gqlite 1.2.3 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/ext/Cargo.toml +20 -0
- data/ext/gqlitedb/Cargo.toml +77 -0
- data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/benches/common/pokec.rs +30 -20
- data/ext/gqlitedb/gqlite_bench_data/README.MD +6 -0
- data/ext/gqlitedb/gqlite_bench_data/scripts/generate_smaller_pokec.rb +85 -0
- data/ext/gqlitedb/gqlite_bench_data/scripts/to_efficient_pokec.rb +34 -0
- data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/src/aggregators/arithmetic.rs +1 -0
- data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/src/aggregators/stats.rs +27 -49
- data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/src/aggregators.rs +7 -7
- data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/src/capi.rs +10 -9
- data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/src/compiler/expression_analyser.rs +6 -4
- data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/src/compiler/variables_manager.rs +27 -31
- data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/src/compiler.rs +37 -41
- data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/src/connection.rs +42 -84
- data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/src/error.rs +105 -34
- data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/src/functions/containers.rs +21 -26
- data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/src/functions/edge.rs +2 -2
- data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/src/functions/math.rs +2 -2
- data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/src/functions/node.rs +1 -1
- data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/src/functions/path.rs +15 -20
- data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/src/functions/scalar.rs +2 -2
- data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/src/functions/value.rs +6 -6
- data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/src/functions.rs +20 -20
- data/ext/gqlitedb/src/graph.rs +11 -0
- data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/src/interpreter/evaluators.rs +160 -194
- data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/src/interpreter/instructions.rs +2 -1
- data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/src/lib.rs +9 -4
- data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/src/parser/ast.rs +44 -52
- data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/src/parser/gql.pest +1 -1
- data/ext/{gqliterb/vendor/gqlitedb/src/parser/parser.rs → gqlitedb/src/parser/parser_impl.rs} +50 -28
- data/ext/gqlitedb/src/parser.rs +4 -0
- data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/src/prelude.rs +3 -2
- data/ext/gqlitedb/src/query_result.rs +88 -0
- data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/src/store/redb.rs +226 -148
- data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/src/store/sqlite.rs +111 -128
- data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/src/store.rs +22 -22
- data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/src/tests/evaluators.rs +32 -76
- data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/src/tests/store.rs +95 -111
- data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/src/tests/templates/ast.rs +29 -29
- data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/src/tests/templates/programs.rs +4 -4
- data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/src/value/compare.rs +13 -20
- data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/src/value/contains.rs +2 -2
- data/ext/gqlitedb/src/value.rs +225 -0
- data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/src/value_table.rs +15 -5
- data/ext/gqliterb/Cargo.toml +12 -35
- data/ext/gqliterb/src/lib.rs +60 -38
- data/ext/graphcore/Cargo.toml +19 -0
- data/ext/graphcore/README.MD +4 -0
- data/ext/graphcore/release.toml +1 -0
- data/ext/graphcore/src/error.rs +28 -0
- data/ext/{gqliterb/vendor/gqlitedb → graphcore}/src/graph.rs +134 -38
- data/ext/graphcore/src/lib.rs +16 -0
- data/ext/graphcore/src/prelude.rs +4 -0
- data/ext/{gqliterb/vendor/gqlitedb → graphcore}/src/serialize_with.rs +2 -2
- data/ext/graphcore/src/table.rs +272 -0
- data/ext/{gqliterb/vendor/gqlitedb → graphcore}/src/value/value_map.rs +44 -49
- data/ext/graphcore/src/value.rs +413 -0
- metadata +94 -83
- data/ext/gqliterb/.cargo/config.toml +0 -2
- data/ext/gqliterb/Cargo.lock +0 -1116
- data/ext/gqliterb/vendor/gqlitedb/Cargo.lock +0 -2115
- data/ext/gqliterb/vendor/gqlitedb/Cargo.toml +0 -138
- data/ext/gqliterb/vendor/gqlitedb/src/parser.rs +0 -4
- data/ext/gqliterb/vendor/gqlitedb/src/value.rs +0 -609
- /data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/askama.toml +0 -0
- /data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/benches/common/mod.rs +0 -0
- /data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/benches/pokec_divan.rs +0 -0
- /data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/benches/pokec_iai.rs +0 -0
- /data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/release.toml +0 -0
- /data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/src/aggregators/containers.rs +0 -0
- /data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/src/aggregators/count.rs +0 -0
- /data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/src/consts.rs +0 -0
- /data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/src/functions/string.rs +0 -0
- /data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/src/interpreter/mod.rs +0 -0
- /data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/src/store/pgql.rs +0 -0
- /data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/src/tests/compiler.rs +0 -0
- /data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/src/tests/parser.rs +0 -0
- /data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/src/tests/store/redb.rs +0 -0
- /data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/src/tests/store/sqlite.rs +0 -0
- /data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/src/tests/templates.rs +0 -0
- /data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/src/tests.rs +0 -0
- /data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/src/utils.rs +0 -0
- /data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/templates/sql/sqlite/call_stats.sql +0 -0
- /data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/templates/sql/sqlite/edge_count_for_node.sql +0 -0
- /data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/templates/sql/sqlite/edge_create.sql +0 -0
- /data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/templates/sql/sqlite/edge_delete.sql +0 -0
- /data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/templates/sql/sqlite/edge_delete_by_nodes.sql +0 -0
- /data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/templates/sql/sqlite/edge_select.sql +0 -0
- /data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/templates/sql/sqlite/edge_update.sql +0 -0
- /data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/templates/sql/sqlite/graph_create.sql +0 -0
- /data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/templates/sql/sqlite/graph_delete.sql +0 -0
- /data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/templates/sql/sqlite/metadata_create_table.sql +0 -0
- /data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/templates/sql/sqlite/metadata_get.sql +0 -0
- /data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/templates/sql/sqlite/metadata_set.sql +0 -0
- /data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/templates/sql/sqlite/node_create.sql +0 -0
- /data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/templates/sql/sqlite/node_delete.sql +0 -0
- /data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/templates/sql/sqlite/node_select.sql +0 -0
- /data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/templates/sql/sqlite/node_update.sql +0 -0
- /data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/templates/sql/sqlite/table_exists.sql +0 -0
- /data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/templates/sql/sqlite/upgrade_from_1_01.sql +0 -0
- /data/ext/{gqliterb/vendor/gqlitedb → gqlitedb}/templates/sql/sqlite/upgrade_graph_from_1_01.sql +0 -0
@@ -20,6 +20,7 @@ fn unknown_variable_error(name: &ast::VariableIdentifier) -> ErrorType
|
|
20
20
|
// \_/ \__,_|_| |_|\__,_|_.__/|_|\___|
|
21
21
|
|
22
22
|
#[derive(Debug, Clone)]
|
23
|
+
#[allow(clippy::large_enum_variant)]
|
23
24
|
pub(crate) enum VariableContent
|
24
25
|
{
|
25
26
|
Node(ast::NodePattern),
|
@@ -137,14 +138,14 @@ impl VariablesManager
|
|
137
138
|
{
|
138
139
|
identifier
|
139
140
|
.as_ref()
|
140
|
-
.
|
141
|
+
.is_some_and(|identifier| self.variables.contains_key(identifier))
|
141
142
|
}
|
142
143
|
/// Get the index of the variable in the row of variables
|
143
144
|
pub(crate) fn get_variable_index(&self, identifier: &ast::VariableIdentifier) -> Result<usize>
|
144
145
|
{
|
145
146
|
self
|
146
147
|
.variables
|
147
|
-
.get(
|
148
|
+
.get(identifier)
|
148
149
|
.ok_or_else(|| unknown_variable_error(identifier))
|
149
150
|
.map(|x| x.col_id)
|
150
151
|
}
|
@@ -175,7 +176,7 @@ impl VariablesManager
|
|
175
176
|
var_id.as_ref().map_or(Ok(false), |name| {
|
176
177
|
self
|
177
178
|
.variables
|
178
|
-
.get(
|
179
|
+
.get(name)
|
179
180
|
.ok_or_else(|| unknown_variable_error(name))
|
180
181
|
.map(|x| x.is_set)
|
181
182
|
})
|
@@ -190,7 +191,7 @@ impl VariablesManager
|
|
190
191
|
{
|
191
192
|
self
|
192
193
|
.variables
|
193
|
-
.get_mut(
|
194
|
+
.get_mut(var_id)
|
194
195
|
.ok_or_else(|| unknown_variable_error(var_id))
|
195
196
|
.map(|x| x.is_set = true)
|
196
197
|
}
|
@@ -205,7 +206,7 @@ impl VariablesManager
|
|
205
206
|
expression_type: ExpressionType,
|
206
207
|
) -> Result<()>
|
207
208
|
{
|
208
|
-
if self.variables.contains_key(
|
209
|
+
if self.variables.contains_key(var_id)
|
209
210
|
{
|
210
211
|
Err(
|
211
212
|
CompileTimeError::VariableAlreadyBound {
|
@@ -228,7 +229,7 @@ impl VariablesManager
|
|
228
229
|
{
|
229
230
|
if let Some(var_id) = &node.variable
|
230
231
|
{
|
231
|
-
if let Some(var) = self.variables.get(
|
232
|
+
if let Some(var) = self.variables.get(var_id)
|
232
233
|
{
|
233
234
|
match var.variable_type
|
234
235
|
{
|
@@ -236,7 +237,7 @@ impl VariablesManager
|
|
236
237
|
{
|
237
238
|
VariableContent::Node(var_node) =>
|
238
239
|
{
|
239
|
-
if (!node.labels.is_none() ||
|
240
|
+
if (!node.labels.is_none() || node.properties.is_some())
|
240
241
|
&& (node.labels != var_node.labels || node.properties != var_node.properties)
|
241
242
|
{
|
242
243
|
Err(
|
@@ -271,7 +272,7 @@ impl VariablesManager
|
|
271
272
|
{
|
272
273
|
if let Some(props) = &node.properties
|
273
274
|
{
|
274
|
-
expression_analyser::Analyser::new(
|
275
|
+
expression_analyser::Analyser::new(self, &self.function_manager).analyse(props)?;
|
275
276
|
}
|
276
277
|
self.variables.insert(
|
277
278
|
var_id.clone(),
|
@@ -291,7 +292,7 @@ impl VariablesManager
|
|
291
292
|
self.validate_node(&edge.destination)?;
|
292
293
|
if let Some(var_id) = &edge.variable
|
293
294
|
{
|
294
|
-
if let Some(var) = self.variables.get(
|
295
|
+
if let Some(var) = self.variables.get(var_id)
|
295
296
|
{
|
296
297
|
match var.content
|
297
298
|
{
|
@@ -313,7 +314,7 @@ impl VariablesManager
|
|
313
314
|
{
|
314
315
|
if let Some(props) = &edge.properties
|
315
316
|
{
|
316
|
-
expression_analyser::Analyser::new(
|
317
|
+
expression_analyser::Analyser::new(self, &self.function_manager).analyse(props)?;
|
317
318
|
}
|
318
319
|
self.variables.insert(
|
319
320
|
var_id.clone(),
|
@@ -333,7 +334,7 @@ impl VariablesManager
|
|
333
334
|
{
|
334
335
|
if let Some(var_id) = &node.variable
|
335
336
|
{
|
336
|
-
if let Some(var) = self.variables.get(
|
337
|
+
if let Some(var) = self.variables.get(var_id)
|
337
338
|
{
|
338
339
|
match var.variable_type
|
339
340
|
{
|
@@ -341,7 +342,7 @@ impl VariablesManager
|
|
341
342
|
{
|
342
343
|
VariableContent::Node(var_node) =>
|
343
344
|
{
|
344
|
-
if (!node.labels.is_none() ||
|
345
|
+
if (!node.labels.is_none() || node.properties.is_some())
|
345
346
|
&& (node.labels != var_node.labels || node.properties != var_node.properties)
|
346
347
|
{
|
347
348
|
Err(
|
@@ -388,7 +389,7 @@ impl VariablesManager
|
|
388
389
|
{
|
389
390
|
if let Some(var_id) = &edge.variable
|
390
391
|
{
|
391
|
-
if let Some(var) = self.variables.get(
|
392
|
+
if let Some(var) = self.variables.get(var_id)
|
392
393
|
{
|
393
394
|
match var.variable_type
|
394
395
|
{
|
@@ -396,7 +397,7 @@ impl VariablesManager
|
|
396
397
|
{
|
397
398
|
VariableContent::Edge(var_edge) =>
|
398
399
|
{
|
399
|
-
if (!edge.labels.is_none() ||
|
400
|
+
if (!edge.labels.is_none() || edge.properties.is_some())
|
400
401
|
&& (var_edge.labels != edge.labels || var_edge.properties != edge.properties)
|
401
402
|
{
|
402
403
|
Err(
|
@@ -474,7 +475,7 @@ impl VariablesManager
|
|
474
475
|
{
|
475
476
|
self.validate_node(&edge.destination)?;
|
476
477
|
}
|
477
|
-
if is_create || !self.is_valid_existing_edge(
|
478
|
+
if is_create || !self.is_valid_existing_edge(edge)?
|
478
479
|
{
|
479
480
|
self.validate_edge(edge)?;
|
480
481
|
}
|
@@ -507,7 +508,7 @@ impl VariablesManager
|
|
507
508
|
named_expression: &ast::NamedExpression,
|
508
509
|
) -> Result<usize>
|
509
510
|
{
|
510
|
-
let expression_info = expression_analyser::Analyser::new(
|
511
|
+
let expression_info = expression_analyser::Analyser::new(self, &self.function_manager)
|
511
512
|
.analyse(&named_expression.expression)?;
|
512
513
|
let col_id = self
|
513
514
|
.variables
|
@@ -529,7 +530,7 @@ impl VariablesManager
|
|
529
530
|
{
|
530
531
|
let mut var = self
|
531
532
|
.variables
|
532
|
-
.remove(
|
533
|
+
.remove(var_id)
|
533
534
|
.ok_or_else(|| unknown_variable_error(var_id))?;
|
534
535
|
var.col_id = col_id;
|
535
536
|
new_variables.insert(var_id.clone(), var.mark_set());
|
@@ -539,7 +540,7 @@ impl VariablesManager
|
|
539
540
|
}
|
540
541
|
pub(crate) fn analyse(&mut self, statement: &ast::Statement) -> Result<()>
|
541
542
|
{
|
542
|
-
if self.variables.iter().any(|(_, var)| var.is_set
|
543
|
+
if self.variables.iter().any(|(_, var)| !var.is_set)
|
543
544
|
{
|
544
545
|
return Err(
|
545
546
|
InternalError::NotAllVariablesAreSet {
|
@@ -570,22 +571,17 @@ impl VariablesManager
|
|
570
571
|
{
|
571
572
|
for pattern in create.patterns.iter()
|
572
573
|
{
|
573
|
-
|
574
|
+
if let ast::Pattern::Node(n) = &pattern
|
574
575
|
{
|
575
|
-
|
576
|
+
if self.has_variable(&n.variable)
|
576
577
|
{
|
577
|
-
|
578
|
-
|
579
|
-
|
580
|
-
|
581
|
-
|
582
|
-
|
583
|
-
.into(),
|
584
|
-
);
|
585
|
-
}
|
578
|
+
return Err(
|
579
|
+
CompileTimeError::VariableAlreadyBound {
|
580
|
+
name: n.variable.clone().unwrap().name().clone(),
|
581
|
+
}
|
582
|
+
.into(),
|
583
|
+
);
|
586
584
|
}
|
587
|
-
_ =>
|
588
|
-
{}
|
589
585
|
}
|
590
586
|
self.analyse_pattern(pattern, true)?;
|
591
587
|
}
|
@@ -52,7 +52,7 @@ impl Compiler
|
|
52
52
|
) -> Result<()>
|
53
53
|
{
|
54
54
|
expression_analyser::Analyser::new(&self.variables_manager, &self.function_manager)
|
55
|
-
.analyse(
|
55
|
+
.analyse(expression)?;
|
56
56
|
|
57
57
|
let expr = match expression
|
58
58
|
{
|
@@ -83,7 +83,7 @@ impl Compiler
|
|
83
83
|
self.compile_expression(
|
84
84
|
function_call
|
85
85
|
.arguments
|
86
|
-
.
|
86
|
+
.first()
|
87
87
|
.ok_or(error::InternalError::MissingAggregationArgument)?,
|
88
88
|
&mut argument_instructions,
|
89
89
|
aggregations,
|
@@ -141,7 +141,7 @@ impl Compiler
|
|
141
141
|
self.compile_expression(v, instructions, aggregations)?;
|
142
142
|
keys.push(k.to_owned());
|
143
143
|
}
|
144
|
-
Instruction::CreateMap { keys
|
144
|
+
Instruction::CreateMap { keys }
|
145
145
|
}
|
146
146
|
ast::Expression::MemberAccess(member_access) =>
|
147
147
|
{
|
@@ -328,33 +328,32 @@ impl Compiler
|
|
328
328
|
.mark_variables_as_set(&node.variable)?;
|
329
329
|
self.compile_optional_expression(&node.properties, instructions)?;
|
330
330
|
let mut labels = Default::default();
|
331
|
-
|
331
|
+
Self::compile_labels_expression(&mut labels, &node.labels)?;
|
332
332
|
instructions.push(Instruction::CreateNodeLiteral { labels });
|
333
333
|
Ok(())
|
334
334
|
}
|
335
335
|
|
336
336
|
fn compile_labels_expression(
|
337
|
-
&mut self,
|
338
337
|
labels: &mut Vec<String>,
|
339
338
|
label_expressions: &ast::LabelExpression,
|
340
339
|
) -> Result<()>
|
341
340
|
{
|
342
|
-
match
|
341
|
+
match label_expressions
|
343
342
|
{
|
344
|
-
|
343
|
+
ast::LabelExpression::And(expressions) =>
|
345
344
|
{
|
346
345
|
for expr in expressions.iter()
|
347
346
|
{
|
348
|
-
|
347
|
+
Self::compile_labels_expression(labels, expr)?;
|
349
348
|
}
|
350
349
|
Ok(())
|
351
350
|
}
|
352
|
-
|
351
|
+
ast::LabelExpression::String(label) =>
|
353
352
|
{
|
354
353
|
labels.push(label.to_owned());
|
355
354
|
Ok(())
|
356
355
|
}
|
357
|
-
|
356
|
+
ast::LabelExpression::None => Ok(()),
|
358
357
|
_ => Err(
|
359
358
|
InternalError::InvalidCreateLabels {
|
360
359
|
context: "compile_create_labels",
|
@@ -366,21 +365,20 @@ impl Compiler
|
|
366
365
|
|
367
366
|
// Assume top of the stack contains an edge or node
|
368
367
|
fn compile_filter_labels(
|
369
|
-
&mut self,
|
370
368
|
instructions: &mut Instructions,
|
371
369
|
label_expressions: &ast::LabelExpression,
|
372
370
|
has_label_function: &functions::Function,
|
373
371
|
) -> Result<()>
|
374
372
|
{
|
375
|
-
match
|
373
|
+
match label_expressions
|
376
374
|
{
|
377
|
-
|
375
|
+
ast::LabelExpression::And(expressions) =>
|
378
376
|
{
|
379
377
|
instructions.push(Instruction::Push { value: true.into() });
|
380
378
|
instructions.push(Instruction::Swap);
|
381
379
|
for expr in expressions.iter()
|
382
380
|
{
|
383
|
-
|
381
|
+
Self::compile_filter_labels(instructions, expr, has_label_function)?;
|
384
382
|
// stack contains (a: bool) (b: labels) (c: bool)
|
385
383
|
instructions.push(Instruction::InverseRot3);
|
386
384
|
// stack contains (c: bool) (a: bool) (b: labels)
|
@@ -391,7 +389,7 @@ impl Compiler
|
|
391
389
|
}
|
392
390
|
Ok(())
|
393
391
|
}
|
394
|
-
|
392
|
+
ast::LabelExpression::Or(expressions) =>
|
395
393
|
{
|
396
394
|
instructions.push(Instruction::Push {
|
397
395
|
value: false.into(),
|
@@ -399,7 +397,7 @@ impl Compiler
|
|
399
397
|
instructions.push(Instruction::Swap);
|
400
398
|
for expr in expressions.iter()
|
401
399
|
{
|
402
|
-
|
400
|
+
Self::compile_filter_labels(instructions, expr, has_label_function)?;
|
403
401
|
// stack contains (a: bool) (b: labels) (c: bool)
|
404
402
|
instructions.push(Instruction::InverseRot3);
|
405
403
|
// stack contains (c: bool) (a: bool) (b: labels)
|
@@ -410,13 +408,13 @@ impl Compiler
|
|
410
408
|
}
|
411
409
|
Ok(())
|
412
410
|
}
|
413
|
-
|
411
|
+
ast::LabelExpression::Not(expr) =>
|
414
412
|
{
|
415
|
-
|
413
|
+
Self::compile_filter_labels(instructions, expr, has_label_function)?;
|
416
414
|
instructions.push(Instruction::NotUnaryOperator);
|
417
415
|
Ok(())
|
418
416
|
}
|
419
|
-
|
417
|
+
ast::LabelExpression::String(label) =>
|
420
418
|
{
|
421
419
|
instructions.push(Instruction::Duplicate);
|
422
420
|
instructions.push(Instruction::Push {
|
@@ -428,7 +426,7 @@ impl Compiler
|
|
428
426
|
});
|
429
427
|
Ok(())
|
430
428
|
}
|
431
|
-
|
429
|
+
ast::LabelExpression::None =>
|
432
430
|
{
|
433
431
|
instructions.push(Instruction::Push { value: true.into() });
|
434
432
|
Ok(())
|
@@ -436,10 +434,7 @@ impl Compiler
|
|
436
434
|
}
|
437
435
|
}
|
438
436
|
|
439
|
-
fn compile_create_patterns(
|
440
|
-
&mut self,
|
441
|
-
patterns: &Vec<crate::parser::ast::Pattern>,
|
442
|
-
) -> Result<Block>
|
437
|
+
fn compile_create_patterns(&mut self, patterns: &[crate::parser::ast::Pattern]) -> Result<Block>
|
443
438
|
{
|
444
439
|
let actions = patterns.iter().map(|c| {
|
445
440
|
let mut instructions = Instructions::new();
|
@@ -505,7 +500,7 @@ impl Compiler
|
|
505
500
|
Err(CompileTimeError::NoSingleRelationshipType)?;
|
506
501
|
}
|
507
502
|
let mut labels = Default::default();
|
508
|
-
|
503
|
+
Self::compile_labels_expression(&mut labels, &edge.labels)?;
|
509
504
|
instructions.push(Instruction::CreateEdgeLiteral { labels });
|
510
505
|
}
|
511
506
|
crate::parser::ast::Pattern::Path(_) =>
|
@@ -538,7 +533,7 @@ impl Compiler
|
|
538
533
|
let mut labels = Default::default();
|
539
534
|
if node.labels.is_all_inclusive()
|
540
535
|
{
|
541
|
-
|
536
|
+
Self::compile_labels_expression(&mut labels, &node.labels)?;
|
542
537
|
}
|
543
538
|
else
|
544
539
|
{
|
@@ -555,7 +550,7 @@ impl Compiler
|
|
555
550
|
let has_label_function = self
|
556
551
|
.function_manager
|
557
552
|
.get_function::<CompileTimeError>("has_label")?;
|
558
|
-
|
553
|
+
Self::compile_filter_labels(filter, &node.labels, &has_label_function)?;
|
559
554
|
filter.push(Instruction::Rot3);
|
560
555
|
filter.push(Instruction::AndBinaryOperator);
|
561
556
|
filter.push(Instruction::Swap);
|
@@ -634,14 +629,14 @@ impl Compiler
|
|
634
629
|
let mut labels = Default::default();
|
635
630
|
if edge.labels.is_all_inclusive()
|
636
631
|
{
|
637
|
-
|
632
|
+
Self::compile_labels_expression(&mut labels, &edge.labels)?;
|
638
633
|
}
|
639
634
|
else
|
640
635
|
{
|
641
636
|
let has_label_function = self
|
642
637
|
.function_manager
|
643
638
|
.get_function::<CompileTimeError>("has_label")?;
|
644
|
-
|
639
|
+
Self::compile_filter_labels(&mut filter, &edge.labels, &has_label_function)?;
|
645
640
|
filter.push(Instruction::Rot3);
|
646
641
|
filter.push(Instruction::AndBinaryOperator);
|
647
642
|
filter.push(Instruction::Swap);
|
@@ -690,7 +685,7 @@ impl Compiler
|
|
690
685
|
.mark_variables_as_set(&path_variable)?;
|
691
686
|
// Create block
|
692
687
|
Ok(BlockMatch::MatchEdge {
|
693
|
-
instructions
|
688
|
+
instructions,
|
694
689
|
left_variable: self
|
695
690
|
.variables_manager
|
696
691
|
.get_variable_index_option(&source_variable)?,
|
@@ -706,10 +701,11 @@ impl Compiler
|
|
706
701
|
})
|
707
702
|
}
|
708
703
|
|
704
|
+
#[allow(clippy::type_complexity)]
|
709
705
|
fn compile_return_with(
|
710
706
|
&mut self,
|
711
707
|
all: bool,
|
712
|
-
expressions: &
|
708
|
+
expressions: &[ast::NamedExpression],
|
713
709
|
where_expression: &Option<ast::Expression>,
|
714
710
|
modifiers: &ast::Modifiers,
|
715
711
|
) -> Result<(
|
@@ -755,7 +751,7 @@ impl Compiler
|
|
755
751
|
.into(),
|
756
752
|
);
|
757
753
|
}
|
758
|
-
let col_id = self.variables_manager.analyse_named_expression(
|
754
|
+
let col_id = self.variables_manager.analyse_named_expression(e)?;
|
759
755
|
variables.push((
|
760
756
|
e.identifier.clone(),
|
761
757
|
RWExpression {
|
@@ -778,7 +774,7 @@ impl Compiler
|
|
778
774
|
self.compile_expression(where_expression, &mut filter, &mut None)?;
|
779
775
|
}
|
780
776
|
|
781
|
-
let modifiers = self.compile_modifiers(
|
777
|
+
let modifiers = self.compile_modifiers(modifiers)?;
|
782
778
|
let variables_size = self.variables_size();
|
783
779
|
self
|
784
780
|
.variables_manager
|
@@ -793,7 +789,7 @@ impl Compiler
|
|
793
789
|
|
794
790
|
fn compile_match_patterns(
|
795
791
|
&mut self,
|
796
|
-
patterns: &
|
792
|
+
patterns: &[crate::parser::ast::Pattern],
|
797
793
|
where_expression: &Option<crate::parser::ast::Expression>,
|
798
794
|
optional: bool,
|
799
795
|
) -> Result<Block>
|
@@ -811,7 +807,7 @@ impl Compiler
|
|
811
807
|
.variables_manager
|
812
808
|
.mark_variables_as_set(&node.variable)?;
|
813
809
|
Ok(BlockMatch::MatchNode {
|
814
|
-
instructions
|
810
|
+
instructions,
|
815
811
|
variable: self
|
816
812
|
.variables_manager
|
817
813
|
.get_variable_index_option(&node.variable)?,
|
@@ -820,7 +816,7 @@ impl Compiler
|
|
820
816
|
}
|
821
817
|
crate::parser::ast::Pattern::Edge(edge) =>
|
822
818
|
{
|
823
|
-
self.compile_match_edge(None,
|
819
|
+
self.compile_match_edge(None, edge, is_single_match, &mut edge_variables)
|
824
820
|
}
|
825
821
|
crate::parser::ast::Pattern::Path(path) => self.compile_match_edge(
|
826
822
|
Some(path.variable.to_owned()),
|
@@ -841,7 +837,7 @@ impl Compiler
|
|
841
837
|
}
|
842
838
|
self.compile_expression(where_expression, &mut filter, &mut None)?;
|
843
839
|
}
|
844
|
-
Ok(Block::
|
840
|
+
Ok(Block::Match {
|
845
841
|
blocks,
|
846
842
|
filter,
|
847
843
|
optional,
|
@@ -852,7 +848,7 @@ impl Compiler
|
|
852
848
|
fn check_for_constant_integer_expression(&mut self, x: &ast::Expression) -> Result<()>
|
853
849
|
{
|
854
850
|
let ei = expression_analyser::Analyser::new(&self.variables_manager, &self.function_manager)
|
855
|
-
.analyse(
|
851
|
+
.analyse(x)?;
|
856
852
|
if !ei.constant
|
857
853
|
{
|
858
854
|
Err(error::CompileTimeError::NonConstantExpression.into())
|
@@ -879,7 +875,7 @@ impl Compiler
|
|
879
875
|
.map(|x| {
|
880
876
|
self.check_for_constant_integer_expression(x)?;
|
881
877
|
let mut instructions = Instructions::new();
|
882
|
-
self.compile_expression(
|
878
|
+
self.compile_expression(x, &mut instructions, &mut None)?;
|
883
879
|
Ok::<_, ErrorType>(instructions)
|
884
880
|
})
|
885
881
|
.transpose()?;
|
@@ -889,7 +885,7 @@ impl Compiler
|
|
889
885
|
.map(|x| {
|
890
886
|
self.check_for_constant_integer_expression(x)?;
|
891
887
|
let mut instructions = Instructions::new();
|
892
|
-
self.compile_expression(
|
888
|
+
self.compile_expression(x, &mut instructions, &mut None)?;
|
893
889
|
Ok::<_, ErrorType>(instructions)
|
894
890
|
})
|
895
891
|
.transpose()?;
|
@@ -1023,7 +1019,7 @@ pub(crate) fn compile(
|
|
1023
1019
|
| expression_analyser::ExpressionType::Edge
|
1024
1020
|
| expression_analyser::ExpressionType::Variant =>
|
1025
1021
|
{
|
1026
|
-
compiler.compile_expression(
|
1022
|
+
compiler.compile_expression(expr, &mut instructions, &mut None)?
|
1027
1023
|
}
|
1028
1024
|
_ => Err(CompileTimeError::InvalidDelete)?,
|
1029
1025
|
}
|