示例#1
0
static void phpStreamApplyFilterList(const Resource& fpres,
                                     char *filter,
                                     int rwMode) {
  char *token = nullptr;
  filter = strtok_r(filter, "|", &token);
  while (filter) {
    auto ret = HHVM_FN(stream_filter_append)(fpres, String(filter, CopyString),
                                             rwMode, null_variant);
    if (!ret.toBoolean()) {
      raise_warning("Unable to create filter (%s)", filter);
    }
    filter = strtok_r(nullptr, "|", &token);
  }
}
示例#2
0
 void State::processInput(int key, int scancode, int action, int mods)
 {
     CEGUI::GUIContext& context = CEGUI::System::getSingleton().getDefaultGUIContext();
     if(action == GLFW_PRESS)
     {
         context.injectKeyDown(glfwToCEGUIKey(key));
         if(toBoolean(this->contextHandle->getSettingValue("debug","debugInput")))
             aeon::log("Key Pressed: "+aeon::toString(key), AEON_INFO);
     }
     else if(action == GLFW_RELEASE)
     {
         context.injectKeyUp(glfwToCEGUIKey(key));
         if(toBoolean(this->contextHandle->getSettingValue("debug","debugInput")))
             aeon::log("Key Released: "+aeon::toString(key), AEON_INFO);
     }
     else if(action == GLFW_REPEAT)
     {
         // TODO: Banana phone
         context.injectKeyDown(glfwToCEGUIKey(key));
         if(toBoolean(this->contextHandle->getSettingValue("debug","debugInput")))
             aeon::log("Key Repeat: "+aeon::toString(key), AEON_INFO);
     }
 }
  req::ptr<StreamFilter> createInstance(const char* php_func,
                                        req::ptr<File> stream,
                                        const String& filter,
                                        const Variant& params) {
    auto class_name = m_registeredFilters.rvalAt(filter).asCStrRef();
    Class* class_ = Unit::getClass(class_name.get(), true);
    Object obj = Object();

    if (LIKELY(class_ != nullptr)) {
      PackedArrayInit ctor_args(3);
      ctor_args.append(Variant(stream));
      ctor_args.append(filter);
      ctor_args.append(params);
      obj = Object::attach(
        g_context->createObject(class_name.get(), ctor_args.toArray())
      );
      auto created = obj->o_invoke(s_onCreate, Array::Create());
      /* - true: documented value for success
       * - null: undocumented default successful value
       * - false: documented value for failure
       */
      if (!(created.isNull() || created.toBoolean())) {
        obj.reset();
      }
    } else {
      raise_warning("%s: user-filter \"%s\" requires class \"%s\", but that "
                    "class " "is not defined",
                    php_func,
                    filter.data(),
                    class_name.data());
      // Fall through, as to match Zend, the warning below should also be raised
    }

    if (obj.isNull()) {
      raise_warning("%s: unable to create or locate filter \"%s\"",
                    php_func,
                    filter.data());
      return nullptr;
    }

    return req::make<StreamFilter>(obj, stream);
  }
示例#4
0
  Resource createInstance(const char* php_func,
                          const Resource& stream,
                          const String& filter,
                          CVarRef params) {
    auto class_name = m_registeredFilters.rvalAt(filter).asCStrRef();
    Class* class_ = Unit::lookupClass(class_name.get());
    Object obj = null_object;

    if (LIKELY(class_ != nullptr)) {
      ArrayInit ctor_args(3);
      ctor_args.set(stream);
      ctor_args.set(filter);
      ctor_args.set(params);
      obj = g_context->createObject(class_name.get(), ctor_args.toArray());
      auto created = obj->o_invoke(s_onCreate, Array::Create());
      /* - true: documented value for success
       * - null: undocumented default successful value
       * - false: documented value for failure
       */
      if (!(created.isNull() || created.toBoolean())) {
        obj = null_object;
      }
    } else {
      raise_warning("%s: user-filter \"%s\" requires class \"%s\", but that "
                    "class " "is not defined",
                    php_func,
                    filter->data(),
                    class_name->data());
      // Fall through, as to match Zend, the warning below should also be raised
    }

    if (obj.isNull()) {
      raise_warning("%s: unable to create or locate filter \"%s\"",
                    php_func,
                    filter->data());
      return null_resource;
    }

    return Resource(NEWOBJ(StreamFilter)(obj));
  }
static void perWorldBindingsTestInterfaceEmptyMethodOptionalBooleanArgMethodForMainWorld(const v8::FunctionCallbackInfo<v8::Value>& info)
{
    ExceptionState exceptionState(ExceptionState::ExecutionContext, "perWorldBindingsTestInterfaceEmptyMethodOptionalBooleanArg", "TestInterfaceNode", info.Holder(), info.GetIsolate());
    TestInterfaceNode* impl = V8TestInterfaceNode::toImpl(info.Holder());
    bool optionalBooleanArgument;
    {
        int numArgsPassed = info.Length();
        while (numArgsPassed > 0) {
            if (!info[numArgsPassed - 1]->IsUndefined())
                break;
            --numArgsPassed;
        }
        if (UNLIKELY(numArgsPassed <= 0)) {
            v8SetReturnValueForMainWorld(info, WTF::getPtr(impl->perWorldBindingsTestInterfaceEmptyMethodOptionalBooleanArg()));
            return;
        }
        optionalBooleanArgument = toBoolean(info.GetIsolate(), info[0], exceptionState);
        if (exceptionState.throwIfNeeded())
            return;
    }
    v8SetReturnValueForMainWorld(info, WTF::getPtr(impl->perWorldBindingsTestInterfaceEmptyMethodOptionalBooleanArg(optionalBooleanArgument)));
}
示例#6
0
    inline ber::Value Value::toBerValue() const
    {
        switch(type().value())
        {
            case ParameterType::Integer:
                return ber::Value(toInteger());

            case ParameterType::Real:
                return ber::Value(toReal());

            case ParameterType::String:
                return ber::Value(toString());

            case ParameterType::Octets:
                return ber::Value(toOctets());

            case ParameterType::Boolean:
                return ber::Value(toBoolean());
        }

        return ber::Value();
    }
bool Array::less(CObjRef v2) const {
    if (m_px == NULL || v2.get() == NULL) {
        return HPHP::less(toBoolean(), v2.toBoolean());
    }
    return false;
}
bool Array::equal(CArrRef v2) const {
    if (m_px == NULL || v2.get() == NULL) {
        return HPHP::equal(toBoolean(), v2.toBoolean());
    }
    return m_px->equal(v2.get(), false);
}
示例#9
0
static bool yaf_route_map_route(const Object& o, const Object& request)
{
    auto ptr_uri = request->o_realProp(YAF_REQUEST_PROPERTY_NAME_URI, 
            ObjectData::RealPropUnchecked, "Yaf_Request_Abstract");

    auto ptr_base_uri = request->o_realProp(YAF_REQUEST_PROPERTY_NAME_BASE, 
            ObjectData::RealPropUnchecked, "Yaf_Request_Abstract");

    auto ptr_ctl_prefer = o->o_realProp(YAF_ROUTE_MAP_VAR_NAME_CTL_PREFER, 
             ObjectData::RealPropUnchecked, "Yaf_Route_Map");

    auto ptr_delim = o->o_realProp(YAF_ROUTE_MAP_VAR_NAME_DELIMETER, 
             ObjectData::RealPropUnchecked, "Yaf_Route_Map");

    if (ptr_uri == NULL) {
        raise_warning("invalid uri:%p", ptr_uri);
        return false;
    }

    std::string req_uri;
    if (ptr_uri && ptr_uri->isString() && 
        ptr_base_uri && 
        ptr_base_uri->isString()&&
        strncasecmp(ptr_uri->toString().c_str(), 
            ptr_base_uri->toString().c_str(), ptr_base_uri->toString().length()) == 0) {
        req_uri = std::string(ptr_uri->toString().c_str() + ptr_base_uri->toString().length()); 
    } else {
        req_uri = std::string(ptr_uri->toString().c_str());
    }

    if (req_uri.length() == 0) {
        return false;
    }

    std::string str_query_str;
    if (ptr_delim->isString() && ptr_delim->toString().length()) {
        const char* str_delim = ptr_delim->toString().c_str();
        char* tmp_req_uri = strdup(req_uri.c_str());
        char* query_str = strstr(tmp_req_uri, str_delim);
        if (query_str && *(query_str - 1) == '/') {
            char* rest = query_str + strlen(str_delim);
            if (*rest == '\0') {
                req_uri = std::string(req_uri, query_str - tmp_req_uri);
                query_str = NULL;
            } else if(*rest == '/') {
                req_uri = std::string(req_uri, query_str - tmp_req_uri);
                str_query_str  = std::string(rest);
            } else {
                query_str = NULL;
            }
        }
        
        free(tmp_req_uri);
    }

    std::string route_result;
    char* save_ptr = NULL;
    char* tmp = strdup(req_uri.c_str());
    char* seg = strtok_r(tmp, YAF_ROUTER_URL_DELIMIETER, &save_ptr);
    while (seg) {
        int seg_len = strlen(seg);
        if (seg_len) {
            route_result += seg;
        }

        route_result += "_";
        seg = strtok_r(NULL, YAF_ROUTER_URL_DELIMIETER, &save_ptr);
    }

    free(tmp);
    if (route_result.length()) {
        if (route_result[route_result.length() - 1] == '_') {
            route_result.pop_back();
        }

        if (ptr_ctl_prefer->toBoolean()) {
            auto ptr_controller = request->o_realProp(YAF_REQUEST_PROPERTY_NAME_CONTROLLER, 
                        ObjectData::RealPropUnchecked, "Yaf_Request_Abstract");
            *ptr_controller = String(route_result);
        } else {
            auto ptr_action = request->o_realProp(YAF_REQUEST_PROPERTY_NAME_ACTION, 
                        ObjectData::RealPropUnchecked, "Yaf_Request_Abstract");
            *ptr_action = String(route_result);
        }
    }

    if (str_query_str.length()) {
        Array arr = yaf_router_parse_parameters(str_query_str.c_str()); 
        yaf_request_set_params_multi(&request, arr);
    }

    return true;
}
static void V8TestInterfaceNamedConstructorConstructorCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
{
    if (!info.IsConstructCall()) {
        V8ThrowException::throwTypeError(info.GetIsolate(), ExceptionMessages::constructorNotCallableAsFunction("Audio"));
        return;
    }

    if (ConstructorMode::current(info.GetIsolate()) == ConstructorMode::WrapExistingObject) {
        v8SetReturnValue(info, info.Holder());
        return;
    }
    ExceptionState exceptionState(ExceptionState::ConstructionContext, "TestInterfaceNamedConstructor", info.Holder(), info.GetIsolate());
    if (UNLIKELY(info.Length() < 1)) {
        setMinimumArityTypeError(exceptionState, 1, info.Length());
        exceptionState.throwIfNeeded();
        return;
    }
    V8StringResource<> stringArg;
    bool defaultUndefinedOptionalBooleanArg;
    int defaultUndefinedOptionalLongArg;
    V8StringResource<> defaultUndefinedOptionalStringArg;
    V8StringResource<> defaultNullStringOptionalstringArg;
    V8StringResource<> optionalStringArg;
    {
        int numArgsPassed = info.Length();
        while (numArgsPassed > 0) {
            if (!info[numArgsPassed - 1]->IsUndefined())
                break;
            --numArgsPassed;
        }
        stringArg = info[0];
        if (!stringArg.prepare())
            return;
        defaultUndefinedOptionalBooleanArg = toBoolean(info.GetIsolate(), info[1], exceptionState);
        if (exceptionState.throwIfNeeded())
            return;
        defaultUndefinedOptionalLongArg = toInt32(info.GetIsolate(), info[2], NormalConversion, exceptionState);
        if (exceptionState.throwIfNeeded())
            return;
        defaultUndefinedOptionalStringArg = info[3];
        if (!defaultUndefinedOptionalStringArg.prepare())
            return;
        if (!info[4]->IsUndefined()) {
            defaultNullStringOptionalstringArg = info[4];
            if (!defaultNullStringOptionalstringArg.prepare())
                return;
        } else {
            defaultNullStringOptionalstringArg = nullptr;
        }
        if (UNLIKELY(numArgsPassed <= 5)) {
            Document& document = *toDocument(currentExecutionContext(info.GetIsolate()));
            RefPtr<TestInterfaceNamedConstructor> impl = TestInterfaceNamedConstructor::createForJSConstructor(document, stringArg, defaultUndefinedOptionalBooleanArg, defaultUndefinedOptionalLongArg, defaultUndefinedOptionalStringArg, defaultNullStringOptionalstringArg, exceptionState);
            if (exceptionState.hadException()) {
                exceptionState.throwIfNeeded();
                return;
            }
            v8::Local<v8::Object> wrapper = info.Holder();
            wrapper = impl->associateWithWrapper(info.GetIsolate(), &V8TestInterfaceNamedConstructorConstructor::wrapperTypeInfo, wrapper);
            v8SetReturnValue(info, wrapper);
            return;
        }
        optionalStringArg = info[5];
        if (!optionalStringArg.prepare())
            return;
    }
    Document& document = *toDocument(currentExecutionContext(info.GetIsolate()));
    RefPtr<TestInterfaceNamedConstructor> impl = TestInterfaceNamedConstructor::createForJSConstructor(document, stringArg, defaultUndefinedOptionalBooleanArg, defaultUndefinedOptionalLongArg, defaultUndefinedOptionalStringArg, defaultNullStringOptionalstringArg, optionalStringArg, exceptionState);
    if (exceptionState.hadException()) {
        exceptionState.throwIfNeeded();
        return;
    }
    v8::Local<v8::Object> wrapper = info.Holder();
    wrapper = impl->associateWithWrapper(info.GetIsolate(), &V8TestInterfaceNamedConstructorConstructor::wrapperTypeInfo, wrapper);
    v8SetReturnValue(info, wrapper);
}
示例#11
0
/* SRC: classes/exception.php line 152 */
void c_Exception::t_inittrace() {
  INSTANCE_METHOD_INJECTION_BUILTIN(Exception, Exception::initTrace);
  Variant v_top;
  Variant v_frame;

  ObjectData *obj_tmp UNUSED;
  {
    const CallInfo *cit0 = NULL;
    MethodCallPackage mcp0;
    mcp0.staticMethodCall(NAMSTR(s_sys_ssf08d205d, "static"), NAMSTR(s_sys_ssc453e9e9, "getTraceOptions"));
    mcp0.lateStaticBind(fi.getThreadInfo());
    cit0 = mcp0.ci;
    const Array &tmp1((x_debug_backtrace(toBoolean((cit0->getMeth0Args())(mcp0, 0)))));
    m_trace = tmp1;
  }
  LOOP_COUNTER(1);
  {
    while (!(empty(m_trace))) {
      LOOP_COUNTER_CHECK(1);
      {
        {
          const Variant &tmp0((m_trace.rvalAt(0LL, AccessFlags::Error)));
          v_top.assignVal(tmp0);
        }
        {
          bool tmp0;
          {
            bool tmp1 = ((isset(v_top, NAMSTR(s_sys_ssc82dbd12, "class"), true) && isset(v_top, NAMSTR(s_sys_ss52403931, "function"), true)));
            if (tmp1) {
              const String &tmp2((toString(v_top.rvalAt(NAMSTR(s_sys_ssc82dbd12, "class"), AccessFlags::Error_Key))));
              int64 tmp3((x_strcasecmp(tmp2, NAMSTR(s_sys_ssae8717ad, "exception"))));
              tmp1 = (same(tmp3, 0LL));
            }
            bool tmp4 = (tmp1);
            if (tmp4) {
              const String &tmp5((toString(v_top.rvalAt(NAMSTR(s_sys_ss52403931, "function"), AccessFlags::Error_Key))));
              int64 tmp6((x_strcasecmp(tmp5, NAMSTR(s_sys_ssa26bedd7, "__init__"))));
              tmp4 = (same(tmp6, 0LL));
            }
            tmp0 = (tmp4);
          }
          if (tmp0) {
            {
              {
                const Variant &tmp0((x_array_shift(ref(m_trace))));
                v_frame.assignVal(tmp0);
              }
              if (isset(v_frame, NAMSTR(s_sys_ss8ce7db5b, "file"), true)) {
                {
                  const Variant &tmp0((v_frame.rvalAt(NAMSTR(s_sys_ss8ce7db5b, "file"), AccessFlags::Error_Key)));
                  m_file.assignVal(tmp0);
                }
              }
              if (isset(v_frame, NAMSTR(s_sys_ssddf8728c, "line"), true)) {
                {
                  const Variant &tmp0((v_frame.rvalAt(NAMSTR(s_sys_ssddf8728c, "line"), AccessFlags::Error_Key)));
                  m_line.assignVal(tmp0);
                }
              }
              return;
            }
          }
        }
        x_array_shift(ref(m_trace));
      }
    }
  }
}
static void parseOldStyleNames(const WebVector<WebMediaConstraint>& oldNames, WebMediaTrackConstraintSet& result, MediaErrorState& errorState)
{
    for (const WebMediaConstraint& constraint : oldNames) {
        if (constraint.m_name.equals(kMinAspectRatio)) {
            result.aspectRatio.setMin(atof(constraint.m_value.utf8().c_str()));
        } else if (constraint.m_name.equals(kMaxAspectRatio)) {
            result.aspectRatio.setMax(atof(constraint.m_value.utf8().c_str()));
        } else if (constraint.m_name.equals(kMaxWidth)) {
            result.width.setMax(atoi(constraint.m_value.utf8().c_str()));
        } else if (constraint.m_name.equals(kMinWidth)) {
            result.width.setMin(atoi(constraint.m_value.utf8().c_str()));
        } else if (constraint.m_name.equals(kMaxHeight)) {
            result.height.setMax(atoi(constraint.m_value.utf8().c_str()));
        } else if (constraint.m_name.equals(kMinHeight)) {
            result.height.setMin(atoi(constraint.m_value.utf8().c_str()));
        } else if (constraint.m_name.equals(kMinFrameRate)) {
            result.frameRate.setMin(atof(constraint.m_value.utf8().c_str()));
        } else if (constraint.m_name.equals(kMaxFrameRate)) {
            result.frameRate.setMax(atof(constraint.m_value.utf8().c_str()));
        } else if (constraint.m_name.equals(kEchoCancellation)) {
            result.echoCancellation.setExact(toBoolean(constraint.m_value));
        } else if (constraint.m_name.equals(kMediaStreamSource)) {
            // TODO(hta): This has only a few legal values. Should be
            // represented as an enum, and cause type errors.
            // https://crbug.com/576582
            result.mediaStreamSource.setExact(constraint.m_value);
        } else if (constraint.m_name.equals(kMediaStreamSourceId)) {
            result.deviceId.setExact(constraint.m_value);
        } else if (constraint.m_name.equals(kMediaStreamRenderToAssociatedSink)) {
            // TODO(hta): This is a boolean represented as string.
            // Should give TypeError when it's not parseable.
            // https://crbug.com/576582
            result.renderToAssociatedSink.setExact(toBoolean(constraint.m_value));
        } else if (constraint.m_name.equals(kMediaStreamAudioHotword)) {
            result.hotwordEnabled.setExact(toBoolean(constraint.m_value));
        } else if (constraint.m_name.equals(kGoogEchoCancellation)) {
            result.googEchoCancellation.setExact(toBoolean(constraint.m_value));
        } else if (constraint.m_name.equals(kGoogExperimentalEchoCancellation)) {
            result.googExperimentalEchoCancellation.setExact(toBoolean(constraint.m_value));
        } else if (constraint.m_name.equals(kGoogAutoGainControl)) {
            result.googAutoGainControl.setExact(toBoolean(constraint.m_value));
        } else if (constraint.m_name.equals(kGoogExperimentalAutoGainControl)) {
            result.googExperimentalAutoGainControl.setExact(toBoolean(constraint.m_value));
        } else if (constraint.m_name.equals(kGoogNoiseSuppression)) {
            result.googNoiseSuppression.setExact(toBoolean(constraint.m_value));
        } else if (constraint.m_name.equals(kGoogExperimentalNoiseSuppression)) {
            result.googExperimentalNoiseSuppression.setExact(toBoolean(constraint.m_value));
        } else if (constraint.m_name.equals(kGoogBeamforming)) {
            result.googBeamforming.setExact(toBoolean(constraint.m_value));
        } else if (constraint.m_name.equals(kGoogArrayGeometry)) {
            result.googArrayGeometry.setExact(constraint.m_value);
        } else if (constraint.m_name.equals(kGoogHighpassFilter)) {
            result.googHighpassFilter.setExact(toBoolean(constraint.m_value));
        } else if (constraint.m_name.equals(kGoogTypingNoiseDetection)) {
            result.googTypingNoiseDetection.setExact(toBoolean(constraint.m_value));
        } else if (constraint.m_name.equals(kGoogAudioMirroring)) {
            result.googAudioMirroring.setExact(toBoolean(constraint.m_value));
        } else if (constraint.m_name.equals(kTestConstraint1)
            || constraint.m_name.equals(kTestConstraint2)) {
            // These constraints are only for testing parsing. Ignore them.
        } else {
            // TODO(hta): UMA stats for unknown constraints passed.
            // https://crbug.com/576613
            WTF_LOG(Media, "Unknown constraint name detected");
            errorState.throwConstraintError("Unknown name of constraint detected", constraint.m_name);
        }
    }
}
示例#13
0
bool Array::equal(CObjRef v2) const {
  if (m_px == nullptr || v2.get() == nullptr) {
    return HPHP::equal(toBoolean(), v2.toBoolean());
  }
  return false;
}
示例#14
0
文件: CVar.cpp 项目: Antidote/Orion
void CVar::serializeCVar(TiXmlNode* rootNode, bool oldDeveloper)
{
    if (rootNode == NULL)
        return;

    TiXmlElement* cvarNode = rootNode->FirstChildElement("CVar");

    while (cvarNode != NULL)
    {
        if (!std::string(cvarNode->Attribute("name")).compare(name()))
            break;
        cvarNode = cvarNode->NextSiblingElement("CVar");
    }

    TiXmlText* text = NULL;
    TiXmlText* oldText = NULL;


    if (!cvarNode)
    {
        cvarNode = new TiXmlElement("CVar");
        cvarNode->SetAttribute("name", name());
        rootNode->LinkEndChild(cvarNode);
    }
    else
    {
        if (cvarNode->FirstChild())
        {
            oldText = cvarNode->FirstChild()->ToText();
        }
    }

    switch(type())
    {
        case CVar::Boolean:
        {
            cvarNode->SetAttribute("type", "boolean");
            std::string val;
            if (com_developer == this)
                val = (oldDeveloper ? "true" : "false");
            else
                val = (toBoolean() ? "true" : "false");

            text = new TiXmlText(val);
            break;
        }
        case CVar::Integer:
            cvarNode->SetAttribute("type", "integer");
            break;
        case CVar::Float:
            cvarNode->SetAttribute("type", "float");
            break;
        case CVar::Literal:
        {
            cvarNode->SetAttribute("type", "literal");
            text = new TiXmlText(toLiteral());
            text->SetCDATA(true);
            break;
        }
        case CVar::Color:
        {
            Colori col = toColori();
            cvarNode->SetAttribute("type", "color");
            cvarNode->SetAttribute("r", (col.r & 255));
            cvarNode->SetAttribute("g", (col.g & 255));
            cvarNode->SetAttribute("b", (col.b & 255));
            cvarNode->SetAttribute("a", (col.a & 255));
        }
            break;
        default: break;
    }

    if (!text && type() != Color)
        text = new TiXmlText(toLiteral());

    if (oldText && type() != Color)
    {
        cvarNode->RemoveChild(oldText);
    }

    if (text && type() != Color)
        cvarNode->LinkEndChild(text);
}
示例#15
0
bool String::more(CObjRef v2) const {
  if (m_px == NULL || v2.get() == NULL) {
    return HPHP::more(toBoolean(), v2.toBoolean());
  }
  return false;
}
示例#16
0
bool String::less(CObjRef v2) const {
  if (m_px == NULL || v2.get() == NULL) {
    return HPHP::less(toBoolean(), v2.toBoolean());
  }
  return true;
}
示例#17
0
bool String::equal(CArrRef v2) const {
  if (m_px == NULL || v2.get() == NULL) {
    return HPHP::equal(toBoolean(), v2.toBoolean());
  }
  return false;
}
bool Array::more(CObjRef v2) const {
    if (m_px == NULL || v2.get() == NULL) {
        return HPHP::more(toBoolean(), v2.toBoolean());
    }
    return true;
}
/**
 *  Get a boolean value at a certain index
 *  @param  index
 *  @return bool
 */
bool Array::boolean(int index) const
{
    // get value
    return toBoolean(json_object_array_get_idx(_json, index));
}
void OpcodeComparisonHandler::_run()
{
    Logger::debug("SCRIPT") << "[8033-8038] [*] " << _cmpOpcodeName() << std::endl;
    auto bValue = _vm->dataStack()->pop();
    auto aValue = _vm->dataStack()->pop();
    int result = 0;
    switch (aValue.type())
    {
        case VMStackValue::Type::INTEGER:
        {
            int arg1 = aValue.integerValue();
            switch (bValue.type())
            {
                case VMStackValue::Type::INTEGER:
                {
                    result = _compare(arg1, bValue.integerValue()); // INTEGER op INTEGER
                    break;
                }
                case VMStackValue::Type::FLOAT:
                {
                    result = _compare(arg1, bValue.floatValue()); // INTEGER op FLOAT
                    break;
                }
                case VMStackValue::Type::STRING:
                {
                    result = _compare(arg1, bValue.toInteger()); // INTEGER op STRING (parsed as int)
                    break;
                }
                default:
                {
                    _error(std::string() + _cmpOpcodeName() + ": invalid right argument type: " + bValue.typeName());
                }
            }
            break;
        }
        case VMStackValue::Type::FLOAT:
        {
            float arg1 = aValue.floatValue();
            switch (bValue.type())
            {
                case VMStackValue::Type::INTEGER:
                {
                    result = _compare(arg1, bValue.integerValue()); // FLOAT op INTEGER
                    break;
                }
                case VMStackValue::Type::FLOAT:
                {
                    result = _compare(arg1, bValue.floatValue()); // FLOAT op FLOAT
                    break;
                }
                case VMStackValue::Type::STRING:
                {
                    float arg2 = 0.0;
                    try 
                    {
                        arg2 = std::stof(bValue.stringValue());
                    }
                    catch (std::invalid_argument ex) { }
                    catch (std::out_of_range ex) { }
                    result = _compare(arg1, arg2); // FLOAT op STRING (parsed as float)
                    break;
                }
                default:
                {
                    _error(std::string() + _cmpOpcodeName() + ": invalid right argument type: " + bValue.typeName());
                }
            }
            break;
        }
        case VMStackValue::Type::STRING:
        {
            switch (bValue.type())
            {
                case VMStackValue::Type::INTEGER:
                {
                    result = _compare(aValue.toInteger(), bValue.integerValue()); // STRING (as integer) op INTEGER
                    break;
                }
                case VMStackValue::Type::FLOAT:
                {
                    float arg1 = 0.0;
                    try 
                    {
                        arg1 = std::stof(aValue.stringValue());
                    }
                    catch (std::invalid_argument ex) { }
                    catch (std::out_of_range ex) { }
                    result = _compare(arg1, bValue.floatValue()); // STRING (as float) op FLOAT
                    break;
                }
                case VMStackValue::Type::STRING:
                {
                    result = _compare(aValue.stringValue(), bValue.stringValue()); // STRING op STRING
                    break;
                }
                default:
                {
                    _error(std::string() + _cmpOpcodeName() + ": invalid right argument type: " + bValue.typeName());
                }
            }
            break;
        }
        case VMStackValue::Type::OBJECT:
        {
            switch (bValue.type())
            {
                case VMStackValue::Type::INTEGER:
                {
                    result = _compare((int)aValue.toBoolean(), bValue.integerValue()); // OBJECT op INTEGER
                    break;
                }
                case VMStackValue::Type::FLOAT:
                {
                    result = _compare((float)aValue.toBoolean(), bValue.floatValue()); // OBJECT op FLOAT
                    break;
                }
                case VMStackValue::Type::STRING:
                {
                    result = _compare(aValue.toString(), bValue.stringValue()); // OBJECT op STRING - compare object name
                    break;
                }
                default:
                {
                    _error(std::string() + _cmpOpcodeName() + ": invalid right argument type: " + bValue.typeName());
                }
            }
            break;
        }
        default:
        {
            _error(std::string() + _cmpOpcodeName() + ": invalid left argument type: " + aValue.typeName());
        }
    }
    _vm->dataStack()->push(result);
}
示例#21
0
/* SRC: classes/exception.php line 25 */
void c_Exception::t___init__() {
  INSTANCE_METHOD_INJECTION_BUILTIN(Exception, Exception::__init__);
  Variant v_top;
  Variant v_frame;

  ObjectData *obj_tmp UNUSED;
  if (toBoolean(m_inited)) {
    {
      return;
    }
  }
  m_inited = true;
  {
    const Array &tmp0((x_debug_backtrace(false)));
    m_trace = tmp0;
  }
  LOOP_COUNTER(1);
  {
    while (!(empty(m_trace))) {
      LOOP_COUNTER_CHECK(1);
      {
        {
          const Variant &tmp0((m_trace.rvalAt(0LL, AccessFlags::Error)));
          v_top.assignVal(tmp0);
        }
        {
          bool tmp0;
          {
            bool tmp1 = (empty(v_top, NAMSTR(s_sys_ssc82dbd12, "class"), true));
            if (!tmp1) {
              const String &tmp2((toString(v_top.rvalAt(NAMSTR(s_sys_ss52403931, "function"), AccessFlags::Error_Key))));
              bool tmp3 = (toBoolean(x_strcasecmp(tmp2, NAMSTR(s_sys_ssa26bedd7, "__init__"))));
              if (tmp3) {
                const String &tmp4((toString(v_top.rvalAt(NAMSTR(s_sys_ss52403931, "function"), AccessFlags::Error_Key))));
                tmp3 = (toBoolean(x_strcasecmp(tmp4, NAMSTR(s_sys_ssa1b87da7, "__construct"))));
              }
              bool tmp5 = (tmp3);
              if (tmp5) {
                const String &tmp6((toString(v_top.rvalAt(NAMSTR(s_sys_ss52403931, "function"), AccessFlags::Error_Key))));
                const String &tmp7((toString(v_top.rvalAt(NAMSTR(s_sys_ssc82dbd12, "class"), AccessFlags::Error_Key))));
                tmp5 = (toBoolean(x_strcasecmp(tmp6, tmp7)));
              }
              tmp1 = (tmp5);
            }
            bool tmp8 = (tmp1);
            if (!tmp8) {
              const String &tmp9((toString(v_top.rvalAt(NAMSTR(s_sys_ssc82dbd12, "class"), AccessFlags::Error_Key))));
              bool tmp10 = (toBoolean(x_strcasecmp(tmp9, NAMSTR(s_sys_ssae8717ad, "exception"))));
              if (tmp10) {
                const Variant &tmp11((v_top.rvalAt(NAMSTR(s_sys_ssc82dbd12, "class"), AccessFlags::Error_Key)));
                tmp10 = (!(x_is_subclass_of(tmp11, NAMSTR(s_sys_ssae8717ad, "exception"))));
              }
              tmp8 = (tmp10);
            }
            tmp0 = (tmp8);
          }
          if (tmp0) {
            {
              break;
            }
          }
        }
        {
          const Variant &tmp0((x_array_shift(ref(m_trace))));
          v_frame.assignVal(tmp0);
        }
      }
    }
  }
  if (isset(v_frame, NAMSTR(s_sys_ss8ce7db5b, "file"), true)) {
    {
      const Variant &tmp0((v_frame.rvalAt(NAMSTR(s_sys_ss8ce7db5b, "file"), AccessFlags::Error_Key)));
      m_file.assignVal(tmp0);
    }
  }
  if (isset(v_frame, NAMSTR(s_sys_ssddf8728c, "line"), true)) {
    {
      const Variant &tmp0((v_frame.rvalAt(NAMSTR(s_sys_ssddf8728c, "line"), AccessFlags::Error_Key)));
      m_line.assignVal(tmp0);
    }
  }
}