Class: Delorean::HashArgs

Inherits:
SNode
  • Object
show all
Defined in:
lib/delorean/nodes.rb

Instance Method Summary collapse

Instance Method Details

#check(context) ⇒ Object



575
576
577
578
579
580
581
582
# File 'lib/delorean/nodes.rb', line 575

def check(context, *)
  [e0.check(context),
   (e1.check(context) unless defined?(splat)),
   (ifexp.e3.check(context) if defined?(ifexp.e3)),
   (args_rest.al.check(context) if
     defined?(args_rest.al) && !args_rest.al.empty?),
  ].compact.sum
end

#rewrite(context, var) ⇒ Object



584
585
586
587
588
589
590
591
592
593
594
595
# File 'lib/delorean/nodes.rb', line 584

def rewrite(context, var)
  res = if defined?(splat)
    "#{var}.merge!(#{e0.rewrite(context)})"
  else
    "#{var}[#{e0.rewrite(context)}]=(#{e1.rewrite(context)})"
  end
  res += " if (#{ifexp.e3.rewrite(context)})" if defined?(ifexp.e3)
  res += ";"
  res += args_rest.al.rewrite(context, var) if
    defined?(args_rest.al) && !args_rest.al.text_value.empty?
  res
end