Add basic support for case guards

This commit is contained in:
Chris Smowton
2023-10-27 17:31:47 +01:00
parent e94c5a772c
commit ba0f3cf718
3 changed files with 66 additions and 28 deletions

View File

@@ -523,6 +523,9 @@ class PatternCase extends SwitchCase {
/** Gets the variable declared by this pattern case. */
LocalVariableDeclExpr getDecl() { result.isNthChildOf(this, 0) }
/** Gets the guard applicable to this pattern case, if any. */
Expr getGuard() { result.isNthChildOf(this, -3) }
override string pp() { result = "case T t ..." }
override string toString() { result = "case T t ..." }