浏览代码

* fixed div qword

peter 21 年之前
父节点
当前提交
07c67967cf
共有 1 个文件被更改,包括 27 次插入17 次删除
  1. 27 17
      compiler/nmat.pas

+ 27 - 17
compiler/nmat.pas

@@ -85,12 +85,12 @@ interface
 implementation
 implementation
 
 
     uses
     uses
-      systems,tokens,
+      systems,
       verbose,globals,cutils,
       verbose,globals,cutils,
       globtype,
       globtype,
-      symconst,symtype,symtable,symdef,symsym,defutil,
-      htypechk,pass_1,cpubase,
-      cgbase,procinfo,
+      symconst,symtype,symdef,defutil,
+      htypechk,pass_1,
+      cgbase,
       ncon,ncnv,ncal,nadd;
       ncon,ncnv,ncal,nadd;
 
 
 {****************************************************************************
 {****************************************************************************
@@ -171,11 +171,17 @@ implementation
          if (rd.typ in [u32bit,u64bit]) and
          if (rd.typ in [u32bit,u64bit]) and
             is_constintnode(left) and
             is_constintnode(left) and
             (tordconstnode(left).value >= 0) then
             (tordconstnode(left).value >= 0) then
-           inserttypeconv(left,right.resulttype);
+           begin
+             inserttypeconv(left,right.resulttype);
+             ld:=torddef(left.resulttype.def);
+           end;
          if (ld.typ in [u32bit,u64bit]) and
          if (ld.typ in [u32bit,u64bit]) and
             is_constintnode(right) and
             is_constintnode(right) and
             (tordconstnode(right).value >= 0) then
             (tordconstnode(right).value >= 0) then
-           inserttypeconv(right,left.resulttype);
+          begin
+            inserttypeconv(right,left.resulttype);
+            rd:=torddef(right.resulttype.def);
+          end;
 
 
          { when there is one currency value, everything is done
          { when there is one currency value, everything is done
            using currency }
            using currency }
@@ -197,16 +203,16 @@ implementation
            begin
            begin
              if is_signed(rd) or is_signed(ld) then
              if is_signed(rd) or is_signed(ld) then
                begin
                begin
-                  if (torddef(ld).typ<>s64bit) then
+                  if (ld.typ<>s64bit) then
                     inserttypeconv(left,s64inttype);
                     inserttypeconv(left,s64inttype);
-                  if (torddef(rd).typ<>s64bit) then
+                  if (rd.typ<>s64bit) then
                     inserttypeconv(right,s64inttype);
                     inserttypeconv(right,s64inttype);
                end
                end
              else
              else
                begin
                begin
-                  if (torddef(ld).typ<>u64bit) then
+                  if (ld.typ<>u64bit) then
                     inserttypeconv(left,u64inttype);
                     inserttypeconv(left,u64inttype);
-                  if (torddef(rd).typ<>u64bit) then
+                  if (rd.typ<>u64bit) then
                     inserttypeconv(right,u64inttype);
                     inserttypeconv(right,u64inttype);
                end;
                end;
              resulttype:=left.resulttype;
              resulttype:=left.resulttype;
@@ -214,14 +220,14 @@ implementation
          else
          else
           { when mixing cardinals and signed numbers, convert everythign to 64bit (JM) }
           { when mixing cardinals and signed numbers, convert everythign to 64bit (JM) }
           if ((rd.typ = u32bit) and
           if ((rd.typ = u32bit) and
-              is_signed(left.resulttype.def)) or
+              is_signed(ld)) or
              ((ld.typ = u32bit) and
              ((ld.typ = u32bit) and
-              is_signed(right.resulttype.def)) then
+              is_signed(rd)) then
            begin
            begin
               CGMessage(type_w_mixed_signed_unsigned);
               CGMessage(type_w_mixed_signed_unsigned);
-              if (torddef(ld).typ<>s64bit) then
+              if (ld.typ<>s64bit) then
                 inserttypeconv(left,s64inttype);
                 inserttypeconv(left,s64inttype);
-              if (torddef(rd).typ<>s64bit) then
+              if (rd.typ<>s64bit) then
                 inserttypeconv(right,s64inttype);
                 inserttypeconv(right,s64inttype);
               resulttype:=left.resulttype;
               resulttype:=left.resulttype;
            end
            end
@@ -229,9 +235,9 @@ implementation
 {$endif cpu64bit}
 {$endif cpu64bit}
            begin
            begin
               { Make everything always default singed int }
               { Make everything always default singed int }
-              if not(torddef(right.resulttype.def).typ in [torddef(sinttype.def).typ,torddef(uinttype.def).typ]) then
+              if not(rd.typ in [torddef(sinttype.def).typ,torddef(uinttype.def).typ]) then
                 inserttypeconv(right,sinttype);
                 inserttypeconv(right,sinttype);
-              if not(torddef(left.resulttype.def).typ in [torddef(sinttype.def).typ,torddef(uinttype.def).typ]) then
+              if not(ld.typ in [torddef(sinttype.def).typ,torddef(uinttype.def).typ]) then
                 inserttypeconv(left,sinttype);
                 inserttypeconv(left,sinttype);
               resulttype:=right.resulttype;
               resulttype:=right.resulttype;
            end;
            end;
@@ -459,6 +465,7 @@ implementation
          if not is_64bit(left.resulttype.def) then
          if not is_64bit(left.resulttype.def) then
 {$endif}
 {$endif}
            begin
            begin
+             { constants generate signed integers }
              if is_signed(left.resulttype.def) then
              if is_signed(left.resulttype.def) then
                inserttypeconv(left,sinttype)
                inserttypeconv(left,sinttype)
              else
              else
@@ -854,7 +861,10 @@ begin
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.62  2004-05-19 23:29:25  peter
+  Revision 1.63  2004-05-28 21:14:34  peter
+    * fixed div qword
+
+  Revision 1.62  2004/05/19 23:29:25  peter
     * don't change sign for unsigned shl/shr operations
     * don't change sign for unsigned shl/shr operations
     * cleanup for u32bit
     * cleanup for u32bit