Remove extraneous pass (#49797)

This removes the storeSettings pass where nodes in the AST could store 
information they needed out of CompilerSettings for use during later 
passes. CompilerSettings is part of ScriptRoot which is available during the 
analysis pass making the storeSettings pass redundant.
This commit is contained in:
Jack Conradson 2019-12-04 11:43:55 -08:00
parent ce2ca3bd3d
commit dbf6183469
66 changed files with 9 additions and 501 deletions

View File

@ -211,8 +211,7 @@ final class Compiler {
ScriptClassInfo scriptClassInfo = new ScriptClassInfo(painlessLookup, scriptClass);
SClass root = Walker.buildPainlessTree(scriptClassInfo, name, source, settings, painlessLookup, null);
root.extractVariables(extractedVariables);
root.storeSettings(settings);
root.analyze(painlessLookup);
root.analyze(painlessLookup, settings);
Map<String, Object> statics = root.write();
try {
@ -243,8 +242,7 @@ final class Compiler {
SClass root = Walker.buildPainlessTree(scriptClassInfo, name, source, settings, painlessLookup,
debugStream);
root.extractVariables(new HashSet<>());
root.storeSettings(settings);
root.analyze(painlessLookup);
root.analyze(painlessLookup, settings);
root.write();
return root.getBytes();

View File

@ -20,7 +20,6 @@
package org.elasticsearch.painless.node;
import org.elasticsearch.painless.ClassWriter;
import org.elasticsearch.painless.CompilerSettings;
import org.elasticsearch.painless.Globals;
import org.elasticsearch.painless.Locals;
import org.elasticsearch.painless.Location;
@ -56,11 +55,6 @@ public abstract class ANode {
this.location = Objects.requireNonNull(location);
}
/**
* Store settings required for future compiler passes.
*/
abstract void storeSettings(CompilerSettings settings);
/**
* Adds all variable names referenced to the variable set.
* <p>

View File

@ -22,7 +22,6 @@ package org.elasticsearch.painless.node;
import org.elasticsearch.painless.AnalyzerCaster;
import org.elasticsearch.painless.ClassWriter;
import org.elasticsearch.painless.CompilerSettings;
import org.elasticsearch.painless.DefBootstrap;
import org.elasticsearch.painless.Globals;
import org.elasticsearch.painless.Locals;
@ -65,15 +64,6 @@ public final class EAssignment extends AExpression {
this.operation = operation;
}
@Override
void storeSettings(CompilerSettings settings) {
lhs.storeSettings(settings);
if (rhs != null) {
rhs.storeSettings(settings);
}
}
@Override
void extractVariables(Set<String> variables) {
lhs.extractVariables(variables);

View File

@ -21,7 +21,6 @@ package org.elasticsearch.painless.node;
import org.elasticsearch.painless.AnalyzerCaster;
import org.elasticsearch.painless.ClassWriter;
import org.elasticsearch.painless.CompilerSettings;
import org.elasticsearch.painless.DefBootstrap;
import org.elasticsearch.painless.Globals;
import org.elasticsearch.painless.Locals;
@ -60,12 +59,6 @@ public final class EBinary extends AExpression {
this.right = Objects.requireNonNull(right);
}
@Override
void storeSettings(CompilerSettings settings) {
left.storeSettings(settings);
right.storeSettings(settings);
}
@Override
void extractVariables(Set<String> variables) {
left.extractVariables(variables);

View File

@ -20,7 +20,6 @@
package org.elasticsearch.painless.node;
import org.elasticsearch.painless.ClassWriter;
import org.elasticsearch.painless.CompilerSettings;
import org.elasticsearch.painless.Globals;
import org.elasticsearch.painless.Locals;
import org.elasticsearch.painless.Location;
@ -50,12 +49,6 @@ public final class EBool extends AExpression {
this.right = Objects.requireNonNull(right);
}
@Override
void storeSettings(CompilerSettings settings) {
left.storeSettings(settings);
right.storeSettings(settings);
}
@Override
void extractVariables(Set<String> variables) {
left.extractVariables(variables);

View File

@ -20,7 +20,6 @@
package org.elasticsearch.painless.node;
import org.elasticsearch.painless.ClassWriter;
import org.elasticsearch.painless.CompilerSettings;
import org.elasticsearch.painless.Globals;
import org.elasticsearch.painless.Locals;
import org.elasticsearch.painless.Location;
@ -40,11 +39,6 @@ public final class EBoolean extends AExpression {
this.constant = constant;
}
@Override
void storeSettings(CompilerSettings settings) {
// Do nothing.
}
@Override
void extractVariables(Set<String> variables) {
// Do nothing.

View File

@ -20,7 +20,6 @@
package org.elasticsearch.painless.node;
import org.elasticsearch.painless.ClassWriter;
import org.elasticsearch.painless.CompilerSettings;
import org.elasticsearch.painless.Globals;
import org.elasticsearch.painless.Locals;
import org.elasticsearch.painless.Location;
@ -64,13 +63,6 @@ public final class ECallLocal extends AExpression {
this.arguments = Objects.requireNonNull(arguments);
}
@Override
void storeSettings(CompilerSettings settings) {
for (AExpression argument : arguments) {
argument.storeSettings(settings);
}
}
@Override
void extractVariables(Set<String> variables) {
for (AExpression argument : arguments) {

View File

@ -20,7 +20,6 @@
package org.elasticsearch.painless.node;
import org.elasticsearch.painless.ClassWriter;
import org.elasticsearch.painless.CompilerSettings;
import org.elasticsearch.painless.DefBootstrap;
import org.elasticsearch.painless.FunctionRef;
import org.elasticsearch.painless.Globals;
@ -55,11 +54,6 @@ public final class ECapturingFunctionRef extends AExpression implements ILambda
this.call = Objects.requireNonNull(call);
}
@Override
void storeSettings(CompilerSettings settings) {
// Do nothing.
}
@Override
void extractVariables(Set<String> variables) {
variables.add(variable);

View File

@ -20,7 +20,6 @@
package org.elasticsearch.painless.node;
import org.elasticsearch.painless.ClassWriter;
import org.elasticsearch.painless.CompilerSettings;
import org.elasticsearch.painless.Globals;
import org.elasticsearch.painless.Locals;
import org.elasticsearch.painless.Location;
@ -47,11 +46,6 @@ final class ECast extends AExpression {
this.cast = Objects.requireNonNull(cast);
}
@Override
void storeSettings(CompilerSettings settings) {
throw createError(new IllegalStateException("illegal tree structure"));
}
@Override
void extractVariables(Set<String> variables) {
throw createError(new IllegalStateException("Illegal tree structure."));

View File

@ -21,7 +21,6 @@ package org.elasticsearch.painless.node;
import org.elasticsearch.painless.AnalyzerCaster;
import org.elasticsearch.painless.ClassWriter;
import org.elasticsearch.painless.CompilerSettings;
import org.elasticsearch.painless.DefBootstrap;
import org.elasticsearch.painless.Globals;
import org.elasticsearch.painless.Locals;
@ -59,12 +58,6 @@ public final class EComp extends AExpression {
this.right = Objects.requireNonNull(right);
}
@Override
void storeSettings(CompilerSettings settings) {
left.storeSettings(settings);
right.storeSettings(settings);
}
@Override
void extractVariables(Set<String> variables) {
left.extractVariables(variables);

View File

@ -21,7 +21,6 @@ package org.elasticsearch.painless.node;
import org.elasticsearch.painless.AnalyzerCaster;
import org.elasticsearch.painless.ClassWriter;
import org.elasticsearch.painless.CompilerSettings;
import org.elasticsearch.painless.Globals;
import org.elasticsearch.painless.Locals;
import org.elasticsearch.painless.Location;
@ -50,13 +49,6 @@ public final class EConditional extends AExpression {
this.right = Objects.requireNonNull(right);
}
@Override
void storeSettings(CompilerSettings settings) {
condition.storeSettings(settings);
left.storeSettings(settings);
right.storeSettings(settings);
}
@Override
void extractVariables(Set<String> variables) {
condition.extractVariables(variables);

View File

@ -20,7 +20,6 @@
package org.elasticsearch.painless.node;
import org.elasticsearch.painless.ClassWriter;
import org.elasticsearch.painless.CompilerSettings;
import org.elasticsearch.painless.Globals;
import org.elasticsearch.painless.Locals;
import org.elasticsearch.painless.Location;
@ -41,11 +40,6 @@ final class EConstant extends AExpression {
this.constant = constant;
}
@Override
void storeSettings(CompilerSettings settings) {
throw new IllegalStateException("illegal tree structure");
}
@Override
void extractVariables(Set<String> variables) {
throw new IllegalStateException("Illegal tree structure.");

View File

@ -20,7 +20,6 @@
package org.elasticsearch.painless.node;
import org.elasticsearch.painless.ClassWriter;
import org.elasticsearch.painless.CompilerSettings;
import org.elasticsearch.painless.Globals;
import org.elasticsearch.painless.Locals;
import org.elasticsearch.painless.Location;
@ -43,11 +42,6 @@ public final class EDecimal extends AExpression {
this.value = Objects.requireNonNull(value);
}
@Override
void storeSettings(CompilerSettings settings) {
// Do nothing.
}
@Override
void extractVariables(Set<String> variables) {
// Do nothing.

View File

@ -21,7 +21,6 @@ package org.elasticsearch.painless.node;
import org.elasticsearch.painless.AnalyzerCaster;
import org.elasticsearch.painless.ClassWriter;
import org.elasticsearch.painless.CompilerSettings;
import org.elasticsearch.painless.Globals;
import org.elasticsearch.painless.Locals;
import org.elasticsearch.painless.Location;
@ -48,12 +47,6 @@ public class EElvis extends AExpression {
this.rhs = requireNonNull(rhs);
}
@Override
void storeSettings(CompilerSettings settings) {
lhs.storeSettings(settings);
rhs.storeSettings(settings);
}
@Override
void extractVariables(Set<String> variables) {
lhs.extractVariables(variables);

View File

@ -20,7 +20,6 @@
package org.elasticsearch.painless.node;
import org.elasticsearch.painless.ClassWriter;
import org.elasticsearch.painless.CompilerSettings;
import org.elasticsearch.painless.Globals;
import org.elasticsearch.painless.Locals;
import org.elasticsearch.painless.Location;
@ -45,11 +44,6 @@ public final class EExplicit extends AExpression {
this.child = Objects.requireNonNull(child);
}
@Override
void storeSettings(CompilerSettings settings) {
child.storeSettings(settings);
}
@Override
void extractVariables(Set<String> variables) {
child.extractVariables(variables);

View File

@ -20,7 +20,6 @@
package org.elasticsearch.painless.node;
import org.elasticsearch.painless.ClassWriter;
import org.elasticsearch.painless.CompilerSettings;
import org.elasticsearch.painless.FunctionRef;
import org.elasticsearch.painless.Globals;
import org.elasticsearch.painless.Locals;
@ -49,11 +48,6 @@ public final class EFunctionRef extends AExpression implements ILambda {
this.call = Objects.requireNonNull(call);
}
@Override
void storeSettings(CompilerSettings settings) {
// do nothing
}
@Override
void extractVariables(Set<String> variables) {
// do nothing

View File

@ -20,7 +20,6 @@
package org.elasticsearch.painless.node;
import org.elasticsearch.painless.ClassWriter;
import org.elasticsearch.painless.CompilerSettings;
import org.elasticsearch.painless.Globals;
import org.elasticsearch.painless.Locals;
import org.elasticsearch.painless.Location;
@ -50,11 +49,6 @@ public final class EInstanceof extends AExpression {
this.type = Objects.requireNonNull(type);
}
@Override
void storeSettings(CompilerSettings settings) {
expression.storeSettings(settings);
}
@Override
void extractVariables(Set<String> variables) {
expression.extractVariables(variables);

View File

@ -20,7 +20,6 @@
package org.elasticsearch.painless.node;
import org.elasticsearch.painless.ClassWriter;
import org.elasticsearch.painless.CompilerSettings;
import org.elasticsearch.painless.FunctionRef;
import org.elasticsearch.painless.Globals;
import org.elasticsearch.painless.Locals;
@ -68,8 +67,6 @@ public final class ELambda extends AExpression implements ILambda {
private final List<String> paramNameStrs;
private final List<AStatement> statements;
private CompilerSettings settings;
// extracted variables required to determine captures
private final Set<String> extractedVariables;
// desugared synthetic method (lambda body)
@ -92,15 +89,6 @@ public final class ELambda extends AExpression implements ILambda {
this.extractedVariables = new HashSet<>();
}
@Override
void storeSettings(CompilerSettings settings) {
for (AStatement statement : statements) {
statement.storeSettings(settings);
}
this.settings = settings;
}
@Override
void extractVariables(Set<String> variables) {
for (AStatement statement : statements) {
@ -180,10 +168,9 @@ public final class ELambda extends AExpression implements ILambda {
desugared = new SFunction(
location, PainlessLookupUtility.typeToCanonicalTypeName(returnType), name, paramTypes, paramNames,
new SBlock(location, statements), true);
desugared.storeSettings(settings);
desugared.generateSignature(scriptRoot.getPainlessLookup());
desugared.analyze(scriptRoot, Locals.newLambdaScope(locals.getProgramScope(), desugared.name, returnType,
desugared.parameters, captures.size(), settings.getMaxLoopCounter()));
desugared.parameters, captures.size(), scriptRoot.getCompilerSettings().getMaxLoopCounter()));
scriptRoot.getFunctionTable().addFunction(desugared.name, desugared.returnType, desugared.typeParameters, true);
scriptRoot.getClassNode().addFunction(desugared);

View File

@ -20,7 +20,6 @@
package org.elasticsearch.painless.node;
import org.elasticsearch.painless.ClassWriter;
import org.elasticsearch.painless.CompilerSettings;
import org.elasticsearch.painless.Globals;
import org.elasticsearch.painless.Locals;
import org.elasticsearch.painless.Location;
@ -53,13 +52,6 @@ public final class EListInit extends AExpression {
this.values = values;
}
@Override
void storeSettings(CompilerSettings settings) {
for (AExpression value : values) {
value.storeSettings(settings);
}
}
@Override
void extractVariables(Set<String> variables) {
for (AExpression value : values) {

View File

@ -20,7 +20,6 @@
package org.elasticsearch.painless.node;
import org.elasticsearch.painless.ClassWriter;
import org.elasticsearch.painless.CompilerSettings;
import org.elasticsearch.painless.Globals;
import org.elasticsearch.painless.Locals;
import org.elasticsearch.painless.Location;
@ -55,17 +54,6 @@ public final class EMapInit extends AExpression {
this.values = values;
}
@Override
void storeSettings(CompilerSettings settings) {
for (AExpression key : keys) {
key.storeSettings(settings);
}
for (AExpression value : values) {
value.storeSettings(settings);
}
}
@Override
void extractVariables(Set<String> variables) {
for (AExpression key : keys) {

View File

@ -20,7 +20,6 @@
package org.elasticsearch.painless.node;
import org.elasticsearch.painless.ClassWriter;
import org.elasticsearch.painless.CompilerSettings;
import org.elasticsearch.painless.Globals;
import org.elasticsearch.painless.Locals;
import org.elasticsearch.painless.Location;
@ -48,13 +47,6 @@ public final class ENewArray extends AExpression {
this.initialize = initialize;
}
@Override
void storeSettings(CompilerSettings settings) {
for (AExpression argument : arguments) {
argument.storeSettings(settings);
}
}
@Override
void extractVariables(Set<String> variables) {
for (AExpression argument : arguments) {

View File

@ -20,7 +20,6 @@
package org.elasticsearch.painless.node;
import org.elasticsearch.painless.ClassWriter;
import org.elasticsearch.painless.CompilerSettings;
import org.elasticsearch.painless.FunctionRef;
import org.elasticsearch.painless.Globals;
import org.elasticsearch.painless.Locals;
@ -40,8 +39,6 @@ import java.util.Set;
public final class ENewArrayFunctionRef extends AExpression implements ILambda {
private final String type;
private CompilerSettings settings;
private SFunction function;
private FunctionRef ref;
private String defPointer;
@ -52,11 +49,6 @@ public final class ENewArrayFunctionRef extends AExpression implements ILambda {
this.type = Objects.requireNonNull(type);
}
@Override
void storeSettings(CompilerSettings settings) {
this.settings = settings;
}
@Override
void extractVariables(Set<String> variables) {
// do nothing
@ -69,11 +61,10 @@ public final class ENewArrayFunctionRef extends AExpression implements ILambda {
location, type, scriptRoot.getNextSyntheticName("newarray"),
Collections.singletonList("int"), Collections.singletonList("size"),
new SBlock(location, Collections.singletonList(code)), true);
function.storeSettings(settings);
function.generateSignature(scriptRoot.getPainlessLookup());
function.extractVariables(null);
function.analyze(scriptRoot, Locals.newLambdaScope(locals.getProgramScope(), function.name, function.returnType,
function.parameters, 0, settings.getMaxLoopCounter()));
function.parameters, 0, scriptRoot.getCompilerSettings().getMaxLoopCounter()));
scriptRoot.getFunctionTable().addFunction(function.name, function.returnType, function.typeParameters, true);
scriptRoot.getClassNode().addFunction(function);

View File

@ -20,7 +20,6 @@
package org.elasticsearch.painless.node;
import org.elasticsearch.painless.ClassWriter;
import org.elasticsearch.painless.CompilerSettings;
import org.elasticsearch.painless.Globals;
import org.elasticsearch.painless.Locals;
import org.elasticsearch.painless.Location;
@ -54,13 +53,6 @@ public final class ENewObj extends AExpression {
this.arguments = Objects.requireNonNull(arguments);
}
@Override
void storeSettings(CompilerSettings settings) {
for (AExpression argument : arguments) {
argument.storeSettings(settings);
}
}
@Override
void extractVariables(Set<String> variables) {
for (AExpression argument : arguments) {

View File

@ -20,7 +20,6 @@
package org.elasticsearch.painless.node;
import org.elasticsearch.painless.ClassWriter;
import org.elasticsearch.painless.CompilerSettings;
import org.elasticsearch.painless.Globals;
import org.elasticsearch.painless.Locals;
import org.elasticsearch.painless.Location;
@ -40,11 +39,6 @@ public final class ENull extends AExpression {
super(location);
}
@Override
void storeSettings(CompilerSettings settings) {
// do nothing
}
@Override
void extractVariables(Set<String> variables) {
// Do nothing.

View File

@ -20,7 +20,6 @@
package org.elasticsearch.painless.node;
import org.elasticsearch.painless.ClassWriter;
import org.elasticsearch.painless.CompilerSettings;
import org.elasticsearch.painless.Globals;
import org.elasticsearch.painless.Locals;
import org.elasticsearch.painless.Location;
@ -45,11 +44,6 @@ public final class ENumeric extends AExpression {
this.radix = radix;
}
@Override
void storeSettings(CompilerSettings settings) {
// do nothing
}
@Override
void extractVariables(Set<String> variables) {
// Do nothing.

View File

@ -20,7 +20,6 @@
package org.elasticsearch.painless.node;
import org.elasticsearch.painless.ClassWriter;
import org.elasticsearch.painless.CompilerSettings;
import org.elasticsearch.painless.Constant;
import org.elasticsearch.painless.Globals;
import org.elasticsearch.painless.Locals;
@ -43,8 +42,6 @@ public final class ERegex extends AExpression {
private final int flags;
private Constant constant;
private CompilerSettings settings;
public ERegex(Location location, String pattern, String flagsString) {
super(location);
@ -59,11 +56,6 @@ public final class ERegex extends AExpression {
this.flags = flags;
}
@Override
void storeSettings(CompilerSettings settings) {
this.settings = settings;
}
@Override
void extractVariables(Set<String> variables) {
// Do nothing.
@ -71,7 +63,7 @@ public final class ERegex extends AExpression {
@Override
void analyze(ScriptRoot scriptRoot, Locals locals) {
if (false == settings.areRegexesEnabled()) {
if (false == scriptRoot.getCompilerSettings().areRegexesEnabled()) {
throw createError(new IllegalStateException("Regexes are disabled. Set [script.painless.regex.enabled] to [true] "
+ "in elasticsearch.yaml to allow them. Be careful though, regexes break out of Painless's protection against deep "
+ "recursion and long loops."));

View File

@ -20,7 +20,6 @@
package org.elasticsearch.painless.node;
import org.elasticsearch.painless.ClassWriter;
import org.elasticsearch.painless.CompilerSettings;
import org.elasticsearch.painless.Globals;
import org.elasticsearch.painless.Locals;
import org.elasticsearch.painless.Location;
@ -43,11 +42,6 @@ public final class EStatic extends AExpression {
this.type = Objects.requireNonNull(type);
}
@Override
void storeSettings(CompilerSettings settings) {
// do nothing
}
@Override
void extractVariables(Set<String> variables) {
// Do nothing.

View File

@ -20,7 +20,6 @@
package org.elasticsearch.painless.node;
import org.elasticsearch.painless.ClassWriter;
import org.elasticsearch.painless.CompilerSettings;
import org.elasticsearch.painless.Globals;
import org.elasticsearch.painless.Locals;
import org.elasticsearch.painless.Location;
@ -41,11 +40,6 @@ public final class EString extends AExpression {
this.constant = Objects.requireNonNull(string);
}
@Override
void storeSettings(CompilerSettings settings) {
// do nothing
}
@Override
void extractVariables(Set<String> variables) {
// Do nothing.

View File

@ -21,7 +21,6 @@ package org.elasticsearch.painless.node;
import org.elasticsearch.painless.AnalyzerCaster;
import org.elasticsearch.painless.ClassWriter;
import org.elasticsearch.painless.CompilerSettings;
import org.elasticsearch.painless.DefBootstrap;
import org.elasticsearch.painless.Globals;
import org.elasticsearch.painless.Locals;
@ -56,11 +55,6 @@ public final class EUnary extends AExpression {
this.child = Objects.requireNonNull(child);
}
@Override
void storeSettings(CompilerSettings settings) {
child.storeSettings(settings);
}
@Override
void extractVariables(Set<String> variables) {
child.extractVariables(variables);

View File

@ -20,7 +20,6 @@
package org.elasticsearch.painless.node;
import org.elasticsearch.painless.ClassWriter;
import org.elasticsearch.painless.CompilerSettings;
import org.elasticsearch.painless.Globals;
import org.elasticsearch.painless.Locals;
import org.elasticsearch.painless.Locals.Variable;
@ -47,11 +46,6 @@ public final class EVariable extends AStoreable {
this.name = Objects.requireNonNull(name);
}
@Override
void storeSettings(CompilerSettings settings) {
// do nothing
}
@Override
void extractVariables(Set<String> variables) {
variables.add(name);

View File

@ -20,7 +20,6 @@
package org.elasticsearch.painless.node;
import org.elasticsearch.painless.ClassWriter;
import org.elasticsearch.painless.CompilerSettings;
import org.elasticsearch.painless.Globals;
import org.elasticsearch.painless.Locals;
import org.elasticsearch.painless.Location;
@ -49,12 +48,6 @@ public final class PBrace extends AStoreable {
this.index = Objects.requireNonNull(index);
}
@Override
void storeSettings(CompilerSettings settings) {
prefix.storeSettings(settings);
index.storeSettings(settings);
}
@Override
void extractVariables(Set<String> variables) {
prefix.extractVariables(variables);

View File

@ -20,7 +20,6 @@
package org.elasticsearch.painless.node;
import org.elasticsearch.painless.ClassWriter;
import org.elasticsearch.painless.CompilerSettings;
import org.elasticsearch.painless.Globals;
import org.elasticsearch.painless.Locals;
import org.elasticsearch.painless.Location;
@ -54,15 +53,6 @@ public final class PCallInvoke extends AExpression {
this.arguments = Objects.requireNonNull(arguments);
}
@Override
void storeSettings(CompilerSettings settings) {
prefix.storeSettings(settings);
for (AExpression argument : arguments) {
argument.storeSettings(settings);
}
}
@Override
void extractVariables(Set<String> variables) {
prefix.extractVariables(variables);

View File

@ -20,7 +20,6 @@
package org.elasticsearch.painless.node;
import org.elasticsearch.painless.ClassWriter;
import org.elasticsearch.painless.CompilerSettings;
import org.elasticsearch.painless.Globals;
import org.elasticsearch.painless.Locals;
import org.elasticsearch.painless.Location;
@ -55,11 +54,6 @@ public final class PField extends AStoreable {
this.value = Objects.requireNonNull(value);
}
@Override
void storeSettings(CompilerSettings settings) {
prefix.storeSettings(settings);
}
@Override
void extractVariables(Set<String> variables) {
prefix.extractVariables(variables);

View File

@ -20,7 +20,6 @@
package org.elasticsearch.painless.node;
import org.elasticsearch.painless.ClassWriter;
import org.elasticsearch.painless.CompilerSettings;
import org.elasticsearch.painless.Globals;
import org.elasticsearch.painless.Locals;
import org.elasticsearch.painless.Location;
@ -45,11 +44,6 @@ final class PSubArrayLength extends AStoreable {
this.value = Objects.requireNonNull(value);
}
@Override
void storeSettings(CompilerSettings settings) {
throw createError(new IllegalStateException("illegal tree structure"));
}
@Override
void extractVariables(Set<String> variables) {
throw createError(new IllegalStateException("Illegal tree structure."));

View File

@ -20,7 +20,6 @@
package org.elasticsearch.painless.node;
import org.elasticsearch.painless.ClassWriter;
import org.elasticsearch.painless.CompilerSettings;
import org.elasticsearch.painless.Globals;
import org.elasticsearch.painless.Locals;
import org.elasticsearch.painless.Location;
@ -45,11 +44,6 @@ final class PSubBrace extends AStoreable {
this.index = Objects.requireNonNull(index);
}
@Override
void storeSettings(CompilerSettings settings) {
throw createError(new IllegalStateException("illegal tree structure"));
}
@Override
void extractVariables(Set<String> variables) {
throw createError(new IllegalStateException("illegal tree structure"));

View File

@ -20,7 +20,6 @@
package org.elasticsearch.painless.node;
import org.elasticsearch.painless.ClassWriter;
import org.elasticsearch.painless.CompilerSettings;
import org.elasticsearch.painless.Globals;
import org.elasticsearch.painless.Locals;
import org.elasticsearch.painless.Location;
@ -49,11 +48,6 @@ final class PSubCallInvoke extends AExpression {
this.arguments = Objects.requireNonNull(arguments);
}
@Override
void storeSettings(CompilerSettings settings) {
throw createError(new IllegalStateException("illegal tree structure"));
}
@Override
void extractVariables(Set<String> variables) {
throw createError(new IllegalStateException("Illegal tree structure."));

View File

@ -20,7 +20,6 @@
package org.elasticsearch.painless.node;
import org.elasticsearch.painless.ClassWriter;
import org.elasticsearch.painless.CompilerSettings;
import org.elasticsearch.painless.DefBootstrap;
import org.elasticsearch.painless.Globals;
import org.elasticsearch.painless.Locals;
@ -46,11 +45,6 @@ final class PSubDefArray extends AStoreable {
this.index = Objects.requireNonNull(index);
}
@Override
void storeSettings(CompilerSettings settings) {
throw createError(new IllegalStateException("illegal tree structure"));
}
@Override
void extractVariables(Set<String> variables) {
throw createError(new IllegalStateException("Illegal tree structure."));

View File

@ -20,7 +20,6 @@
package org.elasticsearch.painless.node;
import org.elasticsearch.painless.ClassWriter;
import org.elasticsearch.painless.CompilerSettings;
import org.elasticsearch.painless.DefBootstrap;
import org.elasticsearch.painless.Globals;
import org.elasticsearch.painless.Locals;
@ -55,11 +54,6 @@ final class PSubDefCall extends AExpression {
this.arguments = Objects.requireNonNull(arguments);
}
@Override
void storeSettings(CompilerSettings settings) {
throw createError(new IllegalStateException("illegal tree structure"));
}
@Override
void extractVariables(Set<String> variables) {
throw createError(new IllegalStateException("Illegal tree structure."));

View File

@ -20,7 +20,6 @@
package org.elasticsearch.painless.node;
import org.elasticsearch.painless.ClassWriter;
import org.elasticsearch.painless.CompilerSettings;
import org.elasticsearch.painless.DefBootstrap;
import org.elasticsearch.painless.Globals;
import org.elasticsearch.painless.Locals;
@ -46,11 +45,6 @@ final class PSubDefField extends AStoreable {
this.value = Objects.requireNonNull(value);
}
@Override
void storeSettings(CompilerSettings settings) {
throw createError(new IllegalStateException("illegal tree structure"));
}
@Override
void extractVariables(Set<String> variables) {
throw createError(new IllegalStateException("Illegal tree structure."));

View File

@ -20,7 +20,6 @@
package org.elasticsearch.painless.node;
import org.elasticsearch.painless.ClassWriter;
import org.elasticsearch.painless.CompilerSettings;
import org.elasticsearch.painless.Globals;
import org.elasticsearch.painless.Locals;
import org.elasticsearch.painless.Location;
@ -47,11 +46,6 @@ final class PSubField extends AStoreable {
this.field = Objects.requireNonNull(field);
}
@Override
void storeSettings(CompilerSettings settings) {
throw createError(new IllegalStateException("illegal tree structure"));
}
@Override
void extractVariables(Set<String> variables) {
throw createError(new IllegalStateException("Illegal tree structure."));

View File

@ -20,7 +20,6 @@
package org.elasticsearch.painless.node;
import org.elasticsearch.painless.ClassWriter;
import org.elasticsearch.painless.CompilerSettings;
import org.elasticsearch.painless.Globals;
import org.elasticsearch.painless.Locals;
import org.elasticsearch.painless.Location;
@ -51,11 +50,6 @@ final class PSubListShortcut extends AStoreable {
this.index = Objects.requireNonNull(index);
}
@Override
void storeSettings(CompilerSettings settings) {
throw createError(new IllegalStateException("illegal tree structure"));
}
@Override
void extractVariables(Set<String> variables) {
throw createError(new IllegalStateException("Illegal tree structure."));

View File

@ -20,7 +20,6 @@
package org.elasticsearch.painless.node;
import org.elasticsearch.painless.ClassWriter;
import org.elasticsearch.painless.CompilerSettings;
import org.elasticsearch.painless.Globals;
import org.elasticsearch.painless.Locals;
import org.elasticsearch.painless.Location;
@ -50,11 +49,6 @@ final class PSubMapShortcut extends AStoreable {
this.index = Objects.requireNonNull(index);
}
@Override
void storeSettings(CompilerSettings settings) {
throw createError(new IllegalStateException("illegal tree structure"));
}
@Override
void extractVariables(Set<String> variables) {
throw createError(new IllegalStateException("Illegal tree structure."));

View File

@ -20,7 +20,6 @@
package org.elasticsearch.painless.node;
import org.elasticsearch.painless.ClassWriter;
import org.elasticsearch.painless.CompilerSettings;
import org.elasticsearch.painless.Globals;
import org.elasticsearch.painless.Locals;
import org.elasticsearch.painless.Location;
@ -46,11 +45,6 @@ public class PSubNullSafeCallInvoke extends AExpression {
this.guarded = requireNonNull(guarded);
}
@Override
void storeSettings(CompilerSettings settings) {
throw createError(new IllegalStateException("illegal tree structure"));
}
@Override
void extractVariables(Set<String> variables) {
throw createError(new IllegalStateException("illegal tree structure"));

View File

@ -20,7 +20,6 @@
package org.elasticsearch.painless.node;
import org.elasticsearch.painless.ClassWriter;
import org.elasticsearch.painless.CompilerSettings;
import org.elasticsearch.painless.Globals;
import org.elasticsearch.painless.Locals;
import org.elasticsearch.painless.Location;
@ -41,11 +40,6 @@ public class PSubNullSafeField extends AStoreable {
this.guarded = guarded;
}
@Override
void storeSettings(CompilerSettings settings) {
throw createError(new IllegalStateException("illegal tree structure"));
}
@Override
void extractVariables(Set<String> variables) {
throw createError(new IllegalStateException("illegal tree structure"));

View File

@ -20,7 +20,6 @@
package org.elasticsearch.painless.node;
import org.elasticsearch.painless.ClassWriter;
import org.elasticsearch.painless.CompilerSettings;
import org.elasticsearch.painless.Globals;
import org.elasticsearch.painless.Locals;
import org.elasticsearch.painless.Location;
@ -49,11 +48,6 @@ final class PSubShortcut extends AStoreable {
this.setter = setter;
}
@Override
void storeSettings(CompilerSettings settings) {
throw createError(new IllegalStateException("illegal tree structure"));
}
@Override
void extractVariables(Set<String> variables) {
throw createError(new IllegalStateException("Illegal tree structure."));

View File

@ -20,7 +20,6 @@
package org.elasticsearch.painless.node;
import org.elasticsearch.painless.ClassWriter;
import org.elasticsearch.painless.CompilerSettings;
import org.elasticsearch.painless.Globals;
import org.elasticsearch.painless.Locals;
import org.elasticsearch.painless.Location;
@ -46,13 +45,6 @@ public final class SBlock extends AStatement {
this.statements = Collections.unmodifiableList(statements);
}
@Override
void storeSettings(CompilerSettings settings) {
for (AStatement statement : statements) {
statement.storeSettings(settings);
}
}
@Override
void extractVariables(Set<String> variables) {
for (AStatement statement : statements) {

View File

@ -20,7 +20,6 @@
package org.elasticsearch.painless.node;
import org.elasticsearch.painless.ClassWriter;
import org.elasticsearch.painless.CompilerSettings;
import org.elasticsearch.painless.Globals;
import org.elasticsearch.painless.Locals;
import org.elasticsearch.painless.Location;
@ -38,11 +37,6 @@ public final class SBreak extends AStatement {
super(location);
}
@Override
void storeSettings(CompilerSettings settings) {
// do nothing
}
@Override
void extractVariables(Set<String> variables) {
// Do nothing.

View File

@ -20,7 +20,6 @@
package org.elasticsearch.painless.node;
import org.elasticsearch.painless.ClassWriter;
import org.elasticsearch.painless.CompilerSettings;
import org.elasticsearch.painless.Globals;
import org.elasticsearch.painless.Locals;
import org.elasticsearch.painless.Locals.Variable;
@ -56,13 +55,6 @@ public final class SCatch extends AStatement {
this.block = block;
}
@Override
void storeSettings(CompilerSettings settings) {
if (block != null) {
block.storeSettings(settings);
}
}
@Override
void extractVariables(Set<String> variables) {
variables.add(name);

View File

@ -117,19 +117,6 @@ public final class SClass extends AStatement {
fields.add(field);
}
@Override
public void storeSettings(CompilerSettings settings) {
for (SFunction function : functions) {
function.storeSettings(settings);
}
for (AStatement statement : statements) {
statement.storeSettings(settings);
}
this.settings = settings;
}
@Override
public void extractVariables(Set<String> variables) {
for (SFunction function : functions) {
@ -143,7 +130,8 @@ public final class SClass extends AStatement {
extractedVariables.addAll(variables);
}
public void analyze(PainlessLookup painlessLookup) {
public void analyze(PainlessLookup painlessLookup, CompilerSettings settings) {
this.settings = settings;
table = new ScriptRoot(painlessLookup, settings, scriptClassInfo, this);
for (SFunction function : functions) {

View File

@ -20,7 +20,6 @@
package org.elasticsearch.painless.node;
import org.elasticsearch.painless.ClassWriter;
import org.elasticsearch.painless.CompilerSettings;
import org.elasticsearch.painless.Globals;
import org.elasticsearch.painless.Locals;
import org.elasticsearch.painless.Location;
@ -38,11 +37,6 @@ public final class SContinue extends AStatement {
super(location);
}
@Override
void storeSettings(CompilerSettings settings) {
// do nothing
}
@Override
void extractVariables(Set<String> variables) {
// Do nothing.

View File

@ -20,7 +20,6 @@
package org.elasticsearch.painless.node;
import org.elasticsearch.painless.ClassWriter;
import org.elasticsearch.painless.CompilerSettings;
import org.elasticsearch.painless.Globals;
import org.elasticsearch.painless.Locals;
import org.elasticsearch.painless.Location;
@ -46,13 +45,6 @@ public final class SDeclBlock extends AStatement {
this.declarations = Collections.unmodifiableList(declarations);
}
@Override
void storeSettings(CompilerSettings settings) {
for (SDeclaration declaration: declarations) {
declaration.storeSettings(settings);
}
}
@Override
void extractVariables(Set<String> variables) {
for (SDeclaration declaration : declarations) {

View File

@ -20,7 +20,6 @@
package org.elasticsearch.painless.node;
import org.elasticsearch.painless.ClassWriter;
import org.elasticsearch.painless.CompilerSettings;
import org.elasticsearch.painless.Globals;
import org.elasticsearch.painless.Locals;
import org.elasticsearch.painless.Locals.Variable;
@ -51,13 +50,6 @@ public final class SDeclaration extends AStatement {
this.expression = expression;
}
@Override
void storeSettings(CompilerSettings settings) {
if (expression != null) {
expression.storeSettings(settings);
}
}
@Override
void extractVariables(Set<String> variables) {
variables.add(name);

View File

@ -20,7 +20,6 @@
package org.elasticsearch.painless.node;
import org.elasticsearch.painless.ClassWriter;
import org.elasticsearch.painless.CompilerSettings;
import org.elasticsearch.painless.Globals;
import org.elasticsearch.painless.Locals;
import org.elasticsearch.painless.Location;
@ -49,15 +48,6 @@ public final class SDo extends AStatement {
this.block = block;
}
@Override
void storeSettings(CompilerSettings settings) {
condition.storeSettings(settings);
if (block != null) {
block.storeSettings(settings);
}
}
@Override
void extractVariables(Set<String> variables) {
condition.extractVariables(variables);

View File

@ -20,7 +20,6 @@
package org.elasticsearch.painless.node;
import org.elasticsearch.painless.ClassWriter;
import org.elasticsearch.painless.CompilerSettings;
import org.elasticsearch.painless.Globals;
import org.elasticsearch.painless.Locals;
import org.elasticsearch.painless.Locals.Variable;
@ -54,15 +53,6 @@ public class SEach extends AStatement {
this.block = block;
}
@Override
void storeSettings(CompilerSettings settings) {
expression.storeSettings(settings);
if (block != null) {
block.storeSettings(settings);
}
}
@Override
void extractVariables(Set<String> variables) {
variables.add(name);

View File

@ -20,7 +20,6 @@
package org.elasticsearch.painless.node;
import org.elasticsearch.painless.ClassWriter;
import org.elasticsearch.painless.CompilerSettings;
import org.elasticsearch.painless.Globals;
import org.elasticsearch.painless.Locals;
import org.elasticsearch.painless.Location;
@ -43,11 +42,6 @@ public final class SExpression extends AStatement {
this.expression = Objects.requireNonNull(expression);
}
@Override
void storeSettings(CompilerSettings settings) {
expression.storeSettings(settings);
}
@Override
void extractVariables(Set<String> variables) {
expression.extractVariables(variables);

View File

@ -20,7 +20,6 @@
package org.elasticsearch.painless.node;
import org.elasticsearch.painless.ClassWriter;
import org.elasticsearch.painless.CompilerSettings;
import org.elasticsearch.painless.Globals;
import org.elasticsearch.painless.Locals;
import org.elasticsearch.painless.Location;
@ -65,11 +64,6 @@ public class SField extends ANode {
return instance;
}
@Override
void storeSettings(CompilerSettings settings) {
throw createError(new UnsupportedOperationException("unexpected node"));
}
@Override
void extractVariables(Set<String> variables) {
throw createError(new UnsupportedOperationException("unexpected node"));

View File

@ -20,7 +20,6 @@
package org.elasticsearch.painless.node;
import org.elasticsearch.painless.ClassWriter;
import org.elasticsearch.painless.CompilerSettings;
import org.elasticsearch.painless.Globals;
import org.elasticsearch.painless.Locals;
import org.elasticsearch.painless.Location;
@ -55,25 +54,6 @@ public final class SFor extends AStatement {
this.block = block;
}
@Override
void storeSettings(CompilerSettings settings) {
if (initializer != null) {
initializer.storeSettings(settings);
}
if (condition != null) {
condition.storeSettings(settings);
}
if (afterthought != null) {
afterthought.storeSettings(settings);
}
if (block != null) {
block.storeSettings(settings);
}
}
@Override
void extractVariables(Set<String> variables) {
if (initializer != null) {

View File

@ -78,13 +78,6 @@ public final class SFunction extends AStatement {
this.synthetic = synthetic;
}
@Override
void storeSettings(CompilerSettings settings) {
block.storeSettings(settings);
this.settings = settings;
}
@Override
void extractVariables(Set<String> variables) {
// we reset the list for function scope
@ -128,6 +121,8 @@ public final class SFunction extends AStatement {
@Override
void analyze(ScriptRoot scriptRoot, Locals locals) {
this.settings = scriptRoot.getCompilerSettings();
if (block.statements.isEmpty()) {
throw createError(new IllegalArgumentException("Cannot generate an empty function [" + name + "]."));
}

View File

@ -20,7 +20,6 @@
package org.elasticsearch.painless.node;
import org.elasticsearch.painless.ClassWriter;
import org.elasticsearch.painless.CompilerSettings;
import org.elasticsearch.painless.Globals;
import org.elasticsearch.painless.Locals;
import org.elasticsearch.painless.Location;
@ -47,15 +46,6 @@ public final class SIf extends AStatement {
this.ifblock = ifblock;
}
@Override
void storeSettings(CompilerSettings settings) {
condition.storeSettings(settings);
if (ifblock != null) {
ifblock.storeSettings(settings);
}
}
@Override
void extractVariables(Set<String> variables) {
condition.extractVariables(variables);

View File

@ -20,7 +20,6 @@
package org.elasticsearch.painless.node;
import org.elasticsearch.painless.ClassWriter;
import org.elasticsearch.painless.CompilerSettings;
import org.elasticsearch.painless.Globals;
import org.elasticsearch.painless.Locals;
import org.elasticsearch.painless.Location;
@ -52,19 +51,6 @@ public final class SIfElse extends AStatement {
this.elseblock = elseblock;
}
@Override
void storeSettings(CompilerSettings settings) {
condition.storeSettings(settings);
if (ifblock != null) {
ifblock.storeSettings(settings);
}
if (elseblock != null) {
elseblock.storeSettings(settings);
}
}
@Override
void extractVariables(Set<String> variables) {
condition.extractVariables(variables);

View File

@ -20,7 +20,6 @@
package org.elasticsearch.painless.node;
import org.elasticsearch.painless.ClassWriter;
import org.elasticsearch.painless.CompilerSettings;
import org.elasticsearch.painless.Globals;
import org.elasticsearch.painless.Locals;
import org.elasticsearch.painless.Location;
@ -43,13 +42,6 @@ public final class SReturn extends AStatement {
this.expression = expression;
}
@Override
void storeSettings(CompilerSettings settings) {
if (expression != null) {
expression.storeSettings(settings);
}
}
@Override
void extractVariables(Set<String> variables) {
if (expression != null) {

View File

@ -21,7 +21,6 @@ package org.elasticsearch.painless.node;
import org.elasticsearch.painless.AnalyzerCaster;
import org.elasticsearch.painless.ClassWriter;
import org.elasticsearch.painless.CompilerSettings;
import org.elasticsearch.painless.Globals;
import org.elasticsearch.painless.Locals;
import org.elasticsearch.painless.Locals.Variable;
@ -57,11 +56,6 @@ final class SSubEachArray extends AStatement {
this.block = block;
}
@Override
void storeSettings(CompilerSettings settings) {
throw createError(new IllegalStateException("illegal tree structure"));
}
@Override
void extractVariables(Set<String> variables) {
throw createError(new IllegalStateException("Illegal tree structure."));

View File

@ -21,7 +21,6 @@ package org.elasticsearch.painless.node;
import org.elasticsearch.painless.AnalyzerCaster;
import org.elasticsearch.painless.ClassWriter;
import org.elasticsearch.painless.CompilerSettings;
import org.elasticsearch.painless.DefBootstrap;
import org.elasticsearch.painless.Globals;
import org.elasticsearch.painless.Locals;
@ -66,11 +65,6 @@ final class SSubEachIterable extends AStatement {
this.block = block;
}
@Override
void storeSettings(CompilerSettings settings) {
throw createError(new IllegalStateException("illegal tree structure"));
}
@Override
void extractVariables(Set<String> variables) {
throw createError(new IllegalStateException("Illegal tree structure."));

View File

@ -20,7 +20,6 @@
package org.elasticsearch.painless.node;
import org.elasticsearch.painless.ClassWriter;
import org.elasticsearch.painless.CompilerSettings;
import org.elasticsearch.painless.Globals;
import org.elasticsearch.painless.Locals;
import org.elasticsearch.painless.Location;
@ -43,11 +42,6 @@ public final class SThrow extends AStatement {
this.expression = Objects.requireNonNull(expression);
}
@Override
void storeSettings(CompilerSettings settings) {
expression.storeSettings(settings);
}
@Override
void extractVariables(Set<String> variables) {
expression.extractVariables(variables);

View File

@ -20,7 +20,6 @@
package org.elasticsearch.painless.node;
import org.elasticsearch.painless.ClassWriter;
import org.elasticsearch.painless.CompilerSettings;
import org.elasticsearch.painless.Globals;
import org.elasticsearch.painless.Locals;
import org.elasticsearch.painless.Location;
@ -49,17 +48,6 @@ public final class STry extends AStatement {
this.catches = Collections.unmodifiableList(catches);
}
@Override
void storeSettings(CompilerSettings settings) {
if (block != null) {
block.storeSettings(settings);
}
for (SCatch ctch : catches) {
ctch.storeSettings(settings);
}
}
@Override
void extractVariables(Set<String> variables) {
if (block != null) {

View File

@ -20,7 +20,6 @@
package org.elasticsearch.painless.node;
import org.elasticsearch.painless.ClassWriter;
import org.elasticsearch.painless.CompilerSettings;
import org.elasticsearch.painless.Globals;
import org.elasticsearch.painless.Locals;
import org.elasticsearch.painless.Location;
@ -49,15 +48,6 @@ public final class SWhile extends AStatement {
this.block = block;
}
@Override
void storeSettings(CompilerSettings settings) {
condition.storeSettings(settings);
if (block != null) {
block.storeSettings(settings);
}
}
@Override
void extractVariables(Set<String> variables) {
condition.extractVariables(variables);