Move ReturningStmt::getValue implementation to internal library

This commit is contained in:
Arthur Baars
2021-02-09 14:01:08 +01:00
parent e398837bdc
commit daa7bd7fd4
2 changed files with 11 additions and 10 deletions

View File

@@ -2,7 +2,6 @@ private import codeql_ruby.AST
private import codeql_ruby.CFG
private import internal.Statement
private import codeql_ruby.controlflow.internal.ControlFlowGraphImpl
private import codeql_ruby.ast.internal.TreeSitter
/**
* A statement.
@@ -42,15 +41,7 @@ class ReturningStmt extends Stmt {
final override string toString() { result = range.toString() }
/** Gets the returned value, if any. */
final Expr getValue() {
exists(Generated::ArgumentList a, int c |
a = range.getArgumentList() and c = count(a.getChild(_))
|
result = a.getChild(0) and c = 1
or
result = a and c > 1
)
}
final Expr getValue() { result = range.getValue() }
}
/**

View File

@@ -8,6 +8,16 @@ module Stmt {
module ReturningStmt {
abstract class Range extends Stmt::Range {
abstract Generated::ArgumentList getArgumentList();
final Expr getValue() {
exists(Generated::ArgumentList a, int c |
a = this.getArgumentList() and c = count(a.getChild(_))
|
result = a.getChild(0) and c = 1
or
result = a and c > 1
)
}
}
}