Class: Ibex::VerificationReport::CanonicalIR

Inherits:
Object
  • Object
show all
Defined in:
lib/ibex/verification_report/canonical_ir.rb

Overview

Rebuilds immutable IR with source locations expressed as report logical identities.

Constant Summary collapse

LOGICAL_ROOT =

@rbs! type json_value = String | Integer | Float | bool | nil | Array | Hash[json_value, json_value]

"input"

Instance Method Summary collapse

Constructor Details

#initialize(automaton, source_records:) ⇒ CanonicalIR

Returns a new instance of CanonicalIR.

Raises:

  • (ArgumentError)


17
18
19
20
21
22
23
24
25
26
27
# File 'lib/ibex/verification_report/canonical_ir.rb', line 17

def initialize(automaton, source_records:)
  raise ArgumentError, "source_records must not be empty" if source_records.empty?
  if source_records.length > LogicalPath::MAX_INPUT_FILES
    raise ArgumentError, "verification reports support at most #{LogicalPath::MAX_INPUT_FILES} input files"
  end

  @automaton = automaton
  @logical_files = source_records.map.with_index do |record, index|
    [record, LogicalPath.input(record.path, index)]
  end
end

Instance Method Details

#buildObject

Raises:

  • (ArgumentError)


30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/ibex/verification_report/canonical_ir.rb', line 30

def build
  document = JSON.parse(IR::Serialize.dump(@automaton))
  normalize_source_identity!(document)
  grammar = IR::Validator.validate(generate_json(document.fetch("grammar")))
  raise ArgumentError, "canonical bundle grammar did not validate" unless grammar.is_a?(IR::Grammar)

  document["grammar_digest"] = digest(grammar)
  automaton = IR::Validator.validate(generate_json(document))
  raise ArgumentError, "canonical bundle automaton did not validate" unless automaton.is_a?(IR::Automaton)

  automaton
end