Phasor 3.1.1
Stack VM based Programming Language
Loading...
Searching...
No Matches
phasor.Value.Value Class Reference

Public Member Functions

"Value" null (cls)
"Value" from_bool (cls, bool v)
"Value" from_int (cls, int v)
"Value" from_float (cls, float v)
"Value" from_string (cls, str v)
bool as_bool (self)
int as_int (self)
float as_float (self)
str as_string (self)
str __repr__ (self)
bool __eq__ (self, object other)

Public Attributes

_Payload type = ValueType.Null:

Static Protected Attributes

_Payload _data = None

Detailed Description

A typed constant-pool entry.

Use the class-method constructors rather than setting ``type`` /
``_data`` directly::

    Value.null()
    Value.from_bool(True)
    Value.from_int(42)
    Value.from_float(3.14)
    Value.from_string("hello")

Definition at line 26 of file Value.py.

Member Function Documentation

◆ __eq__()

bool phasor.Value.Value.__eq__ ( self,
object other )
Return ``True`` if *other* is a :class:`Value` with identical type and payload.

Definition at line 98 of file Value.py.

◆ __repr__()

str phasor.Value.Value.__repr__ ( self)
Return a concise debug representation showing the type and payload.

Definition at line 92 of file Value.py.

◆ as_bool()

bool phasor.Value.Value.as_bool ( self)
Return the payload as a Python ``bool``, raising ``TypeError`` if the type is not Bool.

Definition at line 68 of file Value.py.

◆ as_float()

float phasor.Value.Value.as_float ( self)
Return the payload as a Python ``float``, raising ``TypeError`` if the type is not Float.

Definition at line 80 of file Value.py.

◆ as_int()

int phasor.Value.Value.as_int ( self)
Return the payload as a Python ``int``, raising ``TypeError`` if the type is not Int.

Definition at line 74 of file Value.py.

◆ as_string()

str phasor.Value.Value.as_string ( self)
Return the payload as a Python ``str``, raising ``TypeError`` if the type is not String.

Definition at line 86 of file Value.py.

◆ from_bool()

"Value" phasor.Value.Value.from_bool ( cls,
bool v )
Return a new Bool-typed value wrapping *v*.

Definition at line 49 of file Value.py.

◆ from_float()

"Value" phasor.Value.Value.from_float ( cls,
float v )
Return a new Float-typed value wrapping *v*.

Definition at line 59 of file Value.py.

◆ from_int()

"Value" phasor.Value.Value.from_int ( cls,
int v )
Return a new Int-typed value wrapping *v*.

Definition at line 54 of file Value.py.

◆ from_string()

"Value" phasor.Value.Value.from_string ( cls,
str v )
Return a new String-typed value wrapping *v*.

Definition at line 64 of file Value.py.

◆ null()

"Value" phasor.Value.Value.null ( cls)
Return a new Null-typed value.

Definition at line 44 of file Value.py.

Member Data Documentation

◆ _data

phasor.Value.Value._data = None
staticprotected

Definition at line 41 of file Value.py.

◆ type

_Payload phasor.Value.Value.type = ValueType.Null:

Definition at line 94 of file Value.py.


The documentation for this class was generated from the following file: