# Path: globs.py
# WRITTEN_MODULES = {}
# RUNTIME_MODULE_OBJS = {
#     'runtime.py': 'ir/z.o',
#     'gc/interface.py': 'ir/gc_runtime.o',
# }


from atom import *
from base import *
from types_builtin import *
from globs import TypeOf, ResultOf
    opts = t.data.opts
    assert not opts.valueType, "Can't add extr to value-DT %s" % (nodet,)

def check_expr_as(t, e):
    typecheck(extrinsic(TypeOf, e), t)
    in_env(CHECK, t, lambda: in_env(EXPRCTXT, e, lambda: _check_expr(e)))

def check_expr_as_itself(e):
    t = extrinsic(TypeOf, e)
    in_env(CHECK, t, lambda: in_env(EXPRCTXT, e, lambda: _check_expr(e)))
    return t

def check_same(e):
    typecheck(extrinsic(TypeOf, e), env(CHECK))
    in_env(EXPRCTXT, e, lambda: _check_expr(e))

def _check_expr(e):
    match(e,
        ("Lit(lit)", lambda lit: check(lit_type(lit))),
        ("e==Call(f, args)", check_call),
        ("TupleLit(es)", check_tuplelit),
        ("ListLit(es)", check_listlit),
        ("And(l, r) or Or(l, r)", check_logic),
        ("Ternary(c, t, f)", check_ternary),
        ("e==FuncExpr(f)", check_func),
        ("m==Match(p, cs)", check_match),
        ("Attr(e, f==Field(ft))", check_attr),
        ("GetEnv(Env(t))", check),
        ("HaveEnv(_)", lambda: check(TBool())),
        ("InEnv(environ, init, f)", check_inenv),

# Path: globs.py
# WRITTEN_MODULES = {}
# RUNTIME_MODULE_OBJS = {
#     'runtime.py': 'ir/z.o',
#     'gc/interface.py': 'ir/gc_runtime.o',
# }


# Path: check.py
from atom import *
from base import *
from types_builtin import *
from globs import TypeOf, ResultOf

    opts = t.data.opts
    assert not opts.valueType, "Can't add extr to value-DT %s" % (nodet,)

def check_expr_as(t, e):
    typecheck(extrinsic(TypeOf, e), t)
    in_env(CHECK, t, lambda: in_env(EXPRCTXT, e, lambda: _check_expr(e)))

def check_expr_as_itself(e):
    t = extrinsic(TypeOf, e)
    in_env(CHECK, t, lambda: in_env(EXPRCTXT, e, lambda: _check_expr(e)))
    return t

def check_same(e):
    typecheck(extrinsic(TypeOf, e), env(CHECK))
    in_env(EXPRCTXT, e, lambda: _check_expr(e))

def _check_expr(e):
    match(e,
        ("Lit(lit)", lambda lit: check(lit_type(lit))),
        ("e==Call(f, args)", check_call),
        ("TupleLit(es)", check_tuplelit),
        ("ListLit(es)", check_listlit),
        ("And(l, r) or Or(l, r)", check_logic),
        ("Ternary(c, t, f)", check_ternary),
        ("e==FuncExpr(f)", check_func),
        ("m==Match(p, cs)", check_match),
        ("Attr(e, f==Field(ft))", check_attr),
        ("GetEnv(Env(t))", check),
        ("HaveEnv(_)", lambda: check(TBool())),
        ("InEnv(environ, init, f)", check_inenv),

        ("CreateCtx(Env(t), init)", check_createctx),