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

Method parse_spec_bit_vector

cranelift/isle/isle/src/parser.rs:568–588  ·  view source on GitHub ↗
(&mut self)

Source from the content-addressed store, hash-verified

566 }
567
568 fn parse_spec_bit_vector(&mut self) -> Result<(i128, i8)> {
569 let pos = self.pos();
570 let s = self.expect_symbol()?;
571 if let Some(s) = s.strip_prefix("#b") {
572 match i128::from_str_radix(s, 2) {
573 Ok(i) => Ok((i, s.len() as i8)),
574 Err(_) => Err(self.error(pos, "Not a constant binary bit vector".to_string())),
575 }
576 } else if let Some(s) = s.strip_prefix("#x") {
577 match i128::from_str_radix(s, 16) {
578 Ok(i) => Ok((i, (s.len() as i8) * 4)),
579 Err(_) => Err(self.error(pos, "Not a constant hex bit vector".to_string())),
580 }
581 } else {
582 Err(self.error(
583 pos,
584 "Not a constant bit vector; must start with `#x` (hex) or `#b` (binary)"
585 .to_string(),
586 ))
587 }
588 }
589
590 fn parse_spec_bool(&mut self) -> Result<bool> {
591 let pos = self.pos();

Callers 1

parse_spec_exprMethod · 0.80

Calls 6

OkFunction · 0.85
expect_symbolMethod · 0.80
posMethod · 0.45
lenMethod · 0.45
errorMethod · 0.45
to_stringMethod · 0.45

Tested by

no test coverage detected