comparison trunk/src/dil/ast/Parameter.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
children 9daa6c34c45a
comparison
equal deleted inserted replaced
603:fc351756cc84 604:87f09469d337
1 /++
2 Author: Aziz Köksal
3 License: GPL3
4 +/
5 module dil.ast.Parameter;
6
7 import dil.ast.Node;
8 import dil.ast.Types;
9 import dil.ast.Expressions;
10 import dil.lexer.Identifier;
11 import dil.Enums;
12
13 class Parameter : Node
14 {
15 StorageClass stc;
16 TypeNode type;
17 Identifier* ident;
18 Expression defValue;
19
20 this(StorageClass stc, TypeNode type, Identifier* ident, Expression defValue)
21 {
22 super(NodeCategory.Other);
23 mixin(set_kind);
24 // type can be null when param in foreach statement
25 addOptChild(type);
26 addOptChild(defValue);
27
28 this.stc = stc;
29 this.type = type;
30 this.ident = ident;
31 this.defValue = defValue;
32 }
33
34 /// func(...) or func(int[] values ...)
35 bool isVariadic()
36 {
37 return !!(stc & StorageClass.Variadic);
38 }
39
40 /// func(...)
41 bool isOnlyVariadic()
42 {
43 return stc == StorageClass.Variadic &&
44 type is null && ident is null;
45 }
46 }
47
48 class Parameters : Node
49 {
50 this()
51 {
52 super(NodeCategory.Other);
53 mixin(set_kind);
54 }
55
56 bool hasVariadic()
57 {
58 if (children.length != 0)
59 return items[$-1].isVariadic();
60 return false;
61 }
62
63 void opCatAssign(Parameter param)
64 { addChild(param); }
65
66 Parameter[] items()
67 { return cast(Parameter[])children; }
68
69 size_t length()
70 { return children.length; }
71 }