Lichen

tests/chain.py

118:900d641f42d6
2016-10-20 Paul Boddie Added some more support for generating invocation code, distinguishing between static invocation targets that are identified and whose functions can be obtained directly and other kinds of targets whose functions must be obtained via the special attribute.
     1 class C:     2     class D:     3         class E:     4             def m(self, x):     5                 self.x = x     6                 l = self.x.__len__     7                 s = self.o     8                 return self.o.__len__     9             n = 123    10             o = "123"    11     12         p = "456"    13         q = 789    14     15         class F(E):    16             def r(self, y):    17                 s = self.o    18                 C.D.F.t = 234    19                 return self.o.__len__    20             t = 123    21             def u(self):    22                 return self.o    23             def v(self):    24                 return self.u().__len__    25     26 def static():    27     c = C    28     d = C.D    29     e = C.D.E    30     f = C.D.E.m    31     g = C.D.E.n    32     h = C.D.p    33     34 def static_via_constant():    35     i = C.D.p.__len__    36     37 def assign():    38     C.D.q = 987    39     40 def indirect():    41     e = C.D.E    42     inst = e()    43     method = inst.m    44     return method("5")    45     46 def broken():    47     inst2 = C.D.F()    48     l = inst2.u().__len__    49     50 static()    51 static_via_constant()    52 assign()    53 result1 = indirect()    54 broken()    55     56 # Static chains.    57     58 c = C    59 d = C.D    60 e = C.D.E    61 f = C.D.E.m    62 g = C.D.E.n    63 h = C.D.p    64     65 # Static via constant.    66     67 i = C.D.p.__len__    68     69 # Static assignment.    70     71 C.D.q = 987    72     73 # Indirect accesses.    74     75 inst = e()    76 method = inst.m    77 result2 = method("5")    78     79 # Broken chains.    80     81 inst2 = C.D.F()    82 l = inst2.u().__len__