Ejemplo n.º 1
0
int64_t
SBValue::GetValueAsSigned(int64_t fail_value)
{
    ValueLocker locker;
    lldb::ValueObjectSP value_sp(GetSP(locker));
    if (value_sp)
    {
        Scalar scalar;
        if (value_sp->ResolveValue (scalar))
            return scalar.SLongLong(fail_value);
    }
    return fail_value;
}
Ejemplo n.º 2
0
int64_t
SBValue::GetValueAsSigned(SBError& error, int64_t fail_value)
{
    error.Clear();
    ValueLocker locker;
    lldb::ValueObjectSP value_sp(GetSP(locker));
    if (value_sp)
    {
        Scalar scalar;
        if (value_sp->ResolveValue (scalar))
            return scalar.SLongLong (fail_value);
        else
            error.SetErrorString ("could not resolve value");
    }
    else
        error.SetErrorStringWithFormat ("could not get SBValue: %s", locker.GetError().AsCString());
    
    return fail_value;
}
Ejemplo n.º 3
0
bool
CompilerType::SetValueFromScalar (const Scalar &value, Stream &strm)
{
    if (!IsValid())
        return false;

    // Aggregate types don't have scalar values
    if (!IsAggregateType ())
    {
        strm.GetFlags().Set(Stream::eBinary);
        uint64_t count = 0;
        lldb::Encoding encoding = GetEncoding (count);
        
        if (encoding == lldb::eEncodingInvalid || count != 1)
            return false;
        
        const uint64_t bit_width = GetBitSize(nullptr);
        // This function doesn't currently handle non-byte aligned assignments
        if ((bit_width % 8) != 0)
            return false;
        
        const uint64_t byte_size = (bit_width + 7 ) / 8;
        switch (encoding)
        {
            case lldb::eEncodingInvalid:
                break;
            case lldb::eEncodingVector:
                break;
            case lldb::eEncodingUint:
                switch (byte_size)
            {
                case 1: strm.PutHex8(value.UInt()); return true;
                case 2: strm.PutHex16(value.UInt()); return true;
                case 4: strm.PutHex32(value.UInt()); return true;
                case 8: strm.PutHex64(value.ULongLong()); return true;
                default:
                    break;
            }
                break;
                
            case lldb::eEncodingSint:
                switch (byte_size)
            {
                case 1: strm.PutHex8(value.SInt()); return true;
                case 2: strm.PutHex16(value.SInt()); return true;
                case 4: strm.PutHex32(value.SInt()); return true;
                case 8: strm.PutHex64(value.SLongLong()); return true;
                default:
                    break;
            }
                break;
                
            case lldb::eEncodingIEEE754:
                if (byte_size <= sizeof(long double))
                {
                    if (byte_size == sizeof(float))
                    {
                        strm.PutFloat(value.Float());
                        return true;
                    }
                    else
                        if (byte_size == sizeof(double))
                        {
                            strm.PutDouble(value.Double());
                            return true;
                        }
                        else
                            if (byte_size == sizeof(long double))
                            {
                                strm.PutDouble(value.LongDouble());
                                return true;
                            }
                }
                break;
        }
    }
    return false;
}