diff ast/Exp.d @ 176:dc9bf56b7ace

Can now use & as a unary operator and take an AddressOf
author Anders Johnsen <skabet@gmail.com>
date Thu, 24 Jul 2008 23:03:18 +0200
parents 01c2c49775ef
children 2a1a635bd531
line wrap: on
line diff
--- a/ast/Exp.d	Thu Jul 24 21:12:12 2008 +0200
+++ b/ast/Exp.d	Thu Jul 24 23:03:18 2008 +0200
@@ -20,6 +20,7 @@
     Binary,
     Negate,
     Deref,
+    AddressOfExp,
     IntegerLit,
     MemberReference,
     Index,
@@ -306,6 +307,33 @@
     public Exp exp;
 }
 
+class AddressOfExp : Exp
+{
+    this(SLoc op, Exp exp)
+    {
+        super(ExpType.AddressOfExp, op);
+        this.exp = exp;
+    }
+
+    override AddressOfExp simplify()
+    {
+        exp = exp.simplify();
+        return this;
+    }
+
+    override DType type() 
+    {
+        return exp.type().getPointerTo; 
+    }
+
+    override SourceRange sourceRange()
+    {
+        return SourceRange(loc) + exp.sourceRange;
+    }
+
+    public Exp exp;
+}
+
 class IntegerLit : Exp
 {
     this(SLoc loc, char[] t)