more-pirop-to-nqpop #41

Closed
wants to merge 1 commit into
from
View
18 docs/nqp-opcode.txt
@@ -51,8 +51,8 @@ General notes:
nqp::chars pir::length__Is
nqp::split pir::split__Pss
nqp::iscclass pir::iscclass__Isii (?)
- nqp::findcclass pir::find_cclass__Isii (?)
- nqp::findnotcclass pir::find_not_cclass__Isii (?)
+ nqp::findcclass pir::find_cclass__Iisii (?)
+ nqp::findnotcclass pir::find_not_cclass__Iisii (?)
relational:
nqp::iseq_i pir::iseq__Iii
@@ -78,23 +78,29 @@ General notes:
nqp::bindattribute pir::setattribute__0PPsP
nqp::getattribute pir::getattribute__PPPs
nqp::findmethod pir::find_method__PPs (?)
+ nqp::can pir::can__IPs (?)
nqp::null pir::null__P
nqp::isnull pir::isnull__IP
nqp::defined pir::defined__IP
- nqp::?? pir::istrue__IP
+ nqp::istrue pir::istrue__IP
nqp::clone pir::clone__PP
nqp::typecheck or ::isa pir::type_check__IPP
or ::istype
+ nqp::?? pir::isa__IPs (?)
+ nqp::?? pir::typeof__SP (?)
+ nqp::?? pir::does__IPs (?)
nqp::create pir::repr_instance_of__PP (?)
+
nqp::unbox_i pir::repr_unbox_int__IP
nqp::unbox_n pir::repr_unbox_num__NP
nqp::unbox_s pir::repr_unbox_str__SP
nqp::box_i pir::repr_box_int__PPi
nqp::box_n pir::repr_box_num__PPn
nqp::box_s pir::repr_box_str__PPs
- nqp::what or nqp::getwhat (?)
- nqp::how or nqp::gethow (?)
- nqp::?? pir::can__IPs (?)
+ nqp::what or nqp::getwhat pir::get_what__PP (?)
+ nqp::how or nqp::gethow pir::get_how__PP (?)
+ nqp::who or nqp::getwho pir::get_who__PP (?)
+ nqp::where or nqp::getwhere pir::get_id__IP (?)
Rakudo-specific:
nqp::p6box_i pir::perl6_box_int__Pi
View
4 src/HLL/Actions.pm
@@ -35,7 +35,7 @@ class HLL::Actions {
method SET_BLOCK_OUTER_CTX($block) {
my $outer_ctx := %*COMPILING<%?OPTIONS><outer_ctx>;
- if pir::defined($outer_ctx) {
+ if nqp::defined($outer_ctx) {
my @ns := pir::getattribute__PPs($outer_ctx, 'current_namespace').get_name;
@ns.shift;
$block.namespace(@ns);
@@ -61,7 +61,7 @@ class HLL::Actions {
}
if $key eq 'POSTFIX' { $past.unshift($/[0].ast); }
else {
- for $/.list { if pir::defined__IP($_.ast) { $past.push($_.ast); } }
+ for $/.list { if nqp::defined($_.ast) { $past.push($_.ast); } }
}
make $past;
}
View
12 src/HLL/Compiler.pm
@@ -57,7 +57,7 @@ class HLL::Compiler {
$tagset := $tagset // (@symbols ?? 'ALL' !! 'DEFAULT');
my %exports;
my %source := $module{'EXPORT'}{~$tagset};
- if !pir::defined(%source) {
+ if !nqp::defined(%source) {
%source := $tagset eq 'ALL' ?? $module !! {};
}
if @symbols {
@@ -161,7 +161,7 @@ class HLL::Compiler {
my $code := $stdin.readline_interactive(~$prompt);
last if nqp::isnull($code);
- unless pir::defined($code) {
+ unless nqp::defined($code) {
nqp::print("\n");
last;
}
@@ -181,7 +181,7 @@ class HLL::Compiler {
next;
}
};
- if pir::defined($*MAIN_CTX) {
+ if nqp::defined($*MAIN_CTX) {
for $*MAIN_CTX.lexpad_full() {
%interactive_pad{$_.key} := $_.value;
}
@@ -212,7 +212,7 @@ class HLL::Compiler {
if !pir::isa($output, 'String')
&& %adverbs<target> eq '' {
my $outer_ctx := %adverbs<outer_ctx>;
- if pir::defined($outer_ctx) {
+ if nqp::defined($outer_ctx) {
$output[0].set_outer_ctx($outer_ctx);
}
@@ -267,7 +267,7 @@ class HLL::Compiler {
method interactive_prompt() { '> ' }
method compiler_progname($value?) {
- if pir::defined($value) {
+ if nqp::defined($value) {
$!compiler_progname := $value;
}
$!compiler_progname;
@@ -319,7 +319,7 @@ class HLL::Compiler {
my $has_error := 0;
my $target := nqp::lc(%adverbs<target>);
try {
- if pir::defined(%adverbs<e>) {
+ if nqp::defined(%adverbs<e>) {
$!user_progname := '-e';
my $?FILES := '-e';
$result := self.eval(%adverbs<e>, '-e', |@a, |%adverbs);
View
4 src/HLL/World.pm
@@ -73,7 +73,7 @@ class HLL::World {
# Gets the slot for a given object. Dies if it is not in the context.
method slot_for_object($obj) {
my $slot := %!addr_to_slot{nqp::where($obj)};
- unless pir::defined($slot) {
+ unless nqp::defined($slot) {
nqp::die('slot_for_object called on object not in context');
}
$slot
@@ -178,7 +178,7 @@ class HLL::World {
# Get the object's serialization context; we're stuck if it
# has none.
my $sc := pir::nqp_get_sc_for_object__PP($obj);
- unless pir::defined($sc) {
+ unless nqp::defined($sc) {
self.add_object($obj);
$sc := $!sc;
}
View
8 src/ModuleLoader.pm
@@ -53,7 +53,7 @@ knowhow ModuleLoader {
last;
}
}
- if pir::defined(%modules_loaded{$path}) {
+ if nqp::defined(%modules_loaded{$path}) {
$module_ctx := %modules_loaded{$path};
}
else {
@@ -66,7 +66,7 @@ knowhow ModuleLoader {
}
# Provided we have a mainline...
- if pir::defined($module_ctx) {
+ if nqp::defined($module_ctx) {
# Merge any globals.
my $UNIT := pir::getattribute__PPs($module_ctx, 'lex_pad');
unless nqp::isnull($UNIT<GLOBALish>) {
@@ -152,13 +152,13 @@ knowhow ModuleLoader {
}
# Unless we already did so, load the setting.
- unless pir::defined(%settings_loaded{$path}) {
+ unless nqp::defined(%settings_loaded{$path}) {
my $*CTXSAVE := self;
my $*MAIN_CTX;
my $preserve_global := pir::get_hll_global__Ps('GLOBAL');
pir::load_bytecode($path);
pir::set_hll_global__vsP('GLOBAL', $preserve_global);
- unless pir::defined($*MAIN_CTX) {
+ unless nqp::defined($*MAIN_CTX) {
nqp::die("Unable to load setting $setting_name; maybe it is missing a YOU_ARE_HERE?");
}
%settings_loaded{$path} := $*MAIN_CTX;
View
10 src/NQP/Actions.pm
@@ -117,7 +117,7 @@ class NQP::Actions is HLL::Actions {
if $<statement> {
for $<statement> {
my $ast := $_.ast;
- $ast := $ast<sink> if pir::defined($ast<sink>);
+ $ast := $ast<sink> if nqp::defined($ast<sink>);
if $ast<bareblock> { $ast := block_immediate($ast); }
$ast := PAST::Stmt.new($ast) if $ast ~~ PAST::Node;
$past.push( $ast );
@@ -189,7 +189,7 @@ class NQP::Actions is HLL::Actions {
}
method outerctx($/) {
- unless pir::defined(%*COMPILING<%?OPTIONS><outer_ctx>) {
+ unless nqp::defined(%*COMPILING<%?OPTIONS><outer_ctx>) {
# We haven't got a specified outer context already, so load a
# setting.
my $SETTING := $*W.load_setting(%*COMPILING<%?OPTIONS><setting> // 'NQPCORE');
@@ -243,7 +243,7 @@ class NQP::Actions is HLL::Actions {
method statement_control:sym<use>($/) {
my $module := $*W.load_module(~$<name>, $*GLOBALish);
- if pir::defined($module) {
+ if nqp::defined($module) {
import_HOW_exports($module);
}
make PAST::Stmts.new();
@@ -481,7 +481,7 @@ class NQP::Actions is HLL::Actions {
last;
}
}
- if pir::defined($attr) {
+ if nqp::defined($attr) {
if nqp::can($attr, 'type') {
$past.type($attr.type);
}
@@ -1175,7 +1175,7 @@ class NQP::Actions is HLL::Actions {
my $past := PAST::Node.'map_node'(|$args, :map<nqp>, :op($op),
:node($/));
- pir::defined($past) ||
+ nqp::defined($past) ||
$/.CURSOR.panic("Unrecognized nqp:: opcode 'nqp::$op'");
make $past;
}
View
8 src/NQP/World.pm
@@ -229,7 +229,7 @@ class NQP::World is HLL::World {
my $fixups := PAST::Stmts.new();
my $dummy;
my $code_ref_idx;
- if pir::defined($past<compile_time_dummy>) {
+ if nqp::defined($past<compile_time_dummy>) {
$dummy := $past<compile_time_dummy>;
}
else {
@@ -336,8 +336,8 @@ class NQP::World is HLL::World {
method pkg_create_mo($how, :$name, :$repr) {
# Create the meta-object and add to root objects.
my %args;
- if pir::defined($name) { %args<name> := $name; }
- if pir::defined($repr) { %args<repr> := $repr; }
+ if nqp::defined($name) { %args<name> := $name; }
+ if nqp::defined($repr) { %args<repr> := $repr; }
my $mo := $how.new_type(|%args);
my $slot := self.add_object($mo);
@@ -390,7 +390,7 @@ class NQP::World is HLL::World {
# Fixup code depends on if we have the routine in the SC for
# fixing up.
my $fixup := PAST::Op.new( :pirop('set_sub_multisig vPP'), self.get_ref($sig_obj) );
- if pir::defined($routine<compile_time_dummy>) {
+ if nqp::defined($routine<compile_time_dummy>) {
$fixup.unshift(self.get_slot_past_for_object($routine<compile_time_dummy>));
}
else {
View
3 src/PAST/NQP.pir
@@ -530,6 +530,7 @@ entry to produce the node to be returned.
maphash['substr'] = 'substr__Ssii'
maphash['x'] = 'repeat__Ssi'
maphash['iscclass'] = 'is_cclass__Iisi'
+ maphash['findnotcclass'] = 'find_not_cclass__Iisii'
maphash['sprintf'] = 'sprintf__SsP'
# relational opcodes
@@ -656,6 +657,8 @@ entry to produce the node to be returned.
maphash['box_s'] = 'repr_box_str__PsP'
maphash['where'] = 'get_id__IP'
maphash['can'] = 'can__IPs'
+ maphash['findmethod'] = 'find_method__PPs'
+ maphash['defined'] = 'defined__IP'
# serialization context related opcodes
maphash['sha1'] = 'nqp_sha1__Ss'
View
2 src/QAST/Node.nqp
@@ -9,7 +9,7 @@ class QAST::Node is NQPCapture {
$new.BUILD();
nqp::splice($new.list, @children, 0, 0);
for %options {
- pir::find_method__PPs($new, $_.key)($new, $_.value);
+ nqp::findmethod($new, $_.key)($new, $_.value);
}
$new;
}
View
18 src/QRegex/Cursor.nqp
@@ -40,7 +40,7 @@ role NQPCursorRole {
$subcur := nqp::shift($iter);
$submatch := $subcur.MATCH;
$name := nqp::getattr($subcur, $?CLASS, '$!name');
- if pir::defined($name) {
+ if nqp::defined($name) {
if nqp::index($name, '=') < 0 {
%caplist{$name} >= 2
?? nqp::push($caps{$name}, $submatch)
@@ -64,7 +64,7 @@ role NQPCursorRole {
nqp::bindattr($new, $?CLASS, '$!orig', $target);
$target := pir::trans_encoding__Ssi($target, pir::find_encoding__Is('ucs4'));
nqp::bindattr_s($new, $?CLASS, '$!target', $target);
- if pir::defined($c) {
+ if nqp::defined($c) {
nqp::bindattr_i($new, $?CLASS, '$!from', -1);
nqp::bindattr_i($new, $?CLASS, '$!pos', $c);
}
@@ -115,7 +115,7 @@ role NQPCursorRole {
method !cursor_capture($capture, $name) {
$!match := nqp::null();
- $!cstack := [] unless pir::defined($!cstack);
+ $!cstack := [] unless nqp::defined($!cstack);
nqp::push($!cstack, $capture);
nqp::bindattr($capture, $?CLASS, '$!name', $name);
pir::push__vPi($!bstack, 0);
@@ -126,7 +126,7 @@ role NQPCursorRole {
}
method !cursor_push_cstack($capture) {
- $!cstack := [] unless pir::defined($!cstack);
+ $!cstack := [] unless nqp::defined($!cstack);
nqp::push($!cstack, $capture);
$!cstack;
}
@@ -161,13 +161,13 @@ role NQPCursorRole {
method !reduce($name) {
my $actions := pir::find_dynamic_lex__Ps('$*ACTIONS');
- pir::find_method__PPs($actions, $name)($actions, self.MATCH)
+ nqp::findmethod($actions, $name)($actions, self.MATCH)
if nqp::can($actions, $name);
}
method !reduce_with_match($name, $key, $match) {
my $actions := pir::find_dynamic_lex__Ps('$*ACTIONS');
- pir::find_method__PPs($actions, $name)($actions, $match, $key)
+ nqp::findmethod($actions, $name)($actions, $match, $key)
if nqp::can($actions, $name);
}
@@ -283,7 +283,7 @@ role NQPCursorRole {
|| !nqp::iscclass(pir::const::CCLASS_WORD, $!target, $!pos)
|| !nqp::iscclass(pir::const::CCLASS_WORD, $!target, $!pos-1)
) && $cur."!cursor_pass"(
- pir::find_not_cclass__Iisii(
+ nqp::findnotcclass(
pir::const::CCLASS_WHITESPACE, $!target, $!pos, nqp::chars($!target)),
'ws');
$cur;
@@ -313,7 +313,7 @@ role NQPCursorRole {
method ident() {
my $cur := self."!cursor_start"();
$cur."!cursor_pass"(
- pir::find_not_cclass__Iisii(
+ nqp::findnotcclass(
pir::const::CCLASS_WORD,
$!target, $!pos, nqp::chars($!target)))
if $!pos < nqp::chars($!target) &&
@@ -497,7 +497,7 @@ class NQPCursor does NQPCursorRole {
my $cur := self.'!cursor_init'($target, |%options);
pir::is_invokable__IP($rule) ??
$rule($cur).MATCH() !!
- pir::find_method__PPs($cur, $rule)($cur).MATCH()
+ nqp::findmethod($cur, $rule)($cur).MATCH()
}
method !INTERPOLATE($var) {
View
6 src/QRegex/NFA.nqp
@@ -145,7 +145,7 @@ class QRegex::NFA {
if $max > 1 || $min > 1 {
my $count := 0;
my $st;
- my $has_sep := pir::defined($node[1]);
+ my $has_sep := nqp::defined($node[1]);
while $count < $max || $count < $min {
if $count >= $min {
my $f := self.addedge($from, $to, $EDGE_EPSILON, 0);
@@ -175,7 +175,7 @@ class QRegex::NFA {
}
if $max == -1 {
if $min == 0 { # * quantifier
- if pir::defined($node[1]) { # * %
+ if nqp::defined($node[1]) { # * %
my $start := self.addstate();
self.addedge($from, $start, $EDGE_EPSILON, 0);
my $looper := self.addstate();
@@ -195,7 +195,7 @@ class QRegex::NFA {
self.addedge($from, $start, $EDGE_EPSILON, 0);
my $looper := self.addstate();
my $st := self.regex_nfa($node[0], $start, $looper);
- if pir::defined($node[1]) {
+ if nqp::defined($node[1]) {
self.regex_nfa($node[1], $looper, $start);
}
else {
View
6 src/core/NQPRoutine.pm
@@ -7,7 +7,7 @@ my knowhow NQPRoutine {
$!dispatchees.push($code);
}
method is_dispatcher() {
- pir::defined($!dispatchees)
+ nqp::defined($!dispatchees)
}
method derive_dispatcher() {
# Clone the underlying VM code ref.
@@ -21,7 +21,7 @@ my knowhow NQPRoutine {
# If needed, arrange for a fixup of the cloned code-ref.
my $clone_callback := pir::getprop__PPs($!do, 'CLONE_CALLBACK');
- if pir::defined($clone_callback) {
+ if nqp::defined($clone_callback) {
$clone_callback($!do, $do, $der);
}
@@ -38,7 +38,7 @@ my knowhow NQPRoutine {
# If needed, arrange for a fixup of the cloned code-ref.
my $clone_callback := pir::getprop__PPs($!do, 'CLONE_CALLBACK');
- if pir::defined($clone_callback) {
+ if nqp::defined($clone_callback) {
$clone_callback($!do, $do, $der);
}
View
2 src/how/NQPAttribute.pm
@@ -45,7 +45,7 @@ knowhow NQPAttribute {
# unless has_method($obj, $method, 0) {
# $obj.HOW.add_method($obj.WHAT, $method, method ($value?) {
# pir::setattribute__vppsp(self, $obj.WHAT, $long_name, $value)
- # if pir::defined($value);
+ # if nqp::defined($value);
# pir::getattribute__ppps(self, $obj.WHAT, $long_name);
# }
# );
View
16 src/how/NQPClassHOW.pm
@@ -138,7 +138,7 @@ knowhow NQPClassHOW {
}
method add_parrot_vtable_mapping($obj, $name, $meth) {
- if pir::defined(%!parrot_vtable_mapping{$name}) {
+ if nqp::defined(%!parrot_vtable_mapping{$name}) {
nqp::die("Class '" ~ $!name ~
"' already has a Parrot v-table override for '" ~
$name ~ "'");
@@ -147,7 +147,7 @@ knowhow NQPClassHOW {
}
method add_parrot_vtable_handler_mapping($obj, $name, $att_name) {
- if pir::defined(%!parrot_vtable_handler_mapping{$name}) {
+ if nqp::defined(%!parrot_vtable_handler_mapping{$name}) {
nqp::die("Class '" ~ $!name ~
"' already has a Parrot v-table handler for '" ~
$name ~ "'");
@@ -212,7 +212,7 @@ knowhow NQPClassHOW {
# Do we have anything in the methods table already in
# this class?
my $dispatcher := %!methods{$name};
- if pir::defined($dispatcher) {
+ if nqp::defined($dispatcher) {
# Yes. Only or dispatcher, though? If only, error. If
# dispatcher, simply add new dispatchee.
if pir::is_dispatcher__IP($dispatcher) {
@@ -233,7 +233,7 @@ knowhow NQPClassHOW {
my $parent := @!mro[$j];
my %meths := $parent.HOW.method_table($parent);
my $dispatcher := %meths{$name};
- if pir::defined($dispatcher) {
+ if nqp::defined($dispatcher) {
# Found a possible - make sure it's a dispatcher, not
# an only.
if pir::is_dispatcher__IP($dispatcher) {
@@ -242,7 +242,7 @@ knowhow NQPClassHOW {
@new_dispatchees[0] := $code;
my $new_disp := pir::create_dispatch_and_add_candidates__PPP($dispatcher, @new_dispatchees);
my $clone_callback := pir::getprop__PPs($dispatcher, 'CLONE_CALLBACK');
- if pir::defined($clone_callback) {
+ if nqp::defined($clone_callback) {
$clone_callback($dispatcher, $new_disp);
}
%!methods{$name} := $new_disp;
@@ -385,7 +385,7 @@ knowhow NQPClassHOW {
method publish_boolification_spec($obj) {
my $bool_meth := self.find_method($obj, 'Bool');
- if pir::defined($bool_meth) {
+ if nqp::defined($bool_meth) {
pir::set_boolification_spec__0PiP($obj, 0, $bool_meth)
}
else {
@@ -517,7 +517,7 @@ knowhow NQPClassHOW {
for @!mro {
my %meths := $_.HOW.method_table($obj);
my $can := %meths{$name};
- if pir::defined($can) {
+ if nqp::defined($can) {
return $can;
}
}
@@ -531,7 +531,7 @@ knowhow NQPClassHOW {
for @!mro {
my %meths := $_.HOW.method_table($obj);
my $found := %meths{$name};
- if pir::defined($found) {
+ if nqp::defined($found) {
return $!trace && !$no_trace && nqp::substr($name, 0, 1) ne '!' ??
-> *@pos, *%named {
say(nqp::x(' ', $!trace_depth) ~ "Calling $name");
View
4 src/how/RoleToRoleApplier.pm
@@ -8,7 +8,7 @@ knowhow RoleToRoleApplier {
my $name := ~$_;
my $meth := $_;
my @meth_list;
- if pir::defined(%meth_info{$name}) {
+ if nqp::defined(%meth_info{$name}) {
@meth_list := %meth_info{$name};
}
else {
@@ -40,7 +40,7 @@ knowhow RoleToRoleApplier {
# Do we already have a method of this name? If so, ignore all of the
# methods we have from elsewhere.
- unless pir::defined(%target_meth_info{$name}) {
+ unless nqp::defined(%target_meth_info{$name}) {
# No methods in the target role. If only one, it's easy...
if +@add_meths == 1 {
$target.HOW.add_method($target, $name, @add_meths[0]);
View
2 t/hll/04-import.t
@@ -22,7 +22,7 @@ say("1..0 skip design changes (EXPORT now lexical), need re-work");
#ok( alpha() eq 'alpha', "imported 'alpha' sub into current namespace" );
#
#our &beta;
-#ok( !pir::defined(&beta), "didn't import &beta");
+#ok( !nqp::defined(&beta), "didn't import &beta");
#
#our $gamma;
#ok( $gamma eq 'gamma', 'did import $gamma');