From: Jean Privat Date: Thu, 12 Feb 2009 02:02:58 +0000 (-0500) Subject: Do not use CALL macro directly. X-Git-Tag: v0.2.1~34 X-Git-Url: http://nitlanguage.org Do not use CALL macro directly. Instead generate specific call macro for methods and use them. --- diff --git a/src/compiling/compiling_base.nit b/src/compiling/compiling_base.nit index af34c05..93ba9fe 100644 --- a/src/compiling/compiling_base.nit +++ b/src/compiling/compiling_base.nit @@ -306,5 +306,11 @@ redef class MMLocalProperty do return "COLOR_SUPER_{cname}" end + + # C macro used to get the function for the call of a super property + meth super_meth_call: String + do + return "CALL_SUPER_{cname}" + end end diff --git a/src/compiling/compiling_global.nit b/src/compiling/compiling_global.nit index c0407e4..f79a631 100644 --- a/src/compiling/compiling_global.nit +++ b/src/compiling/compiling_global.nit @@ -509,16 +509,23 @@ redef class MMSrcModule for pg in c.global_properties do var p = c[pg] if p.local_class == c then - if pg.intro == p and p isa MMAttribute then - if v.tc.attr_sim then - var bc = pg.local_class - assert bc isa MMSrcLocalClass - var s = bc.base_attr_pos.symbol - v.add_decl("#define {pg.attr_access}(recv) ATTRS(recv, {s}, {pg.pos_of})") - else - v.add_decl("#define {pg.attr_access}(recv) ATTR(recv, {pg.color_id})") + if pg.intro == p then + if p isa MMAttribute then + if v.tc.attr_sim then + var bc = pg.local_class + assert bc isa MMSrcLocalClass + var s = bc.base_attr_pos.symbol + v.add_decl("#define {pg.attr_access}(recv) ATTRS(recv, {s}, {pg.pos_of})") + else + v.add_decl("#define {pg.attr_access}(recv) ATTR(recv, {pg.color_id})") + end + else if p isa MMMethod then + v.add_decl("#define {pg.meth_call}(recv) (({p.cname}_t)CALL((recv), {pg.color_id}))") end end + if p isa MMSrcMethod and p.need_super then + v.add_decl("#define {p.super_meth_call}(recv) (({p.cname}_t)CALL((recv), {p.color_id_for_super}))") + end p.compile_property_to_c(v) end if pg.is_init_for(c) then diff --git a/src/compiling/compiling_methods.nit b/src/compiling/compiling_methods.nit index b744d07..ed0c4ab 100644 --- a/src/compiling/compiling_methods.nit +++ b/src/compiling/compiling_methods.nit @@ -302,7 +302,7 @@ redef class MMMethod cargs.add("init_table /*YYY*/") end - var m = "(({cname}_t)CALL({cargs[0]},{global.color_id}))" + var m = "{global.meth_call}({cargs[0]})" var vcall = "{m}({cargs.join(", ")}) /*{local_class}::{name}*/" if name == ee then vcall = "UNTAG_Bool({vcall})" @@ -331,7 +331,7 @@ redef class MMMethod # Compile a call as call-next-method on self with given args meth compile_super_call(v: CompilerVisitor, cargs: Array[String]): String do - var m = "(({cname}_t)CALL({cargs[0]},{color_id_for_super}))" + var m = "{super_meth_call}({cargs[0]})" var vcall = "{m}({cargs.join(", ")}) /*super {local_class}::{name}*/" return vcall end