nitc :: MContract :: adapt_method_to_contract
Method to adapt the givenn_mpropdef.n_block
to the contract
nitc :: MContract :: adapt_msignature
Adapt them_signature
to the contract
nitc :: MContract :: adapt_nsignature
Adapt then_signature
to the contract
nitc :: MContract :: adapt_specific_msignature
Create and return an adaptedMSignature
specifically for the contract in fonction of the given m_signature
nitc :: MContract :: adapt_specific_nsignature
Create and return an adaptedASignature
specifically for the contract in fonction of the given n_signature
nitc :: MContract :: create_inherit_nblock
Creating specific inheritance block contractnitc :: MContract :: create_intro_contract
Create the initial contract (intro)nitc :: MContract :: create_subcontract
Create a contract to check the old (super call) and the new conditionsnitc :: MContract :: defaultinit
nitc :: MContract :: is_already_applied
Is the contract is it already applied on the givenmfacet
nitc :: MContract :: make_contract
Build a new contract method with a specific blockn_block
in a specified mclassdef
nitc :: MContract :: no_intro_contract
Method use to diplay warning when the contract is not present at the introductionnitc :: MEntity :: _const_color
nitc :: MEntity :: _css_classes
CSS classes used to decorateself
nitc :: MEntity :: _deprecation
Is the entity deprecated?nitc :: MMethod :: _getter_for
The attribute this getter is fornitc :: MEntity :: _html_full_name
The MEntityfull_name
escaped for HTML
nitc :: MProperty :: _intro_mclassdef
The classdef that introduce the propertynitc :: MProperty :: _is_after_all
Does self have theafter_all
annotation?
nitc :: MProperty :: _is_autoinit
Is the property usable as an initializer?nitc :: MProperty :: _is_before_all
Does self have thebefore_all
annotation?
nitc :: MEntity :: _is_broken
The indication that the entity did not pass some semantic verifications.nitc :: MProperty :: _is_example
nitc :: MMethod :: _is_root_init
The constructor is a (the) root init with empty signature but a set of initializersnitc :: MMethod :: _is_toplevel
Is the property defined at the top_level of the module?nitc :: MMethod :: _mcontract_facet
The contract facet of the methodnitc :: MProperty :: _mpropdefs
All definitions of the property.nitc :: MMethod :: _restful_async
Is this arestful
method to be executed asynchronously
nitc :: MMethod :: _restful_resources
Associated resources within an action, e.g.foo
in http://localhost/foo?arg=bar
nitc :: MMethod :: _restful_verbs
HTTP access methods, e.g.GET
nitc :: MMethod :: _setter_for
The attribute this setter is fornitc :: MProperty :: _visibility
The visibility of the propertyserialization :: Serializable :: accept_inspect_serializer_core
serialization :: Serializable :: accept_json_serializer
Refinable service to customize the serialization of this class to JSONserialization :: Serializable :: accept_msgpack_attribute_counter
Hook to customize the behavior of theAttributeCounter
serialization :: Serializable :: accept_msgpack_serializer
Hook to customize the serialization of this class to MessagePacknitc :: MContract :: adapt_method_to_contract
Method to adapt the givenn_mpropdef.n_block
to the contract
nitc :: MContract :: adapt_msignature
Adapt them_signature
to the contract
nitc :: MContract :: adapt_nsignature
Adapt then_signature
to the contract
nitc :: MContract :: adapt_specific_msignature
Create and return an adaptedMSignature
specifically for the contract in fonction of the given m_signature
nitc :: MContract :: adapt_specific_nsignature
Create and return an adaptedASignature
specifically for the contract in fonction of the given n_signature
nitc :: MEntity :: add_doc_to_infobox
Append an entry for the doc in the given infoboxserialization :: Serializable :: add_to_bundle
Called by[]=
to dynamically choose the appropriate method according
nitc :: MMethod :: build_c_implementation_signature
Similar tobuild_c_signature
but adapted to create the signature expected by JNI for C functions
nitc :: MMethod :: build_ccall
Build a C function call for the FFI implementation (uses friendly naming).nitc :: MMethod :: build_cname
Build a C function name for the FFI implementation (uses friendly naming).nitc :: MMethod :: build_contract_facet
Buildmcontract_facet
if is not exist and return it
nitc :: MMethod :: build_csignature
Build a C function signature for the FFI implementation (uses friendly naming).nitc :: MMethod :: build_ensure
Buildmensure
if is not exist and return it
nitc :: MMethod :: build_expect
Buildmexpect
if is not exist and return it
nitc :: MMethod :: build_jni_format
Returns the JNI signature format of this Nit methodcore :: Object :: class_factory
Implementation used byget_class
to create the specific class.
nitc :: MEntity :: collect_ancestors
Collectself
ancestors (direct and indirect)
nitc :: MEntity :: collect_children
Collectself
children (direct descendants)
nitc :: MEntity :: collect_descendants
Collectself
descendants (direct and direct)
nitc :: MEntity :: collect_linearization
Collectself
linearization anchored on mainmodule
nitc :: MEntity :: collect_metrics
nitc :: MEntity :: collect_modifiers
Collect modifier keywords likeredef
, private
etc
nitc :: MProperty :: collect_mpropdefs
Collect all property definitions ofself
nitc :: MEntity :: collect_parents
Collectself
parents (direct ancestors)
nitc :: MEntity :: const_color
nitc :: MEntity :: const_color=
nitc :: MEntity :: core_serialize_base
serialization :: Serializable :: core_serialize_to
Actual serialization ofself
to serializer
nitc :: MEntity :: create_ast_representation
Build a ANode fromself
nitc :: MMethod :: create_facet
Method to create a facet of the method.nitc :: MContract :: create_inherit_nblock
Creating specific inheritance block contractnitc :: MContract :: create_intro_contract
Create the initial contract (intro)nitc :: MContract :: create_subcontract
Create a contract to check the old (super call) and the new conditionsnitc :: MEntity :: cs_comment
Returns the comment of this MEntity formatted for console.nitc :: MEntity :: cs_declaration
Returns the complete MEntity declaration (modifiers + name + signature).nitc :: MEntity :: cs_full_name
Returnsself.full_name
formatted for console
nitc :: MEntity :: cs_list_item
Returnsself
as a list element that can be displayed in console.
nitc :: MEntity :: cs_location
Source code location of this MEntity formatted for consolenitc :: MEntity :: cs_short_comment
Returns the comment of this MEntity formatted for console.nitc :: MEntity :: cs_signature
Returnsself
signature formatted for console.
nitc :: MEntity :: cs_source_code
Source code associated to this MEntity.nitc :: MEntity :: css_classes=
CSS classes used to decorateself
nitc :: MMethod :: defaultinit
core :: Object :: defaultinit
nitc :: MEntity :: defaultinit
nitc :: TableCallable :: defaultinit
nitc :: HInfoBoxable :: defaultinit
nitc :: MContract :: defaultinit
nitc :: MProperty :: defaultinit
nitc :: MMethod :: define_contract_facet
Define contract facet for MMethod in the given mclassdef. The facet represents the entry point with contracts (expect, ensure) of the method.nitc :: MEntity :: deprecation=
Is the entity deprecated?nitc :: MEntity :: field_separator
serialization :: Serializable :: from_deserializer
Create an instance of this class from thedeserializer
nitc :: MProperty :: full_name=
The canonical name of the property.nitc :: MMethod :: getter_for=
The attribute this getter is fornitc :: MEntity :: hierarchy_poset
Build a poset representingself
in it's own hierarchy
nitc :: MEntity :: html_declaration
Returns the complete MEntity declaration decorated with HTMLnitc :: MEntity :: html_full_name=
The MEntityfull_name
escaped for HTML
nitc :: MEntity :: html_name=
The MEntity name escaped for HTMLnitc :: MEntity :: html_namespace
Returnsfull_name
decorated with HTML links
nitc :: MEntity :: html_signature
Returns the MEntity signature decorated with HTMLnitc :: HInfoBoxable :: infobox
An new infobox documenting the entitynitc :: MProperty :: intro_mclassdef
The classdef that introduce the propertynitc :: MProperty :: intro_mclassdef=
The classdef that introduce the propertynitc :: MProperty :: is_after_all=
Does self have theafter_all
annotation?
nitc :: MContract :: is_already_applied
Is the contract is it already applied on the givenmfacet
nitc :: MProperty :: is_autoinit=
Is the property usable as an initializer?nitc :: MProperty :: is_before=
Does self have thebefore
annotation?
nitc :: MProperty :: is_before_all
Does self have thebefore_all
annotation?
nitc :: MProperty :: is_before_all=
Does self have thebefore_all
annotation?
nitc :: MEntity :: is_broken=
The indication that the entity did not pass some semantic verifications.nitc :: MProperty :: is_example=
nitc :: MEntity :: is_fictive=
Isself
created for internal purpose?
nitc :: MMethod :: is_init_for
Is the property a legal constructor for a given class?nitc :: MMethod :: is_null_safe
A specific method that is safe to call on null.nitc :: MMethod :: is_root_init
The constructor is a (the) root init with empty signature but a set of initializersnitc :: MMethod :: is_root_init=
The constructor is a (the) root init with empty signature but a set of initializerscore :: 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.
nitc :: MMethod :: is_toplevel
Is the property defined at the top_level of the module?nitc :: MMethod :: is_toplevel=
Is the property defined at the top_level of the module?nitc :: MEntity :: json_namespace
Returnself.full_name
as an object that can be serialized to json.
nitc :: MEntity :: line_separator
nitc :: MEntity :: linkto_text
Link to theself
with a specific text.
nitc :: MProperty :: lookup_all_definitions
Return all definitions in a linearization ordernitc :: MProperty :: lookup_definitions
Return the most specific property definitions defined or inherited by a type.nitc :: MProperty :: lookup_first_definition
Return the most specific definition in the linearization ofmtype
.
nitc :: MProperty :: lookup_super_definitions
Return the most specific property definitions inherited by a type.nitc :: MContract :: make_contract
Build a new contract method with a specific blockn_block
in a specified mclassdef
nitc :: MMethod :: mcontract_facet
The contract facet of the methodnitc :: MMethod :: mcontract_facet=
The contract facet of the methodnitc :: MEntity :: mdoc_or_fallback
The documentation associated to the entity or their main nested entity.nitc :: MProperty :: mpropdefs=
All definitions of the property.serialization :: Serializable :: msgpack_extra_array_items
Hook to request a larger than usual metadata arraycore :: Object :: native_class_name
The class name of the object in CString format.nitc :: MContract :: no_intro_contract
Method use to diplay warning when the contract is not present at the introductioncore :: Object :: output_class_name
Display class name on stdout (debug only).mentity
nitc :: MEntity :: ratings_by_dimension
Get the ratings of adimension
nitc :: MMethod :: restful_async
Is this arestful
method to be executed asynchronously
nitc :: MMethod :: restful_async=
Is this arestful
method to be executed asynchronously
nitc :: MMethod :: restful_resources
Associated resources within an action, e.g.foo
in http://localhost/foo?arg=bar
nitc :: MMethod :: restful_resources=
Associated resources within an action, e.g.foo
in http://localhost/foo?arg=bar
nitc :: MMethod :: restful_verbs
HTTP access methods, e.g.GET
nitc :: MMethod :: restful_verbs=
HTTP access methods, e.g.GET
nitc :: MProperty :: select_most_specific
Return an array containing olny the most specific property definitionsserialization :: Serializable :: serialize_msgpack
Serializeself
to MessagePack bytes
serialization :: Serializable :: serialize_to
Serializeself
to serializer
serialization :: Serializable :: serialize_to_json
Serializeself
to JSON
serialization :: Serializable :: serialize_to_or_delay
Accept references or force direct serialization (usingserialize_to
)
nitc :: MMethod :: setter_for=
The attribute this setter is fornitc :: MMethod :: short_cname
Short name of this method in C (without the class name)nitc :: MEntity :: source_url
Render a HTML link for the MEntity locationserialization :: Serializable :: to_pretty_json
Serializeself
to plain pretty JSON
nitc :: MEntity :: tpl_module
Builds a dot UML package diagram entity fromself
nitc :: MProperty :: visibility=
The visibility of the propertyv.enter_visit
on all nested entities.
nitc :: MEntity :: write_extra_doc
Extra auto documentation to append to thestream
nitc :: MEntity :: write_location
Location (file and line when available) of related declarationsnitc :: MProperty :: write_synopsis
Serializer::serialize
table_send
invariant
and ensure
).
redef class MContract
# Should contract be called?
# return `true` if the contract needs to be called.
private fun is_called(v: ContractsVisitor, mpropdef: MPropDef): Bool
do
return v.toolcontext.opt_full_contract.value
end
# Method use to diplay warning when the contract is not present at the introduction
private fun no_intro_contract(v: ContractsVisitor, a: Array[AAnnotation])do end
# Creating specific inheritance block contract
#
# `super_args` : Correspond to the `super` call arguments
private fun create_inherit_nblock(v: ContractsVisitor, n_conditions: Array[AExpr], super_args: Array[AExpr]): ABlockExpr is abstract
# Method to adapt the given `n_mpropdef.n_block` to the contract
private fun adapt_method_to_contract(v: ContractsVisitor, mfacet: MFacet, n_mpropdef: AMethPropdef) is abstract
# Create and return an adapted `MSignature` specifically for the contract in fonction of the given `m_signature`
private fun adapt_specific_msignature(m_signature: MSignature): MSignature do return m_signature.adapt_to_contract
# Create and return an adapted `ASignature` specifically for the contract in fonction of the given `n_signature`
private fun adapt_specific_nsignature(n_signature: ASignature): ASignature do return n_signature.adapt_to_contract
# Adapt the `m_signature` to the contract
# If `m_signature == null` return a new `MSignature` else it calls a specific adapt method see `adapt_specific_msignature`
private fun adapt_msignature(m_signature: nullable MSignature): MSignature
do
if m_signature == null then return new MSignature(new Array[MParameter])
return adapt_specific_msignature(m_signature)
end
# Adapt the `n_signature` to the contract
# If `n_signature == null` return a new `ASignature` else it calls a specific adapt method see `adapt_specific_nsignature`
private fun adapt_nsignature(n_signature: nullable ASignature): ASignature
do
if n_signature == null then return new ASignature
return adapt_specific_nsignature(n_signature)
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
# Create a contract to check the old (super call) and the new conditions
#
# Example:
# ~~~nitish
# fun contrat([...])
# do
# super # Call the old contracts
# assert new_condition
# end
# ~~~
#
private fun create_subcontract(v: ContractsVisitor, n_conditions: Array[AExpr], mclassdef: MClassDef)
do
var args = v.n_signature.make_parameter_read(v.ast_builder)
var n_block = v.ast_builder.make_block
n_block = self.create_inherit_nblock(v, n_conditions, args)
make_contract(v, n_block, mclassdef)
end
# Build a new contract method with a specific block `n_block` in a specified `mclassdef`
private fun make_contract(v: ContractsVisitor, n_block: AExpr, mclassdef: MClassDef)
do
var n_contractdef = v.toolcontext.modelbuilder.create_method_from_property(self, mclassdef, false, v.m_signature)
# Set the signature to keep the same variable
n_contractdef.n_signature = v.n_signature
n_contractdef.n_block = n_block
# Define the location of the new method for corresponding of the annotation location
n_contractdef.location = v.current_location
n_contractdef.do_all(v.toolcontext)
end
end
src/contracts.nit:272,1--370,3