Commit graph

106 commits

Author SHA1 Message Date
Olivier Goffart
c024f97890 Viewer: use binding when needed 2020-05-30 17:42:17 +02:00
Olivier Goffart
dc276290e9 Add support for self assignment (+=, -=, ...) 2020-05-28 17:02:06 +02:00
Olivier Goffart
38329361b6 Use Property::set in C++ for constant bindings 2020-05-28 14:58:08 +02:00
Olivier Goffart
74898a1386 Make property conneciton binding in the C++
(somehow plus/minus is not working yet)
2020-05-28 14:52:43 +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
f6d1151832 Use the EvaluationContext in the signal handler 2020-05-28 14:26:35 +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
Simon Hausmann
f2df9293a9 Fix the C++ build
Remove the Optional from the evaluation context passing for property
evaluation. Unfortunately there are nullptr uses left on the C++ side,
that need to be replaced with passing through.
2020-05-28 12:07:11 +02:00
Olivier Goffart
f27816a450 Recurse into the expressions in the passes 2020-05-28 08:01:33 +02:00
Olivier Goffart
92697ec6b0 Add some code to parse statements in blocks (separated with semicolon) 2020-05-28 07:22:08 +02:00
Olivier Goffart
250b0a2e5b Rust macro: get the right span for the diagnostics
Merge the features proc_macro_span and proc_macro_diagnostics, they are the same.
2020-05-27 18:37:45 +02:00
Olivier Goffart
42cddf2925 Add the conversion test 2020-05-27 16:46:31 +02:00
Olivier Goffart
5580b5112f Fix number to string conversion in C++ 2020-05-27 16:18:08 +02:00
Olivier Goffart
486b2ab8f8 Do type checking and convert from number to string 2020-05-27 15:43:45 +02:00
Simon Hausmann
c8b64f5c4b Remove the lowering
The LoweredItem and LoweredComponent contained, in essence, the same
information as the Element and Component in object_tree. Since the
moving declarations pass moved everything to the root element and the
LoweredPropertyDeclarations have been removed as well, this is the last
step.
2020-05-27 14:45:35 +02:00
Simon Hausmann
32990e15e2 Remove LoweredPropertyDeclaration
This type that allowed indexing the property declarations in the hierarchy
to the properties moved to the root is not needed anymore.
For now a simple set remains in the LoweredItem to generate
correct accessor prefixes.
2020-05-27 11:13:58 +02:00
Olivier Goffart
41332a759f Make property reference works in C++ 2020-05-27 10:00:45 +02:00
Simon Hausmann
01fc0df1a2 Revert "Fix C++ build"
This reverts commit 6818ea746f.

The build was fine before this change. We don't call map_name() on the
root declarations, so this can't really happen.
2020-05-27 09:58:55 +02:00
Simon Hausmann
6818ea746f Fix C++ build
Don't rename the declarations in the root element.
2020-05-27 09:56:24 +02:00
Olivier Goffart
c137b4dab5 Add a pass to move all declaration on the top level 2020-05-27 09:37:46 +02:00
Olivier Goffart
3472674262 Add a pass to assign unique id to the elements 2020-05-27 08:20:52 +02:00
Simon Hausmann
e77fe37568 Make it more convenient to deal with diagnostics in the Rust frontend
Provide a ToTokens implementation of Diagnostics by moving the code from the macro.
This makes it easier later to re-use the same logic to return
with diagnostics.
2020-05-26 15:17:18 +02:00
Olivier Goffart
36fb526811 Do inlining in a pass before the lowering 2020-05-26 15:10:27 +02:00
Olivier Goffart
b3d1a7196c Compile fix 2020-05-26 12:15:31 +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
4ea78134d8 Recactor the compiler so there are passes 2020-05-26 09:40:36 +02:00
Olivier Goffart
e8e1567975 Make the compiler actualy use the lib rather than re-declaring everything 2020-05-26 09:18:31 +02:00
Olivier Goffart
dee50a6fe8 More fixes to property lookup with components 2020-05-26 08:10:37 +02:00
Olivier Goffart
b12e63de52 Fix lookup of property within component 2020-05-26 07:43:12 +02:00
Simon Hausmann
0932953ac8 Implement property declarations for the C++ backend 2020-05-25 19:13:52 +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
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
a55cad05b9 Allow running specific syntax tests
By specifying the relative path as a command line argument, it's easier to
debug a specific case in the IDE.
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
19eca01dff Lookup of property within the root component 2020-05-25 16:13:17 +02:00
Olivier Goffart
ce657a5b01 Add test for failled lookup 2020-05-25 15:50:34 +02:00
Olivier Goffart
2bc695643d Fix the type of color 2020-05-25 15:43:19 +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
Simon Hausmann
e6bed90ced Resolve the type in property declarations
... and added int32 as another primitive type.
2020-05-25 14:03:01 +02:00
Simon Hausmann
d4387b74b9 Rename Type::Number to Type::Float32
Properties of that type are implemented as f32.
2020-05-25 13:52:31 +02:00
Olivier Goffart
3629e5f158 Refactor the Expression
So we will resolve the expression in a different step
2020-05-25 13:15:10 +02:00