comparison dmd2/mtype.h @ 1452:638d16625da2

LDC 2 compiles again.
author Robert Clipsham <robert@octarineparrot.com>
date Sat, 30 May 2009 17:23:32 +0100
parents 4d366a75d95f
children 54b3c1394d62
comparison
equal deleted inserted replaced
1423:42bd767ec5a4 1452:638d16625da2
19 #include "stringtable.h" 19 #include "stringtable.h"
20 20
21 #include "arraytypes.h" 21 #include "arraytypes.h"
22 #include "expression.h" 22 #include "expression.h"
23 23
24 // llvm 24 #if IN_LLVM
25 #include "../ir/irtype.h" 25 #include "../ir/irfuncty.h"
26 namespace llvm { class Type; } 26 namespace llvm { class Type; }
27 struct IrFuncTy; 27 class Ir;
28 class IrType;
29 #endif
28 30
29 struct Scope; 31 struct Scope;
30 struct Identifier; 32 struct Identifier;
31 struct Expression; 33 struct Expression;
32 struct StructDeclaration; 34 struct StructDeclaration;
46 48
47 // Back end 49 // Back end
48 #if IN_GCC 50 #if IN_GCC
49 union tree_node; typedef union tree_node TYPE; 51 union tree_node; typedef union tree_node TYPE;
50 typedef TYPE type; 52 typedef TYPE type;
51 #else 53 #endif
54
55 #if IN_DMD
52 typedef struct TYPE type; 56 typedef struct TYPE type;
53 #endif
54 struct Symbol; 57 struct Symbol;
58 #endif
59
55 60
56 enum ENUMTY 61 enum ENUMTY
57 { 62 {
58 Tarray, // dynamic array 63 Tarray, // dynamic array
59 Tsarray, // static array 64 Tsarray, // static array
114 119
115 struct Type : Object 120 struct Type : Object
116 { 121 {
117 TY ty; 122 TY ty;
118 unsigned char mod; // modifiers MODxxxx 123 unsigned char mod; // modifiers MODxxxx
124 /* pick this order of numbers so switch statements work better
125 */
119 #define MODconst 1 // type is const 126 #define MODconst 1 // type is const
120 #define MODinvariant 2 // type is invariant 127 #define MODinvariant 4 // type is invariant
121 #define MODshared 4 // type is shared 128 #define MODshared 2 // type is shared
122 char *deco; 129 char *deco;
130
131 /* Note that there is no "shared immutable", because that is just immutable
132 */
133
123 Type *cto; // MODconst ? mutable version of this type : const version 134 Type *cto; // MODconst ? mutable version of this type : const version
124 Type *ito; // MODinvariant ? mutable version of this type : invariant version 135 Type *ito; // MODinvariant ? mutable version of this type : invariant version
136 Type *sto; // MODshared ? mutable version of this type : shared mutable version
137 Type *scto; // MODshared|MODconst ? mutable version of this type : shared const version
138
125 Type *pto; // merged pointer to this type 139 Type *pto; // merged pointer to this type
126 Type *rto; // reference to this type 140 Type *rto; // reference to this type
127 Type *arrayof; // array of this type 141 Type *arrayof; // array of this type
128 TypeInfoDeclaration *vtinfo; // TypeInfo object for this Type 142 TypeInfoDeclaration *vtinfo; // TypeInfo object for this Type
129 143
144 #if IN_DMD
130 type *ctype; // for back end 145 type *ctype; // for back end
146 #endif
131 147
132 #define tvoid basic[Tvoid] 148 #define tvoid basic[Tvoid]
133 #define tint8 basic[Tint8] 149 #define tint8 basic[Tint8]
134 #define tuns8 basic[Tuns8] 150 #define tuns8 basic[Tuns8]
135 #define tint16 basic[Tint16] 151 #define tint16 basic[Tint16]
181 static ClassDeclaration *typeinfofunction; 197 static ClassDeclaration *typeinfofunction;
182 static ClassDeclaration *typeinfodelegate; 198 static ClassDeclaration *typeinfodelegate;
183 static ClassDeclaration *typeinfotypelist; 199 static ClassDeclaration *typeinfotypelist;
184 static ClassDeclaration *typeinfoconst; 200 static ClassDeclaration *typeinfoconst;
185 static ClassDeclaration *typeinfoinvariant; 201 static ClassDeclaration *typeinfoinvariant;
202 static ClassDeclaration *typeinfoshared;
186 203
187 static Type *basic[TMAX]; 204 static Type *basic[TMAX];
188 static unsigned char mangleChar[TMAX]; 205 static unsigned char mangleChar[TMAX];
189 static unsigned char sizeTy[TMAX]; 206 static unsigned char sizeTy[TMAX];
190 static StringTable stringtable; 207 static StringTable stringtable;
208 #if IN_LLVM
209 static StringTable deco_stringtable;
210 #endif
191 211
192 // These tables are for implicit conversion of binary ops; 212 // These tables are for implicit conversion of binary ops;
193 // the indices are the type of operand one, followed by operand two. 213 // the indices are the type of operand one, followed by operand two.
194 static unsigned char impcnvResult[TMAX][TMAX]; 214 static unsigned char impcnvResult[TMAX][TMAX];
195 static unsigned char impcnvType1[TMAX][TMAX]; 215 static unsigned char impcnvType1[TMAX][TMAX];
203 int equals(Object *o); 223 int equals(Object *o);
204 int dyncast() { return DYNCAST_TYPE; } // kludge for template.isType() 224 int dyncast() { return DYNCAST_TYPE; } // kludge for template.isType()
205 int covariant(Type *t); 225 int covariant(Type *t);
206 char *toChars(); 226 char *toChars();
207 static char needThisPrefix(); 227 static char needThisPrefix();
228 #if IN_LLVM
229 static void init(Ir*);
230 #else
208 static void init(); 231 static void init();
232 #endif
209 d_uns64 size(); 233 d_uns64 size();
210 virtual d_uns64 size(Loc loc); 234 virtual d_uns64 size(Loc loc);
211 virtual unsigned alignsize(); 235 virtual unsigned alignsize();
212 virtual Type *semantic(Loc loc, Scope *sc); 236 virtual Type *semantic(Loc loc, Scope *sc);
213 virtual void toDecoBuffer(OutBuffer *buf, int flag = 0); 237 Type *trySemantic(Loc loc, Scope *sc);
238 // append the mangleof or a string uniquely identifying this type to buf
239 virtual void toDecoBuffer(OutBuffer *buf, int flag = 0, bool mangle=false);
214 Type *merge(); 240 Type *merge();
241 Type *merge2();
215 virtual void toCBuffer(OutBuffer *buf, Identifier *ident, HdrGenState *hgs); 242 virtual void toCBuffer(OutBuffer *buf, Identifier *ident, HdrGenState *hgs);
216 virtual void toCBuffer2(OutBuffer *buf, HdrGenState *hgs, int mod); 243 virtual void toCBuffer2(OutBuffer *buf, HdrGenState *hgs, int mod);
217 void toCBuffer3(OutBuffer *buf, HdrGenState *hgs, int mod); 244 void toCBuffer3(OutBuffer *buf, HdrGenState *hgs, int mod);
218 #if TARGET_LINUX 245 #if POSIX
219 virtual void toCppMangle(OutBuffer *buf, CppMangleState *cms); 246 virtual void toCppMangle(OutBuffer *buf, CppMangleState *cms);
220 #endif 247 #endif
221 virtual int isintegral(); 248 virtual int isintegral();
222 virtual int isfloating(); // real, imaginary, or complex 249 virtual int isfloating(); // real, imaginary, or complex
223 virtual int isreal(); 250 virtual int isreal();
232 virtual void checkDeprecated(Loc loc, Scope *sc); 259 virtual void checkDeprecated(Loc loc, Scope *sc);
233 int isConst() { return mod & MODconst; } 260 int isConst() { return mod & MODconst; }
234 int isInvariant() { return mod & MODinvariant; } 261 int isInvariant() { return mod & MODinvariant; }
235 int isMutable() { return !(mod & (MODconst | MODinvariant)); } 262 int isMutable() { return !(mod & (MODconst | MODinvariant)); }
236 int isShared() { return mod & MODshared; } 263 int isShared() { return mod & MODshared; }
264 int isSharedConst() { return mod == (MODshared | MODconst); }
237 Type *constOf(); 265 Type *constOf();
238 Type *invariantOf(); 266 Type *invariantOf();
239 Type *mutableOf(); 267 Type *mutableOf();
268 Type *sharedOf();
269 Type *sharedConstOf();
270 void fixTo(Type *t);
271 void check();
272 Type *castMod(unsigned mod);
273 Type *addMod(unsigned mod);
274 Type *addStorageClass(unsigned stc);
240 Type *pointerTo(); 275 Type *pointerTo();
241 Type *referenceTo(); 276 Type *referenceTo();
242 Type *arrayOf(); 277 Type *arrayOf();
243 virtual Type *makeConst(); 278 virtual Type *makeConst();
244 virtual Type *makeInvariant(); 279 virtual Type *makeInvariant();
280 virtual Type *makeShared();
281 virtual Type *makeSharedConst();
245 virtual Dsymbol *toDsymbol(Scope *sc); 282 virtual Dsymbol *toDsymbol(Scope *sc);
246 virtual Type *toBasetype(); 283 virtual Type *toBasetype();
247 virtual Type *toHeadMutable(); 284 virtual Type *toHeadMutable();
248 virtual int isBaseOf(Type *t, int *poffset); 285 virtual int isBaseOf(Type *t, int *poffset);
249 virtual MATCH constConv(Type *to); 286 virtual MATCH constConv(Type *to);
251 virtual ClassDeclaration *isClassHandle(); 288 virtual ClassDeclaration *isClassHandle();
252 virtual Expression *getProperty(Loc loc, Identifier *ident); 289 virtual Expression *getProperty(Loc loc, Identifier *ident);
253 virtual Expression *dotExp(Scope *sc, Expression *e, Identifier *ident); 290 virtual Expression *dotExp(Scope *sc, Expression *e, Identifier *ident);
254 virtual unsigned memalign(unsigned salign); 291 virtual unsigned memalign(unsigned salign);
255 virtual Expression *defaultInit(Loc loc = 0); 292 virtual Expression *defaultInit(Loc loc = 0);
256 virtual int isZeroInit(); // if initializer is 0 293 virtual int isZeroInit(Loc loc = 0); // if initializer is 0
294 #if IN_DMD
257 virtual dt_t **toDt(dt_t **pdt); 295 virtual dt_t **toDt(dt_t **pdt);
296 #endif
258 Identifier *getTypeInfoIdent(int internal); 297 Identifier *getTypeInfoIdent(int internal);
259 virtual MATCH deduceType(Scope *sc, Type *tparam, TemplateParameters *parameters, Objects *dedtypes); 298 virtual MATCH deduceType(Scope *sc, Type *tparam, TemplateParameters *parameters, Objects *dedtypes);
260 virtual void resolve(Loc loc, Scope *sc, Expression **pe, Type **pt, Dsymbol **ps); 299 virtual void resolve(Loc loc, Scope *sc, Expression **pe, Type **pt, Dsymbol **ps);
261 Expression *getInternalTypeInfo(Scope *sc); 300 Expression *getInternalTypeInfo(Scope *sc);
262 Expression *getTypeInfo(Scope *sc); 301 Expression *getTypeInfo(Scope *sc);
263 virtual TypeInfoDeclaration *getTypeInfoDeclaration(); 302 virtual TypeInfoDeclaration *getTypeInfoDeclaration();
264 virtual int builtinTypeInfo(); 303 virtual int builtinTypeInfo();
265 virtual Type *reliesOnTident(); 304 virtual Type *reliesOnTident();
266 virtual Expression *toExpression(); 305 virtual Expression *toExpression();
267 virtual int hasPointers(); 306 virtual int hasPointers();
307 //Type *next;
268 virtual Type *nextOf(); 308 virtual Type *nextOf();
269 309
270 static void error(Loc loc, const char *format, ...); 310 static void error(Loc loc, const char *format, ...) IS_PRINTF(2);
271 311 static void warning(Loc loc, const char *format, ...) IS_PRINTF(2);
312
313 #if IN_DMD
272 // For backend 314 // For backend
273 virtual unsigned totym(); 315 virtual unsigned totym();
274 virtual type *toCtype(); 316 virtual type *toCtype();
275 virtual type *toCParamtype(); 317 virtual type *toCParamtype();
276 virtual Symbol *toSymbol(); 318 virtual Symbol *toSymbol();
319 #endif
277 320
278 // For eliminating dynamic_cast 321 // For eliminating dynamic_cast
279 virtual TypeBasic *isTypeBasic(); 322 virtual TypeBasic *isTypeBasic();
280 323
281 // LDC 324 #if IN_LLVM
282 IrType ir; 325 static Ir* sir;
326 IrType* irtype;
327 #endif
283 }; 328 };
284 329
285 struct TypeNext : Type 330 struct TypeNext : Type
286 { 331 {
287 Type *next; 332 Type *next;
288 333
289 TypeNext(TY ty, Type *next); 334 TypeNext(TY ty, Type *next);
290 void toDecoBuffer(OutBuffer *buf, int flag); 335 void toDecoBuffer(OutBuffer *buf, int flag, bool mangle);
291 void checkDeprecated(Loc loc, Scope *sc); 336 void checkDeprecated(Loc loc, Scope *sc);
292 Type *reliesOnTident(); 337 Type *reliesOnTident();
293 Type *nextOf(); 338 Type *nextOf();
294 Type *makeConst(); 339 Type *makeConst();
295 Type *makeInvariant(); 340 Type *makeInvariant();
341 Type *makeShared();
342 Type *makeSharedConst();
296 MATCH constConv(Type *to); 343 MATCH constConv(Type *to);
344 void transitive();
297 }; 345 };
298 346
299 struct TypeBasic : Type 347 struct TypeBasic : Type
300 { 348 {
301 const char *dstring; 349 const char *dstring;
307 unsigned alignsize(); 355 unsigned alignsize();
308 Expression *getProperty(Loc loc, Identifier *ident); 356 Expression *getProperty(Loc loc, Identifier *ident);
309 Expression *dotExp(Scope *sc, Expression *e, Identifier *ident); 357 Expression *dotExp(Scope *sc, Expression *e, Identifier *ident);
310 char *toChars(); 358 char *toChars();
311 void toCBuffer2(OutBuffer *buf, HdrGenState *hgs, int mod); 359 void toCBuffer2(OutBuffer *buf, HdrGenState *hgs, int mod);
312 #if TARGET_LINUX 360 #if POSIX
313 void toCppMangle(OutBuffer *buf, CppMangleState *cms); 361 void toCppMangle(OutBuffer *buf, CppMangleState *cms);
314 #endif 362 #endif
315 int isintegral(); 363 int isintegral();
316 int isbit(); 364 int isbit();
317 int isfloating(); 365 int isfloating();
320 int iscomplex(); 368 int iscomplex();
321 int isscalar(); 369 int isscalar();
322 int isunsigned(); 370 int isunsigned();
323 MATCH implicitConvTo(Type *to); 371 MATCH implicitConvTo(Type *to);
324 Expression *defaultInit(Loc loc); 372 Expression *defaultInit(Loc loc);
325 int isZeroInit(); 373 int isZeroInit(Loc loc);
326 int builtinTypeInfo(); 374 int builtinTypeInfo();
327 375
328 // For eliminating dynamic_cast 376 // For eliminating dynamic_cast
329 TypeBasic *isTypeBasic(); 377 TypeBasic *isTypeBasic();
330 }; 378 };
344 Type *syntaxCopy(); 392 Type *syntaxCopy();
345 d_uns64 size(Loc loc); 393 d_uns64 size(Loc loc);
346 unsigned alignsize(); 394 unsigned alignsize();
347 Type *semantic(Loc loc, Scope *sc); 395 Type *semantic(Loc loc, Scope *sc);
348 void resolve(Loc loc, Scope *sc, Expression **pe, Type **pt, Dsymbol **ps); 396 void resolve(Loc loc, Scope *sc, Expression **pe, Type **pt, Dsymbol **ps);
349 void toDecoBuffer(OutBuffer *buf, int flag); 397 void toDecoBuffer(OutBuffer *buf, int flag, bool mangle);
350 void toCBuffer2(OutBuffer *buf, HdrGenState *hgs, int mod); 398 void toCBuffer2(OutBuffer *buf, HdrGenState *hgs, int mod);
351 Expression *dotExp(Scope *sc, Expression *e, Identifier *ident); 399 Expression *dotExp(Scope *sc, Expression *e, Identifier *ident);
352 int isString(); 400 int isString();
353 int isZeroInit(); 401 int isZeroInit(Loc loc);
354 unsigned memalign(unsigned salign); 402 unsigned memalign(unsigned salign);
355 MATCH constConv(Type *to); 403 MATCH constConv(Type *to);
356 MATCH implicitConvTo(Type *to); 404 MATCH implicitConvTo(Type *to);
357 Expression *defaultInit(Loc loc); 405 Expression *defaultInit(Loc loc);
406 #if IN_DMD
358 dt_t **toDt(dt_t **pdt); 407 dt_t **toDt(dt_t **pdt);
359 dt_t **toDtElem(dt_t **pdt, Expression *e); 408 dt_t **toDtElem(dt_t **pdt, Expression *e);
409 #endif
360 MATCH deduceType(Scope *sc, Type *tparam, TemplateParameters *parameters, Objects *dedtypes); 410 MATCH deduceType(Scope *sc, Type *tparam, TemplateParameters *parameters, Objects *dedtypes);
361 TypeInfoDeclaration *getTypeInfoDeclaration(); 411 TypeInfoDeclaration *getTypeInfoDeclaration();
362 Expression *toExpression(); 412 Expression *toExpression();
363 int hasPointers(); 413 int hasPointers();
364 #if TARGET_LINUX 414 #if POSIX
365 void toCppMangle(OutBuffer *buf, CppMangleState *cms); 415 void toCppMangle(OutBuffer *buf, CppMangleState *cms);
366 #endif 416 #endif
367 417
418 #if IN_DMD
368 type *toCtype(); 419 type *toCtype();
369 type *toCParamtype(); 420 type *toCParamtype();
421 #endif
370 }; 422 };
371 423
372 // Dynamic array, no dimension 424 // Dynamic array, no dimension
373 struct TypeDArray : TypeArray 425 struct TypeDArray : TypeArray
374 { 426 {
375 TypeDArray(Type *t); 427 TypeDArray(Type *t);
376 Type *syntaxCopy(); 428 Type *syntaxCopy();
377 d_uns64 size(Loc loc); 429 d_uns64 size(Loc loc);
378 unsigned alignsize(); 430 unsigned alignsize();
379 Type *semantic(Loc loc, Scope *sc); 431 Type *semantic(Loc loc, Scope *sc);
380 void toDecoBuffer(OutBuffer *buf, int flag); 432 void toDecoBuffer(OutBuffer *buf, int flag, bool mangle);
381 void toCBuffer2(OutBuffer *buf, HdrGenState *hgs, int mod); 433 void toCBuffer2(OutBuffer *buf, HdrGenState *hgs, int mod);
382 Expression *dotExp(Scope *sc, Expression *e, Identifier *ident); 434 Expression *dotExp(Scope *sc, Expression *e, Identifier *ident);
383 int isString(); 435 int isString();
384 int isZeroInit(); 436 int isZeroInit(Loc loc);
385 int checkBoolean(); 437 int checkBoolean();
386 MATCH implicitConvTo(Type *to); 438 MATCH implicitConvTo(Type *to);
387 Expression *defaultInit(Loc loc); 439 Expression *defaultInit(Loc loc);
388 int builtinTypeInfo(); 440 int builtinTypeInfo();
441 MATCH deduceType(Scope *sc, Type *tparam, TemplateParameters *parameters, Objects *dedtypes);
389 TypeInfoDeclaration *getTypeInfoDeclaration(); 442 TypeInfoDeclaration *getTypeInfoDeclaration();
390 int hasPointers(); 443 int hasPointers();
391 #if TARGET_LINUX 444 #if POSIX
392 void toCppMangle(OutBuffer *buf, CppMangleState *cms); 445 void toCppMangle(OutBuffer *buf, CppMangleState *cms);
393 #endif 446 #endif
394 447
395 type *toCtype(); 448 #if IN_DMD
449 type *toCtype();
450 #endif
396 }; 451 };
397 452
398 struct TypeAArray : TypeArray 453 struct TypeAArray : TypeArray
399 { 454 {
400 Type *index; // key type 455 Type *index; // key type
402 TypeAArray(Type *t, Type *index); 457 TypeAArray(Type *t, Type *index);
403 Type *syntaxCopy(); 458 Type *syntaxCopy();
404 d_uns64 size(Loc loc); 459 d_uns64 size(Loc loc);
405 Type *semantic(Loc loc, Scope *sc); 460 Type *semantic(Loc loc, Scope *sc);
406 void resolve(Loc loc, Scope *sc, Expression **pe, Type **pt, Dsymbol **ps); 461 void resolve(Loc loc, Scope *sc, Expression **pe, Type **pt, Dsymbol **ps);
407 void toDecoBuffer(OutBuffer *buf, int flag); 462 void toDecoBuffer(OutBuffer *buf, int flag, bool mangle);
408 void toCBuffer2(OutBuffer *buf, HdrGenState *hgs, int mod); 463 void toCBuffer2(OutBuffer *buf, HdrGenState *hgs, int mod);
409 Expression *dotExp(Scope *sc, Expression *e, Identifier *ident); 464 Expression *dotExp(Scope *sc, Expression *e, Identifier *ident);
410 Expression *defaultInit(Loc loc); 465 Expression *defaultInit(Loc loc);
411 MATCH deduceType(Scope *sc, Type *tparam, TemplateParameters *parameters, Objects *dedtypes); 466 MATCH deduceType(Scope *sc, Type *tparam, TemplateParameters *parameters, Objects *dedtypes);
412 int isZeroInit(); 467 int isZeroInit(Loc loc);
413 int checkBoolean(); 468 int checkBoolean();
414 TypeInfoDeclaration *getTypeInfoDeclaration(); 469 TypeInfoDeclaration *getTypeInfoDeclaration();
415 int hasPointers(); 470 int hasPointers();
416 MATCH implicitConvTo(Type *to); 471 MATCH implicitConvTo(Type *to);
417 MATCH constConv(Type *to); 472 MATCH constConv(Type *to);
418 #if TARGET_LINUX 473 #if POSIX
419 void toCppMangle(OutBuffer *buf, CppMangleState *cms); 474 void toCppMangle(OutBuffer *buf, CppMangleState *cms);
420 #endif 475 #endif
421 476
477 #if IN_DMD
422 // Back end 478 // Back end
423 Symbol *aaGetSymbol(const char *func, int flags); 479 Symbol *aaGetSymbol(const char *func, int flags);
424 480
425 type *toCtype(); 481 type *toCtype();
482 #endif
426 }; 483 };
427 484
428 struct TypePointer : TypeNext 485 struct TypePointer : TypeNext
429 { 486 {
430 TypePointer(Type *t); 487 TypePointer(Type *t);
435 MATCH implicitConvTo(Type *to); 492 MATCH implicitConvTo(Type *to);
436 int isscalar(); 493 int isscalar();
437 // LDC: pointers are unsigned 494 // LDC: pointers are unsigned
438 int isunsigned() { return TRUE; }; 495 int isunsigned() { return TRUE; };
439 Expression *defaultInit(Loc loc); 496 Expression *defaultInit(Loc loc);
440 int isZeroInit(); 497 int isZeroInit(Loc loc);
441 TypeInfoDeclaration *getTypeInfoDeclaration(); 498 TypeInfoDeclaration *getTypeInfoDeclaration();
442 int hasPointers(); 499 int hasPointers();
443 #if TARGET_LINUX 500
444 void toCppMangle(OutBuffer *buf, CppMangleState *cms); 501 #if POSIX
445 #endif 502 void toCppMangle(OutBuffer *buf, CppMangleState *cms);
446 503 #endif
447 type *toCtype(); 504
505 #if IN_DMD
506 type *toCtype();
507 #endif
448 }; 508 };
449 509
450 struct TypeReference : TypeNext 510 struct TypeReference : TypeNext
451 { 511 {
452 TypeReference(Type *t); 512 TypeReference(Type *t);
454 Type *semantic(Loc loc, Scope *sc); 514 Type *semantic(Loc loc, Scope *sc);
455 d_uns64 size(Loc loc); 515 d_uns64 size(Loc loc);
456 void toCBuffer2(OutBuffer *buf, HdrGenState *hgs, int mod); 516 void toCBuffer2(OutBuffer *buf, HdrGenState *hgs, int mod);
457 Expression *dotExp(Scope *sc, Expression *e, Identifier *ident); 517 Expression *dotExp(Scope *sc, Expression *e, Identifier *ident);
458 Expression *defaultInit(Loc loc); 518 Expression *defaultInit(Loc loc);
459 int isZeroInit(); 519 int isZeroInit(Loc loc);
460 #if TARGET_LINUX 520 #if POSIX
461 void toCppMangle(OutBuffer *buf, CppMangleState *cms); 521 void toCppMangle(OutBuffer *buf, CppMangleState *cms);
462 #endif 522 #endif
463 }; 523 };
464 524
465 enum RET 525 enum RET
483 int inuse; 543 int inuse;
484 544
485 TypeFunction(Arguments *parameters, Type *treturn, int varargs, enum LINK linkage); 545 TypeFunction(Arguments *parameters, Type *treturn, int varargs, enum LINK linkage);
486 Type *syntaxCopy(); 546 Type *syntaxCopy();
487 Type *semantic(Loc loc, Scope *sc); 547 Type *semantic(Loc loc, Scope *sc);
488 void toDecoBuffer(OutBuffer *buf, int flag); 548 void toDecoBuffer(OutBuffer *buf, int flag, bool mangle);
489 void toCBuffer(OutBuffer *buf, Identifier *ident, HdrGenState *hgs); 549 void toCBuffer(OutBuffer *buf, Identifier *ident, HdrGenState *hgs);
490 void toCBuffer2(OutBuffer *buf, HdrGenState *hgs, int mod); 550 void toCBuffer2(OutBuffer *buf, HdrGenState *hgs, int mod);
491 MATCH deduceType(Scope *sc, Type *tparam, TemplateParameters *parameters, Objects *dedtypes); 551 MATCH deduceType(Scope *sc, Type *tparam, TemplateParameters *parameters, Objects *dedtypes);
492 TypeInfoDeclaration *getTypeInfoDeclaration(); 552 TypeInfoDeclaration *getTypeInfoDeclaration();
493 Type *reliesOnTident(); 553 Type *reliesOnTident();
494 #if TARGET_LINUX 554 #if POSIX
495 void toCppMangle(OutBuffer *buf, CppMangleState *cms); 555 void toCppMangle(OutBuffer *buf, CppMangleState *cms);
496 #endif 556 #endif
497 bool parameterEscapes(Argument *p); 557 bool parameterEscapes(Argument *p);
498 558
499 int callMatch(Expression *ethis, Expressions *toargs); 559 int callMatch(Expression *ethis, Expressions *toargs);
500 type *toCtype(); 560 #if IN_DMD
561 type *toCtype();
562 #endif
563
501 enum RET retStyle(); 564 enum RET retStyle();
502 565
566 #if IN_DMD
503 unsigned totym(); 567 unsigned totym();
504 568 #elif IN_LLVM
505 // LDC 569 // LDC
506 IrFuncTy* fty; 570 IrFuncTy fty;
571
572 FuncDeclaration* funcdecl;
573 #endif
507 }; 574 };
508 575
509 struct TypeDelegate : TypeNext 576 struct TypeDelegate : TypeNext
510 { 577 {
511 // .next is a TypeFunction 578 // .next is a TypeFunction
515 Type *semantic(Loc loc, Scope *sc); 582 Type *semantic(Loc loc, Scope *sc);
516 d_uns64 size(Loc loc); 583 d_uns64 size(Loc loc);
517 unsigned alignsize(); // added in LDC 584 unsigned alignsize(); // added in LDC
518 void toCBuffer2(OutBuffer *buf, HdrGenState *hgs, int mod); 585 void toCBuffer2(OutBuffer *buf, HdrGenState *hgs, int mod);
519 Expression *defaultInit(Loc loc); 586 Expression *defaultInit(Loc loc);
520 int isZeroInit(); 587 int isZeroInit(Loc loc);
521 int checkBoolean(); 588 int checkBoolean();
522 TypeInfoDeclaration *getTypeInfoDeclaration(); 589 TypeInfoDeclaration *getTypeInfoDeclaration();
523 Expression *dotExp(Scope *sc, Expression *e, Identifier *ident); 590 Expression *dotExp(Scope *sc, Expression *e, Identifier *ident);
524 int hasPointers(); 591 int hasPointers();
525 #if TARGET_LINUX 592 #if POSIX
526 void toCppMangle(OutBuffer *buf, CppMangleState *cms); 593 void toCppMangle(OutBuffer *buf, CppMangleState *cms);
527 #endif 594 #endif
528 595
529 type *toCtype(); 596 #if IN_DMD
597 type *toCtype();
598 #endif
530 }; 599 };
531 600
532 struct TypeQualified : Type 601 struct TypeQualified : Type
533 { 602 {
534 Loc loc; 603 Loc loc;
548 Identifier *ident; 617 Identifier *ident;
549 618
550 TypeIdentifier(Loc loc, Identifier *ident); 619 TypeIdentifier(Loc loc, Identifier *ident);
551 Type *syntaxCopy(); 620 Type *syntaxCopy();
552 //char *toChars(); 621 //char *toChars();
553 void toDecoBuffer(OutBuffer *buf, int flag); 622 void toDecoBuffer(OutBuffer *buf, int flag, bool mangle);
554 void toCBuffer2(OutBuffer *buf, HdrGenState *hgs, int mod); 623 void toCBuffer2(OutBuffer *buf, HdrGenState *hgs, int mod);
555 void resolve(Loc loc, Scope *sc, Expression **pe, Type **pt, Dsymbol **ps); 624 void resolve(Loc loc, Scope *sc, Expression **pe, Type **pt, Dsymbol **ps);
556 Dsymbol *toDsymbol(Scope *sc); 625 Dsymbol *toDsymbol(Scope *sc);
557 Type *semantic(Loc loc, Scope *sc); 626 Type *semantic(Loc loc, Scope *sc);
558 MATCH deduceType(Scope *sc, Type *tparam, TemplateParameters *parameters, Objects *dedtypes); 627 MATCH deduceType(Scope *sc, Type *tparam, TemplateParameters *parameters, Objects *dedtypes);
567 TemplateInstance *tempinst; 636 TemplateInstance *tempinst;
568 637
569 TypeInstance(Loc loc, TemplateInstance *tempinst); 638 TypeInstance(Loc loc, TemplateInstance *tempinst);
570 Type *syntaxCopy(); 639 Type *syntaxCopy();
571 //char *toChars(); 640 //char *toChars();
572 //void toDecoBuffer(OutBuffer *buf, int flag); 641 //void toDecoBuffer(OutBuffer *buf, int flag, bool mangle);
573 void toCBuffer2(OutBuffer *buf, HdrGenState *hgs, int mod); 642 void toCBuffer2(OutBuffer *buf, HdrGenState *hgs, int mod);
574 void resolve(Loc loc, Scope *sc, Expression **pe, Type **pt, Dsymbol **ps); 643 void resolve(Loc loc, Scope *sc, Expression **pe, Type **pt, Dsymbol **ps);
575 Type *semantic(Loc loc, Scope *sc); 644 Type *semantic(Loc loc, Scope *sc);
645 Dsymbol *toDsymbol(Scope *sc);
576 MATCH deduceType(Scope *sc, Type *tparam, TemplateParameters *parameters, Objects *dedtypes); 646 MATCH deduceType(Scope *sc, Type *tparam, TemplateParameters *parameters, Objects *dedtypes);
577 }; 647 };
578 648
579 struct TypeTypeof : TypeQualified 649 struct TypeTypeof : TypeQualified
580 { 650 {
606 unsigned alignsize(); 676 unsigned alignsize();
607 char *toChars(); 677 char *toChars();
608 Type *syntaxCopy(); 678 Type *syntaxCopy();
609 Type *semantic(Loc loc, Scope *sc); 679 Type *semantic(Loc loc, Scope *sc);
610 Dsymbol *toDsymbol(Scope *sc); 680 Dsymbol *toDsymbol(Scope *sc);
611 void toDecoBuffer(OutBuffer *buf, int flag); 681 void toDecoBuffer(OutBuffer *buf, int flag, bool mangle);
612 void toCBuffer2(OutBuffer *buf, HdrGenState *hgs, int mod); 682 void toCBuffer2(OutBuffer *buf, HdrGenState *hgs, int mod);
613 Expression *dotExp(Scope *sc, Expression *e, Identifier *ident); 683 Expression *dotExp(Scope *sc, Expression *e, Identifier *ident);
614 unsigned memalign(unsigned salign); 684 unsigned memalign(unsigned salign);
615 Expression *defaultInit(Loc loc); 685 Expression *defaultInit(Loc loc);
616 int isZeroInit(); 686 int isZeroInit(Loc loc);
617 int isAssignable(); 687 int isAssignable();
618 int checkBoolean(); 688 int checkBoolean();
689 #if IN_DMD
619 dt_t **toDt(dt_t **pdt); 690 dt_t **toDt(dt_t **pdt);
691 #endif
620 MATCH deduceType(Scope *sc, Type *tparam, TemplateParameters *parameters, Objects *dedtypes); 692 MATCH deduceType(Scope *sc, Type *tparam, TemplateParameters *parameters, Objects *dedtypes);
621 TypeInfoDeclaration *getTypeInfoDeclaration(); 693 TypeInfoDeclaration *getTypeInfoDeclaration();
622 int hasPointers(); 694 int hasPointers();
623 MATCH implicitConvTo(Type *to); 695 MATCH implicitConvTo(Type *to);
624 MATCH constConv(Type *to); 696 MATCH constConv(Type *to);
625 Type *toHeadMutable(); 697 Type *toHeadMutable();
626 #if TARGET_LINUX 698 #if POSIX
627 void toCppMangle(OutBuffer *buf, CppMangleState *cms); 699 void toCppMangle(OutBuffer *buf, CppMangleState *cms);
628 #endif 700 #endif
629 701
630 type *toCtype(); 702 #if IN_DMD
631 703 type *toCtype();
704 #elif IN_LLVM
632 // LDC 705 // LDC
633 // cache the hasUnalignedFields check 706 // cache the hasUnalignedFields check
634 // 0 = not checked, 1 = aligned, 2 = unaligned 707 // 0 = not checked, 1 = aligned, 2 = unaligned
635 int unaligned; 708 int unaligned;
709 #endif
636 }; 710 };
637 711
638 struct TypeEnum : Type 712 struct TypeEnum : Type
639 { 713 {
640 EnumDeclaration *sym; 714 EnumDeclaration *sym;
644 unsigned alignsize(); 718 unsigned alignsize();
645 char *toChars(); 719 char *toChars();
646 Type *syntaxCopy(); 720 Type *syntaxCopy();
647 Type *semantic(Loc loc, Scope *sc); 721 Type *semantic(Loc loc, Scope *sc);
648 Dsymbol *toDsymbol(Scope *sc); 722 Dsymbol *toDsymbol(Scope *sc);
649 void toDecoBuffer(OutBuffer *buf, int flag); 723 void toDecoBuffer(OutBuffer *buf, int flag, bool mangle);
650 void toCBuffer2(OutBuffer *buf, HdrGenState *hgs, int mod); 724 void toCBuffer2(OutBuffer *buf, HdrGenState *hgs, int mod);
651 Expression *dotExp(Scope *sc, Expression *e, Identifier *ident); 725 Expression *dotExp(Scope *sc, Expression *e, Identifier *ident);
652 Expression *getProperty(Loc loc, Identifier *ident); 726 Expression *getProperty(Loc loc, Identifier *ident);
653 int isintegral(); 727 int isintegral();
654 int isfloating(); 728 int isfloating();
656 int isunsigned(); 730 int isunsigned();
657 MATCH implicitConvTo(Type *to); 731 MATCH implicitConvTo(Type *to);
658 MATCH constConv(Type *to); 732 MATCH constConv(Type *to);
659 Type *toBasetype(); 733 Type *toBasetype();
660 Expression *defaultInit(Loc loc); 734 Expression *defaultInit(Loc loc);
661 int isZeroInit(); 735 int isZeroInit(Loc loc);
662 MATCH deduceType(Scope *sc, Type *tparam, TemplateParameters *parameters, Objects *dedtypes); 736 MATCH deduceType(Scope *sc, Type *tparam, TemplateParameters *parameters, Objects *dedtypes);
663 TypeInfoDeclaration *getTypeInfoDeclaration(); 737 TypeInfoDeclaration *getTypeInfoDeclaration();
664 int hasPointers(); 738 int hasPointers();
665 #if TARGET_LINUX 739 #if POSIX
666 void toCppMangle(OutBuffer *buf, CppMangleState *cms); 740 void toCppMangle(OutBuffer *buf, CppMangleState *cms);
667 #endif 741 #endif
668 742
669 type *toCtype(); 743 #if IN_DMD
744 type *toCtype();
745 #endif
670 }; 746 };
671 747
672 struct TypeTypedef : Type 748 struct TypeTypedef : Type
673 { 749 {
674 TypedefDeclaration *sym; 750 TypedefDeclaration *sym;
678 d_uns64 size(Loc loc); 754 d_uns64 size(Loc loc);
679 unsigned alignsize(); 755 unsigned alignsize();
680 char *toChars(); 756 char *toChars();
681 Type *semantic(Loc loc, Scope *sc); 757 Type *semantic(Loc loc, Scope *sc);
682 Dsymbol *toDsymbol(Scope *sc); 758 Dsymbol *toDsymbol(Scope *sc);
683 void toDecoBuffer(OutBuffer *buf, int flag); 759 void toDecoBuffer(OutBuffer *buf, int flag, bool mangle);
684 void toCBuffer2(OutBuffer *buf, HdrGenState *hgs, int mod); 760 void toCBuffer2(OutBuffer *buf, HdrGenState *hgs, int mod);
685 Expression *dotExp(Scope *sc, Expression *e, Identifier *ident); 761 Expression *dotExp(Scope *sc, Expression *e, Identifier *ident);
686 Expression *getProperty(Loc loc, Identifier *ident); 762 Expression *getProperty(Loc loc, Identifier *ident);
687 int isbit(); 763 int isbit();
688 int isintegral(); 764 int isintegral();
696 int isAssignable(); 772 int isAssignable();
697 Type *toBasetype(); 773 Type *toBasetype();
698 MATCH implicitConvTo(Type *to); 774 MATCH implicitConvTo(Type *to);
699 MATCH constConv(Type *to); 775 MATCH constConv(Type *to);
700 Expression *defaultInit(Loc loc); 776 Expression *defaultInit(Loc loc);
701 int isZeroInit(); 777 int isZeroInit(Loc loc);
778 #if IN_DMD
702 dt_t **toDt(dt_t **pdt); 779 dt_t **toDt(dt_t **pdt);
780 #endif
703 MATCH deduceType(Scope *sc, Type *tparam, TemplateParameters *parameters, Objects *dedtypes); 781 MATCH deduceType(Scope *sc, Type *tparam, TemplateParameters *parameters, Objects *dedtypes);
704 TypeInfoDeclaration *getTypeInfoDeclaration(); 782 TypeInfoDeclaration *getTypeInfoDeclaration();
705 int hasPointers(); 783 int hasPointers();
706 Type *toHeadMutable(); 784 Type *toHeadMutable();
707 #if TARGET_LINUX 785 #if POSIX
708 void toCppMangle(OutBuffer *buf, CppMangleState *cms); 786 void toCppMangle(OutBuffer *buf, CppMangleState *cms);
709 #endif 787 #endif
710 788
789 #if IN_DMD
711 type *toCtype(); 790 type *toCtype();
712 type *toCParamtype(); 791 type *toCParamtype();
792 #endif
713 }; 793 };
714 794
715 struct TypeClass : Type 795 struct TypeClass : Type
716 { 796 {
717 ClassDeclaration *sym; 797 ClassDeclaration *sym;
720 d_uns64 size(Loc loc); 800 d_uns64 size(Loc loc);
721 char *toChars(); 801 char *toChars();
722 Type *syntaxCopy(); 802 Type *syntaxCopy();
723 Type *semantic(Loc loc, Scope *sc); 803 Type *semantic(Loc loc, Scope *sc);
724 Dsymbol *toDsymbol(Scope *sc); 804 Dsymbol *toDsymbol(Scope *sc);
725 void toDecoBuffer(OutBuffer *buf, int flag); 805 void toDecoBuffer(OutBuffer *buf, int flag, bool mangle);
726 void toCBuffer2(OutBuffer *buf, HdrGenState *hgs, int mod); 806 void toCBuffer2(OutBuffer *buf, HdrGenState *hgs, int mod);
727 Expression *dotExp(Scope *sc, Expression *e, Identifier *ident); 807 Expression *dotExp(Scope *sc, Expression *e, Identifier *ident);
728 ClassDeclaration *isClassHandle(); 808 ClassDeclaration *isClassHandle();
729 int isBaseOf(Type *t, int *poffset); 809 int isBaseOf(Type *t, int *poffset);
730 MATCH implicitConvTo(Type *to); 810 MATCH implicitConvTo(Type *to);
731 Expression *defaultInit(Loc loc); 811 Expression *defaultInit(Loc loc);
732 int isZeroInit(); 812 int isZeroInit(Loc loc);
733 MATCH deduceType(Scope *sc, Type *tparam, TemplateParameters *parameters, Objects *dedtypes); 813 MATCH deduceType(Scope *sc, Type *tparam, TemplateParameters *parameters, Objects *dedtypes);
734 int isauto(); 814 int isauto();
735 int checkBoolean(); 815 int checkBoolean();
736 TypeInfoDeclaration *getTypeInfoDeclaration(); 816 TypeInfoDeclaration *getTypeInfoDeclaration();
737 int hasPointers(); 817 int hasPointers();
818 int builtinTypeInfo();
819 #if DMDV2
738 Type *toHeadMutable(); 820 Type *toHeadMutable();
739 MATCH constConv(Type *to); 821 MATCH constConv(Type *to);
740 #if TARGET_LINUX 822 #if POSIX
741 void toCppMangle(OutBuffer *buf, CppMangleState *cms); 823 void toCppMangle(OutBuffer *buf, CppMangleState *cms);
742 #endif 824 #endif
743 825 #endif
826
827 #if IN_DMD
744 type *toCtype(); 828 type *toCtype();
745 829
746 Symbol *toSymbol(); 830 Symbol *toSymbol();
831 #endif
747 }; 832 };
748 833
749 struct TypeTuple : Type 834 struct TypeTuple : Type
750 { 835 {
751 Arguments *arguments; // types making up the tuple 836 Arguments *arguments; // types making up the tuple
755 Type *syntaxCopy(); 840 Type *syntaxCopy();
756 Type *semantic(Loc loc, Scope *sc); 841 Type *semantic(Loc loc, Scope *sc);
757 int equals(Object *o); 842 int equals(Object *o);
758 Type *reliesOnTident(); 843 Type *reliesOnTident();
759 void toCBuffer2(OutBuffer *buf, HdrGenState *hgs, int mod); 844 void toCBuffer2(OutBuffer *buf, HdrGenState *hgs, int mod);
760 void toDecoBuffer(OutBuffer *buf, int flag); 845 void toDecoBuffer(OutBuffer *buf, int flag, bool mangle);
761 Expression *getProperty(Loc loc, Identifier *ident); 846 Expression *getProperty(Loc loc, Identifier *ident);
762 TypeInfoDeclaration *getTypeInfoDeclaration(); 847 TypeInfoDeclaration *getTypeInfoDeclaration();
763 }; 848 };
764 849
765 struct TypeSlice : TypeNext 850 struct TypeSlice : TypeNext
787 Expression *defaultArg; 872 Expression *defaultArg;
788 873
789 Argument(unsigned storageClass, Type *type, Identifier *ident, Expression *defaultArg); 874 Argument(unsigned storageClass, Type *type, Identifier *ident, Expression *defaultArg);
790 Argument *syntaxCopy(); 875 Argument *syntaxCopy();
791 Type *isLazyArray(); 876 Type *isLazyArray();
792 void toDecoBuffer(OutBuffer *buf); 877 void toDecoBuffer(OutBuffer *buf, bool mangle);
793 static Arguments *arraySyntaxCopy(Arguments *args); 878 static Arguments *arraySyntaxCopy(Arguments *args);
794 static char *argsTypesToChars(Arguments *args, int varargs); 879 static char *argsTypesToChars(Arguments *args, int varargs);
795 static void argsCppMangle(OutBuffer *buf, CppMangleState *cms, Arguments *arguments, int varargs); 880 static void argsCppMangle(OutBuffer *buf, CppMangleState *cms, Arguments *arguments, int varargs);
796 static void argsToCBuffer(OutBuffer *buf, HdrGenState *hgs, Arguments *arguments, int varargs); 881 static void argsToCBuffer(OutBuffer *buf, HdrGenState *hgs, Arguments *arguments, int varargs);
797 static void argsToDecoBuffer(OutBuffer *buf, Arguments *arguments); 882 static void argsToDecoBuffer(OutBuffer *buf, Arguments *arguments, bool mangle);
798 static int isTPL(Arguments *arguments); 883 static int isTPL(Arguments *arguments);
799 static size_t dim(Arguments *arguments); 884 static size_t dim(Arguments *arguments);
800 static Argument *getNth(Arguments *arguments, size_t nth, size_t *pn = NULL); 885 static Argument *getNth(Arguments *arguments, size_t nth, size_t *pn = NULL);
801 }; 886 };
802 887
804 extern int REALSIZE; 889 extern int REALSIZE;
805 extern int REALPAD; 890 extern int REALPAD;
806 extern int Tsize_t; 891 extern int Tsize_t;
807 extern int Tptrdiff_t; 892 extern int Tptrdiff_t;
808 893
894 int arrayTypeCompatible(Loc loc, Type *t1, Type *t2);
895
809 #endif /* DMD_MTYPE_H */ 896 #endif /* DMD_MTYPE_H */