瀏覽代碼

+ add functions for syms and defs and write sub entries of the sym/def to PPU and loads them again

git-svn-id: trunk@42399 -
svenbarth 6 年之前
父節點
當前提交
dfb9fffcf9
共有 3 個文件被更改,包括 46 次插入4 次删除
  1. 16 0
      compiler/symdef.pas
  2. 16 0
      compiler/symsym.pas
  3. 14 4
      compiler/symtable.pas

+ 16 - 0
compiler/symdef.pas

@@ -123,6 +123,10 @@ interface
           destructor  destroy;override;
           function getcopy : tstoreddef;virtual;
           procedure ppuwrite(ppufile:tcompilerppufile);virtual;
+          { this is called directly after ppuload }
+          procedure ppuload_subentries(ppufile:tcompilerppufile);virtual;
+          { this is called directly after ppuwrite }
+          procedure ppuwrite_subentries(ppufile:tcompilerppufile);virtual;
           procedure buildderef;override;
           procedure buildderefimpl;override;
           procedure deref;override;
@@ -2136,6 +2140,18 @@ implementation
       end;
 
 
+    procedure tstoreddef.ppuload_subentries(ppufile: tcompilerppufile);
+      begin
+        { by default: do nothing }
+      end;
+
+
+    procedure tstoreddef.ppuwrite_subentries(ppufile: tcompilerppufile);
+      begin
+        { by default: do nothing }
+      end;
+
+
     procedure tstoreddef.buildderef;
       var
         i : longint;

+ 16 - 0
compiler/symsym.pas

@@ -52,6 +52,10 @@ interface
           constructor ppuload(st:tsymtyp;ppufile:tcompilerppufile);
           destructor destroy;override;
           procedure ppuwrite(ppufile:tcompilerppufile);virtual;
+          { this is called directly after ppuload }
+          procedure ppuload_subentries(ppufile:tcompilerppufile);virtual;
+          { this is called directly after ppuwrite }
+          procedure ppuwrite_subentries(ppufile:tcompilerppufile);virtual;
           procedure buildderef; override;
           procedure register_sym; override;
        end;
@@ -595,6 +599,18 @@ implementation
       end;
 
 
+    procedure tstoredsym.ppuload_subentries(ppufile: tcompilerppufile);
+      begin
+        { by default: do nothing }
+      end;
+
+
+    procedure tstoredsym.ppuwrite_subentries(ppufile: tcompilerppufile);
+      begin
+        { by default: do nothing }
+      end;
+
+
     procedure tstoredsym.buildderef;
       begin
         inherited;

+ 14 - 4
compiler/symtable.pas

@@ -561,13 +561,13 @@ implementation
         def : tdef;
         b   : byte;
       begin
-         def:=nil;
          { load start of definition section, which holds the amount of defs }
          if ppufile.readentry<>ibstartdefs then
            Message(unit_f_ppu_read_error);
          { read definitions }
          repeat
            b:=ppufile.readentry;
+           def:=nil;
            case b of
              ibpointerdef : def:=cpointerdef.ppuload(ppufile);
              ibarraydef : def:=carraydef.ppuload(ppufile);
@@ -594,6 +594,8 @@ implementation
            else
              Message1(unit_f_ppu_invalid_entry,tostr(b));
            end;
+           if assigned(def) then
+             tstoreddef(def).ppuload_subentries(ppufile);
            InsertDef(def);
          until false;
       end;
@@ -604,12 +606,12 @@ implementation
         b   : byte;
         sym : tsym;
       begin
-         sym:=nil;
          { load start of definition section, which holds the amount of defs }
          if ppufile.readentry<>ibstartsyms then
           Message(unit_f_ppu_read_error);
          { now read the symbols }
          repeat
+           sym:=nil;
            b:=ppufile.readentry;
            case b of
                 ibtypesym : sym:=ctypesym.ppuload(ppufile);
@@ -632,6 +634,8 @@ implementation
            else
              Message1(unit_f_ppu_invalid_entry,tostr(b));
            end;
+           if assigned(sym) then
+             tstoredsym(sym).ppuload_subentries(ppufile);
            Insert(sym,false);
          until false;
       end;
@@ -656,7 +660,10 @@ implementation
           begin
             def:=tstoreddef(DefList[i]);
             if def.is_registered then
-              def.ppuwrite(ppufile);
+              begin
+                def.ppuwrite(ppufile);
+                def.ppuwrite_subentries(ppufile);
+              end;
           end;
         { write end of definitions }
         ppufile.writeentry(ibenddefs);
@@ -682,7 +689,10 @@ implementation
           begin
             sym:=tstoredsym(SymList[i]);
             if sym.is_registered then
-              sym.ppuwrite(ppufile);
+              begin
+                sym.ppuwrite(ppufile);
+                sym.ppuwrite_subentries(ppufile);
+              end;
           end;
         { end of symbols }
         ppufile.writeentry(ibendsyms);