Class: Kumi::Core::Analyzer::MacroExpander

Inherits:
Object
  • Object
show all
Defined in:
lib/kumi/core/analyzer/macro_expander.rb

Overview

Takes a function’s ‘expand` template and pre-normalized NAST arguments, and recursively builds a new NAST tree representing the expansion.

Constant Summary collapse

NAST =
Kumi::Core::NAST

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(func, normalized_args, loc, errors) ⇒ MacroExpander

Returns a new instance of MacroExpander.



15
16
17
18
19
20
# File 'lib/kumi/core/analyzer/macro_expander.rb', line 15

def initialize(func, normalized_args, loc, errors)
  @func = func
  @normalized_args = normalized_args
  @loc = loc
  @errors = errors
end

Class Method Details

.expand(func, normalized_args, loc, errors) ⇒ Object



11
12
13
# File 'lib/kumi/core/analyzer/macro_expander.rb', line 11

def self.expand(func, normalized_args, loc, errors)
  new(func, normalized_args, loc, errors).expand
end

Instance Method Details

#expandObject



22
23
24
# File 'lib/kumi/core/analyzer/macro_expander.rb', line 22

def expand
  build_nast_node(@func.expand)
end