- var iself = new IRegister(get_type)
- var iselfa = [iself]
- var iroutine = new IRoutine(new Array[IRegister], iself)
- var icb = new ICodeBuilder(module, iroutine, null)
- var obj = new INative("OBJ2VAL(obj)", null)
- obj.result = iself
- icb.stmt(obj)
-
- for g in global_properties do
- var p = self[g]
- var t = p.signature.return_type
- if p isa MMAttribute and t != null then
- var ir = p.iroutine
- if ir == null then continue
- # FIXME: Not compatible with sep compilation
- var e = ir.inline_in_seq(icb.seq, iselfa).as(not null)
- icb.stmt(new IAttrWrite(p, iself, e))
+ do
+ var iself = new IRegister(get_type)
+ var iselfa = [iself]
+ var iroutine = new IRoutine(new Array[IRegister], iself)
+ var icb = new ICodeBuilder(module, iroutine, null)
+ var obj = new INative("OBJ2VAL(obj)", null)
+ obj.result = iself
+ icb.stmt(obj)
+
+ for g in global_properties do
+ var p = self[g]
+ var t = p.signature.return_type
+ if p isa MMAttribute and t != null then
+ var ir = p.iroutine
+ if ir == null then continue
+ # FIXME: Not compatible with sep compilation
+ var e = ir.inline_in_seq(icb.seq, iselfa).as(not null)
+ icb.stmt(new IAttrWrite(p, iself, e))
+ end
- var cname = "NEW_{name}"
- var args = iroutine.compile_signature_to_c(v, cname, "new {name}", null, null)
- var ctx_old = v.ctx
- v.ctx = new CContext
- v.add_decl("obj_t obj;")
- v.add_instr("obj = alloc(sizeof(val_t) * {itab.length});")
- v.add_instr("obj->vft = (classtable_elt_t*)VFT_{name};")
- var r = iroutine.compile_to_c(v, cname, args).as(not null)
- v.add_instr("return {r};")
- ctx_old.append(v.ctx)
- v.ctx = ctx_old
- v.unindent
- v.add_instr("}")
+ var cname = "NEW_{name}"
+ var args = iroutine.compile_signature_to_c(v, cname, "new {name}", null, null)
+ var ctx_old = v.ctx
+ v.ctx = new CContext
+ v.add_decl("obj_t obj;")
+ v.add_instr("obj = alloc(sizeof(val_t) * {itab.length});")
+ v.add_instr("obj->vft = (classtable_elt_t*)VFT_{name};")
+ var r = iroutine.compile_to_c(v, cname, args).as(not null)
+ v.add_instr("return {r};")
+ ctx_old.append(v.ctx)
+ v.ctx = ctx_old
+ v.unindent
+ v.add_instr("}")
+ end
- # Compile CHECKNAME
- var iself = new IRegister(get_type)
- var iselfa = [iself]
- var iroutine = new IRoutine(iselfa, null)
- var icb = new ICodeBuilder(module, iroutine, null)
- for g in global_properties do
- var p = self[g]
- var t = p.signature.return_type
- if p isa MMAttribute and t != null and not t.is_nullable then
- icb.add_attr_check(p, iself)
+ do
+ # Compile CHECKNAME
+ var iself = new IRegister(get_type)
+ var iselfa = [iself]
+ var iroutine = new IRoutine(iselfa, null)
+ var icb = new ICodeBuilder(module, iroutine, null)
+ for g in global_properties do
+ var p = self[g]
+ var t = p.signature.return_type
+ if p isa MMAttribute and t != null and not t.is_nullable then
+ icb.add_attr_check(p, iself)
+ end
+ var cname = "CHECKNEW_{name}"
+ var args = iroutine.compile_signature_to_c(v, cname, "check new {name}", null, null)
+ var ctx_old = v.ctx
+ v.ctx = new CContext
+ iroutine.compile_to_c(v, cname, args)
+ ctx_old.append(v.ctx)
+ v.ctx = ctx_old
+ v.unindent
+ v.add_instr("}")
- var cname = "CHECKNEW_{name}"
- var args = iroutine.compile_signature_to_c(v, cname, "check new {name}", null, null)
- var ctx_old = v.ctx
- v.ctx = new CContext
- iroutine.compile_to_c(v, cname, args)
- ctx_old.append(v.ctx)
- v.ctx = ctx_old
- v.unindent
- v.add_instr("}")
var init_table_size = cshe.greaters.length + 1
var init_table_decl = "int init_table[{init_table_size}] = \{0{", 0" * (init_table_size-1)}};"
var init_table_size = cshe.greaters.length + 1
var init_table_decl = "int init_table[{init_table_size}] = \{0{", 0" * (init_table_size-1)}};"