Class: MethodSig::YarvOptionalArgument
- Inherits:
-
OptionalArgument
- Object
- Argument
- OptionalArgument
- MethodSig::YarvOptionalArgument
- Defined in:
- lib/decompiler/method/signature/argument.rb
Instance Attribute Summary collapse
-
#iseq ⇒ Object
readonly
Returns the value of attribute iseq.
-
#local_idx ⇒ Object
readonly
Returns the value of attribute local_idx.
-
#pc_start ⇒ Object
readonly
Returns the value of attribute pc_start.
Attributes inherited from Argument
Instance Method Summary collapse
- #default ⇒ Object
-
#initialize(name, iseq, pc_start, local_idx, is_rest, is_block) ⇒ YarvOptionalArgument
constructor
A new instance of YarvOptionalArgument.
- #inspect ⇒ Object
- #local_table_idx ⇒ Object
Methods inherited from OptionalArgument
Methods inherited from Argument
#block?, #optional?, #required?, #rest?, #to_s
Constructor Details
#initialize(name, iseq, pc_start, local_idx, is_rest, is_block) ⇒ YarvOptionalArgument
Returns a new instance of YarvOptionalArgument.
69 70 71 72 73 74 75 |
# File 'lib/decompiler/method/signature/argument.rb', line 69 def initialize(name, iseq, pc_start, local_idx, is_rest, is_block) super(name, is_rest, is_block) @iseq = iseq @pc_start = pc_start @local_idx = local_idx @default = nil end |
Instance Attribute Details
#iseq ⇒ Object (readonly)
Returns the value of attribute iseq.
65 66 67 |
# File 'lib/decompiler/method/signature/argument.rb', line 65 def iseq @iseq end |
#local_idx ⇒ Object (readonly)
Returns the value of attribute local_idx.
67 68 69 |
# File 'lib/decompiler/method/signature/argument.rb', line 67 def local_idx @local_idx end |
#pc_start ⇒ Object (readonly)
Returns the value of attribute pc_start.
66 67 68 |
# File 'lib/decompiler/method/signature/argument.rb', line 66 def pc_start @pc_start end |
Instance Method Details
#default ⇒ Object
82 83 84 85 86 87 88 89 90 91 92 93 94 95 |
# File 'lib/decompiler/method/signature/argument.rb', line 82 def default return @default if @default env = Internal::ByteDecoder::Environment.new(@iseq.local_table()) local_table_idx = local_table_idx() @iseq.bytedecode(env, @pc_start) do |instr| RubyVM::Instruction::SETLOCAL === instr && instr.operands[0] == local_table_idx end expressions = env.expressions + env.stack @default = expressions[0].rhs.to_s return @default end |
#inspect ⇒ Object
77 78 79 80 |
# File 'lib/decompiler/method/signature/argument.rb', line 77 def inspect default() super end |
#local_table_idx ⇒ Object
97 98 99 |
# File 'lib/decompiler/method/signature/argument.rb', line 97 def local_table_idx return @iseq.local_table.size - @local_idx + 1 end |