Class: EleetScript::SetConstantNode

Inherits:
SetVarNode show all
Defined in:
lib/lang/nodes.rb,
lib/lang/interpreter.rb

Instance Method Summary collapse

Methods inherited from SetVarNode

#to_s

Instance Method Details

#eval(context) ⇒ Object



194
195
196
197
198
199
200
# File 'lib/lang/interpreter.rb', line 194

def eval(context)
  if !context.constants.has_key?(name)
    context[name] = value.eval(context)
  else
    Helpers.throw_eleet_error(context, "Cannot reassign constant \"#{name}\" after it's already been defined!")
  end
end