Mercurial > projects > dil
comparison trunk/src/dil/ast/Types.d @ 604:87f09469d337
Moved class Parameter/s to module dil.ast.Parameter.
author | Aziz K?ksal <aziz.koeksal@gmail.com> |
---|---|
date | Sun, 06 Jan 2008 01:06:36 +0100 |
parents | 041eae272362 |
children | 9daa6c34c45a |
comparison
equal
deleted
inserted
replaced
603:fc351756cc84 | 604:87f09469d337 |
---|---|
4 +/ | 4 +/ |
5 module dil.ast.Types; | 5 module dil.ast.Types; |
6 | 6 |
7 import dil.ast.Node; | 7 import dil.ast.Node; |
8 import dil.ast.Expressions; | 8 import dil.ast.Expressions; |
9 import dil.ast.Parameter; | |
9 import dil.lexer.Identifier; | 10 import dil.lexer.Identifier; |
10 import dil.Enums; | 11 import dil.Enums; |
11 import dil.semantic.Scope; | 12 import dil.semantic.Scope; |
12 import dil.semantic.Types; | 13 import dil.semantic.Types; |
13 | |
14 class Parameter : Node | |
15 { | |
16 StorageClass stc; | |
17 TypeNode type; | |
18 Identifier* ident; | |
19 Expression defValue; | |
20 | |
21 this(StorageClass stc, TypeNode type, Identifier* ident, Expression defValue) | |
22 { | |
23 super(NodeCategory.Other); | |
24 mixin(set_kind); | |
25 // type can be null when param in foreach statement | |
26 addOptChild(type); | |
27 addOptChild(defValue); | |
28 | |
29 this.stc = stc; | |
30 this.type = type; | |
31 this.ident = ident; | |
32 this.defValue = defValue; | |
33 } | |
34 | |
35 /// func(...) or func(int[] values ...) | |
36 bool isVariadic() | |
37 { | |
38 return !!(stc & StorageClass.Variadic); | |
39 } | |
40 | |
41 /// func(...) | |
42 bool isOnlyVariadic() | |
43 { | |
44 return stc == StorageClass.Variadic && | |
45 type is null && ident is null; | |
46 } | |
47 } | |
48 | |
49 class Parameters : Node | |
50 { | |
51 this() | |
52 { | |
53 super(NodeCategory.Other); | |
54 mixin(set_kind); | |
55 } | |
56 | |
57 bool hasVariadic() | |
58 { | |
59 if (children.length != 0) | |
60 return items[$-1].isVariadic(); | |
61 return false; | |
62 } | |
63 | |
64 void opCatAssign(Parameter param) | |
65 { addChild(param); } | |
66 | |
67 Parameter[] items() | |
68 { return cast(Parameter[])children; } | |
69 | |
70 size_t length() | |
71 { return children.length; } | |
72 } | |
73 | 14 |
74 class BaseClass : Node | 15 class BaseClass : Node |
75 { | 16 { |
76 Protection prot; | 17 Protection prot; |
77 TypeNode type; | 18 TypeNode type; |