1
0
mirror of https://github.com/cc65/cc65.git synced 2025-01-11 11:30:13 +00:00

More renaming

git-svn-id: svn://svn.cc65.org/cc65/trunk@806 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
cuz 2001-07-17 21:29:21 +00:00
parent cc83744882
commit c571214513
4 changed files with 158 additions and 158 deletions

View File

@ -961,7 +961,7 @@ static void ParseVoidInit (void)
ConsumeLCurly (); ConsumeLCurly ();
do { do {
constexpr (&lval); constexpr (&lval);
switch (lval.e_tptr[0]) { switch (lval.Type[0]) {
case T_SCHAR: case T_SCHAR:
case T_UCHAR: case T_UCHAR:

View File

@ -117,7 +117,7 @@ static unsigned GlobalModeFlags (unsigned flags)
static int IsNullPtr (ExprDesc* lval) static int IsNullPtr (ExprDesc* lval)
/* Return true if this is the NULL pointer constant */ /* Return true if this is the NULL pointer constant */
{ {
return (IsClassInt (lval->e_tptr) && /* Is it an int? */ return (IsClassInt (lval->Type) && /* Is it an int? */
lval->e_flags == E_MCONST && /* Is it constant? */ lval->e_flags == E_MCONST && /* Is it constant? */
lval->e_const == 0); /* And is it's value zero? */ lval->e_const == 0); /* And is it's value zero? */
} }
@ -163,8 +163,8 @@ static unsigned typeadjust (ExprDesc* lhs, ExprDesc* rhs, int NoPush)
unsigned flags; unsigned flags;
/* Get the type strings */ /* Get the type strings */
type* lhst = lhs->e_tptr; type* lhst = lhs->Type;
type* rhst = rhs->e_tptr; type* rhst = rhs->Type;
/* Generate type adjustment code if needed */ /* Generate type adjustment code if needed */
ltype = TypeOf (lhst); ltype = TypeOf (lhst);
@ -182,7 +182,7 @@ static unsigned typeadjust (ExprDesc* lhs, ExprDesc* rhs, int NoPush)
flags = g_typeadjust (ltype, rtype); flags = g_typeadjust (ltype, rtype);
/* Set the type of the result */ /* Set the type of the result */
lhs->e_tptr = promoteint (lhst, rhst); lhs->Type = promoteint (lhst, rhst);
/* Return the code generator flags */ /* Return the code generator flags */
return flags; return flags;
@ -201,13 +201,13 @@ unsigned assignadjust (type* lhst, ExprDesc* rhs)
/* Get the type of the right hand side. Treat function types as /* Get the type of the right hand side. Treat function types as
* pointer-to-function * pointer-to-function
*/ */
type* rhst = rhs->e_tptr; type* rhst = rhs->Type;
if (IsTypeFunc (rhst)) { if (IsTypeFunc (rhst)) {
rhst = PointerTo (rhst); rhst = PointerTo (rhst);
} }
/* After calling this function, rhs will have the type of the lhs */ /* After calling this function, rhs will have the type of the lhs */
rhs->e_tptr = lhst; rhs->Type = lhst;
/* First, do some type checking */ /* First, do some type checking */
if (IsTypeVoid (lhst) || IsTypeVoid (rhst)) { if (IsTypeVoid (lhst) || IsTypeVoid (rhst)) {
@ -289,7 +289,7 @@ void DefineData (ExprDesc* lval)
case E_TCONST: case E_TCONST:
/* Number */ /* Number */
g_defdata (TypeOf (lval->e_tptr) | CF_CONST, lval->e_const, 0); g_defdata (TypeOf (lval->Type) | CF_CONST, lval->e_const, 0);
break; break;
case E_TREGISTER: case E_TREGISTER:
@ -330,7 +330,7 @@ static void lconst (unsigned flags, ExprDesc* lval)
case E_TCONST: case E_TCONST:
/* Number constant */ /* Number constant */
g_getimmed (flags | TypeOf (lval->e_tptr) | CF_CONST, lval->e_const, 0); g_getimmed (flags | TypeOf (lval->Type) | CF_CONST, lval->e_const, 0);
break; break;
case E_TREGISTER: case E_TREGISTER:
@ -471,7 +471,7 @@ void exprhs (unsigned flags, int k, ExprDesc *lval)
f = lval->e_flags; f = lval->e_flags;
if (k) { if (k) {
/* Dereferenced lvalue */ /* Dereferenced lvalue */
flags |= TypeOf (lval->e_tptr); flags |= TypeOf (lval->Type);
if (lval->e_test & E_FORCETEST) { if (lval->e_test & E_FORCETEST) {
flags |= CF_TEST; flags |= CF_TEST;
lval->e_test &= ~E_FORCETEST; lval->e_test &= ~E_FORCETEST;
@ -493,7 +493,7 @@ void exprhs (unsigned flags, int k, ExprDesc *lval)
} }
} else if (f == E_MEOFFS) { } else if (f == E_MEOFFS) {
/* reference not storable */ /* reference not storable */
flags |= TypeOf (lval->e_tptr); flags |= TypeOf (lval->Type);
g_inc (flags | CF_CONST, lval->e_const); g_inc (flags | CF_CONST, lval->e_const);
} else if ((f & E_MEXPR) == 0) { } else if ((f & E_MEXPR) == 0) {
/* Constant of some sort, load it into the primary */ /* Constant of some sort, load it into the primary */
@ -501,7 +501,7 @@ void exprhs (unsigned flags, int k, ExprDesc *lval)
} }
if (lval->e_test & E_FORCETEST) { /* we testing this value? */ if (lval->e_test & E_FORCETEST) { /* we testing this value? */
/* debug... */ /* debug... */
flags |= TypeOf (lval->e_tptr); flags |= TypeOf (lval->Type);
g_test (flags); /* yes, force a test */ g_test (flags); /* yes, force a test */
lval->e_test &= ~E_FORCETEST; lval->e_test &= ~E_FORCETEST;
} }
@ -625,7 +625,7 @@ static unsigned FunctionParamList (FuncDesc* Func)
} }
/* Use the type of the argument for the push */ /* Use the type of the argument for the push */
Flags |= TypeOf (lval.e_tptr); Flags |= TypeOf (lval.Type);
/* If this is a fastcall function, don't push the last argument */ /* If this is a fastcall function, don't push the last argument */
if (ParamCount == Func->ParamCount && (Func->Flags & FD_FASTCALL) != 0) { if (ParamCount == Func->ParamCount && (Func->Flags & FD_FASTCALL) != 0) {
@ -690,7 +690,7 @@ static void CallFunction (ExprDesc* lval)
/* Get a pointer to the function descriptor from the type string */ /* Get a pointer to the function descriptor from the type string */
Func = GetFuncDesc (lval->e_tptr); Func = GetFuncDesc (lval->Type);
/* Initialize vars to keep gcc silent */ /* Initialize vars to keep gcc silent */
Mark = 0; Mark = 0;
@ -723,9 +723,9 @@ static void CallFunction (ExprDesc* lval)
/* We had no parameters - remove save code */ /* We had no parameters - remove save code */
RemoveCode (Mark); RemoveCode (Mark);
} }
g_callind (TypeOf (lval->e_tptr), ParamSize); g_callind (TypeOf (lval->Type), ParamSize);
} else { } else {
g_call (TypeOf (lval->e_tptr), (const char*) lval->e_name, ParamSize); g_call (TypeOf (lval->Type), (const char*) lval->e_name, ParamSize);
} }
} }
@ -795,7 +795,7 @@ static int primary (ExprDesc* lval)
/* Character and integer constants. */ /* Character and integer constants. */
if (CurTok.Tok == TOK_ICONST || CurTok.Tok == TOK_CCONST) { if (CurTok.Tok == TOK_ICONST || CurTok.Tok == TOK_CCONST) {
lval->e_flags = E_MCONST | E_TCONST; lval->e_flags = E_MCONST | E_TCONST;
lval->e_tptr = CurTok.Type; lval->Type = CurTok.Type;
lval->e_const = CurTok.IVal; lval->e_const = CurTok.IVal;
NextToken (); NextToken ();
return 0; return 0;
@ -819,7 +819,7 @@ static int primary (ExprDesc* lval)
/* Illegal expression in PP mode */ /* Illegal expression in PP mode */
Error ("Preprocessor expression expected"); Error ("Preprocessor expression expected");
lval->e_flags = E_MCONST; lval->e_flags = E_MCONST;
lval->e_tptr = type_int; lval->Type = type_int;
return 0; return 0;
} }
@ -839,7 +839,7 @@ static int primary (ExprDesc* lval)
NextToken (); NextToken ();
/* The expression type is the symbol type */ /* The expression type is the symbol type */
lval->e_tptr = Sym->Type; lval->Type = Sym->Type;
/* Check for illegal symbol types */ /* Check for illegal symbol types */
CHECK ((Sym->Flags & SC_LABEL) != SC_LABEL); CHECK ((Sym->Flags & SC_LABEL) != SC_LABEL);
@ -848,7 +848,7 @@ static int primary (ExprDesc* lval)
Error ("Variable identifier expected"); Error ("Variable identifier expected");
/* Assume an int type to make lval valid */ /* Assume an int type to make lval valid */
lval->e_flags = E_MLOCAL | E_TLOFFS; lval->e_flags = E_MLOCAL | E_TLOFFS;
lval->e_tptr = type_int; lval->Type = type_int;
lval->e_const = 0; lval->e_const = 0;
return 0; return 0;
} }
@ -903,7 +903,7 @@ static int primary (ExprDesc* lval)
/* The symbol is referenced now */ /* The symbol is referenced now */
Sym->Flags |= SC_REF; Sym->Flags |= SC_REF;
if (IsTypeFunc (lval->e_tptr) || IsTypeArray (lval->e_tptr)) { if (IsTypeFunc (lval->Type) || IsTypeArray (lval->Type)) {
return 0; return 0;
} }
return 1; return 1;
@ -921,7 +921,7 @@ static int primary (ExprDesc* lval)
*/ */
Warning ("Function call without a prototype"); Warning ("Function call without a prototype");
Sym = AddGlobalSym (Ident, GetImplicitFuncType(), SC_EXTERN | SC_REF | SC_FUNC); Sym = AddGlobalSym (Ident, GetImplicitFuncType(), SC_EXTERN | SC_REF | SC_FUNC);
lval->e_tptr = Sym->Type; lval->Type = Sym->Type;
lval->e_flags = E_MGLOBAL | E_MCONST | E_TGLAB; lval->e_flags = E_MGLOBAL | E_MCONST | E_TGLAB;
lval->e_name = (unsigned long) Sym->Name; lval->e_name = (unsigned long) Sym->Name;
lval->e_const = 0; lval->e_const = 0;
@ -932,7 +932,7 @@ static int primary (ExprDesc* lval)
/* Undeclared Variable */ /* Undeclared Variable */
Sym = AddLocalSym (Ident, type_int, SC_AUTO | SC_REF, 0); Sym = AddLocalSym (Ident, type_int, SC_AUTO | SC_REF, 0);
lval->e_flags = E_MLOCAL | E_TLOFFS; lval->e_flags = E_MLOCAL | E_TLOFFS;
lval->e_tptr = type_int; lval->Type = type_int;
lval->e_const = 0; lval->e_const = 0;
Error ("Undefined symbol: `%s'", Ident); Error ("Undefined symbol: `%s'", Ident);
return 1; return 1;
@ -944,7 +944,7 @@ static int primary (ExprDesc* lval)
if (CurTok.Tok == TOK_SCONST) { if (CurTok.Tok == TOK_SCONST) {
lval->e_flags = E_MCONST | E_TLIT; lval->e_flags = E_MCONST | E_TLIT;
lval->e_const = CurTok.IVal; lval->e_const = CurTok.IVal;
lval->e_tptr = GetCharArrayType (strlen (GetLiteral (CurTok.IVal))); lval->Type = GetCharArrayType (strlen (GetLiteral (CurTok.IVal)));
NextToken (); NextToken ();
return 0; return 0;
} }
@ -952,7 +952,7 @@ static int primary (ExprDesc* lval)
/* ASM statement? */ /* ASM statement? */
if (CurTok.Tok == TOK_ASM) { if (CurTok.Tok == TOK_ASM) {
doasm (); doasm ();
lval->e_tptr = type_void; lval->Type = type_void;
lval->e_flags = E_MEXPR; lval->e_flags = E_MEXPR;
lval->e_const = 0; lval->e_const = 0;
return 0; return 0;
@ -960,7 +960,7 @@ static int primary (ExprDesc* lval)
/* __AX__ and __EAX__ pseudo values? */ /* __AX__ and __EAX__ pseudo values? */
if (CurTok.Tok == TOK_AX || CurTok.Tok == TOK_EAX) { if (CurTok.Tok == TOK_AX || CurTok.Tok == TOK_EAX) {
lval->e_tptr = (CurTok.Tok == TOK_AX)? type_uint : type_ulong; lval->Type = (CurTok.Tok == TOK_AX)? type_uint : type_ulong;
lval->e_flags = E_MREG; lval->e_flags = E_MREG;
lval->e_test &= ~E_CC; lval->e_test &= ~E_CC;
lval->e_const = 0; lval->e_const = 0;
@ -971,7 +971,7 @@ static int primary (ExprDesc* lval)
/* Illegal primary. */ /* Illegal primary. */
Error ("Expression expected"); Error ("Expression expected");
lval->e_flags = E_MCONST; lval->e_flags = E_MCONST;
lval->e_tptr = type_int; lval->Type = type_int;
return 0; return 0;
} }
@ -996,7 +996,7 @@ static int arrayref (int k, ExprDesc* lval)
NextToken (); NextToken ();
/* Get the type of left side */ /* Get the type of left side */
tptr1 = lval->e_tptr; tptr1 = lval->Type;
/* We can apply a special treatment for arrays that have a const base /* We can apply a special treatment for arrays that have a const base
* address. This is true for most arrays and will produce a lot better * address. This is true for most arrays and will produce a lot better
@ -1063,19 +1063,19 @@ static int arrayref (int k, ExprDesc* lval)
} }
/* Result is of element type */ /* Result is of element type */
lval->e_tptr = Indirect (tptr1); lval->Type = Indirect (tptr1);
/* Done */ /* Done */
goto end_array; goto end_array;
} else if (IsClassPtr (tptr2 = lval2.e_tptr)) { } else if (IsClassPtr (tptr2 = lval2.Type)) {
/* Subscript is pointer, get element type */ /* Subscript is pointer, get element type */
lval2.e_tptr = Indirect (tptr2); lval2.Type = Indirect (tptr2);
/* Scale the rhs value in the primary register */ /* Scale the rhs value in the primary register */
g_scale (TypeOf (tptr1), SizeOf (lval2.e_tptr)); g_scale (TypeOf (tptr1), SizeOf (lval2.Type));
/* */ /* */
lval->e_tptr = lval2.e_tptr; lval->Type = lval2.Type;
} else { } else {
Error ("Cannot subscript"); Error ("Cannot subscript");
} }
@ -1092,22 +1092,22 @@ static int arrayref (int k, ExprDesc* lval)
Mark2 = GetCodePos (); Mark2 = GetCodePos ();
exprhs (CF_NONE, l, &lval2); exprhs (CF_NONE, l, &lval2);
tptr2 = lval2.e_tptr; tptr2 = lval2.Type;
if (IsClassPtr (tptr1)) { if (IsClassPtr (tptr1)) {
/* Get the element type */ /* Get the element type */
lval->e_tptr = Indirect (tptr1); lval->Type = Indirect (tptr1);
/* Indexing is based on int's, so we will just use the integer /* Indexing is based on int's, so we will just use the integer
* portion of the index (which is in (e)ax, so there's no further * portion of the index (which is in (e)ax, so there's no further
* action required). * action required).
*/ */
g_scale (CF_INT, SizeOf (lval->e_tptr)); g_scale (CF_INT, SizeOf (lval->Type));
} else if (IsClassPtr (tptr2)) { } else if (IsClassPtr (tptr2)) {
/* Get the element type */ /* Get the element type */
lval2.e_tptr = Indirect (tptr2); lval2.Type = Indirect (tptr2);
/* Get the int value on top. If we go here, we're sure, /* Get the int value on top. If we go here, we're sure,
* both values are 16 bit (the first one was truncated * both values are 16 bit (the first one was truncated
@ -1124,8 +1124,8 @@ static int arrayref (int k, ExprDesc* lval)
} }
/* Scale it */ /* Scale it */
g_scale (TypeOf (tptr1), SizeOf (lval2.e_tptr)); g_scale (TypeOf (tptr1), SizeOf (lval2.Type));
lval->e_tptr = lval2.e_tptr; lval->Type = lval2.Type;
} else { } else {
Error ("Cannot subscript"); Error ("Cannot subscript");
} }
@ -1153,22 +1153,22 @@ static int arrayref (int k, ExprDesc* lval)
(rflags & E_MGLOBAL) != 0 || /* Static array, or ... */ (rflags & E_MGLOBAL) != 0 || /* Static array, or ... */
rflags == E_MLOCAL; /* Local array */ rflags == E_MLOCAL; /* Local array */
if (ConstSubAddr && SizeOf (lval->e_tptr) == 1) { if (ConstSubAddr && SizeOf (lval->Type) == 1) {
type* SavedType; type* SavedType;
/* Reverse the order of evaluation */ /* Reverse the order of evaluation */
unsigned flags = (SizeOf (lval2.e_tptr) == 1)? CF_CHAR : CF_INT; unsigned flags = (SizeOf (lval2.Type) == 1)? CF_CHAR : CF_INT;
RemoveCode (Mark2); RemoveCode (Mark2);
/* Get a pointer to the array into the primary. We have changed /* Get a pointer to the array into the primary. We have changed
* e_tptr above but we need the original type to load the * Type above but we need the original type to load the
* address, so restore it temporarily. * address, so restore it temporarily.
*/ */
SavedType = lval->e_tptr; SavedType = lval->Type;
lval->e_tptr = tptr1; lval->Type = tptr1;
exprhs (CF_NONE, k, lval); exprhs (CF_NONE, k, lval);
lval->e_tptr = SavedType; lval->Type = SavedType;
/* Add the variable */ /* Add the variable */
if (rflags == E_MLOCAL) { if (rflags == E_MLOCAL) {
@ -1204,7 +1204,7 @@ static int arrayref (int k, ExprDesc* lval)
lval->e_flags = E_MEXPR; lval->e_flags = E_MEXPR;
end_array: end_array:
ConsumeRBrack (); ConsumeRBrack ();
return !IsTypeArray (lval->e_tptr); return !IsTypeArray (lval->Type);
} }
@ -1221,17 +1221,17 @@ static int structref (int k, ExprDesc* lval)
NextToken (); NextToken ();
if (CurTok.Tok != TOK_IDENT) { if (CurTok.Tok != TOK_IDENT) {
Error ("Identifier expected"); Error ("Identifier expected");
lval->e_tptr = type_int; lval->Type = type_int;
return 0; return 0;
} }
/* Get the symbol table entry and check for a struct field */ /* Get the symbol table entry and check for a struct field */
strcpy (Ident, CurTok.Ident); strcpy (Ident, CurTok.Ident);
NextToken (); NextToken ();
Field = FindStructField (lval->e_tptr, Ident); Field = FindStructField (lval->Type, Ident);
if (Field == 0) { if (Field == 0) {
Error ("Struct/union has no field named `%s'", Ident); Error ("Struct/union has no field named `%s'", Ident);
lval->e_tptr = type_int; lval->Type = type_int;
return 0; return 0;
} }
@ -1249,7 +1249,7 @@ static int structref (int k, ExprDesc* lval)
lval->e_const = Field->V.Offs; lval->e_const = Field->V.Offs;
lval->e_flags = E_MEOFFS; lval->e_flags = E_MEOFFS;
} }
lval->e_tptr = Field->Type; lval->Type = Field->Type;
return !IsTypeArray (Field->Type); return !IsTypeArray (Field->Type);
} }
@ -1279,17 +1279,17 @@ static int hie11 (ExprDesc *lval)
/* Function call. Skip the opening parenthesis */ /* Function call. Skip the opening parenthesis */
NextToken (); NextToken ();
tptr = lval->e_tptr; tptr = lval->Type;
if (IsTypeFunc (tptr) || IsTypeFuncPtr (tptr)) { if (IsTypeFunc (tptr) || IsTypeFuncPtr (tptr)) {
if (IsTypeFuncPtr (tptr)) { if (IsTypeFuncPtr (tptr)) {
/* Pointer to function. Handle transparently */ /* Pointer to function. Handle transparently */
exprhs (CF_NONE, k, lval); /* Function pointer to A/X */ exprhs (CF_NONE, k, lval); /* Function pointer to A/X */
++lval->e_tptr; /* Skip T_PTR */ ++lval->Type; /* Skip T_PTR */
lval->e_flags |= E_MEXPR; lval->e_flags |= E_MEXPR;
} }
CallFunction (lval); CallFunction (lval);
lval->e_flags = E_MEXPR; lval->e_flags = E_MEXPR;
lval->e_tptr += DECODE_SIZE + 1; /* Set to result */ lval->Type += DECODE_SIZE + 1; /* Set to result */
} else { } else {
Error ("Illegal function call"); Error ("Illegal function call");
} }
@ -1297,14 +1297,14 @@ static int hie11 (ExprDesc *lval)
} else if (CurTok.Tok == TOK_DOT) { } else if (CurTok.Tok == TOK_DOT) {
if (!IsClassStruct (lval->e_tptr)) { if (!IsClassStruct (lval->Type)) {
Error ("Struct expected"); Error ("Struct expected");
} }
k = structref (0, lval); k = structref (0, lval);
} else if (CurTok.Tok == TOK_PTR_REF) { } else if (CurTok.Tok == TOK_PTR_REF) {
tptr = lval->e_tptr; tptr = lval->Type;
if (tptr[0] != T_PTR || (tptr[1] & T_STRUCT) == 0) { if (tptr[0] != T_PTR || (tptr[1] & T_STRUCT) == 0) {
Error ("Struct pointer expected"); Error ("Struct pointer expected");
} }
@ -1325,7 +1325,7 @@ static void store (ExprDesc* lval)
unsigned flags; unsigned flags;
f = lval->e_flags; f = lval->e_flags;
flags = TypeOf (lval->e_tptr); flags = TypeOf (lval->Type);
if (f & E_MGLOBAL) { if (f & E_MGLOBAL) {
flags |= GlobalModeFlags (f); flags |= GlobalModeFlags (f);
if (lval->e_test) { if (lval->e_test) {
@ -1369,10 +1369,10 @@ static void pre_incdec (ExprDesc* lval, void (*inc) (unsigned, unsigned long))
} }
/* Get the data type */ /* Get the data type */
flags = TypeOf (lval->e_tptr) | CF_FORCECHAR | CF_CONST; flags = TypeOf (lval->Type) | CF_FORCECHAR | CF_CONST;
/* Get the increment value in bytes */ /* Get the increment value in bytes */
val = (lval->e_tptr [0] == T_PTR)? PSizeOf (lval->e_tptr) : 1; val = (lval->Type [0] == T_PTR)? PSizeOf (lval->Type) : 1;
/* We're currently only able to handle some adressing modes */ /* We're currently only able to handle some adressing modes */
if ((lval->e_flags & E_MGLOBAL) == 0 && /* Global address? */ if ((lval->e_flags & E_MGLOBAL) == 0 && /* Global address? */
@ -1449,7 +1449,7 @@ static void post_incdec (ExprDesc *lval, int k, void (*inc) (unsigned, unsigned
} }
/* Get the data type */ /* Get the data type */
flags = TypeOf (lval->e_tptr); flags = TypeOf (lval->Type);
/* Push the address if needed */ /* Push the address if needed */
PushAddr (lval); PushAddr (lval);
@ -1459,8 +1459,8 @@ static void post_incdec (ExprDesc *lval, int k, void (*inc) (unsigned, unsigned
g_save (flags | CF_FORCECHAR); g_save (flags | CF_FORCECHAR);
/* If we have a pointer expression, increment by the size of the type */ /* If we have a pointer expression, increment by the size of the type */
if (lval->e_tptr[0] == T_PTR) { if (lval->Type[0] == T_PTR) {
inc (flags | CF_CONST | CF_FORCECHAR, SizeOf (lval->e_tptr + 1)); inc (flags | CF_CONST | CF_FORCECHAR, SizeOf (lval->Type + 1));
} else { } else {
inc (flags | CF_CONST | CF_FORCECHAR, 1); inc (flags | CF_CONST | CF_FORCECHAR, 1);
} }
@ -1496,7 +1496,7 @@ static void unaryop (int tok, ExprDesc* lval)
exprhs (CF_NONE, k, lval); exprhs (CF_NONE, k, lval);
/* Get the type of the expression */ /* Get the type of the expression */
flags = TypeOf (lval->e_tptr); flags = TypeOf (lval->Type);
/* Handle the operation */ /* Handle the operation */
switch (tok) { switch (tok) {
@ -1530,8 +1530,8 @@ static int typecast (ExprDesc* lval)
k = hie10 (lval); k = hie10 (lval);
/* If the expression is a function, treat it as pointer-to-function */ /* If the expression is a function, treat it as pointer-to-function */
if (IsTypeFunc (lval->e_tptr)) { if (IsTypeFunc (lval->Type)) {
lval->e_tptr = PointerTo (lval->e_tptr); lval->Type = PointerTo (lval->Type);
} }
/* Check for a constant on the right side */ /* Check for a constant on the right side */
@ -1545,7 +1545,7 @@ static int typecast (ExprDesc* lval)
if (IsClassInt (Type)) { if (IsClassInt (Type)) {
/* Get the current and new size of the value */ /* Get the current and new size of the value */
unsigned OldSize = SizeOf (lval->e_tptr); unsigned OldSize = SizeOf (lval->Type);
unsigned NewSize = SizeOf (Type); unsigned NewSize = SizeOf (Type);
unsigned OldBits = OldSize * 8; unsigned OldBits = OldSize * 8;
unsigned NewBits = NewSize * 8; unsigned NewBits = NewSize * 8;
@ -1564,7 +1564,7 @@ static int typecast (ExprDesc* lval)
} else if (NewSize > OldSize) { } else if (NewSize > OldSize) {
/* Sign extend the value if needed */ /* Sign extend the value if needed */
if (!IsSignUnsigned (Type) && !IsSignUnsigned (lval->e_tptr)) { if (!IsSignUnsigned (Type) && !IsSignUnsigned (lval->Type)) {
if (lval->e_const & (0x01UL << (OldBits-1))) { if (lval->e_const & (0x01UL << (OldBits-1))) {
lval->e_const |= ((~0L) << OldBits); lval->e_const |= ((~0L) << OldBits);
} }
@ -1581,13 +1581,13 @@ static int typecast (ExprDesc* lval)
* we have to load the value into the primary and generate code to * we have to load the value into the primary and generate code to
* cast the value in the primary register. * cast the value in the primary register.
*/ */
if (SizeOf (Type) != SizeOf (lval->e_tptr)) { if (SizeOf (Type) != SizeOf (lval->Type)) {
/* Load the value into the primary */ /* Load the value into the primary */
exprhs (CF_NONE, k, lval); exprhs (CF_NONE, k, lval);
/* Mark the lhs as const to avoid a manipulation of TOS */ /* Mark the lhs as const to avoid a manipulation of TOS */
g_typecast (TypeOf (Type) | CF_CONST, TypeOf (lval->e_tptr)); g_typecast (TypeOf (Type) | CF_CONST, TypeOf (lval->Type));
/* Value is now in primary */ /* Value is now in primary */
lval->e_flags = E_MEXPR; lval->e_flags = E_MEXPR;
@ -1597,7 +1597,7 @@ static int typecast (ExprDesc* lval)
} }
/* In any case, use the new type */ /* In any case, use the new type */
lval->e_tptr = TypeDup (Type); lval->Type = TypeDup (Type);
/* Done */ /* Done */
return k; return k;
@ -1633,7 +1633,7 @@ static int hie10 (ExprDesc* lval)
/* Constant expression */ /* Constant expression */
lval->e_const = !lval->e_const; lval->e_const = !lval->e_const;
} else { } else {
g_bneg (TypeOf (lval->e_tptr)); g_bneg (TypeOf (lval->Type));
lval->e_test |= E_CC; /* bneg will set cc */ lval->e_test |= E_CC; /* bneg will set cc */
lval->e_flags = E_MEXPR; /* say it's an expr */ lval->e_flags = E_MEXPR; /* say it's an expr */
} }
@ -1646,9 +1646,9 @@ static int hie10 (ExprDesc* lval)
lval->e_flags = E_MEXPR; lval->e_flags = E_MEXPR;
lval->e_const = 0; /* Offset is zero now */ lval->e_const = 0; /* Offset is zero now */
} }
t = lval->e_tptr; t = lval->Type;
if (IsClassPtr (t)) { if (IsClassPtr (t)) {
lval->e_tptr = Indirect (t); lval->Type = Indirect (t);
} else { } else {
Error ("Illegal indirection"); Error ("Illegal indirection");
} }
@ -1660,16 +1660,16 @@ static int hie10 (ExprDesc* lval)
/* The & operator may be applied to any lvalue, and it may be /* The & operator may be applied to any lvalue, and it may be
* applied to functions, even if they're no lvalues. * applied to functions, even if they're no lvalues.
*/ */
if (k == 0 && !IsTypeFunc (lval->e_tptr)) { if (k == 0 && !IsTypeFunc (lval->Type)) {
/* Allow the & operator with an array */ /* Allow the & operator with an array */
if (!IsTypeArray (lval->e_tptr)) { if (!IsTypeArray (lval->Type)) {
Error ("Illegal address"); Error ("Illegal address");
} }
} else { } else {
t = TypeAlloc (TypeLen (lval->e_tptr) + 2); t = TypeAlloc (TypeLen (lval->Type) + 2);
t [0] = T_PTR; t [0] = T_PTR;
TypeCpy (t + 1, lval->e_tptr); TypeCpy (t + 1, lval->Type);
lval->e_tptr = t; lval->Type = t;
} }
return 0; return 0;
@ -1684,12 +1684,12 @@ static int hie10 (ExprDesc* lval)
/* Remember the output queue pointer */ /* Remember the output queue pointer */
CodeMark Mark = GetCodePos (); CodeMark Mark = GetCodePos ();
hie10 (lval); hie10 (lval);
lval->e_const = SizeOf (lval->e_tptr); lval->e_const = SizeOf (lval->Type);
/* Remove any generated code */ /* Remove any generated code */
RemoveCode (Mark); RemoveCode (Mark);
} }
lval->e_flags = E_MCONST | E_TCONST; lval->e_flags = E_MCONST | E_TCONST;
lval->e_tptr = type_uint; lval->Type = type_uint;
lval->e_test &= ~E_CC; lval->e_test &= ~E_CC;
return 0; return 0;
@ -1742,7 +1742,7 @@ static int hie_internal (GenDesc** ops, /* List of generators */
*UsedGen = 1; *UsedGen = 1;
/* All operators that call this function expect an int on the lhs */ /* All operators that call this function expect an int on the lhs */
if (!IsClassInt (lval->e_tptr)) { if (!IsClassInt (lval->Type)) {
Error ("Integer expression expected"); Error ("Integer expression expected");
} }
@ -1752,7 +1752,7 @@ static int hie_internal (GenDesc** ops, /* List of generators */
/* Get the lhs on stack */ /* Get the lhs on stack */
Mark1 = GetCodePos (); Mark1 = GetCodePos ();
ltype = TypeOf (lval->e_tptr); ltype = TypeOf (lval->Type);
if (k == 0 && lval->e_flags == E_MCONST) { if (k == 0 && lval->e_flags == E_MCONST) {
/* Constant value */ /* Constant value */
Mark2 = GetCodePos (); Mark2 = GetCodePos ();
@ -1768,7 +1768,7 @@ static int hie_internal (GenDesc** ops, /* List of generators */
rconst = (evalexpr (CF_NONE, hienext, &lval2) == 0); rconst = (evalexpr (CF_NONE, hienext, &lval2) == 0);
/* Check the type of the rhs */ /* Check the type of the rhs */
if (!IsClassInt (lval2.e_tptr)) { if (!IsClassInt (lval2.Type)) {
Error ("Integer expression expected"); Error ("Integer expression expected");
} }
@ -1783,7 +1783,7 @@ static int hie_internal (GenDesc** ops, /* List of generators */
lval->e_const = kcalc (tok, lval->e_const, lval2.e_const); lval->e_const = kcalc (tok, lval->e_const, lval2.e_const);
/* Get the type of the result */ /* Get the type of the result */
lval->e_tptr = promoteint (lval->e_tptr, lval2.e_tptr); lval->Type = promoteint (lval->Type, lval2.Type);
} else { } else {
@ -1791,7 +1791,7 @@ static int hie_internal (GenDesc** ops, /* List of generators */
* expects the lhs in the primary, remove the push of the primary * expects the lhs in the primary, remove the push of the primary
* now. * now.
*/ */
unsigned rtype = TypeOf (lval2.e_tptr); unsigned rtype = TypeOf (lval2.Type);
type = 0; type = 0;
if (rconst) { if (rconst) {
/* Second value is constant - check for div */ /* Second value is constant - check for div */
@ -1811,7 +1811,7 @@ static int hie_internal (GenDesc** ops, /* List of generators */
/* Determine the type of the operation result. */ /* Determine the type of the operation result. */
type |= g_typeadjust (ltype, rtype); type |= g_typeadjust (ltype, rtype);
lval->e_tptr = promoteint (lval->e_tptr, lval2.e_tptr); lval->Type = promoteint (lval->Type, lval2.Type);
/* Generate code */ /* Generate code */
Gen->Func (type, lval2.e_const); Gen->Func (type, lval2.e_const);
@ -1852,7 +1852,7 @@ static int hie_compare (GenDesc** ops, /* List of generators */
/* Get the lhs on stack */ /* Get the lhs on stack */
Mark1 = GetCodePos (); Mark1 = GetCodePos ();
ltype = TypeOf (lval->e_tptr); ltype = TypeOf (lval->Type);
if (k == 0 && lval->e_flags == E_MCONST) { if (k == 0 && lval->e_flags == E_MCONST) {
/* Constant value */ /* Constant value */
Mark2 = GetCodePos (); Mark2 = GetCodePos ();
@ -1868,17 +1868,17 @@ static int hie_compare (GenDesc** ops, /* List of generators */
rconst = (evalexpr (CF_NONE, hienext, &lval2) == 0); rconst = (evalexpr (CF_NONE, hienext, &lval2) == 0);
/* Make sure, the types are compatible */ /* Make sure, the types are compatible */
if (IsClassInt (lval->e_tptr)) { if (IsClassInt (lval->Type)) {
if (!IsClassInt (lval2.e_tptr) && !(IsClassPtr(lval2.e_tptr) && IsNullPtr(lval))) { if (!IsClassInt (lval2.Type) && !(IsClassPtr(lval2.Type) && IsNullPtr(lval))) {
Error ("Incompatible types"); Error ("Incompatible types");
} }
} else if (IsClassPtr (lval->e_tptr)) { } else if (IsClassPtr (lval->Type)) {
if (IsClassPtr (lval2.e_tptr)) { if (IsClassPtr (lval2.Type)) {
/* Both pointers are allowed in comparison if they point to /* Both pointers are allowed in comparison if they point to
* the same type, or if one of them is a void pointer. * the same type, or if one of them is a void pointer.
*/ */
type* left = Indirect (lval->e_tptr); type* left = Indirect (lval->Type);
type* right = Indirect (lval2.e_tptr); type* right = Indirect (lval2.Type);
if (TypeCmp (left, right) < TC_EQUAL && *left != T_VOID && *right != T_VOID) { if (TypeCmp (left, right) < TC_EQUAL && *left != T_VOID && *right != T_VOID) {
/* Incomatible pointers */ /* Incomatible pointers */
Error ("Incompatible types"); Error ("Incompatible types");
@ -1920,16 +1920,16 @@ static int hie_compare (GenDesc** ops, /* List of generators */
* operation as char operation. Otherwise the default * operation as char operation. Otherwise the default
* promotions are used. * promotions are used.
*/ */
if (IsTypeChar (lval->e_tptr) && (IsTypeChar (lval2.e_tptr) || rconst)) { if (IsTypeChar (lval->Type) && (IsTypeChar (lval2.Type) || rconst)) {
flags |= CF_CHAR; flags |= CF_CHAR;
if (IsSignUnsigned (lval->e_tptr) || IsSignUnsigned (lval2.e_tptr)) { if (IsSignUnsigned (lval->Type) || IsSignUnsigned (lval2.Type)) {
flags |= CF_UNSIGNED; flags |= CF_UNSIGNED;
} }
if (rconst) { if (rconst) {
flags |= CF_FORCECHAR; flags |= CF_FORCECHAR;
} }
} else { } else {
unsigned rtype = TypeOf (lval2.e_tptr) | (flags & CF_CONST); unsigned rtype = TypeOf (lval2.Type) | (flags & CF_CONST);
flags |= g_typeadjust (ltype, rtype); flags |= g_typeadjust (ltype, rtype);
} }
@ -1939,7 +1939,7 @@ static int hie_compare (GenDesc** ops, /* List of generators */
} }
/* Result type is always int */ /* Result type is always int */
lval->e_tptr = type_int; lval->Type = type_int;
/* We have a rvalue now, condition codes are set */ /* We have a rvalue now, condition codes are set */
k = 0; k = 0;
@ -1981,7 +1981,7 @@ static void parseadd (int k, ExprDesc* lval)
NextToken (); NextToken ();
/* Get the left hand side type, initialize operation flags */ /* Get the left hand side type, initialize operation flags */
lhst = lval->e_tptr; lhst = lval->Type;
flags = 0; flags = 0;
/* Check for constness on both sides */ /* Check for constness on both sides */
@ -1991,7 +1991,7 @@ static void parseadd (int k, ExprDesc* lval)
if (evalexpr (CF_NONE, hie9, &lval2) == 0) { if (evalexpr (CF_NONE, hie9, &lval2) == 0) {
/* Right hand side is also constant. Get the rhs type */ /* Right hand side is also constant. Get the rhs type */
rhst = lval2.e_tptr; rhst = lval2.Type;
/* Both expressions are constants. Check for pointer arithmetic */ /* Both expressions are constants. Check for pointer arithmetic */
if (IsClassPtr (lhst) && IsClassInt (rhst)) { if (IsClassPtr (lhst) && IsClassInt (rhst)) {
@ -2002,7 +2002,7 @@ static void parseadd (int k, ExprDesc* lval)
/* Left is int, right is pointer, must scale lhs */ /* Left is int, right is pointer, must scale lhs */
lval->e_const = lval->e_const * PSizeOf (rhst) + lval2.e_const; lval->e_const = lval->e_const * PSizeOf (rhst) + lval2.e_const;
/* Result type is a pointer */ /* Result type is a pointer */
lval->e_tptr = lval2.e_tptr; lval->Type = lval2.Type;
} else if (IsClassInt (lhst) && IsClassInt (rhst)) { } else if (IsClassInt (lhst) && IsClassInt (rhst)) {
/* Integer addition */ /* Integer addition */
lval->e_const += lval2.e_const; lval->e_const += lval2.e_const;
@ -2018,7 +2018,7 @@ static void parseadd (int k, ExprDesc* lval)
} else { } else {
/* lhs is constant, rhs is not. Get the rhs type. */ /* lhs is constant, rhs is not. Get the rhs type. */
rhst = lval2.e_tptr; rhst = lval2.Type;
/* Check for pointer arithmetic */ /* Check for pointer arithmetic */
if (IsClassPtr (lhst) && IsClassInt (rhst)) { if (IsClassPtr (lhst) && IsClassInt (rhst)) {
@ -2031,7 +2031,7 @@ static void parseadd (int k, ExprDesc* lval)
lval->e_const *= PSizeOf (rhst); lval->e_const *= PSizeOf (rhst);
/* Operate on pointers, result type is a pointer */ /* Operate on pointers, result type is a pointer */
flags = CF_PTR; flags = CF_PTR;
lval->e_tptr = lval2.e_tptr; lval->Type = lval2.Type;
} else if (IsClassInt (lhst) && IsClassInt (rhst)) { } else if (IsClassInt (lhst) && IsClassInt (rhst)) {
/* Integer addition */ /* Integer addition */
flags = typeadjust (lval, &lval2, 1); flags = typeadjust (lval, &lval2, 1);
@ -2054,17 +2054,17 @@ static void parseadd (int k, ExprDesc* lval)
/* Left hand side is not constant. Get the value onto the stack. */ /* Left hand side is not constant. Get the value onto the stack. */
exprhs (CF_NONE, k, lval); /* --> primary register */ exprhs (CF_NONE, k, lval); /* --> primary register */
Mark = GetCodePos (); Mark = GetCodePos ();
g_push (TypeOf (lval->e_tptr), 0); /* --> stack */ g_push (TypeOf (lval->Type), 0); /* --> stack */
/* Evaluate the rhs */ /* Evaluate the rhs */
if (evalexpr (CF_NONE, hie9, &lval2) == 0) { if (evalexpr (CF_NONE, hie9, &lval2) == 0) {
/* Right hand side is a constant. Get the rhs type */ /* Right hand side is a constant. Get the rhs type */
rhst = lval2.e_tptr; rhst = lval2.Type;
/* Remove pushed value from stack */ /* Remove pushed value from stack */
RemoveCode (Mark); RemoveCode (Mark);
pop (TypeOf (lval->e_tptr)); pop (TypeOf (lval->Type));
/* Check for pointer arithmetic */ /* Check for pointer arithmetic */
if (IsClassPtr (lhst) && IsClassInt (rhst)) { if (IsClassPtr (lhst) && IsClassInt (rhst)) {
@ -2077,7 +2077,7 @@ static void parseadd (int k, ExprDesc* lval)
g_scale (CF_INT | CF_CONST, PSizeOf (rhst)); g_scale (CF_INT | CF_CONST, PSizeOf (rhst));
/* Operate on pointers, result type is a pointer */ /* Operate on pointers, result type is a pointer */
flags = CF_PTR; flags = CF_PTR;
lval->e_tptr = lval2.e_tptr; lval->Type = lval2.Type;
} else if (IsClassInt (lhst) && IsClassInt (rhst)) { } else if (IsClassInt (lhst) && IsClassInt (rhst)) {
/* Integer addition */ /* Integer addition */
flags = typeadjust (lval, &lval2, 1); flags = typeadjust (lval, &lval2, 1);
@ -2096,7 +2096,7 @@ static void parseadd (int k, ExprDesc* lval)
} else { } else {
/* lhs and rhs are not constant. Get the rhs type. */ /* lhs and rhs are not constant. Get the rhs type. */
rhst = lval2.e_tptr; rhst = lval2.Type;
/* Check for pointer arithmetic */ /* Check for pointer arithmetic */
if (IsClassPtr (lhst) && IsClassInt (rhst)) { if (IsClassPtr (lhst) && IsClassInt (rhst)) {
@ -2111,7 +2111,7 @@ static void parseadd (int k, ExprDesc* lval)
g_scale (CF_INT, PSizeOf (rhst)); g_scale (CF_INT, PSizeOf (rhst));
/* Operate on pointers, result type is a pointer */ /* Operate on pointers, result type is a pointer */
flags = CF_PTR; flags = CF_PTR;
lval->e_tptr = lval2.e_tptr; lval->Type = lval2.Type;
} else if (IsClassInt (lhst) && IsClassInt (rhst)) { } else if (IsClassInt (lhst) && IsClassInt (rhst)) {
/* Integer addition */ /* Integer addition */
flags = typeadjust (lval, &lval2, 0); flags = typeadjust (lval, &lval2, 0);
@ -2153,7 +2153,7 @@ static void parsesub (int k, ExprDesc* lval)
NextToken (); NextToken ();
/* Get the left hand side type, initialize operation flags */ /* Get the left hand side type, initialize operation flags */
lhst = lval->e_tptr; lhst = lval->Type;
flags = 0; flags = 0;
rscale = 1; /* Scale by 1, that is, don't scale */ rscale = 1; /* Scale by 1, that is, don't scale */
@ -2167,7 +2167,7 @@ static void parsesub (int k, ExprDesc* lval)
if (evalexpr (CF_NONE, hie9, &lval2) == 0) { if (evalexpr (CF_NONE, hie9, &lval2) == 0) {
/* The right hand side is constant. Get the rhs type. */ /* The right hand side is constant. Get the rhs type. */
rhst = lval2.e_tptr; rhst = lval2.Type;
/* Check left hand side */ /* Check left hand side */
if (k == 0 && (lval->e_flags & E_MCONST) != 0) { if (k == 0 && (lval->e_flags & E_MCONST) != 0) {
@ -2189,7 +2189,7 @@ static void parsesub (int k, ExprDesc* lval)
lval->e_const = (lval->e_const - lval2.e_const) / PSizeOf (lhst); lval->e_const = (lval->e_const - lval2.e_const) / PSizeOf (lhst);
} }
/* Operate on pointers, result type is an integer */ /* Operate on pointers, result type is an integer */
lval->e_tptr = type_int; lval->Type = type_int;
} else if (IsClassInt (lhst) && IsClassInt (rhst)) { } else if (IsClassInt (lhst) && IsClassInt (rhst)) {
/* Integer subtraction */ /* Integer subtraction */
typeadjust (lval, &lval2, 1); typeadjust (lval, &lval2, 1);
@ -2225,7 +2225,7 @@ static void parsesub (int k, ExprDesc* lval)
} }
/* Operate on pointers, result type is an integer */ /* Operate on pointers, result type is an integer */
flags = CF_PTR; flags = CF_PTR;
lval->e_tptr = type_int; lval->Type = type_int;
} else if (IsClassInt (lhst) && IsClassInt (rhst)) { } else if (IsClassInt (lhst) && IsClassInt (rhst)) {
/* Integer subtraction */ /* Integer subtraction */
flags = typeadjust (lval, &lval2, 1); flags = typeadjust (lval, &lval2, 1);
@ -2251,7 +2251,7 @@ static void parsesub (int k, ExprDesc* lval)
} else { } else {
/* Right hand side is not constant. Get the rhs type. */ /* Right hand side is not constant. Get the rhs type. */
rhst = lval2.e_tptr; rhst = lval2.Type;
/* Check for pointer arithmetic */ /* Check for pointer arithmetic */
if (IsClassPtr (lhst) && IsClassInt (rhst)) { if (IsClassPtr (lhst) && IsClassInt (rhst)) {
@ -2268,7 +2268,7 @@ static void parsesub (int k, ExprDesc* lval)
} }
/* Operate on pointers, result type is an integer */ /* Operate on pointers, result type is an integer */
flags = CF_PTR; flags = CF_PTR;
lval->e_tptr = type_int; lval->Type = type_int;
} else if (IsClassInt (lhst) && IsClassInt (rhst)) { } else if (IsClassInt (lhst) && IsClassInt (rhst)) {
/* Integer subtraction. If the left hand side descriptor says that /* Integer subtraction. If the left hand side descriptor says that
* the lhs is const, we have to remove this mark, since this is no * the lhs is const, we have to remove this mark, since this is no
@ -2583,8 +2583,8 @@ static int hieQuest (ExprDesc *lval)
* type. * type.
* - all other cases are flagged by an error. * - all other cases are flagged by an error.
*/ */
type2 = lval2.e_tptr; type2 = lval2.Type;
type3 = lval3.e_tptr; type3 = lval3.Type;
if (IsClassInt (type2) && IsClassInt (type3)) { if (IsClassInt (type2) && IsClassInt (type3)) {
/* Get common type */ /* Get common type */
@ -2617,16 +2617,16 @@ static int hieQuest (ExprDesc *lval)
Error ("Incompatible pointer types"); Error ("Incompatible pointer types");
} }
/* Result has the common type */ /* Result has the common type */
rtype = lval2.e_tptr; rtype = lval2.Type;
} else if (IsClassPtr (type2) && IsNullPtr (&lval3)) { } else if (IsClassPtr (type2) && IsNullPtr (&lval3)) {
/* Result type is pointer, no cast needed */ /* Result type is pointer, no cast needed */
rtype = lval2.e_tptr; rtype = lval2.Type;
} else if (IsNullPtr (&lval2) && IsClassPtr (type3)) { } else if (IsNullPtr (&lval2) && IsClassPtr (type3)) {
/* Result type is pointer, no cast needed */ /* Result type is pointer, no cast needed */
rtype = lval3.e_tptr; rtype = lval3.Type;
} else { } else {
Error ("Incompatible types"); Error ("Incompatible types");
rtype = lval2.e_tptr; /* Doesn't matter here */ rtype = lval2.Type; /* Doesn't matter here */
} }
/* If we don't have the label defined until now, do it */ /* If we don't have the label defined until now, do it */
@ -2636,7 +2636,7 @@ static int hieQuest (ExprDesc *lval)
/* Setup the target expression */ /* Setup the target expression */
lval->e_flags = E_MEXPR; lval->e_flags = E_MEXPR;
lval->e_tptr = rtype; lval->Type = rtype;
k = 0; k = 0;
} }
return k; return k;
@ -2659,9 +2659,9 @@ static void opeq (GenDesc* Gen, ExprDesc *lval, int k)
} }
/* Determine the type of the lhs */ /* Determine the type of the lhs */
flags = TypeOf (lval->e_tptr); flags = TypeOf (lval->Type);
MustScale = (Gen->Func == g_add || Gen->Func == g_sub) && MustScale = (Gen->Func == g_add || Gen->Func == g_sub) &&
lval->e_tptr [0] == T_PTR; lval->Type [0] == T_PTR;
/* Get the lhs address on stack (if needed) */ /* Get the lhs address on stack (if needed) */
PushAddr (lval); PushAddr (lval);
@ -2684,13 +2684,13 @@ static void opeq (GenDesc* Gen, ExprDesc *lval, int k)
} }
if (MustScale) { if (MustScale) {
/* lhs is a pointer, scale rhs */ /* lhs is a pointer, scale rhs */
lval2.e_const *= SizeOf (lval->e_tptr+1); lval2.e_const *= SizeOf (lval->Type+1);
} }
/* If the lhs is character sized, the operation may be later done /* If the lhs is character sized, the operation may be later done
* with characters. * with characters.
*/ */
if (SizeOf (lval->e_tptr) == 1) { if (SizeOf (lval->Type) == 1) {
flags |= CF_FORCECHAR; flags |= CF_FORCECHAR;
} }
@ -2706,18 +2706,18 @@ static void opeq (GenDesc* Gen, ExprDesc *lval, int k)
/* rhs is not constant and already in the primary register */ /* rhs is not constant and already in the primary register */
if (MustScale) { if (MustScale) {
/* lhs is a pointer, scale rhs */ /* lhs is a pointer, scale rhs */
g_scale (TypeOf (lval2.e_tptr), SizeOf (lval->e_tptr+1)); g_scale (TypeOf (lval2.Type), SizeOf (lval->Type+1));
} }
/* If the lhs is character sized, the operation may be later done /* If the lhs is character sized, the operation may be later done
* with characters. * with characters.
*/ */
if (SizeOf (lval->e_tptr) == 1) { if (SizeOf (lval->Type) == 1) {
flags |= CF_FORCECHAR; flags |= CF_FORCECHAR;
} }
/* Adjust the types of the operands if needed */ /* Adjust the types of the operands if needed */
Gen->Func (g_typeadjust (flags, TypeOf (lval2.e_tptr)), 0); Gen->Func (g_typeadjust (flags, TypeOf (lval2.Type)), 0);
} }
store (lval); store (lval);
lval->e_flags = E_MEXPR; lval->e_flags = E_MEXPR;
@ -2752,29 +2752,29 @@ static void addsubeq (GenDesc* Gen, ExprDesc *lval, int k)
NextToken (); NextToken ();
/* Check if we have a pointer expression and must scale rhs */ /* Check if we have a pointer expression and must scale rhs */
MustScale = (lval->e_tptr [0] == T_PTR); MustScale = (lval->Type [0] == T_PTR);
/* Determine the code generator flags */ /* Determine the code generator flags */
flags = TypeOf (lval->e_tptr) | CF_FORCECHAR; flags = TypeOf (lval->Type) | CF_FORCECHAR;
/* Evaluate the rhs */ /* Evaluate the rhs */
if (evalexpr (CF_NONE, hie1, &lval2) == 0) { if (evalexpr (CF_NONE, hie1, &lval2) == 0) {
/* The resulting value is a constant. */ /* The resulting value is a constant. */
if (MustScale) { if (MustScale) {
/* lhs is a pointer, scale rhs */ /* lhs is a pointer, scale rhs */
lval2.e_const *= SizeOf (lval->e_tptr+1); lval2.e_const *= SizeOf (lval->Type+1);
} }
flags |= CF_CONST; flags |= CF_CONST;
} else { } else {
/* rhs is not constant and already in the primary register */ /* rhs is not constant and already in the primary register */
if (MustScale) { if (MustScale) {
/* lhs is a pointer, scale rhs */ /* lhs is a pointer, scale rhs */
g_scale (TypeOf (lval2.e_tptr), SizeOf (lval->e_tptr+1)); g_scale (TypeOf (lval2.Type), SizeOf (lval->Type+1));
} }
} }
/* Adjust the rhs to the lhs */ /* Adjust the rhs to the lhs */
g_typeadjust (flags, TypeOf (lval2.e_tptr)); g_typeadjust (flags, TypeOf (lval2.Type));
/* Output apropriate code */ /* Output apropriate code */
if (lval->e_flags & E_MGLOBAL) { if (lval->e_flags & E_MGLOBAL) {
@ -2823,7 +2823,7 @@ static void Assignment (ExprDesc* lval)
int k; int k;
ExprDesc lval2; ExprDesc lval2;
unsigned flags; unsigned flags;
type* ltype = lval->e_tptr; type* ltype = lval->Type;
/* Check for assignment to const */ /* Check for assignment to const */
if (IsQualConst (ltype)) { if (IsQualConst (ltype)) {
@ -2854,7 +2854,7 @@ static void Assignment (ExprDesc* lval)
g_push (CF_PTR | CF_UNSIGNED, 0); g_push (CF_PTR | CF_UNSIGNED, 0);
/* Check for equality of the structs */ /* Check for equality of the structs */
if (TypeCmp (ltype, lval2.e_tptr) < TC_EQUAL) { if (TypeCmp (ltype, lval2.Type) < TC_EQUAL) {
Error ("Incompatible types"); Error ("Incompatible types");
} }
@ -3052,7 +3052,7 @@ void constexpr (ExprDesc* lval)
Error ("Constant expression expected"); Error ("Constant expression expected");
/* To avoid any compiler errors, make the expression a valid const */ /* To avoid any compiler errors, make the expression a valid const */
lval->e_flags = E_MCONST; lval->e_flags = E_MCONST;
lval->e_tptr = type_int; lval->Type = type_int;
lval->e_const = 0; lval->e_const = 0;
} }
} }
@ -3063,11 +3063,11 @@ void intexpr (ExprDesc* lval)
/* Get an integer expression */ /* Get an integer expression */
{ {
expression (lval); expression (lval);
if (!IsClassInt (lval->e_tptr)) { if (!IsClassInt (lval->Type)) {
Error ("Integer expression expected"); Error ("Integer expression expected");
/* To avoid any compiler errors, make the expression a valid int */ /* To avoid any compiler errors, make the expression a valid int */
lval->e_flags = E_MCONST; lval->e_flags = E_MCONST;
lval->e_tptr = type_int; lval->Type = type_int;
lval->e_const = 0; lval->e_const = 0;
} }
} }
@ -3083,11 +3083,11 @@ void boolexpr (ExprDesc* lval)
/* If it's an integer, it's ok. If it's not an integer, but a pointer, /* If it's an integer, it's ok. If it's not an integer, but a pointer,
* the pointer used in a boolean context is also ok * the pointer used in a boolean context is also ok
*/ */
if (!IsClassInt (lval->e_tptr) && !IsClassPtr (lval->e_tptr)) { if (!IsClassInt (lval->Type) && !IsClassPtr (lval->Type)) {
Error ("Boolean expression expected"); Error ("Boolean expression expected");
/* To avoid any compiler errors, make the expression a valid int */ /* To avoid any compiler errors, make the expression a valid int */
lval->e_flags = E_MCONST; lval->e_flags = E_MCONST;
lval->e_tptr = type_int; lval->Type = type_int;
lval->e_const = 0; lval->e_const = 0;
} }
} }

View File

@ -45,11 +45,11 @@
typedef struct ExprDesc ExprDesc; typedef struct ExprDesc ExprDesc;
struct ExprDesc { struct ExprDesc {
struct SymEntry* Sym; /* Symbol table entry if known */ struct SymEntry* Sym; /* Symbol table entry if known */
type* e_tptr; /* Type array of expression */ type* Type; /* Type array of expression */
long e_const; /* Value if expression constant */ long e_const; /* Value if expression constant */
unsigned e_flags; unsigned short e_flags;
unsigned e_test; /* */ unsigned short e_test; /* */
unsigned long e_name; /* Name or label number */ unsigned long e_name; /* Name or label number */
}; };
@ -65,7 +65,7 @@ void doasm (void);
* looks like the one defined for C++ (C has no ASM directive), that is, * looks like the one defined for C++ (C has no ASM directive), that is,
* a string literal in parenthesis. * a string literal in parenthesis.
*/ */
unsigned assignadjust (type* lhst, ExprDesc* rhs); unsigned assignadjust (type* lhst, ExprDesc* rhs);
/* Adjust the type of the right hand expression so that it can be assigned to /* Adjust the type of the right hand expression so that it can be assigned to
* the type on the left hand side. This function is used for assignment and * the type on the left hand side. This function is used for assignment and

View File

@ -314,7 +314,7 @@ static void ContinueStatement (void)
static void CascadeSwitch (ExprDesc* eval) static void CascadeSwitch (ExprDesc* Expr)
/* Handle a switch statement for chars with a cmp cascade for the selector */ /* Handle a switch statement for chars with a cmp cascade for the selector */
{ {
unsigned ExitLab; /* Exit label */ unsigned ExitLab; /* Exit label */
@ -333,7 +333,7 @@ static void CascadeSwitch (ExprDesc* eval)
AddLoop (oursp, 0, ExitLab, 0, 0); AddLoop (oursp, 0, ExitLab, 0, 0);
/* Setup some variables needed in the loop below */ /* Setup some variables needed in the loop below */
Flags = TypeOf (eval->e_tptr) | CF_CONST | CF_FORCECHAR; Flags = TypeOf (Expr->Type) | CF_CONST | CF_FORCECHAR;
CodeLab = NextLab = 0; CodeLab = NextLab = 0;
HaveBreak = 1; HaveBreak = 1;
HaveDefault = 0; HaveDefault = 0;
@ -374,13 +374,13 @@ static void CascadeSwitch (ExprDesc* eval)
/* Read the selector expression */ /* Read the selector expression */
constexpr (&lval); constexpr (&lval);
if (!IsClassInt (lval.e_tptr)) { if (!IsClassInt (lval.Type)) {
Error ("Switch quantity not an integer"); Error ("Switch quantity not an integer");
} }
/* Check the range of the expression */ /* Check the range of the expression */
Val = lval.e_const; Val = lval.e_const;
switch (*eval->e_tptr) { switch (*Expr->Type) {
case T_SCHAR: case T_SCHAR:
/* Signed char */ /* Signed char */
@ -408,7 +408,7 @@ static void CascadeSwitch (ExprDesc* eval)
break; break;
default: default:
Internal ("Invalid type: %02X", *eval->e_tptr & 0xFF); Internal ("Invalid type: %02X", *Expr->Type & 0xFF);
} }
/* Emit a compare */ /* Emit a compare */
@ -492,7 +492,7 @@ static void CascadeSwitch (ExprDesc* eval)
static void TableSwitch (ExprDesc* eval) static void TableSwitch (ExprDesc* Expr)
/* Handle a switch statement via table based selector */ /* Handle a switch statement via table based selector */
{ {
/* Entry for one case in a switch statement */ /* Entry for one case in a switch statement */
@ -537,7 +537,7 @@ static void TableSwitch (ExprDesc* eval)
if (CurTok.Tok == TOK_CASE) { if (CurTok.Tok == TOK_CASE) {
NextToken (); NextToken ();
constexpr (&lval); constexpr (&lval);
if (!IsClassInt (lval.e_tptr)) { if (!IsClassInt (lval.Type)) {
Error ("Switch quantity not an integer"); Error ("Switch quantity not an integer");
} }
p->sw_const = lval.e_const; p->sw_const = lval.e_const;
@ -576,7 +576,7 @@ static void TableSwitch (ExprDesc* eval)
g_defcodelabel (lcase); g_defcodelabel (lcase);
/* Create the call to the switch subroutine */ /* Create the call to the switch subroutine */
Flags = TypeOf (eval->e_tptr); Flags = TypeOf (Expr->Type);
g_switch (Flags); g_switch (Flags);
/* First entry is negative of label count */ /* First entry is negative of label count */
@ -605,24 +605,24 @@ static void TableSwitch (ExprDesc* eval)
static void SwitchStatement (void) static void SwitchStatement (void)
/* Handle a 'switch' statement */ /* Handle a 'switch' statement */
{ {
ExprDesc eval; /* Switch statement expression */ ExprDesc Expr; /* Switch statement expression */
/* Eat the "switch" */ /* Eat the "switch" */
NextToken (); NextToken ();
/* Read the switch expression */ /* Read the switch expression */
ConsumeLParen (); ConsumeLParen ();
intexpr (&eval); intexpr (&Expr);
ConsumeRParen (); ConsumeRParen ();
/* result of expr is in P */ /* result of expr is in P */
ConsumeLCurly (); ConsumeLCurly ();
/* Now decide which sort of switch we will create: */ /* Now decide which sort of switch we will create: */
if (IsTypeChar (eval.e_tptr) || (CodeSizeFactor >= 200 && IsClassInt (eval.e_tptr))) { if (IsTypeChar (Expr.Type) || (CodeSizeFactor >= 200 && IsClassInt (Expr.Type))) {
CascadeSwitch (&eval); CascadeSwitch (&Expr);
} else { } else {
TableSwitch (&eval); TableSwitch (&Expr);
} }
} }