@@ -57,10 +57,8 @@ for `State.LoadTextExternal` for more information. Keep in mind that due to limi
5757is not reentrant! If you need concurrency support it would be better to use ` State.LoadBinary ` and write your own wrapper.
5858
5959The default compiler provided by this library does not support constant folding, and some special instructions are not
60- used at all (instead preferring simpler sequences of other instructions). For example TESTSET is never generated, TEST
61- is used in all cases (largely because it would greatly complicate the compiler if I tried to use TESTSET where possible).
62- Expressions use a simple "recursive" code generation style, meaning that it wastes registers like crazy in some (rare)
63- cases.
60+ used at all (instead preferring simpler sequences of other instructions). Expressions use a simple "recursive" code
61+ generation style, meaning that it wastes registers like crazy in some (rare) cases.
6462
6563One of the biggest code quality offenders is ` or ` and ` and ` , as they can result in sequences like this one:
6664
@@ -84,6 +82,11 @@ But the current expression compiler is not smart enough to do it that way. Lucki
8482things produce code that is very close or identical to what ` luac ` produces. Note that the reason why this code is so
8583bad is entirely because the expression used ` or ` (and the implementation of ` and ` and ` or ` is very bad).
8684
85+ To my knowledge there is only one case where my compiler does a better job than ` luac ` , namely when compiling loops or
86+ conditionals with constant conditions, impossible conditions are elided (so if you say ` while false do x(y z) end ` the
87+ compiler will do nothing). AFAIK there is no way to jump into such blocks anyway, so eliding them should have no effect
88+ on the correctness of the program.
89+
8790The compiler provides an implementation of a ` continue ` keyword, but the keyword definition in the lexer is commented
8891out. If you want ` continue ` all you need to do is uncomment the indicated line (near the top of ` ast/lexer.go ` ). There
8992is also a flag in the VM that * should* make tables use 0 based indexing. This feature has received minimal testing, so
@@ -113,6 +116,7 @@ The following standard functions/variables are not available:
113116* ` string.packsize ` (too lazy to implement, ask if you need it)
114117* ` string.unpack ` (too lazy to implement, ask if you need it)
115118
119+
116120* * *
117121
118122The following standard modules are not available:
@@ -126,6 +130,7 @@ The following standard modules are not available:
126130Coroutine support is not available. I can implement something based on goroutines fairly easily, but I will only do so
127131if someone actually needs it and/or if I get really bored...
128132
133+
129134* * *
130135
131136In addition to the stuff that is not available at all the following functions are not implemented exactly as the Lua
@@ -146,6 +151,12 @@ Lua implementation does not follow the specification exactly:
146151* The ` # ` (length) operator always returns the exact length of a (table) sequence, not the total length of the array
147152 portion of the table. See the comment in ` table.go ` (about halfway down) for more details (including quotes from the
148153 spec and examples).
154+ * The reference Lua compiler/VM does some really weird things with the modulo operator. For example: ` -3 % 5 == 2 ` Every
155+ other calculator or programming language I chose to feed this to reported: ` -3 % 5 == -3 ` (but ` 5 % -3 == 2 ` , so it
156+ seems like Lua reverses the operands?). It seems Lua only reports weird results when one of the operands is negative?
157+ There is nothing in the spec that implies this is correct behavior, so I am guessing that it is simply a bug. Needless
158+ to say I simply use the Go modulus operator (so I get the correct result rather than the weird one Lua gets).
159+
149160
150161* * *
151162
@@ -186,6 +197,7 @@ The list is (roughly) in priority order.
186197* Write more tests for the compiler and VM.
187198* (supermeta) Allow using byte slices as strings and vice-versa. Maybe attach a method to byte slices that allows conversion
188199 back and forth? (this would probably be fairly easy to do)
200+ * Do the same with rune slices?
189201* Write better stack traces for errors.
190202* Improve compilation of ` and ` and ` or ` .
191203* Fix jumping to a label at the end of a block.
@@ -208,7 +220,24 @@ regard to "commit noise". This means that a new release will often have changes
208220noise, each change listed here will list the files I modified for that change.
209221
210222(please don't bug me about using version control, I * do* use version control. I just use a custom type designed for
211- single person teams where the only important use is rolling back bad changes and such)
223+ single person teams, where the only important use is rolling back bad changes and such)
224+
225+
226+ * * *
227+
228+ 1.1.1
229+
230+ More script tests, more compiler bugs fixed. Same song, different verse.
231+
232+ * Added another set of script tests. (script_test.go)
233+ * Fixed unary operators after a power operator, for example ` 2 ^ - -2 ` . To fix this issue I totally rewrote how operators
234+ are parsed. (ast/parse_expr.go)
235+ * Fixed semicolons immediately after a return statement. (ast/parse.go)
236+ * Fixed an improper optimization or repeat-until loops. Basically if the loop had a constant for the loop condition its
237+ sense was being reversed (so a false condition resulted in the loop being compiled as a simple block, and a true condition
238+ resulted in an infinite loop). (compile.go)
239+ * Fixed ` and ` in non-boolean contexts. Also ` and ` and ` or ` * may* produce slightly better code now. (compile_expr.go)
240+
212241
213242* * *
214243
@@ -219,8 +248,8 @@ earlier work for one of my many toy languages. This new API is kinda cool, but i
219248Basically it is intended for quick projects and temporarily exposing data to scripts. It was fun to write, and so even
220249if no one uses it, it has served its purpose : P
221250
222- I really should have been working on more script tests, but this was more fun... Anyway, I have no doubt responsibility
223- will reassert itself soon.. .
251+ I really should have been working on more script tests, but this was more fun... I have no doubt responsibility will
252+ reassert itself soon.
224253
225254Anyway, I also added two new convenience methods for table iteration, as well as some minor changes to the old one (you
226255can still use it, but it is now a thin wrapper over one of the new functions, so you shouldn't).
@@ -247,6 +276,7 @@ can still use it, but it is now a thin wrapper over one of the new functions, so
247276 access internal APIs (stupid circular imports). (script_test.go)
248277* Clarified what API functions may panic, I think I got them all... (api.go)
249278
279+
250280* * *
251281
2522821.0.2
@@ -275,6 +305,7 @@ Oh, and `pcall` works now (it didn't work at all before. Sorry, I never used it)
275305 behavior that arises when a function stores a closure to an unclosed upvalue then errors out (the closure may still be
276306 referenced, but it's upvalues may be invalid). (api.go, callframe.go)
277307
308+
278309* * *
279310
2803111.0.1
0 commit comments