Module yksom::vm::objects [−][src]
This module contains the core SOM objects. Note that there is a fundamental constraint that
must be obeyed by the programmer at all times: upon their creation, instances of the Obj
trait must immediately be passed to Val::from_obj
. In other words this is safe:
let x = Val::from_obj(vm, String_{ s: "a".to_owned() }); dbg!(x.tobj().as_str());
but this leads to undefined behaviour:
let x = String_{ s: "a".to_owned() }; dbg!(x.tobj().as_str());
The reason for this is that methods on Obj
s can call Val::restore
which converts an Obj
reference back into a Val
.
Although this constraint is not enforced through the type system, it is not hard to obey: as
soon as you create an Obj
instance, pass it to Val::from_obj
.
Structs
ArbInt | A boxed arbitrary sized |
Block | |
Class | |
Double | A boxed Double (which is synonymous with a f64 in yksom). |
Inst | An instance of a user class. |
Int | A boxed |
Method | |
MethodsArray | |
NormalArray | |
String_ | |
ThinObj | A narrow pointer to #trait_id. |
UpVar | An UpVar references either a variable on the stack or, if the UpVar is closed, a copy of that
variable inside the struct itself (the |
Enums
ObjType | The SOM type of objects. |
Traits
Array | |
Obj | The main SOM Object trait. Notice that code should almost never call these functions directly:
you should instead call the equivalent function in the |
StaticObjType |