+ TSymtablestack.getcopyuntil() method that creates a copy of a

symtablestack up to and including a particular symtable

git-svn-id: branches/jvmbackend@18582 -
This commit is contained in:
Jonas Maebe 2011-08-20 08:12:29 +00:00
parent e9e72e6de0
commit 1bc846dd3c

View File

@ -133,6 +133,7 @@ interface
procedure push(st:TSymtable); virtual;
procedure pop(st:TSymtable); virtual;
function top:TSymtable;
function getcopyuntil(finalst: TSymtable): TSymtablestack;
end;
@ -430,6 +431,30 @@ implementation
end;
function addstitemreverse(st: TSymtablestack; finalst: tsymtable; curitem: psymtablestackitem): boolean;
begin
if not assigned(curitem) then
begin
result:=true;
exit;
end;
if addstitemreverse(st,finalst,curitem^.next) then
begin
st.push(curitem^.symtable);
result:=curitem^.symtable<>finalst
end
else
result:=false
end;
function TSymtablestack.getcopyuntil(finalst: TSymtable): TSymtablestack;
begin
result:=TSymtablestack.create;
addstitemreverse(result,finalst,stack);
end;
{$ifdef MEMDEBUG}
initialization
memrealnames:=TMemDebug.create('Realnames');