Show
Ignore:
Timestamp:
07/03/08 16:03:58 (5 months ago)
Author:
ruoso
Message:

[smop] some more work in p6opaque, delegation almost working... I need to finish the "setting how" method, so I can effectively test the delegation

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • v6/smop/src/p6opaque.sm0p

    r21179 r21182  
    102102                                      SMOP__Object* capture) { 
    103103  SMOP__Object* ret = SMOP__NATIVE__bool_false; 
     104 
    104105  if (identifier == SMOP__ID__REPR_CREATE) { 
    105106    ret = smop_lowlevel_alloc(sizeof(SMOP__p6opaque_struct)); 
    106107    ret->RI = (SMOP__ResponderInterface*)SMOP__p6opaque__RI; 
     108 
    107109  } else if (identifier == SMOP__ID__REPR_how) { 
    108     fprintf(stderr,"[SMOP p6opaque] .^!how not implemented"); 
    109     ret = SMOP__NATIVE__bool_true; 
     110    if (SMOP_RI(capture) == (SMOP__ResponderInterface*)SMOP__NATIVE__capture) { 
     111      SMOP__Object* invocant = SMOP__NATIVE__capture_invocant(interpreter,capture); 
     112      SMOP__Object* set = SMOP__NATIVE__capture_positional(interpreter,capture,0); 
     113 
     114      if (invocant == SMOP__p6opaque__RI) { 
     115        fprintf(stderr, "[SMOP p6opaque] TODO: p6opaque RI's meta undefined yet\n"); 
     116        ret = SMOP__NATIVE__bool_false; 
     117      } else { 
     118        if (set) 
     119          smop_lowlevel_wrlock(invocant); 
     120        else 
     121          smop_lowlevel_rdlock(invocant); 
     122 
     123        if (((SMOP__p6opaque_struct*)invocant)->metadata) { 
     124          // we have our own metadata. 
     125          SMOP__Object* old = ((SMOP__p6opaque_struct*)invocant)->metadata->how; 
     126          ret = old; 
     127          if (set) { 
     128            ((SMOP__p6opaque_struct*)invocant)->metadata->how = set; 
     129            ret = set; 
     130          } 
     131          smop_lowlevel_unlock(invocant); 
     132          if (old) SMOP_RELEASE(interpreter, old); 
     133 
     134        } else if (((SMOP__p6opaque_struct*)invocant)->instanceof) { 
     135 
     136          // re-dispatch to the instanceof 
     137          SMOP__Object* super = ((SMOP__p6opaque_struct*)invocant)->instanceof; 
     138          smop_lowlevel_unlock(invocant); 
     139 
     140          if (set) { 
     141            fprintf(stderr, "[SMOP p6opaque] Can't set how on a instance\n"); 
     142          } else { 
     143 
     144            ret = SMOP__NATIVE__bool_true; 
     145            SMOP__Object* frame; 
     146            SMOP__Object* continuation = SMOP_DISPATCH(interpreter, SMOP_RI(interpreter), 
     147                                                       SMOP__ID__continuation, interpreter); 
     148            $frame = q:sm0p { 
     149              $continuation; 
     150              $super.SMOP__ID__REPR_how(); 
     151              SMOP__SLIME__CurrentFrame.move_capturize(SMOP__SLIME__Capturize.new(2,(1),(),1)); 
     152              $continuation.setr(); 
     153              $interpreter.goto(|$continuation); 
     154            }; 
     155 
     156            SMOP_DISPATCH(interpreter, SMOP_RI(interpreter), 
     157                          SMOP__ID__goto, 
     158                          frame); 
     159          } 
     160 
     161        } else if (set) { 
     162          // create the metadata struct and set the how. 
     163         
     164 
     165        } else { 
     166 
     167          fprintf(stderr,"[SMOP p6opaque] TODO: invalid .^!how call\n"); 
     168        } 
     169      } 
     170 
     171      if (set) SMOP_RELEASE(interpreter,set); 
     172      SMOP_RELEASE(interpreter,invocant); 
     173    } else { 
     174      fprintf(stderr,"[SMOP p6opaque] TODO: non-native captures\n"); 
     175      ret = SMOP__NATIVE__bool_false; 
     176    } 
    110177  } else { 
    111178    // as we want to support different captures, we'll start to use a 
     
    164231  ((SMOP__ResponderInterface*)SMOP__p6opaque__RI)->REFERENCE = p6opaque_reference; 
    165232  ((SMOP__ResponderInterface*)SMOP__p6opaque__RI)->RELEASE = p6opaque_release; 
     233  ((SMOP__ResponderInterface*)SMOP__p6opaque__RI)->id = "p6opaque"; 
    166234 
    167235}