Mercurial > projects > ddmd
comparison dmd/Type.d @ 131:206db751bd4c
dmdfe 2.037 compiles now
author | Eldar Insafutdinov <e.insafutdinov@gmail.com> |
---|---|
date | Fri, 10 Sep 2010 00:27:37 +0100 |
parents | 60bb0fe4563e |
children | af1bebfd96a4 |
comparison
equal
deleted
inserted
replaced
130:60bb0fe4563e | 131:206db751bd4c |
---|---|
52 import dmd.TypeClass; | 52 import dmd.TypeClass; |
53 import dmd.TypeTuple; | 53 import dmd.TypeTuple; |
54 import dmd.TypeSlice; | 54 import dmd.TypeSlice; |
55 import dmd.Global; | 55 import dmd.Global; |
56 import dmd.StringValue; | 56 import dmd.StringValue; |
57 import dmd.TRUST; | |
58 import dmd.TemplateDeclaration; | |
59 import dmd.DotIdExp; | |
60 import dmd.AggregateDeclaration; | |
61 import dmd.DotTemplateInstanceExp; | |
62 | |
63 import dmd.expression.Util; | |
57 | 64 |
58 import dmd.backend.Symbol; | 65 import dmd.backend.Symbol; |
59 import dmd.backend.TYPE; | 66 import dmd.backend.TYPE; |
60 import dmd.backend.dt_t; | 67 import dmd.backend.dt_t; |
61 import dmd.backend.Util; | 68 import dmd.backend.Util; |
450 /// // We can add const, but not subtract it | 457 /// // We can add const, but not subtract it |
451 /// if (arg2.type.implicitConvTo(arg1.type) < MATCH.MATCHconst) | 458 /// if (arg2.type.implicitConvTo(arg1.type) < MATCH.MATCHconst) |
452 ///} | 459 ///} |
453 goto Ldistinct; | 460 goto Ldistinct; |
454 } | 461 } |
455 const STC sc = STC.STCref | STC.STCin | STC.STCout | STC.STClazy; | 462 const StorageClass sc = STC.STCref | STC.STCin | STC.STCout | STC.STClazy; |
456 if ((arg1.storageClass & sc) != (arg2.storageClass & sc)) | 463 if ((arg1.storageClass & sc) != (arg2.storageClass & sc)) |
457 inoutmismatch = 1; | 464 inoutmismatch = 1; |
458 // We can add scope, but not subtract it | 465 // We can add scope, but not subtract it |
459 if (!(arg1.storageClass & STC.STCscope) && (arg2.storageClass & STC.STCscope)) | 466 if (!(arg1.storageClass & STC.STCscope) && (arg2.storageClass & STC.STCscope)) |
460 inoutmismatch = 1; | 467 inoutmismatch = 1; |
524 if (t1.isref != t2.isref) | 531 if (t1.isref != t2.isref) |
525 goto Lnotcovariant; | 532 goto Lnotcovariant; |
526 | 533 |
527 /* Can convert safe/trusted to system | 534 /* Can convert safe/trusted to system |
528 */ | 535 */ |
529 if (t1.trust <= TRUST.TRUSTsystem && t2.trust >= TRUSTtrusted) | 536 if (t1.trust <= TRUST.TRUSTsystem && t2.trust >= TRUST.TRUSTtrusted) |
530 goto Lnotcovariant; | 537 goto Lnotcovariant; |
531 | 538 |
532 //printf("\tcovaraint: 1\n"); | 539 //printf("\tcovaraint: 1\n"); |
533 return 1; | 540 return 1; |
534 | 541 |
1420 } | 1427 } |
1421 } | 1428 } |
1422 return t; | 1429 return t; |
1423 } | 1430 } |
1424 | 1431 |
1425 Type addStorageClass(STC stc) | 1432 Type addStorageClass(StorageClass stc) |
1426 { | 1433 { |
1427 /* Just translate to MOD bits and let addMod() do the work | 1434 /* Just translate to MOD bits and let addMod() do the work |
1428 */ | 1435 */ |
1429 MOD mod = MOD.MODundefined; | 1436 MOD mod = MOD.MODundefined; |
1430 | 1437 |
1804 { | 1811 { |
1805 assert(ty == TY.Tstruct || ty == TY.Tclass); | 1812 assert(ty == TY.Tstruct || ty == TY.Tclass); |
1806 AggregateDeclaration sym = toDsymbol(sc).isAggregateDeclaration(); | 1813 AggregateDeclaration sym = toDsymbol(sc).isAggregateDeclaration(); |
1807 assert(sym); | 1814 assert(sym); |
1808 | 1815 |
1809 if (ident != Id.__sizeof && | 1816 if (ident !is Id.__sizeof && |
1810 ident != Id.alignof && | 1817 ident !is Id.alignof_ && |
1811 ident != Id.init && | 1818 ident !is Id.init_ && |
1812 ident != Id.mangleof && | 1819 ident !is Id.mangleof_ && |
1813 ident != Id.stringof && | 1820 ident !is Id.stringof_ && |
1814 ident != Idoffsetof) | 1821 ident !is Id.offsetof) |
1815 { | 1822 { |
1816 /* See if we should forward to the alias this. | 1823 /* See if we should forward to the alias this. |
1817 */ | 1824 */ |
1818 if (sym.aliasthis) | 1825 if (sym.aliasthis) |
1819 { /* Rewrite e.ident as: | 1826 { /* Rewrite e.ident as: |
1830 Dsymbol fd = search_function(sym, Id.opDot); | 1837 Dsymbol fd = search_function(sym, Id.opDot); |
1831 if (fd) | 1838 if (fd) |
1832 { /* Rewrite e.ident as: | 1839 { /* Rewrite e.ident as: |
1833 * e.opDot().ident | 1840 * e.opDot().ident |
1834 */ | 1841 */ |
1835 e = build_overload(e.loc, sc, e, NULL, fd.ident); | 1842 e = build_overload(e.loc, sc, e, null, fd.ident); |
1836 e = new DotIdExp(e.loc, e, ident); | 1843 e = new DotIdExp(e.loc, e, ident); |
1837 return e.semantic(sc); | 1844 return e.semantic(sc); |
1838 } | 1845 } |
1839 | 1846 |
1840 /* Look for overloaded opDispatch to see if we should forward request | 1847 /* Look for overloaded opDispatch to see if we should forward request |