Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What is SSA?
This PR adds SSA analysis to Powershell by instantiating the shared SSA (static single-assignment) library which is also used by many of the existing CodeQL-supported languages (at least C#, Ruby, C++, Swift and Java once the draft PR is merged). SSA is the most classic compiler/static analysis representation of code. Basically, code such as:
is converted to something that's equivalent to:
where every single variable is defined exactly once in the source code.
If you are just interested in how SSA is achieved, I suggest only looking at 645db5b. It will be more obvious in a subsequent PR where I add some tests, though.
The commits
This PR contains slightly too many changes than I would like, but at least they're nicely separated into individual commits 😄
parent
extensional. This was discovered during SSA development since I was missing some scopes for various variables.Variables
andParameters
are no longer instances ofAst
, and the AST no longer has a top elements. So that's a bit annoying. If we want to fix this later we can create IPA types (i.e.,newtype
s) for all AST elements like many of the official CodeQL languages do (off the top of my head of I can think of C++, Swift, Ruby having done this in the past)