# HG changeset patch # User Aziz K?ksal # Date 1200607056 -3600 # Node ID f1325a4506debd1d0f11a110217b81c15c402271 # Parent d8c32113afdecb9f7412f2016a534812df60812c Removed enum TID from dil.ast.Types. Renamed UndefinedType to IllegalType. diff -r d8c32113afde -r f1325a4506de trunk/src/dil/ast/DefaultVisitor.d --- a/trunk/src/dil/ast/DefaultVisitor.d Thu Jan 17 22:28:04 2008 +0100 +++ b/trunk/src/dil/ast/DefaultVisitor.d Thu Jan 17 22:57:36 2008 +0100 @@ -287,7 +287,7 @@ else static if (is(T : TypeNode)) { - //UndefinedType, + //IllegalType, //IntegralType, //IdentifierType have no subnodes. static if (is(T == QualifiedType)) diff -r d8c32113afde -r f1325a4506de trunk/src/dil/ast/Node.d --- a/trunk/src/dil/ast/Node.d Thu Jan 17 22:28:04 2008 +0100 +++ b/trunk/src/dil/ast/Node.d Thu Jan 17 22:57:36 2008 +0100 @@ -35,6 +35,7 @@ this(NodeCategory category) { + assert(category != NodeCategory.Undefined); this.category = category; } diff -r d8c32113afde -r f1325a4506de trunk/src/dil/ast/NodesEnum.d --- a/trunk/src/dil/ast/NodesEnum.d Thu Jan 17 22:28:04 2008 +0100 +++ b/trunk/src/dil/ast/NodesEnum.d Thu Jan 17 22:57:36 2008 +0100 @@ -183,7 +183,7 @@ "AsmRegisterExpression", // Types: - "UndefinedType", + "IllegalType", "IntegralType", "QualifiedType", "ModuleScopeType", diff -r d8c32113afde -r f1325a4506de trunk/src/dil/ast/Types.d --- a/trunk/src/dil/ast/Types.d Thu Jan 17 22:28:04 2008 +0100 +++ b/trunk/src/dil/ast/Types.d Thu Jan 17 22:57:36 2008 +0100 @@ -8,80 +8,33 @@ import dil.ast.Expression; import dil.ast.Parameters; import dil.lexer.Identifier; +import dil.semantic.Types; import dil.Enums; -import dil.semantic.Types; - -// Scheduled for deletion. -enum TID -{ - Void = TOK.Void, - Char = TOK.Char, - Wchar = TOK.Wchar, - Dchar = TOK.Dchar, - Bool = TOK.Bool, - Byte = TOK.Byte, - Ubyte = TOK.Ubyte, - Short = TOK.Short, - Ushort = TOK.Ushort, - Int = TOK.Int, - Uint = TOK.Uint, - Long = TOK.Long, - Ulong = TOK.Ulong, - Float = TOK.Float, - Double = TOK.Double, - Real = TOK.Real, - Ifloat = TOK.Ifloat, - Idouble = TOK.Idouble, - Ireal = TOK.Ireal, - Cfloat = TOK.Cfloat, - Cdouble = TOK.Cdouble, - Creal = TOK.Creal, - Cent = TOK.Cent, - Ucent = TOK.Ucent, - - Undefined, - BaseClass, - Function, - Delegate, - Pointer, - CFuncPointer, - Array, - Qualified, - ModuleScope, - Identifier, - Typeof, - TemplateInstance, - Const, // D2 - Invariant, // D2 -} /// The base class of all type nodes. abstract class TypeNode : Node { - TID tid; TypeNode next; Type type; /// The semantic type of this type node. - this(TID tid) + this() { - this(tid, null); + this(null); } - this(TID tid, TypeNode next) + this(TypeNode next) { super(NodeCategory.Type); addOptChild(next); - this.tid = tid; this.next = next; } } -/// Illegal type. -class UndefinedType : TypeNode +/// Syntax error. +class IllegalType : TypeNode { this() { - super(TID.Undefined); mixin(set_kind); } } @@ -89,10 +42,11 @@ /// char, int, float etc. class IntegralType : TypeNode { + TOK tok; this(TOK tok) { - super(cast(TID)tok); mixin(set_kind); + this.tok = tok; } } @@ -102,7 +56,6 @@ Identifier* ident; this(Identifier* ident) { - super(TID.Identifier); mixin(set_kind); this.ident = ident; } @@ -115,7 +68,7 @@ TypeNode right; this(TypeNode left, TypeNode right) { - super(TID.Qualified, left); + super(left); mixin(set_kind); addChild(right); this.right = right; @@ -127,7 +80,7 @@ { this(TypeNode next) { - super(TID.ModuleScope, next); + super(next); mixin(set_kind); } } @@ -146,7 +99,6 @@ /// D2.0: "typeof" "(" "return" ")" this() { - super(TID.Typeof); mixin(set_kind); } @@ -163,7 +115,6 @@ TemplateArguments targs; this(Identifier* ident, TemplateArguments targs) { - super(TID.TemplateInstance); mixin(set_kind); addOptChild(targs); this.ident = ident; @@ -174,9 +125,9 @@ /// Type * class PointerType : TypeNode { - this(TypeNode t) + this(TypeNode next) { - super(TID.Pointer, t); + super(next); mixin(set_kind); } } @@ -192,39 +143,37 @@ this(TypeNode t) { - super(TID.Array, t); + super(t); mixin(set_kind); } this(TypeNode t, Expression e, Expression e2) { + this(t); addChild(e); addOptChild(e2); this.e = e; this.e2 = e2; - this(t); } this(TypeNode t, TypeNode assocType) { + this(t); addChild(assocType); this.assocType = assocType; - this(t); } } /// ReturnType "function" "(" Parameters? ")" class FunctionType : TypeNode { - TypeNode returnType; + alias next returnType; Parameters params; this(TypeNode returnType, Parameters params) { - super(TID.Function); + super(returnType); mixin(set_kind); - addChild(returnType); addChild(params); - this.returnType = returnType; this.params = params; } } @@ -232,15 +181,13 @@ /// ReturnType "delegate" "(" Parameters? ")" class DelegateType : TypeNode { - TypeNode returnType; + alias next returnType; Parameters params; this(TypeNode returnType, Parameters params) { - super(TID.Delegate); + super(returnType); mixin(set_kind); - addChild(returnType); addChild(params); - this.returnType = returnType; this.params = params; } } @@ -251,7 +198,7 @@ Parameters params; this(TypeNode type, Parameters params) { - super(TID.CFuncPointer, type); + super(type); mixin(set_kind); addOptChild(params); } @@ -263,7 +210,7 @@ Protection prot; this(Protection prot, TypeNode type) { - super(TID.BaseClass, type); + super(type); mixin(set_kind); this.prot = prot; } @@ -274,10 +221,10 @@ /// "const" "(" Type ")" class ConstType : TypeNode { - this(TypeNode t) + this(TypeNode next) { // If t is null: cast(const) - super(TID.Const, t); + super(next); mixin(set_kind); } } @@ -285,10 +232,10 @@ /// "invariant" "(" Type ")" class InvariantType : TypeNode { - this(TypeNode t) + this(TypeNode next) { // If t is null: cast(invariant) - super(TID.Invariant, t); + super(next); mixin(set_kind); } } diff -r d8c32113afde -r f1325a4506de trunk/src/dil/parser/Parser.d --- a/trunk/src/dil/parser/Parser.d Thu Jan 17 22:28:04 2008 +0100 +++ b/trunk/src/dil/parser/Parser.d Thu Jan 17 22:57:36 2008 +0100 @@ -3518,7 +3518,7 @@ } // version(D2) default: error(MID.ExpectedButFound, "BasicType", token.srcText); - t = new UndefinedType(); + t = new IllegalType(); nT(); } return set(t, begin);