git @ Cat's Eye Technologies SixtyPical / cab84b8
Change the serialization format to be (hopefully) clearer. Chris Pressey 3 years ago
2 changed file(s) with 36 addition(s) and 60 deletion(s). Raw diff Collapse all Expand all
7272 if routine.name not in self.fall_out_map:
7373 self.fall_out_map[routine.name] = None
7474
75 routine_list = []
75 roster = []
7676 pending_routines = copy(self.fall_out_map)
7777 while pending_routines:
7878 # Pick a routine that is still pending to be serialized.
8686 chains.sort(key=len, reverse=True)
8787 routines = chains[0]
8888
89 # Remove (r1,r2,...,rn) from R and append them to L in that order.
90 # Mark (r1,r2,...rn-1) as "will have their final goto removed."
89 # Append (r1,r2,...,rn) to the roster and remove r1,r2,...rn from R.
90 # A sublist like this appearing in the roster has meaning
91 # "optimize the final goto out of all but the last routine in the sublist".
9192 for r in routines:
9293 del pending_routines[r]
93 if r == routines[-1]:
94 routine_list.append(['retain', r])
95 else:
96 routine_list.append(['fallthru', r])
94 roster.append(routines)
9795
98 return routine_list
96 return roster
7272 = *** serialization:
7373 = [
7474 = [
75 = "retain",
7675 = "main"
7776 = ]
7877 = ]
9695 = *** serialization:
9796 = [
9897 = [
99 = "fallthru",
100 = "main"
101 = ],
102 = [
103 = "retain",
104 = "foo"
105 = ]
106 = ]
107
108 More than one routine can fall through to a routine.
109
110 If main does a `goto foo`, then it can fall through to `foo`.
98 = "main",
99 = "foo"
100 = ]
101 = ]
102
103 More than one routine can fall through to a routine. We pick one
104 of them to fall through, when selecting the order of routines.
111105
112106 | define foo routine trashes a, z, n
113107 | {
133127 = *** serialization:
134128 = [
135129 = [
136 = "fallthru",
137 = "main"
138 = ],
139 = [
140 = "retain",
141 = "foo"
142 = ],
143 = [
144 = "retain",
130 = "main",
131 = "foo"
132 = ],
133 = [
145134 = "bar"
146135 = ]
147136 = ]
187176 = *** serialization:
188177 = [
189178 = [
190 = "retain",
191 = "main"
192 = ],
193 = [
194 = "fallthru",
195 = "bar"
196 = ],
197 = [
198 = "retain",
179 = "main"
180 = ],
181 = [
182 = "bar",
199183 = "foo"
200184 = ]
201185 = ]
226210 = *** serialization:
227211 = [
228212 = [
229 = "retain",
230 = "main"
231 = ],
232 = [
233 = "retain",
234 = "bar"
235 = ],
236 = [
237 = "retain",
213 = "main"
214 = ],
215 = [
216 = "bar"
217 = ],
218 = [
238219 = "foo"
239220 = ]
240221 = ]
264245 = *** serialization:
265246 = [
266247 = [
267 = "retain",
268 = "main"
269 = ],
270 = [
271 = "retain",
272 = "bar"
273 = ],
274 = [
275 = "retain",
276 = "foo"
277 = ]
278 = ]
248 = "main"
249 = ],
250 = [
251 = "bar"
252 = ],
253 = [
254 = "foo"
255 = ]
256 = ]