Browse Source

* equal_paras and convertable_paras changed by transforming third parameter
into an enum with three possible values:
cp_none, cp_value_equal_const and cp_all.

pierre 25 years ago
parent
commit
38f27344f4
4 changed files with 75 additions and 23 deletions
  1. 7 2
      compiler/hcgdata.pas
  2. 13 3
      compiler/psub.pas
  3. 7 2
      compiler/ptype.pas
  4. 48 16
      compiler/types.pas

+ 7 - 2
compiler/hcgdata.pas

@@ -517,7 +517,7 @@ implementation
                              while assigned(procdefcoll) do
                                begin
                                   { compare parameters }
-                                  if equal_paras(procdefcoll^.data^.para,hp^.para,false) and
+                                  if equal_paras(procdefcoll^.data^.para,hp^.para,cp_all) and
                                      (
                                        (po_virtualmethod in procdefcoll^.data^.procoptions) or
                                        (po_virtualmethod in hp^.procoptions)
@@ -731,7 +731,12 @@ implementation
 end.
 {
   $Log$
-  Revision 1.28  2000-05-11 06:55:28  florian
+  Revision 1.29  2000-06-20 12:47:52  pierre
+    * equal_paras and convertable_paras changed by transforming third parameter
+      into an enum with three possible values:
+      cp_none, cp_value_equal_const and cp_all.
+
+  Revision 1.28  2000/05/11 06:55:28  florian
     * fixed some vmt problems, especially related to overloaded methods
       in objects/classes
 

+ 13 - 3
compiler/psub.pas

@@ -1286,11 +1286,16 @@ begin
            { check the parameters }
            if (not(m_repeat_forward in aktmodeswitches) and
                (aktprocsym^.definition^.para^.count=0)) or
-              (equal_paras(aktprocsym^.definition^.para,hd^.para,false) and
+              (equal_paras(aktprocsym^.definition^.para,hd^.para,cp_none) and
               { for operators equal_paras is not enough !! }
               ((aktprocsym^.definition^.proctypeoption<>potype_operator) or (optoken<>_ASSIGNMENT) or
                is_equal(pd^.nextoverloaded^.rettype.def,aktprocsym^.definition^.rettype.def))) then
              begin
+               if not equal_paras(aktprocsym^.definition^.para,hd^.para,cp_all) then
+                 begin
+                    Message1(parser_e_header_dont_match_forward,aktprocsym^.demangledName);
+                    exit;
+                 end;
                if hd^.forwarddef then
                { remove the forward definition  but don't delete it,      }
                { the symtable is the owner !!  }
@@ -2074,7 +2079,12 @@ end.
 
 {
   $Log$
-  Revision 1.63  2000-06-18 18:12:40  peter
+  Revision 1.64  2000-06-20 12:47:52  pierre
+    * equal_paras and convertable_paras changed by transforming third parameter
+      into an enum with three possible values:
+      cp_none, cp_value_equal_const and cp_all.
+
+  Revision 1.63  2000/06/18 18:12:40  peter
     * support overload keyword
 
   Revision 1.62  2000/06/02 21:24:48  pierre
@@ -2211,4 +2221,4 @@ end.
     * moved mangledname creation of normal proc so it also handles a wrong
       method proc
 
-}
+}

+ 7 - 2
compiler/ptype.pas

@@ -287,7 +287,7 @@ uses
              get_procdef:=nil;
              while assigned(p) do
                begin
-                  if equal_paras(p^.para,propertyparas,true) then
+                  if equal_paras(p^.para,propertyparas,cp_value_equal_const) then
                     break;
                   p:=p^.nextoverloaded;
                end;
@@ -1589,7 +1589,12 @@ uses
 end.
 {
   $Log$
-  Revision 1.27  2000-06-18 18:16:38  peter
+  Revision 1.28  2000-06-20 12:47:53  pierre
+    * equal_paras and convertable_paras changed by transforming third parameter
+      into an enum with three possible values:
+      cp_none, cp_value_equal_const and cp_all.
+
+  Revision 1.27  2000/06/18 18:16:38  peter
     * don't allow enum assignments in tp/delphi mode
 
   Revision 1.26  2000/06/13 17:09:56  kaz

+ 48 - 16
compiler/types.pas

@@ -146,15 +146,20 @@ interface
     function CheckTypes(def1,def2 : pdef) : boolean;
 
     { true, if two parameter lists are equal        }
-    { if value_equal_const is true, call by value   }
+    { if acp is cp_none, all have to match exactly  }
+    { if acp is cp_value_equal_const call by value  }
     { and call by const parameter are assumed as    }
     { equal                                         }
-    function equal_paras(paralist1,paralist2 : plinkedlist;value_equal_const : boolean) : boolean;
+    { if acp is cp_all the var const or nothing are considered equal }
+    type
+      compare_type = ( cp_none, cp_value_equal_const, cp_all);
+
+    function equal_paras(paralist1,paralist2 : plinkedlist; acp : compare_type) : boolean;
 
 
     { true if a type can be allowed for another one
       in a func var }
-    function convertable_paras(paralist1,paralist2 : plinkedlist;value_equal_const : boolean) : boolean;
+    function convertable_paras(paralist1,paralist2 : plinkedlist; acp : compare_type) : boolean;
 
     { true if a function can be assigned to a procvar }
     function proc_to_procvar_equal(def1:pprocdef;def2:pprocvardef) : boolean;
@@ -215,7 +220,9 @@ implementation
          (sym^.typ in [propertysym,varsym]);
       end;
 
-    function equal_paras(paralist1,paralist2 : plinkedlist;value_equal_const : boolean) : boolean;
+    {  compare_type = ( cp_none, cp_value_equal_const, cp_all); }
+
+    function equal_paras(paralist1,paralist2 : plinkedlist; acp : compare_type) : boolean;
       var
         def1,def2 : pparaitem;
       begin
@@ -223,7 +230,8 @@ implementation
          def2:=pparaitem(paralist2^.first);
          while (assigned(def1)) and (assigned(def2)) do
            begin
-              if value_equal_const then
+             case acp of
+              cp_value_equal_const :
                 begin
                    if not(is_equal(def1^.paratype.def,def2^.paratype.def)) or
                      ((def1^.paratyp<>def2^.paratyp) and
@@ -235,8 +243,8 @@ implementation
                         equal_paras:=false;
                         exit;
                      end;
-                end
-              else
+                end;
+              cp_all :
                 begin
                    if not(is_equal(def1^.paratype.def,def2^.paratype.def)) or
                      (def1^.paratyp<>def2^.paratyp) then
@@ -245,6 +253,15 @@ implementation
                         exit;
                      end;
                 end;
+              cp_none :
+                begin
+                   if not(is_equal(def1^.paratype.def,def2^.paratype.def)) then
+                     begin
+                        equal_paras:=false;
+                        exit;
+                     end;
+                end;
+              end;
               def1:=pparaitem(def1^.next);
               def2:=pparaitem(def2^.next);
            end;
@@ -254,7 +271,7 @@ implementation
            equal_paras:=false;
       end;
 
-    function convertable_paras(paralist1,paralist2 : plinkedlist;value_equal_const : boolean) : boolean;
+    function convertable_paras(paralist1,paralist2 : plinkedlist;acp : compare_type) : boolean;
       var
         def1,def2 : pparaitem;
         doconv : tconverttype;
@@ -263,7 +280,8 @@ implementation
          def2:=pparaitem(paralist2^.first);
          while (assigned(def1)) and (assigned(def2)) do
            begin
-              if value_equal_const then
+              case acp of
+              cp_value_equal_const :
                 begin
                    if (isconvertable(def1^.paratype.def,def2^.paratype.def,doconv,callparan,false)=0) or
                      ((def1^.paratyp<>def2^.paratyp) and
@@ -275,8 +293,8 @@ implementation
                         convertable_paras:=false;
                         exit;
                      end;
-                end
-              else
+                end;
+              cp_all :
                 begin
                    if (isconvertable(def1^.paratype.def,def2^.paratype.def,doconv,callparan,false)=0) or
                      (def1^.paratyp<>def2^.paratyp) then
@@ -285,6 +303,15 @@ implementation
                         exit;
                      end;
                 end;
+              cp_none :
+                begin
+                   if (isconvertable(def1^.paratype.def,def2^.paratype.def,doconv,callparan,false)=0) then
+                     begin
+                        convertable_paras:=false;
+                        exit;
+                     end;
+                end;
+              end;
               def1:=pparaitem(def1^.next);
               def2:=pparaitem(def2^.next);
            end;
@@ -322,8 +349,8 @@ implementation
          { check return value and para's and options, methodpointer is already checked
            parameters may also be convertable }
          if is_equal(def1^.rettype.def,def2^.rettype.def) and
-            (equal_paras(def1^.para,def2^.para,false) or
-             convertable_paras(def1^.para,def2^.para,false)) and
+            (equal_paras(def1^.para,def2^.para,cp_all) or
+             convertable_paras(def1^.para,def2^.para,cp_all)) and
             ((po_comp * def1^.procoptions)= (po_comp * def2^.procoptions)) then
            proc_to_procvar_equal:=true
          else
@@ -944,7 +971,7 @@ implementation
                    ((pprocvardef(def1)^.procoptions * po_compatibility_options)=
                     (pprocvardef(def2)^.procoptions * po_compatibility_options)) and
                    is_equal(pprocvardef(def1)^.rettype.def,pprocvardef(def2)^.rettype.def) and
-                   equal_paras(pprocvardef(def1)^.para,pprocvardef(def2)^.para,false);
+                   equal_paras(pprocvardef(def1)^.para,pprocvardef(def2)^.para,cp_all);
              end
          else
            if (def1^.deftype=arraydef) and (def2^.deftype=arraydef) then
@@ -1058,7 +1085,12 @@ implementation
 end.
 {
   $Log$
-  Revision 1.100  2000-05-28 15:22:54  florian
+  Revision 1.101  2000-06-20 12:47:53  pierre
+    * equal_paras and convertable_paras changed by transforming third parameter
+      into an enum with three possible values:
+      cp_none, cp_value_equal_const and cp_all.
+
+  Revision 1.100  2000/05/28 15:22:54  florian
     * fixed a problem with subrange enumerations in case statements
 
   Revision 1.99  2000/03/01 15:36:12  florian
@@ -1149,4 +1181,4 @@ end.
     * open array checks also for s32bitdef, because u32bit also has a
       high range of -1
 
-}
+}