]> git.sur5r.net Git - cc65/blobdiff - src/cc65/expr.h
Fixed a bug
[cc65] / src / cc65 / expr.h
index 7e776bd9000c4cca36be86f0fbf79c5426cd2295..efd1777e66bf2a2be7161ebd67dd20ed72956aa8 100644 (file)
 
 
 
+/* cc65 */
 #include "datatype.h"
+#include "exprdesc.h"
 
 
 
 /*****************************************************************************/
-/*                                  data                                    */
+/*                                  code                                    */
 /*****************************************************************************/
 
 
 
-/* Defines for the flags field of the expression descriptor */
-#define E_MREG         0x0110  /* Special: Expression is primary register */
-#define E_MGLOBAL              0x0080  /* Reference to static variable */
-#define E_MLOCAL       0x0040  /* Reference to local variable (stack offset) */
-#define E_MCONST       0x0020  /* Constant value */
-#define E_MEXPR                0x0010  /* Result is in primary register */
-#define E_MEOFFS               0x0011  /* Base is in primary register, const offset */
-
-#define E_MCTYPE       0x0007  /* Type of a constant */
-#define E_TCONST       0x0000  /* Constant */
-#define E_TGLAB                0x0001  /* Global label */
-#define E_TLIT         0x0002  /* Literal of some kind */
-#define E_TLOFFS       0x0003  /* Constant stack offset */
-#define E_TLLAB                0x0004  /* Local label */
-#define E_TREGISTER    0x0005  /* Register variable */
-
-/* Defines for the test field of the expression descriptor */
-#define E_CC           0x0001  /* expr has set cond codes apropos result value */
-#define E_FORCETEST            0x0002  /* if expr has NOT set CC, force a test */
-
-/* Describe the result of an expression */
-typedef struct ExprDesc ExprDesc;
-struct ExprDesc {
-    struct SymEntry*   Sym;     /* Symbol table entry if known */
-    type*              Type;    /* Type array of expression */
-    long                       ConstVal;/* Value if expression constant */
-    unsigned short             Flags;
-    unsigned short     Test;    /* */
-    unsigned long      Name;    /* Name or label number */
-};
-
-
-
-/*****************************************************************************/
-/*                                  code                                    */
-/*****************************************************************************/
-
+void PushAddr (ExprDesc* lval);
+/* If the expression contains an address that was somehow evaluated,
+ * push this address on the stack. This is a helper function for all
+ * sorts of implicit or explicit assignment functions where the lvalue
+ * must be saved if it's not constant, before evaluating the rhs.
+ */
 
+void ConstSubExpr (int (*F) (ExprDesc*), ExprDesc* Expr);
+/* Will evaluate an expression via the given function. If the result is not
+ * a constant, a diagnostic will be printed, and the value is replaced by
+ * a constant one to make sure there are no internal errors that result
+ * from this input error.
+ */
 
-void doasm (void);
-/* This function parses ASM statements. The syntax of the ASM directive
- * looks like the one defined for C++ (C has no ASM directive), that is,
- * a string literal in parenthesis.
+void CheckBoolExpr (ExprDesc* lval);
+/* Check if the given expression is a boolean expression, output a diagnostic
+ * if not.
  */
 
 unsigned assignadjust (type* lhst, ExprDesc* rhs);
@@ -76,6 +52,12 @@ unsigned assignadjust (type* lhst, ExprDesc* rhs);
 void exprhs (unsigned flags, int k, ExprDesc *lval);
 /* Put the result of an expression into the primary register */
 
+void Store (ExprDesc* lval, const type* StoreType);
+/* Store the primary register into the location denoted by lval. If StoreType
+ * is given, use this type when storing instead of lval->Type. If StoreType
+ * is NULL, use lval->Type instead.
+ */
+
 void expression1 (ExprDesc* lval);
 /* Evaluate an expression on level 1 (no comma operator) and put it into
  * the primary register
@@ -91,27 +73,34 @@ int evalexpr (unsigned flags, int (*f) (ExprDesc*), ExprDesc* lval);
  * primary register and 1 is returned.
  */
 
-void constexpr (ExprDesc* lval);
+void ConstExpr (ExprDesc* lval);
 /* Get a constant value */
 
+void ConstIntExpr (ExprDesc* Val);
+/* Get a constant int value */
+
 void intexpr (ExprDesc* lval);
 /* Get an integer expression */
 
-void boolexpr (ExprDesc* lval);
-/* Get a boolean expression */
-
-void test (unsigned label, int cond);
-/* Generate code to perform test and jump if false. */
+int hie10 (ExprDesc* lval);
+/* Handle ++, --, !, unary - etc. */
 
 int hie1 (ExprDesc* lval);
 /* Parse first level of expression hierarchy. */
 
-int hie0 (ExprDesc* lval);
-/* Parse comma operator (highest level of expression hierarchy) */
-
 void DefineData (ExprDesc* lval);
 /* Output a data definition for the given expression */
 
+void Test (unsigned Label, int Invert);
+/* Evaluate a boolean test expression and jump depending on the result of
+ * the test and on Invert.
+ */
+
+void TestInParens (unsigned Label, int Invert);
+/* Evaluate a boolean test expression in parenthesis and jump depending on
+ * the result of the test * and on Invert.
+ */
+
 
 
 /* End of expr.h */