public void Substitute(IRGenericParameterList methodParams) { GenericParameters.Substitute(ParentType.GenericParameters, methodParams); if (Resolved && !mSubstituted) { mSubstituted = true; if (ReturnType != null) ReturnType.Resolve(ref mReturnType, ParentType.GenericParameters, GenericParameters); if (!this.IsStatic) Parameters[0].Type = this.ParentType; Parameters.ForEach(p => p.Substitute()); Locals.ForEach(l => l.Substitute()); Instructions.ForEach(i => i.Substitute()); } }
public void Resolve(ref IRField selfReference, IRGenericParameterList typeParams, IRGenericParameterList methodParams) { IRType t = ParentType; ParentType.Resolve(ref t, typeParams, methodParams); IRField f2 = selfReference; selfReference = t.Fields[ParentType.Fields.FindIndex(f => f == f2)]; }
public void Resolve(ref IRMethod selfReference, IRGenericParameterList typeParams, IRGenericParameterList methodParams) { if (!Resolved || PresolvedMethod || PostsolvedMethod) { IRType t = ParentType; t.Resolve(ref t, typeParams, methodParams); if (IsGeneric) { if (!this.GenericParameters.Resolved) { if (this.PostsolvedMethod) { this.GenericParameters.TrySubstitute(typeParams, methodParams); } else { if (this.PresolvedMethod) { selfReference = Assembly.AppDomain.PresolveGenericMethod(this.GenericMethod, methodParams.ToList(), typeParams.ToList()); } else { selfReference = Assembly.AppDomain.PresolveGenericMethod(this, methodParams.ToList(), typeParams.ToList()); } selfReference.PresolvedMethod = false; selfReference.PostsolvedMethod = true; selfReference.Resolve(ref selfReference, typeParams, methodParams); return; } } if (this.GenericParameters.Resolved) { IRMethod mth = null; if (!t.GenericMethods.TryGetValue(this, out mth)) { IRMethod mth2 = null; mth = this.GenericMethod.Clone(t); mth.GenericParameters.Substitute(t.GenericParameters, this.GenericParameters); if (!t.GenericMethods.TryGetValue(mth, out mth2)) { t.GenericMethods.Add(mth, mth); mth.Substitute(this.GenericParameters); } else { mth = mth2; } } selfReference = mth; } else { // Dia a painful death. // This will eventually need to get the instantiation of this method. } } else { if (t.GenericParameters.Resolved) { selfReference = t.Methods[selfReference.ParentTypeMethodIndex]; selfReference.Resolve(ref selfReference, t.GenericParameters, methodParams); } } } }