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

Method parse_function_body

cranelift/reader/src/parser.rs:2004–2033  ·  view source on GitHub ↗

Parse a function body, add contents to `ctx`. function-body ::= * { extended-basic-block }

(&mut self, ctx: &mut Context)

Source from the content-addressed store, hash-verified

2002 // function-body ::= * { extended-basic-block }
2003 //
2004 fn parse_function_body(&mut self, ctx: &mut Context) -> ParseResult<()> {
2005 while self.token() != Some(Token::RBrace) {
2006 self.parse_basic_block(ctx)?;
2007 }
2008
2009 // Now that we've seen all defined values in the function, ensure that
2010 // all references refer to a definition.
2011 for block in &ctx.function.layout {
2012 for inst in ctx.function.layout.block_insts(block) {
2013 for value in ctx.function.dfg.inst_values(inst) {
2014 if !ctx.map.contains_value(value) {
2015 return err!(
2016 ctx.map.location(AnyEntity::Inst(inst)).unwrap(),
2017 "undefined operand value {}",
2018 value
2019 );
2020 }
2021 }
2022 }
2023 }
2024
2025 for alias in &ctx.aliases {
2026 if !ctx.function.dfg.set_alias_type_for_parser(*alias) {
2027 let loc = ctx.map.location(AnyEntity::Value(*alias)).unwrap();
2028 return err!(loc, "alias cycle involving {}", alias);
2029 }
2030 }
2031
2032 Ok(())
2033 }
2034
2035 // Parse a basic block, add contents to `ctx`.
2036 //

Callers 1

parse_functionMethod · 0.80

Calls 10

OkFunction · 0.85
tokenMethod · 0.80
parse_basic_blockMethod · 0.80
block_instsMethod · 0.80
inst_valuesMethod · 0.80
contains_valueMethod · 0.80
locationMethod · 0.80
ValueClass · 0.50
unwrapMethod · 0.45

Tested by

no test coverage detected