From aec1b8dddc68ecb8288ec6132932e4c7b4bca09f Mon Sep 17 00:00:00 2001 From: Ash Wolf Date: Tue, 10 Jan 2023 11:05:21 +0000 Subject: getting close to done --- compiler_and_linker/unsorted/IroUtil.c | 37 ++++++++++++++++++++++++++++++---- 1 file changed, 33 insertions(+), 4 deletions(-) (limited to 'compiler_and_linker/unsorted/IroUtil.c') diff --git a/compiler_and_linker/unsorted/IroUtil.c b/compiler_and_linker/unsorted/IroUtil.c index 67edd4b..53e6733 100644 --- a/compiler_and_linker/unsorted/IroUtil.c +++ b/compiler_and_linker/unsorted/IroUtil.c @@ -956,10 +956,40 @@ void IRO_ReplaceReferenceWithNode(IROLinear *a, IROLinear *b) { } } -void IRO_GetTemp(IROExpr *expr) { +VarRecord *IRO_GetTemp(IROExpr *expr) { + expr->x8 = create_temp_object(expr->linear->rtype); + return IRO_FindVar(expr->x8, 1, 1); } IROLinear *IRO_AssignToTemp(IROExpr *expr) { + IROLinear *objref; + IROLinear *ind; + IROLinear *ass; + + objref = IRO_NewLinear(IROLinearOperand); + objref->u.node = create_objectrefnode(expr->x8); + objref->rtype = objref->u.node->data.objref->type; + objref->index = ++IRO_NumLinear; + objref->flags |= IROLF_Reffed | IROLF_Assigned | IROLF_Ind; + + ind = IRO_NewLinear(IROLinearOp1Arg); + ind->nodetype = EINDIRECT; + ind->rtype = expr->linear->rtype; + ind->u.monadic = objref; + ind->index = ++IRO_NumLinear; + ind->flags |= IROLF_Reffed | IROLF_Assigned; + + ass = IRO_NewLinear(IROLinearOp2Arg); + ass->nodetype = EASS; + ass->u.diadic.left = ind; + ass->u.diadic.right = expr->linear; + ass->rtype = expr->linear->rtype; + ass->index = ++IRO_NumLinear; + + objref->next = ind; + ind->next = ass; + IRO_PasteAfter(objref, ass, expr->linear); + return ass; } IROLinear *IRO_FindStart(IROLinear *linear) { @@ -993,7 +1023,7 @@ void IRO_RemoveCommaNodeFromIR(void) { if (!linear) break; if (linear->nodetype == ECOMMA) { - linear->u.diadic.left->flags &= ~IROLF_Reffed; + linear->u.diadic.left->flags = linear->u.diadic.left->flags & ~IROLF_Reffed; IRO_LocateFather_Cut_And_Paste_Without_Nopping(linear, linear->u.diadic.right); linear->type = IROLinearNop; } @@ -1200,7 +1230,7 @@ IROLinear *IRO_NewIntConst(CInt64 val, Type *type) { return linear; } -IROLinear *IRO_NewFloatConst(Float val, Type *type) { +IROLinear *IRO_NewFloatConst(const Float val, Type *type) { ENode *node; IROLinear *linear; @@ -1230,4 +1260,3 @@ void IRO_CheckForUserBreak(void) { IRO_LastUserBreakTick = COS_GetTicks(); } } - -- cgit v1.2.3