Skip to content

Commit

Permalink
[common] Allow NQPClassHOW to take and store the name of the class, a…
Browse files Browse the repository at this point in the history
…nd add .name method for introspecting it.
  • Loading branch information
jnthn committed Oct 31, 2010
1 parent 3c4309f commit b76e080
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions common/NQP/NQPSetting.pm
Expand Up @@ -311,15 +311,16 @@ knowhow NQPClassHOW {
##

# Creates a new instance of this meta-class.
method new() {
nqp::instance_of(self).BUILD()
method new(:$name) {
nqp::instance_of(self).BUILD(:name($name))
}

method CREATE($obj) {
nqp::instance_of($obj)
}

method BUILD() {
method BUILD(:$name) {
$!name := $name;
$!composed := 0;
%!methods := NQPHash.new;
@!attributes := NQPArray.new;
Expand All @@ -331,8 +332,8 @@ knowhow NQPClassHOW {
# to go with it, and return that.
# XXX TODO :$repr named parameter defaulting to P6opaque (don't
# have default values yet implemented).
method new_type() {
my $metaclass := self.new();
method new_type(:$name = '<anon>', :$repr = 'P6opaque') {
my $metaclass := self.new(:name($name));
nqp::type_object_for($metaclass, 'P6opaque');
}

Expand Down Expand Up @@ -421,6 +422,10 @@ knowhow NQPClassHOW {
%!methods
}

method name($obj) {
$!name
}

method parents($obj, :$local!) {
@!parents
}
Expand Down

0 comments on commit b76e080

Please sign in to comment.