Skip to content

Commit c79d769

Browse files
committed
Make built-in functions read-only. Closes #42
1 parent f28d51d commit c79d769

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/interpreter.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,8 @@ export class Interpreter {
147147
}
148148

149149
private readonly init: InitFunc = (interpreter, scope) => {
150+
scope.toString = () => "#GlobalScope";
151+
150152
let currentColor = "black";
151153
prop("color", {
152154
get: fn(() => currentColor),
@@ -323,7 +325,7 @@ export class Interpreter {
323325
}
324326

325327
function setFn(name: string, fnWrapper: Function) {
326-
interpreter.setProperty(scope, name, fn(fnWrapper));
328+
interpreter.setProperty(scope, name, fn(fnWrapper), JSInterpreter.READONLY_NONENUMERABLE_DESCRIPTOR);
327329
}
328330
function fn(wrapper: Function) {
329331
return interpreter.createNativeFunction(wrapper);

0 commit comments

Comments
 (0)