Skip to content

Commit 760d39c

Browse files
committed
Upgrade some call sites to non-deprecated versions
1 parent 4af691d commit 760d39c

54 files changed

Lines changed: 304 additions & 666 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

pom.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -493,6 +493,8 @@
493493
<compilerArgs>
494494
<arg>-XDignore.symbol.file</arg>
495495
<arg>-parameters</arg>
496+
<arg>-Xmaxwarns</arg>
497+
<arg>9999</arg>
496498
</compilerArgs>
497499
</configuration>
498500
</plugin>

src/main/java/com/laytonsmith/core/ArgumentValidation.java

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -491,7 +491,7 @@ public static boolean getBooleanish(Mixed c, Target t, Environment env) {
491491
if(InstanceofUtil.isInstanceof(c, Booleanish.class, env)) {
492492
return ((Booleanish) c).getBooleanValue(t);
493493
}
494-
throw new CRECastException("Could not convert value of type " + c.typeof() + " to a " + Booleanish.TYPE, t);
494+
throw new CRECastException("Could not convert value of type " + c.typeof(env) + " to a " + Booleanish.TYPE, t);
495495
}
496496

497497
/**
@@ -516,15 +516,21 @@ public static CByteArray getByteArray(Mixed c, Target t, Environment env) {
516516
} else if(c instanceof CNull) {
517517
return new CByteArray(t, 0);
518518
} else {
519-
throw new CRECastException("Expecting byte array, but found " + c.typeof() + " instead.", t);
519+
throw new CRECastException("Expecting byte array, but found " + c.typeof(env) + " instead.", t);
520520
}
521521
}
522522

523+
/** @deprecated Use {@link #getClassType(Mixed, Target, Environment)} instead. */
524+
@Deprecated
523525
public static CClassType getClassType(Mixed c, Target t) {
526+
return getClassType(c, t, null);
527+
}
528+
529+
public static CClassType getClassType(Mixed c, Target t, Environment env) {
524530
if(c instanceof CClassType) {
525531
return (CClassType) c;
526532
} else {
527-
throw new CRECastException("Expecting a ClassType, but found " + c.typeof() + " instead.", t);
533+
throw new CRECastException("Expecting a ClassType, but found " + c.typeof(env) + " instead.", t);
528534
}
529535
}
530536

@@ -559,7 +565,7 @@ public static String getStringObject(Mixed c, Target t) {
559565
*/
560566
public static String getStringObject(Mixed c, Target t, Environment env) {
561567
if(!c.isInstanceOf(CString.class)) {
562-
throw new CRECastException("Expected a string, but found " + c.typeof() + " instead.", t);
568+
throw new CRECastException("Expected a string, but found " + c.typeof(env) + " instead.", t);
563569
}
564570
return c.val();
565571
}

src/main/java/com/laytonsmith/core/ObjectGenerator.java

Lines changed: 33 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -181,16 +181,22 @@ public CArray location(MCLocation l, boolean includeYawAndPitch) {
181181
return ca;
182182
}
183183

184+
/** @deprecated Use {@link #location(Mixed, MCWorld, Target, Environment)} instead. */
185+
@Deprecated
186+
public MCLocation location(Mixed c, MCWorld w, Target t) {
187+
return location(c, w, t, null);
188+
}
189+
184190
/**
185191
* Given a Location Object, returns a MCLocation. If the optional world is not specified in the object, the world
186192
* provided is used instead. Location "objects" are MethodScript arrays that represent a location in game. There are
187193
* 4 usages: <ul> <li>(x, y, z)</li> <li>(x, y, z, world)</li> <li>(x, y, z, yaw, pitch)</li> <li>(x, y, z, world,
188194
* yaw, pitch)</li> </ul> In all cases, the pitch and yaw default to 0, and the world defaults to the specified
189195
* world. <em>More conveniently: ([world], x, y, z, [yaw, pitch])</em>
190196
*/
191-
public MCLocation location(Mixed c, MCWorld w, Target t) {
197+
public MCLocation location(Mixed c, MCWorld w, Target t, Environment env) {
192198
if(!(c.isInstanceOf(CArray.TYPE))) {
193-
throw new CREFormatException("Expecting an array, received " + c.typeof().getSimpleName(), t);
199+
throw new CREFormatException("Expecting an array, received " + c.typeof(env).getSimpleName(), t);
194200
}
195201
CArray array = (CArray) c;
196202
MCWorld world = w;
@@ -2063,6 +2069,12 @@ public Vector3D vector(Mixed c, Target t) {
20632069
return vector(Vector3D.ZERO, c, t);
20642070
}
20652071

2072+
/** @deprecated Use {@link #vector(Vector3D, Mixed, Target, Environment)} instead. */
2073+
@Deprecated
2074+
public Vector3D vector(Vector3D v, Mixed c, Target t) {
2075+
return vector(v, c, t, null);
2076+
}
2077+
20662078
/**
20672079
* Modifies an existing vector using a given vector object. Because Vector3D is immutable, this method does not
20682080
* actually modify the existing vector, but creates a new one.
@@ -2072,7 +2084,7 @@ public Vector3D vector(Mixed c, Target t) {
20722084
* @param t the target
20732085
* @return the Vector
20742086
*/
2075-
public Vector3D vector(Vector3D v, Mixed c, Target t) {
2087+
public Vector3D vector(Vector3D v, Mixed c, Target t, Environment env) {
20762088
if(c.isInstanceOf(CArray.TYPE)) {
20772089
CArray va = (CArray) c;
20782090
double x = v.X();
@@ -2107,7 +2119,7 @@ public Vector3D vector(Vector3D v, Mixed c, Target t) {
21072119
// fulfilling the todo?
21082120
return v;
21092121
} else {
2110-
throw new CREFormatException("Expecting an array, received " + c.typeof().getSimpleName(), t);
2122+
throw new CREFormatException("Expecting an array, received " + c.typeof(env).getSimpleName(), t);
21112123
}
21122124
}
21132125

@@ -2446,7 +2458,13 @@ public CArray fireworkEffect(MCFireworkEffect mcfe, Target t) {
24462458
return fe;
24472459
}
24482460

2461+
/** @deprecated Use {@link #fireworkEffect(CArray, Target, Environment)} instead. */
2462+
@Deprecated
24492463
public MCFireworkEffect fireworkEffect(CArray fe, Target t) {
2464+
return fireworkEffect(fe, t, null);
2465+
}
2466+
2467+
public MCFireworkEffect fireworkEffect(CArray fe, Target t, Environment env) {
24502468
MCFireworkBuilder builder = StaticLayer.GetConvertor().GetFireworkBuilder();
24512469
if(fe.containsKey("flicker")) {
24522470
builder.setFlicker(ArgumentValidation.getBoolean(fe.get("flicker", t), t));
@@ -2473,7 +2491,7 @@ public MCFireworkEffect fireworkEffect(CArray fe, Target t) {
24732491
break;
24742492
} else {
24752493
throw new CREFormatException("Expecting individual color to be an array or string, but found "
2476-
+ color.typeof(), t);
2494+
+ color.typeof(env), t);
24772495
}
24782496
builder.addColor(mccolor);
24792497
}
@@ -2489,7 +2507,7 @@ public MCFireworkEffect fireworkEffect(CArray fe, Target t) {
24892507
}
24902508
} else {
24912509
throw new CREFormatException("Expecting an array or string for colors parameter, but found "
2492-
+ colors.typeof(), t);
2510+
+ colors.typeof(env), t);
24932511
}
24942512
} else {
24952513
builder.addColor(MCColor.WHITE);
@@ -2510,7 +2528,7 @@ public MCFireworkEffect fireworkEffect(CArray fe, Target t) {
25102528
break;
25112529
} else {
25122530
throw new CREFormatException("Expecting individual color to be an array or string, but found "
2513-
+ color.typeof(), t);
2531+
+ color.typeof(env), t);
25142532
}
25152533
builder.addFadeColor(mccolor);
25162534
}
@@ -2521,7 +2539,7 @@ public MCFireworkEffect fireworkEffect(CArray fe, Target t) {
25212539
}
25222540
} else {
25232541
throw new CREFormatException("Expecting an array or string for fade parameter, but found "
2524-
+ colors.typeof(), t);
2542+
+ colors.typeof(env), t);
25252543
}
25262544
}
25272545
if(fe.containsKey("type")) {
@@ -2595,9 +2613,15 @@ public Construct recipe(MCRecipe r, Target t) {
25952613
return ret;
25962614
}
25972615

2616+
/** @deprecated Use {@link #recipe(Mixed, Target, Environment)} instead. */
2617+
@Deprecated
25982618
public MCRecipe recipe(Mixed c, Target t) {
2619+
return recipe(c, t, null);
2620+
}
2621+
2622+
public MCRecipe recipe(Mixed c, Target t, Environment env) {
25992623
if(!(c.isInstanceOf(CArray.TYPE))) {
2600-
throw new CRECastException("Expected array but received " + c.typeof().getSimpleName(), t);
2624+
throw new CRECastException("Expected array but received " + c.typeof(env).getSimpleName(), t);
26012625
}
26022626
CArray recipe = (CArray) c;
26032627

src/main/java/com/laytonsmith/core/Procedure.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -243,25 +243,25 @@ public Mixed execute(List<Mixed> args, Environment oldEnv, Target t) {
243243

244244
// Type check vararg parameter.
245245
if(var.getDefinedType().isVariadicType()) {
246-
if(InstanceofUtil.isInstanceof(c.typeof(), var.getDefinedType().getVarargsBaseType(), env)) {
246+
if(InstanceofUtil.isInstanceof(c.typeof(env), var.getDefinedType().getVarargsBaseType(), env)) {
247247
vararg.push(c, t);
248248
continue;
249249
} else {
250250
throw new CRECastException("Procedure \"" + name + "\" expects a value of type "
251251
+ var.getDefinedType().val() + " in argument " + (varInd + 1) + ", but"
252-
+ " a value of type " + c.typeof() + " was found instead.", c.getTarget());
252+
+ " a value of type " + c.typeof(env) + " was found instead.", c.getTarget());
253253
}
254254
}
255255

256256
// Type check non-vararg parameter.
257-
if(InstanceofUtil.isInstanceof(c.typeof(), var.getDefinedType(), env)) {
257+
if(InstanceofUtil.isInstanceof(c.typeof(env), var.getDefinedType(), env)) {
258258
env.getEnv(GlobalEnv.class).GetVarList().set(new IVariable(var.getDefinedType(),
259259
var.getVariableName(), c, c.getTarget()));
260260
continue;
261261
} else {
262262
throw new CRECastException("Procedure \"" + name + "\" expects a value of type "
263263
+ var.getDefinedType().val() + " in argument " + (varInd + 1) + ", but"
264-
+ " a value of type " + c.typeof() + " was found instead.", c.getTarget());
264+
+ " a value of type " + c.typeof(env) + " was found instead.", c.getTarget());
265265
}
266266
}
267267
}
@@ -302,9 +302,9 @@ public Mixed execute(List<Mixed> args, Environment oldEnv, Target t) {
302302
}
303303
if(returnType.equals(CVoid.TYPE) != ret.equals(CVoid.VOID)
304304
|| !ret.equals(CNull.NULL) && !ret.equals(CVoid.VOID)
305-
&& !InstanceofUtil.isInstanceof(ret.typeof(), returnType, env)) {
305+
&& !InstanceofUtil.isInstanceof(ret.typeof(env), returnType, env)) {
306306
throw new CRECastException("Expected procedure \"" + name + "\" to return a value of type "
307-
+ returnType.val() + " but a value of type " + ret.typeof() + " was returned instead",
307+
+ returnType.val() + " but a value of type " + ret.typeof(env) + " was returned instead",
308308
ret.getTarget());
309309
}
310310
return ret;

src/main/java/com/laytonsmith/core/Static.java

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1485,6 +1485,12 @@ public static boolean InCmdLine(Environment environment, boolean defaultValue) {
14851485
return environment.getEnv(GlobalEnv.class).inCmdlineMode();
14861486
}
14871487

1488+
/** @deprecated Use {@link #AssertType(Class, Mixed[], int, Function, Target, Environment)} instead. */
1489+
@Deprecated
1490+
public static <T extends Mixed> T AssertType(Class<T> type, Mixed[] args, int argNumber, Function func, Target t) {
1491+
return AssertType(type, args, argNumber, func, t, null);
1492+
}
1493+
14881494
/**
14891495
* This verifies that the type required is actually present, and returns the value, cast to the appropriate type,
14901496
* or, if not the correct type, a CRE.
@@ -1497,15 +1503,16 @@ public static boolean InCmdLine(Environment environment, boolean defaultValue) {
14971503
* @param args The array of arguments.
14981504
* @param argNumber The argument number, used both for grabbing the correct argument from args, and building the
14991505
* error message if the cast cannot occur.
1500-
* @param func The function, in case this errors out, to build the error message.
1506+
* @param func The function, in case this errors out,
1507+
* @param envto build the error message.
15011508
* @param t The code target
15021509
* @return The value, cast to the desired type.
15031510
*/
1504-
public static <T extends Mixed> T AssertType(Class<T> type, Mixed[] args, int argNumber, Function func, Target t) {
1511+
public static <T extends Mixed> T AssertType(Class<T> type, Mixed[] args, int argNumber, Function func, Target t, Environment env) {
15051512
Mixed value = args[argNumber];
15061513
if(!type.isAssignableFrom(value.getClass())) {
15071514
typeof todesired = ClassDiscovery.GetClassAnnotation(type, typeof.class);
1508-
CClassType toactual = value.typeof();
1515+
CClassType toactual = value.typeof(env);
15091516
if(todesired != null) {
15101517
throw new CRECastException("Argument " + (argNumber + 1) + " of " + func.getName() + " was expected to be a "
15111518
+ todesired.value() + ", but " + toactual + " \"" + value.val() + "\" was found.", t);

src/main/java/com/laytonsmith/core/asm/LLVMArgumentValidation.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ public static String getValueFromConstant(IRBuilder builder, ParseTree data, Env
200200
public static IRData getAny(IRBuilder builder, Environment env, ParseTree c, Target t) throws ConfigCompileException {
201201
LLVMEnvironment e = env.getEnv(LLVMEnvironment.class);
202202
if(c.isConst()) {
203-
IRType datatype = convertCClassTypeToIRType(c.getData().typeof());
203+
IRType datatype = convertCClassTypeToIRType(c.getData().typeof(env));
204204
String data = getValueFromConstant(builder, c, env);
205205
int alloca = e.getNewLocalVariableReference(datatype);
206206
int load = e.getNewLocalVariableReference(datatype);

src/main/java/com/laytonsmith/core/asm/LLVMPlatformResolver.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,6 @@ public static IRData outputConstant(IRBuilder builder, Mixed c, Environment env)
4040
builder.appendLine(c.getTarget(), "%" + gep + " = getelementptr inbounds [" + length + " x i8], [" + length + " x i8]* %" + alloca + ", i64 0, i64 0");
4141
return IRDataBuilder.setReturnVariable(gep, IRType.STRING);
4242
}
43-
throw new UnsupportedOperationException("Unsupported data type " + c.typeof().getName());
43+
throw new UnsupportedOperationException("Unsupported data type " + c.typeof(env).getName());
4444
}
4545
}

src/main/java/com/laytonsmith/core/constructs/CFixedArray.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -103,9 +103,9 @@ public Set<Mixed> keySet(Environment env) {
103103
return set;
104104
}
105105

106-
private void validateSet(Mixed value, Target t) {
107-
if(!value.typeof().doesExtend(allowedType)) {
108-
throw new CRECastException("Cannot set value of type " + value.typeof().toString() + " into fixed_array of type " + allowedType.toString(), t);
106+
private void validateSet(Mixed value, Target t, Environment env) {
107+
if(!value.typeof(env).doesExtend(allowedType)) {
108+
throw new CRECastException("Cannot set value of type " + value.typeof(env).toString() + " into fixed_array of type " + allowedType.toString(), t);
109109
}
110110
}
111111

@@ -119,11 +119,11 @@ public void set(Mixed index, Mixed value, Target t) {
119119
@Override
120120
public void set(Mixed index, Mixed value, Target t, Environment env) {
121121
int in = ArgumentValidation.getInt32(index, t, env);
122-
set(in, value, t);
122+
set(in, value, t, env);
123123
}
124124

125-
public void set(int index, Mixed value, Target t) {
126-
validateSet(value, t);
125+
public void set(int index, Mixed value, Target t, Environment env) {
126+
validateSet(value, t, env);
127127
if(index >= data.length || index < 0) {
128128
throw new CREIndexOverflowException("Index under/overflow in fixed_array", t);
129129
}
@@ -176,8 +176,8 @@ public long size(Environment env) {
176176
return data.length;
177177
}
178178

179-
public void fill(Mixed value, Target t) {
180-
validateSet(value, t);
179+
public void fill(Mixed value, Target t, Environment env) {
180+
validateSet(value, t, env);
181181
ArrayUtils.fill(data, value);
182182
}
183183

src/main/java/com/laytonsmith/core/constructs/CMutablePrimitive.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ public long size() {
126126

127127
@Override
128128
public long size(Environment env) {
129-
if(value.isInstanceOf(Sizeable.TYPE)) {
129+
if(value.isInstanceOf(Sizeable.TYPE, null, env)) {
130130
return ArgumentValidation.getObject(value, Target.UNKNOWN, Sizeable.class).size(env);
131131
} else {
132132
return 0;

src/main/java/com/laytonsmith/core/constructs/InstanceofUtil.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ public static boolean isInstanceof(Mixed value, FullyQualifiedClassName instance
7575
// TODO: Need to put the return type here, so we can work with this, but for now, just always return false
7676
return false;
7777
}
78-
return isInstanceof(value.typeof(), instanceofThis, env);
78+
return isInstanceof(value.typeof(env), instanceofThis, env);
7979
}
8080

8181
/**

0 commit comments

Comments
 (0)