Skip to content

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

Merged
jdconrad merged 8 commits intoelastic:masterfrom
jdconrad:trees5
Feb 4, 2020
Merged

Remove custom "execute" method from SClass user node in Painless#51776
jdconrad merged 8 commits intoelastic:masterfrom
jdconrad:trees5

Conversation

@jdconrad
Copy link
Copy Markdown
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
Copy Markdown
Collaborator

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

// 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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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.

public class NodeToStringTests extends ESTestCase {

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

Choose a reason for hiding this comment

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

?

Copy link
Copy Markdown
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
Copy Markdown
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

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
Copy Markdown
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
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done.

private List<String> parameterNames = new ArrayList<>();
private boolean isStatic;
private boolean isSynthetic;
private boolean doAutoReturn;
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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