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

Remove custom "execute" method from SClass user node in Painless #51776

Merged
merged 8 commits into from
Feb 4, 2020

Conversation

jdconrad
Copy link
Contributor

One of the goals moving forward is to make the user tree nodes and ir tree nodes generic (as in not have custom code for specific methods, etc.). Eventually, the user tree should not need to process anything from the ScriptContextInfo class as any customization should be added as generic nodes by whatever is creating the user and ir trees, respectively. This PR moves all code required for the customized "execute" method from the SClass/ClassNode into the SFunction/FunctionNode as a first step towards the aforementioned goals. In upcoming PRs the customized "execute" method code will be completely removed from the SFunction/FunctionNode classes as well. The SClass/ClassNode now consist of only functions and fields instead of also having logic to process statements for a singular custom "execute" method.

@jdconrad jdconrad added :Core/Infra/Scripting Scripting abstractions, Painless, and Mustache >refactoring v8.0.0 labels Jan 31, 2020
@elasticmachine
Copy link
Collaborator

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

@@ -125,7 +125,8 @@ public void writeStatementOffset(Location location) {
int offset = location.getOffset();
// ensure we don't have duplicate stuff going in here. can catch bugs
// (e.g. nodes get assigned wrong offsets by antlr walker)
assert statements.get(offset) == false;
// TODO: introduce a way to ignore internal statements so this assert is not triggered
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider cutting an issue for TODOs like this so they don't get lost, then ref the issue in the comment.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done: #51836

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pls reference from TODO.


/**
* Tests {@link Object#toString} implementations on all extensions of {@link ANode}.
*/
public class NodeToStringTests extends ESTestCase {

public void testEAssignment() {
/*public void testEAssignment() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you do Test.skip("ignoring rapidly changing tests until quiescent, see issue #XXXX")

Copy link
Contributor Author

@jdconrad jdconrad Feb 4, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done: #51842

private boolean methodEscape;

public SFunction(Location location, String rtnType, String name,
List<String> paramTypes, List<String> paramNames,
SBlock block, boolean synthetic) {
SBlock block, boolean isInternal, boolean isStatic, boolean synthetic, boolean doAutoReturn) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

doAutoReturn implies an action, perhaps autoReturnEnabled?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

private boolean isSynthetic;
private boolean doAutoReturn;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Even with the name change, a comment on the semantics of this var would be useful since it's a non-standard extension.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@jdconrad
Copy link
Contributor Author

jdconrad commented Feb 4, 2020

@stu-elastic Thank you for the review. I believe I've addressed all the PR comments at this point, so ready for the next round.

"for function [" + name + "] with [" + typeParameters.size() + "] parameters"));
}

// TODO: do not specialize for execute
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no need to change, but I usually do something like
// TODO: do not specialize for execute, see #51841

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got it. Will do for the next instance.

Copy link
Contributor

@stu-elastic stu-elastic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@jdconrad
Copy link
Contributor Author

jdconrad commented Feb 4, 2020

@stu-elastic Thanks again.

@jdconrad jdconrad merged commit c6746e2 into elastic:master Feb 4, 2020
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 v8.0.0-alpha1
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants