Swift: Add up and downgrade scripts.

This commit is contained in:
Mathias Vorreiter Pedersen
2023-10-27 15:48:38 +01:00
parent fb470e4140
commit 6538a7645d
11 changed files with 13249 additions and 0 deletions

View File

@@ -0,0 +1,16 @@
// Change the second column in named_patterns from a @var_decl to a string
class NamedPattern extends @named_pattern {
VarDecl getVarDecl() { named_patterns(this, result) }
string toString() { none() }
}
class VarDecl extends @var_decl {
string getName() { var_decls(this, result, _) }
string toString() { none() }
}
from NamedPattern np, VarDecl d, string name
where d = np.getVarDecl() and name = d.getName()
select np, name

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,4 @@
description: change the second column in named_patterns to a string
compatibility: full
named_patterns.rel: run named_patterns.ql

View File

@@ -0,0 +1,43 @@
// Change the second column in named_patterns from a string a @var_decl using the same logic that used to be in the Swift QL libraries
class Pattern extends @pattern {
string toString() { none() }
}
class NamedPattern extends @named_pattern {
string getName() { named_patterns(this, result) }
VarDecl getVarDecl() {
this.getImmediateEnclosingPattern*() = result.getImmediateParentPattern() and
pragma[only_bind_out](result.getName()) = pragma[only_bind_out](this.getName())
}
Pattern getImmediateEnclosingPattern() {
enum_element_pattern_sub_patterns(result, this)
or
optional_some_patterns(result, this)
or
tuple_pattern_elements(result, _, this)
or
binding_patterns(result, this)
or
is_pattern_sub_patterns(result, this)
or
paren_patterns(result, this)
or
typed_patterns(result, this)
}
string toString() { none() }
}
class VarDecl extends @var_decl {
string getName() { var_decls(this, result, _) }
Pattern getImmediateParentPattern() { var_decl_parent_patterns(this, result) }
string toString() { none() }
}
from NamedPattern np, string name, VarDecl varDecl
where np.getName() = name and varDecl = np.getVarDecl()
select np, varDecl

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,4 @@
description: change the second column in named_patterns to a var_decl
compatibility: partial
named_patterns.rel: run named_patterns.ql

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,2 @@
description: update named_patterns table
compatibility: partial