Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Update nqp::setcontspec usages for new protocol.
  • Loading branch information
jnthn committed Mar 19, 2013
1 parent 813cc56 commit 8b49b7a
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions src/Perl6/Metamodel/BOOTSTRAP.pm
Expand Up @@ -77,6 +77,9 @@ my stub Metamodel metaclass Perl6::Metamodel::PackageHOW { ... };
# We stick all the declarative bits inside of a BEGIN, so they get
# serialized.
BEGIN {
# Ensure Rakudo dynops are initialized.
pir::rakudo_dynop_setup__v();

# Maps code objects to their static self, avoiding them being closures.
sub static($code) {
$code.get_lexinfo().get_static_code()
Expand Down Expand Up @@ -286,7 +289,7 @@ BEGIN {
Scalar.HOW.compose_repr(Scalar);

# Scalar needs to be registered as a container type.
nqp::setcontspec(Scalar, Scalar, '$!value', nqp::null());
nqp::setcontspec(Scalar, 'rakudo_scalar', nqp::null());

# class Proxy is Any {
# has &!FETCH;
Expand All @@ -295,24 +298,28 @@ BEGIN {
# method STORE(\$v) { ... }
# }
my $PROXY_FETCH;
my $PROXY_STORE;
Proxy.HOW.add_parent(Proxy, Any);
Proxy.HOW.add_attribute(Proxy, BOOTSTRAPATTR.new(:name<&!FETCH>, :type(Mu), :package(Proxy)));
Proxy.HOW.add_attribute(Proxy, BOOTSTRAPATTR.new(:name<&!STORE>, :type(Mu), :package(Proxy)));
Proxy.HOW.add_method(Proxy, 'FETCH', ($PROXY_FETCH := static(sub ($cont) {
nqp::decont(
nqp::getattr($cont, Proxy, '&!FETCH')(pir::perl6_var__PP($cont)))
})));
Proxy.HOW.add_method(Proxy, 'STORE', static(sub ($cont, $val) {
Proxy.HOW.add_method(Proxy, 'STORE', ($PROXY_STORE := static(sub ($cont, $val) {
nqp::getattr($cont, Proxy, '&!STORE')(pir::perl6_var__PP($cont), $val)
}));
})));
Proxy.HOW.add_method(Proxy, 'new', static(sub ($type, :$FETCH, :$STORE) {
my $cont := nqp::create(Proxy);
nqp::bindattr($cont, Proxy, '&!FETCH', $FETCH);
nqp::bindattr($cont, Proxy, '&!STORE', $STORE);
$cont
}));
Proxy.HOW.compose(Proxy);
nqp::setcontspec(Proxy, nqp::null(), '', $PROXY_FETCH);
nqp::setcontspec(Proxy, 'code_pair', nqp::hash(
'fetch', $PROXY_FETCH,
'store', $PROXY_STORE
));
Proxy.HOW.compose_repr(Proxy);

# Helper for creating a scalar attribute. Sets it up as a real Perl 6
Expand Down

0 comments on commit 8b49b7a

Please sign in to comment.