Mercurial > projects > dang
diff ast/Exp.d @ 72:628cb46ab13b new_gen
First update on the way to Arrays! :)
Lexer and ast/Exp now have the types needed.
All that needs to be updated now is the Parser. I suggest two options:
1) Making the Id a class that we can make a ArrayId and PointerId for at some point.
2) Use a struct as now, but adding some bools / ints to give a more abstract description of the type
2) is messy and 1) is slower... :/
author | Anders Johnsen <skabet@gmail.com> |
---|---|
date | Thu, 01 May 2008 23:08:41 +0200 |
parents | 381975d76baf |
children | 13eea2c4e60d ad956143dcdc |
line wrap: on
line diff
--- a/ast/Exp.d Thu May 01 19:51:22 2008 +0200 +++ b/ast/Exp.d Thu May 01 23:08:41 2008 +0200 @@ -17,8 +17,9 @@ Negate, IntegerLit, MemberReference, - ArrayLookup, + ArrayReference, Identifier, + ArrayIdentifier, AssignExp, CallExp, CastExp, @@ -280,11 +281,11 @@ private DType myType; } -class ArrayLookup : Exp +class ArrayReference : Exp { this(Exp target, IntegerLit pos) { - super(ExpType.ArrayLookup); + super(ExpType.ArrayReference); this.target = target; this.pos = pos; } @@ -327,6 +328,27 @@ Exp exp; } +class ArrayIdentifier : Identifier +{ + this(Identifier arrayOf) + { + super(ExpType.ArrayIdentifier); + this.arrayOf = arrayOf; + } + + override DType type() + { + if (myType !is null) + return myType; + myType = new DArray(arrayOf.type); + return myType; + } + + Identifier arrayOf; + + private DType myType; +} + class Identifier : Exp { this(Token t) @@ -336,6 +358,11 @@ name = t.get; } + protected this(ExpType t) + { + super(t); + } + override DType type() { if (myType !is null)