mirror of
https://github.com/RGBCube/serenity
synced 2025-05-19 17:45:08 +00:00
LibJS: Allow functions to take arguments (#1405)
This commit is contained in:
parent
425fd3ce51
commit
01133733dd
7 changed files with 46 additions and 14 deletions
|
@ -42,9 +42,9 @@ Interpreter::~Interpreter()
|
|||
{
|
||||
}
|
||||
|
||||
Value Interpreter::run(const ScopeNode& scope_node, ScopeType scope_type)
|
||||
Value Interpreter::run(const ScopeNode& scope_node, HashMap<String, Value> scope_variables, ScopeType scope_type)
|
||||
{
|
||||
enter_scope(scope_node, scope_type);
|
||||
enter_scope(scope_node, move(scope_variables), scope_type);
|
||||
|
||||
Value last_value = js_undefined();
|
||||
for (auto& node : scope_node.children()) {
|
||||
|
@ -55,9 +55,9 @@ Value Interpreter::run(const ScopeNode& scope_node, ScopeType scope_type)
|
|||
return last_value;
|
||||
}
|
||||
|
||||
void Interpreter::enter_scope(const ScopeNode& scope_node, ScopeType scope_type)
|
||||
void Interpreter::enter_scope(const ScopeNode& scope_node, HashMap<String, Value> scope_variables, ScopeType scope_type)
|
||||
{
|
||||
m_scope_stack.append({ scope_type, scope_node, {} });
|
||||
m_scope_stack.append({ scope_type, scope_node, move(scope_variables) });
|
||||
}
|
||||
|
||||
void Interpreter::exit_scope(const ScopeNode& scope_node)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue