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

Separate AST into direct AST representation of script and an internal representation #49869

Closed
stu-elastic opened this issue Dec 5, 2019 · 3 comments
Assignees
Labels
:Core/Infra/Scripting Scripting abstractions, Painless, and Mustache >refactoring

Comments

@stu-elastic
Copy link
Contributor

Painless parses the script into an AST and mutates while processing. Correlation with user provided script is difficult as we don't have the raw representation. Keeping the original AST around without mutating it will enable better error messages and other IDE-like functionality.

@stu-elastic stu-elastic added the :Core/Infra/Scripting Scripting abstractions, Painless, and Mustache label Dec 5, 2019
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-core-infra (:Core/Infra/Scripting)

@stu-elastic
Copy link
Contributor Author

Migrated from: #31009

jdconrad added a commit that referenced this issue Feb 11, 2020
This change moves almost all of the customized code required to decorate 
the execute method into an external phase. This external phase operates 
only on the ir tree after the user tree has generated the initial ir tree from 
user specified code. The external phase uses ir nodes to create the 
necessary customized code instead of writing asm directly. This is a first 
example of modifying the ir tree to customize it specifically for Elasticsearch 
and leaves the ir nodes in a more generic state.

Another change required for this was to remove the notion of auto-return 
from the ir tree completely. The user tree is now responsible for generating 
appropriate ir tree nodes to support auto-return. This is the first example of 
divergent user and ir trees as the user tree is intended to be higher level 
while the ir tree is supposed to provide lower level translation into asm.

Relates to #49869
Relates to #51841
jdconrad added a commit that referenced this issue Mar 3, 2020
This change removes the ECast node from the user tree, so that there are 
no structural changes to the user tree making it structurally immutable. All 
generated casts are now built directly into the ir tree instead. This also 
removes the isNull member variable from AExpression because now an 
instanceof operator can be used instead of having to pass this information 
between potentially multiple levels of user tree nodes.

Relates to #49869
jdconrad added a commit that referenced this issue Mar 9, 2020
…53075)

This is a step toward the long-term goal of making the "user" trees nodes 
immutable. This change isolates the mutable data for expression nodes in 
the "user" tree during the semantic (analysis) phase by moving the 
mutable data into Input and Output objects. These objects are created 
locally during the semantic phase to share information required for 
semantic checking between parent-child nodes.

Note that for this change, Input and Output are still stored in a mutable 
way on the expression nodes. This will not be the case once the semantic 
(analysis) phase and ir generation (write) phase are combined in a future 
change.

Relates #49869
jdconrad added a commit that referenced this issue Mar 13, 2020
…53348)

This is the follow up to #53075, isolating the mutable data on the 
statement nodes as the referenced change did the expression nodes.

This is a step toward the long-term goal of making the "user" trees nodes 
immutable. This change isolates the mutable data for statement nodes in 
the "user" tree during the semantic (analysis) phase by moving the 
mutable data into Input and Output objects. These objects are created 
locally during the semantic phase to share information required for 
semantic checking between parent-child nodes.

Note that for this change, Input and Output are still stored in a mutable 
way on the statement nodes. This will not be the case once the semantic 
(analysis) phase and ir generation (write) phase are combined in a future 
change.

Relates #49869
jdconrad added a commit that referenced this issue Mar 23, 2020
This is the next step in producing immutable state in the Painless "user" 
tree. This combines the analyze phase and the write phase so that both 
semantic checking and the ir tree are generated in the same phase. This 
allows the removal of the Input/Output objects created in the previous PRs 
from being mutable state on the nodes. Instead they are now local state 
for the analyze phase.

Relates: #53561
Relates: #49869
@jdconrad
Copy link
Contributor

Closing in favor of #53702

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
:Core/Infra/Scripting Scripting abstractions, Painless, and Mustache >refactoring
Projects
None yet
Development

No branches or pull requests

3 participants