@@ -777,6 +777,9 @@ class Call extends TCall, Expr, Formula {
777777 none ( ) // overriden in sublcasses.
778778 }
779779
780+ /** Gets an argument of this call, if any. */
781+ final Expr getAnArgument ( ) { result = getArgument ( _) }
782+
780783 PredicateOrBuiltin getTarget ( ) { resolveCall ( this , result ) }
781784
782785 override Type getType ( ) { result = this .getTarget ( ) .getReturnType ( ) }
@@ -1741,7 +1744,19 @@ class FunctionSymbol extends string {
17411744/**
17421745 * A binary operation expression, such as `x + 3` or `y / 2`.
17431746 */
1744- class BinOpExpr extends TBinOpExpr , Expr { }
1747+ class BinOpExpr extends TBinOpExpr , Expr {
1748+ /** Gets the left operand of the binary expression. */
1749+ Expr getLeftOperand ( ) { none ( ) } // overriden in subclasses
1750+
1751+ /* Gets the right operand of the binary expression. */
1752+ Expr getRightOperand ( ) { none ( ) } // overriden in subclasses
1753+
1754+ /** Gets the operator of the binary expression. */
1755+ FunctionSymbol getOperator ( ) { none ( ) } // overriden in subclasses
1756+
1757+ /* Gets an operand of the binary expression. */
1758+ final Expr getAnOperand ( ) { result = getLeftOperand ( ) or result = getRightOperand ( ) }
1759+ }
17451760
17461761/**
17471762 * An addition or subtraction expression.
@@ -1752,17 +1767,11 @@ class AddSubExpr extends TAddSubExpr, BinOpExpr {
17521767
17531768 AddSubExpr ( ) { this = TAddSubExpr ( expr ) and operator = expr .getChild ( ) .getValue ( ) }
17541769
1755- /** Gets the left operand of the binary expression. */
1756- Expr getLeftOperand ( ) { toGenerated ( result ) = expr .getLeft ( ) }
1757-
1758- /* Gets the right operand of the binary expression. */
1759- Expr getRightOperand ( ) { toGenerated ( result ) = expr .getRight ( ) }
1770+ override Expr getLeftOperand ( ) { toGenerated ( result ) = expr .getLeft ( ) }
17601771
1761- /* Gets an operand of the binary expression. */
1762- Expr getAnOperand ( ) { result = getLeftOperand ( ) or result = getRightOperand ( ) }
1772+ override Expr getRightOperand ( ) { toGenerated ( result ) = expr .getRight ( ) }
17631773
1764- /** Gets the operator of the binary expression. */
1765- FunctionSymbol getOperator ( ) { result = operator }
1774+ override FunctionSymbol getOperator ( ) { result = operator }
17661775
17671776 override PrimitiveType getType ( ) {
17681777 // Both operands are the same type
@@ -1822,16 +1831,12 @@ class MulDivModExpr extends TMulDivModExpr, BinOpExpr {
18221831 MulDivModExpr ( ) { this = TMulDivModExpr ( expr ) and operator = expr .getChild ( ) .getValue ( ) }
18231832
18241833 /** Gets the left operand of the binary expression. */
1825- Expr getLeftOperand ( ) { toGenerated ( result ) = expr .getLeft ( ) }
1834+ override Expr getLeftOperand ( ) { toGenerated ( result ) = expr .getLeft ( ) }
18261835
18271836 /** Gets the right operand of the binary expression. */
1828- Expr getRightOperand ( ) { toGenerated ( result ) = expr .getRight ( ) }
1837+ override Expr getRightOperand ( ) { toGenerated ( result ) = expr .getRight ( ) }
18291838
1830- /** Gets an operand of the binary expression. */
1831- Expr getAnOperand ( ) { result = getLeftOperand ( ) or result = getRightOperand ( ) }
1832-
1833- /** Gets the operator of the binary expression. */
1834- FunctionSymbol getOperator ( ) { result = operator }
1839+ override FunctionSymbol getOperator ( ) { result = operator }
18351840
18361841 override PrimitiveType getType ( ) {
18371842 // Both operands are of the same type
@@ -1904,6 +1909,11 @@ class Range extends TRange, Expr {
19041909 */
19051910 Expr getHighEndpoint ( ) { toGenerated ( result ) = range .getUpper ( ) }
19061911
1912+ /**
1913+ * Gets the lower and upper bounds of the range.
1914+ */
1915+ Expr getAnEndpoint ( ) { result = [ getLowEndpoint ( ) , getHighEndpoint ( ) ] }
1916+
19071917 override PrimitiveType getType ( ) { result .getName ( ) = "int" }
19081918
19091919 override string getAPrimaryQlClass ( ) { result = "Range" }
@@ -1930,6 +1940,11 @@ class Set extends TSet, Expr {
19301940 */
19311941 Expr getElement ( int i ) { toGenerated ( result ) = set .getChild ( i ) }
19321942
1943+ /**
1944+ * Gets an element in this set literal expression, if any.
1945+ */
1946+ Expr getAnElement ( ) { result = getElement ( _) }
1947+
19331948 override Type getType ( ) { result = this .getElement ( 0 ) .getType ( ) }
19341949
19351950 override string getAPrimaryQlClass ( ) { result = "Set" }
0 commit comments