X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=src%2Fcc65%2Fexpr.h;h=efd1777e66bf2a2be7161ebd67dd20ed72956aa8;hb=dbbce2e939af8fd78f659e5c66eea8b002369ba2;hp=7e776bd9000c4cca36be86f0fbf79c5426cd2295;hpb=f249ae345ed1e25c3b6debe8bccad5b26de2c083;p=cc65 diff --git a/src/cc65/expr.h b/src/cc65/expr.h index 7e776bd90..efd1777e6 100644 --- a/src/cc65/expr.h +++ b/src/cc65/expr.h @@ -11,59 +11,35 @@ +/* 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 */