# 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
            unification_failure(src, dest, "mismatched datatypes")
        assert len(m.ats) == len(m.a.tvars), "Wrong %s typevar count" % (m.a,)
        for at, bt in ezip(m.ats, m.bts):
            try_unite(at, bt)
    elif m("(TPrim(sp), TPrim(dp))"):
        if not prim_equal(m.sp, m.dp):
            unification_failure(src, dest, "primitive types")
    elif m("(TWeak(a), TWeak(b))"):
        try_unite(m.a, m.b)
    elif m("(TWeak(a), _)"):
        try_unite(m.a, dest)
    elif m("(_, TWeak(b))"):
        try_unite(src, m.b)
    else:
        fail("type mismatch")

def try_unite_results(t1, a, t2, b):
    m = match((a, b))
    if m("(Ret(at), Ret(bt))"):
        try_unite(m.at, m.bt)
    elif not results_equal(a, b):
        unification_failure(t1, t2, "conflicting result types")

def typecheck(src, dest):
    in_env(UNIFYCTXT, (src, dest), lambda: try_unite(src, dest))

def check(dest):
    typecheck(env(CHECK), dest)

def pat_ctor(pat, ctor, args):

# 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

            unification_failure(src, dest, "mismatched datatypes")
        assert len(m.ats) == len(m.a.tvars), "Wrong %s typevar count" % (m.a,)
        for at, bt in ezip(m.ats, m.bts):
            try_unite(at, bt)
    elif m("(TPrim(sp), TPrim(dp))"):
        if not prim_equal(m.sp, m.dp):
            unification_failure(src, dest, "primitive types")
    elif m("(TWeak(a), TWeak(b))"):
        try_unite(m.a, m.b)
    elif m("(TWeak(a), _)"):
        try_unite(m.a, dest)
    elif m("(_, TWeak(b))"):
        try_unite(src, m.b)
    else:
        fail("type mismatch")

def try_unite_results(t1, a, t2, b):
    m = match((a, b))
    if m("(Ret(at), Ret(bt))"):
        try_unite(m.at, m.bt)
    elif not results_equal(a, b):
        unification_failure(t1, t2, "conflicting result types")

def typecheck(src, dest):
    in_env(UNIFYCTXT, (src, dest), lambda: try_unite(src, dest))

def check(dest):
    typecheck(env(CHECK), dest)

def pat_ctor(pat, ctor, args):

    ctorT = extrinsic(TypeOf, ctor)