Trait yksom::vm::objects::Obj[][src]

pub trait Obj: Debug + Send {
Show methods fn dyn_objtype(self: Gc<Self>) -> ObjType
    where
        Self: Send
;
fn get_class(self: Gc<Self>, vm: &mut VM) -> Val
    where
        Self: Send
; fn to_array(self: Gc<Self>) -> Result<Gc<dyn Array>, Box<VMError>>
    where
        Self: Send
, { ... }
fn to_strval(self: Gc<Self>, _: &mut VM) -> Result<Val, Box<VMError>>
    where
        Self: Send
, { ... }
fn num_inst_vars(self: Gc<Self>, _: &VM) -> usize
    where
        Self: Send
, { ... }
fn inst_var_at(
        self: Gc<Self>,
        vm: &VM,
        i: usize
    ) -> Result<Val, Box<VMError>>
    where
        Self: Send
, { ... }
fn inst_var_at_put(
        self: Gc<Self>,
        vm: &VM,
        i: usize,
        v: Val
    ) -> Result<(), Box<VMError>>
    where
        Self: Send
, { ... }
unsafe fn unchecked_inst_var_get(self: Gc<Self>, _: &VM, _: usize) -> Val
    where
        Self: Send
, { ... }
unsafe fn unchecked_inst_var_set(self: Gc<Self>, _: &VM, _: usize, _: Val)
    where
        Self: Send
, { ... }
fn length(self: Gc<Self>) -> usize
    where
        Self: Send
, { ... }
fn hashcode(self: Gc<Self>) -> u64
    where
        Self: Send
, { ... }
fn add(self: Gc<Self>, _: &mut VM, _: Val) -> Result<Val, Box<VMError>>
    where
        Self: Send
, { ... }
fn and(self: Gc<Self>, _: &mut VM, _: Val) -> Result<Val, Box<VMError>>
    where
        Self: Send
, { ... }
fn div(self: Gc<Self>, _: &mut VM, _: Val) -> Result<Val, Box<VMError>>
    where
        Self: Send
, { ... }
fn double_div(
        self: Gc<Self>,
        _: &mut VM,
        _: Val
    ) -> Result<Val, Box<VMError>>
    where
        Self: Send
, { ... }
fn modulus(self: Gc<Self>, _: &mut VM, _: Val) -> Result<Val, Box<VMError>>
    where
        Self: Send
, { ... }
fn mul(self: Gc<Self>, _: &mut VM, _: Val) -> Result<Val, Box<VMError>>
    where
        Self: Send
, { ... }
fn remainder(
        self: Gc<Self>,
        _: &mut VM,
        _: Val
    ) -> Result<Val, Box<VMError>>
    where
        Self: Send
, { ... }
fn shl(self: Gc<Self>, _: &mut VM, _: Val) -> Result<Val, Box<VMError>>
    where
        Self: Send
, { ... }
fn shr(self: Gc<Self>, _: &mut VM, _: Val) -> Result<Val, Box<VMError>>
    where
        Self: Send
, { ... }
fn sqrt(self: Gc<Self>, _: &mut VM) -> Result<Val, Box<VMError>>
    where
        Self: Send
, { ... }
fn sub(self: Gc<Self>, _: &mut VM, _: Val) -> Result<Val, Box<VMError>>
    where
        Self: Send
, { ... }
fn xor(self: Gc<Self>, _: &mut VM, _: Val) -> Result<Val, Box<VMError>>
    where
        Self: Send
, { ... }
fn ref_equals(
        self: Gc<Self>,
        vm: &mut VM,
        other: Val
    ) -> Result<Val, Box<VMError>>
    where
        Self: Send
, { ... }
fn equals(self: Gc<Self>, _: &mut VM, _: Val) -> Result<Val, Box<VMError>>
    where
        Self: Send
, { ... }
fn not_equals(
        self: Gc<Self>,
        _: &mut VM,
        _: Val
    ) -> Result<Val, Box<VMError>>
    where
        Self: Send
, { ... }
fn greater_than(
        self: Gc<Self>,
        _: &mut VM,
        _: Val
    ) -> Result<Val, Box<VMError>>
    where
        Self: Send
, { ... }
fn greater_than_equals(
        self: Gc<Self>,
        _: &mut VM,
        _: Val
    ) -> Result<Val, Box<VMError>>
    where
        Self: Send
, { ... }
fn less_than(
        self: Gc<Self>,
        _: &mut VM,
        _: Val
    ) -> Result<Val, Box<VMError>>
    where
        Self: Send
, { ... }
fn less_than_equals(
        self: Gc<Self>,
        _: &mut VM,
        _: Val
    ) -> Result<Val, Box<VMError>>
    where
        Self: Send
, { ... }
}

The main SOM Object trait. Notice that code should almost never call these functions directly: you should instead call the equivalent function in the Val struct.

Required methods

fn dyn_objtype(self: Gc<Self>) -> ObjType where
    Self: Send
[src]

What ObjType does this Val represent?

fn get_class(self: Gc<Self>, vm: &mut VM) -> Val where
    Self: Send
[src]

What class is this object an instance of?

Loading content...

Provided methods

fn to_array(self: Gc<Self>) -> Result<Gc<dyn Array>, Box<VMError>> where
    Self: Send
[src]

If (and only if) this object implements the Array trait then return a reference to this object as an Array trait object.

fn to_strval(self: Gc<Self>, _: &mut VM) -> Result<Val, Box<VMError>> where
    Self: Send
[src]

Convert this object to a Val that represents a SOM string.

fn num_inst_vars(self: Gc<Self>, _: &VM) -> usize where
    Self: Send
[src]

How many instance variables does this object contain?

fn inst_var_at(self: Gc<Self>, vm: &VM, i: usize) -> Result<Val, Box<VMError>> where
    Self: Send
[src]

Return the instance variable at i (using SOM indexing).

fn inst_var_at_put(
    self: Gc<Self>,
    vm: &VM,
    i: usize,
    v: Val
) -> Result<(), Box<VMError>> where
    Self: Send
[src]

Return the instance variable at i (using SOM indexing).

unsafe fn unchecked_inst_var_get(self: Gc<Self>, _: &VM, _: usize) -> Val where
    Self: Send
[src]

Lookup an instance variable in this object. If usize exceeds the number of instance variables this will lead to undefined behaviour.

unsafe fn unchecked_inst_var_set(self: Gc<Self>, _: &VM, _: usize, _: Val) where
    Self: Send
[src]

Set an instance variable in this object. If usize exceeds the number of instance variables this will lead to undefined behaviour.

fn length(self: Gc<Self>) -> usize where
    Self: Send
[src]

What is this object’s length?

fn hashcode(self: Gc<Self>) -> u64 where
    Self: Send
[src]

What is this object’s hashcode?

fn add(self: Gc<Self>, _: &mut VM, _: Val) -> Result<Val, Box<VMError>> where
    Self: Send
[src]

Produce a new Val which adds other to this.

fn and(self: Gc<Self>, _: &mut VM, _: Val) -> Result<Val, Box<VMError>> where
    Self: Send
[src]

Produce a new Val which performs a bitwise and with other and this.

fn div(self: Gc<Self>, _: &mut VM, _: Val) -> Result<Val, Box<VMError>> where
    Self: Send
[src]

Produce a new Val which divides other from this.

fn double_div(self: Gc<Self>, _: &mut VM, _: Val) -> Result<Val, Box<VMError>> where
    Self: Send
[src]

fn modulus(self: Gc<Self>, _: &mut VM, _: Val) -> Result<Val, Box<VMError>> where
    Self: Send
[src]

Produce a new Val which performs a mod operation on this with other.

fn mul(self: Gc<Self>, _: &mut VM, _: Val) -> Result<Val, Box<VMError>> where
    Self: Send
[src]

Produce a new Val which multiplies other to this.

fn remainder(self: Gc<Self>, _: &mut VM, _: Val) -> Result<Val, Box<VMError>> where
    Self: Send
[src]

Produce a new Val which returns the remainder of dividing this with other.

fn shl(self: Gc<Self>, _: &mut VM, _: Val) -> Result<Val, Box<VMError>> where
    Self: Send
[src]

Produce a new Val which shifts self other bits to the left.

fn shr(self: Gc<Self>, _: &mut VM, _: Val) -> Result<Val, Box<VMError>> where
    Self: Send
[src]

Produce a new Val which shifts self other bits to the right, treating self as if it did not have a sign bit.

fn sqrt(self: Gc<Self>, _: &mut VM) -> Result<Val, Box<VMError>> where
    Self: Send
[src]

Produces a new Val which is the square root of this.

fn sub(self: Gc<Self>, _: &mut VM, _: Val) -> Result<Val, Box<VMError>> where
    Self: Send
[src]

Produce a new Val which subtracts other from this.

fn xor(self: Gc<Self>, _: &mut VM, _: Val) -> Result<Val, Box<VMError>> where
    Self: Send
[src]

Produce a new Val which performs a bitwise xor with other and this

fn ref_equals(
    self: Gc<Self>,
    vm: &mut VM,
    other: Val
) -> Result<Val, Box<VMError>> where
    Self: Send
[src]

Is this Val reference equality equal to other? Only immutable SOM types are likely to want to override this.

fn equals(self: Gc<Self>, _: &mut VM, _: Val) -> Result<Val, Box<VMError>> where
    Self: Send
[src]

Does this Val equal other?

fn not_equals(self: Gc<Self>, _: &mut VM, _: Val) -> Result<Val, Box<VMError>> where
    Self: Send
[src]

Does this Val not equal other?

fn greater_than(self: Gc<Self>, _: &mut VM, _: Val) -> Result<Val, Box<VMError>> where
    Self: Send
[src]

Is this Val greater than other?

fn greater_than_equals(
    self: Gc<Self>,
    _: &mut VM,
    _: Val
) -> Result<Val, Box<VMError>> where
    Self: Send
[src]

Is this Val greater than or equal to other?

fn less_than(self: Gc<Self>, _: &mut VM, _: Val) -> Result<Val, Box<VMError>> where
    Self: Send
[src]

Is this Val less than other?

fn less_than_equals(
    self: Gc<Self>,
    _: &mut VM,
    _: Val
) -> Result<Val, Box<VMError>> where
    Self: Send
[src]

Is this Val less than or equal to other?

Loading content...

Implementors

impl Obj for ArbInt[src]

impl Obj for Block[src]

impl Obj for Class[src]

impl Obj for Double[src]

impl Obj for Inst[src]

impl Obj for Int[src]

impl Obj for Method[src]

impl Obj for MethodsArray[src]

impl Obj for NormalArray[src]

impl Obj for String_[src]

Loading content...