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 extends Mixed> 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 extends Mixed> 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 extends Mixed> 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 extends Mixed> 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;