Mercurial > projects > ldc
comparison dmd/mtype.c @ 664:eef8ac26c66c
Some missed LLVMDC -> LDC.
author | Christian Kamm <kamm incasoftware de> |
---|---|
date | Mon, 06 Oct 2008 22:54:08 +0200 |
parents | 50383e476c7e |
children | 30b42a283c8e |
comparison
equal
deleted
inserted
replaced
663:6aaa3d3c1183 | 664:eef8ac26c66c |
---|---|
101 ClassDeclaration *Type::typeinfoenum; | 101 ClassDeclaration *Type::typeinfoenum; |
102 ClassDeclaration *Type::typeinfofunction; | 102 ClassDeclaration *Type::typeinfofunction; |
103 ClassDeclaration *Type::typeinfodelegate; | 103 ClassDeclaration *Type::typeinfodelegate; |
104 ClassDeclaration *Type::typeinfotypelist; | 104 ClassDeclaration *Type::typeinfotypelist; |
105 | 105 |
106 // LLVMDC | 106 // LDC |
107 Type* Type::topaque; | 107 Type* Type::topaque; |
108 | 108 |
109 Type *Type::tvoidptr; | 109 Type *Type::tvoidptr; |
110 Type *Type::basic[TMAX]; | 110 Type *Type::basic[TMAX]; |
111 unsigned char Type::mangleChar[TMAX]; | 111 unsigned char Type::mangleChar[TMAX]; |
208 mangleChar[Terror] = '@'; | 208 mangleChar[Terror] = '@'; |
209 mangleChar[Ttypeof] = '@'; | 209 mangleChar[Ttypeof] = '@'; |
210 mangleChar[Ttuple] = 'B'; | 210 mangleChar[Ttuple] = 'B'; |
211 mangleChar[Tslice] = '@'; | 211 mangleChar[Tslice] = '@'; |
212 | 212 |
213 // LLVMDC | 213 // LDC |
214 mangleChar[Topaque] = 'O'; | 214 mangleChar[Topaque] = 'O'; |
215 | 215 |
216 for (i = 0; i < TMAX; i++) | 216 for (i = 0; i < TMAX; i++) |
217 { if (!mangleChar[i]) | 217 { if (!mangleChar[i]) |
218 fprintf(stdmsg, "ty = %d\n", i); | 218 fprintf(stdmsg, "ty = %d\n", i); |
232 basic[basetab[i]] = new TypeBasic(basetab[i]); | 232 basic[basetab[i]] = new TypeBasic(basetab[i]); |
233 basic[Terror] = basic[Tint32]; | 233 basic[Terror] = basic[Tint32]; |
234 | 234 |
235 tvoidptr = tvoid->pointerTo(); | 235 tvoidptr = tvoid->pointerTo(); |
236 | 236 |
237 // LLVMDC | 237 // LDC |
238 topaque = new TypeOpaque(); | 238 topaque = new TypeOpaque(); |
239 | 239 |
240 // set size_t / ptrdiff_t types and pointer size | 240 // set size_t / ptrdiff_t types and pointer size |
241 if (global.params.is64bit) | 241 if (global.params.is64bit) |
242 { | 242 { |
724 toDecoBuffer(&buf); | 724 toDecoBuffer(&buf); |
725 len = buf.offset; | 725 len = buf.offset; |
726 name = (char *)alloca(19 + sizeof(len) * 3 + len + 1); | 726 name = (char *)alloca(19 + sizeof(len) * 3 + len + 1); |
727 buf.writeByte(0); | 727 buf.writeByte(0); |
728 sprintf(name, "_D%dTypeInfo_%s6__initZ", 9 + len, buf.data); | 728 sprintf(name, "_D%dTypeInfo_%s6__initZ", 9 + len, buf.data); |
729 // LLVMDC | 729 // LDC |
730 // it is not clear where the underscore that's stripped here is added back in | 730 // it is not clear where the underscore that's stripped here is added back in |
731 // if (global.params.isWindows) | 731 // if (global.params.isWindows) |
732 // name++; // C mangling will add it back in | 732 // name++; // C mangling will add it back in |
733 //printf("name = %s\n", name); | 733 //printf("name = %s\n", name); |
734 id = Lexer::idPool(name); | 734 id = Lexer::idPool(name); |
1000 unsigned TypeBasic::alignsize() | 1000 unsigned TypeBasic::alignsize() |
1001 { unsigned sz; | 1001 { unsigned sz; |
1002 | 1002 |
1003 switch (ty) | 1003 switch (ty) |
1004 { | 1004 { |
1005 //LLVMDC: llvm aligns 12 byte reals to 4 byte | 1005 //LDC: llvm aligns 12 byte reals to 4 byte |
1006 case Tfloat80: | 1006 case Tfloat80: |
1007 case Timaginary80: | 1007 case Timaginary80: |
1008 case Tcomplex80: | 1008 case Tcomplex80: |
1009 //sz = REALSIZE; | 1009 //sz = REALSIZE; |
1010 sz = 4; | 1010 sz = 4; |
1011 break; | 1011 break; |
1012 | 1012 |
1013 //LLVMDC: llvm aligns these to 4 byte boundaries | 1013 //LDC: llvm aligns these to 4 byte boundaries |
1014 case Tint64: | 1014 case Tint64: |
1015 case Tuns64: | 1015 case Tuns64: |
1016 case Tfloat64: | 1016 case Tfloat64: |
1017 case Timaginary64: | 1017 case Timaginary64: |
1018 sz = 4; | 1018 sz = 4; |
1552 if (ident == Id::reverse && (n->ty == Tchar || n->ty == Twchar)) | 1552 if (ident == Id::reverse && (n->ty == Tchar || n->ty == Twchar)) |
1553 { | 1553 { |
1554 Expression *ec; | 1554 Expression *ec; |
1555 Expressions *arguments; | 1555 Expressions *arguments; |
1556 | 1556 |
1557 //LLVMDC: Build arguments. | 1557 //LDC: Build arguments. |
1558 static FuncDeclaration *adReverseChar_fd = NULL; | 1558 static FuncDeclaration *adReverseChar_fd = NULL; |
1559 if(!adReverseChar_fd) { | 1559 if(!adReverseChar_fd) { |
1560 Arguments* args = new Arguments; | 1560 Arguments* args = new Arguments; |
1561 Type* arrty = Type::tchar->arrayOf(); | 1561 Type* arrty = Type::tchar->arrayOf(); |
1562 args->push(new Argument(STCin, arrty, NULL, NULL)); | 1562 args->push(new Argument(STCin, arrty, NULL, NULL)); |
1583 else if (ident == Id::sort && (n->ty == Tchar || n->ty == Twchar)) | 1583 else if (ident == Id::sort && (n->ty == Tchar || n->ty == Twchar)) |
1584 { | 1584 { |
1585 Expression *ec; | 1585 Expression *ec; |
1586 Expressions *arguments; | 1586 Expressions *arguments; |
1587 | 1587 |
1588 //LLVMDC: Build arguments. | 1588 //LDC: Build arguments. |
1589 static FuncDeclaration *adSortChar_fd = NULL; | 1589 static FuncDeclaration *adSortChar_fd = NULL; |
1590 if(!adSortChar_fd) { | 1590 if(!adSortChar_fd) { |
1591 Arguments* args = new Arguments; | 1591 Arguments* args = new Arguments; |
1592 Type* arrty = Type::tchar->arrayOf(); | 1592 Type* arrty = Type::tchar->arrayOf(); |
1593 args->push(new Argument(STCin, arrty, NULL, NULL)); | 1593 args->push(new Argument(STCin, arrty, NULL, NULL)); |
1618 int size = next->size(e->loc); | 1618 int size = next->size(e->loc); |
1619 int dup; | 1619 int dup; |
1620 | 1620 |
1621 assert(size); | 1621 assert(size); |
1622 dup = (ident == Id::dup); | 1622 dup = (ident == Id::dup); |
1623 //LLVMDC: Build arguments. | 1623 //LDC: Build arguments. |
1624 static FuncDeclaration *adDup_fd = NULL; | 1624 static FuncDeclaration *adDup_fd = NULL; |
1625 if(!adDup_fd) { | 1625 if(!adDup_fd) { |
1626 Arguments* args = new Arguments; | 1626 Arguments* args = new Arguments; |
1627 args->push(new Argument(STCin, Type::typeinfo->type, NULL, NULL)); | 1627 args->push(new Argument(STCin, Type::typeinfo->type, NULL, NULL)); |
1628 args->push(new Argument(STCin, Type::topaque->arrayOf(), NULL, NULL)); | 1628 args->push(new Argument(STCin, Type::topaque->arrayOf(), NULL, NULL)); |
1654 { | 1654 { |
1655 Expression *ec; | 1655 Expression *ec; |
1656 Expressions *arguments; | 1656 Expressions *arguments; |
1657 bool isBit = (n->ty == Tbit); | 1657 bool isBit = (n->ty == Tbit); |
1658 | 1658 |
1659 //LLVMDC: Build arguments. | 1659 //LDC: Build arguments. |
1660 static FuncDeclaration *adSort_fd = NULL; | 1660 static FuncDeclaration *adSort_fd = NULL; |
1661 if(!adSort_fd) { | 1661 if(!adSort_fd) { |
1662 Arguments* args = new Arguments; | 1662 Arguments* args = new Arguments; |
1663 args->push(new Argument(STCin, Type::topaque->arrayOf(), NULL, NULL)); | 1663 args->push(new Argument(STCin, Type::topaque->arrayOf(), NULL, NULL)); |
1664 args->push(new Argument(STCin, Type::typeinfo->type, NULL, NULL)); | 1664 args->push(new Argument(STCin, Type::typeinfo->type, NULL, NULL)); |
1678 ec = new VarExp(0, adSort_fd); | 1678 ec = new VarExp(0, adSort_fd); |
1679 e = e->castTo(sc, n->arrayOf()); // convert to dynamic array | 1679 e = e->castTo(sc, n->arrayOf()); // convert to dynamic array |
1680 arguments = new Expressions(); | 1680 arguments = new Expressions(); |
1681 arguments->push(e); | 1681 arguments->push(e); |
1682 if (next->ty != Tbit) | 1682 if (next->ty != Tbit) |
1683 arguments->push(n->getTypeInfo(sc)); // LLVMDC, we don't support the getInternalTypeInfo | 1683 arguments->push(n->getTypeInfo(sc)); // LDC, we don't support the getInternalTypeInfo |
1684 // optimization arbitrarily, not yet at least... | 1684 // optimization arbitrarily, not yet at least... |
1685 e = new CallExp(e->loc, ec, arguments); | 1685 e = new CallExp(e->loc, ec, arguments); |
1686 e->type = next->arrayOf(); | 1686 e->type = next->arrayOf(); |
1687 } | 1687 } |
1688 else | 1688 else |
2344 if (ident == Id::length) | 2344 if (ident == Id::length) |
2345 { | 2345 { |
2346 Expression *ec; | 2346 Expression *ec; |
2347 Expressions *arguments; | 2347 Expressions *arguments; |
2348 | 2348 |
2349 //LLVMDC: Build arguments. | 2349 //LDC: Build arguments. |
2350 static FuncDeclaration *aaLen_fd = NULL; | 2350 static FuncDeclaration *aaLen_fd = NULL; |
2351 if(!aaLen_fd) { | 2351 if(!aaLen_fd) { |
2352 Arguments* args = new Arguments; | 2352 Arguments* args = new Arguments; |
2353 args->push(new Argument(STCin, Type::topaque->pointerTo(), NULL, NULL)); | 2353 args->push(new Argument(STCin, Type::topaque->pointerTo(), NULL, NULL)); |
2354 aaLen_fd = FuncDeclaration::genCfunc(args, Type::tsize_t, Id::aaLen); | 2354 aaLen_fd = FuncDeclaration::genCfunc(args, Type::tsize_t, Id::aaLen); |
2365 Expression *ec; | 2365 Expression *ec; |
2366 Expressions *arguments; | 2366 Expressions *arguments; |
2367 int size = key->size(e->loc); | 2367 int size = key->size(e->loc); |
2368 | 2368 |
2369 assert(size); | 2369 assert(size); |
2370 //LLVMDC: Build arguments. | 2370 //LDC: Build arguments. |
2371 static FuncDeclaration *aaKeys_fd = NULL; | 2371 static FuncDeclaration *aaKeys_fd = NULL; |
2372 if(!aaKeys_fd) { | 2372 if(!aaKeys_fd) { |
2373 Arguments* args = new Arguments; | 2373 Arguments* args = new Arguments; |
2374 args->push(new Argument(STCin, Type::topaque->pointerTo(), NULL, NULL)); | 2374 args->push(new Argument(STCin, Type::topaque->pointerTo(), NULL, NULL)); |
2375 args->push(new Argument(STCin, Type::tsize_t, NULL, NULL)); | 2375 args->push(new Argument(STCin, Type::tsize_t, NULL, NULL)); |
2386 else if (ident == Id::values) | 2386 else if (ident == Id::values) |
2387 { | 2387 { |
2388 Expression *ec; | 2388 Expression *ec; |
2389 Expressions *arguments; | 2389 Expressions *arguments; |
2390 | 2390 |
2391 //LLVMDC: Build arguments. | 2391 //LDC: Build arguments. |
2392 static FuncDeclaration *aaValues_fd = NULL; | 2392 static FuncDeclaration *aaValues_fd = NULL; |
2393 if(!aaValues_fd) { | 2393 if(!aaValues_fd) { |
2394 Arguments* args = new Arguments; | 2394 Arguments* args = new Arguments; |
2395 args->push(new Argument(STCin, Type::topaque->pointerTo(), NULL, NULL)); | 2395 args->push(new Argument(STCin, Type::topaque->pointerTo(), NULL, NULL)); |
2396 args->push(new Argument(STCin, Type::tsize_t, NULL, NULL)); | 2396 args->push(new Argument(STCin, Type::tsize_t, NULL, NULL)); |
2411 else if (ident == Id::rehash) | 2411 else if (ident == Id::rehash) |
2412 { | 2412 { |
2413 Expression *ec; | 2413 Expression *ec; |
2414 Expressions *arguments; | 2414 Expressions *arguments; |
2415 | 2415 |
2416 //LLVMDC: Build arguments. | 2416 //LDC: Build arguments. |
2417 static FuncDeclaration *aaRehash_fd = NULL; | 2417 static FuncDeclaration *aaRehash_fd = NULL; |
2418 if(!aaRehash_fd) { | 2418 if(!aaRehash_fd) { |
2419 Arguments* args = new Arguments; | 2419 Arguments* args = new Arguments; |
2420 args->push(new Argument(STCin, Type::topaque->pointerTo(), NULL, NULL)); | 2420 args->push(new Argument(STCin, Type::topaque->pointerTo(), NULL, NULL)); |
2421 args->push(new Argument(STCin, Type::typeinfo->type, NULL, NULL)); | 2421 args->push(new Argument(STCin, Type::typeinfo->type, NULL, NULL)); |
4463 sym->error(e->loc, "'%s' is not a member", v->toChars()); | 4463 sym->error(e->loc, "'%s' is not a member", v->toChars()); |
4464 | 4464 |
4465 // *(&e + offset) | 4465 // *(&e + offset) |
4466 accessCheck(e->loc, sc, e, d); | 4466 accessCheck(e->loc, sc, e, d); |
4467 | 4467 |
4468 // LLVMDC we don't want dot exprs turned into pointer arithmetic. it complicates things for no apparent gain | 4468 // LDC we don't want dot exprs turned into pointer arithmetic. it complicates things for no apparent gain |
4469 #ifndef IN_LLVM | 4469 #ifndef IN_LLVM |
4470 b = new AddrExp(e->loc, e); | 4470 b = new AddrExp(e->loc, e); |
4471 b->type = e->type->pointerTo(); | 4471 b->type = e->type->pointerTo(); |
4472 b = new AddExp(e->loc, b, new IntegerExp(e->loc, v->offset, Type::tint32)); | 4472 b = new AddExp(e->loc, b, new IntegerExp(e->loc, v->offset, Type::tint32)); |
4473 b->type = v->type->pointerTo(); | 4473 b->type = v->type->pointerTo(); |
4728 e->type = t->pointerTo(); | 4728 e->type = t->pointerTo(); |
4729 } | 4729 } |
4730 e = new PtrExp(e->loc, e, t); | 4730 e = new PtrExp(e->loc, e, t); |
4731 } | 4731 } |
4732 | 4732 |
4733 #endif // !LLVMDC | 4733 #endif // !LDC |
4734 | 4734 |
4735 return e; | 4735 return e; |
4736 } | 4736 } |
4737 | 4737 |
4738 if (ident == Id::__vptr) | 4738 if (ident == Id::__vptr) |