Property definitions

nitc $ Instance :: defaultinit
# An instance represents a value of the executed program.
abstract class Instance
	# The dynamic type of the instance
	# ASSERT: not self.mtype.is_anchored
	var mtype: MType

	# Return `true` if the instance is the `true` value.
	#
	# Return `false` if the instance is the `false` value.
	# Abort if the instance is not a boolean value.
	fun is_true: Bool do abort

	# Return `true` if the instance is null.
	# Return `false` otherwise.
	fun is_null: Bool do return mtype isa MNullType

	# Return true if `self` IS `o` (using the Nit semantic of is)
	fun eq_is(o: Instance): Bool do return self.is_same_instance(o)

	# Human readable object identity "Type#number"
	redef fun to_s do return "{mtype}"

	# Return the integer value if the instance is an integer.
	# else aborts
	fun to_i: Int do abort

	# Return the integer value if the instance is a float.
	# else aborts
	fun to_f: Float do abort

	# Return the integer value if the instance is a byte.
	# else aborts
	fun to_b: Byte do abort

	# Return the integer value if the instance is a int8.
	# else aborts
	fun to_i8: Int8 do abort

	# Return the integer value if the instance is a int16.
	# else aborts
	fun to_i16: Int16 do abort

	# Return the integer value if the instance is a uint16.
	# else aborts
	fun to_u16: UInt16 do abort

	# Return the integer value if the instance is a int32.
	# else aborts
	fun to_i32: Int32 do abort

	# Return the integer value if the instance is a uint32.
	# else aborts
	fun to_u32: UInt32 do abort

	# The real value encapsulated if the instance is primitive.
	# Else aborts.
	fun val: nullable Object do abort
end
src/interpreter/naive_interpreter.nit:711,1--768,3