#include "expr.h"
#include "function.h"
#include "global.h"
+#include "loadexpr.h"
#include "locals.h"
+#include "stackptr.h"
#include "symtab.h"
#include "typeconv.h"
/* Check for an optional initialization */
if (CurTok.Tok == TOK_ASSIGN) {
- ExprDesc lval;
+ ExprDesc Expr;
/* Skip the '=' */
NextToken ();
} else {
/* Parse the expression */
- hie1 (InitExprDesc (&lval));
+ hie1 (&Expr);
/* Convert it to the target type */
- TypeConversion (&lval, Decl->Type);
+ TypeConversion (&Expr, Decl->Type);
/* Load the value into the primary */
- ExprLoad (CF_NONE, &lval);
+ LoadExpr (CF_NONE, &Expr);
/* Store the value into the variable */
g_putstatic (CF_REGVAR | TypeOf (Decl->Type), Reg, 0);
/* Check for an optional initialization */
if (CurTok.Tok == TOK_ASSIGN) {
- ExprDesc lval;
+ ExprDesc Expr;
/* Skip the '=' */
NextToken ();
Flags = (Size == SIZEOF_CHAR)? CF_FORCECHAR : CF_NONE;
/* Parse the expression */
- hie1 (InitExprDesc (&lval));
+ hie1 (&Expr);
/* Convert it to the target type */
- TypeConversion (&lval, Decl->Type);
+ TypeConversion (&Expr, Decl->Type);
/* If the value is not const, load it into the primary.
* Otherwise pass the information to the code generator.
*/
- if (ED_IsLVal (&lval) || lval.Flags != E_MCONST) {
- ExprLoad (CF_NONE, &lval);
- ED_MakeRVal (&lval);
- } else {
+ if (ED_IsConstAbsInt (&Expr)) {
Flags |= CF_CONST;
+ } else {
+ LoadExpr (CF_NONE, &Expr);
+ ED_MakeRVal (&Expr);
}
/* Push the value */
- g_push (Flags | TypeOf (Decl->Type), lval.ConstVal);
+ g_push (Flags | TypeOf (Decl->Type), Expr.IVal);
}
*SC |= SC_REF;
/* Variable is located at the current SP */
- SymData = oursp;
+ SymData = StackPtr;
} else {
/* Non-initialized local variable. Just keep track of
/* Allow assignments */
if (CurTok.Tok == TOK_ASSIGN) {
- ExprDesc lval;
+ ExprDesc Expr;
/* Skip the '=' */
NextToken ();
} else {
/* Parse the expression */
- hie1 (InitExprDesc (&lval));
+ hie1 (&Expr);
/* Convert it to the target type */
- TypeConversion (&lval, Decl->Type);
+ TypeConversion (&Expr, Decl->Type);
/* Load the value into the primary */
- ExprLoad (CF_NONE, &lval);
+ LoadExpr (CF_NONE, &Expr);
/* Store the value into the variable */
g_putstatic (TypeOf (Decl->Type), SymData, 0);
/* Declare local variables and types. */
{
/* Remember the current stack pointer */
- int InitialStack = oursp;
+ int InitialStack = StackPtr;
/* Loop until we don't find any more variables */
while (1) {
/* In case we've allocated local variables in this block, emit a call to
* the stack checking routine if stack checks are enabled.
*/
- if (IS_Get (&CheckStack) && InitialStack != oursp) {
+ if (IS_Get (&CheckStack) && InitialStack != StackPtr) {
g_cstackcheck ();
}
}