void resolve_rule_list(struct rule_list_s * n) { if (n->list) { resolve_rule_list(n->list); } if (n->rule) { resolve_rule(n->rule); } }
void resolve_rule_list(struct rule_list_s * n, struct filtergen_opts * o) { if (n->list) { resolve_rule_list(n->list, o); } if (n->rule) { resolve_rule(n->rule, o); } }
void mk_unfold::expand_tail(rule& r, unsigned tail_idx, rule_set const& src, rule_set& dst) { SASSERT(tail_idx <= r.get_uninterpreted_tail_size()); if (tail_idx == r.get_uninterpreted_tail_size()) { dst.add_rule(&r); } else { func_decl* p = r.get_decl(tail_idx); rule_vector const& p_rules = src.get_predicate_rules(p); rule_ref new_rule(rm); for (unsigned i = 0; i < p_rules.size(); ++i) { rule const& r2 = *p_rules[i]; if (m_unify.unify_rules(r, tail_idx, r2) && m_unify.apply(r, tail_idx, r2, new_rule)) { expr_ref_vector s1 = m_unify.get_rule_subst(r, true); expr_ref_vector s2 = m_unify.get_rule_subst(r2, false); resolve_rule(rm, r, r2, tail_idx, s1, s2, *new_rule.get()); expand_tail(*new_rule.get(), tail_idx+r2.get_uninterpreted_tail_size(), src, dst); } } } }
static char * exec_instr( pInstr s ) { pCell tc, tc2; char buffer[16]; switch (s->opcode) { case SET: /* operand must be a string */ tc = temp_pop(); switch (tc->type) { case mu: fprintf(stderr, "exec_inst/SET: warning - unhandled case mu\n" ); break; case string_t: var_put(s->operand.contents.s, tc->contents.s); break; case int_t: var_put_int(s->operand.contents.s, tc->contents.i); break; } break; case EMIT: tc = temp_pop(); switch (tc->type) { case mu: fprintf(stderr, "exec_inst/EMIT: warning - unhandled case mu\n" ); break; case string_t: return tc->contents.s; case int_t: sprintf(buffer, "%i", tc->contents.i); return strdup(buffer); } case PUSHV: { struct var *v = var_lookup(vars, s->operand.contents.s); if (v == 0) { fprintf(stderr, "attempted to use unknown variable \"%s\" in expression.\n", s->operand.contents.s); push_str("(NULL)"); } else { switch (v->type) { case mu: fprintf(stderr, "exec_inst/PUSHV: warning - unhandled case mu\n" ); break; case string_t: push_str(strdup(v->value.s)); break; case int_t: push_int(v->value.i); break; } } } break; case INVOKE: { pRule r = rule_find(rule_base, s->operand.contents.s); if (r) { push_str(resolve_rule(rule_base, r)); } else { fprintf(stderr, "attempted to invoke non-existent rule \"%s\" in expression.\n", s->operand.contents.s); push_str(NULL); } } break; case PUSH: switch (s->operand.type) { case mu: fprintf(stderr, "exec_inst/PUSH: warning - unhandled case mu\n" ); break; case string_t: push_str(strdup(s->operand.contents.s)); break; case int_t: push_int(s->operand.contents.i); break; } break; case ADD: tc = temp_pop(); tc2 = temp_pop(); if ((tc->type == int_t) && (tc2->type == int_t)) { push_int(tc->contents.i + tc2->contents.i); } else { char *s0, *s1; /* string concatenation */ s0 = ((tc->type == int_t) ? itoa(tc->contents.i) : (tc->contents.s)); s1 = ((tc2->type == int_t) ? itoa(tc2->contents.i) : (tc2->contents.s)); push_str(concat(s1, s0)); free(s0); free(s1); } break; case SUB: tc = temp_pop(); tc2 = temp_pop(); if ((tc->type == int_t) && (tc2->type == int_t)) { push_int(tc2->contents.i + tc->contents.i); } break; case MUL: tc = temp_pop(); tc2 = temp_pop(); if ((tc->type == int_t) && (tc2->type == int_t)) { push_int(tc->contents.i * tc2->contents.i); } break; case DIV: tc = temp_pop(); tc2 = temp_pop(); if ((tc->type == int_t) && (tc2->type == int_t)) { push_int(tc2->contents.i / tc->contents.i); } break; case MOD: tc = temp_pop(); tc2 = temp_pop(); if ((tc->type == int_t) && (tc2->type == int_t)) { push_int(tc2->contents.i % tc->contents.i); } break; case RANDOM: tc2 = temp_pop(); tc = temp_pop(); if ((tc->type == int_t) && (tc2->type == int_t)) { push_int((ranq1() % (tc2->contents.i - tc->contents.i + 1)) + tc->contents.i); } break; case LESSER: tc2 = temp_pop(); tc = temp_pop(); if ((tc->type == int_t) && (tc2->type == int_t)) { push_int(min(tc->contents.i, tc2->contents.i)); } break; case GREATER: tc2 = temp_pop(); tc = temp_pop(); if ((tc->type == int_t) && (tc2->type == int_t)) { push_int(max(tc->contents.i, tc2->contents.i)); } break; } return NULL; }