Class: Ibex::BisonImport::Result
- Inherits:
-
Object
- Object
- Ibex::BisonImport::Result
- Defined in:
- lib/ibex/bison_import.rb
Overview
Immutable source artifact and versioned analysis report.
Instance Attribute Summary collapse
-
#actions ⇒ Object
readonly
: Array.
-
#bounds ⇒ Object
readonly
: Hash[Symbol, Integer].
-
#class_name ⇒ Object
readonly
: String.
-
#directives ⇒ Object
readonly
: Array.
-
#file ⇒ Object
readonly
: String.
-
#rule_count ⇒ Object
readonly
: Integer.
-
#source ⇒ Object
readonly
: String.
Instance Method Summary collapse
-
#initialize(source:, file:, class_name:, directives:, actions:, rule_count:, bounds:) ⇒ Result
constructor
A new instance of Result.
- #structural_unsupported ⇒ Object
- #structurally_complete? ⇒ Boolean
- #to_h ⇒ 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 ⇒ Object (readonly)
: Array
132 133 134 |
# File 'lib/ibex/bison_import.rb', line 132 def actions @actions end |
#bounds ⇒ Object (readonly)
: Hash[Symbol, Integer]
134 135 136 |
# File 'lib/ibex/bison_import.rb', line 134 def bounds @bounds end |
#class_name ⇒ Object (readonly)
: String
130 131 132 |
# File 'lib/ibex/bison_import.rb', line 130 def class_name @class_name end |
#directives ⇒ Object (readonly)
: Array
131 132 133 |
# File 'lib/ibex/bison_import.rb', line 131 def directives @directives end |
#file ⇒ Object (readonly)
: String
129 130 131 |
# File 'lib/ibex/bison_import.rb', line 129 def file @file end |
#rule_count ⇒ Object (readonly)
: Integer
133 134 135 |
# File 'lib/ibex/bison_import.rb', line 133 def rule_count @rule_count end |
#source ⇒ Object (readonly)
: String
128 129 130 |
# File 'lib/ibex/bison_import.rb', line 128 def source @source end |
Instance Method Details
#structural_unsupported ⇒ Object
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 ⇒ 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 |