if (exp->op) {
switch (exp->op) {
case PSI_T_NOT:
- exp->calc = psi_calc_not;
+ exp->calc = psi_calc_bool_not;
break;
case PSI_T_TILDE:
exp->calc = psi_calc_bin_not;
break;
case PSI_T_OR:
- exp->calc = psi_calc_or;
+ exp->calc = psi_calc_bool_or;
break;
case PSI_T_AND:
- exp->calc = psi_calc_and;
+ exp->calc = psi_calc_bool_and;
break;
case PSI_T_CMP_EQ:
exp->calc = psi_calc_cmp_eq;
if (frame) PSI_DEBUG_PRINT(frame->context, "%s", "\n");
}
-static inline int psi_num_exp_op_cmp(token_t op1, token_t op2)
-{
- if (PSI_T_LPAREN == op2) {
- return -1;
- } else if (PSI_T_LPAREN == op1) {
- return 1;
- } else if (op1 == op2) {
- return 0;
- } else if (!op1) {
- return 1;
- } else if (!op2) {
- return -1;
- }
-
- return psi_token_oper_cmp(op1, op2);
-}
-
static void psi_num_exp_reduce(struct psi_num_exp *exp, struct psi_plist **output_ptr,
- struct psi_plist **input_ptr, struct psi_call_frame *frame)
+ struct psi_plist **input_ptr, struct psi_call_frame *frame, HashTable *defs)
{
struct psi_plist *output = *output_ptr, *input = *input_ptr;
struct element {
switch (exp->op) {
case 0:
- entry.type = psi_number_eval(exp->data.n, &entry.data.value, frame);
+ entry.type = psi_number_eval(exp->data.n, &entry.data.value, frame, defs);
output = psi_plist_add(output, &entry);
break;
case PSI_T_LPAREN:
entry.type = exp->op;
input = psi_plist_add(input, &entry);
- psi_num_exp_reduce(exp->data.u, &output, &input, frame);
+ psi_num_exp_reduce(exp->data.u, &output, &input, frame, defs);
while (psi_plist_pop(input, &entry)) {
if (entry.type == PSI_T_LPAREN) {
break;
case PSI_T_TILDE:
while (psi_plist_top(input, &entry)) {
/* bail out if exp->op >= entry.type */
- if (psi_num_exp_op_cmp(exp->op, entry.type) != 1) {
+ if (psi_calc_oper(exp->op, entry.type) != 1) {
break;
}
psi_plist_pop(input, NULL);
entry.type = exp->op;
entry.data.calc = exp->calc;
input = psi_plist_add(input, &entry);
- psi_num_exp_reduce(exp->data.u, &output, &input, frame);
+ psi_num_exp_reduce(exp->data.u, &output, &input, frame, defs);
break;
default:
- psi_num_exp_reduce(exp->data.b.lhs, &output, &input, frame);
+ psi_num_exp_reduce(exp->data.b.lhs, &output, &input, frame, defs);
while (psi_plist_top(input, &entry)) {
/* bail out if exp->op > entry.type */
- if (psi_num_exp_op_cmp(exp->op, entry.type) == -1) {
+ if (psi_calc_oper(exp->op, entry.type) == -1) {
break;
}
psi_plist_pop(input, NULL);
entry.type = exp->op;
entry.data.calc = exp->calc;
input = psi_plist_add(input, &entry);
- psi_num_exp_reduce(exp->data.b.rhs, &output, &input, frame);
+ psi_num_exp_reduce(exp->data.b.rhs, &output, &input, frame, defs);
break;
}
}
token_t psi_num_exp_exec(struct psi_num_exp *exp, impl_val *res,
- struct psi_call_frame *frame)
+ struct psi_call_frame *frame, HashTable *defs)
{
struct psi_plist *output, *input;
struct element {
output = psi_plist_init_ex(sizeof(entry), NULL);
input = psi_plist_init_ex(sizeof(entry), NULL);
- psi_num_exp_reduce(exp, &output, &input, frame);
+ psi_num_exp_reduce(exp, &output, &input, frame, defs);
while (psi_plist_pop(input, &entry)) {
if (frame) PSI_DEBUG_PRINT(frame->context, " %s", psi_num_exp_op_tok(entry.type));