Add simplified canonical ordering APIs for FlatExpression#549
Closed
Add simplified canonical ordering APIs for FlatExpression#549
Conversation
Agent-Logs-Url: https://github.com/dadhi/FastExpressionCompiler/sessions/bc8ce881-a5e5-4b7b-ad10-dac6ff73fa64 Co-authored-by: dadhi <39516+dadhi@users.noreply.github.com>
Agent-Logs-Url: https://github.com/dadhi/FastExpressionCompiler/sessions/bc8ce881-a5e5-4b7b-ad10-dac6ff73fa64 Co-authored-by: dadhi <39516+dadhi@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Explore canonical representation pros and cons for FlatExpression
Add canonical ordering APIs for FlatExpression and compact unreachable nodes
May 5, 2026
dadhi
requested changes
May 6, 2026
Owner
dadhi
left a comment
There was a problem hiding this comment.
I do not like so much increased complexity and number of locs. Can we simplify back to support only constant indexes and not signal indexes. Let drop dymamic index stuff and thoutougly test all add helpers in assert js
Agent-Logs-Url: https://github.com/dadhi/FastExpressionCompiler/sessions/a59f1ceb-a4eb-40cd-9e5a-9ced5ca388e6 Co-authored-by: dadhi <39516+dadhi@users.noreply.github.com>
Contributor
Author
Addressed in fdf7b03. |
Copilot
AI
changed the title
Add canonical ordering APIs for FlatExpression and compact unreachable nodes
Add simplified canonical ordering APIs for FlatExpression
May 6, 2026
Owner
|
L |
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.
This explores the canonical-representation direction for
FlatExpressionby adding ordering primitives directly onExprTree. The implementation now keeps that support intentionally narrow and simple: it detects canonical post-order directly and rebuilds non-canonical trees through the existing expression round-trip path.What this adds
ExprTree.IsInOrder()to detect whether a flat tree is already in canonical post-order.ExprTree.PutInOrder()to normalize a flat tree into that layout.Canonical layout
Simplified normalization
PutInOrder()no longer performs manual node-index remapping, sibling rewiring, closure-constant compaction, or metadata reconstruction.ToExpression()/FromExpression()round-trip, reducing complexity and LOC while preserving the supported behavior.Tests added
PutInOrder():Example