Commit Graph

28 Commits

Author SHA1 Message Date
Paolo Tranquilli
492d5aec78 Swift: rename doc to description in properties 2022-10-20 08:57:41 +02:00
Paolo Tranquilli
4d87abed0e Swift: generate docname in qlgen 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
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
3ce76e6c08 Swift: preserve base order in code generation 2022-08-31 10:45:22 +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
b5aad04f65 Swift: add indexes to generated parent-child library 2022-08-29 17:10:46 +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
9347030611 Swift: rename Ipa to Synth 2022-08-15 14:31:17 +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
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
47f26e6029 Swift: fix codegen unit tests 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
f2b589743a Swift: add possibility to collapse class hierarchy in tests 2022-06-28 12:01:36 +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
Paolo Tranquilli
3597efb728 Swift: rename to getImmediateParent and use hidden AST 2022-06-01 14:32:58 +02:00
Paolo Tranquilli
a86d0fc8a7 Swift: move getAChild to a separate module 2022-06-01 14:32:58 +02:00
Paolo Tranquilli
946e1f498a Swift: generate getParent implementation
By explicitly marking children in the `schema.yml` file, an internal
`getAChild` predicate is implemented, that is in turn used in `AstNode`
to implement `getParent`.

This is yet to be used in the control flow library to replace the
hand-rolled implementation.

A further, more complex step is to use the same information to fully
generate the core implementation of `PrintAst` (including the
accessor string). This will be done later.

The `parent` tests use the same swift code as the extractor tests, and
this is currently enforced by `sync-files.py`. Notice that `qltest.sh`
had to be modified to deal with multiple files, which was not working
yet.
2022-06-01 14:32:58 +02:00
Paolo Tranquilli
c08e6fdc1e Swift codegen: add predicate properties
Properties marked with `predicate` in the schema are now accepted.

* in the dbscheme, they will translate to a table with a single `id`
  column (and the table name will not be pluralized)
* in C++ classes, they will translate to `bool` fields
* in QL classes, they will translate to predicates

Closes https://github.com/github/codeql-c-team/issues/1016
2022-05-09 17:50:49 +02:00
Paolo Tranquilli
c87fb4df53 Swift: remove now unused ql.Property.params 2022-05-05 12:01:13 +02:00
Paolo Tranquilli
9798d8ba26 Swift: add ?* modifier to schema specification
This indicates a list of optional entries. This is different than
simply repeatind entries because of the indexing.
2022-05-05 11:50:12 +02:00
Paolo Tranquilli
0100c7171d Swift: testing non-trivial dataclass properties 2022-04-27 10:17:49 +02:00
Paolo Tranquilli
f171ce6341 Swift: add unit tests to code generation
Tests can be run with
```
bazel test //swift/codegen:tests
```

Coverage can be checked installing `pytest-cov` and running
```
pytest --cov=swift/codegen swift/codegen/test
```
2022-04-27 08:24:11 +02:00