Software Engineering for Smart Data Analytics & Smart Data Analytics for Software Engineering
This file describes the changes in the type representation from JT 3 to JT 4.
In JT 4.0, for each type there is a single fact that represents it. This applies not only to class types, but also to array types, parameterized types and wildcards. For example, there is a single fact that represents the type List<String> and a single one for the type C[].
As a result of change 1, in JT 4, array types, parameterized types an wildcards are now globally unique entities. Correspondingly, the facts that represent them do not have any parent reference anymore. They can be referenced from a number of other elements / facts and therefore it is not possible to define a unique parent:
JT 3 | JT 4 | |
---|---|---|
arrayTypeT(#id, | –> | arrayTypeT(#id, #type, 'dim') |
parameterizedTypeT(#id, | –> | parameterizedTypeT(#id, #rawType, [#typeParam_1, ...]) |
wildCardT(#id, | –> | wildcardT(#id, 'kind', bounds) |
In JTransformer 4, each use of a type is represented by referencing the respective type fact directly, using its id. There are no more typeRefT indirections.
All PEFs that previously (JT 3) referred to a typeRefT/4 fact now (JT 4) directly refer to the PEF referenced by the typeRefT.
For example, two fields “C f1;” and “int f2;” are represented as follows:
JT 3 | –> | JT 4 |
---|---|---|
IN EACH MEMBER DECLARATION | ||
fieldT(F1, …, TR1, 'f1', …). | fieldT(F1, …, IdOfC, 'f1', …). | |
typeRefT(TR1, F1, F1, IdOfC). | ||
fieldT(F2, …, TR2, 'f2', …). | fieldT(F2, …, IdOfint, 'f2', …). | |
typeRefT(TR2, F2, F2, IdOfint). | ||
UNIQUE | ||
classT(IdOfC, …, 'C', …). | classT(IdOfC, …, 'C', …). | |
basicTypeT(IdOfint, int). | basicTypeT(IdOfint, int). |
For example, two fields “C[] f1;” and “C[] f2;” are represented as follows:
JT 3 | –> | JT 4 |
---|---|---|
IN EACH MEMBER DECLARATION | ||
fieldT(F1, …, AT1, 'f1', …). | fieldT(F1, …, AT, 'f1', …). | |
arrayTypeT(AT1, | ||
typeRefT(TR1, AT1, F1, IdOfC). | ||
fieldT(F2, …, AT2, 'f2', …). | fieldT(F2, …, AT, 'f2', …). | |
arrayTypeT(AT2, | ||
typeRefT(TR2, AT2, F2, IdOfC). | ||
UNIQUE | ||
classT(IdOfC, …, 'C', …). | classT(IdOfC, …, 'C', …). | |
arrayTypeT(AT, IdOfC, 1). |
For example, two fields “C<D> f1;” and “C<E> f2;” are represented as follows:
JT 3 | –> | JT 4 |
---|---|---|
IN EACH MEMBER DECLARATION | ||
fieldT(F1, …, AT1, 'f1', …). | fieldT(F1, …, AT, 'f1', …). | |
arrayTypeT(AT1, | ||
typeRefT(TR1, AT1, F1, IdOfC). | ||
fieldT(F2, …, AT2, 'f2', …). | fieldT(F2, …, AT, 'f2', …). | |
arrayTypeT(AT2, | ||
typeRefT(TR2, AT2, F2, IdOfC). | ||
UNIQUE | ||
classT(IdOfC, …, 'C', …). | classT(IdOfC, …, 'C', …). | |
arrayTypeT(AT, IdOfC, 1). |
In JT 4, static references to classes (which were also represented with the typeRefT in JT 3) are represented with staticTypeRefT facts.
Except for the adaptations above, working with types in conditional transformations in JT 4.0 is much simpler than in JT 3.0:
ensure_type_exists(+TypeFacts) is det. |
---|
TypeFacts is a list of type PEFs, i.e. it may contain parameterizedTypeT/3, arrayTypeT/3, wildcardT/3 and outerTypeParamsT/3 facts. The first argument of each PEF must be unbound, but the PEFs may contain references among each other. References to types not contained in TypeFacts must be bound. The predicate will then bind the variables to the IDs of the type facts representing the given type. These type facts either already exist or will be created otherwise. |