PS: Shorter predicate names and better toString messages.

This commit is contained in:
Mathias Vorreiter Pedersen
2024-08-28 14:21:11 +01:00
parent c69d70a97f
commit 8d59e09216
8 changed files with 44 additions and 44 deletions

View File

@@ -9,5 +9,5 @@ class AssignStmt extends @assignment_statement, Stmt {
Stmt getRightHandSide() { assignment_statement(this, _, _, result) }
override string toString() { result = "AssignmentStatement at: " + this.getLocation().toString() }
override string toString() { result = "...=..." }
}

View File

@@ -3,7 +3,7 @@ import powershell
class CmdExpr extends @command_expression, CmdBase {
override SourceLocation getLocation() { command_expression_location(this, result) }
Expr getExpression() { command_expression(this, result, _) }
Expr getExpr() { command_expression(this, result, _) }
int getNumRedirections() { command_expression(this, _, result) }
@@ -11,5 +11,5 @@ class CmdExpr extends @command_expression, CmdBase {
Redirection getARedirection() { result = this.getRedirection(_) }
override string toString() { result = "CommandExpression at: " + this.getLocation().toString() }
override string toString() { result = this.getExpr().toString() }
}

View File

@@ -7,5 +7,5 @@ class ConstExpr extends @constant_expression, BaseConstExpr {
StringLiteral getValue() { constant_expression_value(this, result) }
override string toString() { result = "ConstantExpression at: " + this.getLocation().toString() }
override string toString() { result = this.getValue().toString() }
}

View File

@@ -1,7 +1,7 @@
import powershell
class ScriptBlock extends @script_block, Ast {
override string toString() { result = "ScriptBlock at: " + this.getLocation().toString() }
override string toString() { result = this.getLocation().getFile().getBaseName() }
override SourceLocation getLocation() { script_block_location(this, result) }

View File

@@ -2,22 +2,22 @@ arrayExpr
| Arrays.ps1:11:11:11:25 | ArrayExpression at: Arrays.ps1:11:11:11:25 | Arrays.ps1:11:13:11:24 | StatementBlock at: Arrays.ps1:11:13:11:24 |
| Arrays.ps1:14:41:14:44 | ArrayExpression at: Arrays.ps1:14:41:14:44 | Arrays.ps1:0:0:0:0 | StatementBlock at: Arrays.ps1:0:0:0:0 |
arrayLiteral
| Arrays.ps1:1:11:1:37 | ArrayLiteral at: Arrays.ps1:1:11:1:37 | 0 | Arrays.ps1:1:11:1:12 | ConstantExpression at: Arrays.ps1:1:11:1:12 |
| Arrays.ps1:1:11:1:37 | ArrayLiteral at: Arrays.ps1:1:11:1:37 | 1 | Arrays.ps1:1:13:1:14 | ConstantExpression at: Arrays.ps1:1:13:1:14 |
| Arrays.ps1:1:11:1:37 | ArrayLiteral at: Arrays.ps1:1:11:1:37 | 0 | Arrays.ps1:1:11:1:12 | 1 |
| Arrays.ps1:1:11:1:37 | ArrayLiteral at: Arrays.ps1:1:11:1:37 | 1 | Arrays.ps1:1:13:1:14 | 2 |
| Arrays.ps1:1:11:1:37 | ArrayLiteral at: Arrays.ps1:1:11:1:37 | 2 | Arrays.ps1:1:15:1:18 | a |
| Arrays.ps1:1:11:1:37 | ArrayLiteral at: Arrays.ps1:1:11:1:37 | 3 | Arrays.ps1:1:19:1:24 | true |
| Arrays.ps1:1:11:1:37 | ArrayLiteral at: Arrays.ps1:1:11:1:37 | 4 | Arrays.ps1:1:25:1:31 | false |
| Arrays.ps1:1:11:1:37 | ArrayLiteral at: Arrays.ps1:1:11:1:37 | 5 | Arrays.ps1:1:32:1:37 | null |
| Arrays.ps1:5:34:5:37 | ArrayLiteral at: Arrays.ps1:5:34:5:37 | 0 | Arrays.ps1:5:34:5:35 | ConstantExpression at: Arrays.ps1:5:34:5:35 |
| Arrays.ps1:5:34:5:37 | ArrayLiteral at: Arrays.ps1:5:34:5:37 | 1 | Arrays.ps1:5:36:5:37 | ConstantExpression at: Arrays.ps1:5:36:5:37 |
| Arrays.ps1:6:9:6:12 | ArrayLiteral at: Arrays.ps1:6:9:6:12 | 0 | Arrays.ps1:6:9:6:10 | ConstantExpression at: Arrays.ps1:6:9:6:10 |
| Arrays.ps1:6:9:6:12 | ArrayLiteral at: Arrays.ps1:6:9:6:12 | 1 | Arrays.ps1:6:11:6:12 | ConstantExpression at: Arrays.ps1:6:11:6:12 |
| Arrays.ps1:7:9:7:12 | ArrayLiteral at: Arrays.ps1:7:9:7:12 | 0 | Arrays.ps1:7:9:7:10 | ConstantExpression at: Arrays.ps1:7:9:7:10 |
| Arrays.ps1:7:9:7:12 | ArrayLiteral at: Arrays.ps1:7:9:7:12 | 1 | Arrays.ps1:7:11:7:12 | ConstantExpression at: Arrays.ps1:7:11:7:12 |
| Arrays.ps1:8:9:8:12 | ArrayLiteral at: Arrays.ps1:8:9:8:12 | 0 | Arrays.ps1:8:9:8:10 | ConstantExpression at: Arrays.ps1:8:9:8:10 |
| Arrays.ps1:8:9:8:12 | ArrayLiteral at: Arrays.ps1:8:9:8:12 | 1 | Arrays.ps1:8:11:8:12 | ConstantExpression at: Arrays.ps1:8:11:8:12 |
| Arrays.ps1:9:9:9:12 | ArrayLiteral at: Arrays.ps1:9:9:9:12 | 0 | Arrays.ps1:9:9:9:10 | ConstantExpression at: Arrays.ps1:9:9:9:10 |
| Arrays.ps1:9:9:9:12 | ArrayLiteral at: Arrays.ps1:9:9:9:12 | 1 | Arrays.ps1:9:11:9:12 | ConstantExpression at: Arrays.ps1:9:11:9:12 |
| Arrays.ps1:5:34:5:37 | ArrayLiteral at: Arrays.ps1:5:34:5:37 | 0 | Arrays.ps1:5:34:5:35 | 2 |
| Arrays.ps1:5:34:5:37 | ArrayLiteral at: Arrays.ps1:5:34:5:37 | 1 | Arrays.ps1:5:36:5:37 | 2 |
| Arrays.ps1:6:9:6:12 | ArrayLiteral at: Arrays.ps1:6:9:6:12 | 0 | Arrays.ps1:6:9:6:10 | 0 |
| Arrays.ps1:6:9:6:12 | ArrayLiteral at: Arrays.ps1:6:9:6:12 | 1 | Arrays.ps1:6:11:6:12 | 0 |
| Arrays.ps1:7:9:7:12 | ArrayLiteral at: Arrays.ps1:7:9:7:12 | 0 | Arrays.ps1:7:9:7:10 | 1 |
| Arrays.ps1:7:9:7:12 | ArrayLiteral at: Arrays.ps1:7:9:7:12 | 1 | Arrays.ps1:7:11:7:12 | 0 |
| Arrays.ps1:8:9:8:12 | ArrayLiteral at: Arrays.ps1:8:9:8:12 | 0 | Arrays.ps1:8:9:8:10 | 0 |
| Arrays.ps1:8:9:8:12 | ArrayLiteral at: Arrays.ps1:8:9:8:12 | 1 | Arrays.ps1:8:11:8:12 | 1 |
| Arrays.ps1:9:9:9:12 | ArrayLiteral at: Arrays.ps1:9:9:9:12 | 0 | Arrays.ps1:9:9:9:10 | 1 |
| Arrays.ps1:9:9:9:12 | ArrayLiteral at: Arrays.ps1:9:9:9:12 | 1 | Arrays.ps1:9:11:9:12 | 1 |
| Arrays.ps1:11:13:11:24 | ArrayLiteral at: Arrays.ps1:11:13:11:24 | 0 | Arrays.ps1:11:13:11:16 | a |
| Arrays.ps1:11:13:11:24 | ArrayLiteral at: Arrays.ps1:11:13:11:24 | 1 | Arrays.ps1:11:17:11:20 | b |
| Arrays.ps1:11:13:11:24 | ArrayLiteral at: Arrays.ps1:11:13:11:24 | 2 | Arrays.ps1:11:21:11:24 | c |

View File

@@ -1,19 +1,19 @@
binaryExpr
| BinaryExpression.ps1:3:11:3:24 | ...+... | BinaryExpression.ps1:3:11:3:16 | val1 | BinaryExpression.ps1:3:19:3:24 | val2 |
| TernaryExpression.ps1:1:9:1:16 | ...+... | TernaryExpression.ps1:1:9:1:10 | ConstantExpression at: TernaryExpression.ps1:1:9:1:10 | TernaryExpression.ps1:1:15:1:16 | ConstantExpression at: TernaryExpression.ps1:1:15:1:16 |
| TernaryExpression.ps1:1:9:1:16 | ...+... | TernaryExpression.ps1:1:9:1:10 | 6 | TernaryExpression.ps1:1:15:1:16 | 7 |
cmdExpr
| BinaryExpression.ps1:1:9:1:10 | CommandExpression at: BinaryExpression.ps1:1:9:1:10 | BinaryExpression.ps1:1:9:1:10 | ConstantExpression at: BinaryExpression.ps1:1:9:1:10 |
| BinaryExpression.ps1:2:9:2:10 | CommandExpression at: BinaryExpression.ps1:2:9:2:10 | BinaryExpression.ps1:2:9:2:10 | ConstantExpression at: BinaryExpression.ps1:2:9:2:10 |
| BinaryExpression.ps1:3:11:3:24 | CommandExpression at: BinaryExpression.ps1:3:11:3:24 | BinaryExpression.ps1:3:11:3:24 | ...+... |
| BinaryExpression.ps1:4:1:4:8 | CommandExpression at: BinaryExpression.ps1:4:1:4:8 | BinaryExpression.ps1:4:1:4:8 | result |
| ExpandableString.ps1:1:1:1:40 | CommandExpression at: ExpandableString.ps1:1:1:1:40 | ExpandableString.ps1:1:1:1:40 | ExpandableStringExpression at: ExpandableString.ps1:1:1:1:40 |
| ExpandableString.ps1:1:23:1:38 | CommandExpression at: ExpandableString.ps1:1:23:1:38 | file://:0:0:0:0 | (no string representation) |
| SubExpression.ps1:1:1:1:24 | CommandExpression at: SubExpression.ps1:1:1:1:24 | SubExpression.ps1:1:1:1:24 | ArrayExpression at: SubExpression.ps1:1:1:1:24 |
| SubExpression.ps1:2:1:2:22 | CommandExpression at: SubExpression.ps1:2:1:2:22 | SubExpression.ps1:2:1:2:22 | ArrayExpression at: SubExpression.ps1:2:1:2:22 |
| TernaryExpression.ps1:1:8:1:23 | CommandExpression at: TernaryExpression.ps1:1:8:1:23 | TernaryExpression.ps1:1:8:1:23 | ...?...:... |
| TernaryExpression.ps1:1:9:1:16 | CommandExpression at: TernaryExpression.ps1:1:9:1:16 | TernaryExpression.ps1:1:9:1:16 | ...+... |
| BinaryExpression.ps1:1:9:1:10 | 1 | BinaryExpression.ps1:1:9:1:10 | 1 |
| BinaryExpression.ps1:2:9:2:10 | 2 | BinaryExpression.ps1:2:9:2:10 | 2 |
| BinaryExpression.ps1:3:11:3:24 | ...+... | BinaryExpression.ps1:3:11:3:24 | ...+... |
| BinaryExpression.ps1:4:1:4:8 | result | BinaryExpression.ps1:4:1:4:8 | result |
| ExpandableString.ps1:1:1:1:40 | ExpandableStringExpression at: ExpandableString.ps1:1:1:1:40 | ExpandableString.ps1:1:1:1:40 | ExpandableStringExpression at: ExpandableString.ps1:1:1:1:40 |
| ExpandableString.ps1:1:23:1:38 | (no string representation) | file://:0:0:0:0 | (no string representation) |
| SubExpression.ps1:1:1:1:24 | ArrayExpression at: SubExpression.ps1:1:1:1:24 | SubExpression.ps1:1:1:1:24 | ArrayExpression at: SubExpression.ps1:1:1:1:24 |
| SubExpression.ps1:2:1:2:22 | ArrayExpression at: SubExpression.ps1:2:1:2:22 | SubExpression.ps1:2:1:2:22 | ArrayExpression at: SubExpression.ps1:2:1:2:22 |
| TernaryExpression.ps1:1:8:1:23 | ...?...:... | TernaryExpression.ps1:1:8:1:23 | ...?...:... |
| TernaryExpression.ps1:1:9:1:16 | ...+... | TernaryExpression.ps1:1:9:1:16 | ...+... |
invokeMemoryExpression
| SubExpression.ps1:1:1:1:24 | ArrayExpression at: SubExpression.ps1:1:1:1:24 | file://:0:0:0:0 | (no string representation) | 0 | SubExpression.ps1:1:21:1:23 | ConstantExpression at: SubExpression.ps1:1:21:1:23 |
| SubExpression.ps1:1:1:1:24 | ArrayExpression at: SubExpression.ps1:1:1:1:24 | file://:0:0:0:0 | (no string representation) | 0 | SubExpression.ps1:1:21:1:23 | 10 |
expandableString
| ExpandableString.ps1:1:1:1:40 | ExpandableStringExpression at: ExpandableString.ps1:1:1:1:40 | 0 | ExpandableString.ps1:1:8:1:13 | name |
| ExpandableString.ps1:1:1:1:40 | ExpandableStringExpression at: ExpandableString.ps1:1:1:1:40 | 1 | file://:0:0:0:0 | (no string representation) |

View File

@@ -6,7 +6,7 @@ query predicate binaryExpr(BinaryExpr e, Expr e1, Expr e2) {
}
query predicate cmdExpr(CmdExpr cmd, Expr e) {
e = cmd.getExpression()
e = cmd.getExpr()
}
query predicate invokeMemoryExpression(InvokeMemberExpression invoke, Expr e, int i, Expr arg) {

View File

@@ -1,38 +1,38 @@
| ExitStatement.ps1:1:1:1:8 | exit ... |
| ExitStatement.ps1:1:6:1:8 | -1 |
| ExitStatement.ps1:1:6:1:8 | ...\|... |
| ExitStatement.ps1:1:6:1:8 | CommandExpression at: ExitStatement.ps1:1:6:1:8 |
| IfStatement.ps1:1:1:1:7 | AssignmentStatement at: IfStatement.ps1:1:1:1:7 |
| IfStatement.ps1:1:6:1:7 | CommandExpression at: IfStatement.ps1:1:6:1:7 |
| IfStatement.ps1:1:1:1:7 | ...=... |
| IfStatement.ps1:1:6:1:7 | 4 |
| IfStatement.ps1:3:1:8:2 | if (...) {...} else {...} |
| IfStatement.ps1:3:5:3:13 | ...+... |
| IfStatement.ps1:3:5:3:13 | ...\|... |
| IfStatement.ps1:3:5:3:13 | CommandExpression at: IfStatement.ps1:3:5:3:13 |
| IfStatement.ps1:4:2:4:36 | ...\|... |
| IfStatement.ps1:4:2:4:36 | CommandExpression at: IfStatement.ps1:4:2:4:36 |
| IfStatement.ps1:4:2:4:36 | ExpandableStringExpression at: IfStatement.ps1:4:2:4:36 |
| IfStatement.ps1:7:2:7:21 | ...\|... |
| IfStatement.ps1:7:2:7:21 | CommandExpression at: IfStatement.ps1:7:2:7:21 |
| IfStatement.ps1:7:2:7:21 | ExpandableStringExpression at: IfStatement.ps1:7:2:7:21 |
| TrapStatement.ps1:1:1:4:2 | FunctionDefinition at: TrapStatement.ps1:1:1:4:2 |
| TrapStatement.ps1:2:5:2:26 | TrapStatement at: TrapStatement.ps1:2:5:2:26 |
| TrapStatement.ps1:2:11:2:25 | ...\|... |
| TrapStatement.ps1:2:11:2:25 | CommandExpression at: TrapStatement.ps1:2:11:2:25 |
| TrapStatement.ps1:2:11:2:25 | Error found. |
| TrapStatement.ps1:3:5:3:19 | ...\|... |
| TrapStatement.ps1:3:5:3:19 | nonsenseString |
| TrapStatement.ps1:6:1:6:9 | ...\|... |
| TrapStatement.ps1:6:1:6:9 | TrapTest |
| Try.ps1:1:1:13:2 | try {...} |
| Try.ps1:2:4:2:95 | AssignmentStatement at: Try.ps1:2:4:2:95 |
| Try.ps1:2:4:2:95 | ...=... |
| Try.ps1:2:17:2:95 | ...\|... |
| Try.ps1:2:17:2:95 | New-Object |
| Try.ps1:2:69:2:94 | ...\|... |
| Try.ps1:2:69:2:94 | CommandExpression at: Try.ps1:2:69:2:94 |
| Try.ps1:2:69:2:94 | ArrayLiteral at: Try.ps1:2:69:2:94 |
| Try.ps1:3:11:3:21 | ...\|... |
| Try.ps1:3:11:3:21 | CommandExpression at: Try.ps1:3:11:3:21 |
| Try.ps1:3:11:3:21 | Exception |
| Try.ps1:6:5:6:64 | ...\|... |
| Try.ps1:6:5:6:64 | CommandExpression at: Try.ps1:6:5:6:64 |
| Try.ps1:6:5:6:64 | Unable to download MyDoc.doc from http://www.contoso.com. |
| Try.ps1:9:5:9:52 | ...\|... |
| Try.ps1:9:5:9:52 | CommandExpression at: Try.ps1:9:5:9:52 |
| Try.ps1:9:5:9:52 | An error occurred that could not be resolved. |
| Try.ps1:12:5:12:37 | ...\|... |
| Try.ps1:12:5:12:37 | CommandExpression at: Try.ps1:12:5:12:37 |
| Try.ps1:12:5:12:37 | The finally block is executed. |
| UseProcessBlockForPipelineCommand.ps1:1:1:11:2 | FunctionDefinition at: UseProcessBlockForPipelineCommand.ps1:1:1:11:2 |
| UseProcessBlockForPipelineCommand.ps1:10:5:10:12 | ...\|... |
| UseProcessBlockForPipelineCommand.ps1:10:5:10:12 | CommandExpression at: UseProcessBlockForPipelineCommand.ps1:10:5:10:12 |
| UseProcessBlockForPipelineCommand.ps1:10:5:10:12 | Number |
| file://:0:0:0:0 | (no string representation) |