AST: use simpler MemberExpr nodes#435
Merged
bvdberg merged 1 commit intoc2lang:masterfrom Feb 10, 2026
Merged
Conversation
ba9d1d1 to
afde52a
Compare
bvdberg
reviewed
Feb 10, 2026
generator/c/c_generator_expr.c2
Outdated
| need_dot = true; | ||
| fn bool Generator.needBaseDecl(Generator* gen, Expr* base) { | ||
| Decl* d; | ||
| if (base.isIdentifier()) { |
Member
There was a problem hiding this comment.
Can this happen? If i put an assert here, it does not seem to trigger
Contributor
Author
There was a problem hiding this comment.
No it is no longer used anywhere. This function is a recursive type function, the compiler does not detect that it is unused: the test for self reference should be improved.
Contributor
Author
There was a problem hiding this comment.
I have rebased the branch and removed this function
Member
There was a problem hiding this comment.
Weird, the comment i have was actually about part of an If-statement.. lol. This comment also applies. I made my changes in another commit on top, after i merged you pull request. It indeed appears to be a bit faster. Nice!
afde52a to
474e3e0
Compare
* restrict `MemberExpr` nodes to `<expr>.b` and `a.b` forms * store a single `SrcLoc` for the member name (size is always 32 bytes) * use bitfield to avoid using `strlen` for SrcLoc computations * simplify `Parser.parseCastExpr`, `p.parsePureMemberExpr` and `Parser.parseImpureMemberExpr`: no longer use `peekToken` on identifiers, remove `Parser.parseIdentifier` * store name length in `IdentifierExpr` nodes to simplify end location computation * rename `MemberExpr.getExprBase` as `MemberExpr.getBaseExpr` for consistency * merge `Generator.emitMemberExprBase` into `Generator.emitMemberExpr` * disable bogus const check in `conversion_checker.Checker.check` * improve `Analyser.analyseToContainer` for const/volatile correctness * fix `Analyser.findMemberOffset` for member expression chains should support ̀to_container(s, array[n].ptr, ptr)`? * this simplifies the code and reduces memory usage by 100KB
474e3e0 to
ab1f939
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
MemberExprnodes to<expr>.banda.bformsSrcLocfor the member name (size is always 32 bytes)strlenfor SrcLoc computationsParser.parseCastExpr,p.parsePureMemberExprandParser.parseImpureMemberExpr: no longer usepeekTokenon identifiers.IdentifierExprnodes to simplify end location computationMemberExpr.getExprBaseasMemberExpr.getBaseExprfor consistencyGenerator.emitMemberExprBaseintoGenerator.emitMemberExprconversion_checker.Checker.checkAnalyser.analyseToContainerfor const/volatile correctnessAnalyser.findMemberOffsetfor member expression chains should support ̀to_container(s, array[n].ptr, ptr)`?