n
as an expression in the current context.Return the value of the expression.
If n
cannot be evaluated, then aborts.
# Evaluate `n` as an expression in the current context.
# Return the value of the expression.
# If `n` cannot be evaluated, then aborts.
fun expr(n: AExpr): nullable Instance
do
var frame = self.frame
var old = frame.current_node
frame.current_node = n
#n.debug("IN Execute expr")
var i = n.expr(self)
if i == null and not self.is_escaping then
n.debug("inconsitance: no value and not escaping.")
end
var implicit_cast_to = n.implicit_cast_to
if i != null and implicit_cast_to != null then
var mtype = self.unanchor_type(implicit_cast_to)
if not self.is_subtype(i.mtype, mtype) then n.fatal(self, "Cast failed. Expected `{implicit_cast_to}`, got `{i.mtype}`")
end
#n.debug("OUT Execute expr: value is {i}")
#if not is_subtype(i.mtype, n.mtype.as(not null)) then n.debug("Expected {n.mtype.as(not null)} got {i}")
frame.current_node = old
return i
end
src/interpreter/naive_interpreter.nit:161,2--184,4