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.
1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 |
# File 'lib/HDLRuby/hruby_low_mutable.rb', line 1474 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 |