[svn:parrot] r44573 - in branches/ops_pct/compilers/opsc: src/Ops src/Ops/Compiler t
bacek at svn.parrot.org
bacek at svn.parrot.org
Mon Mar 1 12:34:35 UTC 2010
Author: bacek
Date: Mon Mar 1 12:34:35 2010
New Revision: 44573
URL: https://trac.parrot.org/parrot/changeset/44573
Log:
Move expand_args into Actions
Modified:
branches/ops_pct/compilers/opsc/src/Ops/Compiler.pm
branches/ops_pct/compilers/opsc/src/Ops/Compiler/Actions.pm
branches/ops_pct/compilers/opsc/t/03-past.t
Modified: branches/ops_pct/compilers/opsc/src/Ops/Compiler.pm
==============================================================================
--- branches/ops_pct/compilers/opsc/src/Ops/Compiler.pm Mon Mar 1 12:34:06 2010 (r44572)
+++ branches/ops_pct/compilers/opsc/src/Ops/Compiler.pm Mon Mar 1 12:34:35 2010 (r44573)
@@ -7,40 +7,5 @@
Ops::Compiler.parseactions(Ops::Compiler::Actions);
}
-=begin
-
-=item C<expand_args(@args)>
-
-Given an argument list, returns a list of all the possible argument
-combinations.
-
-=end
-sub expand_args(@args) {
-
- return list() unless + at args;
-
- my $arg := @args.shift;
-
- my @var := list($arg<type>);
- if $arg<variant> {
- @var.push($arg<variant>);
- }
-
- my @list := expand_args(@args);
- unless + at list {
- return @var;
- }
-
- my @results;
- for @list -> $l {
- for @var -> $v {
- # NQP can't handle it automagically. So wrap $l into list.
- my @l := pir::does__IPS($l, 'array') ?? $l !! list($l);
- @results.push(list($v, |@l));
- }
- }
-
- @results;
-}
# vim: ft=perl6 expandtab shiftwidth=4:
Modified: branches/ops_pct/compilers/opsc/src/Ops/Compiler/Actions.pm
==============================================================================
--- branches/ops_pct/compilers/opsc/src/Ops/Compiler/Actions.pm Mon Mar 1 12:34:06 2010 (r44572)
+++ branches/ops_pct/compilers/opsc/src/Ops/Compiler/Actions.pm Mon Mar 1 12:34:35 2010 (r44573)
@@ -121,11 +121,41 @@
@result;
}
-# Expand normalized arguments. Create list of all possible variants of arguments.
-sub expand_arguments(*@args) {
- return unless + at args;
-}
+=begin
+
+=item C<expand_args(@args)>
+
+Given an argument list, returns a list of all the possible argument
+combinations.
+
+=end
+sub expand_args(@args) {
+ return list() unless + at args;
+
+ my $arg := @args.shift;
+
+ my @var := list($arg<type>);
+ if $arg<variant> {
+ @var.push($arg<variant>);
+ }
+
+ my @list := expand_args(@args);
+ unless + at list {
+ return @var;
+ }
+
+ my @results;
+ for @list -> $l {
+ for @var -> $v {
+ # NQP can't handle it automagically. So wrap $l into list.
+ my @l := pir::does__IPS($l, 'array') ?? $l !! list($l);
+ @results.push(list($v, |@l));
+ }
+ }
+
+ @results;
+}
method op_params($/) {
Modified: branches/ops_pct/compilers/opsc/t/03-past.t
==============================================================================
--- branches/ops_pct/compilers/opsc/t/03-past.t Mon Mar 1 12:34:06 2010 (r44572)
+++ branches/ops_pct/compilers/opsc/t/03-past.t Mon Mar 1 12:34:35 2010 (r44573)
@@ -82,7 +82,7 @@
ok($arg<type> eq 'nc', 'Third type is correct');
ok(!($arg<variant>), 'Third arg without variant');
-my @expanded := Ops::Compiler::expand_args(@args);
+my @expanded := Ops::Compiler::Actions::expand_args(@args);
#_dumper(@expanded);
ok( @expanded[0].join('_') eq 'i_p_nc', "First variant correct");
More information about the parrot-commits
mailing list