| 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 | use v5.16; | ||
| 11 | use strict; | ||
| 12 | use warnings; | ||
| 13 | |||
| 14 | use Carp; | ||
| 15 | |||
| 16 | use parent 'Data::Identifier::Interface::Userdata'; | ||
| 17 | |||
| 18 | our $VERSION = v0.12; | ||
| 19 | |||
| 20 | use constant { | ||
| 21 | 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 | }; | ||
| 32 | |||
| 33 | |||
| 34 | sub physical { | ||
| 35 | my ($self) = @_; | ||
| 36 | return $self->{physical}; | ||
| 37 | } | ||
| 38 | |||
| 39 | |||
| 40 | sub name { | ||
| 41 | my ($self) = @_; | ||
| 42 | return $self->{name}; | ||
| 43 | } | ||
| 44 | |||
| 45 | |||
| 46 | sub owner { | ||
| 47 | my ($self, $n) = @_; | ||
| 48 | $self->{owner} = $n if defined $n; | ||
| 49 | return $self->{owner}; | ||
| 50 | } | ||
| 51 | |||
| 52 | |||
| 53 | sub temperature { | ||
| 54 | my ($self, $n) = @_; | ||
| 55 | $self->{temperature} = $n if defined $n; | ||
| 56 | return $self->{temperature}; | ||
| 57 | } | ||
| 58 | |||
| 59 | |||
| 60 | sub clone { | ||
| 61 | my ($self) = @_; | ||
| 62 | return __PACKAGE__->_new(%{$self}); | ||
| 63 | } | ||
| 64 | |||
| 65 | # ---- Private helpers ---- | ||
| 66 | |||
| 67 | sub _new { | ||
| 68 | my ($pkg, %opts) = @_; | ||
| 69 | 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__ |