Ver código fonte

* remove sym from ttype, we can now reference any def in any unit directly

git-svn-id: trunk@5063 -
peter 19 anos atrás
pai
commit
71af18855e
5 arquivos alterados com 17 adições e 68 exclusões
  1. 13 13
      compiler/pdecl.pas
  2. 0 1
      compiler/pdecvar.pas
  3. 1 1
      compiler/pexpr.pas
  4. 1 13
      compiler/ptype.pas
  5. 2 40
      compiler/symtype.pas

+ 13 - 13
compiler/pdecl.pas

@@ -208,7 +208,7 @@ implementation
                    symtablestack.top.insert(sym);
                    { procvar can have proc directives, but not type references }
                    if (tt.def.deftype=procvardef) and
-                      (tt.sym=nil) then
+                      (tt.def.typesym=nil) then
                     begin
                       { support p : procedure;stdcall=nil; }
                       if try_to_consume(_SEMICOLON) then
@@ -329,7 +329,7 @@ implementation
                     if assigned(srsym) and
                        (srsym.typ=typesym) then
                      begin
-                       tabstractpointerdef(pd).pointertype.setsym(srsym);
+                       tabstractpointerdef(pd).pointertype.setdef(ttypesym(srsym).restype.def);
                        { avoid wrong unused warnings web bug 801 PM }
                        inc(ttypesym(srsym).refs);
                        { we need a class type for classrefdef }
@@ -485,19 +485,19 @@ implementation
               { read the type definition }
               read_named_type(tt,orgtypename,nil,generictypelist,false);
               { update the definition of the type }
-              newtype.restype:=tt;
-              if assigned(tt.sym) then
-                istyperenaming:=true
-              else
-                tt.sym:=newtype;
-              if isunique and assigned(tt.def) then
+              if assigned(tt.def) then
                 begin
-                   tt.setdef(tstoreddef(tt.def).getcopy);
-                   include(tt.def.defoptions,df_unique);
-                   newtype.restype:=tt;
+                  if assigned(tt.def.typesym) then
+                    istyperenaming:=true;
+                  if isunique then
+                    begin
+                      tt.setdef(tstoreddef(tt.def).getcopy);
+                      include(tt.def.defoptions,df_unique);
+                    end;
+                  if not assigned(tt.def.typesym) then
+                    tt.def.typesym:=newtype;
                 end;
-              if assigned(tt.def) and not assigned(tt.def.typesym) then
-                tt.def.typesym:=newtype;
+              newtype.restype:=tt;
               { KAZ: handle TGUID declaration in system unit }
               if (cs_compilesystem in aktmoduleswitches) and not assigned(rec_tguid) and
                  (typename='TGUID') and { name: TGUID and size=16 bytes that is 128 bits }

+ 0 - 1
compiler/pdecvar.pas

@@ -1364,7 +1364,6 @@ implementation
               unionsymtable.datasize:=maxsize;
               unionsymtable.fieldalignment:=maxalignment;
               uniontype.def:=uniondef;
-              uniontype.sym:=nil;
               UnionSym:=tfieldvarsym.create('$case',vs_value,uniontype,[]);
               unionsymtable.addalignmentpadding;
 {$ifdef powerpc}

+ 1 - 1
compiler/pexpr.pas

@@ -1413,7 +1413,7 @@ implementation
 
                 typesym :
                   begin
-                    htype.setsym(srsym);
+                    htype:=ttypesym(srsym).restype;
                     if not assigned(htype.def) then
                      begin
                        again:=false;

+ 1 - 13
compiler/ptype.pas

@@ -229,19 +229,7 @@ implementation
             tt:=generrortype;
             exit;
           end;
-         { Use the definitions for current unit, because
-           they can be refered from the parameters and symbols are not
-           loaded at that time. Only write the definition when the
-           symbol is the real owner of the definition (not a redefine) }
-         if (ttypesym(srsym).owner.symtabletype in [staticsymtable,globalsymtable]) and
-            ttypesym(srsym).owner.iscurrentunit and
-            (
-             (ttypesym(srsym).restype.def.typesym=nil) or
-             (srsym=ttypesym(srsym).restype.def.typesym)
-            ) then
-          tt.setdef(ttypesym(srsym).restype.def)
-         else
-          tt.setsym(srsym);
+        tt.setdef(ttypesym(srsym).restype.def);
       end;
 
 

+ 2 - 40
compiler/symtype.pas

@@ -149,11 +149,9 @@ interface
 
       ttype = object
         def : tdef;
-        sym : tsym;
         deref : tderef;
         procedure reset;
         procedure setdef(p:tdef);
-        procedure setsym(p:tsym);
         procedure resolve;
         procedure buildderef;
       end;
@@ -543,23 +541,12 @@ implementation
     procedure ttype.reset;
       begin
         def:=nil;
-        sym:=nil;
       end;
 
 
     procedure ttype.setdef(p:tdef);
       begin
         def:=p;
-        sym:=nil;
-      end;
-
-
-    procedure ttype.setsym(p:tsym);
-      begin
-        sym:=p;
-        def:=p.gettypedef;
-        if not assigned(def) then
-         internalerror(1234005);
       end;
 
 
@@ -569,18 +556,7 @@ implementation
       begin
         p:=deref.resolve;
         if assigned(p) then
-          begin
-            if p is tsym then
-              begin
-                setsym(tsym(p));
-                if not assigned(def) then
-                 internalerror(200212272);
-              end
-            else
-              begin
-                setdef(tdef(p));
-              end;
-          end
+          setdef(tdef(p))
         else
           reset;
       end;
@@ -588,20 +564,7 @@ implementation
 
     procedure ttype.buildderef;
       begin
-        { Write symbol references when the symbol is a redefine,
-          but don't write symbol references for the current unit
-          and for the system unit }
-        if assigned(sym) and
-           (
-            (sym<>def.typesym) or
-            (
-             not((sym.owner.symtabletype in [globalsymtable,staticsymtable]) and
-                 sym.owner.iscurrentunit)
-            )
-           ) then
-          deref.build(sym)
-        else
-          deref.build(def);
+        deref.build(def);
       end;
 
 
@@ -1013,7 +976,6 @@ implementation
       begin
         getderef(t.deref);
         t.def:=nil;
-        t.sym:=nil;
       end;