Renamed several expression ops and added others.

Placed the DumpExpr function into the common directory, since it is
used by the assembler and linker.


git-svn-id: svn://svn.cc65.org/cc65/trunk@225 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
cuz
2000-07-29 15:53:33 +00:00
parent b40d409c4f
commit 0a57d32509
14 changed files with 285 additions and 331 deletions

189
src/common/exprdefs.c Normal file
View File

@@ -0,0 +1,189 @@
/*****************************************************************************/
/* */
/* exprdefs.c */
/* */
/* Expression tree definitions */
/* */
/* */
/* */
/* (C) 1998-2000 Ullrich von Bassewitz */
/* Wacholderweg 14 */
/* D-70597 Stuttgart */
/* EMail: uz@musoftware.de */
/* */
/* */
/* This software is provided 'as-is', without any expressed or implied */
/* warranty. In no event will the authors be held liable for any damages */
/* arising from the use of this software. */
/* */
/* Permission is granted to anyone to use this software for any purpose, */
/* including commercial applications, and to alter it and redistribute it */
/* freely, subject to the following restrictions: */
/* */
/* 1. The origin of this software must not be misrepresented; you must not */
/* claim that you wrote the original software. If you use this software */
/* in a product, an acknowledgment in the product documentation would be */
/* appreciated but is not required. */
/* 2. Altered source versions must be plainly marked as such, and must not */
/* be misrepresented as being the original software. */
/* 3. This notice may not be removed or altered from any source */
/* distribution. */
/* */
/*****************************************************************************/
#include <stdio.h>
#include "abend.h"
#include "exprdefs.h"
/*****************************************************************************/
/* Code */
/*****************************************************************************/
static void InternalDumpExpr (const ExprNode* Expr)
/* Dump an expression in RPN to stdout */
{
if (Expr == 0) {
return;
}
InternalDumpExpr (Expr->Left);
InternalDumpExpr (Expr->Right);
switch (Expr->Op) {
case EXPR_LITERAL:
case EXPR_ULABEL:
printf (" $%04lX", Expr->V.Val & 0xFFFF);
break;
case EXPR_SYMBOL:
printf (" SYM");
break;
case EXPR_SEGMENT:
printf (" SEG");
break;
case EXPR_PLUS:
printf (" +");
break;
case EXPR_MINUS:
printf (" -");
break;
case EXPR_MUL:
printf (" *");
break;
case EXPR_DIV:
printf (" /");
break;
case EXPR_MOD:
printf (" MOD");
break;
case EXPR_OR:
printf (" OR");
break;
case EXPR_XOR:
printf (" XOR");
break;
case EXPR_AND:
printf (" AND");
break;
case EXPR_SHL:
printf (" SHL");
break;
case EXPR_SHR:
printf (" SHR");
break;
case EXPR_EQ:
printf (" =");
break;
case EXPR_NE:
printf ("<>");
break;
case EXPR_LT:
printf (" <");
break;
case EXPR_GT:
printf (" >");
break;
case EXPR_UNARY_MINUS:
printf (" NEG");
break;
case EXPR_NOT:
printf (" ~");
break;
case EXPR_BYTE0:
printf (" BYTE0");
break;
case EXPR_BYTE1:
printf (" BYTE1");
break;
case EXPR_BYTE2:
printf (" BYTE2");
break;
case EXPR_BYTE3:
printf (" BYTE3");
break;
case EXPR_SWAP:
printf (" SWAP");
break;
case EXPR_BAND:
printf (" BOOL_AND");
break;
case EXPR_BOR:
printf (" BOOL_OR");
break;
case EXPR_BXOR:
printf (" BOOL_XOR");
break;
case EXPR_BNOT:
printf (" BOOL_NOT");
break;
default:
AbEnd ("Unknown Op type: %u", Expr->Op);
}
}
void DumpExpr (const ExprNode* Expr)
/* Dump an expression tree to stdout */
{
InternalDumpExpr (Expr);
printf ("\n");
}

View File

@@ -6,10 +6,10 @@
/* */
/* */
/* */
/* (C) 1998 Ullrich von Bassewitz */
/* Wacholderweg 14 */
/* D-70597 Stuttgart */
/* EMail: uz@musoftware.de */
/* (C) 1998-2000 Ullrich von Bassewitz */
/* Wacholderweg 14 */
/* D-70597 Stuttgart */
/* EMail: uz@musoftware.de */
/* */
/* */
/* This software is provided 'as-is', without any expressed or implied */
@@ -84,10 +84,17 @@
/* Unary operations, right hand side is empty */
#define EXPR_UNARY_MINUS (EXPR_UNARYNODE | 0x01)
#define EXPR_NOT (EXPR_UNARYNODE | 0x02)
#define EXPR_LOBYTE (EXPR_UNARYNODE | 0x03)
#define EXPR_HIBYTE (EXPR_UNARYNODE | 0x04)
#define EXPR_SWAP (EXPR_UNARYNODE | 0x05)
#define EXPR_BNOT (EXPR_UNARYNODE | 0x06)
#define EXPR_SWAP (EXPR_UNARYNODE | 0x03)
#define EXPR_BNOT (EXPR_UNARYNODE | 0x04)
#define EXPR_FORCEWORD (EXPR_UNARYNODE | 0x05)
#define EXPR_FORCEFAR (EXPR_UNARYNODE | 0x06)
#define EXPR_BYTE0 (EXPR_UNARYNODE | 0x08)
#define EXPR_BYTE1 (EXPR_UNARYNODE | 0x09)
#define EXPR_BYTE2 (EXPR_UNARYNODE | 0x0A)
#define EXPR_BYTE3 (EXPR_UNARYNODE | 0x0B)
#define EXPR_WORD0 (EXPR_UNARYNODE | 0x0C)
#define EXPR_WORD1 (EXPR_UNARYNODE | 0x0D)
@@ -101,7 +108,7 @@ struct ExprNode_ {
union {
long Val; /* If this is a value */
struct SymEntry_* Sym; /* If this is a symbol */
unsigned SegNum; /* If this is a segment */
unsigned SegNum; /* If this is a segment */
unsigned ImpNum; /* If this is an import */
struct Memory_* MemArea; /* If this is a memory area */
} V;
@@ -116,6 +123,17 @@ struct ExprNode_ {
/*****************************************************************************/
/* Code */
/*****************************************************************************/
void DumpExpr (const ExprNode* Expr);
/* Dump an expression tree to stdout */
/* End of exprdefs.h */
#endif

View File

@@ -12,6 +12,7 @@ LIB = common.a
OBJS = abend.o \
bitops.o \
cmdline.o \
exprdefs.o \
fname.o \
hashstr.o \
xmalloc.o \

View File

@@ -68,6 +68,7 @@ CCCFG = -bt=$(TARGET) -d1 -onatx -zp4 -5 -zq -w2
OBJS = abend.obj \
bitops.obj \
cmdline.obj \
exprdefs.obj \
fname.obj \
hashstr.obj \
wildargv.obj \

View File

@@ -46,7 +46,7 @@
/* Defines for magic and version */
#define OBJ_MAGIC 0x616E7A55
#define OBJ_VERSION 0x0005
#define OBJ_VERSION 0x0006
/* Size of an object file header */
#define OBJ_HDR_SIZE 56