All contracts have the same implementation for the introduction.
Example:
fun contrat([...])
do
assert contract_condition
end
# Create the initial contract (intro)
# All contracts have the same implementation for the introduction.
#
# Example:
# ~~~nitish
# fun contrat([...])
# do
# assert contract_condition
# end
# ~~~
#
private fun create_intro_contract(v: ContractsVisitor, n_conditions: Array[AExpr], mclassdef: MClassDef)
do
var n_block = v.ast_builder.make_block
for n_condition in n_conditions do
# Create a new tid to set the name of the assert for more explicit error
var tid = new TId.init_tk(n_condition.location)
tid.text = "{n_condition.location.text}"
var n_assert = v.ast_builder.make_assert(tid, n_condition, null)
# Define the assert location to reference the annoation
n_assert.location = n_condition.location
n_block.add n_assert
end
make_contract(v, n_block, mclassdef)
end
src/contracts.nit:314,2--338,4