Class: MilkTea::AsyncRuntimeInstaller

Inherits:
Object
  • Object
show all
Defined in:
lib/milk_tea/core/async_runtime_installer.rb

Instance Method Summary collapse

Constructor Details

#initialize(resolve_module_path:, check_block:, bind_block:) ⇒ AsyncRuntimeInstaller

Returns a new instance of AsyncRuntimeInstaller.



5
6
7
8
9
# File 'lib/milk_tea/core/async_runtime_installer.rb', line 5

def initialize(resolve_module_path:, check_block:, bind_block:)
  @resolve_module_path = resolve_module_path
  @check_block = check_block
  @bind_block = bind_block
end

Instance Method Details

#install_async_runtime_dependency!(ast, modules, importer_path: nil, collecting_errors: false) ⇒ Object



11
12
13
14
15
16
17
18
# File 'lib/milk_tea/core/async_runtime_installer.rb', line 11

def install_async_runtime_dependency!(ast, modules, importer_path: nil, collecting_errors: false)
  return if modules.key?("std.async")
  return unless async_main_declared?(ast)

  import_path = @resolve_module_path.call("std.async", importer_path:)
  import_analysis = @check_block.call(import_path, collecting_errors)
  modules["std.async"] = @bind_block.call(import_analysis)
end