Class: SlowBlink::Field
- Inherits:
-
Object
- Object
- SlowBlink::Field
- Defined in:
- lib/slow_blink/field.rb
Instance Attribute Summary collapse
- #id ⇒ Object readonly
-
#location ⇒ String
readonly
Location string formatted as: [ FILENAME, ':' ], LINE_NUMBER, ':', COLUMN_NUMBER.
- #name ⇒ Object readonly
Instance Method Summary collapse
Instance Attribute Details
#id ⇒ Object (readonly)
28 29 30 |
# File 'lib/slow_blink/field.rb', line 28 def id @id end |
#location ⇒ String (readonly)
Location string formatted as: [ FILENAME, ':' ], LINE_NUMBER, ':', COLUMN_NUMBER
34 35 36 |
# File 'lib/slow_blink/field.rb', line 34 def location @location end |
#name ⇒ Object (readonly)
31 32 33 |
# File 'lib/slow_blink/field.rb', line 31 def name @name end |
Instance Method Details
#optional? ⇒ true, false
88 89 90 |
# File 'lib/slow_blink/field.rb', line 88 def optional? @optional end |
#type ⇒ Type
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 |
# File 'lib/slow_blink/field.rb', line 37 def type result = nil if @type.is_a? REF ptr = @type.resolve stack = [] sequence = @type.sequence? dynamic = @type.dynamic? while ptr and ptr.is_a? Definition and ptr.type.is_a? REF do if stack.include? ptr raise ParseError.new "#{ptr.location}: circular reference detected" else if ptr.type.dynamic? # assumption: double dynamic is still dynamic dynamic = true end if ptr.type.sequence? if sequence raise ParseError.new "#{ptr.location}: sequence of sequences detected while resolving from '#{@type.location}'" end sequence = true end stack << ptr ptr = ptr.type.resolve end end if ptr.nil? if stack.size == 0 stack << @type end raise ParseError.new "#{stack.last.location}: reference does not resolve" elsif ptr.is_a? Group if dynamic result = DynamicGroup.new(:group => ptr, :sequence => sequence, :table => @table) else result = StaticGroup.new(:group => ptr, :sequence => sequence, :table => @table) end else result = ptr.type end else result = @type end result end |