python: Avoid abstract class in public interface

use construction from Ruby with `ParameterNodeImpl`
This commit is contained in:
yoff
2022-05-16 09:12:06 +00:00
committed by GitHub
parent a7a646960d
commit dac1b6867a
2 changed files with 19 additions and 4 deletions

View File

@@ -651,8 +651,20 @@ class SummaryCall extends DataFlowCall, TSummaryCall {
override Location getLocation() { result = c.getLocation() }
}
/**
* The value of a parameter at function entry, viewed as a node in a data
* flow graph.
*/
abstract class ParameterNodeImpl extends Node {
/**
* Holds if this node is the parameter of callable `c` at the
* (zero-based) index `i`.
*/
abstract predicate isParameterOf(DataFlowCallable c, int i);
}
/** A parameter for a library callable with a flow summary. */
class SummaryParameterNode extends ParameterNode, TSummaryParameterNode {
class SummaryParameterNode extends ParameterNodeImpl, TSummaryParameterNode {
private FlowSummaryImpl::Public::SummarizedCallable sc;
private int pos;

View File

@@ -111,6 +111,8 @@ newtype TNode =
FlowSummaryImpl::Private::summaryParameterNodeRange(c, pos)
}
class TParameterNode = TCfgNode or TSummaryParameterNode;
/** Helper for `Node::getEnclosingCallable`. */
private DataFlowCallable getCallableScope(Scope s) {
result.getScope() = s
@@ -286,15 +288,16 @@ ExprNode exprNode(DataFlowExpr e) { result.getNode().getNode() = e }
* The value of a parameter at function entry, viewed as a node in a data
* flow graph.
*/
abstract class ParameterNode extends Node {
class ParameterNode extends Node, TParameterNode instanceof ParameterNodeImpl {
/**
* Holds if this node is the parameter of callable `c` at the
* (zero-based) index `i`.
*/
abstract predicate isParameterOf(DataFlowCallable c, int i);
final predicate isParameterOf(DataFlowCallable c, int i) { super.isParameterOf(c, i) }
}
class SourceParameterNode extends ParameterNode, CfgNode {
/** A parameter node foudn in the source code (not in a summary). */
class SourceParameterNode extends ParameterNodeImpl, CfgNode {
//, LocalSourceNode {
ParameterDefinition def;