Python points-to: More comment clarifications and typo fixes.

This commit is contained in:
Mark Shannon
2019-05-28 17:52:55 +01:00
parent 3adaf07170
commit 77c508f954
4 changed files with 10 additions and 8 deletions

View File

@@ -29,7 +29,7 @@ abstract class ClassObjectInternal extends ObjectInternal {
* @classmethod
* def f(cls): pass
* ```
* `this.lookup("f")` is equivent to `C.__dict__['f']`, which is the class-method
* `this.lookup("f")` is equivalent to `C.__dict__['f']`, which is the class-method
* whereas
* `this.attr("f") is equivalent to `C.f`, which is a bound-method.
*/

View File

@@ -155,6 +155,11 @@ class ClassMethodObjectInternal extends ObjectInternal, TClassMethod {
origin = CfgOrigin::unknown()
}
/** Holds if attribute lookup on this object may "bind" `cls` to `descriptor`.
* `cls` will always be a class as this is a classmethod.
* Here "bind" means that `instance` is passed to the `classmethod.__get__()` method
* at runtime. The term "bind" is used as this most likely results in a bound-method.
*/
pragma [noinline] override predicate binds(ObjectInternal cls, string name, ObjectInternal descriptor) {
descriptor = this.getFunction() and
exists(ObjectInternal instance |

View File

@@ -176,8 +176,10 @@ class PackageObjectInternal extends ModuleObjectInternal, TPackageObject {
exists(Module init |
init = this.getSourceModule() and
(
/* There is no variable shadowing the name of the child module */
not exists(EssaVariable var | var.getAUse() = init.getANormalExit() and var.getSourceVariable().getName() = name)
or
/* The variable shadowing the name of the child module is undefined at exit */
ModuleAttributes::pointsToAtExit(init, name, ObjectInternal::undefined(), _)
) and
not name = "__init__" and

View File

@@ -47,12 +47,7 @@ class Value extends TObject {
/** Gets a call to this object */
CallNode getACall() {
PointsToInternal::pointsTo(result.getFunction(), _, this, _)
or
exists(BoundMethodObjectInternal bm |
PointsToInternal::pointsTo(result.getFunction(), _, bm, _) and
bm.getFunction() = this
)
result = this.getACall(_)
}
/** Gets a call to this object with the given `caller` context. */
@@ -249,7 +244,7 @@ class ClassValue extends Value {
* @classmethod
* def f(cls): pass
* ```
* `this.lookup("f")` is equivent to `C.__dict__['f']`, which is the class-method
* `this.lookup("f")` is equivalent to `C.__dict__['f']`, which is the class-method
* whereas
* `this.attr("f") is equivalent to `C.f`, which is a bound-method.
*/