implement outward calling of nested procedures, fix standalone mode
This commit is contained in:
parent
6d08db2933
commit
a1795d9b1f
1 changed files with 19 additions and 5 deletions
|
|
@ -111,7 +111,7 @@ begin
|
||||||
emitIns2('BRANCH','@+2'); (* NOP, to make alignment explicit *)
|
emitIns2('BRANCH','@+2'); (* NOP, to make alignment explicit *)
|
||||||
emitIns('.CPOOL'); (* header/prologue + 2 constants is 32 bytes *)
|
emitIns('.CPOOL'); (* header/prologue + 2 constants is 32 bytes *)
|
||||||
|
|
||||||
if useStdlib then
|
if useStdlib and not useStandalone then
|
||||||
begin
|
begin
|
||||||
writeln(outfile, '%include "stdlib.lsym"');
|
writeln(outfile, '%include "stdlib.lsym"');
|
||||||
writeln(outfile, '%incbin "stdlib.lib"');
|
writeln(outfile, '%incbin "stdlib.lib"');
|
||||||
|
|
@ -312,7 +312,12 @@ begin
|
||||||
emitArrayConsts;
|
emitArrayConsts;
|
||||||
|
|
||||||
if useStandalone then
|
if useStandalone then
|
||||||
emitInclude('corelib.s')
|
begin
|
||||||
|
emitInclude('corelib.s');
|
||||||
|
emitInclude('runtime.s');
|
||||||
|
emitInclude('float32.s');
|
||||||
|
emitInclude('stdlib.s');
|
||||||
|
end
|
||||||
else
|
else
|
||||||
emitInclude('coreloader.lsym');
|
emitInclude('coreloader.lsym');
|
||||||
|
|
||||||
|
|
@ -1059,6 +1064,7 @@ end;
|
||||||
*)
|
*)
|
||||||
procedure emitProcedureCall(aProc: ProcRef);
|
procedure emitProcedureCall(aProc: ProcRef);
|
||||||
var procLabel: IdentString;
|
var procLabel: IdentString;
|
||||||
|
i:integer;
|
||||||
begin
|
begin
|
||||||
(* pass pointer to stackframe of caller for nested procedures *)
|
(* pass pointer to stackframe of caller for nested procedures *)
|
||||||
if aProc^.isNested then
|
if aProc^.isNested then
|
||||||
|
|
@ -1069,9 +1075,17 @@ begin
|
||||||
if aProc^.level > curProcedure^.level then
|
if aProc^.level > curProcedure^.level then
|
||||||
emitIns2('LOADREG','FP')
|
emitIns2('LOADREG','FP')
|
||||||
else
|
else
|
||||||
(* TODO: calling nested aProc with a lower nesting level.
|
begin
|
||||||
need to chase a chain of old BP pointers. *)
|
(* Calling nested aProc with a lower nesting level.
|
||||||
errorExit2('internal error: outward call of nested aProc not implemented', '');
|
Need to chase a chain of old BP pointers. *)
|
||||||
|
emitIns2('LOADREG', 'BP');
|
||||||
|
(* BP points to the stackframe of the outer procedure,
|
||||||
|
@BP contains the stackframe of the procedure one step further
|
||||||
|
outwards, and so on.
|
||||||
|
*)
|
||||||
|
for i := aProc^.level + 1 to curProcedure^.level do
|
||||||
|
emitIns('LOADI');
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
emitFpAdjust(-curProcedure^.tempsSize);
|
emitFpAdjust(-curProcedure^.tempsSize);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue