Changeset 21201

Show
Ignore:
Timestamp:
07/03/08 23:23:38 (3 months ago)
Author:
ruoso
Message:

[smop] still more work on p6opaque, few bugs fixed, some slime bugs still.

Location:
v6/smop
Files:
6 modified

Legend:

Unmodified
Added
Removed
  • v6/smop/src/Makefile.am

    r21180 r21201  
    22        perl $(top_srcdir)/sm0p.pl $(top_srcdir) $< $@ 
    33 
    4 AM_CFLAGS = -Wall -D_GNU_SOURCE -DSMOP_LOWLEVEL_MEM_TRACE -I$(top_srcdir)/include 
     4AM_CFLAGS = -Wall -D_GNU_SOURCE -DSMOP_LOWLEVEL_MEM_TRACE -I$(top_srcdir)/include  
    55AM_LDFLAGS = --no-undefined 
    66# use this to see alloc, refcnt_inc, refcnt_dec and destroys...    -DSMOP_LOWLEVEL_MEM_DEBUG  
  • v6/smop/src/p6opaque.sm0p

    r21182 r21201  
    115115        fprintf(stderr, "[SMOP p6opaque] TODO: p6opaque RI's meta undefined yet\n"); 
    116116        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; 
    117120      } else { 
    118121        if (set) 
     
    140143          if (set) { 
    141144            fprintf(stderr, "[SMOP p6opaque] Can't set how on a instance\n"); 
     145            SMOP_RELEASE(interpreter,set); 
    142146          } else { 
    143147 
     
    145149            SMOP__Object* frame; 
    146150            SMOP__Object* continuation = SMOP_DISPATCH(interpreter, SMOP_RI(interpreter), 
    147                                                        SMOP__ID__continuation, interpreter); 
     151                                                       SMOP__ID__continuation, SMOP_REFERENCE(interpreter,interpreter)); 
    148152            $frame = q:sm0p { 
    149153              $continuation; 
     
    161165        } else if (set) { 
    162166          // 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); 
    165174        } else { 
    166  
    167175          fprintf(stderr,"[SMOP p6opaque] TODO: invalid .^!how call\n"); 
    168176        } 
     
    182190    SMOP__Object* frame; 
    183191    SMOP__Object* continuation = SMOP_DISPATCH(interpreter, SMOP_RI(interpreter), 
    184                                                SMOP__ID__continuation, interpreter); 
     192                                               SMOP__ID__continuation,  
     193                                               SMOP_REFERENCE(interpreter,interpreter)); 
    185194    $frame = q:sm0p { 
    186195      $capture; 
  • v6/smop/src/smop_interpreter.c

    r20478 r21201  
    4747                    SMOP__NATIVE__capture_create(invocant, SMOP_REFERENCE(invocant,cont), NULL, NULL)); 
    4848       
     49       
    4950      if (invocant != SMOP__INTPTR__InterpreterInstance) { 
    5051        smop_lowlevel_rdlock(invocant); 
  • v6/smop/src/smop_slime_frame.c

    r20100 r21201  
    174174      SMOP__Object* node = ((smop_slime_frame_struct*)frame)->nodes[pc]; 
    175175      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)); 
    178178      SMOP_RELEASE(interpreter,frame); 
    179179      ret = SMOP__NATIVE__bool_true; 
     
    253253      assert(SMOP_RI(count) == (SMOP__ResponderInterface*)SMOP__NATIVE__int); 
    254254      int c = SMOP__NATIVE__int_fetch(count); 
     255      SMOP_RELEASE(interpreter, count); 
    255256      smop_lowlevel_rdlock(frame); 
    256257      int pc = ((smop_slime_frame_struct*)frame)->pc; 
     
    260261      SMOP__Object* res = SMOP_DISPATCH(interpreter,SMOP_RI(node),SMOP__ID__result, 
    261262                                        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))); 
    264267      ret = SMOP__NATIVE__bool_true; 
    265268      SMOP_RELEASE(interpreter,frame); 
     
    277280      int c = SMOP__NATIVE__int_fetch(count); 
    278281      int t = SMOP__NATIVE__int_fetch(target); 
     282      SMOP_RELEASE(interpreter, count); 
     283      SMOP_RELEASE(interpreter, target); 
    279284      smop_lowlevel_rdlock(frame); 
    280285      int pc = ((smop_slime_frame_struct*)frame)->pc; 
     
    285290                                        SMOP__NATIVE__capture_create(interpreter,SMOP_REFERENCE(interpreter,node),NULL,NULL)); 
    286291      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); 
    288296      ret = SMOP__NATIVE__bool_true; 
    289297      SMOP_RELEASE(interpreter,frame); 
     
    325333                                        SMOP__NATIVE__capture_create(interpreter,SMOP_REFERENCE(interpreter,node),NULL,NULL)); 
    326334      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)); 
    328336      SMOP_RELEASE(interpreter,count); 
    329337      SMOP_RELEASE(interpreter,target); 
  • v6/smop/src/smop_slime_node.c

    r20099 r21201  
    4545      old = ((smop_slime_node_struct*)node)->responder; 
    4646      ((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); 
    5354    if (old) SMOP_RELEASE(interpreter, old); 
    5455    SMOP_RELEASE(interpreter,node); 
     
    160161    smop_lowlevel_unlock(node); 
    161162 
    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"); 
    164164 
    165165    if (responder) { 
  • v6/smop/test/12_p6opaque.sm0p

    r21129 r21201  
    88  smop_init(); 
    99 
    10   printf("1..5\n"); 
     10  printf("1..4\n"); 
    1111 
    1212 
     
    1616                                                                         SMOP__INTPTR__InterpreterInstance,NULL,NULL)); 
    1717  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 
    2024  $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(); 
    2527  }; 
     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  //}; 
    2632 
    2733  if (!frame) printf("not "); 
    2834  printf("ok 1 - frame created.\n"); 
    2935 
     36  SMOP_RELEASE(interpreter,p6opaque); 
    3037  SMOP_DISPATCH(interpreter, SMOP_RI(interpreter), 
    3138                SMOP__ID__goto, 
     
    4148 
    4249 
    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  
    5450  SMOP_RELEASE(SMOP__INTPTR__InterpreterInstance,interpreter); 
    5551 
    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"); 
    5753 
    5854  smop_destr();