1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
|
/*
A S S I G N M E . C
*/
#include "iccomp.h"
ESTRUC_ *assignment(lval, rval, opstr) /* opstr is '=', or "/=", etc. */
ESTRUC_
*lval,
*rval;
char
*opstr;
{
ESTRUC_
*tmp;
size_t
type,
value;
if (!test_type(lval, e_var))
{
semantic(lvalue_needed, opstr);
discard(rval);
return (lval);
}
etoc(rval); /* convert rval to code */
/* same types */
if (lval->type & rval->type & (e_int | e_str | e_list))
{
type = lval->type; /* save type/idx for return */
value = lval->evalue;
gencode(lval, op_copy_var, lval->evalue);
tmp = catcode(rval, lval); /* catenate assignment code */
tmp->evalue = value; /* set lvalue type and idx */
tmp->type = type;
return tmp;
}
semantic(type_conflict, opstr);
discard(rval);
return lval;
}
|