Jelajahi Sumber

* tvarsym.get_push_size replaced by paramanager.push_size

peter 23 tahun lalu
induk
melakukan
3d696d9c7c
5 mengubah file dengan 61 tambahan dan 47 penghapusan
  1. 6 3
      compiler/browcol.pas
  2. 41 5
      compiler/paramgr.pas
  3. 5 14
      compiler/symdef.pas
  4. 4 23
      compiler/symsym.pas
  5. 5 2
      compiler/symtable.pas

+ 6 - 3
compiler/browcol.pas

@@ -268,7 +268,7 @@ uses
   CUtils,
   globtype,globals,comphook,
   finput,fmodule,
-  cpuinfo,aasmbase,aasmtai,
+  cpuinfo,aasmbase,aasmtai,paramgr,
   symsym,symdef,symtype,symbase;
 
 const
@@ -1454,7 +1454,7 @@ end;
                else
                  MemInfo.Size:=getsize;
                { this is not completely correct... }
-               MemInfo.PushSize:=getpushsize(pocall_none);
+               MemInfo.PushSize:=paramanager.push_size(varspez,vartype.def,pocall_none);
                Symbol^.SetMemInfo(MemInfo);
              end;
           constsym :
@@ -2118,7 +2118,10 @@ begin
 end.
 {
   $Log$
-  Revision 1.30  2002-11-24 18:17:29  carl
+  Revision 1.31  2002-11-27 20:04:10  peter
+    * tvarsym.get_push_size replaced by paramanager.push_size
+
+  Revision 1.30  2002/11/24 18:17:29  carl
     * fix compilation problems after my changes to tcontsym
 
   Revision 1.29  2002/11/20 22:48:42  pierre

+ 41 - 5
compiler/paramgr.pas

@@ -31,7 +31,7 @@ unit paramgr;
     uses
        cpubase,
        globtype,
-       symtype,symdef;
+       symconst,symtype,symdef;
 
     type
        {# This class defines some methods to take care of routine
@@ -58,6 +58,8 @@ unit paramgr;
             the address is pushed
           }
           function push_addr_param(def : tdef;calloption : tproccalloption) : boolean;virtual;
+          { return the size of a push }
+          function push_size(varspez:tvarspez;def : tdef;calloption : tproccalloption) : longint;
           { Returns true if a parameter needs to be copied on the stack, this
             is required for cdecl procedures
           }
@@ -110,7 +112,7 @@ unit paramgr;
 
     uses
        cpuinfo,globals,systems,
-       symconst,symbase,symsym,
+       symbase,symsym,
        rgobj,
        defutil,cgbase,cginfo,verbose;
 
@@ -145,7 +147,8 @@ unit paramgr;
       begin
          push_high_param:=is_open_array(def) or
                           is_open_string(def) or
-                          is_array_of_const(def);
+                          (is_array_of_const(def) and
+                           not(calloption in [pocall_cdecl,pocall_cppdecl]));
       end;
 
 
@@ -173,7 +176,9 @@ unit paramgr;
                                   )
                                 ) or
                                 is_open_array(def) or
-                                is_array_of_const(def) or
+                                { array of const for cdecl are only pushed values }
+                                (is_array_of_const(def) and
+                                 not(calloption in [pocall_cdecl,pocall_cppdecl])) or
                                 is_array_constructor(def);
              objectdef :
                push_addr_param:=is_object(def);
@@ -224,6 +229,34 @@ unit paramgr;
       end;
 
 
+    { return the size of a push }
+    function tparamanager.push_size(varspez:tvarspez;def : tdef;calloption : tproccalloption) : longint;
+      begin
+        push_size:=-1;
+        case varspez of
+          vs_out,
+          vs_var :
+            push_size:=pointer_size;
+          vs_value,
+          vs_const :
+            begin
+                if push_addr_param(def,calloption) then
+                  push_size:=pointer_size
+                else
+                  begin
+                    { special array are normally pushed by addr, only for
+                      cdecl array of const it comes here and the pushsize
+                      is unknown }
+                    if is_array_of_const(def) then
+                      push_size:=0
+                    else
+                      push_size:=def.size;
+                  end;
+            end;
+        end;
+      end;
+
+
     function tparamanager.getfuncretparaloc(p : tabstractprocdef) : tparalocation;
       begin
          result.loc:=LOC_REFERENCE;
@@ -379,7 +412,10 @@ end.
 
 {
    $Log$
-   Revision 1.25  2002-11-27 02:33:19  peter
+   Revision 1.26  2002-11-27 20:04:09  peter
+     * tvarsym.get_push_size replaced by paramanager.push_size
+
+   Revision 1.25  2002/11/27 02:33:19  peter
      * copy_value_on_stack method added for cdecl record passing
 
    Revision 1.24  2002/11/25 17:43:21  peter

+ 5 - 14
compiler/symdef.pas

@@ -3158,19 +3158,7 @@ implementation
          pdc:=TParaItem(Para.first);
          while assigned(pdc) do
           begin
-            case pdc.paratyp of
-              vs_out,
-              vs_var :
-                inc(l,POINTER_SIZE);
-              vs_value,
-              vs_const :
-                begin
-                  if paramanager.push_addr_param(pdc.paratype.def,proccalloption) then
-                    inc(l,POINTER_SIZE)
-                  else
-                    inc(l,pdc.paratype.def.size);
-                end;
-            end;
+            inc(l,paramanager.push_size(pdc.paratyp,pdc.paratype.def,proccalloption));
             l:=align(l,alignsize);
             if assigned(pdc.paratype.def) and
                is_special_array(pdc.paratype.def) then
@@ -5529,7 +5517,10 @@ implementation
 end.
 {
   $Log$
-  Revision 1.112  2002-11-25 21:05:53  carl
+  Revision 1.113  2002-11-27 20:04:09  peter
+    * tvarsym.get_push_size replaced by paramanager.push_size
+
+  Revision 1.112  2002/11/25 21:05:53  carl
    * several mistakes fixed in message files
 
   Revision 1.111  2002/11/25 18:43:33  carl

+ 4 - 23
compiler/symsym.pas

@@ -192,7 +192,6 @@ interface
           procedure set_mangledname(const s:string);
           function  getsize : longint;
           function  getvaluesize : longint;
-          function  getpushsize(calloption:tproccalloption): longint;
 {$ifdef var_notification}
           function register_notification(flags:Tnotification_flags;
                                          callback:Tnotification_callback):cardinal;
@@ -1653,27 +1652,6 @@ implementation
       end;
 
 
-    function tvarsym.getpushsize(calloption:tproccalloption) : longint;
-      begin
-         getpushsize:=-1;
-         if assigned(vartype.def) then
-           begin
-              case varspez of
-                vs_out,
-                vs_var :
-                  getpushsize:=pointer_size;
-                vs_value,
-                vs_const :
-                  begin
-                      if paramanager.push_addr_param(vartype.def,calloption) then
-                        getpushsize:=pointer_size
-                      else
-                        getpushsize:=vartype.def.size;
-                  end;
-              end;
-           end;
-      end;
-
 {$ifdef var_notification}
     function Tvarsym.register_notification(flags:Tnotification_flags;callback:
                                            Tnotification_callback):cardinal;
@@ -2479,7 +2457,10 @@ implementation
 end.
 {
   $Log$
-  Revision 1.78  2002-11-27 02:34:20  peter
+  Revision 1.79  2002-11-27 20:04:10  peter
+    * tvarsym.get_push_size replaced by paramanager.push_size
+
+  Revision 1.78  2002/11/27 02:34:20  peter
     * only find real equal procvars
 
   Revision 1.77  2002/11/25 18:43:34  carl

+ 5 - 2
compiler/symtable.pas

@@ -1436,7 +1436,7 @@ implementation
           internalerror(200208256);
         { here we need the size of a push instead of the
           size of the data }
-        l:=tvarsym(sym).getpushsize(tprocdef(defowner).proccalloption);
+        l:=paramanager.push_size(tvarsym(sym).varspez,tvarsym(sym).vartype.def,tprocdef(defowner).proccalloption);
         varalign:=size_2_align(l);
         tvarsym(sym).varstate:=vs_assigned;
         { we need the new datasize already aligned so we can't
@@ -2337,7 +2337,10 @@ implementation
 end.
 {
   $Log$
-  Revision 1.80  2002-11-22 22:45:49  carl
+  Revision 1.81  2002-11-27 20:04:09  peter
+    * tvarsym.get_push_size replaced by paramanager.push_size
+
+  Revision 1.80  2002/11/22 22:45:49  carl
   + small optimization for speed
 
   Revision 1.79  2002/11/19 16:26:33  pierre