/* * Copyright (c) 2021, Andreas Kling * * SPDX-License-Identifier: BSD-2-Clause */ #include #include #include #include #include #include #include #include #include #include #include namespace JS::Bytecode { bool g_dump_bytecode = false; Interpreter::Interpreter(VM& vm) : m_vm(vm) { } Interpreter::~Interpreter() { } void Interpreter::visit_edges(Cell::Visitor& visitor) { for (auto& frame : m_call_frames) { frame.visit([&](auto& value) { value->visit_edges(visitor); }); } } // 16.1.6 ScriptEvaluation ( scriptRecord ), https://tc39.es/ecma262/#sec-runtime-semantics-scriptevaluation ThrowCompletionOr Interpreter::run(Script& script_record, JS::GCPtr lexical_environment_override) { auto& vm = this->vm(); // 1. Let globalEnv be scriptRecord.[[Realm]].[[GlobalEnv]]. auto& global_environment = script_record.realm().global_environment(); // 2. Let scriptContext be a new ECMAScript code execution context. ExecutionContext script_context(vm.heap()); // 3. Set the Function of scriptContext to null. // NOTE: This was done during execution context construction. // 4. Set the Realm of scriptContext to scriptRecord.[[Realm]]. script_context.realm = &script_record.realm(); // 5. Set the ScriptOrModule of scriptContext to scriptRecord. script_context.script_or_module = NonnullGCPtr