Beispiel #1
0
long GetStructSize (SymTable* Struct)
/* Get the size of a struct or union */
{
    SymEntry* SizeSym = FindSizeOfScope (Struct);
    if (SizeSym == 0) {
        Error ("Size of struct/union is unknown");
        return 0;
    } else {
        return GetSymVal (SizeSym);
    }
}
Beispiel #2
0
void WriteScopes (void)
/* Write the scope table to the object file */
{
    /* Tell the object file module that we're about to start the scopes */
    ObjStartScopes ();

    /* We will write scopes only if debug symbols are requested */
    if (DbgSyms) {

        /* Get head of list */
        SymTable* S = RootScope;

        /* Write the scope count to the file */
        ObjWriteVar (ScopeCount);

        /* Walk through all scopes and write them to the file */
        while (S) {

            /* Flags for this scope */
            unsigned Flags = 0;

            /* Check if this scope has a size. If so, remember it in the
            ** flags.
            */
            long Size;
            SymEntry* SizeSym = FindSizeOfScope (S);
            if (SizeSym != 0 && SymIsConst (SizeSym, &Size)) {
                Flags |= SCOPE_SIZE;
            }

            /* Check if the scope has a label */
            if (S->Label) {
                Flags |= SCOPE_LABELED;
            }

            /* Scope must be defined */
            CHECK (S->Type != SCOPE_UNDEF);

            /* Id of parent scope */
            if (S->Parent) {
                ObjWriteVar (S->Parent->Id);
            } else {
                ObjWriteVar (0);
            }

            /* Lexical level */
            ObjWriteVar (S->Level);

            /* Scope flags */
            ObjWriteVar (Flags);

            /* Type of scope */
            ObjWriteVar (S->Type);

            /* Name of the scope */
            ObjWriteVar (S->Name);

            /* If the scope has a size, write it to the file */
            if (SCOPE_HAS_SIZE (Flags)) {
                ObjWriteVar (Size);
            }

            /* If the scope has a label, write its id to the file */
            if (SCOPE_HAS_LABEL (Flags)) {
                ObjWriteVar (S->Label->DebugSymId);
            }

            /* Spans for this scope */
            WriteSpanList (&S->Spans);

            /* Next scope */
            S = S->Next;
        }

    } else {

        /* No debug info requested */
        ObjWriteVar (0);

    }

    /* Done writing the scopes */
    ObjEndScopes ();
}