Class: SyntaxTree::YARV::CallData

Inherits:
Object
  • Object
show all
Defined in:
lib/syntax_tree/yarv/instructions.rb

Overview

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

Constant Summary collapse

CALL_ARGS_SPLAT =
1 << 0
CALL_ARGS_BLOCKARG =
1 << 1
CALL_FCALL =
1 << 2
CALL_VCALL =
1 << 3
CALL_ARGS_SIMPLE =
1 << 4
CALL_BLOCKISEQ =
1 << 5
CALL_KWARG =
1 << 6
CALL_KW_SPLAT =
1 << 7
CALL_TAILCALL =
1 << 8
CALL_SUPER =
1 << 9
CALL_ZSUPER =
1 << 10
CALL_OPT_SEND =
1 << 11
CALL_KW_SPLAT_MUT =
1 << 12

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(method, argc = 0, flags = CallData::CALL_ARGS_SIMPLE, kw_arg = nil) ⇒ CallData



24
25
26
27
28
29
30
31
32
33
34
# File 'lib/syntax_tree/yarv/instructions.rb', line 24

def initialize(
  method,
  argc = 0,
  flags = CallData::CALL_ARGS_SIMPLE,
  kw_arg = nil
)
  @method = method
  @argc = argc
  @flags = flags
  @kw_arg = kw_arg
end

Instance Attribute Details

#argcObject (readonly)

Returns the value of attribute argc.



22
23
24
# File 'lib/syntax_tree/yarv/instructions.rb', line 22

def argc
  @argc
end

#flagsObject (readonly)

Returns the value of attribute flags.



22
23
24
# File 'lib/syntax_tree/yarv/instructions.rb', line 22

def flags
  @flags
end

#kw_argObject (readonly)

Returns the value of attribute kw_arg.



22
23
24
# File 'lib/syntax_tree/yarv/instructions.rb', line 22

def kw_arg
  @kw_arg
end

#methodObject (readonly)

Returns the value of attribute method.



22
23
24
# File 'lib/syntax_tree/yarv/instructions.rb', line 22

def method
  @method
end

Class Method Details

.from(serialized) ⇒ Object



46
47
48
49
50
51
52
53
# File 'lib/syntax_tree/yarv/instructions.rb', line 46

def self.from(serialized)
  new(
    serialized[:mid],
    serialized[:orig_argc],
    serialized[:flag],
    serialized[:kw_arg]
  )
end

Instance Method Details

#flag?(mask) ⇒ Boolean



36
37
38
# File 'lib/syntax_tree/yarv/instructions.rb', line 36

def flag?(mask)
  (flags & mask) > 0
end

#to_hObject



40
41
42
43
44
# File 'lib/syntax_tree/yarv/instructions.rb', line 40

def to_h
  result = { mid: method, flag: flags, orig_argc: argc }
  result[:kw_arg] = kw_arg if kw_arg
  result
end