| 454 | |
| 455 | |
| 456 | bool CodeBlock::compile(const char *codeFileName, StringTableEntry fileName, const char *inScript, bool overrideNoDso) |
| 457 | { |
| 458 | AssertFatal(Con::isMainThread(), "Compiling code on a secondary thread"); |
| 459 | |
| 460 | // This will return true, but return value is ignored |
| 461 | char *script; |
| 462 | chompUTF8BOM( inScript, &script ); |
| 463 | |
| 464 | gSyntaxError = false; |
| 465 | |
| 466 | consoleAllocReset(); |
| 467 | |
| 468 | STEtoCode = compileSTEtoCode; |
| 469 | |
| 470 | gStatementList = NULL; |
| 471 | gAnonFunctionList = NULL; |
| 472 | |
| 473 | // Set up the parser. |
| 474 | smCurrentParser = getParserForFile(fileName); |
| 475 | AssertISV(smCurrentParser, avar("CodeBlock::compile - no parser available for '%s'!", fileName)); |
| 476 | |
| 477 | // Now do some parsing. |
| 478 | smCurrentParser->setScanBuffer(script, fileName); |
| 479 | smCurrentParser->restart(NULL); |
| 480 | smCurrentParser->parse(); |
| 481 | if (gStatementList) |
| 482 | { |
| 483 | if (gAnonFunctionList) |
| 484 | { |
| 485 | // Prepend anonymous functions to statement list, so they're defined already when |
| 486 | // the statements run. |
| 487 | gAnonFunctionList->append(gStatementList); |
| 488 | gStatementList = gAnonFunctionList; |
| 489 | } |
| 490 | } |
| 491 | |
| 492 | |
| 493 | if(gSyntaxError) |
| 494 | { |
| 495 | consoleAllocReset(); |
| 496 | return false; |
| 497 | } |
| 498 | |
| 499 | #ifdef TORQUE_NO_DSO_GENERATION |
| 500 | if(!overrideNoDso) |
| 501 | return false; |
| 502 | #endif // !TORQUE_NO_DSO_GENERATION |
| 503 | |
| 504 | FileStream st; |
| 505 | if(!st.open(codeFileName, Torque::FS::File::Write)) |
| 506 | return false; |
| 507 | st.write(U32(Con::DSOVersion)); |
| 508 | |
| 509 | // Reset all our value tables... |
| 510 | resetTables(); |
| 511 | |
| 512 | smInFunction = false; |
| 513 |
nothing calls this directly
no test coverage detected