Class: Malady::AST::AssignNode

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

Instance Attribute Summary collapse

Attributes inherited from Node

#filename, #line

Instance Method Summary collapse

Methods inherited from Node

#pos

Constructor Details

#initialize(filename, line, name, value) ⇒ AssignNode

Returns a new instance of AssignNode.



115
116
117
118
119
# File 'lib/malady/ast.rb', line 115

def initialize(filename, line, name, value)
  super
  @name = name
  @value = value
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



113
114
115
# File 'lib/malady/ast.rb', line 113

def name
  @name
end

#valueObject (readonly)

Returns the value of attribute value.



113
114
115
# File 'lib/malady/ast.rb', line 113

def value
  @value
end

Instance Method Details

#bytecode(g) ⇒ Object



121
122
123
124
125
126
# File 'lib/malady/ast.rb', line 121

def bytecode(g)
  pos(g)
  local = g.state.scope.new_local(name)
  value.bytecode(g)
  local.reference.set_bytecode(g)
end