feat: implement map literal syntax with curly braces and DUP bytecode

Add support for map literals using `{}` syntax in the compiler, replacing the previous `new Map` constructor pattern. This introduces a new `map()` grammar function that loads the Map class, instantiates it, and compiles key-value pairs using subscript setter calls. A new `CODE_DUP` bytecode is added to duplicate the map reference on the stack for each element insertion. The change includes updated test files to use literal syntax and new error tests for edge cases like EOF after colon, comma, key, or value.
This commit is contained in:
Bob Nystrom
2015-01-25 07:21:50 +00:00
parent 5c33ecc04f
commit 2ec0a8aef9
12 changed files with 83 additions and 20 deletions
+2
View File
@@ -0,0 +1,2 @@
var map = {1: 2,
// expect error