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.
Add NQPNativeHOW meta-object for native types and native package decl…
…arator to go with it.
- Loading branch information
Showing
4 changed files
with
48 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
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,38 @@ | ||
knowhow NQPNativeHOW { | ||
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. | ||
# XXX Should check that this is an inlineable REPR. | ||
method new_type(:$name = '<anon>', :$repr!) { | ||
my $metaclass := self.new(:name($name)); | ||
pir::repr_type_object_for__PPS($metaclass, $repr); | ||
} | ||
|
||
method add_method($obj, $name, $code_obj) { | ||
pir::die("Native types may not have methods (must be boxed to call method)"); | ||
} | ||
|
||
method add_multi_method($obj, $name, $code_obj) { | ||
pir::die("Native types may not have methods (must be boxed to call method)"); | ||
} | ||
|
||
method add_attribute($obj, $meta_attr) { | ||
pir::die("Native types may not have attributes"); | ||
} | ||
|
||
method compose($obj) { | ||
$!composed := 1; | ||
} | ||
} |