diff --git a/src/CSharpBackend.pm b/src/CSharpBackend.pm index b7bce085..4c3dae38 100644 --- a/src/CSharpBackend.pm +++ b/src/CSharpBackend.pm @@ -404,6 +404,11 @@ sub sub2 { push @thaw, CgOp::rawsset($si, CgOp::rawnew($si_ty, @{ $node->{sictor} })); + if ($_->class ne 'Sub') { + my $cl = $unit->deref($unit->get_stash(@{ $_->find_lex_pkg($_->class) })->obj); + push @thaw, CgOp::setfield('mo', CgOp::rawsget($si), CgOp::rawsget($cl->{peer}{mo})); + } + my $pp = $node->{pp}; if ($pp) { push @thaw, CgOp::rawsset($pp, CgOp::rawnew('Frame', diff --git a/src/Metamodel.pm b/src/Metamodel.pm index 7627208c..7c2dda39 100644 --- a/src/Metamodel.pm +++ b/src/Metamodel.pm @@ -173,6 +173,17 @@ our $unit; __PACKAGE__->meta->make_immutable; } +{ + package Metamodel::Grammar; + use Moose; + extends 'Metamodel::Class'; + + sub _defsuper { 'Grammar' } + + no Moose; + __PACKAGE__->meta->make_immutable; +} + { package Metamodel::Method; use Moose; diff --git a/test.pl b/test.pl index ebd569a6..a185e02b 100644 --- a/test.pl +++ b/test.pl @@ -2,7 +2,7 @@ use Test; -plan 539; +plan 534; ok 1, "one is true"; ok 2, "two is also true"; @@ -63,16 +63,6 @@ ok $a == 55, "looping works"; } -{ - my $x; - INIT { - $x = 1; - } - ok $x, "changes made in the protolexpad are visible at runtime"; -} - -ok INIT { 1 }, "init blocks can return values"; - { sub foo() { 42 } ok (foo) == 42, "can call argless function without parens"; @@ -228,13 +218,6 @@ ok $g() == 0, "different clones have different state vars"; } -{ - my $x; - my $unclonable-sub = INIT { sub () { $x } }; - $x = 42; - ok $unclonable-sub() == 42, "mainlines are not cloned"; -} - { my class A { } my class B is A { } @@ -449,9 +432,6 @@ EOC } -is $?FILE, 'test.pl', '$?FILE works'; -is $?ORIG.substr(0,5), '# vim', '$?ORIG works'; - { my @x; diff --git a/test2.pl b/test2.pl index ee011c7c..55debc56 100644 --- a/test2.pl +++ b/test2.pl @@ -1,5 +1,25 @@ # vim: ft=perl6 use Test; +{ + my $x; + INIT { + $x = 1; + } + ok $x, "changes made in the protolexpad are visible at runtime"; +} + +ok INIT { 1 }, "init blocks can return values"; + +{ + my $x; + my $unclonable-sub = INIT { sub () { $x } }; + $x = 42; + ok $unclonable-sub() == 42, "mainlines are not cloned"; +} + +is $?FILE, 'test.pl', '$?FILE works'; +is $?ORIG.substr(0,5), '# vim', '$?ORIG works'; + done-testing;