Skip to content

Instantly share code, notes, and snippets.

@ugexe

ugexe/mod.pm6 Secret

Created May 27, 2015 18:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ugexe/a9463c3ec6a1ae257ed2 to your computer and use it in GitHub Desktop.
Save ugexe/a9463c3ec6a1ae257ed2 to your computer and use it in GitHub Desktop.
use MONKEY-TYPING;
augment class IO::Path {
method blah { say "..." }
}
nickl@localhost:~/perl6/zef$ perl6 test.pl6
CompUnit.new(from => "Perl6", name => "mod", extension => "pm6", precomp-ext => "moarvm", path => q|/home/nickl/perl6/zef/mod.pm6|.IO(:SPEC(IO::Spec::Unix)), has-source => Bool::True, has-precomp => Bool::False, is-loaded => Bool::False)
-------
True
CompUnit.new(from => "Perl6", name => "mod", extension => "pm6", precomp-ext => "moarvm", path => q|/home/nickl/perl6/zef/mod.pm6|.IO(:SPEC(IO::Spec::Unix)), has-source => Bool::True, has-precomp => Bool::False, is-loaded => Bool::False)
----
use lib '.';
use mod;
class CompUnit2 is CompUnit {
has $!path;
has $!has-precomp;
has $.precomp-path;
has $.build-output is rw;
method precomp($out, |c) {
$!precomp-path = $out //= self.precomp-path // "{$!path}.{$*VM.precomp-ext}";
nextwith($!precomp-path, |c)
}
}
my $in = "mod.pm6";
my $out = "mod.pm6.moarvm";
my $cu = CompUnit2.new($in.IO.absolute);
say $cu.perl;
say "-------";
say $cu.precomp($out);
say $cu.perl;
say "----";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment