Class: Kapusta::Compiler::MacroExpander

Inherits:
Object
  • Object
show all
Defined in:
lib/kapusta/compiler/macro_expander.rb

Defined Under Namespace

Classes: Error, Lowering

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeMacroExpander

Returns a new instance of MacroExpander.



22
23
24
# File 'lib/kapusta/compiler/macro_expander.rb', line 22

def initialize
  @macros = {}
end

Class Method Details

.fresh_gensym(prefix) ⇒ Object



11
12
13
14
# File 'lib/kapusta/compiler/macro_expander.rb', line 11

def fresh_gensym(prefix)
  @gensym_counter += 1
  GeneratedSym.new("#{prefix}_g#{@gensym_counter}", @gensym_counter)
end

.fresh_local_gensym(prefix) ⇒ Object



16
17
18
19
# File 'lib/kapusta/compiler/macro_expander.rb', line 16

def fresh_local_gensym(prefix)
  @gensym_counter += 1
  GeneratedSym.new("#{prefix}_local_#{@gensym_counter}", @gensym_counter)
end

Instance Method Details

#expand_all(forms) ⇒ Object



26
27
28
# File 'lib/kapusta/compiler/macro_expander.rb', line 26

def expand_all(forms)
  forms.flat_map { |form| expand_top(form) }
end