public override bool Rewrite(CodeDescriptor decompilee, System.Reflection.MethodBase callee, Analysis.StackElement[] args, Analysis.IDecompiler stack, IFunctionBuilder builder) { Array arr = (Array)args[0].Sample; if (arr == null) { throw new InvalidOperationException("Unable to deduce array length"); } int numElems = arr.Length; Type tTE = arr.GetType().GetElementType(); Type tTA; callee.IsFunction(out tTA); FunctionCall newCall = IntrinsicFunctions.NewArray(tTE, LiteralReference.CreateConstant(numElems), arr); FunctionSpec fspec = (FunctionSpec)newCall.Callee; IntrinsicFunction ifun = fspec.IntrinsicRep; ArrayParams aparams = (ArrayParams)ifun.Parameter; for (int i = 0; i < numElems; i++) { aparams.Elements[i] = IntrinsicFunctions.GetArrayElement( args[0].Expr, LiteralReference.CreateConstant(i)); } object sample = null; try { sample = callee.Invoke(arr); } catch (Exception) { } Expression conv = IntrinsicFunctions.Cast(newCall, arr.GetType(), tTA); stack.Push(conv, sample); return(true); }