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

Method parse_user_func_name

cranelift/reader/src/parser.rs:1281–1311  ·  view source on GitHub ↗

Parse a user-defined function name For example, in a function decl, the parser would be in this state: function ::= "function" * name signature { ... }

(&mut self)

Source from the content-addressed store, hash-verified

1279 // function ::= "function" * name signature { ... }
1280 //
1281 fn parse_user_func_name(&mut self) -> ParseResult<UserFuncName> {
1282 match self.token() {
1283 Some(Token::Name(s)) => {
1284 self.consume();
1285 Ok(UserFuncName::testcase(s))
1286 }
1287 Some(Token::UserRef(namespace)) => {
1288 self.consume();
1289 match self.token() {
1290 Some(Token::Colon) => {
1291 self.consume();
1292 match self.token() {
1293 Some(Token::Integer(index_str)) => {
1294 self.consume();
1295 let index: u32 =
1296 u32::from_str_radix(index_str, 10).map_err(|_| {
1297 self.error("the integer given overflows the u32 type")
1298 })?;
1299 Ok(UserFuncName::user(namespace, index))
1300 }
1301 _ => err!(self.loc, "expected integer"),
1302 }
1303 }
1304 _ => {
1305 err!(self.loc, "expected user function name in the form uX:Y")
1306 }
1307 }
1308 }
1309 _ => err!(self.loc, "expected external name"),
1310 }
1311 }
1312
1313 // Parse an external name.
1314 //

Callers 1

parse_functionMethod · 0.80

Calls 4

OkFunction · 0.85
tokenMethod · 0.80
consumeMethod · 0.45
errorMethod · 0.45

Tested by

no test coverage detected