Răsfoiți Sursa

compiler: fix assembler constant expressions evaluation + fully enable appropriate test

git-svn-id: trunk@14475 -
paul 15 ani în urmă
părinte
comite
56bd6e830e
2 a modificat fișierele cu 8 adăugiri și 6 ștergeri
  1. 7 5
      compiler/rautils.pas
  2. 1 1
      tests/webtbs/tw8195b.pp

+ 7 - 5
compiler/rautils.pas

@@ -378,12 +378,14 @@ begin
   Case _Operator OF
     '(' :
       Priority:=0;
-    '+', '-' :
+    '|','^','~' :             // the lowest priority: OR, XOR, NOT
+      Priority:=0;
+    '&' :                     // bigger priority: AND
       Priority:=1;
-    '*', '/','%','<','>' :
+    '+', '-' :                // bigger priority: +, -
       Priority:=2;
-    '|','&','^','~' :
-      Priority:=0;
+    '*', '/','%','<','>' :   // the highest priority: *, /, MOD, SHL, SHR
+      Priority:=3;
     else
       Message(asmr_e_expr_illegal);
   end;
@@ -440,7 +442,7 @@ begin
                    end;
                   { if start of expression then surely a prefix }
                   { or if previous char was also an operator    }
-                  if (I = 1) or (not (Expr[I-1] in ['0'..'9','(',')'])) then
+                  if (I = 1) or (not (Expr[I-1] in ['0'..'9',')'])) then
                     OpPush(Expr[I],true)
                   else
                     Begin

+ 1 - 1
tests/webtbs/tw8195b.pp

@@ -9,7 +9,7 @@
 
 function Expression1: Integer;
 asm
-//  mov eax, 4 * 3 - 2 + (-1) / 2
+  mov eax, 4 * 3 - 2 + (-1) / 2
 end;
 
 function Expression2: Integer;