Skip to content

FlatExpression: explore canonical representation pros and cons #531

Closed

Description

@dadhi

Canonical means that equivalent (up to Parameter names and Constant values) FE nodes should be in the same order in ExpressionTree and so trivially comparable via loop. See #530.
Explore does this representation actually helps in

  • FEC collect phase - besides the slready collected closure constants - what about nested lambdas, blocks, label and gotos, etc. being collected by CompilerContext in TryCollectInfo methods
  • In emit phase, e.g. to trivially emit arithmetic expressions on stack from the natural stack order in FE.
  • in other regards - look at tasks solved by FEC now and next tasks: full fledged interpreter and C# parser (and potentially for other langs)

Explore and implement IsInOrder and PutInOrder methods.
Ordering should be done inplace modifying this ExpressionTree.
It may be implemented by doing a min amount of nodes swap.

While doing InOrder we may also:

  • drop/consider empty unrichable nodes, the check may retutn thr numbet of such nodes
  • we need to compact gaps created by empty nodes to ensure the indexes are the same
  • do other checks eg, for labels

Activity

  1. self-assigned this
    on Apr 22, 2026
  2. added this to the v6.0.0 milestone on Apr 22, 2026
  3. dadhi commented on May 6, 2026

    @dadhi
    OwnerAuthor

    We do not need normalization. Now that we have a link from last child to parent we can likely go in a single loop.

  4. removed this from the v6.0.0 milestone on May 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions