Procházet zdrojové kódy

LibJS: Create a global/outermost CallFrame for Bytecode::Interpreter

Note that we don't yet support nested calls using bytecode.
Andreas Kling před 4 roky
rodič
revize
2316a084bf
1 změnil soubory, kde provedl 11 přidání a 0 odebrání
  1. 11 0
      Userland/Libraries/LibJS/Bytecode/Interpreter.cpp

+ 11 - 0
Userland/Libraries/LibJS/Bytecode/Interpreter.cpp

@@ -25,6 +25,17 @@ void Interpreter::run(Bytecode::Block const& block)
 {
     dbgln("Bytecode::Interpreter will run block {:p}", &block);
 
+    CallFrame global_call_frame;
+    global_call_frame.this_value = &global_object();
+    static FlyString global_execution_context_name = "(*BC* global execution context)";
+    global_call_frame.function_name = global_execution_context_name;
+    global_call_frame.scope = &global_object();
+    VERIFY(!vm().exception());
+    // FIXME: How do we know if we're in strict mode? Maybe the Bytecode::Block should know this?
+    // global_call_frame.is_strict_mode = ???;
+    vm().push_call_frame(global_call_frame, global_object());
+    VERIFY(!vm().exception());
+
     m_registers.resize(block.register_count());
 
     size_t pc = 0;