| 1 |
#include "../chaining.h" |
| 2 |
|
| 3 |
json_value *otl_dump_chaining(const otl_Subtable *_subtable) { |
| 4 |
const subtable_chaining *subtable = &(_subtable->chaining); |
| 5 |
if (subtable->type) return json_null_new(); |
| 6 |
const otl_ChainingRule *rule = &(subtable->rule); |
| 7 |
json_value *_st = json_object_new(4); |
| 8 |
|
| 9 |
json_value *_match = json_array_new(rule->matchCount); |
| 10 |
for (tableid_t j = 0; j < rule->matchCount; j++) { |
| 11 |
json_array_push(_match, Coverage.dump(rule->match[j])); |
| 12 |
} |
| 13 |
json_object_push(_st, "match", _match); |
| 14 |
|
| 15 |
json_value *_apply = json_array_new(rule->applyCount); |
| 16 |
for (tableid_t j = 0; j < rule->applyCount; j++) { |
| 17 |
json_value *_application = json_object_new(2); |
| 18 |
json_object_push(_application, "at", json_integer_new(rule->apply[j].index)); |
| 19 |
json_object_push(_application, "lookup", json_string_new(rule->apply[j].lookup.name)); |
| 20 |
json_array_push(_apply, _application); |
| 21 |
} |
| 22 |
json_object_push(_st, "apply", preserialize(_apply)); |
| 23 |
|
| 24 |
json_object_push(_st, "inputBegins", json_integer_new(rule->inputBegins)); |
| 25 |
json_object_push(_st, "inputEnds", json_integer_new(rule->inputEnds)); |
| 26 |
return _st; |
| 27 |
} |