Mercurial > projects > ldc
comparison dmd/declaration.h @ 1146:1860414bf3b7
* Moved ir/irsymbol.cpp/h into ir/irdsymbol.cpp/h.
* Added #if IN_DMD versioning around DMD backend specific code in the D1 frontend, D2 is currently broken.
* All part of a greater cleanup scheme.
author | Tomas Lindquist Olsen <tomas.l.olsen gmail.com> |
---|---|
date | Thu, 26 Mar 2009 20:45:53 +0100 |
parents | eeb8b95ea92e |
children | dbe4af57b240 |
comparison
equal
deleted
inserted
replaced
1145:40caa8207b3e | 1146:1860414bf3b7 |
---|---|
189 #endif | 189 #endif |
190 | 190 |
191 void toDocBuffer(OutBuffer *buf); | 191 void toDocBuffer(OutBuffer *buf); |
192 | 192 |
193 void toObjFile(int multiobj); // compile to .obj file | 193 void toObjFile(int multiobj); // compile to .obj file |
194 #if IN_DMD | |
194 void toDebug(); | 195 void toDebug(); |
195 int cvMember(unsigned char *p); | 196 int cvMember(unsigned char *p); |
197 #endif | |
196 | 198 |
197 TypedefDeclaration *isTypedefDeclaration() { return this; } | 199 TypedefDeclaration *isTypedefDeclaration() { return this; } |
198 | 200 |
201 #if IN_DMD | |
199 Symbol *sinit; | 202 Symbol *sinit; |
200 Symbol *toInitializer(); | 203 Symbol *toInitializer(); |
204 #endif | |
201 }; | 205 }; |
202 | 206 |
203 /**************************************************************/ | 207 /**************************************************************/ |
204 | 208 |
205 struct AliasDeclaration : Declaration | 209 struct AliasDeclaration : Declaration |
262 ExpInitializer *getExpInitializer(); | 266 ExpInitializer *getExpInitializer(); |
263 void checkCtorConstInit(); | 267 void checkCtorConstInit(); |
264 void checkNestedReference(Scope *sc, Loc loc); | 268 void checkNestedReference(Scope *sc, Loc loc); |
265 Dsymbol *toAlias(); | 269 Dsymbol *toAlias(); |
266 | 270 |
271 void toObjFile(int multiobj); // compile to .obj file | |
272 #if IN_DMD | |
267 Symbol *toSymbol(); | 273 Symbol *toSymbol(); |
268 void toObjFile(int multiobj); // compile to .obj file | |
269 int cvMember(unsigned char *p); | 274 int cvMember(unsigned char *p); |
275 #endif | |
270 | 276 |
271 // Eliminate need for dynamic_cast | 277 // Eliminate need for dynamic_cast |
272 VarDeclaration *isVarDeclaration() { return (VarDeclaration *)this; } | 278 VarDeclaration *isVarDeclaration() { return (VarDeclaration *)this; } |
273 | 279 |
280 #if IN_LLVM | |
274 // LDC | 281 // LDC |
275 AnonDeclaration* anonDecl; | 282 AnonDeclaration* anonDecl; |
276 unsigned offset2; | 283 unsigned offset2; |
277 bool nakedUse; | 284 bool nakedUse; |
285 #endif | |
278 }; | 286 }; |
279 | 287 |
280 /**************************************************************/ | 288 /**************************************************************/ |
281 | 289 |
282 // LDC uses this to denote static struct initializers | 290 // LDC uses this to denote static struct initializers |
285 { | 293 { |
286 StructDeclaration *dsym; | 294 StructDeclaration *dsym; |
287 | 295 |
288 StaticStructInitDeclaration(Loc loc, StructDeclaration *dsym); | 296 StaticStructInitDeclaration(Loc loc, StructDeclaration *dsym); |
289 | 297 |
298 #if IN_DMD | |
290 Symbol *toSymbol(); | 299 Symbol *toSymbol(); |
300 #endif | |
291 | 301 |
292 // Eliminate need for dynamic_cast | 302 // Eliminate need for dynamic_cast |
293 StaticStructInitDeclaration *isStaticStructInitDeclaration() { return (StaticStructInitDeclaration *)this; } | 303 StaticStructInitDeclaration *isStaticStructInitDeclaration() { return (StaticStructInitDeclaration *)this; } |
294 }; | 304 }; |
295 | 305 |
301 Dsymbol *syntaxCopy(Dsymbol *); | 311 Dsymbol *syntaxCopy(Dsymbol *); |
302 void semantic(Scope *sc); | 312 void semantic(Scope *sc); |
303 | 313 |
304 void emitComment(Scope *sc); | 314 void emitComment(Scope *sc); |
305 | 315 |
316 #if IN_DMD | |
306 Symbol *toSymbol(); | 317 Symbol *toSymbol(); |
318 #endif | |
307 | 319 |
308 ClassInfoDeclaration* isClassInfoDeclaration() { return this; } | 320 ClassInfoDeclaration* isClassInfoDeclaration() { return this; } |
309 }; | 321 }; |
310 | 322 |
311 struct ModuleInfoDeclaration : VarDeclaration | 323 struct ModuleInfoDeclaration : VarDeclaration |
316 Dsymbol *syntaxCopy(Dsymbol *); | 328 Dsymbol *syntaxCopy(Dsymbol *); |
317 void semantic(Scope *sc); | 329 void semantic(Scope *sc); |
318 | 330 |
319 void emitComment(Scope *sc); | 331 void emitComment(Scope *sc); |
320 | 332 |
333 #if IN_DMD | |
321 Symbol *toSymbol(); | 334 Symbol *toSymbol(); |
335 #endif | |
322 }; | 336 }; |
323 | 337 |
324 struct TypeInfoDeclaration : VarDeclaration | 338 struct TypeInfoDeclaration : VarDeclaration |
325 { | 339 { |
326 Type *tinfo; | 340 Type *tinfo; |
329 Dsymbol *syntaxCopy(Dsymbol *); | 343 Dsymbol *syntaxCopy(Dsymbol *); |
330 void semantic(Scope *sc); | 344 void semantic(Scope *sc); |
331 | 345 |
332 void emitComment(Scope *sc); | 346 void emitComment(Scope *sc); |
333 | 347 |
348 void toObjFile(int multiobj); // compile to .obj file | |
349 #if IN_DMD | |
334 Symbol *toSymbol(); | 350 Symbol *toSymbol(); |
335 void toObjFile(int multiobj); // compile to .obj file | |
336 virtual void toDt(dt_t **pdt); | 351 virtual void toDt(dt_t **pdt); |
352 #endif | |
337 | 353 |
338 virtual TypeInfoDeclaration* isTypeInfoDeclaration() { return this; } | 354 virtual TypeInfoDeclaration* isTypeInfoDeclaration() { return this; } |
339 | 355 |
356 #if IN_LLVM | |
340 // LDC | 357 // LDC |
341 virtual void llvmDeclare(); | 358 virtual void llvmDeclare(); |
342 virtual void llvmDefine(); | 359 virtual void llvmDefine(); |
360 #endif | |
343 }; | 361 }; |
344 | 362 |
345 struct TypeInfoStructDeclaration : TypeInfoDeclaration | 363 struct TypeInfoStructDeclaration : TypeInfoDeclaration |
346 { | 364 { |
347 TypeInfoStructDeclaration(Type *tinfo); | 365 TypeInfoStructDeclaration(Type *tinfo); |
348 | 366 |
349 void toDt(dt_t **pdt); | 367 #if IN_DMD |
350 | 368 void toDt(dt_t **pdt); |
351 // LDC | 369 #endif |
352 void llvmDeclare(); | 370 |
353 void llvmDefine(); | 371 #if IN_LLVM |
372 // LDC | |
373 void llvmDeclare(); | |
374 void llvmDefine(); | |
375 #endif | |
354 }; | 376 }; |
355 | 377 |
356 struct TypeInfoClassDeclaration : TypeInfoDeclaration | 378 struct TypeInfoClassDeclaration : TypeInfoDeclaration |
357 { | 379 { |
358 TypeInfoClassDeclaration(Type *tinfo); | 380 TypeInfoClassDeclaration(Type *tinfo); |
359 | 381 |
360 void toDt(dt_t **pdt); | 382 #if IN_DMD |
361 | 383 void toDt(dt_t **pdt); |
362 // LDC | 384 #endif |
363 void llvmDeclare(); | 385 |
364 void llvmDefine(); | 386 #if IN_LLVM |
387 // LDC | |
388 void llvmDeclare(); | |
389 void llvmDefine(); | |
390 #endif | |
365 }; | 391 }; |
366 | 392 |
367 struct TypeInfoInterfaceDeclaration : TypeInfoDeclaration | 393 struct TypeInfoInterfaceDeclaration : TypeInfoDeclaration |
368 { | 394 { |
369 TypeInfoInterfaceDeclaration(Type *tinfo); | 395 TypeInfoInterfaceDeclaration(Type *tinfo); |
370 | 396 |
371 void toDt(dt_t **pdt); | 397 #if IN_DMD |
372 | 398 void toDt(dt_t **pdt); |
373 // LDC | 399 #endif |
374 void llvmDeclare(); | 400 |
375 void llvmDefine(); | 401 #if IN_LLVM |
402 // LDC | |
403 void llvmDeclare(); | |
404 void llvmDefine(); | |
405 #endif | |
376 }; | 406 }; |
377 | 407 |
378 struct TypeInfoTypedefDeclaration : TypeInfoDeclaration | 408 struct TypeInfoTypedefDeclaration : TypeInfoDeclaration |
379 { | 409 { |
380 TypeInfoTypedefDeclaration(Type *tinfo); | 410 TypeInfoTypedefDeclaration(Type *tinfo); |
381 | 411 |
382 void toDt(dt_t **pdt); | 412 #if IN_DMD |
383 | 413 void toDt(dt_t **pdt); |
384 // LDC | 414 #endif |
385 void llvmDeclare(); | 415 |
386 void llvmDefine(); | 416 #if IN_LLVM |
417 // LDC | |
418 void llvmDeclare(); | |
419 void llvmDefine(); | |
420 #endif | |
387 }; | 421 }; |
388 | 422 |
389 struct TypeInfoPointerDeclaration : TypeInfoDeclaration | 423 struct TypeInfoPointerDeclaration : TypeInfoDeclaration |
390 { | 424 { |
391 TypeInfoPointerDeclaration(Type *tinfo); | 425 TypeInfoPointerDeclaration(Type *tinfo); |
392 | 426 |
393 void toDt(dt_t **pdt); | 427 #if IN_DMD |
394 | 428 void toDt(dt_t **pdt); |
395 // LDC | 429 #endif |
396 void llvmDeclare(); | 430 |
397 void llvmDefine(); | 431 #if IN_LLVM |
432 // LDC | |
433 void llvmDeclare(); | |
434 void llvmDefine(); | |
435 #endif | |
398 }; | 436 }; |
399 | 437 |
400 struct TypeInfoArrayDeclaration : TypeInfoDeclaration | 438 struct TypeInfoArrayDeclaration : TypeInfoDeclaration |
401 { | 439 { |
402 TypeInfoArrayDeclaration(Type *tinfo); | 440 TypeInfoArrayDeclaration(Type *tinfo); |
403 | 441 |
404 void toDt(dt_t **pdt); | 442 #if IN_DMD |
405 | 443 void toDt(dt_t **pdt); |
406 // LDC | 444 #endif |
407 void llvmDeclare(); | 445 |
408 void llvmDefine(); | 446 #if IN_LLVM |
447 // LDC | |
448 void llvmDeclare(); | |
449 void llvmDefine(); | |
450 #endif | |
409 }; | 451 }; |
410 | 452 |
411 struct TypeInfoStaticArrayDeclaration : TypeInfoDeclaration | 453 struct TypeInfoStaticArrayDeclaration : TypeInfoDeclaration |
412 { | 454 { |
413 TypeInfoStaticArrayDeclaration(Type *tinfo); | 455 TypeInfoStaticArrayDeclaration(Type *tinfo); |
414 | 456 |
415 void toDt(dt_t **pdt); | 457 #if IN_DMD |
416 | 458 void toDt(dt_t **pdt); |
417 // LDC | 459 #endif |
418 void llvmDeclare(); | 460 |
419 void llvmDefine(); | 461 #if IN_LLVM |
462 // LDC | |
463 void llvmDeclare(); | |
464 void llvmDefine(); | |
465 #endif | |
420 }; | 466 }; |
421 | 467 |
422 struct TypeInfoAssociativeArrayDeclaration : TypeInfoDeclaration | 468 struct TypeInfoAssociativeArrayDeclaration : TypeInfoDeclaration |
423 { | 469 { |
424 TypeInfoAssociativeArrayDeclaration(Type *tinfo); | 470 TypeInfoAssociativeArrayDeclaration(Type *tinfo); |
425 | 471 |
426 void toDt(dt_t **pdt); | 472 #if IN_DMD |
427 | 473 void toDt(dt_t **pdt); |
428 // LDC | 474 #endif |
429 void llvmDeclare(); | 475 |
430 void llvmDefine(); | 476 #if IN_LLVM |
477 // LDC | |
478 void llvmDeclare(); | |
479 void llvmDefine(); | |
480 #endif | |
431 }; | 481 }; |
432 | 482 |
433 struct TypeInfoEnumDeclaration : TypeInfoDeclaration | 483 struct TypeInfoEnumDeclaration : TypeInfoDeclaration |
434 { | 484 { |
435 TypeInfoEnumDeclaration(Type *tinfo); | 485 TypeInfoEnumDeclaration(Type *tinfo); |
436 | 486 |
437 void toDt(dt_t **pdt); | 487 #if IN_DMD |
438 | 488 void toDt(dt_t **pdt); |
439 // LDC | 489 #endif |
440 void llvmDeclare(); | 490 |
441 void llvmDefine(); | 491 #if IN_LLVM |
492 // LDC | |
493 void llvmDeclare(); | |
494 void llvmDefine(); | |
495 #endif | |
442 }; | 496 }; |
443 | 497 |
444 struct TypeInfoFunctionDeclaration : TypeInfoDeclaration | 498 struct TypeInfoFunctionDeclaration : TypeInfoDeclaration |
445 { | 499 { |
446 TypeInfoFunctionDeclaration(Type *tinfo); | 500 TypeInfoFunctionDeclaration(Type *tinfo); |
447 | 501 |
448 void toDt(dt_t **pdt); | 502 #if IN_DMD |
449 | 503 void toDt(dt_t **pdt); |
450 // LDC | 504 #endif |
451 void llvmDeclare(); | 505 |
452 void llvmDefine(); | 506 #if IN_LLVM |
507 // LDC | |
508 void llvmDeclare(); | |
509 void llvmDefine(); | |
510 #endif | |
453 }; | 511 }; |
454 | 512 |
455 struct TypeInfoDelegateDeclaration : TypeInfoDeclaration | 513 struct TypeInfoDelegateDeclaration : TypeInfoDeclaration |
456 { | 514 { |
457 TypeInfoDelegateDeclaration(Type *tinfo); | 515 TypeInfoDelegateDeclaration(Type *tinfo); |
458 | 516 |
459 void toDt(dt_t **pdt); | 517 #if IN_DMD |
460 | 518 void toDt(dt_t **pdt); |
461 // LDC | 519 #endif |
462 void llvmDeclare(); | 520 |
463 void llvmDefine(); | 521 #if IN_LLVM |
522 // LDC | |
523 void llvmDeclare(); | |
524 void llvmDefine(); | |
525 #endif | |
464 }; | 526 }; |
465 | 527 |
466 struct TypeInfoTupleDeclaration : TypeInfoDeclaration | 528 struct TypeInfoTupleDeclaration : TypeInfoDeclaration |
467 { | 529 { |
468 TypeInfoTupleDeclaration(Type *tinfo); | 530 TypeInfoTupleDeclaration(Type *tinfo); |
469 | 531 |
470 void toDt(dt_t **pdt); | 532 #if IN_DMD |
471 | 533 void toDt(dt_t **pdt); |
472 // LDC | 534 #endif |
473 void llvmDeclare(); | 535 |
474 void llvmDefine(); | 536 #if IN_LLVM |
537 // LDC | |
538 void llvmDeclare(); | |
539 void llvmDefine(); | |
540 #endif | |
475 }; | 541 }; |
476 | 542 |
477 #if DMDV2 | 543 #if DMDV2 |
478 struct TypeInfoConstDeclaration : TypeInfoDeclaration | 544 struct TypeInfoConstDeclaration : TypeInfoDeclaration |
479 { | 545 { |
480 TypeInfoConstDeclaration(Type *tinfo); | 546 TypeInfoConstDeclaration(Type *tinfo); |
481 | 547 |
482 void toDt(dt_t **pdt); | 548 #if IN_DMD |
483 | 549 void toDt(dt_t **pdt); |
484 // LDC | 550 #endif |
485 void llvmDeclare(); | 551 |
486 void llvmDefine(); | 552 #if IN_LLVM |
553 // LDC | |
554 void llvmDeclare(); | |
555 void llvmDefine(); | |
556 #endif | |
487 }; | 557 }; |
488 | 558 |
489 struct TypeInfoInvariantDeclaration : TypeInfoDeclaration | 559 struct TypeInfoInvariantDeclaration : TypeInfoDeclaration |
490 { | 560 { |
491 TypeInfoInvariantDeclaration(Type *tinfo); | 561 TypeInfoInvariantDeclaration(Type *tinfo); |
492 | 562 |
493 void toDt(dt_t **pdt); | 563 #if IN_DMD |
494 | 564 void toDt(dt_t **pdt); |
495 // LDC | 565 #endif |
496 void llvmDeclare(); | 566 |
497 void llvmDefine(); | 567 #if IN_LLVM |
568 // LDC | |
569 void llvmDeclare(); | |
570 void llvmDefine(); | |
571 #endif | |
498 }; | 572 }; |
499 #endif | 573 #endif |
500 | 574 |
501 /**************************************************************/ | 575 /**************************************************************/ |
502 | 576 |
576 // 8 if there's inline asm | 650 // 8 if there's inline asm |
577 | 651 |
578 // Support for NRVO (named return value optimization) | 652 // Support for NRVO (named return value optimization) |
579 int nrvo_can; // !=0 means we can do it | 653 int nrvo_can; // !=0 means we can do it |
580 VarDeclaration *nrvo_var; // variable to replace with shidden | 654 VarDeclaration *nrvo_var; // variable to replace with shidden |
655 #if IN_DMD | |
581 Symbol *shidden; // hidden pointer passed to function | 656 Symbol *shidden; // hidden pointer passed to function |
657 #endif | |
582 | 658 |
583 #if DMDV2 | 659 #if DMDV2 |
584 enum BUILTIN builtin; // set if this is a known, builtin | 660 enum BUILTIN builtin; // set if this is a known, builtin |
585 // function we can evaluate at compile | 661 // function we can evaluate at compile |
586 // time | 662 // time |
635 | 711 |
636 // LDC: give argument types to runtime functions | 712 // LDC: give argument types to runtime functions |
637 static FuncDeclaration *genCfunc(Arguments *args, Type *treturn, const char *name); | 713 static FuncDeclaration *genCfunc(Arguments *args, Type *treturn, const char *name); |
638 static FuncDeclaration *genCfunc(Arguments *args, Type *treturn, Identifier *id); | 714 static FuncDeclaration *genCfunc(Arguments *args, Type *treturn, Identifier *id); |
639 | 715 |
716 #if IN_DMD | |
640 Symbol *toSymbol(); | 717 Symbol *toSymbol(); |
641 Symbol *toThunkSymbol(int offset); // thunk version | 718 Symbol *toThunkSymbol(int offset); // thunk version |
719 #endif | |
642 void toObjFile(int multiobj); // compile to .obj file | 720 void toObjFile(int multiobj); // compile to .obj file |
721 #if IN_DMD | |
643 int cvMember(unsigned char *p); | 722 int cvMember(unsigned char *p); |
723 #endif | |
644 | 724 |
645 FuncDeclaration *isFuncDeclaration() { return this; } | 725 FuncDeclaration *isFuncDeclaration() { return this; } |
646 | 726 |
727 #if IN_LLVM | |
647 // LDC stuff | 728 // LDC stuff |
648 | 729 |
649 // vars declared in this function that nested funcs reference | 730 // vars declared in this function that nested funcs reference |
650 // is this is not empty, nestedFrameRef is set and these VarDecls | 731 // is this is not empty, nestedFrameRef is set and these VarDecls |
651 // probably have nestedref set too, see VarDeclaration::checkNestedReference | 732 // probably have nestedref set too, see VarDeclaration::checkNestedReference |
664 // if this is an array operation it gets a little special attention | 745 // if this is an array operation it gets a little special attention |
665 bool isArrayOp; | 746 bool isArrayOp; |
666 | 747 |
667 // true if overridden with the pragma(allow_inline); stmt | 748 // true if overridden with the pragma(allow_inline); stmt |
668 bool allowInlining; | 749 bool allowInlining; |
750 #endif | |
669 }; | 751 }; |
670 | 752 |
671 struct FuncAliasDeclaration : FuncDeclaration | 753 struct FuncAliasDeclaration : FuncDeclaration |
672 { | 754 { |
673 FuncDeclaration *funcalias; | 755 FuncDeclaration *funcalias; |
674 | 756 |
675 FuncAliasDeclaration(FuncDeclaration *funcalias); | 757 FuncAliasDeclaration(FuncDeclaration *funcalias); |
676 | 758 |
677 FuncAliasDeclaration *isFuncAliasDeclaration() { return this; } | 759 FuncAliasDeclaration *isFuncAliasDeclaration() { return this; } |
678 const char *kind(); | 760 const char *kind(); |
761 #if IN_DMD | |
679 Symbol *toSymbol(); | 762 Symbol *toSymbol(); |
763 #endif | |
680 }; | 764 }; |
681 | 765 |
682 struct FuncLiteralDeclaration : FuncDeclaration | 766 struct FuncLiteralDeclaration : FuncDeclaration |
683 { | 767 { |
684 enum TOK tok; // TOKfunction or TOKdelegate | 768 enum TOK tok; // TOKfunction or TOKdelegate |