Esempio n. 1
0
void DumpTemplateInfo( TEMPLATE_INFO *tinfo )
{
    TEMPLATE_SPECIALIZATION *tprimary;
    VBUF prefix, suffix;
    int i;
    char delim;

    tprimary = RingFirst( tinfo->specializations );
    printf( "    TEMPLATE_INFO" F_BADDR
            " defn"         F_PTR
            " num_args"     F_HEX_4
                            F_EOL
          , tinfo
          , tprimary->defn
          , tprimary->num_args
          );
    printf( "      %s", NameStr( tinfo->sym->name->name ) );
    delim = '<';
    for( i = 0; i < tprimary->num_args; ++i ) {
        FormatType( tprimary->type_list[i], &prefix, &suffix );
        printf( "%c %s<id> %s", delim, VbufString( &prefix ), VbufString( &suffix ) );
        VbufFree( &prefix );
        VbufFree( &suffix );
        delim = ',';
    }
    printf( ">\n" );
}
Esempio n. 2
0
void PrintFullType(             // PRINT FULL TYPE INFORMATION
    TYPE tp )                   // - type pointer
{
    VBUF prefix, suffix;

    FormatType( tp, &prefix, &suffix );
    printf( "     Type" F_BADDR ": %s<id> %s" F_EOL, tp, VbufString( &prefix ), VbufString( &suffix ) );
    VbufFree( &prefix );
    VbufFree( &suffix );
}
Esempio n. 3
0
static void handleOptionFC( OPT_STORAGE *data, int value )
{
    value = value;
    if( data->fc ) {
        data->fc = FALSE;
        if( CompFlags.batch_file_primary ) {
            if( CompFlags.batch_file_processing ) {
                BadCmdLine( ERR_FC_IN_BATCH_FILE );
            } else {
                BadCmdLine( ERR_FC_MORE_THAN_ONCE );
            }
        } else {
            CompFlags.batch_file_primary = TRUE;
            if( CompFlags.batch_file_processing ) {
                VBUF buf;
                if( CmdLnBatchRead( &buf ) ) {
                    CmdLnCtxPush( CTX_CLTYPE_FC );
                    procOptions( data, VbufString( &buf ) );
                    CmdLnCtxPop();
                }
                CmdLnBatchFreeRecord( &buf );
            } else {
                CmdLnBatchOpen( data->fc_value->data );
                CMemFreePtr( &data->fc_value );
            }
        }
    }
}
Esempio n. 4
0
static void statsPrint(         // PRINT STATISTICS
    INITFINI* defn )            // - definition
{
    defn = defn;
    if( CompFlags.stats_printed ) {
        return;
    }
    if( CompFlags.quiet_mode ) {
        return;
    }
    if( ! CompFlags.srcfile_compiled ) {
        return;
    }
    if( WholeFName != NULL ) {
        VBUF buffer;
        VbufInit( &buffer );
        VbufConcStr( &buffer, WholeFName );
        VbufConcStr( &buffer, ": " );
        intPrint( &buffer, "line", ", ", SrcLineCount );
        if( IncLineCount != 0 ) {
            VbufConcStr( &buffer, "included " );
            VbufConcDecimal( &buffer, IncLineCount );
            VbufConcStr( &buffer, ", " );
        }
        intPrint( &buffer, "warning", ", ", WngCount );
        intPrint( &buffer, "error", "", ErrCount );
        MsgDisplayLine( VbufString( &buffer ) );
        CompFlags.stats_printed = 1;
        VbufFree( &buffer );
    }
}
Esempio n. 5
0
static void printArgs( arg_list *args )
/*************************************/
{
    int i;
    VBUF prefix, suffix, flags;

    FormatTypeModFlags( args->qualifier, &flags );
    printf( "    'this qualifier': '%s'\n", VbufString( &flags ) );
    VbufFree( &flags );
    for( i = 0 ; i < args->num_args ; i++ ) {
        FormatType( args->type_list[i], &prefix, &suffix );
        printf( "    [%d]: '%s<id> %s'\n", i+1, VbufString( &prefix ), VbufString( &suffix ) );
        VbufFree( &prefix );
        VbufFree( &suffix );
    }
}
Esempio n. 6
0
void FormatScope( SCOPE scope, VBUF *pvbuf, bool include_function )
/*****************************************************************/
// include_function - if true, include function scope resolution in formatting
//                  - else terminate scope resolution at function
{
    VbufInit( pvbuf );
    fmtSymScope( scope, pvbuf, include_function );
    strrev( VbufString( pvbuf ) );
}
Esempio n. 7
0
static void doFormatSym( SYMBOL sym, VBUF *pvbuf, FMT_CONTROL control )
{
    VbufInit( pvbuf );
    if( sym == NULL ) {
        VbufConcStr( pvbuf, nullSymbol );
    } else {
        formatScopedSym( sym, pvbuf, control );
        strrev( VbufString( pvbuf ) );
    }
}
Esempio n. 8
0
static char *doFormatSym( SYMBOL sym, VBUF *pvbuf, FMT_CONTROL control )
{
    VbufInit( pvbuf );
    if( sym == NULL ) {
        VbufConcStr( pvbuf, nullSymbol );
        return( VbufString( pvbuf ) );
    } else {
        return( strrev( formatScopedSym( sym, pvbuf, control ) ) );
    }
}
Esempio n. 9
0
char *DbgSymNameFull(           // GET FULL SYMBOL NAME
    SYMBOL sym,                 // - symbol
    VBUF *vbuf )                // - variable-sized buffer
{
    if( sym != NULL ) {
        return( FormatSym( sym, vbuf ) );
    }
    VbufInit( vbuf );
    VbufConcStr( vbuf, "**NULL**" );
    return( VbufString( vbuf ) );
}
Esempio n. 10
0
static void pragError(          // #PRAGMA ERROR
    void )
{
    VBUF str;

    if( CurToken == T_STRING ) {
        PPCTL_ENABLE_MACROS();
        collectStrings( &str );
        CErr2p( ERR_USER_ERROR_MSG, VbufString( &str ) );
        VbufFree( &str );
        PPCTL_DISABLE_MACROS();
    }
}
Esempio n. 11
0
void DumpTemplateSpecialization(// DUMP A TEMPLATE SPECIALIZATION
    TEMPLATE_SPECIALIZATION *tspec )// - template specialization
{
    TEMPLATE_INFO *tinfo = tspec->tinfo;
    VBUF vbuf;                  // - variable-sized buffer

    FormatTemplateSpecialization( tspec, &vbuf );
    printf( "    TEMPLATE_SPECIALIZATION" F_BADDR
            " tinfo"        F_BADDR
                            F_EOL
            , tspec, tinfo );
    printf( "      %s\n", VbufString( &vbuf ) );
    VbufFree( &vbuf );
}
Esempio n. 12
0
char *FormatName( NAME name, VBUF *pvbuf )
/****************************************/
{
    VBUF    prefix;
    bool    ctordtor;

    VbufInit( pvbuf );
    VbufInit( &prefix );
    ctordtor = fmtSymName( NULL, name, &prefix, pvbuf, FF_NULL );
    if( !ctordtor ) {
        VbufConcVbuf( pvbuf, &prefix );
    }
    VbufFree( &prefix );
    return( strrev( VbufString( pvbuf ) ) );
}
Esempio n. 13
0
static PC_SEGMENT *addDefSeg(   // ADD A DEFAULT PC SEGMENT
    DEF_SEG *def_seg,           // - default segment info.
    unsigned ads_control )      // - control mask
{
    unsigned attrs;             // - attributes for segment
    PC_SEGMENT *curr;           // - segment pointer
    VBUF seg_name;              // - virtual buffer for name
    unsigned sa_control;        // - segmentAlloc control mask

    VbufInit( &seg_name );
    ++def_seg->ctr;
    sa_control = SA_NULL;
    if( ads_control & ADS_MODULE_PREFIX ) {
        if(( ads_control & ADS_CODE_SEGMENT ) == 0 && DataSegName[0] != '\0' ) {
            VbufConcStr( &seg_name, DataSegName );
        } else {
            VbufConcStr( &seg_name, ModuleName );
        }
        sa_control |= SA_MODULE_PREFIX;
    }
    if( ads_control & ADS_STRING_SEGMENT ) {
        sa_control |= SA_DEFINE_ANYTIME;
    }
    VbufConcStr( &seg_name, def_seg->pcseg->name );
    if( ads_control & ADS_ZM_SEGMENT ) {
        VbufConcDecimal( &seg_name, def_seg->ctr );
    }
    if( def_seg == &code_def_seg ) {
        attrs = SGAT_CODE_GEN;
    } else {
        if( ads_control & ADS_CONST_SEGMENT ) {
            attrs = SGAT_DATA_PRIVATE_RO;
        } else {
            attrs = SGAT_DATA_PRIVATE_RW;
        }
        VbufConcDecimal( &seg_name, def_seg->ctr );
    }
    curr = segmentAlloc( VbufString( &seg_name ), NULL, SEG_NULL, attrs, sa_control );
    if( 0 == ( attrs & EXEC ) ) {
        _markUsed( curr, TRUE );
    }
    if( ads_control & ADS_STRING_SEGMENT ) {
        curr->only_strings = TRUE;
    }
    VbufFree( &seg_name );
    return( curr );
}
Esempio n. 14
0
static void pragMessage(        // #PRAGMA MESSAGE
    void )
{
    VBUF str;

    if( ExpectingToken( T_LEFT_PAREN ) ) {
        PPCTL_ENABLE_MACROS();
        NextToken();
        if( CurToken == T_STRING ) {
            collectStrings( &str );
            CErr2p( WARN_USER_WARNING_MSG, VbufString( &str ) );
            VbufFree( &str );
        }
        PPCTL_DISABLE_MACROS();
        MustRecog( T_RIGHT_PAREN );
    }
}
Esempio n. 15
0
void MsgDisplayLineArgs         // DISPLAY A BARE LINE, FROM ARGUMENTS
    ( char* seg                 // - the line segments
    , ... )
{
    va_list args;               // - arg list
    char* str;                  // - current segment
    VBUF buffer;                // - buffer

    VbufInit( &buffer );
    va_start( args, seg );
    for( str = seg; str != NULL; str = va_arg( args, char* ) ) {
        VbufConcStr( &buffer, str );
    }
    ideDisplay( IDEMSGSEV_NOTE_MSG, 0, VbufString( &buffer ), NULL );
    va_end( args );
    VbufFree( &buffer );
}
Esempio n. 16
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 );
}
Esempio n. 17
0
void PrintFnovResolution( FNOV_RESULT result, arg_list *args,
/***********************************************************/
    FNOV_LIST *match, FNOV_LIST *reject, SYMBOL sym )
// pseudo pretty display of overloaded ranking information
{
    int         length;
    VBUF        name;

    if( sym != NULL ) {
        FormatSym( sym, &name );
    } else if( match != NULL ) {
        FormatSym( match->sym, &name );
    } else if( reject != NULL ) {
        FormatSym( reject->sym, &name );
    } else {
        VbufInit( &name );
    }
    printf( " Result: %s\n", resultNames[result] );
    if( VbufLen( &name ) > 0 ) {
        printf( "Symbol: '%s'", VbufString( &name ) );
        VbufFree( &name );
        length = RingCount( match ) + RingCount( reject );
        if( length > 0 ) {
            printf( " occurs %d time%s",
                    length,
                    (length != 1 ? "s " : " " ) );
        }
    }
    printf( "\n" );

    if( sym == NULL && args != NULL ) {
        printf( "Ranked Arguments:\n" );
        printArgs( args );
    }
    if( match != NULL ) {
        printf( "Matching Functions:\n" );
        PrintFnovList( match );
    }
    if( reject != NULL ) {
        printf( "Rejected Functions:\n" );
        PrintFnovList( reject );
    }
}
Esempio n. 18
0
static char *formatScopedSym( SYMBOL sym, VBUF *pvbuf, FMT_CONTROL control )
/**************************************************************************/
{
    VBUF    prefix;
    bool    ctordtor;

    VbufInit( &prefix );
    if( sym->name == NULL ) {
        ctordtor = fmtSymName( sym, NULL, &prefix, pvbuf, control );
    } else {
        ctordtor = fmtSymName( sym, sym->name->name, &prefix, pvbuf, control );
    }
    if( !SymIsAnonymous( sym ) ) {
        fmtSymScope( SymScope( sym ), pvbuf, true );
    }
    if( !ctordtor ) {
        VbufConcVbuf( pvbuf, &prefix );
    }
    VbufFree( &prefix );
    return( VbufString( pvbuf ) );
}
Esempio n. 19
0
static void processCmdFile(     // PROCESS A COMMAND FILE
    OPT_STORAGE *data )         // - option data
{
    VBUF rec;                   // - record for file
    int c;                      // - next character

    VbufInit( &rec );
    for(;;) {
        for(;;) {
            c = NextChar();
            if( c == LCHR_EOF ) break;
            if( c == '\n' ) break;
            if( c == '\r' ) break;
            VbufConcChr( &rec, (char)c );
        }
        procOptions( data, VbufString( &rec ) );
        for( ; ( c == '\n' ) || ( c == '\r' ); c = NextChar() );
        if( c == LCHR_EOF ) break;
        VbufRewind( &rec );
        VbufConcChr( &rec, (char)c );
    }
    VbufFree( &rec );
}
Esempio n. 20
0
static void vbufWrite(          // WRITE A VBUFFER
    VBUF* vbuf )                // - the VBUF to be written
{
    MsgDisplayLine( VbufString( vbuf ) );
}
Esempio n. 21
0
void MsgDisplay                 // DISPLAY A MESSAGE
    ( IDEMsgSeverity severity   // - message severity
    , MSG_NUM msgnum            // - message number
    , va_list args )            // - substitution arguments
{

    VBUF buffer;                // - formatting buffer
    SYMBOL sym;                 // - sym requiring location
    TOKEN_LOCN prt_locn;        // - print location
    TOKEN_LOCN *msg_locn;       // - message location
    CTX context;                // - current context
    void *inf;                  // - information about context
    char *inf_prefix;           // - prefix for information
    boolean context_changed;    // - TRUE ==> new context from last time

    context_changed = CtxCurrent( &context, &inf, &inf_prefix );
    setMsgLocation( context );
    prt_locn = err_locn;
    ++reserveDepth;
    VbufInit( &buffer );
    sym = msgBuild( msgnum, args, &buffer );
    switch( severity ) {
      case IDEMSGSEV_ERROR :
      case IDEMSGSEV_WARNING :
        if( CompFlags.ew_switch_used ) {
            switch( context ) {
              case CTX_INIT :
              case CTX_FINI :
              case CTX_CMDLN_VALID :
              case CTX_CG_OPT :
              case CTX_ENDFILE :
                if( context_changed ) {
                    fmt_inf_hdr( inf_prefix );
                }
                break;
              case CTX_CMDLN_ENV :
              case CTX_CMDLN_PGM :
                if( context_changed ) {
                    fmt_inf_hdr_switch( inf_prefix, inf );
                }
                break;
              case CTX_CG_FUNC :
              case CTX_FUNC_GEN :
                if( context_changed ) {
                    fmt_inf_hdr_sym( inf_prefix, inf );
                }
                break;
              case CTX_FORCED_INCS :
              case CTX_SOURCE :
                build_file_nesting();
                break;
              DbgDefault( "Unexpected message context" );
            }
        }
        msg_locn = &prt_locn;
        break;
      case IDEMSGSEV_NOTE :
      case IDEMSGSEV_NOTE_MSG :
        msg_locn = &notes_locn;
        break;
      default :
        msg_locn = NULL;
        break;
    }
    ideDisplay( severity
              , msgnum
              , VbufString( &buffer )
              , msg_locn );
    if( context_changed
     && ! CompFlags.ew_switch_used
     && ( severity == IDEMSGSEV_ERROR
       || severity == IDEMSGSEV_WARNING )
     && ( context == CTX_SOURCE
       || context == CTX_FORCED_INCS )
      ) {
        build_file_nesting();
    }
    VbufFree( &buffer );
    --reserveDepth;
    if( NULL != sym ) {
        notes_locn = sym->locn->tl;
        MsgDisplayArgs( IDEMSGSEV_NOTE
                      , SymIsFunctionTemplateModel( sym )
                            ? INF_TEMPLATE_FN_DECL : INF_SYMBOL_DECLARATION
                      , sym
                      , &sym->locn->tl );
    }
}
Esempio n. 22
0
void DumpCgFront(               // DUMP GENERATED CODE
    const char *prefix,         // - name added to print line
    DISK_ADDR disk_blk,         // - disk block
    DISK_OFFSET offset,         // - disk offset
    void *instruction )         // - intermediate code
{
    CGINTER *ins;               // - instruction
    char *opcode;               // - opcode
    unsigned uvalue;            // - value with opcode
    VBUF vbuf;

    ins = instruction;
    opcode = DbgIcOpcode( ins->opcode );
    if( ins->opcode == IC_EOF ) {
        uvalue = 0;
    } else {
        uvalue = ins->value.uvalue;
    }
    switch( optypes[ ins->opcode ] ) {
      case DBG_OPCODE_SYM :
        printf(                 F_NAME
                " "             F_BUF_FMT
                " "             F_INSTR
                " "             F_HEX_4
                " "             F_NAME F_EOL
              , prefix
              , disk_blk, offset
              , opcode
              , uvalue
              , DbgSymNameFull( ins->value.pvalue, &vbuf ) );
        VbufFree( &vbuf );
        break;
      case DBG_OPCODE_TYP :
      { VBUF fmt_prefix, fmt_suffix;
        FormatType( ins->value.pvalue, &fmt_prefix, &fmt_suffix );
        printf(                 F_NAME
                " "             F_BUF_FMT
                " "             F_INSTR
                " "             F_HEX_4
                " %s<id>%s" F_EOL
              , prefix
              , disk_blk, offset
              , opcode
              , uvalue
              , VbufString( &fmt_prefix )
              , VbufString( &fmt_suffix ) );
        VbufFree( &fmt_prefix );
        VbufFree( &fmt_suffix );
      } break;
      case DBG_OPCODE_NUL :
        printf(                 F_NAME
                " "             F_BUF_FMT
                " "             F_INSTR F_EOL
              , prefix
              , disk_blk, offset
              , opcode );
        break;
      case DBG_OPCODE_SRC :
      {
        printf(                 F_EOL F_NAME
                " "             F_BUF_FMT
                " "             F_INSTR
                " "             F_NAME F_EOL
              , prefix
              , disk_blk, offset
              , opcode
              , SrcFileFullName( ins->value.pvalue ) );
      } break;
      case DBG_OPCODE_SCP :
        printf(                 F_NAME
                " "             F_BUF_FMT
                " "             F_INSTR
                " "             "scope: " F_HEX F_EOL
              , prefix
              , disk_blk, offset
              , opcode
              , uvalue );
        break;
      case DBG_OPCODE_STR :
      case DBG_OPCODE_CON :
      case DBG_OPCODE_BIN :
        switch( ins->opcode ) {
          case IC_OPR_BINARY :
          case IC_OPR_UNARY :
            printf(                 F_NAME
                    " "             F_BUF_FMT
                    " "             F_INSTR
                    " "             F_NAME F_EOL
                  , prefix
                  , disk_blk, offset
                  , opcode
                  , DbgOperator( ins->value.uvalue ) );
            break;
          case IC_DBG_LINE :
            printf(                 F_NAME
                    " "             F_BUF_FMT
                    " "             F_INSTR
                    " "             F_DECIMAL F_EOL F_EOL
                  , prefix
                  , disk_blk, offset
                  , opcode
                  , uvalue );
            break;
          default :
            printf(                 F_NAME
                    " "             F_BUF_FMT
                    " "             F_INSTR
                    " "             F_HEX F_EOL
                  , prefix
                  , disk_blk, offset
                  , opcode
                  , uvalue );
            break;
        }
        break;
      default :
        CFatal( "**** UNDEFINED OPCODE TYPE *****" );
        break;
    }
}