Class: Rubinius::AST::ConstantAssignment

Inherits:
Node
  • Object
show all
Defined in:
lib/compiler/ast/constants.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, expr, value) ⇒ ConstantAssignment

Returns a new instance of ConstantAssignment.



63
64
65
66
67
68
69
70
71
72
# File 'lib/compiler/ast/constants.rb', line 63

def initialize(line, expr, value)
  @line = line
  @value = value

  if expr.kind_of? Symbol
    @constant = ConstantAccess.new line, expr
  else
    @constant = expr
  end
end

Instance Attribute Details

#constantObject

Returns the value of attribute constant.



61
62
63
# File 'lib/compiler/ast/constants.rb', line 61

def constant
  @constant
end

#valueObject

Returns the value of attribute value.



61
62
63
# File 'lib/compiler/ast/constants.rb', line 61

def value
  @value
end

Instance Method Details

#to_sexpObject



74
75
76
77
78
# File 'lib/compiler/ast/constants.rb', line 74

def to_sexp
  sexp = [:cdecl, @constant.assign_sexp]
  sexp << @value.to_sexp if @value
  sexp
end