better type assertion ergonomic

This commit is contained in:
2026-04-20 17:57:54 +08:00
parent 581c333070
commit 11b0b8a78e
13 changed files with 399 additions and 258 deletions
+22 -22
View File
@@ -1,13 +1,13 @@
use gc_arena::{Gc, Mutation};
use crate::{BytecodeReader, StepResult, Value};
use crate::{BytecodeReader, Step, Value};
impl<'gc> crate::Vm<'gc> {
#[inline(always)]
pub(crate) fn op_push_smi(&mut self, reader: &mut BytecodeReader<'_>) -> StepResult {
pub(crate) fn op_push_smi(&mut self, reader: &mut BytecodeReader<'_>) -> Step {
let val = reader.read_i32();
self.push_stack(Value::new_inline(val));
StepResult::Continue
self.push(Value::new_inline(val));
Step::Continue
}
#[inline(always)]
@@ -15,41 +15,41 @@ impl<'gc> crate::Vm<'gc> {
&mut self,
reader: &mut BytecodeReader<'_>,
mc: &Mutation<'gc>,
) -> StepResult {
) -> Step {
let val = reader.read_i64();
self.push_stack(Value::new_gc(Gc::new(mc, val)));
StepResult::Continue
self.push(Value::new_gc(Gc::new(mc, val)));
Step::Continue
}
#[inline(always)]
pub(crate) fn op_push_float(&mut self, reader: &mut BytecodeReader<'_>) -> StepResult {
pub(crate) fn op_push_float(&mut self, reader: &mut BytecodeReader<'_>) -> Step {
let val = reader.read_f64();
self.push_stack(Value::new_float(val));
StepResult::Continue
self.push(Value::new_float(val));
Step::Continue
}
#[inline(always)]
pub(crate) fn op_push_string(&mut self, reader: &mut BytecodeReader<'_>) -> StepResult {
pub(crate) fn op_push_string(&mut self, reader: &mut BytecodeReader<'_>) -> Step {
let sid = reader.read_string_id();
self.push_stack(Value::new_inline(sid));
StepResult::Continue
self.push(Value::new_inline(sid));
Step::Continue
}
#[inline(always)]
pub(crate) fn op_push_null(&mut self) -> StepResult {
self.push_stack(Value::new_inline(crate::Null));
StepResult::Continue
pub(crate) fn op_push_null(&mut self) -> Step {
self.push(Value::new_inline(crate::Null));
Step::Continue
}
#[inline(always)]
pub(crate) fn op_push_true(&mut self) -> StepResult {
self.push_stack(Value::new_inline(true));
StepResult::Continue
pub(crate) fn op_push_true(&mut self) -> Step {
self.push(Value::new_inline(true));
Step::Continue
}
#[inline(always)]
pub(crate) fn op_push_false(&mut self) -> StepResult {
self.push_stack(Value::new_inline(false));
StepResult::Continue
pub(crate) fn op_push_false(&mut self) -> Step {
self.push(Value::new_inline(false));
Step::Continue
}
}