Class: Atomy::Code::Send

Inherits:
Object show all
Defined in:
lib/atomy/code/send.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(receiver, message, arguments = [], splat_argument = nil, proc_argument = nil, block = nil) ⇒ Send

Returns a new instance of Send.



6
7
8
9
10
11
12
13
# File 'lib/atomy/code/send.rb', line 6

def initialize(receiver, message, arguments = [], splat_argument = nil, proc_argument = nil, block = nil)
  @receiver = receiver
  @message = message
  @arguments = arguments
  @splat_argument = splat_argument
  @proc_argument = proc_argument
  @block = block
end

Instance Attribute Details

#argumentsObject (readonly)

Returns the value of attribute arguments.



4
5
6
# File 'lib/atomy/code/send.rb', line 4

def arguments
  @arguments
end

#blockObject (readonly)

Returns the value of attribute block.



4
5
6
# File 'lib/atomy/code/send.rb', line 4

def block
  @block
end

#messageObject (readonly)

Returns the value of attribute message.



4
5
6
# File 'lib/atomy/code/send.rb', line 4

def message
  @message
end

#proc_argumentObject (readonly)

Returns the value of attribute proc_argument.



4
5
6
# File 'lib/atomy/code/send.rb', line 4

def proc_argument
  @proc_argument
end

#receiverObject (readonly)

Returns the value of attribute receiver.



4
5
6
# File 'lib/atomy/code/send.rb', line 4

def receiver
  @receiver
end

Instance Method Details

#bytecode(gen, mod) ⇒ Object



15
16
17
18
19
20
21
22
23
# File 'lib/atomy/code/send.rb', line 15

def bytecode(gen, mod)
  flocal = gen.state.scope.search_local(:"#{@message}:function")

  if @receiver.nil? && flocal
    invoke_function(gen, mod, flocal)
  else
    invoke_method(gen, mod)
  end
end

#push_proc_argument(gen, mod) ⇒ Object



97
98
99
100
101
102
103
104
105
106
107
# File 'lib/atomy/code/send.rb', line 97

def push_proc_argument(gen, mod)
  nil_proc_arg = gen.new_label
  mod.compile(gen, @proc_argument)
  gen.dup
  gen.goto_if_nil(nil_proc_arg)
  gen.push_cpath_top
  gen.find_const(:Proc)
  gen.swap
  gen.send(:__from_block__, 1)
  nil_proc_arg.set!
end