Skip to content

Commit 69d548e

Browse files
committed
Toss various nqp:: ops that are too Parrot-specific.
1 parent bfea0f7 commit 69d548e

File tree

17 files changed

+62
-68
lines changed

17 files changed

+62
-68
lines changed

docs/nqp-opcode.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ General notes:
7777
object:
7878
nqp::bindattribute pir::setattribute__0PPsP
7979
nqp::getattribute pir::getattribute__PPPs
80-
nqp::find_method pir::find_method__PPs (?)
80+
nqp::findmethod pir::find_method__PPs (?)
8181
nqp::can pir::can__IPs (?)
8282
nqp::null pir::null__P
8383
nqp::isnull pir::isnull__IP

src/HLL/Actions.pm

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ class HLL::Actions {
77
}
88

99
method ints_to_string($ints) {
10-
if nqp::does($ints, 'array') {
10+
if pir::does($ints, 'array') {
1111
my $result := '';
1212
for $ints {
1313
$result := $result ~ nqp::chr($_.ast);
@@ -69,7 +69,7 @@ class HLL::Actions {
6969
method term:sym<circumfix>($/) { make $<circumfix>.ast }
7070

7171
method termish($/) { make $<term>.ast; }
72-
method nullterm($/) { make nqp::new('Undef') }
72+
method nullterm($/) { make pir::new__Ps('Undef') }
7373
method nullterm_alt($/) { make $<term>.ast; }
7474

7575
method integer($/) { make $<VALUE>.ast; }

src/HLL/CommandLine.pm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ class HLL::CommandLine::Result {
109109
# how I miss p6's Hash.push
110110

111111
if nqp::existskey(%!options, $name) {
112-
if nqp::does(%!options{$name}, 'array') {
112+
if pir::does(%!options{$name}, 'array') {
113113
nqp::push(%!options{$name}, $value);
114114
} else {
115115
%!options{$name} := [ %!options{$name}, $value ];

src/HLL/Compiler.pm

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -43,14 +43,14 @@ class HLL::Compiler {
4343
}
4444

4545
my sub value_type($value) {
46-
nqp::isa($value, 'NameSpace')
46+
pir::isa($value, 'NameSpace')
4747
?? 'namespace'
48-
!! (nqp::isa($value, 'Sub') ?? 'sub' !! 'var')
48+
!! (pir::isa($value, 'Sub') ?? 'sub' !! 'var')
4949
}
5050

5151
method get_exports($module, :$tagset, *@symbols) {
5252
# convert a module name to something hash-like, if needed
53-
if (!nqp::does($module, 'hash')) {
53+
if (!pir::does($module, 'hash')) {
5454
$module := self.get_module($module);
5555
}
5656

@@ -209,7 +209,7 @@ class HLL::Compiler {
209209
}
210210
$output := self.compile($code, |%adverbs);
211211

212-
if !nqp::isa($output, 'String')
212+
if !pir::isa($output, 'String')
213213
&& %adverbs<target> eq '' {
214214
my $outer_ctx := %adverbs<outer_ctx>;
215215
if nqp::defined($outer_ctx) {
@@ -335,7 +335,7 @@ class HLL::Compiler {
335335
my $output := %adverbs<output>;
336336
my $fh := ($output eq '' || $output eq '-')
337337
?? pir::getinterp__P().stdout_handle()
338-
!! nqp::new('FileHandle').open($output, 'w');
338+
!! pir::new__Ps('FileHandle').open($output, 'w');
339339
self.panic("Cannot write to $output") unless $fh;
340340
nqp::print($fh, $result);
341341
$fh.close()
@@ -398,11 +398,11 @@ class HLL::Compiler {
398398
method evalfiles($files, *@args, *%adverbs) {
399399
my $target := nqp::lc(%adverbs<target>);
400400
my $encoding := %adverbs<encoding>;
401-
my @files := nqp::does($files, 'array') ?? $files !! [$files];
401+
my @files := pir::does($files, 'array') ?? $files !! [$files];
402402
$!user_progname := nqp::join(',', @files);
403403
my @codes;
404404
for @files {
405-
my $in-handle := nqp::new('FileHandle');
405+
my $in-handle := pir::new__Ps('FileHandle');
406406
my $err := 0;
407407
try {
408408
# the PIR version checked for utf8 specifically...
@@ -468,7 +468,7 @@ class HLL::Compiler {
468468

469469
method past($source, *%adverbs) {
470470
my $ast := $source.ast();
471-
self.panic("Unable to obtain ast from " ~ nqp::typeof($source))
471+
self.panic("Unable to obtain ast from " ~ pir::typeof($source))
472472
unless $ast ~~ PAST::Node;
473473
$ast;
474474
}
@@ -547,7 +547,7 @@ class HLL::Compiler {
547547
my $file := $spec[0];
548548
my $flags := $spec[1];
549549
if $file gt '' {
550-
my $fh := nqp::new('FileHandle');
550+
my $fh := pir::new__Ps('FileHandle');
551551
$fh.open($file, 'w') || self.panic("Cannot write to $file");
552552
pir::nqpevent_fh__PP($fh);
553553
}
@@ -560,7 +560,7 @@ class HLL::Compiler {
560560
}
561561

562562
method removestage($stagename) {
563-
my @new_stages := nqp::new('ResizableStringArray');
563+
my @new_stages := pir::new__Ps('ResizableStringArray');
564564
for @!stages {
565565
if $_ ne $stagename {
566566
@new_stages.push($_);
@@ -584,7 +584,7 @@ class HLL::Compiler {
584584
self.stages(@new-stages);
585585
return 1;
586586
}
587-
my @new-stages := nqp::new('ResizableStringArray');
587+
my @new-stages := pir::new__Ps('ResizableStringArray');
588588
for self.stages {
589589
if $_ eq $where {
590590
if $position eq 'before' {

src/HLL/World.pm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ class HLL::World {
223223
# the deserialization.
224224
method serialize_and_produce_deserialization_past($sc_reg) {
225225
# Serialize.
226-
my $sh := nqp::new('ResizableStringArray');
226+
my $sh := pir::new__Ps('ResizableStringArray');
227227
my $serialized := pir::nqp_serialize_sc__SPP($!sc, $sh);
228228

229229
# Now it's serialized, pop this SC off the compiling SC stack.

src/PAST/NQP.pir

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -433,7 +433,7 @@ entry to produce the node to be returned.
433433
# I/O opcodes
434434
maphash['print'] = 'print'
435435
maphash['say'] = 'say'
436-
maphash['stat'] = 'stat__isi'
436+
maphash['stat'] = 'stat__Isi'
437437
maphash['open'] = 'open__Pss'
438438

439439
# terms
@@ -535,7 +535,6 @@ entry to produce the node to be returned.
535535
maphash['iscclass'] = 'is_cclass__Iisi'
536536
maphash['findnotcclass'] = 'find_not_cclass__Iisii'
537537
maphash['sprintf'] = 'sprintf__SsP'
538-
maphash['find_not_cclass'] = 'find_not_cclass__Iisii'
539538

540539
# relational opcodes
541540
maphash['cmp_i'] = 'cmp__Iii'
@@ -661,11 +660,7 @@ entry to produce the node to be returned.
661660
maphash['box_s'] = 'repr_box_str__PsP'
662661
maphash['where'] = 'get_id__IP'
663662
maphash['can'] = 'can__IPs'
664-
maphash['does'] = 'does'
665-
maphash['isa'] = 'isa__IPs'
666-
maphash['new'] = 'new__PsP'
667-
maphash['find_method'] = 'find_method__pps'
668-
maphash['typeof'] = 'typeof__SP'
663+
maphash['findmethod'] = 'find_method__pps'
669664

670665
# serialization context related opcodes
671666
maphash['sha1'] = 'nqp_sha1__Ss'

src/QAST/Node.nqp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ class QAST::Node is NQPCapture {
99
$new.BUILD();
1010
nqp::splice($new.list, @children, 0, 0);
1111
for %options {
12-
nqp::find_method($new, $_.key)($new, $_.value);
12+
nqp::findmethod($new, $_.key)($new, $_.value);
1313
}
1414
$new;
1515
}

src/QRegex/Cursor.nqp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ role NQPCursorRole {
9999
nqp::bindattr_s($new, $?CLASS, '$!target', $!target),
100100
nqp::bindattr_i($new, $?CLASS, '$!from', $!pos),
101101
$?CLASS,
102-
nqp::bindattr($new, $?CLASS, '$!bstack', nqp::new('ResizableIntegerArray')),
102+
nqp::bindattr($new, $?CLASS, '$!bstack', pir::new__Ps('ResizableIntegerArray')),
103103
0
104104
)
105105
}
@@ -161,13 +161,13 @@ role NQPCursorRole {
161161

162162
method !reduce($name) {
163163
my $actions := pir::find_dynamic_lex__Ps('$*ACTIONS');
164-
nqp::find_method($actions, $name)($actions, self.MATCH)
164+
nqp::findmethod($actions, $name)($actions, self.MATCH)
165165
if nqp::can($actions, $name);
166166
}
167167

168168
method !reduce_with_match($name, $key, $match) {
169169
my $actions := pir::find_dynamic_lex__Ps('$*ACTIONS');
170-
nqp::find_method($actions, $name)($actions, $match, $key)
170+
nqp::findmethod($actions, $name)($actions, $match, $key)
171171
if nqp::can($actions, $name);
172172
}
173173

@@ -458,7 +458,7 @@ class NQPCursor does NQPCursorRole {
458458
my $EMPTY_MATCH_HASH := nqp::hash();
459459
method MATCH() {
460460
my $match := nqp::getattr(self, NQPCursor, '$!match');
461-
unless nqp::istype($match, NQPMatch) || nqp::isa($match, 'Hash') {
461+
unless nqp::istype($match, NQPMatch) || pir::isa($match, 'Hash') {
462462
my $list := $EMPTY_MATCH_LIST;
463463
my $hash := $EMPTY_MATCH_HASH;
464464
$match := nqp::create(NQPMatch);
@@ -497,11 +497,11 @@ class NQPCursor does NQPCursorRole {
497497
my $cur := self.'!cursor_init'($target, |%options);
498498
pir::is_invokable__IP($rule) ??
499499
$rule($cur).MATCH() !!
500-
nqp::find_method($cur, $rule)($cur).MATCH()
500+
nqp::findmethod($cur, $rule)($cur).MATCH()
501501
}
502502

503503
method !INTERPOLATE($var) {
504-
if nqp::does($var, 'array') {
504+
if pir::does($var, 'array') {
505505
my $maxlen := -1;
506506
my $cur := self.'!cursor_start'();
507507
my $pos := nqp::getattr_i($cur, $?CLASS, '$!from');
@@ -542,7 +542,7 @@ class NQPCursor does NQPCursorRole {
542542
method !INTERPOLATE_REGEX($var) {
543543
unless pir::is_invokable__IP($var) {
544544
my $rxcompiler := pir::compreg__Ps('QRegex::P6Regex');
545-
if nqp::does($var, 'array') {
545+
if pir::does($var, 'array') {
546546
my $res := [];
547547
for $var {
548548
my $elem := $_;

src/core/IO.pm

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ Open file.
1010

1111
sub open($filename, :$r, :$w, :$a, :$bin) {
1212
my $mode := $w ?? 'w' !! ($a ?? 'wa' !! 'r');
13-
my $handle := nqp::new('FileHandle');
13+
my $handle := pir::new__Ps('FileHandle');
1414
$handle.open($filename, $mode);
1515
$handle.encoding($bin ?? 'binary' !! 'utf8');
1616
$handle;
@@ -41,8 +41,7 @@ Write the string value of C<$contents> to C<$filename>.
4141
=end item
4242

4343
sub spew($filename, $contents) {
44-
my $handle := nqp::new('FileHandle');
45-
$handle.open($filename, 'w');
44+
my $handle := open($filename, :w);
4645
$handle.print($contents);
4746
$handle.close();
4847
}

src/core/Regex.pm

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,9 @@ perform the replacement on all matches of C<$text>.
3434
sub subst ($text, $regex, $repl, :$global?) {
3535
my @matches := $global ?? match($text, $regex, :global)
3636
!! [ $text ~~ $regex ];
37-
my $is_code := nqp::isa($repl, 'Sub');
37+
my $is_code := pir::isa($repl, 'Sub');
3838
my $offset := 0;
39-
my $result := nqp::new('StringBuilder');
39+
my $result := pir::new__Ps('StringBuilder');
4040

4141
for @matches -> $match {
4242
if $match {

0 commit comments

Comments
 (0)