void FillTreeScript(TreeViewItem treeitem, Neo.SmartContract.Debug.LogScript script) { treeitem.Tag = script; treeitem.Header = "script:" + script.hash; foreach (var op in script.ops) { TreeViewItem itemop = new TreeViewItem(); itemop.Header = op.GetHeader(); if (op.op == Neo.VM.OpCode.SYSCALL && op.param != null) { string p = System.Text.Encoding.ASCII.GetString(op.param); itemop.Header = op.GetHeader() + " " + p; } itemop.Tag = op; treeitem.Items.Add(itemop); if (op.subScript != null) { TreeViewItem subscript = new TreeViewItem(); itemop.Items.Add(subscript); FillTreeScript(subscript, op.subScript); } } }
private void treeCode_SelectedItemChanged(object sender, RoutedPropertyChangedEventArgs <object> e) { Neo.SmartContract.Debug.LogScript script = null; Neo.SmartContract.Debug.LogOp logop = null; if (treeCode.SelectedItem != null) { var treenode = treeCode.SelectedItem as TreeViewItem; var treenodep = treenode != null ? treenode.Parent as TreeViewItem : null; script = treenode.Tag as Neo.SmartContract.Debug.LogScript; logop = treenode.Tag as Neo.SmartContract.Debug.LogOp; if (script == null && treenodep != null) { script = treenodep.Tag as Neo.SmartContract.Debug.LogScript; } } listStack.Items.Clear(); listAltStack.Items.Clear(); var stateid = -1; if (logop != null) { if (this.debugtool.simvm.mapState.ContainsKey(logop)) { stateid = debugtool.simvm.mapState[logop]; if (debugtool.simvm.stateClone.ContainsKey(stateid)) { var state = debugtool.simvm.stateClone[stateid]; foreach (var l in state.CalcStack) { listStack.Items.Add(l); } foreach (var l in state.AltStack) { listAltStack.Items.Add(l); } } } } if (script == null) { selectScript.Content = "未选中脚本"; } else { selectScript.Content = "选中脚本" + script.hash; if (debugtool.scripts.ContainsKey(script.hash)) { selectScriptDebug.Content = "有调试信息"; var debugscript = debugtool.scripts[script.hash]; if (debugscript != this.listBoxASM.Tag) { this.listBoxASM.Tag = debugscript; this.listBoxASM.Items.Clear(); foreach (var op in debugscript.codes) { this.listBoxASM.Items.Add(op); } this.codeEdit.Text = debugscript.srcfile; } if (logop != null) { foreach (Neo.Compiler.Op op in listBoxASM.Items) { if (op.addr == (ushort)logop.addr) { listBoxASM.SelectedItem = op; listBoxASM.ScrollIntoView(op); break; } } } } else { selectScriptDebug.Content = "没有调试信息"; this.listBoxASM.Tag = null; this.listBoxASM.Items.Clear(); this.codeEdit.Text = ""; } } }