Exemplo n.º 1
0
bool CtxCurrent(                // GET CURRENT CONTEXT
    CTX *a_context,             // - addr[ current context ]
    void const **a_data,              // - addr[ ptr to data for context ]
    char const **a_prefix )     // - addr[ prefix for header line in error ]
{
    bool retn;                  // - TRUE ==> context changed from last time
    void const *data;           // - current data

    *a_context = context;
    *a_prefix = ctx_names[ context ];
    switch( context ) {
      case CTX_INIT :
      case CTX_FINI :
      case CTX_CMDLN_VALID :
      case CTX_FORCED_INCS :
      case CTX_SOURCE :
      case CTX_CG_OPT :
      case CTX_ENDFILE:
        data = NULL;
        break;
      case CTX_CMDLN_ENV :
      case CTX_CMDLN_PGM :
        data = CtxGetSwitchAddr();
        break;
      case CTX_CG_FUNC :
      case CTX_FUNC_GEN :
        data = func;
        break;
    }
    retn = ( context != last_context ) || ( data != last_data );
    last_data = data;
    *a_data = data;
    last_context = context;
    return retn;
}
Exemplo n.º 2
0
static CTX_CL* cmdLnCtxAlloc(   // ALLOCATE NEW CONTEXT
    CTX_CLTYPE type )           // - type of context
{
    CTX_CL* entry;

    entry = VstkPush( &cmdLnContexts );
    entry->base.ctx_type = type;
    entry->base.sw_ptr = NULL;
    if( type == CTX_CLTYPE_PGM ) {
        entry->base.cmd_line = NULL;
        entry->base.cmd_scan = NULL;
    } else {
        entry->base.cmd_line = CmdScanAddr();
        entry->base.cmd_scan = CtxGetSwitchAddr();
    }
    return entry;
}
Exemplo n.º 3
0
void *CtxWhereAreYou(           // SET DEBUGGING BUFFER
    void )
{
    char *buf;                  // - points into buffer

    buf = stpcpy( CompilerContext, ctx_names[ context ] );
    switch( context ) {
      case CTX_CMDLN_ENV :
      case CTX_CMDLN_PGM :
        buf = stpcpy( buf, ": " );
        buf = stpcpy( buf, CtxGetSwitchAddr() );
        break;
      case CTX_FORCED_INCS :
      case CTX_SOURCE :
        if( location.src_file == NULL ) break;
        buf = stpcpy( buf, ": " );
        buf = stpcpy( buf, SrcFileName( location.src_file ) );
        buf = stpcpy( buf, "(" );
        buf = stdcpy( buf, location.line );
        buf = stpcpy( buf, "," );
        buf = stdcpy( buf, location.column );
        buf = stpcpy( buf, ")" );
        break;
      case CTX_CG_FUNC :
      case CTX_FUNC_GEN :
        buf = stpcpy( buf, ": " );
        if( func == NULL ) {
            buf = stpcpy( buf, "data generation" );
        } else {
            VBUF vbuf;
            buf = stpcpy( buf, DbgSymNameFull( func, &vbuf ) );
            VbufFree( &vbuf );
        }
        if( ( context == CTX_FUNC_GEN )
          &&( line != 0 ) ) {
            buf = stpcpy( buf, "(" );
            buf = stdcpy( buf, location.line );
            buf = stpcpy( buf, ")" );
        }
        break;
    }
    return CompilerContext;
}