ifs, implications, instanceof

This commit is contained in:
Taus
2021-05-27 10:12:41 +00:00
committed by GitHub
parent 79789e28a1
commit cdd9978c30
2 changed files with 59 additions and 2 deletions

View File

@@ -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;

View File

@@ -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) {