1. my constant $?COMPILATION-ID :=
  2. nqp::p6box_s(nqp::sha1(nqp::concat(
  3. $*W.handle,
  4. nqp::getcomp('perl6').compilation-id
  5. )));
  6. class VM does Systemic {
  7. has $.config;
  8. has $.prefix;
  9. has $.precomp-ext;
  10. has $.precomp-target;
  11. submethod BUILD(
  12. :$!config,
  13. :$desc,
  14. --> Nil
  15. ) {
  16. $!name = 'moar';
  17. $!desc = $desc // 'Short for "Metamodel On A Runtime", MoarVM is a modern virtual machine built for the Rakudo Perl 6 compiler and the NQP Compiler Toolchain.';
  18. $!auth = "The MoarVM Team";
  19. $!version = Version.new($!config<version> // "unknown");
  20. $!prefix = $!config<prefix>;
  21. $!precomp-ext = "moarvm";
  22. $!precomp-target = "mbc";
  23. # add new backends here please
  24. }
  25. method platform-library-name(IO::Path $library, Version :$version) {
  26. my int $is-win = Rakudo::Internals.IS-WIN;
  27. my int $is-darwin = self.osname eq 'darwin';
  28. my $basename = $library.basename;
  29. my int $full-path = $library ne $basename;
  30. my $dirname = $library.dirname;
  31. # OS X needs version before extension
  32. $basename ~= ".$version" if $is-darwin && $version.defined;
  33. my $dll = self.config<dll>;
  34. my $platform-name = sprintf($dll, $basename);
  35. $platform-name ~= '.' ~ $version
  36. if $version.defined and nqp::iseq_i(nqp::add_i($is-darwin,$is-win),0);
  37. $full-path
  38. ?? $dirname.IO.add($platform-name).absolute
  39. !! $platform-name.IO
  40. }
  41. proto method osname(|) {*}
  42. multi method osname(VM:U:) {
  43. nqp::lc(nqp::atkey(nqp::backendconfig,'osname'))
  44. }
  45. multi method osname(VM:D:) {
  46. nqp::lc($!config<osname>)
  47. }
  48. }
  49. sub INITIALIZE-A-VM-NOW() {
  50. VM.new(:config(nqp::backendconfig));
  51. }
  52. Rakudo::Internals.REGISTER-DYNAMIC: '$*VM', {
  53. PROCESS::<$VM> := INITIALIZE-A-VM-NOW();
  54. }