示例#1
0
void WaitPhase::calculate(EvalContext context)
{
    if (context.ib()->rule_exec->phase == m_data->phase) {
        children().back()->eval(context);
        forward(children().back());
    }
}
示例#2
0
void FinishPhase::calculate(EvalContext context)
{
    map_calculate(children().back(), context);

    if (context.ib()->rule_exec->phase == m_data->phase) {
        finish();
    }
}
示例#3
0
void Var::calculate(EvalContext context)
{
    Value value;
    bool time_to_finish = false;
    ib_rule_phase_num_t current_phase = context.ib()->rule_exec->phase;
    ib_rule_phase_num_t initial_phase = m_data->source.initial_phase();
    ib_rule_phase_num_t finish_phase = m_data->source.final_phase();

    if (
        initial_phase != IB_PHASE_NONE &&
        current_phase < initial_phase
    ) {
        // Nothing to do, yet.
        return;
    }
    if (
        m_data->wait_phase != IB_PHASE_NONE &&
        current_phase < m_data->wait_phase
    ) {
        // User wants us to do nothing, yet.
        return;
    }

    if (
        finish_phase != IB_PHASE_NONE &&
        finish_phase <= current_phase
    ) {
        // Var says it's done.
        time_to_finish = true;
    }
    if (
        m_data->final_phase != IB_PHASE_NONE &&
        m_data->final_phase <= current_phase
    ) {
        // Users says var is done.
        time_to_finish = true;
    }

    if (is_aliased()) {
        if (time_to_finish) {
            finish();
        }
        return;
    }

    try {
        value = m_data->source.get(context.var_store());
    }
    catch (enoent) {
        return;
    }

    if (
        value.is_dynamic() ||
        value.type() != Value::LIST
    ) {
        add_value(value);
        finish();
    }
    else {
        alias(value.value_as_list<Value>());
        if (time_to_finish) {
            finish();
        }
    }
}