2007-02-25 | paulb | file changeset files shortlog | Introduced instance annotations on program nodes in order to support more complicated class/instance mechanisms, such as the "prolific" multiple instance class introduced here. Changed InvokeBlock plus LoadRef to just InvokeRef, adding subprogram copying in order to avoid specialised copies of methods all sharing the same internal subprograms. Fixed the copying of argument attributes on nodes. Changed list construction to use an internal subprogram, fixing the list initialiser to be like the standard Python list initialiser. Added "re-running" of invocations in order to prevent deep recursion which crashes Python. |
paulb@95 | 1 | class A1: |
paulb@95 | 2 | def __init__(self): |
paulb@95 | 3 | self.b = [] |
paulb@95 | 4 | |
paulb@95 | 5 | class A2: |
paulb@95 | 6 | def b(self): |
paulb@95 | 7 | return A3() |
paulb@95 | 8 | |
paulb@95 | 9 | class A3: |
paulb@95 | 10 | c = [] |
paulb@95 | 11 | |
paulb@95 | 12 | class A4: |
paulb@95 | 13 | def __getslice__(self, start=None, end=None, step=None): |
paulb@95 | 14 | return [] |
paulb@95 | 15 | def __getitem__(self, item): |
paulb@95 | 16 | return self |
paulb@95 | 17 | |
paulb@58 | 18 | a = [1,2,3] |
paulb@58 | 19 | b = [4,5] |
paulb@95 | 20 | c = [6] |
paulb@95 | 21 | d = [] |
paulb@95 | 22 | e = 1 |
paulb@95 | 23 | f = 2 |
paulb@95 | 24 | |
paul@2 | 25 | a += b |
paulb@95 | 26 | |
paulb@180 | 27 | a = A1() # May augment types since this is a global namespace. |
paul@2 | 28 | a.b += c |
paulb@95 | 29 | a.b[e:] += d |
paulb@95 | 30 | |
paulb@95 | 31 | a = A2() |
paul@2 | 32 | a.b().c += d |
paulb@95 | 33 | |
paulb@95 | 34 | a = A4() |
paulb@95 | 35 | a[e:f] += d |
paulb@95 | 36 | a[e] += c |
paulb@95 | 37 | a[e,f] += d |
paulb@180 | 38 | |
paulb@180 | 39 | def f(): |
paulb@180 | 40 | a = [1,2,3] |
paulb@180 | 41 | b = [4,5] |
paulb@180 | 42 | c = [6] |
paulb@180 | 43 | d = [] |
paulb@180 | 44 | e = 1 |
paulb@180 | 45 | f = 2 |
paulb@180 | 46 | |
paulb@180 | 47 | a += b |
paulb@180 | 48 | |
paulb@180 | 49 | a = A1() |
paulb@180 | 50 | a.b += c |
paulb@180 | 51 | a.b[e:] += d |
paulb@180 | 52 | |
paulb@180 | 53 | a = A2() |
paulb@180 | 54 | a.b().c += d |
paulb@180 | 55 | |
paulb@180 | 56 | a = A4() |
paulb@180 | 57 | a[e:f] += d |
paulb@180 | 58 | a[e] += c |
paulb@180 | 59 | a[e,f] += d |
paulb@180 | 60 | |
paulb@180 | 61 | f() |