/* 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 . */ #if (!NO_GAS_FORMATTER || !NO_INTEL_FORMATTER || !NO_MASM_FORMATTER || !NO_NASM_FORMATTER) && !NO_FORMATTER namespace Iced.Intel { /// /// Used by a to write all text /// public abstract class FormatterOutput { /// /// Writes text and text kind /// /// Text, can be an empty string /// Text kind. This value can be identical to the previous value passed to this method. It's /// the responsibility of the implementer to merge any such strings if needed. public abstract void Write(string text, FormatterOutputTextKind kind); /// /// Called just before and just after formatting an operand /// /// Operand number, 0-based. This is a formatter operand and isn't necessarily the same as an instruction operand. /// true if we're about to format the operand, false if we've formatted it public virtual void OnOperand(int operand, bool begin) { } internal void Write(in SymbolResult text) { if ((text.Flags & SymbolFlags.Signed) != 0) Write("-", FormatterOutputTextKind.Operator); Write(text.Text); } internal void Write(in TextInfo text) { var array = text.TextArray; if (array != null) { foreach (var part in array) Write(part.Text, part.Color); } else if (text.Text.Text is string s) Write(s, text.Text.Color); } } } #endif