import icode
private import analysis
+import primitive_info
import compiling_base
# Compiler context from ICode to C
else
p = cparams.join(", ")
end
- if human_name != null then v.add_decl("static const char * const LOCATE_{cname} = \"{human_name}\";")
+ if human_name != null then
+ v.add_instr("static const char LOCATE_{cname}[] = \"{human_name}\";")
+ end
v.add_decl("{r} {cname}({p});")
v.add_decl("typedef {r} (*{cname}_t)({p});")
v.add_instr("{r} {cname}({p})\{")
v.add_instr("fra.me.meth = LOCATE_{v.basecname};")
v.add_instr("fra.me.has_broke = 0;")
v.add_instr("fra.me.REG_size = {std_slots_nb};")
+ v.add_instr("fra.me.nitni_local_ref_head = NULL;")
# Declare/initialize local variables
for i in [0..std_slots_nb[ do
else if n == once "copy_to".to_symbol then
s = "(void)memcpy(UNBOX_NativeString({regs[1]})+UNTAG_Int({regs[4]}), UNBOX_NativeString({regs[0]})+UNTAG_Int({regs[3]}), UNTAG_Int({regs[2]}));"
end
+ else if c == once "Sys".to_symbol then
+ if n == once "force_garbage_collection".to_symbol then
+ s = "Nit_gc_force_garbage_collection()"
+ end
else if n == once "object_id".to_symbol then
s = "TAG_Int((bigint)((obj_t){regs[0]})[1].object_id)"
else if n == once "sys".to_symbol then
redef fun compile_to_c(v)
do
if not need_result then return
- # FIXME handle formaltypes
v.add_location(location)
- var g = stype.local_class.global
- var recv = v.register(expr)
+ var recv = v.register(expr2)
var w = new_result(v)
w.add("TAG_Bool(")
- if expr.stype.is_nullable then
+ if expr2.stype.is_nullable then
if stype.is_nullable then
w.add("(")
w.add(recv)
w.add("==NIT_NULL) || ")
- else if stype.as_nullable == expr.stype then
+ else if stype.as_nullable == expr2.stype then
w.add(recv)
w.add("!=NIT_NULL)")
return
w.add("!=NIT_NULL) && ")
end
end
- w.add("VAL_ISA(")
- w.add(recv)
- w.add(", ")
- w.add(g.color_id)
- w.add(", ")
- w.add(g.id_id)
- w.add(")) /*cast ")
- w.add(stype.to_s)
- w.add("*/")
+ # FIXME handle formaltypes
+ var t = stype
+ if t isa MMVirtualType then
+ var slf = v.register(expr1)
+ var g = t.property.global
+ w.add("VAL_ISA(")
+ w.add(recv)
+ w.add(", ")
+ w.add(g.vt_class_color)
+ w.add("(")
+ w.add(slf)
+ w.add(")")
+ w.add(", ")
+ w.add(g.vt_class_id)
+ w.add("(")
+ w.add(slf)
+ w.add(")")
+ w.add(")) /*cast ")
+ w.add(t.to_s)
+ w.add("*/")
+ else
+ var g = t.local_class.global
+ w.add("VAL_ISA(")
+ w.add(recv)
+ w.add(", ")
+ w.add(g.color_id)
+ w.add(", ")
+ w.add(g.id_id)
+ w.add(")) /*cast ")
+ w.add(t.to_s)
+ w.add("*/")
+ end
end
end