From 0d6be2cac2547d9e28f65ba3812322aedc3c5439 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Mon, 9 Mar 2020 21:53:13 +0100 Subject: [PATCH] LibJS: Make FunctionDeclaration and CallExpression scope-aware --- Libraries/LibJS/AST.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Libraries/LibJS/AST.cpp b/Libraries/LibJS/AST.cpp index 4748b69290..00ed1227bf 100644 --- a/Libraries/LibJS/AST.cpp +++ b/Libraries/LibJS/AST.cpp @@ -40,7 +40,7 @@ Value ScopeNode::execute(Interpreter& interpreter) const Value FunctionDeclaration::execute(Interpreter& interpreter) const { auto* function = interpreter.heap().allocate(name(), body()); - interpreter.global_object().put(m_name, Value(function)); + interpreter.set_variable(m_name, Value(function)); return Value(function); } @@ -51,7 +51,7 @@ Value CallExpression::execute(Interpreter& interpreter) const return js_undefined(); } - auto callee = interpreter.global_object().get(name()); + auto callee = interpreter.get_variable(name()); ASSERT(callee.is_object()); auto* callee_object = callee.as_object(); ASSERT(callee_object->is_function());