mirror of
https://github.com/github/codeql.git
synced 2026-02-11 20:51:06 +01:00
ifs, implications, instanceof
This commit is contained in:
@@ -620,6 +620,53 @@ class Forex extends Quantifier {
|
||||
override string getAPrimaryQlClass() { result = "Forex" }
|
||||
}
|
||||
|
||||
class IfFormula extends TIfFormula, Formula {
|
||||
Generated::IfTerm ifterm;
|
||||
|
||||
IfFormula() { this = TIfFormula(ifterm) }
|
||||
|
||||
/** Gets the condition of this if formula. */
|
||||
Formula getCondition() { toGenerated(result) = ifterm.getCond() }
|
||||
|
||||
/** Gets the then part of this if formula. */
|
||||
Formula getThenPart() { toGenerated(result) = ifterm.getFirst() }
|
||||
|
||||
/** Gets the else part of this if formula. */
|
||||
Formula getElsePart() { toGenerated(result) = ifterm.getSecond() }
|
||||
|
||||
override string getAPrimaryQlClass() { result = "IfFormula" }
|
||||
}
|
||||
|
||||
class Implication extends TImplication, Formula {
|
||||
Generated::Implication imp;
|
||||
|
||||
Implication() { this = TImplication(imp) }
|
||||
|
||||
/** Gets the left operand of this implication. */
|
||||
Formula getLeftOperand() { toGenerated(result) = imp.getLeft() }
|
||||
|
||||
/** Gets the right operand of this implication. */
|
||||
Formula getRightOperand() { toGenerated(result) = imp.getRight() }
|
||||
|
||||
override string getAPrimaryQlClass() { result = "Implication" }
|
||||
}
|
||||
|
||||
class InstanceOf extends TInstanceOf, Formula {
|
||||
Generated::InstanceOf inst;
|
||||
|
||||
InstanceOf() { this = TInstanceOf(inst) }
|
||||
|
||||
/** Gets the expression being checked. */
|
||||
Expr getExpr() { toGenerated(result) = inst.getChild(0) }
|
||||
|
||||
/** Gets the reference to the type being checked. */
|
||||
Type getType() { toGenerated(result) = inst.getChild(1) }
|
||||
|
||||
/** Gets the type being checked. */
|
||||
//QLType getType() { result = getTypeRef().getType() }
|
||||
override string getAPrimaryQlClass() { result = "InstanceOf" }
|
||||
}
|
||||
|
||||
class Aggregate extends TAggregate, Expr {
|
||||
Generated::Aggregate agg;
|
||||
Generated::FullAggregateBody body;
|
||||
|
||||
@@ -37,13 +37,18 @@ newtype TAstNode =
|
||||
not agg.getChild(_) instanceof Generated::FullAggregateBody
|
||||
} or
|
||||
TNegation(Generated::Negation neg) or
|
||||
TIfFormula(Generated::IfTerm ifterm) or
|
||||
TImplication(Generated::Implication impl) or
|
||||
TInstanceOf(Generated::InstanceOf inst) or
|
||||
TAddExpr(Generated::AddExpr addexp) or
|
||||
TLiteral(Generated::Literal lit) or
|
||||
TUnaryExpr(Generated::UnaryExpr unaryexpr) or
|
||||
TDontCare(Generated::Underscore dontcare) or
|
||||
TModuleExpr(Generated::ModuleExpr me)
|
||||
|
||||
class TFormula = TDisjunction or TConjunction or TComparisonFormula or TQuantifier or TNegation;
|
||||
class TFormula =
|
||||
TDisjunction or TConjunction or TComparisonFormula or TQuantifier or TNegation or TIfFormula or
|
||||
TImplication or TInstanceOf;
|
||||
|
||||
class TBinOpExpr = TAddExpr;
|
||||
|
||||
@@ -59,7 +64,12 @@ Generated::AstNode toGeneratedFormula(AST::AstNode n) {
|
||||
n = TComparisonFormula(result) or
|
||||
n = TComparisonOp(result) or
|
||||
n = TQuantifier(result) or
|
||||
n = TNegation(result)
|
||||
n = TAggregate(result) or
|
||||
n = TIdentifier(result) or
|
||||
n = TNegation(result) or
|
||||
n = TIfFormula(result) or
|
||||
n = TImplication(result) or
|
||||
n = TInstanceOf(result)
|
||||
}
|
||||
|
||||
Generated::AstNode toGeneratedExpr(AST::AstNode n) {
|
||||
|
||||
Reference in New Issue
Block a user