فهرست منبع

* integrate the functionality to create an address-only procvardef from a
procdef into tprocdef.getcopyas()

git-svn-id: branches/hlcgllvm@28474 -

Jonas Maebe 11 سال پیش
والد
کامیت
63a3ff3c7f
2فایلهای تغییر یافته به همراه13 افزوده شده و 4 حذف شده
  1. 6 3
      compiler/ncnv.pas
  2. 7 1
      compiler/symdef.pas

+ 6 - 3
compiler/ncnv.pas

@@ -1992,6 +1992,7 @@ implementation
     function ttypeconvnode.typecheck_proc_to_procvar : tnode;
       var
         pd : tabstractprocdef;
+        copytype : tproccopytyp;
       begin
         result:=nil;
         pd:=tabstractprocdef(left.resultdef);
@@ -2005,15 +2006,17 @@ implementation
           resultdef:=totypedef
         else
          begin
-           resultdef:=pd.getcopyas(procvardef,pc_normal);
            { only need the address of the method? this is needed
              for @tobject.create. In this case there will be a loadn without
              a methodpointer. }
            if (left.nodetype=loadn) and
               not assigned(tloadnode(left).left) and
               (not(m_nested_procvars in current_settings.modeswitches) or
-               not is_nested_pd(tprocvardef(resultdef))) then
-             include(tprocvardef(resultdef).procoptions,po_addressonly);
+               not is_nested_pd(tabstractprocdef(tloadnode(left).resultdef))) then
+             copytype:=pc_address_only
+           else
+             copytype:=pc_normal;
+           resultdef:=pd.getcopyas(procvardef,copytype);
          end;
       end;
 

+ 7 - 1
compiler/symdef.pas

@@ -546,7 +546,10 @@ interface
        tproccopytyp = (pc_normal,
                        { always creates a top-level function, removes all
                          special parameters (self, vmt, parentfp, ...) }
-                       pc_bareproc
+                       pc_bareproc,
+                       { creates a procvardef describing only the code pointer
+                         of a method/netsted function/... }
+                       pc_address_only
                        );
 
        tabstractprocdef = class(tstoreddef)
@@ -4554,6 +4557,9 @@ implementation
           tabstractprocdef(result).procoptions:=tabstractprocdef(result).procoptions*[po_explicitparaloc,po_hascallingconvention,po_varargs,po_iocheck,po_has_importname,po_has_importdll];
         if newtyp=procvardef then
           tabstractprocdef(result).procoptions:=tabstractprocdef(result).procoptions-[po_has_importname,po_has_importdll];
+        if copytyp=pc_address_only then
+          include(tabstractprocdef(result).procoptions,po_addressonly);
+
         tabstractprocdef(result).callerargareasize:=callerargareasize;
         tabstractprocdef(result).calleeargareasize:=calleeargareasize;
         tabstractprocdef(result).maxparacount:=maxparacount;