|
@@ -266,19 +266,18 @@ implementation
|
|
srsym : tsym;
|
|
srsym : tsym;
|
|
para : tcallparanode;
|
|
para : tcallparanode;
|
|
newstatement : tstatementnode;
|
|
newstatement : tstatementnode;
|
|
- hdef : tdef;
|
|
|
|
begin
|
|
begin
|
|
result:=internalstatements(newstatement);
|
|
result:=internalstatements(newstatement);
|
|
|
|
|
|
- if assigned(current_procinfo.procdef._class) then
|
|
|
|
|
|
+ if assigned(current_objectdef) then
|
|
begin
|
|
begin
|
|
{ a constructor needs a help procedure }
|
|
{ a constructor needs a help procedure }
|
|
if (current_procinfo.procdef.proctypeoption=potype_constructor) then
|
|
if (current_procinfo.procdef.proctypeoption=potype_constructor) then
|
|
begin
|
|
begin
|
|
- if is_class(current_procinfo.procdef._class) then
|
|
|
|
|
|
+ if is_class(current_objectdef) then
|
|
begin
|
|
begin
|
|
include(current_procinfo.flags,pi_needs_implicit_finally);
|
|
include(current_procinfo.flags,pi_needs_implicit_finally);
|
|
- srsym:=search_class_member(current_procinfo.procdef._class,'NEWINSTANCE');
|
|
|
|
|
|
+ srsym:=search_class_member(current_objectdef,'NEWINSTANCE');
|
|
if assigned(srsym) and
|
|
if assigned(srsym) and
|
|
(srsym.typ=procsym) then
|
|
(srsym.typ=procsym) then
|
|
begin
|
|
begin
|
|
@@ -300,17 +299,15 @@ implementation
|
|
internalerror(200305108);
|
|
internalerror(200305108);
|
|
end
|
|
end
|
|
else
|
|
else
|
|
- if is_object(current_procinfo.procdef._class) then
|
|
|
|
|
|
+ if is_object(current_objectdef) then
|
|
begin
|
|
begin
|
|
- hdef:=current_procinfo.procdef._class;
|
|
|
|
- hdef:=tpointerdef.create(hdef);
|
|
|
|
{ parameter 3 : vmt_offset }
|
|
{ parameter 3 : vmt_offset }
|
|
{ parameter 2 : address of pointer to vmt,
|
|
{ parameter 2 : address of pointer to vmt,
|
|
this is required to allow setting the vmt to -1 to indicate
|
|
this is required to allow setting the vmt to -1 to indicate
|
|
that memory was allocated }
|
|
that memory was allocated }
|
|
{ parameter 1 : self pointer }
|
|
{ parameter 1 : self pointer }
|
|
para:=ccallparanode.create(
|
|
para:=ccallparanode.create(
|
|
- cordconstnode.create(current_procinfo.procdef._class.vmt_offset,s32inttype,false),
|
|
|
|
|
|
+ cordconstnode.create(current_objectdef.vmt_offset,s32inttype,false),
|
|
ccallparanode.create(
|
|
ccallparanode.create(
|
|
ctypeconvnode.create_internal(
|
|
ctypeconvnode.create_internal(
|
|
load_vmt_pointer_node,
|
|
load_vmt_pointer_node,
|
|
@@ -341,9 +338,9 @@ implementation
|
|
|
|
|
|
{ maybe call BeforeDestruction for classes }
|
|
{ maybe call BeforeDestruction for classes }
|
|
if (current_procinfo.procdef.proctypeoption=potype_destructor) and
|
|
if (current_procinfo.procdef.proctypeoption=potype_destructor) and
|
|
- is_class(current_procinfo.procdef._class) then
|
|
|
|
|
|
+ is_class(current_objectdef) then
|
|
begin
|
|
begin
|
|
- srsym:=search_class_member(current_procinfo.procdef._class,'BEFOREDESTRUCTION');
|
|
|
|
|
|
+ srsym:=search_class_member(current_objectdef,'BEFOREDESTRUCTION');
|
|
if assigned(srsym) and
|
|
if assigned(srsym) and
|
|
(srsym.typ=procsym) then
|
|
(srsym.typ=procsym) then
|
|
begin
|
|
begin
|
|
@@ -373,7 +370,7 @@ implementation
|
|
begin
|
|
begin
|
|
result:=internalstatements(newstatement);
|
|
result:=internalstatements(newstatement);
|
|
|
|
|
|
- if assigned(current_procinfo.procdef._class) then
|
|
|
|
|
|
+ if assigned(current_objectdef) then
|
|
begin
|
|
begin
|
|
{ Don't test self and the vmt here. The reason is that }
|
|
{ Don't test self and the vmt here. The reason is that }
|
|
{ a constructor already checks whether these are valid }
|
|
{ a constructor already checks whether these are valid }
|
|
@@ -384,9 +381,9 @@ implementation
|
|
current_settings.localswitches:=oldlocalswitches-[cs_check_object,cs_check_range];
|
|
current_settings.localswitches:=oldlocalswitches-[cs_check_object,cs_check_range];
|
|
{ maybe call AfterConstruction for classes }
|
|
{ maybe call AfterConstruction for classes }
|
|
if (current_procinfo.procdef.proctypeoption=potype_constructor) and
|
|
if (current_procinfo.procdef.proctypeoption=potype_constructor) and
|
|
- is_class(current_procinfo.procdef._class) then
|
|
|
|
|
|
+ is_class(current_objectdef) then
|
|
begin
|
|
begin
|
|
- srsym:=search_class_member(current_procinfo.procdef._class,'AFTERCONSTRUCTION');
|
|
|
|
|
|
+ srsym:=search_class_member(current_objectdef,'AFTERCONSTRUCTION');
|
|
if assigned(srsym) and
|
|
if assigned(srsym) and
|
|
(srsym.typ=procsym) then
|
|
(srsym.typ=procsym) then
|
|
begin
|
|
begin
|
|
@@ -410,9 +407,9 @@ implementation
|
|
{ a destructor needs a help procedure }
|
|
{ a destructor needs a help procedure }
|
|
if (current_procinfo.procdef.proctypeoption=potype_destructor) then
|
|
if (current_procinfo.procdef.proctypeoption=potype_destructor) then
|
|
begin
|
|
begin
|
|
- if is_class(current_procinfo.procdef._class) then
|
|
|
|
|
|
+ if is_class(current_objectdef) then
|
|
begin
|
|
begin
|
|
- srsym:=search_class_member(current_procinfo.procdef._class,'FREEINSTANCE');
|
|
|
|
|
|
+ srsym:=search_class_member(current_objectdef,'FREEINSTANCE');
|
|
if assigned(srsym) and
|
|
if assigned(srsym) and
|
|
(srsym.typ=procsym) then
|
|
(srsym.typ=procsym) then
|
|
begin
|
|
begin
|
|
@@ -434,16 +431,16 @@ implementation
|
|
internalerror(200305108);
|
|
internalerror(200305108);
|
|
end
|
|
end
|
|
else
|
|
else
|
|
- if is_object(current_procinfo.procdef._class) then
|
|
|
|
|
|
+ if is_object(current_objectdef) then
|
|
begin
|
|
begin
|
|
{ finalize object data }
|
|
{ finalize object data }
|
|
- if current_procinfo.procdef._class.needs_inittable then
|
|
|
|
|
|
+ if current_objectdef.needs_inittable then
|
|
addstatement(newstatement,finalize_data_node(load_self_node));
|
|
addstatement(newstatement,finalize_data_node(load_self_node));
|
|
{ parameter 3 : vmt_offset }
|
|
{ parameter 3 : vmt_offset }
|
|
{ parameter 2 : pointer to vmt }
|
|
{ parameter 2 : pointer to vmt }
|
|
{ parameter 1 : self pointer }
|
|
{ parameter 1 : self pointer }
|
|
para:=ccallparanode.create(
|
|
para:=ccallparanode.create(
|
|
- cordconstnode.create(current_procinfo.procdef._class.vmt_offset,s32inttype,false),
|
|
|
|
|
|
+ cordconstnode.create(current_objectdef.vmt_offset,s32inttype,false),
|
|
ccallparanode.create(
|
|
ccallparanode.create(
|
|
ctypeconvnode.create_internal(
|
|
ctypeconvnode.create_internal(
|
|
load_vmt_pointer_node,
|
|
load_vmt_pointer_node,
|
|
@@ -474,14 +471,14 @@ implementation
|
|
|
|
|
|
{ a constructor needs call destructor (if available) when it
|
|
{ a constructor needs call destructor (if available) when it
|
|
is not inherited }
|
|
is not inherited }
|
|
- if assigned(current_procinfo.procdef._class) and
|
|
|
|
|
|
+ if assigned(current_objectdef) and
|
|
(current_procinfo.procdef.proctypeoption=potype_constructor) then
|
|
(current_procinfo.procdef.proctypeoption=potype_constructor) then
|
|
begin
|
|
begin
|
|
{ Don't test self and the vmt here. See generate_bodyexit_block }
|
|
{ Don't test self and the vmt here. See generate_bodyexit_block }
|
|
{ why (JM) }
|
|
{ why (JM) }
|
|
oldlocalswitches:=current_settings.localswitches;
|
|
oldlocalswitches:=current_settings.localswitches;
|
|
current_settings.localswitches:=oldlocalswitches-[cs_check_object,cs_check_range];
|
|
current_settings.localswitches:=oldlocalswitches-[cs_check_object,cs_check_range];
|
|
- pd:=current_procinfo.procdef._class.Finddestructor;
|
|
|
|
|
|
+ pd:=current_objectdef.Finddestructor;
|
|
if assigned(pd) then
|
|
if assigned(pd) then
|
|
begin
|
|
begin
|
|
{ if vmt<>0 then call destructor }
|
|
{ if vmt<>0 then call destructor }
|
|
@@ -691,9 +688,10 @@ implementation
|
|
|
|
|
|
procedure tcgprocinfo.generate_code;
|
|
procedure tcgprocinfo.generate_code;
|
|
var
|
|
var
|
|
- oldprocinfo : tprocinfo;
|
|
|
|
|
|
+ old_current_procinfo : tprocinfo;
|
|
oldmaxfpuregisters : longint;
|
|
oldmaxfpuregisters : longint;
|
|
oldfilepos : tfileposinfo;
|
|
oldfilepos : tfileposinfo;
|
|
|
|
+ old_current_objectdef : tobjectdef;
|
|
templist : TAsmList;
|
|
templist : TAsmList;
|
|
headertai : tai;
|
|
headertai : tai;
|
|
i : integer;
|
|
i : integer;
|
|
@@ -717,12 +715,14 @@ implementation
|
|
if assigned(tg) then
|
|
if assigned(tg) then
|
|
internalerror(200309201);
|
|
internalerror(200309201);
|
|
|
|
|
|
- oldprocinfo:=current_procinfo;
|
|
|
|
|
|
+ old_current_procinfo:=current_procinfo;
|
|
oldfilepos:=current_filepos;
|
|
oldfilepos:=current_filepos;
|
|
|
|
+ old_current_objectdef:=current_objectdef;
|
|
oldmaxfpuregisters:=current_settings.maxfpuregisters;
|
|
oldmaxfpuregisters:=current_settings.maxfpuregisters;
|
|
|
|
|
|
current_procinfo:=self;
|
|
current_procinfo:=self;
|
|
current_filepos:=entrypos;
|
|
current_filepos:=entrypos;
|
|
|
|
+ current_objectdef:=procdef._class;
|
|
|
|
|
|
templist:=TAsmList.create;
|
|
templist:=TAsmList.create;
|
|
|
|
|
|
@@ -1139,7 +1139,8 @@ implementation
|
|
templist.free;
|
|
templist.free;
|
|
current_settings.maxfpuregisters:=oldmaxfpuregisters;
|
|
current_settings.maxfpuregisters:=oldmaxfpuregisters;
|
|
current_filepos:=oldfilepos;
|
|
current_filepos:=oldfilepos;
|
|
- current_procinfo:=oldprocinfo;
|
|
|
|
|
|
+ current_objectdef:=old_current_objectdef;
|
|
|
|
+ current_procinfo:=old_current_procinfo;
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
|
|
@@ -1266,21 +1267,22 @@ implementation
|
|
|
|
|
|
procedure tcgprocinfo.parse_body;
|
|
procedure tcgprocinfo.parse_body;
|
|
var
|
|
var
|
|
- oldprocinfo : tprocinfo;
|
|
|
|
- oldblock_type : tblock_type;
|
|
|
|
|
|
+ old_current_procinfo : tprocinfo;
|
|
|
|
+ old_block_type : tblock_type;
|
|
st : TSymtable;
|
|
st : TSymtable;
|
|
|
|
+ old_current_objectdef : tobjectdef;
|
|
begin
|
|
begin
|
|
- oldprocinfo:=current_procinfo;
|
|
|
|
- oldblock_type:=block_type;
|
|
|
|
-
|
|
|
|
- { reset break and continue labels }
|
|
|
|
- block_type:=bt_body;
|
|
|
|
|
|
+ old_current_procinfo:=current_procinfo;
|
|
|
|
+ old_block_type:=block_type;
|
|
|
|
+ old_current_objectdef:=current_objectdef;
|
|
|
|
|
|
current_procinfo:=self;
|
|
current_procinfo:=self;
|
|
|
|
+ current_objectdef:=procdef._class;
|
|
|
|
|
|
{ calculate the lexical level }
|
|
{ calculate the lexical level }
|
|
if procdef.parast.symtablelevel>maxnesting then
|
|
if procdef.parast.symtablelevel>maxnesting then
|
|
Message(parser_e_too_much_lexlevel);
|
|
Message(parser_e_too_much_lexlevel);
|
|
|
|
+ block_type:=bt_body;
|
|
|
|
|
|
{$ifdef state_tracking}
|
|
{$ifdef state_tracking}
|
|
{ aktstate:=Tstate_storage.create;}
|
|
{ aktstate:=Tstate_storage.create;}
|
|
@@ -1383,10 +1385,11 @@ implementation
|
|
{ aktstate.destroy;}
|
|
{ aktstate.destroy;}
|
|
{$endif state_tracking}
|
|
{$endif state_tracking}
|
|
|
|
|
|
- current_procinfo:=oldprocinfo;
|
|
|
|
|
|
+ current_objectdef:=old_current_objectdef;
|
|
|
|
+ current_procinfo:=old_current_procinfo;
|
|
|
|
|
|
{ Restore old state }
|
|
{ Restore old state }
|
|
- block_type:=oldblock_type;
|
|
|
|
|
|
+ block_type:=old_block_type;
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
|
|
@@ -1526,23 +1529,22 @@ implementation
|
|
|
|
|
|
var
|
|
var
|
|
old_current_procinfo : tprocinfo;
|
|
old_current_procinfo : tprocinfo;
|
|
|
|
+ old_current_objectdef : tobjectdef;
|
|
pdflags : tpdflags;
|
|
pdflags : tpdflags;
|
|
pd,firstpd : tprocdef;
|
|
pd,firstpd : tprocdef;
|
|
s : string;
|
|
s : string;
|
|
begin
|
|
begin
|
|
{ save old state }
|
|
{ save old state }
|
|
old_current_procinfo:=current_procinfo;
|
|
old_current_procinfo:=current_procinfo;
|
|
|
|
+ old_current_objectdef:=current_objectdef;
|
|
|
|
|
|
{ reset current_procinfo.procdef to nil to be sure that nothing is writing
|
|
{ reset current_procinfo.procdef to nil to be sure that nothing is writing
|
|
to an other procdef }
|
|
to an other procdef }
|
|
current_procinfo:=nil;
|
|
current_procinfo:=nil;
|
|
|
|
+ current_objectdef:=nil;
|
|
|
|
|
|
{ parse procedure declaration }
|
|
{ parse procedure declaration }
|
|
- if assigned(old_current_procinfo) and
|
|
|
|
- assigned(old_current_procinfo.procdef) then
|
|
|
|
- pd:=parse_proc_dec(old_current_procinfo.procdef._class)
|
|
|
|
- else
|
|
|
|
- pd:=parse_proc_dec(nil);
|
|
|
|
|
|
+ pd:=parse_proc_dec(old_current_objectdef);
|
|
|
|
|
|
{ set the default function options }
|
|
{ set the default function options }
|
|
if parse_only then
|
|
if parse_only then
|
|
@@ -1586,7 +1588,7 @@ implementation
|
|
begin
|
|
begin
|
|
{ A method must be forward defined (in the object declaration) }
|
|
{ A method must be forward defined (in the object declaration) }
|
|
if assigned(pd._class) and
|
|
if assigned(pd._class) and
|
|
- (not assigned(old_current_procinfo.procdef._class)) then
|
|
|
|
|
|
+ (not assigned(old_current_objectdef)) then
|
|
begin
|
|
begin
|
|
MessagePos1(pd.fileinfo,parser_e_header_dont_match_any_member,pd.fullprocname(false));
|
|
MessagePos1(pd.fileinfo,parser_e_header_dont_match_any_member,pd.fullprocname(false));
|
|
tprocsym(pd.procsym).write_parameter_lists(pd);
|
|
tprocsym(pd.procsym).write_parameter_lists(pd);
|
|
@@ -1667,6 +1669,7 @@ implementation
|
|
current_asmdata.DefineAsmSymbol(pd.mangledname,AB_LOCAL,AT_FUNCTION);
|
|
current_asmdata.DefineAsmSymbol(pd.mangledname,AB_LOCAL,AT_FUNCTION);
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
+ current_objectdef:=old_current_objectdef;
|
|
current_procinfo:=old_current_procinfo;
|
|
current_procinfo:=old_current_procinfo;
|
|
end;
|
|
end;
|
|
|
|
|