Class: Rubinius::AST::Send

Inherits:
Node
  • Object
show all
Defined in:
lib/compiler/ast/sends.rb

Instance Attribute Summary collapse

Attributes inherited from Node

#line

Instance Method Summary collapse

Methods inherited from Node

#ascii_graph, #attributes, #children, match_arguments?, match_send?, #new_block_generator, #new_generator, #node_name, node_name, #pos, #set_child, transform, #transform, transform_comment, transform_kind, transform_kind=, transform_name, #visit, #walk

Constructor Details

#initialize(line, receiver, name, privately = false, vcall_style = false) ⇒ Send

Returns a new instance of Send.



9
10
11
12
13
14
15
16
17
# File 'lib/compiler/ast/sends.rb', line 9

def initialize(line, receiver, name, privately=false, vcall_style=false)
  @line = line
  @receiver = receiver
  @name = name
  @privately = privately
  @block = nil
  @check_for_local = false
  @vcall_style = vcall_style
end

Instance Attribute Details

#blockObject

Returns the value of attribute block.



6
7
8
# File 'lib/compiler/ast/sends.rb', line 6

def block
  @block
end

#check_for_localObject

Returns the value of attribute check_for_local.



7
8
9
# File 'lib/compiler/ast/sends.rb', line 7

def check_for_local
  @check_for_local
end

#nameObject

Returns the value of attribute name.



6
7
8
# File 'lib/compiler/ast/sends.rb', line 6

def name
  @name
end

#privatelyObject

Returns the value of attribute privately.



6
7
8
# File 'lib/compiler/ast/sends.rb', line 6

def privately
  @privately
end

#receiverObject

Returns the value of attribute receiver.



6
7
8
# File 'lib/compiler/ast/sends.rb', line 6

def receiver
  @receiver
end

#variableObject

Returns the value of attribute variable.



6
7
8
# File 'lib/compiler/ast/sends.rb', line 6

def variable
  @variable
end

Instance Method Details

#arguments_sexpObject



33
34
35
36
37
38
39
# File 'lib/compiler/ast/sends.rb', line 33

def arguments_sexp
  return nil if @vcall_style

  sexp = [:arglist]
  sexp << @block.to_sexp if @block.kind_of? BlockPass
  sexp
end

#check_local_reference(g) ⇒ Object



19
20
21
22
23
# File 'lib/compiler/ast/sends.rb', line 19

def check_local_reference(g)
  if @receiver.kind_of? Self and (@check_for_local or g.state.eval?)
    g.state.scope.search_local(@name)
  end
end

#receiver_sexpObject



29
30
31
# File 'lib/compiler/ast/sends.rb', line 29

def receiver_sexp
  @privately ? nil : @receiver.to_sexp
end

#sexp_nameObject



25
26
27
# File 'lib/compiler/ast/sends.rb', line 25

def sexp_name
  :call
end

#to_sexpObject



41
42
43
44
45
46
47
48
49
50
51
# File 'lib/compiler/ast/sends.rb', line 41

def to_sexp
  sexp = [sexp_name, receiver_sexp, @name, arguments_sexp]
  case @block
  when For
    @block.to_sexp.insert 1, @receiver.to_sexp
  when Iter
    @block.to_sexp.insert 1, sexp
  else
    sexp
  end
end