Ruby: Add up/downgrade scripts (sigh)

This commit is contained in:
Tom Hvitved
2024-03-19 10:41:17 +01:00
parent 72ff494739
commit 865026f22b
12 changed files with 6184 additions and 0 deletions

View File

@@ -0,0 +1,44 @@
class TAstNodeParent = @file or @erb_ast_node;
abstract class AstNodeParent extends TAstNodeParent {
string toString() { none() }
}
class AstNode extends AstNodeParent, @erb_ast_node { }
class File extends AstNodeParent, @file { }
class Location extends @location_default {
string toString() { none() }
}
pragma[nomagic]
predicate hasFileParent(
AstNode n, File f, int startline, int startcolumn, int endline, int endcolumn
) {
exists(Location loc |
not erb_ast_node_parent(n, _, _) and
erb_ast_node_location(n, loc) and
locations_default(loc, f, startline, startcolumn, endline, endcolumn)
)
}
pragma[nomagic]
predicate hasFileParent(AstNode n, File f, int i) {
n =
rank[i + 1](AstNode n0, int startline, int startcolumn, int endline, int endcolumn |
hasFileParent(n0, f, startline, startcolumn, endline, endcolumn)
|
n0 order by startline, startcolumn, endline, endcolumn
)
}
from AstNode n, AstNodeParent parent, int i, Location location
where
erb_ast_node_location(n, location) and
(
erb_ast_node_parent(n, parent, i)
or
hasFileParent(n, parent, i)
)
select n, parent, i, location

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,44 @@
class TAstNodeParent = @file or @ruby_ast_node;
abstract class AstNodeParent extends TAstNodeParent {
string toString() { none() }
}
class AstNode extends AstNodeParent, @ruby_ast_node { }
class File extends AstNodeParent, @file { }
class Location extends @location_default {
string toString() { none() }
}
pragma[nomagic]
predicate hasFileParent(
AstNode n, File f, int startline, int startcolumn, int endline, int endcolumn
) {
exists(Location loc |
not ruby_ast_node_parent(n, _, _) and
ruby_ast_node_location(n, loc) and
locations_default(loc, f, startline, startcolumn, endline, endcolumn)
)
}
pragma[nomagic]
predicate hasFileParent(AstNode n, File f, int i) {
n =
rank[i + 1](AstNode n0, int startline, int startcolumn, int endline, int endcolumn |
hasFileParent(n0, f, startline, startcolumn, endline, endcolumn)
|
n0 order by startline, startcolumn, endline, endcolumn
)
}
from AstNode n, AstNodeParent parent, int i, Location location
where
ruby_ast_node_location(n, location) and
(
ruby_ast_node_parent(n, parent, i)
or
hasFileParent(n, parent, i)
)
select n, parent, i, location

View File

@@ -0,0 +1,8 @@
description: Merge `ruby_ast_node_location` and `ruby_ast_node_parent` into `ruby_ast_node_info` (and same for `erb`)
compatibility: backwards
erb_ast_node_info.rel: run erb_ast_node_info.qlo
erb_ast_node_location.rel: delete
erb_ast_node_parent.rel: delete
ruby_ast_node_info.rel: run ruby_ast_node_info.qlo
ruby_ast_node_location.rel: delete
ruby_ast_node_parent.rel: delete

View File

@@ -0,0 +1,11 @@
class AstNode extends @erb_ast_node {
string toString() { none() }
}
class Location extends @location_default {
string toString() { none() }
}
from AstNode n, Location location
where erb_ast_node_info(n, _, _, location)
select n, location

View File

@@ -0,0 +1,7 @@
class AstNode extends @erb_ast_node {
string toString() { none() }
}
from AstNode n, int i, AstNode parent
where erb_ast_node_info(n, parent, i, _)
select n, parent, i

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,11 @@
class AstNode extends @ruby_ast_node {
string toString() { none() }
}
class Location extends @location_default {
string toString() { none() }
}
from AstNode n, Location location
where ruby_ast_node_info(n, _, _, location)
select n, location

View File

@@ -0,0 +1,7 @@
class AstNode extends @ruby_ast_node {
string toString() { none() }
}
from AstNode n, int i, AstNode parent
where ruby_ast_node_info(n, parent, i, _)
select n, parent, i

View File

@@ -0,0 +1,8 @@
description: Split up `ruby_ast_node_info` into `ruby_ast_node_location` and `ruby_ast_node_parent` (and same for `erb`)
compatibility: backwards
erb_ast_node_location.rel: run erb_ast_node_location.qlo
erb_ast_node_parent.rel: run erb_ast_node_parent.qlo
erb_ast_node_info.rel: delete
ruby_ast_node_location.rel: run ruby_ast_node_location.qlo
ruby_ast_node_parent.rel: run ruby_ast_node_parent.qlo
ruby_ast_node_info.rel: delete