]> git.sur5r.net Git - cc65/blobdiff - src/cc65/expr.h
Merge remote-tracking branch 'upstream/master' into a5200
[cc65] / src / cc65 / expr.h
index 325abcd6de941f836c9d071f0f12e98321bf7ce4..193fe39eb3182ea6233474ed251c6ece53d34f77 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 */
+void ExprWithCheck (void (*Func) (ExprDesc*), ExprDesc* Expr);
+/* Call an expression function with checks. */
 
-#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*              e_tptr;  /* Type array of expression */
-    long               e_const; /* Value if expression constant */
-    unsigned           e_flags;
-    unsigned           e_test;  /* */
-    unsigned long      e_name;  /* Name or label number */
-};
-
-
-
-/*****************************************************************************/
-/*                                  code                                    */
-/*****************************************************************************/
-
-
-
-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 MarkedExprWithCheck (void (*Func) (ExprDesc*), ExprDesc* Expr);
+/* Call an expression function with checks and record start and end of the
+ * generated code.
  */
 
-unsigned assignadjust (type* lhst, ExprDesc* rhs);
-/* 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
- * for converting parameters in a function call. It returns the code generator
- * flags for the operation.
+void PushAddr (const ExprDesc* Expr);
+/* 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 exprhs (unsigned flags, int k, ExprDesc *lval);
-/* Put the result of an expression into the primary register */
-
-void expression1 (ExprDesc* lval);
-/* Evaluate an expression on level 1 (no comma operator) and put it into
- * the primary register
+void Store (ExprDesc* Expr, 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 expression (ExprDesc* lval);
-/* Evaluate an expression and put it into the primary register */
-
-int evalexpr (unsigned flags, int (*f) (ExprDesc*), ExprDesc* lval);
+int evalexpr (unsigned flags, void (*Func) (ExprDesc*), ExprDesc* Expr);
 /* Will evaluate an expression via the given function. If the result is a
- * constant, 0 is returned and the value is put in the lval struct. If the
- * result is not constant, exprhs is called to bring the value into the
+ * constant, 0 is returned and the value is put in the Expr struct. If the
+ * result is not constant, LoadExpr is called to bring the value into the
  * primary register and 1 is returned.
  */
 
-void constexpr (ExprDesc* lval);
-/* Get a constant value */
+void Expression0 (ExprDesc* Expr);
+/* Evaluate an expression via hie0 and put the result into the primary register */
 
-void intexpr (ExprDesc* lval);
-/* Get an integer expression */
+void ConstExpr (void (*Func) (ExprDesc*), ExprDesc* Expr);
+/* Will evaluate an expression via the given function. If the result is not
+ * a constant of some sort, 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 boolexpr (ExprDesc* lval);
-/* Get a boolean expression */
+void BoolExpr (void (*Func) (ExprDesc*), ExprDesc* Expr);
+/* Will evaluate an expression via the given function. If the result is not
+ * something that may be evaluated in a boolean context, 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 test (unsigned label, int cond);
-/* Generate code to perform test and jump if false. */
+void ConstAbsIntExpr (void (*Func) (ExprDesc*), ExprDesc* Expr);
+/* Will evaluate an expression via the given function. If the result is not
+ * a constant numeric integer value, 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.
+ */
 
-int hie1 (ExprDesc* lval);
-/* Parse first level of expression hierarchy. */
+void hie10 (ExprDesc* lval);
+/* Handle ++, --, !, unary - etc. */
 
-int hie0 (ExprDesc* lval);
-/* Parse comma operator (highest level of expression hierarchy) */
+void hie8 (ExprDesc* Expr);
+/* Process + and - binary operators. */
 
-void DefineData (ExprDesc* lval);
-/* Output a data definition for the given expression */
+void hie1 (ExprDesc* lval);
+/* Parse first level of expression hierarchy. */
+
+void hie0 (ExprDesc* Expr);
+/* Parse comma operator. */
 
 
 
 /* End of expr.h */
 
 #endif
-
-
-
-