pub enum PointerObj {
UpVal(UpValue),
SliceMember(GosValue, i32),
StructField(GosValue, i32),
PkgMember(PackageKey, i32),
}
Expand description
There are 4 types of pointers, they point to:
- local
- slice member
- struct field
- package member References to outer function’s local vars and pointers to local vars are all UpValues
Variants§
Implementations§
Source§impl PointerObj
impl PointerObj
pub fn new_closed_up_value(val: &GosValue) -> PointerObj
pub fn new_slice_member( val: GosValue, i: i32, t: ValueType, t_elem: ValueType, ) -> Result<PointerObj, RuntimeError>
pub fn deref( &self, stack: &Stack, pkgs: &PiggyVec<PackageKey, PackageObj>, ) -> Result<GosValue, RuntimeError>
Sourcepub fn cast(
&self,
new_type: ValueType,
stack: &Stack,
pkgs: &PiggyVec<PackageKey, PackageObj>,
) -> Result<PointerObj, RuntimeError>
pub fn cast( &self, new_type: ValueType, stack: &Stack, pkgs: &PiggyVec<PackageKey, PackageObj>, ) -> Result<PointerObj, RuntimeError>
cast returns the GosValue the pointer points to, with a new type obviously this is very unsafe, more rigorous checks should be done here.
Sourcepub fn set_pointee(
&self,
val: &GosValue,
stack: &mut Stack,
pkgs: &PiggyVec<PackageKey, PackageObj>,
gcc: &GcContainer,
) -> Result<(), RuntimeError>
pub fn set_pointee( &self, val: &GosValue, stack: &mut Stack, pkgs: &PiggyVec<PackageKey, PackageObj>, gcc: &GcContainer, ) -> Result<(), RuntimeError>
set_value is not used by VM, it’s for FFI
Trait Implementations§
Source§impl Clone for PointerObj
impl Clone for PointerObj
Source§fn clone(&self) -> PointerObj
fn clone(&self) -> PointerObj
Returns a copy of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl Debug for PointerObj
impl Debug for PointerObj
Source§impl Display for PointerObj
impl Display for PointerObj
Source§impl Hash for PointerObj
impl Hash for PointerObj
Source§impl Ord for PointerObj
impl Ord for PointerObj
Source§fn cmp(&self, other: &PointerObj) -> Ordering
fn cmp(&self, other: &PointerObj) -> Ordering
1.21.0 · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
Source§impl PartialEq for PointerObj
impl PartialEq for PointerObj
Source§impl PartialOrd for PointerObj
impl PartialOrd for PointerObj
impl Eq for PointerObj
Auto Trait Implementations§
impl Freeze for PointerObj
impl !RefUnwindSafe for PointerObj
impl !Send for PointerObj
impl !Sync for PointerObj
impl Unpin for PointerObj
impl !UnwindSafe for PointerObj
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more