From 03c02cdb4227bd6192b3429b428cba9525ae30bd Mon Sep 17 00:00:00 2001 From: peter Date: Wed, 20 Jul 2005 11:30:00 +0000 Subject: [PATCH] * support Type[index] typecasting git-svn-id: trunk@711 - --- compiler/i386/ra386int.pas | 30 +++++++++++++++++++++--------- compiler/rautils.pas | 21 +++++++++++++++++++++ 2 files changed, 42 insertions(+), 9 deletions(-) diff --git a/compiler/i386/ra386int.pas b/compiler/i386/ra386int.pas index 8b99432bf4..4f80643426 100644 --- a/compiler/i386/ra386int.pas +++ b/compiler/i386/ra386int.pas @@ -711,7 +711,7 @@ Unit Ra386int; begin Consume(AS_DOT); if actasmtoken=AS_ID then - s:=s+'.'+actasmpattern; + s:=s+'.'+actasmpattern; if not Consume(AS_ID) then begin RecoverConsume(true); @@ -1622,14 +1622,26 @@ Unit Ra386int; if SearchType(expr,typesize) then begin oper.hastype:=true; - if (actasmtoken=AS_LPAREN) then - begin - Consume(AS_LPAREN); - BuildOperand(oper); - Consume(AS_RPAREN); - if oper.opr.typ in [OPR_REFERENCE,OPR_LOCAL] then - oper.SetSize(typesize,true); - end; + case actasmtoken of + AS_LPAREN : + begin + { Support Type([Reference]) } + Consume(AS_LPAREN); + BuildOperand(oper); + Consume(AS_RPAREN); + if oper.opr.typ in [OPR_REFERENCE,OPR_LOCAL] then + oper.SetSize(typesize,true); + end; + AS_LBRACKET : + begin + { Support Var.Type[Index] } + { Convert @label.Byte[1] to reference } + if oper.opr.typ=OPR_SYMBOL then + oper.initref; + if oper.opr.typ in [OPR_REFERENCE,OPR_LOCAL] then + oper.SetSize(typesize,true); + end; + end; end else begin diff --git a/compiler/rautils.pas b/compiler/rautils.pas index e1afa9b6ad..dec8206fc9 100644 --- a/compiler/rautils.pas +++ b/compiler/rautils.pas @@ -944,6 +944,8 @@ procedure TOperand.InitRef; {*********************************************************************} var l : aint; + hsymofs : aint; + hsymbol : tasmsymbol; reg : tregister; Begin case opr.typ of @@ -968,6 +970,15 @@ Begin Fillchar(opr.ref,sizeof(treference),0); opr.Ref.base:=reg; end; + OPR_SYMBOL : + begin + hsymbol:=opr.symbol; + hsymofs:=opr.symofs; + opr.typ:=OPR_REFERENCE; + Fillchar(opr.ref,sizeof(treference),0); + opr.ref.symbol:=hsymbol; + opr.ref.offset:=hsymofs; + end; else begin Message(asmr_e_invalid_operand_type); @@ -1346,6 +1357,16 @@ Begin end; end; end; + { Support Field.Type as typecasting } + if (st=nil) and (s<>'') then + begin + asmsearchsym(s,sym,srsymtable); + if assigned(sym) and (sym.typ=typesym) then + begin + size:=ttypesym(sym).restype.def.size; + s:='' + end; + end; GetRecordOffsetSize:=(s=''); end;