The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.
+ */ + @Override public T visitCompile(JavascriptParser.CompileContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.
+ */ + @Override public T visitConditional(JavascriptParser.ConditionalContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.
+ */ + @Override public T visitBoolor(JavascriptParser.BoolorContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.
+ */ + @Override public T visitBoolcomp(JavascriptParser.BoolcompContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.
+ */ + @Override public T visitNumeric(JavascriptParser.NumericContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.
+ */ + @Override public T visitAddsub(JavascriptParser.AddsubContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.
+ */ + @Override public T visitUnary(JavascriptParser.UnaryContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.
+ */ + @Override public T visitPrecedence(JavascriptParser.PrecedenceContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.
+ */ + @Override public T visitMuldiv(JavascriptParser.MuldivContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.
+ */ + @Override public T visitExternal(JavascriptParser.ExternalContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.
+ */ + @Override public T visitBwshift(JavascriptParser.BwshiftContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.
+ */ + @Override public T visitBwor(JavascriptParser.BworContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.
+ */ + @Override public T visitBooland(JavascriptParser.BoolandContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.
+ */ + @Override public T visitBwxor(JavascriptParser.BwxorContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.
+ */ + @Override public T visitBwand(JavascriptParser.BwandContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.
+ */ + @Override public T visitBooleqne(JavascriptParser.BooleqneContext ctx) { return visitChildren(ctx); } +} diff --git a/lucene/expressions/src/java/org/apache/lucene/expressions/js/JavascriptCompiler.java b/lucene/expressions/src/java/org/apache/lucene/expressions/js/JavascriptCompiler.java index 9e475f489a4..b23d86aba5e 100644 --- a/lucene/expressions/src/java/org/apache/lucene/expressions/js/JavascriptCompiler.java +++ b/lucene/expressions/src/java/org/apache/lucene/expressions/js/JavascriptCompiler.java @@ -24,18 +24,18 @@ import java.lang.reflect.Method; import java.lang.reflect.Modifier; import java.nio.charset.StandardCharsets; import java.text.ParseException; +import java.util.ArrayDeque; import java.util.Arrays; import java.util.Collections; +import java.util.Deque; import java.util.HashMap; import java.util.LinkedHashMap; import java.util.Map; import java.util.Properties; -import org.antlr.runtime.ANTLRStringStream; -import org.antlr.runtime.CharStream; -import org.antlr.runtime.CommonTokenStream; -import org.antlr.runtime.RecognitionException; -import org.antlr.runtime.tree.Tree; +import org.antlr.v4.runtime.ANTLRInputStream; +import org.antlr.v4.runtime.CommonTokenStream; +import org.antlr.v4.runtime.tree.ParseTree; import org.apache.lucene.expressions.Expression; import org.apache.lucene.queries.function.FunctionValues; import org.apache.lucene.util.IOUtils; @@ -45,6 +45,8 @@ import org.objectweb.asm.Opcodes; import org.objectweb.asm.Type; import org.objectweb.asm.commons.GeneratorAdapter; +import static org.apache.lucene.expressions.js.JavascriptParser.ExpressionContext; + /** * An expression compiler for javascript expressions. *
@@ -73,7 +75,6 @@ import org.objectweb.asm.commons.GeneratorAdapter;
* @lucene.experimental
*/
public class JavascriptCompiler {
-
static final class Loader extends ClassLoader {
Loader(ClassLoader parent) {
super(parent);
@@ -91,13 +92,14 @@ public class JavascriptCompiler {
private static final String COMPILED_EXPRESSION_CLASS = JavascriptCompiler.class.getName() + "$CompiledExpression";
private static final String COMPILED_EXPRESSION_INTERNAL = COMPILED_EXPRESSION_CLASS.replace('.', '/');
- private static final Type EXPRESSION_TYPE = Type.getType(Expression.class);
- private static final Type FUNCTION_VALUES_TYPE = Type.getType(FunctionValues.class);
+ static final Type EXPRESSION_TYPE = Type.getType(Expression.class);
+ static final Type FUNCTION_VALUES_TYPE = Type.getType(FunctionValues.class);
private static final org.objectweb.asm.commons.Method
EXPRESSION_CTOR = getMethod("void