X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=src%2Fcc65%2Fstmt.c;h=67742113cdda5532c7e9540d6d3a48042118702f;hb=57c2e0cc0bcda3d08692abc60f5c85510801801d;hp=44a98072d86c5ee1143323a168e6cec2d0283545;hpb=08eb9b7b0e2d25137a17220a4eaa0c7d53bac222;p=cc65 diff --git a/src/cc65/stmt.c b/src/cc65/stmt.c index 44a98072d..67742113c 100644 --- a/src/cc65/stmt.c +++ b/src/cc65/stmt.c @@ -51,6 +51,7 @@ #include "global.h" #include "goto.h" #include "litpool.h" +#include "loadexpr.h" #include "locals.h" #include "loop.h" #include "pragma.h" @@ -202,7 +203,7 @@ static void DoStatement (void) NextToken (); /* Add the loop to the loop stack */ - AddLoop (StackPtr, BreakLabel, ContinueLabel); + AddLoop (BreakLabel, ContinueLabel); /* Define the loop label */ g_defcodelabel (LoopLabel); @@ -242,7 +243,7 @@ static void WhileStatement (void) /* Add the loop to the loop stack. In case of a while loop, the loop head * label is used for continue statements. */ - AddLoop (StackPtr, BreakLabel, LoopLabel); + AddLoop (BreakLabel, LoopLabel); /* Define the head label */ g_defcodelabel (LoopLabel); @@ -293,7 +294,7 @@ static void ReturnStatement (void) TypeConversion (&Expr, F_GetReturnType (CurrentFunc)); /* Load the value into the primary */ - ExprLoad (CF_NONE, &Expr); + LoadExpr (CF_NONE, &Expr); } } else if (!F_HasVoidReturn (CurrentFunc) && !F_HasOldStyleIntRet (CurrentFunc)) { @@ -393,7 +394,7 @@ static void ForStatement (void) /* Add the loop to the loop stack. A continue jumps to the start of the * the increment condition. */ - AddLoop (StackPtr, BreakLabel, IncLabel); + AddLoop (BreakLabel, IncLabel); /* Skip the opening paren */ ConsumeLParen (); @@ -417,7 +418,7 @@ static void ForStatement (void) ConsumeSemi (); /* Remember the start of the increment expression */ - IncExprStart = GetCodePos(); + GetCodePos (&IncExprStart); /* Label for the increment expression */ g_defcodelabel (IncLabel); @@ -432,7 +433,7 @@ static void ForStatement (void) g_jump (TestLabel); /* Remember the end of the increment expression */ - IncExprEnd = GetCodePos(); + GetCodePos (&IncExprEnd); /* Skip the closing paren */ ConsumeRParen (); @@ -446,7 +447,9 @@ static void ForStatement (void) * the loop body. */ if (HaveIncExpr) { - MoveCode (IncExprStart, IncExprEnd, GetCodePos()); + CodeMark Here; + GetCodePos (&Here); + MoveCode (&IncExprStart, &IncExprEnd, &Here); } else { /* Jump back to the increment expression */ g_jump (IncLabel); @@ -519,7 +522,7 @@ int Statement (int* PendingToken) { ExprDesc Expr; int GotBreak; - CodeMark Start; + CodeMark Start, End; /* Assume no pending token */ if (PendingToken) { @@ -592,19 +595,20 @@ int Statement (int* PendingToken) default: /* Remember the current code position */ - Start = GetCodePos (); + GetCodePos (&Start); /* Actual statement */ ExprWithCheck (hie0, &Expr); /* Load the result only if it is an lvalue and the type is * marked as volatile. Otherwise the load is useless. */ if (ED_IsLVal (&Expr) && IsQualVolatile (Expr.Type)) { - ExprLoad (CF_NONE, &Expr); + LoadExpr (CF_NONE, &Expr); } /* If the statement didn't generate code, and is not of type - * void, emit a warning - */ - if (GetCodePos () == Start && !IsTypeVoid (Expr.Type)) { + * void, emit a warning. + */ + GetCodePos (&End); + if (CodeRangeIsEmpty (&Start, &End) && !IsTypeVoid (Expr.Type)) { Warning ("Statement has no effect"); } CheckSemi (PendingToken);