Пример #1
0
 public override bool Rewrite(Meta.CodeDescriptor decompilee, System.Reflection.MethodBase callee, Analysis.StackElement[] args, Analysis.IDecompiler stack, SysDOM.IFunctionBuilder builder)
 {
     stack.Push(
         Expression.Conditional(args[0].Expr, args[1].Expr, args[2].Expr),
         args[1].Sample);
     return(true);
 }
Пример #2
0
            public override bool Rewrite(Meta.CodeDescriptor decompilee, System.Reflection.MethodBase callee, Analysis.StackElement[] args, Analysis.IDecompiler stack, IFunctionBuilder builder)
            {
                object[] outArgs;
                object   sample;

                if (!stack.TryGetReturnValueSample((MethodInfo)callee, args, out outArgs, out sample))
                {
                    throw new InvalidOperationException("Unable to create sample for ScSinCos call");
                }

                var fcall = IntrinsicFunctions.XILOpCode(
                    new XILInstr(InstructionCodes.ScSinCos),
                    TypeDescriptor.GetTypeOf(sample),
                    new Expression[] { args[0].Expr });

                stack.Push(fcall, sample);
                return(true);
            }
Пример #3
0
            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);
            }