Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Mark out Parrot-specific bits in MOP.
  • Loading branch information
jnthn committed Apr 14, 2013
1 parent 13c5f8d commit c9065ee
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions src/how/NQPClassHOW.nqp
Expand Up @@ -35,10 +35,12 @@ knowhow NQPClassHOW {
# Cached values, which are thrown away if the class changes.
has %!caches;

#?if parrot
# Parrot-specific vtable mapping hash. Maps vtable name to method.
has %!parrot_vtable_mapping;
has %!parrot_vtable_handler_mapping;

has %!parrot_vtable_handler_mapping;
#?endif

# Call tracing.
has $!trace;
has $!trace_depth;
Expand Down Expand Up @@ -75,8 +77,10 @@ knowhow NQPClassHOW {
%!method-vtable-slots := nqp::hash();
@!mro := nqp::list();
@!done := nqp::list();
#?if parrot
%!parrot_vtable_mapping := nqp::hash();
%!parrot_vtable_handler_mapping := nqp::hash();
#?endif
@!BUILDALLPLAN := nqp::list();
@!BUILDPLAN := nqp::list();
$!trace := 0;
Expand Down Expand Up @@ -167,8 +171,10 @@ knowhow NQPClassHOW {
self.publish_type_cache($obj);
self.publish_method_cache($obj);
self.publish_boolification_spec($obj);
#?if parrot
self.publish_parrot_vtable_mapping($obj);
self.publish_parrot_vtablee_handler_mapping($obj);
#?endif
1;
}

Expand All @@ -181,6 +187,7 @@ knowhow NQPClassHOW {
nqp::push(@!roles, $role);
}

#?if parrot
method add_parrot_vtable_mapping($obj, $name, $meth) {
if nqp::defined(%!parrot_vtable_mapping{$name}) {
nqp::die("Class '" ~ $!name ~
Expand All @@ -198,6 +205,7 @@ knowhow NQPClassHOW {
}
%!parrot_vtable_handler_mapping{$name} := [ $obj, $att_name ];
}
#?endif

method compose($obj) {
# Incorporate roles. First, specialize them with the type object
Expand Down Expand Up @@ -234,9 +242,11 @@ knowhow NQPClassHOW {
self.publish_method_cache($obj);
self.publish_boolification_spec($obj);

#?if parrot
# Install Parrot v-table mapping.
self.publish_parrot_vtable_mapping($obj);
self.publish_parrot_vtablee_handler_mapping($obj);
#?endif

# Create BUILDPLAN.
self.create_BUILDPLAN($obj);
Expand Down Expand Up @@ -480,6 +490,7 @@ knowhow NQPClassHOW {
}
}

#?if parrot
method publish_parrot_vtable_mapping($obj) {
my %mapping;
my %seen_handlers;
Expand Down Expand Up @@ -511,7 +522,8 @@ knowhow NQPClassHOW {
pir::stable_publish_vtable_handler_mapping__0PP($obj, %mapping);
}
}

#?endif

# Creates the plan for building up the object. This works
# out what we'll need to do up front, so we can just zip
# through the "todo list" each time we need to make an object.
Expand Down Expand Up @@ -646,13 +658,15 @@ knowhow NQPClassHOW {
@attrs
}

#?if parrot
method parrot_vtable_mappings($obj, :$local!) {
%!parrot_vtable_mapping
}

method parrot_vtable_handler_mappings($obj, :$local!) {
%!parrot_vtable_handler_mapping
}
#?endif

##
## Checky
Expand Down

0 comments on commit c9065ee

Please sign in to comment.