1
Fork 0
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:
howar6hill 2020-03-12 19:22:13 +08:00 committed by GitHub
parent 425fd3ce51
commit 01133733dd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 46 additions and 14 deletions

View file

@ -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)