Mercurial > projects > dang
diff sema/DType.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 |
line wrap: on
line diff
--- a/sema/DType.d Thu May 01 19:51:22 2008 +0200 +++ b/sema/DType.d Thu May 01 23:08:41 2008 +0200 @@ -30,6 +30,11 @@ /// Return a DStruct if this is one, otherwise return null DStruct asStruct() { return null; } + /// Is this type a DArray + bool isArray() { return false; } + /// Return a DArray if this is one, otherwise return null + DArray asArray() { return null; } + /// Is this type a DFunction bool isFunction() { return false; } /// Return a DFunction if this is one, otherwise return null @@ -177,6 +182,22 @@ } } +class DArray : DType +{ + this(DType arrayOf, DType actual = null) + { + super(id, actual); + this.arrayOf = arrayOf; + } + + override bool isArray() { return true; } + override DArray asArray() { return this; } + + int byteSize() { return arrayOf.byteSize; } + + DType arrayOf; +} + class DFunction : DType { this(Identifier id, DType actual = null)