Переглянути джерело

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

Note that we don't yet support nested calls using bytecode.
Andreas Kling 4 роки тому
батько
коміт
2316a084bf
1 змінених файлів з 11 додано та 0 видалено
  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);
     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());
     m_registers.resize(block.register_count());
 
 
     size_t pc = 0;
     size_t pc = 0;