void Injection::execute() const { if (m_builtin) { ASSERT(m_callback); // Execute function in runtime m_callback(m_arg); return; } // Execute php code piece TypedValue retval; VarEnv *varEnv = NULL; ActRec *cfpSave = NULL; ObjectData *this_ = NULL; Class *cls = NULL; ActRec *fp = g_vmContext->getFP(); if (fp) { if (!fp->hasVarEnv()) { fp->m_varEnv = VarEnv::createLazyAttach(fp); } varEnv = fp->m_varEnv; cfpSave = varEnv->getCfp(); if (fp->hasThis()) { this_ = fp->getThis(); } else if (fp->hasClass()) { cls = fp->getClass(); } } // Note: For now we don't merge analysis code's class and function. // Later we might decide to do so g_vmContext->invokeFunc(&retval, m_unit->getMain(), Array::Create(), this_, cls, varEnv, NULL, NULL); if (varEnv) { varEnv->setCfp(cfpSave); } }
Array f_get_defined_vars() { VarEnv* v = g_vmContext->getVarEnv(); if (v) { return v->getDefinedVariables(); } else { return Array::Create(); } }
int64_t f_extract(CArrRef var_array, int extract_type /* = EXTR_OVERWRITE */, CStrRef prefix /* = "" */) { bool reference = extract_type & EXTR_REFS; extract_type &= ~EXTR_REFS; VarEnv* v = g_vmContext->getVarEnv(); if (!v) return 0; int count = 0; for (ArrayIter iter(var_array); iter; ++iter) { String name = iter.first(); StringData* nameData = name.get(); switch (extract_type) { case EXTR_SKIP: if (v->lookup(nameData) != NULL) { continue; } break; case EXTR_IF_EXISTS: if (v->lookup(nameData) == NULL) { continue; } break; case EXTR_PREFIX_SAME: if (v->lookup(nameData) != NULL) { name = prefix + "_" + name; } break; case EXTR_PREFIX_ALL: name = prefix + "_" + name; break; case EXTR_PREFIX_INVALID: if (!is_valid_var_name(nameData->data(), nameData->size())) { name = prefix + "_" + name; } break; case EXTR_PREFIX_IF_EXISTS: if (v->lookup(nameData) == NULL) { continue; } name = prefix + "_" + name; break; default: break; } nameData = name.get(); // skip invalid variable names, as in PHP if (!is_valid_var_name(nameData->data(), nameData->size())) { continue; } g_vmContext->setVar(nameData, iter.nvSecond(), reference); count++; } return count; }
bool WddxPacket::add_var(const String& varName, bool hasVarTag) { VarEnv* v = g_context->getOrCreateVarEnv(); if (!v) return false; Variant varVariant = *reinterpret_cast<Variant*>(v->lookup(varName.get())); return recursiveAddVar(varName, varVariant, hasVarTag); }
ALWAYS_INLINE static Array get_defined_vars() { VarEnv* v = g_context->getOrCreateVarEnv(); return v ? v->getDefinedVariables() : empty_array(); }