Browse Source

* Added the thlcgobj.a_load_undefined_cgpara() method to pass an undefined value as a parameter to a routine. The generic version passes the 0/nil value if the parameter's location is not a register.
* Use a_load_undefined_cgpara() to load values for unused parameters.

git-svn-id: trunk@45439 -

yury 5 years ago
parent
commit
9d1c814387
2 changed files with 13 additions and 2 deletions
  1. 11 0
      compiler/hlcgobj.pas
  2. 2 2
      compiler/ncgcal.pas

+ 11 - 0
compiler/hlcgobj.pas

@@ -197,6 +197,11 @@ unit hlcgobj;
              @param(r reference to get address from)
           }
           procedure a_loadaddr_ref_cgpara(list : TAsmList;fromsize : tdef;const r : treference;const cgpara : TCGPara);virtual;
+          {# Pass an undefined value as a parameter to a routine.
+             A generic version is provided and passes the 0/nil value
+             if the parameter's location is not a register.
+          }
+          procedure a_load_undefined_cgpara(list : TAsmList;size : tdef;const cgpara : TCGPara);virtual;
 
           { Remarks:
             * If a method specifies a size you have only to take care
@@ -1125,6 +1130,12 @@ implementation
          end;
     end;
 
+  procedure thlcgobj.a_load_undefined_cgpara(list: TAsmList; size: tdef; const cgpara: TCGPara);
+    begin
+      if not (cgpara.Location^.Loc in [LOC_REGISTER,LOC_CREGISTER]) then
+        a_load_const_cgpara(list,size,0,cgpara);
+    end;
+
   function thlcgobj.a_call_name_static(list: TAsmList; pd: tprocdef; const s: TSymStr; const paras: array of pcgpara; forceresdef: tdef): tcgpara;
     begin
       result:=a_call_name(list,pd,s,paras,forceresdef,false);

+ 2 - 2
compiler/ncgcal.pas

@@ -314,8 +314,8 @@ implementation
             tempcgpara.Location^.Loc:=LOC_VOID;
           end
         else
-          { Load the dummy nil/0 value }
-          hlcg.a_load_const_cgpara(current_asmdata.CurrAsmList,left.resultdef,0,tempcgpara);
+          { Load an undefined dummy value }
+          hlcg.a_load_undefined_cgpara(current_asmdata.CurrAsmList,left.resultdef,tempcgpara);
       end;