callsite
to see if the target mpropdef
has a contract.nitc :: CallSiteVisitor :: _ast_builder
nitc :: CallSiteVisitor :: _toolcontext
Instance of the toolcontextnitc :: CallSiteVisitor :: _visited_propdef
Actual visited methodnitc :: CallSiteVisitor :: ast_builder
nitc :: CallSiteVisitor :: ast_builder=
nitc :: CallSiteVisitor :: defaultinit
nitc :: CallSiteVisitor :: drive_callsite_to_contract
Check if the callsite is bound on a property with a contract.nitc :: CallSiteVisitor :: toolcontext
Instance of the toolcontextnitc :: CallSiteVisitor :: toolcontext=
Instance of the toolcontextnitc :: CallSiteVisitor :: visited_propdef
Actual visited methodnitc :: CallSiteVisitor :: visited_propdef=
Actual visited methodnitc $ CallSiteVisitor :: SELF
Type of this instance, automatically specialized in every classnitc $ CallSiteVisitor :: visit
What the visitor do when a node is visitednitc :: CallSiteVisitor :: _ast_builder
nitc :: CallSiteVisitor :: _toolcontext
Instance of the toolcontextnitc :: CallSiteVisitor :: _visited_propdef
Actual visited methodnitc :: CallSiteVisitor :: ast_builder
nitc :: CallSiteVisitor :: ast_builder=
core :: Object :: class_factory
Implementation used byget_class
to create the specific class.
nitc :: Visitor :: current_node=
The current visited nodenitc :: Visitor :: defaultinit
nitc :: CallSiteVisitor :: defaultinit
core :: Object :: defaultinit
nitc :: CallSiteVisitor :: drive_callsite_to_contract
Check if the callsite is bound on a property with a contract.nitc :: Visitor :: enter_visit
Ask the visitor to visit a given node.core :: Object :: is_same_instance
Return true ifself
and other
are the same instance (i.e. same identity).
core :: Object :: is_same_serialized
Isself
the same as other
in a serialization context?
core :: Object :: is_same_type
Return true ifself
and other
have the same dynamic type.
core :: Object :: native_class_name
The class name of the object in CString format.core :: Object :: output_class_name
Display class name on stdout (debug only).nitc :: CallSiteVisitor :: toolcontext
Instance of the toolcontextnitc :: CallSiteVisitor :: toolcontext=
Instance of the toolcontextnitc :: CallSiteVisitor :: visited_propdef
Actual visited methodnitc :: CallSiteVisitor :: visited_propdef=
Actual visited method
# 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