Repository navigation
Commit 9f3c81d
committed
compiler: Print an Array initializer through the ordinary printer path
An Array initializer already reached the printer, via `ccode` on a
`ListInitializer`; what it did not do was reach it at the Array's own
precision. The elements were printed with the Operator's settings, so a
narrow Array sitting in an Operator whose arithmetic is left at the
default width had its entries emitted at the wider type.
Pass the Array's dtype to `ccode`, as `Expression` already does, rather
than route the initializer around the printer through an `initvalue`
hook of its own. A target that needs to spell its literals differently
overrides `_print_ListInitializer`, which is the ordinary extension
point.
With the precision now correct at the point of printing, `_prec` no
longer needs to be told whether the arithmetic was narrowed on purpose:
a real literal takes the precision it is being printed at, and the
`float32` floor applies only where that is not itself a float. That is
the same value as before for every dtype other than `float16`.1 parent 9759188 commit 9f3c81d
3 files changed
Lines changed: 17 additions & 40 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
186 | 186 | | |
187 | 187 | | |
188 | 188 | | |
189 | | - | |
190 | | - | |
191 | | - | |
192 | | - | |
193 | | - | |
194 | | - | |
195 | | - | |
196 | | - | |
197 | 189 | | |
198 | 190 | | |
199 | 191 | | |
| |||
210 | 202 | | |
211 | 203 | | |
212 | 204 | | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
213 | 213 | | |
214 | 214 | | |
215 | 215 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
43 | 43 | | |
44 | 44 | | |
45 | 45 | | |
46 | | - | |
47 | | - | |
48 | | - | |
49 | | - | |
50 | | - | |
51 | | - | |
52 | 46 | | |
53 | 47 | | |
54 | 48 | | |
| |||
86 | 80 | | |
87 | 81 | | |
88 | 82 | | |
89 | | - | |
90 | | - | |
91 | | - | |
92 | | - | |
93 | | - | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
94 | 88 | | |
95 | 89 | | |
96 | 90 | | |
| |||
386 | 380 | | |
387 | 381 | | |
388 | 382 | | |
389 | | - | |
390 | | - | |
391 | | - | |
392 | | - | |
393 | | - | |
394 | | - | |
395 | | - | |
396 | | - | |
397 | | - | |
398 | | - | |
399 | | - | |
400 | 383 | | |
401 | 384 | | |
402 | 385 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
360 | 360 | | |
361 | 361 | | |
362 | 362 | | |
363 | | - | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
364 | 367 | | |
365 | 368 | | |
366 | 369 | | |
367 | 370 | | |
368 | 371 | | |
369 | | - | |
370 | | - | |
371 | | - | |
372 | | - | |
373 | | - | |
374 | | - | |
375 | | - | |
376 | | - | |
377 | | - | |
378 | 372 | | |
379 | 373 | | |
380 | 374 | | |
| |||
0 commit comments