Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 5d84ecc

Browse files
author
alexet
committed
QLSpecification: Fix handling of fields to handle overriding properly.
1 parent ebb253e commit 5d84ecc

1 file changed

Lines changed: 18 additions & 8 deletions

File tree

docs/codeql/ql-language-reference/ql-language-specification.rst

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1948,29 +1948,39 @@ The store is first initialized with the *database content* of all built-in predi
19481948

19491949
Each layer of the stratification is *populated* in order. To populate a layer, each predicate in the layer is repeatedly populated until the store stops changing. The way that a predicate is populated is as follows:
19501950

1951-
- To populate a predicate that has a formula as a body, find all named tuples with the variables of the predicate's arguments that match the body formula and the types of the variables. If the predicate has a result, then the matching named tuples should additionally have a value for ``result`` that is in the result type of the predicate.
1952-
If the predicate is a member predicate of a class ``C`` and not a characteristic predicate, then the tuples should additionally have a value for ``this`` and fields that match some tuple in ``C.class``.
1953-
If the predicate is a characteristic predicate of a class ``C``, then the tuples should additionally have a value for ``this`` and fields that match some tuple in ``C.extends`` and each
1954-
declared field ``f`` with type ``B`` the value of ``f`` is a member of ``B.class``.
1955-
For each such tuple remove any components that have the same name as a field on the declaring type and add it to the predicate in the store.
1951+
- To populate a predicate that has a formula as a body, find all named tuples with identify each named tuple ``t`` that has the following properties:
1952+
- The tuple matches the body formula.
1953+
- The variables should be the predicate's arguments.
1954+
- If the predicate has a result, then the tuples should additionally have a value for ``result``
1955+
- If the predicate is a member predicate or characteristic predicate of a class ``C`` then the tuples should additionally have a value for ``this`` and each visible field on the class.
1956+
- The values corresponding to the arguments should all be a member of the declared types of the arguments.
1957+
- The values corresponding to ``result`` should all be a member of the result type.
1958+
- The values corresponding to the fields should all be a member of the declared types of the fields.
1959+
- If the predicate is a member predicate of a class ``C`` and not a characteristic predicate, then the tuples should additionally extend some tuple in ``C.class``.
1960+
- If the predicate is a characteristic predicate of a class ``C``, then there should be a tuple ``t'``in ``C.extends`` such that for each visible field in ``C`` any field that is equal to or overrides a field in that ``t'`` should have the same value in ``t``. ``this`` should also map to the same value in ``t`` and ``t``.
1961+
For each such tuple remove any components that correspond to fields and add it to the predicate in the store.
19561962

19571963
- To populate an abstract predicate, do nothing.
19581964

19591965
- The population of predicates with a higher-order body is left only partially specified. A number of tuples are added to the given predicate in the store. The tuples that are added must be fully determined by the QL program and by the state of the store.
19601966

19611967
- To populate the type ``C.extends`` for a class ``C``, identify each named tuple that has the following properties:
19621968
- The value of ``this`` is in all non-class base types of ``C``.
1963-
- For each class base type ``B`` of ``C`` the projection of the tuple onto fields the public fields of ``B`` is the projection of a tuple in ``B.B`` onto the public fields of ``B``.
1969+
- The keys of the tuple are ``this`` and the union of the public fields from each base type.
1970+
- For each class base type ``B`` of ``C`` there is a named tuple with with variables from the public fields of ``B`` and ``this`` that is the given tuple and some tuple in ``B.B`` both extend.
19641971
For each such tuple add it to ``C.extends``.
19651972

19661973
- To populate the type ``C.C`` for a class ``C``, if ``C`` has a characteristic predicate, then add all tuples from that predicate to the store.
1967-
Otherwise add all tuples into the store that it satisfy ``C.extends`` and for each declared field ``f`` with type ``B`` the value of ``f`` is a member of ``B.class``
1974+
Otherwise add all tuples ``t`` such that:
1975+
- The variables of ``t`` should be ``this`` and the visible fields of ``C``.
1976+
- The values corresponding to the fields should all be a member of the declared types of the fields.
1977+
- If the predicate is a characteristic predicate of a class ``C``, then there should be a tuple ``t'``in ``C.extends`` such that for each visible field in ``C`` any field that is equal to or overrides a field in that ``t'`` should have the same value in ``t``. ``this`` should also map to the same value in ``t`` and ``t``.
19681978

19691979
- To populate the type ``C.class`` for a non-abstract class type ``C``, add each tuple in ``C.C`` to ``C.class``.
19701980

19711981
- To populate the type ``C.class`` for an abstract class type ``C``, identify each named tuple that has the following properties:
19721982
- It is a member of ``C.C``
1973-
- For each class ``D`` that has ``C`` as a base type then the projection of the tuple to the public ``D.class``.
1983+
- For each class ``D`` that has ``C`` as a base type then there is a named tuple with variables from the public fields of ``C`` and ``this`` that the given tuple and a tuple in ``D.class`` both extend.
19741984

19751985

19761986
Query evaluation

0 commit comments

Comments
 (0)