63 Commits

Author SHA1 Message Date
Tom Hvitved
d77b35c5d2 Codegen: Add Raw::getImmediateChild and Synth::getSynthParent 2025-11-09 20:39:38 +01:00
Paolo Tranquilli
de72e68d2c Merge branch 'main' into redsun82/codegen-new-parent-child 2025-06-26 12:14:53 +02:00
Paolo Tranquilli
6bbf1e3bc1 Codegen: use one generated test file per directory
This collapses all generated test QL sources into a single one per
directory, using query predicates to run the different tests.

This should improve the time required to run generated tests.
2025-06-25 11:44:54 +02:00
Paolo Tranquilli
1dcd60527c Codegen: improve implementation of generated parent/child relationship
This improves the implementation of the generated parent/child
relationship by adding a new `all_children` field to `ql.Class` which
lists all children (both direct and inherited) of a class, carefully
avoiding duplicating children in case of diamond inheritance. This:
* simplifies the generated code,
* avoid children ambiguities in case of diamond inheritance.

This only comes with some changes in the order of children in the
generated tests (we were previously sorting bases alphabetically there).
For the rest this should be a non-functional change.
2025-06-24 17:26:24 +02:00
Paolo Tranquilli
e935bd6faf Rust: expand derive macros 2025-06-20 11:19:06 +02:00
Paolo Tranquilli
77c40da51a Rust/Codegen: fix detached predicates 2025-06-03 10:41:31 +02:00
Tom Hvitved
4fb138a1a3 Rust: Make Element.toString non-recursive 2025-04-01 08:48:13 +02:00
Tom Hvitved
d1ad65ae09 Rust: Cache Element.toString 2025-03-14 11:58:38 +01:00
Tom Hvitved
8777bc42c7 Rust: Add get(Immediate)Child predicate 2025-03-13 11:13:01 +01:00
Tom Hvitved
ec33457ad4 Codegen: Improve return type of self-typed properties 2025-02-03 09:11:09 +01:00
Paolo Tranquilli
b57a37479b Rust: make File usable in codegen 2024-12-02 15:15:46 +01:00
Tom Hvitved
86a7c486f9 Rust: "control-flow" -> "control flow" 2024-11-21 10:42:11 +01:00
Tom Hvitved
c8736e8a3d Rust: Auto-generate CfgNodes.qll 2024-11-21 10:21:11 +01:00
Tom Hvitved
062127b42e Codegen: Do not cache injectors/projectors in Synth module 2024-09-24 14:41:20 +02:00
Paolo Tranquilli
c74b6be136 Rust/Codegen: allow to "detach" property emission
By using the `rust.detach` pragma on a property, we make that property
not appear in the generated struct as a field, and provide instead
a `generated::Class::emit_property` function that can be used to emit
the corresponding TRAP entry independently.
2024-09-20 16:06:22 +02:00
Tom Hvitved
1433363523 Codegen: Create internal folders 2024-09-17 20:06:35 +02:00
Paolo Tranquilli
1ce4707ff9 Merge branch 'main' into redsun82/rust-typed-labels 2024-09-16 16:44:55 +02:00
Tom Hvitved
8d68bdf4d6 Codegen: Fix return type of getResolveStep and resolve 2024-09-16 14:19:29 +02:00
Tom Hvitved
9c0cafeeb8 Codegen: Make public AST classes final 2024-09-16 13:39:53 +02:00
Paolo Tranquilli
f1233b14e8 Rust: fix generated hierarchy 2024-09-16 10:06:01 +02:00
Paolo Tranquilli
8f93f5e34b Rust: move to Label<T> and mark unsafety of from_untyped 2024-09-13 17:17:19 +02:00
Paolo Tranquilli
faf1eeeb0d Rust: introduce typed labels 2024-09-13 13:57:14 +02:00
Paolo Tranquilli
573b8b9373 Merge branch 'rust-experiment' into redsun82/rust-ci 2024-09-09 12:32:02 +02:00
Paolo Tranquilli
10a23c0843 Merge branch 'rust-experiment' into redsun82/rust-doctest-gen 2024-09-09 12:20:55 +02:00
Paolo Tranquilli
ee2a8b09f6 Rust: fix formatting 2024-09-09 12:11:50 +02:00
Paolo Tranquilli
3cd8aaf4b0 Rust: simplify rust doc test annotation 2024-09-09 08:59:17 +02:00
Arthur Baars
c8f73587cc Rust: codegen: fix generated code 2024-09-07 10:32:59 +02:00
Paolo Tranquilli
928f3f11f1 Rust: remove <> from function wrapper 2024-09-06 14:34:12 +02:00
Paolo Tranquilli
8c5cc2efdc Rust: generate test code from schema docstrings
This generates test source files from code blocks in class docstrings.

By default the test code is generated as is, but it can optionally:
* be wrapped in a function providing an adequate context using
  `@rust.doc_test_function(name, *, lifetimes=(), return_type="()", **kwargs)`,
  with `kwargs` providing both generic and normal params depending on
  capitalization
* be skipped altogether using `@rust.skip_doc_test`

So for example an annotation like
```python
@rust.doc_test_function("foo",
                        lifetimes=("a",),
                        T="Eq",
                        x="&'a T",
                        y="&'a T",
                        return_type="&'a T")
```
will result in the following wrapper:
```rust
fn foo<'a, T: Eq>(x: &'a T, y: &'a T) -> &'a T {
    // example code here
}
```
2024-09-06 14:24:42 +02:00
Paolo Tranquilli
7e1290aa74 Rust: reuse shared rust trap library 2024-08-30 16:08:37 +02:00
Paolo Tranquilli
4f0fe1ce3a Rust: bazel packaging 2024-08-30 13:05:46 +02:00
Paolo Tranquilli
590a146b49 Rust: some basic extraction of function names (with locations!) 2024-08-29 17:58:50 +02:00
Paolo Tranquilli
f40901f391 Rust: archiving + skeleton def translator 2024-08-28 17:15:49 +02:00
Paolo Tranquilli
0b57ecf0c7 Codegen: add internal QLdoc to property templates 2023-11-24 06:56:55 +01:00
Paolo Tranquilli
2d34fec0a2 Codegen: remove unneeded has_description property 2023-11-24 06:56:55 +01:00
Paolo Tranquilli
9264b2a6d6 Codegen: add internal to properties, rename ql_internal->internal 2023-11-24 06:56:55 +01:00
Paolo Tranquilli
f5633be837 Codegen: rename has_doc to has_qldoc 2023-11-22 10:19:36 +01:00
Paolo Tranquilli
e40c53a340 Swift: add full docs to stub classes 2023-11-21 17:27:30 +01:00
Paolo Tranquilli
b4fd95bd6a Swift: move stub QLdocs to separate templates 2023-11-21 16:25:21 +01:00
Paolo Tranquilli
5b724a7aaf Swift: add QLdoc for Generated modules 2023-11-21 16:18:28 +01:00
Paolo Tranquilli
dcb2117b31 Swift: tweak generated doc comments 2023-11-09 12:12:07 +01:00
Paolo Tranquilli
ac838d72de Codegen: mark all generated files and classes as INTERNAL 2023-11-08 10:02:17 +01:00
Paolo Tranquilli
10afa4381a Swift: add more doc strings to generated things 2023-11-07 16:29:03 +01:00
Paolo Tranquilli
60b7d79fba Revert "Revert "Swift: use C++20 constraints and concepts to simplify code"" 2023-09-21 10:17:22 +02:00
Paolo Tranquilli
1daedd9fb6 Revert "Swift: use C++20 constraints and concepts to simplify code" 2023-08-21 17:40:15 +02:00
Paolo Tranquilli
7c764f3b50 Swift: use C++20 constraints and concepts to simplify code
This simplifies several instances of metaprogramming by leveraging
[constraints and concepts from C++20][1]. This:
* gets rid of `std::enable_if` by usage of `requires`, making it more
  readable and yield better compiler messages.
* uses `requires` instead of `static_assert` to enforce `TrapLabel`
  typing
* simplifies all compile-time tests for validity of a given expression
* uses some standard library concepts where possible
* generalizes and simplifies `SwiftLocationExtractor`

Notice that in order to use the `std::derived_from` concept, `virtual`
inheritance had to be added to the label tags, because diamond
inheritance is a problem otherwise. That's because
`std::derived_from<T, U>` requires that `T*` be convertible to `U*`,
which is false if there are multiple non-virtual inheritance paths from
`U` to `T`. As tags never get actually instantiated, there is no runtime
performance penalty in using `virtual` inheritance.

[1]: https://en.cppreference.com/w/cpp/language/constraints
2023-08-17 17:24:42 +02:00
Paolo Tranquilli
700e3d5e53 Codegen: rename ipa to synth 2023-06-07 09:12:39 +02:00
Nora Dimitrijević
928da77d10 Merge branch 'main' into redsun82/swift-synth-properties 2023-06-06 15:34:02 +02:00
Paolo Tranquilli
b09386a2c8 Codegen: ignore synth properties in Raw.qll 2023-05-25 16:05:12 +02:00
Paolo Tranquilli
242d263e8a Codegen: move ipa info from ql.Class to ql.Property 2023-05-25 16:05:11 +02:00