Permalink
Browse files

[common] Allow NQPClassHOW to take and store the name of the class, a…

…nd add .name method for introspecting it.
  • Loading branch information...
jnthn committed Oct 31, 2010
1 parent 3c4309f commit b76e0809b9f574798fe1e8f40db1fa43c56a94fb
Showing with 10 additions and 5 deletions.
  1. +10 −5 common/NQP/NQPSetting.pm
View
@@ -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;
@@ -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');
}
@@ -421,6 +422,10 @@ knowhow NQPClassHOW {
%!methods
}
+ method name($obj) {
+ $!name
+ }
+
method parents($obj, :$local!) {
@!parents
}

0 comments on commit b76e080

Please sign in to comment.