@@ -211,22 +211,23 @@ func (fc *funcContext) translateStmt(stmt ast.Stmt, label *types.Label) {
211
211
iVar := fc .newVariable ("_i" )
212
212
fc .Printf ("%s = 0;" , iVar )
213
213
keysVar := fc .newVariable ("_keys" )
214
- fc .Printf ("%s = %s ? %s.keys() : [];" , keysVar , refVar , refVar )
215
-
214
+ fc .Printf ("%s = %s ? %s.entries() : [];" , keysVar , refVar , refVar )
216
215
fc .translateLoopingStmt (func () string { return iVar + " < " + refVar + ".size" }, s .Body , func () {
217
216
keyVar := fc .newVariable ("_key" )
217
+ valueVar := fc .newVariable ("_value" )
218
218
entryVar := fc .newVariable ("_entry" )
219
- fc .Printf ("%s = %s.next().value;" , keyVar , keysVar )
220
- fc .Printf ("%s = %s.get(%s);" , entryVar , refVar , keyVar )
219
+ fc .Printf ("%s = %s.next().value;" , entryVar , keysVar )
220
+ fc .Printf ("%s = %s[0];" , keyVar , entryVar )
221
+ fc .Printf ("%s = %s[1];" , valueVar , entryVar )
221
222
fc .translateStmt (& ast.IfStmt {
222
- Cond : fc .newIdent (entryVar + " === undefined" , types .Typ [types .Bool ]),
223
+ Cond : fc .newIdent (valueVar + " === undefined" , types .Typ [types .Bool ]),
223
224
Body : & ast.BlockStmt {List : []ast.Stmt {& ast.BranchStmt {Tok : token .CONTINUE }}},
224
225
}, nil )
225
226
if ! isBlank (s .Key ) {
226
227
fc .Printf ("%s" , fc .translateAssign (s .Key , fc .newIdent (keyVar , t .Key ()), s .Tok == token .DEFINE ))
227
228
}
228
229
if ! isBlank (s .Value ) {
229
- fc .Printf ("%s" , fc .translateAssign (s .Value , fc .newIdent (entryVar , t .Elem ()), s .Tok == token .DEFINE ))
230
+ fc .Printf ("%s" , fc .translateAssign (s .Value , fc .newIdent (valueVar , t .Elem ()), s .Tok == token .DEFINE ))
230
231
}
231
232
}, func () {
232
233
fc .Printf ("%s++;" , iVar )
0 commit comments