Class: SyntaxTree::YARV::CallData
- Inherits:
-
Object
- Object
- SyntaxTree::YARV::CallData
- Defined in:
- lib/syntax_tree/yarv/calldata.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
-
#argc ⇒ Object
readonly
Returns the value of attribute argc.
-
#flags ⇒ Object
readonly
Returns the value of attribute flags.
-
#kw_arg ⇒ Object
readonly
Returns the value of attribute kw_arg.
-
#method ⇒ Object
readonly
Returns the value of attribute method.
Class Method Summary collapse
Instance Method Summary collapse
- #flag?(mask) ⇒ Boolean
-
#initialize(method, argc = 0, flags = CallData::CALL_ARGS_SIMPLE, kw_arg = nil) ⇒ CallData
constructor
A new instance of CallData.
- #inspect ⇒ Object
- #to_h ⇒ Object
Constructor Details
#initialize(method, argc = 0, flags = CallData::CALL_ARGS_SIMPLE, kw_arg = nil) ⇒ CallData
Returns a new instance of CallData.
24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/syntax_tree/yarv/calldata.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
#argc ⇒ Object (readonly)
Returns the value of attribute argc.
22 23 24 |
# File 'lib/syntax_tree/yarv/calldata.rb', line 22 def argc @argc end |
#flags ⇒ Object (readonly)
Returns the value of attribute flags.
22 23 24 |
# File 'lib/syntax_tree/yarv/calldata.rb', line 22 def flags @flags end |
#kw_arg ⇒ Object (readonly)
Returns the value of attribute kw_arg.
22 23 24 |
# File 'lib/syntax_tree/yarv/calldata.rb', line 22 def kw_arg @kw_arg end |
#method ⇒ Object (readonly)
Returns the value of attribute method.
22 23 24 |
# File 'lib/syntax_tree/yarv/calldata.rb', line 22 def method @method end |
Class Method Details
.from(serialized) ⇒ Object
71 72 73 74 75 76 77 78 |
# File 'lib/syntax_tree/yarv/calldata.rb', line 71 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/calldata.rb', line 36 def flag?(mask) (flags & mask) > 0 end |
#inspect ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/syntax_tree/yarv/calldata.rb', line 46 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 << :BLOCKISEQ if flag?(CALL_BLOCKISEQ) 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 ⇒ Object
40 41 42 43 44 |
# File 'lib/syntax_tree/yarv/calldata.rb', line 40 def to_h result = { mid: method, flag: flags, orig_argc: argc } result[:kw_arg] = kw_arg if kw_arg result end |