Difference between revisions of "XCSG:InstanceMethod"

From AtlasWiki
Jump to: navigation, search
(Created page with "The semantics of Method are those common to UML [5, pp. 2-47, 2-66], MS-IL [27, p. 14], and the JVM [36, p. 34, 2.6]. If the operation is a query, then the body of the method...")
 
(Specification)
 
(10 intermediate revisions by 2 users not shown)
Line 1: Line 1:
The semantics of Method are those common to UML [5, pp. 2-47, 2-66], MS-IL [27, p. 14], and the JVM [36, p. 34, 2.6].
+
An InstanceMethod is a [[Method]] associated with instances of a [[Classifier]], it has an implicit <code>this</code> [[parameter]], which is reified in an XCSG graph; Methods of [[InnerClass|inner classes]] result in additional implicit parameters, which are likewise reified.
 
+
If the operation is a query, then the body of the method must not produce any side effects.
+
 
+
The signature of the method must “match” that of the operation it implements.
+
 
+
Compared to the pre and postconditions for the operation it implements, the method’s precondition must be weaker than or the same as that associated with the operation, and the method’s postcondition must be stronger than or the same (in accordance with LSP).
+
 
+
The visibility of the method must be the same as the operation it implements.
+
 
+
The operation implemented by the method must either be defined by or inherited by the classifier that owns the method.
+
 
+
The method must implement the last overridden definition of the operation.
+
 
+
There may be at most one method defined for each operation in a given classifier.
+
 
+
Additional constraints, however, are required to ensure the body of the method is well-formed and consistent with the specification.  For example, if the signature of the operation specifies a return parameter, the method body must terminate with the execution of a MethodReturn that generates a value of the appropriate type.  If the operation permits the throwing of only certain exceptions, then the throwing of an exception that is not in this list should not be permitted.  And so on.
+
 
+
The attribute implicitOverride indicates whether the method implicitly overrides an inherited method with a matching signature.  If the method does not override an inherited method at all, or if the overriding is explicitly specified by the user (as in C#), this property should be set to false.  Otherwise, if the method does override an inherited method and this is implied by language rules for matching signatures (as in C++ and Java), this property should be set to true.
+
 
+
The attribute inline is regarded as a hint to the compiler that the method should be considered as a candidate for inlining.  It does not gurantee that calls to the method will always be inlined.  In particular, calls that involve dynamic dispatch are generally not inlined irrespective of the value of this attribute.
+
The inlining of a method should not affect its semantics.
+
  
 
== Specification ==
 
== Specification ==
{| class="atlaswikitable" style="width:100%"
+
{{Node
! width="160" align="left" | Metaclass
+
| extends = Method
| InstanceMethod
+
| description = A [[Method]] associated with instances of a [[Classifier]]
|-
+
}}
! Extends
+
| [[Method]]
+
|-
+
! Description
+
| A method associated with the instances of a classifier
+
|}
+
 
+
{| class="atlaswikitable"  style="width:100%"
+
! width="160"| Attribute
+
| implicitOverride
+
|-
+
! Description
+
| Does the method implicitly override an inherited method with a matching signature?
+
|}
+
 
+
{| class="atlaswikitable"  style="width:100%"
+
! width="160"|Tag
+
| inline
+
|-
+
! Description
+
| Should calls to the method be inlined (if possible)?
+
|}
+
 
+
A method provides an implementation for an operation.  Often a number of methods (associated with different classifiers) provide alternate implementations for the same operation.  The body of the method consists of a series of statements.
+
 
+
== Language mappings ==
+
Member functions in C++ and methods in Java that are concrete (are not declared pure virtual or abstract) map to methods.
+

Latest revision as of 13:53, 17 April 2014

An InstanceMethod is a Method associated with instances of a Classifier, it has an implicit this parameter, which is reified in an XCSG graph; Methods of inner classes result in additional implicit parameters, which are likewise reified.

Specification

Metaclass InstanceMethod
Extends Method
Description A Method associated with instances of a Classifier
All Superkinds Method, Function, Node, ModelElement
Specified In Edges
In Edge Predecessor Multiplicity Description
Overrides InstanceMethod Connects an InstanceMethod to another InstanceMethod that it overrides.

Inherited From In Edge Predecessor Multiplicity Description
Method InvokedSignature DynamicDispatchCallSite Connects a DynamicDispatchCallSite to the definition of the invoked Method of the InvokedType; if the Method is not defined or overridden in the InvokedType, it points to the inherited Method.
Function Call Function Indicates the possibility of one or more calls to the Function pointed to within the Function that the edge comes from.

InvokedFunction StaticCallSite Connects a StaticCallSite to the exact Function called.
ReadsFunctionAddress Function 1 Connects a Function to a Function that it takes the address of.
Specified Out Edges
Out Edge Successor Multiplicity Description
Overrides InstanceMethod 0..1 Connects an InstanceMethod to another InstanceMethod that it overrides.

Inherited From Out Edge Successor Multiplicity Description
Method Java:AnnotatedWith Java:Annotation Connects a Java element to an annotation on that Java element.
Function Call Function Indicates the possibility of one or more calls to the Function pointed to within the Function that the edge comes from.

HasControlFlow ControlFlow (Node) Connects a Function to any ControlFlow (Node)s it contains.
HasParameter Parameter Connects a Function to a Parameter of that Function.
HasReturnValue ReturnValue 0..1 Connects a (non-void) Function to its MasterReturn node.
ReadsFunctionAddress Function Connects a Function to a Function that it takes the address of.
ReadsVariable InstanceVariable Connects a Function to a InstanceVariable or ProgramVariable that it reads.

ProgramVariable
Returns Type 1 Connects a Function to the Type of its return value (which may be Void).
Known Possible In Edges

Inherited From In Edge Predecessor Multiplicity Description
Node Contains Node 1 Indicates that the predecessor contains the successor in a sense specified by the specific type of Contains edge.
Known Possible Out Edges

Inherited From Out Edge Successor Multiplicity Description
Method Java:ThrowsClause Java:Class Indicates a Java Method specifies that it may throw an exception of the indicated type (which must extend java.lang.Throwable).
Node Contains Node Indicates that the predecessor contains the successor in a sense specified by the specific type of Contains edge.