implement primop (filter)
This commit is contained in:
+13
-3
@@ -2,8 +2,9 @@
|
||||
#![allow(dead_code)]
|
||||
|
||||
use bumpalo::Bump;
|
||||
use fix_builtins::PrimOpPhase;
|
||||
use fix_codegen::disassembler::{Disassembler, DisassemblerContext};
|
||||
use fix_codegen::{BytecodeContext, InstructionPtr};
|
||||
use fix_codegen::{BytecodeContext, InstructionPtr, Op};
|
||||
use fix_common::{StringId, Symbol};
|
||||
use fix_error::{Error, Result, Source};
|
||||
use fix_ir::downgrade::{Downgrade as _, DowngradeContext};
|
||||
@@ -47,6 +48,11 @@ impl Evaluator {
|
||||
pub fn new() -> Self {
|
||||
let mut strings = DefaultStringInterner::new();
|
||||
let global_env = fix_ir::new_global_env(&mut strings);
|
||||
let mut bytecode = Vec::with_capacity(PrimOpPhase::Illegal as usize * 2);
|
||||
for phase in 0..=PrimOpPhase::Illegal as u8 {
|
||||
bytecode.push(Op::DispatchPrimOp as u8);
|
||||
bytecode.push(phase);
|
||||
}
|
||||
Self {
|
||||
runtime: RuntimeState {
|
||||
strings,
|
||||
@@ -56,7 +62,7 @@ impl Evaluator {
|
||||
sources: Vec::new(),
|
||||
spans: Vec::new(),
|
||||
thunk_count: 0,
|
||||
bytecode: Vec::new(),
|
||||
bytecode,
|
||||
global_env,
|
||||
},
|
||||
}
|
||||
@@ -239,7 +245,11 @@ impl<'a, R: VmRuntimeCtx> BytecodeContext for CompilerCtx<'a, R> {
|
||||
Float(x) => StaticValue::new_float(x),
|
||||
Bool(x) => StaticValue::new_inline(x),
|
||||
String(x) => StaticValue::new_inline(x),
|
||||
PrimOp { id, arity } => StaticValue::new_primop(id, arity),
|
||||
PrimOp {
|
||||
id,
|
||||
arity,
|
||||
dispatch_ip,
|
||||
} => StaticValue::new_primop(id, arity, dispatch_ip),
|
||||
Null => StaticValue::default(),
|
||||
};
|
||||
self.runtime.add_const(val)
|
||||
|
||||
Reference in New Issue
Block a user