MCPcopy Create free account
hub / github.com/aardappel/treesheets / EngineRunByteCode

Function EngineRunByteCode

lobster/src/engine.cpp:88–124  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

86}
87
88void EngineRunByteCode(VMArgs &&vmargs) {
89 lobster::VM vm(std::move(vmargs));
90 #ifdef USE_EXCEPTION_HANDLING
91 try
92 #endif
93 {
94 vm.EvalProgram();
95 }
96 #ifdef USE_EXCEPTION_HANDLING
97 catch (string &s) {
98 #ifdef USE_MAIN_LOOP_CALLBACK
99 if (s == "SUSPEND-VM-MAINLOOP") {
100 // emscripten requires that we don't control the main loop.
101 // We just got to the start of the first frame inside gl_frame(), and the VM is suspended.
102 // Install the one-frame callback:
103 #ifdef __EMSCRIPTEN__
104 // This has a better explanation of the last argument than the emscripten docs:
105 // http://flohofwoe.blogspot.com/2013/09/emscripten-and-pnacl-app-entry-in.html
106 // We're passing true as last argument, which means emscripten is not going to
107 // return from this function until completely done, emulating behavior as if we
108 // control the main loop. What it really does is throw a JS exception to escape from
109 // C++ execution, leaving this main loop in a frozen state to later return to.
110 emscripten_set_main_loop_arg(one_frame_callback, &vm, 0, true);
111 // When we return here, we're done and exit normally.
112 #else
113 // Emulate this behavior so we can debug it.
114 while (vm.evalret == "") one_frame_callback(&vm);
115 #endif
116 } else
117 #endif
118 {
119 // An actual error.
120 THROW_OR_ABORT(s);
121 }
122 }
123 #endif
124}
125
126extern "C" int EngineRunCompiledCodeMain(int argc, char *argv[], const void *entry_point,
127 const void *bytecodefb, size_t static_size,

Callers 2

mainFunction · 0.85

Calls 1

EvalProgramMethod · 0.80

Tested by

no test coverage detected