Name

SPVM::Byte - A byte Value as An Object

Description

Byte class in SPVM represents a byte value as an object.

Usage

my $byte_object = Byte->new(5);
my $byte_value = $byte_object->value;
$byte_object->set_value(10);

# New unsigned object
my $unsigned_byte = Byte->new_unsigned(255);

Details

This class is automatically loaded.

Interfaces

Fields

value

has value : rw byte;

The value.

If the "unsigned" field is 1, the value is treated as an unsigned 8-bit integer (0 to 255).

If the "is_read_only" field is 1, a compilation error or a runtime error occurs when setting the value.

is_read_only

has is_read_only : ro byte;

If this value is 1, the "value" field is read-only.

unsigned

has unsigned : rw byte;

If this value is 1, the value is treated as an unsigned 8-bit integer.

Class Methods

new

static method new : Byte ($value : int);

Creates a new Byte object with a byte $value. The "unsigned" field is initialized to 0.

new_unsigned

static method new_unsigned : Byte ($value : int);

Creates a new Byte object with a byte $value. The "unsigned" field is initialized to 1.

Instance Methods

make_read_only

method make_read_only : void ();

Sets "is_read_only" field to 1.

clone

method clone : Byte ();

Creates a new Byte object that clones this object.

The "unsigned" field is copied to the new object.

The value of "is_read_only" field in the new object is 0.

to_string

method to_string : string ();

Casts the value to string type and returns it.

If "unsigned" field is 1, the value is converted to a string as an unsigned 8-bit integer.

Copyright & License

Copyright (c) 2023 Yuki Kimoto

MIT License