diff --git a/src/main/java/me/topchetoeu/jscript/compilation/JavaScript.java b/src/main/java/me/topchetoeu/jscript/compilation/JavaScript.java index 2fd20e0..d28dcd5 100644 --- a/src/main/java/me/topchetoeu/jscript/compilation/JavaScript.java +++ b/src/main/java/me/topchetoeu/jscript/compilation/JavaScript.java @@ -253,21 +253,21 @@ public final class JavaScript { return !JavaScript.reserved.contains(name); } - public static CompileResult compile(Environment env, Node ...statements) { + public static CompileResult compile(Environment env, boolean passthrough, Node ...statements) { env = env.child(); env.add(COMPILE_ROOT, env); var func = new FunctionValueNode(null, null, Arrays.asList(), new CompoundNode(null, statements), null); - var res = func.compileBody(env, new FunctionScope(true), true, null); + var res = func.compileBody(env, new FunctionScope(passthrough), true, null); return res; } - public static CompileResult compile(Environment env, Filename filename, String raw) { - return JavaScript.compile(env, JavaScript.parse(env, filename, raw)); + public static CompileResult compile(Environment env, Filename filename, String raw, boolean passthrough) { + return JavaScript.compile(env, passthrough, JavaScript.parse(env, filename, raw)); } - public static CompileResult compile(Filename filename, String raw) { + public static CompileResult compile(Filename filename, String raw, boolean passthrough) { var env = new Environment(); - return JavaScript.compile(env, JavaScript.parse(env, filename, raw)); + return JavaScript.compile(env, passthrough, JavaScript.parse(env, filename, raw)); } public static ParseRes parseLabel(Source src, int i) { diff --git a/src/main/java/me/topchetoeu/jscript/runtime/Compiler.java b/src/main/java/me/topchetoeu/jscript/runtime/Compiler.java index ccc130c..852d160 100644 --- a/src/main/java/me/topchetoeu/jscript/runtime/Compiler.java +++ b/src/main/java/me/topchetoeu/jscript/runtime/Compiler.java @@ -15,7 +15,7 @@ import me.topchetoeu.jscript.runtime.values.functions.CodeFunction; public interface Compiler { public static final Compiler DEFAULT = (env, filename, raw) -> { try { - var res = JavaScript.compile(env, filename, raw); + var res = JavaScript.compile(env, filename, raw, true); var body = res.body(); DebugContext.get(env).onSource(filename, raw); registerFunc(env, body, res);