diff options
| author | Ginger Bill <bill@gingerbill.org> | 2017-05-09 16:21:31 +0100 |
|---|---|---|
| committer | Ginger Bill <bill@gingerbill.org> | 2017-05-09 16:21:31 +0100 |
| commit | c6d531df9597253ee95593c56e61039fe4e40ba2 (patch) | |
| tree | 8469ee00657577f4909891e8773231351f54b3cd /src/ir.c | |
| parent | 8677c81da7ca8af37c49a203a18fd7beab74f023 (diff) | |
Add %% operator (divisor modulo)
Diffstat (limited to 'src/ir.c')
| -rw-r--r-- | src/ir.c | 10 |
1 files changed, 10 insertions, 0 deletions
@@ -2073,6 +2073,7 @@ irValue *ir_emit_arith(irProcedure *proc, TokenKind op, irValue *left, irValue * case Token_Mul: case Token_Quo: case Token_Mod: + case Token_ModMod: case Token_And: case Token_Or: case Token_Xor: @@ -2081,6 +2082,14 @@ irValue *ir_emit_arith(irProcedure *proc, TokenKind op, irValue *left, irValue * break; } + if (op == Token_ModMod) { + irValue *n = left; + irValue *m = right; + irValue *a = ir_emit(proc, ir_instr_binary_op(proc, Token_Mod, n, m, type)); + irValue *b = ir_emit(proc, ir_instr_binary_op(proc, Token_Add, a, m, type)); + return ir_emit(proc, ir_instr_binary_op(proc, Token_Mod, b, m, type)); + } + return ir_emit(proc, ir_instr_binary_op(proc, op, left, right, type)); } @@ -3744,6 +3753,7 @@ irValue *ir_build_expr(irProcedure *proc, AstNode *expr) { case Token_Mul: case Token_Quo: case Token_Mod: + case Token_ModMod: case Token_And: case Token_Or: case Token_Xor: |