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.
1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 |
# File 'lib/HDLRuby/hruby_low_mutable.rb', line 1608 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 |