Variant MethodStatement:: invokeInstanceDirect(CObjRef obj, VariableEnvironment &env, const FunctionCallExpression *caller) const { if (getModifiers() & ClassStatement::Static) { return invokeStaticDirect(obj->o_getClassName(), env, caller); } attemptAccess(FrameInjection::GetClassName(false)); DECLARE_THREAD_INFO RECURSION_INJECTION REQUEST_TIMEOUT_INJECTION #ifdef HOTPROFILER ProfilerInjection pi(info, m_fullName.c_str()); #endif MethScopeVariableEnvironment fenv(this, 0); directBind(env, caller, fenv); fenv.setCurrentObject(obj); String clsName(m_class->name().c_str(), m_class->name().size(), AttachLiteral); EvalFrameInjection fi(clsName, m_fullName.c_str(), fenv, loc()->file, obj.get()); if (m_ref) { return ref(evalBody(fenv)); } return evalBody(fenv); }
void binary_serialize_spec(CObjRef zthis, PHPOutputTransport& transport, CArrRef spec) { for (ArrayIter key_ptr = spec.begin(); !key_ptr.end(); ++key_ptr) { Variant key = key_ptr.first(); if (!key.isInteger()) { throw_tprotocolexception("Bad keytype in TSPEC (expected 'long')", INVALID_DATA); return; } unsigned long fieldno = key.toInt64(); Array fieldspec = key_ptr.second().toArray(); // field name String varname = fieldspec.rvalAt(PHPTransport::s_var, AccessFlags::Error_Key).toString(); // thrift type int8_t ttype = fieldspec.rvalAt(PHPTransport::s_type, AccessFlags::Error_Key).toByte(); Variant prop = zthis->o_get(varname, true, zthis->o_getClassName()); if (!prop.isNull()) { transport.writeI8(ttype); transport.writeI16(fieldno); binary_serialize(ttype, transport, prop, fieldspec); } } transport.writeI8(T_STOP); // struct end }
void binary_deserialize_spec(CObjRef zthis, PHPInputTransport& transport, CArrRef spec) { // SET and LIST have 'elem' => array('type', [optional] 'class') // MAP has 'val' => array('type', [optiona] 'class') while (true) { Variant val; int8_t ttype = transport.readI8(); if (ttype == T_STOP) return; int16_t fieldno = transport.readI16(); if (!(val = spec.rvalAt(fieldno)).isNull()) { Array fieldspec = val.toArray(); // pull the field name // zend hash tables use the null at the end in the length... so strlen(hash key) + 1. String varname = fieldspec.rvalAt(PHPTransport::s_var).toString(); // and the type int8_t expected_ttype = fieldspec.rvalAt(PHPTransport::s_type).toInt64(); if (ttypes_are_compatible(ttype, expected_ttype)) { Variant rv = binary_deserialize(ttype, transport, fieldspec); zthis->o_set(varname, rv, zthis->o_getClassName()); } else { skip_element(ttype, transport); } } else { skip_element(ttype, transport); } } }
void f_thrift_protocol_write_binary(CObjRef transportobj, const String& method_name, int64_t msgtype, CObjRef request_struct, int seqid, bool strict_write) { PHPOutputTransport transport(transportobj); if (strict_write) { int32_t version = VERSION_1 | msgtype; transport.writeI32(version); transport.writeString(method_name.data(), method_name.size()); transport.writeI32(seqid); } else { transport.writeString(method_name.data(), method_name.size()); transport.writeI8(msgtype); transport.writeI32(seqid); } Variant spec = HHVM_FN(hphp_get_static_property)( request_struct->o_getClassName(), s_TSPEC, false); binary_serialize_spec(request_struct, transport, spec.toArray()); transport.flush(); }
void VariableSerializer::write(CObjRef v) { if (!v.isNull() && m_type == JSON) { Array props = v->o_toArray(); ClassInfo::PropertyVec properties; ClassInfo::GetClassProperties(properties, v->o_getClassName()); for (ClassInfo::PropertyVec::const_iterator iter = properties.begin(); iter != properties.end(); ++iter) { if ((*iter)->attribute & ClassInfo::IsProtected) { props.remove((*iter)->name); } } // Remove private props for (ArrayIter it(props); !it.end(); it.next()) { if (it.first().toString().charAt(0) == '\0') { props.remove(it.first()); } } setObjectInfo(v->o_getClassName(), v->o_getId()); props.serialize(this); } else { v.serialize(this); } }
void VariableSerializer::write(CObjRef v) { if (!v.isNull() && m_type == JSON) { if (incNestedLevel(v.get(), true)) { writeOverflow(v.get(), true); } else { Array props(ArrayData::Create()); ClassInfo::GetArray(v.get(), v->o_getClassPropTable(), props, true); setObjectInfo(v->o_getClassName(), v->o_getId()); props.serialize(this); } decNestedLevel(v.get()); } else { v.serialize(this); } }
Variant MethodStatement::invokeInstance(CObjRef obj, CArrRef params, bool check /* = true */) const { if (getModifiers() & ClassStatement::Static) { return invokeStatic(obj->o_getClassName(), params); } if (check) attemptAccess(FrameInjection::GetClassName(false)); // The debug frame should have been pushed at ObjectMethodExpression DECLARE_THREAD_INFO_NOINIT MethScopeVariableEnvironment env(this); env.setCurrentObject(obj); String clsName(m_class->name()); EvalFrameInjection fi(clsName, m_fullName.c_str(), env, loc()->file, obj.get()); if (m_ref) { return ref(invokeImpl(env, params)); } return invokeImpl(env, params); }
Variant MethodStatement::invokeInstance(CObjRef obj, CArrRef params, const MethodStatementWrapper *msw, bool check /* = true */) const { ASSERT(msw->m_methodStatement == this); if (getModifiers() & ClassStatement::Static) { return invokeStatic(obj->o_getClassName(), params, msw, check); } if (check) attemptAccess(FrameInjection::GetClassName(false), msw); // The debug frame should have been pushed at ObjectMethodExpression DECLARE_THREAD_INFO_NOINIT MethScopeVariableEnvironment env(this); env.setCurrentObject(obj); env.setCurrentAlias(get_current_alias()); EvalFrameInjection fi(msw->m_className, m_fullName->data(), env, loc()->file, obj.get(), FrameInjection::ObjectMethod); if (m_ref) { return strongBind(invokeImpl(env, params)); } return invokeImpl(env, params); }
Variant MethodStatement:: invokeInstanceDirect(CObjRef obj, VariableEnvironment &env, const FunctionCallExpression *caller) const { if (getModifiers() & ClassStatement::Static) { return invokeStaticDirect(obj->o_getClassName(), env, caller); } attemptAccess(FrameInjection::GetClassName(false)); DECLARE_THREAD_INFO_NOINIT MethScopeVariableEnvironment fenv(this); directBind(env, caller, fenv); fenv.setCurrentObject(obj); String clsName(m_class->name()); EvalFrameInjection fi(clsName, m_fullName.c_str(), fenv, loc()->file, obj.get()); if (m_ref) { return ref(evalBody(fenv)); } return evalBody(fenv); }
Variant MethodStatement::invokeInstance(CObjRef obj, CArrRef params, bool check /* = true */) const { if (getModifiers() & ClassStatement::Static) { return invokeStatic(obj->o_getClassName(), params); } if (check) attemptAccess(FrameInjection::GetClassName(false)); // The debug frame should have been pushed at ObjectMethodExpression DECLARE_THREAD_INFO RECURSION_INJECTION REQUEST_TIMEOUT_INJECTION #ifdef HOTPROFILER ProfilerInjection pi(info, m_fullName.c_str()); #endif MethScopeVariableEnvironment env(this, params.size()); env.setCurrentObject(obj); EvalFrameInjection fi(m_class->name().c_str(), m_fullName.c_str(), env, loc()->file, obj.get()); if (m_ref) { return ref(invokeImpl(env, params)); } return invokeImpl(env, params); }
Variant MethodStatement:: invokeInstanceDirect(CObjRef obj, CStrRef alias, VariableEnvironment &env, const FunctionCallExpression *caller, const MethodStatementWrapper *msw, bool check /* = true */) const { ASSERT(msw->m_methodStatement == this); if (getModifiers() & ClassStatement::Static) { return invokeStaticDirect(obj->o_getClassName(), alias, env, caller, false, msw, check); } if (check) attemptAccess(FrameInjection::GetClassName(false), msw); DECLARE_THREAD_INFO_NOINIT MethScopeVariableEnvironment fenv(this); directBind(env, caller, fenv); fenv.setCurrentObject(obj); fenv.setCurrentAlias(alias); EvalFrameInjection::EvalStaticClassNameHelper helper(obj); EvalFrameInjection fi(msw->m_className, m_fullName->data(), fenv, loc()->file, obj.get(), FrameInjection::ObjectMethod); if (m_ref) { return strongBind(evalBody(fenv)); } return evalBody(fenv); }
void VariableEnvironment::setCurrentObject(CObjRef co) { ASSERT(!m_currentClass); m_currentObject = co; m_currentClass = co->o_getClassName(); getVar(s_this, SgNormal) = co; }
String f_get_resource_type(CObjRef handle) { if (handle.isResource()) { return handle->o_getClassName(); } return ""; }
void VariableEnvironment::setCurrentObject(CObjRef co) { ASSERT(!m_currentClass); m_currentObject = co; m_currentClass = co->o_getClassName(); get("this") = co; }