--- Revision None +++ Revision 343738383139 @@ -0,0 +1,104 @@ +15:39 ~/g/code/p6/crypt$ nom handles.pl +foo(a, b) +bar(A, B) +DEBUG: Methods are: +(submethod BUILD(User , Mu *%_) { ... }, method bar(User , $arg1, $arg2, Mu *%_) { ... }, method foo(Mu , |$c, Mu *%_) { ... }) +Method BUILD: +- param '', type: Userall(), type_captures: , rw: no, copy: no, named: no, named_names: ().list, capture: no, parcel: no, slurpy: no, optional: no, invocant: yes, pos: yes +- param '%_', type: Muall(), type_captures: , rw: no, copy: no, named: yes, named_names: ().list, capture: no, parcel: no, slurpy: yes, optional: no, invocant: no, pos: no +Method bar: +- param '', type: Userall(), type_captures: , rw: no, copy: no, named: no, named_names: ().list, capture: no, parcel: no, slurpy: no, optional: no, invocant: yes, pos: yes +- param '$arg1', type: Anyall(), type_captures: , rw: no, copy: no, named: no, named_names: ().list, capture: no, parcel: no, slurpy: no, optional: no, invocant: no, pos: yes +- param '$arg2', type: Anyall(), type_captures: , rw: no, copy: no, named: no, named_names: ().list, capture: no, parcel: no, slurpy: no, optional: no, invocant: no, pos: yes +- param '%_', type: Muall(), type_captures: , rw: no, copy: no, named: yes, named_names: ().list, capture: no, parcel: no, slurpy: yes, optional: no, invocant: no, pos: no +Method foo: +- param '', type: Muall(), type_captures: , rw: no, copy: no, named: no, named_names: ().list, capture: no, parcel: no, slurpy: no, optional: no, invocant: yes, pos: yes +- param '$c', type: Anyall(), type_captures: , rw: no, copy: no, named: no, named_names: ().list, capture: yes, parcel: no, slurpy: no, optional: no, invocant: no, pos: no +- param '%_', type: Muall(), type_captures: , rw: no, copy: no, named: yes, named_names: ().list, capture: no, parcel: no, slurpy: yes, optional: no, invocant: no, pos: no +DEBUG: Commands are: +("BUILD" => ().list.item, "bar" => ("arg1", "arg2").list.item, "foo" => ().list.item).hash +Commands:("BUILD" => ().list.item, "bar" => ("arg1", "arg2").list.item, "foo" => ().list.item).hash +15:40 ~/g/code/p6/crypt$ perl6 handles.pl +foo(a, b) +bar(A, B) +DEBUG: Methods are: +(submethod BUILD(User , Mu *%_) { ... }, method bar(User , $arg1, $arg2, Mu *%_) { ... }, method foo(Mu , |$c, Mu *%_) { ... }) +Method BUILD: +- param '', type: Userall(), type_captures: , rw: no, copy: no, named: no, named_names: ().list, capture: no, parcel: no, slurpy: no, optional: no, invocant: yes, pos: yes +- param '%_', type: Muall(), type_captures: , rw: no, copy: no, named: yes, named_names: ().list, capture: no, parcel: no, slurpy: yes, optional: no, invocant: no, pos: no +Method bar: +- param '', type: Userall(), type_captures: , rw: no, copy: no, named: no, named_names: ().list, capture: no, parcel: no, slurpy: no, optional: no, invocant: yes, pos: yes +- param '$arg1', type: Anyall(), type_captures: , rw: no, copy: no, named: no, named_names: ().list, capture: no, parcel: no, slurpy: no, optional: no, invocant: no, pos: yes +- param '$arg2', type: Anyall(), type_captures: , rw: no, copy: no, named: no, named_names: ().list, capture: no, parcel: no, slurpy: no, optional: no, invocant: no, pos: yes +- param '%_', type: Muall(), type_captures: , rw: no, copy: no, named: yes, named_names: ().list, capture: no, parcel: no, slurpy: yes, optional: no, invocant: no, pos: no +Method foo: +- param '', type: Muall(), type_captures: , rw: no, copy: no, named: no, named_names: ().list, capture: no, parcel: no, slurpy: no, optional: no, invocant: yes, pos: yes +- param '$c', type: Anyall(), type_captures: , rw: no, copy: no, named: no, named_names: ().list, capture: yes, parcel: no, slurpy: no, optional: no, invocant: no, pos: yes +- param '%_', type: Muall(), type_captures: , rw: no, copy: no, named: yes, named_names: ().list, capture: no, parcel: no, slurpy: yes, optional: no, invocant: no, pos: no +DEBUG: Commands are: +("BUILD" => ().list.item, "bar" => ("arg1", "arg2").list.item, "foo" => ("c",).list.item).hash +Commands:("BUILD" => ().list.item, "bar" => ("arg1", "arg2").list.item, "foo" => ("c",).list.item).hash +15:40 ~/g/code/p6/crypt$ cat handles.pl +#! /usr/bin/env perl6 + +use v6; + +class Engine { + method foo($arg1, $arg2) { say "foo($arg1, $arg2)"; } +} + +class User { + has $!engine handles ; + + submethod BUILD() { $!engine = Engine.new; } + + method bar($arg1, $arg2) { say "bar($arg1, $arg2)"; } +} + +my User $u .= new; + +$u.foo('a', 'b'); +$u.bar('A', 'B'); + +say "Commands:", objCommands($u).perl; + +sub objCommands($obj) { + say "DEBUG: Methods are:\n", $obj.^methods.perl; + sub params($method) { + say "Method {$method.name}:"; + for $method.signature.params { + say "- param '{.name}'", + ", type: {.type.perl}", + ", constraints: {.constraints}", + ", type_captures: {.type_captures}", + # RAKUDO: NYI 2012-07-15 + #", read_only: {.read_only ?? 'yes' !! 'no'}", + ", rw: {.rw ?? 'yes' !! 'no'}", + ", copy: {.copy ?? 'yes' !! 'no'}", + ", named: {.named ?? 'yes' !! 'no'}", + ", named_names: {.named_names.perl}", + ", capture: {.capture ?? 'yes' !! 'no'}", + ", parcel: {.parcel ?? 'yes' !! 'no'}", + ", slurpy: {.slurpy ?? 'yes' !! 'no'}", + ", optional: {.optional ?? 'yes' !! 'no'}", + ", invocant: {.invocant ?? 'yes' !! 'no'}", + #", multi_invocant: {.multi_invocant ?? 'yes' !! 'no'}", + ", pos: {.positional ?? 'yes' !! 'no'}" + ; + } + + $method.signature.params + ==> grep { .positional && !.invocant } + ==> map { .name.substr(1) } + } + my %commands = map { $^m.name => params($m) }, $obj.^methods; + + say "DEBUG: Commands are:\n", %commands.perl; + + return %commands; +} +15:41 ~/g/code/p6/crypt$ perl6 --version +This is perl6 version 2012.06 built on parrot 4.5.0 revision 0 +15:45 ~/g/code/p6/crypt$ nom --version +This is perl6 version 2012.06-87-g499cc68 built on parrot 4.5.0 revision RELEASE_4_5_0 +15:45 ~/g/code/p6/crypt$