Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Clean up $*ARGFILES, .lines, .eof, and .get.
  • Loading branch information
pmichaud committed Jul 25, 2011
1 parent ad0bb3f commit 953c714
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 10 deletions.
4 changes: 3 additions & 1 deletion src/Perl6/Compiler.nqp
Expand Up @@ -4,7 +4,9 @@ use QRegex;
class Perl6::Compiler is HLL::Compiler {
method command_eval(*@args, *%options) {
my $hll_ns := pir::get_root_global__Ps('perl6');
$hll_ns<@!ARGS> := @args;
my $argiter := nqp::iterator(@args);
nqp::shift($argiter) unless pir::defined(%options<e>);
$hll_ns<$!ARGITER> := $argiter;
my $super := pir::find_method__PPs(HLL::Compiler, 'command_eval');
$super(self, |@args, |%options);
}
Expand Down
11 changes: 5 additions & 6 deletions src/core/IO/ArgFiles.pm
Expand Up @@ -4,7 +4,9 @@ my class ArgFiles {
has $!io;
has $!ins;

method eof() { ! $!args }
method eof() {
! $!args && $!io.opened && $!io.eof
}

method get() {
unless $!io.defined && $!io.opened {
Expand All @@ -25,11 +27,8 @@ my class ArgFiles {

method lines($limit = *) {
my $l = $limit ~~ Whatever ?? $Inf !! $limit;
gather while !$.eof && $l-- > 0 {
my $line = $.get;
if $line.defined {
take $line;
}
gather while $l-- > 0 {
take $.get // last;
}
}
}
Expand Down
4 changes: 1 addition & 3 deletions src/core/terms.pm
Expand Up @@ -2,9 +2,7 @@ sub term:<time>() { nqp::p6box_i(pir::time__I()) }

{
my @ARGS;
my Mu $argiter := nqp::iterator(pir::get_hll_global__Ps('@!ARGS'));
$argiter := nqp::iterator(pir::get_hll_global__Ps('@!ARGS'));
nqp::shift($argiter) if $argiter;
my Mu $argiter := pir::get_hll_global__Ps('$!ARGITER');
@ARGS.push(nqp::p6box_s(nqp::shift($argiter))) while $argiter;
nqp::bindkey(pir::get_who__PP(PROCESS), '@ARGS', @ARGS);
$PROCESS::ARGFILES = ArgFiles.new(:args(@ARGS));
Expand Down

0 comments on commit 953c714

Please sign in to comment.