Module: IgniterLang::CompilerResult

Defined in:
lib/igniter_lang/compiler_result.rb

Class Method Summary collapse

Class Method Details

.ok(format_version:, semantic_ir:, source_path:, report:, igapp_path:, contracts:, runtime_smoke:) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/igniter_lang/compiler_result.rb', line 9

def ok(format_version:, semantic_ir:, source_path:, report:, igapp_path:, contracts:, runtime_smoke:)
  {
    "kind" => "compiler_result",
    "format_version" => format_version,
    "status" => "ok",
    "program_id" => semantic_ir.fetch("program_id"),
    "source_path" => source_path.to_s,
    "source_hash" => report.fetch("source_hash"),
    "grammar_version" => report.fetch("grammar_version"),
    "stages" => stages(report, assemble: "ok"),
    "igapp_path" => igapp_path.to_s,
    "compilation_report_ref" => report.fetch("program_id"),
    "semantic_ir_ref" => report.fetch("semantic_ir_ref"),
    "contracts" => contracts,
    "diagnostics" => [],
    "warnings" => Diagnostics.warnings(report.fetch("diagnostics", [])),
    "runtime_smoke" => runtime_smoke,
    "report" => report
  }
end

.public_result(result) ⇒ Object



69
70
71
# File 'lib/igniter_lang/compiler_result.rb', line 69

def public_result(result)
  result.reject { |key, _value| key == "report" }
end

.refusal(format_version:, status:, report:, source_path:, report_path:) ⇒ Object



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/igniter_lang/compiler_result.rb', line 30

def refusal(format_version:, status:, report:, source_path:, report_path:)
  diagnostics = report.fetch("diagnostics", [])
  {
    "kind" => "compiler_result",
    "format_version" => format_version,
    "status" => status,
    "program_id" => report.fetch("semantic_ir_ref", nil),
    "source_path" => source_path.to_s,
    "source_hash" => report.fetch("source_hash", nil),
    "grammar_version" => report.fetch("grammar_version", nil),
    "stages" => stages(report, assemble: "skipped"),
    "igapp_path" => nil,
    "contracts" => [],
    "compilation_report_path" => report_path.to_s,
    "diagnostics" => Diagnostics.errors(diagnostics),
    "warnings" => Diagnostics.warnings(diagnostics),
    "report" => report
  }
end

.stages(report, assemble:) ⇒ Object



73
74
75
# File 'lib/igniter_lang/compiler_result.rb', line 73

def stages(report, assemble:)
  report.fetch("stages").merge("assemble" => assemble)
end

.strict_terminal(format_version:, status:, report:, source_path:, diagnostics:) ⇒ Object



50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/igniter_lang/compiler_result.rb', line 50

def strict_terminal(format_version:, status:, report:, source_path:, diagnostics:)
  {
    "kind" => "compiler_result",
    "format_version" => format_version,
    "status" => status,
    "program_id" => report.fetch("semantic_ir_ref", nil),
    "source_path" => source_path.to_s,
    "source_hash" => report.fetch("source_hash", nil),
    "grammar_version" => report.fetch("grammar_version", nil),
    "stages" => stages(report, assemble: "skipped"),
    "igapp_path" => nil,
    "contracts" => [],
    "compilation_report_path" => nil,
    "diagnostics" => diagnostics,
    "warnings" => Diagnostics.warnings(report.fetch("diagnostics", [])),
    "report" => report
  }
end