Class: Ibex::IR::ParserContract::Entry

Inherits:
Object
  • Object
show all
Defined in:
lib/ibex/ir/parser_contract.rb

Overview

One specified or explicitly unspecified contract field.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(key, value: nil, location: nil, explicit: false) ⇒ Entry

Returns a new instance of Entry.



26
27
28
29
30
31
32
33
34
35
# File 'lib/ibex/ir/parser_contract.rb', line 26

def initialize(key, value: nil, location: nil, explicit: false)
  definition = DEFINITIONS.fetch(key) { raise ArgumentError, "unknown parser contract key #{key.inspect}" }
  validate_state!(key, definition.fetch(:values), value, location, explicit)

  @key = key
  @value = value
  @location = location
  @explicit = explicit
  freeze
end

Instance Attribute Details

#explicitObject (readonly)

: bool



23
24
25
# File 'lib/ibex/ir/parser_contract.rb', line 23

def explicit
  @explicit
end

#keyObject (readonly)

: Symbol



20
21
22
# File 'lib/ibex/ir/parser_contract.rb', line 20

def key
  @key
end

#locationObject (readonly)

: Location?



22
23
24
# File 'lib/ibex/ir/parser_contract.rb', line 22

def location
  @location
end

#valueObject (readonly)

: Symbol?



21
22
23
# File 'lib/ibex/ir/parser_contract.rb', line 21

def value
  @value
end

Instance Method Details

#to_hObject



38
39
40
# File 'lib/ibex/ir/parser_contract.rb', line 38

def to_h
  { value: @value&.to_s, explicit: @explicit, loc: serialized_location }
end