소스 검색

* convert_l3 convertlevel added. This level is used for conversions
where information can be lost like converting widestring->ansistring
or dword->byte

peter 22 년 전
부모
커밋
34de6782a5
4개의 변경된 파일62개의 추가작업 그리고 31개의 파일을 삭제
  1. 13 8
      compiler/defcmp.pas
  2. 31 17
      compiler/ncal.pas
  3. 8 2
      compiler/ncnv.pas
  4. 10 4
      compiler/symconst.pas

+ 13 - 8
compiler/defcmp.pas

@@ -227,7 +227,7 @@ implementation
                           { "punish" bad type conversions :) (JM) }
                           if (not is_in_limit(def_from,def_to)) and
                              (def_from.size > def_to.size) then
-                            eq:=te_convert_l2
+                            eq:=te_convert_l3
                         else
                           eq:=te_convert_l1;
                       end;
@@ -298,9 +298,9 @@ implementation
                          { Prefer conversions to shortstring over other
                            conversions. This is compatible with Delphi (PFV) }
                          if tstringdef(def_to).string_typ=st_shortstring then
-                           eq:=te_convert_l1
+                           eq:=te_convert_l2
                          else
-                           eq:=te_convert_l2;
+                           eq:=te_convert_l3;
                        end;
                    end;
                  orddef :
@@ -340,7 +340,7 @@ implementation
                           if is_pchar(def_from) then
                            begin
                              doconv:=tc_pchar_2_string;
-                             { trefer ansistrings because pchars can overflow shortstrings, }
+                             { prefer ansistrings because pchars can overflow shortstrings, }
                              { but only if ansistrings are the default (JM)                 }
                              if (is_shortstring(def_to) and
                                  not(cs_ansistrings in aktlocalswitches)) or
@@ -353,12 +353,12 @@ implementation
                           else if is_pwidechar(def_from) then
                            begin
                              doconv:=tc_pwchar_2_string;
-                             { trefer ansistrings because pchars can overflow shortstrings, }
+                             { prefer ansistrings because pchars can overflow shortstrings, }
                              { but only if ansistrings are the default (JM)                 }
                              if is_widestring(def_to) then
                                eq:=te_convert_l1
                              else
-                               eq:=te_convert_l2;
+                               eq:=te_convert_l3;
                            end;
                        end;
                    end;
@@ -691,7 +691,7 @@ implementation
                          is_void(tpointerdef(def_from).pointertype.def) then
                        begin
                          doconv:=tc_equal;
-                         { give pwidechar a small penalty }
+                         { give pwidechar a penalty }
                          if is_pwidechar(def_to) then
                           eq:=te_convert_l2
                          else
@@ -1179,7 +1179,12 @@ implementation
 end.
 {
   $Log$
-  Revision 1.18  2003-01-15 01:44:32  peter
+  Revision 1.19  2003-01-16 22:13:51  peter
+    * convert_l3 convertlevel added. This level is used for conversions
+      where information can be lost like converting widestring->ansistring
+      or dword->byte
+
+  Revision 1.18  2003/01/15 01:44:32  peter
     * merged methodpointer fixes from 1.0.x
 
   Revision 1.17  2003/01/09 21:43:39  peter

+ 31 - 17
compiler/ncal.pas

@@ -46,6 +46,7 @@ interface
           equal_count,
           cl1_count,
           cl2_count,
+          cl3_count,
           coper_count : integer; { should be signed }
           ordinal_distance : bestreal;
           invalid     : boolean;
@@ -292,30 +293,35 @@ type
              res:=(bestpd^.coper_count-currpd^.coper_count);
              if (res=0) then
               begin
-                { less cl2 parameters? }
-                res:=(bestpd^.cl2_count-currpd^.cl2_count);
+                { less cl3 parameters? }
+                res:=(bestpd^.cl3_count-currpd^.cl3_count);
                 if (res=0) then
                  begin
-                   { less cl1 parameters? }
-                   res:=(bestpd^.cl1_count-currpd^.cl1_count);
+                   { less cl2 parameters? }
+                   res:=(bestpd^.cl2_count-currpd^.cl2_count);
                    if (res=0) then
                     begin
-                      { more exact parameters? }
-                      res:=(currpd^.exact_count-bestpd^.exact_count);
+                      { less cl1 parameters? }
+                      res:=(bestpd^.cl1_count-currpd^.cl1_count);
                       if (res=0) then
                        begin
-                         { less equal parameters? }
-                         res:=(bestpd^.equal_count-currpd^.equal_count);
+                         { more exact parameters? }
+                         res:=(currpd^.exact_count-bestpd^.exact_count);
                          if (res=0) then
                           begin
-                            { smaller ordinal distance? }
-                            if (currpd^.ordinal_distance<bestpd^.ordinal_distance) then
-                             res:=1
-                            else
-                             if (currpd^.ordinal_distance>bestpd^.ordinal_distance) then
-                              res:=-1
-                            else
-                             res:=0;
+                            { less equal parameters? }
+                            res:=(bestpd^.equal_count-currpd^.equal_count);
+                            if (res=0) then
+                             begin
+                               { smaller ordinal distance? }
+                               if (currpd^.ordinal_distance<bestpd^.ordinal_distance) then
+                                res:=1
+                               else
+                                if (currpd^.ordinal_distance>bestpd^.ordinal_distance) then
+                                 res:=-1
+                               else
+                                res:=0;
+                             end;
                           end;
                        end;
                     end;
@@ -1371,6 +1377,7 @@ type
                           ' eq: '+tostr(hp^.equal_count)+
                           ' l1: '+tostr(hp^.cl1_count)+
                           ' l2: '+tostr(hp^.cl2_count)+
+                          ' l3: '+tostr(hp^.cl3_count)+
                           ' oper: '+tostr(hp^.coper_count)+
                           ' ord: '+realtostr(hp^.exact_count));
               { Print parameters in left-right order }
@@ -1495,6 +1502,8 @@ type
                      inc(hp^.cl1_count);
                    te_convert_l2 :
                      inc(hp^.cl2_count);
+                   te_convert_l3 :
+                     inc(hp^.cl3_count);
                    te_convert_operator :
                      inc(hp^.coper_count);
                    te_incompatible :
@@ -2375,7 +2384,12 @@ begin
 end.
 {
   $Log$
-  Revision 1.126  2003-01-15 01:44:32  peter
+  Revision 1.127  2003-01-16 22:13:52  peter
+    * convert_l3 convertlevel added. This level is used for conversions
+      where information can be lost like converting widestring->ansistring
+      or dword->byte
+
+  Revision 1.126  2003/01/15 01:44:32  peter
     * merged methodpointer fixes from 1.0.x
 
   Revision 1.125  2003/01/12 17:52:07  peter

+ 8 - 2
compiler/ncnv.pas

@@ -1068,7 +1068,8 @@ implementation
             end;
 
           te_convert_l1,
-          te_convert_l2 :
+          te_convert_l2,
+          te_convert_l3 :
             begin
               { nothing to do }
             end;
@@ -2024,7 +2025,12 @@ begin
 end.
 {
   $Log$
-  Revision 1.100  2003-01-15 01:44:32  peter
+  Revision 1.101  2003-01-16 22:13:52  peter
+    * convert_l3 convertlevel added. This level is used for conversions
+      where information can be lost like converting widestring->ansistring
+      or dword->byte
+
+  Revision 1.100  2003/01/15 01:44:32  peter
     * merged methodpointer fixes from 1.0.x
 
   Revision 1.99  2003/01/09 21:43:39  peter

+ 10 - 4
compiler/symconst.pas

@@ -303,7 +303,8 @@ type
   tequaltype = (
     te_incompatible,
     te_convert_operator,
-    te_convert_l2,     { compatible conversion with possible loss of data }
+    te_convert_l3,     { compatible conversion with possible loss of data }
+    te_convert_l2,     { compatible less prefered conversion }
     te_convert_l1,     { compatible conversion     }
     te_equal,          { the definitions are equal }
     te_exact
@@ -356,8 +357,8 @@ const
      );
 
      EqualTypeName : array[tequaltype] of string[16] = (
-       'incompatible','convert_operator','convert_l2','convert_l1',
-       'equal','exact'
+       'incompatible','convert_operator','convert_l3','convert_l2',
+       'convert_l1','equal','exact'
      );
 
 implementation
@@ -365,7 +366,12 @@ implementation
 end.
 {
   $Log$
-  Revision 1.45  2003-01-09 21:52:37  peter
+  Revision 1.46  2003-01-16 22:13:52  peter
+    * convert_l3 convertlevel added. This level is used for conversions
+      where information can be lost like converting widestring->ansistring
+      or dword->byte
+
+  Revision 1.45  2003/01/09 21:52:37  peter
     * merged some verbosity options.
     * V_LineInfo is a verbosity flag to include line info