Esempio n. 1
0
bool TagEntry::operator ==(const TagEntry& rhs)
{
    //Note: tree item id is not used in this function!
    bool res =
        m_scope == rhs.m_scope &&
        m_file == rhs.m_file &&
        m_kind == rhs.m_kind &&
        m_parent == rhs.m_parent &&
        m_pattern == rhs.m_pattern &&
        m_name == rhs.m_name &&
        m_path == rhs.m_path &&
        m_lineNumber == rhs.m_lineNumber &&
        GetInherits() == rhs.GetInherits() &&
        GetAccess() == rhs.GetAccess() &&
        GetSignature() == rhs.GetSignature() &&
        GetTyperef() == rhs.GetTyperef();

    bool res2 = m_scope == rhs.m_scope &&
                m_file == rhs.m_file &&
                m_kind == rhs.m_kind &&
                m_parent == rhs.m_parent &&
                m_pattern == rhs.m_pattern &&
                m_name == rhs.m_name &&
                m_path == rhs.m_path &&
                GetInherits() == rhs.GetInherits() &&
                GetAccess() == rhs.GetAccess() &&
                GetSignature() == rhs.GetSignature() &&
                GetTyperef() == rhs.GetTyperef();

    if (res2 && !res) {
        // the entries are differs only in the line numbers
        m_differOnByLineNumber = true;
    }
    return res;
}
Esempio n. 2
0
int TagEntry::Update(wxSQLite3Statement& updatePerepareStmnt)
{
    // If this node is a dummy, (IsOk() == false) we dont update it to database
    if( !IsOk() )
        return TagOk;

    try
    {
        // see TagsDatabase::GetUpdateOneStatement() function for the order of binding
        updatePerepareStmnt.Bind(1, GetParentId());
        updatePerepareStmnt.Bind(2, GetName());
        updatePerepareStmnt.Bind(3, GetFile());
        updatePerepareStmnt.Bind(4, GetLine());
        updatePerepareStmnt.Bind(5, GetAccess());
        updatePerepareStmnt.Bind(6, GetPattern());
        updatePerepareStmnt.Bind(7, GetParent());
        updatePerepareStmnt.Bind(8, GetInherits());
        updatePerepareStmnt.Bind(9, GetTyperef());
        updatePerepareStmnt.Bind(10, GetScope());
        updatePerepareStmnt.Bind(11, GetKind());
        updatePerepareStmnt.Bind(12, GetSignature());
        updatePerepareStmnt.Bind(13, GetPath());
        updatePerepareStmnt.ExecuteUpdate();
        updatePerepareStmnt.Reset();
    }
    catch(wxSQLite3Exception& exc)
    {
        wxLogMessage(exc.GetMessage());
        return TagError;
    }
    return TagOk;
}
Esempio n. 3
0
int TagEntry::Store(wxSQLite3Statement& insertPerepareStmnt)
{
    // If this node is a dummy, (IsOk() == false) we dont insert it to database
    if( !IsOk() )
        return TagOk;

    try
    {
        // see TagsDatabase::GetInsertOneStatement() for the order of binding
        insertPerepareStmnt.Bind(1, GetParentId());
        insertPerepareStmnt.Bind(2, GetName());
        insertPerepareStmnt.Bind(3, GetFile());
        insertPerepareStmnt.Bind(4, GetLine());
        insertPerepareStmnt.Bind(5, GetKind());
        insertPerepareStmnt.Bind(6, GetAccess());
        insertPerepareStmnt.Bind(7, GetSignature());
        insertPerepareStmnt.Bind(8, GetPattern());
        insertPerepareStmnt.Bind(9, GetParent());
        insertPerepareStmnt.Bind(10, GetInherits());
        insertPerepareStmnt.Bind(11, GetPath());
        insertPerepareStmnt.Bind(12, GetTyperef());
        insertPerepareStmnt.Bind(13, GetScope());
        insertPerepareStmnt.ExecuteUpdate();
        insertPerepareStmnt.Reset();

    }
    catch(wxSQLite3Exception& exc)
    {
        if(exc.ErrorCodeAsString(exc.GetErrorCode()) == wxT("SQLITE_CONSTRAINT"))
            return TagExist;
        wxLogMessage(exc.GetMessage());
        return TagError;
    }
    return TagOk;
}
wxString TagEntry::TypeFromTyperef() const
{
    wxString typeref = GetTyperef();
    if(typeref.IsEmpty() == false) {
        wxString name = typeref.BeforeFirst(wxT(':'));
        return name;
    }
    return wxEmptyString;
}
Esempio n. 5
0
static uint_8 * cv_write_bitfield( struct dsym *types, struct dsym *type, struct asym *sym, uint_8 *pt )
/******************************************************************************************************/
{
    pt = checkflush( types, (uint_8 *)CurrSource, pt, sizeof( struct cv_typerec_bitfield ) );
    sym->cv_typeref = currtype++;
    ((struct cv_typerec_bitfield *)pt)->tr.size = sizeof( struct cv_typerec_bitfield ) - sizeof(uint_16);
    ((struct cv_typerec_bitfield *)pt)->tr.leaf = LF_BITFIELD;
    ((struct cv_typerec_bitfield *)pt)->length = sym->total_size;
    ((struct cv_typerec_bitfield *)pt)->position = sym->offset;
    ((struct cv_typerec_bitfield *)pt)->type = GetTyperef( (struct asym *)type, USE16 );
    pt += sizeof( struct cv_typerec_bitfield );
    return( pt );
}
wxString TagEntry::NameFromTyperef(wxString& templateInitList, bool nameIncludeTemplate)
{
    wxString typeref = GetTyperef();
    if(typeref.IsEmpty() == false) {
        wxString name = typeref.AfterFirst(wxT(':'));
        return name;
    }

    // incase our entry is a typedef, and it is not marked as typeref,
    // try to get the real name from the pattern
    if(GetKind() == wxT("typedef")) {

        wxString pat(GetPattern());
        if(!GetPattern().Contains(wxT("typedef"))) {
            // The pattern does not contain 'typedef' however this *is* a typedef
            // try to see if this is a macro
            pat.StartsWith(wxT("/^"), &pat);
            pat.Trim().Trim(false);

            // we take the first token
            CppScanner scanner;
            scanner.SetText(pat.To8BitData());
            int type = scanner.yylex();
            if(type == IDENTIFIER) {
                wxString token = wxString::From8BitData(scanner.YYText());

                PPToken tok = TagsManagerST::Get()->GetDatabase()->GetMacro(token);
                if(tok.flags & PPToken::IsValid) {
                    // we found a match!
                    if(tok.flags & PPToken::IsFunctionLike) {
                        wxArrayString argList;
                        if(GetMacroArgList(scanner, argList)) {
                            tok.expandOnce(argList);
                        }
                    }
                    pat = tok.replacement;
                    pat << wxT(";");

                    // Remove double spaces
                    while(pat.Replace(wxT("  "), wxT(" "))) {
                    }
                }
            }
        }

        wxString name;
        if(TypedefFromPattern(pat, GetName(), name, templateInitList, nameIncludeTemplate)) return name;
    }

    return wxEmptyString;
}
Esempio n. 7
0
static uint_8 * cv_write_symbol( struct dsym *symbols, struct asym *sym, uint_8 *ps, uint_8 *sbuffer )
/****************************************************************************************************/
{
    int        len;
    int        ofs;
    short      rectype;
    uint_8     Ofssize;
    struct fixup *fixup;

    Ofssize = GetSymOfssize( sym );
    len = GetCVStructLen( sym, Ofssize );
    ps = checkflush( symbols, sbuffer, ps, 1 + sym->name_size + len );
    switch ( sym->state ) {
    case SYM_TYPE:
        ((struct cv_symrec_udt *)ps)->sr.size = sizeof( struct cv_symrec_udt ) - sizeof(uint_16) + 1 + sym->name_size;
        ((struct cv_symrec_udt *)ps)->sr.type = S_UDT;
        if ( sym->typekind != TYPE_TYPEDEF ) {
            ((struct cv_symrec_udt *)ps)->typeref = sym->cv_typeref;
        } else {
            ((struct cv_symrec_udt *)ps)->typeref = GetTyperef( sym, Ofssize );
        }

        /* Some typedefs won't get a valid type (<name> TYPEDEF PROTO ...).
         * In such cases just skip the type!
         */
        if ( ((struct cv_symrec_udt *)ps)->typeref == 0 )
            return( ps );

        DebugMsg(( "cv_write_symbol: TYPE=%s typeref=%Xh\n", sym->name, ((struct cv_symrec_udt *)ps)->typeref ));
        rectype = FIX_VOID; /* types have no fixup */
        break;
    default: /* is SYM_INTERNAL */
        if ( sym->isproc ) {
            DebugMsg(( "cv_write_symbol: PROC=%s\n", sym->name ));
            if ( Ofssize == USE16 ) {
                ((struct cv_symrec_lproc16 *)ps)->sr.size = sizeof( struct cv_symrec_lproc16 ) - sizeof(uint_16) + 1 + sym->name_size;
                ((struct cv_symrec_lproc16 *)ps)->sr.type = (sym->public ? S_GPROC16 : S_LPROC16);
                ((struct cv_symrec_lproc16 *)ps)->pParent = 0;  /* filled by CVPACK */
                ((struct cv_symrec_lproc16 *)ps)->pEnd = 0;     /* filled by CVPACK */
                ((struct cv_symrec_lproc16 *)ps)->pNext = 0;    /* filled by CVPACK */
                ((struct cv_symrec_lproc16 *)ps)->proc_length = sym->total_size;
                ((struct cv_symrec_lproc16 *)ps)->debug_start = 0;
                ((struct cv_symrec_lproc16 *)ps)->debug_end = sym->total_size;
                ((struct cv_symrec_lproc16 *)ps)->offset = 0;
                ((struct cv_symrec_lproc16 *)ps)->segment = 0;
                ((struct cv_symrec_lproc16 *)ps)->proctype = 0; /* typeref */
                ((struct cv_symrec_lproc16 *)ps)->flags = ((sym->mem_type == MT_FAR) ? CV_TYPE_LABEL_FAR : CV_TYPE_LABEL_NEAR);
                rectype = FIX_PTR16;
                ofs = offsetof( struct cv_symrec_lproc16, offset );
            } else {
Esempio n. 8
0
static uint_16 GetTyperef( struct asym *sym, uint_8 Ofssize )
/***********************************************************/
{
    union cv_typeref_u value = { CV_PDS_SPECIAL_NO_TYPE, 0, CV_PDT_SPECIAL, CV_PDM_DIRECT, 0 };
    int size = SizeFromMemtype( sym->mem_type, Ofssize, sym->type );

    if ( ( sym->mem_type & MT_SPECIAL ) == 0 && sym->mem_type != MT_FWORD ) {
        if ( sym->mem_type & MT_FLOAT ) {
            value.s.type = CV_PDT_REAL;
            switch ( size ) {
            case 4:  value.s.size = CV_PDS_REAL_32BIT; break;
            case 8:  value.s.size = CV_PDS_REAL_64BIT; break;
            case 10: value.s.size = CV_PDS_REAL_80BIT; break;
            }
        } else {
            if ( sym->mem_type & MT_SIGNED )
                value.s.type = CV_PDT_SIGNED_INTEGRAL;
            else
                value.s.type = CV_PDT_UNSIGNED_INTEGRAL;
            switch ( size ) {
            case 1:  value.s.size = CV_PDS_INTEGRAL_1BYTE; break;
            case 2:  value.s.size = CV_PDS_INTEGRAL_2BYTE; break;
            case 4:  value.s.size = CV_PDS_INTEGRAL_4BYTE; break;
            case 8:  value.s.size = CV_PDS_INTEGRAL_8BYTE; break;
            //case 16: value.s.size = CV_PDS_INTEGRAL_16BYTE; break;
            }
        }
    } else {
        switch ( sym->mem_type ) {
        //case MT_ABS:  break;  /* v2.07: MT_ABS obsolete */
        case MT_PTR:  break;
        case MT_BITS:
            if ( sym->cv_typeref )
                return( sym->cv_typeref );
            break;
        case MT_NEAR: value.s.mode = CV_PDM_NEARPTR; break;
        case MT_FAR:  value.s.mode = CV_PDM_FARPTR; break;
        case MT_TYPE:
            for ( sym = sym->type; sym->type; sym = sym->type );
            if ( sym->cv_typeref )
                return( sym->cv_typeref );
            return( GetTyperef( sym, Ofssize ) );
            break;
        }
    }

    return( value.uvalue );
}
Esempio n. 9
0
wxString TagEntry::NameFromTyperef(wxString &templateInitList)
{
    wxString typeref = GetTyperef();
    if ( typeref.IsEmpty() == false ) {
        wxString name = typeref.AfterFirst(wxT(':'));
        return name;
    }

    // incase our entry is a typedef, and it is not marked as typeref,
    // try to get the real name from the pattern
    if ( GetKind() == wxT("typedef")) {
        wxString name;
        if (TypedefFromPattern(GetPattern(), GetName(),name, templateInitList))
            return name;
    }
    return wxEmptyString;
}
Esempio n. 10
0
bool TagEntry::operator ==(const TagEntry& rhs)
{
    //Note: tree item id is not used in this function!
    return
        m_parentId == rhs.m_parentId &&
        m_scope == rhs.m_scope &&
        m_file == rhs.m_file &&
        m_kind == rhs.m_kind &&
        m_parent == rhs.m_parent &&
        m_pattern == rhs.m_pattern &&
        m_lineNumber == rhs.m_lineNumber &&
        m_name == rhs.m_name &&
        m_path == rhs.m_path &&
        GetInherits() == rhs.GetInherits() &&
        GetAccess() == rhs.GetAccess() &&
        GetSignature() == rhs.GetSignature() &&
        GetPosition() == rhs.GetPosition() &&
        GetTyperef() == rhs.GetTyperef();
}
Esempio n. 11
0
static uint_8 * cv_write_type( struct dsym *types, struct asym *sym, uint_8 *pt )
/*******************************************************************************/
{
    struct dsym *type = (struct dsym *)sym;
    uint_8      *tmp;
    struct field_item  *curr;
    int         typelen = 0;
    int         i;
    int         size;
    uint_16     cnt = 0;

    /* handle structs, unions and records only */
    if ( type->sym.typekind != TYPE_STRUCT &&
        type->sym.typekind != TYPE_UNION &&
        type->sym.typekind != TYPE_RECORD )
        return( pt );

    if ( sym->total_size >= 0x8000 )
        typelen = sizeof( uint_32 );

    /* Count the member fields. If a member's type is unknown, create it! */
    for ( curr = type->e.structinfo->head; curr; curr = curr->next, cnt++ ) {
        if ( curr->sym->mem_type == MT_TYPE && curr->sym->type->cv_typeref == 0 ) {
            pt = cv_write_type( types, curr->sym->type, pt );
        } else if ( curr->sym->mem_type == MT_BITS && curr->sym->cv_typeref == 0 ) {
            pt = cv_write_bitfield( types, type, curr->sym, pt );
        }
    }

    sym->cv_typeref = currtype++;
    switch ( type->sym.typekind ) {
    case TYPE_UNION:
        DebugMsg(( "cv_write_type(%Xh, ref=%X): UNION=%s\n", GetTPos(), sym->cv_typeref, sym->name ));
        size = ( sizeof( struct cv_typerec_union ) + typelen + 1 + sym->name_size + 3 ) & ~3;
        pt = checkflush( types, (uint_8 *)CurrSource, pt, size );
        ((struct cv_typerec_union *)pt)->tr.size = size - sizeof(uint_16);
        ((struct cv_typerec_union *)pt)->tr.leaf = LF_UNION;
        ((struct cv_typerec_union *)pt)->count = cnt;
        ((struct cv_typerec_union *)pt)->field = currtype++;
        ((struct cv_typerec_union *)pt)->property = 0;
        if ( typelen != 0 ) {
            ((struct cv_typerec_union *)pt)->length = LF_ULONG;
            tmp = pt + sizeof( struct cv_typerec_union );
            *(uint_32 *)tmp = sym->total_size;
            tmp += sizeof( uint_32 );
        } else {
            ((struct cv_typerec_union *)pt)->length = sym->total_size;
            tmp = pt + sizeof( struct cv_typerec_union );
        }
        break;
    case TYPE_RECORD:
    case TYPE_STRUCT:
        DebugMsg(( "cv_write_type(%Xh, ref=%X): STRUCT=%s\n", GetTPos(), sym->cv_typeref, sym->name ));
        size = ( sizeof( struct cv_typerec_structure ) + typelen + 1 + sym->name_size + 3 ) & ~3;
        pt = checkflush( types, (uint_8 *)CurrSource, pt, size );
        ((struct cv_typerec_structure *)pt)->tr.size = size - sizeof(uint_16);
        ((struct cv_typerec_structure *)pt)->tr.leaf = LF_STRUCTURE;
        ((struct cv_typerec_structure *)pt)->count = cnt;
        ((struct cv_typerec_structure *)pt)->field = currtype++;
        if ( type->sym.typekind == TYPE_RECORD )
            ((struct cv_typerec_structure *)pt)->property = 1; /* is "packed" */
        else
            ((struct cv_typerec_structure *)pt)->property = 0;
        ((struct cv_typerec_structure *)pt)->dList = 0;
        ((struct cv_typerec_structure *)pt)->vshape = 0;
        if ( typelen != 0 ) {
            ((struct cv_typerec_structure *)pt)->length = LF_ULONG;
            tmp = pt + sizeof( struct cv_typerec_structure );
            *(uint_32 *)tmp = sym->total_size;
            tmp += sizeof( uint_32 );
        } else {
            ((struct cv_typerec_structure *)pt)->length = sym->total_size;
            tmp = pt + sizeof( struct cv_typerec_structure );
        }
    }
    SetPrefixName( tmp, sym->name, sym->name_size );
    PadBytes( tmp, (uint_8 *)CurrSource );
    pt += size;

    pt = checkflush( types, (uint_8 *)CurrSource, pt, sizeof( struct cv_typerec_fieldlist ) );
    size = sizeof( struct cv_typerec_fieldlist) + GetFieldListSize( type );
    ((struct cv_typerec_fieldlist *)pt)->tr.size = size - sizeof(uint_16);
    ((struct cv_typerec_fieldlist *)pt)->tr.leaf = LF_FIELDLIST;
    DebugMsg(( "cv_write_type(%Xh, ref=%X): FIELDLIST, size=%u\n", GetTPos(), currtype-1, size ));
    pt += sizeof( struct cv_typerec_fieldlist );

    /* add the struct's members to the fieldlist */
    for ( i = cnt, curr = type->e.structinfo->head; i; curr = curr->next, i-- ) {
        typelen = 0;
        if ( curr->sym->offset >= 0x8000 )
            typelen += sizeof( uint_32 );
        size = ( sizeof( struct cv_typerec_member ) + typelen + 1 + curr->sym->name_size + 3 ) & ~3;
        pt = checkflush( types, (uint_8 *)CurrSource, pt, size );
        ((struct cv_typerec_member *)pt)->leaf = LF_MEMBER;
        ((struct cv_typerec_member *)pt)->type = GetTyperef( curr->sym, USE16 );
        ((struct cv_typerec_member *)pt)->attribute.access = CV_ATTR_ACC_PUBLIC;
        ((struct cv_typerec_member *)pt)->attribute.mprop = CV_ATTR_MPR_VANILLA;
        ((struct cv_typerec_member *)pt)->attribute.pseudo = 0;
        ((struct cv_typerec_member *)pt)->attribute.noinherit = 0;
        ((struct cv_typerec_member *)pt)->attribute.noconstruct = 0;
        ((struct cv_typerec_member *)pt)->attribute.reserved = 0;
        if ( typelen == 0 ) {
            if ( type->sym.typekind == TYPE_RECORD )
                ((struct cv_typerec_member *)pt)->offset = 0;
            else
                ((struct cv_typerec_member *)pt)->offset = curr->sym->offset;
            tmp = pt + sizeof( struct cv_typerec_member );
        } else {
            ((struct cv_typerec_member *)pt)->offset = LF_ULONG;
            tmp = pt + sizeof( struct cv_typerec_member );
            *(uint_32 *)tmp = curr->sym->offset;
            tmp += sizeof( uint_32 );
        }
        DebugMsg(( "cv_write_type(%Xh): MEMBER=%s, typeref=%X\n", GetTPos(), curr->sym->name, ((struct cv_typerec_member *)pt)->type ));
        SetPrefixName( tmp, curr->sym->name, curr->sym->name_size );
        PadBytes( tmp, (uint_8 *)CurrSource );
        pt += size;
    }

    return( pt );
}