# Path: astconv.py
# SCOPE = new_env('SCOPE', ScopeContext)
# OMNI = new_env('OMNI', OmniContext)
# SPECIAL_CASES = {
#     'identity': lambda r: r(0),
#     'tuple2': lambda r: E.TupleLit([r(0), r(1)]),
#     'tuple3': lambda r: E.TupleLit([r(0), r(1), r(2)]),
#     'tuple4': lambda r: E.TupleLit([r(0), r(1), r(2), r(3)]),
#     'tuple5': lambda r: E.TupleLit([r(0), r(1), r(2), r(3), r(4)]),
# }
# def ast_envs():
# def is_top_level():
# def sym_call(path, args):
# def builtin_ref(name):
# def builtin_call(name, args):
# def identifier(obj, name=None, namespace=valueNamespace,
#                permissible_nms=frozenset(), export=False):
# def ident_exists(nm, namespace=valueNamespace):
# def refs_existing(nm, namespace=valueNamespace):
# def check_bind_kind(v):
# def type_ref(nm):
# def destroy_forward_ref(ref):
# def inside_scope(f):
#     def new_scope(*args, **kwargs):
# def make_grammar_decorator(index_only=False):
#     def decorator(key, meta=None):
#         def inserter(f):
#     def dispatch(nd, *args):
# def conv_exprs(elist):
# def conv_type(t, tvars, dt=None):
#     def binop(e, o=op):
#     def unaop(e, s=sym):
# def conv_and(e):
# def unwrap_ast(node):
# def _make_dt(dt_nm, *args, **opts):
# def make_cdecl(nm, t):
# def make_cimport(nm, t):
# def make_adt(*args):
# def make_dt(*args):
# def make_env(nm, t):
# def make_extrinsic(nm, t):
# def refs_symbol(e):
# def conv_get_env(environ):
# def conv_get_env(environ):
# def conv_in_env(environ, val, f):
# def conv_create_ctx(environ, val):
# def conv_free_ctx(environ, ctx):
# def conv_get_extrinsic(ext, e):
# def conv_has_extrinsic(ext, e):
# def conv_add_extrinsic(ext, e, val):
# def conv_update_extrinsic(ext, e, val):
# def conv_scope_extrinsic(ext, f):
# def conv_hint(e, **kwargs):
# def conv_anno(t, e):
# def conv_special(e):
# def replace_refs(mapping, e):
# def extract_ret(b):
# def conv_byneed(f):
# def conv_byneed_rebound(f, bs):
#         def rebind_func(params, b):
# def conv_match_case(code, f):
# def conv_block_match_case(m, test, body):
# def conv_match(*args):
# def conv_match_try(node, bs, asLocalVars):
# def setup_block_match(m, blockMatch):
# def cleanup_block_match():
# def conv_callfunc(e):
# def conv_compare(e):
# def conv_const(e):
# def conv_dict(e):
# def conv_genexpr(e):
# def conv_genexprinner(e):
# def conv_getattr(e):
# def conv_ifexp(e):
# def extract_arglist(s):
# def conv_lambda(e):
# def conv_list(e):
# def conv_listcomp(e):
# def conv_name(e):
# def conv_or(e):
# def conv_slice(e):
# def conv_subscript(e):
# def conv_tuple(e):
# def conv_assert(s):
# def conv_assign(s):
# def conv_top_assign(s):
# def conv_asslist(s):
# def conv_asstuple(s):
# def op_to_aug(op):
# def conv_augassign(s):
# def conv_break(s):
# def conv_continue(s):
# def convert_to_voidexpr(e):
# def conv_discard(s):
# def conv_ass(s):
# def conv_try_reass(s):
# def conv_for(s):
# def conv_from(s):
# def import_module(bundle_mod):
# def conv_function(s):
#     def build():
# def conv_if(s):
# def import_names(nms):
# def conv_import(s):
# def conv_pass(s):
# def conv_printnl(s):
# def ignore_debug_print(s):
# def conv_return(s):
# def conv_stmts(stmts):
# def conv_stmts_noscope(stmts):
# def conv_while(s):
# def setup_builtin_module():
# def convert_file(filename, name, deps):
#     def go():
# def escape(text):


from atom import *
from astconv import AstHint, AstType
import vat
    def t_Expr(self, e):
        with_hint_maybe(e, lambda: self.visit())

    def Bind(self, bind):
        instantiate(bind, bind.target)
        with_hint_maybe(bind, lambda: self.visit())

    def LhsVar(self, lhs):
        instantiate(lhs, lhs.var)

    # Ideally with type info here we would fix fields. Deferred to prop.
    def LhsAttr(self, lhs):
        self.visit()
    def Attr(self, e):
        self.visit()

    def FuncExpr(self, e):
        scan_func(e.func, e)
    def Defn(self, defn):
        if matches(defn, "Defn(PatVar(_), FuncExpr(_))"):
            scan_func(defn.expr.func, defn.pat.var)
        else:
            self.visit()

def scan_func(f, typeDest):
    if not has_extrinsic(AstType, f):
        vat.visit(Scanner, f.body, "Body(Expr)")
        return

    tvars = {}

# Path: astconv.py
# SCOPE = new_env('SCOPE', ScopeContext)
# OMNI = new_env('OMNI', OmniContext)
# SPECIAL_CASES = {
#     'identity': lambda r: r(0),
#     'tuple2': lambda r: E.TupleLit([r(0), r(1)]),
#     'tuple3': lambda r: E.TupleLit([r(0), r(1), r(2)]),
#     'tuple4': lambda r: E.TupleLit([r(0), r(1), r(2), r(3)]),
#     'tuple5': lambda r: E.TupleLit([r(0), r(1), r(2), r(3), r(4)]),
# }
# def ast_envs():
# def is_top_level():
# def sym_call(path, args):
# def builtin_ref(name):
# def builtin_call(name, args):
# def identifier(obj, name=None, namespace=valueNamespace,
#                permissible_nms=frozenset(), export=False):
# def ident_exists(nm, namespace=valueNamespace):
# def refs_existing(nm, namespace=valueNamespace):
# def check_bind_kind(v):
# def type_ref(nm):
# def destroy_forward_ref(ref):
# def inside_scope(f):
#     def new_scope(*args, **kwargs):
# def make_grammar_decorator(index_only=False):
#     def decorator(key, meta=None):
#         def inserter(f):
#     def dispatch(nd, *args):
# def conv_exprs(elist):
# def conv_type(t, tvars, dt=None):
#     def binop(e, o=op):
#     def unaop(e, s=sym):
# def conv_and(e):
# def unwrap_ast(node):
# def _make_dt(dt_nm, *args, **opts):
# def make_cdecl(nm, t):
# def make_cimport(nm, t):
# def make_adt(*args):
# def make_dt(*args):
# def make_env(nm, t):
# def make_extrinsic(nm, t):
# def refs_symbol(e):
# def conv_get_env(environ):
# def conv_get_env(environ):
# def conv_in_env(environ, val, f):
# def conv_create_ctx(environ, val):
# def conv_free_ctx(environ, ctx):
# def conv_get_extrinsic(ext, e):
# def conv_has_extrinsic(ext, e):
# def conv_add_extrinsic(ext, e, val):
# def conv_update_extrinsic(ext, e, val):
# def conv_scope_extrinsic(ext, f):
# def conv_hint(e, **kwargs):
# def conv_anno(t, e):
# def conv_special(e):
# def replace_refs(mapping, e):
# def extract_ret(b):
# def conv_byneed(f):
# def conv_byneed_rebound(f, bs):
#         def rebind_func(params, b):
# def conv_match_case(code, f):
# def conv_block_match_case(m, test, body):
# def conv_match(*args):
# def conv_match_try(node, bs, asLocalVars):
# def setup_block_match(m, blockMatch):
# def cleanup_block_match():
# def conv_callfunc(e):
# def conv_compare(e):
# def conv_const(e):
# def conv_dict(e):
# def conv_genexpr(e):
# def conv_genexprinner(e):
# def conv_getattr(e):
# def conv_ifexp(e):
# def extract_arglist(s):
# def conv_lambda(e):
# def conv_list(e):
# def conv_listcomp(e):
# def conv_name(e):
# def conv_or(e):
# def conv_slice(e):
# def conv_subscript(e):
# def conv_tuple(e):
# def conv_assert(s):
# def conv_assign(s):
# def conv_top_assign(s):
# def conv_asslist(s):
# def conv_asstuple(s):
# def op_to_aug(op):
# def conv_augassign(s):
# def conv_break(s):
# def conv_continue(s):
# def convert_to_voidexpr(e):
# def conv_discard(s):
# def conv_ass(s):
# def conv_try_reass(s):
# def conv_for(s):
# def conv_from(s):
# def import_module(bundle_mod):
# def conv_function(s):
#     def build():
# def conv_if(s):
# def import_names(nms):
# def conv_import(s):
# def conv_pass(s):
# def conv_printnl(s):
# def ignore_debug_print(s):
# def conv_return(s):
# def conv_stmts(stmts):
# def conv_stmts_noscope(stmts):
# def conv_while(s):
# def setup_builtin_module():
# def convert_file(filename, name, deps):
#     def go():
# def escape(text):


# Path: scan.py
from atom import *
from astconv import AstHint, AstType
import vat

    def t_Expr(self, e):
        with_hint_maybe(e, lambda: self.visit())

    def Bind(self, bind):
        instantiate(bind, bind.target)
        with_hint_maybe(bind, lambda: self.visit())

    def LhsVar(self, lhs):
        instantiate(lhs, lhs.var)

    # Ideally with type info here we would fix fields. Deferred to prop.
    def LhsAttr(self, lhs):
        self.visit()
    def Attr(self, e):
        self.visit()

    def FuncExpr(self, e):
        scan_func(e.func, e)
    def Defn(self, defn):
        if matches(defn, "Defn(PatVar(_), FuncExpr(_))"):
            scan_func(defn.expr.func, defn.pat.var)
        else:
            self.visit()

def scan_func(f, typeDest):
    if not has_extrinsic(AstType, f):
        vat.visit(Scanner, f.body, "Body(Expr)")
        return

    tvars = {}

    ftstr = extrinsic(AstType, f)