コード例 #1
0
        //public MyJson.JsonNode_Object ToJson()
        //{
        //    MyJson.JsonNode_Object script = new MyJson.JsonNode_Object();
        //    script.SetDictValue("hash", this.hash);
        //    MyJson.JsonNode_Array array = new MyJson.JsonNode_Array();
        //    script.SetDictValue("ops", array);
        //    foreach (var op in ops)
        //    {
        //        array.Add(op.ToJson());
        //    }
        //    return script;
        //}
        public static LogScript FromJson(MyJson.JsonNode_Object json)
        {
            var       hash   = json["hash"].AsString();
            LogScript script = new LogScript(hash);
            var       array  = json["ops"].AsList();

            foreach (var op in array)
            {
                script.ops.Add(LogOp.FromJson(op as MyJson.JsonNode_Object));
                var ss = script.ops.Last().subScript;
                if (ss != null)
                {
                    ss.parent = script;
                }
            }
            return(script);
        }
コード例 #2
0
        //public static MyJson.JsonNode_Object StatkItemToJson(StackItem item)
        //{
        //    //MyJson.JsonNode_Object json = new MyJson.JsonNode_Object();
        //    //var type = item.GetType().Name;
        //    //if (type == "InteropInterface")
        //    //{
        //    //    json.SetDictValue(type, item.GetInterface<VM.IInteropInterface>().GetType().Name);
        //    //}
        //    //else if (type == "Boolean")
        //    //{
        //    //    json.SetDictValue(type, item.GetBoolean().ToString());
        //    //}
        //    //else if (type == "ByteArray")
        //    //{
        //    //    json.SetDictValue(type, item.GetByteArray().ToHexString());
        //    //}
        //    //else if (type == "Integer")
        //    //{
        //    //    json.SetDictValue(type, item.GetBigInteger().ToString());
        //    //}
        //    //else if (item.IsArray || item.IsStruct)
        //    //{
        //    //    MyJson.JsonNode_Array array = new MyJson.JsonNode_Array();
        //    //    json.SetDictValue(type, array);
        //    //    foreach (var i in item.GetArray())
        //    //    {
        //    //        array.Add(StatkItemToJson(i));
        //    //    }
        //    //}
        //    //return json;
        //}
        //public MyJson.JsonNode_Object ToJson()
        //{
        //    MyJson.JsonNode_Object _op = new MyJson.JsonNode_Object();
        //    _op.SetDictValue("addr", addr);
        //    _op.SetDictValue("op", op.ToString());
        //    if (this.stack != null)
        //    {
        //        MyJson.JsonNode_Array array = new MyJson.JsonNode_Array();
        //        _op.SetDictValue("stack", array);
        //        foreach (var r in stack)
        //        {
        //            if (r.ind > 0)
        //            {
        //                array.AddArrayValue(r.type.ToString() + "|" + r.ind);
        //            }
        //            else
        //            {
        //                array.AddArrayValue(r.type.ToString());
        //            }
        //        }
        //    }
        //    if (opresult != null)
        //    {
        //        _op.SetDictValue("result", StatkItemToJson(opresult));
        //    }
        //    if (subScript != null)
        //    {
        //        _op.SetDictValue("subscript", subScript.ToJson());
        //    }
        //    return _op;
        //}
        public static LogOp FromJson(MyJson.JsonNode_Object json)
        {
            var   opstr = json["op"].AsString();
            var   addr  = json["addr"].AsInt();
            var   op    = (VM.OpCode)Enum.Parse(typeof(VM.OpCode), opstr);
            LogOp _op   = new LogOp(addr, op);

            if (json.ContainsKey("stack"))
            {
                var array = json["stack"].AsList();
                _op.stack = new Op[array.Count];
                for (var i = 0; i < array.Count; i++)
                {
                    var str = array[i].AsString();
                    var ind = -1;
                    if (str.Contains('|'))
                    {
                        var strs = str.Split('|');
                        ind = int.Parse(strs[1]);
                        str = strs[0];
                    }
                    var type = (OpType)Enum.Parse(typeof(OpType), str);
                    _op.stack[i] = new Op(type, ind);
                }
            }
            if (json.ContainsKey("param"))
            {
                _op.param = ThinNeo.Debug.DebugTool.HexString2Bytes(json["param"].AsString());
            }
            if (json.ContainsKey("result"))
            {
                _op.opresult = StackItem.FromJson(json["result"] as MyJson.JsonNode_Object);
            }
            if (json.ContainsKey("subscript"))
            {
                _op.subScript = LogScript.FromJson(json["subscript"] as MyJson.JsonNode_Object);
            }
            return(_op);
        }
コード例 #3
0
        public LogOp Clone()
        {
            LogOp op = new LogOp(this.addr, this.op);

            op.error = this.error;
            if (this.stack != null)
            {
                op.stack = new Op[this.stack.Length];
                for (var i = 0; i < this.stack.Length; i++)
                {
                    op.stack[i] = this.stack[i];
                }
            }
            if (this.param != null)
            {
                op.param = this.param.Clone() as byte[];
            }
            if (this.opresult != null)
            {
                op.opresult = this.opresult.Clone();
            }
            op.subScript = this.subScript;
            return(op);
        }