Skip to content

Commit 05e2ec3

Browse files
committed
QL: A bit more documentation
1 parent 0e38056 commit 05e2ec3

1 file changed

Lines changed: 47 additions & 1 deletion

File tree

ql/src/codeql_ql/ast/Ast.qll

Lines changed: 47 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -957,86 +957,132 @@ class FunctionSymbol extends string {
957957
FunctionSymbol() { this = "+" or this = "-" or this = "*" or this = "/" or this = "%" }
958958
}
959959

960-
/** A binary operation expression, such as `x+3` or `y/2` */
960+
/**
961+
* A binary operation expression, such as `x + 3` or `y / 2`.
962+
*/
961963
class BinOpExpr extends TBinOpExpr, Expr { }
962964

965+
/**
966+
* An addition or subtraction expression.
967+
*/
963968
class AddSubExpr extends TAddSubExpr, BinOpExpr {
964969
Generated::AddExpr expr;
965970
FunctionSymbol operator;
966971

967972
AddSubExpr() { this = TAddSubExpr(expr) and operator = expr.getChild().getValue() }
968973

974+
/** Gets the left operand of the binary expression. */
969975
Expr getLeftOperand() { toGenerated(result) = expr.getLeft() }
970976

977+
/* Gets the right operand of the binary expression. */
971978
Expr getRightOperand() { toGenerated(result) = expr.getRight() }
972979

980+
/* Gets an operand of the binary expression. */
973981
Expr getAnOperand() { result = getLeftOperand() or result = getRightOperand() }
974982

983+
/** Gets the operator of the binary expression. */
975984
FunctionSymbol getOperator() { result = operator }
976985
}
977986

987+
/**
988+
* An addition expression, such as `x + y`.
989+
*/
978990
class AddExpr extends AddSubExpr {
979991
AddExpr() { operator = "+" }
980992

981993
override string getAPrimaryQlClass() { result = "AddExpr" }
982994
}
983995

996+
/**
997+
* A subtraction expression, such as `x - y`.
998+
*/
984999
class SubExpr extends AddSubExpr {
9851000
SubExpr() { operator = "-" }
9861001

9871002
override string getAPrimaryQlClass() { result = "SubExpr" }
9881003
}
9891004

1005+
/**
1006+
* A multiplication, division, or modulo expression.
1007+
*/
9901008
class MulDivModExpr extends TMulDivModExpr, BinOpExpr {
9911009
Generated::MulExpr expr;
9921010
FunctionSymbol operator;
9931011

9941012
MulDivModExpr() { this = TMulDivModExpr(expr) and operator = expr.getChild().getValue() }
9951013

1014+
/** Gets the left operand of the binary expression. */
9961015
Expr getLeftOperand() { toGenerated(result) = expr.getLeft() }
9971016

1017+
/** Gets the right operand of the binary expression. */
9981018
Expr getRightOperand() { toGenerated(result) = expr.getRight() }
9991019

1020+
/** Gets an operand of the binary expression. */
10001021
Expr getAnOperand() { result = getLeftOperand() or result = getRightOperand() }
10011022

1023+
/** Gets the operator of the binary expression. */
10021024
FunctionSymbol getOperator() { result = operator }
10031025
}
10041026

1027+
/**
1028+
* A division expression, such as `x / y`.
1029+
*/
10051030
class DivExpr extends MulDivModExpr {
10061031
DivExpr() { operator = "/" }
10071032

10081033
override string getAPrimaryQlClass() { result = "DivExpr" }
10091034
}
10101035

1036+
/**
1037+
* A multiplication expression, such as `x * y`.
1038+
*/
10111039
class MulExpr extends MulDivModExpr {
10121040
MulExpr() { operator = "*" }
10131041

10141042
override string getAPrimaryQlClass() { result = "MulExpr" }
10151043
}
10161044

1045+
/**
1046+
* A modulo expression, such as `x % y`.
1047+
*/
10171048
class ModExpr extends MulDivModExpr {
10181049
ModExpr() { operator = "%" }
10191050

10201051
override string getAPrimaryQlClass() { result = "ModExpr" }
10211052
}
10221053

1054+
/**
1055+
* A range expression, such as `[1 .. 10]`.
1056+
*/
10231057
class Range extends TRange, Expr {
10241058
Generated::Range range;
10251059

10261060
Range() { this = TRange(range) }
10271061

1062+
/**
1063+
* Gets the lower bound of the range.
1064+
*/
10281065
Expr getLowEndpoint() { toGenerated(result) = range.getLower() }
10291066

1067+
/**
1068+
* Gets the upper bound of the range.
1069+
*/
10301070
Expr getHighEndpoint() { toGenerated(result) = range.getUpper() }
10311071

10321072
override string getAPrimaryQlClass() { result = "Range" }
10331073
}
10341074

1075+
/**
1076+
* A set literal expression, such as `[1,3,5,7]`.
1077+
*/
10351078
class Set extends TSet, Expr {
10361079
Generated::SetLiteral set;
10371080

10381081
Set() { this = TSet(set) }
10391082

1083+
/**
1084+
* Gets the ith element in the set literal expression.
1085+
*/
10401086
Expr getElement(int i) { toGenerated(result) = set.getChild(i) }
10411087

10421088
override string getAPrimaryQlClass() { result = "Set" }

0 commit comments

Comments
 (0)