Commit 3b6cc477 authored by Daniel Dehennin's avatar Daniel Dehennin

Imported Upstream version 2015.07.2

parent 700335ba
......@@ -213,7 +213,8 @@ MAIN: {
"(You can get a MoarVM built automatically with --gen-moar.)";
}
sorry(@errors) if @errors;
$config{'make'} = $^O eq 'MSWin32' ? 'nmake' : 'make';
$config{'make'} = `$moar_path --libpath="src/vm/moar/stage0" "src/vm/moar/stage0/nqp.moarvm" -e "print(nqp::backendconfig()<make>)"`
|| 'make';
$config{moar} = $moar_path;
fill_template_file(
'tools/build/Makefile-Moar.in',
......
......@@ -801,6 +801,8 @@ examples/rubyish/t/template.t
gen/jvm/.gitignore
gen/moar/.gitignore
gen/parrot/.gitignore
ports/macports/Portfile
ports/macports/README
src/HLL/Actions.nqp
src/HLL/CommandLine.nqp
src/HLL/Compiler.nqp
......@@ -992,6 +994,19 @@ src/vm/jvm/runtime/org/perl6/nqp/sixmodel/reprs/Lexotic.java
src/vm/jvm/runtime/org/perl6/nqp/sixmodel/reprs/LexoticInstance.java
src/vm/jvm/runtime/org/perl6/nqp/sixmodel/reprs/MultiCache.java
src/vm/jvm/runtime/org/perl6/nqp/sixmodel/reprs/MultiCacheInstance.java
src/vm/jvm/runtime/org/perl6/nqp/sixmodel/reprs/MultiDimArray.java
src/vm/jvm/runtime/org/perl6/nqp/sixmodel/reprs/MultiDimArrayInstance.java
src/vm/jvm/runtime/org/perl6/nqp/sixmodel/reprs/MultiDimArrayInstanceBase.java
src/vm/jvm/runtime/org/perl6/nqp/sixmodel/reprs/MultiDimArrayInstance_i.java
src/vm/jvm/runtime/org/perl6/nqp/sixmodel/reprs/MultiDimArrayInstance_i16.java
src/vm/jvm/runtime/org/perl6/nqp/sixmodel/reprs/MultiDimArrayInstance_i32.java
src/vm/jvm/runtime/org/perl6/nqp/sixmodel/reprs/MultiDimArrayInstance_i8.java
src/vm/jvm/runtime/org/perl6/nqp/sixmodel/reprs/MultiDimArrayInstance_n.java
src/vm/jvm/runtime/org/perl6/nqp/sixmodel/reprs/MultiDimArrayInstance_s.java
src/vm/jvm/runtime/org/perl6/nqp/sixmodel/reprs/MultiDimArrayInstance_u16.java
src/vm/jvm/runtime/org/perl6/nqp/sixmodel/reprs/MultiDimArrayInstance_u32.java
src/vm/jvm/runtime/org/perl6/nqp/sixmodel/reprs/MultiDimArrayInstance_u8.java
src/vm/jvm/runtime/org/perl6/nqp/sixmodel/reprs/MultiDimArrayREPRData.java
src/vm/jvm/runtime/org/perl6/nqp/sixmodel/reprs/NFA.java
src/vm/jvm/runtime/org/perl6/nqp/sixmodel/reprs/NFAInstance.java
src/vm/jvm/runtime/org/perl6/nqp/sixmodel/reprs/NFAStateInfo.java
......@@ -1028,6 +1043,7 @@ src/vm/jvm/runtime/org/perl6/nqp/sixmodel/reprs/SemaphoreInstance.java
src/vm/jvm/runtime/org/perl6/nqp/sixmodel/reprs/Uninstantiable.java
src/vm/jvm/runtime/org/perl6/nqp/sixmodel/reprs/VMArray.java
src/vm/jvm/runtime/org/perl6/nqp/sixmodel/reprs/VMArrayInstance.java
src/vm/jvm/runtime/org/perl6/nqp/sixmodel/reprs/VMArrayInstanceBase.java
src/vm/jvm/runtime/org/perl6/nqp/sixmodel/reprs/VMArrayInstance_i.java
src/vm/jvm/runtime/org/perl6/nqp/sixmodel/reprs/VMArrayInstance_i16.java
src/vm/jvm/runtime/org/perl6/nqp/sixmodel/reprs/VMArrayInstance_i32.java
......@@ -1168,7 +1184,9 @@ t/hll/04-import.t
t/hll/05-commandline.t
t/hll/06-sprintf.t
t/jvm/01-continuations.t
t/jvm/02-multidim.t
t/moar/01-continuations.t
t/moar/02-multidim.t
t/nativecall/01-basic.t
t/nqp/01-literals.t
t/nqp/02-if.t
......
......@@ -87,6 +87,9 @@ A hash that may have the following keys:
each element. Again, this is just about layout and lookup, not about type
checking.
* dimensions - the number of dimensions an array of this type supports. A
given REPR may be restricted to only support a single dimensions.
## hash
A hash that may have the following keys:
......
......@@ -14,23 +14,6 @@ must be tagged for release immediately prior to the Rakudo release.
=item 1.
I<Note: This step has changed starting in 2012.07.>
Check to see if F<tools/build/PARROT_REVISION> needs to be
bumped to a later Parrot release. If PARROT_REVISION already
contains a Parrot release tag (e.g., C<RELEASE_3_9_0>) then
it does not need to be changed. If PARROT_REVISION refers to
an interim commit, as in C<RELEASE_4_6_0-27-gda9adfa>, then
update PARROT_REVISION to contain the tag corresponding to
Parrot's monthly release.
To see a list of Parrot release tags, use C<git tag> on an
up-to-date Parrot repository.
Once F<tools/build/PARROT_REVISION> has been set to a Parrot
release, it must not be changed (except to another Parrot
release) until after the Rakudo release.
MoarVM tries to have a synchronised release schedule with NQP
and rakudo, so there's most probably a release tag for MoarVM
that you can bump F<tools/build/MOAR_REVISION> to. Release tags
......@@ -89,13 +72,13 @@ release guide for links on how to create GPG keys, should it be necessary.
Sign the tarball:
$ gpg --sign nqp-YYY.MM.tar.gz
$ gpg -b --armor nqp-YYY.MM.tar.gz
=item 8
Upload the release tarball and signature to L<http://rakudo.org/downloads/rakudo>:
$ scp nqp-2013.12.tar.gz nqp-2013.12.tar.gz.gpg \
$ scp nqp-2013.12.tar.gz nqp-2013.12.tar.gz.asc \
rakudo@rakudo.org:public_html/downloads/nqp/
If you do not have permissions for that, ask one of (pmichaud, jnthn, FROGGS,
......
# $Id$
PortSystem 1.0
name nqp
version 2015.05
categories lang devel
platforms darwin
license Artistic-2
maintainers coleda.com:will
description A lightweight Perl-6 like language for virtual machines.
long_description Unlike a full-fledged implementation of Perl 6, NQP \
strives to have as small a runtime footprint as it can, \
while still providing a Perl 6 object model and regular \
expression engine for the virtual machine.
homepage https://github.com/perl6/nqp
master_sites http://rakudo.org/downloads/nqp/
# To find the correct checksums for the given release, use:
# openssl dgst -rmd160 <file>
# openssl dgst -sha256 <file>
checksums rmd160 8fc571c56d222b0d57984199643918e54af259c2 \
sha256 790bfc3fa1af7f88f039d170875d69e6e17a9b03cd2119887e5df20834374316
# FIXME: may need ExtUtil::Command if by chance our default perl5 binary
# does not match what Apple ships.
depends_build port:perl5
# Unsupported by configure.pl.
configure.universal_args-delete --disable-dependency-tracking
universal_variant yes
subport nqp {
depends_lib port:MoarVM
depends_build port:MoarVM
depends_run port:MoarVM
configure.cmd ${prefix}/bin/perl Configure.pl --backends=moar --with-moar=${prefix}/bin/moar
}
subport nqp-jvm {
distfiles nqp-${version}.tar.gz
configure.cmd ${prefix}/bin/perl Configure.pl --backends=jvm
}
When updating the Portfile to reflect the new release:
First, update the portfile
1) update the version
2) remove the revision, if any is currently specified.
3) Recalculate the checksums (commands given in the file for this.) Keep the trailing \ on the first line.
Then, test out the portfile locally.
4) Setup a local portfile directory. Edit /opt/local/etc/macports/sources.conf, adding a reference to a local directory, like: file:///Users/bob/sandbox/macports/
5) In that folder, create a subdir lang/nqp
6) copy the updated Portfile to that folder.
7) Reindex to pick up the new portfile: `portindex`
8) From the top level of that folder, verify that we still build with our declared dependencies with, e.g. `port -t build nqp@2015.04`
9) Install the port, e.g. `sudo port install nqp@2015.04`
Finally, open a ticket to update the portfile
10) Create a unified diff from
https://trac.macports.org/browser/trunk/dports/lang/nqp/Portfile?format=txt
to our most recent copy.
11) create an "update" ticket in http://trac.macports.org/ - you'll need a trac account to open the ticket. Be sure to attach the diff, and list "nqp" as the port. Additionally, set keywords to "haspatch", and if you're listed as a maintainer, "maintainer"
12) git push the updated Portfile
13) hang out in #macports on freenode and mention the ticket.
......@@ -341,11 +341,15 @@ class HLL::Compiler does HLL::Backend::Default {
if $filename eq '-' {
$in-handle := nqp::getstdin();
}
elsif nqp::stat($filename, nqp::const::STAT_ISDIR) {
nqp::sayfh(nqp::getstderr(), "Can not run directory $filename.");
$err := 1;
}
else {
$in-handle := nqp::open($filename, 'r');
}
CATCH {
nqp::say("Could not open $filename. $_");
nqp::sayfh(nqp::getstderr(), "Could not open $filename. $_");
$err := 1;
}
}
......@@ -355,10 +359,11 @@ class HLL::Compiler does HLL::Backend::Default {
nqp::push(@codes, nqp::readallfh($in-handle));
nqp::closefh($in-handle);
CATCH {
$err := "Error while reading from file: $_";
nqp::sayfh(nqp::getstderr(), "Error while reading from file: $_");
$err := 1;
}
}
nqp::die($err) if $err;
nqp::exit(1) if $err;
}
my $code := join('', @codes);
my $?FILES := join(' ', @files);
......
......@@ -454,8 +454,8 @@ An operator precedence parser.
while @prefixish && @postfixish {
my %preO := @prefixish[0]<OPER><O>;
my %postO := @postfixish[nqp::elems(@postfixish)-1]<OPER><O>;
my $preprec := nqp::ifnull(nqp::atkey(%preO, 'prec'), '');
my $postprec := nqp::ifnull(nqp::atkey(%postO, 'prec'), '');
my $preprec := nqp::ifnull(nqp::atkey(%preO, 'sub'), nqp::ifnull(nqp::atkey(%preO, 'prec'), ''));
my $postprec := nqp::ifnull(nqp::atkey(%postO, 'sub'), nqp::ifnull(nqp::atkey(%postO, 'prec'), ''));
if $postprec gt $preprec ||
$postprec eq $preprec && %postO<uassoc> eq 'right'
......@@ -504,15 +504,15 @@ An operator precedence parser.
$inprec := ~%inO<prec>;
$infixcur.panic('Missing infixish operator precedence')
unless $inprec;
if $inprec lt $preclim {
if $inprec le $preclim {
$term_done := 1;
last;
}
%inO<prec> := nqp::ifnull(nqp::atkey(%inO, 'sub'), nqp::atkey(%inO, 'prec'));
while @opstack {
$opprec := ~@opstack[+@opstack-1]<OPER><O><prec>;
my %opO := @opstack[+@opstack-1]<OPER><O>;
$opprec := nqp::ifnull(nqp::atkey(%opO, 'sub'), nqp::atkey(%opO, 'prec'));
last unless $opprec gt $inprec;
self.EXPR_reduce(@termstack, @opstack);
}
......
......@@ -93,7 +93,7 @@ grammar NQP::Grammar is HLL::Grammar {
[ 'cut' »
<.panic: 'Obsolete pod format, please use =begin/=end instead'> ]?
| \n ]>
|
| {}
[ \s || <.panic: 'Illegal pod directive'> ]
\N*
]
......
......@@ -247,11 +247,27 @@ role NQPCursorRole is export {
method !cursor_push_cstack($capture) {
if !nqp::defined($!cstack) { $!cstack := [$capture] }
elsif nqp::elems($!cstack) == 0 {
nqp::push($!cstack, $capture);
}
elsif !nqp::isnull($capture) {
my $name := nqp::getattr($capture, $?CLASS, '$!name');
if !nqp::isnull($name) && nqp::defined($name) {
nqp::push($!cstack, $capture);
}
else { # is top capture anonymous enough to be reused?
my $top := nqp::atpos($!cstack,-1);
my $topname := nqp::getattr($top, $?CLASS, '$!name');
if !nqp::isnull($topname) && nqp::defined($topname) {
nqp::push($!cstack, $capture);
}
else {
# $top anon capture just used for pos advancement, so update it in place.
# We replace the whole capture because jvm can't seem to copy only the pos,
# and because the chances are that both captures are in the nursury anyway.
nqp::bindpos($!cstack,-1,$capture);
}
}
}
$!cstack;
}
......@@ -714,10 +730,7 @@ role NQPCursorRole is export {
}
method FAILGOAL($goal, $dba?) {
unless $dba {
$dba := nqp::getcodename(nqp::callercode());
}
nqp::die("Unable to parse expression in $dba; couldn't find final $goal");
self."!cursor_start_cur"()
}
}
......
......@@ -160,6 +160,21 @@ class QRegex::NFA {
dentout($to);
}
method altseq($node, $from, $to) {
if +@($node) {
my $indent := dentin();
my int $st := self.regex_nfa($node[0], $from, $to);
$to := $st if $to < 0 && $st > 0;
$st := self.addedge($from, $to, $EDGE_EPSILON, 0);
$to := $st if $to < 0 && $st > 0;
note("$indent ...altseq returns $to") if $nfadeb;
dentout($to);
}
else {
self.fate($node, $from, $to);
}
}
method anchor($node, $from, $to) {
self.addedge($from, $to, $EDGE_EPSILON, 0);
}
......
......@@ -89,8 +89,8 @@ class QRegex::P6Regex::Actions is HLL::Actions {
}
if $<separator> {
if $qast.rxtype ne 'quant' && $qast.rxtype ne 'dynquant' {
$/.CURSOR.panic("'" ~ $<separator>[0]<septype> ~
"' many only be used immediately following a quantifier")
$/.CURSOR.panic("'" ~ $<separator><septype> ~
"' may only be used immediately following a quantifier")
}
$qast.push($<separator>.ast);
if $<separator><septype> eq '%%' {
......@@ -298,7 +298,7 @@ class QRegex::P6Regex::Actions is HLL::Actions {
my $name := $<pos> ?? +$<pos> !! ~$<name>;
if $<quantified_atom> {
$qast := $<quantified_atom>[0].ast;
if $qast.rxtype eq 'quant' && $qast[0].rxtype eq 'subrule' {
if ($qast.rxtype eq 'quant' || $qast.rxtype eq 'dynquant') && $qast[0].rxtype eq 'subrule' {
self.subrule_alias($qast[0], $name);
}
elsif $qast.rxtype eq 'subrule' {
......@@ -831,7 +831,7 @@ class QRegex::P6Regex::Actions is HLL::Actions {
sub capnames($ast, int $count) {
my %capnames;
my $rxtype := $ast.rxtype;
if $rxtype eq 'concat' || $rxtype eq 'goal' {
if $rxtype eq 'concat' || $rxtype eq 'goal' || $rxtype eq 'conjseq' {
for $ast.list {
my %x := capnames($_, $count);
for %x { %capnames{$_.key} := +%capnames{$_.key} + $_.value; }
......@@ -867,14 +867,15 @@ class QRegex::P6Regex::Actions is HLL::Actions {
for %x { %capnames{$_.key} := +%capnames{$_.key} + %x{$_.key} }
$count := %x{''};
}
elsif $rxtype eq 'quant' {
elsif $rxtype eq 'quant' || $rxtype eq 'dynquant' {
my $ilist := ($ast.subtype eq 'item');
my %astcap := capnames($ast[0], $count);
for %astcap { %capnames{$_.key} := $ilist ?? $_.value !! 2 }
$count := %astcap{''};
if $ast[1] {
my $sep_ast := $ast[$rxtype eq 'quant' ?? 1 !! 2];
if $sep_ast {
# handle any separator quantification
my %astcap := capnames($ast[1], $count);
my %astcap := capnames($sep_ast, $count);
for %astcap { %capnames{$_.key} := $ilist ?? $_.value !! 2 }
$count := %astcap{''};
}
......
......@@ -201,7 +201,7 @@ grammar QRegex::P6Regex::Grammar is HLL::Grammar {
|| <sigmaybe>?
[
| <!rxstopper> <quantifier>
| <?[:]> <backmod> <!alpha>
| <?[:]> <backmod> <!alnum>
]
[ <!{$*VARDEF}> <.SIGOK> <sigfinal=.sigmaybe> ]?
[ <.ws> <separator> ]?
......@@ -221,11 +221,8 @@ grammar QRegex::P6Regex::Grammar is HLL::Grammar {
# :dba('regex atom')
[
| \w
[
| \w+! <?before \w>
| <?before ' ' \w> <!{ %*RX<s> }> <.worry("Space is not signficant here; please use quotes or :s (:sigspace) modifier (or, to suppress this warning, omit the space, or otherwise change the spacing)")>
]?
<.SIGOK>
[ <?before ' ' \w> <!{ %*RX<s> || $*HAS_GOAL }> <.worry("Space is not significant here; please use quotes or :s (:sigspace) modifier (or, to suppress this warning, omit the space, or otherwise change the spacing)")> ]?
<.SIGOK>
| <metachar>
]
}
......@@ -301,6 +298,7 @@ grammar QRegex::P6Regex::Grammar is HLL::Grammar {
## we cheat here, really should be regex_infix:sym<~>
token metachar:sym<~> {
:my $*HAS_GOAL := 1;
<sym>
<.ws> <GOAL=.quantified_atom>
<.ws> <EXPR=.quantified_atom>
......@@ -468,5 +466,9 @@ grammar QRegex::P6Regex::Grammar is HLL::Grammar {
token mod_ident:sym<ratchet> { $<sym>=[r] 'atchet'? » }
token mod_ident:sym<sigspace> { $<sym>=[s] 'igspace'? » }
token mod_ident:sym<dba> { <sym> » }
token mod_ident:sym<oops> { {} (\D+) { $/.CURSOR.panic('Unrecognized regex modifier :' ~ $/[0].Str) } }
token mod_ident:sym<oops> { {} (\w+) { self.throw_unrecognized_regex_modifier($/[0].Str) } }
method throw_unrecognized_regex_modifier($mod) {
self.panic('Unrecognized regex modifier :' ~ $mod);
}
}
......@@ -1980,6 +1980,16 @@ my %const_map := nqp::hash(
'STAT_PLATFORM_BLOCKSIZE', -6,
'STAT_PLATFORM_BLOCKS', -7,
'PIPE_INHERIT_IN', 1,
'PIPE_IGNORE_IN', 2,
'PIPE_CAPTURE_IN', 4,
'PIPE_INHERIT_OUT', 8,
'PIPE_IGNORE_OUT', 16,
'PIPE_CAPTURE_OUT', 32,
'PIPE_INHERIT_ERR', 64,
'PIPE_IGNORE_ERR', 128,
'PIPE_CAPTURE_ERR', 256,
'TYPE_CHECK_CACHE_DEFINITIVE', 0,
'TYPE_CHECK_CACHE_THEN_METHOD', 1,
'TYPE_CHECK_NEEDS_ACCEPTS', 2,
......@@ -2055,17 +2065,9 @@ QAST::OperationsJAST.map_classlib_core_op('link', $TYPE_OPS, 'link', [$RT_STR, $
QAST::OperationsJAST.map_classlib_core_op('gethostname', $TYPE_OPS, 'gethostname', [], $RT_STR);
# Two variants of shell until we deprecate shell1
QAST::OperationsJAST.map_classlib_core_op('shell1', $TYPE_OPS, 'shell1', [$RT_STR], $RT_INT, :tc);
QAST::OperationsJAST.map_classlib_core_op('shell3', $TYPE_OPS, 'shell3', [$RT_STR, $RT_STR, $RT_OBJ], $RT_INT, :tc);
QAST::OperationsJAST.add_core_op('shell', -> $qastcomp, $op {
my @operands := $op.list;
$qastcomp.as_jast(+@operands == 1
?? QAST::Op.new( :op('shell1'), |@operands )
!! QAST::Op.new( :op('shell3'), |@operands ));
});
QAST::OperationsJAST.map_classlib_core_op('spawn', $TYPE_OPS, 'spawn', [$RT_OBJ, $RT_STR, $RT_OBJ], $RT_INT, :tc);
QAST::OperationsJAST.map_classlib_core_op('openpipe', $TYPE_OPS, 'openpipe', [$RT_STR, $RT_STR, $RT_OBJ, $RT_STR], $RT_OBJ, :tc);
QAST::OperationsJAST.map_classlib_core_op('shell', $TYPE_OPS, 'shell', [$RT_STR, $RT_STR, $RT_OBJ, $RT_OBJ, $RT_OBJ, $RT_OBJ, $RT_INT], $RT_INT, :tc);
QAST::OperationsJAST.map_classlib_core_op('spawn', $TYPE_OPS, 'spawn', [$RT_OBJ, $RT_STR, $RT_OBJ, $RT_OBJ, $RT_OBJ, $RT_OBJ, $RT_INT], $RT_INT, :tc);
QAST::OperationsJAST.map_classlib_core_op('syncpipe', $TYPE_OPS, 'syncpipe', [], $RT_OBJ, :tc);
QAST::OperationsJAST.map_classlib_core_op('symlink', $TYPE_OPS, 'symlink', [$RT_STR, $RT_STR], $RT_INT, :tc);
......@@ -2351,6 +2353,18 @@ QAST::OperationsJAST.map_classlib_core_op('atpos_s', $TYPE_OPS, 'atpos_s', [$RT_
QAST::OperationsJAST.map_classlib_core_op('atposref_i', $TYPE_OPS, 'atposref_i', [$RT_OBJ, $RT_INT], $RT_OBJ, :tc);
QAST::OperationsJAST.map_classlib_core_op('atposref_n', $TYPE_OPS, 'atposref_n', [$RT_OBJ, $RT_INT], $RT_OBJ, :tc);
QAST::OperationsJAST.map_classlib_core_op('atposref_s', $TYPE_OPS, 'atposref_s', [$RT_OBJ, $RT_INT], $RT_OBJ, :tc);
QAST::OperationsJAST.map_classlib_core_op('atpos2d', $TYPE_OPS, 'atpos2d_o', [$RT_OBJ, $RT_INT, $RT_INT], $RT_OBJ, :tc);
QAST::OperationsJAST.map_classlib_core_op('atpos2d_i', $TYPE_OPS, 'atpos2d_i', [$RT_OBJ, $RT_INT, $RT_INT], $RT_INT, :tc);
QAST::OperationsJAST.map_classlib_core_op('atpos2d_n', $TYPE_OPS, 'atpos2d_n', [$RT_OBJ, $RT_INT, $RT_INT], $RT_NUM, :tc);
QAST::OperationsJAST.map_classlib_core_op('atpos2d_s', $TYPE_OPS, 'atpos2d_s', [$RT_OBJ, $RT_INT, $RT_INT], $RT_STR, :tc);
QAST::OperationsJAST.map_classlib_core_op('atpos3d', $TYPE_OPS, 'atpos3d_o', [$RT_OBJ, $RT_INT, $RT_INT, $RT_INT], $RT_OBJ, :tc);
QAST::OperationsJAST.map_classlib_core_op('atpos3d_i', $TYPE_OPS, 'atpos3d_i', [$RT_OBJ, $RT_INT, $RT_INT, $RT_INT], $RT_INT, :tc);
QAST::OperationsJAST.map_classlib_core_op('atpos3d_n', $TYPE_OPS, 'atpos3d_n', [$RT_OBJ, $RT_INT, $RT_INT, $RT_INT], $RT_NUM, :tc);
QAST::OperationsJAST.map_classlib_core_op('atpos3d_s', $TYPE_OPS, 'atpos3d_s', [$RT_OBJ, $RT_INT, $RT_INT, $RT_INT], $RT_STR, :tc);
QAST::OperationsJAST.map_classlib_core_op('atposnd', $TYPE_OPS, 'atposnd_o', [$RT_OBJ, $RT_OBJ], $RT_OBJ, :tc);
QAST::OperationsJAST.map_classlib_core_op('atposnd_i', $TYPE_OPS, 'atposnd_i', [$RT_OBJ, $RT_OBJ], $RT_INT, :tc);
QAST::OperationsJAST.map_classlib_core_op('atposnd_n', $TYPE_OPS, 'atposnd_n', [$RT_OBJ, $RT_OBJ], $RT_NUM, :tc);
QAST::OperationsJAST.map_classlib_core_op('atposnd_s', $TYPE_OPS, 'atposnd_s', [$RT_OBJ, $RT_OBJ], $RT_STR, :tc);
QAST::OperationsJAST.map_classlib_core_op('atkey', $TYPE_OPS, 'atkey', [$RT_OBJ, $RT_STR], $RT_OBJ, :tc);
QAST::OperationsJAST.map_classlib_core_op('atkey_i', $TYPE_OPS, 'atkey_i', [$RT_OBJ, $RT_STR], $RT_INT, :tc);
QAST::OperationsJAST.map_classlib_core_op('atkey_n', $TYPE_OPS, 'atkey_n', [$RT_OBJ, $RT_STR], $RT_NUM, :tc);
......@@ -2359,6 +2373,18 @@ QAST::OperationsJAST.map_classlib_core_op('bindpos', $TYPE_OPS, 'bindpos', [$RT_
QAST::OperationsJAST.map_classlib_core_op('bindpos_i', $TYPE_OPS, 'bindpos_i', [$RT_OBJ, $RT_INT, $RT_INT], $RT_INT, :tc);
QAST::OperationsJAST.map_classlib_core_op('bindpos_n', $TYPE_OPS, 'bindpos_n', [$RT_OBJ, $RT_INT, $RT_NUM], $RT_NUM, :tc);
QAST::OperationsJAST.map_classlib_core_op('bindpos_s', $TYPE_OPS, 'bindpos_s', [$RT_OBJ, $RT_INT, $RT_STR], $RT_STR, :tc);
QAST::OperationsJAST.map_classlib_core_op('bindpos2d', $TYPE_OPS, 'bindpos2d_o', [$RT_OBJ, $RT_INT, $RT_INT, $RT_OBJ], $RT_OBJ, :tc);
QAST::OperationsJAST.map_classlib_core_op('bindpos2d_i', $TYPE_OPS, 'bindpos2d_i', [$RT_OBJ, $RT_INT, $RT_INT, $RT_INT], $RT_INT, :tc);
QAST::OperationsJAST.map_classlib_core_op('bindpos2d_n', $TYPE_OPS, 'bindpos2d_n', [$RT_OBJ, $RT_INT, $RT_INT, $RT_NUM], $RT_NUM, :tc);
QAST::OperationsJAST.map_classlib_core_op('bindpos2d_s', $TYPE_OPS, 'bindpos2d_s', [$RT_OBJ, $RT_INT, $RT_INT, $RT_STR], $RT_STR, :tc);
QAST::OperationsJAST.map_classlib_core_op('bindpos3d', $TYPE_OPS, 'bindpos3d_o', [$RT_OBJ, $RT_INT, $RT_INT, $RT_INT, $RT_OBJ], $RT_OBJ, :tc);
QAST::OperationsJAST.map_classlib_core_op('bindpos3d_i', $TYPE_OPS, 'bindpos3d_i', [$RT_OBJ, $RT_INT, $RT_INT, $RT_INT, $RT_INT], $RT_INT, :tc);
QAST::OperationsJAST.map_classlib_core_op('bindpos3d_n', $TYPE_OPS, 'bindpos3d_n', [$RT_OBJ, $RT_INT, $RT_INT, $RT_INT, $RT_NUM], $RT_NUM, :tc);
QAST::OperationsJAST.map_classlib_core_op('bindpos3d_s', $TYPE_OPS, 'bindpos3d_s', [$RT_OBJ, $RT_INT, $RT_INT, $RT_INT, $RT_STR], $RT_STR, :tc);
QAST::OperationsJAST.map_classlib_core_op('bindposnd', $TYPE_OPS, 'bindposnd_o', [$RT_OBJ, $RT_OBJ, $RT_OBJ], $RT_OBJ, :tc);
QAST::OperationsJAST.map_classlib_core_op('bindposnd_i', $TYPE_OPS, 'bindposnd_i', [$RT_OBJ, $RT_OBJ, $RT_INT], $RT_INT, :tc);
QAST::OperationsJAST.map_classlib_core_op('bindposnd_n', $TYPE_OPS, 'bindposnd_n', [$RT_OBJ, $RT_OBJ, $RT_NUM], $RT_NUM, :tc);
QAST::OperationsJAST.map_classlib_core_op('bindposnd_s', $TYPE_OPS, 'bindposnd_s', [$RT_OBJ, $RT_OBJ, $RT_STR], $RT_STR, :tc);
QAST::OperationsJAST.map_classlib_core_op('bindkey', $TYPE_OPS, 'bindkey', [$RT_OBJ, $RT_STR, $RT_OBJ], $RT_OBJ, :tc);
QAST::OperationsJAST.map_classlib_core_op('bindkey_i', $TYPE_OPS, 'bindkey_i', [$RT_OBJ, $RT_STR, $RT_INT], $RT_INT, :tc);
QAST::OperationsJAST.map_classlib_core_op('bindkey_n', $TYPE_OPS, 'bindkey_n', [$RT_OBJ, $RT_STR, $RT_NUM], $RT_NUM, :tc);
......@@ -2368,6 +2394,9 @@ QAST::OperationsJAST.map_classlib_core_op('existskey', $TYPE_OPS, 'existskey', [
QAST::OperationsJAST.map_classlib_core_op('deletekey', $TYPE_OPS, 'deletekey', [$RT_OBJ, $RT_STR], $RT_OBJ, :tc);
QAST::OperationsJAST.map_classlib_core_op('elems', $TYPE_OPS, 'elems', [$RT_OBJ], $RT_INT, :tc);
QAST::OperationsJAST.map_classlib_core_op('setelems', $TYPE_OPS, 'setelems', [$RT_OBJ, $RT_INT], $RT_OBJ, :tc);
QAST::OperationsJAST.map_classlib_core_op('dimensions', $TYPE_OPS, 'dimensions', [$RT_OBJ], $RT_OBJ, :tc);
QAST::OperationsJAST.map_classlib_core_op('setdimensions', $TYPE_OPS, 'setdimensions', [$RT_OBJ, $RT_OBJ], $RT_OBJ, :tc);
QAST::OperationsJAST.map_classlib_core_op('numdimensions', $TYPE_OPS, 'numdimensions', [$RT_OBJ], $RT_INT, :tc);
QAST::OperationsJAST.map_classlib_core_op('push', $TYPE_OPS, 'push', [$RT_OBJ, $RT_OBJ], $RT_OBJ, :tc);
QAST::OperationsJAST.map_classlib_core_op('push_i', $TYPE_OPS, 'push_i', [$RT_OBJ, $RT_INT], $RT_INT, :tc);
QAST::OperationsJAST.map_classlib_core_op('push_n', $TYPE_OPS, 'push_n', [$RT_OBJ, $RT_NUM], $RT_NUM, :tc);
......
package org.perl6.nqp.io;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
......@@ -9,34 +8,70 @@ import java.nio.channels.ByteChannel;
import java.nio.channels.Channels;
import java.nio.channels.ReadableByteChannel;
import java.nio.channels.WritableByteChannel;
import java.nio.charset.Charset;
import java.util.Map;
import org.perl6.nqp.runtime.ExceptionHandling;
import org.perl6.nqp.runtime.ThreadContext;
public class ProcessChannel implements ByteChannel {
protected WritableByteChannel stdin;
protected ReadableByteChannel stdout;
protected Process process;
public ProcessChannel(Process process, OutputStream stdin, InputStream stdout) {
this.stdin = Channels.newChannel(stdin);
this.stdout = Channels.newChannel(stdout);
public class ProcessChannel implements ByteChannel, java.lang.Runnable {
public WritableByteChannel out;
public OutputStream out_stream;
public ReadableByteChannel in;
public Process process;
public void run() {
try {
ByteBuffer bb = ByteBuffer.allocate(32768);
int read = 1;
while (read > 0) {
read = in.read(bb);
if (read > 0) {
out_stream.write(bb.array(), 0, read);
}
}
} catch (Exception e) {
throw new RuntimeException("Broken pipe", e);
} finally {
try {
out.close();
} catch (Exception e) {
}
try {
in.close();
} catch (Exception e) {
}
}
}
public ProcessChannel(Process process, OutputStream out, ReadableByteChannel in) {
this.out = Channels.newChannel(out);
this.out_stream = out;
this.in = in;
this.process = process;
}
public ProcessChannel(Process process, OutputStream out) {
this.out = Channels.newChannel(out);
this.process = process;
}
public ProcessChannel(Process process, InputStream in) {
this.in = Channels.newChannel(in);
this.process = process;
}
public int read(ByteBuffer dst) throws IOException {
return stdout.read(dst);
return in.read(dst);
}
public boolean isOpen() {
return stdin.isOpen();
return in.isOpen();
}
public void close() throws IOException {
stdin.close();
stdout.close();
if (in instanceof ReadableByteChannel)
in.close();
if (out instanceof WritableByteChannel)
out.close();
}
public int exitValue() throws InterruptedException {
......@@ -44,6 +79,6 @@ public class ProcessChannel implements ByteChannel {
}
public int write(ByteBuffer src) throws IOException {
return stdin.write(src);
return out.write(src);
}
}
package org.perl6.nqp.io;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.lang.ProcessBuilder.Redirect;
import java.nio.charset.Charset;
import java.util.Map;
import org.perl6.nqp.runtime.ExceptionHandling;
import org.perl6.nqp.runtime.ThreadContext;
public class ProcessHandle extends SyncHandle {
Process process;
public ProcessHandle(ThreadContext tc, String cmd, String dir, Map<String, String> env) {
ProcessBuilder pb;
String os = System.getProperty("os.name").toLowerCase();
if (os.indexOf("win") >= 0) {
pb = new ProcessBuilder("cmd", "/c", cmd.replace('/', '\\'));
} else {
pb = new ProcessBuilder("sh", "-c", cmd);
}
pb.directory(new File(dir));
pb.redirectError(Redirect.INHERIT);
// Clear the JVM inherited environment and use provided only
Map<String, String> pbEnv = pb.environment();
pbEnv.clear();
pbEnv.putAll(env);
try {
process = pb.start();
chan = new ProcessChannel(process, process.getOutputStream(), process.getInputStream());
setEncoding(tc, Charset.forName("UTF-8"));
} catch (IOException e) {
throw ExceptionHandling.dieInternal(tc, e);
}
public Process process;
public ProcessHandle(ThreadContext tc) {
setEncoding(tc, Charset.forName("UTF-8"));
}
public void bindChannel(ThreadContext tc, Process process, OutputStream out) {
this.process = process;
this.chan = new ProcessChannel(process, out);
setEncoding(tc, Charset.forName("UTF-8"));
}
public void bindChannel(ThreadContext tc, Process process, InputStream in) {
this.process = process;
this.chan = new ProcessChannel(process, in);
setEncoding(tc, Charset.forName("UTF-8"));
}
public void flush(ThreadContext tc) {
......
......@@ -17,7 +17,7 @@ import org.perl6.nqp.runtime.ThreadContext;
public abstract class SyncHandle implements IIOClosable, IIOEncodable,
IIOSyncReadable, IIOSyncWritable, IIOLineSeparable, IIOExitable {
protected ByteChannel chan;
public ByteChannel chan;
protected CharsetEncoder enc;
protected CharsetDecoder dec;
protected boolean eof = false;
......
......@@ -38,6 +38,7 @@ import org.perl6.nqp.sixmodel.reprs.ConcBlockingQueue;
import org.perl6.nqp.sixmodel.reprs.ConditionVariable;
import org.perl6.nqp.sixmodel.reprs.AsyncTask;
import org.perl6.nqp.sixmodel.reprs.NativeRef;
import org.perl6.nqp.sixmodel.reprs.MultiDimArray;
public class REPRRegistry {
private static HashMap<String, Integer> reprIdMap = new HashMap<String, Integer>();
......@@ -100,5 +101,6 @@ public class REPRRegistry {
addREPR("ConditionVariable", new ConditionVariable());
addREPR("AsyncTask", new AsyncTask());
addREPR("NativeRef", new NativeRef());
addREPR("MultiDimArray", new MultiDimArray());
}
}
......@@ -124,6 +124,24 @@ public abstract class SixModelObject implements Cloneable {
public void splice(ThreadContext tc, SixModelObject from, long offset, long count) {
throw ExceptionHandling.dieInternal(tc, this.st.REPR.name + " representation does not implement splice");
}
public SixModelObject at_pos_multidim_boxed(ThreadContext tc, long[] indices) {
throw ExceptionHandling.dieInternal(tc, this.st.REPR.name + " representation does not implement at_pos_boxed_multidim");
}
public void at_pos_multidim_native(ThreadContext tc, long[] indices) {
throw ExceptionHandling.dieInternal(tc, this.st.REPR.name + " representation does not implement at_pos_multidim_native");
}
public void bind_pos_multidim_boxed(ThreadContext tc, long[] indices, SixModelObject value) {
throw ExceptionHandling.dieInternal(tc, this.st.REPR.name + " representation does not implement bind_pos_boxed_multidim");
}
public void bind_pos_multidim_native(ThreadContext tc, long[] indices) {
throw ExceptionHandling.dieInternal(tc, this.st.REPR.name + " representation does not implement bind_pos_native_multidim");
}
public long[] dimensions(ThreadContext tc) {
throw ExceptionHandling.dieInternal(tc, this.st.REPR.name + " representation does not implement dimensions");
}
public void set_dimensions(ThreadContext tc, long[] dimensions) {
throw ExceptionHandling.dieInternal(tc, this.st.REPR.name + " representation does not implement set_dimensions");
}
/**
* Associative access functions.
......
package org.perl6.nqp.sixmodel.reprs;
import org.perl6.nqp.runtime.ExceptionHandling;
import org.perl6.nqp.runtime.ThreadContext;
import org.perl6.nqp.sixmodel.REPR;
import org.perl6.nqp.sixmodel.STable;
import org.perl6.nqp.sixmodel.SerializationReader;
import org.perl6.nqp.sixmodel.SerializationWriter;
import org.perl6.nqp.sixmodel.SixModelObject;
import org.perl6.nqp.sixmodel.StorageSpec;
import org.perl6.nqp.sixmodel.TypeObject;
public class MultiDimArray extends REPR {
public SixModelObject type_object_for(ThreadContext tc, SixModelObject HOW) {
STable st = new STable(this, HOW);
SixModelObject obj = new TypeObject();
obj.st = st;
st.WHAT = obj;
return st.WHAT;
}
public SixModelObject allocate(ThreadContext tc, STable st) {