Skip to content

Commit 7a655ec

Browse files
committed
Fix upgrade script
1 parent 1db8370 commit 7a655ec

2 files changed

Lines changed: 78 additions & 1 deletion

File tree

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,5 @@
11
description: Add @rangeelementexpr, grouping the loop variables of a range statement
2-
compatibility: partial
2+
compatibility: full
3+
4+
exprs.rel: run upgrade.qlo new_exprs
5+
has_location.rel: run upgrade.qlo new_has_location
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
class Expr extends @expr {
2+
string toString() { none() }
3+
}
4+
5+
class ExprParent extends @exprparent {
6+
string toString() { none() }
7+
}
8+
9+
class RangeStmt extends @rangestmt {
10+
string toString() { none() }
11+
}
12+
13+
class Location extends @location {
14+
string toString() { none() }
15+
}
16+
17+
newtype TAddedExpr = TRangeElement(RangeStmt stmt)
18+
19+
module Fresh = QlBuiltins::NewEntity<TAddedExpr>;
20+
21+
class TNewExpr = @expr or Fresh::EntityId;
22+
23+
class NewExpr extends TNewExpr {
24+
string toString() { none() }
25+
}
26+
27+
class TNewExprParent = @exprparent or Fresh::EntityId;
28+
29+
class NewExprParent extends TNewExprParent {
30+
string toString() { none() }
31+
}
32+
33+
class TNewLocatable = @locatable or Fresh::EntityId;
34+
35+
class NewLocatable extends TNewLocatable {
36+
string toString() { none() }
37+
}
38+
39+
predicate isRangeElementChild(ExprParent parent, int idx, RangeStmt range) {
40+
parent = range and
41+
idx in [0 .. 1]
42+
}
43+
44+
query predicate new_exprs(NewExpr id, int kind, NewExprParent parent, int idx) {
45+
exists(RangeStmt range |
46+
id = Fresh::map(TRangeElement(range)) and
47+
kind = 55 and
48+
parent = range and
49+
idx = 0
50+
)
51+
or
52+
exists(Expr oldId, int oldKind, ExprParent oldParent, int oldIdx |
53+
exprs(oldId, oldKind, oldParent, oldIdx) and
54+
id = oldId and
55+
kind = oldKind and
56+
idx = oldIdx
57+
|
58+
exists(RangeStmt range | isRangeElementChild(oldParent, oldIdx, range) |
59+
parent = Fresh::map(TRangeElement(range))
60+
)
61+
or
62+
not isRangeElementChild(oldParent, oldIdx, _) and
63+
parent = oldParent
64+
)
65+
}
66+
67+
query predicate new_has_location(NewLocatable locatable, Location location) {
68+
has_location(locatable, location)
69+
or
70+
exists(RangeStmt range |
71+
locatable = Fresh::map(TRangeElement(range)) and
72+
has_location(range, location)
73+
)
74+
}

0 commit comments

Comments
 (0)