Class: SetLocalNode

Inherits:
Struct
  • Object
show all
Defined in:
lib/toylang/ast/nodes.rb,
lib/toylang/interpreter/evaluation.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#nameObject

Returns the value of attribute name

Returns:

  • (Object)

    the current value of name



39
40
41
# File 'lib/toylang/ast/nodes.rb', line 39

def name
  @name
end

#valueObject

Returns the value of attribute value

Returns:

  • (Object)

    the current value of value



39
40
41
# File 'lib/toylang/ast/nodes.rb', line 39

def value
  @value
end

Instance Method Details

#eval(context) ⇒ Object



71
72
73
# File 'lib/toylang/interpreter/evaluation.rb', line 71

def eval(context)
  context.locals[name] = value.eval(context)
end