-
Notifications
You must be signed in to change notification settings - Fork 10
/
expr.h
63 lines (56 loc) · 1.55 KB
/
expr.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
/* expr.h expression handling for vasm */
/* (c) in 2002-2015 by Volker Barthelmann and Frank Wille */
#include "hugeint.h"
enum {
ADD,SUB,MUL,DIV,MOD,NEG,CPL,LAND,LOR,BAND,BOR,XOR,NOT,LSH,RSH,RSHU,
LT,GT,LEQ,GEQ,NEQ,EQ,NUM,HUG,FLT,SYM
};
#define LAST_EXP_TYPE SYM
struct expr {
int type;
struct expr *left;
struct expr *right;
union {
taddr val;
tfloat flt;
thuge huge;
symbol *sym;
} c;
};
/* Macros for extending the unary operation types (e.g. '<' and '>' for 6502).
Cpu module has to define EXT_UNARY_EVAL(type,val,res,c) for evaluation. */
#ifndef EXT_UNARY_NAME
#define EXT_UNARY_NAME(s) 0
#endif
#ifndef EXT_UNARY_TYPE
#define EXT_UNARY_TYPE(s) NOT
#endif
/* global variables */
extern char current_pc_char;
extern int unsigned_shift;
/* functions */
expr *new_expr(void);
expr *make_expr(int,expr *,expr *);
expr *copy_tree(expr *);
expr *curpc_expr(void);
expr *parse_expr(char **);
expr *parse_expr_tmplab(char **);
expr *parse_expr_huge(char **);
expr *parse_expr_float(char **);
taddr parse_constexpr(char **);
expr *number_expr(taddr);
expr *huge_expr(thuge);
expr *float_expr(tfloat);
void free_expr(expr *);
int type_of_expr(expr *);
void simplify_expr(expr *);
int eval_expr(expr *,taddr *,section *,taddr);
int eval_expr_huge(expr *,thuge *);
int eval_expr_float(expr *,tfloat *);
void print_expr(FILE *,expr *);
int find_base(expr *,symbol **,section *,taddr);
/* find_base return codes */
#define BASE_ILLEGAL 0
#define BASE_OK 1
#define BASE_PCREL 2
#define BASE_NONE -1 /* no base-symbol assigned, all labels are absolute */