Bracket access expressions are those
expressions which are classified as array access expressions
by the Java programming language, i.e., expressions of the form
e
[
i
]
.
Bracket Access Expressions and Other Selector Expressions | |||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
The XL programming language reclassifies these expressions
as property access expressions which may access a property variable of an object (see Section 7.1, “Property Variables”),
as invocation expressions of operator methods (Section 11.2.2, “Operator Method Declarations”),
or as conventional array access expressions.
These kinds of expressions cannot be distinguished syntactically,
a distinction is made by the compiler
with the help of semantic information.
Namely, the expression
e
[
i
]
is reclassified by the first applicable of the following rules:
If i
is a single identifier
n
,
e
is a property access expression for a
property p
,
and p
has a subproperty named
n
, then the whole expression is a property
access expression for this subproperty.
If i
is a single identifier
n
,
e
is a local variable access expression for a
query variable v
which is wrapped
by a query variable w
(Section 17.1, “Query Variables”), and
if the invocation of the method getWrapProperty
of the
current compile-time model returns a property
q
for the type of w
,
then the previous rule is checked again, with the expression
e
being replaced by a
property access expression for q
's
type-cast property of v
's type on the
instance which is the value of w
.
If i
is a single identifier
n
and the type of
e
has a direct property named
n
, then the whole expression is a property
access expression for this property on the
instance which is the result of the evaluation of e
.
If the type of e
is an array type,
the index expression undergoes unary numeric promotion;
the promoted type must be int
.
Now if e
is a property access expression for a
property p
which has an array type, and if
p
has a component property, then the whole
expression is a property access expression for this component property;
its index value is the result of the evaluation of
i
.
Otherwise, the whole expression is classified as a conventional array
access expression.
If none of the above rules is applicable, the whole expression
is reclassified as an invocation expression of an operator method
named operator$index
(Section 11.2.2, “Operator Method Declarations”).
The result of a property access expression is a variable of the type of the property.