sim_lib_lang_julia/
generic.rs1use std::sync::Arc;
2
3use sim_kernel::{Cx, Result, Shape, Symbol, Value};
4use sim_lib_dispatch::{DispatchMethod, GenericFunction, MethodBody, MethodRole};
5
6pub struct JuliaFunction {
12 generic: GenericFunction,
13}
14
15impl JuliaFunction {
16 pub fn new(name: Symbol) -> Self {
18 Self {
19 generic: GenericFunction::new(name),
20 }
21 }
22
23 pub fn add_method(
25 &mut self,
26 method: Symbol,
27 argument_shapes: Vec<Arc<dyn Shape>>,
28 body: MethodBody,
29 ) -> Result<()> {
30 self.generic.add_method(DispatchMethod::new(
31 method,
32 MethodRole::Primary,
33 argument_shapes,
34 body,
35 ))
36 }
37
38 pub fn dispatch_order(&self, cx: &mut Cx, args: &[Value]) -> Result<Vec<Symbol>> {
40 self.generic.dispatch_order(cx, args)
41 }
42
43 pub fn call(&self, cx: &mut Cx, args: &[Value]) -> Result<Value> {
45 self.generic
46 .call_for_profile(cx, &crate::julia_profile_symbol(), args)
47 }
48}