mirror of
https://github.com/cc65/cc65.git
synced 2024-12-23 04:30:10 +00:00
Renamed ExprDesc.Val to ExprDesc.IVal. Added an FVal field for a floating
point constant. git-svn-id: svn://svn.cc65.org/cc65/trunk@3107 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
parent
eb388aa237
commit
9fc71c5e93
@ -137,19 +137,19 @@ static void ParseByteArg (StrBuf* T, unsigned Arg)
|
||||
|
||||
/* Check the range but allow negative values if the type is signed */
|
||||
if (IsSignUnsigned (Expr.Type)) {
|
||||
if (Expr.Val < 0 || Expr.Val > 0xFF) {
|
||||
if (Expr.IVal < 0 || Expr.IVal > 0xFF) {
|
||||
AsmRangeError (Arg);
|
||||
Expr.Val = 0;
|
||||
Expr.IVal = 0;
|
||||
}
|
||||
} else {
|
||||
if (Expr.Val < -128 || Expr.Val > 127) {
|
||||
if (Expr.IVal < -128 || Expr.IVal > 127) {
|
||||
AsmRangeError (Arg);
|
||||
Expr.Val = 0;
|
||||
Expr.IVal = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/* Convert into a hex number */
|
||||
xsprintf (Buf, sizeof (Buf), "$%02lX", Expr.Val & 0xFF);
|
||||
xsprintf (Buf, sizeof (Buf), "$%02lX", Expr.IVal & 0xFF);
|
||||
|
||||
/* Add the number to the target buffer */
|
||||
SB_AppendStr (T, Buf);
|
||||
@ -171,19 +171,19 @@ static void ParseWordArg (StrBuf* T, unsigned Arg)
|
||||
|
||||
/* Check the range but allow negative values if the type is signed */
|
||||
if (IsSignUnsigned (Expr.Type)) {
|
||||
if (Expr.Val < 0 || Expr.Val > 0xFFFF) {
|
||||
if (Expr.IVal < 0 || Expr.IVal > 0xFFFF) {
|
||||
AsmRangeError (Arg);
|
||||
Expr.Val = 0;
|
||||
Expr.IVal = 0;
|
||||
}
|
||||
} else {
|
||||
if (Expr.Val < -32768 || Expr.Val > 32767) {
|
||||
if (Expr.IVal < -32768 || Expr.IVal > 32767) {
|
||||
AsmRangeError (Arg);
|
||||
Expr.Val = 0;
|
||||
Expr.IVal = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/* Convert into a hex number */
|
||||
xsprintf (Buf, sizeof (Buf), "$%04lX", Expr.Val & 0xFFFF);
|
||||
xsprintf (Buf, sizeof (Buf), "$%04lX", Expr.IVal & 0xFFFF);
|
||||
|
||||
/* Add the number to the target buffer */
|
||||
SB_AppendStr (T, Buf);
|
||||
@ -204,7 +204,7 @@ static void ParseLongArg (StrBuf* T, unsigned Arg attribute ((unused)))
|
||||
ConstAbsIntExpr (hie1, &Expr);
|
||||
|
||||
/* Convert into a hex number */
|
||||
xsprintf (Buf, sizeof (Buf), "$%08lX", Expr.Val & 0xFFFFFFFF);
|
||||
xsprintf (Buf, sizeof (Buf), "$%08lX", Expr.IVal & 0xFFFFFFFF);
|
||||
|
||||
/* Add the number to the target buffer */
|
||||
SB_AppendStr (T, Buf);
|
||||
@ -302,7 +302,7 @@ static void ParseStrArg (StrBuf* T, unsigned Arg attribute ((unused)))
|
||||
|
||||
default:
|
||||
ConstAbsIntExpr (hie1, &Expr);
|
||||
xsprintf (Buf, sizeof (Buf), "%ld", Expr.Val);
|
||||
xsprintf (Buf, sizeof (Buf), "%ld", Expr.IVal);
|
||||
SB_AppendStr (T, Buf);
|
||||
break;
|
||||
}
|
||||
|
@ -191,7 +191,7 @@ static void AddEncodeToDeclaration (Declaration* D, type T, unsigned long Val)
|
||||
D->Index += DECODE_SIZE;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
static void ParseStorageClass (DeclSpec* D, unsigned DefStorage)
|
||||
/* Parse a storage class */
|
||||
@ -267,10 +267,10 @@ static void ParseEnumDecl (void)
|
||||
|
||||
/* Check for an assigned value */
|
||||
if (CurTok.Tok == TOK_ASSIGN) {
|
||||
ExprDesc lval;
|
||||
ExprDesc Expr;
|
||||
NextToken ();
|
||||
ConstAbsIntExpr (hie1, &lval);
|
||||
EnumVal = lval.Val;
|
||||
ConstAbsIntExpr (hie1, &Expr);
|
||||
EnumVal = Expr.IVal;
|
||||
}
|
||||
|
||||
/* Add an entry to the symbol table */
|
||||
@ -281,7 +281,7 @@ static void ParseEnumDecl (void)
|
||||
break;
|
||||
NextToken ();
|
||||
}
|
||||
ConsumeRCurly ();
|
||||
ConsumeRCurly ();
|
||||
}
|
||||
|
||||
|
||||
@ -1045,17 +1045,17 @@ static void Decl (const DeclSpec* Spec, Declaration* D, unsigned Mode)
|
||||
NextToken ();
|
||||
/* Read the size if it is given */
|
||||
if (CurTok.Tok != TOK_RBRACK) {
|
||||
ExprDesc lval;
|
||||
ConstAbsIntExpr (hie1, &lval);
|
||||
if (lval.Val <= 0) {
|
||||
ExprDesc Expr;
|
||||
ConstAbsIntExpr (hie1, &Expr);
|
||||
if (Expr.IVal <= 0) {
|
||||
if (D->Ident[0] != '\0') {
|
||||
Error ("Size of array `%s' is invalid", D->Ident);
|
||||
} else {
|
||||
Error ("Size of array is invalid");
|
||||
}
|
||||
lval.Val = 1;
|
||||
Expr.IVal = 1;
|
||||
}
|
||||
Size = lval.Val;
|
||||
Size = Expr.IVal;
|
||||
}
|
||||
ConsumeRBrack ();
|
||||
|
||||
@ -1431,7 +1431,7 @@ static unsigned ParseVoidInit (void)
|
||||
case T_UCHAR:
|
||||
if (ED_IsConstAbsInt (&Expr)) {
|
||||
/* Make it byte sized */
|
||||
Expr.Val &= 0xFF;
|
||||
Expr.IVal &= 0xFF;
|
||||
}
|
||||
DefineData (&Expr);
|
||||
Size += SIZEOF_CHAR;
|
||||
@ -1445,7 +1445,7 @@ static unsigned ParseVoidInit (void)
|
||||
case T_ARRAY:
|
||||
if (ED_IsConstAbsInt (&Expr)) {
|
||||
/* Make it word sized */
|
||||
Expr.Val &= 0xFFFF;
|
||||
Expr.IVal &= 0xFFFF;
|
||||
}
|
||||
DefineData (&Expr);
|
||||
Size += SIZEOF_INT;
|
||||
@ -1455,7 +1455,7 @@ static unsigned ParseVoidInit (void)
|
||||
case T_ULONG:
|
||||
if (ED_IsConstAbsInt (&Expr)) {
|
||||
/* Make it dword sized */
|
||||
Expr.Val &= 0xFFFFFFFF;
|
||||
Expr.IVal &= 0xFFFFFFFF;
|
||||
}
|
||||
DefineData (&Expr);
|
||||
Size += SIZEOF_LONG;
|
||||
@ -1527,7 +1527,7 @@ static unsigned ParseInitInternal (type* T, int AllowFlexibleMembers)
|
||||
unsigned ParseInit (type* T)
|
||||
/* Parse initialization of variables. Return the number of data bytes. */
|
||||
{
|
||||
/* Parse the initialization */
|
||||
/* Parse the initialization */
|
||||
unsigned Size = ParseInitInternal (T, !ANSI);
|
||||
|
||||
/* The initialization may not generate code on global level, because code
|
||||
|
204
src/cc65/expr.c
204
src/cc65/expr.c
@ -195,18 +195,18 @@ void DefineData (ExprDesc* Expr)
|
||||
|
||||
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:
|
||||
@ -216,7 +216,7 @@ void DefineData (ExprDesc* Expr)
|
||||
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:
|
||||
@ -233,18 +233,18 @@ static void LoadConstant (unsigned Flags, ExprDesc* Expr)
|
||||
|
||||
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:
|
||||
@ -254,10 +254,10 @@ static void LoadConstant (unsigned Flags, ExprDesc* Expr)
|
||||
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:
|
||||
@ -392,28 +392,28 @@ void ExprLoad (unsigned Flags, ExprDesc* Expr)
|
||||
|
||||
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:
|
||||
@ -425,7 +425,7 @@ void ExprLoad (unsigned Flags, ExprDesc* Expr)
|
||||
|
||||
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:
|
||||
@ -438,12 +438,12 @@ void ExprLoad (unsigned Flags, ExprDesc* Expr)
|
||||
} 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 */
|
||||
@ -593,10 +593,10 @@ static unsigned FunctionParamList (FuncDesc* Func)
|
||||
}
|
||||
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 */
|
||||
@ -768,7 +768,7 @@ static void Primary (ExprDesc* E)
|
||||
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;
|
||||
}
|
||||
@ -834,7 +834,7 @@ static void Primary (ExprDesc* E)
|
||||
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;
|
||||
@ -851,7 +851,7 @@ static void Primary (ExprDesc* E)
|
||||
} 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 */
|
||||
@ -915,7 +915,7 @@ static void Primary (ExprDesc* E)
|
||||
/* 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;
|
||||
@ -1052,7 +1052,7 @@ static void ArrayRef (ExprDesc* Expr)
|
||||
/* 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);
|
||||
@ -1064,7 +1064,7 @@ static void ArrayRef (ExprDesc* Expr)
|
||||
if (IsTypeArray (Expr->Type)) {
|
||||
|
||||
/* Adjust the offset */
|
||||
Expr->Val += SubScript.Val;
|
||||
Expr->IVal += SubScript.IVal;
|
||||
|
||||
} else {
|
||||
|
||||
@ -1077,7 +1077,7 @@ static void ArrayRef (ExprDesc* Expr)
|
||||
}
|
||||
|
||||
/* Use the offset */
|
||||
Expr->Val = SubScript.Val;
|
||||
Expr->IVal = SubScript.IVal;
|
||||
}
|
||||
|
||||
} else {
|
||||
@ -1089,7 +1089,7 @@ static void ArrayRef (ExprDesc* Expr)
|
||||
* 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);
|
||||
|
||||
}
|
||||
|
||||
@ -1170,29 +1170,29 @@ static void ArrayRef (ExprDesc* Expr)
|
||||
|
||||
/* 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1262,7 +1262,7 @@ static void StructRef (ExprDesc* Expr)
|
||||
}
|
||||
|
||||
/* 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;
|
||||
@ -1362,28 +1362,28 @@ void Store (ExprDesc* Expr, const type* StoreType)
|
||||
|
||||
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:
|
||||
@ -1393,7 +1393,7 @@ void Store (ExprDesc* Expr, const type* StoreType)
|
||||
|
||||
case E_LOC_EXPR:
|
||||
/* An expression in the primary register */
|
||||
g_putind (Flags, Expr->Val);
|
||||
g_putind (Flags, Expr->IVal);
|
||||
break;
|
||||
|
||||
default:
|
||||
@ -1433,28 +1433,28 @@ static void PreInc (ExprDesc* Expr)
|
||||
|
||||
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:
|
||||
@ -1464,7 +1464,7 @@ static void PreInc (ExprDesc* Expr)
|
||||
|
||||
case E_LOC_EXPR:
|
||||
/* An expression in the primary register */
|
||||
g_addeqind (Flags, Expr->Val, Val);
|
||||
g_addeqind (Flags, Expr->IVal, Val);
|
||||
break;
|
||||
|
||||
default:
|
||||
@ -1475,7 +1475,7 @@ static void PreInc (ExprDesc* Expr)
|
||||
ED_MakeRValExpr (Expr);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
static void PreDec (ExprDesc* Expr)
|
||||
/* Handle the predecrement operators */
|
||||
@ -1504,28 +1504,28 @@ static void PreDec (ExprDesc* Expr)
|
||||
|
||||
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:
|
||||
@ -1535,7 +1535,7 @@ static void PreDec (ExprDesc* Expr)
|
||||
|
||||
case E_LOC_EXPR:
|
||||
/* An expression in the primary register */
|
||||
g_subeqind (Flags, Expr->Val, Val);
|
||||
g_subeqind (Flags, Expr->IVal, Val);
|
||||
break;
|
||||
|
||||
default:
|
||||
@ -1547,7 +1547,7 @@ static void PreDec (ExprDesc* Expr)
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
static void PostIncDec (ExprDesc* Expr, void (*inc) (unsigned, unsigned long))
|
||||
/* Handle i-- and i++ */
|
||||
{
|
||||
@ -1612,9 +1612,9 @@ static void UnaryOp (ExprDesc* Expr)
|
||||
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 {
|
||||
@ -1664,7 +1664,7 @@ void hie10 (ExprDesc* Expr)
|
||||
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);
|
||||
@ -1797,7 +1797,7 @@ static void hie_internal (const GenDesc* Ops, /* List of generators */
|
||||
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);
|
||||
@ -1821,7 +1821,7 @@ static void hie_internal (const GenDesc* Ops, /* List of generators */
|
||||
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);
|
||||
@ -1838,9 +1838,9 @@ static void hie_internal (const GenDesc* Ops, /* List of generators */
|
||||
/* 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) {
|
||||
@ -1855,7 +1855,7 @@ static void hie_internal (const GenDesc* Ops, /* List of generators */
|
||||
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);
|
||||
@ -1893,7 +1893,7 @@ static void hie_compare (const GenDesc* Ops, /* List of generators */
|
||||
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);
|
||||
@ -1933,7 +1933,7 @@ static void hie_compare (const GenDesc* Ops, /* List of generators */
|
||||
pop (ltype);
|
||||
|
||||
/* Evaluate the result */
|
||||
Expr->Val = kcalc (tok, Expr->Val, Expr2.Val);
|
||||
Expr->IVal = kcalc (tok, Expr->IVal, Expr2.IVal);
|
||||
|
||||
} else {
|
||||
|
||||
@ -1971,7 +1971,7 @@ static void hie_compare (const GenDesc* Ops, /* List of generators */
|
||||
}
|
||||
|
||||
/* Generate code */
|
||||
Gen->Func (flags, Expr2.Val);
|
||||
Gen->Func (flags, Expr2.IVal);
|
||||
|
||||
/* The result is an rvalue in the primary */
|
||||
ED_MakeRValExpr (Expr);
|
||||
@ -2036,16 +2036,16 @@ static void parseadd (ExprDesc* 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 */
|
||||
@ -2085,10 +2085,10 @@ static void parseadd (ExprDesc* Expr)
|
||||
/* 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)) {
|
||||
|
||||
@ -2105,16 +2105,16 @@ static void parseadd (ExprDesc* Expr)
|
||||
*/
|
||||
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);
|
||||
}
|
||||
@ -2124,10 +2124,10 @@ static void parseadd (ExprDesc* Expr)
|
||||
/* 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 */
|
||||
@ -2158,7 +2158,7 @@ static void parseadd (ExprDesc* Expr)
|
||||
/* 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)) {
|
||||
@ -2176,7 +2176,7 @@ static void parseadd (ExprDesc* Expr)
|
||||
}
|
||||
|
||||
/* Generate code for the add */
|
||||
g_inc (flags | CF_CONST, Expr2.Val);
|
||||
g_inc (flags | CF_CONST, Expr2.IVal);
|
||||
|
||||
} else {
|
||||
|
||||
@ -2274,14 +2274,14 @@ static void parsesub (ExprDesc* Expr)
|
||||
/* 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 */
|
||||
@ -2289,7 +2289,7 @@ static void parsesub (ExprDesc* Expr)
|
||||
} 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 `-'");
|
||||
@ -2308,7 +2308,7 @@ static void parsesub (ExprDesc* Expr)
|
||||
|
||||
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)) {
|
||||
@ -2330,7 +2330,7 @@ static void parsesub (ExprDesc* Expr)
|
||||
}
|
||||
|
||||
/* 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) {
|
||||
@ -2512,7 +2512,7 @@ static void hieAndPP (ExprDesc* Expr)
|
||||
ConstAbsIntExpr (hie2, &Expr2);
|
||||
|
||||
/* Combine the two */
|
||||
Expr->Val = (Expr->Val && Expr2.Val);
|
||||
Expr->IVal = (Expr->IVal && Expr2.IVal);
|
||||
}
|
||||
}
|
||||
|
||||
@ -2535,7 +2535,7 @@ static void hieOrPP (ExprDesc *Expr)
|
||||
ConstAbsIntExpr (hieAndPP, &Expr2);
|
||||
|
||||
/* Combine the two */
|
||||
Expr->Val = (Expr->Val || Expr2.Val);
|
||||
Expr->IVal = (Expr->IVal || Expr2.IVal);
|
||||
}
|
||||
}
|
||||
|
||||
@ -2852,7 +2852,7 @@ static void opeq (const GenDesc* Gen, ExprDesc* Expr)
|
||||
}
|
||||
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
|
||||
@ -2864,11 +2864,11 @@ static void opeq (const GenDesc* Gen, ExprDesc* Expr)
|
||||
|
||||
/* 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 */
|
||||
@ -2938,7 +2938,7 @@ static void addsubeq (const GenDesc* Gen, ExprDesc *Expr)
|
||||
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;
|
||||
@ -2965,9 +2965,9 @@ static void addsubeq (const GenDesc* Gen, ExprDesc *Expr)
|
||||
/* 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;
|
||||
|
||||
@ -2975,9 +2975,9 @@ static void addsubeq (const GenDesc* Gen, ExprDesc *Expr)
|
||||
/* 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;
|
||||
|
||||
@ -2986,9 +2986,9 @@ static void addsubeq (const GenDesc* Gen, ExprDesc *Expr)
|
||||
/* 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;
|
||||
|
||||
@ -2996,18 +2996,18 @@ static void addsubeq (const GenDesc* Gen, ExprDesc *Expr)
|
||||
/* 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;
|
||||
|
||||
|
@ -58,9 +58,10 @@ ExprDesc* ED_Init (ExprDesc* Expr)
|
||||
{
|
||||
Expr->Sym = 0;
|
||||
Expr->Type = 0;
|
||||
Expr->Val = 0;
|
||||
Expr->Flags = 0;
|
||||
Expr->Name = 0;
|
||||
Expr->IVal = 0;
|
||||
Expr->FVal = 0.0;
|
||||
return Expr;
|
||||
}
|
||||
|
||||
@ -75,7 +76,7 @@ const char* ED_GetLabelName (const ExprDesc* Expr, long Offs)
|
||||
static char Buf[256];
|
||||
|
||||
/* Expr may have it's own offset, adjust Offs accordingly */
|
||||
Offs += Expr->Val;
|
||||
Offs += Expr->IVal;
|
||||
|
||||
/* Generate a label depending on the location */
|
||||
switch (ED_GetLoc (Expr)) {
|
||||
@ -130,7 +131,7 @@ int ED_GetStackOffs (const ExprDesc* Expr, int Offs)
|
||||
*/
|
||||
{
|
||||
PRECONDITION (ED_IsLocStack (Expr));
|
||||
Offs += ((int) Expr->Val) - StackPtr;
|
||||
Offs += ((int) Expr->IVal) - StackPtr;
|
||||
CHECK (Offs >= 0); /* Cannot handle negative stack offsets */
|
||||
return Offs;
|
||||
}
|
||||
@ -142,9 +143,10 @@ ExprDesc* ED_MakeConstAbs (ExprDesc* Expr, long Value, type* Type)
|
||||
{
|
||||
Expr->Sym = 0;
|
||||
Expr->Type = Type;
|
||||
Expr->Val = Value;
|
||||
Expr->Flags = E_LOC_ABS | E_RTYPE_RVAL;
|
||||
Expr->Name = 0;
|
||||
Expr->IVal = Value;
|
||||
Expr->FVal = 0.0;
|
||||
return Expr;
|
||||
}
|
||||
|
||||
@ -155,9 +157,10 @@ ExprDesc* ED_MakeConstAbsInt (ExprDesc* Expr, long Value)
|
||||
{
|
||||
Expr->Sym = 0;
|
||||
Expr->Type = type_int;
|
||||
Expr->Val = Value;
|
||||
Expr->Flags = E_LOC_ABS | E_RTYPE_RVAL;
|
||||
Expr->Name = 0;
|
||||
Expr->IVal = Value;
|
||||
Expr->FVal = 0.0;
|
||||
return Expr;
|
||||
}
|
||||
|
||||
@ -169,10 +172,11 @@ ExprDesc* ED_MakeRValExpr (ExprDesc* Expr)
|
||||
*/
|
||||
{
|
||||
Expr->Sym = 0;
|
||||
Expr->Val = 0; /* No offset */
|
||||
Expr->Flags &= ~(E_MASK_LOC | E_MASK_RTYPE | E_NEED_TEST | E_CC_SET);
|
||||
Expr->Flags |= (E_LOC_EXPR | E_RTYPE_RVAL);
|
||||
Expr->Name = 0;
|
||||
Expr->IVal = 0; /* No offset */
|
||||
Expr->FVal = 0.0;
|
||||
return Expr;
|
||||
}
|
||||
|
||||
@ -184,10 +188,11 @@ ExprDesc* ED_MakeLValExpr (ExprDesc* Expr)
|
||||
*/
|
||||
{
|
||||
Expr->Sym = 0;
|
||||
Expr->Val = 0; /* No offset */
|
||||
Expr->Flags &= ~(E_MASK_LOC | E_MASK_RTYPE | E_NEED_TEST | E_CC_SET);
|
||||
Expr->Flags |= (E_LOC_EXPR | E_RTYPE_LVAL);
|
||||
Expr->Name = 0;
|
||||
Expr->IVal = 0; /* No offset */
|
||||
Expr->FVal = 0.0;
|
||||
return Expr;
|
||||
}
|
||||
|
||||
@ -227,7 +232,7 @@ int ED_IsNullPtr (const ExprDesc* Expr)
|
||||
/* Return true if the given expression is a NULL pointer constant */
|
||||
{
|
||||
return (Expr->Flags & (E_MASK_LOC|E_MASK_RTYPE)) == (E_LOC_ABS|E_RTYPE_RVAL) &&
|
||||
Expr->Val == 0 &&
|
||||
Expr->IVal == 0 &&
|
||||
IsClassInt (Expr->Type);
|
||||
}
|
||||
|
||||
@ -262,7 +267,8 @@ void PrintExprDesc (FILE* F, ExprDesc* E)
|
||||
fprintf (F, "Type: (unknown)\n"
|
||||
"Raw type: (unknown)\n");
|
||||
}
|
||||
fprintf (F, "Value: 0x%08lX\n", E->Val);
|
||||
fprintf (F, "IVal: 0x%08lX\n", E->IVal);
|
||||
fprintf (F, "FVal: %f\n", E->FVal);
|
||||
|
||||
Flags = E->Flags;
|
||||
Sep = '(';
|
||||
|
@ -86,9 +86,10 @@ typedef struct ExprDesc ExprDesc;
|
||||
struct ExprDesc {
|
||||
struct SymEntry* Sym; /* Symbol table entry if known */
|
||||
type* Type; /* Type array of expression */
|
||||
long Val; /* Value if expression constant */
|
||||
unsigned short Flags;
|
||||
unsigned Flags;
|
||||
unsigned long Name; /* Name or label number */
|
||||
long IVal; /* Integer value if expression constant */
|
||||
float FVal; /* Floating point value */
|
||||
};
|
||||
|
||||
|
||||
|
@ -224,7 +224,7 @@ static unsigned ParseAutoDecl (Declaration* Decl, unsigned* SC)
|
||||
}
|
||||
|
||||
/* Push the value */
|
||||
g_push (Flags | TypeOf (Decl->Type), Expr.Val);
|
||||
g_push (Flags | TypeOf (Decl->Type), Expr.IVal);
|
||||
|
||||
}
|
||||
|
||||
|
@ -755,8 +755,8 @@ static int PushIf (int Skip, int Invert, int Cond)
|
||||
|
||||
static int DoIf (int Skip)
|
||||
/* Process #if directive */
|
||||
{
|
||||
ExprDesc lval;
|
||||
{
|
||||
ExprDesc Expr;
|
||||
char* S;
|
||||
|
||||
/* We're about to abuse the compiler expression parser to evaluate the
|
||||
@ -804,7 +804,7 @@ static int DoIf (int Skip)
|
||||
NextToken ();
|
||||
|
||||
/* Call the expression parser */
|
||||
ConstExpr (hie1, &lval);
|
||||
ConstExpr (hie1, &Expr);
|
||||
|
||||
/* End preprocessing mode */
|
||||
Preprocessing = 0;
|
||||
@ -814,7 +814,7 @@ static int DoIf (int Skip)
|
||||
NextTok = sv2;
|
||||
|
||||
/* Set the #if condition according to the expression result */
|
||||
return PushIf (Skip, 1, lval.Val != 0);
|
||||
return PushIf (Skip, 1, Expr.IVal != 0);
|
||||
}
|
||||
|
||||
|
||||
|
@ -205,14 +205,14 @@ static void StdFunc_memcpy (FuncDesc* F attribute ((unused)), ExprDesc* Expr)
|
||||
|
||||
/* 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 ();
|
||||
@ -230,7 +230,7 @@ static void StdFunc_memcpy (FuncDesc* F attribute ((unused)), ExprDesc* Expr)
|
||||
/* 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");
|
||||
@ -252,7 +252,7 @@ static void StdFunc_memcpy (FuncDesc* F attribute ((unused)), ExprDesc* Expr)
|
||||
* 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)) ||
|
||||
@ -268,10 +268,10 @@ static void StdFunc_memcpy (FuncDesc* F attribute ((unused)), ExprDesc* 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));
|
||||
@ -289,7 +289,7 @@ static void StdFunc_memcpy (FuncDesc* F attribute ((unused)), ExprDesc* Expr)
|
||||
} 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));
|
||||
@ -302,7 +302,7 @@ static void StdFunc_memcpy (FuncDesc* F attribute ((unused)), ExprDesc* Expr)
|
||||
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));
|
||||
|
||||
}
|
||||
@ -312,10 +312,10 @@ static void StdFunc_memcpy (FuncDesc* F attribute ((unused)), ExprDesc* Expr)
|
||||
*/
|
||||
*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
|
||||
@ -325,7 +325,7 @@ static void StdFunc_memcpy (FuncDesc* F attribute ((unused)), ExprDesc* Expr)
|
||||
* 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);
|
||||
@ -337,18 +337,18 @@ static void StdFunc_memcpy (FuncDesc* F attribute ((unused)), ExprDesc* Expr)
|
||||
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");
|
||||
@ -365,7 +365,7 @@ static void StdFunc_memcpy (FuncDesc* F attribute ((unused)), ExprDesc* Expr)
|
||||
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");
|
||||
@ -375,7 +375,7 @@ static void StdFunc_memcpy (FuncDesc* F attribute ((unused)), ExprDesc* Expr)
|
||||
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));
|
||||
}
|
||||
|
||||
@ -386,9 +386,9 @@ static void StdFunc_memcpy (FuncDesc* F attribute ((unused)), ExprDesc* Expr)
|
||||
*/
|
||||
*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
|
||||
@ -399,7 +399,7 @@ static void StdFunc_memcpy (FuncDesc* F attribute ((unused)), ExprDesc* Expr)
|
||||
* 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);
|
||||
@ -411,18 +411,18 @@ static void StdFunc_memcpy (FuncDesc* F attribute ((unused)), ExprDesc* Expr)
|
||||
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));
|
||||
@ -439,7 +439,7 @@ static void StdFunc_memcpy (FuncDesc* F attribute ((unused)), ExprDesc* Expr)
|
||||
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");
|
||||
@ -449,7 +449,7 @@ static void StdFunc_memcpy (FuncDesc* F attribute ((unused)), ExprDesc* Expr)
|
||||
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));
|
||||
}
|
||||
|
||||
@ -500,7 +500,7 @@ static void StdFunc_memset (FuncDesc* F attribute ((unused)), ExprDesc* Expr)
|
||||
|
||||
/* 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 ();
|
||||
@ -509,12 +509,12 @@ static void StdFunc_memset (FuncDesc* F attribute ((unused)), ExprDesc* Expr)
|
||||
* 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);
|
||||
}
|
||||
@ -533,7 +533,7 @@ static void StdFunc_memset (FuncDesc* F attribute ((unused)), ExprDesc* Expr)
|
||||
/* 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");
|
||||
@ -559,7 +559,7 @@ static void StdFunc_memset (FuncDesc* F attribute ((unused)), ExprDesc* Expr)
|
||||
* 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)))) {
|
||||
@ -573,10 +573,10 @@ static void StdFunc_memset (FuncDesc* F attribute ((unused)), ExprDesc* 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));
|
||||
@ -589,7 +589,7 @@ static void StdFunc_memset (FuncDesc* F attribute ((unused)), ExprDesc* Expr)
|
||||
} 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));
|
||||
@ -597,7 +597,7 @@ static void StdFunc_memset (FuncDesc* F attribute ((unused)), ExprDesc* Expr)
|
||||
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));
|
||||
|
||||
}
|
||||
@ -607,10 +607,10 @@ static void StdFunc_memset (FuncDesc* F attribute ((unused)), ExprDesc* Expr)
|
||||
*/
|
||||
*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);
|
||||
@ -623,11 +623,11 @@ static void StdFunc_memset (FuncDesc* F attribute ((unused)), ExprDesc* Expr)
|
||||
|
||||
/* 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
|
||||
@ -635,9 +635,9 @@ static void StdFunc_memset (FuncDesc* F attribute ((unused)), ExprDesc* Expr)
|
||||
*/
|
||||
*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.
|
||||
@ -650,20 +650,20 @@ static void StdFunc_memset (FuncDesc* F attribute ((unused)), ExprDesc* Expr)
|
||||
/* 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));
|
||||
}
|
||||
|
||||
@ -719,7 +719,7 @@ static void StdFunc_strcpy (FuncDesc* F attribute ((unused)), ExprDesc* Expr)
|
||||
|
||||
/* 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 ();
|
||||
@ -794,7 +794,7 @@ static void StdFunc_strcpy (FuncDesc* F attribute ((unused)), ExprDesc* Expr)
|
||||
* 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);
|
||||
@ -837,7 +837,7 @@ static void StdFunc_strcpy (FuncDesc* F attribute ((unused)), ExprDesc* Expr)
|
||||
* 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);
|
||||
@ -940,8 +940,8 @@ static void StdFunc_strlen (FuncDesc* F attribute ((unused)), ExprDesc* Expr)
|
||||
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
|
||||
@ -968,7 +968,7 @@ static void StdFunc_strlen (FuncDesc* F attribute ((unused)), ExprDesc* Expr)
|
||||
* 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);
|
||||
|
@ -148,7 +148,7 @@ void SwitchStatement (void)
|
||||
ConstAbsIntExpr (hie1, &CaseExpr);
|
||||
|
||||
/* Check the range of the expression */
|
||||
Val = CaseExpr.Val;
|
||||
Val = CaseExpr.IVal;
|
||||
switch (SwitchExprType) {
|
||||
|
||||
case T_SCHAR:
|
||||
|
@ -63,13 +63,13 @@ unsigned Test (unsigned Label, int Invert)
|
||||
if (ED_IsConstAbs (&Expr)) {
|
||||
|
||||
/* Result is constant, so we know the outcome */
|
||||
Result = (Expr.Val != 0);
|
||||
Result = (Expr.IVal != 0);
|
||||
|
||||
/* Constant rvalue */
|
||||
if (!Invert && Expr.Val == 0) {
|
||||
if (!Invert && Expr.IVal == 0) {
|
||||
g_jump (Label);
|
||||
Warning ("Unreachable code");
|
||||
} else if (Invert && Expr.Val != 0) {
|
||||
} else if (Invert && Expr.IVal != 0) {
|
||||
g_jump (Label);
|
||||
}
|
||||
|
||||
|
@ -138,13 +138,13 @@ static void DoConversion (ExprDesc* Expr, const type* NewType)
|
||||
if (NewBits <= OldBits) {
|
||||
|
||||
/* Cut the value to the new size */
|
||||
Expr->Val &= (0xFFFFFFFFUL >> (32 - NewBits));
|
||||
Expr->IVal &= (0xFFFFFFFFUL >> (32 - NewBits));
|
||||
|
||||
/* If the new type is signed, sign extend the value */
|
||||
if (!IsSignUnsigned (NewType)) {
|
||||
if (Expr->Val & (0x01UL << (NewBits-1))) {
|
||||
if (Expr->IVal & (0x01UL << (NewBits-1))) {
|
||||
/* Beware: Use the safe shift routine here. */
|
||||
Expr->Val |= shl_l (~0UL, NewBits);
|
||||
Expr->IVal |= shl_l (~0UL, NewBits);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -233,7 +233,7 @@ void TypeConversion (ExprDesc* Expr, type* NewType)
|
||||
}
|
||||
} else if (IsClassInt (Expr->Type)) {
|
||||
/* Int to pointer assignment is valid only for constant zero */
|
||||
if (!ED_IsConstAbsInt (Expr) || Expr->Val != 0) {
|
||||
if (!ED_IsConstAbsInt (Expr) || Expr->IVal != 0) {
|
||||
Warning ("Converting integer to pointer without a cast");
|
||||
}
|
||||
} else if (IsTypeFuncPtr (NewType) && IsTypeFunc(Expr->Type)) {
|
||||
|
Loading…
Reference in New Issue
Block a user