some thoughts
This commit is contained in:
parent
988cb6c376
commit
9168867ab7
2 changed files with 5 additions and 4 deletions
|
|
@ -4,7 +4,8 @@
|
|||
// pub const fconst_2: u8 = 13; // (0xd) Push float 2
|
||||
// pub const dconst_0:u8 = 14; // (0xe) push double 0
|
||||
// pub const dconst_1:u8 = 15; // (0xf) push double 1
|
||||
pub const BIPUSH:u8 = 16; // (0x10) Push byte
|
||||
// TODO turn all into references
|
||||
pub const BIPUSH: &u8 = &16; // (0x10) Push byte
|
||||
pub const LDC: u8 = 18; // (0x12) Push item from run-time pub constant pool
|
||||
pub const LDC_W: u8 = 19; // (0x13) Push item from run-time constant pool (wide index)
|
||||
pub const LDC2_W: u8 = 20; // (0x14) Push long or double from run-time constant pool (wide index)
|
||||
|
|
|
|||
|
|
@ -86,7 +86,7 @@ impl Vm {
|
|||
pc += 1;
|
||||
println!("{}", opcode);
|
||||
match opcode {
|
||||
&opcodes::BIPUSH => {
|
||||
opcodes::BIPUSH => {
|
||||
let c = code.opcodes[pc] as i32;
|
||||
stack.push(Arc::new(Value::I32(c)));
|
||||
pc += 1;
|
||||
|
|
@ -151,10 +151,10 @@ impl Vm {
|
|||
&opcodes::GETFIELD => {
|
||||
let cp_index = read_u16(&code.opcodes, pc);
|
||||
if let CpEntry::Fieldref(class_index, name_and_type_index) = method.constant_pool.get(&cp_index).unwrap() {
|
||||
if let Value::Ref(inst) = &*stack.pop()? {
|
||||
if let Value::Ref(inst) = &*stack.pop()? { //TODO smell?
|
||||
if let CpEntry::NameAndType(name, _) = method.constant_pool.get(name_and_type_index).unwrap() {
|
||||
let value = inst.data.get(&name).unwrap();
|
||||
println!("{:?}", value);
|
||||
// println!("{:?}", value);
|
||||
stack.push(value.clone());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue