|
| 1 | +class Element extends @element { |
| 2 | + string toString() { none() } |
| 3 | +} |
| 4 | + |
| 5 | +newtype TAddedElement = |
| 6 | + TMacroBlockExpr(Element block) { |
| 7 | + block_exprs(block) and macro_call_macro_call_expansions(_, block) |
| 8 | + } |
| 9 | + |
| 10 | +module Fresh = QlBuiltins::NewEntity<TAddedElement>; |
| 11 | + |
| 12 | +class TNewElement = @element or Fresh::EntityId; |
| 13 | + |
| 14 | +class NewElement extends TNewElement { |
| 15 | + string toString() { none() } |
| 16 | +} |
| 17 | + |
| 18 | +query predicate new_macro_block_exprs(NewElement id) { id = Fresh::map(TMacroBlockExpr(_)) } |
| 19 | + |
| 20 | +query predicate new_macro_block_expr_statements(NewElement id, int index, Element stmt) { |
| 21 | + exists(Element block, Element list | |
| 22 | + id = Fresh::map(TMacroBlockExpr(block)) and |
| 23 | + block_expr_stmt_lists(block, list) and |
| 24 | + stmt_list_statements(list, index, stmt) |
| 25 | + ) |
| 26 | +} |
| 27 | + |
| 28 | +query predicate new_macro_block_expr_tail_exprs(NewElement id, Element expr) { |
| 29 | + exists(Element block, Element list | |
| 30 | + id = Fresh::map(TMacroBlockExpr(block)) and |
| 31 | + block_expr_stmt_lists(block, list) and |
| 32 | + stmt_list_tail_exprs(list, expr) |
| 33 | + ) |
| 34 | +} |
| 35 | + |
| 36 | +query predicate new_block_exprs(Element id) { |
| 37 | + block_exprs(id) and |
| 38 | + not macro_call_macro_call_expansions(_, id) |
| 39 | +} |
| 40 | + |
| 41 | +query predicate new_stmt_lists(Element id) { |
| 42 | + stmt_lists(id) and |
| 43 | + not exists(Element block | |
| 44 | + macro_call_macro_call_expansions(_, block) and |
| 45 | + block_expr_stmt_lists(block, id) |
| 46 | + ) |
| 47 | +} |
| 48 | + |
| 49 | +query predicate new_block_expr_stmt_lists(Element id, Element list) { |
| 50 | + block_expr_stmt_lists(id, list) and |
| 51 | + not macro_call_macro_call_expansions(_, id) |
| 52 | +} |
| 53 | + |
| 54 | +query predicate new_stmt_list_statements(Element id, int index, Element stmt) { |
| 55 | + stmt_list_statements(id, index, stmt) and |
| 56 | + not exists(Element block | |
| 57 | + macro_call_macro_call_expansions(_, block) and |
| 58 | + block_expr_stmt_lists(block, id) |
| 59 | + ) |
| 60 | +} |
| 61 | + |
| 62 | +query predicate new_stmt_list_tail_exprs(Element id, Element expr) { |
| 63 | + stmt_list_tail_exprs(id, expr) and |
| 64 | + not exists(Element block | |
| 65 | + macro_call_macro_call_expansions(_, block) and |
| 66 | + block_expr_stmt_lists(block, id) |
| 67 | + ) |
| 68 | +} |
| 69 | + |
| 70 | +query predicate new_macro_call_macro_call_expansions(NewElement id, NewElement expansion) { |
| 71 | + macro_call_macro_call_expansions(id, expansion) and |
| 72 | + not block_exprs(expansion) |
| 73 | + or |
| 74 | + exists(Element block | |
| 75 | + expansion = Fresh::map(TMacroBlockExpr(block)) and |
| 76 | + macro_call_macro_call_expansions(id, block) |
| 77 | + ) |
| 78 | +} |
0 commit comments