Parse a function body, add contents to `ctx`. function-body ::= * { extended-basic-block }
(&mut self, ctx: &mut Context)
| 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 | // |
no test coverage detected