Browse Source

* g_copyopenarrayvalue gets length reference
* don't copy open arrays for cdecl

peter 22 years ago
parent
commit
2df40538b9
2 changed files with 27 additions and 7 deletions
  1. 6 2
      compiler/cgobj.pas
  2. 21 5
      compiler/ncgutil.pas

+ 6 - 2
compiler/cgobj.pas

@@ -361,7 +361,7 @@ unit cgobj;
           {# Generates overflow checking code for a node }
           procedure g_overflowcheck(list: taasmoutput; const l:tlocation; def:tdef); virtual; abstract;
 
-          procedure g_copyvaluepara_openarray(list : taasmoutput;const ref:treference;elesize:integer);virtual;abstract;
+          procedure g_copyvaluepara_openarray(list : taasmoutput;const arrayref,lenref:treference;elesize:integer);virtual;abstract;
           {# Emits instructions which should be emitted when entering
              a routine declared as @var(interrupt). The default
              behavior does nothing, should be overriden as required.
@@ -1700,7 +1700,11 @@ finalization
 end.
 {
   $Log$
-  Revision 1.107  2003-06-03 21:11:09  peter
+  Revision 1.108  2003-06-06 14:43:02  peter
+    * g_copyopenarrayvalue gets length reference
+    * don't copy open arrays for cdecl
+
+  Revision 1.107  2003/06/03 21:11:09  peter
     * cg.a_load_* get a from and to size specifier
     * makeregsize only accepts newregister
     * i386 uses generic tcgnotnode,tcgunaryminus

+ 21 - 5
compiler/ncgutil.pas

@@ -996,6 +996,7 @@ implementation
       var
         href1,href2 : treference;
         list : taasmoutput;
+        hsym : tvarsym;
         loadref: boolean;
       begin
         list:=taasmoutput(arg);
@@ -1010,10 +1011,21 @@ implementation
              reference_reset_base(href1,tvarsym(p).reg,0);
            if is_open_array(tvarsym(p).vartype.def) or
               is_array_of_const(tvarsym(p).vartype.def) then
-             if loadref then
-               cg.g_copyvaluepara_openarray(list,href1,tarraydef(tvarsym(p).vartype.def).elesize)
-             else
-               internalerror(2003053101)
+            begin
+              { cdecl functions don't have a high pointer so it is not possible to generate
+                a local copy }
+              if not(current_procinfo.procdef.proccalloption in [pocall_cdecl,pocall_cppdecl]) then
+                begin
+                  hsym:=tvarsym(tsym(p).owner.search('high'+p.name));
+                  if not assigned(hsym) then
+                    internalerror(200306061);
+                  reference_reset_base(href2,current_procinfo.framepointer,tvarsym(hsym).adjusted_address);
+                  if loadref then
+                   cg.g_copyvaluepara_openarray(list,href1,href2,tarraydef(tvarsym(p).vartype.def).elesize)
+                  else
+                   internalerror(2003053101)
+                end;
+            end
            else
             begin
               reference_reset_base(href2,current_procinfo.framepointer,tvarsym(p).localvarsym.adjusted_address);
@@ -1942,7 +1954,11 @@ implementation
 end.
 {
   $Log$
-  Revision 1.121  2003-06-03 21:11:09  peter
+  Revision 1.122  2003-06-06 14:43:02  peter
+    * g_copyopenarrayvalue gets length reference
+    * don't copy open arrays for cdecl
+
+  Revision 1.121  2003/06/03 21:11:09  peter
     * cg.a_load_* get a from and to size specifier
     * makeregsize only accepts newregister
     * i386 uses generic tcgnotnode,tcgunaryminus