Class: Ibex::IR::Action

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

Overview

Opaque Ruby semantic action metadata.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(code:, location:, named_refs: [], context_length: 0, composition: nil) ⇒ Action

Returns a new instance of Action.



84
85
86
87
88
89
90
91
# File 'lib/ibex/ir/grammar_ir.rb', line 84

def initialize(code:, location:, named_refs: [], context_length: 0, composition: nil)
  @code = code.dup.freeze
  @location = IR.deep_freeze(location)
  @named_refs = IR.deep_freeze(named_refs)
  @context_length = context_length
  @composition = IR.deep_freeze(composition)
  freeze
end

Instance Attribute Details

#codeObject (readonly)

: String



76
77
78
# File 'lib/ibex/ir/grammar_ir.rb', line 76

def code
  @code
end

#compositionObject (readonly)

: action_composition?



80
81
82
# File 'lib/ibex/ir/grammar_ir.rb', line 80

def composition
  @composition
end

#context_lengthObject (readonly)

: Integer



79
80
81
# File 'lib/ibex/ir/grammar_ir.rb', line 79

def context_length
  @context_length
end

#locationObject (readonly)

: location



77
78
79
# File 'lib/ibex/ir/grammar_ir.rb', line 77

def location
  @location
end

#named_refsObject (readonly)

: Array



78
79
80
# File 'lib/ibex/ir/grammar_ir.rb', line 78

def named_refs
  @named_refs
end

Instance Method Details

#to_hObject



94
95
96
97
98
99
# File 'lib/ibex/ir/grammar_ir.rb', line 94

def to_h
  value = { code: @code, loc: @location, named_refs: @named_refs,
            context_length: @context_length } #: Hash[Symbol, Object?]
  value[:composition] = @composition
  value
end