This repository has been archived by the owner on Feb 3, 2021. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Add an NQPModuleHOW.
- Loading branch information
Showing
2 changed files
with
45 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| knowhow NQPModuleHOW { | ||
| has $!name; | ||
| has $!composed; | ||
|
|
||
| method new(:$name) { | ||
| my $obj := pir::repr_instance_of__PP(self); | ||
| $obj.BUILD(:name($name)); | ||
| $obj | ||
| } | ||
|
|
||
| method BUILD(:$name) { | ||
| $!name := $name; | ||
| } | ||
|
|
||
| # Create a new meta-class instance, and then a new type object | ||
| # to go with it, and return that. | ||
| method new_type(:$name = '<anon>', :$repr = 'P6opaque') { | ||
| my $metaclass := self.new(:name($name)); | ||
| pir::repr_type_object_for__PPS($metaclass, $repr); | ||
| } | ||
|
|
||
| method add_method($obj, $name, $code_obj) { | ||
| # XXX Commented out as in some places, module is used to try to | ||
| # shove methods into Parrot classes (which doesn't work any, mind). | ||
| #pir::die("Modules may not have methods"); | ||
| } | ||
|
|
||
| method add_multi_method($obj, $name, $code_obj) { | ||
| pir::die("Modules may not have methods"); | ||
| } | ||
|
|
||
| method add_attribute($obj, $meta_attr) { | ||
| pir::die("Modules may not have attributes"); | ||
| } | ||
|
|
||
| method compose($obj) { | ||
| $!composed := 1; | ||
| } | ||
|
|
||
| method name($obj) { | ||
| $!name | ||
| } | ||
| } |