File Coverage

lib/SIRTX/VM/Register.pm
Criterion Covered Total %
statement 17 32 53.1
branch 0 4 0.0
condition n/a
subroutine 6 12 50.0
pod 5 5 100.0
total 28 53 52.8


line stmt bran cond sub pod time code
1             # Copyright (c) 2024-2025 Philipp Schafft
2              
3             # licensed under Artistic License 2.0 (see LICENSE file)
4              
5             # ABSTRACT: module for interacting with SIRTX VM code
6              
7              
8             package SIRTX::VM::Register;
9              
10 1     1   1496 use v5.16;
  1         4  
11 1     1   5 use strict;
  1         3  
  1         20  
12 1     1   3 use warnings;
  1         1  
  1         36  
13              
14 1     1   4 use Carp;
  1         1  
  1         55  
15              
16 1     1   4 use parent 'Data::Identifier::Interface::Userdata';
  1         1  
  1         5  
17              
18             our $VERSION = v0.12;
19              
20             use constant {
21 1         356 TYPE_USER => 'user',
22             TYPE_SYSTEM => 'system',
23              
24             OWNER_MINE => 'mine',
25             OWNER_YOURS => 'yours',
26             OWNER_THEIRS => 'theirs',
27              
28             TEMPERATURE_HOT => 'hot',
29             TEMPERATURE_COLD => 'cold',
30             TEMPERATURE_LUKEWARM => 'lukewarm',
31 1     1   109 };
  1         2  
32              
33              
34             sub physical {
35 0     0 1   my ($self) = @_;
36 0           return $self->{physical};
37             }
38              
39              
40             sub name {
41 0     0 1   my ($self) = @_;
42 0           return $self->{name};
43             }
44              
45              
46             sub owner {
47 0     0 1   my ($self, $n) = @_;
48 0 0         $self->{owner} = $n if defined $n;
49 0           return $self->{owner};
50             }
51              
52              
53             sub temperature {
54 0     0 1   my ($self, $n) = @_;
55 0 0         $self->{temperature} = $n if defined $n;
56 0           return $self->{temperature};
57             }
58              
59              
60             sub clone {
61 0     0 1   my ($self) = @_;
62 0           return __PACKAGE__->_new(%{$self});
  0            
63             }
64              
65             # ---- Private helpers ----
66              
67             sub _new {
68 0     0     my ($pkg, %opts) = @_;
69 0           my $self = bless {
70             owner => OWNER_MINE,
71             temperature => TEMPERATURE_LUKEWARM,
72             %opts,
73             }, $pkg;
74             }
75              
76             # ---- Docs for constants ----
77              
78              
79             1;
80              
81             __END__