/*-----------------------------------------------------------------*/
/* forward definition of some functions */
-operand *geniCodeAssign (operand *, operand *, int);
+operand *geniCodeAssign (operand *, operand *, int, int);
static operand *geniCodeArray (operand *, operand *,int);
static operand *geniCodeArray2Ptr (operand *);
operand *geniCodeRValue (operand *, bool);
if (IS_ITEMP (rv))
OP_SYMBOL(rv)->noSpilLoc = 1;
- geniCodeAssign (rOp, rv, 0);
+ geniCodeAssign (rOp, rv, 0, 0);
size = (IS_PTR (rvtype) ? getSize (rvtype->next) : 1);
if (IS_FLOAT (rvtype))
IC_RESULT (ic) = result = newiTempOperand (rvtype, 0);
ADDTOCHAIN (ic);
- geniCodeAssign (op, result, 0);
+ geniCodeAssign (op, result, 0, 0);
return rOp;
IC_RESULT (ic) = result = newiTempOperand (roptype, 0);
ADDTOCHAIN (ic);
- (void) geniCodeAssign (op, result, 0);
+ (void) geniCodeAssign (op, result, 0, 0);
if (lvalue || IS_TRUE_SYMOP (op))
return op;
else
if (IS_ITEMP (rv))
OP_SYMBOL(rv)->noSpilLoc = 1;
- geniCodeAssign (rOp, rv, 0);
+ geniCodeAssign (rOp, rv, 0, 0);
size = (IS_PTR (rvtype) ? getSize (rvtype->next) : 1);
if (IS_FLOAT (rvtype))
IC_RESULT (ic) = result = newiTempOperand (rvtype, 0);
ADDTOCHAIN (ic);
- geniCodeAssign (op, result, 0);
+ geniCodeAssign (op, result, 0, 0);
return rOp;
IC_RESULT (ic) = result = newiTempOperand (roptype, 0);
ADDTOCHAIN (ic);
- (void) geniCodeAssign (op, result, 0);
+ (void) geniCodeAssign (op, result, 0, 0);
if (lvalue || IS_TRUE_SYMOP (op))
return op;
else
result = newiTempOperand (newCharLink(), 1);
geniCodeLabel (falseLabel);
- geniCodeAssign (result, operandFromLit (0), 0);
+ geniCodeAssign (result, operandFromLit (0), 0, 0);
/* generate an unconditional goto */
geniCodeGoto (exitLabel);
geniCodeLabel (trueLabel);
- geniCodeAssign (result, operandFromLit (1), 0);
+ geniCodeAssign (result, operandFromLit (1), 0, 0);
geniCodeLabel (exitLabel);
/* move the value to a new Operand */
result = newiTempOperand (tree->right->ftype, 0);
- geniCodeAssign (result, geniCodeRValue (true, FALSE), 0);
+ geniCodeAssign (result, geniCodeRValue (true, FALSE), 0, 0);
/* generate an unconditional goto */
geniCodeGoto (exitLabel);
geniCodeLabel (falseLabel);
false = ast2iCode (tree->right->right,lvl+1);
- geniCodeAssign (result, geniCodeRValue (false, FALSE), 0);
+ geniCodeAssign (result, geniCodeRValue (false, FALSE), 0, 0);
/* create the exit label */
geniCodeLabel (exitLabel);
/* geniCodeAssign - generate code for assignment */
/*-----------------------------------------------------------------*/
operand *
-geniCodeAssign (operand * left, operand * right, int nosupdate)
+geniCodeAssign (operand * left, operand * right, int nosupdate, int strictLval)
{
iCode *ic;
sym_link *ltype = operandType (left);
sym_link *rtype = operandType (right);
- if (!left->isaddr && !IS_ITEMP (left))
+ if (!left->isaddr && (!IS_ITEMP (left) || strictLval))
{
werror (E_LVALUE_REQUIRED, "assignment");
return left;
operand *top = operandFromSymbol (argVals->sym);
/* clear useDef and other bitVectors */
OP_USES(top)=OP_DEFS(top)=OP_SYMBOL(top)->clashes = NULL;
- geniCodeAssign (top, pval, 1);
+ geniCodeAssign (top, pval, 1, 0);
}
else
{
else
right = geniCodeRValue (right, FALSE);
- geniCodeAssign (left, right, 0);
+ geniCodeAssign (left, right, 0, 1);
return right;
}
case MUL_ASSIGN:
geniCodeAssign (left,
geniCodeMultiply (geniCodeRValue (operandFromOperand (left),
FALSE),
- geniCodeRValue (right, FALSE), FALSE),
- getResultTypeFromType (tree->ftype));
+ geniCodeRValue (right, FALSE),
+ getResultTypeFromType (tree->ftype)),
+ 0, 1);
case DIV_ASSIGN:
return
FALSE),
geniCodeRValue (right, FALSE),
getResultTypeFromType (tree->ftype)),
- 0);
+ 0, 1);
case MOD_ASSIGN:
return
geniCodeAssign (left,
FALSE),
geniCodeRValue (right, FALSE),
getResultTypeFromType (tree->ftype)),
- 0);
+ 0, 1);
case ADD_ASSIGN:
{
sym_link *rtype = operandType (right);
right,
getResultTypeFromType (tree->ftype),
lvl),
- 0);
+ 0, 1);
}
case SUB_ASSIGN:
{
FALSE),
right,
getResultTypeFromType (tree->ftype)),
- 0);
+ 0, 1);
}
case LEFT_ASSIGN:
return
,FALSE),
geniCodeRValue (right, FALSE),
getResultTypeFromType (tree->ftype)),
- 0);
+ 0, 1);
case RIGHT_ASSIGN:
return
geniCodeAssign (left,
geniCodeRightShift (geniCodeRValue (operandFromOperand (left)
,FALSE),
- geniCodeRValue (right, FALSE)), 0);
+ geniCodeRValue (right, FALSE)), 0, 1);
case AND_ASSIGN:
return
geniCodeAssign (left,
FALSE),
geniCodeRValue (right, FALSE),
BITWISEAND,
- operandType (left)), 0);
+ operandType (left)), 0, 1);
case XOR_ASSIGN:
return
geniCodeAssign (left,
FALSE),
geniCodeRValue (right, FALSE),
'^',
- operandType (left)), 0);
+ operandType (left)), 0, 1);
case OR_ASSIGN:
return
geniCodeAssign (left,
,FALSE),
geniCodeRValue (right, FALSE),
'|',
- operandType (left)), 0);
+ operandType (left)), 0, 1);
case ',':
return geniCodeRValue (right, FALSE);