 syntax = esprima.Syntax
 debug = require 'debug'
 path = require 'path'
-
-#debug.setLevel if __ejs? then 1 else 0
 
 { Set } = require 'set'
 { NodeVisitor } = require 'nodevisitor'


exports.compile = (tree, base_output_filename, source_filename) ->

        console.warn "compiling #{source_filename}"
        
        tree = insert_toplevel_func tree, base_output_filename



        toplevel_name = tree.body[0].id.name
        
        debug.log 1, "before closure conversion"
        debug.log 1, -> escodegen.generate tree
        
        tree = closure_conversion.convert tree, path.basename source_filename

        debug.log 1, "after closure conversion"
        debug.log 1, -> escodegen.generate tree
        
        module = new llvm.Module "compiled-#{base_output_filename}"

        module.toplevel_name = toplevel_name
