Skip to content

Commit 028f2b8

Browse files
committed
C#: Add downgrade script.
1 parent e458163 commit 028f2b8

File tree

4 files changed

+3044
-0
lines changed

4 files changed

+3044
-0
lines changed
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
class Expr extends @expr {
2+
string toString() { none() }
3+
}
4+
5+
class ControlFlowElement extends @control_flow_element {
6+
string toString() { none() }
7+
}
8+
9+
predicate assignmentKind(int kind) {
10+
// | 63 = @simple_assign_expr
11+
// | 80 = @add_event_expr
12+
// | 81 = @remove_event_expr
13+
// | 83 = @local_var_decl_expr
14+
kind = [63, 80, 81, 83]
15+
}
16+
17+
predicate compoundAssignmentKind(int kind) {
18+
// | 64 = @assign_add_expr
19+
// | 65 = @assign_sub_expr
20+
// | 66 = @assign_mul_expr
21+
// | 67 = @assign_div_expr
22+
// | 68 = @assign_rem_expr
23+
// | 69 = @assign_and_expr
24+
// | 70 = @assign_xor_expr
25+
// | 71 = @assign_or_expr
26+
// | 72 = @assign_lshift_expr
27+
// | 73 = @assign_rshift_expr
28+
// | 119 = @assign_coalesce_expr
29+
kind = [64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 119]
30+
}
31+
32+
predicate isAssignmentOrCompoundAssignment(Expr ass) {
33+
exists(int kind | assignmentKind(kind) or compoundAssignmentKind(kind) |
34+
expressions(ass, kind, _)
35+
)
36+
}
37+
38+
query predicate new_expr_parent(Expr e, int child, ControlFlowElement parent) {
39+
if isAssignmentOrCompoundAssignment(parent)
40+
then
41+
// Swap children for assignments, local variable declarations and add/remove event.
42+
child = 0 and expr_parent(e, 1, parent)
43+
or
44+
child = 1 and expr_parent(e, 0, parent)
45+
else
46+
// Copy the expr_parent relation.
47+
expr_parent(e, child, parent)
48+
}

0 commit comments

Comments
 (0)