MCPcopy Create free account
hub / github.com/dylan-sutton-chavez/edge-python / resolve_canonical

Method resolve_canonical

compiler/src/main/resolver.rs:115–136  ·  view source on GitHub ↗
(&self, spec: &str)

Source from the content-addressed store, hash-verified

113 }
114
115 fn resolve_canonical(&self, spec: &str) -> Result<Resolved, String> {
116 let entry = with_runtime(|rt| {
117 rt.registry.iter().find(|(s, _)| s == spec).map(|(s, e)| {
118 let cloned = match e {
119 ModuleEntry::Code(src) => ModuleEntry::Code(src.clone()),
120 ModuleEntry::Native(funcs) => ModuleEntry::Native(funcs.clone()),
121 };
122 (s.clone(), cloned)
123 })
124 }).ok_or_else(|| s!("module '", str spec, "' not registered (host did not pre-fetch / register before run())"))?;
125 match entry.1 {
126 ModuleEntry::Code(src) => Ok(Resolved::Code {
127 src,
128 canonical: spec.to_string(),
129 }),
130 ModuleEntry::Native(funcs) => {
131 let all: Vec<NativeBinding> = funcs.iter().map(|(n, id)| make_native_binding(n.clone(), *id)).collect();
132 let (bindings, classes, consts) = partition_bindings(all);
133 Ok(Resolved::Native { bindings, classes, consts, canonical: spec.to_string() })
134 }
135 }
136 }
137}
138

Callers 2

resolveMethod · 0.45
resolve_bareMethod · 0.45

Calls 5

with_runtimeFunction · 0.85
make_native_bindingFunction · 0.85
partition_bindingsFunction · 0.85
collectMethod · 0.80
iterMethod · 0.45

Tested by

no test coverage detected