2018-06-13 00:39:33 +00:00
|
|
|
package io.github.applecommander.bastools.api;
|
2018-05-29 03:33:41 +00:00
|
|
|
|
|
|
|
import java.util.function.Function;
|
|
|
|
|
2018-06-13 00:39:33 +00:00
|
|
|
import io.github.applecommander.bastools.api.optimizations.ExtractConstantValues;
|
|
|
|
import io.github.applecommander.bastools.api.optimizations.MergeLines;
|
|
|
|
import io.github.applecommander.bastools.api.optimizations.RemoveEmptyStatements;
|
|
|
|
import io.github.applecommander.bastools.api.optimizations.RemoveRemStatements;
|
|
|
|
import io.github.applecommander.bastools.api.optimizations.Renumber;
|
2018-05-29 03:33:41 +00:00
|
|
|
|
2018-06-10 15:39:14 +00:00
|
|
|
/**
|
|
|
|
* All optimization capabilities are definined here in the "best" manner of execution.
|
|
|
|
* Essentially, the goal is to prioritize the optimizations to manage dependencies.
|
|
|
|
*/
|
2018-05-29 03:33:41 +00:00
|
|
|
public enum Optimization {
|
2018-06-09 16:24:29 +00:00
|
|
|
REMOVE_EMPTY_STATEMENTS(RemoveEmptyStatements::new),
|
|
|
|
REMOVE_REM_STATEMENTS(RemoveRemStatements::new),
|
2018-06-10 15:39:14 +00:00
|
|
|
EXTRACT_CONSTANT_VALUES(ExtractConstantValues::new),
|
2018-06-09 16:24:29 +00:00
|
|
|
MERGE_LINES(MergeLines::new),
|
|
|
|
RENUMBER(Renumber::new);
|
2018-05-29 03:33:41 +00:00
|
|
|
|
|
|
|
private Function<Configuration,Visitor> factory;
|
|
|
|
|
|
|
|
private Optimization(Function<Configuration,Visitor> factory) {
|
|
|
|
this.factory = factory;
|
|
|
|
}
|
|
|
|
|
|
|
|
public Visitor create(Configuration config) {
|
|
|
|
return factory.apply(config);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|