Class: OrigenTesters::ATP::Processors::Flattener

Inherits:
OrigenTesters::ATP::Processor show all
Defined in:
lib/origen_testers/atp/processors/flattener.rb

Overview

Gives every node their own individual wrapping of condition nodes. No attempt is made to identify or remove duplicate conditions in the wrapping, that will be done later by the RedundantConditionRemover.

Instance Method Summary collapse

Methods inherited from OrigenTesters::ATP::Processor

#clean_flag, #extract_volatiles, #process, #process_all, #volatile?, #volatile_flags

Instance Method Details

#handler_missing(node) ⇒ Object


42
43
44
# File 'lib/origen_testers/atp/processors/flattener.rb', line 42

def handler_missing(node)
  results << wrap_with_current_conditions(node)
end

#on_condition_node(node) ⇒ Object


32
33
34
35
36
37
# File 'lib/origen_testers/atp/processors/flattener.rb', line 32

def on_condition_node(node)
  flag, *nodes = *node
  @conditions << node.updated(node.type, [flag])
  process_all(nodes)
  @conditions.pop
end

#on_flow(node) ⇒ Object


14
15
16
# File 'lib/origen_testers/atp/processors/flattener.rb', line 14

def on_flow(node)
  process_all(node.children)
end

#on_group(node) ⇒ Object


25
26
27
28
29
30
# File 'lib/origen_testers/atp/processors/flattener.rb', line 25

def on_group(node)
  @results << []
  process_all(node.children)
  nodes = @results.pop
  results << node.updated(nil, nodes)
end

#on_volatile(node) ⇒ Object Also known as: on_name, on_id

Handles the top-level flow nodes


19
20
21
# File 'lib/origen_testers/atp/processors/flattener.rb', line 19

def on_volatile(node)
  results << node
end

#resultsObject


53
54
55
# File 'lib/origen_testers/atp/processors/flattener.rb', line 53

def results
  @results.last
end

#run(node) ⇒ Object


7
8
9
10
11
12
# File 'lib/origen_testers/atp/processors/flattener.rb', line 7

def run(node)
  @results = [[]]
  @conditions = []
  process(node)
  node.updated(:flow, results)
end

#wrap_with_current_conditions(node) ⇒ Object


46
47
48
49
50
51
# File 'lib/origen_testers/atp/processors/flattener.rb', line 46

def wrap_with_current_conditions(node)
  @conditions.reverse_each do |condition|
    node = condition.updated(nil, condition.children + [node])
  end
  node
end