MCPcopy Create free account
hub / github.com/GarageGames/Torque3D / compile

Method compile

Engine/source/console/codeBlock.cpp:456–571  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

454
455
456bool CodeBlock::compile(const char *codeFileName, StringTableEntry fileName, const char *inScript, bool overrideNoDso)
457{
458 AssertFatal(Con::isMainThread(), "Compiling code on a secondary thread");
459
460 // This will return true, but return value is ignored
461 char *script;
462 chompUTF8BOM( inScript, &script );
463
464 gSyntaxError = false;
465
466 consoleAllocReset();
467
468 STEtoCode = compileSTEtoCode;
469
470 gStatementList = NULL;
471 gAnonFunctionList = NULL;
472
473 // Set up the parser.
474 smCurrentParser = getParserForFile(fileName);
475 AssertISV(smCurrentParser, avar("CodeBlock::compile - no parser available for '%s'!", fileName));
476
477 // Now do some parsing.
478 smCurrentParser->setScanBuffer(script, fileName);
479 smCurrentParser->restart(NULL);
480 smCurrentParser->parse();
481 if (gStatementList)
482 {
483 if (gAnonFunctionList)
484 {
485 // Prepend anonymous functions to statement list, so they're defined already when
486 // the statements run.
487 gAnonFunctionList->append(gStatementList);
488 gStatementList = gAnonFunctionList;
489 }
490 }
491
492
493 if(gSyntaxError)
494 {
495 consoleAllocReset();
496 return false;
497 }
498
499#ifdef TORQUE_NO_DSO_GENERATION
500 if(!overrideNoDso)
501 return false;
502#endif // !TORQUE_NO_DSO_GENERATION
503
504 FileStream st;
505 if(!st.open(codeFileName, Torque::FS::File::Write))
506 return false;
507 st.write(U32(Con::DSOVersion));
508
509 // Reset all our value tables...
510 resetTables();
511
512 smInFunction = false;
513

Callers

nothing calls this directly

Calls 15

isMainThreadFunction · 0.85
chompUTF8BOMFunction · 0.85
consoleAllocResetFunction · 0.85
getParserForFileFunction · 0.85
avarFunction · 0.85
resetTablesFunction · 0.85
compileBlockFunction · 0.85
errorfFunction · 0.85
emitMethod · 0.80
emitCodeStreamMethod · 0.80
getNumLineBreaksMethod · 0.80
U32Enum · 0.50

Tested by

no test coverage detected