nitlanguage
/
nit.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
model: `new` factories have a return type.
[nit.git]
/
src
/
rapid_type_analysis.nit
diff --git
a/src/rapid_type_analysis.nit
b/src/rapid_type_analysis.nit
index
3d8fb9e
..
f63034c
100644
(file)
--- a/
src/rapid_type_analysis.nit
+++ b/
src/rapid_type_analysis.nit
@@
-31,6
+31,7
@@
private import ordered_tree # for live_methods_to_tree
private import more_collections
redef class ModelBuilder
private import more_collections
redef class ModelBuilder
+ # Performs a rapid-type-analysis on the program associated with `mainmodule`.
fun do_rapid_type_analysis(mainmodule: MModule): RapidTypeAnalysis
do
var analysis = new RapidTypeAnalysis(self, mainmodule)
fun do_rapid_type_analysis(mainmodule: MModule): RapidTypeAnalysis
do
var analysis = new RapidTypeAnalysis(self, mainmodule)
@@
-236,20
+237,16
@@
class RapidTypeAnalysis
if not modelbuilder.mpropdef2npropdef.has_key(mmethoddef) then
# It is an init for a class?
if not modelbuilder.mpropdef2npropdef.has_key(mmethoddef) then
# It is an init for a class?
- if mmeth.name == "init" then
+ if mmeth.is_root_init then
var nclassdef = self.modelbuilder.mclassdef2nclassdef[mmethoddef.mclassdef]
assert mmethoddef == nclassdef.mfree_init
var nclassdef = self.modelbuilder.mclassdef2nclassdef[mmethoddef.mclassdef]
assert mmethoddef == nclassdef.mfree_init
- var super_inits = nclassdef.super_inits
- if super_inits != null then
- #assert args.length == 1
- for su in super_inits do
- v.add_monomorphic_send(v.receiver, su)
- end
- end
if mmethoddef.mproperty.is_root_init and not mmethoddef.is_intro then
self.add_super_send(v.receiver, mmethoddef)
end
if mmethoddef.mproperty.is_root_init and not mmethoddef.is_intro then
self.add_super_send(v.receiver, mmethoddef)
end
+ else if mmethoddef.constant_value != null then
+ # Make the return type live
+ v.add_type(mmethoddef.msignature.return_mtype.as(MClassType))
else
abort
end
else
abort
end
@@
-270,9
+267,7
@@
class RapidTypeAnalysis
end
end
end
end
- if mmeth.is_new then
- v.add_type(v.receiver)
- else if mmethoddef.is_intern or mmethoddef.is_extern then
+ if mmethoddef.is_intern or mmethoddef.is_extern 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
# 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
@@
-681,6
+676,8
@@
redef class AForExpr
abort
end
v.add_callsite(self.method_next)
abort
end
v.add_callsite(self.method_next)
+ var mf = self.method_finish
+ if mf != null then v.add_callsite(mf)
end
end
end
end