Class: Delorean::HashExpr

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

Instance Method Summary collapse

Instance Method Details

#check(context) ⇒ Object



775
776
777
# File 'lib/delorean/nodes.rb', line 775

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

#rewrite(context) ⇒ Object



779
780
781
782
783
784
785
786
# File 'lib/delorean/nodes.rb', line 779

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