MCPcopy Create free account
hub / github.com/MaterializeInc/materialize / implement

Function implement

src/transform/src/normalize_lets.rs:1009–1043  ·  view source on GitHub ↗
(
        relation: &mut MirRelationExpr,
        remap: &BTreeMap<LocalId, LocalId>,
    )

Source from the content-addressed store, hash-verified

1007 }
1008
1009 fn implement(
1010 relation: &mut MirRelationExpr,
1011 remap: &BTreeMap<LocalId, LocalId>,
1012 ) -> Result<(), crate::TransformError> {
1013 let mut worklist = vec![relation];
1014 while let Some(expr) = worklist.pop() {
1015 match expr {
1016 MirRelationExpr::Let { id, .. } => {
1017 *id = *remap
1018 .get(id)
1019 .ok_or(crate::TransformError::IdentifierMissing(*id))?;
1020 }
1021 MirRelationExpr::LetRec { ids, .. } => {
1022 for id in ids.iter_mut() {
1023 *id = *remap
1024 .get(id)
1025 .ok_or(crate::TransformError::IdentifierMissing(*id))?;
1026 }
1027 }
1028 MirRelationExpr::Get {
1029 id: Id::Local(id), ..
1030 } => {
1031 *id = *remap
1032 .get(id)
1033 .ok_or(crate::TransformError::IdentifierMissing(*id))?;
1034 }
1035 _ => {
1036 // Remapped identifiers not used in these patterns.
1037 }
1038 }
1039 // The order is not critical, but behave as a stack for clarity.
1040 worklist.extend(expr.children_mut().rev());
1041 }
1042 Ok(())
1043 }
1044}

Callers 1

renumber_bindingsFunction · 0.85

Calls 4

popMethod · 0.45
getMethod · 0.45
extendMethod · 0.45
children_mutMethod · 0.45

Tested by

no test coverage detected