Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
implement Routine.package
  • Loading branch information
moritz committed Apr 10, 2012
1 parent edfd0f2 commit 8144a04
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/Perl6/Metamodel/BOOTSTRAP.pm
Expand Up @@ -565,7 +565,10 @@ BEGIN {
Routine.HOW.add_attribute(Routine, BOOTSTRAPATTR.new(:name<$!md_thunk>, :type(Mu), :package(Routine)));
Routine.HOW.add_attribute(Routine, BOOTSTRAPATTR.new(:name<$!rw>, :type(int), :package(Routine)));
Routine.HOW.add_attribute(Routine, BOOTSTRAPATTR.new(:name<$!inline_info>, :type(str), :package(Routine)));
Routine.HOW.add_attribute(Routine, BOOTSTRAPATTR.new(:name<$!yada>, :type(int), :package(Routine)));Code.HOW.add_method(Code, 'is_dispatcher', static(sub ($self) {
Routine.HOW.add_attribute(Routine, BOOTSTRAPATTR.new(:name<$!yada>, :type(int), :package(Routine)));
Routine.HOW.add_attribute(Routine, BOOTSTRAPATTR.new(:name<$!package>, :type(Mu), :package(Routine)));

Code.HOW.add_method(Code, 'is_dispatcher', static(sub ($self) {
my $dc_self := pir::perl6_decontainerize__PP($self);
my $disp_list := nqp::getattr($dc_self, Routine, '$!dispatchees');
pir::perl6_booleanize__PI(pir::defined__IP($disp_list));
Expand Down
2 changes: 2 additions & 0 deletions src/Perl6/World.pm
Expand Up @@ -715,8 +715,10 @@ class Perl6::World is HLL::World {
}

# If it's a routine, flag that it needs fresh magicals.
# Also store the namespace, which makes backtraces nicer.
if nqp::istype($code, $routine_type) {
self.get_static_lexpad($code_past).set_fresh_magicals();
nqp::bindattr($code, $routine_type, '$!package', $*PACKAGE);
}

self.add_fixup_task(:deserialize_past($des), :fixup_past($fixups));
Expand Down
2 changes: 2 additions & 0 deletions src/core/Routine.pm
Expand Up @@ -95,4 +95,6 @@ my class Routine {
method yada() {
nqp::p6bool(nqp::getattr_i(self, Routine, '$!yada'))
}

method package() { $!package }
}

0 comments on commit 8144a04

Please sign in to comment.