| 487 | |
| 488 | |
| 489 | bool CodeBlock::compile(const char *codeFileName, StringTableEntry fileName, const char *inScript, bool overrideNoDso) |
| 490 | { |
| 491 | AssertFatal(Con::isMainThread(), "Compiling code on a secondary thread"); |
| 492 | |
| 493 | // This will return true, but return value is ignored |
| 494 | char *script; |
| 495 | chompUTF8BOM(inScript, &script); |
| 496 | |
| 497 | gSyntaxError = false; |
| 498 | gIsEvalCompile = false; |
| 499 | gFuncVars = NULL; |
| 500 | |
| 501 | consoleAllocReset(); |
| 502 | |
| 503 | STEtoCode = compileSTEtoCode; |
| 504 | |
| 505 | gStatementList = NULL; |
| 506 | |
| 507 | // Set up the parser. |
| 508 | smCurrentParser = getParserForFile(fileName); |
| 509 | AssertISV(smCurrentParser, avar("CodeBlock::compile - no parser available for '%s'!", fileName)); |
| 510 | |
| 511 | // Now do some parsing. |
| 512 | smCurrentParser->setScanBuffer(script, fileName); |
| 513 | smCurrentParser->restart(NULL); |
| 514 | smCurrentParser->parse(); |
| 515 | |
| 516 | if (gSyntaxError) |
| 517 | { |
| 518 | consoleAllocReset(); |
| 519 | return false; |
| 520 | } |
| 521 | |
| 522 | #ifdef TORQUE_NO_DSO_GENERATION |
| 523 | if (!overrideNoDso) |
| 524 | return false; |
| 525 | #endif // !TORQUE_NO_DSO_GENERATION |
| 526 | |
| 527 | FileStream st; |
| 528 | if (!st.open(codeFileName, Torque::FS::File::Write)) |
| 529 | return false; |
| 530 | st.write(U32(Con::DSOVersion)); |
| 531 | |
| 532 | // Reset all our value tables... |
| 533 | resetTables(); |
| 534 | |
| 535 | smInFunction = false; |
| 536 | |
| 537 | CodeStream codeStream; |
| 538 | U32 lastIp; |
| 539 | if (gStatementList) |
| 540 | { |
| 541 | lastIp = compileBlock(gStatementList, codeStream, 0) + 1; |
| 542 | } |
| 543 | else |
| 544 | { |
| 545 | codeSize = 1; |
| 546 | lastIp = 0; |
nothing calls this directly
no test coverage detected