@@ -167,7 +167,7 @@ function TRhodus.compileToAST (sourceCode : string; var syntaxError : TSyntaxErr
167
167
begin
168
168
root := ast.constructAST ();
169
169
if bolShowTree then
170
- printLnCallBack (displayAST (root));
170
+ printLnCallBack (AnsiString ( displayAST (root) ));
171
171
end
172
172
else
173
173
result := False;
@@ -226,7 +226,7 @@ function TRhodus.compileCode (const src : string; var module : TModuleLib; inter
226
226
error : TSyntaxError;
227
227
compilerError : TCompilerError;
228
228
begin
229
- result := True;
229
+ result := True; root := nil ;
230
230
// Note we don't clear the symboltables because the next script
231
231
// may need to refer to entries in the symbol table.
232
232
module .clearCode;
@@ -239,19 +239,19 @@ function TRhodus.compileCode (const src : string; var module : TModuleLib; inter
239
239
try
240
240
if not syntaxParser.syntaxCheck (error) then
241
241
begin
242
- printLnCallBack (' ERROR ' + ' [line ' + inttostr (error.lineNumber) + ' , column: ' + inttostr (error.columnNumber) + ' ] ' + error.errorMsg);
242
+ printLnCallBack (AnsiString ( ' ERROR ' + ' [line ' + inttostr (error.lineNumber) + ' , column: ' + inttostr (error.columnNumber) + ' ] ' + error.errorMsg) );
243
243
result := False;
244
244
exit;
245
245
end ;
246
246
root := ast.constructAST;
247
247
248
248
if bolShowByteCode then
249
- printLnCallBack (displayAST (root));
249
+ printLnCallBack (AnsiString ( displayAST (root) ));
250
250
try
251
251
if not compiler.startCompilation (module , root, compilerError) then
252
252
begin
253
253
// setGreen;
254
- printLnCallBack (' ERROR ' + ' [line ' + inttostr (compilerError.lineNumber) + ' , column: ' + inttostr (compilerError.columnNumber) + ' ] ' + compilerError.errorMsg);
254
+ printLnCallBack (AnsiString ( ' ERROR ' + ' [line ' + inttostr (compilerError.lineNumber) + ' , column: ' + inttostr (compilerError.columnNumber) + ' ] ' + compilerError.errorMsg) );
255
255
// setWhite;
256
256
result := False;
257
257
exit;
@@ -262,7 +262,7 @@ function TRhodus.compileCode (const src : string; var module : TModuleLib; inter
262
262
on e: ERuntimeException do
263
263
begin
264
264
// setGreen;
265
- printLnCallBack (' ERROR: ' + e.Message);
265
+ printLnCallBack (AnsiString ( ' ERROR: ' + e.Message) );
266
266
// setWhite;
267
267
result := False;
268
268
end ;
@@ -277,7 +277,7 @@ function TRhodus.compileCode (const src : string; var module : TModuleLib; inter
277
277
on e:exception do
278
278
begin
279
279
// setGreen;
280
- printLnCallBack (' ERROR ' + ' [line ' + inttostr (sc.tokenElement.lineNumber) + ' , column: ' + inttostr (sc.tokenElement.columnNumber) + ' ] ' + e.Message);
280
+ printLnCallBack (AnsiString ( ' ERROR ' + ' [line ' + inttostr (sc.tokenElement.lineNumber) + ' , column: ' + inttostr (sc.tokenElement.columnNumber) + ' ] ' + e.Message) );
281
281
// setWhite;
282
282
result := False;
283
283
end ;
@@ -287,7 +287,7 @@ function TRhodus.compileCode (const src : string; var module : TModuleLib; inter
287
287
288
288
function TRhodus.memAllocatedByVm : integer;
289
289
var vm : TVM;
290
- start : integer ;
290
+ start : UInt64 ;
291
291
begin
292
292
start := getMemoryAllocated();
293
293
vm := TVM.Create;
@@ -304,9 +304,9 @@ procedure TRhodus.showByteCodeMethod (module : TModule);
304
304
if mainModule.symbolTable.Items[key].symbolType = symUserFunc then
305
305
begin
306
306
if not mainModule.symbolTable.items[key].fValue.isbuiltInFunction then
307
- printLnCallBack (dissassemble(mainModule, mainModule.symbolTable.items[key].fValue.codeBlock));
307
+ printLnCallBack (AnsiString ( dissassemble(mainModule, mainModule.symbolTable.items[key].fValue.codeBlock) ));
308
308
end ;
309
- printLnCallBack (dissassemble(mainModule, mainModule.moduleProgram));
309
+ printLnCallBack (AnsiString ( dissassemble(mainModule, mainModule.moduleProgram) ));
310
310
end ;
311
311
312
312
@@ -367,28 +367,28 @@ function TRhodus.runCode (module : TModule; interactive : boolean) : boolean;
367
367
stNone : begin end ;
368
368
stInteger : begin
369
369
fmt := SysLibraryRef.find (' integerFormat' ).sValue.value ;
370
- printLnCallBack (Format (fmt, [st.iValue]));
370
+ printLnCallBack (AnsiString ( Format (fmt, [st.iValue]) ));
371
371
end ;
372
- stBoolean : printLnCallBack (BoolToStr(st.bValue, True));
372
+ stBoolean : printLnCallBack (AnsiString ( BoolToStr(st.bValue, True) ));
373
373
stDouble : begin
374
374
fmt := SysLibraryRef.find (' doubleFormat' ).sValue.value ;
375
- printLnCallBack (Format(fmt, [st.dValue]));
375
+ printLnCallBack (AnsiString ( Format(fmt, [st.dValue]) ));
376
376
end ;
377
- stString : printLnCallBack (st.sValue.value );
378
- stList : printLnCallBack (st.lValue.listToString());
379
- stArray : printLnCallBack (st.aValue.arrayToString());
380
- stModule : printLnCallBack (' Module: ' + st.module .name + ' ' + st.module .helpStr);
381
- stFunction: printLnCallBack (' Function: ' + st.fValue.moduleRef.name + ' .' + st.fValue.name );
382
- stObjectMethod : begin printLnCallBack (' Object Method: ' + st.oValue.helpStr); vm.pop(); end ; // pop the operand
377
+ stString : printLnCallBack (AnsiString ( st.sValue.value ) );
378
+ stList : printLnCallBack (AnsiString ( st.lValue.listToString() ));
379
+ stArray : printLnCallBack (AnsiString ( st.aValue.arrayToString() ));
380
+ stModule : printLnCallBack (AnsiString ( ' Module: ' + st.module .name + ' ' + st.module .helpStr) );
381
+ stFunction: printLnCallBack (AnsiString ( ' Function: ' + st.fValue.moduleRef.name + ' .' + st.fValue.name ) );
382
+ stObjectMethod : begin printLnCallBack (AnsiString ( ' Object Method: ' + st.oValue.helpStr) ); vm.pop(); end ; // pop the operand
383
383
else
384
- printLnCallBack (' Unrecognized type of value returned from virtual machine' );
384
+ printLnCallBack (AnsiString ( ' Unrecognized type of value returned from virtual machine' ) );
385
385
end ;
386
386
end ;
387
387
except
388
388
on e:exception do
389
389
begin
390
390
setColor(' Cyan' );
391
- printLnCallBack (' ERROR: ' + e.Message);
391
+ printLnCallBack (AnsiString ( ' ERROR: ' + e.Message) );
392
392
setWhite;
393
393
result := False;
394
394
end ;
@@ -426,14 +426,14 @@ procedure TRhodus.compileAndRun (const src : string; interactive : boolean);
426
426
st := vm.pop;
427
427
case st.stackType of
428
428
stNone : begin end ;
429
- stInteger : printLnCallBack (Format (' %d' , [st.iValue]));
430
- stBoolean : printLnCallBack (BoolToStr(st.bValue, True));
431
- stDouble : printLnCallBack (Format(' %g' , [st.dValue]));
432
- stString : printLnCallBack (st.sValue.value );
433
- stList : printLnCallBack (st.lValue.listToString());
434
- stArray : printLnCallBack (st.aValue.arrayToString());
435
- stModule : printLnCallBack (' Module: ' + st.module .name + ' ' + st.module .helpStr);
436
- stFunction: printLnCallBack (' Function: ' + st.fValue.moduleRef.name + ' .' + st.fValue.name );
429
+ stInteger : printLnCallBack (AnsiString ( Format (' %d' , [st.iValue]) ));
430
+ stBoolean : printLnCallBack (AnsiString ( BoolToStr(st.bValue, True) ));
431
+ stDouble : printLnCallBack (AnsiString ( Format(' %g' , [st.dValue]) ));
432
+ stString : printLnCallBack (AnsiString ( st.sValue.value ) );
433
+ stList : printLnCallBack (AnsiString ( st.lValue.listToString() ));
434
+ stArray : printLnCallBack (AnsiString ( st.aValue.arrayToString() ));
435
+ stModule : printLnCallBack (AnsiString ( ' Module: ' + st.module .name + ' ' + st.module .helpStr) );
436
+ stFunction: printLnCallBack (AnsiString ( ' Function: ' + st.fValue.moduleRef.name + ' .' + st.fValue.name ) );
437
437
else
438
438
printLnCallBack (' Unrecognized type of value returned from virtual machine' );
439
439
end ;
@@ -447,16 +447,16 @@ procedure TRhodus.compileAndRun (const src : string; interactive : boolean);
447
447
if mainModule.symbolTable.items[key].fValue.isbuiltInFunction then
448
448
printLnCallBack (' No code for builtin function' )
449
449
else
450
- printLnCallBack (dissassemble(mainModule, mainModule.symbolTable.items[key].fValue.codeBlock));
450
+ printLnCallBack (AnsiString ( dissassemble(mainModule, mainModule.symbolTable.items[key].fValue.codeBlock) ));
451
451
end ;
452
- printLnCallBack (dissassemble(mainModule, mainModule.moduleProgram));
452
+ printLnCallBack (AnsiString ( dissassemble(mainModule, mainModule.moduleProgram) ));
453
453
end ;
454
454
455
455
except
456
456
on e:exception do
457
457
begin
458
458
setGreen;
459
- printLnCallBack (' ERROR: ' + e.Message);
459
+ printLnCallBack (AnsiString ( ' ERROR: ' + e.Message) );
460
460
setWhite;
461
461
end ;
462
462
end ;
0 commit comments