add compiler
This commit is contained in:
@@ -19,8 +19,8 @@ impl Instruction {
|
||||
let a = context.pop();
|
||||
let b = context.pop();
|
||||
if let (Some(a), Some(b)) = (a, b) {
|
||||
context.push(b);
|
||||
context.push(a);
|
||||
context.push(b);
|
||||
} else {
|
||||
return Err(RuntimeError::ErrorVmState(format!("Stack is not enough when call swap!")));
|
||||
}
|
||||
@@ -85,7 +85,7 @@ impl Instruction {
|
||||
let addr = context.pop();
|
||||
if let Some(addr) = addr {
|
||||
match context.get_mem(addr) {
|
||||
Some(val) => { context.put_mem(addr, val); },
|
||||
Some(val) => { context.push(val); },
|
||||
None => return Err(RuntimeError::ErrorVmState(format!("Memory addr not found: {}!", addr))),
|
||||
}
|
||||
} else {
|
||||
@@ -165,6 +165,7 @@ impl Vm {
|
||||
if context.is_debug() {
|
||||
let is_define_label = if let Instruction::DefineLabel(_) = ins { true } else { false };
|
||||
if !is_define_label {
|
||||
println!("[DEBUG] Context: {:?}", context);
|
||||
println!("[DEBUG] Execute instruction: {:?}", ins);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user