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

View File

@ -20,7 +20,6 @@
package org.elasticsearch.painless.node; package org.elasticsearch.painless.node;
import org.elasticsearch.painless.ClassWriter; import org.elasticsearch.painless.ClassWriter;
import org.elasticsearch.painless.CompilerSettings;
import org.elasticsearch.painless.Globals; import org.elasticsearch.painless.Globals;
import org.elasticsearch.painless.Locals; import org.elasticsearch.painless.Locals;
import org.elasticsearch.painless.Location; import org.elasticsearch.painless.Location;
@ -56,11 +55,6 @@ public abstract class ANode {
this.location = Objects.requireNonNull(location); 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. * Adds all variable names referenced to the variable set.
* <p> * <p>

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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