1. my constant $?COMPILATION-ID :=
  2. 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 = Str,
  14. --> Nil
  15. ) {
  16. $!name = 'moar';
  17. $!auth = "The MoarVM Team";
  18. $!version = Version.new($!config<version> // "unknown");
  19. $!prefix = $!config<prefix>;
  20. $!precomp-ext = "moarvm";
  21. $!precomp-target = "mbc";
  22. # add new backends here please
  23. }
  24. method platform-library-name(IO::Path $library, Version :$version) {
  25. my int $is-win = Rakudo::Internals.IS-WIN;
  26. my int $is-darwin = self.osname eq 'darwin';
  27. my $basename = $library.basename;
  28. my int $full-path = $library ne $basename;
  29. my $dirname = $library.dirname;
  30. # OS X needs version before extension
  31. $basename ~= ".$version" if $is-darwin && $version.defined;
  32. my $dll = self.config<dll>;
  33. my $platform-name = sprintf($dll, $basename);
  34. $platform-name ~= '.' ~ $version
  35. if $version.defined and nqp::iseq_i(nqp::add_i($is-darwin,$is-win),0);
  36. $full-path
  37. ?? $dirname.IO.add($platform-name).absolute
  38. !! $platform-name.IO
  39. }
  40. proto method osname(|) { * }
  41. multi method osname(VM:U:) {
  42. nqp::lc(nqp::atkey(nqp::backendconfig,'osname'))
  43. }
  44. multi method osname(VM:D:) {
  45. nqp::lc($!config<osname>)
  46. }
  47. }
  48. sub INITIALIZE-A-VM-NOW() {
  49. my $desc := DateTime.now.Str;
  50. VM.new(:config(nqp::backendconfig),:$desc);
  51. }
  52. Rakudo::Internals.REGISTER-DYNAMIC: '$*VM', {
  53. PROCESS::<$VM> := INITIALIZE-A-VM-NOW();
  54. }