nitlanguage
/
nit.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
RTA: force primitive types to be alive
[nit.git]
/
src
/
rapid_type_analysis.nit
diff --git
a/src/rapid_type_analysis.nit
b/src/rapid_type_analysis.nit
index
3c32689
..
e2422aa
100644
(file)
--- a/
src/rapid_type_analysis.nit
+++ b/
src/rapid_type_analysis.nit
@@
-81,6
+81,12
@@
class RapidTypeAnalysis
# The method definitions that remain to visit
private var todo = new List[MMethodDef]
# The method definitions that remain to visit
private var todo = new List[MMethodDef]
+ private fun force_alive(classname: String)
+ do
+ var classes = self.modelbuilder.model.get_mclasses_by_name(classname)
+ if classes != null then for c in classes do self.add_new(c.mclass_type, c.mclass_type)
+ end
+
# Run the analysis until all visitable method definitions are visited.
fun run_analysis
do
# Run the analysis until all visitable method definitions are visited.
fun run_analysis
do
@@
-96,9
+102,11
@@
class RapidTypeAnalysis
add_send(maintype, mainprop)
end
add_send(maintype, mainprop)
end
- # Force Bool
- var classes = self.modelbuilder.model.get_mclasses_by_name("Bool")
- if classes != null then for c in classes do self.add_new(c.mclass_type, c.mclass_type)
+ # Force primitive types
+ force_alive("Bool")
+ force_alive("Int")
+ force_alive("Float")
+ force_alive("Char")
while not todo.is_empty do
var mmethoddef = todo.shift
while not todo.is_empty do
var mmethoddef = todo.shift
@@
-112,9
+120,9
@@
class RapidTypeAnalysis
#elttype = elttype.anchor_to(self.mainmodule, v.receiver)
var vararg = self.mainmodule.get_primitive_class("Array").get_mtype([elttype])
v.add_type(vararg)
#elttype = elttype.anchor_to(self.mainmodule, v.receiver)
var vararg = self.mainmodule.get_primitive_class("Array").get_mtype([elttype])
v.add_type(vararg)
- v.add_monomorphic_send(vararg, self.modelbuilder.force_get_primitive_method(node, "with_native", vararg.mclass, self.mainmodule))
var native = self.mainmodule.get_primitive_class("NativeArray").get_mtype([elttype])
v.add_type(native)
var native = self.mainmodule.get_primitive_class("NativeArray").get_mtype([elttype])
v.add_type(native)
+ v.add_monomorphic_send(vararg, self.modelbuilder.force_get_primitive_method(node, "with_native", vararg.mclass, self.mainmodule))
end
end
@@
-153,12
+161,16
@@
class RapidTypeAnalysis
v.add_monomorphic_send(v.receiver, auto_super_init)
end
end
v.add_monomorphic_send(v.receiver, auto_super_init)
end
end
- else if npropdef isa AInternMethPropdef or npropdef isa AExternMethPropdef then
+ else if npropdef isa AInternMethPropdef or
+ (npropdef isa AExternMethPropdef and npropdef.n_extern != null) then
# UGLY: We force the "instantation" of the concrete return type if any
var ret = mmethoddef.msignature.return_mtype
if ret != null and ret isa MClassType and ret.mclass.kind != abstract_kind and ret.mclass.kind != interface_kind then
v.add_type(ret)
end
# UGLY: We force the "instantation" of the concrete return type if any
var ret = mmethoddef.msignature.return_mtype
if ret != null and ret isa MClassType and ret.mclass.kind != abstract_kind and ret.mclass.kind != interface_kind then
v.add_type(ret)
end
+ else if npropdef isa AExternMethPropdef then
+ var nclassdef = npropdef.parent.as(AClassdef)
+ v.enter_visit(npropdef)
else if npropdef isa AExternInitPropdef then
v.add_type(v.receiver)
else
else if npropdef isa AExternInitPropdef then
v.add_type(v.receiver)
else
@@
-428,7
+440,7
@@
redef class AStringFormExpr
do
var native = v.get_class("NativeString").mclass_type
v.add_type(native)
do
var native = v.get_class("NativeString").mclass_type
v.add_type(native)
- var prop = v.get_method(native, "to_s")
+ var prop = v.get_method(native, "to_s_with_length")
v.add_monomorphic_send(native, prop)
end
end
v.add_monomorphic_send(native, prop)
end
end