@@ -10,7 +10,7 @@ private import semmle.python.types.Builtins
1010class SpecificInstanceInternal extends TSpecificInstance , ObjectInternal {
1111
1212 override string toString ( ) {
13- result = this .getOrigin ( ) .toString ( )
13+ result = this .getOrigin ( ) .getNode ( ) . toString ( )
1414 }
1515
1616 /** The boolean value of this object, if it has one */
@@ -53,16 +53,17 @@ class SpecificInstanceInternal extends TSpecificInstance, ObjectInternal {
5353 this = TSpecificInstance ( result , _, _)
5454 }
5555
56- /** Holds if `obj` is the result of calling `this` and `origin` is
57- * the origin of `obj`.
58- */
5956 override predicate callResult ( PointsToContext2 callee , ObjectInternal obj , CfgOrigin origin ) {
57+ none ( )
58+ }
59+
60+ override predicate callResult ( ObjectInternal obj , CfgOrigin origin ) {
6061 // In general instances aren't callable, but some are...
6162 // TO DO -- Handle cases where class overrides __call__
6263 none ( )
6364 }
6465
65- override int intValue ( ) {
66+ override int intValue ( ) {
6667 none ( )
6768 }
6869
@@ -96,7 +97,9 @@ class UnknownInstanceInternal extends TUnknownInstance, ObjectInternal {
9697 }
9798
9899 override predicate introduced ( ControlFlowNode node , PointsToContext2 context ) {
99- none ( )
100+ context .appliesTo ( node ) and
101+ this .getClass ( ) = ObjectInternal:: builtin ( "float" ) and
102+ node .getNode ( ) instanceof FloatLiteral
100103 }
101104
102105 /** Gets the class declaration for this object, if it is a declared class. */
@@ -129,10 +132,11 @@ class UnknownInstanceInternal extends TUnknownInstance, ObjectInternal {
129132 none ( )
130133 }
131134
132- /** Holds if `obj` is the result of calling `this` and `origin` is
133- * the origin of `obj`.
134- */
135135 override predicate callResult ( PointsToContext2 callee , ObjectInternal obj , CfgOrigin origin ) {
136+ none ( )
137+ }
138+
139+ override predicate callResult ( ObjectInternal obj , CfgOrigin origin ) {
136140 // In general instances aren't callable, but some are...
137141 // TO DO -- Handle cases where class overrides __call__
138142 none ( )
@@ -157,3 +161,61 @@ class UnknownInstanceInternal extends TUnknownInstance, ObjectInternal {
157161 override predicate attributesUnknown ( ) { any ( ) }
158162
159163}
164+
165+
166+ class SuperInstance extends TSuperInstance , ObjectInternal {
167+
168+ override string toString ( ) {
169+ result = "super()"
170+ }
171+
172+ override boolean booleanValue ( ) { result = true }
173+
174+ override predicate introduced ( ControlFlowNode node , PointsToContext2 context ) {
175+ exists ( ObjectInternal self , ClassObjectInternal startclass |
176+ super_instantiation ( node , self , startclass , context ) and
177+ this = TSuperInstance ( self , startclass )
178+ )
179+ }
180+
181+ ClassObjectInternal getStartClass ( ) {
182+ this = TSuperInstance ( _, result )
183+ }
184+
185+ ObjectInternal getSelf ( ) {
186+ this = TSuperInstance ( result , _)
187+ }
188+
189+ override ClassDecl getClassDeclaration ( ) { none ( ) }
190+
191+ override boolean isClass ( ) { result = false }
192+
193+ override ObjectInternal getClass ( ) { none ( ) }
194+
195+ override boolean isComparable ( ) { none ( ) }
196+
197+ override Builtin getBuiltin ( ) { none ( ) }
198+
199+ override ControlFlowNode getOrigin ( ) {
200+ none ( )
201+ }
202+
203+ override predicate callResult ( ObjectInternal obj , CfgOrigin origin ) { none ( ) }
204+
205+ override predicate callResult ( PointsToContext2 callee , ObjectInternal obj , CfgOrigin origin ) { none ( ) }
206+
207+ override int intValue ( ) { none ( ) }
208+
209+ override string strValue ( ) { none ( ) }
210+
211+ override predicate calleeAndOffset ( Function scope , int paramOffset ) { none ( ) }
212+
213+ override predicate attribute ( string name , ObjectInternal value , CfgOrigin origin ) { none ( ) }
214+
215+ override predicate attributesUnknown ( ) { none ( ) }
216+
217+ }
218+
219+
220+
221+
0 commit comments