Extend tstaticvarsym (and by extension tabstractnormalvarsym) with the capability to create it as unregistered if needed.

git-svn-id: trunk@32373 -
This commit is contained in:
svenbarth 2015-11-20 11:15:30 +00:00
parent 922646d106
commit 0ac12f0eaf
7 changed files with 22 additions and 22 deletions

View File

@ -174,7 +174,7 @@ implementation
{ find the type of the descriptor structure } { find the type of the descriptor structure }
descriptordef:=search_named_unit_globaltype('BLOCKRTL','FPC_BLOCK_DESCRIPTOR_SIMPLE',true).typedef; descriptordef:=search_named_unit_globaltype('BLOCKRTL','FPC_BLOCK_DESCRIPTOR_SIMPLE',true).typedef;
{ create new static variable } { create new static variable }
descriptor:=cstaticvarsym.create(name,vs_value,descriptordef,[]); descriptor:=cstaticvarsym.create(name,vs_value,descriptordef,[],true);
symtablestack.top.insert(descriptor); symtablestack.top.insert(descriptor);
include(descriptor.symoptions,sp_internal); include(descriptor.symoptions,sp_internal);
{ create typed constant for the descriptor } { create typed constant for the descriptor }
@ -253,7 +253,7 @@ implementation
result:=cstaticvarsym.create( result:=cstaticvarsym.create(
'$'+literalname, '$'+literalname,
vs_value, vs_value,
blockliteraldef,[]); blockliteraldef,[],true);
include(result.symoptions,sp_internal); include(result.symoptions,sp_internal);
symtablestack.top.insert(result); symtablestack.top.insert(result);
{ initialise it } { initialise it }

View File

@ -204,7 +204,7 @@ implementation
begin begin
vs:=cstaticvarsym.create(sym.realname+'$threadvar',sym.varspez, vs:=cstaticvarsym.create(sym.realname+'$threadvar',sym.varspez,
jvmgetthreadvardef(sym.vardef), jvmgetthreadvardef(sym.vardef),
sym.varoptions - [vo_is_thread_var]); sym.varoptions - [vo_is_thread_var],true);
sym.owner.insert(vs); sym.owner.insert(vs);
{ make sure that the new sym does not get allocated (we will allocate { make sure that the new sym does not get allocated (we will allocate
it when encountering the original sym, because only then we know it when encountering the original sym, because only then we know

View File

@ -350,7 +350,7 @@ implementation
initialization code } initialization code }
if tenumsym(tenumdef(def).symtable.symlist[i]).value=0 then if tenumsym(tenumdef(def).symtable.symlist[i]).value=0 then
begin begin
aliassym:=cstaticvarsym.create('__FPC_Zero_Initializer',vs_final,enumclass,[vo_is_external]); aliassym:=cstaticvarsym.create('__FPC_Zero_Initializer',vs_final,enumclass,[vo_is_external],true);
enumclass.symtable.insert(aliassym); enumclass.symtable.insert(aliassym);
aliassym.set_raw_mangledname(sym.mangledname); aliassym.set_raw_mangledname(sym.mangledname);
end; end;
@ -737,7 +737,7 @@ implementation
begin begin
{ make sure we don't emit a definition for this field (we'll do { make sure we don't emit a definition for this field (we'll do
that for the constsym already) -> mark as external } that for the constsym already) -> mark as external }
ssym:=cstaticvarsym.create(internal_static_field_name(csym.realname),vs_final,csym.constdef,[vo_is_external]); ssym:=cstaticvarsym.create(internal_static_field_name(csym.realname),vs_final,csym.constdef,[vo_is_external],true);
csym.owner.insert(ssym); csym.owner.insert(ssym);
{ alias storage to the constsym } { alias storage to the constsym }
ssym.set_mangledname(csym.realname); ssym.set_mangledname(csym.realname);
@ -775,7 +775,7 @@ implementation
has been compiler -> insert a copy in the unit's staticsymtable has been compiler -> insert a copy in the unit's staticsymtable
} }
symtablestack.push(current_module.localsymtable); symtablestack.push(current_module.localsymtable);
ssym:=cstaticvarsym.create(internal_static_field_name(csym.realname),vs_final,tsetdef(csym.constdef).getcopy,[vo_is_external,vo_has_local_copy]); ssym:=cstaticvarsym.create(internal_static_field_name(csym.realname),vs_final,tsetdef(csym.constdef).getcopy,[vo_is_external,vo_has_local_copy],true);
symtablestack.top.insert(ssym); symtablestack.top.insert(ssym);
symtablestack.pop(current_module.localsymtable); symtablestack.pop(current_module.localsymtable);
{ alias storage to the constsym } { alias storage to the constsym }

View File

@ -272,7 +272,7 @@ implementation
end end
else else
begin begin
sym:=cstaticvarsym.create(orgname,varspez,hdef,[]); sym:=cstaticvarsym.create(orgname,varspez,hdef,[],true);
sym.visibility:=symtablestack.top.currentvisibility; sym.visibility:=symtablestack.top.currentvisibility;
symtablestack.top.insert(sym); symtablestack.top.insert(sym);
end; end;
@ -352,7 +352,7 @@ implementation
end end
else else
begin begin
labelsym.jumpbuf:=cstaticvarsym.create('LABEL$_'+labelsym.name,vs_value,rec_jmp_buf,[]); labelsym.jumpbuf:=cstaticvarsym.create('LABEL$_'+labelsym.name,vs_value,rec_jmp_buf,[],true);
symtablestack.top.insert(labelsym.jumpbuf); symtablestack.top.insert(labelsym.jumpbuf);
cnodeutils.insertbssdata(tstaticvarsym(labelsym.jumpbuf)); cnodeutils.insertbssdata(tstaticvarsym(labelsym.jumpbuf));
end; end;

View File

@ -1066,7 +1066,7 @@ implementation
case vs.typ of case vs.typ of
localvarsym : localvarsym :
begin begin
tcsym:=cstaticvarsym.create('$default'+vs.realname,vs_const,vs.vardef,[]); tcsym:=cstaticvarsym.create('$default'+vs.realname,vs_const,vs.vardef,[],true);
include(tcsym.symoptions,sp_internal); include(tcsym.symoptions,sp_internal);
vs.defaultconstsym:=tcsym; vs.defaultconstsym:=tcsym;
symtablestack.top.insert(tcsym); symtablestack.top.insert(tcsym);
@ -1296,7 +1296,7 @@ implementation
staticsymtable, staticsymtable,
globalsymtable : globalsymtable :
begin begin
vs:=cstaticvarsym.create(orgpattern,vs_value,generrordef,[]); vs:=cstaticvarsym.create(orgpattern,vs_value,generrordef,[],true);
if vd_threadvar in options then if vd_threadvar in options then
include(vs.varoptions,vo_is_thread_var); include(vs.varoptions,vo_is_thread_var);
end; end;

View File

@ -650,7 +650,7 @@ implementation
begin begin
{ insert symbol for got access in assembler code} { insert symbol for got access in assembler code}
gotvarsym:=cstaticvarsym.create('_GLOBAL_OFFSET_TABLE_', gotvarsym:=cstaticvarsym.create('_GLOBAL_OFFSET_TABLE_',
vs_value,voidpointertype,[vo_is_external]); vs_value,voidpointertype,[vo_is_external],true);
gotvarsym.set_mangledname('_GLOBAL_OFFSET_TABLE_'); gotvarsym.set_mangledname('_GLOBAL_OFFSET_TABLE_');
current_module.localsymtable.insert(gotvarsym); current_module.localsymtable.insert(gotvarsym);
{ avoid unnecessary warnings } { avoid unnecessary warnings }

View File

@ -240,7 +240,7 @@ interface
{ the variable is not living at entry of the scope, so it does not need to be initialized if it is a reg. var { the variable is not living at entry of the scope, so it does not need to be initialized if it is a reg. var
(not written to ppu, because not important and would change interface crc) } (not written to ppu, because not important and would change interface crc) }
noregvarinitneeded : boolean; noregvarinitneeded : boolean;
constructor create(st:tsymtyp;const n : string;vsp:tvarspez;def:tdef;vopts:tvaroptions); constructor create(st:tsymtyp;const n : string;vsp:tvarspez;def:tdef;vopts:tvaroptions;doregister:boolean);
constructor ppuload(st:tsymtyp;ppufile:tcompilerppufile); constructor ppuload(st:tsymtyp;ppufile:tcompilerppufile);
function globalasmsym: boolean; function globalasmsym: boolean;
procedure ppuwrite(ppufile:tcompilerppufile);override; procedure ppuwrite(ppufile:tcompilerppufile);override;
@ -296,7 +296,7 @@ interface
to the symbol of the corresponding class field } to the symbol of the corresponding class field }
fieldvarsym : tfieldvarsym; fieldvarsym : tfieldvarsym;
fieldvarsymderef : tderef; fieldvarsymderef : tderef;
constructor create(const n : string;vsp:tvarspez;def:tdef;vopts:tvaroptions);virtual; constructor create(const n : string;vsp:tvarspez;def:tdef;vopts:tvaroptions;doregister:boolean);virtual;
constructor create_dll(const n : string;vsp:tvarspez;def:tdef);virtual; constructor create_dll(const n : string;vsp:tvarspez;def:tdef);virtual;
constructor create_C(const n: string; const mangled : TSymStr;vsp:tvarspez;def:tdef);virtual; constructor create_C(const n: string; const mangled : TSymStr;vsp:tvarspez;def:tdef);virtual;
constructor create_from_fieldvar(const n:string;fieldvar:tfieldvarsym);virtual; constructor create_from_fieldvar(const n:string;fieldvar:tfieldvarsym);virtual;
@ -1827,9 +1827,9 @@ implementation
TABSTRACTNORMALVARSYM TABSTRACTNORMALVARSYM
****************************************************************************} ****************************************************************************}
constructor tabstractnormalvarsym.create(st:tsymtyp;const n : string;vsp:tvarspez;def:tdef;vopts:tvaroptions); constructor tabstractnormalvarsym.create(st:tsymtyp;const n : string;vsp:tvarspez;def:tdef;vopts:tvaroptions;doregister:boolean);
begin begin
inherited create(st,n,vsp,def,vopts,true); inherited create(st,n,vsp,def,vopts,doregister);
fillchar(localloc,sizeof(localloc),0); fillchar(localloc,sizeof(localloc),0);
fillchar(currentregloc,sizeof(localloc),0); fillchar(currentregloc,sizeof(localloc),0);
fillchar(initialloc,sizeof(initialloc),0); fillchar(initialloc,sizeof(initialloc),0);
@ -1889,9 +1889,9 @@ implementation
Tstaticvarsym Tstaticvarsym
****************************************************************************} ****************************************************************************}
constructor tstaticvarsym.create(const n : string;vsp:tvarspez;def:tdef;vopts:tvaroptions); constructor tstaticvarsym.create(const n : string;vsp:tvarspez;def:tdef;vopts:tvaroptions;doregister:boolean);
begin begin
inherited create(staticvarsym,n,vsp,def,vopts); inherited create(staticvarsym,n,vsp,def,vopts,doregister);
{$ifdef symansistr} {$ifdef symansistr}
_mangledname:=''; _mangledname:='';
{$else symansistr} {$else symansistr}
@ -1902,20 +1902,20 @@ implementation
constructor tstaticvarsym.create_dll(const n : string;vsp:tvarspez;def:tdef); constructor tstaticvarsym.create_dll(const n : string;vsp:tvarspez;def:tdef);
begin begin
tstaticvarsym(self).create(n,vsp,def,[vo_is_dll_var]); tstaticvarsym(self).create(n,vsp,def,[vo_is_dll_var],true);
end; end;
constructor tstaticvarsym.create_C(const n: string; const mangled : TSymStr;vsp:tvarspez;def:tdef); constructor tstaticvarsym.create_C(const n: string; const mangled : TSymStr;vsp:tvarspez;def:tdef);
begin begin
tstaticvarsym(self).create(n,vsp,def,[]); tstaticvarsym(self).create(n,vsp,def,[],true);
set_mangledname(mangled); set_mangledname(mangled);
end; end;
constructor tstaticvarsym.create_from_fieldvar(const n: string;fieldvar:tfieldvarsym); constructor tstaticvarsym.create_from_fieldvar(const n: string;fieldvar:tfieldvarsym);
begin begin
create(internal_static_field_name(n),vs_value,fieldvar.vardef,[]); create(internal_static_field_name(n),vs_value,fieldvar.vardef,[],true);
fieldvarsym:=fieldvar; fieldvarsym:=fieldvar;
end; end;
@ -2086,7 +2086,7 @@ implementation
constructor tlocalvarsym.create(const n : string;vsp:tvarspez;def:tdef;vopts:tvaroptions); constructor tlocalvarsym.create(const n : string;vsp:tvarspez;def:tdef;vopts:tvaroptions);
begin begin
inherited create(localvarsym,n,vsp,def,vopts); inherited create(localvarsym,n,vsp,def,vopts,true);
end; end;
@ -2110,7 +2110,7 @@ implementation
constructor tparavarsym.create(const n : string;nr:word;vsp:tvarspez;def:tdef;vopts:tvaroptions); constructor tparavarsym.create(const n : string;nr:word;vsp:tvarspez;def:tdef;vopts:tvaroptions);
begin begin
inherited create(paravarsym,n,vsp,def,vopts); inherited create(paravarsym,n,vsp,def,vopts,true);
if (vsp in [vs_var,vs_value,vs_const,vs_constref]) and if (vsp in [vs_var,vs_value,vs_const,vs_constref]) and
not(vo_is_funcret in vopts) then not(vo_is_funcret in vopts) then
varstate := vs_initialised; varstate := vs_initialised;