Class: OrigenTesters::ATP::Validators::Flags

Inherits:
OrigenTesters::ATP::Validator show all
Defined in:
lib/origen_testers/atp/validators/flags.rb

Instance Attribute Summary

Attributes inherited from OrigenTesters::ATP::Validator

#flow

Instance Method Summary collapse

Methods inherited from OrigenTesters::ATP::Validator

#error, #initialize, #process, #test_process, testing, testing=

Methods inherited from Processor

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

Constructor Details

This class inherits a constructor from OrigenTesters::ATP::Validator

Instance Method Details

#on_completionObject



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/origen_testers/atp/validators/flags.rb', line 10

def on_completion
  failed = false
  unless @conflicting.empty?
    error 'if_flag and unless_flag conditions cannot be nested and refer to the same flag unless it is declared as volatile'
    error "The following conflicts were found in flow #{flow.name}:"
    @conflicting.each do |a, b|
      a_condition = a.to_a[1] ? 'if_job:    ' : 'unless_job:'
      b_condition = b.to_a[1] ? 'if_job:    ' : 'unless_job:'
      error "  #{a.type}(#{a.to_a[0]}) #{a.source}"
      error "  #{b.type}(#{b.to_a[0]}) #{b.source}"
      error ''
    end
    failed = true
  end
  failed
end

#on_flow(node) ⇒ Object



27
28
29
30
# File 'lib/origen_testers/atp/validators/flags.rb', line 27

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

#on_if_flag(node) ⇒ Object



32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/origen_testers/atp/validators/flags.rb', line 32

def on_if_flag(node)
  if volatile?(node.to_a[0])
    process_all(node.children)
  else
    if n = @open_unless_nodes.find { |n| n.to_a[0] == node.to_a[0] }
      @conflicting << [n, node]
    end
    @open_if_nodes << node
    process_all(node.children)
    @open_if_nodes.pop
  end
end

#on_unless_flag(node) ⇒ Object



45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/origen_testers/atp/validators/flags.rb', line 45

def on_unless_flag(node)
  if volatile?(node.to_a[0])
    process_all(node.children)
  else
    if n = @open_if_nodes.find { |n| n.to_a[0] == node.to_a[0] }
      @conflicting << [n, node]
    end
    @open_unless_nodes << node
    process_all(node.children)
    @open_unless_nodes.pop
  end
end

#setupObject



4
5
6
7
8
# File 'lib/origen_testers/atp/validators/flags.rb', line 4

def setup
  @open_if_nodes = []
  @open_unless_nodes = []
  @conflicting = []
end