refactor vm
This commit is contained in:
@@ -0,0 +1,62 @@
|
||||
use crate::{BytecodeReader, PrimOp, StepResult, Value};
|
||||
use fix_builtins::BuiltinId;
|
||||
use num_enum::TryFromPrimitive;
|
||||
|
||||
impl<'gc> crate::Vm<'gc> {
|
||||
#[inline(always)]
|
||||
pub(crate) fn op_load_builtins(&mut self) -> StepResult<'gc> {
|
||||
self.push_stack(self.builtins);
|
||||
StepResult::Continue
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
pub(crate) fn op_load_builtin(&mut self, reader: &mut BytecodeReader<'_>) -> StepResult<'gc> {
|
||||
let Ok(id) = BuiltinId::try_from_primitive(reader.read_u8())
|
||||
.map_err(|err| panic!("unknown builtin id: {}", err.number));
|
||||
self.push_stack(Value::new_inline(PrimOp {
|
||||
id,
|
||||
arity: fix_builtins::BUILTINS[id as usize].1,
|
||||
}));
|
||||
StepResult::Continue
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
pub(crate) fn op_mk_pos(&mut self, reader: &mut BytecodeReader<'_>) -> StepResult<'gc> {
|
||||
let _span_id = reader.read_u32();
|
||||
todo!("MkPos");
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
pub(crate) fn op_load_repl_binding(&mut self, reader: &mut BytecodeReader<'_>) -> StepResult<'gc> {
|
||||
let _name = reader.read_string_id();
|
||||
todo!("LoadReplBinding");
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
pub(crate) fn op_load_scoped_binding(&mut self, reader: &mut BytecodeReader<'_>) -> StepResult<'gc> {
|
||||
let _name = reader.read_string_id();
|
||||
todo!("LoadScopedBinding");
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
pub(crate) fn op_concat_strings(
|
||||
&mut self,
|
||||
ctx: &mut impl crate::VmContext,
|
||||
reader: &mut BytecodeReader<'_>,
|
||||
_mc: &gc_arena::Mutation<'gc>,
|
||||
) -> StepResult<'gc> {
|
||||
let _parts_count = reader.read_u16() as usize;
|
||||
let _force_string = reader.read_u8() != 0;
|
||||
let mut _operands: smallvec::SmallVec<[crate::OperandData; 4]> =
|
||||
smallvec::SmallVec::with_capacity(_parts_count);
|
||||
for _ in 0.._parts_count {
|
||||
_operands.push(reader.read_operand_data(ctx));
|
||||
}
|
||||
todo!("implement ConcatStrings (force parts, coerce to string, concatenate)");
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
pub(crate) fn op_resolve_path(&mut self, _ctx: &mut impl crate::VmContext) -> StepResult<'gc> {
|
||||
todo!("implement ResolvePath");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user