* fix field offset in reference

This commit is contained in:
peter 2003-10-29 16:47:18 +00:00
parent 5925d38ac7
commit bef3bb7b22
3 changed files with 70 additions and 26 deletions

View File

@ -1478,7 +1478,6 @@ Begin
end
else
begin
InitRef;
expr:=actasmpattern;
Consume(AS_ID);
{ typecasting? }
@ -1526,6 +1525,7 @@ Begin
Begin
{ not found, finally ... add it anyways ... }
Message1(asmr_w_id_supposed_external,expr);
InitRef;
opr.ref.symbol:=objectlibrary.newasmsymbol(expr);
end;
end
@ -2119,7 +2119,10 @@ finalization
end.
{
$Log$
Revision 1.55 2003-10-26 13:37:22 florian
Revision 1.56 2003-10-29 16:47:18 peter
* fix field offset in reference
Revision 1.55 2003/10/26 13:37:22 florian
* fixed web bug 2128
Revision 1.54 2003/10/24 17:39:03 peter

View File

@ -1430,7 +1430,6 @@ Begin
Begin
if actasmpattern = '@RESULT' then
Begin
InitRef;
SetupResult;
Consume(AS_ID);
end
@ -1454,7 +1453,6 @@ Begin
{ support result for delphi modes }
if (m_objpas in aktmodeswitches) and (actasmpattern='RESULT') then
begin
InitRef;
SetUpResult;
Consume(AS_ID);
end
@ -1506,7 +1504,6 @@ Begin
end
else
begin
InitRef;
if not SetupVar(expr,false) then
Begin
{ not a variable, check special variables.. }
@ -1924,7 +1921,10 @@ finalization
end.
{
$Log$
Revision 1.61 2003-10-29 15:40:20 peter
Revision 1.62 2003-10-29 16:47:18 peter
* fix field offset in reference
Revision 1.61 2003/10/29 15:40:20 peter
* support indexing and offset retrieval for locals
Revision 1.60 2003/10/27 15:29:43 peter

View File

@ -787,6 +787,27 @@ Function TOperand.SetupVar(const s:string;GetOffset : boolean): Boolean;
end;
end;
procedure setconst(l:longint);
begin
{ We return the address of the field, just like Delphi/TP }
case opr.typ of
OPR_NONE :
begin
opr.typ:=OPR_CONSTANT;
opr.val:=l;
end;
OPR_CONSTANT :
inc(opr.val,l);
OPR_REFERENCE :
inc(opr.ref.offset,l);
OPR_LOCAL :
inc(opr.localsymofs,l);
else
Message(asmr_e_invalid_operand_type);
end;
end;
{ search and sets up the correct fields in the Instr record }
{ for the NON-constant identifier passed to the routine. }
{ if not found returns FALSE. }
@ -812,10 +833,16 @@ Begin
(plist^.sltype=sl_load) then
sym:=plist^.sym
else
Message(asmr_e_unsupported_symbol_type);
begin
Message(asmr_e_unsupported_symbol_type);
exit;
end;
end
else
Message(asmr_e_unsupported_symbol_type);
begin
Message(asmr_e_unsupported_symbol_type);
exit;
end;
end;
case sym.typ of
varsym :
@ -827,31 +854,40 @@ Begin
case tvarsym(sym).owner.symtabletype of
objectsymtable :
begin
{ We return the address of the field, just like Delphi/TP }
opr.typ:=OPR_CONSTANT;
opr.val:=tvarsym(sym).fieldoffset;
setconst(tvarsym(sym).fieldoffset);
hasvar:=true;
SetupVar:=true;
Exit;
end;
globalsymtable,
staticsymtable :
opr.ref.symbol:=objectlibrary.newasmsymboldata(tvarsym(sym).mangledname);
begin
initref;
opr.ref.symbol:=objectlibrary.newasmsymboldata(tvarsym(sym).mangledname);
end;
parasymtable,
localsymtable :
begin
indexreg:=opr.ref.base;
if opr.ref.index<>NR_NO then
begin
if indexreg=NR_NO then
indexreg:=opr.ref.index
else
Message(asmr_e_multiple_index);
end;
if (vo_is_external in tvarsym(sym).varoptions) then
opr.ref.symbol:=objectlibrary.newasmsymboldata(tvarsym(sym).mangledname)
begin
initref;
opr.ref.symbol:=objectlibrary.newasmsymboldata(tvarsym(sym).mangledname)
end
else
begin
if opr.typ=OPR_REFERENCE then
begin
indexreg:=opr.ref.base;
if opr.ref.index<>NR_NO then
begin
if indexreg=NR_NO then
indexreg:=opr.ref.index
else
Message(asmr_e_multiple_index);
end;
end
else
indexreg:=NR_NO;
opr.typ:=OPR_LOCAL;
if assigned(current_procinfo.parent) and
(current_procinfo.procdef.proccalloption<>pocall_inline) and
@ -892,6 +928,7 @@ Begin
end;
typedconstsym :
begin
initref;
opr.ref.symbol:=objectlibrary.newasmsymboldata(ttypedconstsym(sym).mangledname);
case ttypedconstsym(sym).typedconsttype.def.deftype of
orddef,
@ -918,8 +955,7 @@ Begin
begin
if tconstsym(sym).consttyp in [constint,constchar,constbool] then
begin
opr.typ:=OPR_CONSTANT;
opr.val:=tconstsym(sym).value.valueord;
setconst(tconstsym(sym).value.valueord);
SetupVar:=true;
Exit;
end;
@ -928,14 +964,15 @@ Begin
begin
if ttypesym(sym).restype.def.deftype in [recorddef,objectdef] then
begin
opr.typ:=OPR_CONSTANT;
opr.val:=0;
setconst(0);
SetupVar:=TRUE;
Exit;
end;
end;
procsym :
begin
if opr.typ<>OPR_NONE then
Message(asmr_e_invalid_operand_type);
if Tprocsym(sym).procdef_count>1 then
Message(asmr_w_calling_overload_func);
l:=opr.ref.offset;
@ -964,6 +1001,7 @@ begin
p:=objectlibrary.getasmsymbol(hs);
if assigned(p) then
begin
InitRef;
opr.ref.symbol:=p;
hasvar:=true;
SetupDirectVar:=true;
@ -1564,7 +1602,10 @@ end;
end.
{
$Log$
Revision 1.74 2003-10-29 15:40:20 peter
Revision 1.75 2003-10-29 16:47:18 peter
* fix field offset in reference
Revision 1.74 2003/10/29 15:40:20 peter
* support indexing and offset retrieval for locals
Revision 1.73 2003/10/28 15:36:01 peter