-
Notifications
You must be signed in to change notification settings - Fork 24.9k
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
Add typed emit functionality #68231
Add typed emit functionality #68231
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/* | ||
* Licensed to Elasticsearch under one or more contributor | ||
* license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright | ||
* ownership. Elasticsearch licenses this file to you under | ||
* the Apache License, Version 2.0 (the "License"); you may | ||
* not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
package org.elasticsearch.painless.spi.annotation; | ||
|
||
/** | ||
* Inject the script itself into a method call. Only allowed on augmentations. | ||
*/ | ||
public class InjectScriptAnnotation { | ||
public static final String NAME = "inject_script"; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/* | ||
* Licensed to Elasticsearch under one or more contributor | ||
* license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright | ||
* ownership. Elasticsearch licenses this file to you under | ||
* the Apache License, Version 2.0 (the "License"); you may | ||
* not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
package org.elasticsearch.painless.spi.annotation; | ||
|
||
import java.util.Map; | ||
|
||
public class InjectScriptAnnotationParser implements WhitelistAnnotationParser { | ||
|
||
public static final InjectScriptAnnotationParser INSTANCE = new InjectScriptAnnotationParser(); | ||
|
||
private InjectScriptAnnotationParser() {} | ||
|
||
@Override | ||
public Object parse(Map<String, String> arguments) { | ||
if (false == arguments.isEmpty()) { | ||
throw new IllegalArgumentException("[@inject_script] can no have parameters"); | ||
} | ||
return new InjectScriptAnnotation(); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -445,7 +445,7 @@ public static CallSite bootstrap(PainlessLookup painlessLookup, FunctionTable fu | |
switch(flavor) { | ||
// "function-call" like things get a polymorphic cache | ||
case METHOD_CALL: | ||
if (args.length == 0) { | ||
if (args.length < 2) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we always pass in the script as an argument? Seems like we should only do that when it's actually required? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We pass in two things indy - the recipe like before and whether or not we passed in the script. arg[1] 0 if we didn't pass the script and 1 if we did. |
||
throw new BootstrapMethodError("Invalid number of parameters for method call"); | ||
} | ||
if (args[0] instanceof String == false) { | ||
|
@@ -456,7 +456,7 @@ public static CallSite bootstrap(PainlessLookup painlessLookup, FunctionTable fu | |
if (numLambdas > type.parameterCount()) { | ||
throw new BootstrapMethodError("Illegal recipe for method call: too many bits"); | ||
} | ||
if (args.length != numLambdas + 1) { | ||
if (args.length != numLambdas + 2) { | ||
throw new BootstrapMethodError("Illegal number of parameters: expected " + numLambdas + " references"); | ||
} | ||
return new PIC(painlessLookup, functions, constants, methodHandlesLookup, name, type, initialDepth, flavor, args); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would you please add a sentence or two JavaDoc for this? The name doesn't make it immediately clear to me that we are passing in around the "this" pointer for the script internally.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
++ Same as before. But maybe we should somehow link this into the inject annotation like you were saying? Some way for inject to know its injecting member variables?