Changeset 506

Show
Ignore:
Timestamp:
02/08/08 04:14:39 (8 months ago)
Author:
krobillard
Message:

Changed if/keep to if-some. Added or-else.

Location:
trunk/thune
Files:
8 modified

Legend:

Unmodified
Added
Removed
  • trunk/thune/boot.c

    r503 r506  
    2424  "  opcode! 19 'try     make :try\n" 
    2525  "  opcode! 20 'ift     make :ift\n" 
    26   "  opcode! 21 'iff     make :iff\n" 
    27   "  opcode! 22 'if      make :if\n" 
    28   "  opcode! 23 'halt    make :halt\n" 
    29   "  opcode! 24 'quit    make :quit\n" 
    30   "  opcode! 25 'inc     make :inc\n" 
    31   "  opcode! 26 'dec     make :dec\n" 
    32   "  opcode! 27 '++      make :++\n" 
    33   "  opcode! 28 '--      make :--\n" 
    34   "  opcode! 29 'verify  make :verify\n" 
    35   "  opcode! 30 'forever make :forever\n" 
     26  "  opcode! 21 'if-some make :if-some\n" 
     27  "  opcode! 22 'iff     make :iff\n" 
     28  "  opcode! 23 'or-else make :or-else\n" 
     29  "  opcode! 24 'if      make :if\n" 
     30  "  opcode! 25 'halt    make :halt\n" 
     31  "  opcode! 26 'quit    make :quit\n" 
     32  "  opcode! 27 'inc     make :inc\n" 
     33  "  opcode! 28 'dec     make :dec\n" 
     34  "  opcode! 29 '++      make :++\n" 
     35  "  opcode! 30 '--      make :--\n" 
     36  "  opcode! 31 'verify  make :verify\n" 
     37  "  opcode! 32 'forever make :forever\n" 
    3638  "  int!/decimal! :number!\n" 
    3739  "  word!/set-word!/get-word!/lit-word! :any-word!\n" 
     
    5658  "  to-block kernel-ops infuse\n" 
    5759  "] proc :load    ;(filename -- block)\n" 
    58   "[select if/keep do] proc :case\n" 
     60  "[select if-some do] proc :case\n" 
    5961  "['break throw] proc :break\n" 
    6062  "[\n" 
     
    9092  "[ser old new | len] [\n" 
    9193  "    old length? :len\n" 
    92   "    ser old find if/keep (new len change :ser recurse)\n" 
     94  "    ser old find if-some (new len change :ser recurse)\n" 
    9395  "    ser\n" 
    9496  "] func :replace.all     ;(ser old new -- ser)\n" 
  • trunk/thune/doc/UserManual

    r503 r506  
    360360iff       (logic -- )                Evaluate next value if false. 
    361361if/C      (val val -- )              Evaluate next value if comparison is true. 
    362 if/keep   (val -- [val])             Evaluate next value if true, else drop. 
     362if-some   (val -- [val])             Evaluate next value if true, else drop. 
     363or-else   (val -- [val])             Keep true value, or drop and evaluate next. 
    363364either    (logic t-val f-val -- )    Evaluate either t-val or f-val. 
    364365forever   (block -- )                Evaluate block until exception thrown. 
  • trunk/thune/gl/gx_atoms.h

    r504 r506  
    11// This file is automatically generated - do not edit. 
    22 
    3 #define UR_ATOM_DRAW_LIST_OPCODES               324 
    4 #define UR_ATOM_WIDTH           325 
    5 #define UR_ATOM_HEIGHT          326 
    6 #define UR_ATOM_AREA            327 
    7 #define UR_ATOM_RECT            328 
    8 #define UR_ATOM_RASTER          329 
    9 #define UR_ATOM_TEXTURE         330 
    10 #define UR_ATOM_ELEM            331 
     3#define UR_ATOM_DRAW_LIST_OPCODES               326 
     4#define UR_ATOM_WIDTH           327 
     5#define UR_ATOM_HEIGHT          328 
     6#define UR_ATOM_AREA            329 
     7#define UR_ATOM_RECT            330 
     8#define UR_ATOM_RASTER          331 
     9#define UR_ATOM_TEXTURE         332 
     10#define UR_ATOM_ELEM            333 
    1111#define UR_ATOM_CLOSE           184 
    12 #define UR_ATOM_FOCUS           332 
    13 #define UR_ATOM_RESIZE          333 
    14 #define UR_ATOM_KEY_DOWN                334 
    15 #define UR_ATOM_KEY_UP          335 
    16 #define UR_ATOM_MOUSE_MOVE              336 
    17 #define UR_ATOM_MOUSE_UP                337 
    18 #define UR_ATOM_MOUSE_DOWN              338 
    19 #define UR_ATOM_MOUSE_WHEEL             339 
    20 #define UR_ATOM_AMBIENT         340 
    21 #define UR_ATOM_DIFFUSE         341 
    22 #define UR_ATOM_SPECULAR                342 
    23 #define UR_ATOM_POS             343 
    24 #define UR_ATOM_SHADER          344 
    25 #define UR_ATOM_VERTEX          345 
    26 #define UR_ATOM_FRAGMENT                346 
    27 #define UR_ATOM_DEFAULT         347 
     12#define UR_ATOM_FOCUS           334 
     13#define UR_ATOM_RESIZE          335 
     14#define UR_ATOM_KEY_DOWN                336 
     15#define UR_ATOM_KEY_UP          337 
     16#define UR_ATOM_MOUSE_MOVE              338 
     17#define UR_ATOM_MOUSE_UP                339 
     18#define UR_ATOM_MOUSE_DOWN              340 
     19#define UR_ATOM_MOUSE_WHEEL             341 
     20#define UR_ATOM_AMBIENT         342 
     21#define UR_ATOM_DIFFUSE         343 
     22#define UR_ATOM_SPECULAR                344 
     23#define UR_ATOM_POS             345 
     24#define UR_ATOM_SHADER          346 
     25#define UR_ATOM_VERTEX          347 
     26#define UR_ATOM_FRAGMENT                348 
     27#define UR_ATOM_DEFAULT         349 
    2828#define UR_ATOM_WAIT            135 
    29 #define UR_ATOM_RGB             348 
    30 #define UR_ATOM_RGBA            349 
    31 #define UR_ATOM_DEPTH           350 
    32 #define UR_ATOM_CLAMP           351 
    33 #define UR_ATOM_REPEAT          352 
    34 #define UR_ATOM_NEAREST         353 
    35 #define UR_ATOM_LINEAR          354 
    36 #define UR_ATOM_MIN             355 
    37 #define UR_ATOM_MAG             356 
    38 #define UR_ATOM_MIPMAP          357 
    39 #define UR_ATOM_GRAY            358 
    40 #define UR_ATOM_RGB             348 
    41 #define UR_ATOM_RGBA            349 
    42 #define UR_ATOM_ON              265 
    43 #define UR_ATOM_OFF             267 
     29#define UR_ATOM_RGB             350 
     30#define UR_ATOM_RGBA            351 
     31#define UR_ATOM_DEPTH           352 
     32#define UR_ATOM_CLAMP           353 
     33#define UR_ATOM_REPEAT          354 
     34#define UR_ATOM_NEAREST         355 
     35#define UR_ATOM_LINEAR          356 
     36#define UR_ATOM_MIN             357 
     37#define UR_ATOM_MAG             358 
     38#define UR_ATOM_MIPMAP          359 
     39#define UR_ATOM_GRAY            360 
     40#define UR_ATOM_RGB             350 
     41#define UR_ATOM_RGBA            351 
     42#define UR_ATOM_ON              267 
     43#define UR_ATOM_OFF             269 
    4444#define UR_ATOM_ADD             203 
    45 #define UR_ATOM_BURN            359 
    46 #define UR_ATOM_COLOR           360 
    47 #define UR_ATOM_TRANS           361 
    48 #define UR_ATOM_SPRITE          362 
    49 #define UR_ATOM_ONCE            363 
    50 #define UR_ATOM_PING_PONG               364 
    51 #define UR_ATOM_PONG            365 
     45#define UR_ATOM_BURN            361 
     46#define UR_ATOM_COLOR           362 
     47#define UR_ATOM_TRANS           363 
     48#define UR_ATOM_SPRITE          364 
     49#define UR_ATOM_ONCE            365 
     50#define UR_ATOM_PING_PONG               366 
     51#define UR_ATOM_PONG            367 
  • trunk/thune/internal.h

    r502 r506  
    198198#define OP_TRY              19 
    199199#define OP_IF_TRUE          20 
    200 #define OP_IF_FALSE         21 
    201 #define OP_IF               22 
    202 #define OP_HALT             23 
    203 #define OP_QUIT             24 
    204 #define OP_INCREMENT        25 
    205 #define OP_DECREMENT        26 
    206 #define OP_INC_WORD         27 
    207 #define OP_DEC_WORD         28 
    208 #define OP_VERIFY           29 
    209 #define OP_FOREVER          30 
    210 #define OP_REDUCE           31 
    211 #define OP_DO_FUNC          32 
     200#define OP_IF_SOME          21 
     201#define OP_IF_FALSE         22 
     202#define OP_OR_ELSE          23 
     203#define OP_IF               24 
     204#define OP_HALT             25 
     205#define OP_QUIT             26 
     206#define OP_INCREMENT        27 
     207#define OP_DECREMENT        28 
     208#define OP_INC_WORD         29 
     209#define OP_DEC_WORD         30 
     210#define OP_VERIFY           31 
     211#define OP_FOREVER          32 
     212#define OP_REDUCE           33 
     213#define OP_DO_FUNC          34 
    212214//#define OP_END              255 
    213215 
  • trunk/thune/mkboot.t

    r503 r506  
    2525  opcode! 19 'try     make :try 
    2626  opcode! 20 'ift     make :ift 
    27   opcode! 21 'iff     make :iff 
    28   opcode! 22 'if      make :if 
    29   opcode! 23 'halt    make :halt 
    30   opcode! 24 'quit    make :quit 
    31   opcode! 25 'inc     make :inc 
    32   opcode! 26 'dec     make :dec 
    33   opcode! 27 '++      make :++ 
    34   opcode! 28 '--      make :-- 
    35   opcode! 29 'verify  make :verify 
    36   opcode! 30 'forever make :forever 
     27  opcode! 21 'if-some make :if-some 
     28  opcode! 22 'iff     make :iff 
     29  opcode! 23 'or-else make :or-else 
     30  opcode! 24 'if      make :if 
     31  opcode! 25 'halt    make :halt 
     32  opcode! 26 'quit    make :quit 
     33  opcode! 27 'inc     make :inc 
     34  opcode! 28 'dec     make :dec 
     35  opcode! 29 '++      make :++ 
     36  opcode! 30 '--      make :-- 
     37  opcode! 31 'verify  make :verify 
     38  opcode! 32 'forever make :forever 
    3739 
    3840  int!/decimal! :number! 
     
    6163] proc :load    ;(filename -- block) 
    6264 
    63 [select if/keep do] proc :case 
     65[select if-some do] proc :case 
    6466 
    6567['break throw] proc :break 
     
    104106[ser old new | len] [ 
    105107    old length? :len 
    106     ser old find if/keep (new len change :ser recurse) 
     108    ser old find if-some (new len change :ser recurse) 
    107109    ser 
    108110] func :replace.all     ;(ser old new -- ser) 
  • trunk/thune/rune/mkboot.t

    r351 r506  
    122122] 
    123123 
    124 ;case func [blk] [select blk if/keep do] 
     124;case func [blk] [select blk if-some do] 
    125125 
    126126break: does [throw 'break] 
  • trunk/thune/scripts/obj_to_gx.t

    r458 r506  
    9797    ) 
    9898 
    99     geo/surfs if/keep write-surf 
     99    geo/surfs if-some write-surf 
    100100    ;"  color 0.8,0.8,0.8" print 
    101101 
     
    232232        | "usemtl" cl (data trim mtllib select :geo/surfs) 
    233233        | "g"  sl 
    234         | "o"  cl (geo if/keep write-geo 
     234        | "o"  cl (geo if-some write-geo 
    235235                   gx-geom [ 
    236236                     data trim copy :name 
  • trunk/thune/thune.c

    r503 r506  
    373373#define EMH_HALT(pc,end) 
    374374#endif 
     375 
     376 
     377inline int ur_isFalse( UCell* c ) 
     378{ 
     379    return ur_is(c, UT_NONE) || (ur_is(c, UT_LOGIC) && ! ur_logic(c)); 
     380} 
    375381 
    376382 
     
    685691                    break; 
    686692 
    687                 case OP_IF_TRUE:       // (logic -- ) 
    688                     val = UR_TOS; 
    689                     if( ur_is(val, UT_NONE) || 
    690                         (ur_is(val, UT_LOGIC) && ! ur_logic(val)) ) 
     693                case OP_IF_TRUE:        // (logic -- ) 
     694if_true: 
     695                    if( ur_isFalse( UR_TOS ) ) 
    691696                        goto if_skip; 
    692697                    UR_S_DROP; 
    693698                    break; 
    694699 
    695                 case OP_IF_FALSE:      // (logic -- ) 
    696                     val = UR_TOS; 
    697                     if( ur_is(val, UT_NONE) || 
    698                         (ur_is(val, UT_LOGIC) && ! ur_logic(val)) ) 
     700                case OP_IF_SOME:        // (val -- [val]) 
     701                    if( ur_isFalse( UR_TOS ) ) 
     702                        goto if_skip; 
     703                    break; 
     704 
     705                case OP_IF_FALSE:       // (logic -- ) 
     706                    if( ur_isFalse( UR_TOS ) ) 
    699707                        goto if_do; 
    700708if_skip: 
     
    705713                    break; 
    706714 
    707                 case OP_IF:            // (val val -- ) 
     715                case OP_OR_ELSE:        // (val -- [val]) 
     716                    if( ur_isFalse( UR_TOS ) ) 
     717                        goto if_do; 
     718                    if( pc != end ) 
     719                        ++pc; 
     720                    break; 
     721 
     722                case OP_IF:             // (val val -- ) 
    708723                { 
    709724                    int n; 
     
    716731                            goto if_skip; 
    717732 
    718                         case UR_ATOM_GT: 
    719                             n = ur_greaterThan( UR_TOS, ur_s_next(UR_TOS) ); 
    720                             break; 
    721  
    722                         case UR_ATOM_LT: 
    723                             n = ur_lessThan( UR_TOS, ur_s_next(UR_TOS) ); 
    724                             break; 
    725  
    726733                        case UR_ATOM_NEQ: 
    727734                            if( ! ur_equal( ut, UR_TOS, ur_s_next(UR_TOS) ) ) 
     
    729736                            goto if_skip; 
    730737 
     738                        case UR_ATOM_GT: 
     739                            n = ur_greaterThan( UR_TOS, ur_s_next(UR_TOS) ); 
     740                            break; 
     741 
     742                        case UR_ATOM_LT: 
     743                            n = ur_lessThan( UR_TOS, ur_s_next(UR_TOS) ); 
     744                            break; 
     745 
    731746                        case UR_ATOM_GTE: 
    732747                            n = ur_greaterOrEqual( UR_TOS, ur_s_next(UR_TOS) ); 
     
    737752                            break; 
    738753 
    739                         case UR_ATOM_KEEP:  // (val -- [val]) 
    740                             UR_S_GROW; 
    741                             val = UR_TOS; 
    742                             if( ur_is(val, UT_NONE) || 
    743                                 (ur_is(val, UT_LOGIC) && ! ur_logic(val)) ) 
    744                                 goto if_skip; 
    745                             goto execute; 
    746  
    747754                        //case UR_ATOM_ZERO: 
    748755                        //    break; 
     756 
     757                        default: 
     758                            goto if_true; 
    749759                    } 
    750760                    if( n == 1 )