Skip to content

Commit

Permalink
show [function] as function on the console
Browse files Browse the repository at this point in the history
  • Loading branch information
taisukef committed Jan 5, 2025
1 parent 861ed6b commit d608815
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
13 changes: 13 additions & 0 deletions DNCL3.js
Original file line number Diff line number Diff line change
Expand Up @@ -1054,4 +1054,17 @@ export class DNCL3 {
throw new Error("対応していない expression type が使われました。 " + ast.type);
}
}
getVars() {
const res = {};
for (const name in this.vars) {
const o = this.vars[name];
console.log(name, typeof o, o.type)
if (typeof o == "object" && o.type == "FunctionDeclaration") {
res[name] = "[function]";
} else {
res[name] = o;
}
}
return res;
}
}
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ <h1>DNCL3実行環境</h1>
dncl.run();
if (chkvar.checked) {
console.log(dncl.vars)
run.setValue(run.getValue() + "\nvars " + JSON.stringify(dncl.vars, null, 2) + "\n");
run.setValue(run.getValue() + "\nvars " + JSON.stringify(dncl.getVars(), null, 2) + "\n");
}
} catch (e) {
console.log(e);
Expand Down

0 comments on commit d608815

Please sign in to comment.