MCPcopy Create free account
hub / github.com/anjo76/angelscript / Build

Method Build

sdk/angelscript/source/as_builder.cpp:300–354  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

298}
299
300int asCBuilder::Build()
301{
302 Reset();
303
304 // The template callbacks must only be called after the subtypes have a known structure,
305 // otherwise the callback may think it is not possible to create the template instance,
306 // even though it is.
307 // TODO: This flag shouldn't be set globally in the engine, as it would mean that another
308 // thread requesting a template instance in parallel to the compilation wouldn't
309 // evaluate the template instance.
310 engine->deferValidationOfTemplateTypes = true;
311 asUINT numTempl = (asUINT)engine->templateInstanceTypes.GetLength();
312
313 ParseScripts();
314 if (numErrors > 0)
315 return asERROR;
316
317 // Compile the types first
318 CompileInterfaces();
319 CompileClasses(numTempl);
320
321 // Evaluate the template instances one last time, this time with error messages, as we know
322 // all classes have been fully built and it is known which ones will need garbage collection.
323 EvaluateTemplateInstances(numTempl, false);
324 engine->deferValidationOfTemplateTypes = false;
325 if (numErrors > 0)
326 return asERROR;
327
328 // Then the global variables. Here the variables declared with auto
329 // will be resolved, so they can be accessed properly in the functions
330 CompileGlobalVariables();
331
332 // Finally the global functions and class methods
333 CompileFunctions();
334
335 // TODO: Attempt to reorder the initialization of global variables so that
336 // they do not access other uninitialized global variables out-of-order
337 // The builder needs to check for each of the global variable, what functions
338 // that are accessed, and what global variables are access by these functions.
339
340 if( numWarnings > 0 && engine->ep.compilerWarnings == 2 )
341 WriteError(TXT_WARNINGS_TREATED_AS_ERROR, 0, 0);
342
343 if( numErrors > 0 )
344 return asERROR;
345
346 // Make sure something was compiled, otherwise return an error
347 if( module->IsEmpty() )
348 {
349 WriteError(TXT_NOTHING_WAS_BUILT, 0, 0);
350 return asERROR;
351 }
352
353 return asSUCCESS;
354}
355
356int asCBuilder::CompileGlobalVar(const char *sectionName, const char *code, int lineOffset)
357{

Callers

nothing calls this directly

Calls 2

GetLengthMethod · 0.45
IsEmptyMethod · 0.45

Tested by

no test coverage detected