case E_LOC_ABS:
/* Absolute: numeric address or const */
- g_defdata (TypeOf (Expr->Type) | CF_CONST, Expr->Val, 0);
+ g_defdata (TypeOf (Expr->Type) | CF_CONST, Expr->IVal, 0);
break;
case E_LOC_GLOBAL:
/* Global variable */
- g_defdata (CF_EXTERNAL, Expr->Name, Expr->Val);
+ g_defdata (CF_EXTERNAL, Expr->Name, Expr->IVal);
break;
case E_LOC_STATIC:
case E_LOC_LITERAL:
/* Static variable or literal in the literal pool */
- g_defdata (CF_STATIC, Expr->Name, Expr->Val);
+ g_defdata (CF_STATIC, Expr->Name, Expr->IVal);
break;
case E_LOC_REGISTER:
if (IS_Get (&AllowRegVarAddr) == 0) {
Error ("Cannot take the address of a register variable");
}
- g_defdata (CF_REGVAR, Expr->Name, Expr->Val);
+ g_defdata (CF_REGVAR, Expr->Name, Expr->IVal);
break;
default:
case E_LOC_ABS:
/* Number constant */
- g_getimmed (Flags | TypeOf (Expr->Type) | CF_CONST, Expr->Val, 0);
+ g_getimmed (Flags | TypeOf (Expr->Type) | CF_CONST, Expr->IVal, 0);
break;
case E_LOC_GLOBAL:
/* Global symbol, load address */
- g_getimmed ((Flags | CF_EXTERNAL) & ~CF_CONST, Expr->Name, Expr->Val);
+ g_getimmed ((Flags | CF_EXTERNAL) & ~CF_CONST, Expr->Name, Expr->IVal);
break;
case E_LOC_STATIC:
case E_LOC_LITERAL:
/* Static symbol or literal, load address */
- g_getimmed ((Flags | CF_STATIC) & ~CF_CONST, Expr->Name, Expr->Val);
+ g_getimmed ((Flags | CF_STATIC) & ~CF_CONST, Expr->Name, Expr->IVal);
break;
case E_LOC_REGISTER:
if (IS_Get (&AllowRegVarAddr) == 0) {
Error ("Cannot take the address of a register variable");
}
- g_getimmed ((Flags | CF_REGVAR) & ~CF_CONST, Expr->Name, Expr->Val);
+ g_getimmed ((Flags | CF_REGVAR) & ~CF_CONST, Expr->Name, Expr->IVal);
case E_LOC_STACK:
- g_leasp (Expr->Val);
+ g_leasp (Expr->IVal);
break;
default:
case E_LOC_ABS:
/* Absolute: numeric address or const */
- g_getstatic (Flags | CF_ABSOLUTE, Expr->Val, 0);
+ g_getstatic (Flags | CF_ABSOLUTE, Expr->IVal, 0);
break;
case E_LOC_GLOBAL:
/* Global variable */
- g_getstatic (Flags | CF_EXTERNAL, Expr->Name, Expr->Val);
+ g_getstatic (Flags | CF_EXTERNAL, Expr->Name, Expr->IVal);
break;
case E_LOC_STATIC:
case E_LOC_LITERAL:
/* Static variable or literal in the literal pool */
- g_getstatic (Flags | CF_STATIC, Expr->Name, Expr->Val);
+ g_getstatic (Flags | CF_STATIC, Expr->Name, Expr->IVal);
break;
case E_LOC_REGISTER:
/* Register variable */
- g_getstatic (Flags | CF_REGVAR, Expr->Name, Expr->Val);
+ g_getstatic (Flags | CF_REGVAR, Expr->Name, Expr->IVal);
break;
case E_LOC_STACK:
/* Value on the stack */
- g_getlocal (Flags, Expr->Val);
+ g_getlocal (Flags, Expr->IVal);
break;
case E_LOC_PRIMARY:
case E_LOC_EXPR:
/* Reference to address in primary with offset in Expr */
- g_getind (Flags, Expr->Val);
+ g_getind (Flags, Expr->IVal);
break;
default:
} else {
/* An rvalue */
if (ED_IsLocExpr (Expr)) {
- if (Expr->Val != 0) {
+ if (Expr->IVal != 0) {
/* We have an expression in the primary plus a constant
* offset. Adjust the value in the primary accordingly.
*/
Flags |= TypeOf (Expr->Type);
- g_inc (Flags | CF_CONST, Expr->Val);
+ g_inc (Flags | CF_CONST, Expr->IVal);
}
} else {
/* Constant of some sort, load it into the primary */
}
FrameOffs -= ArgSize;
/* Store */
- g_putlocal (Flags | CF_NOKEEP, FrameOffs, Expr.Val);
+ g_putlocal (Flags | CF_NOKEEP, FrameOffs, Expr.IVal);
} else {
/* Push the argument */
- g_push (Flags, Expr.Val);
+ g_push (Flags, Expr.IVal);
}
/* Calculate total parameter size */
if (CurTok.Tok == TOK_ICONST || CurTok.Tok == TOK_CCONST) {
E->Flags = E_LOC_ABS | E_RTYPE_RVAL;
E->Type = CurTok.Type;
- E->Val = CurTok.IVal;
+ E->IVal = CurTok.IVal;
NextToken ();
return;
}
if ((Sym->Flags & SC_CONST) == SC_CONST) {
/* Enum or some other numeric constant */
E->Flags = E_LOC_ABS | E_RTYPE_RVAL;
- E->Val = Sym->V.ConstVal;
+ E->IVal = Sym->V.ConstVal;
} else if ((Sym->Flags & SC_FUNC) == SC_FUNC) {
/* Function */
E->Flags = E_LOC_GLOBAL | E_RTYPE_LVAL;
} else {
/* Normal parameter */
E->Flags = E_LOC_STACK | E_RTYPE_LVAL;
- E->Val = Sym->V.Offs;
+ E->IVal = Sym->V.Offs;
}
} else if ((Sym->Flags & SC_REGISTER) == SC_REGISTER) {
/* Register variable, zero page based */
/* String literal */
E->Type = GetCharArrayType (GetLiteralPoolOffs () - CurTok.IVal);
E->Flags = E_LOC_LITERAL | E_RTYPE_RVAL;
- E->Val = CurTok.IVal;
+ E->IVal = CurTok.IVal;
E->Name = LiteralPoolLabel;
NextToken ();
break;
/* Lhs is pointer/array. Scale the subscript value according to
* the element size.
*/
- SubScript.Val *= CheckedSizeOf (ElementType);
+ SubScript.IVal *= CheckedSizeOf (ElementType);
/* Remove the address load code */
RemoveCode (Mark1);
if (IsTypeArray (Expr->Type)) {
/* Adjust the offset */
- Expr->Val += SubScript.Val;
+ Expr->IVal += SubScript.IVal;
} else {
}
/* Use the offset */
- Expr->Val = SubScript.Val;
+ Expr->IVal = SubScript.IVal;
}
} else {
* we will ignore the true type of the subscript here and
* use always an int. #### Use offset but beware of ExprLoad!
*/
- g_inc (CF_INT | CF_CONST, SubScript.Val);
+ g_inc (CF_INT | CF_CONST, SubScript.IVal);
}
/* Add the variable */
if (ED_IsLocStack (&SubScript)) {
- g_addlocal (Flags, SubScript.Val);
+ g_addlocal (Flags, SubScript.IVal);
} else {
Flags |= GlobalModeFlags (SubScript.Flags);
- g_addstatic (Flags, SubScript.Name, SubScript.Val);
+ g_addstatic (Flags, SubScript.Name, SubScript.IVal);
}
} else {
if (ED_IsLocAbs (Expr)) {
/* Constant numeric address. Just add it */
- g_inc (CF_INT, Expr->Val);
+ g_inc (CF_INT, Expr->IVal);
} else if (ED_IsLocStack (Expr)) {
/* Base address is a local variable address */
if (IsTypeArray (Expr->Type)) {
- g_addaddr_local (CF_INT, Expr->Val);
+ g_addaddr_local (CF_INT, Expr->IVal);
} else {
- g_addlocal (CF_PTR, Expr->Val);
+ g_addlocal (CF_PTR, Expr->IVal);
}
} else {
/* Base address is a static variable address */
unsigned Flags = CF_INT | GlobalModeFlags (Expr->Flags);
if (IsTypeArray (Expr->Type)) {
- g_addaddr_static (Flags, Expr->Name, Expr->Val);
+ g_addaddr_static (Flags, Expr->Name, Expr->IVal);
} else {
- g_addstatic (Flags, Expr->Name, Expr->Val);
+ g_addstatic (Flags, Expr->Name, Expr->IVal);
}
}
}
}
/* Set the struct field offset */
- Expr->Val += Field->V.Offs;
+ Expr->IVal += Field->V.Offs;
/* The type is now the type of the field */
Expr->Type = Field->Type;
case E_LOC_ABS:
/* Absolute: numeric address or const */
- g_putstatic (Flags | CF_ABSOLUTE, Expr->Val, 0);
+ g_putstatic (Flags | CF_ABSOLUTE, Expr->IVal, 0);
break;
case E_LOC_GLOBAL:
/* Global variable */
- g_putstatic (Flags | CF_EXTERNAL, Expr->Name, Expr->Val);
+ g_putstatic (Flags | CF_EXTERNAL, Expr->Name, Expr->IVal);
break;
case E_LOC_STATIC:
case E_LOC_LITERAL:
/* Static variable or literal in the literal pool */
- g_putstatic (Flags | CF_STATIC, Expr->Name, Expr->Val);
+ g_putstatic (Flags | CF_STATIC, Expr->Name, Expr->IVal);
break;
case E_LOC_REGISTER:
/* Register variable */
- g_putstatic (Flags | CF_REGVAR, Expr->Name, Expr->Val);
+ g_putstatic (Flags | CF_REGVAR, Expr->Name, Expr->IVal);
break;
case E_LOC_STACK:
/* Value on the stack */
- g_putlocal (Flags, Expr->Val, 0);
+ g_putlocal (Flags, Expr->IVal, 0);
break;
case E_LOC_PRIMARY:
case E_LOC_EXPR:
/* An expression in the primary register */
- g_putind (Flags, Expr->Val);
+ g_putind (Flags, Expr->IVal);
break;
default:
case E_LOC_ABS:
/* Absolute: numeric address or const */
- g_addeqstatic (Flags | CF_ABSOLUTE, Expr->Val, 0, Val);
+ g_addeqstatic (Flags | CF_ABSOLUTE, Expr->IVal, 0, Val);
break;
case E_LOC_GLOBAL:
/* Global variable */
- g_addeqstatic (Flags | CF_EXTERNAL, Expr->Name, Expr->Val, Val);
+ g_addeqstatic (Flags | CF_EXTERNAL, Expr->Name, Expr->IVal, Val);
break;
case E_LOC_STATIC:
case E_LOC_LITERAL:
/* Static variable or literal in the literal pool */
- g_addeqstatic (Flags | CF_STATIC, Expr->Name, Expr->Val, Val);
+ g_addeqstatic (Flags | CF_STATIC, Expr->Name, Expr->IVal, Val);
break;
case E_LOC_REGISTER:
/* Register variable */
- g_addeqstatic (Flags | CF_REGVAR, Expr->Name, Expr->Val, Val);
+ g_addeqstatic (Flags | CF_REGVAR, Expr->Name, Expr->IVal, Val);
break;
case E_LOC_STACK:
/* Value on the stack */
- g_addeqlocal (Flags, Expr->Val, Val);
+ g_addeqlocal (Flags, Expr->IVal, Val);
break;
case E_LOC_PRIMARY:
case E_LOC_EXPR:
/* An expression in the primary register */
- g_addeqind (Flags, Expr->Val, Val);
+ g_addeqind (Flags, Expr->IVal, Val);
break;
default:
ED_MakeRValExpr (Expr);
}
-
+
static void PreDec (ExprDesc* Expr)
/* Handle the predecrement operators */
case E_LOC_ABS:
/* Absolute: numeric address or const */
- g_subeqstatic (Flags | CF_ABSOLUTE, Expr->Val, 0, Val);
+ g_subeqstatic (Flags | CF_ABSOLUTE, Expr->IVal, 0, Val);
break;
case E_LOC_GLOBAL:
/* Global variable */
- g_subeqstatic (Flags | CF_EXTERNAL, Expr->Name, Expr->Val, Val);
+ g_subeqstatic (Flags | CF_EXTERNAL, Expr->Name, Expr->IVal, Val);
break;
case E_LOC_STATIC:
case E_LOC_LITERAL:
/* Static variable or literal in the literal pool */
- g_subeqstatic (Flags | CF_STATIC, Expr->Name, Expr->Val, Val);
+ g_subeqstatic (Flags | CF_STATIC, Expr->Name, Expr->IVal, Val);
break;
case E_LOC_REGISTER:
/* Register variable */
- g_subeqstatic (Flags | CF_REGVAR, Expr->Name, Expr->Val, Val);
+ g_subeqstatic (Flags | CF_REGVAR, Expr->Name, Expr->IVal, Val);
break;
case E_LOC_STACK:
/* Value on the stack */
- g_subeqlocal (Flags, Expr->Val, Val);
+ g_subeqlocal (Flags, Expr->IVal, Val);
break;
case E_LOC_PRIMARY:
case E_LOC_EXPR:
/* An expression in the primary register */
- g_subeqind (Flags, Expr->Val, Val);
+ g_subeqind (Flags, Expr->IVal, Val);
break;
default:
}
-
+
static void PostIncDec (ExprDesc* Expr, void (*inc) (unsigned, unsigned long))
/* Handle i-- and i++ */
{
if (ED_IsConstAbs (Expr)) {
/* Value is constant */
switch (Tok) {
- case TOK_MINUS: Expr->Val = -Expr->Val; break;
- case TOK_PLUS: break;
- case TOK_COMP: Expr->Val = ~Expr->Val; break;
+ case TOK_MINUS: Expr->IVal = -Expr->IVal; break;
+ case TOK_PLUS: break;
+ case TOK_COMP: Expr->IVal = ~Expr->IVal; break;
default: Internal ("Unexpected token: %d", Tok);
}
} else {
NextToken ();
if (evalexpr (CF_NONE, hie10, Expr) == 0) {
/* Constant expression */
- Expr->Val = !Expr->Val;
+ Expr->IVal = !Expr->IVal;
} else {
g_bneg (TypeOf (Expr->Type));
ED_MakeRValExpr (Expr);
if (ED_IsConstAbs (Expr)) {
/* Constant value */
Mark2 = GetCodePos ();
- g_push (ltype | CF_CONST, Expr->Val);
+ g_push (ltype | CF_CONST, Expr->IVal);
} else {
/* Value not constant */
ExprLoad (CF_NONE, Expr);
pop (ltype);
/* Evaluate the result */
- Expr->Val = kcalc (Tok, Expr->Val, Expr2.Val);
+ Expr->IVal = kcalc (Tok, Expr->IVal, Expr2.IVal);
/* Get the type of the result */
Expr->Type = promoteint (Expr->Type, Expr2.Type);
/* Second value is constant - check for div */
type |= CF_CONST;
rtype |= CF_CONST;
- if (Tok == TOK_DIV && Expr2.Val == 0) {
+ if (Tok == TOK_DIV && Expr2.IVal == 0) {
Error ("Division by zero");
- } else if (Tok == TOK_MOD && Expr2.Val == 0) {
+ } else if (Tok == TOK_MOD && Expr2.IVal == 0) {
Error ("Modulo operation with zero");
}
if ((Gen->Flags & GEN_NOPUSH) != 0) {
Expr->Type = promoteint (Expr->Type, Expr2.Type);
/* Generate code */
- Gen->Func (type, Expr2.Val);
+ Gen->Func (type, Expr2.IVal);
/* We have a rvalue in the primary now */
ED_MakeRValExpr (Expr);
if (ED_IsConstAbs (Expr)) {
/* Constant value */
Mark2 = GetCodePos ();
- g_push (ltype | CF_CONST, Expr->Val);
+ g_push (ltype | CF_CONST, Expr->IVal);
} else {
/* Value not constant */
ExprLoad (CF_NONE, Expr);
pop (ltype);
/* Evaluate the result */
- Expr->Val = kcalc (tok, Expr->Val, Expr2.Val);
+ Expr->IVal = kcalc (tok, Expr->IVal, Expr2.IVal);
} else {
}
/* Generate code */
- Gen->Func (flags, Expr2.Val);
+ Gen->Func (flags, Expr2.IVal);
/* The result is an rvalue in the primary */
ED_MakeRValExpr (Expr);
/* Both expressions are constants. Check for pointer arithmetic */
if (IsClassPtr (lhst) && IsClassInt (rhst)) {
/* Left is pointer, right is int, must scale rhs */
- Expr->Val += Expr2.Val * CheckedPSizeOf (lhst);
+ Expr->IVal += Expr2.IVal * CheckedPSizeOf (lhst);
/* Result type is a pointer */
} else if (IsClassInt (lhst) && IsClassPtr (rhst)) {
/* Left is int, right is pointer, must scale lhs */
- Expr->Val = Expr->Val * CheckedPSizeOf (rhst) + Expr2.Val;
+ Expr->IVal = Expr->IVal * CheckedPSizeOf (rhst) + Expr2.IVal;
/* Result type is a pointer */
Expr->Type = Expr2.Type;
} else if (IsClassInt (lhst) && IsClassInt (rhst)) {
/* Integer addition */
- Expr->Val += Expr2.Val;
+ Expr->IVal += Expr2.IVal;
typeadjust (Expr, &Expr2, 1);
} else {
/* OOPS */
/* Generate the code for the add */
if (ED_GetLoc (Expr) == E_LOC_ABS) {
/* Numeric constant */
- g_inc (flags, Expr->Val);
+ g_inc (flags, Expr->IVal);
} else {
/* Constant address */
- g_addaddr_static (flags, Expr->Name, Expr->Val);
+ g_addaddr_static (flags, Expr->Name, Expr->IVal);
}
} else if (IsClassInt (lhst) && IsClassPtr (rhst)) {
*/
if (ED_IsLocAbs (Expr)) {
/* Numeric constant, scale lhs */
- Expr->Val *= ScaleFactor;
+ Expr->IVal *= ScaleFactor;
/* Generate the code for the add */
- g_inc (flags, Expr->Val);
+ g_inc (flags, Expr->IVal);
} else if (ScaleFactor == 1) {
/* Constant address but no need to scale */
- g_addaddr_static (flags, Expr->Name, Expr->Val);
+ g_addaddr_static (flags, Expr->Name, Expr->IVal);
} else {
/* Constant address that must be scaled */
g_push (TypeOf (Expr2.Type), 0); /* rhs --> stack */
- g_getimmed (flags, Expr->Name, Expr->Val);
+ g_getimmed (flags, Expr->Name, Expr->IVal);
g_scale (CF_PTR, ScaleFactor);
g_add (CF_PTR, 0);
}
/* Generate the code for the add */
if (ED_IsLocAbs (Expr)) {
/* Numeric constant */
- g_inc (flags, Expr->Val);
+ g_inc (flags, Expr->IVal);
} else {
/* Constant address */
- g_addaddr_static (flags, Expr->Name, Expr->Val);
+ g_addaddr_static (flags, Expr->Name, Expr->IVal);
}
} else {
/* OOPS */
/* Check for pointer arithmetic */
if (IsClassPtr (lhst) && IsClassInt (rhst)) {
/* Left is pointer, right is int, must scale rhs */
- Expr2.Val *= CheckedPSizeOf (lhst);
+ Expr2.IVal *= CheckedPSizeOf (lhst);
/* Operate on pointers, result type is a pointer */
flags = CF_PTR;
} else if (IsClassInt (lhst) && IsClassPtr (rhst)) {
}
/* Generate code for the add */
- g_inc (flags | CF_CONST, Expr2.Val);
+ g_inc (flags | CF_CONST, Expr2.IVal);
} else {
/* Check for pointer arithmetic */
if (IsClassPtr (lhst) && IsClassInt (rhst)) {
/* Left is pointer, right is int, must scale rhs */
- Expr->Val -= Expr2.Val * CheckedPSizeOf (lhst);
+ Expr->IVal -= Expr2.IVal * CheckedPSizeOf (lhst);
/* Operate on pointers, result type is a pointer */
} else if (IsClassPtr (lhst) && IsClassPtr (rhst)) {
/* Left is pointer, right is pointer, must scale result */
if (TypeCmp (Indirect (lhst), Indirect (rhst)) < TC_QUAL_DIFF) {
Error ("Incompatible pointer types");
} else {
- Expr->Val = (Expr->Val - Expr2.Val) /
+ Expr->IVal = (Expr->IVal - Expr2.IVal) /
CheckedPSizeOf (lhst);
}
/* Operate on pointers, result type is an integer */
} else if (IsClassInt (lhst) && IsClassInt (rhst)) {
/* Integer subtraction */
typeadjust (Expr, &Expr2, 1);
- Expr->Val -= Expr2.Val;
+ Expr->IVal -= Expr2.IVal;
} else {
/* OOPS */
Error ("Invalid operands for binary operator `-'");
if (IsClassPtr (lhst) && IsClassInt (rhst)) {
/* Left is pointer, right is int, must scale rhs */
- Expr2.Val *= CheckedPSizeOf (lhst);
+ Expr2.IVal *= CheckedPSizeOf (lhst);
/* Operate on pointers, result type is a pointer */
flags = CF_PTR;
} else if (IsClassPtr (lhst) && IsClassPtr (rhst)) {
}
/* Do the subtraction */
- g_dec (flags | CF_CONST, Expr2.Val);
+ g_dec (flags | CF_CONST, Expr2.IVal);
/* If this was a pointer subtraction, we must scale the result */
if (rscale != 1) {
ConstAbsIntExpr (hie2, &Expr2);
/* Combine the two */
- Expr->Val = (Expr->Val && Expr2.Val);
+ Expr->IVal = (Expr->IVal && Expr2.IVal);
}
}
ConstAbsIntExpr (hieAndPP, &Expr2);
/* Combine the two */
- Expr->Val = (Expr->Val || Expr2.Val);
+ Expr->IVal = (Expr->IVal || Expr2.IVal);
}
}
}
if (MustScale) {
/* lhs is a pointer, scale rhs */
- Expr2.Val *= CheckedSizeOf (Expr->Type+1);
+ Expr2.IVal *= CheckedSizeOf (Expr->Type+1);
}
/* If the lhs is character sized, the operation may be later done
/* Special handling for add and sub - some sort of a hack, but short code */
if (Gen->Func == g_add) {
- g_inc (flags | CF_CONST, Expr2.Val);
+ g_inc (flags | CF_CONST, Expr2.IVal);
} else if (Gen->Func == g_sub) {
- g_dec (flags | CF_CONST, Expr2.Val);
+ g_dec (flags | CF_CONST, Expr2.IVal);
} else {
- Gen->Func (flags | CF_CONST, Expr2.Val);
+ Gen->Func (flags | CF_CONST, Expr2.IVal);
}
} else {
/* rhs is not constant and already in the primary register */
if (ED_IsConstAbs (&Expr2)) {
/* The resulting value is a constant. Scale it. */
if (MustScale) {
- Expr2.Val *= CheckedSizeOf (Indirect (Expr->Type));
+ Expr2.IVal *= CheckedSizeOf (Indirect (Expr->Type));
}
rflags |= CF_CONST;
lflags |= CF_CONST;
/* Absolute: numeric address or const */
lflags |= CF_ABSOLUTE;
if (Gen->Tok == TOK_PLUS_ASSIGN) {
- g_addeqstatic (lflags, Expr->Name, Expr->Val, Expr2.Val);
+ g_addeqstatic (lflags, Expr->Name, Expr->IVal, Expr2.IVal);
} else {
- g_subeqstatic (lflags, Expr->Name, Expr->Val, Expr2.Val);
+ g_subeqstatic (lflags, Expr->Name, Expr->IVal, Expr2.IVal);
}
break;
/* Global variable */
lflags |= CF_EXTERNAL;
if (Gen->Tok == TOK_PLUS_ASSIGN) {
- g_addeqstatic (lflags, Expr->Name, Expr->Val, Expr2.Val);
+ g_addeqstatic (lflags, Expr->Name, Expr->IVal, Expr2.IVal);
} else {
- g_subeqstatic (lflags, Expr->Name, Expr->Val, Expr2.Val);
+ g_subeqstatic (lflags, Expr->Name, Expr->IVal, Expr2.IVal);
}
break;
/* Static variable or literal in the literal pool */
lflags |= CF_STATIC;
if (Gen->Tok == TOK_PLUS_ASSIGN) {
- g_addeqstatic (lflags, Expr->Name, Expr->Val, Expr2.Val);
+ g_addeqstatic (lflags, Expr->Name, Expr->IVal, Expr2.IVal);
} else {
- g_subeqstatic (lflags, Expr->Name, Expr->Val, Expr2.Val);
+ g_subeqstatic (lflags, Expr->Name, Expr->IVal, Expr2.IVal);
}
break;
/* Register variable */
lflags |= CF_REGVAR;
if (Gen->Tok == TOK_PLUS_ASSIGN) {
- g_addeqstatic (lflags, Expr->Name, Expr->Val, Expr2.Val);
+ g_addeqstatic (lflags, Expr->Name, Expr->IVal, Expr2.IVal);
} else {
- g_subeqstatic (lflags, Expr->Name, Expr->Val, Expr2.Val);
+ g_subeqstatic (lflags, Expr->Name, Expr->IVal, Expr2.IVal);
}
break;
case E_LOC_STACK:
/* Value on the stack */
if (Gen->Tok == TOK_PLUS_ASSIGN) {
- g_addeqlocal (lflags, Expr->Val, Expr2.Val);
+ g_addeqlocal (lflags, Expr->IVal, Expr2.IVal);
} else {
- g_subeqlocal (lflags, Expr->Val, Expr2.Val);
+ g_subeqlocal (lflags, Expr->IVal, Expr2.IVal);
}
break;
/* Argument #1 */
ParseArg (&Arg1, Arg1Type);
- g_push (Arg1.Flags, Arg1.Expr.Val);
+ g_push (Arg1.Flags, Arg1.Expr.IVal);
Arg1.End = GetCodePos ();
ParamSize += SizeOf (Arg1Type);
ConsumeComma ();
/* Argument #2 */
ParseArg (&Arg2, Arg2Type);
- g_push (Arg2.Flags, Arg2.Expr.Val);
+ g_push (Arg2.Flags, Arg2.Expr.IVal);
Arg2.End = GetCodePos ();
ParamSize += SizeOf (Arg2Type);
ConsumeComma ();
/* Emit the actual function call. This will also cleanup the stack. */
g_call (CF_FIXARGC, Func_memcpy, ParamSize);
- if (ED_IsConstAbsInt (&Arg3.Expr) && Arg3.Expr.Val == 0) {
+ if (ED_IsConstAbsInt (&Arg3.Expr) && Arg3.Expr.IVal == 0) {
/* memcpy has been called with a count argument of zero */
Warning ("Call to memcpy has no effect");
* be generated. If such a situation is detected, throw away the
* generated, and emit better code.
*/
- if (ED_IsConstAbsInt (&Arg3.Expr) && Arg3.Expr.Val <= 256 &&
+ if (ED_IsConstAbsInt (&Arg3.Expr) && Arg3.Expr.IVal <= 256 &&
((ED_IsRVal (&Arg2.Expr) && ED_IsLocConst (&Arg2.Expr)) ||
(ED_IsLVal (&Arg2.Expr) && ED_IsLocRegister (&Arg2.Expr))) &&
((ED_IsRVal (&Arg1.Expr) && ED_IsLocConst (&Arg1.Expr)) ||
Label = GetLocalLabel ();
/* Generate memcpy code */
- if (Arg3.Expr.Val <= 127) {
+ if (Arg3.Expr.IVal <= 127) {
- AddCodeLine ("ldy #$%02X", (unsigned char) (Arg3.Expr.Val-1));
- AddCodeLine ("lda #$%02X", (unsigned char) Arg2.Expr.Val);
+ AddCodeLine ("ldy #$%02X", (unsigned char) (Arg3.Expr.IVal-1));
+ AddCodeLine ("lda #$%02X", (unsigned char) Arg2.Expr.IVal);
g_defcodelabel (Label);
if (Reg2) {
AddCodeLine ("lda (%s),y", ED_GetLabelName (&Arg2.Expr, 0));
} else {
AddCodeLine ("ldy #$00");
- AddCodeLine ("lda #$%02X", (unsigned char) Arg2.Expr.Val);
+ AddCodeLine ("lda #$%02X", (unsigned char) Arg2.Expr.IVal);
g_defcodelabel (Label);
if (Reg2) {
AddCodeLine ("lda (%s),y", ED_GetLabelName (&Arg2.Expr, 0));
AddCodeLine ("sta %s,y", ED_GetLabelName (&Arg1.Expr, 0));
}
AddCodeLine ("iny");
- AddCodeLine ("cpy #$%02X", (unsigned char) Arg3.Expr.Val);
+ AddCodeLine ("cpy #$%02X", (unsigned char) Arg3.Expr.IVal);
AddCodeLine ("bne %s", LocalLabelName (Label));
}
*/
*Expr = Arg1.Expr;
- } else if (ED_IsConstAbsInt (&Arg3.Expr) && Arg3.Expr.Val <= 256 &&
+ } else if (ED_IsConstAbsInt (&Arg3.Expr) && Arg3.Expr.IVal <= 256 &&
ED_IsRVal (&Arg2.Expr) && ED_IsLocConst (&Arg2.Expr) &&
ED_IsRVal (&Arg1.Expr) && ED_IsLocStack (&Arg1.Expr) &&
- (Arg1.Expr.Val - StackPtr) + Arg3.Expr.Val < 256) {
+ (Arg1.Expr.IVal - StackPtr) + Arg3.Expr.IVal < 256) {
/* It is possible to just use one index register even if the stack
* offset is not zero, by adjusting the offset to the constant
* address calculation could overflow in the linker.
*/
int AllowOneIndex = !ED_IsLocRegister (&Arg2.Expr) &&
- !(ED_IsLocAbs (&Arg2.Expr) && Arg2.Expr.Val < 256);
+ !(ED_IsLocAbs (&Arg2.Expr) && Arg2.Expr.IVal < 256);
/* Calculate the real stack offset */
int Offs = ED_GetStackOffs (&Arg1.Expr, 0);
Label = GetLocalLabel ();
/* Generate memcpy code */
- if (Arg3.Expr.Val <= 127) {
+ if (Arg3.Expr.IVal <= 127) {
if (Offs == 0 || AllowOneIndex) {
- AddCodeLine ("ldy #$%02X", (unsigned char) (Offs + Arg3.Expr.Val - 1));
+ AddCodeLine ("ldy #$%02X", (unsigned char) (Offs + Arg3.Expr.IVal - 1));
g_defcodelabel (Label);
AddCodeLine ("lda %s,y", ED_GetLabelName (&Arg2.Expr, -Offs));
AddCodeLine ("sta (sp),y");
AddCodeLine ("dey");
AddCodeLine ("bpl %s", LocalLabelName (Label));
} else {
- AddCodeLine ("ldx #$%02X", (unsigned char) (Arg3.Expr.Val-1));
- AddCodeLine ("ldy #$%02X", (unsigned char) (Offs + Arg3.Expr.Val - 1));
+ AddCodeLine ("ldx #$%02X", (unsigned char) (Arg3.Expr.IVal-1));
+ AddCodeLine ("ldy #$%02X", (unsigned char) (Offs + Arg3.Expr.IVal - 1));
g_defcodelabel (Label);
AddCodeLine ("lda %s,x", ED_GetLabelName (&Arg2.Expr, 0));
AddCodeLine ("sta (sp),y");
AddCodeLine ("lda %s,y", ED_GetLabelName (&Arg2.Expr, -Offs));
AddCodeLine ("sta (sp),y");
AddCodeLine ("iny");
- AddCodeLine ("cpy #$%02X", (unsigned char) (Offs + Arg3.Expr.Val));
+ AddCodeLine ("cpy #$%02X", (unsigned char) (Offs + Arg3.Expr.IVal));
AddCodeLine ("bne %s", LocalLabelName (Label));
} else {
AddCodeLine ("ldx #$00");
AddCodeLine ("sta (sp),y");
AddCodeLine ("iny");
AddCodeLine ("inx");
- AddCodeLine ("cpx #$%02X", (unsigned char) Arg3.Expr.Val);
+ AddCodeLine ("cpx #$%02X", (unsigned char) Arg3.Expr.IVal);
AddCodeLine ("bne %s", LocalLabelName (Label));
}
*/
*Expr = Arg1.Expr;
- } else if (ED_IsConstAbsInt (&Arg3.Expr) && Arg3.Expr.Val <= 256 &&
+ } else if (ED_IsConstAbsInt (&Arg3.Expr) && Arg3.Expr.IVal <= 256 &&
ED_IsRVal (&Arg2.Expr) && ED_IsLocStack (&Arg2.Expr) &&
- (Arg2.Expr.Val - StackPtr) + Arg3.Expr.Val < 256 &&
+ (Arg2.Expr.IVal - StackPtr) + Arg3.Expr.IVal < 256 &&
ED_IsRVal (&Arg1.Expr) && ED_IsLocConst (&Arg1.Expr)) {
/* It is possible to just use one index register even if the stack
* address calculation could overflow in the linker.
*/
int AllowOneIndex = !ED_IsLocRegister (&Arg1.Expr) &&
- !(ED_IsLocAbs (&Arg1.Expr) && Arg1.Expr.Val < 256);
+ !(ED_IsLocAbs (&Arg1.Expr) && Arg1.Expr.IVal < 256);
/* Calculate the real stack offset */
int Offs = ED_GetStackOffs (&Arg2.Expr, 0);
Label = GetLocalLabel ();
/* Generate memcpy code */
- if (Arg3.Expr.Val <= 127) {
+ if (Arg3.Expr.IVal <= 127) {
if (Offs == 0 || AllowOneIndex) {
- AddCodeLine ("ldy #$%02X", (unsigned char) (Offs + Arg3.Expr.Val - 1));
+ AddCodeLine ("ldy #$%02X", (unsigned char) (Offs + Arg3.Expr.IVal - 1));
g_defcodelabel (Label);
AddCodeLine ("lda (sp),y");
AddCodeLine ("sta %s,y", ED_GetLabelName (&Arg1.Expr, -Offs));
AddCodeLine ("dey");
AddCodeLine ("bpl %s", LocalLabelName (Label));
} else {
- AddCodeLine ("ldx #$%02X", (unsigned char) (Arg3.Expr.Val-1));
- AddCodeLine ("ldy #$%02X", (unsigned char) (Offs + Arg3.Expr.Val - 1));
+ AddCodeLine ("ldx #$%02X", (unsigned char) (Arg3.Expr.IVal-1));
+ AddCodeLine ("ldy #$%02X", (unsigned char) (Offs + Arg3.Expr.IVal - 1));
g_defcodelabel (Label);
AddCodeLine ("lda (sp),y");
AddCodeLine ("sta %s,x", ED_GetLabelName (&Arg1.Expr, 0));
AddCodeLine ("lda (sp),y");
AddCodeLine ("sta %s,y", ED_GetLabelName (&Arg1.Expr, -Offs));
AddCodeLine ("iny");
- AddCodeLine ("cpy #$%02X", (unsigned char) (Offs + Arg3.Expr.Val));
+ AddCodeLine ("cpy #$%02X", (unsigned char) (Offs + Arg3.Expr.IVal));
AddCodeLine ("bne %s", LocalLabelName (Label));
} else {
AddCodeLine ("ldx #$00");
AddCodeLine ("sta %s,x", ED_GetLabelName (&Arg1.Expr, 0));
AddCodeLine ("iny");
AddCodeLine ("inx");
- AddCodeLine ("cpx #$%02X", (unsigned char) Arg3.Expr.Val);
+ AddCodeLine ("cpx #$%02X", (unsigned char) Arg3.Expr.IVal);
AddCodeLine ("bne %s", LocalLabelName (Label));
}
/* Argument #1 */
ParseArg (&Arg1, Arg1Type);
- g_push (Arg1.Flags, Arg1.Expr.Val);
+ g_push (Arg1.Flags, Arg1.Expr.IVal);
Arg1.End = GetCodePos ();
ParamSize += SizeOf (Arg1Type);
ConsumeComma ();
* function if it is a constant zero.
*/
ParseArg (&Arg2, Arg2Type);
- if ((Arg2.Flags & CF_CONST) != 0 && Arg2.Expr.Val == 0) {
+ if ((Arg2.Flags & CF_CONST) != 0 && Arg2.Expr.IVal == 0) {
/* Don't call memset, call bzero instead */
MemSet = 0;
} else {
/* Push the argument */
- g_push (Arg2.Flags, Arg2.Expr.Val);
+ g_push (Arg2.Flags, Arg2.Expr.IVal);
Arg2.End = GetCodePos ();
ParamSize += SizeOf (Arg2Type);
}
/* Emit the actual function call. This will also cleanup the stack. */
g_call (CF_FIXARGC, MemSet? Func_memset : Func__bzero, ParamSize);
- if (ED_IsConstAbsInt (&Arg3.Expr) && Arg3.Expr.Val == 0) {
+ if (ED_IsConstAbsInt (&Arg3.Expr) && Arg3.Expr.IVal == 0) {
/* memset has been called with a count argument of zero */
Warning ("Call to memset has no effect");
* being constant numerical values. Some checks have shown that this
* covers nearly 90% of all memset calls.
*/
- if (ED_IsConstAbsInt (&Arg3.Expr) && Arg3.Expr.Val <= 256 &&
+ if (ED_IsConstAbsInt (&Arg3.Expr) && Arg3.Expr.IVal <= 256 &&
ED_IsConstAbsInt (&Arg2.Expr) &&
((ED_IsRVal (&Arg1.Expr) && ED_IsLocConst (&Arg1.Expr)) ||
(ED_IsLVal (&Arg1.Expr) && ED_IsLocRegister (&Arg1.Expr)))) {
Label = GetLocalLabel ();
/* Generate memset code */
- if (Arg3.Expr.Val <= 127) {
+ if (Arg3.Expr.IVal <= 127) {
- AddCodeLine ("ldy #$%02X", (unsigned char) (Arg3.Expr.Val-1));
- AddCodeLine ("lda #$%02X", (unsigned char) Arg2.Expr.Val);
+ AddCodeLine ("ldy #$%02X", (unsigned char) (Arg3.Expr.IVal-1));
+ AddCodeLine ("lda #$%02X", (unsigned char) Arg2.Expr.IVal);
g_defcodelabel (Label);
if (Reg) {
AddCodeLine ("sta (%s),y", ED_GetLabelName (&Arg1.Expr, 0));
} else {
AddCodeLine ("ldy #$00");
- AddCodeLine ("lda #$%02X", (unsigned char) Arg2.Expr.Val);
+ AddCodeLine ("lda #$%02X", (unsigned char) Arg2.Expr.IVal);
g_defcodelabel (Label);
if (Reg) {
AddCodeLine ("sta (%s),y", ED_GetLabelName (&Arg1.Expr, 0));
AddCodeLine ("sta %s,y", ED_GetLabelName (&Arg1.Expr, 0));
}
AddCodeLine ("iny");
- AddCodeLine ("cpy #$%02X", (unsigned char) Arg3.Expr.Val);
+ AddCodeLine ("cpy #$%02X", (unsigned char) Arg3.Expr.IVal);
AddCodeLine ("bne %s", LocalLabelName (Label));
}
*/
*Expr = Arg1.Expr;
- } else if (ED_IsConstAbsInt (&Arg3.Expr) && Arg3.Expr.Val <= 256 &&
+ } else if (ED_IsConstAbsInt (&Arg3.Expr) && Arg3.Expr.IVal <= 256 &&
ED_IsConstAbsInt (&Arg2.Expr) &&
ED_IsRVal (&Arg1.Expr) && ED_IsLocStack (&Arg1.Expr) &&
- (Arg1.Expr.Val - StackPtr) + Arg3.Expr.Val < 256) {
+ (Arg1.Expr.IVal - StackPtr) + Arg3.Expr.IVal < 256) {
/* Calculate the real stack offset */
int Offs = ED_GetStackOffs (&Arg1.Expr, 0);
/* Generate memset code */
AddCodeLine ("ldy #$%02X", (unsigned char) Offs);
- AddCodeLine ("lda #$%02X", (unsigned char) Arg2.Expr.Val);
+ AddCodeLine ("lda #$%02X", (unsigned char) Arg2.Expr.IVal);
g_defcodelabel (Label);
AddCodeLine ("sta (sp),y");
AddCodeLine ("iny");
- AddCodeLine ("cpy #$%02X", (unsigned char) (Offs + Arg3.Expr.Val));
+ AddCodeLine ("cpy #$%02X", (unsigned char) (Offs + Arg3.Expr.IVal));
AddCodeLine ("bne %s", LocalLabelName (Label));
/* memset returns the address, so the result is actually identical
*/
*Expr = Arg1.Expr;
- } else if (ED_IsConstAbsInt (&Arg3.Expr) && Arg3.Expr.Val <= 256 &&
+ } else if (ED_IsConstAbsInt (&Arg3.Expr) && Arg3.Expr.IVal <= 256 &&
ED_IsConstAbsInt (&Arg2.Expr) &&
- (Arg2.Expr.Val != 0 || CodeSizeFactor > 200)) {
+ (Arg2.Expr.IVal != 0 || CodeSizeFactor > 200)) {
/* Remove all of the generated code but the load of the first
* argument.
/* Generate code */
AddCodeLine ("sta ptr1");
AddCodeLine ("stx ptr1+1");
- if (Arg3.Expr.Val <= 127) {
- AddCodeLine ("ldy #$%02X", (unsigned char) (Arg3.Expr.Val-1));
- AddCodeLine ("lda #$%02X", (unsigned char) Arg2.Expr.Val);
+ if (Arg3.Expr.IVal <= 127) {
+ AddCodeLine ("ldy #$%02X", (unsigned char) (Arg3.Expr.IVal-1));
+ AddCodeLine ("lda #$%02X", (unsigned char) Arg2.Expr.IVal);
g_defcodelabel (Label);
AddCodeLine ("sta (ptr1),y");
AddCodeLine ("dey");
AddCodeLine ("bpl %s", LocalLabelName (Label));
} else {
AddCodeLine ("ldy #$00");
- AddCodeLine ("lda #$%02X", (unsigned char) Arg2.Expr.Val);
+ AddCodeLine ("lda #$%02X", (unsigned char) Arg2.Expr.IVal);
g_defcodelabel (Label);
AddCodeLine ("sta (ptr1),y");
AddCodeLine ("iny");
- AddCodeLine ("cpy #$%02X", (unsigned char) Arg3.Expr.Val);
+ AddCodeLine ("cpy #$%02X", (unsigned char) Arg3.Expr.IVal);
AddCodeLine ("bne %s", LocalLabelName (Label));
}
/* Argument #1 */
ParseArg (&Arg1, Arg1Type);
- g_push (Arg1.Flags, Arg1.Expr.Val);
+ g_push (Arg1.Flags, Arg1.Expr.IVal);
Arg1.End = GetCodePos ();
ParamSize += SizeOf (Arg1Type);
ConsumeComma ();
* address calculation could overflow in the linker.
*/
int AllowOneIndex = !ED_IsLocRegister (&Arg1.Expr) &&
- !(ED_IsLocAbs (&Arg1.Expr) && Arg1.Expr.Val < 256);
+ !(ED_IsLocAbs (&Arg1.Expr) && Arg1.Expr.IVal < 256);
/* Calculate the real stack offset */
int Offs = ED_GetStackOffs (&Arg2.Expr, 0);
* address calculation could overflow in the linker.
*/
int AllowOneIndex = !ED_IsLocRegister (&Arg2.Expr) &&
- !(ED_IsLocAbs (&Arg2.Expr) && Arg2.Expr.Val < 256);
+ !(ED_IsLocAbs (&Arg2.Expr) && Arg2.Expr.IVal < 256);
/* Calculate the real stack offset */
int Offs = ED_GetStackOffs (&Arg1.Expr, 0);
if (ED_IsLocLiteral (&Arg) && IS_Get (&WritableStrings) == 0) {
/* Constant string literal */
- ED_MakeConstAbs (Expr, strlen (GetLiteral (Arg.Val)), type_size_t);
- ResetLiteralPoolOffs (Arg.Val);
+ ED_MakeConstAbs (Expr, strlen (GetLiteral (Arg.IVal)), type_size_t);
+ ResetLiteralPoolOffs (Arg.IVal);
/* We will inline strlen for arrays with constant addresses, if either the
* inlining was forced on the command line, or the array is smaller than
* completely within the reach of a byte sized index register.
*/
} else if (ED_IsLocStack (&Arg) && IsArray && IsByteIndex &&
- (Arg.Val - StackPtr) + ECount < 256) {
+ (Arg.IVal - StackPtr) + ECount < 256) {
/* Calculate the true stack offset */
int Offs = ED_GetStackOffs (&Arg, 0);