2000-05-28 13:40:48 +00:00
|
|
|
/*
|
|
|
|
* expr.h
|
|
|
|
*
|
|
|
|
* Ullrich von Bassewitz, 21.06.1998
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef EXPR_H
|
|
|
|
#define EXPR_H
|
|
|
|
|
|
|
|
|
|
|
|
|
2002-11-01 21:27:31 +00:00
|
|
|
/* cc65 */
|
2000-05-28 13:40:48 +00:00
|
|
|
#include "datatype.h"
|
2002-11-01 21:27:31 +00:00
|
|
|
#include "exprdesc.h"
|
2000-05-28 13:40:48 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
2002-11-01 21:27:31 +00:00
|
|
|
/* code */
|
2000-05-28 13:40:48 +00:00
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
|
|
|
2002-11-01 21:27:31 +00:00
|
|
|
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.
|
|
|
|
*/
|
2000-05-28 13:40:48 +00:00
|
|
|
|
2001-09-09 20:49:20 +00:00
|
|
|
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.
|
2000-05-28 13:40:48 +00:00
|
|
|
*/
|
2001-07-17 21:53:17 +00:00
|
|
|
|
2002-11-24 18:18:16 +00:00
|
|
|
void CheckBoolExpr (ExprDesc* lval);
|
|
|
|
/* Check if the given expression is a boolean expression, output a diagnostic
|
|
|
|
* if not.
|
|
|
|
*/
|
|
|
|
|
2001-07-17 21:24:19 +00:00
|
|
|
unsigned assignadjust (type* lhst, ExprDesc* rhs);
|
2000-05-28 13:40:48 +00:00
|
|
|
/* 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.
|
|
|
|
*/
|
|
|
|
|
2001-07-17 21:24:19 +00:00
|
|
|
void exprhs (unsigned flags, int k, ExprDesc *lval);
|
2000-05-28 13:40:48 +00:00
|
|
|
/* Put the result of an expression into the primary register */
|
|
|
|
|
2002-11-01 21:27:31 +00:00
|
|
|
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.
|
|
|
|
*/
|
|
|
|
|
2001-07-17 21:24:19 +00:00
|
|
|
void expression1 (ExprDesc* lval);
|
2000-05-28 13:40:48 +00:00
|
|
|
/* Evaluate an expression on level 1 (no comma operator) and put it into
|
|
|
|
* the primary register
|
|
|
|
*/
|
|
|
|
|
2001-07-17 21:24:19 +00:00
|
|
|
void expression (ExprDesc* lval);
|
2000-05-28 13:40:48 +00:00
|
|
|
/* Evaluate an expression and put it into the primary register */
|
|
|
|
|
2001-07-17 21:24:19 +00:00
|
|
|
int evalexpr (unsigned flags, int (*f) (ExprDesc*), ExprDesc* lval);
|
2000-05-28 13:40:48 +00:00
|
|
|
/* 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
|
|
|
|
* primary register and 1 is returned.
|
|
|
|
*/
|
|
|
|
|
2002-02-18 08:40:11 +00:00
|
|
|
void ConstExpr (ExprDesc* lval);
|
2000-05-28 13:40:48 +00:00
|
|
|
/* Get a constant value */
|
|
|
|
|
2002-02-18 08:40:11 +00:00
|
|
|
void ConstIntExpr (ExprDesc* Val);
|
|
|
|
/* Get a constant int value */
|
|
|
|
|
2001-07-17 21:24:19 +00:00
|
|
|
void intexpr (ExprDesc* lval);
|
2000-05-28 13:40:48 +00:00
|
|
|
/* Get an integer expression */
|
|
|
|
|
2002-11-01 15:16:16 +00:00
|
|
|
int hie10 (ExprDesc* lval);
|
|
|
|
/* Handle ++, --, !, unary - etc. */
|
|
|
|
|
2001-07-17 21:24:19 +00:00
|
|
|
int hie1 (ExprDesc* lval);
|
2000-05-28 13:40:48 +00:00
|
|
|
/* Parse first level of expression hierarchy. */
|
|
|
|
|
2001-07-17 21:24:19 +00:00
|
|
|
void DefineData (ExprDesc* lval);
|
2000-05-28 13:40:48 +00:00
|
|
|
/* Output a data definition for the given expression */
|
|
|
|
|
2002-11-24 18:18:16 +00:00
|
|
|
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.
|
|
|
|
*/
|
|
|
|
|
2000-05-28 13:40:48 +00:00
|
|
|
|
|
|
|
|
|
|
|
/* End of expr.h */
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|