Skip to content

Commit 6b2938a

Browse files
committed
Python: Extends new Value API a bit to support callable subclasses and sequences.
1 parent f69ea7f commit 6b2938a

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

python/ql/src/semmle/python/objects/ObjectAPI.qll

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -350,6 +350,46 @@ class ClassValue extends Value {
350350

351351
}
352352

353+
class PythonFunctionValue extends CallableValue {
354+
355+
PythonFunctionValue() {
356+
this instanceof PythonFunctionObjectInternal
357+
}
358+
359+
}
360+
361+
class BuiltinFunctionValue extends CallableValue {
362+
363+
BuiltinFunctionValue() {
364+
this instanceof BuiltinFunctionObjectInternal
365+
}
366+
367+
}
368+
369+
class SequenceValue extends Value {
370+
371+
SequenceValue() {
372+
this instanceof SequenceObjectInternal
373+
}
374+
375+
Value getItem(int n) {
376+
result = this.(SequenceObjectInternal).getItem(n)
377+
}
378+
379+
int length() {
380+
result = this.(SequenceObjectInternal).length()
381+
}
382+
383+
}
384+
385+
class TupleValue extends SequenceValue {
386+
387+
TupleValue() {
388+
this instanceof TupleObjectInternal
389+
}
390+
391+
}
392+
353393
/** A method-resolution-order sequence of classes */
354394
class MRO extends TClassList {
355395

0 commit comments

Comments
 (0)