codeBlock.cpp 35 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515
  1. //-----------------------------------------------------------------------------
  2. // Copyright (c) 2012 GarageGames, LLC
  3. //
  4. // Permission is hereby granted, free of charge, to any person obtaining a copy
  5. // of this software and associated documentation files (the "Software"), to
  6. // deal in the Software without restriction, including without limitation the
  7. // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
  8. // sell copies of the Software, and to permit persons to whom the Software is
  9. // furnished to do so, subject to the following conditions:
  10. //
  11. // The above copyright notice and this permission notice shall be included in
  12. // all copies or substantial portions of the Software.
  13. //
  14. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  17. // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  18. // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  19. // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
  20. // IN THE SOFTWARE.
  21. //-----------------------------------------------------------------------------
  22. #include "console/console.h"
  23. #include "console/compiler.h"
  24. #include "console/codeBlock.h"
  25. #include "console/telnetDebugger.h"
  26. #include "console/ast.h"
  27. #include "core/strings/unicode.h"
  28. #include "core/strings/stringFunctions.h"
  29. #include "core/stringTable.h"
  30. #include "core/stream/fileStream.h"
  31. using namespace Compiler;
  32. bool CodeBlock::smInFunction = false;
  33. CodeBlock * CodeBlock::smCodeBlockList = NULL;
  34. CodeBlock * CodeBlock::smCurrentCodeBlock = NULL;
  35. ConsoleParser *CodeBlock::smCurrentParser = NULL;
  36. //-------------------------------------------------------------------------
  37. CodeBlock::CodeBlock()
  38. {
  39. globalStrings = NULL;
  40. functionStrings = NULL;
  41. functionStringsMaxLen = 0;
  42. globalStringsMaxLen = 0;
  43. globalFloats = NULL;
  44. functionFloats = NULL;
  45. lineBreakPairs = NULL;
  46. breakList = NULL;
  47. breakListSize = 0;
  48. refCount = 0;
  49. code = NULL;
  50. name = NULL;
  51. fullPath = NULL;
  52. modPath = NULL;
  53. codeSize = 0;
  54. lineBreakPairCount = 0;
  55. nextFile = NULL;
  56. }
  57. CodeBlock::~CodeBlock()
  58. {
  59. // Make sure we aren't lingering in the current code block...
  60. AssertFatal(smCurrentCodeBlock != this, "CodeBlock::~CodeBlock - Caught lingering in smCurrentCodeBlock!");
  61. if (name)
  62. removeFromCodeList();
  63. delete[] const_cast<char*>(globalStrings);
  64. delete[] const_cast<char*>(functionStrings);
  65. functionStringsMaxLen = 0;
  66. globalStringsMaxLen = 0;
  67. delete[] globalFloats;
  68. delete[] functionFloats;
  69. delete[] code;
  70. delete[] breakList;
  71. }
  72. //-------------------------------------------------------------------------
  73. StringTableEntry CodeBlock::getCurrentCodeBlockName()
  74. {
  75. if (CodeBlock::getCurrentBlock())
  76. return CodeBlock::getCurrentBlock()->name;
  77. else
  78. return NULL;
  79. }
  80. StringTableEntry CodeBlock::getCurrentCodeBlockFullPath()
  81. {
  82. if (CodeBlock::getCurrentBlock())
  83. return CodeBlock::getCurrentBlock()->fullPath;
  84. else
  85. return NULL;
  86. }
  87. StringTableEntry CodeBlock::getCurrentCodeBlockModName()
  88. {
  89. if (CodeBlock::getCurrentBlock())
  90. return CodeBlock::getCurrentBlock()->modPath;
  91. else
  92. return NULL;
  93. }
  94. CodeBlock *CodeBlock::find(StringTableEntry name)
  95. {
  96. for (CodeBlock *walk = CodeBlock::getCodeBlockList(); walk; walk = walk->nextFile)
  97. if (walk->name == name)
  98. return walk;
  99. return NULL;
  100. }
  101. //-------------------------------------------------------------------------
  102. void CodeBlock::addToCodeList()
  103. {
  104. // remove any code blocks with my name
  105. for (CodeBlock **walk = &smCodeBlockList; *walk; walk = &((*walk)->nextFile))
  106. {
  107. if ((*walk)->name == name)
  108. {
  109. *walk = (*walk)->nextFile;
  110. break;
  111. }
  112. }
  113. nextFile = smCodeBlockList;
  114. smCodeBlockList = this;
  115. }
  116. void CodeBlock::clearAllBreaks()
  117. {
  118. if (!lineBreakPairs)
  119. return;
  120. for (U32 i = 0; i < lineBreakPairCount; i++)
  121. {
  122. U32 *p = lineBreakPairs + i * 2;
  123. code[p[1]] = p[0] & 0xFF;
  124. }
  125. }
  126. void CodeBlock::clearBreakpoint(U32 lineNumber)
  127. {
  128. if (!lineBreakPairs)
  129. return;
  130. for (U32 i = 0; i < lineBreakPairCount; i++)
  131. {
  132. U32 *p = lineBreakPairs + i * 2;
  133. if ((p[0] >> 8) == lineNumber)
  134. {
  135. code[p[1]] = p[0] & 0xFF;
  136. return;
  137. }
  138. }
  139. }
  140. void CodeBlock::setAllBreaks()
  141. {
  142. if (!lineBreakPairs)
  143. return;
  144. for (U32 i = 0; i < lineBreakPairCount; i++)
  145. {
  146. U32 *p = lineBreakPairs + i * 2;
  147. code[p[1]] = OP_BREAK;
  148. }
  149. }
  150. bool CodeBlock::setBreakpoint(U32 lineNumber)
  151. {
  152. if (!lineBreakPairs)
  153. return false;
  154. for (U32 i = 0; i < lineBreakPairCount; i++)
  155. {
  156. U32 *p = lineBreakPairs + i * 2;
  157. if ((p[0] >> 8) == lineNumber)
  158. {
  159. code[p[1]] = OP_BREAK;
  160. return true;
  161. }
  162. }
  163. return false;
  164. }
  165. U32 CodeBlock::findFirstBreakLine(U32 lineNumber)
  166. {
  167. if (!lineBreakPairs)
  168. return 0;
  169. for (U32 i = 0; i < lineBreakPairCount; i++)
  170. {
  171. U32 *p = lineBreakPairs + i * 2;
  172. U32 line = (p[0] >> 8);
  173. if (lineNumber <= line)
  174. return line;
  175. }
  176. return 0;
  177. }
  178. struct LinePair
  179. {
  180. U32 instLine;
  181. U32 ip;
  182. };
  183. void CodeBlock::findBreakLine(U32 ip, U32 &line, U32 &instruction)
  184. {
  185. U32 min = 0;
  186. U32 max = lineBreakPairCount - 1;
  187. LinePair *p = (LinePair *)lineBreakPairs;
  188. U32 found;
  189. if (!lineBreakPairCount || p[min].ip > ip || p[max].ip < ip)
  190. {
  191. line = 0;
  192. instruction = OP_INVALID;
  193. return;
  194. }
  195. else if (p[min].ip == ip)
  196. found = min;
  197. else if (p[max].ip == ip)
  198. found = max;
  199. else
  200. {
  201. for (;;)
  202. {
  203. if (min == max - 1)
  204. {
  205. found = min;
  206. break;
  207. }
  208. U32 mid = (min + max) >> 1;
  209. if (p[mid].ip == ip)
  210. {
  211. found = mid;
  212. break;
  213. }
  214. else if (p[mid].ip > ip)
  215. max = mid;
  216. else
  217. min = mid;
  218. }
  219. }
  220. instruction = p[found].instLine & 0xFF;
  221. line = p[found].instLine >> 8;
  222. }
  223. const char *CodeBlock::getFileLine(U32 ip)
  224. {
  225. static char nameBuffer[256];
  226. U32 line, inst;
  227. findBreakLine(ip, line, inst);
  228. dSprintf(nameBuffer, sizeof(nameBuffer), "%s (%d)", name ? name : "<input>", line);
  229. return nameBuffer;
  230. }
  231. void CodeBlock::removeFromCodeList()
  232. {
  233. for (CodeBlock **walk = &smCodeBlockList; *walk; walk = &((*walk)->nextFile))
  234. {
  235. if (*walk == this)
  236. {
  237. *walk = nextFile;
  238. // clear out all breakpoints
  239. clearAllBreaks();
  240. break;
  241. }
  242. }
  243. // Let the telnet debugger know that this code
  244. // block has been unloaded and that it needs to
  245. // remove references to it.
  246. if (TelDebugger)
  247. TelDebugger->clearCodeBlockPointers(this);
  248. }
  249. void CodeBlock::calcBreakList()
  250. {
  251. U32 size = 0;
  252. S32 line = -1;
  253. U32 seqCount = 0;
  254. U32 i;
  255. for (i = 0; i < lineBreakPairCount; i++)
  256. {
  257. U32 lineNumber = lineBreakPairs[i * 2];
  258. if (lineNumber == U32(line + 1))
  259. seqCount++;
  260. else
  261. {
  262. if (seqCount)
  263. size++;
  264. size++;
  265. seqCount = 1;
  266. }
  267. line = lineNumber;
  268. }
  269. if (seqCount)
  270. size++;
  271. breakList = new U32[size];
  272. breakListSize = size;
  273. line = -1;
  274. seqCount = 0;
  275. size = 0;
  276. for (i = 0; i < lineBreakPairCount; i++)
  277. {
  278. U32 lineNumber = lineBreakPairs[i * 2];
  279. if (lineNumber == U32(line + 1))
  280. seqCount++;
  281. else
  282. {
  283. if (seqCount)
  284. breakList[size++] = seqCount;
  285. breakList[size++] = lineNumber - getMax(0, line) - 1;
  286. seqCount = 1;
  287. }
  288. line = lineNumber;
  289. }
  290. if (seqCount)
  291. breakList[size++] = seqCount;
  292. for (i = 0; i < lineBreakPairCount; i++)
  293. {
  294. U32 *p = lineBreakPairs + i * 2;
  295. p[0] = (p[0] << 8) | code[p[1]];
  296. }
  297. // Let the telnet debugger know that this code
  298. // block has been loaded and that it can add break
  299. // points it has for it.
  300. if (TelDebugger)
  301. TelDebugger->addAllBreakpoints(this);
  302. }
  303. bool CodeBlock::read(StringTableEntry fileName, Stream &st)
  304. {
  305. const StringTableEntry exePath = Platform::getMainDotCsDir();
  306. const StringTableEntry cwd = Platform::getCurrentDirectory();
  307. name = fileName;
  308. if (fileName)
  309. {
  310. fullPath = NULL;
  311. if (Platform::isFullPath(fileName))
  312. fullPath = fileName;
  313. if (dStrnicmp(exePath, fileName, dStrlen(exePath)) == 0)
  314. name = StringTable->insert(fileName + dStrlen(exePath) + 1, true);
  315. else if (dStrnicmp(cwd, fileName, dStrlen(cwd)) == 0)
  316. name = StringTable->insert(fileName + dStrlen(cwd) + 1, true);
  317. if (fullPath == NULL)
  318. {
  319. char buf[1024];
  320. fullPath = StringTable->insert(Platform::makeFullPathName(fileName, buf, sizeof(buf)), true);
  321. }
  322. modPath = Con::getModNameFromPath(fileName);
  323. }
  324. //
  325. addToCodeList();
  326. U32 globalSize, size, i;
  327. st.read(&size);
  328. if (size)
  329. {
  330. globalStrings = new char[size];
  331. globalStringsMaxLen = size;
  332. st.read(size, globalStrings);
  333. }
  334. globalSize = size;
  335. st.read(&size);
  336. if (size)
  337. {
  338. functionStrings = new char[size];
  339. functionStringsMaxLen = size;
  340. st.read(size, functionStrings);
  341. }
  342. st.read(&size);
  343. if (size)
  344. {
  345. globalFloats = new F64[size];
  346. for (i = 0; i < size; i++)
  347. st.read(&globalFloats[i]);
  348. }
  349. st.read(&size);
  350. if (size)
  351. {
  352. functionFloats = new F64[size];
  353. for (i = 0; i < size; i++)
  354. st.read(&functionFloats[i]);
  355. }
  356. U32 codeLength;
  357. st.read(&codeLength);
  358. st.read(&lineBreakPairCount);
  359. U32 totSize = codeLength + lineBreakPairCount * 2;
  360. code = new U32[totSize];
  361. // 0xFF is used as a flag to help compress the bytecode.
  362. // If detected, the bytecode is only a U8.
  363. for (i = 0; i < codeLength; i++)
  364. {
  365. U8 b;
  366. st.read(&b);
  367. if (b == 0xFF)
  368. st.read(&code[i]);
  369. else
  370. code[i] = b;
  371. }
  372. for (i = codeLength; i < totSize; i++)
  373. st.read(&code[i]);
  374. lineBreakPairs = code + codeLength;
  375. // StringTable-ize our identifiers.
  376. U32 identCount;
  377. st.read(&identCount);
  378. while (identCount--)
  379. {
  380. U32 offset;
  381. st.read(&offset);
  382. StringTableEntry ste;
  383. if (offset < globalSize)
  384. ste = StringTable->insert(globalStrings + offset);
  385. else
  386. ste = StringTable->EmptyString();
  387. U32 count;
  388. st.read(&count);
  389. while (count--)
  390. {
  391. U32 ip;
  392. st.read(&ip);
  393. #ifdef TORQUE_CPU_X64
  394. *(U64*)(code + ip) = (U64)ste;
  395. #else
  396. code[ip] = *((U32 *)&ste);
  397. #endif
  398. }
  399. }
  400. if (lineBreakPairCount)
  401. calcBreakList();
  402. return true;
  403. }
  404. bool CodeBlock::compile(const char *codeFileName, StringTableEntry fileName, const char *inScript, bool overrideNoDso)
  405. {
  406. AssertFatal(Con::isMainThread(), "Compiling code on a secondary thread");
  407. // This will return true, but return value is ignored
  408. char *script;
  409. chompUTF8BOM(inScript, &script);
  410. gSyntaxError = false;
  411. consoleAllocReset();
  412. STEtoCode = compileSTEtoCode;
  413. gStatementList = NULL;
  414. gAnonFunctionList = NULL;
  415. // Set up the parser.
  416. smCurrentParser = getParserForFile(fileName);
  417. AssertISV(smCurrentParser, avar("CodeBlock::compile - no parser available for '%s'!", fileName));
  418. // Now do some parsing.
  419. smCurrentParser->setScanBuffer(script, fileName);
  420. smCurrentParser->restart(NULL);
  421. smCurrentParser->parse();
  422. if (gStatementList)
  423. {
  424. if (gAnonFunctionList)
  425. {
  426. // Prepend anonymous functions to statement list, so they're defined already when
  427. // the statements run.
  428. gAnonFunctionList->append(gStatementList);
  429. gStatementList = gAnonFunctionList;
  430. }
  431. }
  432. if (gSyntaxError)
  433. {
  434. consoleAllocReset();
  435. return false;
  436. }
  437. #ifdef TORQUE_NO_DSO_GENERATION
  438. if (!overrideNoDso)
  439. return false;
  440. #endif // !TORQUE_NO_DSO_GENERATION
  441. FileStream st;
  442. if (!st.open(codeFileName, Torque::FS::File::Write))
  443. return false;
  444. st.write(U32(Con::DSOVersion));
  445. // Reset all our value tables...
  446. resetTables();
  447. smInFunction = false;
  448. CodeStream codeStream;
  449. U32 lastIp;
  450. if (gStatementList)
  451. {
  452. lastIp = compileBlock(gStatementList, codeStream, 0) + 1;
  453. }
  454. else
  455. {
  456. codeSize = 1;
  457. lastIp = 0;
  458. }
  459. codeStream.emit(OP_RETURN);
  460. codeStream.emitCodeStream(&codeSize, &code, &lineBreakPairs);
  461. lineBreakPairCount = codeStream.getNumLineBreaks();
  462. // Write string table data...
  463. getGlobalStringTable().write(st);
  464. getFunctionStringTable().write(st);
  465. // Write float table data...
  466. getGlobalFloatTable().write(st);
  467. getFunctionFloatTable().write(st);
  468. if (lastIp != codeSize)
  469. Con::errorf(ConsoleLogEntry::General, "CodeBlock::compile - precompile size mismatch, a precompile/compile function pair is probably mismatched.");
  470. U32 totSize = codeSize + codeStream.getNumLineBreaks() * 2;
  471. st.write(codeSize);
  472. st.write(lineBreakPairCount);
  473. // Write out our bytecode, doing a bit of compression for low numbers.
  474. U32 i;
  475. for (i = 0; i < codeSize; i++)
  476. {
  477. if (code[i] < 0xFF)
  478. st.write(U8(code[i]));
  479. else
  480. {
  481. st.write(U8(0xFF));
  482. st.write(code[i]);
  483. }
  484. }
  485. // Write the break info...
  486. for (i = codeSize; i < totSize; i++)
  487. st.write(code[i]);
  488. getIdentTable().write(st);
  489. consoleAllocReset();
  490. st.close();
  491. return true;
  492. }
  493. ConsoleValueRef CodeBlock::compileExec(StringTableEntry fileName, const char *inString, bool noCalls, S32 setFrame)
  494. {
  495. AssertFatal(Con::isMainThread(), "Compiling code on a secondary thread");
  496. // Check for a UTF8 script file
  497. char *string;
  498. chompUTF8BOM(inString, &string);
  499. STEtoCode = evalSTEtoCode;
  500. consoleAllocReset();
  501. name = fileName;
  502. if (fileName)
  503. {
  504. const StringTableEntry exePath = Platform::getMainDotCsDir();
  505. const StringTableEntry cwd = Platform::getCurrentDirectory();
  506. fullPath = NULL;
  507. if (Platform::isFullPath(fileName))
  508. fullPath = fileName;
  509. if (dStrnicmp(exePath, fileName, dStrlen(exePath)) == 0)
  510. name = StringTable->insert(fileName + dStrlen(exePath) + 1, true);
  511. else if (dStrnicmp(cwd, fileName, dStrlen(cwd)) == 0)
  512. name = StringTable->insert(fileName + dStrlen(cwd) + 1, true);
  513. if (fullPath == NULL)
  514. {
  515. char buf[1024];
  516. fullPath = StringTable->insert(Platform::makeFullPathName(fileName, buf, sizeof(buf)), true);
  517. }
  518. modPath = Con::getModNameFromPath(fileName);
  519. }
  520. if (name)
  521. addToCodeList();
  522. gStatementList = NULL;
  523. gAnonFunctionList = NULL;
  524. // Set up the parser.
  525. smCurrentParser = getParserForFile(fileName);
  526. AssertISV(smCurrentParser, avar("CodeBlock::compile - no parser available for '%s'!", fileName));
  527. // Now do some parsing.
  528. smCurrentParser->setScanBuffer(string, fileName);
  529. smCurrentParser->restart(NULL);
  530. smCurrentParser->parse();
  531. if (gStatementList)
  532. {
  533. if (gAnonFunctionList)
  534. {
  535. // Prepend anonymous functions to statement list, so they're defined already when
  536. // the statements run.
  537. gAnonFunctionList->append(gStatementList);
  538. gStatementList = gAnonFunctionList;
  539. }
  540. }
  541. if (!gStatementList)
  542. {
  543. delete this;
  544. return ConsoleValueRef();
  545. }
  546. resetTables();
  547. smInFunction = false;
  548. CodeStream codeStream;
  549. U32 lastIp = compileBlock(gStatementList, codeStream, 0);
  550. lineBreakPairCount = codeStream.getNumLineBreaks();
  551. globalStrings = getGlobalStringTable().build();
  552. globalStringsMaxLen = getGlobalStringTable().totalLen;
  553. functionStrings = getFunctionStringTable().build();
  554. functionStringsMaxLen = getFunctionStringTable().totalLen;
  555. globalFloats = getGlobalFloatTable().build();
  556. functionFloats = getFunctionFloatTable().build();
  557. codeStream.emit(OP_RETURN);
  558. codeStream.emitCodeStream(&codeSize, &code, &lineBreakPairs);
  559. //dumpInstructions(0, false);
  560. consoleAllocReset();
  561. if (lineBreakPairCount && fileName)
  562. calcBreakList();
  563. if (lastIp + 1 != codeSize)
  564. Con::warnf(ConsoleLogEntry::General, "precompile size mismatch, precompile: %d compile: %d", codeSize, lastIp);
  565. return exec(0, fileName, NULL, 0, 0, noCalls, NULL, setFrame);
  566. }
  567. //-------------------------------------------------------------------------
  568. void CodeBlock::incRefCount()
  569. {
  570. refCount++;
  571. }
  572. void CodeBlock::decRefCount()
  573. {
  574. refCount--;
  575. if (!refCount)
  576. delete this;
  577. }
  578. //-------------------------------------------------------------------------
  579. String CodeBlock::getFunctionArgs(U32 ip)
  580. {
  581. StringBuilder str;
  582. U32 fnArgc = code[ip + 8];
  583. for (U32 i = 0; i < fnArgc; ++i)
  584. {
  585. StringTableEntry var = CodeToSTE(code, ip + (i * 2) + 9);
  586. if (i != 0)
  587. str.append(", ");
  588. str.append("string ");
  589. // Try to capture junked parameters
  590. if (var[0])
  591. str.append(var + 1);
  592. else
  593. str.append("JUNK");
  594. }
  595. return str.end();
  596. }
  597. //-------------------------------------------------------------------------
  598. void CodeBlock::dumpInstructions(U32 startIp, bool upToReturn)
  599. {
  600. U32 ip = startIp;
  601. smInFunction = false;
  602. U32 endFuncIp = 0;
  603. while (ip < codeSize)
  604. {
  605. if (ip > endFuncIp)
  606. {
  607. smInFunction = false;
  608. }
  609. switch (code[ip++])
  610. {
  611. case OP_FUNC_DECL:
  612. {
  613. StringTableEntry fnName = CodeToSTE(code, ip);
  614. StringTableEntry fnNamespace = CodeToSTE(code, ip + 2);
  615. StringTableEntry fnPackage = CodeToSTE(code, ip + 4);
  616. bool hasBody = bool(code[ip + 6]);
  617. U32 newIp = code[ip + 7];
  618. U32 argc = code[ip + 8];
  619. endFuncIp = newIp;
  620. Con::printf("%i: OP_FUNC_DECL name=%s nspace=%s package=%s hasbody=%i newip=%i argc=%i",
  621. ip - 1, fnName, fnNamespace, fnPackage, hasBody, newIp, argc);
  622. // Skip args.
  623. ip += 9 + (argc * 2);
  624. smInFunction = true;
  625. break;
  626. }
  627. case OP_CREATE_OBJECT:
  628. {
  629. StringTableEntry objParent = CodeToSTE(code, ip);
  630. bool isDataBlock = code[ip + 2];
  631. bool isInternal = code[ip + 3];
  632. bool isSingleton = code[ip + 4];
  633. U32 lineNumber = code[ip + 5];
  634. U32 failJump = code[ip + 6];
  635. Con::printf("%i: OP_CREATE_OBJECT objParent=%s isDataBlock=%i isInternal=%i isSingleton=%i lineNumber=%i failJump=%i",
  636. ip - 1, objParent, isDataBlock, isInternal, isSingleton, lineNumber, failJump);
  637. ip += 7;
  638. break;
  639. }
  640. case OP_ADD_OBJECT:
  641. {
  642. bool placeAtRoot = code[ip++];
  643. Con::printf("%i: OP_ADD_OBJECT placeAtRoot=%i", ip - 1, placeAtRoot);
  644. break;
  645. }
  646. case OP_END_OBJECT:
  647. {
  648. bool placeAtRoot = code[ip++];
  649. Con::printf("%i: OP_END_OBJECT placeAtRoot=%i", ip - 1, placeAtRoot);
  650. break;
  651. }
  652. case OP_FINISH_OBJECT:
  653. {
  654. Con::printf("%i: OP_FINISH_OBJECT", ip - 1);
  655. break;
  656. }
  657. case OP_JMPIFFNOT:
  658. {
  659. Con::printf("%i: OP_JMPIFFNOT ip=%i", ip - 1, code[ip]);
  660. ++ip;
  661. break;
  662. }
  663. case OP_JMPIFNOT:
  664. {
  665. Con::printf("%i: OP_JMPIFNOT ip=%i", ip - 1, code[ip]);
  666. ++ip;
  667. break;
  668. }
  669. case OP_JMPIFF:
  670. {
  671. Con::printf("%i: OP_JMPIFF ip=%i", ip - 1, code[ip]);
  672. ++ip;
  673. break;
  674. }
  675. case OP_JMPIF:
  676. {
  677. Con::printf("%i: OP_JMPIF ip=%i", ip - 1, code[ip]);
  678. ++ip;
  679. break;
  680. }
  681. case OP_JMPIFNOT_NP:
  682. {
  683. Con::printf("%i: OP_JMPIFNOT_NP ip=%i", ip - 1, code[ip]);
  684. ++ip;
  685. break;
  686. }
  687. case OP_JMPIF_NP:
  688. {
  689. Con::printf("%i: OP_JMPIF_NP ip=%i", ip - 1, code[ip]);
  690. ++ip;
  691. break;
  692. }
  693. case OP_JMP:
  694. {
  695. Con::printf("%i: OP_JMP ip=%i", ip - 1, code[ip]);
  696. ++ip;
  697. break;
  698. }
  699. case OP_RETURN:
  700. {
  701. Con::printf("%i: OP_RETURN", ip - 1);
  702. if (upToReturn)
  703. return;
  704. break;
  705. }
  706. case OP_RETURN_VOID:
  707. {
  708. Con::printf("%i: OP_RETURNVOID", ip - 1);
  709. if (upToReturn)
  710. return;
  711. break;
  712. }
  713. case OP_RETURN_UINT:
  714. {
  715. Con::printf("%i: OP_RETURNUINT", ip - 1);
  716. if (upToReturn)
  717. return;
  718. break;
  719. }
  720. case OP_RETURN_FLT:
  721. {
  722. Con::printf("%i: OP_RETURNFLT", ip - 1);
  723. if (upToReturn)
  724. return;
  725. break;
  726. }
  727. case OP_CMPEQ:
  728. {
  729. Con::printf("%i: OP_CMPEQ", ip - 1);
  730. break;
  731. }
  732. case OP_CMPGR:
  733. {
  734. Con::printf("%i: OP_CMPGR", ip - 1);
  735. break;
  736. }
  737. case OP_CMPGE:
  738. {
  739. Con::printf("%i: OP_CMPGE", ip - 1);
  740. break;
  741. }
  742. case OP_CMPLT:
  743. {
  744. Con::printf("%i: OP_CMPLT", ip - 1);
  745. break;
  746. }
  747. case OP_CMPLE:
  748. {
  749. Con::printf("%i: OP_CMPLE", ip - 1);
  750. break;
  751. }
  752. case OP_CMPNE:
  753. {
  754. Con::printf("%i: OP_CMPNE", ip - 1);
  755. break;
  756. }
  757. case OP_XOR:
  758. {
  759. Con::printf("%i: OP_XOR", ip - 1);
  760. break;
  761. }
  762. case OP_MOD:
  763. {
  764. Con::printf("%i: OP_MOD", ip - 1);
  765. break;
  766. }
  767. case OP_BITAND:
  768. {
  769. Con::printf("%i: OP_BITAND", ip - 1);
  770. break;
  771. }
  772. case OP_BITOR:
  773. {
  774. Con::printf("%i: OP_BITOR", ip - 1);
  775. break;
  776. }
  777. case OP_NOT:
  778. {
  779. Con::printf("%i: OP_NOT", ip - 1);
  780. break;
  781. }
  782. case OP_NOTF:
  783. {
  784. Con::printf("%i: OP_NOTF", ip - 1);
  785. break;
  786. }
  787. case OP_ONESCOMPLEMENT:
  788. {
  789. Con::printf("%i: OP_ONESCOMPLEMENT", ip - 1);
  790. break;
  791. }
  792. case OP_SHR:
  793. {
  794. Con::printf("%i: OP_SHR", ip - 1);
  795. break;
  796. }
  797. case OP_SHL:
  798. {
  799. Con::printf("%i: OP_SHL", ip - 1);
  800. break;
  801. }
  802. case OP_AND:
  803. {
  804. Con::printf("%i: OP_AND", ip - 1);
  805. break;
  806. }
  807. case OP_OR:
  808. {
  809. Con::printf("%i: OP_OR", ip - 1);
  810. break;
  811. }
  812. case OP_ADD:
  813. {
  814. Con::printf("%i: OP_ADD", ip - 1);
  815. break;
  816. }
  817. case OP_SUB:
  818. {
  819. Con::printf("%i: OP_SUB", ip - 1);
  820. break;
  821. }
  822. case OP_MUL:
  823. {
  824. Con::printf("%i: OP_MUL", ip - 1);
  825. break;
  826. }
  827. case OP_DIV:
  828. {
  829. Con::printf("%i: OP_DIV", ip - 1);
  830. break;
  831. }
  832. case OP_NEG:
  833. {
  834. Con::printf("%i: OP_NEG", ip - 1);
  835. break;
  836. }
  837. case OP_INC:
  838. {
  839. Con::printf("%i: OP_INC varName=%s", ip - 1, CodeToSTE(code, ip));
  840. ip += 2;
  841. break;
  842. }
  843. case OP_DEC:
  844. {
  845. Con::printf("%i: OP_DEC varName=%s", ip - 1, CodeToSTE(code, ip));
  846. ip += 2;
  847. break;
  848. }
  849. case OP_SETCURVAR:
  850. {
  851. StringTableEntry var = CodeToSTE(code, ip);
  852. Con::printf("%i: OP_SETCURVAR var=%s", ip - 1, var);
  853. ip += 2;
  854. break;
  855. }
  856. case OP_SETCURVAR_CREATE:
  857. {
  858. StringTableEntry var = CodeToSTE(code, ip);
  859. Con::printf("%i: OP_SETCURVAR_CREATE var=%s", ip - 1, var);
  860. ip += 2;
  861. break;
  862. }
  863. case OP_SETCURVAR_ARRAY:
  864. {
  865. Con::printf("%i: OP_SETCURVAR_ARRAY", ip - 1);
  866. break;
  867. }
  868. case OP_SETCURVAR_ARRAY_VARLOOKUP:
  869. {
  870. StringTableEntry arrayName = CodeToSTE(code, ip);
  871. StringTableEntry arrayLookup = CodeToSTE(code, ip + 2);
  872. Con::printf("%i: OP_SETCURVAR_ARRAY_VARLOOKUP arrayName=%s arrayLookup=%s", ip - 1, arrayName, arrayLookup);
  873. ip += 4;
  874. break;
  875. }
  876. case OP_SETCURVAR_ARRAY_CREATE:
  877. {
  878. Con::printf("%i: OP_SETCURVAR_ARRAY_CREATE", ip - 1);
  879. break;
  880. }
  881. case OP_SETCURVAR_ARRAY_CREATE_VARLOOKUP:
  882. {
  883. StringTableEntry arrayName = CodeToSTE(code, ip);
  884. StringTableEntry arrayLookup = CodeToSTE(code, ip + 2);
  885. Con::printf("%i: OP_SETCURVAR_ARRAY_CREATE_VARLOOKUP arrayName=%s arrayLookup=%s", ip - 1, arrayName, arrayLookup);
  886. ip += 4;
  887. break;
  888. }
  889. case OP_LOADVAR_UINT:
  890. {
  891. Con::printf("%i: OP_LOADVAR_UINT", ip - 1);
  892. break;
  893. }
  894. case OP_LOADVAR_FLT:
  895. {
  896. Con::printf("%i: OP_LOADVAR_FLT", ip - 1);
  897. break;
  898. }
  899. case OP_LOADVAR_STR:
  900. {
  901. Con::printf("%i: OP_LOADVAR_STR", ip - 1);
  902. break;
  903. }
  904. case OP_LOADVAR_VAR:
  905. {
  906. Con::printf("%i: OP_LOADVAR_VAR", ip - 1);
  907. break;
  908. }
  909. case OP_SAVEVAR_UINT:
  910. {
  911. Con::printf("%i: OP_SAVEVAR_UINT", ip - 1);
  912. break;
  913. }
  914. case OP_SAVEVAR_FLT:
  915. {
  916. Con::printf("%i: OP_SAVEVAR_FLT", ip - 1);
  917. break;
  918. }
  919. case OP_SAVEVAR_STR:
  920. {
  921. Con::printf("%i: OP_SAVEVAR_STR", ip - 1);
  922. break;
  923. }
  924. case OP_SAVEVAR_VAR:
  925. {
  926. Con::printf("%i: OP_SAVEVAR_VAR", ip - 1);
  927. break;
  928. }
  929. case OP_SETCUROBJECT:
  930. {
  931. Con::printf("%i: OP_SETCUROBJECT", ip - 1);
  932. break;
  933. }
  934. case OP_SETCUROBJECT_NEW:
  935. {
  936. Con::printf("%i: OP_SETCUROBJECT_NEW", ip - 1);
  937. break;
  938. }
  939. case OP_SETCUROBJECT_INTERNAL:
  940. {
  941. Con::printf("%i: OP_SETCUROBJECT_INTERNAL", ip - 1);
  942. ++ip;
  943. break;
  944. }
  945. case OP_SETCURFIELD:
  946. {
  947. StringTableEntry curField = CodeToSTE(code, ip);
  948. Con::printf("%i: OP_SETCURFIELD field=%s", ip - 1, curField);
  949. ip += 2;
  950. break;
  951. }
  952. case OP_SETCURFIELD_ARRAY:
  953. {
  954. Con::printf("%i: OP_SETCURFIELD_ARRAY", ip - 1);
  955. break;
  956. }
  957. case OP_SETCURFIELD_ARRAY_VAR:
  958. {
  959. StringTableEntry var = CodeToSTE(code, ip);
  960. Con::printf("%i: OP_SETCURFIELD_ARRAY_VAR var=%s", ip - 1, var);
  961. ip += 2;
  962. break;
  963. }
  964. case OP_SETCURFIELD_THIS:
  965. {
  966. StringTableEntry curField = CodeToSTE(code, ip);
  967. Con::printf("%i: OP_SETCURFIELD_THIS field=%s", ip - 1, curField);
  968. ip += 2;
  969. break;
  970. }
  971. case OP_SETCURFIELD_TYPE:
  972. {
  973. U32 type = code[ip];
  974. Con::printf("%i: OP_SETCURFIELD_TYPE type=%i", ip - 1, type);
  975. ++ip;
  976. break;
  977. }
  978. case OP_LOADFIELD_UINT:
  979. {
  980. Con::printf("%i: OP_LOADFIELD_UINT", ip - 1);
  981. break;
  982. }
  983. case OP_LOADFIELD_FLT:
  984. {
  985. Con::printf("%i: OP_LOADFIELD_FLT", ip - 1);
  986. break;
  987. }
  988. case OP_LOADFIELD_STR:
  989. {
  990. Con::printf("%i: OP_LOADFIELD_STR", ip - 1);
  991. break;
  992. }
  993. case OP_SAVEFIELD_UINT:
  994. {
  995. Con::printf("%i: OP_SAVEFIELD_UINT", ip - 1);
  996. break;
  997. }
  998. case OP_SAVEFIELD_FLT:
  999. {
  1000. Con::printf("%i: OP_SAVEFIELD_FLT", ip - 1);
  1001. break;
  1002. }
  1003. case OP_SAVEFIELD_STR:
  1004. {
  1005. Con::printf("%i: OP_SAVEFIELD_STR", ip - 1);
  1006. break;
  1007. }
  1008. case OP_STR_TO_UINT:
  1009. {
  1010. Con::printf("%i: OP_STR_TO_UINT", ip - 1);
  1011. break;
  1012. }
  1013. case OP_STR_TO_FLT:
  1014. {
  1015. Con::printf("%i: OP_STR_TO_FLT", ip - 1);
  1016. break;
  1017. }
  1018. case OP_STR_TO_NONE:
  1019. {
  1020. Con::printf("%i: OP_STR_TO_NONE", ip - 1);
  1021. break;
  1022. }
  1023. case OP_FLT_TO_UINT:
  1024. {
  1025. Con::printf("%i: OP_FLT_TO_UINT", ip - 1);
  1026. break;
  1027. }
  1028. case OP_FLT_TO_STR:
  1029. {
  1030. Con::printf("%i: OP_FLT_TO_STR", ip - 1);
  1031. break;
  1032. }
  1033. case OP_FLT_TO_NONE:
  1034. {
  1035. Con::printf("%i: OP_FLT_TO_NONE", ip - 1);
  1036. break;
  1037. }
  1038. case OP_UINT_TO_FLT:
  1039. {
  1040. Con::printf("%i: OP_SAVEFIELD_STR", ip - 1);
  1041. break;
  1042. }
  1043. case OP_UINT_TO_STR:
  1044. {
  1045. Con::printf("%i: OP_UINT_TO_STR", ip - 1);
  1046. break;
  1047. }
  1048. case OP_UINT_TO_NONE:
  1049. {
  1050. Con::printf("%i: OP_UINT_TO_NONE", ip - 1);
  1051. break;
  1052. }
  1053. case OP_COPYVAR_TO_NONE:
  1054. {
  1055. Con::printf("%i: OP_COPYVAR_TO_NONE", ip - 1);
  1056. break;
  1057. }
  1058. case OP_LOADIMMED_UINT:
  1059. {
  1060. U32 val = code[ip];
  1061. Con::printf("%i: OP_LOADIMMED_UINT val=%i", ip - 1, val);
  1062. ++ip;
  1063. break;
  1064. }
  1065. case OP_LOADIMMED_FLT:
  1066. {
  1067. F64 val = (smInFunction ? functionFloats : globalFloats)[code[ip]];
  1068. Con::printf("%i: OP_LOADIMMED_FLT val=%f", ip - 1, val);
  1069. ++ip;
  1070. break;
  1071. }
  1072. case OP_TAG_TO_STR:
  1073. {
  1074. const char* str = (smInFunction ? functionStrings : globalStrings) + code[ip];
  1075. Con::printf("%i: OP_TAG_TO_STR str=%s", ip - 1, str);
  1076. ++ip;
  1077. break;
  1078. }
  1079. case OP_LOADIMMED_STR:
  1080. {
  1081. const char* str = (smInFunction ? functionStrings : globalStrings) + code[ip];
  1082. Con::printf("%i: OP_LOADIMMED_STR str=%s", ip - 1, str);
  1083. ++ip;
  1084. break;
  1085. }
  1086. case OP_DOCBLOCK_STR:
  1087. {
  1088. const char* str = (smInFunction ? functionStrings : globalStrings) + code[ip];
  1089. Con::printf("%i: OP_DOCBLOCK_STR str=%s", ip - 1, str);
  1090. ++ip;
  1091. break;
  1092. }
  1093. case OP_LOADIMMED_IDENT:
  1094. {
  1095. StringTableEntry str = CodeToSTE(code, ip);
  1096. Con::printf("%i: OP_LOADIMMED_IDENT str=%s", ip - 1, str);
  1097. ip += 2;
  1098. break;
  1099. }
  1100. case OP_CALLFUNC_RESOLVE:
  1101. {
  1102. StringTableEntry fnNamespace = CodeToSTE(code, ip + 2);
  1103. StringTableEntry fnName = CodeToSTE(code, ip);
  1104. U32 callType = code[ip + 2];
  1105. Con::printf("%i: OP_CALLFUNC_RESOLVE name=%s nspace=%s callType=%s", ip - 1, fnName, fnNamespace,
  1106. callType == FuncCallExprNode::FunctionCall ? "FunctionCall"
  1107. : callType == FuncCallExprNode::MethodCall ? "MethodCall" : "ParentCall");
  1108. ip += 5;
  1109. break;
  1110. }
  1111. case OP_CALLFUNC:
  1112. {
  1113. StringTableEntry fnNamespace = CodeToSTE(code, ip + 2);
  1114. StringTableEntry fnName = CodeToSTE(code, ip);
  1115. U32 callType = code[ip + 4];
  1116. Con::printf("%i: OP_CALLFUNC name=%s nspace=%s callType=%s", ip - 1, fnName, fnNamespace,
  1117. callType == FuncCallExprNode::FunctionCall ? "FunctionCall"
  1118. : callType == FuncCallExprNode::MethodCall ? "MethodCall" : "ParentCall");
  1119. ip += 5;
  1120. break;
  1121. }
  1122. case OP_CALLFUNC_POINTER:
  1123. {
  1124. Con::printf("%i: OP_CALLFUNC_POINTER", ip - 1);
  1125. break;
  1126. }
  1127. case OP_CALLFUNC_THIS:
  1128. {
  1129. StringTableEntry fnName = CodeToSTE(code, ip);
  1130. Con::printf("%i: OP_CALLFUNC_THIS name=%s ", ip - 1, fnName);
  1131. ip += 2;
  1132. break;
  1133. }
  1134. case OP_ADVANCE_STR:
  1135. {
  1136. Con::printf("%i: OP_ADVANCE_STR", ip - 1);
  1137. break;
  1138. }
  1139. case OP_ADVANCE_STR_APPENDCHAR:
  1140. {
  1141. char ch = code[ip];
  1142. Con::printf("%i: OP_ADVANCE_STR_APPENDCHAR char=%c", ip - 1, ch);
  1143. ++ip;
  1144. break;
  1145. }
  1146. case OP_ADVANCE_STR_COMMA:
  1147. {
  1148. Con::printf("%i: OP_ADVANCE_STR_COMMA", ip - 1);
  1149. break;
  1150. }
  1151. case OP_ADVANCE_STR_NUL:
  1152. {
  1153. Con::printf("%i: OP_ADVANCE_STR_NUL", ip - 1);
  1154. break;
  1155. }
  1156. case OP_REWIND_STR:
  1157. {
  1158. Con::printf("%i: OP_REWIND_STR", ip - 1);
  1159. break;
  1160. }
  1161. case OP_TERMINATE_REWIND_STR:
  1162. {
  1163. Con::printf("%i: OP_TERMINATE_REWIND_STR", ip - 1);
  1164. break;
  1165. }
  1166. case OP_COMPARE_STR:
  1167. {
  1168. Con::printf("%i: OP_COMPARE_STR", ip - 1);
  1169. break;
  1170. }
  1171. case OP_PUSH:
  1172. {
  1173. Con::printf("%i: OP_PUSH", ip - 1);
  1174. break;
  1175. }
  1176. case OP_PUSH_UINT:
  1177. {
  1178. Con::printf("%i: OP_PUSH_UINT", ip - 1);
  1179. break;
  1180. }
  1181. case OP_PUSH_FLT:
  1182. {
  1183. Con::printf("%i: OP_PUSH_FLT", ip - 1);
  1184. break;
  1185. }
  1186. case OP_PUSH_VAR:
  1187. {
  1188. Con::printf("%i: OP_PUSH_VAR", ip - 1);
  1189. break;
  1190. }
  1191. case OP_PUSH_THIS:
  1192. {
  1193. Con::printf("%i: OP_PUSH_THIS varName=%s", ip - 1, CodeToSTE(code, ip));
  1194. ip += 2;
  1195. break;
  1196. }
  1197. case OP_PUSH_FRAME:
  1198. {
  1199. Con::printf("%i: OP_PUSH_FRAME", ip - 1);
  1200. break;
  1201. }
  1202. case OP_ASSERT:
  1203. {
  1204. const char* message = (smInFunction ? functionStrings : globalStrings) + code[ip];
  1205. Con::printf("%i: OP_ASSERT message=%s", ip - 1, message);
  1206. ++ip;
  1207. break;
  1208. }
  1209. case OP_BREAK:
  1210. {
  1211. Con::printf("%i: OP_BREAK", ip - 1);
  1212. break;
  1213. }
  1214. case OP_ITER_BEGIN:
  1215. {
  1216. StringTableEntry varName = CodeToSTE(code, ip);
  1217. U32 failIp = code[ip + 2];
  1218. Con::printf("%i: OP_ITER_BEGIN varName=%s failIp=%i", ip - 1, varName, failIp);
  1219. ip += 3;
  1220. break;
  1221. }
  1222. case OP_ITER_BEGIN_STR:
  1223. {
  1224. StringTableEntry varName = CodeToSTE(code, ip);
  1225. U32 failIp = code[ip + 2];
  1226. Con::printf("%i: OP_ITER_BEGIN varName=%s failIp=%i", ip - 1, varName, failIp);
  1227. ip += 3;
  1228. break;
  1229. }
  1230. case OP_ITER:
  1231. {
  1232. U32 breakIp = code[ip];
  1233. Con::printf("%i: OP_ITER breakIp=%i", ip - 1, breakIp);
  1234. ++ip;
  1235. break;
  1236. }
  1237. case OP_ITER_END:
  1238. {
  1239. Con::printf("%i: OP_ITER_END", ip - 1);
  1240. break;
  1241. }
  1242. default:
  1243. Con::printf("%i: !!INVALID!!", ip - 1);
  1244. break;
  1245. }
  1246. }
  1247. smInFunction = false;
  1248. }