|
@@ -72,6 +72,7 @@ Value Interpreter::run(GlobalObject& global_object, const Program& program)
|
|
|
global_call_frame.function_name = "(global execution context)";
|
|
|
global_call_frame.environment = heap().allocate<LexicalEnvironment>(global_object, LexicalEnvironment::EnvironmentRecordType::Global);
|
|
|
global_call_frame.environment->bind_this_value(global_object, &global_object);
|
|
|
+ global_call_frame.is_strict_mode = program.is_strict_mode();
|
|
|
if (vm().exception())
|
|
|
return {};
|
|
|
vm().call_stack().append(move(global_call_frame));
|
|
@@ -91,15 +92,15 @@ const GlobalObject& Interpreter::global_object() const
|
|
|
return static_cast<const GlobalObject&>(*m_global_object.cell());
|
|
|
}
|
|
|
|
|
|
-void Interpreter::enter_scope(const ScopeNode& scope_node, ArgumentVector arguments, ScopeType scope_type, GlobalObject& global_object, bool is_strict)
|
|
|
+void Interpreter::enter_scope(const ScopeNode& scope_node, ArgumentVector arguments, ScopeType scope_type, GlobalObject& global_object)
|
|
|
{
|
|
|
for (auto& declaration : scope_node.functions()) {
|
|
|
- auto* function = ScriptFunction::create(global_object, declaration.name(), declaration.body(), declaration.parameters(), declaration.function_length(), current_environment(), is_strict);
|
|
|
+ auto* function = ScriptFunction::create(global_object, declaration.name(), declaration.body(), declaration.parameters(), declaration.function_length(), current_environment(), declaration.is_strict_mode());
|
|
|
vm().set_variable(declaration.name(), function, global_object);
|
|
|
}
|
|
|
|
|
|
if (scope_type == ScopeType::Function) {
|
|
|
- push_scope({ scope_type, scope_node, false, is_strict });
|
|
|
+ push_scope({ scope_type, scope_node, false });
|
|
|
return;
|
|
|
}
|
|
|
|
|
@@ -130,7 +131,7 @@ void Interpreter::enter_scope(const ScopeNode& scope_node, ArgumentVector argume
|
|
|
pushed_lexical_environment = true;
|
|
|
}
|
|
|
|
|
|
- push_scope({ scope_type, scope_node, pushed_lexical_environment, is_strict });
|
|
|
+ push_scope({ scope_type, scope_node, pushed_lexical_environment });
|
|
|
}
|
|
|
|
|
|
void Interpreter::exit_scope(const ScopeNode& scope_node)
|
|
@@ -150,18 +151,16 @@ void Interpreter::exit_scope(const ScopeNode& scope_node)
|
|
|
|
|
|
void Interpreter::push_scope(ScopeFrame frame)
|
|
|
{
|
|
|
- if (in_strict_mode())
|
|
|
- frame.is_strict_mode = true;
|
|
|
m_scope_stack.append(move(frame));
|
|
|
}
|
|
|
|
|
|
-Value Interpreter::execute_statement(GlobalObject& global_object, const Statement& statement, ArgumentVector arguments, ScopeType scope_type, bool is_strict)
|
|
|
+Value Interpreter::execute_statement(GlobalObject& global_object, const Statement& statement, ArgumentVector arguments, ScopeType scope_type)
|
|
|
{
|
|
|
if (!statement.is_scope_node())
|
|
|
return statement.execute(*this, global_object);
|
|
|
|
|
|
auto& block = static_cast<const ScopeNode&>(statement);
|
|
|
- enter_scope(block, move(arguments), scope_type, global_object, is_strict);
|
|
|
+ enter_scope(block, move(arguments), scope_type, global_object);
|
|
|
|
|
|
if (block.children().is_empty())
|
|
|
vm().set_last_value({}, js_undefined());
|