return tree
end
- # Methods that are are still candidate to the try_send
+ # Methods that are still candidate to the try_send
private var totry_methods = new HashSet[MMethod]
+ # Methods that are are no more candidate to the try_send
+ private var totry_methods_to_remove = new Array[MMethod]
+
+ # Methods that are or were candidate to the try_send
+ # Used to ensure that try_send is only used once
+ private var try_methods = new HashSet[MMethod]
+
# The method definitions that remain to visit
private var todo = new List[MMethodDef]
for p in totry_methods do try_send(mtype, p)
for p in live_super_sends do try_super_send(mtype, p)
+ # Remove cleared ones
+ for p in totry_methods_to_remove do totry_methods.remove(p)
+ totry_methods_to_remove.clear
+
var bound_mtype = mtype.anchor_to(mainmodule, recv)
for cd in bound_mtype.collect_mclassdefs(mainmodule)
do
if not live_methoddefs.has(d) then return
end
#print "full property: {mpropdef.mproperty} for {mpropdef.mproperty.mpropdefs.length} definitions"
- totry_methods.remove(mpropdef.mproperty)
+ totry_methods_to_remove.add(mpropdef.mproperty)
end
fun add_send(recv: MType, mproperty: MMethod)
do
- if live_methods.has(mproperty) then return
+ if try_methods.has(mproperty) then return
#print "new prop: {mproperty}"
live_methods.add(mproperty)
+ try_methods.add(mproperty)
if mproperty.mpropdefs.length == 1 then
# If there is only one definition, just add the definition and do not try again the property
var d = mproperty.mpropdefs.first
fun add_type(mtype: MClassType) do analysis.add_new(receiver, mtype)
- fun add_monomorphic_send(mtype: MType, mproperty: MMethod) do analysis.try_send(mtype.as(MClassType), mproperty)
+ fun add_monomorphic_send(mtype: MType, mproperty: MMethod)
+ do
+ analysis.live_methods.add(mproperty)
+ analysis.try_send(mtype.as(MClassType), mproperty)
+ end
fun add_send(mtype: MType, mproperty: MMethod) do analysis.add_send(mtype, mproperty)
#
# Declarations are only useful for scope rules
# Once names are associated with real objects, ther declaration become useless
- # Therefore, if there is no initial value, then just detach it
+ # Therefore, if there is no initial value, then just ignore it
# Else, replace it with a simple assignment
redef fun accept_transform_visitor(v)
do
var nexpr = n_expr
if nexpr == null then
- detach
+ # do nothing
+ # note: not detached because the collection is currently under iteration
else
var nvar = v.builder.make_var_assign(self.variable.as(not null), nexpr)
replace_with(nvar)
# t.to_s
redef fun accept_transform_visitor(v)
do
+ if true then return # FIXME: transformation disabled for the moment
+
var nblock = v.builder.make_block
var arraytype = v.get_class(self, "Array").get_mtype([v.get_class(self, "Object").mclass_type])
var msignature = callsite.msignature
var args = compute_raw_arguments
- self.raw_arguments = args
callsite.check_signature(v, args)
private fun property_name: String is abstract
# An array of all arguments (excluding self)
- var raw_arguments: nullable Array[AExpr]
+ fun raw_arguments: Array[AExpr] do return compute_raw_arguments
private fun compute_raw_arguments: Array[AExpr] is abstract
end
self.callsite = callsite
var args = compute_raw_arguments
- self.raw_arguments = args
callsite.check_signature(v, args)