o fixes handling of iso i/o parameters/program parameters:

* explicit reset is needed
  * variable must be declared again

git-svn-id: trunk@30757 -
This commit is contained in:
florian 2015-05-01 20:58:31 +00:00
parent d1e48b0f71
commit 7dd1d6aa77
20 changed files with 129 additions and 12 deletions

View File

@ -94,6 +94,9 @@ type
tcpuunitsym = class(tunitsym)
end;
tcpuprogramparasym = class(tprogramparasym)
end;
tcpunamespacesym = class(tnamespacesym)
end;
@ -162,6 +165,7 @@ begin
{ used tsym classes }
clabelsym:=tcpulabelsym;
cunitsym:=tcpuunitsym;
cprogramparasym:=tcpuprogramparasym;
cnamespacesym:=tcpunamespacesym;
cprocsym:=tcpuprocsym;
ctypesym:=tcputypesym;

View File

@ -115,6 +115,10 @@ type
end;
tcpuunitsymclass = class of tcpuunitsym;
tcpuprogramparasym = class(tprogramparasym)
end;
tcpuprogramparasymclass = class(tprogramparasym);
tcpunamespacesym = class(tnamespacesym)
end;
tcpunamespacesymclass = class of tcpunamespacesym;
@ -195,6 +199,7 @@ begin
{ used tsym classes }
clabelsym:=tcpulabelsym;
cunitsym:=tcpuunitsym;
cprogramparasym:=tcpuprogramparasym;
cnamespacesym:=tcpunamespacesym;
cprocsym:=tcpuprocsym;
ctypesym:=tcputypesym;

View File

@ -119,6 +119,10 @@ type
end;
tcpuunitsymclass = class of tcpuunitsym;
tcpuprogramparasym = class(tprogramparasym)
end;
tcpuprogramparasymclass = class(tprogramparasym);
tcpunamespacesym = class(tnamespacesym)
end;
tcpunamespacesymclass = class of tcpunamespacesym;
@ -199,6 +203,7 @@ begin
{ used tsym classes }
clabelsym:=tcpulabelsym;
cunitsym:=tcpuunitsym;
cprogramparasym:=tcpuprogramparasym;
cnamespacesym:=tcpunamespacesym;
cprocsym:=tcpuprocsym;
ctypesym:=tcputypesym;

View File

@ -115,6 +115,10 @@ type
end;
tcpuunitsymclass = class of tcpuunitsym;
tcpuprogramparasym = class(tprogramparasym)
end;
tcpuprogramparasymclass = class(tprogramparasym);
tcpunamespacesym = class(tnamespacesym)
end;
tcpunamespacesymclass = class of tcpunamespacesym;
@ -195,6 +199,7 @@ begin
{ used tsym classes }
clabelsym:=tcpulabelsym;
cunitsym:=tcpuunitsym;
cprogramparasym:=tcpuprogramparasym;
cnamespacesym:=tcpunamespacesym;
cprocsym:=tcpuprocsym;
ctypesym:=tcputypesym;

View File

@ -115,6 +115,10 @@ type
end;
tcpuunitsymclass = class of tcpuunitsym;
tcpuprogramparasym = class(tprogramparasym)
end;
tcpuprogramparasymclass = class(tprogramparasym);
tcpunamespacesym = class(tnamespacesym)
end;
tcpunamespacesymclass = class of tcpunamespacesym;
@ -195,6 +199,7 @@ begin
{ used tsym classes }
clabelsym:=tcpulabelsym;
cunitsym:=tcpuunitsym;
cprogramparasym:=tcpuprogramparasym;
cnamespacesym:=tcpunamespacesym;
cprocsym:=tcpuprocsym;
ctypesym:=tcputypesym;

View File

@ -124,6 +124,10 @@ type
end;
tcpuunitsymclass = class of tcpuunitsym;
tcpuprogramparasym = class(tprogramparasym)
end;
tcpuprogramparasymclass = class(tprogramparasym);
tcpunamespacesym = class(tnamespacesym)
end;
tcpunamespacesymclass = class of tcpunamespacesym;
@ -250,6 +254,7 @@ begin
{ used tsym classes }
clabelsym:=tcpulabelsym;
cunitsym:=tcpuunitsym;
cprogramparasym:=tcpuprogramparasym;
cnamespacesym:=tcpunamespacesym;
cprocsym:=tcpuprocsym;
ctypesym:=tcputypesym;

View File

@ -153,6 +153,10 @@ type
end;
tcpuunitsymclass = class of tcpuunitsym;
tcpuprogramparasym = class(tprogramparasym)
end;
tcpuprogramparasymclass = class(tprogramparasym);
tcpunamespacesym = class(tnamespacesym)
end;
tcpunamespacesymclass = class of tcpunamespacesym;
@ -493,6 +497,7 @@ begin
{ used tsym classes }
clabelsym:=tcpulabelsym;
cunitsym:=tcpuunitsym;
cprogramparasym:=tcpuprogramparasym;
cnamespacesym:=tcpunamespacesym;
cprocsym:=tcpuprocsym;
ctypesym:=tcputypesym;

View File

@ -115,6 +115,10 @@ type
end;
tcpuunitsymclass = class of tcpuunitsym;
tcpuprogramparasym = class(tprogramparasym)
end;
tcpuprogramparasymclass = class(tprogramparasym);
tcpunamespacesym = class(tnamespacesym)
end;
tcpunamespacesymclass = class of tcpunamespacesym;
@ -195,6 +199,7 @@ begin
{ used tsym classes }
clabelsym:=tcpulabelsym;
cunitsym:=tcpuunitsym;
cprogramparasym:=tcpuprogramparasym;
cnamespacesym:=tcpunamespacesym;
cprocsym:=tcpuprocsym;
ctypesym:=tcputypesym;

View File

@ -144,6 +144,10 @@ type
end;
tcpuunitsymclass = class of tcpuunitsym;
tcpuprogramparasym = class(tprogramparasym)
end;
tcpuprogramparasymclass = class(tprogramparasym);
tcpunamespacesym = class(tnamespacesym)
end;
tcpunamespacesymclass = class of tcpunamespacesym;
@ -914,6 +918,7 @@ begin
{ used tsym classes }
clabelsym:=tcpulabelsym;
cunitsym:=tcpuunitsym;
cprogramparasym:=tcpuprogramparasym;
cnamespacesym:=tcpunamespacesym;
cprocsym:=tcpuprocsym;
ctypesym:=tcputypesym;

View File

@ -124,6 +124,10 @@ type
end;
tcpuunitsymclass = class of tcpuunitsym;
tcpuprogramparasym = class(tprogramparasym)
end;
tcpuprogramparasymclass = class(tprogramparasym);
tcpunamespacesym = class(tnamespacesym)
end;
tcpunamespacesymclass = class of tcpunamespacesym;
@ -249,6 +253,7 @@ begin
{ used tsym classes }
clabelsym:=tcpulabelsym;
cunitsym:=tcpuunitsym;
cprogramparasym:=tcpuprogramparasym;
cnamespacesym:=tcpunamespacesym;
cprocsym:=tcpuprocsym;
ctypesym:=tcputypesym;

View File

@ -117,6 +117,10 @@ type
end;
tcpuunitsymclass = class of tcpuunitsym;
tcpuprogramparasym = class(tprogramparasym)
end;
tcpuprogramparasymclass = class(tprogramparasym);
tcpunamespacesym = class(tnamespacesym)
end;
tcpunamespacesymclass = class of tcpunamespacesym;
@ -197,6 +201,7 @@ begin
{ used tsym classes }
clabelsym:=tcpulabelsym;
cunitsym:=tcpuunitsym;
cprogramparasym:=tcpuprogramparasym;
cnamespacesym:=tcpunamespacesym;
cprocsym:=tcpuprocsym;
ctypesym:=tcputypesym;

View File

@ -1921,7 +1921,7 @@ type
resources_used : boolean;
program_name : ansistring;
consume_semicolon_after_uses : boolean;
ps : tstaticvarsym;
ps : tprogramparasym;
paramnum : longint;
textsym : ttypesym;
sc : array of TProgramParam;
@ -2076,10 +2076,8 @@ type
internalerror(2013011201);
for i:=0 to high(sc) do
begin
ps:=cstaticvarsym.create(sc[i].name,vs_value,textsym.typedef,[]);
ps.isoindex:=sc[i].nr;
ps:=cprogramparasym.create(sc[i].name,sc[i].nr);
current_module.localsymtable.insert(ps,true);
cnodeutils.insertbssdata(tstaticvarsym(ps));
end;
end;

View File

@ -124,6 +124,10 @@ type
end;
tcpuunitsymclass = class of tcpuunitsym;
tcpuprogramparasym = class(tprogramparasym)
end;
tcpuprogramparasymclass = class(tprogramparasym);
tcpunamespacesym = class(tnamespacesym)
end;
tcpunamespacesymclass = class of tcpunamespacesym;
@ -249,6 +253,7 @@ begin
{ used tsym classes }
clabelsym:=tcpulabelsym;
cunitsym:=tcpuunitsym;
cprogramparasym:=tcpuprogramparasym;
cnamespacesym:=tcpunamespacesym;
cprocsym:=tcpuprocsym;
ctypesym:=tcputypesym;

View File

@ -121,6 +121,10 @@ type
end;
tcpuunitsymclass = class of tcpuunitsym;
tcpuprogramparasym = class(tprogramparasym)
end;
tcpuprogramparasymclass = class(tprogramparasym);
tcpunamespacesym = class(tnamespacesym)
end;
tcpunamespacesymclass = class of tcpunamespacesym;
@ -273,6 +277,7 @@ begin
{ used tsym classes }
clabelsym:=tcpulabelsym;
cunitsym:=tcpuunitsym;
cprogramparasym:=tcpuprogramparasym;
cnamespacesym:=tcpunamespacesym;
cprocsym:=tcpuprocsym;
ctypesym:=tcputypesym;

View File

@ -115,6 +115,10 @@ type
end;
tcpuunitsymclass = class of tcpuunitsym;
tcpuprogramparasym = class(tprogramparasym)
end;
tcpuprogramparasymclass = class(tprogramparasym);
tcpunamespacesym = class(tnamespacesym)
end;
tcpunamespacesymclass = class of tcpunamespacesym;
@ -195,6 +199,7 @@ begin
{ used tsym classes }
clabelsym:=tcpulabelsym;
cunitsym:=tcpuunitsym;
cprogramparasym:=tcpuprogramparasym;
cnamespacesym:=tcpunamespacesym;
cprocsym:=tcpuprocsym;
ctypesym:=tcputypesym;

View File

@ -585,7 +585,7 @@ type
staticvarsym,localvarsym,paravarsym,fieldvarsym,
typesym,procsym,unitsym,constsym,enumsym,
errorsym,syssym,labelsym,absolutevarsym,propertysym,
macrosym,namespacesym,undefinedsym
macrosym,namespacesym,undefinedsym,programparasym
);
{ State of the variable:
@ -704,11 +704,11 @@ inherited_objectoptions : tobjectoptions = [oo_has_virtual,oo_has_private,oo_has
pushleftright_pocalls : tproccalloptions = [pocall_register,pocall_pascal];
{$endif}
SymTypeName : array[tsymtyp] of string[12] = (
SymTypeName : array[tsymtyp] of string[14] = (
'abstractsym','globalvar','localvar','paravar','fieldvar',
'type','proc','unit','const','enum',
'errorsym','system sym','label','absolutevar','property',
'macrosym','namespace','undefinedsym'
'macrosym','namespace','undefinedsym','programparasym'
);
typName : array[tdeftyp] of string[12] = (

View File

@ -89,6 +89,17 @@ interface
end;
tunitsymclass = class of tunitsym;
tprogramparasym = class(Tstoredsym)
isoindex : dword;
constructor create(const n : string;i : dword);virtual;
constructor ppuload(ppufile:tcompilerppufile);
destructor destroy;override;
{ do not override this routine in platform-specific subclasses,
override ppuwrite_platform instead }
procedure ppuwrite(ppufile:tcompilerppufile);override;final;
end;
tprogramparasymclass = class of tprogramparasym;
tnamespacesym = class(Tstoredsym)
unitsym:tsym;
unitsymderef:tderef;
@ -460,6 +471,7 @@ interface
clabelsym: tlabelsymclass;
cunitsym: tunitsymclass;
cprogramparasym: tprogramparasymclass;
cnamespacesym: tnamespacesymclass;
cprocsym: tprocsymclass;
ctypesym: ttypesymclass;
@ -534,7 +546,6 @@ implementation
Message1(sym_w_non_implemented_symbol,srsym.realname);
end;
{****************************************************************************
TSYM (base for all symtypes)
****************************************************************************}
@ -693,6 +704,34 @@ implementation
writeentry(ppufile,ibunitsym);
end;
{****************************************************************************
TPROGRAMPARASYM
****************************************************************************}
constructor tprogramparasym.create(const n : string; i : dword);
begin
inherited create(programparasym,n);
isoindex:=i;
end;
constructor tprogramparasym.ppuload(ppufile : tcompilerppufile);
begin
{ program parameter syms (iso pascal style) might be never written to a ppu }
internalerror(2015050102);
end;
destructor tprogramparasym.destroy;
begin
inherited destroy;
end;
procedure tprogramparasym.ppuwrite(ppufile : tcompilerppufile);
begin
{ program parameter syms (iso pascal style) might be never written to a ppu }
internalerror(2015050101);
end;
{****************************************************************************
TNAMESPACESYM
****************************************************************************}

View File

@ -2192,6 +2192,14 @@ implementation
if sym.typ=symconst.namespacesym then
tnamespacesym(sym).unitsym:=tsym(hsym);
end
{ iso mode program parameters: staticvarsyms might have the same name as a program parameters,
in this case, copy the isoindex and make the original symbol invisible }
else if (m_iso in current_settings.modeswitches) and (hsym.typ=programparasym) and (sym.typ=staticvarsym)
and (tstaticvarsym(hsym).isoindex<>0) then
begin
HideSym(hsym);
tstaticvarsym(sym).isoindex:=tprogramparasym(hsym).isoindex;
end
else
DuplicateSym(hashedid,sym,hsym,false);
result:=true;

View File

@ -115,6 +115,10 @@ type
end;
tcpuunitsymclass = class of tcpuunitsym;
tcpuprogramparasym = class(tprogramparasym)
end;
tcpuprogramparasymclass = class(tprogramparasym);
tcpunamespacesym = class(tnamespacesym)
end;
tcpunamespacesymclass = class of tcpunamespacesym;
@ -195,6 +199,7 @@ begin
{ used tsym classes }
clabelsym:=tcpulabelsym;
cunitsym:=tcpuunitsym;
cprogramparasym:=tcpuprogramparasym;
cnamespacesym:=tcpunamespacesym;
cprocsym:=tcpuprocsym;
ctypesym:=tcputypesym;

View File

@ -646,12 +646,10 @@ begin
assign(t,paramstr(nr));
{$else FPC_HAS_FEATURE_COMMANDARGS}
{ primitive workaround for targets supporting no command line arguments,
invent some file name, this will be fixed later on anways because
the current way of handling iso program parameters is apparently
wrong }
invent some file name, try to avoid complex procedures like concating strings which might
pull-in bigger parts of the rtl }
assign(t,chr((nr mod 16)+65));
{$endif FPC_HAS_FEATURE_COMMANDARGS}
reset(t);
end;