mirror of
https://github.com/github/codeql.git
synced 2026-05-25 00:27:09 +02:00
PS: Better toString in a couple of classes.
This commit is contained in:
@@ -7,5 +7,5 @@ class ArrayLiteral extends @array_literal, Expr {
|
||||
|
||||
Expr getAnElement() { array_literal_element(this, _, result) }
|
||||
|
||||
override string toString() { result = "ArrayLiteral at: " + this.getLocation().toString() }
|
||||
override string toString() { result = "...,..." }
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import powershell
|
||||
|
||||
class BreakStmt extends GotoStmt, Stmt {
|
||||
class BreakStmt extends GotoStmt, @break_statement {
|
||||
override SourceLocation getLocation() { break_statement_location(this, result) }
|
||||
|
||||
override string toString() { result = "continue" }
|
||||
override string toString() { result = "break" }
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import powershell
|
||||
|
||||
class ContinueStmt extends GotoStmt, Stmt {
|
||||
class ContinueStmt extends GotoStmt, @continue_statement {
|
||||
override SourceLocation getLocation() { continue_statement_location(this, result) }
|
||||
|
||||
override string toString() { result = "continue" }
|
||||
|
||||
@@ -9,6 +9,8 @@ class IfStmt extends @if_statement, Stmt {
|
||||
|
||||
PipelineBase getCondition(int i) { if_statement_clause(this, i, result, _) } // TODO: Change @ast to @pipeline_base in dbscheme
|
||||
|
||||
PipelineBase getACondition() { result = this.getCondition(_) }
|
||||
|
||||
StmtBlock getThen(int i) { if_statement_clause(this, i, _, result) } // TODO: Change @ast to @statement_block in dbscheme
|
||||
|
||||
/** ..., if any. */
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import powershell
|
||||
|
||||
class ParamBlock extends @param_block, Ast {
|
||||
override string toString() { result = "ParamBlock" }
|
||||
override string toString() { result = "param(...)" }
|
||||
|
||||
override SourceLocation getLocation() { param_block_location(this, result) }
|
||||
|
||||
|
||||
@@ -1,11 +1,15 @@
|
||||
import powershell
|
||||
|
||||
class Pipeline extends @pipeline, Chainable {
|
||||
override string toString() { result = "...|..." }
|
||||
override string toString() {
|
||||
if this.getNumberOfComponents() = 1
|
||||
then result = this.getComponent(0).toString()
|
||||
else result = "...|..."
|
||||
}
|
||||
|
||||
override SourceLocation getLocation() { pipeline_location(this, result) }
|
||||
|
||||
int getNumComponents() { pipeline(this, result) }
|
||||
int getNumberOfComponents() { result = count(this.getAComponent()) }
|
||||
|
||||
CmdBase getComponent(int i) { pipeline_component(this, i, result) }
|
||||
|
||||
|
||||
@@ -1,7 +1,13 @@
|
||||
import powershell
|
||||
|
||||
class ScriptBlock extends @script_block, Ast {
|
||||
override string toString() { result = this.getLocation().getFile().getBaseName() }
|
||||
predicate isTopLevel() { not exists(this.getParent()) }
|
||||
|
||||
override string toString() {
|
||||
if this.isTopLevel()
|
||||
then result = this.getLocation().getFile().getBaseName()
|
||||
else result = "{...}"
|
||||
}
|
||||
|
||||
override SourceLocation getLocation() { script_block_location(this, result) }
|
||||
|
||||
|
||||
@@ -15,5 +15,5 @@ class StmtBlock extends @statement_block, Ast {
|
||||
|
||||
TrapStmt getATrapStatement() { result = this.getTrapStatement(_) }
|
||||
|
||||
override string toString() { result = "StatementBlock at: " + this.getLocation().toString() }
|
||||
override string toString() { result = "{...}" }
|
||||
}
|
||||
|
||||
@@ -10,4 +10,14 @@ class ConditionalExpr extends @ternary_expression, Expr {
|
||||
Expr getIfFalse() { ternary_expression(this, _, result, _) }
|
||||
|
||||
Expr getIfTrue() { ternary_expression(this, _, _, result) }
|
||||
|
||||
Expr getBranch(boolean value) {
|
||||
value = true and
|
||||
result = this.getIfTrue()
|
||||
or
|
||||
value = false and
|
||||
result = this.getIfFalse()
|
||||
}
|
||||
|
||||
Expr getABranch() { result = this.getBranch(_) }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user