MCPcopy Create free account
hub / github.com/argumentcomputer/ix / ground_consts

Function ground_consts

crates/compile/src/ground.rs:45–79  ·  view source on GitHub ↗

Checks every constant in `env` for groundedness and returns a map of all ungrounded names. First collects immediately ungrounded constants in parallel, then propagates ungroundedness transitively through `in_refs` (the reverse reference graph).

(
  env: &Env,
  in_refs: &RefMap,
)

Source from the content-addressed store, hash-verified

43/// First collects immediately ungrounded constants in parallel, then propagates
44/// ungroundedness transitively through `in_refs` (the reverse reference graph).
45pub fn ground_consts(
46 env: &Env,
47 in_refs: &RefMap,
48) -> FxHashMap<Name, GroundError> {
49 // Collect immediate ungrounded constants.
50 let names: Vec<&Name> = env.keys().collect();
51 let ungrounded: FxHashMap<_, _> = names
52 .into_par_iter()
53 .filter_map(|name| {
54 let constant = env.get(name)?;
55 match ground_const_check(&constant, env) {
56 Err(err) => Some((name.clone(), err)),
57 Ok(()) => None,
58 }
59 })
60 .collect();
61 proliferate_ungrounded(ungrounded, in_refs)
62}
63
64/// Per-constant groundedness check, for callers that already hold a
65/// decoded constant and check as part of a wider pass.
66pub fn ground_const_check(
67 constant: &ConstantInfo,
68 env: &Env,
69) -> Result<(), GroundError> {
70 let univs = const_univs(constant);
71 let mut stt = GroundState::default();
72 ground_const(constant, env, univs, 0, &mut stt)
73}
74
75/// Spread ungroundedness from the immediately-ungrounded set through
76/// the reverse-reference graph: anything referencing an ungrounded
77/// constant is itself ungrounded.
78pub fn proliferate_ungrounded(
79 mut ungrounded: FxHashMap<Name, GroundError>,
80 in_refs: &RefMap,
81) -> FxHashMap<Name, GroundError> {
82 let mut stack: Vec<_> = ungrounded.keys().cloned().collect();

Callers 2

checkFunction · 0.85
compile_env_with_optionsFunction · 0.85

Calls 7

const_univsFunction · 0.85
ground_constFunction · 0.85
entryMethod · 0.80
pushMethod · 0.80
cloneMethod · 0.45
getMethod · 0.45
insertMethod · 0.45

Tested by

no test coverage detected