Skip to content

Commit

Permalink
Make Metamodel::Native(Ref)HOW consistent
Browse files Browse the repository at this point in the history
With regards to the .(sub)method_table methods.  Also make sure we
create these return values at compile time.
  • Loading branch information
lizmat committed Mar 20, 2024
1 parent 6945637 commit 85b65a9
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 9 deletions.
15 changes: 8 additions & 7 deletions src/Perl6/Metamodel/NativeHOW.nqp
Original file line number Diff line number Diff line change
Expand Up @@ -84,14 +84,15 @@ class Perl6::Metamodel::NativeHOW
method unsigned( $XXX?) { $!unsigned }
method nativesize($XXX?) { $!nativesize }

method method_table($XXX?) {
nqp::hash('new',
nqp::getstaticcode(sub (*@_, *%_) {
nqp::die('Cannot instantiate a native type')
}))
}
my constant METHOD_TABLE := nqp::hash('new',
nqp::getstaticcode(sub (*@_, *%_) {
nqp::die('Cannot instantiate a native type')
})
);
my constant SUBMETHOD_TABLE := nqp::hash;

method submethod_table($XXX?) { nqp::hash }
method method_table( $XXX?) { METHOD_TABLE }
method submethod_table($XXX?) { SUBMETHOD_TABLE }
}

# vim: expandtab sw=4
11 changes: 9 additions & 2 deletions src/Perl6/Metamodel/NativeRefHOW.nqp
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,15 @@ class Perl6::Metamodel::NativeRefHOW
method native_type($XXX?) { $!type }
method ref_kind($XXX?) { $!refkind }

method method_table($XXX?) { nqp::hash }
method submethod_table($XXX?) { nqp::hash }
my constant METHOD_TABLE := nqp::hash('new',
nqp::getstaticcode(sub (*@_, *%_) {
nqp::die('Cannot instantiate a native reference type')
})
);
my constant SUBMETHOD_TABLE := nqp::hash;

method method_table( $XXX?) { METHOD_TABLE }
method submethod_table($XXX?) { SUBMETHOD_TABLE }
}

# vim: expandtab sw=4

0 comments on commit 85b65a9

Please sign in to comment.