                 @function_stack.shift()
                 n
 
+        visitFor: (n) ->
+                @skipExpressionStatement = true
+                init = @visit n.init
+                @skipExpressionStatement = false
+                n.test = @visit n.test
+                n.update = @visit n.update
+                n.body = @visit n.body
+                n
+                        
         visitForIn: (n) ->
                 if n.left.type is syntax.VariableDeclaration
                         @function_stack[0].vars.push

                        assignments = []
                        for i in [0...n.declarations.length]
                                if n.declarations[i].init?
                                        assignments.push
                                                type: syntax.ExpressionStatement
                                                expression:
                                                        type: syntax.AssignmentExpression
                                                        left: create_identifier n.declarations[i].id.name
                                                        right: n.declarations[i].init
                                                        operator: "="

                        # now return the new assignments, which will replace the original variable
                        # declaration node.
                        if assignments.length == 1
                                return assignments[0]

                        return {
                                type: syntax.BlockStatement
                                body: assignments
                        }
                n

# this class really doesn't behave like a normal NodeVisitor, as it modifies the tree in-place

                for decl in n.declarations
                        decl.init = @visit decl.init
                        if @currentMapping().hasOwnProperty decl.id.name
                                assignment =
                                        type: syntax.AssignmentExpression,
                                        operator: "="
                                        left:
                                                type: syntax.CallExpression
                                                callee: create_identifier "%slot"
                                                arguments: [ @currentMapping()["%env"], (create_number_literal @currentMapping()["%slot_mapping"][decl.id.name]) ]
                                        right: decl.init || { type: syntax.Identifier, name: "undefined" }
                                
                                if @skipExpressionStatement
                                        rv.push assignment
                                else
                                        rv.push {
                                                type: syntax.ExpressionStatement
                                                expression: assignment
                                        }
                        else
                                rv.push {
                                        type: syntax.VariableDeclaration
