Class: CodeTools::AST::LocalVariableAssignment

Inherits:
VariableAssignment show all
Includes:
LocalVariable
Defined in:
lib/rubinius/code/ast/variables.rb

Instance Attribute Summary

Attributes included from LocalVariable

#variable

Attributes inherited from VariableAssignment

#name, #value

Attributes inherited from Node

#line

Instance Method Summary collapse

Methods included from LocalVariable

#placeholder?

Methods inherited from VariableAssignment

#defined, #to_sexp

Methods inherited from Node

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

Constructor Details

#initialize(line, name, value = nil) ⇒ LocalVariableAssignment

Returns a new instance of LocalVariableAssignment.



503
504
505
506
507
508
# File 'lib/rubinius/code/ast/variables.rb', line 503

def initialize(line, name, value=nil)
  @line = line
  @name = name
  @value = value
  @variable = nil
end

Instance Method Details

#bytecode(g) ⇒ Object



510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
# File 'lib/rubinius/code/ast/variables.rb', line 510

def bytecode(g)
  unless @variable
    g.state.scope.assign_local_reference self
  end

  if @value
    @value.bytecode(g)
  end

  # Set the position after the value, so the position
  # reflects where the assignment itself is done
  pos(g)

  @variable.set_bytecode(g)
end

#sexp_nameObject



526
527
528
# File 'lib/rubinius/code/ast/variables.rb', line 526

def sexp_name
  :lasgn
end