Skip to content

Commit

Permalink
Merge branch 'master' of github.com:sk89q/commandhelper
Browse files Browse the repository at this point in the history
  • Loading branch information
LadyCailin committed Nov 4, 2015
2 parents c4d85cc + 845ee8d commit e2f9546
Show file tree
Hide file tree
Showing 8 changed files with 10 additions and 296 deletions.
95 changes: 0 additions & 95 deletions README.html

This file was deleted.

20 changes: 0 additions & 20 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -465,26 +465,6 @@
</configuration>
</plugin>

<!-- Assembly -->
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.2-beta-2</version>
<configuration>
<descriptor>${basedir}/src/main/assembly/default.xml</descriptor>
</configuration>
</plugin>

<!-- Release -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
<version>2.2.2</version>
<configuration>
<preparationGoals>assembly:assembly</preparationGoals>
<goals>assembly:assembly</goals>
</configuration>
</plugin>

<!-- Shade plugin -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
Expand Down
33 changes: 0 additions & 33 deletions src/main/assembly/default.xml

This file was deleted.

24 changes: 0 additions & 24 deletions src/main/java/com/laytonsmith/core/MethodScriptCompiler.java
Original file line number Diff line number Diff line change
Expand Up @@ -1592,30 +1592,6 @@ private static void optimize(ParseTree tree, Stack<List<Procedure>> procs, Set<C
//There's no way to optimize something that's not a function
return;
}
//cc has to be inb4 other autoconcats, so sconcats on the lower level won't get run
if (tree.getData().val().equals("cc")) {
for (int i = 0; i < tree.getChildren().size(); i++) {
ParseTree node = tree.getChildAt(i);
if (node.getData().val().equals(__autoconcat__)) {
Compiler.__autoconcat__ func;
try {
func = (Compiler.__autoconcat__) FunctionList.getFunction(node.getData());
} catch (ConfigCompileException ex) {
compilerErrors.add(ex);
return;
}
try {
ParseTree tempNode = func.optimizeSpecial(node.getChildren(), false);
tree.setData(tempNode.getData());
tree.setChildren(tempNode.getChildren());
} catch (ConfigCompileException ex) {
compilerErrors.add(ex);
}
optimize(tree, procs, compilerErrors);
return;
}
}
}
//If it is a proc definition, we need to go ahead and see if we can add it to the const proc stack
if (tree.getData().val().equals("proc")) {
procs.push(new ArrayList<Procedure>());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ public static ParseTree compile(TokenStream tokenStream, Environment compilerEnv

private static void link(ParseTree root, Environment compilerEnvirontment) throws ConfigCompileException {
//Before we actually link, we need to optimize our branch functions, that is,
//currently just if. However, at this point, we also need to optimize __autoconcat__ and cc.
//currently just if. However, at this point, we also need to optimize __autoconcat__.
//so we know what the tree actually looks like. Also, we want to first group all our auto includes
//together, along with our actual tree.
ParseTree master = new ParseTree(new CFunction("__autoconcat__", Target.UNKNOWN), root.getFileOptions());
Expand Down
29 changes: 8 additions & 21 deletions src/main/java/com/laytonsmith/core/compiler/OptimizerObject.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,27 +43,14 @@ public ParseTree optimize() throws ConfigCompileException{
private void optimize01(ParseTree tree, CompilerEnvironment compilerEnvironment) throws ConfigCompileException {
com.laytonsmith.core.functions.Compiler.__autoconcat__ autoconcat
= (com.laytonsmith.core.functions.Compiler.__autoconcat__) FunctionList.getFunction("__autoconcat__", Target.UNKNOWN);
if (tree.getData() instanceof CFunction && tree.getData().val().equals("cc")) {
for (int i = 0; i < tree.getChildren().size(); i++) {
ParseTree node = tree.getChildAt(i);
if (node.getData().val().equals("__autoconcat__")) {
ParseTree tempNode = autoconcat.optimizeSpecial(node.getChildren(), false);
tree.setData(tempNode.getData());
tree.setChildren(tempNode.getChildren());
optimize01(tree, compilerEnvironment);
return;
}
}
} else {
if (tree.getData() instanceof CFunction && tree.getData().val().equals("__autoconcat__")) {
ParseTree tempNode = autoconcat.optimizeSpecial(tree.getChildren(), true);
tree.setData(tempNode.getData());
tree.setChildren(tempNode.getChildren());
}
for (int i = 0; i < tree.getChildren().size(); i++) {
ParseTree node = tree.getChildren().get(i);
optimize01(node, compilerEnvironment);
}
if (tree.getData() instanceof CFunction && tree.getData().val().equals("__autoconcat__")) {
ParseTree tempNode = autoconcat.optimizeSpecial(tree.getChildren(), true);
tree.setData(tempNode.getData());
tree.setChildren(tempNode.getChildren());
}
for (int i = 0; i < tree.getChildren().size(); i++) {
ParseTree node = tree.getChildren().get(i);
optimize01(node, compilerEnvironment);
}
}

Expand Down
101 changes: 0 additions & 101 deletions src/main/java/com/laytonsmith/core/functions/StringHandling.java
Original file line number Diff line number Diff line change
Expand Up @@ -59,107 +59,6 @@ public static String docs() {
return "These class provides functions that allow strings to be manipulated";
}

@api
@hide("Overly complicated, and just not worth having. This is deprecated, and will be removed in a future release")
public static class cc extends AbstractFunction implements Optimizable {

@Override
public String getName() {
return "cc";
}

@Override
public Integer[] numArgs() {
return new Integer[]{Integer.MAX_VALUE};
}

@Override
public String docs() {
return "string {args...} The cousin to <strong>c</strong>on<strong>c</strong>at, this function does some magic under the covers"
+ " to remove the auto-concatenation effect in bare strings. Take the following example: cc(bare string) -> barestring";
}

@Override
public ExceptionType[] thrown() {
return null;
}

@Override
public boolean isRestricted() {
return false;
}

@Override
public boolean preResolveVariables() {
return false;
}

@Override
public CHVersion since() {
return CHVersion.V3_3_1;
}

@Override
public Boolean runAsync() {
return null;
}

@Override
public Construct exec(Target t, Environment environment, Construct... args) throws ConfigRuntimeException {
return CVoid.VOID;
}

@Override
public Construct execs(Target t, Environment env, Script parent, ParseTree... nodes) {
//if any of the nodes are sconcat, move their children up a level
List<ParseTree> list = new ArrayList<ParseTree>();
for (ParseTree node : nodes) {
if (node.getData().val().equals("sconcat")) {
for (ParseTree sub : node.getChildren()) {
list.add(sub);
}
} else {
list.add(node);
}
}

StringBuilder b = new StringBuilder();
for (ParseTree node : list) {
Construct c = parent.seval(node, env);
b.append(c.val());
}
return new CString(b.toString(), t);
}

@Override
public boolean useSpecialExec() {
return true;
}

public ParseTree optimizeSpecial(Target target, List<ParseTree> children) {
throw new UnsupportedOperationException("Not yet implemented");
}

@Override
public ExampleScript[] examples() throws ConfigCompileException {
return new ExampleScript[]{
new ExampleScript("", "cc('These' 'normally' 'have' 'spaces' 'between' 'them')"),};
}

@Override
public Set<OptimizationOption> optimizationOptions() {
return EnumSet.of(OptimizationOption.OPTIMIZE_DYNAMIC);
}

@Override
public ParseTree optimizeDynamic(Target t, List<ParseTree> children, FileOptions fileOptions) throws ConfigCompileException, ConfigRuntimeException {
CHLog.GetLogger().w(CHLog.Tags.DEPRECATION, getName() + " has been deprecated, and will be removed in a future release."
+ " Please use dot concatenation where necessary, to achieve the same effect.", t);
return null;
}

}

@api
public static class concat extends AbstractFunction implements Optimizable {

Expand Down
2 changes: 1 addition & 1 deletion src/test/java/com/laytonsmith/testing/ProcedureTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public void setUp() {
}

@Test public void ensureOutOfScopeWorks() throws Exception{
SRun("assign(@lol, '42') proc(_blah, msg(cc('notlol' @lol))) _blah()", fakePlayer);
SRun("assign(@lol, '42') proc(_blah, msg('notlol'.@lol)) _blah()", fakePlayer);
verify(fakePlayer).sendMessage("notlolnull");
}

Expand Down

0 comments on commit e2f9546

Please sign in to comment.