Changeset 21201
- Timestamp:
- 07/03/08 23:23:38 (3 months ago)
- Location:
- v6/smop
- Files:
-
- 6 modified
-
src/Makefile.am (modified) (1 diff)
-
src/p6opaque.sm0p (modified) (5 diffs)
-
src/smop_interpreter.c (modified) (1 diff)
-
src/smop_slime_frame.c (modified) (6 diffs)
-
src/smop_slime_node.c (modified) (2 diffs)
-
test/12_p6opaque.sm0p (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
v6/smop/src/Makefile.am
r21180 r21201 2 2 perl $(top_srcdir)/sm0p.pl $(top_srcdir) $< $@ 3 3 4 AM_CFLAGS = -Wall -D_GNU_SOURCE -DSMOP_LOWLEVEL_MEM_TRACE -I$(top_srcdir)/include 4 AM_CFLAGS = -Wall -D_GNU_SOURCE -DSMOP_LOWLEVEL_MEM_TRACE -I$(top_srcdir)/include 5 5 AM_LDFLAGS = --no-undefined 6 6 # use this to see alloc, refcnt_inc, refcnt_dec and destroys... -DSMOP_LOWLEVEL_MEM_DEBUG -
v6/smop/src/p6opaque.sm0p
r21182 r21201 115 115 fprintf(stderr, "[SMOP p6opaque] TODO: p6opaque RI's meta undefined yet\n"); 116 116 ret = SMOP__NATIVE__bool_false; 117 } else if (SMOP_RI(invocant) != (SMOP__ResponderInterface*)SMOP__p6opaque__RI) { 118 fprintf(stderr, "[SMOP p6opaque] call to repr method with non p6opaque invocant\n"); 119 ret = SMOP__NATIVE__bool_false; 117 120 } else { 118 121 if (set) … … 140 143 if (set) { 141 144 fprintf(stderr, "[SMOP p6opaque] Can't set how on a instance\n"); 145 SMOP_RELEASE(interpreter,set); 142 146 } else { 143 147 … … 145 149 SMOP__Object* frame; 146 150 SMOP__Object* continuation = SMOP_DISPATCH(interpreter, SMOP_RI(interpreter), 147 SMOP__ID__continuation, interpreter);151 SMOP__ID__continuation, SMOP_REFERENCE(interpreter,interpreter)); 148 152 $frame = q:sm0p { 149 153 $continuation; … … 161 165 } else if (set) { 162 166 // create the metadata struct and set the how. 163 164 167 SMOP__p6opaque_LOWL_metadata* m = calloc(1,sizeof(SMOP__p6opaque_LOWL_metadata)); 168 assert(m); 169 m->how = set; 170 ((SMOP__p6opaque_struct*)invocant)->metadata = m; 171 smop_lowlevel_unlock(invocant); 172 173 ret = SMOP_REFERENCE(interpreter, set); 165 174 } else { 166 167 175 fprintf(stderr,"[SMOP p6opaque] TODO: invalid .^!how call\n"); 168 176 } … … 182 190 SMOP__Object* frame; 183 191 SMOP__Object* continuation = SMOP_DISPATCH(interpreter, SMOP_RI(interpreter), 184 SMOP__ID__continuation, interpreter); 192 SMOP__ID__continuation, 193 SMOP_REFERENCE(interpreter,interpreter)); 185 194 $frame = q:sm0p { 186 195 $capture; -
v6/smop/src/smop_interpreter.c
r20478 r21201 47 47 SMOP__NATIVE__capture_create(invocant, SMOP_REFERENCE(invocant,cont), NULL, NULL)); 48 48 49 49 50 if (invocant != SMOP__INTPTR__InterpreterInstance) { 50 51 smop_lowlevel_rdlock(invocant); -
v6/smop/src/smop_slime_frame.c
r20100 r21201 174 174 SMOP__Object* node = ((smop_slime_frame_struct*)frame)->nodes[pc]; 175 175 smop_lowlevel_unlock(frame); 176 SMOP_DISPATCH(interpreter,SMOP_RI(node),SMOP__ID__ setr,177 SMOP__NATIVE__capture_create(interpreter, node,(SMOP__Object*[]){value, NULL},NULL));176 SMOP_DISPATCH(interpreter,SMOP_RI(node),SMOP__ID__result, 177 SMOP__NATIVE__capture_create(interpreter,SMOP_REFERENCE(interpreter,node),(SMOP__Object*[]){value, NULL},NULL)); 178 178 SMOP_RELEASE(interpreter,frame); 179 179 ret = SMOP__NATIVE__bool_true; … … 253 253 assert(SMOP_RI(count) == (SMOP__ResponderInterface*)SMOP__NATIVE__int); 254 254 int c = SMOP__NATIVE__int_fetch(count); 255 SMOP_RELEASE(interpreter, count); 255 256 smop_lowlevel_rdlock(frame); 256 257 int pc = ((smop_slime_frame_struct*)frame)->pc; … … 260 261 SMOP__Object* res = SMOP_DISPATCH(interpreter,SMOP_RI(node),SMOP__ID__result, 261 262 SMOP__NATIVE__capture_create(interpreter,SMOP_REFERENCE(interpreter,node),NULL,NULL)); 262 SMOP_DISPATCH(interpreter,SMOP_RI(thisnode),SMOP__ID__result, 263 SMOP__NATIVE__capture_create(interpreter,thisnode,(SMOP__Object*[]){res,NULL},NULL)); 263 SMOP_RELEASE(interpreter, 264 SMOP_DISPATCH(interpreter,SMOP_RI(thisnode),SMOP__ID__result, 265 SMOP__NATIVE__capture_create(interpreter, 266 SMOP_REFERENCE(interpreter,thisnode),(SMOP__Object*[]){res,NULL},NULL))); 264 267 ret = SMOP__NATIVE__bool_true; 265 268 SMOP_RELEASE(interpreter,frame); … … 277 280 int c = SMOP__NATIVE__int_fetch(count); 278 281 int t = SMOP__NATIVE__int_fetch(target); 282 SMOP_RELEASE(interpreter, count); 283 SMOP_RELEASE(interpreter, target); 279 284 smop_lowlevel_rdlock(frame); 280 285 int pc = ((smop_slime_frame_struct*)frame)->pc; … … 285 290 SMOP__NATIVE__capture_create(interpreter,SMOP_REFERENCE(interpreter,node),NULL,NULL)); 286 291 SMOP_DISPATCH(interpreter,SMOP_RI(thisnode),SMOP__ID__responder, 287 SMOP__NATIVE__capture_create(interpreter,thisnode,(SMOP__Object*[]){res,NULL},NULL)); 292 SMOP__NATIVE__capture_create(interpreter, 293 SMOP_REFERENCE(interpreter,thisnode), 294 (SMOP__Object*[]){(SMOP__Object*)SMOP_RI(res),NULL},NULL)); 295 SMOP_RELEASE(interpreter, res); 288 296 ret = SMOP__NATIVE__bool_true; 289 297 SMOP_RELEASE(interpreter,frame); … … 325 333 SMOP__NATIVE__capture_create(interpreter,SMOP_REFERENCE(interpreter,node),NULL,NULL)); 326 334 SMOP_DISPATCH(interpreter,SMOP_RI(thisnode),SMOP__ID__identifier, 327 SMOP__NATIVE__capture_create(interpreter, thisnode,(SMOP__Object*[]){res,NULL},NULL));335 SMOP__NATIVE__capture_create(interpreter,SMOP_REFERENCE(interpreter,thisnode),(SMOP__Object*[]){res,NULL},NULL)); 328 336 SMOP_RELEASE(interpreter,count); 329 337 SMOP_RELEASE(interpreter,target); -
v6/smop/src/smop_slime_node.c
r20099 r21201 45 45 old = ((smop_slime_node_struct*)node)->responder; 46 46 ((smop_slime_node_struct*)node)->responder = set; 47 } else { 48 smop_lowlevel_rdlock(node); 49 } 50 ret = ((smop_slime_node_struct*)node)->responder; 51 smop_lowlevel_unlock(node); 52 SMOP_REFERENCE(interpreter,ret); 47 ret = ((smop_slime_node_struct*)node)->responder; 48 } else { 49 smop_lowlevel_rdlock(node); 50 ret = ((smop_slime_node_struct*)node)->responder; 51 SMOP_REFERENCE(interpreter,ret); 52 } 53 smop_lowlevel_unlock(node); 53 54 if (old) SMOP_RELEASE(interpreter, old); 54 55 SMOP_RELEASE(interpreter,node); … … 160 161 smop_lowlevel_unlock(node); 161 162 162 //if (identifier && SMOP_RI(identifier) == SMOP_RI(SMOP__ID__new)) 163 //fprintf(stderr,"[SMOP__SLIME__Node:DEBUG] eval %s.\n", (char*)(identifier->data)); 163 //fprintf(stderr,"[SMOP__SLIME__Node:DEBUG] eval\n"); 164 164 165 165 if (responder) { -
v6/smop/test/12_p6opaque.sm0p
r21129 r21201 8 8 smop_init(); 9 9 10 printf("1.. 5\n");10 printf("1..4\n"); 11 11 12 12 … … 16 16 SMOP__INTPTR__InterpreterInstance,NULL,NULL)); 17 17 SMOP__Object* frame; 18 SMOP__Object* scalar1 = SMOP__S1P__Scalar_create(SMOP__NATIVE__bool_true); 19 18 SMOP__Object* how = SMOP__NATIVE__bool_true; 19 SMOP__Object* p6opaque = 20 SMOP_DISPATCH(SMOP__INTPTR__InterpreterInstance, SMOP__p6opaque__RI, 21 SMOP__ID__REPR_CREATE, SMOP__NATIVE__capture_create(SMOP__INTPTR__InterpreterInstance, 22 SMOP__INTPTR__InterpreterInstance,NULL,NULL)); 23 20 24 $frame = q:sm0p { 21 $scalar1; 22 SMOP__p6opaque__RI.SMOP__ID__REPR_CREATE(); 23 SMOP__SLIME__CurrentFrame.move_capturize(SMOP__SLIME__Capturize.new(2,(1),(),1)); 24 $scalar1.SMOP__ID__STORE(); 25 ; 26 $p6opaque.SMOP__ID__new(); 25 27 }; 28 // SMOP__SLIME__CurrentFrame.move_responder(7,2); 29 // SMOP__SLIME__CurrentFrame.move_capturize(SMOP__SLIME__Capturize.new(9,(),(),1)); 30 // SMOP__p6opaque__RI.SMOP__ID__new(); 31 //}; 26 32 27 33 if (!frame) printf("not "); 28 34 printf("ok 1 - frame created.\n"); 29 35 36 SMOP_RELEASE(interpreter,p6opaque); 30 37 SMOP_DISPATCH(interpreter, SMOP_RI(interpreter), 31 38 SMOP__ID__goto, … … 41 48 42 49 43 SMOP__Object* r1 = SMOP__S1P__Scalar_FETCH(scalar1);44 if (SMOP_RI(r1) != (SMOP__ResponderInterface*)SMOP__p6opaque__RI) printf("not ");45 printf("ok 4 - P6 Opaque created inside the interpreter loop\n");46 47 SMOP_RELEASE(interpreter,scalar1);48 49 SMOP_DISPATCH(interpreter, SMOP_RI(interpreter),50 SMOP__ID__loop, SMOP__NATIVE__capture_create(interpreter,51 SMOP_REFERENCE(interpreter,interpreter),52 NULL, NULL));53 54 50 SMOP_RELEASE(SMOP__INTPTR__InterpreterInstance,interpreter); 55 51 56 printf("ok 5- Scalar destroyed should free the p6opaque object also.\n");52 printf("ok 4 - Scalar destroyed should free the p6opaque object also.\n"); 57 53 58 54 smop_destr();
