Allow predicates in queries, to match on nodes' text
This commit is contained in:
parent
307a1a6c11
commit
096126d039
8 changed files with 781 additions and 186 deletions
|
|
@ -795,14 +795,34 @@ class Query {
|
|||
|
||||
const count = getValue(TRANSFER_BUFFER, 'i32');
|
||||
const startAddress = getValue(TRANSFER_BUFFER + SIZE_OF_INT, 'i32');
|
||||
const result = new Array(count);
|
||||
unmarshalCaptures(this, node.tree, startAddress, result);
|
||||
const result = [];
|
||||
|
||||
let address = startAddress;
|
||||
for (let i = 0; i < count; i++) {
|
||||
const pattern = getValue(address, 'i32');
|
||||
address += SIZE_OF_INT;
|
||||
const captureCount = getValue(address, 'i32');
|
||||
address += SIZE_OF_INT;
|
||||
const captureIndex = getValue(address, 'i32');
|
||||
address += SIZE_OF_INT;
|
||||
|
||||
const captures = new Array(captureCount);
|
||||
address = unmarshalCaptures(this, node.tree, address, captures);
|
||||
|
||||
if (capturesMatchConditions(this, node.tree, pattern, captures)) {
|
||||
result.push(captures[captureIndex]);
|
||||
}
|
||||
}
|
||||
|
||||
C._free(startAddress);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
function capturesMatchConditions(query, tree, pattern, captures) {
|
||||
return true;
|
||||
}
|
||||
|
||||
function unmarshalCaptures(query, tree, address, result) {
|
||||
for (let i = 0, n = result.length; i < n; i++) {
|
||||
const captureIndex = getValue(address, 'i32');
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue