Permalink
Browse files

All compile errors are fixed, but there are failing tests.

  • Loading branch information...
LadyCailin committed Nov 15, 2018
1 parent 224b8d2 commit ffa81603a64ade00d52be58f6a050ea71fc9100a
Showing with 124 additions and 119 deletions.
  1. +2 −3 src/main/java/com/laytonsmith/abstraction/bukkit/BukkitMCCommand.java
  2. +11 −9 src/main/java/com/laytonsmith/abstraction/enums/MCGameRule.java
  3. +6 −6 src/main/java/com/laytonsmith/core/Globals.java
  4. +1 −1 src/main/java/com/laytonsmith/core/MethodScriptCompiler.java
  5. +8 −8 src/main/java/com/laytonsmith/core/constructs/CEntry.java
  6. +1 −1 src/main/java/com/laytonsmith/core/constructs/CKeyword.java
  7. +3 −3 src/main/java/com/laytonsmith/core/constructs/CLabel.java
  8. +8 −0 src/main/java/com/laytonsmith/core/constructs/CString.java
  9. +4 −4 src/main/java/com/laytonsmith/core/exceptions/FunctionReturnException.java
  10. +4 −3 src/main/java/com/laytonsmith/core/functions/ArrayHandling.java
  11. +5 −4 src/main/java/com/laytonsmith/core/functions/BasicLogic.java
  12. +3 −2 src/main/java/com/laytonsmith/core/functions/ByteArrays.java
  13. +1 −2 src/main/java/com/laytonsmith/core/functions/CompositeFunction.java
  14. +2 −2 src/main/java/com/laytonsmith/core/functions/DataHandling.java
  15. +1 −1 src/main/java/com/laytonsmith/core/functions/Debug.java
  16. +5 −4 src/main/java/com/laytonsmith/core/functions/Echoes.java
  17. +9 −8 src/main/java/com/laytonsmith/core/functions/ExecutionQueue.java
  18. +2 −1 src/main/java/com/laytonsmith/core/functions/InventoryManagement.java
  19. +4 −3 src/main/java/com/laytonsmith/core/functions/Meta.java
  20. +1 −1 src/main/java/com/laytonsmith/core/functions/OAuth.java
  21. +5 −4 src/main/java/com/laytonsmith/core/functions/PlayerManagement.java
  22. +6 −5 src/main/java/com/laytonsmith/core/functions/Regex.java
  23. +3 −2 src/main/java/com/laytonsmith/core/functions/Scheduling.java
  24. +14 −13 src/main/java/com/laytonsmith/core/functions/StringHandling.java
  25. +1 −4 src/main/java/com/laytonsmith/core/functions/Trades.java
  26. +4 −18 src/main/java/com/laytonsmith/core/functions/World.java
  27. +6 −5 src/test/java/com/laytonsmith/core/events/PrefiltersTest.java
  28. +2 −1 src/test/java/com/laytonsmith/core/functions/ArrayHandlingTest.java
  29. +2 −1 src/test/java/com/laytonsmith/testing/RandomTests.java
@@ -12,7 +12,6 @@
import com.laytonsmith.core.constructs.CBoolean;
import com.laytonsmith.core.constructs.CClosure;
import com.laytonsmith.core.constructs.CString;
import com.laytonsmith.core.constructs.Construct;
import com.laytonsmith.core.constructs.Target;
import com.laytonsmith.core.environments.CommandHelperEnvironment;
import com.laytonsmith.core.events.Driver;
@@ -215,7 +214,7 @@ public String toString() {
new CArray(t) // reserved for an obgen style command array
);
} catch (FunctionReturnException e) {
Construct fret = e.getReturn();
Mixed fret = e.getReturn();
if(fret instanceof CArray) {
List<String> ret = new ArrayList<>();
if(((CArray) fret).inAssociativeMode()) {
@@ -258,7 +257,7 @@ public boolean handleCustomCommand(MCCommandSender sender, String label, String[
new CArray(t) // reserved for an obgen style command array
);
} catch (FunctionReturnException e) {
Construct fret = e.getReturn();
Mixed fret = e.getReturn();
if(fret instanceof CBoolean) {
return ((CBoolean) fret).getBoolean();
}
@@ -1,7 +1,9 @@
package com.laytonsmith.abstraction.enums;
import com.laytonsmith.annotations.MEnum;
import com.laytonsmith.core.constructs.Construct.ConstructType;
import com.laytonsmith.core.constructs.CBoolean;
import com.laytonsmith.core.constructs.CInt;
import com.laytonsmith.core.natives.interfaces.Mixed;
@MEnum("com.commandhelper.GameRule")
public enum MCGameRule {
@@ -18,26 +20,26 @@
DOWEATHERCYCLE("doWeatherCycle"),
KEEPINVENTORY("keepInventory"),
LOGADMINCOMMANDS("logAdminCommands"),
MAXCOMMANDCHAINLENGTH("maxCommandChainLength", ConstructType.INT),
MAXENTITYCRAMMING("maxEntityCramming", ConstructType.INT),
MAXCOMMANDCHAINLENGTH("maxCommandChainLength", CInt.class),
MAXENTITYCRAMMING("maxEntityCramming", CInt.class),
MOBGRIEFING("mobGriefing"),
NATURALREGENERATION("naturalRegeneration"),
RANDOMTICKSPEED("randomTickSpeed", ConstructType.INT),
RANDOMTICKSPEED("randomTickSpeed", CInt.class),
REDUCEDDEBUGINFO("reducedDebugInfo"),
SENDCOMMANDFEEDBACK("sendCommandFeedback"),
SHOWDEATHMESSAGES("showDeathMessages"),
SPAWNRADIUS("spawnRadius", ConstructType.INT),
SPAWNRADIUS("spawnRadius", CInt.class),
SPECTATORSGENERATECHUNKS("spectatorsGenerateChunks");
private final String gameRule;
private final ConstructType ruleType;
private final Class<? extends Mixed> ruleType;
MCGameRule(String gameRule) {
this.gameRule = gameRule;
this.ruleType = ConstructType.BOOLEAN;
this.ruleType = CBoolean.class;
}
MCGameRule(String gameRule, ConstructType type) {
MCGameRule(String gameRule, Class<? extends Mixed> type) {
this.gameRule = gameRule;
this.ruleType = type;
}
@@ -46,7 +48,7 @@ public String getGameRule() {
return this.gameRule;
}
public ConstructType getRuleType() {
public Class<? extends Mixed> getRuleType() {
return this.ruleType;
}
}
@@ -1,7 +1,7 @@
package com.laytonsmith.core;
import com.laytonsmith.core.constructs.CNull;
import com.laytonsmith.core.constructs.Construct;
import com.laytonsmith.core.natives.interfaces.Mixed;
import java.util.HashMap;
import java.util.Map;
@@ -13,16 +13,16 @@
private Globals() {
}
private static final Map<String, Construct> GLOBAL_CONSTRUCT = new HashMap<>();
private static final Map<String, Mixed> GLOBAL_CONSTRUCT = new HashMap<>();
/**
* Sets a variable in the global registry.
*
* @param name The value name
* @param value The value itself
*/
public static synchronized void SetGlobal(String name, Construct value) {
Map<String, Construct> vars = GLOBAL_CONSTRUCT; // (HashMap<String, Construct>)env.get("global_construct");
public static synchronized void SetGlobal(String name, Mixed value) {
Map<String, Mixed> vars = GLOBAL_CONSTRUCT; // (HashMap<String, Construct>)env.get("global_construct");
if(value instanceof CNull) {
vars.remove(name);
} else {
@@ -37,8 +37,8 @@ public static synchronized void SetGlobal(String name, Construct value) {
* @param name The name of the value to return.
* @return the construct stored at this name, or CNull if none exists
*/
public static synchronized Construct GetGlobalConstruct(String name) {
Map<String, Construct> vars = GLOBAL_CONSTRUCT; // (HashMap<String, Construct>)env.get("global_construct");
public static synchronized Mixed GetGlobalConstruct(String name) {
Map<String, Mixed> vars = GLOBAL_CONSTRUCT; // (HashMap<String, Construct>)env.get("global_construct");
return vars.getOrDefault(name, CNull.NULL);
}
@@ -2015,7 +2015,7 @@ private static void optimize(ParseTree tree, Stack<List<Procedure>> procs, Set<C
}
if(p != null) {
try {
Construct c = DataHandling.proc.optimizeProcedure(p.getTarget(), p, children);
Mixed c = DataHandling.proc.optimizeProcedure(p.getTarget(), p, children);
if(c != null) {
tree.setData(c);
tree.removeChildren();
@@ -9,15 +9,15 @@
*/
public class CEntry extends Construct {
Construct ckey;
Construct construct;
Mixed ckey;
Mixed construct;
public CEntry(String value, Target t) {
super(value, ConstructType.ENTRY, t);
throw new UnsupportedOperationException("CEntry Constructs cannot use this constructor");
}
// public CEntry(String value, Target t) {
// super(value, MixedType.ENTRY, t);
// throw new UnsupportedOperationException("CEntry Constructs cannot use this constructor");
// }
public CEntry(Construct key, Construct value, Target t) {
public CEntry(Mixed key, Mixed value, Target t) {
super(key.val() + ":(CEntry)", ConstructType.ENTRY, t);
this.ckey = key;
this.construct = value;
@@ -28,7 +28,7 @@ public String val() {
return construct.val();
}
public Construct construct() {
public Mixed construct() {
return this.construct;
}
@@ -24,7 +24,7 @@ public static boolean isKeyword(ParseTree node, String keyword) {
return node.getData() instanceof CKeyword && keyword.equals(node.getData().val());
}
public static boolean isKeyword(Construct node, String keyword) {
public static boolean isKeyword(Mixed node, String keyword) {
return node instanceof CKeyword && keyword.equals(node.val());
}
@@ -10,14 +10,14 @@
*/
public class CLabel extends Construct {
Construct label;
Mixed label;
public CLabel(Construct value) {
public CLabel(Mixed value) {
super(value.val(), ConstructType.LABEL, value.getTarget());
label = value;
}
public Construct cVal() {
public Mixed cVal() {
return label;
}
@@ -36,6 +36,14 @@ public CString(CharSequence value, Target t) {
this(value.toString(), t);
}
/**
* Given the input construct, uses the val() method of it, and constructs a new string based on that.
* @param val
*/
public CString(Mixed val) {
this(val.val(), val.getTarget());
}
@Override
public CString clone() throws CloneNotSupportedException {
return this;
@@ -1,22 +1,22 @@
package com.laytonsmith.core.exceptions;
import com.laytonsmith.core.constructs.Construct;
import com.laytonsmith.core.constructs.Target;
import com.laytonsmith.core.natives.interfaces.Mixed;
/**
*
*
*/
public class FunctionReturnException extends ProgramFlowManipulationException {
Construct ret;
Mixed ret;
public FunctionReturnException(Construct ret, Target t) {
public FunctionReturnException(Mixed ret, Target t) {
super(t);
this.ret = ret;
}
public Construct getReturn() {
public Mixed getReturn() {
return ret;
}
}
@@ -25,6 +25,7 @@
import com.laytonsmith.core.constructs.CSlice;
import com.laytonsmith.core.constructs.CString;
import com.laytonsmith.core.constructs.CVoid;
import com.laytonsmith.core.constructs.Construct;
import com.laytonsmith.core.constructs.Target;
import com.laytonsmith.core.environments.Environment;
import com.laytonsmith.core.environments.GlobalEnv;
@@ -354,7 +355,7 @@ public Mixed execs(Target t, Environment env, Script parent, ParseTree... nodes)
try {
((CArray) array).set(index, value, t);
} catch (IndexOutOfBoundsException e) {
throw new CREIndexOverflowException("The index " + index.asString().getQuote() + " is out of bounds", t);
throw new CREIndexOverflowException("The index " + new CString(index).getQuote() + " is out of bounds", t);
}
return value;
}
@@ -1639,7 +1640,7 @@ public CHVersion since() {
@Override
public ParseTree optimizeDynamic(Target t, List<ParseTree> children, FileOptions fileOptions) throws ConfigCompileException, ConfigRuntimeException {
if(children.size() == 2) {
if(!children.get(1).getData().isDynamic()) {
if(!Construct.IsDynamicHelper(children.get(1).getData())) {
try {
CArray.SortType.valueOf(children.get(1).getData().val().toUpperCase());
} catch (IllegalArgumentException e) {
@@ -3286,7 +3287,7 @@ public Mixed exec(Target t, Environment environment, Mixed... args) throws Confi
}
public boolean subsetOf(Mixed constA, Mixed constB, Target t) {
if(constA.getCType() != constB.getCType()) {
if(!constA.typeof().equals(constB.typeof())) {
return false;
}
if(constA instanceof CArray) {
@@ -24,6 +24,7 @@
import com.laytonsmith.core.constructs.CSlice;
import com.laytonsmith.core.constructs.CString;
import com.laytonsmith.core.constructs.CVoid;
import com.laytonsmith.core.constructs.Construct;
import com.laytonsmith.core.constructs.Target;
import com.laytonsmith.core.environments.Environment;
import com.laytonsmith.core.environments.GlobalEnv;
@@ -637,7 +638,7 @@ public int compare(Mixed t, Mixed t1) {
&& new DataHandling.array().getName().equals(children.get(i).getData().val())) {
CArray data = new CArray(t);
for(ParseTree child : children.get(i).getChildren()) {
if(child.getData().isDynamic()) {
if(Construct.IsDynamicHelper(child.getData())) {
throw new ConfigCompileException(notConstant, child.getTarget());
}
data.push(child.getData(), t);
@@ -656,7 +657,7 @@ public int compare(Mixed t, Mixed t1) {
values.add(cc);
}
} else {
if(c.isDynamic()) {
if(Construct.IsDynamicHelper(c)) {
throw new ConfigCompileException(notConstant, c.getTarget());
}
if(values.contains(c)) {
@@ -667,7 +668,7 @@ public int compare(Mixed t, Mixed t1) {
}
} else {
Mixed c = children.get(i).getData();
if(c.isDynamic()) {
if(Construct.IsDynamicHelper(c)) {
throw new ConfigCompileException(notConstant, c.getTarget());
}
if(values.contains(c)) {
@@ -680,7 +681,7 @@ public int compare(Mixed t, Mixed t1) {
if((children.size() > 3 || (children.size() > 1 && children.get(1).getData() instanceof CArray))
//No point in doing this optimization if there are only 3 args and the case is flat.
//Also, doing this check prevents an inifinite loop during optimization.
&& (children.size() > 0 && !children.get(0).getData().isDynamic())) {
&& (children.size() > 0 && !Construct.IsDynamicHelper(children.get(0).getData()))) {
ParseTree toReturn = null;
//The item passed in is constant (or has otherwise been made constant)
//so we can go ahead and condense this down to the single code path
@@ -12,6 +12,7 @@
import com.laytonsmith.core.constructs.CInt;
import com.laytonsmith.core.constructs.CString;
import com.laytonsmith.core.constructs.CVoid;
import com.laytonsmith.core.constructs.Construct;
import com.laytonsmith.core.constructs.Target;
import com.laytonsmith.core.environments.Environment;
import com.laytonsmith.core.exceptions.CRE.CRECastException;
@@ -416,7 +417,7 @@ public Mixed exec(Target t, Environment environment, Mixed... args) throws Confi
Integer pos = get_getPos(args, t);
String encoding = null;
if(args.length == 3) {
encoding = args[2].nval();
encoding = Construct.nval(args[2]);
}
try {
return new CString(ba.readUTF8String(pos, encoding), t);
@@ -702,7 +703,7 @@ public Mixed exec(Target t, Environment environment, Mixed... args) throws Confi
Integer pos = set_getPos(args, t);
String encoding = null;
if(args.length == 3) {
encoding = args[2].nval();
encoding = Construct.nval(args[2]);
}
try {
ba.writeUTF8String(s, pos, encoding);
@@ -6,7 +6,6 @@
import com.laytonsmith.core.constructs.CArray;
import com.laytonsmith.core.constructs.CClassType;
import com.laytonsmith.core.constructs.CVoid;
import com.laytonsmith.core.constructs.Construct;
import com.laytonsmith.core.constructs.IVariable;
import com.laytonsmith.core.constructs.IVariableList;
import com.laytonsmith.core.constructs.Target;
@@ -54,7 +53,7 @@ public Mixed exec(Target t, Environment environment, Mixed... args) throws Confi
IVariableList newVariables = new IVariableList();
newVariables.set(new IVariable(CClassType.get("array"), "@arguments", new CArray(t, args.length, args), t));
env.SetVarList(newVariables);
Construct ret = CVoid.VOID;
Mixed ret = CVoid.VOID;
try {
if(env.GetScript() != null) {
env.GetScript().eval(tree, environment);
@@ -2196,8 +2196,8 @@ public static Procedure getProcedure(Target t, Environment env, Script parent, P
if(nodes[i].getData() instanceof CFunction) {
if(((CFunction) nodes[i].getData()).getValue().equals("assign")) {
thisNodeIsAssign = true;
if((nodes[i].getChildren().size() == 3 && nodes[i].getChildAt(0).getData().isDynamic())
|| nodes[i].getChildAt(1).getData().isDynamic()) {
if((nodes[i].getChildren().size() == 3 && Construct.IsDynamicHelper(nodes[i].getChildAt(0).getData()))
|| Construct.IsDynamicHelper(nodes[i].getChildAt(1).getData())) {
usesAssign = true;
}
}
@@ -273,7 +273,7 @@ public Mixed exec(Target t, Environment environment, Mixed... args) throws Confi
}
return CVoid.VOID;
} else {
throw new CRECastException("Expecting an ivar, but recieved " + args[0].getCType() + " instead", t);
throw new CRECastException("Expecting an ivar, but recieved " + args[0].typeof().getSimpleName() + " instead", t);
}
//TODO: Once Prefs are no longer static, check to see if debug mode is on during compilation, and
//if so, remove this function entirely
Oops, something went wrong.

0 comments on commit ffa8160

Please sign in to comment.