if _variables.has_key(v) then
return _variables[v]
else
- var reg = new_register(v.stype.as(not null))
+ var t = v.stype
+ if t == null then t = visitor.type_object.as_nullable
+ var reg = new_register(t)
_variables[v] = reg
return reg
end
v.seq = iclos.body
escapable.continue_seq = iclos.body
escapable.continue_value = iclos.result
+ escapable.break_seq = v.return_seq
+ escapable.break_value = v.return_value
n_signature.fill_iroutine_parameters(v, variable.closure.signature, iclos.params, null)
if n_expr != null then
v.generate_stmt(n_expr)
v.iroutine.closure_decls[position].default = iclos
+
+ # Add a final break in case of break block witout value
+ if variable.closure.is_break and v.return_value == null then
+ v.stmt(new IEscape(v.return_seq.as(not null)))
+ end
end
v.seq = old_seq
end
end
else if c == once "NativeArray".to_symbol then
if n == once "object_id".to_symbol then
- s = "TAG_Int(UNBOX_NativeArray(@@@))"
+ s = "TAG_Int(((Nit_NativeArray)@@@)->object_id)"
else if n == once "[]".to_symbol then
- s = "UNBOX_NativeArray(@@@)[UNTAG_Int(@@@)]"
+ s = "((Nit_NativeArray)@@@)->val[UNTAG_Int(@@@)]"
else if n == once "[]=".to_symbol then
- s = "UNBOX_NativeArray(@@@)[UNTAG_Int(@@@)]=@@@;"
+ s = "((Nit_NativeArray)@@@)->val[UNTAG_Int(@@@)]=@@@"
else if n == once "copy_to".to_symbol then
var t = p[0]
p[0] = p[1]
p[1] = t
- s = "(void)memcpy(UNBOX_NativeArray(@@@), UNBOX_NativeArray(@@@), UNTAG_Int(@@@)*sizeof(val_t));"
+ s = "(void)memcpy(((Nit_NativeArray )@@@)->val, ((Nit_NativeArray)@@@)->val, UNTAG_Int(@@@)*sizeof(val_t))"
end
else if c == once "NativeString".to_symbol then
if n == once "object_id".to_symbol then
s = "exit(UNTAG_Int(@@@));"
else if n == once "calloc_array".to_symbol then
p[0] = p[1]
- s = "BOX_NativeArray((val_t*)malloc((UNTAG_Int(@@@) * sizeof(val_t))))"
+ s = "NEW_NativeArray(UNTAG_Int(@@@), sizeof(val_t))"
else if n == once "calloc_string".to_symbol then
p[0] = p[1]
- s = "BOX_NativeString((char*)malloc((UNTAG_Int(@@@) * sizeof(char))))"
+ s = "BOX_NativeString((char*)raw_alloc((UNTAG_Int(@@@) * sizeof(char))))"
end
if s == null then
v.visitor.error(self, "Fatal error: unknown intern method {method.full_name}.")
v.stmt(iif)
var seq_old = v.seq
v.seq = iif.else_seq
+ v.generate_stmt(n_else)
var id = n_id
if id == null then
v.add_abort("Assert failed")
v.generate_stmt(n_expr)
+ # Add a final break in case of break block witout value
+ if closure.is_break and escapable.break_value == null then
+ v.stmt(new IEscape(escapable.break_seq.as(not null)))
+ end
+
v.seq = seq_old
_iclosure_def = iclos
return iclos