Skip to content

Commit a3d104e

Browse files
committed
Twiddle to make roles work again. Kinda defers a tricky problem for later, mind...
1 parent 00ec5f3 commit a3d104e

File tree

2 files changed

+19
-7
lines changed

2 files changed

+19
-7
lines changed

src/NQP/Actions.pm

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -442,7 +442,16 @@ method package_def($/) {
442442
$past.blocktype('declaration');
443443
$past.unshift(PAST::Var.new( :name('$?CLASS'), :scope('parameter') ));
444444
$past.symbol('$?CLASS', :scope('lexical'));
445-
$*PACKAGE-SETUP[0][0][1].push(PAST::Val.new( :value($past), :named('body_block') ));
445+
$*PACKAGE-SETUP.push(PAST::Op.new(
446+
:pasttype('callmethod'), :name('set_body_block'),
447+
PAST::Op.new(
448+
# XXX nqpop get_how
449+
:pirop('get_how PP'),
450+
PAST::Var.new( :name('type_obj'), :scope('register') )
451+
),
452+
PAST::Var.new( :name('type_obj'), :scope('register') ),
453+
PAST::Val.new( :value($past) )
454+
));
446455
}
447456
else {
448457
$past.blocktype('immediate');

src/metamodel/how/NQPParametricRoleHOW.pm

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,23 +32,26 @@ knowhow NQPParametricRoleHOW {
3232
##
3333

3434
# Creates a new instance of this meta-class.
35-
method new(:$name!, :$body_block!) {
35+
method new(:$name!) {
3636
my $obj := pir::repr_instance_of__PP(self);
37-
$obj.BUILD(:name($name), :body_block($body_block));
37+
$obj.BUILD(:name($name));
3838
$obj
3939
}
4040

41-
method BUILD(:$name!, :$body_block!) {
41+
method BUILD(:$name!) {
4242
$!name := $name;
43-
$!body_block := $body_block;
4443
}
4544

4645
# Create a new meta-class instance, and then a new type object
4746
# to go with it, and return that.
48-
method new_type(:$body_block!, :$name = '<anon>', :$repr = 'P6opaque') {
49-
my $metarole := self.new(:name($name), :body_block($body_block));
47+
method new_type(:$name = '<anon>', :$repr = 'P6opaque') {
48+
my $metarole := self.new(:name($name));
5049
pir::repr_type_object_for__PPS($metarole, $repr);
5150
}
51+
52+
method set_body_block($obj, $body_block) {
53+
$!body_block := $body_block;
54+
}
5255

5356
method add_method($obj, $name, $code_obj) {
5457
if %!methods{$name} {

0 commit comments

Comments
 (0)