Changeset 22940 for v6

Show
Ignore:
Timestamp:
11/09/08 21:26:02 (2 months ago)
Author:
pmurias
Message:

[smop] changed "bool" to "true", native_int uses the RI DSL

Location:
v6/smop
Files:
17 modified
1 moved

Legend:

Unmodified
Added
Removed
  • v6/smop/CMakeLists.txt

    r22915 r22940  
    109109    src/s1p_attribute.ri 
    110110    src/s1p_hash_bvalue.ri 
     111    src/native_int.ri 
    111112) 
    112113compile_ri (${ri_file}) 
  • v6/smop/include/smop_identifiers.h

    r22711 r22940  
    1212extern SMOP__Object* SMOP__ID__BIND;              /* "BIND" */ 
    1313extern SMOP__Object* SMOP__ID__bless;             /* "bless" */ 
    14 extern SMOP__Object* SMOP__ID__bool;              /* "bool" */ 
     14extern SMOP__Object* SMOP__ID__true;              /* "true" */ 
    1515extern SMOP__Object* SMOP__ID__BUILDALL;          /* "BUILDALL" */ 
    1616extern SMOP__Object* SMOP__ID__BUILD;             /* "BUILD" */ 
  • v6/smop/src/idconst_decl_all.h

    r22711 r22940  
    33SMOP__Object* SMOP__ID__BIND; 
    44SMOP__Object* SMOP__ID__bless; 
    5 SMOP__Object* SMOP__ID__bool; 
     5SMOP__Object* SMOP__ID__true; 
    66SMOP__Object* SMOP__ID__BUILDALL; 
    77SMOP__Object* SMOP__ID__BUILD; 
  • v6/smop/src/idconst_init_all.c

    r22711 r22940  
    33SMOP__ID__BIND = SMOP__NATIVE__idconst_create_nolist( "BIND" ); 
    44SMOP__ID__bless = SMOP__NATIVE__idconst_create_nolist( "bless" ); 
    5 SMOP__ID__bool = SMOP__NATIVE__idconst_create_nolist( "bool" ); 
     5SMOP__ID__true = SMOP__NATIVE__idconst_create_nolist( "true" ); 
    66SMOP__ID__BUILDALL = SMOP__NATIVE__idconst_create_nolist( "BUILDALL" ); 
    77SMOP__ID__BUILD = SMOP__NATIVE__idconst_create_nolist( "BUILD" ); 
     
    118118constlist[2] = SMOP__ID__BIND; 
    119119constlist[3] = SMOP__ID__bless; 
    120 constlist[4] = SMOP__ID__bool; 
     120constlist[4] = SMOP__ID__true; 
    121121constlist[5] = SMOP__ID__BUILDALL; 
    122122constlist[6] = SMOP__ID__BUILD; 
  • v6/smop/src/lowlevel.sm0p

    r22923 r22940  
    156156 
    157157      if ((SMOP__Object*)SMOP_RI(value) == SMOP__INTPTR__InterpreterInstance || 
    158           (SMOP__Object*)SMOP_RI(value) == SMOP__NATIVE__capture || 
    159           (SMOP__Object*)SMOP_RI(value) == SMOP__NATIVE__int || 
    160           (SMOP__Object*)SMOP_RI(value) == SMOP__NATIVE__uint) { 
     158          (SMOP__Object*)SMOP_RI(value) == SMOP__NATIVE__capture) { 
    161159 
    162160        SMOP_DISPATCH(interpreter, SMOP_RI(value), SMOP__ID__DESTROYALL, value); 
     
    179177      smop_lowlevel_free(value); 
    180178    } else if ((SMOP__Object*)SMOP_RI(value) == SMOP__INTPTR__InterpreterInstance || 
    181                (SMOP__Object*)SMOP_RI(value) == SMOP__NATIVE__capture || 
    182                (SMOP__Object*)SMOP_RI(value) == SMOP__NATIVE__int || 
    183                (SMOP__Object*)SMOP_RI(value) == SMOP__NATIVE__uint) { 
     179               (SMOP__Object*)SMOP_RI(value) == SMOP__NATIVE__capture) { 
    184180 
    185181      SMOP_DISPATCH(interpreter, SMOP_RI(value), SMOP__ID__DESTROYALL, value); 
  • v6/smop/src/native_bool.c

    r22663 r22940  
    1919  ___INVOCANT_RI_SHOULD_MATCH___; 
    2020  SMOP__Object* ret = SMOP__NATIVE__bool_false; 
    21   if (identifier == SMOP__ID__bool) { 
     21  if (identifier == SMOP__ID__true) { 
    2222    ret = SMOP_REFERENCE(interpreter,invocant); 
    2323  } else if (identifier == SMOP__ID__defined) { 
  • v6/smop/src/native_int.ri

    r22299 r22940  
    1 #include <stdlib.h> 
    2 #include <smop.h> 
    3 #include <smop_lowlevel.h> 
    4 #include <smop_s1p.h> 
    5 #include <stdio.h> 
    6  
    7 SMOP__Object* SMOP__NATIVE__int; 
    8  
    9 typedef struct smop_native_int_struct { 
    10   SMOP__Object__BASE 
    11   int intvalue; 
    12 } smop_native_int_struct; 
    13  
    14 static SMOP__Object* int_message(SMOP__Object* interpreter, 
    15                                      SMOP__ResponderInterface* self, 
    16                                      SMOP__Object* identifier, 
    17                                      SMOP__Object* capture) { 
    18  
    19   ___CONST_IDENTIFIER_ONLY___; 
    20  
    21   SMOP__Object* ret = SMOP__NATIVE__bool_false; 
    22  
    23   if (identifier == SMOP__ID__infix_num_gt) { 
    24  
    25     ___NATIVE_CAPTURE_ONLY___; 
    26     ___INVOCANT_RI_SHOULD_MATCH___; 
    27  
     1%prefix smop_native_int 
     2%RI SMOP__NATIVE__int 
     3%RI.id Native int 
     4%attr int intvalue 
     5%method infix:> 
    286    SMOP__Object* other = SMOP__NATIVE__capture_positional(interpreter,capture,0); 
    297    if (SMOP_RI(other) == (SMOP__ResponderInterface*)SMOP__NATIVE__int) { 
    30       //fprintf(stderr,"native int: %d > %d\n", SMOP__NATIVE__int_fetch(invocant), 
    31       //        SMOP__NATIVE__int_fetch(other)); 
    328      if (SMOP__NATIVE__int_fetch(invocant) > SMOP__NATIVE__int_fetch(other)) { 
    339        ret = SMOP__NATIVE__bool_true; 
     
    3814      ___UNKNOWN_METHOD___; 
    3915    } 
    40  
    4116    SMOP_RELEASE(interpreter, other); 
    42     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; 
    51  
    52   } else if (identifier == SMOP__ID__infix_num_ge) { 
    53  
    54     ___NATIVE_CAPTURE_ONLY___; 
    55     ___INVOCANT_RI_SHOULD_MATCH___; 
    56  
     17%method infix:>= 
    5718    SMOP__Object* other = SMOP__NATIVE__capture_positional(interpreter,capture,0); 
    5819    if (SMOP_RI(other) == (SMOP__ResponderInterface*)SMOP__NATIVE__int) { 
    59       //fprintf(stderr,"native int: %d > %d\n", SMOP__NATIVE__int_fetch(invocant), 
    60       //        SMOP__NATIVE__int_fetch(other)); 
    6120      if (SMOP__NATIVE__int_fetch(invocant) >= SMOP__NATIVE__int_fetch(other)) { 
    6221        ret = SMOP__NATIVE__bool_true; 
     
    6726      ___UNKNOWN_METHOD___; 
    6827    } 
    69  
    7028    SMOP_RELEASE(interpreter, other); 
    71     SMOP_RELEASE(interpreter,invocant); 
    72  
    73   } else if (identifier == SMOP__ID__DESTROYALL) { 
    74     // notthing 
    75   } else if (identifier == SMOP__ID__new) { 
    76  
     29%method defined 
     30    ret = SMOP__NATIVE__bool_true; 
     31%method FETCH 
     32    ___VALUE_FETCH___; 
     33%method STORE 
     34    ___VALUE_STORE___; 
     35%method new 
    7736    SMOP__Object* other = SMOP__NATIVE__capture_positional(interpreter,capture,0); 
    7837    if (other && SMOP_RI(other) == (SMOP__ResponderInterface*)SMOP__NATIVE__int) { 
     
    8443      return SMOP__NATIVE__int_create(0); 
    8544    } 
    86  
    87   } else if (identifier == SMOP__ID__postfix_plusplus) { 
    88  
    89     ___NATIVE_CAPTURE_ONLY___; 
    90     ___INVOCANT_RI_SHOULD_MATCH___; 
    91  
     45%method postfix:++ 
    9246    smop_lowlevel_wrlock(invocant); 
    9347    ((smop_native_int_struct*)invocant)->intvalue++; 
    9448    smop_lowlevel_unlock(invocant); 
    95  
    96     SMOP_RELEASE(interpreter, invocant); 
    97  
    98   } else { 
    99     ___UNKNOWN_METHOD___; 
    100   } 
    101  
    102   SMOP_RELEASE(interpreter,capture); 
    103   return ret; 
    104 } 
    105  
    106  
    107 void smop_native_int_init() { 
    108   SMOP__NATIVE__int = calloc(1,sizeof(SMOP__ResponderInterface)); 
    109   ((SMOP__ResponderInterface*)SMOP__NATIVE__int)->MESSAGE = int_message; 
    110   ((SMOP__ResponderInterface*)SMOP__NATIVE__int)->REFERENCE = smop_lowlevel_generic_reference; 
    111   ((SMOP__ResponderInterface*)SMOP__NATIVE__int)->RELEASE = smop_lowlevel_generic_release; 
    112   ((SMOP__ResponderInterface*)SMOP__NATIVE__int)->id = "Native int"; 
    113 } 
    114  
    115 void smop_native_int_destr() { 
    116   free(SMOP__NATIVE__int); 
    117 } 
    118  
     49%method DESTROYALL 
     50%{ 
    11951SMOP__Object* SMOP__NATIVE__int_create(int value) { 
    12052  SMOP__Object* ret = smop_lowlevel_alloc(sizeof(smop_native_int_struct)); 
     
    13062  return v; 
    13163} 
     64%} 
  • v6/smop/src/s1p_array.c

    r22729 r22940  
    134134    SMOP_RELEASE(interpreter,invocant->array); 
    135135 
    136   } else if (identifier == SMOP__ID__bool) { 
     136  } else if (identifier == SMOP__ID__true) { 
    137137    ret = SMOP__NATIVE__bool_true; 
    138138 
  • v6/smop/src/s1p_grep.sm0p

    r22543 r22940  
    129129    my $capture = ¢SMOP__S1P__Capturize."capturize"($item); 
    130130    my $result = $code."postcircumfix:( )"($capture); 
    131     my $bool = $result."bool"(); 
     131    my $bool = $result."true"(); 
    132132    if $bool { goto in } else { goto fetch_item }; 
    133133     
  • v6/smop/src/s1p_lexicalscope.ri

    r22725 r22940  
    1919  SMOP_REFERENCE(interpreter, ret); 
    2020 
    21 %method bool 
     21%method true 
    2222  ret = SMOP__NATIVE__bool_true; 
    2323 
     
    8484    else: 
    8585      my $outer = $invocant."outer"(); 
    86       my $outer_true = $outer."bool"(); 
     86      my $outer_true = $outer."true"(); 
    8787      my $outer_cell = $outer."FETCH"(); 
    8888      if $outer_true {goto than2} else {goto else2}; 
  • v6/smop/src/s1p_lexicalscope.sm0p

    r22512 r22940  
    4444    SMOP_REFERENCE(interpreter, ret); 
    4545 
    46   } else if (identifier == SMOP__ID__bool) { 
     46  } else if (identifier == SMOP__ID__true) { 
    4747    ret = SMOP__NATIVE__bool_true; 
    4848 
     
    143143    else: 
    144144      my $outer = $invocant."outer"(); 
    145       my $outer_true = $outer."bool"(); 
     145      my $outer_true = $outer."true"(); 
    146146      my $outer_cell = $outer."FETCH"(); 
    147147      if $outer_true {goto than2} else {goto else2}; 
  • v6/smop/src/s1p_scalar.c

    r22730 r22940  
    4343      SMOP_REFERENCE(interpreter,ret); 
    4444 
    45   } else if (SMOP__ID__bool == identifier) { 
     45  } else if (SMOP__ID__true == identifier) { 
    4646    SMOP__Object* cell = SMOP__S1P__Scalar_FETCH(scalar); 
    4747    ret = SMOP_DISPATCH(interpreter, SMOP_RI(cell), 
    48                         SMOP__ID__bool, 
     48                        SMOP__ID__true, 
    4949                        SMOP__NATIVE__capture_delegate(interpreter, 
    5050                                                       SMOP_REFERENCE(interpreter,cell), 
  • v6/smop/test/32_array_iterator.m0ld

    r22268 r22940  
    2323my $elems = $list."elems"(); 
    2424my $greater = $elems."infix:>"(0); 
    25 my $bool = $greater."bool"(); 
     25my $bool = $greater."true"(); 
    2626 
    2727if $bool { goto iteration } else { goto end }; 
  • v6/smop/test/34_array_unshift.m0ld

    r22289 r22940  
    2323my $elems = $list."elems"(); 
    2424my $greater = $elems."infix:>"(0); 
    25 my $bool = $greater."bool"(); 
     25my $bool = $greater."true"(); 
    2626 
    2727if $bool { goto iteration } else { goto end }; 
  • v6/smop/test/35_array_grep.m0ld

    r22543 r22940  
    3434     
    3535    my $greater = $it."infix:>"(3); 
    36     my $bool = $greater."bool"(); 
     36    my $bool = $greater."true"(); 
    3737     
    3838    my $out_scalar = ¢SMOP__S1P__RootNamespace."postcircumfix:{ }"("$*OUT"); 
     
    6464    
    6565    my $greater = $it."infix:>"(3); 
    66     my $bool = $greater."bool"(); 
     66    my $bool = $greater."true"(); 
    6767     
    6868    my $continuation = $interpreter."continuation"(); 
  • v6/smop/test/36_adhoc_signature.m0ld

    r22525 r22940  
    6464 
    6565my $accepts = $signature."ACCEPTS"(1); 
    66 my $accepts_bool = $accepts."bool"(); 
     66my $accepts_bool = $accepts."true"(); 
    6767if $accepts_bool { goto then } else { goto else }; 
    6868 
  • v6/smop/test/37_multisub.m0ld

    r22692 r22940  
    2323    my $cap = ¢SMOP__S1P__Capturize."capturize"($p1, ¢SMOP__NATIVE__int); 
    2424    my $cmp = ¢SMOP__S1P__ritest."postcircumfix:( )"($cap); 
    25     my $bool = $cmp."bool"(); 
     25    my $bool = $cmp."true"(); 
    2626     
    2727    if $bool { goto nexttest } else { goto false }; 
     
    2929    $cap = ¢SMOP__S1P__Capturize."capturize"($p2, ¢SMOP__NATIVE__int); 
    3030    $cmp = ¢SMOP__S1P__ritest."postcircumfix:( )"($cap); 
    31     $bool = $cmp."bool"(); 
     31    $bool = $cmp."true"(); 
    3232     
    3333    if $bool { goto true } else { goto false }; 
     
    6767    my $cap = ¢SMOP__S1P__Capturize."capturize"($p1, ¢SMOP__NATIVE__bool); 
    6868    my $cmp = ¢SMOP__S1P__ritest."postcircumfix:( )"($cap); 
    69     my $bool = $cmp."bool"(); 
     69    my $bool = $cmp."true"(); 
    7070     
    7171    if $bool { goto nexttest } else { goto false }; 
     
    7373    $cap = ¢SMOP__S1P__Capturize."capturize"($p2, ¢SMOP__NATIVE__bool); 
    7474    $cmp = ¢SMOP__S1P__ritest."postcircumfix:( )"($cap); 
    75     $bool = $cmp."bool"(); 
     75    $bool = $cmp."true"(); 
    7676     
    7777    if $bool { goto true } else { goto false }; 
  • v6/smop/test/38_ritest.m0ld

    r22543 r22940  
    1010my $capture = ¢SMOP__S1P__Capturize."capturize"(1, ¢SMOP__NATIVE__int); 
    1111my $test = ¢SMOP__S1P__ritest."postcircumfix:( )"($capture); 
    12 my $bool = $test."bool"(); 
     12my $bool = $test."true"(); 
    1313 
    1414if $bool { goto isint } else { goto notint }; 
     
    2424$capture = ¢SMOP__S1P__Capturize."capturize"("test", ¢SMOP__NATIVE__int); 
    2525$test = ¢SMOP__S1P__ritest."postcircumfix:( )"($capture); 
    26 $bool = $test."bool"(); 
     26$bool = $test."true"(); 
    2727 
    2828if $bool { goto isint2 } else { goto notint2 };