comparison dmd/mtype.h @ 159:5acec6b2eef8 trunk

[svn r175] merged dmd 1.029
author ChristianK
date Thu, 01 May 2008 15:15:28 +0200
parents 5c17f81fc1c1
children 1856c62af24b
comparison
equal deleted inserted replaced
158:287540c5f05e 159:5acec6b2eef8
103 extern int Tptrdiff_t; 103 extern int Tptrdiff_t;
104 104
105 struct Type : Object 105 struct Type : Object
106 { 106 {
107 TY ty; 107 TY ty;
108 unsigned char mod; // modifiers (MODconst, MODinvariant)
109 #define MODconst 1 // type is const
110 #define MODinvariant 2 // type is invariant
108 Type *next; 111 Type *next;
109 char *deco; 112 char *deco;
110 Type *pto; // merged pointer to this type 113 Type *pto; // merged pointer to this type
111 Type *rto; // reference to this type 114 Type *rto; // reference to this type
112 Type *arrayof; // array of this type 115 Type *arrayof; // array of this type
191 d_uns64 size(); 194 d_uns64 size();
192 virtual d_uns64 size(Loc loc); 195 virtual d_uns64 size(Loc loc);
193 virtual unsigned alignsize(); 196 virtual unsigned alignsize();
194 virtual Type *semantic(Loc loc, Scope *sc); 197 virtual Type *semantic(Loc loc, Scope *sc);
195 virtual void toDecoBuffer(OutBuffer *buf); 198 virtual void toDecoBuffer(OutBuffer *buf);
196 virtual void toTypeInfoBuffer(OutBuffer *buf);
197 Type *merge(); 199 Type *merge();
198 void toCBuffer(OutBuffer *buf, Identifier *ident, HdrGenState *hgs); 200 virtual void toCBuffer(OutBuffer *buf, Identifier *ident, HdrGenState *hgs);
199 virtual void toCBuffer2(OutBuffer *buf, Identifier *ident, HdrGenState *hgs); 201 virtual void toCBuffer2(OutBuffer *buf, HdrGenState *hgs, int mod);
202 void toCBuffer3(OutBuffer *buf, HdrGenState *hgs, int mod);
200 virtual int isbit(); 203 virtual int isbit();
201 virtual int isintegral(); 204 virtual int isintegral();
202 virtual int isfloating(); // real, imaginary, or complex 205 virtual int isfloating(); // real, imaginary, or complex
203 virtual int isreal(); 206 virtual int isreal();
204 virtual int isimaginary(); 207 virtual int isimaginary();
258 d_uns64 size(Loc loc); 261 d_uns64 size(Loc loc);
259 unsigned alignsize(); 262 unsigned alignsize();
260 Expression *getProperty(Loc loc, Identifier *ident); 263 Expression *getProperty(Loc loc, Identifier *ident);
261 Expression *dotExp(Scope *sc, Expression *e, Identifier *ident); 264 Expression *dotExp(Scope *sc, Expression *e, Identifier *ident);
262 char *toChars(); 265 char *toChars();
263 void toCBuffer2(OutBuffer *buf, Identifier *ident, HdrGenState *hgs); 266 void toCBuffer2(OutBuffer *buf, HdrGenState *hgs, int mod);
264 int isintegral(); 267 int isintegral();
265 int isbit(); 268 int isbit();
266 int isfloating(); 269 int isfloating();
267 int isreal(); 270 int isreal();
268 int isimaginary(); 271 int isimaginary();
279 }; 282 };
280 283
281 struct TypeArray : Type 284 struct TypeArray : Type
282 { 285 {
283 TypeArray(TY ty, Type *next); 286 TypeArray(TY ty, Type *next);
284 virtual void toPrettyBracket(OutBuffer *buf, HdrGenState *hgs) = 0;
285 void toCBuffer2(OutBuffer *buf, Identifier *ident, HdrGenState *hgs);
286 Expression *dotExp(Scope *sc, Expression *e, Identifier *ident); 287 Expression *dotExp(Scope *sc, Expression *e, Identifier *ident);
287 }; 288 };
288 289
289 // Static array, one with a fixed dimension 290 // Static array, one with a fixed dimension
290 struct TypeSArray : TypeArray 291 struct TypeSArray : TypeArray
296 d_uns64 size(Loc loc); 297 d_uns64 size(Loc loc);
297 unsigned alignsize(); 298 unsigned alignsize();
298 Type *semantic(Loc loc, Scope *sc); 299 Type *semantic(Loc loc, Scope *sc);
299 void resolve(Loc loc, Scope *sc, Expression **pe, Type **pt, Dsymbol **ps); 300 void resolve(Loc loc, Scope *sc, Expression **pe, Type **pt, Dsymbol **ps);
300 void toDecoBuffer(OutBuffer *buf); 301 void toDecoBuffer(OutBuffer *buf);
301 void toTypeInfoBuffer(OutBuffer *buf); 302 void toCBuffer2(OutBuffer *buf, HdrGenState *hgs, int mod);
302 void toPrettyBracket(OutBuffer *buf, HdrGenState *hgs);
303 Expression *dotExp(Scope *sc, Expression *e, Identifier *ident); 303 Expression *dotExp(Scope *sc, Expression *e, Identifier *ident);
304 int isString(); 304 int isString();
305 int isZeroInit(); 305 int isZeroInit();
306 unsigned memalign(unsigned salign); 306 unsigned memalign(unsigned salign);
307 MATCH implicitConvTo(Type *to); 307 MATCH implicitConvTo(Type *to);
324 Type *syntaxCopy(); 324 Type *syntaxCopy();
325 d_uns64 size(Loc loc); 325 d_uns64 size(Loc loc);
326 unsigned alignsize(); 326 unsigned alignsize();
327 Type *semantic(Loc loc, Scope *sc); 327 Type *semantic(Loc loc, Scope *sc);
328 void toDecoBuffer(OutBuffer *buf); 328 void toDecoBuffer(OutBuffer *buf);
329 void toTypeInfoBuffer(OutBuffer *buf); 329 void toCBuffer2(OutBuffer *buf, HdrGenState *hgs, int mod);
330 void toPrettyBracket(OutBuffer *buf, HdrGenState *hgs);
331 Expression *dotExp(Scope *sc, Expression *e, Identifier *ident); 330 Expression *dotExp(Scope *sc, Expression *e, Identifier *ident);
332 int isString(); 331 int isString();
333 int isZeroInit(); 332 int isZeroInit();
334 int checkBoolean(); 333 int checkBoolean();
335 MATCH implicitConvTo(Type *to); 334 MATCH implicitConvTo(Type *to);
349 TypeAArray(Type *t, Type *index); 348 TypeAArray(Type *t, Type *index);
350 Type *syntaxCopy(); 349 Type *syntaxCopy();
351 d_uns64 size(Loc loc); 350 d_uns64 size(Loc loc);
352 Type *semantic(Loc loc, Scope *sc); 351 Type *semantic(Loc loc, Scope *sc);
353 void toDecoBuffer(OutBuffer *buf); 352 void toDecoBuffer(OutBuffer *buf);
354 void toPrettyBracket(OutBuffer *buf, HdrGenState *hgs); 353 void toCBuffer2(OutBuffer *buf, HdrGenState *hgs, int mod);
355 Expression *dotExp(Scope *sc, Expression *e, Identifier *ident); 354 Expression *dotExp(Scope *sc, Expression *e, Identifier *ident);
356 Expression *defaultInit(Loc loc); 355 Expression *defaultInit(Loc loc);
357 MATCH deduceType(Scope *sc, Type *tparam, TemplateParameters *parameters, Objects *dedtypes); 356 MATCH deduceType(Scope *sc, Type *tparam, TemplateParameters *parameters, Objects *dedtypes);
358 int checkBoolean(); 357 int checkBoolean();
359 TypeInfoDeclaration *getTypeInfoDeclaration(); 358 TypeInfoDeclaration *getTypeInfoDeclaration();
369 { 368 {
370 TypePointer(Type *t); 369 TypePointer(Type *t);
371 Type *syntaxCopy(); 370 Type *syntaxCopy();
372 Type *semantic(Loc loc, Scope *sc); 371 Type *semantic(Loc loc, Scope *sc);
373 d_uns64 size(Loc loc); 372 d_uns64 size(Loc loc);
374 void toCBuffer2(OutBuffer *buf, Identifier *ident, HdrGenState *hgs); 373 void toCBuffer2(OutBuffer *buf, HdrGenState *hgs, int mod);
375 MATCH implicitConvTo(Type *to); 374 MATCH implicitConvTo(Type *to);
376 int isscalar(); 375 int isscalar();
377 Expression *defaultInit(Loc loc); 376 Expression *defaultInit(Loc loc);
378 int isZeroInit(); 377 int isZeroInit();
379 TypeInfoDeclaration *getTypeInfoDeclaration(); 378 TypeInfoDeclaration *getTypeInfoDeclaration();
385 struct TypeReference : Type 384 struct TypeReference : Type
386 { 385 {
387 TypeReference(Type *t); 386 TypeReference(Type *t);
388 Type *syntaxCopy(); 387 Type *syntaxCopy();
389 d_uns64 size(Loc loc); 388 d_uns64 size(Loc loc);
390 void toCBuffer2(OutBuffer *buf, Identifier *ident, HdrGenState *hgs); 389 void toCBuffer2(OutBuffer *buf, HdrGenState *hgs, int mod);
391 Expression *dotExp(Scope *sc, Expression *e, Identifier *ident); 390 Expression *dotExp(Scope *sc, Expression *e, Identifier *ident);
392 Expression *defaultInit(Loc loc); 391 Expression *defaultInit(Loc loc);
393 int isZeroInit(); 392 int isZeroInit();
394 }; 393 };
395 394
410 409
411 TypeFunction(Arguments *parameters, Type *treturn, int varargs, enum LINK linkage); 410 TypeFunction(Arguments *parameters, Type *treturn, int varargs, enum LINK linkage);
412 Type *syntaxCopy(); 411 Type *syntaxCopy();
413 Type *semantic(Loc loc, Scope *sc); 412 Type *semantic(Loc loc, Scope *sc);
414 void toDecoBuffer(OutBuffer *buf); 413 void toDecoBuffer(OutBuffer *buf);
415 void toCBuffer2(OutBuffer *buf, Identifier *ident, HdrGenState *hgs); 414 void toCBuffer(OutBuffer *buf, Identifier *ident, HdrGenState *hgs);
415 void toCBuffer2(OutBuffer *buf, HdrGenState *hgs, int mod);
416 MATCH deduceType(Scope *sc, Type *tparam, TemplateParameters *parameters, Objects *dedtypes); 416 MATCH deduceType(Scope *sc, Type *tparam, TemplateParameters *parameters, Objects *dedtypes);
417 TypeInfoDeclaration *getTypeInfoDeclaration(); 417 TypeInfoDeclaration *getTypeInfoDeclaration();
418 Type *reliesOnTident(); 418 Type *reliesOnTident();
419 419
420 int callMatch(Expressions *toargs); 420 int callMatch(Expressions *toargs);
431 { 431 {
432 TypeDelegate(Type *t); 432 TypeDelegate(Type *t);
433 Type *syntaxCopy(); 433 Type *syntaxCopy();
434 Type *semantic(Loc loc, Scope *sc); 434 Type *semantic(Loc loc, Scope *sc);
435 d_uns64 size(Loc loc); 435 d_uns64 size(Loc loc);
436 void toCBuffer2(OutBuffer *buf, Identifier *ident, HdrGenState *hgs); 436 void toCBuffer2(OutBuffer *buf, HdrGenState *hgs, int mod);
437 Expression *defaultInit(Loc loc); 437 Expression *defaultInit(Loc loc);
438 int isZeroInit(); 438 int isZeroInit();
439 int checkBoolean(); 439 int checkBoolean();
440 TypeInfoDeclaration *getTypeInfoDeclaration(); 440 TypeInfoDeclaration *getTypeInfoDeclaration();
441 Expression *dotExp(Scope *sc, Expression *e, Identifier *ident); 441 Expression *dotExp(Scope *sc, Expression *e, Identifier *ident);
450 Array idents; // array of Identifier's representing ident.ident.ident etc. 450 Array idents; // array of Identifier's representing ident.ident.ident etc.
451 451
452 TypeQualified(TY ty, Loc loc); 452 TypeQualified(TY ty, Loc loc);
453 void syntaxCopyHelper(TypeQualified *t); 453 void syntaxCopyHelper(TypeQualified *t);
454 void addIdent(Identifier *ident); 454 void addIdent(Identifier *ident);
455 void toCBuffer2Helper(OutBuffer *buf, Identifier *ident, HdrGenState *hgs); 455 void toCBuffer2Helper(OutBuffer *buf, HdrGenState *hgs);
456 d_uns64 size(Loc loc); 456 d_uns64 size(Loc loc);
457 void resolveHelper(Loc loc, Scope *sc, Dsymbol *s, Dsymbol *scopesym, 457 void resolveHelper(Loc loc, Scope *sc, Dsymbol *s, Dsymbol *scopesym,
458 Expression **pe, Type **pt, Dsymbol **ps); 458 Expression **pe, Type **pt, Dsymbol **ps);
459 }; 459 };
460 460
464 464
465 TypeIdentifier(Loc loc, Identifier *ident); 465 TypeIdentifier(Loc loc, Identifier *ident);
466 Type *syntaxCopy(); 466 Type *syntaxCopy();
467 //char *toChars(); 467 //char *toChars();
468 void toDecoBuffer(OutBuffer *buf); 468 void toDecoBuffer(OutBuffer *buf);
469 void toCBuffer2(OutBuffer *buf, Identifier *ident, HdrGenState *hgs); 469 void toCBuffer2(OutBuffer *buf, HdrGenState *hgs, int mod);
470 void resolve(Loc loc, Scope *sc, Expression **pe, Type **pt, Dsymbol **ps); 470 void resolve(Loc loc, Scope *sc, Expression **pe, Type **pt, Dsymbol **ps);
471 Dsymbol *toDsymbol(Scope *sc); 471 Dsymbol *toDsymbol(Scope *sc);
472 Type *semantic(Loc loc, Scope *sc); 472 Type *semantic(Loc loc, Scope *sc);
473 MATCH deduceType(Scope *sc, Type *tparam, TemplateParameters *parameters, Objects *dedtypes); 473 MATCH deduceType(Scope *sc, Type *tparam, TemplateParameters *parameters, Objects *dedtypes);
474 Type *reliesOnTident(); 474 Type *reliesOnTident();
483 483
484 TypeInstance(Loc loc, TemplateInstance *tempinst); 484 TypeInstance(Loc loc, TemplateInstance *tempinst);
485 Type *syntaxCopy(); 485 Type *syntaxCopy();
486 //char *toChars(); 486 //char *toChars();
487 //void toDecoBuffer(OutBuffer *buf); 487 //void toDecoBuffer(OutBuffer *buf);
488 void toCBuffer2(OutBuffer *buf, Identifier *ident, HdrGenState *hgs); 488 void toCBuffer2(OutBuffer *buf, HdrGenState *hgs, int mod);
489 void resolve(Loc loc, Scope *sc, Expression **pe, Type **pt, Dsymbol **ps); 489 void resolve(Loc loc, Scope *sc, Expression **pe, Type **pt, Dsymbol **ps);
490 Type *semantic(Loc loc, Scope *sc); 490 Type *semantic(Loc loc, Scope *sc);
491 MATCH deduceType(Scope *sc, Type *tparam, TemplateParameters *parameters, Objects *dedtypes); 491 MATCH deduceType(Scope *sc, Type *tparam, TemplateParameters *parameters, Objects *dedtypes);
492 }; 492 };
493 493
496 Expression *exp; 496 Expression *exp;
497 497
498 TypeTypeof(Loc loc, Expression *exp); 498 TypeTypeof(Loc loc, Expression *exp);
499 Type *syntaxCopy(); 499 Type *syntaxCopy();
500 Dsymbol *toDsymbol(Scope *sc); 500 Dsymbol *toDsymbol(Scope *sc);
501 void toCBuffer2(OutBuffer *buf, Identifier *ident, HdrGenState *hgs); 501 void toCBuffer2(OutBuffer *buf, HdrGenState *hgs, int mod);
502 Type *semantic(Loc loc, Scope *sc); 502 Type *semantic(Loc loc, Scope *sc);
503 d_uns64 size(Loc loc); 503 d_uns64 size(Loc loc);
504 }; 504 };
505 505
506 struct TypeStruct : Type 506 struct TypeStruct : Type
513 char *toChars(); 513 char *toChars();
514 Type *syntaxCopy(); 514 Type *syntaxCopy();
515 Type *semantic(Loc loc, Scope *sc); 515 Type *semantic(Loc loc, Scope *sc);
516 Dsymbol *toDsymbol(Scope *sc); 516 Dsymbol *toDsymbol(Scope *sc);
517 void toDecoBuffer(OutBuffer *buf); 517 void toDecoBuffer(OutBuffer *buf);
518 void toTypeInfoBuffer(OutBuffer *buf); 518 void toCBuffer2(OutBuffer *buf, HdrGenState *hgs, int mod);
519 void toCBuffer2(OutBuffer *buf, Identifier *ident, HdrGenState *hgs);
520 Expression *dotExp(Scope *sc, Expression *e, Identifier *ident); 519 Expression *dotExp(Scope *sc, Expression *e, Identifier *ident);
521 unsigned memalign(unsigned salign); 520 unsigned memalign(unsigned salign);
522 Expression *defaultInit(Loc loc); 521 Expression *defaultInit(Loc loc);
523 int isZeroInit(); 522 int isZeroInit();
524 int checkBoolean(); 523 int checkBoolean();
539 unsigned alignsize(); 538 unsigned alignsize();
540 char *toChars(); 539 char *toChars();
541 Type *semantic(Loc loc, Scope *sc); 540 Type *semantic(Loc loc, Scope *sc);
542 Dsymbol *toDsymbol(Scope *sc); 541 Dsymbol *toDsymbol(Scope *sc);
543 void toDecoBuffer(OutBuffer *buf); 542 void toDecoBuffer(OutBuffer *buf);
544 void toTypeInfoBuffer(OutBuffer *buf); 543 void toCBuffer2(OutBuffer *buf, HdrGenState *hgs, int mod);
545 void toCBuffer2(OutBuffer *buf, Identifier *ident, HdrGenState *hgs);
546 Expression *dotExp(Scope *sc, Expression *e, Identifier *ident); 544 Expression *dotExp(Scope *sc, Expression *e, Identifier *ident);
547 Expression *getProperty(Loc loc, Identifier *ident); 545 Expression *getProperty(Loc loc, Identifier *ident);
548 int isintegral(); 546 int isintegral();
549 int isfloating(); 547 int isfloating();
550 int isscalar(); 548 int isscalar();
570 unsigned alignsize(); 568 unsigned alignsize();
571 char *toChars(); 569 char *toChars();
572 Type *semantic(Loc loc, Scope *sc); 570 Type *semantic(Loc loc, Scope *sc);
573 Dsymbol *toDsymbol(Scope *sc); 571 Dsymbol *toDsymbol(Scope *sc);
574 void toDecoBuffer(OutBuffer *buf); 572 void toDecoBuffer(OutBuffer *buf);
575 void toTypeInfoBuffer(OutBuffer *buf); 573 void toCBuffer2(OutBuffer *buf, HdrGenState *hgs, int mod);
576 void toCBuffer2(OutBuffer *buf, Identifier *ident, HdrGenState *hgs);
577 Expression *dotExp(Scope *sc, Expression *e, Identifier *ident); 574 Expression *dotExp(Scope *sc, Expression *e, Identifier *ident);
578 Expression *getProperty(Loc loc, Identifier *ident); 575 Expression *getProperty(Loc loc, Identifier *ident);
579 int isbit(); 576 int isbit();
580 int isintegral(); 577 int isintegral();
581 int isfloating(); 578 int isfloating();
607 char *toChars(); 604 char *toChars();
608 Type *syntaxCopy(); 605 Type *syntaxCopy();
609 Type *semantic(Loc loc, Scope *sc); 606 Type *semantic(Loc loc, Scope *sc);
610 Dsymbol *toDsymbol(Scope *sc); 607 Dsymbol *toDsymbol(Scope *sc);
611 void toDecoBuffer(OutBuffer *buf); 608 void toDecoBuffer(OutBuffer *buf);
612 void toCBuffer2(OutBuffer *buf, Identifier *ident, HdrGenState *hgs); 609 void toCBuffer2(OutBuffer *buf, HdrGenState *hgs, int mod);
613 Expression *dotExp(Scope *sc, Expression *e, Identifier *ident); 610 Expression *dotExp(Scope *sc, Expression *e, Identifier *ident);
614 ClassDeclaration *isClassHandle(); 611 ClassDeclaration *isClassHandle();
615 int isBaseOf(Type *t, int *poffset); 612 int isBaseOf(Type *t, int *poffset);
616 MATCH implicitConvTo(Type *to); 613 MATCH implicitConvTo(Type *to);
617 Expression *defaultInit(Loc loc); 614 Expression *defaultInit(Loc loc);
635 TypeTuple(Expressions *exps); 632 TypeTuple(Expressions *exps);
636 Type *syntaxCopy(); 633 Type *syntaxCopy();
637 Type *semantic(Loc loc, Scope *sc); 634 Type *semantic(Loc loc, Scope *sc);
638 int equals(Object *o); 635 int equals(Object *o);
639 Type *reliesOnTident(); 636 Type *reliesOnTident();
640 void toCBuffer2(OutBuffer *buf, Identifier *ident, HdrGenState *hgs); 637 void toCBuffer2(OutBuffer *buf, HdrGenState *hgs, int mod);
641 void toDecoBuffer(OutBuffer *buf); 638 void toDecoBuffer(OutBuffer *buf);
642 Expression *getProperty(Loc loc, Identifier *ident); 639 Expression *getProperty(Loc loc, Identifier *ident);
643 TypeInfoDeclaration *getTypeInfoDeclaration(); 640 TypeInfoDeclaration *getTypeInfoDeclaration();
644 }; 641 };
645 642
650 647
651 TypeSlice(Type *next, Expression *lwr, Expression *upr); 648 TypeSlice(Type *next, Expression *lwr, Expression *upr);
652 Type *syntaxCopy(); 649 Type *syntaxCopy();
653 Type *semantic(Loc loc, Scope *sc); 650 Type *semantic(Loc loc, Scope *sc);
654 void resolve(Loc loc, Scope *sc, Expression **pe, Type **pt, Dsymbol **ps); 651 void resolve(Loc loc, Scope *sc, Expression **pe, Type **pt, Dsymbol **ps);
655 void toCBuffer2(OutBuffer *buf, Identifier *ident, HdrGenState *hgs); 652 void toCBuffer2(OutBuffer *buf, HdrGenState *hgs, int mod);
656 }; 653 };
657 654
658 /**************************************************************/ 655 /**************************************************************/
659 656
660 //enum InOut { None, In, Out, InOut, Lazy }; 657 //enum InOut { None, In, Out, InOut, Lazy };