1 #ifndef _PSI_TYPES_NUM_EXP
2 #define _PSI_TYPES_NUM_EXP
4 typedef struct num_exp
{
5 struct psi_token
*token
;
11 struct decl_enum_item
*enm
;
14 int (*calculator
)(int t1
, impl_val
*v1
, int t2
, impl_val
*v2
, impl_val
*res
);
15 struct num_exp
*operand
;
18 static inline num_exp
*init_num_exp(token_t t
, void *num
) {
19 num_exp
*exp
= calloc(1, sizeof(*exp
));
23 exp
->u
.numb
= strdup(num
);
28 EMPTY_SWITCH_DEFAULT_CASE();
33 static inline num_exp
*copy_num_exp(num_exp
*exp
) {
35 num_exp
*num
= calloc(1, sizeof(*num
));
37 memcpy(num
, exp
, sizeof(*num
));
40 num
->token
= psi_token_copy(num
->token
);
43 num
->operand
= copy_num_exp(num
->operand
);
48 num
->u
.numb
= strdup(num
->u
.numb
);
51 dvar
= init_decl_var(num
->u
.dvar
->name
, num
->u
.dvar
->pointer_level
, num
->u
.dvar
->array_size
);
52 dvar
->arg
= num
->u
.dvar
->arg
;
53 if (num
->u
.dvar
->token
) {
54 dvar
->token
= psi_token_copy(num
->u
.dvar
->token
);
62 static inline void free_num_exp(num_exp
*exp
) {
73 free_decl_var(exp
->u
.dvar
);
77 EMPTY_SWITCH_DEFAULT_CASE();
80 free_num_exp(exp
->operand
);