Class: Macro::MethodNode

Inherits:
Object show all
Defined in:
lib/macro.rb

Overview

postpone macro expansion in methods til method defn is executed

Instance Method Summary collapse

Instance Method Details

#macro_expand(macros, session) ⇒ Object



599
600
601
602
603
604
605
606
607
608
# File 'lib/macro.rb', line 599

def macro_expand(macros,session)
  expand=proc{|x| Node===x ? Macro.expand(x,macros,session) : x}
  self.receiver= expand[receiver]
  args.map!( &expand )if args
  self.body= expand[body]
  rescues.map!( &expand )if rescues
  self.ensure_= expand[ensure_]
  self.else_= expand[else_]
  return self,false
end

#old_macro_expand(macros, session) ⇒ Object



583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
# File 'lib/macro.rb', line 583

def old_macro_expand(macros,session)
  if session[:@expand_in_defs]
    session[:@expand_in_defs]=false
      expand=proc{|x| Node===x ? Macro.expand(x,macros,session) : x}
      self.receiver= expand[receiver]
      args.map!( &expand )if args
      self.body= expand[body]
      rescues.map!( &expand )if rescues
      self.ensure_= expand[ensure_]
      self.else_= expand[else_]
    session[:@expand_in_defs]=true
    return self,false
  else
    return Macro.postpone(self,session),false
  end
end