iced/Iced/Intel/Formatter.cs

85 lines
3.2 KiB
C#

/*
Copyright (C) 2018 de4dot@gmail.com
This file is part of Iced.
Iced is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Iced is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with Iced. If not, see <https://www.gnu.org/licenses/>.
*/
#if (!NO_GAS_FORMATTER || !NO_INTEL_FORMATTER || !NO_MASM_FORMATTER || !NO_NASM_FORMATTER) && !NO_FORMATTER
namespace Iced.Intel {
/// <summary>
/// Formats decoded instructions
/// </summary>
public abstract class Formatter {
/// <summary>
/// Gets the formatter options
/// </summary>
public abstract FormatterOptions Options { get; }
/// <summary>
/// Formats the mnemonic and any prefixes
/// </summary>
/// <param name="instruction">Instruction</param>
/// <param name="output">Output</param>
public abstract void FormatMnemonic(ref Instruction instruction, FormatterOutput output);
/// <summary>
/// Gets the number of operands that will be formatted. A formatter can add and remove operands
/// </summary>
/// <param name="instruction">Instruction</param>
/// <returns></returns>
public abstract int GetOperandCount(ref Instruction instruction);
/// <summary>
/// Formats an operand. This is a formatter operand and not necessarily a real instruction operand.
/// A formatter can add and remove operands.
/// </summary>
/// <param name="instruction">Instruction</param>
/// <param name="output">Output</param>
/// <param name="operand">Operand number, 0-based. This is a formatter operand and isn't necessarily the same as an instruction operand.
/// See <see cref="GetOperandCount(ref Instruction)"/></param>
public abstract void FormatOperand(ref Instruction instruction, FormatterOutput output, int operand);
/// <summary>
/// Formats an operand separator
/// </summary>
/// <param name="instruction">Instruction</param>
/// <param name="output">Output</param>
public abstract void FormatOperandSeparator(ref Instruction instruction, FormatterOutput output);
/// <summary>
/// Formats all operands
/// </summary>
/// <param name="instruction">Instruction</param>
/// <param name="output">Output</param>
public abstract void FormatAllOperands(ref Instruction instruction, FormatterOutput output);
/// <summary>
/// Formats the whole instruction: prefixes, mnemonic, operands
/// </summary>
/// <param name="instruction">Instruction</param>
/// <param name="output">Output</param>
public abstract void Format(ref Instruction instruction, FormatterOutput output);
/// <summary>
/// Formats the whole instruction: prefixes, mnemonic, operands
/// </summary>
/// <param name="instruction">Instruction</param>
/// <param name="output">Output</param>
public void Format(Instruction instruction, FormatterOutput output) => Format(ref instruction, output);
}
}
#endif