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

Method compileExec

Engine/source/console/codeBlock.cpp:573–673  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

571}
572
573ConsoleValueRef CodeBlock::compileExec(StringTableEntry fileName, const char *inString, bool noCalls, S32 setFrame)
574{
575 AssertFatal(Con::isMainThread(), "Compiling code on a secondary thread");
576
577 // Check for a UTF8 script file
578 char *string;
579 chompUTF8BOM( inString, &string );
580
581 STEtoCode = evalSTEtoCode;
582 consoleAllocReset();
583
584 name = fileName;
585
586 if(fileName)
587 {
588 const StringTableEntry exePath = Platform::getMainDotCsDir();
589 const StringTableEntry cwd = Platform::getCurrentDirectory();
590
591 fullPath = NULL;
592
593 if(Platform::isFullPath(fileName))
594 fullPath = fileName;
595
596 if(dStrnicmp(exePath, fileName, dStrlen(exePath)) == 0)
597 name = StringTable->insert(fileName + dStrlen(exePath) + 1, true);
598 else if(dStrnicmp(cwd, fileName, dStrlen(cwd)) == 0)
599 name = StringTable->insert(fileName + dStrlen(cwd) + 1, true);
600
601 if(fullPath == NULL)
602 {
603 char buf[1024];
604 fullPath = StringTable->insert(Platform::makeFullPathName(fileName, buf, sizeof(buf)), true);
605 }
606
607 modPath = Con::getModNameFromPath(fileName);
608 }
609
610 if(name)
611 addToCodeList();
612
613 gStatementList = NULL;
614 gAnonFunctionList = NULL;
615
616 // Set up the parser.
617 smCurrentParser = getParserForFile(fileName);
618 AssertISV(smCurrentParser, avar("CodeBlock::compile - no parser available for '%s'!", fileName));
619
620 // Now do some parsing.
621 smCurrentParser->setScanBuffer(string, fileName);
622 smCurrentParser->restart(NULL);
623 smCurrentParser->parse();
624 if (gStatementList)
625 {
626 if (gAnonFunctionList)
627 {
628 // Prepend anonymous functions to statement list, so they're defined already when
629 // the statements run.
630 gAnonFunctionList->append(gStatementList);

Callers 4

executeFileFunction · 0.80
evaluateFunction · 0.80
evaluatefFunction · 0.80
evaluateExpressionMethod · 0.80

Calls 15

isMainThreadFunction · 0.85
chompUTF8BOMFunction · 0.85
consoleAllocResetFunction · 0.85
dStrnicmpFunction · 0.85
getModNameFromPathFunction · 0.85
getParserForFileFunction · 0.85
avarFunction · 0.85
resetTablesFunction · 0.85
compileBlockFunction · 0.85
warnfFunction · 0.85
getNumLineBreaksMethod · 0.80
emitMethod · 0.80

Tested by

no test coverage detected