Class: Kumi::Core::Analyzer::Passes::LIR::LowerPass

Inherits:
PassBase
  • Object
show all
Includes:
StencilEmitter
Defined in:
lib/kumi/core/analyzer/passes/lir/lower_pass.rb

Defined Under Namespace

Classes: Env

Constant Summary collapse

NAST =
Kumi::Core::NAST
Ids =
Kumi::Core::LIR::Ids
Build =
Kumi::Core::LIR::Build
Emit =
Kumi::Core::LIR::Emit

Instance Method Summary collapse

Methods included from StencilEmitter

#emit_roll, #emit_shift

Methods inherited from PassBase

#debug, #debug_enabled?, #initialize

Methods included from ErrorReporting

#inferred_location, #raise_localized_error, #raise_syntax_error, #raise_type_error, #report_enhanced_error, #report_error, #report_semantic_error, #report_syntax_error, #report_type_error

Constructor Details

This class inherits a constructor from Kumi::Core::Analyzer::Passes::PassBase

Instance Method Details

#run(_errors) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/kumi/core/analyzer/passes/lir/lower_pass.rb', line 14

def run(_errors)
  @snast    = get_state(:snast_module, required: true)
  @registry = get_state(:registry, required: true)
  @ids      = Ids.new
  @anchors  = get_state(:anchor_by_decl, required: true)
  @pre      = get_state(:precomputed_plan_by_fqn, required: true)
  plans     = get_state(:input_table, required: true)
  @plans_by_fqn = plans.each_with_object({}) { |p, h| h[p.path_fqn.to_s] = p }

  ops_by_decl = {}
  @snast.decls.each do |name, decl|
    @ops = []
    @env = Env.new
    @current_decl = decl
    lower_declaration(decl)
    ops_by_decl[name] = { operations: @ops }
  end

  ops_by_decl.freeze
  state.with(:lir_module, ops_by_decl)
       .with(:lir_00_unoptimized, ops_by_decl)
       .with(:id_generator, @ids)
end