From b37cf6de08a2f800b508b6a4883176cb264a4e8b Mon Sep 17 00:00:00 2001 From: Sebastien Bourdeauducq Date: Mon, 1 Nov 2021 00:03:15 +0800 Subject: [PATCH] nac3artiq: share isa->time_fns map --- nac3artiq/src/lib.rs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/nac3artiq/src/lib.rs b/nac3artiq/src/lib.rs index c751bce8..fe72cd76 100644 --- a/nac3artiq/src/lib.rs +++ b/nac3artiq/src/lib.rs @@ -57,6 +57,7 @@ pub struct PrimitivePythonId { #[pyclass(unsendable, name = "NAC3")] struct Nac3 { isa: Isa, + time_fns: &'static (dyn TimeFns + Sync), primitive: PrimitiveStore, builtins_ty: HashMap, builtins_def: HashMap, @@ -284,6 +285,7 @@ impl Nac3 { Ok(Nac3 { isa, + time_fns, primitive, builtins_ty, builtins_def, @@ -438,14 +440,10 @@ impl Nac3 { ) .expect("couldn't write module to file"); }))); - let time_fns: &(dyn TimeFns + Sync) = match isa { - Isa::RiscV => &timeline::NOW_PINNING_TIME_FNS, - Isa::CortexA9 => &timeline::EXTERN_TIME_FNS, - }; let thread_names: Vec = (0..4).map(|i| format!("module{}", i)).collect(); let threads: Vec<_> = thread_names .iter() - .map(|s| Box::new(ArtiqCodeGenerator::new(s.to_string(), time_fns))) + .map(|s| Box::new(ArtiqCodeGenerator::new(s.to_string(), self.time_fns))) .collect(); py.allow_threads(|| {