Exemplo n.º 1
0
TriState Value::asTriState() const
{
    switch (opcode()) {
    case Const32:
        return triState(!!asInt32());
    case Const64:
        return triState(!!asInt64());
    case ConstDouble:
        // Use "!= 0" to really emphasize what this mean with respect to NaN and such.
        return triState(asDouble() != 0);
    default:
        return MixedTriState;
    }
}
Exemplo n.º 2
0
TriState ConstFloatValue::equalOrUnorderedConstant(const Value* other) const
{
    if (std::isnan(m_value))
        return TrueTriState;

    if (!other->hasFloat())
        return MixedTriState;
    float otherValue = other->asFloat();
    return triState(std::isunordered(m_value, otherValue) || m_value == otherValue);
}
Exemplo n.º 3
0
static TriState equalToStringImpl(JSValue value, StringImpl* stringImpl)
{
    if (!value.isString())
        return FalseTriState;
    
    JSString* jsString = asString(value);
    const StringImpl* string = jsString->tryGetValueImpl();
    if (!string)
        return MixedTriState;
    
    return triState(WTF::equal(stringImpl, string));
}
Exemplo n.º 4
0
TriState LazyJSValue::strictEqual(const LazyJSValue& other) const
{
    switch (m_kind) {
    case KnownValue:
        switch (other.m_kind) {
        case KnownValue:
            return JSValue::pureStrictEqual(value(), other.value());
        case SingleCharacterString:
            return equalToSingleCharacter(value(), other.character());
        case KnownStringImpl:
            return equalToStringImpl(value(), other.stringImpl());
        }
        break;
    case SingleCharacterString:
        switch (other.m_kind) {
        case SingleCharacterString:
            return triState(character() == other.character());
        case KnownStringImpl:
            if (other.stringImpl()->length() != 1)
                return FalseTriState;
            return triState(other.stringImpl()->at(0) == character());
        default:
            return other.strictEqual(*this);
        }
        break;
    case KnownStringImpl:
        switch (other.m_kind) {
        case KnownStringImpl:
            return triState(WTF::equal(stringImpl(), other.stringImpl()));
        default:
            return other.strictEqual(*this);
        }
        break;
    }
    RELEASE_ASSERT_NOT_REACHED();
    return FalseTriState;
}
Exemplo n.º 5
0
static TriState equalToSingleCharacter(JSValue value, UChar character)
{
    if (!value.isString())
        return FalseTriState;
    
    JSString* jsString = asString(value);
    if (jsString->length() != 1)
        return FalseTriState;
    
    const StringImpl* string = jsString->tryGetValueImpl();
    if (!string)
        return MixedTriState;
    
    return triState(string->at(0) == character);
}
Exemplo n.º 6
0
TriState ConstFloatValue::greaterEqualConstant(const Value* other) const
{
    if (!other->hasFloat())
        return MixedTriState;
    return triState(m_value >= other->asFloat());
}
Exemplo n.º 7
0
TriState ConstFloatValue::lessThanConstant(const Value* other) const
{
    if (!other->hasFloat())
        return MixedTriState;
    return triState(m_value < other->asFloat());
}
Exemplo n.º 8
0
TriState ConstDoubleValue::greaterEqualConstant(Value* other) const
{
    if (!other->hasDouble())
        return MixedTriState;
    return triState(m_value >= other->asDouble());
}
Exemplo n.º 9
0
TriState ConstDoubleValue::lessThanConstant(Value* other) const
{
    if (!other->hasDouble())
        return MixedTriState;
    return triState(m_value < other->asDouble());
}
Exemplo n.º 10
0
TriState ConstDoubleValue::lessEqualConstant(const Value* other) const
{
    if (!other->hasDouble())
        return MixedTriState;
    return triState(m_value <= other->asDouble());
}
Exemplo n.º 11
0
TriState ConstDoubleValue::greaterThanConstant(const Value* other) const
{
    if (!other->hasDouble())
        return MixedTriState;
    return triState(m_value > other->asDouble());
}