Browse Source

* detect whether or not a def/sym is registered based on its defid, so we
don't need a separate field for this
o changed the order in which symid and realname are stored to/loaded from
the ppufile (because tsym.create now initialised tsym.symid, and it's
called from ppuload) -> increased ppu version

git-svn-id: trunk@32031 -

Jonas Maebe 9 năm trước cách đây
mục cha
commit
2d2b8c635d
5 tập tin đã thay đổi với 35 bổ sung13 xóa
  1. 1 1
      compiler/ppu.pas
  2. 10 0
      compiler/symconst.pas
  3. 10 5
      compiler/symdef.pas
  4. 12 7
      compiler/symsym.pas
  5. 2 0
      compiler/symtype.pas

+ 1 - 1
compiler/ppu.pas

@@ -43,7 +43,7 @@ type
 {$endif Test_Double_checksum}
 
 const
-  CurrentPPUVersion = 178;
+  CurrentPPUVersion = 179;
 
 { buffer sizes }
   maxentrysize = 1024;

+ 10 - 0
compiler/symconst.pas

@@ -145,6 +145,16 @@ const
   { prefix for names of class helper procsyms added to regular symtables }
   class_helper_prefix = 'CH$';
 
+  { tsym.symid value in case the sym has not yet been registered }
+  symid_not_registered = -1;
+  { tsym.symid value in case the sym has been registered, but not put in a
+    symtable }
+  symid_registered_nost = -2;
+  { tdef.defid value in case the def has not yet been registered }
+  defid_not_registered = -1;
+  { tdef.defid value in case the sym has been registered, but not put in a
+    symtable }
+  defid_registered_nost = -2;
 
 type
   { keep this in sync with TIntfFlag in rtl/objpas/typinfo.pp }

+ 10 - 5
compiler/symdef.pas

@@ -69,7 +69,7 @@ interface
        protected
           typesymderef  : tderef;
           { whether this def is already registered in the unit's def list }
-          registered : boolean;
+          function registered : boolean;
           procedure ppuwrite_platform(ppufile:tcompilerppufile);virtual;
           procedure ppuload_platform(ppufile:tcompilerppufile);virtual;
        public
@@ -1647,6 +1647,12 @@ implementation
       end;
 
 
+    function tstoreddef.registered: boolean;
+      begin
+        result:=defid<>defid_not_registered;
+      end;
+
+
     procedure tstoreddef.ppuwrite_platform(ppufile: tcompilerppufile);
       begin
         { by default: do nothing }
@@ -1710,8 +1716,6 @@ implementation
       begin
          inherited create(dt);
          DefId:=ppufile.getlongint;
-         { defs loaded from ppu are always owned }
-         registered:=true;
          current_module.deflist[DefId]:=self;
 {$ifdef EXTDEBUG}
          fillchar(fileinfo,sizeof(fileinfo),0);
@@ -2141,7 +2145,9 @@ implementation
          begin
            current_module.deflist.Add(self);
            DefId:=current_module.deflist.Count-1;
-         end;
+         end
+       else
+         DefId:=defid_registered_nost;
        { Register in symtable stack }
        if assigned(symtablestack) then
          begin
@@ -2155,7 +2161,6 @@ implementation
              internalerror(2015022301);
            insertstack^.symtable.insertdef(self);
          end;
-       registered:=true;
      end;
 
 

+ 12 - 7
compiler/symsym.pas

@@ -43,7 +43,7 @@ interface
        { this class is the base for all symbol objects }
        tstoredsym = class(tsym)
        private
-          registered : boolean;
+          function registered : boolean;
           procedure writeentry(ppufile: tcompilerppufile; ibnr: byte);
        protected
           procedure ppuwrite_platform(ppufile: tcompilerppufile);virtual;
@@ -555,10 +555,8 @@ implementation
 
     constructor tstoredsym.ppuload(st:tsymtyp;ppufile:tcompilerppufile);
       begin
-         SymId:=ppufile.getlongint;
          inherited Create(st,ppufile.getstring);
-         { Register symbol }
-         registered:=true;
+         SymId:=ppufile.getlongint;
          current_module.symlist[SymId]:=self;
          ppufile.getposinfo(fileinfo);
          visibility:=tvisibility(ppufile.getbyte);
@@ -574,8 +572,8 @@ implementation
       var
         oldintfcrc : boolean;
       begin
-         ppufile.putlongint(SymId);
          ppufile.putstring(realname);
+         ppufile.putlongint(SymId);
          ppufile.putposinfo(fileinfo);
          ppufile.putbyte(byte(visibility));
          { symoptions can differ between interface and implementation, except
@@ -594,6 +592,12 @@ implementation
       end;
 
 
+    function tstoredsym.registered: boolean;
+      begin
+        result:=symid<>symid_not_registered;
+      end;
+
+
     procedure tstoredsym.writeentry(ppufile: tcompilerppufile; ibnr: byte);
       begin
         ppuwrite_platform(ppufile);
@@ -627,8 +631,9 @@ implementation
           begin
             current_module.symlist.Add(self);
             SymId:=current_module.symlist.Count-1;
-          end;
-        registered:=true;
+          end
+        else
+          SymId:=symid_registered_nost;
       end;
 
 {****************************************************************************

+ 2 - 0
compiler/symtype.pas

@@ -264,6 +264,7 @@ implementation
          defoptions:=[];
          dbg_state:=dbg_state_unused;
          stab_number:=0;
+         defid:=defid_not_registered;
       end;
 
 
@@ -402,6 +403,7 @@ implementation
          isdbgwritten := false;
          visibility:=vis_public;
          deprecatedmsg:=nil;
+         symid:=symid_not_registered;
       end;
 
     destructor  Tsym.destroy;