bytecode evaluation
This commit is contained in:
parent
fb29955f7d
commit
8642dcdd6a
5 changed files with 528 additions and 31 deletions
|
@ -3,35 +3,65 @@ use std::collections::HashMap;
|
|||
use crate::stackframe::Value;
|
||||
use crate::classfile::{ AbstractTypeDescription, MethodInfo };
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct HeapArea {
|
||||
pub memory_capacity: usize,
|
||||
pub memory_used: usize,
|
||||
pub object_area: ObjectArea,
|
||||
pub static_area: StaticArea,
|
||||
}
|
||||
|
||||
type ObjectReference=u32;
|
||||
impl HeapArea {
|
||||
pub fn new(memory_capacity: usize) -> Self {
|
||||
HeapArea {
|
||||
memory_capacity,
|
||||
memory_used: 0,
|
||||
object_area: ObjectArea::default(),
|
||||
static_area: StaticArea::default(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub type ObjectReference=u32;
|
||||
|
||||
const DEFAULT_COMPARTMENT_CAPACITY: usize = u16::MAX as usize;
|
||||
|
||||
#[derive(Default, Debug)]
|
||||
pub struct ObjectArea {
|
||||
compartments: Vec<ObjectCompartment>,
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct ObjectCompartment {
|
||||
objects: Box<[HeapObject]>,
|
||||
objects: Box<[ObjectCompartmentEntry]>,
|
||||
first_free: usize,
|
||||
reserved_count: usize,
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub enum ObjectCompartmentEntry {
|
||||
Valid(HeapObject),
|
||||
Empty(usize), // next empty value
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct HeapObject {
|
||||
fields: Box<[ObjectField]>,
|
||||
}
|
||||
|
||||
#[derive(Default, Debug)]
|
||||
pub struct StaticArea {
|
||||
static_objects: HashMap<String, StaticObject>,
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct StaticObject {
|
||||
pub class_index: usize,
|
||||
pub fields: Box<[ObjectField]>,
|
||||
pub methods: Box<[MethodInfo]>,
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct ObjectField {
|
||||
pub type_description: AbstractTypeDescription,
|
||||
pub value: Value,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue