Exemple #1
0
        protected override void CopyItemsAsText(LocalVM[] locals)
        {
            Array.Sort(locals, (a, b) => a.Index.CompareTo(b.Index));

            var output = new NoSyntaxHighlightOutput();

            for (int i = 0; i < locals.Length; i++)
            {
                if (i > 0)
                {
                    output.WriteLine();
                }

                var local = locals[i];
                output.Write(local.Index.ToString(), TextTokenKind.Number);
                output.Write("\t", TextTokenKind.Text);
                output.Write(local.IsPinned ? dnSpy_AsmEditor_Resources.Local_Pinned_Character : string.Empty, TextTokenKind.Text);
                output.Write("\t", TextTokenKind.Text);
                output.Write(local.IsCompilerGenerated ? dnSpy_AsmEditor_Resources.Local_CompilerGenerated_Character : string.Empty, TextTokenKind.Text);
                output.Write("\t", TextTokenKind.Text);
                output.Write(local.Name ?? string.Empty, TextTokenKind.Local);
                output.Write("\t", TextTokenKind.Text);
                BodyUtils.WriteObject(output, local.Type);
            }
            if (locals.Length > 1)
            {
                output.WriteLine();
            }

            try {
                Clipboard.SetText(output.ToString());
            }
            catch (ExternalException) { }
        }
Exemple #2
0
        protected override void CopyItemsAsText(LocalVM[] locals)
        {
            Array.Sort(locals, (a, b) => a.Index.CompareTo(b.Index));

            var output = new StringBuilderTextColorOutput();

            for (int i = 0; i < locals.Length; i++)
            {
                if (i > 0)
                {
                    output.WriteLine();
                }

                var local = locals[i];
                output.Write(BoxedTextColor.Number, local.Index.ToString());
                output.Write(BoxedTextColor.Text, "\t");
                output.Write(BoxedTextColor.Text, local.IsPinned ? dnSpy_AsmEditor_Resources.Local_Pinned_Character : string.Empty);
                output.Write(BoxedTextColor.Text, "\t");
                output.Write(BoxedTextColor.Text, local.DebuggerHidden ? dnSpy_AsmEditor_Resources.Local_CompilerGenerated_Character : string.Empty);
                output.Write(BoxedTextColor.Text, "\t");
                output.Write(BoxedTextColor.Local, local.Name ?? string.Empty);
                output.Write(BoxedTextColor.Text, "\t");
                BodyUtils.WriteObject(output, local.Type);
            }
            if (locals.Length > 1)
            {
                output.WriteLine();
            }

            try {
                Clipboard.SetText(output.ToString());
            }
            catch (ExternalException) { }
        }
 public Instruction CopyTo(Dictionary <object, object> ops, Instruction instr)
 {
     instr.OpCode        = Code.ToOpCode();
     instr.Operand       = BodyUtils.ToOperandModel(ops, Operand);
     instr.SequencePoint = SequencePoint;
     return(instr);
 }
Exemple #4
0
        protected override void CopyItemsAsText(LocalVM[] locals)
        {
            Array.Sort(locals, (a, b) => a.Index.CompareTo(b.Index));

            var output = new PlainTextOutput();

            for (int i = 0; i < locals.Length; i++)
            {
                if (i > 0)
                {
                    output.WriteLine();
                }

                var local = locals[i];
                output.Write(local.Index.ToString(), TextTokenType.Number);
                output.Write('\t', TextTokenType.Text);
                output.Write(local.IsPinned ? "P" : string.Empty, TextTokenType.Text);
                output.Write('\t', TextTokenType.Text);
                output.Write(local.IsCompilerGenerated ? "C" : string.Empty, TextTokenType.Text);
                output.Write('\t', TextTokenType.Text);
                output.Write(local.Name ?? string.Empty, TextTokenType.Local);
                output.Write('\t', TextTokenType.Text);
                BodyUtils.WriteObject(output, local.Type);
            }
            if (locals.Length > 1)
            {
                output.WriteLine();
            }

            Clipboard.SetText(output.ToString());
        }
 public ExceptionHandlerOptions(Dictionary <object, object> ops, ExceptionHandler eh)
 {
     this.TryStart     = (InstructionVM)BodyUtils.TryGetVM(ops, eh.TryStart);
     this.TryEnd       = (InstructionVM)BodyUtils.TryGetVM(ops, eh.TryEnd);
     this.FilterStart  = (InstructionVM)BodyUtils.TryGetVM(ops, eh.FilterStart);
     this.HandlerStart = (InstructionVM)BodyUtils.TryGetVM(ops, eh.HandlerStart);
     this.HandlerEnd   = (InstructionVM)BodyUtils.TryGetVM(ops, eh.HandlerEnd);
     this.CatchType    = eh.CatchType;
     this.HandlerType  = eh.HandlerType;
 }
 public ExceptionHandler CopyTo(Dictionary <object, object> ops, ExceptionHandler eh)
 {
     eh.TryStart     = BodyUtils.TryGetModel(ops, this.TryStart) as Instruction;
     eh.TryEnd       = BodyUtils.TryGetModel(ops, this.TryEnd) as Instruction;
     eh.FilterStart  = BodyUtils.TryGetModel(ops, this.FilterStart) as Instruction;
     eh.HandlerStart = BodyUtils.TryGetModel(ops, this.HandlerStart) as Instruction;
     eh.HandlerEnd   = BodyUtils.TryGetModel(ops, this.HandlerEnd) as Instruction;
     eh.CatchType    = this.CatchType;
     eh.HandlerType  = this.HandlerType;
     return(eh);
 }
Exemple #7
0
        protected override void CopyItemsAsText(ExceptionHandlerVM[] ehs)
        {
            Array.Sort(ehs, (a, b) => a.Index.CompareTo(b.Index));

            var output = new StringBuilderTextColorOutput();

            for (int i = 0; i < ehs.Length; i++)
            {
                if (i > 0)
                {
                    output.WriteLine();
                }

                var eh = ehs[i];
                output.Write(BoxedTextColor.Number, eh.Index.ToString());
                output.Write(BoxedTextColor.Text, "\t");
                BodyUtils.WriteObject(output, eh.TryStartVM.SelectedItem);
                output.Write(BoxedTextColor.Text, "\t");
                BodyUtils.WriteObject(output, eh.TryEndVM.SelectedItem);
                output.Write(BoxedTextColor.Text, "\t");
                BodyUtils.WriteObject(output, eh.FilterStartVM.SelectedItem);
                output.Write(BoxedTextColor.Text, "\t");
                BodyUtils.WriteObject(output, eh.HandlerStartVM.SelectedItem);
                output.Write(BoxedTextColor.Text, "\t");
                BodyUtils.WriteObject(output, eh.HandlerEndVM.SelectedItem);
                output.Write(BoxedTextColor.Text, "\t");
                output.Write(BoxedTextColor.Text, ((EnumVM)eh.HandlerTypeVM.Items[eh.HandlerTypeVM.SelectedIndex]).Name);
                output.Write(BoxedTextColor.Text, "\t");
                BodyUtils.WriteObject(output, eh.CatchType);
            }
            if (ehs.Length > 1)
            {
                output.WriteLine();
            }

            try {
                Clipboard.SetText(output.ToString());
            }
            catch (ExternalException) { }
        }
        protected override void CopyItemsAsText(ExceptionHandlerVM[] ehs)
        {
            Array.Sort(ehs, (a, b) => a.Index.CompareTo(b.Index));

            var output = new PlainTextOutput();

            for (int i = 0; i < ehs.Length; i++)
            {
                if (i > 0)
                {
                    output.WriteLine();
                }

                var eh = ehs[i];
                output.Write(eh.Index.ToString(), TextTokenType.Number);
                output.Write('\t', TextTokenType.Text);
                BodyUtils.WriteObject(output, eh.TryStartVM.SelectedItem);
                output.Write('\t', TextTokenType.Text);
                BodyUtils.WriteObject(output, eh.TryEndVM.SelectedItem);
                output.Write('\t', TextTokenType.Text);
                BodyUtils.WriteObject(output, eh.FilterStartVM.SelectedItem);
                output.Write('\t', TextTokenType.Text);
                BodyUtils.WriteObject(output, eh.HandlerStartVM.SelectedItem);
                output.Write('\t', TextTokenType.Text);
                BodyUtils.WriteObject(output, eh.HandlerEndVM.SelectedItem);
                output.Write('\t', TextTokenType.Text);
                output.Write(((EnumVM)eh.HandlerTypeVM.Items[eh.HandlerTypeVM.SelectedIndex]).Name, TextTokenType.Text);
                output.Write('\t', TextTokenType.Text);
                BodyUtils.WriteObject(output, eh.CatchType);
            }
            if (ehs.Length > 1)
            {
                output.WriteLine();
            }

            Clipboard.SetText(output.ToString());
        }
Exemple #9
0
        public static void CopyItemsAsTextToClipboard(InstructionVM[] instrs)
        {
            var output = new StringBuilderTextColorOutput();

            for (int i = 0; i < instrs.Length; i++)
            {
                if (i > 0)
                {
                    output.WriteLine();
                }

                var instr = instrs[i];
                output.Write(BoxedTextColor.Number, instr.Index.ToString());
                output.Write(BoxedTextColor.Text, "\t");
                output.Write(BoxedTextColor.Label, instr.Offset.ToString("X4"));
                output.Write(BoxedTextColor.Text, "\t");
                output.Write(BoxedTextColor.OpCode, instr.Code.ToOpCode().ToString());

                switch (instr.InstructionOperandVM.InstructionOperandType)
                {
                case InstructionOperandType.None:
                    break;

                case InstructionOperandType.SByte:
                    output.Write(BoxedTextColor.Text, "\t");
                    output.Write(BoxedTextColor.Number, instr.InstructionOperandVM.SByte.StringValue);
                    break;

                case InstructionOperandType.Byte:
                    output.Write(BoxedTextColor.Text, "\t");
                    output.Write(BoxedTextColor.Number, instr.InstructionOperandVM.Byte.StringValue);
                    break;

                case InstructionOperandType.Int32:
                    output.Write(BoxedTextColor.Text, "\t");
                    output.Write(BoxedTextColor.Number, instr.InstructionOperandVM.Int32.StringValue);
                    break;

                case InstructionOperandType.Int64:
                    output.Write(BoxedTextColor.Text, "\t");
                    output.Write(BoxedTextColor.Number, instr.InstructionOperandVM.Int64.StringValue);
                    break;

                case InstructionOperandType.Single:
                    output.Write(BoxedTextColor.Text, "\t");
                    output.Write(BoxedTextColor.Number, instr.InstructionOperandVM.Single.StringValue);
                    break;

                case InstructionOperandType.Double:
                    output.Write(BoxedTextColor.Text, "\t");
                    output.Write(BoxedTextColor.Number, instr.InstructionOperandVM.Double.StringValue);
                    break;

                case InstructionOperandType.String:
                    output.Write(BoxedTextColor.Text, "\t");
                    output.Write(BoxedTextColor.String, instr.InstructionOperandVM.String.StringValue);
                    break;

                case InstructionOperandType.Field:
                case InstructionOperandType.Method:
                case InstructionOperandType.Token:
                case InstructionOperandType.Type:
                case InstructionOperandType.MethodSig:
                case InstructionOperandType.BranchTarget:
                case InstructionOperandType.SwitchTargets:
                case InstructionOperandType.Local:
                case InstructionOperandType.Parameter:
                    output.Write(BoxedTextColor.Text, "\t");
                    BodyUtils.WriteObject(output, instr.InstructionOperandVM.Value);
                    break;

                default:
                    throw new InvalidOperationException();
                }
            }
            if (instrs.Length > 1)
            {
                output.WriteLine();
            }

            try {
                Clipboard.SetText(output.ToString());
            }
            catch (ExternalException) { }
        }
 public InstructionOptions(Dictionary <object, object> ops, Instruction instr)
 {
     Code          = instr.OpCode.Code;
     Operand       = BodyUtils.ToOperandVM(ops, instr.Operand);
     SequencePoint = instr.SequencePoint;
 }
Exemple #11
0
        public static void CopyItemsAsTextToClipboard(InstructionVM[] instrs)
        {
            var output = new PlainTextOutput();

            for (int i = 0; i < instrs.Length; i++)
            {
                if (i > 0)
                {
                    output.WriteLine();
                }

                var instr = instrs[i];
                output.Write(instr.Index.ToString(), TextTokenType.Number);
                output.Write('\t', TextTokenType.Text);
                output.Write(string.Format("{0:X4}", instr.Offset), TextTokenType.Label);
                output.Write('\t', TextTokenType.Text);
                output.Write(instr.Code.ToOpCode().ToString(), TextTokenType.OpCode);

                switch (instr.InstructionOperandVM.InstructionOperandType)
                {
                case InstructionOperandType.None:
                    break;

                case InstructionOperandType.SByte:
                    output.Write('\t', TextTokenType.Text);
                    output.Write(instr.InstructionOperandVM.SByte.StringValue, TextTokenType.Number);
                    break;

                case InstructionOperandType.Byte:
                    output.Write('\t', TextTokenType.Text);
                    output.Write(instr.InstructionOperandVM.Byte.StringValue, TextTokenType.Number);
                    break;

                case InstructionOperandType.Int32:
                    output.Write('\t', TextTokenType.Text);
                    output.Write(instr.InstructionOperandVM.Int32.StringValue, TextTokenType.Number);
                    break;

                case InstructionOperandType.Int64:
                    output.Write('\t', TextTokenType.Text);
                    output.Write(instr.InstructionOperandVM.Int64.StringValue, TextTokenType.Number);
                    break;

                case InstructionOperandType.Single:
                    output.Write('\t', TextTokenType.Text);
                    output.Write(instr.InstructionOperandVM.Single.StringValue, TextTokenType.Number);
                    break;

                case InstructionOperandType.Double:
                    output.Write('\t', TextTokenType.Text);
                    output.Write(instr.InstructionOperandVM.Double.StringValue, TextTokenType.Number);
                    break;

                case InstructionOperandType.String:
                    output.Write('\t', TextTokenType.Text);
                    output.Write(instr.InstructionOperandVM.String.StringValue, TextTokenType.String);
                    break;

                case InstructionOperandType.Field:
                case InstructionOperandType.Method:
                case InstructionOperandType.Token:
                case InstructionOperandType.Type:
                case InstructionOperandType.MethodSig:
                case InstructionOperandType.BranchTarget:
                case InstructionOperandType.SwitchTargets:
                case InstructionOperandType.Local:
                case InstructionOperandType.Parameter:
                    output.Write('\t', TextTokenType.Text);
                    BodyUtils.WriteObject(output, instr.InstructionOperandVM.Value);
                    break;

                default:
                    throw new InvalidOperationException();
                }
            }
            if (instrs.Length > 1)
            {
                output.WriteLine();
            }

            Clipboard.SetText(output.ToString());
        }