A runtime variable hold a runtime value in C.

Runtime variables are associated to Nit local variables and intermediate results in Nit expressions.

The tricky point is that a single C variable can be associated to more than one RuntimeVariable because the static knowledge of the type of an expression can vary in the C code.

Introduced properties

private var _is_exact: Bool

nitc :: RuntimeVariable :: _is_exact

If the variable exaclty a mcasttype?
private var _mcasttype: MType

nitc :: RuntimeVariable :: _mcasttype

The current casted type of the variable (as known in Nit)
private var _mtype: MType

nitc :: RuntimeVariable :: _mtype

The static type of the variable (as declard in C)
private var _name: String

nitc :: RuntimeVariable :: _name

The name of the variable in the C code
init defaultinit(name: String, mtype: MType, mcasttype: MType)

nitc :: RuntimeVariable :: defaultinit

fun is_exact: Bool

nitc :: RuntimeVariable :: is_exact

If the variable exaclty a mcasttype?
fun is_exact=(is_exact: Bool)

nitc :: RuntimeVariable :: is_exact=

If the variable exaclty a mcasttype?
fun mcasttype: MType

nitc :: RuntimeVariable :: mcasttype

The current casted type of the variable (as known in Nit)
fun mcasttype=(mcasttype: MType)

nitc :: RuntimeVariable :: mcasttype=

The current casted type of the variable (as known in Nit)
fun mtype: MType

nitc :: RuntimeVariable :: mtype

The static type of the variable (as declard in C)
protected fun mtype=(mtype: MType)

nitc :: RuntimeVariable :: mtype=

The static type of the variable (as declard in C)
fun name: String

nitc :: RuntimeVariable :: name

The name of the variable in the C code
protected fun name=(name: String)

nitc :: RuntimeVariable :: name=

The name of the variable in the C code

Redefined properties

redef type SELF: RuntimeVariable

nitc $ RuntimeVariable :: SELF

Type of this instance, automatically specialized in every class
redef init init

nitc $ RuntimeVariable :: init

redef fun inspect: String

nitc $ RuntimeVariable :: inspect

Developer readable representation of self.
redef fun to_s: String

nitc $ RuntimeVariable :: to_s

User readable representation of self.

All properties

fun !=(other: nullable Object): Bool

core :: Object :: !=

Have self and other different values?
fun ==(other: nullable Object): Bool

core :: Object :: ==

Have self and other the same value?
type CLASS: Class[SELF]

core :: Object :: CLASS

The type of the class of self.
type SELF: Object

core :: Object :: SELF

Type of this instance, automatically specialized in every class
private var _is_exact: Bool

nitc :: RuntimeVariable :: _is_exact

If the variable exaclty a mcasttype?
private var _mcasttype: MType

nitc :: RuntimeVariable :: _mcasttype

The current casted type of the variable (as known in Nit)
private var _mtype: MType

nitc :: RuntimeVariable :: _mtype

The static type of the variable (as declard in C)
private var _name: String

nitc :: RuntimeVariable :: _name

The name of the variable in the C code
protected fun class_factory(name: String): CLASS

core :: Object :: class_factory

Implementation used by get_class to create the specific class.
fun class_name: String

core :: Object :: class_name

The class name of the object.
init defaultinit(name: String, mtype: MType, mcasttype: MType)

nitc :: RuntimeVariable :: defaultinit

fun get_class: CLASS

core :: Object :: get_class

The meta-object representing the dynamic type of self.
fun hash: Int

core :: Object :: hash

The hash code of the object.
init init

core :: Object :: init

fun inspect: String

core :: Object :: inspect

Developer readable representation of self.
protected fun inspect_head: String

core :: Object :: inspect_head

Return "CLASSNAME:#OBJECTID".
fun is_exact: Bool

nitc :: RuntimeVariable :: is_exact

If the variable exaclty a mcasttype?
fun is_exact=(is_exact: Bool)

nitc :: RuntimeVariable :: is_exact=

If the variable exaclty a mcasttype?
intern fun is_same_instance(other: nullable Object): Bool

core :: Object :: is_same_instance

Return true if self and other are the same instance (i.e. same identity).
fun is_same_serialized(other: nullable Object): Bool

core :: Object :: is_same_serialized

Is self the same as other in a serialization context?
intern fun is_same_type(other: Object): Bool

core :: Object :: is_same_type

Return true if self and other have the same dynamic type.
fun mcasttype: MType

nitc :: RuntimeVariable :: mcasttype

The current casted type of the variable (as known in Nit)
fun mcasttype=(mcasttype: MType)

nitc :: RuntimeVariable :: mcasttype=

The current casted type of the variable (as known in Nit)
fun mtype: MType

nitc :: RuntimeVariable :: mtype

The static type of the variable (as declard in C)
protected fun mtype=(mtype: MType)

nitc :: RuntimeVariable :: mtype=

The static type of the variable (as declard in C)
fun name: String

nitc :: RuntimeVariable :: name

The name of the variable in the C code
protected fun name=(name: String)

nitc :: RuntimeVariable :: name=

The name of the variable in the C code
private intern fun native_class_name: CString

core :: Object :: native_class_name

The class name of the object in CString format.
intern fun object_id: Int

core :: Object :: object_id

An internal hash code for the object based on its identity.
fun output

core :: Object :: output

Display self on stdout (debug only).
intern fun output_class_name

core :: Object :: output_class_name

Display class name on stdout (debug only).
fun serialization_hash: Int

core :: Object :: serialization_hash

Hash value use for serialization
intern fun sys: Sys

core :: Object :: sys

Return the global sys object, the only instance of the Sys class.
abstract fun to_jvalue(env: JniEnv): JValue

core :: Object :: to_jvalue

fun to_s: String

core :: Object :: to_s

User readable representation of self.
package_diagram nitc::RuntimeVariable RuntimeVariable core::Object Object nitc::RuntimeVariable->core::Object

Parents

interface Object

core :: Object

The root of the class hierarchy.

Class definitions

nitc $ RuntimeVariable
# A runtime variable hold a runtime value in C.
# Runtime variables are associated to Nit local variables and intermediate results in Nit expressions.
#
# The tricky point is that a single C variable can be associated to more than one `RuntimeVariable` because the static knowledge of the type of an expression can vary in the C code.
class RuntimeVariable
	# The name of the variable in the C code
	var name: String

	# The static type of the variable (as declard in C)
	var mtype: MType

	# The current casted type of the variable (as known in Nit)
	var mcasttype: MType is writable

	# If the variable exaclty a mcasttype?
	# false (usual value) means that the variable is a mcasttype or a subtype.
	var is_exact: Bool = false is writable

	init
	do
		assert not mtype.need_anchor
		assert not mcasttype.need_anchor
	end

	redef fun to_s do return name

	redef fun inspect
	do
		var exact_str
		if self.is_exact then
			exact_str = " exact"
		else
			exact_str = ""
		end
		var type_str
		if self.mtype == self.mcasttype then
			type_str = "{mtype}{exact_str}"
		else
			type_str = "{mtype}({mcasttype}{exact_str})"
		end
		return "<{name}:{type_str}>"
	end
end
src/compiler/abstract_compiler.nit:2349,1--2391,3