Skip to content

Commit 1e225d0

Browse files
committed
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.
1 parent 75f73f1 commit 1e225d0

27 files changed

Lines changed: 924 additions & 63 deletions

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

Lines changed: 143 additions & 22 deletions
Large diffs are not rendered by default.

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

Lines changed: 183 additions & 30 deletions
Large diffs are not rendered by default.

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import com.laytonsmith.PureUtilities.Version;
44
import com.laytonsmith.annotations.typeof;
55
import com.laytonsmith.core.MSVersion;
6+
import com.laytonsmith.core.environments.Environment;
67
import com.laytonsmith.core.objects.ObjectModifier;
78
import java.util.EnumSet;
89
import java.util.Set;
@@ -94,6 +95,11 @@ public boolean getBooleanValue(Target t) {
9495
return val;
9596
}
9697

98+
@Override
99+
public boolean getBooleanValue(Environment env, Target t) {
100+
return getBooleanValue(t);
101+
}
102+
97103

98104

99105
/**

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

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import com.laytonsmith.annotations.typeof;
66
import com.laytonsmith.core.ArgumentValidation;
77
import com.laytonsmith.core.MSVersion;
8+
import com.laytonsmith.core.environments.Environment;
89
import com.laytonsmith.core.exceptions.CRE.CRERangeException;
910
import com.laytonsmith.core.exceptions.CRE.CREReadOnlyException;
1011
import com.laytonsmith.core.exceptions.CRE.CREUnsupportedOperationException;
@@ -395,6 +396,11 @@ public long size() {
395396
return maxValue;
396397
}
397398

399+
@Override
400+
public long size(Environment env) {
401+
return size();
402+
}
403+
398404
/**
399405
* Returns the maximum size of the underlying data before it would have to be resized to add more data. This is not
400406
* to be confused with the size.
@@ -490,6 +496,11 @@ public Mixed slice(int begin, int end, Target t) {
490496
return getBytes(end - begin, begin);
491497
}
492498

499+
@Override
500+
public Mixed slice(int begin, int end, Target t, Environment env) {
501+
return slice(begin, end, t);
502+
}
503+
493504
@Override
494505
public boolean isAssociative() {
495506
return false;
@@ -530,6 +541,11 @@ public Set<Mixed> keySet() {
530541
throw new CREUnsupportedOperationException("Getting a key set from a byte array is not supported.", getTarget());
531542
}
532543

544+
@Override
545+
public Set<Mixed> keySet(Environment env) {
546+
return keySet();
547+
}
548+
533549
@Override
534550
public Set<String> stringKeySet() {
535551
throw new CREUnsupportedOperationException("Getting a string key set from a byte array is not supported.", getTarget());
@@ -540,6 +556,11 @@ public void set(Mixed index, Mixed c, Target t) throws ConfigRuntimeException {
540556
throw new CREUnsupportedOperationException("Modifying a byte array using array_set() is not supported.", t);
541557
}
542558

559+
@Override
560+
public void set(Mixed index, Mixed c, Target t, Environment env) throws ConfigRuntimeException {
561+
set(index, c, t);
562+
}
563+
543564
@Override
544565
protected CArray deepClone(CArray array, Target t, ArrayList<CArray[]> cloneRefs) {
545566
CByteArray that = (CByteArray) array;
@@ -556,6 +577,11 @@ public Mixed get(Mixed index, Target t) throws ConfigRuntimeException {
556577
return new CInt(b, t);
557578
}
558579

580+
@Override
581+
public Mixed get(Mixed index, Target t, Environment env) throws ConfigRuntimeException {
582+
return get(index, t);
583+
}
584+
559585
@Override
560586
public boolean containsKey(String c) {
561587
throw new CREUnsupportedOperationException("Checking for a key in a byte array is not supported.", getTarget());
@@ -652,6 +678,11 @@ public void set(Mixed index, Mixed c, Target t) {
652678
throw new CREByteArrayReadOnlyException("Arrays copied from ByteArrays are read only", t);
653679
}
654680

681+
@Override
682+
public void set(Mixed index, Mixed c, Target t, Environment env) {
683+
set(index, c, t);
684+
}
685+
655686
@Override
656687
public Mixed get(Mixed index, Target t) {
657688
int i = ArgumentValidation.getInt32(index, t);
@@ -662,11 +693,21 @@ public Mixed get(Mixed index, Target t) {
662693
}
663694
}
664695

696+
@Override
697+
public Mixed get(Mixed index, Target t, Environment env) {
698+
return get(index, t);
699+
}
700+
665701
@Override
666702
public long size() {
667703
return backing.length;
668704
}
669705

706+
@Override
707+
public long size(Environment env) {
708+
return size();
709+
}
710+
670711
@Override
671712
public String val() {
672713
if(value == null) {

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

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -604,6 +604,11 @@ public Mixed get(String index, Target t) throws ConfigRuntimeException {
604604
throw new CREUnsupportedOperationException("Unsupported operation", t);
605605
}
606606

607+
@Override
608+
public Mixed get(String index, Target t, Environment env) throws ConfigRuntimeException {
609+
return get(index, t);
610+
}
611+
607612
@Override
608613
public Mixed get(int index, Target t) throws ConfigRuntimeException {
609614
if(isEnum()) {
@@ -616,6 +621,11 @@ public Mixed get(int index, Target t) throws ConfigRuntimeException {
616621
throw new CREUnsupportedOperationException("Unsupported operation", t);
617622
}
618623

624+
@Override
625+
public Mixed get(int index, Target t, Environment env) throws ConfigRuntimeException {
626+
return get(index, t);
627+
}
628+
619629
@Override
620630
public Mixed get(Mixed index, Target t) throws ConfigRuntimeException {
621631
if(isEnum()) {
@@ -628,6 +638,11 @@ public Mixed get(Mixed index, Target t) throws ConfigRuntimeException {
628638
throw new CREUnsupportedOperationException("Unsupported operation", t);
629639
}
630640

641+
@Override
642+
public Mixed get(Mixed index, Target t, Environment env) throws ConfigRuntimeException {
643+
return get(index, t);
644+
}
645+
631646
@Override
632647
public Set<Mixed> keySet() {
633648
if(isEnum()) {
@@ -640,6 +655,11 @@ public Set<Mixed> keySet() {
640655
return new HashSet<>();
641656
}
642657

658+
@Override
659+
public Set<Mixed> keySet(Environment env) {
660+
return keySet();
661+
}
662+
643663
@Override
644664
public long size() {
645665
if(isEnum()) {
@@ -652,6 +672,11 @@ public long size() {
652672
return 0;
653673
}
654674

675+
@Override
676+
public long size(Environment env) {
677+
return size();
678+
}
679+
655680
@Override
656681
public boolean isAssociative() {
657682
return true;
@@ -667,6 +692,11 @@ public Mixed slice(int begin, int end, Target t) {
667692
throw new CREUnsupportedOperationException("Unsupported operation", t);
668693
}
669694

695+
@Override
696+
public Mixed slice(int begin, int end, Target t, Environment env) {
697+
return slice(begin, end, t);
698+
}
699+
670700
/**
671701
* If this was constructed against a native class, we can do some optimizations in the course
672702
* of operation. This may be null, and all code that uses this method must support the mechanisms if this
@@ -682,6 +712,11 @@ public boolean getBooleanValue(Target t) {
682712
return true;
683713
}
684714

715+
@Override
716+
public boolean getBooleanValue(Environment env, Target t) {
717+
return getBooleanValue(t);
718+
}
719+
685720
/**
686721
* Returns a new type based on the parent type, which is a variadic variant.
687722
* @return A new variadic type.
@@ -741,6 +776,7 @@ public GenericTypeParameters getTypeGenericParameters() {
741776
/**
742777
* Stub for generics support — not yet implemented.
743778
*/
779+
@Override
744780
public GenericParameters getGenericParameters() {
745781
throw new UnsupportedOperationException("Not yet implemented");
746782
}

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -354,4 +354,9 @@ public CClassType[] getInterfaces() {
354354
public boolean getBooleanValue(Target t) {
355355
return true;
356356
}
357+
358+
@Override
359+
public boolean getBooleanValue(Environment env, Target t) {
360+
return getBooleanValue(t);
361+
}
357362
}

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import com.laytonsmith.PureUtilities.Version;
44
import com.laytonsmith.annotations.typeof;
55
import com.laytonsmith.core.MSVersion;
6+
import com.laytonsmith.core.environments.Environment;
67
import com.laytonsmith.core.exceptions.CRE.CREFormatException;
78
import java.math.BigDecimal;
89

@@ -88,4 +89,9 @@ public boolean getBooleanValue(Target t) {
8889
return val.compareTo(new BigDecimal(0)) != 0;
8990
}
9091

92+
@Override
93+
public boolean getBooleanValue(Environment env, Target t) {
94+
return getBooleanValue(t);
95+
}
96+
9197
}

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

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import com.laytonsmith.core.exceptions.CRE.CREIndexOverflowException;
1010
import com.laytonsmith.core.exceptions.CRE.CREUnsupportedOperationException;
1111
import com.laytonsmith.core.exceptions.ConfigRuntimeException;
12+
import com.laytonsmith.core.environments.Environment;
1213
import com.laytonsmith.core.natives.interfaces.ArrayAccessSet;
1314
import com.laytonsmith.core.natives.interfaces.Booleanish;
1415
import com.laytonsmith.core.natives.interfaces.Mixed;
@@ -48,6 +49,11 @@ public Mixed get(String index, Target t) throws ConfigRuntimeException {
4849
return null;
4950
}
5051

52+
@Override
53+
public Mixed get(String index, Target t, Environment env) throws ConfigRuntimeException {
54+
return get(index, t);
55+
}
56+
5157
@Override
5258
public Mixed get(int index, Target t) throws ConfigRuntimeException {
5359
if(index < 0 || index >= data.length) {
@@ -60,11 +66,21 @@ public Mixed get(int index, Target t) throws ConfigRuntimeException {
6066
return d;
6167
}
6268

69+
@Override
70+
public Mixed get(int index, Target t, Environment env) throws ConfigRuntimeException {
71+
return get(index, t);
72+
}
73+
6374
@Override
6475
public Mixed get(Mixed index, Target t) throws ConfigRuntimeException {
6576
return get(ArgumentValidation.getInt32(index, t), t);
6677
}
6778

79+
@Override
80+
public Mixed get(Mixed index, Target t, Environment env) throws ConfigRuntimeException {
81+
return get(index, t);
82+
}
83+
6884
@Override
6985
public Set<Mixed> keySet() {
7086
Set<Mixed> set = new LinkedHashSet<>(data.length);
@@ -74,6 +90,11 @@ public Set<Mixed> keySet() {
7490
return set;
7591
}
7692

93+
@Override
94+
public Set<Mixed> keySet(Environment env) {
95+
return keySet();
96+
}
97+
7798
private void validateSet(Mixed value, Target t) {
7899
if(!value.typeof().doesExtend(allowedType)) {
79100
throw new CRECastException("Cannot set value of type " + value.typeof().toString() + " into fixed_array of type " + allowedType.toString(), t);
@@ -86,6 +107,11 @@ public void set(Mixed index, Mixed value, Target t) {
86107
set(in, value, t);
87108
}
88109

110+
@Override
111+
public void set(Mixed index, Mixed value, Target t, Environment env) {
112+
set(index, value, t);
113+
}
114+
89115
public void set(int index, Mixed value, Target t) {
90116
validateSet(value, t);
91117
if(index >= data.length || index < 0) {
@@ -109,16 +135,31 @@ public Mixed slice(int begin, int end, Target t) {
109135
throw new CREUnsupportedOperationException("slices are not yet implemented on fixed_array", t);
110136
}
111137

138+
@Override
139+
public Mixed slice(int begin, int end, Target t, Environment env) {
140+
return slice(begin, end, t);
141+
}
142+
112143
@Override
113144
public boolean getBooleanValue(Target t) {
114145
return size() > 0;
115146
}
116147

148+
@Override
149+
public boolean getBooleanValue(Environment env, Target t) {
150+
return getBooleanValue(t);
151+
}
152+
117153
@Override
118154
public long size() {
119155
return data.length;
120156
}
121157

158+
@Override
159+
public long size(Environment env) {
160+
return size();
161+
}
162+
122163
public void fill(Mixed value, Target t) {
123164
validateSet(value, t);
124165
ArrayUtils.fill(data, value);

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

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,11 @@ public void set(Mixed index, Mixed c, Target t) {
5656
throw new CRECastException("mutable_primitives cannot have values set in them", t);
5757
}
5858

59+
@Override
60+
public void set(Mixed index, Mixed c, Target t, com.laytonsmith.core.environments.Environment env) {
61+
set(index, c, t);
62+
}
63+
5964
/**
6065
* Sets the value as if
6166
* {@link #set(Mixed, com.laytonsmith.core.constructs.Target)} were called, then
@@ -79,6 +84,11 @@ public Mixed get(Mixed index, Target t) {
7984
return value;
8085
}
8186

87+
@Override
88+
public Mixed get(Mixed index, Target t, com.laytonsmith.core.environments.Environment env) {
89+
return get(index, t);
90+
}
91+
8292
@Override
8393
public String val() {
8494
return value.val();
@@ -108,6 +118,11 @@ public long size() {
108118
}
109119
}
110120

121+
@Override
122+
public long size(com.laytonsmith.core.environments.Environment env) {
123+
return size();
124+
}
125+
111126
@Override
112127
public boolean canBeAssociative() {
113128
return false;

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import com.laytonsmith.PureUtilities.Version;
44
import com.laytonsmith.annotations.typeof;
55
import com.laytonsmith.core.MSVersion;
6+
import com.laytonsmith.core.environments.Environment;
67
import com.laytonsmith.core.natives.interfaces.Booleanish;
78

89
/**
@@ -111,5 +112,10 @@ public boolean getBooleanValue(Target t) {
111112
return false;
112113
}
113114

115+
@Override
116+
public boolean getBooleanValue(Environment env, Target t) {
117+
return getBooleanValue(t);
118+
}
119+
114120

115121
}

0 commit comments

Comments
 (0)