Skip to content
Snippets Groups Projects
Commit 954339eb authored by Russel Arbore's avatar Russel Arbore
Browse files

Do DC subst in float-collections

parent b903546c
No related branches found
No related tags found
1 merge request!148Do DC subst in float-collections
Pipeline #201424 passed
use std::collections::BTreeMap; use std::collections::{BTreeMap, HashMap};
use hercules_ir::*; use hercules_ir::*;
...@@ -83,10 +83,6 @@ pub fn float_collections( ...@@ -83,10 +83,6 @@ pub fn float_collections(
.map(|(idx, node)| (NodeID::new(idx), node.clone())) .map(|(idx, node)| (NodeID::new(idx), node.clone()))
.collect(); .collect();
let success = editors.get_mut(&caller).unwrap().edit(|mut edit| { let success = editors.get_mut(&caller).unwrap().edit(|mut edit| {
let cons_ids: Vec<_> = cons
.iter()
.map(|(_, node)| edit.add_node(node.clone()))
.collect();
for (id, node) in calls { for (id, node) in calls {
let Node::Call { let Node::Call {
control, control,
...@@ -97,6 +93,19 @@ pub fn float_collections( ...@@ -97,6 +93,19 @@ pub fn float_collections(
else { else {
panic!() panic!()
}; };
let dc_args = (0..dynamic_constants.len())
.map(|i| edit.add_dynamic_constant(DynamicConstant::Parameter(i)));
let substs = dc_args
.zip(dynamic_constants.iter().map(|id| *id))
.collect::<HashMap<_, _>>();
let cons_ids: Vec<_> = cons
.iter()
.map(|(_, node)| {
let mut node = node.clone();
substitute_dynamic_constants_in_node(&substs, &mut node, &mut edit);
edit.add_node(node)
})
.collect();
let mut args = Vec::from(args); let mut args = Vec::from(args);
args.extend(cons_ids.iter()); args.extend(cons_ids.iter());
let new_call = edit.add_node(Node::Call { let new_call = edit.add_node(Node::Call {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment