iced_x86/formatter/fast/
trait_options_fast_fmt.rs

1// SPDX-License-Identifier: MIT
2// Copyright (C) 2018-present iced project and contributors
3
4use crate::formatter::fast::options::FastFormatterOptions;
5use crate::formatter::fast::trait_options::SpecializedFormatterTraitOptions;
6
7/// Default [`FastFormatter`] options
8///
9/// [`FastFormatter`]: type.FastFormatter.html
10#[allow(missing_copy_implementations)]
11#[allow(missing_debug_implementations)]
12pub struct DefaultFastFormatterTraitOptions;
13
14impl SpecializedFormatterTraitOptions for DefaultFastFormatterTraitOptions {
15	/// DO NOT USE: NOT PART OF THE PUBLIC API
16	const __IS_FAST_FORMATTER: bool = true;
17
18	/// Set to `true` so symbol resolvers can be used
19	const ENABLE_SYMBOL_RESOLVER: bool = true;
20
21	/// Enables support for formatting `db`, `dw`, `dd`, `dq`.
22	///
23	/// For fastest code, this should be *disabled*, not enabled.
24	const ENABLE_DB_DW_DD_DQ: bool = true;
25
26	/// Add a space after the operand separator
27	///
28	/// Default | Value | Example
29	/// --------|-------|--------
30	/// _ | `true` | `mov rax, rcx`
31	/// 👍 | `false` | `mov rax,rcx`
32	///
33	/// # Arguments
34	///
35	/// * `options`: Current formatter options
36	#[must_use]
37	#[inline]
38	fn space_after_operand_separator(options: &FastFormatterOptions) -> bool {
39		options.space_after_operand_separator()
40	}
41
42	/// Show `RIP+displ` or the virtual address
43	///
44	/// Default | Value | Example
45	/// --------|-------|--------
46	/// _ | `true` | `mov eax,[rip+12345678h]`
47	/// 👍 | `false` | `mov eax,[1029384756AFBECDh]`
48	///
49	/// # Arguments
50	///
51	/// * `options`: Current formatter options
52	#[must_use]
53	#[inline]
54	fn rip_relative_addresses(options: &FastFormatterOptions) -> bool {
55		options.rip_relative_addresses()
56	}
57
58	/// Use pseudo instructions
59	///
60	/// Default | Value | Example
61	/// --------|-------|--------
62	/// 👍 | `true` | `vcmpnltsd xmm2,xmm6,xmm3`
63	/// _ | `false` | `vcmpsd xmm2,xmm6,xmm3,5h`
64	///
65	/// # Arguments
66	///
67	/// * `options`: Current formatter options
68	#[must_use]
69	#[inline]
70	fn use_pseudo_ops(options: &FastFormatterOptions) -> bool {
71		options.use_pseudo_ops()
72	}
73
74	/// Show the original value after the symbol name
75	///
76	/// Default | Value | Example
77	/// --------|-------|--------
78	/// _ | `true` | `mov eax,[myfield (12345678)]`
79	/// 👍 | `false` | `mov eax,[myfield]`
80	///
81	/// # Arguments
82	///
83	/// * `options`: Current formatter options
84	#[must_use]
85	#[inline]
86	fn show_symbol_address(options: &FastFormatterOptions) -> bool {
87		options.show_symbol_address()
88	}
89
90	/// Always show the effective segment register. If the option is `false`, only show the segment register if
91	/// there's a segment override prefix.
92	///
93	/// Default | Value | Example
94	/// --------|-------|--------
95	/// _ | `true` | `mov eax,ds:[ecx]`
96	/// 👍 | `false` | `mov eax,[ecx]`
97	///
98	/// # Arguments
99	///
100	/// * `options`: Current formatter options
101	#[must_use]
102	#[inline]
103	fn always_show_segment_register(options: &FastFormatterOptions) -> bool {
104		options.always_show_segment_register()
105	}
106
107	/// Always show the size of memory operands
108	///
109	/// Default | Value | Example | Example
110	/// --------|-------|---------|--------
111	/// _ | `true` | `mov eax,dword ptr [ebx]` | `add byte ptr [eax],0x12`
112	/// 👍 | `false` | `mov eax,[ebx]` | `add byte ptr [eax],0x12`
113	///
114	/// # Arguments
115	///
116	/// * `options`: Current formatter options
117	#[must_use]
118	#[inline]
119	fn always_show_memory_size(options: &FastFormatterOptions) -> bool {
120		options.always_show_memory_size()
121	}
122
123	/// Use uppercase hex digits
124	///
125	/// Default | Value | Example
126	/// --------|-------|--------
127	/// 👍 | `true` | `0xFF`
128	/// _ | `false` | `0xff`
129	///
130	/// # Arguments
131	///
132	/// * `options`: Current formatter options
133	#[must_use]
134	#[inline]
135	fn uppercase_hex(options: &FastFormatterOptions) -> bool {
136		options.uppercase_hex()
137	}
138
139	/// Use a hex prefix (`0x`) or a hex suffix (`h`)
140	///
141	/// Default | Value | Example
142	/// --------|-------|--------
143	/// _ | `true` | `0x5A`
144	/// 👍 | `false` | `5Ah`
145	///
146	/// # Arguments
147	///
148	/// * `options`: Current formatter options
149	#[must_use]
150	#[inline]
151	fn use_hex_prefix(options: &FastFormatterOptions) -> bool {
152		options.use_hex_prefix()
153	}
154}