diff --git a/vm/src/bytecode.rs b/vm/src/bytecode.rs index f07b38cc0..9c7479942 100644 --- a/vm/src/bytecode.rs +++ b/vm/src/bytecode.rs @@ -190,7 +190,7 @@ pub enum Constant { Boolean { value: bool }, String { value: String }, Bytes { value: Vec }, - Code { code: CodeObject }, + Code { code: Box }, Tuple { elements: Vec }, None, } diff --git a/vm/src/compile.rs b/vm/src/compile.rs index 761297b4a..1959cee83 100644 --- a/vm/src/compile.rs +++ b/vm/src/compile.rs @@ -603,7 +603,9 @@ impl Compiler { self.prepare_decorators(decorator_list)?; self.emit(Instruction::LoadConst { - value: bytecode::Constant::Code { code }, + value: bytecode::Constant::Code { + code: Box::new(code), + }, }); self.emit(Instruction::LoadConst { value: bytecode::Constant::String { @@ -653,7 +655,9 @@ impl Compiler { let code = self.pop_code_object(); self.emit(Instruction::LoadConst { - value: bytecode::Constant::Code { code }, + value: bytecode::Constant::Code { + code: Box::new(code), + }, }); self.emit(Instruction::LoadConst { value: bytecode::Constant::String { @@ -1075,7 +1079,9 @@ impl Compiler { self.emit(Instruction::ReturnValue); let code = self.pop_code_object(); self.emit(Instruction::LoadConst { - value: bytecode::Constant::Code { code }, + value: bytecode::Constant::Code { + code: Box::new(code), + }, }); self.emit(Instruction::LoadConst { value: bytecode::Constant::String { value: name }, @@ -1360,7 +1366,9 @@ impl Compiler { // List comprehension code: self.emit(Instruction::LoadConst { - value: bytecode::Constant::Code { code }, + value: bytecode::Constant::Code { + code: Box::new(code), + }, }); // List comprehension function name: diff --git a/vm/src/frame.rs b/vm/src/frame.rs index 50bbde150..ec0c09923 100644 --- a/vm/src/frame.rs +++ b/vm/src/frame.rs @@ -716,8 +716,7 @@ impl Frame { let obj = import_module(vm, current_path, module)?; for (k, v) in obj.get_key_value_pairs().iter() { - &self - .scope + self.scope .locals .set_item(&vm.ctx, &objstr::get_value(k), v.clone()); } diff --git a/vm/src/pyobject.rs b/vm/src/pyobject.rs index e8a2b32c0..9e0cdbb95 100644 --- a/vm/src/pyobject.rs +++ b/vm/src/pyobject.rs @@ -682,7 +682,7 @@ impl PyContext { bytecode::Constant::String { ref value } => self.new_str(value.clone()), bytecode::Constant::Bytes { ref value } => self.new_bytes(value.clone()), bytecode::Constant::Boolean { ref value } => self.new_bool(value.clone()), - bytecode::Constant::Code { ref code } => self.new_code_object(code.clone()), + bytecode::Constant::Code { ref code } => self.new_code_object(*code.clone()), bytecode::Constant::Tuple { ref elements } => { let elements = elements .iter()