Class: OrigenTesters::Decompiler::Pattern::VectorBodyElement

Inherits:
Base
  • Object
show all
Defined in:
lib/origen_testers/decompiler/pattern/elements/vector_body_element.rb

Constant Summary collapse

BASE_ELEMENTS =

The known vector element types, supported regardless of the tester/platform.

[:vector, :comment_block]

Instance Attribute Summary collapse

Attributes inherited from Base

#context, #node

Instance Method Summary collapse

Methods inherited from Base

#[], #execute!, #method_missing, #pinlist, #platform_nodes

Constructor Details

#initialize(node:, context:, **options) ⇒ VectorBodyElement

Returns a new instance of VectorBodyElement



14
15
16
17
18
19
20
21
22
23
24
# File 'lib/origen_testers/decompiler/pattern/elements/vector_body_element.rb', line 14

def initialize(node:, context:, **options)
  @source = :vector_body_element
  super(node: node, context: context)
  @type = node.type
  @vector_index = options[:vector_index]

  # If the processor is a :vector or a comment_block, we can deal with
  # this automatically. We also know that neither of these elemnts are
  # platform specific.
  @element = (BASE_ELEMENTS.include?(type)) ? to_element : false
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class OrigenTesters::Decompiler::Pattern::Base

Instance Attribute Details

#elementObject (readonly)

Returns the value of attribute element



11
12
13
# File 'lib/origen_testers/decompiler/pattern/elements/vector_body_element.rb', line 11

def element
  @element
end

#typeObject (readonly)

Returns the value of attribute type



10
11
12
# File 'lib/origen_testers/decompiler/pattern/elements/vector_body_element.rb', line 10

def type
  @type
end

#vector_indexObject (readonly)

Returns the value of attribute vector_index



12
13
14
# File 'lib/origen_testers/decompiler/pattern/elements/vector_body_element.rb', line 12

def vector_index
  @vector_index
end

Instance Method Details

#decompilerObject



78
79
80
# File 'lib/origen_testers/decompiler/pattern/elements/vector_body_element.rb', line 78

def decompiler
  decompiled_pattern.platform
end

#decompiler?(d = nil) ⇒ Boolean

Returns:

  • (Boolean)


82
83
84
# File 'lib/origen_testers/decompiler/pattern/elements/vector_body_element.rb', line 82

def decompiler?(d = nil)
  decompiled_pattern.decompiler?(d)
end

#is_a_comment?Boolean Also known as: is_comment?

Returns:

  • (Boolean)


86
87
88
# File 'lib/origen_testers/decompiler/pattern/elements/vector_body_element.rb', line 86

def is_a_comment?
  type == :comment || type == :comment_block
end

#is_a_vector?Boolean Also known as: is_vector?, vector?

Returns:

  • (Boolean)


62
63
64
# File 'lib/origen_testers/decompiler/pattern/elements/vector_body_element.rb', line 62

def is_a_vector?
  type == :vector
end

#is_tester_specific?Boolean Also known as: is_tester_specific_element?, is_platform_specific?, is_platform_specific_element?, is_decompiler_specific?, is_decompiler_specific_element?, is_a_tester_specific_element?, is_a_platform_specific_element?, is_a_decompiler_specific_element?

Returns:

  • (Boolean)


91
92
93
# File 'lib/origen_testers/decompiler/pattern/elements/vector_body_element.rb', line 91

def is_tester_specific?
  platform_nodes.include?(type)
end

#platformObject Also known as: tester



68
69
70
# File 'lib/origen_testers/decompiler/pattern/elements/vector_body_element.rb', line 68

def platform
  decompiled_pattern.platform
end

#platform?(p = nil) ⇒ Boolean Also known as: tester?

Returns:

  • (Boolean)


73
74
75
# File 'lib/origen_testers/decompiler/pattern/elements/vector_body_element.rb', line 73

def platform?(p = nil)
  decompiled_pattern.platform?(p)
end

#to_elementObject

Note:

Calling this not required, as this is just an interface to a known processor type.

Returns an element class (e.g., Vector) that casts itself to a known vector-element type. For example, if this element's processor is a 'vector', then it can cast itself to a Vector class,

to expose functionality (e.g., #timeset) on the class itself. Otherwise, the functionality will remain
on the processor and its up to the user to know what the processor has.


31
32
33
34
35
36
37
38
39
# File 'lib/origen_testers/decompiler/pattern/elements/vector_body_element.rb', line 31

def to_element
  if type == :comment_block
    CommentBlock.new(self)
  elsif type == :vector
    Vector.new(self)
  else
    fail "Could not cast platform-specific vector body element type :#{type} to a standalone class!"
  end
end

#to_yaml_hash(options = {}) ⇒ Object



41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/origen_testers/decompiler/pattern/elements/vector_body_element.rb', line 41

def to_yaml_hash(options = {})
  {
    class:        self.class.to_s,
    vector_index: vector_index
  }.merge(
    begin
      if element
        element.to_yaml_hash(options)
      else
        # If this element couldn't be matched, provide a simple yaml hash
        # including some basic elements.
        {
          type:           type,
          processor:      processor.class.to_s,
          platform_nodes: _platform_nodes_
        }
      end
    end
  )
end