-
-
Notifications
You must be signed in to change notification settings - Fork 3.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature Discussion: Patterns #2048
Labels
Comments
siegfriedpammer
added
New Feature
Decompiler
The decompiler engine itself
C#
Documentation
labels
Jun 26, 2020
This was referenced Jun 26, 2020
This was referenced Jul 11, 2020
dgrunwald
added a commit
that referenced
this issue
Jul 25, 2020
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
ILAst Pattern Matching
Some IL instructions are classified as "patterns".
Every
match.*
instruction has the following properties:TestedOperand
specifies what gets matched against the pattern.Variable
stores the value ofTestedOperand
(after converting to the matched type, if appropriate).match.*
node, it corresponds to the C#single_variable_designation
.StackType.I4
: 1 if the pattern was matched, 0 otherwise.Some
match
instructions have a body withList<ILInstruction> nestedPatterns
. Here every nested pattern must be a pattern according toIsPattern()
, and thetestedOperand
of each must be a member of theVariable
of the parent pattern. (members are: field, property, or deconstruction.result).(exception:
match.and
/match.or
, these instead require thetestedOperand
to be exactly theVariable
of the parent pattern)Examples
expr is var x
=>
match.var(x = expr)
=>
expr is T x
=>
match.type T(x = expr) {}
=>
expr is C { A: var x } z
=>
=>
expr is C { A: var x, B: 42, C: { A: 4 } } z
=>
=>
expr is C(var x, var y, <4) { ... }
=>
expr is C(1, D(2, 3))
=>
x is >= 0 and var y and <= 100
x is not C _
=>
expr is (var a, var b)
(when expr is object)=>
expr is (var a, var b)
(when expr is ValueTuple<int, int>)=>
The text was updated successfully, but these errors were encountered: