args = v.frame.arguments
end
- var mproperty = self.mproperty
- if mproperty != null then
- if mproperty.intro.msignature.arity == 0 then
+ var callsite = self.callsite
+ if callsite != null then
+ if callsite.mproperty.intro.msignature.arity == 0 then
args = [recv]
end
# Super init call
- var res = v.send(mproperty, args)
+ var res = v.compile_callsite(callsite, args)
return res
end
redef class ASendExpr
redef fun accept_auto_super_init(v)
do
- var mproperty = self.mproperty
+ var mproperty = self.callsite.mproperty
if mproperty == null then return
if mproperty.is_init then
v.has_explicit_super_init = true
return
end
n.visit_all(self)
- if n isa ASuperExpr and n.mproperty == null then
+ if n isa ASuperExpr and n.callsite == null then
var mprop = mpropdef
assert mprop != null
res.add(mprop)
var vari = v.frame.map[self.variable.as(not null)]
var value = v.expr(self.n_value)
if value == null then return
- var res = v.send(reassign_property.mproperty, [vari, value])
+ var res = v.send(reassign_callsite.mproperty, [vari, value])
assert res != null
v.frame.map[self.variable.as(not null)] = res
end
if i == null then return null
args.add(i)
end
- var mproperty = self.mproperty.as(not null)
- var res = v.send(mproperty, args)
+ var res = v.send(callsite.mproperty, args)
return res
end
end
var value = v.expr(self.n_value)
if value == null then return
- var mproperty = self.mproperty.as(not null)
- var read = v.send(mproperty, args)
+ var read = v.send(callsite.mproperty, args)
assert read != null
- var write = v.send(self.reassign_property.mproperty, [read, value])
+ var write = v.send(reassign_callsite.mproperty, [read, value])
assert write != null
args.add(write)
- v.send(self.write_mproperty.as(not null), args)
+ v.send(write_callsite.mproperty, args)
end
end
args = v.frame.arguments
end
- var mproperty = self.mproperty
- if mproperty != null then
- if mproperty.intro.msignature.arity == 0 then
+ var callsite = self.callsite
+ if callsite != null then
+ if callsite.mproperty.intro.msignature.arity == 0 then
args = [recv]
end
# Super init call
- var res = v.send(mproperty, args)
+ var res = v.send(callsite.mproperty, args)
return res
end
if i == null then return null
args.add(i)
end
- var mproperty = self.mproperty.as(not null)
- var res2 = v.send(mproperty, args)
+ var res2 = v.send(callsite.mproperty, args)
if res2 != null then
#self.debug("got {res2} from {mproperty}. drop {recv}")
return res2
if value == null then return
var mproperty = self.mproperty.as(not null)
var attr = v.read_attribute(mproperty, recv)
- var res = v.send(reassign_property.mproperty, [attr, value])
+ var res = v.send(reassign_callsite.mproperty, [attr, value])
assert res != null
assert recv isa MutableInstance
recv.attributes[mproperty] = res
fun add_send(mtype: MType, mproperty: MMethod) do analysis.add_send(mtype, mproperty)
fun add_cast_type(mtype: MType) do analysis.add_cast(mtype)
+
+ fun add_callsite(callsite: nullable CallSite) do if callsite != null then analysis.add_send(callsite.recv, callsite.mproperty)
end
###
redef class ASendExpr
redef fun accept_rapid_type_visitor(v)
do
- var mproperty = self.mproperty.as(not null)
- var recvtype = self.n_expr.mtype.as(not null)
- v.add_send(recvtype, mproperty)
+ v.add_callsite(callsite)
end
end
redef class ASendReassignFormExpr
redef fun accept_rapid_type_visitor(v)
do
- v.add_send(self.read_type.as(not null), self.reassign_property.mproperty)
- var mproperty = self.mproperty.as(not null)
- var write_mproperty = self.write_mproperty.as(not null)
- if n_expr isa ASelfExpr then
- v.add_monomorphic_send(v.receiver, mproperty)
- v.add_monomorphic_send(v.receiver, write_mproperty)
- else
- var recvtype = self.n_expr.mtype.as(not null)
- v.add_send(recvtype, mproperty)
- v.add_send(recvtype, write_mproperty)
- end
+ v.add_callsite(callsite)
+ v.add_callsite(reassign_callsite)
+ v.add_callsite(write_callsite)
end
end
redef class AVarReassignExpr
redef fun accept_rapid_type_visitor(v)
do
- v.add_send(self.read_type.as(not null), self.reassign_property.mproperty)
+ v.add_callsite(reassign_callsite)
end
end
redef class AAttrReassignExpr
redef fun accept_rapid_type_visitor(v)
do
- v.add_send(self.read_type.as(not null), self.reassign_property.mproperty)
+ v.add_callsite(reassign_callsite)
end
end
redef class ASuperExpr
redef fun accept_rapid_type_visitor(v)
do
- var mproperty = self.mproperty
- if mproperty != null then
- v.add_monomorphic_send(v.receiver, mproperty)
+ var callsite = self.callsite
+ if callsite != null then
+ v.add_callsite(callsite)
return
end
do
var mtype = self.mtype.as(MClassType)
v.add_type(mtype)
- var mproperty = self.mproperty.as(not null)
- v.add_monomorphic_send(mtype, mproperty)
+ v.add_callsite(callsite)
end
end
end
redef class AReassignFormExpr
- # @depreciated use `reassign_callsite`
- fun reassign_property: nullable MMethodDef do return self.reassign_callsite.mpropdef
-
# The method designed by the reassign operator.
var reassign_callsite: nullable CallSite
## MESSAGE SENDING AND PROPERTY
redef class ASendExpr
- # @depreciated: use `callsite`
- fun mproperty: nullable MMethod do return callsite.mproperty
-
# The property invoked by the send.
var callsite: nullable CallSite
end
redef class ASendReassignFormExpr
- # @depreciated use `write_callsite`
- fun write_mproperty: nullable MMethod do return write_callsite.mproperty
-
# The property invoked for the writing
var write_callsite: nullable CallSite
redef class ASuperExpr
# The method to call if the super is in fact a 'super init call'
# Note: if the super is a normal call-next-method, then this attribute is null
- var mproperty: nullable MMethod
+ var callsite: nullable CallSite
redef fun accept_typing(v)
do
v.error(self, "Error: No super method to call for {mproperty}.")
return
end
- self.mproperty = superprop.mproperty
- var args = self.n_args.to_a
var msignature = v.resolve_signature_for(superprop, recvtype, true)
+ var callsite = new CallSite(self, recvtype, true, superprop.mproperty, superprop, msignature, false)
+ self.callsite = callsite
+
+ var args = self.n_args.to_a
if args.length > 0 then
- v.check_signature(self, args, mproperty.name, msignature)
+ callsite.check_signature(v, args)
else
# TODO: Check signature
end
####
redef class ANewExpr
- # @depreciated use `callsite`
- fun mproperty: nullable MMethod do return self.callsite.mproperty
-
# The constructor invoked by the new.
var callsite: nullable CallSite
Sys Bool Int A B C
Number of live runtime types (instantied resolved type): 6
Sys Bool Int A B C
-Number of live methods: 11
+Number of live methods: 14
Number of live method definitions: 14
Number of live runtime cast types (ie used in as and isa): 0