cvsuser     04/11/26 21:49:22

  Modified:    compilers/pge pge_gen.c
               runtime/parrot/library PGE.pir
               runtime/parrot/library/PGE Class.pir
               t/library pge.t
  Log:
  Changed PGE to "new" class method style, rather than "find_type" style.
  
  Revision  Changes    Path
  1.5       +3 -3      parrot/compilers/pge/pge_gen.c
  
  Index: pge_gen.c
  ===================================================================
  RCS file: /cvs/public/parrot/compilers/pge/pge_gen.c,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- pge_gen.c 23 Nov 2004 14:09:15 -0000      1.4
  +++ pge_gen.c 27 Nov 2004 05:49:20 -0000      1.5
  @@ -533,11 +533,11 @@
       emit("    .param string target\n");
       emit("    .local pmc match\n");
       emit("    .local pmc rulecor\n");
  +    emit("    .local pmc newmeth\n");
       emit("  class_loaded:\n");
  -    emit("    find_type $I0, \"PGE::Match\"\n");
  -    emit("    new match, $I0\n");
       emit("    newsub rulecor, .Coroutine, _PGE_Rule_cor\n");
  -    emit("    match.\"_init\"(target, rulecor)\n");
  +    emit("    find_global newmeth, \"PGE::Match\", \"new\"\n");
  +    emit("    match = newmeth(target, rulecor)\n");
       emit("    match.\"_next\"()\n");
       emit("    .return(match)\n");
       emit(".end\n\n");
  
  
  
  1.2       +13 -0     parrot/runtime/parrot/library/PGE.pir
  
  Index: PGE.pir
  ===================================================================
  RCS file: /cvs/public/parrot/runtime/parrot/library/PGE.pir,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- PGE.pir   22 Nov 2004 19:55:53 -0000      1.1
  +++ PGE.pir   27 Nov 2004 05:49:21 -0000      1.2
  @@ -129,10 +129,23 @@
   
   .namespace [ "PGE::Match" ]
   
  +.sub "new"
  +    .param string target
  +    .param pmc rule_coro
  +
  +    .local pmc self
  +    find_type $I0, "PGE::Match"
  +    new self, $I0
  +    self."_init"(target, rule_coro)
  +
  +    .return(self)
  +.end
  +
   .sub _init method
       .param string target
       .param pmc rulecor
       .local pmc state, rephash, caphash
  +    
       $P0 = new .PerlString                  # set .target
       $P0 = target
       classoffset $I0, self, "PGE::Match"       
  
  
  
  1.3       +24 -51    parrot/runtime/parrot/library/PGE/Class.pir
  
  Index: Class.pir
  ===================================================================
  RCS file: /cvs/public/parrot/runtime/parrot/library/PGE/Class.pir,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- Class.pir 23 Nov 2004 13:42:15 -0000      1.2
  +++ Class.pir 27 Nov 2004 05:49:22 -0000      1.3
  @@ -127,14 +127,10 @@
   <[aeiou]> in Perl 6-land).  To use this class:
   
       # create the character class
  +    .local pmc new_sub
       .local pmc class
  -    find_type $I0, "PGE::Class::Discrete"
  -    new class, $I0
  -
  -    # assign the characters it will match
  -    class = "aeiou"
  -    # or
  -    class.set_chars("aeiou")
  +    find_global new_sub, "PGE::Class::Discrete", "new"
  +    class = new_sub("aeiou")
   
       # decide whether it matches a character
       .local int matches
  @@ -145,38 +141,22 @@
   Ranges ("a-m") are not supported.  That means the three characters "a", "-",
   and "m".  
   
  -Also keep in mind that you can't (yet) do:
  -
  -    matches = class[$S0]
  -
  -Because of how parrot creates keys.  Use the method form or make a Key object
  -in that case.
  -
   =cut
   
  -.sub __init method
  -    .local int offset
  -    classoffset offset, self, "PGE::Class::Discrete"
  +.sub "new"
  +    .param string chars
  +    .local pmc me
   
  -    $P0 = new String
  -    setattribute self, offset, $P0
  -    .return()
  -.end
  +    find_type $I0, "PGE::Class::Discrete"
  +    new me, $I0
   
  -.sub __set_string_native method
  -    .param string list
       .local int offset
  -    classoffset offset, self, "PGE::Class::Discrete"
  -    getattribute $P0, self, offset
  +    classoffset offset, me, "PGE::Class::Discrete"
   
  -    $P0 = list
  -    .return()
  -.end
  -
  -.sub set_chars method
  -    .param string list
  -    self = list
  -    .return()
  +    $P0 = new String
  +    $P0 = chars
  +    setattribute me, offset, $P0
  +    .return(me)
   .end
   
   .sub __get_integer_keyed method
  @@ -206,30 +186,23 @@
   
       # create the character class
       .local pmc class
  -    find_type $I0, "PGE::Class::Invert"
  -    new class, $I0
  -
  -    # assign a child object
  -    assign class, some_other_p6ge_class
  -    # or
  -    class.set_child(some_other_p6ge_class)
  +    .local pmc new_sub
  +    find_global new_sub, "PGE::Class::Invert", "new"
  +    class = new_sub(some_other_pge_class)
   
   =cut
   
  -.sub __set_pmc method
  +.sub "new"
       .param pmc child
  +    .local pmc me
   
  -    .local int offset
  -    classoffset offset, self, "PGE::Class::Invert"
  -    setattribute self, offset, child
  -    .return()
  -.end
  -
  -.sub set_child method
  -    .param pmc child
  +    find_type $I0, "PGE::Class::Invert"
  +    new me, $I0
   
  -    assign self, child
  -    .return()
  +    .local int offset
  +    classoffset offset, me, "PGE::Class::Invert"
  +    setattribute me, offset, child
  +    .return(me)
   .end
   
   .sub __get_integer_keyed method
  
  
  
  1.2       +8 -9      parrot/t/library/pge.t
  
  Index: pge.t
  ===================================================================
  RCS file: /cvs/public/parrot/t/library/pge.t,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- pge.t     23 Nov 2004 13:42:16 -0000      1.1
  +++ pge.t     27 Nov 2004 05:49:22 -0000      1.2
  @@ -1,6 +1,6 @@
   #! perl -w
   # Copyright: 2001-2003 The Perl Foundation.  All Rights Reserved.
  -# $Id: pge.t,v 1.1 2004/11/23 13:42:16 luqui Exp $
  +# $Id: pge.t,v 1.2 2004/11/27 05:49:22 luqui Exp $
   
   =head1 NAME
   
  @@ -23,10 +23,10 @@
       load_bytecode "library/PGE/Class.pir"
   
       .local pmc vowels
  -    $I0 = find_type "PGE::Class::Discrete"
  -    new vowels, $I0
  +    .local pmc new_sub
   
  -    set vowels, "aeiou"
  +    find_global new_sub, "PGE::Class::Discrete", "new"
  +    vowels = new_sub("aeiou")
   
       $I1 = vowels["o"]
       if $I1 goto OK1
  @@ -48,16 +48,15 @@
   OUT
   
   # 2
  -output_is(<<'CODE', <<'OUT', "character class membership: method forms");
  +output_is(<<'CODE', <<'OUT', "character class membership: method form");
   ##PIR##
   .sub _main
       load_bytecode "library/PGE/Class.pir"
   
       .local pmc vowels
  -    $I0 = find_type "PGE::Class::Discrete"
  -    new vowels, $I0
  -
  -    vowels.set_chars("aeiou")
  +    .local pmc new_sub
  +    find_global new_sub, "PGE::Class::Discrete", "new"
  +    vowels = new_sub("aeiou")
   
       $I1 = vowels.matches("o")
       if $I1 goto OK1
  
  
  

Reply via email to