| 571 | } |
| 572 | |
| 573 | ConsoleValueRef 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); |
no test coverage detected