Python: adapt to new shared CFG signature

Main added two new requirements to AstSig:
- A 'Parameter' class with a 'getDefaultValue()' method, plus a
  'callableGetParameter(Callable, int)' predicate.
- A 'CallableContext' class in InputSig1, replacing the previous
  'CallableBodyPartContext'.

Add stub implementations: 'Parameter' is empty (none()) and
'callableGetParameter' returns nothing, mirroring Java's TODO. Rename
'CallableBodyPartContext = Void' to 'CallableContext = Void' in the
Python Input module.

NewCfg evaluation-order tests still pass at the 22/24 baseline; all
11 shared-CFG consistency queries still report 0 violations on
CPython.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
Copilot
2026-05-05 15:26:20 +00:00
parent 03b8e8fdde
commit 9781ee8d66

View File

@@ -165,6 +165,20 @@ module Ast implements AstSig<Py::Location> {
/** Gets the body of callable `c`. */
AstNode callableGetBody(Callable c) { result = TBlockStmt(c.asScope(), "body") }
/**
* A parameter of a callable.
*
* TODO: Implement in order to include parameters in the CFG.
*/
class Parameter extends AstNode {
Parameter() { none() }
Expr getDefaultValue() { none() }
}
/** Gets the `index`th parameter of callable `c`. */
Parameter callableGetParameter(Callable c, int index) { none() }
/** A statement. */
class Stmt extends AstNode {
Stmt() { this instanceof TStmt or this instanceof TBlockStmt }
@@ -1119,7 +1133,7 @@ private module Input implements InputSig1, InputSig2 {
string toString() { result = "label" }
}
class CallableBodyPartContext = Void;
class CallableContext = Void;
predicate inConditionalContext(Ast::AstNode n, ConditionKind kind) {
kind.isBoolean() and