Class: CastOff::Compiler::Iseq::Args
- Inherits:
-
Object
- Object
- CastOff::Compiler::Iseq::Args
- Includes:
- Util
- Defined in:
- lib/cast_off/compile/iseq.rb
Instance Attribute Summary collapse
-
#arg_size ⇒ Object
readonly
Returns the value of attribute arg_size.
-
#argc ⇒ Object
readonly
Returns the value of attribute argc.
-
#block_index ⇒ Object
readonly
Returns the value of attribute block_index.
-
#opt_len ⇒ Object
readonly
Returns the value of attribute opt_len.
-
#opts ⇒ Object
readonly
Returns the value of attribute opts.
-
#post_len ⇒ Object
readonly
Returns the value of attribute post_len.
-
#post_start ⇒ Object
readonly
Returns the value of attribute post_start.
-
#rest_index ⇒ Object
readonly
Returns the value of attribute rest_index.
Instance Method Summary collapse
- #block? ⇒ Boolean
-
#initialize(args, iseq) ⇒ Args
constructor
A new instance of Args.
- #opt? ⇒ Boolean
- #post? ⇒ Boolean
- #rest? ⇒ Boolean
- #simple? ⇒ Boolean
- #splat? ⇒ Boolean
Methods included from Util
Constructor Details
#initialize(args, iseq) ⇒ Args
Returns a new instance of Args.
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/cast_off/compile/iseq.rb', line 15 def initialize(args, iseq) @iseq = iseq case args when Integer @argc, @opts, @post_len, @post_start, @rest_index, @block_index, @simple = args, [], 0, 0, -1, -1, 1 when Array bug() unless args.size == 7 @argc, @opts, @post_len, @post_start, @rest_index, @block_index, @simple = args else bug() end @opt_len = @opts.empty? ? 0 : (@opts.size() - 1) @arg_size = @argc + @opt_len + @post_len + (@rest_index == -1 ? 0 : 1) + (@block_index == -1 ? 0 : 1) case @iseq.itype when :method bug() if @simple == 2 when :block # nothing to do else bug() end if @rest_index != -1 bug() unless @rest_index + 1 == @post_start bug() unless @argc + @opt_len == @rest_index end end |
Instance Attribute Details
#arg_size ⇒ Object (readonly)
Returns the value of attribute arg_size.
13 14 15 |
# File 'lib/cast_off/compile/iseq.rb', line 13 def arg_size @arg_size end |
#argc ⇒ Object (readonly)
Returns the value of attribute argc.
13 14 15 |
# File 'lib/cast_off/compile/iseq.rb', line 13 def argc @argc end |
#block_index ⇒ Object (readonly)
Returns the value of attribute block_index.
13 14 15 |
# File 'lib/cast_off/compile/iseq.rb', line 13 def block_index @block_index end |
#opt_len ⇒ Object (readonly)
Returns the value of attribute opt_len.
13 14 15 |
# File 'lib/cast_off/compile/iseq.rb', line 13 def opt_len @opt_len end |
#opts ⇒ Object (readonly)
Returns the value of attribute opts.
13 14 15 |
# File 'lib/cast_off/compile/iseq.rb', line 13 def opts @opts end |
#post_len ⇒ Object (readonly)
Returns the value of attribute post_len.
13 14 15 |
# File 'lib/cast_off/compile/iseq.rb', line 13 def post_len @post_len end |
#post_start ⇒ Object (readonly)
Returns the value of attribute post_start.
13 14 15 |
# File 'lib/cast_off/compile/iseq.rb', line 13 def post_start @post_start end |
#rest_index ⇒ Object (readonly)
Returns the value of attribute rest_index.
13 14 15 |
# File 'lib/cast_off/compile/iseq.rb', line 13 def rest_index @rest_index end |
Instance Method Details
#block? ⇒ Boolean
52 53 54 |
# File 'lib/cast_off/compile/iseq.rb', line 52 def block? @block_index != -1 end |
#opt? ⇒ Boolean
56 57 58 |
# File 'lib/cast_off/compile/iseq.rb', line 56 def opt? not @opts.empty? end |
#post? ⇒ Boolean
44 45 46 |
# File 'lib/cast_off/compile/iseq.rb', line 44 def post? @post_len != 0 end |
#rest? ⇒ Boolean
48 49 50 |
# File 'lib/cast_off/compile/iseq.rb', line 48 def rest? @rest_index != -1 end |
#simple? ⇒ Boolean
60 61 62 |
# File 'lib/cast_off/compile/iseq.rb', line 60 def simple? (@simple & 0x01) != 0 end |
#splat? ⇒ Boolean
64 65 66 |
# File 'lib/cast_off/compile/iseq.rb', line 64 def splat? (@simple & 0x02 == 0) && (@argc + @post_len > 0) end |