Ver código fonte

* considering that at least in theory every symbol and every def can carry RTTI attributes (Delphi only supports property and field symbols), move the rtti_attribute_list to tstoredsym/tstoreddef

git-svn-id: trunk@42374 -
svenbarth 6 anos atrás
pai
commit
a1b556d211
2 arquivos alterados com 21 adições e 23 exclusões
  1. 18 21
      compiler/symdef.pas
  2. 3 2
      compiler/symsym.pas

+ 18 - 21
compiler/symdef.pas

@@ -58,6 +58,21 @@ interface
          procedure deref;
        end;
 
+       { trtti_attribute_list }
+
+       trtti_attribute = class
+          typesym         : tsym;
+          constructorcall : tnode;
+          symbolname      : string;
+       end;
+
+       trtti_attribute_list = class
+          rtti_attributes    : TFPObjectList;
+          procedure addattribute(atypesym: tsym; constructorcall: tnode);
+          destructor destroy; override;
+          function get_attribute_count: longint;
+       end;
+
        { tstoreddef }
 
        tstoreddef = class(tdef)
@@ -96,6 +111,8 @@ interface
           { contains additional data if this def is a generic constraint
             Note: this class is allocated on demand! }
           genconstraintdata : tgenericconstraintdata;
+          { this is Nil if the def has no RTTI attributes }
+          rtti_attribute_list : trtti_attribute_list;
           constructor create(dt:tdeftyp;doregister:boolean);
           constructor ppuload(dt:tdeftyp;ppufile:tcompilerppufile);
           destructor  destroy;override;
@@ -392,21 +409,6 @@ interface
        end;
        pvmtentry = ^tvmtentry;
 
-       { trtti_attribute_list }
-
-       trtti_attribute = class
-          typesym         : tsym;
-          constructorcall : tnode;
-          symbolname      : string;
-       end;
-
-       trtti_attribute_list = class
-          rtti_attributes    : TFPObjectList;
-          procedure addattribute(atypesym: tsym; constructorcall: tnode);
-          destructor destroy; override;
-          function get_attribute_count: longint;
-       end;
-
        { tobjectdef }
 
        tvmcallstatic = (vmcs_default, vmcs_yes, vmcs_no, vmcs_unreachable);
@@ -453,7 +455,6 @@ interface
           }
           classref_created_in_current_module : boolean;
           objecttype     : tobjecttyp;
-          rtti_attribute_list : trtti_attribute_list;
           constructor create(ot:tobjecttyp;const n:string;c:tobjectdef;doregister:boolean);virtual;
           constructor ppuload(ppufile:tcompilerppufile);
           destructor  destroy;override;
@@ -1884,6 +1885,7 @@ implementation
             generictokenbuf.free;
             generictokenbuf:=nil;
           end;
+        rtti_attribute_list.free;
         genericparas.free;
         if assigned(genericparaderefs) then
           for i:=0 to genericparaderefs.count-1 do
@@ -7025,11 +7027,6 @@ implementation
              freemem(vmcallstaticinfo);
              vmcallstaticinfo:=nil;
            end;
-         if assigned(rtti_attribute_list) then
-           begin
-             rtti_attribute_list.Free;
-             rtti_attribute_list:=nil;
-           end;
          inherited destroy;
       end;
 

+ 3 - 2
compiler/symsym.pas

@@ -46,6 +46,8 @@ interface
           procedure ppuwrite_platform(ppufile: tcompilerppufile);virtual;
           procedure ppuload_platform(ppufile: tcompilerppufile);virtual;
        public
+          { this is Nil if the symbol has no RTTI attributes }
+          rtti_attribute_list : trtti_attribute_list;
           constructor create(st:tsymtyp;const n : string;doregister:boolean);
           constructor ppuload(st:tsymtyp;ppufile:tcompilerppufile);
           destructor destroy;override;
@@ -352,7 +354,6 @@ interface
           dispid        : longint;
           propaccesslist: array[tpropaccesslisttypes] of tpropaccesslist;
           parast : tsymtable;
-          rtti_attribute_list : trtti_attribute_list;
           constructor create(const n : string);virtual;
           destructor  destroy;override;
           constructor ppuload(ppufile:tcompilerppufile);
@@ -622,6 +623,7 @@ implementation
 
     destructor tstoredsym.destroy;
       begin
+        rtti_attribute_list.free;
         inherited destroy;
       end;
 
@@ -1376,7 +1378,6 @@ implementation
          for pap:=low(tpropaccesslisttypes) to high(tpropaccesslisttypes) do
            propaccesslist[pap].free;
          parast.free;
-         rtti_attribute_list.free;
          inherited destroy;
       end;