From 1719ca957a814875d0eee07aa7a3b1b60370ce9e Mon Sep 17 00:00:00 2001 From: Jonathan Worthington Date: Thu, 11 Nov 2021 15:58:42 +0100 Subject: [PATCH 1/4] Remove use of nqp::attrinited in NQPMu It seems we can get away with treating NQPMu as a sentinel for the sake of default handling in NQP. This doesn't regress the NQP tests, nor the Rakudo build/test/spectest, which should really exercise just about all the things written in NQP. --- src/core/NQPMu.nqp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/NQPMu.nqp b/src/core/NQPMu.nqp index 5f2a72278..00ef3bf43 100644 --- a/src/core/NQPMu.nqp +++ b/src/core/NQPMu.nqp @@ -28,7 +28,7 @@ my class NQPMu { } } elsif nqp::iseq_i($code, 4) { - unless nqp::attrinited(self, nqp::atpos($task, 1), nqp::atpos($task, 2)) { + unless nqp::eqaddr(nqp::getattr(self, nqp::atpos($task, 1), nqp::atpos($task, 2)), NQPMu) { nqp::bindattr(self, nqp::atpos($task, 1), nqp::atpos($task, 2), nqp::atpos($task, 3)(self, nqp::getattr(self, nqp::atpos($task, 1), nqp::atpos($task, 2)))); From e532765ca69d7a9be1d3f5b6a5b1ca1d743eca67 Mon Sep 17 00:00:00 2001 From: Jonathan Worthington Date: Thu, 11 Nov 2021 16:02:34 +0100 Subject: [PATCH 2/4] Remove nqp::attrinited tests --- t/nqp/058-attrs.t | 34 +-------------------------- t/serialization/01-basic.t | 47 +------------------------------------- 2 files changed, 2 insertions(+), 79 deletions(-) diff --git a/t/nqp/058-attrs.t b/t/nqp/058-attrs.t index f317b1ce8..9139f6193 100644 --- a/t/nqp/058-attrs.t +++ b/t/nqp/058-attrs.t @@ -1,4 +1,4 @@ -plan(35); +plan(30); class Foo { has $!answer; @@ -115,38 +115,6 @@ class ClassB { ok(nqp::ishash(ClassA.new.get_attr), 'BUILD initializes a % attribute with a hash'); ok(nqp::isnull(ClassB.new.get_attr), 'without a BUILD a % attribute is initialized with a null'); -class AttrInitedTest { - has $!attr1; - has $!attr2; - method get_attr1() { - $!attr1; - } - method set_attr2() { - $!attr2 := 200 - } - has int $!attr3; - method set_attr3() { - $!attr3 := 200 - } - - has int $!attr4; - method get_attr4() { - $!attr1; - } -} -my $partial := AttrInitedTest.new; -ok(!nqp::attrinited($partial, AttrInitedTest, '$!attr1'), 'nqp::attrinitied on a uninitialized attr'); -$partial.get_attr1; -ok(nqp::attrinited($partial, AttrInitedTest, '$!attr1'), 'nqp::attrinitied on a attr that has been autovivified'); -$partial.set_attr2; -ok(nqp::attrinited($partial, AttrInitedTest, '$!attr2'), 'nqp::attrinitied on a attr that has been bound to'); - -my $in_void := AttrInitedTest.new; -ok(!nqp::attrinited($in_void, AttrInitedTest, '$!attr1'), 'nqp::attrinitied before getting attr'); -nqp::getattr($in_void, AttrInitedTest, '$!attr1'); -ok(nqp::attrinited($in_void, AttrInitedTest, '$!attr1'), 'nqp::attrinitied with nqp::getattr as void'); - - use nqpmo; class Mutable { diff --git a/t/serialization/01-basic.t b/t/serialization/01-basic.t index ee79c2ee8..d5b12a546 100644 --- a/t/serialization/01-basic.t +++ b/t/serialization/01-basic.t @@ -1,4 +1,4 @@ -plan(1518); +plan(1514); { my $sc := nqp::createsc('exampleHandle'); @@ -494,51 +494,6 @@ sub fresh_out_sc() { ok(nqp::atpos_i($matching, 0) == 11,"...and we get the right fate"); } -# nqp::attrinitied works after serialization -{ - my $sc := nqp::createsc(fresh_in_sc()); - my $sh := nqp::list_s(); - - my class TestAttrinitied { - has $!written; - has $!read; - has $!not_inited; - has $!null; - method write() { - $!written := 123; - $!null := nqp::null(); - } - method read() { - if $!read { - ok(0); - } - } - } - - my $v := TestAttrinitied.new(); - $v.write(); - $v.read(); - - add_to_sc($sc, 0, $v); - - my $serialized := nqp::serialize($sc, $sh); - - my $dsc := nqp::createsc(fresh_out_sc()); - nqp::deserialize($serialized, $dsc, $sh, nqp::list(), nqp::null()); - - ok(nqp::attrinited(nqp::scgetobj($dsc, 0), TestAttrinitied, '$!written'), 'nqp::attrinited on an attribute that has been written to'); - ok(!nqp::attrinited(nqp::scgetobj($dsc, 0), TestAttrinitied, '$!not_inited'), 'nqp::attinitied on an attribute that has not be initialized'); - ok(nqp::attrinited(nqp::scgetobj($dsc, 0), TestAttrinitied, '$!read'), 'nqp::attrinited on an attribute that has been autovivified'); - - if nqp::getcomp('nqp').backend.name eq 'jvm' { - skip('null handling is broken on the jvm', 1); - } - else { - ok(nqp::attrinited(nqp::scgetobj($dsc, 0), TestAttrinitied, '$!null'), 'nqp::attrinited on an attribute that has been set with null'); - } - -} - # Serializing an SC with a VMArray { my $old-empty-hash := nqp::hash(); From d5944e3cb6ad1d3dbad07c21d6d316a189ab653e Mon Sep 17 00:00:00 2001 From: Jonathan Worthington Date: Thu, 11 Nov 2021 16:05:00 +0100 Subject: [PATCH 3/4] Remove nqp::attrinited mapping on MoarVM --- src/vm/moar/QAST/QASTOperationsMAST.nqp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/vm/moar/QAST/QASTOperationsMAST.nqp b/src/vm/moar/QAST/QASTOperationsMAST.nqp index 059fdb69f..f38bb257e 100644 --- a/src/vm/moar/QAST/QASTOperationsMAST.nqp +++ b/src/vm/moar/QAST/QASTOperationsMAST.nqp @@ -3387,7 +3387,6 @@ while $i < $n { QAST::MASTOperations.add_core_moarop_mapping('rebless', 'rebless', :decont(0, 1)); QAST::MASTOperations.add_core_moarop_mapping('istype', 'istype', :decont(0, 1)); -QAST::MASTOperations.add_core_moarop_mapping('attrinited', 'attrinited', :decont(1)); QAST::MASTOperations.add_core_moarop_mapping('setboolspec', 'setboolspec', 0, :decont(0)); QAST::MASTOperations.add_core_moarop_mapping('settypecache', 'settypecache', 0, :decont(0)); QAST::MASTOperations.add_core_moarop_mapping('settypecheckmode', 'settypecheckmode', 0, :decont(0)); From 5adb747960453ed0ef21959d82eec6dca768acaf Mon Sep 17 00:00:00 2001 From: Jonathan Worthington Date: Thu, 11 Nov 2021 16:06:26 +0100 Subject: [PATCH 4/4] Remove docs for nqp::attrinited --- docs/ops.markdown | 8 -------- 1 file changed, 8 deletions(-) diff --git a/docs/ops.markdown b/docs/ops.markdown index 24b700267..57ce48b9d 100644 --- a/docs/ops.markdown +++ b/docs/ops.markdown @@ -339,7 +339,6 @@ The opcodes are grouped into the following categories: ## [Objects](#objects) -[attrinited](#attrinited) | [bind](#bind) | [bindattr](#bindattr) | [bindcomp](#bindcomp) | @@ -2178,13 +2177,6 @@ an integer. # Objects -## attrinited -* `attrinited(Mu $obj. Mu:T $type, str $attributename --> int)` - -Test if the attribute of name `$attributename` of object `$obj` -has been bound, see `bindattr`. Note that any access to the atribute -that results in a `getattr` call causes it to be inited. - ## bind * `bind(Mu $variable, Mu $value)`