Class: Ibex::BisonImport::Result

Inherits:
Object
  • Object
show all
Defined in:
lib/ibex/bison_import.rb,
sig/ibex/bison_import.rbs

Overview

Immutable source artifact and versioned analysis report.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(source:, file:, class_name:, directives:, actions:, rule_count:, bounds:) ⇒ Result

Returns a new instance of Result.

RBS:

  • (source: String, file: String, class_name: String, directives: Array[Directive], actions: Array[Action], rule_count: Integer, bounds: Hash[Symbol, Integer]) -> void

Parameters:

  • source: (String)
  • file: (String)
  • class_name: (String)
  • directives: (Array[Directive])
  • actions: (Array[Action])
  • rule_count: (Integer)
  • bounds: (Hash[Symbol, Integer])


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

#actionsArray[Action] (readonly)

Signature:

  • Array[Action]

Returns:



132
133
134
# File 'lib/ibex/bison_import.rb', line 132

def actions
  @actions
end

#boundsHash[Symbol, Integer] (readonly)

Signature:

  • Hash[Symbol, Integer]

Returns:

  • (Hash[Symbol, Integer])


134
135
136
# File 'lib/ibex/bison_import.rb', line 134

def bounds
  @bounds
end

#class_nameString (readonly)

Signature:

  • String

Returns:

  • (String)


130
131
132
# File 'lib/ibex/bison_import.rb', line 130

def class_name
  @class_name
end

#directivesArray[Directive] (readonly)

Signature:

  • Array[Directive]

Returns:



131
132
133
# File 'lib/ibex/bison_import.rb', line 131

def directives
  @directives
end

#fileString (readonly)

Signature:

  • String

Returns:

  • (String)


129
130
131
# File 'lib/ibex/bison_import.rb', line 129

def file
  @file
end

#rule_countInteger (readonly)

Signature:

  • Integer

Returns:

  • (Integer)


133
134
135
# File 'lib/ibex/bison_import.rb', line 133

def rule_count
  @rule_count
end

#sourceString (readonly)

Signature:

  • String

Returns:

  • (String)


128
129
130
# File 'lib/ibex/bison_import.rb', line 128

def source
  @source
end

Instance Method Details

#structural_unsupportedArray[Directive]

RBS:

  • () -> Array[Directive]

Returns:



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

RBS:

  • () -> bool

Returns:

  • (Boolean)


186
187
188
# File 'lib/ibex/bison_import.rb', line 186

def structurally_complete?
  structural_unsupported.empty?
end

#to_hHash[Symbol, Object?]

RBS:

  • () -> Hash[Symbol, Object?]

Returns:

  • (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