2018-06-24 | Paul Boddie | file changeset files shortlog | Changed target handling in the invocation code to eliminate superfluous temporary storage for targets and to treat context and target storage separately. Changed access instruction generation to expose the accessor test instructions more readily to the translator, with the error conversion being introduced by the translator. This allows the presence of accessor tests to be considered by the translator and for such tests to be included in generated code where they might otherwise be optimised away. Fixed detection of context temporary variables. Simplified the tracking of target and context temporary usage. |
paul@2 | 1 | def f(): |
paul@2 | 2 | l = [1, 2, 3] |
paul@2 | 3 | x = l |
paul@2 | 4 | a, b, c = l |
paul@2 | 5 | d, e, f = [1, 2, 3] |
paul@243 | 6 | print a, b, c # 1, 2, 3 |
paul@243 | 7 | print d, e, f # 1, 2, 3 |
paul@243 | 8 | print x # [1, 2, 3] |
paul@2 | 9 | |
paul@2 | 10 | def g(x): |
paul@2 | 11 | l = [1, 2, 3] |
paul@2 | 12 | m = [4, l, 6] |
paul@2 | 13 | if x: |
paul@2 | 14 | n = l |
paul@2 | 15 | else: |
paul@2 | 16 | n = m |
paul@173 | 17 | print n |
paul@2 | 18 | |
paul@560 | 19 | def h(): |
paul@560 | 20 | return 7, 8, 9 |
paul@560 | 21 | |
paul@561 | 22 | def i(): |
paul@561 | 23 | a, b, c = h() |
paul@561 | 24 | print a, b, c |
paul@561 | 25 | |
paul@561 | 26 | # Test assignment operations within functions. |
paul@561 | 27 | |
paul@197 | 28 | f() |
paul@243 | 29 | g(0) # [4, [1, 2, 3], 6] |
paul@243 | 30 | g(1) # [1, 2, 3] |
paul@197 | 31 | |
paul@561 | 32 | # Test aliasing, assignment of list elements and direct assignment of elements. |
paul@561 | 33 | |
paul@2 | 34 | l = [1, 2, 3] |
paul@2 | 35 | x = l |
paul@2 | 36 | a, b, c = l |
paul@2 | 37 | d, e, f = [1, 2, 3] |
paul@560 | 38 | |
paul@560 | 39 | print a, b, c # 1 2 3 |
paul@560 | 40 | print d, e, f # 1 2 3 |
paul@243 | 41 | print x # [1, 2, 3] |
paul@560 | 42 | |
paul@561 | 43 | # Test embedding of sequences in sequences. |
paul@561 | 44 | |
paul@2 | 45 | m = [4, l, 6] |
paul@561 | 46 | |
paul@561 | 47 | # Test sequence truth value interpretation. |
paul@561 | 48 | |
paul@2 | 49 | if x: |
paul@2 | 50 | n = l |
paul@2 | 51 | else: |
paul@2 | 52 | n = m |
paul@560 | 53 | |
paul@243 | 54 | print n # [1, 2, 3] |
paul@560 | 55 | |
paul@561 | 56 | # Test temporary variable usage at module level. |
paul@561 | 57 | |
paul@560 | 58 | a, b, c = h() |
paul@560 | 59 | print a, b, c # 7 8 9 |
paul@561 | 60 | |
paul@561 | 61 | # Test temporary variable usage in functions. |
paul@561 | 62 | |
paul@561 | 63 | i() # 7 8 9 |
paul@561 | 64 | |
paul@561 | 65 | # Test temporary variable usage in classes. |
paul@561 | 66 | |
paul@561 | 67 | class C: |
paul@561 | 68 | a, b, c = h() |
paul@561 | 69 | print a, b, c # 7 8 9 |