Class: Highway::Compiler::Build::Builder

Inherits:
Object
  • Object
show all
Defined in:
lib/highway/compiler/build/builder.rb

Overview

This class is responsible for manifest generation based on the semantic tree. This is the third and final phase of the compiler.

Instance Method Summary collapse

Constructor Details

#initialize(interface:) ⇒ Builder

Initialize an instance.

Parameters:



23
24
25
# File 'lib/highway/compiler/build/builder.rb', line 23

def initialize(interface:)
  @interface = interface
end

Instance Method Details

#build(sema_tree:, preset:) ⇒ Object

Build the manifst.

The builder resolves variables and steps in the semantic tree for given preset and builds concrete invocations.

The builder produces a manifest that is later executed by runner.

return [Highway::Compiler::Build::Output::Manifest]

Parameters:



37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/highway/compiler/build/builder.rb', line 37

def build(sema_tree:, preset:)

  manifest = Build::Output::Manifest.new()

  manifest.preset = preset

  variables = resolve_variables(sema_tree: sema_tree, preset: preset)
  steps = resolve_steps(sema_tree: sema_tree, preset: preset)

  build_invocations(stages: sema_tree.stages, variables: variables, steps: steps, manifest: manifest)

  manifest

end