Mercurial > projects > ldc
comparison dmd/expression.c @ 130:a7dfa0ed966c trunk
[svn r134] Merged the DMD 1.024 frontend.
Added std.base64.
author | lindquist |
---|---|
date | Fri, 28 Dec 2007 23:52:40 +0100 |
parents | 288fe1029e1f |
children | 5825d48b27d1 |
comparison
equal
deleted
inserted
replaced
129:8096ba7082db | 130:a7dfa0ed966c |
---|---|
1268 this->type = type; | 1268 this->type = type; |
1269 } | 1269 } |
1270 | 1270 |
1271 char *RealExp::toChars() | 1271 char *RealExp::toChars() |
1272 { | 1272 { |
1273 static char buffer[sizeof(value) * 3 + 8 + 1 + 1]; | 1273 char buffer[sizeof(value) * 3 + 8 + 1 + 1]; |
1274 | 1274 |
1275 #ifdef IN_GCC | 1275 #ifdef IN_GCC |
1276 value.format(buffer, sizeof(buffer)); | 1276 value.format(buffer, sizeof(buffer)); |
1277 if (type->isimaginary()) | 1277 if (type->isimaginary()) |
1278 strcat(buffer, "i"); | 1278 strcat(buffer, "i"); |
1279 #else | 1279 #else |
1280 sprintf(buffer, type->isimaginary() ? "%Lgi" : "%Lg", value); | 1280 sprintf(buffer, type->isimaginary() ? "%Lgi" : "%Lg", value); |
1281 #endif | 1281 #endif |
1282 assert(strlen(buffer) < sizeof(buffer)); | 1282 assert(strlen(buffer) < sizeof(buffer)); |
1283 return buffer; | 1283 return mem.strdup(buffer); |
1284 } | 1284 } |
1285 | 1285 |
1286 integer_t RealExp::toInteger() | 1286 integer_t RealExp::toInteger() |
1287 { | 1287 { |
1288 #ifdef IN_GCC | 1288 #ifdef IN_GCC |
1482 //printf("ComplexExp::ComplexExp(%s)\n", toChars()); | 1482 //printf("ComplexExp::ComplexExp(%s)\n", toChars()); |
1483 } | 1483 } |
1484 | 1484 |
1485 char *ComplexExp::toChars() | 1485 char *ComplexExp::toChars() |
1486 { | 1486 { |
1487 static char buffer[sizeof(value) * 3 + 8 + 1]; | 1487 char buffer[sizeof(value) * 3 + 8 + 1]; |
1488 | 1488 |
1489 #ifdef IN_GCC | 1489 #ifdef IN_GCC |
1490 char buf1[sizeof(value) * 3 + 8 + 1]; | 1490 char buf1[sizeof(value) * 3 + 8 + 1]; |
1491 char buf2[sizeof(value) * 3 + 8 + 1]; | 1491 char buf2[sizeof(value) * 3 + 8 + 1]; |
1492 creall(value).format(buf1, sizeof(buf1)); | 1492 creall(value).format(buf1, sizeof(buf1)); |
1494 sprintf(buffer, "(%s+%si)", buf1, buf2); | 1494 sprintf(buffer, "(%s+%si)", buf1, buf2); |
1495 #else | 1495 #else |
1496 sprintf(buffer, "(%Lg+%Lgi)", creall(value), cimagl(value)); | 1496 sprintf(buffer, "(%Lg+%Lgi)", creall(value), cimagl(value)); |
1497 assert(strlen(buffer) < sizeof(buffer)); | 1497 assert(strlen(buffer) < sizeof(buffer)); |
1498 #endif | 1498 #endif |
1499 return buffer; | 1499 return mem.strdup(buffer); |
1500 } | 1500 } |
1501 | 1501 |
1502 integer_t ComplexExp::toInteger() | 1502 integer_t ComplexExp::toInteger() |
1503 { | 1503 { |
1504 #ifdef IN_GCC | 1504 #ifdef IN_GCC |
3138 TypeClass *tc = (TypeClass *)(tb); | 3138 TypeClass *tc = (TypeClass *)(tb); |
3139 ClassDeclaration *cd = tc->sym->isClassDeclaration(); | 3139 ClassDeclaration *cd = tc->sym->isClassDeclaration(); |
3140 if (cd->isInterfaceDeclaration()) | 3140 if (cd->isInterfaceDeclaration()) |
3141 error("cannot create instance of interface %s", cd->toChars()); | 3141 error("cannot create instance of interface %s", cd->toChars()); |
3142 else if (cd->isAbstract()) | 3142 else if (cd->isAbstract()) |
3143 error("cannot create instance of abstract class %s", cd->toChars()); | 3143 { error("cannot create instance of abstract class %s", cd->toChars()); |
3144 for (int i = 0; i < cd->vtbl.dim; i++) | |
3145 { FuncDeclaration *fd = ((Dsymbol *)cd->vtbl.data[i])->isFuncDeclaration(); | |
3146 if (fd && fd->isAbstract()) | |
3147 error("function %s is abstract", fd->toChars()); | |
3148 } | |
3149 } | |
3144 checkDeprecated(sc, cd); | 3150 checkDeprecated(sc, cd); |
3145 if (cd->isNested()) | 3151 if (cd->isNested()) |
3146 { /* We need a 'this' pointer for the nested class. | 3152 { /* We need a 'this' pointer for the nested class. |
3147 * Ensure we have the right one. | 3153 * Ensure we have the right one. |
3148 */ | 3154 */ |
5526 else | 5532 else |
5527 { dte = (DotTemplateExp *)(e1); | 5533 { dte = (DotTemplateExp *)(e1); |
5528 TemplateDeclaration *td = dte->td; | 5534 TemplateDeclaration *td = dte->td; |
5529 assert(td); | 5535 assert(td); |
5530 if (!arguments) | 5536 if (!arguments) |
5531 // Should fix deduce() so it works on NULL argument | 5537 // Should fix deduceFunctionTemplate() so it works on NULL argument |
5532 arguments = new Expressions(); | 5538 arguments = new Expressions(); |
5533 f = td->deduce(sc, loc, NULL, arguments); | 5539 f = td->deduceFunctionTemplate(sc, loc, NULL, arguments); |
5534 if (!f) | 5540 if (!f) |
5535 { type = Type::terror; | 5541 { type = Type::terror; |
5536 return this; | 5542 return this; |
5537 } | 5543 } |
5538 ad = td->toParent()->isAggregateDeclaration(); | 5544 ad = td->toParent()->isAggregateDeclaration(); |
5703 e1 = e; | 5709 e1 = e; |
5704 } | 5710 } |
5705 else if (e1->op == TOKtemplate) | 5711 else if (e1->op == TOKtemplate) |
5706 { | 5712 { |
5707 TemplateExp *te = (TemplateExp *)e1; | 5713 TemplateExp *te = (TemplateExp *)e1; |
5708 f = te->td->deduce(sc, loc, NULL, arguments); | 5714 f = te->td->deduceFunctionTemplate(sc, loc, NULL, arguments); |
5709 if (!f) | 5715 if (!f) |
5710 { type = Type::terror; | 5716 { type = Type::terror; |
5711 return this; | 5717 return this; |
5712 } | 5718 } |
5713 if (f->needThis() && hasThis(sc)) | 5719 if (f->needThis() && hasThis(sc)) |