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

Method parse_constant_decl

cranelift/reader/src/parser.rs:1923–1938  ·  view source on GitHub ↗

Parse a constant decl. constant-decl ::= * Constant(c) "=" ty? "[" literal {"," literal} "]"

(&mut self)

Source from the content-addressed store, hash-verified

1921 //
1922 // constant-decl ::= * Constant(c) "=" ty? "[" literal {"," literal} "]"
1923 fn parse_constant_decl(&mut self) -> ParseResult<(Constant, ConstantData)> {
1924 let name = self.match_constant()?;
1925 self.match_token(Token::Equal, "expected '=' in constant decl")?;
1926 let data = if let Some(Token::Type(_)) = self.token() {
1927 let ty = self.match_type("expected type of constant")?;
1928 self.match_uimm128(ty)
1929 } else {
1930 self.match_hexadecimal_constant("expected an immediate hexadecimal operand")
1931 }?;
1932
1933 // Collect any trailing comments.
1934 self.token();
1935 self.claim_gathered_comments(name);
1936
1937 Ok((name, data))
1938 }
1939
1940 // Parse an alias region decl
1941 //

Callers 1

parse_preambleMethod · 0.80

Calls 8

OkFunction · 0.85
match_constantMethod · 0.80
match_tokenMethod · 0.80
tokenMethod · 0.80
match_typeMethod · 0.80
match_uimm128Method · 0.80

Tested by

no test coverage detected