Class: Kumi::Core::Analyzer::Passes::LIR::InlineDeclarationsPass

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

Defined Under Namespace

Classes: Env, GammaInfo, Hoist

Constant Summary collapse

LIR =
Kumi::Core::LIR
MAX_PASSES =
30

Instance Method Summary collapse

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



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/kumi/core/analyzer/passes/lir/inline_declarations_pass.rb', line 12

def run(_errors)
  current_ops = get_state(:lir_module)
  @ids        = get_state(:id_generator)

  MAX_PASSES.times do
    new_ops, changed = run_one_pass(current_ops)
    unless changed
      new_ops.freeze
      return state.with(:lir_module, new_ops)
                  .with(:lir_02_inlined_ops_by_decl, new_ops)
    end
    current_ops = new_ops
  end
  raise "LIR inlining did not converge after #{MAX_PASSES} passes."
end