Makefile.in: host_alias to host
[delight/core.git] / dmd2 / init.h
blobfa1c05e18f7df54d31be03ac10efb773eb2662c1
2 // Compiler implementation of the D programming language
3 // Copyright (c) 1999-2007 by Digital Mars
4 // All Rights Reserved
5 // written by Walter Bright
6 // http://www.digitalmars.com
7 // License for redistribution is by either the Artistic License
8 // in artistic.txt, or the GNU General Public License in gnu.txt.
9 // See the included readme.txt for details.
11 #ifndef INIT_H
12 #define INIT_H
14 #include "root.h"
16 #include "mars.h"
17 #include "arraytypes.h"
19 struct Identifier;
20 struct Expression;
21 struct Scope;
22 struct Type;
23 struct dt_t;
24 struct AggregateDeclaration;
25 struct VoidInitializer;
26 struct StructInitializer;
27 struct ArrayInitializer;
28 struct ExpInitializer;
29 #ifdef _DH
30 struct HdrGenState;
31 #endif
33 struct Initializer : Object
35 Loc loc;
37 Initializer(Loc loc);
38 virtual Initializer *syntaxCopy();
39 virtual Initializer *semantic(Scope *sc, Type *t);
40 virtual Type *inferType(Scope *sc);
41 virtual Expression *toExpression() = 0;
42 virtual void toCBuffer(OutBuffer *buf, HdrGenState *hgs) = 0;
43 char *toChars();
45 static Initializers *arraySyntaxCopy(Initializers *ai);
47 virtual dt_t *toDt();
49 virtual VoidInitializer *isVoidInitializer() { return NULL; }
50 virtual StructInitializer *isStructInitializer() { return NULL; }
51 virtual ArrayInitializer *isArrayInitializer() { return NULL; }
52 virtual ExpInitializer *isExpInitializer() { return NULL; }
55 struct VoidInitializer : Initializer
57 Type *type; // type that this will initialize to
59 VoidInitializer(Loc loc);
60 Initializer *syntaxCopy();
61 Initializer *semantic(Scope *sc, Type *t);
62 Expression *toExpression();
63 void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
65 dt_t *toDt();
67 virtual VoidInitializer *isVoidInitializer() { return this; }
70 struct StructInitializer : Initializer
72 Identifiers field; // of Identifier *'s
73 Initializers value; // parallel array of Initializer *'s
75 Array vars; // parallel array of VarDeclaration *'s
76 AggregateDeclaration *ad; // which aggregate this is for
78 StructInitializer(Loc loc);
79 Initializer *syntaxCopy();
80 void addInit(Identifier *field, Initializer *value);
81 Initializer *semantic(Scope *sc, Type *t);
82 Expression *toExpression();
83 void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
85 dt_t *toDt();
87 StructInitializer *isStructInitializer() { return this; }
90 struct ArrayInitializer : Initializer
92 Expressions index; // indices
93 Initializers value; // of Initializer *'s
94 target_size_t dim; // length of array being initialized
95 Type *type; // type that array will be used to initialize
96 int sem; // !=0 if semantic() is run
98 ArrayInitializer(Loc loc);
99 Initializer *syntaxCopy();
100 void addInit(Expression *index, Initializer *value);
101 Initializer *semantic(Scope *sc, Type *t);
102 Type *inferType(Scope *sc);
103 Expression *toExpression();
104 Initializer *toAssocArrayInitializer();
105 void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
107 dt_t *toDt();
108 dt_t *toDtBit(); // for bit arrays
110 ArrayInitializer *isArrayInitializer() { return this; }
113 struct ExpInitializer : Initializer
115 Expression *exp;
117 ExpInitializer(Loc loc, Expression *exp);
118 Initializer *syntaxCopy();
119 Initializer *semantic(Scope *sc, Type *t);
120 Type *inferType(Scope *sc);
121 Expression *toExpression();
122 void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
124 dt_t *toDt();
126 virtual ExpInitializer *isExpInitializer() { return this; }
129 #endif