@@ -211,22 +211,23 @@ func (fc *funcContext) translateStmt(stmt ast.Stmt, label *types.Label) {
211211 iVar := fc .newVariable ("_i" )
212212 fc .Printf ("%s = 0;" , iVar )
213213 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 )
216215 fc .translateLoopingStmt (func () string { return iVar + " < " + refVar + ".size" }, s .Body , func () {
217216 keyVar := fc .newVariable ("_key" )
217+ valueVar := fc .newVariable ("_value" )
218218 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 )
221222 fc .translateStmt (& ast.IfStmt {
222- Cond : fc .newIdent (entryVar + " === undefined" , types .Typ [types .Bool ]),
223+ Cond : fc .newIdent (valueVar + " === undefined" , types .Typ [types .Bool ]),
223224 Body : & ast.BlockStmt {List : []ast.Stmt {& ast.BranchStmt {Tok : token .CONTINUE }}},
224225 }, nil )
225226 if ! isBlank (s .Key ) {
226227 fc .Printf ("%s" , fc .translateAssign (s .Key , fc .newIdent (keyVar , t .Key ()), s .Tok == token .DEFINE ))
227228 }
228229 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 ))
230231 }
231232 }, func () {
232233 fc .Printf ("%s++;" , iVar )
0 commit comments