Files
not-python/src/obj/int.rs

40 lines
746 B
Rust
Raw Normal View History

use crate::obj::prelude::*;
use shredder::Scan;
use std::fmt::{Debug, Formatter, self};
pub type IntRef = ObjRef<Int>;
#[derive(Scan)]
pub struct Int {
value: i64,
vtable: Vtable,
attrs: Attrs,
}
impl Int {
pub fn new_obj(value: i64) -> ObjRef<Self> {
// TODO : vtable for Int
let obj_ref = ObjRef::new(Self {
value,
vtable: Default::default(),
attrs: Default::default(),
});
obj_ref
}
pub fn value(&self) -> i64 {
self.value
}
}
impl_obj_readonly!(Int);
impl Debug for Int {
fn fmt(&self, fmt: &mut Formatter) -> fmt::Result {
fmt.debug_struct("Int")
.field("value", &self.value)
.finish()
}
}