public override void Transform(IRType type) { if (!type.IsAbstract && (type.IsGeneric || type.NestedInsideOfType != null || type.IsArrayType || type.IsManagedPointerType || type.IsUnmanagedPointerType)) { if (type.VirtualMethodTree[3].ParentType != type) { // It doesn't already implement ToString() itself. IRMethod ts = new IRMethod(type.Assembly); ts.ParentType = type; ts.ReturnType = type.Assembly.AppDomain.System_String; ts.Parameters.Add(new IRParameter(type.Assembly) { ParentMethod = ts, Type = type }); ts.VirtualMethodIndex = 3; var r = new IRReturnInstruction(); r.ParentMethod = ts; r.Linearized = true; var loc = new IRLinearizedLocation(r, IRLinearizedLocationType.String); loc.String.Value = type.ToString(); r.Sources.Add(loc); ts.Instructions.Add(r); ts.ParentTypeMethodIndex = type.Methods.Count; type.Methods.Add(ts); type.VirtualMethodTree[3] = ts; if (!ts.Resolved) // This adds it to the Domain's Methods list. throw new Exception(); } } }
public override void Transform(IRMethod method) { if (method.IsInternalCall) { IRInstruction added = null; switch (method.ToString()) { case "object object::Internal_PointerToReference(void*)": case "void* object.Internal_ReferenceToPointer(object)": method.Instructions.Add( added = new IRReturnInstruction() { Sources = new List<IRLinearizedLocation>() { new IRLinearizedLocation(null, IRLinearizedLocationType.Parameter) { Parameter = new IRLinearizedLocation.ParameterLocationData() { ParameterIndex = 0 } } } } ); added.Sources[0].SetParentInstruction(added); added.ParentMethod = method; break; case "(null) object::Internal_FastCopy(void*, void*, int)": break; case "(null) object::Internal_FastZero(void*, int)": break; case "(null) string..ctor(string, char[])": break; case "(null) string..ctor(string, char, int)": break; default: throw new Exception("Unknown internal call '" + method.ToString() + "'!"); } } }