Remove old, unused code from vm; remove pub from various struct fields.
This commit is contained in:
		
							parent
							
								
									258fe824bd
								
							
						
					
					
						commit
						68553a756b
					
				| @ -32,9 +32,9 @@ fn main() { | |||||||
|     let array_impl_ptr_size_fld = DmField::new("ptr_size", DmType::USize); |     let array_impl_ptr_size_fld = DmField::new("ptr_size", DmType::USize); | ||||||
|     let array_impl_length_fld = DmField::new("length", DmType::Long); |     let array_impl_length_fld = DmField::new("length", DmType::Long); | ||||||
| 
 | 
 | ||||||
|     array_impl.fields.push(array_impl_ptr_address_fld); |     array_impl.add_field(array_impl_ptr_address_fld); | ||||||
|     array_impl.fields.push(array_impl_ptr_size_fld); |     array_impl.add_field(array_impl_ptr_size_fld); | ||||||
|     array_impl.fields.push(array_impl_length_fld); |     array_impl.add_field(array_impl_length_fld); | ||||||
| 
 | 
 | ||||||
|     // std::core::ArrayImpl::_ctor_0(
 |     // std::core::ArrayImpl::_ctor_0(
 | ||||||
|     //   r0: self
 |     //   r0: self
 | ||||||
| @ -56,7 +56,7 @@ fn main() { | |||||||
|         None, |         None, | ||||||
|     ); |     ); | ||||||
|     let array_impl_ctor_0_method = DmMethod::new(array_impl_ctor_0_fn, None); |     let array_impl_ctor_0_method = DmMethod::new(array_impl_ctor_0_fn, None); | ||||||
|     array_impl.methods.push(Rc::new(array_impl_ctor_0_method)); |     array_impl.add_method(array_impl_ctor_0_method); | ||||||
| 
 | 
 | ||||||
|     // Add Array and ArrayImpl to array lib
 |     // Add Array and ArrayImpl to array lib
 | ||||||
|     array_lib.interfaces.push(array_int_rc.clone()); |     array_lib.interfaces.push(array_int_rc.clone()); | ||||||
| @ -71,7 +71,7 @@ fn main() { | |||||||
|     let mut string_impl = DmImplementation::new("std::core::StringImpl", "StringImpl", None); |     let mut string_impl = DmImplementation::new("std::core::StringImpl", "StringImpl", None); | ||||||
| 
 | 
 | ||||||
|     let bytes_field = DmField::new("bytes", DmType::Object); |     let bytes_field = DmField::new("bytes", DmType::Object); | ||||||
|     string_impl.fields.push(bytes_field); |     string_impl.add_field(bytes_field); | ||||||
| 
 | 
 | ||||||
|     // std::core::String::_ctor_0(
 |     // std::core::String::_ctor_0(
 | ||||||
|     //   r0: self
 |     //   r0: self
 | ||||||
| @ -90,7 +90,7 @@ fn main() { | |||||||
| 
 | 
 | ||||||
|     let string_ctor_0_method = DmMethod::new(string_ctor_0_fn, None); |     let string_ctor_0_method = DmMethod::new(string_ctor_0_fn, None); | ||||||
| 
 | 
 | ||||||
|     string_impl.methods.push(Rc::new(string_ctor_0_method)); |     string_impl.add_method(string_ctor_0_method); | ||||||
| 
 | 
 | ||||||
|     string_lib.interfaces.push(Rc::new(string_int)); |     string_lib.interfaces.push(Rc::new(string_int)); | ||||||
|     string_lib.implementations.push(Rc::new(string_impl)); |     string_lib.implementations.push(Rc::new(string_impl)); | ||||||
|  | |||||||
| @ -8,17 +8,3 @@ pub enum DmType { | |||||||
|     Object, |     Object, | ||||||
|     USize, |     USize, | ||||||
| } | } | ||||||
| 
 |  | ||||||
| impl DmType { |  | ||||||
|     pub fn size_in_bytes(&self) -> usize { |  | ||||||
|         match self { |  | ||||||
|             DmType::Byte => size_of::<u8>(), |  | ||||||
|             DmType::Int => size_of::<i32>(), |  | ||||||
|             DmType::Long => size_of::<i64>(), |  | ||||||
|             DmType::Double => size_of::<f64>(), |  | ||||||
|             DmType::Boolean => size_of::<bool>(), |  | ||||||
|             DmType::Object => size_of::<usize>(), |  | ||||||
|             DmType::USize => size_of::<usize>(), |  | ||||||
|         } |  | ||||||
|     } |  | ||||||
| } |  | ||||||
|  | |||||||
| @ -23,6 +23,13 @@ impl DvmValue { | |||||||
|         } |         } | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|  |     pub fn is_long(&self) -> bool { | ||||||
|  |         match self { | ||||||
|  |             DvmValue::Long(_) => true, | ||||||
|  |             _ => false, | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|     pub fn expect_object(&self) -> Rc<DvmObject> { |     pub fn expect_object(&self) -> Rc<DvmObject> { | ||||||
|         if let DvmValue::Object(o) = self { |         if let DvmValue::Object(o) = self { | ||||||
|             o.clone() |             o.clone() | ||||||
| @ -45,4 +52,11 @@ impl DvmValue { | |||||||
|             panic!("Expected DvmValue::USize, but found DvmValue::{:?}", self); |             panic!("Expected DvmValue::USize, but found DvmValue::{:?}", self); | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|  | 
 | ||||||
|  |     pub fn is_usize(&self) -> bool { | ||||||
|  |         match self { | ||||||
|  |             DvmValue::USize(_) => true, | ||||||
|  |             _ => false, | ||||||
|  |         } | ||||||
|  |     } | ||||||
| } | } | ||||||
|  | |||||||
| @ -18,21 +18,21 @@ unsafe fn read_field(data_pointer: *const u8, dm_type: &DmType) -> DvmValue { | |||||||
| pub fn read_field_by_name(field_name: &str, self_object: &DvmObject) -> DvmValue { | pub fn read_field_by_name(field_name: &str, self_object: &DvmObject) -> DvmValue { | ||||||
|     let (field_index, field) = self_object |     let (field_index, field) = self_object | ||||||
|         .implementation() |         .implementation() | ||||||
|         .fields |         .fields() | ||||||
|         .iter() |         .iter() | ||||||
|         .enumerate() |         .enumerate() | ||||||
|         .find(|(_index, field)| field.name() == field_name) |         .find(|(_index, field)| field.name() == field_name) | ||||||
|         .expect(&format!( |         .expect(&format!( | ||||||
|             "Cannot find field {} in {}", |             "Cannot find field {} in {}", | ||||||
|             field_name, |             field_name, | ||||||
|             self_object.implementation().fqn |             self_object.implementation().fqn() | ||||||
|         )); |         )); | ||||||
|     let data_pointer = self_object.data()[field_index]; |     let data_pointer = self_object.data()[field_index]; | ||||||
|     unsafe { read_field(data_pointer, field.dm_type()) } |     unsafe { read_field(data_pointer, field.dm_type()) } | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| pub fn read_field_by_index(index: usize, self_object: &DvmObject) -> DvmValue { | pub fn read_field_by_index(index: usize, self_object: &DvmObject) -> DvmValue { | ||||||
|     let field = &self_object.implementation().fields[index]; |     let field = &self_object.implementation().fields()[index]; | ||||||
|     let data_pointer = self_object.data()[index]; |     let data_pointer = self_object.data()[index]; | ||||||
|     unsafe { read_field(data_pointer, field.dm_type()) } |     unsafe { read_field(data_pointer, field.dm_type()) } | ||||||
| } | } | ||||||
| @ -68,13 +68,13 @@ unsafe fn write_field(data_pointer: *mut u8, value: DvmValue) { | |||||||
| pub fn write_field_by_name(field_name: &str, self_object: &DvmObject, value: DvmValue) { | pub fn write_field_by_name(field_name: &str, self_object: &DvmObject, value: DvmValue) { | ||||||
|     let field_index = self_object |     let field_index = self_object | ||||||
|         .implementation() |         .implementation() | ||||||
|         .fields |         .fields() | ||||||
|         .iter() |         .iter() | ||||||
|         .position(|field| field.name() == field_name) |         .position(|field| field.name() == field_name) | ||||||
|         .expect(&format!( |         .expect(&format!( | ||||||
|             "Cannot find field {} in {}", |             "Cannot find field {} in {}", | ||||||
|             field_name, |             field_name, | ||||||
|             self_object.implementation().fqn |             self_object.implementation().fqn() | ||||||
|         )); |         )); | ||||||
|     let data_pointer = self_object.data()[field_index]; |     let data_pointer = self_object.data()[field_index]; | ||||||
|     unsafe { write_field(data_pointer, value) }; |     unsafe { write_field(data_pointer, value) }; | ||||||
|  | |||||||
| @ -2,11 +2,10 @@ pub mod dm_type; | |||||||
| pub mod dvm_value; | pub mod dvm_value; | ||||||
| pub mod lib; | pub mod lib; | ||||||
| pub mod mem; | pub mod mem; | ||||||
| mod object; | pub mod object; | ||||||
| pub mod object_type; | pub mod object_type; | ||||||
| pub mod op_codes; | pub mod op_codes; | ||||||
| pub mod platform; | pub mod platform; | ||||||
| mod pointer; |  | ||||||
| pub mod util; | pub mod util; | ||||||
| 
 | 
 | ||||||
| use crate::vm::dvm_value::DvmValue; | use crate::vm::dvm_value::DvmValue; | ||||||
| @ -68,7 +67,7 @@ impl DvmContext { | |||||||
|             for implementation_function in lib |             for implementation_function in lib | ||||||
|                 .implementations |                 .implementations | ||||||
|                 .iter() |                 .iter() | ||||||
|                 .flat_map(|implementation| &implementation.functions) |                 .flat_map(|implementation| implementation.functions()) | ||||||
|             { |             { | ||||||
|                 self.functions.insert( |                 self.functions.insert( | ||||||
|                     implementation_function.fqn().to_string(), |                     implementation_function.fqn().to_string(), | ||||||
| @ -78,7 +77,7 @@ impl DvmContext { | |||||||
|             for method in lib |             for method in lib | ||||||
|                 .implementations |                 .implementations | ||||||
|                 .iter() |                 .iter() | ||||||
|                 .flat_map(|implementation| &implementation.methods) |                 .flat_map(|implementation| implementation.methods()) | ||||||
|             { |             { | ||||||
|                 self.functions |                 self.functions | ||||||
|                     .insert(method.dm_fn().fqn().to_string(), method.dm_fn().clone()); |                     .insert(method.dm_fn().fqn().to_string(), method.dm_fn().clone()); | ||||||
| @ -324,7 +323,7 @@ pub fn run_byte_code(state: &mut DvmState, context: &DvmContext, byte_code: &[u8 | |||||||
|                     .find_map(|lib| { |                     .find_map(|lib| { | ||||||
|                         lib.implementations |                         lib.implementations | ||||||
|                             .iter() |                             .iter() | ||||||
|                             .find(|implementation| implementation.fqn == impl_name) |                             .find(|implementation| implementation.fqn() == impl_name) | ||||||
|                     }) |                     }) | ||||||
|                     .unwrap_or_else(|| { |                     .unwrap_or_else(|| { | ||||||
|                         dvm_panic!(&format!("Implementation not found: {}", impl_name), state) |                         dvm_panic!(&format!("Implementation not found: {}", impl_name), state) | ||||||
| @ -446,7 +445,7 @@ pub fn run_byte_code(state: &mut DvmState, context: &DvmContext, byte_code: &[u8 | |||||||
|                 let self_obj = args.get(0).unwrap().expect_object(); |                 let self_obj = args.get(0).unwrap().expect_object(); | ||||||
|                 let method = self_obj |                 let method = self_obj | ||||||
|                     .implementation() |                     .implementation() | ||||||
|                     .get_method(&symbol_name, &self_obj) |                     .find_method(&symbol_name, &self_obj) | ||||||
|                     .unwrap_or_else(|| { |                     .unwrap_or_else(|| { | ||||||
|                         dvm_panic!( |                         dvm_panic!( | ||||||
|                             &format!("Could not find method with name: {}", symbol_name), |                             &format!("Could not find method with name: {}", symbol_name), | ||||||
| @ -500,7 +499,7 @@ mod run_code_tests { | |||||||
|     fn impl_with_object_field() -> DmImplementation { |     fn impl_with_object_field() -> DmImplementation { | ||||||
|         let mut dm_impl = DmImplementation::new("ImplWithObjectField", "ImplWithObjectField", None); |         let mut dm_impl = DmImplementation::new("ImplWithObjectField", "ImplWithObjectField", None); | ||||||
|         let object_field = DmField::new("object_field", DmType::Object); |         let object_field = DmField::new("object_field", DmType::Object); | ||||||
|         dm_impl.fields.push(object_field); |         dm_impl.add_field(object_field); | ||||||
|         dm_impl |         dm_impl | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
| @ -549,8 +548,8 @@ mod run_code_tests { | |||||||
|         dummy_lib.implementations.push(dummy_impl_rc.clone()); |         dummy_lib.implementations.push(dummy_impl_rc.clone()); | ||||||
| 
 | 
 | ||||||
|         let mut code = Vec::new(); |         let mut code = Vec::new(); | ||||||
|         add_alloc(&mut code, 0, &dummy_impl_rc.fqn); |         add_alloc(&mut code, 0, &dummy_impl_rc.fqn()); | ||||||
|         add_alloc(&mut code, 1, &dummy_impl_rc.fqn); |         add_alloc(&mut code, 1, &dummy_impl_rc.fqn()); | ||||||
|         add_store(&mut code, 0, 0, 1); |         add_store(&mut code, 0, 0, 1); | ||||||
|         add_load(&mut code, 2, 0, 0); |         add_load(&mut code, 2, 0, 0); | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -24,8 +24,8 @@ fn layout_for(dm_type: &DmType) -> Layout { | |||||||
| 
 | 
 | ||||||
| impl DvmObject { | impl DvmObject { | ||||||
|     pub fn new(implementation: Rc<DmImplementation>) -> Self { |     pub fn new(implementation: Rc<DmImplementation>) -> Self { | ||||||
|         let mut data = vec![ptr::null_mut(); implementation.fields.len()]; |         let mut data = vec![ptr::null_mut(); implementation.fields().len()]; | ||||||
|         for (index, field) in implementation.fields.iter().enumerate() { |         for (index, field) in implementation.fields().iter().enumerate() { | ||||||
|             data[index] = unsafe { alloc(layout_for(field.dm_type())) } |             data[index] = unsafe { alloc(layout_for(field.dm_type())) } | ||||||
|         } |         } | ||||||
|         DvmObject { |         DvmObject { | ||||||
| @ -45,7 +45,7 @@ impl DvmObject { | |||||||
| 
 | 
 | ||||||
| impl Drop for DvmObject { | impl Drop for DvmObject { | ||||||
|     fn drop(&mut self) { |     fn drop(&mut self) { | ||||||
|         for (index, field) in self.implementation.fields.iter().enumerate() { |         for (index, field) in self.implementation.fields().iter().enumerate() { | ||||||
|             unsafe { dealloc(self.data[index], layout_for(field.dm_type())) } |             unsafe { dealloc(self.data[index], layout_for(field.dm_type())) } | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|  | |||||||
| @ -138,7 +138,7 @@ impl DmInterface { | |||||||
|             .find(|&dm_fn| dm_fn.fqn == name) |             .find(|&dm_fn| dm_fn.fqn == name) | ||||||
|             .is_some() |             .is_some() | ||||||
|         { |         { | ||||||
|             return self_object.implementation().get_method(name, self_object); |             return self_object.implementation().find_method(name, self_object); | ||||||
|         } |         } | ||||||
|         None |         None | ||||||
|     } |     } | ||||||
| @ -146,16 +146,12 @@ impl DmInterface { | |||||||
|     pub fn get_virtual_methods(&self) -> Vec<Rc<DmVirtualMethod>> { |     pub fn get_virtual_methods(&self) -> Vec<Rc<DmVirtualMethod>> { | ||||||
|         self.virtual_methods.clone() |         self.virtual_methods.clone() | ||||||
|     } |     } | ||||||
| 
 |  | ||||||
|     pub fn get_property(&self, name: &str, self_object: &DvmObject) -> Option<&DmProperty> { |  | ||||||
|         todo!() |  | ||||||
|     } |  | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| #[derive(Debug, Eq)] | #[derive(Debug, Eq)] | ||||||
| pub struct DmVirtualMethod { | pub struct DmVirtualMethod { | ||||||
|     pub fqn: String, |     fqn: String, | ||||||
|     pub short_name: String, |     short_name: String, | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| impl PartialEq for DmVirtualMethod { | impl PartialEq for DmVirtualMethod { | ||||||
| @ -164,14 +160,31 @@ impl PartialEq for DmVirtualMethod { | |||||||
|     } |     } | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | impl DmVirtualMethod { | ||||||
|  |     pub fn new(fqn: &str, short_name: &str) -> Self { | ||||||
|  |         DmVirtualMethod { | ||||||
|  |             fqn: fqn.to_string(), | ||||||
|  |             short_name: short_name.to_string(), | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     pub fn fqn(&self) -> &str { | ||||||
|  |         self.fqn.as_str() | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     pub fn short_name(&self) -> &str { | ||||||
|  |         self.short_name.as_str() | ||||||
|  |     } | ||||||
|  | } | ||||||
|  | 
 | ||||||
| #[derive(Debug, Eq)] | #[derive(Debug, Eq)] | ||||||
| pub struct DmImplementation { | pub struct DmImplementation { | ||||||
|     pub fqn: String, |     fqn: String, | ||||||
|     pub short_name: String, |     short_name: String, | ||||||
|     pub interface: Option<Rc<DmInterface>>, |     interface: Option<Rc<DmInterface>>, | ||||||
|     pub functions: Vec<Rc<DmFn>>, |     functions: Vec<Rc<DmFn>>, | ||||||
|     pub methods: Vec<Rc<DmMethod>>, |     methods: Vec<Rc<DmMethod>>, | ||||||
|     pub fields: Vec<DmField>, |     fields: Vec<DmField>, | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| impl PartialEq for DmImplementation { | impl PartialEq for DmImplementation { | ||||||
| @ -192,11 +205,31 @@ impl DmImplementation { | |||||||
|         } |         } | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|  |     pub fn fqn(&self) -> &str { | ||||||
|  |         self.fqn.as_str() | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     pub fn short_name(&self) -> &str { | ||||||
|  |         self.short_name.as_str() | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|     pub fn interface(&self) -> Option<Rc<DmInterface>> { |     pub fn interface(&self) -> Option<Rc<DmInterface>> { | ||||||
|         self.interface.clone() |         self.interface.clone() | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     pub fn get_method(&self, name: &str, self_object: &DvmObject) -> Option<Rc<DmMethod>> { |     pub fn functions(&self) -> Vec<Rc<DmFn>> { | ||||||
|  |         self.functions.clone() | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     pub fn methods(&self) -> Vec<Rc<DmMethod>> { | ||||||
|  |         self.methods.clone() | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     pub fn add_method(&mut self, dm_method: DmMethod) { | ||||||
|  |         self.methods.push(Rc::new(dm_method)); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     pub fn find_method(&self, name: &str, self_object: &DvmObject) -> Option<Rc<DmMethod>> { | ||||||
|         for method in &self.methods { |         for method in &self.methods { | ||||||
|             if method.dm_fn.fqn == name { |             if method.dm_fn.fqn == name { | ||||||
|                 return Some(method.clone()); |                 return Some(method.clone()); | ||||||
| @ -209,28 +242,19 @@ impl DmImplementation { | |||||||
|         None |         None | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     pub fn get_property(&self, name: &str, self_object: &DvmObject) -> Option<Rc<DmProperty>> { |     pub fn fields(&self) -> &Vec<DmField> { | ||||||
|         todo!() |         &self.fields | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     pub fn get_field(&self, name: &str, self_object: &DvmObject) -> Option<&DmField> { |     pub fn add_field(&mut self, dm_field: DmField) { | ||||||
|  |         self.fields.push(dm_field); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     pub fn find_field(&self, name: &str, self_object: &DvmObject) -> Option<&DmField> { | ||||||
|         self.fields.iter().find(|field| field.name == name) |         self.fields.iter().find(|field| field.name == name) | ||||||
|     } |     } | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| #[derive(Debug, Eq)] |  | ||||||
| pub struct DmProperty { |  | ||||||
|     pub name: String, |  | ||||||
|     pub data_offset: usize, |  | ||||||
|     pub primitive_type: Rc<DmType>, |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| impl PartialEq for DmProperty { |  | ||||||
|     fn eq(&self, other: &Self) -> bool { |  | ||||||
|         self.name == other.name |  | ||||||
|     } |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| #[derive(Debug, Eq)] | #[derive(Debug, Eq)] | ||||||
| pub struct DmField { | pub struct DmField { | ||||||
|     name: String, |     name: String, | ||||||
|  | |||||||
| @ -35,7 +35,7 @@ fn get_string(dvm_value: &DvmValue) -> String { | |||||||
| } | } | ||||||
| 
 | 
 | ||||||
| fn object_to_string(alloc_object_rc: Rc<DvmObject>) -> String { | fn object_to_string(alloc_object_rc: Rc<DvmObject>) -> String { | ||||||
|     if alloc_object_rc.implementation().fqn == "std::core::StringImpl" { |     if alloc_object_rc.implementation().fqn() == "std::core::StringImpl" { | ||||||
|         extract_string_from_string(alloc_object_rc.clone()) |         extract_string_from_string(alloc_object_rc.clone()) | ||||||
|     } else { |     } else { | ||||||
|         todo!("what happens if we don't have a String?") |         todo!("what happens if we don't have a String?") | ||||||
| @ -44,7 +44,7 @@ fn object_to_string(alloc_object_rc: Rc<DvmObject>) -> String { | |||||||
| 
 | 
 | ||||||
| fn extract_string_from_string(string_object: Rc<DvmObject>) -> String { | fn extract_string_from_string(string_object: Rc<DvmObject>) -> String { | ||||||
|     let bytes_object = read_field_by_name("bytes", &string_object).expect_object(); |     let bytes_object = read_field_by_name("bytes", &string_object).expect_object(); | ||||||
|     if bytes_object.implementation().fqn != "std::core::ArrayImpl" { |     if bytes_object.implementation().fqn() != "std::core::ArrayImpl" { | ||||||
|         panic!("String.bytes field is not a std::core::ArrayImpl"); |         panic!("String.bytes field is not a std::core::ArrayImpl"); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -1,27 +0,0 @@ | |||||||
| use std::fmt::{Display, Formatter}; |  | ||||||
| 
 |  | ||||||
| #[derive(Debug, PartialEq, Eq)] |  | ||||||
| pub struct DvmPointer { |  | ||||||
|     address: *mut u8, |  | ||||||
|     size: usize, |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| impl DvmPointer { |  | ||||||
|     pub fn new(address: *mut u8, size: usize) -> DvmPointer { |  | ||||||
|         DvmPointer { address, size } |  | ||||||
|     } |  | ||||||
| 
 |  | ||||||
|     pub fn address(&self) -> *mut u8 { |  | ||||||
|         self.address |  | ||||||
|     } |  | ||||||
| 
 |  | ||||||
|     pub fn size(&self) -> usize { |  | ||||||
|         self.size |  | ||||||
|     } |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| impl Display for DvmPointer { |  | ||||||
|     fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { |  | ||||||
|         f.write_fmt(format_args!("0x{:x}", self.address as usize)) |  | ||||||
|     } |  | ||||||
| } |  | ||||||
		Loading…
	
		Reference in New Issue
	
	Block a user
	 Jesse Brault
						Jesse Brault