Skip to content

Commit ad83558

Browse files
committed
Merge branch 'master' of github.com:perl6/nqp
2 parents 8742805 + a6b7c9c commit ad83558

File tree

15 files changed

+210
-108
lines changed

15 files changed

+210
-108
lines changed

Configure.pl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@
229229
print "got: $_";
230230
if (/(?:java|jdk) version "(\d+)(?:\.(\d+))?/) {
231231
$jvm_found = 1;
232-
if ($1 > 1 || $1 == 1 && $2 >= 7) {
232+
if ($1 > 1 || $1 == 1 && $2 >= 8) {
233233
$jvm_ok = 1;
234234
}
235235
$got = $_;
@@ -243,7 +243,7 @@
243243
}
244244
elsif (!$jvm_ok) {
245245
push @errors,
246-
"Need at least JVM 1.7 (got $got)";
246+
"Need at least JVM 1.8 (got $got)";
247247
}
248248
}
249249
sorry($options{'ignore-errors'}, @errors) if @errors;

src/QRegex/Cursor.nqp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,6 @@ role NQPMatchRole is export {
8888
method CURSOR() { self }
8989
method PRECURSOR() { self."!cursor_init"(nqp::getattr($!shared, ParseShared, '$!target'), :p($!from)) }
9090
method Str() { $!pos >= $!from ?? nqp::substr(nqp::getattr($!shared, ParseShared, '$!target'), $!from, nqp::sub_i(self.to, $!from)) !! '' }
91-
method Int() { my int $i := +self.Str(); $i } # XXX need a better way to do this
9291
method Num() { +self.Str() }
9392
method Bool() { $!pos >= $!from }
9493
method chars() { $!pos >= $!from ?? nqp::sub_i(self.to, $!from) !! 0 }
@@ -1292,6 +1291,12 @@ class NQPMatch is NQPCapture does NQPMatchRole {
12921291
&& nqp::istrue(nqp::getattr(self, $?CLASS, '$!match'));
12931292
}
12941293

1294+
method Int() {
1295+
# XXX need a better way to do this
1296+
my int $i := +self.Str();
1297+
$i;
1298+
}
1299+
12951300
method parse($target, :$rule = 'TOP', :$actions, *%options) {
12961301
my $braid := Braid.'!braid_init'(:grammar(self), :actions($actions), :package($*PACKAGE));
12971302
my $cur := self.'!cursor_init'($target, :braid($braid), |%options);

src/vm/js/Compiler.nqp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -486,12 +486,12 @@ class QAST::CompilerJS does DWIMYNameMangling does SerializeOnce {
486486
}
487487

488488
if ($pos_required) {
489-
@setup.push("if (arguments.length < {$pos_required+2}) nqp.tooFewPos(arguments.length, $pos_required);");
489+
@setup.unshift("if (arguments.length < {$pos_required+2}) nqp.tooFewPos(arguments.length, $pos_required);");
490490
}
491491

492492
if (!$pos_slurpy) {
493493
my $max := $pos_required + $pos_optional + 2;
494-
@setup.push("if (arguments.length > $max) nqp.tooManyPos(arguments.length, $max);");
494+
@setup.unshift("if (arguments.length > $max) nqp.tooManyPos(arguments.length, $max);");
495495
}
496496

497497
Chunk.new($T_NONVAL, nqp::join(',', @sig), @setup);

src/vm/js/Operations.nqp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1677,6 +1677,8 @@ class QAST::OperationsJS {
16771677

16781678
add_simple_op('normalizecodes', $T_OBJ, [$T_OBJ, $T_INT, $T_OBJ], :side_effects);
16791679

1680+
add_simple_op('codes', $T_INT, [$T_STR]);
1681+
16801682
add_simple_op('strfromcodes', $T_STR, [$T_OBJ]);
16811683
add_simple_op('strtocodes', $T_OBJ, [$T_STR, $T_INT, $T_OBJ], :side_effects);
16821684

src/vm/js/const_map.nqp

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,4 +76,40 @@ my %const_map := nqp::hash(
7676
'NORMALIZE_NFD', 2,
7777
'NORMALIZE_NFKC', 3,
7878
'NORMALIZE_NFKD', 4,
79+
80+
'SIG_HUP', 1,
81+
'SIG_INT', 2,
82+
'SIG_QUIT', 3,
83+
'SIG_ILL', 4,
84+
'SIG_TRAP', 5,
85+
'SIG_ABRT', 6,
86+
'SIG_EMT', 7,
87+
'SIG_FPE', 8,
88+
'SIG_KILL', 9,
89+
'SIG_BUS', 10,
90+
'SIG_SEGV', 11,
91+
'SIG_SYS', 12,
92+
'SIG_PIPE', 13,
93+
'SIG_ALRM', 14,
94+
'SIG_TERM', 15,
95+
'SIG_URG', 16,
96+
'SIG_STOP', 17,
97+
'SIG_TSTP', 18,
98+
'SIG_CONT', 19,
99+
'SIG_CHLD', 20,
100+
'SIG_TTIN', 21,
101+
'SIG_TTOU', 22,
102+
'SIG_IO', 23,
103+
'SIG_XCPU', 24,
104+
'SIG_XFSZ', 25,
105+
'SIG_VTALRM', 26,
106+
'SIG_PROF', 27,
107+
'SIG_WINCH', 28,
108+
'SIG_INFO', 29,
109+
'SIG_USR1', 30,
110+
'SIG_USR2', 31,
111+
'SIG_THR', 32,
112+
'SIG_STKFLT', 116,
113+
'SIG_PWR', 130,
114+
'SIG_BREAK', 221,
79115
);

src/vm/js/nqp-runtime/core.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1355,6 +1355,10 @@ op.strtocodes = function(str, form, codes) {
13551355
return codes;
13561356
};
13571357

1358+
op.codes = function(str) {
1359+
return str.normalize('NFC').length;
1360+
}
1361+
13581362
op.islist = function(list) {
13591363
return (list._STable && list._STable.REPR instanceof reprs.VMArray) ? 1 : 0;
13601364
};

src/vm/js/nqp-runtime/io.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,10 @@ op.lstat_time = function(file, code) {
147147
};
148148

149149
class IOHandle extends NQPObject {
150+
$$can(ctx, name) {
151+
return 0;
152+
}
153+
150154
$$toBool(ctx) {
151155
return 1;
152156
}
@@ -192,10 +196,6 @@ class FileHandle extends IOHandle {
192196
return 1;
193197
}
194198

195-
$$can(ctx, name) {
196-
return 0;
197-
}
198-
199199
$$filenofh() {
200200
return this.fd;
201201
}
@@ -390,7 +390,7 @@ op.getstderr = function() {
390390
};
391391

392392
class Stdout extends StdHandle {
393-
isttyfh() {
393+
$$isttyfh() {
394394
return (process.stdout.isTTY ? 1 : 0);
395395
}
396396

src/vm/js/nqp-runtime/runtime.js

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ exports.loaderCtx = null;
107107

108108
op.loadbytecode = function(ctx, file) {
109109
// HACK - temporary hack for rakudo-js
110-
if (file == '/share/nqp/lib/Perl6/BOOTSTRAP.js') {
110+
if (file == '/nqp/lib/Perl6/BOOTSTRAP.js') {
111111
file = 'Perl6::BOOTSTRAP';
112112
}
113113

@@ -492,43 +492,57 @@ exports.tooManyPos = function(got, expected) {
492492
exports.arg_i = function(ctx, contedArg) {
493493
if (contedArg instanceof NativeIntArg) {
494494
return contedArg.value;
495+
} else if (contedArg instanceof NativeNumArg) {
496+
throw new NQPException('Expected native int argument, but got num');
497+
} else if (contedArg instanceof NativeStrArg) {
498+
throw new NQPException('Expected native int argument, but got str');
495499
}
500+
496501
const arg = contedArg.$$decont(ctx);
497502
if (arg instanceof NQPInt) {
498503
return arg.value;
499504
} else if (arg.$$getInt) {
500505
return arg.$$getInt();
501506
} else {
502-
require('nqp-runtime').dumpObj(arg);
503-
throw new NQPException('expected int got something else');
507+
throw new NQPException('Expected native int argument, but got something else');
504508
}
505509
};
506510

507511
exports.arg_n = function(ctx, contedArg) {
508512
if (contedArg instanceof NativeNumArg) {
509513
return contedArg.value;
514+
} else if (contedArg instanceof NativeIntArg) {
515+
throw new NQPException('Expected native num argument, but got int');
516+
} else if (contedArg instanceof NativeStrArg) {
517+
throw new NQPException('Expected native num argument, but got str');
510518
}
519+
511520
const arg = contedArg.$$decont(ctx);
512521
if (typeof arg === 'number') {
513522
return arg;
514523
} else if (arg.$$getNum) {
515524
return arg.$$getNum();
516525
} else {
517-
throw new NQPException('expected num got something else');
526+
throw new NQPException('Expected native num argument, but got something else');
518527
}
519528
};
520529

521530
exports.arg_s = function(ctx, contedArg) {
522531
if (contedArg instanceof NativeStrArg) {
523532
return contedArg.value;
533+
} else if (contedArg instanceof NativeIntArg) {
534+
throw new NQPException('Expected native str argument, but got int');
535+
} else if (contedArg instanceof NativeNumArg) {
536+
throw new NQPException('Expected native str argument, but got num');
524537
}
538+
525539
const arg = contedArg.$$decont(ctx);
526540
if (typeof arg === 'string') {
527541
return arg;
528542
} else if (arg.$$getStr) {
529543
return arg.$$getStr();
530544
} else {
531-
throw new NQPException('expected string got something else');
545+
throw new NQPException('Expected native str argument, but got something else');
532546
}
533547
};
534548

src/vm/jvm/QAST/Compiler.nqp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2347,6 +2347,8 @@ QAST::OperationsJAST.map_classlib_core_op('strfromcodes', $TYPE_OPS, 'strfromcod
23472347
QAST::OperationsJAST.map_classlib_core_op('strtocodes', $TYPE_OPS, 'strtocodes', [$RT_STR, $RT_INT, $RT_OBJ], $RT_OBJ, :tc);
23482348
QAST::OperationsJAST.map_classlib_core_op('normalizecodes', $TYPE_OPS, 'normalizecodes', [$RT_OBJ, $RT_INT, $RT_OBJ], $RT_OBJ, :tc);
23492349

2350+
QAST::OperationsJAST.map_classlib_core_op('codes', $TYPE_OPS, 'codes', [$RT_STR], $RT_INT);
2351+
23502352
QAST::OperationsJAST.map_classlib_core_op('codepointfromname', $TYPE_OPS, 'codepointfromname', [$RT_STR], $RT_INT);
23512353
QAST::OperationsJAST.map_classlib_core_op('getstrfromname', $TYPE_OPS, 'getstrfromname', [$RT_STR], $RT_STR);
23522354
QAST::OperationsJAST.map_classlib_core_op('encode', $TYPE_OPS, 'encode', [$RT_STR, $RT_STR, $RT_OBJ], $RT_OBJ, :tc);

src/vm/jvm/runtime/org/perl6/nqp/runtime/Ops.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4323,6 +4323,10 @@ public static SixModelObject normalizecodes(SixModelObject in, long normalizatio
43234323
return out;
43244324
}
43254325

4326+
public static long codes(String str) {
4327+
return Normalizer.normalize(str, Normalizer.Form.NFC).codePoints().count();
4328+
}
4329+
43264330
public static SixModelObject strtocodes(String str, long normalization, SixModelObject codes, ThreadContext tc) {
43274331
int i = 0;
43284332
for (int c : Normalizer.normalize(str, javaNormalizationForm(normalization, tc)).codePoints().toArray()) {

0 commit comments

Comments
 (0)