# 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
import vat
            unification_failure(src, dest, "conflicting array kinds")
    elif m("(TFunc(sa, sr, sm), TFunc(da, dr, dm))"):
        try_unite_tuples(src, m.sa, dest, m.da)
        try_unite_results(src, m.sr, dest, m.dr)
        if not metas_equal(m.sm, m.dm):
            unification_failure(src, dest, "conflicting func metas")
    elif m("(TData(a, ats), TData(b, bts))"):
        if m.a is not m.b:
            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")
    else:
        fail("type mismatch")

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

def unify_m(t):
    unify(env(INPAT), t)

def unify_results(src, dest):
    in_env(UNIFYCTXT, (src, dest),
            lambda: try_unite_results(src, src, dest, dest))

def set_type(e, t):
    assert isinstance(t, Type), "%s is not a type" % (t,)

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


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

            unification_failure(src, dest, "conflicting array kinds")
    elif m("(TFunc(sa, sr, sm), TFunc(da, dr, dm))"):
        try_unite_tuples(src, m.sa, dest, m.da)
        try_unite_results(src, m.sr, dest, m.dr)
        if not metas_equal(m.sm, m.dm):
            unification_failure(src, dest, "conflicting func metas")
    elif m("(TData(a, ats), TData(b, bts))"):
        if m.a is not m.b:
            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")
    else:
        fail("type mismatch")

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

def unify_m(t):
    unify(env(INPAT), t)

def unify_results(src, dest):
    in_env(UNIFYCTXT, (src, dest),
            lambda: try_unite_results(src, src, dest, dest))

def set_type(e, t):
    assert isinstance(t, Type), "%s is not a type" % (t,)

    add_extrinsic(TypeOf, e, t)