summaryrefslogtreecommitdiff
path: root/Libraries/LibJS/AST.cpp
diff options
context:
space:
mode:
authorMatthew Olsson <matthewcolsson@gmail.com>2020-10-03 17:02:43 -0700
committerAndreas Kling <kling@serenityos.org>2020-10-04 10:46:12 +0200
commit6eb6752c4cb8bc339bdd5af51d3673ea6d100300 (patch)
tree8071cc11d994dbf756958722f02d2ea66dd72470 /Libraries/LibJS/AST.cpp
parent1b3f9c170c6f047ddad879bcd278cf0c8beb2d6c (diff)
downloadserenity-6eb6752c4cb8bc339bdd5af51d3673ea6d100300.zip
LibJS: Strict mode is now handled by Functions and Programs, not Blocks
Since blocks can't be strict by themselves, it makes no sense for them to store whether or not they are strict. Strict-ness is now stored in the Program and FunctionNode ASTNodes. Fixes issue #3641
Diffstat (limited to 'Libraries/LibJS/AST.cpp')
-rw-r--r--Libraries/LibJS/AST.cpp7
1 files changed, 6 insertions, 1 deletions
diff --git a/Libraries/LibJS/AST.cpp b/Libraries/LibJS/AST.cpp
index a8a1b44cdc..ccdb818d1b 100644
--- a/Libraries/LibJS/AST.cpp
+++ b/Libraries/LibJS/AST.cpp
@@ -89,6 +89,11 @@ Value ScopeNode::execute(Interpreter& interpreter, GlobalObject& global_object)
return interpreter.execute_statement(global_object, *this);
}
+Value Program::execute(Interpreter& interpreter, GlobalObject& global_object) const
+{
+ return interpreter.execute_statement(global_object, *this, {}, ScopeType::Block, m_is_strict_mode);
+}
+
Value FunctionDeclaration::execute(Interpreter&, GlobalObject&) const
{
return js_undefined();
@@ -96,7 +101,7 @@ Value FunctionDeclaration::execute(Interpreter&, GlobalObject&) const
Value FunctionExpression::execute(Interpreter& interpreter, GlobalObject& global_object) const
{
- return ScriptFunction::create(global_object, name(), body(), parameters(), function_length(), interpreter.current_environment(), m_is_arrow_function);
+ return ScriptFunction::create(global_object, name(), body(), parameters(), function_length(), interpreter.current_environment(), is_strict_mode(), m_is_arrow_function);
}
Value ExpressionStatement::execute(Interpreter& interpreter, GlobalObject& global_object) const