Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Typifier skeleton #24

Merged
merged 3 commits into from
Mar 15, 2020
Merged

Typifier skeleton #24

merged 3 commits into from
Mar 15, 2020

Conversation

kvark
Copy link
Member

@kvark kvark commented Mar 14, 2020

There is a small TODO in the current WGSL parser:

                Token::Separator('.') => {
                    let _ = lexer.next();
                    let _name = lexer.next_ident()?;
                    let expr = crate::Expression::AccessIndex {
                        base: handle,
                        index: 0, //TODO: compute from `name`
                    };
                    handle = ctx.expressions.append(expr);
                }

We have a base expression, and we need to access a sub-field. The IR doesn't care about names, so in case of a structure it just needs an index into the member list. The problem, however, is realizing that the base type is a structure. In order to compute them, we essentially need to know all the types of all the expressions.

This is where Typifier comes in. It's a generic processor of IR that helps to build that type information for a growing list of expressions.

@kvark kvark marked this pull request as ready for review March 15, 2020 02:50
@kvark
Copy link
Member Author

kvark commented Mar 15, 2020

Partially reviewed by @jrmuizel. Merging.

@kvark kvark merged commit a768af6 into gfx-rs:master Mar 15, 2020
@kvark kvark deleted the typify branch March 15, 2020 14:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant