sim-lib-agent 0.1.2

Agent runtime surfaces for SIM.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
use super::runtime::{AgentFnKind, AgentFunction};
use sim_kernel::{Linker, Result};
use std::sync::Arc;

pub(crate) fn register_agent_functions(
    cx: &mut sim_kernel::LoadCx,
    linker: &mut Linker<'_>,
) -> Result<()> {
    for (symbol, kind) in AgentFnKind::all() {
        let function_id = linker.function(symbol.clone())?;
        let value = cx.factory().opaque(Arc::new(AgentFunction {
            symbol: symbol.clone(),
            kind: *kind,
        }))?;
        linker.bind_function_value(function_id, value)?;
    }
    Ok(())
}