This feels like you’re getting into the bleeding edges of MOP.  My 
understanding is that a MVMContext is purely a runtime thing.  Not sure how it 
comes to be that the MVMContext needs serializing, but that error message 
indicates that the VM is not ready to do that.

So my guess is that somehow during compilation, the MVMContext gets added to 
the SC (Serialization Context) when it shouldn’t.

Most likely Timo Paulssen or Jonathan Worthington can give you better answers.

> On 26 Dec 2018, at 04:26, Vadim Belman <vr...@lflat.org> wrote:
> 
> Hi!
> 
> By playing with slangs I stumbled upon pretty confusing issue. I have a 
> module with a test slang which looks like this:
> 
>      class My::Metamodel::MyHOW is Metamodel::ClassHOW {
>          method compose (|) {
>              note "My compose";
>              nextsame;
>          }
>      }
> 
>      sub EXPORT {
>          use nqp;
>          use NQPHLL:from<NQP>;
> 
>          my role MySlang {
>              token package_declarator:sym<myclass> {
>                  :my $*OUTERPACKAGE := self.package;
>                  :my $*PKGDECL := 'myclass';
>                  :my $*LINE_NO := HLL::Compiler.lineof(self.orig(), 
> self.from(), :cache(1));
>                  <sym><.kok>
>                  <package_def>
>                  <.set_braid_from(self)>
>              }
>          }
> 
>          my role MyActions {
>              method package_declarator:sym<myclass>(Mu $/) {
>                  $/.make( nqp::atkey(nqp::findmethod($/, 'hash')($/), 
> 'package_def').ast );
>              }
>          }
>          $ = $*LANG.refine_slang( 'MAIN', MySlang, MyActions );
>          $*LANG.set_how('myclass', My::Metamodel::MyHOW);
>          {}
>      }
> 
> And when it's used in a script:
> 
>      use lib '.';
>      use myslang;
> 
>      myclass My {
>          method foo { say "!foo" }
>      }
> 
>      My.new.foo;
> 
> everything works as expected, I get this output:
> 
>     My compose
>     !foo
> 
> Then I define a module smodule.pm6:
> 
>      use myslang;
> 
>      myclass Foo {
>      }
> 
> And load it dynamically with 'require':
> 
>     require ::('smodule');
> 
> only to get this:
> 
>     My compose
>     ===SORRY!===
>     Missing serialize REPR function for REPR MVMContext (BOOTContext)
> 
> Now I wonder if it's a bug or I'm missing a thing or two in what I'm doing? 
> So far, basic guidelines of adding a new package type were taken from 
> World.nqp add_package_declarator method which does some extra work some of 
> which is clearly not needed in my case; and some perhaps necessary but I 
> don't understand it yet.
> 
> Best regards,
> Vadim Belman
> 

Reply via email to