Mercurial > projects > dil
diff trunk/src/dil/Expressions.d @ 536:0781ac288537
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.
author | Aziz K?ksal <aziz.koeksal@gmail.com> |
---|---|
date | Tue, 18 Dec 2007 15:14:41 +0100 |
parents | 812f497b20dc |
children | db7913148b29 |
line wrap: on
line diff
--- 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; } }