unified: Add a few more AST helper classes

This commit is contained in:
Asger F
2026-07-01 21:50:04 +02:00
parent 982f6a5e8a
commit 970e991b2c

View File

@@ -5,6 +5,39 @@
private import unified
module Public {
/**
* A logical 'and' expression with short-circuiting.
*/
class LogicalAndExpr extends BinaryExpr {
LogicalAndExpr() { this.getOperator().getValue() = "&&" }
Expr getAnOperand() { result = [this.getLeft(), this.getRight()] }
}
/**
* Declaration of a local or top-level variable.
*/
class LocalVariableDeclaration extends VariableDeclaration {
private Block block;
LocalVariableDeclaration() { this = block.getStmt(_) }
/** Gets the block in which this variable is declared. */
Block getDeclaringBlock() { result = block }
}
/**
* Declaration of a local or top-level function.
*/
class LocalFunctionDeclaration extends FunctionDeclaration {
private Block block;
LocalFunctionDeclaration() { this = block.getStmt(_) }
/** Gets the block in which this function is declared. */
Block getDeclaringBlock() { result = block }
}
/**
* A comment appearing in the source code.
*/