| 476 | |
| 477 | |
| 478 | bool CodeBlock::compile(const char *codeFileName, StringTableEntry fileName, const char *script) |
| 479 | { |
| 480 | gSyntaxError = false; |
| 481 | |
| 482 | consoleAllocReset(); |
| 483 | |
| 484 | STEtoCode = compileSTEtoCode; |
| 485 | |
| 486 | statementList = NULL; |
| 487 | |
| 488 | // Set up the parser. |
| 489 | smCurrentParser = getParserForFile(fileName); |
| 490 | AssertISV(smCurrentParser, avar("CodeBlock::compile - no parser available for '%s'!", fileName)); |
| 491 | |
| 492 | // Now do some parsing. |
| 493 | smCurrentParser->setScanBuffer(script, fileName); |
| 494 | smCurrentParser->restart(NULL); |
| 495 | smCurrentParser->parse(); |
| 496 | |
| 497 | if(gSyntaxError) |
| 498 | { |
| 499 | consoleAllocReset(); |
| 500 | return false; |
| 501 | } |
| 502 | |
| 503 | FileStream st; |
| 504 | if(!ResourceManager->openFileForWrite(st, codeFileName)) |
| 505 | return false; |
| 506 | st.write(DSO_VERSION); |
| 507 | |
| 508 | // Reset all our value tables... |
| 509 | resetTables(); |
| 510 | |
| 511 | smInFunction = false; |
| 512 | smBreakLineCount = 0; |
| 513 | setBreakCodeBlock(this); |
| 514 | |
| 515 | if(statementList) |
| 516 | codeSize = precompileBlock(statementList, 0) + 1; |
| 517 | else |
| 518 | codeSize = 1; |
| 519 | |
| 520 | lineBreakPairCount = smBreakLineCount; |
| 521 | code = new U32[codeSize + smBreakLineCount * 2]; |
| 522 | lineBreakPairs = code + codeSize; |
| 523 | |
| 524 | // Write string table data... |
| 525 | getGlobalStringTable().write(st); |
| 526 | getFunctionStringTable().write(st); |
| 527 | |
| 528 | // Write float table data... |
| 529 | getGlobalFloatTable().write(st); |
| 530 | getFunctionFloatTable().write(st); |
| 531 | |
| 532 | smBreakLineCount = 0; |
| 533 | U32 lastIp; |
| 534 | if(statementList) |
| 535 | lastIp = compileBlock(statementList, code, 0, 0, 0); |
nothing calls this directly
no test coverage detected