Swift: Make the RegexEval interface cleaner.

This commit is contained in:
Geoffrey White
2023-06-23 14:33:25 +01:00
parent 987ca61ef5
commit 5cffa59476

View File

@@ -60,18 +60,15 @@ private class ParsedStringRegex extends RegExp, StringLiteralExpr {
* ```
*/
abstract class RegexEval extends CallExpr {
Expr regexInput;
Expr stringInput;
/**
* Gets the input to this call that is the regular expression being evaluated.
*/
Expr getRegexInput() { result = regexInput }
abstract Expr getRegexInput();
/**
* Gets the input to this call that is the string the regular expression is evaluated on.
*/
Expr getStringInput() { result = stringInput }
abstract Expr getStringInput();
/**
* Gets a regular expression value that is evaluated here (if any can be identified).
@@ -83,6 +80,9 @@ abstract class RegexEval extends CallExpr {
* A call to a function that always evaluates a regular expression.
*/
private class AlwaysRegexEval extends RegexEval {
Expr regexInput;
Expr stringInput;
AlwaysRegexEval() {
this.getStaticTarget()
.(Method)
@@ -127,4 +127,8 @@ private class AlwaysRegexEval extends RegexEval {
regexInput = this.getArgument(0).getExpr() and
stringInput = this.getQualifier()
}
override Expr getRegexInput() { result = regexInput }
override Expr getStringInput() { result = stringInput }
}