Class: Ibex::BisonImport::Result
- Inherits:
-
Object
- Object
- Ibex::BisonImport::Result
- Defined in:
- lib/ibex/bison_import.rb,
sig/ibex/bison_import.rbs
Overview
Immutable source artifact and versioned analysis report.
Instance Attribute Summary collapse
- #actions ⇒ Array[Action] readonly
- #bounds ⇒ Hash[Symbol, Integer] readonly
- #class_name ⇒ String readonly
- #directives ⇒ Array[Directive] readonly
- #file ⇒ String readonly
- #rule_count ⇒ Integer readonly
- #source ⇒ String readonly
Instance Method Summary collapse
-
#initialize(source:, file:, class_name:, directives:, actions:, rule_count:, bounds:) ⇒ Result
constructor
A new instance of Result.
- #structural_unsupported ⇒ Array[Directive]
- #structurally_complete? ⇒ Boolean
- #to_h ⇒ Hash[Symbol, Object?]
Constructor Details
#initialize(source:, file:, class_name:, directives:, actions:, rule_count:, bounds:) ⇒ Result
Returns a new instance of Result.
138 139 140 141 142 143 144 145 146 147 |
# File 'lib/ibex/bison_import.rb', line 138 def initialize(source:, file:, class_name:, directives:, actions:, rule_count:, bounds:) @source = source.freeze @file = file.freeze @class_name = class_name.freeze @directives = directives.freeze @actions = actions.freeze @rule_count = rule_count @bounds = IR.deep_freeze(bounds) freeze end |
Instance Attribute Details
#actions ⇒ Array[Action] (readonly)
132 133 134 |
# File 'lib/ibex/bison_import.rb', line 132 def actions @actions end |
#bounds ⇒ Hash[Symbol, Integer] (readonly)
134 135 136 |
# File 'lib/ibex/bison_import.rb', line 134 def bounds @bounds end |
#class_name ⇒ String (readonly)
130 131 132 |
# File 'lib/ibex/bison_import.rb', line 130 def class_name @class_name end |
#directives ⇒ Array[Directive] (readonly)
131 132 133 |
# File 'lib/ibex/bison_import.rb', line 131 def directives @directives end |
#file ⇒ String (readonly)
129 130 131 |
# File 'lib/ibex/bison_import.rb', line 129 def file @file end |
#rule_count ⇒ Integer (readonly)
133 134 135 |
# File 'lib/ibex/bison_import.rb', line 133 def rule_count @rule_count end |
#source ⇒ String (readonly)
128 129 130 |
# File 'lib/ibex/bison_import.rb', line 128 def source @source end |
Instance Method Details
#structural_unsupported ⇒ Array[Directive]
178 179 180 181 182 183 |
# File 'lib/ibex/bison_import.rb', line 178 def structural_unsupported @directives.select do |directive| directive.status == :unsupported && !STRUCTURE_NEUTRAL_UNSUPPORTED.include?(directive.name) end end |
#structurally_complete? ⇒ Boolean
186 187 188 |
# File 'lib/ibex/bison_import.rb', line 186 def structurally_complete? structural_unsupported.empty? end |
#to_h ⇒ Hash[Symbol, Object?]
150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 |
# File 'lib/ibex/bison_import.rb', line 150 def to_h unsupported = @directives.select { |directive| directive.status == :unsupported } structural = structural_unsupported { ibex_report: "bison_import", schema_version: 1, result: unsupported.empty? ? "imported" : "imported_with_unsupported", file: @file, class_name: @class_name, generated_source: @source, directive_contract: DIRECTIVES.sort.to_h, directives: @directives.map(&:to_h), unsupported: unsupported.map(&:to_h), structurally_complete: structural.empty?, structural_unsupported: structural.map(&:to_h), actions: @actions.map(&:to_h), counts: { rules: @rule_count, actions: @actions.length, unsupported_directives: unsupported.length, structural_unsupported_directives: structural.length }, bounds: @bounds, statement: "C semantic actions are opaque analysis data; Ruby generation is refused." } end |