2001-12-08 20:40:50 +00:00
|
|
|
/*
|
2002-10-22 14:53:18 +00:00
|
|
|
expr.h
|
2001-12-08 20:40:50 +00:00
|
|
|
|
2002-10-22 14:53:18 +00:00
|
|
|
expression construction and manipulations
|
2001-12-08 20:40:50 +00:00
|
|
|
|
2002-10-22 14:53:18 +00:00
|
|
|
Copyright (C) 2001 Bill Currie <bill@taniwha.org>
|
2001-12-08 20:40:50 +00:00
|
|
|
|
2002-10-22 14:53:18 +00:00
|
|
|
Author: Bill Currie <bill@taniwha.org>
|
|
|
|
Date: 2001/06/15
|
2001-12-08 20:40:50 +00:00
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or
|
|
|
|
modify it under the terms of the GNU General Public License
|
|
|
|
as published by the Free Software Foundation; either version 2
|
|
|
|
of the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
|
|
|
|
See the GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to:
|
|
|
|
|
|
|
|
Free Software Foundation, Inc.
|
|
|
|
59 Temple Place - Suite 330
|
|
|
|
Boston, MA 02111-1307, USA
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __expr_h
|
|
|
|
#define __expr_h
|
|
|
|
|
2022-01-08 15:26:52 +00:00
|
|
|
#include "QF/progs/pr_comp.h"
|
2004-01-25 08:55:03 +00:00
|
|
|
|
2010-12-19 02:35:18 +00:00
|
|
|
/** \defgroup qfcc_expr Expressions
|
|
|
|
\ingroup qfcc
|
|
|
|
*/
|
2020-02-11 06:20:49 +00:00
|
|
|
///@{
|
2010-12-19 02:35:18 +00:00
|
|
|
|
|
|
|
/** Type of the exression node in an expression tree.
|
|
|
|
*/
|
2022-01-07 14:12:20 +00:00
|
|
|
#define EX_EXPR(expr) ex_##expr,
|
2001-06-20 07:02:36 +00:00
|
|
|
typedef enum {
|
2022-01-07 14:12:20 +00:00
|
|
|
#include "tools/qfcc/include/expr_names.h"
|
2021-06-27 05:53:08 +00:00
|
|
|
ex_count, ///< number of valid expression types
|
2001-06-20 07:02:36 +00:00
|
|
|
} expr_type;
|
2022-01-07 14:12:20 +00:00
|
|
|
#undef EX_EXPR
|
2001-06-20 07:02:36 +00:00
|
|
|
|
2010-12-19 02:35:18 +00:00
|
|
|
/** Binary and unary expressions.
|
|
|
|
|
|
|
|
This is used for both binary and unary expressions. Unary expressions do
|
|
|
|
not use e2. The opcode is generally the parser token for the expression,
|
|
|
|
though special codes are used for non-math expressions.
|
|
|
|
*/
|
|
|
|
typedef struct ex_expr_s {
|
|
|
|
int op; ///< op-code of this expression
|
|
|
|
struct type_s *type; ///< the type of the result of this expression
|
|
|
|
struct expr_s *e1; ///< left side of binary, sole of unary
|
|
|
|
struct expr_s *e2; ///< right side of binary, null for unary
|
|
|
|
} ex_expr_t;
|
|
|
|
|
2002-06-07 17:29:30 +00:00
|
|
|
typedef struct ex_label_s {
|
2012-11-03 09:08:32 +00:00
|
|
|
struct ex_label_s *next;
|
2010-12-19 02:35:18 +00:00
|
|
|
struct reloc_s *refs; ///< relocations associated with this label
|
2011-01-19 06:47:45 +00:00
|
|
|
struct sblock_s *dest; ///< the location of this label if known
|
2010-12-19 02:35:18 +00:00
|
|
|
const char *name; ///< the name of this label
|
2020-03-11 04:31:12 +00:00
|
|
|
struct symbol_s *symbol; ///< symbol used to define this label (maybe 0)
|
2011-03-03 06:28:49 +00:00
|
|
|
int used; ///< label is used as a target
|
2012-11-16 11:12:13 +00:00
|
|
|
struct daglabel_s *daglabel;
|
2002-05-11 03:37:36 +00:00
|
|
|
} ex_label_t;
|
2001-06-25 22:11:20 +00:00
|
|
|
|
2012-11-03 09:08:32 +00:00
|
|
|
typedef struct {
|
|
|
|
ex_label_t *label;
|
|
|
|
} ex_labelref_t;
|
|
|
|
|
2023-05-26 15:59:43 +00:00
|
|
|
typedef struct designator_s {
|
|
|
|
struct designator_s *next;
|
|
|
|
struct expr_s *field;
|
|
|
|
struct expr_s *index;
|
|
|
|
} designator_t;
|
|
|
|
|
2020-03-11 10:42:38 +00:00
|
|
|
typedef struct element_s {
|
|
|
|
struct element_s *next; ///< next in chain
|
|
|
|
int offset;
|
|
|
|
struct type_s *type;
|
2020-03-11 06:46:57 +00:00
|
|
|
struct expr_s *expr; ///< initializer expression
|
2023-05-26 15:59:43 +00:00
|
|
|
designator_t *designator; ///< for labeled initializers
|
2020-03-11 10:42:38 +00:00
|
|
|
} element_t;
|
2020-03-11 06:46:57 +00:00
|
|
|
|
2020-03-11 10:42:38 +00:00
|
|
|
typedef struct element_chain_s {
|
|
|
|
element_t *head;
|
|
|
|
element_t **tail;
|
|
|
|
} element_chain_t;
|
2020-03-11 06:46:57 +00:00
|
|
|
|
2001-06-26 03:33:01 +00:00
|
|
|
typedef struct {
|
2010-12-19 02:35:18 +00:00
|
|
|
struct expr_s *head; ///< the first expression in the block
|
|
|
|
struct expr_s **tail; ///< last expression in the block, for appending
|
|
|
|
struct expr_s *result; ///< the result of this block if non-void
|
|
|
|
int is_call; ///< this block exprssion forms a function call
|
2020-03-14 03:27:23 +00:00
|
|
|
void *return_addr;///< who allocated this
|
2002-05-11 03:37:36 +00:00
|
|
|
} ex_block_t;
|
2001-06-26 03:33:01 +00:00
|
|
|
|
2001-08-11 21:15:24 +00:00
|
|
|
typedef struct {
|
2011-01-21 02:26:43 +00:00
|
|
|
struct operand_s *op; ///< The operand for the temporary variable, if
|
2010-12-19 02:35:18 +00:00
|
|
|
///< allocated
|
|
|
|
struct type_s *type; ///< The type of the temporary variable.
|
2002-05-11 03:37:36 +00:00
|
|
|
} ex_temp_t;
|
2001-08-11 21:15:24 +00:00
|
|
|
|
2013-06-24 06:37:08 +00:00
|
|
|
typedef struct {
|
|
|
|
struct type_s *type; ///< Type of vector (vector/quaternion)
|
|
|
|
struct expr_s *list; ///< Linked list of element expressions.
|
|
|
|
} ex_vector_t;
|
|
|
|
|
2021-12-24 04:22:01 +00:00
|
|
|
typedef struct {
|
|
|
|
struct expr_s *sel_ref; ///< Reference to selector in selector table
|
|
|
|
struct selector_s *sel; ///< selector
|
|
|
|
} ex_selector_t;
|
|
|
|
|
2010-12-19 02:35:18 +00:00
|
|
|
/** Pointer constant expression.
|
|
|
|
|
|
|
|
Represent a pointer to an absolute address in data space.
|
|
|
|
*/
|
2011-02-08 05:45:48 +00:00
|
|
|
typedef struct ex_pointer_s {
|
2010-12-19 02:35:18 +00:00
|
|
|
int val;
|
2002-06-04 18:44:03 +00:00
|
|
|
struct type_s *type;
|
2002-07-14 03:41:13 +00:00
|
|
|
struct def_s *def;
|
2020-03-17 06:28:15 +00:00
|
|
|
struct operand_s *tempop;
|
2002-05-11 03:37:36 +00:00
|
|
|
} ex_pointer_t;
|
2001-12-12 08:39:47 +00:00
|
|
|
|
2012-11-21 01:06:15 +00:00
|
|
|
typedef struct ex_func_s {
|
|
|
|
int val;
|
|
|
|
struct type_s *type;
|
|
|
|
} ex_func_t;
|
|
|
|
|
2003-10-22 08:05:17 +00:00
|
|
|
typedef struct {
|
|
|
|
int size;
|
|
|
|
struct expr_s *e[1];
|
|
|
|
} ex_list_t;
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
ex_list_t *true_list;
|
|
|
|
ex_list_t *false_list;
|
|
|
|
struct expr_s *e;
|
|
|
|
} ex_bool_t;
|
|
|
|
|
2020-03-11 13:57:20 +00:00
|
|
|
typedef struct ex_memset_s {
|
|
|
|
struct expr_s *dst;
|
|
|
|
struct expr_s *val;
|
|
|
|
struct expr_s *count;
|
|
|
|
} ex_memset_t;
|
|
|
|
|
2010-12-19 02:35:18 +00:00
|
|
|
/** State expression used for think function state-machines.
|
|
|
|
|
|
|
|
State expressions are of the form <code>[framenum, nextthink]</code>
|
|
|
|
(standard) or <code>[framenum, nextthink, timestep]</code> (QF extension)
|
|
|
|
and come before the opening brace of the function. If the state
|
|
|
|
expression is of the former form, then \c step will be null. Normally,
|
|
|
|
\c framenum and \c nextthink must be constant (though \c nextthink may
|
|
|
|
be a forward reference), but qfcc allows both \c framenum and
|
|
|
|
\c nextthink, and also \c timestep, to be variable.
|
|
|
|
|
|
|
|
\par From qcc:
|
|
|
|
States are special functions made for convenience. They
|
|
|
|
automatically set frame, nextthink (implicitly), and think (allowing
|
|
|
|
forward definitions).
|
|
|
|
|
|
|
|
\verbatim
|
|
|
|
void() name = [framenum, nextthink] {code};
|
|
|
|
\endverbatim
|
|
|
|
expands to:
|
|
|
|
\verbatim
|
|
|
|
void name ()
|
|
|
|
{
|
|
|
|
self.frame=framenum;
|
|
|
|
self.nextthink = time + 0.1;
|
|
|
|
self.think = nextthink
|
|
|
|
[code]
|
|
|
|
};
|
|
|
|
\endverbatim
|
|
|
|
|
|
|
|
Although the above expansion shows three expressions, a state expression
|
|
|
|
using constant values is just one instruction: either
|
|
|
|
<code>state framenum, nextthink</code> (standard) or
|
|
|
|
<code>state.f framenum, nextthink, timestep</code> (QF, optional).
|
|
|
|
*/
|
2004-02-11 01:43:33 +00:00
|
|
|
typedef struct {
|
2010-12-19 02:35:18 +00:00
|
|
|
struct expr_s *frame; ///< the frame to which to change in this state
|
|
|
|
struct expr_s *think; ///< think function for the next state
|
|
|
|
struct expr_s *step; ///< time step until the next state
|
2004-02-11 01:43:33 +00:00
|
|
|
} ex_state_t;
|
|
|
|
|
2011-01-18 23:41:24 +00:00
|
|
|
typedef struct ex_value_s {
|
2012-07-18 14:01:09 +00:00
|
|
|
struct ex_value_s *next;
|
2012-07-19 01:42:05 +00:00
|
|
|
struct daglabel_s *daglabel;///< dag label for this value
|
2018-10-12 13:05:17 +00:00
|
|
|
struct type_s *type;
|
|
|
|
etype_t lltype;
|
2011-01-18 23:41:24 +00:00
|
|
|
union {
|
|
|
|
const char *string_val; ///< string constant
|
2020-02-14 11:08:59 +00:00
|
|
|
double double_val; ///< double constant
|
2022-01-05 13:32:07 +00:00
|
|
|
int64_t long_val; ///< signed 64-bit constant
|
|
|
|
uint64_t ulong_val; ///< unsigned 64-bit constant
|
2011-01-18 23:41:24 +00:00
|
|
|
float float_val; ///< float constant
|
|
|
|
float vector_val[3]; ///< vector constant
|
|
|
|
int entity_val; ///< entity constant
|
2012-11-21 01:06:15 +00:00
|
|
|
ex_func_t func_val; ///< function constant
|
2011-01-18 23:41:24 +00:00
|
|
|
ex_pointer_t pointer; ///< pointer constant
|
|
|
|
float quaternion_val[4]; ///< quaternion constant
|
2022-01-18 04:21:06 +00:00
|
|
|
int int_val; ///< int constant
|
|
|
|
unsigned uint_val; ///< unsigned int constant
|
2022-01-18 13:08:37 +00:00
|
|
|
int16_t short_val; ///< short constant
|
|
|
|
uint16_t ushort_val; ///< unsigned short constant
|
2022-04-27 12:36:15 +00:00
|
|
|
#define VEC_TYPE(type_name, base_type) pr_##type_name##_t type_name##_val;
|
|
|
|
#include "tools/qfcc/include/vec_types.h"
|
2011-01-18 23:41:24 +00:00
|
|
|
} v;
|
|
|
|
} ex_value_t;
|
|
|
|
|
2022-01-08 03:06:52 +00:00
|
|
|
typedef struct {
|
|
|
|
struct type_s *type; ///< type to view the expression
|
|
|
|
struct expr_s *expr; ///< the expression to alias
|
|
|
|
struct expr_s *offset; ///< offset for alias
|
|
|
|
} ex_alias_t;
|
|
|
|
|
2022-01-08 07:52:24 +00:00
|
|
|
typedef struct {
|
|
|
|
struct type_s *type; ///< pointer type
|
|
|
|
struct expr_s *lvalue; ///< the lvalue being addressed
|
|
|
|
struct expr_s *offset; ///< offset from the address
|
|
|
|
} ex_address_t;
|
|
|
|
|
2022-01-08 09:44:29 +00:00
|
|
|
typedef struct {
|
|
|
|
struct expr_s *dst; ///< destination of assignment
|
|
|
|
struct expr_s *src; ///< source of assignment
|
|
|
|
} ex_assign_t;
|
|
|
|
|
2022-01-09 05:02:16 +00:00
|
|
|
typedef struct {
|
|
|
|
pr_branch_e type; ///< type of branch
|
|
|
|
struct expr_s *target; ///< destination of branch
|
|
|
|
struct expr_s *index; ///< index for indirect branches
|
|
|
|
struct expr_s *test; ///< test expression (null for jump/call)
|
|
|
|
struct expr_s *args; ///< only for call
|
|
|
|
struct type_s *ret_type; ///< void for non-call
|
|
|
|
} ex_branch_t;
|
|
|
|
|
2022-01-09 07:28:08 +00:00
|
|
|
typedef struct {
|
|
|
|
struct expr_s *ret_val;
|
2022-02-05 09:58:42 +00:00
|
|
|
int at_return; ///< return void_return call through void
|
2022-01-09 07:28:08 +00:00
|
|
|
} ex_return_t;
|
|
|
|
|
2022-01-21 09:47:12 +00:00
|
|
|
typedef struct {
|
|
|
|
short mode; ///< currently must be 0
|
|
|
|
short offset; ///< amount by which stack will be adjusted
|
|
|
|
} ex_adjstk_t;
|
|
|
|
|
|
|
|
typedef struct {
|
2022-02-05 09:58:42 +00:00
|
|
|
short mode;
|
2022-01-21 09:47:12 +00:00
|
|
|
short reg; ///< base register to load
|
|
|
|
struct expr_s *with; ///< value to load
|
|
|
|
} ex_with_t;
|
|
|
|
|
2022-01-30 01:56:15 +00:00
|
|
|
typedef struct {
|
|
|
|
int op; ///< operation to perform
|
|
|
|
struct expr_s *vec; ///< vector expression on which to operate
|
|
|
|
struct type_s *type; ///< result type
|
|
|
|
} ex_horizontal_t;
|
|
|
|
|
2022-05-01 01:02:26 +00:00
|
|
|
//NOTE always operates on vec4 or dvec4, so needs a suitable destination and
|
|
|
|
//care must be taken when working with smaller source operands (check aligmnet
|
|
|
|
//and adjust swizzle operation as needed)
|
|
|
|
typedef struct {
|
|
|
|
struct expr_s *src; ///< source expression
|
|
|
|
unsigned source[4]; ///< src component indices
|
|
|
|
unsigned neg; ///< bitmask of dst components to negate
|
|
|
|
unsigned zero; ///< bitmask of dst components to 0
|
|
|
|
struct type_s *type; ///< result type
|
|
|
|
} ex_swizzle_t;
|
|
|
|
|
2022-08-18 08:46:14 +00:00
|
|
|
typedef struct {
|
|
|
|
struct expr_s *src; ///< source expression
|
|
|
|
int extend; ///< extend mode 0: 0, 1: 1, 2: copy/0 3:-1
|
2023-08-25 08:20:28 +00:00
|
|
|
bool reverse; ///< reverse resultant vector
|
2022-08-18 08:46:14 +00:00
|
|
|
struct type_s *type; ///< result type;
|
|
|
|
} ex_extend_t;
|
|
|
|
|
2023-08-21 08:37:56 +00:00
|
|
|
typedef struct {
|
[qfcc] Use scatter-gather for multivec expressions
This makes working with them much easier, and the type system reflects
what's in the multi-vector. Unfortunately, that does mean that large
algebras will wind up having a LOT of types, but it allows for efficient
storage of sparse multi-vectors:
auto v = 4*(e1 + e032 + e123);
results in:
0005 0213 1:0008<00000008>4:void 0:0000<00000000>?:invalid
0:0044<00000044>4:void assign (<void>), v
0006 0213 1:000c<0000000c>4:void 0:0000<00000000>?:invalid
0:0048<00000048>4:void assign (<void>), {v + 4}
Where the two source vectors are:
44:1 0 .imm float:18e [4, 0, 0, 0]
48:1 0 .imm float:1aa [4, 0, 0, 4]
They just happen to be adjacent, but don't need to be.
2023-08-22 15:03:56 +00:00
|
|
|
struct type_s *type; ///< overall type of multivector
|
2023-08-21 08:37:56 +00:00
|
|
|
struct algebra_s *algebra; ///< owning algebra
|
|
|
|
int count; ///< number of component expressions
|
|
|
|
struct expr_s *components; ///< multivector components
|
|
|
|
} ex_multivec_t;
|
|
|
|
|
2011-01-24 06:41:43 +00:00
|
|
|
#define POINTER_VAL(p) (((p).def ? (p).def->offset : 0) + (p).val)
|
2003-05-15 05:58:31 +00:00
|
|
|
|
2001-06-15 19:38:43 +00:00
|
|
|
typedef struct expr_s {
|
2010-12-19 02:35:18 +00:00
|
|
|
struct expr_s *next; ///< the next expression in a block expression
|
2020-02-23 13:27:07 +00:00
|
|
|
expr_type type; ///< the type of the result of this expression
|
|
|
|
int line; ///< source line that generated this expression
|
2022-01-18 03:11:14 +00:00
|
|
|
pr_string_t file; ///< source file that generated this expression
|
2011-01-20 05:00:41 +00:00
|
|
|
int printid; ///< avoid duplicate output when printing
|
2020-02-23 13:27:07 +00:00
|
|
|
unsigned paren:1; ///< the expression is enclosed in ()
|
|
|
|
unsigned rvalue:1; ///< the expression is on the right side of =
|
2020-02-23 13:28:54 +00:00
|
|
|
unsigned implicit:1; ///< don't warn for implicit casts
|
2001-06-15 19:38:43 +00:00
|
|
|
union {
|
2010-12-19 02:35:18 +00:00
|
|
|
ex_label_t label; ///< label expression
|
2012-11-03 09:08:32 +00:00
|
|
|
ex_labelref_t labelref; ///< label reference expression (&)
|
2010-12-19 02:35:18 +00:00
|
|
|
ex_state_t state; ///< state expression
|
2023-06-13 09:06:11 +00:00
|
|
|
ex_bool_t boolean; ///< boolean logic expression
|
2010-12-19 02:35:18 +00:00
|
|
|
ex_block_t block; ///< statement block expression
|
|
|
|
ex_expr_t expr; ///< binary or unary expression
|
2020-03-16 16:42:46 +00:00
|
|
|
struct def_s *def; ///< def reference expression
|
2011-01-13 05:54:24 +00:00
|
|
|
struct symbol_s *symbol; ///< symbol reference expression
|
2010-12-19 02:35:18 +00:00
|
|
|
ex_temp_t temp; ///< temporary variable expression
|
2013-06-24 06:37:08 +00:00
|
|
|
ex_vector_t vector; ///< vector expression list
|
2021-12-24 04:22:01 +00:00
|
|
|
ex_selector_t selector; ///< selector ref and name
|
2012-07-18 14:01:09 +00:00
|
|
|
ex_value_t *value; ///< constant value
|
2020-03-11 10:42:38 +00:00
|
|
|
element_chain_t compound; ///< compound initializer
|
2020-03-11 13:57:20 +00:00
|
|
|
ex_memset_t memset; ///< memset expr params
|
2022-01-08 03:06:52 +00:00
|
|
|
ex_alias_t alias; ///< alias expr params
|
2022-01-08 07:52:24 +00:00
|
|
|
ex_address_t address; ///< alias expr params
|
2022-01-08 09:44:29 +00:00
|
|
|
ex_assign_t assign; ///< assignment expr params
|
2022-01-09 05:02:16 +00:00
|
|
|
ex_branch_t branch; ///< branch expr params
|
2022-01-09 07:28:08 +00:00
|
|
|
ex_return_t retrn; ///< return expr params
|
2022-01-21 09:47:12 +00:00
|
|
|
ex_adjstk_t adjstk; ///< stack adjust param
|
|
|
|
ex_with_t with; ///< with expr param
|
2020-03-13 08:57:58 +00:00
|
|
|
struct type_s *nil; ///< type for nil if known
|
2022-01-30 01:56:15 +00:00
|
|
|
ex_horizontal_t hop; ///< horizontal vector operation
|
2022-05-01 01:02:26 +00:00
|
|
|
ex_swizzle_t swizzle; ///< vector swizzle operation
|
2022-08-18 08:46:14 +00:00
|
|
|
ex_extend_t extend; ///< vector extend operation
|
2023-08-21 08:37:56 +00:00
|
|
|
ex_multivec_t multivec; ///< geometric algebra multivector
|
2001-06-15 19:38:43 +00:00
|
|
|
} e;
|
|
|
|
} expr_t;
|
|
|
|
|
2018-10-12 05:50:55 +00:00
|
|
|
extern const char *expr_names[];
|
2001-07-26 05:15:34 +00:00
|
|
|
|
2010-12-19 02:35:18 +00:00
|
|
|
/** Report a type mismatch error.
|
|
|
|
|
|
|
|
\a e1 is used for reporting the file and line number of the error.
|
|
|
|
|
|
|
|
\param e1 Left side expression. Used for reporting the type.
|
|
|
|
\param e2 Right side expression. Used for reporting the type.
|
|
|
|
\param op The opcode of the expression.
|
|
|
|
\return \a e1 with its type set to ex_error.
|
|
|
|
*/
|
2004-01-25 08:55:03 +00:00
|
|
|
expr_t *type_mismatch (expr_t *e1, expr_t *e2, int op);
|
|
|
|
|
2011-01-09 10:41:24 +00:00
|
|
|
expr_t *param_mismatch (expr_t *e, int param, const char *fn,
|
|
|
|
struct type_s *t1, struct type_s *t2);
|
|
|
|
expr_t *test_error (expr_t *e, struct type_s *t);
|
|
|
|
|
2002-05-17 17:37:44 +00:00
|
|
|
extern expr_t *local_expr;
|
|
|
|
|
2010-12-19 02:35:18 +00:00
|
|
|
/** Get the type descriptor of the expression result.
|
|
|
|
|
|
|
|
\param e The expression from which to get the result type.
|
|
|
|
\return Pointer to the type description, or null if the expression
|
|
|
|
type (expr_t::type) is inappropriate.
|
|
|
|
*/
|
2020-03-13 10:58:07 +00:00
|
|
|
struct type_s *get_type (expr_t *e);
|
2010-12-19 02:35:18 +00:00
|
|
|
|
|
|
|
/** Get the basic type code of the expression result.
|
|
|
|
|
|
|
|
\param e The expression from which to get the result type.
|
|
|
|
\return Pointer to the type description, or ev_type_count if
|
|
|
|
get_type() returns null.
|
|
|
|
*/
|
2020-03-13 10:58:07 +00:00
|
|
|
etype_t extract_type (expr_t *e);
|
2001-07-26 05:15:34 +00:00
|
|
|
|
2010-12-19 02:35:18 +00:00
|
|
|
/** Create a new expression node.
|
|
|
|
|
|
|
|
Sets the source file and line number information. The expression node is
|
|
|
|
otherwise raw. This function is generally not used directly.
|
|
|
|
|
|
|
|
\return The new expression node.
|
|
|
|
*/
|
2001-06-15 19:38:43 +00:00
|
|
|
expr_t *new_expr (void);
|
2002-09-11 16:21:26 +00:00
|
|
|
|
2011-01-11 03:05:29 +00:00
|
|
|
/** Create a deep copy of an expression tree.
|
|
|
|
|
|
|
|
\param e The root of the expression tree to copy.
|
|
|
|
\return A new expression tree giving the same expression.
|
|
|
|
*/
|
|
|
|
expr_t *copy_expr (expr_t *e);
|
|
|
|
|
2020-03-10 16:52:45 +00:00
|
|
|
/** Copy source expression's file and line to the destination expression
|
|
|
|
|
|
|
|
\param dst The expression to receive the file and line
|
|
|
|
\param src The expression from which the file and line will be taken
|
|
|
|
\return \a dst
|
|
|
|
*/
|
|
|
|
expr_t *expr_file_line (expr_t *dst, const expr_t *src);
|
|
|
|
|
2010-12-19 02:35:18 +00:00
|
|
|
/** Create a new label name.
|
|
|
|
|
2020-03-11 01:49:49 +00:00
|
|
|
The label name is guaranteed to be unique to the compilation. It is made
|
|
|
|
up of the name of the current function plus an incrementing number. The
|
|
|
|
number is not reset between functions.
|
2010-12-19 02:35:18 +00:00
|
|
|
|
|
|
|
\return The string representing the label name.
|
|
|
|
*/
|
2001-11-13 08:58:54 +00:00
|
|
|
const char *new_label_name (void);
|
2002-09-11 16:21:26 +00:00
|
|
|
|
2010-12-19 02:35:18 +00:00
|
|
|
/** Create a new label expression node.
|
|
|
|
|
2012-11-03 09:08:32 +00:00
|
|
|
The label name is set using new_label_name().
|
2010-12-19 02:35:18 +00:00
|
|
|
|
|
|
|
\return The new label expression (::ex_label_t) node.
|
|
|
|
*/
|
2001-06-26 02:46:02 +00:00
|
|
|
expr_t *new_label_expr (void);
|
2010-12-19 02:35:18 +00:00
|
|
|
|
2020-03-11 02:31:54 +00:00
|
|
|
/** Create a named label expression node.
|
|
|
|
|
|
|
|
The label name is set using new_label_name(), but the symbol is used to add
|
|
|
|
the label to the function's label scope symbol table. If the label already
|
|
|
|
exists in the function's label scope, then the existing label is returned,
|
|
|
|
allowing for forward label declarations.
|
|
|
|
|
|
|
|
\param label The name symbol to use for adding the label to the function
|
|
|
|
label scope.
|
|
|
|
\return The new label expression (::ex_label_t) node.
|
|
|
|
*/
|
|
|
|
expr_t *named_label_expr (struct symbol_s *label);
|
|
|
|
|
2012-11-03 09:08:32 +00:00
|
|
|
/** Create a new label reference expression node.
|
|
|
|
|
|
|
|
Used for taking the address of a label (eg. jump tables).
|
|
|
|
The label's \a used field is incremented.
|
|
|
|
|
|
|
|
\return The new label reference expression (::ex_labelref_t) node.
|
|
|
|
*/
|
|
|
|
expr_t *new_label_ref (ex_label_t *label);
|
|
|
|
|
2010-12-19 02:35:18 +00:00
|
|
|
/** Create a new state expression node.
|
|
|
|
|
|
|
|
The label name is set using new_label_name(), and the label is linked
|
|
|
|
into the global list of labels for later resolution.
|
|
|
|
|
|
|
|
\param frame The expression giving the frame number.
|
|
|
|
\param think The expression giving the think function.
|
|
|
|
\param step The expression giving the time step value, or null if
|
|
|
|
no time-step is specified (standard form).
|
|
|
|
\return The new state expression (::ex_state_t) node.
|
|
|
|
*/
|
2004-02-11 01:43:33 +00:00
|
|
|
expr_t *new_state_expr (expr_t *frame, expr_t *think, expr_t *step);
|
2010-12-19 02:35:18 +00:00
|
|
|
|
2003-10-22 08:05:17 +00:00
|
|
|
expr_t *new_bool_expr (ex_list_t *true_list, ex_list_t *false_list, expr_t *e);
|
2010-12-19 02:35:18 +00:00
|
|
|
|
|
|
|
/** Create a new statement block expression node.
|
|
|
|
|
|
|
|
The returned block expression is empty. Use append_expr() to add
|
|
|
|
expressions to the block expression.
|
|
|
|
|
|
|
|
\return The new block expression (::ex_block_t) node.
|
|
|
|
*/
|
2001-06-26 03:33:01 +00:00
|
|
|
expr_t *new_block_expr (void);
|
2010-12-19 02:35:18 +00:00
|
|
|
|
2019-06-09 04:54:03 +00:00
|
|
|
/** Create a new statement block expression node from an expression list
|
|
|
|
|
|
|
|
The returned block holds the expression list in reverse order. This makes
|
|
|
|
it easy to build the list in a parser.
|
|
|
|
|
|
|
|
\param expr_list The expression list to convert to an expression block.
|
|
|
|
Note that the evaluation order will be reversed.
|
|
|
|
\return The new block expression (::ex_block_t) node.
|
|
|
|
*/
|
|
|
|
expr_t *build_block_expr (expr_t *expr_list);
|
|
|
|
|
2023-05-26 15:59:43 +00:00
|
|
|
designator_t *new_designator (expr_t *field, expr_t *index);
|
|
|
|
element_t *new_element (expr_t *expr, designator_t *designator);
|
2020-03-11 06:46:57 +00:00
|
|
|
expr_t *new_compound_init (void);
|
2020-03-11 10:42:38 +00:00
|
|
|
expr_t *append_element (expr_t *compound, element_t *element);
|
2020-03-28 03:10:23 +00:00
|
|
|
expr_t *initialized_temp_expr (const struct type_s *type, expr_t *compound);
|
2020-03-11 10:42:38 +00:00
|
|
|
void assign_elements (expr_t *local_expr, expr_t *ptr,
|
|
|
|
element_chain_t *element_chain);
|
2020-03-28 03:10:23 +00:00
|
|
|
void build_element_chain (element_chain_t *element_chain,
|
|
|
|
const struct type_s *type,
|
2020-03-11 10:42:38 +00:00
|
|
|
expr_t *eles, int base_offset);
|
|
|
|
void free_element_chain (element_chain_t *element_chain);
|
2020-03-11 06:46:57 +00:00
|
|
|
|
2022-01-30 01:56:15 +00:00
|
|
|
/** Create a new binary expression node.
|
2010-12-19 02:35:18 +00:00
|
|
|
|
|
|
|
If either \a e1 or \a e2 are error expressions, then that expression will
|
|
|
|
be returned instead of a new binary expression.
|
|
|
|
|
|
|
|
\param op The op-ccode of the binary expression.
|
|
|
|
\param e1 The left side of the binary expression.
|
|
|
|
\param e2 The right side of the binary expression.
|
|
|
|
\return The new binary expression node (::ex_expr_t) if neither
|
|
|
|
\a e1 nor \a e2 are error expressions, otherwise the
|
|
|
|
expression that is an error expression.
|
|
|
|
*/
|
2001-06-26 02:46:02 +00:00
|
|
|
expr_t *new_binary_expr (int op, expr_t *e1, expr_t *e2);
|
2010-12-19 02:35:18 +00:00
|
|
|
|
2022-01-30 01:56:15 +00:00
|
|
|
/** Create a new unary expression node.
|
2010-12-19 02:35:18 +00:00
|
|
|
|
|
|
|
If \a e1 is an error expression, then it will be returned instead of a
|
2020-03-14 10:26:47 +00:00
|
|
|
new unary expression.
|
2010-12-19 02:35:18 +00:00
|
|
|
|
|
|
|
\param op The op-code of the unary expression.
|
|
|
|
\param e1 The "right" side of the expression.
|
|
|
|
\return The new unary expression node (::ex_expr_t) if \a e1
|
|
|
|
is not an error expression, otherwise \a e1.
|
|
|
|
*/
|
2001-06-26 02:46:02 +00:00
|
|
|
expr_t *new_unary_expr (int op, expr_t *e1);
|
2010-12-19 02:35:18 +00:00
|
|
|
|
2022-01-30 01:56:15 +00:00
|
|
|
/** Create a new horizontal vector operantion node.
|
|
|
|
|
|
|
|
If \a vec is an error expression, then it will be returned instead of a
|
|
|
|
new unary expression.
|
|
|
|
|
|
|
|
\param op The op-code of the horizontal operation.
|
|
|
|
\param vec The expression (must be a vector type) on which to operate.
|
|
|
|
\param type The result type (must be scalar type)
|
|
|
|
\return The new unary expression node (::ex_expr_t) if \a e1
|
|
|
|
is not an error expression, otherwise \a e1.
|
|
|
|
*/
|
|
|
|
expr_t *new_horizontal_expr (int op, expr_t *vec, struct type_s *type);
|
|
|
|
|
2022-05-01 01:02:26 +00:00
|
|
|
expr_t *new_swizzle_expr (expr_t *src, const char *swizzle);
|
|
|
|
|
2023-08-25 08:20:28 +00:00
|
|
|
expr_t *new_extend_expr (expr_t *src, struct type_s *type, int ext, bool rev);
|
2022-08-18 08:46:14 +00:00
|
|
|
|
2020-03-16 16:42:46 +00:00
|
|
|
/** Create a new def reference (non-temporary variable) expression node.
|
|
|
|
|
|
|
|
\return The new def reference expression node (::def_t).
|
|
|
|
*/
|
|
|
|
expr_t *new_def_expr (struct def_s *def);
|
|
|
|
|
2011-01-13 05:54:24 +00:00
|
|
|
/** Create a new symbol reference (non-temporary variable) expression node.
|
|
|
|
|
|
|
|
\return The new symbol reference expression node (::symbol_t).
|
|
|
|
*/
|
|
|
|
expr_t *new_symbol_expr (struct symbol_s *symbol);
|
|
|
|
|
2010-12-19 02:35:18 +00:00
|
|
|
/** Create a new temporary variable expression node.
|
|
|
|
|
|
|
|
Does not allocate a new temporary variable.
|
|
|
|
The ex_temp_t::users field will be 0.
|
|
|
|
|
|
|
|
\param type The type of the temporary variable.
|
|
|
|
\return The new temporary variable expression node (ex_temp_t).
|
|
|
|
*/
|
2020-03-28 03:10:23 +00:00
|
|
|
expr_t *new_temp_def_expr (const struct type_s *type);
|
2010-12-19 02:35:18 +00:00
|
|
|
|
|
|
|
/** Create a new nil expression node.
|
|
|
|
|
|
|
|
nil represents 0 of any type.
|
|
|
|
|
|
|
|
\return The new nil expression node.
|
|
|
|
*/
|
2002-09-11 16:21:26 +00:00
|
|
|
expr_t *new_nil_expr (void);
|
2010-12-19 02:35:18 +00:00
|
|
|
|
2022-01-24 09:35:16 +00:00
|
|
|
/** Create a new args expression node
|
|
|
|
|
|
|
|
Marker between real parameters and those passed through ...
|
|
|
|
|
|
|
|
\return The new args expression node.
|
|
|
|
*/
|
|
|
|
expr_t *new_args_expr (void);
|
|
|
|
|
2012-12-23 10:29:50 +00:00
|
|
|
/** Create a new value expression node.
|
|
|
|
|
|
|
|
\param value The value to put in the expression node.
|
|
|
|
\return The new value expression.
|
|
|
|
*/
|
|
|
|
expr_t *new_value_expr (ex_value_t *value);
|
|
|
|
|
2023-08-23 06:27:55 +00:00
|
|
|
/** Create a new typed zero value expression node.
|
|
|
|
|
|
|
|
Similar to new_nil_expr, but is 0 of a specific type.
|
|
|
|
|
|
|
|
\param type The type to use for the zero.
|
|
|
|
\return The new value expression.
|
|
|
|
*/
|
|
|
|
expr_t *new_zero_expr (struct type_s *type);
|
|
|
|
|
2011-01-17 13:33:33 +00:00
|
|
|
/** Create a new symbol expression node from a name.
|
2010-12-19 02:35:18 +00:00
|
|
|
|
2011-01-17 13:33:33 +00:00
|
|
|
\param name The name for the symbol.
|
|
|
|
\return The new symbol expression.
|
2010-12-19 02:35:18 +00:00
|
|
|
*/
|
2002-01-21 19:03:29 +00:00
|
|
|
expr_t *new_name_expr (const char *name);
|
2002-09-11 16:21:26 +00:00
|
|
|
|
2023-09-10 04:13:49 +00:00
|
|
|
struct symbol_s *get_name (expr_t *e) __attribute__((pure));
|
|
|
|
|
2010-12-19 02:35:18 +00:00
|
|
|
/** Create a new string constant expression node.
|
|
|
|
|
|
|
|
\param string_val The string constant being represented.
|
|
|
|
\return The new string constant expression node
|
|
|
|
(expr_t::e::string_val).
|
|
|
|
*/
|
2002-09-11 16:21:26 +00:00
|
|
|
expr_t *new_string_expr (const char *string_val);
|
2018-10-09 03:35:01 +00:00
|
|
|
const char *expr_string (expr_t *e) __attribute__((pure));
|
2010-12-19 02:35:18 +00:00
|
|
|
|
2020-02-14 07:38:37 +00:00
|
|
|
/** Create a new double constant expression node.
|
|
|
|
|
|
|
|
\param double_val The double constant being represented.
|
|
|
|
\return The new double constant expression node
|
|
|
|
(expr_t::e::double_val).
|
|
|
|
*/
|
|
|
|
expr_t *new_double_expr (double double_val);
|
|
|
|
double expr_double (expr_t *e) __attribute__((pure));
|
|
|
|
|
2010-12-19 02:35:18 +00:00
|
|
|
/** Create a new float constant expression node.
|
|
|
|
|
|
|
|
\param float_val The float constant being represented.
|
|
|
|
\return The new float constant expression node
|
|
|
|
(expr_t::e::float_val).
|
|
|
|
*/
|
2002-09-11 16:21:26 +00:00
|
|
|
expr_t *new_float_expr (float float_val);
|
2018-10-09 03:35:01 +00:00
|
|
|
float expr_float (expr_t *e) __attribute__((pure));
|
2010-12-19 02:35:18 +00:00
|
|
|
|
|
|
|
/** Create a new vector constant expression node.
|
|
|
|
|
|
|
|
\param vector_val The vector constant being represented.
|
|
|
|
\return The new vector constant expression node
|
|
|
|
(expr_t::e::vector_val).
|
|
|
|
*/
|
2011-01-10 23:43:34 +00:00
|
|
|
expr_t *new_vector_expr (const float *vector_val);
|
2018-10-09 03:35:01 +00:00
|
|
|
const float *expr_vector (expr_t *e) __attribute__((pure));
|
2013-06-24 06:37:08 +00:00
|
|
|
expr_t *new_vector_list (expr_t *e);
|
2010-12-19 02:35:18 +00:00
|
|
|
|
|
|
|
/** Create a new entity constant expression node.
|
|
|
|
|
|
|
|
\param entity_val The entity constant being represented.
|
|
|
|
\return The new entity constant expression node
|
|
|
|
(expr_t::e::entity_val).
|
|
|
|
*/
|
2002-09-11 16:21:26 +00:00
|
|
|
expr_t *new_entity_expr (int entity_val);
|
2010-12-19 02:35:18 +00:00
|
|
|
|
|
|
|
/** Create a new field constant expression node.
|
|
|
|
|
2019-06-08 10:22:29 +00:00
|
|
|
\param field_val offset? XXX
|
2010-12-19 02:35:18 +00:00
|
|
|
\param type The type of the field.
|
|
|
|
\param def
|
|
|
|
\return The new field constant expression node
|
|
|
|
(expr_t::e::field_val).
|
|
|
|
*/
|
2004-11-12 10:49:00 +00:00
|
|
|
expr_t *new_field_expr (int field_val, struct type_s *type, struct def_s *def);
|
2023-09-09 14:08:38 +00:00
|
|
|
struct symbol_s *get_struct_field (const struct type_s *t1, expr_t *e1,
|
|
|
|
expr_t *e2);
|
2010-12-19 02:35:18 +00:00
|
|
|
|
|
|
|
/** Create a new function constant expression node.
|
|
|
|
|
|
|
|
\param func_val The function constant being represented.
|
2012-11-21 01:06:15 +00:00
|
|
|
\param type The type of the function
|
2010-12-19 02:35:18 +00:00
|
|
|
\return The new function constant expression node
|
|
|
|
(expr_t::e::func_val).
|
|
|
|
*/
|
2012-11-21 01:06:15 +00:00
|
|
|
expr_t *new_func_expr (int func_val, struct type_s *type);
|
2010-12-19 02:35:18 +00:00
|
|
|
|
|
|
|
/** Create a new pointer constant expression node.
|
|
|
|
|
|
|
|
\param val The pointer constant (address) being represented. XXX
|
|
|
|
\param type The type of the referenced value.
|
|
|
|
\param def
|
|
|
|
\return The new pointer constant expression node
|
|
|
|
(expr_t::e::pointer_val).
|
|
|
|
*/
|
2004-04-09 04:12:44 +00:00
|
|
|
expr_t *new_pointer_expr (int val, struct type_s *type, struct def_s *def);
|
2010-12-19 02:35:18 +00:00
|
|
|
|
|
|
|
/** Create a new quaternion constant expression node.
|
|
|
|
|
|
|
|
\param quaternion_val The quaternion constant being represented.
|
|
|
|
\return The new quaternion constant expression node
|
|
|
|
(expr_t::e::quaternion_val).
|
|
|
|
*/
|
2011-01-10 23:43:34 +00:00
|
|
|
expr_t *new_quaternion_expr (const float *quaternion_val);
|
2018-10-09 03:35:01 +00:00
|
|
|
const float *expr_quaternion (expr_t *e) __attribute__((pure));
|
2010-12-19 02:35:18 +00:00
|
|
|
|
2022-01-18 04:21:06 +00:00
|
|
|
/** Create a new itn constant expression node.
|
2010-12-19 02:35:18 +00:00
|
|
|
|
2022-01-18 04:21:06 +00:00
|
|
|
\param int_val The int constant being represented.
|
|
|
|
\return The new int constant expression node
|
|
|
|
(expr_t::e::int_val).
|
2010-12-19 02:35:18 +00:00
|
|
|
*/
|
2022-01-18 04:21:06 +00:00
|
|
|
expr_t *new_int_expr (int int_val);
|
|
|
|
int expr_int (expr_t *e) __attribute__((pure));
|
2010-12-19 02:35:18 +00:00
|
|
|
|
2022-01-18 04:21:06 +00:00
|
|
|
/** Create a new int constant expression node.
|
2011-04-09 01:07:47 +00:00
|
|
|
|
2022-01-18 04:21:06 +00:00
|
|
|
\param uint_val The int constant being represented.
|
|
|
|
\return The new int constant expression node
|
|
|
|
(expr_t::e::int_val).
|
2011-04-09 01:07:47 +00:00
|
|
|
*/
|
2022-01-18 04:21:06 +00:00
|
|
|
expr_t *new_uint_expr (unsigned uint_val);
|
|
|
|
unsigned expr_uint (expr_t *e) __attribute__((pure));
|
2011-04-09 01:07:47 +00:00
|
|
|
|
2022-04-29 06:38:55 +00:00
|
|
|
expr_t *new_long_expr (pr_long_t long_val);
|
|
|
|
expr_t *new_ulong_expr (pr_ulong_t ulong_val);
|
|
|
|
|
2010-12-19 02:35:18 +00:00
|
|
|
/** Create a new short constant expression node.
|
|
|
|
|
|
|
|
\param short_val The short constant being represented.
|
|
|
|
\return The new short constant expression node
|
|
|
|
(expr_t::e::short_val).
|
|
|
|
*/
|
2002-09-11 16:21:26 +00:00
|
|
|
expr_t *new_short_expr (short short_val);
|
2018-10-09 03:35:01 +00:00
|
|
|
short expr_short (expr_t *e) __attribute__((pure));
|
2022-04-27 12:36:15 +00:00
|
|
|
unsigned short expr_ushort (expr_t *e) __attribute__((pure));
|
2002-09-11 16:21:26 +00:00
|
|
|
|
2020-03-17 02:07:50 +00:00
|
|
|
int expr_integral (expr_t *e) __attribute__((pure));
|
|
|
|
|
2021-06-27 05:53:08 +00:00
|
|
|
/** Check if the expression refers to a constant value.
|
2010-12-19 02:35:18 +00:00
|
|
|
|
|
|
|
\param e The expression to check.
|
|
|
|
\return True if the expression is constant.
|
|
|
|
*/
|
2018-10-09 03:35:01 +00:00
|
|
|
int is_constant (expr_t *e) __attribute__((pure));
|
2010-12-19 02:35:18 +00:00
|
|
|
|
2022-01-29 09:24:16 +00:00
|
|
|
/** Check if the expression refers to a variable.
|
|
|
|
|
|
|
|
\param e The expression to check.
|
|
|
|
\return True if the expression refers to a variable (def
|
|
|
|
expression, var symbol expression, or temp expression).
|
|
|
|
*/
|
|
|
|
int is_variable (expr_t *e) __attribute__((pure));
|
|
|
|
|
2021-12-24 04:58:16 +00:00
|
|
|
/** Check if the expression refers to a selector
|
|
|
|
|
|
|
|
\param e The expression to check.
|
|
|
|
\return True if the expression is a selector.
|
|
|
|
*/
|
|
|
|
int is_selector (expr_t *e) __attribute__((pure));
|
|
|
|
|
2011-02-15 00:28:27 +00:00
|
|
|
/** Return a value expression representing the constant stored in \a e.
|
|
|
|
|
|
|
|
If \a e does not represent a constant, or \a e is already a value or
|
|
|
|
nil expression, then \a e is returned rather than a new expression.
|
|
|
|
|
|
|
|
\param e The expression from which to extract the value.
|
|
|
|
\return A new expression holding the value of \a e or \e itself.
|
|
|
|
*/
|
|
|
|
expr_t *constant_expr (expr_t *e);
|
|
|
|
|
2010-12-19 02:35:18 +00:00
|
|
|
/** Check if the op-code is a comparison.
|
|
|
|
|
|
|
|
\param op The op-code to check.
|
|
|
|
\return True if the op-code is a comparison operator.
|
|
|
|
*/
|
2018-10-09 03:35:01 +00:00
|
|
|
int is_compare (int op) __attribute__((const));
|
2010-12-19 02:35:18 +00:00
|
|
|
|
|
|
|
/** Check if the op-code is a math operator.
|
|
|
|
|
|
|
|
\param op The op-code to check.
|
|
|
|
\return True if the op-code is a math operator.
|
|
|
|
*/
|
2018-10-09 03:35:01 +00:00
|
|
|
int is_math_op (int op) __attribute__((const));
|
2010-12-19 02:35:18 +00:00
|
|
|
|
|
|
|
/** Check if the op-code is a logic operator.
|
|
|
|
|
|
|
|
\param op The op-code to check.
|
|
|
|
\return True if the op-code is a logic operator.
|
|
|
|
*/
|
2018-10-09 03:35:01 +00:00
|
|
|
int is_logic (int op) __attribute__((const));
|
2010-12-19 02:35:18 +00:00
|
|
|
|
2018-10-09 03:35:01 +00:00
|
|
|
int has_function_call (expr_t *e) __attribute__((pure));
|
2022-01-21 04:09:23 +00:00
|
|
|
int is_function_call (expr_t *e) __attribute__((pure));
|
2013-09-27 14:07:38 +00:00
|
|
|
|
2020-03-11 13:57:48 +00:00
|
|
|
int is_nil (expr_t *e) __attribute__((pure));
|
2018-10-09 03:35:01 +00:00
|
|
|
int is_string_val (expr_t *e) __attribute__((pure));
|
|
|
|
int is_float_val (expr_t *e) __attribute__((pure));
|
|
|
|
int is_vector_val (expr_t *e) __attribute__((pure));
|
|
|
|
int is_quaternion_val (expr_t *e) __attribute__((pure));
|
2022-01-18 04:21:06 +00:00
|
|
|
int is_int_val (expr_t *e) __attribute__((pure));
|
|
|
|
int is_uint_val (expr_t *e) __attribute__((pure));
|
2018-10-09 03:35:01 +00:00
|
|
|
int is_short_val (expr_t *e) __attribute__((pure));
|
2020-03-17 02:07:50 +00:00
|
|
|
int is_integral_val (expr_t *e) __attribute__((pure));
|
2020-03-17 02:19:12 +00:00
|
|
|
int is_pointer_val (expr_t *e) __attribute__((pure));
|
2023-08-21 03:32:17 +00:00
|
|
|
int is_math_val (expr_t *e) __attribute__((pure));
|
2011-01-18 23:41:24 +00:00
|
|
|
|
2010-12-30 07:05:06 +00:00
|
|
|
/** Create a reference to the global <code>.self</code> entity variable.
|
|
|
|
|
2011-01-03 07:19:05 +00:00
|
|
|
This is used for <code>\@self</code>.
|
2010-12-30 07:05:06 +00:00
|
|
|
\return A new expression referencing the <code>.self</code> def.
|
|
|
|
*/
|
2002-05-18 00:30:14 +00:00
|
|
|
expr_t *new_self_expr (void);
|
2010-12-30 07:05:06 +00:00
|
|
|
|
|
|
|
/** Create a reference to the <code>.this</code> entity field.
|
|
|
|
|
2011-01-03 07:19:05 +00:00
|
|
|
This is used for <code>\@this</code>.
|
2010-12-30 07:05:06 +00:00
|
|
|
\return A new expression referencing the <code>.this</code> def.
|
|
|
|
*/
|
2002-05-31 16:58:42 +00:00
|
|
|
expr_t *new_this_expr (void);
|
2010-12-30 07:05:06 +00:00
|
|
|
|
|
|
|
/** Create an expression of the correct type that references the return slot.
|
|
|
|
|
|
|
|
\param type The type of the reference to the return slot.
|
|
|
|
\return A new expression referencing the return slot.
|
|
|
|
*/
|
2003-04-22 15:29:32 +00:00
|
|
|
expr_t *new_ret_expr (struct type_s *type);
|
2010-12-30 07:05:06 +00:00
|
|
|
|
2011-03-03 02:06:10 +00:00
|
|
|
expr_t *new_alias_expr (struct type_s *type, expr_t *expr);
|
2019-06-10 09:13:28 +00:00
|
|
|
expr_t *new_offset_alias_expr (struct type_s *type, expr_t *expr, int offset);
|
2011-03-03 02:06:10 +00:00
|
|
|
|
2022-01-08 07:52:24 +00:00
|
|
|
expr_t *new_address_expr (struct type_s *lvtype, expr_t *lvalue,
|
|
|
|
expr_t *offset);
|
2022-01-08 09:44:29 +00:00
|
|
|
expr_t *new_assign_expr (expr_t *dst, expr_t *src);
|
2022-01-09 07:28:08 +00:00
|
|
|
expr_t *new_return_expr (expr_t *ret_val);
|
2022-01-21 09:47:12 +00:00
|
|
|
expr_t *new_adjstk_expr (int mode, int offset);
|
|
|
|
expr_t *new_with_expr (int mode, int reg, expr_t *val);
|
2022-01-08 07:52:24 +00:00
|
|
|
|
2010-12-30 07:05:06 +00:00
|
|
|
/** Create an expression of the correct type that references the specified
|
|
|
|
parameter slot.
|
|
|
|
|
|
|
|
\param type The type of the reference to the parameter slot.
|
|
|
|
\param num The index of the parameter (0-7).
|
|
|
|
\return A new expression referencing the parameter slot.
|
|
|
|
*/
|
2003-04-22 15:29:32 +00:00
|
|
|
expr_t *new_param_expr (struct type_s *type, int num);
|
2010-12-30 07:05:06 +00:00
|
|
|
|
2023-05-26 12:56:19 +00:00
|
|
|
expr_t *new_memset_expr (expr_t *dst, expr_t *val, expr_t *count);
|
|
|
|
|
2011-02-05 13:32:23 +00:00
|
|
|
/** Convert a name to an expression of the appropriate type.
|
|
|
|
|
|
|
|
Converts the expression in-place. If the exprssion is not a name
|
|
|
|
expression (ex_name), no converision takes place.
|
|
|
|
|
|
|
|
\param e The expression to convert.
|
|
|
|
*/
|
|
|
|
void convert_name (expr_t *e);
|
|
|
|
|
2001-06-26 03:33:01 +00:00
|
|
|
expr_t *append_expr (expr_t *block, expr_t *e);
|
2022-01-24 09:35:16 +00:00
|
|
|
expr_t *prepend_expr (expr_t *block, expr_t *e);
|
2001-06-26 03:33:01 +00:00
|
|
|
|
2013-06-24 02:36:52 +00:00
|
|
|
expr_t *reverse_expr_list (expr_t *e);
|
2001-06-25 17:15:56 +00:00
|
|
|
void print_expr (expr_t *e);
|
2012-11-19 03:14:02 +00:00
|
|
|
void dump_dot_expr (void *e, const char *filename);
|
2001-07-24 22:30:31 +00:00
|
|
|
|
2020-02-27 11:30:07 +00:00
|
|
|
expr_t *convert_nil (expr_t *e, struct type_s *t);
|
2001-07-24 23:53:35 +00:00
|
|
|
|
2011-01-26 23:31:51 +00:00
|
|
|
expr_t *test_expr (expr_t *e);
|
2003-10-22 08:05:17 +00:00
|
|
|
void backpatch (ex_list_t *list, expr_t *label);
|
|
|
|
expr_t *convert_bool (expr_t *e, int block);
|
2013-09-27 08:41:20 +00:00
|
|
|
expr_t *convert_from_bool (expr_t *e, struct type_s *type);
|
2003-10-22 08:05:17 +00:00
|
|
|
expr_t *bool_expr (int op, expr_t *label, expr_t *e1, expr_t *e2);
|
2001-06-20 07:02:36 +00:00
|
|
|
expr_t *binary_expr (int op, expr_t *e1, expr_t *e2);
|
2013-09-27 08:43:33 +00:00
|
|
|
expr_t *field_expr (expr_t *e1, expr_t *e2);
|
2001-08-10 16:17:00 +00:00
|
|
|
expr_t *asx_expr (int op, expr_t *e1, expr_t *e2);
|
2001-06-20 07:02:36 +00:00
|
|
|
expr_t *unary_expr (int op, expr_t *e);
|
2023-09-14 09:25:29 +00:00
|
|
|
void vararg_integer (expr_t *e);
|
2020-02-19 12:28:32 +00:00
|
|
|
expr_t *build_function_call (expr_t *fexpr, const struct type_s *ftype,
|
2004-11-13 11:50:00 +00:00
|
|
|
expr_t *params);
|
2001-06-20 21:18:04 +00:00
|
|
|
expr_t *function_expr (expr_t *e1, expr_t *e2);
|
2002-06-04 18:44:03 +00:00
|
|
|
struct function_s;
|
2011-03-03 06:28:49 +00:00
|
|
|
expr_t *branch_expr (int op, expr_t *test, expr_t *label);
|
|
|
|
expr_t *goto_expr (expr_t *label);
|
2022-01-09 05:02:16 +00:00
|
|
|
expr_t *jump_table_expr (expr_t *table, expr_t *index);
|
|
|
|
expr_t *call_expr (expr_t *func, expr_t *args, struct type_s *ret_type);
|
2002-06-04 18:44:03 +00:00
|
|
|
expr_t *return_expr (struct function_s *f, expr_t *e);
|
2022-02-05 09:58:42 +00:00
|
|
|
expr_t *at_return_expr (struct function_s *f, expr_t *e);
|
2001-08-11 21:15:24 +00:00
|
|
|
expr_t *conditional_expr (expr_t *cond, expr_t *e1, expr_t *e2);
|
2001-08-20 06:22:28 +00:00
|
|
|
expr_t *incop_expr (int op, expr_t *e, int postop);
|
2001-11-15 00:46:36 +00:00
|
|
|
expr_t *array_expr (expr_t *array, expr_t *index);
|
2022-01-25 03:28:53 +00:00
|
|
|
expr_t *deref_pointer_expr (expr_t *pointer);
|
2022-01-25 14:39:17 +00:00
|
|
|
expr_t *offset_pointer_expr (expr_t *pointer, expr_t *offset);
|
|
|
|
expr_t *address_expr (expr_t *e1, struct type_s *t);
|
2012-12-20 01:02:00 +00:00
|
|
|
expr_t *build_if_statement (int not, expr_t *test, expr_t *s1, expr_t *els,
|
|
|
|
expr_t *s2);
|
2013-06-25 01:46:51 +00:00
|
|
|
expr_t *build_while_statement (int not, expr_t *test, expr_t *statement,
|
2011-01-17 13:33:33 +00:00
|
|
|
expr_t *break_label, expr_t *continue_label);
|
2013-06-25 01:46:51 +00:00
|
|
|
expr_t *build_do_while_statement (expr_t *statement, int not, expr_t *test,
|
2011-01-17 13:33:33 +00:00
|
|
|
expr_t *break_label, expr_t *continue_label);
|
|
|
|
expr_t *build_for_statement (expr_t *init, expr_t *test, expr_t *next,
|
|
|
|
expr_t *statement,
|
|
|
|
expr_t *break_label, expr_t *continue_label);
|
2013-06-24 02:36:52 +00:00
|
|
|
expr_t *build_state_expr (expr_t *e);
|
2011-03-05 09:01:37 +00:00
|
|
|
expr_t *think_expr (struct symbol_s *think_sym);
|
2020-03-14 08:45:54 +00:00
|
|
|
int is_lvalue (const expr_t *expr) __attribute__((pure));
|
2018-10-13 14:32:53 +00:00
|
|
|
expr_t *assign_expr (expr_t *dst, expr_t *src);
|
2002-06-04 18:44:03 +00:00
|
|
|
expr_t *cast_expr (struct type_s *t, expr_t *e);
|
2023-08-21 08:37:56 +00:00
|
|
|
expr_t *cast_error (expr_t *e, struct type_s *t1, struct type_s *t2);
|
2001-06-26 07:21:20 +00:00
|
|
|
|
2018-10-09 03:35:01 +00:00
|
|
|
const char *get_op_string (int op) __attribute__((const));
|
2001-10-25 17:48:35 +00:00
|
|
|
|
2002-05-08 23:12:49 +00:00
|
|
|
struct keywordarg_s;
|
2003-05-15 05:58:31 +00:00
|
|
|
struct class_type_s;
|
2002-05-08 23:12:49 +00:00
|
|
|
expr_t *selector_expr (struct keywordarg_s *selector);
|
|
|
|
expr_t *protocol_expr (const char *protocol);
|
2002-06-04 18:44:03 +00:00
|
|
|
expr_t *encode_expr (struct type_s *type);
|
2003-05-15 05:58:31 +00:00
|
|
|
expr_t *super_expr (struct class_type_s *class_type);
|
2002-05-08 23:12:49 +00:00
|
|
|
expr_t *message_expr (expr_t *receiver, struct keywordarg_s *message);
|
2002-08-18 04:08:02 +00:00
|
|
|
expr_t *sizeof_expr (expr_t *expr, struct type_s *type);
|
2002-05-08 23:12:49 +00:00
|
|
|
|
2004-01-25 08:55:03 +00:00
|
|
|
expr_t *fold_constants (expr_t *e);
|
|
|
|
|
2020-02-11 06:20:49 +00:00
|
|
|
///@}
|
2010-12-19 02:35:18 +00:00
|
|
|
|
2001-12-08 20:40:50 +00:00
|
|
|
#endif//__expr_h
|