Skip to content

Commit b426c1f

Browse files
committed
PS: Make top level a function as well.
1 parent 56c703e commit b426c1f

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

powershell/ql/lib/semmle/code/powershell/Function.qll

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,8 @@ abstract private class AbstractFunction extends Ast {
6969
EntryBasicBlock getEntryBasicBlock() { result.getScope() = this.getBody() }
7070
}
7171

72+
final class Function = AbstractFunction;
73+
7274
/**
7375
* A function definition.
7476
*/
@@ -114,4 +116,12 @@ class Constructor extends Method {
114116
Constructor() { this.isConstructor() }
115117
}
116118

117-
final class Function = FunctionBase;
119+
class TopLevel extends AbstractFunction instanceof TopLevelScriptBlock {
120+
final override string getName() { result = "toplevel" }
121+
122+
final override ScriptBlock getBody() { result = this }
123+
124+
final override Parameter getFunctionParameter(int i) { none() }
125+
126+
final override Type getDeclaringType() { none() }
127+
}

0 commit comments

Comments
 (0)