Commit graph

69 commits

Author SHA1 Message Date
Simon Hausmann
abe6888296 Collect proper per-file diagnostics in the compiler passes
When creating diagnostics in the passes, report them correctly in the
build diagnostics. There's no automated test yet, but it was manually
verified.
2020-07-21 15:27:41 +02:00
Simon Hausmann
26528a8e9c Keep track of the source file in the syntax tree
When going from the plain rowan::SyntaxNode tree to the syntax_nodes::*
elements, attach the source file and keep track of it from that point
on. That'll pave the way for proper multi-file diagnostics generated
later on from the passes, where we store syntax_nodes::* types.
2020-07-21 15:27:41 +02:00
Olivier Goffart
e486505bb6 Fix the rustwasm build
Somehow in this case, the repeated element stayed borrowed
2020-07-21 13:44:52 +02:00
Olivier Goffart
46ca98b159 Make sure to visit all the expressions in the different passes
Including the new expressions in the states
2020-07-21 13:30:04 +02:00
Olivier Goffart
d27bd60e45 Fix tests 2020-07-21 12:15:48 +02:00
Olivier Goffart
9d735d98cd Build the transitions tree and more flexible animations 2020-07-20 18:46:04 +02:00
Simon Hausmann
2055a2fbd7 Eliminate a few more span call sites
SyntaxToken supports Spanned and this appears to be equivalent to the manual span creation.
2020-07-20 16:12:40 +02:00
Simon Hausmann
f8c0eb0bd6 Prepare for passing passing more information from syntax node to diagnostics
Let the bulk of the push_error() calls take a Spanned trait impl, so
that we can pass node on the call sites. Then when later change the
underyling trait to pass something that can also provide the source file
and we don't have to change all call sites again.
2020-07-20 16:01:15 +02:00
Simon Hausmann
0cb59381e4 Fix type of PropertyDeclaration::type_location
In preparation for passing through the source file, avoid storing the Span
in the object tree and instead store the syntax node.
2020-07-20 15:36:17 +02:00
Olivier Goffart
c0fab1c3e9 More progress in states and transition parsing
Fill the object_tree with states, and part of the transition

Also make sure to duplicate animations properly in inlining
2020-07-20 15:04:06 +02:00
Simon Hausmann
e914715d88 Rename Diagnostics to FileDiagnostics
As this structure holds the diagnostics just for one file.
2020-07-16 18:25:42 +02:00
Simon Hausmann
3611d274eb Prepare type registry hierarchy for run-time extension
It should be possible to load multiple times into the same registry,
which will require interior mutability: While a loaded type has a
reference to the registry, a newly loaded type shall be added.
2020-07-16 14:59:09 +02:00
Simon Hausmann
2ac0805409 Minor cleanup
Don't need an accessor function in the Document for a public field. That said,
the choice of registry instance for the path "compilation" doesn't really matter,
as the lookup shall always end up
in the global registry.
2020-07-15 13:36:30 +02:00
Simon Hausmann
5b43962bb2 Split up TypeRegistry
For a .60 files the locally defined components are now stored in a separate
per-document TypeRegistry instance that falls back to the global registry
for lookups.
2020-07-15 13:09:43 +02:00
Simon Hausmann
38b605998c Fix build 2020-06-29 16:44:54 +02:00
Simon Hausmann
85ac4ad824 Generalize the handling of contextual elements
Certainly elements are only allowed as children of certain others, such
as Row only within GridLayout, for example. This patch implements this
constraint at type lookup type and allows removing "Row" from the
general list of types that can be instantiated anywhere.

This mechanism will also be used for path elements, in the future.
2020-06-29 15:43:55 +02:00
Olivier Goffart
19a8559d3f WIP: Conditional elements
The parsing part is implemented, but not the backend as it requires
non-const "models"
2020-06-29 15:03:09 +02:00
Simon Hausmann
ab697ab71d Parse animation declarations into the object tree
So

    animate x { ... }

is basically a short-hand for

    PropertyAnimation {
        ...
    }

    <magically associated that animation with x whenever x is changed>

We could also support a shared animation syntax in the future:

    blah := PropertyAnimation { ... }

    animate x with blah;
    animate y with blah;

This patch also adds a primitive PropertyAnimation struct, which will be
used by the generated code to collect the values specified in the .60
markup.
2020-06-24 17:43:48 +02:00
Olivier Goffart
d7fe69ff74 Lookup the index from a repeater expression 2020-06-16 17:23:38 +02:00
Olivier Goffart
56aad7f474 Fix looking up of 'id' so that we can't access inaccessible id 2020-06-16 16:04:38 +02:00
Olivier Goffart
81ce11ee8b Add a reference to the enclosing component in the element itself 2020-06-15 16:40:55 +02:00
Olivier Goffart
9adc55cd70 Partially revert the refactoring that changed the Element::children list
Put the information about RepeatedElement in an Option within the normlal Element
2020-06-15 13:42:11 +02:00
Olivier Goffart
c956fb94f0 Put the RepeatedElement in the object_tree 2020-06-15 10:09:32 +02:00
Olivier Goffart
136a90907b Refactor the element children to account for RepeatedElements 2020-06-12 22:24:50 +02:00
Simon Hausmann
9a935bdd0f Provide convenience accessors for public signals in C++ and Rust
Typically their emission requires an evaluation context parameter.
Similar to properties, provide a public emitter function that takes care
of the context.

This also required two fixes in the compiler, in order to make the
following (as part of the test case) work:

    signal foo;
    foo => { ... }

    (1) Register declared signals before attempting to implement the
    connection handlers.
    (2) When looking up the signal property, not only look in the base
    type but also in the current type.
2020-06-11 21:05:52 +02:00
Olivier Goffart
e95d7da888 Parser: typed syntax node accessor 2020-06-11 17:50:28 +02:00
Olivier Goffart
d4594cff97 Introduce a new DeclaredIdentifier syntax kind to disambiguiate identifiers when there are several 2020-06-11 16:55:38 +02:00
Simon Hausmann
be3d0ab369 Provide convenience accessors for public properties in C++
While properties declared in the root component are named as-is and
exposed as Property<T>, their get() function in particular is hard to
use because it requires an EvaluationContext as a parameter.

This patch adds get_foo() and set_foo() accessors for each public
property and hides the evaluation context business for the getter.

The added test uses this right away and adds missing test coverage for
the conditional expression.
2020-06-11 15:45:16 +02:00
Olivier Goffart
8b6bb47af8 Create a type alias for Rc<RefCell<Element>> 2020-06-11 15:28:51 +02:00
Olivier Goffart
96a372e45d Grid layout in the interpreter
current imploementation is just a prototype
2020-06-10 19:40:47 +02:00
Olivier Goffart
ed69f4c432 WIP layouts 2020-06-10 19:40:47 +02:00
Simon Hausmann
1404cb73ae Add support for embedding resources in the rust generator
This is relatively straight-forward via a pass in the compiler to
collect the resources to embed and then use include_bytes! (once per
resource).

What's really annoying is that the rust resource enum can't store a
&'static [u8] because cbindgen doesn't represent that, probably because
the slice representation isn't guaranteed to stay as it is. So instead
this, for now, uses raw pointers.
2020-06-09 22:54:29 +02:00
Olivier Goffart
a756b7fa0e Keep a reference to the AST node in the Element structure
So we can give error for elements
2020-06-09 18:20:32 +02:00
Olivier Goffart
c05da294a1 Add GridLayout and Row
The compiler currently lowers them to nothing
2020-06-09 12:46:16 +02:00
Olivier Goffart
e86a7d3192 Merge signal and property declaration
A Signal is just a property of type Type::Signal

Simplifies the code a bit
2020-05-28 12:49:18 +02:00
Olivier Goffart
95b671c97c Support for code blocks and signal call 2020-05-28 12:30:08 +02:00
Olivier Goffart
3472674262 Add a pass to assign unique id to the elements 2020-05-27 08:20:52 +02:00
Olivier Goffart
36fb526811 Do inlining in a pass before the lowering 2020-05-26 15:10:27 +02:00
Simon Hausmann
96d5165d28 Correctly report type conversion errors in the C++ backend
This requires a bit of error propagation, but now the errors are
reported correctly, in the unlikely event that they occur.
2020-05-26 11:45:22 +02:00
Olivier Goffart
a39a72b240 Fix the syntax_tests to actually match the regexp
The error regexp was not properly matched, being effectively ignoed.
Fixed that and the tests.
Added self tests to syntax_tests.
2020-05-26 11:24:37 +02:00
Olivier Goffart
7ba39f0a1c Make sure that we cannot override a property from the base 2020-05-26 11:23:54 +02:00
Olivier Goffart
9e4c355fa1 Lookup of quallified id 2020-05-25 17:24:31 +02:00
Simon Hausmann
1efa80882e Parse initializers for property declarations 2020-05-25 16:42:09 +02:00
Simon Hausmann
b3ee72b6c5 Permit bindings on declared properties
At least syntactically :-)
2020-05-25 16:42:09 +02:00
Simon Hausmann
88faafe305 Fix property declaration storage in the object tree
We need to maintain an associated data structure to permit checking for
duplicate property declarations.
2020-05-25 16:42:09 +02:00
Simon Hausmann
747cf18fcd Small typo fix
(Unkown -> Unknown)
2020-05-25 16:42:09 +02:00
Olivier Goffart
c0a4902240 Rename expressions -> expression_tree
there is already an expressions module in the parser
2020-05-25 15:28:37 +02:00
Simon Hausmann
73917187d6 Fix error message for duplicate property bindings 2020-05-25 15:05:11 +02:00
Olivier Goffart
11e5ce5887 Rename the CondeStatement syntax node to BindingExpression
This is the right-hand-side of a binding, and it is a pure expression.
Statements will be reserved for signals
2020-05-25 14:58:26 +02:00
Olivier Goffart
1de4eb476b Lookup of identifier is now done while resolving expressions 2020-05-25 14:37:09 +02:00