class Opal::Rewriters::MlhsArgs

Rewrites

def m( (a, b), (c, d) )

body

end

To

def m($mlhs_tmp1, $mlhs_tmp2)

(a, b) = $mlhs_tmp1
(c, d) = $mlhs_tmp2
body

end

Public Instance Methods

on_def(node) click to toggle source
Calls superclass method
# File lib/opal/rewriters/mlhs_args.rb, line 22
def on_def(node)
  node = super(node)
  mid, args, body = *node

  arguments = Arguments.new(args)

  args = args.updated(nil, arguments.rewritten)
  if arguments.initialization
    body ||= s(:nil) # prevent returning mlhs assignment
    body = prepend_to_body(body, arguments.initialization)
  end

  node.updated(nil, [mid, args, body])
end
on_defs(node) click to toggle source
Calls superclass method
# File lib/opal/rewriters/mlhs_args.rb, line 37
def on_defs(node)
  node = super(node)
  recv, mid, args, body = *node

  arguments = Arguments.new(args)

  args = args.updated(nil, arguments.rewritten)
  if arguments.initialization
    body ||= s(:nil) # prevent returning mlhs assignment
    body = prepend_to_body(body, arguments.initialization)
  end

  node.updated(nil, [recv, mid, args, body])
end
on_iter(node) click to toggle source
Calls superclass method
# File lib/opal/rewriters/mlhs_args.rb, line 52
def on_iter(node)
  node = super(node)
  args, body = *node

  arguments = Arguments.new(args)

  args = args.updated(nil, arguments.rewritten)
  if arguments.initialization
    body ||= s(:nil) # prevent returning mlhs assignment
    body = prepend_to_body(body, arguments.initialization)
  end

  node.updated(nil, [args, body])
end