Lichen

tests/global_names.py

338:61776a5a0e16
2016-12-07 Paul Boddie Associate constant name information with references so that structure members such as function instance default members can be generated statically, thus eliminating unnecessary structure initialisation in the translated code. Improved the determination of dynamic functions in the importer to consider only non-constant defaults.
     1 class C:     2     x = 3     3      4 def f():     5     x = g.x     6     print x             # 3     7     y = g     8     print y             # __main__.C     9     return y.x    10     11 def i():    12     x = h.x    13     y = h    14     return y    15     16 g = C    17 result = f()    18 print result            # 3    19     20 h = C    21 print i()               # __main__.C    22 print i().x             # 3    23     24 h = C()    25 print i()               # <__main__.C instance>    26 print i().x             # 3