Mercurial > projects > ldc
comparison dmd/expression.c @ 305:2b72433d5c8c trunk
[svn r326] Fixed a bunch of issues with printf's that MinGW32 did not support.
Fixed problems with label collisions when using labels inside inline asm. LabelStatement is now easily reached given its
Identifier, which should be useful elsewhere too.
Enabled inline asm for building the lib/compiler/llvmdc runtime code, fixing branches out of asm makes this possible.
author | lindquist |
---|---|
date | Fri, 27 Jun 2008 22:04:35 +0200 |
parents | 297690b5d4a5 |
children | 7086a84ab3d6 |
comparison
equal
deleted
inserted
replaced
304:3ebc136702dd | 305:2b72433d5c8c |
---|---|
403 assert(arguments); | 403 assert(arguments); |
404 size_t nargs = arguments ? arguments->dim : 0; | 404 size_t nargs = arguments ? arguments->dim : 0; |
405 size_t nparams = Argument::dim(tf->parameters); | 405 size_t nparams = Argument::dim(tf->parameters); |
406 | 406 |
407 if (nargs > nparams && tf->varargs == 0) | 407 if (nargs > nparams && tf->varargs == 0) |
408 error(loc, "expected %zu arguments, not %zu", nparams, nargs); | 408 error(loc, "expected %"PRIuSIZE" arguments, not %"PRIuSIZE, nparams, nargs); |
409 | 409 |
410 n = (nargs > nparams) ? nargs : nparams; // n = max(nargs, nparams) | 410 n = (nargs > nparams) ? nargs : nparams; // n = max(nargs, nparams) |
411 | 411 |
412 done = 0; | 412 done = 0; |
413 for (size_t i = 0; i < n; i++) | 413 for (size_t i = 0; i < n; i++) |
427 { | 427 { |
428 if (!p->defaultArg) | 428 if (!p->defaultArg) |
429 { | 429 { |
430 if (tf->varargs == 2 && i + 1 == nparams) | 430 if (tf->varargs == 2 && i + 1 == nparams) |
431 goto L2; | 431 goto L2; |
432 error(loc, "expected %zu arguments, not %zu", nparams, nargs); | 432 error(loc, "expected %"PRIuSIZE" arguments, not %"PRIuSIZE, nparams, nargs); |
433 break; | 433 break; |
434 } | 434 } |
435 arg = p->defaultArg->copy(); | 435 arg = p->defaultArg->copy(); |
436 arguments->push(arg); | 436 arguments->push(arg); |
437 nargs++; | 437 nargs++; |
441 { | 441 { |
442 //printf("\t\tvarargs == 2, p->type = '%s'\n", p->type->toChars()); | 442 //printf("\t\tvarargs == 2, p->type = '%s'\n", p->type->toChars()); |
443 if (arg->implicitConvTo(p->type)) | 443 if (arg->implicitConvTo(p->type)) |
444 { | 444 { |
445 if (nargs != nparams) | 445 if (nargs != nparams) |
446 error(loc, "expected %zu arguments, not %zu", nparams, nargs); | 446 error(loc, "expected %"PRIuSIZE" arguments, not %"PRIuSIZE, nparams, nargs); |
447 goto L1; | 447 goto L1; |
448 } | 448 } |
449 L2: | 449 L2: |
450 Type *tb = p->type->toBasetype(); | 450 Type *tb = p->type->toBasetype(); |
451 Type *tret = p->isLazyArray(); | 451 Type *tret = p->isLazyArray(); |
1048 { | 1048 { |
1049 #if 1 | 1049 #if 1 |
1050 return Expression::toChars(); | 1050 return Expression::toChars(); |
1051 #else | 1051 #else |
1052 static char buffer[sizeof(value) * 3 + 1]; | 1052 static char buffer[sizeof(value) * 3 + 1]; |
1053 | 1053 sprintf(buffer, "%lld", value); |
1054 sprintf(buffer, "%jd", value); | |
1055 return buffer; | 1054 return buffer; |
1056 #endif | 1055 #endif |
1057 } | 1056 } |
1058 | 1057 |
1059 integer_t IntegerExp::toInteger() | 1058 integer_t IntegerExp::toInteger() |
1226 L3: | 1225 L3: |
1227 buf->printf("%du", (unsigned)v); | 1226 buf->printf("%du", (unsigned)v); |
1228 break; | 1227 break; |
1229 | 1228 |
1230 case Tint64: | 1229 case Tint64: |
1231 buf->printf("%jdL", v); | 1230 buf->printf("%lldL", v); |
1232 break; | 1231 break; |
1233 | 1232 |
1234 case Tuns64: | 1233 case Tuns64: |
1235 buf->printf("%juLU", v); | 1234 buf->printf("%lluLU", v); |
1236 break; | 1235 break; |
1237 | 1236 |
1238 case Tbit: | 1237 case Tbit: |
1239 case Tbool: | 1238 case Tbool: |
1240 buf->writestring((char *)(v ? "true" : "false")); | 1239 buf->writestring((char *)(v ? "true" : "false")); |
1252 #endif | 1251 #endif |
1253 assert(0); | 1252 assert(0); |
1254 } | 1253 } |
1255 } | 1254 } |
1256 else if (v & 0x8000000000000000LL) | 1255 else if (v & 0x8000000000000000LL) |
1257 buf->printf("0x%jx", v); | 1256 buf->printf("0x%llx", v); |
1258 else | 1257 else |
1259 buf->printf("%jd", v); | 1258 buf->printf("%lld", v); |
1260 } | 1259 } |
1261 | 1260 |
1262 void IntegerExp::toMangleBuffer(OutBuffer *buf) | 1261 void IntegerExp::toMangleBuffer(OutBuffer *buf) |
1263 { | 1262 { |
1264 if ((sinteger_t)value < 0) | 1263 if ((sinteger_t)value < 0) |
1265 buf->printf("N%jd", -value); | 1264 buf->printf("N%lld", -value); |
1266 else | 1265 else |
1267 buf->printf("%jd", value); | 1266 buf->printf("%lld", value); |
1268 } | 1267 } |
1269 | 1268 |
1270 /******************************** RealExp **************************/ | 1269 /******************************** RealExp **************************/ |
1271 | 1270 |
1272 RealExp::RealExp(Loc loc, real_t value, Type *type) | 1271 RealExp::RealExp(Loc loc, real_t value, Type *type) |
6467 } | 6466 } |
6468 e = e->semantic(sc); | 6467 e = e->semantic(sc); |
6469 } | 6468 } |
6470 else | 6469 else |
6471 { | 6470 { |
6472 error("string slice [%ju .. %ju] is out of bounds", i1, i2); | 6471 error("string slice [%llu .. %llu] is out of bounds", i1, i2); |
6473 e = e1; | 6472 e = e1; |
6474 } | 6473 } |
6475 return e; | 6474 return e; |
6476 } | 6475 } |
6477 | 6476 |
6826 else | 6825 else |
6827 e = new TypeExp(e1->loc, Argument::getNth(tup->arguments, (size_t)index)->type); | 6826 e = new TypeExp(e1->loc, Argument::getNth(tup->arguments, (size_t)index)->type); |
6828 } | 6827 } |
6829 else | 6828 else |
6830 { | 6829 { |
6831 error("array index [%ju] is outside array bounds [0 .. %zu]", | 6830 error("array index [%llu] is outside array bounds [0 .. %"PRIuSIZE"]", |
6832 index, length); | 6831 index, length); |
6833 e = e1; | 6832 e = e1; |
6834 } | 6833 } |
6835 break; | 6834 break; |
6836 } | 6835 } |
6837 | 6836 |
6838 default: | 6837 default: |