void StrongForEachStatement::eval(VariableEnvironment &env) const {
  if (env.isGotoing()) return;

  ENTER_STMT;
  LvalExpression* lvalSource = m_source->cast<LvalExpression>();
  Variant source(lvalSource ? ref(lvalSource->lval(env)) :
                              ref(m_source->eval(env)));
  source.escalate(true);
  Variant vTemp;

  if (m_key) {
    Variant kTemp;
    for (MutableArrayIter iter =
           source.begin(&kTemp, vTemp, env.currentContext());
         iter.advance();) {
      m_key->set(env, kTemp);
      m_value->set(env, ref(vTemp));
      if (!m_body) continue;
      EVAL_STMT_HANDLE_GOTO_BEGIN(restart1);
      EVAL_STMT_HANDLE_BREAK(m_body, env);
      EVAL_STMT_HANDLE_GOTO_END(restart1);
    }
  } else {
    for (MutableArrayIter iter =
           source.begin(NULL, vTemp, env.currentContext());
         iter.advance();) {
      m_value->set(env, ref(vTemp));
      if (!m_body) continue;
      EVAL_STMT_HANDLE_GOTO_BEGIN(restart2);
      EVAL_STMT_HANDLE_BREAK(m_body, env);
      EVAL_STMT_HANDLE_GOTO_END(restart2);
    }
  }
}
void StrongForEachStatement::eval(VariableEnvironment &env) const {
  ENTER_STMT;
  Variant source(ref(m_source->lval(env)));
  source.escalate(true);
  Variant vTemp;

  if (m_key) {
    Variant kTemp;
    for (MutableArrayIterPtr iter = source.begin(&kTemp, vTemp);
         iter->advance();) {
      Variant &v = m_value->lval(env);
      v = ref(vTemp);
      Variant &k = m_key->lval(env);
      k = ref(kTemp);
      if (!m_body) continue;
      EVAL_STMT_HANDLE_BREAK(m_body, env);
    }
  } else {
    for (MutableArrayIterPtr iter = source.begin(NULL, vTemp);
         iter->advance();) {
      Variant &v = m_value->lval(env);
      v = ref(vTemp);
      if (!m_body) continue;
      EVAL_STMT_HANDLE_BREAK(m_body, env);
    }
  }
}
Ejemplo n.º 3
0
void ForEachStatement::eval(VariableEnvironment &env) const {
  if (env.isGotoing()) return;
  ENTER_STMT;
  DECLARE_THREAD_INFO;
  LOOP_COUNTER(1);
  Variant map(m_source->eval(env));
  if (m_key) {
    TempExpressionList *texp = m_key->cast<TempExpressionList>();
    if (texp) {
      for (ArrayIter iter = map.begin(env.currentContext(), true);
           !iter.end(); iter.next()) {
        {
          LOOP_COUNTER_CHECK_INFO(1);
          const Variant &value = iter.second();
          const Variant &key = iter.first();
          TempExpressionHelper helper(texp, env);
          m_value->set(env, value);
          texp->setImpl(env, key);
        }
        if (!m_body) continue;
        EVAL_STMT_HANDLE_GOTO_BEGIN(restart1);
        EVAL_STMT_HANDLE_BREAK(m_body, env);
        EVAL_STMT_HANDLE_GOTO_END(restart1);
      }
    } else {
      for (ArrayIter iter = map.begin(env.currentContext(), true);
           !iter.end(); iter.next()) {
        LOOP_COUNTER_CHECK_INFO(1);
        const Variant &value = iter.second();
        const Variant &key = iter.first();
        m_value->set(env, value);
        m_key->set(env, key);
        if (!m_body) continue;
        EVAL_STMT_HANDLE_GOTO_BEGIN(restart2);
        EVAL_STMT_HANDLE_BREAK(m_body, env);
        EVAL_STMT_HANDLE_GOTO_END(restart2);
      }
    }
  } else {
    for (ArrayIter iter = map.begin(env.currentContext(), true);
         !iter.end(); iter.next()) {
      LOOP_COUNTER_CHECK_INFO(1);
      m_value->set(env, iter.second());
      if (!m_body) continue;
      EVAL_STMT_HANDLE_GOTO_BEGIN(restart3);
      EVAL_STMT_HANDLE_BREAK(m_body, env);
      EVAL_STMT_HANDLE_GOTO_END(restart3);
    }
  }
}
Ejemplo n.º 4
0
void DoWhileStatement::eval(VariableEnvironment &env) const {
  ENTER_STMT;
  do {
    if (!m_body) continue;
    EVAL_STMT_HANDLE_BREAK(m_body, env);
 } while (m_cond->eval(env));
}
Ejemplo n.º 5
0
void ForStatement::eval(VariableEnvironment &env) const {
  ENTER_STMT;
  for (Expression::evalVector(m_init, env);
       m_cond.empty() ? true : (bool)Expression::evalVector(m_cond, env);
       Expression::evalVector(m_next, env)) {
    EVAL_STMT_HANDLE_BREAK(m_body, env);
  }
}
void DoWhileStatement::eval(VariableEnvironment &env) const {
  if (env.isGotoing() && env.isLimitedGoto()) return;
  ENTER_STMT;
  DECLARE_THREAD_INFO;
  LOOP_COUNTER(1);

  do {
    LOOP_COUNTER_CHECK_INFO(1);
    EVAL_STMT_HANDLE_GOTO_BEGIN(restart);
    if (m_body) EVAL_STMT_HANDLE_BREAK(m_body, env);
    EVAL_STMT_HANDLE_GOTO_END(restart);
  } while (m_cond->eval(env));
}
Ejemplo n.º 7
0
void ForStatement::eval(VariableEnvironment &env) const {
  ENTER_STMT;
  DECLARE_THREAD_INFO;
  LOOP_COUNTER(1);
  for (Expression::evalVector(m_init, env);
       m_cond.empty() ? true : (bool)Expression::evalVector(m_cond, env);
       Expression::evalVector(m_next, env)) {
    LOOP_COUNTER_CHECK(1);
    if (m_body) {
      EVAL_STMT_HANDLE_BREAK(m_body, env);
    }
  }
}