datex_core/values/value/
to_instructions.rs1use crate::{
2 core_compiler::{
3 to_instructions::{ToInstructions, yield_all},
4 value_visitor::ValueVisitor,
5 },
6 prelude::*,
7 runtime::cache::shared_references_cache::SharedReferencesCache,
8 values::value::Value,
9};
10
11impl ToInstructions for Value {
12 fn to_instructions<'a>(
13 &'a self,
14 visitor: &'a mut dyn ValueVisitor,
15 cache: &'a mut SharedReferencesCache,
16 ) -> Box<dyn Iterator<Item = crate::instruction::Instruction> + 'a> {
17 Box::new(gen move {
18 match self {
20 Value::Native(native) => {
21 yield_all!(native.to_instructions(visitor, cache));
22 }
23 Value::Core(core) => {
24 yield_all!(core.to_instructions(visitor, cache));
25 }
26 }
27 })
28 }
29}