Class: Opal::Nodes::CallNode

Inherits:
Base
  • Object
show all
Defined in:
opal/lib/opal/nodes/call.rb

Direct Known Subclasses

BaseSuperNode, CSendNode, JsCallNode

Defined Under Namespace

Classes: DependencyResolver

Constant Summary

SPECIALS =
{}
OPERATORS =

Operators that get optimized by compiler

{ :+ => :plus, :- => :minus, :* => :times, :/ => :divide,
:< => :lt, :<= => :le, :> => :gt, :>= => :ge }.freeze

Instance Attribute Summary collapse

Attributes inherited from Base

#compiler, #type

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#add_gvar, #add_ivar, #add_local, #add_temp, #children, children, #class_variable_owner, #class_variable_owner_nesting_level, #comments, #compile_to_fragments, #error, #expr, #expr?, #expr_or_nil, #fragment, handle, handlers, #has_rescue_else?, #helper, #in_ensure, #in_ensure?, #in_while?, #process, #push, #recv, #recv?, #s, #scope, #stmt, #stmt?, truthy_optimize?, #unshift, #while_loop, #with_temp, #wrap

Methods included from Helpers

#conditional_send, #current_indent, #empty_line, #indent, #js_falsy, #js_truthy, #js_truthy_optimize, #line, #mid_to_jsid, #property, #valid_name?

Constructor Details

#initializeCallNode

Returns a new instance of CallNode



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'opal/lib/opal/nodes/call.rb', line 27

def initialize(*)
  super
  @recvr, @meth, *args = *@sexp

  *rest, last_arg = *args

  if last_arg && %i[iter block_pass].include?(last_arg.type)
    @iter = last_arg
    args = rest
  else
    @iter = nil
  end

  @arglist = s(:arglist, *args)
end

Instance Attribute Details

#arglistObject (readonly)

Returns the value of attribute arglist



14
15
16
# File 'opal/lib/opal/nodes/call.rb', line 14

def arglist
  @arglist
end

#iterObject (readonly)

Returns the value of attribute iter



14
15
16
# File 'opal/lib/opal/nodes/call.rb', line 14

def iter
  @iter
end

#methObject (readonly)

Returns the value of attribute meth



14
15
16
# File 'opal/lib/opal/nodes/call.rb', line 14

def meth
  @meth
end

#recvrObject (readonly)

Returns the value of attribute recvr



14
15
16
# File 'opal/lib/opal/nodes/call.rb', line 14

def recvr
  @recvr
end

Class Method Details

.add_special(name, options = {}, &handler) ⇒ Object



22
23
24
25
# File 'opal/lib/opal/nodes/call.rb', line 22

def self.add_special(name, options = {}, &handler)
  SPECIALS[name] = options
  define_method("handle_#{name}", &handler)
end

Instance Method Details

#compileObject



43
44
45
46
47
48
49
50
51
52
53
54
# File 'opal/lib/opal/nodes/call.rb', line 43

def compile
  # handle some methods specially
  # some special methods need to skip compilation, so we pass the default as a block
  handle_special do
    compiler.method_calls << meth.to_sym if record_method?

    # if trying to access an lvar in irb mode
    return compile_irb_var if using_irb?

    default_compile
  end
end