Beispiel #1
0
        public override string ToString()
        {
            var sb = new StringBuilder();

            sb.AppendLine(FormattingUtils.OutputLine("Offset", "Opcode", "Comment"));
            foreach (var entry in this.lines)
            {
                string ofsStr  = entry.startOfs.ToString();
                string opStr   = entry.name;
                string hintStr = entry.comment;

                if (!string.IsNullOrEmpty(hintStr))
                {
                    if (hintStr.Contains("$$"))
                    {
                        hintStr = hintStr.Replace("$$", FormattingUtils.OutputData(entry.data, true));
                    }

                    if (hintStr.Contains("$XX"))
                    {
                        hintStr = hintStr.Replace("$XX", FormattingUtils.OutputHex(entry.data));
                    }

                    hintStr = "// " + hintStr;
                }

                sb.AppendLine(FormattingUtils.OutputLine(ofsStr, opStr, hintStr));
            }

            return(sb.ToString());
        }
Beispiel #2
0
        public static string StackItemAsString(StackItem item, bool addQuotes = false)
        {
            if (item.IsArray)
            {
                var s     = new StringBuilder();
                var items = item.GetArray();

                s.Append('[');
                for (int i = 0; i < items.Length; i++)
                {
                    var element = items[i];
                    if (i > 0)
                    {
                        s.Append(',');
                    }
                    s.Append(StackItemAsString(element));
                }
                s.Append(']');
                return(s.ToString());
            }

            if (item is Neo.VM.Types.Boolean)
            {
                return(item.GetBoolean().ToString());
            }

            if (item is Neo.VM.Types.Integer)
            {
                return(item.GetBigInteger().ToString());
            }

            if (item is Neo.VM.Types.InteropInterface)
            {
                return("{InteropInterface}");
            }

            var data = item.GetByteArray();

            if (data == null)
            {
                return("[Null]");
            }

            if (data == null || data.Length == 0)
            {
                return("False");
            }


            return(FormattingUtils.OutputData(data, addQuotes));
        }