runtime, macros: unify NaN-boxed value API under ValueVariant trait
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
use bumpalo::Bump;
|
||||
use fix_bytecode::{Const, InstructionPtr, Op, Continuation};
|
||||
use fix_bytecode::{Const, Continuation, InstructionPtr, Op};
|
||||
use fix_error::{Error, Result, Source};
|
||||
use fix_lang::{StringId, Symbol};
|
||||
use fix_runtime::{StaticValue, VmCode, VmRuntimeCtx};
|
||||
@@ -148,16 +148,20 @@ impl<'a, R: VmRuntimeCtx> BytecodeContext for CompilerCtx<'a, R> {
|
||||
fn add_constant(&mut self, val: Const) -> u32 {
|
||||
use Const::*;
|
||||
let val = match val {
|
||||
Smi(x) => StaticValue::new_inline(x),
|
||||
Float(x) => StaticValue::new_float(x),
|
||||
Bool(x) => StaticValue::new_inline(x),
|
||||
String(x) => StaticValue::new_inline(x),
|
||||
Path(x) => StaticValue::new_inline(fix_runtime::Path(x)),
|
||||
Smi(x) => StaticValue::new(x),
|
||||
Float(x) => StaticValue::new(x),
|
||||
Bool(x) => StaticValue::new(x),
|
||||
String(x) => StaticValue::new(x),
|
||||
Path(x) => StaticValue::new(fix_runtime::Path(x)),
|
||||
PrimOp {
|
||||
id,
|
||||
arity,
|
||||
dispatch_ip,
|
||||
} => StaticValue::new_primop(id, arity, dispatch_ip),
|
||||
} => StaticValue::new(fix_runtime::PrimOp {
|
||||
id,
|
||||
arity,
|
||||
dispatch_ip,
|
||||
}),
|
||||
Null => StaticValue::default(),
|
||||
};
|
||||
self.runtime.add_const(val)
|
||||
|
||||
Reference in New Issue
Block a user