From 4a7059020377ae3c47378f0be685520de991c5f9 Mon Sep 17 00:00:00 2001 From: LadyCailin Date: Wed, 18 Feb 2026 16:14:54 +0100 Subject: [PATCH 01/28] Add GenericParameters to exec signature. (#1407) Add GenericParameters to exec signature. This change adds GenericParameters to Function.exec. This is currently unused, but will be used once the genericsTake2 branch is merged in. This is a backwards incompatible change in general, and extensions will not be able to recompile with this change in. However, the call sites for all uses of general exec have been updated to use reflection to fall back to the old 3 argument version if the new method call fails. All core classes have been updated, which also necessitated changes to caller sites in some places as well. --- src/main/java/com/laytonsmith/core/Main.java | 8 +- .../core/MethodScriptCompiler.java | 2 +- .../java/com/laytonsmith/core/Script.java | 2 +- .../java/com/laytonsmith/core/Updater.java | 2 +- .../com/laytonsmith/core/asm/AsmCompiler.java | 2 +- .../laytonsmith/core/asm/LLVMFunction.java | 6 +- .../laytonsmith/core/constructs/CArray.java | 10 +- .../core/constructs/CResource.java | 2 +- .../laytonsmith/core/constructs/CSlice.java | 2 +- .../core/events/drivers/PlayerEvents.java | 4 +- .../core/functions/ArrayHandling.java | 111 ++++----- .../core/functions/BasicLogic.java | 79 ++++--- .../laytonsmith/core/functions/BossBar.java | 17 +- .../core/functions/BukkitMetadata.java | 9 +- .../core/functions/ByteArrays.java | 47 ++-- .../laytonsmith/core/functions/Clipboard.java | 5 +- .../laytonsmith/core/functions/Cmdline.java | 61 ++--- .../laytonsmith/core/functions/Commands.java | 13 +- .../laytonsmith/core/functions/Compiler.java | 25 +- .../core/functions/CompositeFunction.java | 3 +- .../core/functions/ControlFlow.java | 46 ++-- .../laytonsmith/core/functions/Crypto.java | 25 +- .../core/functions/DataHandling.java | 83 +++---- .../core/functions/DataTransformations.java | 17 +- .../com/laytonsmith/core/functions/Debug.java | 21 +- .../laytonsmith/core/functions/Easings.java | 5 +- .../laytonsmith/core/functions/Echoes.java | 25 +- .../core/functions/Enchantments.java | 17 +- .../core/functions/EntityManagement.java | 147 ++++++------ .../core/functions/Environment.java | 93 ++++---- .../core/functions/EventBinding.java | 27 ++- .../core/functions/Exceptions.java | 11 +- .../core/functions/ExecutionQueue.java | 17 +- .../core/functions/ExtensionMeta.java | 13 +- .../core/functions/FileHandling.java | 21 +- .../laytonsmith/core/functions/Function.java | 50 +++- .../core/functions/InventoryManagement.java | 69 +++--- .../laytonsmith/core/functions/ItemMeta.java | 11 +- .../laytonsmith/core/functions/Marquee.java | 5 +- .../com/laytonsmith/core/functions/Math.java | 89 +++---- .../core/functions/MatrixHandling.java | 39 +-- .../com/laytonsmith/core/functions/Meta.java | 69 +++--- .../laytonsmith/core/functions/Minecraft.java | 37 +-- .../core/functions/MobManagement.java | 103 ++++---- .../com/laytonsmith/core/functions/OAuth.java | 15 +- .../com/laytonsmith/core/functions/OS.java | 3 +- .../core/functions/ObjectManagement.java | 11 +- .../core/functions/Performance.java | 3 +- .../core/functions/Permissions.java | 3 +- .../core/functions/Persistence.java | 11 +- .../core/functions/PlayerManagement.java | 223 +++++++++--------- .../core/functions/PluginMeta.java | 13 +- .../laytonsmith/core/functions/Recipes.java | 13 +- .../core/functions/Reflection.java | 23 +- .../com/laytonsmith/core/functions/Regex.java | 13 +- .../core/functions/ResourceManager.java | 5 +- .../com/laytonsmith/core/functions/SQL.java | 7 +- .../laytonsmith/core/functions/Sandbox.java | 17 +- .../core/functions/Scheduling.java | 23 +- .../core/functions/Scoreboards.java | 43 ++-- .../core/functions/Statistics.java | 13 +- .../core/functions/StringHandling.java | 59 ++--- .../core/functions/TaskHandling.java | 5 +- .../laytonsmith/core/functions/Threading.java | 25 +- .../laytonsmith/core/functions/Trades.java | 15 +- .../laytonsmith/core/functions/Weather.java | 11 +- .../com/laytonsmith/core/functions/Web.java | 11 +- .../com/laytonsmith/core/functions/World.java | 77 +++--- .../com/laytonsmith/core/functions/XGUI.java | 9 +- .../core/functions/asm/Cmdline.java | 5 +- .../core/functions/asm/Compiler.java | 5 +- .../core/functions/asm/DataHandling.java | 3 +- .../laytonsmith/core/functions/asm/Math.java | 3 +- .../laytonsmith/core/functions/asm/Meta.java | 3 +- .../com/laytonsmith/tools/Interpreter.java | 8 +- .../tools/docgen/DocGenTemplates.java | 4 +- .../laytonsmith/tools/pnviewer/PNViewer.java | 2 +- .../core/functions/ArrayHandlingTest.java | 26 +- .../core/functions/BasicLogicTest.java | 44 ++-- .../core/functions/EchoesTest.java | 8 +- .../laytonsmith/core/functions/MathTest.java | 84 +++---- .../core/functions/StringHandlingTest.java | 36 +-- .../com/laytonsmith/testing/RandomTests.java | 2 +- .../com/laytonsmith/testing/StaticTest.java | 6 +- 84 files changed, 1225 insertions(+), 1115 deletions(-) diff --git a/src/main/java/com/laytonsmith/core/Main.java b/src/main/java/com/laytonsmith/core/Main.java index cced2bcd21..ee7b328594 100644 --- a/src/main/java/com/laytonsmith/core/Main.java +++ b/src/main/java/com/laytonsmith/core/Main.java @@ -335,9 +335,9 @@ public ArgumentParser getArgumentParser() { @Override public void execute(ArgumentParser.ArgumentParserResults parsedArgs) throws Exception { - String buildYear = new Scheduling.simple_date().exec(Target.UNKNOWN, null, + String buildYear = new Scheduling.simple_date().exec(Target.UNKNOWN, null, null, new CString("yyyy", Target.UNKNOWN), - new Meta.engine_build_date().exec(Target.UNKNOWN, null)).val(); + new Meta.engine_build_date().exec(Target.UNKNOWN, null, null)).val(); StreamUtils.GetSystemOut().println("The MIT License (MIT)\n" + "\n" + "Copyright (c) 2012-" + buildYear + " Methodscript Contributors\n" @@ -594,7 +594,7 @@ public static void CreateNewFiles(List files, boolean force) throws IOEx + "\tstrict;" + li + "\tname: " + f.getName() + ";" + li + "\tauthor: " + System.getProperty("user.name") + ";" + li - + "\tcreated: " + new Scheduling.simple_date().exec(Target.UNKNOWN, null, new CString("yyyy-MM-dd", Target.UNKNOWN)).val() + ";" + li + + "\tcreated: " + new Scheduling.simple_date().exec(Target.UNKNOWN, null, null, new CString("yyyy-MM-dd", Target.UNKNOWN)).val() + ";" + li + "\tdescription: " + ";" + li + ">" + li + li, f, true); } @@ -641,7 +641,7 @@ public void execute(ArgumentParser.ArgumentParserResults parsedArgs) throws Exce classSimpleName = split[split.length - 1]; String author = System.getProperty("user.name"); - String created = new Scheduling.simple_date().exec(Target.UNKNOWN, null, + String created = new Scheduling.simple_date().exec(Target.UNKNOWN, null, null, new CString("yyyy-MM-dd", Target.UNKNOWN)).val(); File file = new File(clazz.replace(".", "/") + ".ms"); if(file.exists()) { diff --git a/src/main/java/com/laytonsmith/core/MethodScriptCompiler.java b/src/main/java/com/laytonsmith/core/MethodScriptCompiler.java index 8858208ec7..1016308acb 100644 --- a/src/main/java/com/laytonsmith/core/MethodScriptCompiler.java +++ b/src/main/java/com/laytonsmith/core/MethodScriptCompiler.java @@ -2699,7 +2699,7 @@ private static void optimize(ParseTree tree, Environment env, + tree.getData().val(), tree.getData().getTarget())); result = null; } else { - result = func.exec(tree.getData().getTarget(), env, constructs); + result = Function.ExecuteFunction(func, tree.getData().getTarget(), env, constructs); } } else if(isValidNumArgs(func, constructs.length)) { result = ((Optimizable) func).optimize(tree.getData().getTarget(), env, constructs); diff --git a/src/main/java/com/laytonsmith/core/Script.java b/src/main/java/com/laytonsmith/core/Script.java index e57f6af57d..c73e3e6cc4 100644 --- a/src/main/java/com/laytonsmith/core/Script.java +++ b/src/main/java/com/laytonsmith/core/Script.java @@ -427,7 +427,7 @@ public Mixed eval(ParseTree c, final Environment env) throws CancelCommandExcept } Mixed ret; try { - ret = f.exec(m.getTarget(), env, args); + ret = Function.ExecuteFunction(f, m.getTarget(), env, args); } finally { if(p != null) { p.stop(); diff --git a/src/main/java/com/laytonsmith/core/Updater.java b/src/main/java/com/laytonsmith/core/Updater.java index a4f07111de..9c58fbbf40 100644 --- a/src/main/java/com/laytonsmith/core/Updater.java +++ b/src/main/java/com/laytonsmith/core/Updater.java @@ -43,7 +43,7 @@ public static BuildArtifact getLatestVersionInfo() throws ApiException, ParseExc } public static Boolean isUpdateAvailable() { - Mixed buildDate = new Meta.engine_build_date().exec(null, null, (Mixed[]) null); + Mixed buildDate = new Meta.engine_build_date().exec(null, null, null, (Mixed[]) null); if(buildDate instanceof CNull) { return null; } diff --git a/src/main/java/com/laytonsmith/core/asm/AsmCompiler.java b/src/main/java/com/laytonsmith/core/asm/AsmCompiler.java index 5595fbe768..891f8be1ed 100644 --- a/src/main/java/com/laytonsmith/core/asm/AsmCompiler.java +++ b/src/main/java/com/laytonsmith/core/asm/AsmCompiler.java @@ -554,7 +554,7 @@ public static IRData getIR(IRBuilder builder, ParseTree node, Environment env) t if(fb instanceof LLVMFunction f) { builder.functionsUsed.add(f); return f.buildIR(builder, node.getTarget(), env, - node.getChildren().toArray(new ParseTree[node.getChildren().size()])); + null, node.getChildren().toArray(new ParseTree[node.getChildren().size()])); } else { throw new Error("Unexpected function type"); } diff --git a/src/main/java/com/laytonsmith/core/asm/LLVMFunction.java b/src/main/java/com/laytonsmith/core/asm/LLVMFunction.java index bf25a3f810..f74d46f15b 100644 --- a/src/main/java/com/laytonsmith/core/asm/LLVMFunction.java +++ b/src/main/java/com/laytonsmith/core/asm/LLVMFunction.java @@ -15,6 +15,7 @@ import com.laytonsmith.core.constructs.CClassType; import com.laytonsmith.core.constructs.CFunction; import com.laytonsmith.core.constructs.Target; +import com.laytonsmith.core.constructs.generics.GenericParameters; import com.laytonsmith.core.environments.Environment; import com.laytonsmith.core.exceptions.ConfigCompileException; import com.laytonsmith.core.exceptions.ConfigRuntimeException; @@ -106,7 +107,7 @@ public Boolean runAsync() { } @Override - public final Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public final Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { throw new UnsupportedOperationException("Not supported."); } @@ -228,12 +229,13 @@ public int compareTo(Function o) { * @param builder The ongoing builder. Functions should append to this as needed. * @param t The code target this node comes from. * @param env The Environment + * @param parameters Generic parameters passed to this function call. * @param nodes The children passed to this function, could be empty array. * @return Information on the returned value, including things like type (if known) and how to reference the * output value. * @throws com.laytonsmith.core.exceptions.ConfigCompileException If there is a compilation error. */ - public abstract IRData buildIR(IRBuilder builder, Target t, Environment env, ParseTree... nodes) throws ConfigCompileException; + public abstract IRData buildIR(IRBuilder builder, Target t, Environment env, GenericParameters parameters, ParseTree... nodes) throws ConfigCompileException; @Override public final boolean useSpecialExec() { diff --git a/src/main/java/com/laytonsmith/core/constructs/CArray.java b/src/main/java/com/laytonsmith/core/constructs/CArray.java index 07a05ad31b..3e603f41ef 100644 --- a/src/main/java/com/laytonsmith/core/constructs/CArray.java +++ b/src/main/java/com/laytonsmith/core/constructs/CArray.java @@ -823,7 +823,7 @@ public boolean canBeAssociative() { @Override public Mixed slice(int begin, int end, Target t) { - return new ArrayHandling.array_get().exec(t, null, new CSlice(begin, end, t)); + return new ArrayHandling.array_get().exec(t, null, null, new CSlice(begin, end, t)); } @Override @@ -923,13 +923,13 @@ public int compare(Mixed o1, Mixed o2) { } public int compareRegular(Mixed o1, Mixed o2) { - if(ArgumentValidation.getBooleanObject(new DataHandling.is_numeric().exec(Target.UNKNOWN, null, o1), Target.UNKNOWN) - && ArgumentValidation.getBooleanObject(new DataHandling.is_numeric().exec(Target.UNKNOWN, null, o2), Target.UNKNOWN)) { + if(ArgumentValidation.getBooleanObject(new DataHandling.is_numeric().exec(Target.UNKNOWN, null, null, o1), Target.UNKNOWN) + && ArgumentValidation.getBooleanObject(new DataHandling.is_numeric().exec(Target.UNKNOWN, null, null, o2), Target.UNKNOWN)) { return compareNumeric(o1, o2); - } else if(ArgumentValidation.getBooleanObject(new DataHandling.is_numeric().exec(Target.UNKNOWN, null, o1), Target.UNKNOWN)) { + } else if(ArgumentValidation.getBooleanObject(new DataHandling.is_numeric().exec(Target.UNKNOWN, null, null, o1), Target.UNKNOWN)) { //The first is a number, the second is a string return -1; - } else if(ArgumentValidation.getBooleanObject(new DataHandling.is_numeric().exec(Target.UNKNOWN, null, o2), Target.UNKNOWN)) { + } else if(ArgumentValidation.getBooleanObject(new DataHandling.is_numeric().exec(Target.UNKNOWN, null, null, o2), Target.UNKNOWN)) { //The second is a number, the first is a string return 1; } else { diff --git a/src/main/java/com/laytonsmith/core/constructs/CResource.java b/src/main/java/com/laytonsmith/core/constructs/CResource.java index 4806972cc8..7967b75a1c 100644 --- a/src/main/java/com/laytonsmith/core/constructs/CResource.java +++ b/src/main/java/com/laytonsmith/core/constructs/CResource.java @@ -106,7 +106,7 @@ public Version since() { @Override public void msFinalize() { - new res_free_resource().exec(new Target(0, new File("/Finalizer"), 0), null, this); + new res_free_resource().exec(new Target(0, new File("/Finalizer"), 0), null, null, this); } public static interface ResourceToString { diff --git a/src/main/java/com/laytonsmith/core/constructs/CSlice.java b/src/main/java/com/laytonsmith/core/constructs/CSlice.java index 26a539f7b3..67c682c3fd 100644 --- a/src/main/java/com/laytonsmith/core/constructs/CSlice.java +++ b/src/main/java/com/laytonsmith/core/constructs/CSlice.java @@ -69,7 +69,7 @@ public CSlice(long from, long to, Target t) { @Override public List asList() { - CArray ca = new ArrayHandling.range().exec(Target.UNKNOWN, null, new CInt(start, Target.UNKNOWN), new CInt(finish, Target.UNKNOWN)); + CArray ca = new ArrayHandling.range().exec(Target.UNKNOWN, null, null, new CInt(start, Target.UNKNOWN), new CInt(finish, Target.UNKNOWN)); return ca.asList(); } diff --git a/src/main/java/com/laytonsmith/core/events/drivers/PlayerEvents.java b/src/main/java/com/laytonsmith/core/events/drivers/PlayerEvents.java index f813248389..76fc82986b 100644 --- a/src/main/java/com/laytonsmith/core/events/drivers/PlayerEvents.java +++ b/src/main/java/com/laytonsmith/core/events/drivers/PlayerEvents.java @@ -1793,7 +1793,7 @@ public boolean matches(String key, Mixed value, MCPlayerCommandEvent event, Targ String command = event.getCommand(); String prefilter = value.val(); StringHandling.parse_args pa = new StringHandling.parse_args(); - CArray ca = (CArray) pa.exec(Target.UNKNOWN, null, new CString(command, Target.UNKNOWN)); + CArray ca = (CArray) pa.exec(Target.UNKNOWN, null, null, new CString(command, Target.UNKNOWN)); if(ca.size() > 0) { if(!ca.get(0, Target.UNKNOWN).val().equals(prefilter)) { return false; @@ -1831,7 +1831,7 @@ public Map evaluate(BindableEvent e) throws EventException { map.put("command", new CString(event.getCommand(), Target.UNKNOWN)); StringHandling.parse_args pa = new StringHandling.parse_args(); - CArray ca = (CArray) pa.exec(Target.UNKNOWN, null, new CString(event.getCommand(), Target.UNKNOWN)); + CArray ca = (CArray) pa.exec(Target.UNKNOWN, null, null, new CString(event.getCommand(), Target.UNKNOWN)); map.put("prefix", new CString(ca.get(0, Target.UNKNOWN).val(), Target.UNKNOWN)); return map; diff --git a/src/main/java/com/laytonsmith/core/functions/ArrayHandling.java b/src/main/java/com/laytonsmith/core/functions/ArrayHandling.java index 2cdd7bf802..a4923e7303 100644 --- a/src/main/java/com/laytonsmith/core/functions/ArrayHandling.java +++ b/src/main/java/com/laytonsmith/core/functions/ArrayHandling.java @@ -33,6 +33,7 @@ import com.laytonsmith.core.constructs.CVoid; import com.laytonsmith.core.constructs.Construct; import com.laytonsmith.core.constructs.Target; +import com.laytonsmith.core.constructs.generics.GenericParameters; import com.laytonsmith.core.environments.Environment; import com.laytonsmith.core.environments.GlobalEnv; import com.laytonsmith.core.environments.StaticRuntimeEnv; @@ -90,7 +91,7 @@ public Integer[] numArgs() { } @Override - public Mixed exec(Target t, Environment env, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { // TODO: It's far too late to deprecate this, but this method and length() are aliases, so // we should at least harmonize the implementations. if(args[0] instanceof Sizeable s) { @@ -166,7 +167,7 @@ public Integer[] numArgs() { } @Override - public Mixed exec(Target t, Environment env, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { Mixed index; Mixed defaultConstruct = null; if(args.length >= 2) { @@ -429,7 +430,7 @@ public Mixed execs(Target t, Environment env, Script parent, ParseTree... nodes) } @Override - public Mixed exec(Target t, Environment env, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { if(args[0].isInstanceOf(CArray.TYPE)) { try { ((CArray) args[0]).set(args[1], args[2], t); @@ -514,7 +515,7 @@ public Integer[] numArgs() { } @Override - public Mixed exec(Target t, Environment env, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { if(args.length < 2) { throw new CREInsufficientArgumentsException( "At least 2 arguments must be provided to " + this.getName(), t); @@ -616,7 +617,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { CArray array = ArgumentValidation.getArray(args[0], t); Mixed value = args[1]; int index = ArgumentValidation.getInt32(args[2], t); @@ -709,7 +710,7 @@ public Integer[] numArgs() { } @Override - public Mixed exec(Target t, Environment env, Mixed... args) throws CancelCommandException, ConfigRuntimeException { + public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws CancelCommandException, ConfigRuntimeException { ArrayAccess aa; if(args[0] instanceof ArrayAccess) { aa = (ArrayAccess) args[0]; @@ -718,7 +719,7 @@ public Mixed exec(Target t, Environment env, Mixed... args) throws CancelCommand aa = ca; } for(Mixed key : aa.keySet()) { - if(new equals().exec(t, env, aa.get(key, t), args[1]).getBoolean()) { + if(new equals().exec(t, env, null, aa.get(key, t), args[1]).getBoolean()) { return CBoolean.TRUE; } } @@ -820,7 +821,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { ArrayAccess aa; if(args[0] instanceof ArrayAccess a) { aa = a; @@ -828,7 +829,7 @@ public Mixed exec(Target t, Environment environment, Mixed... args) throws Confi aa = ArgumentValidation.getArray(args[0], t); } for(Mixed key : aa.keySet()) { - if(new equals_ic().exec(t, environment, aa.get(key, t), args[1]).getBoolean()) { + if(new equals_ic().exec(t, environment, null, aa.get(key, t), args[1]).getBoolean()) { return CBoolean.TRUE; } } @@ -874,7 +875,7 @@ public Integer[] numArgs() { } @Override - public Mixed exec(Target t, Environment env, Mixed... args) throws CancelCommandException, ConfigRuntimeException { + public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws CancelCommandException, ConfigRuntimeException { ArrayAccess aa; if(args[0] instanceof ArrayAccess a) { aa = a; @@ -882,7 +883,7 @@ public Mixed exec(Target t, Environment env, Mixed... args) throws CancelCommand aa = ArgumentValidation.getArray(args[0], t); } for(Mixed key : aa.keySet()) { - if(new sequals().exec(t, env, aa.get(key, t), args[1]).getBoolean()) { + if(new sequals().exec(t, env, null, aa.get(key, t), args[1]).getBoolean()) { return CBoolean.TRUE; } } @@ -990,7 +991,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment env, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { if(args[0].isInstanceOf(CArray.TYPE)) { Mixed m = args[0]; for(int i = 1; i < args.length; i++) { @@ -1109,7 +1110,7 @@ public Boolean runAsync() { } @Override - public CArray exec(Target t, Environment env, Mixed... args) throws ConfigRuntimeException { + public CArray exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { if(args[0].isInstanceOf(CArray.TYPE) && args[1].isInstanceOf(CInt.TYPE)) { CArray original = (CArray) args[0]; int size = (int) ((CInt) args[1]).getInt(); @@ -1198,7 +1199,7 @@ public Boolean runAsync() { } @Override - public CArray exec(Target t, Environment env, Mixed... args) throws ConfigRuntimeException { + public CArray exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { long start = 0; long finish = 0; long increment = 1; @@ -1279,7 +1280,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment env, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { // As an exception, strings aren't supported here. There's no reason to do this for a string that isn't accidental. if(args[0].isInstanceOf(ArrayAccess.TYPE) && !(args[0].isInstanceOf(CString.TYPE))) { ArrayAccess ca = (ArrayAccess) args[0]; @@ -1346,7 +1347,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment env, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { if(args[0].isInstanceOf(CArray.TYPE)) { CArray ca = ArgumentValidation.getArray(args[0], t); CArray ca2 = new CArray(t); @@ -1414,7 +1415,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { CArray newArray = new CArray(t); if(args.length < 2) { throw new CREInsufficientArgumentsException("array_merge must be called with at least two parameters", t); @@ -1500,7 +1501,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { CArray array = ArgumentValidation.getArray(args[0], t); if(array.isAssociative()) { return array.remove(args[1]); @@ -1564,7 +1565,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { if(!(args[0].isInstanceOf(ArrayAccess.TYPE))) { throw new CRECastException("Expecting argument 1 to be an ArrayAccess type object", t); } @@ -1620,7 +1621,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { CArray array = ArgumentValidation.getArray(args[0], t); String innerGlue = ArgumentValidation.getString(args[1], t); String outerGlue = ArgumentValidation.getString(args[2], t); @@ -1713,7 +1714,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { return new CSlice(ArgumentValidation.getInt(args[0], t), ArgumentValidation.getInt(args[1], t), t); } @@ -1754,7 +1755,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { if(!(args[0].isInstanceOf(CArray.TYPE))) { throw new CRECastException("The first parameter to array_sort must be an array", t); } @@ -1991,7 +1992,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { startup(); final CArray array = ArgumentValidation.getArray(args[0], t); final CString sortType = new CString(args.length > 2 ? args[1].val() : CArray.ArraySortType.REGULAR.name(), t); @@ -2000,7 +2001,7 @@ public Mixed exec(Target t, Environment environment, Mixed... args) throws Confi @Override public void run() { - Mixed c = new array_sort().exec(Target.UNKNOWN, null, array, sortType); + Mixed c = new array_sort().exec(Target.UNKNOWN, null, null, array, sortType); callback.executeCallable(environment, t, new Mixed[]{c}); } }); @@ -2051,7 +2052,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { CArray array = ArgumentValidation.getArray(args[0], t); //This needs to be in terms of array_remove, to ensure that the iteration //logic is followed. We will iterate backwards, however, to make the @@ -2061,7 +2062,7 @@ public Mixed exec(Target t, Environment environment, Mixed... args) throws Confi } else { for(long i = array.size() - 1; i >= 0; i--) { if(BasicLogic.equals.doEquals(array.get(i, t), args[1])) { - new array_remove().exec(t, environment, array, new CInt(i, t)); + new array_remove().exec(t, environment, null, array, new CInt(i, t)); } } } @@ -2120,7 +2121,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { if(!(args[0].isInstanceOf(CArray.TYPE))) { throw new CRECastException("Expected parameter 1 to be an array, but was " + args[0].val(), t); } @@ -2183,8 +2184,8 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { - CArray ca = (CArray) new array_indexes().exec(t, environment, args); + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { + CArray ca = (CArray) new array_indexes().exec(t, environment, generics, args); if(ca.isEmpty()) { return CNull.NULL; } else { @@ -2242,8 +2243,8 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { - CArray ca = (CArray) new array_indexes().exec(t, environment, args); + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { + CArray ca = (CArray) new array_indexes().exec(t, environment, generics, args); if(ca.isEmpty()) { return CNull.NULL; } else { @@ -2301,7 +2302,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { if(args[0].isInstanceOf(CArray.TYPE)) { ((CArray) args[0]).reverse(t); } @@ -2361,7 +2362,7 @@ public Boolean runAsync() { Random r = new Random(System.currentTimeMillis()); @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { long number = 1; boolean getKeys = true; CArray array = ArgumentValidation.getArray(args[0], t); @@ -2466,7 +2467,7 @@ public Boolean runAsync() { } @Override - public CArray exec(final Target t, final Environment environment, Mixed... args) throws ConfigRuntimeException { + public CArray exec(final Target t, final Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { CArray array = ArgumentValidation.getArray(args[0], t); boolean compareTypes = true; if(args.length == 2) { @@ -2482,8 +2483,8 @@ public CArray exec(final Target t, final Environment environment, Mixed... args) @Override public boolean checkIfEquals(Mixed item1, Mixed item2) { - return (fCompareTypes && ArgumentValidation.getBoolean(sequals.exec(t, environment, item1, item2), t)) - || (!fCompareTypes && ArgumentValidation.getBoolean(equals.exec(t, environment, item1, item2), t)); + return (fCompareTypes && ArgumentValidation.getBoolean(sequals.exec(t, environment, null, item1, item2), t)) + || (!fCompareTypes && ArgumentValidation.getBoolean(equals.exec(t, environment, null, item1, item2), t)); } }); for(Mixed c : set) { @@ -2553,7 +2554,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { com.laytonsmith.core.natives.interfaces.Iterable array; CClosure closure; if(!(args[0] instanceof com.laytonsmith.core.natives.interfaces.Iterable)) { @@ -2656,7 +2657,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { if(args.length != 1) { throw new CREInsufficientArgumentsException("Expecting exactly one argument", t); } @@ -2724,7 +2725,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { if(args.length != 1) { throw new CREInsufficientArgumentsException("Expecting exactly one argument", t); } @@ -2797,7 +2798,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { ArrayAccess aa; if(args[0] instanceof CFixedArray fa) { aa = fa; @@ -2875,7 +2876,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { CArray array = ArgumentValidation.getArray(args[0], t); CClosure closure = ArgumentValidation.getObject(args[1], t, CClosure.class); if(array.isEmpty()) { @@ -2960,7 +2961,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { CArray array = ArgumentValidation.getArray(args[0], t); CClosure closure = ArgumentValidation.getObject(args[1], t, CClosure.class); if(array.isEmpty()) { @@ -3045,7 +3046,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { CArray array = ArgumentValidation.getArray(args[0], t); CClosure closure = ArgumentValidation.getObject(args[1], t, CClosure.class); for(Mixed c : array.keySet()) { @@ -3118,7 +3119,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { CArray array = ArgumentValidation.getArray(args[0], t); CClosure closure = ArgumentValidation.getObject(args[1], t, CClosure.class); for(Mixed c : array.keySet()) { @@ -3191,7 +3192,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { CArray array = ArgumentValidation.getArray(args[0], t); CClosure closure = ArgumentValidation.getObject(args[1], t, CClosure.class); CArray newArray = (array.isAssociative() ? CArray.GetAssociativeArray(t) : new CArray(t, (int) array.size())); @@ -3287,7 +3288,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { CArray one = ArgumentValidation.getArray(args[0], t); CArray two = ArgumentValidation.getArray(args[1], t); CClosure closure = null; @@ -3330,14 +3331,14 @@ public Mixed exec(Target t, Environment environment, Mixed... args) throws Confi for(int i = 0; i < k1.length; i++) { for(int j = 0; j < k2.length; j++) { if(associativeMode) { - if(equals.exec(t, environment, k1[i], k2[j]).getBoolean()) { + if(equals.exec(t, environment, null, k1[i], k2[j]).getBoolean()) { ret.set(k1[i], one.get(k1[i], t), t); continue i; } } else { if(closure == null) { if(comparisonFunction != null) { - if(ArgumentValidation.getBoolean(comparisonFunction.exec(t, environment, + if(ArgumentValidation.getBoolean(comparisonFunction.exec(t, environment, null, one.get(k1[i], t), two.get(k2[j], t) ), t)) { ret.push(one.get(k1[i], t), t); @@ -3474,7 +3475,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { Mixed constA = args[0]; Mixed constB = args[1]; if(!(constA.isInstanceOf(CArray.TYPE))) { @@ -3624,7 +3625,7 @@ public Class[] thrown() { Random rand = new Random(); @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { CArray array = ArgumentValidation.getArray(args[0], t); if(array.isEmpty()) { throw new CRELengthException("Array is empty", t); @@ -3679,7 +3680,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { CArray one = ArgumentValidation.getArray(args[0], t); CArray two = ArgumentValidation.getArray(args[1], t); CClosure closure = null; @@ -3722,14 +3723,14 @@ public Mixed exec(Target t, Environment environment, Mixed... args) throws Confi boolean addValue = true; for(int j = 0; j < k2.length; j++) { if(associativeMode) { - if(equals.exec(t, environment, k1[i], k2[j]).getBoolean()) { + if(equals.exec(t, environment, null, k1[i], k2[j]).getBoolean()) { addValue = false; break; } } else { if(closure == null) { if(comparisonFunction != null) { - if(ArgumentValidation.getBoolean(comparisonFunction.exec(t, environment, + if(ArgumentValidation.getBoolean(comparisonFunction.exec(t, environment, null, one.get(k1[i], t), two.get(k2[j], t) ), t)) { addValue = false; @@ -3817,7 +3818,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { Mixed fill = args[1]; if(args[0] instanceof CFixedArray fa) { fa.fill(fill, t); @@ -3873,7 +3874,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment env, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { ArgumentValidation.getArray(args[0], t).clear(); return CVoid.VOID; } diff --git a/src/main/java/com/laytonsmith/core/functions/BasicLogic.java b/src/main/java/com/laytonsmith/core/functions/BasicLogic.java index 0640280275..e7ce19f552 100644 --- a/src/main/java/com/laytonsmith/core/functions/BasicLogic.java +++ b/src/main/java/com/laytonsmith/core/functions/BasicLogic.java @@ -29,6 +29,7 @@ import com.laytonsmith.core.constructs.CSymbol; import com.laytonsmith.core.constructs.CVoid; import com.laytonsmith.core.constructs.Target; +import com.laytonsmith.core.constructs.generics.GenericParameters; import com.laytonsmith.core.environments.Environment; import com.laytonsmith.core.environments.GlobalEnv; import com.laytonsmith.core.exceptions.CRE.CRECastException; @@ -71,7 +72,7 @@ public static class equals extends AbstractFunction implements Optimizable { * @return */ public static boolean doEquals(Mixed one, Mixed two) { - CBoolean ret = SELF.exec(Target.UNKNOWN, null, one, two); + CBoolean ret = SELF.exec(Target.UNKNOWN, null, null, one, two); return ret.getBoolean(); } @@ -86,7 +87,7 @@ public Integer[] numArgs() { } @Override - public CBoolean exec(Target t, Environment env, Mixed... args) throws CancelCommandException, ConfigRuntimeException { + public CBoolean exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws CancelCommandException, ConfigRuntimeException { if(args.length <= 1) { throw new CREInsufficientArgumentsException("At least two arguments must be passed to equals", t); } @@ -254,7 +255,7 @@ public Boolean runAsync() { } @Override - public CBoolean exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public CBoolean exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { if(args.length != 2) { throw new CREFormatException(this.getName() + " expects 2 arguments.", t); } @@ -264,7 +265,7 @@ public CBoolean exec(Target t, Environment environment, Mixed... args) throws Co // for numeric strings. Thus '2' !== '2.0' return CBoolean.get(args[0].val().equals(args[1].val())); } - return new equals().exec(t, environment, args); + return new equals().exec(t, environment, null, args); } else { return CBoolean.FALSE; } @@ -332,8 +333,8 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { - return new sequals().exec(t, environment, args).not(); + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { + return new sequals().exec(t, environment, null, args).not(); } @Override @@ -410,8 +411,8 @@ public Boolean runAsync() { } @Override - public CBoolean exec(Target t, Environment env, Mixed... args) throws ConfigRuntimeException { - return new equals().exec(t, env, args).not(); + public CBoolean exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { + return new equals().exec(t, env, null, args).not(); } @Override @@ -480,7 +481,7 @@ public Boolean runAsync() { } @Override - public CBoolean exec(Target t, Environment env, Mixed... args) throws ConfigRuntimeException { + public CBoolean exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { if(args.length <= 1) { throw new CREInsufficientArgumentsException("At least two arguments must be passed to equals_ic", t); } @@ -574,13 +575,13 @@ public Boolean runAsync() { } @Override - public CBoolean exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public CBoolean exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { Mixed v1 = args[0]; Mixed v2 = args[1]; if(!v2.getClass().equals(v1.getClass())) { return CBoolean.FALSE; } - return new equals_ic().exec(t, environment, v1, v2); + return new equals_ic().exec(t, environment, null, v1, v2); } @Override @@ -673,8 +674,8 @@ public Boolean runAsync() { } @Override - public CBoolean exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { - return new equals_ic().exec(t, environment, args).not(); + public CBoolean exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { + return new equals_ic().exec(t, environment, null, args).not(); } @Override @@ -720,11 +721,11 @@ public Boolean runAsync() { } @Override - public CBoolean exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public CBoolean exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { if(args[0].isInstanceOf(CArray.TYPE) && args[1].isInstanceOf(CArray.TYPE)) { return CBoolean.get(args[0] == args[1]); } else { - return new equals().exec(t, environment, args); + return new equals().exec(t, environment, null, args); } } @@ -792,7 +793,7 @@ public Integer[] numArgs() { } @Override - public CBoolean exec(Target t, Environment env, Mixed... args) throws CancelCommandException, ConfigRuntimeException { + public CBoolean exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws CancelCommandException, ConfigRuntimeException { if(args.length != 2) { throw new CREFormatException(this.getName() + " expects 2 arguments.", t); } @@ -866,7 +867,7 @@ public Integer[] numArgs() { } @Override - public CBoolean exec(Target t, Environment env, Mixed... args) throws CancelCommandException, ConfigRuntimeException { + public CBoolean exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws CancelCommandException, ConfigRuntimeException { if(args.length != 2) { throw new CREFormatException(this.getName() + " expects 2 arguments.", t); } @@ -940,7 +941,7 @@ public Integer[] numArgs() { } @Override - public CBoolean exec(Target t, Environment env, Mixed... args) throws CancelCommandException, ConfigRuntimeException { + public CBoolean exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws CancelCommandException, ConfigRuntimeException { if(args.length != 2) { throw new CREFormatException(this.getName() + " expects 2 arguments.", t); } @@ -1015,7 +1016,7 @@ public Integer[] numArgs() { } @Override - public CBoolean exec(Target t, Environment env, Mixed... args) throws CancelCommandException, ConfigRuntimeException { + public CBoolean exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws CancelCommandException, ConfigRuntimeException { if(args.length != 2) { throw new CREFormatException(this.getName() + " expects 2 arguments.", t); } @@ -1091,7 +1092,7 @@ public Integer[] numArgs() { } @Override - public CBoolean exec(Target t, Environment env, Mixed... args) { + public CBoolean exec(Target t, Environment env, GenericParameters generics, Mixed... args) { //This will only happen if they hardcode true/false in, but we still //need to handle it appropriately. for(Mixed c : args) { @@ -1252,7 +1253,7 @@ public boolean useSpecialExec() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { return CVoid.VOID; } @@ -1384,7 +1385,7 @@ public Integer[] numArgs() { } @Override - public CBoolean exec(Target t, Environment env, Mixed... args) { + public CBoolean exec(Target t, Environment env, GenericParameters generics, Mixed... args) { //This will only happen if they hardcode true/false in, but we still //need to handle it appropriately. for(Mixed c : args) { @@ -1548,7 +1549,7 @@ public boolean useSpecialExec() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { return CVoid.VOID; } @@ -1644,7 +1645,7 @@ public Integer[] numArgs() { } @Override - public CBoolean exec(Target t, Environment env, Mixed... args) throws CancelCommandException, ConfigRuntimeException { + public CBoolean exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws CancelCommandException, ConfigRuntimeException { if(args.length != 1) { throw new CREFormatException(this.getName() + " expects 1 argument.", t); } @@ -1748,7 +1749,7 @@ public Boolean runAsync() { } @Override - public CBoolean exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public CBoolean exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { if(args.length != 2) { throw new CREFormatException(this.getName() + " expects 2 arguments.", t); } @@ -1822,7 +1823,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) { return CNull.NULL; } @@ -1897,7 +1898,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) { return CNull.NULL; } @@ -1972,11 +1973,11 @@ public Boolean runAsync() { } @Override - public CBoolean exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public CBoolean exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { if(args.length != 2) { throw new CREFormatException(this.getName() + " expects 2 arguments.", t); } - return new xor().exec(t, environment, args).not(); + return new xor().exec(t, environment, null, args).not(); } @Override @@ -2044,7 +2045,7 @@ public Boolean runAsync() { } @Override - public CInt exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public CInt exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { if(args.length < 2) { throw new CREFormatException(this.getName() + " expects at least 2 arguments.", t); } @@ -2131,7 +2132,7 @@ public Boolean runAsync() { } @Override - public CInt exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public CInt exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { if(args.length < 2) { throw new CREFormatException(this.getName() + " expects at least 2 arguments.", t); } @@ -2220,7 +2221,7 @@ public Boolean runAsync() { } @Override - public CInt exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public CInt exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { if(args.length < 2) { throw new CREFormatException(this.getName() + " expects at least 2 arguments.", t); } @@ -2305,7 +2306,7 @@ public Boolean runAsync() { } @Override - public CInt exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public CInt exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { if(args.length != 1) { throw new CREFormatException(this.getName() + " expects 1 argument.", t); } @@ -2371,7 +2372,7 @@ public Boolean runAsync() { } @Override - public CInt exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public CInt exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { if(args.length != 2) { throw new CREFormatException(this.getName() + " expects 2 arguments.", t); } @@ -2441,7 +2442,7 @@ public Boolean runAsync() { } @Override - public CInt exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public CInt exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { if(args.length != 2) { throw new CREFormatException(this.getName() + " expects 2 arguments.", t); } @@ -2513,7 +2514,7 @@ public Boolean runAsync() { } @Override - public CInt exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public CInt exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { if(args.length != 2) { throw new CREFormatException(this.getName() + " expects 2 arguments.", t); } @@ -2564,7 +2565,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { return CVoid.VOID; } @@ -2644,7 +2645,7 @@ public Boolean runAsync() { } @Override - public CInt exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public CInt exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { return new CInt(args[0].hashCode(), t); } @@ -2705,7 +2706,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment env, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { double d1 = ArgumentValidation.getNumber(args[0], t); double d2 = ArgumentValidation.getNumber(args[1], t); double epsilon = ArgumentValidation.getDouble(args[2], t); diff --git a/src/main/java/com/laytonsmith/core/functions/BossBar.java b/src/main/java/com/laytonsmith/core/functions/BossBar.java index cdb67bf635..d1923a616a 100644 --- a/src/main/java/com/laytonsmith/core/functions/BossBar.java +++ b/src/main/java/com/laytonsmith/core/functions/BossBar.java @@ -16,6 +16,7 @@ import com.laytonsmith.core.constructs.CString; import com.laytonsmith.core.constructs.CVoid; import com.laytonsmith.core.constructs.Target; +import com.laytonsmith.core.constructs.generics.GenericParameters; import com.laytonsmith.core.environments.CommandHelperEnvironment; import com.laytonsmith.core.environments.Environment; import com.laytonsmith.core.exceptions.CRE.CRECastException; @@ -78,7 +79,7 @@ public Integer[] numArgs() { } @Override - public CArray exec(Target t, Environment env, Mixed... args) throws ConfigRuntimeException { + public CArray exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { CArray ca = new CArray(t); for(String id : BARS.keySet()) { ca.push(new CString(id, t), t); @@ -120,7 +121,7 @@ public Integer[] numArgs() { } @Override - public Mixed exec(Target t, Environment env, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { String id = args[0].val(); if(BARS.containsKey(id)) { throw new CREIllegalArgumentException("That boss bar id is already in use.", t); @@ -202,7 +203,7 @@ public Integer[] numArgs() { } @Override - public Mixed exec(Target t, Environment env, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { String id = args[0].val(); MCBossBar bar = BARS.get(id); if(bar == null) { @@ -278,7 +279,7 @@ public Integer[] numArgs() { } @Override - public Mixed exec(Target t, Environment env, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { String id = args[0].val(); MCBossBar bar = BARS.get(id); if(bar == null) { @@ -319,7 +320,7 @@ public Integer[] numArgs() { } @Override - public Mixed exec(Target t, Environment env, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { String id = args[0].val(); MCBossBar bar = BARS.get(id); if(bar == null) { @@ -356,7 +357,7 @@ public Integer[] numArgs() { } @Override - public Mixed exec(Target t, Environment env, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCBossBar bar = BARS.get(args[0].val()); if(bar == null) { throw new CRENotFoundException("That boss bar id does not exist.", t); @@ -390,7 +391,7 @@ public Integer[] numArgs() { } @Override - public Mixed exec(Target t, Environment env, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCBossBar bar = BARS.get(args[0].val()); if(bar == null) { throw new CRENotFoundException("That boss bar id does not exist.", t); @@ -424,7 +425,7 @@ public Integer[] numArgs() { } @Override - public Mixed exec(Target t, Environment env, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCBossBar bar = BARS.get(args[0].val()); if(bar == null) { throw new CRENotFoundException("That boss bar id does not exist.", t); diff --git a/src/main/java/com/laytonsmith/core/functions/BukkitMetadata.java b/src/main/java/com/laytonsmith/core/functions/BukkitMetadata.java index 820c9b13a8..d30985192c 100644 --- a/src/main/java/com/laytonsmith/core/functions/BukkitMetadata.java +++ b/src/main/java/com/laytonsmith/core/functions/BukkitMetadata.java @@ -16,6 +16,7 @@ import com.laytonsmith.core.constructs.CString; import com.laytonsmith.core.constructs.CVoid; import com.laytonsmith.core.constructs.Target; +import com.laytonsmith.core.constructs.generics.GenericParameters; import com.laytonsmith.core.environments.CommandHelperEnvironment; import com.laytonsmith.core.environments.Environment; import com.laytonsmith.core.exceptions.CRE.CREBadEntityException; @@ -107,7 +108,7 @@ public ExampleScript[] examples() throws ConfigCompileException { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { List metadata; if(args.length == 1) { metadata = Static.getPlayer(environment, t).getMetadata(args[0].val()); @@ -156,7 +157,7 @@ public String docs() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { String key; MCMetadatable metadatable; if(args.length == 1) { @@ -213,7 +214,7 @@ public String docs() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { String key; MCMetadatable metadatable; Mixed value; @@ -258,7 +259,7 @@ public String docs() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { String key; MCMetadatable metadatable; if(args.length == 1) { diff --git a/src/main/java/com/laytonsmith/core/functions/ByteArrays.java b/src/main/java/com/laytonsmith/core/functions/ByteArrays.java index 15cb83bb1a..3d1a7c41b1 100644 --- a/src/main/java/com/laytonsmith/core/functions/ByteArrays.java +++ b/src/main/java/com/laytonsmith/core/functions/ByteArrays.java @@ -14,6 +14,7 @@ import com.laytonsmith.core.constructs.CVoid; import com.laytonsmith.core.constructs.Construct; import com.laytonsmith.core.constructs.Target; +import com.laytonsmith.core.constructs.generics.GenericParameters; import com.laytonsmith.core.environments.Environment; import com.laytonsmith.core.exceptions.CRE.CRECastException; import com.laytonsmith.core.exceptions.CRE.CREFormatException; @@ -52,7 +53,7 @@ public Class[] thrown() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { return new CByteArray(t); } @@ -82,7 +83,7 @@ public String getName() { public static class ba_as_array extends ba { @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { CByteArray ba = ArgumentValidation.getByteArray(args[0], t); return ba.asArray(t); } @@ -117,7 +118,7 @@ public String getName() { public static class ba_rewind extends ba { @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { CByteArray ba = getBA(args, t); ba.rewind(); return CVoid.VOID; @@ -149,7 +150,7 @@ public String getName() { public static class ba_get_byte extends ba_get { @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { CByteArray ba = getBA(args, t); Integer pos = get_getPos(args, t); try { @@ -181,7 +182,7 @@ public String getName() { public static class ba_get_char extends ba_get { @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { CByteArray ba = getBA(args, t); Integer pos = get_getPos(args, t); try { @@ -213,7 +214,7 @@ public String getName() { public static class ba_get_short extends ba_get { @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { CByteArray ba = getBA(args, t); Integer pos = get_getPos(args, t); try { @@ -244,7 +245,7 @@ public String getName() { public static class ba_get_int extends ba_get { @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { CByteArray ba = getBA(args, t); Integer pos = get_getPos(args, t); try { @@ -276,7 +277,7 @@ public String getName() { public static class ba_get_long extends ba_get { @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { CByteArray ba = getBA(args, t); Integer pos = get_getPos(args, t); try { @@ -308,7 +309,7 @@ public String getName() { public static class ba_get_float extends ba_get { @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { CByteArray ba = getBA(args, t); Integer pos = get_getPos(args, t); try { @@ -340,7 +341,7 @@ public String getName() { public static class ba_get_double extends ba_get { @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { CByteArray ba = getBA(args, t); Integer pos = get_getPos(args, t); try { @@ -376,7 +377,7 @@ public Integer[] numArgs() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { CByteArray ba = getBA(args, t); int size = ArgumentValidation.getInt32(args[1], t); Integer pos = null; @@ -412,7 +413,7 @@ public String getName() { public static class ba_get_string extends ba_get { @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { CByteArray ba = getBA(args, t); Integer pos = get_getPos(args, t); String encoding = null; @@ -454,7 +455,7 @@ public String getName() { public static class ba_put_byte extends ba_put { @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { CByteArray ba = getBA(args, t); byte b = ArgumentValidation.getInt8(args[1], t); Integer pos = set_getPos(args, t); @@ -489,7 +490,7 @@ public Class[] thrown() { public static class ba_put_char extends ba_put { @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { CByteArray ba = getBA(args, t); String b = args[1].val(); char c = '\0'; @@ -523,7 +524,7 @@ public String getName() { public static class ba_put_short extends ba_put { @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { CByteArray ba = getBA(args, t); short b = ArgumentValidation.getInt16(args[1], t); Integer pos = set_getPos(args, t); @@ -558,7 +559,7 @@ public Class[] thrown() { public static class ba_put_int extends ba_put { @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { CByteArray ba = getBA(args, t); int b = ArgumentValidation.getInt32(args[1], t); Integer pos = set_getPos(args, t); @@ -592,7 +593,7 @@ public Class[] thrown() { public static class ba_put_long extends ba_put { @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { CByteArray ba = getBA(args, t); long b = ArgumentValidation.getInt(args[1], t); Integer pos = set_getPos(args, t); @@ -622,7 +623,7 @@ public String getName() { public static class ba_put_float extends ba_put { @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { CByteArray ba = getBA(args, t); float b = ArgumentValidation.getDouble32(args[1], t); Integer pos = set_getPos(args, t); @@ -657,7 +658,7 @@ public Class[] thrown() { public static class ba_put_double extends ba_put { @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { CByteArray ba = getBA(args, t); double b = ArgumentValidation.getDouble(args[1], t); Integer pos = set_getPos(args, t); @@ -687,7 +688,7 @@ public String getName() { public static class ba_put_bytes extends ba_put { @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { CByteArray dest = getBA(args, t); CByteArray src = ArgumentValidation.getByteArray(args[1], t); Integer pos = set_getPos(args, t); @@ -717,7 +718,7 @@ public String getName() { public static class ba_put_string extends ba_put { @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { CByteArray ba = getBA(args, t); String s = args[1].val(); Integer pos = set_getPos(args, t); @@ -775,7 +776,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { CByteArray ba = ArgumentValidation.getByteArray(args[0], t); boolean setLittle = ArgumentValidation.getBoolean(args[1], t); ba.setOrder(setLittle ? ByteOrder.LITTLE_ENDIAN : ByteOrder.BIG_ENDIAN); @@ -826,7 +827,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { CByteArray ba = ArgumentValidation.getByteArray(args[0], t); return CBoolean.get(ba.getOrder() == ByteOrder.LITTLE_ENDIAN); } diff --git a/src/main/java/com/laytonsmith/core/functions/Clipboard.java b/src/main/java/com/laytonsmith/core/functions/Clipboard.java index a19b672894..08a0e76f69 100644 --- a/src/main/java/com/laytonsmith/core/functions/Clipboard.java +++ b/src/main/java/com/laytonsmith/core/functions/Clipboard.java @@ -7,6 +7,7 @@ import com.laytonsmith.core.constructs.CString; import com.laytonsmith.core.constructs.CVoid; import com.laytonsmith.core.constructs.Target; +import com.laytonsmith.core.constructs.generics.GenericParameters; import com.laytonsmith.core.environments.Environment; import com.laytonsmith.core.exceptions.CRE.CREFormatException; import com.laytonsmith.core.exceptions.CRE.CREIOException; @@ -64,7 +65,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { Cmdline.requireCmdlineMode(environment, this, t); if(clipboard == null) { throw new CREUnsupportedOperationException( @@ -132,7 +133,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { Cmdline.requireCmdlineMode(environment, this, t); if(clipboard == null) { throw new CREUnsupportedOperationException( diff --git a/src/main/java/com/laytonsmith/core/functions/Cmdline.java b/src/main/java/com/laytonsmith/core/functions/Cmdline.java index 8b86483d91..84d111ea5c 100644 --- a/src/main/java/com/laytonsmith/core/functions/Cmdline.java +++ b/src/main/java/com/laytonsmith/core/functions/Cmdline.java @@ -33,6 +33,7 @@ import com.laytonsmith.core.constructs.CVoid; import com.laytonsmith.core.constructs.Construct; import com.laytonsmith.core.constructs.Target; +import com.laytonsmith.core.constructs.generics.GenericParameters; import com.laytonsmith.core.environments.Environment; import com.laytonsmith.core.environments.GlobalEnv; import com.laytonsmith.core.environments.StaticRuntimeEnv; @@ -97,7 +98,7 @@ public Boolean runAsync() { } @Override - public CVoid exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public CVoid exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { String msg = Static.MCToANSIColors(args[0].val()); PrintStream out = StreamUtils.GetSystemOut(); out.print(msg); @@ -162,7 +163,7 @@ public Boolean runAsync() { } @Override - public CVoid exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public CVoid exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { String msg = Static.MCToANSIColors(args[0].val()); PrintStream se = StreamUtils.GetSystemErr(); se.print(msg); @@ -226,7 +227,7 @@ public Boolean runAsync() { } @Override - public CVoid exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public CVoid exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { String msg = Static.MCToANSIColors(args[0].val()); PrintStream so = StreamUtils.GetSystemOut(); so.print(msg); @@ -283,7 +284,7 @@ public Boolean runAsync() { } @Override - public CVoid exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public CVoid exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { String msg = Static.MCToANSIColors(args[0].val()); StreamUtils.GetSystemErr().print(msg); StreamUtils.GetSystemErr().flush(); @@ -338,7 +339,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { int exit_code = 0; if(args.length == 1) { exit_code = ArgumentValidation.getInt32(args[0], t); @@ -346,7 +347,7 @@ public Mixed exec(Target t, Environment environment, Mixed... args) throws Confi if(Static.InCmdLine(environment, true)) { System.exit(exit_code); } - return new ControlFlow.die().exec(t, environment, args); + return new ControlFlow.die().exec(t, environment, null, args); } @Override @@ -404,7 +405,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { if(args.length == 1) { String propName = args[0].val(); String prop; @@ -510,7 +511,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { if(args.length == 1) { return new CString(System.getenv(args[0].val()), t); } else { @@ -564,7 +565,7 @@ public Boolean runAsync() { @SuppressWarnings({"BroadCatchBlock", "TooBroadCatch", "UseSpecificCatch"}) @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { //TODO: Make this more robust by having a local cache of the environment which we modify, and get_env returns from. Map newenv = new HashMap<>(System.getenv()); newenv.put(args[0].val(), args[1].val()); @@ -655,7 +656,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { if(!Static.InCmdLine(environment, true)) { throw new CREInsufficientPermissionException(getName() + " cannot be used outside of cmdline mode.", t); } @@ -733,7 +734,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { requireCmdlineMode(environment, this, t); String prompt = args[0].val(); @@ -806,7 +807,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { if(!Static.InCmdLine(environment, true)) { throw new CREInsufficientPermissionException(getName() + " cannot be used outside of cmdline mode.", t); } @@ -865,7 +866,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { java.awt.Toolkit.getDefaultToolkit().beep(); return CVoid.VOID; } @@ -912,7 +913,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { if(Static.InCmdLine(environment, true)) { try { new jline.console.ConsoleReader().clearScreen(); @@ -967,7 +968,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(final Target t, final Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(final Target t, final Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { if(!Static.InCmdLine(environment, true)) { if(!Prefs.AllowShellCommands()) { throw new CREInsufficientPermissionException("Shell commands are not allowed. Enable them in preferences.ini.", t); @@ -1175,7 +1176,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { if(!Static.InCmdLine(environment, true)) { if(!Prefs.AllowShellCommands()) { throw new CREInsufficientPermissionException("Shell commands are not allowed. Enable them in preferences.ini.", t); @@ -1314,7 +1315,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { Set oses = new HashSet<>(); String osS = args[0].val(); for(String osSS : osS.split("\\|")) { @@ -1327,7 +1328,7 @@ public Mixed exec(Target t, Environment environment, Mixed... args) throws Confi oses.add(os); } if(oses.contains(OSUtils.GetOS())) { - return new shell_adv().exec(t, environment, ArrayUtils.cast(ArrayUtils.slice(args, 1, args.length - 1), Construct[].class)); + return new shell_adv().exec(t, environment, null, ArrayUtils.cast(ArrayUtils.slice(args, 1, args.length - 1), Construct[].class)); } return CVoid.VOID; } @@ -1380,7 +1381,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { Set oses = new HashSet<>(); String osS = args[0].val(); for(String osSS : osS.split("\\|")) { @@ -1393,7 +1394,7 @@ public Mixed exec(Target t, Environment environment, Mixed... args) throws Confi oses.add(os); } if(oses.contains(OSUtils.GetOS())) { - return new shell().exec(t, environment, ArrayUtils.cast(ArrayUtils.slice(args, 1, args.length - 1), Construct[].class)); + return new shell().exec(t, environment, null, ArrayUtils.cast(ArrayUtils.slice(args, 1, args.length - 1), Construct[].class)); } return CNull.NULL; } @@ -1456,7 +1457,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { return new CString(OSUtils.GetOS().name(), t); } @@ -1501,7 +1502,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { if(!Static.InCmdLine(environment, true)) { throw new CREInsufficientPermissionException(getName() + " cannot be used outside of cmdline mode.", t); } @@ -1585,7 +1586,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { File root; if(Static.InCmdLine(environment, true)) { root = environment.getEnv(GlobalEnv.class).GetRootFolder(); @@ -1652,7 +1653,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { requireCmdlineMode(environment, this, t); File cd = Static.GetFileFromArgument(args.length == 0 ? null : args[0].val(), environment, t, new File(System.getProperty("user.home"))); if(!cd.exists()) { @@ -1704,7 +1705,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { requireCmdlineMode(environment, this, t); CArray ca = new CArray(t); File cwd = Static.GetFileFromArgument(args.length > 0 ? args[0].val() : null, environment, t, environment.getEnv(GlobalEnv.class).GetRootFolder()); @@ -1765,7 +1766,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { requireCmdlineMode(environment, this, t); if(!(args[0].isInstanceOf(CClosure.TYPE))) { throw new CRECastException("Expecting a closure for argument 1 of " + getName(), t); @@ -1818,7 +1819,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { requireCmdlineMode(environment, this, t); try { int i = new jline.console.ConsoleReader().getTerminal().getWidth(); @@ -1870,7 +1871,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { String name = StaticLayer.GetConvertor().GetUser(environment); if(name == null) { return CNull.NULL; @@ -1922,7 +1923,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { return CBoolean.GenerateCBoolean(Static.InCmdLine(environment, true), t); } @@ -1967,7 +1968,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { requireCmdlineMode(environment, this, t); final CArray a = new CArray(t); String regex = ArgumentValidation.getString(args[0], t); diff --git a/src/main/java/com/laytonsmith/core/functions/Commands.java b/src/main/java/com/laytonsmith/core/functions/Commands.java index 302391b584..52acefac68 100644 --- a/src/main/java/com/laytonsmith/core/functions/Commands.java +++ b/src/main/java/com/laytonsmith/core/functions/Commands.java @@ -17,6 +17,7 @@ import com.laytonsmith.core.constructs.CString; import com.laytonsmith.core.constructs.CVoid; import com.laytonsmith.core.constructs.Target; +import com.laytonsmith.core.constructs.generics.GenericParameters; import com.laytonsmith.core.environments.CommandHelperEnvironment; import com.laytonsmith.core.environments.Environment; import com.laytonsmith.core.exceptions.CRE.CRECastException; @@ -68,7 +69,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCServer s = Static.getServer(); MCCommandMap map = s.getCommandMap(); if(map == null) { @@ -164,7 +165,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCCommandMap map = Static.getServer().getCommandMap(); if(map == null) { throw new CRENotFoundException(this.getName() + " is not supported in this mode (CommandMap not found).", t); @@ -225,7 +226,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCCommandMap map = Static.getServer().getCommandMap(); if(map == null) { throw new CRENotFoundException( @@ -496,7 +497,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCCommandMap map = Static.getServer().getCommandMap(); if(map == null) { throw new CRENotFoundException(this.getName() + " is not supported in this mode (CommandMap not found).", t); @@ -568,7 +569,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCCommandMap map = Static.getServer().getCommandMap(); if(map == null) { return CNull.NULL; @@ -641,7 +642,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCCommandMap map = Static.getServer().getCommandMap(); if(map != null) { map.clearCommands(); diff --git a/src/main/java/com/laytonsmith/core/functions/Compiler.java b/src/main/java/com/laytonsmith/core/functions/Compiler.java index 26a2ebee2b..47ff8d62d8 100644 --- a/src/main/java/com/laytonsmith/core/functions/Compiler.java +++ b/src/main/java/com/laytonsmith/core/functions/Compiler.java @@ -36,6 +36,7 @@ import com.laytonsmith.core.constructs.InstanceofUtil; import com.laytonsmith.core.constructs.Target; import com.laytonsmith.core.constructs.Token; +import com.laytonsmith.core.constructs.generics.GenericParameters; import com.laytonsmith.core.environments.Environment; import com.laytonsmith.core.environments.GlobalEnv; import com.laytonsmith.core.environments.Environment.EnvironmentImpl; @@ -101,7 +102,7 @@ public Mixed execs(Target t, Environment env, Script parent, ParseTree... nodes) } @Override - public Mixed exec(Target t, Environment env, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { return CVoid.VOID; } @@ -154,7 +155,7 @@ public String docs() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { return new CEntry(args[0], args[1], t); } } @@ -167,7 +168,7 @@ public static class __autoconcat__ extends DummyFunction { public static final String NAME = "__autoconcat__"; @Override - public Mixed exec(Target t, Environment env, Mixed... args) throws CancelCommandException, ConfigRuntimeException { + public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws CancelCommandException, ConfigRuntimeException { throw new Error("Should not have gotten here, " + __autoconcat__.NAME + " was not removed before runtime."); } @@ -716,7 +717,7 @@ public String docs() { } @Override - public Mixed exec(Target t, Environment env, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { return CVoid.VOID; } @@ -782,7 +783,7 @@ public Integer[] numArgs() { } @Override - public Mixed exec(Target t, Environment env, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { throw new CRENotFoundException("\"" + args[0].val() + "\" cannot be resolved to a type.", t); } @@ -910,7 +911,7 @@ public boolean isRestricted() { } @Override - public Mixed exec(Target t, Environment env, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { String s = null; if(args.length == 1) { s = args[0].val(); @@ -936,7 +937,7 @@ public String docs() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { if(args.length == 0) { return CVoid.VOID; } @@ -949,7 +950,7 @@ public Mixed exec(Target t, Environment environment, Mixed... args) throws Confi public static class __cbracket__ extends DummyFunction implements Optimizable { @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { throw new UnsupportedOperationException("Not supported yet."); } @@ -985,7 +986,7 @@ public static class __cbrace__ extends DummyFunction implements Optimizable { public static final String NAME = "__cbrace__"; @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { throw new UnsupportedOperationException("Not supported yet."); } @@ -1066,7 +1067,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { throw new UnsupportedOperationException(getName() + " should have been compiled out. If you are reaching" + " this, an error has occurred in the parser. Please report this error to the developers."); } @@ -1240,7 +1241,7 @@ public String docs() { } @Override - public Mixed exec(Target t, Environment env, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { Mixed value = args[0]; CClassType type = ArgumentValidation.getClassType(args[1], t); if(!InstanceofUtil.isInstanceof(value, type, env)) { @@ -1337,7 +1338,7 @@ public String getName() { } @Override - public Mixed exec(Target t, Environment env, Mixed... args) throws CancelCommandException, ConfigRuntimeException { + public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws CancelCommandException, ConfigRuntimeException { // Get arguments. CClassType type; diff --git a/src/main/java/com/laytonsmith/core/functions/CompositeFunction.java b/src/main/java/com/laytonsmith/core/functions/CompositeFunction.java index 30937cdf93..6461fb1999 100644 --- a/src/main/java/com/laytonsmith/core/functions/CompositeFunction.java +++ b/src/main/java/com/laytonsmith/core/functions/CompositeFunction.java @@ -16,6 +16,7 @@ import com.laytonsmith.core.constructs.IVariable; import com.laytonsmith.core.constructs.IVariableList; import com.laytonsmith.core.constructs.Target; +import com.laytonsmith.core.constructs.generics.GenericParameters; import com.laytonsmith.core.environments.Environment; import com.laytonsmith.core.environments.GlobalEnv; import com.laytonsmith.core.exceptions.ConfigCompileException; @@ -41,7 +42,7 @@ public abstract class CompositeFunction extends AbstractFunction { private static final Map, ParseTree> CACHED_SCRIPTS = new HashMap<>(); @Override - public final Mixed exec(Target t, Environment env, Mixed... args) throws ConfigRuntimeException { + public final Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { ParseTree tree; // TODO: Ultimately, this is not scalable. We need to compile and cache these scripts at Java compile time, // not at runtime the first time a function is used. This is an easier first step though. diff --git a/src/main/java/com/laytonsmith/core/functions/ControlFlow.java b/src/main/java/com/laytonsmith/core/functions/ControlFlow.java index b571627e0e..6f109abe7c 100644 --- a/src/main/java/com/laytonsmith/core/functions/ControlFlow.java +++ b/src/main/java/com/laytonsmith/core/functions/ControlFlow.java @@ -52,6 +52,7 @@ import com.laytonsmith.core.constructs.IVariable; import com.laytonsmith.core.constructs.InstanceofUtil; import com.laytonsmith.core.constructs.Target; +import com.laytonsmith.core.constructs.generics.GenericParameters; import com.laytonsmith.core.environments.CommandHelperEnvironment; import com.laytonsmith.core.environments.Environment; import com.laytonsmith.core.environments.GlobalEnv; @@ -127,7 +128,7 @@ public Mixed execs(Target t, Environment env, Script parent, ParseTree... nodes) } @Override - public Mixed exec(Target t, Environment env, Mixed... args) + public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws CancelCommandException, ConfigRuntimeException { return CVoid.VOID; } @@ -407,7 +408,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { return CNull.NULL; } @@ -636,7 +637,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { return CNull.NULL; } @@ -695,11 +696,11 @@ public Mixed execs(Target t, Environment env, Script parent, ParseTree... nodes) return parent.seval(code, env); } } - } else if(equals.exec(t, env, value, inner).getBoolean()) { + } else if(equals.exec(t, env, null, value, inner).getBoolean()) { return parent.seval(code, env); } } - } else if(equals.exec(t, env, value, evalStatement).getBoolean()) { + } else if(equals.exec(t, env, null, value, evalStatement).getBoolean()) { return parent.seval(code, env); } } @@ -856,7 +857,7 @@ public ParseTree optimizeDynamic(Target t, Environment env, + " remove the duplicate value"; final BasicLogic.equals equals = new BasicLogic.equals(); Set values = new TreeSet<>((Mixed t1, Mixed t2) -> { - if(equals.exec(Target.UNKNOWN, null, t1, t2).getBoolean()) { + if(equals.exec(Target.UNKNOWN, null, null, t1, t2).getBoolean()) { return 0; } else { return t1.val().compareTo(t2.val()); @@ -943,7 +944,7 @@ public ParseTree optimizeDynamic(Target t, Environment env, break; } } - } else if(equals.exec(t, null, children.get(0).getData(), value).getBoolean()) { + } else if(equals.exec(t, null, null, children.get(0).getData(), value).getBoolean()) { toReturn = children.get(i + 1); break; } @@ -1006,7 +1007,7 @@ public List isScope(List children) { public static class switch_ic extends _switch implements Optimizable, BranchStatement, VariableScope { @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { throw new Error(); } @@ -1093,7 +1094,7 @@ public Integer[] numArgs() { } @Override - public Mixed exec(Target t, Environment env, Mixed... args) { + public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) { return CVoid.VOID; } @@ -1314,7 +1315,7 @@ public boolean useSpecialExec() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { return null; } @@ -1469,7 +1470,7 @@ public Integer[] numArgs() { } @Override - public Mixed exec(Target t, Environment env, Mixed... args) + public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws CancelCommandException, ConfigRuntimeException { return CVoid.VOID; } @@ -1503,9 +1504,9 @@ public Mixed execs(Target t, Environment env, Script parent, ParseTree... nodes) long finish = ((CSlice) arr).getFinish(); if(finish < start) { arr = new ArrayHandling.range() - .exec(t, env, new CInt(start, t), new CInt(finish - 1, t), new CInt(-1, t)); + .exec(t, env, null, new CInt(start, t), new CInt(finish - 1, t), new CInt(-1, t)); } else { - arr = new ArrayHandling.range().exec(t, env, new CInt(start, t), new CInt(finish + 1, t)); + arr = new ArrayHandling.range().exec(t, env, null, new CInt(start, t), new CInt(finish + 1, t)); } } if(!(arr instanceof com.laytonsmith.core.natives.interfaces.Iterable)) { @@ -2123,7 +2124,7 @@ public boolean useSpecialExec() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { return CNull.NULL; } @@ -2229,7 +2230,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { return CNull.NULL; } @@ -2471,7 +2472,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment env, Mixed... args) + public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws CancelCommandException, ConfigRuntimeException { int num = 1; if(args.length == 1) { @@ -2619,7 +2620,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment env, Mixed... args) + public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws CancelCommandException, ConfigRuntimeException { int num = 1; if(args.length == 1) { @@ -2756,7 +2757,7 @@ public Set optimizationOptions() { } @Override - public Mixed exec(Target t, Environment env, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { Mixed ret = (args.length == 1 ? args[0] : CVoid.VOID); throw new FunctionReturnException(ret, t); } @@ -2813,7 +2814,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment env, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { if(args.length < 1) { throw new CREInsufficientArgumentsException("Expecting at least one argument to " + getName(), t); } @@ -2863,7 +2864,7 @@ public ParseTree optimizeDynamic(Target t, Environment env, public static class call_proc_array extends call_proc { @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { CArray ca = ArgumentValidation.getArray(args[1], t); if(ca.inAssociativeMode()) { throw new CRECastException("Expected the array passed to " + getName() + " to be non-associative.", t); @@ -2873,7 +2874,8 @@ public Mixed exec(Target t, Environment environment, Mixed... args) throws Confi for(int i = 1; i < args2.length; i++) { args2[i] = ca.get(i - 1, t); } - return super.exec(t, environment, args2); + // TODO: This probably needs to change once generics are added + return super.exec(t, environment, null, args2); } @Override @@ -2924,7 +2926,7 @@ public Integer[] numArgs() { } @Override - public Mixed exec(Target t, Environment env, Mixed... args) throws CancelCommandException { + public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws CancelCommandException { if(args.length == 0) { throw new CancelCommandException("", t); } diff --git a/src/main/java/com/laytonsmith/core/functions/Crypto.java b/src/main/java/com/laytonsmith/core/functions/Crypto.java index c27de8bcd8..17b3e89d8b 100644 --- a/src/main/java/com/laytonsmith/core/functions/Crypto.java +++ b/src/main/java/com/laytonsmith/core/functions/Crypto.java @@ -13,6 +13,7 @@ import com.laytonsmith.core.constructs.CSecureString; import com.laytonsmith.core.constructs.CString; import com.laytonsmith.core.constructs.Target; +import com.laytonsmith.core.constructs.generics.GenericParameters; import com.laytonsmith.core.environments.Environment; import com.laytonsmith.core.exceptions.CRE.CRECastException; import com.laytonsmith.core.exceptions.CRE.CREPluginInternalException; @@ -114,7 +115,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { String s = args[0].val(); StringBuilder b = new StringBuilder(); for(int i = 0; i < s.length(); i++) { @@ -193,7 +194,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { try { byte[] val = getByteArrayFromArg(args[0]); MessageDigest digest = java.security.MessageDigest.getInstance("MD5"); @@ -264,7 +265,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { try { byte[] val = getByteArrayFromArg(args[0]); MessageDigest digest = java.security.MessageDigest.getInstance("SHA1"); @@ -334,7 +335,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { try { byte[] val = getByteArrayFromArg(args[0]); MessageDigest digest = java.security.MessageDigest.getInstance("SHA-256"); @@ -405,7 +406,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { try { byte[] val = getByteArrayFromArg(args[0]); MessageDigest digest = java.security.MessageDigest.getInstance("SHA-512"); @@ -453,7 +454,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { int log_rounds = 5; if(args.length == 2) { log_rounds = ArgumentValidation.getInt32(args[1], t); @@ -529,7 +530,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { String val; if(args[0].isInstanceOf(CSecureString.TYPE)) { val = new String(((CSecureString) args[0]).getDecryptedCharArray()); @@ -590,7 +591,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { CByteArray ba = ArgumentValidation.getByteArray(args[0], t); byte[] data = ba.asByteArrayCopy(); data = Base64.encodeBase64(data); @@ -645,7 +646,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { CByteArray ba = ArgumentValidation.getByteArray(args[0], t); byte[] data = ba.asByteArrayCopy(); data = Base64.decodeBase64(data); @@ -722,7 +723,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { return getHMAC("HmacMD5", t, args); } @@ -782,7 +783,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { return getHMAC("HmacSHA1", t, args); } @@ -842,7 +843,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { return getHMAC("HmacSHA256", t, args); } diff --git a/src/main/java/com/laytonsmith/core/functions/DataHandling.java b/src/main/java/com/laytonsmith/core/functions/DataHandling.java index bc4eb359aa..6680b1e0f0 100644 --- a/src/main/java/com/laytonsmith/core/functions/DataHandling.java +++ b/src/main/java/com/laytonsmith/core/functions/DataHandling.java @@ -70,6 +70,7 @@ import com.laytonsmith.core.constructs.InstanceofUtil; import com.laytonsmith.core.constructs.ProcedureUsage; import com.laytonsmith.core.constructs.Target; +import com.laytonsmith.core.constructs.generics.GenericParameters; import com.laytonsmith.core.environments.CommandHelperEnvironment; import com.laytonsmith.core.environments.Environment; import com.laytonsmith.core.environments.Environment.EnvironmentImpl; @@ -143,7 +144,7 @@ public Integer[] numArgs() { } @Override - public Mixed exec(Target t, Environment env, Mixed... args) throws CancelCommandException, ConfigRuntimeException { + public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws CancelCommandException, ConfigRuntimeException { return new CArray(t, args); } @@ -279,7 +280,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { return CArray.GetAssociativeArray(t, args); } @@ -340,7 +341,7 @@ public Integer[] numArgs() { } @Override - public Mixed exec(Target t, Environment env, Mixed... args) throws CancelCommandException, ConfigRuntimeException { + public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws CancelCommandException, ConfigRuntimeException { IVariableList list = env.getEnv(GlobalEnv.class).GetVarList(); IVariable var; if(args.length == 3) { @@ -845,7 +846,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment env, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { return CBoolean.get(!(args[0].isInstanceOf(CArray.TYPE))); } @@ -906,7 +907,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment env, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { return CBoolean.get(args[0].isInstanceOf(CString.TYPE)); } @@ -965,7 +966,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment env, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { return CBoolean.get(args[0].isInstanceOf(CByteArray.TYPE)); } @@ -1025,7 +1026,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment env, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { return CBoolean.get(args[0].isInstanceOf(CArray.TYPE)); } @@ -1087,7 +1088,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment env, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { return CBoolean.get(args[0].isInstanceOf(CInt.TYPE) || args[0].isInstanceOf(CDouble.TYPE)); } @@ -1150,7 +1151,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment env, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { return CBoolean.get(args[0].isInstanceOf(CDouble.TYPE)); } @@ -1211,7 +1212,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment env, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { return CBoolean.get(args[0].isInstanceOf(CInt.TYPE)); } @@ -1271,7 +1272,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment env, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { return CBoolean.get(args[0].isInstanceOf(CBoolean.TYPE)); } @@ -1330,7 +1331,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment env, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { return CBoolean.get(args[0] instanceof CNull); } @@ -1385,7 +1386,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { boolean b = true; try { ArgumentValidation.getNumber(args[0], t); @@ -1459,7 +1460,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { double d; try { d = ArgumentValidation.getDouble(args[0], t); @@ -1696,7 +1697,7 @@ public static Procedure getProcedure(Target t, Environment env, Script parent, P } @Override - public Mixed exec(Target t, Environment env, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { return CVoid.VOID; } @@ -1940,7 +1941,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment env, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { String procName = args[0].val(); Procedure proc = env.getEnv(GlobalEnv.class).GetProcs().get(procName); if(proc == null) { @@ -2075,7 +2076,7 @@ public Boolean runAsync() { } @Override - public CVoid exec(Target t, Environment env, Mixed... args) throws ConfigRuntimeException { + public CVoid exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { return CVoid.VOID; } @@ -2291,7 +2292,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { // This function is rewritten to include() calls in compile time, so this doesn't exist in runtime. throw new UnsupportedOperationException(); } @@ -2439,7 +2440,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment env, Mixed... args) { + public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) { return CBoolean.get(env.getEnv(GlobalEnv.class).GetProcs().get(args[0].val()) != null); } } @@ -2483,7 +2484,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment env, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { if(args[0].isInstanceOf(CArray.TYPE)) { return CBoolean.get(((CArray) args[0]).inAssociativeMode()); } else { @@ -2542,7 +2543,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { return CBoolean.get(args[0].isInstanceOf(CClosure.TYPE)); } @@ -2603,7 +2604,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { String key; if(args[0].isInstanceOf(CString.TYPE)) { key = args[0].val(); @@ -2674,7 +2675,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { String key; if(args[0].isInstanceOf(CString.TYPE)) { key = args[0].val(); @@ -2766,7 +2767,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { return CVoid.VOID; } @@ -3133,7 +3134,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { if(args[args.length - 1] instanceof Callable callable) { Mixed[] vals = new Mixed[args.length - 1]; System.arraycopy(args, 0, vals, 0, args.length - 1); @@ -3198,7 +3199,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { Mixed[] vals = ArgumentValidation.getArray(args[0], t).asList().toArray(new Mixed[0]); CClosure closure = ArgumentValidation.getObject(args[1], t, CClosure.class); return closure.executeCallable(vals); @@ -3250,7 +3251,7 @@ public boolean isRestricted() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { if(!(args[args.length - 1].isInstanceOf(CClosure.TYPE))) { throw new CRECastException("Only a closure (created from the closure function) can be sent to executeas()", t); } @@ -3339,7 +3340,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { return CBoolean.get(ArgumentValidation.getBoolean(args[0], t)); } @@ -3408,7 +3409,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { Mixed arg = args[0]; if(arg instanceof CMutablePrimitive) { arg = ((CMutablePrimitive) arg).get(); @@ -3501,7 +3502,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { return new CDouble(ArgumentValidation.getDouble(args[0], t), t); } @@ -3566,7 +3567,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { if(args[0].isInstanceOf(CString.TYPE)) { return args[0]; } @@ -3618,7 +3619,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { int radix = ArgumentValidation.getInt32(args[1], t); if(radix < Character.MIN_RADIX || radix > Character.MAX_RADIX) { throw new CRERangeException("The radix must be between " + Character.MIN_RADIX + " and " + Character.MAX_RADIX + ", inclusive.", t); @@ -3690,7 +3691,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { String value = args[0].val(); int radix = ArgumentValidation.getInt32(args[1], t); if(radix < Character.MIN_RADIX || radix > Character.MAX_RADIX) { @@ -3775,7 +3776,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { try { return args[0].typeof(); } catch (IllegalArgumentException ex) { @@ -3912,7 +3913,7 @@ public Mixed execs(Target t, Environment env, Script parent, ParseTree... nodes) } @Override - public Mixed exec(Target t, Environment env, Mixed... args) throws CancelCommandException, ConfigRuntimeException { + public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws CancelCommandException, ConfigRuntimeException { return CVoid.VOID; } //Doesn't matter, run out of state anyways @@ -3968,7 +3969,7 @@ public Integer[] numArgs() { } @Override - public Mixed exec(Target t, Environment env, Mixed... args) throws CancelCommandException, ConfigRuntimeException { + public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws CancelCommandException, ConfigRuntimeException { return CVoid.VOID; } @@ -4029,7 +4030,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { Mixed val = CNull.NULL; if(args.length > 0) { val = args[0]; @@ -4131,7 +4132,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { if(args[0] instanceof CNull) { return CBoolean.FALSE; } @@ -4193,7 +4194,7 @@ public ParseTree optimizeDynamic(Target t, Environment env, } // It's hardcoded, allow it, but optimize it out. if(children.get(0).isConst()) { - return new ParseTree(exec(t, null, children.get(0).getData(), children.get(1).getData()), fileOptions); + return new ParseTree(exec(t, null, null, children.get(0).getData(), children.get(1).getData()), fileOptions); } return null; } @@ -4238,7 +4239,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment env, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { IVariableList list = env.getEnv(GlobalEnv.class).GetVarList(); Mixed value = list.get(((IVariable) args[0]).getVariableName(), t, env).ival(); list.freeValue(value); @@ -4304,7 +4305,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { CClassType type = ArgumentValidation.getClassType(args[0], t); int size = ArgumentValidation.getInt32(args[1], t); if(size < 0) { diff --git a/src/main/java/com/laytonsmith/core/functions/DataTransformations.java b/src/main/java/com/laytonsmith/core/functions/DataTransformations.java index e56c9db147..ae64c58534 100644 --- a/src/main/java/com/laytonsmith/core/functions/DataTransformations.java +++ b/src/main/java/com/laytonsmith/core/functions/DataTransformations.java @@ -14,6 +14,7 @@ import com.laytonsmith.core.constructs.CString; import com.laytonsmith.core.constructs.Construct; import com.laytonsmith.core.constructs.Target; +import com.laytonsmith.core.constructs.generics.GenericParameters; import com.laytonsmith.core.environments.Environment; import com.laytonsmith.core.environments.GlobalEnv; import com.laytonsmith.core.exceptions.CRE.CRECastException; @@ -72,7 +73,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { CArray ca = ArgumentValidation.getArray(args[0], t); try { return new CString(Construct.json_encode(ca, t), t); @@ -129,7 +130,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { String s = args[0].val(); try { return Construct.json_decode(s, t); @@ -187,7 +188,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { CArray ca = ArgumentValidation.getArray(args[0], t); boolean prettyPrint = false; if(args.length == 2) { @@ -248,7 +249,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment env, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { String data = args[0].val(); LoaderOptions options = new LoaderOptions(); Mixed codePointLimit = env.getEnv(GlobalEnv.class) @@ -322,7 +323,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { Properties props = new Properties(); CArray arr = ArgumentValidation.getArray(args[0], t); String comment = null; @@ -401,7 +402,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { Properties props = new Properties(); Reader reader = new StringReader(args[0].val()); try { @@ -468,7 +469,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { XMLDocument doc; try { doc = new XMLDocument(args[0].val()); @@ -524,7 +525,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { throw new UnsupportedOperationException("Not supported yet."); } diff --git a/src/main/java/com/laytonsmith/core/functions/Debug.java b/src/main/java/com/laytonsmith/core/functions/Debug.java index 3e8a878b2e..a703d73f60 100644 --- a/src/main/java/com/laytonsmith/core/functions/Debug.java +++ b/src/main/java/com/laytonsmith/core/functions/Debug.java @@ -22,6 +22,7 @@ import com.laytonsmith.core.constructs.CVoid; import com.laytonsmith.core.constructs.IVariable; import com.laytonsmith.core.constructs.Target; +import com.laytonsmith.core.constructs.generics.GenericParameters; import com.laytonsmith.core.environments.Environment; import com.laytonsmith.core.environments.GlobalEnv; import com.laytonsmith.core.exceptions.CRE.CRECastException; @@ -109,7 +110,7 @@ public static String docs() { // return false; // } // -// public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { +// public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { // if(!(Boolean) Static.getPreferences().getPreference("allow-debug-logging")) { // throw new ConfigRuntimeException("allow-debug-logging is currently set to false. To use " + this.getVariableName() + ", enable it in your preferences.", CRESecurityException.class, t); // } @@ -242,7 +243,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { if(Prefs.DebugMode()) { try { Static.LogDebug(MethodScriptFileLocations.getDefault().getConfigDirectory(), args[0].val(), LogLevel.DEBUG); @@ -259,7 +260,7 @@ public Mixed exec(Target t, Environment environment, Mixed... args) throws Confi public static class trace extends always_trace { @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { //TODO: Once Prefs are no longer static, check to see if debug mode is on during compilation, and //if so, remove this function entirely if(Prefs.DebugMode()) { @@ -306,7 +307,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { return doTrace(t, environment, args); } @@ -441,7 +442,7 @@ public ParseTree optimizeDynamic(Target t, Environment env, // return false; // } // -// public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { +// public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { // if(!(Boolean) Static.getPreferences().getPreference("allow-debug-logging")) { // throw new ConfigRuntimeException("allow-debug-logging is currently set to false. To use " + this.getVariableName() + ", enable it in your preferences.", CRESecurityException.class, t); // } @@ -494,7 +495,7 @@ public ParseTree optimizeDynamic(Target t, Environment env, // return true; // } // -// public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { +// public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { // if(!(Boolean) Static.getPreferences().getPreference("allow-debug-logging")) { // throw new ConfigRuntimeException("allow-debug-logging is currently set to false. To use " + this.getVariableName() + ", enable it in your preferences.", CRESecurityException.class, t); // } @@ -570,7 +571,7 @@ public ParseTree optimizeDynamic(Target t, Environment env, // return false; // } // -// public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { +// public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { // if(!(Boolean) Static.getPreferences().getPreference("allow-debug-logging")) { // throw new ConfigRuntimeException("allow-debug-logging is currently set to false. To use " + this.getVariableName() + ", enable it in your preferences.", CRESecurityException.class, t); // } @@ -606,7 +607,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { Set threadSet = Thread.getAllStackTraces().keySet(); CArray carray = new CArray(t); for(Thread thread : threadSet) { @@ -658,7 +659,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { File file = new File("dump.hprof"); try { HeapDumper.dumpHeap(file.getAbsolutePath(), true); @@ -713,7 +714,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { Script.debugOutput = ArgumentValidation.getBoolean(args[0], t); if(Script.debugOutput) { StreamUtils.GetSystemOut().println(TermColors.BG_RED + "[[DEBUG]] set_debug_output(true)" diff --git a/src/main/java/com/laytonsmith/core/functions/Easings.java b/src/main/java/com/laytonsmith/core/functions/Easings.java index 8e8f559765..3ccbaf485b 100644 --- a/src/main/java/com/laytonsmith/core/functions/Easings.java +++ b/src/main/java/com/laytonsmith/core/functions/Easings.java @@ -13,6 +13,7 @@ import com.laytonsmith.core.constructs.CClassType; import com.laytonsmith.core.constructs.CDouble; import com.laytonsmith.core.constructs.Target; +import com.laytonsmith.core.constructs.generics.GenericParameters; import com.laytonsmith.core.environments.Environment; import com.laytonsmith.core.exceptions.CRE.CRECastException; import com.laytonsmith.core.exceptions.CRE.CREThrowable; @@ -52,7 +53,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment env, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { com.laytonsmith.core.Easings.EasingType type = ArgumentValidation.getEnum(args[0], com.laytonsmith.core.Easings.EasingType.class, t); double x = ArgumentValidation.getDouble(args[1], t); @@ -136,7 +137,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment env, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { CArray start = ArgumentValidation.getArray(args[0], t); double startX = ArgumentValidation.getDouble(start.get("x", t), t); double startY = ArgumentValidation.getDouble(start.get("y", t), t); diff --git a/src/main/java/com/laytonsmith/core/functions/Echoes.java b/src/main/java/com/laytonsmith/core/functions/Echoes.java index 0bc72f0fbb..ea7f08f5c0 100644 --- a/src/main/java/com/laytonsmith/core/functions/Echoes.java +++ b/src/main/java/com/laytonsmith/core/functions/Echoes.java @@ -25,6 +25,7 @@ import com.laytonsmith.core.constructs.CVoid; import com.laytonsmith.core.constructs.Construct; import com.laytonsmith.core.constructs.Target; +import com.laytonsmith.core.constructs.generics.GenericParameters; import com.laytonsmith.core.environments.CommandHelperEnvironment; import com.laytonsmith.core.environments.Environment; import com.laytonsmith.core.environments.GlobalEnv; @@ -69,7 +70,7 @@ public Integer[] numArgs() { } @Override - public Mixed exec(final Target t, Environment env, final Mixed... args) throws ConfigRuntimeException { + public Mixed exec(final Target t, Environment env, GenericParameters generics, final Mixed... args) throws ConfigRuntimeException { StringBuilder b = new StringBuilder(); for(Mixed arg : args) { b.append(arg.val()); @@ -135,7 +136,7 @@ public Integer[] numArgs() { } @Override - public Mixed exec(Target t, Environment env, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { if(args.length < 2) { throw new CREInsufficientArgumentsException("You must send at least 2 arguments to tmsg", t); } @@ -201,7 +202,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { String selector = "@a"; String json; try { @@ -310,7 +311,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCPlayer player; int fadein = 10; int stay = 70; @@ -351,7 +352,7 @@ public String docs() { return "void {[player], message} Sends a message to the action bar above the hot bar."; } - public Construct exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Construct exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCPlayer player; String message; if(args.length == 2) { @@ -400,7 +401,7 @@ public Integer[] numArgs() { } @Override - public Mixed exec(Target t, Environment env, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { String val = Construct.nval(args[0]); if(val == null) { return new CString(MCChatColor.WHITE.toString(), t); @@ -552,7 +553,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { return new CString(MCChatColor.stripColor(args[0].val()), t); } @@ -572,7 +573,7 @@ public Integer[] numArgs() { } @Override - public Mixed exec(final Target t, final Environment env, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(final Target t, final Environment env, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCPlayer p = env.getEnv(CommandHelperEnvironment.class).GetPlayer(); if(p != null) { p.chat(args[0].val()); @@ -646,7 +647,7 @@ public MSVersion since() { } @Override - public Mixed exec(Target t, Environment env, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { final MCPlayer player = Static.GetPlayer(args[0], t); player.chat(args[1].val()); return CVoid.VOID; @@ -700,7 +701,7 @@ public MSVersion since() { } @Override - public Mixed exec(Target t, Environment env, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { final MCServer server = Static.getServer(); // Handle "broadcast(message, [null])". @@ -789,7 +790,7 @@ public MSVersion since() { } @Override - public Mixed exec(Target t, Environment env, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { String mes = Static.MCToANSIColors(args[0].val()); boolean prefix = ArgumentValidation.getBooleanish(env.getEnv(GlobalEnv.class) .GetRuntimeSetting("function.console.prefix_default", CBoolean.TRUE), t); @@ -835,7 +836,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { Mixed text = args[0]; String symbol = "&"; if(args.length == 2) { diff --git a/src/main/java/com/laytonsmith/core/functions/Enchantments.java b/src/main/java/com/laytonsmith/core/functions/Enchantments.java index 88c6e81994..e10aaac9d7 100644 --- a/src/main/java/com/laytonsmith/core/functions/Enchantments.java +++ b/src/main/java/com/laytonsmith/core/functions/Enchantments.java @@ -21,6 +21,7 @@ import com.laytonsmith.core.constructs.CString; import com.laytonsmith.core.constructs.CVoid; import com.laytonsmith.core.constructs.Target; +import com.laytonsmith.core.constructs.generics.GenericParameters; import com.laytonsmith.core.environments.CommandHelperEnvironment; import com.laytonsmith.core.environments.Environment; import com.laytonsmith.core.exceptions.CRE.CRECastException; @@ -182,7 +183,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCPlayer p; int offset = 0; if(args.length == 4 || args.length == 3 && args[2].isInstanceOf(CArray.TYPE)) { @@ -257,7 +258,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCPlayer p; int offset = 0; if(args.length == 3) { @@ -330,7 +331,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCPlayer p; Mixed slot; if(args.length == 2) { @@ -391,7 +392,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCEnchantment e = GetEnchantment(args[0].val(), t); MCItemStack is = ObjectGenerator.GetGenerator().item(args[1], t); return CBoolean.get(e.canEnchantItem(is)); @@ -438,7 +439,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCEnchantment e = GetEnchantment(args[0].val().replace(' ', '_'), t); return new CInt(e.getMaxLevel(), t); } @@ -487,7 +488,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCItemStack is; if(args[0].isInstanceOf(CArray.TYPE)) { is = ObjectGenerator.GetGenerator().item(args[0], t); @@ -570,7 +571,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { try { GetEnchantment(args[0].val(), t); return CBoolean.TRUE; @@ -599,7 +600,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { CArray ret = new CArray(t); for(MCEnchantment e : MCEnchantment.values()) { ret.push(new CString(e.name().toLowerCase(), t), t); diff --git a/src/main/java/com/laytonsmith/core/functions/EntityManagement.java b/src/main/java/com/laytonsmith/core/functions/EntityManagement.java index daa5d8e824..e80a147e33 100644 --- a/src/main/java/com/laytonsmith/core/functions/EntityManagement.java +++ b/src/main/java/com/laytonsmith/core/functions/EntityManagement.java @@ -145,6 +145,7 @@ import com.laytonsmith.core.constructs.CString; import com.laytonsmith.core.constructs.CVoid; import com.laytonsmith.core.constructs.Target; +import com.laytonsmith.core.constructs.generics.GenericParameters; import com.laytonsmith.core.environments.CommandHelperEnvironment; import com.laytonsmith.core.environments.Environment; import com.laytonsmith.core.exceptions.CRE.CREBadEntityException; @@ -224,7 +225,7 @@ public Class[] thrown() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { CArray ret = new CArray(t); if(args.length == 0) { for(MCWorld w : Static.getServer().getWorlds()) { @@ -316,7 +317,7 @@ public ExampleScript[] examples() throws ConfigCompileException { public static class entity_exists extends EntityGetterFunction { @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { try { Static.getEntity(args[0], t); } catch(ConfigRuntimeException cre) { @@ -345,7 +346,7 @@ public MSVersion since() { public static class is_entity_living extends EntityGetterFunction { @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCEntity e; try { @@ -393,7 +394,7 @@ public MSVersion since() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCEntity e = Static.getEntity(args[0], t); return CBoolean.get(e instanceof MCLivingEntity && ((MCLivingEntity) e).isTameable()); } @@ -404,7 +405,7 @@ public Mixed exec(Target t, Environment environment, Mixed... args) throws Confi public static class entity_loc extends EntityGetterFunction { @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCEntity e = Static.getEntity(args[0], t); return ObjectGenerator.GetGenerator().location(e.getLocation()); } @@ -447,7 +448,7 @@ public Class[] thrown() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCEntity e = Static.getEntity(args[0], t); MCLocation l; if(args[1].isInstanceOf(CArray.TYPE)) { @@ -507,7 +508,7 @@ public MSVersion since() { public static class entity_velocity extends EntityGetterFunction { @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCEntity e = Static.getEntity(args[0], t); CArray va = ObjectGenerator.GetGenerator().vector(e.getVelocity(), t); va.set("magnitude", new CDouble(e.getVelocity().length(), t), t); @@ -546,7 +547,7 @@ public MSVersion since() { public static class set_entity_velocity extends EntitySetterFunction { @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCEntity e = Static.getEntity(args[0], t); try { e.setVelocity(ObjectGenerator.GetGenerator().vector(args[1], t)); @@ -597,7 +598,7 @@ public MSVersion since() { public static class entity_remove extends EntityGetterFunction { @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCEntity ent = Static.getEntity(args[0], t); if(ent instanceof MCHumanEntity) { throw new CREBadEntityException("Cannot remove human entity (" + ent.getUniqueId() + ")!", t); @@ -630,7 +631,7 @@ public MSVersion since() { public static class get_entity_saves_on_unload extends EntityGetterFunction { @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCEntity ent = Static.getEntity(args[0], t); return CBoolean.get(ent.savesOnUnload()); } @@ -657,7 +658,7 @@ public MSVersion since() { public static class set_entity_saves_on_unload extends EntitySetterFunction { @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCEntity ent = Static.getEntity(args[0], t); ent.setSavesOnUnload(ArgumentValidation.getBooleanObject(args[1], t)); return CVoid.VOID; @@ -691,7 +692,7 @@ public Class[] thrown() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCEntity ent; try { ent = Static.getEntity(args[0], t); @@ -723,7 +724,7 @@ public MSVersion since() { public static class get_entity_age extends EntityGetterFunction { @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { return new CInt(Static.getEntity(args[0], t).getTicksLived(), t); } @@ -754,7 +755,7 @@ public Class[] thrown() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { int age = ArgumentValidation.getInt32(args[1], t); MCEntity ent = Static.getEntity(args[0], t); try { @@ -792,7 +793,7 @@ public Class[] thrown() { } @Override - public Mixed exec(Target t, Environment env, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCPlayer p = env.getEnv(CommandHelperEnvironment.class).GetPlayer(); @@ -953,7 +954,7 @@ public Integer[] numArgs() { } @Override - public Mixed exec(Target t, Environment env, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCPlayer p = env.getEnv(CommandHelperEnvironment.class).GetPlayer(); MCLocation loc; @@ -1085,7 +1086,7 @@ public Set optimizationOptions() { public static class entity_onfire extends EntityGetterFunction { @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCEntity ent = Static.getEntity(args[0], t); return new CInt(ent.getFireTicks() / 20, t); } @@ -1113,7 +1114,7 @@ public MSVersion since() { public static class set_entity_onfire extends EntitySetterFunction { @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCEntity ent = Static.getEntity(args[0], t); int seconds = ArgumentValidation.getInt32(args[1], t); if(seconds < 0) { @@ -1148,7 +1149,7 @@ public MSVersion since() { public static class play_entity_effect extends EntitySetterFunction implements Optimizable { @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCEntity ent = Static.getEntity(args[0], t); try { MCEntityEffect mee = MCEntityEffect.valueOf(args[1].val().toUpperCase()); @@ -1213,7 +1214,7 @@ public Set optimizationOptions() { public static class get_mob_name extends EntityGetterFunction { @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCEntity le = Static.getEntity(args[0], t); try { return new CString(le.getCustomName(), t); @@ -1243,7 +1244,7 @@ public MSVersion since() { public static class set_mob_name extends EntitySetterFunction { @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCEntity le = Static.getEntity(args[0], t); try { le.setCustomName(args[1].val()); @@ -1281,7 +1282,7 @@ public Class[] thrown() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCCommandSender cs = environment.getEnv(CommandHelperEnvironment.class).GetCommandSender(); int qty = 1; CArray ret = new CArray(t); @@ -1441,7 +1442,7 @@ public Set optimizationOptions() { public static class set_entity_rider extends EntitySetterFunction { @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCEntity horse; MCEntity rider; boolean success; @@ -1498,7 +1499,7 @@ public MSVersion since() { public static class get_entity_rider extends EntityGetterFunction { @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCEntity ent = Static.getEntity(args[0], t); List passengers = ent.getPassengers(); if(!passengers.isEmpty()) { @@ -1529,7 +1530,7 @@ public MSVersion since() { public static class get_entity_riders extends EntityGetterFunction { @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCEntity ent = Static.getEntity(args[0], t); List riders = ent.getPassengers(); CArray ret = new CArray(t); @@ -1560,7 +1561,7 @@ public MSVersion since() { public static class get_entity_vehicle extends EntityGetterFunction { @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCEntity ent = Static.getEntity(args[0], t); if(ent.isInsideVehicle()) { return new CString(ent.getVehicle().getUniqueId().toString(), t); @@ -1594,7 +1595,7 @@ public Class[] thrown() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCEntity e = Static.getEntity(args[0], t); if(e instanceof MCMinecart) { return new CDouble(((MCMinecart) e).getMaxSpeed(), t); @@ -1629,7 +1630,7 @@ public Class[] thrown() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCEntity e = Static.getEntity(args[0], t); double speed = ArgumentValidation.getDouble(args[1], t); if(e instanceof MCMinecart) { @@ -1661,7 +1662,7 @@ public MSVersion since() { public static class get_name_visible extends EntityGetterFunction { @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { try { return CBoolean.get(Static.getEntity(args[0], t).isCustomNameVisible()); } catch(IllegalArgumentException e) { @@ -1692,7 +1693,7 @@ public MSVersion since() { public static class set_name_visible extends EntitySetterFunction { @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { try { Static.getEntity(args[0], t).setCustomNameVisible(ArgumentValidation.getBoolean(args[1], t)); } catch(IllegalArgumentException e) { @@ -1724,7 +1725,7 @@ public MSVersion since() { public static class get_art_at extends EntityGetterFunction { @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCWorld w = null; if(environment.getEnv(CommandHelperEnvironment.class).GetPlayer() != null) { w = environment.getEnv(CommandHelperEnvironment.class).GetPlayer().getWorld(); @@ -1762,7 +1763,7 @@ public Version since() { public static class set_art_at extends EntitySetterFunction { @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCWorld w = null; if(environment.getEnv(CommandHelperEnvironment.class).GetPlayer() != null) { w = environment.getEnv(CommandHelperEnvironment.class).GetPlayer().getWorld(); @@ -1814,7 +1815,7 @@ public Version since() { public static class entity_grounded extends EntityGetterFunction { @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { return CBoolean.get(Static.getEntity(args[0], t).isOnGround()); } @@ -1881,7 +1882,7 @@ public String docs() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCEntity entity = Static.getEntity(args[0], t); CArray specArray = CArray.GetAssociativeArray(t); switch(entity.getType().getAbstracted()) { @@ -2594,7 +2595,7 @@ private static void throwException(String index, Target t) throws ConfigRuntimeE } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCEntity entity = Static.getEntity(args[0], t); CArray specArray = ArgumentValidation.getArray(args[1], t); @@ -4216,7 +4217,7 @@ public String docs() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCEntity entity = Static.getEntity(args[0], t); if(entity instanceof MCProjectile) { @@ -4255,7 +4256,7 @@ public String docs() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCEntity entity = Static.getEntity(args[0], t); if(entity instanceof MCProjectile) { if(args[1] instanceof CNull) { @@ -4297,7 +4298,7 @@ public String docs() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCEntity entity = Static.getEntity(args[0], t); if(entity instanceof MCProjectile) { return CBoolean.get(((MCProjectile) entity).doesBounce()); @@ -4327,7 +4328,7 @@ public String docs() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCEntity entity = Static.getEntity(args[0], t); if(entity instanceof MCProjectile) { ((MCProjectile) entity).setBounce(ArgumentValidation.getBoolean(args[1], t)); @@ -4360,7 +4361,7 @@ public String docs() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCEntity entity = Static.getEntity(args[0], t); if(entity instanceof MCItemProjectile) { return ObjectGenerator.GetGenerator().item(((MCItemProjectile) entity).getItem(), t); @@ -4392,7 +4393,7 @@ public String docs() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCEntity entity = Static.getEntity(args[0], t); if(entity instanceof MCItemProjectile) { ((MCItemProjectile) entity).setItem(ObjectGenerator.GetGenerator().item(args[1], t)); @@ -4423,7 +4424,7 @@ public String docs() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { return new CDouble(Static.getEntity(args[0], t).getFallDistance(), t); } @@ -4448,7 +4449,7 @@ public String docs() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { Static.getEntity(args[0], t).setFallDistance(ArgumentValidation.getDouble32(args[1], t)); return CVoid.VOID; } @@ -4474,7 +4475,7 @@ public String docs() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { Static.getEntity(args[0], t).setGlowing(ArgumentValidation.getBoolean(args[1], t)); return CVoid.VOID; } @@ -4500,7 +4501,7 @@ public String docs() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCEntity e = Static.getEntity(args[0], t); return CBoolean.GenerateCBoolean(e.isGlowing(), t); } @@ -4526,7 +4527,7 @@ public String docs() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { return CBoolean.GenerateCBoolean(Static.getEntity(args[0], t).isSilent(), t); } @@ -4551,7 +4552,7 @@ public String docs() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCEntity e = Static.getEntity(args[0], t); e.setSilent(ArgumentValidation.getBoolean(args[1], t)); return CVoid.VOID; @@ -4578,7 +4579,7 @@ public String docs() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { return CBoolean.GenerateCBoolean(Static.getEntity(args[0], t).hasGravity(), t); } @@ -4603,7 +4604,7 @@ public String docs() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCEntity e = Static.getEntity(args[0], t); e.setHasGravity(ArgumentValidation.getBoolean(args[1], t)); return CVoid.VOID; @@ -4630,7 +4631,7 @@ public String docs() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { return CBoolean.GenerateCBoolean(Static.getEntity(args[0], t).isInvulnerable(), t); } @@ -4656,7 +4657,7 @@ public String docs() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCEntity e = Static.getEntity(args[0], t); e.setInvulnerable(ArgumentValidation.getBoolean(args[1], t)); return CVoid.VOID; @@ -4684,7 +4685,7 @@ public String docs() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCEntity e = Static.getEntity(args[0], t); return new CInt(e.getFreezingTicks(), t); } @@ -4717,7 +4718,7 @@ public Class[] thrown() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCEntity entity = Static.getEntity(args[0], t); int ticks = ArgumentValidation.getInt32(args[1], t); if(ticks < 0) { @@ -4748,7 +4749,7 @@ public String docs() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCEntity e = Static.getEntity(args[0], t); CArray tags = new CArray(t); for(String tag : e.getScoreboardTags()) { @@ -4783,7 +4784,7 @@ public String docs() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCEntity e = Static.getEntity(args[0], t); return CBoolean.get(e.hasScoreboardTag(args[1].val())); } @@ -4809,7 +4810,7 @@ public String docs() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCEntity e = Static.getEntity(args[0], t); return CBoolean.get(e.addScoreboardTag(args[1].val())); } @@ -4835,7 +4836,7 @@ public String docs() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCEntity e = Static.getEntity(args[0], t); return CBoolean.get(e.removeScoreboardTag(args[1].val())); } @@ -4888,7 +4889,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment env, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCLocation l; MCItemStack is; boolean natural; @@ -4949,7 +4950,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCPlayer p = environment.getEnv(CommandHelperEnvironment.class).GetPlayer(); MCWorld w = null; if(p != null) { @@ -5063,7 +5064,7 @@ public MSVersion since() { public static class get_hanging_direction extends EntityGetterFunction { @Override - public Mixed exec(Target t, com.laytonsmith.core.environments.Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, com.laytonsmith.core.environments.Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCEntity entity = Static.getEntity(args[0], t); if(entity instanceof MCHanging hanging) { return new CString(hanging.getFacing().name(), t); @@ -5120,7 +5121,7 @@ public CClassType getReturnType(Target t, List argTypes, List[] thrown() { } @Override - public Mixed exec(Target t, Environment env, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCLivingEntity entity = Static.getLivingEntity(args[0], t); if(args[1] instanceof CNull) { entity.setKiller(null); @@ -5816,7 +5817,7 @@ public String docs() { } @Override - public Mixed exec(Target t, Environment env, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCEntity entity = Static.getEntity(args[0], t); return CBoolean.get(!entity.isVisibleByDefault()); } @@ -5845,7 +5846,7 @@ public String docs() { } @Override - public Mixed exec(Target t, Environment env, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCEntity entity = Static.getEntity(args[0], t); entity.setVisibleByDefault(!ArgumentValidation.getBooleanObject(args[1], t)); return CVoid.VOID; @@ -5915,7 +5916,7 @@ public String docs() { } @Override - public Mixed exec(Target t, Environment env, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCEntity entity = Static.getEntity(args[0], t); return new CString(entity.getPose().name(), t); } @@ -5953,7 +5954,7 @@ public String docs() { } @Override - public Mixed exec(Target t, Environment env, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCEntity entity = Static.getEntity(args[0], t); MCPose pose; try { diff --git a/src/main/java/com/laytonsmith/core/functions/Environment.java b/src/main/java/com/laytonsmith/core/functions/Environment.java index 86c2e365c5..d6d3890547 100644 --- a/src/main/java/com/laytonsmith/core/functions/Environment.java +++ b/src/main/java/com/laytonsmith/core/functions/Environment.java @@ -58,6 +58,7 @@ import com.laytonsmith.core.constructs.CVoid; import com.laytonsmith.core.constructs.Construct; import com.laytonsmith.core.constructs.Target; +import com.laytonsmith.core.constructs.generics.GenericParameters; import com.laytonsmith.core.environments.CommandHelperEnvironment; import com.laytonsmith.core.exceptions.CRE.CREBadEntityException; import com.laytonsmith.core.exceptions.CRE.CRECastException; @@ -105,7 +106,7 @@ public String docs() { } @Override - public Mixed exec(Target t, com.laytonsmith.core.environments.Environment env, Mixed... args) + public Mixed exec(Target t, com.laytonsmith.core.environments.Environment env, GenericParameters generics, Mixed... args) throws CancelCommandException, ConfigRuntimeException { MCLocation loc = ObjectGenerator.GetGenerator().location(args[0], null, t); MCBlock b = loc.getWorld().getBlockAt(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ()); @@ -158,7 +159,7 @@ public String docs() { } @Override - public Mixed exec(Target t, com.laytonsmith.core.environments.Environment env, Mixed... args) + public Mixed exec(Target t, com.laytonsmith.core.environments.Environment env, GenericParameters generics, Mixed... args) throws CancelCommandException, ConfigRuntimeException { MCLocation loc = ObjectGenerator.GetGenerator().location(args[0], null, t); boolean physics = true; @@ -215,7 +216,7 @@ public String docs() { } @Override - public Mixed exec(Target t, com.laytonsmith.core.environments.Environment env, Mixed... args) + public Mixed exec(Target t, com.laytonsmith.core.environments.Environment env, GenericParameters generics, Mixed... args) throws CancelCommandException, ConfigRuntimeException { MCLocation loc = ObjectGenerator.GetGenerator().location(args[0], null, t); MCBlock b = loc.getWorld().getBlockAt(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ()); @@ -268,7 +269,7 @@ public String docs() { } @Override - public Mixed exec(Target t, com.laytonsmith.core.environments.Environment env, Mixed... args) + public Mixed exec(Target t, com.laytonsmith.core.environments.Environment env, GenericParameters generics, Mixed... args) throws CancelCommandException, ConfigRuntimeException { MCLocation loc = ObjectGenerator.GetGenerator().location(args[0], null, t); MCBlock b = loc.getWorld().getBlockAt(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ()); @@ -330,7 +331,7 @@ public String docs() { } @Override - public Mixed exec(Target t, com.laytonsmith.core.environments.Environment env, Mixed... args) + public Mixed exec(Target t, com.laytonsmith.core.environments.Environment env, GenericParameters generics, Mixed... args) throws CancelCommandException, ConfigRuntimeException { MCLocation loc = ObjectGenerator.GetGenerator().location(args[0], null, t); MCBlock b = loc.getWorld().getBlockAt(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ()); @@ -385,7 +386,7 @@ public String docs() { } @Override - public Mixed exec(Target t, com.laytonsmith.core.environments.Environment env, Mixed... args) + public Mixed exec(Target t, com.laytonsmith.core.environments.Environment env, GenericParameters generics, Mixed... args) throws CancelCommandException, ConfigRuntimeException { MCLocation loc = ObjectGenerator.GetGenerator().location(args[0], null, t); MCBlock b = loc.getWorld().getBlockAt(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ()); @@ -486,7 +487,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, com.laytonsmith.core.environments.Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, com.laytonsmith.core.environments.Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCPlayer player = environment.getEnv(CommandHelperEnvironment.class).GetPlayer(); MCWorld world = null; if(player != null) { @@ -597,7 +598,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, com.laytonsmith.core.environments.Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, com.laytonsmith.core.environments.Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCPlayer player = environment.getEnv(CommandHelperEnvironment.class).GetPlayer(); MCWorld world = null; if(player != null) { @@ -669,7 +670,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, com.laytonsmith.core.environments.Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, com.laytonsmith.core.environments.Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCCommandSender sender = environment.getEnv(CommandHelperEnvironment.class).GetCommandSender(); MCWorld w = null; if(sender instanceof MCPlayer) { @@ -720,7 +721,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, com.laytonsmith.core.environments.Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, com.laytonsmith.core.environments.Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCCommandSender sender = environment.getEnv(CommandHelperEnvironment.class).GetCommandSender(); MCWorld w = null; if(sender instanceof MCPlayer) { @@ -789,7 +790,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, com.laytonsmith.core.environments.Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, com.laytonsmith.core.environments.Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCCommandSender sender = environment.getEnv(CommandHelperEnvironment.class).GetCommandSender(); MCWorld w = null; if(sender instanceof MCPlayer) { @@ -859,7 +860,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, com.laytonsmith.core.environments.Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, com.laytonsmith.core.environments.Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCCommandSender sender = environment.getEnv(CommandHelperEnvironment.class).GetCommandSender(); MCWorld w = null; if(sender instanceof MCPlayer) { @@ -915,7 +916,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, com.laytonsmith.core.environments.Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, com.laytonsmith.core.environments.Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCCommandSender sender = environment.getEnv(CommandHelperEnvironment.class).GetCommandSender(); MCWorld w = null; if(sender instanceof MCPlayer) { @@ -977,7 +978,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, com.laytonsmith.core.environments.Environment environment, Mixed... args) + public Mixed exec(Target t, com.laytonsmith.core.environments.Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCPlayer p = environment.getEnv(CommandHelperEnvironment.class).GetPlayer(); MCLocation loc = ObjectGenerator.GetGenerator().location(args[0], p != null ? p.getWorld() : null, t); @@ -1059,7 +1060,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, com.laytonsmith.core.environments.Environment environment, Mixed... args) + public Mixed exec(Target t, com.laytonsmith.core.environments.Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCPlayer p = environment.getEnv(CommandHelperEnvironment.class).GetPlayer(); MCLocation loc = ObjectGenerator.GetGenerator().location(args[0], p != null ? p.getWorld() : null, t); @@ -1131,7 +1132,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, com.laytonsmith.core.environments.Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, com.laytonsmith.core.environments.Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCPlayer p = environment.getEnv(CommandHelperEnvironment.class).GetPlayer(); MCWorld w = (p != null ? p.getWorld() : null); MCBlock b = ObjectGenerator.GetGenerator().location(args[0], w, t).getBlock(); @@ -1185,7 +1186,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, com.laytonsmith.core.environments.Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, com.laytonsmith.core.environments.Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { int x; int z; MCCommandSender sender = environment.getEnv(CommandHelperEnvironment.class).GetCommandSender(); @@ -1288,7 +1289,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, com.laytonsmith.core.environments.Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, com.laytonsmith.core.environments.Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCCommandSender sender = environment.getEnv(CommandHelperEnvironment.class).GetCommandSender(); MCWorld w = null; if(sender instanceof MCPlayer) { @@ -1345,7 +1346,7 @@ public MSVersion since() { } @Override - public Mixed exec(Target t, com.laytonsmith.core.environments.Environment env, Mixed... args) throws CancelCommandException, ConfigRuntimeException { + public Mixed exec(Target t, com.laytonsmith.core.environments.Environment env, GenericParameters generics, Mixed... args) throws CancelCommandException, ConfigRuntimeException { int x = 0; int z = 0; MCWorld w = null; @@ -1431,7 +1432,7 @@ public MSVersion since() { } @Override - public Mixed exec(Target t, com.laytonsmith.core.environments.Environment env, Mixed... args) throws CancelCommandException, ConfigRuntimeException { + public Mixed exec(Target t, com.laytonsmith.core.environments.Environment env, GenericParameters generics, Mixed... args) throws CancelCommandException, ConfigRuntimeException { MCLocation loc; float size = 3; boolean safe = false; @@ -1498,7 +1499,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, com.laytonsmith.core.environments.Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, com.laytonsmith.core.environments.Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCPlayer p = environment.getEnv(CommandHelperEnvironment.class).GetPlayer(); MCInstrument i = null; MCNote n = null; @@ -1671,7 +1672,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, com.laytonsmith.core.environments.Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, com.laytonsmith.core.environments.Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCLocation l = ObjectGenerator.GetGenerator().location(args[0], null, t); MCParticle p; int count = 0; @@ -1805,7 +1806,7 @@ public Boolean runAsync() { @Override public Mixed exec(Target t, com.laytonsmith.core.environments.Environment environment, - Mixed... args) throws ConfigRuntimeException { + GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCLocation loc = null; MCEntity ent = null; @@ -1976,7 +1977,7 @@ public Boolean runAsync() { @Override public Mixed exec(Target t, com.laytonsmith.core.environments.Environment environment, - Mixed... args) throws ConfigRuntimeException { + GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCLocation loc = null; MCEntity ent = null; @@ -2109,7 +2110,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, com.laytonsmith.core.environments.Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, com.laytonsmith.core.environments.Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCPlayer p = environment.getEnv(CommandHelperEnvironment.class).GetPlayer(); MCLocation l = ObjectGenerator.GetGenerator().location(args[0], p == null ? null : p.getWorld(), t); MCBlock b = l.getBlock(); @@ -2208,7 +2209,7 @@ public Version since() { } @Override - public Mixed exec(Target t, com.laytonsmith.core.environments.Environment environment, Mixed... args) + public Mixed exec(Target t, com.laytonsmith.core.environments.Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCWorld w = null; MCPlayer pl = environment.getEnv(CommandHelperEnvironment.class).GetPlayer(); @@ -2261,7 +2262,7 @@ public Version since() { } @Override - public Mixed exec(Target t, com.laytonsmith.core.environments.Environment environment, Mixed... args) + public Mixed exec(Target t, com.laytonsmith.core.environments.Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCWorld w = null; MCPlayer pl = environment.getEnv(CommandHelperEnvironment.class).GetPlayer(); @@ -2314,7 +2315,7 @@ public Version since() { } @Override - public Mixed exec(Target t, com.laytonsmith.core.environments.Environment environment, Mixed... args) + public Mixed exec(Target t, com.laytonsmith.core.environments.Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCWorld w = null; MCPlayer pl = environment.getEnv(CommandHelperEnvironment.class).GetPlayer(); @@ -2369,7 +2370,7 @@ public Version since() { } @Override - public Mixed exec(Target t, com.laytonsmith.core.environments.Environment environment, Mixed... args) + public Mixed exec(Target t, com.laytonsmith.core.environments.Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCWorld w = null; MCPlayer pl = environment.getEnv(CommandHelperEnvironment.class).GetPlayer(); @@ -2457,7 +2458,7 @@ public Version since() { } @Override - public Mixed exec(Target t, com.laytonsmith.core.environments.Environment environment, Mixed... args) + public Mixed exec(Target t, com.laytonsmith.core.environments.Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCWorld w = null; MCPlayer pl = environment.getEnv(CommandHelperEnvironment.class).GetPlayer(); @@ -2511,7 +2512,7 @@ public Version since() { } @Override - public Mixed exec(Target t, com.laytonsmith.core.environments.Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, com.laytonsmith.core.environments.Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCTreeType treeType; if(args.length == 1) { treeType = MCTreeType.TREE; @@ -2569,7 +2570,7 @@ public Version since() { } @Override - public Mixed exec(Target t, com.laytonsmith.core.environments.Environment environment, Mixed... args) + public Mixed exec(Target t, com.laytonsmith.core.environments.Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCLocation loc = ObjectGenerator.GetGenerator().location(args[0], null, t); return CBoolean.get(loc.getBlock().getState().isLockable()); @@ -2619,7 +2620,7 @@ public Version since() { } @Override - public Mixed exec(Target t, com.laytonsmith.core.environments.Environment environment, Mixed... args) + public Mixed exec(Target t, com.laytonsmith.core.environments.Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCLocation loc = ObjectGenerator.GetGenerator().location(args[0], null, t); MCBlockState block = loc.getBlock().getState(); @@ -2673,7 +2674,7 @@ public Version since() { } @Override - public Mixed exec(Target t, com.laytonsmith.core.environments.Environment environment, Mixed... args) + public Mixed exec(Target t, com.laytonsmith.core.environments.Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCLocation loc = ObjectGenerator.GetGenerator().location(args[0], null, t); MCBlockState block = loc.getBlock().getState(); @@ -2728,7 +2729,7 @@ public Version since() { } @Override - public Mixed exec(Target t, com.laytonsmith.core.environments.Environment environment, Mixed... args) + public Mixed exec(Target t, com.laytonsmith.core.environments.Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCLocation loc = ObjectGenerator.GetGenerator().location(args[0], null, t); MCBlockState block = loc.getBlock().getState(); @@ -2779,7 +2780,7 @@ public Version since() { } @Override - public Mixed exec(Target t, com.laytonsmith.core.environments.Environment environment, Mixed... args) + public Mixed exec(Target t, com.laytonsmith.core.environments.Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCLocation loc = ObjectGenerator.GetGenerator().location(args[0], null, t); if(loc.getBlock().isCommandBlock()) { @@ -2831,7 +2832,7 @@ public Version since() { } @Override - public Mixed exec(Target t, com.laytonsmith.core.environments.Environment environment, Mixed... args) + public Mixed exec(Target t, com.laytonsmith.core.environments.Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { String cmd = null; if(args.length == 2 && !(args[1] instanceof CNull)) { @@ -2891,7 +2892,7 @@ public Version since() { } @Override - public Mixed exec(Target t, com.laytonsmith.core.environments.Environment environment, Mixed... args) + public Mixed exec(Target t, com.laytonsmith.core.environments.Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCLocation loc = ObjectGenerator.GetGenerator().location(args[0], null, t); if(loc.getBlock().isCommandBlock()) { @@ -2943,7 +2944,7 @@ public Version since() { } @Override - public Mixed exec(Target t, com.laytonsmith.core.environments.Environment environment, Mixed... args + public Mixed exec(Target t, com.laytonsmith.core.environments.Environment environment, GenericParameters generics, Mixed... args ) throws ConfigRuntimeException { String name = null; if(args.length == 2 && !(args[1] instanceof CNull)) { @@ -2983,7 +2984,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, com.laytonsmith.core.environments.Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, com.laytonsmith.core.environments.Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCLocation loc = ObjectGenerator.GetGenerator().location(args[0], null, t); MCBlock b = loc.getWorld().getBlockAt(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ()); if(b.getState() instanceof MCBanner banner) { @@ -3056,7 +3057,7 @@ public CClassType getReturnType(Target t, List argTypes, List[] thrown() { } @Override - public Mixed exec(Target t, com.laytonsmith.core.environments.Environment environment, Mixed... args) + public Mixed exec(Target t, com.laytonsmith.core.environments.Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCLocation loc = ObjectGenerator.GetGenerator().location(args[0], null, t); return CBoolean.get(loc.getBlock().applyBoneMeal()); @@ -3263,7 +3264,7 @@ public Version since() { } @Override - public Mixed exec(Target t, com.laytonsmith.core.environments.Environment environment, Mixed... args) + public Mixed exec(Target t, com.laytonsmith.core.environments.Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCLocation loc = ObjectGenerator.GetGenerator().location(args[0], null, t); MCBlockState bs = loc.getBlock().getState(); @@ -3322,7 +3323,7 @@ public Version since() { } @Override - public Mixed exec(Target t, com.laytonsmith.core.environments.Environment environment, Mixed... args) + public Mixed exec(Target t, com.laytonsmith.core.environments.Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCLocation loc = ObjectGenerator.GetGenerator().location(args[0], null, t); MCBlockState bs = loc.getBlock().getState(); @@ -3396,7 +3397,7 @@ public Version since() { } @Override - public Mixed exec(Target t, com.laytonsmith.core.environments.Environment environment, Mixed... args) + public Mixed exec(Target t, com.laytonsmith.core.environments.Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCLocation loc = ObjectGenerator.GetGenerator().location(args[0], null, t); MCBlockState bs = loc.getBlock().getState(); @@ -3464,7 +3465,7 @@ public Version since() { } @Override - public Mixed exec(Target t, com.laytonsmith.core.environments.Environment environment, Mixed... args) + public Mixed exec(Target t, com.laytonsmith.core.environments.Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCLocation loc = ObjectGenerator.GetGenerator().location(args[0], null, t); MCBlockState bs = loc.getBlock().getState(); diff --git a/src/main/java/com/laytonsmith/core/functions/EventBinding.java b/src/main/java/com/laytonsmith/core/functions/EventBinding.java index afe27912ec..b67a8a131d 100644 --- a/src/main/java/com/laytonsmith/core/functions/EventBinding.java +++ b/src/main/java/com/laytonsmith/core/functions/EventBinding.java @@ -34,6 +34,7 @@ import com.laytonsmith.core.constructs.IVariable; import com.laytonsmith.core.constructs.IVariableList; import com.laytonsmith.core.constructs.Target; +import com.laytonsmith.core.constructs.generics.GenericParameters; import com.laytonsmith.core.environments.Environment; import com.laytonsmith.core.environments.GlobalEnv; import com.laytonsmith.core.environments.StaticRuntimeEnv; @@ -127,7 +128,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment env, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { return CVoid.VOID; } @@ -507,7 +508,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment env, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { return EventUtils.DumpEvents(); } } @@ -552,7 +553,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { String id; BoundEvent be; if(args.length == 1) { @@ -627,7 +628,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { boolean cancelled = true; if(args.length == 1) { cancelled = ArgumentValidation.getBoolean(args[0], t); @@ -684,7 +685,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { BoundEvent.ActiveEvent original = environment.getEnv(GlobalEnv.class).GetEvent(); if(original == null) { throw new CREBindException("is_cancelled cannot be called outside an event handler", t); @@ -747,7 +748,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { CArray obj = null; if(args[1] instanceof CNull) { obj = new CArray(t); @@ -816,7 +817,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { String parameter = args[0].val(); Mixed value = args[1]; boolean throwOnFailure = false; @@ -884,7 +885,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { if(environment.getEnv(GlobalEnv.class).GetEvent() == null) { throw new CREBindException("lock must be called from within an event handler", t); } @@ -955,7 +956,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { if(environment.getEnv(GlobalEnv.class).GetEvent() == null) { throw new CREBindException("is_locked may only be called from inside an event handler", t); } @@ -1004,7 +1005,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { if(environment.getEnv(GlobalEnv.class).GetEvent() == null) { throw new CREBindException("consume may only be called from an event handler!", t); } @@ -1055,7 +1056,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { if(environment.getEnv(GlobalEnv.class).GetEvent() == null) { throw new CREBindException("is_consumed must be called from within an event handler", t); } @@ -1109,7 +1110,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { if(environment.getEnv(GlobalEnv.class).GetEvent() == null) { throw new CREBindException("event_meta must be called from within an event handler!", t); } @@ -1145,7 +1146,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { return CBoolean.get(EventUtils.GetEventById(args[0].val()) != null); } diff --git a/src/main/java/com/laytonsmith/core/functions/Exceptions.java b/src/main/java/com/laytonsmith/core/functions/Exceptions.java index 916aab22e9..da978c7133 100644 --- a/src/main/java/com/laytonsmith/core/functions/Exceptions.java +++ b/src/main/java/com/laytonsmith/core/functions/Exceptions.java @@ -39,6 +39,7 @@ import com.laytonsmith.core.constructs.IVariableList; import com.laytonsmith.core.constructs.NativeTypeList; import com.laytonsmith.core.constructs.Target; +import com.laytonsmith.core.constructs.generics.GenericParameters; import com.laytonsmith.core.environments.Environment; import com.laytonsmith.core.environments.GlobalEnv; import com.laytonsmith.core.environments.StaticRuntimeEnv; @@ -205,7 +206,7 @@ public Mixed execs(Target t, Environment env, Script that, ParseTree... nodes) { } @Override - public Mixed exec(Target t, Environment env, Mixed... args) throws CancelCommandException, ConfigRuntimeException { + public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws CancelCommandException, ConfigRuntimeException { return CVoid.VOID; } @@ -339,7 +340,7 @@ public Boolean runAsync() { // return true; // } @Override - public Mixed exec(Target t, Environment env, Mixed... args) throws CancelCommandException, ConfigRuntimeException { + public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws CancelCommandException, ConfigRuntimeException { if(args.length == 1) { try { // Exception type @@ -397,7 +398,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { if(args[0].isInstanceOf(CClosure.TYPE)) { CClosure old = environment.getEnv(StaticRuntimeEnv.class).getExceptionHandler(); environment.getEnv(StaticRuntimeEnv.class).setExceptionHandler((CClosure) args[0]); @@ -495,7 +496,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { return CVoid.VOID; } @@ -728,7 +729,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { StackTraceManager stManager = environment.getEnv(GlobalEnv.class).GetStackTraceManager(); List elements = stManager.getCurrentStackTrace(); CArray ret = new CArray(t); diff --git a/src/main/java/com/laytonsmith/core/functions/ExecutionQueue.java b/src/main/java/com/laytonsmith/core/functions/ExecutionQueue.java index df365ec803..a49728cdc5 100644 --- a/src/main/java/com/laytonsmith/core/functions/ExecutionQueue.java +++ b/src/main/java/com/laytonsmith/core/functions/ExecutionQueue.java @@ -9,6 +9,7 @@ import com.laytonsmith.core.constructs.CVoid; import com.laytonsmith.core.constructs.Construct; import com.laytonsmith.core.constructs.Target; +import com.laytonsmith.core.constructs.generics.GenericParameters; import com.laytonsmith.core.environments.Environment; import com.laytonsmith.core.environments.GlobalEnv; import com.laytonsmith.core.environments.StaticRuntimeEnv; @@ -56,7 +57,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, final Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, final Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { final CClosure c; String queue = null; if(!(args[0].isInstanceOf(CClosure.TYPE))) { @@ -139,7 +140,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, final Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, final Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { final CClosure c; String queue = null; if(!(args[0].isInstanceOf(CClosure.TYPE))) { @@ -222,7 +223,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { String queue = null; if(args.length == 1) { queue = Construct.nval(args[0]); @@ -272,7 +273,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { String queue = null; if(args.length == 1) { queue = Construct.nval(args[0]); @@ -323,7 +324,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { String queue = null; if(args.length == 1) { queue = Construct.nval(args[0]); @@ -374,7 +375,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { String queue = null; if(args.length == 1) { queue = Construct.nval(args[0]); @@ -423,7 +424,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { String queue = null; if(args.length == 2) { queue = Construct.nval(args[1]); @@ -489,7 +490,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { String queue = null; if(args.length == 2) { queue = Construct.nval(args[1]); diff --git a/src/main/java/com/laytonsmith/core/functions/ExtensionMeta.java b/src/main/java/com/laytonsmith/core/functions/ExtensionMeta.java index 633ec52668..534c2fc178 100644 --- a/src/main/java/com/laytonsmith/core/functions/ExtensionMeta.java +++ b/src/main/java/com/laytonsmith/core/functions/ExtensionMeta.java @@ -12,6 +12,7 @@ import com.laytonsmith.core.constructs.CBoolean; import com.laytonsmith.core.constructs.CString; import com.laytonsmith.core.constructs.Target; +import com.laytonsmith.core.constructs.generics.GenericParameters; import com.laytonsmith.core.environments.Environment; import com.laytonsmith.core.events.Event; import com.laytonsmith.core.events.EventList; @@ -57,7 +58,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { try { FunctionList.getFunction(args[0].val().toLowerCase(), environment.getEnvClasses(), t); } catch (ConfigCompileException ex) { @@ -159,7 +160,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { return CBoolean.get(EventList.getEvent(args[0].val().toLowerCase()) != null); } @@ -204,7 +205,7 @@ public ParseTree optimizeDynamic(Target t, Environment env, throw new ConfigCompileException(getName() + " can only accept hardcoded string values", t); } - return new ParseTree(this.exec(t, null, children.get(0).getData()), children.get(0).getFileOptions()); + return new ParseTree(this.exec(t, null, null, children.get(0).getData()), children.get(0).getFileOptions()); } } @@ -228,7 +229,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { Map trackers = ExtensionManager.getTrackers(); for(ExtensionTracker tracker : trackers.values()) { String identifier = tracker.getIdentifier(); @@ -276,7 +277,7 @@ public ParseTree optimizeDynamic(Target t, Environment env, } else if(!(children.get(0).getData().isInstanceOf(CString.TYPE))) { throw new ConfigCompileException(getName() + " can only accept hardcoded string values", t); } else { - return new ParseTree(this.exec(t, null, children.get(0).getData()), children.get(0).getFileOptions()); + return new ParseTree(this.exec(t, null, null, children.get(0).getData()), children.get(0).getFileOptions()); } } } @@ -300,7 +301,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { Map trackers = ExtensionManager.getTrackers(); CArray retn = CArray.GetAssociativeArray(t); diff --git a/src/main/java/com/laytonsmith/core/functions/FileHandling.java b/src/main/java/com/laytonsmith/core/functions/FileHandling.java index 965f2a4cc2..62496247fc 100644 --- a/src/main/java/com/laytonsmith/core/functions/FileHandling.java +++ b/src/main/java/com/laytonsmith/core/functions/FileHandling.java @@ -28,6 +28,7 @@ import com.laytonsmith.core.constructs.CString; import com.laytonsmith.core.constructs.CVoid; import com.laytonsmith.core.constructs.Target; +import com.laytonsmith.core.constructs.generics.GenericParameters; import com.laytonsmith.core.environments.Environment; import com.laytonsmith.core.environments.StaticRuntimeEnv; import com.laytonsmith.core.exceptions.CRE.CRECastException; @@ -80,7 +81,7 @@ public Integer[] numArgs() { } @Override - public Mixed exec(Target t, Environment env, Mixed... args) throws CancelCommandException, ConfigRuntimeException { + public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws CancelCommandException, ConfigRuntimeException { File location = Static.GetFileFromArgument(args[0].val(), env, t, null); String charset = "UTF-8"; if(args.length > 1) { @@ -160,7 +161,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { return CNull.NULL; } @@ -204,9 +205,9 @@ public ParseTree optimizeDynamic(Target t, Environment env, String ret; if(children.size() == 1) { - ret = new read().exec(t, env, children.get(0).getData()).val(); + ret = new read().exec(t, env, null, children.get(0).getData()).val(); } else { - ret = new read().exec(t, env, children.get(0).getData(), + ret = new read().exec(t, env, null, children.get(0).getData(), children.get(1).getData()).val(); } ParseTree tree = new ParseTree(new CString(ret, t), fileOptions); @@ -262,7 +263,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(final Target t, final Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(final Target t, final Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { startup(); final String file = args[0].val(); final CClosure callback; @@ -389,7 +390,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { File location = Static.GetFileFromArgument(args[0].val(), environment, t, null); try { if(!Static.InCmdLine(environment, true) && !Security.CheckSecurity(location)) { @@ -442,7 +443,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment env, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { File location = Static.GetFileFromArgument(args[0].val(), env, t, null); try { if(!Static.InCmdLine(env, true)) { @@ -507,7 +508,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment env, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { File location = Static.GetFileFromArgument(args[0].val(), env, t, null); try { //Verify this file is not above the craftbukkit directory (or whatever directory the user specified @@ -570,7 +571,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { //TODO: Doesn't work yet. //TODO: Be sure to change over to Static.GetFileFromArgument String path = args[0].val().trim().replace('\\', '/'); @@ -634,7 +635,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { File f = Static.GetFileFromArgument(args[0].val(), environment, t, null); try { return new CString(f.getCanonicalPath(), t); diff --git a/src/main/java/com/laytonsmith/core/functions/Function.java b/src/main/java/com/laytonsmith/core/functions/Function.java index 3fe5b7d4ff..858c0ed89d 100644 --- a/src/main/java/com/laytonsmith/core/functions/Function.java +++ b/src/main/java/com/laytonsmith/core/functions/Function.java @@ -1,5 +1,6 @@ package com.laytonsmith.core.functions; +import com.laytonsmith.PureUtilities.Common.ReflectionUtils; import com.laytonsmith.core.Documentation; import com.laytonsmith.core.LogLevel; import com.laytonsmith.core.ParseTree; @@ -11,14 +12,17 @@ import com.laytonsmith.core.compiler.signature.SignatureBuilder; import com.laytonsmith.core.constructs.CClassType; import com.laytonsmith.core.constructs.Target; +import com.laytonsmith.core.constructs.generics.GenericParameters; import com.laytonsmith.core.environments.Environment; import com.laytonsmith.core.exceptions.CRE.CREThrowable; import com.laytonsmith.core.exceptions.CancelCommandException; import com.laytonsmith.core.exceptions.ConfigCompileException; import com.laytonsmith.core.exceptions.ConfigRuntimeException; import com.laytonsmith.core.natives.interfaces.Mixed; +import java.util.Collections; import java.util.List; import java.util.Set; +import java.util.concurrent.ConcurrentHashMap; /** * Note that to "activate" this class as a function, you must prefix the '@api' annotation to it. @@ -68,18 +72,19 @@ public interface Function extends FunctionBase, Documentation, Comparable getBranches(ParseTree self); } + + // TODO: The reflection bridge below is a backward-compatibility shim for + // 3rd-party functions that still implement the old 3-arg + // exec(Target, Environment, Mixed...) signature. Once all known extensions + // have been updated, the cache and reflection fallback can be removed, and + // callers can invoke exec directly. + + /** + * Cache of Function classes that only implement the old 3-arg exec signature. + */ + Set> OLD_EXEC_CACHE = Collections.newSetFromMap(new ConcurrentHashMap<>()); + + /** + * Invokes {@link #exec} on the given function with backward compatibility for 3rd-party functions + * that still implement the old 3-arg exec(Target, Environment, Mixed...) signature. + * For functions with the new signature, this has zero overhead beyond a Set lookup on cached misses. + * + * @param f The function to execute. + * @param t The code target. + * @param env The environment. + * @param args The arguments. + * @return The result of the function execution. + * @throws ConfigRuntimeException + */ + static Mixed ExecuteFunction(Function f, Target t, Environment env, Mixed[] args) throws ConfigRuntimeException { + if(OLD_EXEC_CACHE.contains(f.getClass())) { + return ReflectionUtils.invokeMethod(f.getClass(), f, "exec", + new Class[]{Target.class, Environment.class, Mixed[].class}, + new Object[]{t, env, args}); + } + try { + return f.exec(t, env, null, args); + } catch(AbstractMethodError e) { + OLD_EXEC_CACHE.add(f.getClass()); + return ReflectionUtils.invokeMethod(f.getClass(), f, "exec", + new Class[]{Target.class, Environment.class, Mixed[].class}, + new Object[]{t, env, args}); + } + } } diff --git a/src/main/java/com/laytonsmith/core/functions/InventoryManagement.java b/src/main/java/com/laytonsmith/core/functions/InventoryManagement.java index 69480e403b..d1b6bb7e16 100644 --- a/src/main/java/com/laytonsmith/core/functions/InventoryManagement.java +++ b/src/main/java/com/laytonsmith/core/functions/InventoryManagement.java @@ -38,6 +38,7 @@ import com.laytonsmith.core.constructs.CVoid; import com.laytonsmith.core.constructs.Construct; import com.laytonsmith.core.constructs.Target; +import com.laytonsmith.core.constructs.generics.GenericParameters; import com.laytonsmith.core.environments.CommandHelperEnvironment; import com.laytonsmith.core.environments.Environment; import com.laytonsmith.core.exceptions.CRE.CREBadEntityException; @@ -122,7 +123,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment env, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { Integer index = -1; boolean all; MCPlayer m; @@ -217,7 +218,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCPlayer p; if(args.length == 1) { @@ -273,7 +274,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCPlayer p; if(args.length == 1) { @@ -332,7 +333,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCPlayer player; MCPlayer other; @@ -396,7 +397,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCPlayer p; if(args.length == 1) { @@ -490,7 +491,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment env, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCPlayer m; Mixed arg; if(args.length == 3) { @@ -594,7 +595,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment env, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCPlayer p; if(args.length == 0) { p = env.getEnv(CommandHelperEnvironment.class).GetPlayer(); @@ -651,7 +652,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCPlayer p; MCItemStack is; Mixed c; @@ -773,7 +774,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCPlayer p; Mixed item; CArray ca = null; @@ -907,7 +908,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCPlayer p; MCItemStack is; int itemOffset = 0; @@ -1022,7 +1023,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCPlayer p; MCItemStack is; int itemOffset = 0; @@ -1167,7 +1168,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCPlayer p; MCItemStack is; int itemOffset = 0; @@ -1279,7 +1280,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCPlayer p; MCItemStack is; int itemOffset = 0; @@ -1431,7 +1432,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment env, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCCommandSender p = env.getEnv(CommandHelperEnvironment.class).GetCommandSender(); MCPlayer m = null; @@ -1532,7 +1533,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment env, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCCommandSender p = env.getEnv(CommandHelperEnvironment.class).GetCommandSender(); Integer index = -1; @@ -1609,7 +1610,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCWorld w = null; MCPlayer p = environment.getEnv(CommandHelperEnvironment.class).GetPlayer(); if(p != null) { @@ -1664,7 +1665,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCWorld w = null; MCPlayer p = environment.getEnv(CommandHelperEnvironment.class).GetPlayer(); if(p != null) { @@ -1728,7 +1729,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCWorld w = null; MCPlayer p = environment.getEnv(CommandHelperEnvironment.class).GetPlayer(); if(p != null) { @@ -1790,7 +1791,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCWorld w = null; MCPlayer p = environment.getEnv(CommandHelperEnvironment.class).GetPlayer(); if(p != null) { @@ -1848,7 +1849,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCWorld w = null; if(environment.getEnv(CommandHelperEnvironment.class).GetPlayer() != null) { w = environment.getEnv(CommandHelperEnvironment.class).GetPlayer().getWorld(); @@ -1900,7 +1901,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCWorld w = null; MCPlayer p = environment.getEnv(CommandHelperEnvironment.class).GetPlayer(); if(p != null) { @@ -1957,7 +1958,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCPlayer p1 = environment.getEnv(CommandHelperEnvironment.class).GetPlayer(); MCPlayer p2; if(args.length == 2) { @@ -2040,7 +2041,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment env, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCInventory inventory = InventoryManagement.GetInventory(args[0], null, t); @@ -2120,7 +2121,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment env, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCInventory inventory = InventoryManagement.GetInventory(args[0], null, t); Integer size = inventory.getSize(); @@ -2211,7 +2212,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCInventory inventory = InventoryManagement.GetInventory(args[0], null, t); MCItemStack is; if(args.length == 2) { @@ -2299,7 +2300,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCInventory inventory = InventoryManagement.GetInventory(args[0], null, t); Integer size = inventory.getSize(); CArray ca = null; @@ -2411,7 +2412,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCPlayer player; switch(args.length) { case 1: { @@ -2493,7 +2494,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCPlayer player; switch(args.length) { case 0: { @@ -2549,7 +2550,7 @@ public Integer[] numArgs() { } @Override - public Mixed exec(Target t, Environment env, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCPlayer p; MCInventory inv; if(args.length == 2) { @@ -2609,7 +2610,7 @@ public String docs() { } @Override - public Mixed exec(Target t, Environment env, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCPlayer p; if(args.length == 1) { p = Static.GetPlayer(args[0], t); @@ -2667,7 +2668,7 @@ public String docs() { } @Override - public Mixed exec(Target t, Environment env, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCInventory inv = GetInventory(args[0], null, t); CArray list = new CArray(t); for(MCHumanEntity viewer : inv.getViewers()) { @@ -2717,7 +2718,7 @@ public String docs() { } @Override - public Mixed exec(Target t, Environment env, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { CArray list = new CArray(t); for(String id : VIRTUAL_INVENTORIES.keySet()) { list.push(new CString(id, t), t); @@ -2780,7 +2781,7 @@ public String docs() { } @Override - public Mixed exec(Target t, Environment env, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { String id = args[0].val(); if(VIRTUAL_INVENTORIES.get(id) != null) { throw new CREIllegalArgumentException("An inventory using the id \"" + id + "\" already exists.", t); @@ -2891,7 +2892,7 @@ public String docs() { } @Override - public Mixed exec(Target t, Environment env, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { String id = args[0].val(); MCInventory inv = VIRTUAL_INVENTORIES.get(id); if(inv != null) { diff --git a/src/main/java/com/laytonsmith/core/functions/ItemMeta.java b/src/main/java/com/laytonsmith/core/functions/ItemMeta.java index ede6f1c841..0af569a673 100644 --- a/src/main/java/com/laytonsmith/core/functions/ItemMeta.java +++ b/src/main/java/com/laytonsmith/core/functions/ItemMeta.java @@ -35,6 +35,7 @@ import com.laytonsmith.core.constructs.CNull; import com.laytonsmith.core.constructs.CVoid; import com.laytonsmith.core.constructs.Target; +import com.laytonsmith.core.constructs.generics.GenericParameters; import com.laytonsmith.core.environments.CommandHelperEnvironment; import com.laytonsmith.core.environments.Environment; import com.laytonsmith.core.exceptions.CRE.CRECastException; @@ -78,7 +79,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCPlayer p; MCItemStack is; Mixed slot; @@ -182,7 +183,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCPlayer p; Mixed slot; Mixed meta; @@ -290,7 +291,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCPlayer p = environment.getEnv(CommandHelperEnvironment.class).GetPlayer(); int slot; if(args.length == 2) { @@ -355,7 +356,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCPlayer p = environment.getEnv(CommandHelperEnvironment.class).GetPlayer(); int slot; CArray color; @@ -434,7 +435,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCPlayer p; Mixed slot; if(args.length == 2) { diff --git a/src/main/java/com/laytonsmith/core/functions/Marquee.java b/src/main/java/com/laytonsmith/core/functions/Marquee.java index 423785a599..f3397b5cfd 100644 --- a/src/main/java/com/laytonsmith/core/functions/Marquee.java +++ b/src/main/java/com/laytonsmith/core/functions/Marquee.java @@ -8,6 +8,7 @@ import com.laytonsmith.core.constructs.CString; import com.laytonsmith.core.constructs.CVoid; import com.laytonsmith.core.constructs.Target; +import com.laytonsmith.core.constructs.generics.GenericParameters; import com.laytonsmith.core.environments.Environment; import com.laytonsmith.core.exceptions.CRE.CRECastException; import com.laytonsmith.core.exceptions.CRE.CREThrowable; @@ -52,7 +53,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(final Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(final Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { final String marqueeName; final String text; final int stringWidth; @@ -158,7 +159,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { String marqueeName = args[0].val(); if(MARQUEE_MAP.containsKey(marqueeName)) { MARQUEE_MAP.get(marqueeName).stop(); diff --git a/src/main/java/com/laytonsmith/core/functions/Math.java b/src/main/java/com/laytonsmith/core/functions/Math.java index d3868ed4ab..54a2f17d45 100644 --- a/src/main/java/com/laytonsmith/core/functions/Math.java +++ b/src/main/java/com/laytonsmith/core/functions/Math.java @@ -21,6 +21,7 @@ import com.laytonsmith.core.constructs.CArray; import com.laytonsmith.core.constructs.CClassType; import com.laytonsmith.core.constructs.CDouble; +import com.laytonsmith.core.constructs.generics.GenericParameters; import com.laytonsmith.core.constructs.CFunction; import com.laytonsmith.core.constructs.CInt; import com.laytonsmith.core.constructs.CMutablePrimitive; @@ -77,7 +78,7 @@ public Integer[] numArgs() { } @Override - public Mixed exec(Target t, Environment env, Mixed... args) throws CancelCommandException, ConfigRuntimeException { + public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws CancelCommandException, ConfigRuntimeException { if(ArgumentValidation.anyDoubles(args)) { double tally = ArgumentValidation.getNumber(args[0], t); for(int i = 1; i < args.length; i++) { @@ -165,7 +166,7 @@ public Integer[] numArgs() { } @Override - public Mixed exec(Target t, Environment env, Mixed... args) throws CancelCommandException, ConfigRuntimeException { + public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws CancelCommandException, ConfigRuntimeException { if(ArgumentValidation.anyDoubles(args)) { double tally = ArgumentValidation.getNumber(args[0], t); for(int i = 1; i < args.length; i++) { @@ -241,7 +242,7 @@ public Integer[] numArgs() { } @Override - public Mixed exec(Target t, Environment env, Mixed... args) throws CancelCommandException, ConfigRuntimeException { + public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws CancelCommandException, ConfigRuntimeException { if(ArgumentValidation.anyDoubles(args)) { double tally = ArgumentValidation.getNumber(args[0], t); for(int i = 1; i < args.length; i++) { @@ -327,7 +328,7 @@ public Integer[] numArgs() { } @Override - public Mixed exec(Target t, Environment env, Mixed... args) throws CancelCommandException, ConfigRuntimeException { + public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws CancelCommandException, ConfigRuntimeException { double tally = ArgumentValidation.getNumber(args[0], t); for(int i = 1; i < args.length; i++) { double next = ArgumentValidation.getNumber(args[i], t); @@ -403,7 +404,7 @@ public Integer[] numArgs() { } @Override - public Mixed exec(Target t, Environment env, Mixed... args) throws CancelCommandException, ConfigRuntimeException { + public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws CancelCommandException, ConfigRuntimeException { long arg1 = ArgumentValidation.getInt(args[0], t); long arg2 = ArgumentValidation.getInt(args[1], t); if(arg2 == 0) { @@ -468,7 +469,7 @@ public Integer[] numArgs() { } @Override - public Mixed exec(Target t, Environment env, Mixed... args) throws CancelCommandException, ConfigRuntimeException { + public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws CancelCommandException, ConfigRuntimeException { double arg1 = ArgumentValidation.getNumber(args[0], t); double arg2 = ArgumentValidation.getNumber(args[1], t); return new CDouble(java.lang.Math.pow(arg1, arg2), t); @@ -521,7 +522,7 @@ public Set optimizationOptions() { * * @return */ - protected static Mixed doIncrementDecrement(ParseTree[] nodes, + private static Mixed doIncrementDecrement(ParseTree[] nodes, Script parent, Environment env, Target t, Function func, boolean pre, boolean inc) { if(nodes[0].getData() instanceof CFunction && ((CFunction) nodes[0].getData()).hasFunction()) { @@ -548,7 +549,7 @@ protected static Mixed doIncrementDecrement(ParseTree[] nodes, if(!(array.isInstanceOf(CArray.TYPE)) && !(array.isInstanceOf(ArrayAccess.TYPE))) { //Let's just evaluate this like normal with array_get, so it will //throw the appropriate exception. - new ArrayHandling.array_get().exec(t, env, array, index); + new ArrayHandling.array_get().exec(t, env, null, array, index); throw ConfigRuntimeException.CreateUncatchableException("Shouldn't have gotten here. Please report this error, and how you got here.", t); } else if(!(array.isInstanceOf(CArray.TYPE))) { //It's an ArrayAccess type, but we can't use that here, so, throw our @@ -568,7 +569,7 @@ protected static Mixed doIncrementDecrement(ParseTree[] nodes, } else { newVal = new CInt(ArgumentValidation.getInt(value, t) - delta, t); } - new ArrayHandling.array_set().exec(t, env, array, index, newVal); + new ArrayHandling.array_set().exec(t, env, null, array, index, newVal); if(pre) { return newVal; } else { @@ -581,7 +582,7 @@ protected static Mixed doIncrementDecrement(ParseTree[] nodes, } else { newVal = new CDouble(ArgumentValidation.getDouble(value, t) - delta, t); } - new ArrayHandling.array_set().exec(t, env, array, index, newVal); + new ArrayHandling.array_set().exec(t, env, null, array, index, newVal); if(pre) { return newVal; } else { @@ -596,7 +597,7 @@ protected static Mixed doIncrementDecrement(ParseTree[] nodes, for(int i = 0; i < args.length; i++) { args[i] = parent.eval(nodes[i], env); } - return func.exec(t, env, args); + return func.exec(t, env, null, args); } @api @@ -627,7 +628,7 @@ public Mixed execs(Target t, Environment env, Script parent, ParseTree... nodes) } @Override - public Mixed exec(Target t, Environment env, Mixed... args) throws CancelCommandException, ConfigRuntimeException { + public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws CancelCommandException, ConfigRuntimeException { long value = 1; if(args.length == 2) { if(args[1] instanceof IVariable) { @@ -707,7 +708,7 @@ public Mixed optimize(Target t, Environment env, Mixed... args) throws ConfigCom if(args[0] instanceof IVariable) { return null; } else { - return exec(t, null, args); + return exec(t, null, null, args); } } @@ -747,7 +748,7 @@ public Mixed execs(Target t, Environment env, Script parent, ParseTree... nodes) } @Override - public Mixed exec(Target t, Environment env, Mixed... args) throws CancelCommandException, ConfigRuntimeException { + public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws CancelCommandException, ConfigRuntimeException { long value = 1; if(args.length == 2) { if(args[1] instanceof IVariable) { @@ -822,7 +823,7 @@ public Mixed optimize(Target t, Environment env, Mixed... args) throws ConfigCom if(args[0] instanceof IVariable) { return null; } else { - return exec(t, null, args); + return exec(t, null, null, args); } } @@ -877,7 +878,7 @@ public Mixed execs(Target t, Environment env, Script parent, ParseTree... nodes) } @Override - public Mixed exec(Target t, Environment env, Mixed... args) throws CancelCommandException, ConfigRuntimeException { + public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws CancelCommandException, ConfigRuntimeException { long value = 1; if(args.length == 2) { if(args[1] instanceof IVariable) { @@ -946,7 +947,7 @@ public Mixed optimize(Target t, Environment env, Mixed... args) throws ConfigCom if(args[0] instanceof IVariable) { return null; } else { - return exec(t, null, args); + return exec(t, null, null, args); } } @@ -997,7 +998,7 @@ public Mixed execs(Target t, Environment env, Script parent, ParseTree... nodes) } @Override - public Mixed exec(Target t, Environment env, Mixed... args) throws CancelCommandException, ConfigRuntimeException { + public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws CancelCommandException, ConfigRuntimeException { long value = 1; if(args.length == 2) { if(args[1] instanceof IVariable) { @@ -1072,7 +1073,7 @@ public Mixed optimize(Target t, Environment env, Mixed... args) throws ConfigCom if(args[0] instanceof IVariable) { return null; } else { - return exec(t, null, args); + return exec(t, null, null, args); } } @@ -1136,7 +1137,7 @@ public MSVersion since() { } @Override - public Mixed exec(Target t, Environment env, Mixed... args) throws CancelCommandException, ConfigRuntimeException { + public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws CancelCommandException, ConfigRuntimeException { if(args.length == 0) { return new CDouble(java.lang.Math.random(), t); } else { @@ -1223,7 +1224,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment env, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { if(args[0].isInstanceOf(CInt.TYPE)) { return new CInt(java.lang.Math.abs(ArgumentValidation.getInt(args[0], t)), t); } else { @@ -1287,7 +1288,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment env, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { return new CInt((long) java.lang.Math.floor(ArgumentValidation.getNumber(args[0], t)), t); } @@ -1339,7 +1340,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment env, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { return new CInt((long) java.lang.Math.ceil(ArgumentValidation.getNumber(args[0], t)), t); } @@ -1392,7 +1393,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment env, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { double d = ArgumentValidation.getNumber(args[0], t); if(d < 0) { throw new CRERangeException("sqrt expects a number >= 0", t); @@ -1454,7 +1455,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment env, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { if(args.length == 0) { throw new CREInsufficientArgumentsException("You must send at least one parameter to min", t); } @@ -1536,7 +1537,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment env, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { if(args.length == 0) { throw new CREInsufficientArgumentsException("You must send at least one parameter to max", t); } @@ -1617,7 +1618,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment env, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { return new CDouble(java.lang.Math.sin(ArgumentValidation.getNumber(args[0], t)), t); } @@ -1669,7 +1670,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment env, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { return new CDouble(java.lang.Math.cos(ArgumentValidation.getNumber(args[0], t)), t); } @@ -1721,7 +1722,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment env, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { return new CDouble(java.lang.Math.tan(ArgumentValidation.getNumber(args[0], t)), t); } @@ -1773,7 +1774,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment env, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { return new CDouble(java.lang.Math.asin(ArgumentValidation.getNumber(args[0], t)), t); } @@ -1825,7 +1826,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment env, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { return new CDouble(java.lang.Math.acos(ArgumentValidation.getNumber(args[0], t)), t); } @@ -1877,7 +1878,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment env, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { return new CDouble(java.lang.Math.atan(ArgumentValidation.getNumber(args[0], t)), t); } @@ -1929,7 +1930,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment env, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { return Static.getNumber(java.lang.Math.sinh(ArgumentValidation.getNumber(args[0], t)), t); } @@ -1981,7 +1982,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment env, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { return Static.getNumber(java.lang.Math.cosh(ArgumentValidation.getNumber(args[0], t)), t); } @@ -2033,7 +2034,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment env, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { return Static.getNumber(java.lang.Math.tanh(ArgumentValidation.getNumber(args[0], t)), t); } @@ -2085,7 +2086,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment env, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { return new CDouble(java.lang.Math.toRadians(ArgumentValidation.getNumber(args[0], t)), t); } @@ -2137,7 +2138,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment env, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { return new CDouble(java.lang.Math.toDegrees(ArgumentValidation.getNumber(args[0], t)), t); } @@ -2193,7 +2194,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment env, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { return new CDouble(java.lang.Math.atan2(ArgumentValidation.getNumber(args[0], t), ArgumentValidation.getNumber(args[1], t)), t); } @@ -2246,7 +2247,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment env, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { double number = ArgumentValidation.getNumber(args[0], t); int precision = 0; if(args.length > 1) { @@ -2298,7 +2299,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { double x = ArgumentValidation.getDouble(args[0], t) + 1; DecimalFormat twoDForm = new DecimalFormat("0.##############E0"); String str = twoDForm.format(x); @@ -2396,7 +2397,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { String expr = args[0].val().trim(); if("".equals(expr)) { throw new CREFormatException("Expression may not be empty", t); @@ -2502,7 +2503,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { if(args[0].isInstanceOf(CInt.TYPE)) { return new CInt(-(ArgumentValidation.getInt(args[0], t)), t); } else { @@ -2543,7 +2544,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { double val = ArgumentValidation.getDouble(args[0], t); if(val <= 0) { throw new CRERangeException("val was <= 0", t); @@ -2688,7 +2689,7 @@ public Version since() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { try { MathConstants c = MathConstants.valueOf(args[0].val()); Number v = c.getValue(); diff --git a/src/main/java/com/laytonsmith/core/functions/MatrixHandling.java b/src/main/java/com/laytonsmith/core/functions/MatrixHandling.java index 9f2d217ad3..6ea7483d39 100644 --- a/src/main/java/com/laytonsmith/core/functions/MatrixHandling.java +++ b/src/main/java/com/laytonsmith/core/functions/MatrixHandling.java @@ -17,6 +17,7 @@ import com.laytonsmith.core.constructs.CString; import com.laytonsmith.core.constructs.CVoid; import com.laytonsmith.core.constructs.Target; +import com.laytonsmith.core.constructs.generics.GenericParameters; import com.laytonsmith.core.environments.Environment; import com.laytonsmith.core.exceptions.CRE.CRECastException; import com.laytonsmith.core.exceptions.CRE.CREIllegalArgumentException; @@ -96,7 +97,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment env, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { if(args.length == 1) { return CReal2dMatrix.FromConstruct(ArgumentValidation.getArray(args[0], t), t); } else { @@ -173,7 +174,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment env, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { CReal2dMatrix matrix = getMatrix(args[0], t, 1); int column = ArgumentValidation.getInt32(args[1], t); double[] data = matrix.getColumn(column); @@ -236,7 +237,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment env, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { CReal2dMatrix matrix = getMatrixOnly(args[0], t, 1); return matrix.deepClone(); } @@ -290,7 +291,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment env, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { CReal2dMatrix matrix = getMatrix(args[0], t, 1); double[] data = matrix.getData(); String format = "%.3f"; @@ -382,7 +383,7 @@ public Boolean runAsync() { } @Override - public CArray exec(Target t, Environment env, Mixed... args) throws ConfigRuntimeException { + public CArray exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { CReal2dMatrix m = MatrixHandling.getMatrixOnly(args[0], t, 1); return m.toArray(); } @@ -438,7 +439,7 @@ public Boolean runAsync() { } @Override - public CReal2dMatrix exec(Target t, Environment env, Mixed... args) throws ConfigRuntimeException { + public CReal2dMatrix exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { int dimension = ArgumentValidation.getInt32(args[0], t); double[] data = new double[dimension * dimension]; for(int i = 0; i < (dimension * dimension); i++) { @@ -498,7 +499,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment env, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { return MatrixHandling.getMatrix(args[0], t, 1).transpose(); } @@ -553,7 +554,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment env, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { CReal2dMatrix left = MatrixHandling.getMatrix(args[0], t, 1); CReal2dMatrix right = MatrixHandling.getMatrix(args[1], t, 2); left.add(right, t); @@ -618,7 +619,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment env, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { CReal2dMatrix left = MatrixHandling.getMatrix(args[0], t, 1); CReal2dMatrix right = MatrixHandling.getMatrix(args[1], t, 2); left.subtract(right, t); @@ -683,7 +684,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment env, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { CReal2dMatrix matrix = MatrixHandling.getMatrix(args[0], t, 1); double scalar = ArgumentValidation.getDouble(args[1], t); matrix.scalarMultiply(scalar); @@ -742,7 +743,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment env, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { CReal2dMatrix matrix = MatrixHandling.getMatrix(args[0], t, 1); int row = ArgumentValidation.getInt32(args[1], t); int column = ArgumentValidation.getInt32(args[2], t); @@ -806,7 +807,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment env, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { CReal2dMatrix left = MatrixHandling.getMatrix(args[0], t, 1); CReal2dMatrix right = MatrixHandling.getMatrix(args[1], t, 2); return left.multiply(right, t); @@ -872,7 +873,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment env, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { CReal2dMatrix left = MatrixHandling.getMatrix(args[0], t, 1); CReal2dMatrix right = MatrixHandling.getMatrix(args[1], t, 2); return CBoolean.get(left.canMultiply(right)); @@ -937,7 +938,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment env, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { CReal2dMatrix left = MatrixHandling.getMatrix(args[0], t, 1); CReal2dMatrix right = MatrixHandling.getMatrix(args[1], t, 2); return CBoolean.get(left.canAdd(right)); @@ -1002,7 +1003,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment env, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { CReal2dMatrix matrix = MatrixHandling.getMatrix(args[0], t, 1); return CBoolean.get(matrix.isSquare()); } @@ -1057,7 +1058,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment env, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { CReal2dMatrix left = MatrixHandling.getMatrix(args[0], t, 1); CReal2dMatrix right = MatrixHandling.getMatrix(args[1], t, 2); double tolerance = ArgumentValidation.getDouble(args[2], t); @@ -1126,7 +1127,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment env, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { CReal2dMatrix matrix = MatrixHandling.getMatrix(args[0], t, 1); return new CDouble(matrix.trace(t), t); } @@ -1182,7 +1183,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment env, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { CReal2dMatrix matrix = MatrixHandling.getMatrix(args[0], t, 1); return new CDouble(matrix.determinant(t), t); } @@ -1239,7 +1240,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment env, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { CReal2dMatrix matrix = MatrixHandling.getMatrix(args[0], t, 1); return new CDouble(matrix.norm(), t); } diff --git a/src/main/java/com/laytonsmith/core/functions/Meta.java b/src/main/java/com/laytonsmith/core/functions/Meta.java index 6f662587fe..a23dec1b3c 100644 --- a/src/main/java/com/laytonsmith/core/functions/Meta.java +++ b/src/main/java/com/laytonsmith/core/functions/Meta.java @@ -42,6 +42,7 @@ import com.laytonsmith.core.constructs.IVariable; import com.laytonsmith.core.constructs.Target; import com.laytonsmith.core.constructs.Variable; +import com.laytonsmith.core.constructs.generics.GenericParameters; import com.laytonsmith.core.environments.CommandHelperEnvironment; import com.laytonsmith.core.environments.Environment; import com.laytonsmith.core.environments.GlobalEnv; @@ -115,7 +116,7 @@ public Boolean runAsync() { return false; } - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { return CBoolean.get(CommandHelperPlugin.isFirstLoad()); } @@ -151,7 +152,7 @@ public Integer[] numArgs() { } @Override - public Mixed exec(Target t, final Environment env, Mixed... args) throws CancelCommandException, ConfigRuntimeException { + public Mixed exec(Target t, final Environment env, GenericParameters generics, Mixed... args) throws CancelCommandException, ConfigRuntimeException { if(args[1] instanceof CNull || args[1].val().isEmpty() || args[1].val().charAt(0) != '/') { throw new CREFormatException("The first character of the command must be a forward slash (i.e. '/give')", t); } @@ -159,7 +160,7 @@ public Mixed exec(Target t, final Environment env, Mixed... args) throws CancelC if(args[0].isInstanceOf(CArray.TYPE)) { CArray u = (CArray) args[0]; for(int i = 0; i < u.size(); i++) { - exec(t, env, new Mixed[]{new CString(u.get(i, t).val(), t), args[1]}); + exec(t, env, null, new Mixed[]{new CString(u.get(i, t).val(), t), args[1]}); } return CVoid.VOID; } @@ -258,7 +259,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment env, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { Mixed command; MCPlayer sender; if(args.length == 2) { @@ -271,7 +272,7 @@ public Mixed exec(Target t, Environment env, Mixed... args) throws ConfigRuntime //If the command sender is null, this is not a player, so just try to run() this. if(sender == null) { - return new run().exec(t, env, args); + return new run().exec(t, env, null, args); } if(command instanceof CNull || command.val().isEmpty() || command.val().charAt(0) != '/') { @@ -410,7 +411,7 @@ public Integer[] numArgs() { } @Override - public Mixed exec(Target t, Environment env, Mixed... args) throws CancelCommandException, ConfigRuntimeException { + public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws CancelCommandException, ConfigRuntimeException { if(args[0] instanceof CNull || args[0].val().isEmpty() || args[0].val().charAt(0) != '/') { throw new CREFormatException("The first character of the command must be a forward slash (i.e. '/give')", t); } @@ -497,7 +498,7 @@ public Integer[] numArgs() { } @Override - public Mixed exec(Target t, Environment env, Mixed... args) throws CancelCommandException, ConfigRuntimeException { + public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws CancelCommandException, ConfigRuntimeException { MCCommandSender sender; String commandString; List argList; @@ -600,7 +601,7 @@ public Boolean runAsync() { } @Override - public CBoolean exec(Target t, Environment environment, Mixed... args) + public CBoolean exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { AliasCore ac = Static.getAliasCore(); @@ -679,7 +680,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment env, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCCommandSender sender = env.getEnv(CommandHelperEnvironment.class).GetCommandSender(); if(sender == null) { throw new CREException("No command sender in this context.", t); @@ -759,7 +760,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) { return null; } @@ -849,7 +850,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { if(environment.getEnv(CommandHelperEnvironment.class).GetCommand() == null) { return CNull.NULL; } else { @@ -883,7 +884,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { String player = args[0].val(); String cmd = args[1].val(); if(cmd.isEmpty() || cmd.charAt(0) != '/') { @@ -963,7 +964,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCCommandSender sender = environment.getEnv(CommandHelperEnvironment.class).GetCommandSender(); MCLocation loc; CArray ret; @@ -1022,7 +1023,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCPlayer player; boolean state; if(args.length == 1) { @@ -1089,17 +1090,17 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { CString s; if(args[0].isInstanceOf(CString.TYPE)) { s = (CString) args[0]; } else { s = new CString(args[0].val(), t); } - if(is_alias.exec(t, environment, s).getBoolean()) { - call_alias.exec(t, environment, s); + if(is_alias.exec(t, environment, null, s).getBoolean()) { + call_alias.exec(t, environment, null, s); } else { - run.exec(t, environment, s); + run.exec(t, environment, null, s); } return CVoid.VOID; } @@ -1164,7 +1165,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { return CVoid.VOID; } @@ -1218,15 +1219,15 @@ public Boolean runAsync() { } @Override - public CArray exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public CArray exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { CArray c = new CArray(t); for(Locale l : Locale.getAvailableLocales()) { if(!l.getCountry().isEmpty()) { c.push(new CString(l.toString(), t), t); } } - new ArrayHandling.array_sort().exec(t, environment, c); - c = new ArrayHandling.array_unique().exec(t, environment, c); + new ArrayHandling.array_sort().exec(t, environment, null, c); + c = new ArrayHandling.array_unique().exec(t, environment, null, c); return c; } @@ -1280,12 +1281,12 @@ public Boolean runAsync() { } public static long GetEngineBuildDate() { - Mixed m = new engine_build_date().exec(Target.UNKNOWN, null); + Mixed m = new engine_build_date().exec(Target.UNKNOWN, null, null); return m instanceof CNull ? 0 : ((CInt) m).getInt(); } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { JarFile jf; try { String jar = ClassDiscovery.GetClassContainer(Meta.class).toString(); @@ -1341,7 +1342,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { return new CInt(environment.getEnv(GlobalEnv.class).GetScript().getCompileTime(), t); } @@ -1386,7 +1387,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { return new CResource<>(environment, t); } @@ -1433,7 +1434,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { CArray ret = new CArray(t); for(FileOptions.CompilerOption s : FileOptions.CompilerOption.values()) { ret.push(new CString(s.getName(), t), t); @@ -1482,7 +1483,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { CArray ret = new CArray(t); for(FileOptions.SuppressWarning s : FileOptions.SuppressWarning.values()) { ret.push(new CString(s.getName(), t), t); @@ -1533,7 +1534,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { String name = ArgumentValidation.getString(args[0], t); Mixed setting = args[1]; environment.getEnv(GlobalEnv.class).SetRuntimeSetting(name, setting); @@ -1586,7 +1587,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { String name = ArgumentValidation.getString(args[0], t); GlobalEnv env = environment.getEnv(GlobalEnv.class); if(env.GetRuntimeSetting(name) != null) { @@ -1645,7 +1646,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { String name = ArgumentValidation.getString(args[0], t); return CBoolean.get(environment.getEnv(GlobalEnv.class).GetRuntimeSetting(name) != null); } @@ -1691,7 +1692,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { throw new Error(); } @@ -1768,7 +1769,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { return new CString(ClassDiscovery.GetClassContainer(Meta.class).toString(), t); } @@ -1814,7 +1815,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { SmartComment comment = environment.getEnv(GlobalEnv.class).GetAliasComment(); if(comment == null) { return CNull.NULL; diff --git a/src/main/java/com/laytonsmith/core/functions/Minecraft.java b/src/main/java/com/laytonsmith/core/functions/Minecraft.java index 3cc9ad89c8..cf3ceab481 100644 --- a/src/main/java/com/laytonsmith/core/functions/Minecraft.java +++ b/src/main/java/com/laytonsmith/core/functions/Minecraft.java @@ -38,6 +38,7 @@ import com.laytonsmith.core.constructs.CNull; import com.laytonsmith.core.constructs.CString; import com.laytonsmith.core.constructs.CVoid; +import com.laytonsmith.core.constructs.generics.GenericParameters; import com.laytonsmith.core.constructs.Target; import com.laytonsmith.core.environments.CommandHelperEnvironment; import com.laytonsmith.core.environments.Environment; @@ -95,7 +96,7 @@ public Integer[] numArgs() { } @Override - public Mixed exec(Target t, Environment env, Mixed... args) throws CancelCommandException, ConfigRuntimeException { + public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws CancelCommandException, ConfigRuntimeException { if(args[0].isInstanceOf(CInt.TYPE)) { return new CInt(ArgumentValidation.getInt(args[0], t), t); } @@ -225,7 +226,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { int i = -1; int i2 = -1; if(args[0].isInstanceOf(CString.TYPE)) { @@ -309,7 +310,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { CArray item = ArgumentValidation.getArray(args[0], t); MCItemStack is = ObjectGenerator.GetGenerator().item(item, t, true); return ObjectGenerator.GetGenerator().item(is, t); @@ -357,7 +358,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { Mixed id = args[0]; if(id.isInstanceOf(CArray.TYPE)) { MCItemStack is = ObjectGenerator.GetGenerator().item(id, t); @@ -461,7 +462,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment env, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCPlayer p = env.getEnv(CommandHelperEnvironment.class).GetPlayer(); MCLocation l = ObjectGenerator.GetGenerator().location(args[0], p == null ? null : p.getWorld(), t); MCEffect effect; @@ -629,7 +630,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment env, Mixed... args) throws CancelCommandException, ConfigRuntimeException { + public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws CancelCommandException, ConfigRuntimeException { MCServer server = Static.getServer(); int index = -1; if(args.length == 0) { @@ -793,7 +794,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment env, Mixed... args) throws CancelCommandException, ConfigRuntimeException { + public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws CancelCommandException, ConfigRuntimeException { MCServer server = Static.getServer(); CArray co = new CArray(t); List so = server.getBannedPlayers(); @@ -847,7 +848,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment env, Mixed... args) throws CancelCommandException, ConfigRuntimeException { + public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws CancelCommandException, ConfigRuntimeException { MCServer server = Static.getServer(); CArray co = new CArray(t); List so = server.getWhitelistedPlayers(); @@ -881,7 +882,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCWorld w = null; MCPlayer p = environment.getEnv(CommandHelperEnvironment.class).GetPlayer(); if(p != null) { @@ -941,7 +942,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCWorld w = null; MCPlayer p = environment.getEnv(CommandHelperEnvironment.class).GetPlayer(); if(p != null) { @@ -1010,7 +1011,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCPlayer p = Static.GetPlayer(args[0], t); p.sendResourcePack(args[1].val()); return CVoid.VOID; @@ -1060,7 +1061,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCServer s = Static.getServer(); CArray ret = new CArray(t); for(String ip : s.getIPBans()) { @@ -1109,7 +1110,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCServer s = Static.getServer(); String ip = args[0].val(); if(ArgumentValidation.getBoolean(args[1], t)) { @@ -1151,7 +1152,7 @@ public Class[] thrown() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCMaterial mat = StaticLayer.GetMaterial(args[0].val()); if(mat == null) { try { @@ -1319,7 +1320,7 @@ public Version since() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws CancelCommandException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws CancelCommandException { Static.getServer().shutdown(); throw new CancelCommandException("", t); } @@ -1351,7 +1352,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCWorld world = null; MCPlayer p = environment.getEnv(CommandHelperEnvironment.class).GetPlayer(); if(p != null) { @@ -1414,7 +1415,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { CArray mats = new CArray(t); for(String mat : MCMaterial.types()) { mats.push(new CString(mat, t), t); @@ -1465,7 +1466,7 @@ public String docs() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCCommandSender sender; String selector; if(args.length == 2) { diff --git a/src/main/java/com/laytonsmith/core/functions/MobManagement.java b/src/main/java/com/laytonsmith/core/functions/MobManagement.java index a63db86dbf..01598158a4 100644 --- a/src/main/java/com/laytonsmith/core/functions/MobManagement.java +++ b/src/main/java/com/laytonsmith/core/functions/MobManagement.java @@ -38,6 +38,7 @@ import com.laytonsmith.core.constructs.CString; import com.laytonsmith.core.constructs.CVoid; import com.laytonsmith.core.constructs.Target; +import com.laytonsmith.core.constructs.generics.GenericParameters; import com.laytonsmith.core.environments.CommandHelperEnvironment; import com.laytonsmith.core.environments.Environment; import com.laytonsmith.core.exceptions.CRE.CREBadEntityException; @@ -108,7 +109,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCLivingEntity mob = Static.getLivingEntity(args[0], t); if(!mob.isTameable()) { throw new CREUntameableMobException("The specified entity is not tameable", t); @@ -164,7 +165,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCLivingEntity mob = Static.getLivingEntity(args[0], t); if(!mob.isTameable()) { throw new CREUntameableMobException("The specified entity is not tameable", t); @@ -221,7 +222,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCLivingEntity mob = Static.getLivingEntity(args[0], t); Mixed player = args[1]; if(!mob.isTameable()) { @@ -279,7 +280,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCLivingEntity e = Static.getLivingEntity(args[0], t); double percent = ArgumentValidation.getDouble(args[1], t); if(percent < 0 || percent > 100) { @@ -331,7 +332,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCLivingEntity e = Static.getLivingEntity(args[0], t); return new CDouble(e.getHealth() / e.getMaxHealth() * 100.0, t); } @@ -341,7 +342,7 @@ public Mixed exec(Target t, Environment environment, Mixed... args) throws Confi public static class get_entity_breedable extends EntityManagement.EntityGetterFunction { @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCEntity ent = Static.getEntity(args[0], t); if(ent instanceof MCBreedable) { @@ -371,7 +372,7 @@ public MSVersion since() { public static class set_entity_breedable extends EntityManagement.EntitySetterFunction { @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { boolean breed = ArgumentValidation.getBoolean(args[1], t); MCEntity ent = Static.getEntity(args[0], t); @@ -411,7 +412,7 @@ public Class[] thrown() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCLivingEntity ent = Static.getLivingEntity(args[0], t); if(ent instanceof MCAgeable mob) { return new CInt(mob.getAge(), t); @@ -447,7 +448,7 @@ public Class[] thrown() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { int age = ArgumentValidation.getInt32(args[1], t); boolean lock = false; if(args.length == 3) { @@ -498,7 +499,7 @@ public Class[] thrown() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCLivingEntity ent = Static.getLivingEntity(args[0], t); if(ent instanceof MCAnimal animal) { return new CInt(animal.getLoveTicks(), t); @@ -533,7 +534,7 @@ public Class[] thrown() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCLivingEntity ent = Static.getLivingEntity(args[0], t); int ticks = ArgumentValidation.getInt32(args[1], t); if(ent instanceof MCAnimal animal) { @@ -564,7 +565,7 @@ public MSVersion since() { public static class get_mob_effects extends EntityManagement.EntityGetterFunction { @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCLivingEntity mob = Static.getLivingEntity(args[0], t); return ObjectGenerator.GetGenerator().potions(mob.getEffects(), t); } @@ -629,7 +630,7 @@ public Class[] thrown() { } @Override - public Mixed exec(Target t, Environment env, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCLivingEntity mob = Static.getLivingEntity(args[0], t); MCPotionEffectType type = null; @@ -693,7 +694,7 @@ public MSVersion since() { public static class get_mob_target extends EntityManagement.EntityGetterFunction { @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCLivingEntity le = Static.getLivingEntity(args[0], t); if(le.getTarget(t) == null) { return CNull.NULL; @@ -728,7 +729,7 @@ public Class[] thrown() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCLivingEntity le = Static.getLivingEntity(args[0], t); MCLivingEntity target = null; if(!(args[1] instanceof CNull)) { @@ -760,7 +761,7 @@ public MSVersion since() { public static class get_mob_equipment extends EntityManagement.EntityGetterFunction { @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCLivingEntity le = Static.getLivingEntity(args[0], t); MCEntityEquipment eq = le.getEquipment(); if(eq == null) { @@ -809,7 +810,7 @@ public MSVersion since() { public static class set_mob_equipment extends EntityManagement.EntitySetterFunction { @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCLivingEntity le = Static.getLivingEntity(args[0], t); MCEntityEquipment ee = le.getEquipment(); if(ee == null) { @@ -870,7 +871,7 @@ public MSVersion since() { public static class get_max_health extends EntityManagement.EntityGetterFunction { @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCLivingEntity le = Static.getLivingEntity(args[0], t); return new CDouble(le.getMaxHealth(), t); } @@ -895,7 +896,7 @@ public MSVersion since() { public static class set_max_health extends EntityManagement.EntitySetterFunction { @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCLivingEntity le = Static.getLivingEntity(args[0], t); le.setMaxHealth(ArgumentValidation.getDouble(args[1], t)); return CVoid.VOID; @@ -929,7 +930,7 @@ public MSVersion since() { public static class get_equipment_droprates extends EntityManagement.EntityGetterFunction { @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCLivingEntity le = Static.getLivingEntity(args[0], t); if(le instanceof MCPlayer || le instanceof MCArmorStand) { throw new CREBadEntityException(getName() + "() does not work on type: " + le.getType(), t); @@ -968,7 +969,7 @@ public MSVersion since() { public static class set_equipment_droprates extends EntityManagement.EntitySetterFunction { @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCLivingEntity le = Static.getLivingEntity(args[0], t); if(le instanceof MCPlayer || le instanceof MCArmorStand) { throw new CREBadEntityException(getName() + "() does not work on type: " + le.getType(), t); @@ -1022,7 +1023,7 @@ public MSVersion since() { public static class can_pickup_items extends EntityManagement.EntityGetterFunction { @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { return CBoolean.get(Static.getLivingEntity(args[0], t).getCanPickupItems()); } @@ -1046,7 +1047,7 @@ public MSVersion since() { public static class set_can_pickup_items extends EntityManagement.EntitySetterFunction { @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { Static.getLivingEntity(args[0], t).setCanPickupItems(ArgumentValidation.getBoolean(args[1], t)); return CVoid.VOID; } @@ -1071,7 +1072,7 @@ public MSVersion since() { public static class get_entity_persistence extends EntityManagement.EntityGetterFunction { @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { return CBoolean.get(!Static.getLivingEntity(args[0], t).getRemoveWhenFarAway()); } @@ -1095,7 +1096,7 @@ public MSVersion since() { public static class set_entity_persistence extends EntityManagement.EntitySetterFunction { @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { Static.getLivingEntity(args[0], t).setRemoveWhenFarAway(!ArgumentValidation.getBoolean(args[1], t)); return CVoid.VOID; } @@ -1120,7 +1121,7 @@ public MSVersion since() { public static class get_leashholder extends EntityManagement.EntityGetterFunction { @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCEntity e = Static.getEntity(args[0], t); if(!(e instanceof MCLeashable)) { throw new CREBadEntityException("Entity type is not leashable.", t); @@ -1153,7 +1154,7 @@ public MSVersion since() { public static class set_leashholder extends EntityManagement.EntitySetterFunction { @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCEntity e = Static.getEntity(args[0], t); MCEntity holder; if(args[1] instanceof CNull) { @@ -1201,7 +1202,7 @@ public String docs() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { return new CInt(Static.getLivingEntity(args[0], t).getRemainingAir(), t); } @@ -1225,7 +1226,7 @@ public String docs() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { Static.getLivingEntity(args[0], t).setRemainingAir(ArgumentValidation.getInt32(args[1], t)); return CVoid.VOID; } @@ -1250,7 +1251,7 @@ public String docs() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { return new CInt(Static.getLivingEntity(args[0], t).getMaximumAir(), t); } @@ -1274,7 +1275,7 @@ public String docs() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { Static.getLivingEntity(args[0], t).setMaximumAir(ArgumentValidation.getInt32(args[1], t)); return CVoid.VOID; } @@ -1313,7 +1314,7 @@ public String docs() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCLivingEntity entity = Static.getLivingEntity(args[0], t); HashSet transparents = null; int maxDistance = 512; @@ -1387,7 +1388,7 @@ public String docs() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { return CBoolean.get(Static.getLivingEntity(args[0], t).hasLineOfSight(Static.getEntity(args[1], t))); } @@ -1407,7 +1408,7 @@ public Class[] thrown() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCEntity entity = Static.getEntity(args[0], t); if(!(entity instanceof MCLivingEntity)) { @@ -1464,7 +1465,7 @@ public String docs() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCLivingEntity e = Static.getLivingEntity(args[0], t); boolean glide = ArgumentValidation.getBoolean(args[1], t); @@ -1493,7 +1494,7 @@ public String docs() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { return CBoolean.GenerateCBoolean(Static.getLivingEntity(args[0], t).isGliding(), t); } @@ -1517,7 +1518,7 @@ public String docs() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { return CBoolean.GenerateCBoolean(Static.getLivingEntity(args[0], t).hasAI(), t); } @@ -1541,7 +1542,7 @@ public String docs() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCLivingEntity e = Static.getLivingEntity(args[0], t); boolean ai = ArgumentValidation.getBoolean(args[1], t); @@ -1570,7 +1571,7 @@ public String docs() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { return CBoolean.GenerateCBoolean(Static.getLivingEntity(args[0], t).isCollidable(), t); } @@ -1594,7 +1595,7 @@ public String docs() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCLivingEntity e = Static.getLivingEntity(args[0], t); boolean collidable = ArgumentValidation.getBoolean(args[1], t); e.setCollidable(collidable); @@ -1644,7 +1645,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCLivingEntity e = Static.getLivingEntity(args[0], t); MCAttribute attribute; try { @@ -1701,7 +1702,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCLivingEntity e = Static.getLivingEntity(args[0], t); MCAttribute attribute; try { @@ -1758,7 +1759,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCLivingEntity e = Static.getLivingEntity(args[0], t); MCAttribute attribute; try { @@ -1815,7 +1816,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCLivingEntity e = Static.getLivingEntity(args[0], t); MCAttribute attribute; try { @@ -1877,7 +1878,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCLivingEntity e = Static.getLivingEntity(args[0], t); MCAttribute attribute; try { @@ -1936,7 +1937,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCLivingEntity e = Static.getLivingEntity(args[0], t); MCAttribute attribute; try { @@ -1995,7 +1996,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCLivingEntity e = Static.getLivingEntity(args[0], t); MCAttributeModifier modifier = ObjectGenerator.GetGenerator().attributeModifier(ArgumentValidation.getArray(args[1], t), t); try { @@ -2048,7 +2049,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCLivingEntity e = Static.getLivingEntity(args[0], t); MCAttributeModifier modifier = null; if(args.length == 2) { @@ -2131,7 +2132,7 @@ public String docs() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { return new CInt(Static.getLivingEntity(args[0], t).getNoDamageTicks(), t); } @@ -2155,7 +2156,7 @@ public String docs() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { Static.getLivingEntity(args[0], t).setNoDamageTicks(ArgumentValidation.getInt32(args[1], t)); return CVoid.VOID; } @@ -2181,7 +2182,7 @@ public String docs() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { return CBoolean.get(Static.getLivingEntity(args[0], t).isSleeping()); } diff --git a/src/main/java/com/laytonsmith/core/functions/OAuth.java b/src/main/java/com/laytonsmith/core/functions/OAuth.java index b576bde393..b12acae478 100644 --- a/src/main/java/com/laytonsmith/core/functions/OAuth.java +++ b/src/main/java/com/laytonsmith/core/functions/OAuth.java @@ -20,6 +20,7 @@ import com.laytonsmith.core.constructs.CVoid; import com.laytonsmith.core.constructs.Construct; import com.laytonsmith.core.constructs.Target; +import com.laytonsmith.core.constructs.generics.GenericParameters; import com.laytonsmith.core.environments.Environment; import com.laytonsmith.core.environments.StaticRuntimeEnv; import com.laytonsmith.core.exceptions.CRE.CREFormatException; @@ -116,7 +117,7 @@ CArray toOptionsArray() { } public static String execute(Environment env, OAuthOptions options) { - return new x_get_oauth_token().exec(Target.UNKNOWN, env, options.toOptionsArray()).val(); + return new x_get_oauth_token().exec(Target.UNKNOWN, env, null, options.toOptionsArray()).val(); } @Override @@ -135,7 +136,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, com.laytonsmith.core.environments.Environment env, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, com.laytonsmith.core.environments.Environment env, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { // TODO: Make this part support profiles CArray options = ArgumentValidation.getArray(args[0], t); String authorizationUrl = options.get("authorizationUrl", t).val(); @@ -179,7 +180,7 @@ public Mixed exec(Target t, com.laytonsmith.core.environments.Environment env, M } String requestURI = generateRequestURI(authorizationUrl, clientId, scope, redirectUrl, extraHeaders); - new XGUI.x_launch_browser().exec(t, env, new CString(requestURI, t)); + new XGUI.x_launch_browser().exec(t, env, null, new CString(requestURI, t)); synchronized(lock) { if(lock.getObject() == null) { lock.wait(); @@ -207,7 +208,7 @@ public Mixed exec(Target t, com.laytonsmith.core.environments.Environment env, M switch(responseType) { case "application/json": { CArray tokenJson = (CArray) new DataTransformations.json_decode() - .exec(t, env, new CString(tokenResponse.getContentAsString(), t)); + .exec(t, env, null, new CString(tokenResponse.getContentAsString(), t)); if(tokenJson.containsKey("refresh_token")) { storeRefreshToken(env, clientId, tokenJson.get("refresh_token", t).val()); } @@ -246,7 +247,7 @@ public Mixed exec(Target t, com.laytonsmith.core.environments.Environment env, M tokenParameters.put("grant_type", "refresh_token"); settings.setParameters(tokenParameters); HTTPResponse tokenResponse = WebUtility.GetPage(new URL(tokenUrl), settings); - CArray tokenJson = (CArray) new DataTransformations.json_decode().exec(t, env, new CString(tokenResponse.getContentAsString(), t)); + CArray tokenJson = (CArray) new DataTransformations.json_decode().exec(t, env, null, new CString(tokenResponse.getContentAsString(), t)); accessToken = tokenJson.get("access_token", t).val(); storeAccessToken(env, clientId, new AccessToken(accessToken, ArgumentValidation.getInt32(tokenJson.get("expires_in", t), t) * 1000)); } @@ -500,7 +501,7 @@ public static void execute(Environment env, String clientId) { if(clientId != null) { args = new Mixed[]{new CString(clientId, Target.UNKNOWN)}; } - new clear_oauth_tokens().exec(Target.UNKNOWN, env, args); + new clear_oauth_tokens().exec(Target.UNKNOWN, env, null, args); } @Override @@ -519,7 +520,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { PersistenceNetwork pn = environment.getEnv(StaticRuntimeEnv.class).GetPersistenceNetwork(); String namespace = "oauth"; if(args.length >= 1) { diff --git a/src/main/java/com/laytonsmith/core/functions/OS.java b/src/main/java/com/laytonsmith/core/functions/OS.java index ebed196878..4c302a521b 100644 --- a/src/main/java/com/laytonsmith/core/functions/OS.java +++ b/src/main/java/com/laytonsmith/core/functions/OS.java @@ -6,6 +6,7 @@ import com.laytonsmith.core.MSVersion; import com.laytonsmith.core.constructs.CInt; import com.laytonsmith.core.constructs.Target; +import com.laytonsmith.core.constructs.generics.GenericParameters; import com.laytonsmith.core.environments.Environment; import com.laytonsmith.core.exceptions.CRE.CREThrowable; import com.laytonsmith.core.exceptions.CRE.CREUnsupportedOperationException; @@ -41,7 +42,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { try { return new CInt(OSUtils.GetMyPid(), t); } catch (UnsupportedOperationException ex) { diff --git a/src/main/java/com/laytonsmith/core/functions/ObjectManagement.java b/src/main/java/com/laytonsmith/core/functions/ObjectManagement.java index 2a6a3c7d76..c8fef22e5a 100644 --- a/src/main/java/com/laytonsmith/core/functions/ObjectManagement.java +++ b/src/main/java/com/laytonsmith/core/functions/ObjectManagement.java @@ -24,6 +24,7 @@ import com.laytonsmith.core.constructs.CVoid; import com.laytonsmith.core.constructs.NativeTypeList; import com.laytonsmith.core.constructs.Target; +import com.laytonsmith.core.constructs.generics.GenericParameters; import com.laytonsmith.core.environments.Environment; import com.laytonsmith.core.environments.GlobalEnv; import com.laytonsmith.core.exceptions.CRE.CREClassDefinitionError; @@ -80,7 +81,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. } @@ -131,7 +132,7 @@ public boolean useSpecialExec() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { throw new Error(); } @@ -197,7 +198,7 @@ private Mixed evaluateMixed(ParseTree data, Target t) { throw new CREClassDefinitionError("Expected __to_class_reference__, but found " + data.getData() + " instead", t); } - return new __to_class_reference__().exec(t, null, + return new __to_class_reference__().exec(t, null, null, data.getChildren().stream() .map((parseTree -> parseTree.getData())) .collect(Collectors.toList()) @@ -448,7 +449,7 @@ public boolean useSpecialExec() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { throw new Error(); } @@ -597,7 +598,7 @@ public Class[] thrown() { @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { try { return CClassType.get(FullyQualifiedClassName.forFullyQualifiedClass(args[0].val())); } catch (ClassNotFoundException ex) { diff --git a/src/main/java/com/laytonsmith/core/functions/Performance.java b/src/main/java/com/laytonsmith/core/functions/Performance.java index 38adac62bd..efcbb96276 100644 --- a/src/main/java/com/laytonsmith/core/functions/Performance.java +++ b/src/main/java/com/laytonsmith/core/functions/Performance.java @@ -7,6 +7,7 @@ import com.laytonsmith.core.Static; import com.laytonsmith.core.constructs.CVoid; import com.laytonsmith.core.constructs.Target; +import com.laytonsmith.core.constructs.generics.GenericParameters; import com.laytonsmith.core.environments.Environment; import com.laytonsmith.core.exceptions.CRE.CRESecurityException; import com.laytonsmith.core.exceptions.CRE.CREThrowable; @@ -83,7 +84,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { if(!Prefs.AllowProfiling()) { throw new CRESecurityException("allow-profiling is currently off, you must set it to true in your preferences.", t); } diff --git a/src/main/java/com/laytonsmith/core/functions/Permissions.java b/src/main/java/com/laytonsmith/core/functions/Permissions.java index e90b3e6474..0890ecefab 100644 --- a/src/main/java/com/laytonsmith/core/functions/Permissions.java +++ b/src/main/java/com/laytonsmith/core/functions/Permissions.java @@ -7,6 +7,7 @@ import com.laytonsmith.core.Static; import com.laytonsmith.core.constructs.CBoolean; import com.laytonsmith.core.constructs.Target; +import com.laytonsmith.core.constructs.generics.GenericParameters; import com.laytonsmith.core.environments.CommandHelperEnvironment; import com.laytonsmith.core.environments.Environment; import com.laytonsmith.core.environments.GlobalEnv; @@ -70,7 +71,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCCommandSender sender; String permission; diff --git a/src/main/java/com/laytonsmith/core/functions/Persistence.java b/src/main/java/com/laytonsmith/core/functions/Persistence.java index 1d3e7804e5..dc520ce27b 100644 --- a/src/main/java/com/laytonsmith/core/functions/Persistence.java +++ b/src/main/java/com/laytonsmith/core/functions/Persistence.java @@ -15,6 +15,7 @@ import com.laytonsmith.core.constructs.CVoid; import com.laytonsmith.core.constructs.Construct; import com.laytonsmith.core.constructs.Target; +import com.laytonsmith.core.constructs.generics.GenericParameters; import com.laytonsmith.core.environments.Environment; import com.laytonsmith.core.environments.GlobalEnv; import com.laytonsmith.core.environments.StaticRuntimeEnv; @@ -91,7 +92,7 @@ public MSVersion since() { } @Override - public Mixed exec(Target t, Environment env, Mixed... args) throws CancelCommandException, ConfigRuntimeException { + public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws CancelCommandException, ConfigRuntimeException { String key = GetNamespace(args, args.length - 1, getName(), t); String value = null; try { @@ -174,7 +175,7 @@ public MSVersion since() { } @Override - public Mixed exec(Target t, Environment env, Mixed... args) throws CancelCommandException, ConfigRuntimeException { + public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws CancelCommandException, ConfigRuntimeException { Object o; String namespace = GetNamespace(args, null, getName(), t); MSLog.GetLogger().Log(MSLog.Tags.PERSISTENCE, LogLevel.DEBUG, "Getting value: " + namespace, t); @@ -264,7 +265,7 @@ public ExampleScript[] examples() throws ConfigCompileException { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { PersistenceNetwork p = environment.getEnv(StaticRuntimeEnv.class).GetPersistenceNetwork(); List keyChain = new ArrayList(); keyChain.add("storage"); @@ -345,7 +346,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment env, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { try { return CBoolean.get(env.getEnv(StaticRuntimeEnv.class).GetPersistenceNetwork() .hasKey(("storage." + GetNamespace(args, null, getName(), t)).split("\\."))); @@ -403,7 +404,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { String namespace = GetNamespace(args, null, getName(), t); MSLog.GetLogger().Log(MSLog.Tags.PERSISTENCE, LogLevel.DEBUG, "Clearing value: " + namespace, t); try { diff --git a/src/main/java/com/laytonsmith/core/functions/PlayerManagement.java b/src/main/java/com/laytonsmith/core/functions/PlayerManagement.java index 21acb4dd87..f2570cdd1c 100644 --- a/src/main/java/com/laytonsmith/core/functions/PlayerManagement.java +++ b/src/main/java/com/laytonsmith/core/functions/PlayerManagement.java @@ -60,6 +60,7 @@ import com.laytonsmith.core.constructs.CVoid; import com.laytonsmith.core.constructs.Construct; import com.laytonsmith.core.constructs.Target; +import com.laytonsmith.core.constructs.generics.GenericParameters; import com.laytonsmith.core.environments.CommandHelperEnvironment; import com.laytonsmith.core.environments.Environment; import com.laytonsmith.core.environments.GlobalEnv; @@ -119,7 +120,7 @@ public Integer[] numArgs() { } @Override - public Mixed exec(Target t, Environment env, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCCommandSender p = env.getEnv(CommandHelperEnvironment.class).GetCommandSender(); if(args.length == 1) { @@ -197,7 +198,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCOfflinePlayer pl = environment.getEnv(CommandHelperEnvironment.class).GetPlayer(); boolean dashless = false; if(args.length >= 1) { @@ -262,7 +263,7 @@ public Integer[] numArgs() { } @Override - public Mixed exec(Target t, Environment env, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { CArray players = new CArray(t); if(args.length == 0) { for(MCPlayer player : Static.getServer().getOnlinePlayers()) { @@ -359,7 +360,7 @@ boolean inRadius(MCPlayer player, double dist, MCLocation loc) { } @Override - public Mixed exec(Target t, Environment env, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { Collection pa = Static.getServer().getOnlinePlayers(); MCPlayer p = env.getEnv(CommandHelperEnvironment.class).GetPlayer(); @@ -431,7 +432,7 @@ public Integer[] numArgs() { } @Override - public Mixed exec(Target t, Environment env, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCPlayer p; if(args.length == 0) { p = env.getEnv(CommandHelperEnvironment.class).GetPlayer(); @@ -521,7 +522,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment env, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCPlayer p = env.getEnv(CommandHelperEnvironment.class).GetPlayer(); MCLocation l; if(args.length <= 2) { @@ -621,7 +622,7 @@ public MSVersion since() { } @Override - public Mixed exec(Target t, Environment env, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCPlayer p = env.getEnv(CommandHelperEnvironment.class).GetPlayer(); HashSet trans = null; int transparentIndex = -1; @@ -720,7 +721,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCPlayer p = environment.getEnv(CommandHelperEnvironment.class).GetPlayer(); if(args.length > 0) { p = Static.GetPlayer(args[0], t); @@ -770,7 +771,7 @@ public Integer[] numArgs() { } @Override - public Mixed exec(Target t, Environment env, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCCommandSender p = env.getEnv(CommandHelperEnvironment.class).GetCommandSender(); MCPlayer m = null; if(args.length == 1) { @@ -825,7 +826,7 @@ public Integer[] numArgs() { } @Override - public Mixed exec(Target t, Environment env, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCCommandSender sender; if(args.length == 0) { sender = env.getEnv(CommandHelperEnvironment.class).GetCommandSender(); @@ -938,7 +939,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment env, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCCommandSender m = env.getEnv(CommandHelperEnvironment.class).GetCommandSender(); String player; int index; @@ -1126,7 +1127,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment env, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCCommandSender p = env.getEnv(CommandHelperEnvironment.class).GetCommandSender(); MCPlayer m = null; if(args.length == 0) { @@ -1182,7 +1183,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment env, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCCommandSender p = env.getEnv(CommandHelperEnvironment.class).GetCommandSender(); String message = "You have been kicked"; MCPlayer m = null; @@ -1264,7 +1265,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment env, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCPlayer m; if(args.length == 0) { m = env.getEnv(CommandHelperEnvironment.class).GetPlayer(); @@ -1338,7 +1339,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment env, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCPlayer player; String name; if(args.length == 1) { @@ -1415,7 +1416,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment env, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCPlayer player; if(args.length == 0) { player = env.getEnv(CommandHelperEnvironment.class).GetPlayer(); @@ -1485,7 +1486,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment env, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCCommandSender p = env.getEnv(CommandHelperEnvironment.class).GetCommandSender(); //Getter if(args.length == 0 || args.length == 1) { @@ -1624,7 +1625,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment env, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCCommandSender p = env.getEnv(CommandHelperEnvironment.class).GetCommandSender(); MCPlayer m = null; if(p instanceof MCPlayer) { @@ -1685,7 +1686,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment env, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCCommandSender p = env.getEnv(CommandHelperEnvironment.class).GetCommandSender(); MCPlayer m = null; String mode; @@ -1750,7 +1751,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment env, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCCommandSender p = env.getEnv(CommandHelperEnvironment.class).GetCommandSender(); MCPlayer m = null; if(p instanceof MCPlayer) { @@ -1804,7 +1805,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment env, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCCommandSender p = env.getEnv(CommandHelperEnvironment.class).GetCommandSender(); MCPlayer m = null; int xp; @@ -1865,7 +1866,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCCommandSender p = environment.getEnv(CommandHelperEnvironment.class).GetCommandSender(); MCPlayer m = null; int xp; @@ -1924,7 +1925,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment env, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCCommandSender p = env.getEnv(CommandHelperEnvironment.class).GetCommandSender(); MCPlayer m = null; if(p instanceof MCPlayer) { @@ -1977,7 +1978,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment env, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCCommandSender p = env.getEnv(CommandHelperEnvironment.class).GetCommandSender(); MCPlayer m = null; int level; @@ -2035,7 +2036,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment env, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCCommandSender p = env.getEnv(CommandHelperEnvironment.class).GetCommandSender(); MCPlayer m = null; if(p instanceof MCPlayer) { @@ -2089,7 +2090,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment env, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCCommandSender p = env.getEnv(CommandHelperEnvironment.class).GetCommandSender(); MCPlayer m = null; int xp; @@ -2154,7 +2155,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment env, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCCommandSender p = env.getEnv(CommandHelperEnvironment.class).GetCommandSender(); MCPlayer m = null; if(p instanceof MCPlayer) { @@ -2207,7 +2208,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment env, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCCommandSender p = env.getEnv(CommandHelperEnvironment.class).GetCommandSender(); MCPlayer m = null; int level; @@ -2277,7 +2278,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment env, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCPlayer m = Static.GetPlayer(args[0].val(), t); MCPotionEffectType type = null; @@ -2366,7 +2367,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCPlayer p = environment.getEnv(CommandHelperEnvironment.class).GetPlayer(); if(args.length > 0) { p = Static.GetPlayer(args[0], t); @@ -2419,7 +2420,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment env, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCPlayer p; if(args.length == 0) { p = env.getEnv(CommandHelperEnvironment.class).GetPlayer(); @@ -2491,7 +2492,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment env, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCPlayer m; if(args.length == 0) { m = env.getEnv(CommandHelperEnvironment.class).GetPlayer(); @@ -2542,7 +2543,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment env, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCPlayer m; if(args.length == 0) { m = env.getEnv(CommandHelperEnvironment.class).GetPlayer(); @@ -2594,7 +2595,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment env, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCCommandSender p = env.getEnv(CommandHelperEnvironment.class).GetCommandSender(); MCPlayer m = null; if(p instanceof MCPlayer) { @@ -2658,7 +2659,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment env, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { try { //Static.GetPlayer() autocompletes names, which we don't want in this function, //however we have to check if this is an injected player first. @@ -2715,7 +2716,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment env, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCOfflinePlayer pl = Static.GetUser(args[0].val(), t); return CBoolean.get(pl != null && pl.isWhitelisted()); } @@ -2761,7 +2762,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment env, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCOfflinePlayer pl = Static.GetUser(args[0].val(), t); boolean whitelist = ArgumentValidation.getBoolean(args[1], t); if(pl == null) { @@ -2824,7 +2825,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment env, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCOfflinePlayer pl = Static.GetUser(args[0].val(), t); if(pl == null) { throw new CRENotFoundException( @@ -2879,7 +2880,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment env, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { String target = args[0].val(); boolean ban = ArgumentValidation.getBoolean(args[1], t); String reason = ""; @@ -2952,7 +2953,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment env, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCCommandSender p = env.getEnv(CommandHelperEnvironment.class).GetCommandSender(); MCPlayer m = null; double speed; @@ -3016,7 +3017,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment env, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCCommandSender p = env.getEnv(CommandHelperEnvironment.class).GetCommandSender(); MCPlayer m = null; @@ -3074,7 +3075,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment env, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCCommandSender p = env.getEnv(CommandHelperEnvironment.class).GetCommandSender(); MCPlayer m = null; double speed; @@ -3138,7 +3139,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment env, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCCommandSender p = env.getEnv(CommandHelperEnvironment.class).GetCommandSender(); MCPlayer m = null; @@ -3195,7 +3196,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCPlayer m = environment.getEnv(CommandHelperEnvironment.class).GetPlayer(); if(args.length == 1) { m = Static.GetPlayer(args[0].val(), t); @@ -3244,7 +3245,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCPlayer m = environment.getEnv(CommandHelperEnvironment.class).GetPlayer(); MCLocation l; if(args.length == 1) { @@ -3302,7 +3303,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCPlayer m = environment.getEnv(CommandHelperEnvironment.class).GetPlayer(); if(args.length == 1) { m = Static.GetPlayer(args[0].val(), t); @@ -3352,7 +3353,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCPlayer p = environment.getEnv(CommandHelperEnvironment.class).GetPlayer(); if(args.length == 1) { p = Static.GetPlayer(args[0], t); @@ -3403,7 +3404,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCPlayer p = environment.getEnv(CommandHelperEnvironment.class).GetPlayer(); Mixed ticks; if(args.length == 2) { @@ -3461,7 +3462,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCPlayer p = environment.getEnv(CommandHelperEnvironment.class).GetPlayer(); if(args.length == 1) { p = Static.GetPlayer(args[0], t); @@ -3511,7 +3512,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCPlayer p = environment.getEnv(CommandHelperEnvironment.class).GetPlayer(); boolean flight; if(args.length == 1) { @@ -3596,7 +3597,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCPlayer p = null; boolean relative = false; if(environment.getEnv(CommandHelperEnvironment.class).GetPlayer() != null) { @@ -3692,7 +3693,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCPlayer p = null; if(environment.getEnv(CommandHelperEnvironment.class).GetPlayer() != null) { p = environment.getEnv(CommandHelperEnvironment.class).GetPlayer(); @@ -3744,7 +3745,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCPlayer p = null; if(environment.getEnv(CommandHelperEnvironment.class).GetPlayer() != null) { p = environment.getEnv(CommandHelperEnvironment.class).GetPlayer(); @@ -3777,7 +3778,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCPlayer m = environment.getEnv(CommandHelperEnvironment.class).GetPlayer(); if(args.length == 1) { m = Static.GetPlayer(args[0], t); @@ -3827,7 +3828,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCPlayer m = environment.getEnv(CommandHelperEnvironment.class).GetPlayer(); int offset = 0; if(args.length == 2) { @@ -3887,7 +3888,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCPlayer m; String listName; if(args.length == 2) { @@ -3943,7 +3944,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCPlayer p = environment.getEnv(CommandHelperEnvironment.class).GetPlayer(); if(args.length == 1) { p = Static.GetPlayer(args[0], t); @@ -4010,7 +4011,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCPlayer p; if(args.length == 1) { p = Static.GetPlayer(args[0], t); @@ -4054,7 +4055,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCPlayer p = environment.getEnv(CommandHelperEnvironment.class).GetPlayer(); Vector3D v; int offset = 0; @@ -4142,7 +4143,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCPlayer p = environment.getEnv(CommandHelperEnvironment.class).GetPlayer(); int offset = 0; if(args.length == 3 || args.length == 6) { @@ -4296,7 +4297,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCPlayer p = environment.getEnv(CommandHelperEnvironment.class).GetPlayer(); int offset = 0; if(args.length == 3) { @@ -4408,7 +4409,7 @@ public Class[] thrown() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCPlayer p; MCLocation location; float progress; @@ -4477,7 +4478,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCPlayer p = environment.getEnv(CommandHelperEnvironment.class).GetPlayer(); if(args.length == 1) { p = Static.GetPlayer(args[0], t); @@ -4526,7 +4527,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCPlayer p = environment.getEnv(CommandHelperEnvironment.class).GetPlayer(); int hungerIndex = 0; if(args.length == 2) { @@ -4579,7 +4580,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCPlayer p = environment.getEnv(CommandHelperEnvironment.class).GetPlayer(); if(args.length == 1) { p = Static.GetPlayer(args[0], t); @@ -4628,7 +4629,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCPlayer p = environment.getEnv(CommandHelperEnvironment.class).GetPlayer(); float saturation; int saturationIndex = 0; @@ -4680,7 +4681,7 @@ public Integer[] numArgs() { } @Override - public Mixed exec(Target t, Environment env, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCOfflinePlayer player = env.getEnv(CommandHelperEnvironment.class).GetPlayer(); if(args.length == 1) { player = Static.GetUser(args[0].val(), t); @@ -4771,7 +4772,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment env, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCCommandSender p = env.getEnv(CommandHelperEnvironment.class).GetCommandSender(); String pname = null; MCPlayer m = null; @@ -4894,7 +4895,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCPlayer p = environment.getEnv(CommandHelperEnvironment.class).GetPlayer(); if(args.length == 1) { p = Static.GetPlayer(args[0].val(), t); @@ -4949,7 +4950,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCPlayer p = environment.getEnv(CommandHelperEnvironment.class).GetPlayer(); if(args.length == 1) { p = Static.GetPlayer(args[0].val(), t); @@ -4979,7 +4980,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCServer s = Static.getServer(); CArray ret = new CArray(t); // This causes the function to return an empty array for a fake/null server. @@ -5042,7 +5043,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCOfflinePlayer offp = Static.GetUser(args[0].val(), t); return CBoolean.get(offp != null && offp.hasPlayedBefore()); } @@ -5099,7 +5100,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCOfflinePlayer op; if(args.length == 1) { op = Static.GetUser(args[0].val(), t); @@ -5166,7 +5167,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCOfflinePlayer op; if(args.length == 1) { op = Static.GetUser(args[0].val(), t); @@ -5232,7 +5233,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCOfflinePlayer p = Static.GetUser(args[0].val(), t); if(p == null) { return CNull.NULL; @@ -5286,7 +5287,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { Static.getServer().savePlayers(); return CVoid.VOID; } @@ -5348,7 +5349,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCPlayer p = environment.getEnv(CommandHelperEnvironment.class).GetPlayer(); boolean flight; if(args.length == 1) { @@ -5416,7 +5417,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCPlayer p; if(args.length == 1) { p = Static.GetPlayer(args[0], t); @@ -5469,7 +5470,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCPlayer p; if(args.length == 0) { p = environment.getEnv(CommandHelperEnvironment.class).GetPlayer(); @@ -5530,7 +5531,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCPlayer p; int offset = 0; if(args.length == 1) { @@ -5578,7 +5579,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, com.laytonsmith.core.environments.Environment environment, Mixed... args) + public Mixed exec(Target t, com.laytonsmith.core.environments.Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCPlayer p = Static.GetPlayer(args[0], t); @@ -5663,7 +5664,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, com.laytonsmith.core.environments.Environment environment, Mixed... args) + public Mixed exec(Target t, com.laytonsmith.core.environments.Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCPlayer p = Static.GetPlayer(args[0], t); @@ -5719,7 +5720,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, com.laytonsmith.core.environments.Environment environment, Mixed... args) + public Mixed exec(Target t, com.laytonsmith.core.environments.Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCPlayer p = Static.GetPlayer(args[0], t); @@ -5798,7 +5799,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment env, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCPlayer p; String materialName; if(args.length == 2) { @@ -5862,7 +5863,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment env, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCPlayer p; String materialName; int cooldown; @@ -5932,7 +5933,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment env, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCHumanEntity he; if(args.length == 0) { he = env.getEnv(CommandHelperEnvironment.class).GetPlayer(); @@ -5985,7 +5986,7 @@ public String docs() { } @Override - public Mixed exec(Target t, Environment env, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCPlayer p; if(args.length == 2) { p = Static.GetPlayer(args[0], t); @@ -6039,7 +6040,7 @@ public String docs() { } @Override - public Mixed exec(Target t, Environment env, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCPlayer p; String header; if(args.length == 2) { @@ -6095,7 +6096,7 @@ public String docs() { } @Override - public Mixed exec(Target t, Environment env, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCPlayer p; if(args.length == 2) { p = Static.GetPlayer(args[0], t); @@ -6149,7 +6150,7 @@ public String docs() { } @Override - public Mixed exec(Target t, Environment env, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCPlayer p; String footer; if(args.length == 2) { @@ -6206,7 +6207,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCPlayer p = environment.getEnv(CommandHelperEnvironment.class).GetPlayer(); if(p == null) { throw new CREPlayerOfflineException("ptellraw() requires player context. Consider tellraw().", t); @@ -6311,7 +6312,7 @@ public String docs() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCPlayer p = environment.getEnv(CommandHelperEnvironment.class).GetPlayer(); String filter = null; MCPlayerStatistic stat; @@ -6414,7 +6415,7 @@ public String docs() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCPlayer p = environment.getEnv(CommandHelperEnvironment.class).GetPlayer(); String filter = null; MCPlayerStatistic stat; @@ -6536,7 +6537,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCPlayer p; if(args.length == 1) { p = Static.GetPlayer(args[0], t); @@ -6587,7 +6588,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCPlayer p; if(args.length == 1) { p = Static.GetPlayer(args[0], t); @@ -6625,7 +6626,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCPlayer p; if(args.length == 1) { p = Static.GetPlayer(args[0], t); @@ -6690,7 +6691,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCPlayer p; Mixed c; if(args.length == 2) { @@ -6778,7 +6779,7 @@ public Integer[] numArgs() { } @Override - public Mixed exec(Target t, Environment env, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCPlayer p; if(args.length == 0) { p = env.getEnv(CommandHelperEnvironment.class).GetPlayer(); @@ -6829,7 +6830,7 @@ public Integer[] numArgs() { } @Override - public Mixed exec(Target t, Environment env, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCPlayer p; String stringKey; if(args.length == 1) { @@ -6889,7 +6890,7 @@ public Integer[] numArgs() { } @Override - public Mixed exec(Target t, Environment env, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCPlayer p; Mixed value; if(args.length == 1) { @@ -6960,7 +6961,7 @@ public Integer[] numArgs() { } @Override - public Mixed exec(Target t, Environment env, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCPlayer p; if(args.length == 0) { p = env.getEnv(CommandHelperEnvironment.class).GetPlayer(); @@ -7014,7 +7015,7 @@ public Integer[] numArgs() { } @Override - public Mixed exec(Target t, Environment env, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCPlayer p; MCEntity e; if(args.length == 1) { @@ -7069,7 +7070,7 @@ public Integer[] numArgs() { } @Override - public Mixed exec(Target t, Environment env, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCPlayer p; MCEntity e; if(args.length == 1) { @@ -7125,7 +7126,7 @@ public Integer[] numArgs() { } @Override - public Mixed exec(Target t, Environment env, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCPlayer p; MCEntity e; if(args.length == 1) { @@ -7183,7 +7184,7 @@ public Integer[] numArgs() { } @Override - public Mixed exec(Target t, Environment env, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCPlayer p; MCLivingEntity le; Mixed equipment; @@ -7255,7 +7256,7 @@ public String docs() { + " This is an indicator of the quality of the player's connection, as represented in the tab list."; } - public Construct exec(Target t, Environment env, Mixed... args) throws ConfigRuntimeException { + public Construct exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCPlayer p; if(args.length == 1) { p = Static.GetPlayer(args[0].val(), t); @@ -7300,7 +7301,7 @@ public String docs() { + " Array contains the following keys: forward, backward, left, right, jump, sneak, and sprint."; } - public Construct exec(Target t, Environment env, Mixed... args) throws ConfigRuntimeException { + public Construct exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCPlayer p; if(args.length == 1) { p = Static.GetPlayer(args[0].val(), t); @@ -7349,7 +7350,7 @@ public static class set_player_sleeping_ignored extends AbstractFunction { } @Override - public Mixed exec(Target t, Environment env, Mixed... args) + public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { final MCPlayer player; final boolean value; @@ -7405,7 +7406,7 @@ public static class is_player_sleeping_ignored extends AbstractFunction { } @Override - public Mixed exec(Target t, Environment env, Mixed... args) + public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { final MCPlayer player; if(args.length == 0) { @@ -7480,7 +7481,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCPlayer thisPlayer; boolean isVanished; MCPlayer otherPlayer; @@ -7539,7 +7540,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCPlayer thisPlayer; MCPlayer otherPlayer; if(args.length == 1) { diff --git a/src/main/java/com/laytonsmith/core/functions/PluginMeta.java b/src/main/java/com/laytonsmith/core/functions/PluginMeta.java index f7c1ff5926..ba04388ad9 100644 --- a/src/main/java/com/laytonsmith/core/functions/PluginMeta.java +++ b/src/main/java/com/laytonsmith/core/functions/PluginMeta.java @@ -14,6 +14,7 @@ import com.laytonsmith.core.constructs.CString; import com.laytonsmith.core.constructs.CVoid; import com.laytonsmith.core.constructs.Target; +import com.laytonsmith.core.constructs.generics.GenericParameters; import com.laytonsmith.core.environments.CommandHelperEnvironment; import com.laytonsmith.core.environments.Environment; import com.laytonsmith.core.exceptions.CRE.CRECastException; @@ -55,7 +56,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCPluginMeta meta = StaticLayer.GetConvertor().GetPluginMeta(); MCPlayer p = environment.getEnv(CommandHelperEnvironment.class).GetPlayer(); int offset = 0; @@ -118,7 +119,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCPlayer p = environment.getEnv(CommandHelperEnvironment.class).GetPlayer(); int offset = 0; @@ -183,7 +184,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCMessenger messenger = Static.getServer().getMessenger(); if(messenger == null) { throw new CRENotFoundException( @@ -248,7 +249,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCMessenger messenger = Static.getServer().getMessenger(); if(messenger == null) { throw new CRENotFoundException( @@ -309,7 +310,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCMessenger messenger = Static.getServer().getMessenger(); if(messenger == null) { throw new CRENotFoundException( @@ -363,7 +364,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCMessenger messenger = Static.getServer().getMessenger(); if(messenger == null) { throw new CRENotFoundException( diff --git a/src/main/java/com/laytonsmith/core/functions/Recipes.java b/src/main/java/com/laytonsmith/core/functions/Recipes.java index 16749a8b29..8bb8a493c7 100644 --- a/src/main/java/com/laytonsmith/core/functions/Recipes.java +++ b/src/main/java/com/laytonsmith/core/functions/Recipes.java @@ -11,6 +11,7 @@ import com.laytonsmith.core.constructs.CBoolean; import com.laytonsmith.core.constructs.CVoid; import com.laytonsmith.core.constructs.Target; +import com.laytonsmith.core.constructs.generics.GenericParameters; import com.laytonsmith.core.environments.CommandHelperEnvironment; import com.laytonsmith.core.environments.Environment; import com.laytonsmith.core.exceptions.CRE.CRECastException; @@ -56,7 +57,7 @@ public Class[] thrown() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { try { return CBoolean.get(Static.getServer().addRecipe(ObjectGenerator.GetGenerator().recipe(args[0], t))); } catch (IllegalStateException ex) { @@ -212,7 +213,7 @@ public Class[] thrown() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { return CBoolean.get(Static.getServer().removeRecipe(args[0].val())); } @@ -247,7 +248,7 @@ public Class[] thrown() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { CArray ret = new CArray(t); MCItemStack item = ObjectGenerator.GetGenerator().item(args[0], t); List recipes = Static.getServer().getRecipesFor(item); @@ -291,7 +292,7 @@ public Class[] thrown() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { CArray ret = new CArray(t); List recipes = Static.getServer().allRecipes(); for(MCRecipe recipe : recipes) { @@ -332,7 +333,7 @@ public Class[] thrown() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { Static.getServer().clearRecipes(); return CVoid.VOID; } @@ -368,7 +369,7 @@ public Class[] thrown() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { Static.getServer().resetRecipes(); return CVoid.VOID; } diff --git a/src/main/java/com/laytonsmith/core/functions/Reflection.java b/src/main/java/com/laytonsmith/core/functions/Reflection.java index 83e53f70ee..c17e5569b8 100644 --- a/src/main/java/com/laytonsmith/core/functions/Reflection.java +++ b/src/main/java/com/laytonsmith/core/functions/Reflection.java @@ -30,6 +30,7 @@ import com.laytonsmith.core.constructs.IVariable; import com.laytonsmith.core.constructs.NativeTypeList; import com.laytonsmith.core.constructs.Target; +import com.laytonsmith.core.constructs.generics.GenericParameters; import com.laytonsmith.core.environments.CommandHelperEnvironment; import com.laytonsmith.core.environments.Environment; import com.laytonsmith.core.environments.GlobalEnv; @@ -203,7 +204,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment env, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { if(args.length < 1) { throw new CREInsufficientArgumentsException("Not enough parameters was sent to " + getName(), t); } @@ -296,7 +297,7 @@ public Mixed exec(Target t, Environment env, Mixed... args) throws ConfigRuntime l.forEach((String t1) -> { a.push(new CString(t1, Target.UNKNOWN), Target.UNKNOWN); }); - return new ArrayHandling.array_sort().exec(t, env, a); + return new ArrayHandling.array_sort().exec(t, env, null, a); } else if(args.length == 2) { Keyword k = KeywordList.getKeywordByName(args[1].val()); if(k == null) { @@ -355,7 +356,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { CClassType type = ArgumentValidation.getClassType(args[0], t); CArray ret = CArray.GetAssociativeArray(t); ret.set("fqcn", type.getFQCN().getFQCN()); @@ -442,7 +443,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment env, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { String element = args[0].val(); DocField docField; try { @@ -596,7 +597,7 @@ private void initf(Environment env) { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { CArray ret = CArray.GetAssociativeArray(t); if(FUNCS.keySet().size() < 10) { initf(environment); @@ -653,7 +654,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { CArray ret = new CArray(t); for(Event event : EventList.GetEvents()) { @@ -703,7 +704,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { CArray ret = new CArray(t); for(Script s : Static.getAliasCore().getScripts()) { ret.push(new CString(s.getSignature(), t), t); @@ -752,7 +753,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { PersistenceNetwork pn = environment.getEnv(StaticRuntimeEnv.class).GetPersistenceNetwork(); return new CString(pn.getKeySource(args[0].val().split("\\.")).toString(), t); } @@ -803,7 +804,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { CArray ret = new CArray(t); for(Map.Entry p : environment.getEnv(GlobalEnv.class).GetProcs().entrySet()) { ret.push(new CString(p.getKey(), t), t); @@ -868,7 +869,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { CArray ret = new CArray(t); ObjectDefinitionTable odt = environment.getEnv(CompilerEnvironment.class).getObjectDefinitionTable(); for(ObjectDefinition od : odt.getObjectDefinitionSet()) { @@ -936,7 +937,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { String type = ArgumentValidation.getStringObject(args[0], t); try { return CClassType.get(FullyQualifiedClassName.forName(args[0].val(), t, environment)); diff --git a/src/main/java/com/laytonsmith/core/functions/Regex.java b/src/main/java/com/laytonsmith/core/functions/Regex.java index d4fc2aba6b..c0ceacefef 100644 --- a/src/main/java/com/laytonsmith/core/functions/Regex.java +++ b/src/main/java/com/laytonsmith/core/functions/Regex.java @@ -16,6 +16,7 @@ import com.laytonsmith.core.constructs.CString; import com.laytonsmith.core.constructs.Construct; import com.laytonsmith.core.constructs.Target; +import com.laytonsmith.core.constructs.generics.GenericParameters; import com.laytonsmith.core.environments.Environment; import com.laytonsmith.core.exceptions.CRE.CRECastException; import com.laytonsmith.core.exceptions.CRE.CREFormatException; @@ -90,7 +91,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment env, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { Pattern pattern = getPattern(args[0], t); String subject = args[1].val(); Matcher m = pattern.matcher(subject); @@ -178,7 +179,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment env, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { Pattern pattern = getPattern(args[0], t); String subject = args[1].val(); CArray fret = new CArray(t); @@ -271,7 +272,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment env, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { Pattern pattern = getPattern(args[0], t); Mixed replacement = args[1]; String subject = args[2].val(); @@ -392,7 +393,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment env, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { Pattern pattern = getPattern(args[0], t); String subject = args[1].val(); /** @@ -492,7 +493,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment env, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { Pattern pattern = getPattern(args[0], t); String subject = args[1].val(); long ret = 0; @@ -551,7 +552,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { return new CString(java.util.regex.Pattern.quote(args[0].val()), t); } diff --git a/src/main/java/com/laytonsmith/core/functions/ResourceManager.java b/src/main/java/com/laytonsmith/core/functions/ResourceManager.java index 290d6ba6a3..ac740b4657 100644 --- a/src/main/java/com/laytonsmith/core/functions/ResourceManager.java +++ b/src/main/java/com/laytonsmith/core/functions/ResourceManager.java @@ -11,6 +11,7 @@ import com.laytonsmith.core.constructs.CResource; import com.laytonsmith.core.constructs.CVoid; import com.laytonsmith.core.constructs.Target; +import com.laytonsmith.core.constructs.generics.GenericParameters; import com.laytonsmith.core.environments.Environment; import com.laytonsmith.core.exceptions.CRE.CRECastException; import com.laytonsmith.core.exceptions.CRE.CREFormatException; @@ -110,7 +111,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { ResourceTypes type; Mixed data = null; try { @@ -209,7 +210,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { if(args[0].isInstanceOf(CResource.TYPE)) { CResource resource = (CResource) args[0]; if(RESOURCES.containsKey(resource.getId())) { diff --git a/src/main/java/com/laytonsmith/core/functions/SQL.java b/src/main/java/com/laytonsmith/core/functions/SQL.java index 18e1d36c3c..12fbc24942 100644 --- a/src/main/java/com/laytonsmith/core/functions/SQL.java +++ b/src/main/java/com/laytonsmith/core/functions/SQL.java @@ -28,6 +28,7 @@ import com.laytonsmith.core.constructs.CVoid; import com.laytonsmith.core.constructs.Construct; import com.laytonsmith.core.constructs.Target; +import com.laytonsmith.core.constructs.generics.GenericParameters; import com.laytonsmith.core.environments.Environment; import com.laytonsmith.core.environments.StaticRuntimeEnv; import com.laytonsmith.core.exceptions.ConfigCompileException; @@ -150,7 +151,7 @@ public void run() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { try { Profiles.Profile profile; if(args[0].isInstanceOf(CArray.TYPE)) { @@ -495,7 +496,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(final Target t, final Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(final Target t, final Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { startup(); Mixed arg = args[args.length - 1]; if(!(arg.isInstanceOf(CClosure.TYPE))) { @@ -512,7 +513,7 @@ public void run() { Mixed returnValue = CNull.NULL; Mixed exception = CNull.NULL; try { - returnValue = new query().exec(t, environment, newArgs); + returnValue = new query().exec(t, environment, null, newArgs); } catch (ConfigRuntimeException ex) { exception = ObjectGenerator.GetGenerator().exception(ex, environment, t); } diff --git a/src/main/java/com/laytonsmith/core/functions/Sandbox.java b/src/main/java/com/laytonsmith/core/functions/Sandbox.java index 037cf53459..1d5664ef5a 100644 --- a/src/main/java/com/laytonsmith/core/functions/Sandbox.java +++ b/src/main/java/com/laytonsmith/core/functions/Sandbox.java @@ -25,6 +25,7 @@ import com.laytonsmith.core.constructs.CString; import com.laytonsmith.core.constructs.CVoid; import com.laytonsmith.core.constructs.Target; +import com.laytonsmith.core.constructs.generics.GenericParameters; import com.laytonsmith.core.environments.CommandHelperEnvironment; import com.laytonsmith.core.environments.Environment; import com.laytonsmith.core.environments.GlobalEnv; @@ -106,7 +107,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { BoundEvent.ActiveEvent original = environment.getEnv(GlobalEnv.class).GetEvent(); if(original == null) { throw new CREBindException("is_cancelled cannot be called outside an event handler", t); @@ -155,7 +156,7 @@ public Integer[] numArgs() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { return new CString(GenerateMooSaying(args[0].val()) + " \\ ^__^\n" + " \\ (oo)\\_______\n" @@ -176,7 +177,7 @@ public Integer[] numArgs() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { return new CString( GenerateMooSaying(args[0].val()) + " ^__^ /\n" @@ -198,7 +199,7 @@ public Integer[] numArgs() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { return new CString(" .-*)) `*-.\n" + " /* ((* *'.\n" + "| *)) * *\\\n" @@ -215,7 +216,7 @@ public Mixed exec(Target t, Environment environment, Mixed... args) throws Confi public static class norway extends DummyFunction { @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCChatColor red = MCChatColor.RED; MCChatColor white = MCChatColor.WHITE; MCChatColor blue = MCChatColor.BLUE; @@ -279,7 +280,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { Random r; try { r = (Random) ArgumentValidation.getObject(args[0], t, CResource.class).getResource(); @@ -407,7 +408,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment env, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { try { File file = Static.GetFileFromArgument(args[0].val(), env, t, null).getCanonicalFile(); if(!Static.InCmdLine(env, true) && !Security.CheckSecurity(file)) { @@ -486,7 +487,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { if(!Static.InCmdLine(environment, true)) { throw new CRESecurityException(getName() + " is only available in cmdline mode.", t); } diff --git a/src/main/java/com/laytonsmith/core/functions/Scheduling.java b/src/main/java/com/laytonsmith/core/functions/Scheduling.java index 6c9cff182a..8f50b54b50 100644 --- a/src/main/java/com/laytonsmith/core/functions/Scheduling.java +++ b/src/main/java/com/laytonsmith/core/functions/Scheduling.java @@ -30,6 +30,7 @@ import com.laytonsmith.core.constructs.CVoid; import com.laytonsmith.core.constructs.Construct; import com.laytonsmith.core.constructs.Target; +import com.laytonsmith.core.constructs.generics.GenericParameters; import com.laytonsmith.core.environments.Environment; import com.laytonsmith.core.environments.GlobalEnv; import com.laytonsmith.core.environments.StaticRuntimeEnv; @@ -130,7 +131,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment env, Mixed... args) throws CancelCommandException, ConfigRuntimeException { + public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws CancelCommandException, ConfigRuntimeException { return new CInt(System.currentTimeMillis(), t); } } @@ -175,7 +176,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment env, Mixed... args) throws CancelCommandException, ConfigRuntimeException { + public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws CancelCommandException, ConfigRuntimeException { return new CInt(System.nanoTime(), t); } } @@ -220,7 +221,7 @@ public MSVersion since() { } @Override - public Mixed exec(Target t, Environment env, Mixed... args) throws CancelCommandException, ConfigRuntimeException { + public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws CancelCommandException, ConfigRuntimeException { Mixed x = args[0]; double time = ArgumentValidation.getNumber(x, t); try { @@ -277,7 +278,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(final Target t, final Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(final Target t, final Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { long time = ArgumentValidation.getInt(args[0], t); int offset = 0; long delay = time; @@ -383,7 +384,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(final Target t, final Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(final Target t, final Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { final TaskManager taskManager = environment.getEnv(StaticRuntimeEnv.class).GetTaskManager(); long time = ArgumentValidation.getInt(args[0], t); if(time < 0) { @@ -497,7 +498,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { if(args.length == 0 && environment.getEnv(GlobalEnv.class).GetCustom("timeout-id") != null) { StaticLayer.ClearFutureRunnable((Integer) environment.getEnv(GlobalEnv.class).GetCustom("timeout-id")); } else if(args.length == 1) { @@ -613,7 +614,7 @@ public Boolean runAsync() { } @Override - public CString exec(Target t, Environment env, Mixed... args) { + public CString exec(Target t, Environment env, GenericParameters generics, Mixed... args) { Date now = new Date(); if(args.length >= 2 && !(args[1] instanceof CNull)) { now = new Date(ArgumentValidation.getInt(args[1], t)); @@ -684,7 +685,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { SimpleDateFormat dateFormat; Locale locale = Locale.getDefault(); if(args.length >= 3) { @@ -765,7 +766,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { String[] timezones = ArrayUtils.EMPTY_STRING_ARRAY; try { timezones = TimeZone.getAvailableIDs(); @@ -852,7 +853,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { //First things first, check the format of the arguments. if(!(args[0].isInstanceOf(CString.TYPE))) { throw new CRECastException("Expected string for argument 1 in " + getName(), t); @@ -1204,7 +1205,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { Integer id = (Integer) environment.getEnv(GlobalEnv.class).GetCustom("cron-task-id"); if(args.length == 1) { id = (int) ArgumentValidation.getInt(args[0], t); diff --git a/src/main/java/com/laytonsmith/core/functions/Scoreboards.java b/src/main/java/com/laytonsmith/core/functions/Scoreboards.java index a0998c38f2..17b9dd9202 100644 --- a/src/main/java/com/laytonsmith/core/functions/Scoreboards.java +++ b/src/main/java/com/laytonsmith/core/functions/Scoreboards.java @@ -28,6 +28,7 @@ import com.laytonsmith.core.constructs.CVoid; import com.laytonsmith.core.constructs.Construct; import com.laytonsmith.core.constructs.Target; +import com.laytonsmith.core.constructs.generics.GenericParameters; import com.laytonsmith.core.environments.CommandHelperEnvironment; import com.laytonsmith.core.environments.Environment; import com.laytonsmith.core.exceptions.CRE.CREFormatException; @@ -256,7 +257,7 @@ public Class[] thrown() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCPlayer p = Static.GetPlayer(args[0], t); String ret; try { @@ -300,7 +301,7 @@ public Class[] thrown() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCPlayer p = Static.GetPlayer(args[0], t); p.setScoreboard(assignBoard(1, t, args)); return CVoid.VOID; @@ -337,7 +338,7 @@ public Class[] thrown() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { CArray ret = new CArray(t); for(String id : BOARDS.keySet()) { ret.push(new CString(id, t), t); @@ -372,7 +373,7 @@ public MSVersion since() { public static class get_objectives extends SBFunction { @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCScoreboard s; if(args.length == 0) { s = getBoard(MAIN, t); @@ -436,7 +437,7 @@ public MSVersion since() { public static class get_teams extends SBFunction { @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCScoreboard s; if(args.length == 0) { s = getBoard(MAIN, t); @@ -483,7 +484,7 @@ public Class[] thrown() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCScoreboard newBoard = Static.getServer().getNewScoreboard(); if(newBoard == null) { throw new CRENullPointerException( @@ -520,7 +521,7 @@ public MSVersion since() { public static class create_objective extends SBFunction { @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCScoreboard s = assignBoard(2, t, args); String name = args[0].val(); MCCriteria criteria = MCCriteria.DUMMY; @@ -568,7 +569,7 @@ public MSVersion since() { public static class create_team extends SBFunction { @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCScoreboard s = assignBoard(1, t, args); String name = args[0].val(); try { @@ -611,7 +612,7 @@ public Class[] thrown() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCScoreboard s = assignBoard(2, t, args); MCObjective o = s.getObjective(args[0].val()); if(o == null) { @@ -692,7 +693,7 @@ public Class[] thrown() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCScoreboard s = assignBoard(2, t, args); MCTeam o = s.getTeam(args[0].val()); if(o == null) { @@ -797,7 +798,7 @@ public MSVersion since() { public static class team_add_player extends SBFunction { @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCScoreboard s = assignBoard(2, t, args); MCTeam team = s.getTeam(args[0].val()); if(team == null) { @@ -833,7 +834,7 @@ public MSVersion since() { public static class team_remove_player extends SBFunction { @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCScoreboard s = assignBoard(2, t, args); MCTeam team = s.getTeam(args[0].val()); if(team == null) { @@ -868,7 +869,7 @@ public MSVersion since() { public static class get_pteam extends SBFunction { @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCScoreboard s = assignBoard(1, t, args); MCTeam team = s.getPlayerTeam(args[0].val()); if(team == null) { @@ -904,7 +905,7 @@ public MSVersion since() { public static class remove_scoreboard extends SBFunction { @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { String id = args[0].val(); boolean nullify = true; if(args.length == 2) { @@ -960,7 +961,7 @@ public MSVersion since() { public static class remove_objective extends SBFunction { @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCScoreboard s = assignBoard(1, t, args); MCObjective o = s.getObjective(args[0].val()); try { @@ -998,7 +999,7 @@ public MSVersion since() { public static class remove_team extends SBFunction { @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCScoreboard s = assignBoard(1, t, args); MCTeam team = s.getTeam(args[0].val()); try { @@ -1041,7 +1042,7 @@ public Class[] thrown() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCScoreboard s = assignBoard(2, t, args); MCObjective o = s.getObjective(args[0].val()); if(o == null) { @@ -1086,7 +1087,7 @@ public Class[] thrown() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCScoreboard s = assignBoard(3, t, args); MCObjective o = s.getObjective(args[0].val()); if(o == null) { @@ -1127,7 +1128,7 @@ public MSVersion since() { public static class reset_all_pscores extends SBFunction { @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { assignBoard(1, t, args).resetScores(args[0].val()); return CVoid.VOID; } @@ -1163,7 +1164,7 @@ public Class[] thrown() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCScoreboard s = assignBoard(2, t, args); MCTeam team = s.getTeam(args[0].val()); if(team == null) { @@ -1254,7 +1255,7 @@ public MSVersion since() { public static class get_scoreboard_entries extends SBFunction { @Override - public Mixed exec(Target t, Environment env, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCScoreboard s = assignBoard(0, t, args); Set entries = s.getEntries(); CArray ret = new CArray(t, entries.size()); diff --git a/src/main/java/com/laytonsmith/core/functions/Statistics.java b/src/main/java/com/laytonsmith/core/functions/Statistics.java index 53484ad166..dc42d9c05d 100644 --- a/src/main/java/com/laytonsmith/core/functions/Statistics.java +++ b/src/main/java/com/laytonsmith/core/functions/Statistics.java @@ -10,6 +10,7 @@ import com.laytonsmith.core.constructs.CDouble; import com.laytonsmith.core.constructs.CNumber; import com.laytonsmith.core.constructs.Target; +import com.laytonsmith.core.constructs.generics.GenericParameters; import com.laytonsmith.core.environments.Environment; import com.laytonsmith.core.exceptions.CRE.CRECastException; import com.laytonsmith.core.exceptions.CRE.CREIndexOverflowException; @@ -67,7 +68,7 @@ public Set optimizationOptions() { public static class average extends StatisticsFunction { @Override - public CNumber exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public CNumber exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { long count; if(args.length == 1 && args[0].isInstanceOf(CArray.TYPE)) { CArray c = ArgumentValidation.getArray(args[0], t); @@ -75,7 +76,7 @@ public CNumber exec(Target t, Environment environment, Mixed... args) throws Con } else { count = args.length; } - double sum = new sum().exec(t, environment, args).getNumber(); + double sum = new sum().exec(t, environment, null, args).getNumber(); return new CDouble(sum / count, t); } @@ -117,7 +118,7 @@ public ExampleScript[] examples() throws ConfigCompileException { public static class sum extends StatisticsFunction { @Override - public CNumber exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public CNumber exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { List values = new ArrayList<>(); if(args.length == 1 && args[0].isInstanceOf(CArray.TYPE)) { CArray c = ArgumentValidation.getArray(args[0], t); @@ -173,7 +174,7 @@ public ExampleScript[] examples() throws ConfigCompileException { public static class median extends StatisticsFunction { @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { List values = new ArrayList<>(); if(args.length == 1 && args[0].isInstanceOf(CArray.TYPE)) { CArray c = ArgumentValidation.getArray(args[0], t); @@ -237,7 +238,7 @@ public ExampleScript[] examples() throws ConfigCompileException { public static class mode extends StatisticsFunction { @Override - public CArray exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public CArray exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { List values = new ArrayList<>(); if(args.length == 1 && args[0].isInstanceOf(CArray.TYPE)) { CArray c = ArgumentValidation.getArray(args[0], t); @@ -336,7 +337,7 @@ public Class[] thrown() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { double percentile = ArgumentValidation.getDouble(args[0], t); List values = new ArrayList<>(); if(args.length == 2 && args[1].isInstanceOf(CArray.TYPE)) { diff --git a/src/main/java/com/laytonsmith/core/functions/StringHandling.java b/src/main/java/com/laytonsmith/core/functions/StringHandling.java index cc9e8b0fbe..3d2c74eed5 100644 --- a/src/main/java/com/laytonsmith/core/functions/StringHandling.java +++ b/src/main/java/com/laytonsmith/core/functions/StringHandling.java @@ -33,6 +33,7 @@ import com.laytonsmith.core.constructs.Construct; import com.laytonsmith.core.constructs.InstanceofUtil; import com.laytonsmith.core.constructs.Target; +import com.laytonsmith.core.constructs.generics.GenericParameters; import com.laytonsmith.core.environments.Environment; import com.laytonsmith.core.exceptions.CRE.CRECastException; import com.laytonsmith.core.exceptions.CRE.CREError; @@ -97,7 +98,7 @@ public Class[] thrown() { } @Override - public Mixed exec(Target t, Environment env, Mixed... args) throws CancelCommandException, ConfigRuntimeException { + public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws CancelCommandException, ConfigRuntimeException { StringBuilder b = new StringBuilder(); for(int i = 0; i < args.length; i++) { b.append(args[i].val()); @@ -172,7 +173,7 @@ public Integer[] numArgs() { } @Override - public Mixed exec(Target t, Environment env, Mixed... args) throws CancelCommandException, ConfigRuntimeException { + public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws CancelCommandException, ConfigRuntimeException { StringBuilder b = new StringBuilder(); for(int i = 0; i < args.length; i++) { if(i > 0) { @@ -301,7 +302,7 @@ public Integer[] numArgs() { } @Override - public Mixed exec(Target t, Environment env, Mixed... args) throws CancelCommandException, ConfigRuntimeException { + public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws CancelCommandException, ConfigRuntimeException { String thing = args[0].val(); String what = args[1].val(); String that = args[2].val(); @@ -362,7 +363,7 @@ public Integer[] numArgs() { } @Override - public Mixed exec(Target t, Environment env, Mixed... args) throws CancelCommandException, ConfigRuntimeException { + public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws CancelCommandException, ConfigRuntimeException { String string = args[0].val(); boolean useAdvanced = false; if(args.length >= 2) { @@ -469,7 +470,7 @@ public MSVersion since() { } @Override - public Mixed exec(Target t, Environment env, Mixed... args) throws CancelCommandException, ConfigRuntimeException { + public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws CancelCommandException, ConfigRuntimeException { return new CString(args[0].val().trim(), args[0].getTarget()); } @@ -526,7 +527,7 @@ public MSVersion since() { } @Override - public Mixed exec(Target t, Environment env, Mixed... args) throws CancelCommandException, ConfigRuntimeException { + public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws CancelCommandException, ConfigRuntimeException { return new CString(StringUtils.trimRight(args[0].val()), args[0].getTarget()); } @@ -583,7 +584,7 @@ public MSVersion since() { } @Override - public Mixed exec(Target t, Environment env, Mixed... args) throws CancelCommandException, ConfigRuntimeException { + public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws CancelCommandException, ConfigRuntimeException { return new CString(StringUtils.trimLeft(args[0].val()), t); } @@ -646,7 +647,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment env, Mixed... args) throws CancelCommandException, ConfigRuntimeException { + public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws CancelCommandException, ConfigRuntimeException { if(args[0].isInstanceOf(Sizeable.TYPE)) { return new CInt(((Sizeable) args[0]).size(), t); } else { @@ -708,7 +709,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment env, Mixed... args) throws CancelCommandException, ConfigRuntimeException { + public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws CancelCommandException, ConfigRuntimeException { if(!(args[0].isInstanceOf(CString.TYPE))) { throw new CREFormatException(this.getName() + " expects a string as first argument, but type " + args[0].typeof() + " was found.", t); @@ -771,7 +772,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment env, Mixed... args) throws CancelCommandException, ConfigRuntimeException { + public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws CancelCommandException, ConfigRuntimeException { if(!(args[0].isInstanceOf(CString.TYPE))) { throw new CREFormatException(this.getName() + " expects a string as first argument, but type " + args[0].typeof() + " was found.", t); @@ -837,7 +838,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment env, Mixed... args) throws CancelCommandException, ConfigRuntimeException { + public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws CancelCommandException, ConfigRuntimeException { try { String s = args[0].val(); int begin = ArgumentValidation.getInt32(args[1], t); @@ -893,7 +894,7 @@ public String docs() { } @Override - public Mixed exec(Target t, Environment env, Mixed... args) throws CancelCommandException, ConfigRuntimeException { + public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws CancelCommandException, ConfigRuntimeException { Static.AssertNonCNull(t, args); String teststring = args[0].val(); @@ -961,7 +962,7 @@ public String docs() { } @Override - public Mixed exec(Target t, Environment env, Mixed... args) throws CancelCommandException, ConfigRuntimeException { + public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws CancelCommandException, ConfigRuntimeException { Static.AssertNonCNull(t, args); String teststring = args[0].val(); @@ -1021,7 +1022,7 @@ public String getName() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws CancelCommandException, ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws CancelCommandException, ConfigRuntimeException { if(args[0] instanceof CNull) { throw new CRECastException(this.getName() + " expects a string as first argument, but found null.", t); } @@ -1125,7 +1126,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment env, Mixed... args) throws CancelCommandException, ConfigRuntimeException { + public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws CancelCommandException, ConfigRuntimeException { Static.AssertNonCNull(t, args); String haystack = args[0].val(); String needle = args[1].val(); @@ -1309,7 +1310,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment env, Mixed... args) throws CancelCommandException, ConfigRuntimeException { + public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws CancelCommandException, ConfigRuntimeException { //http://stackoverflow.com/questions/2667015/is-regex-too-slow-real-life-examples-where-simple-non-regex-alternative-is-bett //According to this, regex isn't necessarily slower, but we do want to escape the pattern either way, since the main advantage //of this function is convenience (not speed) however, if we can eek out a little extra speed too, excellent. @@ -1386,7 +1387,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { if(args.length < 2) { throw new CREInsufficientArgumentsException(getName() + " expects 2 or more arguments", t); } @@ -1936,7 +1937,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { String val = args[0].val(); String encoding = "UTF-8"; if(args.length == 2) { @@ -1992,7 +1993,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { CByteArray ba = ArgumentValidation.getByteArray(args[0], t); String encoding = "UTF-8"; if(args.length == 2) { @@ -2047,7 +2048,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { if(args.length < 2) { throw new CREInsufficientArgumentsException(getName() + " must have 2 arguments at minimum", t); } @@ -2136,7 +2137,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { try { return new CString(new String(Character.toChars(ArgumentValidation.getInt32(args[0], t))), t); } catch (IllegalArgumentException ex) { @@ -2204,7 +2205,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { if(args[0].val().toCharArray().length == 0) { throw new CRERangeException("Empty string cannot be converted to unicode.", t); } @@ -2262,7 +2263,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { return new CInt(StringUtils.LevenshteinDistance(args[0].val(), args[1].val()), t); } @@ -2319,7 +2320,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { return new CInt(args[0].val().compareTo(args[1].val()), t); } @@ -2364,7 +2365,7 @@ public ExampleScript[] examples() throws ConfigCompileException { public static class string_compare_ic extends string_compare { @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { return new CInt(args[0].val().compareToIgnoreCase(args[1].val()), t); } @@ -2417,7 +2418,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { if(args[0] instanceof CNull) { return CNull.NULL; } @@ -2526,7 +2527,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { if(args[0].isInstanceOf(CArray.TYPE)) { CArray array = ArgumentValidation.getArray(args[0], t); return new CSecureString(array, t); @@ -2604,7 +2605,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { if(args[0].isInstanceOf(CSecureString.TYPE)) { CSecureString secure = ArgumentValidation.getObject(args[0], t, CSecureString.class); return secure.getDecryptedCharCArray(); @@ -2713,7 +2714,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { UUIDType type = UUIDType.RANDOM; String input = null; if(args.length > 0) { diff --git a/src/main/java/com/laytonsmith/core/functions/TaskHandling.java b/src/main/java/com/laytonsmith/core/functions/TaskHandling.java index d058dcb761..a784bf8042 100644 --- a/src/main/java/com/laytonsmith/core/functions/TaskHandling.java +++ b/src/main/java/com/laytonsmith/core/functions/TaskHandling.java @@ -10,6 +10,7 @@ import com.laytonsmith.core.constructs.CInt; import com.laytonsmith.core.constructs.CVoid; import com.laytonsmith.core.constructs.Target; +import com.laytonsmith.core.constructs.generics.GenericParameters; import com.laytonsmith.core.environments.Environment; import com.laytonsmith.core.environments.StaticRuntimeEnv; import com.laytonsmith.core.exceptions.CRE.CRECastException; @@ -50,7 +51,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { TaskManager tm = environment.getEnv(StaticRuntimeEnv.class).GetTaskManager(); CArray ret = new CArray(t); for(TaskHandler task : tm.getTasks()) { @@ -134,7 +135,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { String type = args[0].val(); int id = ArgumentValidation.getInt32(args[1], t); TaskManager tm = environment.getEnv(StaticRuntimeEnv.class).GetTaskManager(); diff --git a/src/main/java/com/laytonsmith/core/functions/Threading.java b/src/main/java/com/laytonsmith/core/functions/Threading.java index 7b00b4757d..412ca96add 100644 --- a/src/main/java/com/laytonsmith/core/functions/Threading.java +++ b/src/main/java/com/laytonsmith/core/functions/Threading.java @@ -23,6 +23,7 @@ import com.laytonsmith.core.constructs.CString; import com.laytonsmith.core.constructs.CVoid; import com.laytonsmith.core.constructs.Target; +import com.laytonsmith.core.constructs.generics.GenericParameters; import com.laytonsmith.core.environments.Environment; import com.laytonsmith.core.environments.StaticRuntimeEnv; import com.laytonsmith.core.exceptions.CRE.CRECastException; @@ -84,7 +85,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(final Target t, final Environment env, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(final Target t, final Environment env, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { final String threadId = args[0].val(); final com.laytonsmith.core.natives.interfaces.Callable closure = ArgumentValidation.getObject(args[1], t, com.laytonsmith.core.natives.interfaces.Callable.class); @@ -102,7 +103,7 @@ public void run() { ConfigRuntimeException.HandleUncaughtException(ex, env); } catch (CancelCommandException ex) { if(ex.getMessage() != null) { - new Echoes.console().exec(t, env, new CString(ex.getMessage(), t), CBoolean.FALSE); + new Echoes.console().exec(t, env, null, new CString(ex.getMessage(), t), CBoolean.FALSE); } } finally { dm.deactivateThread(Thread.currentThread()); @@ -183,7 +184,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { return new CString(Thread.currentThread().getName(), t); } @@ -237,7 +238,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(final Target t, final Environment env, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(final Target t, final Environment env, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { final com.laytonsmith.core.natives.interfaces.Callable closure = ArgumentValidation.getObject(args[0], t, com.laytonsmith.core.natives.interfaces.Callable.class); StaticLayer.GetConvertor().runOnMainThreadLater( @@ -302,7 +303,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(final Target t, final Environment env, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(final Target t, final Environment env, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { final com.laytonsmith.core.natives.interfaces.Callable closure = ArgumentValidation.getObject(args[0], t, com.laytonsmith.core.natives.interfaces.Callable.class); Object ret; @@ -511,7 +512,7 @@ public Mixed execs(Target t, Environment env, Script parent, ParseTree... nodes) } @Override - public Mixed exec(final Target t, final Environment env, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(final Target t, final Environment env, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { return CVoid.VOID; } @@ -631,7 +632,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment env, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { // Get the sync object tree and the code to synchronize. Mixed cSyncObject = args[0]; com.laytonsmith.core.natives.interfaces.Callable callable @@ -726,7 +727,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { String threadId = args[0].val(); Thread th; synchronized(THREAD_ID_MAP) { @@ -791,7 +792,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { String threadId = args[0].val(); Thread th; synchronized(THREAD_ID_MAP) { @@ -844,7 +845,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { Thread th; if(args.length == 1) { String threadId = args[0].val(); @@ -904,7 +905,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { if(args.length == 1) { String threadId = args[0].val(); Thread th; @@ -963,7 +964,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { return CBoolean.get(Thread.interrupted()); } diff --git a/src/main/java/com/laytonsmith/core/functions/Trades.java b/src/main/java/com/laytonsmith/core/functions/Trades.java index 8493ca3b57..f7376b9a9c 100644 --- a/src/main/java/com/laytonsmith/core/functions/Trades.java +++ b/src/main/java/com/laytonsmith/core/functions/Trades.java @@ -21,6 +21,7 @@ import com.laytonsmith.core.constructs.CString; import com.laytonsmith.core.constructs.CVoid; import com.laytonsmith.core.constructs.Target; +import com.laytonsmith.core.constructs.generics.GenericParameters; import com.laytonsmith.core.environments.CommandHelperEnvironment; import com.laytonsmith.core.environments.Environment; import com.laytonsmith.core.exceptions.CRE.CREBadEntityException; @@ -57,7 +58,7 @@ public Class[] thrown() { } @Override - public Mixed exec(Target t, Environment env, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { CArray ret = new CArray(t); for(MCMerchantRecipe mr : GetMerchant(args[0], t).getRecipes()) { ret.push(trade(mr, t), t); @@ -97,7 +98,7 @@ public Class[] thrown() { } @Override - public Mixed exec(Target t, Environment env, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCMerchant merchant = GetMerchant(args[0], t); CArray trades = ArgumentValidation.getArray(args[1], t); List recipes = new ArrayList<>(); @@ -169,7 +170,7 @@ public Class[] thrown() { } @Override - public Mixed exec(Target t, Environment env, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { CArray ret = CArray.GetAssociativeArray(t); for(Map.Entry entry : VIRTUAL_MERCHANTS.entrySet()) { if(entry.getValue() == null) { @@ -212,7 +213,7 @@ public Class[] thrown() { } @Override - public Mixed exec(Target t, Environment env, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { if(VIRTUAL_MERCHANTS.containsKey(args[0].val())) { throw new CREIllegalArgumentException("There is already a merchant with id " + args[0].val(), t); } else { @@ -255,7 +256,7 @@ public Class[] thrown() { } @Override - public Mixed exec(Target t, Environment env, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { return CBoolean.get(VIRTUAL_MERCHANTS.remove(args[0].val()) != null); } @@ -291,7 +292,7 @@ public Class[] thrown() { } @Override - public Mixed exec(Target t, Environment env, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCPlayer player; boolean force = false; if(args.length > 1) { @@ -344,7 +345,7 @@ public Class[] thrown() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCMerchant merchant = GetMerchant(args[0], t); return merchant.isTrading() ? new CString(merchant.getTrader().getUniqueId().toString(), t) : CNull.NULL; } diff --git a/src/main/java/com/laytonsmith/core/functions/Weather.java b/src/main/java/com/laytonsmith/core/functions/Weather.java index a221e23b08..42f484f6be 100644 --- a/src/main/java/com/laytonsmith/core/functions/Weather.java +++ b/src/main/java/com/laytonsmith/core/functions/Weather.java @@ -18,6 +18,7 @@ import com.laytonsmith.core.constructs.CString; import com.laytonsmith.core.constructs.CVoid; import com.laytonsmith.core.constructs.Target; +import com.laytonsmith.core.constructs.generics.GenericParameters; import com.laytonsmith.core.environments.CommandHelperEnvironment; import com.laytonsmith.core.environments.Environment; import com.laytonsmith.core.exceptions.CRE.CRECastException; @@ -59,7 +60,7 @@ public Class[] thrown() { } @Override - public Mixed exec(Target t, Environment env, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { int x; int y; int z; @@ -136,7 +137,7 @@ public Integer[] numArgs() { } @Override - public Mixed exec(Target t, Environment env, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { boolean b = ArgumentValidation.getBoolean(args[0], t); MCWorld w = null; int duration = -1; @@ -227,7 +228,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCWorld w = null; if(args.length == 1) { if(environment.getEnv(CommandHelperEnvironment.class).GetCommandSender() instanceof MCPlayer) { @@ -289,7 +290,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCWorld w = null; if(args.length == 1) { w = Static.getServer().getWorld(args[0].val()); @@ -346,7 +347,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCWorld w = null; if(args.length == 1) { w = Static.getServer().getWorld(args[0].val()); diff --git a/src/main/java/com/laytonsmith/core/functions/Web.java b/src/main/java/com/laytonsmith/core/functions/Web.java index d07fe19bc2..1aa175d507 100644 --- a/src/main/java/com/laytonsmith/core/functions/Web.java +++ b/src/main/java/com/laytonsmith/core/functions/Web.java @@ -36,6 +36,7 @@ import com.laytonsmith.core.constructs.CVoid; import com.laytonsmith.core.constructs.Construct; import com.laytonsmith.core.constructs.Target; +import com.laytonsmith.core.constructs.generics.GenericParameters; import com.laytonsmith.core.environments.Environment; import com.laytonsmith.core.environments.GlobalEnv; import com.laytonsmith.core.environments.StaticRuntimeEnv; @@ -218,7 +219,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(final Target t, final Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(final Target t, final Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { final URL url; try { url = new URL(args[0].val()); @@ -637,7 +638,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { CArray array = ArgumentValidation.getArray(args[0], t); CookieJar jar = getCookieJar(array, t); jar.clearSessionCookies(); @@ -686,7 +687,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { try { return new CString(URLEncoder.encode(args[0].val(), "UTF-8"), t); } catch (UnsupportedEncodingException ex) { @@ -743,7 +744,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { try { return new CString(URLDecoder.decode(args[0].val(), "UTF-8"), t); } catch (UnsupportedEncodingException ex) { @@ -801,7 +802,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { // Argument processing CArray options; if(args.length == 1) { diff --git a/src/main/java/com/laytonsmith/core/functions/World.java b/src/main/java/com/laytonsmith/core/functions/World.java index a91c9db9d5..2a52f73c86 100644 --- a/src/main/java/com/laytonsmith/core/functions/World.java +++ b/src/main/java/com/laytonsmith/core/functions/World.java @@ -43,6 +43,7 @@ import com.laytonsmith.core.constructs.CString; import com.laytonsmith.core.constructs.CVoid; import com.laytonsmith.core.constructs.Target; +import com.laytonsmith.core.constructs.generics.GenericParameters; import com.laytonsmith.core.environments.CommandHelperEnvironment; import com.laytonsmith.core.environments.Environment; import com.laytonsmith.core.exceptions.CRE.CRECastException; @@ -119,7 +120,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCWorld w; if(args.length == 1) { w = Static.getServer().getWorld(args[0].val()); @@ -156,7 +157,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCWorld w = null; if(args.length == 1) { MCPlayer p = environment.getEnv(CommandHelperEnvironment.class).GetPlayer(); @@ -260,7 +261,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCPlayer m = environment.getEnv(CommandHelperEnvironment.class).GetPlayer(); MCWorld world; int x; @@ -319,7 +320,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCPlayer m = environment.getEnv(CommandHelperEnvironment.class).GetPlayer(); MCWorld world; int x; @@ -402,7 +403,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCPlayer m = environment.getEnv(CommandHelperEnvironment.class).GetPlayer(); MCWorld world; int x; @@ -483,7 +484,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCPlayer m = environment.getEnv(CommandHelperEnvironment.class).GetPlayer(); MCWorld world; if(args.length == 1) { @@ -557,7 +558,7 @@ public String docs() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCPlayer m = environment.getEnv(CommandHelperEnvironment.class).GetPlayer(); MCWorld world; int x; @@ -630,7 +631,7 @@ public String docs() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCWorld world; if(args.length == 1) { world = Static.getServer().getWorld(args[0].val()); @@ -719,7 +720,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCPlayer m = environment.getEnv(CommandHelperEnvironment.class).GetPlayer(); MCWorld world; int x; @@ -812,7 +813,7 @@ public Boolean runAsync() { Random rnd = new Random(); @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCPlayer m = environment.getEnv(CommandHelperEnvironment.class).GetPlayer(); MCWorld world; int x; @@ -928,7 +929,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCWorld w = null; if(environment.getEnv(CommandHelperEnvironment.class).GetPlayer() != null) { w = environment.getEnv(CommandHelperEnvironment.class).GetPlayer().getWorld(); @@ -1019,7 +1020,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCWorld w = null; if(environment.getEnv(CommandHelperEnvironment.class).GetPlayer() != null) { w = environment.getEnv(CommandHelperEnvironment.class).GetPlayer().getWorld(); @@ -1073,7 +1074,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCWorld w = null; if(environment.getEnv(CommandHelperEnvironment.class).GetPlayer() != null) { w = environment.getEnv(CommandHelperEnvironment.class).GetPlayer().getWorld(); @@ -1134,7 +1135,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCWorld w = null; if(environment.getEnv(CommandHelperEnvironment.class).GetPlayer() != null) { w = environment.getEnv(CommandHelperEnvironment.class).GetPlayer().getWorld(); @@ -1168,7 +1169,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment env, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCWorldCreator creator = StaticLayer.GetConvertor().getWorldCreator(args[0].val()); if(args.length >= 3) { MCWorldType type; @@ -1248,7 +1249,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { CArray worlds = new CArray(t); for(MCWorld w : Static.getServer().getWorlds()) { worlds.push(new CString(w.getName(), t), t); @@ -1291,7 +1292,7 @@ public Integer[] numArgs() { } @Override - public Mixed exec(Target t, Environment env, Mixed... args) throws CancelCommandException, ConfigRuntimeException { + public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws CancelCommandException, ConfigRuntimeException { MCCommandSender cs = env.getEnv(CommandHelperEnvironment.class).GetCommandSender(); MCPlayer p = null; MCWorld w = null; @@ -1378,7 +1379,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment env, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCPlayer p = env.getEnv(CommandHelperEnvironment.class).GetPlayer(); MCLocation loc = ObjectGenerator.GetGenerator().location(args[0], p != null ? p.getWorld() : null, t); @@ -1459,7 +1460,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCWorld w = Static.getServer().getWorld(args[0].val()); if(w == null) { throw new CREInvalidWorldException("Unknown world: " + args[0], t); @@ -1519,7 +1520,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { boolean save = true; if(args.length == 2) { save = ArgumentValidation.getBoolean(args[1], t); @@ -1593,7 +1594,7 @@ public Version since() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCWorld world = Static.getServer().getWorld(args[0].val()); if(world == null) { throw new CREInvalidWorldException("Unknown world: " + args[0].val(), t); @@ -1643,7 +1644,7 @@ public Version since() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCDifficulty difficulty; if(args.length == 1) { try { @@ -1709,7 +1710,7 @@ public Version since() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCWorld world = Static.getServer().getWorld(args[0].val()); if(world == null) { throw new CREInvalidWorldException("Unknown world: " + args[0].val(), t); @@ -1758,7 +1759,7 @@ public Version since() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { if(args.length == 1) { boolean pvp = ArgumentValidation.getBoolean(args[0], t); for(MCWorld world : Static.getServer().getWorlds()) { @@ -1817,7 +1818,7 @@ public Version since() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCWorld world = Static.getServer().getWorld(args[0].val()); if(world == null) { throw new CREInvalidWorldException("Unknown world: " + args[0].val(), t); @@ -1908,7 +1909,7 @@ public Version since() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { int offset = args.length - 2; List worlds = Static.getServer().getWorlds(); MCWorld world = worlds.get(0); @@ -1982,7 +1983,7 @@ public Class[] thrown() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCWorld world = Static.getServer().getWorld(args[0].val()); if(world == null) { throw new CREInvalidWorldException("Unknown world: " + args[0].val(), t); @@ -2066,7 +2067,7 @@ public Version since() { } @Override - public Mixed exec(Target t, Environment env, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCPlayer p = env.getEnv(CommandHelperEnvironment.class).GetPlayer(); MCLocation loc = ObjectGenerator.GetGenerator().location(args[0], p != null ? p.getWorld() : null, t); double distance = 1; @@ -2154,7 +2155,7 @@ public Version since() { } @Override - public Mixed exec(Target t, Environment env, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCPlayer p = env.getEnv(CommandHelperEnvironment.class).GetPlayer(); @@ -2221,7 +2222,7 @@ public Version since() { } @Override - public Mixed exec(Target t, Environment env, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCPlayer p = env.getEnv(CommandHelperEnvironment.class).GetPlayer(); @@ -2282,7 +2283,7 @@ public Version since() { } @Override - public Mixed exec(Target t, Environment env, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { CArray loc = ArgumentValidation.getArray(args[0], t); double yaw; double pitch; @@ -2347,7 +2348,7 @@ public Version since() { } @Override - public Mixed exec(Target t, Environment env, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCLocation loc1 = ObjectGenerator.GetGenerator().location(args[0], null, t); MCLocation loc2 = ObjectGenerator.GetGenerator().location(args[1], null, t); try { @@ -2377,7 +2378,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCWorld world = Static.getWorld(args[0], t); world.save(); return CVoid.VOID; @@ -2424,7 +2425,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target target, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target target, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCPlayer player = environment.getEnv(CommandHelperEnvironment.class).GetPlayer(); MCWorld world = null; if(player != null) { @@ -2474,7 +2475,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCWorld w = Static.getServer().getWorld(args[0].val()); if(w == null) { throw new CREInvalidWorldException("Unknown world: " + args[0], t); @@ -2532,7 +2533,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCWorld w = Static.getServer().getWorld(args[0].val()); if(w == null) { throw new CREInvalidWorldException("Unknown world: " + args[0], t); @@ -2611,7 +2612,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCWorld w = Static.getServer().getWorld(args[0].val()); if(w == null) { throw new CREInvalidWorldException("Unknown world: " + args[0].val(), t); @@ -2659,7 +2660,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { if(args.length == 1) { boolean autosave = ArgumentValidation.getBooleanish(args[0], t); for(MCWorld world : Static.getServer().getWorlds()) { diff --git a/src/main/java/com/laytonsmith/core/functions/XGUI.java b/src/main/java/com/laytonsmith/core/functions/XGUI.java index 326cb11135..006b1018db 100644 --- a/src/main/java/com/laytonsmith/core/functions/XGUI.java +++ b/src/main/java/com/laytonsmith/core/functions/XGUI.java @@ -12,6 +12,7 @@ import com.laytonsmith.core.constructs.CInt; import com.laytonsmith.core.constructs.CVoid; import com.laytonsmith.core.constructs.Target; +import com.laytonsmith.core.constructs.generics.GenericParameters; import com.laytonsmith.core.environments.Environment; import com.laytonsmith.core.exceptions.CRE.CREFormatException; import com.laytonsmith.core.exceptions.CRE.CREIOException; @@ -78,7 +79,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { JFrame frame = new JFrame(); int id = WINDOW_IDS.incrementAndGet(); String title = ""; @@ -148,7 +149,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { int id = ArgumentValidation.getInt32(args[0], t); boolean show = true; if(args.length > 1) { @@ -202,7 +203,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { int windowID = ArgumentValidation.getInt32(args[0], t); int x = ArgumentValidation.getInt32(args[1], t); int y = ArgumentValidation.getInt32(args[2], t); @@ -267,7 +268,7 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { String url = args[0].val(); try { if(Desktop.isDesktopSupported()) { diff --git a/src/main/java/com/laytonsmith/core/functions/asm/Cmdline.java b/src/main/java/com/laytonsmith/core/functions/asm/Cmdline.java index 3daf163263..1b9eff9476 100644 --- a/src/main/java/com/laytonsmith/core/functions/asm/Cmdline.java +++ b/src/main/java/com/laytonsmith/core/functions/asm/Cmdline.java @@ -15,6 +15,7 @@ import com.laytonsmith.core.asm.LLVMVersion; import com.laytonsmith.core.compiler.CompilerEnvironment; import com.laytonsmith.core.constructs.Target; +import com.laytonsmith.core.constructs.generics.GenericParameters; import com.laytonsmith.core.environments.Environment; import com.laytonsmith.core.exceptions.CRE.CREThrowable; import com.laytonsmith.core.exceptions.ConfigCompileException; @@ -30,7 +31,7 @@ public class Cmdline { public static class exit extends LLVMFunction { @Override - public IRData buildIR(IRBuilder builder, Target t, Environment env, ParseTree... nodes) throws ConfigCompileException { + public IRData buildIR(IRBuilder builder, Target t, Environment env, GenericParameters generics, ParseTree... nodes) throws ConfigCompileException { OSUtils.OS os = env.getEnv(CompilerEnvironment.class).getTargetOS(); LLVMEnvironment llvmenv = env.getEnv(LLVMEnvironment.class); String code = "i32 0"; @@ -72,7 +73,7 @@ public Version since() { public static class sys_out extends LLVMFunction { @Override - public IRData buildIR(IRBuilder builder, Target t, Environment env, ParseTree... nodes) throws ConfigCompileException { + public IRData buildIR(IRBuilder builder, Target t, Environment env, GenericParameters generics, ParseTree... nodes) throws ConfigCompileException { OSUtils.OS os = env.getEnv(CompilerEnvironment.class).getTargetOS(); LLVMEnvironment llvmenv = env.getEnv(LLVMEnvironment.class); List lines = new ArrayList<>(); diff --git a/src/main/java/com/laytonsmith/core/functions/asm/Compiler.java b/src/main/java/com/laytonsmith/core/functions/asm/Compiler.java index a0e73f70a3..7174825733 100644 --- a/src/main/java/com/laytonsmith/core/functions/asm/Compiler.java +++ b/src/main/java/com/laytonsmith/core/functions/asm/Compiler.java @@ -11,6 +11,7 @@ import com.laytonsmith.core.asm.LLVMFunction; import com.laytonsmith.core.asm.LLVMVersion; import com.laytonsmith.core.constructs.Target; +import com.laytonsmith.core.constructs.generics.GenericParameters; import com.laytonsmith.core.environments.Environment; import com.laytonsmith.core.exceptions.CRE.CREThrowable; import com.laytonsmith.core.exceptions.ConfigCompileException; @@ -23,7 +24,7 @@ public class Compiler { public static class __statements__ extends LLVMFunction { @Override - public IRData buildIR(IRBuilder builder, Target t, Environment env, ParseTree... nodes) throws ConfigCompileException { + public IRData buildIR(IRBuilder builder, Target t, Environment env, GenericParameters generics, ParseTree... nodes) throws ConfigCompileException { for(ParseTree node : nodes) { AsmCompiler.getIR(builder, node, env); } @@ -56,7 +57,7 @@ public Version since() { public static class dyn extends LLVMFunction { @Override - public IRData buildIR(IRBuilder builder, Target t, Environment env, ParseTree... nodes) throws ConfigCompileException { + public IRData buildIR(IRBuilder builder, Target t, Environment env, GenericParameters generics, ParseTree... nodes) throws ConfigCompileException { IRData data = AsmCompiler.getIR(builder, nodes[0], env); LLVMEnvironment llvmenv = env.getEnv(LLVMEnvironment.class); int alloca = llvmenv.getNewLocalVariableReference(data.getResultType()); diff --git a/src/main/java/com/laytonsmith/core/functions/asm/DataHandling.java b/src/main/java/com/laytonsmith/core/functions/asm/DataHandling.java index 83c1f36237..ce82912167 100644 --- a/src/main/java/com/laytonsmith/core/functions/asm/DataHandling.java +++ b/src/main/java/com/laytonsmith/core/functions/asm/DataHandling.java @@ -14,6 +14,7 @@ import com.laytonsmith.core.constructs.CClassType; import com.laytonsmith.core.constructs.IVariable; import com.laytonsmith.core.constructs.Target; +import com.laytonsmith.core.constructs.generics.GenericParameters; import com.laytonsmith.core.environments.Environment; import com.laytonsmith.core.exceptions.CRE.CRECastException; import com.laytonsmith.core.exceptions.CRE.CREThrowable; @@ -28,7 +29,7 @@ public class DataHandling { public static class assign extends LLVMFunction { @Override - public IRData buildIR(IRBuilder builder, Target t, Environment env, ParseTree... nodes) throws ConfigCompileException { + public IRData buildIR(IRBuilder builder, Target t, Environment env, GenericParameters generics, ParseTree... nodes) throws ConfigCompileException { LLVMEnvironment llvmenv = env.getEnv(LLVMEnvironment.class); int offset; CClassType type; diff --git a/src/main/java/com/laytonsmith/core/functions/asm/Math.java b/src/main/java/com/laytonsmith/core/functions/asm/Math.java index 40d88372b1..89c4fdc4e3 100644 --- a/src/main/java/com/laytonsmith/core/functions/asm/Math.java +++ b/src/main/java/com/laytonsmith/core/functions/asm/Math.java @@ -15,6 +15,7 @@ import com.laytonsmith.core.asm.LLVMVersion; import com.laytonsmith.core.compiler.CompilerEnvironment; import com.laytonsmith.core.constructs.Target; +import com.laytonsmith.core.constructs.generics.GenericParameters; import com.laytonsmith.core.environments.Environment; import com.laytonsmith.core.exceptions.CRE.CREThrowable; import com.laytonsmith.core.exceptions.ConfigCompileException; @@ -43,7 +44,7 @@ public void addStartupCode(IRBuilder builder, Environment startupEnv, Target t) } @Override - public IRData buildIR(IRBuilder builder, Target t, Environment env, ParseTree... nodes) throws ConfigCompileException { + public IRData buildIR(IRBuilder builder, Target t, Environment env, GenericParameters generics, ParseTree... nodes) throws ConfigCompileException { LLVMEnvironment llvmenv = env.getEnv(LLVMEnvironment.class); CompilerEnvironment cEnv = env.getEnv(CompilerEnvironment.class); llvmenv.addGlobalDeclaration(AsmCommonLibTemplates.RAND, env); diff --git a/src/main/java/com/laytonsmith/core/functions/asm/Meta.java b/src/main/java/com/laytonsmith/core/functions/asm/Meta.java index 16f61e6483..0406499fbb 100644 --- a/src/main/java/com/laytonsmith/core/functions/asm/Meta.java +++ b/src/main/java/com/laytonsmith/core/functions/asm/Meta.java @@ -10,6 +10,7 @@ import com.laytonsmith.core.asm.LLVMFunction; import com.laytonsmith.core.asm.LLVMVersion; import com.laytonsmith.core.constructs.Target; +import com.laytonsmith.core.constructs.generics.GenericParameters; import com.laytonsmith.core.environments.Environment; import com.laytonsmith.core.exceptions.CRE.CREThrowable; import com.laytonsmith.core.exceptions.ConfigCompileException; @@ -22,7 +23,7 @@ public class Meta { public static class noop extends LLVMFunction { @Override - public IRData buildIR(IRBuilder builder, Target t, Environment env, ParseTree... nodes) + public IRData buildIR(IRBuilder builder, Target t, Environment env, GenericParameters generics, ParseTree... nodes) throws ConfigCompileException { builder.appendLine(t, "add i1 0, 0 ; noop()"); return IRDataBuilder.asVoid(); diff --git a/src/main/java/com/laytonsmith/tools/Interpreter.java b/src/main/java/com/laytonsmith/tools/Interpreter.java index 706ba3ef39..ad5f2443a4 100644 --- a/src/main/java/com/laytonsmith/tools/Interpreter.java +++ b/src/main/java/com/laytonsmith/tools/Interpreter.java @@ -949,19 +949,19 @@ public boolean doBuiltin(String script) { a = new Construct[]{new CString(args.get(0), Target.UNKNOWN)}; } try { - new Cmdline.cd().exec(Target.UNKNOWN, env, a); + new Cmdline.cd().exec(Target.UNKNOWN, env, null, a); } catch (CREIOException ex) { pl(RED + ex.getMessage()); } return true; case "pwd": - pl(new Cmdline.pwd().exec(Target.UNKNOWN, env).val()); + pl(new Cmdline.pwd().exec(Target.UNKNOWN, env, null).val()); return true; case "exit": // We need previous code to intercept, we cannot do this here. throw new Error("I should not run"); case "logout": - new Cmdline.exit().exec(Target.UNKNOWN, env, new CInt(0, Target.UNKNOWN)); + new Cmdline.exit().exec(Target.UNKNOWN, env, null, new CInt(0, Target.UNKNOWN)); return true; // won't actually run case "echo": // TODO Probably need some variable interpolation maybe? Otherwise, I don't think this command @@ -974,7 +974,7 @@ public boolean doBuiltin(String script) { } String output = StringUtils.Join(args, " "); if(colorize) { - output = new Echoes.colorize().exec(Target.UNKNOWN, env, new CString(output, Target.UNKNOWN)).val(); + output = new Echoes.colorize().exec(Target.UNKNOWN, env, null, new CString(output, Target.UNKNOWN)).val(); } pl(output); return true; diff --git a/src/main/java/com/laytonsmith/tools/docgen/DocGenTemplates.java b/src/main/java/com/laytonsmith/tools/docgen/DocGenTemplates.java index d3cb329ea1..1445e37850 100644 --- a/src/main/java/com/laytonsmith/tools/docgen/DocGenTemplates.java +++ b/src/main/java/com/laytonsmith/tools/docgen/DocGenTemplates.java @@ -735,7 +735,7 @@ public String generate(String... args) { @Override public String generate(String... args) { String template = args[0]; - return new Scheduling.simple_date().exec(Target.UNKNOWN, null, new CString(template, Target.UNKNOWN)).val(); + return new Scheduling.simple_date().exec(Target.UNKNOWN, null, null, new CString(template, Target.UNKNOWN)).val(); } }; @@ -772,7 +772,7 @@ public String generate(String... args) throws GenerateException { public static final Generator CURRENTYEAR = new Generator() { @Override public String generate(String... args) throws GenerateException { - return new Scheduling.simple_date().exec(Target.UNKNOWN, null, new CString("yyyy", Target.UNKNOWN)).val(); + return new Scheduling.simple_date().exec(Target.UNKNOWN, null, null, new CString("yyyy", Target.UNKNOWN)).val(); } }; diff --git a/src/main/java/com/laytonsmith/tools/pnviewer/PNViewer.java b/src/main/java/com/laytonsmith/tools/pnviewer/PNViewer.java index 8f3f57e30a..571b72e798 100644 --- a/src/main/java/com/laytonsmith/tools/pnviewer/PNViewer.java +++ b/src/main/java/com/laytonsmith/tools/pnviewer/PNViewer.java @@ -338,7 +338,7 @@ public void run() { } catch (MarshalException ex) { Logger.getLogger(PNViewer.class.getName()).log(Level.SEVERE, null, ex); } - valueTypeLabel.setText(new DataHandling.typeof().exec(Target.UNKNOWN, null, c).val()); + valueTypeLabel.setText(new DataHandling.typeof().exec(Target.UNKNOWN, null, null, c).val()); valueTextArea.setText(c.val()); } } diff --git a/src/test/java/com/laytonsmith/core/functions/ArrayHandlingTest.java b/src/test/java/com/laytonsmith/core/functions/ArrayHandlingTest.java index d72a113913..ccc78090ef 100644 --- a/src/test/java/com/laytonsmith/core/functions/ArrayHandlingTest.java +++ b/src/test/java/com/laytonsmith/core/functions/ArrayHandlingTest.java @@ -64,7 +64,7 @@ public void testDocs() { public void testArraySize() throws Exception, CancelCommandException { ArrayHandling.array_size a = new ArrayHandling.array_size(); CArray arr = commonArray; - Mixed ret = a.exec(Target.UNKNOWN, env, arr); + Mixed ret = a.exec(Target.UNKNOWN, env, null, arr); assertReturn(ret, C.INT); assertCEquals(C.onstruct(3), ret); } @@ -72,7 +72,7 @@ public void testArraySize() throws Exception, CancelCommandException { @Test(expected = Exception.class, timeout = 10000) public void testArraySizeEx() throws CancelCommandException { ArrayHandling.array_size a = new ArrayHandling.array_size(); - a.exec(Target.UNKNOWN, env, C.Int(0)); + a.exec(Target.UNKNOWN, env, null, C.Int(0)); } @Test//(timeout = 10000) @@ -121,46 +121,46 @@ public void testArrayReferenceBeingCorrectWithArrayGet() throws Exception { @Test(timeout = 10000) public void testArrayContains() throws CancelCommandException { ArrayHandling.array_contains a = new ArrayHandling.array_contains(); - assertCEquals(C.onstruct(true), a.exec(Target.UNKNOWN, env, commonArray, C.onstruct(1))); - assertCEquals(C.onstruct(false), a.exec(Target.UNKNOWN, env, commonArray, C.onstruct(55))); + assertCEquals(C.onstruct(true), a.exec(Target.UNKNOWN, env, null, commonArray, C.onstruct(1))); + assertCEquals(C.onstruct(false), a.exec(Target.UNKNOWN, env, null, commonArray, C.onstruct(55))); } @Test(timeout = 10000) public void testArraySContains() throws CancelCommandException { ArrayHandling.array_scontains a = new ArrayHandling.array_scontains(); - assertCEquals(C.onstruct(true), a.exec(Target.UNKNOWN, env, commonArray, C.onstruct(1))); - assertCEquals(C.onstruct(false), a.exec(Target.UNKNOWN, env, commonArray, C.onstruct(55))); - assertCEquals(C.onstruct(false), a.exec(Target.UNKNOWN, env, commonArray, new CString("2", Target.UNKNOWN))); + assertCEquals(C.onstruct(true), a.exec(Target.UNKNOWN, env, null, commonArray, C.onstruct(1))); + assertCEquals(C.onstruct(false), a.exec(Target.UNKNOWN, env, null, commonArray, C.onstruct(55))); + assertCEquals(C.onstruct(false), a.exec(Target.UNKNOWN, env, null, commonArray, new CString("2", Target.UNKNOWN))); } @Test(expected = Exception.class, timeout = 10000) public void testArrayContainsEx() throws CancelCommandException { ArrayHandling.array_contains a = new ArrayHandling.array_contains(); - a.exec(Target.UNKNOWN, env, C.Int(0), C.Int(1)); + a.exec(Target.UNKNOWN, env, null, C.Int(0), C.Int(1)); } @Test(timeout = 10000) public void testArrayGet() throws CancelCommandException { ArrayHandling.array_get a = new ArrayHandling.array_get(); - assertCEquals(C.onstruct(1), a.exec(Target.UNKNOWN, env, commonArray, C.onstruct(0))); + assertCEquals(C.onstruct(1), a.exec(Target.UNKNOWN, env, null, commonArray, C.onstruct(0))); } @Test(expected = Exception.class, timeout = 10000) public void testArrayGetEx() throws CancelCommandException { ArrayHandling.array_get a = new ArrayHandling.array_get(); - a.exec(Target.UNKNOWN, env, C.Int(0), C.Int(1)); + a.exec(Target.UNKNOWN, env, null, C.Int(0), C.Int(1)); } @Test(expected = ConfigRuntimeException.class, timeout = 10000) public void testArrayGetBad() throws CancelCommandException { ArrayHandling.array_get a = new ArrayHandling.array_get(); - a.exec(Target.UNKNOWN, env, commonArray, C.onstruct(55)); + a.exec(Target.UNKNOWN, env, null, commonArray, C.onstruct(55)); } @Test(timeout = 10000) public void testArrayPush() throws CancelCommandException { ArrayHandling.array_push a = new ArrayHandling.array_push(); - assertReturn(a.exec(Target.UNKNOWN, env, commonArray, C.onstruct(4)), C.VOID); + assertReturn(a.exec(Target.UNKNOWN, env, null, commonArray, C.onstruct(4)), C.VOID); assertCEquals(C.onstruct(1), commonArray.get(0, Target.UNKNOWN)); assertCEquals(C.onstruct(2), commonArray.get(1, Target.UNKNOWN)); assertCEquals(C.onstruct(3), commonArray.get(2, Target.UNKNOWN)); @@ -178,7 +178,7 @@ public void testArrayPush2() throws Exception { @Test(expected = Exception.class) public void testArrayPushEx() throws CancelCommandException { ArrayHandling.array_push a = new ArrayHandling.array_push(); - a.exec(Target.UNKNOWN, env, C.Int(0), C.Int(1)); + a.exec(Target.UNKNOWN, env, null, C.Int(0), C.Int(1)); } @Test(timeout = 10000) diff --git a/src/test/java/com/laytonsmith/core/functions/BasicLogicTest.java b/src/test/java/com/laytonsmith/core/functions/BasicLogicTest.java index 5fc508e83c..bf5563b69c 100644 --- a/src/test/java/com/laytonsmith/core/functions/BasicLogicTest.java +++ b/src/test/java/com/laytonsmith/core/functions/BasicLogicTest.java @@ -205,48 +205,48 @@ public void testOr2() throws Exception { @Test(timeout = 10000) public void testNot() throws CancelCommandException { BasicLogic.not a = new BasicLogic.not(); - assertCFalse(a.exec(Target.UNKNOWN, env, cTrue)); - assertCTrue(a.exec(Target.UNKNOWN, env, cFalse)); + assertCFalse(a.exec(Target.UNKNOWN, env, null, cTrue)); + assertCTrue(a.exec(Target.UNKNOWN, env, null, cFalse)); } @Test(timeout = 10000) public void testGt() throws CancelCommandException { BasicLogic.gt a = new BasicLogic.gt(); - assertCFalse(a.exec(Target.UNKNOWN, env, argOne, argOne2)); - assertCTrue(a.exec(Target.UNKNOWN, env, argTwo, argOne)); - assertCFalse(a.exec(Target.UNKNOWN, env, argOne, argTwo)); - assertCFalse(a.exec(Target.UNKNOWN, env, argNegOne, argOne)); - assertCTrue(a.exec(Target.UNKNOWN, env, argOne, argNegOne)); + assertCFalse(a.exec(Target.UNKNOWN, env, null, argOne, argOne2)); + assertCTrue(a.exec(Target.UNKNOWN, env, null, argTwo, argOne)); + assertCFalse(a.exec(Target.UNKNOWN, env, null, argOne, argTwo)); + assertCFalse(a.exec(Target.UNKNOWN, env, null, argNegOne, argOne)); + assertCTrue(a.exec(Target.UNKNOWN, env, null, argOne, argNegOne)); } @Test(timeout = 10000) public void testGte() throws CancelCommandException { BasicLogic.gte a = new BasicLogic.gte(); - assertCTrue(a.exec(Target.UNKNOWN, env, argOne, argOne2)); - assertCTrue(a.exec(Target.UNKNOWN, env, argTwo, argOne)); - assertCFalse(a.exec(Target.UNKNOWN, env, argOne, argTwo)); - assertCFalse(a.exec(Target.UNKNOWN, env, argNegOne, argOne)); - assertCTrue(a.exec(Target.UNKNOWN, env, argOne, argNegOne)); + assertCTrue(a.exec(Target.UNKNOWN, env, null, argOne, argOne2)); + assertCTrue(a.exec(Target.UNKNOWN, env, null, argTwo, argOne)); + assertCFalse(a.exec(Target.UNKNOWN, env, null, argOne, argTwo)); + assertCFalse(a.exec(Target.UNKNOWN, env, null, argNegOne, argOne)); + assertCTrue(a.exec(Target.UNKNOWN, env, null, argOne, argNegOne)); } @Test(timeout = 10000) public void testLt() throws CancelCommandException { BasicLogic.lt a = new BasicLogic.lt(); - assertCFalse(a.exec(Target.UNKNOWN, env, argOne, argOne2)); - assertCFalse(a.exec(Target.UNKNOWN, env, argTwo, argOne)); - assertCTrue(a.exec(Target.UNKNOWN, env, argOne, argTwo)); - assertCTrue(a.exec(Target.UNKNOWN, env, argNegOne, argOne)); - assertCFalse(a.exec(Target.UNKNOWN, env, argOne, argNegOne)); + assertCFalse(a.exec(Target.UNKNOWN, env, null, argOne, argOne2)); + assertCFalse(a.exec(Target.UNKNOWN, env, null, argTwo, argOne)); + assertCTrue(a.exec(Target.UNKNOWN, env, null, argOne, argTwo)); + assertCTrue(a.exec(Target.UNKNOWN, env, null, argNegOne, argOne)); + assertCFalse(a.exec(Target.UNKNOWN, env, null, argOne, argNegOne)); } @Test(timeout = 10000) public void testLte() throws CancelCommandException { BasicLogic.lte a = new BasicLogic.lte(); - assertCTrue(a.exec(Target.UNKNOWN, env, argOne, argOne2)); - assertCFalse(a.exec(Target.UNKNOWN, env, argTwo, argOne)); - assertCTrue(a.exec(Target.UNKNOWN, env, argOne, argTwo)); - assertCTrue(a.exec(Target.UNKNOWN, env, argNegOne, argOne)); - assertCFalse(a.exec(Target.UNKNOWN, env, argOne, argNegOne)); + assertCTrue(a.exec(Target.UNKNOWN, env, null, argOne, argOne2)); + assertCFalse(a.exec(Target.UNKNOWN, env, null, argTwo, argOne)); + assertCTrue(a.exec(Target.UNKNOWN, env, null, argOne, argTwo)); + assertCTrue(a.exec(Target.UNKNOWN, env, null, argNegOne, argOne)); + assertCFalse(a.exec(Target.UNKNOWN, env, null, argOne, argNegOne)); } @Test(timeout = 10000) diff --git a/src/test/java/com/laytonsmith/core/functions/EchoesTest.java b/src/test/java/com/laytonsmith/core/functions/EchoesTest.java index 5bcf2f94d6..03e1a2e0ea 100644 --- a/src/test/java/com/laytonsmith/core/functions/EchoesTest.java +++ b/src/test/java/com/laytonsmith/core/functions/EchoesTest.java @@ -68,7 +68,7 @@ public void testDocs() { @Test(timeout = 10000) public void testChat() throws CancelCommandException { Echoes.chat a = new Echoes.chat(); - a.exec(Target.UNKNOWN, env, C.onstruct("Hello World!")); + a.exec(Target.UNKNOWN, env, null, C.onstruct("Hello World!")); verify(fakePlayer).chat("Hello World!"); } @@ -78,7 +78,7 @@ public void testBroadcast() throws NoSuchFieldException, InstantiationException, Echoes.broadcast a = new Echoes.broadcast(); when(fakePlayer.getServer()).thenReturn(fakeServer); CommandHelperPlugin.myServer = fakeServer; - a.exec(Target.UNKNOWN, env, C.onstruct("Hello World!")); + a.exec(Target.UNKNOWN, env, null, C.onstruct("Hello World!")); verify(fakeServer).broadcastMessage("Hello World!"); } @@ -130,7 +130,7 @@ public void testRGBColor() throws Exception { } private static final String LOWERCASE_A = - new color().exec(Target.UNKNOWN, null, new CString("a", Target.UNKNOWN)).val(); + new color().exec(Target.UNKNOWN, null, null, new CString("a", Target.UNKNOWN)).val(); @Test public void testColorize1() throws Exception { @@ -164,7 +164,7 @@ public void testColorize6() throws Exception { @Test public void testColorizeRGB() throws Exception { - String expectedColor = new color().exec(Target.UNKNOWN, null, new CString("#ff11aa", Target.UNKNOWN)).val(); + String expectedColor = new color().exec(Target.UNKNOWN, null, null, new CString("#ff11aa", Target.UNKNOWN)).val(); assertEquals(expectedColor + "Hi", SRun("colorize('&#ff11aaHi', '&')", fakePlayer)); } diff --git a/src/test/java/com/laytonsmith/core/functions/MathTest.java b/src/test/java/com/laytonsmith/core/functions/MathTest.java index a65e637e11..a8fe1f42b0 100644 --- a/src/test/java/com/laytonsmith/core/functions/MathTest.java +++ b/src/test/java/com/laytonsmith/core/functions/MathTest.java @@ -74,28 +74,28 @@ public void tearDown() { @Test(timeout = 10000) public void testAbs() { Math.abs a = new Math.abs(); - assertCEquals(C.onstruct(5), a.exec(Target.UNKNOWN, env, C.onstruct(5))); - assertCEquals(C.onstruct(3), a.exec(Target.UNKNOWN, env, C.onstruct(-3))); - assertCEquals(C.onstruct(0), a.exec(Target.UNKNOWN, env, C.onstruct(0))); - assertCEquals(C.onstruct(3.5), a.exec(Target.UNKNOWN, env, C.onstruct(-3.5))); + assertCEquals(C.onstruct(5), a.exec(Target.UNKNOWN, env, null, C.onstruct(5))); + assertCEquals(C.onstruct(3), a.exec(Target.UNKNOWN, env, null, C.onstruct(-3))); + assertCEquals(C.onstruct(0), a.exec(Target.UNKNOWN, env, null, C.onstruct(0))); + assertCEquals(C.onstruct(3.5), a.exec(Target.UNKNOWN, env, null, C.onstruct(-3.5))); } @Test(timeout = 10000) public void testAdd() { Math.add a = new Math.add(); - assertCEquals(C.onstruct(7), a.exec(Target.UNKNOWN, env, C.onstruct(5), C.onstruct(2))); - assertCEquals(C.onstruct(6), a.exec(Target.UNKNOWN, env, C.onstruct(3), C.onstruct(3))); - assertCEquals(C.onstruct(-4), a.exec(Target.UNKNOWN, env, C.onstruct(-3), C.onstruct(-1))); - assertCEquals(C.onstruct(1), a.exec(Target.UNKNOWN, env, C.onstruct(1), C.onstruct(0))); - assertCEquals(C.onstruct(562949953421310L), a.exec(Target.UNKNOWN, env, C.onstruct(281474976710655L), C.onstruct(281474976710655L))); - assertCEquals(C.onstruct(3.1415), a.exec(Target.UNKNOWN, env, C.onstruct(3), C.onstruct(0.1415))); + assertCEquals(C.onstruct(7), a.exec(Target.UNKNOWN, env, null, C.onstruct(5), C.onstruct(2))); + assertCEquals(C.onstruct(6), a.exec(Target.UNKNOWN, env, null, C.onstruct(3), C.onstruct(3))); + assertCEquals(C.onstruct(-4), a.exec(Target.UNKNOWN, env, null, C.onstruct(-3), C.onstruct(-1))); + assertCEquals(C.onstruct(1), a.exec(Target.UNKNOWN, env, null, C.onstruct(1), C.onstruct(0))); + assertCEquals(C.onstruct(562949953421310L), a.exec(Target.UNKNOWN, env, null, C.onstruct(281474976710655L), C.onstruct(281474976710655L))); + assertCEquals(C.onstruct(3.1415), a.exec(Target.UNKNOWN, env, null, C.onstruct(3), C.onstruct(0.1415))); } @Test(timeout = 10000) public void testDec() throws Exception { Math.dec a = new Math.dec(); - IVariable v = (IVariable) a.exec(Target.UNKNOWN, env, new IVariable(Auto.TYPE, "var", C.onstruct(1), Target.UNKNOWN, env)); - IVariable v2 = (IVariable) a.exec(Target.UNKNOWN, env, new IVariable(Auto.TYPE, "var2", C.onstruct(2.5), Target.UNKNOWN, env)); + IVariable v = (IVariable) a.exec(Target.UNKNOWN, env, null, new IVariable(Auto.TYPE, "var", C.onstruct(1), Target.UNKNOWN, env)); + IVariable v2 = (IVariable) a.exec(Target.UNKNOWN, env, null, new IVariable(Auto.TYPE, "var2", C.onstruct(2.5), Target.UNKNOWN, env)); assertCEquals(C.onstruct(0), v.ival()); assertCEquals(C.onstruct(1.5), v2.ival()); StaticTest.SRun("assign(@var, 0) dec(@var, 2) msg(@var)", fakePlayer); @@ -105,16 +105,16 @@ public void testDec() throws Exception { @Test(timeout = 10000) public void testDivide() { Math.divide a = new Math.divide(); - assertCEquals(C.onstruct(2.5), a.exec(Target.UNKNOWN, env, C.onstruct(5), C.onstruct(2))); - assertCEquals(C.onstruct(1), a.exec(Target.UNKNOWN, env, C.onstruct(3), C.onstruct(3))); - assertCEquals(C.onstruct(3), a.exec(Target.UNKNOWN, env, C.onstruct(-3), C.onstruct(-1))); + assertCEquals(C.onstruct(2.5), a.exec(Target.UNKNOWN, env, null, C.onstruct(5), C.onstruct(2))); + assertCEquals(C.onstruct(1), a.exec(Target.UNKNOWN, env, null, C.onstruct(3), C.onstruct(3))); + assertCEquals(C.onstruct(3), a.exec(Target.UNKNOWN, env, null, C.onstruct(-3), C.onstruct(-1))); } @Test(timeout = 10000) public void testInc() throws Exception { Math.inc a = new Math.inc(); - IVariable v = (IVariable) a.exec(Target.UNKNOWN, env, new IVariable(Auto.TYPE, "var", C.onstruct(1), Target.UNKNOWN, env)); - IVariable v2 = (IVariable) a.exec(Target.UNKNOWN, env, new IVariable(Auto.TYPE, "var2", C.onstruct(2.5), Target.UNKNOWN, env)); + IVariable v = (IVariable) a.exec(Target.UNKNOWN, env, null, new IVariable(Auto.TYPE, "var", C.onstruct(1), Target.UNKNOWN, env)); + IVariable v2 = (IVariable) a.exec(Target.UNKNOWN, env, null, new IVariable(Auto.TYPE, "var2", C.onstruct(2.5), Target.UNKNOWN, env)); assertCEquals(C.onstruct(2), v.ival()); assertCEquals(C.onstruct(3.5), v2.ival()); StaticTest.SRun("assign(@var, 0) inc(@var, 2) msg(@var)", fakePlayer); @@ -130,50 +130,50 @@ public void testArrayGetInc() throws Exception { @Test(timeout = 10000) public void testMod() { Math.mod a = new Math.mod(); - assertCEquals(C.onstruct(1), a.exec(Target.UNKNOWN, env, C.onstruct(5), C.onstruct(2))); - assertCEquals(C.onstruct(0), a.exec(Target.UNKNOWN, env, C.onstruct(3), C.onstruct(3))); - assertCEquals(C.onstruct(-1), a.exec(Target.UNKNOWN, env, C.onstruct(-3), C.onstruct(-2))); + assertCEquals(C.onstruct(1), a.exec(Target.UNKNOWN, env, null, C.onstruct(5), C.onstruct(2))); + assertCEquals(C.onstruct(0), a.exec(Target.UNKNOWN, env, null, C.onstruct(3), C.onstruct(3))); + assertCEquals(C.onstruct(-1), a.exec(Target.UNKNOWN, env, null, C.onstruct(-3), C.onstruct(-2))); } @Test(timeout = 10000) public void testMultiply() { Math.multiply a = new Math.multiply(); - assertCEquals(C.onstruct(10), a.exec(Target.UNKNOWN, env, C.onstruct(5), C.onstruct(2))); - assertCEquals(C.onstruct(9), a.exec(Target.UNKNOWN, env, C.onstruct(3), C.onstruct(3))); - assertCEquals(C.onstruct(6), a.exec(Target.UNKNOWN, env, C.onstruct(-3), C.onstruct(-2))); - assertCEquals(C.onstruct(5), a.exec(Target.UNKNOWN, env, C.onstruct(10), C.onstruct(0.5))); - assertCEquals(C.onstruct(-562949953421311L), a.exec(Target.UNKNOWN, env, C.onstruct(281474976710655L), C.onstruct(281474976710655L))); - assertCEquals(C.onstruct(5312385410449346020L), a.exec(Target.UNKNOWN, env, C.onstruct(9876543210L), C.onstruct(9876543210L))); + assertCEquals(C.onstruct(10), a.exec(Target.UNKNOWN, env, null, C.onstruct(5), C.onstruct(2))); + assertCEquals(C.onstruct(9), a.exec(Target.UNKNOWN, env, null, C.onstruct(3), C.onstruct(3))); + assertCEquals(C.onstruct(6), a.exec(Target.UNKNOWN, env, null, C.onstruct(-3), C.onstruct(-2))); + assertCEquals(C.onstruct(5), a.exec(Target.UNKNOWN, env, null, C.onstruct(10), C.onstruct(0.5))); + assertCEquals(C.onstruct(-562949953421311L), a.exec(Target.UNKNOWN, env, null, C.onstruct(281474976710655L), C.onstruct(281474976710655L))); + assertCEquals(C.onstruct(5312385410449346020L), a.exec(Target.UNKNOWN, env, null, C.onstruct(9876543210L), C.onstruct(9876543210L))); } @Test(timeout = 10000) public void testPow() { Math.pow a = new Math.pow(); - assertCEquals(C.onstruct(25), a.exec(Target.UNKNOWN, env, C.onstruct(5), C.onstruct(2))); - assertCEquals(C.onstruct(27), a.exec(Target.UNKNOWN, env, C.onstruct(3), C.onstruct(3))); - assertCEquals(C.onstruct(1), a.exec(Target.UNKNOWN, env, C.onstruct(-1), C.onstruct(-2))); + assertCEquals(C.onstruct(25), a.exec(Target.UNKNOWN, env, null, C.onstruct(5), C.onstruct(2))); + assertCEquals(C.onstruct(27), a.exec(Target.UNKNOWN, env, null, C.onstruct(3), C.onstruct(3))); + assertCEquals(C.onstruct(1), a.exec(Target.UNKNOWN, env, null, C.onstruct(-1), C.onstruct(-2))); } @Test(timeout = 10000) public void testRand1() { Math.rand a = new Math.rand(); for(int i = 0; i < 1000; i++) { - long j = ArgumentValidation.getInt(a.exec(Target.UNKNOWN, env, C.onstruct(10)), t); + long j = ArgumentValidation.getInt(a.exec(Target.UNKNOWN, env, null, C.onstruct(10)), t); if(!(j < 10 && j >= 0)) { fail("Expected a number between 0 and 10, but got " + j); } - j = ArgumentValidation.getInt(a.exec(Target.UNKNOWN, env, C.onstruct(10), C.onstruct(20)), t); + j = ArgumentValidation.getInt(a.exec(Target.UNKNOWN, env, null, C.onstruct(10), C.onstruct(20)), t); if(!(j < 20 && j >= 10)) { fail("Expected a number between 10 and 20, but got " + j); } } try { - a.exec(Target.UNKNOWN, env, C.onstruct(20), C.onstruct(10)); + a.exec(Target.UNKNOWN, env, null, C.onstruct(20), C.onstruct(10)); fail("Didn't expect this test to pass"); } catch (ConfigRuntimeException e) { } try { - a.exec(Target.UNKNOWN, env, C.onstruct(-1)); + a.exec(Target.UNKNOWN, env, null, C.onstruct(-1)); fail("Didn't expect this test to pass"); } catch (ConfigRuntimeException e) { } @@ -188,25 +188,25 @@ public void testRand2() throws Exception { @Test(timeout = 10000) public void testSubtract() { Math.subtract a = new Math.subtract(); - assertCEquals(C.onstruct(3), a.exec(Target.UNKNOWN, env, C.onstruct(5), C.onstruct(2))); - assertCEquals(C.onstruct(0), a.exec(Target.UNKNOWN, env, C.onstruct(3), C.onstruct(3))); - assertCEquals(C.onstruct(-1), a.exec(Target.UNKNOWN, env, C.onstruct(-3), C.onstruct(-2))); - assertCEquals(C.onstruct(3), a.exec(Target.UNKNOWN, env, C.onstruct(3.1415), C.onstruct(0.1415))); - assertCEquals(C.onstruct(281474976710655L), a.exec(Target.UNKNOWN, env, C.onstruct(562949953421310L), C.onstruct(281474976710655L))); + assertCEquals(C.onstruct(3), a.exec(Target.UNKNOWN, env, null, C.onstruct(5), C.onstruct(2))); + assertCEquals(C.onstruct(0), a.exec(Target.UNKNOWN, env, null, C.onstruct(3), C.onstruct(3))); + assertCEquals(C.onstruct(-1), a.exec(Target.UNKNOWN, env, null, C.onstruct(-3), C.onstruct(-2))); + assertCEquals(C.onstruct(3), a.exec(Target.UNKNOWN, env, null, C.onstruct(3.1415), C.onstruct(0.1415))); + assertCEquals(C.onstruct(281474976710655L), a.exec(Target.UNKNOWN, env, null, C.onstruct(562949953421310L), C.onstruct(281474976710655L))); } @Test(timeout = 10000) public void testFloor() { Math.floor a = new Math.floor(); - assertCEquals(C.onstruct(3), a.exec(Target.UNKNOWN, env, C.onstruct(3.8415))); - assertCEquals(C.onstruct(-4), a.exec(Target.UNKNOWN, env, C.onstruct(-3.1415))); + assertCEquals(C.onstruct(3), a.exec(Target.UNKNOWN, env, null, C.onstruct(3.8415))); + assertCEquals(C.onstruct(-4), a.exec(Target.UNKNOWN, env, null, C.onstruct(-3.1415))); } @Test(timeout = 10000) public void testCeil() { Math.ceil a = new Math.ceil(); - assertCEquals(C.onstruct(4), a.exec(Target.UNKNOWN, env, C.onstruct(3.1415))); - assertCEquals(C.onstruct(-3), a.exec(Target.UNKNOWN, env, C.onstruct(-3.1415))); + assertCEquals(C.onstruct(4), a.exec(Target.UNKNOWN, env, null, C.onstruct(3.1415))); + assertCEquals(C.onstruct(-3), a.exec(Target.UNKNOWN, env, null, C.onstruct(-3.1415))); } @Test(timeout = 10000) diff --git a/src/test/java/com/laytonsmith/core/functions/StringHandlingTest.java b/src/test/java/com/laytonsmith/core/functions/StringHandlingTest.java index 93aed265f5..35297f5e2f 100644 --- a/src/test/java/com/laytonsmith/core/functions/StringHandlingTest.java +++ b/src/test/java/com/laytonsmith/core/functions/StringHandlingTest.java @@ -41,16 +41,16 @@ public void tearDown() { @Test(timeout = 10000) public void testConcat() throws Exception { StringHandling.concat a = new StringHandling.concat(); - assertCEquals(C.onstruct("1234"), a.exec(Target.UNKNOWN, null, C.onstruct(1), C.onstruct(2), C.onstruct(3), C.onstruct(4))); - assertCEquals(C.onstruct("astring"), a.exec(Target.UNKNOWN, null, C.onstruct("a"), C.String("string"))); + assertCEquals(C.onstruct("1234"), a.exec(Target.UNKNOWN, null, null, C.onstruct(1), C.onstruct(2), C.onstruct(3), C.onstruct(4))); + assertCEquals(C.onstruct("astring"), a.exec(Target.UNKNOWN, null, null, C.onstruct("a"), C.String("string"))); assertEquals("05", SRun("'0' . 5", null)); } @Test(timeout = 10000) public void testLength() { StringHandling.length a = new StringHandling.length(); - assertCEquals(C.onstruct(5), a.exec(Target.UNKNOWN, null, C.onstruct("12345"))); - assertCEquals(C.onstruct(2), a.exec(Target.UNKNOWN, null, C.Array(C.onstruct(0), C.onstruct(1)))); + assertCEquals(C.onstruct(5), a.exec(Target.UNKNOWN, null, null, C.onstruct("12345"))); + assertCEquals(C.onstruct(2), a.exec(Target.UNKNOWN, null, null, C.Array(C.onstruct(0), C.onstruct(1)))); } @Test//(timeout = 10000) @@ -58,8 +58,8 @@ public void testParseArgs() throws Exception { SRun("msg(parse_args('o \"\\\\t\"', true))", fakePlayer); verify(fakePlayer).sendMessage("{o, \\t}"); StringHandling.parse_args a = new StringHandling.parse_args(); - assertCEquals(C.Array(C.onstruct("one"), C.onstruct("two")), a.exec(Target.UNKNOWN, null, C.onstruct("one two"))); - assertCEquals(C.Array(C.onstruct("one"), C.onstruct("two")), a.exec(Target.UNKNOWN, null, C.onstruct("one two"))); + assertCEquals(C.Array(C.onstruct("one"), C.onstruct("two")), a.exec(Target.UNKNOWN, null, null, C.onstruct("one two"))); + assertCEquals(C.Array(C.onstruct("one"), C.onstruct("two")), a.exec(Target.UNKNOWN, null, null, C.onstruct("one two"))); SRun("msg(parse_args('one \"two\"', true))", fakePlayer); verify(fakePlayer).sendMessage("{one, two}"); } @@ -71,9 +71,9 @@ public void testRead() { @Test(timeout = 10000) public void testReplace() { StringHandling.replace a = new StringHandling.replace(); - assertCEquals(C.onstruct("yay"), a.exec(Target.UNKNOWN, null, C.onstruct("yayathing"), C.onstruct("athing"), C.onstruct(""))); - assertCEquals(C.onstruct("yaymonkey"), a.exec(Target.UNKNOWN, null, C.onstruct("yayathing"), C.onstruct("athing"), C.onstruct("monkey"))); - assertCEquals(C.onstruct("yayathing"), a.exec(Target.UNKNOWN, null, C.onstruct("yayathing"), C.onstruct("wut"), C.onstruct("chicken"))); + assertCEquals(C.onstruct("yay"), a.exec(Target.UNKNOWN, null, null, C.onstruct("yayathing"), C.onstruct("athing"), C.onstruct(""))); + assertCEquals(C.onstruct("yaymonkey"), a.exec(Target.UNKNOWN, null, null, C.onstruct("yayathing"), C.onstruct("athing"), C.onstruct("monkey"))); + assertCEquals(C.onstruct("yayathing"), a.exec(Target.UNKNOWN, null, null, C.onstruct("yayathing"), C.onstruct("wut"), C.onstruct("chicken"))); } @Test(timeout = 10000) @@ -86,30 +86,30 @@ public void testSconcat() throws Exception { @Test(timeout = 10000) public void testSubstr() { StringHandling.substr a = new StringHandling.substr(); - assertCEquals(C.onstruct("urge"), a.exec(Target.UNKNOWN, null, C.onstruct("hamburger"), C.onstruct(4), C.onstruct(8))); - assertCEquals(C.onstruct("mile"), a.exec(Target.UNKNOWN, null, C.onstruct("smiles"), C.onstruct(1), C.onstruct(5))); - assertCEquals(C.onstruct("ning"), a.exec(Target.UNKNOWN, null, C.onstruct("lightning"), C.onstruct(5))); + assertCEquals(C.onstruct("urge"), a.exec(Target.UNKNOWN, null, null, C.onstruct("hamburger"), C.onstruct(4), C.onstruct(8))); + assertCEquals(C.onstruct("mile"), a.exec(Target.UNKNOWN, null, null, C.onstruct("smiles"), C.onstruct(1), C.onstruct(5))); + assertCEquals(C.onstruct("ning"), a.exec(Target.UNKNOWN, null, null, C.onstruct("lightning"), C.onstruct(5))); } @Test(timeout = 10000) public void testToUpper() { StringHandling.to_upper a = new StringHandling.to_upper(); - assertCEquals(C.onstruct("TESTING 123"), a.exec(Target.UNKNOWN, null, C.onstruct("testing 123"))); - assertCEquals(C.onstruct("TESTING 123"), a.exec(Target.UNKNOWN, null, C.onstruct("TeStInG 123"))); + assertCEquals(C.onstruct("TESTING 123"), a.exec(Target.UNKNOWN, null, null, C.onstruct("testing 123"))); + assertCEquals(C.onstruct("TESTING 123"), a.exec(Target.UNKNOWN, null, null, C.onstruct("TeStInG 123"))); } @Test(timeout = 10000) public void testToLower() { StringHandling.to_lower a = new StringHandling.to_lower(); - assertCEquals(C.onstruct("testing 123"), a.exec(Target.UNKNOWN, null, C.onstruct("TESTING 123"))); - assertCEquals(C.onstruct("testing 123"), a.exec(Target.UNKNOWN, null, C.onstruct("TeStInG 123"))); + assertCEquals(C.onstruct("testing 123"), a.exec(Target.UNKNOWN, null, null, C.onstruct("TESTING 123"))); + assertCEquals(C.onstruct("testing 123"), a.exec(Target.UNKNOWN, null, null, C.onstruct("TeStInG 123"))); } @Test(timeout = 10000) public void testTrim() { StringHandling.trim a = new StringHandling.trim(); - assertCEquals(C.onstruct("test 123"), a.exec(Target.UNKNOWN, null, C.onstruct(" test 123 "))); - assertCEquals(C.onstruct("test 123"), a.exec(Target.UNKNOWN, null, C.onstruct("test 123"))); + assertCEquals(C.onstruct("test 123"), a.exec(Target.UNKNOWN, null, null, C.onstruct(" test 123 "))); + assertCEquals(C.onstruct("test 123"), a.exec(Target.UNKNOWN, null, null, C.onstruct("test 123"))); } @Test diff --git a/src/test/java/com/laytonsmith/testing/RandomTests.java b/src/test/java/com/laytonsmith/testing/RandomTests.java index 553a00bf39..998db8df57 100644 --- a/src/test/java/com/laytonsmith/testing/RandomTests.java +++ b/src/test/java/com/laytonsmith/testing/RandomTests.java @@ -362,7 +362,7 @@ public void done(String output) { public void testVoidAndReturnedVoidAreTheExactSame() throws Exception { try { Environment env = Static.GenerateStandaloneEnvironment(true); - Mixed returnedVoid = new ArrayHandling.array_insert().exec(Target.UNKNOWN, env, + Mixed returnedVoid = new ArrayHandling.array_insert().exec(Target.UNKNOWN, env, null, C.Array(), C.String(""), C.Int(0)); Construct voidKeyword = Static.resolveConstruct("void", Target.UNKNOWN); assertTrue(returnedVoid == voidKeyword); diff --git a/src/test/java/com/laytonsmith/testing/StaticTest.java b/src/test/java/com/laytonsmith/testing/StaticTest.java index 8a88f118f8..bcadb0ad89 100644 --- a/src/test/java/com/laytonsmith/testing/StaticTest.java +++ b/src/test/java/com/laytonsmith/testing/StaticTest.java @@ -289,7 +289,7 @@ public static void TestExec(Function f, MCCommandSender p, String commandType) t } } try { - f.exec(Target.UNKNOWN, env, con); + Function.ExecuteFunction(f, Target.UNKNOWN, env, con); } catch (CancelCommandException e) { } catch (ConfigRuntimeException e) { if(f.getName().equals("throw")) { @@ -364,7 +364,7 @@ public static Object Val(Mixed c) { */ public static void assertCEquals(Mixed expected, Mixed actual) throws CancelCommandException { equals e = new equals(); - CBoolean ret = (CBoolean) e.exec(Target.UNKNOWN, null, expected, actual); + CBoolean ret = (CBoolean) e.exec(Target.UNKNOWN, null, null, expected, actual); if(ret.getBoolean() == false) { throw new AssertionError("Expected " + expected + " and " + actual + " to be equal to each other"); } @@ -379,7 +379,7 @@ public static void assertCEquals(Mixed expected, Mixed actual) throws CancelComm */ public static void assertCNotEquals(Mixed expected, Mixed actual) throws CancelCommandException { equals e = new equals(); - CBoolean ret = (CBoolean) e.exec(Target.UNKNOWN, null, expected, actual); + CBoolean ret = (CBoolean) e.exec(Target.UNKNOWN, null, null, expected, actual); if(ret.getBoolean() == true) { throw new AssertionError("Did not expect " + expected + " and " + actual + " to be equal to each other"); } From 8868c6edc88fcf745ccbcd9ba6682cf840e89839 Mon Sep 17 00:00:00 2001 From: LadyCailin Date: Fri, 20 Feb 2026 21:36:10 +0100 Subject: [PATCH 02/28] Add Env/GenericParams overloads to various methods. (#1408) * Add Env/GenericParams overloads to various methods. These are needed for genericsTake2. They simply forward to the old methods with null for now, which continue to exist (but deprecated), but the callers should all be updated, and so now have more time to upgrade before the genericsTake2 branch is merged in with the breaking changes. --- pom.xml | 4 +- .../laytonsmith/core/ArgumentValidation.java | 250 ++++++++++-- .../laytonsmith/core/constructs/CArray.java | 370 ++++++++++++++---- .../laytonsmith/core/constructs/CBoolean.java | 8 + .../core/constructs/CByteArray.java | 65 ++- .../core/constructs/CClassType.java | 60 ++- .../laytonsmith/core/constructs/CClosure.java | 7 + .../laytonsmith/core/constructs/CDecimal.java | 8 + .../core/constructs/CFixedArray.java | 63 ++- .../core/constructs/CMutablePrimitive.java | 36 +- .../laytonsmith/core/constructs/CNull.java | 8 + .../laytonsmith/core/constructs/CNumber.java | 8 + .../core/constructs/CReal2dMatrix.java | 52 ++- .../core/constructs/CReal2dMatrixRow.java | 65 ++- .../core/constructs/CResource.java | 9 +- .../laytonsmith/core/constructs/CSlice.java | 33 +- .../laytonsmith/core/constructs/CString.java | 55 ++- .../core/constructs/Construct.java | 40 +- .../core/constructs/InstanceofUtil.java | 5 +- .../core/constructs/LeftHandSideType.java | 1 + .../exceptions/CRE/AbstractCREException.java | 75 +++- .../natives/interfaces/AbstractMixed.java | 22 ++ .../AbstractMixedInterfaceRunner.java | 24 +- .../core/natives/interfaces/ArrayAccess.java | 72 +++- .../natives/interfaces/ArrayAccessSet.java | 13 + .../core/natives/interfaces/Booleanish.java | 14 +- .../core/natives/interfaces/MEnumType.java | 119 +++++- .../core/natives/interfaces/Mixed.java | 34 ++ .../core/natives/interfaces/Sizeable.java | 11 + .../laytonsmith/core/objects/UserObject.java | 23 +- 30 files changed, 1374 insertions(+), 180 deletions(-) diff --git a/pom.xml b/pom.xml index 193873153d..5674b4adba 100644 --- a/pom.xml +++ b/pom.xml @@ -227,7 +227,7 @@ com.mysql mysql-connector-j - 8.3.0 + 9.4.0 jar compile @@ -394,7 +394,7 @@ com.squareup.okio okio-jvm - 3.10.0 + 3.16.0 com.google.code.gson diff --git a/src/main/java/com/laytonsmith/core/ArgumentValidation.java b/src/main/java/com/laytonsmith/core/ArgumentValidation.java index f03bd479cb..7ff0a4c889 100644 --- a/src/main/java/com/laytonsmith/core/ArgumentValidation.java +++ b/src/main/java/com/laytonsmith/core/ArgumentValidation.java @@ -4,6 +4,7 @@ import com.laytonsmith.PureUtilities.Common.StringUtils; import com.laytonsmith.annotations.MEnum; import com.laytonsmith.annotations.typeof; +import com.laytonsmith.core.environments.Environment; import com.laytonsmith.core.exceptions.CRE.CRECastException; import com.laytonsmith.core.exceptions.CRE.CREFormatException; import com.laytonsmith.core.exceptions.CRE.CRERangeException; @@ -19,6 +20,7 @@ import com.laytonsmith.core.constructs.CNumber; import com.laytonsmith.core.constructs.CString; import com.laytonsmith.core.constructs.CVoid; +import com.laytonsmith.core.constructs.InstanceofUtil; import com.laytonsmith.core.constructs.Target; import com.laytonsmith.core.exceptions.ConfigRuntimeException; import com.laytonsmith.core.natives.interfaces.Booleanish; @@ -39,6 +41,14 @@ private ArgumentValidation() { // } + /** + * @deprecated Use {@link #getItemFromArray(CArray, String, Target, Mixed, Environment)} instead. + */ + @Deprecated + public static Mixed getItemFromArray(CArray object, String key, Target t, Mixed defaultItem) throws ConfigRuntimeException { + return getItemFromArray(object, key, t, defaultItem, null); + } + /** * Returns an item from an array, as a generic construct. This provides a standard way of returning an item from an * array. If defaultItem is null, then it is required that the item be present in the object. If it is not, a @@ -49,11 +59,12 @@ private ArgumentValidation() { * @param t The code target * @param defaultItem The default item to return if the specified key isn't present in the array. If this is a java * null, and the key isn't present, a standard error message is thrown. + * @param env The environment * @return The item in the array, or the defaultItem. * @throws ConfigRuntimeException A FormatException is thrown if it doesn't contain the appropriate value and the * defaultItem is null. */ - public static Mixed getItemFromArray(CArray object, String key, Target t, Mixed defaultItem) throws ConfigRuntimeException { + public static Mixed getItemFromArray(CArray object, String key, Target t, Mixed defaultItem, Environment env) throws ConfigRuntimeException { if(object.containsKey(key)) { return object.get(key, t); } else if(defaultItem == null) { @@ -63,14 +74,23 @@ public static Mixed getItemFromArray(CArray object, String key, Target t, Mixed } } + /** + * @deprecated Use {@link #getArray(Mixed, Target, Environment)} instead. + */ + @Deprecated + public static CArray getArray(Mixed construct, Target t) { + return getArray(construct, t, null); + } + /** * Returns a CArray object from a given construct, throwing a common error message if not. * * @param construct * @param t + * @param env * @return */ - public static CArray getArray(Mixed construct, Target t) { + public static CArray getArray(Mixed construct, Target t, Environment env) { if(construct.isInstanceOf(CArray.TYPE)) { return ((CArray) construct); } else { @@ -106,6 +126,14 @@ public static T getObject(Mixed construct, Target t, Class } } + /** + * @deprecated Use {@link #getNumber(Mixed, Target, Environment)} instead. + */ + @Deprecated + public static double getNumber(Mixed c, Target t) { + return getNumber(c, t, null); + } + /** * This function pulls a numerical equivalent from any given construct. It throws a ConfigRuntimeException if it * cannot be converted, for instance the string "s" cannot be cast to a number. The number returned will always be a @@ -113,9 +141,10 @@ public static T getObject(Mixed construct, Target t, Class * * @param c * @param t + * @param env * @return */ - public static double getNumber(Mixed c, Target t) { + public static double getNumber(Mixed c, Target t, Environment env) { // TODO: Formalize this in the same way that Booleanish is formalized. if(c instanceof CMutablePrimitive) { c = ((CMutablePrimitive) c).get(); @@ -124,9 +153,9 @@ public static double getNumber(Mixed c, Target t) { if(c == null || c instanceof CNull) { return 0.0; } - if(c instanceof CNumber) { + if(InstanceofUtil.isInstanceof(c, CNumber.class, env)) { d = ((CNumber) c).getNumber(); - } else if(c instanceof CString) { + } else if(InstanceofUtil.isInstanceof(c, CString.class, env)) { try { d = Double.parseDouble(c.val()); } catch (NumberFormatException e) { @@ -138,7 +167,7 @@ public static double getNumber(Mixed c, Target t) { } else { d = 0; } - } else if(c instanceof CDecimal) { + } else if(InstanceofUtil.isInstanceof(c, CDecimal.class, env)) { throw new CRECastException("Expecting a number, but received a decimal value instead. This cannot be" + " automatically cast, please use double(@decimal) to manually cast down to a double.", t); } else { @@ -168,14 +197,31 @@ public static double getNumber(Mixed c, Target t) { + ")[\\x00-\\x20]*" // trailing whitespace ); + /** + * @deprecated Use {@link #isNumber(Mixed, Environment)} instead. + */ + @Deprecated + public static boolean isNumber(Mixed c) { + return isNumber(c, null); + } + /** * Validates that a construct's value is a number or string that can be returned by GetNumber() * * @param c Mixed + * @param env * @return boolean */ - public static boolean isNumber(Mixed c) { - return c instanceof CNumber || VALID_DOUBLE.matcher(c.val()).matches(); + public static boolean isNumber(Mixed c, Environment env) { + return InstanceofUtil.isInstanceof(c, CNumber.class, env) || VALID_DOUBLE.matcher(c.val()).matches(); + } + + /** + * @deprecated Use {@link #getDouble(Mixed, Target, Environment)} instead. + */ + @Deprecated + public static double getDouble(Mixed c, Target t) { + return getDouble(c, t, null); } /** @@ -183,19 +229,28 @@ public static boolean isNumber(Mixed c) { * * @param c * @param t + * @param env * @return */ - public static double getDouble(Mixed c, Target t) { + public static double getDouble(Mixed c, Target t, Environment env) { if(c instanceof CMutablePrimitive) { c = ((CMutablePrimitive) c).get(); } try { - return getNumber(c, t); + return getNumber(c, t, env); } catch (ConfigRuntimeException e) { throw new CRECastException("Expecting a double, but received " + c.val() + " instead", t); } } + /** + * @deprecated Use {@link #getDouble32(Mixed, Target, Environment)} instead. + */ + @Deprecated + public static float getDouble32(Mixed c, Target t) { + return getDouble32(c, t, null); + } + /** * Returns a 32-bit float from the construct. Since the backing value is actually a double, if the number contained * in the construct is not within range after truncating, an exception is thrown (fail fast). When needing a float @@ -203,25 +258,35 @@ public static double getDouble(Mixed c, Target t) { * * @param c * @param t + * @param env * @return */ - public static float getDouble32(Mixed c, Target t) { - double l = getDouble(c, t); + public static float getDouble32(Mixed c, Target t, Environment env) { + double l = getDouble(c, t, env); if(Math.abs(l) > Float.MAX_VALUE) { throw new CRERangeException("Expecting a 32 bit float, but a larger value was found: " + l, t); } return (float) l; } + /** + * @deprecated Use {@link #getInt(Mixed, Target, Environment)} instead. + */ + @Deprecated + public static long getInt(Mixed c, Target t) { + return getInt(c, t, null); + } + /** * Returns a long from any given construct. * * @param c * @param t + * @param env * @throws CRECastException If the value cannot be converted to a long * @return */ - public static long getInt(Mixed c, Target t) { + public static long getInt(Mixed c, Target t, Environment env) { if(c instanceof CMutablePrimitive) { c = ((CMutablePrimitive) c).get(); } @@ -247,6 +312,14 @@ public static long getInt(Mixed c, Target t) { return i; } + /** + * @deprecated Use {@link #getInt32(Mixed, Target, Environment)} instead. + */ + @Deprecated + public static int getInt32(Mixed c, Target t) { + return getInt32(c, t, null); + } + /** * Returns a 32 bit int from the construct. Since the backing value is actually a long, if the number contained in * the construct is not the same after truncating, an exception is thrown (fail fast). When needing an int from a @@ -254,15 +327,16 @@ public static long getInt(Mixed c, Target t) { * * @param c * @param t + * @param env * @throws CRERangeException If the value would be truncated * @throws CRECastException If the value cannot be cast to an int * @return */ - public static int getInt32(Mixed c, Target t) { + public static int getInt32(Mixed c, Target t, Environment env) { if(c instanceof CMutablePrimitive) { c = ((CMutablePrimitive) c).get(); } - long l = getInt(c, t); + long l = getInt(c, t, env); int i = (int) l; if(i != l) { throw new CRERangeException("Expecting a 32 bit integer, but a larger value was found: " + l, t); @@ -270,6 +344,14 @@ public static int getInt32(Mixed c, Target t) { return i; } + /** + * @deprecated Use {@link #getInt16(Mixed, Target, Environment)} instead. + */ + @Deprecated + public static short getInt16(Mixed c, Target t) { + return getInt16(c, t, null); + } + /** * Returns a 16 bit int from the construct (a short). Since the backing value is actually a long, if the number * contained in the construct is not the same after truncating, an exception is thrown (fail fast). When needing an @@ -277,15 +359,16 @@ public static int getInt32(Mixed c, Target t) { * * @param c * @param t + * @param env * @throws CRERangeException If the value would be truncated * @throws CRECastException If the value cannot be cast to an int * @return */ - public static short getInt16(Mixed c, Target t) { + public static short getInt16(Mixed c, Target t, Environment env) { if(c instanceof CMutablePrimitive) { c = ((CMutablePrimitive) c).get(); } - long l = getInt(c, t); + long l = getInt(c, t, env); short s = (short) l; if(s != l) { throw new CRERangeException("Expecting a 16 bit integer, but a larger value was found: " + l, t); @@ -293,6 +376,14 @@ public static short getInt16(Mixed c, Target t) { return s; } + /** + * @deprecated Use {@link #getInt8(Mixed, Target, Environment)} instead. + */ + @Deprecated + public static byte getInt8(Mixed c, Target t) { + return getInt8(c, t, null); + } + /** * Returns an 8 bit int from the construct (a byte). Since the backing value is actually a long, if the number * contained in the construct is not the same after truncating, an exception is thrown (fail fast). When needing a @@ -300,15 +391,16 @@ public static short getInt16(Mixed c, Target t) { * * @param c * @param t + * @param env * @throws CRERangeException If the value would be truncated * @throws CRECastException If the value cannot be cast to an int * @return */ - public static byte getInt8(Mixed c, Target t) { + public static byte getInt8(Mixed c, Target t, Environment env) { if(c instanceof CMutablePrimitive) { c = ((CMutablePrimitive) c).get(); } - long l = getInt(c, t); + long l = getInt(c, t, env); byte b = (byte) l; if(b != l) { throw new CRERangeException("Expecting an 8 bit integer, but a larger value was found: " + l, t); @@ -316,6 +408,14 @@ public static byte getInt8(Mixed c, Target t) { return b; } + /** + * @deprecated Use {@link #getBooleanObject(Mixed, Target, Environment)} instead. + */ + @Deprecated + public static boolean getBooleanObject(Mixed c, Target t) { + return getBooleanObject(c, t, null); + } + /** * Returns a the boolean value from the underlying CBoolean, or throws a CastException if the underlying type is * not a CBoolean. @@ -325,10 +425,19 @@ public static byte getInt8(Mixed c, Target t) { * to validate the type, use {@link #getObject(Mixed, Target, Class)} * @param c * @param t + * @param env * @return */ - public static boolean getBooleanObject(Mixed c, Target t) { - return getBooleanish(c, t); + public static boolean getBooleanObject(Mixed c, Target t, Environment env) { + return getBooleanish(c, t, env); + } + + /** + * @deprecated Use {@link #getBoolean(Mixed, Target, Environment)} instead. + */ + @Deprecated + public static boolean getBoolean(Mixed c, Target t) { + return getBoolean(c, t, null); } /** @@ -338,14 +447,23 @@ public static boolean getBooleanObject(Mixed c, Target t) { * {@link #getBooleanish} or {@link #getBooleanObject}. * @param c * @param t + * @param env * @return * @deprecated Use {@link #getBooleanish} for current behavior, or {@link #getBooleanObject} for strict behavior. * Generally speaking, if it seems reasonable for the user to send a non-boolean data type in this parameter, then * getBooleanish should be used. If it indicates a probable error, getBooleanObject should be used. */ @Deprecated - public static boolean getBoolean(Mixed c, Target t) { - return getBooleanish(c, t); + public static boolean getBoolean(Mixed c, Target t, Environment env) { + return getBooleanish(c, t, env); + } + + /** + * @deprecated Use {@link #getBooleanish(Mixed, Target, Environment)} instead. + */ + @Deprecated + public static boolean getBooleanish(Mixed c, Target t) { + return getBooleanish(c, t, null); } /** @@ -355,9 +473,10 @@ public static boolean getBoolean(Mixed c, Target t) { * * @param c The value to convert * @param t The code target + * @param env * @return */ - public static boolean getBooleanish(Mixed c, Target t) { + public static boolean getBooleanish(Mixed c, Target t, Environment env) { if(c instanceof CVoid) { // Eventually, we may want to turn this into a warning, maybe even a compiler error, but for now, // to keep backwards compatibility, we want to keep this as is. @@ -369,20 +488,29 @@ public static boolean getBooleanish(Mixed c, Target t) { if(c == null) { return false; } - if(c instanceof Booleanish) { + if(InstanceofUtil.isInstanceof(c, Booleanish.class, env)) { return ((Booleanish) c).getBooleanValue(t); } throw new CRECastException("Could not convert value of type " + c.typeof() + " to a " + Booleanish.TYPE, t); } + /** + * @deprecated Use {@link #getByteArray(Mixed, Target, Environment)} instead. + */ + @Deprecated + public static CByteArray getByteArray(Mixed c, Target t) { + return getByteArray(c, t, null); + } + /** * Returns a CByteArray object from the given construct. * * @param c * @param t + * @param env * @return */ - public static CByteArray getByteArray(Mixed c, Target t) { + public static CByteArray getByteArray(Mixed c, Target t, Environment env) { if(c instanceof CByteArray) { return (CByteArray) c; } else if(c instanceof CNull) { @@ -412,58 +540,94 @@ public static String getString(Mixed c, Target t) { return c.val(); } + /** + * @deprecated Use {@link #getStringObject(Mixed, Target, Environment)} instead. + */ + @Deprecated + public static String getStringObject(Mixed c, Target t) { + return getStringObject(c, t, null); + } + /** * Returns a String object from the given construct. Note that unlike {@link #getString}, this strictly expects a * string object, and will throw a CRECastException if it is not a string. * * @param c * @param t + * @param env * @return */ - public static String getStringObject(Mixed c, Target t) { + public static String getStringObject(Mixed c, Target t, Environment env) { if(!c.isInstanceOf(CString.class)) { throw new CRECastException("Expected a string, but found " + c.typeof() + " instead.", t); } return c.val(); } + /** + * @deprecated Use {@link #anyDoubles(Environment, Mixed...)} instead. + */ + @Deprecated + public static boolean anyDoubles(Mixed... c) { + return anyDoubles(null, c); + } + /** * Returns true if any of the constructs are a CDouble, false otherwise. * + * @param env * @param c * @return */ - public static boolean anyDoubles(Mixed... c) { + public static boolean anyDoubles(Environment env, Mixed... c) { for(Mixed c1 : c) { - if(c1 instanceof CDouble || c1 instanceof CString && c1.val().indexOf(".", 1) > -1) { + if(InstanceofUtil.isInstanceof(c1, CDouble.class, env) || InstanceofUtil.isInstanceof(c1, CString.class, env) && c1.val().indexOf(".", 1) > -1) { return true; } } return false; } + /** + * @deprecated Use {@link #anyStrings(Environment, Mixed...)} instead. + */ + @Deprecated + public static boolean anyStrings(Mixed... c) { + return anyStrings(null, c); + } + /** * Return true if any of the constructs are CStrings, false otherwise. * + * @param env * @param c * @return */ - public static boolean anyStrings(Mixed... c) { + public static boolean anyStrings(Environment env, Mixed... c) { for(Mixed c1 : c) { - if(c1 instanceof CString) { + if(InstanceofUtil.isInstanceof(c1, CString.class, env)) { return true; } } return false; } + /** + * @deprecated Use {@link #anyNulls(Environment, Mixed...)} instead. + */ + @Deprecated + public static boolean anyNulls(Mixed... c) { + return anyNulls(null, c); + } + /** * Returns true if any of the constructs are null * + * @param env * @param c * @return */ - public static boolean anyNulls(Mixed... c) { + public static boolean anyNulls(Environment env, Mixed... c) { for(Mixed c1 : c) { if(c1 instanceof CNull) { return true; @@ -472,13 +636,22 @@ public static boolean anyNulls(Mixed... c) { return false; } + /** + * @deprecated Use {@link #anyBooleans(Environment, Mixed...)} instead. + */ + @Deprecated + public static boolean anyBooleans(Mixed... c) { + return anyBooleans(null, c); + } + /** * Returns true if any of the constructs are CBooleans, false otherwise. * + * @param env * @param c * @return */ - public static boolean anyBooleans(Mixed... c) { + public static boolean anyBooleans(Environment env, Mixed... c) { for(Mixed c1 : c) { if(c1 instanceof CBoolean) { return true; @@ -515,6 +688,14 @@ public static > T getEnum(Mixed c, Class enumClass, Target } } + /** + * @deprecated Use {@link #getEnumSet(Mixed, Class, Target, Environment)} instead. + */ + @Deprecated + public static > Set getEnumSet(Mixed c, Class enumClass, Target t) { + return getEnumSet(c, enumClass, t, null); + } + /** * Returns a set of the given enum value. The input value may be either a single value or an array. If * it is a single value, the set will be of size 1. Null is also supported, and will return a set of size @@ -523,9 +704,10 @@ public static > T getEnum(Mixed c, Class enumClass, Target * @param c * @param enumClass * @param t + * @param env * @return */ - public static > Set getEnumSet(Mixed c, Class enumClass, Target t) { + public static > Set getEnumSet(Mixed c, Class enumClass, Target t, Environment env) { if(c instanceof CNull) { return EnumSet.noneOf(enumClass); } diff --git a/src/main/java/com/laytonsmith/core/constructs/CArray.java b/src/main/java/com/laytonsmith/core/constructs/CArray.java index 3e603f41ef..df90b50747 100644 --- a/src/main/java/com/laytonsmith/core/constructs/CArray.java +++ b/src/main/java/com/laytonsmith/core/constructs/CArray.java @@ -97,7 +97,13 @@ public CArray(Target t, int initialCapacity, Collection items) { this(t, initialCapacity, getArray(items)); } + /** @deprecated Use {@code CArray(Target, int, Environment, Mixed[]} instead. */ + @Deprecated public CArray(Target t, int initialCapacity, Mixed... items) { + this(t, initialCapacity, null, items); + } + + public CArray(Target t, int initialCapacity, Environment env, Mixed... items) { super("{}", ConstructType.ARRAY, t); if(initialCapacity == -1) { associativeMode = true; @@ -117,8 +123,8 @@ public CArray(Target t, int initialCapacity, Mixed... items) { for(Mixed item : items) { if(item instanceof CEntry) { Mixed value = ((CEntry) item).construct; - associativeArray.put(normalizeConstruct(((CEntry) item).ckey), value); - if(value.isInstanceOf(CArray.TYPE)) { + associativeArray.put(normalizeConstruct(((CEntry) item).ckey, env), value); + if(value.isInstanceOf(CArray.TYPE, null, env)) { ((CArray) value).parent = this; } } else { @@ -134,7 +140,7 @@ public CArray(Target t, int initialCapacity, Mixed... items) { max = -1; //Special case, there are no integer indexes in here yet. } associativeArray.put(Integer.toString(max + 1), item); - if(item.isInstanceOf(CArray.TYPE)) { + if(item.isInstanceOf(CArray.TYPE, null, env)) { ((CArray) item).parent = this; } } @@ -144,7 +150,7 @@ public CArray(Target t, int initialCapacity, Mixed... items) { if(items != null) { for(Mixed item : items) { array.add(item); - if(item.isInstanceOf(CArray.TYPE)) { + if(item.isInstanceOf(CArray.TYPE, null, env)) { ((CArray) item).parent = this; } } @@ -182,12 +188,19 @@ private static Mixed[] getArray(Collection items) { return c; } + /** @deprecated Use {@link #asList(Environment)} instead. */ + @Deprecated + public List asList() { + return asList(null); + } + /** * Returns a List based on the array. This is only applicable if this is a normal array. * + * @param env * @return */ - public List asList() { + public List asList(Environment env) { if(inAssociativeMode()) { throw new RuntimeException("asList can only be called on a normal array"); } else { @@ -216,13 +229,33 @@ public boolean inAssociativeMode() { * * @param t * @return + * @deprecated Use {@link #GetAssociativeArray(Target, GenericParameters, Environment)} instead. */ + @Deprecated public static CArray GetAssociativeArray(Target t) { - return new CArray(t, -1); + return GetAssociativeArray(t, null, null); } + /** @deprecated Use {@link #GetAssociativeArray(Target, GenericParameters, Environment, Mixed[])} instead. */ + @Deprecated public static CArray GetAssociativeArray(Target t, Mixed[] args) { - return new CArray(t, -1, args); + return GetAssociativeArray(t, null, null, args); + } + + /** + * Returns a new empty CArray that is in associative mode. + * + * @param t + * @param genericParameters + * @param env + * @return + */ + public static CArray GetAssociativeArray(Target t, GenericParameters genericParameters, Environment env) { + return new CArray(t, -1, genericParameters, env); + } + + public static CArray GetAssociativeArray(Target t, GenericParameters genericParameters, Environment env, Mixed[] args) { + return new CArray(t, -1, env, args); } /** @@ -261,18 +294,31 @@ public void reverse(Target t) { } } + /** @deprecated Use {@link #push(Mixed, Target, Environment)} instead. */ + @Deprecated + public final void push(Mixed c, Target t) { + push(c, t, null); + } + /** * Pushes a new Construct onto the end of the array. * * @param c * @param t + * @param env */ - public final void push(Mixed c, Target t) { - push(c, null, t); + public final void push(Mixed c, Target t, Environment env) { + push(c, null, t, env); } public final void push(String s) { - push(new CString(s, Target.UNKNOWN), Target.UNKNOWN); + push(new CString(s, Target.UNKNOWN), Target.UNKNOWN, null); + } + + /** @deprecated Use {@link #push(Mixed, Integer, Target, Environment)} instead. */ + @Deprecated + public void push(Mixed c, Integer index, Target t) throws IllegalArgumentException, IndexOutOfBoundsException { + push(c, index, t, null); } /** @@ -282,10 +328,13 @@ public final void push(String s) { * should use {@link #set} anyways for an associative array. * * @param c The Construct to add to the array + * @param index The index to push on. May be null. + * @param t The code target + * @param env The environment * @throws IllegalArgumentException If index is not null, and this is an associative array. * @throws IndexOutOfBoundsException If the index is not null, and the index specified is out of range. */ - public void push(Mixed c, Integer index, Target t) throws IllegalArgumentException, IndexOutOfBoundsException { + public void push(Mixed c, Integer index, Target t, Environment env) throws IllegalArgumentException, IndexOutOfBoundsException { if(!associativeMode) { if(index != null) { array.add(index, c); @@ -311,20 +360,28 @@ public void push(Mixed c, Integer index, Target t) throws IllegalArgumentExcepti associativeArray.put(Integer.toString(max + 1), c); } } - if(c.isInstanceOf(CArray.TYPE)) { + if(c.isInstanceOf(CArray.TYPE, null, env)) { ((CArray) c).parent = this; } setDirty(); } + /** @deprecated Use {@link #keySet(Environment)} instead. */ + @Deprecated + @Override + public Set keySet() { + return keySet(null); + } + /** * Returns the key set for this array. If it's an associative array, it simply returns the key set of the map, * otherwise it generates a set of CInts from 0 to size-1, and returns that. * + * @param env * @return */ @Override - public Set keySet() { + public Set keySet(Environment env) { Set set; if(!associativeMode) { set = new LinkedHashSet<>(array.size()); @@ -367,25 +424,34 @@ private void setAssociative() { array = null; // null out the original array container so it can be GC'd } + /** @deprecated Use {@link #set(Mixed, Mixed, Target, Environment)} instead. */ + @Deprecated + public void set(Mixed index, Mixed c, Target t) { + set(index, c, t, null); + } + /** + * Sets the value at the given index. * - * @param index - * @param c + * @param index The index. Should be either an int or a string. + * @param c The element to set. + * @param t The code target. + * @param env The environment. */ @Override - public void set(Mixed index, Mixed c, Target t) { + public void set(Mixed index, Mixed c, Target t, Environment env) { if(!associativeMode) { if(index instanceof CNull) { // Invalid normal array index setAssociative(); } else { try { - int indx = ArgumentValidation.getInt32(index, t); + int indx = ArgumentValidation.getInt32(index, t, env); if(indx > nextIndex || indx < 0) { // Out of range setAssociative(); } else if(indx == nextIndex) { - this.push(c, t); + this.push(c, t, env); } else { array.set(indx, c); } @@ -396,49 +462,80 @@ public void set(Mixed index, Mixed c, Target t) { } } if(associativeMode) { - associativeArray.put(normalizeConstruct(index), c); + associativeArray.put(normalizeConstruct(index, env), c); } - if(c.isInstanceOf(CArray.TYPE)) { + if(c.isInstanceOf(CArray.TYPE, null, env)) { ((CArray) c).parent = this; } setDirty(); } + /** @deprecated Use {@link #set(int, Mixed, Target, Environment)} instead. */ + @Deprecated public final void set(int index, Mixed c, Target t) { - this.set(new CInt(index, t), c, t); + this.set(index, c, t, null); + } + + public final void set(int index, Mixed c, Target t, Environment env) { + this.set(new CInt(index, t), c, t, env); } /* Shortcuts */ + /** @deprecated Use {@link #set(String, Mixed, Target, Environment)} instead. */ + @Deprecated public final void set(String index, Mixed c, Target t) { - set(new CString(index, t), c, t); + set(index, c, t, null); } + public final void set(String index, Mixed c, Target t, Environment env) { + set(new CString(index, t), c, t, env); + } + + /** @deprecated Use {@link #set(String, String, Target, Environment)} instead. */ + @Deprecated public final void set(String index, String value, Target t) { - set(index, new CString(value, t), t); + set(index, value, t, null); + } + + public final void set(String index, String value, Target t, Environment env) { + set(index, new CString(value, t), t, env); } + /** @deprecated Use {@link #set(String, String, Environment)} instead. */ + @Deprecated public final void set(String index, String value) { - set(index, value, Target.UNKNOWN); + set(index, value, (Environment) null); + } + + public final void set(String index, String value, Environment env) { + set(index, value, Target.UNKNOWN, env); } public final void set(String index, double value) { - set(index, new CDouble(value, Target.UNKNOWN), Target.UNKNOWN); + set(index, new CDouble(value, Target.UNKNOWN), Target.UNKNOWN, null); } public final void set(String index, long value) { - set(index, new CInt(value, Target.UNKNOWN), Target.UNKNOWN); + set(index, new CInt(value, Target.UNKNOWN), Target.UNKNOWN, null); } + /** @deprecated Use {@link #get(Mixed, Target, Environment)} instead. */ + @Deprecated @Override public Mixed get(Mixed index, Target t) { + return get(index, t, null); + } + + @Override + public Mixed get(Mixed index, Target t, Environment env) { if(!associativeMode) { try { - return array.get(ArgumentValidation.getInt32(index, t)); + return array.get(ArgumentValidation.getInt32(index, t, env)); } catch (IndexOutOfBoundsException e) { throw new CREIndexOverflowException("The element at index \"" + index.val() + "\" does not exist", t, e); } } else { - Mixed val = associativeArray.get(normalizeConstruct(index)); + Mixed val = associativeArray.get(normalizeConstruct(index, env)); if(val != null) { if(val instanceof CEntry) { return ((CEntry) val).construct(); @@ -453,18 +550,38 @@ public Mixed get(Mixed index, Target t) { } } + /** @deprecated Use {@link #get(Mixed, Target, Environment)} instead. */ + @Deprecated public final Mixed get(long index, Target t) { - return this.get(new CInt(index, t), t); + return this.get(new CInt(index, t), t, null); } + public final Mixed get(long index, Target t, Environment env) { + return this.get(new CInt(index, t), t, env); + } + + /** @deprecated Use {@link #get(int, Target, Environment)} instead. */ + @Deprecated @Override public final Mixed get(int index, Target t) { - return this.get(new CInt(index, t), t); + return this.get(new CInt(index, t), t, null); } + @Override + public final Mixed get(int index, Target t, Environment env) { + return this.get(new CInt(index, t), t, env); + } + + /** @deprecated Use {@link #get(String, Target, Environment)} instead. */ + @Deprecated @Override public final Mixed get(String index, Target t) { - return this.get(new CString(index, t), t); + return this.get(new CString(index, t), t, null); + } + + @Override + public final Mixed get(String index, Target t, Environment env) { + return this.get(new CString(index, t), t, env); } public boolean containsKey(String c) { @@ -499,13 +616,20 @@ public final boolean contains(int i) { return contains(new CString(Integer.toString(i), Target.UNKNOWN)); } + /** @deprecated Use {@link #indexesOf(Mixed, Environment)} instead. */ + @Deprecated + public CArray indexesOf(Mixed value) { + return indexesOf(value, null); + } + /** * Returns an array of the keys of all the values that are equal to the value specified * - * @param value - * @return + * @param value The value to find the index(es) of + * @param env The environment + * @return An array of keys where the corresponding value is equal to the value specified. */ - public CArray indexesOf(Mixed value) { + public CArray indexesOf(Mixed value, Environment env) { CArray ret = new CArray(Target.UNKNOWN); if(associativeMode) { for(String key : associativeArray.keySet()) { @@ -526,7 +650,8 @@ public CArray indexesOf(Mixed value) { @Override public String val() { if(valueDirty) { - getString(new Stack<>(), this.getTarget()); + // TODO: Hmmmmmm. Might need env here. + getString(new Stack<>(), this.getTarget(), null); } return mutVal; } @@ -544,23 +669,23 @@ public String toString() { * @param t * @return */ - protected String getString(Stack arrays, Target t) { + protected String getString(Stack arrays, Target t, Environment env) { if(!valueDirty) { return mutVal; } StringBuilder b = new StringBuilder(); b.append("{"); if(!inAssociativeMode()) { - for(int i = 0; i < this.size(); i++) { - Mixed value = this.get(i, t); + for(int i = 0; i < this.size(env); i++) { + Mixed value = this.get(i, t, env); String v; - if(value.isInstanceOf(CArray.TYPE)) { + if(value.isInstanceOf(CArray.TYPE, null, env)) { if(arrays.contains(value)) { //Check for recursion v = "*recursion*"; } else { arrays.add(((CArray) value)); - v = ((CArray) value).getString(arrays, t); + v = ((CArray) value).getString(arrays, t, env); arrays.pop(); } } else { @@ -579,16 +704,16 @@ protected String getString(Stack arrays, Target t) { } first = false; String v; - if(this.get(key, t) == null) { + if(this.get(key, t, env) == null) { v = "null"; } else { - Mixed value = this.get(key, t); - if(value.isInstanceOf(CArray.TYPE)) { + Mixed value = this.get(key, t, env); + if(value.isInstanceOf(CArray.TYPE, null, env)) { if(arrays.contains(value)) { v = "*recursion*"; } else { arrays.add(((CArray) value)); - v = ((CArray) value).getString(arrays, t); + v = ((CArray) value).getString(arrays, t, env); } } else { v = value.val(); @@ -603,8 +728,15 @@ protected String getString(Stack arrays, Target t) { return mutVal; } + /** @deprecated Use {@link #size(Environment)} instead. */ + @Deprecated @Override public long size() { + return size(null); + } + + @Override + public long size(Environment env) { if(associativeMode) { return associativeArray.size(); } else { @@ -632,11 +764,23 @@ public CArray clone() { return clone; } + /** @deprecated Use {@link #deepClone(Target, Environment)} instead. */ + @Deprecated public CArray deepClone(Target t) { - return deepClone(this, t, new ArrayList<>()); + return deepClone(t, null); + } + + public CArray deepClone(Target t, Environment env) { + return deepClone(this, t, new ArrayList<>(), env); } + /** @deprecated Use {@link #deepClone(CArray, Target, ArrayList, Environment)} instead. */ + @Deprecated protected CArray deepClone(CArray array, Target t, ArrayList cloneRefs) { + return deepClone(array, t, cloneRefs, null); + } + + protected CArray deepClone(CArray array, Target t, ArrayList cloneRefs, Environment env) { // Return the clone reference if this array has been cloned before (both clones will have the same reference). for(CArray[] refCouple : cloneRefs) { @@ -646,69 +790,90 @@ protected CArray deepClone(CArray array, Target t, ArrayList cloneRefs } // Create the clone to put array in and add it to the cloneRefs list. - CArray clone = new CArray(t, (int) array.size()); + CArray clone = new CArray(t, (int) array.size(env)); clone.associativeMode = array.associativeMode; cloneRefs.add(new CArray[]{array, clone}); // Iterate over the array, recursively calling this method to perform a deep clone. - for(Mixed key : array.keySet()) { - Mixed value = array.get(key, t); - if(value.isInstanceOf(CArray.TYPE)) { - value = deepClone((CArray) value, t, cloneRefs); + for(Mixed key : array.keySet(env)) { + Mixed value = array.get(key, t, env); + if(value.isInstanceOf(CArray.TYPE, null, env)) { + value = deepClone((CArray) value, t, cloneRefs, env); } - clone.set(key, value, t); + clone.set(key, value, t, env); } return clone; } - private String normalizeConstruct(Mixed c) { - if(c.isInstanceOf(CArray.TYPE)) { + private String normalizeConstruct(Mixed c, Environment env) { + if(c.isInstanceOf(CArray.TYPE, null, env)) { throw new CRECastException("Arrays cannot be used as the key in an associative array", c.getTarget()); - } else if(c.isInstanceOf(CString.TYPE) || c.isInstanceOf(CInt.TYPE)) { + } else if(c.isInstanceOf(CString.TYPE, null, env) || c.isInstanceOf(CInt.TYPE, null, env)) { return c.val(); } else if(c instanceof CNull) { return ""; - } else if(c.isInstanceOf(CBoolean.TYPE)) { + } else if(c.isInstanceOf(CBoolean.TYPE, null, env)) { if(((CBoolean) c).getBoolean()) { return "1"; } else { return "0"; } } else if(c instanceof CLabel) { - return normalizeConstruct(((CLabel) c).cVal()); + return normalizeConstruct(((CLabel) c).cVal(), env); } else { return c.val(); } } + /** @deprecated Use {@link #remove(int, Environment)} instead. */ + @Deprecated + public Mixed remove(int i) { + return remove(i, null); + } + /** * Removes the value at the specified integer key. * - * @param i - * @return + * @param i The index to remove at + * @param env The environment + * @return The value that was removed */ - public Mixed remove(int i) { - return remove(new CInt(i, Target.UNKNOWN)); + public Mixed remove(int i, Environment env) { + return remove(new CInt(i, Target.UNKNOWN), env); + } + + /** @deprecated Use {@link #remove(String, Environment)} instead. */ + @Deprecated + public Mixed remove(String s) { + return remove(s, null); } /** * Removes the value at the specified string key. * - * @param s - * @return + * @param s The index to remove at + * @param env The environment + * @return The value that was removed */ - public Mixed remove(String s) { - return remove(new CString(s, Target.UNKNOWN)); + public Mixed remove(String s, Environment env) { + return remove(new CString(s, Target.UNKNOWN), env); + } + + /** @deprecated Use {@link #remove(Mixed, Environment)} instead. */ + @Deprecated + public Mixed remove(Mixed construct) { + return remove(construct, null); } /** * Removes the value at the specified key * * @param construct The value to remove + * @param env The environment * @return The removed value, or CNull if nothing was removed. */ - public Mixed remove(Mixed construct) { - String c = normalizeConstruct(construct); + public Mixed remove(Mixed construct, Environment env) { + String c = normalizeConstruct(construct, env); Mixed ret; if(!associativeMode) { try { @@ -757,14 +922,21 @@ public void removeValues(Mixed construct) { setDirty(); } + /** @deprecated Use {@link #createNew(Target, Environment)} instead. */ + @Deprecated + public CArray createNew(Target t) { + return createNew(t, null); + } + /** * Creates a new, empty array, with the same type. Note to subclasses: By default, this method expects a constructor * that accepts a {@link Target}. If this assumption is not valid, you may override this method as needed. * - * @param t - * @return + * @param t The code target + * @param env The environment + * @return A new empty array */ - public CArray createNew(Target t) { + public CArray createNew(Target t, Environment env) { try { Constructor con = (Constructor) this.getClass().getConstructor(Target.class); try { @@ -821,9 +993,16 @@ public boolean canBeAssociative() { return true; } + /** @deprecated Use {@link #slice(int, int, Target, Environment)} instead. */ + @Deprecated @Override public Mixed slice(int begin, int end, Target t) { - return new ArrayHandling.array_get().exec(t, null, null, new CSlice(begin, end, t)); + return slice(begin, end, t, null); + } + + @Override + public Mixed slice(int begin, int end, Target t, Environment env) { + return new ArrayHandling.array_get().exec(t, env, null, new CSlice(begin, end, t)); } @Override @@ -866,7 +1045,13 @@ public enum ArraySortType { STRING_IC } + /** @deprecated Use {@link #sort(ArraySortType, Environment)} instead. */ + @Deprecated public void sort(final ArraySortType sort) { + sort(sort, null); + } + + public void sort(final ArraySortType sort, Environment env) { if(this.associativeMode) { array = new ArrayList<>(associativeArray.values()); this.associativeArray.clear(); @@ -887,12 +1072,12 @@ public int compare(Mixed o1, Mixed o2) { } else { c = o2; } - if(c.isInstanceOf(CArray.TYPE)) { + if(c.isInstanceOf(CArray.TYPE, null, env)) { throw new CRECastException("Cannot sort an array of arrays.", CArray.this.getTarget()); } - if(!(c.isInstanceOf(CBoolean.TYPE) || c.isInstanceOf(CString.TYPE) || c.isInstanceOf(CInt.TYPE) - || c.isInstanceOf(CDouble.TYPE) || c instanceof CNull || c.isInstanceOf(CClassType.TYPE))) { - throw new CREFormatException("Unsupported type being sorted: " + c.typeof(), CArray.this.getTarget()); + if(!(c.isInstanceOf(CBoolean.TYPE, null, env) || c.isInstanceOf(CString.TYPE, null, env) || c.isInstanceOf(CInt.TYPE, null, env) + || c.isInstanceOf(CDouble.TYPE, null, env) || c instanceof CNull || c.isInstanceOf(CClassType.TYPE, null, env))) { + throw new CREFormatException("Unsupported type being sorted: " + c.typeof(env), CArray.this.getTarget()); } } if(o1 instanceof CNull || o2 instanceof CNull) { @@ -904,12 +1089,12 @@ public int compare(Mixed o1, Mixed o2) { return o1.val().compareTo(""); } } - if(o1.isInstanceOf(CBoolean.TYPE) || o2.isInstanceOf(CBoolean.TYPE)) { - if(ArgumentValidation.getBooleanish(o1, Target.UNKNOWN) == ArgumentValidation.getBooleanish(o2, Target.UNKNOWN)) { + if(o1.isInstanceOf(CBoolean.TYPE, null, env) || o2.isInstanceOf(CBoolean.TYPE, null, env)) { + if(ArgumentValidation.getBooleanish(o1, Target.UNKNOWN, env) == ArgumentValidation.getBooleanish(o2, Target.UNKNOWN, env)) { return 0; } else { - int oo1 = ArgumentValidation.getBooleanish(o1, Target.UNKNOWN) ? 1 : 0; - int oo2 = ArgumentValidation.getBooleanish(o2, Target.UNKNOWN) ? 1 : 0; + int oo1 = ArgumentValidation.getBooleanish(o1, Target.UNKNOWN, env) ? 1 : 0; + int oo2 = ArgumentValidation.getBooleanish(o2, Target.UNKNOWN, env) ? 1 : 0; return (oo1 < oo2) ? -1 : 1; } } @@ -923,13 +1108,13 @@ public int compare(Mixed o1, Mixed o2) { } public int compareRegular(Mixed o1, Mixed o2) { - if(ArgumentValidation.getBooleanObject(new DataHandling.is_numeric().exec(Target.UNKNOWN, null, null, o1), Target.UNKNOWN) - && ArgumentValidation.getBooleanObject(new DataHandling.is_numeric().exec(Target.UNKNOWN, null, null, o2), Target.UNKNOWN)) { + if(ArgumentValidation.getBooleanObject(new DataHandling.is_numeric().exec(Target.UNKNOWN, null, null, o1), Target.UNKNOWN, env) + && ArgumentValidation.getBooleanObject(new DataHandling.is_numeric().exec(Target.UNKNOWN, null, null, o2), Target.UNKNOWN, env)) { return compareNumeric(o1, o2); - } else if(ArgumentValidation.getBooleanObject(new DataHandling.is_numeric().exec(Target.UNKNOWN, null, null, o1), Target.UNKNOWN)) { + } else if(ArgumentValidation.getBooleanObject(new DataHandling.is_numeric().exec(Target.UNKNOWN, null, null, o1), Target.UNKNOWN, env)) { //The first is a number, the second is a string return -1; - } else if(ArgumentValidation.getBooleanObject(new DataHandling.is_numeric().exec(Target.UNKNOWN, null, null, o2), Target.UNKNOWN)) { + } else if(ArgumentValidation.getBooleanObject(new DataHandling.is_numeric().exec(Target.UNKNOWN, null, null, o2), Target.UNKNOWN, env)) { //The second is a number, the first is a string return 1; } else { @@ -939,8 +1124,8 @@ public int compareRegular(Mixed o1, Mixed o2) { } public int compareNumeric(Mixed o1, Mixed o2) { - double d1 = ArgumentValidation.getNumber(o1, o1.getTarget()); - double d2 = ArgumentValidation.getNumber(o2, o2.getTarget()); + double d1 = ArgumentValidation.getNumber(o1, o1.getTarget(), env); + double d2 = ArgumentValidation.getNumber(o2, o2.getTarget(), env); return Double.compare(d1, d2); } @@ -951,8 +1136,14 @@ public int compareString(String o1, String o2) { this.setDirty(); } + /** @deprecated Use {@link #isEmpty(Environment)} instead. */ + @Deprecated public boolean isEmpty() { - return size() == 0; + return isEmpty(null); + } + + public boolean isEmpty(Environment env) { + return size(env) == 0; } /** @@ -986,9 +1177,16 @@ public CClassType[] getInterfaces() { ArrayAccessSet.TYPE}; } + /** @deprecated Use {@link #getBooleanValue(Environment, Target)} instead. */ + @Deprecated @Override public boolean getBooleanValue(Target t) { - return size() > 0; + return getBooleanValue(null, t); + } + + @Override + public boolean getBooleanValue(Environment env, Target t) { + return size(env) > 0; } } diff --git a/src/main/java/com/laytonsmith/core/constructs/CBoolean.java b/src/main/java/com/laytonsmith/core/constructs/CBoolean.java index f4f079863f..df6126656b 100644 --- a/src/main/java/com/laytonsmith/core/constructs/CBoolean.java +++ b/src/main/java/com/laytonsmith/core/constructs/CBoolean.java @@ -3,6 +3,7 @@ import com.laytonsmith.PureUtilities.Version; import com.laytonsmith.annotations.typeof; import com.laytonsmith.core.MSVersion; +import com.laytonsmith.core.environments.Environment; import com.laytonsmith.core.objects.ObjectModifier; import java.util.EnumSet; import java.util.Set; @@ -89,8 +90,15 @@ public boolean getBoolean() { return val; } + /** @deprecated Use {@link #getBooleanValue(Environment, Target)} instead. */ + @Deprecated @Override public boolean getBooleanValue(Target t) { + return getBooleanValue(null, t); + } + + @Override + public boolean getBooleanValue(Environment env, Target t) { return val; } diff --git a/src/main/java/com/laytonsmith/core/constructs/CByteArray.java b/src/main/java/com/laytonsmith/core/constructs/CByteArray.java index a6f93a368f..9aac413bc0 100644 --- a/src/main/java/com/laytonsmith/core/constructs/CByteArray.java +++ b/src/main/java/com/laytonsmith/core/constructs/CByteArray.java @@ -5,6 +5,7 @@ import com.laytonsmith.annotations.typeof; import com.laytonsmith.core.ArgumentValidation; import com.laytonsmith.core.MSVersion; +import com.laytonsmith.core.environments.Environment; import com.laytonsmith.core.exceptions.CRE.CRERangeException; import com.laytonsmith.core.exceptions.CRE.CREReadOnlyException; import com.laytonsmith.core.exceptions.CRE.CREUnsupportedOperationException; @@ -28,7 +29,7 @@ * */ @typeof("ms.lang.byte_array") -public class CByteArray extends CArray implements Sizeable, ArrayAccess { +public final class CByteArray extends CArray implements Sizeable, ArrayAccess { @SuppressWarnings("FieldNameHidesFieldInSuperclass") public static final CClassType TYPE = CClassType.get(CByteArray.class); @@ -389,9 +390,16 @@ public CByteArray getBytes(int size, Integer pos) { * Returns the current size of the byte array. This is not to be confused with the capacity. * * @return + * @deprecated Use {@link #size(Environment)} instead. */ + @Deprecated @Override public long size() { + return size(null); + } + + @Override + public long size(Environment env) { return maxValue; } @@ -485,8 +493,15 @@ public boolean canBeAssociative() { return false; } + /** @deprecated Use {@link #slice(int, int, Target, Environment)} instead. */ + @Deprecated @Override public Mixed slice(int begin, int end, Target t) { + return slice(begin, end, t, null); + } + + @Override + public Mixed slice(int begin, int end, Target t, Environment env) { return getBytes(end - begin, begin); } @@ -525,8 +540,15 @@ public void push(Mixed c, Integer index, Target t) throws IllegalArgumentExcepti throw new CREUnsupportedOperationException("Modifying a byte array using array_push() is not supported.", t); } + /** @deprecated Use {@link #keySet(Environment)} instead. */ + @Deprecated @Override public Set keySet() { + return keySet(null); + } + + @Override + public Set keySet(Environment env) { throw new CREUnsupportedOperationException("Getting a key set from a byte array is not supported.", getTarget()); } @@ -535,8 +557,15 @@ public Set stringKeySet() { throw new CREUnsupportedOperationException("Getting a string key set from a byte array is not supported.", getTarget()); } + /** @deprecated Use {@link #set(Mixed, Mixed, Target, Environment)} instead. */ + @Deprecated @Override public void set(Mixed index, Mixed c, Target t) throws ConfigRuntimeException { + set(index, c, t, null); + } + + @Override + public void set(Mixed index, Mixed c, Target t, Environment env) throws ConfigRuntimeException { throw new CREUnsupportedOperationException("Modifying a byte array using array_set() is not supported.", t); } @@ -549,9 +578,16 @@ protected CArray deepClone(CArray array, Target t, ArrayList cloneRefs return CByteArray.wrap(newArray, t); } + /** @deprecated Use {@link #get(Mixed, Target, Environment)} instead. */ + @Deprecated @Override public Mixed get(Mixed index, Target t) throws ConfigRuntimeException { - int i = ArgumentValidation.getInt32(index, t); + return get(index, t, null); + } + + @Override + public Mixed get(Mixed index, Target t, Environment env) throws ConfigRuntimeException { + int i = ArgumentValidation.getInt32(index, t, env); byte b = getByte(i); return new CInt(b, t); } @@ -647,14 +683,28 @@ public void push(Mixed c, Integer i, Target t) { throw new CREByteArrayReadOnlyException("Arrays copied from ByteArrays are read only", t); } + /** @deprecated Use {@link #set(Mixed, Mixed, Target, Environment)} instead. */ + @Deprecated @Override public void set(Mixed index, Mixed c, Target t) { + set(index, c, t, null); + } + + @Override + public void set(Mixed index, Mixed c, Target t, Environment env) { throw new CREByteArrayReadOnlyException("Arrays copied from ByteArrays are read only", t); } + /** @deprecated Use {@link #get(Mixed, Target, Environment)} instead. */ + @Deprecated @Override public Mixed get(Mixed index, Target t) { - int i = ArgumentValidation.getInt32(index, t); + return get(index, t, null); + } + + @Override + public Mixed get(Mixed index, Target t, Environment env) { + int i = ArgumentValidation.getInt32(index, t, env); try { return new CInt(backing[i], t); } catch (ArrayIndexOutOfBoundsException e) { @@ -662,8 +712,15 @@ public Mixed get(Mixed index, Target t) { } } + /** @deprecated Use {@link #size(Environment)} instead. */ + @Deprecated @Override public long size() { + return size(null); + } + + @Override + public long size(Environment env) { return backing.length; } @@ -718,7 +775,7 @@ public CClassType[] getSuperclasses() { @Override public Set getObjectModifiers() { - return EnumSet.of(ObjectModifier.STATIC); + return EnumSet.of(ObjectModifier.STATIC, ObjectModifier.FINAL); } @Override diff --git a/src/main/java/com/laytonsmith/core/constructs/CClassType.java b/src/main/java/com/laytonsmith/core/constructs/CClassType.java index 554e3d1996..9eb555a9e6 100644 --- a/src/main/java/com/laytonsmith/core/constructs/CClassType.java +++ b/src/main/java/com/laytonsmith/core/constructs/CClassType.java @@ -592,11 +592,18 @@ public CClassType typeof() { // TODO: These getters will eventually be re-done to support static methods, but for now that is out of scope, // so we just specifically support enums for now. + /** @deprecated Use {@link #get(String, Target, Environment)} instead. */ + @Deprecated @Override public Mixed get(String index, Target t) throws ConfigRuntimeException { + return get(index, t, null); + } + + @Override + public Mixed get(String index, Target t, Environment env) throws ConfigRuntimeException { if(isEnum()) { try { - return NativeTypeList.getNativeEnumType(fqcn).get(index, t); + return NativeTypeList.getNativeEnumType(fqcn).get(index, t, env); } catch (ClassNotFoundException ex) { throw new RuntimeException(ex); } @@ -604,11 +611,18 @@ public Mixed get(String index, Target t) throws ConfigRuntimeException { throw new CREUnsupportedOperationException("Unsupported operation", t); } + /** @deprecated Use {@link #get(int, Target, Environment)} instead. */ + @Deprecated @Override public Mixed get(int index, Target t) throws ConfigRuntimeException { + return get(index, t, null); + } + + @Override + public Mixed get(int index, Target t, Environment env) throws ConfigRuntimeException { if(isEnum()) { try { - return NativeTypeList.getNativeEnumType(fqcn).get(index, t); + return NativeTypeList.getNativeEnumType(fqcn).get(index, t, env); } catch (ClassNotFoundException ex) { throw new RuntimeException(ex); } @@ -616,11 +630,18 @@ public Mixed get(int index, Target t) throws ConfigRuntimeException { throw new CREUnsupportedOperationException("Unsupported operation", t); } + /** @deprecated Use {@link #get(Mixed, Target, Environment)} instead. */ + @Deprecated @Override public Mixed get(Mixed index, Target t) throws ConfigRuntimeException { + return get(index, t, null); + } + + @Override + public Mixed get(Mixed index, Target t, Environment env) throws ConfigRuntimeException { if(isEnum()) { try { - return NativeTypeList.getNativeEnumType(fqcn).get(index, t); + return NativeTypeList.getNativeEnumType(fqcn).get(index, t, env); } catch (ClassNotFoundException ex) { throw new RuntimeException(ex); } @@ -628,11 +649,18 @@ public Mixed get(Mixed index, Target t) throws ConfigRuntimeException { throw new CREUnsupportedOperationException("Unsupported operation", t); } + /** @deprecated Use {@link #keySet(Environment)} instead. */ + @Deprecated @Override public Set keySet() { + return keySet(null); + } + + @Override + public Set keySet(Environment env) { if(isEnum()) { try { - return NativeTypeList.getNativeEnumType(fqcn).keySet(); + return NativeTypeList.getNativeEnumType(fqcn).keySet(env); } catch (ClassNotFoundException ex) { throw new RuntimeException(ex); } @@ -640,11 +668,18 @@ public Set keySet() { return new HashSet<>(); } + /** @deprecated Use {@link #size(Environment)} instead. */ + @Deprecated @Override public long size() { + return size(null); + } + + @Override + public long size(Environment env) { if(isEnum()) { try { - return NativeTypeList.getNativeEnumType(fqcn).size(); + return NativeTypeList.getNativeEnumType(fqcn).size(env); } catch (ClassNotFoundException ex) { throw new RuntimeException(ex); } @@ -662,8 +697,15 @@ public boolean canBeAssociative() { return true; } + /** @deprecated Use {@link #slice(int, int, Target, Environment)} instead. */ + @Deprecated @Override public Mixed slice(int begin, int end, Target t) { + return slice(begin, end, t, null); + } + + @Override + public Mixed slice(int begin, int end, Target t, Environment env) { throw new CREUnsupportedOperationException("Unsupported operation", t); } @@ -677,8 +719,15 @@ public Class getNativeType() { return nativeClass; } + /** @deprecated Use {@link #getBooleanValue(Environment, Target)} instead. */ + @Deprecated @Override public boolean getBooleanValue(Target t) { + return getBooleanValue(null, t); + } + + @Override + public boolean getBooleanValue(Environment env, Target t) { return true; } @@ -741,6 +790,7 @@ public GenericTypeParameters getTypeGenericParameters() { /** * Stub for generics support — not yet implemented. */ + @Override public GenericParameters getGenericParameters() { throw new UnsupportedOperationException("Not yet implemented"); } diff --git a/src/main/java/com/laytonsmith/core/constructs/CClosure.java b/src/main/java/com/laytonsmith/core/constructs/CClosure.java index ae8d0131c4..0ad103b6de 100644 --- a/src/main/java/com/laytonsmith/core/constructs/CClosure.java +++ b/src/main/java/com/laytonsmith/core/constructs/CClosure.java @@ -350,8 +350,15 @@ public CClassType[] getInterfaces() { return new CClassType[]{Callable.TYPE, Booleanish.TYPE}; } + /** @deprecated Use {@link #getBooleanValue(Environment, Target)} instead. */ + @Deprecated @Override public boolean getBooleanValue(Target t) { + return getBooleanValue(null, t); + } + + @Override + public boolean getBooleanValue(Environment env, Target t) { return true; } } diff --git a/src/main/java/com/laytonsmith/core/constructs/CDecimal.java b/src/main/java/com/laytonsmith/core/constructs/CDecimal.java index 640f54f9d8..8aaf7e7af6 100644 --- a/src/main/java/com/laytonsmith/core/constructs/CDecimal.java +++ b/src/main/java/com/laytonsmith/core/constructs/CDecimal.java @@ -3,6 +3,7 @@ import com.laytonsmith.PureUtilities.Version; import com.laytonsmith.annotations.typeof; import com.laytonsmith.core.MSVersion; +import com.laytonsmith.core.environments.Environment; import com.laytonsmith.core.exceptions.CRE.CREFormatException; import java.math.BigDecimal; @@ -83,8 +84,15 @@ public CDecimal duplicate() { return new CDecimal(val, getTarget()); } + /** @deprecated Use {@link #getBooleanValue(Environment, Target)} instead. */ + @Deprecated @Override public boolean getBooleanValue(Target t) { + return getBooleanValue(null, t); + } + + @Override + public boolean getBooleanValue(Environment env, Target t) { return val.compareTo(new BigDecimal(0)) != 0; } diff --git a/src/main/java/com/laytonsmith/core/constructs/CFixedArray.java b/src/main/java/com/laytonsmith/core/constructs/CFixedArray.java index 6f57ecb57e..ac18ea4477 100644 --- a/src/main/java/com/laytonsmith/core/constructs/CFixedArray.java +++ b/src/main/java/com/laytonsmith/core/constructs/CFixedArray.java @@ -9,6 +9,7 @@ import com.laytonsmith.core.exceptions.CRE.CREIndexOverflowException; import com.laytonsmith.core.exceptions.CRE.CREUnsupportedOperationException; import com.laytonsmith.core.exceptions.ConfigRuntimeException; +import com.laytonsmith.core.environments.Environment; import com.laytonsmith.core.natives.interfaces.ArrayAccessSet; import com.laytonsmith.core.natives.interfaces.Booleanish; import com.laytonsmith.core.natives.interfaces.Mixed; @@ -43,13 +44,27 @@ public boolean isDynamic() { return true; } + /** @deprecated Use {@link #get(String, Target, Environment)} instead. */ + @Deprecated @Override public Mixed get(String index, Target t) throws ConfigRuntimeException { + return get(index, t, null); + } + + @Override + public Mixed get(String index, Target t, Environment env) throws ConfigRuntimeException { return null; } + /** @deprecated Use {@link #get(int, Target, Environment)} instead. */ + @Deprecated @Override public Mixed get(int index, Target t) throws ConfigRuntimeException { + return get(index, t, null); + } + + @Override + public Mixed get(int index, Target t, Environment env) throws ConfigRuntimeException { if(index < 0 || index >= data.length) { throw new CREIndexOverflowException("Index overflows array size", t); } @@ -60,13 +75,27 @@ public Mixed get(int index, Target t) throws ConfigRuntimeException { return d; } + /** @deprecated Use {@link #get(Mixed, Target, Environment)} instead. */ + @Deprecated @Override public Mixed get(Mixed index, Target t) throws ConfigRuntimeException { - return get(ArgumentValidation.getInt32(index, t), t); + return get(index, t, null); } + @Override + public Mixed get(Mixed index, Target t, Environment env) throws ConfigRuntimeException { + return get(ArgumentValidation.getInt32(index, t, env), t, env); + } + + /** @deprecated Use {@link #keySet(Environment)} instead. */ + @Deprecated @Override public Set keySet() { + return keySet(null); + } + + @Override + public Set keySet(Environment env) { Set set = new LinkedHashSet<>(data.length); for(int i = 0; i < data.length; i++) { set.add(new CInt(i, Target.UNKNOWN)); @@ -80,9 +109,16 @@ private void validateSet(Mixed value, Target t) { } } + /** @deprecated Use {@link #set(Mixed, Mixed, Target, Environment)} instead. */ + @Deprecated @Override public void set(Mixed index, Mixed value, Target t) { - int in = ArgumentValidation.getInt32(index, t); + set(index, value, t, null); + } + + @Override + public void set(Mixed index, Mixed value, Target t, Environment env) { + int in = ArgumentValidation.getInt32(index, t, env); set(in, value, t); } @@ -104,18 +140,39 @@ public boolean canBeAssociative() { return false; } + /** @deprecated Use {@link #slice(int, int, Target, Environment)} instead. */ + @Deprecated @Override public Mixed slice(int begin, int end, Target t) { + return slice(begin, end, t, null); + } + + @Override + public Mixed slice(int begin, int end, Target t, Environment env) { throw new CREUnsupportedOperationException("slices are not yet implemented on fixed_array", t); } + /** @deprecated Use {@link #getBooleanValue(Environment, Target)} instead. */ + @Deprecated @Override public boolean getBooleanValue(Target t) { - return size() > 0; + return getBooleanValue(null, t); } + @Override + public boolean getBooleanValue(Environment env, Target t) { + return size(env) > 0; + } + + /** @deprecated Use {@link #size(Environment)} instead. */ + @Deprecated @Override public long size() { + return size(null); + } + + @Override + public long size(Environment env) { return data.length; } diff --git a/src/main/java/com/laytonsmith/core/constructs/CMutablePrimitive.java b/src/main/java/com/laytonsmith/core/constructs/CMutablePrimitive.java index ca2c2e831e..552b78d3cf 100644 --- a/src/main/java/com/laytonsmith/core/constructs/CMutablePrimitive.java +++ b/src/main/java/com/laytonsmith/core/constructs/CMutablePrimitive.java @@ -4,20 +4,24 @@ import com.laytonsmith.annotations.typeof; import com.laytonsmith.core.ArgumentValidation; import com.laytonsmith.core.MSVersion; +import com.laytonsmith.core.environments.Environment; import com.laytonsmith.core.exceptions.CRE.CRECastException; import com.laytonsmith.core.exceptions.CRE.CREFormatException; import com.laytonsmith.core.natives.interfaces.Mixed; import com.laytonsmith.core.natives.interfaces.Sizeable; import com.laytonsmith.core.natives.interfaces.ValueType; +import com.laytonsmith.core.objects.ObjectModifier; import java.util.ArrayList; +import java.util.EnumSet; import java.util.List; +import java.util.Set; import java.util.Stack; /** * */ @typeof("ms.lang.mutable_primitive") -public class CMutablePrimitive extends CArray implements Sizeable { +public final class CMutablePrimitive extends CArray implements Sizeable { @SuppressWarnings("FieldNameHidesFieldInSuperclass") public static final CClassType TYPE = CClassType.get(CMutablePrimitive.class); @@ -51,8 +55,15 @@ public void set(Mixed value, Target t) { this.value = value; } + /** @deprecated Use {@link #set(Mixed, Mixed, Target, Environment)} instead. */ + @Deprecated @Override public void set(Mixed index, Mixed c, Target t) { + set(index, c, t, null); + } + + @Override + public void set(Mixed index, Mixed c, Target t, Environment env) { throw new CRECastException("mutable_primitives cannot have values set in them", t); } @@ -74,8 +85,15 @@ public Mixed get() { return value; } + /** @deprecated Use {@link #get(Mixed, Target, Environment)} instead. */ + @Deprecated @Override public Mixed get(Mixed index, Target t) { + return get(index, t, null); + } + + @Override + public Mixed get(Mixed index, Target t, Environment env) { return value; } @@ -99,10 +117,17 @@ protected String getQuote() { return new CString(value.val(), Target.UNKNOWN).getQuote(); } + /** @deprecated Use {@link #size(Environment)} instead. */ + @Deprecated @Override public long size() { + return size(null); + } + + @Override + public long size(Environment env) { if(value.isInstanceOf(Sizeable.TYPE)) { - return ArgumentValidation.getObject(value, Target.UNKNOWN, Sizeable.class).size(); + return ArgumentValidation.getObject(value, Target.UNKNOWN, Sizeable.class).size(env); } else { return 0; } @@ -136,7 +161,7 @@ protected List getArray() { } @Override - protected String getString(Stack arrays, Target t) { + protected String getString(Stack arrays, Target t, Environment env) { return value.val(); } @@ -165,4 +190,9 @@ public CClassType[] getInterfaces() { return new CClassType[]{Sizeable.TYPE}; } + @Override + public Set getObjectModifiers() { + return EnumSet.of(ObjectModifier.FINAL); + } + } diff --git a/src/main/java/com/laytonsmith/core/constructs/CNull.java b/src/main/java/com/laytonsmith/core/constructs/CNull.java index 67420cda4f..065867aff1 100644 --- a/src/main/java/com/laytonsmith/core/constructs/CNull.java +++ b/src/main/java/com/laytonsmith/core/constructs/CNull.java @@ -3,6 +3,7 @@ import com.laytonsmith.PureUtilities.Version; import com.laytonsmith.annotations.typeof; import com.laytonsmith.core.MSVersion; +import com.laytonsmith.core.environments.Environment; import com.laytonsmith.core.natives.interfaces.Booleanish; /** @@ -106,8 +107,15 @@ public CClassType[] getInterfaces() { throw new RuntimeException("Cannot call getInterfaces on null"); } + /** @deprecated Use {@link #getBooleanValue(Environment, Target)} instead. */ + @Deprecated @Override public boolean getBooleanValue(Target t) { + return getBooleanValue(null, t); + } + + @Override + public boolean getBooleanValue(Environment env, Target t) { return false; } diff --git a/src/main/java/com/laytonsmith/core/constructs/CNumber.java b/src/main/java/com/laytonsmith/core/constructs/CNumber.java index 4edc77996e..7af9266def 100644 --- a/src/main/java/com/laytonsmith/core/constructs/CNumber.java +++ b/src/main/java/com/laytonsmith/core/constructs/CNumber.java @@ -3,6 +3,7 @@ import com.laytonsmith.PureUtilities.Version; import com.laytonsmith.annotations.typeof; import com.laytonsmith.core.MSVersion; +import com.laytonsmith.core.environments.Environment; /** * @@ -41,8 +42,15 @@ public Version since() { public abstract double getNumber(); + /** @deprecated Use {@link #getBooleanValue(Environment, Target)} instead. */ + @Deprecated @Override public boolean getBooleanValue(Target t) { + return getBooleanValue(null, t); + } + + @Override + public boolean getBooleanValue(Environment env, Target t) { return getNumber() != 0.0; } } diff --git a/src/main/java/com/laytonsmith/core/constructs/CReal2dMatrix.java b/src/main/java/com/laytonsmith/core/constructs/CReal2dMatrix.java index c395025fca..30ee10e35a 100644 --- a/src/main/java/com/laytonsmith/core/constructs/CReal2dMatrix.java +++ b/src/main/java/com/laytonsmith/core/constructs/CReal2dMatrix.java @@ -4,6 +4,7 @@ import com.laytonsmith.annotations.typeof; import com.laytonsmith.core.ArgumentValidation; import com.laytonsmith.core.MSVersion; +import com.laytonsmith.core.environments.Environment; import com.laytonsmith.core.exceptions.CRE.CREIllegalArgumentException; import com.laytonsmith.core.exceptions.CRE.CREIndexOverflowException; import com.laytonsmith.core.exceptions.CRE.CRELengthException; @@ -154,26 +155,54 @@ public boolean isAssociative() { return false; } + /** @deprecated Use {@link #get(Mixed, Target, Environment)} instead. */ + @Deprecated @Override public CReal2dMatrixRow get(Mixed index, Target t) throws ConfigRuntimeException { - return get(ArgumentValidation.getInt32(index, t), t); + return (CReal2dMatrixRow) get(index, t, null); } + @Override + public Mixed get(Mixed index, Target t, Environment env) throws ConfigRuntimeException { + return get(ArgumentValidation.getInt32(index, t, env), t, env); + } + + /** @deprecated Use {@link #get(String, Target, Environment)} instead. */ + @Deprecated @Override public Mixed get(String index, Target t) throws ConfigRuntimeException { + return get(index, t, null); + } + + @Override + public Mixed get(String index, Target t, Environment env) throws ConfigRuntimeException { throw new CREIllegalArgumentException("Matrices cannot be indexed into with non-numeric values.", t); } + /** @deprecated Use {@link #get(int, Target, Environment)} instead. */ + @Deprecated @Override public CReal2dMatrixRow get(int index, Target t) throws ConfigRuntimeException { + return (CReal2dMatrixRow) get(index, t, null); + } + + @Override + public Mixed get(int index, Target t, Environment env) throws ConfigRuntimeException { if(index >= getRowCount() || index < 0) { throw new CRERangeException("Matrix range out of bounds.", t); } return new CReal2dMatrixRow(this, index); } + /** @deprecated Use {@link #keySet(Environment)} instead. */ + @Deprecated @Override public Set keySet() { + return keySet(null); + } + + @Override + public Set keySet(Environment env) { Set set = new HashSet<>(); for(int i = 0; i < getRowCount(); i++) { set.add(new CInt(i, Target.UNKNOWN)); @@ -181,13 +210,27 @@ public Set keySet() { return set; } + /** @deprecated Use {@link #getBooleanValue(Environment, Target)} instead. */ + @Deprecated @Override public boolean getBooleanValue(Target t) { + return getBooleanValue(null, t); + } + + @Override + public boolean getBooleanValue(Environment env, Target t) { return data.length != 0; } + /** @deprecated Use {@link #slice(int, int, Target, Environment)} instead. */ + @Deprecated @Override public CArray slice(int begin, int end, Target t) { + return (CArray) slice(begin, end, t, null); + } + + @Override + public Mixed slice(int begin, int end, Target t, Environment env) { CArray ret = new CArray(t); int step = (begin <= end) ? 1 : -1; @@ -204,8 +247,15 @@ public CArray slice(int begin, int end, Target t) { return ret; } + /** @deprecated Use {@link #size(Environment)} instead. */ + @Deprecated @Override public long size() { + return size(null); + } + + @Override + public long size(Environment env) { return getRowCount(); } diff --git a/src/main/java/com/laytonsmith/core/constructs/CReal2dMatrixRow.java b/src/main/java/com/laytonsmith/core/constructs/CReal2dMatrixRow.java index 9beb85bd2d..3b26bff39a 100644 --- a/src/main/java/com/laytonsmith/core/constructs/CReal2dMatrixRow.java +++ b/src/main/java/com/laytonsmith/core/constructs/CReal2dMatrixRow.java @@ -6,6 +6,7 @@ import com.laytonsmith.core.MSVersion; import com.laytonsmith.core.exceptions.CRE.CRECastException; import com.laytonsmith.core.exceptions.ConfigRuntimeException; +import com.laytonsmith.core.environments.Environment; import com.laytonsmith.core.natives.interfaces.AbstractMixedClass; import com.laytonsmith.core.natives.interfaces.ArrayAccessSet; import com.laytonsmith.core.natives.interfaces.Mixed; @@ -52,23 +53,51 @@ public CClassType[] getInterfaces() { return new CClassType[]{com.laytonsmith.core.natives.interfaces.Iterable.TYPE, ArrayAccessSet.TYPE}; } + /** @deprecated Use {@link #get(String, Target, Environment)} instead. */ + @Deprecated @Override public Mixed get(String index, Target t) throws ConfigRuntimeException { + return get(index, t, null); + } + + @Override + public Mixed get(String index, Target t, Environment env) throws ConfigRuntimeException { throw new CRECastException("Real2dMatrix only supports int keys.", t); } + /** @deprecated Use {@link #get(int, Target, Environment)} instead. */ + @Deprecated @Override public CDouble get(int index, Target t) throws ConfigRuntimeException { + return (CDouble) get(index, t, null); + } + + @Override + public Mixed get(int index, Target t, Environment env) throws ConfigRuntimeException { return new CDouble(getNative(index, t), t); } + /** @deprecated Use {@link #get(Mixed, Target, Environment)} instead. */ + @Deprecated @Override public Mixed get(Mixed index, Target t) throws ConfigRuntimeException { - return get(ArgumentValidation.getInt32(index, t), t); + return get(index, t, null); } + @Override + public Mixed get(Mixed index, Target t, Environment env) throws ConfigRuntimeException { + return get(ArgumentValidation.getInt32(index, t, env), t, env); + } + + /** @deprecated Use {@link #keySet(Environment)} instead. */ + @Deprecated @Override public Set keySet() { + return keySet(null); + } + + @Override + public Set keySet(Environment env) { Set set = new HashSet<>(); for(int i = 0; i < parent.columns; i++) { set.add(new CInt(i, Target.UNKNOWN)); @@ -86,37 +115,65 @@ public boolean canBeAssociative() { return false; } + /** @deprecated Use {@link #slice(int, int, Target, Environment)} instead. */ + @Deprecated @Override public Mixed slice(int begin, int end, Target t) { + return slice(begin, end, t, null); + } + + @Override + public Mixed slice(int begin, int end, Target t, Environment env) { CArray ret = new CArray(t); int step = (begin <= end) ? 1 : -1; // Note: loop includes 'begin', excludes 'end', just like typical slice semantics for(int i = begin; i != end; i += step) { - CDouble d = get(i, t); + CDouble d = (CDouble) get(i, t, env); ret.push(d, t); } return ret; } + /** @deprecated Use {@link #getBooleanValue(Environment, Target)} instead. */ + @Deprecated @Override public boolean getBooleanValue(Target t) { + return getBooleanValue(null, t); + } + + @Override + public boolean getBooleanValue(Environment env, Target t) { // 0 dimension matrices are not possible, so this will // always have at least one value in it, thus always // true. return true; } + /** @deprecated Use {@link #size(Environment)} instead. */ + @Deprecated @Override public long size() { + return size(null); + } + + @Override + public long size(Environment env) { return parent.columns; } + /** @deprecated Use {@link #set(Mixed, Mixed, Target, Environment)} instead. */ + @Deprecated @Override public void set(Mixed index, Mixed value, Target t) { - int in = ArgumentValidation.getInt32(index, t); - double d = ArgumentValidation.getDouble(value, t); + set(index, value, t, null); + } + + @Override + public void set(Mixed index, Mixed value, Target t, Environment env) { + int in = ArgumentValidation.getInt32(index, t, env); + double d = ArgumentValidation.getDouble(value, t, env); setNative(in, d, t); } diff --git a/src/main/java/com/laytonsmith/core/constructs/CResource.java b/src/main/java/com/laytonsmith/core/constructs/CResource.java index 7967b75a1c..80b710373a 100644 --- a/src/main/java/com/laytonsmith/core/constructs/CResource.java +++ b/src/main/java/com/laytonsmith/core/constructs/CResource.java @@ -6,8 +6,11 @@ import com.laytonsmith.core.MSVersion; import com.laytonsmith.core.functions.ResourceManager.res_free_resource; import com.laytonsmith.core.natives.interfaces.Mixed; +import com.laytonsmith.core.objects.ObjectModifier; import java.io.File; +import java.util.EnumSet; +import java.util.Set; import java.util.concurrent.atomic.AtomicLong; /** @@ -17,7 +20,7 @@ * created. */ @typeof("ms.lang.Resource") -public class CResource extends Construct implements Finalizable { +public final class CResource extends Construct implements Finalizable { @SuppressWarnings("FieldNameHidesFieldInSuperclass") public static final CClassType TYPE = CClassType.get(CResource.class); @@ -130,4 +133,8 @@ public CClassType[] getInterfaces() { return CClassType.EMPTY_CLASS_ARRAY; } + @Override + public Set getObjectModifiers() { + return EnumSet.of(ObjectModifier.FINAL); + } } diff --git a/src/main/java/com/laytonsmith/core/constructs/CSlice.java b/src/main/java/com/laytonsmith/core/constructs/CSlice.java index 67c682c3fd..37842a2a24 100644 --- a/src/main/java/com/laytonsmith/core/constructs/CSlice.java +++ b/src/main/java/com/laytonsmith/core/constructs/CSlice.java @@ -4,6 +4,7 @@ import com.laytonsmith.annotations.typeof; import com.laytonsmith.core.ArgumentValidation; import com.laytonsmith.core.MSVersion; +import com.laytonsmith.core.environments.Environment; import com.laytonsmith.core.exceptions.CRE.CRECastException; import com.laytonsmith.core.exceptions.CRE.CRERangeException; import com.laytonsmith.core.exceptions.ConfigCompileException; @@ -103,7 +104,7 @@ public String toString() { } @Override - protected String getString(Stack arrays, Target t) { + protected String getString(Stack arrays, Target t, Environment env) { //We don't need to consider arrays, because we can't //get stuck in an infinite loop. return val(); @@ -114,22 +115,43 @@ public boolean inAssociativeMode() { return false; } + /** @deprecated Use {@link #set(Mixed, Mixed, Target, Environment)} instead. */ + @Deprecated @Override public void set(Mixed index, Mixed c, Target t) { + set(index, c, t, null); + } + + @Override + public void set(Mixed index, Mixed c, Target t, Environment env) { throw new CRECastException("CSlices cannot set values", t); } + /** @deprecated Use {@link #get(Mixed, Target, Environment)} instead. */ + @Deprecated @Override public Mixed get(Mixed index, Target t) { - long i = ArgumentValidation.getInt(index, t); + return get(index, t, null); + } + + @Override + public Mixed get(Mixed index, Target t, Environment env) { + long i = ArgumentValidation.getInt(index, t, env); if(i > max) { throw new CRERangeException("Index out of bounds. Index: " + i + " Size: " + max, t); } return new CInt(start + (direction * i), t); } + /** @deprecated Use {@link #keySet(Environment)} instead. */ + @Deprecated @Override public Set keySet() { + return keySet(null); + } + + @Override + public Set keySet(Environment env) { // To keep our memory footprint down, we create a "fake" keyset here, which doesn't // require actually creating an entire Set. Removing items from the set isn't supported, // but all iteration options are. @@ -165,8 +187,15 @@ public int size() { }; } + /** @deprecated Use {@link #size(Environment)} instead. */ + @Deprecated @Override public long size() { + return size(null); + } + + @Override + public long size(Environment env) { return size; } diff --git a/src/main/java/com/laytonsmith/core/constructs/CString.java b/src/main/java/com/laytonsmith/core/constructs/CString.java index 988f047cc2..d0bface90a 100644 --- a/src/main/java/com/laytonsmith/core/constructs/CString.java +++ b/src/main/java/com/laytonsmith/core/constructs/CString.java @@ -60,8 +60,15 @@ public boolean isDynamic() { return false; } + /** @deprecated Use {@link #size(Environment)} instead. */ + @Deprecated @Override public long size() { + return size(null); + } + + @Override + public long size(Environment env) { return val().length(); } @@ -70,8 +77,15 @@ public boolean canBeAssociative() { return false; } + /** @deprecated Use {@link #slice(int, int, Target, Environment)} instead. */ + @Deprecated @Override public Mixed slice(int begin, int end, Target t) { + return slice(begin, end, t, null); + } + + @Override + public Mixed slice(int begin, int end, Target t, Environment env) { if(begin > end) { return new CString("", t); } @@ -87,8 +101,15 @@ public String getQuote() { return super.getQuote(); } + /** @deprecated Use {@link #get(int, Target, Environment)} instead. */ + @Deprecated @Override public Mixed get(int index, Target t) throws ConfigRuntimeException { + return get(index, t, null); + } + + @Override + public Mixed get(int index, Target t, Environment env) throws ConfigRuntimeException { try { return new CString(this.val().charAt(index), t); } catch (StringIndexOutOfBoundsException e) { @@ -96,17 +117,31 @@ public Mixed get(int index, Target t) throws ConfigRuntimeException { } } + /** @deprecated Use {@link #get(Mixed, Target, Environment)} instead. */ + @Deprecated @Override public final Mixed get(Mixed index, Target t) throws ConfigRuntimeException { - int i = ArgumentValidation.getInt32(index, t); - return get(i, t); + return get(index, t, null); } + @Override + public final Mixed get(Mixed index, Target t, Environment env) throws ConfigRuntimeException { + int i = ArgumentValidation.getInt32(index, t, env); + return get(i, t, env); + } + + /** @deprecated Use {@link #get(String, Target, Environment)} instead. */ + @Deprecated @Override public final Mixed get(String index, Target t) { + return get(index, t, null); + } + + @Override + public final Mixed get(String index, Target t, Environment env) { try { int i = Integer.parseInt(index); - return get(i, t); + return get(i, t, env); } catch (NumberFormatException e) { throw new CREFormatException("Expecting numerical index, but received " + index, t); } @@ -117,8 +152,15 @@ public boolean isAssociative() { return false; } + /** @deprecated Use {@link #keySet(Environment)} instead. */ + @Deprecated @Override public Set keySet() { + return keySet(null); + } + + @Override + public Set keySet(Environment env) { return new AbstractSet() { @Override public int size() { @@ -175,8 +217,15 @@ public CString duplicate() { return new CString(val(), getTarget()); } + /** @deprecated Use {@link #getBooleanValue(Environment, Target)} instead. */ + @Deprecated @Override public boolean getBooleanValue(Target t) { + return getBooleanValue(null, t); + } + + @Override + public boolean getBooleanValue(Environment env, Target t) { if(val().equals("false")) { MSLog.GetLogger().e(MSLog.Tags.FALSESTRING, "String \"false\" evaluates as true (non-empty strings are" + " true). This is most likely not what you meant to do. This warning can globally be disabled" diff --git a/src/main/java/com/laytonsmith/core/constructs/Construct.java b/src/main/java/com/laytonsmith/core/constructs/Construct.java index b8a8a86104..1c267813f9 100644 --- a/src/main/java/com/laytonsmith/core/constructs/Construct.java +++ b/src/main/java/com/laytonsmith/core/constructs/Construct.java @@ -7,6 +7,9 @@ import com.laytonsmith.core.SimpleDocumentation; import com.laytonsmith.core.Static; import com.laytonsmith.core.exceptions.MarshalException; +import com.laytonsmith.core.constructs.generics.GenericParameters; +import com.laytonsmith.core.constructs.generics.LeftHandGenericUse; +import com.laytonsmith.core.environments.Environment; import com.laytonsmith.core.natives.interfaces.Mixed; import com.laytonsmith.core.objects.AccessModifier; import com.laytonsmith.core.objects.ObjectModifier; @@ -192,9 +195,9 @@ private static Object json_encode0(Mixed c, Target t) throws MarshalException { return c.val(); } else if(c instanceof CVoid) { return ""; - } else if(c instanceof CInt) { + } else if(InstanceofUtil.isInstanceof(c, CInt.class, null)) { return ((CInt) c).getInt(); - } else if(c instanceof CDouble) { + } else if(InstanceofUtil.isInstanceof(c, CDouble.class, null)) { return ((CDouble) c).getDouble(); } else if(c instanceof CBoolean) { return ((CBoolean) c).getBoolean(); @@ -411,13 +414,13 @@ public static Construct GetConstruct(Object o, boolean allowResources) throws Cl public static Object GetPOJO(Mixed c) throws ClassCastException { if(c instanceof CNull) { return null; - } else if(c instanceof CString) { + } else if(InstanceofUtil.isInstanceof(c, CString.class, null)) { return c.val(); } else if(c instanceof CBoolean) { return Boolean.valueOf(((CBoolean) c).getBoolean()); - } else if(c instanceof CInt) { + } else if(InstanceofUtil.isInstanceof(c, CInt.class, null)) { return Long.valueOf(((CInt) c).getInt()); - } else if(c instanceof CDouble) { + } else if(InstanceofUtil.isInstanceof(c, CDouble.class, null)) { return Double.valueOf(((CDouble) c).getDouble()); } else if(c.isInstanceOf(CByteArray.TYPE)) { return ((CByteArray) c).asByteArrayCopy(); @@ -495,10 +498,12 @@ protected String getQuote() { * This method may be overridden in special cases, such as dynamic types, but for most types, this * @return * @throws IllegalArgumentException If the class isn't public facing. + * @deprecated Use {@link #typeof(Environment)} instead. */ + @Deprecated @Override public CClassType typeof() { - return typeof(this); + return typeof((Environment) null); } /** @@ -511,6 +516,11 @@ public static CClassType typeof(Mixed that) { return CClassType.get(that.getClass()); } + @Override + public CClassType typeof(Environment env) { + return typeof(this); + } + /** * Overridden from {@link SimpleDocumentation}. This should just return the value of the typeof annotation, * unconditionally. @@ -605,8 +615,22 @@ public static boolean isInstanceof(Mixed that, Class type) { return that.typeof().doesExtend(CClassType.get(type)); } + /** + * @deprecated Use {@link #isInstanceOf(CClassType, LeftHandGenericUse, Environment)} instead. + */ + @Deprecated @Override public boolean isInstanceOf(CClassType type) { + return isInstanceOf(type, null, null); + } + + @Override + public boolean isInstanceOf(Class type) { + return type.isAssignableFrom(this.getClass()); + } + + @Override + public boolean isInstanceOf(CClassType type, LeftHandGenericUse lhsGenericParameters, Environment env) { if(type.getNativeType() != null) { return type.getNativeType().isAssignableFrom(this.getClass()); } @@ -614,8 +638,8 @@ public boolean isInstanceOf(CClassType type) { } @Override - public boolean isInstanceOf(Class type) { - return type.isAssignableFrom(this.getClass()); + public GenericParameters getGenericParameters() { + return null; } /** diff --git a/src/main/java/com/laytonsmith/core/constructs/InstanceofUtil.java b/src/main/java/com/laytonsmith/core/constructs/InstanceofUtil.java index fd1a37c764..17eb62aab4 100644 --- a/src/main/java/com/laytonsmith/core/constructs/InstanceofUtil.java +++ b/src/main/java/com/laytonsmith/core/constructs/InstanceofUtil.java @@ -39,7 +39,7 @@ public static Set getAllCastableClasses(CClassType c, Environment en */ private static Set getAllCastableClassesWithBlacklist(CClassType c, Set blacklist, Environment env) { - if(blacklist.contains(c)) { + if(blacklist.contains(c) || CNull.TYPE.equals(c)) { return blacklist; } blacklist.add(c); @@ -108,6 +108,9 @@ public static boolean isInstanceof(CClassType type, FullyQualifiedClassName inst * @return */ public static boolean isInstanceof(Mixed value, Class instanceofThis, Environment env) { + if(instanceofThis.isAssignableFrom(value.getClass())) { + return true; + } FullyQualifiedClassName typeof = typeof(instanceofThis); return typeof == null ? false : isInstanceof(value, typeof, env); } diff --git a/src/main/java/com/laytonsmith/core/constructs/LeftHandSideType.java b/src/main/java/com/laytonsmith/core/constructs/LeftHandSideType.java index ae7ffc0ec8..676e4a5262 100644 --- a/src/main/java/com/laytonsmith/core/constructs/LeftHandSideType.java +++ b/src/main/java/com/laytonsmith/core/constructs/LeftHandSideType.java @@ -748,6 +748,7 @@ public String toString() { return val(); } + @Override public GenericParameters getGenericParameters() { return null; } diff --git a/src/main/java/com/laytonsmith/core/exceptions/CRE/AbstractCREException.java b/src/main/java/com/laytonsmith/core/exceptions/CRE/AbstractCREException.java index 76dc6339ba..0dd97d8f6b 100644 --- a/src/main/java/com/laytonsmith/core/exceptions/CRE/AbstractCREException.java +++ b/src/main/java/com/laytonsmith/core/exceptions/CRE/AbstractCREException.java @@ -14,6 +14,8 @@ import com.laytonsmith.core.constructs.Construct; import com.laytonsmith.core.constructs.NativeTypeList; import com.laytonsmith.core.constructs.Target; +import com.laytonsmith.core.constructs.generics.GenericParameters; +import com.laytonsmith.core.constructs.generics.LeftHandGenericUse; import com.laytonsmith.core.environments.Environment; import com.laytonsmith.core.exceptions.ConfigRuntimeException; import com.laytonsmith.core.exceptions.StackTraceManager; @@ -189,25 +191,53 @@ public String val() { * @param t * @return * @throws ConfigRuntimeException + * @deprecated Use {@link #get(String, Target, Environment)} instead. */ + @Deprecated @Override public Mixed get(String index, Target t) throws ConfigRuntimeException { - return exceptionObject.get(index, t); + return get(index, t, null); } + @Override + public Mixed get(String index, Target t, Environment env) throws ConfigRuntimeException { + return exceptionObject.get(index, t, env); + } + + /** @deprecated Use {@link #get(int, Target, Environment)} instead. */ + @Deprecated @Override public Mixed get(int index, Target t) throws ConfigRuntimeException { - return exceptionObject.get(index, t); + return get(index, t, null); + } + + @Override + public Mixed get(int index, Target t, Environment env) throws ConfigRuntimeException { + return exceptionObject.get(index, t, env); } + /** @deprecated Use {@link #get(Mixed, Target, Environment)} instead. */ + @Deprecated @Override public Mixed get(Mixed index, Target t) throws ConfigRuntimeException { - return exceptionObject.get(index, t); + return get(index, t, null); } + @Override + public Mixed get(Mixed index, Target t, Environment env) throws ConfigRuntimeException { + return exceptionObject.get(index, t, env); + } + + /** @deprecated Use {@link #keySet(Environment)} instead. */ + @Deprecated @Override public Set keySet() { - return exceptionObject.keySet(); + return keySet(null); + } + + @Override + public Set keySet(Environment env) { + return exceptionObject.keySet(env); } @Override @@ -220,9 +250,16 @@ public boolean canBeAssociative() { return exceptionObject.canBeAssociative(); } + /** @deprecated Use {@link #slice(int, int, Target, Environment)} instead. */ + @Deprecated @Override public Mixed slice(int begin, int end, Target t) { - return exceptionObject.slice(begin, end, t); + return slice(begin, end, t, null); + } + + @Override + public Mixed slice(int begin, int end, Target t, Environment env) { + return exceptionObject.slice(begin, end, t, env); } @Override @@ -294,9 +331,11 @@ public CClassType[] getSuperclasses() { throw new UnsupportedOperationException(); } + /** @deprecated Use {@link #isInstanceOf(CClassType, LeftHandGenericUse, Environment)} instead. */ + @Deprecated @Override public boolean isInstanceOf(CClassType type) { - return Construct.isInstanceof(this, type); + return isInstanceOf(type, null, null); } @Override @@ -304,13 +343,37 @@ public boolean isInstanceOf(Class type) { return Construct.isInstanceof(this, type); } + @Override + public boolean isInstanceOf(CClassType type, LeftHandGenericUse lhsGenericParameters, Environment env) { + return Construct.isInstanceof(this, type); + } + + /** @deprecated Use {@link #typeof(Environment)} instead. */ + @Deprecated @Override public CClassType typeof() { + return typeof(null); + } + + @Override + public CClassType typeof(Environment env) { return Construct.typeof(this); } + @Override + public GenericParameters getGenericParameters() { + return null; + } + + /** @deprecated Use {@link #getBooleanValue(Environment, Target)} instead. */ + @Deprecated @Override public boolean getBooleanValue(Target t) { + return getBooleanValue(null, t); + } + + @Override + public boolean getBooleanValue(Environment env, Target t) { return true; } diff --git a/src/main/java/com/laytonsmith/core/natives/interfaces/AbstractMixed.java b/src/main/java/com/laytonsmith/core/natives/interfaces/AbstractMixed.java index 67150e8dd5..74e3e95f47 100644 --- a/src/main/java/com/laytonsmith/core/natives/interfaces/AbstractMixed.java +++ b/src/main/java/com/laytonsmith/core/natives/interfaces/AbstractMixed.java @@ -6,6 +6,9 @@ import com.laytonsmith.core.constructs.CClassType; import com.laytonsmith.core.constructs.Construct; import com.laytonsmith.core.constructs.Target; +import com.laytonsmith.core.constructs.generics.GenericParameters; +import com.laytonsmith.core.constructs.generics.LeftHandGenericUse; +import com.laytonsmith.core.environments.Environment; import com.laytonsmith.core.objects.AccessModifier; import com.laytonsmith.core.objects.ObjectModifier; import java.net.URL; @@ -60,8 +63,15 @@ public CClassType getContainingClass() { return null; } + /** @deprecated Use {@link #isInstanceOf(CClassType, LeftHandGenericUse, Environment)} instead. */ + @Deprecated @Override public boolean isInstanceOf(CClassType type) { + return isInstanceOf(type, null, null); + } + + @Override + public boolean isInstanceOf(CClassType type, LeftHandGenericUse lhsGenericParameters, Environment env) { if(type.getNativeType() != null) { return type.getNativeType().isAssignableFrom(this.getClass()); } @@ -81,12 +91,24 @@ public boolean isInstanceOf(Class type) { * This method may be overridden in special cases, such as dynamic types, but for most types, this * @return * @throws IllegalArgumentException If the class isn't public facing. + * @deprecated Use {@link #typeof(Environment)} instead. */ + @Deprecated @Override public CClassType typeof() { + return typeof(null); + } + + @Override + public CClassType typeof(Environment env) { return Construct.typeof(this); } + @Override + public GenericParameters getGenericParameters() { + return null; + } + @Override public URL getSourceJar() { return ClassDiscovery.GetClassContainer(this.getClass()); diff --git a/src/main/java/com/laytonsmith/core/natives/interfaces/AbstractMixedInterfaceRunner.java b/src/main/java/com/laytonsmith/core/natives/interfaces/AbstractMixedInterfaceRunner.java index 658ba2c1a0..56a7a192ee 100644 --- a/src/main/java/com/laytonsmith/core/natives/interfaces/AbstractMixedInterfaceRunner.java +++ b/src/main/java/com/laytonsmith/core/natives/interfaces/AbstractMixedInterfaceRunner.java @@ -10,6 +10,9 @@ import com.laytonsmith.core.constructs.CClassType; import com.laytonsmith.core.constructs.Construct; import com.laytonsmith.core.constructs.Target; +import com.laytonsmith.core.constructs.generics.GenericParameters; +import com.laytonsmith.core.constructs.generics.LeftHandGenericUse; +import com.laytonsmith.core.environments.Environment; import com.laytonsmith.core.objects.AccessModifier; import java.net.URL; import java.util.EnumSet; @@ -113,15 +116,24 @@ public CClassType getContainingClass() { * * @return * @throws IllegalArgumentException If the class isn't public facing. + * @deprecated Use {@link #typeof(Environment)} instead. */ + @Deprecated @Override public final CClassType typeof() { + return typeof(null); + } + + @Override + public final CClassType typeof(Environment env) { return Construct.typeof(this); } + /** @deprecated Use {@link #isInstanceOf(CClassType, LeftHandGenericUse, Environment)} instead. */ + @Deprecated @Override public boolean isInstanceOf(CClassType type) { - return Construct.isInstanceof(this, type); + return isInstanceOf(type, null, null); } @Override @@ -129,4 +141,14 @@ public boolean isInstanceOf(Class type) { return Construct.isInstanceof(this, type); } + @Override + public boolean isInstanceOf(CClassType type, LeftHandGenericUse lhsGenericParameters, Environment env) { + return Construct.isInstanceof(this, type); + } + + @Override + public GenericParameters getGenericParameters() { + return null; + } + } diff --git a/src/main/java/com/laytonsmith/core/natives/interfaces/ArrayAccess.java b/src/main/java/com/laytonsmith/core/natives/interfaces/ArrayAccess.java index b9cdf4caa3..2e78caf9bb 100644 --- a/src/main/java/com/laytonsmith/core/natives/interfaces/ArrayAccess.java +++ b/src/main/java/com/laytonsmith/core/natives/interfaces/ArrayAccess.java @@ -4,6 +4,7 @@ import com.laytonsmith.annotations.typeof; import com.laytonsmith.core.constructs.CClassType; import com.laytonsmith.core.constructs.Target; +import com.laytonsmith.core.environments.Environment; import com.laytonsmith.core.exceptions.ConfigRuntimeException; import java.util.Set; @@ -23,9 +24,21 @@ public interface ArrayAccess extends Booleanish { * @param index * @param t * @return + * @deprecated Use {@link #get(String, Target, Environment)} instead. */ + @Deprecated public Mixed get(String index, Target t) throws ConfigRuntimeException; + /** + * Return the mixed at this location, with environment context. + * + * @param index + * @param t + * @param env + * @return + */ + Mixed get(String index, Target t, Environment env) throws ConfigRuntimeException; + /** * Returns the mixed at this location. This should throw an exception if the index does not exist. This method will * not be called if {@link #isAssociative()} returns true. @@ -34,9 +47,22 @@ public interface ArrayAccess extends Booleanish { * @param t * @return * @throws ConfigRuntimeException + * @deprecated Use {@link #get(int, Target, Environment)} instead. */ + @Deprecated public Mixed get(int index, Target t) throws ConfigRuntimeException; + /** + * Returns the mixed at this location, with environment context. + * + * @param index + * @param t + * @param env + * @return + * @throws ConfigRuntimeException + */ + Mixed get(int index, Target t, Environment env) throws ConfigRuntimeException; + /** * Returns the mixed at this location. This should throw an exception if the index does not exist. This method may * be called whether or not it isAssociative returns true. @@ -45,17 +71,40 @@ public interface ArrayAccess extends Booleanish { * @param t * @return * @throws ConfigRuntimeException + * @deprecated Use {@link #get(Mixed, Target, Environment)} instead. */ + @Deprecated public Mixed get(Mixed index, Target t) throws ConfigRuntimeException; + /** + * Returns the mixed at this location, with environment context. + * + * @param index + * @param t + * @param env + * @return + * @throws ConfigRuntimeException + */ + Mixed get(Mixed index, Target t, Environment env) throws ConfigRuntimeException; + /** * If {@link #isAssociative()} returns true, this should return a set of all keys. If {@link #isAssociative()} * returns false, this method will not be called. * * @return + * @deprecated Use {@link #keySet(Environment)} instead. */ + @Deprecated public Set keySet(); + /** + * Returns the key set with environment context. + * + * @param env + * @return + */ + Set keySet(Environment env); + /** * Unlike {@link #canBeAssociative()}, this is a runtime flag. If the underlying object is associative (that is, it * is an unordered, non numeric key set), this should return true. If this is true, then @@ -80,23 +129,26 @@ public interface ArrayAccess extends Booleanish { * Returns a slice at the specified location. Should throw an exception if an element in the range doesn't exist. * The range is inclusive. * - * @implNote In general, MethodScript supports undefined begin and end slices, as well as reverse slices. For - * CArray type only, this is fully covered, but for other slice types, only negative slice numbers are converted, - * and subclasses must handle both forward and reverse slices if applicable. A good way to handle that is as such: - *

-	 * int start = Math.min(begin, end);
-	 * int stop = Math.max(begin, end);
-	 * int step = (begin <= end) ? 1 : -1;
-	 * for(int i = start; i != stop; i += step) { ... }
-	 * 
- * * @param begin * @param end * @param t * @return + * @deprecated Use {@link #slice(int, int, Target, Environment)} instead. */ + @Deprecated public Mixed slice(int begin, int end, Target t); + /** + * Returns a slice at the specified location, with environment context. + * + * @param begin + * @param end + * @param t + * @param env + * @return + */ + Mixed slice(int begin, int end, Target t, Environment env); + @Override public String docs(); diff --git a/src/main/java/com/laytonsmith/core/natives/interfaces/ArrayAccessSet.java b/src/main/java/com/laytonsmith/core/natives/interfaces/ArrayAccessSet.java index 1fa79ea07b..63838ffc5b 100644 --- a/src/main/java/com/laytonsmith/core/natives/interfaces/ArrayAccessSet.java +++ b/src/main/java/com/laytonsmith/core/natives/interfaces/ArrayAccessSet.java @@ -3,6 +3,7 @@ import com.laytonsmith.annotations.typeof; import com.laytonsmith.core.constructs.CClassType; import com.laytonsmith.core.constructs.Target; +import com.laytonsmith.core.environments.Environment; /** * Things that implement this can set the value via square bracket notation. The generic type provided is the index @@ -23,6 +24,18 @@ public interface ArrayAccessSet extends Mixed { * @param index The zero-based index. * @param value The value to set. * @param t The code target. + * @deprecated Use {@link #set(Mixed, Mixed, Target, Environment)} instead. */ + @Deprecated public void set(Mixed index, Mixed value, Target t); + + /** + * Sets the value at the specified index in the object, with environment context. + * + * @param index The zero-based index. + * @param value The value to set. + * @param t The code target. + * @param env The environment. + */ + void set(Mixed index, Mixed value, Target t, Environment env); } diff --git a/src/main/java/com/laytonsmith/core/natives/interfaces/Booleanish.java b/src/main/java/com/laytonsmith/core/natives/interfaces/Booleanish.java index 8074cdd2ab..b6a8850e86 100644 --- a/src/main/java/com/laytonsmith/core/natives/interfaces/Booleanish.java +++ b/src/main/java/com/laytonsmith/core/natives/interfaces/Booleanish.java @@ -4,7 +4,7 @@ import com.laytonsmith.core.ArgumentValidation; import com.laytonsmith.core.constructs.CClassType; import com.laytonsmith.core.constructs.Target; - +import com.laytonsmith.core.environments.Environment; /** * A value that is Booleanish is a non-boolean value, that can be converted to Boolean. @@ -28,6 +28,18 @@ public interface Booleanish extends Mixed { * @param t The code target, in case there are errors that are thrown, the correct target can be provided in the * error. * @return True if the value is trueish, false if it is falseish. + * @deprecated Use {@link #getBooleanValue(Environment, Target)} instead. */ + @Deprecated boolean getBooleanValue(Target t); + + /** + * Returns true if this value is a trueish value, with environment context. + * + * @param env The environment. + * @param t The code target. + * @return True if the value is trueish, false if it is falseish. + */ + boolean getBooleanValue(Environment env, Target t); + } diff --git a/src/main/java/com/laytonsmith/core/natives/interfaces/MEnumType.java b/src/main/java/com/laytonsmith/core/natives/interfaces/MEnumType.java index 2aa4e17be3..62825e3c54 100644 --- a/src/main/java/com/laytonsmith/core/natives/interfaces/MEnumType.java +++ b/src/main/java/com/laytonsmith/core/natives/interfaces/MEnumType.java @@ -15,6 +15,9 @@ import com.laytonsmith.core.constructs.CClassType; import com.laytonsmith.core.constructs.Construct; import com.laytonsmith.core.constructs.Target; +import com.laytonsmith.core.constructs.generics.GenericParameters; +import com.laytonsmith.core.constructs.generics.LeftHandGenericUse; +import com.laytonsmith.core.environments.Environment; import com.laytonsmith.core.exceptions.CRE.CREIllegalArgumentException; import com.laytonsmith.core.exceptions.CRE.CREIndexOverflowException; import com.laytonsmith.core.exceptions.CRE.CREUnsupportedOperationException; @@ -137,9 +140,11 @@ public URL getSourceJar() { return ClassDiscovery.GetClassContainer(enumClass); } + /** @deprecated Use {@link #isInstanceOf(CClassType, LeftHandGenericUse, Environment)} instead. */ + @Deprecated @Override public boolean isInstanceOf(CClassType type) { - return Mixed.TYPE.equals(type) || MEnumType.TYPE.equals(type) || this.typeof().equals(type); + return isInstanceOf(type, null, null); } @Override @@ -147,8 +152,20 @@ public boolean isInstanceOf(Class type) { return type.isAssignableFrom(this.getClass()); } + @Override + public boolean isInstanceOf(CClassType type, LeftHandGenericUse lhsGenericParameters, Environment env) { + return Mixed.TYPE.equals(type) || MEnumType.TYPE.equals(type) || this.typeof(env).equals(type); + } + + /** @deprecated Use {@link #typeof(Environment)} instead. */ + @Deprecated @Override public CClassType typeof() { + return typeof(null); + } + + @Override + public CClassType typeof(Environment env) { try { return CClassType.get(fqcn); } catch (ClassNotFoundException ex) { @@ -246,8 +263,15 @@ public String toString() { return v.toString(); } + /** @deprecated Use {@link #typeof(Environment)} instead. */ + @Deprecated @Override public CClassType typeof() { + return typeof(null); + } + + @Override + public CClassType typeof(Environment env) { try { return CClassType.get(fqcn); } catch (ClassNotFoundException ex) { @@ -255,9 +279,11 @@ public CClassType typeof() { } } + /** @deprecated Use {@link #isInstanceOf(CClassType, LeftHandGenericUse, Environment)} instead. */ + @Deprecated @Override public boolean isInstanceOf(CClassType type) { - return Construct.isInstanceof(this, type); + return isInstanceOf(type, null, null); } @Override @@ -265,6 +291,16 @@ public boolean isInstanceOf(Class type) { return Construct.isInstanceof(this, type); } + @Override + public boolean isInstanceOf(CClassType type, LeftHandGenericUse lhsGenericParameters, Environment env) { + return Construct.isInstanceof(this, type); + } + + @Override + public GenericParameters getGenericParameters() { + return null; + } + @Override public CClassType getContainingClass() { return null; @@ -327,8 +363,15 @@ public int size() { }; } + /** @deprecated Use {@link #getBooleanValue(Environment, Target)} instead. */ + @Deprecated @Override public boolean getBooleanValue(Target t) { + return getBooleanValue(null, t); + } + + @Override + public boolean getBooleanValue(Environment env, Target t) { return true; } @@ -428,9 +471,11 @@ public CClassType getContainingClass() { return null; } + /** @deprecated Use {@link #isInstanceOf(CClassType, LeftHandGenericUse, Environment)} instead. */ + @Deprecated @Override public boolean isInstanceOf(CClassType type) { - return TYPE.equals(type); + return isInstanceOf(type, null, null); } @Override @@ -438,11 +483,28 @@ public boolean isInstanceOf(Class type) { throw new UnsupportedOperationException("Not supported yet."); } + @Override + public boolean isInstanceOf(CClassType type, LeftHandGenericUse lhsGenericParameters, Environment env) { + return TYPE.equals(type); + } + + /** @deprecated Use {@link #typeof(Environment)} instead. */ + @Deprecated @Override public CClassType typeof() { + return typeof(null); + } + + @Override + public CClassType typeof(Environment env) { return TYPE; } + @Override + public GenericParameters getGenericParameters() { + return null; + } + @Override public URL getSourceJar() { return ClassDiscovery.GetClassContainer(MEnumType.class); @@ -472,8 +534,15 @@ public List values() { } return values; } + /** @deprecated Use {@link #get(String, Target, Environment)} instead. */ + @Deprecated @Override public Mixed get(String index, Target t) throws ConfigRuntimeException { + return get(index, t, null); + } + + @Override + public Mixed get(String index, Target t, Environment env) throws ConfigRuntimeException { for(MEnumTypeValue v : values()) { if(v.name().equals(index)) { return v; @@ -482,26 +551,54 @@ public Mixed get(String index, Target t) throws ConfigRuntimeException { throw new CREIllegalArgumentException(index + " cannot be found in " + typeof(), t); } + /** @deprecated Use {@link #get(int, Target, Environment)} instead. */ + @Deprecated @Override public Mixed get(int index, Target t) throws ConfigRuntimeException { + return get(index, t, null); + } + + @Override + public Mixed get(int index, Target t, Environment env) throws ConfigRuntimeException { if(index >= values().size()) { throw new CREIndexOverflowException("The index " + index + " is out of bounds", t); } return values().get(index); } + /** @deprecated Use {@link #get(Mixed, Target, Environment)} instead. */ + @Deprecated @Override public Mixed get(Mixed index, Target t) throws ConfigRuntimeException { - return get(index.val(), t); + return get(index, t, null); } + @Override + public Mixed get(Mixed index, Target t, Environment env) throws ConfigRuntimeException { + return get(index.val(), t, env); + } + + /** @deprecated Use {@link #keySet(Environment)} instead. */ + @Deprecated @Override public Set keySet() { + return keySet(null); + } + + @Override + public Set keySet(Environment env) { return values().stream().collect(Collectors.toSet()); } + /** @deprecated Use {@link #size(Environment)} instead. */ + @Deprecated @Override public long size() { + return size(null); + } + + @Override + public long size(Environment env) { return values().size(); } @@ -515,8 +612,15 @@ public boolean canBeAssociative() { return true; } + /** @deprecated Use {@link #slice(int, int, Target, Environment)} instead. */ + @Deprecated @Override public Mixed slice(int begin, int end, Target t) { + return slice(begin, end, t, null); + } + + @Override + public Mixed slice(int begin, int end, Target t, Environment env) { throw new CREUnsupportedOperationException("Cannot slice an enum", t); } @@ -526,8 +630,15 @@ public Mixed slice(int begin, int end, Target t) { */ protected abstract List getValues(); + /** @deprecated Use {@link #getBooleanValue(Environment, Target)} instead. */ + @Deprecated @Override public boolean getBooleanValue(Target t) { + return getBooleanValue(null, t); + } + + @Override + public boolean getBooleanValue(Environment env, Target t) { return true; } diff --git a/src/main/java/com/laytonsmith/core/natives/interfaces/Mixed.java b/src/main/java/com/laytonsmith/core/natives/interfaces/Mixed.java index 3333761733..a654046807 100644 --- a/src/main/java/com/laytonsmith/core/natives/interfaces/Mixed.java +++ b/src/main/java/com/laytonsmith/core/natives/interfaces/Mixed.java @@ -10,6 +10,9 @@ import com.laytonsmith.core.constructs.CClassType; import com.laytonsmith.core.constructs.Construct; import com.laytonsmith.core.constructs.Target; +import com.laytonsmith.core.constructs.generics.GenericParameters; +import com.laytonsmith.core.constructs.generics.LeftHandGenericUse; +import com.laytonsmith.core.environments.Environment; import com.laytonsmith.core.objects.AccessModifier; import java.util.Set; @@ -116,9 +119,22 @@ public interface Mixed extends Cloneable, Documentation { * * @param type * @return + * @deprecated Use {@link #isInstanceOf(CClassType, LeftHandGenericUse, Environment)} instead. */ + @Deprecated public boolean isInstanceOf(CClassType type); + /** + * Checks if this value is an instance of the given type, with environment context. + * The lhsGenericParameters parameter is for future generic type checking and may be null. + * + * @param type + * @param lhsGenericParameters + * @param env + * @return + */ + public boolean isInstanceOf(CClassType type, LeftHandGenericUse lhsGenericParameters, Environment env); + /** * Generally speaking, we cannot use Java's instanceof keyword to determine if something is an instanceof, because * user classes do not extend the hierarchy of objects in MethodScript. Essentially, we need to extend Java's @@ -143,9 +159,27 @@ public interface Mixed extends Cloneable, Documentation { * * @return * @throws IllegalArgumentException If the class isn't public facing. + * @deprecated Use {@link #typeof(Environment)} instead. */ + @Deprecated public CClassType typeof(); + /** + * Returns the typeof this value, as a CClassType object, with environment context. + * + * @param env + * @return + * @throws IllegalArgumentException If the class isn't public facing. + */ + public CClassType typeof(Environment env); + + /** + * Returns the generic parameters for this value, or null if none. + * + * @return + */ + public GenericParameters getGenericParameters(); + /** * Casts the class to the specified type. This only works with Java types, and so for dynamic elements, this * may throw a RuntimeException. For dynamic types, use the other castTo. diff --git a/src/main/java/com/laytonsmith/core/natives/interfaces/Sizeable.java b/src/main/java/com/laytonsmith/core/natives/interfaces/Sizeable.java index 33cee2f9cb..8fb7b97738 100644 --- a/src/main/java/com/laytonsmith/core/natives/interfaces/Sizeable.java +++ b/src/main/java/com/laytonsmith/core/natives/interfaces/Sizeable.java @@ -2,6 +2,7 @@ import com.laytonsmith.annotations.typeof; import com.laytonsmith.core.constructs.CClassType; +import com.laytonsmith.core.environments.Environment; /** * Any object that can report a size should implement this. @@ -16,6 +17,16 @@ public interface Sizeable extends Mixed { * Returns the size of this object. * * @return + * @deprecated Use {@link #size(Environment)} instead. */ + @Deprecated long size(); + + /** + * Returns the size of this object, with environment context. + * + * @param env + * @return + */ + long size(Environment env); } diff --git a/src/main/java/com/laytonsmith/core/objects/UserObject.java b/src/main/java/com/laytonsmith/core/objects/UserObject.java index f370fcd56e..f2bbb48f95 100644 --- a/src/main/java/com/laytonsmith/core/objects/UserObject.java +++ b/src/main/java/com/laytonsmith/core/objects/UserObject.java @@ -9,6 +9,8 @@ import com.laytonsmith.core.constructs.CNull; import com.laytonsmith.core.constructs.Construct; import com.laytonsmith.core.constructs.Target; +import com.laytonsmith.core.constructs.generics.GenericParameters; +import com.laytonsmith.core.constructs.generics.LeftHandGenericUse; import com.laytonsmith.core.environments.Environment; import com.laytonsmith.core.natives.interfaces.Mixed; import java.net.URL; @@ -149,9 +151,11 @@ public CClassType getContainingClass() { return objectDefinition.getContainingClass(); } + /** @deprecated Use {@link #isInstanceOf(CClassType, LeftHandGenericUse, Environment)} instead. */ + @Deprecated @Override public boolean isInstanceOf(CClassType type) { - return Construct.isInstanceof(this, type); + return isInstanceOf(type, null, null); } @Override @@ -159,11 +163,28 @@ public boolean isInstanceOf(Class type) { return Construct.isInstanceof(this, type); } + @Override + public boolean isInstanceOf(CClassType type, LeftHandGenericUse lhsGenericParameters, Environment env) { + return Construct.isInstanceof(this, type); + } + + /** @deprecated Use {@link #typeof(Environment)} instead. */ + @Deprecated @Override public CClassType typeof() { + return typeof(null); + } + + @Override + public CClassType typeof(Environment env) { return objectDefinition.getType(); } + @Override + public GenericParameters getGenericParameters() { + return null; + } + @Override public URL getSourceJar() { return null; From d0f2eac0b9e49ff665d7af82f6bded6f48b57384 Mon Sep 17 00:00:00 2001 From: LadyCailin Date: Sat, 21 Feb 2026 19:02:29 +0100 Subject: [PATCH 03/28] Reverse the order of the getBooleanValue parameters. --- .../com/laytonsmith/core/constructs/CArray.java | 9 ++++++--- .../laytonsmith/core/constructs/CBoolean.java | 6 +++--- .../laytonsmith/core/constructs/CClassType.java | 6 +++--- .../laytonsmith/core/constructs/CClosure.java | 6 +++--- .../laytonsmith/core/constructs/CDecimal.java | 6 +++--- .../laytonsmith/core/constructs/CFixedArray.java | 6 +++--- .../com/laytonsmith/core/constructs/CNull.java | 6 +++--- .../com/laytonsmith/core/constructs/CNumber.java | 6 +++--- .../core/constructs/CReal2dMatrix.java | 6 +++--- .../core/constructs/CReal2dMatrixRow.java | 6 +++--- .../com/laytonsmith/core/constructs/CString.java | 6 +++--- .../exceptions/CRE/AbstractCREException.java | 6 +++--- .../core/natives/interfaces/Booleanish.java | 16 ++++++++++++---- .../core/natives/interfaces/MEnumType.java | 12 ++++++------ 14 files changed, 57 insertions(+), 46 deletions(-) diff --git a/src/main/java/com/laytonsmith/core/constructs/CArray.java b/src/main/java/com/laytonsmith/core/constructs/CArray.java index df90b50747..52e84dda81 100644 --- a/src/main/java/com/laytonsmith/core/constructs/CArray.java +++ b/src/main/java/com/laytonsmith/core/constructs/CArray.java @@ -557,6 +557,9 @@ public final Mixed get(long index, Target t) { } public final Mixed get(long index, Target t, Environment env) { + if((int) index != index) { + throw new CREIndexOverflowException("The element at index \"" + index + "\" does not exist", t); + } return this.get(new CInt(index, t), t, env); } @@ -1177,15 +1180,15 @@ public CClassType[] getInterfaces() { ArrayAccessSet.TYPE}; } - /** @deprecated Use {@link #getBooleanValue(Environment, Target)} instead. */ + /** @deprecated Use {@link #getBooleanValue(Target, Environment)} instead. */ @Deprecated @Override public boolean getBooleanValue(Target t) { - return getBooleanValue(null, t); + return getBooleanValue(t, null); } @Override - public boolean getBooleanValue(Environment env, Target t) { + public boolean getBooleanValue(Target t, Environment env) { return size(env) > 0; } diff --git a/src/main/java/com/laytonsmith/core/constructs/CBoolean.java b/src/main/java/com/laytonsmith/core/constructs/CBoolean.java index df6126656b..8fe73d2a0c 100644 --- a/src/main/java/com/laytonsmith/core/constructs/CBoolean.java +++ b/src/main/java/com/laytonsmith/core/constructs/CBoolean.java @@ -90,15 +90,15 @@ public boolean getBoolean() { return val; } - /** @deprecated Use {@link #getBooleanValue(Environment, Target)} instead. */ + /** @deprecated Use {@link #getBooleanValue(Target, Environment)} instead. */ @Deprecated @Override public boolean getBooleanValue(Target t) { - return getBooleanValue(null, t); + return getBooleanValue(t, null); } @Override - public boolean getBooleanValue(Environment env, Target t) { + public boolean getBooleanValue(Target t, Environment env) { return val; } diff --git a/src/main/java/com/laytonsmith/core/constructs/CClassType.java b/src/main/java/com/laytonsmith/core/constructs/CClassType.java index 9eb555a9e6..99e2378d54 100644 --- a/src/main/java/com/laytonsmith/core/constructs/CClassType.java +++ b/src/main/java/com/laytonsmith/core/constructs/CClassType.java @@ -719,15 +719,15 @@ public Class getNativeType() { return nativeClass; } - /** @deprecated Use {@link #getBooleanValue(Environment, Target)} instead. */ + /** @deprecated Use {@link #getBooleanValue(Target, Environment)} instead. */ @Deprecated @Override public boolean getBooleanValue(Target t) { - return getBooleanValue(null, t); + return getBooleanValue(t, null); } @Override - public boolean getBooleanValue(Environment env, Target t) { + public boolean getBooleanValue(Target t, Environment env) { return true; } diff --git a/src/main/java/com/laytonsmith/core/constructs/CClosure.java b/src/main/java/com/laytonsmith/core/constructs/CClosure.java index 0ad103b6de..956a812ab5 100644 --- a/src/main/java/com/laytonsmith/core/constructs/CClosure.java +++ b/src/main/java/com/laytonsmith/core/constructs/CClosure.java @@ -350,15 +350,15 @@ public CClassType[] getInterfaces() { return new CClassType[]{Callable.TYPE, Booleanish.TYPE}; } - /** @deprecated Use {@link #getBooleanValue(Environment, Target)} instead. */ + /** @deprecated Use {@link #getBooleanValue(Target, Environment)} instead. */ @Deprecated @Override public boolean getBooleanValue(Target t) { - return getBooleanValue(null, t); + return getBooleanValue(t, null); } @Override - public boolean getBooleanValue(Environment env, Target t) { + public boolean getBooleanValue(Target t, Environment env) { return true; } } diff --git a/src/main/java/com/laytonsmith/core/constructs/CDecimal.java b/src/main/java/com/laytonsmith/core/constructs/CDecimal.java index 8aaf7e7af6..8bed5efa14 100644 --- a/src/main/java/com/laytonsmith/core/constructs/CDecimal.java +++ b/src/main/java/com/laytonsmith/core/constructs/CDecimal.java @@ -84,15 +84,15 @@ public CDecimal duplicate() { return new CDecimal(val, getTarget()); } - /** @deprecated Use {@link #getBooleanValue(Environment, Target)} instead. */ + /** @deprecated Use {@link #getBooleanValue(Target, Environment)} instead. */ @Deprecated @Override public boolean getBooleanValue(Target t) { - return getBooleanValue(null, t); + return getBooleanValue(t, null); } @Override - public boolean getBooleanValue(Environment env, Target t) { + public boolean getBooleanValue(Target t, Environment env) { return val.compareTo(new BigDecimal(0)) != 0; } diff --git a/src/main/java/com/laytonsmith/core/constructs/CFixedArray.java b/src/main/java/com/laytonsmith/core/constructs/CFixedArray.java index ac18ea4477..f5feabb13f 100644 --- a/src/main/java/com/laytonsmith/core/constructs/CFixedArray.java +++ b/src/main/java/com/laytonsmith/core/constructs/CFixedArray.java @@ -152,15 +152,15 @@ public Mixed slice(int begin, int end, Target t, Environment env) { throw new CREUnsupportedOperationException("slices are not yet implemented on fixed_array", t); } - /** @deprecated Use {@link #getBooleanValue(Environment, Target)} instead. */ + /** @deprecated Use {@link #getBooleanValue(Target, Environment)} instead. */ @Deprecated @Override public boolean getBooleanValue(Target t) { - return getBooleanValue(null, t); + return getBooleanValue(t, null); } @Override - public boolean getBooleanValue(Environment env, Target t) { + public boolean getBooleanValue(Target t, Environment env) { return size(env) > 0; } diff --git a/src/main/java/com/laytonsmith/core/constructs/CNull.java b/src/main/java/com/laytonsmith/core/constructs/CNull.java index 065867aff1..be684e3e76 100644 --- a/src/main/java/com/laytonsmith/core/constructs/CNull.java +++ b/src/main/java/com/laytonsmith/core/constructs/CNull.java @@ -107,15 +107,15 @@ public CClassType[] getInterfaces() { throw new RuntimeException("Cannot call getInterfaces on null"); } - /** @deprecated Use {@link #getBooleanValue(Environment, Target)} instead. */ + /** @deprecated Use {@link #getBooleanValue(Target, Environment)} instead. */ @Deprecated @Override public boolean getBooleanValue(Target t) { - return getBooleanValue(null, t); + return getBooleanValue(t, null); } @Override - public boolean getBooleanValue(Environment env, Target t) { + public boolean getBooleanValue(Target t, Environment env) { return false; } diff --git a/src/main/java/com/laytonsmith/core/constructs/CNumber.java b/src/main/java/com/laytonsmith/core/constructs/CNumber.java index 7af9266def..daafac0161 100644 --- a/src/main/java/com/laytonsmith/core/constructs/CNumber.java +++ b/src/main/java/com/laytonsmith/core/constructs/CNumber.java @@ -42,15 +42,15 @@ public Version since() { public abstract double getNumber(); - /** @deprecated Use {@link #getBooleanValue(Environment, Target)} instead. */ + /** @deprecated Use {@link #getBooleanValue(Target, Environment)} instead. */ @Deprecated @Override public boolean getBooleanValue(Target t) { - return getBooleanValue(null, t); + return getBooleanValue(t, null); } @Override - public boolean getBooleanValue(Environment env, Target t) { + public boolean getBooleanValue(Target t, Environment env) { return getNumber() != 0.0; } } diff --git a/src/main/java/com/laytonsmith/core/constructs/CReal2dMatrix.java b/src/main/java/com/laytonsmith/core/constructs/CReal2dMatrix.java index 30ee10e35a..1a00825377 100644 --- a/src/main/java/com/laytonsmith/core/constructs/CReal2dMatrix.java +++ b/src/main/java/com/laytonsmith/core/constructs/CReal2dMatrix.java @@ -210,15 +210,15 @@ public Set keySet(Environment env) { return set; } - /** @deprecated Use {@link #getBooleanValue(Environment, Target)} instead. */ + /** @deprecated Use {@link #getBooleanValue(Target, Environment)} instead. */ @Deprecated @Override public boolean getBooleanValue(Target t) { - return getBooleanValue(null, t); + return getBooleanValue(t, null); } @Override - public boolean getBooleanValue(Environment env, Target t) { + public boolean getBooleanValue(Target t, Environment env) { return data.length != 0; } diff --git a/src/main/java/com/laytonsmith/core/constructs/CReal2dMatrixRow.java b/src/main/java/com/laytonsmith/core/constructs/CReal2dMatrixRow.java index 3b26bff39a..c9487c02ef 100644 --- a/src/main/java/com/laytonsmith/core/constructs/CReal2dMatrixRow.java +++ b/src/main/java/com/laytonsmith/core/constructs/CReal2dMatrixRow.java @@ -136,15 +136,15 @@ public Mixed slice(int begin, int end, Target t, Environment env) { return ret; } - /** @deprecated Use {@link #getBooleanValue(Environment, Target)} instead. */ + /** @deprecated Use {@link #getBooleanValue(Target, Environment)} instead. */ @Deprecated @Override public boolean getBooleanValue(Target t) { - return getBooleanValue(null, t); + return getBooleanValue(t, null); } @Override - public boolean getBooleanValue(Environment env, Target t) { + public boolean getBooleanValue(Target t, Environment env) { // 0 dimension matrices are not possible, so this will // always have at least one value in it, thus always // true. diff --git a/src/main/java/com/laytonsmith/core/constructs/CString.java b/src/main/java/com/laytonsmith/core/constructs/CString.java index d0bface90a..b3b3557948 100644 --- a/src/main/java/com/laytonsmith/core/constructs/CString.java +++ b/src/main/java/com/laytonsmith/core/constructs/CString.java @@ -217,15 +217,15 @@ public CString duplicate() { return new CString(val(), getTarget()); } - /** @deprecated Use {@link #getBooleanValue(Environment, Target)} instead. */ + /** @deprecated Use {@link #getBooleanValue(Target, Environment)} instead. */ @Deprecated @Override public boolean getBooleanValue(Target t) { - return getBooleanValue(null, t); + return getBooleanValue(t, null); } @Override - public boolean getBooleanValue(Environment env, Target t) { + public boolean getBooleanValue(Target t, Environment env) { if(val().equals("false")) { MSLog.GetLogger().e(MSLog.Tags.FALSESTRING, "String \"false\" evaluates as true (non-empty strings are" + " true). This is most likely not what you meant to do. This warning can globally be disabled" diff --git a/src/main/java/com/laytonsmith/core/exceptions/CRE/AbstractCREException.java b/src/main/java/com/laytonsmith/core/exceptions/CRE/AbstractCREException.java index 0dd97d8f6b..48fa200b3a 100644 --- a/src/main/java/com/laytonsmith/core/exceptions/CRE/AbstractCREException.java +++ b/src/main/java/com/laytonsmith/core/exceptions/CRE/AbstractCREException.java @@ -365,15 +365,15 @@ public GenericParameters getGenericParameters() { return null; } - /** @deprecated Use {@link #getBooleanValue(Environment, Target)} instead. */ + /** @deprecated Use {@link #getBooleanValue(Target, Environment)} instead. */ @Deprecated @Override public boolean getBooleanValue(Target t) { - return getBooleanValue(null, t); + return getBooleanValue(t, null); } @Override - public boolean getBooleanValue(Environment env, Target t) { + public boolean getBooleanValue(Target t, Environment env) { return true; } diff --git a/src/main/java/com/laytonsmith/core/natives/interfaces/Booleanish.java b/src/main/java/com/laytonsmith/core/natives/interfaces/Booleanish.java index b6a8850e86..412ad2d3ea 100644 --- a/src/main/java/com/laytonsmith/core/natives/interfaces/Booleanish.java +++ b/src/main/java/com/laytonsmith/core/natives/interfaces/Booleanish.java @@ -28,18 +28,26 @@ public interface Booleanish extends Mixed { * @param t The code target, in case there are errors that are thrown, the correct target can be provided in the * error. * @return True if the value is trueish, false if it is falseish. - * @deprecated Use {@link #getBooleanValue(Environment, Target)} instead. + * @deprecated Use {@link #getBooleanValue(Target, Environment)} instead. */ @Deprecated boolean getBooleanValue(Target t); /** - * Returns true if this value is a trueish value, with environment context. + * Returns true if this value is a trueish value. Each implementation is free to define this as they wish. In + * general, code that supports Booleanish values should not use this method directly, use + * {@link ArgumentValidation#getBooleanish(com.laytonsmith.core.natives.interfaces.Mixed, + * com.laytonsmith.core.constructs.Target)}, which ensures that the error message, if this is not an actual + * Booleanish value, is standardized. In general, methods should not accept a Booleanish value (with some critical + * exceptions, such as if(), for(), etc) as in the future, this will prevent functions from being fully strongly + * typed in strict mode. In non-strict mode (or strict mode with the auto keyword) Booleanish types will be cross + * cast to a boolean first anyways, so there is no point in accepting Booleanish values. * + * @param t The code target, in case there are errors that are thrown, the correct target can be provided in the + * error. * @param env The environment. - * @param t The code target. * @return True if the value is trueish, false if it is falseish. */ - boolean getBooleanValue(Environment env, Target t); + boolean getBooleanValue(Target t, Environment env); } diff --git a/src/main/java/com/laytonsmith/core/natives/interfaces/MEnumType.java b/src/main/java/com/laytonsmith/core/natives/interfaces/MEnumType.java index 62825e3c54..5507334db3 100644 --- a/src/main/java/com/laytonsmith/core/natives/interfaces/MEnumType.java +++ b/src/main/java/com/laytonsmith/core/natives/interfaces/MEnumType.java @@ -363,15 +363,15 @@ public int size() { }; } - /** @deprecated Use {@link #getBooleanValue(Environment, Target)} instead. */ + /** @deprecated Use {@link #getBooleanValue(Target, Environment)} instead. */ @Deprecated @Override public boolean getBooleanValue(Target t) { - return getBooleanValue(null, t); + return getBooleanValue(t, null); } @Override - public boolean getBooleanValue(Environment env, Target t) { + public boolean getBooleanValue(Target t, Environment env) { return true; } @@ -630,15 +630,15 @@ public Mixed slice(int begin, int end, Target t, Environment env) { */ protected abstract List getValues(); - /** @deprecated Use {@link #getBooleanValue(Environment, Target)} instead. */ + /** @deprecated Use {@link #getBooleanValue(Target, Environment)} instead. */ @Deprecated @Override public boolean getBooleanValue(Target t) { - return getBooleanValue(null, t); + return getBooleanValue(t, null); } @Override - public boolean getBooleanValue(Environment env, Target t) { + public boolean getBooleanValue(Target t, Environment env) { return true; } From aae5d12e49bde6a753aabec2c8a784fda144639f Mon Sep 17 00:00:00 2001 From: LadyCailin Date: Sun, 22 Feb 2026 16:45:10 +0100 Subject: [PATCH 04/28] Upgrade some call sites to non-deprecated versions --- pom.xml | 2 + .../laytonsmith/core/ArgumentValidation.java | 14 +- .../com/laytonsmith/core/ObjectGenerator.java | 42 +++- .../java/com/laytonsmith/core/Procedure.java | 12 +- .../java/com/laytonsmith/core/Static.java | 13 +- .../core/asm/LLVMArgumentValidation.java | 2 +- .../core/asm/LLVMPlatformResolver.java | 2 +- .../core/constructs/CFixedArray.java | 16 +- .../core/constructs/CMutablePrimitive.java | 2 +- .../core/constructs/InstanceofUtil.java | 2 +- .../core/events/AbstractGenericEvent.java | 28 ++- .../com/laytonsmith/core/events/Event.java | 2 +- .../laytonsmith/core/events/EventUtils.java | 9 +- .../core/events/drivers/BlockEvents.java | 63 +----- .../core/events/drivers/CmdlineEvents.java | 14 +- .../core/events/drivers/EntityEvents.java | 134 +----------- .../core/events/drivers/InventoryEvents.java | 62 ------ .../core/events/drivers/PlayerEvents.java | 199 ++++++------------ .../core/events/drivers/PluginEvents.java | 6 - .../core/events/drivers/ServerEvents.java | 35 +-- .../core/events/drivers/VehicleEvents.java | 34 +-- .../core/events/drivers/WeatherEvents.java | 15 -- .../core/events/drivers/WorldEvents.java | 20 -- .../core/functions/ArrayHandling.java | 10 +- .../laytonsmith/core/functions/BossBar.java | 8 +- .../laytonsmith/core/functions/Cmdline.java | 8 +- .../laytonsmith/core/functions/Commands.java | 8 +- .../core/functions/ControlFlow.java | 18 +- .../laytonsmith/core/functions/Crypto.java | 4 +- .../core/functions/DataTransformations.java | 2 +- .../com/laytonsmith/core/functions/Debug.java | 6 +- .../laytonsmith/core/functions/Echoes.java | 4 +- .../core/functions/Enchantments.java | 10 +- .../core/functions/EventBinding.java | 18 +- .../core/functions/Exceptions.java | 8 +- .../core/functions/ExecutionQueue.java | 4 +- .../core/functions/ExtensionMeta.java | 6 +- .../core/functions/FileHandling.java | 2 +- .../laytonsmith/core/functions/ItemMeta.java | 4 +- .../laytonsmith/core/functions/Marquee.java | 2 +- .../com/laytonsmith/core/functions/Meta.java | 4 +- .../laytonsmith/core/functions/Minecraft.java | 12 +- .../core/functions/MobManagement.java | 6 +- .../core/functions/ResourceManager.java | 2 +- .../com/laytonsmith/core/functions/SQL.java | 16 +- .../laytonsmith/core/functions/Sandbox.java | 2 +- .../core/functions/Scheduling.java | 10 +- .../core/functions/Scoreboards.java | 6 +- .../core/functions/Statistics.java | 10 +- .../laytonsmith/core/functions/Weather.java | 6 +- .../com/laytonsmith/core/functions/Web.java | 22 +- .../com/laytonsmith/core/functions/World.java | 20 +- .../tools/langserv/LangServModel.java | 2 +- .../core/constructs/CFixedArrayTest.java | 2 +- 54 files changed, 304 insertions(+), 666 deletions(-) diff --git a/pom.xml b/pom.xml index 5674b4adba..71290718cc 100644 --- a/pom.xml +++ b/pom.xml @@ -493,6 +493,8 @@ -XDignore.symbol.file -parameters + -Xmaxwarns + 9999 diff --git a/src/main/java/com/laytonsmith/core/ArgumentValidation.java b/src/main/java/com/laytonsmith/core/ArgumentValidation.java index 7ff0a4c889..651f9f15fc 100644 --- a/src/main/java/com/laytonsmith/core/ArgumentValidation.java +++ b/src/main/java/com/laytonsmith/core/ArgumentValidation.java @@ -491,7 +491,7 @@ public static boolean getBooleanish(Mixed c, Target t, Environment env) { if(InstanceofUtil.isInstanceof(c, Booleanish.class, env)) { return ((Booleanish) c).getBooleanValue(t); } - throw new CRECastException("Could not convert value of type " + c.typeof() + " to a " + Booleanish.TYPE, t); + throw new CRECastException("Could not convert value of type " + c.typeof(env) + " to a " + Booleanish.TYPE, t); } /** @@ -516,15 +516,21 @@ public static CByteArray getByteArray(Mixed c, Target t, Environment env) { } else if(c instanceof CNull) { return new CByteArray(t, 0); } else { - throw new CRECastException("Expecting byte array, but found " + c.typeof() + " instead.", t); + throw new CRECastException("Expecting byte array, but found " + c.typeof(env) + " instead.", t); } } + /** @deprecated Use {@link #getClassType(Mixed, Target, Environment)} instead. */ + @Deprecated public static CClassType getClassType(Mixed c, Target t) { + return getClassType(c, t, null); + } + + public static CClassType getClassType(Mixed c, Target t, Environment env) { if(c instanceof CClassType) { return (CClassType) c; } else { - throw new CRECastException("Expecting a ClassType, but found " + c.typeof() + " instead.", t); + throw new CRECastException("Expecting a ClassType, but found " + c.typeof(env) + " instead.", t); } } @@ -559,7 +565,7 @@ public static String getStringObject(Mixed c, Target t) { */ public static String getStringObject(Mixed c, Target t, Environment env) { if(!c.isInstanceOf(CString.class)) { - throw new CRECastException("Expected a string, but found " + c.typeof() + " instead.", t); + throw new CRECastException("Expected a string, but found " + c.typeof(env) + " instead.", t); } return c.val(); } diff --git a/src/main/java/com/laytonsmith/core/ObjectGenerator.java b/src/main/java/com/laytonsmith/core/ObjectGenerator.java index fc683e1fbb..ba409d1270 100644 --- a/src/main/java/com/laytonsmith/core/ObjectGenerator.java +++ b/src/main/java/com/laytonsmith/core/ObjectGenerator.java @@ -181,6 +181,12 @@ public CArray location(MCLocation l, boolean includeYawAndPitch) { return ca; } + /** @deprecated Use {@link #location(Mixed, MCWorld, Target, Environment)} instead. */ + @Deprecated + public MCLocation location(Mixed c, MCWorld w, Target t) { + return location(c, w, t, null); + } + /** * Given a Location Object, returns a MCLocation. If the optional world is not specified in the object, the world * provided is used instead. Location "objects" are MethodScript arrays that represent a location in game. There are @@ -188,9 +194,9 @@ public CArray location(MCLocation l, boolean includeYawAndPitch) { * yaw, pitch) In all cases, the pitch and yaw default to 0, and the world defaults to the specified * world. More conveniently: ([world], x, y, z, [yaw, pitch]) */ - public MCLocation location(Mixed c, MCWorld w, Target t) { + public MCLocation location(Mixed c, MCWorld w, Target t, Environment env) { if(!(c.isInstanceOf(CArray.TYPE))) { - throw new CREFormatException("Expecting an array, received " + c.typeof().getSimpleName(), t); + throw new CREFormatException("Expecting an array, received " + c.typeof(env).getSimpleName(), t); } CArray array = (CArray) c; MCWorld world = w; @@ -2063,6 +2069,12 @@ public Vector3D vector(Mixed c, Target t) { return vector(Vector3D.ZERO, c, t); } + /** @deprecated Use {@link #vector(Vector3D, Mixed, Target, Environment)} instead. */ + @Deprecated + public Vector3D vector(Vector3D v, Mixed c, Target t) { + return vector(v, c, t, null); + } + /** * Modifies an existing vector using a given vector object. Because Vector3D is immutable, this method does not * actually modify the existing vector, but creates a new one. @@ -2072,7 +2084,7 @@ public Vector3D vector(Mixed c, Target t) { * @param t the target * @return the Vector */ - public Vector3D vector(Vector3D v, Mixed c, Target t) { + public Vector3D vector(Vector3D v, Mixed c, Target t, Environment env) { if(c.isInstanceOf(CArray.TYPE)) { CArray va = (CArray) c; double x = v.X(); @@ -2107,7 +2119,7 @@ public Vector3D vector(Vector3D v, Mixed c, Target t) { // fulfilling the todo? return v; } else { - throw new CREFormatException("Expecting an array, received " + c.typeof().getSimpleName(), t); + throw new CREFormatException("Expecting an array, received " + c.typeof(env).getSimpleName(), t); } } @@ -2446,7 +2458,13 @@ public CArray fireworkEffect(MCFireworkEffect mcfe, Target t) { return fe; } + /** @deprecated Use {@link #fireworkEffect(CArray, Target, Environment)} instead. */ + @Deprecated public MCFireworkEffect fireworkEffect(CArray fe, Target t) { + return fireworkEffect(fe, t, null); + } + + public MCFireworkEffect fireworkEffect(CArray fe, Target t, Environment env) { MCFireworkBuilder builder = StaticLayer.GetConvertor().GetFireworkBuilder(); if(fe.containsKey("flicker")) { builder.setFlicker(ArgumentValidation.getBoolean(fe.get("flicker", t), t)); @@ -2473,7 +2491,7 @@ public MCFireworkEffect fireworkEffect(CArray fe, Target t) { break; } else { throw new CREFormatException("Expecting individual color to be an array or string, but found " - + color.typeof(), t); + + color.typeof(env), t); } builder.addColor(mccolor); } @@ -2489,7 +2507,7 @@ public MCFireworkEffect fireworkEffect(CArray fe, Target t) { } } else { throw new CREFormatException("Expecting an array or string for colors parameter, but found " - + colors.typeof(), t); + + colors.typeof(env), t); } } else { builder.addColor(MCColor.WHITE); @@ -2510,7 +2528,7 @@ public MCFireworkEffect fireworkEffect(CArray fe, Target t) { break; } else { throw new CREFormatException("Expecting individual color to be an array or string, but found " - + color.typeof(), t); + + color.typeof(env), t); } builder.addFadeColor(mccolor); } @@ -2521,7 +2539,7 @@ public MCFireworkEffect fireworkEffect(CArray fe, Target t) { } } else { throw new CREFormatException("Expecting an array or string for fade parameter, but found " - + colors.typeof(), t); + + colors.typeof(env), t); } } if(fe.containsKey("type")) { @@ -2595,9 +2613,15 @@ public Construct recipe(MCRecipe r, Target t) { return ret; } + /** @deprecated Use {@link #recipe(Mixed, Target, Environment)} instead. */ + @Deprecated public MCRecipe recipe(Mixed c, Target t) { + return recipe(c, t, null); + } + + public MCRecipe recipe(Mixed c, Target t, Environment env) { if(!(c.isInstanceOf(CArray.TYPE))) { - throw new CRECastException("Expected array but received " + c.typeof().getSimpleName(), t); + throw new CRECastException("Expected array but received " + c.typeof(env).getSimpleName(), t); } CArray recipe = (CArray) c; diff --git a/src/main/java/com/laytonsmith/core/Procedure.java b/src/main/java/com/laytonsmith/core/Procedure.java index 8e62f139c3..193473331e 100644 --- a/src/main/java/com/laytonsmith/core/Procedure.java +++ b/src/main/java/com/laytonsmith/core/Procedure.java @@ -243,25 +243,25 @@ public Mixed execute(List args, Environment oldEnv, Target t) { // Type check vararg parameter. if(var.getDefinedType().isVariadicType()) { - if(InstanceofUtil.isInstanceof(c.typeof(), var.getDefinedType().getVarargsBaseType(), env)) { + if(InstanceofUtil.isInstanceof(c.typeof(env), var.getDefinedType().getVarargsBaseType(), env)) { vararg.push(c, t); continue; } else { throw new CRECastException("Procedure \"" + name + "\" expects a value of type " + var.getDefinedType().val() + " in argument " + (varInd + 1) + ", but" - + " a value of type " + c.typeof() + " was found instead.", c.getTarget()); + + " a value of type " + c.typeof(env) + " was found instead.", c.getTarget()); } } // Type check non-vararg parameter. - if(InstanceofUtil.isInstanceof(c.typeof(), var.getDefinedType(), env)) { + if(InstanceofUtil.isInstanceof(c.typeof(env), var.getDefinedType(), env)) { env.getEnv(GlobalEnv.class).GetVarList().set(new IVariable(var.getDefinedType(), var.getVariableName(), c, c.getTarget())); continue; } else { throw new CRECastException("Procedure \"" + name + "\" expects a value of type " + var.getDefinedType().val() + " in argument " + (varInd + 1) + ", but" - + " a value of type " + c.typeof() + " was found instead.", c.getTarget()); + + " a value of type " + c.typeof(env) + " was found instead.", c.getTarget()); } } } @@ -302,9 +302,9 @@ public Mixed execute(List args, Environment oldEnv, Target t) { } if(returnType.equals(CVoid.TYPE) != ret.equals(CVoid.VOID) || !ret.equals(CNull.NULL) && !ret.equals(CVoid.VOID) - && !InstanceofUtil.isInstanceof(ret.typeof(), returnType, env)) { + && !InstanceofUtil.isInstanceof(ret.typeof(env), returnType, env)) { throw new CRECastException("Expected procedure \"" + name + "\" to return a value of type " - + returnType.val() + " but a value of type " + ret.typeof() + " was returned instead", + + returnType.val() + " but a value of type " + ret.typeof(env) + " was returned instead", ret.getTarget()); } return ret; diff --git a/src/main/java/com/laytonsmith/core/Static.java b/src/main/java/com/laytonsmith/core/Static.java index e07f9c7278..8ca217b3c2 100644 --- a/src/main/java/com/laytonsmith/core/Static.java +++ b/src/main/java/com/laytonsmith/core/Static.java @@ -1485,6 +1485,12 @@ public static boolean InCmdLine(Environment environment, boolean defaultValue) { return environment.getEnv(GlobalEnv.class).inCmdlineMode(); } + /** @deprecated Use {@link #AssertType(Class, Mixed[], int, Function, Target, Environment)} instead. */ + @Deprecated + public static T AssertType(Class type, Mixed[] args, int argNumber, Function func, Target t) { + return AssertType(type, args, argNumber, func, t, null); + } + /** * This verifies that the type required is actually present, and returns the value, cast to the appropriate type, * or, if not the correct type, a CRE. @@ -1497,15 +1503,16 @@ public static boolean InCmdLine(Environment environment, boolean defaultValue) { * @param args The array of arguments. * @param argNumber The argument number, used both for grabbing the correct argument from args, and building the * error message if the cast cannot occur. - * @param func The function, in case this errors out, to build the error message. + * @param func The function, in case this errors out, + * @param envto build the error message. * @param t The code target * @return The value, cast to the desired type. */ - public static T AssertType(Class type, Mixed[] args, int argNumber, Function func, Target t) { + public static T AssertType(Class type, Mixed[] args, int argNumber, Function func, Target t, Environment env) { Mixed value = args[argNumber]; if(!type.isAssignableFrom(value.getClass())) { typeof todesired = ClassDiscovery.GetClassAnnotation(type, typeof.class); - CClassType toactual = value.typeof(); + CClassType toactual = value.typeof(env); if(todesired != null) { throw new CRECastException("Argument " + (argNumber + 1) + " of " + func.getName() + " was expected to be a " + todesired.value() + ", but " + toactual + " \"" + value.val() + "\" was found.", t); diff --git a/src/main/java/com/laytonsmith/core/asm/LLVMArgumentValidation.java b/src/main/java/com/laytonsmith/core/asm/LLVMArgumentValidation.java index 64eec0c93c..36cbe066fa 100644 --- a/src/main/java/com/laytonsmith/core/asm/LLVMArgumentValidation.java +++ b/src/main/java/com/laytonsmith/core/asm/LLVMArgumentValidation.java @@ -200,7 +200,7 @@ public static String getValueFromConstant(IRBuilder builder, ParseTree data, Env public static IRData getAny(IRBuilder builder, Environment env, ParseTree c, Target t) throws ConfigCompileException { LLVMEnvironment e = env.getEnv(LLVMEnvironment.class); if(c.isConst()) { - IRType datatype = convertCClassTypeToIRType(c.getData().typeof()); + IRType datatype = convertCClassTypeToIRType(c.getData().typeof(env)); String data = getValueFromConstant(builder, c, env); int alloca = e.getNewLocalVariableReference(datatype); int load = e.getNewLocalVariableReference(datatype); diff --git a/src/main/java/com/laytonsmith/core/asm/LLVMPlatformResolver.java b/src/main/java/com/laytonsmith/core/asm/LLVMPlatformResolver.java index 68d1f2b973..33026372d5 100644 --- a/src/main/java/com/laytonsmith/core/asm/LLVMPlatformResolver.java +++ b/src/main/java/com/laytonsmith/core/asm/LLVMPlatformResolver.java @@ -40,6 +40,6 @@ public static IRData outputConstant(IRBuilder builder, Mixed c, Environment env) builder.appendLine(c.getTarget(), "%" + gep + " = getelementptr inbounds [" + length + " x i8], [" + length + " x i8]* %" + alloca + ", i64 0, i64 0"); return IRDataBuilder.setReturnVariable(gep, IRType.STRING); } - throw new UnsupportedOperationException("Unsupported data type " + c.typeof().getName()); + throw new UnsupportedOperationException("Unsupported data type " + c.typeof(env).getName()); } } diff --git a/src/main/java/com/laytonsmith/core/constructs/CFixedArray.java b/src/main/java/com/laytonsmith/core/constructs/CFixedArray.java index f5feabb13f..3f3c621f2e 100644 --- a/src/main/java/com/laytonsmith/core/constructs/CFixedArray.java +++ b/src/main/java/com/laytonsmith/core/constructs/CFixedArray.java @@ -103,9 +103,9 @@ public Set keySet(Environment env) { return set; } - private void validateSet(Mixed value, Target t) { - if(!value.typeof().doesExtend(allowedType)) { - throw new CRECastException("Cannot set value of type " + value.typeof().toString() + " into fixed_array of type " + allowedType.toString(), t); + private void validateSet(Mixed value, Target t, Environment env) { + if(!value.typeof(env).doesExtend(allowedType)) { + throw new CRECastException("Cannot set value of type " + value.typeof(env).toString() + " into fixed_array of type " + allowedType.toString(), t); } } @@ -119,11 +119,11 @@ public void set(Mixed index, Mixed value, Target t) { @Override public void set(Mixed index, Mixed value, Target t, Environment env) { int in = ArgumentValidation.getInt32(index, t, env); - set(in, value, t); + set(in, value, t, env); } - public void set(int index, Mixed value, Target t) { - validateSet(value, t); + public void set(int index, Mixed value, Target t, Environment env) { + validateSet(value, t, env); if(index >= data.length || index < 0) { throw new CREIndexOverflowException("Index under/overflow in fixed_array", t); } @@ -176,8 +176,8 @@ public long size(Environment env) { return data.length; } - public void fill(Mixed value, Target t) { - validateSet(value, t); + public void fill(Mixed value, Target t, Environment env) { + validateSet(value, t, env); ArrayUtils.fill(data, value); } diff --git a/src/main/java/com/laytonsmith/core/constructs/CMutablePrimitive.java b/src/main/java/com/laytonsmith/core/constructs/CMutablePrimitive.java index 552b78d3cf..c32bb3d72d 100644 --- a/src/main/java/com/laytonsmith/core/constructs/CMutablePrimitive.java +++ b/src/main/java/com/laytonsmith/core/constructs/CMutablePrimitive.java @@ -126,7 +126,7 @@ public long size() { @Override public long size(Environment env) { - if(value.isInstanceOf(Sizeable.TYPE)) { + if(value.isInstanceOf(Sizeable.TYPE, null, env)) { return ArgumentValidation.getObject(value, Target.UNKNOWN, Sizeable.class).size(env); } else { return 0; diff --git a/src/main/java/com/laytonsmith/core/constructs/InstanceofUtil.java b/src/main/java/com/laytonsmith/core/constructs/InstanceofUtil.java index 17eb62aab4..c3e18d4ad4 100644 --- a/src/main/java/com/laytonsmith/core/constructs/InstanceofUtil.java +++ b/src/main/java/com/laytonsmith/core/constructs/InstanceofUtil.java @@ -75,7 +75,7 @@ public static boolean isInstanceof(Mixed value, FullyQualifiedClassName instance // TODO: Need to put the return type here, so we can work with this, but for now, just always return false return false; } - return isInstanceof(value.typeof(), instanceofThis, env); + return isInstanceof(value.typeof(env), instanceofThis, env); } /** diff --git a/src/main/java/com/laytonsmith/core/events/AbstractGenericEvent.java b/src/main/java/com/laytonsmith/core/events/AbstractGenericEvent.java index 37c220d0a7..7d89a2ded8 100644 --- a/src/main/java/com/laytonsmith/core/events/AbstractGenericEvent.java +++ b/src/main/java/com/laytonsmith/core/events/AbstractGenericEvent.java @@ -23,6 +23,7 @@ import com.laytonsmith.core.events.prefilters.Prefilter; import com.laytonsmith.core.events.prefilters.PrefilterBuilder; import com.laytonsmith.core.exceptions.CRE.CREFormatException; +import com.laytonsmith.core.exceptions.CRE.CREUnsupportedOperationException; import com.laytonsmith.core.exceptions.CancelCommandException; import com.laytonsmith.core.exceptions.ConfigCompileException; import com.laytonsmith.core.exceptions.ConfigCompileGroupException; @@ -59,8 +60,8 @@ public final void setAbstractEventMixin(EventMixinInterface mixin) { } /** - * This function should return true if the event code should be run, based on implementation specific conditions - * for the BindableEvent. + * This function should return true if the event code should be run, based on implementation specific conditions for + * the BindableEvent. * * @param e The bindable event itself * @return {@code true} if the event code should be run @@ -152,13 +153,13 @@ public final void execute(ParseTree tree, BoundEvent b, Environment env, BoundEv try { try { MethodScriptCompiler.execute(tree, env, null, null); - } catch (CancelCommandException ex) { + } catch(CancelCommandException ex) { if(ex.getMessage() != null && !ex.getMessage().isEmpty()) { StreamUtils.GetSystemOut().println(ex.getMessage()); } - } catch (FunctionReturnException ex) { + } catch(FunctionReturnException ex) { //We simply allow this to end the event execution - } catch (ProgramFlowManipulationException ex) { + } catch(ProgramFlowManipulationException ex) { ConfigRuntimeException.HandleUncaughtException(new CREFormatException("Unexpected control flow operation used.", ex.getTarget()), env); } } finally { @@ -325,9 +326,10 @@ public final Map> getPrefilters() { } /** - * Returns the prefilter builder for this subclass. This is built by AbstractEvent and cached, so that calls - * to getPrefilters will be faster for future calls. Subclasses should implement this in order to provide - * declarative prefilter support, which is more efficient and provides more features to end users. + * Returns the prefilter builder for this subclass. This is built by AbstractEvent and cached, so that calls to + * getPrefilters will be faster for future calls. Subclasses should implement this in order to provide declarative + * prefilter support, which is more efficient and provides more features to end users. + * * @return */ // TODO: Once everything has this, this should be re-added, since everything should have its own version. @@ -338,15 +340,19 @@ protected PrefilterBuilder getPrefilterBuilder() { /** * By default, we do nothing. + * * @param prefilters * @param env */ @Override public void validatePrefilters(Map, ParseTree> prefilters, Environment env) - throws ConfigCompileException, ConfigCompileGroupException { + throws ConfigCompileException, ConfigCompileGroupException { // } - - + @Override + public TBindableEvent convert(CArray manualObject, Target t, Environment env) { + throw new CREUnsupportedOperationException("Manual triggering of the " + + getName() + " event is not supported.", t); + } } diff --git a/src/main/java/com/laytonsmith/core/events/Event.java b/src/main/java/com/laytonsmith/core/events/Event.java index ba363f0628..405e96fc80 100644 --- a/src/main/java/com/laytonsmith/core/events/Event.java +++ b/src/main/java/com/laytonsmith/core/events/Event.java @@ -72,7 +72,7 @@ public interface Event extends Comparable< * @param t * @return */ - public TBindableEvent convert(CArray manualObject, Target t); + public TBindableEvent convert(CArray manualObject, Target t, Environment env); /** * This function is called when an event is triggered. It passes the event, and expects back a Map, which will be diff --git a/src/main/java/com/laytonsmith/core/events/EventUtils.java b/src/main/java/com/laytonsmith/core/events/EventUtils.java index 1058a00711..efaa496b65 100644 --- a/src/main/java/com/laytonsmith/core/events/EventUtils.java +++ b/src/main/java/com/laytonsmith/core/events/EventUtils.java @@ -9,6 +9,7 @@ import com.laytonsmith.core.constructs.CString; import com.laytonsmith.core.constructs.Construct; import com.laytonsmith.core.constructs.Target; +import com.laytonsmith.core.environments.Environment; import com.laytonsmith.core.events.BoundEvent.Priority; import com.laytonsmith.core.events.prefilters.Prefilter; import com.laytonsmith.core.exceptions.CRE.CREBindException; @@ -142,7 +143,7 @@ public static SortedSet GetEvents(Driver type) { return EVENT_HANDLES.get(type); } - public static void ManualTrigger(String eventName, CArray object, Target t, boolean serverWide) { + public static void ManualTrigger(String eventName, CArray object, Target t, boolean serverWide, Environment env) { for(Driver type : EVENT_HANDLES.keySet()) { SortedSet toRun = new TreeSet<>(); SortedSet bounded = GetEvents(type); @@ -152,7 +153,7 @@ public static void ManualTrigger(String eventName, CArray object, Target t, bool if(b.getEventName().equalsIgnoreCase(eventName)) { BindableEvent convertedEvent = null; try { - convertedEvent = driver.convert(object, t); + convertedEvent = driver.convert(object, t, env); } catch (UnsupportedOperationException ex) { // The event will stay null, and be caught below } @@ -167,10 +168,10 @@ public static void ManualTrigger(String eventName, CArray object, Target t, bool //If it's not a serverwide event, or this event doesn't support external events. if(!toRun.isEmpty()) { if(!serverWide || !driver.supportsExternal()) { - FireListeners(toRun, driver, driver.convert(object, t)); + FireListeners(toRun, driver, driver.convert(object, t, env)); } else { //It's serverwide, so we can just trigger it normally with the driver, and it should trickle back down to us - driver.manualTrigger(driver.convert(object, t)); + driver.manualTrigger(driver.convert(object, t, env)); } } else { //They have fired a non existent event diff --git a/src/main/java/com/laytonsmith/core/events/drivers/BlockEvents.java b/src/main/java/com/laytonsmith/core/events/drivers/BlockEvents.java index c8712da03e..2281ee87ab 100644 --- a/src/main/java/com/laytonsmith/core/events/drivers/BlockEvents.java +++ b/src/main/java/com/laytonsmith/core/events/drivers/BlockEvents.java @@ -36,6 +36,7 @@ import com.laytonsmith.core.constructs.CNull; import com.laytonsmith.core.constructs.CString; import com.laytonsmith.core.constructs.Target; +import com.laytonsmith.core.environments.Environment; import com.laytonsmith.core.events.AbstractEvent; import com.laytonsmith.core.events.BindableEvent; import com.laytonsmith.core.events.BoundEvent; @@ -68,11 +69,6 @@ public boolean matches(Map prefilter, BindableEvent e) throws Pre return true; } - @Override - public BindableEvent convert(CArray manualObject, Target t) { - return null; - } - @Override public boolean modifyEvent(String key, Mixed value, BindableEvent e) { return false; @@ -252,11 +248,6 @@ public boolean matches(Map prefilter, BindableEvent e) throws Pre return true; } - @Override - public BindableEvent convert(CArray manualObject, Target t) { - return null; - } - @Override public Map evaluate(BindableEvent e) throws EventException { MCBlockBreakEvent event = (MCBlockBreakEvent) e; @@ -397,11 +388,6 @@ public boolean matches(Map prefilter, BindableEvent e) throws Pre return true; } - @Override - public BindableEvent convert(CArray manualObject, Target t) { - return null; - } - @Override public Map evaluate(BindableEvent e) throws EventException { MCBlockPlaceEvent event = (MCBlockPlaceEvent) e; @@ -547,11 +533,6 @@ public boolean matches(Map prefilter, BindableEvent e) throws Pre return true; } - @Override - public BindableEvent convert(CArray manualObject, Target t) { - return null; - } - @Override public Map evaluate(BindableEvent e) throws EventException { MCBlockBurnEvent event = (MCBlockBurnEvent) e; @@ -626,11 +607,6 @@ public boolean matches(Map prefilter, BindableEvent e) throws Pre return true; } - @Override - public BindableEvent convert(CArray manualObject, Target t) { - return null; - } - @Override public Map evaluate(BindableEvent e) throws EventException { if(!(e instanceof MCBlockIgniteEvent)) { @@ -771,11 +747,6 @@ public boolean matches(Map prefilter, BindableEvent e) throws Pre return true; } - @Override - public BindableEvent convert(CArray manualObject, Target t) { - return null; - } - @Override public Map evaluate(BindableEvent e) throws EventException { if(!(e instanceof MCBlockFromToEvent)) { @@ -1045,7 +1016,7 @@ public boolean modifyEvent(String key, Mixed value, BindableEvent event) { } @Override - public BindableEvent convert(CArray manual, Target t) { + public BindableEvent convert(CArray manual, Target t, Environment env) { MCSignChangeEvent e = EventBuilder.instantiate( MCSignChangeEvent.class, Static.GetPlayer(manual.get("player", Target.UNKNOWN).val(), Target.UNKNOWN), @@ -1109,11 +1080,6 @@ public boolean matches(Map prefilter, BindableEvent e) throws Pre return false; } - @Override - public BindableEvent convert(CArray manualObject, Target t) { - return null; - } - @Override public Map evaluate(BindableEvent e) throws EventException { MCBlockDispenseEvent event = (MCBlockDispenseEvent) e; @@ -1256,11 +1222,6 @@ public boolean matches(Map prefilter, BindableEvent event) throws return true; } - @Override - public BindableEvent convert(CArray manualObject, Target t) { - return null; - } - @Override public Map evaluate(BindableEvent event) throws EventException { if(!(event instanceof MCBlockGrowEvent)) { @@ -1316,11 +1277,6 @@ public boolean matches(Map prefilter, BindableEvent event) throws return event instanceof MCNotePlayEvent; } - @Override - public BindableEvent convert(CArray manualObject, Target t) { - return null; - } - @Override public Map evaluate(BindableEvent event) throws EventException { if(!(event instanceof MCNotePlayEvent)) { @@ -1419,11 +1375,6 @@ public boolean matches(Map prefilter, BindableEvent e) throws Pre return true; } - @Override - public BindableEvent convert(CArray manualObject, Target t) { - return null; - } - @Override public Map evaluate(BindableEvent e) throws EventException { if(!(e instanceof MCBlockFadeEvent)) { @@ -1480,11 +1431,6 @@ public boolean matches(Map prefilter, BindableEvent e) throws Pre return e instanceof MCBlockExplodeEvent; } - @Override - public BindableEvent convert(CArray manualObject, Target t) { - return null; - } - @Override public Map evaluate(BindableEvent e) throws EventException { if(!(e instanceof MCBlockExplodeEvent)) { @@ -1555,11 +1501,6 @@ public Driver driver() { return Driver.BLOCK_FORM; } - @Override - public BindableEvent convert(CArray manualObject, Target t) { - return null; - } - @Override public Version since() { return MSVersion.V3_3_4; diff --git a/src/main/java/com/laytonsmith/core/events/drivers/CmdlineEvents.java b/src/main/java/com/laytonsmith/core/events/drivers/CmdlineEvents.java index 7da7ed47f9..9f8132b40e 100644 --- a/src/main/java/com/laytonsmith/core/events/drivers/CmdlineEvents.java +++ b/src/main/java/com/laytonsmith/core/events/drivers/CmdlineEvents.java @@ -12,6 +12,7 @@ import com.laytonsmith.core.constructs.CInt; import com.laytonsmith.core.constructs.CString; import com.laytonsmith.core.constructs.Target; +import com.laytonsmith.core.environments.Environment; import com.laytonsmith.core.events.AbstractEvent; import com.laytonsmith.core.events.BindableEvent; import com.laytonsmith.core.events.BoundEvent; @@ -100,7 +101,7 @@ protected PrefilterBuilder getPrefilterBuilder() { } @Override - public BindableEvent convert(CArray manualObject, Target t) { + public BindableEvent convert(CArray manualObject, Target t, Environment env) { return new BindableEvent() { @Override @@ -164,9 +165,9 @@ protected PrefilterBuilder getPrefilterBuilder() { } @Override - public BindableEvent convert(CArray manualObject, Target t) { - CmdlinePromptInput cpi = new CmdlinePromptInput(manualObject.get("command", t).val(), - ArgumentValidation.getBoolean(manualObject.get("shellMode", t), t)); + public BindableEvent convert(CArray manualObject, Target t, Environment env) { + CmdlinePromptInput cpi = new CmdlinePromptInput(manualObject.get("command", t, env).val(), + ArgumentValidation.getBoolean(manualObject.get("shellMode", t, env), t)); return cpi; } @@ -261,11 +262,6 @@ public boolean matches(Map prefilter, BindableEvent e) throws Pre return true; } - @Override - public BindableEvent convert(CArray manualObject, Target t) { - throw new UnsupportedOperationException("Not supported yet."); - } - @Override public Map evaluate(BindableEvent e) throws EventException { return Collections.EMPTY_MAP; diff --git a/src/main/java/com/laytonsmith/core/events/drivers/EntityEvents.java b/src/main/java/com/laytonsmith/core/events/drivers/EntityEvents.java index 80c3237765..768ecc3eff 100644 --- a/src/main/java/com/laytonsmith/core/events/drivers/EntityEvents.java +++ b/src/main/java/com/laytonsmith/core/events/drivers/EntityEvents.java @@ -141,11 +141,6 @@ public boolean matches(Map prefilter, BindableEvent e) throws Pre return false; } - @Override - public BindableEvent convert(CArray manualObject, Target t) { - throw ConfigRuntimeException.CreateUncatchableException("Unsupported Operation", Target.UNKNOWN); - } - @Override public Map evaluate(BindableEvent e) throws EventException { if(e instanceof MCItemDespawnEvent) { @@ -221,11 +216,6 @@ public boolean matches(Map prefilter, BindableEvent e) throws Pre return false; } - @Override - public BindableEvent convert(CArray manualObject, Target t) { - throw ConfigRuntimeException.CreateUncatchableException("Unsupported Operation", Target.UNKNOWN); - } - @Override public Map evaluate(BindableEvent e) throws EventException { if(e instanceof MCItemSpawnEvent) { @@ -315,11 +305,6 @@ public boolean matches(Map prefilter, BindableEvent event) throws return false; } - @Override - public BindableEvent convert(CArray manualObject, Target t) { - throw ConfigRuntimeException.CreateUncatchableException("Unsupported Operation", Target.UNKNOWN); - } - @Override public Map evaluate(BindableEvent event) throws EventException { if(event instanceof MCEntityExplodeEvent) { @@ -425,8 +410,8 @@ public boolean matches(Map prefilter, BindableEvent event) throws } @Override - public BindableEvent convert(CArray manualObject, Target t) { - MCEntity p = Static.getEntity(manualObject.get("id", Target.UNKNOWN), Target.UNKNOWN); + public BindableEvent convert(CArray manualObject, Target t, Environment env) { + MCEntity p = Static.getEntity(manualObject.get("id", Target.UNKNOWN, env), Target.UNKNOWN); if(!(p instanceof MCProjectile)) { throw new CREBadEntityException("The id was not a projectile", Target.UNKNOWN); } @@ -553,11 +538,6 @@ public boolean matches(Map prefilter, BindableEvent event) throws } } - @Override - public BindableEvent convert(CArray manualObject, Target t) { - return null; - } - @Override public Map evaluate(BindableEvent event) throws EventException { if(event instanceof MCProjectileLaunchEvent) { @@ -658,11 +638,6 @@ public boolean matches(Map prefilter, BindableEvent e) return false; } - @Override - public BindableEvent convert(CArray manualObject, Target t) { - return null; - } - @Override public Map evaluate(BindableEvent event) throws EventException { @@ -772,11 +747,6 @@ public boolean matches(Map prefilter, BindableEvent event) throws return true; } - @Override - public BindableEvent convert(CArray manualObject, Target t) { - return null; - } - @Override public Map evaluate(BindableEvent event) throws EventException { if(!(event instanceof MCCreatureSpawnEvent)) { @@ -877,11 +847,6 @@ public boolean matches(Map prefilter, BindableEvent event) return false; } - @Override - public BindableEvent convert(CArray manualObject, Target t) { - return null; - } - @Override public Map evaluate(BindableEvent e) throws EventException { @@ -959,11 +924,6 @@ public boolean matches(Map prefilter, BindableEvent event) return false; } - @Override - public BindableEvent convert(CArray manualObject, Target t) { - return null; - } - @Override public Map evaluate(BindableEvent e) throws EventException { @@ -1055,11 +1015,6 @@ public boolean matches(Map prefilter, BindableEvent event) return false; } - @Override - public BindableEvent convert(CArray manualObject, Target t) { - return null; - } - @Override public Map evaluate(BindableEvent e) throws EventException { @@ -1125,11 +1080,6 @@ public String docs() { + "{player|item}"; } - @Override - public BindableEvent convert(CArray manualObject, Target t) { - return null; - } - @Override public MSVersion since() { return MSVersion.V3_3_1; @@ -1246,11 +1196,6 @@ public boolean matches(Map prefilter, BindableEvent e) throws Pre return false; } - @Override - public BindableEvent convert(CArray manualObject, Target t) { - return null; - } - @Override public Map evaluate(BindableEvent e) throws EventException { if(e instanceof MCPlayerPickupItemEvent) { @@ -1328,11 +1273,6 @@ public boolean matches(Map prefilter, BindableEvent e) return false; } - @Override - public BindableEvent convert(CArray manualObject, Target t) { - throw ConfigRuntimeException.CreateUncatchableException("Unsupported Operation", Target.UNKNOWN); - } - @Override public Map evaluate(BindableEvent e) throws EventException { @@ -1484,9 +1424,9 @@ public boolean modifyEvent(String key, Mixed value, BindableEvent event) { } @Override - public BindableEvent convert(CArray manual, Target t) { + public BindableEvent convert(CArray manual, Target t, Environment env) { return EventBuilder.instantiate(MCEntityTargetEvent.class, - Static.GetPlayer(manual.get("player", Target.UNKNOWN).val(), Target.UNKNOWN)); + Static.GetPlayer(manual.get("player", Target.UNKNOWN, env).val(), Target.UNKNOWN)); } } @@ -1528,11 +1468,6 @@ public boolean matches(Map prefilter, BindableEvent e) throws Pre return false; } - @Override - public BindableEvent convert(CArray manualObject, Target t) { - throw ConfigRuntimeException.CreateUncatchableException("Unsupported Operation", Target.UNKNOWN); - } - @Override public Map evaluate(BindableEvent e) throws EventException { if(e instanceof MCEntityEnterPortalEvent) { @@ -1624,11 +1559,6 @@ public boolean matches(Map prefilter, BindableEvent e) return false; } - @Override - public BindableEvent convert(CArray manualObject, Target t) { - return null; - } - @Override public Map evaluate(BindableEvent e) throws EventException { @@ -1728,11 +1658,6 @@ public boolean matches(Map prefilter, BindableEvent e) throws Pre return false; } - @Override - public BindableEvent convert(CArray manualObject, Target t) { - return null; - } - @Override public Map evaluate(BindableEvent e) throws EventException { if(e instanceof MCEntityInteractEvent) { @@ -1843,12 +1768,6 @@ public boolean matches(Map prefilter, BindableEvent event) throws return false; } } - - @Override - public BindableEvent convert(CArray manualObject, Target t) { - return null; - } - @Override public Map evaluate(BindableEvent event) throws EventException { if(event instanceof MCHangingBreakEvent) { @@ -1931,11 +1850,6 @@ public boolean matches(Map prefilter, BindableEvent event) throws return false; } - @Override - public BindableEvent convert(CArray manualObject, Target t) { - return null; - } - @Override public Map evaluate(BindableEvent event) throws EventException { if(event instanceof MCHangingPlaceEvent e) { @@ -2025,11 +1939,6 @@ public boolean matches(Map filter, BindableEvent e) throws Prefil return false; } - @Override - public BindableEvent convert(CArray manualObject, Target t) { - return null; - } - @Override public Map evaluate(BindableEvent e) throws EventException { if(e instanceof MCEntityToggleGlideEvent) { @@ -2107,11 +2016,6 @@ protected String getProperty(MCEntityToggleSwimEvent event) { }); } - @Override - public MCEntityToggleSwimEvent convert(CArray manualObject, Target t) { - return null; - } - @Override public Map evaluate(MCEntityToggleSwimEvent e) throws EventException { Map ret = evaluate_helper(e); @@ -2190,11 +2094,6 @@ public boolean matches(Map prefilter, BindableEvent e) throws Pre return true; } - @Override - public BindableEvent convert(CArray manualObject, Target t) { - return null; - } - @Override public Map evaluate(BindableEvent event) throws EventException { if(event instanceof MCFireworkExplodeEvent) { @@ -2255,11 +2154,6 @@ public boolean matches(Map prefilter, BindableEvent e) throws Pre return false; } - @Override - public BindableEvent convert(CArray manualObject, Target t) { - return null; - } - @Override public Map evaluate(BindableEvent e) throws EventException { if(e instanceof MCEntityRegainHealthEvent) { @@ -2330,11 +2224,6 @@ public boolean matches(Map prefilter, BindableEvent e) throws Pre return false; } - @Override - public BindableEvent convert(CArray manualObject, Target t) { - return null; - } - @Override public Map evaluate(BindableEvent e) throws EventException { if(e instanceof MCEntityPortalEvent) { @@ -2411,11 +2300,6 @@ public boolean matches(Map prefilter, BindableEvent e) throws Pre return false; } - @Override - public BindableEvent convert(CArray manualObject, Target t) { - return null; - } - @Override public Map evaluate(BindableEvent e) throws EventException { if(e instanceof MCEntityUnleashEvent) { @@ -2474,11 +2358,6 @@ public boolean matches(Map prefilter, BindableEvent event) throws return false; } - @Override - public BindableEvent convert(CArray manualObject, Target t) { - return null; - } - @Override public Map evaluate(BindableEvent e) throws EventException { if(e instanceof MCPotionSplashEvent) { @@ -2559,11 +2438,6 @@ public Driver driver() { return Driver.ENTITY_POTION_EFFECT; } - @Override - public BindableEvent convert(CArray manualObject, Target t) { - return null; - } - @Override public Version since() { return MSVersion.V3_3_4; diff --git a/src/main/java/com/laytonsmith/core/events/drivers/InventoryEvents.java b/src/main/java/com/laytonsmith/core/events/drivers/InventoryEvents.java index c78751acbf..4374a0b306 100644 --- a/src/main/java/com/laytonsmith/core/events/drivers/InventoryEvents.java +++ b/src/main/java/com/laytonsmith/core/events/drivers/InventoryEvents.java @@ -44,9 +44,7 @@ import com.laytonsmith.core.events.Driver; import com.laytonsmith.core.events.Prefilters; import com.laytonsmith.core.events.Prefilters.PrefilterType; -import com.laytonsmith.core.exceptions.CRE.CREBindException; import com.laytonsmith.core.exceptions.CRE.CREFormatException; -import com.laytonsmith.core.exceptions.ConfigRuntimeException; import com.laytonsmith.core.exceptions.EventException; import com.laytonsmith.core.exceptions.PrefilterNonMatchException; import com.laytonsmith.core.functions.InventoryManagement; @@ -133,11 +131,6 @@ public boolean matches(Map prefilter, BindableEvent event) throws return false; } - @Override - public BindableEvent convert(CArray manualObject, Target t) { - throw new CREBindException("Unsupported Operation", Target.UNKNOWN); - } - @Override public Map evaluate(BindableEvent event) throws EventException { if(event instanceof MCInventoryClickEvent) { @@ -273,11 +266,6 @@ public boolean matches(Map prefilter, BindableEvent event) throws return false; } - @Override - public BindableEvent convert(CArray manualObject, Target t) { - return null; - } - @Override public Map evaluate(BindableEvent event) throws EventException { if(event instanceof MCInventoryDragEvent) { @@ -383,11 +371,6 @@ public boolean matches(Map prefilter, BindableEvent event) throws return true; } - @Override - public BindableEvent convert(CArray manualObject, Target t) { - return null; - } - @Override public Map evaluate(BindableEvent event) throws EventException { if(event instanceof MCInventoryOpenEvent) { @@ -465,11 +448,6 @@ public boolean matches(Map prefilter, BindableEvent event) throws return true; } - @Override - public BindableEvent convert(CArray manualObject, Target t) { - return null; - } - @Override public Map evaluate(BindableEvent event) throws EventException { if(event instanceof MCInventoryCloseEvent) { @@ -546,11 +524,6 @@ public boolean matches(Map prefilter, BindableEvent e) throws Pre return true; } - @Override - public BindableEvent convert(CArray manualObject, Target t) { - return null; - } - @Override public Map evaluate(BindableEvent event) throws EventException { if(event instanceof MCEnchantItemEvent) { @@ -637,11 +610,6 @@ public boolean matches(Map prefilter, BindableEvent e) throws Pre return true; } - @Override - public BindableEvent convert(CArray manualObject, Target t) { - return null; - } - @Override public Map evaluate(BindableEvent event) throws EventException { if(event instanceof MCPrepareItemEnchantEvent) { @@ -743,11 +711,6 @@ public boolean matches(Map prefilter, BindableEvent event) throws return false; } - @Override - public BindableEvent convert(CArray manualObject, Target t) { - throw ConfigRuntimeException.CreateUncatchableException("Unsupported operation.", Target.UNKNOWN); - } - @Override public Map evaluate(BindableEvent event) throws EventException { if(event instanceof MCItemHeldEvent) { @@ -853,11 +816,6 @@ public boolean matches(Map prefilter, BindableEvent event) throws return false; } - @Override - public BindableEvent convert(CArray manualObject, Target t) { - throw ConfigRuntimeException.CreateUncatchableException("Unsupported operation.", Target.UNKNOWN); - } - @Override public Map evaluate(BindableEvent event) throws EventException { if(event instanceof MCItemSwapEvent) { @@ -928,11 +886,6 @@ public boolean matches(Map prefilter, BindableEvent event) throws return false; } - @Override - public BindableEvent convert(CArray manualObject, Target t) { - throw ConfigRuntimeException.CreateUncatchableException("Unsupported operation.", Target.UNKNOWN); - } - @Override public Map evaluate(BindableEvent event) throws EventException { if(event instanceof MCPrepareItemCraftEvent e) { @@ -1018,11 +971,6 @@ public boolean matches(Map prefilter, BindableEvent event) throws return false; } - @Override - public BindableEvent convert(CArray manualObject, Target t) { - throw ConfigRuntimeException.CreateUncatchableException("Unsupported operation.", Target.UNKNOWN); - } - @Override public Map evaluate(BindableEvent event) throws EventException { if(event instanceof MCPrepareAnvilEvent e) { @@ -1120,11 +1068,6 @@ public boolean matches(Map prefilter, BindableEvent event) throws return false; } - @Override - public BindableEvent convert(CArray manualObject, Target t) { - throw ConfigRuntimeException.CreateUncatchableException("Unsupported operation.", Target.UNKNOWN); - } - @Override public Map evaluate(BindableEvent event) throws EventException { if(event instanceof MCPrepareSmithingEvent e) { @@ -1198,11 +1141,6 @@ public boolean matches(Map prefilter, BindableEvent event) throws return false; } - @Override - public BindableEvent convert(CArray manualObject, Target t) { - throw ConfigRuntimeException.CreateUncatchableException("Unsupported operation.", Target.UNKNOWN); - } - @Override public Map evaluate(BindableEvent event) throws EventException { if(event instanceof MCPrepareGrindstoneEvent e) { diff --git a/src/main/java/com/laytonsmith/core/events/drivers/PlayerEvents.java b/src/main/java/com/laytonsmith/core/events/drivers/PlayerEvents.java index 76fc82986b..d03b3e31dd 100644 --- a/src/main/java/com/laytonsmith/core/events/drivers/PlayerEvents.java +++ b/src/main/java/com/laytonsmith/core/events/drivers/PlayerEvents.java @@ -150,11 +150,6 @@ protected String getProperty(MCFoodLevelChangeEvent event) { }); } - @Override - public BindableEvent convert(CArray manualObject, Target t) { - return null; - } - @Override public Map evaluate(BindableEvent e) throws EventException { if(e instanceof MCFoodLevelChangeEvent) { @@ -250,10 +245,9 @@ public void bind(BoundEvent event) { } @Override - public BindableEvent convert(CArray manualObject, Target t) { - MCPlayer p = Static.GetPlayer(manualObject.get("player", Target.UNKNOWN), Target.UNKNOWN); - MCItemStack i = ObjectGenerator.GetGenerator().item(manualObject.get("item", Target.UNKNOWN), - Target.UNKNOWN); + public BindableEvent convert(CArray manualObject, Target t, Environment env) { + MCPlayer p = Static.GetPlayer(manualObject.get("player", t, env), t); + MCItemStack i = ObjectGenerator.GetGenerator().item(manualObject.get("item", t, env), t); return EventBuilder.instantiate(MCPlayerItemConsumeEvent.class, p, i); } @@ -331,11 +325,6 @@ protected Object getProperty(MCPlayerKickEvent event) { }); } - @Override - public BindableEvent convert(CArray manualObject, Target t) { - return null; - } - @Override public Map evaluate(BindableEvent e) throws EventException { if(e instanceof MCPlayerKickEvent) { @@ -424,11 +413,11 @@ protected MCLocation getLocation(MCPlayerTeleportEvent event) { } @Override - public BindableEvent convert(CArray manualObject, Target t) { - MCPlayer p = Static.GetPlayer(manualObject.get("player", Target.UNKNOWN), Target.UNKNOWN); - MCLocation from = ObjectGenerator.GetGenerator().location(manualObject.get("from", Target.UNKNOWN), + public BindableEvent convert(CArray manualObject, Target t, Environment env) { + MCPlayer p = Static.GetPlayer(manualObject.get("player", t, env), t); + MCLocation from = ObjectGenerator.GetGenerator().location(manualObject.get("from", t, env), p.getWorld(), manualObject.getTarget()); - MCLocation to = ObjectGenerator.GetGenerator().location(manualObject.get("to", Target.UNKNOWN), + MCLocation to = ObjectGenerator.GetGenerator().location(manualObject.get("to", t, env), p.getWorld(), manualObject.getTarget()); return EventBuilder.instantiate(MCPlayerTeleportEvent.class, p, from, to); } @@ -528,11 +517,11 @@ protected MCLocation getLocation(MCPlayerPortalEvent event) { } @Override - public BindableEvent convert(CArray manualObject, Target t) { - MCPlayer p = Static.GetPlayer(manualObject.get("player", Target.UNKNOWN), Target.UNKNOWN); - MCLocation from = ObjectGenerator.GetGenerator().location(manualObject.get("from", Target.UNKNOWN), + public BindableEvent convert(CArray manualObject, Target t, Environment env) { + MCPlayer p = Static.GetPlayer(manualObject.get("player", t, env), t); + MCLocation from = ObjectGenerator.GetGenerator().location(manualObject.get("from", t, env), p.getWorld(), manualObject.getTarget()); - MCLocation to = ObjectGenerator.GetGenerator().location(manualObject.get("to", Target.UNKNOWN), + MCLocation to = ObjectGenerator.GetGenerator().location(manualObject.get("to", t, env), p.getWorld(), manualObject.getTarget()); return EventBuilder.instantiate(MCPlayerPortalEvent.class, p, from, to); } @@ -632,11 +621,6 @@ protected PrefilterBuilder getPrefilterBuilder() { .set("player", "The player that is connecting", new PlayerPrefilterMatcher<>()); } - @Override - public BindableEvent convert(CArray manualObject, Target t) { - return null; - } - @Override public Map evaluate(BindableEvent e) throws EventException { if(e instanceof MCPlayerLoginEvent) { @@ -782,10 +766,10 @@ public boolean modifyEvent(String key, Mixed value, BindableEvent event) { } @Override - public BindableEvent convert(CArray manual, Target t) { + public BindableEvent convert(CArray manual, Target t, Environment env) { MCPlayerJoinEvent e = EventBuilder.instantiate(MCPlayerJoinEvent.class, - Static.GetPlayer(manual.get("player", Target.UNKNOWN).val(), Target.UNKNOWN), - manual.get("join_message", Target.UNKNOWN).val()); + Static.GetPlayer(manual.get("player", t, env).val(), t), + manual.get("join_message", t, env).val()); return e; } @@ -944,14 +928,13 @@ public Map evaluate(BindableEvent e) throws EventException { } @Override - public BindableEvent convert(CArray manual, Target t) { - MCPlayer p = Static.GetPlayer(manual.get("player", Target.UNKNOWN), Target.UNKNOWN); - MCAction a = MCAction.valueOf(manual.get("action", Target.UNKNOWN).val().toUpperCase()); - MCItemStack is = Static.ParseItemNotation("player_interact event", manual.get("item", Target.UNKNOWN).val(), - 1, Target.UNKNOWN); - MCBlock b = ObjectGenerator.GetGenerator().location(manual.get("location", Target.UNKNOWN), null, - Target.UNKNOWN).getBlock(); - MCBlockFace bf = MCBlockFace.valueOf(manual.get("facing", Target.UNKNOWN).val().toUpperCase()); + public BindableEvent convert(CArray manual, Target t, Environment env) { + MCPlayer p = Static.GetPlayer(manual.get("player", t, env), t); + MCAction a = MCAction.valueOf(manual.get("action", t, env).val().toUpperCase()); + MCItemStack is = Static.ParseItemNotation("player_interact event", manual.get("item", t, env).val(), + 1, t); + MCBlock b = ObjectGenerator.GetGenerator().location(manual.get("location", t, env), null, t).getBlock(); + MCBlockFace bf = MCBlockFace.valueOf(manual.get("facing", t, env).val().toUpperCase()); MCPlayerInteractEvent e = EventBuilder.instantiate(MCPlayerInteractEvent.class, p, a, is, b, bf); return e; } @@ -1035,11 +1018,11 @@ public boolean modifyEvent(String key, Mixed value, BindableEvent event) { } @Override - public BindableEvent convert(CArray manual, Target t) { - MCPlayer p = Static.GetPlayer(manual.get("player", Target.UNKNOWN), Target.UNKNOWN); - MCBlock b = ObjectGenerator.GetGenerator().location(manual.get("location", Target.UNKNOWN), - null, Target.UNKNOWN).getBlock(); - MCEnterBedResult r = MCEnterBedResult.valueOf(manual.get("result", Target.UNKNOWN).val()); + public BindableEvent convert(CArray manual, Target t, Environment env) { + MCPlayer p = Static.GetPlayer(manual.get("player", t, env), t); + MCBlock b = ObjectGenerator.GetGenerator().location(manual.get("location", t, env), + null, t).getBlock(); + MCEnterBedResult r = MCEnterBedResult.valueOf(manual.get("result", t, env).val()); MCPlayerEnterBedEvent e = EventBuilder.instantiate(MCPlayerEnterBedEvent.class, p, b, r); return e; } @@ -1103,10 +1086,10 @@ public boolean modifyEvent(String key, Mixed value, BindableEvent event) { } @Override - public BindableEvent convert(CArray manual, Target t) { - MCPlayer p = Static.GetPlayer(manual.get("player", Target.UNKNOWN), Target.UNKNOWN); - MCBlock b = ObjectGenerator.GetGenerator().location(manual.get("location", Target.UNKNOWN), - null, Target.UNKNOWN).getBlock(); + public BindableEvent convert(CArray manual, Target t, Environment env) { + MCPlayer p = Static.GetPlayer(manual.get("player", t, env), t); + MCBlock b = ObjectGenerator.GetGenerator().location(manual.get("location", t, env), + null, t).getBlock(); MCPlayerEnterBedEvent e = EventBuilder.instantiate(MCPlayerEnterBedEvent.class, p, b); return e; } @@ -1145,10 +1128,9 @@ protected MCLocation getLocation(MCPlayerInteractEvent event) { } @Override - public BindableEvent convert(CArray manual, Target t) { - MCPlayer p = Static.GetPlayer(manual.get("player", Target.UNKNOWN), Target.UNKNOWN); - MCBlock b = ObjectGenerator.GetGenerator().location(manual.get("location", Target.UNKNOWN), null, - Target.UNKNOWN).getBlock(); + public BindableEvent convert(CArray manual, Target t, Environment env) { + MCPlayer p = Static.GetPlayer(manual.get("player", t, env), t); + MCBlock b = ObjectGenerator.GetGenerator().location(manual.get("location", t, env), null, t).getBlock(); MCPlayerInteractEvent e = EventBuilder.instantiate(MCPlayerInteractEvent.class, p, MCAction.PHYSICAL, null, b, MCBlockFace.UP); return e; @@ -1272,12 +1254,11 @@ public Map evaluate(BindableEvent e) throws EventException { } @Override - public BindableEvent convert(CArray manual, Target t) { + public BindableEvent convert(CArray manual, Target t, Environment env) { //For firing off the event manually, we have to convert the CArray into an //actual object that will trigger it - MCPlayer p = Static.GetPlayer(manual.get("player", Target.UNKNOWN), Target.UNKNOWN); - MCLocation l = ObjectGenerator.GetGenerator().location(manual.get("location", Target.UNKNOWN), p.getWorld(), - Target.UNKNOWN); + MCPlayer p = Static.GetPlayer(manual.get("player", t, env), t); + MCLocation l = ObjectGenerator.GetGenerator().location(manual.get("location", t, env), p.getWorld(), t); MCPlayerRespawnEvent e = EventBuilder.instantiate(MCPlayerRespawnEvent.class, p, l, false); return e; } @@ -1372,18 +1353,18 @@ public Map evaluate(BindableEvent e) throws EventException { } @Override - public BindableEvent convert(CArray manual, Target t) { + public BindableEvent convert(CArray manual, Target t, Environment env) { //For firing off the event manually, we have to convert the CArray into an //actual object that will trigger it - String splayer = manual.get("player", Target.UNKNOWN).val(); + String splayer = manual.get("player", t, env).val(); List list = new ArrayList<>(); - String deathMessage = manual.get("death_message", Target.UNKNOWN).val(); - CArray clist = (CArray) manual.get("drops", Target.UNKNOWN); + String deathMessage = manual.get("death_message", t, env).val(); + CArray clist = (CArray) manual.get("drops", t, env); for(String key : clist.stringKeySet()) { - list.add(ObjectGenerator.GetGenerator().item(clist.get(key, Target.UNKNOWN), clist.getTarget())); + list.add(ObjectGenerator.GetGenerator().item(clist.get(key, t, env), clist.getTarget())); } MCPlayerDeathEvent e = EventBuilder.instantiate(MCPlayerDeathEvent.class, Static.GetPlayer(splayer, - Target.UNKNOWN), list, + t), list, 0, deathMessage); return e; } @@ -1455,10 +1436,10 @@ protected PrefilterBuilder getPrefilterBuilder() { } @Override - public BindableEvent convert(CArray manualObject, Target t) { + public BindableEvent convert(CArray manualObject, Target t, Environment env) { //Get the parameters from the manualObject - MCPlayer player = Static.GetPlayer(manualObject.get("player", Target.UNKNOWN), Target.UNKNOWN); - String message = Construct.nval(manualObject.get("message", Target.UNKNOWN)); + MCPlayer player = Static.GetPlayer(manualObject.get("player", Target.UNKNOWN, env), Target.UNKNOWN); + String message = Construct.nval(manualObject.get("message", Target.UNKNOWN, env)); BindableEvent e = EventBuilder.instantiate(MCPlayerCommandEvent.class, player, message); @@ -1543,11 +1524,11 @@ public boolean matches(String key, Mixed value, MCPlayerChatEvent event, Target } @Override - public BindableEvent convert(CArray manualObject, Target t) { + public BindableEvent convert(CArray manualObject, Target t, Environment env) { //Get the parameters from the manualObject - MCPlayer player = Static.GetPlayer(manualObject.get("player", Target.UNKNOWN), Target.UNKNOWN); - String message = Construct.nval(manualObject.get("message", Target.UNKNOWN)); - String format = Construct.nval(manualObject.get("format", Target.UNKNOWN)); + MCPlayer player = Static.GetPlayer(manualObject.get("player", Target.UNKNOWN, env), Target.UNKNOWN); + String message = Construct.nval(manualObject.get("message", Target.UNKNOWN, env)); + String format = Construct.nval(manualObject.get("format", Target.UNKNOWN, env)); BindableEvent e = EventBuilder.instantiate(MCPlayerChatEvent.class, player, message, format); @@ -1684,10 +1665,10 @@ public boolean matches(String key, Mixed value, MCPlayerChatEvent event, Target } @Override - public BindableEvent convert(CArray manualObject, Target t) { + public BindableEvent convert(CArray manualObject, Target t, Environment env) { //Get the parameters from the manualObject - MCPlayer player = Static.GetPlayer(manualObject.get("player", Target.UNKNOWN), Target.UNKNOWN); - String message = Construct.nval(manualObject.get("message", Target.UNKNOWN)); + MCPlayer player = Static.GetPlayer(manualObject.get("player", Target.UNKNOWN, env), Target.UNKNOWN); + String message = Construct.nval(manualObject.get("message", Target.UNKNOWN, env)); BindableEvent e = EventBuilder.instantiate(MCPlayerChatEvent.class, player, message); @@ -1814,9 +1795,9 @@ public PrefilterMatcher.PrefilterDocs getDocsObject() { } @Override - public BindableEvent convert(CArray manualObject, Target t) { - MCPlayer player = Static.GetPlayer(manualObject.get("player", Target.UNKNOWN), Target.UNKNOWN); - String command = Construct.nval(manualObject.get("command", Target.UNKNOWN)); + public BindableEvent convert(CArray manualObject, Target t, Environment env) { + MCPlayer player = Static.GetPlayer(manualObject.get("player", Target.UNKNOWN, env), Target.UNKNOWN); + String command = Construct.nval(manualObject.get("command", Target.UNKNOWN, env)); BindableEvent e = EventBuilder.instantiate(MCPlayerCommandEvent.class, player, command); return e; @@ -1908,9 +1889,9 @@ protected MCWorld getWorld(MCWorldChangedEvent event) { } @Override - public BindableEvent convert(CArray manualObject, Target t) { - MCPlayer player = Static.GetPlayer(manualObject.get("player", Target.UNKNOWN), Target.UNKNOWN); - MCWorld from = Static.getServer().getWorld(manualObject.get("from", Target.UNKNOWN).val()); + public BindableEvent convert(CArray manualObject, Target t, Environment env) { + MCPlayer player = Static.GetPlayer(manualObject.get("player", Target.UNKNOWN, env), Target.UNKNOWN); + MCWorld from = Static.getServer().getWorld(manualObject.get("from", Target.UNKNOWN, env).val()); BindableEvent e = EventBuilder.instantiate(MCPlayerCommandEvent.class, player, from); @@ -2045,11 +2026,11 @@ protected MCWorld getWorld(MCPlayerMoveEvent event) { } @Override - public BindableEvent convert(CArray manualObject, Target t) { - MCPlayer p = Static.GetPlayer(manualObject.get("player", Target.UNKNOWN), Target.UNKNOWN); - MCLocation from = ObjectGenerator.GetGenerator().location(manualObject.get("from", Target.UNKNOWN), + public BindableEvent convert(CArray manualObject, Target t, Environment env) { + MCPlayer p = Static.GetPlayer(manualObject.get("player", Target.UNKNOWN, env), Target.UNKNOWN); + MCLocation from = ObjectGenerator.GetGenerator().location(manualObject.get("from", Target.UNKNOWN, env), p.getWorld(), manualObject.getTarget()); - MCLocation to = ObjectGenerator.GetGenerator().location(manualObject.get("to", Target.UNKNOWN), + MCLocation to = ObjectGenerator.GetGenerator().location(manualObject.get("to", Target.UNKNOWN, env), p.getWorld(), manualObject.getTarget()); return EventBuilder.instantiate(MCPlayerMoveEvent.class, p, from, to); } @@ -2138,11 +2119,6 @@ public boolean matches(Map prefilter, BindableEvent e) throws Pre return false; } - @Override - public BindableEvent convert(CArray manualObject, Target t) { - throw ConfigRuntimeException.CreateUncatchableException("Unsupported Operation", Target.UNKNOWN); - } - @Override public Map evaluate(BindableEvent e) throws EventException { if(e instanceof MCPlayerFishEvent) { @@ -2268,11 +2244,6 @@ protected Enum getEnum(MCGamemodeChangeEvent event) { }); } - @Override - public BindableEvent convert(CArray manualObject, Target t) { - throw new CREBindException("Unsupported Operation", Target.UNKNOWN); - } - @Override public Map evaluate(BindableEvent event) throws EventException { if(event instanceof MCGamemodeChangeEvent) { @@ -2324,11 +2295,6 @@ protected PrefilterBuilder getPrefilterBuilder() { .set("player", "The player whose exp is changing", new PlayerPrefilterMatcher<>()); } - @Override - public BindableEvent convert(CArray manualObject, Target t) { - throw ConfigRuntimeException.CreateUncatchableException("Unsupported Operation", Target.UNKNOWN); - } - @Override public Map evaluate(BindableEvent event) throws EventException { if(event instanceof MCExpChangeEvent) { @@ -2406,11 +2372,6 @@ protected boolean getProperty(MCPlayerEditBookEvent event) { }); } - @Override - public BindableEvent convert(CArray manualObject, Target t) { - return null; - } - @Override public Map evaluate(BindableEvent event) throws EventException { if(event instanceof MCPlayerEditBookEvent) { @@ -2557,11 +2518,6 @@ protected Object getProperty(MCPlayerToggleFlightEvent event) { }); } - @Override - public BindableEvent convert(CArray manualObject, Target t) { - return null; - } - @Override public Map evaluate(BindableEvent event) throws EventException { if(event instanceof MCPlayerToggleFlightEvent) { @@ -2627,12 +2583,6 @@ protected Object getProperty(MCPlayerToggleSneakEvent event) { } }); } - - @Override - public BindableEvent convert(CArray manualObject, Target t) { - return null; - } - @Override public Map evaluate(BindableEvent event) throws EventException { if(event instanceof MCPlayerToggleSneakEvent) { @@ -2699,11 +2649,6 @@ protected Object getProperty(MCPlayerToggleSprintEvent event) { }); } - @Override - public BindableEvent convert(CArray manualObject, Target t) { - return null; - } - @Override public Map evaluate(BindableEvent event) throws EventException { if(event instanceof MCPlayerToggleSprintEvent) { @@ -2782,11 +2727,6 @@ public boolean modifyEvent(String key, Mixed value, BindableEvent event) { public MSVersion since() { return MSVersion.V3_3_4; } - - @Override - public BindableEvent convert(CArray manualObject, Target t) { - return null; - } } public abstract static class player_bucket_event extends AbstractEvent { @@ -2799,11 +2739,6 @@ public boolean matches(Map prefilter, BindableEvent e) throws Pre return false; } - @Override - public BindableEvent convert(CArray manualObject, Target t) { - throw ConfigRuntimeException.CreateUncatchableException("Unsupported operation.", Target.UNKNOWN); - } - @Override public boolean modifyEvent(String key, Mixed value, BindableEvent e) { return false; @@ -2954,11 +2889,6 @@ public boolean modifyEvent(String key, Mixed value, BindableEvent event) { public MSVersion since() { return MSVersion.V3_3_5; } - - @Override - public BindableEvent convert(CArray manualObject, Target t) { - return null; - } } @api @@ -3020,10 +2950,5 @@ public boolean modifyEvent(String key, Mixed value, BindableEvent event) { public MSVersion since() { return MSVersion.V3_3_5; } - - @Override - public BindableEvent convert(CArray manualObject, Target t) { - return null; - } } } diff --git a/src/main/java/com/laytonsmith/core/events/drivers/PluginEvents.java b/src/main/java/com/laytonsmith/core/events/drivers/PluginEvents.java index f6e06d9a15..9aa99e1fc3 100644 --- a/src/main/java/com/laytonsmith/core/events/drivers/PluginEvents.java +++ b/src/main/java/com/laytonsmith/core/events/drivers/PluginEvents.java @@ -3,7 +3,6 @@ import com.laytonsmith.abstraction.events.MCPluginIncomingMessageEvent; import com.laytonsmith.annotations.api; import com.laytonsmith.core.MSVersion; -import com.laytonsmith.core.constructs.CArray; import com.laytonsmith.core.constructs.CByteArray; import com.laytonsmith.core.constructs.CString; import com.laytonsmith.core.constructs.Target; @@ -61,11 +60,6 @@ public boolean matches(Map prefilter, BindableEvent e) throws Pre return false; } - @Override - public BindableEvent convert(CArray manualObject, Target t) { - return null; - } - @Override public Map evaluate(BindableEvent e) throws EventException { if(e instanceof MCPluginIncomingMessageEvent) { diff --git a/src/main/java/com/laytonsmith/core/events/drivers/ServerEvents.java b/src/main/java/com/laytonsmith/core/events/drivers/ServerEvents.java index e5c2418f19..4211e7dbae 100644 --- a/src/main/java/com/laytonsmith/core/events/drivers/ServerEvents.java +++ b/src/main/java/com/laytonsmith/core/events/drivers/ServerEvents.java @@ -33,7 +33,6 @@ import com.laytonsmith.core.events.EventBuilder; import com.laytonsmith.core.events.Prefilters; import com.laytonsmith.core.events.Prefilters.PrefilterType; -import com.laytonsmith.core.exceptions.ConfigRuntimeException; import com.laytonsmith.core.exceptions.EventException; import com.laytonsmith.core.exceptions.PrefilterNonMatchException; import com.laytonsmith.core.exceptions.CRE.CRECastException; @@ -98,11 +97,6 @@ public boolean matches(Map prefilter, BindableEvent e) throws Pre return true; } - @Override - public BindableEvent convert(CArray manualObject, Target t) { - throw new UnsupportedOperationException("Not supported yet."); - } - @Override public Map evaluate(BindableEvent e) throws EventException { if(!(e instanceof MCServerCommandEvent)) { @@ -185,11 +179,6 @@ public boolean matches(Map prefilter, BindableEvent e) throws Pre return false; } - @Override - public BindableEvent convert(CArray manualObject, Target t) { - throw ConfigRuntimeException.CreateUncatchableException("Unsupported Operation", Target.UNKNOWN); - } - @Override public Map evaluate(BindableEvent e) throws EventException { if(e instanceof MCServerPingEvent) { @@ -293,11 +282,6 @@ public boolean matches(Map prefilter, BindableEvent event) throws return event instanceof MCCommandTabCompleteEvent; } - @Override - public BindableEvent convert(CArray manualObject, Target t) { - throw ConfigRuntimeException.CreateUncatchableException("Unsupported Operation", Target.UNKNOWN); - } - @Override public Map evaluate(BindableEvent event) throws EventException { if(event instanceof MCCommandTabCompleteEvent) { @@ -405,11 +389,6 @@ public boolean matches(Map evaluate(BindableEvent e) throws EventException { MCRedstoneChangedEvent event = (MCRedstoneChangedEvent) e; @@ -465,26 +444,24 @@ public boolean matches(Map prefilter, BindableEvent e) throws Pre } @Override - public BindableEvent convert(CArray manualObject, Target t) { + public BindableEvent convert(CArray manualObject, Target t, Environment env) { // Get the player recipients. Mixed cRecipients = manualObject.get("player_recipients", t); if(!(cRecipients instanceof CArray) && !(cRecipients instanceof CNull)) { - throw new CRECastException("Expected player_recipients to be an array, but received: " - + cRecipients.typeof().toString(), t); + throw new CRECastException("Expected player_recipients to be an array", t); } Set recipients = new HashSet<>(); CArray recipientsArray = (CArray) cRecipients; - for(int i = 0; i < recipientsArray.size(); i++) { - MCPlayer player = Static.GetPlayer(recipientsArray.get(i, t), t); + for(int i = 0; i < recipientsArray.size(env); i++) { + MCPlayer player = Static.GetPlayer(recipientsArray.get(i, t, env), t); recipients.add(player); } // Get the message. - Mixed cMessage = manualObject.get("message", t); + Mixed cMessage = manualObject.get("message", t, env); if(!(cMessage instanceof CString)) { - throw new CRECastException("Expected message to be a string, but received: " - + cMessage.typeof().toString(), t); + throw new CRECastException("Expected message to be a string.", t); } // Instantiate and return the event. diff --git a/src/main/java/com/laytonsmith/core/events/drivers/VehicleEvents.java b/src/main/java/com/laytonsmith/core/events/drivers/VehicleEvents.java index a975390fd4..e1e8ae33e1 100644 --- a/src/main/java/com/laytonsmith/core/events/drivers/VehicleEvents.java +++ b/src/main/java/com/laytonsmith/core/events/drivers/VehicleEvents.java @@ -29,6 +29,7 @@ import com.laytonsmith.core.constructs.CNull; import com.laytonsmith.core.constructs.CString; import com.laytonsmith.core.constructs.Target; +import com.laytonsmith.core.environments.Environment; import com.laytonsmith.core.events.AbstractEvent; import com.laytonsmith.core.events.BindableEvent; import com.laytonsmith.core.events.BoundEvent; @@ -85,11 +86,6 @@ public boolean matches(Map prefilter, BindableEvent event) throws return false; } - @Override - public BindableEvent convert(CArray manualObject, Target t) { - throw ConfigRuntimeException.CreateUncatchableException("Unsupported Operation", Target.UNKNOWN); - } - @Override public Map evaluate(BindableEvent event) throws EventException { if(event instanceof MCVehicleEnterExitEvent) { @@ -156,11 +152,6 @@ public boolean matches(Map prefilter, BindableEvent event) throws return false; } - @Override - public BindableEvent convert(CArray manualObject, Target t) { - throw ConfigRuntimeException.CreateUncatchableException("Unsupported Operation", Target.UNKNOWN); - } - @Override public Map evaluate(BindableEvent event) throws EventException { if(event instanceof MCVehicleEnterExitEvent) { @@ -272,12 +263,6 @@ public boolean matches(Map prefilter, BindableEvent e) throws Pre } return false; } - - @Override - public BindableEvent convert(CArray manualObject, Target t) { - throw ConfigRuntimeException.CreateUncatchableException("Unsupported Operation", Target.UNKNOWN); - } - @Override public Map evaluate(BindableEvent event) throws EventException { if(event instanceof MCVehicleCollideEvent) { @@ -482,15 +467,17 @@ public boolean matches(Map prefilter, BindableEvent e) throws Pre } @Override - public BindableEvent convert(CArray manualObject, Target t) { + public BindableEvent convert(CArray manualObject, Target t, Environment env) { - MCEntity e = Static.getEntity(manualObject.get("id", Target.UNKNOWN), Target.UNKNOWN); + MCEntity e = Static.getEntity(manualObject.get("id", t, env), t); if(!(e instanceof MCVehicle)) { - throw new CREBadEntityException("The id was not a vehicle", Target.UNKNOWN); + throw new CREBadEntityException("The id was not a vehicle", t); } - MCLocation from = ObjectGenerator.GetGenerator().location(manualObject.get("from", Target.UNKNOWN), e.getWorld(), manualObject.getTarget()); - MCLocation to = ObjectGenerator.GetGenerator().location(manualObject.get("to", Target.UNKNOWN), e.getWorld(), manualObject.getTarget()); + MCLocation from = ObjectGenerator.GetGenerator().location(manualObject.get("from", t, env), + e.getWorld(), manualObject.getTarget()); + MCLocation to = ObjectGenerator.GetGenerator().location(manualObject.get("to", t, env), + e.getWorld(), manualObject.getTarget()); return EventBuilder.instantiate(MCVehicleMoveEvent.class, e, from, to); } @@ -580,11 +567,6 @@ public boolean matches(Map prefilter, BindableEvent event) throws return false; } - @Override - public BindableEvent convert(CArray manualObject, Target t) { - throw ConfigRuntimeException.CreateUncatchableException("Unsupported Operation", Target.UNKNOWN); - } - @Override public Map evaluate(BindableEvent event) throws EventException { if(event instanceof MCVehicleDestroyEvent) { diff --git a/src/main/java/com/laytonsmith/core/events/drivers/WeatherEvents.java b/src/main/java/com/laytonsmith/core/events/drivers/WeatherEvents.java index f260067c3b..4917c8e411 100644 --- a/src/main/java/com/laytonsmith/core/events/drivers/WeatherEvents.java +++ b/src/main/java/com/laytonsmith/core/events/drivers/WeatherEvents.java @@ -9,7 +9,6 @@ import com.laytonsmith.core.MSVersion; import com.laytonsmith.core.ObjectGenerator; import com.laytonsmith.core.Static; -import com.laytonsmith.core.constructs.CArray; import com.laytonsmith.core.constructs.CBoolean; import com.laytonsmith.core.constructs.CString; import com.laytonsmith.core.constructs.Target; @@ -63,11 +62,6 @@ public boolean matches(Map prefilter, BindableEvent event) throws return false; } - @Override - public BindableEvent convert(CArray manualObject, Target t) { - return null; - } - @Override public Map evaluate(BindableEvent event) throws EventException { if(event instanceof MCLightningStrikeEvent) { @@ -148,11 +142,6 @@ public boolean matches(Map prefilter, BindableEvent event) throws return false; } - @Override - public BindableEvent convert(CArray manualObject, Target t) { - return null; - } - @Override public Map evaluate(BindableEvent event) throws EventException { if(event instanceof MCThunderChangeEvent) { @@ -212,10 +201,6 @@ public boolean matches(Map prefilter, BindableEvent event) throws return false; } - @Override - public BindableEvent convert(CArray manualObject, Target t) { - return null; - } @Override public Map evaluate(BindableEvent event) throws EventException { diff --git a/src/main/java/com/laytonsmith/core/events/drivers/WorldEvents.java b/src/main/java/com/laytonsmith/core/events/drivers/WorldEvents.java index b8544dbc8c..297dbe796f 100644 --- a/src/main/java/com/laytonsmith/core/events/drivers/WorldEvents.java +++ b/src/main/java/com/laytonsmith/core/events/drivers/WorldEvents.java @@ -88,11 +88,6 @@ public boolean matches(Map prefilter, BindableEvent e) throws Pre public boolean modifyEvent(String key, Mixed value, BindableEvent event) { return false; } - - @Override - public BindableEvent convert(CArray manualObject, Target t) { - return null; - } } @api @@ -136,11 +131,6 @@ public boolean matches(Map prefilter, BindableEvent e) throws Pre public boolean modifyEvent(String key, Mixed value, BindableEvent event) { return false; } - - @Override - public BindableEvent convert(CArray manualObject, Target t) { - return null; - } } @api @@ -184,11 +174,6 @@ public boolean matches(Map prefilter, BindableEvent e) throws Pre public boolean modifyEvent(String key, Mixed value, BindableEvent event) { return false; } - - @Override - public BindableEvent convert(CArray manualObject, Target t) { - return null; - } } @api @@ -269,10 +254,5 @@ public Map evaluate(BindableEvent e) throws EventException { public boolean modifyEvent(String key, Mixed value, BindableEvent event) { return false; } - - @Override - public BindableEvent convert(CArray manualObject, Target t) { - return null; - } } } diff --git a/src/main/java/com/laytonsmith/core/functions/ArrayHandling.java b/src/main/java/com/laytonsmith/core/functions/ArrayHandling.java index a4923e7303..acef637d11 100644 --- a/src/main/java/com/laytonsmith/core/functions/ArrayHandling.java +++ b/src/main/java/com/laytonsmith/core/functions/ArrayHandling.java @@ -3818,18 +3818,18 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { Mixed fill = args[1]; if(args[0] instanceof CFixedArray fa) { - fa.fill(fill, t); + fa.fill(fill, t, env); return fa; } else { - CArray array = ArgumentValidation.getArray(args[0], t); + CArray array = ArgumentValidation.getArray(args[0], t, env); if(array.isAssociative()) { throw new CRECastException(getName() + " can only accept normal arrays.", t); } - for(Mixed key : array.keySet()) { - array.set(key, fill, t); + for(Mixed key : array.keySet(env)) { + array.set(key, fill, t, env); } return array; } diff --git a/src/main/java/com/laytonsmith/core/functions/BossBar.java b/src/main/java/com/laytonsmith/core/functions/BossBar.java index d1923a616a..3c59f009d8 100644 --- a/src/main/java/com/laytonsmith/core/functions/BossBar.java +++ b/src/main/java/com/laytonsmith/core/functions/BossBar.java @@ -132,7 +132,7 @@ public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed.. boolean visible = true; double percent = 1.0; if(args.length == 2) { - if(!(args[1].isInstanceOf(CArray.TYPE))) { + if(!(args[1].isInstanceOf(CArray.TYPE, null, env))) { throw new CRECastException("Expected array for parameter 2 of create_bar()", t); } CArray ca = (CArray) args[1]; @@ -209,15 +209,15 @@ public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed.. if(bar == null) { throw new CRENotFoundException("That boss bar id does not exist.", t); } - if(args[1].isInstanceOf(CString.TYPE)) { + if(args[1].isInstanceOf(CString.TYPE, null, env)) { bar.setTitle(args[1].val()); - } else if(args[1].isInstanceOf(CDouble.TYPE)) { + } else if(args[1].isInstanceOf(CDouble.TYPE, null, env)) { try { bar.setProgress(ArgumentValidation.getDouble(args[1], t)); } catch (IllegalArgumentException ex) { throw new CRERangeException("Progress percentage must be from 0.0 to 1.0.", t); } - } else if(args[1].isInstanceOf(CArray.TYPE)) { + } else if(args[1].isInstanceOf(CArray.TYPE, null, env)) { CArray ca = (CArray) args[1]; if(ca.containsKey("title")) { bar.setTitle(ca.get("title", t).val()); diff --git a/src/main/java/com/laytonsmith/core/functions/Cmdline.java b/src/main/java/com/laytonsmith/core/functions/Cmdline.java index 84d111ea5c..4d4d798e9e 100644 --- a/src/main/java/com/laytonsmith/core/functions/Cmdline.java +++ b/src/main/java/com/laytonsmith/core/functions/Cmdline.java @@ -983,7 +983,7 @@ public Mixed exec(final Target t, final Environment environment, GenericParamete final CClosure stderr; final CClosure exit; final boolean subshell; - if(args[0].isInstanceOf(CArray.TYPE)) { + if(args[0].isInstanceOf(CArray.TYPE, null, environment)) { CArray array = (CArray) args[0]; command = new String[(int) array.size()]; for(int i = 0; i < array.size(); i++) { @@ -1188,7 +1188,7 @@ public Mixed exec(Target t, Environment environment, GenericParameters generics, String[] command; int expectedExitCode = 0; File workingDir = null; - if(args[0].isInstanceOf(CArray.TYPE)) { + if(args[0].isInstanceOf(CArray.TYPE, null, environment)) { CArray array = (CArray) args[0]; command = new String[(int) array.size()]; for(int i = 0; i < array.size(); i++) { @@ -1768,7 +1768,7 @@ public Boolean runAsync() { @Override public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { requireCmdlineMode(environment, this, t); - if(!(args[0].isInstanceOf(CClosure.TYPE))) { + if(!(args[0].isInstanceOf(CClosure.TYPE, null, environment))) { throw new CRECastException("Expecting a closure for argument 1 of " + getName(), t); } environment.getEnv(GlobalEnv.class).SetCustom("cmdline_prompt", args[0]); @@ -1975,7 +1975,7 @@ public Mixed exec(Target t, Environment environment, GenericParameters generics, String startFrom = environment.getEnv(GlobalEnv.class).GetRootFolder().getAbsolutePath(); Set findTypes = EnumSet.allOf(FindType.class); if(args.length == 2) { - if(args[1].isInstanceOf(CArray.TYPE)) { + if(args[1].isInstanceOf(CArray.TYPE, null, environment)) { findTypes = ArgumentValidation.getEnumSet(args[1], FindType.class, t); } else { startFrom = ArgumentValidation.getString(args[1], t); diff --git a/src/main/java/com/laytonsmith/core/functions/Commands.java b/src/main/java/com/laytonsmith/core/functions/Commands.java index 52acefac68..a0287d7f1e 100644 --- a/src/main/java/com/laytonsmith/core/functions/Commands.java +++ b/src/main/java/com/laytonsmith/core/functions/Commands.java @@ -92,7 +92,7 @@ public Mixed exec(Target t, Environment environment, GenericParameters generics, * @param arg */ public static void customExec(Target t, Environment environment, MCCommand cmd, Mixed arg) { - if(arg.isInstanceOf(Callable.TYPE)) { + if(arg.isInstanceOf(Callable.TYPE, null, environment)) { onTabComplete.put(cmd.getName(), (Callable) arg); } else { throw new CREFormatException("Only Callables are accepted as tabcompleters", t); @@ -244,7 +244,7 @@ public Mixed exec(Target t, Environment environment, GenericParameters generics, register = true; cmd = StaticLayer.GetConvertor().getNewCommand(cmdStr); } - if(args[1].isInstanceOf(CArray.TYPE)) { + if(args[1].isInstanceOf(CArray.TYPE, null, environment)) { CArray ops = (CArray) args[1]; if(ops.containsKey("permission")) { cmd.setPermission(ops.get("permission", t).val()); @@ -260,7 +260,7 @@ public Mixed exec(Target t, Environment environment, GenericParameters generics, } List oldAliases = new ArrayList<>(cmd.getAliases()); if(ops.containsKey("aliases")) { - if(ops.get("aliases", t).isInstanceOf(CArray.TYPE)) { + if(ops.get("aliases", t).isInstanceOf(CArray.TYPE, null, environment)) { List ca = ((CArray) ops.get("aliases", t)).asList(); List aliases = new ArrayList<>(); for(Mixed c : ca) { @@ -519,7 +519,7 @@ public Mixed exec(Target t, Environment environment, GenericParameters generics, * @param arg */ static void customExec(Target t, Environment environment, MCCommand cmd, Mixed arg) { - if(arg.isInstanceOf(CClosure.TYPE)) { + if(arg.isInstanceOf(CClosure.TYPE, null, environment)) { onCommand.put(cmd.getName(), (CClosure) arg); } else { throw new CREFormatException("At this time, only closures are accepted as command executors.", t); diff --git a/src/main/java/com/laytonsmith/core/functions/ControlFlow.java b/src/main/java/com/laytonsmith/core/functions/ControlFlow.java index 6f109abe7c..42094a261c 100644 --- a/src/main/java/com/laytonsmith/core/functions/ControlFlow.java +++ b/src/main/java/com/laytonsmith/core/functions/ControlFlow.java @@ -674,7 +674,7 @@ public Mixed execs(Target t, Environment env, Script parent, ParseTree... nodes) if(evalStatement instanceof CSlice) { //Can do more optimal handling for this Array subclass long rangeLeft = ((CSlice) evalStatement).getStart(); long rangeRight = ((CSlice) evalStatement).getFinish(); - if(value.isInstanceOf(CInt.TYPE)) { + if(value.isInstanceOf(CInt.TYPE, null, env)) { long v = ArgumentValidation.getInt(value, t); if((rangeLeft < rangeRight && v >= rangeLeft && v <= rangeRight) || (rangeLeft > rangeRight && v >= rangeRight && v <= rangeLeft) @@ -682,13 +682,13 @@ public Mixed execs(Target t, Environment env, Script parent, ParseTree... nodes) return parent.seval(code, env); } } - } else if(evalStatement.isInstanceOf(CArray.TYPE)) { + } else if(evalStatement.isInstanceOf(CArray.TYPE, null, env)) { for(String index : ((CArray) evalStatement).stringKeySet()) { Mixed inner = ((CArray) evalStatement).get(index, t); if(inner instanceof CSlice) { long rangeLeft = ((CSlice) inner).getStart(); long rangeRight = ((CSlice) inner).getFinish(); - if(value.isInstanceOf(CInt.TYPE)) { + if(value.isInstanceOf(CInt.TYPE, null, env)) { long v = ArgumentValidation.getInt(value, t); if((rangeLeft < rangeRight && v >= rangeLeft && v <= rangeRight) || (rangeLeft > rangeRight && v >= rangeRight && v <= rangeLeft) @@ -883,7 +883,7 @@ public ParseTree optimizeDynamic(Target t, Environment env, children.set(i, new ParseTree(data, children.get(i).getFileOptions())); } //Now we validate that the values are constant and non-repeating. - if(children.get(i).getData().isInstanceOf(CArray.TYPE)) { + if(children.get(i).getData().isInstanceOf(CArray.TYPE, null, env)) { List list = ((CArray) children.get(i).getData()).asList(); for(Mixed c : list) { if(c instanceof CSlice) { @@ -915,7 +915,7 @@ public ParseTree optimizeDynamic(Target t, Environment env, } } - if((children.size() > 3 || (children.size() > 1 && children.get(1).getData().isInstanceOf(CArray.TYPE))) + if((children.size() > 3 || (children.size() > 1 && children.get(1).getData().isInstanceOf(CArray.TYPE, null, env))) //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 && !Construct.IsDynamicHelper(children.get(0).getData()))) { @@ -926,7 +926,7 @@ public ParseTree optimizeDynamic(Target t, Environment env, for(int i = 1; i < children.size(); i += 2) { Mixed data = children.get(i).getData(); - if(!(data.isInstanceOf(CArray.TYPE)) || data instanceof CSlice) { + if(!(data.isInstanceOf(CArray.TYPE, null, env)) || data instanceof CSlice) { //Put it in an array to make the rest of this parsing easier. data = new CArray(t); ((CArray) data).push(children.get(i).getData(), t); @@ -935,7 +935,7 @@ public ParseTree optimizeDynamic(Target t, Environment env, if(value instanceof CSlice) { long rangeLeft = ((CSlice) value).getStart(); long rangeRight = ((CSlice) value).getFinish(); - if(children.get(0).getData().isInstanceOf(CInt.TYPE)) { + if(children.get(0).getData().isInstanceOf(CInt.TYPE, null, env)) { long v = ArgumentValidation.getInt(children.get(0).getData(), t); if((rangeLeft < rangeRight && v >= rangeLeft && v <= rangeRight) || (rangeLeft > rangeRight && v >= rangeRight && v <= rangeLeft) @@ -1918,7 +1918,7 @@ public Mixed execs(Target t, Environment env, Script parent, ParseTree... nodes) Mixed data = parent.seval(array, env); - if(!(data.isInstanceOf(CArray.TYPE)) && !(data instanceof CSlice)) { + if(!(data.isInstanceOf(CArray.TYPE, null, env)) && !(data instanceof CSlice)) { throw new CRECastException(getName() + " expects an array for parameter 1", t); } @@ -2516,7 +2516,7 @@ public ParseTree optimizeDynamic(Target t, Environment env, + " be hard coded, and should not be dynamically determinable, since this is always a sign" + " of loose code flow, which should be avoided.", t); } - if(!(children.get(0).getData().isInstanceOf(CInt.TYPE))) { + if(!(children.get(0).getData().isInstanceOf(CInt.TYPE, null, env))) { throw new ConfigCompileException("break() only accepts integer values.", t); } } diff --git a/src/main/java/com/laytonsmith/core/functions/Crypto.java b/src/main/java/com/laytonsmith/core/functions/Crypto.java index 17b3e89d8b..b3e1c13afa 100644 --- a/src/main/java/com/laytonsmith/core/functions/Crypto.java +++ b/src/main/java/com/laytonsmith/core/functions/Crypto.java @@ -461,7 +461,7 @@ public Mixed exec(Target t, Environment environment, GenericParameters generics, } try { String val; - if(args[0].isInstanceOf(CSecureString.TYPE)) { + if(args[0].isInstanceOf(CSecureString.TYPE, null, environment)) { val = new String(((CSecureString) args[0]).getDecryptedCharArray()); } else { val = args[0].val(); @@ -532,7 +532,7 @@ public Boolean runAsync() { @Override public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { String val; - if(args[0].isInstanceOf(CSecureString.TYPE)) { + if(args[0].isInstanceOf(CSecureString.TYPE, null, environment)) { val = new String(((CSecureString) args[0]).getDecryptedCharArray()); } else { val = args[0].val(); diff --git a/src/main/java/com/laytonsmith/core/functions/DataTransformations.java b/src/main/java/com/laytonsmith/core/functions/DataTransformations.java index ae64c58534..68a757eb1b 100644 --- a/src/main/java/com/laytonsmith/core/functions/DataTransformations.java +++ b/src/main/java/com/laytonsmith/core/functions/DataTransformations.java @@ -338,7 +338,7 @@ public Mixed exec(Target t, Environment environment, GenericParameters generics, String val; if(c instanceof CNull) { val = ""; - } else if(c.isInstanceOf(CArray.TYPE)) { + } else if(c.isInstanceOf(CArray.TYPE, null, environment)) { throw new CRECastException("Arrays cannot be encoded with ini_encode.", t); } else { val = c.val(); diff --git a/src/main/java/com/laytonsmith/core/functions/Debug.java b/src/main/java/com/laytonsmith/core/functions/Debug.java index a703d73f60..c33f6db533 100644 --- a/src/main/java/com/laytonsmith/core/functions/Debug.java +++ b/src/main/java/com/laytonsmith/core/functions/Debug.java @@ -368,14 +368,14 @@ public static CVoid doTrace(Target t, Environment environment, Mixed... args) { + TermColors.RESET + ": " + TermColors.BRIGHT_WHITE + ivar.getDefinedType() + TermColors.RESET + " (actual type " - + TermColors.BRIGHT_WHITE + val.typeof() - + (val.isInstanceOf(Sizeable.TYPE) ? ", length: " + ((Sizeable) val).size() : "") + + TermColors.BRIGHT_WHITE + val.typeof(environment) + + (val.isInstanceOf(Sizeable.TYPE, null, environment) ? ", length: " + ((Sizeable) val).size() : "") + TermColors.RESET + ") " + TermColors.CYAN + ivar.getVariableName() + TermColors.RESET + ": " + val.val()); return CVoid.VOID; } else { - throw new CRECastException("Expecting an ivar, but received " + args[0].typeof().getSimpleName() + throw new CRECastException("Expecting an ivar, but received " + args[0].typeof(environment).getSimpleName() + " instead", t); } } diff --git a/src/main/java/com/laytonsmith/core/functions/Echoes.java b/src/main/java/com/laytonsmith/core/functions/Echoes.java index ea7f08f5c0..bfdc51ce6a 100644 --- a/src/main/java/com/laytonsmith/core/functions/Echoes.java +++ b/src/main/java/com/laytonsmith/core/functions/Echoes.java @@ -711,7 +711,7 @@ public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed.. } // Handle "broadcast(message, recipientsArray)". - if(args[1].isInstanceOf(CArray.TYPE)) { + if(args[1].isInstanceOf(CArray.TYPE, null, env)) { // Get the CArray and validate that it is non-associative. CArray array = (CArray) args[1]; @@ -842,7 +842,7 @@ public Mixed exec(Target t, Environment environment, GenericParameters generics, if(args.length == 2) { symbol = args[1].val(); } - if(!(text.isInstanceOf(CString.TYPE))) { + if(!(text.isInstanceOf(CString.TYPE, null, environment))) { return text; } String stext = text.val(); diff --git a/src/main/java/com/laytonsmith/core/functions/Enchantments.java b/src/main/java/com/laytonsmith/core/functions/Enchantments.java index e10aaac9d7..17cb910d51 100644 --- a/src/main/java/com/laytonsmith/core/functions/Enchantments.java +++ b/src/main/java/com/laytonsmith/core/functions/Enchantments.java @@ -186,7 +186,7 @@ public Boolean runAsync() { public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCPlayer p; int offset = 0; - if(args.length == 4 || args.length == 3 && args[2].isInstanceOf(CArray.TYPE)) { + if(args.length == 4 || args.length == 3 && args[2].isInstanceOf(CArray.TYPE, null, environment)) { p = Static.GetPlayer(args[0].val(), t); offset = 1; } else { @@ -198,7 +198,7 @@ public Mixed exec(Target t, Environment environment, GenericParameters generics, throw new CRECastException("There is no item at slot " + args[offset], t); } - if(args[args.length - 1].isInstanceOf(CArray.TYPE)) { + if(args[args.length - 1].isInstanceOf(CArray.TYPE, null, environment)) { CArray ca = (CArray) args[args.length - 1]; Map enchants = ObjectGenerator.GetGenerator().enchants(ca, t); for(Map.Entry en : enchants.entrySet()) { @@ -274,7 +274,7 @@ public Mixed exec(Target t, Environment environment, GenericParameters generics, throw new CRECastException("There is no item at slot " + args[offset], t); } - if(args[offset + 1].isInstanceOf(CArray.TYPE)) { + if(args[offset + 1].isInstanceOf(CArray.TYPE, null, environment)) { for(String name : ((CArray) args[offset + 1]).stringKeySet()) { MCEnchantment e = GetEnchantment(name, t); is.removeEnchantment(e); @@ -490,7 +490,7 @@ public Boolean runAsync() { @Override public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCItemStack is; - if(args[0].isInstanceOf(CArray.TYPE)) { + if(args[0].isInstanceOf(CArray.TYPE, null, environment)) { is = ObjectGenerator.GetGenerator().item(args[0], t); } else { is = Static.ParseItemNotation(null, args[0].val(), 1, t); @@ -519,7 +519,7 @@ public ParseTree optimizeDynamic(Target t, Environment env, FileOptions fileOptions) throws ConfigCompileException, ConfigRuntimeException { if(children.size() == 1 - && (children.get(0).getData().isInstanceOf(CString.TYPE) || children.get(0).getData().isInstanceOf(CInt.TYPE))) { + && (children.get(0).getData().isInstanceOf(CString.TYPE, null, env) || children.get(0).getData().isInstanceOf(CInt.TYPE, null, env))) { env.getEnv(CompilerEnvironment.class).addCompilerWarning(fileOptions, new CompilerWarning("The string item format in " + getName() + " is deprecated.", t, null)); } diff --git a/src/main/java/com/laytonsmith/core/functions/EventBinding.java b/src/main/java/com/laytonsmith/core/functions/EventBinding.java index b67a8a131d..29c0cf8ef5 100644 --- a/src/main/java/com/laytonsmith/core/functions/EventBinding.java +++ b/src/main/java/com/laytonsmith/core/functions/EventBinding.java @@ -165,10 +165,10 @@ public Mixed execs(Target t, Environment env, Script parent, ParseTree... nodes) ParseTree tree = nodes[nodes.length - 1]; //Check to see if our arguments are correct - if(!(options instanceof CNull || options.isInstanceOf(CArray.TYPE))) { + if(!(options instanceof CNull || options.isInstanceOf(CArray.TYPE, null, env))) { throw new CRECastException("The options must be an array or null", t); } - if(!(prefilter instanceof CNull || prefilter.isInstanceOf(CArray.TYPE))) { + if(!(prefilter instanceof CNull || prefilter.isInstanceOf(CArray.TYPE, null, env))) { throw new CRECastException("The prefilters must be an array or null", t); } if(!(event_obj instanceof IVariable)) { @@ -387,14 +387,14 @@ public ParseTree optimizeDynamic(Target t, Environment env, if(node.getData() instanceof CFunction && node.getData().val().equals(Compiler.centry.NAME)) { List children = node.getChildren(); if(children.get(0).getData().val().equals("id") - && children.get(1).getData().isInstanceOf(CString.TYPE)) { + && children.get(1).getData().isInstanceOf(CString.TYPE, null, env)) { if(children.get(1).getData().val().matches(".*?:\\d*?")) { exceptions.add(new ConfigCompileException(children.get(1).getData().val() + " is not a valid event identifier." + " It cannot match the regex \".*?:\\d*?\".", children.get(1).getTarget())); } } else if(children.get(0).getData().val().equals("priority") - && children.get(1).getData().isInstanceOf(CString.TYPE)) { + && children.get(1).getData().isInstanceOf(CString.TYPE, null, env)) { try { BoundEvent.Priority.valueOf(children.get(1).getData().val().toUpperCase()); try { @@ -748,20 +748,20 @@ public Boolean runAsync() { } @Override - public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { + public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { CArray obj = null; if(args[1] instanceof CNull) { obj = new CArray(t); - } else if(args[1].isInstanceOf(CArray.TYPE)) { + } else if(args[1].isInstanceOf(CArray.TYPE, null, env)) { obj = (CArray) args[1]; } else { throw new CRECastException("The eventObject must be null, or an array", t); } boolean serverWide = false; if(args.length == 3) { - serverWide = ArgumentValidation.getBoolean(args[2], t); + serverWide = ArgumentValidation.getBoolean(args[2], t, env); } - EventUtils.ManualTrigger(args[0].val(), obj, t, serverWide); + EventUtils.ManualTrigger(args[0].val(), obj, t, serverWide, env); return CVoid.VOID; } } @@ -896,7 +896,7 @@ public Mixed exec(Target t, Environment environment, GenericParameters generics, if(args.length == 0) { e.lock(null); } else { - if(args[0].isInstanceOf(CArray.TYPE)) { + if(args[0].isInstanceOf(CArray.TYPE, null, environment)) { CArray ca = (CArray) args[1]; for(int i = 0; i < ca.size(); i++) { params.add(ca.get(i, t).val()); diff --git a/src/main/java/com/laytonsmith/core/functions/Exceptions.java b/src/main/java/com/laytonsmith/core/functions/Exceptions.java index da978c7133..575c00efa2 100644 --- a/src/main/java/com/laytonsmith/core/functions/Exceptions.java +++ b/src/main/java/com/laytonsmith/core/functions/Exceptions.java @@ -156,9 +156,9 @@ public Mixed execs(Target t, Environment env, Script that, ParseTree... nodes) { List interest = new ArrayList<>(); if(types != null) { Mixed ptypes = that.seval(types, env); - if(ptypes.isInstanceOf(CString.TYPE)) { + if(ptypes.isInstanceOf(CString.TYPE, null, env)) { interest.add(FullyQualifiedClassName.forName(ptypes.val(), t, env)); - } else if(ptypes.isInstanceOf(CArray.TYPE)) { + } else if(ptypes.isInstanceOf(CArray.TYPE, null, env)) { CArray ca = (CArray) ptypes; for(int i = 0; i < ca.size(); i++) { interest.add(FullyQualifiedClassName.forName(ca.get(i, t).val(), t, env)); @@ -399,7 +399,7 @@ public Boolean runAsync() { @Override public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { - if(args[0].isInstanceOf(CClosure.TYPE)) { + if(args[0].isInstanceOf(CClosure.TYPE, null, environment)) { CClosure old = environment.getEnv(StaticRuntimeEnv.class).getExceptionHandler(); environment.getEnv(StaticRuntimeEnv.class).setExceptionHandler((CClosure) args[0]); if(old == null) { @@ -612,7 +612,7 @@ public ParseTree optimizeDynamic(Target t, Environment env, // Check for a container function with a string as first argument, being an unknown type. if(assign.numberOfChildren() > 0) { - if(assign.getChildAt(0).getData().isInstanceOf(CString.TYPE)) { + if(assign.getChildAt(0).getData().isInstanceOf(CString.TYPE, null, env)) { throw new ConfigCompileException("Unknown class type: " + assign.getChildAt(0).getData().val(), t); } diff --git a/src/main/java/com/laytonsmith/core/functions/ExecutionQueue.java b/src/main/java/com/laytonsmith/core/functions/ExecutionQueue.java index a49728cdc5..1a0776d395 100644 --- a/src/main/java/com/laytonsmith/core/functions/ExecutionQueue.java +++ b/src/main/java/com/laytonsmith/core/functions/ExecutionQueue.java @@ -60,7 +60,7 @@ public Boolean runAsync() { public Mixed exec(Target t, final Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { final CClosure c; String queue = null; - if(!(args[0].isInstanceOf(CClosure.TYPE))) { + if(!(args[0].isInstanceOf(CClosure.TYPE, null, environment))) { throw new CRECastException("Parameter 1 to " + getName() + " must be a closure.", t); } c = ((CClosure) args[0]); @@ -143,7 +143,7 @@ public Boolean runAsync() { public Mixed exec(Target t, final Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { final CClosure c; String queue = null; - if(!(args[0].isInstanceOf(CClosure.TYPE))) { + if(!(args[0].isInstanceOf(CClosure.TYPE, null, environment))) { throw new CRECastException("Parameter 1 to " + getName() + " must be a closure.", t); } c = ((CClosure) args[0]); diff --git a/src/main/java/com/laytonsmith/core/functions/ExtensionMeta.java b/src/main/java/com/laytonsmith/core/functions/ExtensionMeta.java index 534c2fc178..da71c7b992 100644 --- a/src/main/java/com/laytonsmith/core/functions/ExtensionMeta.java +++ b/src/main/java/com/laytonsmith/core/functions/ExtensionMeta.java @@ -113,7 +113,7 @@ public ParseTree optimizeDynamic(Target t, Environment env, throw new ConfigCompileException(getName() + " can only accept one argument", t); } - if(!(children.get(0).getData().isInstanceOf(CString.TYPE))) { + if(!(children.get(0).getData().isInstanceOf(CString.TYPE, null, env))) { throw new ConfigCompileException(getName() + " can only accept hardcoded string values", t); } @@ -201,7 +201,7 @@ public ParseTree optimizeDynamic(Target t, Environment env, throw new ConfigCompileException(getName() + " can only accept one argument", t); } - if(!(children.get(0).getData().isInstanceOf(CString.TYPE))) { + if(!(children.get(0).getData().isInstanceOf(CString.TYPE, null, env))) { throw new ConfigCompileException(getName() + " can only accept hardcoded string values", t); } @@ -274,7 +274,7 @@ public ParseTree optimizeDynamic(Target t, Environment env, throws ConfigCompileException, ConfigRuntimeException { if(children.size() != 1) { throw new ConfigCompileException(getName() + " can only accept one argument", t); - } else if(!(children.get(0).getData().isInstanceOf(CString.TYPE))) { + } else if(!(children.get(0).getData().isInstanceOf(CString.TYPE, null, env))) { throw new ConfigCompileException(getName() + " can only accept hardcoded string values", t); } else { return new ParseTree(this.exec(t, null, null, children.get(0).getData()), children.get(0).getFileOptions()); diff --git a/src/main/java/com/laytonsmith/core/functions/FileHandling.java b/src/main/java/com/laytonsmith/core/functions/FileHandling.java index 62496247fc..d9d736d9c7 100644 --- a/src/main/java/com/laytonsmith/core/functions/FileHandling.java +++ b/src/main/java/com/laytonsmith/core/functions/FileHandling.java @@ -275,7 +275,7 @@ public Mixed exec(final Target t, final Environment environment, GenericParamete } final String encoding = _encoding; - if(!(args[1 + callbackIndex].isInstanceOf(CClosure.TYPE))) { + if(!(args[1 + callbackIndex].isInstanceOf(CClosure.TYPE, null, environment))) { throw new CRECastException("Expected parameter " + (2 + callbackIndex) + " of " + getName() + " to be a closure!", t); } else { callback = ((CClosure) args[1]); diff --git a/src/main/java/com/laytonsmith/core/functions/ItemMeta.java b/src/main/java/com/laytonsmith/core/functions/ItemMeta.java index 0af569a673..198020170e 100644 --- a/src/main/java/com/laytonsmith/core/functions/ItemMeta.java +++ b/src/main/java/com/laytonsmith/core/functions/ItemMeta.java @@ -363,14 +363,14 @@ public Mixed exec(Target t, Environment environment, GenericParameters generics, if(args.length == 3) { p = Static.GetPlayer(args[0], t); slot = ArgumentValidation.getInt32(args[1], t); - if(args[2].isInstanceOf(CArray.TYPE)) { + if(args[2].isInstanceOf(CArray.TYPE, null, environment)) { color = (CArray) args[2]; } else { throw new CREFormatException("Expected an array but received " + args[2] + " instead.", t); } } else { slot = ArgumentValidation.getInt32(args[0], t); - if(args[1].isInstanceOf(CArray.TYPE)) { + if(args[1].isInstanceOf(CArray.TYPE, null, environment)) { color = (CArray) args[1]; } else { throw new CREFormatException("Expected an array but received " + args[1] + " instead.", t); diff --git a/src/main/java/com/laytonsmith/core/functions/Marquee.java b/src/main/java/com/laytonsmith/core/functions/Marquee.java index f3397b5cfd..c43c8706ee 100644 --- a/src/main/java/com/laytonsmith/core/functions/Marquee.java +++ b/src/main/java/com/laytonsmith/core/functions/Marquee.java @@ -69,7 +69,7 @@ public Mixed exec(final Target t, Environment environment, GenericParameters gen text = args[1 + offset].val(); stringWidth = ArgumentValidation.getInt32(args[2 + offset], t); delayTime = ArgumentValidation.getInt32(args[3 + offset], t); - if(args[4 + offset].isInstanceOf(CClosure.TYPE)) { + if(args[4 + offset].isInstanceOf(CClosure.TYPE, null, environment)) { callback = ((CClosure) args[4 + offset]); } else { throw new CRECastException("Expected argument " + (4 + offset + 1) + " to be a closure, but was not.", t); diff --git a/src/main/java/com/laytonsmith/core/functions/Meta.java b/src/main/java/com/laytonsmith/core/functions/Meta.java index a23dec1b3c..5266590af2 100644 --- a/src/main/java/com/laytonsmith/core/functions/Meta.java +++ b/src/main/java/com/laytonsmith/core/functions/Meta.java @@ -157,7 +157,7 @@ public Mixed exec(Target t, final Environment env, GenericParameters generics, M throw new CREFormatException("The first character of the command must be a forward slash (i.e. '/give')", t); } String cmd = args[1].val().substring(1); - if(args[0].isInstanceOf(CArray.TYPE)) { + if(args[0].isInstanceOf(CArray.TYPE, null, env)) { CArray u = (CArray) args[0]; for(int i = 0; i < u.size(); i++) { exec(t, env, null, new Mixed[]{new CString(u.get(i, t).val(), t), args[1]}); @@ -1092,7 +1092,7 @@ public Boolean runAsync() { @Override public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { CString s; - if(args[0].isInstanceOf(CString.TYPE)) { + if(args[0].isInstanceOf(CString.TYPE, null, environment)) { s = (CString) args[0]; } else { s = new CString(args[0].val(), t); diff --git a/src/main/java/com/laytonsmith/core/functions/Minecraft.java b/src/main/java/com/laytonsmith/core/functions/Minecraft.java index cf3ceab481..a1e1728af7 100644 --- a/src/main/java/com/laytonsmith/core/functions/Minecraft.java +++ b/src/main/java/com/laytonsmith/core/functions/Minecraft.java @@ -97,7 +97,7 @@ public Integer[] numArgs() { @Override public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws CancelCommandException, ConfigRuntimeException { - if(args[0].isInstanceOf(CInt.TYPE)) { + if(args[0].isInstanceOf(CInt.TYPE, null, env)) { return new CInt(ArgumentValidation.getInt(args[0], t), t); } String c = args[0].val(); @@ -229,7 +229,7 @@ public Boolean runAsync() { public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { int i = -1; int i2 = -1; - if(args[0].isInstanceOf(CString.TYPE)) { + if(args[0].isInstanceOf(CString.TYPE, null, environment)) { //We also accept item notation if(args[0].val().contains(":")) { String[] split = args[0].val().split(":"); @@ -241,7 +241,7 @@ public Mixed exec(Target t, Environment environment, GenericParameters generics, throw new CREFormatException("Incorrect format for the item notation: " + args[0].val(), t); } } - } else if(args[0].isInstanceOf(CArray.TYPE)) { + } else if(args[0].isInstanceOf(CArray.TYPE, null, environment)) { MCItemStack is = ObjectGenerator.GetGenerator().item(args[0], t, true); return new CString(is.getType().getName(), t); } @@ -360,7 +360,7 @@ public Boolean runAsync() { @Override public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { Mixed id = args[0]; - if(id.isInstanceOf(CArray.TYPE)) { + if(id.isInstanceOf(CArray.TYPE, null, environment)) { MCItemStack is = ObjectGenerator.GetGenerator().item(id, t); return new CInt(is.maxStackSize(), t); } @@ -398,7 +398,7 @@ public ParseTree optimizeDynamic(Target t, Environment env, if(children.size() < 1) { return null; } - if(children.get(0).getData().isInstanceOf(CString.TYPE) && children.get(0).getData().val().contains(":") + if(children.get(0).getData().isInstanceOf(CString.TYPE, null, env) && children.get(0).getData().val().contains(":") || ArgumentValidation.isNumber(children.get(0).getData())) { env.getEnv(CompilerEnvironment.class).addCompilerWarning(fileOptions, new CompilerWarning("Numeric ids are deprecated in " + getName(), t, null)); @@ -551,7 +551,7 @@ public ParseTree optimizeDynamic(Target t, Environment env, return null; } Mixed effect = children.get(1).getData(); - if(effect.isInstanceOf(CString.TYPE)) { + if(effect.isInstanceOf(CString.TYPE, null, env)) { String effectName = effect.val().split(":")[0].toUpperCase(); try { MCEffect.valueOf(effectName); diff --git a/src/main/java/com/laytonsmith/core/functions/MobManagement.java b/src/main/java/com/laytonsmith/core/functions/MobManagement.java index 01598158a4..a6be12969c 100644 --- a/src/main/java/com/laytonsmith/core/functions/MobManagement.java +++ b/src/main/java/com/laytonsmith/core/functions/MobManagement.java @@ -634,7 +634,7 @@ public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed.. MCLivingEntity mob = Static.getLivingEntity(args[0], t); MCPotionEffectType type = null; - if(args[1].isInstanceOf(CString.TYPE)) { + if(args[1].isInstanceOf(CString.TYPE, null, env)) { try { type = MCPotionEffectType.valueOf(args[1].val().toUpperCase()); } catch (IllegalArgumentException ex) { @@ -821,7 +821,7 @@ public Mixed exec(Target t, Environment environment, GenericParameters generics, return CVoid.VOID; } Map eq = ee.getAllEquipment(); - if(args[1].isInstanceOf(CArray.TYPE)) { + if(args[1].isInstanceOf(CArray.TYPE, null, environment)) { CArray ea = (CArray) args[1]; for(String key : ea.stringKeySet()) { try { @@ -983,7 +983,7 @@ public Mixed exec(Target t, Environment environment, GenericParameters generics, for(Map.Entry ent : eq.entrySet()) { eq.put(ent.getKey(), 0F); } - } else if(args[1].isInstanceOf(CArray.TYPE)) { + } else if(args[1].isInstanceOf(CArray.TYPE, null, environment)) { CArray ea = (CArray) args[1]; for(String key : ea.stringKeySet()) { try { diff --git a/src/main/java/com/laytonsmith/core/functions/ResourceManager.java b/src/main/java/com/laytonsmith/core/functions/ResourceManager.java index ac740b4657..b2b7acdf7c 100644 --- a/src/main/java/com/laytonsmith/core/functions/ResourceManager.java +++ b/src/main/java/com/laytonsmith/core/functions/ResourceManager.java @@ -211,7 +211,7 @@ public Boolean runAsync() { @Override public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { - if(args[0].isInstanceOf(CResource.TYPE)) { + if(args[0].isInstanceOf(CResource.TYPE, null, environment)) { CResource resource = (CResource) args[0]; if(RESOURCES.containsKey(resource.getId())) { RESOURCES.remove(resource.getId()); diff --git a/src/main/java/com/laytonsmith/core/functions/SQL.java b/src/main/java/com/laytonsmith/core/functions/SQL.java index 12fbc24942..289a064382 100644 --- a/src/main/java/com/laytonsmith/core/functions/SQL.java +++ b/src/main/java/com/laytonsmith/core/functions/SQL.java @@ -154,7 +154,7 @@ public void run() { public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { try { Profiles.Profile profile; - if(args[0].isInstanceOf(CArray.TYPE)) { + if(args[0].isInstanceOf(CArray.TYPE, null, environment)) { Map data = new HashMap<>(); for(String key : ((CArray) args[0]).stringKeySet()) { data.put(key, ((CArray) args[0]).get(key, t).val()); @@ -201,19 +201,19 @@ public Mixed exec(Target t, Environment environment, GenericParameters generics, continue; } try { - if(params[i].isInstanceOf(CInt.TYPE)) { + if(params[i].isInstanceOf(CInt.TYPE, null, environment)) { ps.setLong(i + 1, ArgumentValidation.getInt(params[i], t)); - } else if(params[i].isInstanceOf(CDouble.TYPE)) { + } else if(params[i].isInstanceOf(CDouble.TYPE, null, environment)) { ps.setDouble(i + 1, (Double) ArgumentValidation.getDouble(params[i], t)); - } else if(params[i].isInstanceOf(CString.TYPE)) { + } else if(params[i].isInstanceOf(CString.TYPE, null, environment)) { if(type == Types.NCHAR || type == Types.NVARCHAR || type == Types.LONGNVARCHAR) { ps.setNString(i + 1, (String) params[i].val()); } else { ps.setString(i + 1, (String) params[i].val()); } - } else if(params[i].isInstanceOf(CByteArray.TYPE)) { + } else if(params[i].isInstanceOf(CByteArray.TYPE, null, environment)) { ps.setBytes(i + 1, ((CByteArray) params[i]).asByteArrayCopy()); - } else if(params[i].isInstanceOf(CBoolean.TYPE)) { + } else if(params[i].isInstanceOf(CBoolean.TYPE, null, environment)) { ps.setBoolean(i + 1, ArgumentValidation.getBoolean(params[i], t)); } else { throw new CRECastException("The type " + params[i].getClass().getSimpleName() @@ -347,7 +347,7 @@ public ParseTree optimizeDynamic(Target t, Environment env, env.getEnv(CompilerEnvironment.class).addCompilerWarning(fileOptions, new CompilerWarning(msg, t, null)); } - } else if(queryData.isInstanceOf(CString.TYPE)) { + } else if(queryData.isInstanceOf(CString.TYPE, null, env)) { //It's a hard coded query, so we can double check parameter lengths and other things String query = queryData.val(); int count = 0; @@ -499,7 +499,7 @@ public Boolean runAsync() { public Mixed exec(final Target t, final Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { startup(); Mixed arg = args[args.length - 1]; - if(!(arg.isInstanceOf(CClosure.TYPE))) { + if(!(arg.isInstanceOf(CClosure.TYPE, null, environment))) { throw new CRECastException("The last argument to " + getName() + " must be a closure.", t); } final CClosure closure = ((CClosure) arg); diff --git a/src/main/java/com/laytonsmith/core/functions/Sandbox.java b/src/main/java/com/laytonsmith/core/functions/Sandbox.java index 1d5664ef5a..ca18488a2b 100644 --- a/src/main/java/com/laytonsmith/core/functions/Sandbox.java +++ b/src/main/java/com/laytonsmith/core/functions/Sandbox.java @@ -497,7 +497,7 @@ public Mixed exec(Target t, Environment environment, GenericParameters generics, } byte[] content; - if(!(args[1].isInstanceOf(CByteArray.TYPE))) { + if(!(args[1].isInstanceOf(CByteArray.TYPE, null, environment))) { content = args[1].val().getBytes(Charset.forName("UTF-8")); } else { content = ArgumentValidation.getByteArray(args[1], t).asByteArrayCopy(); diff --git a/src/main/java/com/laytonsmith/core/functions/Scheduling.java b/src/main/java/com/laytonsmith/core/functions/Scheduling.java index 8f50b54b50..7280fd1804 100644 --- a/src/main/java/com/laytonsmith/core/functions/Scheduling.java +++ b/src/main/java/com/laytonsmith/core/functions/Scheduling.java @@ -292,7 +292,7 @@ public Mixed exec(final Target t, final Environment environment, GenericParamete if(time < 0) { throw new CRERangeException("Negative repeating delay", t); } - if(!(args[1 + offset].isInstanceOf(Callable.TYPE))) { + if(!(args[1 + offset].isInstanceOf(Callable.TYPE, null, environment))) { throw new CRECastException(getName() + " expects a Callable to be sent as the second argument", t); } final Callable c = (Callable) args[1 + offset]; @@ -390,7 +390,7 @@ public Mixed exec(final Target t, final Environment environment, GenericParamete if(time < 0) { throw new CRERangeException("Negative delay", t); } - if(!(args[1].isInstanceOf(Callable.TYPE))) { + if(!(args[1].isInstanceOf(Callable.TYPE, null, environment))) { throw new CRECastException(getName() + " expects a Callable to be sent as the second argument", t); } final Callable c = (Callable) args[1]; @@ -855,10 +855,10 @@ public Boolean runAsync() { @Override public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { //First things first, check the format of the arguments. - if(!(args[0].isInstanceOf(CString.TYPE))) { + if(!(args[0].isInstanceOf(CString.TYPE, null, environment))) { throw new CRECastException("Expected string for argument 1 in " + getName(), t); } - if(!(args[1].isInstanceOf(CClosure.TYPE))) { + if(!(args[1].isInstanceOf(CClosure.TYPE, null, environment))) { throw new CRECastException("Expected closure for argument 2 in " + getName(), t); } CronFormat format = validateFormat(args[0].val(), t); @@ -1177,7 +1177,7 @@ public ParseTree optimizeDynamic(Target t, Environment env, List children, FileOptions fileOptions) throws ConfigCompileException, ConfigRuntimeException { if(children.get(0).isConst()) { - if(children.get(0).getData().isInstanceOf(CString.TYPE)) { + if(children.get(0).getData().isInstanceOf(CString.TYPE, null, env)) { validateFormat(children.get(0).getData().val(), t); } } diff --git a/src/main/java/com/laytonsmith/core/functions/Scoreboards.java b/src/main/java/com/laytonsmith/core/functions/Scoreboards.java index 17b9dd9202..7dee7634f1 100644 --- a/src/main/java/com/laytonsmith/core/functions/Scoreboards.java +++ b/src/main/java/com/laytonsmith/core/functions/Scoreboards.java @@ -619,7 +619,7 @@ public Mixed exec(Target t, Environment environment, GenericParameters generics, throw new CREScoreboardException("No objective by that name exists.", t); } CArray dis = CArray.GetAssociativeArray(t); - if(args[1].isInstanceOf(CArray.TYPE)) { + if(args[1].isInstanceOf(CArray.TYPE, null, environment)) { dis = (CArray) args[1]; } else { dis.set("displayname", args[1], t); @@ -700,7 +700,7 @@ public Mixed exec(Target t, Environment environment, GenericParameters generics, throw new CREScoreboardException("No team by that name exists.", t); } CArray dis = CArray.GetAssociativeArray(t); - if(args[1].isInstanceOf(CArray.TYPE)) { + if(args[1].isInstanceOf(CArray.TYPE, null, environment)) { dis = (CArray) args[1]; } else { dis.set("displayname", args[1], t); @@ -1170,7 +1170,7 @@ public Mixed exec(Target t, Environment environment, GenericParameters generics, if(team == null) { throw new CREScoreboardException("No team by that name exists.", t); } - if(args[1].isInstanceOf(CArray.TYPE)) { + if(args[1].isInstanceOf(CArray.TYPE, null, environment)) { CArray options = (CArray) args[1]; if(options.containsKey("friendlyfire")) { team.setAllowFriendlyFire(ArgumentValidation.getBoolean(options.get("friendlyfire", t), t)); diff --git a/src/main/java/com/laytonsmith/core/functions/Statistics.java b/src/main/java/com/laytonsmith/core/functions/Statistics.java index dc42d9c05d..6410790313 100644 --- a/src/main/java/com/laytonsmith/core/functions/Statistics.java +++ b/src/main/java/com/laytonsmith/core/functions/Statistics.java @@ -70,7 +70,7 @@ public static class average extends StatisticsFunction { @Override public CNumber exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { long count; - if(args.length == 1 && args[0].isInstanceOf(CArray.TYPE)) { + if(args.length == 1 && args[0].isInstanceOf(CArray.TYPE, null, environment)) { CArray c = ArgumentValidation.getArray(args[0], t); count = c.size(); } else { @@ -120,7 +120,7 @@ public static class sum extends StatisticsFunction { @Override public CNumber exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { List values = new ArrayList<>(); - if(args.length == 1 && args[0].isInstanceOf(CArray.TYPE)) { + if(args.length == 1 && args[0].isInstanceOf(CArray.TYPE, null, environment)) { CArray c = ArgumentValidation.getArray(args[0], t); for(Mixed m : c.asList()) { values.add(ArgumentValidation.getDouble(m, t)); @@ -176,7 +176,7 @@ public static class median extends StatisticsFunction { @Override public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { List values = new ArrayList<>(); - if(args.length == 1 && args[0].isInstanceOf(CArray.TYPE)) { + if(args.length == 1 && args[0].isInstanceOf(CArray.TYPE, null, environment)) { CArray c = ArgumentValidation.getArray(args[0], t); for(Mixed m : c.asList()) { values.add(ArgumentValidation.getDouble(m, t)); @@ -240,7 +240,7 @@ public static class mode extends StatisticsFunction { @Override public CArray exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { List values = new ArrayList<>(); - if(args.length == 1 && args[0].isInstanceOf(CArray.TYPE)) { + if(args.length == 1 && args[0].isInstanceOf(CArray.TYPE, null, environment)) { CArray c = ArgumentValidation.getArray(args[0], t); for(Mixed m : c.asList()) { values.add(ArgumentValidation.getDouble(m, t)); @@ -340,7 +340,7 @@ public Class[] thrown() { public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { double percentile = ArgumentValidation.getDouble(args[0], t); List values = new ArrayList<>(); - if(args.length == 2 && args[1].isInstanceOf(CArray.TYPE)) { + if(args.length == 2 && args[1].isInstanceOf(CArray.TYPE, null, environment)) { CArray c = ArgumentValidation.getArray(args[1], t); for(Mixed m : c.asList()) { values.add(ArgumentValidation.getNumber(m, t)); diff --git a/src/main/java/com/laytonsmith/core/functions/Weather.java b/src/main/java/com/laytonsmith/core/functions/Weather.java index 42f484f6be..8af2683dda 100644 --- a/src/main/java/com/laytonsmith/core/functions/Weather.java +++ b/src/main/java/com/laytonsmith/core/functions/Weather.java @@ -68,7 +68,7 @@ public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed.. MCWorld w = null; boolean safe = false; int safeIndex = 1; - if(args[0].isInstanceOf(CArray.TYPE)) { + if(args[0].isInstanceOf(CArray.TYPE, null, env)) { CArray a = (CArray) args[0]; MCPlayer p = env.getEnv(CommandHelperEnvironment.class).GetPlayer(); MCLocation l = ObjectGenerator.GetGenerator().location(a, p == null ? null : p.getWorld(), t); @@ -142,9 +142,9 @@ public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed.. MCWorld w = null; int duration = -1; if(args.length == 2) { - if(args[1].isInstanceOf(CString.TYPE)) { + if(args[1].isInstanceOf(CString.TYPE, null, env)) { w = Static.getServer().getWorld(args[1].val()); - } else if(args[1].isInstanceOf(CInt.TYPE)) { + } else if(args[1].isInstanceOf(CInt.TYPE, null, env)) { duration = ArgumentValidation.getInt32(args[1], t); } else { throw new CREFormatException("", t); diff --git a/src/main/java/com/laytonsmith/core/functions/Web.java b/src/main/java/com/laytonsmith/core/functions/Web.java index 1aa175d507..8f6439f38a 100644 --- a/src/main/java/com/laytonsmith/core/functions/Web.java +++ b/src/main/java/com/laytonsmith/core/functions/Web.java @@ -233,7 +233,7 @@ public Mixed exec(final Target t, final Environment environment, GenericParamete final boolean binary; final String textEncoding; boolean useDefaultHeaders = true; - if(args[1].isInstanceOf(CClosure.TYPE)) { + if(args[1].isInstanceOf(CClosure.TYPE, null, environment)) { success = (CClosure) args[1]; error = null; arrayJar = null; @@ -262,7 +262,7 @@ public Mixed exec(final Target t, final Environment environment, GenericParamete for(String key : headers.stringKeySet()) { List h = new ArrayList(); Mixed c = headers.get(key, t); - if(c.isInstanceOf(CArray.TYPE)) { + if(c.isInstanceOf(CArray.TYPE, null, environment)) { for(String kkey : ((CArray) c).stringKeySet()) { h.add(((CArray) c).get(kkey, t).val()); } @@ -289,13 +289,13 @@ public Mixed exec(final Target t, final Environment environment, GenericParamete } } if(csettings.containsKey("params") && !(csettings.get("params", t) instanceof CNull)) { - if(csettings.get("params", t).isInstanceOf(CArray.TYPE)) { + if(csettings.get("params", t).isInstanceOf(CArray.TYPE, null, environment)) { CArray params = ArgumentValidation.getArray(csettings.get("params", t), t); Map> mparams = new HashMap<>(); for(String key : params.stringKeySet()) { Mixed c = params.get(key, t); List l = new ArrayList<>(); - if(c.isInstanceOf(CArray.TYPE)) { + if(c.isInstanceOf(CArray.TYPE, null, environment)) { for(String kkey : ((CArray) c).stringKeySet()) { l.add(((ArrayAccess) c).get(kkey, t).val()); } @@ -306,7 +306,7 @@ public Mixed exec(final Target t, final Environment environment, GenericParamete } settings.setComplexParameters(mparams); } else { - if(csettings.get("params", t).isInstanceOf(CByteArray.TYPE)) { + if(csettings.get("params", t).isInstanceOf(CByteArray.TYPE, null, environment)) { CByteArray b = (CByteArray) csettings.get("params", t); settings.setRawParameter(b.asByteArrayCopy()); } else { @@ -329,7 +329,7 @@ public Mixed exec(final Target t, final Environment environment, GenericParamete } //Only required parameter if(csettings.containsKey("success")) { - if(csettings.get("success", t).isInstanceOf(CClosure.TYPE)) { + if(csettings.get("success", t).isInstanceOf(CClosure.TYPE, null, environment)) { success = (CClosure) csettings.get("success", t); } else { throw new CRECastException("Expecting the success parameter to be a closure.", t); @@ -338,7 +338,7 @@ public Mixed exec(final Target t, final Environment environment, GenericParamete throw new CRECastException("Missing the success parameter, which is required.", t); } if(csettings.containsKey("error")) { - if(csettings.get("error", t).isInstanceOf(CClosure.TYPE)) { + if(csettings.get("error", t).isInstanceOf(CClosure.TYPE, null, environment)) { error = (CClosure) csettings.get("error", t); } else { throw new CRECastException("Expecting the error parameter to be a closure.", t); @@ -375,9 +375,9 @@ public Mixed exec(final Target t, final Environment environment, GenericParamete } if(csettings.containsKey("trustStore")) { Mixed trustStore = csettings.get("trustStore", t); - if(trustStore.isInstanceOf(CBoolean.TYPE) && ArgumentValidation.getBoolean(trustStore, t) == false) { + if(trustStore.isInstanceOf(CBoolean.TYPE, null, environment) && ArgumentValidation.getBoolean(trustStore, t) == false) { settings.setDisableCertChecking(true); - } else if(trustStore.isInstanceOf(CArray.TYPE)) { + } else if(trustStore.isInstanceOf(CArray.TYPE, null, environment)) { CArray trustStoreA = ((CArray) trustStore); LinkedHashMap trustStoreJ = new LinkedHashMap<>((int) trustStoreA.size()); final String noDefault = "no default"; @@ -847,7 +847,7 @@ public Mixed exec(Target t, Environment environment, GenericParameters generics, String body = ArgumentValidation.getItemFromArray(options, "body", t, new CString("", t)).val(); Mixed cto = ArgumentValidation.getItemFromArray(options, "to", t, null); CArray to; - if(cto.isInstanceOf(CString.TYPE)) { + if(cto.isInstanceOf(CString.TYPE, null, environment)) { to = new CArray(t); to.push(cto, t); } else { @@ -903,7 +903,7 @@ protected PasswordAuthentication getPasswordAuthentication() { for(Mixed c : to.asList()) { Message.RecipientType type = Message.RecipientType.TO; String address; - if(c.isInstanceOf(CArray.TYPE)) { + if(c.isInstanceOf(CArray.TYPE, null, environment)) { CArray ca = (CArray) c; String stype = ArgumentValidation.getItemFromArray(ca, "type", t, new CString("TO", t)).val(); switch(stype) { diff --git a/src/main/java/com/laytonsmith/core/functions/World.java b/src/main/java/com/laytonsmith/core/functions/World.java index 2a52f73c86..10c2340653 100644 --- a/src/main/java/com/laytonsmith/core/functions/World.java +++ b/src/main/java/com/laytonsmith/core/functions/World.java @@ -274,7 +274,7 @@ public Mixed exec(Target t, Environment environment, GenericParameters generics, z = l.getBlockZ(); } else if(args.length == 2) { //Either location array and world provided, or x and z. Test for array at pos 2 - if(args[1].isInstanceOf(CArray.TYPE)) { + if(args[1].isInstanceOf(CArray.TYPE, null, environment)) { world = Static.getServer().getWorld(args[0].val()); MCLocation l = ObjectGenerator.GetGenerator().location(args[1], null, t); x = l.getBlockX(); @@ -333,7 +333,7 @@ public Mixed exec(Target t, Environment environment, GenericParameters generics, z = l.getBlockZ(); } else if(args.length == 2) { //Either location array and world provided, or x and z. Test for array at pos 2 - if(args[1].isInstanceOf(CArray.TYPE)) { + if(args[1].isInstanceOf(CArray.TYPE, null, environment)) { world = Static.getServer().getWorld(args[0].val()); if(world == null) { throw new CREInvalidWorldException("The given world (" + args[0].val() + ") does not exist.", t); @@ -416,7 +416,7 @@ public Mixed exec(Target t, Environment environment, GenericParameters generics, z = l.getBlockZ(); } else if(args.length == 2) { //Either location array and world provided, or x and z. Test for array at pos 2 - if(args[1].isInstanceOf(CArray.TYPE)) { + if(args[1].isInstanceOf(CArray.TYPE, null, environment)) { world = Static.getServer().getWorld(args[0].val()); MCLocation l = ObjectGenerator.GetGenerator().location(args[1], null, t); x = l.getBlockX(); @@ -735,7 +735,7 @@ public Mixed exec(Target t, Environment environment, GenericParameters generics, z = l.getBlockZ() >> 4; } else if(args.length == 2) { //Either location array and world provided, or x and z. Test for array at pos 1 - if(args[0].isInstanceOf(CArray.TYPE)) { + if(args[0].isInstanceOf(CArray.TYPE, null, environment)) { world = Static.getServer().getWorld(args[1].val()); if(world == null) { throw new CREInvalidWorldException("World " + args[1].val() + " does not exist.", t); @@ -826,7 +826,7 @@ public Mixed exec(Target t, Environment environment, GenericParameters generics, z = l.getBlockZ() >> 4; } else if(args.length == 2) { //Either location array and world provided, or x and z. Test for array at pos 1 - if(args[0].isInstanceOf(CArray.TYPE)) { + if(args[0].isInstanceOf(CArray.TYPE, null, environment)) { world = Static.getServer().getWorld(args[1].val()); if(world == null) { throw new CREInvalidWorldException("The given world (" + args[1].val() + ") does not exist.", t); @@ -1188,8 +1188,8 @@ public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed.. creator.type(type).environment(environment); } if((args.length >= 4) && !(args[3] instanceof CNull)) { - if(args[3].isInstanceOf(CInt.TYPE)) { - creator.seed(ArgumentValidation.getInt(args[3], t)); + if(args[3].isInstanceOf(CInt.TYPE, null, env)) { + creator.seed(ArgumentValidation.getInt(args[3], t, env)); } else { creator.seed(args[3].val().hashCode()); } @@ -1310,7 +1310,7 @@ public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed.. } if(args.length == 1) { - if(args[0].isInstanceOf(CArray.TYPE)) { + if(args[0].isInstanceOf(CArray.TYPE, null, env)) { l = ObjectGenerator.GetGenerator().location(args[0], w, t); } else { throw new CREFormatException("Expecting argument 1 of get_chunk_loc to be a location array", t); @@ -2079,7 +2079,7 @@ public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed.. clamp = ArgumentValidation.getBooleanish(args[3], t); } Vector3D vector; - if(args[1].isInstanceOf(CArray.TYPE)) { + if(args[1].isInstanceOf(CArray.TYPE, null, env)) { MCLocation to = ObjectGenerator.GetGenerator().location(args[1], loc.getWorld(), t); if(clamp) { // Need to check if the shift would go beyond the target, if so, just return the final @@ -2540,7 +2540,7 @@ public Mixed exec(Target t, Environment environment, GenericParameters generics, } MCWorldBorder wb = w.getWorldBorder(); Mixed c = args[1]; - if(!(c.isInstanceOf(CArray.TYPE))) { + if(!(c.isInstanceOf(CArray.TYPE, null, environment))) { throw new CREFormatException("Expected array but given \"" + args[1].val() + "\"", t); } CArray params = (CArray) c; diff --git a/src/main/java/com/laytonsmith/tools/langserv/LangServModel.java b/src/main/java/com/laytonsmith/tools/langserv/LangServModel.java index e41e5daa2a..26b7a24342 100644 --- a/src/main/java/com/laytonsmith/tools/langserv/LangServModel.java +++ b/src/main/java/com/laytonsmith/tools/langserv/LangServModel.java @@ -500,7 +500,7 @@ public void startup() { for(FullyQualifiedClassName fqcn : NativeTypeList.getNativeTypeList()) { try { Mixed m = NativeTypeList.getInvalidInstanceForUse(fqcn); - CompletionItem ci = new CompletionItem(m.typeof().getSimpleName()); + CompletionItem ci = new CompletionItem(m.typeof(null).getSimpleName()); ci.setKind(CompletionItemKind.TypeParameter); ci.setDetail(m.getName()); ci.setDocumentation(m.docs()); diff --git a/src/test/java/com/laytonsmith/core/constructs/CFixedArrayTest.java b/src/test/java/com/laytonsmith/core/constructs/CFixedArrayTest.java index 0432151cfe..c217b9a26e 100644 --- a/src/test/java/com/laytonsmith/core/constructs/CFixedArrayTest.java +++ b/src/test/java/com/laytonsmith/core/constructs/CFixedArrayTest.java @@ -34,7 +34,7 @@ public void testBasic1() { assertEquals(10, fa.size()); assertEquals(false, fa.canBeAssociative()); assertEquals(CNull.NULL, fa.get(0, Target.UNKNOWN)); - fa.set(0, new CInt(10, Target.UNKNOWN), Target.UNKNOWN); + fa.set(0, new CInt(10, Target.UNKNOWN), Target.UNKNOWN, null); assertEquals(10, ((CInt) fa.get(0, Target.UNKNOWN)).val); } } From 09cf9d1aaee28585e73095097d5a5be3e89c2bba Mon Sep 17 00:00:00 2001 From: LadyCailin Date: Mon, 23 Feb 2026 12:10:47 +0100 Subject: [PATCH 05/28] Fix more deprecation warnings --- deprecation.txt | 0 .../laytonsmith/abstraction/MCCommand.java | 3 +- .../abstraction/bukkit/BukkitMCCommand.java | 7 +- .../abstraction/enums/MCTagType.java | 24 +- .../commandhelper/CommandHelperPlugin.java | 3 +- .../laytonsmith/core/ArgumentValidation.java | 8 +- .../core/FullyQualifiedClassName.java | 2 +- .../com/laytonsmith/core/ObjectGenerator.java | 222 +++++--- .../java/com/laytonsmith/core/ParseTree.java | 2 +- .../java/com/laytonsmith/core/Script.java | 2 +- .../java/com/laytonsmith/core/Static.java | 93 +++- .../laytonsmith/core/asm/LLVMFunction.java | 2 +- .../core/compiler/OptimizationUtilities.java | 10 +- .../compiler/analysis/StaticAnalysis.java | 2 +- .../laytonsmith/core/constructs/CArray.java | 10 +- .../laytonsmith/core/constructs/CClosure.java | 10 +- .../core/constructs/CMutablePrimitive.java | 11 +- .../core/constructs/Construct.java | 87 ++-- .../core/constructs/IVariable.java | 4 +- .../com/laytonsmith/core/events/Event.java | 69 ++- .../laytonsmith/core/events/EventUtils.java | 2 +- .../core/events/drivers/BlockEvents.java | 100 ++-- .../core/events/drivers/CmdlineEvents.java | 12 +- .../core/events/drivers/EntityEvents.java | 132 ++--- .../core/events/drivers/InventoryEvents.java | 63 +-- .../core/events/drivers/PlayerEvents.java | 130 ++--- .../core/events/drivers/PluginEvents.java | 5 +- .../core/events/drivers/ServerEvents.java | 22 +- .../core/events/drivers/VehicleEvents.java | 22 +- .../core/events/drivers/WeatherEvents.java | 12 +- .../core/events/drivers/WorldEvents.java | 15 +- .../exceptions/CRE/AbstractCREException.java | 4 +- .../core/functions/AbstractFunction.java | 8 +- .../core/functions/ArrayHandling.java | 482 +++++++++--------- .../core/functions/BasicLogic.java | 6 +- .../core/functions/BukkitMetadata.java | 12 +- .../laytonsmith/core/functions/Compiler.java | 12 +- .../laytonsmith/core/functions/Crypto.java | 22 +- .../core/functions/DataHandling.java | 65 ++- .../core/functions/DataTransformations.java | 2 +- .../core/functions/Enchantments.java | 6 +- .../core/functions/EntityManagement.java | 68 +-- .../core/functions/Environment.java | 42 +- .../core/functions/EventBinding.java | 2 +- .../laytonsmith/core/functions/Function.java | 34 +- .../core/functions/InventoryManagement.java | 86 ++-- .../com/laytonsmith/core/functions/Math.java | 32 +- .../core/functions/ObjectManagement.java | 14 +- .../core/functions/Persistence.java | 2 +- .../core/functions/PlayerManagement.java | 38 +- .../com/laytonsmith/core/functions/Regex.java | 24 +- .../com/laytonsmith/core/functions/SQL.java | 4 +- .../laytonsmith/core/functions/Sandbox.java | 2 +- .../core/functions/StringHandling.java | 18 +- .../laytonsmith/core/functions/Threading.java | 8 +- .../com/laytonsmith/core/functions/Web.java | 14 +- .../natives/interfaces/AbstractMixed.java | 2 +- .../AbstractMixedInterfaceRunner.java | 2 +- .../core/natives/interfaces/MEnumType.java | 2 +- .../laytonsmith/core/objects/UserObject.java | 2 +- .../java/com/laytonsmith/tools/Manager.java | 2 +- 61 files changed, 1154 insertions(+), 949 deletions(-) create mode 100644 deprecation.txt diff --git a/deprecation.txt b/deprecation.txt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/src/main/java/com/laytonsmith/abstraction/MCCommand.java b/src/main/java/com/laytonsmith/abstraction/MCCommand.java index 13caa3d422..e998581e18 100644 --- a/src/main/java/com/laytonsmith/abstraction/MCCommand.java +++ b/src/main/java/com/laytonsmith/abstraction/MCCommand.java @@ -1,5 +1,6 @@ package com.laytonsmith.abstraction; +import com.laytonsmith.core.environments.Environment; import java.util.List; public interface MCCommand extends AbstractionObject { @@ -52,7 +53,7 @@ public interface MCCommand extends AbstractionObject { List tabComplete(MCCommandSender sender, String alias, String[] args); - List handleTabComplete(MCCommandSender sender, String alias, String[] args); + List handleTabComplete(MCCommandSender sender, String alias, String[] args, Environment env); boolean handleCustomCommand(MCCommandSender sender, String label, String[] args); } diff --git a/src/main/java/com/laytonsmith/abstraction/bukkit/BukkitMCCommand.java b/src/main/java/com/laytonsmith/abstraction/bukkit/BukkitMCCommand.java index 9ce6045e67..a320515791 100644 --- a/src/main/java/com/laytonsmith/abstraction/bukkit/BukkitMCCommand.java +++ b/src/main/java/com/laytonsmith/abstraction/bukkit/BukkitMCCommand.java @@ -13,6 +13,7 @@ import com.laytonsmith.core.constructs.CString; import com.laytonsmith.core.constructs.Target; import com.laytonsmith.core.environments.CommandHelperEnvironment; +import com.laytonsmith.core.environments.Environment; import com.laytonsmith.core.events.Driver; import com.laytonsmith.core.events.EventUtils; import com.laytonsmith.core.exceptions.CRE.CREPluginInternalException; @@ -208,7 +209,7 @@ public String toString() { } @Override - public List handleTabComplete(MCCommandSender sender, String alias, String[] args) { + public List handleTabComplete(MCCommandSender sender, String alias, String[] args, Environment env) { if(Commands.onTabComplete.containsKey(cmd.getName().toLowerCase())) { Target t = Target.UNKNOWN; CArray cargs = new CArray(t); @@ -221,7 +222,7 @@ public List handleTabComplete(MCCommandSender sender, String alias, Stri Mixed fret = closure.executeCallable(null, t, new CString(alias, t), new CString(sender.getName(), t), cargs, new CArray(t) // reserved for an obgen style command array ); - if(fret.isInstanceOf(CArray.TYPE)) { + if(fret.isInstanceOf(CArray.TYPE, null, env)) { List ret = new ArrayList<>(); if(((CArray) fret).inAssociativeMode()) { for(Mixed key : ((CArray) fret).keySet()) { @@ -262,7 +263,7 @@ public boolean handleCustomCommand(MCCommandSender sender, String label, String[ Mixed fret = closure.executeCallable(null, t, new CString(label, t), new CString(sender.getName(), t), cargs, new CArray(t) // reserved for an obgen style command array ); - if(fret.isInstanceOf(CBoolean.TYPE)) { + if(fret instanceof CBoolean) { return ((CBoolean) fret).getBoolean(); } } catch (ConfigRuntimeException cre) { diff --git a/src/main/java/com/laytonsmith/abstraction/enums/MCTagType.java b/src/main/java/com/laytonsmith/abstraction/enums/MCTagType.java index 6d27e95ff6..3109fc237a 100644 --- a/src/main/java/com/laytonsmith/abstraction/enums/MCTagType.java +++ b/src/main/java/com/laytonsmith/abstraction/enums/MCTagType.java @@ -9,6 +9,7 @@ import com.laytonsmith.core.constructs.CInt; import com.laytonsmith.core.constructs.CString; import com.laytonsmith.core.constructs.Target; +import com.laytonsmith.core.environments.Environment; import com.laytonsmith.core.exceptions.CRE.CRECastException; import com.laytonsmith.core.exceptions.CRE.CREFormatException; import com.laytonsmith.core.natives.interfaces.Mixed; @@ -123,16 +124,23 @@ MCTagType(Function conversion, Function constru this.construction = construction; } + /** @deprecated Use {@link #convert(MCTagContainer, Mixed, Environment)} instead. */ + @Deprecated + public Object convert(MCTagContainer container, Mixed value) { + return convert(container, value, null); + } + /** * Returns a Java object from a MethodScript construct. * Throws a ConfigRuntimeException if the value is not valid for this tag type. * @param container the tag container context * @param value MethodScript construct + * @param env * @return a Java object */ - public Object convert(MCTagContainer container, Mixed value) { + public Object convert(MCTagContainer container, Mixed value, Environment env) { if(this == TAG_CONTAINER) { - if(!value.isInstanceOf(CArray.TYPE)) { + if(!value.isInstanceOf(CArray.TYPE, null, env)) { throw new CREFormatException("Expected tag container to be an array.", value.getTarget()); } CArray containerArray = (CArray) value; @@ -141,7 +149,7 @@ public Object convert(MCTagContainer container, Mixed value) { } for(String key : containerArray.stringKeySet()) { Mixed possibleArray = containerArray.get(key, value.getTarget()); - if(!possibleArray.isInstanceOf(CArray.TYPE)) { + if(!possibleArray.isInstanceOf(CArray.TYPE, null, env)) { throw new CREFormatException("Expected tag entry to be an array.", possibleArray.getTarget()); } CArray entryArray = (CArray) possibleArray; @@ -158,11 +166,11 @@ public Object convert(MCTagContainer container, Mixed value) { } Object tagValue; if(tagType == MCTagType.TAG_CONTAINER) { - tagValue = tagType.convert(container.newContainer(), entryValue); + tagValue = tagType.convert(container.newContainer(), entryValue, env); } else if(tagType == TAG_CONTAINER_ARRAY) { - tagValue = tagType.convert(container, entryValue); + tagValue = tagType.convert(container, entryValue, env); } else { - tagValue = tagType.convert(container, entryValue); + tagValue = tagType.convert(container, entryValue, env); } try { container.set(StaticLayer.GetConvertor().GetNamespacedKey(key), tagType, tagValue); @@ -174,7 +182,7 @@ public Object convert(MCTagContainer container, Mixed value) { } return container; } else if(this == TAG_CONTAINER_ARRAY) { - if(!value.isInstanceOf(CArray.TYPE)) { + if(!value.isInstanceOf(CArray.TYPE, null, env)) { throw new CREFormatException("Expected tag container to be an array.", value.getTarget()); } CArray array = (CArray) value; @@ -184,7 +192,7 @@ public Object convert(MCTagContainer container, Mixed value) { MCTagContainer[] containers = new MCTagContainer[(int) array.size()]; int i = 0; for(Mixed possibleContainer : array) { - containers[i++] = (MCTagContainer) TAG_CONTAINER.convert(container.newContainer(), possibleContainer); + containers[i++] = (MCTagContainer) TAG_CONTAINER.convert(container.newContainer(), possibleContainer, env); } return containers; } diff --git a/src/main/java/com/laytonsmith/commandhelper/CommandHelperPlugin.java b/src/main/java/com/laytonsmith/commandhelper/CommandHelperPlugin.java index 176ca46fee..f82f7e1202 100644 --- a/src/main/java/com/laytonsmith/commandhelper/CommandHelperPlugin.java +++ b/src/main/java/com/laytonsmith/commandhelper/CommandHelperPlugin.java @@ -536,7 +536,8 @@ public void registerEventsDynamic(Listener listener) { public List onTabComplete(CommandSender sender, Command command, String alias, String[] args) { MCCommandSender mcsender = BukkitConvertor.BukkitGetCorrectSender(sender); MCCommand cmd = new BukkitMCCommand(command); - return cmd.handleTabComplete(mcsender, alias, args); + // TODO: Figure out how to get an env here + return cmd.handleTabComplete(mcsender, alias, args, null); } /** diff --git a/src/main/java/com/laytonsmith/core/ArgumentValidation.java b/src/main/java/com/laytonsmith/core/ArgumentValidation.java index 651f9f15fc..d00967cad2 100644 --- a/src/main/java/com/laytonsmith/core/ArgumentValidation.java +++ b/src/main/java/com/laytonsmith/core/ArgumentValidation.java @@ -91,7 +91,7 @@ public static CArray getArray(Mixed construct, Target t) { * @return */ public static CArray getArray(Mixed construct, Target t, Environment env) { - if(construct.isInstanceOf(CArray.TYPE)) { + if(construct.isInstanceOf(CArray.TYPE, null, env)) { return ((CArray) construct); } else { throw new CRECastException("Expecting array, but received " + construct.val(), t); @@ -294,9 +294,9 @@ public static long getInt(Mixed c, Target t, Environment env) { if(c == null || c instanceof CNull) { return 0; } - if(c.isInstanceOf(CInt.TYPE)) { + if(c.isInstanceOf(CInt.TYPE, null, env)) { i = getObject(c, t, CInt.class).getInt(); - } else if(c.isInstanceOf(CBoolean.TYPE)) { + } else if(c instanceof CBoolean) { if(getObject(c, t, CBoolean.class).getBoolean()) { i = 1; } else { @@ -717,7 +717,7 @@ public static > Set getEnumSet(Mixed c, Class enumClass, if(c instanceof CNull) { return EnumSet.noneOf(enumClass); } - if(!c.isInstanceOf(CArray.TYPE)) { + if(!c.isInstanceOf(CArray.TYPE, null, env)) { Mixed val = c; c = new CArray(t); ((CArray) c).push(val, t); diff --git a/src/main/java/com/laytonsmith/core/FullyQualifiedClassName.java b/src/main/java/com/laytonsmith/core/FullyQualifiedClassName.java index b66f6918c6..3a891d56ea 100644 --- a/src/main/java/com/laytonsmith/core/FullyQualifiedClassName.java +++ b/src/main/java/com/laytonsmith/core/FullyQualifiedClassName.java @@ -88,7 +88,7 @@ public static FullyQualifiedClassName forNativeEnum(Class clazz) String fqcn = m.value(); FullyQualifiedClassName f = new FullyQualifiedClassName(fqcn); try { - f.nativeClass = NativeTypeList.getNativeEnumType(f).typeof().getNativeType(); + f.nativeClass = NativeTypeList.getNativeEnumType(f).typeof(null).getNativeType(); } catch (ClassNotFoundException ex) { // This can't happen, it would have already been the above error. throw new Error(ex); diff --git a/src/main/java/com/laytonsmith/core/ObjectGenerator.java b/src/main/java/com/laytonsmith/core/ObjectGenerator.java index ba409d1270..e02d83c816 100644 --- a/src/main/java/com/laytonsmith/core/ObjectGenerator.java +++ b/src/main/java/com/laytonsmith/core/ObjectGenerator.java @@ -195,7 +195,7 @@ public MCLocation location(Mixed c, MCWorld w, Target t) { * world. More conveniently: ([world], x, y, z, [yaw, pitch]) */ public MCLocation location(Mixed c, MCWorld w, Target t, Environment env) { - if(!(c.isInstanceOf(CArray.TYPE))) { + if(!(c.isInstanceOf(CArray.TYPE, null, env))) { throw new CREFormatException("Expecting an array, received " + c.typeof(env).getSimpleName(), t); } CArray array = (CArray) c; @@ -290,15 +290,31 @@ public Construct item(MCItemStack is, Target t) { * @param t * @return An abstract item stack */ + /** + * @deprecated Use {@link #item(Mixed, Target, Environment)} instead. + */ + @Deprecated public MCItemStack item(Mixed i, Target t) { - return item(i, t, false); + return item(i, t, false, null); + } + + public MCItemStack item(Mixed i, Target t, Environment env) { + return item(i, t, false, env); } + /** + * @deprecated Use {@link #item(Mixed, Target, boolean, Environment)} instead. + */ + @Deprecated public MCItemStack item(Mixed i, Target t, boolean legacy) { + return item(i, t, legacy, null); + } + + public MCItemStack item(Mixed i, Target t, boolean legacy, Environment env) { if(i instanceof CNull) { return EmptyItem(); } - if(!(i.isInstanceOf(CArray.TYPE))) { + if(!(i.isInstanceOf(CArray.TYPE, null, env))) { throw new CREFormatException("Expected an array!", t); } CArray item = (CArray) i; @@ -335,7 +351,7 @@ public MCItemStack item(Mixed i, Target t, boolean legacy) { } } else { Mixed type = item.get("type", t); - if(type.isInstanceOf(CString.TYPE)) { + if(type.isInstanceOf(CString.TYPE, null, env)) { int seperatorIndex = type.val().indexOf(':'); if(seperatorIndex != -1) { try { @@ -367,7 +383,7 @@ public MCItemStack item(Mixed i, Target t, boolean legacy) { // convert legacy meta to material if(material.getName().equals("PIG_SPAWN_EGG") && item.containsKey("meta")) { Mixed meta = item.get("meta", t); - if(meta.isInstanceOf(CArray.TYPE) && ((CArray) meta).containsKey("spawntype")) { + if(meta.isInstanceOf(CArray.TYPE, null, env) && ((CArray) meta).containsKey("spawntype")) { Mixed spawntype = ((CArray) meta).get("spawntype", t); if(!(spawntype instanceof CNull)) { MCMaterial newmaterial; @@ -988,11 +1004,19 @@ public Construct itemMeta(MCItemStack is, Target t) { * @return abstract item meta * @throws ConfigRuntimeException */ + /** + * @deprecated Use {@link #itemMeta(Mixed, MCMaterial, Target, Environment)} instead. + */ + @Deprecated public MCItemMeta itemMeta(Mixed c, MCMaterial mat, Target t) throws ConfigRuntimeException { + return itemMeta(c, mat, t, null); + } + + public MCItemMeta itemMeta(Mixed c, MCMaterial mat, Target t, Environment env) throws ConfigRuntimeException { if(c instanceof CNull) { return null; } - if(!c.isInstanceOf(CArray.TYPE)) { + if(!c.isInstanceOf(CArray.TYPE, null, env)) { throw new CREFormatException("An array was expected but received " + c + " instead.", t); } else { MCItemFactory itemFactory = Static.getServer().getItemFactory(); @@ -1015,11 +1039,11 @@ public MCItemMeta itemMeta(Mixed c, MCMaterial mat, Target t) throws ConfigRunti Mixed li = ma.get("lore", t); if(li instanceof CNull) { //do nothing - } else if(li.isInstanceOf(CString.TYPE)) { + } else if(li.isInstanceOf(CString.TYPE, null, env)) { List ll = new ArrayList<>(); ll.add(li.val()); meta.setLore(ll); - } else if(li.isInstanceOf(CArray.TYPE)) { + } else if(li.isInstanceOf(CArray.TYPE, null, env)) { CArray la = (CArray) li; List ll = new ArrayList<>(); for(int j = 0; j < la.size(); j++) { @@ -1032,7 +1056,7 @@ public MCItemMeta itemMeta(Mixed c, MCMaterial mat, Target t) throws ConfigRunti } if(ma.containsKey("enchants")) { Mixed enchants = ma.get("enchants", t); - if(enchants.isInstanceOf(CArray.TYPE)) { + if(enchants.isInstanceOf(CArray.TYPE, null, env)) { for(Map.Entry ench : enchants((CArray) enchants, t).entrySet()) { meta.addEnchant(ench.getKey(), ench.getValue(), true); } @@ -1054,7 +1078,7 @@ public MCItemMeta itemMeta(Mixed c, MCMaterial mat, Target t) throws ConfigRunti } if(ma.containsKey("flags")) { Mixed flags = ma.get("flags", t); - if(flags.isInstanceOf(CArray.TYPE)) { + if(flags.isInstanceOf(CArray.TYPE, null, env)) { CArray flagArray = (CArray) flags; for(int i = 0; i < flagArray.size(); i++) { Mixed flag = flagArray.get(i, t); @@ -1069,7 +1093,7 @@ public MCItemMeta itemMeta(Mixed c, MCMaterial mat, Target t) throws ConfigRunti Mixed modifiers = ma.get("modifiers", t); if(modifiers instanceof CNull) { // no modifiers - } else if(modifiers.isInstanceOf(CArray.TYPE)) { + } else if(modifiers.isInstanceOf(CArray.TYPE, null, env)) { CArray modifierArray = (CArray) modifiers; if(modifierArray.isAssociative()) { throw new CREFormatException("Array of attribute modifiers cannot be associative.", t); @@ -1135,7 +1159,7 @@ public MCItemMeta itemMeta(Mixed c, MCMaterial mat, Target t) throws ConfigRunti Mixed mixedFood = ma.get("food", t); if(mixedFood instanceof CNull) { // not supported yet - } else if(mixedFood.isInstanceOf(CArray.TYPE)) { + } else if(mixedFood.isInstanceOf(CArray.TYPE, null, env)) { CArray foodArray = (CArray) mixedFood; if(!foodArray.isAssociative()) { throw new CREFormatException("Food array must be associative.", t); @@ -1195,7 +1219,7 @@ public MCItemMeta itemMeta(Mixed c, MCMaterial mat, Target t) throws ConfigRunti Mixed mixedCooldown = ma.get("cooldown", t); if(mixedCooldown instanceof CNull) { // not yet supported - } else if(mixedCooldown.isInstanceOf(CArray.TYPE)) { + } else if(mixedCooldown.isInstanceOf(CArray.TYPE, null, env)) { CArray cooldownArray = (CArray) mixedCooldown; if(!cooldownArray.isAssociative()) { throw new CREFormatException("Cooldown array must be associative.", t); @@ -1235,7 +1259,7 @@ public MCItemMeta itemMeta(Mixed c, MCMaterial mat, Target t) throws ConfigRunti Mixed equippableMixed = ma.get("equippable", t); if(equippableMixed instanceof CNull) { // not yet supported - } else if(equippableMixed.isInstanceOf(CArray.TYPE)) { + } else if(equippableMixed.isInstanceOf(CArray.TYPE, null, env)) { CArray equippableArray = (CArray) equippableMixed; if(!equippableArray.isAssociative()) { throw new CREFormatException("Equippable array must be associative.", t); @@ -1252,7 +1276,7 @@ public MCItemMeta itemMeta(Mixed c, MCMaterial mat, Target t) throws ConfigRunti Mixed entitiesMixed = equippableArray.get("entities", t); if(entitiesMixed instanceof CNull) { // ignored - } else if(entitiesMixed.isInstanceOf(CArray.TYPE)) { + } else if(entitiesMixed.isInstanceOf(CArray.TYPE, null, env)) { CArray entitiesArray = (CArray) entitiesMixed; if(entitiesArray.isAssociative()) { throw new CREFormatException("Allowed entities array must not be associative.", t); @@ -1452,7 +1476,7 @@ public MCItemMeta itemMeta(Mixed c, MCMaterial mat, Target t) throws ConfigRunti } else if(bs instanceof MCDecoratedPot decoratedPot) { if(ma.containsKey("sherds")) { Mixed sherds = ma.get("sherds", t); - if(sherds.isInstanceOf(CArray.TYPE)) { + if(sherds.isInstanceOf(CArray.TYPE, null, env)) { CArray sherdArray = (CArray) sherds; if(!sherdArray.isAssociative()) { throw new CREFormatException("Expected associative array for decorated pot meta.", t); @@ -1476,7 +1500,7 @@ public MCItemMeta itemMeta(Mixed c, MCMaterial mat, Target t) throws ConfigRunti if(ma.containsKey("inventory")) { MCInventory inv = ((MCInventoryHolder) bs).getInventory(); Mixed cInvRaw = ma.get("inventory", t); - if(cInvRaw.isInstanceOf(CArray.TYPE)) { + if(cInvRaw.isInstanceOf(CArray.TYPE, null, env)) { CArray cinv = (CArray) cInvRaw; for(String key : cinv.stringKeySet()) { try { @@ -1505,7 +1529,7 @@ public MCItemMeta itemMeta(Mixed c, MCMaterial mat, Target t) throws ConfigRunti } if(ma.containsKey("signtext")) { Mixed possibleLines = ma.get("signtext", t); - if(possibleLines.isInstanceOf(CArray.TYPE)) { + if(possibleLines.isInstanceOf(CArray.TYPE, null, env)) { CArray lines = (CArray) possibleLines; for(int i = 0; i < lines.size(); i++) { sign.setLine(i, lines.get(i, t).val()); @@ -1527,7 +1551,7 @@ public MCItemMeta itemMeta(Mixed c, MCMaterial mat, Target t) throws ConfigRunti if(backText != null) { if(ma.containsKey("backtext")) { Mixed possibleLines = ma.get("backtext", t); - if(possibleLines.isInstanceOf(CArray.TYPE)) { + if(possibleLines.isInstanceOf(CArray.TYPE, null, env)) { CArray lines = (CArray) possibleLines; for(int i = 0; i < lines.size(); i++) { backText.setLine(i, lines.get(i, t).val()); @@ -1568,7 +1592,7 @@ public MCItemMeta itemMeta(Mixed c, MCMaterial mat, Target t) throws ConfigRunti Mixed mtrim = ma.get("trim", t); if(mtrim instanceof CNull) { // nothing - } else if(mtrim.isInstanceOf(CArray.TYPE)) { + } else if(mtrim.isInstanceOf(CArray.TYPE, null, env)) { CArray trim = (CArray) mtrim; if(!trim.isAssociative()) { throw new CREFormatException("Expected associative array for armor trim meta.", t); @@ -1585,7 +1609,7 @@ public MCItemMeta itemMeta(Mixed c, MCMaterial mat, Target t) throws ConfigRunti Mixed ci = ma.get("color", t); if(ci instanceof CNull) { //nothing - } else if(ci.isInstanceOf(CArray.TYPE)) { + } else if(ci.isInstanceOf(CArray.TYPE, null, env)) { ((MCColorableArmorMeta) armorMeta).setColor(color((CArray) ci, t)); } else { throw new CREFormatException("Color was expected to be an array.", t); @@ -1596,7 +1620,7 @@ public MCItemMeta itemMeta(Mixed c, MCMaterial mat, Target t) throws ConfigRunti MCFireworkEffectMeta femeta = (MCFireworkEffectMeta) meta; if(ma.containsKey("effect")) { Mixed cfem = ma.get("effect", t); - if(cfem.isInstanceOf(CArray.TYPE)) { + if(cfem.isInstanceOf(CArray.TYPE, null, env)) { femeta.setEffect(fireworkEffect((CArray) cfem, t)); } else if(!(cfem instanceof CNull)) { throw new CREFormatException("FireworkCharge effect was expected to be an array or null.", t); @@ -1606,7 +1630,7 @@ public MCItemMeta itemMeta(Mixed c, MCMaterial mat, Target t) throws ConfigRunti MCFireworkMeta fmeta = (MCFireworkMeta) meta; if(ma.containsKey("firework")) { Mixed construct = ma.get("firework", t); - if(construct.isInstanceOf(CArray.TYPE)) { + if(construct.isInstanceOf(CArray.TYPE, null, env)) { CArray firework = (CArray) construct; if(firework.containsKey("strength")) { fmeta.setStrength(ArgumentValidation.getInt32(firework.get("strength", t), t)); @@ -1614,9 +1638,9 @@ public MCItemMeta itemMeta(Mixed c, MCMaterial mat, Target t) throws ConfigRunti if(firework.containsKey("effects")) { // New style (supports multiple effects) Mixed effects = firework.get("effects", t); - if(effects.isInstanceOf(CArray.TYPE)) { + if(effects.isInstanceOf(CArray.TYPE, null, env)) { for(Mixed effect : ((CArray) effects).asList()) { - if(effect.isInstanceOf(CArray.TYPE)) { + if(effect.isInstanceOf(CArray.TYPE, null, env)) { fmeta.addEffect(fireworkEffect((CArray) effect, t)); } else { throw new CREFormatException("Firework effect was expected to be an array.", t); @@ -1638,7 +1662,7 @@ public MCItemMeta itemMeta(Mixed c, MCMaterial mat, Target t) throws ConfigRunti Mixed ci = ma.get("color", t); if(ci instanceof CNull) { //nothing - } else if(ci.isInstanceOf(CArray.TYPE)) { + } else if(ci.isInstanceOf(CArray.TYPE, null, env)) { ((MCLeatherArmorMeta) meta).setColor(color((CArray) ci, t)); } else { throw new CREFormatException("Color was expected to be an array.", t); @@ -1670,7 +1694,7 @@ public MCItemMeta itemMeta(Mixed c, MCMaterial mat, Target t) throws ConfigRunti Mixed pages = ma.get("pages", t); if(pages instanceof CNull) { //nothing - } else if(pages.isInstanceOf(CArray.TYPE)) { + } else if(pages.isInstanceOf(CArray.TYPE, null, env)) { CArray pa = (CArray) pages; List pl = new ArrayList<>(); for(int j = 0; j < pa.size(); j++) { @@ -1730,7 +1754,7 @@ public MCItemMeta itemMeta(Mixed c, MCMaterial mat, Target t) throws ConfigRunti Mixed stored = ma.get("stored", t); if(stored instanceof CNull) { //Still doing nothing - } else if(stored.isInstanceOf(CArray.TYPE)) { + } else if(stored.isInstanceOf(CArray.TYPE, null, env)) { for(Map.Entry ench : enchants((CArray) stored, t).entrySet()) { ((MCEnchantmentStorageMeta) meta).addStoredEnchant(ench.getKey(), ench.getValue(), true); } @@ -1741,7 +1765,7 @@ public MCItemMeta itemMeta(Mixed c, MCMaterial mat, Target t) throws ConfigRunti } else if(meta instanceof MCPotionMeta) { if(ma.containsKey("potions")) { Mixed effects = ma.get("potions", t); - if(effects.isInstanceOf(CArray.TYPE)) { + if(effects.isInstanceOf(CArray.TYPE, null, env)) { for(MCLivingEntity.MCEffect e : potions((CArray) effects, t)) { ((MCPotionMeta) meta).addCustomEffect(e.getPotionEffectType(), e.getStrength(), e.getTicksRemaining(), e.isAmbient(), e.hasParticles(), e.showIcon(), true, t); @@ -1757,7 +1781,7 @@ public MCItemMeta itemMeta(Mixed c, MCMaterial mat, Target t) throws ConfigRunti } } else if(ma.containsKey("base")) { Mixed potiondata = ma.get("base", t); - if(potiondata.isInstanceOf(CArray.TYPE)) { + if(potiondata.isInstanceOf(CArray.TYPE, null, env)) { if(Static.getServer().getMinecraftVersion().gte(MCVersion.MC1_20_6)) { ((MCPotionMeta) meta).setBasePotionType(legacyPotionData((CArray) potiondata, t)); } else { @@ -1767,16 +1791,16 @@ public MCItemMeta itemMeta(Mixed c, MCMaterial mat, Target t) throws ConfigRunti } if(ma.containsKey("color")) { Mixed color = ma.get("color", t); - if(color.isInstanceOf(CArray.TYPE)) { + if(color.isInstanceOf(CArray.TYPE, null, env)) { ((MCPotionMeta) meta).setColor(color((CArray) color, t)); - } else if(color.isInstanceOf(CString.TYPE)) { + } else if(color.isInstanceOf(CString.TYPE, null, env)) { ((MCPotionMeta) meta).setColor(StaticLayer.GetConvertor().GetColor(color.val(), t)); } } } else if(meta instanceof MCSuspiciousStewMeta) { if(ma.containsKey("potions")) { Mixed effects = ma.get("potions", t); - if(effects.isInstanceOf(CArray.TYPE)) { + if(effects.isInstanceOf(CArray.TYPE, null, env)) { for(MCLivingEntity.MCEffect e : potions((CArray) effects, t)) { ((MCSuspiciousStewMeta) meta).addCustomEffect(e.getPotionEffectType(), e.getStrength(), e.getTicksRemaining(), e.isAmbient(), e.hasParticles(), e.showIcon(), true, t); @@ -1808,7 +1832,7 @@ public MCItemMeta itemMeta(Mixed c, MCMaterial mat, Target t) throws ConfigRunti } else if(meta instanceof MCMapMeta) { if(ma.containsKey("color")) { Mixed ci = ma.get("color", t); - if(ci.isInstanceOf(CArray.TYPE)) { + if(ci.isInstanceOf(CArray.TYPE, null, env)) { ((MCMapMeta) meta).setColor(color((CArray) ci, t)); } else if(!(ci instanceof CNull)) { throw new CREFormatException("Color was expected to be an array.", t); @@ -1897,7 +1921,7 @@ public MCItemMeta itemMeta(Mixed c, MCMaterial mat, Target t) throws ConfigRunti } else if(meta instanceof MCKnowledgeBookMeta knowledgeBookMeta) { if(ma.containsKey("recipes")) { Mixed value = ma.get("recipes", t); - if(value.isInstanceOf(CArray.TYPE)) { + if(value.isInstanceOf(CArray.TYPE, null, env)) { CArray array = ((CArray) value); List keys = new ArrayList<>((int) array.size()); for(Mixed entry : ((CArray) value).asList()) { @@ -2085,7 +2109,7 @@ public Vector3D vector(Vector3D v, Mixed c, Target t) { * @return the Vector */ public Vector3D vector(Vector3D v, Mixed c, Target t, Environment env) { - if(c.isInstanceOf(CArray.TYPE)) { + if(c.isInstanceOf(CArray.TYPE, null, env)) { CArray va = (CArray) c; double x = v.X(); double y = v.Y(); @@ -2133,7 +2157,15 @@ public CArray enchants(Map map, Target t) { return ret; } + /** + * @deprecated Use {@link #enchants(CArray, Target, Environment)} instead. + */ + @Deprecated public Map enchants(CArray enchantArray, Target t) { + return enchants(enchantArray, t, null); + } + + public Map enchants(CArray enchantArray, Target t, Environment env) { Map ret = new HashMap<>(); for(String key : enchantArray.stringKeySet()) { MCEnchantment etype = null; @@ -2143,7 +2175,7 @@ public Map enchants(CArray enchantArray, Target t) { if(enchantArray.isAssociative()) { try { etype = MCEnchantment.valueOf(key.toUpperCase()); - if(value.isInstanceOf(CInt.TYPE)) { + if(value.isInstanceOf(CInt.TYPE, null, env)) { ret.put(etype, ArgumentValidation.getInt32(value, t)); continue; } @@ -2153,7 +2185,7 @@ public Map enchants(CArray enchantArray, Target t) { } // legacy format - if(value.isInstanceOf(CArray.TYPE)) { + if(value.isInstanceOf(CArray.TYPE, null, env)) { CArray ea = (CArray) value; if(etype == null) { String setype = ea.get("etype", t).val(); @@ -2300,10 +2332,18 @@ public CArray potions(List effectList, Target t) { return ea; } + /** + * @deprecated Use {@link #potions(CArray, Target, Environment)} instead. + */ + @Deprecated public List potions(CArray ea, Target t) { + return potions(ea, t, null); + } + + public List potions(CArray ea, Target t, Environment env) { List ret = new ArrayList<>(); for(String key : ea.stringKeySet()) { - if(ea.get(key, t).isInstanceOf(CArray.TYPE)) { + if(ea.get(key, t).isInstanceOf(CArray.TYPE, null, env)) { CArray effect = (CArray) ea.get(key, t); MCPotionEffectType type; int strength = 0; @@ -2358,7 +2398,15 @@ public CArray potionData(MCPotionData mcpd, Target t) { return base; } + /** + * @deprecated Use {@link #potionData(CArray, Target, Environment)} instead. + */ + @Deprecated public MCPotionData potionData(CArray pd, Target t) { + return potionData(pd, t, null); + } + + public MCPotionData potionData(CArray pd, Target t, Environment env) { MCPotionType type; try { type = MCPotionType.valueOf(pd.get("type", t).val().toUpperCase()); @@ -2369,7 +2417,7 @@ public MCPotionData potionData(CArray pd, Target t) { boolean upgraded = false; if(pd.containsKey("extended")) { Mixed cext = pd.get("extended", t); - if(cext.isInstanceOf(CBoolean.TYPE)) { + if(cext instanceof CBoolean) { extended = ((CBoolean) cext).getBoolean(); } else { throw new CREFormatException( @@ -2378,7 +2426,7 @@ public MCPotionData potionData(CArray pd, Target t) { } if(pd.containsKey("upgraded")) { Mixed cupg = pd.get("upgraded", t); - if(cupg.isInstanceOf(CBoolean.TYPE)) { + if(cupg instanceof CBoolean) { upgraded = ((CBoolean) cupg).getBoolean(); } else { throw new CREFormatException( @@ -2392,7 +2440,15 @@ public MCPotionData potionData(CArray pd, Target t) { } } + /** + * @deprecated Use {@link #legacyPotionData(CArray, Target, Environment)} instead. + */ + @Deprecated public MCPotionType legacyPotionData(CArray potionArray, Target t) { + return legacyPotionData(potionArray, t, null); + } + + public MCPotionType legacyPotionData(CArray potionArray, Target t, Environment env) { MCPotionType type; try { // need to get converted type first before extending/upgrading @@ -2407,13 +2463,13 @@ public MCPotionType legacyPotionData(CArray potionArray, Target t) { boolean upgraded = false; if(potionArray.containsKey("extended")) { Mixed cext = potionArray.get("extended", t); - if(cext.isInstanceOf(CBoolean.TYPE)) { + if(cext instanceof CBoolean) { extended = ((CBoolean) cext).getBoolean(); } } if(potionArray.containsKey("upgraded")) { Mixed cupg = potionArray.get("upgraded", t); - if(cupg.isInstanceOf(CBoolean.TYPE)) { + if(cupg instanceof CBoolean) { upgraded = ((CBoolean) cupg).getBoolean(); } } @@ -2474,18 +2530,18 @@ public MCFireworkEffect fireworkEffect(CArray fe, Target t, Environment env) { } if(fe.containsKey("colors")) { Mixed colors = fe.get("colors", t); - if(colors.isInstanceOf(CArray.TYPE)) { + if(colors.isInstanceOf(CArray.TYPE, null, env)) { CArray ccolors = (CArray) colors; if(ccolors.size() == 0) { builder.addColor(MCColor.WHITE); } else { for(Mixed color : ccolors.asList()) { MCColor mccolor; - if(color.isInstanceOf(CString.TYPE)) { + if(color.isInstanceOf(CString.TYPE, null, env)) { mccolor = StaticLayer.GetConvertor().GetColor(color.val(), t); - } else if(color.isInstanceOf(CArray.TYPE)) { + } else if(color.isInstanceOf(CArray.TYPE, null, env)) { mccolor = color((CArray) color, t); - } else if(color.isInstanceOf(CInt.TYPE) && ccolors.size() == 3) { + } else if(color.isInstanceOf(CInt.TYPE, null, env) && ccolors.size() == 3) { // Appears to be a single color builder.addColor(color(ccolors, t)); break; @@ -2496,7 +2552,7 @@ public MCFireworkEffect fireworkEffect(CArray fe, Target t, Environment env) { builder.addColor(mccolor); } } - } else if(colors.isInstanceOf(CString.TYPE)) { + } else if(colors.isInstanceOf(CString.TYPE, null, env)) { String[] split = colors.val().split("\\|"); if(split.length == 0) { builder.addColor(MCColor.WHITE); @@ -2514,15 +2570,15 @@ public MCFireworkEffect fireworkEffect(CArray fe, Target t, Environment env) { } if(fe.containsKey("fade")) { Mixed colors = fe.get("fade", t); - if(colors.isInstanceOf(CArray.TYPE)) { + if(colors.isInstanceOf(CArray.TYPE, null, env)) { CArray ccolors = (CArray) colors; for(Mixed color : ccolors.asList()) { MCColor mccolor; - if(color.isInstanceOf(CArray.TYPE)) { + if(color.isInstanceOf(CArray.TYPE, null, env)) { mccolor = color((CArray) color, t); - } else if(color.isInstanceOf(CString.TYPE)) { + } else if(color.isInstanceOf(CString.TYPE, null, env)) { mccolor = StaticLayer.GetConvertor().GetColor(color.val(), t); - } else if(color.isInstanceOf(CInt.TYPE) && ccolors.size() == 3) { + } else if(color.isInstanceOf(CInt.TYPE, null, env) && ccolors.size() == 3) { // Appears to be a single color builder.addFadeColor(color(ccolors, t)); break; @@ -2532,7 +2588,7 @@ public MCFireworkEffect fireworkEffect(CArray fe, Target t, Environment env) { } builder.addFadeColor(mccolor); } - } else if(colors.isInstanceOf(CString.TYPE)) { + } else if(colors.isInstanceOf(CString.TYPE, null, env)) { String[] split = colors.val().split("\\|"); for(String s : split) { builder.addFadeColor(StaticLayer.GetConvertor().GetColor(s, t)); @@ -2620,7 +2676,7 @@ public MCRecipe recipe(Mixed c, Target t) { } public MCRecipe recipe(Mixed c, Target t, Environment env) { - if(!(c.isInstanceOf(CArray.TYPE))) { + if(!(c.isInstanceOf(CArray.TYPE, null, env))) { throw new CRECastException("Expected array but received " + c.typeof(env).getSimpleName(), t); } CArray recipe = (CArray) c; @@ -2656,7 +2712,7 @@ public MCRecipe recipe(Mixed c, Target t, Environment env) { } int i = 0; for(Mixed row : shaped.asList()) { - if(row.isInstanceOf(CString.TYPE) && row.val().length() >= 1 && row.val().length() <= 3) { + if(row.isInstanceOf(CString.TYPE, null, env) && row.val().length() >= 1 && row.val().length() <= 3) { shape[i] = row.val(); i++; } else { @@ -2671,13 +2727,13 @@ public MCRecipe recipe(Mixed c, Target t, Environment env) { } for(String key : shapedIngredients.stringKeySet()) { Mixed ingredient = shapedIngredients.get(key, t); - if(ingredient.isInstanceOf(CArray.TYPE)) { + if(ingredient.isInstanceOf(CArray.TYPE, null, env)) { if(((CArray) ingredient).isAssociative()) { // Single exact item ingredient ((MCShapedRecipe) ret).setIngredient(key.charAt(0), recipeItem(ingredient, t)); } else { // Multiple ingredient choices - ((MCShapedRecipe) ret).setIngredient(key.charAt(0), recipeChoice((CArray) ingredient, t)); + ((MCShapedRecipe) ret).setIngredient(key.charAt(0), recipeChoice((CArray) ingredient, t, env)); } } else if(ingredient instanceof CNull) { // empty @@ -2693,7 +2749,7 @@ public MCRecipe recipe(Mixed c, Target t, Environment env) { throw new CREIllegalArgumentException("Ingredients array is invalid.", t); } for(Mixed ingredient : ingredients.asList()) { - if(ingredient.isInstanceOf(CArray.TYPE)) { + if(ingredient.isInstanceOf(CArray.TYPE, null, env)) { if(((CArray) ingredient).isAssociative()) { // Single ingredient item array if(((CArray) ingredient).containsKey("meta")) { @@ -2708,7 +2764,7 @@ public MCRecipe recipe(Mixed c, Target t, Environment env) { } } else { // Multiple ingredient choices - ((MCShapelessRecipe) ret).addIngredient(recipeChoice((CArray) ingredient, t)); + ((MCShapelessRecipe) ret).addIngredient(recipeChoice((CArray) ingredient, t, env)); } } else { // single ingredient material @@ -2722,11 +2778,11 @@ public MCRecipe recipe(Mixed c, Target t, Environment env) { case FURNACE: case SMOKING: Mixed input = recipe.get("input", t); - if(input.isInstanceOf(CArray.TYPE)) { + if(input.isInstanceOf(CArray.TYPE, null, env)) { if(((CArray) input).isAssociative()) { ((MCCookingRecipe) ret).setInput(recipeItem(input, t)); } else { - ((MCCookingRecipe) ret).setInput(recipeChoice((CArray) input, t)); + ((MCCookingRecipe) ret).setInput(recipeChoice((CArray) input, t, env)); } } else { ((MCCookingRecipe) ret).setInput(recipeMaterial(input, t)); @@ -2741,11 +2797,11 @@ public MCRecipe recipe(Mixed c, Target t, Environment env) { case STONECUTTING: Mixed stoneCutterInput = recipe.get("input", t); - if(stoneCutterInput.isInstanceOf(CArray.TYPE)) { + if(stoneCutterInput.isInstanceOf(CArray.TYPE, null, env)) { if(((CArray) stoneCutterInput).isAssociative()) { ((MCStonecuttingRecipe) ret).setInput(recipeItem(stoneCutterInput, t)); } else { - ((MCStonecuttingRecipe) ret).setInput(recipeChoice((CArray) stoneCutterInput, t)); + ((MCStonecuttingRecipe) ret).setInput(recipeChoice((CArray) stoneCutterInput, t, env)); } } else { ((MCStonecuttingRecipe) ret).setInput(recipeMaterial(stoneCutterInput, t)); @@ -2784,12 +2840,12 @@ private MCMaterial recipeMaterial(Mixed arg, Target t) { * @return * @throws CREIllegalArgumentException */ - private MCRecipeChoice recipeChoice(CArray ingredient, Target t) { + private MCRecipeChoice recipeChoice(CArray ingredient, Target t, Environment env) { // Multiple ingredient choices MCRecipeChoice.MaterialChoice materialChoice = new MCRecipeChoice.MaterialChoice(); MCRecipeChoice.ExactChoice exactChoice = new MCRecipeChoice.ExactChoice(); for(Mixed choice : ingredient.asList()) { - if(choice.isInstanceOf(CArray.TYPE)) { + if(choice.isInstanceOf(CArray.TYPE, null, env)) { exactChoice.addItem(recipeItem(choice, t)); } else { materialChoice.addMaterial(recipeMaterial(choice, t)); @@ -2943,7 +2999,15 @@ private Construct blockState(String value) { return new CString(value, Target.UNKNOWN); } + /** + * @deprecated Use {@link #particleData(MCParticle, MCLocation, CArray, Target, Environment)} instead. + */ + @Deprecated public Object particleData(MCParticle particleType, MCLocation l, CArray pa, Target t) { + return particleData(particleType, l, pa, t, null); + } + + public Object particleData(MCParticle particleType, MCLocation l, CArray pa, Target t, Environment env) { switch(particleType.getAbstracted()) { case BLOCK_DUST: case BLOCK_CRACK: @@ -2968,8 +3032,8 @@ public Object particleData(MCParticle particleType, MCLocation l, CArray pa, Tar case ITEM_CRACK: if(pa.containsKey("item")) { Mixed value = pa.get("item", t); - if(value.isInstanceOf(CArray.TYPE)) { - return item(pa.get("item", t), t); + if(value.isInstanceOf(CArray.TYPE, null, env)) { + return item(pa.get("item", t), t, env); } else { MCMaterial mat = StaticLayer.GetMaterial(value.val()); if(mat != null) { @@ -2989,7 +3053,7 @@ public Object particleData(MCParticle particleType, MCLocation l, CArray pa, Tar case FLASH: if(pa.containsKey("color")) { Mixed c = pa.get("color", t); - if(c.isInstanceOf(CArray.TYPE)) { + if(c.isInstanceOf(CArray.TYPE, null, env)) { return color((CArray) c, t); } else { return StaticLayer.GetConvertor().GetColor(c.val(), t); @@ -2999,7 +3063,7 @@ public Object particleData(MCParticle particleType, MCLocation l, CArray pa, Tar case DRAGON_BREATH: if(pa.containsKey("power")) { Mixed d = pa.get("power", t); - if(d.isInstanceOf(CDouble.TYPE)) { + if(d.isInstanceOf(CDouble.TYPE, null, env)) { return (float) ((CDouble) d).getDouble(); } else if(!(d instanceof CNull)) { throw new CREIllegalArgumentException("Expected double for power but found " + d, t); @@ -3011,7 +3075,7 @@ public Object particleData(MCParticle particleType, MCLocation l, CArray pa, Tar MCColor spellColor = MCColor.WHITE; if(pa.containsKey("color")) { Mixed c = pa.get("color", t); - if(c.isInstanceOf(CArray.TYPE)) { + if(c.isInstanceOf(CArray.TYPE, null, env)) { spellColor = color((CArray) c, t); } else { spellColor = StaticLayer.GetConvertor().GetColor(c.val(), t); @@ -3020,7 +3084,7 @@ public Object particleData(MCParticle particleType, MCLocation l, CArray pa, Tar float power = 1.0F; if(pa.containsKey("power")) { Mixed d = pa.get("power", t); - if(d.isInstanceOf(CDouble.TYPE)) { + if(d.isInstanceOf(CDouble.TYPE, null, env)) { power = (float) ((CDouble) d).getDouble(); } else if(!(d instanceof CNull)) { throw new CREIllegalArgumentException("Expected double for power but found " + d, t); @@ -3031,14 +3095,14 @@ public Object particleData(MCParticle particleType, MCLocation l, CArray pa, Tar if(pa.containsKey("color")) { Mixed c = pa.get("color", t); MCColor fromColor; - if(c.isInstanceOf(CArray.TYPE)) { + if(c.isInstanceOf(CArray.TYPE, null, env)) { fromColor = color((CArray) c, t); } else { fromColor = StaticLayer.GetConvertor().GetColor(c.val(), t); } if(pa.containsKey("tocolor")) { Mixed sc = pa.get("tocolor", t); - if(sc.isInstanceOf(CArray.TYPE)) { + if(sc.isInstanceOf(CArray.TYPE, null, env)) { return new MCParticleData.DustTransition(fromColor, color((CArray) sc, t)); } else { return new MCParticleData.DustTransition(fromColor, @@ -3048,7 +3112,7 @@ public Object particleData(MCParticle particleType, MCLocation l, CArray pa, Tar return new MCParticleData.DustTransition(fromColor, MCColor.WHITE); } else if(pa.containsKey("tocolor")) { Mixed sc = pa.get("tocolor", t); - if(sc.isInstanceOf(CArray.TYPE)) { + if(sc.isInstanceOf(CArray.TYPE, null, env)) { return new MCParticleData.DustTransition(MCColor.WHITE, color((CArray) sc, t)); } else { return new MCParticleData.DustTransition(MCColor.WHITE, @@ -3059,7 +3123,7 @@ public Object particleData(MCParticle particleType, MCLocation l, CArray pa, Tar case VIBRATION: if(pa.containsKey("destination")) { Mixed d = pa.get("destination", t); - if(d.isInstanceOf(CArray.TYPE)) { + if(d.isInstanceOf(CArray.TYPE, null, env)) { return new MCParticleData.VibrationBlockDestination(location(d, l.getWorld(), t), 5); } else { return new MCParticleData.VibrationEntityDestination(Static.getEntity(d, t), 5); @@ -3069,7 +3133,7 @@ public Object particleData(MCParticle particleType, MCLocation l, CArray pa, Tar case SHRIEK: if(pa.containsKey("delay")) { Mixed d = pa.get("delay", t); - if(d.isInstanceOf(CInt.TYPE)) { + if(d.isInstanceOf(CInt.TYPE, null, env)) { return (int) ((CInt) d).getInt(); } else if(!(d instanceof CNull)) { throw new CREIllegalArgumentException("Expected integer for delay but found " + d, t); @@ -3079,7 +3143,7 @@ public Object particleData(MCParticle particleType, MCLocation l, CArray pa, Tar case SCULK_CHARGE: if(pa.containsKey("angle")) { Mixed d = pa.get("angle", t); - if(d.isInstanceOf(CDouble.TYPE)) { + if(d.isInstanceOf(CDouble.TYPE, null, env)) { return (float) ((CDouble) d).getDouble(); } else if(!(d instanceof CNull)) { throw new CREIllegalArgumentException("Expected double for angle but found " + d, t); @@ -3090,14 +3154,14 @@ public Object particleData(MCParticle particleType, MCLocation l, CArray pa, Tar MCLocation target = l; if(pa.containsKey("target")) { Mixed d = pa.get("target", t); - if(d.isInstanceOf(CArray.TYPE)) { + if(d.isInstanceOf(CArray.TYPE, null, env)) { target = location(d, l.getWorld(), t); } } MCColor color; if(pa.containsKey("color")) { Mixed c = pa.get("color", t); - if(c.isInstanceOf(CArray.TYPE)) { + if(c.isInstanceOf(CArray.TYPE, null, env)) { color = color((CArray) c, t); } else { color = StaticLayer.GetConvertor().GetColor(c.val(), t); diff --git a/src/main/java/com/laytonsmith/core/ParseTree.java b/src/main/java/com/laytonsmith/core/ParseTree.java index 7920ae9ad9..669a4dfccb 100644 --- a/src/main/java/com/laytonsmith/core/ParseTree.java +++ b/src/main/java/com/laytonsmith/core/ParseTree.java @@ -441,7 +441,7 @@ public Target getTarget() { */ public CClassType getDeclaredType(Environment env) { if(isConst()) { - return getData().typeof(); + return getData().typeof(env); } else if(getData() instanceof IVariable ivar) { StaticAnalysis sa = env.getEnv(CompilerEnvironment.class).getStaticAnalysis(); if(sa.isLocalEnabled()) { diff --git a/src/main/java/com/laytonsmith/core/Script.java b/src/main/java/com/laytonsmith/core/Script.java index c73e3e6cc4..2b44b5d5c5 100644 --- a/src/main/java/com/laytonsmith/core/Script.java +++ b/src/main/java/com/laytonsmith/core/Script.java @@ -422,7 +422,7 @@ public Mixed eval(ParseTree c, final Environment env) throws CancelCommandExcept if(f.shouldProfile()) { Profiler profiler = env.getEnv(StaticRuntimeEnv.class).GetProfiler(); if(profiler.isLoggable(f.profileAt())) { - p = profiler.start(f.profileMessage(args), f.profileAt()); + p = profiler.start(Function.ExecuteProfileMessage(f, env, args), f.profileAt()); } } Mixed ret; diff --git a/src/main/java/com/laytonsmith/core/Static.java b/src/main/java/com/laytonsmith/core/Static.java index 8ca217b3c2..e771e3dd0f 100644 --- a/src/main/java/com/laytonsmith/core/Static.java +++ b/src/main/java/com/laytonsmith/core/Static.java @@ -43,6 +43,7 @@ import com.laytonsmith.core.constructs.CString; import com.laytonsmith.core.constructs.CVoid; import com.laytonsmith.core.constructs.Construct; +import com.laytonsmith.core.constructs.InstanceofUtil; import com.laytonsmith.core.constructs.NativeTypeList; import com.laytonsmith.core.constructs.Target; import com.laytonsmith.core.constructs.Variable; @@ -829,8 +830,24 @@ public static UUID GetUUID(Mixed subject, Target t) { return GetUUID(subject.val(), t); } + /** + * @deprecated Use {@link #GetUser(Mixed, Target, Environment)} instead. + */ + @Deprecated public static MCOfflinePlayer GetUser(Mixed search, Target t) { - return GetUser(search.val(), t); + return GetUser(search.val(), t, null); + } + + public static MCOfflinePlayer GetUser(Mixed search, Target t, Environment env) { + return GetUser(search.val(), t, env); + } + + /** + * @deprecated Use {@link #GetUser(String, Target, Environment)} instead. + */ + @Deprecated + public static MCOfflinePlayer GetUser(String search, Target t) { + return GetUser(search, t, null); } /** @@ -840,9 +857,10 @@ public static MCOfflinePlayer GetUser(Mixed search, Target t) { * * @param search The text to be searched, can be between 1 and 16 characters, or 32 or 36 characters * @param t + * @param env * @return */ - public static MCOfflinePlayer GetUser(String search, Target t) { + public static MCOfflinePlayer GetUser(String search, Target t, Environment env) { MCOfflinePlayer ofp; if(search.length() > 0 && search.length() <= 16) { if(CONSOLE_NAME.equals(search)) { @@ -854,7 +872,7 @@ public static MCOfflinePlayer GetUser(String search, Target t) { try { ofp = getServer().getOfflinePlayer(GetUUID(search, t)); } catch(ConfigRuntimeException cre) { - if(cre instanceof CREThrowable && ((CREThrowable) cre).isInstanceOf(CRELengthException.TYPE)) { + if(cre instanceof CREThrowable && ((CREThrowable) cre).isInstanceOf(CRELengthException.TYPE, null, env)) { throw new CRELengthException("The given string was the wrong size to identify a player." + " A player name is expected to be between 1 and 16 characters. " + cre.getMessage(), t); } else { @@ -875,7 +893,26 @@ public static MCOfflinePlayer GetUser(String search, Target t) { * @return * @throws ConfigRuntimeException */ + /** + * @deprecated Use {@link #GetPlayer(String, Target, Environment)} instead. + */ + @Deprecated public static MCPlayer GetPlayer(String player, Target t) throws ConfigRuntimeException { + return GetPlayer(player, t, null); + } + + /** + * Returns the player specified by name or UUID. Injected players are also returned in this list. If provided a string + * between 1 and 16 characters, the lookup will be name-based. If provided a string that is 32 or 36 characters, the + * lookup will be UUID-based. Throws CREPlayerOfflineException if the player is not online. + * + * @param player + * @param t + * @param env + * @return + * @throws ConfigRuntimeException + */ + public static MCPlayer GetPlayer(String player, Target t, Environment env) throws ConfigRuntimeException { if(player == null) { throw new CREPlayerOfflineException("No player was specified!", t); } @@ -897,7 +934,7 @@ public static MCPlayer GetPlayer(String player, Target t) throws ConfigRuntimeEx throw new CREPlayerOfflineException("The specified player (" + player + ") is not online", t); } } catch(CREThrowable ex) { - if(ex.isInstanceOf(CRELengthException.TYPE)) { + if(ex.isInstanceOf(CRELengthException.TYPE, null, env)) { throw new CRELengthException("The given string was the wrong size to identify a player." + " A player name is expected to be between 1 and 16 characters. " + ex.getMessage(), t); } else { @@ -908,8 +945,16 @@ public static MCPlayer GetPlayer(String player, Target t) throws ConfigRuntimeEx return p; } + /** + * @deprecated Use {@link #GetPlayer(Mixed, Target, Environment)} instead. + */ + @Deprecated public static MCPlayer GetPlayer(Mixed player, Target t) throws ConfigRuntimeException { - return GetPlayer(player.val(), t); + return GetPlayer(player.val(), t, null); + } + + public static MCPlayer GetPlayer(Mixed player, Target t, Environment env) throws ConfigRuntimeException { + return GetPlayer(player.val(), t, env); } /** @@ -1569,7 +1614,7 @@ public String getString(CResource res) { boolean[] array = (boolean[]) object; CArray r = new CArray(t); for(boolean b : array) { - r.push(CBoolean.get(b), t); + r.push(CBoolean.get(b), t, null); } return r; } else if(object instanceof byte[]) { @@ -1585,51 +1630,51 @@ public String getString(CResource res) { short[] array = (short[]) object; CArray r = new CArray(t); for(short s : array) { - r.push(new CInt(s, t), t); + r.push(new CInt(s, t), t, null); } return r; } else if(object instanceof int[]) { int[] array = (int[]) object; CArray r = new CArray(t); for(int i : array) { - r.push(new CInt(i, t), t); + r.push(new CInt(i, t), t, null); } return r; } else if(object instanceof long[]) { long[] array = (long[]) object; CArray r = new CArray(t); for(long l : array) { - r.push(new CInt(l, t), t); + r.push(new CInt(l, t), t, null); } return r; } else if(object instanceof float[]) { float[] array = (float[]) object; CArray r = new CArray(t); for(float f : array) { - r.push(new CDouble(f, t), t); + r.push(new CDouble(f, t), t, null); } return r; } else if(object instanceof double[]) { double[] array = (double[]) object; CArray r = new CArray(t); for(double d : array) { - r.push(new CDouble(d, t), t); + r.push(new CDouble(d, t), t, null); } return r; } else if(object instanceof Object[]) { CArray r = new CArray(t); for(Object o : (Object[]) object) { - r.push((o == object) ? r : getMSObject(o, t), t); + r.push((o == object) ? r : getMSObject(o, t), t, null); } return r; } else if(object instanceof Collection) { return getMSObject(((Collection) object).toArray(), t); } else if(object instanceof Map) { Map map = ((Map) object); - CArray r = CArray.GetAssociativeArray(t); + CArray r = CArray.GetAssociativeArray(t, null, null); for(Object key : map.keySet()) { Object o = map.get(key); - r.set(key.toString(), (o == object) ? r : getMSObject(o, t), t); + r.set(key.toString(), (o == object) ? r : getMSObject(o, t), t, null); } return r; } else { @@ -1637,13 +1682,21 @@ public String getString(CResource res) { } } + /** + * @deprecated Use {@link #getJavaObject(Mixed, Environment)} instead. + */ + @Deprecated + public static Object getJavaObject(Mixed construct) { + return getJavaObject(construct, null); + } + /** * Given a MethodScript object, returns a java object. * * @param construct * @return */ - public static Object getJavaObject(Mixed construct) { + public static Object getJavaObject(Mixed construct, Environment env) { if((construct == null) || (construct instanceof CNull)) { return null; } else if(construct instanceof CVoid) { @@ -1654,19 +1707,19 @@ public static Object getJavaObject(Mixed construct) { return ((CInt) construct).getInt(); } else if(construct instanceof CDouble) { return ((CDouble) construct).getDouble(); - } else if(construct instanceof CString) { + } else if(InstanceofUtil.isInstanceof(construct, CString.class, env)) { return construct.val(); } else if(construct instanceof CByteArray) { return ((CByteArray) construct).asByteArrayCopy(); } else if(construct instanceof CResource) { return ((CResource) construct).getResource(); - } else if(construct.isInstanceOf(CArray.TYPE)) { + } else if(construct.isInstanceOf(CArray.TYPE, null, env)) { CArray array = (CArray) construct; if(array.isAssociative()) { HashMap map = new HashMap<>(); for(Mixed key : array.keySet()) { Mixed c = array.get(key.val(), Target.UNKNOWN); - map.put(key.val(), (c == array) ? map : getJavaObject(c)); + map.put(key.val(), (c == array) ? map : getJavaObject(c, env)); } return map; } else { @@ -1678,7 +1731,7 @@ public static Object getJavaObject(Mixed construct) { if(c == array) { a[i] = a; } else { - a[i] = getJavaObject(array.get(i, Target.UNKNOWN)); + a[i] = getJavaObject(array.get(i, Target.UNKNOWN), env); } if(a[i] != null) { if(clazz == null) { @@ -1724,7 +1777,7 @@ public static Object getJavaObject(Mixed construct) { } } } else { - return construct; + throw new ClassCastException(construct.getClass().getName() + " cannot be cast to a POJO"); } } diff --git a/src/main/java/com/laytonsmith/core/asm/LLVMFunction.java b/src/main/java/com/laytonsmith/core/asm/LLVMFunction.java index f74d46f15b..9d059867c0 100644 --- a/src/main/java/com/laytonsmith/core/asm/LLVMFunction.java +++ b/src/main/java/com/laytonsmith/core/asm/LLVMFunction.java @@ -194,7 +194,7 @@ public LogLevel profileAt() { } @Override - public String profileMessage(Mixed... args) { + public String profileMessage(Environment env, Mixed... args) { throw new UnsupportedOperationException("Not supported."); } diff --git a/src/main/java/com/laytonsmith/core/compiler/OptimizationUtilities.java b/src/main/java/com/laytonsmith/core/compiler/OptimizationUtilities.java index 561d407c3d..7b98877da6 100644 --- a/src/main/java/com/laytonsmith/core/compiler/OptimizationUtilities.java +++ b/src/main/java/com/laytonsmith/core/compiler/OptimizationUtilities.java @@ -81,12 +81,12 @@ public static String optimize(String script, Environment env, StringBuilder b = new StringBuilder(); //The root always contains null. for(ParseTree child : tree.getChildren()) { - b.append(optimize0(child)); + b.append(optimize0(child, env)); } return b.toString(); } - private static String optimize0(ParseTree node) { + private static String optimize0(ParseTree node, Environment env) { if(node.getData() instanceof CFunction) { StringBuilder b = new StringBuilder(); boolean first = true; @@ -96,7 +96,7 @@ private static String optimize0(ParseTree node) { b.append(","); } first = false; - b.append(optimize0(child)); + b.append(optimize0(child, env)); } b.append(")"); return b.toString(); @@ -111,7 +111,7 @@ private static String optimize0(ParseTree node) { return ((Variable) node.getData()).getVariableName(); } else if(node.getData() instanceof CSlice) { return node.getData().val(); - } else if(node.getData().isInstanceOf(CArray.TYPE)) { + } else if(node.getData().isInstanceOf(CArray.TYPE, null, env)) { //It's a hardcoded array. This only happens in the course of optimization, if //the optimizer adds a new array. We still need to handle it appropriately though. //The values in the array will be constant, guaranteed. @@ -124,7 +124,7 @@ private static String optimize0(ParseTree node) { b.append(","); } first = false; - b.append(optimize0(new ParseTree(n.get(key, Target.UNKNOWN), node.getFileOptions(), true))); + b.append(optimize0(new ParseTree(n.get(key, Target.UNKNOWN), node.getFileOptions(), true), env)); } b.append(")"); return b.toString(); diff --git a/src/main/java/com/laytonsmith/core/compiler/analysis/StaticAnalysis.java b/src/main/java/com/laytonsmith/core/compiler/analysis/StaticAnalysis.java index eacf81b141..5dab6016bd 100644 --- a/src/main/java/com/laytonsmith/core/compiler/analysis/StaticAnalysis.java +++ b/src/main/java/com/laytonsmith/core/compiler/analysis/StaticAnalysis.java @@ -449,7 +449,7 @@ public CClassType typecheck(ParseTree ast, Environment env, Set \\ and ' -> \' b.append("'").append(data.replace("\\", "\\\\").replace("\t", "\\t").replace("\n", "\\n") @@ -251,8 +251,8 @@ protected void execute(Mixed... values) throws ConfigRuntimeException, ProgramFl isVarArg = true; } if(isVarArg) { - if(!InstanceofUtil.isInstanceof(value.typeof(), varargType.getVarargsBaseType(), env)) { - throw new CRECastException("Expected type " + varargType + " but found " + value.typeof(), + if(!InstanceofUtil.isInstanceof(value.typeof(env), varargType.getVarargsBaseType(), env)) { + throw new CRECastException("Expected type " + varargType + " but found " + value.typeof(env), getTarget()); } vararg.push(value, value.getTarget()); @@ -294,9 +294,9 @@ protected void execute(Mixed... values) throws ConfigRuntimeException, ProgramFl // Check the return type of the closure to see if it matches the defined type // Normal execution. Mixed ret = ex.getReturn(); - if(!InstanceofUtil.isInstanceof(ret.typeof(), returnType, environment)) { + if(!InstanceofUtil.isInstanceof(ret.typeof(environment), returnType, environment)) { throw new CRECastException("Expected closure to return a value of type " + returnType.val() - + " but a value of type " + ret.typeof() + " was returned instead", ret.getTarget()); + + " but a value of type " + ret.typeof(environment) + " was returned instead", ret.getTarget()); } // Now rethrow it throw ex; diff --git a/src/main/java/com/laytonsmith/core/constructs/CMutablePrimitive.java b/src/main/java/com/laytonsmith/core/constructs/CMutablePrimitive.java index c32bb3d72d..b32896aecf 100644 --- a/src/main/java/com/laytonsmith/core/constructs/CMutablePrimitive.java +++ b/src/main/java/com/laytonsmith/core/constructs/CMutablePrimitive.java @@ -42,14 +42,21 @@ public boolean isDynamic() { return true; } + /** @deprecated Use {@link #set(Mixed, Target, Environment)} instead. */ + @Deprecated + public void set(Mixed value, Target t) { + set(value, t, null); + } + /** * Sets the value of the underlying primitive. Only primitives (and null) may be stored. * * @param value * @param t + * @param env */ - public void set(Mixed value, Target t) { - if(!value.isInstanceOf(ValueType.TYPE)) { + public void set(Mixed value, Target t, Environment env) { + if(!value.isInstanceOf(ValueType.TYPE, null, env)) { throw new CREFormatException("mutable_primitives can only store primitive values.", t); } this.value = value; diff --git a/src/main/java/com/laytonsmith/core/constructs/Construct.java b/src/main/java/com/laytonsmith/core/constructs/Construct.java index 1c267813f9..1d6f96bc3c 100644 --- a/src/main/java/com/laytonsmith/core/constructs/Construct.java +++ b/src/main/java/com/laytonsmith/core/constructs/Construct.java @@ -26,8 +26,6 @@ import java.util.Map.Entry; import java.util.Objects; import java.util.Set; -import java.util.SortedMap; -import java.util.TreeMap; import java.util.concurrent.atomic.AtomicInteger; import org.json.simple.JSONArray; import org.json.simple.JSONObject; @@ -167,6 +165,14 @@ public Construct clone() throws CloneNotSupportedException { return (Construct) super.clone(); } + /** + * @deprecated Use {@link #json_encode(Mixed, Target, Environment)} instead. + */ + @Deprecated + public static String json_encode(Mixed c, Target t) throws MarshalException { + return json_encode(c, t, null); + } + /** * This function takes a Construct, and turns it into a JSON value. If the construct is not one of the following, a * MarshalException is thrown: CArray, CBoolean, CDouble, CInt, CNull, CString, CVoid, Command. Currently @@ -183,15 +189,16 @@ public Construct clone() throws CloneNotSupportedException { * * @param c * @param t + * @param env * @return * @throws com.laytonsmith.core.exceptions.MarshalException */ - public static String json_encode(Mixed c, Target t) throws MarshalException { - return JSONValue.toJSONString(json_encode0(c, t)); + public static String json_encode(Mixed c, Target t, Environment env) throws MarshalException { + return JSONValue.toJSONString(json_encode0(c, t, env)); } - private static Object json_encode0(Mixed c, Target t) throws MarshalException { - if(c.isInstanceOf(CString.TYPE) || c instanceof Command) { + private static Object json_encode0(Mixed c, Target t, Environment env) throws MarshalException { + if(c.isInstanceOf(CString.TYPE, null, env) || c instanceof Command) { return c.val(); } else if(c instanceof CVoid) { return ""; @@ -203,22 +210,22 @@ private static Object json_encode0(Mixed c, Target t) throws MarshalException { return ((CBoolean) c).getBoolean(); } else if(c instanceof CNull) { return null; - } else if(c.isInstanceOf(CArray.TYPE)) { + } else if(c.isInstanceOf(CArray.TYPE, null, env)) { CArray ca = (CArray) c; if(!ca.inAssociativeMode()) { List list = new ArrayList(); for(int i = 0; i < ca.size(); i++) { - list.add(json_encode0(ca.get(i, t), t)); + list.add(json_encode0(ca.get(i, t), t, env)); } return list; } else { Map map = new HashMap(); for(String key : ca.stringKeySet()) { - map.put(key, json_encode0(ca.get(key, t), t)); + map.put(key, json_encode0(ca.get(key, t), t, env)); } return map; } - } else if(c.isInstanceOf(CClassType.TYPE)) { + } else if(c instanceof CClassType) { return c.val(); } else { throw new MarshalException("The type of " + c.getClass().getSimpleName() + " is not currently supported", c); @@ -410,42 +417,11 @@ public static Construct GetConstruct(Object o, boolean allowResources) throws Cl * @param c * @return * @throws ClassCastException + * @deprecated Use {@link Static#getJavaObject(Mixed, Environment)} instead. */ + @Deprecated public static Object GetPOJO(Mixed c) throws ClassCastException { - if(c instanceof CNull) { - return null; - } else if(InstanceofUtil.isInstanceof(c, CString.class, null)) { - return c.val(); - } else if(c instanceof CBoolean) { - return Boolean.valueOf(((CBoolean) c).getBoolean()); - } else if(InstanceofUtil.isInstanceof(c, CInt.class, null)) { - return Long.valueOf(((CInt) c).getInt()); - } else if(InstanceofUtil.isInstanceof(c, CDouble.class, null)) { - return Double.valueOf(((CDouble) c).getDouble()); - } else if(c.isInstanceOf(CByteArray.TYPE)) { - return ((CByteArray) c).asByteArrayCopy(); - } else if(c.isInstanceOf(CArray.TYPE)) { - CArray ca = (CArray) c; - if(ca.inAssociativeMode()) { - //SortedMap - SortedMap map = new TreeMap<>(); - for(Entry entry : ca.getAssociativeArray().entrySet()) { - map.put(entry.getKey(), GetPOJO(entry.getValue())); - } - return map; - } else { - //ArrayList - ArrayList list = new ArrayList((int) ca.size()); - for(Mixed construct : ca.getArray()) { - list.add(GetPOJO(construct)); - } - return list; - } - } else if(c instanceof CResource) { - return ((CResource) c).getResource(); - } else { - throw new ClassCastException(c.getClass().getName() + " cannot be cast to a POJO"); - } + return Static.getJavaObject(c); } public CString asString() { @@ -599,11 +575,27 @@ public CClassType getContainingClass() { return null; } + /** + * @deprecated Use {@link #isInstanceof(Mixed, CClassType, Environment)} instead. + */ + @Deprecated public static boolean isInstanceof(Mixed that, CClassType type) { - return that.getClass().isAnnotationPresent(typeof.class) && that.typeof().doesExtend(type); + return isInstanceof(that, type, null); + } + + public static boolean isInstanceof(Mixed that, CClassType type, Environment env) { + return that.getClass().isAnnotationPresent(typeof.class) && that.typeof(env).doesExtend(type); } + /** + * @deprecated Use {@link #isInstanceof(Mixed, Class, Environment)} instead. + */ + @Deprecated public static boolean isInstanceof(Mixed that, Class type) { + return isInstanceof(that, type, null); + } + + public static boolean isInstanceof(Mixed that, Class type, Environment env) { if(ClassDiscovery.GetClassAnnotation(that.getClass(), typeof.class) == null) { // This can happen in cases where we are in the middle of optimization. // This can perhaps be improved in the future, when we store the return @@ -611,8 +603,7 @@ public static boolean isInstanceof(Mixed that, Class type) { // but anyways, for now, just return false. return false; } - // TODO: We need the compiler environment here so we can look up custom types. - return that.typeof().doesExtend(CClassType.get(type)); + return that.typeof(env).doesExtend(CClassType.get(type)); } /** @@ -634,7 +625,7 @@ public boolean isInstanceOf(CClassType type, LeftHandGenericUse lhsGenericParame if(type.getNativeType() != null) { return type.getNativeType().isAssignableFrom(this.getClass()); } - return isInstanceof(this, type); + return isInstanceof(this, type, env); } @Override diff --git a/src/main/java/com/laytonsmith/core/constructs/IVariable.java b/src/main/java/com/laytonsmith/core/constructs/IVariable.java index e1a30dd1c0..c44e085579 100644 --- a/src/main/java/com/laytonsmith/core/constructs/IVariable.java +++ b/src/main/java/com/laytonsmith/core/constructs/IVariable.java @@ -49,9 +49,9 @@ public IVariable(CClassType type, String name, Mixed value, Target t, Environmen if(value instanceof CVoid) { throw new CRECastException("Void may not be assigned to a variable", t); } - if(!InstanceofUtil.isInstanceof(value.typeof(), type, env)) { + if(!InstanceofUtil.isInstanceof(value.typeof(env), type, env)) { throw new CRECastException(name + " is of type " + type.val() + ", but a value of type " - + value.typeof() + " was assigned to it.", t); + + value.typeof(env) + " was assigned to it.", t); } this.type = type; this.varValue = value; diff --git a/src/main/java/com/laytonsmith/core/events/Event.java b/src/main/java/com/laytonsmith/core/events/Event.java index 405e96fc80..1d4047b3d5 100644 --- a/src/main/java/com/laytonsmith/core/events/Event.java +++ b/src/main/java/com/laytonsmith/core/events/Event.java @@ -13,11 +13,16 @@ import com.laytonsmith.core.exceptions.EventException; import com.laytonsmith.core.exceptions.PrefilterNonMatchException; import com.laytonsmith.core.natives.interfaces.Mixed; +import com.laytonsmith.PureUtilities.Common.ReflectionUtils; +import java.util.Collections; import java.util.Map; +import java.util.Set; +import java.util.concurrent.ConcurrentHashMap; /** * This interface should be implemented to allow the bind() function to bind to a particular event type. To be * recognized as an event type, it should also tag itself with @api, and it will be included in the EventList. + * * @param The underlying event type. */ public interface Event extends Comparable>, Documentation { @@ -48,8 +53,8 @@ public interface Event extends Comparable< * parameters. * * For subclasses who properly implement {@link #getPrefilters}, this should be changed to throw an - * UnsupportedOperationException until the method is fully removed. For classes that extend AbstractEvent, it - * should simply be removed. + * UnsupportedOperationException until the method is fully removed. For classes that extend AbstractEvent, it should + * simply be removed. * * @param prefilter The prefilter map, provided by the script * @param e The bindable event itself @@ -80,10 +85,11 @@ public interface Event extends Comparable< * is considered a fatal error, and will throw an uncatchable CH exception. * * @param e The bindable event + * @param env The environment. * @return The map build from the event * @throws com.laytonsmith.core.exceptions.EventException If some exception occurs during map building */ - public Map evaluate(TBindableEvent e) throws EventException; + public Map evaluate(TBindableEvent e, Environment env) throws EventException; /** * This is called to determine if an event is cancellable in the first place @@ -177,9 +183,10 @@ public interface Event extends Comparable< * @param key * @param value * @param event + * @param env The environment. * @return */ - public boolean modifyEvent(String key, Mixed value, TBindableEvent event); + public boolean modifyEvent(String key, Mixed value, TBindableEvent event, Environment env); /** * Returns if this event is cancelled. If the event is not cancellable, false should be returned, though this case @@ -235,9 +242,10 @@ public interface Event extends Comparable< public Map> getPrefilters(); /** - * Called after prefilters are individually validated, and can be used when there is additional validation - * that can be done across multiple prefilters, i.e. when the value of one prefilter is as such, then - * another prefilter may have different behavior. + * Called after prefilters are individually validated, and can be used when there is additional validation that can + * be done across multiple prefilters, i.e. when the value of one prefilter is as such, then another prefilter may + * have different behavior. + * * @param prefilters The full set of prefilters. * @param env The environment. * @throws com.laytonsmith.core.exceptions.ConfigCompileException @@ -246,4 +254,51 @@ public interface Event extends Comparable< public void validatePrefilters(Map, ParseTree> prefilters, Environment env) throws ConfigCompileException, ConfigCompileGroupException; + // Reflection bridge for backward compatibility with 3rd-party events + // that still implement the old modifyEvent(String, Mixed, BindableEvent) signature. + // Added 2026-02-23. + Set> OLD_MODIFY_EVENT_CACHE = Collections.newSetFromMap(new ConcurrentHashMap<>()); + + @SuppressWarnings({"unchecked", "checkstyle:methodtypeparametername"}) + static boolean ExecuteModifyEvent(Event event, + String key, Mixed value, + TBindableEvent underlying, Environment env) { + if(OLD_MODIFY_EVENT_CACHE.contains(event.getClass())) { + return (boolean) ReflectionUtils.invokeMethod(event.getClass(), event, "modifyEvent", + new Class[]{String.class, Mixed.class, BindableEvent.class}, + new Object[]{key, value, underlying}); + } + try { + return event.modifyEvent(key, value, underlying, env); + } catch(AbstractMethodError e) { + OLD_MODIFY_EVENT_CACHE.add(event.getClass()); + return (boolean) ReflectionUtils.invokeMethod(event.getClass(), event, "modifyEvent", + new Class[]{String.class, Mixed.class, BindableEvent.class}, + new Object[]{key, value, underlying}); + } + } + + // Reflection bridge for backward compatibility with 3rd-party events + // that still implement the old evaluate(BindableEvent) signature. + // Added 2026-02-23. + Set> OLD_EVALUATE_CACHE = Collections.newSetFromMap(new ConcurrentHashMap<>()); + + @SuppressWarnings({"unchecked", "checkstyle:methodtypeparametername"}) + static Map ExecuteEvaluate( + Event event, TBindableEvent e, Environment env) throws EventException { + if(OLD_EVALUATE_CACHE.contains(event.getClass())) { + return (Map) ReflectionUtils.invokeMethod(event.getClass(), event, "evaluate", + new Class[]{BindableEvent.class}, + new Object[]{e}); + } + try { + return event.evaluate(e, env); + } catch(AbstractMethodError ex) { + OLD_EVALUATE_CACHE.add(event.getClass()); + return (Map) ReflectionUtils.invokeMethod(event.getClass(), event, "evaluate", + new Class[]{BindableEvent.class}, + new Object[]{e}); + } + } + } diff --git a/src/main/java/com/laytonsmith/core/events/EventUtils.java b/src/main/java/com/laytonsmith/core/events/EventUtils.java index efaa496b65..cdc1d1bd39 100644 --- a/src/main/java/com/laytonsmith/core/events/EventUtils.java +++ b/src/main/java/com/laytonsmith/core/events/EventUtils.java @@ -337,7 +337,7 @@ public static void FireListeners(SortedSet toRun, Event driver, Bind try { //We must re-set the active event's bound event and parsed event activeEvent.setBoundEvent(b); - activeEvent.setParsedEvent(driver.evaluate(e)); + activeEvent.setParsedEvent(Event.ExecuteEvaluate(driver, e, b.getEnvironment())); b.trigger(activeEvent); } catch (FunctionReturnException ex) { //We also know how to deal with this diff --git a/src/main/java/com/laytonsmith/core/events/drivers/BlockEvents.java b/src/main/java/com/laytonsmith/core/events/drivers/BlockEvents.java index 2281ee87ab..c7758567e3 100644 --- a/src/main/java/com/laytonsmith/core/events/drivers/BlockEvents.java +++ b/src/main/java/com/laytonsmith/core/events/drivers/BlockEvents.java @@ -70,12 +70,12 @@ public boolean matches(Map prefilter, BindableEvent e) throws Pre } @Override - public boolean modifyEvent(String key, Mixed value, BindableEvent e) { + public boolean modifyEvent(String key, Mixed value, BindableEvent e, Environment env) { return false; } @Override - public Map evaluate(BindableEvent e) throws EventException { + public Map evaluate(BindableEvent e, Environment env) throws EventException { MCBlockPistonEvent event = (MCBlockPistonEvent) e; Target t = Target.UNKNOWN; Map map = evaluate_helper(event); @@ -156,8 +156,8 @@ public Driver driver() { } @Override - public Map evaluate(BindableEvent e) throws EventException { - return super.evaluate(e); + public Map evaluate(BindableEvent e, Environment env) throws EventException { + return super.evaluate(e, env); } @Override @@ -207,12 +207,12 @@ public void bind(BoundEvent event) { + " is deprecated for \"block\". Converted to " + mat.getName(), event.getTarget()); } else if(prefilter.containsKey("type")) { Mixed cid = prefilter.get("type"); - if(cid.isInstanceOf(CInt.TYPE)) { + if(cid.isInstanceOf(CInt.TYPE, null, event.getEnvironment())) { int id = (int) ((CInt) cid).getInt(); int data = 0; if(prefilter.containsKey("data")) { Mixed cdata = prefilter.get("data"); - if(cdata.isInstanceOf(CInt.TYPE)) { + if(cdata.isInstanceOf(CInt.TYPE, null, event.getEnvironment())) { data = (int) ((CInt) cdata).getInt(); } } @@ -249,7 +249,7 @@ public boolean matches(Map prefilter, BindableEvent e) throws Pre } @Override - public Map evaluate(BindableEvent e) throws EventException { + public Map evaluate(BindableEvent e, Environment env) throws EventException { MCBlockBreakEvent event = (MCBlockBreakEvent) e; Target t = Target.UNKNOWN; Map map = evaluate_helper(event); @@ -272,12 +272,12 @@ public Map evaluate(BindableEvent e) throws EventException { } @Override - public boolean modifyEvent(String key, Mixed value, BindableEvent e) { + public boolean modifyEvent(String key, Mixed value, BindableEvent e, Environment env) { MCBlockBreakEvent event = (MCBlockBreakEvent) e; if(key.equals("drops")) { List drops = new ArrayList<>(); - if(value.isInstanceOf(CArray.TYPE)) { + if(value.isInstanceOf(CArray.TYPE, null, env)) { CArray arr = (CArray) value; for(int i = 0; i < arr.size(); i++) { CArray item = ArgumentValidation.getArray(arr.get(i, value.getTarget()), value.getTarget()); @@ -292,7 +292,7 @@ public boolean modifyEvent(String key, Mixed value, BindableEvent e) { } if(key.equals("xp")) { - if(value.isInstanceOf(CInt.TYPE)) { + if(value.isInstanceOf(CInt.TYPE, null, env)) { int xp = Integer.parseInt(value.val()); event.setExpToDrop(xp); return true; @@ -346,12 +346,12 @@ public void bind(BoundEvent event) { + " is deprecated for \"block\". Converted to " + mat.getName(), event.getTarget()); } else if(prefilter.containsKey("type")) { Mixed cid = prefilter.get("type"); - if(cid.isInstanceOf(CInt.TYPE)) { + if(cid.isInstanceOf(CInt.TYPE, null, event.getEnvironment())) { int id = (int) ((CInt) cid).getInt(); int data = 0; if(prefilter.containsKey("data")) { Mixed cdata = prefilter.get("data"); - if(cdata.isInstanceOf(CInt.TYPE)) { + if(cdata.isInstanceOf(CInt.TYPE, null, event.getEnvironment())) { data = (int) ((CInt) cdata).getInt(); } } @@ -389,7 +389,7 @@ public boolean matches(Map prefilter, BindableEvent e) throws Pre } @Override - public Map evaluate(BindableEvent e) throws EventException { + public Map evaluate(BindableEvent e, Environment env) throws EventException { MCBlockPlaceEvent event = (MCBlockPlaceEvent) e; Target t = Target.UNKNOWN; Map map = evaluate_helper(e); @@ -422,7 +422,7 @@ public Map evaluate(BindableEvent e) throws EventException { } @Override - public boolean modifyEvent(String key, Mixed value, BindableEvent e) { + public boolean modifyEvent(String key, Mixed value, BindableEvent e, Environment env) { MCBlockPlaceEvent event = (MCBlockPlaceEvent) e; if(key.equals("block")) { @@ -442,7 +442,7 @@ public boolean modifyEvent(String key, Mixed value, BindableEvent e) { + " is deprecated for \"block\". Converted to " + mat.getName(), value.getTarget()); return true; } else if(key.equals("type")) { - if(value.isInstanceOf(CInt.TYPE)) { + if(value.isInstanceOf(CInt.TYPE, null, env)) { MCMaterial mat = StaticLayer.GetMaterialFromLegacy((int) ((CInt) value).getInt(), 0); event.getBlock().setType(mat); MSLog.GetLogger().w(MSLog.Tags.DEPRECATION, "Mutable data key \"type\" in " + getName() @@ -497,12 +497,12 @@ public void bind(BoundEvent event) { + " is deprecated for \"block\". Converted to " + mat.getName(), event.getTarget()); } else if(prefilter.containsKey("type")) { Mixed cid = prefilter.get("type"); - if(cid.isInstanceOf(CInt.TYPE)) { + if(cid.isInstanceOf(CInt.TYPE, null, event.getEnvironment())) { int id = (int) ((CInt) cid).getInt(); int data = 0; if(prefilter.containsKey("data")) { Mixed cdata = prefilter.get("data"); - if(cdata.isInstanceOf(CInt.TYPE)) { + if(cdata.isInstanceOf(CInt.TYPE, null, event.getEnvironment())) { data = (int) ((CInt) cdata).getInt(); } } @@ -534,7 +534,7 @@ public boolean matches(Map prefilter, BindableEvent e) throws Pre } @Override - public Map evaluate(BindableEvent e) throws EventException { + public Map evaluate(BindableEvent e, Environment env) throws EventException { MCBlockBurnEvent event = (MCBlockBurnEvent) e; Target t = Target.UNKNOWN; Map map = evaluate_helper(event); @@ -555,7 +555,7 @@ public Map evaluate(BindableEvent e) throws EventException { } @Override - public boolean modifyEvent(String key, Mixed value, BindableEvent e) { + public boolean modifyEvent(String key, Mixed value, BindableEvent e, Environment env) { return false; } } @@ -608,7 +608,7 @@ public boolean matches(Map prefilter, BindableEvent e) throws Pre } @Override - public Map evaluate(BindableEvent e) throws EventException { + public Map evaluate(BindableEvent e, Environment env) throws EventException { if(!(e instanceof MCBlockIgniteEvent)) { throw new EventException("Cannot convert e to MCBlockIgniteEvent"); } @@ -637,7 +637,7 @@ public Map evaluate(BindableEvent e) throws EventException { } @Override - public boolean modifyEvent(String key, Mixed value, BindableEvent event) { + public boolean modifyEvent(String key, Mixed value, BindableEvent event, Environment env) { return false; } } @@ -680,12 +680,12 @@ public void bind(BoundEvent event) { + " is deprecated for \"block\". Converted to " + mat.getName(), event.getTarget()); } else if(prefilter.containsKey("type")) { Mixed cid = prefilter.get("type"); - if(cid.isInstanceOf(CInt.TYPE)) { + if(cid.isInstanceOf(CInt.TYPE, null, event.getEnvironment())) { int id = (int) ((CInt) cid).getInt(); int data = 0; if(prefilter.containsKey("data")) { Mixed cdata = prefilter.get("data"); - if(cdata.isInstanceOf(CInt.TYPE)) { + if(cdata.isInstanceOf(CInt.TYPE, null, event.getEnvironment())) { data = (int) ((CInt) cdata).getInt(); } } @@ -705,12 +705,12 @@ public void bind(BoundEvent event) { + " is deprecated for \"toblock\". Converted to " + mat.getName(), event.getTarget()); } else if(prefilter.containsKey("totype")) { Mixed cid = prefilter.get("totype"); - if(cid.isInstanceOf(CInt.TYPE)) { + if(cid.isInstanceOf(CInt.TYPE, null, event.getEnvironment())) { int id = (int) ((CInt) cid).getInt(); int data = 0; if(prefilter.containsKey("todata")) { Mixed cdata = prefilter.get("todata"); - if(cdata.isInstanceOf(CInt.TYPE)) { + if(cdata.isInstanceOf(CInt.TYPE, null, event.getEnvironment())) { data = (int) ((CInt) cdata).getInt(); } } @@ -748,7 +748,7 @@ public boolean matches(Map prefilter, BindableEvent e) throws Pre } @Override - public Map evaluate(BindableEvent e) throws EventException { + public Map evaluate(BindableEvent e, Environment env) throws EventException { if(!(e instanceof MCBlockFromToEvent)) { throw new EventException("Cannot convert e to MCBlockFromToEvent"); } @@ -776,14 +776,14 @@ public Driver driver() { } @Override - public boolean modifyEvent(String key, Mixed value, BindableEvent event) { + public boolean modifyEvent(String key, Mixed value, BindableEvent event, Environment env) { if(!(event instanceof MCBlockFromToEvent)) { return false; } MCBlockFromToEvent e = (MCBlockFromToEvent) event; if(key.equals("block")) { MCBlock block = e.getBlock(); - if(value.isInstanceOf(CArray.TYPE)) { + if(value.isInstanceOf(CArray.TYPE, null, env)) { CArray blockArray = (CArray) value; if(blockArray.containsKey("name")) { Mixed name = blockArray.get("name", value.getTarget()); @@ -839,7 +839,7 @@ public boolean modifyEvent(String key, Mixed value, BindableEvent event) { } if(key.equals("toblock")) { MCBlock block = e.getToBlock(); - if(value.isInstanceOf(CArray.TYPE)) { + if(value.isInstanceOf(CArray.TYPE, null, env)) { CArray blockArray = (CArray) value; if(blockArray.containsKey("name")) { Mixed name = blockArray.get("name", value.getTarget()); @@ -948,7 +948,7 @@ public boolean matches(Map prefilter, BindableEvent e) throws Pre } @Override - public Map evaluate(BindableEvent e) throws EventException { + public Map evaluate(BindableEvent e, Environment env) throws EventException { if(!(e instanceof MCSignChangeEvent)) { throw new EventException("Cannot convert e to MCSignChangeEvent"); } @@ -964,7 +964,7 @@ public Map evaluate(BindableEvent e) throws EventException { } @Override - public boolean modifyEvent(String key, Mixed value, BindableEvent event) { + public boolean modifyEvent(String key, Mixed value, BindableEvent event, Environment env) { if(!(event instanceof MCSignChangeEvent)) { return false; } @@ -972,7 +972,7 @@ public boolean modifyEvent(String key, Mixed value, BindableEvent event) { // Allow changing everything at once. if(key.equals("text")) { - if(!(value.isInstanceOf(CArray.TYPE))) { + if(!(value.isInstanceOf(CArray.TYPE, null, env))) { return false; } @@ -1081,7 +1081,7 @@ public boolean matches(Map prefilter, BindableEvent e) throws Pre } @Override - public Map evaluate(BindableEvent e) throws EventException { + public Map evaluate(BindableEvent e, Environment env) throws EventException { MCBlockDispenseEvent event = (MCBlockDispenseEvent) e; Target t = Target.UNKNOWN; Map map = evaluate_helper(e); @@ -1100,7 +1100,7 @@ public Map evaluate(BindableEvent e) throws EventException { } @Override - public boolean modifyEvent(String key, Mixed value, BindableEvent event) { + public boolean modifyEvent(String key, Mixed value, BindableEvent event, Environment env) { if(event instanceof MCBlockDispenseEvent) { if("item".equals(key)) { ((MCBlockDispenseEvent) event).setItem(ObjectGenerator.GetGenerator().item(value, value.getTarget())); @@ -1139,12 +1139,12 @@ public void bind(BoundEvent event) { + " is deprecated for \"block\". Converted to " + mat.getName(), event.getTarget()); } else if(prefilter.containsKey("oldtype")) { Mixed cid = prefilter.get("oldtype"); - if(cid.isInstanceOf(CInt.TYPE)) { + if(cid.isInstanceOf(CInt.TYPE, null, event.getEnvironment())) { int id = (int) ((CInt) cid).getInt(); int data = 0; if(prefilter.containsKey("olddata")) { Mixed cdata = prefilter.get("olddata"); - if(cdata.isInstanceOf(CInt.TYPE)) { + if(cdata.isInstanceOf(CInt.TYPE, null, event.getEnvironment())) { data = (int) ((CInt) cdata).getInt(); } } @@ -1164,12 +1164,12 @@ public void bind(BoundEvent event) { + " is deprecated for \"newblock\". Converted to " + mat.getName(), event.getTarget()); } else if(prefilter.containsKey("newtype")) { Mixed cid = prefilter.get("newtype"); - if(cid.isInstanceOf(CInt.TYPE)) { + if(cid.isInstanceOf(CInt.TYPE, null, event.getEnvironment())) { int id = (int) ((CInt) cid).getInt(); int data = 0; if(prefilter.containsKey("newdata")) { Mixed cdata = prefilter.get("newdata"); - if(cdata.isInstanceOf(CInt.TYPE)) { + if(cdata.isInstanceOf(CInt.TYPE, null, event.getEnvironment())) { data = (int) ((CInt) cdata).getInt(); } } @@ -1223,7 +1223,7 @@ public boolean matches(Map prefilter, BindableEvent event) throws } @Override - public Map evaluate(BindableEvent event) throws EventException { + public Map evaluate(BindableEvent event, Environment env) throws EventException { if(!(event instanceof MCBlockGrowEvent)) { throw new EventException("Cannot convert event to BlockGrowEvent"); } @@ -1238,7 +1238,7 @@ public Map evaluate(BindableEvent event) throws EventException { } @Override - public boolean modifyEvent(String key, Mixed value, BindableEvent e) { + public boolean modifyEvent(String key, Mixed value, BindableEvent e, Environment env) { return false; } } @@ -1278,7 +1278,7 @@ public boolean matches(Map prefilter, BindableEvent event) throws } @Override - public Map evaluate(BindableEvent event) throws EventException { + public Map evaluate(BindableEvent event, Environment env) throws EventException { if(!(event instanceof MCNotePlayEvent)) { throw new EventException("Cannot convert event to NotePlayEvent"); } @@ -1295,7 +1295,7 @@ public Map evaluate(BindableEvent event) throws EventException { } @Override - public boolean modifyEvent(String key, Mixed value, BindableEvent e) { + public boolean modifyEvent(String key, Mixed value, BindableEvent e, Environment env) { MSLog.GetLogger().w(MSLog.Tags.DEPRECATION, "Modifying the instrument or note for note_play" + " events is no longer supported.", value.getTarget()); return false; @@ -1343,7 +1343,7 @@ public void bind(BoundEvent event) { + " is deprecated for \"block\". Converted to " + mat.getName(), event.getTarget()); } else if(prefilter.containsKey("oldtype")) { Mixed cid = prefilter.get("oldtype"); - if(cid.isInstanceOf(CInt.TYPE)) { + if(cid.isInstanceOf(CInt.TYPE, null, event.getEnvironment())) { int id = (int) ((CInt) cid).getInt(); MCMaterial mat = StaticLayer.GetMaterialFromLegacy(id, 0); if(mat == null) { @@ -1376,7 +1376,7 @@ public boolean matches(Map prefilter, BindableEvent e) throws Pre } @Override - public Map evaluate(BindableEvent e) throws EventException { + public Map evaluate(BindableEvent e, Environment env) throws EventException { if(!(e instanceof MCBlockFadeEvent)) { throw new EventException("Cannot convert event to BlockFadeEvent"); } @@ -1392,7 +1392,7 @@ public Map evaluate(BindableEvent e) throws EventException { } @Override - public boolean modifyEvent(String key, Mixed value, BindableEvent event) { + public boolean modifyEvent(String key, Mixed value, BindableEvent event, Environment env) { return false; } } @@ -1432,7 +1432,7 @@ public boolean matches(Map prefilter, BindableEvent e) throws Pre } @Override - public Map evaluate(BindableEvent e) throws EventException { + public Map evaluate(BindableEvent e, Environment env) throws EventException { if(!(e instanceof MCBlockExplodeEvent)) { throw new EventException("Cannot convert event to BlockExplodeEvent"); } @@ -1452,7 +1452,7 @@ public Map evaluate(BindableEvent e) throws EventException { } @Override - public boolean modifyEvent(String key, Mixed value, BindableEvent event) { + public boolean modifyEvent(String key, Mixed value, BindableEvent event, Environment env) { if(event instanceof MCBlockExplodeEvent) { MCBlockExplodeEvent e = (MCBlockExplodeEvent) event; if(key.equals("yield")) { @@ -1460,7 +1460,7 @@ public boolean modifyEvent(String key, Mixed value, BindableEvent event) { return true; } if(key.equals("blocks")) { - if(value.isInstanceOf(CArray.TYPE)) { + if(value.isInstanceOf(CArray.TYPE, null, env)) { CArray ba = (CArray) value; List blocks = new ArrayList<>(); for(Mixed m : ba.asList()) { @@ -1522,7 +1522,7 @@ public boolean matches(Map prefilter, BindableEvent e) throws Pre } @Override - public Map evaluate(BindableEvent e) throws EventException { + public Map evaluate(BindableEvent e, Environment env) throws EventException { if(!(e instanceof MCBlockFormEvent)) { throw new EventException("Cannot convert event to MCBlockFormEvent"); } else { @@ -1537,7 +1537,7 @@ public Map evaluate(BindableEvent e) throws EventException { } @Override - public boolean modifyEvent(String key, Mixed value, BindableEvent e) { + public boolean modifyEvent(String key, Mixed value, BindableEvent e, Environment env) { return false; } } diff --git a/src/main/java/com/laytonsmith/core/events/drivers/CmdlineEvents.java b/src/main/java/com/laytonsmith/core/events/drivers/CmdlineEvents.java index 9f8132b40e..9fd9216acd 100644 --- a/src/main/java/com/laytonsmith/core/events/drivers/CmdlineEvents.java +++ b/src/main/java/com/laytonsmith/core/events/drivers/CmdlineEvents.java @@ -112,7 +112,7 @@ public Object _GetObject() { } @Override - public Map evaluate(BindableEvent e) throws EventException { + public Map evaluate(BindableEvent e, Environment env) throws EventException { Map map = new HashMap<>(); map.put("time", new CInt(System.currentTimeMillis(), Target.UNKNOWN)); return map; @@ -124,7 +124,7 @@ public Driver driver() { } @Override - public boolean modifyEvent(String key, Mixed value, BindableEvent event) { + public boolean modifyEvent(String key, Mixed value, BindableEvent event, Environment env) { return false; } @@ -172,7 +172,7 @@ public BindableEvent convert(CArray manualObject, Target t, Environment env) { } @Override - public Map evaluate(BindableEvent e) throws EventException { + public Map evaluate(BindableEvent e, Environment env) throws EventException { CmdlinePromptInput cpi = (CmdlinePromptInput) e; Map map = new HashMap<>(); map.put("command", new CString(cpi.getCommand(), Target.UNKNOWN)); @@ -186,7 +186,7 @@ public Driver driver() { } @Override - public boolean modifyEvent(String key, Mixed value, BindableEvent event) { + public boolean modifyEvent(String key, Mixed value, BindableEvent event, Environment env) { return false; } @@ -263,7 +263,7 @@ public boolean matches(Map prefilter, BindableEvent e) throws Pre } @Override - public Map evaluate(BindableEvent e) throws EventException { + public Map evaluate(BindableEvent e, Environment env) throws EventException { return Collections.EMPTY_MAP; } @@ -273,7 +273,7 @@ public Driver driver() { } @Override - public boolean modifyEvent(String key, Mixed value, BindableEvent event) { + public boolean modifyEvent(String key, Mixed value, BindableEvent event, Environment env) { return false; } diff --git a/src/main/java/com/laytonsmith/core/events/drivers/EntityEvents.java b/src/main/java/com/laytonsmith/core/events/drivers/EntityEvents.java index 768ecc3eff..b18ebbf558 100644 --- a/src/main/java/com/laytonsmith/core/events/drivers/EntityEvents.java +++ b/src/main/java/com/laytonsmith/core/events/drivers/EntityEvents.java @@ -142,7 +142,7 @@ public boolean matches(Map prefilter, BindableEvent e) throws Pre } @Override - public Map evaluate(BindableEvent e) throws EventException { + public Map evaluate(BindableEvent e, Environment env) throws EventException { if(e instanceof MCItemDespawnEvent) { Target t = Target.UNKNOWN; MCItemDespawnEvent event = (MCItemDespawnEvent) e; @@ -163,7 +163,7 @@ public Driver driver() { @Override public boolean modifyEvent(String key, Mixed value, - BindableEvent event) { + BindableEvent event, Environment env) { return false; } @@ -217,7 +217,7 @@ public boolean matches(Map prefilter, BindableEvent e) throws Pre } @Override - public Map evaluate(BindableEvent e) throws EventException { + public Map evaluate(BindableEvent e, Environment env) throws EventException { if(e instanceof MCItemSpawnEvent) { Target t = Target.UNKNOWN; MCItemSpawnEvent event = (MCItemSpawnEvent) e; @@ -237,7 +237,7 @@ public Driver driver() { } @Override - public boolean modifyEvent(String key, Mixed value, BindableEvent event) { + public boolean modifyEvent(String key, Mixed value, BindableEvent event, Environment env) { if(event instanceof MCItemSpawnEvent) { if("item".equals(key)) { ((MCItemSpawnEvent) event).getEntity().setItemStack(ObjectGenerator.GetGenerator().item(value, value.getTarget())); @@ -306,7 +306,7 @@ public boolean matches(Map prefilter, BindableEvent event) throws } @Override - public Map evaluate(BindableEvent event) throws EventException { + public Map evaluate(BindableEvent event, Environment env) throws EventException { if(event instanceof MCEntityExplodeEvent) { Target t = Target.UNKNOWN; MCEntityExplodeEvent e = (MCEntityExplodeEvent) event; @@ -333,7 +333,7 @@ public Driver driver() { } @Override - public boolean modifyEvent(String key, Mixed value, BindableEvent event) { + public boolean modifyEvent(String key, Mixed value, BindableEvent event, Environment env) { if(event instanceof MCEntityExplodeEvent) { MCEntityExplodeEvent e = (MCEntityExplodeEvent) event; if(key.equals("yield")) { @@ -341,7 +341,7 @@ public boolean modifyEvent(String key, Mixed value, BindableEvent event) { return true; } if(key.equals("blocks")) { - if(value.isInstanceOf(CArray.TYPE)) { + if(value.isInstanceOf(CArray.TYPE, null, env)) { CArray ba = (CArray) value; List blocks = new ArrayList<>(); for(String b : ba.stringKeySet()) { @@ -419,7 +419,7 @@ public BindableEvent convert(CArray manualObject, Target t, Environment env) { } @Override - public Map evaluate(BindableEvent event) throws EventException { + public Map evaluate(BindableEvent event, Environment env) throws EventException { Target t = Target.UNKNOWN; MCProjectileHitEvent e = (MCProjectileHitEvent) event; Map ret = evaluate_helper(e); @@ -458,7 +458,7 @@ public Driver driver() { } @Override - public boolean modifyEvent(String key, Mixed value, BindableEvent event) { + public boolean modifyEvent(String key, Mixed value, BindableEvent event, Environment env) { if(event instanceof MCProjectileHitEvent) { MCProjectileHitEvent e = (MCProjectileHitEvent) event; if(key.equalsIgnoreCase("shooter")) { @@ -539,7 +539,7 @@ public boolean matches(Map prefilter, BindableEvent event) throws } @Override - public Map evaluate(BindableEvent event) throws EventException { + public Map evaluate(BindableEvent event, Environment env) throws EventException { if(event instanceof MCProjectileLaunchEvent) { MCProjectileLaunchEvent projectileLaunchEvent = (MCProjectileLaunchEvent) event; Map mapEvent = evaluate_helper(event); @@ -577,7 +577,7 @@ public Map evaluate(BindableEvent event) throws EventException { } @Override - public boolean modifyEvent(String key, Mixed value, BindableEvent event) { + public boolean modifyEvent(String key, Mixed value, BindableEvent event, Environment env) { if(event instanceof MCProjectileLaunchEvent) { MCProjectileLaunchEvent projectileLaunchEvent = (MCProjectileLaunchEvent) event; if(key.equals("velocity")) { @@ -639,7 +639,7 @@ public boolean matches(Map prefilter, BindableEvent e) } @Override - public Map evaluate(BindableEvent event) + public Map evaluate(BindableEvent event, Environment env) throws EventException { if(event instanceof MCEntityDeathEvent) { MCEntityDeathEvent e = (MCEntityDeathEvent) event; @@ -673,7 +673,7 @@ public Driver driver() { } @Override - public boolean modifyEvent(String key, Mixed value, BindableEvent event) { + public boolean modifyEvent(String key, Mixed value, BindableEvent event, Environment env) { if(event instanceof MCEntityDeathEvent) { MCEntityDeathEvent e = (MCEntityDeathEvent) event; if(key.equals("xp")) { @@ -684,7 +684,7 @@ public boolean modifyEvent(String key, Mixed value, BindableEvent event) { if(value instanceof CNull) { value = new CArray(value.getTarget()); } - if(!(value.isInstanceOf(CArray.TYPE))) { + if(!(value.isInstanceOf(CArray.TYPE, null, env))) { throw new CRECastException("drops must be an array, or null", value.getTarget()); } e.clearDrops(); @@ -748,7 +748,7 @@ public boolean matches(Map prefilter, BindableEvent event) throws } @Override - public Map evaluate(BindableEvent event) throws EventException { + public Map evaluate(BindableEvent event, Environment env) throws EventException { if(!(event instanceof MCCreatureSpawnEvent)) { throw new EventException("Could not convert to MCCreatureSpawnEvent"); } @@ -768,7 +768,7 @@ public Driver driver() { } @Override - public boolean modifyEvent(String key, Mixed value, BindableEvent event) { + public boolean modifyEvent(String key, Mixed value, BindableEvent event, Environment env) { MCCreatureSpawnEvent e = (MCCreatureSpawnEvent) event; if(key.equals("type")) { MCEntityType type; @@ -848,8 +848,8 @@ public boolean matches(Map prefilter, BindableEvent event) } @Override - public Map evaluate(BindableEvent e) - throws EventException { + public Map evaluate(BindableEvent e, + Environment env) throws EventException { if(e instanceof MCEntityDamageEvent) { MCEntityDamageEvent event = (MCEntityDamageEvent) e; Map map = evaluate_helper(e); @@ -869,7 +869,7 @@ public Driver driver() { @Override public boolean modifyEvent(String key, Mixed value, - BindableEvent event) { + BindableEvent event, Environment env) { MCEntityDamageEvent e = (MCEntityDamageEvent) event; if(key.equals("amount")) { e.setDamage(ArgumentValidation.getDouble(value, value.getTarget())); @@ -925,8 +925,8 @@ public boolean matches(Map prefilter, BindableEvent event) } @Override - public Map evaluate(BindableEvent e) - throws EventException { + public Map evaluate(BindableEvent e, + Environment env) throws EventException { if(e instanceof MCPlayerInteractEntityEvent) { MCPlayerInteractEntityEvent event = (MCPlayerInteractEntityEvent) e; Map map = evaluate_helper(e); @@ -959,7 +959,7 @@ public Driver driver() { @Override public boolean modifyEvent(String key, Mixed value, - BindableEvent event) { + BindableEvent event, Environment env) { return false; } @@ -1016,8 +1016,8 @@ public boolean matches(Map prefilter, BindableEvent event) } @Override - public Map evaluate(BindableEvent e) - throws EventException { + public Map evaluate(BindableEvent e, + Environment env) throws EventException { if(e instanceof MCPlayerInteractAtEntityEvent) { MCPlayerInteractAtEntityEvent event = (MCPlayerInteractAtEntityEvent) e; Map map = evaluate_helper(e); @@ -1050,7 +1050,7 @@ public Driver driver() { } @Override - public boolean modifyEvent(String key, Mixed value, BindableEvent event) { + public boolean modifyEvent(String key, Mixed value, BindableEvent event, Environment env) { return false; } @@ -1118,7 +1118,7 @@ public boolean matches(Map prefilter, BindableEvent e) throws Pre } @Override - public Map evaluate(BindableEvent e) throws EventException { + public Map evaluate(BindableEvent e, Environment env) throws EventException { if(e instanceof MCPlayerDropItemEvent) { MCPlayerDropItemEvent event = (MCPlayerDropItemEvent) e; Map map = evaluate_helper(e); @@ -1133,7 +1133,7 @@ public Map evaluate(BindableEvent e) throws EventException { } @Override - public boolean modifyEvent(String key, Mixed value, BindableEvent event) { + public boolean modifyEvent(String key, Mixed value, BindableEvent event, Environment env) { if(event instanceof MCPlayerDropItemEvent) { MCPlayerDropItemEvent e = (MCPlayerDropItemEvent) event; @@ -1197,7 +1197,7 @@ public boolean matches(Map prefilter, BindableEvent e) throws Pre } @Override - public Map evaluate(BindableEvent e) throws EventException { + public Map evaluate(BindableEvent e, Environment env) throws EventException { if(e instanceof MCPlayerPickupItemEvent) { MCPlayerPickupItemEvent event = (MCPlayerPickupItemEvent) e; Map map = evaluate_helper(e); @@ -1216,7 +1216,7 @@ public Driver driver() { } @Override - public boolean modifyEvent(String key, Mixed value, BindableEvent event) { + public boolean modifyEvent(String key, Mixed value, BindableEvent event, Environment env) { if(event instanceof MCPlayerPickupItemEvent) { MCPlayerPickupItemEvent e = (MCPlayerPickupItemEvent) event; @@ -1274,8 +1274,8 @@ public boolean matches(Map prefilter, BindableEvent e) } @Override - public Map evaluate(BindableEvent e) - throws EventException { + public Map evaluate(BindableEvent e, + Environment env) throws EventException { if(e instanceof MCEntityDamageByEntityEvent) { MCEntityDamageByEntityEvent event = (MCEntityDamageByEntityEvent) e; Map map = evaluate_helper(e); @@ -1321,11 +1321,11 @@ public Driver driver() { @Override public boolean modifyEvent(String key, Mixed value, - BindableEvent e) { + BindableEvent e, Environment env) { MCEntityDamageByEntityEvent event = (MCEntityDamageByEntityEvent) e; if(key.equals("amount")) { - if(value.isInstanceOf(CInt.TYPE)) { + if(value.isInstanceOf(CInt.TYPE, null, env)) { event.setDamage(Integer.parseInt(value.val())); return true; @@ -1384,7 +1384,7 @@ public boolean matches(Map prefilter, BindableEvent e) throws Pre } @Override - public Map evaluate(BindableEvent e) throws EventException { + public Map evaluate(BindableEvent e, Environment env) throws EventException { if(e instanceof MCEntityTargetEvent) { MCEntityTargetEvent ete = (MCEntityTargetEvent) e; Map map = evaluate_helper(e); @@ -1401,7 +1401,7 @@ public Map evaluate(BindableEvent e) throws EventException { } @Override - public boolean modifyEvent(String key, Mixed value, BindableEvent event) { + public boolean modifyEvent(String key, Mixed value, BindableEvent event, Environment env) { if(event instanceof MCEntityTargetEvent) { MCEntityTargetEvent ete = (MCEntityTargetEvent) event; @@ -1409,7 +1409,7 @@ public boolean modifyEvent(String key, Mixed value, BindableEvent event) { if(value instanceof CNull) { ete.setTarget(null); return true; - } else if(value.isInstanceOf(CString.TYPE)) { + } else if(value.isInstanceOf(CString.TYPE, null, env)) { MCPlayer p = Static.GetPlayer(value.val(), value.getTarget()); if(p.isOnline()) { @@ -1469,7 +1469,7 @@ public boolean matches(Map prefilter, BindableEvent e) throws Pre } @Override - public Map evaluate(BindableEvent e) throws EventException { + public Map evaluate(BindableEvent e, Environment env) throws EventException { if(e instanceof MCEntityEnterPortalEvent) { MCEntityEnterPortalEvent event = (MCEntityEnterPortalEvent) e; MCMaterial mat = event.getLocation().getBlock().getType(); @@ -1486,7 +1486,7 @@ public Map evaluate(BindableEvent e) throws EventException { } @Override - public boolean modifyEvent(String key, Mixed value, BindableEvent event) { + public boolean modifyEvent(String key, Mixed value, BindableEvent event, Environment env) { return false; } @@ -1528,7 +1528,7 @@ public void bind(BoundEvent event) { Map prefilter = event.getPrefilter(); if(prefilter.containsKey("from")) { Mixed type = prefilter.get("from"); - if(type.isInstanceOf(CString.TYPE) && type.val().contains(":") || ArgumentValidation.isNumber(type)) { + if(type.isInstanceOf(CString.TYPE, null, event.getEnvironment()) && type.val().contains(":") || ArgumentValidation.isNumber(type)) { MSLog.GetLogger().w(MSLog.Tags.DEPRECATION, "The 0:0 block format in " + getName() + " is deprecated in \"from\" prefilter.", event.getTarget()); MCItemStack is = Static.ParseItemNotation(null, type.val(), 1, event.getTarget()); @@ -1537,7 +1537,7 @@ public void bind(BoundEvent event) { } if(prefilter.containsKey("to")) { Mixed type = prefilter.get("to"); - if(type.isInstanceOf(CString.TYPE) && type.val().contains(":") || ArgumentValidation.isNumber(type)) { + if(type.isInstanceOf(CString.TYPE, null, event.getEnvironment()) && type.val().contains(":") || ArgumentValidation.isNumber(type)) { MSLog.GetLogger().w(MSLog.Tags.DEPRECATION, "The 0:0 block format in " + getName() + " is deprecated in \"to\" prefilter.", event.getTarget()); MCItemStack is = Static.ParseItemNotation(null, type.val(), 1, event.getTarget()); @@ -1560,8 +1560,8 @@ public boolean matches(Map prefilter, BindableEvent e) } @Override - public Map evaluate(BindableEvent e) - throws EventException { + public Map evaluate(BindableEvent e, + Environment env) throws EventException { if(e instanceof MCEntityChangeBlockEvent) { MCEntityChangeBlockEvent event = (MCEntityChangeBlockEvent) e; Target t = Target.UNKNOWN; @@ -1577,7 +1577,7 @@ public Map evaluate(BindableEvent e) } @Override - public boolean modifyEvent(String key, Mixed value, BindableEvent event) { + public boolean modifyEvent(String key, Mixed value, BindableEvent event, Environment env) { return false; } @@ -1623,7 +1623,7 @@ public void bind(BoundEvent event) { + " is deprecated for \"block\". Converted to " + mat.getName(), event.getTarget()); } else if(prefilter.containsKey("block")) { Mixed ctype = prefilter.get("block"); - if(ctype.isInstanceOf(CString.TYPE) && ctype.val().contains(":") || ArgumentValidation.isNumber(ctype)) { + if(ctype.isInstanceOf(CString.TYPE, null, event.getEnvironment()) && ctype.val().contains(":") || ArgumentValidation.isNumber(ctype)) { int type; String notation = ctype.val(); int separatorIndex = notation.indexOf(':'); @@ -1659,7 +1659,7 @@ public boolean matches(Map prefilter, BindableEvent e) throws Pre } @Override - public Map evaluate(BindableEvent e) throws EventException { + public Map evaluate(BindableEvent e, Environment env) throws EventException { if(e instanceof MCEntityInteractEvent) { MCEntityInteractEvent event = (MCEntityInteractEvent) e; Target t = Target.UNKNOWN; @@ -1674,7 +1674,7 @@ public Map evaluate(BindableEvent e) throws EventException { } @Override - public boolean modifyEvent(String key, Mixed value, BindableEvent event) { + public boolean modifyEvent(String key, Mixed value, BindableEvent event, Environment env) { return false; } @@ -1769,7 +1769,7 @@ public boolean matches(Map prefilter, BindableEvent event) throws } } @Override - public Map evaluate(BindableEvent event) throws EventException { + public Map evaluate(BindableEvent event, Environment env) throws EventException { if(event instanceof MCHangingBreakEvent) { MCHangingBreakEvent hangingBreakEvent = (MCHangingBreakEvent) event; Map mapEvent = evaluate_helper(event); @@ -1797,7 +1797,7 @@ public Map evaluate(BindableEvent event) throws EventException { } @Override - public boolean modifyEvent(String key, Mixed value, BindableEvent event) { + public boolean modifyEvent(String key, Mixed value, BindableEvent event, Environment env) { return false; } } @@ -1851,7 +1851,7 @@ public boolean matches(Map prefilter, BindableEvent event) throws } @Override - public Map evaluate(BindableEvent event) throws EventException { + public Map evaluate(BindableEvent event, Environment env) throws EventException { if(event instanceof MCHangingPlaceEvent e) { Map ret = evaluate_helper(event); MCHanging hanging = e.getEntity(); @@ -1897,7 +1897,7 @@ public Driver driver() { } @Override - public boolean modifyEvent(String key, Mixed value, BindableEvent event) { + public boolean modifyEvent(String key, Mixed value, BindableEvent event, Environment env) { return false; } @@ -1940,7 +1940,7 @@ public boolean matches(Map filter, BindableEvent e) throws Prefil } @Override - public Map evaluate(BindableEvent e) throws EventException { + public Map evaluate(BindableEvent e, Environment env) throws EventException { if(e instanceof MCEntityToggleGlideEvent) { MCEntityToggleGlideEvent evt = (MCEntityToggleGlideEvent) e; Map ret = evaluate_helper(evt); @@ -1963,7 +1963,7 @@ public Map evaluate(BindableEvent e) throws EventException { } @Override - public boolean modifyEvent(String key, Mixed value, BindableEvent event) throws ConfigRuntimeException { + public boolean modifyEvent(String key, Mixed value, BindableEvent event, Environment env) throws ConfigRuntimeException { return false; } @@ -2017,7 +2017,7 @@ protected String getProperty(MCEntityToggleSwimEvent event) { } @Override - public Map evaluate(MCEntityToggleSwimEvent e) throws EventException { + public Map evaluate(MCEntityToggleSwimEvent e, Environment env) throws EventException { Map ret = evaluate_helper(e); Target t = Target.UNKNOWN; @@ -2035,7 +2035,7 @@ public Map evaluate(MCEntityToggleSwimEvent e) throws EventExcept } @Override - public boolean modifyEvent(String key, Mixed value, MCEntityToggleSwimEvent event) throws ConfigRuntimeException { + public boolean modifyEvent(String key, Mixed value, MCEntityToggleSwimEvent event, Environment env) throws ConfigRuntimeException { return false; } @@ -2095,7 +2095,7 @@ public boolean matches(Map prefilter, BindableEvent e) throws Pre } @Override - public Map evaluate(BindableEvent event) throws EventException { + public Map evaluate(BindableEvent event, Environment env) throws EventException { if(event instanceof MCFireworkExplodeEvent) { MCFireworkExplodeEvent e = (MCFireworkExplodeEvent) event; Map ret = new HashMap<>(); @@ -2114,7 +2114,7 @@ public Driver driver() { } @Override - public boolean modifyEvent(String key, Mixed value, BindableEvent event) { + public boolean modifyEvent(String key, Mixed value, BindableEvent event, Environment env) { return false; } } @@ -2155,7 +2155,7 @@ public boolean matches(Map prefilter, BindableEvent e) throws Pre } @Override - public Map evaluate(BindableEvent e) throws EventException { + public Map evaluate(BindableEvent e, Environment env) throws EventException { if(e instanceof MCEntityRegainHealthEvent) { MCEntityRegainHealthEvent event = (MCEntityRegainHealthEvent) e; @@ -2175,7 +2175,7 @@ public Driver driver() { } @Override - public boolean modifyEvent(String key, Mixed value, BindableEvent event) { + public boolean modifyEvent(String key, Mixed value, BindableEvent event, Environment env) { if(event instanceof MCEntityRegainHealthEvent) { MCEntityRegainHealthEvent e = (MCEntityRegainHealthEvent) event; if(key.equalsIgnoreCase("amount")) { @@ -2225,7 +2225,7 @@ public boolean matches(Map prefilter, BindableEvent e) throws Pre } @Override - public Map evaluate(BindableEvent e) throws EventException { + public Map evaluate(BindableEvent e, Environment env) throws EventException { if(e instanceof MCEntityPortalEvent) { MCEntityPortalEvent event = (MCEntityPortalEvent) e; Map ret = new HashMap<>(); @@ -2252,7 +2252,7 @@ public Driver driver() { } @Override - public boolean modifyEvent(String key, Mixed value, BindableEvent event) { + public boolean modifyEvent(String key, Mixed value, BindableEvent event, Environment env) { if(event instanceof MCEntityPortalEvent) { MCEntityPortalEvent e = (MCEntityPortalEvent) event; @@ -2301,7 +2301,7 @@ public boolean matches(Map prefilter, BindableEvent e) throws Pre } @Override - public Map evaluate(BindableEvent e) throws EventException { + public Map evaluate(BindableEvent e, Environment env) throws EventException { if(e instanceof MCEntityUnleashEvent) { MCEntityUnleashEvent event = (MCEntityUnleashEvent) e; @@ -2321,7 +2321,7 @@ public Driver driver() { } @Override - public boolean modifyEvent(String key, Mixed value, BindableEvent event) { + public boolean modifyEvent(String key, Mixed value, BindableEvent event, Environment env) { return false; } @@ -2359,7 +2359,7 @@ public boolean matches(Map prefilter, BindableEvent event) throws } @Override - public Map evaluate(BindableEvent e) throws EventException { + public Map evaluate(BindableEvent e, Environment env) throws EventException { if(e instanceof MCPotionSplashEvent) { MCPotionSplashEvent event = (MCPotionSplashEvent) e; Target t = Target.UNKNOWN; @@ -2384,7 +2384,7 @@ public Driver driver() { } @Override - public boolean modifyEvent(String key, Mixed value, BindableEvent event) { + public boolean modifyEvent(String key, Mixed value, BindableEvent event, Environment env) { if(event instanceof MCPotionSplashEvent) { MCPotionSplashEvent splashEvent = (MCPotionSplashEvent) event; Target t = value.getTarget(); @@ -2461,7 +2461,7 @@ public boolean matches(Map prefilter, BindableEvent e) throws Pre } @Override - public Map evaluate(BindableEvent e) throws EventException { + public Map evaluate(BindableEvent e, Environment env) throws EventException { if(!(e instanceof MCEntityPotionEffectEvent)) { throw new EventException("Cannot convert event to MCEntityPotionEffectEvent"); } else { @@ -2481,7 +2481,7 @@ public Map evaluate(BindableEvent e) throws EventException { } @Override - public boolean modifyEvent(String key, Mixed value, BindableEvent e) { + public boolean modifyEvent(String key, Mixed value, BindableEvent e, Environment env) { return false; } } diff --git a/src/main/java/com/laytonsmith/core/events/drivers/InventoryEvents.java b/src/main/java/com/laytonsmith/core/events/drivers/InventoryEvents.java index 4374a0b306..918108aee9 100644 --- a/src/main/java/com/laytonsmith/core/events/drivers/InventoryEvents.java +++ b/src/main/java/com/laytonsmith/core/events/drivers/InventoryEvents.java @@ -38,6 +38,7 @@ import com.laytonsmith.core.constructs.CInt; import com.laytonsmith.core.constructs.CString; import com.laytonsmith.core.constructs.Target; +import com.laytonsmith.core.environments.Environment; import com.laytonsmith.core.events.AbstractEvent; import com.laytonsmith.core.events.BindableEvent; import com.laytonsmith.core.events.BoundEvent; @@ -100,7 +101,7 @@ public void bind(BoundEvent event) { Map prefilter = event.getPrefilter(); if(prefilter.containsKey("slotitem")) { Mixed type = prefilter.get("slotitem"); - if(type.isInstanceOf(CString.TYPE) && type.val().contains(":") || ArgumentValidation.isNumber(type)) { + if(type.isInstanceOf(CString.TYPE, null, event.getEnvironment()) && type.val().contains(":") || ArgumentValidation.isNumber(type)) { MCItemStack is = Static.ParseItemNotation(null, prefilter.get("slotitem").val(), 1, event.getTarget()); prefilter.put("slotitem", new CString(is.getType().getName(), event.getTarget())); MSLog.GetLogger().w(MSLog.Tags.DEPRECATION, "The item notation format for the \"slotitem\" prefilter" @@ -132,7 +133,7 @@ public boolean matches(Map prefilter, BindableEvent event) throws } @Override - public Map evaluate(BindableEvent event) throws EventException { + public Map evaluate(BindableEvent event, Environment env) throws EventException { if(event instanceof MCInventoryClickEvent) { MCInventoryClickEvent e = (MCInventoryClickEvent) event; Map map = evaluate_helper(event); @@ -182,7 +183,7 @@ public Driver driver() { } @Override - public boolean modifyEvent(String key, Mixed value, BindableEvent event) { + public boolean modifyEvent(String key, Mixed value, BindableEvent event, Environment env) { if(event instanceof MCInventoryClickEvent) { MCInventoryClickEvent e = (MCInventoryClickEvent) event; @@ -237,7 +238,7 @@ public void bind(BoundEvent event) { Map prefilter = event.getPrefilter(); if(prefilter.containsKey("cursoritem")) { Mixed type = prefilter.get("cursoritem"); - if(type.isInstanceOf(CString.TYPE) && type.val().contains(":") || ArgumentValidation.isNumber(type)) { + if(type.isInstanceOf(CString.TYPE, null, event.getEnvironment()) && type.val().contains(":") || ArgumentValidation.isNumber(type)) { MCItemStack is = Static.ParseItemNotation(null, prefilter.get("cursoritem").val(), 1, event.getTarget()); prefilter.put("cursoritem", new CString(is.getType().getName(), event.getTarget())); MSLog.GetLogger().w(MSLog.Tags.DEPRECATION, "The item notation format for the \"cursoritem\" prefilter" @@ -267,7 +268,7 @@ public boolean matches(Map prefilter, BindableEvent event) throws } @Override - public Map evaluate(BindableEvent event) throws EventException { + public Map evaluate(BindableEvent event, Environment env) throws EventException { if(event instanceof MCInventoryDragEvent) { MCInventoryDragEvent e = (MCInventoryDragEvent) event; Map map = evaluate_helper(event); @@ -319,7 +320,7 @@ public Driver driver() { } @Override - public boolean modifyEvent(String key, Mixed value, BindableEvent event) { + public boolean modifyEvent(String key, Mixed value, BindableEvent event, Environment env) { if(event instanceof MCInventoryDragEvent) { MCInventoryDragEvent e = (MCInventoryDragEvent) event; @@ -372,7 +373,7 @@ public boolean matches(Map prefilter, BindableEvent event) throws } @Override - public Map evaluate(BindableEvent event) throws EventException { + public Map evaluate(BindableEvent event, Environment env) throws EventException { if(event instanceof MCInventoryOpenEvent) { MCInventoryOpenEvent e = (MCInventoryOpenEvent) event; Map map = evaluate_helper(event); @@ -389,7 +390,7 @@ public Map evaluate(BindableEvent event) throws EventException { map.put("inventory", items); map.put("inventorytype", new CString(inv.getType().name(), t)); - map.put("holder", InventoryManagement.GetInventoryHolder(inv, t)); + map.put("holder", InventoryManagement.GetInventoryHolder(inv, t, env)); map.put("virtual", CBoolean.get(inv.getHolder() instanceof MCVirtualInventoryHolder)); return map; @@ -404,7 +405,7 @@ public Driver driver() { } @Override - public boolean modifyEvent(String key, Mixed value, BindableEvent event) { + public boolean modifyEvent(String key, Mixed value, BindableEvent event, Environment env) { return false; } @@ -449,7 +450,7 @@ public boolean matches(Map prefilter, BindableEvent event) throws } @Override - public Map evaluate(BindableEvent event) throws EventException { + public Map evaluate(BindableEvent event, Environment env) throws EventException { if(event instanceof MCInventoryCloseEvent) { MCInventoryCloseEvent e = (MCInventoryCloseEvent) event; Map map = evaluate_helper(event); @@ -466,7 +467,7 @@ public Map evaluate(BindableEvent event) throws EventException { map.put("inventory", items); map.put("inventorytype", new CString(inv.getType().name(), t)); - map.put("holder", InventoryManagement.GetInventoryHolder(inv, t)); + map.put("holder", InventoryManagement.GetInventoryHolder(inv, t, env)); map.put("virtual", CBoolean.get(inv.getHolder() instanceof MCVirtualInventoryHolder)); return map; @@ -481,7 +482,7 @@ public Driver driver() { } @Override - public boolean modifyEvent(String key, Mixed value, BindableEvent event) { + public boolean modifyEvent(String key, Mixed value, BindableEvent event, Environment env) { return false; } @@ -525,7 +526,7 @@ public boolean matches(Map prefilter, BindableEvent e) throws Pre } @Override - public Map evaluate(BindableEvent event) throws EventException { + public Map evaluate(BindableEvent event, Environment env) throws EventException { if(event instanceof MCEnchantItemEvent) { MCEnchantItemEvent e = (MCEnchantItemEvent) event; Map map = evaluate_helper(event); @@ -554,7 +555,7 @@ public Driver driver() { } @Override - public boolean modifyEvent(String key, Mixed value, BindableEvent event) { + public boolean modifyEvent(String key, Mixed value, BindableEvent event, Environment env) { if(event instanceof MCEnchantItemEvent) { MCEnchantItemEvent e = (MCEnchantItemEvent) event; @@ -611,7 +612,7 @@ public boolean matches(Map prefilter, BindableEvent e) throws Pre } @Override - public Map evaluate(BindableEvent event) throws EventException { + public Map evaluate(BindableEvent event, Environment env) throws EventException { if(event instanceof MCPrepareItemEnchantEvent) { Target t = Target.UNKNOWN; MCPrepareItemEnchantEvent e = (MCPrepareItemEnchantEvent) event; @@ -643,7 +644,7 @@ public Driver driver() { } @Override - public boolean modifyEvent(String key, Mixed value, BindableEvent event) { + public boolean modifyEvent(String key, Mixed value, BindableEvent event, Environment env) { if(event instanceof MCPrepareItemEnchantEvent) { Target t = value.getTarget(); MCPrepareItemEnchantEvent e = (MCPrepareItemEnchantEvent) event; @@ -654,7 +655,7 @@ public boolean modifyEvent(String key, Mixed value, BindableEvent event) { } if(key.equalsIgnoreCase("expcosts")) { - if(value.isInstanceOf(CArray.TYPE)) { + if(value.isInstanceOf(CArray.TYPE, null, env)) { CArray cExpCosts = (CArray) value; if(!cExpCosts.inAssociativeMode()) { MCEnchantmentOffer[] offers = e.getOffers(); @@ -712,7 +713,7 @@ public boolean matches(Map prefilter, BindableEvent event) throws } @Override - public Map evaluate(BindableEvent event) throws EventException { + public Map evaluate(BindableEvent event, Environment env) throws EventException { if(event instanceof MCItemHeldEvent) { MCItemHeldEvent e = (MCItemHeldEvent) event; Map ret = evaluate_helper(e); @@ -730,7 +731,7 @@ public Driver driver() { } @Override - public boolean modifyEvent(String key, Mixed value, BindableEvent event) { + public boolean modifyEvent(String key, Mixed value, BindableEvent event, Environment env) { if(event instanceof MCItemHeldEvent) { MCItemHeldEvent e = (MCItemHeldEvent) event; if("to".equals(key)) { @@ -774,7 +775,7 @@ public void bind(BoundEvent event) { Map prefilter = event.getPrefilter(); if(prefilter.containsKey("main_hand")) { Mixed type = prefilter.get("main_hand"); - if(type.isInstanceOf(CString.TYPE) && type.val().contains(":") || ArgumentValidation.isNumber(type)) { + if(type.isInstanceOf(CString.TYPE, null, event.getEnvironment()) && type.val().contains(":") || ArgumentValidation.isNumber(type)) { MSLog.GetLogger().w(MSLog.Tags.DEPRECATION, "The item notation format in the \"main_hand\"" + " prefilter in " + getName() + " is deprecated.", event.getTarget()); MCItemStack is = Static.ParseItemNotation(null, prefilter.get("main_hand").val(), 1, event.getTarget()); @@ -783,7 +784,7 @@ public void bind(BoundEvent event) { } if(prefilter.containsKey("off_hand")) { Mixed type = prefilter.get("off_hand"); - if(type.isInstanceOf(CString.TYPE) && type.val().contains(":") || ArgumentValidation.isNumber(type)) { + if(type.isInstanceOf(CString.TYPE, null, event.getEnvironment()) && type.val().contains(":") || ArgumentValidation.isNumber(type)) { MSLog.GetLogger().w(MSLog.Tags.DEPRECATION, "The item notation format in the \"off_hand\"" + " prefilter in " + getName() + " is deprecated.", event.getTarget()); MCItemStack is = Static.ParseItemNotation(null, prefilter.get("off_hand").val(), 1, event.getTarget()); @@ -817,7 +818,7 @@ public boolean matches(Map prefilter, BindableEvent event) throws } @Override - public Map evaluate(BindableEvent event) throws EventException { + public Map evaluate(BindableEvent event, Environment env) throws EventException { if(event instanceof MCItemSwapEvent) { MCItemSwapEvent e = (MCItemSwapEvent) event; Map ret = evaluate_helper(e); @@ -835,7 +836,7 @@ public Driver driver() { } @Override - public boolean modifyEvent(String key, Mixed value, BindableEvent event) { + public boolean modifyEvent(String key, Mixed value, BindableEvent event, Environment env) { if(event instanceof MCItemSwapEvent) { MCItemSwapEvent e = (MCItemSwapEvent) event; if("main_hand".equals(key)) { @@ -887,7 +888,7 @@ public boolean matches(Map prefilter, BindableEvent event) throws } @Override - public Map evaluate(BindableEvent event) throws EventException { + public Map evaluate(BindableEvent event, Environment env) throws EventException { if(event instanceof MCPrepareItemCraftEvent e) { Map ret = evaluate_helper(e); Target t = Target.UNKNOWN; @@ -918,7 +919,7 @@ public Driver driver() { } @Override - public boolean modifyEvent(String key, Mixed value, BindableEvent event) { + public boolean modifyEvent(String key, Mixed value, BindableEvent event, Environment env) { if(event instanceof MCPrepareItemCraftEvent e) { Target t = Target.UNKNOWN; if("result".equals(key)) { @@ -972,7 +973,7 @@ public boolean matches(Map prefilter, BindableEvent event) throws } @Override - public Map evaluate(BindableEvent event) throws EventException { + public Map evaluate(BindableEvent event, Environment env) throws EventException { if(event instanceof MCPrepareAnvilEvent e) { MCAnvilInventory anvil = (MCAnvilInventory) e.getInventory(); Map ret = evaluate_helper(e); @@ -999,7 +1000,7 @@ public Driver driver() { } @Override - public boolean modifyEvent(String key, Mixed value, BindableEvent event) { + public boolean modifyEvent(String key, Mixed value, BindableEvent event, Environment env) { if(event instanceof MCPrepareAnvilEvent e) { Target t = value.getTarget(); if(key.equalsIgnoreCase("result")) { @@ -1069,7 +1070,7 @@ public boolean matches(Map prefilter, BindableEvent event) throws } @Override - public Map evaluate(BindableEvent event) throws EventException { + public Map evaluate(BindableEvent event, Environment env) throws EventException { if(event instanceof MCPrepareSmithingEvent e) { MCSmithingInventory smithing = (MCSmithingInventory) e.getInventory(); Map ret = evaluate_helper(e); @@ -1095,7 +1096,7 @@ public Driver driver() { } @Override - public boolean modifyEvent(String key, Mixed value, BindableEvent event) { + public boolean modifyEvent(String key, Mixed value, BindableEvent event, Environment env) { if(event instanceof MCPrepareSmithingEvent e) { Target t = value.getTarget(); if(key.equalsIgnoreCase("result")) { @@ -1142,7 +1143,7 @@ public boolean matches(Map prefilter, BindableEvent event) throws } @Override - public Map evaluate(BindableEvent event) throws EventException { + public Map evaluate(BindableEvent event, Environment env) throws EventException { if(event instanceof MCPrepareGrindstoneEvent e) { MCGrindstoneInventory grindstone = (MCGrindstoneInventory) e.getInventory(); Map ret = evaluate_helper(e); @@ -1164,7 +1165,7 @@ public Driver driver() { } @Override - public boolean modifyEvent(String key, Mixed value, BindableEvent event) { + public boolean modifyEvent(String key, Mixed value, BindableEvent event, Environment env) { if(event instanceof MCPrepareGrindstoneEvent e) { Target t = value.getTarget(); if(key.equalsIgnoreCase("result")) { diff --git a/src/main/java/com/laytonsmith/core/events/drivers/PlayerEvents.java b/src/main/java/com/laytonsmith/core/events/drivers/PlayerEvents.java index d03b3e31dd..dbb898d18c 100644 --- a/src/main/java/com/laytonsmith/core/events/drivers/PlayerEvents.java +++ b/src/main/java/com/laytonsmith/core/events/drivers/PlayerEvents.java @@ -151,7 +151,7 @@ protected String getProperty(MCFoodLevelChangeEvent event) { } @Override - public Map evaluate(BindableEvent e) throws EventException { + public Map evaluate(BindableEvent e, Environment env) throws EventException { if(e instanceof MCFoodLevelChangeEvent) { Map ret = evaluate_helper(e); MCFoodLevelChangeEvent event = (MCFoodLevelChangeEvent) e; @@ -179,7 +179,7 @@ public Driver driver() { } @Override - public boolean modifyEvent(String key, Mixed value, BindableEvent event) { + public boolean modifyEvent(String key, Mixed value, BindableEvent event, Environment env) { if(event instanceof MCFoodLevelChangeEvent) { MCFoodLevelChangeEvent e = (MCFoodLevelChangeEvent) event; @@ -252,7 +252,7 @@ public BindableEvent convert(CArray manualObject, Target t, Environment env) { } @Override - public Map evaluate(BindableEvent event) throws EventException { + public Map evaluate(BindableEvent event, Environment env) throws EventException { if(event instanceof MCPlayerItemConsumeEvent) { MCPlayerItemConsumeEvent e = (MCPlayerItemConsumeEvent) event; Map ret = evaluate_helper(e); @@ -277,7 +277,7 @@ public Driver driver() { } @Override - public boolean modifyEvent(String key, Mixed value, BindableEvent event) { + public boolean modifyEvent(String key, Mixed value, BindableEvent event, Environment env) { if(event instanceof MCPlayerItemConsumeEvent) { MCPlayerItemConsumeEvent e = (MCPlayerItemConsumeEvent) event; if(key.equalsIgnoreCase("item")) { @@ -326,7 +326,7 @@ protected Object getProperty(MCPlayerKickEvent event) { } @Override - public Map evaluate(BindableEvent e) throws EventException { + public Map evaluate(BindableEvent e, Environment env) throws EventException { if(e instanceof MCPlayerKickEvent) { MCPlayerKickEvent event = (MCPlayerKickEvent) e; Map map = evaluate_helper(e); @@ -346,7 +346,7 @@ public Driver driver() { @Override public boolean modifyEvent(String key, Mixed value, - BindableEvent event) { + BindableEvent event, Environment env) { if(event instanceof MCPlayerKickEvent) { MCPlayerKickEvent e = (MCPlayerKickEvent) event; if(key.equalsIgnoreCase("message")) { @@ -423,7 +423,7 @@ public BindableEvent convert(CArray manualObject, Target t, Environment env) { } @Override - public Map evaluate(BindableEvent e) throws EventException { + public Map evaluate(BindableEvent e, Environment env) throws EventException { if(e instanceof MCPlayerTeleportEvent) { MCPlayerTeleportEvent event = (MCPlayerTeleportEvent) e; Map map = evaluate_helper(e); @@ -446,7 +446,7 @@ public Driver driver() { } @Override - public boolean modifyEvent(String key, Mixed value, BindableEvent event) { + public boolean modifyEvent(String key, Mixed value, BindableEvent event, Environment env) { if(event instanceof MCPlayerTeleportEvent) { MCPlayerTeleportEvent e = (MCPlayerTeleportEvent) event; @@ -527,7 +527,7 @@ public BindableEvent convert(CArray manualObject, Target t, Environment env) { } @Override - public Map evaluate(BindableEvent e) throws EventException { + public Map evaluate(BindableEvent e, Environment env) throws EventException { if(e instanceof MCPlayerPortalEvent) { MCPlayerPortalEvent event = (MCPlayerPortalEvent) e; Map map = evaluate_helper(e); @@ -554,7 +554,7 @@ public Driver driver() { } @Override - public boolean modifyEvent(String key, Mixed value, BindableEvent event) { + public boolean modifyEvent(String key, Mixed value, BindableEvent event, Environment env) { if(event instanceof MCPlayerPortalEvent) { MCPlayerPortalEvent e = (MCPlayerPortalEvent) event; @@ -622,7 +622,7 @@ protected PrefilterBuilder getPrefilterBuilder() { } @Override - public Map evaluate(BindableEvent e) throws EventException { + public Map evaluate(BindableEvent e, Environment env) throws EventException { if(e instanceof MCPlayerLoginEvent) { MCPlayerLoginEvent event = (MCPlayerLoginEvent) e; Map map = evaluate_helper(e); @@ -647,7 +647,7 @@ public Driver driver() { } @Override - public boolean modifyEvent(String key, Mixed value, BindableEvent e) { + public boolean modifyEvent(String key, Mixed value, BindableEvent e, Environment env) { if(e instanceof MCPlayerLoginEvent) { MCPlayerLoginEvent event = (MCPlayerLoginEvent) e; if(key.equals("result")) { @@ -735,7 +735,7 @@ protected String getProperty(MCPlayerJoinEvent event) { } @Override - public Map evaluate(BindableEvent e) throws EventException { + public Map evaluate(BindableEvent e, Environment env) throws EventException { if(e instanceof MCPlayerJoinEvent) { MCPlayerJoinEvent ple = (MCPlayerJoinEvent) e; Map map = evaluate_helper(e); @@ -749,7 +749,7 @@ public Map evaluate(BindableEvent e) throws EventException { } @Override - public boolean modifyEvent(String key, Mixed value, BindableEvent event) { + public boolean modifyEvent(String key, Mixed value, BindableEvent event, Environment env) { if(event instanceof MCPlayerJoinEvent) { MCPlayerJoinEvent pje = (MCPlayerJoinEvent) event; if(key.equals("join_message") || key.equals("message")) { @@ -828,7 +828,7 @@ public void bind(BoundEvent event) { } if(prefilter.containsKey("block")) { Mixed ctype = prefilter.get("block"); - if(ctype.isInstanceOf(CString.TYPE) && ctype.val().contains(":") + if(ctype.isInstanceOf(CString.TYPE, null, event.getEnvironment()) && ctype.val().contains(":") || ArgumentValidation.isNumber(ctype)) { int type; String notation = ctype.val(); @@ -892,7 +892,7 @@ public String getProperty(MCPlayerInteractEvent pie) { } @Override - public Map evaluate(BindableEvent e) throws EventException { + public Map evaluate(BindableEvent e, Environment env) throws EventException { if(e instanceof MCPlayerInteractEvent) { MCPlayerInteractEvent pie = (MCPlayerInteractEvent) e; Map map = evaluate_helper(e); @@ -940,7 +940,7 @@ public BindableEvent convert(CArray manual, Target t, Environment env) { } @Override - public boolean modifyEvent(String key, Mixed value, BindableEvent event) { + public boolean modifyEvent(String key, Mixed value, BindableEvent event, Environment env) { if(event instanceof MCPlayerInteractEvent) { MCPlayerInteractEvent pie = (MCPlayerInteractEvent) event; } @@ -995,7 +995,7 @@ protected Enum getEnum(MCPlayerEnterBedEvent event) { } @Override - public Map evaluate(BindableEvent e) throws EventException { + public Map evaluate(BindableEvent e, Environment env) throws EventException { if(e instanceof MCPlayerEnterBedEvent) { MCPlayerEnterBedEvent bee = (MCPlayerEnterBedEvent) e; Map map = evaluate_helper(e); @@ -1013,7 +1013,7 @@ public Driver driver() { } @Override - public boolean modifyEvent(String key, Mixed value, BindableEvent event) { + public boolean modifyEvent(String key, Mixed value, BindableEvent event, Environment env) { return false; } @@ -1064,7 +1064,7 @@ protected MCLocation getLocation(MCPlayerLeaveBedEvent event) { } @Override - public Map evaluate(BindableEvent e) throws EventException { + public Map evaluate(BindableEvent e, Environment env) throws EventException { if(e instanceof MCPlayerLeaveBedEvent) { MCPlayerLeaveBedEvent bee = (MCPlayerLeaveBedEvent) e; Map map = evaluate_helper(e); @@ -1081,7 +1081,7 @@ public Driver driver() { } @Override - public boolean modifyEvent(String key, Mixed value, BindableEvent event) { + public boolean modifyEvent(String key, Mixed value, BindableEvent event, Environment env) { return false; } @@ -1137,7 +1137,7 @@ public BindableEvent convert(CArray manual, Target t, Environment env) { } @Override - public Map evaluate(BindableEvent e) throws EventException { + public Map evaluate(BindableEvent e, Environment env) throws EventException { if(e instanceof MCPlayerInteractEvent) { MCPlayerInteractEvent pie = (MCPlayerInteractEvent) e; Map map = evaluate_helper(e); @@ -1156,7 +1156,7 @@ public Driver driver() { } @Override - public boolean modifyEvent(String key, Mixed value, BindableEvent event) { + public boolean modifyEvent(String key, Mixed value, BindableEvent event, Environment env) { return false; } @@ -1235,7 +1235,7 @@ protected MCLocation getLocation(MCPlayerRespawnEvent event) { } @Override - public Map evaluate(BindableEvent e) throws EventException { + public Map evaluate(BindableEvent e, Environment env) throws EventException { if(e instanceof MCPlayerRespawnEvent) { MCPlayerRespawnEvent event = (MCPlayerRespawnEvent) e; Map map = evaluate_helper(e); @@ -1264,7 +1264,7 @@ public BindableEvent convert(CArray manual, Target t, Environment env) { } @Override - public boolean modifyEvent(String key, Mixed value, BindableEvent event) { + public boolean modifyEvent(String key, Mixed value, BindableEvent event, Environment env) { if(event instanceof MCPlayerRespawnEvent) { MCPlayerRespawnEvent e = (MCPlayerRespawnEvent) event; if(key.equals("location")) { @@ -1330,10 +1330,10 @@ protected Object getProperty(MCPlayerDeathEvent event) { //We have an actual event now, change it into a Map //that will end up being the @event object @Override - public Map evaluate(BindableEvent e) throws EventException { + public Map evaluate(BindableEvent e, Environment env) throws EventException { if(e instanceof MCPlayerDeathEvent) { MCPlayerDeathEvent event = (MCPlayerDeathEvent) e; - Map map = super.evaluate(e); + Map map = super.evaluate(e, env); map.putAll(evaluate_helper(e)); map.put("death_message", new CString(event.getDeathMessage(), Target.UNKNOWN)); map.put("keep_inventory", CBoolean.get(event.getKeepInventory())); @@ -1371,7 +1371,7 @@ public BindableEvent convert(CArray manual, Target t, Environment env) { //Given the paramters, change the underlying event @Override - public boolean modifyEvent(String key, Mixed value, BindableEvent event) { + public boolean modifyEvent(String key, Mixed value, BindableEvent event, Environment env) { if(event instanceof MCPlayerDeathEvent) { MCPlayerDeathEvent e = (MCPlayerDeathEvent) event; switch(key) { @@ -1394,7 +1394,7 @@ public boolean modifyEvent(String key, Mixed value, BindableEvent event) { e.setNewTotalExp(ArgumentValidation.getInt32(value, Target.UNKNOWN)); return true; default: - return super.modifyEvent(key, value, event); + return super.modifyEvent(key, value, event, env); } } else { return false; @@ -1447,7 +1447,7 @@ public BindableEvent convert(CArray manualObject, Target t, Environment env) { } @Override - public Map evaluate(BindableEvent e) throws EventException { + public Map evaluate(BindableEvent e, Environment env) throws EventException { if(e instanceof MCPlayerQuitEvent) { MCPlayerQuitEvent event = (MCPlayerQuitEvent) e; Map map = evaluate_helper(e); @@ -1460,7 +1460,7 @@ public Map evaluate(BindableEvent e) throws EventException { } @Override - public boolean modifyEvent(String key, Mixed value, BindableEvent event) { + public boolean modifyEvent(String key, Mixed value, BindableEvent event, Environment env) { if(event instanceof MCPlayerQuitEvent) { MCPlayerQuitEvent e = (MCPlayerQuitEvent) event; if("message".equals(key)) { @@ -1536,7 +1536,7 @@ public BindableEvent convert(CArray manualObject, Target t, Environment env) { } @Override - public Map evaluate(BindableEvent e) throws EventException { + public Map evaluate(BindableEvent e, Environment env) throws EventException { if(e instanceof MCPlayerChatEvent) { MCPlayerChatEvent event = (MCPlayerChatEvent) e; Map map = evaluate_helper(e); @@ -1555,14 +1555,14 @@ public Map evaluate(BindableEvent e) throws EventException { } @Override - public boolean modifyEvent(String key, Mixed value, BindableEvent event) { + public boolean modifyEvent(String key, Mixed value, BindableEvent event, Environment env) { if(event instanceof MCPlayerChatEvent) { MCPlayerChatEvent e = (MCPlayerChatEvent) event; if("message".equals(key)) { e.setMessage(Construct.nval(value)); } if("recipients".equals(key)) { - if(value.isInstanceOf(CArray.TYPE)) { + if(value.isInstanceOf(CArray.TYPE, null, env)) { List list = new ArrayList(); for(String index : ((CArray) value).stringKeySet()) { Mixed v = ((CArray) value).get(index, value.getTarget()); @@ -1676,7 +1676,7 @@ public BindableEvent convert(CArray manualObject, Target t, Environment env) { } @Override - public Map evaluate(BindableEvent e) throws EventException { + public Map evaluate(BindableEvent e, Environment env) throws EventException { if(e instanceof MCPlayerChatEvent) { MCPlayerChatEvent event = (MCPlayerChatEvent) e; Map map = evaluate_helper(e); @@ -1695,14 +1695,14 @@ public Map evaluate(BindableEvent e) throws EventException { } @Override - public boolean modifyEvent(String key, Mixed value, BindableEvent event) { + public boolean modifyEvent(String key, Mixed value, BindableEvent event, Environment env) { if(event instanceof MCPlayerChatEvent) { MCPlayerChatEvent e = (MCPlayerChatEvent) event; if("message".equals(key)) { e.setMessage(Construct.nval(value)); } if("recipients".equals(key)) { - if(value.isInstanceOf(CArray.TYPE)) { + if(value.isInstanceOf(CArray.TYPE, null, env)) { List list = new ArrayList<>(); for(String index : ((CArray) value).stringKeySet()) { Mixed v = ((CArray) value).get(index, value.getTarget()); @@ -1804,7 +1804,7 @@ public BindableEvent convert(CArray manualObject, Target t, Environment env) { } @Override - public Map evaluate(BindableEvent e) throws EventException { + public Map evaluate(BindableEvent e, Environment env) throws EventException { if(e instanceof MCPlayerCommandEvent) { MCPlayerCommandEvent event = (MCPlayerCommandEvent) e; Map map = evaluate_helper(e); @@ -1822,7 +1822,7 @@ public Map evaluate(BindableEvent e) throws EventException { } @Override - public boolean modifyEvent(String key, Mixed value, BindableEvent event) { + public boolean modifyEvent(String key, Mixed value, BindableEvent event, Environment env) { if(event instanceof MCPlayerCommandEvent) { MCPlayerCommandEvent e = (MCPlayerCommandEvent) event; @@ -1899,7 +1899,7 @@ public BindableEvent convert(CArray manualObject, Target t, Environment env) { } @Override - public Map evaluate(BindableEvent e) throws EventException { + public Map evaluate(BindableEvent e, Environment env) throws EventException { if(e instanceof MCWorldChangedEvent) { MCWorldChangedEvent event = (MCWorldChangedEvent) e; Map map = evaluate_helper(e); @@ -1913,7 +1913,7 @@ public Map evaluate(BindableEvent e) throws EventException { } @Override - public boolean modifyEvent(String key, Mixed value, BindableEvent event) { + public boolean modifyEvent(String key, Mixed value, BindableEvent event, Environment env) { if(event instanceof MCWorldChangedEvent) { MCWorldChangedEvent e = (MCWorldChangedEvent) event; } @@ -2036,7 +2036,7 @@ public BindableEvent convert(CArray manualObject, Target t, Environment env) { } @Override - public Map evaluate(BindableEvent e) throws EventException { + public Map evaluate(BindableEvent e, Environment env) throws EventException { if(e instanceof MCPlayerMoveEvent) { MCPlayerMoveEvent event = (MCPlayerMoveEvent) e; Map map = new HashMap<>(); @@ -2056,7 +2056,7 @@ public Driver driver() { } @Override - public boolean modifyEvent(String key, Mixed value, BindableEvent event) { + public boolean modifyEvent(String key, Mixed value, BindableEvent event, Environment env) { //Nothing can be modified, so always return false return false; } @@ -2120,7 +2120,7 @@ public boolean matches(Map prefilter, BindableEvent e) throws Pre } @Override - public Map evaluate(BindableEvent e) throws EventException { + public Map evaluate(BindableEvent e, Environment env) throws EventException { if(e instanceof MCPlayerFishEvent) { MCPlayerFishEvent event = (MCPlayerFishEvent) e; Target t = Target.UNKNOWN; @@ -2149,7 +2149,7 @@ public Map evaluate(BindableEvent e) throws EventException { } @Override - public boolean modifyEvent(String key, Mixed value, BindableEvent event) { + public boolean modifyEvent(String key, Mixed value, BindableEvent event, Environment env) { if(event instanceof MCPlayerFishEvent) { MCPlayerFishEvent e = (MCPlayerFishEvent) event; if(key.equals("xp")) { @@ -2245,7 +2245,7 @@ protected Enum getEnum(MCGamemodeChangeEvent event) { } @Override - public Map evaluate(BindableEvent event) throws EventException { + public Map evaluate(BindableEvent event, Environment env) throws EventException { if(event instanceof MCGamemodeChangeEvent) { MCGamemodeChangeEvent e = (MCGamemodeChangeEvent) event; Map ret = evaluate_helper(e); @@ -2262,7 +2262,7 @@ public Driver driver() { } @Override - public boolean modifyEvent(String key, Mixed value, BindableEvent event) { + public boolean modifyEvent(String key, Mixed value, BindableEvent event, Environment env) { return false; } @@ -2296,7 +2296,7 @@ protected PrefilterBuilder getPrefilterBuilder() { } @Override - public Map evaluate(BindableEvent event) throws EventException { + public Map evaluate(BindableEvent event, Environment env) throws EventException { if(event instanceof MCExpChangeEvent) { MCExpChangeEvent e = (MCExpChangeEvent) event; Map ret = evaluate_helper(e); @@ -2313,7 +2313,7 @@ public Driver driver() { } @Override - public boolean modifyEvent(String key, Mixed value, BindableEvent event) { + public boolean modifyEvent(String key, Mixed value, BindableEvent event, Environment env) { if(event instanceof MCExpChangeEvent) { MCExpChangeEvent e = (MCExpChangeEvent) event; if("amount".equals(key)) { @@ -2373,7 +2373,7 @@ protected boolean getProperty(MCPlayerEditBookEvent event) { } @Override - public Map evaluate(BindableEvent event) throws EventException { + public Map evaluate(BindableEvent event, Environment env) throws EventException { if(event instanceof MCPlayerEditBookEvent) { MCPlayerEditBookEvent playerEditBookEvent = (MCPlayerEditBookEvent) event; Map mapEvent = evaluate_helper(event); @@ -2430,7 +2430,7 @@ public Map evaluate(BindableEvent event) throws EventException { } @Override - public boolean modifyEvent(String key, Mixed value, BindableEvent event) { + public boolean modifyEvent(String key, Mixed value, BindableEvent event, Environment env) { if(event instanceof MCPlayerEditBookEvent) { if(key.equalsIgnoreCase("title")) { MCPlayerEditBookEvent e = ((MCPlayerEditBookEvent) event); @@ -2519,7 +2519,7 @@ protected Object getProperty(MCPlayerToggleFlightEvent event) { } @Override - public Map evaluate(BindableEvent event) throws EventException { + public Map evaluate(BindableEvent event, Environment env) throws EventException { if(event instanceof MCPlayerToggleFlightEvent) { MCPlayerToggleFlightEvent ptfe = (MCPlayerToggleFlightEvent) event; Map mapEvent = evaluate_helper(event); @@ -2532,7 +2532,7 @@ public Map evaluate(BindableEvent event) throws EventException { } @Override - public boolean modifyEvent(String key, Mixed value, BindableEvent event) { + public boolean modifyEvent(String key, Mixed value, BindableEvent event, Environment env) { return false; } } @@ -2584,7 +2584,7 @@ protected Object getProperty(MCPlayerToggleSneakEvent event) { }); } @Override - public Map evaluate(BindableEvent event) throws EventException { + public Map evaluate(BindableEvent event, Environment env) throws EventException { if(event instanceof MCPlayerToggleSneakEvent) { MCPlayerToggleSneakEvent ptse = (MCPlayerToggleSneakEvent) event; Map mapEvent = evaluate_helper(event); @@ -2597,7 +2597,7 @@ public Map evaluate(BindableEvent event) throws EventException { } @Override - public boolean modifyEvent(String key, Mixed value, BindableEvent event) { + public boolean modifyEvent(String key, Mixed value, BindableEvent event, Environment env) { return false; } } @@ -2650,7 +2650,7 @@ protected Object getProperty(MCPlayerToggleSprintEvent event) { } @Override - public Map evaluate(BindableEvent event) throws EventException { + public Map evaluate(BindableEvent event, Environment env) throws EventException { if(event instanceof MCPlayerToggleSprintEvent) { MCPlayerToggleSprintEvent ptse = (MCPlayerToggleSprintEvent) event; Map mapEvent = evaluate_helper(event); @@ -2663,7 +2663,7 @@ public Map evaluate(BindableEvent event) throws EventException { } @Override - public boolean modifyEvent(String key, Mixed value, BindableEvent event) { + public boolean modifyEvent(String key, Mixed value, BindableEvent event, Environment env) { return false; } } @@ -2709,7 +2709,7 @@ protected Enum getEnum(MCPlayerResourcePackEvent event) { } @Override - public Map evaluate(BindableEvent event) throws EventException { + public Map evaluate(BindableEvent event, Environment env) throws EventException { Map map = evaluate_helper(event); map.put("status", new CString(((MCPlayerResourcePackEvent) event).getStatus().name(), Target.UNKNOWN)); if(Static.getServer().getMinecraftVersion().gte(MCVersion.MC1_20_4)) { @@ -2719,7 +2719,7 @@ public Map evaluate(BindableEvent event) throws EventException { } @Override - public boolean modifyEvent(String key, Mixed value, BindableEvent event) { + public boolean modifyEvent(String key, Mixed value, BindableEvent event, Environment env) { return false; } @@ -2740,12 +2740,12 @@ public boolean matches(Map prefilter, BindableEvent e) throws Pre } @Override - public boolean modifyEvent(String key, Mixed value, BindableEvent e) { + public boolean modifyEvent(String key, Mixed value, BindableEvent e, Environment env) { return false; } @Override - public Map evaluate(BindableEvent event) throws EventException { + public Map evaluate(BindableEvent event, Environment env) throws EventException { if(event instanceof MCPlayerBucketEvent e) { Map ret = evaluate_helper(e); Target t = Target.UNKNOWN; @@ -2868,7 +2868,7 @@ protected String getProperty(MCPlayerAdvancementDoneEvent event) { } @Override - public Map evaluate(BindableEvent event) throws EventException { + public Map evaluate(BindableEvent event, Environment env) throws EventException { if(event instanceof MCPlayerAdvancementDoneEvent e) { Map map = new HashMap<>(); map.put("player", new CString(e.getPlayer().getName(), Target.UNKNOWN)); @@ -2881,7 +2881,7 @@ public Map evaluate(BindableEvent event) throws EventException { } @Override - public boolean modifyEvent(String key, Mixed value, BindableEvent event) { + public boolean modifyEvent(String key, Mixed value, BindableEvent event, Environment env) { return false; } @@ -2929,7 +2929,7 @@ protected MCItemStack getItemStack(MCPlayerStopUsingItemEvent event) { } @Override - public Map evaluate(BindableEvent event) throws EventException { + public Map evaluate(BindableEvent event, Environment env) throws EventException { if(event instanceof MCPlayerStopUsingItemEvent e) { Map map = new HashMap<>(); map.put("player", new CString(e.getPlayer().getName(), Target.UNKNOWN)); @@ -2942,7 +2942,7 @@ public Map evaluate(BindableEvent event) throws EventException { } @Override - public boolean modifyEvent(String key, Mixed value, BindableEvent event) { + public boolean modifyEvent(String key, Mixed value, BindableEvent event, Environment env) { return false; } diff --git a/src/main/java/com/laytonsmith/core/events/drivers/PluginEvents.java b/src/main/java/com/laytonsmith/core/events/drivers/PluginEvents.java index 9aa99e1fc3..39ee6219a0 100644 --- a/src/main/java/com/laytonsmith/core/events/drivers/PluginEvents.java +++ b/src/main/java/com/laytonsmith/core/events/drivers/PluginEvents.java @@ -9,6 +9,7 @@ import com.laytonsmith.core.events.AbstractEvent; import com.laytonsmith.core.events.BindableEvent; import com.laytonsmith.core.events.Driver; +import com.laytonsmith.core.environments.Environment; import com.laytonsmith.core.events.Prefilters; import com.laytonsmith.core.exceptions.EventException; import com.laytonsmith.core.exceptions.PrefilterNonMatchException; @@ -61,7 +62,7 @@ public boolean matches(Map prefilter, BindableEvent e) throws Pre } @Override - public Map evaluate(BindableEvent e) throws EventException { + public Map evaluate(BindableEvent e, Environment env) throws EventException { if(e instanceof MCPluginIncomingMessageEvent) { MCPluginIncomingMessageEvent event = (MCPluginIncomingMessageEvent) e; Map ret = evaluate_helper(e); @@ -88,7 +89,7 @@ public Driver driver() { } @Override - public boolean modifyEvent(String key, Mixed value, BindableEvent event) { + public boolean modifyEvent(String key, Mixed value, BindableEvent event, Environment env) { return false; } diff --git a/src/main/java/com/laytonsmith/core/events/drivers/ServerEvents.java b/src/main/java/com/laytonsmith/core/events/drivers/ServerEvents.java index 4211e7dbae..b71663b7df 100644 --- a/src/main/java/com/laytonsmith/core/events/drivers/ServerEvents.java +++ b/src/main/java/com/laytonsmith/core/events/drivers/ServerEvents.java @@ -98,7 +98,7 @@ public boolean matches(Map prefilter, BindableEvent e) throws Pre } @Override - public Map evaluate(BindableEvent e) throws EventException { + public Map evaluate(BindableEvent e, Environment env) throws EventException { if(!(e instanceof MCServerCommandEvent)) { throw new EventException("Cannot convert e to MCServerCommandEvent"); } @@ -128,7 +128,7 @@ private static String getCommandsenderString(MCCommandSender sender) { } @Override - public boolean modifyEvent(String key, Mixed value, BindableEvent event) { + public boolean modifyEvent(String key, Mixed value, BindableEvent event, Environment env) { if(event instanceof MCServerCommandEvent) { MCServerCommandEvent e = (MCServerCommandEvent) event; if(key.equals("command")) { @@ -180,7 +180,7 @@ public boolean matches(Map prefilter, BindableEvent e) throws Pre } @Override - public Map evaluate(BindableEvent e) throws EventException { + public Map evaluate(BindableEvent e, Environment env) throws EventException { if(e instanceof MCServerPingEvent) { MCServerPingEvent event = (MCServerPingEvent) e; Target t = Target.UNKNOWN; @@ -207,7 +207,7 @@ public Map evaluate(BindableEvent e) throws EventException { } @Override - public boolean modifyEvent(String key, Mixed value, BindableEvent event) { + public boolean modifyEvent(String key, Mixed value, BindableEvent event, Environment env) { if(event instanceof MCServerPingEvent) { MCServerPingEvent e = (MCServerPingEvent) event; switch(key.toLowerCase()) { @@ -283,7 +283,7 @@ public boolean matches(Map prefilter, BindableEvent event) throws } @Override - public Map evaluate(BindableEvent event) throws EventException { + public Map evaluate(BindableEvent event, Environment env) throws EventException { if(event instanceof MCCommandTabCompleteEvent) { MCCommandTabCompleteEvent e = (MCCommandTabCompleteEvent) event; Target t = Target.UNKNOWN; @@ -315,11 +315,11 @@ public Driver driver() { } @Override - public boolean modifyEvent(String key, Mixed value, BindableEvent event) { + public boolean modifyEvent(String key, Mixed value, BindableEvent event, Environment env) { if(event instanceof MCCommandTabCompleteEvent) { MCCommandTabCompleteEvent e = (MCCommandTabCompleteEvent) event; if("completions".equals(key)) { - if(value.isInstanceOf(CArray.TYPE)) { + if(value.isInstanceOf(CArray.TYPE, null, env)) { List comp = new ArrayList<>(); if(((CArray) value).inAssociativeMode()) { for(Mixed k : ((CArray) value).keySet()) { @@ -390,7 +390,7 @@ public boolean matches(Map evaluate(BindableEvent e) throws EventException { + public Map evaluate(BindableEvent e, Environment env) throws EventException { MCRedstoneChangedEvent event = (MCRedstoneChangedEvent) e; Map map = evaluate_helper(e); map.put("location", ObjectGenerator.GetGenerator().location(event.getLocation(), false)); @@ -404,7 +404,7 @@ public Driver driver() { } @Override - public boolean modifyEvent(String key, Mixed value, BindableEvent event) { + public boolean modifyEvent(String key, Mixed value, BindableEvent event, Environment env) { return false; } @@ -470,7 +470,7 @@ public BindableEvent convert(CArray manualObject, Target t, Environment env) { } @Override - public Map evaluate(BindableEvent e) throws EventException { + public Map evaluate(BindableEvent e, Environment env) throws EventException { MCBroadcastMessageEvent event = (MCBroadcastMessageEvent) e; Map map = evaluate_helper(e); map.put("message", new CString(event.getMessage(), Target.UNKNOWN)); @@ -488,7 +488,7 @@ public Driver driver() { } @Override - public boolean modifyEvent(String key, Mixed value, BindableEvent e) { + public boolean modifyEvent(String key, Mixed value, BindableEvent e, Environment env) { if(key.equals("message")) { MCBroadcastMessageEvent event = (MCBroadcastMessageEvent) e; event.setMessage(Construct.nval(value)); diff --git a/src/main/java/com/laytonsmith/core/events/drivers/VehicleEvents.java b/src/main/java/com/laytonsmith/core/events/drivers/VehicleEvents.java index e1e8ae33e1..a5d16a88cd 100644 --- a/src/main/java/com/laytonsmith/core/events/drivers/VehicleEvents.java +++ b/src/main/java/com/laytonsmith/core/events/drivers/VehicleEvents.java @@ -87,7 +87,7 @@ public boolean matches(Map prefilter, BindableEvent event) throws } @Override - public Map evaluate(BindableEvent event) throws EventException { + public Map evaluate(BindableEvent event, Environment env) throws EventException { if(event instanceof MCVehicleEnterExitEvent) { MCVehicleEnterExitEvent e = (MCVehicleEnterExitEvent) event; Target t = Target.UNKNOWN; @@ -113,7 +113,7 @@ public Driver driver() { } @Override - public boolean modifyEvent(String key, Mixed value, BindableEvent event) { + public boolean modifyEvent(String key, Mixed value, BindableEvent event, Environment env) { return false; } @@ -153,7 +153,7 @@ public boolean matches(Map prefilter, BindableEvent event) throws } @Override - public Map evaluate(BindableEvent event) throws EventException { + public Map evaluate(BindableEvent event, Environment env) throws EventException { if(event instanceof MCVehicleEnterExitEvent) { MCVehicleEnterExitEvent e = (MCVehicleEnterExitEvent) event; Target t = Target.UNKNOWN; @@ -179,7 +179,7 @@ public Driver driver() { } @Override - public boolean modifyEvent(String key, Mixed value, BindableEvent event) { + public boolean modifyEvent(String key, Mixed value, BindableEvent event, Environment env) { return false; } @@ -220,7 +220,7 @@ public void bind(BoundEvent event) { Map prefilter = event.getPrefilter(); if(prefilter.containsKey("hittype")) { Mixed type = prefilter.get("hittype"); - if(type.isInstanceOf(CString.TYPE) && type.val().contains(":") || ArgumentValidation.isNumber(type)) { + if(type.isInstanceOf(CString.TYPE, null, event.getEnvironment()) && type.val().contains(":") || ArgumentValidation.isNumber(type)) { MSLog.GetLogger().w(MSLog.Tags.DEPRECATION, "The 0:0 block format in " + getName() + " is deprecated in \"hittype\".", event.getTarget()); MCItemStack is = Static.ParseItemNotation(null, type.val(), 1, event.getTarget()); @@ -264,7 +264,7 @@ public boolean matches(Map prefilter, BindableEvent e) throws Pre return false; } @Override - public Map evaluate(BindableEvent event) throws EventException { + public Map evaluate(BindableEvent event, Environment env) throws EventException { if(event instanceof MCVehicleCollideEvent) { MCVehicleCollideEvent e = (MCVehicleCollideEvent) event; Target t = Target.UNKNOWN; @@ -308,7 +308,7 @@ public Driver driver() { } @Override - public boolean modifyEvent(String key, Mixed value, BindableEvent event) { + public boolean modifyEvent(String key, Mixed value, BindableEvent event, Environment env) { if(event instanceof MCVehicleEntityCollideEvent) { MCVehicleEntityCollideEvent e = (MCVehicleEntityCollideEvent) event; if(key.equals("collide")) { @@ -482,7 +482,7 @@ public BindableEvent convert(CArray manualObject, Target t, Environment env) { } @Override - public Map evaluate(BindableEvent event) throws EventException { + public Map evaluate(BindableEvent event, Environment env) throws EventException { if(event instanceof MCVehicleMoveEvent) { MCVehicleMoveEvent e = (MCVehicleMoveEvent) event; Target t = Target.UNKNOWN; @@ -525,7 +525,7 @@ public Driver driver() { } @Override - public boolean modifyEvent(String key, Mixed value, BindableEvent event) { + public boolean modifyEvent(String key, Mixed value, BindableEvent event, Environment env) { //Nothing can be modified, so always return false return false; } @@ -568,7 +568,7 @@ public boolean matches(Map prefilter, BindableEvent event) throws } @Override - public Map evaluate(BindableEvent event) throws EventException { + public Map evaluate(BindableEvent event, Environment env) throws EventException { if(event instanceof MCVehicleDestroyEvent) { MCVehicleDestroyEvent e = (MCVehicleDestroyEvent) event; Target t = Target.UNKNOWN; @@ -604,7 +604,7 @@ public Driver driver() { } @Override - public boolean modifyEvent(String key, Mixed value, BindableEvent event) { + public boolean modifyEvent(String key, Mixed value, BindableEvent event, Environment env) { return false; } diff --git a/src/main/java/com/laytonsmith/core/events/drivers/WeatherEvents.java b/src/main/java/com/laytonsmith/core/events/drivers/WeatherEvents.java index 4917c8e411..dfb22ced06 100644 --- a/src/main/java/com/laytonsmith/core/events/drivers/WeatherEvents.java +++ b/src/main/java/com/laytonsmith/core/events/drivers/WeatherEvents.java @@ -63,7 +63,7 @@ public boolean matches(Map prefilter, BindableEvent event) throws } @Override - public Map evaluate(BindableEvent event) throws EventException { + public Map evaluate(BindableEvent event, Environment env) throws EventException { if(event instanceof MCLightningStrikeEvent) { MCLightningStrikeEvent e = (MCLightningStrikeEvent) event; Target t = Target.UNKNOWN; @@ -85,7 +85,7 @@ public Driver driver() { } @Override - public boolean modifyEvent(String key, Mixed value, BindableEvent event) { + public boolean modifyEvent(String key, Mixed value, BindableEvent event, Environment env) { return false; } @@ -143,7 +143,7 @@ public boolean matches(Map prefilter, BindableEvent event) throws } @Override - public Map evaluate(BindableEvent event) throws EventException { + public Map evaluate(BindableEvent event, Environment env) throws EventException { if(event instanceof MCThunderChangeEvent) { MCThunderChangeEvent e = (MCThunderChangeEvent) event; Target t = Target.UNKNOWN; @@ -162,7 +162,7 @@ public Driver driver() { } @Override - public boolean modifyEvent(String key, Mixed value, BindableEvent event) { + public boolean modifyEvent(String key, Mixed value, BindableEvent event, Environment env) { return false; } @@ -203,7 +203,7 @@ public boolean matches(Map prefilter, BindableEvent event) throws @Override - public Map evaluate(BindableEvent event) throws EventException { + public Map evaluate(BindableEvent event, Environment env) throws EventException { if(event instanceof MCWeatherChangeEvent) { MCWeatherChangeEvent e = (MCWeatherChangeEvent) event; Target t = Target.UNKNOWN; @@ -222,7 +222,7 @@ public Driver driver() { } @Override - public boolean modifyEvent(String key, Mixed value, BindableEvent event) { + public boolean modifyEvent(String key, Mixed value, BindableEvent event, Environment env) { return false; } diff --git a/src/main/java/com/laytonsmith/core/events/drivers/WorldEvents.java b/src/main/java/com/laytonsmith/core/events/drivers/WorldEvents.java index 297dbe796f..8794cf03bf 100644 --- a/src/main/java/com/laytonsmith/core/events/drivers/WorldEvents.java +++ b/src/main/java/com/laytonsmith/core/events/drivers/WorldEvents.java @@ -21,6 +21,7 @@ import com.laytonsmith.core.events.AbstractEvent; import com.laytonsmith.core.events.BindableEvent; import com.laytonsmith.core.events.Driver; +import com.laytonsmith.core.environments.Environment; import com.laytonsmith.core.events.Prefilters; import com.laytonsmith.core.exceptions.EventException; import com.laytonsmith.core.exceptions.PrefilterNonMatchException; @@ -40,7 +41,7 @@ public static String docs() { public abstract static class WorldEvent extends AbstractEvent { @Override - public Map evaluate(BindableEvent e) throws EventException { + public Map evaluate(BindableEvent e, Environment env) throws EventException { Map r = evaluate_helper(e); r.put("world", new CString(((MCWorldEvent) e).getWorld().getName(), Target.UNKNOWN)); return r; @@ -85,7 +86,7 @@ public boolean matches(Map prefilter, BindableEvent e) throws Pre } @Override - public boolean modifyEvent(String key, Mixed value, BindableEvent event) { + public boolean modifyEvent(String key, Mixed value, BindableEvent event, Environment env) { return false; } } @@ -128,7 +129,7 @@ public boolean matches(Map prefilter, BindableEvent e) throws Pre } @Override - public boolean modifyEvent(String key, Mixed value, BindableEvent event) { + public boolean modifyEvent(String key, Mixed value, BindableEvent event, Environment env) { return false; } } @@ -171,7 +172,7 @@ public boolean matches(Map prefilter, BindableEvent e) throws Pre } @Override - public boolean modifyEvent(String key, Mixed value, BindableEvent event) { + public boolean modifyEvent(String key, Mixed value, BindableEvent event, Environment env) { return false; } } @@ -233,8 +234,8 @@ public boolean matches(Map prefilter, BindableEvent e) throws Pre } @Override - public Map evaluate(BindableEvent e) throws EventException { - Map r = super.evaluate(e); + public Map evaluate(BindableEvent e, Environment env) throws EventException { + Map r = super.evaluate(e, env); MCStructureGrowEvent event = (MCStructureGrowEvent) e; List blocks = event.getBlocks(); CArray a = new CArray(Target.UNKNOWN, blocks.size()); @@ -251,7 +252,7 @@ public Map evaluate(BindableEvent e) throws EventException { } @Override - public boolean modifyEvent(String key, Mixed value, BindableEvent event) { + public boolean modifyEvent(String key, Mixed value, BindableEvent event, Environment env) { return false; } } diff --git a/src/main/java/com/laytonsmith/core/exceptions/CRE/AbstractCREException.java b/src/main/java/com/laytonsmith/core/exceptions/CRE/AbstractCREException.java index 48fa200b3a..1a6693491d 100644 --- a/src/main/java/com/laytonsmith/core/exceptions/CRE/AbstractCREException.java +++ b/src/main/java/com/laytonsmith/core/exceptions/CRE/AbstractCREException.java @@ -135,7 +135,7 @@ public static AbstractCREException getFromCArray(CArray exception, Target t, Env .forName(exception.get("classType", t).val(), t, env); Class clzz = NativeTypeList.getNativeClass(classType); Throwable cause = null; - if(exception.get("causedBy", t).isInstanceOf(CArray.TYPE)) { + if(exception.get("causedBy", t).isInstanceOf(CArray.TYPE, null, env)) { // It has a cause cause = new CRECausedByWrapper((CArray) exception.get("causedBy", t)); } @@ -345,7 +345,7 @@ public boolean isInstanceOf(Class type) { @Override public boolean isInstanceOf(CClassType type, LeftHandGenericUse lhsGenericParameters, Environment env) { - return Construct.isInstanceof(this, type); + return Construct.isInstanceof(this, type, env); } /** @deprecated Use {@link #typeof(Environment)} instead. */ diff --git a/src/main/java/com/laytonsmith/core/functions/AbstractFunction.java b/src/main/java/com/laytonsmith/core/functions/AbstractFunction.java index 26daa6c629..fcb9a0f6e7 100644 --- a/src/main/java/com/laytonsmith/core/functions/AbstractFunction.java +++ b/src/main/java/com/laytonsmith/core/functions/AbstractFunction.java @@ -297,7 +297,7 @@ public LogLevel profileAt() { } @Override - public String profileMessage(Mixed... args) { + public String profileMessage(Environment env, Mixed... args) { StringBuilder b = new StringBuilder(); boolean first = true; for(Mixed ccc : args) { @@ -305,14 +305,14 @@ public String profileMessage(Mixed... args) { b.append(", "); } first = false; - if(ccc.isInstanceOf(CArray.TYPE)) { + if(ccc.isInstanceOf(CArray.TYPE, null, env)) { //Arrays take too long to toString, so we don't want to actually toString them here if //we don't need to. b.append(""); - } else if(ccc.isInstanceOf(CClosure.TYPE)) { + } else if(ccc.isInstanceOf(CClosure.TYPE, null, env)) { //The toString of a closure is too long, so let's not output them either. b.append(""); - } else if(ccc.isInstanceOf(CString.TYPE)) { + } else if(ccc.isInstanceOf(CString.TYPE, null, env)) { String val = ccc.val().replace("\\", "\\\\").replace("'", "\\'"); int max = 1000; if(val.length() > max) { diff --git a/src/main/java/com/laytonsmith/core/functions/ArrayHandling.java b/src/main/java/com/laytonsmith/core/functions/ArrayHandling.java index acef637d11..6be618c5ab 100644 --- a/src/main/java/com/laytonsmith/core/functions/ArrayHandling.java +++ b/src/main/java/com/laytonsmith/core/functions/ArrayHandling.java @@ -95,10 +95,10 @@ public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed.. // TODO: It's far too late to deprecate this, but this method and length() are aliases, so // we should at least harmonize the implementations. if(args[0] instanceof Sizeable s) { - return new CInt(s.size(), t); + return new CInt(s.size(env), t); } - if(args[0].isInstanceOf(CArray.TYPE) && !(args[0] instanceof CMutablePrimitive)) { - return new CInt(((CArray) args[0]).size(), t); + if(args[0].isInstanceOf(CArray.TYPE, null, env) && !(args[0] instanceof CMutablePrimitive)) { + return new CInt(((CArray) args[0]).size(env), t); } throw new CRECastException("Argument 1 of " + this.getName() + " must be an array", t); } @@ -179,13 +179,13 @@ public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed.. defaultConstruct = args[2]; } - if(args[0].isInstanceOf(CArray.TYPE)) { + if(args[0].isInstanceOf(CArray.TYPE, null, env)) { CArray ca = (CArray) args[0]; if(index instanceof CSlice) { // Deep clone the array if the "index" is the initial one. if(((CSlice) index).getStart() == 0 && ((CSlice) index).getFinish() == -1) { - return ca.deepClone(t); + return ca.deepClone(t, env); } else if(ca.inAssociativeMode()) { throw new CRECastException("Array slices are not allowed with an associative array", t); } @@ -196,29 +196,29 @@ public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed.. try { //Convert negative indexes if(start < 0) { - start = ca.size() + start; + start = ca.size(env) + start; if(start < 0) { throw new CREIndexOverflowException("The element at index \"" + ((CSlice) index).getStart() + "\" does not exist", t); } } if(finish < 0) { - finish = ca.size() + finish; + finish = ca.size(env) + finish; if(finish < 0) { throw new CREIndexOverflowException("The element at index \"" + ((CSlice) index).getFinish() + "\" does not exist", t); } } - CArray na = ca.createNew(t); + CArray na = ca.createNew(t, env); if(finish < start) { //return an empty array in cases where the indexes don't make sense return na; } for(long i = start; i <= finish; i++) { try { - na.push(ca.get((int) i, t).clone(), t); + na.push(ca.get((int) i, t, env).clone(), t, env); } catch(CloneNotSupportedException e) { - na.push(ca.get((int) i, t), t); + na.push(ca.get((int) i, t, env), t, env); } } return na; @@ -231,10 +231,10 @@ public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed.. if(index instanceof CNull) { throw new CRECastException("Expected a number, but received null instead", t); } - long iindex = ArgumentValidation.getInt(index, t); + long iindex = ArgumentValidation.getInt(index, t, env); if(iindex < 0) { //negative index, convert to positive index - iindex = ca.size() + iindex; + iindex = ca.size(env) + iindex; if(iindex < 0) { if(defaultConstruct != null) { return defaultConstruct; @@ -242,32 +242,32 @@ public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed.. throw new CREIndexOverflowException("The element at index \"" + index.val() + "\" does not exist", t); } - } else if(defaultConstruct != null && iindex >= ca.size()) { + } else if(defaultConstruct != null && iindex >= ca.size(env)) { return defaultConstruct; } - return ca.get(iindex, t); + return ca.get(iindex, t, env); } else { if(defaultConstruct != null && !ca.containsKey(index.val())) { return defaultConstruct; } - return ca.get(index, t); + return ca.get(index, t, env); } } catch(ConfigRuntimeException e) { if(env.getEnv(GlobalEnv.class).GetFlag(GlobalEnv.FLAG_ARRAY_SPECIAL_GET) != null) { //They are asking for an array that doesn't exist yet, so let's create it now. CArray c; if(ca.inAssociativeMode()) { - c = CArray.GetAssociativeArray(t); + c = CArray.GetAssociativeArray(t, null, env); } else { c = new CArray(t); } - ca.set(index, c, t); + ca.set(index, c, t, env); return c; } throw e; } } - } else if(args[0].isInstanceOf(com.laytonsmith.core.natives.interfaces.Iterable.TYPE)) { + } else if(args[0].isInstanceOf(com.laytonsmith.core.natives.interfaces.Iterable.TYPE, null, env)) { com.laytonsmith.core.natives.interfaces.Iterable aa = (com.laytonsmith.core.natives.interfaces.Iterable) args[0]; if(index instanceof CSlice cSlice) { @@ -277,19 +277,19 @@ public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed.. try { //Convert negative indexes if(start < 0) { - start = (int) aa.size() + start; + start = (int) aa.size(env) + start; } if(finish < 0) { - finish = (int) aa.size() + finish; + finish = (int) aa.size(env) + finish; } - return aa.slice(start, finish + 1, t); + return aa.slice(start, finish + 1, t, env); } catch(NumberFormatException e) { throw new CRECastException("Ranges must be integer numbers, i.e., [0..5]", t); } - } else if(index.isInstanceOf(CInt.TYPE)) { - return aa.get(ArgumentValidation.getInt32(index, t), t); + } else if(index.isInstanceOf(CInt.TYPE, null, env)) { + return aa.get(ArgumentValidation.getInt32(index, t, env), t, env); } else { - return aa.get(index, t); + return aa.get(index, t, env); } } else { throw new CRECastException("Argument 1 of " + this.getName() + " must be an Iterable object, such as an array.", t); @@ -349,10 +349,10 @@ public Mixed optimize(Target t, Environment env, Mixed... args) throws ConfigCom if(args.length == 0) { throw new CRECastException("Argument 1 of " + this.getName() + " must be an array", t); } - if(args[0].isInstanceOf(ArrayAccess.TYPE)) { + if(args[0].isInstanceOf(ArrayAccess.TYPE, null, env)) { ArrayAccess aa = (ArrayAccess) args[0]; if(args.length > 1 && !aa.canBeAssociative()) { - if(!(args[1].isInstanceOf(CInt.TYPE)) && !(args[1] instanceof CSlice)) { + if(!(args[1].isInstanceOf(CInt.TYPE, null, env)) && !(args[1] instanceof CSlice)) { throw new ConfigCompileException("Accessing an element as an associative array," + " when it can only accept integers.", t); } @@ -417,12 +417,12 @@ public Mixed execs(Target t, Environment env, Script parent, ParseTree... nodes) } Mixed index = parent.seval(nodes[1], env); Mixed value = parent.seval(nodes[2], env); - if(!(array.isInstanceOf(ArrayAccessSet.TYPE))) { + if(!(array.isInstanceOf(ArrayAccessSet.TYPE, null, env))) { throw new CRECastException("Argument 1 of " + this.getName() + " must be an array, or implement ArrayAccessSet.", t); } try { - ((ArrayAccessSet) array).set(index, value, t); + ((ArrayAccessSet) array).set(index, value, t, env); } catch(IndexOutOfBoundsException e) { throw new CREIndexOverflowException("The index " + new CString(index).getQuote() + " is out of bounds", t); } @@ -431,9 +431,9 @@ public Mixed execs(Target t, Environment env, Script parent, ParseTree... nodes) @Override public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { - if(args[0].isInstanceOf(CArray.TYPE)) { + if(args[0].isInstanceOf(CArray.TYPE, null, env)) { try { - ((CArray) args[0]).set(args[1], args[2], t); + ((CArray) args[0]).set(args[1], args[2], t, env); } catch(IndexOutOfBoundsException e) { throw new CREIndexOverflowException("The index " + args[1].val() + " is out of bounds", t); } @@ -520,11 +520,11 @@ public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed.. throw new CREInsufficientArgumentsException( "At least 2 arguments must be provided to " + this.getName(), t); } - if(args[0].isInstanceOf(CArray.TYPE)) { + if(args[0].isInstanceOf(CArray.TYPE, null, env)) { CArray array = (CArray) args[0]; - int initialSize = (int) array.size(); + int initialSize = (int) array.size(env); for(int i = 1; i < args.length; i++) { - array.push(args[i], t); + array.push(args[i], t, env); for(Iterator iterator : env.getEnv(GlobalEnv.class).GetArrayAccessIteratorsFor(((ArrayAccess) args[0]))) { //This is always pushing after the current index. //Given that this is the last one, we don't need to waste @@ -618,11 +618,11 @@ public Boolean runAsync() { @Override public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { - CArray array = ArgumentValidation.getArray(args[0], t); + CArray array = ArgumentValidation.getArray(args[0], t, environment); Mixed value = args[1]; - int index = ArgumentValidation.getInt32(args[2], t); + int index = ArgumentValidation.getInt32(args[2], t, environment); try { - array.push(value, index, t); + array.push(value, index, t, environment); //If the push succeeded (actually an insert) we need to check to see if we are currently iterating //and act appropriately. for(Iterator iterator : environment.getEnv(GlobalEnv.class).GetArrayAccessIteratorsFor(array)) { @@ -715,11 +715,11 @@ public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed.. if(args[0] instanceof ArrayAccess) { aa = (ArrayAccess) args[0]; } else { - CArray ca = ArgumentValidation.getArray(args[0], t); + CArray ca = ArgumentValidation.getArray(args[0], t, env); aa = ca; } - for(Mixed key : aa.keySet()) { - if(new equals().exec(t, env, null, aa.get(key, t), args[1]).getBoolean()) { + for(Mixed key : aa.keySet(env)) { + if(new equals().exec(t, env, null, aa.get(key, t, env), args[1]).getBoolean()) { return CBoolean.TRUE; } } @@ -826,10 +826,10 @@ public Mixed exec(Target t, Environment environment, GenericParameters generics, if(args[0] instanceof ArrayAccess a) { aa = a; } else { - aa = ArgumentValidation.getArray(args[0], t); + aa = ArgumentValidation.getArray(args[0], t, environment); } - for(Mixed key : aa.keySet()) { - if(new equals_ic().exec(t, environment, null, aa.get(key, t), args[1]).getBoolean()) { + for(Mixed key : aa.keySet(environment)) { + if(new equals_ic().exec(t, environment, null, aa.get(key, t, environment), args[1]).getBoolean()) { return CBoolean.TRUE; } } @@ -880,10 +880,10 @@ public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed.. if(args[0] instanceof ArrayAccess a) { aa = a; } else { - aa = ArgumentValidation.getArray(args[0], t); + aa = ArgumentValidation.getArray(args[0], t, env); } - for(Mixed key : aa.keySet()) { - if(new sequals().exec(t, env, null, aa.get(key, t), args[1]).getBoolean()) { + for(Mixed key : aa.keySet(env)) { + if(new sequals().exec(t, env, null, aa.get(key, t, env), args[1]).getBoolean()) { return CBoolean.TRUE; } } @@ -992,17 +992,17 @@ public Boolean runAsync() { @Override public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { - if(args[0].isInstanceOf(CArray.TYPE)) { + if(args[0].isInstanceOf(CArray.TYPE, null, env)) { Mixed m = args[0]; for(int i = 1; i < args.length; i++) { - if(!(m.isInstanceOf(CArray.TYPE))) { + if(!(m.isInstanceOf(CArray.TYPE, null, env))) { return CBoolean.FALSE; } CArray ca = (CArray) m; if(!ca.inAssociativeMode()) { try { - int index = ArgumentValidation.getInt32(args[i], t); - if(index >= ca.size() || index < 0) { + int index = ArgumentValidation.getInt32(args[i], t, env); + if(index >= ca.size(env) || index < 0) { return CBoolean.FALSE; } } catch(ConfigRuntimeException e) { @@ -1014,7 +1014,7 @@ public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed.. return CBoolean.FALSE; } } - m = ca.get(args[i], t); + m = ca.get(args[i], t, env); } return CBoolean.TRUE; } else { @@ -1111,15 +1111,15 @@ public Boolean runAsync() { @Override public CArray exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { - if(args[0].isInstanceOf(CArray.TYPE) && args[1].isInstanceOf(CInt.TYPE)) { + if(args[0].isInstanceOf(CArray.TYPE, null, env) && args[1].isInstanceOf(CInt.TYPE, null, env)) { CArray original = (CArray) args[0]; int size = (int) ((CInt) args[1]).getInt(); Mixed fill = CNull.NULL; if(args.length == 3) { fill = args[2]; } - for(long i = original.size(); i < size; i++) { - original.push(fill, t); + for(long i = original.size(env); i < size; i++) { + original.push(fill, t, env); } } else { throw new CRECastException( @@ -1204,21 +1204,21 @@ public CArray exec(Target t, Environment env, GenericParameters generics, Mixed. long finish = 0; long increment = 1; if(args.length == 1) { - finish = ArgumentValidation.getInt(args[0], t); + finish = ArgumentValidation.getInt(args[0], t, env); } else if(args.length == 2) { - start = ArgumentValidation.getInt(args[0], t); - finish = ArgumentValidation.getInt(args[1], t); + start = ArgumentValidation.getInt(args[0], t, env); + finish = ArgumentValidation.getInt(args[1], t, env); } else if(args.length == 3) { - start = ArgumentValidation.getInt(args[0], t); - finish = ArgumentValidation.getInt(args[1], t); - increment = ArgumentValidation.getInt(args[2], t); + start = ArgumentValidation.getInt(args[0], t, env); + finish = ArgumentValidation.getInt(args[1], t, env); + increment = ArgumentValidation.getInt(args[2], t, env); } if(start < finish && increment < 0 || start > finish && increment > 0 || increment == 0) { - return new CArray(t); + return new CArray(t, null, env); } CArray ret = new CArray(t); for(long i = start; (increment > 0 ? i < finish : i > finish); i = i + increment) { - ret.push(new CInt(i, t), t); + ret.push(new CInt(i, t), t, env); } return ret; } @@ -1282,11 +1282,11 @@ public Boolean runAsync() { @Override public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { // As an exception, strings aren't supported here. There's no reason to do this for a string that isn't accidental. - if(args[0].isInstanceOf(ArrayAccess.TYPE) && !(args[0].isInstanceOf(CString.TYPE))) { + if(args[0].isInstanceOf(ArrayAccess.TYPE, null, env) && !(args[0].isInstanceOf(CString.TYPE, null, env))) { ArrayAccess ca = (ArrayAccess) args[0]; CArray ca2 = new CArray(t); - for(Mixed c : ca.keySet()) { - ca2.push(c, t); + for(Mixed c : ca.keySet(env)) { + ca2.push(c, t, env); } return ca2; } else { @@ -1348,11 +1348,11 @@ public Boolean runAsync() { @Override public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { - if(args[0].isInstanceOf(CArray.TYPE)) { - CArray ca = ArgumentValidation.getArray(args[0], t); + if(args[0].isInstanceOf(CArray.TYPE, null, env)) { + CArray ca = ArgumentValidation.getArray(args[0], t, env); CArray ca2 = new CArray(t); - for(Mixed c : ca.keySet()) { - ca2.push(ca.get(c, t), t); + for(Mixed c : ca.keySet(env)) { + ca2.push(ca.get(c, t, env), t, env); } return ca2; } else { @@ -1421,19 +1421,19 @@ public Mixed exec(Target t, Environment environment, GenericParameters generics, throw new CREInsufficientArgumentsException("array_merge must be called with at least two parameters", t); } for(Mixed arg : args) { - if(arg.isInstanceOf(ArrayAccess.TYPE)) { + if(arg.isInstanceOf(ArrayAccess.TYPE, null, environment)) { com.laytonsmith.core.natives.interfaces.Iterable cur = (com.laytonsmith.core.natives.interfaces.Iterable) arg; if(!cur.isAssociative()) { - for(int j = 0; j < cur.size(); j++) { - newArray.push(cur.get(j, t), t); + for(int j = 0; j < cur.size(environment); j++) { + newArray.push(cur.get(j, t, environment), t, environment); } } else { - for(Mixed key : cur.keySet()) { - if(key.isInstanceOf(CInt.TYPE)) { - newArray.set(key, cur.get((int) ((CInt) key).getInt(), t), t); + for(Mixed key : cur.keySet(environment)) { + if(key.isInstanceOf(CInt.TYPE, null, environment)) { + newArray.set(key, cur.get((int) ((CInt) key).getInt(), t, environment), t, environment); } else { - newArray.set(key, cur.get(key.val(), t), t); + newArray.set(key, cur.get(key.val(), t, environment), t, environment); } } } @@ -1502,12 +1502,12 @@ public Boolean runAsync() { @Override public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { - CArray array = ArgumentValidation.getArray(args[0], t); + CArray array = ArgumentValidation.getArray(args[0], t, environment); if(array.isAssociative()) { - return array.remove(args[1]); + return array.remove(args[1], environment); } else { - int index = ArgumentValidation.getInt32(args[1], t); - Mixed removed = array.remove(args[1]); + int index = ArgumentValidation.getInt32(args[1], t, environment); + Mixed removed = array.remove(args[1], environment); //If the removed index is <= the current index, we need to decrement the counter. for(Iterator iterator : environment.getEnv(GlobalEnv.class).GetArrayAccessIteratorsFor(array)) { if(index <= iterator.getCurrent()) { @@ -1566,7 +1566,7 @@ public Boolean runAsync() { @Override public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { - if(!(args[0].isInstanceOf(ArrayAccess.TYPE))) { + if(!(args[0].isInstanceOf(ArrayAccess.TYPE, null, environment))) { throw new CRECastException("Expecting argument 1 to be an ArrayAccess type object", t); } StringBuilder b = new StringBuilder(); @@ -1576,8 +1576,8 @@ public Mixed exec(Target t, Environment environment, GenericParameters generics, glue = ArgumentValidation.getObject(args[1], t, CPrimitive.class).val(); } boolean first = true; - for(Mixed key : ca.keySet()) { - Mixed value = ca.get(key, t); + for(Mixed key : ca.keySet(environment)) { + Mixed value = ca.get(key, t, environment); if(!first) { b.append(glue).append(value.val()); } else { @@ -1622,7 +1622,7 @@ public Boolean runAsync() { @Override public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { - CArray array = ArgumentValidation.getArray(args[0], t); + CArray array = ArgumentValidation.getArray(args[0], t, environment); String innerGlue = ArgumentValidation.getString(args[1], t); String outerGlue = ArgumentValidation.getString(args[2], t); if(!array.isAssociative()) { @@ -1632,8 +1632,8 @@ public Mixed exec(Target t, Environment environment, GenericParameters generics, StringBuilder b = new StringBuilder(); boolean first = true; - for(Mixed key : array.keySet()) { - Mixed value = array.get(key, t); + for(Mixed key : array.keySet(environment)) { + Mixed value = array.get(key, t, environment); if(!first) { b.append(outerGlue); } @@ -1715,7 +1715,7 @@ public Boolean runAsync() { @Override public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { - return new CSlice(ArgumentValidation.getInt(args[0], t), ArgumentValidation.getInt(args[1], t), t); + return new CSlice(ArgumentValidation.getInt(args[0], t, environment), ArgumentValidation.getInt(args[1], t, environment), t); } @Override @@ -1756,18 +1756,18 @@ public Boolean runAsync() { @Override public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { - if(!(args[0].isInstanceOf(CArray.TYPE))) { + if(!(args[0].isInstanceOf(CArray.TYPE, null, environment))) { throw new CRECastException("The first parameter to array_sort must be an array", t); } CArray ca = (CArray) args[0]; CArray.ArraySortType sortType = CArray.ArraySortType.REGULAR; CClosure customSort = null; - if(ca.size() <= 1) { + if(ca.size(environment) <= 1) { return ca; } try { if(args.length == 2) { - if(args[1].isInstanceOf(CClosure.TYPE)) { + if(args[1].isInstanceOf(CClosure.TYPE, null, environment)) { sortType = null; customSort = (CClosure) args[1]; } else { @@ -1782,57 +1782,57 @@ public Mixed exec(Target t, Environment environment, GenericParameters generics, if(ca.isAssociative()) { throw new CRECastException("Associative arrays may not be sorted using a custom comparator.", t); } - CArray sorted = customSort(ca, customSort, t); + CArray sorted = customSort(ca, customSort, t, environment); //Clear it out and re-apply the values, so this is in place. ca.clear(); - for(Mixed c : sorted.keySet()) { - ca.set(c, sorted.get(c, t), t); + for(Mixed c : sorted.keySet(environment)) { + ca.set(c, sorted.get(c, t, environment), t, environment); } } else { - ca.sort(sortType); + ca.sort(sortType, environment); } return ca; } - private CArray customSort(CArray ca, CClosure closure, Target t) { - if(ca.size() <= 1) { + private CArray customSort(CArray ca, CClosure closure, Target t, Environment env) { + if(ca.size(env) <= 1) { return ca; } CArray left = new CArray(t); CArray right = new CArray(t); - int middle = (int) (ca.size() / 2); + int middle = (int) (ca.size(env) / 2); for(int i = 0; i < middle; i++) { - left.push(ca.get(i, t), t); + left.push(ca.get(i, t, env), t, env); } - for(int i = middle; i < ca.size(); i++) { - right.push(ca.get(i, t), t); + for(int i = middle; i < ca.size(env); i++) { + right.push(ca.get(i, t, env), t, env); } - left = customSort(left, closure, t); - right = customSort(right, closure, t); + left = customSort(left, closure, t, env); + right = customSort(right, closure, t, env); - return merge(left, right, closure, t); + return merge(left, right, closure, t, env); } - private CArray merge(CArray left, CArray right, CClosure closure, Target t) { + private CArray merge(CArray left, CArray right, CClosure closure, Target t, Environment env) { CArray result = new CArray(t); - while(left.size() > 0 || right.size() > 0) { - if(left.size() > 0 && right.size() > 0) { + while(left.size(env) > 0 || right.size(env) > 0) { + if(left.size(env) > 0 && right.size(env) > 0) { // Compare the first two elements of each side - Mixed l = left.get(0, t); - Mixed r = right.get(0, t); + Mixed l = left.get(0, t, env); + Mixed r = right.get(0, t, env); Mixed c = closure.executeCallable(null, t, l, r); int value; if(c instanceof CNull) { value = 0; - } else if(c.isInstanceOf(CBoolean.TYPE)) { + } else if(c instanceof CBoolean) { if(((CBoolean) c).getBoolean()) { value = 1; } else { value = -1; } - } else if(c.isInstanceOf(CInt.TYPE)) { + } else if(c.isInstanceOf(CInt.TYPE, null, env)) { long longVal = ((CInt) c).getInt(); value = (longVal > 0 ? 1 : (longVal < 0 ? -1 : 0)); } else { @@ -1840,18 +1840,18 @@ private CArray merge(CArray left, CArray right, CClosure closure, Target t) { + " type). It must always return true, false, null, or an integer.", t); } if(value <= 0) { - result.push(left.get(0, t), t); - left.remove(0); + result.push(left.get(0, t, env), t, env); + left.remove(0, env); } else { - result.push(right.get(0, t), t); - right.remove(0); + result.push(right.get(0, t, env), t, env); + right.remove(0, env); } - } else if(left.size() > 0) { - result.push(left.get(0, t), t); - left.remove(0); - } else if(right.size() > 0) { - result.push(right.get(0, t), t); - right.remove(0); + } else if(left.size(env) > 0) { + result.push(left.get(0, t, env), t, env); + left.remove(0, env); + } else if(right.size(env) > 0) { + result.push(right.get(0, t, env), t, env); + right.remove(0, env); } } return result; @@ -1994,7 +1994,7 @@ public Boolean runAsync() { @Override public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { startup(); - final CArray array = ArgumentValidation.getArray(args[0], t); + final CArray array = ArgumentValidation.getArray(args[0], t, environment); final CString sortType = new CString(args.length > 2 ? args[1].val() : CArray.ArraySortType.REGULAR.name(), t); final CClosure callback = ArgumentValidation.getObject((args.length == 2 ? args[1] : args[2]), t, CClosure.class); queue.invokeLater(environment.getEnv(StaticRuntimeEnv.class).GetDaemonManager(), new Runnable() { @@ -2053,15 +2053,15 @@ public Boolean runAsync() { @Override public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { - CArray array = ArgumentValidation.getArray(args[0], t); + CArray array = ArgumentValidation.getArray(args[0], t, environment); //This needs to be in terms of array_remove, to ensure that the iteration //logic is followed. We will iterate backwards, however, to make the //process more efficient, unless this is an associative array. if(array.isAssociative()) { array.removeValues(args[1]); } else { - for(long i = array.size() - 1; i >= 0; i--) { - if(BasicLogic.equals.doEquals(array.get(i, t), args[1])) { + for(long i = array.size(environment) - 1; i >= 0; i--) { + if(BasicLogic.equals.doEquals(array.get(i, t, environment), args[1])) { new array_remove().exec(t, environment, null, array, new CInt(i, t)); } } @@ -2122,10 +2122,10 @@ public Boolean runAsync() { @Override public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { - if(!(args[0].isInstanceOf(CArray.TYPE))) { + if(!(args[0].isInstanceOf(CArray.TYPE, null, environment))) { throw new CRECastException("Expected parameter 1 to be an array, but was " + args[0].val(), t); } - return ((CArray) args[0]).indexesOf(args[1]); + return ((CArray) args[0]).indexesOf(args[1], environment); } @Override @@ -2186,10 +2186,10 @@ public Boolean runAsync() { @Override public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { CArray ca = (CArray) new array_indexes().exec(t, environment, generics, args); - if(ca.isEmpty()) { + if(ca.isEmpty(environment)) { return CNull.NULL; } else { - return ca.get(0, t); + return ca.get(0, t, environment); } } @@ -2245,10 +2245,10 @@ public Boolean runAsync() { @Override public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { CArray ca = (CArray) new array_indexes().exec(t, environment, generics, args); - if(ca.isEmpty()) { + if(ca.isEmpty(environment)) { return CNull.NULL; } else { - return ca.get(ca.size() - 1, t); + return ca.get(ca.size(environment) - 1, t, environment); } } @@ -2303,7 +2303,7 @@ public Boolean runAsync() { @Override public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { - if(args[0].isInstanceOf(CArray.TYPE)) { + if(args[0].isInstanceOf(CArray.TYPE, null, environment)) { ((CArray) args[0]).reverse(t); } return args[0]; @@ -2365,34 +2365,34 @@ public Boolean runAsync() { public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { long number = 1; boolean getKeys = true; - CArray array = ArgumentValidation.getArray(args[0], t); + CArray array = ArgumentValidation.getArray(args[0], t, environment); CArray newArray = new CArray(t); - if(array.isEmpty()) { + if(array.isEmpty(environment)) { return newArray; } if(args.length > 1) { - number = ArgumentValidation.getInt(args[1], t); + number = ArgumentValidation.getInt(args[1], t, environment); } if(number < 1) { throw new CRERangeException("number may not be less than 1.", t); } - if(number > array.size()) { + if(number > array.size(environment)) { throw new CRERangeException("Number cannot be larger than array size", t); } if(args.length > 2) { - getKeys = ArgumentValidation.getBoolean(args[2], t); + getKeys = ArgumentValidation.getBooleanObject(args[2], t, environment); } LinkedHashSet randoms = new LinkedHashSet<>(); while(randoms.size() < number) { - randoms.add(java.lang.Math.abs(r.nextInt() % (int) array.size())); + randoms.add(java.lang.Math.abs(r.nextInt() % (int) array.size(environment))); } - List keySet = new ArrayList<>(array.keySet()); + List keySet = new ArrayList<>(array.keySet(environment)); for(Integer i : randoms) { if(getKeys) { - newArray.push(keySet.get(i), t); + newArray.push(keySet.get(i), t, environment); } else { - newArray.push(array.get(keySet.get(i), t), t); + newArray.push(array.get(keySet.get(i), t, environment), t, environment); } } return newArray; @@ -2468,27 +2468,27 @@ public Boolean runAsync() { @Override public CArray exec(final Target t, final Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { - CArray array = ArgumentValidation.getArray(args[0], t); + CArray array = ArgumentValidation.getArray(args[0], t, environment); boolean compareTypes = true; if(args.length == 2) { - compareTypes = ArgumentValidation.getBoolean(args[1], t); + compareTypes = ArgumentValidation.getBooleanObject(args[1], t, environment); } final boolean fCompareTypes = compareTypes; if(array.inAssociativeMode()) { return array.clone(); } else { - List asList = array.asList(); + List asList = array.asList(environment); CArray newArray = new CArray(t); Set set = new LinkedComparatorSet<>(asList, new LinkedComparatorSet.EqualsComparator() { @Override public boolean checkIfEquals(Mixed item1, Mixed item2) { - return (fCompareTypes && ArgumentValidation.getBoolean(sequals.exec(t, environment, null, item1, item2), t)) - || (!fCompareTypes && ArgumentValidation.getBoolean(equals.exec(t, environment, null, item1, item2), t)); + return (fCompareTypes && ArgumentValidation.getBooleanObject(sequals.exec(t, environment, null, item1, item2), t, environment)) + || (!fCompareTypes && ArgumentValidation.getBooleanObject(equals.exec(t, environment, null, item1, item2), t, environment)); } }); for(Mixed c : set) { - newArray.push(c, t); + newArray.push(c, t, environment); } return newArray; } @@ -2560,34 +2560,34 @@ public Mixed exec(Target t, Environment environment, GenericParameters generics, if(!(args[0] instanceof com.laytonsmith.core.natives.interfaces.Iterable)) { throw new CRECastException("Expecting an array for argument 1", t); } - if(!(args[1].isInstanceOf(CClosure.TYPE))) { + if(!(args[1].isInstanceOf(CClosure.TYPE, null, environment))) { throw new CRECastException("Expecting a closure for argument 2", t); } array = (com.laytonsmith.core.natives.interfaces.Iterable) args[0]; closure = (CClosure) args[1]; CArray newArray; if(array.isAssociative()) { - newArray = CArray.GetAssociativeArray(t); - for(Mixed key : array.keySet()) { - Mixed value = array.get(key, t); + newArray = CArray.GetAssociativeArray(t, null, environment); + for(Mixed key : array.keySet(environment)) { + Mixed value = array.get(key, t, environment); Mixed ret = closure.executeCallable(environment, t, key, value); - boolean bret = ArgumentValidation.getBooleanish(ret, t); + boolean bret = ArgumentValidation.getBooleanish(ret, t, environment); if(bret) { - newArray.set(key, value, t); + newArray.set(key, value, t, environment); } } } else { newArray = new CArray(t); - for(int i = 0; i < array.size(); i++) { + for(int i = 0; i < array.size(environment); i++) { Mixed key = new CInt(i, t); - Mixed value = array.get(i, t); + Mixed value = array.get(i, t, environment); Mixed ret = closure.executeCallable(environment, t, key, value); if(ret == CNull.NULL) { ret = CBoolean.FALSE; } - boolean bret = ArgumentValidation.getBooleanish(ret, t); + boolean bret = ArgumentValidation.getBooleanish(ret, t, environment); if(bret) { - newArray.push(value, t); + newArray.push(value, t, environment); } } } @@ -2661,10 +2661,10 @@ public Mixed exec(Target t, Environment environment, GenericParameters generics, if(args.length != 1) { throw new CREInsufficientArgumentsException("Expecting exactly one argument", t); } - if(!(args[0].isInstanceOf(CArray.TYPE))) { + if(!(args[0].isInstanceOf(CArray.TYPE, null, environment))) { throw new CRECastException("Expecting argument 1 to be an array", t); } - return ((CArray) args[0]).deepClone(t); + return ((CArray) args[0]).deepClone(t, environment); } @Override @@ -2729,13 +2729,13 @@ public Mixed exec(Target t, Environment environment, GenericParameters generics, if(args.length != 1) { throw new CREInsufficientArgumentsException("Expecting exactly one argument", t); } - if(!(args[0].isInstanceOf(CArray.TYPE))) { + if(!(args[0].isInstanceOf(CArray.TYPE, null, environment))) { throw new CRECastException("Expecting argument 1 to be an array", t); } CArray array = (CArray) args[0]; - CArray shallowClone = (array.isAssociative() ? CArray.GetAssociativeArray(t) : new CArray(t)); - for(Mixed key : array.keySet()) { - shallowClone.set(key, array.get(key, t), t); + CArray shallowClone = (array.isAssociative() ? CArray.GetAssociativeArray(t, null, environment) : new CArray(t)); + for(Mixed key : array.keySet(environment)) { + shallowClone.set(key, array.get(key, t, environment), t, environment); } return shallowClone; } @@ -2803,12 +2803,12 @@ public Mixed exec(Target t, Environment environment, GenericParameters generics, if(args[0] instanceof CFixedArray fa) { aa = fa; } else { - aa = ArgumentValidation.getArray(args[0], t); + aa = ArgumentValidation.getArray(args[0], t, environment); } CClosure closure = ArgumentValidation.getObject(args[1], t, CClosure.class); - for(Mixed key : aa.keySet()) { + for(Mixed key : aa.keySet(environment)) { try { - closure.executeCallable(environment, t, key, aa.get(key, t)); + closure.executeCallable(environment, t, key, aa.get(key, t, environment)); } catch(ProgramFlowManipulationException ex) { // Ignored } @@ -2877,20 +2877,20 @@ public Boolean runAsync() { @Override public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { - CArray array = ArgumentValidation.getArray(args[0], t); + CArray array = ArgumentValidation.getArray(args[0], t, environment); CClosure closure = ArgumentValidation.getObject(args[1], t, CClosure.class); - if(array.isEmpty()) { + if(array.isEmpty(environment)) { return CNull.NULL; } - if(array.size() == 1) { + if(array.size(environment) == 1) { // This line looks bad, but all it does is return the first (and since we know only) value in the array, // whether or not it is associative or normal. - return array.get(array.keySet().toArray(new Mixed[0])[0], t); + return array.get(array.keySet(environment).toArray(Mixed[]::new)[0], t, environment); } - List keys = new ArrayList<>(array.keySet()); - Mixed lastValue = array.get(keys.get(0), t); + List keys = new ArrayList<>(array.keySet(environment)); + Mixed lastValue = array.get(keys.get(0), t, environment); for(int i = 1; i < keys.size(); ++i) { - lastValue = closure.executeCallable(environment, t, lastValue, array.get(keys.get(i), t)); + lastValue = closure.executeCallable(environment, t, lastValue, array.get(keys.get(i), t, environment)); if(lastValue instanceof CVoid) { throw new CREIllegalArgumentException("The closure passed to " + getName() + " cannot return void.", t); } @@ -2962,20 +2962,20 @@ public Boolean runAsync() { @Override public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { - CArray array = ArgumentValidation.getArray(args[0], t); + CArray array = ArgumentValidation.getArray(args[0], t, environment); CClosure closure = ArgumentValidation.getObject(args[1], t, CClosure.class); - if(array.isEmpty()) { + if(array.isEmpty(environment)) { return CNull.NULL; } - if(array.size() == 1) { + if(array.size(environment) == 1) { // This line looks bad, but all it does is return the first (and since we know only) value in the array, // whether or not it is associative or normal. - return array.get(array.keySet().toArray(new Mixed[0])[0], t); + return array.get(array.keySet(environment).toArray(Mixed[]::new)[0], t, environment); } - List keys = new ArrayList<>(array.keySet()); - Mixed lastValue = array.get(keys.get(keys.size() - 1), t); + List keys = new ArrayList<>(array.keySet(environment)); + Mixed lastValue = array.get(keys.get(keys.size() - 1), t, environment); for(int i = keys.size() - 2; i >= 0; --i) { - lastValue = closure.executeCallable(environment, t, lastValue, array.get(keys.get(i), t)); + lastValue = closure.executeCallable(environment, t, lastValue, array.get(keys.get(i), t, environment)); if(lastValue instanceof CVoid) { throw new CREIllegalArgumentException("The closure passed to " + getName() + " cannot return void.", t); } @@ -3047,11 +3047,11 @@ public Boolean runAsync() { @Override public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { - CArray array = ArgumentValidation.getArray(args[0], t); + CArray array = ArgumentValidation.getArray(args[0], t, environment); CClosure closure = ArgumentValidation.getObject(args[1], t, CClosure.class); - for(Mixed c : array.keySet()) { - Mixed fr = closure.executeCallable(environment, t, array.get(c, t)); - boolean ret = ArgumentValidation.getBooleanish(fr, t); + for(Mixed c : array.keySet(environment)) { + Mixed fr = closure.executeCallable(environment, t, array.get(c, t, environment)); + boolean ret = ArgumentValidation.getBooleanish(fr, t, environment); if(ret == false) { return CBoolean.FALSE; } @@ -3120,11 +3120,11 @@ public Boolean runAsync() { @Override public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { - CArray array = ArgumentValidation.getArray(args[0], t); + CArray array = ArgumentValidation.getArray(args[0], t, environment); CClosure closure = ArgumentValidation.getObject(args[1], t, CClosure.class); - for(Mixed c : array.keySet()) { - Mixed fr = closure.executeCallable(environment, t, array.get(c, t)); - boolean ret = ArgumentValidation.getBooleanish(fr, t); + for(Mixed c : array.keySet(environment)) { + Mixed fr = closure.executeCallable(environment, t, array.get(c, t, environment)); + boolean ret = ArgumentValidation.getBooleanish(fr, t, environment); if(ret == true) { return CBoolean.TRUE; } @@ -3193,17 +3193,17 @@ public Boolean runAsync() { @Override public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { - CArray array = ArgumentValidation.getArray(args[0], t); + CArray array = ArgumentValidation.getArray(args[0], t, environment); CClosure closure = ArgumentValidation.getObject(args[1], t, CClosure.class); - CArray newArray = (array.isAssociative() ? CArray.GetAssociativeArray(t) : new CArray(t, (int) array.size())); + CArray newArray = (array.isAssociative() ? CArray.GetAssociativeArray(t, null, environment) : new CArray(t, (int) array.size(environment))); - for(Mixed c : array.keySet()) { - Mixed fr = closure.executeCallable(environment, t, array.get(c, t)); - if(fr.isInstanceOf(CVoid.TYPE)) { + for(Mixed c : array.keySet(environment)) { + Mixed fr = closure.executeCallable(environment, t, array.get(c, t, environment)); + if(fr.isInstanceOf(CVoid.TYPE, null, environment)) { throw new CREIllegalArgumentException("The closure passed to " + getName() + " must return a value.", t); } - newArray.set(c, fr, t); + newArray.set(c, fr, t, environment); } return newArray; @@ -3289,8 +3289,8 @@ public Boolean runAsync() { @Override public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { - CArray one = ArgumentValidation.getArray(args[0], t); - CArray two = ArgumentValidation.getArray(args[1], t); + CArray one = ArgumentValidation.getArray(args[0], t, environment); + CArray two = ArgumentValidation.getArray(args[1], t, environment); CClosure closure = null; ArrayValueComparisonMode mode = ArrayValueComparisonMode.HASH; boolean associativeMode = one.isAssociative() || two.isAssociative(); @@ -3299,7 +3299,7 @@ public Mixed exec(Target t, Environment environment, GenericParameters generics, throw new CREIllegalArgumentException("For associative arrays, only 2 parameters may be provided," + " the comparison mode value is not used.", t); } - if(args[2].isInstanceOf(CClosure.TYPE)) { + if(args[2].isInstanceOf(CClosure.TYPE, null, environment)) { closure = ArgumentValidation.getObject(args[2], t, CClosure.class); } else { mode = ArgumentValidation.getEnum(args[2], ArrayValueComparisonMode.class, t); @@ -3317,14 +3317,14 @@ public Mixed exec(Target t, Environment environment, GenericParameters generics, // Iterate one, and check if the hash of each value is in the set. If so, add it. for(Mixed c : one) { if(a2Set.contains(c.hashCode())) { - ret.push(c, t); + ret.push(c, t, environment); } } } else { - Mixed[] k1 = new Mixed[(int) one.size()]; - Mixed[] k2 = new Mixed[(int) two.size()]; - one.keySet().toArray(k1); - two.keySet().toArray(k2); + Mixed[] k1 = new Mixed[(int) one.size(environment)]; + Mixed[] k2 = new Mixed[(int) two.size(environment)]; + one.keySet(environment).toArray(k1); + two.keySet(environment).toArray(k2); equals equals = new equals(); Function comparisonFunction = mode.getComparisonFunction(); i: @@ -3332,26 +3332,26 @@ public Mixed exec(Target t, Environment environment, GenericParameters generics, for(int j = 0; j < k2.length; j++) { if(associativeMode) { if(equals.exec(t, environment, null, k1[i], k2[j]).getBoolean()) { - ret.set(k1[i], one.get(k1[i], t), t); + ret.set(k1[i], one.get(k1[i], t, environment), t, environment); continue i; } } else { if(closure == null) { if(comparisonFunction != null) { - if(ArgumentValidation.getBoolean(comparisonFunction.exec(t, environment, null, - one.get(k1[i], t), two.get(k2[j], t) - ), t)) { - ret.push(one.get(k1[i], t), t); + if(ArgumentValidation.getBooleanish(comparisonFunction.exec(t, environment, null, + one.get(k1[i], t, environment), two.get(k2[j], t, environment) + ), t, environment)) { + ret.push(one.get(k1[i], t, environment), t, environment); continue i; } } else { throw new Error(); } } else { - Mixed fre = closure.executeCallable(environment, t, one.get(k1[i], t), two.get(k2[j], t)); - boolean res = ArgumentValidation.getBoolean(fre, fre.getTarget()); + Mixed fre = closure.executeCallable(environment, t, one.get(k1[i], t, environment), two.get(k2[j], t, environment)); + boolean res = ArgumentValidation.getBooleanish(fre, fre.getTarget(), environment); if(res) { - ret.push(one.get(k1[i], t), t); + ret.push(one.get(k1[i], t, environment), t, environment); continue i; } } @@ -3478,13 +3478,13 @@ public Boolean runAsync() { public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { Mixed constA = args[0]; Mixed constB = args[1]; - if(!(constA.isInstanceOf(CArray.TYPE))) { + if(!(constA.isInstanceOf(CArray.TYPE, null, environment))) { throw new CREIllegalArgumentException("Expecting an array, but received " + constA, t); } - if(!(constB.isInstanceOf(CArray.TYPE))) { + if(!(constB.isInstanceOf(CArray.TYPE, null, environment))) { throw new CREIllegalArgumentException("Expecting an array, but received " + constB, t); } - return CBoolean.get(subsetOf(constA, constB, t)); + return CBoolean.get(subsetOf(constA, constB, t, environment)); } @Override @@ -3509,11 +3509,11 @@ public ExampleScript[] examples() throws ConfigCompileException { }; } - public boolean subsetOf(Mixed constA, Mixed constB, Target t) { - if(!constA.typeof().equals(constB.typeof())) { + private boolean subsetOf(Mixed constA, Mixed constB, Target t, Environment env) { + if(!constA.typeof(env).equals(constB.typeof(env))) { return false; } - if(constA.isInstanceOf(CArray.TYPE)) { + if(constA.isInstanceOf(CArray.TYPE, null, env)) { CArray arrA = (CArray) constA; CArray arrB = (CArray) constB; if(arrA.isAssociative() != arrB.isAssociative()) { @@ -3524,20 +3524,20 @@ public boolean subsetOf(Mixed constA, Mixed constB, Target t) { if(!arrB.containsKey(key)) { return false; } - Mixed eltA = arrA.get(key, t); - Mixed eltB = arrB.get(key, t); - if(!subsetOf(eltA, eltB, t)) { + Mixed eltA = arrA.get(key, t, env); + Mixed eltB = arrB.get(key, t, env); + if(!subsetOf(eltA, eltB, t, env)) { return false; } } } else { - for(int i = 0; i < arrA.size(); i++) { + for(int i = 0; i < arrA.size(env); i++) { if(!arrB.containsKey(i)) { return false; } - Mixed eltA = arrA.get(i, t); - Mixed eltB = arrB.get(i, t); - if(!subsetOf(eltA, eltB, t)) { + Mixed eltA = arrA.get(i, t, env); + Mixed eltB = arrB.get(i, t, env); + if(!subsetOf(eltA, eltB, t, env)) { return false; } } @@ -3626,12 +3626,12 @@ public Class[] thrown() { @Override public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { - CArray array = ArgumentValidation.getArray(args[0], t); - if(array.isEmpty()) { + CArray array = ArgumentValidation.getArray(args[0], t, environment); + if(array.isEmpty(environment)) { throw new CRELengthException("Array is empty", t); } - List keySet = new ArrayList<>(array.keySet()); - return array.get(keySet.get(java.lang.Math.abs(rand.nextInt() % (int) array.size())), t); + List keySet = new ArrayList<>(array.keySet(environment)); + return array.get(keySet.get(java.lang.Math.abs(rand.nextInt() % (int) array.size(environment))), t, environment); } @Override @@ -3681,8 +3681,8 @@ public Boolean runAsync() { @Override public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { - CArray one = ArgumentValidation.getArray(args[0], t); - CArray two = ArgumentValidation.getArray(args[1], t); + CArray one = ArgumentValidation.getArray(args[0], t, environment); + CArray two = ArgumentValidation.getArray(args[1], t, environment); CClosure closure = null; ArrayValueComparisonMode mode = ArrayValueComparisonMode.HASH; boolean associativeMode = one.isAssociative() || two.isAssociative(); @@ -3691,7 +3691,7 @@ public Mixed exec(Target t, Environment environment, GenericParameters generics, throw new CREIllegalArgumentException("For associative arrays, only 2 parameters may be provided," + " the comparison mode value is not used.", t); } - if(args[2].isInstanceOf(CClosure.TYPE)) { + if(args[2].isInstanceOf(CClosure.TYPE, null, environment)) { closure = ArgumentValidation.getObject(args[2], t, CClosure.class); } else { mode = ArgumentValidation.getEnum(args[2], ArrayValueComparisonMode.class, t); @@ -3709,14 +3709,14 @@ public Mixed exec(Target t, Environment environment, GenericParameters generics, // Iterate one, and check if the hash of each value is in the set. If not, add it. for(Mixed c : one) { if(!a2Set.contains(c.hashCode())) { - ret.push(c, t); + ret.push(c, t, environment); } } } else { - Mixed[] k1 = new Mixed[(int) one.size()]; - Mixed[] k2 = new Mixed[(int) two.size()]; - one.keySet().toArray(k1); - two.keySet().toArray(k2); + Mixed[] k1 = new Mixed[(int) one.size(environment)]; + Mixed[] k2 = new Mixed[(int) two.size(environment)]; + one.keySet(environment).toArray(k1); + two.keySet(environment).toArray(k2); equals equals = new equals(); Function comparisonFunction = mode.getComparisonFunction(); for(int i = 0; i < k1.length; i++) { @@ -3730,9 +3730,9 @@ public Mixed exec(Target t, Environment environment, GenericParameters generics, } else { if(closure == null) { if(comparisonFunction != null) { - if(ArgumentValidation.getBoolean(comparisonFunction.exec(t, environment, null, - one.get(k1[i], t), two.get(k2[j], t) - ), t)) { + if(ArgumentValidation.getBooleanish(comparisonFunction.exec(t, environment, null, + one.get(k1[i], t, environment), two.get(k2[j], t, environment) + ), t, environment)) { addValue = false; break; } @@ -3740,8 +3740,8 @@ public Mixed exec(Target t, Environment environment, GenericParameters generics, throw new Error(); } } else { - Mixed fre = closure.executeCallable(environment, t, one.get(k1[i], t), two.get(k2[j], t)); - boolean res = ArgumentValidation.getBoolean(fre, fre.getTarget()); + Mixed fre = closure.executeCallable(environment, t, one.get(k1[i], t, environment), two.get(k2[j], t, environment)); + boolean res = ArgumentValidation.getBooleanish(fre, fre.getTarget(), environment); if(res) { addValue = false; break; @@ -3751,9 +3751,9 @@ public Mixed exec(Target t, Environment environment, GenericParameters generics, } if(addValue) { if(associativeMode) { - ret.set(k1[i], one.get(k1[i], t), t); + ret.set(k1[i], one.get(k1[i], t, environment), t, environment); } else { - ret.push(one.get(k1[i], t), t); + ret.push(one.get(k1[i], t, environment), t, environment); } } } @@ -3875,7 +3875,7 @@ public Boolean runAsync() { @Override public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { - ArgumentValidation.getArray(args[0], t).clear(); + ArgumentValidation.getArray(args[0], t, env).clear(); return CVoid.VOID; } diff --git a/src/main/java/com/laytonsmith/core/functions/BasicLogic.java b/src/main/java/com/laytonsmith/core/functions/BasicLogic.java index e7ce19f552..70bd420045 100644 --- a/src/main/java/com/laytonsmith/core/functions/BasicLogic.java +++ b/src/main/java/com/laytonsmith/core/functions/BasicLogic.java @@ -259,8 +259,8 @@ public CBoolean exec(Target t, Environment environment, GenericParameters generi if(args.length != 2) { throw new CREFormatException(this.getName() + " expects 2 arguments.", t); } - if(args[1].typeof().equals(args[0].typeof())) { - if(args[0].isInstanceOf(CString.TYPE) && args[1].isInstanceOf(CString.TYPE)) { + if(args[1].typeof(environment).equals(args[0].typeof(environment))) { + if(args[0].isInstanceOf(CString.TYPE, null, environment) && args[1].isInstanceOf(CString.TYPE, null, environment)) { // Check for actual string equality, so we don't do type massaging // for numeric strings. Thus '2' !== '2.0' return CBoolean.get(args[0].val().equals(args[1].val())); @@ -722,7 +722,7 @@ public Boolean runAsync() { @Override public CBoolean exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { - if(args[0].isInstanceOf(CArray.TYPE) && args[1].isInstanceOf(CArray.TYPE)) { + if(args[0].isInstanceOf(CArray.TYPE, null, environment) && args[1].isInstanceOf(CArray.TYPE, null, environment)) { return CBoolean.get(args[0] == args[1]); } else { return new equals().exec(t, environment, null, args); diff --git a/src/main/java/com/laytonsmith/core/functions/BukkitMetadata.java b/src/main/java/com/laytonsmith/core/functions/BukkitMetadata.java index d30985192c..daa621207e 100644 --- a/src/main/java/com/laytonsmith/core/functions/BukkitMetadata.java +++ b/src/main/java/com/laytonsmith/core/functions/BukkitMetadata.java @@ -113,7 +113,7 @@ public Mixed exec(Target t, Environment environment, GenericParameters generics, if(args.length == 1) { metadata = Static.getPlayer(environment, t).getMetadata(args[0].val()); } else { - metadata = GetMetadatable(args[0], t).getMetadata(args[1].val()); + metadata = GetMetadatable(args[0], t, environment).getMetadata(args[1].val()); } if(args.length == 3) { MCPlugin plugin = Static.getPlugin(args[2], t); @@ -164,7 +164,7 @@ public Mixed exec(Target t, Environment environment, GenericParameters generics, metadatable = Static.getPlayer(environment, t); key = args[0].val(); } else { - metadatable = GetMetadatable(args[0], t); + metadatable = GetMetadatable(args[0], t, environment); key = args[1].val(); } if(metadatable.hasMetadata(key)) { @@ -225,7 +225,7 @@ public Mixed exec(Target t, Environment environment, GenericParameters generics, value = args[1]; plugin = StaticLayer.GetPlugin(); } else { - metadatable = GetMetadatable(args[0], t); + metadatable = GetMetadatable(args[0], t, environment); key = args[1].val(); value = args[2]; plugin = (args.length == 4) ? Static.getPlugin(args[3], t) : StaticLayer.GetPlugin(); @@ -266,7 +266,7 @@ public Mixed exec(Target t, Environment environment, GenericParameters generics, metadatable = Static.getPlayer(environment, t); key = args[0].val(); } else { - metadatable = GetMetadatable(args[0], t); + metadatable = GetMetadatable(args[0], t, environment); key = args[1].val(); } if(args.length == 3) { @@ -293,8 +293,8 @@ public Version since() { * @param t * @return */ - private static MCMetadatable GetMetadatable(Mixed construct, Target t) { - if(construct.isInstanceOf(CArray.TYPE)) { + private static MCMetadatable GetMetadatable(Mixed construct, Target t, Environment env) { + if(construct.isInstanceOf(CArray.TYPE, null, env)) { return ObjectGenerator.GetGenerator().location(construct, null, t).getBlock(); } else if(construct instanceof CString) { switch(construct.val().length()) { diff --git a/src/main/java/com/laytonsmith/core/functions/Compiler.java b/src/main/java/com/laytonsmith/core/functions/Compiler.java index 47ff8d62d8..f728618916 100644 --- a/src/main/java/com/laytonsmith/core/functions/Compiler.java +++ b/src/main/java/com/laytonsmith/core/functions/Compiler.java @@ -364,7 +364,7 @@ public static ParseTree rewrite(List list, boolean returnSConcat, // Convert bare string or concat() to type reference if needed. ParseTree typeNode = node.getChildAt(0); - if(!typeNode.getData().isInstanceOf(CClassType.TYPE)) { + if(!(typeNode.getData() instanceof CClassType)) { ParseTree convertedTypeNode = __type_ref__.createFromBareStringOrConcats(typeNode); if(convertedTypeNode != null) { typeNode = convertedTypeNode; @@ -470,7 +470,7 @@ public static ParseTree rewrite(List list, boolean returnSConcat, } if(convertedTypeNode != null - || typeNode.getData().equals(CVoid.VOID) || typeNode.getData().isInstanceOf(CClassType.TYPE)) { + || typeNode.getData().equals(CVoid.VOID) || typeNode.getData() instanceof CClassType) { if(k == list.size() - 1) { // This is not a typed assignment break; @@ -499,7 +499,7 @@ public static ParseTree rewrite(List list, boolean returnSConcat, list.get(k).setChildren(children); break; default: - if(typeNode.getData().equals(CVoid.VOID) || typeNode.getData().isInstanceOf(CClassType.TYPE)) { + if(typeNode.getData().equals(CVoid.VOID) || typeNode.getData() instanceof CClassType) { throw new ConfigCompileException("Unexpected ClassType \"" + typeNode.getData().val() + "\"", typeNode.getTarget()); } @@ -664,7 +664,7 @@ private static void rewriteParenthesis(List list) throws ConfigCompil // Do not rewrite casts to execute() if the callable is the cast (i.e. "(type) (val)"). if(prevNodeVal instanceof CFunction cfunc && cfunc.val().equals(Compiler.p.NAME) && prevNode.numberOfChildren() == 1 - && (prevNode.getChildAt(0).getData().isInstanceOf(CClassType.TYPE) + && (prevNode.getChildAt(0).getData() instanceof CClassType || __type_ref__.createFromBareStringOrConcats(prevNode.getChildAt(0)) != null)) { break; } @@ -1097,7 +1097,7 @@ public ParseTree postParseRewrite(ParseTree ast, Environment env, if(children.size() != 1) { throw new ConfigCompileException(getName() + " can only take one parameter", t); } - if(!(children.get(0).getData().isInstanceOf(CString.TYPE))) { + if(!(children.get(0).getData().isInstanceOf(CString.TYPE, null, env))) { throw new ConfigCompileException("Only hardcoded strings may be passed into " + getName(), t); } String value = children.get(0).getData().val(); @@ -1246,7 +1246,7 @@ public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed.. CClassType type = ArgumentValidation.getClassType(args[1], t); if(!InstanceofUtil.isInstanceof(value, type, env)) { throw new CRECastException( - "Cannot cast from " + value.typeof().getSimpleName() + " to " + type.getSimpleName() + ".", t); + "Cannot cast from " + value.typeof(env).getSimpleName() + " to " + type.getSimpleName() + ".", t); } return value; } diff --git a/src/main/java/com/laytonsmith/core/functions/Crypto.java b/src/main/java/com/laytonsmith/core/functions/Crypto.java index b3e1c13afa..b3164e9d34 100644 --- a/src/main/java/com/laytonsmith/core/functions/Crypto.java +++ b/src/main/java/com/laytonsmith/core/functions/Crypto.java @@ -45,7 +45,7 @@ public static String docs() { + " rather than the default string value \"**secure string**\"."; } - private static CString getHMAC(String algorithm, Target t, Mixed[] args) { + private static CString getHMAC(String algorithm, Target t, Environment env, Mixed[] args) { try { byte[] key; if(args[0] instanceof CByteArray) { @@ -56,7 +56,7 @@ private static CString getHMAC(String algorithm, Target t, Mixed[] args) { SecretKeySpec signingKey = new SecretKeySpec(key, algorithm); Mac mac = Mac.getInstance(algorithm); mac.init(signingKey); - byte[] hmac = mac.doFinal(getByteArrayFromArg(args[1])); + byte[] hmac = mac.doFinal(getByteArrayFromArg(args[1], env)); String hash = StringUtils.toHex(hmac).toLowerCase(); return new CString(hash, t); } catch (NoSuchAlgorithmException | InvalidKeyException ex) { @@ -64,9 +64,9 @@ private static CString getHMAC(String algorithm, Target t, Mixed[] args) { } } - private static byte[] getByteArrayFromArg(Mixed c) { + private static byte[] getByteArrayFromArg(Mixed c, Environment env) { byte[] val; - if(c.isInstanceOf(CSecureString.TYPE)) { + if(c.isInstanceOf(CSecureString.TYPE, null, env)) { val = ArrayUtils.charToBytes(((CSecureString) c).getDecryptedCharArray()); } else if(c instanceof CByteArray) { val = ((CByteArray) c).asByteArrayCopy(); @@ -196,7 +196,7 @@ public Boolean runAsync() { @Override public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { try { - byte[] val = getByteArrayFromArg(args[0]); + byte[] val = getByteArrayFromArg(args[0], environment); MessageDigest digest = java.security.MessageDigest.getInstance("MD5"); digest.update(val); String hash = StringUtils.toHex(digest.digest()).toLowerCase(); @@ -267,7 +267,7 @@ public Boolean runAsync() { @Override public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { try { - byte[] val = getByteArrayFromArg(args[0]); + byte[] val = getByteArrayFromArg(args[0], environment); MessageDigest digest = java.security.MessageDigest.getInstance("SHA1"); digest.update(val); String hash = StringUtils.toHex(digest.digest()).toLowerCase(); @@ -337,7 +337,7 @@ public Boolean runAsync() { @Override public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { try { - byte[] val = getByteArrayFromArg(args[0]); + byte[] val = getByteArrayFromArg(args[0], environment); MessageDigest digest = java.security.MessageDigest.getInstance("SHA-256"); digest.update(val); String hash = StringUtils.toHex(digest.digest()).toLowerCase(); @@ -408,7 +408,7 @@ public Boolean runAsync() { @Override public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { try { - byte[] val = getByteArrayFromArg(args[0]); + byte[] val = getByteArrayFromArg(args[0], environment); MessageDigest digest = java.security.MessageDigest.getInstance("SHA-512"); digest.update(val); String hash = StringUtils.toHex(digest.digest()).toLowerCase(); @@ -724,7 +724,7 @@ public Boolean runAsync() { @Override public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { - return getHMAC("HmacMD5", t, args); + return getHMAC("HmacMD5", t, environment, args); } @Override @@ -784,7 +784,7 @@ public Boolean runAsync() { @Override public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { - return getHMAC("HmacSHA1", t, args); + return getHMAC("HmacSHA1", t, environment, args); } @Override @@ -844,7 +844,7 @@ public Boolean runAsync() { @Override public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { - return getHMAC("HmacSHA256", t, args); + return getHMAC("HmacSHA256", t, environment, args); } @Override diff --git a/src/main/java/com/laytonsmith/core/functions/DataHandling.java b/src/main/java/com/laytonsmith/core/functions/DataHandling.java index 6680b1e0f0..afc3bcd9a6 100644 --- a/src/main/java/com/laytonsmith/core/functions/DataHandling.java +++ b/src/main/java/com/laytonsmith/core/functions/DataHandling.java @@ -239,7 +239,7 @@ public ParseTree optimizeDynamic(Target t, Environment env, String v; if(value instanceof IVariable iVariable) { v = iVariable.getVariableName(); - } else if(value.isInstanceOf(CString.TYPE)) { + } else if(value.isInstanceOf(CString.TYPE, null, env)) { v = ((CString) value).getQuote(); } else { v = "@value"; @@ -387,9 +387,9 @@ public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed.. if(val instanceof CVoid) { throw new CRECastException("Void may not be assigned to a variable", t); } - if(!InstanceofUtil.isInstanceof(val.typeof(), type, env)) { + if(!InstanceofUtil.isInstanceof(val.typeof(env), type, env)) { throw new CRECastException(varName + " is of type " + type.val() + ", but a value of type " - + val.typeof() + " was assigned to it.", t); + + val.typeof(env) + " was assigned to it.", t); } // Set variable in variable list. @@ -421,9 +421,9 @@ public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed.. var = new IVariable(Auto.TYPE, varName, val, t); list.set(var); } else { - if(!InstanceofUtil.isInstanceof(val.typeof(), var.getDefinedType(), env)) { + if(!InstanceofUtil.isInstanceof(val.typeof(env), var.getDefinedType(), env)) { throw new CRECastException(varName + " is of type " + var.getDefinedType() - + ", but a value of type " + val.typeof() + " was assigned to it.", t); + + ", but a value of type " + val.typeof(env) + " was assigned to it.", t); } var.setIval(val); } @@ -663,7 +663,7 @@ public Mixed optimize(Target t, Environment env, Mixed... args) throws ConfigCom int offset = 0; if(args.length == 3) { offset = 1; - if(!args[0].isInstanceOf(CClassType.TYPE) + if(!(args[0] instanceof CClassType) && (!(args[0] instanceof CFunction) || !args[0].val().equals(__type_ref__.NAME))) { throw new ConfigCompileException("Expecting a ClassType for parameter 1 to assign", t); } @@ -717,7 +717,7 @@ public ParseTree optimizeDynamic(Target t, Environment env, if(typeNode.getData() instanceof CClassType declaredType && varNode.getData() instanceof IVariable) { if(valNode.isConst()) { - CClassType valType = valNode.getData().typeof(); + CClassType valType = valNode.getData().typeof(env); if((valType != CClassType.AUTO || declaredType == CClassType.AUTO) && InstanceofUtil.isInstanceof(valType, declaredType, env)) { ParseTree newAssignNode = new ParseTree(new CFunction(__unsafe_assign__.NAME, t), fileOptions); @@ -847,7 +847,7 @@ public Boolean runAsync() { @Override public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { - return CBoolean.get(!(args[0].isInstanceOf(CArray.TYPE))); + return CBoolean.get(!(args[0].isInstanceOf(CArray.TYPE, null, env))); } @Override @@ -908,7 +908,7 @@ public Boolean runAsync() { @Override public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { - return CBoolean.get(args[0].isInstanceOf(CString.TYPE)); + return CBoolean.get(args[0].isInstanceOf(CString.TYPE, null, env)); } @Override @@ -967,7 +967,7 @@ public Boolean runAsync() { @Override public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { - return CBoolean.get(args[0].isInstanceOf(CByteArray.TYPE)); + return CBoolean.get(args[0] instanceof CByteArray); } @Override @@ -1027,7 +1027,7 @@ public Boolean runAsync() { @Override public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { - return CBoolean.get(args[0].isInstanceOf(CArray.TYPE)); + return CBoolean.get(args[0].isInstanceOf(CArray.TYPE, null, env)); } @Override @@ -1089,7 +1089,7 @@ public Boolean runAsync() { @Override public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { - return CBoolean.get(args[0].isInstanceOf(CInt.TYPE) || args[0].isInstanceOf(CDouble.TYPE)); + return CBoolean.get(args[0].isInstanceOf(CInt.TYPE, null, env) || args[0].isInstanceOf(CDouble.TYPE, null, env)); } @Override @@ -1152,7 +1152,7 @@ public Boolean runAsync() { @Override public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { - return CBoolean.get(args[0].isInstanceOf(CDouble.TYPE)); + return CBoolean.get(args[0].isInstanceOf(CDouble.TYPE, null, env)); } @Override @@ -1213,7 +1213,7 @@ public Boolean runAsync() { @Override public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { - return CBoolean.get(args[0].isInstanceOf(CInt.TYPE)); + return CBoolean.get(args[0].isInstanceOf(CInt.TYPE, null, env)); } @Override @@ -1273,7 +1273,7 @@ public Boolean runAsync() { @Override public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { - return CBoolean.get(args[0].isInstanceOf(CBoolean.TYPE)); + return CBoolean.get(args[0] instanceof CBoolean); } @Override @@ -1561,7 +1561,7 @@ public static Procedure getProcedure(Target t, Environment env, Script parent, P boolean procDefinitelyNotConstant = false; CClassType returnType = Auto.TYPE; NodeModifiers modifiers = null; - if(nodes[0].getData().equals(CVoid.VOID) || nodes[0].getData().isInstanceOf(CClassType.TYPE)) { + if(nodes[0].getData().equals(CVoid.VOID) || nodes[0].getData() instanceof CClassType) { if(nodes[0].getData().equals(CVoid.VOID)) { returnType = CVoid.TYPE; } else { @@ -1802,8 +1802,7 @@ public static Mixed optimizeProcedure(Target t, Procedure myProc, List 0 && nodes[0].getData().isInstanceOf(CClassType.TYPE)) { + if(nodes.length > 0 && nodes[0].getData() instanceof CClassType) { returnType = (CClassType) nodes[0].getData(); nodeOffset = 1; } @@ -2976,7 +2975,7 @@ public Mixed execs(Target t, Environment env, Script parent, ParseTree... nodes) } // Handle the closure type first thing CClassType returnType = Auto.TYPE; - if(nodes[0].getData().isInstanceOf(CClassType.TYPE)) { + if(nodes[0].getData() instanceof CClassType) { returnType = (CClassType) nodes[0].getData(); ParseTree[] newNodes = new ParseTree[nodes.length - 1]; for(int i = 1; i < nodes.length; i++) { @@ -3252,7 +3251,7 @@ public boolean isRestricted() { @Override public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { - if(!(args[args.length - 1].isInstanceOf(CClosure.TYPE))) { + if(!(args[args.length - 1].isInstanceOf(CClosure.TYPE, null, environment))) { throw new CRECastException("Only a closure (created from the closure function) can be sent to executeas()", t); } Mixed[] vals = new Mixed[args.length - 3]; @@ -3568,7 +3567,7 @@ public Boolean runAsync() { @Override public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { - if(args[0].isInstanceOf(CString.TYPE)) { + if(args[0].isInstanceOf(CString.TYPE, null, environment)) { return args[0]; } return new CString(args[0].val(), t); @@ -3778,7 +3777,7 @@ public Boolean runAsync() { @Override public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { try { - return args[0].typeof(); + return args[0].typeof(environment); } catch (IllegalArgumentException ex) { throw new Error("Class " + args[0].getClass().getName() + " is not annotated with @typeof. Please report this" + " error to the developers."); @@ -3868,7 +3867,7 @@ public Mixed execs(Target t, Environment env, Script parent, ParseTree... nodes) try { env.getEnv(GlobalEnv.class).SetDynamicScriptingMode(true); Mixed script = parent.seval(node, env); - if(script.isInstanceOf(CClosure.TYPE)) { + if(script.isInstanceOf(CClosure.TYPE, null, env)) { throw new CRECastException("Closures cannot be eval'd directly. Use execute() instead.", t); } ParseTree root = MethodScriptCompiler.compile(MethodScriptCompiler.lex(script.val(), env, t.file(), true), @@ -4137,7 +4136,7 @@ public Mixed exec(Target t, Environment environment, GenericParameters generics, return CBoolean.FALSE; } CClassType type; - if(args[1].isInstanceOf(CClassType.TYPE)) { + if(args[1] instanceof CClassType) { type = (CClassType) args[1]; } else { throw new RuntimeException("This should have been optimized out, this is a bug in instanceof," @@ -4177,7 +4176,7 @@ public ParseTree optimizeDynamic(Target t, Environment env, FileOptions fileOptions) throws ConfigCompileException, ConfigRuntimeException { // There are two specific cases here where we will give more precise error messages. // If it's a string, yell at them (Note CKeyword extends CString, for better or worse) - if(children.get(1).getData().isInstanceOf(CString.TYPE)) { + if(children.get(1).getData().isInstanceOf(CString.TYPE, null, env)) { throw new ConfigCompileException("Unexpected string type passed to \"instanceof\"", t); } // If it's a variable, also yell at them @@ -4185,7 +4184,7 @@ public ParseTree optimizeDynamic(Target t, Environment env, throw new ConfigCompileException("Variable types are not allowed in \"instanceof\"", t); } // Unknown error, but this is still never valid. - if(!(children.get(1).getData().isInstanceOf(CClassType.TYPE))) { + if(!(children.get(1).getData() instanceof CClassType)) { throw new ConfigCompileException("Unexpected type for \"instanceof\": " + children.get(1).getData(), t); } // null is technically a type, but instanceof shouldn't work with that diff --git a/src/main/java/com/laytonsmith/core/functions/DataTransformations.java b/src/main/java/com/laytonsmith/core/functions/DataTransformations.java index 68a757eb1b..b1ddbb0f9d 100644 --- a/src/main/java/com/laytonsmith/core/functions/DataTransformations.java +++ b/src/main/java/com/laytonsmith/core/functions/DataTransformations.java @@ -76,7 +76,7 @@ public Boolean runAsync() { public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { CArray ca = ArgumentValidation.getArray(args[0], t); try { - return new CString(Construct.json_encode(ca, t), t); + return new CString(Construct.json_encode(ca, t, environment), t); } catch (MarshalException ex) { throw new CRECastException(ex.getMessage(), t); } diff --git a/src/main/java/com/laytonsmith/core/functions/Enchantments.java b/src/main/java/com/laytonsmith/core/functions/Enchantments.java index 17cb910d51..28c17998fe 100644 --- a/src/main/java/com/laytonsmith/core/functions/Enchantments.java +++ b/src/main/java/com/laytonsmith/core/functions/Enchantments.java @@ -70,8 +70,8 @@ public static MCEnchantment GetEnchantment(String name, Target t) { * @param value * @return */ - public static int ConvertLevel(Mixed value) { - if(value.isInstanceOf(CInt.TYPE)) { + public static int ConvertLevel(Mixed value, Environment environment) { + if(value.isInstanceOf(CInt.TYPE, null, environment)) { return (int) ((CInt) value).getInt(); } String lc = value.val().toLowerCase().trim(); @@ -205,7 +205,7 @@ public Mixed exec(Target t, Environment environment, GenericParameters generics, is.addUnsafeEnchantment(en.getKey(), en.getValue()); } } else { - int level = ConvertLevel(args[offset + 2]); + int level = ConvertLevel(args[offset + 2], environment); if(level > 0) { is.addUnsafeEnchantment(GetEnchantment(args[offset + 1].val(), t), level); } else { diff --git a/src/main/java/com/laytonsmith/core/functions/EntityManagement.java b/src/main/java/com/laytonsmith/core/functions/EntityManagement.java index e80a147e33..9a7cbf71a5 100644 --- a/src/main/java/com/laytonsmith/core/functions/EntityManagement.java +++ b/src/main/java/com/laytonsmith/core/functions/EntityManagement.java @@ -255,7 +255,7 @@ public Mixed exec(Target t, Environment environment, GenericParameters generics, ret.push(new CString(e.getUniqueId().toString(), t), t); } } else { - if(args[0].isInstanceOf(CArray.TYPE)) { + if(args[0].isInstanceOf(CArray.TYPE, null, environment)) { c = ObjectGenerator.GetGenerator().location(args[0], null, t).getChunk(); for(MCEntity e : c.getEntities()) { ret.push(new CString(e.getUniqueId().toString(), t), t); @@ -451,7 +451,7 @@ public Class[] thrown() { public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { MCEntity e = Static.getEntity(args[0], t); MCLocation l; - if(args[1].isInstanceOf(CArray.TYPE)) { + if(args[1].isInstanceOf(CArray.TYPE, null, environment)) { l = ObjectGenerator.GetGenerator().location(args[1], e.getWorld(), t); } else { throw new CREFormatException("An array was expected but received " + args[1], t); @@ -922,7 +922,7 @@ public ParseTree optimizeDynamic(Target t, com.laytonsmith.core.environments.Env return null; } Mixed c = children.get(1).getData(); - if(c.isInstanceOf(CString.TYPE)) { + if(c.isInstanceOf(CString.TYPE, null, env)) { try { MCEntityType.MCVanillaEntityType.valueOf(c.val().toUpperCase()); } catch(IllegalArgumentException ex) { @@ -961,7 +961,7 @@ public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed.. int dist; List types = new ArrayList<>(); - if(!(args[0].isInstanceOf(CArray.TYPE))) { + if(!(args[0].isInstanceOf(CArray.TYPE, null, env))) { throw new CREBadEntityException("Expecting an array at parameter 1 of entities_in_radius", t); } @@ -973,7 +973,7 @@ public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed.. } if(args.length == 3) { - if(args[2].isInstanceOf(CArray.TYPE)) { + if(args[2].isInstanceOf(CArray.TYPE, null, env)) { CArray ta = (CArray) args[2]; for(int i = 0; i < ta.size(); i++) { types.add(ta.get(i, t).val()); @@ -1051,7 +1051,7 @@ public ParseTree optimizeDynamic(Target t, com.laytonsmith.core.environments.Env return null; } Mixed c = children.get(children.size() - 1).getData(); - if(c.isInstanceOf(CString.TYPE)) { + if(c.isInstanceOf(CString.TYPE, null, env)) { try { MCEntityType.MCVanillaEntityType.valueOf(c.val().toUpperCase()); } catch(IllegalArgumentException ex) { @@ -1061,7 +1061,7 @@ public ParseTree optimizeDynamic(Target t, com.laytonsmith.core.environments.Env } } else if(c instanceof CFunction && c.val().equals(DataHandling.array.NAME)) { for(ParseTree node : children.get(children.size() - 1).getChildren()) { - if(node.getData().isInstanceOf(CString.TYPE)) { + if(node.getData().isInstanceOf(CString.TYPE, null, env)) { try { MCEntityType.MCVanillaEntityType.valueOf(node.getData().val().toUpperCase()); } catch(IllegalArgumentException ex) { @@ -1191,7 +1191,7 @@ public ParseTree optimizeDynamic(Target t, com.laytonsmith.core.environments.Env return null; } Mixed c = children.get(1).getData(); - if(c.isInstanceOf(CString.TYPE)) { + if(c.isInstanceOf(CString.TYPE, null, env)) { try { MCEntityEffect.valueOf(c.val().toUpperCase()); } catch(IllegalArgumentException ex) { @@ -1293,7 +1293,7 @@ public Mixed exec(Target t, Environment environment, GenericParameters generics, if(args.length >= 3) { l = ObjectGenerator.GetGenerator().location(args[2], null, t); if(args.length == 4) { - if(args[3].isInstanceOf(CClosure.TYPE)) { + if(args[3].isInstanceOf(CClosure.TYPE, null, environment)) { consumer = (CClosure) args[3]; } else { throw new CREIllegalArgumentException("Expected a closure as last argument for spawn_entity().", t); @@ -1414,7 +1414,7 @@ public ParseTree optimizeDynamic(Target t, com.laytonsmith.core.environments.Env return null; } Mixed c = children.get(0).getData(); - if(c.isInstanceOf(CString.TYPE)) { + if(c.isInstanceOf(CString.TYPE, null, env)) { try { MCEntityType.MCVanillaEntityType type = MCEntityType.MCVanillaEntityType.valueOf(c.val().toUpperCase()); if(!type.isSpawnable()) { @@ -2606,7 +2606,7 @@ public Mixed exec(Target t, Environment environment, GenericParameters generics, switch(index.toLowerCase()) { case entity_spec.KEY_AREAEFFECTCLOUD_COLOR: Mixed colorMixed = specArray.get(index, t); - if(colorMixed.isInstanceOf(CArray.TYPE)) { + if(colorMixed.isInstanceOf(CArray.TYPE, null, environment)) { CArray color = (CArray) colorMixed; cloud.setColor(ObjectGenerator.GetGenerator().color(color, t)); } else { @@ -2621,7 +2621,7 @@ public Mixed exec(Target t, Environment environment, GenericParameters generics, break; case entity_spec.KEY_AREAEFFECTCLOUD_PARTICLE: Mixed particleMixed = specArray.get(index, t); - if(particleMixed.isInstanceOf(CArray.TYPE)) { + if(particleMixed.isInstanceOf(CArray.TYPE, null, environment)) { CArray pa = (CArray) particleMixed; MCParticle p; try { @@ -2632,7 +2632,7 @@ public Mixed exec(Target t, Environment environment, GenericParameters generics, } try { cloud.setParticle(p, ObjectGenerator.GetGenerator().particleData(p, - cloud.getLocation(), pa, t)); + cloud.getLocation(), pa, t, environment)); } catch(IllegalArgumentException ex) { throw new CREFormatException("Invalid particle data for " + p.name(), t); } @@ -2647,7 +2647,7 @@ public Mixed exec(Target t, Environment environment, GenericParameters generics, break; case entity_spec.KEY_AREAEFFECTCLOUD_POTIONMETA: Mixed c = specArray.get(index, t); - if(c.isInstanceOf(CArray.TYPE)) { + if(c.isInstanceOf(CArray.TYPE, null, environment)) { CArray meta = (CArray) c; if(meta.containsKey("potiontype") && Static.getServer().getMinecraftVersion().gte(MCVersion.MC1_20_6)) { @@ -2659,12 +2659,12 @@ public Mixed exec(Target t, Environment environment, GenericParameters generics, } } else if(meta.containsKey("base")) { Mixed base = meta.get("base", t); - if(base.isInstanceOf(CArray.TYPE)) { + if(base.isInstanceOf(CArray.TYPE, null, environment)) { if(Static.getServer().getMinecraftVersion().gte(MCVersion.MC1_20_6)) { MCPotionType type = ObjectGenerator.GetGenerator().legacyPotionData((CArray) base, t); cloud.setBasePotionType(type); } else { - MCPotionData pd = ObjectGenerator.GetGenerator().potionData((CArray) base, t); + MCPotionData pd = ObjectGenerator.GetGenerator().potionData((CArray) base, t, environment); cloud.setBasePotionData(pd); } } @@ -2672,8 +2672,8 @@ public Mixed exec(Target t, Environment environment, GenericParameters generics, if(meta.containsKey("potions")) { cloud.clearCustomEffects(); Mixed potions = meta.get("potions", t); - if(potions.isInstanceOf(CArray.TYPE)) { - List list = ObjectGenerator.GetGenerator().potions((CArray) potions, t); + if(potions.isInstanceOf(CArray.TYPE, null, environment)) { + List list = ObjectGenerator.GetGenerator().potions((CArray) potions, t, environment); for(MCLivingEntity.MCEffect effect : list) { cloud.addCustomEffect(effect); } @@ -2699,7 +2699,7 @@ public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed cloudSource = specArray.get(index, t); if(cloudSource instanceof CNull) { cloud.setSource(null); - } else if(cloudSource.isInstanceOf(CArray.TYPE)) { + } else if(cloudSource.isInstanceOf(CArray.TYPE, null, environment)) { MCBlock b = ObjectGenerator.GetGenerator().location(cloudSource, cloud.getWorld(), t).getBlock(); if(b.isDispenser()) { cloud.setSource(b.getDispenser().getBlockProjectileSource()); @@ -2757,7 +2757,7 @@ public Mixed exec(Target t, Environment environment, GenericParameters generics, break; case entity_spec.KEY_ARROW_POTIONMETA: Mixed c = specArray.get(index, t); - if(c.isInstanceOf(CArray.TYPE)) { + if(c.isInstanceOf(CArray.TYPE, null, environment)) { CArray meta = (CArray) c; if(meta.containsKey("potiontype") && Static.getServer().getMinecraftVersion().gte(MCVersion.MC1_20_6)) { @@ -2769,12 +2769,12 @@ public Mixed exec(Target t, Environment environment, GenericParameters generics, } } else if(meta.containsKey("base")) { Mixed base = meta.get("base", t); - if(base.isInstanceOf(CArray.TYPE)) { + if(base.isInstanceOf(CArray.TYPE, null, environment)) { if(Static.getServer().getMinecraftVersion().gte(MCVersion.MC1_20_6)) { MCPotionType type = ObjectGenerator.GetGenerator().legacyPotionData((CArray) base, t); arrow.setBasePotionType(type); } else { - MCPotionData pd = ObjectGenerator.GetGenerator().potionData((CArray) base, t); + MCPotionData pd = ObjectGenerator.GetGenerator().potionData((CArray) base, t, environment); arrow.setBasePotionData(pd); } } @@ -2782,8 +2782,8 @@ public Mixed exec(Target t, Environment environment, GenericParameters generics, if(meta.containsKey("potions")) { arrow.clearCustomEffects(); Mixed potions = meta.get("potions", t); - if(potions.isInstanceOf(CArray.TYPE)) { - List list = ObjectGenerator.GetGenerator().potions((CArray) potions, t); + if(potions.isInstanceOf(CArray.TYPE, null, environment)) { + List list = ObjectGenerator.GetGenerator().potions((CArray) potions, t, environment); for(MCLivingEntity.MCEffect effect : list) { arrow.addCustomEffect(effect); } @@ -2797,7 +2797,7 @@ public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed colorMixed = specArray.get(index, t); if(colorMixed instanceof CNull) { arrow.setColor(null); - } else if(colorMixed.isInstanceOf(CArray.TYPE)) { + } else if(colorMixed.isInstanceOf(CArray.TYPE, null, environment)) { CArray color = (CArray) colorMixed; arrow.setColor(ObjectGenerator.GetGenerator().color(color, t)); } else { @@ -2834,7 +2834,7 @@ public Mixed exec(Target t, Environment environment, GenericParameters generics, case entity_spec.KEY_ARMORSTAND_POSES: Map poseMap = stand.getAllPoses(); Mixed posesMixed = specArray.get(index, t); - if(posesMixed.isInstanceOf(CArray.TYPE)) { + if(posesMixed.isInstanceOf(CArray.TYPE, null, environment)) { CArray poseArray = (CArray) posesMixed; for(MCBodyPart key : poseMap.keySet()) { try { @@ -2915,7 +2915,7 @@ public Mixed exec(Target t, Environment environment, GenericParameters generics, MCBlockData bd; Mixed m = specArray.get(index, t); try { - if(m.isInstanceOf(CArray.TYPE)) { + if(m.isInstanceOf(CArray.TYPE, null, environment)) { bd = ObjectGenerator.GetGenerator().blockData((CArray) m, t); } else { bd = Static.getServer().createBlockData(m.val().toLowerCase()); @@ -3085,7 +3085,7 @@ public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed c = specArray.get(index, t); if(c instanceof CNull) { endercrystal.setBeamTarget(null); - } else if(c.isInstanceOf(CArray.TYPE)) { + } else if(c.isInstanceOf(CArray.TYPE, null, environment)) { MCLocation l = ObjectGenerator.GetGenerator().location((CArray) c, endercrystal.getWorld(), t); endercrystal.setBeamTarget(l); } else { @@ -3230,7 +3230,7 @@ public Mixed exec(Target t, Environment environment, GenericParameters generics, fm.clearEffects(); CArray effects = ArgumentValidation.getArray(specArray.get(index, t), t); for(Mixed eff : effects.asList()) { - if(eff.isInstanceOf(CArray.TYPE)) { + if(eff.isInstanceOf(CArray.TYPE, null, environment)) { fm.addEffect(ObjectGenerator.GetGenerator().fireworkEffect((CArray) eff, t)); } else { throw new CRECastException("Firework effect expected to be an array.", t); @@ -3924,7 +3924,7 @@ public Mixed exec(Target t, Environment environment, GenericParameters generics, break; case entity_spec.KEY_DISPLAY_TEXT_BACKGROUND_COLOR: Mixed color = specArray.get(index, t); - if(color.isInstanceOf(CArray.TYPE)) { + if(color.isInstanceOf(CArray.TYPE, null, environment)) { tDisplay.setBackgroundColor(ObjectGenerator.GetGenerator().color((CArray) color, t)); } else if(color instanceof CNull) { tDisplay.setBackgroundColor(null); @@ -4261,7 +4261,7 @@ public Mixed exec(Target t, Environment environment, GenericParameters generics, if(entity instanceof MCProjectile) { if(args[1] instanceof CNull) { ((MCProjectile) entity).setShooter(null); - } else if(args[1].isInstanceOf(CArray.TYPE)) { + } else if(args[1].isInstanceOf(CArray.TYPE, null, environment)) { MCBlock b = ObjectGenerator.GetGenerator().location(args[1], entity.getWorld(), t).getBlock(); if(b.isDispenser()) { ((MCProjectile) entity).setShooter(b.getDispenser().getBlockProjectileSource()); @@ -4903,7 +4903,7 @@ public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed.. is = ObjectGenerator.GetGenerator().item(args[0], t); } else { MCPlayer p; - if(args[0].isInstanceOf(CArray.TYPE)) { + if(args[0].isInstanceOf(CArray.TYPE, null, env)) { p = env.getEnv(CommandHelperEnvironment.class).GetPlayer(); l = ObjectGenerator.GetGenerator().location(args[0], (p != null ? p.getWorld() : null), t); natural = true; @@ -4975,7 +4975,7 @@ public Mixed exec(Target t, Environment environment, GenericParameters generics, List effects = new ArrayList<>(); if(options.containsKey("effects")) { Mixed cEffects = options.get("effects", t); - if(cEffects.isInstanceOf(CArray.TYPE)) { + if(cEffects.isInstanceOf(CArray.TYPE, null, environment)) { for(Mixed c : ((CArray) cEffects).asList()) { effects.add(ObjectGenerator.GetGenerator().fireworkEffect((CArray) c, t)); } @@ -5479,7 +5479,7 @@ public Mixed exec(Target t, com.laytonsmith.core.environments.Environment enviro display.setBrightness(null); } else { MCDisplay.Brightness brightness; - if(m.isInstanceOf(CArray.TYPE)) { + if(m.isInstanceOf(CArray.TYPE, null, environment)) { CArray brightnessArray = (CArray) m; if(!brightnessArray.isAssociative()) { throw new CREIllegalArgumentException( diff --git a/src/main/java/com/laytonsmith/core/functions/Environment.java b/src/main/java/com/laytonsmith/core/functions/Environment.java index d6d3890547..ab663753fa 100644 --- a/src/main/java/com/laytonsmith/core/functions/Environment.java +++ b/src/main/java/com/laytonsmith/core/functions/Environment.java @@ -499,7 +499,7 @@ public Mixed exec(Target t, com.laytonsmith.core.environments.Environment enviro String line2 = ""; String line3 = ""; String line4 = ""; - if((args.length == 2 || args.length == 3) && args[args.length - 1].isInstanceOf(CArray.TYPE)) { + if((args.length == 2 || args.length == 3) && args[args.length - 1].isInstanceOf(CArray.TYPE, null, environment)) { if(args.length == 3) { try { side = MCSign.Side.valueOf(args[1].val()); @@ -1235,7 +1235,7 @@ public ParseTree optimizeDynamic(Target t, com.laytonsmith.core.environments.Env return null; } Mixed c = children.get(children.size() - 1).getData(); - if(c.isInstanceOf(CString.TYPE)) { + if(c.isInstanceOf(CString.TYPE, null, env)) { try { MCBiomeType.MCVanillaBiomeType.valueOf(c.val()); } catch (IllegalArgumentException ex) { @@ -1356,7 +1356,7 @@ public Mixed exec(Target t, com.laytonsmith.core.environments.Environment env, G w = player.getWorld(); } - if(args.length < 3 && args[0].isInstanceOf(CArray.TYPE)) { + if(args.length < 3 && args[0].isInstanceOf(CArray.TYPE, null, env)) { MCLocation loc = ObjectGenerator.GetGenerator().location(args[0], w, t); x = loc.getBlockX(); z = loc.getBlockZ(); @@ -1439,7 +1439,7 @@ public Mixed exec(Target t, com.laytonsmith.core.environments.Environment env, G boolean fire = true; MCEntity source = null; - if(!(args[0].isInstanceOf(CArray.TYPE))) { + if(!(args[0].isInstanceOf(CArray.TYPE, null, env))) { throw new CRECastException("Expecting an array at parameter 1 of explosion", t); } if(args.length >= 2) { @@ -1517,7 +1517,7 @@ public Mixed exec(Target t, com.laytonsmith.core.environments.Environment enviro noteOffset = 2; l = ObjectGenerator.GetGenerator().location(args[3], p.getWorld(), t); } else { - if(!(args[1].isInstanceOf(CArray.TYPE)) && args[2].isInstanceOf(CArray.TYPE)) { + if(!(args[1].isInstanceOf(CArray.TYPE, null, environment)) && args[2].isInstanceOf(CArray.TYPE, null, environment)) { //Player provided, location not instrumentOffset = 1; noteOffset = 2; @@ -1538,7 +1538,7 @@ public Mixed exec(Target t, com.laytonsmith.core.environments.Environment enviro + StringUtils.Join(MCInstrument.values(), ", ", ", or "), t); } MCTone tone = null; - if(args[noteOffset].isInstanceOf(CArray.TYPE)) { + if(args[noteOffset].isInstanceOf(CArray.TYPE, null, environment)) { int octave = ArgumentValidation.getInt32(((CArray) args[noteOffset]).get("octave", t), t); if(octave < 0 || octave > 2) { throw new CRERangeException("The octave must be 0, 1, or 2, but was " + octave, t); @@ -1683,7 +1683,7 @@ public Mixed exec(Target t, com.laytonsmith.core.environments.Environment enviro boolean force = false; Object data = null; - if(args[1].isInstanceOf(CArray.TYPE)) { + if(args[1].isInstanceOf(CArray.TYPE, null, environment)) { CArray pa = (CArray) args[1]; try { p = MCParticle.valueOf(pa.get("particle", t).val().toUpperCase()); @@ -1711,7 +1711,7 @@ public Mixed exec(Target t, com.laytonsmith.core.environments.Environment enviro force = ArgumentValidation.getBooleanObject(pa.get("force", t), t); } - data = ObjectGenerator.GetGenerator().particleData(p, l, pa, t); + data = ObjectGenerator.GetGenerator().particleData(p, l, pa, t, environment); } else { try { @@ -1761,7 +1761,7 @@ public ParseTree optimizeDynamic(Target t, com.laytonsmith.core.environments.Env if(node.getData() instanceof CFunction && node.getData().val().equals(Compiler.centry.NAME)) { children = node.getChildren(); if(children.get(0).getData().val().equals("particle") - && children.get(1).getData().isInstanceOf(CString.TYPE)) { + && children.get(1).getData().isInstanceOf(CString.TYPE, null, env)) { try { MCParticle.MCVanillaParticle.valueOf(children.get(1).getData().val().toUpperCase()); } catch (IllegalArgumentException ex) { @@ -1810,7 +1810,7 @@ public Mixed exec(Target t, MCLocation loc = null; MCEntity ent = null; - if(args[0].isInstanceOf(CArray.TYPE)) { + if(args[0].isInstanceOf(CArray.TYPE, null, environment)) { loc = ObjectGenerator.GetGenerator().location(args[0], null, t); } else if(Static.getServer().getMinecraftVersion().gte(MCVersion.MC1_18_1)) { ent = Static.getEntity(args[0], t); @@ -1824,7 +1824,7 @@ public Mixed exec(Target t, float pitch = 1; Long seed = null; - if(!(args[1].isInstanceOf(CArray.TYPE))) { + if(!(args[1].isInstanceOf(CArray.TYPE, null, environment))) { throw new CREFormatException("An array was expected but received " + args[1], t); } @@ -1859,7 +1859,7 @@ public Mixed exec(Target t, } if(args.length == 3) { - if(args[2].isInstanceOf(CArray.TYPE)) { + if(args[2].isInstanceOf(CArray.TYPE, null, environment)) { CArray players = (CArray) args[2]; for(String key : players.stringKeySet()) { MCPlayer p = Static.GetPlayer(players.get(key, t), t); @@ -1932,7 +1932,7 @@ public ParseTree optimizeDynamic(Target t, com.laytonsmith.core.environments.Env if(node.getData() instanceof CFunction && node.getData().val().equals(Compiler.centry.NAME)) { children = node.getChildren(); if(children.get(0).getData().val().equals("sound") - && children.get(1).getData().isInstanceOf(CString.TYPE)) { + && children.get(1).getData().isInstanceOf(CString.TYPE, null, env)) { try { MCSound.MCVanillaSound.valueOf(children.get(1).getData().val().toUpperCase()); } catch (IllegalArgumentException ex) { @@ -1981,7 +1981,7 @@ public Mixed exec(Target t, MCLocation loc = null; MCEntity ent = null; - if(args[0].isInstanceOf(CArray.TYPE)) { + if(args[0].isInstanceOf(CArray.TYPE, null, environment)) { loc = ObjectGenerator.GetGenerator().location(args[0], null, t); } else if(Static.getServer().getMinecraftVersion().gte(MCVersion.MC1_19_3)) { ent = Static.getEntity(args[0], t); @@ -1995,7 +1995,7 @@ public Mixed exec(Target t, float pitch = 1; Long seed = null; - if(!(args[1].isInstanceOf(CArray.TYPE))) { + if(!(args[1].isInstanceOf(CArray.TYPE, null, environment))) { throw new CREFormatException("An array was expected but received " + args[1], t); } @@ -2025,7 +2025,7 @@ public Mixed exec(Target t, if(args.length == 3) { java.util.List players = new java.util.ArrayList<>(); - if(args[2].isInstanceOf(CArray.TYPE)) { + if(args[2].isInstanceOf(CArray.TYPE, null, environment)) { for(String key : ((CArray) args[2]).stringKeySet()) { players.add(Static.GetPlayer(((CArray) args[2]).get(key, t), t)); } @@ -2836,7 +2836,7 @@ public Mixed exec(Target t, com.laytonsmith.core.environments.Environment enviro throws ConfigRuntimeException { String cmd = null; if(args.length == 2 && !(args[1] instanceof CNull)) { - if(!(args[1].isInstanceOf(CString.TYPE))) { + if(!(args[1].isInstanceOf(CString.TYPE, null, environment))) { throw new CRECastException("Parameter 2 of " + getName() + " must be a string or null", t); } cmd = args[1].val(); @@ -2948,7 +2948,7 @@ public Mixed exec(Target t, com.laytonsmith.core.environments.Environment enviro ) throws ConfigRuntimeException { String name = null; if(args.length == 2 && !(args[1] instanceof CNull)) { - if(!(args[1].isInstanceOf(CString.TYPE))) { + if(!(args[1].isInstanceOf(CString.TYPE, null, environment))) { throw new CRECastException("Parameter 2 of " + getName() + " must be a string or null", t); } name = args[1].val(); @@ -3132,7 +3132,7 @@ public ParseTree optimizeDynamic(Target t, com.laytonsmith.core.environments.Env if(node.getData() instanceof CFunction && node.getData().val().equals(Compiler.centry.NAME)) { children = node.getChildren(); if(children.get(0).getData().val().equals("color") - && children.get(1).getData().isInstanceOf(CString.TYPE)) { + && children.get(1).getData().isInstanceOf(CString.TYPE, null, env)) { try { MCDyeColor.valueOf(children.get(1).getData().val()); } catch (IllegalArgumentException ex) { @@ -3142,7 +3142,7 @@ public ParseTree optimizeDynamic(Target t, com.laytonsmith.core.environments.Env children.get(1).getTarget(), null)); } } else if(children.get(0).getData().val().equals("shape") - && children.get(1).getData().isInstanceOf(CString.TYPE)) { + && children.get(1).getData().isInstanceOf(CString.TYPE, null, env)) { try { MCPatternShape.valueOf(children.get(1).getData().val()); } catch (IllegalArgumentException ex) { @@ -3331,7 +3331,7 @@ public Mixed exec(Target t, com.laytonsmith.core.environments.Environment enviro throw new CREFormatException("The block at the specified location is not a decorated pot", t); } Mixed sherds = args[1]; - if(sherds.isInstanceOf(CArray.TYPE)) { + if(sherds.isInstanceOf(CArray.TYPE, null, environment)) { CArray sherdArray = (CArray) sherds; if(sherdArray.isAssociative()) { for(String key : sherdArray.stringKeySet()) { diff --git a/src/main/java/com/laytonsmith/core/functions/EventBinding.java b/src/main/java/com/laytonsmith/core/functions/EventBinding.java index 29c0cf8ef5..304f3731d9 100644 --- a/src/main/java/com/laytonsmith/core/functions/EventBinding.java +++ b/src/main/java/com/laytonsmith/core/functions/EventBinding.java @@ -835,7 +835,7 @@ public Mixed exec(Target t, Environment environment, GenericParameters generics, boolean success = false; if(!active.isLocked(parameter)) { try { - success = e.modifyEvent(parameter, value, environment.getEnv(GlobalEnv.class).GetEvent().getUnderlyingEvent()); + success = Event.ExecuteModifyEvent(e, parameter, value, environment.getEnv(GlobalEnv.class).GetEvent().getUnderlyingEvent(), environment); } catch (ConfigRuntimeException ex) { ex.setTarget(t); throw ex; diff --git a/src/main/java/com/laytonsmith/core/functions/Function.java b/src/main/java/com/laytonsmith/core/functions/Function.java index 858c0ed89d..a4f5bdaf97 100644 --- a/src/main/java/com/laytonsmith/core/functions/Function.java +++ b/src/main/java/com/laytonsmith/core/functions/Function.java @@ -195,10 +195,11 @@ public ParseTree postParseRewrite(ParseTree ast, Environment env, /** * Returns the message to use when this function gets profiled, if useSpecialExec returns false. * + * @param env * @param args * @return */ - public String profileMessage(Mixed... args); + public String profileMessage(Environment env, Mixed... args); /** * Returns the message to use when this function gets profiled, if useSpecialExec returns true. @@ -243,11 +244,11 @@ public interface CodeBranch { public List getBranches(ParseTree self); } - // TODO: The reflection bridge below is a backward-compatibility shim for - // 3rd-party functions that still implement the old 3-arg - // exec(Target, Environment, Mixed...) signature. Once all known extensions - // have been updated, the cache and reflection fallback can be removed, and - // callers can invoke exec directly. + // Reflection bridge for backward compatibility with 3rd-party functions + // that still implement the old 3-arg exec(Target, Environment, Mixed...) signature. + // Once all known extensions have been updated, the cache and reflection fallback + // can be removed, and callers can invoke exec directly. + // Added 2026-02-23. /** * Cache of Function classes that only implement the old 3-arg exec signature. @@ -281,4 +282,25 @@ static Mixed ExecuteFunction(Function f, Target t, Environment env, Mixed[] args new Object[]{t, env, args}); } } + + // Reflection bridge for backward compatibility with 3rd-party functions + // that still implement the old profileMessage(Mixed...) signature only. + // Added 2026-02-23. + Set> OLD_PROFILE_MESSAGE_CACHE = Collections.newSetFromMap(new ConcurrentHashMap<>()); + + static String ExecuteProfileMessage(Function f, Environment env, Mixed[] args) { + if(OLD_PROFILE_MESSAGE_CACHE.contains(f.getClass())) { + return (String) ReflectionUtils.invokeMethod(f.getClass(), f, "profileMessage", + new Class[]{Mixed[].class}, + new Object[]{args}); + } + try { + return f.profileMessage(env, args); + } catch(AbstractMethodError e) { + OLD_PROFILE_MESSAGE_CACHE.add(f.getClass()); + return (String) ReflectionUtils.invokeMethod(f.getClass(), f, "profileMessage", + new Class[]{Mixed[].class}, + new Object[]{args}); + } + } } diff --git a/src/main/java/com/laytonsmith/core/functions/InventoryManagement.java b/src/main/java/com/laytonsmith/core/functions/InventoryManagement.java index d1b6bb7e16..e3057d60f8 100644 --- a/src/main/java/com/laytonsmith/core/functions/InventoryManagement.java +++ b/src/main/java/com/laytonsmith/core/functions/InventoryManagement.java @@ -512,7 +512,7 @@ public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed.. m = Static.GetPlayer(args[0], t); arg = args[1]; } - if(!(arg.isInstanceOf(CArray.TYPE))) { + if(!(arg.isInstanceOf(CArray.TYPE, null, env))) { throw new CRECastException("Expecting an array as the last argument.", t); } CArray array = (CArray) arg; @@ -670,7 +670,7 @@ public Mixed exec(Target t, Environment environment, GenericParameters generics, return new CInt(0, t); } - if(c.isInstanceOf(CArray.TYPE)) { + if(c.isInstanceOf(CArray.TYPE, null, environment)) { ca = (CArray) c; is = ObjectGenerator.GetGenerator().item(ca, t); } else { @@ -713,7 +713,7 @@ public ParseTree optimizeDynamic(Target t, Environment env, Set> envs, List children, FileOptions fileOptions) throws ConfigCompileException, ConfigRuntimeException { - if(children.size() > 0 && children.get(children.size() - 1).getData().isInstanceOf(CString.TYPE)) { + if(children.size() > 0 && children.get(children.size() - 1).getData().isInstanceOf(CString.TYPE, null, env)) { env.getEnv(CompilerEnvironment.class).addCompilerWarning(fileOptions, new CompilerWarning("The string item format in " + getName() + " is deprecated.", t, null)); } @@ -790,7 +790,7 @@ public Mixed exec(Target t, Environment environment, GenericParameters generics, if(item instanceof CNull) { ca = null; is = StaticLayer.GetItemStack("AIR", 1); - } else if(item.isInstanceOf(CArray.TYPE)) { + } else if(item.isInstanceOf(CArray.TYPE, null, environment)) { ca = (CArray) item; is = ObjectGenerator.GetGenerator().item(ca, t); } else { @@ -836,7 +836,7 @@ public ParseTree optimizeDynamic(Target t, Environment env, Set> envs, List children, FileOptions fileOptions) throws ConfigCompileException, ConfigRuntimeException { - if(children.size() > 0 && children.get(children.size() - 1).getData().isInstanceOf(CString.TYPE)) { + if(children.size() > 0 && children.get(children.size() - 1).getData().isInstanceOf(CString.TYPE, null, env)) { env.getEnv(CompilerEnvironment.class).addCompilerWarning(fileOptions, new CompilerWarning("The string item format in " + getName() + " is deprecated.", t, null)); } @@ -917,11 +917,11 @@ public Mixed exec(Target t, Environment environment, GenericParameters generics, if(args[1] instanceof CNull) { return new CInt(0, t); } - if(args[1].isInstanceOf(CArray.TYPE)) { + if(args[1].isInstanceOf(CArray.TYPE, null, environment)) { itemOffset = 1; } } else if(args.length == 3) { - if(args[0].isInstanceOf(CString.TYPE)) { // we assume player here, apparently + if(args[0].isInstanceOf(CString.TYPE, null, environment)) { // we assume player here, apparently itemOffset = 1; } } else if(args.length == 4) { @@ -935,7 +935,7 @@ public Mixed exec(Target t, Environment environment, GenericParameters generics, p = Static.GetPlayer(args[0], t); } - if(args[itemOffset].isInstanceOf(CArray.TYPE)) { + if(args[itemOffset].isInstanceOf(CArray.TYPE, null, environment)) { is = ObjectGenerator.GetGenerator().item(args[itemOffset], t); } else if(args.length > 1) { is = Static.ParseItemNotation(null, args[itemOffset].val(), ArgumentValidation.getInt32(args[itemOffset + 1], t), t); @@ -972,7 +972,7 @@ public ParseTree optimizeDynamic(Target t, Environment env, List children, FileOptions fileOptions) throws ConfigCompileException, ConfigRuntimeException { if(children.size() > 2 || children.size() == 2 - && (children.get(1).getData().isInstanceOf(CString.TYPE) || children.get(1).getData().isInstanceOf(CInt.TYPE))) { + && (children.get(1).getData().isInstanceOf(CString.TYPE, null, env) || children.get(1).getData().isInstanceOf(CInt.TYPE, null, env))) { env.getEnv(CompilerEnvironment.class).addCompilerWarning(fileOptions, new CompilerWarning("The string item format in " + getName() + " is deprecated.", t, null)); } @@ -1033,7 +1033,7 @@ public Mixed exec(Target t, Environment environment, GenericParameters generics, if(args[1] instanceof CNull) { return new CInt(0, t); } - if(args[1].isInstanceOf(CArray.TYPE)) { + if(args[1].isInstanceOf(CArray.TYPE, null, environment)) { itemOffset = 1; } } else if(args.length == 3) { @@ -1047,7 +1047,7 @@ public Mixed exec(Target t, Environment environment, GenericParameters generics, p = Static.GetPlayer(args[0], t); } - if(args[itemOffset].isInstanceOf(CArray.TYPE)) { + if(args[itemOffset].isInstanceOf(CArray.TYPE, null, environment)) { ca = (CArray) args[itemOffset]; is = ObjectGenerator.GetGenerator().item(ca, t); } else { @@ -1095,7 +1095,7 @@ public ParseTree optimizeDynamic(Target t, Environment env, List children, FileOptions fileOptions) throws ConfigCompileException, ConfigRuntimeException { if(children.size() > 2 || children.size() == 2 - && (children.get(1).getData().isInstanceOf(CString.TYPE) || children.get(1).getData().isInstanceOf(CInt.TYPE))) { + && (children.get(1).getData().isInstanceOf(CString.TYPE, null, env) || children.get(1).getData().isInstanceOf(CInt.TYPE, null, env))) { env.getEnv(CompilerEnvironment.class).addCompilerWarning(fileOptions, new CompilerWarning("The string item format in " + getName() + " is deprecated.", t, null)); } @@ -1177,11 +1177,11 @@ public Mixed exec(Target t, Environment environment, GenericParameters generics, if(args[1] instanceof CNull) { return new CInt(0, t); } - if(args[1].isInstanceOf(CArray.TYPE)) { + if(args[1].isInstanceOf(CArray.TYPE, null, environment)) { itemOffset = 1; } } else if(args.length == 3) { - if(args[0].isInstanceOf(CString.TYPE)) { // we assume player here, apparently + if(args[0].isInstanceOf(CString.TYPE, null, environment)) { // we assume player here, apparently itemOffset = 1; } } else if(args.length == 4) { @@ -1195,7 +1195,7 @@ public Mixed exec(Target t, Environment environment, GenericParameters generics, p = Static.GetPlayer(args[0], t); } - if(args[itemOffset].isInstanceOf(CArray.TYPE)) { + if(args[itemOffset].isInstanceOf(CArray.TYPE, null, environment)) { is = ObjectGenerator.GetGenerator().item(args[itemOffset], t); } else { is = Static.ParseItemNotation(null, args[itemOffset].val(), ArgumentValidation.getInt32(args[itemOffset + 1], t), t); @@ -1230,7 +1230,7 @@ public ParseTree optimizeDynamic(Target t, Environment env, List children, FileOptions fileOptions) throws ConfigCompileException, ConfigRuntimeException { if(children.size() > 2 || children.size() == 2 - && (children.get(1).getData().isInstanceOf(CString.TYPE) || children.get(1).getData().isInstanceOf(CInt.TYPE))) { + && (children.get(1).getData().isInstanceOf(CString.TYPE, null, env) || children.get(1).getData().isInstanceOf(CInt.TYPE, null, env))) { env.getEnv(CompilerEnvironment.class).addCompilerWarning(fileOptions, new CompilerWarning("The string item format in " + getName() + " is deprecated.", t, null)); } @@ -1290,7 +1290,7 @@ public Mixed exec(Target t, Environment environment, GenericParameters generics, if(args[1] instanceof CNull) { return new CInt(0, t); } - if(args[1].isInstanceOf(CArray.TYPE)) { + if(args[1].isInstanceOf(CArray.TYPE, null, environment)) { itemOffset = 1; } } else if(args.length == 3) { @@ -1304,7 +1304,7 @@ public Mixed exec(Target t, Environment environment, GenericParameters generics, p = Static.GetPlayer(args[0], t); } - if(args[itemOffset].isInstanceOf(CArray.TYPE)) { + if(args[itemOffset].isInstanceOf(CArray.TYPE, null, environment)) { ca = (CArray) args[itemOffset]; is = ObjectGenerator.GetGenerator().item(ca, t); } else { @@ -1351,7 +1351,7 @@ public ParseTree optimizeDynamic(Target t, Environment env, List children, FileOptions fileOptions) throws ConfigCompileException, ConfigRuntimeException { if(children.size() > 2 || children.size() == 2 - && (children.get(1).getData().isInstanceOf(CString.TYPE) || children.get(1).getData().isInstanceOf(CInt.TYPE))) { + && (children.get(1).getData().isInstanceOf(CString.TYPE, null, env) || children.get(1).getData().isInstanceOf(CInt.TYPE, null, env))) { env.getEnv(CompilerEnvironment.class).addCompilerWarning(fileOptions, new CompilerWarning("The string item format in " + getName() + " is deprecated.", t, null)); } @@ -1450,7 +1450,7 @@ public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed.. arg = args[0]; } - if(!(arg.isInstanceOf(CArray.TYPE))) { + if(!(arg.isInstanceOf(CArray.TYPE, null, env))) { throw new CRECastException("Expecting an array as argument " + (args.length == 1 ? "1" : "2"), t); } @@ -1616,7 +1616,7 @@ public Mixed exec(Target t, Environment environment, GenericParameters generics, if(p != null) { w = p.getWorld(); } - MCInventory inv = GetInventoryOrNull(args[0], w, t); + MCInventory inv = GetInventoryOrNull(args[0], w, t, environment); return CBoolean.get(inv != null); } @@ -1672,7 +1672,7 @@ public Mixed exec(Target t, Environment environment, GenericParameters generics, w = p.getWorld(); } - MCInventory inv = GetInventory(args[0], w, t); + MCInventory inv = GetInventory(args[0], w, t, environment); int slot = ArgumentValidation.getInt32(args[1], t); try { MCItemStack is = inv.getItem(slot); @@ -1736,7 +1736,7 @@ public Mixed exec(Target t, Environment environment, GenericParameters generics, w = p.getWorld(); } - MCInventory inv = GetInventory(args[0], w, t); + MCInventory inv = GetInventory(args[0], w, t, environment); int slot = ArgumentValidation.getInt32(args[1], t); MCItemStack is = ObjectGenerator.GetGenerator().item(args[2], t); try { @@ -1798,7 +1798,7 @@ public Mixed exec(Target t, Environment environment, GenericParameters generics, w = p.getWorld(); } - MCInventory inv = GetInventory(args[0], w, t); + MCInventory inv = GetInventory(args[0], w, t, environment); return new CString(inv.getType().name(), t); } @@ -1854,7 +1854,7 @@ public Mixed exec(Target t, Environment environment, GenericParameters generics, if(environment.getEnv(CommandHelperEnvironment.class).GetPlayer() != null) { w = environment.getEnv(CommandHelperEnvironment.class).GetPlayer().getWorld(); } - MCInventory inventory = InventoryManagement.GetInventory(args[0], w, t); + MCInventory inventory = InventoryManagement.GetInventory(args[0], w, t, environment); return new CInt(inventory.getSize(), t); } @@ -1907,7 +1907,7 @@ public Mixed exec(Target t, Environment environment, GenericParameters generics, if(p != null) { w = p.getWorld(); } - MCInventory inventory = InventoryManagement.GetInventory(args[0], w, t); + MCInventory inventory = InventoryManagement.GetInventory(args[0], w, t, environment); try { return new CString(inventory.getTitle(), t); } catch (ClassCastException ex) { @@ -2043,7 +2043,7 @@ public Boolean runAsync() { @Override public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { - MCInventory inventory = InventoryManagement.GetInventory(args[0], null, t); + MCInventory inventory = InventoryManagement.GetInventory(args[0], null, t, env); Integer size = inventory.getSize(); Integer index = -1; @@ -2123,10 +2123,10 @@ public Boolean runAsync() { @Override public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { - MCInventory inventory = InventoryManagement.GetInventory(args[0], null, t); + MCInventory inventory = InventoryManagement.GetInventory(args[0], null, t, env); Integer size = inventory.getSize(); - if(!(args[1].isInstanceOf(CArray.TYPE))) { + if(!(args[1].isInstanceOf(CArray.TYPE, null, env))) { throw new CRECastException("Expecting an array as argument 2", t); } @@ -2213,7 +2213,7 @@ public Boolean runAsync() { @Override public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { - MCInventory inventory = InventoryManagement.GetInventory(args[0], null, t); + MCInventory inventory = InventoryManagement.GetInventory(args[0], null, t, environment); MCItemStack is; if(args.length == 2) { is = ObjectGenerator.GetGenerator().item(args[1], t); @@ -2301,7 +2301,7 @@ public Boolean runAsync() { @Override public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { - MCInventory inventory = InventoryManagement.GetInventory(args[0], null, t); + MCInventory inventory = InventoryManagement.GetInventory(args[0], null, t, environment); Integer size = inventory.getSize(); CArray ca = null; @@ -2555,11 +2555,11 @@ public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed.. MCInventory inv; if(args.length == 2) { p = Static.GetPlayer(args[0], t); - inv = GetInventory(args[1], p.getWorld(), t); + inv = GetInventory(args[1], p.getWorld(), t, env); } else { p = env.getEnv(CommandHelperEnvironment.class).GetPlayer(); Static.AssertPlayerNonNull(p, t); - inv = GetInventory(args[0], p.getWorld(), t); + inv = GetInventory(args[0], p.getWorld(), t, env); } p.openInventory(inv); return CVoid.VOID; @@ -2623,7 +2623,7 @@ public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed.. // probably tests return CNull.NULL; } - return GetInventoryHolder(view.getTopInventory(), t); + return GetInventoryHolder(view.getTopInventory(), t, env); } @Override @@ -2669,7 +2669,7 @@ public String docs() { @Override public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { - MCInventory inv = GetInventory(args[0], null, t); + MCInventory inv = GetInventory(args[0], null, t, env); CArray list = new CArray(t); for(MCHumanEntity viewer : inv.getViewers()) { list.push(new CString(viewer.getName(), t), t); @@ -2791,7 +2791,7 @@ public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed.. int size = 54; String title = null; if(args.length > 1) { - if(args[1].isInstanceOf(CNumber.TYPE)) { + if(args[1].isInstanceOf(CNumber.TYPE, null, env)) { size = ArgumentValidation.getInt32(args[1], t); if(size < 9) { size = 9; // minimum @@ -2825,7 +2825,7 @@ public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed.. } if(args.length == 4) { - if(!(args[3].isInstanceOf(CArray.TYPE))) { + if(!(args[3].isInstanceOf(CArray.TYPE, null, env))) { throw new CRECastException("Inventory argument not an array in " + getName(), t); } CArray array = (CArray) args[3]; @@ -2934,10 +2934,10 @@ public MSVersion since() { * @param t * @return */ - static MCInventory GetInventory(Mixed specifier, MCWorld w, Target t) { - MCInventory inv = GetInventoryOrNull(specifier, w, t); + static MCInventory GetInventory(Mixed specifier, MCWorld w, Target t, Environment env) { + MCInventory inv = GetInventoryOrNull(specifier, w, t, env); if(inv == null) { - if(specifier.isInstanceOf(CArray.TYPE)) { + if(specifier.isInstanceOf(CArray.TYPE, null, env)) { throw new CREIllegalArgumentException("The location specified is not capable of having an inventory.", t); } throw new CREIllegalArgumentException("An inventory for \"" + specifier.val() + "\" does not exist.", t); @@ -2945,8 +2945,8 @@ static MCInventory GetInventory(Mixed specifier, MCWorld w, Target t) { return inv; } - private static MCInventory GetInventoryOrNull(Mixed specifier, MCWorld w, Target t) { - if(specifier.isInstanceOf(CArray.TYPE)) { + private static MCInventory GetInventoryOrNull(Mixed specifier, MCWorld w, Target t, Environment env) { + if(specifier.isInstanceOf(CArray.TYPE, null, env)) { MCLocation l = ObjectGenerator.GetGenerator().location(specifier, w, t); return StaticLayer.GetConvertor().GetLocationInventory(l); } @@ -2968,7 +2968,7 @@ private static MCInventory GetInventoryOrNull(Mixed specifier, MCWorld w, Target * @param t * @return The construct representation of the inventory holder */ - public static Mixed GetInventoryHolder(MCInventory inv, Target t) { + public static Mixed GetInventoryHolder(MCInventory inv, Target t, Environment env) { MCInventoryHolder h = inv.getHolder(); if(h instanceof MCEntity) { return new CString(((MCEntity) h).getUniqueId().toString(), t); diff --git a/src/main/java/com/laytonsmith/core/functions/Math.java b/src/main/java/com/laytonsmith/core/functions/Math.java index 54a2f17d45..39da99a06e 100644 --- a/src/main/java/com/laytonsmith/core/functions/Math.java +++ b/src/main/java/com/laytonsmith/core/functions/Math.java @@ -546,12 +546,12 @@ private static Mixed doIncrementDecrement(ParseTree[] nodes, } long delta = ArgumentValidation.getInt(cdelta, t); //First, error check, then get the old value, and store it in temp. - if(!(array.isInstanceOf(CArray.TYPE)) && !(array.isInstanceOf(ArrayAccess.TYPE))) { + if(!(array.isInstanceOf(CArray.TYPE, null, env)) && !(array.isInstanceOf(ArrayAccess.TYPE, null, env))) { //Let's just evaluate this like normal with array_get, so it will //throw the appropriate exception. new ArrayHandling.array_get().exec(t, env, null, array, index); throw ConfigRuntimeException.CreateUncatchableException("Shouldn't have gotten here. Please report this error, and how you got here.", t); - } else if(!(array.isInstanceOf(CArray.TYPE))) { + } else if(!(array.isInstanceOf(CArray.TYPE, null, env))) { //It's an ArrayAccess type, but we can't use that here, so, throw our //own exception. throw new CRECastException("Cannot increment/decrement a non-array array" @@ -562,7 +562,7 @@ private static Mixed doIncrementDecrement(ParseTree[] nodes, Mixed value = myArray.get(index, t); //Alright, now let's actually perform the increment, and store that in the array. - if(value.isInstanceOf(CInt.TYPE)) { + if(value.isInstanceOf(CInt.TYPE, null, env)) { CInt newVal; if(inc) { newVal = new CInt(ArgumentValidation.getInt(value, t) + delta, t); @@ -575,7 +575,7 @@ private static Mixed doIncrementDecrement(ParseTree[] nodes, } else { return value; } - } else if(value.isInstanceOf(CDouble.TYPE)) { + } else if(value.isInstanceOf(CDouble.TYPE, null, env)) { CDouble newVal; if(inc) { newVal = new CDouble(ArgumentValidation.getDouble(value, t) + delta, t); @@ -1225,7 +1225,7 @@ public Boolean runAsync() { @Override public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { - if(args[0].isInstanceOf(CInt.TYPE)) { + if(args[0].isInstanceOf(CInt.TYPE, null, env)) { return new CInt(java.lang.Math.abs(ArgumentValidation.getInt(args[0], t)), t); } else { return new CDouble(java.lang.Math.abs(ArgumentValidation.getDouble(args[0], t)), t); @@ -1461,7 +1461,7 @@ public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed.. } double lowest = Double.POSITIVE_INFINITY; List list = new ArrayList<>(); - recList(list, args); + recList(list, env, args); for(Mixed c : list) { double d = ArgumentValidation.getNumber(c, t); if(d < lowest) { @@ -1475,11 +1475,11 @@ public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed.. } } - public List recList(List list, Mixed... args) { + private List recList(List list, Environment env, Mixed... args) { for(Mixed c : args) { - if(c.isInstanceOf(CArray.TYPE)) { + if(c.isInstanceOf(CArray.TYPE, null, env)) { for(int i = 0; i < ((CArray) c).size(); i++) { - recList(list, ((CArray) c).get(i, Target.UNKNOWN)); + recList(list, env, ((CArray) c).get(i, Target.UNKNOWN)); } } else { list.add(c); @@ -1543,7 +1543,7 @@ public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed.. } double highest = Double.NEGATIVE_INFINITY; List list = new ArrayList<>(); - recList(list, args); + recList(list, env, args); for(Mixed c : list) { double d = ArgumentValidation.getNumber(c, t); if(d > highest) { @@ -1557,11 +1557,11 @@ public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed.. } } - public List recList(List list, Mixed... args) { + private List recList(List list, Environment env, Mixed... args) { for(Mixed c : args) { - if(c.isInstanceOf(CArray.TYPE)) { + if(c.isInstanceOf(CArray.TYPE, null, null)) { for(int i = 0; i < ((CArray) c).size(); i++) { - recList(list, ((CArray) c).get(i, Target.UNKNOWN)); + recList(list, env, ((CArray) c).get(i, Target.UNKNOWN)); } } else { list.add(c); @@ -2403,9 +2403,9 @@ public Mixed exec(Target t, Environment environment, GenericParameters generics, throw new CREFormatException("Expression may not be empty", t); } CArray vars = null; - if(args.length == 2 && args[1].isInstanceOf(CArray.TYPE)) { + if(args.length == 2 && args[1].isInstanceOf(CArray.TYPE, null, environment)) { vars = (CArray) args[1]; - } else if(args.length == 2 && !(args[1].isInstanceOf(CArray.TYPE))) { + } else if(args.length == 2 && !(args[1].isInstanceOf(CArray.TYPE, null, environment))) { throw new CRECastException("The second argument of expr() should be an array", t); } if(vars != null && !vars.inAssociativeMode()) { @@ -2504,7 +2504,7 @@ public Boolean runAsync() { @Override public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { - if(args[0].isInstanceOf(CInt.TYPE)) { + if(args[0].isInstanceOf(CInt.TYPE, null, environment)) { return new CInt(-(ArgumentValidation.getInt(args[0], t)), t); } else { return new CDouble(-(ArgumentValidation.getDouble(args[0], t)), t); diff --git a/src/main/java/com/laytonsmith/core/functions/ObjectManagement.java b/src/main/java/com/laytonsmith/core/functions/ObjectManagement.java index c8fef22e5a..42380667b9 100644 --- a/src/main/java/com/laytonsmith/core/functions/ObjectManagement.java +++ b/src/main/java/com/laytonsmith/core/functions/ObjectManagement.java @@ -169,17 +169,17 @@ private CArray evaluateArrayNoNull(ParseTree data, String component, Target t) { return (CArray) d; } - private Mixed evaluateString(ParseTree data, Target t) { + private Mixed evaluateString(ParseTree data, Target t, Environment env) { if(data.getData() instanceof CNull) { return CNull.NULL; } - if(!(data.getData().isInstanceOf(CString.TYPE))) { + if(!(data.getData().isInstanceOf(CString.TYPE, null, env))) { throw new CREClassDefinitionError("Expected a string, but found " + data.getData() + " instead", t); } return data.getData(); } - private CString evaluateStringNoNull(ParseTree data, Target t) { - Mixed d = evaluateString(data, t); + private CString evaluateStringNoNull(ParseTree data, Target t, Environment env) { + Mixed d = evaluateString(data, t, env); if(d instanceof CNull) { throw new CREClassDefinitionError("Expected a string, but found null instead", t); } @@ -210,7 +210,7 @@ private Mixed evaluateMixed(ParseTree data, Target t) { @Override public Mixed execs(Target t, Environment env, Script parent, ParseTree... nodes) { // 0 - Access Modifier - AccessModifier accessModifier = ArgumentValidation.getEnum(evaluateStringNoNull(nodes[0], t), + AccessModifier accessModifier = ArgumentValidation.getEnum(evaluateStringNoNull(nodes[0], t, env), AccessModifier.class, t); // 1 - Object Modifiers @@ -219,11 +219,11 @@ public Mixed execs(Target t, Environment env, Script parent, ParseTree... nodes) .collect(Collectors.toSet()); // 2 - Object Type - ObjectType type = ArgumentValidation.getEnum(evaluateStringNoNull(nodes[2], t), ObjectType.class, t); + ObjectType type = ArgumentValidation.getEnum(evaluateStringNoNull(nodes[2], t, env), ObjectType.class, t); // 3 - Object Name FullyQualifiedClassName name - = FullyQualifiedClassName.forFullyQualifiedClass(evaluateStringNoNull(nodes[3], t).val()); + = FullyQualifiedClassName.forFullyQualifiedClass(evaluateStringNoNull(nodes[3], t, env).val()); // 4 - Superclasses Set superclasses = new HashSet<>(); diff --git a/src/main/java/com/laytonsmith/core/functions/Persistence.java b/src/main/java/com/laytonsmith/core/functions/Persistence.java index dc520ce27b..25492ab1d0 100644 --- a/src/main/java/com/laytonsmith/core/functions/Persistence.java +++ b/src/main/java/com/laytonsmith/core/functions/Persistence.java @@ -96,7 +96,7 @@ public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed.. String key = GetNamespace(args, args.length - 1, getName(), t); String value = null; try { - value = Construct.json_encode(args[args.length - 1], t); + value = Construct.json_encode(args[args.length - 1], t, env); } catch (MarshalException e) { throw new CREFormatException(e.getMessage(), t); } diff --git a/src/main/java/com/laytonsmith/core/functions/PlayerManagement.java b/src/main/java/com/laytonsmith/core/functions/PlayerManagement.java index f2570cdd1c..d4350b1934 100644 --- a/src/main/java/com/laytonsmith/core/functions/PlayerManagement.java +++ b/src/main/java/com/laytonsmith/core/functions/PlayerManagement.java @@ -372,7 +372,7 @@ public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed.. Static.AssertPlayerNonNull(p, t); loc = p.getLocation(); } else { - if(!(args[0].isInstanceOf(CArray.TYPE))) { + if(!(args[0].isInstanceOf(CArray.TYPE, null, env))) { throw new CRECastException("Expecting an array at parameter 1 of players_in_radius", t); } @@ -526,7 +526,7 @@ public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed.. MCPlayer p = env.getEnv(CommandHelperEnvironment.class).GetPlayer(); MCLocation l; if(args.length <= 2) { - if(!(args[args.length - 1].isInstanceOf(CArray.TYPE))) { + if(!(args[args.length - 1].isInstanceOf(CArray.TYPE, null, env))) { throw new CRECastException("Expecting an array at parameter " + args.length + " of set_ploc", t); } CArray ca = (CArray) args[args.length - 1]; @@ -627,14 +627,14 @@ public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed.. HashSet trans = null; int transparentIndex = -1; if(args.length == 1) { - if(args[0].isInstanceOf(CArray.TYPE)) { + if(args[0].isInstanceOf(CArray.TYPE, null, env)) { transparentIndex = 0; } else { p = Static.GetPlayer(args[0], t); } } else if(args.length == 2) { p = Static.GetPlayer(args[0], t); - if(args[1].isInstanceOf(CArray.TYPE)) { + if(args[1].isInstanceOf(CArray.TYPE, null, env)) { transparentIndex = 1; } else { throw new CREFormatException("An array was expected for argument 2 but received " + args[1], t); @@ -1497,7 +1497,7 @@ public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed.. } } else { //if it's a number, we are setting F. Otherwise, it's a getter for the MCPlayer specified. - if(!(args[0].isInstanceOf(CInt.TYPE))) { + if(!(args[0].isInstanceOf(CInt.TYPE, null, env))) { MCPlayer p2 = Static.GetPlayer(args[0], t); l = p2.getLocation(); } @@ -2282,7 +2282,7 @@ public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed.. MCPlayer m = Static.GetPlayer(args[0].val(), t); MCPotionEffectType type = null; - if(args[1].isInstanceOf(CString.TYPE)) { + if(args[1].isInstanceOf(CString.TYPE, null, env)) { try { type = MCPotionEffectType.valueOf(args[1].val().toUpperCase()); } catch (IllegalArgumentException ex) { @@ -3414,7 +3414,7 @@ public Mixed exec(Target t, Environment environment, GenericParameters generics, ticks = args[0]; } int tick = 0; - if(ticks.isInstanceOf(CBoolean.TYPE)) { + if(ticks instanceof CBoolean) { boolean value = ((CBoolean) ticks).getBoolean(); if(value) { tick = 20; @@ -4164,7 +4164,7 @@ public Mixed exec(Target t, Environment environment, GenericParameters generics, if(signArray.isAssociative()) { if(signArray.containsKey("signtext")) { Mixed possibleLines = signArray.get("signtext", t); - if(possibleLines.isInstanceOf(CArray.TYPE)) { + if(possibleLines.isInstanceOf(CArray.TYPE, null, environment)) { CArray frontLines = (CArray) possibleLines; if(frontLines.size() > 4) { throw new CREFormatException("Sign text array cannot have more than 4 elements.", t); @@ -4195,7 +4195,7 @@ public Mixed exec(Target t, Environment environment, GenericParameters generics, if(backText != null) { if(signArray.containsKey("backtext")) { Mixed possibleLines = signArray.get("backtext", t); - if(possibleLines.isInstanceOf(CArray.TYPE)) { + if(possibleLines.isInstanceOf(CArray.TYPE, null, environment)) { CArray backLines = (CArray) possibleLines; if(backLines.size() > 4) { throw new CREFormatException("Sign back text array cannot have more than 4 elements.", t); @@ -4781,7 +4781,7 @@ public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed.. boolean forced = true; if(args.length == 1) { - if(args[0].isInstanceOf(CArray.TYPE)) { + if(args[0].isInstanceOf(CArray.TYPE, null, env)) { if(p instanceof MCPlayer) { m = ((MCPlayer) p); } @@ -4790,10 +4790,10 @@ public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed.. throw new CRECastException("Expecting an array in set_pbed_location", t); } } else if(args.length == 2) { - if(args[1].isInstanceOf(CArray.TYPE)) { + if(args[1].isInstanceOf(CArray.TYPE, null, env)) { pname = args[0].val(); locationIndex = 1; - } else if(args[0].isInstanceOf(CArray.TYPE)) { + } else if(args[0].isInstanceOf(CArray.TYPE, null, env)) { if(p instanceof MCPlayer) { m = ((MCPlayer) p); } @@ -4803,7 +4803,7 @@ public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed.. throw new CRECastException("Expecting an array in set_pbed_location", t); } } else if(args.length == 3) { - if(args[1].isInstanceOf(CArray.TYPE)) { + if(args[1].isInstanceOf(CArray.TYPE, null, env)) { pname = args[0].val(); locationIndex = 1; forced = ArgumentValidation.getBoolean(args[2], t); @@ -4835,7 +4835,7 @@ public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed.. } Static.AssertPlayerNonNull(m, t); - if(args[locationIndex].isInstanceOf(CArray.TYPE)) { + if(args[locationIndex].isInstanceOf(CArray.TYPE, null, env)) { CArray ca = (CArray) args[locationIndex]; l = ObjectGenerator.GetGenerator().location(ca, m.getWorld(), t); l.add(0, 1, 0); // someone decided to match ploc() here @@ -5586,7 +5586,7 @@ public Mixed exec(Target t, com.laytonsmith.core.environments.Environment enviro String soundName; String categoryName = null; - if(args[1].isInstanceOf(CArray.TYPE)) { + if(args[1].isInstanceOf(CArray.TYPE, null, environment)) { CArray soundArray = (CArray) args[1]; if(!soundArray.isAssociative()) { throw new CRECastException("Expected an associative array", t); @@ -5726,7 +5726,7 @@ public Mixed exec(Target t, com.laytonsmith.core.environments.Environment enviro MCPlayer p = Static.GetPlayer(args[0], t); String soundName; String categoryName = null; - if(args[1].isInstanceOf(CArray.TYPE)) { + if(args[1].isInstanceOf(CArray.TYPE, null, environment)) { CArray soundArray = (CArray) args[1]; if(!soundArray.isAssociative()) { throw new CRECastException("Expected an associative array or sound string", t); @@ -6710,7 +6710,7 @@ public Mixed exec(Target t, Environment environment, GenericParameters generics, if(wb == null) { wb = Static.getServer().createWorldBorder(); } - if(!(c.isInstanceOf(CArray.TYPE))) { + if(!(c.isInstanceOf(CArray.TYPE, null, environment))) { throw new CREFormatException("Expected array or null but given \"" + c.val() + "\"", t); } CArray params = (CArray) c; @@ -6901,7 +6901,7 @@ public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed.. p = Static.GetPlayer(args[0], t); value = args[1]; } - if(value.isInstanceOf(CArray.TYPE)) { + if(value.isInstanceOf(CArray.TYPE, null, env)) { int result = 0; for(Mixed element : ((CArray) value).asList()) { MCNamespacedKey key = StaticLayer.GetConvertor().GetNamespacedKey(element.val()); @@ -7202,7 +7202,7 @@ public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed.. for(MCEquipmentSlot slot : MCEquipmentSlot.values()) { p.sendEquipmentChange(le, slot, null); } - } else if(equipment.isInstanceOf(CArray.TYPE)) { + } else if(equipment.isInstanceOf(CArray.TYPE, null, env)) { CArray ea = (CArray) equipment; for(String key : ea.stringKeySet()) { try { diff --git a/src/main/java/com/laytonsmith/core/functions/Regex.java b/src/main/java/com/laytonsmith/core/functions/Regex.java index c0ceacefef..f459774eb9 100644 --- a/src/main/java/com/laytonsmith/core/functions/Regex.java +++ b/src/main/java/com/laytonsmith/core/functions/Regex.java @@ -92,7 +92,7 @@ public Boolean runAsync() { @Override public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { - Pattern pattern = getPattern(args[0], t); + Pattern pattern = getPattern(args[0], t, env); String subject = args[1].val(); Matcher m = pattern.matcher(subject); if(m.find()) { @@ -111,7 +111,7 @@ public ParseTree optimizeDynamic(Target t, Environment env, List children, FileOptions fileOptions) throws ConfigCompileException, ConfigRuntimeException { if(!Construct.IsDynamicHelper(children.get(0).getData())) { - getPattern(children.get(0).getData(), t); + getPattern(children.get(0).getData(), t, env); } return null; } @@ -180,7 +180,7 @@ public Boolean runAsync() { @Override public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { - Pattern pattern = getPattern(args[0], t); + Pattern pattern = getPattern(args[0], t, env); String subject = args[1].val(); CArray fret = new CArray(t); Matcher m = pattern.matcher(subject); @@ -202,7 +202,7 @@ public ParseTree optimizeDynamic(Target t, Environment env, List children, FileOptions fileOptions) throws ConfigCompileException, ConfigRuntimeException { if(!Construct.IsDynamicHelper(children.get(0).getData())) { - getPattern(children.get(0).getData(), t); + getPattern(children.get(0).getData(), t, env); } return null; } @@ -273,7 +273,7 @@ public Boolean runAsync() { @Override public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { - Pattern pattern = getPattern(args[0], t); + Pattern pattern = getPattern(args[0], t, env); Mixed replacement = args[1]; String subject = args[2].val(); String ret = ""; @@ -315,7 +315,7 @@ public ParseTree optimizeDynamic(Target t, Environment env, replaceNode.addChildAt(2, children.get(1)); //replacement -> that return replaceNode; } else { - getPattern(patternArg.getData(), t); + getPattern(patternArg.getData(), t, env); } } return null; @@ -394,7 +394,7 @@ public Boolean runAsync() { @Override public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { - Pattern pattern = getPattern(args[0], t); + Pattern pattern = getPattern(args[0], t, env); String subject = args[1].val(); /** * We use a different indexing notation than Java's regex split. In the case of 0 for the limit, we will @@ -430,7 +430,7 @@ public ParseTree optimizeDynamic(Target t, Environment env, splitNode.addChildAt(1, children.get(1)); return splitNode; } else { - getPattern(data.getData(), t); + getPattern(data.getData(), t, env); } } return null; @@ -494,7 +494,7 @@ public Boolean runAsync() { @Override public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { - Pattern pattern = getPattern(args[0], t); + Pattern pattern = getPattern(args[0], t, env); String subject = args[1].val(); long ret = 0; Matcher m = pattern.matcher(subject); @@ -510,7 +510,7 @@ public ParseTree optimizeDynamic(Target t, Environment env, List children, FileOptions fileOptions) throws ConfigCompileException, ConfigRuntimeException { if(!Construct.IsDynamicHelper(children.get(0).getData())) { - getPattern(children.get(0).getData(), t); + getPattern(children.get(0).getData(), t, env); } return null; } @@ -596,11 +596,11 @@ public ExampleScript[] examples() throws ConfigCompileException { } - private static Pattern getPattern(Mixed c, Target t) throws ConfigRuntimeException { + private static Pattern getPattern(Mixed c, Target t, Environment env) throws ConfigRuntimeException { String regex = ""; int flags = 0; String sflags = ""; - if(c.isInstanceOf(CArray.TYPE)) { + if(c.isInstanceOf(CArray.TYPE, null, env)) { CArray ca = (CArray) c; regex = ca.get(0, t).val(); sflags = ca.get(1, t).val(); diff --git a/src/main/java/com/laytonsmith/core/functions/SQL.java b/src/main/java/com/laytonsmith/core/functions/SQL.java index 289a064382..7dc0c61f72 100644 --- a/src/main/java/com/laytonsmith/core/functions/SQL.java +++ b/src/main/java/com/laytonsmith/core/functions/SQL.java @@ -211,9 +211,9 @@ public Mixed exec(Target t, Environment environment, GenericParameters generics, } else { ps.setString(i + 1, (String) params[i].val()); } - } else if(params[i].isInstanceOf(CByteArray.TYPE, null, environment)) { + } else if(params[i] instanceof CByteArray) { ps.setBytes(i + 1, ((CByteArray) params[i]).asByteArrayCopy()); - } else if(params[i].isInstanceOf(CBoolean.TYPE, null, environment)) { + } else if(params[i] instanceof CBoolean) { ps.setBoolean(i + 1, ArgumentValidation.getBoolean(params[i], t)); } else { throw new CRECastException("The type " + params[i].getClass().getSimpleName() diff --git a/src/main/java/com/laytonsmith/core/functions/Sandbox.java b/src/main/java/com/laytonsmith/core/functions/Sandbox.java index ca18488a2b..27b416df84 100644 --- a/src/main/java/com/laytonsmith/core/functions/Sandbox.java +++ b/src/main/java/com/laytonsmith/core/functions/Sandbox.java @@ -497,7 +497,7 @@ public Mixed exec(Target t, Environment environment, GenericParameters generics, } byte[] content; - if(!(args[1].isInstanceOf(CByteArray.TYPE, null, environment))) { + if(!(args[1] instanceof CByteArray)) { content = args[1].val().getBytes(Charset.forName("UTF-8")); } else { content = ArgumentValidation.getByteArray(args[1], t).asByteArrayCopy(); diff --git a/src/main/java/com/laytonsmith/core/functions/StringHandling.java b/src/main/java/com/laytonsmith/core/functions/StringHandling.java index 3d2c74eed5..98c2da9715 100644 --- a/src/main/java/com/laytonsmith/core/functions/StringHandling.java +++ b/src/main/java/com/laytonsmith/core/functions/StringHandling.java @@ -648,7 +648,7 @@ public Boolean runAsync() { @Override public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws CancelCommandException, ConfigRuntimeException { - if(args[0].isInstanceOf(Sizeable.TYPE)) { + if(args[0].isInstanceOf(Sizeable.TYPE, null, env)) { return new CInt(((Sizeable) args[0]).size(), t); } else { return new CInt(args[0].val().length(), t); @@ -710,9 +710,9 @@ public Boolean runAsync() { @Override public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws CancelCommandException, ConfigRuntimeException { - if(!(args[0].isInstanceOf(CString.TYPE))) { + if(!(args[0].isInstanceOf(CString.TYPE, null, env))) { throw new CREFormatException(this.getName() + " expects a string as first argument, but type " - + args[0].typeof() + " was found.", t); + + args[0].typeof(env) + " was found.", t); } return new CString(args[0].val().toUpperCase(), t); } @@ -773,9 +773,9 @@ public Boolean runAsync() { @Override public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed... args) throws CancelCommandException, ConfigRuntimeException { - if(!(args[0].isInstanceOf(CString.TYPE))) { + if(!(args[0].isInstanceOf(CString.TYPE, null, env))) { throw new CREFormatException(this.getName() + " expects a string as first argument, but type " - + args[0].typeof() + " was found.", t); + + args[0].typeof(env) + " was found.", t); } return new CString(args[0].val().toLowerCase(), t); } @@ -1420,7 +1420,7 @@ public Mixed exec(Target t, Environment environment, GenericParameters generics, } List flattenedArgs = new ArrayList<>(); - if(numArgs == 3 && args[2].isInstanceOf(CArray.TYPE)) { + if(numArgs == 3 && args[2].isInstanceOf(CArray.TYPE, null, environment)) { if(((CArray) args[2]).inAssociativeMode()) { throw new CRECastException("If the second argument to " + getName() + " is an array, it may not be associative.", t); } else { @@ -2528,7 +2528,7 @@ public Boolean runAsync() { @Override public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { - if(args[0].isInstanceOf(CArray.TYPE)) { + if(args[0].isInstanceOf(CArray.TYPE, null, environment)) { CArray array = ArgumentValidation.getArray(args[0], t); return new CSecureString(array, t); } else { @@ -2606,10 +2606,10 @@ public Boolean runAsync() { @Override public Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException { - if(args[0].isInstanceOf(CSecureString.TYPE)) { + if(args[0].isInstanceOf(CSecureString.TYPE, null, environment)) { CSecureString secure = ArgumentValidation.getObject(args[0], t, CSecureString.class); return secure.getDecryptedCharCArray(); - } else if(args[0].isInstanceOf(CString.TYPE)) { + } else if(args[0].isInstanceOf(CString.TYPE, null, environment)) { CArray array = new CArray(Target.UNKNOWN, args[0].val().length()); for(char c : args[0].val().toCharArray()) { array.push(new CString(c, t), t); diff --git a/src/main/java/com/laytonsmith/core/functions/Threading.java b/src/main/java/com/laytonsmith/core/functions/Threading.java index 412ca96add..41c6a7275a 100644 --- a/src/main/java/com/laytonsmith/core/functions/Threading.java +++ b/src/main/java/com/laytonsmith/core/functions/Threading.java @@ -371,13 +371,13 @@ public Version since() { */ private static final Map SYNC_OBJECT_LOCKS = new HashMap<>(); - private static Lock getSyncObject(Mixed cSyncObject, Function f, Target t) { + private static Lock getSyncObject(Mixed cSyncObject, Function f, Target t, Environment env) { if(cSyncObject instanceof CNull || cSyncObject == null) { throw new CRENullPointerException("Synchronization object may not be null in " + f.getName() + "().", t); } Object syncObject = cSyncObject; - if(cSyncObject.isInstanceOf(ValueType.TYPE)) { + if(cSyncObject.isInstanceOf(ValueType.TYPE, null, env)) { if(!(cSyncObject instanceof CString)) { throw new CREIllegalArgumentException("Only strings and non-value types can be used for synchronization.", t); } @@ -498,7 +498,7 @@ public Mixed execs(Target t, Environment env, Script parent, ParseTree... nodes) // Get the sync object (CArray or String value of the Mixed). Mixed cSyncObject = parent.seval(syncObjectTree, env); - Lock syncObject = getSyncObject(cSyncObject, this, t); + Lock syncObject = getSyncObject(cSyncObject, this, t, env); // Evaluate the code, synchronized by the passed sync object. try { @@ -639,7 +639,7 @@ public Mixed exec(Target t, Environment env, GenericParameters generics, Mixed.. = ArgumentValidation.getObject(args[1], t, com.laytonsmith.core.natives.interfaces.Callable.class); // Get the sync object (CArray or String value of the Mixed). - Lock syncObject = getSyncObject(cSyncObject, this, t); + Lock syncObject = getSyncObject(cSyncObject, this, t, env); // Evaluate the code, synchronized by the passed sync object. DaemonManager dm = env.getEnv(StaticRuntimeEnv.class).GetDaemonManager(); diff --git a/src/main/java/com/laytonsmith/core/functions/Web.java b/src/main/java/com/laytonsmith/core/functions/Web.java index 8f6439f38a..90f8fbbc84 100644 --- a/src/main/java/com/laytonsmith/core/functions/Web.java +++ b/src/main/java/com/laytonsmith/core/functions/Web.java @@ -306,7 +306,7 @@ public Mixed exec(final Target t, final Environment environment, GenericParamete } settings.setComplexParameters(mparams); } else { - if(csettings.get("params", t).isInstanceOf(CByteArray.TYPE, null, environment)) { + if(csettings.get("params", t) instanceof CByteArray) { CByteArray b = (CByteArray) csettings.get("params", t); settings.setRawParameter(b.asByteArrayCopy()); } else { @@ -375,7 +375,7 @@ public Mixed exec(final Target t, final Environment environment, GenericParamete } if(csettings.containsKey("trustStore")) { Mixed trustStore = csettings.get("trustStore", t); - if(trustStore.isInstanceOf(CBoolean.TYPE, null, environment) && ArgumentValidation.getBoolean(trustStore, t) == false) { + if(trustStore instanceof CBoolean && ArgumentValidation.getBoolean(trustStore, t) == false) { settings.setDisableCertChecking(true); } else if(trustStore.isInstanceOf(CArray.TYPE, null, environment)) { CArray trustStoreA = ((CArray) trustStore); @@ -942,7 +942,7 @@ protected PasswordAuthentication getPasswordAuthentication() { if(!"".equals(disposition)) { message.setDisposition(disposition); } - message.setContent(getContent(content, t), type); + message.setContent(getContent(content, t, environment), type); } else { Multipart mp = new MimeMultipart("alternative"); for(Mixed attachment : attachments.asList()) { @@ -951,7 +951,7 @@ protected PasswordAuthentication getPasswordAuthentication() { final String fileName = ArgumentValidation.getItemFromArray(pattachment, "filename", t, new CString("", t)).val().trim(); String description = ArgumentValidation.getItemFromArray(pattachment, "description", t, new CString("", t)).val().trim(); String disposition = ArgumentValidation.getItemFromArray(pattachment, "disposition", t, new CString("", t)).val().trim(); - final Object content = getContent(ArgumentValidation.getItemFromArray(pattachment, "content", t, null), t); + final Object content = getContent(ArgumentValidation.getItemFromArray(pattachment, "content", t, null), t, environment); BodyPart bp = new MimeBodyPart(); if(!"".equals(fileName)) { bp.setFileName(fileName); @@ -1032,10 +1032,10 @@ public String getName() { * @param t * @return */ - private Object getContent(Mixed c, Target t) { - if(c.isInstanceOf(CString.TYPE)) { + private Object getContent(Mixed c, Target t, Environment environment) { + if(c.isInstanceOf(CString.TYPE, null, environment)) { return c.val(); - } else if(c.isInstanceOf(CByteArray.TYPE)) { + } else if(c instanceof CByteArray) { CByteArray cb = (CByteArray) c; return cb.asByteArrayCopy(); } else { diff --git a/src/main/java/com/laytonsmith/core/natives/interfaces/AbstractMixed.java b/src/main/java/com/laytonsmith/core/natives/interfaces/AbstractMixed.java index 74e3e95f47..84d1c3b36d 100644 --- a/src/main/java/com/laytonsmith/core/natives/interfaces/AbstractMixed.java +++ b/src/main/java/com/laytonsmith/core/natives/interfaces/AbstractMixed.java @@ -75,7 +75,7 @@ public boolean isInstanceOf(CClassType type, LeftHandGenericUse lhsGenericParame if(type.getNativeType() != null) { return type.getNativeType().isAssignableFrom(this.getClass()); } - return Construct.isInstanceof(this, type); + return Construct.isInstanceof(this, type, env); } @Override diff --git a/src/main/java/com/laytonsmith/core/natives/interfaces/AbstractMixedInterfaceRunner.java b/src/main/java/com/laytonsmith/core/natives/interfaces/AbstractMixedInterfaceRunner.java index 56a7a192ee..bba8c3d008 100644 --- a/src/main/java/com/laytonsmith/core/natives/interfaces/AbstractMixedInterfaceRunner.java +++ b/src/main/java/com/laytonsmith/core/natives/interfaces/AbstractMixedInterfaceRunner.java @@ -143,7 +143,7 @@ public boolean isInstanceOf(Class type) { @Override public boolean isInstanceOf(CClassType type, LeftHandGenericUse lhsGenericParameters, Environment env) { - return Construct.isInstanceof(this, type); + return Construct.isInstanceof(this, type, env); } @Override diff --git a/src/main/java/com/laytonsmith/core/natives/interfaces/MEnumType.java b/src/main/java/com/laytonsmith/core/natives/interfaces/MEnumType.java index 5507334db3..685224761c 100644 --- a/src/main/java/com/laytonsmith/core/natives/interfaces/MEnumType.java +++ b/src/main/java/com/laytonsmith/core/natives/interfaces/MEnumType.java @@ -293,7 +293,7 @@ public boolean isInstanceOf(Class type) { @Override public boolean isInstanceOf(CClassType type, LeftHandGenericUse lhsGenericParameters, Environment env) { - return Construct.isInstanceof(this, type); + return Construct.isInstanceof(this, type, env); } @Override diff --git a/src/main/java/com/laytonsmith/core/objects/UserObject.java b/src/main/java/com/laytonsmith/core/objects/UserObject.java index f2bbb48f95..c17160995d 100644 --- a/src/main/java/com/laytonsmith/core/objects/UserObject.java +++ b/src/main/java/com/laytonsmith/core/objects/UserObject.java @@ -165,7 +165,7 @@ public boolean isInstanceOf(Class type) { @Override public boolean isInstanceOf(CClassType type, LeftHandGenericUse lhsGenericParameters, Environment env) { - return Construct.isInstanceof(this, type); + return Construct.isInstanceof(this, type, env); } /** @deprecated Use {@link #typeof(Environment)} instead. */ diff --git a/src/main/java/com/laytonsmith/tools/Manager.java b/src/main/java/com/laytonsmith/tools/Manager.java index 0f541a1573..245216a939 100644 --- a/src/main/java/com/laytonsmith/tools/Manager.java +++ b/src/main/java/com/laytonsmith/tools/Manager.java @@ -461,7 +461,7 @@ public static boolean doAddEdit(String key, String valueScript) { Environment env = Environment.createEnvironment(gEnv, staticRuntimeEnv, new CommandHelperEnvironment()); Mixed c = MethodScriptCompiler.execute(MethodScriptCompiler.compile( MethodScriptCompiler.lex(valueScript, env, null, true), env, null), env, null, null); - String value = Construct.json_encode(c, Target.UNKNOWN); + String value = Construct.json_encode(c, Target.UNKNOWN, env); pl(CYAN + "Adding: " + WHITE + value); String[] k = key.split("\\."); DaemonManager dm = new DaemonManager(); From 5d63334c9bcb8c60b3d8fcbe5cdfded713824f97 Mon Sep 17 00:00:00 2001 From: LadyCailin Date: Tue, 24 Feb 2026 01:40:32 +0100 Subject: [PATCH 06/28] Change 'environment' to 'env' everywhere --- .../core/MethodScriptCompiler.java | 52 +-- .../java/com/laytonsmith/core/Static.java | 14 +- .../java/com/laytonsmith/core/StrictMode.java | 10 +- .../laytonsmith/core/asm/LLVMFunction.java | 2 +- .../laytonsmith/core/constructs/CClosure.java | 24 +- .../core/constructs/CIClosure.java | 14 +- .../core/constructs/CNativeClosure.java | 4 +- .../core/constructs/ProcedureUsage.java | 4 +- .../core/functions/ArrayHandling.java | 364 +++++++++--------- .../core/functions/BasicLogic.java | 62 +-- .../core/functions/BukkitMetadata.java | 24 +- .../core/functions/ByteArrays.java | 46 +-- .../laytonsmith/core/functions/Clipboard.java | 8 +- .../laytonsmith/core/functions/Cmdline.java | 80 ++-- .../laytonsmith/core/functions/Commands.java | 36 +- .../laytonsmith/core/functions/Compiler.java | 10 +- .../core/functions/ControlFlow.java | 16 +- .../laytonsmith/core/functions/Crypto.java | 42 +- .../core/functions/DataHandling.java | 64 +-- .../core/functions/DataTransformations.java | 18 +- .../com/laytonsmith/core/functions/Debug.java | 38 +- .../laytonsmith/core/functions/Echoes.java | 16 +- .../core/functions/Enchantments.java | 36 +- .../core/functions/EntityManagement.java | 184 ++++----- .../core/functions/Environment.java | 144 +++---- .../core/functions/EventBinding.java | 62 +-- .../core/functions/Exceptions.java | 14 +- .../core/functions/ExecutionQueue.java | 48 +-- .../core/functions/ExtensionMeta.java | 10 +- .../core/functions/Federation.java | 20 +- .../core/functions/FileHandling.java | 28 +- .../core/functions/InventoryManagement.java | 124 +++--- .../laytonsmith/core/functions/ItemMeta.java | 24 +- .../laytonsmith/core/functions/Marquee.java | 6 +- .../com/laytonsmith/core/functions/Math.java | 16 +- .../com/laytonsmith/core/functions/Meta.java | 102 ++--- .../laytonsmith/core/functions/Minecraft.java | 40 +- .../core/functions/MobManagement.java | 104 ++--- .../com/laytonsmith/core/functions/OAuth.java | 6 +- .../com/laytonsmith/core/functions/OS.java | 2 +- .../core/functions/ObjectManagement.java | 8 +- .../core/functions/Performance.java | 2 +- .../core/functions/Permissions.java | 8 +- .../core/functions/Persistence.java | 10 +- .../core/functions/PlayerManagement.java | 206 +++++----- .../core/functions/PluginMeta.java | 16 +- .../laytonsmith/core/functions/Recipes.java | 12 +- .../com/laytonsmith/core/functions/Redis.java | 2 +- .../core/functions/Reflection.java | 34 +- .../com/laytonsmith/core/functions/Regex.java | 2 +- .../core/functions/ResourceManager.java | 6 +- .../com/laytonsmith/core/functions/SQL.java | 24 +- .../laytonsmith/core/functions/Sandbox.java | 12 +- .../core/functions/Scheduling.java | 46 +-- .../core/functions/Scoreboards.java | 46 +-- .../core/functions/Statistics.java | 22 +- .../core/functions/StringHandling.java | 36 +- .../core/functions/TaskHandling.java | 8 +- .../laytonsmith/core/functions/Threading.java | 12 +- .../laytonsmith/core/functions/Trades.java | 2 +- .../laytonsmith/core/functions/Weather.java | 18 +- .../com/laytonsmith/core/functions/Web.java | 68 ++-- .../com/laytonsmith/core/functions/World.java | 118 +++--- .../com/laytonsmith/core/functions/XGUI.java | 8 +- .../core/natives/interfaces/Callable.java | 4 +- 65 files changed, 1324 insertions(+), 1324 deletions(-) diff --git a/src/main/java/com/laytonsmith/core/MethodScriptCompiler.java b/src/main/java/com/laytonsmith/core/MethodScriptCompiler.java index 1016308acb..859975a91d 100644 --- a/src/main/java/com/laytonsmith/core/MethodScriptCompiler.java +++ b/src/main/java/com/laytonsmith/core/MethodScriptCompiler.java @@ -1265,10 +1265,10 @@ public static List