Mercurial > projects > dang
diff sema/DType.d @ 136:2be29b296081
Lots of changes:
- Parsing classes and interfaces
- Fixed some seg faults in sema
- Supporting "private" to some extend
- And a lot of other small fixes
author | johnsen@johnsen-laptop |
---|---|
date | Fri, 11 Jul 2008 21:47:57 +0200 |
parents | a101853eaae0 |
children | 6e6355fb5f0f |
line wrap: on
line diff
--- a/sema/DType.d Wed Jul 09 13:38:11 2008 +0200 +++ b/sema/DType.d Fri Jul 11 21:47:57 2008 +0200 @@ -31,6 +31,11 @@ /// Return a DStruct if this is one, otherwise return null DStruct asStruct() { return null; } + /// Is this type a DStaticArray + bool isStaticArray() { return false; } + /// Return a DStaticArray if this is one, otherwise return null + DStaticArray asStaticArray() { return null; } + /// Is this type a DArray bool isArray() { return false; } /// Return a DArray if this is one, otherwise return null @@ -129,14 +134,23 @@ /** Get a type representing a static array of this type with length 'size' */ - DArray getAsArray(int size) + DStaticArray getAsStaticArray(int size) { - if(size in myArray) - return myArray[size]; - myArray[size] = new DArray(this, size); - return myArray[size]; + if(size in myStaticArray) + return myStaticArray[size]; + myStaticArray[size] = new DStaticArray(this, size); + return myStaticArray[size]; } - private DArray[int] myArray; + private DStaticArray[int] myStaticArray; + + DArray getAsArray() + { + if(myArray !is null) + return myArray; + myArray = new DArray(this); + return myArray; + } + private DArray myArray; static DInteger Bool, @@ -335,7 +349,7 @@ } } -class DArray : DType +class DStaticArray : DType { this(DType arrayOf, int size, DType actual = null) { @@ -344,8 +358,8 @@ this.size = size; } - override bool isArray() { return true; } - override DArray asArray() { return this; } + override bool isStaticArray() { return true; } + override DStaticArray asStaticArray() { return this; } int byteSize() { return arrayOf.byteSize * size; } @@ -358,6 +372,27 @@ const int size; } +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 8; } // FIXME: Size is a pointer + on size. (platform depend) + + override char[] mangle() + { + return "G"~arrayOf.mangle; // FIXME: Need correct mangling + } + + DType arrayOf; +} + class DPointer : DType { this(DType pointerOf, DType actual = null) @@ -389,6 +424,11 @@ override bool isFunction() { return true; } override DFunction asFunction() { return this; } + override bool hasImplicitConversionTo(DType that) + { + return returnType.hasImplicitConversionTo(that); + } + override char[] mangle() { char[] res;