Class: OrigenTesters::ATP::Processors::ElseRemover
- Inherits:
-
OrigenTesters::ATP::Processor
- Object
- OrigenTesters::ATP::Processor
- OrigenTesters::ATP::Processors::ElseRemover
- Defined in:
- lib/origen_testers/atp/processors/else_remover.rb
Overview
Removes embedded else nodes and converts them to the equivalent inverse condition node at the same level as the parent node
Instance Method Summary collapse
Methods inherited from OrigenTesters::ATP::Processor
#add_global_flag, #clean_flag, #extract_globals, #extract_volatiles, #global_flag?, #global_flags, #handler_missing, #process, #process_all, #volatile?, #volatile_flags
Instance Method Details
#on_condition_node(node) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/origen_testers/atp/processors/else_remover.rb', line 10 def on_condition_node(node) if e = node.find(:else) n1 = node.remove(e) if node.type.to_s =~ /if_/ type = node.type.to_s.sub('if_', 'unless_').to_sym elsif node.type.to_s =~ /unless_/ type = node.type.to_s.sub('unless_', 'if_').to_sym else fail "Don't know how to inverse: #{node.type}" end n2 = e.updated(type, [n1.to_a[0]] + e.children) node.updated(:inline, [n1, n2]) else node.updated(nil, process_all(node.children)) end end |
#run(node) ⇒ Object
6 7 8 |
# File 'lib/origen_testers/atp/processors/else_remover.rb', line 6 def run(node) process(node) end |