I dont know, I changed things
This commit is contained in:
parent
43ceaa95bb
commit
3fd30b80b6
5 changed files with 98 additions and 10 deletions
|
@ -98,6 +98,13 @@ impl HeapArea {
|
|||
|
||||
array_ref
|
||||
}
|
||||
|
||||
pub fn make_primitive_int_array(&mut self, array_capacity: usize, class_store: &ClassStore) -> ObjectReference {
|
||||
let (array_ref, size) = self.object_area.make_primitive_int_array(array_capacity, class_store);
|
||||
self.memory_used += size;
|
||||
|
||||
array_ref
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug, Default, PartialEq)]
|
||||
|
@ -368,6 +375,11 @@ impl ObjectArea {
|
|||
|
||||
*array_element = match element { FieldValue::Char(c) => c, _ => unreachable!() } ;
|
||||
}
|
||||
CompartmentEntry::IntArray(array) => {
|
||||
let array_element = array.content.get_mut(index).unwrap();
|
||||
|
||||
*array_element = match element { FieldValue::Int(i) => i, _ => unreachable!() } ;
|
||||
}
|
||||
_ => unreachable!(),
|
||||
};
|
||||
|
||||
|
@ -435,6 +447,27 @@ impl ObjectArea {
|
|||
|
||||
(array_ref, array_size)
|
||||
}
|
||||
|
||||
fn make_primitive_int_array(&mut self, array_capacity: usize, class_store: &ClassStore) -> (ObjectReference, usize) {
|
||||
// make new type desc
|
||||
let array_type_desc = AbstractTypeDescription {
|
||||
array_level: 1,
|
||||
kind: AbstractTypeKind::Int(),
|
||||
};
|
||||
|
||||
let array_class_ref = class_store.get_array_class_ref(&array_type_desc).unwrap();
|
||||
|
||||
let array_size = array_capacity * std::mem::size_of::<i32>() + std::mem::size_of::<IntArray>();
|
||||
|
||||
let array_object = IntArray {
|
||||
class_ref: array_class_ref,
|
||||
content: vec![0; array_capacity].into(),
|
||||
};
|
||||
|
||||
let array_ref = self.store_entry(CompartmentEntry::IntArray(array_object));
|
||||
|
||||
(array_ref, array_size)
|
||||
}
|
||||
}
|
||||
|
||||
pub struct ObjectCompartment {
|
||||
|
@ -477,6 +510,7 @@ impl ObjectCompartment {
|
|||
CompartmentEntry::ReferenceArray(_) => unreachable!(),
|
||||
CompartmentEntry::ByteArray(_) => unreachable!(),
|
||||
CompartmentEntry::CharArray(_) => unreachable!(),
|
||||
CompartmentEntry::IntArray(_) => unreachable!(),
|
||||
}
|
||||
|
||||
*self.objects.get_mut(compartment_index).unwrap() = object;
|
||||
|
@ -507,6 +541,7 @@ pub enum CompartmentEntry {
|
|||
ReferenceArray(ReferenceArray),
|
||||
ByteArray(ByteArray),
|
||||
CharArray(CharArray),
|
||||
IntArray(IntArray),
|
||||
EmptyNext(usize),
|
||||
EmptyTail(), // last empty value
|
||||
}
|
||||
|
@ -517,6 +552,12 @@ pub struct CharArray {
|
|||
content: Box<[u16]>,
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct IntArray {
|
||||
class_ref: ObjectReference,
|
||||
content: Box<[i32]>,
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct ByteArray {
|
||||
class_ref: ObjectReference,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue