Browse Source

* fixed web bug #1665 (allow char to chararray type conversion) ("merged")

Jonas Maebe 24 years ago
parent
commit
a87a30b831
3 changed files with 44 additions and 3 deletions
  1. 5 1
      compiler/i386/n386cnv.pas
  2. 25 1
      compiler/ncnv.pas
  3. 14 1
      compiler/types.pas

+ 5 - 1
compiler/i386/n386cnv.pas

@@ -385,6 +385,7 @@ implementation
            @second_nothing, {not_possible}
            @second_nothing, {second_string_to_string, handled in resulttype pass }
            @second_char_to_string,
+           @second_nothing, {char_to_charray}
            @second_nothing, { pchar_to_string, handled in resulttype pass }
            @second_nothing, {cchar_to_pchar}
            @second_cstring_to_pchar,
@@ -490,7 +491,10 @@ begin
 end.
 {
   $Log$
-  Revision 1.26  2001-09-30 21:28:34  peter
+  Revision 1.27  2001-11-02 23:24:12  jonas
+    * fixed web bug 1665 (allow char to chararray type conversion) ("merged")
+
+  Revision 1.26  2001/09/30 21:28:34  peter
     * int64->boolean fixed
 
   Revision 1.25  2001/09/30 16:12:47  jonas

+ 25 - 1
compiler/ncnv.pas

@@ -46,6 +46,7 @@ interface
           function resulttype_string_to_chararray : tnode;
           function resulttype_string_to_string : tnode;
           function resulttype_char_to_string : tnode;
+          function resulttype_char_to_chararray : tnode;
           function resulttype_int_to_real : tnode;
           function resulttype_real_to_real : tnode;
           function resulttype_cchar_to_pchar : tnode;
@@ -591,6 +592,24 @@ implementation
       end;
 
 
+    function ttypeconvnode.resulttype_char_to_chararray : tnode;
+
+      begin
+        if resulttype.def.size <> 1 then
+          begin
+            { convert first to string, then to chararray }
+            inserttypeconv(left,cshortstringtype);
+            inserttypeconv(left,resulttype);
+            result:=left;
+            left := nil;
+            exit;
+          end;
+        result := nil;
+        { a chararray with 1 element is the same as a char }
+        set_location(location,left.location);
+      end;
+
+
     function ttypeconvnode.resulttype_char_to_char : tnode;
 
       var
@@ -720,6 +739,7 @@ implementation
           {not_possible} nil,
           { string_2_string } @ttypeconvnode.resulttype_string_to_string,
           { char_2_string } @ttypeconvnode.resulttype_char_to_string,
+          { char_2_chararray } @ttypeconvnode.resulttype_char_to_chararray,
           { pchar_2_string } @ttypeconvnode.resulttype_pchar_to_string,
           { cchar_2_pchar } @ttypeconvnode.resulttype_cchar_to_pchar,
           { cstring_2_pchar } @ttypeconvnode.resulttype_cstring_to_pchar,
@@ -1361,6 +1381,7 @@ implementation
            @ttypeconvnode.first_nothing, {not_possible}
            nil, { removed in resulttype_string_to_string }
            @ttypeconvnode.first_char_to_string,
+           @ttypeconvnode.first_nothing, { char_2_chararray, needs nothing extra }
            nil, { removed in resulttype_chararray_to_string }
            @ttypeconvnode.first_cchar_to_pchar,
            @ttypeconvnode.first_cstring_to_pchar,
@@ -1597,7 +1618,10 @@ begin
 end.
 {
   $Log$
-  Revision 1.43  2001-11-02 22:58:02  peter
+  Revision 1.44  2001-11-02 23:24:11  jonas
+    * fixed web bug 1665 (allow char to chararray type conversion) ("merged")
+
+  Revision 1.43  2001/11/02 22:58:02  peter
     * procsym definition rewrite
 
   Revision 1.42  2001/10/28 17:22:25  peter

+ 14 - 1
compiler/types.pas

@@ -163,6 +163,7 @@ interface
           tc_not_possible,
           tc_string_2_string,
           tc_char_2_string,
+          tc_char_2_chararray,
           tc_pchar_2_string,
           tc_cchar_2_pchar,
           tc_cstring_2_pchar,
@@ -1548,6 +1549,15 @@ implementation
                            b:=1;
                          end;
                       end;
+                    orddef:
+                      begin
+                        if is_chararray(def_to) and
+                           is_char(def_from) then
+                          begin
+                            doconv:=tc_char_2_chararray;
+                            b:=2;
+                          end;
+                      end;
                     recorddef :
                       begin
                         { tvarrec -> array of constconst }
@@ -1858,7 +1868,10 @@ implementation
 end.
 {
   $Log$
-  Revision 1.55  2001-11-02 22:58:09  peter
+  Revision 1.56  2001-11-02 23:24:12  jonas
+    * fixed web bug 1665 (allow char to chararray type conversion) ("merged")
+
+  Revision 1.55  2001/11/02 22:58:09  peter
     * procsym definition rewrite
 
   Revision 1.54  2001/10/28 17:22:25  peter