public string SaveToString() { var json = new MyJson.JsonNode_Object(); json.SetDictValue("script", script.ToJson()); if (string.IsNullOrEmpty(error) == false) { json.SetDictValue("error", error); } json.SetDictValue("VMState", state.ToString()); StringBuilder sb = new StringBuilder(); json.ConvertToStringWithFormat(sb, 0); var jsontxt = sb.ToString(); byte[] data = System.Text.Encoding.UTF8.GetBytes(jsontxt); var ms = new System.IO.MemoryStream(data); var bts = llvm.QuickFile.ToBytes(ms); return(bts.ToHexString()); }
public void Save(string filename) { var path = System.IO.Path.GetDirectoryName(filename); if (System.IO.Directory.Exists(path) == false) { System.IO.Directory.CreateDirectory(path); } System.IO.File.Delete(filename + ".json"); System.IO.File.Delete(filename); var json = new MyJson.JsonNode_Object(); json.SetDictValue("script", script.ToJson()); if (string.IsNullOrEmpty(error) == false) { json.SetDictValue("error", error); } json.SetDictValue("VMState", state.ToString()); StringBuilder sb = new StringBuilder(); json.ConvertToStringWithFormat(sb, 0); System.IO.File.WriteAllText(filename, sb.ToString()); var bts = llvm.QuickFile.ToBytes(filename); //var compressor = new SevenZip.SevenZipCompressor(); //compressor.CompressionMethod = SevenZip.CompressionMethod.Lzma; //compressor.CompressionLevel = SevenZip.CompressionLevel.Fast; //compressor.FastCompression = true; ////compressor.path = path; //compressor.CompressFiles(filename, System.IO.Path.GetFullPath(filename + ".json")); System.IO.File.WriteAllText(filename, bts.ToHexString()); System.IO.File.Delete(filename + ".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 (opparam != null) { _op.SetDictValue("param", opparam.ToHexString()); } if (subScript != null) { _op.SetDictValue("subscript", subScript.ToJson()); } return(_op); }