Browse Source

+ added set of widechar support (limited to 256 chars, is delphi compatible)

florian 21 years ago
parent
commit
d6b865167c
2 changed files with 65 additions and 50 deletions
  1. 18 15
      compiler/nadd.pas
  2. 47 35
      compiler/ncnv.pas

+ 18 - 15
compiler/nadd.pas

@@ -234,20 +234,20 @@ implementation
          rt:=right.nodetype;
          rt:=right.nodetype;
          lt:=left.nodetype;
          lt:=left.nodetype;
 
 
-       if (nodetype = slashn) and
-          (((rt = ordconstn) and
-            (tordconstnode(right).value = 0)) or
-           ((rt = realconstn) and
-            (trealconstnode(right).value_real = 0.0))) then
-         begin
-           if (cs_check_range in aktlocalswitches) or
-              (cs_check_overflow in aktlocalswitches) then
-              begin
-                result:=crealconstnode.create(1,pbestrealtype^);
-                Message(parser_e_division_by_zero);
-                exit;
-              end;
-         end;
+         if (nodetype = slashn) and
+            (((rt = ordconstn) and
+              (tordconstnode(right).value = 0)) or
+             ((rt = realconstn) and
+              (trealconstnode(right).value_real = 0.0))) then
+           begin
+             if (cs_check_range in aktlocalswitches) or
+                (cs_check_overflow in aktlocalswitches) then
+                begin
+                  result:=crealconstnode.create(1,pbestrealtype^);
+                  Message(parser_e_division_by_zero);
+                  exit;
+                end;
+           end;
 
 
 
 
          { both are int constants }
          { both are int constants }
@@ -1977,7 +1977,10 @@ begin
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.121  2004-05-23 14:08:39  peter
+  Revision 1.122  2004-05-23 14:14:18  florian
+    + added set of widechar support (limited to 256 chars, is delphi compatible)
+
+  Revision 1.121  2004/05/23 14:08:39  peter
     * only convert widechar to widestring when both operands are
     * only convert widechar to widestring when both operands are
       constant
       constant
     * support widechar-widechar operations in orddef part
     * support widechar-widechar operations in orddef part

+ 47 - 35
compiler/ncnv.pas

@@ -278,43 +278,52 @@ implementation
         constsethi  : TConstExprInt;
         constsethi  : TConstExprInt;
 
 
         procedure update_constsethi(t:ttype);
         procedure update_constsethi(t:ttype);
-        begin
-          if ((t.def.deftype=orddef) and
-              (torddef(t.def).high>=constsethi)) then
-            begin
-               constsethi:=torddef(t.def).high;
-               if htype.def=nil then
-                 begin
-                    if (constsethi>255) or
-                       (torddef(t.def).low<0) then
-                      htype:=u8inttype
-                    else
+          begin
+            if ((t.def.deftype=orddef) and
+                (torddef(t.def).high>=constsethi)) then
+              begin
+                if torddef(t.def).typ=uwidechar then
+                  begin
+                    constsethi:=255;
+                    if htype.def=nil then
                       htype:=t;
                       htype:=t;
-                 end;
-               if constsethi>255 then
-                 constsethi:=255;
-            end
-          else if ((t.def.deftype=enumdef) and
-                  (tenumdef(t.def).max>=constsethi)) then
-            begin
-               if htype.def=nil then
-                 htype:=t;
-               constsethi:=tenumdef(t.def).max;
-            end;
-        end;
+                  end
+                else
+                  begin
+                    constsethi:=torddef(t.def).high;
+                    if htype.def=nil then
+                      begin
+                         if (constsethi>255) or
+                            (torddef(t.def).low<0) then
+                           htype:=u8inttype
+                         else
+                           htype:=t;
+                      end;
+                    if constsethi>255 then
+                      constsethi:=255;
+                  end;
+              end
+            else if ((t.def.deftype=enumdef) and
+                    (tenumdef(t.def).max>=constsethi)) then
+              begin
+                 if htype.def=nil then
+                   htype:=t;
+                 constsethi:=tenumdef(t.def).max;
+              end;
+          end;
 
 
         procedure do_set(pos : longint);
         procedure do_set(pos : longint);
-        begin
-          if (pos and not $ff)<>0 then
-           Message(parser_e_illegal_set_expr);
-          if pos>constsethi then
-           constsethi:=pos;
-          if pos<constsetlo then
-           constsetlo:=pos;
-          if pos in constset^ then
-            Message(parser_e_illegal_set_expr);
-          include(constset^,pos);
-        end;
+          begin
+            if (pos and not $ff)<>0 then
+             Message(parser_e_illegal_set_expr);
+            if pos>constsethi then
+             constsethi:=pos;
+            if pos<constsetlo then
+             constsetlo:=pos;
+            if pos in constset^ then
+              Message(parser_e_illegal_set_expr);
+            include(constset^,pos);
+          end;
 
 
       var
       var
         l : Longint;
         l : Longint;
@@ -2414,7 +2423,10 @@ begin
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.144  2004-04-29 19:56:37  daniel
+  Revision 1.145  2004-05-23 14:14:18  florian
+    + added set of widechar support (limited to 256 chars, is delphi compatible)
+
+  Revision 1.144  2004/04/29 19:56:37  daniel
     * Prepare compiler infrastructure for multiple ansistring types
     * Prepare compiler infrastructure for multiple ansistring types
 
 
   Revision 1.143  2004/03/23 22:34:49  peter
   Revision 1.143  2004/03/23 22:34:49  peter