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, :unset_flags, :add_flags,
:set_flags_extern, :unset_flags_extern, :add_flags_extern,
:referenced_enables, :set_enables]

Instance Method Summary collapse

Methods inherited from 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_add_flag(node) ⇒ Object



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

def on_add_flag(node)
  add generate_flag_name(node.value), :add_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), :add_flags_extern
  end
end

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



101
102
103
104
# File 'lib/origen_testers/smartest_based_tester/base/processors/extract_flow_vars.rb', line 101

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

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



92
93
94
95
96
97
98
# File 'lib/origen_testers/smartest_based_tester/base/processors/extract_flow_vars.rb', line 92

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



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

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



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

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

#on_set(node) ⇒ Object



107
108
109
110
# File 'lib/origen_testers/smartest_based_tester/base/processors/extract_flow_vars.rb', line 107

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

#on_set_flag(node) ⇒ Object



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

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



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

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

#on_unset_flag(node) ⇒ Object



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

def on_unset_flag(node)
  add generate_flag_name(node.value), :unset_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), :unset_flags_extern
  end
end

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



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

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