| @@ -4453,80 +4453,83 @@ static void expr_or(void) · 4452 unmodified lines |
| 4453 | } | 4453 | } |
| 4454 | } | 4454 | } |
| 4455 | | 4455 | |
| 4456 | /* XXX: fix this mess */ | | |
| 4457 | static void expr_land_const(void) | | |
| 4458 | { | | |
| 4459 | expr_or(); | | |
| 4460 | while (tok == TOK_LAND) { | | |
| 4461 | next(); | | |
| 4462 | expr_or(); | | |
| 4463 | gen_op(TOK_LAND); | | |
| 4464 | } | | |
| 4465 | } | | |
| 4466 | | | |
| 4467 | /* XXX: fix this mess */ | | |
| 4468 | static void expr_lor_const(void) | | |
| 4469 | { | | |
| 4470 | expr_land_const(); | | |
| 4471 | while (tok == TOK_LOR) { | | |
| 4472 | next(); | | |
| 4473 | expr_land_const(); | | |
| 4474 | gen_op(TOK_LOR); | | |
| 4475 | } | | |
| 4476 | } | | |
| 4477 | | | |
| 4478 | /* only used if non constant */ | | |
| 4479 | static void expr_land(void) | 4456 | static void expr_land(void) |
| 4480 | { | 4457 | { |
| 4481 | int t; | | |
| 4482 | | | |
| 4483 | expr_or(); | 4458 | expr_or(); |
| 4484 | if (tok == TOK_LAND) { | 4459 | if (tok == TOK_LAND) { |
| 4485 | t = 0; | 4460 | if ((vtop->r & (VT_VALMASK | VT_LVAL | VT_SYM)) == VT_CONST) { |
| 4486 | save_regs(1); | 4461 | CType ctb, cti; |
| 4487 | for(;;) { | 4462 | ctb.t = VT_BOOL; |
| 4488 | t = gvtst(1, t); | 4463 | cti.t = VT_INT; |
| 4489 | if (tok != TOK_LAND) { | | |
| 4490 | vseti(VT_JMPI, t); | | |
| 4491 | break; | | |
| 4492 | } | | |
| 4493 | next(); | 4464 | next(); |
| 4494 | expr_or(); | 4465 | gen_cast(&ctb); |
| | 4466 | if (vtop->c.i) { |
| | 4467 | vpop(); |
| | 4468 | expr_land(); |
| | 4469 | gen_cast(&ctb); |
| | 4470 | } else { |
| | 4471 | expr_land(); |
| | 4472 | vpop(); |
| | 4473 | } |
| | 4474 | gen_cast(&cti); |
| | 4475 | } else { |
| | 4476 | int t = 0; |
| | 4477 | save_regs(1); |
| | 4478 | for(;;) { |
| | 4479 | t = gvtst(1, t); |
| | 4480 | if (tok != TOK_LAND) { |
| | 4481 | vseti(VT_JMPI, t); |
| | 4482 | break; |
| | 4483 | } |
| | 4484 | next(); |
| | 4485 | expr_or(); |
| | 4486 | } |
| 4495 | } | 4487 | } |
| 4496 | } | 4488 | } |
| 4497 | } | 4489 | } |
| 4498 | | 4490 | |
| 4499 | static void expr_lor(void) | 4491 | static void expr_lor(void) |
| 4500 | { | 4492 | { |
| 4501 | int t; | | |
| 4502 | | | |
| 4503 | expr_land(); | 4493 | expr_land(); |
| 4504 | if (tok == TOK_LOR) { | 4494 | if (tok == TOK_LOR) { |
| 4505 | t = 0; | 4495 | if ((vtop->r & (VT_VALMASK | VT_LVAL | VT_SYM)) == VT_CONST) { |
| 4506 | save_regs(1); | 4496 | CType ctb, cti; |
| 4507 | for(;;) { | 4497 | ctb.t = VT_BOOL; |
| 4508 | t = gvtst(0, t); | 4498 | cti.t = VT_INT; |
| 4509 | if (tok != TOK_LOR) { | | |
| 4510 | vseti(VT_JMP, t); | | |
| 4511 | break; | | |
| 4512 | } | | |
| 4513 | next(); | 4499 | next(); |
| 4514 | expr_land(); | 4500 | gen_cast(&ctb); |
| | 4501 | if (vtop->c.i) { |
| | 4502 | expr_lor(); |
| | 4503 | vpop(); |
| | 4504 | } else { |
| | 4505 | vpop(); |
| | 4506 | expr_lor(); |
| | 4507 | gen_cast(&ctb); |
| | 4508 | } |
| | 4509 | gen_cast(&cti); |
| | 4510 | } else { |
| | 4511 | int t = 0; |
| | 4512 | save_regs(1); |
| | 4513 | for(;;) { |
| | 4514 | t = gvtst(0, t); |
| | 4515 | if (tok != TOK_LOR) { |
| | 4516 | vseti(VT_JMP, t); |
| | 4517 | break; |
| | 4518 | } |
| | 4519 | next(); |
| | 4520 | expr_land(); |
| | 4521 | } |
| 4515 | } | 4522 | } |
| 4516 | } | 4523 | } |
| 4517 | } | 4524 | } |
| 4518 | | 4525 | |
| 4519 | /* XXX: better constant handling */ | | |
| 4520 | static void expr_cond(void) | 4526 | static void expr_cond(void) |
| 4521 | { | 4527 | { |
| 4522 | int tt, u, r1, r2, rc, t1, t2, bt1, bt2; | 4528 | int tt, u, r1, r2, rc, t1, t2, bt1, bt2; |
| 4523 | SValue sv; | 4529 | SValue sv; |
| 4524 | CType type, type1, type2; | 4530 | CType type, type1, type2; |
| 4525 | | 4531 | |
| 4526 | if (const_wanted) | 4532 | expr_lor(); |
| 4527 | expr_lor_const(); | | |
| 4528 | else | | |
| 4529 | expr_lor(); | | |
| 4530 | if (tok == '?') { | 4533 | if (tok == '?') { |
| 4531 | next(); | 4534 | next(); |
| 4532 | if ((vtop->r & (VT_VALMASK | VT_LVAL | VT_SYM)) == VT_CONST) { | 4535 | if ((vtop->r & (VT_VALMASK | VT_LVAL | VT_SYM)) == VT_CONST) { |