Skip to content

Commit

Permalink
new way of handling scope/vars
Browse files Browse the repository at this point in the history
  • Loading branch information
drom committed Mar 12, 2023
1 parent e337525 commit ce06c6c
Showing 1 changed file with 26 additions and 14 deletions.
40 changes: 26 additions & 14 deletions lib/dom-container.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,20 +36,32 @@ const getFullView = desc => {

const arr = [];

const rec = obj => {
Object.keys(obj).map(name => {
const ref = obj[name];
if (typeof ref === 'object') {
arr.push(name);
rec(ref);
arr.push('..');
return;
}
if (typeof ref !== 'string') {
throw new Error();
}
arr.push(name);
});
const rec = ero => {
if (ero.kind === 'scope') {
arr.push(ero.name);
ero.body.map(rec);
arr.push('..');
return;
}
if (ero.kind === 'var') {
arr.push(ero.name);
return;
}
console.error(ero);
throw new Error();
// Object.keys(obj).map(name => {
// const ref = obj[name];
// if (typeof ref === 'object') {
// arr.push(name);
// rec(ref);
// arr.push('..');
// return;
// }
// if (typeof ref !== 'string') {
// throw new Error();
// }
// arr.push(name);
// });
};

rec(desc.wires);
Expand Down

0 comments on commit ce06c6c

Please sign in to comment.