changeset 10:2f493057cf17

Some support for the rest of the boolean operators
author Anders Halager <halager@gmail.com>
date Fri, 18 Apr 2008 13:01:11 +0200
parents a0a3223a76c3
children 642c6a998fd9
files ast/Exp.d gen/LLVMGen.d parser/Parser.d
diffstat 3 files changed, 17 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/ast/Exp.d	Fri Apr 18 12:52:53 2008 +0200
+++ b/ast/Exp.d	Fri Apr 18 13:01:11 2008 +0200
@@ -58,6 +58,8 @@
     public enum Operator
     {
         Eq, Ne,
+        Lt, Le,
+        Gt, Ge,
         Mul, Div,
         Add, Sub,
     }
@@ -72,7 +74,7 @@
 
     char[] resultType()
     {
-        if (op >= Operator.Eq && op <= Operator.Ne)
+        if (op >= Operator.Eq && op <= Operator.Ge)
             return "bool";
         return null;
     }
--- a/gen/LLVMGen.d	Fri Apr 18 12:52:53 2008 +0200
+++ b/gen/LLVMGen.d	Fri Apr 18 13:01:11 2008 +0200
@@ -34,7 +34,12 @@
             op.Sub      : "sub",
             op.Mul      : "mul",
             op.Div      : "div",
-            op.Eq       : "icmp eq"
+            op.Eq       : "icmp eq",
+            op.Ne       : "icmp ne",
+            op.Lt       : "icmp slt",
+            op.Le       : "icmp sle",
+            op.Gt       : "icmp glt",
+            op.Ge       : "icmp gle"
         ];
         table = new SimpleSymbolTable();
     }
--- a/parser/Parser.d	Fri Apr 18 12:52:53 2008 +0200
+++ b/parser/Parser.d	Fri Apr 18 13:01:11 2008 +0200
@@ -294,10 +294,16 @@
 
     static BinOp[] _binary =
     [
-        {Tok.Equals,    2, true, BinaryExp.Operator.Eq},
-        {Tok.NotEquals, 2, true, BinaryExp.Operator.Ne},
+        {Tok.Eq,        2, true, BinaryExp.Operator.Eq},
+        {Tok.Ne,        2, true, BinaryExp.Operator.Ne},
+        {Tok.Lt,        2, true, BinaryExp.Operator.Lt},
+        {Tok.Le,        2, true, BinaryExp.Operator.Le},
+        {Tok.Gt,        2, true, BinaryExp.Operator.Gt},
+        {Tok.Ge,        2, true, BinaryExp.Operator.Ge},
+
         {Tok.Add,       3, true, BinaryExp.Operator.Add},
         {Tok.Sub,       3, true, BinaryExp.Operator.Sub},
+
         {Tok.Mul,       5, true, BinaryExp.Operator.Mul},
         {Tok.Div,       5, true, BinaryExp.Operator.Div}
     ];