Mercurial > projects > dil
comparison 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 |
comparison
equal
deleted
inserted
replaced
535:bdd49ad84f5f | 536:0781ac288537 |
---|---|
9 import dil.Declarations; | 9 import dil.Declarations; |
10 import dil.Statements; | 10 import dil.Statements; |
11 import dil.Identifier; | 11 import dil.Identifier; |
12 import dil.Scope; | 12 import dil.Scope; |
13 import dil.TypeSystem; | 13 import dil.TypeSystem; |
14 import common; | |
14 | 15 |
15 abstract class Expression : Node | 16 abstract class Expression : Node |
16 { | 17 { |
17 Type type; /// The type of this expression. | 18 Type type; /// The type of this expression. |
18 this() | 19 this() |
19 { | 20 { |
20 super(NodeCategory.Expression); | 21 super(NodeCategory.Expression); |
21 } | 22 } |
22 | 23 |
24 // Semantic analysis: | |
25 | |
23 Expression semantic(Scope scop) | 26 Expression semantic(Scope scop) |
24 { | 27 { |
25 return null; | 28 debug Stdout("SA for "~this.classinfo.name).newline; |
29 if (!type) | |
30 type = Types.Undefined; | |
31 return this; | |
26 } | 32 } |
27 | 33 |
28 import dil.Messages; | 34 import dil.Messages; |
29 void error(Scope scop, MID mid) | 35 void error(Scope scop, MID mid) |
30 { | 36 { |
31 scop.error(this.begin, mid); | 37 scop.error(this.begin, mid); |
38 } | |
39 | |
40 void error(Scope scop, char[] msg) | |
41 { | |
42 | |
32 } | 43 } |
33 } | 44 } |
34 | 45 |
35 class EmptyExpression : Expression | 46 class EmptyExpression : Expression |
36 { | 47 { |
710 } | 721 } |
711 } | 722 } |
712 | 723 |
713 class CharExpression : Expression | 724 class CharExpression : Expression |
714 { | 725 { |
715 Token* charLiteral; | 726 dchar character; |
716 this(Token* charLiteral) | 727 this(dchar character) |
717 { | 728 { |
718 mixin(set_kind); | 729 mixin(set_kind); |
719 this.charLiteral = charLiteral; | 730 this.character = character; |
731 } | |
732 | |
733 Expression semantic(Scope scop) | |
734 { | |
735 if (type) | |
736 return this; | |
737 if (character <= 0xFF) | |
738 type = Types.Char; | |
739 else if (character <= 0xFFFF) | |
740 type = Types.Wchar; | |
741 else | |
742 type = Types.Dchar; | |
743 return this; | |
720 } | 744 } |
721 } | 745 } |
722 | 746 |
723 class StringExpression : Expression | 747 class StringExpression : Expression |
724 { | 748 { |