Variant eval(LVariableTable *vars, CObjRef self, CStrRef code_str, bool prepend_php /* = true */) { vector<StaticStatementPtr> statics; String code_str2 = prepend_php ? concat("<?php ", code_str) : code_str; Eval::StatementPtr s = Eval::Parser::parseString(code_str2.data(), statics); Block blk(statics); // install string code container to globals StringCodeContainer *scc = new StringCodeContainer(s); RequestEvalState::addCodeContainer(scc); // todo: pass in params NestedVariableEnvironment env(vars, blk, Array(), self); s->eval(env); if (env.isReturning()) { return env.getRet(); } return true; }
Variant eval(LVariableTable *vars, CObjRef self, CStrRef code_str, bool prepend_php /* = true */) { vector<StaticStatementPtr> statics; Block::VariableIndices variableIndices; String code_str2 = prepend_php ? concat("<?php ", code_str) : code_str; Eval::StatementPtr s = Eval::Parser::ParseString(code_str2, NULL, statics, variableIndices); Block blk(statics, variableIndices); // install string code container to globals SmartPtr<CodeContainer> scc = new StringCodeContainer(s); RequestEvalState::addCodeContainer(scc); // todo: pass in params NestedVariableEnvironment env(vars, blk, Array(), self); EvalFrameInjection fi(empty_string, "_", env, "string", NULL, FrameInjection::PseudoMain|FrameInjection::Function); s->eval(env); if (env.isReturning()) { return env.getRet(); } return true; }