From b1aca1bcd2166c892a2daa449b5f93f10e2c52be Mon Sep 17 00:00:00 2001 From: Dibyendu Majumdar Date: Sat, 25 Jun 2022 19:53:30 +0100 Subject: [PATCH] #245 ensure result is let on top of virtual stack --- ravicomp/src/linearizer.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ravicomp/src/linearizer.c b/ravicomp/src/linearizer.c index f0de42d0..2c4b11c1 100644 --- a/ravicomp/src/linearizer.c +++ b/ravicomp/src/linearizer.c @@ -1673,7 +1673,7 @@ static ravitype_t get_type(LuaSymbol *symbol) { static Pseudo *copy_to_temp_if_necessary(Proc *proc, Pseudo *original, unsigned line_number) { if (original->type == PSEUDO_SYMBOL) { - Pseudo *copy = allocate_temp_pseudo(proc, get_type(original->symbol), false); + Pseudo *copy = allocate_temp_pseudo(proc, get_type(original->symbol), true); instruct_move(proc, op_mov, copy, original, line_number); // TODO we may need to set type more specifically return copy; @@ -1867,11 +1867,11 @@ static Pseudo *linearize_builtin_expression(Proc *proc, AstNode *expr) handle_error(proc->linearizer->compiler_state, "feature not yet implemented"); } Instruction *insn = allocate_instruction(proc, op_C__new, expr->line_number); + Pseudo *target = allocate_temp_pseudo(proc, RAVI_TUSERDATA, true); const StringObject *type_name = astlist_get(expr->builtin_expr.arg_list, 0)->literal_expr.u.ts; Pseudo *tofree1 = add_instruction_operand(proc, insn, allocate_constant_pseudo(proc, allocate_string_constant(proc, type_name))); Pseudo *size_expr = linearize_expression(proc, astlist_get(expr->builtin_expr.arg_list, 1)); Pseudo *tofree2 = add_instruction_operand(proc, insn, size_expr); - Pseudo *target = allocate_temp_pseudo(proc, RAVI_TUSERDATA, false); add_instruction_target(proc, insn, target); add_instruction(proc, insn); free_temp_pseudo(proc, size_expr, false);