C#: Refactor recursive patterns implementation

- Extract names of properties in a propery match, using the `exprorstmt_name` relation.
- Simplify extraction of properties by not distinguishing between top-level patterns
  and nested patterns.
- Introduce `PatternExpr` to capture patterns in `is` expressions, `case` statements,
  and `switch` expression arms.
- Generalize `IsTypeExpr`, `IsPatternExpr`, `IsRecursivePatternExpr`, and `IsConstantExpr`
  to just `IsExpr` with a member predicate `PatternExpr getPattern()`.
- Generalize `TypeCase`, `RecursivePatternCase`, and `ConstCase` to just `CaseStmt` with
  a member predicate `PatternExpr getPattern()`.
- Introduce classes `Switch` and `Case` as base classes of switch statements/expressions
  and case statements/switch expression arms, respectively.
- Simplify CFG logic using the generalized classes.
- Generalize guards library to cover `switch` expressions tests.
- Generalize data flow library to cover `switch` expression assignments.
This commit is contained in:
Tom Hvitved
2019-05-21 15:26:20 +02:00
committed by Calum Grant
parent b28ad9066f
commit a1e58cedac
60 changed files with 1198 additions and 1307 deletions

View File

@@ -542,7 +542,7 @@ compiler_generated(unique int id: @modifiable_direct ref);
@member = @method | @constructor | @destructor | @field | @property | @event | @operator | @indexer | @type;
@named_exprorstmt = @goto_stmt | @labeled_stmt | @literal_expr;
@named_exprorstmt = @goto_stmt | @labeled_stmt | @expr;
@virtualizable = @method | @property | @indexer | @event;
@@ -806,7 +806,7 @@ case @stmt.kind of
| 26 = @fixed_stmt
| 27 = @label_stmt
| 28 = @catch
| 29 = @case
| 29 = @case_stmt
| 30 = @local_function_stmt
;
@@ -985,6 +985,10 @@ case @expr.kind of
| 118 = @switch_case_expr
;
@switch = @switch_stmt | @switch_expr;
@case = @case_stmt | @switch_case_expr;
@pattern_match = @case | @is_expr;
@integer_literal_expr = @int_literal_expr | @long_literal_expr | @uint_literal_expr | @ulong_literal_expr;
@real_literal_expr = @float_literal_expr | @double_literal_expr | @decimal_literal_expr;
@literal_expr = @bool_literal_expr | @char_literal_expr | @integer_literal_expr | @real_literal_expr