Browse Source

* compare_paras() has a parameter to ignore hidden parameters
* cross unit overload searching ignores hidden parameters when
comparing parameter lists. Now function(string):string is
not overriden with procedure(string) which has the same visible
parameter list

peter 22 years ago
parent
commit
e720d73bd9
5 changed files with 69 additions and 34 deletions
  1. 25 19
      compiler/defcmp.pas
  2. 10 2
      compiler/ncal.pas
  3. 14 7
      compiler/nobj.pas
  4. 10 3
      compiler/pdecsub.pas
  5. 10 3
      compiler/symsym.pas

+ 25 - 19
compiler/defcmp.pas

@@ -103,7 +103,7 @@ interface
       search for a routine with default parameters, before
       searching for the same definition with no parameters)
     }
-    function compare_paras(paralist1,paralist2 : TLinkedList; acp : compare_type;allowdefaults:boolean):tequaltype;
+    function compare_paras(paralist1,paralist2 : TLinkedList; acp : compare_type;allowdefaults,ignorehidden:boolean):tequaltype;
 
     { True if a function can be assigned to a procvar }
     { changed first argument type to pabstractprocdef so that it can also be }
@@ -1060,7 +1060,7 @@ implementation
       end;
 
 
-    function compare_paras(paralist1,paralist2 : TLinkedList; acp : compare_type;allowdefaults:boolean):tequaltype;
+    function compare_paras(paralist1,paralist2 : TLinkedList; acp : compare_type;allowdefaults,ignorehidden:boolean):tequaltype;
       var
         currpara1,
         currpara2 : TParaItem;
@@ -1074,6 +1074,13 @@ implementation
          lowesteq:=high(tequaltype);
          currpara1:=TParaItem(paralist1.first);
          currpara2:=TParaItem(paralist2.first);
+         if ignorehidden then
+           begin
+             while assigned(currpara1) and currpara1.is_hidden do
+               currpara1:=tparaitem(currpara1.next);
+             while assigned(currpara2) and currpara2.is_hidden do
+               currpara2:=tparaitem(currpara2.next);
+           end;
          while (assigned(currpara1)) and (assigned(currpara2)) do
            begin
              eq:=te_incompatible;
@@ -1153,6 +1160,13 @@ implementation
                end;
               currpara1:=TParaItem(currpara1.next);
               currpara2:=TParaItem(currpara2.next);
+              if ignorehidden then
+                begin
+                  while assigned(currpara1) and currpara1.is_hidden do
+                    currpara1:=tparaitem(currpara1.next);
+                  while assigned(currpara2) and currpara2.is_hidden do
+                    currpara2:=tparaitem(currpara2.next);
+                end;
            end;
          { when both lists are empty then the parameters are equal. Also
            when one list is empty and the other has a parameter with default
@@ -1192,32 +1206,24 @@ implementation
             { return equal type based on the parameters, but a proc->procvar
               is never exact, so map an exact match of the parameters to
               te_equal }
-            eq:=compare_paras(def1.para,def2.para,cp_procvar,false);
+            eq:=compare_paras(def1.para,def2.para,cp_procvar,false,false);
             if eq=te_exact then
              eq:=te_equal;
             proc_to_procvar_equal:=eq;
           end;
       end;
 
-
-    function is_equal(def1,def2 : tdef) : boolean;
-      var
-        doconv : tconverttype;
-        hpd : tprocdef;
-      begin
-        is_equal:=(compare_defs_ext(def1,def2,nothingn,false,true,doconv,hpd)>=te_equal);
-      end;
-
-
-    function equal_paras(paralist1,paralist2 : TLinkedList; acp : compare_type;allowdefaults:boolean) : boolean;
-      begin
-        equal_paras:=(compare_paras(paralist1,paralist2,acp,allowdefaults)>=te_equal);
-      end;
-
 end.
 {
   $Log$
-  Revision 1.30  2003-10-05 13:05:05  peter
+  Revision 1.31  2003-10-07 21:14:32  peter
+    * compare_paras() has a parameter to ignore hidden parameters
+    * cross unit overload searching ignores hidden parameters when
+      comparing parameter lists. Now function(string):string is
+      not overriden with procedure(string) which has the same visible
+      parameter list
+
+  Revision 1.30  2003/10/05 13:05:05  peter
     * when comparing hidden parameters both must be hidden
 
   Revision 1.29  2003/10/05 12:57:11  peter

+ 10 - 2
compiler/ncal.pas

@@ -1340,7 +1340,8 @@ type
                            hp:=procs;
                            while assigned(hp) do
                             begin
-                              if compare_paras(hp^.data.para,pd.para,cp_value_equal_const,false)>=te_equal then
+                              { Only compare visible parameters for the user }
+                              if compare_paras(hp^.data.para,pd.para,cp_value_equal_const,false,true)>=te_equal then
                                begin
                                  found:=true;
                                  break;
@@ -2608,7 +2609,14 @@ begin
 end.
 {
   $Log$
-  Revision 1.191  2003-10-05 21:21:52  peter
+  Revision 1.192  2003-10-07 21:14:32  peter
+    * compare_paras() has a parameter to ignore hidden parameters
+    * cross unit overload searching ignores hidden parameters when
+      comparing parameter lists. Now function(string):string is
+      not overriden with procedure(string) which has the same visible
+      parameter list
+
+  Revision 1.191  2003/10/05 21:21:52  peter
     * c style array of const generates callparanodes
     * varargs paraloc fixes
 

+ 14 - 7
compiler/nobj.pas

@@ -634,7 +634,7 @@ implementation
                                       begin
                                         if tstoredsym(procdefcoll^.data.procsym).is_visible_for_object(pd._class) and
                                            (not(pdoverload or hasoverloads) or
-                                            (compare_paras(procdefcoll^.data.para,pd.para,cp_value_equal_const,false)>=te_equal)) then
+                                            (compare_paras(procdefcoll^.data.para,pd.para,cp_value_equal_const,false,false)>=te_equal)) then
                                          begin
                                            if is_visible then
                                              procdefcoll^.hidden:=true;
@@ -652,7 +652,7 @@ implementation
                                          begin
                                            { we start a new virtual tree, hide the old }
                                            if (not(pdoverload or hasoverloads) or
-                                               (compare_paras(procdefcoll^.data.para,pd.para,cp_value_equal_const,false)>=te_equal)) and
+                                               (compare_paras(procdefcoll^.data.para,pd.para,cp_value_equal_const,false,false)>=te_equal)) and
                                               (tstoredsym(procdefcoll^.data.procsym).is_visible_for_object(pd._class)) then
                                             begin
                                               if is_visible then
@@ -668,7 +668,7 @@ implementation
                                            { do nothing, the error will follow when adding the entry }
                                          end
                                         { same parameters }
-                                        else if (compare_paras(procdefcoll^.data.para,pd.para,cp_value_equal_const,false)>=te_equal) then
+                                        else if (compare_paras(procdefcoll^.data.para,pd.para,cp_value_equal_const,false,false)>=te_equal) then
                                          begin
                                            { overload is inherited }
                                            if (po_overload in procdefcoll^.data.procoptions) then
@@ -734,7 +734,7 @@ implementation
                                           if the new defintion has not the overload directive }
                                         if is_visible and
                                            ((not(pdoverload or hasoverloads)) or
-                                            (compare_paras(procdefcoll^.data.para,pd.para,cp_value_equal_const,false)>=te_equal)) then
+                                            (compare_paras(procdefcoll^.data.para,pd.para,cp_value_equal_const,false,false)>=te_equal)) then
                                           procdefcoll^.hidden:=true;
                                       end;
                                    end
@@ -744,7 +744,7 @@ implementation
                                        has not the overload directive }
                                      if is_visible and
                                         ((not pdoverload) or
-                                         (compare_paras(procdefcoll^.data.para,pd.para,cp_value_equal_const,false)>=te_equal)) then
+                                         (compare_paras(procdefcoll^.data.para,pd.para,cp_value_equal_const,false,false)>=te_equal)) then
                                        procdefcoll^.hidden:=true;
                                    end;
                                 end; { not hidden }
@@ -1046,7 +1046,7 @@ implementation
           for i:=1 to sym.procdef_count do
             begin
               implprocdef:=sym.procdef[i];
-              if (compare_paras(proc.para,implprocdef.para,cp_none,false)>=te_equal) and
+              if (compare_paras(proc.para,implprocdef.para,cp_none,false,false)>=te_equal) and
                  (proc.proccalloption=implprocdef.proccalloption) then
                 begin
                   gintfgetcprocdef:=implprocdef;
@@ -1356,7 +1356,14 @@ initialization
 end.
 {
   $Log$
-  Revision 1.50  2003-10-07 20:44:22  peter
+  Revision 1.51  2003-10-07 21:14:32  peter
+    * compare_paras() has a parameter to ignore hidden parameters
+    * cross unit overload searching ignores hidden parameters when
+      comparing parameter lists. Now function(string):string is
+      not overriden with procedure(string) which has the same visible
+      parameter list
+
+  Revision 1.50  2003/10/07 20:44:22  peter
     * inherited forced calling convention
     * show hints when forward doesn't match
 

+ 10 - 3
compiler/pdecsub.pas

@@ -1887,7 +1887,7 @@ const
               ) or
               { check arguments }
               (
-               (compare_paras(pd.para,hd.para,cp_none,false)>=te_equal) and
+               (compare_paras(pd.para,hd.para,cp_none,false,false)>=te_equal) and
                { for operators equal_paras is not enough !! }
                ((pd.proctypeoption<>potype_operator) or (optoken<>_ASSIGNMENT) or
                 equal_defs(hd.rettype.def,pd.rettype.def))
@@ -1906,7 +1906,7 @@ const
                       (
                        (m_repeat_forward in aktmodeswitches) and
                        (not((pd.maxparacount=0) or
-                            (compare_paras(pd.para,hd.para,cp_all,false)>=te_equal)))
+                            (compare_paras(pd.para,hd.para,cp_all,false,false)>=te_equal)))
                       ) or
                       (
                        ((m_repeat_forward in aktmodeswitches) or
@@ -2127,7 +2127,14 @@ const
 end.
 {
   $Log$
-  Revision 1.147  2003-10-07 20:52:54  peter
+  Revision 1.148  2003-10-07 21:14:33  peter
+    * compare_paras() has a parameter to ignore hidden parameters
+    * cross unit overload searching ignores hidden parameters when
+      comparing parameter lists. Now function(string):string is
+      not overriden with procedure(string) which has the same visible
+      parameter list
+
+  Revision 1.147  2003/10/07 20:52:54  peter
     * procvar varargs fixed
 
   Revision 1.146  2003/10/05 21:21:52  peter

+ 10 - 3
compiler/symsym.pas

@@ -379,7 +379,7 @@ implementation
        { module }
        fmodule,
        { codegen }
-       tgobj,paramgr,cresstr,
+       paramgr,cresstr,
        procinfo
        ;
 
@@ -1099,7 +1099,7 @@ implementation
            if (eq>=te_equal) or
               (allowconvert and (eq>te_incompatible)) then
             begin
-              eq:=compare_paras(pd^.def.para,params,cp_value_equal_const,allowdefault);
+              eq:=compare_paras(pd^.def.para,params,cp_value_equal_const,allowdefault,false);
               if (eq>=te_equal) or
                  (allowconvert and (eq>te_incompatible)) then
                 begin
@@ -2676,7 +2676,14 @@ implementation
 end.
 {
   $Log$
-  Revision 1.123  2003-10-07 15:17:07  peter
+  Revision 1.124  2003-10-07 21:14:33  peter
+    * compare_paras() has a parameter to ignore hidden parameters
+    * cross unit overload searching ignores hidden parameters when
+      comparing parameter lists. Now function(string):string is
+      not overriden with procedure(string) which has the same visible
+      parameter list
+
+  Revision 1.123  2003/10/07 15:17:07  peter
     * inline supported again, LOC_REFERENCEs are used to pass the
       parameters
     * inlineparasymtable,inlinelocalsymtable removed