class SyntaxTree::YARV::CallData

This is an operand to various YARV instructions that represents the information about a specific call site.

Attributes

argc[R]
flags[R]
kw_arg[R]
method[R]

Public Class Methods

from(serialized) click to toggle source
# File lib/syntax_tree/yarv/calldata.rb, line 77
def self.from(serialized)
  new(
    serialized[:mid],
    serialized[:orig_argc],
    serialized[:flag],
    serialized[:kw_arg]
  )
end
new( method, argc = 0, flags = CallData::CALL_ARGS_SIMPLE, kw_arg = nil ) click to toggle source
# File lib/syntax_tree/yarv/calldata.rb, line 31
def initialize(
  method,
  argc = 0,
  flags = CallData::CALL_ARGS_SIMPLE,
  kw_arg = nil
)
  @method = method
  @argc = argc
  @flags = flags
  @kw_arg = kw_arg
end

Public Instance Methods

flag?(mask) click to toggle source
# File lib/syntax_tree/yarv/calldata.rb, line 43
def flag?(mask)
  (flags & mask) > 0
end
inspect() click to toggle source
# File lib/syntax_tree/yarv/calldata.rb, line 53
def inspect
  names = []
  names << :ARGS_SPLAT if flag?(CALL_ARGS_SPLAT)
  names << :ARGS_BLOCKARG if flag?(CALL_ARGS_BLOCKARG)
  names << :FCALL if flag?(CALL_FCALL)
  names << :VCALL if flag?(CALL_VCALL)
  names << :ARGS_SIMPLE if flag?(CALL_ARGS_SIMPLE)
  names << :KWARG if flag?(CALL_KWARG)
  names << :KW_SPLAT if flag?(CALL_KW_SPLAT)
  names << :TAILCALL if flag?(CALL_TAILCALL)
  names << :SUPER if flag?(CALL_SUPER)
  names << :ZSUPER if flag?(CALL_ZSUPER)
  names << :OPT_SEND if flag?(CALL_OPT_SEND)
  names << :KW_SPLAT_MUT if flag?(CALL_KW_SPLAT_MUT)

  parts = []
  parts << "mid:#{method}" if method
  parts << "argc:#{argc}"
  parts << "kw:[#{kw_arg.join(", ")}]" if kw_arg
  parts << names.join("|") if names.any?

  "<calldata!#{parts.join(", ")}>"
end
to_h() click to toggle source
# File lib/syntax_tree/yarv/calldata.rb, line 47
def to_h
  result = { mid: method, flag: flags, orig_argc: argc }
  result[:kw_arg] = kw_arg if kw_arg
  result
end