Module: HDLRuby::Low::MutableConcat
Overview
Module adding some (but not all) mutable methods to Concat and RefConcat.
Instance Method Summary collapse
-
#replace_expressions!(node2rep) ⇒ Object
Replaces sub expressions using +node2rep+ table indicating the node to replace and the corresponding replacement.
Instance Method Details
#replace_expressions!(node2rep) ⇒ Object
Replaces sub expressions using +node2rep+ table indicating the node to replace and the corresponding replacement. Returns the actually replaced nodes and their corresponding replacement.
NOTE: the replacement is duplicated.
1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 |
# File 'lib/HDLRuby/hruby_low_mutable.rb', line 1645 def replace_expressions!(node2rep) # First recurse on the children. res = {} self.each_node do |node| res.merge!(node.replace_expressions!(node2rep)) end # Is there a replacement of on a sub node? self.map_nodes! do |sub| rep = node2rep[sub] if rep then # Yes, do it. rep = rep.clone node = sub # node.set_parent!(nil) # And register the replacement. res[node] = rep rep else sub end end return res end |