A query expression (Section 16.4, “Query Expressions”) is evaluated sequentially by invocation of the query. This is done as follows:
A compiler for the XL programming language has to produce code
which encodes the structure of the query
in an instance q
of
de.grogra.xl.qnp.Query
. For every type
T
which is primitive or
Object
, the class
Query
declares a generator method
(Section 11.2.1, “Generator Method Declarations”) named
find
A
Matches
with return type T
and a single parameter
of type de.grogra.xl.runtime.Model
.
A
is the type affix of T
(Section 6.1, “Type Affixes and Type Letters”).
At run-time, the invocation of the query is done by a generator
method invocation (Section 16.2.2, “Generator Method Invocations”) of the
suitable generator method on q
.
The single argument to the method is the current run-time model
(Section 3.2, “Run-Time Model”) that corresponds to the
compile-time model of the query. This sequentially yields the values
of the query.
The implementation of the generator methods in
Query
at first obtains an
instance qs
of de.grogra.xl.qnp.QueryState
by
the invocation of the method createQueryState
on the current extent (Section 3.2.1, “Current Extent”) with
the current extended state of the virtual machine
(Chapter 4, Extended State of the Virtual Machine) as argument. Then qs
is set up to represent the query state of the
query. For example, the current binding of query variables is accessible
through the query state.
Finally, after all values have been yielded, the method invocation
qs
.getExtent().dispose
(qs
)
is performed.