MCPcopy Create free account
hub / github.com/bytecodealliance/wasmtime / set_by_name

Method set_by_name

cranelift/codegen/src/ir/memflags.rs:208–233  ·  view source on GitHub ↗

Set a flag bit by name. Returns true if the flag was found and set, false for an unknown flag name. # Errors Returns an error message if the `name` is known but couldn't be applied due to it being a semantic error.

(&mut self, name: &str)

Source from the content-addressed store, hash-verified

206 /// Returns an error message if the `name` is known but couldn't be applied
207 /// due to it being a semantic error.
208 pub fn set_by_name(&mut self, name: &str) -> Result<bool, &'static str> {
209 *self = match name {
210 "notrap" => self.with_trap_code(None),
211 "aligned" => self.with_aligned(),
212 "readonly" => self.with_readonly(),
213 "little" => {
214 if self.flags.explicit_endianness() == Some(Endianness::Big) {
215 return Err("cannot set both big and little endian bits");
216 }
217 self.with_endianness(Endianness::Little)
218 }
219 "big" => {
220 if self.flags.explicit_endianness() == Some(Endianness::Little) {
221 return Err("cannot set both big and little endian bits");
222 }
223 self.with_endianness(Endianness::Big)
224 }
225 "can_move" => self.with_can_move(),
226
227 other => match TrapCode::from_str(other) {
228 Ok(code) => self.with_trap_code(Some(code)),
229 Err(()) => return Ok(false),
230 },
231 };
232 Ok(true)
233 }
234
235 /// Return endianness of the memory access. This will return the endianness
236 /// explicitly specified by the flags if any, and will default to the native

Callers 1

optional_memflagsMethod · 0.80

Calls 7

OkFunction · 0.85
with_trap_codeMethod · 0.45
with_alignedMethod · 0.45
with_readonlyMethod · 0.45
explicit_endiannessMethod · 0.45
with_endiannessMethod · 0.45
with_can_moveMethod · 0.45

Tested by

no test coverage detected