pr9.4
This commit is contained in:
@@ -228,7 +228,7 @@ impl VirtualMachine {
|
||||
|
||||
// Resolve the entrypoint: empty (defaults to func 0), numeric func_idx, or symbol name.
|
||||
let pc = if entrypoint.is_empty() {
|
||||
program.functions.get(0).map(|f| f.code_offset as usize).unwrap_or(0)
|
||||
program.functions.first().map(|f| f.code_offset as usize).unwrap_or(0)
|
||||
} else if let Ok(func_idx) = entrypoint.parse::<usize>() {
|
||||
program
|
||||
.functions
|
||||
@@ -525,7 +525,7 @@ impl VirtualMachine {
|
||||
.imm_u32()
|
||||
.map_err(|e| LogicalFrameEndingReason::Panic(format!("{:?}", e)))?
|
||||
as usize;
|
||||
let val = self.pop().map_err(|e| LogicalFrameEndingReason::Panic(e))?;
|
||||
let val = self.pop().map_err(LogicalFrameEndingReason::Panic)?;
|
||||
match val {
|
||||
Value::Boolean(false) => {
|
||||
let func_start = self
|
||||
@@ -551,7 +551,7 @@ impl VirtualMachine {
|
||||
.imm_u32()
|
||||
.map_err(|e| LogicalFrameEndingReason::Panic(format!("{:?}", e)))?
|
||||
as usize;
|
||||
let val = self.pop().map_err(|e| LogicalFrameEndingReason::Panic(e))?;
|
||||
let val = self.pop().map_err(LogicalFrameEndingReason::Panic)?;
|
||||
match val {
|
||||
Value::Boolean(true) => {
|
||||
let func_start = self
|
||||
@@ -622,7 +622,7 @@ impl VirtualMachine {
|
||||
// Pop args top-first, then reverse to logical order arg1..argN
|
||||
let mut args: Vec<Value> = Vec::with_capacity(arg_count);
|
||||
for _ in 0..arg_count {
|
||||
args.push(self.pop().map_err(|e| LogicalFrameEndingReason::Panic(e))?);
|
||||
args.push(self.pop().map_err(LogicalFrameEndingReason::Panic)?);
|
||||
}
|
||||
args.reverse();
|
||||
|
||||
@@ -1040,7 +1040,7 @@ impl VirtualMachine {
|
||||
_ => Err(OpError::Panic("Invalid types for MOD".into())),
|
||||
})?,
|
||||
OpCode::BoundToInt => {
|
||||
let val = self.pop().map_err(|e| LogicalFrameEndingReason::Panic(e))?;
|
||||
let val = self.pop().map_err(LogicalFrameEndingReason::Panic)?;
|
||||
if let Value::Bounded(b) = val {
|
||||
self.push(Value::Int64(b as i64));
|
||||
} else {
|
||||
@@ -1050,13 +1050,13 @@ impl VirtualMachine {
|
||||
}
|
||||
}
|
||||
OpCode::IntToBoundChecked => {
|
||||
let val = self.pop().map_err(|e| LogicalFrameEndingReason::Panic(e))?;
|
||||
let val = self.pop().map_err(LogicalFrameEndingReason::Panic)?;
|
||||
let int_val = val.as_integer().ok_or_else(|| {
|
||||
LogicalFrameEndingReason::Panic(
|
||||
"Expected integer for INT_TO_BOUND_CHECKED".into(),
|
||||
)
|
||||
})?;
|
||||
if int_val < 0 || int_val > 0xFFFF {
|
||||
if !(0..=0xFFFF).contains(&int_val) {
|
||||
return Err(self.trap(
|
||||
TRAP_OOB,
|
||||
OpCode::IntToBoundChecked as u16,
|
||||
@@ -1101,7 +1101,7 @@ impl VirtualMachine {
|
||||
_ => Err(OpError::Panic("Invalid types for OR".into())),
|
||||
})?,
|
||||
OpCode::Not => {
|
||||
let val = self.pop().map_err(|e| LogicalFrameEndingReason::Panic(e))?;
|
||||
let val = self.pop().map_err(LogicalFrameEndingReason::Panic)?;
|
||||
if let Value::Boolean(b) = val {
|
||||
self.push(Value::Boolean(!b));
|
||||
} else {
|
||||
@@ -1148,7 +1148,7 @@ impl VirtualMachine {
|
||||
_ => Err(OpError::Panic("Invalid types for Shr".into())),
|
||||
})?,
|
||||
OpCode::Neg => {
|
||||
let val = self.pop().map_err(|e| LogicalFrameEndingReason::Panic(e))?;
|
||||
let val = self.pop().map_err(LogicalFrameEndingReason::Panic)?;
|
||||
match val {
|
||||
Value::Int32(a) => self.push(Value::Int32(a.wrapping_neg())),
|
||||
Value::Int64(a) => self.push(Value::Int64(a.wrapping_neg())),
|
||||
|
||||
Reference in New Issue
Block a user