mirror of
https://github.com/Ed94/Odin.git
synced 2026-07-24 08:27:53 +00:00
Add %% operator (divisor modulo)
This commit is contained in:
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user