Browse Source

* moved a bunch of tprocdef fields that are only required when compiling the
procdef to a dynamically allocated record that is not created when loading
the procdef from ppu

git-svn-id: trunk@26332 -

Jonas Maebe 11 năm trước cách đây
mục cha
commit
32b149c622
1 tập tin đã thay đổi với 204 bổ sung38 xóa
  1. 204 38
      compiler/symdef.pas

+ 204 - 38
compiler/symdef.pas

@@ -602,15 +602,53 @@ interface
        end;
 {$endif oldregvars}
 
+       timplprocdefinfo = record
+          resultname : pshortstring;
+          parentfpstruct: tsym;
+          parentfpstructptrtype: tdef;
+          parentfpinitblock: tnode;
+          procstarttai,
+          procendtai   : tai;
+          skpara: pointer;
+          forwarddef,
+          interfacedef : boolean;
+          hasforward  : boolean;
+       end;
+       pimplprocdefinfo = ^timplprocdefinfo;
+
        { tprocdef }
 
        tprocdef = class(tabstractprocdef)
        private
 {$ifdef symansistr}
-          _mangledname : ansistring;
+         _mangledname : ansistring;
 {$else symansistr}
-          _mangledname : pshortstring;
+         _mangledname : pshortstring;
 {$endif}
+         { information that is only required until the implementation of the
+           procdef has been handled }
+         implprocdefinfo : pimplprocdefinfo;
+
+         function GetResultName: PShortString;
+         procedure SetResultName(AValue: PShortString);
+         function GetParentFPStruct: tsym;
+         procedure SetParentFPStruct(AValue: tsym);
+         function GetParentFPStructPtrType: tdef;
+         procedure SetParentFPStructPtrType(AValue: tdef);
+         function GetParentFPInitBlock: tnode;
+         procedure SetParentFPInitBlock(AValue: tnode);
+         function Getprocstarttai: tai;
+         procedure Setprocstarttai(AValue: tai);
+         function Getprocendtai: tai;
+         procedure Setprocendtai(AValue: tai);
+         function Getskpara: pointer;
+         procedure Setskpara(AValue: pointer);
+         function Getforwarddef: boolean;
+         procedure Setforwarddef(AValue: boolean);
+         function Getinterfacedef: boolean;
+         procedure Setinterfacedef(AValue: boolean);
+         function Gethasforward: boolean;
+         procedure Sethasforward(AValue: boolean);
        public
           messageinf : tmessageinf;
           dispid : longint;
@@ -639,8 +677,6 @@ interface
           libsym : tsym;
           libsymderef : tderef;
 {$endif powerpc or m68k}
-          { name of the result variable to insert in the localsymtable }
-          resultname : pshortstring;
           { import info }
           import_dll,
           import_name : pshortstring;
@@ -652,27 +688,9 @@ interface
             easily write out all methods grouped per class }
           exprasmlist      : TAsmList;
 {$endif jvm}
-          { temporary reference to structure containing copies of all local
-            variables and parameters accessed by nested routines; reference to
-            this structure is passed as "parent frame pointer" on targets that
-            lack this concept (at least JVM and LLVM); no need to save to/
-            restore from ppu, since nested routines are always in the same
-            unit (no need to save to ppu) }
-          parentfpstruct: tsym;
-          { pointer to parentfpstruct's type (not yet valid during parsing, so
-            cannot be used for $parentfp parameter) (no need to save to ppu) }
-          parentfpstructptrtype: tdef;
-          { code to copy the parameters accessed from nested routines into the
-            parentfpstruct (no need to save to ppu) }
-          parentfpinitblock: tnode;
 {$ifdef oldregvars}
           regvarinfo: pregvarinfo;
 {$endif oldregvars}
-          { First/last assembler symbol/instruction in aasmoutput list.
-            Note: initialised after compiling the code for the procdef, but
-              not saved to/restored from ppu. Used when inserting debug info }
-          procstarttai,
-          procendtai   : tai;
           import_nr    : word;
           extnumber    : word;
 {$if defined(i386) or defined(i8086)}
@@ -692,17 +710,8 @@ interface
           { set to a value different from tsk_none in case this procdef is for
             a routine that has to be internally generated by the compiler }
           synthetickind : tsynthetickind;
-          { optional parameter for the synthetic routine generation logic }
-          skpara: pointer;
           { true, if the procedure contains no code }
-          isempty,
-          { true, if the procedure is only declared
-            (forward procedure) }
-          forwarddef,
-          { true if the procedure is declared in the interface }
-          interfacedef : boolean;
-          { true if the procedure has a forward declaration }
-          hasforward  : boolean;
+          isempty: boolean;
           constructor create(level:byte);
           constructor ppuload(ppufile:tcompilerppufile);
           destructor  destroy;override;
@@ -735,6 +744,37 @@ interface
           function  is_methodpointer:boolean;override;
           function  is_addressonly:boolean;override;
           procedure make_external;
+
+          { aliases to fields only required when a function is implemented in
+            the current unit }
+          property resultname: PShortString read GetResultName write SetResultName;
+          { temporary reference to structure containing copies of all local
+            variables and parameters accessed by nested routines; reference to
+            this structure is passed as "parent frame pointer" on targets that
+            lack this concept (at least JVM and LLVM); no need to save to/
+            restore from ppu, since nested routines are always in the same
+            unit }
+          property parentfpstruct: tsym read GetParentFPStruct write SetParentFPStruct;
+          { pointer to parentfpstruct's type (not yet valid during parsing, so
+            cannot be used for $parentfp parameter) (no need to save to ppu) }
+          property parentfpstructptrtype: tdef read GetParentFPStructPtrType write SetParentFPStructPtrType;
+          { code to copy the parameters accessed from nested routines into the
+            parentfpstruct (no need to save to ppu) }
+          property parentfpinitblock: tnode read GetParentFPInitBlock write SetParentFPInitBlock;
+          { First/last assembler symbol/instruction in aasmoutput list.
+            Note: initialised after compiling the code for the procdef, but
+              not saved to/restored from ppu. Used when inserting debug info }
+          property procstarttai: tai read Getprocstarttai write Setprocstarttai;
+          property procendtai: tai read Getprocendtai write Setprocendtai;
+          { optional parameter for the synthetic routine generation logic }
+          property skpara: pointer read Getskpara write Setskpara;
+          { true, if the procedure is only declared
+            (forward procedure) }
+          property forwarddef: boolean read Getforwarddef write Setforwarddef;
+          { true if the procedure is declared in the interface }
+          property interfacedef: boolean read Getinterfacedef write Setinterfacedef;
+          { true if the procedure has a forward declaration }
+          property hasforward: boolean read Gethasforward write Sethasforward;
        end;
 
        { single linked list of overloaded procs }
@@ -4456,9 +4496,130 @@ implementation
                                   TPROCDEF
 ***************************************************************************}
 
+    function tprocdef.GetResultName: PShortString;
+      begin
+        result:=implprocdefinfo^.resultname;
+      end;
+
+
+    procedure tprocdef.SetResultName(AValue: PShortString);
+      begin
+        implprocdefinfo^.resultname:=AValue;
+      end;
+
+
+    function tprocdef.GetParentFPInitBlock: tnode;
+      begin
+        result:=implprocdefinfo^.parentfpinitblock;
+      end;
+
+
+    function tprocdef.GetParentFPStruct: tsym;
+      begin
+        result:=implprocdefinfo^.parentfpstruct;
+      end;
+
+
+    function tprocdef.GetParentFPStructPtrType: tdef;
+      begin
+        result:=implprocdefinfo^.parentfpstructptrtype;
+      end;
+
+
+    procedure tprocdef.SetParentFPInitBlock(AValue: tnode);
+      begin
+        implprocdefinfo^.parentfpinitblock:=AValue;
+      end;
+
+
+    function tprocdef.Getprocendtai: tai;
+      begin
+        result:=implprocdefinfo^.procendtai;
+      end;
+
+
+    function tprocdef.Getprocstarttai: tai;
+      begin
+        result:=implprocdefinfo^.procstarttai;
+      end;
+
+
+    procedure tprocdef.Setprocendtai(AValue: tai);
+      begin
+        implprocdefinfo^.procendtai:=AValue;
+      end;
+
+
+    function tprocdef.Getskpara: pointer;
+      begin
+        result:=implprocdefinfo^.skpara;
+      end;
+
+
+    procedure tprocdef.Setskpara(AValue: pointer);
+      begin
+        implprocdefinfo:=AValue;
+      end;
+
+
+    function tprocdef.Getforwarddef: boolean;
+      begin
+        result:=implprocdefinfo^.forwarddef;
+      end;
+
+
+    function tprocdef.Gethasforward: boolean;
+      begin
+        result:=implprocdefinfo^.hasforward;
+      end;
+
+
+    function tprocdef.Getinterfacedef: boolean;
+      begin
+        result:=implprocdefinfo^.interfacedef;
+      end;
+
+
+    procedure tprocdef.Setforwarddef(AValue: boolean);
+      begin
+        implprocdefinfo^.forwarddef:=AValue;
+      end;
+
+
+    procedure tprocdef.Sethasforward(AValue: boolean);
+      begin
+        implprocdefinfo^.hasforward:=AValue;
+      end;
+
+
+    procedure tprocdef.Setinterfacedef(AValue: boolean);
+      begin
+        implprocdefinfo^.interfacedef:=AValue;
+      end;
+
+
+    procedure tprocdef.Setprocstarttai(AValue: tai);
+      begin
+        implprocdefinfo^.procstarttai:=AValue;
+      end;
+
+
+    procedure tprocdef.SetParentFPStruct(AValue: tsym);
+      begin
+        implprocdefinfo^.parentfpstruct:=AValue;
+      end;
+
+
+    procedure tprocdef.SetParentFPStructPtrType(AValue: tdef);
+      begin
+        implprocdefinfo^.parentfpstructptrtype:=AValue;
+      end;
+
+
     constructor tprocdef.create(level:byte);
       begin
          inherited create(procdef,level);
+         implprocdefinfo:=allocmem(sizeof(implprocdefinfo^));
          localst:=tlocalsymtable.create(self,parast.symtablelevel);
 {$ifdef symansistr}
          _mangledname:='';
@@ -4573,9 +4734,6 @@ implementation
             (tf_need_export in target_info.flags) and
             (po_exports in procoptions) then
            deffile.AddExport(mangledname);
-         forwarddef:=false;
-         interfacedef:=false;
-         hasforward:=false;
          { Disable po_has_inlining until the derefimpl is done }
          exclude(procoptions,po_has_inlininginfo);
 {$ifdef i386}
@@ -4615,7 +4773,12 @@ implementation
 {$ifdef jvm}
          exprasmlist.free;
 {$endif}
-         stringdispose(resultname);
+         if assigned(implprocdefinfo) then
+           begin
+            stringdispose(implprocdefinfo^.resultname);
+            freemem(implprocdefinfo);
+            implprocdefinfo:=nil;
+           end;
          stringdispose(import_dll);
          stringdispose(import_name);
          stringdispose(deprecatedmsg);
@@ -4898,8 +5061,11 @@ implementation
 {$if defined(powerpc) or defined(m68k)}
         tprocdef(result).libsym:=libsym;
 {$endif powerpc or m68k}
-        if assigned(resultname) then
-          tprocdef(result).resultname:=stringdup(resultname^);
+        if assigned(implprocdefinfo) then
+          begin
+            if assigned(resultname) then
+              tprocdef(result).resultname:=stringdup(resultname^);
+          end;
         if assigned(import_dll) then
           tprocdef(result).import_dll:=stringdup(import_dll^);
         if assigned(import_name) then