当前位置: 首页>>代码示例>>C++>>正文


C++ GoType类代码示例

本文整理汇总了C++中GoType的典型用法代码示例。如果您正苦于以下问题:C++ GoType类的具体用法?C++ GoType怎么用?C++ GoType使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了GoType类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: CompilerType

CompilerType
GoASTContext::GetFieldAtIndex(lldb::opaque_compiler_type_t type, size_t idx, std::string &name, uint64_t *bit_offset_ptr,
                              uint32_t *bitfield_bit_size_ptr, bool *is_bitfield_ptr)
{
    if (bit_offset_ptr)
        *bit_offset_ptr = 0;
    if (bitfield_bit_size_ptr)
        *bitfield_bit_size_ptr = 0;
    if (is_bitfield_ptr)
        *is_bitfield_ptr = false;

    if (!type || !GetCompleteType(type))
        return CompilerType();

    GoType *t = static_cast<GoType *>(type);
    if (t->IsTypedef())
        return t->GetElementType().GetFieldAtIndex(idx, name, bit_offset_ptr, bitfield_bit_size_ptr, is_bitfield_ptr);

    GoStruct *s = t->GetStruct();
    if (s)
    {
        const auto *field = s->GetField(idx);
        if (field)
        {
            name = field->m_name.GetStringRef();
            if (bit_offset_ptr)
                *bit_offset_ptr = field->m_byte_offset * 8;
            return field->m_type;
        }
    }
    return CompilerType();
}
开发者ID:wiltonlazary,项目名称:swift-lldb,代码行数:32,代码来源:GoASTContext.cpp

示例2: switch

uint64_t
GoASTContext::GetBitSize(lldb::opaque_compiler_type_t type, ExecutionContextScope *exe_scope)
{
    if (!type)
        return 0;
    if (!GetCompleteType(type))
        return 0;
    GoType *t = static_cast<GoType *>(type);
    GoArray *array = nullptr;
    switch (t->GetGoKind())
    {
        case GoType::KIND_BOOL:
        case GoType::KIND_INT8:
        case GoType::KIND_UINT8:
            return 8;
        case GoType::KIND_INT16:
        case GoType::KIND_UINT16:
            return 16;
        case GoType::KIND_INT32:
        case GoType::KIND_UINT32:
        case GoType::KIND_FLOAT32:
            return 32;
        case GoType::KIND_INT64:
        case GoType::KIND_UINT64:
        case GoType::KIND_FLOAT64:
        case GoType::KIND_COMPLEX64:
            return 64;
        case GoType::KIND_COMPLEX128:
            return 128;
        case GoType::KIND_INT:
        case GoType::KIND_UINT:
            return m_int_byte_size * 8;
        case GoType::KIND_UINTPTR:
        case GoType::KIND_FUNC: // I assume this is a pointer?
        case GoType::KIND_CHAN:
        case GoType::KIND_PTR:
        case GoType::KIND_UNSAFEPOINTER:
        case GoType::KIND_MAP:
            return m_pointer_byte_size * 8;
        case GoType::KIND_ARRAY:
            array = t->GetArray();
            return array->GetLength() * array->GetElementType().GetBitSize(exe_scope);
        case GoType::KIND_INTERFACE:
            return t->GetElementType().GetBitSize(exe_scope);
        case GoType::KIND_SLICE:
        case GoType::KIND_STRING:
        case GoType::KIND_STRUCT:
            return t->GetStruct()->GetByteSize() * 8;
        default:
            assert(false);
    }
    return 0;
}
开发者ID:wiltonlazary,项目名称:swift-lldb,代码行数:53,代码来源:GoASTContext.cpp

示例3:

CompilerType
GoASTContext::GetFunctionReturnType(lldb::opaque_compiler_type_t type)
{
    CompilerType result;
    if (type)
    {
        GoType *t = static_cast<GoType *>(type);
        if (t->GetGoKind() == GoType::KIND_FUNC)
            result = t->GetElementType();
    }
    return result;
}
开发者ID:wiltonlazary,项目名称:swift-lldb,代码行数:12,代码来源:GoASTContext.cpp

示例4: if

// Lookup a child given a name. This function will match base class names
// and member member names in "clang_type" only, not descendants.
uint32_t
GoASTContext::GetIndexOfChildWithName(lldb::opaque_compiler_type_t type, const char *name, bool omit_empty_base_classes)
{
    if (!type || !GetCompleteType(type))
        return UINT_MAX;

    GoType *t = static_cast<GoType *>(type);
    GoStruct *s = t->GetStruct();
    if (s)
    {
        for (uint32_t i = 0; i < s->GetNumFields(); ++i)
        {
            const GoStruct::Field *f = s->GetField(i);
            if (f->m_name.GetStringRef() == name)
                return i;
        }
    }
    else if (t->GetGoKind() == GoType::KIND_PTR || t->IsTypedef())
    {
        return t->GetElementType().GetIndexOfChildWithName(name, omit_empty_base_classes);
    }
    return UINT_MAX;
}
开发者ID:wiltonlazary,项目名称:swift-lldb,代码行数:25,代码来源:GoASTContext.cpp

示例5: compiler_type

bool
GoASTContext::GetCompleteType(lldb::opaque_compiler_type_t type)
{
    if (!type)
        return false;
    GoType *t = static_cast<GoType *>(type);
    if (t->IsTypedef() || t->GetGoKind() == GoType::KIND_PTR || t->GetArray())
        return t->GetElementType().GetCompleteType();
    if (GoStruct *s = t->GetStruct())
    {
        if (s->IsComplete())
            return true;
        CompilerType compiler_type(this, s);
        SymbolFile *symbols = GetSymbolFile();
        return symbols && symbols->CompleteType(compiler_type);
    }
    return true;
}
开发者ID:wiltonlazary,项目名称:swift-lldb,代码行数:18,代码来源:GoASTContext.cpp


注:本文中的GoType类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。