refactor: remove dedicated CODE_LIST bytecode in favor of new List instantiation with .add() calls

Eliminate the LIST opcode and its interpreter case, debug printing, and enum entry. Instead compile list literals by loading the List class, calling its constructor, then emitting DUP, element expression, CALL_1 for add(), and POP for each element. This removes interpreter loop code and lifts the previous 255-element limit on list literals.
This commit is contained in:
Bob Nystrom
2015-01-26 06:49:30 +00:00
parent a0fc04a2a9
commit bee26d2ab2
6 changed files with 27 additions and 45 deletions
+2 -2
View File
@@ -1,6 +1,6 @@
class Sequence {
map(f) {
var result = []
var result = new List
for (element in this) {
result.add(f.call(element))
}
@@ -8,7 +8,7 @@ class Sequence {
}
where(f) {
var result = []
var result = new List
for (element in this) {
if (f.call(element)) result.add(element)
}