Changeset 187 for trunk/thune/internal.h

Show
Ignore:
Timestamp:
06/20/06 05:09:27 (3 years ago)
Author:
krobillard
Message:

Thune - Major improvement to the handling of local function values.
Locals can now be passed to inner functions and caught when returned.
Functions are no longer tied to the thread which created them.

The localArgBlk has been eliminated and locals are now stored on the stack.
To accomodate this, the data stack is now separate from the control stack
and grows upwards. This also means that functions can no longer access the
stack below the function call. A limit of one returned value is in place.

To regain full stack usage, locals could be stored on the control stack.
The only downside would be an extra copy of arguments from the data to
the control stack.

ur_wordCell() is now a function rather than a macro.

uc_do() has been merged into ur_eval() and 'do is now implemented as an opcode.

. & .s now use uc_console_out() rather than dprint.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/thune/internal.h

    r184 r187  
    7575{ 
    7676    int16_t code; 
    77     int16_t argc; 
     77    int16_t locals; 
    7878    int32_t bodyN; 
    7979    int32_t sigN; 
     
    116116 
    117117 
    118 //#define CC_LEN_FUNC         1  // + argc 
     118#define CC_LEN_FUNC         1 
    119119#define CC_LEN_EVAL         1 
    120120#define CC_LEN_FOREVER      1 
     
    186186 
    187187#define UR_TOS              ur_thread->tos 
    188 #define UR_BOS              ur_thread->bos 
    189 #define UR_S_PUSH(v)        *--UR_TOS = v 
    190 #define UR_S_GROW           --UR_TOS 
    191 #define UR_S_GROWN(n)       UR_TOS -= n 
    192 #define UR_S_DROP           ++UR_TOS 
    193 #define UR_S_DROPN(n)       UR_TOS += n 
     188#define UR_BOS              ur_thread->dstack 
     189#define UR_S_PUSH(v)        *++UR_TOS = v 
     190#define UR_S_GROW           ++UR_TOS 
     191#define UR_S_GROWN(n)       UR_TOS += n 
     192#define UR_S_DROP           --UR_TOS 
     193#define UR_S_DROPN(n)       UR_TOS -= n 
    194194#define UR_S_SAFE_DROP          if(UR_TOS != UR_BOS) UR_S_DROP 
    195 #define UR_S_DUP            --UR_TOS; *UR_TOS = UR_TOS[1] 
    196 #define UR_S_NIP            UR_TOS[1] = *UR_TOS; UR_S_DROP 
    197 #define ur_s_atBottom(sp)   (sp == ur_thread->bos) 
    198 #define ur_s_notBottom(sp)  (sp != ur_thread->bos) 
    199 #define ur_s_prev(v)        (v + 1) 
    200 #define ur_s_next(v)        (v - 1) 
    201 #define ur_s_backN(v,n)     (v + (n)) 
    202 #define ur_s_aheadN(v,n)    (v - (n)) 
     195#define UR_S_DUP            UR_TOS[1] = *UR_TOS; ++UR_TOS 
     196#define UR_S_NIP            --UR_TOS; *UR_TOS = UR_TOS[1] 
     197#define ur_s_atBottom(sp)   (sp == ur_thread->dstack) 
     198#define ur_s_notBottom(sp)  (sp != ur_thread->dstack) 
     199#define ur_s_prev(v)        (v - 1) 
     200#define ur_s_next(v)        (v + 1) 
     201#define ur_s_backN(v,n)     (v - (n)) 
     202#define ur_s_aheadN(v,n)    (v + (n)) 
    203203 
    204204 
     
    206206 
    207207#define UR_TOC              ((CEntry*) ur_thread->toc) 
    208 #define UR_BOC              ((CEntry*) ur_thread->boc) 
     208#define UR_BOC              ((CEntry*) ur_thread->cstack) 
    209209#define UR_C_GROW           ++ur_thread->toc 
    210210#define UR_C_DEC            --ur_thread->toc