232 Commits

Author SHA1 Message Date
Paolo Tranquilli
861377f650 Swift: property doc tweaks 2022-10-19 11:40:05 +02:00
Paolo Tranquilli
35c1d311c5 Swift: add doc name override 2022-10-18 17:04:51 +02:00
Paolo Tranquilli
8de7df9c21 Swift: add auto-generated docs for getters 2022-10-18 17:04:51 +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
f41fd81965 Swift: add docstring parsing 2022-10-18 16:54:26 +02:00
Paolo Tranquilli
fd46592dfb Merge pull request #10869 from github/redsun82/swift-no-base-suffix
Swift: replace `Base` suffix with `Generated::` module
2022-10-18 14:28:08 +02:00
Paolo Tranquilli
8a839c8b96 Swift: remove obsolete schema.yml 2022-10-18 12:51:56 +02:00
Paolo Tranquilli
9c7eec5e44 Swift: remove debug print from qlgen.py 2022-10-18 12:48:18 +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
Josh Soref
50ed25098b spelling: hierarchy
Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>
2022-10-13 19:42:46 -04:00
Alex Denisov
ecb5708b66 Swift: fix static assert? 2022-09-22 11:17:07 +02:00
Alex Denisov
b364647d76 Swift: add stubs for new exprs 2022-09-22 11:17:07 +02:00
Alex Denisov
d937234f83 Swift: add stubs for new types 2022-09-22 11:17:07 +02:00
Alex Denisov
13fe02edfa Swift: NestedArchetypeType was removed 2022-09-22 11:17:04 +02:00
Paolo Tranquilli
3983c36cb2 Swift: avoid inheriting annotations 2022-09-21 18:02:09 +02:00
Paolo Tranquilli
fd63bab054 Swift: autopep8 test_schema.py 2022-09-21 16:15:52 +02:00
Paolo Tranquilli
163d1717d7 Swift: autopep8 2022-09-21 16:11:40 +02:00
Paolo Tranquilli
96897a0cdc Swift: implement python schema
The information that was contained in `schema.yml` is now in
`swift/schema.py`, which allows a more integrated IDE experience
for writing and navigating it.

Another minor change is that `schema.Class` now has a `str` `group`
field instead of a `pathlib.Path` `dir` one.
2022-09-21 15:53:09 +02:00
Paolo Tranquilli
caaf9e7ff3 Swift: reorganize schema lib files 2022-09-21 15:50:26 +02:00
Paolo Tranquilli
b0e7dfcbdf Swift: python schema mock-up 2022-09-21 15:39:18 +02:00
Paolo Tranquilli
935d5d9619 Merge branch 'main' into redsun82/swift-ifconfigdecl-ql 2022-09-21 13:21:08 +02:00
Paolo Tranquilli
69dfdf5a34 Swift: fix IfConfigDecl in QL libraries
This fixes `IfConfigDecl` for both the AST printer and control flow
libraries.

It turns out that the active lements of an `IfConfigDecl` are already
listed in the enclosing scope (like a `BraceStmt`), so they should not
be listed as children, and `IfConfigDecl` can be jsut a leaf in the
control flow.
2022-09-21 12:12:55 +02:00
Paolo Tranquilli
a50f3f752b Swift: move toposort in schema.py
This makes the result of code generation independent of the order
in which classes are defined in the schema, and makes additional
topological sorting not required.

Being independent from schema order will be important for reviewing the
move to a pure python schema, as generated code will be left untouched.
2022-09-21 10:49:12 +02:00
Paolo Tranquilli
dfc91bb0f0 Swift: make type non optional in TypeRepr 2022-09-20 15:23:27 +02:00
Paolo Tranquilli
72a4bd3f1e Swift: group unresolved elements and remove their tests 2022-09-20 15:22:20 +02:00
Paolo Tranquilli
7ae68fcc03 Swift: rework IfConfigDecl schema 2022-09-20 15:11:58 +02:00
Paolo Tranquilli
c0f477e5c1 Swift: reorder generic type param children in nominal types 2022-08-31 10:57:34 +02:00
Paolo Tranquilli
66e6c7bb13 Swift: make GenericTypeParamDecls children 2022-08-31 10:47:36 +02:00
Paolo Tranquilli
3ce76e6c08 Swift: preserve base order in code generation 2022-08-31 10:45:22 +02:00
Paolo Tranquilli
4825e6b8ba Swift: change some children
* made `members` children of an `IterableDeclContext`
* removed `elements` from the children of `EnumCaseDecl`, as they are
  already children of the enclosing `EnumDecl`
* removed `base` from the children of `SelfApplyExpr`, as they currently
  are already descendants via `getArgument(0).getExpr()`. We should
  maybe consider either removing `base` from the schema and add it as
  a shortcut on QL, or finish up replacing all `SelfApplyExpr` instances
  with synthesized types.
2022-08-30 17:30:39 +02:00
Paolo Tranquilli
75a7bcd3b1 Swift: add missing qlgen.py docstring 2022-08-30 11:03:23 +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
0aecbc2a01 Swift: reorganize some children in schema.yml 2022-08-29 14:52:14 +02:00
Paolo Tranquilli
2e9d9cfb20 Swift: add imported modules properties to ModuleDecl 2022-08-26 11:23:02 +02:00
Paolo Tranquilli
610c788e34 Merge pull request #10156 from github/redsun82/swift-import-optional-module
Swift: make `ImportDecl:imported_module` optional
2022-08-24 15:18:04 +02:00
Paolo Tranquilli
7873f07fac Swift: define ImportDecl:imported_module optional 2022-08-24 14:26:29 +02:00
Mathias Vorreiter Pedersen
1d50dd54ce Merge branch 'main' into swift-extract-this-param-decl 2022-08-24 10:14:18 +01:00
Mathias Vorreiter Pedersen
273053c92a Swift: Extract self parameter declarations. 2022-08-24 10:01:25 +01:00
Paolo Tranquilli
2fc88d5f8e Swift: add module to Decl and remove forward traps
Add module context to all declarations. As keeping the `std::variant`s
required slightly more work for this, and we intended to remove them
any way, this is done in this change.

For background, we put those in as we were not extracting all modules at
the time, so we were missing some DB ids that we put back in by adding
the "defining" traps not only in the trap file related to the defining
module but also to the one where the declaration was used. Since then
we fixed module extraction, so this should not be needed any more.
2022-08-23 16:53:07 +02:00
Paolo Tranquilli
9b50336e47 Swift: synthesize MethodRefExpr
This introduces a `MethodRefExpr` node synthesized out of
`DotSyntaxCallExpr` under the `LookupExpr` hierarchy. This means that
much like
```free_function(1, 2)```
is a `CallExpr` with `getFunction` giving a `DeclRefExpr`,
```foo.method(1, 2)```
is now a `CallExpr` with `getFunction` giving a `MethodRefExpr`.

`ApplyExpr::getStaticTarget` has been made work with it (as well as
`ConstructorRefCallExpr` which for the moment has been left where it
is), a new `MethodApplyExpr` has been introduced deriving from it,
and control and data flow libraries have adapted.

A small but was fixed in `qlgen` where the default constructor for DB
types was not correctly subtracting derived IPA types depending on the
order of definitions in `schema.yml`.

There are still some occurrences of `DotSyntaxCallExpr`, and as already
mentioned the other `SelfApply` class (`ConstructorRefCallExpr`) was
left alone. Their treatment is left for a future PR.
2022-08-19 14:48:36 +02:00
Paolo Tranquilli
9cd2ae2fd1 Swift: rename Synth conversion functions 2022-08-16 16:54:33 +02:00
Paolo Tranquilli
5bad696b41 Swift: remove unused no-parameter constructors 2022-08-16 09:09:00 +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