]> git.sur5r.net Git - cc65/blobdiff - src/common/exprdefs.h
Any field without a name is legal but useless in a union.
[cc65] / src / common / exprdefs.h
index 8eca9ea4f41d1ef4dbf621a6a0152f066d358c78..165c60fda6a419ba9d22c59ad9a1630b9593e2e3 100644 (file)
@@ -6,10 +6,10 @@
 /*                                                                           */
 /*                                                                           */
 /*                                                                           */
-/* (C) 1998     Ullrich von Bassewitz                                        */
-/*              Wacholderweg 14                                              */
-/*              D-70597 Stuttgart                                            */
-/* EMail:       uz@musoftware.de                                             */
+/* (C) 1998-2007 Ullrich von Bassewitz                                       */
+/*               Roemerstrasse 52                                            */
+/*               D-70794 Filderstadt                                         */
+/* EMail:        uz@cc65.org                                                 */
 /*                                                                           */
 /*                                                                           */
 /* This software is provided 'as-is', without any expressed or implied       */
 /* Leaf node codes */
 #define EXPR_LITERAL                   (EXPR_LEAFNODE | 0x01)
 #define EXPR_SYMBOL                    (EXPR_LEAFNODE | 0x02)
-#define EXPR_SEGMENT                   (EXPR_LEAFNODE | 0x03)
-#define EXPR_MEMAREA           (EXPR_LEAFNODE | 0x04)  /* Linker only */
-#define EXPR_ULABEL            (EXPR_LEAFNODE | 0x05)  /* Assembler only */
+#define EXPR_SECTION            (EXPR_LEAFNODE | 0x03)
+#define EXPR_SEGMENT                   (EXPR_LEAFNODE | 0x04)  /* Linker only */
+#define EXPR_MEMAREA                   (EXPR_LEAFNODE | 0x05)  /* Linker only */
+#define EXPR_ULABEL            (EXPR_LEAFNODE | 0x06)  /* Assembler only */
 
 /* Binary operations, left and right hand sides are valid */
 #define EXPR_PLUS                      (EXPR_BINARYNODE | 0x01)
 #define EXPR_GT                        (EXPR_BINARYNODE | 0x0E)
 #define EXPR_LE                        (EXPR_BINARYNODE | 0x0F)
 #define EXPR_GE                        (EXPR_BINARYNODE | 0x10)
-#define EXPR_BAND              (EXPR_BINARYNODE | 0x11)
-#define EXPR_BOR               (EXPR_BINARYNODE | 0x12)
-#define EXPR_BXOR              (EXPR_BINARYNODE | 0x13)
+#define EXPR_BOOLAND           (EXPR_BINARYNODE | 0x11)
+#define EXPR_BOOLOR            (EXPR_BINARYNODE | 0x12)
+#define EXPR_BOOLXOR           (EXPR_BINARYNODE | 0x13)
 
 /* 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_BOOLNOT           (EXPR_UNARYNODE | 0x04)
+
+#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)
 
 
 
 /* The expression node itself */
-typedef struct ExprNode_ ExprNode;
-struct ExprNode_ {
+typedef struct ExprNode ExprNode;
+struct ExprNode {
     unsigned char          Op;         /* Operand/Type */
-    ExprNode*              Left;       /* Left leaf */
-    ExprNode*              Right;      /* Right leaf */
-    struct ObjData_*       Obj;        /* Object file reference (linker) */
+    ExprNode*                      Left;       /* Left leaf */
+    ExprNode*                      Right;      /* Right leaf */
+    struct ObjData       Obj;        /* Object file reference (linker) */
     union {
-               long                Val;        /* If this is a value */
-               struct SymEntry_*   Sym;        /* If this is a symbol */
-       unsigned            SegNum;     /* If this is a segment */
-       unsigned            ImpNum;     /* If this is an import */
-       struct Memory_*     MemArea;    /* If this is a memory area */
+               long                IVal;       /* If this is a int value */
+               struct SymEntry*    Sym;        /* If this is a symbol */
+       unsigned            SegNum;     /* If this is a segment */
+       unsigned            ImpNum;     /* If this is an import */
+        struct Memory*      Mem;        /* If this is a memory area */
+       struct Segment*     Seg;        /* If this is a segment */
+       struct Section*     Sec;        /* If section and Obj is NULL */
     } V;
 };
 
@@ -116,6 +124,17 @@ struct ExprNode_ {
 
 
 
+/*****************************************************************************/
+/*                                          Code                                    */
+/*****************************************************************************/
+
+
+
+void DumpExpr (const ExprNode* Expr, const ExprNode* (*ResolveSym) (const struct SymEntry*));
+/* Dump an expression tree to stdout */
+
+
+
 /* End of exprdefs.h */
 
 #endif