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

Method compile

engine/source/console/codeBlock.cc:478–570  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

476
477
478bool CodeBlock::compile(const char *codeFileName, StringTableEntry fileName, const char *script)
479{
480 gSyntaxError = false;
481
482 consoleAllocReset();
483
484 STEtoCode = compileSTEtoCode;
485
486 statementList = NULL;
487
488 // Set up the parser.
489 smCurrentParser = getParserForFile(fileName);
490 AssertISV(smCurrentParser, avar("CodeBlock::compile - no parser available for '%s'!", fileName));
491
492 // Now do some parsing.
493 smCurrentParser->setScanBuffer(script, fileName);
494 smCurrentParser->restart(NULL);
495 smCurrentParser->parse();
496
497 if(gSyntaxError)
498 {
499 consoleAllocReset();
500 return false;
501 }
502
503 FileStream st;
504 if(!ResourceManager->openFileForWrite(st, codeFileName))
505 return false;
506 st.write(DSO_VERSION);
507
508 // Reset all our value tables...
509 resetTables();
510
511 smInFunction = false;
512 smBreakLineCount = 0;
513 setBreakCodeBlock(this);
514
515 if(statementList)
516 codeSize = precompileBlock(statementList, 0) + 1;
517 else
518 codeSize = 1;
519
520 lineBreakPairCount = smBreakLineCount;
521 code = new U32[codeSize + smBreakLineCount * 2];
522 lineBreakPairs = code + codeSize;
523
524 // Write string table data...
525 getGlobalStringTable().write(st);
526 getFunctionStringTable().write(st);
527
528 // Write float table data...
529 getGlobalFloatTable().write(st);
530 getFunctionFloatTable().write(st);
531
532 smBreakLineCount = 0;
533 U32 lastIp;
534 if(statementList)
535 lastIp = compileBlock(statementList, code, 0, 0, 0);

Callers

nothing calls this directly

Calls 12

consoleAllocResetFunction · 0.85
getParserForFileFunction · 0.85
avarFunction · 0.85
resetTablesFunction · 0.85
setBreakCodeBlockFunction · 0.85
precompileBlockFunction · 0.85
compileBlockFunction · 0.85
errorfFunction · 0.85
parseMethod · 0.45
openFileForWriteMethod · 0.45
writeMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected