# 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
    check(t_DT(Env))
    check_expr_as(t, init)

def check_destroyctx(ctx):
    check_same(ctx)

def check_getextrinsic(t, node):
    check(t)
    check_expr_as_boxed(node)

def check_hasextrinsic(node):
    check(TBool())
    check_expr_as_boxed(node)

def check_expr_as_boxed(e):
    t = check_expr_as_itself(e)
    assert matches(t, "TData(_, _)"), "Can't add extr to %s" % (nodet,)
    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):

# 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

    check(t_DT(Env))
    check_expr_as(t, init)

def check_destroyctx(ctx):
    check_same(ctx)

def check_getextrinsic(t, node):
    check(t)
    check_expr_as_boxed(node)

def check_hasextrinsic(node):
    check(TBool())
    check_expr_as_boxed(node)

def check_expr_as_boxed(e):
    t = check_expr_as_itself(e)
    assert matches(t, "TData(_, _)"), "Can't add extr to %s" % (nodet,)
    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))