PaulBernier / castl

JavaScript to Lua compiler with runtime library.
GNU Lesser General Public License v3.0
372 stars 33 forks source link

Fallback to functions _get and _set if types are unknown #17

Open daurnimator opened 7 years ago

daurnimator commented 7 years ago

Indexing and indexed assignment have slightly different semantics in JS vs Lua. This will also help with #3.

Instead of compiling a = foo.bar to a = foo.bar, it should instead compile to a = _get(foo, "bar").

I had an attempt at this locally, and got it working for indexing and for method calls, but not for assignment; i.e. for a.b = c I got _get(a, "b") = c which is invalid lua code. I think getting this right will require changes to all the compile{Assignment,Update}Expression* functions