Esempio n. 1
0
void DoAPoints( stack_entry *stk, type_kind def )
{
    stack_flags         was_imp_addr;
    addr_off            off;

    LRValue( stk );
    was_imp_addr = stk->flags & SF_IMP_ADDR;
    switch( stk->info.kind ) {
    case TK_BOOL:
    case TK_ENUM:
    case TK_CHAR:
    case TK_INTEGER:
        //NYI: 64 bit offsets
        off = U32FetchTrunc( stk->v.uint );
        stk->v.addr = DefAddrSpaceForAddr( Context.execution );
        stk->v.addr.mach.offset = off;
        stk->info.modifier = TM_NEAR;
        /* fall through */
    case TK_POINTER:
    case TK_ADDRESS:
        if( stk->th != NULL ) {
            LocationCreate( &stk->v.loc, LT_ADDR, &stk->v.addr );
            DIPTypeBase( stk->th, stk->th, stk->lc, &stk->v.loc );
            ClassifyEntry( stk, &stk->info );
            if( stk->info.kind == TK_VOID ) {
                Error( ERR_NONE, LIT_ENG( ERR_VOID_BASE ) );
            }
        } else {
            if( def == TK_NONE )
                def = TK_INTEGER;
            stk->info.kind = def;
            switch( def ) {
            case TK_INTEGER:
                stk->info.modifier = TM_UNSIGNED;
                stk->info.size = DefaultSize( DK_INT );
                break;
            case TK_ADDRESS:
                ExprSetAddrInfo( stk, false );
                break;
            }
            LocationCreate( &stk->v.loc, LT_ADDR, &stk->v.addr );
        }
        stk->flags |= SF_LOCATION | was_imp_addr;
        break;
    default:
        Error( ERR_NONE, LIT_ENG( ERR_ILL_TYPE ) );
        break;
    }
    stk->flags &= ~SF_CONST;
}
Esempio n. 2
0
void SymResolve( stack_entry *entry )
{
    item_mach   tmp;
    sym_handle  *sh;

    if( entry->flags & SF_SYM ) {
        sh = entry->v.sh;
        entry->flags &= ~SF_FORM_MASK;
        if( SymLocation( sh, entry->lc, &entry->v.loc ) == DS_OK ) {
            entry->flags |= SF_LOCATION;
            if( entry->v.loc.e[0].type == LT_ADDR ) {
                entry->flags |= SF_IMP_ADDR;
            }
            GetTrueEntry( entry );
        } else {
            if( entry->info.kind == TK_STRING ) {
                _ChkAlloc( entry->v.string.allocated, entry->info.size,
                            LIT( ERR_NO_MEMORY_FOR_EXPR ) );
                LocationCreate( &entry->v.string.loc, LT_INTERNAL,
                            entry->v.string.allocated );
                if( SymValue( sh, entry->lc, entry->v.string.allocated ) != DS_OK ) {
                    Error( ERR_NONE, LIT( ERR_NO_ACCESS ) );
                }
            } else {
                if( SymValue( sh, entry->lc, &tmp ) != DS_OK ) {
                    Error( ERR_NONE, LIT( ERR_NO_ACCESS ) );
                }
                FromItem( &tmp, entry );
            }
        }
        switch( entry->info.kind ) {
        case TK_CODE:
        case TK_ADDRESS:
            if( !(entry->flags & SF_LOCATION) ) {
                ExprSetAddrInfo( entry, FALSE );
/*
        This was here before, but that messes up things like 'do x=0:0'
        where 'x' is a newly created debugger variable. I can't think
        of any reason why you'd want to do this. If it turns out that there
        is a reason, talk to me.
                        Brian.
            } else {
                LocationToAddr( entry );
*/
            }
            entry->th = NULL;
            break;
        }
    }
}
Esempio n. 3
0
void DoAddr( void )
{
    mad_type_info       mti;

    LValue( ExprSP );
    if( (ExprSP->flags & SF_LOCATION)
        && ExprSP->v.loc.num == 1
        && ExprSP->v.loc.e[0].type == LT_ADDR ) {
        ExprSP->v.addr = ExprSP->v.loc.e[0].u.addr;
        ExprSetAddrInfo( ExprSP, false );
        if( ExprSP->th != NULL ) {
            GetMADTypeDefaultAt( ExprSP->v.addr, MTK_ADDRESS, &mti );
            DIPTypePointer( ExprSP->th, TM_FAR, BITS2BYTES( mti.b.bits ), ExprSP->th );
            ExprSP->info.kind = TK_POINTER;
        } else {
            ExprSP->info.kind = TK_ADDRESS;
        }
        ExprSP->flags &= ~SF_FORM_MASK;
    } else {
        Error( ERR_NONE, LIT_ENG( ERR_NEED_ADDRESS ) );
    }
}
Esempio n. 4
0
void LRValue( stack_entry *entry )
{
    location_list       ll;
    item_mach           tmp;
    bool                extend;
    mad_type_info       mti;
    DIPHDL( type, th );

    ExprResolve( entry );
    if( entry->flags & SF_LOCATION ) {
        if( entry->info.kind == TK_FUNCTION || entry->info.kind == TK_CODE ) {
            /* rvalue of procedure is its address */
            entry->v.addr = entry->v.loc.e[0].u.addr;
            ExprSetAddrInfo( entry, FALSE );
            entry->info.kind = TK_ADDRESS;
        } else if( !AddressExpression( entry ) ) {
            extend = FALSE;
            switch( entry->info.kind ) {
            case TK_ARRAY:
                /* rvalue of array is its address */
                entry->v.addr = entry->v.loc.e[0].u.addr;
                if( entry->th != NULL ) {
                    /* change typing from "array of..." to "pointer to..." */
                    GetMADTypeDefaultAt( entry->v.addr, MTK_ADDRESS, &mti );
                    TypeBase( entry->th, th, NULL, NULL );
                    TypePointer( th, TM_FAR, mti.b.bits / BITS_PER_BYTE, entry->th );
                    TypeInfo( entry->th, entry->lc, &entry->info );
                } else {
                    ExprSetAddrInfo( entry, FALSE );
                }
                break;
            case TK_STRING:
                _ChkAlloc( entry->v.string.allocated, entry->info.size,
                            LIT( ERR_NO_MEMORY_FOR_EXPR ) );
                LocationCreate( &ll, LT_INTERNAL, entry->v.string.allocated );
                if( LocationAssign( &ll, &entry->v.loc, entry->info.size, FALSE ) != DS_OK ) {
                    _Free( entry->v.string.allocated );
                    Error( ERR_NONE, LIT( ERR_NO_ACCESS ) );
                }
                entry->v.string.loc = ll;
                break;
            case TK_BOOL:
            case TK_CHAR:
            case TK_ENUM:
            case TK_INTEGER:
                if( (entry->info.modifier & TM_MOD_MASK) == TM_SIGNED ) extend = TRUE;
                /* fall through */
            default:
                LocationCreate( &ll, LT_INTERNAL, &tmp );
                if( LocationAssign( &ll, &entry->v.loc, entry->info.size, extend ) != DS_OK ) {
                    Error( ERR_NONE, LIT( ERR_NO_ACCESS ) );
                }
                FromItem( &tmp, entry );
                break;
            }
        }
        entry->flags &= ~(SF_LOCATION | SF_IMP_ADDR);
    }
    if( entry->info.kind == TK_POINTER
        && (entry->info.modifier & TM_MOD_MASK) == TM_NEAR ) {
        NearToFar( entry );
    }
}
Esempio n. 5
0
static void LocationToAddr( stack_entry *entry )
{
    entry->v.addr = entry->v.loc.e[0].u.addr;
    entry->flags &= ~SF_LOCATION;
    ExprSetAddrInfo( entry, FALSE );
}