Exception: AmberVM::Interpreter::ReturnData

Inherits:
Exception
  • Object
show all
Defined in:
lib/amber/interpreter.rb

Overview

This is an exception designed to handle the return statement. It is thrown for for the return and the value can be evaluated.

The catching is handled bythe AmberVM::Classes::Block class.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(val, pos = nil) ⇒ ReturnData

The ReturnException is initialized wiht 1 to 2 parameters.

val

The value that will be returned, aka the part after ‘return’.

pos

The position within the source code of the definition - for deugging purpose.



1051
1052
1053
1054
1055
# File 'lib/amber/interpreter.rb', line 1051

def initialize val, pos = nil
  super()
  @val = val
  @pos = pos
end

Instance Attribute Details

#posObject (readonly)

Returns the value of attribute pos.



1043
1044
1045
# File 'lib/amber/interpreter.rb', line 1043

def pos
  @pos
end

#valObject (readonly)

Returns the value of attribute val.



1042
1043
1044
# File 'lib/amber/interpreter.rb', line 1042

def val
  @val
end