nitlanguage
/
nit.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
lib/standard: Added fixed-size integers to standard
[nit.git]
/
src
/
rapid_type_analysis.nit
diff --git
a/src/rapid_type_analysis.nit
b/src/rapid_type_analysis.nit
index
734a76a
..
9ef5320
100644
(file)
--- a/
src/rapid_type_analysis.nit
+++ b/
src/rapid_type_analysis.nit
@@
-82,6
+82,10
@@
class RapidTypeAnalysis
# Live methods.
var live_methods = new HashSet[MMethod]
# Live methods.
var live_methods = new HashSet[MMethod]
+ # Live mmodules.
+ # Those with a live method definitions (see `live_methoddefs`)
+ var live_mmodules = new HashSet[MModule]
+
# Live callsites.
var live_callsites = new HashSet[CallSite]
# Live callsites.
var live_callsites = new HashSet[CallSite]
@@
-209,10
+213,16
@@
class RapidTypeAnalysis
# Force primitive types
force_alive("Bool")
# Force primitive types
force_alive("Bool")
- force_alive("Int")
force_alive("Float")
force_alive("Char")
force_alive("Pointer")
force_alive("Float")
force_alive("Char")
force_alive("Pointer")
+ force_alive("Byte")
+ force_alive("Int")
+ force_alive("Int8")
+ force_alive("Int16")
+ force_alive("UInt16")
+ force_alive("Int32")
+ force_alive("UInt32")
while not todo.is_empty do
var mmethoddef = todo.shift
while not todo.is_empty do
var mmethoddef = todo.shift
@@
-358,7
+368,7
@@
class RapidTypeAnalysis
for npropdef in modelbuilder.collect_attr_propdef(cd) do
if not npropdef.has_value then continue
for npropdef in modelbuilder.collect_attr_propdef(cd) do
if not npropdef.has_value then continue
- var mpropdef = npropdef.mpropdef.as(not null)
+ var mpropdef = npropdef.mreadpropdef.as(not null)
var v = new RapidTypeVisitor(self, bound_mtype, mpropdef)
v.enter_visit(npropdef.n_expr)
v.enter_visit(npropdef.n_block)
var v = new RapidTypeVisitor(self, bound_mtype, mpropdef)
v.enter_visit(npropdef.n_expr)
v.enter_visit(npropdef.n_block)
@@
-388,6
+398,7
@@
class RapidTypeAnalysis
do
if live_methoddefs.has(mpropdef) then return
live_methoddefs.add(mpropdef)
do
if live_methoddefs.has(mpropdef) then return
live_methoddefs.add(mpropdef)
+ live_mmodules.add(mpropdef.mclassdef.mmodule)
todo.add(mpropdef)
var mproperty = mpropdef.mproperty
todo.add(mpropdef)
var mproperty = mpropdef.mproperty
@@
-518,24
+529,35
@@
redef class ANode
end
end
end
end
-redef class AIntExpr
- redef fun accept_rapid_type_visitor(v)
+redef class AExpr
+ # Make the `mtype` of the expression live
+ # Used by literals and instantiations
+ fun allocate_mtype(v: RapidTypeVisitor)
do
do
+ var mtype = self.mtype
+ if not mtype isa MClassType then return
v.add_type(self.mtype.as(MClassType))
end
end
v.add_type(self.mtype.as(MClassType))
end
end
+redef class AIntegerExpr
+ redef fun accept_rapid_type_visitor(v)
+ do
+ allocate_mtype(v)
+ end
+end
+
redef class AFloatExpr
redef fun accept_rapid_type_visitor(v)
do
redef class AFloatExpr
redef fun accept_rapid_type_visitor(v)
do
- v.add_type(self.mtype.as(MClassType))
+ allocate_mtype(v)
end
end
redef class ACharExpr
redef fun accept_rapid_type_visitor(v)
do
end
end
redef class ACharExpr
redef fun accept_rapid_type_visitor(v)
do
- v.add_type(self.mtype.as(MClassType))
+ allocate_mtype(v)
end
end
end
end
@@
-568,7
+590,7
@@
redef class ASuperstringExpr
redef fun accept_rapid_type_visitor(v)
do
var mmodule = v.analysis.mainmodule
redef fun accept_rapid_type_visitor(v)
do
var mmodule = v.analysis.mainmodule
- var object_type = mmodule.object_type
+ var object_type = mmodule.string_type
var arraytype = mmodule.array_type(object_type)
v.add_type(arraytype)
var nattype = mmodule.native_array_type(object_type)
var arraytype = mmodule.array_type(object_type)
v.add_type(arraytype)
var nattype = mmodule.native_array_type(object_type)
@@
-584,7
+606,8
@@
end
redef class ACrangeExpr
redef fun accept_rapid_type_visitor(v)
do
redef class ACrangeExpr
redef fun accept_rapid_type_visitor(v)
do
- var mtype = self.mtype.as(MClassType)
+ var mtype = self.mtype
+ if not mtype isa MClassType then return
v.add_type(mtype)
v.add_callsite(init_callsite)
end
v.add_type(mtype)
v.add_callsite(init_callsite)
end
@@
-593,7
+616,8
@@
end
redef class AOrangeExpr
redef fun accept_rapid_type_visitor(v)
do
redef class AOrangeExpr
redef fun accept_rapid_type_visitor(v)
do
- var mtype = self.mtype.as(MClassType)
+ var mtype = self.mtype
+ if not mtype isa MClassType then return
v.add_type(mtype)
v.add_callsite(init_callsite)
end
v.add_type(mtype)
v.add_callsite(init_callsite)
end
@@
-602,28
+626,32
@@
end
redef class ATrueExpr
redef fun accept_rapid_type_visitor(v)
do
redef class ATrueExpr
redef fun accept_rapid_type_visitor(v)
do
- v.add_type(self.mtype.as(MClassType))
+ allocate_mtype(v)
end
end
redef class AFalseExpr
redef fun accept_rapid_type_visitor(v)
do
end
end
redef class AFalseExpr
redef fun accept_rapid_type_visitor(v)
do
- v.add_type(self.mtype.as(MClassType))
+ allocate_mtype(v)
end
end
redef class AIsaExpr
redef fun accept_rapid_type_visitor(v)
do
end
end
redef class AIsaExpr
redef fun accept_rapid_type_visitor(v)
do
- v.add_cast_type(self.cast_type.as(not null))
+ var cast_type = self.cast_type
+ if cast_type == null then return
+ v.add_cast_type(cast_type)
end
end
redef class AAsCastExpr
redef fun accept_rapid_type_visitor(v)
do
end
end
redef class AAsCastExpr
redef fun accept_rapid_type_visitor(v)
do
- v.add_cast_type(self.mtype.as(not null))
+ var mtype = self.mtype
+ if mtype == null then return
+ v.add_cast_type(mtype)
end
end
end
end