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.
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.
31 32 33 34 35 36 37 38 39 40 41 |
# 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 |
Instance Attribute Details
#argc ⇒ Object (readonly)
Returns the value of attribute argc.
29 30 31 |
# File 'lib/syntax_tree/yarv/calldata.rb', line 29 def argc @argc end |
#flags ⇒ Object (readonly)
Returns the value of attribute flags.
29 30 31 |
# File 'lib/syntax_tree/yarv/calldata.rb', line 29 def flags @flags end |
#kw_arg ⇒ Object (readonly)
Returns the value of attribute kw_arg.
29 30 31 |
# File 'lib/syntax_tree/yarv/calldata.rb', line 29 def kw_arg @kw_arg end |
#method ⇒ Object (readonly)
Returns the value of attribute method.
29 30 31 |
# File 'lib/syntax_tree/yarv/calldata.rb', line 29 def method @method end |
Class Method Details
.from(serialized) ⇒ Object
77 78 79 80 81 82 83 84 |
# 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 |
Instance Method Details
#flag?(mask) ⇒ Boolean
43 44 45 |
# File 'lib/syntax_tree/yarv/calldata.rb', line 43 def flag?(mask) (flags & mask) > 0 end |
#inspect ⇒ Object
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# 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 ⇒ Object
47 48 49 50 51 |
# 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 |