nitc :: CallSiteVisitor :: defaultinit
# This visitor checks the `callsite` to see if the target `mpropdef` has a contract.
private class CallSiteVisitor
super Visitor
# Instance of the toolcontext
var toolcontext: ToolContext
var ast_builder: ASTBuilder
# Actual visited method
var visited_propdef: APropdef is noinit
redef fun visit(node)
do
node.check_callsite(self)
node.visit_all(self)
end
# Check if the callsite is bound on a property with a contract.
# If the property is linked to a contract a new callsite will be created towards the correct facet,
# in the other case the returned callsite wall be the same as the given `callsite`
private fun drive_callsite_to_contract(callsite: CallSite): CallSite
do
var contract_facet = callsite.mproperty.mcontract_facet
var visited_mpropdef = visited_propdef.mpropdef
if visited_mpropdef isa MContract or visited_mpropdef isa MFacet then return callsite
if visited_mpropdef == null or contract_facet == null then return callsite
return ast_builder.create_callsite(toolcontext.modelbuilder, visited_propdef, contract_facet, callsite.recv_is_self)
end
end
src/contracts.nit:218,1--249,3