Class: RubyVM::Instruction::SEND

Inherits:
Object
  • Object
show all
Defined in:
lib/internal/vm/bytedecoder.rb

Instance Method Summary collapse

Instance Method Details

#bytedecode(env) ⇒ Object



537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
# File 'lib/internal/vm/bytedecoder.rb', line 537

def bytedecode(env)
  id = @operands[0]
  num_args = @operands[1]
  args = []
  num_args.times do
    args.unshift env.stack.pop
  end
  has_receiver = !flag_set(RubyVM::CALL_FCALL_BIT)
  has_parens = !flag_set(RubyVM::CALL_VCALL_BIT)
  splat_last = flag_set(RubyVM::CALL_ARGS_SPLAT_BIT)
  receiver = env.stack.pop
  block = @operands[2]
  if INFIX_OPERATORS.include?(id) and args.size == 1 then
    env.stack.push Expression::Infix.new(env.pc, id, receiver, args[0])
  elsif PREFIX_OPERATORS.include?(id) and args.size == 0 then
    env.stack.push Expression::Prefix.new(env.pc, id, receiver)
  else
    env.stack.push Expression::Send.new(
        env.pc, id, has_receiver, has_parens, receiver, block, splat_last, *args)
  end
end

#flag_set(flag) ⇒ Object



559
560
561
562
# File 'lib/internal/vm/bytedecoder.rb', line 559

def flag_set(flag)
  flags = @operands[3]
  return flags & flag == flag
end