Do not call this method directly, use v.stmt
instead
# Try to compile self as a statement
# Do not call this method directly, use `v.stmt` instead
private fun stmt(v: AbstractCompilerVisitor)
do
expr(v)
end
src/compiler/abstract_compiler.nit:3737,2--3742,4
redef fun stmt(v)
do
if v.compiler.modelbuilder.toolcontext.opt_no_check_assert.value then return
var cond = v.expr_bool(self.n_expr)
v.add("if (unlikely(!{cond})) \{")
v.stmt(self.n_else)
explain_assert v
var nid = self.n_id
if nid != null then
v.add_abort("Assert '{nid.text}' failed")
else
v.add_abort("Assert failed")
end
v.add("\}")
end
src/compiler/abstract_compiler.nit:3994,2--4011,4
redef fun stmt(v)
do
# do nothing
end
src/compiler/abstract_compiler.nit:4611,2--4614,4
redef fun stmt(v) do v.add("goto BREAK_{v.escapemark_name(self.escapemark)};")
src/compiler/abstract_compiler.nit:3816,2--79
redef fun stmt(v)
do
var variable = self.variable.as(not null)
var vari = v.variable(variable)
var value = v.expr(self.n_value, variable.declared_type)
var res = v.compile_callsite(self.reassign_callsite.as(not null), [vari, value])
assert res != null
v.assign(v.variable(variable), res)
end
src/compiler/abstract_compiler.nit:3793,2--3801,4
redef fun stmt(v)
do
var recv = v.expr(self.n_expr, null)
var callsite = self.callsite.as(not null)
if callsite.is_broken then return
var args = v.varargize(callsite.mpropdef, callsite.signaturemap, recv, self.raw_arguments)
var value = v.expr(self.n_value, null)
var left = v.compile_callsite(callsite, args)
assert left != null
var res = v.compile_callsite(self.reassign_callsite.as(not null), [left, value])
assert res != null
args.add(res)
v.compile_callsite(self.write_callsite.as(not null), args)
end
src/compiler/abstract_compiler.nit:4433,2--4450,4
redef fun stmt(v)
do
var recv = v.expr(self.n_expr, null)
var value = v.expr(self.n_value, null)
var mproperty = self.mproperty.as(not null)
var attr = v.read_attribute(mproperty, recv)
var res = v.compile_callsite(self.reassign_callsite.as(not null), [attr, value])
assert res != null
v.write_attribute(mproperty, recv, res)
end
src/compiler/abstract_compiler.nit:4568,2--4577,4
redef fun stmt(v)
do
if self.n_catch != null then
v.add("\{")
v.add("struct catch_stack_t *catchStack = getCatchStack();")
v.add("if(catchStack->currentSize == 0) \{")
v.add(" catchStack->cursor = -1;")
v.add(" catchStack->currentSize = 100;")
v.add(" catchStack->envs = malloc(sizeof(jmp_buf)*100);")
v.add("\} else if(catchStack->cursor == catchStack->currentSize - 1) \{")
v.add(" catchStack->currentSize *= 2;")
v.add(" catchStack->envs = realloc(catchStack->envs, sizeof(jmp_buf)*catchStack->currentSize);")
v.add("\}")
v.add("catchStack->cursor += 1;")
v.add("if(!setjmp(catchStack->envs[catchStack->cursor]))\{")
v.stmt(self.n_block)
v.add("catchStack->cursor -= 1;")
v.add("\}else \{")
v.add("catchStack->cursor -= 1;")
v.stmt(self.n_catch)
v.add("\}")
v.add("\}")
else
v.stmt(self.n_block)
end
v.add_escape_label(break_mark)
end
src/compiler/abstract_compiler.nit:3875,2--3901,4
redef fun stmt(v)
do
v.add("for(;;) \{")
var cond = v.expr_bool(self.n_expr)
v.add("if (!{cond}) break;")
v.stmt(self.n_block)
v.add_escape_label(continue_mark)
v.add("\}")
v.add_escape_label(break_mark)
end
src/compiler/abstract_compiler.nit:3905,2--3914,4
redef fun stmt(v)
do
v.add("for(;;) \{")
v.stmt(self.n_block)
v.add_escape_label(continue_mark)
v.add("\}")
v.add_escape_label(break_mark)
end
src/compiler/abstract_compiler.nit:3918,2--3925,4
redef fun stmt(v)
do
for g in n_groups do
var cl = v.expr(g.n_expr, null)
var it_meth = g.method_iterator
assert it_meth != null
var it = v.compile_callsite(it_meth, [cl])
assert it != null
g.it = it
end
v.add("for(;;) \{")
for g in n_groups do
var it = g.it
var isok_meth = g.method_is_ok
assert isok_meth != null
var ok = v.compile_callsite(isok_meth, [it])
assert ok != null
v.add("if(!{ok}) break;")
if g.variables.length == 1 then
var item_meth = g.method_item
assert item_meth != null
var i = v.compile_callsite(item_meth, [it])
assert i != null
v.assign(v.variable(g.variables.first), i)
else if g.variables.length == 2 then
var key_meth = g.method_key
assert key_meth != null
var i = v.compile_callsite(key_meth, [it])
assert i != null
v.assign(v.variable(g.variables[0]), i)
var item_meth = g.method_item
assert item_meth != null
i = v.compile_callsite(item_meth, [it])
assert i != null
v.assign(v.variable(g.variables[1]), i)
else
abort
end
end
v.stmt(self.n_block)
v.add_escape_label(continue_mark)
for g in n_groups do
var next_meth = g.method_next
assert next_meth != null
v.compile_callsite(next_meth, [g.it])
end
v.add("\}")
v.add_escape_label(break_mark)
for g in n_groups do
var method_finish = g.method_finish
if method_finish != null then
# TODO: Find a way to call this also in long escape (e.g. return)
v.compile_callsite(method_finish, [g.it])
end
end
end
src/compiler/abstract_compiler.nit:3929,2--3985,4