static FormatterOptions CreateOptions() { var options = FormatterOptions.CreateGas(); options.UppercaseHex = false; return(options); }
public static FormatterOptions ToIcedOptions(this IX86DisassemblySettings settings) { var options = new FormatterOptions(); CopyBase(options, settings); return(options); }
protected void TestOptionsBase(FormatterOptions options) { { int min = int.MaxValue, max = int.MinValue; foreach (var value in ToEnumConverter.GetNumberBaseValues()) { min = Math.Min(min, (int)value); max = Math.Max(max, (int)value); options.NumberBase = value; } Assert.Throws <ArgumentOutOfRangeException>(() => options.NumberBase = (NumberBase)(min - 1)); Assert.Throws <ArgumentOutOfRangeException>(() => options.NumberBase = (NumberBase)(max + 1)); Assert.Throws <ArgumentOutOfRangeException>(() => options.NumberBase = (NumberBase)int.MinValue); Assert.Throws <ArgumentOutOfRangeException>(() => options.NumberBase = (NumberBase)int.MaxValue); } { int min = int.MaxValue, max = int.MinValue; foreach (var value in ToEnumConverter.GetMemorySizeOptionsValues()) { min = Math.Min(min, (int)value); max = Math.Max(max, (int)value); options.MemorySizeOptions = value; } Assert.Throws <ArgumentOutOfRangeException>(() => options.MemorySizeOptions = (MemorySizeOptions)(min - 1)); Assert.Throws <ArgumentOutOfRangeException>(() => options.MemorySizeOptions = (MemorySizeOptions)(max + 1)); Assert.Throws <ArgumentOutOfRangeException>(() => options.MemorySizeOptions = (MemorySizeOptions)int.MinValue); Assert.Throws <ArgumentOutOfRangeException>(() => options.MemorySizeOptions = (MemorySizeOptions)int.MaxValue); } }
protected override void InitializeFormatterOptionsCore(FormatterOptions options) { var gas = (GasFormatterOptions)options; gas.NakedRegisters = GasSettings.NakedRegisters; gas.ShowMnemonicSizeSuffix = GasSettings.ShowMnemonicSizeSuffix; gas.SpaceAfterMemoryOperandComma = GasSettings.SpaceAfterMemoryOperandComma; }
void Verify_default_formatter_options() { var options = FormatterOptions.CreateIntel(); Assert.False(options.UppercasePrefixes); Assert.False(options.UppercaseMnemonics); Assert.False(options.UppercaseRegisters); Assert.False(options.UppercaseKeywords); Assert.False(options.UppercaseDecorators); Assert.False(options.UppercaseAll); Assert.Equal(0, options.FirstOperandCharIndex); Assert.Equal(0, options.TabSize); Assert.False(options.SpaceAfterOperandSeparator); Assert.False(options.SpaceAfterMemoryBracket); Assert.False(options.SpaceBetweenMemoryAddOperators); Assert.False(options.SpaceBetweenMemoryMulOperators); Assert.False(options.ScaleBeforeIndex); Assert.False(options.AlwaysShowScale); Assert.False(options.AlwaysShowSegmentRegister); Assert.False(options.ShowZeroDisplacements); Assert.Null(options.HexPrefix); Assert.Equal("h", options.HexSuffix); Assert.Equal(4, options.HexDigitGroupSize); Assert.Null(options.DecimalPrefix); Assert.Null(options.DecimalSuffix); Assert.Equal(3, options.DecimalDigitGroupSize); Assert.Null(options.OctalPrefix); Assert.Equal("o", options.OctalSuffix); Assert.Equal(4, options.OctalDigitGroupSize); Assert.Null(options.BinaryPrefix); Assert.Equal("b", options.BinarySuffix); Assert.Equal(4, options.BinaryDigitGroupSize); Assert.Null(options.DigitSeparator); Assert.False(options.LeadingZeroes); Assert.True(options.UppercaseHex); Assert.True(options.SmallHexNumbersInDecimal); Assert.True(options.AddLeadingZeroToHexNumbers); Assert.Equal(NumberBase.Hexadecimal, options.NumberBase); Assert.True(options.BranchLeadingZeroes); Assert.False(options.SignedImmediateOperands); Assert.True(options.SignedMemoryDisplacements); Assert.False(options.DisplacementLeadingZeroes); Assert.Equal(MemorySizeOptions.Default, options.MemorySizeOptions); Assert.False(options.RipRelativeAddresses); Assert.True(options.ShowBranchSize); Assert.True(options.UsePseudoOps); Assert.False(options.ShowSymbolAddress); Assert.False(options.PreferST0); Assert.False(options.GasNakedRegisters); Assert.False(options.GasShowMnemonicSizeSuffix); Assert.False(options.GasSpaceAfterMemoryOperandComma); Assert.True(options.MasmAddDsPrefix32); Assert.True(options.MasmSymbolDisplInBrackets); Assert.True(options.MasmDisplInBrackets); Assert.False(options.NasmShowSignExtendedImmediateSize); }
public static void Initialize(FormatterOptions options, OptionsProps property, object value) { switch (property) { case OptionsProps.AddLeadingZeroToHexNumbers: options.AddLeadingZeroToHexNumbers = (bool)value; break; case OptionsProps.AlwaysShowScale: options.AlwaysShowScale = (bool)value; break; case OptionsProps.AlwaysShowSegmentRegister: options.AlwaysShowSegmentRegister = (bool)value; break; case OptionsProps.BinaryDigitGroupSize: options.BinaryDigitGroupSize = (int)value; break; case OptionsProps.BinaryPrefix: options.BinaryPrefix = (string)value; break; case OptionsProps.BinarySuffix: options.BinarySuffix = (string)value; break; case OptionsProps.BranchLeadingZeroes: options.BranchLeadingZeroes = (bool)value; break; case OptionsProps.DecimalDigitGroupSize: options.DecimalDigitGroupSize = (int)value; break; case OptionsProps.DecimalPrefix: options.DecimalPrefix = (string)value; break; case OptionsProps.DecimalSuffix: options.DecimalSuffix = (string)value; break; case OptionsProps.DigitSeparator: options.DigitSeparator = (string)value; break; case OptionsProps.DisplacementLeadingZeroes: options.DisplacementLeadingZeroes = (bool)value; break; case OptionsProps.FirstOperandCharIndex: options.FirstOperandCharIndex = (int)value; break; case OptionsProps.GasNakedRegisters: options.GasNakedRegisters = (bool)value; break; case OptionsProps.GasShowMnemonicSizeSuffix: options.GasShowMnemonicSizeSuffix = (bool)value; break; case OptionsProps.GasSpaceAfterMemoryOperandComma: options.GasSpaceAfterMemoryOperandComma = (bool)value; break; case OptionsProps.HexDigitGroupSize: options.HexDigitGroupSize = (int)value; break; case OptionsProps.HexPrefix: options.HexPrefix = (string)value; break; case OptionsProps.HexSuffix: options.HexSuffix = (string)value; break; case OptionsProps.LeadingZeroes: options.LeadingZeroes = (bool)value; break; case OptionsProps.MasmAddDsPrefix32: options.MasmAddDsPrefix32 = (bool)value; break; case OptionsProps.MemorySizeOptions: options.MemorySizeOptions = (MemorySizeOptions)value; break; case OptionsProps.NasmShowSignExtendedImmediateSize: options.NasmShowSignExtendedImmediateSize = (bool)value; break; case OptionsProps.NumberBase: options.NumberBase = (NumberBase)value; break; case OptionsProps.OctalDigitGroupSize: options.OctalDigitGroupSize = (int)value; break; case OptionsProps.OctalPrefix: options.OctalPrefix = (string)value; break; case OptionsProps.OctalSuffix: options.OctalSuffix = (string)value; break; case OptionsProps.PreferST0: options.PreferST0 = (bool)value; break; case OptionsProps.RipRelativeAddresses: options.RipRelativeAddresses = (bool)value; break; case OptionsProps.ScaleBeforeIndex: options.ScaleBeforeIndex = (bool)value; break; case OptionsProps.ShowBranchSize: options.ShowBranchSize = (bool)value; break; case OptionsProps.ShowSymbolAddress: options.ShowSymbolAddress = (bool)value; break; case OptionsProps.ShowZeroDisplacements: options.ShowZeroDisplacements = (bool)value; break; case OptionsProps.SignedImmediateOperands: options.SignedImmediateOperands = (bool)value; break; case OptionsProps.SignedMemoryDisplacements: options.SignedMemoryDisplacements = (bool)value; break; case OptionsProps.SmallHexNumbersInDecimal: options.SmallHexNumbersInDecimal = (bool)value; break; case OptionsProps.SpaceAfterMemoryBracket: options.SpaceAfterMemoryBracket = (bool)value; break; case OptionsProps.SpaceAfterOperandSeparator: options.SpaceAfterOperandSeparator = (bool)value; break; case OptionsProps.SpaceBetweenMemoryAddOperators: options.SpaceBetweenMemoryAddOperators = (bool)value; break; case OptionsProps.SpaceBetweenMemoryMulOperators: options.SpaceBetweenMemoryMulOperators = (bool)value; break; case OptionsProps.TabSize: options.TabSize = (int)value; break; case OptionsProps.UppercaseAll: options.UppercaseAll = (bool)value; break; case OptionsProps.UppercaseDecorators: options.UppercaseDecorators = (bool)value; break; case OptionsProps.UppercaseHex: options.UppercaseHex = (bool)value; break; case OptionsProps.UppercaseKeywords: options.UppercaseKeywords = (bool)value; break; case OptionsProps.UppercaseMnemonics: options.UppercaseMnemonics = (bool)value; break; case OptionsProps.UppercasePrefixes: options.UppercasePrefixes = (bool)value; break; case OptionsProps.UppercaseRegisters: options.UppercaseRegisters = (bool)value; break; case OptionsProps.UsePseudoOps: options.UsePseudoOps = (bool)value; break; case OptionsProps.IP: break; default: throw new InvalidOperationException(); } }
static void CopyBase(FormatterOptions options, IX86DisassemblySettings settings) { options.OctalPrefix = settings.OctalPrefix; options.OctalSuffix = settings.OctalSuffix; options.OctalDigitGroupSize = settings.OctalDigitGroupSize; options.BinaryPrefix = settings.BinaryPrefix; options.BinarySuffix = settings.BinarySuffix; options.BinaryDigitGroupSize = settings.BinaryDigitGroupSize; options.DigitSeparator = settings.DigitSeparator; options.LeadingZeroes = settings.LeadingZeroes; options.UppercaseHex = settings.UppercaseHex; options.SmallHexNumbersInDecimal = settings.SmallHexNumbersInDecimal; options.AddLeadingZeroToHexNumbers = settings.AddLeadingZeroToHexNumbers; options.NumberBase = ToIcedNumberBase(settings.NumberBase); options.BranchLeadingZeroes = settings.BranchLeadingZeroes; options.SignedImmediateOperands = settings.SignedImmediateOperands; options.SignedMemoryDisplacements = settings.SignedMemoryDisplacements; options.DisplacementLeadingZeroes = settings.DisplacementLeadingZeroes; options.MemorySizeOptions = ToMemorySizeOptions(settings.MemorySizeOptions); options.RipRelativeAddresses = settings.RipRelativeAddresses; options.DecimalDigitGroupSize = settings.DecimalDigitGroupSize; options.ShowBranchSize = settings.ShowBranchSize; options.DecimalSuffix = settings.DecimalSuffix; options.HexDigitGroupSize = settings.HexDigitGroupSize; options.UppercasePrefixes = settings.UppercasePrefixes; options.UppercaseMnemonics = settings.UppercaseMnemonics; options.UppercaseRegisters = settings.UppercaseRegisters; options.UppercaseKeywords = settings.UppercaseKeywords; options.UppercaseDecorators = settings.UppercaseDecorators; options.UppercaseAll = settings.UppercaseAll; options.FirstOperandCharIndex = settings.FirstOperandCharIndex; options.TabSize = settings.TabSize; options.SpaceAfterOperandSeparator = settings.SpaceAfterOperandSeparator; options.SpaceAfterMemoryBracket = settings.SpaceAfterMemoryBracket; options.SpaceBetweenMemoryAddOperators = settings.SpaceBetweenMemoryAddOperators; options.SpaceBetweenMemoryMulOperators = settings.SpaceBetweenMemoryMulOperators; options.ScaleBeforeIndex = settings.ScaleBeforeIndex; options.AlwaysShowScale = settings.AlwaysShowScale; options.AlwaysShowSegmentRegister = settings.AlwaysShowSegmentRegister; options.ShowZeroDisplacements = settings.ShowZeroDisplacements; options.HexPrefix = settings.HexPrefix; options.HexSuffix = settings.HexSuffix; options.DecimalPrefix = settings.DecimalPrefix; options.UsePseudoOps = settings.UsePseudoOps; options.ShowSymbolAddress = settings.ShowSymbolAddress; options.GasNakedRegisters = settings.GasNakedRegisters; options.GasShowMnemonicSizeSuffix = settings.GasShowMnemonicSizeSuffix; options.GasSpaceAfterMemoryOperandComma = settings.GasSpaceAfterMemoryOperandComma; options.MasmAddDsPrefix32 = settings.MasmAddDsPrefix32; options.MasmDisplInBrackets = settings.MasmDisplInBrackets; options.MasmSymbolDisplInBrackets = settings.MasmSymbolDisplInBrackets; options.NasmShowSignExtendedImmediateSize = settings.NasmShowSignExtendedImmediateSize; }
static FormatterOptions CreateOptions() { var options = FormatterOptions.CreateNasm(); options.UppercaseHex = false; options.HexPrefix = "0x"; options.HexSuffix = null; options.OctalPrefix = "0o"; options.OctalSuffix = null; options.BinaryPrefix = "0b"; options.BinarySuffix = null; return(options); }
static FormatterOptions CreateOptions() { var options = FormatterOptions.CreateIntel(); options.UppercaseHex = false; options.HexPrefix = "0x"; options.HexSuffix = null; options.OctalPrefix = "0o"; options.OctalSuffix = null; options.BinaryPrefix = "0b"; options.BinarySuffix = null; options.SpaceAfterOperandSeparator = true; return(options); }
static void CopyBase(FormatterOptions options, IDisassemblySettings settings) { options.OctalPrefix = settings.OctalPrefix; options.OctalSuffix = settings.OctalSuffix; options.OctalDigitGroupSize = settings.OctalDigitGroupSize; options.BinaryPrefix = settings.BinaryPrefix; options.BinarySuffix = settings.BinarySuffix; options.BinaryDigitGroupSize = settings.BinaryDigitGroupSize; options.DigitSeparator = settings.DigitSeparator; options.AddDigitSeparators = settings.AddDigitSeparators; options.ShortNumbers = settings.ShortNumbers; options.UpperCaseHex = settings.UpperCaseHex; options.SmallHexNumbersInDecimal = settings.SmallHexNumbersInDecimal; options.AddLeadingZeroToHexNumbers = settings.AddLeadingZeroToHexNumbers; options.NumberBase = ToIcedNumberBase(settings.NumberBase); options.ShortBranchNumbers = settings.ShortBranchNumbers; options.SignedImmediateOperands = settings.SignedImmediateOperands; options.SignedMemoryDisplacements = settings.SignedMemoryDisplacements; options.SignExtendMemoryDisplacements = settings.SignExtendMemoryDisplacements; options.AlwaysShowMemorySize = settings.AlwaysShowMemorySize; options.RipRelativeAddresses = settings.RipRelativeAddresses; options.DecimalDigitGroupSize = settings.DecimalDigitGroupSize; options.ShowBranchSize = settings.ShowBranchSize; options.DecimalSuffix = settings.DecimalSuffix; options.HexDigitGroupSize = settings.HexDigitGroupSize; options.UpperCasePrefixes = settings.UpperCasePrefixes; options.UpperCaseMnemonics = settings.UpperCaseMnemonics; options.UpperCaseRegisters = settings.UpperCaseRegisters; options.UpperCaseKeywords = settings.UpperCaseKeywords; options.UpperCaseOther = settings.UpperCaseOther; options.UpperCaseAll = settings.UpperCaseAll; options.FirstOperandCharIndex = settings.FirstOperandCharIndex; options.TabSize = settings.TabSize; options.SpaceAfterOperandSeparator = settings.SpaceAfterOperandSeparator; options.SpaceAfterMemoryOpenBracket = settings.SpaceAfterMemoryBracket; options.SpaceBeforeMemoryCloseBracket = settings.SpaceAfterMemoryBracket; options.SpacesBetweenMemoryAddOperators = settings.SpacesBetweenMemoryAddOperators; options.SpacesBetweenMemoryMulOperators = settings.SpacesBetweenMemoryMulOperators; options.ScaleBeforeIndex = settings.ScaleBeforeIndex; options.AlwaysShowScale = settings.AlwaysShowScale; options.AlwaysShowSegmentRegister = settings.AlwaysShowSegmentRegister; options.ShowZeroDisplacements = settings.ShowZeroDisplacements; options.HexPrefix = settings.HexPrefix; options.HexSuffix = settings.HexSuffix; options.DecimalPrefix = settings.DecimalPrefix; options.UsePseudoOps = settings.UsePseudoOps; }
/// <summary> /// Reformat all comments between the specified start and end point. Comments that start /// within the range, even if they overlap the end are included. /// </summary> /// <param name="textDocument">The text document.</param> /// <param name="start">The start point.</param> /// <param name="end">The end point.</param> public bool FormatComments(TextDocument textDocument, EditPoint start, EditPoint end) { bool foundComments = false; var options = FormatterOptions .FromSettings(Settings.Default) .Set(o => { o.TabSize = textDocument.TabSize; o.IgnoreTokens = CodeCommentHelper .GetTaskListTokens(_package) .Concat(Settings.Default.Formatting_IgnoreLinesStartingWith.Cast <string>()) .ToArray(); }); while (start.Line <= end.Line) { if (CodeCommentHelper.IsCommentLine(start)) { var comment = new CodeComment(start, options); if (comment.IsValid) { comment.Format(); foundComments = true; } if (comment.EndPoint != null) { start = comment.EndPoint.CreateEditPoint(); } } if (start.Line == textDocument.EndPoint.Line) { break; } start.LineDown(); start.StartOfLine(); } return(foundComments); }
FormatterOptions GetFormatterOptions(DbgBreakpointLocationFormatterOptions options) { FormatterOptions flags = 0; if ((options & DbgBreakpointLocationFormatterOptions.ModuleNames) != 0) { flags |= FormatterOptions.ShowModuleNames; } if ((options & DbgBreakpointLocationFormatterOptions.ParameterTypes) != 0) { flags |= FormatterOptions.ShowParameterTypes; } if ((options & DbgBreakpointLocationFormatterOptions.ParameterNames) != 0) { flags |= FormatterOptions.ShowParameterNames; } if ((options & DbgBreakpointLocationFormatterOptions.DeclaringTypes) != 0) { flags |= FormatterOptions.ShowDeclaringTypes; } if ((options & DbgBreakpointLocationFormatterOptions.ReturnTypes) != 0) { flags |= FormatterOptions.ShowReturnTypes; } if ((options & DbgBreakpointLocationFormatterOptions.Namespaces) != 0) { flags |= FormatterOptions.ShowNamespaces; } if ((options & DbgBreakpointLocationFormatterOptions.IntrinsicTypeKeywords) != 0) { flags |= FormatterOptions.ShowIntrinsicTypeKeywords; } if ((options & DbgBreakpointLocationFormatterOptions.DigitSeparators) != 0) { flags |= FormatterOptions.DigitSeparators; } if ((options & DbgBreakpointLocationFormatterOptions.Decimal) != 0) { flags |= FormatterOptions.UseDecimal; } return(flags); }
public override void Write(ITextColorWriter output, IMemberRef member, FormatterOptions flags) => new VisualBasicFormatter(output, flags, null).Write(member);
protected override void InitializeFormatterOptionsCore(FormatterOptions options) { var nasm = (NasmFormatterOptions)options; nasm.ShowSignExtendedImmediateSize = NasmSettings.ShowSignExtendedImmediateSize; }
public void Write(ITextColorWriter output, IMemberRef member, FormatterOptions flags) => implementation.Write(output, member, flags);
public virtual void Write(ITextColorWriter output, IMemberRef member, FormatterOptions flags) => new CSharpFormatter(output, flags, null).Write(member);
protected override void InitializeFormatterOptionsCore(FormatterOptions options) { }
public ConnegAttribute(FormatterOptions formatters) { _formatters = formatters; }
public static FormatterString GetMnemonicCC(FormatterOptions options, int ccIndex, FormatterString[] mnemonics) { int index; switch (ccIndex) { case 0: // o Debug.Assert(mnemonics.Length == 1); index = 0; break; case 1: // no Debug.Assert(mnemonics.Length == 1); index = 0; break; case 2: // b, c, nae Debug.Assert(mnemonics.Length == 3); index = (int)options.CC_b; break; case 3: // ae, nb, nc Debug.Assert(mnemonics.Length == 3); index = (int)options.CC_ae; break; case 4: // e, z Debug.Assert(mnemonics.Length == 2); index = (int)options.CC_e; break; case 5: // ne, nz Debug.Assert(mnemonics.Length == 2); index = (int)options.CC_ne; break; case 6: // be, na Debug.Assert(mnemonics.Length == 2); index = (int)options.CC_be; break; case 7: // a, nbe Debug.Assert(mnemonics.Length == 2); index = (int)options.CC_a; break; case 8: // s Debug.Assert(mnemonics.Length == 1); index = 0; break; case 9: // ns Debug.Assert(mnemonics.Length == 1); index = 0; break; case 10: // p, pe Debug.Assert(mnemonics.Length == 2); index = (int)options.CC_p; break; case 11: // np, po Debug.Assert(mnemonics.Length == 2); index = (int)options.CC_np; break; case 12: // l, nge Debug.Assert(mnemonics.Length == 2); index = (int)options.CC_l; break; case 13: // ge, nl Debug.Assert(mnemonics.Length == 2); index = (int)options.CC_ge; break; case 14: // le, ng Debug.Assert(mnemonics.Length == 2); index = (int)options.CC_le; break; case 15: // g, nle Debug.Assert(mnemonics.Length == 2); index = (int)options.CC_g; break; default: throw new InvalidOperationException(); } Debug.Assert((uint)index < (uint)mnemonics.Length); return(mnemonics[index]); }
public static void Initialize(FormatterOptions options, IEnumerable <(OptionsProps property, object value)> properties)
public void TestOptions() { var options = FormatterOptions.CreateGas(); TestOptionsBase(options); }
static FormatterOptions CreateOptions() => FormatterOptions.CreateMasm();