Changeset 140

Show
Ignore:
Timestamp:
05/06/06 02:05:44 (3 years ago)
Author:
krobillard
Message:

Orca - Function arguments are now copied to the function context unless
recursion is in progress.

Location:
trunk/orca
Files:
1 added
3 modified

Legend:

Unmodified
Added
Removed
  • trunk/orca/context.c

    r94 r140  
    556556 
    557557 
     558#if 0 
    558559/* 
    559560   Returns true if block contains does or func. 
     
    623624    } 
    624625} 
     626#endif 
    625627 
    626628 
  • trunk/orca/ovalue.c

    r138 r140  
    22172217    cr->count  = ac 
    22182218 
    2219 extern void orRebind( OIndex blk, OIndex from, OIndex to ); 
     2219#define RECURSE_COUNT   index 
     2220 
     2221//extern void orRebind( OIndex blk, OIndex from, OIndex to ); 
    22202222 
    22212223/** 
     
    26002602    total = nv->argc + nv->refc; 
    26012603 
     2604#if 0 
    26022605    if( nv->flags & OR_FLAG_CLOSURE ) 
    26032606    { 
     
    26362639    data->used -= total; 
    26372640    *DATA_TOP = *nv; 
     2641#else 
     2642    vblk = orBlockPtr( vblkN ); 
     2643    save = vblk->values + total; 
     2644    if( save->RECURSE_COUNT ) 
     2645    { 
     2646        // Point context values to stack. 
     2647        save = vblk->values; 
     2648        vblk->values = DATA_TOP - total; 
     2649 
     2650        orSetTF( DATA_TOP, OT_UNSET ); 
     2651        DATA_TOP->RECURSE_COUNT = 1; 
     2652        ++data->used; 
     2653 
     2654        orEvalBlock( orBLOCKS + nv->func.bodyBlk, 0 ); 
     2655 
     2656        // Restore context (note we re-acquire the context after eval). 
     2657        vblk = orBlockPtr( vblkN ); 
     2658        vblk->values = save; 
     2659 
     2660        nv = DATA_TOP; 
     2661        data->used -= total + 1; 
     2662        *DATA_TOP = *nv; 
     2663    } 
     2664    else 
     2665    { 
     2666        // Copy arguments from stack to function context. 
     2667        data->used -= total; 
     2668        memCpy( vblk->values, DATA_TOP, sizeof(OValue) * total ); 
     2669 
     2670        ++save->RECURSE_COUNT; 
     2671        orEvalBlock( orBLOCKS + nv->func.bodyBlk, 0 ); 
     2672        --save->RECURSE_COUNT; 
     2673    } 
     2674#endif 
    26382675    } 
    26392676 
     
    42574294 
    42584295 
    4259 //extern void orRebindClosure( OIndex blkN ); 
    4260  
    42614296OR_NATIVE( orDoesNative ) 
    42624297{ 
     
    42834318 
    42844319 
    4285 extern int orClosureRequired( OIndex ); 
     4320//extern int orClosureRequired( OIndex ); 
    42864321 
    42874322//void orMakeFunction( OBlock* spec, OBlock* body ) 
     
    43174352    { 
    43184353    OBlock* vblk; 
     4354    int total = argc + refc; 
    43194355 
    43204356    // ctx->flags = OR_CTX_ONSTACK; 
    43214357    // orMakeContext( &ctx, argc + refc ); 
    43224358 
    4323     ctx.wblkN = orBlockN( orMakeBlock( argc + refc ) ); 
     4359    ctx.wblkN = orBlockN( orMakeBlock( total ) ); 
    43244360    orRefPush( OT_BLOCK, ctx.wblkN ); 
    43254361 
    4326     vblk = orMakeBlock( 0 ); 
    4327     vblk->used = argc + refc; 
     4362    vblk = orMakeBlock( total + 1 ); 
     4363    vblk->used = total; 
    43284364    ctx.vblkN = orBlockN( vblk ); 
    43294365    orRefPush( OT_BLOCK, ctx.vblkN ); 
     4366 
     4367    next = vblk->values + total; 
     4368    orSetTF( next, OT_UNSET ); 
     4369    next->RECURSE_COUNT = 0; 
    43304370 
    43314371    wblk = orBlockPtr( ctx.wblkN ); 
     
    44244464    res->func.context = ctx.vblkN; 
    44254465 
     4466#if 0 
    44264467    if( orClosureRequired( bodyN ) ) 
    44274468    { 
     
    44294470        //printf( "KR closure bit\n" ); 
    44304471    } 
     4472#endif 
    44314473    } 
    44324474} 
  • trunk/orca/ovalue.h

    r98 r140  
    124124#define OR_FLAG_HEX         0x02    // integer! only 
    125125#define OR_FLAG_RECURSION   0x02    // object! only 
    126 #define OR_FLAG_CLOSURE     0x04    // object! only 
     126//#define OR_FLAG_CLOSURE     0x04    // object! only 
    127127#define OR_FLAG_CATCH       0x08 
    128128#define OR_FLAG_THROW       0x10