Commit graph

39 commits

Author SHA1 Message Date
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
Olivier Goffart
170564ecea Implement % as a unit 2020-07-16 11:24:46 +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
Olivier Goffart
24033ecdc3 Support for logical_lenght type 2020-07-15 11:53:19 +02:00
Olivier Goffart
8e7e3aaa7a Make the length its own unit 2020-07-14 17:45:03 +02:00
Olivier Goffart
952ddda7c4 Force duration to have an unit 2020-07-14 16:18:12 +02:00
Olivier Goffart
c30aa370f3 Parse units
They currently have no real meaning
2020-07-14 11:35:45 +02:00
Simon Hausmann
251ef7fc97 Add support for SVG commands in Path elements
Using the commands property we can just paste SVG paths. This makes it
much easier to write examples/demos. A good online path designer is
for example https://codepen.io/anthonydugois/pen/mewdyZ
2020-07-09 13:41:57 +02:00
Simon Hausmann
22d838ffae Add support for true and false boolean literals 2020-07-07 22:11:41 +02:00
Simon Hausmann
a83127ace8 Prepare the path element compilation for extensibility
Avoid any element specific code in the Rust and C++ generator and
minimize the involvement in the interpreter.
2020-07-07 14:14:17 +02:00
Simon Hausmann
fdf7169459 Fix is_constant for Expression::PathElements
Respect the constant'ness of the contained expressions.
2020-07-07 14:14:17 +02:00
Simon Hausmann
a71c67152e Revert "Prepare for additional path elements"
This reverts commit d143addb07.

We're going to need to support binding expressions in path elements.
2020-07-07 14:14:17 +02:00
Simon Hausmann
d143addb07 Prepare for additional path elements
Require that the values to the path element properties are numerical literals.
The conversion happens in the path "compilation" pass, where we can do more
pre-calcuation in the future.
2020-07-02 10:40:31 +02:00
Simon Hausmann
5e61ed4ad2 Implement Path and LineTo in the markup 2020-07-01 15:13:23 +02:00
Olivier Goffart
009addf9b4 Logical operations and comparisons and unary operators 2020-06-29 18:40:37 +02:00
Olivier Goffart
f744fcccab Lookup within objects properties
Generated code not yet implemented
2020-06-22 17:35:01 +02:00
Olivier Goffart
6238d0d14f Prepare for the ability to access the model
Add an expression type for the access of the model variable from a repeater
2020-06-19 13:46:55 +02:00
Olivier Goffart
be8f127317 Object and array parsing 2020-06-18 15:22:30 +02:00
Olivier Goffart
5cd4ed7347 Arithmetic operations 2020-06-16 19:04:03 +02:00
Olivier Goffart
d7fe69ff74 Lookup the index from a repeater expression 2020-06-16 17:23: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
ef9d3963e4 Fix casting of conditional operator 2020-06-12 10:32:56 +02:00
Olivier Goffart
e95d7da888 Parser: typed syntax node accessor 2020-06-11 17:50:28 +02:00
Simon Hausmann
03bef6dba3 Fix casting with conditional expressions
The following scenario would fail compiling to C++ because we failed to
determine the return type of the conditional expression:

    Test := Rectangle {
        property<bool> condition;
        property<color> extra_color;
        color: condition ? root.extra_color : 4289374890;
    }

The type of the true branch would be color and the false branch would be
a float. Since they "disagree", ty() on the expression would return
Type::Invalid. This was temporarily worked around in the C++ generator
by always returning the type of the true branch, but that's wrong.

Instead this patch changes maybe_convert_to to apply the Cast expression
to the individual branches, placing the cast only to the numberic
literal and correcting the return value of ty() on the conditional
expression.
2020-06-11 13:38:24 +02:00
Simon Hausmann
63f81e1991 Add basic support for conditional expressions
Todo are automated tests and cleaning up the C++ implementation.
2020-06-10 16:04:15 +02:00
Simon Hausmann
ea52c7c9c9 Fix typo 2020-06-10 12:03:46 +02:00
Simon Hausmann
5bae6e01a5 Prepare for the ability to embed image data
The Image's source property used to be a string. Now it is a Resource
enum, which can either be None or an absolute file path to the image on
disk. This also replaces the internal Image type.

The compiler internally resolves the img bang expression to a resource
reference, which shall remain just an absolute path. For now the target
generator passes that through, but in the future the target generator
may choose a target specific way of embedding the data and thus
generating a different Resource type in the final code (through
compile_expression in the cpp and rust generator).

The C++ binding is a bit messy as cbindgen doesn't really support
exporting enums that can be constructed on the C++ side. So instead we
use cbindgen to merely export the type internally and only use the tag
from it then. The public API is then a custom Resource type that is
meant to be binary compatible.
2020-06-09 22:54:29 +02:00
Olivier Goffart
dc276290e9 Add support for self assignment (+=, -=, ...) 2020-05-28 17:02:06 +02:00
Simon Hausmann
e227f8a46e Use both set() and set_binding() in the rust frontend
When an expression holds just a constant value, then we can avoid creating a binding.
2020-05-28 14:41:15 +02:00
Olivier Goffart
95b671c97c Support for code blocks and signal call 2020-05-28 12:30:08 +02:00
Olivier Goffart
f27816a450 Recurse into the expressions in the passes 2020-05-28 08:01:33 +02:00
Olivier Goffart
486b2ab8f8 Do type checking and convert from number to string 2020-05-27 15:43:45 +02:00
Olivier Goffart
4ea78134d8 Recactor the compiler so there are passes 2020-05-26 09:40:36 +02:00
Olivier Goffart
dee50a6fe8 More fixes to property lookup with components 2020-05-26 08:10:37 +02:00
Olivier Goffart
905f6c7b15 Fix signal lookup for now
Real signal lookup is still not implemented, any identifier for a signal property is considered as a signal
2020-05-25 17:34:38 +02:00
Olivier Goffart
9e4c355fa1 Lookup of quallified id 2020-05-25 17:24:31 +02:00
Simon Hausmann
747cf18fcd Small typo fix
(Unkown -> Unknown)
2020-05-25 16:42:09 +02:00
Olivier Goffart
19eca01dff Lookup of property within the root component 2020-05-25 16:13:17 +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
Renamed from sixtyfps_compiler/expressions.rs (Browse further)