Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Make Distro/Kernel/VM use Application role
  • Loading branch information
lizmat committed May 13, 2014
1 parent 100730c commit 55ab8aa
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 47 deletions.
32 changes: 22 additions & 10 deletions src/core/Distro.pm
Expand Up @@ -3,21 +3,33 @@
# If you find errors for your hardware or OS distribution, please report them
# with the values that you expected and how to get them in your situation.

class Distro {
has $.name;
has $.ver;
has $.is-win;
class Distro does Application{
has Bool $.is-win;
has Str $.release;

submethod BUILD (:$!name, :$!ver) {
$!ver = "unknown" if $!name eq $!ver;
submethod BUILD (:$name, :$version) {
$!name = $name.lc;
$!auth = "unknown";
$!version = Version.new($version);
$!is-win = so $!name eq any <MSWin32 mingw msys cygwin>;
}
method gist { $!name ~ (" ($!ver)" if $!ver ne "unknown") }
method Str { $!name }

method release {
$!release //= do {
given $*DISTRO.name {
when any <linux darwin> { # needs adapting
qx/uname -r/.chomp;
}
default {
"unknown";
}
}
}
}
}

PROCESS::<$DISTRO> = Distro.new( :name($*OS), :ver($*OSVER) );
PROCESS::<$DISTRO> = Distro.new( :name($*OS), :version($*OSVER) );
$*OS = Deprecation.obsolete(
:name('$*OS'), :value($*OS), :instead('$*DISTRO.name') );
$*OSVER = Deprecation.obsolete(
:name('$*OSVER'), :value($*OSVER), :instead('$*DISTRO.ver') );
:name('$*OSVER'), :value($*OSVER), :instead('$*DISTRO.version') );
25 changes: 4 additions & 21 deletions src/core/Kernel.pm
Expand Up @@ -3,16 +3,12 @@
# If you find errors for your hardware or OS distribution, please report them
# with the values that you expected and how to get them in your situation.

class Kernel {
has $!name;
has $!ver;
has $!release;
class Kernel does Application {
has $!hardware;
has $!arch;
has $!bits;

method gist { $.name ~ (" ($!ver)" if $.ver ne "unknown") }
method Str { $.name }
submethod BUILD (:$!auth = "unknown") {}

method name {
$!name //= do {
Expand All @@ -27,8 +23,8 @@ class Kernel {
}
}

method ver {
$!ver //= do {
method version {
$!version //= do {
given $*DISTRO.name.lc {
when any <linux darwin> { # needs adapting
qx/uname -v/.chomp;
Expand All @@ -40,19 +36,6 @@ class Kernel {
}
}

method release {
$!release //= do {
given $*DISTRO.name.lc {
when any <linux darwin> { # needs adapting
qx/uname -r/.chomp;
}
default {
"unknown";
}
}
}
}

method hardware {
$!hardware //= do {
given $*DISTRO.name.lc {
Expand Down
10 changes: 3 additions & 7 deletions src/core/VM.pm
@@ -1,14 +1,10 @@
class VM {
has $.name;
has $.ver;
class VM does Application {
has $.config;

submethod BUILD (:$!name, :$!config) {
$!ver = $!config<version> // "unknown";
$!auth = "unknown";
$!version = Version.new($!config<version> // "unknown");
}
method gist { $!name ~ (" ($!ver)" if $!ver ne "unknown") }
method Str { $!name }

}

multi postcircumfix:<{ }> (VM $d, "name" ) {
Expand Down
7 changes: 4 additions & 3 deletions tools/build/Makefile-JVM.in
Expand Up @@ -152,9 +152,10 @@ J_CORE_SOURCES = \
src/core/precedence.pm \
src/core/terms.pm \
src/core/Deprecations.pm \
src/core/distro.pm \
src/core/vm.pm \
src/core/kernel.pm \
src/core/Application.pm \
src/core/Distro.pm \
src/core/VM.pm \
src/core/Kernel.pm \
src/core/Thread.pm \
src/core/Lock.pm \
src/core/Semaphore.pm \
Expand Down
7 changes: 4 additions & 3 deletions tools/build/Makefile-Moar.in
Expand Up @@ -167,9 +167,10 @@ M_CORE_SOURCES = \
src/core/SupplyOperations.pm \
src/core/asyncops.pm \
src/core/signals.pm \
src/core/distro.pm \
src/core/vm.pm \
src/core/kernel.pm \
src/core/Application.pm \
src/core/Distro.pm \
src/core/Kernel.pm \
src/core/VM.pm \
src/core/IO/Socket.pm \
src/core/IO/Socket/INET.pm \
src/core/IO/Socket/Async.pm \
Expand Down
7 changes: 4 additions & 3 deletions tools/build/Makefile-Parrot.in
Expand Up @@ -237,9 +237,10 @@ P_CORE_SOURCES = \
src/core/precedence.pm \
src/core/terms.pm \
src/core/Deprecations.pm \
src/core/distro.pm \
src/core/vm.pm \
src/core/kernel.pm \
src/core/Application.pm \
src/core/Distro.pm \
src/core/VM.pm \
src/core/Kernel.pm \
src/core/OS.pm \
src/core/core_epilogue.pm \

Expand Down

0 comments on commit 55ab8aa

Please sign in to comment.