"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "src/core.c/Main.pm6" between
rakudo-2020.09.tar.gz and rakudo-2020.10.tar.gz

About: Rakudo is a compiler for the Raku Pogramming Language (formerly known as Perl 6).

Main.pm6  (rakudo-2020.09):Main.pm6  (rakudo-2020.10)
skipping to change at line 49 skipping to change at line 49
# Call the MAIN_HELPER, it should do everything # Call the MAIN_HELPER, it should do everything
return &main_helper.count == 2 return &main_helper.count == 2
?? main_helper($in-as-argsfiles,$mainline) # post 2018.06 interface ?? main_helper($in-as-argsfiles,$mainline) # post 2018.06 interface
!! main_helper($mainline) # original interface !! main_helper($mainline) # original interface
} }
# Convert raw command line args into positional and named args for MAIN # Convert raw command line args into positional and named args for MAIN
sub default-args-to-capture($, @args is copy --> Capture:D) { sub default-args-to-capture($, @args is copy --> Capture:D) {
my $no-named-after = nqp::isfalse(%sub-main-opts<named-anywhere>); my $no-named-after = nqp::isfalse(%sub-main-opts<named-anywhere>);
my $bundling = nqp::istrue(%sub-main-opts<bundling>);
my $positional := nqp::create(IterationBuffer); my $positional := nqp::create(IterationBuffer);
my %named; my %named;
sub thevalue(\a) { sub thevalue(\a) {
((my \type := ::(a)) andthen Metamodel::EnumHOW.ACCEPTS(type.HOW)) ((my \type := ::(a)) andthen Metamodel::EnumHOW.ACCEPTS(type.HOW))
?? type ?? type
!! val(a) !! val(a)
} }
skipping to change at line 75 skipping to change at line 76
last; last;
} }
# no longer accepting nameds # no longer accepting nameds
elsif $no-named-after && nqp::isgt_i(nqp::elems($positional),0) { elsif $no-named-after && nqp::isgt_i(nqp::elems($positional),0) {
nqp::push($positional, thevalue($passed-value)); nqp::push($positional, thevalue($passed-value));
} }
# named # named
elsif $passed-value elsif $passed-value
~~ /^ [ '--' | '-' | ':' ] ('/'?) (<-[0..9\.]> .*) $/ { # 'hlfix ~~ /^ ( '--' | '-' | ':' ) ('/'?) (<-[0..9\.]> .*) $/ { # 'hlfix
my str $arg = $1.Str; my str $arg = $2.Str;
my $split := nqp::split("=",$arg); my $split := nqp::split("=",$arg);
# explicit value # explicit value
if nqp::isgt_i(nqp::elems($split),1) { if nqp::isgt_i(nqp::elems($split),1) {
my str $name = nqp::shift($split); my str $name = nqp::shift($split);
%named.push: $name => $0.chars die "Can't combine bundling with explicit arguments" if $bun
dling && nqp::iseq_s($0.Str, '-') && $name.chars > 1;
%named.push: $name => $1.chars
?? thevalue(nqp::join("=",$split)) but False ?? thevalue(nqp::join("=",$split)) but False
!! thevalue(nqp::join("=",$split)); !! thevalue(nqp::join("=",$split));
} }
# implicit value # implicit value
else { else {
%named.push: $arg => !($0.chars); if $bundling && nqp::iseq_s($0.Str, '-') {
die "Can't combine bundling with explicit negation" if $
1.chars && $arg.chars > 1;
my @chars = nqp::split('',$arg);
for @chars -> $char {
%named.push: $char => !($1.chars);
}
}
else {
%named.push: $arg => !($1.chars);
}
} }
} }
# positional # positional
else { else {
nqp::push($positional, thevalue($passed-value)); nqp::push($positional, thevalue($passed-value));
} }
} }
Capture.new( list => $positional.List, hash => %named ) Capture.new( list => $positional.List, hash => %named )
} }
skipping to change at line 280 skipping to change at line 291
return False if $signature.params.first: *.capture; return False if $signature.params.first: *.capture;
my @named-params = $signature.params.grep: *.named; my @named-params = $signature.params.grep: *.named;
return False if @named-params.first: *.slurpy; return False if @named-params.first: *.slurpy;
my %accepts-argument is Set = @named-params.map( *.named_names.Slip ); my %accepts-argument is Set = @named-params.map( *.named_names.Slip );
return True unless %accepts-argument{$_} for %named-arguments.keys; return True unless %accepts-argument{$_} for %named-arguments.keys;
False False
} }
sub find-candidates($capture) { sub find-candidates($capture) {
&main &main.^name eq 'Sub'
# Get a list of candidates that match according to the dispatcher ?? &main
.cando($capture) # Get a list of candidates that match according to the dispatcher
# Sort out all that would fail due to binding .cando($capture)
.grep: { !has-unexpected-named-arguments(.signature, $capture.hash) } # Sort out all that would fail due to binding
.grep({
!has-unexpected-named-arguments(.signature, $capture.hash)
})
!! die "MAIN must be a 'sub' to allow it to be called as a CLI handler
"
} }
# turn scalar values of nameds into 1 element arrays, return new capture # turn scalar values of nameds into 1 element arrays, return new capture
sub scalars-into-arrays($capture) { sub scalars-into-arrays($capture) {
my %hash = $capture.hash.map: { my %hash = $capture.hash.map: {
nqp::istype(.value,Positional) ?? $_ !! Pair.new(.key,[.value]) nqp::istype(.value,Positional) ?? $_ !! Pair.new(.key,[.value])
} }
Capture.new( :list($capture.list), :%hash) Capture.new( :list($capture.list), :%hash)
} }
 End of changes. 5 change blocks. 
9 lines changed or deleted 27 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)