- Timestamp:
- 09/20/08 01:03:21 (2 months ago)
- Location:
- v6/smop
- Files:
-
- 1 added
- 6 modified
-
CMakeLists.txt (modified) (1 diff)
-
include/smop_s1p.h (modified) (1 diff)
-
src/native_bool.c (modified) (1 diff)
-
src/smop_internal.h (modified) (2 diffs)
-
src/smop_s1p_emptylist.c (modified) (1 diff)
-
src/smop_s1p_endofiterator.c (added)
-
src/smop_s1p_map.sm0p (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
v6/smop/CMakeLists.txt
r22281 r22288 131 131 src/smop_s1p_pureprototypehow.c 132 132 src/smop_s1p_emptylist.c 133 src/smop_s1p_endofiterator.c 133 134 src/smop_s1p_bindcapturesignature.c 134 135 src/smop_s1p_defaultblocksignature.c -
v6/smop/include/smop_s1p.h
r22272 r22288 7 7 extern SMOP__Object* SMOP__S1P__Array; 8 8 extern SMOP__Object* SMOP__S1P__Array_Iterator; 9 extern SMOP__Object* SMOP__S1P__EndOfIterator; 9 10 extern SMOP__Object* SMOP__S1P__Str; 10 11 extern SMOP__Object* SMOP__S1P__Hash; -
v6/smop/src/native_bool.c
r22183 r22288 22 22 SMOP_RELEASE(interpreter,capture); 23 23 return invocant; 24 } else if (identifier = SMOP__ID__defined) { 25 SMOP_RELEASE(interpreter,capture); 26 return SMOP__NATIVE__bool_true; 24 27 } else { 25 28 ___UNKNOWN_METHOD___; -
v6/smop/src/smop_internal.h
r22272 r22288 65 65 smop_s1p_map_init(); \ 66 66 smop_s1p_array_iterator_init(); \ 67 smop_s1p_emptylist_init(); 67 smop_s1p_emptylist_init(); \ 68 smop_s1p_endofiterator_init(); 68 69 #define SMOP_INTERNAL_DESTROY_SEQUENCE \ 70 smop_s1p_endofiterator_destr(); \ 69 71 smop_s1p_emptylist_destr(); \ 70 72 smop_s1p_array_iterator_destr(); \ … … 164 166 void smop_s1p_emptylist_init(); 165 167 void smop_s1p_emptylist_destr(); 168 void smop_s1p_endofiterator_init(); 169 void smop_s1p_endofiterator_destr(); 166 170 167 171 #endif -
v6/smop/src/smop_s1p_emptylist.c
r22272 r22288 16 16 if (identifier == SMOP__ID__new) { 17 17 ret = SMOP__S1P__EmptyList; 18 19 } else if (identifier == SMOP__ID__defined) { 20 ret = SMOP__NATIVE__bool_true; 18 21 19 22 } else if (identifier == SMOP__ID__postcircumfix_square) { -
v6/smop/src/smop_s1p_map.sm0p
r22287 r22288 12 12 SMOP__Object* input_iterator; 13 13 SMOP__Object* code; 14 } smop_s1p_ array_struct;14 } smop_s1p_map_iterator_struct; 15 15 16 16 static SMOP__Object* map_iterator_consume_mold; 17 static SMOP__Object* map_iterator_voidcontext_mold; 17 18 18 19 static SMOP__Object* smop_s1p_map_message(SMOP__Object* interpreter, … … 26 27 27 28 if (identifier == SMOP__ID__postcircumfix_parens) { 28 ret = smop_lowlevel_alloc(sizeof(smop_s1p_ array_struct));29 ret = smop_lowlevel_alloc(sizeof(smop_s1p_map_iterator_struct)); 29 30 ret->RI = (SMOP__ResponderInterface*)SMOP__S1P__map; 30 ((smop_s1p_ array_struct*)ret)->code = SMOP__NATIVE__capture_positional(interpreter,capture,0);31 ((smop_s1p_ array_struct*)ret)->input_iterator = SMOP__NATIVE__capture_positional(interpreter,capture,1);31 ((smop_s1p_map_iterator_struct*)ret)->code = SMOP__NATIVE__capture_positional(interpreter,capture,0); 32 ((smop_s1p_map_iterator_struct*)ret)->input_iterator = SMOP__NATIVE__capture_positional(interpreter,capture,1); 32 33 33 34 } else if (identifier == SMOP__ID__Void) { 34 35 // map in void context should evaluate eagerly. 36 37 SMOP__Object* frame = (SMOP__Object*)SMOP__Mold__Frame_create(interpreter,SMOP_REFERENCE(interpreter,map_iterator_voidcontext_mold)); 38 SMOP__Object* back = SMOP_DISPATCH(interpreter, SMOP_RI(interpreter), 39 SMOP__ID__continuation, 40 SMOP__NATIVE__capture_create(interpreter,SMOP_REFERENCE(interpreter,interpreter), 41 NULL,NULL)); 42 43 mold_reg_set(interpreter,frame,0,SMOP_REFERENCE(interpreter,interpreter)); 44 mold_reg_set(interpreter,frame,1,SMOP_REFERENCE(interpreter,capture)); 45 mold_reg_set(interpreter,frame,2,back); 46 mold_reg_set(interpreter,frame,3,SMOP_REFERENCE(interpreter,invocant)); 47 48 SMOP_DISPATCH(interpreter,SMOP_RI(interpreter),SMOP__ID__goto,frame); 35 49 50 } else if (identifier == SMOP__ID__prefix_equal) { 51 // this is the bare iterator without a context applied, which 52 // means that it returns the bare return of the code. 53 54 smop_lowlevel_rdlock(invocant); 55 SMOP__Object* code = ((smop_s1p_map_iterator_struct*)invocant)->code; 56 SMOP__Object* in = ((smop_s1p_map_iterator_struct*)invocant)->input_iterator; 57 smop_lowlevel_unlock(invocant); 58 59 SMOP__Object* frame = (SMOP__Object*)SMOP__Mold__Frame_create(interpreter,SMOP_REFERENCE(interpreter,map_iterator_consume_mold)); 60 SMOP__Object* back = SMOP_DISPATCH(interpreter, SMOP_RI(interpreter), 61 SMOP__ID__continuation, 62 SMOP__NATIVE__capture_create(interpreter,SMOP_REFERENCE(interpreter,interpreter), 63 NULL,NULL)); 64 65 mold_reg_set(interpreter,frame,0,SMOP_REFERENCE(interpreter,interpreter)); 66 mold_reg_set(interpreter,frame,1,SMOP_REFERENCE(interpreter,capture)); 67 mold_reg_set(interpreter,frame,2,back); 68 mold_reg_set(interpreter,frame,3,SMOP_REFERENCE(interpreter,code)); 69 mold_reg_set(interpreter,frame,4,SMOP_REFERENCE(interpreter,in)); 70 71 SMOP_DISPATCH(interpreter,SMOP_RI(interpreter),SMOP__ID__goto,frame); 36 72 37 73 } else if (identifier == SMOP__ID__DESTROYALL) { 38 74 smop_lowlevel_wrlock(invocant); 39 SMOP__Object* code = ((smop_s1p_ array_struct*)invocant)->code;40 ((smop_s1p_ array_struct*)invocant)->code = NULL;41 SMOP__Object* in = ((smop_s1p_ array_struct*)invocant)->input_iterator;42 ((smop_s1p_ array_struct*)invocant)->input_iterator = NULL;75 SMOP__Object* code = ((smop_s1p_map_iterator_struct*)invocant)->code; 76 ((smop_s1p_map_iterator_struct*)invocant)->code = NULL; 77 SMOP__Object* in = ((smop_s1p_map_iterator_struct*)invocant)->input_iterator; 78 ((smop_s1p_map_iterator_struct*)invocant)->input_iterator = NULL; 43 79 smop_lowlevel_unlock(invocant); 44 80 … … 71 107 SMOP__Object* interpreter = SMOP__GlobalInterpreter; 72 108 map_iterator_consume_mold = q:m0ld { 109 my $interpreter; 73 110 my $capture; 74 111 my $back; 75 my $interpreter; 112 my $code; 113 my $input_iterator; 114 115 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"(); 120 if $bool { goto iteration } else { goto end }; 76 121 77 78 my $result; 122 iteration: 123 my $item = $next_item."FETCH"(); 124 my $result = $code."postcircumfix:( )"($item); 79 125 my $void = $back."setr"($result); 80 126 $void = $interpreter."goto"($back); 127 128 end: 129 $void = $back."setr"(¢SMOP__S1P__EndOfIterator); 130 $void = $interpreter."goto"($back); 131 132 }; 133 134 map_iterator_voidcontext_mold = q:m0ld { 135 my $interpreter; 136 my $capture; 137 my $back; 138 my $invocant; 139 140 while: 141 my $result = $invocant."prefix:="(); 142 my $defined = $result."defined"(); 143 144 if $defined { goto iteration } else { goto end }; 145 146 iteration: 147 goto while; 148 149 end: 150 my $void = $interpreter."goto"($back); 151 81 152 }; 82 153 … … 86 157 SMOP_RELEASE(SMOP__GlobalInterpreter, map_iterator_consume_mold); 87 158 map_iterator_consume_mold = NULL; 159 SMOP_RELEASE(SMOP__GlobalInterpreter, map_iterator_voidcontext_mold); 160 map_iterator_voidcontext_mold = NULL; 88 161 } 89 162
