From 747f7e86797b174e23156daeeedf040773896245 Mon Sep 17 00:00:00 2001 From: Jean Privat Date: Tue, 16 Jun 2015 09:28:56 -0400 Subject: [PATCH] rta: new method `allocate_mtype` to factorize some code Signed-off-by: Jean Privat --- src/rapid_type_analysis.nit | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/src/rapid_type_analysis.nit b/src/rapid_type_analysis.nit index 9010dde..8fd6ed4 100644 --- a/src/rapid_type_analysis.nit +++ b/src/rapid_type_analysis.nit @@ -519,31 +519,42 @@ redef class ANode end end +redef class AExpr + # Make the `mtype` of the expression live + # Used by literals and instantiations + fun allocate_mtype(v: RapidTypeVisitor) + do + var mtype = self.mtype + if not mtype isa MClassType then return + v.add_type(self.mtype.as(MClassType)) + end +end + redef class AIntExpr redef fun accept_rapid_type_visitor(v) do - v.add_type(self.mtype.as(MClassType)) + allocate_mtype(v) end end redef class AByteExpr redef fun accept_rapid_type_visitor(v) do - v.add_type(self.mtype.as(MClassType)) + allocate_mtype(v) end end 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 - v.add_type(self.mtype.as(MClassType)) + allocate_mtype(v) end end @@ -610,14 +621,14 @@ end 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 - v.add_type(self.mtype.as(MClassType)) + allocate_mtype(v) end end -- 1.7.9.5