Class: OrigenTesters::SmartestBasedTester::Base::Processors::ExtractFlowVars

Inherits:
ATP::Processor
  • Object
show all
Defined in:
lib/origen_testers/smartest_based_tester/base/processors/extract_flow_vars.rb

Overview

Returns an array containing all runtime control variables from the given AST node and their default values

Constant Summary collapse

OWNERS =
[:all, :this_flow, :sub_flows]
CATEGORIES =
[:jobs, :referenced_flags, :set_flags, :set_flags_extern,
:referenced_enables, :set_enables]

Instance Method Summary collapse

Methods inherited from ATP::Processor

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

Instance Method Details

#on_enable(node) ⇒ Object Also known as: on_disable



84
85
86
87
# File 'lib/origen_testers/smartest_based_tester/base/processors/extract_flow_vars.rb', line 84

def on_enable(node)
  flag = node.value.upcase
  add flag, :set_enables
end

#on_if_enabled(node) ⇒ Object Also known as: on_unless_enabled



75
76
77
78
79
80
81
# File 'lib/origen_testers/smartest_based_tester/base/processors/extract_flow_vars.rb', line 75

def on_if_enabled(node)
  flag, *nodes = *node
  [flag].flatten.each do |f|
    add generate_flag_name(f), :referenced_enables
  end
  process_all(nodes)
end

#on_if_flag(node) ⇒ Object Also known as: on_unless_flag



58
59
60
61
62
63
64
# File 'lib/origen_testers/smartest_based_tester/base/processors/extract_flow_vars.rb', line 58

def on_if_flag(node)
  flag, *nodes = *node
  [flag].flatten.each do |f|
    add generate_flag_name(f), :referenced_flags
  end
  process_all(nodes)
end

#on_if_job(node) ⇒ Object Also known as: on_unless_job



52
53
54
55
# File 'lib/origen_testers/smartest_based_tester/base/processors/extract_flow_vars.rb', line 52

def on_if_job(node)
  add ['JOB', ''], :jobs
  process_all(node.children)
end

#on_set(node) ⇒ Object



90
91
92
93
# File 'lib/origen_testers/smartest_based_tester/base/processors/extract_flow_vars.rb', line 90

def on_set(node)
  flag = generate_flag_name(node.to_a[0])
  add flag, :set_enables
end

#on_set_flag(node) ⇒ Object



67
68
69
70
71
72
73
# File 'lib/origen_testers/smartest_based_tester/base/processors/extract_flow_vars.rb', line 67

def on_set_flag(node)
  add generate_flag_name(node.value), :set_flags
  # Also separate flags which have been set and which should be externally visible
  if !node.to_a.include?('auto_generated') || node.to_a.include?('extern')
    add generate_flag_name(node.value), :set_flags_extern
  end
end

#on_sub_flow(node) ⇒ Object



39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/origen_testers/smartest_based_tester/base/processors/extract_flow_vars.rb', line 39

def on_sub_flow(node)
  @sub_flow_depth += 1
  children = node.children
  on_fail = node.find_all(:on_fail)
  children -= on_fail
  on_pass = node.find_all(:on_pass)
  children -= on_pass
  process_all(children)
  @sub_flow_depth -= 1
  process_all(on_fail)
  process_all(on_pass)
end

#run(node, options = {}) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/origen_testers/smartest_based_tester/base/processors/extract_flow_vars.rb', line 13

def run(node, options = {})
  @variables = {}
  @variables[:empty?] = true
  OWNERS.each do |t|
    @variables[t] = {}
    CATEGORIES.each { |c| @variables[t][c] = Set.new }
  end
  @sub_flow_depth = 0
  process(node)
  OWNERS.each do |t|
    CATEGORIES.each do |c|
      curr_vars = @variables[t][c].to_a.dup
      flag_classes = curr_vars.map(&:class)
      if flag_classes.include?(String) && flag_classes.include?(Symbol)
        curr_vars.map!(&:to_s)
      end
      @variables[t][c] = curr_vars.sort do |x, y|
        x = x[0] if x.is_a?(Array)
        y = y[0] if y.is_a?(Array)
        x <=> y
      end
    end
  end
  @variables
end