Пример #1
0
static unsigned MechGet( unsigned select, unsigned parm )
{
    unsigned    result;
    DIPHDL( cue, ch );
    sym_list    *sym;
    address     addr;
    unsigned    old;
    char        *save_scan;
    char        *mod_name;
    unsigned    mod_len;
    unsigned    mod_spec_token;

    result = FALSE;
    switch( select ) {
    case 0: /* init */
        memset( &CurrGet, 0, sizeof( CurrGet ) );
        CurrGet.li.mod = NO_MOD;
        if( _IsOn( SW_CASE_SENSITIVE ) ) {
            CurrGet.li.case_sensitive = TRUE;
        } else {
            CurrGet.li.case_sensitive = FALSE;
        }
        break;
    case 1: /* fini */
        switch( CurrGet.kind ) {
        case GET_NAME:
            PushName( &CurrGet.li );
            break;
        case GET_OPERATOR:
            CurrGet.li.type = ST_OPERATOR;
            PushName( &CurrGet.li );
            break;
        case GET_LNUM:
            switch( FindACue( ch ) ) {
            case SR_EXACT:
                break;
            case SR_CLOSEST:
                if( ClosestLineOk ) break;
            default:
                Error( ERR_NONE, LIT( ERR_NO_CODE ), CurrGet.li.name.len );
            }
            PushAddr( CueAddr( ch ) );
            break;
        }
        break;
    case 2: /* mod curr */
    case 3: /* mod name lookup */
        //NYI: temporary gunk
        CurrGet.multi_module = TRUE;
        CurrGet.li.mod = NO_MOD;
        save_scan = ScanPos();
        ReScan( "@" );
        mod_spec_token = CurrToken;
        ReScan( save_scan );
        if( CurrToken == T_NAME ) {
            mod_name = NamePos();
            mod_len  = NameLen();
            Scan();
        } else {
            mod_name = NULL;
            mod_len = 0;
        }
        if( CurrToken == mod_spec_token ) {
            if( select == 2 ) {
                CurrGet.li.mod = ImagePrimary()->dip_handle;
                if( CurrGet.li.mod == NO_MOD ) {
                    CurrGet.li.mod = ILL_MOD; /* cause lookup to fail */
                }
            } else {
                CurrGet.li.mod = LookupImageName( CurrGet.li.name.start,
                                    CurrGet.li.name.len );
                if( CurrGet.li.mod == NO_MOD ) {
                    #define ANY_IMAGE_NAME      "_anyimage"
                    #define ANY_IMAGE_NAME_LEN  (sizeof(ANY_IMAGE_NAME)-1)
                    if( CurrGet.li.name.len != ANY_IMAGE_NAME_LEN
                      || memicmp( CurrGet.li.name.start, ANY_IMAGE_NAME, ANY_IMAGE_NAME_LEN ) != 0 ) {
                        Error( ERR_NONE, LIT( ERR_NO_IMAGE ), CurrGet.li.name.start,
                                              CurrGet.li.name.len );
                    } else {
                        CurrGet.any_image = TRUE;
                    }
                }
            }
            CurrGet.li.name.start = mod_name;
            CurrGet.li.name.len   = mod_len;
            Scan();
        } else {
            ReScan( save_scan );
        }
        if( CurrGet.li.name.start != NULL ) {
            CurrGet.li.mod = LookupModName( CurrGet.li.mod,
                        CurrGet.li.name.start, CurrGet.li.name.len );
            if( CurrGet.li.mod == NO_MOD ) {
                Error( ERR_NONE, LIT( ERR_NO_MODULE ), CurrGet.li.name.start,
                                      CurrGet.li.name.len );
            }
            CurrGet.multi_module = FALSE;
        } else if( !CurrGet.any_image && CurrGet.li.mod == NO_MOD ) {
            CurrGet.li.mod = CodeAddrMod;
            CurrGet.multi_module = FALSE;
        }
        break;
    case 4: /* file scope */
        CurrGet.li.file_scope = TRUE;
        break;
    case 5: /* given scope */
        CurrGet.li.file_scope = FALSE;
        break;
    case 6: /* scope lookup */
        CurrGet.li.scope.start = CurrGet.li.name.start;
        CurrGet.li.scope.len   = CurrGet.li.name.len;
        break;
    case 7: /* get name >>bool */
        if( CurrToken == T_NAME ) {
            CurrGet.kind = GET_NAME;
            CurrGet.li.name.start = NamePos();
            CurrGet.li.name.len   = NameLen();
            Scan();
            result = TRUE;
        }
        break;
    case 8: /* get operator name */
        CurrGet.kind = GET_OPERATOR;
        CurrGet.li.name.start = NamePos();
        CurrGet.li.name.len   = NameLen();
        Scan();
        break;
    case 9: /* get line number >>bool */
        if( CurrToken == T_LEFT_BRACE ) {
            size_t  len;
            /* Get a specfic file name for the module */
            ScanQuote( &CurrGet.li.source.start, &len );
            CurrGet.li.source.len = len;
        }
        if( CurrToken == T_INT_NUM ) {
            unsigned_64         tmp;

            result = TRUE;
            CurrGet.kind = GET_LNUM;
            old = SetCurrRadix( 10 );
            tmp = IntNumVal();
            CurrGet.li.name.len = U32FetchTrunc( tmp );
            Scan();
            SetCurrRadix( old );
        }
        break;
    case 10: /* GetDtorName >>bool */
        if( CurrToken == T_NAME ) {
            CurrGet.kind = GET_NAME;
            CurrGet.li.name.start = NamePos();
            CurrGet.li.name.len   = NameLen();
            CurrGet.li.type = ST_DESTRUCTOR;
            addr = Context.execution;
            sym = LookupSymList( SS_SCOPED, &addr, FALSE, &CurrGet.li );
            if( sym != NULL ) {
                PurgeSymHandles();
                Scan();
                result = TRUE;
            } else {
                CurrGet.li.type = ST_NONE;
            }
        }
        break;
    case 11: /* GetSetNameType(symbol_type) */
        CurrGet.li.type = parm;
        break;
    case 12: /* GetQueryName >>bool */
        CurrGet.kind = GET_NAME;
        addr = Context.execution;
        sym = LookupSymList( SS_SCOPED, &addr, FALSE, &CurrGet.li );
        if( sym != NULL ) {
            PurgeSymHandles();
            result = TRUE;
        } else {
            CurrGet.li.type = ST_NONE;
        }
        break;
    case 13: /* GetAddScope */
        if( CurrGet.li.scope.len == 0 ) {
            CurrGet.li.scope = CurrGet.li.name;
        } else {
            CurrGet.li.scope.len = (CurrGet.li.name.start-CurrGet.li.scope.start)
                                        + CurrGet.li.name.len;
        }
        break;
    }
    return( result );
}
Пример #2
0
static unsigned MechPush_n_Pop( unsigned select, unsigned parm )
{
    location_list       ll;
    dip_type_info       ti;
    unsigned            result;
    const static unsigned       TypeTbl[] = {
        TI_CREATE( TK_VOID,     TM_NONE,         0 ),
        TI_CREATE( TK_INTEGER,  TM_UNSIGNED,     1 ),
        TI_CREATE( TK_INTEGER,  TM_SIGNED,       1 ),
        TI_CREATE( TK_INTEGER,  TM_UNSIGNED,     2 ),
        TI_CREATE( TK_INTEGER,  TM_SIGNED,       2 ),
        TI_CREATE( TK_INTEGER,  TM_UNSIGNED,     4 ),
        TI_CREATE( TK_INTEGER,  TM_SIGNED,       4 ),
        TI_CREATE( TK_REAL,     TM_NONE,         4 ),
        TI_CREATE( TK_REAL,     TM_NONE,         8 ),
        TI_CREATE( TK_COMPLEX,  TM_NONE,         8 ),
        TI_CREATE( TK_COMPLEX,  TM_NONE,        16 ),
    };

    result = FALSE;
    switch( select ) {
    case 0:
        PushInt( parm );
        break;
    case 1:
        PushAddr( GetDotAddr() );
        break;
    case 2:
        ParseRegSet( TRUE, &ll, &ti );
        if( ti.size != 0 ) {
            if( ti.kind == TK_NONE ) Error( ERR_NONE, LIT( ERR_ILL_TYPE ) );
            PushLocation( &ll, &ti );
            result = TRUE;
        }
        break;
    case 3:
        if( CurrToken == T_INT_NUM ) {
            PushNum64( IntNumVal() );
            Scan();
            result = TRUE;
        } else if( CurrToken == T_REAL_NUM ) {
            PushRealNum( RealNumVal() );
            Scan();
            result = TRUE;
        } else {
            result = FALSE;
        }
        break;
    case 4:
        BasicType( TypeTbl[ parm ] );
        break;
    case 5:
        DupStack();
        break;
    case 6:
        PopEntry();
        break;
    case 7:
        PushString();
        break;
    case 8:
        /* here because old debuggers will always return FALSE */
        switch( parm & SSL_VERSION_MAJOR_MASK ) {
        case SSL_VERSION_MAJOR_CURR:
            break;
        default:
            return( FALSE );
        }
        #if SSL_VERSION_MINOR_CURR != 0
            if( (parm & SSL_VERSION_MINOR_MASK) > SS_MINOR_VERSION_CURR ) {
                return( FALSE );
            }
        #endif
        result = TRUE;
        break;
    case 9:
        BasicType( parm );
        break;
    }
    return( result );
}
Пример #3
0
static ssl_value MechPush_n_Pop( unsigned select, ssl_value parm )
{
    location_list           ll;
    dig_type_info           ti;
    ssl_value               result;
    static const unsigned   TypeTbl[] = {
        TI_CREATE( TK_VOID,     TM_NONE,         0 ),
        TI_CREATE( TK_INTEGER,  TM_UNSIGNED,     1 ),
        TI_CREATE( TK_INTEGER,  TM_SIGNED,       1 ),
        TI_CREATE( TK_INTEGER,  TM_UNSIGNED,     2 ),
        TI_CREATE( TK_INTEGER,  TM_SIGNED,       2 ),
        TI_CREATE( TK_INTEGER,  TM_UNSIGNED,     4 ),
        TI_CREATE( TK_INTEGER,  TM_SIGNED,       4 ),
        TI_CREATE( TK_REAL,     TM_NONE,         4 ),
        TI_CREATE( TK_REAL,     TM_NONE,         8 ),
        TI_CREATE( TK_COMPLEX,  TM_NONE,         8 ),
        TI_CREATE( TK_COMPLEX,  TM_NONE,        16 ),
    };

    result = 0;
    switch( select ) {
    case 0:
        PushInt( SSL2INT( parm ) );
        break;
    case 1:
        PushAddr( GetDotAddr() );
        break;
    case 2:
        ParseRegSet( true, &ll, &ti );
        if( ti.size != 0 ) {
            if( ti.kind == TK_NONE )
                Error( ERR_NONE, LIT_ENG( ERR_ILL_TYPE ) );
            PushLocation( &ll, &ti );
            result = true;
        }
        break;
    case 3:
        if( CurrToken == T_INT_NUM ) {
            PushNum64( IntNumVal() );
            Scan();
            result = true;
        } else if( CurrToken == T_REAL_NUM ) {
            PushRealNum( RealNumVal() );
            Scan();
            result = true;
        }
        break;
    case 4:
        BasicType( TypeTbl[parm] );
        break;
    case 5:
        DupStack();
        break;
    case 6:
        PopEntry();
        break;
    case 7:
        PushString();
        break;
    case 8:
        /* here because old debuggers will always return false */
        if( (parm & SSL_VERSION_MAJOR_MASK) != SSL_VERSION_MAJOR_CURR ) {
            break;
        }
#if SSL_VERSION_MINOR_CURR != 0
        if( (parm & SSL_VERSION_MINOR_MASK) > SS_MINOR_VERSION_CURR ) {
            break;
        }
#endif
        result = true;
        break;
    case 9:
        BasicType( parm );
        break;
    }
    return( result );
}