# HG changeset patch # User Aziz K?ksal # Date 1197987281 -3600 # Node ID 0781ac288537c62cbad87094d2feb57651b28c55 # Parent bdd49ad84f5f0e57f97d632a97ec3a846bb6d283 Added some semantic() methods. Renamed member typ of dil.TypeSystem.Type to tid. Added 'Undefined' to struct Types. Removed charLiteral and added 'dchar character' to class CharExpression. diff -r bdd49ad84f5f -r 0781ac288537 trunk/src/dil/Expressions.d --- a/trunk/src/dil/Expressions.d Tue Dec 18 00:32:30 2007 +0100 +++ b/trunk/src/dil/Expressions.d Tue Dec 18 15:14:41 2007 +0100 @@ -11,6 +11,7 @@ import dil.Identifier; import dil.Scope; import dil.TypeSystem; +import common; abstract class Expression : Node { @@ -20,9 +21,14 @@ super(NodeCategory.Expression); } + // Semantic analysis: + Expression semantic(Scope scop) { - return null; + debug Stdout("SA for "~this.classinfo.name).newline; + if (!type) + type = Types.Undefined; + return this; } import dil.Messages; @@ -30,6 +36,11 @@ { scop.error(this.begin, mid); } + + void error(Scope scop, char[] msg) + { + + } } class EmptyExpression : Expression @@ -712,11 +723,24 @@ class CharExpression : Expression { - Token* charLiteral; - this(Token* charLiteral) + dchar character; + this(dchar character) { mixin(set_kind); - this.charLiteral = charLiteral; + this.character = character; + } + + Expression semantic(Scope scop) + { + if (type) + return this; + if (character <= 0xFF) + type = Types.Char; + else if (character <= 0xFFFF) + type = Types.Wchar; + else + type = Types.Dchar; + return this; } } diff -r bdd49ad84f5f -r 0781ac288537 trunk/src/dil/Parser.d --- a/trunk/src/dil/Parser.d Tue Dec 18 00:32:30 2007 +0100 +++ b/trunk/src/dil/Parser.d Tue Dec 18 15:14:41 2007 +0100 @@ -3311,7 +3311,7 @@ nT(); break; case T.CharLiteral: - e = new CharExpression(token); + e = new CharExpression(token.dchar_); nT(); break; case T.String: diff -r bdd49ad84f5f -r 0781ac288537 trunk/src/dil/TypeSystem.d --- a/trunk/src/dil/TypeSystem.d Tue Dec 18 00:32:30 2007 +0100 +++ b/trunk/src/dil/TypeSystem.d Tue Dec 18 15:14:41 2007 +0100 @@ -12,14 +12,14 @@ abstract class Type : Symbol { Type next; - TYP typ; + TYP tid; /// The ID of the type. this(){} - this(Type next, TYP typ) + this(Type next, TYP tid) { this.next = next; - this.typ = typ; + this.tid = tid; } TypePointer ptrTo() @@ -249,7 +249,7 @@ size_t getSize(Type type) { - auto size = metaInfoTable[type.typ].size; + auto size = metaInfoTable[type.tid].size; if (size == SIZE_NOT_AVAILABLE) return type.sizeOf_(); return size; @@ -270,6 +270,7 @@ TypeBasic Size_t, Ptrdiff_t; TypePointer Void_ptr; + TypeBasic Undefined; /// Allocates an instance of TypeBasic and assigns it to typeName. template newTB(char[] typeName) @@ -314,5 +315,6 @@ Ptrdiff_t = Int; } Void_ptr = Void.ptrTo; + Undefined = new TypeBasic(TYP.Error); } }