do
return "ATTR_{intro.cname}"
end
+
+ # C symbol refering a virtual type class color
+ fun vt_class_color: String
+ do
+ return "VTCOLOR_{intro.cname}"
+ end
+
+ # C symbol refering a virtual type class id
+ fun vt_class_id: String
+ do
+ return "VTID_{intro.cname}"
+ end
end
redef class MMGlobalClass
end
end
+redef class TableEltVTClassColor
+ redef fun compile_macros(v, value)
+ do
+ var pg = property.global
+ v.add_decl("#define {pg.vt_class_color}(recv) (VAL2VFT(recv)[{value}].i)")
+ end
+
+ redef fun compile_to_c(v, c)
+ do
+ var prog = v.program
+ var p = c[property.global]
+ var g = p.signature_for(c.get_type).return_type.local_class.global
+ var col = g.intro.as(MMConcreteClass).class_color_pos
+ return "{prog.table_information.color(col)} /* {prog.table_information.color(self)}: VT {c}::{p} : color of {g} */"
+ end
+end
+
+redef class TableEltVTClassId
+ redef fun compile_macros(v, value)
+ do
+ var pg = property.global
+ v.add_decl("#define {pg.vt_class_id}(recv) (VAL2VFT(recv)[{value}].i)")
+ end
+
+ redef fun compile_to_c(v, c)
+ do
+ var prog = v.program
+ var p = c[property.global]
+ var g = p.signature_for(c.get_type).return_type.local_class.global
+ return "{prog.compiled_classes[g].id} /* {prog.table_information.color(self)}: VT {c}::{p} : id of {g} */"
+ end
+end
+
redef class TableEltAttr
redef fun compile_macros(v, value)
do
end
end
+
redef class AbsTableEltClass
# The C macro name refering the value
fun symbol: String is abstract
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(expr2)
var w = new_result(v)
w.add("TAG_Bool(")
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
ilt.add(new TableEltAttr(p))
else if p isa MMMethod then
clt.add(new TableEltMeth(p))
+ else if p isa MMTypeProperty then
+ clt.add(new TableEltVTClassId(p))
+ clt.add(new TableEltVTClassColor(p))
end
end
if p isa MMMethod and p.need_super then
super TableEltProp
end
+# An element that represents a class color value for a virtual type
+class TableEltVTClassColor
+ super TableEltProp
+end
+
+# An element that represents a class id value for a virtual type
+class TableEltVTClassId
+ super TableEltProp
+end
+
# An element that represents a function pointer to the super method of a local method
class TableEltSuper
super TableEltProp