public override bool Equals(object obj) { if (obj is FuncType) { FuncType x = (FuncType)obj; if (m_params.Length != x.m_params.Length) { return(false); } for (int i = 0; i < m_params.Length; ++i) { if (!m_params[i].Equals(x.m_params[i])) { return(false); } } return(m_ret.Equals(x.m_ret)); } return(false); }
/// <summary> /// Recursively parameterize the pars of a method type. /// </summary> internal FuncType parameterizeFuncType(FuncType t) { Type[] pars = new Type[t.m_params.Length]; for (int i = 0; i < pars.Length; i++) { Type param = t.m_params[i]; if (param.isGenericParameter()) { param = doParameterize(param); } pars[i] = param; } Type ret = t.m_ret; if (ret.isGenericParameter()) { ret = doParameterize(ret); } return(new FuncType(pars, ret)); }
public override bool @is(Type type) { if (this == type) { return(true); } if (type is FuncType) { FuncType t = (FuncType)type; // match return type (if void is needed, anything matches) if (t.m_ret != Sys.VoidType && !m_ret.@is(t.m_ret)) { return(false); } // match params - it is ok for me to have less than // the type params (if I want to ignore them), but I // must have no more if (m_params.Length > t.m_params.Length) { return(false); } for (int i = 0; i < m_params.Length; ++i) { if (!t.m_params[i].@is(m_params[i])) { return(false); } } // this method works for the specified method type return(true); } return(@base().@is(type)); }
/// <summary> /// Recursively parameterize the pars of a method type. /// </summary> internal FuncType parameterizeFuncType(FuncType t) { Type[] pars = new Type[t.m_params.Length]; for (int i=0; i<pars.Length; i++) { Type param = t.m_params[i]; if (param.isGenericParameter()) param = doParameterize(param); pars[i] = param; } Type ret = t.m_ret; if (ret.isGenericParameter()) ret = doParameterize(ret); return new FuncType(pars, ret); }