mirror of
https://github.com/gfx-rs/wgpu.git
synced 2024-11-26 16:53:48 +00:00
[glsl-in] Simplify control flow in search for main
.
This commit is contained in:
parent
115a810981
commit
fae939f537
@ -38,7 +38,7 @@ impl<'source> ParsingContext<'source> {
|
||||
/// Helper method for backtracking from a consumed token
|
||||
///
|
||||
/// This method should always be used instead of assigning to `backtracked_token` since
|
||||
/// it validates that backtracking hasn't ocurred more than one time in a row
|
||||
/// it validates that backtracking hasn't occurred more than one time in a row
|
||||
///
|
||||
/// # Panics
|
||||
/// - If the parser already backtracked without bumping in between
|
||||
@ -172,25 +172,23 @@ impl<'source> ParsingContext<'source> {
|
||||
self.parse_external_declaration(parser, &mut ctx, &mut body)?;
|
||||
}
|
||||
|
||||
match parser.lookup_function.get("main").and_then(|declaration| {
|
||||
declaration
|
||||
.overloads
|
||||
.iter()
|
||||
.find_map(|decl| match decl.kind {
|
||||
FunctionKind::Call(handle) if decl.defined && decl.parameters.is_empty() => {
|
||||
Some(handle)
|
||||
// Add an `EntryPoint` to `parser.module` for `main`, if a
|
||||
// suitable overload exists. Error out if we can't find one.
|
||||
if let Some(declaration) = parser.lookup_function.get("main") {
|
||||
for decl in declaration.overloads.iter() {
|
||||
if let FunctionKind::Call(handle) = decl.kind {
|
||||
if decl.defined && decl.parameters.is_empty() {
|
||||
parser.add_entry_point(handle, body, ctx.expressions);
|
||||
return Ok(());
|
||||
}
|
||||
_ => None,
|
||||
})
|
||||
}) {
|
||||
Some(handle) => parser.add_entry_point(handle, body, ctx.expressions),
|
||||
None => parser.errors.push(Error {
|
||||
kind: ErrorKind::SemanticError("Missing entry point".into()),
|
||||
meta: Span::default(),
|
||||
}),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Ok(())
|
||||
Err(Error {
|
||||
kind: ErrorKind::SemanticError("Missing entry point".into()),
|
||||
meta: Span::default(),
|
||||
})
|
||||
}
|
||||
|
||||
fn parse_uint_constant(&mut self, parser: &mut Parser) -> Result<(u32, Span)> {
|
||||
|
Loading…
Reference in New Issue
Block a user