Show
Ignore:
Timestamp:
07/05/07 04:03:51 (17 months ago)
Author:
krobillard
Message:

Added component! & lit-select! datatypes.
ur_makeBlockT() now has a ptr return argument.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • branches/thune/thread_safe/eval.c

    r417 r426  
    120120            case UT_CONTEXT: 
    121121            case UT_PORT: 
     122#ifdef UR_CONFIG_DATAFLOW 
     123            case UT_COMPONENT: 
     124#endif 
    122125            { 
    123126                int wrdN = ur_lookup( val, ur_sel(sel) ); 
     
    184187 
    185188 
     189#ifdef UR_CONFIG_DATAFLOW 
     190void ur_setPlug( UThread*, UBlock* cblk, UIndex wrdN, const UCell* nval ); 
     191#endif 
     192 
     193 
    186194/** 
    187195  Returns non-zero if successful. 
     
    242250            break; 
    243251 
     252#ifdef UR_CONFIG_DATAFLOW 
     253        case UT_COMPONENT: 
     254            if( ur_selIsAtom(sel) ) 
     255            { 
     256                int wrdN; 
     257                wrdN = ur_lookup( val, ur_sel(sel) ); 
     258                ur_setPlug( ut, tBlockPtr(val->ctx.valBlk), wrdN, nval ); 
     259                return 1; 
     260            } 
     261            break; 
     262#endif 
     263 
    244264        default: 
    245265            if( ! ur_selIsAtom(sel) ) 
     
    295315    { 
    296316        ur_type(tos) = UT_WORD; 
     317    } 
     318    else if( ur_is(tos, UT_LITSELECT) ) 
     319    { 
     320        ur_type(tos) = UT_SELECT; 
    297321    } 
    298322    // else leave tos unchanged... 
     
    366390    { 
    367391        case UR_BIND_THREAD: 
     392#ifdef UR_CONFIG_DATAFLOW 
     393        case UR_BIND_PLUG:      // Each component has its own body for now. 
     394#endif 
    368395            // ur_blockPtr( pc->word.valBlk ) 
    369396            blk = (((UBlock*) ut->blocks.arr.ptr.v) + pc->word.valBlk); 
     
    404431    } 
    405432 
     433    _throwUnsetF( ut, pc, "Invalid bind mask" ); 
    406434    return 0; 
     435} 
     436 
     437 
     438static int ur_setWord( UThread* ut, const UCell* pc, const UCell* val ) 
     439{ 
     440    UBlock* blk; 
     441    UCell* dest; 
     442    int wrdN; 
     443 
     444    wrdN = pc->word.index; 
     445    if( wrdN < 0 ) 
     446    { 
     447        _throwUnbound( ut, pc);     // UR_UNBOUND 
     448        return 0; 
     449    } 
     450 
     451    switch( pc->word.flags & UR_FLAG_BIND_MASK ) 
     452    { 
     453        case UR_BIND_THREAD: 
     454            // ur_blockPtr( pc->word.valBlk ) 
     455            blk = (((UBlock*) ut->blocks.arr.ptr.v) + pc->word.valBlk); 
     456            dest = blk->ptr.cells + wrdN; 
     457            break; 
     458 
     459        case UR_BIND_GLOBAL: 
     460            // ur_blockPtr( pc->word.valBlk ) 
     461            blk = (((UBlock*) ut->env->blocks.arr.ptr.v) - pc->word.valBlk); 
     462            dest = blk->ptr.cells + wrdN; 
     463            break; 
     464 
     465        case UR_BIND_LOCAL: 
     466        { 
     467            LocalFrame* it  = UR_LF_BEG; 
     468            LocalFrame* end = UR_LF_END; 
     469            while( it != end ) 
     470            { 
     471                if( it->n == pc->word.wordBlk ) 
     472                { 
     473                    dest = it->cell + wrdN; 
     474                    goto set_word; 
     475                } 
     476                ++it; 
     477            } 
     478            _throwUnsetF( ut, pc, "out-of-scope local" ); 
     479            return 0; 
     480        } 
     481 
     482#ifdef UR_CONFIG_DATAFLOW 
     483        case UR_BIND_PLUG: 
     484            // Assuming there are no global components. 
     485            ur_setPlug( ut, tBlockPtr(pc->word.valBlk), wrdN, val ); 
     486            return 1; 
     487#endif 
     488 
     489        default: 
     490            _throwUnsetF( ut, pc, "Invalid bind mask" ); 
     491            return 0; 
     492    } 
     493 
     494set_word: 
     495 
     496    ur_copyCell(dest, *val); 
     497    return 1; 
    407498} 
    408499 
     
    13781469    argc = varc = 0; 
    13791470 
    1380     sigN = scell->series.n; 
    13811471    blk = ur_block( scell ); 
    13821472    it  = blk->ptr.cells; 
     
    16331723#ifdef UR_CONFIG_NET 
    16341724extern void uc_net_addr( UThread*, UCell* ); 
     1725#endif 
     1726#ifdef UR_CONFIG_DATAFLOW 
     1727#include "component.c" 
    16351728#endif 
    16361729 
     
    16671760#endif 
    16681761#ifdef LANG_THUNE 
     1762#ifdef UR_CONFIG_DATAFLOW 
     1763    { uc_component,    "component" }, 
     1764    { uc_connect,      "connect" }, 
     1765#endif 
    16691766#ifdef UR_CONFIG_THREADS 
    16701767    { uc_thread,       "thread" },