diff --git a/ir.c b/ir.c index c660c1a..0f58aa7 100644 --- a/ir.c +++ b/ir.c @@ -105,10 +105,10 @@ void print_ir(IRToks *v, const BuiltinFunc *builtin_funcs) { case IRSub: case IRDiv: case IRMul: - printf(" %%%zx ", v->toks[i].Arith.addr); - print_irparam(&v->toks[i].Arith.lhs); + printf(" %%%zx ", v->toks[i].Binary.addr); + print_irparam(&v->toks[i].Binary.lhs); printf(" "); - print_irparam(&v->toks[i].Arith.rhs); + print_irparam(&v->toks[i].Binary.rhs); break; case IRJmp: printf(" %zx", v->toks[i].Jmp.iaddr); diff --git a/ir.h b/ir.h index 58e9e67..fae539e 100644 --- a/ir.h +++ b/ir.h @@ -59,7 +59,7 @@ typedef struct IRTok { struct { size_t addr; IRParam lhs, rhs; - } Arith; + } Binary; struct { size_t iaddr; diff --git a/parse.c b/parse.c index ffb878a..0bb68d8 100644 --- a/parse.c +++ b/parse.c @@ -52,7 +52,7 @@ static void set_irtok_dest_addr(IRTok *t, size_t addr) { case IRSub: case IRMul: case IRDiv: - t->Arith.addr = addr; + t->Binary.addr = addr; break; case IRCallInternal: t->CallI.ret_addr = addr; @@ -436,7 +436,7 @@ static ExprRet expr(IRToks *out_ir, TokList *toks, Map *funcs, Scope *parent_sc, if (lhs->kind == TokVal && rhs->kind == TokVal) { /* evaluate the constant expression immediately */ lhs->kind = TokVal; - TRY_RET(lhs->Val = eval_arith(instr, &lhs->Val, &rhs->Val), (ExprRet){0}); + TRY_RET(lhs->Val = eval_binary(instr, &lhs->Val, &rhs->Val), (ExprRet){0}); } else { bool is_last_operation = t == start && r_op_prec == PREC_DELIM; @@ -450,7 +450,7 @@ static ExprRet expr(IRToks *out_ir, TokList *toks, Map *funcs, Scope *parent_sc, .ln = l_op->ln, .col = l_op->col, .instr = instr, - .Arith = { + .Binary = { .addr = res_addr, .lhs = lhs_irparam, .rhs = rhs_irparam, diff --git a/runtime.c b/runtime.c index b04c8eb..2f50f61 100644 --- a/runtime.c +++ b/runtime.c @@ -2,7 +2,7 @@ #include "util.h" -Value eval_arith(IRInstr instr, const Value *lhs, const Value *rhs) { +Value eval_binary(IRInstr instr, const Value *lhs, const Value *rhs) { switch (instr) { case IRAdd: case IRSub: diff --git a/runtime.h b/runtime.h index 9205218..4d8d367 100644 --- a/runtime.h +++ b/runtime.h @@ -3,7 +3,7 @@ #include "ir.h" -Value eval_arith(IRInstr instr, const Value *lhs, const Value *rhs); +Value eval_binary(IRInstr instr, const Value *lhs, const Value *rhs); Value eval_unary(IRInstr instr, const Value *v); bool is_nonzero(const Value *v); Value zero_val(Type ty); diff --git a/vm.c b/vm.c index 84ad976..39eb2d6 100644 --- a/vm.c +++ b/vm.c @@ -63,10 +63,10 @@ void run(const IRToks *ir, const BuiltinFunc *builtin_funcs) { case IRSub: case IRDiv: case IRMul: - stack_fit(&s, instr->Arith.addr); - TRY_ELSE(s.mem[instr->Arith.addr] = eval_arith(instr->instr, - irparam_to_val(&s, &instr->Arith.lhs), - irparam_to_val(&s, &instr->Arith.rhs)), + stack_fit(&s, instr->Binary.addr); + TRY_ELSE(s.mem[instr->Binary.addr] = eval_binary(instr->instr, + irparam_to_val(&s, &instr->Binary.lhs), + irparam_to_val(&s, &instr->Binary.rhs)), {free(fn_args); stack_term(&s);}); break; case IRJmp: