flatjs
flatjs copied to clipboard
Support assignment chaining for simd data
Suppose x and y are simd fields and v is some simd datum. Then this does not work:
SELF.x = SELF.y = v
The reason is that this translates as a call to SIMD.type.store(), and that function, unlike most other update functions, does not return its input value.
Various fixes are possible. One can use a level of indirection, eg, a method on FlatJS that stands in for the simd store, but I haven't wanted to incur that cost generally for the corner case and the expander doesn't have enough context to know better. One can introduce a local variable (a little tricky but doable, esp if we outlaw one-liner methods) to hold the value and use a comma operator, eg, (v=(rhs), SIMD.type.store(...,v), v)
; the optimizer will likely clean that up OK.