pub fn substitute(&mut self, substs: &Substitutions) {
        use semantics::Repr; // FIXME: Blegh - kind of cross-cutting concerns here...

        let subst_ty = match *Rc::make_mut(&mut self.inner) {
            Type::Var(_, Var::Free(ref name)) => match substs.get(name) {
                None => return,
                Some(ty) => ty.clone(),
            },
            Type::HostVar(Var::Free(ref name)) => match substs.get(name) {
                None => return,
                Some(ty) => ty.repr().clone(),
            },
            Type::Var(_, Var::Bound(_)) | Type::HostVar(Var::Bound(_)) | Type::Const(_) => return,
            Type::Arrow(ref mut param_tys, ref mut ret_ty) => {
                for param_ty in param_tys {
                    param_ty.substitute(substs);
                }
                ret_ty.substitute(substs);

                return;
            }
            Type::Lam(_, _, ref mut body_ty) => {
                body_ty.substitute(substs);
                return;
            }
            Type::App(_, ref mut fn_ty, ref mut arg_tys) => {
                fn_ty.substitute(substs);

                for arg_ty in arg_tys {
                    arg_ty.substitute(substs);
                }

                return;
            }

            Type::Array(_, ref mut elem_ty, ref mut size_expr) => {
                elem_ty.substitute(substs);
                size_expr.substitute(substs);
                return;
            }
            Type::Cond(_, ref mut options) => {
                for option in options {
                    option.value.0.substitute(substs);
                    option.value.1.substitute(substs);
                }
                return;
            }
            Type::Struct(_, ref mut fields) => {
                for field in fields.iter_mut() {
                    field.value.substitute(substs);
                }
                return;
            }
            Type::Assert(_, ref mut ty, ref mut pred) => {
                ty.substitute(substs);
                pred.substitute(substs);
                return;
            }
            Type::Interp(_, ref mut ty, ref mut conv, ref mut repr_ty) => {
                ty.substitute(substs);
                conv.substitute(substs);
                repr_ty.substitute(substs);
                return;
            }

            Type::HostArray(ref mut elem_ty) => {
                elem_ty.substitute(substs);
                return;
            }
            Type::HostUnion(ref mut variants) => {
                for variant in variants {
                    variant.value.substitute(substs);
                }
                return;
            }
            Type::HostStruct(ref mut fields) => {
                for field in fields {
                    field.value.substitute(substs);
                }
                return;
            }
        };

        *self = subst_ty.clone();
    }
/// Replace occurrences of the free variables that exist as keys on
/// `substs` with their corresponding types.
Replace occurrences of the free variables that exist as keys on
`substs` with their corresponding types.
Replace occurrences of the free variables that exist as keys on ` substs ` with their corresponding types .
pub fn substitute(&mut self, substs: &Substitutions) {
        use semantics::Repr; // FIXME: Blegh - kind of cross-cutting concerns here...
        let subst_ty = match *Rc::make_mut(&mut self.inner) {
            Type::Var(_, Var::Free(ref name)) => match substs.get(name) {
                None => return,
                Some(ty) => ty.clone(),
            },
            Type::HostVar(Var::Free(ref name)) => match substs.get(name) {
                None => return,
                Some(ty) => ty.repr().clone(),
            },
            Type::Var(_, Var::Bound(_)) | Type::HostVar(Var::Bound(_)) | Type::Const(_) => return,
            Type::Arrow(ref mut param_tys, ref mut ret_ty) => {
                for param_ty in param_tys {
                    param_ty.substitute(substs);
                }
                ret_ty.substitute(substs);
                return;
            }
            Type::Lam(_, _, ref mut body_ty) => {
                body_ty.substitute(substs);
                return;
            }
            Type::App(_, ref mut fn_ty, ref mut arg_tys) => {
                fn_ty.substitute(substs);
                for arg_ty in arg_tys {
                    arg_ty.substitute(substs);
                }
                return;
            }
            Type::Array(_, ref mut elem_ty, ref mut size_expr) => {
                elem_ty.substitute(substs);
                size_expr.substitute(substs);
                return;
            }
            Type::Cond(_, ref mut options) => {
                for option in options {
                    option.value.0.substitute(substs);
                    option.value.1.substitute(substs);
                }
                return;
            }
            Type::Struct(_, ref mut fields) => {
                for field in fields.iter_mut() {
                    field.value.substitute(substs);
                }
                return;
            }
            Type::Assert(_, ref mut ty, ref mut pred) => {
                ty.substitute(substs);
                pred.substitute(substs);
                return;
            }
            Type::Interp(_, ref mut ty, ref mut conv, ref mut repr_ty) => {
                ty.substitute(substs);
                conv.substitute(substs);
                repr_ty.substitute(substs);
                return;
            }
            Type::HostArray(ref mut elem_ty) => {
                elem_ty.substitute(substs);
                return;
            }
            Type::HostUnion(ref mut variants) => {
                for variant in variants {
                    variant.value.substitute(substs);
                }
                return;
            }
            Type::HostStruct(ref mut fields) => {
                for field in fields {
                    field.value.substitute(substs);
                }
                return;
            }
        };
        *self = subst_ty.clone();
    }
pub fn substitute ( & mut self , substs : & Substitutions ) { use semantics :: Repr ; // FIXME: Blegh - kind of cross-cutting concerns here... let subst_ty = match * Rc :: make_mut ( & mut self . inner ) { Type :: Var ( _ , Var :: Free ( ref name ) ) => match substs . get ( name ) { None => return , Some ( ty ) => ty . clone ( ) , } , Type :: HostVar ( Var :: Free ( ref name ) ) => match substs . get ( name ) { None => return , Some ( ty ) => ty . repr ( ) . clone ( ) , } , Type :: Var ( _ , Var :: Bound ( _ ) ) | Type :: HostVar ( Var :: Bound ( _ ) ) | Type :: Const ( _ ) => return , Type :: Arrow ( ref mut param_tys , ref mut ret_ty ) => { for param_ty in param_tys { param_ty . substitute ( substs ) ; } ret_ty . substitute ( substs ) ; return ; } Type :: Lam ( _ , _ , ref mut body_ty ) => { body_ty . substitute ( substs ) ; return ; } Type :: App ( _ , ref mut fn_ty , ref mut arg_tys ) => { fn_ty . substitute ( substs ) ; for arg_ty in arg_tys { arg_ty . substitute ( substs ) ; } return ; } Type :: Array ( _ , ref mut elem_ty , ref mut size_expr ) => { elem_ty . substitute ( substs ) ; size_expr . substitute ( substs ) ; return ; } Type :: Cond ( _ , ref mut options ) => { for option in options { option . value . 0 . substitute ( substs ) ; option . value . 1 . substitute ( substs ) ; } return ; } Type :: Struct ( _ , ref mut fields ) => { for field in fields . iter_mut ( ) { field . value . substitute ( substs ) ; } return ; } Type :: Assert ( _ , ref mut ty , ref mut pred ) => { ty . substitute ( substs ) ; pred . substitute ( substs ) ; return ; } Type :: Interp ( _ , ref mut ty , ref mut conv , ref mut repr_ty ) => { ty . substitute ( substs ) ; conv . substitute ( substs ) ; repr_ty . substitute ( substs ) ; return ; } Type :: HostArray ( ref mut elem_ty ) => { elem_ty . substitute ( substs ) ; return ; } Type :: HostUnion ( ref mut variants ) => { for variant in variants { variant . value . substitute ( substs ) ; } return ; } Type :: HostStruct ( ref mut fields ) => { for field in fields { field . value . substitute ( substs ) ; } return ; } } ; * self = subst_ty . clone ( ) ; }
Replace occurrences of the free variables that exist as keys on
`substs` with their corresponding types.
Replace occurrences of the free variables that exist as keys on ` substs ` with their corresponding types .
&mut self
substs
&Substitutions
&mut self
substs
&Substitutions