Class: OrigenTesters::Decompiler::Pattern::VectorDelimiterBase

Inherits:
Object
  • Object
show all
Defined in:
lib/origen_testers/decompiler/pattern/vector_delimiter_base.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(parent) ⇒ VectorDelimiterBase

Returns a new instance of VectorDelimiterBase.



8
9
10
11
12
13
14
# File 'lib/origen_testers/decompiler/pattern/vector_delimiter_base.rb', line 8

def initialize(parent)
  @current_vector = []
  @delimited = false
  @in_comment_block = false

  @parent = parent
end

Instance Attribute Details

#current_vectorObject (readonly)

Returns the value of attribute current_vector.



5
6
7
# File 'lib/origen_testers/decompiler/pattern/vector_delimiter_base.rb', line 5

def current_vector
  @current_vector
end

#parentObject (readonly)

Returns the value of attribute parent.



6
7
8
# File 'lib/origen_testers/decompiler/pattern/vector_delimiter_base.rb', line 6

def parent
  @parent
end

Instance Method Details

#comment_startObject



16
17
18
# File 'lib/origen_testers/decompiler/pattern/vector_delimiter_base.rb', line 16

def comment_start
  parent.comment_start
end

#current_vector!Object



56
57
58
# File 'lib/origen_testers/decompiler/pattern/vector_delimiter_base.rb', line 56

def current_vector!
  current_vector.join('')
end

#delimited?Boolean

Returns:

  • (Boolean)


60
61
62
# File 'lib/origen_testers/decompiler/pattern/vector_delimiter_base.rb', line 60

def delimited?
  @delimited
end

#in_comment_block?Boolean

Returns:

  • (Boolean)


20
21
22
# File 'lib/origen_testers/decompiler/pattern/vector_delimiter_base.rb', line 20

def in_comment_block?
  @in_comment_block
end

#include_last_line?Boolean

Returns:

  • (Boolean)


64
65
66
# File 'lib/origen_testers/decompiler/pattern/vector_delimiter_base.rb', line 64

def include_last_line?
  @include_last_line
end

#shift(line) ⇒ Object



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/origen_testers/decompiler/pattern/vector_delimiter_base.rb', line 24

def shift(line)
  if @in_comment_block
    if !line.strip.start_with?(comment_start)
      # End of the comment block.
      # Signal that this vector is over, but don't include the
      # newly shifted line.
      @delimited = true
      @include_last_line = false
    else
      @current_vector << line
    end
  else
    if current_vector.empty? && line.strip.start_with?(comment_start)
      # Currently in an empty vector and encountered a comment.
      # Start a new comment block.
      @in_comment_block = true
      @current_vector << line
    elsif !current_vector.empty? && line.strip.start_with?(comment_start)
      # Not in an empty vector, but not in a comment block.
      # Signal the end of this vector and start a new one with
      # this vector.
      @delimited = true
      @include_last_line = false
    else
      # Standard single vector
      @delimited = true
      @include_last_line = true
      @current_vector << line
    end
  end
end