Add AST node for expression annotations

This commit is contained in:
Taus
2021-05-27 12:52:37 +00:00
committed by GitHub
parent 6aa64ba2cc
commit 20e72d3304
2 changed files with 17 additions and 1 deletions

View File

@@ -857,6 +857,20 @@ class Expr extends TExpr, AstNode {
}
}
class ExprAnnotation extends TExprAnnotation, Expr {
Generated::ExprAnnotation expr_anno;
ExprAnnotation() { this = TExprAnnotation(expr_anno) }
string getName() { result = expr_anno.getName().getValue() }
string getAnnotationArgument() { result = expr_anno.getAnnotArg().getValue() }
Expr getExpression() { toGenerated(result) = expr_anno.getChild() }
override string getAPrimaryQlClass() { result = "ExprAnnotation" }
}
/** A function symbol, such as `+` or `*`. */
class FunctionSymbol extends string {
FunctionSymbol() { this = "+" or this = "-" or this = "*" or this = "/" or this = "%" }

View File

@@ -40,6 +40,7 @@ newtype TAstNode =
TIfFormula(Generated::IfTerm ifterm) or
TImplication(Generated::Implication impl) or
TInstanceOf(Generated::InstanceOf inst) or
TExprAnnotation(Generated::ExprAnnotation expr_anno) or
TAddExpr(Generated::AddExpr addexp) or
TLiteral(Generated::Literal lit) or
TUnaryExpr(Generated::UnaryExpr unaryexpr) or
@@ -55,7 +56,7 @@ class TBinOpExpr = TAddExpr;
class TExpr =
TBinOpExpr or TLiteral or TAggregate or TIdentifier or TInlineCast or TCall or TUnaryExpr or
TDontCare;
TExprAnnotation or TDontCare;
class TCall = TPredicateCall or TMemberCall or TNoneCall or TAnyCall;
@@ -77,6 +78,7 @@ Generated::AstNode toGeneratedFormula(AST::AstNode n) {
Generated::AstNode toGeneratedExpr(AST::AstNode n) {
n = TAddExpr(result) or
n = TExprAnnotation(result) or
n = TLiteral(result) or
n = TAggregate(result) or
n = TIdentifier(result) or