diff options
| author | Ginger Bill <bill@gingerbill.org> | 2017-04-20 23:22:45 +0100 |
|---|---|---|
| committer | Ginger Bill <bill@gingerbill.org> | 2017-04-20 23:22:45 +0100 |
| commit | a713e3300786199510e525aa9f90ee8d91aa862a (patch) | |
| tree | b7fb9141d89e7a5ab673615cdfc0137630fc3260 /src/ir.c | |
| parent | c5411a25a94650ec6370eea3572d3d60f6240482 (diff) | |
Change interval syntax: .. open range, ..< half-closed range
Diffstat (limited to 'src/ir.c')
| -rw-r--r-- | src/ir.c | 14 |
1 files changed, 13 insertions, 1 deletions
@@ -4905,6 +4905,17 @@ irAddr ir_build_addr(irProcedure *proc, AstNode *expr) { if (se->low != NULL) low = ir_build_expr(proc, se->low); if (se->high != NULL) high = ir_build_expr(proc, se->high); if (se->max != NULL) max = ir_build_expr(proc, se->max); + + + if (high != NULL && se->interval0.kind == Token_Ellipsis) { + high = ir_emit_arith(proc, Token_Add, high, v_one, t_int); + } + + if (max != NULL && se->interval1.kind == Token_Ellipsis) { + GB_ASSERT(se->interval0.kind == se->interval1.kind); + max = ir_emit_arith(proc, Token_Add, max, v_one, t_int); + } + irValue *addr = ir_build_addr(proc, se->expr).addr; irValue *base = ir_emit_load(proc, addr); Type *type = base_type(ir_type(base)); @@ -5553,7 +5564,8 @@ void ir_build_range_interval(irProcedure *proc, AstNodeIntervalExpr *node, Type TokenKind op = Token_Lt; switch (node->op.kind) { - case Token_Ellipsis: op = Token_Lt; break; + case Token_Ellipsis: op = Token_LtEq; break; + case Token_HalfClosed: op = Token_Lt; break; default: GB_PANIC("Invalid interval operator"); break; } irValue *cond = ir_emit_comp(proc, op, ir_emit_load(proc, value), upper); |