void TryStatement::eval(VariableEnvironment &env) const { //if (env.isGotoing()) return; ENTER_STMT; try { m_body->eval(env); } catch (Object e) { for (vector<CatchBlockPtr>::const_iterator it = m_catches.begin(); it != m_catches.end(); ++it) { if ((*it)->match(e)) { if ((*it)->body()) { String s = (*it)->vname(); SuperGlobal sg = (*it)->sg(); env.getVar(s, sg) = e; EVAL_STMT((*it)->body(), env); } return; } } throw e; } if (env.isGotoing()) { for (vector<CatchBlockPtr>::const_iterator it = m_catches.begin(); it != m_catches.end(); ++it) { if ((*it)->body()) { EVAL_STMT((*it)->body(), env); if (!env.isGotoing()) return; } } } }
bool CatchBlock::proc(CObjRef exn, VariableEnvironment &env) const { if (exn.instanceof(m_ename.c_str())) { if (m_body) { env.getVar(m_vname, m_sg) = exn; m_body->eval(env); } return true; } return false; }
Variant ClosureExpression::eval(VariableEnvironment &env) const { m_func->eval(env); Array vars; for (unsigned int i = 0; i < m_vars.size(); i++) { Parameter *param = m_vars[i].get(); String name = param->getName(); SuperGlobal sg; if (!param->getSuperGlobal(sg)) { sg = VariableIndex::isSuperGlobal(name); } if (param->isRef()) { vars.append(ref(env.getVar(name, sg))); } else { vars.append(env.getVar(name, sg)); } } // need to get at low level constructor return Object(NEWOBJ(c_GeneratorClosure)( m_func->getClosureCallInfo(), m_func.get(), vars)); }