nitc :: RuntimeVariable :: defaultinit
# 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