Big Object naming refactor
* trait Obj -> Object * Remove *Inst suffix from all object types. ObjInst -> Obj, IntInst -> Int, etc * Type -> Ty, type_inst() -> ty(), type_name() -> ty_name() Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
This commit is contained in:
11
src/vm.rs
11
src/vm.rs
@@ -98,7 +98,7 @@ impl Vm {
|
||||
/// Create a new virtual machine with the given chunk, constants, and global names.
|
||||
pub fn new(chunk: Rc<Chunk>, constants: Vec<ObjP>, global_names: Vec<String>) -> Self {
|
||||
// set up globals
|
||||
let nil = NilInst::create();
|
||||
let nil = Nil::create();
|
||||
let mut globals: Vec<_> = global_names.iter().map(|_| ObjP::clone(&nil)).collect();
|
||||
|
||||
let mut register_global = |name: &str, value: ObjP| {
|
||||
@@ -290,7 +290,7 @@ impl Vm {
|
||||
// need both declarations to borrow cell value
|
||||
let name_obj = Ptr::clone(&self.constants[constant_id as usize]);
|
||||
let name =
|
||||
with_obj_downcast(name_obj, |name: &StrInst| Rc::clone(&name.str_value()));
|
||||
with_obj_downcast(name_obj, |name: &Str| Rc::clone(&name.str_value()));
|
||||
let owner = self.pop();
|
||||
let value = owner.borrow_mut().get_vtable_attr(owner.clone(), &name);
|
||||
if let Some(value) = value {
|
||||
@@ -309,7 +309,7 @@ impl Vm {
|
||||
Op::SetAttr(constant_id) => {
|
||||
let name_obj = Ptr::clone(&self.constants[constant_id as usize]);
|
||||
let name =
|
||||
with_obj_downcast(name_obj, |name: &StrInst| Rc::clone(&name.str_value()));
|
||||
with_obj_downcast(name_obj, |name: &Str| Rc::clone(&name.str_value()));
|
||||
let value = self.pop();
|
||||
let target = self.pop();
|
||||
|
||||
@@ -378,10 +378,9 @@ impl Vm {
|
||||
// constants, we want to deep-clone this object so we don't alter any live
|
||||
// objects.
|
||||
// there is some room for optimization here so we aren't cloning the entire
|
||||
// UserFunctionInst for every individual capture in a function.
|
||||
// UserFunction for every individual capture in a function.
|
||||
let fun_ptr = self.pop();
|
||||
let mut fun: UserFunctionInst =
|
||||
with_obj_downcast(fun_ptr, UserFunctionInst::clone);
|
||||
let mut fun: UserFunction = with_obj_downcast(fun_ptr, UserFunction::clone);
|
||||
let frame_index = self.frames.len() - (depth as usize) - 1;
|
||||
let stack_base = self.frames[frame_index].stack_base;
|
||||
let value = Ptr::clone(&self.stack[stack_base + (slot as usize)]);
|
||||
|
||||
Reference in New Issue
Block a user