# 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
        ctorT = instantiate_type(pat, extrinsic(TypeOf, m.ctor))
        fieldTs, dt = match(ctorT, ("TFunc(fs, Ret(dt), _)", tuple2))
        unify_m(dt)
        for arg, fieldT in ezip(m.args, fieldTs):
            in_env(INPAT, fieldT, lambda: _prop_pat(arg))
    else:
        assert False
    add_extrinsic(PendingType, pat, env(INPAT))

def prop_bind(b, target):
    m = match(Bindable.asLocalVar(target))
    if m('Just(v)'):
        return prop_local_var(m.v)
    else:
        return instantiate_type(b, extrinsic(TypeOf, target))

def prop_local_var(v):
    return env(PROPSCOPE).localVars[v]

def prop_lit(lit):
    return ctype(lit_type(lit))

def prop_listlit(es):
    if len(es) == 0:
        return C.TArray(fresh(), AGC())
    else:
        t = prop_expr(es[0])
        isRaw = matches(t, "TPrim(_)")
        for e in es[1:]:
            consume_value_as(t, e)

# 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

        ctorT = instantiate_type(pat, extrinsic(TypeOf, m.ctor))
        fieldTs, dt = match(ctorT, ("TFunc(fs, Ret(dt), _)", tuple2))
        unify_m(dt)
        for arg, fieldT in ezip(m.args, fieldTs):
            in_env(INPAT, fieldT, lambda: _prop_pat(arg))
    else:
        assert False
    add_extrinsic(PendingType, pat, env(INPAT))

def prop_bind(b, target):
    m = match(Bindable.asLocalVar(target))
    if m('Just(v)'):
        return prop_local_var(m.v)
    else:
        return instantiate_type(b, extrinsic(TypeOf, target))

def prop_local_var(v):
    return env(PROPSCOPE).localVars[v]

def prop_lit(lit):
    return ctype(lit_type(lit))

def prop_listlit(es):
    if len(es) == 0:
        return C.TArray(fresh(), AGC())
    else:
        t = prop_expr(es[0])
        isRaw = matches(t, "TPrim(_)")
        for e in es[1:]:
            consume_value_as(t, e)

        return C.TArray(t, ARaw() if isRaw else AGC())