annotate dmd/TypeAArray.d @ 14:2cc604139636

Implemented Linux support for ddmd. Some parts are a bit hacky to just "get it working", that said, druntime and phobos compile, and unittests pass.
author Robert Clipsham <robert@octarineparrot.com>
date Sun, 04 Apr 2010 02:06:32 +0100
parents 10317f0c89a5
children b7d29f613539
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1 module dmd.TypeAArray;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
3 import dmd.TypeArray;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
4 import dmd.MOD;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
5 import dmd.ArrayTypes;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
6 import dmd.TypeInfoDeclaration;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
7 import dmd.Expression;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
8 import dmd.Scope;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
9 import dmd.Loc;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
10 import dmd.Dsymbol;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
11 import dmd.Type;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
12 import dmd.TypeSArray;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
13 import dmd.OutBuffer;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
14 import dmd.HdrGenState;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
15 import dmd.Identifier;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
16 import dmd.MATCH;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
17 import dmd.TY;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
18 import dmd.Id;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
19 import dmd.CallExp;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
20 import dmd.IntegerExp;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
21 import dmd.FuncDeclaration;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
22 import dmd.VarExp;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
23 import dmd.TypeFunction;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
24 import dmd.NullExp;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
25 import dmd.Array;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
26
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
27 import dmd.backend.Symbol;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
28 import dmd.backend.TYPE;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
29 import dmd.backend.Util;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
30 import dmd.backend.SC;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
31 import dmd.backend.LIST;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
32 import dmd.backend.TYM;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
33 import dmd.backend.TF;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
34 import dmd.backend.mTYman;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
35
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
36 import core.stdc.stdio;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
37 import core.stdc.stdlib;
14
2cc604139636 Implemented Linux support for ddmd. Some parts are a bit hacky to just "get it working", that said, druntime and phobos compile, and unittests pass.
Robert Clipsham <robert@octarineparrot.com>
parents: 0
diff changeset
38 version (Bug4054)
2cc604139636 Implemented Linux support for ddmd. Some parts are a bit hacky to just "get it working", that said, druntime and phobos compile, and unittests pass.
Robert Clipsham <robert@octarineparrot.com>
parents: 0
diff changeset
39 import core.memory;
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
40 class TypeAArray : TypeArray
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
41 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
42 Type index; // key type
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
43
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
44 this(Type t, Type index)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
45 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
46 super(Taarray, t);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
47 this.index = index;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
48 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
49
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
50 Type syntaxCopy()
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
51 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
52 assert(false);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
53 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
54
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
55 version (DumbClone) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
56 } else {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
57 Type clone()
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
58 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
59 assert(false);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
60 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
61 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
62 ulong size(Loc loc)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
63 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
64 return PTRSIZE /* * 2*/;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
65 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
66
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
67 Type semantic(Loc loc, Scope sc)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
68 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
69 //printf("TypeAArray::semantic() %s index.ty = %d\n", toChars(), index.ty);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
70
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
71 // Deal with the case where we thought the index was a type, but
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
72 // in reality it was an expression.
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
73 if (index.ty == Tident || index.ty == Tinstance || index.ty == Tsarray)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
74 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
75 Expression e;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
76 Type t;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
77 Dsymbol s;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
78
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
79 index.resolve(loc, sc, &e, &t, &s);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
80 if (e)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
81 { // It was an expression -
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
82 // Rewrite as a static array
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
83 TypeSArray tsa = new TypeSArray(next, e);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
84 return tsa.semantic(loc,sc);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
85 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
86 else if (t)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
87 index = t;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
88 else
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
89 index.error(loc, "index is not a type or an expression");
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
90 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
91 else
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
92 index = index.semantic(loc,sc);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
93
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
94 if (index.nextOf() && !index.nextOf().isInvariant())
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
95 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
96 index = index.constOf().mutableOf();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
97 static if (false) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
98 printf("index is %p %s\n", index, index.toChars());
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
99 index.check();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
100 printf("index.mod = x%x\n", index.mod);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
101 printf("index.ito = x%x\n", index.ito);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
102 if (index.ito) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
103 printf("index.ito.mod = x%x\n", index.ito.mod);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
104 printf("index.ito.ito = x%x\n", index.ito.ito);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
105 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
106 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
107 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
108
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
109 switch (index.toBasetype().ty)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
110 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
111 case Tbool:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
112 case Tfunction:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
113 case Tvoid:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
114 case Tnone:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
115 error(loc, "can't have associative array key of %s", index.toBasetype().toChars());
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
116 break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
117 default:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
118 break; ///
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
119 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
120 next = next.semantic(loc,sc);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
121 transitive();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
122
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
123 switch (next.toBasetype().ty)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
124 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
125 case Tfunction:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
126 case Tnone:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
127 error(loc, "can't have associative array of %s", next.toChars());
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
128 break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
129 default:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
130 break; ///
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
131 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
132 if (next.isauto())
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
133 error(loc, "cannot have array of auto %s", next.toChars());
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
134
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
135 return merge();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
136 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
137
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
138 void resolve(Loc loc, Scope sc, Expression* pe, Type* pt, Dsymbol* ps)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
139 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
140 assert(false);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
141 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
142
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
143 void toDecoBuffer(OutBuffer buf, int flag)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
144 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
145 Type.toDecoBuffer(buf, flag);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
146 index.toDecoBuffer(buf);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
147 next.toDecoBuffer(buf, (flag & 0x100) ? MOD.MODundefined : mod);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
148 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
149
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
150 void toCBuffer2(OutBuffer buf, HdrGenState* hgs, MOD mod)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
151 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
152 assert(false);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
153 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
154
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
155 Expression dotExp(Scope sc, Expression e, Identifier ident)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
156 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
157 version (LOGDOTEXP) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
158 printf("TypeAArray.dotExp(e = '%s', ident = '%s')\n", e.toChars(), ident.toChars());
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
159 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
160 if (ident == Id.length)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
161 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
162 Expression ec;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
163 FuncDeclaration fd;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
164 Expressions arguments;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
165
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
166 fd = FuncDeclaration.genCfunc(Type.tsize_t, Id.aaLen);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
167 ec = new VarExp(Loc(0), fd);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
168 arguments = new Expressions();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
169 arguments.push(cast(void*)e);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
170 e = new CallExp(e.loc, ec, arguments);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
171 e.type = (cast(TypeFunction)fd.type).next;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
172 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
173 else if (ident == Id.keys)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
174 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
175 Expression ec;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
176 FuncDeclaration fd;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
177 Expressions arguments;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
178 int size = cast(int)index.size(e.loc);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
179
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
180 assert(size);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
181 fd = FuncDeclaration.genCfunc(Type.tindex, Id.aaKeys);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
182 ec = new VarExp(Loc(0), fd);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
183 arguments = new Expressions();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
184 arguments.push(cast(void*)e);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
185 arguments.push(cast(void*)new IntegerExp(Loc(0), size, Type.tsize_t));
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
186 e = new CallExp(e.loc, ec, arguments);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
187 e.type = index.arrayOf();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
188 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
189 else if (ident == Id.values)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
190 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
191 Expression ec;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
192 FuncDeclaration fd;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
193 Expressions arguments;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
194
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
195 fd = FuncDeclaration.genCfunc(Type.tindex, Id.aaValues);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
196 ec = new VarExp(Loc(0), fd);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
197 arguments = new Expressions();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
198 arguments.push(cast(void*)e);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
199 size_t keysize = cast(size_t)index.size(e.loc);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
200 keysize = (keysize + PTRSIZE - 1) & ~(PTRSIZE - 1);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
201 arguments.push(cast(void*)new IntegerExp(Loc(0), keysize, Type.tsize_t));
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
202 arguments.push(cast(void*)new IntegerExp(Loc(0), next.size(e.loc), Type.tsize_t));
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
203 e = new CallExp(e.loc, ec, arguments);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
204 e.type = next.arrayOf();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
205 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
206 else if (ident == Id.rehash)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
207 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
208 Expression ec;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
209 FuncDeclaration fd;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
210 Expressions arguments;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
211
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
212 fd = FuncDeclaration.genCfunc(Type.tint64, Id.aaRehash);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
213 ec = new VarExp(Loc(0), fd);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
214 arguments = new Expressions();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
215 arguments.push(cast(void*)e.addressOf(sc));
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
216 arguments.push(cast(void*)index.getInternalTypeInfo(sc));
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
217 e = new CallExp(e.loc, ec, arguments);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
218 e.type = this;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
219 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
220 else
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
221 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
222 e = Type.dotExp(sc, e, ident);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
223 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
224 return e;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
225 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
226
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
227 Expression defaultInit(Loc loc)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
228 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
229 version (LOGDEFAULTINIT) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
230 printf("TypeAArray.defaultInit() '%s'\n", toChars());
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
231 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
232 Expression e = new NullExp(loc);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
233 e.type = this;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
234 return e;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
235 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
236
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
237 MATCH deduceType(Scope sc, Type tparam, TemplateParameters parameters, Objects dedtypes)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
238 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
239 assert(false);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
240 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
241
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
242 bool isZeroInit(Loc loc)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
243 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
244 assert(false);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
245 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
246
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
247 bool checkBoolean()
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
248 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
249 assert(false);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
250 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
251
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
252 TypeInfoDeclaration getTypeInfoDeclaration()
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
253 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
254 assert(false);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
255 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
256
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
257 bool hasPointers()
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
258 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
259 return true;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
260 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
261
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
262 MATCH implicitConvTo(Type to)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
263 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
264 assert(false);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
265 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
266
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
267 MATCH constConv(Type to)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
268 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
269 assert(false);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
270 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
271
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
272 version (CPP_MANGLE) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
273 void toCppMangle(OutBuffer buf, CppMangleState* cms)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
274 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
275 assert(false);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
276 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
277 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
278
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
279 // Back end
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
280 /********************************************
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
281 * Determine the right symbol to look up
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
282 * an associative array element.
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
283 * Input:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
284 * flags 0 don't add value signature
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
285 * 1 add value signature
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
286 */
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
287 Symbol* aaGetSymbol(const(char)* func, int flags)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
288 in
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
289 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
290 assert(func);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
291 assert((flags & ~1) == 0);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
292 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
293 out (result)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
294 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
295 assert(result);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
296 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
297 body
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
298 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
299 int sz;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
300 char* id;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
301 type* t;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
302 Symbol* s;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
303 int i;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
304
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
305 // Dumb linear symbol table - should use associative array!
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
306 static Array sarray = null;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
307
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
308 //printf("aaGetSymbol(func = '%s', flags = %d, key = %p)\n", func, flags, key);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
309 static if (false) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
310 scope OutBuffer buf = new OutBuffer();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
311 key.toKeyBuffer(buf);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
312
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
313 sz = next.size(); // it's just data, so we only care about the size
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
314 sz = (sz + 3) & ~3; // reduce proliferation of library routines
14
2cc604139636 Implemented Linux support for ddmd. Some parts are a bit hacky to just "get it working", that said, druntime and phobos compile, and unittests pass.
Robert Clipsham <robert@octarineparrot.com>
parents: 0
diff changeset
315 version (Bug4054)
2cc604139636 Implemented Linux support for ddmd. Some parts are a bit hacky to just "get it working", that said, druntime and phobos compile, and unittests pass.
Robert Clipsham <robert@octarineparrot.com>
parents: 0
diff changeset
316 id = cast(char*)GC.malloc(3 + strlen(func) + buf.offset + sizeof(sz) * 3 + 1);
2cc604139636 Implemented Linux support for ddmd. Some parts are a bit hacky to just "get it working", that said, druntime and phobos compile, and unittests pass.
Robert Clipsham <robert@octarineparrot.com>
parents: 0
diff changeset
317 else
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
318 id = cast(char*)alloca(3 + strlen(func) + buf.offset + sizeof(sz) * 3 + 1);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
319 buf.writeByte(0);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
320 if (flags & 1)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
321 sprintf(id, "_aa%s%s%d", func, buf.data, sz);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
322 else
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
323 sprintf(id, "_aa%s%s", func, buf.data);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
324 } else {
14
2cc604139636 Implemented Linux support for ddmd. Some parts are a bit hacky to just "get it working", that said, druntime and phobos compile, and unittests pass.
Robert Clipsham <robert@octarineparrot.com>
parents: 0
diff changeset
325 version (Bug4054)
2cc604139636 Implemented Linux support for ddmd. Some parts are a bit hacky to just "get it working", that said, druntime and phobos compile, and unittests pass.
Robert Clipsham <robert@octarineparrot.com>
parents: 0
diff changeset
326 id = cast(char*)GC.malloc(3 + strlen(func) + 1);
2cc604139636 Implemented Linux support for ddmd. Some parts are a bit hacky to just "get it working", that said, druntime and phobos compile, and unittests pass.
Robert Clipsham <robert@octarineparrot.com>
parents: 0
diff changeset
327 else
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
328 id = cast(char*)alloca(3 + strlen(func) + 1);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
329 sprintf(id, "_aa%s", func);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
330 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
331 if (!sarray)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
332 sarray = new Array();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
333
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
334 // See if symbol is already in sarray
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
335 for (i = 0; i < sarray.dim; i++)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
336 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
337 s = cast(Symbol*)sarray.data[i];
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
338 if (strcmp(id, s.Sident.ptr) == 0)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
339 return s; // use existing Symbol
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
340 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
341
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
342 // Create new Symbol
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
343
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
344 s = symbol_calloc(id);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
345 slist_add(s);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
346 s.Sclass = SCextern;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
347 s.Ssymnum = -1;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
348 symbol_func(s);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
349
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
350 t = type_alloc(TYnfunc);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
351 t.Tflags = TFprototype | TFfixed;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
352 t.Tmangle = mTYman_c;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
353 t.Tparamtypes = null;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
354 t.Tnext = next.toCtype();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
355 t.Tnext.Tcount++;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
356 t.Tcount++;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
357 s.Stype = t;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
358
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
359 sarray.push(s); // remember it
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
360 return s;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
361 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
362
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
363 type* toCtype()
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
364 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
365 assert(false);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
366 }
14
2cc604139636 Implemented Linux support for ddmd. Some parts are a bit hacky to just "get it working", that said, druntime and phobos compile, and unittests pass.
Robert Clipsham <robert@octarineparrot.com>
parents: 0
diff changeset
367 }