Changeset 22299 for v6

Show
Ignore:
Timestamp:
09/20/08 15:36:33 (2 months ago)
Author:
ruoso
Message:

[smop] YAY! YAY! we do have map and grep now!
test/35 is the m0ld version of the following code
map { $_ > 3 ?? print "not ok - item > 3\n" !! print "ok - item < 3\n" },

grep { print "ok - grep iteration"; $_ < 3 } 2..5;

Location:
v6/smop
Files:
7 modified

Legend:

Unmodified
Added
Removed
  • v6/smop/src/native_int.c

    r22272 r22299  
    4141    SMOP_RELEASE(interpreter, other); 
    4242    SMOP_RELEASE(interpreter,invocant); 
     43 
     44  } else if (identifier == SMOP__ID__defined) { 
     45    ret = SMOP__NATIVE__bool_true; 
     46     
     47  } else if (identifier == SMOP__ID__FETCH) { 
     48    ___NATIVE_CAPTURE_ONLY___; 
     49    ___INVOCANT_RI_SHOULD_MATCH___; 
     50    ret = invocant; 
    4351 
    4452  } else if (identifier == SMOP__ID__infix_num_ge) { 
  • v6/smop/src/smop_s1p_array.c

    r22289 r22299  
    112112    } 
    113113 
     114  } else if (identifier == SMOP__ID__defined) { 
     115    // the array container is defined, the value inside it that maybe not. 
     116    ret = SMOP__NATIVE__bool_true; 
     117 
    114118  } else if (identifier == SMOP__ID__STORE) { 
    115119    resize_array(invocant->array,invocant->index+1); 
  • v6/smop/src/smop_s1p_array_iterator.sm0p

    r22281 r22299  
    124124      $void = $interpreter."goto"($back); 
    125125     final: 
    126       $void = $back."setr"(¢SMOP__S1P__EmptyList); 
     126      $void = $back."setr"(¢SMOP__S1P__EndOfIterator); 
    127127      $void = $interpreter."goto"($back) 
    128128 
  • v6/smop/src/smop_s1p_emptylist.c

    r22288 r22299  
    2727 
    2828  } else if (identifier == SMOP__ID__List) { 
     29    ret = SMOP__S1P__EmptyList; 
     30 
     31  } else if (identifier == SMOP__ID__FETCH) { 
    2932    ret = SMOP__S1P__EmptyList; 
    3033 
  • v6/smop/src/smop_s1p_grep.sm0p

    r22298 r22299  
    117117    my $input_iterator; 
    118118     
     119    fetch_item: 
    119120    my $next_item = $input_iterator."prefix:="(); 
    120     my $list = $next_item."List"(); 
    121     my $elems = $list."elems"(); 
    122     my $greater = $elems."infix:>"(0); 
    123     my $bool = $greater."bool"(); 
     121    my $bool = $next_item."defined"(); 
    124122    if $bool { goto iteration } else { goto end }; 
    125  
     123     
    126124    iteration: 
    127125    my $item = $next_item."FETCH"(); 
    128126    my $result = $code."postcircumfix:( )"($item); 
    129     my $void = $back."setr"($result); 
     127    my $bool = $result."bool"(); 
     128    if $bool { goto in } else { goto fetch_item }; 
     129     
     130    in: 
     131    my $void = $back."setr"($item); 
    130132    $void = $interpreter."goto"($back); 
    131  
     133     
    132134    end: 
    133135    $void = $back."setr"(¢SMOP__S1P__EndOfIterator); 
    134136    $void = $interpreter."goto"($back); 
    135  
     137     
    136138  }; 
    137139 
  • v6/smop/src/smop_s1p_map.sm0p

    r22288 r22299  
    114114     
    115115    my $next_item = $input_iterator."prefix:="(); 
    116     my $list = $next_item."List"(); 
    117     my $elems = $list."elems"(); 
    118     my $greater = $elems."infix:>"(0); 
    119     my $bool = $greater."bool"(); 
     116    my $bool = $next_item."defined"(); 
    120117    if $bool { goto iteration } else { goto end }; 
    121118 
  • v6/smop/test/35_array_grep.m0ld

    r22298 r22299  
    4343    my $back = $continuation."back"(); 
    4444     
    45     if $bool { goto in } else { goto out }; 
     45    if $bool { goto out } else { goto in }; 
     46     
     47    in: 
     48    $void = $back."setr"(¢SMOP__NATIVE__bool_true); 
     49    $void = $interpreter."goto"($back); 
    4650     
    4751    out: 
    48     $void = $back."setr"(¢SMOP__NATIVE__bool_true); 
    49     goto end; 
    50      
    51     in: 
    5252    $void = $back."setr"(¢SMOP__NATIVE__bool_false); 
    53      
    54     end: 
    5553    $void = $interpreter."goto"($back); 
    5654})); 
     
    7674 
    7775    in: 
    78     $void = $out."print"("ok\n"); 
     76    $void = $out."print"("ok - item < 3 \n"); 
    7977    goto end; 
    8078 
    8179    out: 
    82     $void = $out."print"("not ok\n"); 
     80    $void = $out."print"("not ok - item > 3\n"); 
    8381 
    8482    end: