Permalink
Browse files

Unfudges for symbols overhaul

  • Loading branch information...
1 parent 4873794 commit e1153e0504c004a306ed40b890c2b24b3142e28c @sorear sorear committed Jun 16, 2011
Showing with 14 additions and 12 deletions.
  1. +3 −3 bin/yapsi
  2. +8 −6 lib/Yapsi.pm
  3. +1 −1 t/compiler.t
  4. +2 −2 t/runtime.t
View
@@ -10,15 +10,15 @@ my $*PROGRAM_NAME = 'yapsi';
sub run-code($program, :$target) {
try {
my @output;
- given ::Yapsi::Compiler.new {
+ given Yapsi::Compiler.new {
@output = $target eq 'future'
?? .to-future($program)
!! .compile($program);
warn $_ for .warnings;
}
if $target eq 'run' {
- my ::Yapsi::Runtime $runtime .= new;
+ my Yapsi::Runtime $runtime .= new;
$runtime.run(@output);
}
else {
@@ -37,7 +37,7 @@ if @*ARGS && @*ARGS[0] eq '--version' {
my $target = 'run';
if @*ARGS && @*ARGS[0] ~~ /'--target='(\w+)/ {
die "Recognized targets: {@TARGETS}"
- unless @TARGETS.grep(* eq $0.lc);
+ unless $0.lc eq any @TARGETS;
$target = $0.lc;
shift @*ARGS;
}
View
@@ -141,7 +141,7 @@ class FUTURE::Until is FUTURE::Op {}
sub traverse-top-down(Match $m, :$key = "TOP", :&action, :@skip) {
action($m, $key);
for %($m).keys -> $key {
- next if grep * eq $key, @skip;
+ next if $key eq any @skip;
given $m{$key} {
when Match { traverse-top-down($_, :$key, :&action, :@skip) }
when List { traverse-top-down($_, :$key, :&action, :@skip)
@@ -383,7 +383,7 @@ class Yapsi::Compiler {
my @already-serialized;
while @blocks-to-serialize > @already-serialized {
- my $block = first -> $b { !grep * === $b, @already-serialized },
+ my $block = first { $_ !=== any(@already-serialized) },
@blocks-to-serialize;
serialize $block;
push @already-serialized, $block;
@@ -511,7 +511,7 @@ class Yapsi::Compiler {
multi process(FUTURE::Block $block) {
$register = unique-register;
push @blocks-to-serialize, $block
- unless grep * === $block, @already-serialized;
+ unless any(@already-serialized) === $block;
if $block.phaser {
unshift @blocksic,
"$register = closure-from-block '$block.name()'",
@@ -656,7 +656,7 @@ class Lexpad {
has Lexpad $.outer;
method Str {
- "lexpad[" ~ %.names.sort({ $^a.value leg $^b.value })>>.key.join(", ") ~ "]";
+ "lexpad[" ~ %.names.sort(*.value)>>.key.join(", ") ~ "]";
}
}
@@ -681,8 +681,10 @@ sub find-label(@sic, $name) {
die "Didn't find label $name";
}
+subset Yapsi::IO where { .can('say') }
+
class Yapsi::Runtime {
- has $.io = $*OUT;
+ has Yapsi::IO $.io = $*OUT;
has Lexpad $.current-lexpad;
method run(@sic) {
@@ -717,7 +719,7 @@ class Yapsi::Runtime {
given $0 {
when "var" {
push @vars, ~$1;
- my $is-our-variable = ?( grep ':our', @($2) );
+ my $is-our-variable = ?( ':our' eq any $2>>.Str );
my $container = $is-our-variable
?? (.slots[.names{~$1}] given $global-lexpad)
!! Container.new;
View
@@ -2,7 +2,7 @@ use v6;
use Test;
use Yapsi;
-my $c = ::Yapsi::Compiler.new;
+my Yapsi::Compiler $c .= new;
my @programs-that-compile =
'',
View
@@ -7,8 +7,8 @@ my $out;
my $clear = method ($out is rw:) { $out = '' }
my $io-collector = class { method say($i) {$out ~= $i ~ "\n"} };
-my ::Yapsi::Compiler $compiler .= new;
-my ::Yapsi::Runtime $runtime .= new( :io($io-collector) );
+my Yapsi::Compiler $compiler .= new;
+my Yapsi::Runtime $runtime .= new( :io($io-collector) );
my @tests =
'say 42', "42\n", 'printing',

0 comments on commit e1153e0

Please sign in to comment.