70 lines
2.2 KiB
Rust
70 lines
2.2 KiB
Rust
use fix_builtins::BuiltinId;
|
|
use num_enum::TryFromPrimitive;
|
|
|
|
use crate::{BytecodeReader, PrimOp, StepResult, Value};
|
|
|
|
impl<'gc> crate::Vm<'gc> {
|
|
#[inline(always)]
|
|
pub(crate) fn op_load_builtins(&mut self) -> StepResult {
|
|
self.push_stack(self.builtins);
|
|
StepResult::Continue
|
|
}
|
|
|
|
#[inline(always)]
|
|
pub(crate) fn op_load_builtin(&mut self, reader: &mut BytecodeReader<'_>) -> StepResult {
|
|
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 {
|
|
let _span_id = reader.read_u32();
|
|
todo!("MkPos");
|
|
}
|
|
|
|
#[inline(always)]
|
|
pub(crate) fn op_load_repl_binding(
|
|
&mut self,
|
|
reader: &mut BytecodeReader<'_>,
|
|
) -> StepResult {
|
|
let _name = reader.read_string_id();
|
|
todo!("LoadReplBinding");
|
|
}
|
|
|
|
#[inline(always)]
|
|
pub(crate) fn op_load_scoped_binding(
|
|
&mut self,
|
|
reader: &mut BytecodeReader<'_>,
|
|
) -> StepResult {
|
|
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 {
|
|
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 {
|
|
todo!("implement ResolvePath");
|
|
}
|
|
}
|