Mercurial > projects > dil
comparison trunk/src/dil/ast/Node.d @ 673:64fec49651cf
Renamed VariableDeclaration to VariablesDeclaration.
Removed TryCast and CastTo template functions.
Renamed Node.iS() to Node.Is().
author | Aziz K?ksal <aziz.koeksal@gmail.com> |
---|---|
date | Fri, 18 Jan 2008 16:44:20 +0100 |
parents | f1325a4506de |
children | c4e3a34e40f1 |
comparison
equal
deleted
inserted
replaced
672:d422e5f2f3ea | 673:64fec49651cf |
---|---|
9 public import dil.lexer.Token; | 9 public import dil.lexer.Token; |
10 public import dil.ast.NodesEnum; | 10 public import dil.ast.NodesEnum; |
11 | 11 |
12 /// This string is mixed into the constructor of a class that inherits from Node. | 12 /// This string is mixed into the constructor of a class that inherits from Node. |
13 const string set_kind = `this.kind = mixin("NodeKind." ~ typeof(this).stringof);`; | 13 const string set_kind = `this.kind = mixin("NodeKind." ~ typeof(this).stringof);`; |
14 | |
15 Class TryCast(Class)(Node n) | |
16 { | |
17 assert(n !is null); | |
18 if (n.kind == mixin("NodeKind." ~ typeof(Class).stringof)) | |
19 return cast(Class)cast(void*)n; | |
20 return null; | |
21 } | |
22 | |
23 Class CastTo(Class)(Node n) | |
24 { | |
25 assert(n !is null && n.kind == mixin("NodeKind." ~ typeof(Class).stringof)); | |
26 return cast(Class)cast(void*)n; | |
27 } | |
28 | 14 |
29 class Node | 15 class Node |
30 { | 16 { |
31 NodeCategory category; | 17 NodeCategory category; |
32 NodeKind kind; | 18 NodeKind kind; |
77 void addOptChildren(Node[] children) | 63 void addOptChildren(Node[] children) |
78 { | 64 { |
79 children is null || addChildren(children); | 65 children is null || addChildren(children); |
80 } | 66 } |
81 | 67 |
82 Class iS(Class)() | 68 Class Is(Class)() |
83 { | 69 { |
84 if (kind == mixin("NodeKind." ~ typeof(Class).stringof)) | 70 if (kind == mixin("NodeKind." ~ typeof(Class).stringof)) |
85 return cast(Class)cast(void*)this; | 71 return cast(Class)cast(void*)this; |
86 return null; | 72 return null; |
87 } | 73 } |