فهرست منبع

* added is_normal_fieldvarsym() helper and use it
o fixes several places where there was a check whether something is a
fieldvarsym, but not whether it's an instance rather than a class field

git-svn-id: trunk@43786 -

Jonas Maebe 5 سال پیش
والد
کامیت
1a9e246c29

+ 3 - 4
compiler/aasmcnst.pas

@@ -512,7 +512,7 @@ implementation
      cutils,
      cutils,
      verbose,globals,systems,widestr,
      verbose,globals,systems,widestr,
      fmodule,
      fmodule,
-     symtable,defutil;
+     symtable,symutil,defutil;
 
 
 {****************************************************************************
 {****************************************************************************
                        taggregateinformation
                        taggregateinformation
@@ -589,8 +589,7 @@ implementation
             repeat
             repeat
               inc(i);
               inc(i);
               sym:=tsym(tabstractrecorddef(def).symtable.symlist[i]);
               sym:=tsym(tabstractrecorddef(def).symtable.symlist[i]);
-            until (sym.typ=fieldvarsym) and
-              not(sp_static in sym.symoptions);
+            until is_normal_fieldvarsym(sym);
             curfield:=tfieldvarsym(sym);
             curfield:=tfieldvarsym(sym);
             nextoffset:=curfield.fieldoffset;
             nextoffset:=curfield.fieldoffset;
             curindex:=i;
             curindex:=i;
@@ -2086,7 +2085,7 @@ implementation
          begin
          begin
            sym:=search_struct_member_no_helper(tabstractrecorddef(curdef),fields[i]);
            sym:=search_struct_member_no_helper(tabstractrecorddef(curdef),fields[i]);
            if not assigned(sym) or
            if not assigned(sym) or
-              (sym.typ<>fieldvarsym) or
+              not is_normal_fieldvarsym(sym) or
               ((i<>high(fields)) and
               ((i<>high(fields)) and
                not(tfieldvarsym(sym).vardef.typ in [objectdef,recorddef])) then
                not(tfieldvarsym(sym).vardef.typ in [objectdef,recorddef])) then
              internalerror(2015071505);
              internalerror(2015071505);

+ 2 - 2
compiler/arm/cpupara.pas

@@ -59,7 +59,7 @@ unit cpupara;
 
 
     uses
     uses
        verbose,systems,cutils,
        verbose,systems,cutils,
-       defutil,symsym,symcpu,symtable,
+       defutil,symsym,symcpu,symtable,symutil,
        { PowerPC uses procinfo as well in cpupara, so this should not hurt }
        { PowerPC uses procinfo as well in cpupara, so this should not hurt }
        procinfo;
        procinfo;
 
 
@@ -294,7 +294,7 @@ unit cpupara;
                   for i:=0 to trecorddef(def).symtable.SymList.count-1 do
                   for i:=0 to trecorddef(def).symtable.SymList.count-1 do
                     begin
                     begin
                       sym:=tsym(trecorddef(def).symtable.SymList[i]);
                       sym:=tsym(trecorddef(def).symtable.SymList[i]);
-                      if sym.typ<>fieldvarsym then
+                      if not is_normal_fieldvarsym(sym) then
                         continue;
                         continue;
                       { bitfield -> ignore }
                       { bitfield -> ignore }
                       if (trecordsymtable(trecorddef(def).symtable).usefieldalignment=bit_alignment) and
                       if (trecordsymtable(trecorddef(def).symtable).usefieldalignment=bit_alignment) and

+ 2 - 2
compiler/armgen/armpara.pas

@@ -43,7 +43,7 @@ type
 implementation
 implementation
 
 
   uses
   uses
-    symconst,symdef,symsym,defutil;
+    symconst,symdef,symsym,symutil,defutil;
 
 
 
 
   function tarmgenparamanager.is_hfa(p: tdef; out basedef: tdef): boolean;
   function tarmgenparamanager.is_hfa(p: tdef; out basedef: tdef): boolean;
@@ -106,7 +106,7 @@ implementation
             for i:=0 to tabstractrecorddef(p).symtable.symlist.count-1 do
             for i:=0 to tabstractrecorddef(p).symtable.symlist.count-1 do
               begin
               begin
                 sym:=tsym(tabstractrecorddef(p).symtable.symlist[i]);
                 sym:=tsym(tabstractrecorddef(p).symtable.symlist[i]);
-                if sym.typ<>fieldvarsym then
+                if not is_normal_fieldvarsym(sym) then
                   continue;
                   continue;
                 if not is_hfa_internal(tfieldvarsym(sym).vardef,basedef,elecount) then
                 if not is_hfa_internal(tfieldvarsym(sym).vardef,basedef,elecount) then
                   exit
                   exit

+ 3 - 8
compiler/browcol.pas

@@ -1560,15 +1560,10 @@ end;
                    Symbol^.Flags:=(Symbol^.Flags or sfPointer);
                    Symbol^.Flags:=(Symbol^.Flags or sfPointer);
                    Symbol^.RelatedTypeID:=Ptrint(tpointerdef(vardef).pointeddef);
                    Symbol^.RelatedTypeID:=Ptrint(tpointerdef(vardef).pointeddef);
                  end;
                  end;
-               if typ=fieldvarsym then
-                 MemInfo.Addr:=tfieldvarsym(sym).fieldoffset
+               if tabstractnormalvarsym(sym).localloc.loc=LOC_REFERENCE then
+                 MemInfo.Addr:=tabstractnormalvarsym(sym).localloc.reference.offset
                else
                else
-                 begin
-                   if tabstractnormalvarsym(sym).localloc.loc=LOC_REFERENCE then
-                     MemInfo.Addr:=tabstractnormalvarsym(sym).localloc.reference.offset
-                   else
-                     MemInfo.Addr:=0;
-                 end;
+                 MemInfo.Addr:=0;
                if assigned(vardef) and (vardef.typ=arraydef) then
                if assigned(vardef) and (vardef.typ=arraydef) then
                  begin
                  begin
                    if tarraydef(vardef).highrange<tarraydef(vardef).lowrange then
                    if tarraydef(vardef).highrange<tarraydef(vardef).lowrange then

+ 4 - 5
compiler/dbgstabs.pas

@@ -158,7 +158,8 @@ implementation
       defutil, cgutils, parabase,
       defutil, cgutils, parabase,
       cpuinfo,cpubase,cpupi,paramgr,
       cpuinfo,cpubase,cpupi,paramgr,
       aasmbase,procinfo,
       aasmbase,procinfo,
-      finput,fmodule,ppu;
+      finput,fmodule,ppu,
+      symutil;
 
 
 
 
     const
     const
@@ -428,8 +429,7 @@ implementation
         if (tsym(p).visibility=vis_hidden) then
         if (tsym(p).visibility=vis_hidden) then
           exit;
           exit;
         { static variables from objects are like global objects }
         { static variables from objects are like global objects }
-        if (Tsym(p).typ=fieldvarsym) and
-           not(sp_static in Tsym(p).symoptions) then
+        if is_normal_fieldvarsym(Tsym(p)) then
           begin
           begin
            case tsym(p).visibility of
            case tsym(p).visibility of
              vis_private,
              vis_private,
@@ -557,8 +557,7 @@ implementation
 
 
     procedure TDebugInfoStabs.field_write_defs(p:TObject;arg:pointer);
     procedure TDebugInfoStabs.field_write_defs(p:TObject;arg:pointer);
       begin
       begin
-        if (Tsym(p).typ=fieldvarsym) and
-           not(sp_static in Tsym(p).symoptions) then
+        if is_normal_fieldvarsym(Tsym(p)) then
           appenddef(TAsmList(arg),tfieldvarsym(p).vardef);
           appenddef(TAsmList(arg),tfieldvarsym(p).vardef);
       end;
       end;
 
 

+ 2 - 2
compiler/htypechk.pas

@@ -216,7 +216,7 @@ implementation
     uses
     uses
        systems,constexp,globals,
        systems,constexp,globals,
        cutils,verbose,
        cutils,verbose,
-       symtable,
+       symtable,symutil,
        defutil,defcmp,
        defutil,defcmp,
        nbas,ncnv,nld,nmem,ncal,nmat,ninl,nutils,procinfo,
        nbas,ncnv,nld,nmem,ncal,nmat,ninl,nutils,procinfo,
        pgenutil
        pgenutil
@@ -3652,7 +3652,7 @@ implementation
           for i:=0 to def.symtable.symlist.count-1 do
           for i:=0 to def.symtable.symlist.count-1 do
             begin
             begin
               sym:=tsym(def.symtable.symlist[i]);
               sym:=tsym(def.symtable.symlist[i]);
-              if (sym.typ<>fieldvarsym) or (sp_static in sym.symoptions) then
+              if not is_normal_fieldvarsym(sym) then
                 continue;
                 continue;
               if not is_valid_for_default(tfieldvarsym(sym).vardef) then
               if not is_valid_for_default(tfieldvarsym(sym).vardef) then
                 begin
                 begin

+ 4 - 5
compiler/ncgrtti.pas

@@ -90,7 +90,7 @@ implementation
        globals,verbose,systems,
        globals,verbose,systems,
        node,ncal,ncon,
        node,ncal,ncon,
        fmodule, procinfo,
        fmodule, procinfo,
-       symtable,
+       symtable,symutil,
        aasmtai,aasmdata,
        aasmtai,aasmdata,
        defutil,
        defutil,
        paramgr
        paramgr
@@ -599,8 +599,7 @@ implementation
         for i:=0 to st.SymList.Count-1 do
         for i:=0 to st.SymList.Count-1 do
           begin
           begin
             sym:=tsym(st.SymList[i]);
             sym:=tsym(st.SymList[i]);
-            if (tsym(sym).typ=fieldvarsym) and
-               not(sp_static in tsym(sym).symoptions) and
+            if is_normal_fieldvarsym(sym) and
                (
                (
                 (rt=fullrtti) or
                 (rt=fullrtti) or
                 tfieldvarsym(sym).vardef.needs_inittable
                 tfieldvarsym(sym).vardef.needs_inittable
@@ -638,8 +637,7 @@ implementation
         for i:=0 to st.SymList.Count-1 do
         for i:=0 to st.SymList.Count-1 do
           begin
           begin
             sym:=tsym(st.SymList[i]);
             sym:=tsym(st.SymList[i]);
-            if (tsym(sym).typ=fieldvarsym) and
-               not(sp_static in tsym(sym).symoptions) and
+            if is_normal_fieldvarsym(sym) and
                (
                (
                 (rt=fullrtti) or
                 (rt=fullrtti) or
                 tfieldvarsym(sym).vardef.needs_inittable
                 tfieldvarsym(sym).vardef.needs_inittable
@@ -783,6 +781,7 @@ implementation
                tcb.emit_tai(Tai_const.Create_int_codeptr(unsetvalue),codeptruinttype);
                tcb.emit_tai(Tai_const.Create_int_codeptr(unsetvalue),codeptruinttype);
                typvalue:=3;
                typvalue:=3;
              end
              end
+           { also for accessing class fields }
            else if propaccesslist.firstsym^.sym.typ=fieldvarsym then
            else if propaccesslist.firstsym^.sym.typ=fieldvarsym then
              begin
              begin
                 address:=0;
                 address:=0;

+ 2 - 3
compiler/powerpc64/symcpu.pas

@@ -181,7 +181,7 @@ const
 implementation
 implementation
 
 
   uses
   uses
-    symconst, defutil, defcmp;
+    symconst, symutil, defutil, defcmp;
 
 
 { tcpurecorddef }
 { tcpurecorddef }
 
 
@@ -195,8 +195,7 @@ implementation
       result:=false;
       result:=false;
       for i:=0 to symtable.SymList.Count-1 do
       for i:=0 to symtable.SymList.Count-1 do
         begin
         begin
-          if (tsym(symtable.symlist[i]).typ=fieldvarsym) and
-             not(sp_static in tsym(symtable.symlist[i]).symoptions) then
+          if is_normal_fieldvarsym(tsym(symtable.symlist[i])) then
             begin
             begin
               checkdef:=tfieldvarsym(symtable.symlist[i]).vardef;
               checkdef:=tfieldvarsym(symtable.symlist[i]).vardef;
               repeat
               repeat

+ 8 - 14
compiler/symtable.pas

@@ -1556,8 +1556,7 @@ implementation
         for i:=0 to SymList.count-1 do
         for i:=0 to SymList.count-1 do
           begin
           begin
             sym:=tsym(symlist[i]);
             sym:=tsym(symlist[i]);
-            if (sym.typ=fieldvarsym) and
-               not(sp_static in sym.symoptions) and
+            if is_normal_fieldvarsym(sym) and
                (tfieldvarsym(sym).fieldoffset>=offset) then
                (tfieldvarsym(sym).fieldoffset>=offset) then
               begin
               begin
                 result:=tfieldvarsym(sym);
                 result:=tfieldvarsym(sym);
@@ -1638,8 +1637,7 @@ implementation
           { record has one field? }
           { record has one field? }
           for i:=0 to currentsymlist.Count-1 do
           for i:=0 to currentsymlist.Count-1 do
             begin
             begin
-              if (tsym(currentsymlist[i]).typ=fieldvarsym) and
-                 not(sp_static in tsym(currentsymlist[i]).symoptions) then
+              if is_normal_fieldvarsym(tsym(currentsymlist[i])) then
                 begin
                 begin
                   if result then
                   if result then
                     begin
                     begin
@@ -1696,7 +1694,7 @@ implementation
         sublist : tfplist;
         sublist : tfplist;
         i : longint;
         i : longint;
       begin
       begin
-        if sym.typ<>fieldvarsym then
+        if not is_normal_fieldvarsym(sym) then
           exit;
           exit;
         if not is_record(fsym.vardef) and not is_object(fsym.vardef) and not is_cppclass(fsym.vardef) then
         if not is_record(fsym.vardef) and not is_object(fsym.vardef) and not is_cppclass(fsym.vardef) then
           exit;
           exit;
@@ -1872,7 +1870,7 @@ implementation
         for i:=0 to unionst.SymList.Count-1 do
         for i:=0 to unionst.SymList.Count-1 do
           begin
           begin
             sym:=TSym(unionst.SymList[i]);
             sym:=TSym(unionst.SymList[i]);
-            if sym.typ<>fieldvarsym then
+            if not is_normal_fieldvarsym(sym) then
               internalerror(200601272);
               internalerror(200601272);
             if tfieldvarsym(sym).fieldoffset=0 then
             if tfieldvarsym(sym).fieldoffset=0 then
               include(tfieldvarsym(sym).varoptions,vo_is_first_field);
               include(tfieldvarsym(sym).varoptions,vo_is_first_field);
@@ -2156,8 +2154,7 @@ implementation
         i:=0;
         i:=0;
         while (i<equivst.symlist.count) do
         while (i<equivst.symlist.count) do
           begin
           begin
-            if (tsym(equivst.symlist[i]).typ<>fieldvarsym) or
-               (sp_static in tsym(equivst.symlist[i]).symoptions) then
+            if not is_normal_fieldvarsym(tsym(equivst.symlist[i])) then
               begin
               begin
                 inc(i);
                 inc(i);
                 continue;
                 continue;
@@ -2215,8 +2212,7 @@ implementation
                       begin
                       begin
                         inc(i);
                         inc(i);
                         while (i<equivst.symlist.count) and
                         while (i<equivst.symlist.count) and
-                              ((tsym(equivst.symlist[i]).typ<>fieldvarsym) or
-                               (sp_static in tsym(equivst.symlist[i]).symoptions) or
+                              (not is_normal_fieldvarsym(tsym(equivst.symlist[i])) or
                                (tfieldvarsym(equivst.symlist[i]).fieldoffset>sym.fieldoffset)) do
                                (tfieldvarsym(equivst.symlist[i]).fieldoffset>sym.fieldoffset)) do
                           inc(i);
                           inc(i);
                         continue;
                         continue;
@@ -2243,8 +2239,7 @@ implementation
         lastvaroffsetprocessed:=-1;
         lastvaroffsetprocessed:=-1;
         while (i<equivcount) do
         while (i<equivcount) do
           begin
           begin
-            if (tsym(equivst.symlist[i]).typ<>fieldvarsym) or
-               (sp_static in tsym(equivst.symlist[i]).symoptions) then
+            if not is_normal_fieldvarsym(tsym(equivst.symlist[i])) then
               begin
               begin
                 inc(i);
                 inc(i);
                 continue;
                 continue;
@@ -2285,8 +2280,7 @@ implementation
         i:=0;
         i:=0;
         while (i < equivcount) do
         while (i < equivcount) do
           begin
           begin
-            if (tsym(equivst.symlist[i]).typ<>fieldvarsym) or
-               (sp_static in tsym(equivst.symlist[i]).symoptions) then
+            if not is_normal_fieldvarsym(tsym(equivst.symlist[i])) then
               begin
               begin
                 inc(i);
                 inc(i);
                 continue;
                 continue;

+ 10 - 0
compiler/symutil.pas

@@ -36,6 +36,8 @@ interface
 
 
     procedure maybe_guarantee_record_typesym(var def: tdef; st: tsymtable);
     procedure maybe_guarantee_record_typesym(var def: tdef; st: tsymtable);
 
 
+    function is_normal_fieldvarsym(sym: tsym): boolean; inline;
+
 
 
 implementation
 implementation
 
 
@@ -143,5 +145,13 @@ implementation
       end;
       end;
 
 
 
 
+    function is_normal_fieldvarsym(sym: tsym): boolean; inline;
+      begin
+        result:=
+           (sym.typ=fieldvarsym) and
+           not(sp_static in sym.symoptions);
+      end;
+
+
 end.
 end.
 
 

+ 2 - 3
compiler/x86/rax86int.pas

@@ -126,7 +126,7 @@ Unit Rax86int;
        aasmtai,
        aasmtai,
 {$endif i8086}
 {$endif i8086}
        { symtable }
        { symtable }
-       symconst,symbase,symtype,symsym,symdef,
+       symconst,symbase,symtype,symsym,symutil,symdef,
 {$ifdef i8086}
 {$ifdef i8086}
        symcpu,
        symcpu,
 {$endif i8086}
 {$endif i8086}
@@ -1620,8 +1620,7 @@ Unit Rax86int;
                     end;
                     end;
                    if (actasmtoken=AS_DOT) or
                    if (actasmtoken=AS_DOT) or
                       (assigned(sym) and
                       (assigned(sym) and
-                       (sym.typ = fieldvarsym) and
-                       not(sp_static in sym.symoptions)) then
+                       is_normal_fieldvarsym(sym)) then
                      begin
                      begin
                       BuildRecordOffsetSize(tempstr,l,size,hs,needvmtofs,hastypecast);
                       BuildRecordOffsetSize(tempstr,l,size,hs,needvmtofs,hastypecast);
                       if hs <> '' then
                       if hs <> '' then

+ 2 - 2
compiler/x86_64/cpupara.pas

@@ -56,7 +56,7 @@ unit cpupara;
        cutils,verbose,
        cutils,verbose,
        systems,
        systems,
        globals,defutil,
        globals,defutil,
-       symtable,
+       symtable,symutil,
        cpupi,
        cpupi,
        cgx86,cgobj,cgcpu;
        cgx86,cgobj,cgcpu;
 
 
@@ -760,7 +760,7 @@ unit cpupara;
         (* Merge the fields of the structure.  *)
         (* Merge the fields of the structure.  *)
         for i:=0 to tabstractrecorddef(def).symtable.symlist.count-1 do
         for i:=0 to tabstractrecorddef(def).symtable.symlist.count-1 do
           begin
           begin
-            if tsym(tabstractrecorddef(def).symtable.symlist[i]).typ<>fieldvarsym then
+            if not is_normal_fieldvarsym(tsym(tabstractrecorddef(def).symtable.symlist[i])) then
               continue;
               continue;
             vs:=tfieldvarsym(tabstractrecorddef(def).symtable.symlist[i]);
             vs:=tfieldvarsym(tabstractrecorddef(def).symtable.symlist[i]);
             checkalignment:=true;
             checkalignment:=true;