Code cleanup

git-svn-id: svn://svn.cc65.org/cc65/trunk@2728 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
cuz
2003-12-12 12:59:10 +00:00
parent 271391d217
commit 54a50d9354
10 changed files with 72 additions and 176 deletions

View File

@@ -1469,103 +1469,6 @@ int IsConstExpr (ExprNode* Expr, long* Val)
static void CheckAddrSize (const ExprNode* N, unsigned char* AddrSize)
/* Internal routine that is recursively called to check for the address size
* of the expression tree.
*/
{
unsigned char A;
unsigned char Left, Right;
if (N) {
switch (N->Op & EXPR_TYPEMASK) {
case EXPR_LEAFNODE:
switch (N->Op) {
case EXPR_SYMBOL:
if (SymIsZP (N->V.Sym)) {
if (*AddrSize < ADDR_SIZE_ZP) {
*AddrSize = ADDR_SIZE_ZP;
}
} else if (SymHasExpr (N->V.Sym)) {
/* Check if this expression is a byte expression */
CheckAddrSize (GetSymExpr (N->V.Sym), AddrSize);
} else {
/* Undefined symbol, use absolute */
if (*AddrSize < ADDR_SIZE_ABS) {
*AddrSize = ADDR_SIZE_ABS;
}
}
break;
case EXPR_SECTION:
A = GetSegAddrSize (N->V.SegNum);
if (A > *AddrSize) {
*AddrSize = A;
}
break;
}
break;
case EXPR_UNARYNODE:
switch (N->Op) {
case EXPR_BYTE0:
case EXPR_BYTE1:
case EXPR_BYTE2:
case EXPR_BYTE3:
/* No need to look at the expression */
*AddrSize = ADDR_SIZE_ZP;
break;
case EXPR_WORD0:
case EXPR_WORD1:
/* No need to look at the expression */
*AddrSize = ADDR_SIZE_ABS;
break;
default:
CheckAddrSize (N->Left, AddrSize);
break;
}
break;
case EXPR_BINARYNODE:
Left = Right = ADDR_SIZE_DEFAULT;
CheckAddrSize (N->Left, &Left);
CheckAddrSize (N->Right, &Right);
A = (Left > Right)? Left : Right;
if (A > *AddrSize) {
*AddrSize = A;
}
break;
default:
Internal ("Unknown expression op: %02X", N->Op);
}
}
}
int IsByteExpr (ExprNode* Root)
/* Return true if this is a byte expression */
{
long Val;
if (IsConstExpr (Root, &Val)) {
return IsByteRange (Val);
} else {
unsigned char AddrSize = ADDR_SIZE_DEFAULT;
CheckAddrSize (Root, &AddrSize);
return (AddrSize == ADDR_SIZE_ZP);
}
}
ExprNode* CloneExpr (ExprNode* Expr)
/* Clone the given expression tree. The function will simply clone symbol
* nodes, it will not resolve them.