Commit Graph

74 Commits

Author SHA1 Message Date
Paolo Tranquilli
e2d7a6910c Swift: generate raw helpers in synthesized stubs
This will add helpers to get the underlying raw entities or constructor
arguments on stubs for synthesized classes.

For example a schema like:

```
@synth.from_class(A)
class B:
    pass

@synth.on_arguments(base=A, index=int)
class C:
    pass
```

will generate

```
cached
private Raw::A getUnderlyingEntity() { this = Synth::TB(result) }
```
in the `B.qll` stub and
```
cached
private Raw::A getUnderlyingBase() { this = Synth::TC(result, _) }

cached
private int getUnderlyingIndex() { this = Synth::TC(_, result) }
```
in the `C.qll` stub.

As stubs these can be freely changed later on.
2023-02-16 10:49:21 +01:00
Paolo Tranquilli
1c086aae7c Swift: add internal imports to ParentChild.qll 2023-01-20 09:59:36 +01:00
Paolo Tranquilli
e840b8f707 Swift: add and fix some schema.py documentation 2023-01-19 18:07:47 +01:00
Paolo Tranquilli
6106edd5e2 Swift: add INTERNAL doc marker to ql.internal classes 2023-01-17 10:30:59 +01:00
Paolo Tranquilli
194c99c513 Swift: fix getNumberOf predicate 2022-12-07 13:46:51 +01:00
Paolo Tranquilli
d39f37540e Swift: add has and getNumberOf properties to generated tests 2022-12-07 13:46:51 +01:00
Paolo Tranquilli
8d3e6ff8a7 Swift: add label iteration 2022-11-08 11:47:12 +01:00
Paolo Tranquilli
7144383505 Swift: fix british spelling of behaviour 2022-10-20 11:43:46 +02:00
Paolo Tranquilli
37b405f134 Swift: add generated docs for predicates 2022-10-20 11:05:01 +02:00
Paolo Tranquilli
22bd10132f Swift: insert blank line between doc and desc 2022-10-20 10:49:26 +02:00
Paolo Tranquilli
7b181a2de0 Swift: change doc of Immediate property getters 2022-10-20 10:39:37 +02:00
Paolo Tranquilli
6830c2f355 Swift: enhance property docs 2022-10-20 10:35:47 +02:00
Paolo Tranquilli
9abaa5c0b3 Swift: rename doc_name with doc in properties 2022-10-20 08:59:08 +02:00
Paolo Tranquilli
492d5aec78 Swift: rename doc to description in properties 2022-10-20 08:57:41 +02:00
Paolo Tranquilli
861377f650 Swift: property doc tweaks 2022-10-19 11:40:05 +02:00
Paolo Tranquilli
8de7df9c21 Swift: add auto-generated docs for getters 2022-10-18 17:04:51 +02:00
Paolo Tranquilli
5f7fa6f915 Swift: generate class docs
Python docstrings in `schema.py` are now added to the generated classes.

As an example, a docstring is added to `Expr`.
2022-10-18 17:04:51 +02:00
Paolo Tranquilli
f4f5e3e382 Swift: remove redundant module namespace 2022-10-18 12:32:31 +02:00
Paolo Tranquilli
307c885c1f Swift: use Generated:: instead of Base suffix
This commit changes `codegen` and the generated classes.
2022-10-18 12:21:06 +02:00
Paolo Tranquilli
e49268d036 Swift: show QL class in generated tests on collapsed hierarchies
In those kinds of tests the results may have different final classes
that are not necessarily visible (or tested) solely through the string
representation. For better testing and reading of expected results,
`getQlPrimaryClasses` is added in these cases.
2022-10-17 14:08:04 +02:00
Paolo Tranquilli
9102cb5d0d Swift: make some ParentChild predicates private 2022-08-30 10:35:08 +02:00
Paolo Tranquilli
beb0472811 Swift: fix ParentChild generation
There was an issue in case multiple inheritance from classes with
children was involved, where indexes would overlap.

The generated code structure has been reshuffled a bit, with
`Impl::getImmediateChildOf<Class>` predicates giving 0-based children
for a given class, including those coming from bases, and the final
`Impl::getImmediateChild` disjuncting the above on final classes only.

This removes the need of `getMaximumChildrenIndex<Class>`, and also
removes the code scanning alerts.

Also, comments were fixed addressing the review.
2022-08-30 10:15:11 +02:00
Paolo Tranquilli
3f4a330658 Swift: make ParentChild::Impl module private 2022-08-29 17:35:16 +02:00
Paolo Tranquilli
b5aad04f65 Swift: add indexes to generated parent-child library 2022-08-29 17:10:46 +02:00
Paolo Tranquilli
9cd2ae2fd1 Swift: rename Synth conversion functions 2022-08-16 16:54:33 +02:00
Paolo Tranquilli
9de5985218 Swift: fix subtracted constructors 2022-08-15 17:00:36 +02:00
Paolo Tranquilli
1365d0911d Swift: generalize synth constructors
Now all types get a default synth constructor.
2022-08-15 16:12:19 +02:00
Paolo Tranquilli
8ba330a886 Swift: rename conversion predicates 2022-08-15 15:04:39 +02:00
Paolo Tranquilli
ace92d0958 Swift: rename Db to Raw 2022-08-15 14:54:21 +02:00
Paolo Tranquilli
9347030611 Swift: rename Ipa to Synth 2022-08-15 14:31:17 +02:00
Paolo Tranquilli
176009ca88 Merge branch 'main' into redsun82/swift-first-prototype-of-generated-ipa-layer 2022-08-15 10:18:41 +02:00
Paolo Tranquilli
7d7966e711 Swift: make trap key prefixes readable
This replaces numeric tag-based prefixes with the actual tag name.
While this means in general slightly larger trap files, it aids
debugging them for a human.

In the future we can make this conditional on some kind of trap debug
option, but for the moment it does not seem detrimental.
2022-07-28 12:43:30 +02:00
Paolo Tranquilli
457ce3d884 Swift: fix derived IPA type properties
Also rename `IpaTypes.qll` to `Ipa.qll`
2022-07-28 10:26:11 +02:00
Paolo Tranquilli
60795fc652 Swift: fix codescanning warnings 2022-07-28 10:26:11 +02:00
Paolo Tranquilli
8b13adbb93 Swift: IPA layer tweaks 2022-07-28 10:26:11 +02:00
Paolo Tranquilli
c578505ae0 Swift: specialize Ipa <-> Db conversions 2022-07-28 10:26:11 +02:00
Paolo Tranquilli
a16d5f72d1 Swift: cache equivalent of asDbInstance
Which is now a predicate in the `IpaTypes.qll` file (where `Cached`
was also renamed to `Ipa`).
2022-07-28 10:26:11 +02:00
Paolo Tranquilli
10976bbbab Swift: use IPA layer in generated classes 2022-07-28 10:26:10 +02:00
Paolo Tranquilli
ea0725525b Swift: first IPA layer 2022-07-28 10:26:10 +02:00
Paolo Tranquilli
7175869518 Swift: add missing newlines in trap
This is mostly cosmetic and for debugging, as the trap importer is
perfectly happy with trap entries on the same line without spaces
between them.
2022-06-28 15:17:18 +02:00
Paolo Tranquilli
299e1af22e Merge main into redsun82/swift-code-reorg 2022-06-24 13:06:14 +02:00
Paolo Tranquilli
8ca529e8d9 Swift: make Element::resolve final
One should only override `getResolveStep` (or `convertsFrom` for `Expr`
classes), as otherwise the resolution/conversion becomes inconsitent.
2022-06-24 10:05:58 +02:00
Paolo Tranquilli
a9877ed2fd Swift: split generated C++ files by directory 2022-06-23 14:24:03 +02:00
Paolo Tranquilli
b2ebf63d2e Swift: split generated C++ code into .h and .cpp 2022-06-23 14:22:58 +02:00
Paolo Tranquilli
48584a6c2e Merge main into redsun82/swift-use-generated-classes 2022-06-20 17:53:21 +02:00
Paolo Tranquilli
be210aa3af Merge alexdenisov/xref-decls into redsun82/swift-use-generated-classes 2022-06-17 17:03:30 +02:00
Paolo Tranquilli
86ebb0bb68 Swift: fix qltest skipping and skip isUnknown
Also remove obsolete accessor and function hand-written tests.
2022-06-15 09:16:55 +02:00
Paolo Tranquilli
de52f9be7b Swift: generated extractor tests 2022-06-14 18:01:29 +02:00
Paolo Tranquilli
ede6bd8ffe Swift: document and partially simplify codegen
This adds:
* a base `README.md` file to `codegen`
* module docstrings for the modules in `generators`
* help strings on all command line flags

Moreover some unneeded command line flags (`--namespace`,
`--include-dir` and `--trap-affix`) have been dropped.
2022-06-02 15:28:57 +02:00
Paolo Tranquilli
3414028b1b Swift: simplify GetImmediateParent.qll 2022-06-01 15:01:49 +02:00