65 lines
2.1 KiB
Rust
65 lines
2.1 KiB
Rust
use fix_builtins::BuiltinId;
|
|
use num_enum::TryFromPrimitive;
|
|
|
|
use crate::{BytecodeReader, PrimOp, Step, Value, VmRuntimeCtx};
|
|
|
|
impl<'gc> crate::Vm<'gc> {
|
|
#[inline(always)]
|
|
pub(crate) fn op_load_builtins(&mut self) -> Step {
|
|
self.push(self.builtins);
|
|
Step::Continue(())
|
|
}
|
|
|
|
#[inline(always)]
|
|
pub(crate) fn op_load_builtin(&mut self, reader: &mut BytecodeReader<'_>) -> Step {
|
|
let Ok(id) = BuiltinId::try_from_primitive(reader.read_u8())
|
|
.map_err(|err| panic!("unknown builtin id: {}", err.number));
|
|
self.push(Value::new_inline(PrimOp {
|
|
id,
|
|
arity: fix_builtins::BUILTINS[id as usize].1,
|
|
dispatch_ip: id.entry_phase().ip(),
|
|
}));
|
|
Step::Continue(())
|
|
}
|
|
|
|
#[inline(always)]
|
|
pub(crate) fn op_mk_pos(&mut self, reader: &mut BytecodeReader<'_>) -> Step {
|
|
let _span_id = reader.read_u32();
|
|
todo!("MkPos");
|
|
}
|
|
|
|
#[inline(always)]
|
|
pub(crate) fn op_load_repl_binding(&mut self, reader: &mut BytecodeReader<'_>) -> Step {
|
|
let _name = reader.read_string_id();
|
|
todo!("LoadReplBinding");
|
|
}
|
|
|
|
#[inline(always)]
|
|
pub(crate) fn op_load_scoped_binding(&mut self, reader: &mut BytecodeReader<'_>) -> Step {
|
|
let _name = reader.read_string_id();
|
|
todo!("LoadScopedBinding");
|
|
}
|
|
|
|
#[inline(always)]
|
|
pub(crate) fn op_concat_strings(
|
|
&mut self,
|
|
ctx: &mut impl VmRuntimeCtx,
|
|
reader: &mut BytecodeReader<'_>,
|
|
_mc: &gc_arena::Mutation<'gc>,
|
|
) -> Step {
|
|
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 VmRuntimeCtx) -> Step {
|
|
todo!("implement ResolvePath");
|
|
}
|
|
}
|