Class: Ibex::IR::ParserContract::Entry
- Inherits:
-
Object
- Object
- Ibex::IR::ParserContract::Entry
- Defined in:
- lib/ibex/ir/parser_contract.rb
Overview
One specified or explicitly unspecified contract field.
Instance Attribute Summary collapse
-
#explicit ⇒ Object
readonly
: bool.
-
#key ⇒ Object
readonly
: Symbol.
-
#location ⇒ Object
readonly
: Location?.
-
#value ⇒ Object
readonly
: Symbol?.
Instance Method Summary collapse
-
#initialize(key, value: nil, location: nil, explicit: false) ⇒ Entry
constructor
A new instance of Entry.
- #to_h ⇒ Object
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
#explicit ⇒ Object (readonly)
: bool
23 24 25 |
# File 'lib/ibex/ir/parser_contract.rb', line 23 def explicit @explicit end |
#key ⇒ Object (readonly)
: Symbol
20 21 22 |
# File 'lib/ibex/ir/parser_contract.rb', line 20 def key @key end |
#location ⇒ Object (readonly)
: Location?
22 23 24 |
# File 'lib/ibex/ir/parser_contract.rb', line 22 def location @location end |
#value ⇒ Object (readonly)
: Symbol?
21 22 23 |
# File 'lib/ibex/ir/parser_contract.rb', line 21 def value @value end |
Instance Method Details
#to_h ⇒ Object
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 |