Ejemplo n.º 1
0
void CmdLnCtxSwitch(            // RECORD SWITCH POSITION
    char const * sw_ptr )       // - current switch location
{
    CTX_CL* entry;              // - new entry

    entry = VstkTop( &cmdLnContexts );
    entry->base.sw_ptr = (char *)sw_ptr;
}
Ejemplo n.º 2
0
void SymTransEmpty(             // DEBUG: VERIFY SYMBOL TRANSLATIONS OVER
    void )
{
    DbgVerify( NULL == VstkTop( &stack_sym_trans )
             , "SymTransEmpty -- stack not empty" );
    DbgVerify( 0 == sym_trans_id
             , "SymTransEmpty -- id != 0" );
}
Ejemplo n.º 3
0
void CgSwitchEnd                // GENERATE CODE FOR END OF SWITCH STMT
    ( void )
{
    SW_CTL *ctl;                // - control for switch

    ctl = VstkTop( &stack_switches );
    CgLabel( ctl->label );
    CGSelect( ctl->id, CgFetchTemp( ctl->temp, ctl->type ) );
    BEFiniLabel( ctl->label );
    VstkPop( &stack_switches );
    CgLabelsPop( &stack_labs_sw, ctl->cases );
}
Ejemplo n.º 4
0
void SymTransFuncEnd(           // COMPLETE FUNCTION TRANSLATION
    FN_CTL* fctl )              // - function control
{
    SYM_TRANS* top;             // - top translation

    sym_trans_id = fctl->sym_trans_id;
    for( ; ; VstkPop( &stack_sym_trans ) ) {
        top = VstkTop( &stack_sym_trans );
        if( top == NULL ) break;
        if( top->id < sym_trans_id ) break;
        dump( "freed", top );
    }
}
Ejemplo n.º 5
0
void *VstkBase(                 // GET BASE ELEMENT
    VSTK_CTL *stack,            // - stack to be based
    int base )                  // - the base index
{
    void *cur;                  // - current element

    -- base;
    if( base >= VstkDimension( stack ) ) {
        cur = VstkTop( stack );
    } else {
        cur = VstkIndex( stack, base );
    }
    return( cur );
}
Ejemplo n.º 6
0
static DUMP_INFO* dumpParentage( // DUMP PARENTAGE
    DUMP_INFO* di )             // - dump information
{
    char**daughter;             // - daughter class

    for( daughter = VstkTop( &di->stack ); ; ) {
        daughter = VstkNext( &di->stack, daughter );
        if( daughter == NULL ) break;
        di = bufferInit( di );
        di = bufferStr( di, "base of: " );
        di = bufferStr( di, *daughter );
        di = bufferWrite( di );
    }
    return di;
}
Ejemplo n.º 7
0
boolean CgExprPopGarbage(       // POP EXPR STACK IF TOP EXPR IS GARBAGE
    void )
{
    CGEXPR* top;                // - top of stack
    boolean retn;               // - TRUE ==> garbage was popped

    top = VstkTop( &expressions );
    if( top == NULL ) {
        retn = TRUE;
    } else if( top->garbage ) {
        VstkPop( &expressions );
        retn = TRUE;
    } else {
        retn = FALSE;
    }
    return retn;
}
Ejemplo n.º 8
0
void CmdLnCtxInfo(              // PRINT CONTEXT INFO
    void )
{
    CTX_CL* entry;              // - current entry
    VBUF buf;                   // - buffer

    VbufInit( &buf );
    for( entry = VstkTop( &cmdLnContexts )
       ; entry != NULL
       ; entry = VstkNext( &cmdLnContexts, entry ) ) {
        VbufRewind( &buf );
        switch( entry->base.ctx_type ) {
          case CTX_CLTYPE_ENV :
            VbufConcChr( &buf, '@' );
            VbufConcStr( &buf, entry->env.var );
            break;
          case CTX_CLTYPE_FC :
            VbufConcStr( &buf, "batch file of commands, line " );
            VbufConcDecimal( &buf, CompInfo.fc_file_line );
            break;
          case CTX_CLTYPE_PGM :
            VbufConcStr( &buf, "command line" );
            break;
          case CTX_CLTYPE_FILE :
            VbufConcStr( &buf, SrcFileFullName( entry->file.source ) );
            break;
          DbgDefault( "bad command-line context" );
        }
        if( entry->base.sw_ptr != NULL ) {
            size_t size;
            char const * not_used;
            char const* old = CmdScanAddr();
            CmdScanInit( entry->base.sw_ptr );
            CmdScanChar();
            size = CmdScanOption( &not_used ) + 1;
            CmdScanInit( old );
            VbufConcStr( &buf, ", switch: " );
            for( old = entry->base.sw_ptr; size > 0; ++old, --size ) {
                VbufConcChr( &buf, *old );
            }
        }
        InfMsgPtr( INF_SWITCH, VbufString( &buf ) );
    }
    VbufFree( &buf );
}
Ejemplo n.º 9
0
void* SymTrans(                 // TRANSLATE SYMBOL/SCOPE
    void *src )                 // - source value
{
    SYM_TRANS *tr;              // - translation element (current)
    unsigned bound;             // - bounding id

    bound = FnCtlTop()->sym_trans_id;
    for( tr = VstkTop( &stack_sym_trans )
       ; tr != NULL && bound <= tr->id
       ; tr = VstkNext( &stack_sym_trans, tr ) ) {
        if( src == tr->src ) {
            src = tr->tgt;
            dump( "used", tr );
            break;
        }
    }
    return( src );
}
Ejemplo n.º 10
0
static void reportOnType        // SET UP TYPE REFERENCE
( SRCFILE curr              // - current source file
  , TYPE type                 // - a type
  , SYMBOL sym )              // - symbol for type
{
    if( NULL != sym && ( SF2_TOKEN_LOCN & sym->flag2 ) ) {
        SRCFILE refed = sym->locn->tl.src_file;
        if( curr != refed ) {
            REPO_STAT* repo = reposStat( curr );
            TYPE* last;
            for( last = VstkTop( &repo->typeset ); ; last = VstkNext( &repo->typeset, last ) ) {
                if( NULL == last ) {
                    *(TYPE*)VstkPush( &repo->typeset ) = type;
                    break;
                }
                if( type == *last ) break;
            }
        }
    }
}
Ejemplo n.º 11
0
void CallIndirectVirtual(       // MARK INDIRECT CALL AS VIRTUAL
    SYMBOL vfunc,               // - the virtual function
    boolean is_virtual,         // - TRUE ==> an actual virtual call
    target_offset_t adj_this,   // - adjustment for "this"
    target_offset_t adj_retn )  // - adjustment for return
{
    CALL_STK* cstk;             // - top of call stack
    SYMBOL virt_fun;            // - dummy symbol for virtual call

    vfunc = vfunc;
    if( is_virtual ) {
        virt_fun = ind_call_stack;
        virt_fun->id = SC_VIRTUAL_FUNCTION;
        virt_fun->u.virt_fun = vfunc;
    } else {
        cstk = VstkTop( &stack_calls );
        DbgVerify( cstk != NULL, "CallIndirectVirtual -- no call stack" );
        cstk->adj_this = adj_this;
        cstk->adj_retn = adj_retn;
    }
}
Ejemplo n.º 12
0
static REPO_STAT* reposStat     // GET REPOSITORY STATISTICS FOR SRCFILE
    ( SRCFILE sf )              // - the source file
{
    REPO_STAT** last;           // - addr[ REPO_STAT ]
    REPO_STAT* retn;            // - REPO_STAT for source file

    for( last = VstkTop( &srcFiles ); ; last = VstkNext( &srcFiles, last ) ) {
        if( NULL == last ) {
            retn = CarveAlloc( carve_sf );
            *(REPO_STAT**)VstkPush( &srcFiles ) = retn;
            VstkOpen( &retn->refset, sizeof( SYMBOL ), 32 );
            VstkOpen( &retn->typeset, sizeof( TYPE ), 32 );
            retn->srcfile = sf;
            retn->defns = 0;
            break;
        }
        retn = *last;
        if( sf == retn->srcfile ) break;
    }
    return retn;
}
Ejemplo n.º 13
0
void ExtraRptSymUsage(          // REPORT SYMBOL USAGE FROM PRIMARY SOURCE
    SYMBOL sym )
{
    extraRptTypeUsage( sym->sym_type );
    if( isReposSym( sym ) ) {
        SRCFILE current = SrcFileCurrent();
        SRCFILE refed = sym->locn->tl.src_file;
        if( current != refed ) {
            REPO_STAT* repo = reposStat( current );
            SYMBOL* last;
            for( last = VstkTop( &repo->refset )
               ;
               ; last = VstkNext( &repo->refset, last ) ) {
                if( NULL == last ) {
                    *(SYMBOL*)VstkPush( &repo->refset ) = sym;
                    break;
                }
                if( sym == *last ) break;
            }
        }
    }
}
Ejemplo n.º 14
0
static void dumpPTreeNode(      // DUMP A PARSE TREE NODE
    PTREE node )                // - node in parse tree
{
    static char buffer[128];    // - debugging buffer
    char *node_name;            // - name of node
    VSTK_CTL ctl;               // - VSTK control information (nodes)
    VSTK_CTL dup;               // - VSTK control information (duplicates)
    int dup_out;                // - last duplicate printed

    VstkOpen( &ctl, sizeof( PTREE ), 32 );
    VstkOpen( &dup, sizeof( PTREE ), 8 );
    dup_out = -1;
    for( ; ; ) {
        switch( node->op ) {
          case PT_ERROR :
            printf( "PT_ERROR"      F_BADDR
                    " ***** ERROR TREE *****" F_EOL
                  , node
                  );
            break;
          case PT_INT_CONSTANT :
            node_name = "PT_INT_CONSTANT";
            printf( F_NAME          F_BADDR
                    " flags"        F_HEX_4
                    " type"         F_PTR
                  , node_name
                  , node
                  , node->flags
                  , node->type
                  );
            if( NULL == Integral64Type( node->type ) ) {
                printf( " integer"      F_HEX_4
                      , node->u.int_constant
                      );
            } else {
                printf( " integer-64" F_S64
                      , VAL64( node->u.int64_constant )
                      );
            }
            dumpNodeType( node );
            dumpLocation( &node->locn );
            dumpPtreeFlags( node );
            break;
          case PT_FLOATING_CONSTANT : {
            char buffer[256];

            BFCnvFS( node->u.floating_constant, buffer, 256 );
            printf( "PT_FLOATING_CONSTANT" F_BADDR
                    " flags"        F_HEX_4
                    " float"        F_CPP_FLOAT
                  , node
                  , node->flags
                  , buffer
                  );
            dumpNodeType( node );
            dumpLocation( &node->locn );
            dumpPtreeFlags( node );
          }
            break;
          case PT_STRING_CONSTANT :
            stvcpy( buffer, node->u.string->string, node->u.string->len );
            printf( "PT_STRING_CONSTANT" F_BADDR
                    " flags"        F_HEX_4
                    " string"       F_STRING
                  , node
                  , node->flags
                  , buffer
                  );
            dumpNodeType( node );
            dumpLocation( &node->locn );
            dumpPtreeFlags( node );
            break;
          case PT_ID :
            printf( "PT_ID"         F_BADDR
                    " flags"        F_HEX_4
                    " cgop"         F_STRING F_NL
                    " id"           F_PTR
                    "="             F_STRING
                    " id_cgop"      F_STRING
                    " u.id.scope"   F_PTR
                  , node
                  , node->flags
                  , DbgOperator( node->cgop )
                  , node->u.id.name
                  , NameStr( node->u.id.name )
                  , DbgOperator( node->id_cgop )
                  , node->u.id.scope
                  );
            dumpNodeType( node );
            dumpLocation( &node->locn );
            dumpPtreeFlags( node );
            break;
          case PT_TYPE :
            printf( "PT_TYPE"       F_BADDR
                    " cgop"         F_STRING
                    " flags"        F_HEX_4
                    " next"         F_PTR
                    " scope"        F_PTR
                  , node
                  , DbgOperator( node->cgop )
                  , node->flags
                  , node->u.type.next
                  , node->u.type.scope
                  );
            dumpNodeType( node );
            dumpLocation( &node->locn );
            dumpPtreeFlags( node );
            break;
          case PT_SYMBOL :
            if( node->cgop == CO_NAME_THIS ) {
                printf( "PT_SYMBOL"     F_BADDR
                        " flags"        F_HEX_4
                        " this "
                      , node
                      , node->flags
                      );
                dumpNodeType( node );
                dumpLocation( &node->locn );
                dumpPtreeFlags( node );
            } else if( node->cgop == CO_NAME_CDTOR_EXTRA ) {
                printf( "PT_SYMBOL"     F_BADDR
                        " flags"        F_HEX_4
                        " cdtor_extra_parm "
                      , node
                      , node->flags
                      );
                dumpNodeType( node );
                dumpLocation( &node->locn );
                dumpPtreeFlags( node );
            } else {
                printf( "PT_SYMBOL"     F_BADDR
                        " flags"        F_HEX_4
                        " cgop"         F_STRING F_NL
                        " symbol"       F_PTR
                        " result"       F_PTR
                      , node
                      , node->flags
                      , DbgOperator( node->cgop )
                      , node->u.symcg.symbol
                      , node->u.symcg.result
                      );
                dumpNodeType( node );
                dumpLocation( &node->locn );
                dumpPtreeFlags( node );
                DumpSymbol( node->u.symcg.symbol );
            }
            break;
          case PT_UNARY :
            printf( "PT_UNARY"      F_BADDR
                    F_POINTS        F_ADDR
                    " flags"        F_HEX_4
                    " cgop"         F_STRING
                  , node
                  , node->u.subtree[0]
                  , node->flags
                  , DbgOperator( node->cgop )
                  );
            dumpNodeType( node );
            dumpLocation( &node->locn );
            dumpPtreeFlags( node );
            PUSH_NODE( ctl, node->u.subtree[0] );
            break;
          case PT_BINARY :
            printf( "PT_BINARY"     F_BADDR
                    F_POINTS        F_ADDR
                    ","             F_ADDR
                    " flags"        F_HEX_4
                    " cgop"         F_STRING
                  , node
                  , node->u.subtree[0]
                  , node->u.subtree[1]
                  , node->flags
                  , DbgOperator( node->cgop )
                  );
            dumpNodeType( node );
            dumpLocation( &node->locn );
            dumpPtreeFlags( node );
            PUSH_NODE( ctl, node->u.subtree[1] );
            PUSH_NODE( ctl, node->u.subtree[0] );
            break;
          case PT_DUP_EXPR :
          { PTREE *duped;       // - duplicated expression
            printf( "PT_DUP_EXPR"   F_BADDR
                    F_POINTS        F_ADDR
                    " flags"        F_HEX_4
                    " node"         F_ADDR
                  , node
                  , node->u.dup.subtree[0]
                  , node->flags
                  , node->u.dup.node
                  );
            dumpNodeType( node );
            dumpLocation( &node->locn );
            dumpPtreeFlags( node );
            if( node->u.subtree[0] != NULL ) {
                for( duped = VstkTop( &dup )
                   ;
                   ; duped = VstkNext( &dup, duped ) ) {
                    if( duped == NULL ) {
                        PUSH_NODE( dup, node->u.subtree[0] );
                    } else if( *duped == node->u.subtree[0] ) {
                        break;
                    }
                }
            }
          } break;
          case PT_IC :
            printf( "PT_IC"         F_BADDR
                    " "             F_NAME
                    " value"        F_ADDR
                  , node
                  , DbgIcOpcode( node->u.ic.opcode )
                  , node->u.ic.value.pvalue
                  );
            dumpNodeType( node );
            dumpLocation( &node->locn );
            dumpPtreeFlags( node );
            break;
          default :
            printf( "***INVALID***" F_BADDR
                    " flags"        F_HEX_4
                    " op"           F_HEX_1
                  , node
                  , node->flags
                  , node->op
                  );
            dumpNodeType( node );
            dumpLocation( &node->locn );
            dumpPtreeFlags( node );
            break;
        }
        {
            PTREE *next;            // - addr[next node]
            next = VstkPop( &ctl );
            if( next != NULL ) {
                node = *next;
            } else {
                ++dup_out;
                if( dup_out > VstkDimension( &dup ) ) break;
                next = VstkIndex( &dup, dup_out );
                printf( "--------------- duplicate ------------\n" );
                node = *next;
            }
        }
    }
    VstkClose( &ctl );
    VstkClose( &dup );
}
Ejemplo n.º 15
0
SYMBOL CallStackTopFunction(    // GET FUNCTION FOR TOP OF CALL STACK
    void )
{
    return ((CALL_STK*)VstkTop( &stack_calls ))->func;
}
Ejemplo n.º 16
0
call_handle CallStackTopHandle( // GET HANDLE FOR TOP OF CALL STACK
    void )
{
    return ((CALL_STK*)VstkTop( &stack_calls ))->handle;
}
Ejemplo n.º 17
0
boolean CallStackTopInlined(    // TEST IF TOP OF CALL STACK IS INLINED
    void )
{
    return NULL != ((CALL_STK*)VstkTop( &stack_calls ))->func;
}
Ejemplo n.º 18
0
target_offset_t CallStackRetnType( // GET RETURN TYPE FOR CALL
    void )
{
    return ((CALL_STK*)VstkTop( &stack_calls ))->retn_type;
}
Ejemplo n.º 19
0
target_offset_t CallStackRetnAdj( // GET RETURN ADJUSTMENT FOR VIRTUAL CALL
    void )
{
    return ((CALL_STK*)VstkTop( &stack_calls ))->adj_retn;
}
Ejemplo n.º 20
0
target_offset_t CallStackThisAdj( // GET "THIS" ADJUSTMENT FOR VIRTUAL CALL
    void )
{
    return ((CALL_STK*)VstkTop( &stack_calls ))->adj_this;
}
Ejemplo n.º 21
0
static SW_CTL *switch_ctl(      // GET CURRENT SW_CTL
    void )
{
    return VstkTop( &stack_switches );
}