Remove unused params from SSource and Walker (#31935)
The "source" field in SSource seems unused. If removed, it can also be removed from the ctor, which in turn makes is possible to delete the sourceText in the Walker class.
This commit is contained in:
parent
a14db2f9d6
commit
ca4c4f736a
|
@ -29,7 +29,6 @@ import org.antlr.v4.runtime.Recognizer;
|
|||
import org.antlr.v4.runtime.atn.PredictionMode;
|
||||
import org.antlr.v4.runtime.tree.TerminalNode;
|
||||
import org.elasticsearch.painless.CompilerSettings;
|
||||
import org.elasticsearch.painless.lookup.PainlessLookup;
|
||||
import org.elasticsearch.painless.Globals;
|
||||
import org.elasticsearch.painless.Location;
|
||||
import org.elasticsearch.painless.Operation;
|
||||
|
@ -107,6 +106,7 @@ import org.elasticsearch.painless.antlr.PainlessParser.TrueContext;
|
|||
import org.elasticsearch.painless.antlr.PainlessParser.TryContext;
|
||||
import org.elasticsearch.painless.antlr.PainlessParser.VariableContext;
|
||||
import org.elasticsearch.painless.antlr.PainlessParser.WhileContext;
|
||||
import org.elasticsearch.painless.lookup.PainlessLookup;
|
||||
import org.elasticsearch.painless.node.AExpression;
|
||||
import org.elasticsearch.painless.node.ANode;
|
||||
import org.elasticsearch.painless.node.AStatement;
|
||||
|
@ -184,7 +184,6 @@ public final class Walker extends PainlessParserBaseVisitor<ANode> {
|
|||
private final CompilerSettings settings;
|
||||
private final Printer debugStream;
|
||||
private final String sourceName;
|
||||
private final String sourceText;
|
||||
private final PainlessLookup painlessLookup;
|
||||
|
||||
private final Deque<Reserved> reserved = new ArrayDeque<>();
|
||||
|
@ -198,7 +197,6 @@ public final class Walker extends PainlessParserBaseVisitor<ANode> {
|
|||
this.debugStream = debugStream;
|
||||
this.settings = settings;
|
||||
this.sourceName = Location.computeSourceName(sourceName);
|
||||
this.sourceText = sourceText;
|
||||
this.globals = new Globals(new BitSet(sourceText.length()));
|
||||
this.painlessLookup = painlessLookup;
|
||||
this.source = (SSource)visit(buildAntlrTree(sourceText));
|
||||
|
@ -267,7 +265,7 @@ public final class Walker extends PainlessParserBaseVisitor<ANode> {
|
|||
statements.add((AStatement)visit(ctx.dstatement()));
|
||||
}
|
||||
|
||||
return new SSource(scriptClassInfo, settings, sourceName, sourceText, debugStream, (MainMethodReserved)reserved.pop(),
|
||||
return new SSource(scriptClassInfo, settings, sourceName, debugStream, (MainMethodReserved)reserved.pop(),
|
||||
location(ctx), functions, globals, statements);
|
||||
}
|
||||
|
||||
|
|
|
@ -21,9 +21,6 @@ package org.elasticsearch.painless.node;
|
|||
|
||||
import org.elasticsearch.painless.CompilerSettings;
|
||||
import org.elasticsearch.painless.Constant;
|
||||
import org.elasticsearch.painless.lookup.PainlessLookup;
|
||||
import org.elasticsearch.painless.lookup.PainlessMethod;
|
||||
import org.elasticsearch.painless.lookup.PainlessMethodKey;
|
||||
import org.elasticsearch.painless.Globals;
|
||||
import org.elasticsearch.painless.Locals;
|
||||
import org.elasticsearch.painless.Locals.Variable;
|
||||
|
@ -32,6 +29,9 @@ import org.elasticsearch.painless.MethodWriter;
|
|||
import org.elasticsearch.painless.ScriptClassInfo;
|
||||
import org.elasticsearch.painless.SimpleChecksAdapter;
|
||||
import org.elasticsearch.painless.WriterConstants;
|
||||
import org.elasticsearch.painless.lookup.PainlessLookup;
|
||||
import org.elasticsearch.painless.lookup.PainlessMethod;
|
||||
import org.elasticsearch.painless.lookup.PainlessMethodKey;
|
||||
import org.elasticsearch.painless.node.SFunction.FunctionReserved;
|
||||
import org.objectweb.asm.ClassVisitor;
|
||||
import org.objectweb.asm.ClassWriter;
|
||||
|
@ -130,7 +130,6 @@ public final class SSource extends AStatement {
|
|||
private final ScriptClassInfo scriptClassInfo;
|
||||
private final CompilerSettings settings;
|
||||
private final String name;
|
||||
private final String source;
|
||||
private final Printer debugStream;
|
||||
private final MainMethodReserved reserved;
|
||||
private final List<SFunction> functions;
|
||||
|
@ -141,14 +140,12 @@ public final class SSource extends AStatement {
|
|||
private final List<org.objectweb.asm.commons.Method> getMethods;
|
||||
private byte[] bytes;
|
||||
|
||||
public SSource(ScriptClassInfo scriptClassInfo, CompilerSettings settings, String name, String source, Printer debugStream,
|
||||
MainMethodReserved reserved, Location location,
|
||||
List<SFunction> functions, Globals globals, List<AStatement> statements) {
|
||||
public SSource(ScriptClassInfo scriptClassInfo, CompilerSettings settings, String name, Printer debugStream,
|
||||
MainMethodReserved reserved, Location location, List<SFunction> functions, Globals globals, List<AStatement> statements) {
|
||||
super(location);
|
||||
this.scriptClassInfo = Objects.requireNonNull(scriptClassInfo);
|
||||
this.settings = Objects.requireNonNull(settings);
|
||||
this.name = Objects.requireNonNull(name);
|
||||
this.source = Objects.requireNonNull(source);
|
||||
this.debugStream = debugStream;
|
||||
this.reserved = Objects.requireNonNull(reserved);
|
||||
// process any synthetic functions generated by walker (because right now, thats still easy)
|
||||
|
|
Loading…
Reference in New Issue