Class: Opal::Rewriters::InlineArgs
- Defined in:
- opal/lib/opal/rewriters/inline_args.rb
Overview
Converts
def m( a, b = 1, *c, d, e:, f: 1, **g, &blk ) end
To something like
def m( a,
Defined Under Namespace
Classes: Initializer
Constant Summary
Constants inherited from Base
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
Methods inherited from Base
#append_to_body, #begin_with_stmts, #error, #prepend_to_body, #process, #s, s, #stmts_of
Instance Method Details
#on_def(node) ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'opal/lib/opal/rewriters/inline_args.rb', line 28 def on_def(node) node = super(node) mid, args, body = *node body ||= s(:nil) # prevent returning initialization statement initializer = Initializer.new(args, type: :def) inline_args = args.updated(nil, initializer.inline) body = prepend_to_body(body, initializer.initialization) node.updated(nil, [mid, inline_args, body]) end |
#on_defs(node) ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'opal/lib/opal/rewriters/inline_args.rb', line 41 def on_defs(node) node = super(node) recv, mid, args, body = *node body ||= s(:nil) # prevent returning initialization statement initializer = Initializer.new(args, type: :defs) inline_args = args.updated(nil, initializer.inline) body = prepend_to_body(body, initializer.initialization) node.updated(nil, [recv, mid, inline_args, body]) end |
#on_iter(node) ⇒ Object
54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'opal/lib/opal/rewriters/inline_args.rb', line 54 def on_iter(node) node = super(node) args, body = *node body ||= s(:nil) # prevent returning initialization statement initializer = Initializer.new(args, type: :iter) inline_args = args.updated(nil, initializer.inline) body = prepend_to_body(body, initializer.initialization) node.updated(nil, [inline_args, body]) end |