Files
nix-js/fix-vm/src/instructions/literals.rs
T

56 lines
1.6 KiB
Rust

use gc_arena::{Gc, Mutation};
use crate::{BytecodeReader, StepResult, Value};
impl<'gc> crate::Vm<'gc> {
#[inline(always)]
pub(crate) fn op_push_smi(&mut self, reader: &mut BytecodeReader<'_>) -> StepResult<'gc> {
let val = reader.read_i32();
self.push_stack(Value::new_inline(val));
StepResult::Continue
}
#[inline(always)]
pub(crate) fn op_push_bigint(
&mut self,
reader: &mut BytecodeReader<'_>,
mc: &Mutation<'gc>,
) -> StepResult<'gc> {
let val = reader.read_i64();
self.push_stack(Value::new_gc(Gc::new(mc, val)));
StepResult::Continue
}
#[inline(always)]
pub(crate) fn op_push_float(&mut self, reader: &mut BytecodeReader<'_>) -> StepResult<'gc> {
let val = reader.read_f64();
self.push_stack(Value::new_float(val));
StepResult::Continue
}
#[inline(always)]
pub(crate) fn op_push_string(&mut self, reader: &mut BytecodeReader<'_>) -> StepResult<'gc> {
let sid = reader.read_string_id();
self.push_stack(Value::new_inline(sid));
StepResult::Continue
}
#[inline(always)]
pub(crate) fn op_push_null(&mut self) -> StepResult<'gc> {
self.push_stack(Value::new_inline(crate::Null));
StepResult::Continue
}
#[inline(always)]
pub(crate) fn op_push_true(&mut self) -> StepResult<'gc> {
self.push_stack(Value::new_inline(true));
StepResult::Continue
}
#[inline(always)]
pub(crate) fn op_push_false(&mut self) -> StepResult<'gc> {
self.push_stack(Value::new_inline(false));
StepResult::Continue
}
}