Exemplo n.º 1
0
void BreakAllModEntries( mod_handle handle )
{
    name_list   list;
    address     addr;
    int         i;
    bool        have_mod_cue;
    sym_info    sinfo;
    DIPHDL( cue, ch );
    DIPHDL( cue, ch_mod );

    NameListInit( &list, WF_CODE );
    NameListAddModules( &list, handle, false, true );
    have_mod_cue = FindFirstCue( handle, ch_mod );
    for( i = 0; i < NameListNumRows( &list ); ++i ) {
        addr = NameListAddr( &list, i );
        SymInfo( NameListHandle( &list, i ), NULL, &sinfo );
        if( !sinfo.is_global && !sinfo.is_public )
            continue;
        if( have_mod_cue && DeAliasAddrCue( handle, addr, ch ) != SR_NONE ) {
            if( CueFileId( ch ) != CueFileId( ch_mod ) ) {
                continue;
            }
        }
        if( FindBreak( addr ) != NULL ) {
            continue;
        }
        AddBreak( addr );
    }
    NameListFree( &list );
}
Exemplo n.º 2
0
extern  void    AsmMoveDot( a_window *wnd, address addr )
{
    int         row;
    asm_window  *asw;
    DIPHDL( cue, ch1 );
    DIPHDL( cue, ch2 );

    if( wnd == NULL ) return;

    asw = WndAsm( wnd );
    if( DeAliasAddrCue( asw->mod, addr, ch1 ) != SR_NONE &&
        DeAliasAddrCue( asw->mod, asw->dotaddr, ch2 ) != SR_NONE ) {
        if( CueMod( ch1 )    == CueMod( ch2 ) &&
            CueFileId( ch1 ) == CueFileId( ch2 ) &&
            CueLine( ch1 )   == CueLine( ch2 ) ) {
            return;
        }
    }
    WndNoSelect( wnd );
    row = AsmAddrRow( wnd, addr );
    if( row == WndRows( wnd ) ) {
        AsmSetFirst( wnd, addr, TRUE );
        row = AsmAddrRow( wnd, addr );
        WndDirtyCurr( wnd );
        WndNewCurrent( wnd, row, PIECE_CURRENT );
        WndRepaint( wnd );
        row = 0;
    } else {
        WndDirtyCurr( wnd );
        WndNewCurrent( wnd, row, PIECE_CURRENT );
    }
    AsmSetDotAddr( wnd, addr );
}
Exemplo n.º 3
0
static remap_return ReMapOnePoint( brkp *bp, image_entry *image )
{
    mod_handle  himage, mod;
    bool        ok;
    address     addr;
    DIPHDL( cue, ch );
    DIPHDL( cue, ch2 );
    remap_return        rc = REMAP_REMAPPED;

    if( !bp->status.b.unmapped )
        return( REMAP_WRONG_IMAGE );
    if( bp->image_name == NULL || bp->mod_name == NULL ) {
        if( image == NULL ) {
            if( ReMapAddress( &bp->loc ) ) {
                rc = REMAP_REMAPPED;
            } else {
                rc = REMAP_ERROR;
            }
        } else {
            rc = ReMapImageAddress( &bp->loc, image );
        }
    } else {
        himage = LookupImageName( bp->image_name, strlen( bp->image_name ) );
        if( himage == NO_MOD )
            return( REMAP_ERROR );
        mod =  LookupModName( himage, bp->mod_name, strlen( bp->mod_name ) );
        if( mod == NO_MOD )
            return( REMAP_ERROR );
        ok = GetBPSymAddr( bp, &addr );
        if( !ok )
            return( REMAP_ERROR );
        if( bp->cue_diff != 0 ) {
            if( DeAliasAddrCue( mod, addr, ch ) != SR_EXACT )
                return( REMAP_ERROR );
            if( LineCue( mod, CueFileId( ch ), CueLine( ch ) + bp->cue_diff, 0, ch2 ) != SR_EXACT )
                return( REMAP_ERROR );
            addr = CueAddr( ch2 );
        }
        if( bp->addr_diff != 0 ) {
            addr.mach.offset += bp->addr_diff;
        }
        bp->loc.addr = addr;
        rc = REMAP_REMAPPED;
    }
    if( rc == REMAP_REMAPPED ) {
        bp->status.b.unmapped = false;
    }
    SetPointAddr( bp, bp->loc.addr );
    if( bp->status.b.activate_on_remap ) {
        ActPoint( bp, true );
    }
    return( rc );
}
Exemplo n.º 4
0
static walk_result FindModCue( mod_handle mod, void *d )
{
    DIPHDL( cue, ch );
    cue_find            *fd = d;
    unsigned long       curr_line;

    fd->id = 0;
    fd->ambig = FALSE;
    fd->match = CMP_NONE;
    if( mod != NO_MOD && fd->len != 0 ) {
        WalkFileList( mod, FindCue, fd );
        if( fd->id == 0 ) return( WR_CONTINUE );
        if( fd->ambig ) {
            Error( ERR_NONE, LIT( ERR_AMBIG_SRC_FILE ), fd->name, fd->len );
        }
    }
    fd->found_a_file = TRUE;
    switch( LineCue( mod, fd->id, CurrGet.li.name.len, 0, ch ) ) {
    case SR_EXACT:
        HDLAssign( cue, fd->best_ch, ch );
        fd->best_line = CurrGet.li.name.len;
        return( WR_STOP );
    case SR_CLOSEST:
        curr_line = CueLine( ch );
        if( curr_line < CurrGet.li.name.len && curr_line > fd->best_line ) {
            HDLAssign( cue, fd->best_ch, ch );
            fd->best_line = CurrGet.li.name.len;
        }
        break;
    case SR_FAIL:
        return( WR_FAIL );
    }
    return( WR_CONTINUE );
}
Exemplo n.º 5
0
extern void WndFileInspect( const char *file, bool binary )
{
    handle              filehndl;
    void                *viewhndl;
    mod_handle          mod;
    DIPHDL( cue, ch );

    viewhndl = NULL;
    if( binary ) {
        filehndl = FileOpen( file, OP_READ );
        if( filehndl == NIL_HANDLE ) Error( ERR_NONE, LIT_ENG( ERR_FILE_NOT_OPEN ), file );
        DoWndBinOpen( file, filehndl );
    } else {
        mod = LookupModName( NO_MOD, file, strlen( file ) );
        if( mod == NO_MOD ) {
            mod = FindFileMod( file );
        }
        if( FindFirstCue( mod, ch ) ) {
            viewhndl = OpenSrcFile( ch );
        } else {
            viewhndl = FOpenSource( file, NO_MOD, 0 );
            ch = NULL;
        }
        if( viewhndl == NULL ) Error( ERR_NONE, LIT_ENG( ERR_FILE_NOT_OPEN ), file );
        DoWndFileOpen( file, viewhndl, ch, false, false, WND_FILE );
    }
}
Exemplo n.º 6
0
static  a_window        *DoWndSrcInspect( address addr, bool existing )
{
    a_window    *wnd;
//    bool        nil;
    mod_handle  mod;
    DIPHDL( cue, ch );
    a_window    *active;

    active = WndFindActive();
//    nil = false;
    if( IS_NIL_ADDR( addr ) ) {
//        nil = true;
        addr = Context.execution;
    }
    wnd = NULL;
    if( existing ) {
        wnd = WndFindExisting( WND_SOURCE );
    }
    if( wnd == NULL ) {
        if( DeAliasAddrMod( addr, &mod ) == SR_NONE
         || DeAliasAddrCue( mod, addr, ch ) == SR_NONE ) {
            ch = NULL;
        }
        wnd = DoWndSrcOpen( ch, existing );
    }
    if( !SrcMoveDot( wnd, addr ) || !SrcHasFileOpen( wnd ) ) {
        if( active != NULL ) WndRestoreToFront( active );
        return( NULL );
    }
    return( wnd );
}
Exemplo n.º 7
0
extern  bool    SrcMoveDot( a_window *wnd, address addr )
{
    unsigned    line;
    mod_handle  mod;
    file_window *file;
    DIPHDL( cue, ch );

    if( wnd == NULL ) return( FALSE );
    file = WndFile( wnd );
    if( file->mod == NO_MOD && !file->track ) return( FALSE );
    if( IS_NIL_ADDR( addr ) ) {
        WndScrollAbs( wnd, 0 );
        return( FALSE );
    }
    DeAliasAddrMod( addr, &mod );
    if( DeAliasAddrCue( mod, addr, ch ) == SR_NONE ) {
        if( LineCue( mod, 0, 0, 0, ch ) == SR_NONE ) return( FALSE );
    }
    line = CueLine( ch );
    if( mod != file->mod || CueFileId( ch ) != file->file_id ) {
        if( !file->track ) return( FALSE );
        FileTrack( wnd, ch );
    }
    --line;
    WndScrollAbs( wnd, line ); //
    WndMoveCurrent( wnd, line, PIECE_SOURCE );
    FileSetDotAddr( wnd, addr );
    FileSetTitle( wnd, CueMod( ch ) );
    return( TRUE );
}
Exemplo n.º 8
0
static unsigned ActiveLine( void )
{
    DIPHDL( cue, ch );

    if( DeAliasAddrCue( ContextMod, Context.execution, ch ) == SR_NONE ) return( 0 );
    return( CueLine( ch ) - 1 );
}
Exemplo n.º 9
0
static void PushBaseSize( void )
{
    DIPHDL( type, th );
    dip_type_info   ti;

    TypeBase( ExprSP->th, th, NULL, NULL );
    TypeInfo( th, ExprSP->lc, &ti );
    PushNum( ti.size );
}
Exemplo n.º 10
0
char *CnvAddr( address addr, cnvaddr_option cao, bool uniq,
                        char *p, size_t max )
{
    char                off_buff[40];
    size_t              str_width, name_width, off_width;
    addr_off            sym_offset;
    search_result       sr;
    location_list       ll;
    DIPHDL( sym, sym );

    off_width = 0;
    AddrFloat( &addr );
    sr = DeAliasAddrSym( NO_MOD, addr, sym );
    switch( sr ) {
    case SR_NONE:
        return( NULL );
    case SR_CLOSEST:
        if( cao == CAO_NO_PLUS )
            return( NULL );
        DIPSymLocation( sym, NULL, &ll );
        sym_offset = addr.mach.offset - ll.e[0].u.addr.mach.offset;
        if( cao == CAO_NORMAL_PLUS ) {
            char    *prfx;
            prfx = AddHexSpec( off_buff );
            off_width = CnvULongHex( sym_offset, prfx, sizeof( off_buff ) - ( prfx - off_buff ) ) - off_buff + 1;
        }
        break;
    case SR_EXACT:
        break;
    }
    name_width = QualifiedSymName( sym, NULL, 0, uniq );
    str_width = name_width + off_width;
    if( max == 0 )
        max = str_width;
    if( str_width > max ) { /* won't fit */
        if( off_width != 0 )
            return( NULL );
        QualifiedSymName( sym, p, max - 1, uniq );
        p += max - 1;
        *p++ = '>';
        *p = NULLCHAR;
        return( p );
    }
    QualifiedSymName( sym, p, name_width + 1, uniq );
    p += name_width;
    if( off_width != 0 ) {
        --off_width;
        *p++ = '+';
        memcpy( p, off_buff, off_width );
        p += off_width;
        *p = NULLCHAR;
    }
    return( p );
}
Exemplo n.º 11
0
address GetRowAddrDirectly( mod_handle mod, cue_fileid file_id, int row, bool exact )
{
    DIPHDL( cue, ch );

    if( mod == NO_MOD || row < 0 ) return( NilAddr );
    switch( LineCue( mod, file_id, row+1, 0, ch ) ) {
    case SR_NONE:
        return( NilAddr );
    case SR_CLOSEST:
        if( exact ) return( NilAddr );
        break;
    }
    return( CueAddr( ch ) );
}
Exemplo n.º 12
0
static void DumpSource( void )
{
    char        buff[256];
    DIPHDL( cue, ch );

    if( _IsOn( SW_TASK_RUNNING ) ) {
        printf( "I don't know where the task is. It's running\n" );
    }
    if( DeAliasAddrCue( NO_MOD, GetCodeDot(), ch ) == SR_NONE ||
        !DUIGetSourceLine( ch, buff, sizeof( buff ) ) ) {
        UnAsm( GetCodeDot(), buff, sizeof( buff ) );
    }
    printf( "%s\n", buff );
}
Exemplo n.º 13
0
static address GetRowAddr( file_window *file, wnd_row row, bool exact )
{
    DIPHDL( cue, ch );

    if( file->mod == NO_MOD || row < 0 ) return( NilAddr );
    switch( LineCue( file->mod, file->file_id, row+1, 0, ch ) ) {
    case SR_NONE:
        return( NilAddr );
    case SR_CLOSEST:
        if( exact ) return( NilAddr );
        break;
    }
    return( CueAddr( ch ) );
}
Exemplo n.º 14
0
extern  a_window        *WndModInspect( mod_handle mod )
{
    a_window    *wnd;
    DIPHDL( cue, ch );

    wnd = WndFindExisting( WND_SOURCE );
    if( wnd == NULL && LineCue( mod, 0, 0, 0, ch ) != SR_NONE ) {
        wnd = DoWndSrcOpen( ch, true );
    }
    if( wnd != NULL ) {
        SrcMoveDot( wnd, ModFirstAddr( mod ) );
    }
    return( wnd );
}
Exemplo n.º 15
0
static bool IsCodePointer( stack_entry *entry )
{
    DIPHDL( type, base_th );
    dip_type_info   ti;

    if( entry->th == NULL ) return( FALSE );
    if( TypeBase( entry->th, base_th, NULL, NULL ) != DS_OK ) return( FALSE );
    if( TypeInfo( base_th, entry->lc, &ti ) != DS_OK ) return( FALSE );
    switch( ti.kind ) {
    case TK_CODE:
    case TK_FUNCTION:
        return( TRUE );
    }
    return( FALSE );
}
Exemplo n.º 16
0
static void RepInitEv( event_record *ev )
{
    DIPHDL( cue, ch );
    if( ev->cue == NULL ) {
        if( DeAliasAddrCue( NO_MOD, ev->ip, ch ) != SR_NONE ) {
            ev->cue = CopySourceLine( ch );
        }
        if( ev->cue == NULL ) {
            UnAsm( ev->ip, TxtBuff, TXT_LEN );
            ev->cue = DupStr( TxtBuff );
        }
    }
    if( ev->addr_string == NULL ) {
        ev->addr_string = DupStr( GetEventAddress( ev ) );
    }
}
Exemplo n.º 17
0
brkp *FindBreakByLine( mod_handle mod, cue_fileid id, unsigned line )
{
    brkp        *bp;
    mod_handle  brk_mod;
    DIPHDL( cue, ch );


    for( bp = BrkList; bp != NULL; bp = bp->next ) {
        if( DeAliasAddrMod( bp->loc.addr, &brk_mod ) == SR_NONE )continue;
        if( brk_mod != mod )continue;
        if( DeAliasAddrCue( brk_mod, bp->loc.addr, ch ) == SR_NONE ) continue;
        if( CueFileId( ch ) != id ) continue;
        if( CueLine( ch ) != line ) continue;
        return( bp );
    }
    return( NULL );
}
Exemplo n.º 18
0
inspect_type WndGetExprSPInspectType( address *paddr )
{
    sym_info    info;
    DIPHDL( sym, sh );

    LValue( ExprSP );
    *paddr = NilAddr;
    if( ExprSP->info.kind == TK_FUNCTION ) {
        ExprValue( ExprSP );
        *paddr = ExprSP->v.addr;
        PopEntry();
        return( INSP_CODE );
    } else if( (ExprSP->flags & SF_LOCATION) && ExprSP->th != NULL && !IsInternalMod( TypeMod( ExprSP->th ) ) ) {
        if( ExprSP->v.loc.num == 1 && ExprSP->v.loc.e[0].type == LT_ADDR ) {
            *paddr = ExprSP->v.loc.e[0].u.addr;
        }
        PopEntry();
        return( INSP_DATA );
    } else {
        if( (ExprSP->flags & SF_LOCATION) && ExprSP->v.loc.e[0].type == LT_ADDR ) {
            *paddr = ExprSP->v.loc.e[0].u.addr;
        } else if( ExprSP->info.kind == TK_ADDRESS
                || ExprSP->info.kind == TK_POINTER ) {
            *paddr = ExprSP->v.addr;
        }
        if( !IS_NIL_ADDR( (*paddr) ) ) {
            AddrFloat( paddr );
            if( DeAliasAddrSym( NO_MOD, *paddr, sh ) != SR_NONE ) {
                SymInfo( sh, ExprSP->lc, &info );
                PopEntry();
                switch( info.kind ) {
                case SK_CODE:
                case SK_PROCEDURE:
                    return( INSP_CODE );
                    break;
                default:
                    return( INSP_RAW_DATA );
                    break;
                }
            }
        }
    }
    ExprValue( ExprSP );
    MakeMemoryAddr( TRUE, EXPR_DATA, paddr );
    return( INSP_RAW_DATA );
}
Exemplo n.º 19
0
char *LineAddr( address  *addr, char *buff, size_t buff_len )
{
    mod_handle          mod;
    char                *end;
    DIPHDL( cue, line );

    AddrFloat( addr );
    if( DeAliasAddrMod( *addr, &mod ) == SR_NONE )
        return( NULL );
    if( DeAliasAddrCue( mod, *addr, line ) == SR_NONE )
        return( NULL );
    end = buff + buff_len;
    buff += DIPModName( mod, buff, buff_len - 1 );
    *buff++ = '@';
    buff = CnvULongDec( DIPCueLine( line ), buff, end - buff );
    *buff = NULLCHAR;
    return( buff );
}
Exemplo n.º 20
0
static void BasicType( unsigned basic_type )
{
    struct internal_mod         mod_srch;
    struct imp_type_handle      *internal;
    dip_type_info               info;
    DIPHDL( type, th );

    WalkModList( NO_MOD, FindInternalMod, &mod_srch );
    internal = TypeCreate( th, mod_srch.mh );
    info.kind = TI_KIND_EXTRACT( basic_type );
    info.modifier = TI_MOD_EXTRACT( basic_type );
    info.size = TI_SIZE_EXTRACT( basic_type );
    FillInDefaults( &info );
    internal->t.k = info.kind;
    internal->t.m = info.modifier;
    internal->t.s = info.size;
    internal->ri = NULL;
    PushType( th );
}
Exemplo n.º 21
0
static void BasicType( unsigned basic_type )
{
    internal_mod        mod_srch;
    imp_type_handle     *ith;
    dig_type_info       ti;
    DIPHDL( type, th );

    DIPWalkModList( NO_MOD, FindInternalMod, &mod_srch );
    DIPTypeInit( th, mod_srch.mh );
    ti.kind = TI_KIND_EXTRACT( basic_type );
    ti.size = TI_SIZE_EXTRACT( basic_type );
    ti.modifier = TI_MOD_EXTRACT( basic_type );
    ti.deref = false;
    FillInDefaults( &ti );
    ith = TH2ITH( th );
    ith->ti = ti;
    ith->ri = NULL;
    PushType( th );
}
Exemplo n.º 22
0
static void AsmSetFirst( a_window *wnd, address addr, bool use_first_source )
{
    int                 row,rows;
    asm_window          *asw = WndAsm( wnd );
    char                chr;
    mad_disasm_data     *dd;
    unsigned            addr_len;
    DIPHDL( cue, ch );

    _AllocA( dd, asw->ddsize );


    if( IS_NIL_ADDR( addr ) || ProgPeek( addr, &chr, 1 ) != 1 ) {
        addr = NilAddr;
    }
    asw->ins[ 0 ].addr = addr;
    asw->ins[ 0 ].line = 0;
    addr_len = AddrToString( &addr, MAF_OFFSET, TxtBuff, TXT_LEN ) - TxtBuff;
    if( addr_len != asw->addr_len ) {
        asw->addr_len = addr_len;
        AsmResize( wnd ); // recusively calls this routine!
        WndZapped( wnd );
        return;
    }
    rows = WndRows( wnd );
    for( row = 0; row < rows; ++row ) {
        asw->ins[ row ].addr = addr;
        if( IS_NIL_ADDR( addr ) ) continue;
        if( ExactCueAt( asw, addr, ch ) ) {
            if( row != 0 || use_first_source ) {
                asw->ins[ row ].addr = addr;
                asw->ins[ row ].line = CueLine( ch );
                ++row;
                if( row >= rows ) break;
            }
        }
        asw->ins[ row ].addr = addr;
        asw->ins[ row ].line = 0;
        if( MADDisasm( dd, &addr, 0 ) != MS_OK ) {
            addr = NilAddr;
        }
    }
}
Exemplo n.º 23
0
void SetPointAddr( brkp *bp, address addr )
{
    DIPHDL( cue, ch );
    image_entry *image;
    mod_handle  mod;
    char  const *start;
    bool        ok;

    if( bp->status.b.unmapped )
        return;
    _Free( bp->source_line );
    bp->source_line = NULL;
    bp->loc.addr = addr;
    _Free( bp->mod_name );
    bp->mod_name = NULL;
    _Free( bp->image_name );
    bp->image_name = NULL;
    _Free( bp->sym_name );
    bp->sym_name = NULL;
    bp->cue_diff = 0;
    bp->addr_diff = 0;
    if( !IS_BP_EXECUTE( bp->th ) ) {
        GetWPVal( bp );
    } else if( DeAliasAddrMod( addr, &mod ) != SR_NONE ) {
        image = ImageEntry( mod );
        if( image == NULL )
            return;
        ModName( mod, TxtBuff, TXT_LEN );
        bp->mod_name = DupStr( TxtBuff );
        if( image->image_name != NULL ) {
            start = SkipPathInfo( image->image_name, OP_REMOTE );
            bp->image_name = DupStrLen( start, ExtPointer( start, OP_REMOTE ) - start );
        } else {
            bp->image_name = NULL;
        }
        switch( DeAliasAddrCue( NO_MOD, addr, ch ) ) {
        case SR_EXACT:
            bp->source_line = CopySourceLine( ch );
            Format( TxtBuff, "%d", CueLine( ch ) );
            bp->sym_name = DupStr( TxtBuff );
            ok = GetBPSymAddr( bp, &addr );
            break;
        case SR_CLOSEST:
            Format( TxtBuff, "%d", CueLine( ch ) );
            bp->sym_name = DupStr( TxtBuff );
            bp->addr_diff = addr.mach.offset - CueAddr( ch ).mach.offset;
            ok = GetBPSymAddr( bp, &addr );
            break;
        default:
            ok = false;
        }
        if( !ok ) {
            _Free( bp->image_name );
            _Free( bp->mod_name );
            _Free( bp->sym_name );
            bp->image_name = NULL;
            bp->mod_name = NULL;
            bp->sym_name = NULL;
        }
    }
}
Exemplo n.º 24
0
static ssl_value MechDo( unsigned select, ssl_value parm )
{
    unsigned long       size;
    ssl_value           result;
    DIPHDL( type, th );
    dig_type_info       ti;
    mad_type_info       mti;

    result = 0;
    switch( select ) {
    case 0:
        DoAssign();
        break;
    case 1:
        DoMul();
        break;
    case 2:
        DoDiv();
        break;
    case 3:
        DoMod();
        break;
    case 4:
        DoMinus();
        break;
    case 5:
        DoShift();
        break;
    case 6:
        DoAnd();
        break;
    case 7:
        DoXor();
        break;
    case 8:
        DoOr();
        break;
    case 9:
        DoAddr();
        break;
    case 10:
        ClassToTypeInfo( parm, &ti );
        DoPoints( ti.kind );
        break;
    case 11:
        DoField();
        break;
    case 12:
        DoCall( Num, SSL2BOOL( parm ) );
        break;
    case 13:
        DoConvert();
        break;
    case 14:
        DoPlus();
        break;
    case 15:
        MakeAddr();
        break;
    case 16:
        result = ( TstEQ( SSL2INT( parm ) ) != 0 );
        break;
    case 17:
        result = ( TstLT( SSL2INT( parm ) ) != 0 );
        break;
    case 18:
        result = ( TstTrue( SSL2INT( parm ) ) != 0 );
        break;
    case 19:
        result = ( TstExist( SSL2INT( parm ) ) != 0 );
        break;
    case 20:
        size = ExprSP->ti.size;
        PopEntry();
        PushNum( size );
        break;
    case 21:
        DIPTypeBase( ExprSP->th, th, NULL, NULL );
        PopEntry();
        PushType( th );
        break;
    case 22:
        GetMADTypeDefault( MTK_ADDRESS, &mti );
        size = BITS2BYTES( mti.b.bits - mti.a.seg.bits );
        if( parm ) {
            size += sizeof( addr_seg );
            DIPTypePointer( ExprSP->th, TM_FAR, size, th );
        } else {
            DIPTypePointer( ExprSP->th, TM_NEAR, size, th );
        }
        PopEntry();
        PushType( th );
        break;
    case 23:
        result = UserType( th );
        if( result ) {
            PopEntry();
            PushType( th );
        }
        break;
    case 24:
        DoMakeComplex();
        break;
    case 25:
        DoStringConcat();
        break;
    case 26:
        DoLConvert();
        break;
    case 27:
        DoPlusScaled();
        break;
    case 28:
        DoMinusScaled();
        break;
    case 29:
        DoPoints( TI_KIND_EXTRACT( parm ) );
        break;
    case 30:
        ti.kind = TK_POINTER;
        ti.size = TI_SIZE_EXTRACT( parm );
        ti.modifier = TI_MOD_EXTRACT( parm );
        ti.deref = false;
        FillInDefaults( &ti );
        DIPTypePointer( ExprSP->th, ti.modifier, ti.size, th );
        PopEntry();
        PushType( th );
        break;
    case 31:
        if( SSL2BOOL( parm ) ) {
            /* file scope */
            if( ExprSP->flags & SF_NAME ) {
                ExprSP->v.li.file_scope = true;
            } else {
                Error( ERR_LOC, LIT_ENG( ERR_WANT_NAME ) );
            }
        } else {
            /* in a namespace */
            DoScope();
        }
        break;
    }
    return( result );
}
Exemplo n.º 25
0
static unsigned MechDo( unsigned select, unsigned parm )
{
    unsigned long       size;
    unsigned            result = 0;
    DIPHDL( type, th );
    dip_type_info       info;
    mad_type_info       mti;

    switch( select ) {
    case 0:
        DoAssign();
        break;
    case 1:
        DoMul();
        break;
    case 2:
        DoDiv();
        break;
    case 3:
        DoMod();
        break;
    case 4:
        DoMinus();
        break;
    case 5:
        DoShift();
        break;
    case 6:
        DoAnd();
        break;
    case 7:
        DoXor();
        break;
    case 8:
        DoOr();
        break;
    case 9:
        DoAddr();
        break;
    case 10:
        ClassToTypeInfo( parm, &info );
        DoPoints( info.kind );
        break;
    case 11:
        DoField();
        break;
    case 12:
        DoCall( Num, parm );
        break;
    case 13:
        DoConvert();
        break;
    case 14:
        DoPlus();
        break;
    case 15:
        MakeAddr();
        break;
    case 16:
        result = TstEQ( parm );
        break;
    case 17:
        result = TstLT( parm );
        break;
    case 18:
        result = TstTrue( parm );
        break;
    case 19:
        result = TstExist( parm );
        break;
    case 20:
        size = ExprSP->info.size;
        PopEntry();
        PushNum( size );
        break;
    case 21:
        TypeBase( ExprSP->th, th, NULL, NULL );
        PopEntry();
        PushType( th );
        break;
    case 22:
        GetMADTypeDefault( MTK_ADDRESS, &mti );
        size = (mti.b.bits - mti.a.seg.bits) / BITS_PER_BYTE;
        if( parm ) {
            size += sizeof( addr_seg );
            TypePointer( ExprSP->th, TM_FAR, size, th );
        } else {
            TypePointer( ExprSP->th, TM_NEAR, size, th );
        }
        PopEntry();
        PushType( th );
        break;
    case 23:
        result = UserType( th );
        if( result ) {
            PopEntry();
            PushType( th );
        }
        break;
    case 24:
        DoMakeComplex();
        break;
    case 25:
        DoStringConcat();
        break;
    case 26:
        DoLConvert();
        break;
    case 27:
        DoPlusScaled();
        break;
    case 28:
        DoMinusScaled();
        break;
    case 29:
        DoPoints( TI_KIND_EXTRACT( parm ) );
        break;
    case 30:
        info.kind = TK_POINTER;
        info.size = TI_SIZE_EXTRACT( parm );
        info.modifier = TI_MOD_EXTRACT( parm );
        FillInDefaults( &info );
        TypePointer( ExprSP->th, info.modifier, info.size, th );
        PopEntry();
        PushType( th );
        break;
    case 31:
        if( parm ) {
            /* file scope */
            if( ExprSP->flags & SF_NAME ) {
                ExprSP->v.li.file_scope = TRUE;
            } else {
                Error( ERR_LOC, LIT( ERR_WANT_NAME ) );
            }
        } else {
            /* in a namespace */
            DoScope();
        }
        break;
    }
    return( result );
}
Exemplo n.º 26
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 );
}
Exemplo n.º 27
0
static  bool    FileGetLine( a_window *wnd, int row, int piece,
                             wnd_line_piece *line )
{
    int         len;
    file_window *file = WndFile( wnd );
    address     addr;
    brkp        *bp;
    bool        curr;
    DIPHDL( cue, ch );

    line->text = LIT_ENG( Empty );
    if( file->viewhndl == NULL && ModHasInfo( file->mod, HK_CUE ) != DS_OK ) {
        return( false );
    }
    curr = ( row == file->active && ContextMod == file->mod );
    switch( piece ) {
    case PIECE_BREAK:
        line->tabstop = false;
        if( row >= file->eof )
            return( false );
        if( file->mod == NO_MOD )
            return( true );
        addr = NilAddr;
        if( !WndDoingSearch ) { // too expensive
            addr = GetRowAddr( file, row, true );
        }
        if( !IS_NIL_ADDR( addr ) ) {
            bp = FindBreakByLine( file->mod, file->file_id, row+1 );
            FileBreakGadget( wnd, line, curr, bp );
        }
        return( true );
    case PIECE_SOURCE:
        line->text = TxtBuff;
        line->extent = WND_MAX_EXTEND;
        if( curr )
            line->attr = WND_STANDOUT;
        if( file->mod != NO_MOD ) {
            line->indent = MaxGadgetLength;
        }
        if( file->viewhndl == NULL ) {
            Format( TxtBuff, LIT_DUI( No_Source_Line ), row+1 );
            if( LineCue( file->mod, file->file_id, 0, 0, ch ) != SR_NONE ) {
                if( (CueAdjust( ch, -1, ch ) & DS_ERR) ) {
                    file->eof = CueLine( ch );
                }
            }
            return( true );
        }
        len = FReadLine( file->viewhndl, row+1, 0, TxtBuff, MAX_LINE_LEN );
        if( len < 0 ) {
            file->eof = row;
            return( false );
        }
        if( len == MAX_LINE_LEN ) {
            StrCopy( " ...", TxtBuff + MAX_LINE_LEN );
        } else {
            TxtBuff[len] = NULLCHAR;
        }
        if( row >= file->rows ) {
            file->rows = row + 1;
            file->rows_offset = FLastOffset( file->viewhndl );
        }
        return( true );
    default:
        return( false );
    }
}
Exemplo n.º 28
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 );
    }
}