refactor: split VmContext
This commit is contained in:
@@ -3,13 +3,13 @@ use std::cmp::Ordering;
|
||||
use gc_arena::{Gc, Mutation};
|
||||
|
||||
use crate::value::*;
|
||||
use crate::{BytecodeReader, NixNum, Step, VmContextExt, VmError};
|
||||
use crate::{BytecodeReader, NixNum, Step, VmError, VmRuntimeCtx, VmRuntimeCtxExt as _};
|
||||
|
||||
impl<'gc> crate::Vm<'gc> {
|
||||
#[inline(always)]
|
||||
pub(crate) fn op_add(
|
||||
&mut self,
|
||||
ctx: &mut impl crate::VmContext,
|
||||
ctx: &mut impl VmRuntimeCtx,
|
||||
reader: &mut BytecodeReader<'_>,
|
||||
mc: &Mutation<'gc>,
|
||||
) -> Step {
|
||||
@@ -82,7 +82,7 @@ impl<'gc> crate::Vm<'gc> {
|
||||
#[inline(always)]
|
||||
pub(crate) fn op_eq(
|
||||
&mut self,
|
||||
ctx: &mut impl crate::VmContext,
|
||||
ctx: &mut impl VmRuntimeCtx,
|
||||
reader: &mut BytecodeReader<'_>,
|
||||
mc: &Mutation<'gc>,
|
||||
) -> Step {
|
||||
@@ -98,7 +98,7 @@ impl<'gc> crate::Vm<'gc> {
|
||||
#[inline(always)]
|
||||
pub(crate) fn op_neq(
|
||||
&mut self,
|
||||
ctx: &mut impl crate::VmContext,
|
||||
ctx: &mut impl VmRuntimeCtx,
|
||||
reader: &mut BytecodeReader<'_>,
|
||||
mc: &Mutation<'gc>,
|
||||
) -> Step {
|
||||
@@ -114,7 +114,7 @@ impl<'gc> crate::Vm<'gc> {
|
||||
#[inline(always)]
|
||||
pub(crate) fn op_lt(
|
||||
&mut self,
|
||||
ctx: &mut impl crate::VmContext,
|
||||
ctx: &mut impl VmRuntimeCtx,
|
||||
reader: &mut BytecodeReader<'_>,
|
||||
mc: &Mutation<'gc>,
|
||||
) -> Step {
|
||||
@@ -124,7 +124,7 @@ impl<'gc> crate::Vm<'gc> {
|
||||
#[inline(always)]
|
||||
pub(crate) fn op_gt(
|
||||
&mut self,
|
||||
ctx: &mut impl crate::VmContext,
|
||||
ctx: &mut impl VmRuntimeCtx,
|
||||
reader: &mut BytecodeReader<'_>,
|
||||
mc: &Mutation<'gc>,
|
||||
) -> Step {
|
||||
@@ -134,7 +134,7 @@ impl<'gc> crate::Vm<'gc> {
|
||||
#[inline(always)]
|
||||
pub(crate) fn op_leq(
|
||||
&mut self,
|
||||
ctx: &mut impl crate::VmContext,
|
||||
ctx: &mut impl VmRuntimeCtx,
|
||||
reader: &mut BytecodeReader<'_>,
|
||||
mc: &Mutation<'gc>,
|
||||
) -> Step {
|
||||
@@ -144,7 +144,7 @@ impl<'gc> crate::Vm<'gc> {
|
||||
#[inline(always)]
|
||||
pub(crate) fn op_geq(
|
||||
&mut self,
|
||||
ctx: &mut impl crate::VmContext,
|
||||
ctx: &mut impl VmRuntimeCtx,
|
||||
reader: &mut BytecodeReader<'_>,
|
||||
mc: &Mutation<'gc>,
|
||||
) -> Step {
|
||||
@@ -153,7 +153,7 @@ impl<'gc> crate::Vm<'gc> {
|
||||
|
||||
fn compare_values(
|
||||
&mut self,
|
||||
ctx: &impl crate::VmContext,
|
||||
ctx: &impl VmRuntimeCtx,
|
||||
reader: &mut BytecodeReader<'_>,
|
||||
mc: &Mutation<'gc>,
|
||||
pred: fn(Ordering) -> bool,
|
||||
@@ -202,7 +202,7 @@ impl<'gc> crate::Vm<'gc> {
|
||||
|
||||
pub(crate) fn values_equal(
|
||||
&mut self,
|
||||
ctx: &impl crate::VmContext,
|
||||
ctx: &impl VmRuntimeCtx,
|
||||
lhs: StrictValue<'gc>,
|
||||
rhs: StrictValue<'gc>,
|
||||
) -> crate::VmResult<bool> {
|
||||
@@ -257,7 +257,7 @@ impl<'gc> crate::Vm<'gc> {
|
||||
|
||||
fn compare_values_inner(
|
||||
&mut self,
|
||||
ctx: &impl crate::VmContext,
|
||||
ctx: &impl VmRuntimeCtx,
|
||||
pred: fn(Ordering) -> bool,
|
||||
lhs: StrictValue<'gc>,
|
||||
rhs: StrictValue<'gc>,
|
||||
@@ -276,10 +276,7 @@ impl<'gc> crate::Vm<'gc> {
|
||||
self.push(Value::new_inline(pred(ord)));
|
||||
return Ok(());
|
||||
}
|
||||
if let (Some(a), Some(b)) = (
|
||||
VmContextExt::get_string(ctx, lhs),
|
||||
VmContextExt::get_string(ctx, rhs),
|
||||
) {
|
||||
if let (Some(a), Some(b)) = (ctx.get_string(lhs), ctx.get_string(rhs)) {
|
||||
self.push(Value::new_inline(pred(a.cmp(b))));
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user