MCPcopy Create free account
hub / github.com/MayaPosch/NymphCast / CompileScript

Function CompileScript

src/server/angelscript/samples/asrun/source/main.cpp:328–356  ·  view source on GitHub ↗

This is where the script is compiled into bytecode that can be executed

Source from the content-addressed store, hash-verified

326
327// This is where the script is compiled into bytecode that can be executed
328int CompileScript(asIScriptEngine *engine, const char *scriptFile)
329{
330 int r;
331
332 // We will only initialize the global variables once we're
333 // ready to execute, so disable the automatic initialization
334 engine->SetEngineProperty(asEP_INIT_GLOBAL_VARS_AFTER_BUILD, false);
335
336 CScriptBuilder builder;
337
338 // Set the pragma callback so we can detect if the script needs debugging
339 builder.SetPragmaCallback(PragmaCallback, 0);
340
341 // Compile the script
342 r = builder.StartNewModule(engine, "script");
343 if( r < 0 ) return -1;
344
345 r = builder.AddSectionFromFile(scriptFile);
346 if( r < 0 ) return -1;
347
348 r = builder.BuildModule();
349 if( r < 0 )
350 {
351 engine->WriteMessage(scriptFile, 0, 0, asMSGTYPE_ERROR, "Script failed to build");
352 return -1;
353 }
354
355 return 0;
356}
357
358// Execute the script by calling the main() function
359int ExecuteScript(asIScriptEngine *engine, const char *scriptFile)

Callers 1

mainFunction · 0.70

Calls 6

SetEnginePropertyMethod · 0.80
SetPragmaCallbackMethod · 0.80
StartNewModuleMethod · 0.80
AddSectionFromFileMethod · 0.80
BuildModuleMethod · 0.80
WriteMessageMethod · 0.80

Tested by

no test coverage detected