1 module d.ast.conditional;
2 
3 import d.ast.declaration;
4 import d.ast.expression;
5 import d.ast.statement;
6 
7 import source.location;
8 
9 final:
10 
11 /**
12  * Version Conditional
13  */
14 class Version(ItemType) : ItemType
15 		if (is(ItemType == Statement) || is(ItemType == Declaration)) {
16 	import source.name;
17 	Name versionId;
18 
19 	ItemType[] items;
20 	ItemType[] elseItems;
21 
22 	this(Location location, Name versionId, ItemType[] items,
23 	     ItemType[] elseItems) {
24 		super(location);
25 
26 		this.versionId = versionId;
27 		this.items = items;
28 		this.elseItems = elseItems;
29 	}
30 }
31 
32 alias VersionDeclaration = Version!Declaration;
33 
34 /**
35  * Version definition (ie version = FOOBAR)
36  */
37 class VersionDefinition(ItemType) : ItemType
38 		if (is(ItemType == Statement) || is(ItemType == Declaration)) {
39 	import source.name;
40 	Name versionId;
41 
42 	this(Location location, Name versionId) {
43 		super(location);
44 
45 		this.versionId = versionId;
46 	}
47 }
48 
49 alias VersionDefinitionDeclaration = VersionDefinition!Declaration;
50 
51 /**
52  * Debug ast alias
53  */
54 alias Debug = Version;
55 alias DebugDefinition = VersionDefinition;
56 
57 /**
58  * Static if Conditional
59  */
60 class StaticIf(ItemType) : ItemType
61 		if (is(ItemType == Statement) || is(ItemType == Declaration)) {
62 	AstExpression condition;
63 	ItemType[] items;
64 	ItemType[] elseItems;
65 
66 	this(Location location, AstExpression condition, ItemType[] items,
67 	     ItemType[] elseItems) {
68 		super(location);
69 
70 		this.condition = condition;
71 		this.items = items;
72 		this.elseItems = elseItems;
73 	}
74 }
75 
76 alias StaticIfDeclaration = StaticIf!Declaration;
77 
78 /**
79  * Mixins
80  */
81 class Mixin(ItemType) : ItemType if (is(ItemType == Statement)
82 	                                     || is(ItemType == Declaration)
83 	                                     || is(ItemType == AstExpression)) {
84 	AstExpression value;
85 
86 	this(Location location, AstExpression value) {
87 		super(location);
88 
89 		this.value = value;
90 	}
91 }
92 
93 alias MixinDeclaration = Mixin!Declaration;
94 
95 /**
96  * Static assert
97  */
98 class StaticAssert(ItemType) : ItemType
99 		if (is(ItemType == Statement) || is(ItemType == Declaration)) {
100 	AstExpression condition;
101 	AstExpression message;
102 
103 	this(Location location, AstExpression condition, AstExpression message) {
104 		super(location);
105 
106 		this.condition = condition;
107 		this.message = message;
108 	}
109 }