void ProtoBuf.Serializers.IProtoSerializer.EmitWrite(CompilerContext ctx, Local valueFrom) { ProtoTypeCode typeCode = this.GetTypeCode(); if (this.map == null) { ctx.LoadValue(valueFrom); ctx.ConvertToInt32(typeCode, false); ctx.EmitBasicWrite("WriteInt32", null); return; } using (Local localWithValue = ctx.GetLocalWithValue(this.ExpectedType, valueFrom)) { CodeLabel codeLabel = ctx.DefineLabel(); for (int i = 0; i < (int)this.map.Length; i++) { CodeLabel codeLabel1 = ctx.DefineLabel(); CodeLabel codeLabel2 = ctx.DefineLabel(); ctx.LoadValue(localWithValue); EnumSerializer.WriteEnumValue(ctx, typeCode, this.map[i].RawValue); ctx.BranchIfEqual(codeLabel2, true); ctx.Branch(codeLabel1, true); ctx.MarkLabel(codeLabel2); ctx.LoadValue(this.map[i].WireValue); ctx.EmitBasicWrite("WriteInt32", null); ctx.Branch(codeLabel, false); ctx.MarkLabel(codeLabel1); } ctx.LoadReaderWriter(); ctx.LoadValue(localWithValue); ctx.CastToObject(this.ExpectedType); ctx.EmitCall(ctx.MapType(typeof(ProtoWriter)).GetMethod("ThrowEnumException")); ctx.MarkLabel(codeLabel); } }
protected override void EmitRead(CompilerContext ctx, Local valueFrom) { using (Local localWithValue = ctx.GetLocalWithValue(this.ExpectedType, valueFrom)) { if (this.Tail.RequiresOldValue) { ctx.LoadAddress(localWithValue, this.ExpectedType); ctx.LoadValue(this.field); } ctx.ReadNullCheckedTail(this.field.FieldType, this.Tail, null); if (this.Tail.ReturnsValue) { using (Local local = new Local(ctx, this.field.FieldType)) { ctx.StoreValue(local); if (!this.field.FieldType.IsValueType) { CodeLabel codeLabel = ctx.DefineLabel(); ctx.LoadValue(local); ctx.BranchIfFalse(codeLabel, true); ctx.LoadAddress(localWithValue, this.ExpectedType); ctx.LoadValue(local); ctx.StoreValue(this.field); ctx.MarkLabel(codeLabel); } else { ctx.LoadAddress(localWithValue, this.ExpectedType); ctx.LoadValue(local); ctx.StoreValue(this.field); } } } } }
private void EmitWriteArrayLoop(CompilerContext ctx, Local i, Local arr) { ctx.LoadValue(0); ctx.StoreValue(i); CodeLabel label = ctx.DefineLabel(); CodeLabel label2 = ctx.DefineLabel(); ctx.Branch(label, false); ctx.MarkLabel(label2); ctx.LoadArrayValue(arr, i); if (this.SupportNull) { base.Tail.EmitWrite(ctx, null); } else { ctx.WriteNullCheckedTail(this.itemType, base.Tail, null); } ctx.LoadValue(i); ctx.LoadValue(1); ctx.Add(); ctx.StoreValue(i); ctx.MarkLabel(label); ctx.LoadValue(i); ctx.LoadLength(arr, false); ctx.BranchIfLess(label2, false); }
public static void EditLabel(UInt32 address, AddressType type) { CodeLabel existingLabel = LabelManager.GetLabel(address, type); CodeLabel newLabel = new CodeLabel() { Address = existingLabel?.Address ?? address, AddressType = existingLabel?.AddressType ?? type, Label = existingLabel?.Label, Comment = existingLabel?.Comment, Length = existingLabel?.Length ?? 1 }; frmEditLabel frm = new frmEditLabel(newLabel, existingLabel); if (frm.ShowDialog() == DialogResult.OK) { bool empty = string.IsNullOrWhiteSpace(newLabel.Label) && string.IsNullOrWhiteSpace(newLabel.Comment); if (existingLabel != null) { LabelManager.DeleteLabel(existingLabel, empty); } if (!empty) { LabelManager.SetLabel(newLabel.Address, newLabel.AddressType, newLabel.Label, newLabel.Comment, true, CodeLabelFlags.None, newLabel.Length); } } }
private string GetFunctionName(int relSubEntryAddr, int absSubEntryAddr, int nmiHandler, int irqHandler) { if (relSubEntryAddr < 0) { return("[bottom of stack]"); } string funcName; CodeLabel label = LabelManager.GetLabel((UInt32)absSubEntryAddr, AddressType.PrgRom); if (label != null) { funcName = label.Label + (relSubEntryAddr >= 0 ? (" ($" + relSubEntryAddr.ToString("X4") + ")") : ""); } else { funcName = (relSubEntryAddr >= 0 ? ("$" + relSubEntryAddr.ToString("X4")) : "n/a"); } if (relSubEntryAddr == nmiHandler) { funcName = "[nmi] " + funcName; } else if (relSubEntryAddr == irqHandler) { funcName = "[irq] " + funcName; } return(funcName); }
private void EmitBeq(CompilerContext ctx, CodeLabel label, Type type) { switch (Helpers.GetTypeCode(type)) { case ProtoTypeCode.Boolean: case ProtoTypeCode.Char: case ProtoTypeCode.SByte: case ProtoTypeCode.Byte: case ProtoTypeCode.Int16: case ProtoTypeCode.UInt16: case ProtoTypeCode.Int32: case ProtoTypeCode.UInt32: case ProtoTypeCode.Int64: case ProtoTypeCode.UInt64: case ProtoTypeCode.Single: case ProtoTypeCode.Double: ctx.BranchIfEqual(label, false); return; } MethodInfo method = type.GetMethod("op_Equality", BindingFlags.Public | BindingFlags.Static, null, new Type[] { type, type }, null); if ((method == null) || (method.ReturnType != ctx.MapType(typeof(bool)))) { throw new InvalidOperationException("No suitable equality operator found for default-values of type: " + type.FullName); } ctx.EmitCall(method); ctx.BranchIfTrue(label, false); }
private void mnuDelete_Click(object sender, EventArgs e) { if (lstLabels.SelectedItems.Count > 0) { int topIndex = lstLabels.TopItem.Index; int lastSelectedIndex = lstLabels.SelectedIndices[lstLabels.SelectedIndices.Count - 1]; for (int i = lstLabels.SelectedItems.Count - 1; i >= 0; i--) { CodeLabel label = (CodeLabel)lstLabels.SelectedItems[i].SubItems[1].Tag; LabelManager.DeleteLabel(label.Address, label.AddressType, i == 0); } //Reposition scroll bar and selected/focused item if (lstLabels.Items.Count > topIndex) { lstLabels.TopItem = lstLabels.Items[topIndex]; } if (lastSelectedIndex < lstLabels.Items.Count) { lstLabels.Items[lastSelectedIndex].Selected = true; } else if (lstLabels.Items.Count > 0) { lstLabels.Items[lstLabels.Items.Count - 1].Selected = true; } if (lstLabels.SelectedItems.Count > 0) { lstLabels.SelectedItems[0].Focused = true; } } }
private void lstLabels_SelectedIndexChanged(object sender, EventArgs e) { mnuDelete.Enabled = lstLabels.SelectedIndices.Count > 0; mnuEdit.Enabled = lstLabels.SelectedIndices.Count == 1; mnuFindOccurrences.Enabled = lstLabels.SelectedIndices.Count == 1; mnuAddToWatch.Enabled = lstLabels.SelectedIndices.Count == 1; mnuAddBreakpoint.Enabled = lstLabels.SelectedIndices.Count == 1; if (lstLabels.SelectedIndices.Count == 1) { CodeLabel label = GetSelectedLabel(); bool availableInCpuMemory = label.GetRelativeAddress(_cpuType).Address >= 0; mnuViewInCpuMemory.Enabled = availableInCpuMemory; bool showViewInMemoryType = label.MemoryType != SnesMemoryType.Register && label.MemoryType != SnesMemoryType.SpcRom && label.MemoryType != SnesMemoryType.SpcRam; if (showViewInMemoryType) { mnuViewInMemoryType.Text = "View in " + ResourceHelper.GetEnumText(label.MemoryType); mnuViewInMemoryType.Visible = true; } else { mnuViewInMemoryType.Visible = false; } } else { mnuViewInCpuMemory.Enabled = false; mnuViewInMemoryType.Visible = false; } }
private void mnuAdd_Click(object sender, EventArgs e) { SnesMemoryType defaultMemType = SnesMemoryType.PrgRom; switch (_cpuType) { case CpuType.Cpu: case CpuType.Sa1: case CpuType.Gsu: defaultMemType = SnesMemoryType.PrgRom; break; case CpuType.Spc: defaultMemType = SnesMemoryType.SpcRam; break; case CpuType.NecDsp: defaultMemType = SnesMemoryType.DspProgramRom; break; case CpuType.Gameboy: defaultMemType = SnesMemoryType.GbPrgRom; break; default: throw new Exception("Unsupported CPU type"); } CodeLabel newLabel = new CodeLabel() { Address = 0, MemoryType = defaultMemType, Label = "", Comment = "" }; EditLabel(newLabel); }
private void mnuEditLabel_Click(object sender, EventArgs e) { UInt32 address = (UInt32)ctrlHexBox.SelectionStart; SnesMemoryType memType = _memoryType; if (!memType.SupportsLabels()) { AddressInfo relAddress = new AddressInfo() { Address = (int)address, Type = memType }; AddressInfo absAddress = DebugApi.GetAbsoluteAddress(relAddress); if (absAddress.Address < 0 || !absAddress.Type.SupportsLabels()) { return; } address = (uint)absAddress.Address; memType = absAddress.Type; } CodeLabel label = LabelManager.GetLabel(address, memType); if (label == null) { label = new CodeLabel() { Address = address, MemoryType = memType }; } ctrlLabelList.EditLabel(label); }
private void lstLabels_SelectedIndexChanged(object sender, EventArgs e) { mnuDelete.Enabled = lstLabels.SelectedIndices.Count > 0; mnuEdit.Enabled = lstLabels.SelectedIndices.Count == 1; mnuFindOccurrences.Enabled = lstLabels.SelectedIndices.Count == 1; mnuAddToWatch.Enabled = lstLabels.SelectedIndices.Count == 1; mnuAddBreakpoint.Enabled = lstLabels.SelectedIndices.Count == 1; if (lstLabels.SelectedIndices.Count == 1) { ListViewItem item = GetSelectedItem(); bool availableInCpuMemory = (int)item.Tag >= 0; mnuViewInCpuMemory.Enabled = availableInCpuMemory; CodeLabel label = (CodeLabel)item.SubItems[1].Tag; if (label.AddressType != AddressType.Register && label.AddressType != AddressType.InternalRam) { mnuViewInMemoryType.Text = "View in " + ResourceHelper.GetEnumText(label.AddressType); mnuViewInMemoryType.Visible = true; } else { mnuViewInMemoryType.Visible = false; } } else { mnuViewInCpuMemory.Enabled = false; mnuViewInMemoryType.Visible = false; } }
private string GetFunctionName(int relSubEntryAddr, StackFrameFlags flags) { if (relSubEntryAddr < 0) { return("[bottom of stack]"); } CodeLabel label = relSubEntryAddr >= 0 ? LabelManager.GetLabel(new AddressInfo() { Address = relSubEntryAddr, Type = _cpuType.ToMemoryType() }) : null; if (label != null) { return(label.Label + " ($" + relSubEntryAddr.ToString(_format) + ")"); } else if (flags == StackFrameFlags.Nmi) { return("[nmi] $" + relSubEntryAddr.ToString(_format)); } else if (flags == StackFrameFlags.Irq) { return("[irq] $" + relSubEntryAddr.ToString(_format)); } return("$" + relSubEntryAddr.ToString(_format)); }
public void UpdateLabelListAddresses() { bool needUpdate = false; foreach (ListViewItem item in _listItems) { CodeLabel label = (CodeLabel)item.Tag; Int32 relativeAddress = label.GetRelativeAddress(_cpuType).Address; if (relativeAddress != (Int32)item.SubItems[1].Tag) { needUpdate = true; if (relativeAddress >= 0) { item.SubItems[1].Text = "$" + relativeAddress.ToString("X4"); } else { item.SubItems[1].Text = "[n/a]"; } item.SubItems[1].Tag = relativeAddress; } } if (needUpdate) { SortItems(); } }
private void mnuDelete_Click(object sender, EventArgs e) { if (lstLabels.SelectedIndices.Count > 0) { int topIndex = lstLabels.TopItem.Index; int lastSelectedIndex = lstLabels.SelectedIndices[lstLabels.SelectedIndices.Count - 1]; List <int> selectedIndexes = new List <int>(lstLabels.SelectedIndices.Cast <int>().ToList()); for (int i = selectedIndexes.Count - 1; i >= 0; i--) { CodeLabel label = (CodeLabel)_listItems[selectedIndexes[i]].SubItems[1].Tag; LabelManager.DeleteLabel(label, i == 0); } //Reposition scroll bar and selected/focused item if (lstLabels.Items.Count > topIndex) { lstLabels.TopItem = lstLabels.Items[topIndex]; } if (lastSelectedIndex < lstLabels.Items.Count) { lstLabels.Items[lastSelectedIndex].Selected = true; } else if (lstLabels.Items.Count > 0) { lstLabels.Items[lstLabels.Items.Count - 1].Selected = true; } if (lstLabels.SelectedIndices.Count > 0) { GetSelectedItem().Focused = true; } } }
protected override void EmitWrite(CompilerContext ctx, Local valueFrom) { using (Local local = ctx.GetLocalWithValue(this.ExpectedType, valueFrom)) { MethodInfo info; MethodInfo info2; MethodInfo method = this.GetEnumeratorInfo(ctx.Model, out info, out info2); Type returnType = method.ReturnType; bool writePacked = this.WritePacked; using (Local local2 = new Local(ctx, returnType)) { using (Local local3 = writePacked ? new Local(ctx, ctx.MapType(typeof(SubItemToken))) : null) { if (writePacked) { ctx.LoadValue(this.fieldNumber); ctx.LoadValue(2); ctx.LoadReaderWriter(); ctx.EmitCall(ctx.MapType(typeof(ProtoWriter)).GetMethod("WriteFieldHeader")); ctx.LoadValue(local); ctx.LoadReaderWriter(); ctx.EmitCall(ctx.MapType(typeof(ProtoWriter)).GetMethod("StartSubItem")); ctx.StoreValue(local3); ctx.LoadValue(this.fieldNumber); ctx.LoadReaderWriter(); ctx.EmitCall(ctx.MapType(typeof(ProtoWriter)).GetMethod("SetPackedField")); } ctx.LoadAddress(local, this.ExpectedType); ctx.EmitCall(method); ctx.StoreValue(local2); using (ctx.Using(local2)) { CodeLabel label = ctx.DefineLabel(); CodeLabel label2 = ctx.DefineLabel(); ctx.Branch(label2, false); ctx.MarkLabel(label); ctx.LoadAddress(local2, returnType); ctx.EmitCall(info2); Type expectedType = base.Tail.ExpectedType; if ((expectedType != ctx.MapType(typeof(object))) && (info2.ReturnType == ctx.MapType(typeof(object)))) { ctx.CastFromObject(expectedType); } base.Tail.EmitWrite(ctx, null); ctx.MarkLabel(label2); ctx.LoadAddress(local2, returnType); ctx.EmitCall(info); ctx.BranchIfTrue(label, false); } if (writePacked) { ctx.LoadValue(local3); ctx.LoadReaderWriter(); ctx.EmitCall(ctx.MapType(typeof(ProtoWriter)).GetMethod("EndSubItem")); } } } } }
public PasswordRecoveryView() { InitializeComponent(); Caption.Background = ShellView.CaptionBrush; Loaded += (sender, args) => CodeLabel.Focus(); }
protected override void OnThisTierChanged(ResizingTier obj) { if (labelCache == null) { labelCache = GetComponent <CodeLabel>(); } labelCache.OnTierChanged(); }
private void mnuEdit_Click(object sender, EventArgs e) { if (lstLabels.SelectedIndices.Count > 0) { CodeLabel label = (CodeLabel)GetSelectedItem().SubItems[1].Tag; EditLabel(label.Address, label.AddressType); } }
private void mnuAddToWatch_Click(object sender, EventArgs e) { if (lstLabels.SelectedIndices.Count > 0) { CodeLabel label = (CodeLabel)GetSelectedItem().SubItems[1].Tag; WatchManager.AddWatch("[" + label.Label + "]"); } }
public static void EditComment(UInt32 address, AddressType type) { string autoName = "C" + address.ToString("X4"); CodeLabel existingLabel = LabelManager.GetLabel(address, type); CodeLabel newLabel = new CodeLabel() { Address = existingLabel?.Address ?? address, AddressType = existingLabel?.AddressType ?? type, Label = existingLabel?.Label, Comment = existingLabel?.Comment, Length = existingLabel?.Length ?? 1 }; if (existingLabel == null) { newLabel.Label = autoName; } bool isMultiLine = false; if (existingLabel != null && existingLabel.Comment.Contains("\r\n")) { isMultiLine = true; } if (isMultiLine) { frmEditLabel frm = new frmEditLabel(newLabel, existingLabel, true); if (frm.ShowDialog() == DialogResult.OK) { bool empty = string.IsNullOrWhiteSpace(newLabel.Comment) && newLabel.Label == autoName; if (existingLabel != null) { LabelManager.DeleteLabel(existingLabel, empty); } if (!empty) { LabelManager.SetLabel(newLabel.Address, newLabel.AddressType, newLabel.Label, newLabel.Comment, true, CodeLabelFlags.None, newLabel.Length); } } } else { frmEditComment frm = new frmEditComment(newLabel, existingLabel); if (frm.ShowDialog() == DialogResult.OK) { bool empty = string.IsNullOrWhiteSpace(newLabel.Comment) && newLabel.Label == autoName; if (existingLabel != null) { LabelManager.DeleteLabel(existingLabel, empty); } if (!empty) { LabelManager.SetLabel(newLabel.Address, newLabel.AddressType, newLabel.Label, newLabel.Comment, true, CodeLabelFlags.None, newLabel.Length); } } } }
protected override void EmitRead(CompilerContext ctx, Local valueFrom) { using (Local localWithValue = ctx.GetLocalWithValue(this.expectedType, valueFrom)) { using (Local local = new Local(ctx, ctx.MapType(typeof(SubItemToken)))) { using (Local local1 = new Local(ctx, ctx.MapType(typeof(int)))) { ctx.LoadReaderWriter(); ctx.EmitCall(ctx.MapType(typeof(ProtoReader)).GetMethod("StartSubItem")); ctx.StoreValue(local); CodeLabel codeLabel = ctx.DefineLabel(); CodeLabel codeLabel1 = ctx.DefineLabel(); CodeLabel codeLabel2 = ctx.DefineLabel(); ctx.MarkLabel(codeLabel); ctx.EmitBasicRead("ReadFieldHeader", ctx.MapType(typeof(int))); ctx.CopyValue(); ctx.StoreValue(local1); ctx.LoadValue(1); ctx.BranchIfEqual(codeLabel1, true); ctx.LoadValue(local1); ctx.LoadValue(1); ctx.BranchIfLess(codeLabel2, false); ctx.LoadReaderWriter(); ctx.EmitCall(ctx.MapType(typeof(ProtoReader)).GetMethod("SkipField")); ctx.Branch(codeLabel, true); ctx.MarkLabel(codeLabel1); if (this.Tail.RequiresOldValue) { if (!this.expectedType.IsValueType) { ctx.LoadValue(localWithValue); } else { ctx.LoadAddress(localWithValue, this.expectedType); ctx.EmitCall(this.expectedType.GetMethod("GetValueOrDefault", Helpers.EmptyTypes)); } } this.Tail.EmitRead(ctx, null); if (this.expectedType.IsValueType) { Type type = this.expectedType; Type[] expectedType = new Type[] { this.Tail.ExpectedType }; ctx.EmitCtor(type, expectedType); } ctx.StoreValue(localWithValue); ctx.Branch(codeLabel, false); ctx.MarkLabel(codeLabel2); ctx.LoadValue(local); ctx.LoadReaderWriter(); ctx.EmitCall(ctx.MapType(typeof(ProtoReader)).GetMethod("EndSubItem")); ctx.LoadValue(localWithValue); } } } }
private void RefreshList() { Int64 exclusiveTotal = _exclusiveTime.Sum(); int hexCount = GetMaxAddrHexSize(); lstFunctions.BeginUpdate(); lstFunctions.ListViewItemSorter = null; lstFunctions.Items.Clear(); for (UInt32 i = 0; i < _exclusiveTime.Length; i++) { if (_exclusiveTime[i] > 0) { string functionName; if (i == _exclusiveTime.Length - 2) { functionName = "[Reset]"; } else if (i == _exclusiveTime.Length - 1) { functionName = "[In-Memory Function]"; } else { CodeLabel label = LabelManager.GetLabel((UInt32)i, AddressType.PrgRom); functionName = "$" + i.ToString("X" + hexCount.ToString()); if (label != null) { functionName = label.Label + " (" + functionName + ")"; } } ListViewItem item = lstFunctions.Items.Add(functionName); item.Tag = i; item.SubItems.Add(_callCount[i].ToString()); item.SubItems[1].Tag = _callCount[i]; item.SubItems.Add(_inclusiveTime[i].ToString()); item.SubItems[2].Tag = _inclusiveTime[i]; double ratio = ((double)_inclusiveTime[i] / exclusiveTotal) * 100; item.SubItems.Add(ratio.ToString("0.00")); item.SubItems[3].Tag = (Int64)(ratio * 100); item.SubItems.Add(_exclusiveTime[i].ToString()); item.SubItems[4].Tag = _exclusiveTime[i]; ratio = ((double)_exclusiveTime[i] / exclusiveTotal) * 100; item.SubItems.Add(ratio.ToString("0.00")); item.SubItems[5].Tag = (Int64)(ratio * 100); } } lstFunctions.ListViewItemSorter = new ListComparer(_sortColumn, _sortOrder); lstFunctions.EndUpdate(); }
protected override void EmitRead(CompilerContext ctx, Local valueFrom) { bool flag; SanityCheck(ctx.Model, this.property, base.Tail, out flag, ctx.NonPublic, ctx.AllowInternal(this.property)); if (this.ExpectedType.IsValueType && (valueFrom == null)) { throw new InvalidOperationException("Attempt to mutate struct on the head of the stack; changes would be lost"); } ctx.LoadAddress(valueFrom, this.ExpectedType); if (flag && base.Tail.RequiresOldValue) { ctx.CopyValue(); } if (base.Tail.RequiresOldValue) { ctx.LoadValue(this.property); } Type propertyType = this.property.PropertyType; ctx.ReadNullCheckedTail(propertyType, base.Tail, null); if (flag) { CodeLabel label = new CodeLabel(); CodeLabel label2 = new CodeLabel(); if (!propertyType.IsValueType) { ctx.CopyValue(); label = ctx.DefineLabel(); label2 = ctx.DefineLabel(); ctx.BranchIfFalse(label, true); } if (this.shadowSetter == null) { ctx.StoreValue(this.property); } else { ctx.EmitCall(this.shadowSetter); } if (!propertyType.IsValueType) { ctx.Branch(label2, true); ctx.MarkLabel(label); ctx.DiscardValue(); ctx.DiscardValue(); ctx.MarkLabel(label2); } } else if (base.Tail.ReturnsValue) { ctx.DiscardValue(); } }
private void mnuViewInMemoryType_Click(object sender, EventArgs e) { if (lstLabels.SelectedIndices.Count == 1) { CodeLabel label = GetSelectedLabel(); if (label.MemoryType != SnesMemoryType.Register) { DebugWindowManager.OpenMemoryViewer(label.GetAbsoluteAddress()); } } }
private void mnuViewInMemoryType_Click(object sender, EventArgs e) { if (lstLabels.SelectedIndices.Count == 1) { ListViewItem item = GetSelectedItem(); CodeLabel label = (CodeLabel)item.SubItems[1].Tag; if (label.AddressType != AddressType.Register && label.AddressType != AddressType.InternalRam) { DebugWindowManager.OpenMemoryViewer((int)label.Address, label.AddressType.ToMemoryType()); } } }
private void mnuAdd_Click(object sender, EventArgs e) { CodeLabel newLabel = new CodeLabel() { Address = 0, MemoryType = _cpuType == CpuType.Cpu ? SnesMemoryType.PrgRom : SnesMemoryType.SpcRam, Label = "", Comment = "" }; EditLabel(newLabel); }
private void lstLabels_DoubleClick(object sender, EventArgs e) { if (lstLabels.SelectedIndices.Count > 0) { CodeLabel label = (CodeLabel)GetSelectedLabel(); int relAddress = label.GetRelativeAddress(_cpuType).Address; if (relAddress >= 0) { DebugWindowManager.OpenDebugger(_cpuType).GoToAddress(relAddress); } } }
private void mnuViewInCpuMemory_Click(object sender, EventArgs e) { if (lstLabels.SelectedIndices.Count == 1) { CodeLabel label = GetSelectedLabel(); AddressInfo relAddress = label.GetRelativeAddress(_cpuType); if (relAddress.Address >= 0) { DebugWindowManager.OpenMemoryViewer(relAddress); } } }
protected override void EmitRead(CompilerContext ctx, Local valueFrom) { bool returnList = this.ReturnList; bool castListForAdd = !this.add.DeclaringType.IsAssignableFrom(this.declaredType); using (Local local = this.AppendToCollection ? ctx.GetLocalWithValue(this.ExpectedType, valueFrom) : new Local(ctx, this.declaredType)) { using (Local local2 = (returnList && this.AppendToCollection) ? new Local(ctx, this.ExpectedType) : null) { if (!this.AppendToCollection) { ctx.LoadNullRef(); ctx.StoreValue(local); } else if (returnList) { ctx.LoadValue(local); ctx.StoreValue(local2); } if (this.concreteType != null) { ctx.LoadValue(local); CodeLabel label = ctx.DefineLabel(); ctx.BranchIfTrue(label, true); ctx.EmitCtor(this.concreteType); ctx.StoreValue(local); ctx.MarkLabel(label); } EmitReadList(ctx, local, base.Tail, this.add, this.packedWireType, castListForAdd); if (returnList) { if (this.AppendToCollection) { ctx.LoadValue(local2); ctx.LoadValue(local); CodeLabel label2 = ctx.DefineLabel(); CodeLabel label3 = ctx.DefineLabel(); ctx.BranchIfEqual(label2, true); ctx.LoadValue(local); ctx.Branch(label3, true); ctx.MarkLabel(label2); ctx.LoadNullRef(); ctx.MarkLabel(label3); } else { ctx.LoadValue(local); } } } } }
protected override void EmitRead(CompilerContext ctx, Local valueFrom) { bool flag; PropertyDecorator.SanityCheck(ctx.Model, this.property, this.Tail, out flag, ctx.NonPublic, ctx.AllowInternal(this.property)); if (this.ExpectedType.IsValueType && valueFrom == null) { throw new InvalidOperationException("Attempt to mutate struct on the head of the stack; changes would be lost"); } using (Local localWithValue = ctx.GetLocalWithValue(this.ExpectedType, valueFrom)) { if (this.Tail.RequiresOldValue) { ctx.LoadAddress(localWithValue, this.ExpectedType); ctx.LoadValue(this.property); } Type propertyType = this.property.PropertyType; ctx.ReadNullCheckedTail(propertyType, this.Tail, null); if (flag) { using (Local local = new Local(ctx, this.property.PropertyType)) { ctx.StoreValue(local); CodeLabel codeLabel = new CodeLabel(); if (!propertyType.IsValueType) { codeLabel = ctx.DefineLabel(); ctx.LoadValue(local); ctx.BranchIfFalse(codeLabel, true); } ctx.LoadAddress(localWithValue, this.ExpectedType); ctx.LoadValue(local); if (this.shadowSetter != null) { ctx.EmitCall(this.shadowSetter); } else { ctx.StoreValue(this.property); } if (!propertyType.IsValueType) { ctx.MarkLabel(codeLabel); } } } else if (this.Tail.ReturnsValue) { ctx.DiscardValue(); } } }