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.
1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 |
# File 'lib/HDLRuby/hruby_low_mutable.rb', line 1563 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 |