nitc :: JavaCompilerVisitor :: expr
mtype
is the expected return type, pass null if no specific type is expected.
# Compile an expression an return its result
# `mtype` is the expected return type, pass null if no specific type is expected.
fun expr(nexpr: AExpr, mtype: nullable MType): RuntimeVariable do
var old = current_node
current_node = nexpr
var res = null
if nexpr.mtype != null then
res = nexpr.expr(self)
end
if res == null then
# Untyped expression.
# Might mean dead code or invalid code.
# so aborts
add_abort("FATAL: bad expression executed.")
# and return a placebo result to please the C compiler
if mtype == null then mtype = compiler.mainmodule.object_type
res = null_instance
self.current_node = old
return res
end
if mtype != null then
mtype = anchor(mtype)
res = autobox(res, mtype)
end
current_node = old
return res
end
src/compiler/java_compiler.nit:718,2--749,4