         
         visitFunctionDeclaration: (n) ->
                 if n.toplevel
-                        super
+                        n.body = @visit n.body
+                        return n
                 else
                         func_exp = n
                         func_exp.type = FunctionExpression

                throw new Error("internal compiler error, only form \"import blah from 'blah'\" supported") if specifiers.length isnt 1
                specifiers[0].id

        generate_export_return = (exported, batch_exported) ->
                exported_getters = []
                for exp in exported
                        exported_getters.push {
                                type: Property,
                                key: exp.name or exp.id,
                                value: {
                                        type: FunctionExpression,
                                        params: [],
                                        body:
                                                type: BlockStatement
                                                body: [
                                                        { type: ReturnStatement, argument: exp.id }
                                                ]
                                },
                                kind: "get"
                        }

                obj_literal = { type: ObjectExpression, properties: exported_getters }

                if batch_exported.length is 0
                        return [ { type: ReturnStatement, argument: obj_literal } ]

                # batch_exported.length > 0, so we need to insert
                # loops over the import tmp id, adding the identifiers
                # to our new export object

                export_id = freshId("export")
                
                ret = [{
                        type: VariableDeclaration,
                        declarations: [{
                                type: VariableDeclarator,
                                id:   export_id,
                                init: obj_literal
                        }],
                        kind: "let"
                }]

                for batch in batch_exported
                        spec_arg = { type: ArrayExpression, elements: batch.specifiers }
                        ret.push { type: ExpressionStatement, expression: create_intrinsic(moduleImportBatch_id, [batch.source, spec_arg, export_id]) }

                ret.push { type: ReturnStatement, argument: export_id }
                ret                
        
        visitFunction: (n) ->
                return n if not n.toplevel
                
                @exports = []
                @batch_exports = []
                n = super
                n.body.body.push exret for exret in generate_export_return(@exports, @batch_exports)
                n
                
        visitImportDeclaration: (n) ->
                if n.specifiers.length is 0
                        # no specifiers, it's of the form:  import from "foo"
                        # don't waste a decl for this type
                        return create_intrinsic(moduleGet_id, [n.source])

                # otherwise create a fresh declaration for the module object
                # 

                        declarations: [{
                                type: VariableDeclarator,
                                id:   import_tmp
                                init: create_intrinsic(moduleGet_id, [n.source_path])
                        }],
                        kind: "let"
                }
