Permalink
Browse files

Deprecate and hide entity_id() and entity_uuid()

  • Loading branch information...
PseudoKnight committed Nov 3, 2017
1 parent 394bceb commit 7015e9d732c1289df4370c6d16f572b4a790ca52
@@ -1831,7 +1831,11 @@ private static void optimize(ParseTree tree, Stack<List<Procedure>> procs, Set<C
throw new ConfigCompileException(e);
}
if (tempNode == Optimizable.PULL_ME_UP) {
tempNode = tree.getChildAt(0);
if(tree.hasChildren()) {
tempNode = tree.getChildAt(0);
} else {
tempNode = null;
}
}
if (tempNode == Optimizable.REMOVE_ME) {
tree.setData(new CFunction("p", Target.UNKNOWN));
@@ -115,12 +115,12 @@
/**
* This is a priority optimization function, meaning it needs to be optimized before its children are.
* This is required when optimization of the children could cause different internal behavior, for instance
* if this function is expecting the precense of soem code element, but the child gets optimized out, this
* if this function is expecting the presence of some code element, but the child gets optimized out, this
* would cause an error, even though the user did in fact provide code in that section.
*/
PRIORITY_OPTIMIZATION("This is a priority optimization function, meaning it needs to be optimized before its children are."
+ " This is required when optimization of the children could cause different internal behavior, for instance"
+ " if this function is expecting the precense of soem code element, but the child gets optimized out, this"
+ " if this function is expecting the presence of some code element, but the child gets optimized out, this"
+ " would cause an error, even though the user did in fact provide code in that section.", CHVersion.V3_3_1);
private final CHVersion since;
@@ -53,11 +53,16 @@
import com.laytonsmith.abstraction.enums.MCSkeletonType;
import com.laytonsmith.abstraction.enums.MCVersion;
import com.laytonsmith.annotations.api;
import com.laytonsmith.annotations.hide;
import com.laytonsmith.annotations.seealso;
import com.laytonsmith.core.ArgumentValidation;
import com.laytonsmith.core.CHLog;
import com.laytonsmith.core.CHVersion;
import com.laytonsmith.core.ObjectGenerator;
import com.laytonsmith.core.Optimizable;
import com.laytonsmith.core.ParseTree;
import com.laytonsmith.core.Static;
import com.laytonsmith.core.compiler.FileOptions;
import com.laytonsmith.core.constructs.CArray;
import com.laytonsmith.core.constructs.CBoolean;
import com.laytonsmith.core.constructs.CDouble;
@@ -86,6 +91,7 @@
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.EnumSet;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
@@ -2498,7 +2504,8 @@ public CHVersion since() {
}
@api
public static class entity_id extends EntityGetterFunction {
@hide("Deprecated.")
public static class entity_id extends EntityGetterFunction implements Optimizable {
@Override
public Construct exec(Target t, Environment environment, Construct... args) throws ConfigRuntimeException {
@@ -2521,10 +2528,21 @@ public CHVersion since() {
return CHVersion.V3_3_1;
}
@Override
public ParseTree optimizeDynamic(Target t, List<ParseTree> children, FileOptions fileOptions) throws ConfigCompileException, ConfigRuntimeException {
CHLog.GetLogger().w(CHLog.Tags.DEPRECATION, "The function entity_id() is deprecated.", t);
return Optimizable.PULL_ME_UP;
}
@Override
public Set<OptimizationOption> optimizationOptions() {
return EnumSet.of(OptimizationOption.OPTIMIZE_DYNAMIC);
}
}
@api
public static class entity_uuid extends EntityGetterFunction {
@hide("Deprecated.")
public static class entity_uuid extends EntityGetterFunction implements Optimizable {
@Override
public Construct exec(Target t, Environment environment, Construct... args) throws ConfigRuntimeException {
@@ -2546,6 +2564,17 @@ public String docs() {
public CHVersion since() {
return CHVersion.V3_3_1;
}
@Override
public ParseTree optimizeDynamic(Target t, List<ParseTree> children, FileOptions fileOptions) throws ConfigCompileException, ConfigRuntimeException {
CHLog.GetLogger().w(CHLog.Tags.DEPRECATION, "The function entity_uuid() is deprecated.", t);
return Optimizable.PULL_ME_UP;
}
@Override
public Set<OptimizationOption> optimizationOptions() {
return EnumSet.of(OptimizationOption.OPTIMIZE_DYNAMIC);
}
}
@api

0 comments on commit 7015e9d

Please sign in to comment.