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

Method optional_offset32

cranelift/reader/src/parser.rs:813–824  ·  view source on GitHub ↗

Match and consume an optional offset32 immediate. Note that this will match an empty string as an empty offset, and that if an offset is present, it must contain a sign.

(&mut self)

Source from the content-addressed store, hash-verified

811 // Note that this will match an empty string as an empty offset, and that if an offset is
812 // present, it must contain a sign.
813 fn optional_offset32(&mut self) -> ParseResult<Offset32> {
814 if let Some(Token::Integer(text)) = self.token() {
815 if text.starts_with('+') || text.starts_with('-') {
816 self.consume();
817 // Lexer just gives us raw text that looks like an integer.
818 // Parse it as an `Offset32` to check for overflow and other issues.
819 return text.parse().map_err(|e| self.error(e));
820 }
821 }
822 // An offset32 operand can be absent.
823 Ok(Offset32::new(0))
824 }
825
826 // Match and consume an optional offset32 immediate.
827 //

Callers 2

parse_inst_operandsMethod · 0.80

Calls 6

OkFunction · 0.85
tokenMethod · 0.80
newFunction · 0.50
consumeMethod · 0.45
parseMethod · 0.45
errorMethod · 0.45

Tested by

no test coverage detected