Class: Delorean::HashExpr

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

Instance Method Summary collapse

Instance Method Details

#check(context) ⇒ Object



817
818
819
# File 'lib/delorean/nodes.rb', line 817

def check(context, *)
  defined?(args) ? args.check(context) : []
end

#rewrite(context) ⇒ Object



821
822
823
824
825
826
827
828
# File 'lib/delorean/nodes.rb', line 821

def rewrite(context)
  return '{}' unless defined?(args)
  return rewrite_with_literal(context) if can_be_literal?
  return rewrite_with_splat_optimisation(context) if can_optimise_splat?

  var = "_h#{context.hcount}"
  "(#{var}={}; #{args.rewrite(context, var)}; #{var})"
end