2000-05-28 13:40:48 +00:00
|
|
|
/*
|
2014-06-30 09:10:35 +00:00
|
|
|
** expr.h
|
|
|
|
**
|
|
|
|
** Ullrich von Bassewitz, 21.06.1998
|
|
|
|
*/
|
2000-05-28 13:40:48 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#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
|
|
|
|
|
|
|
|
|
|
|
|
2020-04-16 09:19:16 +00:00
|
|
|
/*****************************************************************************/
|
|
|
|
/* data */
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#define SQP_KEEP_NONE 0x00
|
|
|
|
#define SQP_KEEP_TEST 0x01U
|
|
|
|
#define SQP_KEEP_EAX 0x02U
|
|
|
|
#define SQP_KEEP_EXPR 0x03U /* SQP_KEEP_TEST | SQP_KEEP_EAX */
|
|
|
|
|
|
|
|
|
|
|
|
|
2000-05-28 13:40:48 +00:00
|
|
|
/*****************************************************************************/
|
2013-05-09 11:56:54 +00:00
|
|
|
/* code */
|
2000-05-28 13:40:48 +00:00
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
|
|
|
2009-09-08 19:48:22 +00:00
|
|
|
void ExprWithCheck (void (*Func) (ExprDesc*), ExprDesc* Expr);
|
2004-06-05 11:35:53 +00:00
|
|
|
/* Call an expression function with checks. */
|
|
|
|
|
2009-09-08 19:48:22 +00:00
|
|
|
void MarkedExprWithCheck (void (*Func) (ExprDesc*), ExprDesc* Expr);
|
|
|
|
/* Call an expression function with checks and record start and end of the
|
2014-06-30 09:10:35 +00:00
|
|
|
** generated code.
|
|
|
|
*/
|
2009-09-08 19:48:22 +00:00
|
|
|
|
2004-06-05 11:35:53 +00:00
|
|
|
void PushAddr (const ExprDesc* Expr);
|
2002-11-01 21:27:31 +00:00
|
|
|
/* If the expression contains an address that was somehow evaluated,
|
2014-06-30 09:10:35 +00:00
|
|
|
** 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
|
|
|
|
2020-04-16 09:19:16 +00:00
|
|
|
void InitDeferredOps (void);
|
|
|
|
/* Init the collection for storing deferred ops */
|
|
|
|
|
|
|
|
void DoneDeferredOps (void);
|
|
|
|
/* Deinit the collection for storing deferred ops */
|
|
|
|
|
|
|
|
int GetDeferredOpCount (void);
|
|
|
|
/* Return how many deferred operations are still waiting in the queque */
|
|
|
|
|
|
|
|
void CheckDeferredOpAllDone (void);
|
|
|
|
/* Check if all deferred operations are done at sequence points.
|
|
|
|
** Die off if check fails.
|
|
|
|
*/
|
|
|
|
|
|
|
|
void DoDeferred (unsigned Flags, ExprDesc* Expr);
|
|
|
|
/* Do deferred operations such as post-inc/dec at sequence points */
|
|
|
|
|
2006-02-19 12:29:37 +00:00
|
|
|
void Store (ExprDesc* Expr, const Type* StoreType);
|
2002-11-01 21:27:31 +00:00
|
|
|
/* Store the primary register into the location denoted by lval. If StoreType
|
2014-06-30 09:10:35 +00:00
|
|
|
** is given, use this type when storing instead of lval->Type. If StoreType
|
|
|
|
** is NULL, use lval->Type instead.
|
|
|
|
*/
|
2002-11-01 21:27:31 +00:00
|
|
|
|
2004-05-31 15:27:33 +00:00
|
|
|
int evalexpr (unsigned flags, void (*Func) (ExprDesc*), ExprDesc* Expr);
|
2000-05-28 13:40:48 +00:00
|
|
|
/* Will evaluate an expression via the given function. If the result is a
|
2014-06-30 09:10:35 +00:00
|
|
|
** 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.
|
|
|
|
*/
|
2000-05-28 13:40:48 +00:00
|
|
|
|
2004-05-31 15:27:33 +00:00
|
|
|
void Expression0 (ExprDesc* Expr);
|
2020-04-16 09:19:16 +00:00
|
|
|
/* Evaluate an expression via hie0 and put the result into the primary register.
|
|
|
|
** The expression is completely evaluated and all side effects complete.
|
|
|
|
*/
|
2004-03-02 18:00:08 +00:00
|
|
|
|
2004-05-31 15:27:33 +00:00
|
|
|
void BoolExpr (void (*Func) (ExprDesc*), ExprDesc* Expr);
|
|
|
|
/* Will evaluate an expression via the given function. If the result is not
|
2014-06-30 09:10:35 +00:00
|
|
|
** 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.
|
|
|
|
*/
|
2002-02-18 08:40:11 +00:00
|
|
|
|
2020-08-29 16:26:52 +00:00
|
|
|
ExprDesc NoCodeConstExpr (void (*Func) (ExprDesc*));
|
2020-08-19 23:52:11 +00:00
|
|
|
/* Get an expression evaluated via the given function. If the result is not a
|
2020-08-29 16:26:52 +00:00
|
|
|
** constant expression without runtime code generated, 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.
|
2020-08-19 23:52:11 +00:00
|
|
|
*/
|
|
|
|
|
2020-08-29 16:26:52 +00:00
|
|
|
ExprDesc NoCodeConstAbsIntExpr (void (*Func) (ExprDesc*));
|
|
|
|
/* Get an expression evaluated via the given function. If the result is not a
|
|
|
|
** constant numeric integer value without runtime code generated, 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.
|
2014-06-30 09:10:35 +00:00
|
|
|
*/
|
2000-05-28 13:40:48 +00:00
|
|
|
|
2004-05-25 20:59:38 +00:00
|
|
|
void hie10 (ExprDesc* lval);
|
2002-11-01 15:16:16 +00:00
|
|
|
/* Handle ++, --, !, unary - etc. */
|
|
|
|
|
2004-06-29 20:26:27 +00:00
|
|
|
void hie8 (ExprDesc* Expr);
|
|
|
|
/* Process + and - binary operators. */
|
|
|
|
|
2004-05-25 20:59:38 +00:00
|
|
|
void hie1 (ExprDesc* lval);
|
2000-05-28 13:40:48 +00:00
|
|
|
/* Parse first level of expression hierarchy. */
|
|
|
|
|
2004-06-29 20:26:27 +00:00
|
|
|
void hie0 (ExprDesc* Expr);
|
|
|
|
/* Parse comma operator. */
|
|
|
|
|
2000-05-28 13:40:48 +00:00
|
|
|
|
|
|
|
|
|
|
|
/* End of expr.h */
|
|
|
|
|
|
|
|
#endif
|