MCPcopy Create free account
hub / github.com/adventuregamestudio/ags / LinkGlobalScripts

Function LinkGlobalScripts

Engine/script/script.cpp:228–285  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

226}
227
228bool LinkGlobalScripts()
229{
230 ccSetOption(SCOPT_AUTOIMPORT, 1);
231
232 // NOTE: this function assumes that the module lists have their elements preallocated!
233
234 std::vector<RuntimeScript*> all_insts; // gather all to resolve exports below
235 for (size_t i = 0; i < numScriptModules; ++i)
236 {
237 all_insts.push_back(scriptModules[i].get());
238 }
239
240 all_insts.push_back(gamescript.get());
241
242 if (dialogScriptsScript)
243 {
244 all_insts.push_back(dialogScriptsScript.get());
245 }
246
247 //
248 // Script linking stage
249 // Register all the script exports
250 for (auto &inst : all_insts)
251 {
252 inst->RegisterExports(simp);
253 }
254 // Resolve all the script imports (these include both engine API and script exports)
255 for (auto &inst : all_insts)
256 {
257 if (!inst->ResolveImports(simp))
258 return false;
259 }
260
261 // Record addresses for 'repeatedly_execute'
262 // TODO: find out why do we have to do that here
263 for (size_t module_idx = 0; module_idx < numScriptModules; module_idx++)
264 {
265 moduleRepExecAddr[module_idx] = scriptModules[module_idx]->GetSymbolAddress(REP_EXEC_NAME);
266 }
267
268 ccSetOption(SCOPT_AUTOIMPORT, 0);
269
270 // Register built-in types under simple aliases for dynamic cast feature
271 // TODO: maybe find a better place to do this? should be done after JointRTTI is created though
272 SetupBuiltinTypeAliases();
273
274 // Optionally dump script's TOC into the log
275 if (logScriptTOC)
276 {
277 for (const auto &inst : all_insts)
278 {
279 if (inst->GetTOC())
280 Debug::Printf(PrintScriptTOC(*inst->GetTOC(), inst->GetScriptName().GetCStr()));
281 }
282 }
283
284 return true;
285}

Callers 2

DoAfterRestoreFunction · 0.85
InitGameStateFunction · 0.85

Calls 10

ccSetOptionFunction · 0.85
SetupBuiltinTypeAliasesFunction · 0.85
PrintfFunction · 0.85
PrintScriptTOCFunction · 0.85
RegisterExportsMethod · 0.80
ResolveImportsMethod · 0.80
GetSymbolAddressMethod · 0.80
GetTOCMethod · 0.80
GetCStrMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected