Commit graph

281 commits

Author SHA1 Message Date
Simon Hausmann
114b51f32b Add include paths to CompilerConfiguration
We'll try to load .60 files from those paths.
2020-07-17 12:15:03 +02:00
Simon Hausmann
ada5f68908 Add aggregating BuildDiagnostics
This type aggregates different per-file diagnostics into a similar interface,
in preparation for reporting diagnostics from multiple source files.
2020-07-17 12:10:25 +02:00
Simon Hausmann
893b5132c8 Further encapsulate Diagnostics
Use has_error() and a new convenience function to get the diagnostics as a string vector.
2020-07-17 11:52:29 +02:00
Simon Hausmann
732a56259f Simplify compilation call sites further
Move run_passes into the library compilation function. That way the
FileDiagnostics are created by the parser, can be passed on to the library
compilation function and after that we don't need them anymore and can
replace them with future BuildDiagnostics for example.
2020-07-16 18:53:59 +02:00
Simon Hausmann
4d12bbb954 Fix type dependency test
Test loading the type that depends on another on our test registry, not the builtin one.
2020-07-16 18:50:54 +02:00
Simon Hausmann
4c65760322 Fold FileLoadError into the diagnostics module
The FileDiagnostics now hold a vector of Diagnostic elements, which is an
enum of either a CompilerDiagnostic or a FileLoadError.
2020-07-16 18:28:27 +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
4c1e4c4da4 Reduce direct access to CompilerDiagnostic::message
Instead use to_string(), to make it easier to change in the future.
2020-07-16 18:22:23 +02:00
Simon Hausmann
23ee925947 Diagnostics refactoring, part 2
Remove the need for PartialEq for the Diagnostics. The objective is to
introduce an enum here in the future
that may hold types that do not support
PartialEq. It turns out that we don't really need it though.
2020-07-16 17:49:29 +02:00
Simon Hausmann
a68cf95d98 Diagnostics refactoring
Remove the need to clone compiler diagnostics. We can avoid it here it
seems.
2020-07-16 17:44:52 +02:00
Olivier Goffart
5e7d5369aa Few fixes to the layout and add a test that the items are well positioned 2020-07-16 17:22:29 +02:00
Olivier Goffart
96cfd8a620 Fix property named "value" in C++, and fix comparison of lenght in rust 2020-07-16 17:22:29 +02:00
Simon Hausmann
08f9e6089e Fix loading of dependent types
Provided the caller gets the order of calls to add_type_from_resource, it
should be possible to load one type after another that depends on the former.
2020-07-16 15:01:04 +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
d35c68254d Added a test case for type dependencies 2020-07-16 14:18:49 +02:00
Simon Hausmann
c85f2537d3 Fix signature of function to load types from a directory
Taking &mut self makes more sense when wanting to populate from a list.

Also we should return a list of diagnostics for each file that we loaded
or an error if we couldn't load the file (for example due to permission
problems, etc.).

This way the caller can choose to show diagnostics, ignore them, etc.
2020-07-16 13:45:45 +02:00
Olivier Goffart
170564ecea Implement % as a unit 2020-07-16 11:24:46 +02:00
Simon Hausmann
c3aae7648a Further simplify compilation call sites
Remove the need to construct the type registry at all the call sites by
offering a compile_syntax_node function in the compiler library.
2020-07-16 09:25:26 +02:00
Simon Hausmann
64a4e749b7 Simplify path setup in the Diagnostics
Pass the path to the parse function, as that's easier at most call sites.
Also offer a convenience parse_file function.
2020-07-15 19:21:25 +02:00
Olivier Goffart
0fbf38f642 Let the compilerlib compile without the codemap dependencies
The idea is that we wouldn't need to bring this dependencies
if the interpreter is running on wasm for example
2020-07-15 19:08:00 +02:00
Olivier Goffart
dfd4a35e35 Set the DPI property according to the window's screen 2020-07-15 18:46:55 +02:00
Olivier Goffart
1dec276002 Continue adapting the window size
Implement the Rust and C++ part
2020-07-15 17:52:14 +02:00
Simon Hausmann
ddc4fb6e1f WIP: window size
Just playing around with propagating the width/height of the window.
2020-07-15 17:52:14 +02:00
Simon Hausmann
055517dc2c Remove duplicated code in Diagnostics emission 2020-07-15 17:34:11 +02:00
Simon Hausmann
8e047d3761 Simplify compiler diagnostics API
Don't require the callers to hold on to the source code string until an
eventual diagnostics code path is hit. Instead it turns out it's
simpler to let the parser consume the source code as string, where
internally after tokenizing it can be moved into the diagnostics and
from there into the code map if needed.

There are a few places where we now clone the source code, but that's
only in cases where we also extract stuff separately (test code) or the
syntax updater.
2020-07-15 17:34:11 +02:00
Olivier Goffart
96e5738785 Add a DPI variable in the interpreter and in the C++ backend 2020-07-15 17:13:23 +02:00
Olivier Goffart
20e7f3178e Rust: add a dpi variable in the component which is used when converting px to lx 2020-07-15 16:39:43 +02:00
Simon Hausmann
46bae52c15 Add support for loading types from a directory containing .60 files 2020-07-15 14:39:45 +02:00
Simon Hausmann
107aa63a7c Add the ability to extend a type registry with a .60 file 2020-07-15 14:30:02 +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
0f0055b87c Cleanup in the expression resolution pass
It turns out that we don't need the type registry :-)
2020-07-15 13:28:56 +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
Olivier Goffart
24033ecdc3 Support for logical_lenght type 2020-07-15 11:53:19 +02:00
Simon Hausmann
719bff4eca Minor cleanup
Don't require a mutable type registry for the compiler passes.
2020-07-15 11:25:28 +02:00
Olivier Goffart
8e7e3aaa7a Make the length its own unit 2020-07-14 17:45:03 +02:00
Olivier Goffart
4b20bf97ef Add px unit in many places
(This was done automatically with the updater)
2020-07-14 17:14:59 +02:00
Simon Hausmann
0fd3680542 Small typo fix 2020-07-14 16:48:10 +02:00
Simon Hausmann
855be51e82 Fix PropertyAnimation field population in Rust generator
Correctly use a separating comma when there are multiple bindings. This
also revers commit bcf5609d73.
2020-07-14 16:33:54 +02:00
Olivier Goffart
952ddda7c4 Force duration to have an unit 2020-07-14 16:18:12 +02:00
Simon Hausmann
39359a4e26 Add support for an offset to PathLayout
This allows animating items on their position along the path.
2020-07-14 15:12:03 +02:00
Simon Hausmann
f8024e6658 Add support for looping in animations 2020-07-14 13:22:28 +02:00
Olivier Goffart
c30aa370f3 Parse units
They currently have no real meaning
2020-07-14 11:35:45 +02:00
Simon Hausmann
a3f365417c Center items on a path layout 2020-07-14 09:43:59 +02:00
Olivier Goffart
e00491811b Get rid of the context in properties/signal 2020-07-13 18:49:06 +02:00
Olivier Goffart
ab7ae9f3e2 Some refactoring of the rust generated code
Always use a Pin<Rc> for the component. (This is required to support repeater
within repeater as well anyway)
Do not use the context within the binding. We can get along by simply capturing
a weak pointer to the component
2020-07-13 16:37:54 +02:00
Simon Hausmann
992f990fa8 Allow for fitting paths into a given bounding rectangle
... by applying a transformation. This allows designing a path in some
other path design tool and then make it fit using bindings.
2020-07-13 15:41:11 +02:00
Simon Hausmann
79ba943882 Allow for positioning grid layouts as well 2020-07-13 14:02:53 +02:00
Simon Hausmann
f6761e2c4c Allow for the positioning of PathLayouts via x/y properties
These are just "virtual" properties that will be transformed into
property members of the main struct through the optimized elements
sub-pass.
2020-07-13 13:34:04 +02:00
Simon Hausmann
e78dd1342a Fix optimized elements pass
Apply the move of bindings and properties also to the optimized elements themselves.
2020-07-13 13:30:55 +02:00
Olivier Goffart
868468b101 Interpreter: Do not use the parent component from the context 2020-07-13 13:13:23 +02:00