| 595 | } |
| 596 | |
| 597 | ConsoleValue CodeBlock::compileExec(StringTableEntry fileName, const char *inString, bool noCalls, S32 setFrame) |
| 598 | { |
| 599 | AssertFatal(Con::isMainThread(), "Compiling code on a secondary thread"); |
| 600 | |
| 601 | // Check for a UTF8 script file |
| 602 | char *string; |
| 603 | chompUTF8BOM(inString, &string); |
| 604 | |
| 605 | STEtoCode = evalSTEtoCode; |
| 606 | consoleAllocReset(); |
| 607 | |
| 608 | name = fileName; |
| 609 | |
| 610 | if (fileName) |
| 611 | { |
| 612 | const StringTableEntry exePath = Platform::getMainDotCsDir(); |
| 613 | const StringTableEntry cwd = Platform::getCurrentDirectory(); |
| 614 | |
| 615 | fullPath = NULL; |
| 616 | |
| 617 | if (Platform::isFullPath(fileName)) |
| 618 | fullPath = fileName; |
| 619 | |
| 620 | if (dStrnicmp(exePath, fileName, dStrlen(exePath)) == 0) |
| 621 | name = StringTable->insert(fileName + dStrlen(exePath) + 1, true); |
| 622 | else if (dStrnicmp(cwd, fileName, dStrlen(cwd)) == 0) |
| 623 | name = StringTable->insert(fileName + dStrlen(cwd) + 1, true); |
| 624 | |
| 625 | if (fullPath == NULL) |
| 626 | { |
| 627 | char buf[1024]; |
| 628 | fullPath = StringTable->insert(Platform::makeFullPathName(fileName, buf, sizeof(buf)), true); |
| 629 | } |
| 630 | |
| 631 | modPath = Con::getModNameFromPath(fileName); |
| 632 | } |
| 633 | |
| 634 | if (name) |
| 635 | addToCodeList(); |
| 636 | |
| 637 | gStatementList = NULL; |
| 638 | |
| 639 | // we are an eval compile if we don't have a file name associated (no exec) |
| 640 | gIsEvalCompile = fileName == NULL; |
| 641 | gFuncVars = gIsEvalCompile ? &gEvalFuncVars : &gGlobalScopeFuncVars; |
| 642 | |
| 643 | // Set up the parser. |
| 644 | smCurrentParser = getParserForFile(fileName); |
| 645 | AssertISV(smCurrentParser, avar("CodeBlock::compile - no parser available for '%s'!", fileName)); |
| 646 | |
| 647 | // Now do some parsing. |
| 648 | smCurrentParser->setScanBuffer(string, fileName); |
| 649 | smCurrentParser->restart(NULL); |
| 650 | smCurrentParser->parse(); |
| 651 | |
| 652 | if (!gStatementList) |
| 653 | { |
| 654 | delete this; |
no test coverage detected