Ad/2010-08-01 Concrete Syntax for a uml action Language for Foundational uml (Alf) Second Revised Submission



Download 1.74 Mb.
Page14/62
Date28.01.2017
Size1.74 Mb.
#9041
1   ...   10   11   12   13   14   15   16   17   ...   62

8.3.4this Expressions


A this expression consists of the keyword this. It evaluates to a reference to the context value for the context in which the this expression occurs.

Syntax

ThisExpression(e: ThisExpression)
= "this"


Figure 8 6 Abstract Syntax of this Expressions



Cross References

  1. Expression see Subclause 8.1

Semantics

The static type of a this expression is the statically determined context classifier for the context in which the this expression occurs. The context classifier is determined as follows.



  • If the expression appears in a method, classifier behavior or property default value, the context classifier is the classifier that owns the method, classifier behavior or property.

  • If the expression appears in a behavior (other than a classifier behavior) that is owned by another behavior, then the context classifier is the context of the owning behavior. (For example, if a state machine is acting as a classifier behavior, then its context classifier is the classifier that owns it, and this is also the context classifier for all effect, entry, exit and do behaviors within it.)

  • Otherwise the context classifier is the behavior containing the this expression.

NOTE. The derivation of the context property of a behavior is defined in Subclause 13.3.2 of the UML Superstructure.

The context value to which a this expression evaluates is determined as follows.



  • For the method of a behavioral feature (see UML Superstructure, Subclause 13.3.3) other than a constuctor, the context value is the value on which the behavioral feature was invoked.

  • For a constructor (see UML Superstructure, Subclause 9.3.1) or propery default value (see UML Superstructure, Subclause 7.3.44), the context object is the newly constructed value.

  • For a classifier behavior (see UML Superstructure, Subclause 13.3.4), the context value is the instance of the active class for which the behavior is executing.

  • For a behavior owned by another behavior (such as an entry action on a state machine), the context value is the context value of the inviking instance owning behavior.

  • Otherwise, the context value is the behavior instance being executed.

Note that the dynamic type of the context value returned by a this expression may actually be a subclass of the static type of the this expression.

The multiplicity of a this expression is [1..1].


8.3.5Parenthesized Expressions


A parenthesized expression is a contained expression surrounded by parentheses.

Syntax

ParenthesizedExpression(e: Expression)
= "(" Expression(e) ")"


NOTE. A parenthesized expression has the abstract syntax of its contained expression.

Semantics

A parenthesized expression is evaluated by evaluating the contained expression and results in the values of the contained expression. The use of parenthesizes only effects order of evaluation, not how the contained expression is evaluated.

The type and multiplicity of a parenthesized expression are the same as the contained expression.

8.3.6Property Access Expressions


A property access expression is used to access the value of a property of instances of a classifier. It is denoted by feature reference, which consists of a target primary expression (see Subclause 8.3.1) and the name of a property of the type of the target expression.

Examples

poleValue.im

this.node

members.name

jack.house

Concrete Syntax

PropertyAccessExpression(e: PropertyAccessExpression)
= FeatureReference(e.featureReference)


FeatureReference(f: FeatureReference)
= FeatureTargetExpression(f.expression) "." NameBinding(f.nameBinding)


FeatureTargetExpression(e: Expression)
= NameTargetExpression(e)
| NonNamePrimaryExpression(e)


NameTargetExpression(e: NameExpression)
= ColonQualifiedName(e.name)


Figure 8 7 Abstract Syntax of Property Access Expressions



Cross References

  1. Name see Subclause 7.5

  2. Expression see Subclause 8.1

  3. ColonQualifiedName see Subclause 8.2

  4. NameBinding see Subclause 8.2

  5. NonNamePrimaryExpression see Subclause 8.3.1

NOTE. See Subclause 8.2 for rules on the disambiguation of a qualified name using the dot notation to a property access expression. Such a potentially ambiguous expression is always initially parsed as a qualified name.

Semantics

The target expression in a property access expression may not be untyped nor may its type be a primitive type or enumeration. The identified property name must denote either:



  • A structural feature (owned or inherited) of the type of the target expression.

  • The name of an association end of a binary association, the opposite end of which is typed by the type of the target expression.

If the identified property is a template, then a template binding must be provided with arguments for all its template parameters.

For it to be legal to use the name of an association end in a property access expression, there must be exactly one binary association visible in the current scope that meets the above criterion and the given name must not also be the name of a structural feature of the type of the target expression.

If the target expression has multiplicity [1..1], then result of the collection expression will always be a single instance. This is known as a single instance property access. If the target expression has multiplicity other than [1..1], then the property access expression is known as a sequence property access. Such an expression is equivalent to a collect expression (see Subclause 8.3.21) as described below under Sequence Property Access.

The type of a property access expression is the same as the type of the named property. The multiplicity upper and lower bounds of the property access expression are equal to the product of the upper and lower bounds, respectively, of the named property and the target expression.

A property access expression is evaluated by first evaluating the target expression, which results in a sequence of instances. The result of the property access expression is then a sequence containing the union of the values of the named property for each of the target instances.

Single Instance Property Access

In the case of a single instance property access expression, the target expression will always evaluate to exactly one instance. If the property name is for a structural feature, then the resulting values of the property access expression are the values of that structural feature for the given instance.

A property access expression may also be used to access the values of an opposite association end of a binary association in which the instance participates. In this case, the resulting values are the values of named end of all links of the association for which the value of the opposite end is the given instance.

As an example of an association end access, consider the following association (represented in Alf notation—see Subclause 10.4.5).

assoc Owns {


owner: Person;
house: House[*];
}

If the association Owns is in the current scope (that is, visible without qualification), and jack is a Person, then the expression

jack.house

is equivalent to the association read expression (see Subclause 8.3.9)

Owns::house(owner => jack)

Sequence Property Access

A sequence property access expression of the form primary.name is equivalent to a collect expression (see Subclause 8.3.21) of the form

primary -> collect x (x.name)

NOTE. It is not an error for the result of the target expression in a property access expression to be empty. In this case, the property access expression evaluates to an empty sequence.



Download 1.74 Mb.

Share with your friends:
1   ...   10   11   12   13   14   15   16   17   ...   62




The database is protected by copyright ©ininet.org 2024
send message

    Main page