Граф коммитов

232 Коммитов

Автор SHA1 Сообщение Дата
Alex Denisov d744b218f6 Misc: add bazel buildifer pre-commit hook 2023-06-30 13:07:04 +02:00
Paolo Tranquilli 1218145259 Codegen: update `README.md` files 2023-02-27 10:01:50 +01:00
Paolo Tranquilli cdd4e8021b Move `swift/codegen` to `misc/codegen` 2023-02-27 09:46:48 +01:00
Paolo Tranquilli 6d192cdcc1 Swift: make C++ code generation language agnostic 2023-02-27 09:46:48 +01:00
Paolo Tranquilli feb4e60c4b Swift: make all ql generation language agnostic 2023-02-27 09:46:48 +01:00
Paolo Tranquilli aca18f5da8 Swift: make codegen use a config file 2023-02-27 09:46:48 +01:00
Paolo Tranquilli e4627cb702 Swift: make `codegen` a bit more language-agnostic 2023-02-27 09:46:48 +01:00
Paolo Tranquilli f50382ba70 Swift: fix weird module naming in codegen 2023-02-16 14:53:31 +01:00
Paolo Tranquilli 3ec2a3c711 Swift: fix subtle codegen bug on missing files
While the internal registry was being cleaned up from files removed by
codegen itself, it was not dropping files removed outside of codegen.

Because of this files removed by the user were not being regenerated
again if no change was staged to them, unless `--force` was provided.

This also fixes some such "ghost" entries in the registry and some
missing generated files.
2023-02-16 11:46:51 +01:00
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 81de500301 Swift: fix import not working in all python versions 2023-02-14 10:40:05 +01:00
Paolo Tranquilli 8e079320f3 Swift: some restructuring of codegen
Loading of the schema and dbscheme has been moved to a separate
`loaders` package for better separation of concerns.
2023-02-14 09:53:02 +01:00
Paolo Tranquilli 483a87abe9 Swift: make `codegen` run also outside `bazel` 2023-02-13 09:39:31 +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 490bd051cd Swift: expand `ref` in autogenerated docs 2023-01-19 09:27:44 +00:00
Paolo Tranquilli 6106edd5e2 Swift: add `INTERNAL` doc marker to `ql.internal` classes 2023-01-17 10:30:59 +01:00
Paolo Tranquilli b22da25e05 Swift: remove `ql.internal` classes from global import 2023-01-17 10:18:03 +01:00
Paolo Tranquilli 48825442c3 Swift: add `ql.internal` pragma in schema definitions 2023-01-17 10:10:35 +01:00
Paolo Tranquilli cdc99b5240 Swift: simplify pragma definition 2023-01-17 10:10:02 +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 bb3aa9e908 Swift: add `--force` to `codegen` 2022-11-30 14:19:33 +01:00
Paolo Tranquilli d6aad13a98 Swift: make `codegen` run when no registry is there 2022-11-30 13:47:12 +01:00
Paolo Tranquilli 76db5f22b3 Swift: make `codegen` resilient to formatting errors
More in general, the managed renderer flow does things more sensibly
in case an exception is thrown:
* it will not remove any file
* it will drop already written files from the registry, so that codegen
  won't be skipped for those files during the next run
2022-11-30 13:43:29 +01:00
Paolo Tranquilli 876add5214 Swift: reject uppercase acronyms in schema
This was causing hardly debuggable errors because names are transformed
to underscored lowercase names in the dbscheme and back to camelcase
for trap emission classes, which is not a noop in case uppercase
acronyms (like SIL or ABI) are in the name.

This makes the error be surfaced early with a helpful message.
2022-11-23 13:56:03 +01:00
Paolo Tranquilli aaa96b20ed Swift: fix python compatibility with CI 2022-11-18 17:51:20 +01:00
Paolo Tranquilli aeb7b0d050 Swift: remove `ModifiedStubMarkedAsGeneratedError` 2022-11-18 17:13:12 +01:00
Paolo Tranquilli 2cd58817d7 Swift: skip QL code generation on untouched files
This is a developer QoL improvement, where running codegen will skip
writing (and especially formatting) any files that were not changed.

**Why?** While code generation in itself was pretty much instant, QL
formatting of generated code was starting to take a long time. This made
unconditionally running codegen quite annoying, for example before each
test run as part of an IDE workflow or as part of the pre-commit hook.

**How?** This was not completely straightforward as we could not work
with the contents of the file prior to code generation as that was
already post-processed by the QL formatting, so we had no chance of
comparing the output of template rendering with that. We therefore store
the hashes of the files _prior_ to QL formatting in a checked-in file
(`swift/ql/.generated.list`). We can therefore load those hashes at
the beginning of code generation, use them to compare the template
rendering output and update them in this special registry file.

**What else?** We also extend this mechanism to detect accidental
modification of generated files in a more robust way. Before this patch,
we were doing it with a rough regexp based heuristic. Now, we just store
the hashes of the files _after_ QL formatting in the same checked file,
so we can check that and stop generation if a generated file was
modified, or a stub was modified without removing the `// generated`
header.
2022-11-18 16:56:01 +01:00
Paolo Tranquilli 1c69a1f012 Swift: fix typo in docstring 2022-11-16 16:36:48 +01:00
Paolo Tranquilli 27df44f5ad Swift: replace empty `IpaInfo()` with a clearer `True` value 2022-11-16 16:35:17 +01:00
Paolo Tranquilli a3d33e27e2 Swift: ignore IPA classes in dbscheme 2022-11-16 11:39:10 +01:00
Paolo Tranquilli 88a0c4053b Swift: move hierarchy IPA logic to `schema.py` 2022-11-16 11:14:17 +01:00
Paolo Tranquilli 56b207e41f Swift: remove IPA classes from `cppgen` 2022-11-15 17:07:52 +01:00
Paolo Tranquilli fc98fd3094 Swift: add `var` to the list of doc expanded abbreviations 2022-11-11 12:34:40 +01:00
Paolo Tranquilli a8e6dc7a54 Swift: avoid wrongly using `doc` instead of `desc` for properties 2022-11-10 09:29:02 +01:00
Paolo Tranquilli 8d3e6ff8a7 Swift: add label iteration 2022-11-08 11:47:12 +01:00
Paolo Tranquilli 2aa528852e Swift: add possibility to specify null class 2022-11-08 11:27:14 +01:00
Paolo Tranquilli 75f30a8f9c Swift: refactor `ExprVisitor` to use translations 2022-11-03 18:16:53 +01:00
Paolo Tranquilli 7144383505 Swift: fix british spelling of `behaviour` 2022-10-20 11:43:46 +02:00
Paolo Tranquilli f9df8a645f Swift: fix potential name conflict on schema class fields 2022-10-20 11:30:05 +02:00
Paolo Tranquilli 8813aea893 Swift: allow default class doc name to be set for properties 2022-10-20 11:23:13 +02:00
Paolo Tranquilli c22a7e1c81 Swift: rename `_DocnameModifier` to `_DocModifier` 2022-10-20 11:05:55 +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 b65f49bd50 Swift: document `introducer_int` 2022-10-20 10:46:12 +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