More bytecode ops
This commit is contained in:
parent
9243c0b291
commit
5bc0d813e5
7 changed files with 395 additions and 120 deletions
|
@ -1,5 +1,5 @@
|
|||
use crate::classfile::{ JavaClassFile, AttributeData };
|
||||
use crate::heap_area::ObjectReference;
|
||||
use crate::heap_area::{ ObjectReference, FieldValue };
|
||||
|
||||
#[derive(Copy, Clone, Debug)]
|
||||
pub enum StackValue {
|
||||
|
@ -48,6 +48,27 @@ impl OperandStack {
|
|||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn push_field_value(&mut self, value: FieldValue) -> Result<(), Error> {
|
||||
match value {
|
||||
FieldValue::Reference(r) => {
|
||||
self.push(StackValue::Reference(r))
|
||||
}
|
||||
|
||||
FieldValue::Boolean(b) => {
|
||||
self.push(StackValue::Int(if b { 1 } else { 0 }))
|
||||
}
|
||||
|
||||
FieldValue::Byte(b) => {
|
||||
self.push(StackValue::Int(b as i32))
|
||||
}
|
||||
|
||||
_ => {
|
||||
println!("{value:?}");
|
||||
todo!();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn pop_computational_1(&mut self, index: usize) -> Result<StackValue, Error> {
|
||||
let absolute_index = self.depth as usize - 1 - index;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue