Allow returning something of type void in a function that returns void
[delight/core.git] / dmd2 / mtype.h
blobc76e24019081566965c021b1ec90c919c2b7d31f
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 /* NOTE: This file has been patched from the original DMD distribution to
12 work with the GDC compiler.
14 Modified by David Friedman, January 2007
17 #ifndef DMD_MTYPE_H
18 #define DMD_MTYPE_H
20 #ifndef ENUM_TY_ONLY
22 #ifdef __DMC__
23 #pragma once
24 #endif /* __DMC__ */
26 #include "root.h"
27 #include "stringtable.h"
29 #include "arraytypes.h"
30 #include "expression.h"
32 struct Scope;
33 struct Identifier;
34 struct Expression;
35 struct StructDeclaration;
36 struct ClassDeclaration;
37 struct VarDeclaration;
38 struct EnumDeclaration;
39 struct TypedefDeclaration;
40 struct TypeInfoDeclaration;
41 struct Dsymbol;
42 struct TemplateInstance;
43 struct CppMangleState;
44 enum LINK;
46 struct TypeBasic;
47 struct HdrGenState;
49 // Back end
50 #if IN_GCC
51 union tree_node; typedef union tree_node TYPE;
52 typedef TYPE type;
53 #else
54 typedef struct TYPE type;
55 #endif
56 struct Symbol;
58 #endif
60 enum ENUMTY
62 Tarray, // dynamic array
63 Tsarray, // static array
64 Taarray, // associative array
65 Tpointer,
66 Treference,
67 Tfunction,
68 Tident,
69 Tclass,
70 Tstruct,
71 Tenum,
72 Ttypedef,
73 Tdelegate,
75 Tnone,
76 Tvoid,
77 Tint8,
78 Tuns8,
79 Tint16,
80 Tuns16,
81 Tint32,
82 Tuns32,
83 Tint64,
84 Tuns64,
85 Tfloat32,
86 Tfloat64,
87 Tfloat80,
89 Timaginary32,
90 Timaginary64,
91 Timaginary80,
93 Tcomplex32,
94 Tcomplex64,
95 Tcomplex80,
97 Tbit,
98 Tbool,
99 Tchar,
100 Twchar,
101 Tdchar,
103 Terror,
104 Tinstance,
105 Ttypeof,
106 Ttuple,
107 Tslice,
108 Treturn,
109 Tmaybe,
110 TMAX
112 typedef unsigned char TY; // ENUMTY
114 #ifndef ENUM_TY_ONLY
116 #define Tascii Tchar
118 extern int Tsize_t;
119 extern int Tptrdiff_t;
120 extern int Tindex;
123 struct Type : Object
125 TY ty;
126 unsigned char mod; // modifiers (MODconst, MODinvariant)
127 #define MODconst 1 // type is const
128 #define MODinvariant 2 // type is invariant
129 char *deco;
130 Type *cto; // MODconst ? mutable version of this type : const version
131 Type *ito; // MODinvariant ? mutable version of this type : invariant version
132 Type *pto; // merged pointer to this type
133 Type *mbe; // maybe null of this pointer or reference
134 Type *rto; // reference to this type
135 Type *arrayof; // array of this type
136 TypeInfoDeclaration *vtinfo; // TypeInfo object for this Type
138 type *ctype; // for back end
140 #define tvoid basic[Tvoid]
141 #define tint8 basic[Tint8]
142 #define tuns8 basic[Tuns8]
143 #define tint16 basic[Tint16]
144 #define tuns16 basic[Tuns16]
145 #define tint32 basic[Tint32]
146 #define tuns32 basic[Tuns32]
147 #define tint64 basic[Tint64]
148 #define tuns64 basic[Tuns64]
149 #define tfloat32 basic[Tfloat32]
150 #define tfloat64 basic[Tfloat64]
151 #define tfloat80 basic[Tfloat80]
153 #define timaginary32 basic[Timaginary32]
154 #define timaginary64 basic[Timaginary64]
155 #define timaginary80 basic[Timaginary80]
157 #define tcomplex32 basic[Tcomplex32]
158 #define tcomplex64 basic[Tcomplex64]
159 #define tcomplex80 basic[Tcomplex80]
161 #define tbit basic[Tbit]
162 #define tbool basic[Tbool]
163 #define tchar basic[Tchar]
164 #define twchar basic[Twchar]
165 #define tdchar basic[Tdchar]
167 // Some special types
168 #define tshiftcnt tint32 // right side of shift expression
169 // #define tboolean tint32 // result of boolean expression
170 #define tboolean tbool // result of boolean expression
171 #define tindex basic[Tindex] // array/ptr index
172 static Type *tvoidptr; // void*
173 #define terror basic[Terror] // for error recovery
175 #define tsize_t basic[Tsize_t] // matches size_t alias
176 #define tptrdiff_t basic[Tptrdiff_t] // matches ptrdiff_t alias
177 #define thash_t tsize_t // matches hash_t alias
179 static ClassDeclaration *typeinfo;
180 static ClassDeclaration *typeinfoclass;
181 static ClassDeclaration *typeinfointerface;
182 static ClassDeclaration *typeinfostruct;
183 static ClassDeclaration *typeinfotypedef;
184 static ClassDeclaration *typeinfopointer;
185 static ClassDeclaration *typeinfoarray;
186 static ClassDeclaration *typeinfostaticarray;
187 static ClassDeclaration *typeinfoassociativearray;
188 static ClassDeclaration *typeinfoenum;
189 static ClassDeclaration *typeinfofunction;
190 static ClassDeclaration *typeinfodelegate;
191 static ClassDeclaration *typeinfotypelist;
192 static ClassDeclaration *typeinfoconst;
193 static ClassDeclaration *typeinfoinvariant;
195 static Type *basic[TMAX];
196 static unsigned char mangleChar[TMAX];
197 static unsigned char sizeTy[TMAX];
198 static StringTable stringtable;
200 // These tables are for implicit conversion of binary ops;
201 // the indices are the type of operand one, followed by operand two.
202 static unsigned char impcnvResult[TMAX][TMAX];
203 static unsigned char impcnvType1[TMAX][TMAX];
204 static unsigned char impcnvType2[TMAX][TMAX];
206 // If !=0, give warning on implicit conversion
207 static unsigned char impcnvWarn[TMAX][TMAX];
209 Type(TY ty);
210 virtual Type *syntaxCopy();
211 int equals(Object *o);
212 int dyncast() { return DYNCAST_TYPE; } // kludge for template.isType()
213 int covariant(Type *t);
214 char *toChars();
215 static char needThisPrefix();
216 static void init();
217 d_uns64 size();
218 virtual d_uns64 size(Loc loc);
219 virtual unsigned alignsize();
220 virtual Type *semantic(Loc loc, Scope *sc);
221 virtual void toDecoBuffer(OutBuffer *buf, int flag = 0);
222 Type *merge();
223 virtual void toCBuffer(OutBuffer *buf, Identifier *ident, HdrGenState *hgs);
224 virtual void toCBuffer2(OutBuffer *buf, HdrGenState *hgs, int mod);
225 void toCBuffer3(OutBuffer *buf, HdrGenState *hgs, int mod);
226 #if IN_GCC || TARGET_LINUX
227 virtual void toCppMangle(OutBuffer *buf, CppMangleState *cms);
228 #endif
229 virtual int isintegral();
230 virtual int isfloating(); // real, imaginary, or complex
231 virtual int isreal();
232 virtual int isimaginary();
233 virtual int iscomplex();
234 virtual int isscalar();
235 virtual int isunsigned();
236 virtual int isauto();
237 virtual int isString();
238 virtual int isAssignable();
239 virtual int checkBoolean(); // if can be converted to boolean value
240 virtual void checkDeprecated(Loc loc, Scope *sc);
241 int isConst() { return mod == MODconst; }
242 int isInvariant() { return mod == MODinvariant; }
243 int isMutable() { return mod == 0; }
244 Type *constOf();
245 Type *invariantOf();
246 Type *mutableOf();
247 Type *pointerTo();
248 Type *maybe(bool merge);
249 Type *referenceTo();
250 Type *arrayOf();
251 virtual Type *makeConst();
252 virtual Type *makeInvariant();
253 virtual Dsymbol *toDsymbol(Scope *sc);
254 virtual Type *toBasetype();
255 virtual Type *toHeadMutable();
256 virtual int isBaseOf(Type *t, target_ptrdiff_t *poffset);
257 virtual MATCH constConv(Type *to);
258 virtual MATCH implicitConvTo(Type *to);
259 virtual ClassDeclaration *isClassHandle();
260 virtual Expression *getProperty(Loc loc, Identifier *ident);
261 virtual Expression *dotExp(Scope *sc, Expression *e, Identifier *ident);
262 virtual unsigned memalign(unsigned salign);
263 virtual Expression *defaultInit(Loc loc = 0);
264 virtual int isZeroInit(); // if initializer is 0
265 virtual dt_t **toDt(dt_t **pdt);
266 Identifier *getTypeInfoIdent(int internal);
267 virtual MATCH deduceType(Scope *sc, Type *tparam, TemplateParameters *parameters, Objects *dedtypes);
268 virtual void resolve(Loc loc, Scope *sc, Expression **pe, Type **pt, Dsymbol **ps);
269 Expression *getInternalTypeInfo(Scope *sc);
270 Expression *getTypeInfo(Scope *sc);
271 virtual TypeInfoDeclaration *getTypeInfoDeclaration();
272 virtual int builtinTypeInfo();
273 virtual Type *reliesOnTident();
274 virtual Expression *toExpression();
275 virtual int hasPointers();
276 virtual Type *nextOf();
278 static void error(Loc loc, const char *format, ...);
280 // For backend
281 virtual unsigned totym();
282 virtual type *toCtype();
283 virtual type *toCParamtype();
284 virtual Symbol *toSymbol();
286 // For eliminating dynamic_cast
287 virtual TypeBasic *isTypeBasic();
290 struct TypeNext : Type
292 Type *next;
294 TypeNext(TY ty, Type *next);
295 void toDecoBuffer(OutBuffer *buf, int flag);
296 void checkDeprecated(Loc loc, Scope *sc);
297 Type *reliesOnTident();
298 Type *nextOf();
299 Type *makeConst();
300 Type *makeInvariant();
301 MATCH constConv(Type *to);
304 struct TypeBasic : Type
306 char *dstring;
307 unsigned flags;
309 TypeBasic(TY ty);
310 Type *syntaxCopy();
311 d_uns64 size(Loc loc);
312 unsigned alignsize();
313 Expression *getProperty(Loc loc, Identifier *ident);
314 Expression *dotExp(Scope *sc, Expression *e, Identifier *ident);
315 char *toChars();
316 void toCBuffer2(OutBuffer *buf, HdrGenState *hgs, int mod);
317 #if IN_GCC || TARGET_LINUX
318 void toCppMangle(OutBuffer *buf, CppMangleState *cms);
319 #endif
320 int isintegral();
321 int isbit();
322 int isfloating();
323 int isreal();
324 int isimaginary();
325 int iscomplex();
326 int isscalar();
327 int isunsigned();
328 MATCH implicitConvTo(Type *to);
329 Expression *defaultInit(Loc loc);
330 int isZeroInit();
331 int builtinTypeInfo();
333 // For eliminating dynamic_cast
334 TypeBasic *isTypeBasic();
337 struct TypeArray : TypeNext
339 TypeArray(TY ty, Type *next);
340 Expression *dotExp(Scope *sc, Expression *e, Identifier *ident);
343 // Static array, one with a fixed dimension
344 struct TypeSArray : TypeArray
346 Expression *dim;
348 TypeSArray(Type *t, Expression *dim);
349 Type *syntaxCopy();
350 d_uns64 size(Loc loc);
351 unsigned alignsize();
352 Type *semantic(Loc loc, Scope *sc);
353 void resolve(Loc loc, Scope *sc, Expression **pe, Type **pt, Dsymbol **ps);
354 void toDecoBuffer(OutBuffer *buf, int flag);
355 void toCBuffer2(OutBuffer *buf, HdrGenState *hgs, int mod);
356 Expression *dotExp(Scope *sc, Expression *e, Identifier *ident);
357 int isString();
358 int isZeroInit();
359 unsigned memalign(unsigned salign);
360 MATCH constConv(Type *to);
361 MATCH implicitConvTo(Type *to);
362 Expression *defaultInit(Loc loc);
363 dt_t **toDt(dt_t **pdt);
364 dt_t **toDtElem(dt_t **pdt, Expression *e);
365 MATCH deduceType(Scope *sc, Type *tparam, TemplateParameters *parameters, Objects *dedtypes);
366 TypeInfoDeclaration *getTypeInfoDeclaration();
367 Expression *toExpression();
368 int hasPointers();
369 #if IN_GCC || TARGET_LINUX
370 void toCppMangle(OutBuffer *buf, CppMangleState *cms);
371 #endif
373 type *toCtype();
374 type *toCParamtype();
377 // Dynamic array, no dimension
378 struct TypeDArray : TypeArray
380 TypeDArray(Type *t);
381 Type *syntaxCopy();
382 d_uns64 size(Loc loc);
383 unsigned alignsize();
384 Type *semantic(Loc loc, Scope *sc);
385 void toDecoBuffer(OutBuffer *buf, int flag);
386 void toCBuffer2(OutBuffer *buf, HdrGenState *hgs, int mod);
387 Expression *dotExp(Scope *sc, Expression *e, Identifier *ident);
388 int isString();
389 int isZeroInit();
390 int checkBoolean();
391 MATCH implicitConvTo(Type *to);
392 Expression *defaultInit(Loc loc);
393 int builtinTypeInfo();
394 TypeInfoDeclaration *getTypeInfoDeclaration();
395 int hasPointers();
396 #if IN_GCC || TARGET_LINUX
397 void toCppMangle(OutBuffer *buf, CppMangleState *cms);
398 #endif
400 type *toCtype();
403 struct TypeAArray : TypeArray
405 Type *index; // key type
407 TypeAArray(Type *t, Type *index);
408 Type *syntaxCopy();
409 d_uns64 size(Loc loc);
410 Type *semantic(Loc loc, Scope *sc);
411 void resolve(Loc loc, Scope *sc, Expression **pe, Type **pt, Dsymbol **ps);
412 void toDecoBuffer(OutBuffer *buf, int flag);
413 void toCBuffer2(OutBuffer *buf, HdrGenState *hgs, int mod);
414 Expression *dotExp(Scope *sc, Expression *e, Identifier *ident);
415 Expression *defaultInit(Loc loc);
416 MATCH deduceType(Scope *sc, Type *tparam, TemplateParameters *parameters, Objects *dedtypes);
417 int checkBoolean();
418 TypeInfoDeclaration *getTypeInfoDeclaration();
419 int hasPointers();
420 MATCH implicitConvTo(Type *to);
421 MATCH constConv(Type *to);
422 #if IN_GCC || TARGET_LINUX
423 void toCppMangle(OutBuffer *buf, CppMangleState *cms);
424 #endif
426 // Back end
427 Symbol *aaGetSymbol(char *func, int flags);
429 type *toCtype();
432 struct TypePointer : TypeNext
434 TypePointer(Type *t);
435 Type *syntaxCopy();
436 Type *semantic(Loc loc, Scope *sc);
437 d_uns64 size(Loc loc);
438 void toCBuffer2(OutBuffer *buf, HdrGenState *hgs, int mod);
439 MATCH implicitConvTo(Type *to);
440 int isscalar();
441 Expression *defaultInit(Loc loc);
442 int isZeroInit();
443 TypeInfoDeclaration *getTypeInfoDeclaration();
444 int hasPointers();
445 #if IN_GCC || TARGET_LINUX
446 void toCppMangle(OutBuffer *buf, CppMangleState *cms);
447 #endif
449 type *toCtype();
452 struct TypeMaybe : TypeNext
454 TypeMaybe(Type *t);
455 Type *syntaxCopy();
457 Type *toBasetype();
458 Type *semantic(Loc loc, Scope *sc);
459 d_uns64 size(Loc loc);
460 void toCBuffer2(OutBuffer *buf, HdrGenState *hgs, int mod);
461 MATCH implicitConvTo(Type *to);
462 int isscalar();
463 Expression *defaultInit(Loc loc);
464 int isZeroInit();
465 TypeInfoDeclaration *getTypeInfoDeclaration();
466 int hasPointers();
467 Expression *dotExp(Scope *sc, Expression *e, Identifier *ident);
468 int checkBoolean();
469 Expression *getTypeInfo(Scope *sc);
471 type *toCtype();
474 struct TypeReference : TypeNext
476 TypeReference(Type *t);
477 Type *syntaxCopy();
478 Type *semantic(Loc loc, Scope *sc);
479 d_uns64 size(Loc loc);
480 void toCBuffer2(OutBuffer *buf, HdrGenState *hgs, int mod);
481 Expression *dotExp(Scope *sc, Expression *e, Identifier *ident);
482 Expression *defaultInit(Loc loc);
483 int isZeroInit();
484 #if IN_GCC || TARGET_LINUX
485 void toCppMangle(OutBuffer *buf, CppMangleState *cms);
486 #endif
489 enum RET
491 RETregs = 1, // returned in registers
492 RETstack = 2, // returned on stack
495 struct TypeFunction : TypeNext
497 // .next is the return type
499 Arguments *parameters; // function parameters
500 int varargs; // 1: T t, ...) style for variable number of arguments
501 // 2: T t ...) style for variable number of arguments
502 bool isnothrow; // true: nothrow
503 bool ispure; // true: pure
504 enum LINK linkage; // calling convention
506 int inuse;
508 TypeFunction(Arguments *parameters, Type *treturn, int varargs, enum LINK linkage);
509 Type *syntaxCopy();
510 Type *semantic(Loc loc, Scope *sc);
511 void toDecoBuffer(OutBuffer *buf, int flag);
512 void toCBuffer(OutBuffer *buf, Identifier *ident, HdrGenState *hgs);
513 void toCBuffer2(OutBuffer *buf, HdrGenState *hgs, int mod);
514 MATCH deduceType(Scope *sc, Type *tparam, TemplateParameters *parameters, Objects *dedtypes);
515 TypeInfoDeclaration *getTypeInfoDeclaration();
516 Type *reliesOnTident();
517 #if IN_GCC || TARGET_LINUX
518 void toCppMangle(OutBuffer *buf, CppMangleState *cms);
519 #endif
521 int callMatch(Expression *ethis, Expressions *toargs);
522 type *toCtype();
523 enum RET retStyle();
525 unsigned totym();
528 struct TypeDelegate : TypeNext
530 // .next is a TypeFunction
532 TypeDelegate(Type *t);
533 Type *syntaxCopy();
534 Type *semantic(Loc loc, Scope *sc);
535 d_uns64 size(Loc loc);
536 void toCBuffer2(OutBuffer *buf, HdrGenState *hgs, int mod);
537 Expression *defaultInit(Loc loc);
538 int isZeroInit();
539 int checkBoolean();
540 TypeInfoDeclaration *getTypeInfoDeclaration();
541 Expression *dotExp(Scope *sc, Expression *e, Identifier *ident);
542 int hasPointers();
543 #if IN_GCC || TARGET_LINUX
544 void toCppMangle(OutBuffer *buf, CppMangleState *cms);
545 #endif
547 type *toCtype();
550 struct TypeQualified : Type
552 Loc loc;
553 Array idents; // array of Identifier's representing ident.ident.ident etc.
555 TypeQualified(TY ty, Loc loc);
556 void syntaxCopyHelper(TypeQualified *t);
557 void addIdent(Identifier *ident);
558 void toCBuffer2Helper(OutBuffer *buf, HdrGenState *hgs);
559 d_uns64 size(Loc loc);
560 void resolveHelper(Loc loc, Scope *sc, Dsymbol *s, Dsymbol *scopesym,
561 Expression **pe, Type **pt, Dsymbol **ps);
564 struct TypeIdentifier : TypeQualified
566 Identifier *ident;
567 bool maybe; // If this turns out to be a type, wrap with TypeMaybe
569 TypeIdentifier(Loc loc, Identifier *ident);
570 Type *syntaxCopy();
571 //char *toChars();
572 void toDecoBuffer(OutBuffer *buf, int flag);
573 void toCBuffer2(OutBuffer *buf, HdrGenState *hgs, int mod);
574 void resolve(Loc loc, Scope *sc, Expression **pe, Type **pt, Dsymbol **ps);
575 Dsymbol *toDsymbol(Scope *sc);
576 Type *semantic(Loc loc, Scope *sc);
577 MATCH deduceType(Scope *sc, Type *tparam, TemplateParameters *parameters, Objects *dedtypes);
578 Type *reliesOnTident();
579 Expression *toExpression();
582 /* Similar to TypeIdentifier, but with a TemplateInstance as the root
584 struct TypeInstance : TypeQualified
586 TemplateInstance *tempinst;
588 TypeInstance(Loc loc, TemplateInstance *tempinst);
589 Type *syntaxCopy();
590 //char *toChars();
591 //void toDecoBuffer(OutBuffer *buf, int flag);
592 void toCBuffer2(OutBuffer *buf, HdrGenState *hgs, int mod);
593 void resolve(Loc loc, Scope *sc, Expression **pe, Type **pt, Dsymbol **ps);
594 Type *semantic(Loc loc, Scope *sc);
595 MATCH deduceType(Scope *sc, Type *tparam, TemplateParameters *parameters, Objects *dedtypes);
598 struct TypeTypeof : TypeQualified
600 Expression *exp;
602 TypeTypeof(Loc loc, Expression *exp);
603 Type *syntaxCopy();
604 Dsymbol *toDsymbol(Scope *sc);
605 void toCBuffer2(OutBuffer *buf, HdrGenState *hgs, int mod);
606 Type *semantic(Loc loc, Scope *sc);
607 d_uns64 size(Loc loc);
610 struct TypeReturn : TypeQualified
612 TypeReturn(Loc loc);
613 Type *syntaxCopy();
614 Dsymbol *toDsymbol(Scope *sc);
615 Type *semantic(Loc loc, Scope *sc);
616 void toCBuffer2(OutBuffer *buf, HdrGenState *hgs, int mod);
619 struct TypeStruct : Type
621 StructDeclaration *sym;
623 TypeStruct(StructDeclaration *sym);
624 d_uns64 size(Loc loc);
625 unsigned alignsize();
626 char *toChars();
627 Type *syntaxCopy();
628 Type *semantic(Loc loc, Scope *sc);
629 Dsymbol *toDsymbol(Scope *sc);
630 void toDecoBuffer(OutBuffer *buf, int flag);
631 void toCBuffer2(OutBuffer *buf, HdrGenState *hgs, int mod);
632 Expression *dotExp(Scope *sc, Expression *e, Identifier *ident);
633 unsigned memalign(unsigned salign);
634 Expression *defaultInit(Loc loc);
635 int isZeroInit();
636 int isAssignable();
637 int checkBoolean();
638 dt_t **toDt(dt_t **pdt);
639 MATCH deduceType(Scope *sc, Type *tparam, TemplateParameters *parameters, Objects *dedtypes);
640 TypeInfoDeclaration *getTypeInfoDeclaration();
641 int hasPointers();
642 MATCH implicitConvTo(Type *to);
643 MATCH constConv(Type *to);
644 Type *toHeadMutable();
645 #if IN_GCC || TARGET_LINUX
646 void toCppMangle(OutBuffer *buf, CppMangleState *cms);
647 #endif
649 type *toCtype();
652 struct TypeEnum : Type
654 EnumDeclaration *sym;
656 TypeEnum(EnumDeclaration *sym);
657 d_uns64 size(Loc loc);
658 unsigned alignsize();
659 char *toChars();
660 Type *semantic(Loc loc, Scope *sc);
661 Dsymbol *toDsymbol(Scope *sc);
662 void toDecoBuffer(OutBuffer *buf, int flag);
663 void toCBuffer2(OutBuffer *buf, HdrGenState *hgs, int mod);
664 Expression *dotExp(Scope *sc, Expression *e, Identifier *ident);
665 Expression *getProperty(Loc loc, Identifier *ident);
666 int isintegral();
667 int isfloating();
668 int isscalar();
669 int isunsigned();
670 MATCH implicitConvTo(Type *to);
671 MATCH constConv(Type *to);
672 Type *toBasetype();
673 Expression *defaultInit(Loc loc);
674 int isZeroInit();
675 MATCH deduceType(Scope *sc, Type *tparam, TemplateParameters *parameters, Objects *dedtypes);
676 TypeInfoDeclaration *getTypeInfoDeclaration();
677 int hasPointers();
678 #if IN_GCC || TARGET_LINUX
679 void toCppMangle(OutBuffer *buf, CppMangleState *cms);
680 #endif
682 type *toCtype();
685 struct TypeTypedef : Type
687 TypedefDeclaration *sym;
689 TypeTypedef(TypedefDeclaration *sym);
690 Type *syntaxCopy();
691 d_uns64 size(Loc loc);
692 unsigned alignsize();
693 char *toChars();
694 Type *semantic(Loc loc, Scope *sc);
695 Dsymbol *toDsymbol(Scope *sc);
696 void toDecoBuffer(OutBuffer *buf, int flag);
697 void toCBuffer2(OutBuffer *buf, HdrGenState *hgs, int mod);
698 Expression *dotExp(Scope *sc, Expression *e, Identifier *ident);
699 Expression *getProperty(Loc loc, Identifier *ident);
700 int isbit();
701 int isintegral();
702 int isfloating();
703 int isreal();
704 int isimaginary();
705 int iscomplex();
706 int isscalar();
707 int isunsigned();
708 int checkBoolean();
709 int isAssignable();
710 Type *toBasetype();
711 MATCH implicitConvTo(Type *to);
712 MATCH constConv(Type *to);
713 Expression *defaultInit(Loc loc);
714 int isZeroInit();
715 dt_t **toDt(dt_t **pdt);
716 MATCH deduceType(Scope *sc, Type *tparam, TemplateParameters *parameters, Objects *dedtypes);
717 TypeInfoDeclaration *getTypeInfoDeclaration();
718 int hasPointers();
719 Type *toHeadMutable();
720 #if IN_GCC || TARGET_LINUX
721 void toCppMangle(OutBuffer *buf, CppMangleState *cms);
722 #endif
724 type *toCtype();
725 type *toCParamtype();
728 struct TypeClass : Type
730 ClassDeclaration *sym;
732 TypeClass(ClassDeclaration *sym);
733 d_uns64 size(Loc loc);
734 char *toChars();
735 Type *syntaxCopy();
736 Type *semantic(Loc loc, Scope *sc);
737 Dsymbol *toDsymbol(Scope *sc);
738 void toDecoBuffer(OutBuffer *buf, int flag);
739 void toCBuffer2(OutBuffer *buf, HdrGenState *hgs, int mod);
740 Expression *dotExp(Scope *sc, Expression *e, Identifier *ident);
741 ClassDeclaration *isClassHandle();
742 int isBaseOf(Type *t, target_ptrdiff_t *poffset);
743 MATCH implicitConvTo(Type *to);
744 Expression *defaultInit(Loc loc);
745 int isZeroInit();
746 MATCH deduceType(Scope *sc, Type *tparam, TemplateParameters *parameters, Objects *dedtypes);
747 int isauto();
748 int checkBoolean();
749 TypeInfoDeclaration *getTypeInfoDeclaration();
750 int hasPointers();
751 Type *toHeadMutable();
752 MATCH constConv(Type *to);
753 #if IN_GCC || TARGET_LINUX
754 void toCppMangle(OutBuffer *buf, CppMangleState *cms);
755 #endif
757 type *toCtype();
759 Symbol *toSymbol();
762 struct TypeTuple : Type
764 Arguments *arguments; // types making up the tuple
766 TypeTuple(Arguments *arguments);
767 TypeTuple(Expressions *exps);
768 Type *syntaxCopy();
769 Type *semantic(Loc loc, Scope *sc);
770 int equals(Object *o);
771 Type *reliesOnTident();
772 void toCBuffer2(OutBuffer *buf, HdrGenState *hgs, int mod);
773 void toDecoBuffer(OutBuffer *buf, int flag);
774 Expression *getProperty(Loc loc, Identifier *ident);
775 TypeInfoDeclaration *getTypeInfoDeclaration();
778 struct TypeSlice : TypeNext
780 Expression *lwr;
781 Expression *upr;
783 TypeSlice(Type *next, Expression *lwr, Expression *upr);
784 Type *syntaxCopy();
785 Type *semantic(Loc loc, Scope *sc);
786 void resolve(Loc loc, Scope *sc, Expression **pe, Type **pt, Dsymbol **ps);
787 void toCBuffer2(OutBuffer *buf, HdrGenState *hgs, int mod);
790 /**************************************************************/
792 //enum InOut { None, In, Out, InOut, Lazy };
794 struct Argument : Object
796 //enum InOut inout;
797 unsigned storageClass;
798 Type *type;
799 Identifier *ident;
800 Expression *defaultArg;
802 Argument(unsigned storageClass, Type *type, Identifier *ident, Expression *defaultArg);
803 Argument *syntaxCopy();
804 Type *isLazyArray();
805 void toDecoBuffer(OutBuffer *buf);
806 static Arguments *arraySyntaxCopy(Arguments *args);
807 static char *argsTypesToChars(Arguments *args, int varargs);
808 static void argsCppMangle(OutBuffer *buf, CppMangleState *cms, Arguments *arguments, int varargs);
809 static void argsToCBuffer(OutBuffer *buf, HdrGenState *hgs, Arguments *arguments, int varargs);
810 static void argsToDecoBuffer(OutBuffer *buf, Arguments *arguments);
811 static size_t dim(Arguments *arguments);
812 static Argument *getNth(Arguments *arguments, size_t nth, size_t *pn = NULL);
815 extern int PTRSIZE;
816 extern int REALSIZE;
817 extern int REALPAD;
818 extern int Tsize_t;
819 extern int Tptrdiff_t;
821 #endif
823 #endif /* DMD_MTYPE_H */