Class: CloudflareWorkers::AutoAwait::Analyzer

Inherits:
Object
  • Object
show all
Defined in:
lib/cloudflare_workers/auto_await/analyzer.rb

Instance Method Summary collapse

Constructor Details

#initialize(registry, debug: false) ⇒ Analyzer

Returns a new instance of Analyzer.



10
11
12
13
14
15
16
17
# File 'lib/cloudflare_workers/auto_await/analyzer.rb', line 10

def initialize(registry, debug: false)
  @registry = registry
  @debug = debug
  @await_nodes = []
  @env = {}
  @method_returns = {}
  @async_local_methods = Set.new
end

Instance Method Details

#process(source, filename = '(auto-await)') ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/cloudflare_workers/auto_await/analyzer.rb', line 19

def process(source, filename = '(auto-await)')
  buffer = Parser::Source::Buffer.new(filename)
  buffer.source = source
  parser = Parser::CurrentRuby.new
  ast = parser.parse(buffer)
  @method_returns = {}
  @async_local_methods = Set.new

  analyze_pass(ast)
  analyze_pass(ast)
  [buffer, @await_nodes]
end