mirror of
https://github.com/github/codeql.git
synced 2026-05-05 21:55:19 +02:00
QL: Add AST support for HOPs
This commit is contained in:
@@ -753,6 +753,22 @@ class InstanceOf extends TInstanceOf, Formula {
|
||||
override string getAPrimaryQlClass() { result = "InstanceOf" }
|
||||
}
|
||||
|
||||
class HigherOrderFormula extends THigherOrderFormula, Formula {
|
||||
Generated::HigherOrderTerm hop;
|
||||
|
||||
HigherOrderFormula() { this = THigherOrderFormula(hop) }
|
||||
|
||||
PredicateExpr getInput(int i) { toGenerated(result) = hop.getChild(i).(Generated::PredicateExpr) }
|
||||
|
||||
private int getNumInputs() { result = 1 + max(int i | exists(this.getInput(i))) }
|
||||
|
||||
Expr getArgument(int i) { toGenerated(result) = hop.getChild(i + getNumInputs()) }
|
||||
|
||||
string getName() { result = hop.getName().getValue() }
|
||||
|
||||
override string getAPrimaryQlClass() { result = "HigherOrderFormula" }
|
||||
}
|
||||
|
||||
/** An aggregate expression, such as `count` or `sum`. */
|
||||
class Aggregate extends TAggregate, Expr {
|
||||
Generated::Aggregate agg;
|
||||
|
||||
@@ -40,6 +40,7 @@ newtype TAstNode =
|
||||
TIfFormula(Generated::IfTerm ifterm) or
|
||||
TImplication(Generated::Implication impl) or
|
||||
TInstanceOf(Generated::InstanceOf inst) or
|
||||
THigherOrderFormula(Generated::HigherOrderTerm hop) or
|
||||
TExprAnnotation(Generated::ExprAnnotation expr_anno) or
|
||||
TAddExpr(Generated::AddExpr addexp) or
|
||||
TLiteral(Generated::Literal lit) or
|
||||
@@ -50,7 +51,7 @@ newtype TAstNode =
|
||||
|
||||
class TFormula =
|
||||
TDisjunction or TConjunction or TComparisonFormula or TQuantifier or TNegation or TIfFormula or
|
||||
TImplication or TInstanceOf or TCall;
|
||||
TImplication or TInstanceOf or TCall or THigherOrderFormula;
|
||||
|
||||
class TBinOpExpr = TAddExpr;
|
||||
|
||||
@@ -73,7 +74,8 @@ Generated::AstNode toGeneratedFormula(AST::AstNode n) {
|
||||
n = TNegation(result) or
|
||||
n = TIfFormula(result) or
|
||||
n = TImplication(result) or
|
||||
n = TInstanceOf(result)
|
||||
n = TInstanceOf(result) or
|
||||
n = THigherOrderFormula(result)
|
||||
}
|
||||
|
||||
Generated::AstNode toGeneratedExpr(AST::AstNode n) {
|
||||
|
||||
Reference in New Issue
Block a user