| 1 |
#include "../chaining.h" |
| 2 |
|
| 3 |
static INLINE void closeRule(otl_ChainingRule *rule) { |
| 4 |
if (rule && rule->match && rule->matchCount) { |
| 5 |
for (tableid_t k = 0; k < rule->matchCount; k++) { |
| 6 |
Coverage.free(rule->match[k]); |
| 7 |
} |
| 8 |
FREE(rule->match); |
| 9 |
} |
| 10 |
if (rule && rule->apply) { |
| 11 |
for (tableid_t j = 0; j < rule->applyCount; j++) { |
| 12 |
Handle.dispose(&rule->apply[j].lookup); |
| 13 |
} |
| 14 |
FREE(rule->apply); |
| 15 |
} |
| 16 |
} |
| 17 |
static INLINE void deleteRule(otl_ChainingRule *rule) { |
| 18 |
if (!rule) return; |
| 19 |
closeRule(rule); |
| 20 |
FREE(rule); |
| 21 |
} |
| 22 |
static INLINE void reverseBacktracks(otl_ChainingRule *rule) { |
| 23 |
if (rule->inputBegins > 0) { |
| 24 |
tableid_t start = 0; |
| 25 |
tableid_t end = rule->inputBegins - 1; |
| 26 |
while (end > start) { |
| 27 |
otl_Coverage *tmp = rule->match[start]; |
| 28 |
rule->match[start] = rule->match[end]; |
| 29 |
rule->match[end] = tmp; |
| 30 |
end--, start++; |
| 31 |
} |
| 32 |
} |
| 33 |
} |