Skip to content

Commit 77bf064

Browse files
committed
Added Target to CArray.push for better errors
1 parent b844419 commit 77bf064

Some content is hidden

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

45 files changed

+178
-177
lines changed

src/main/java/com/laytonsmith/abstraction/bukkit/BukkitMCCommand.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ public List<String> handleTabComplete(MCCommandSender sender, String alias, Stri
207207
Target t = Target.UNKNOWN;
208208
CArray cargs = new CArray(t);
209209
for (String arg : args) {
210-
cargs.push(new CString(arg, t));
210+
cargs.push(new CString(arg, t), t);
211211
}
212212
try {
213213
Commands.onTabComplete.get(cmd.getName().toLowerCase()).execute(new Construct[]{
@@ -243,7 +243,7 @@ public boolean handleCustomCommand(MCCommandSender sender, String label, String[
243243
Target t = Target.UNKNOWN;
244244
CArray cargs = new CArray(t);
245245
for (String arg : args) {
246-
cargs.push(new CString(arg, t));
246+
cargs.push(new CString(arg, t), t);
247247
}
248248

249249
CClosure closure = Commands.onCommand.get(cmd.getName().toLowerCase());

src/main/java/com/laytonsmith/abstraction/bukkit/BukkitMCWorld.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -660,7 +660,7 @@ public CArray spawnMob(MCMobs name, String subClass, int qty, MCLocation l, Targ
660660
}
661661
}
662662
}
663-
ids.push(new CString(e.getUniqueId().toString(), t));
663+
ids.push(new CString(e.getUniqueId().toString(), t), t);
664664
}
665665
return ids;
666666
}

src/main/java/com/laytonsmith/abstraction/bukkit/events/BukkitBlockEvents.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,7 @@ public CArray getLines() {
312312
CArray retn = new CArray(Target.UNKNOWN);
313313

314314
for (int i = 0; i < 4; i++) {
315-
retn.push(new CString(pie.getLine(i), Target.UNKNOWN));
315+
retn.push(new CString(pie.getLine(i), Target.UNKNOWN), Target.UNKNOWN);
316316
}
317317

318318
return retn;

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

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ public Construct item(MCItemStack is, Target t) {
240240
CArray enchObj = CArray.GetAssociativeArray(t);
241241
enchObj.set("etype", new CString(entry.getKey().getName(), t), t);
242242
enchObj.set("elevel", new CInt(entry.getValue(), t), t);
243-
enchants.push(enchObj);
243+
enchants.push(enchObj, t);
244244
}
245245
Construct meta = itemMeta(is, t);
246246
CArray ret = CArray.GetAssociativeArray(t);
@@ -376,7 +376,7 @@ public Construct itemMeta(MCItemStack is, Target t) {
376376
if (meta.hasLore()) {
377377
lore = new CArray(t);
378378
for (String l : meta.getLore()) {
379-
((CArray) lore).push(new CString(l, t));
379+
((CArray) lore).push(new CString(l, t), t);
380380
}
381381
} else {
382382
lore = CNull.NULL;
@@ -397,12 +397,12 @@ public Construct itemMeta(MCItemStack is, Target t) {
397397
}
398398
CArray colors = new CArray(t);
399399
for(MCColor c : mcfm.getColors()){
400-
colors.push(ObjectGenerator.GetGenerator().color(c, t));
400+
colors.push(ObjectGenerator.GetGenerator().color(c, t), t);
401401
}
402402
cf.set("colors", colors, t);
403403
CArray fadeColors = new CArray(t);
404404
for(MCColor c : mcfm.getFadeColors()){
405-
fadeColors.push(ObjectGenerator.GetGenerator().color(c, t));
405+
fadeColors.push(ObjectGenerator.GetGenerator().color(c, t), t);
406406
}
407407
cf.set("fade", fadeColors, t);
408408
ma.set("firework", firework, t);
@@ -431,7 +431,7 @@ public Construct itemMeta(MCItemStack is, Target t) {
431431
if (((MCBookMeta) meta).hasPages()) {
432432
pages = new CArray(t);
433433
for (String p : ((MCBookMeta) meta).getPages()) {
434-
((CArray) pages).push(new CString(p, t));
434+
((CArray) pages).push(new CString(p, t), t);
435435
}
436436
} else {
437437
pages = CNull.NULL;
@@ -470,7 +470,7 @@ public Construct itemMeta(MCItemStack is, Target t) {
470470
CArray pattern = CArray.GetAssociativeArray(t);
471471
pattern.set("shape", new CString(p.getShape().toString(), t), t);
472472
pattern.set("color", new CString(p.getColor().toString(), t), t);
473-
patterns.push(pattern);
473+
patterns.push(pattern, t);
474474
}
475475
ma.set("patterns", patterns, t);
476476
MCDyeColor dyeColor = bannermeta.getBaseColor();
@@ -483,7 +483,7 @@ public Construct itemMeta(MCItemStack is, Target t) {
483483
CArray flagArray = new CArray(t);
484484
if (itemFlags.size() > 0) {
485485
for (MCItemFlag flag : itemFlags) {
486-
flagArray.push(new CString(flag.name(), t));
486+
flagArray.push(new CString(flag.name(), t), t);
487487
}
488488
}
489489
ma.set("flags", flagArray, t);
@@ -732,10 +732,10 @@ public MCItemMeta itemMeta(Construct c, MCMaterial mat, Target t) throws ConfigR
732732

733733
public CArray exception(ConfigRuntimeException e, Target t) {
734734
CArray ex = new CArray(t);
735-
ex.push(new CString(e.getExceptionType().toString(), t));
736-
ex.push(new CString(e.getMessage(), t));
737-
ex.push(new CString((e.getFile() != null ? e.getFile().getAbsolutePath() : "null"), t));
738-
ex.push(new CInt(e.getLineNum(), t));
735+
ex.push(new CString(e.getExceptionType().toString(), t), t);
736+
ex.push(new CString(e.getMessage(), t), t);
737+
ex.push(new CString((e.getFile() != null ? e.getFile().getAbsolutePath() : "null"), t), t);
738+
ex.push(new CInt(e.getLineNum(), t), t);
739739
return ex;
740740
}
741741

@@ -906,7 +906,7 @@ public CArray enchants(Map<MCEnchantment, Integer> map, Target t) {
906906
CArray eObj = CArray.GetAssociativeArray(t);
907907
eObj.set("etype", new CString(entry.getKey().getName(), t), t);
908908
eObj.set("elevel", new CInt(entry.getValue(), t), t);
909-
ret.push(eObj);
909+
ret.push(eObj, t);
910910
}
911911
return ret;
912912
}
@@ -939,7 +939,7 @@ public CArray potions(List<MCLivingEntity.MCEffect> effectList, Target t) {
939939
effect.set("seconds", new CInt(eff.getSecondsRemaining(), t), t);
940940
effect.set("ambient", CBoolean.get(eff.isAmbient()), t);
941941
effect.set("particles", CBoolean.get(eff.hasParticles()), t);
942-
ea.push(effect);
942+
ea.push(effect, t);
943943
}
944944
return ea;
945945
}
@@ -989,14 +989,14 @@ public Construct recipe(MCRecipe r, Target t) {
989989
} else if (r instanceof MCShapelessRecipe) {
990990
CArray il = new CArray(t);
991991
for (MCItemStack i : ((MCShapelessRecipe) r).getIngredients()) {
992-
il.push(item(i, t));
992+
il.push(item(i, t), t);
993993
}
994994
ret.set("ingredients", il, t);
995995
} else if (r instanceof MCShapedRecipe) {
996996
MCShapedRecipe sr = (MCShapedRecipe) r;
997997
CArray shape = new CArray(t);
998998
for (String line : sr.getShape()) {
999-
shape.push(new CString(line, t));
999+
shape.push(new CString(line, t), t);
10001000
}
10011001
CArray imap = CArray.GetAssociativeArray(t);
10021002
for (Map.Entry<Character, MCItemStack> entry : sr.getIngredientMap().entrySet()) {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ public Construct execute(List<Construct> args, Environment env, Target t) {
180180
for (String key : originals.keySet()) {
181181
Construct c = originals.get(key);
182182
env.getEnv(GlobalEnv.class).GetVarList().set(new IVariable(CClassType.AUTO, key, c, Target.UNKNOWN));
183-
arguments.push(c);
183+
arguments.push(c, t);
184184
}
185185
Script fakeScript = Script.GenerateScript(tree, env.getEnv(GlobalEnv.class).GetLabel());//new Script(null, null);
186186
for (int i = 0; i < args.size(); i++) {

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

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1440,7 +1440,7 @@ public String getString(CResource res) {
14401440
boolean[] array = (boolean[]) object;
14411441
CArray r = new CArray(t);
14421442
for (boolean b : array) {
1443-
r.push(CBoolean.get(b));
1443+
r.push(CBoolean.get(b), t);
14441444
}
14451445
return r;
14461446
} else if (object instanceof byte[]) {
@@ -1449,48 +1449,48 @@ public String getString(CResource res) {
14491449
char[] array = (char[]) object;
14501450
CArray r = new CArray(t);
14511451
for (char c : array) {
1452-
r.push(new CString(c, t));
1452+
r.push(new CString(c, t), t);
14531453
}
14541454
return r;
14551455
} else if (object instanceof short[]) {
14561456
short[] array = (short[]) object;
14571457
CArray r = new CArray(t);
14581458
for (short s : array) {
1459-
r.push(new CInt(s, t));
1459+
r.push(new CInt(s, t), t);
14601460
}
14611461
return r;
14621462
} else if (object instanceof int[]) {
14631463
int[] array = (int[]) object;
14641464
CArray r = new CArray(t);
14651465
for (int i : array) {
1466-
r.push(new CInt(i, t));
1466+
r.push(new CInt(i, t), t);
14671467
}
14681468
return r;
14691469
} else if (object instanceof long[]) {
14701470
long[] array = (long[]) object;
14711471
CArray r = new CArray(t);
14721472
for (long l : array) {
1473-
r.push(new CInt(l, t));
1473+
r.push(new CInt(l, t), t);
14741474
}
14751475
return r;
14761476
} else if (object instanceof float[]) {
14771477
float[] array = (float[]) object;
14781478
CArray r = new CArray(t);
14791479
for (float f : array) {
1480-
r.push(new CDouble(f, t));
1480+
r.push(new CDouble(f, t), t);
14811481
}
14821482
return r;
14831483
} else if (object instanceof double[]) {
14841484
double[] array = (double[]) object;
14851485
CArray r = new CArray(t);
14861486
for (double d : array) {
1487-
r.push(new CDouble(d, t));
1487+
r.push(new CDouble(d, t), t);
14881488
}
14891489
return r;
14901490
} else if (object instanceof Object[]) {
14911491
CArray r = new CArray(t);
14921492
for (Object o : (Object[]) object) {
1493-
r.push((o == object) ? r : getMSObject(o, t));
1493+
r.push((o == object) ? r : getMSObject(o, t), t);
14941494
}
14951495
return r;
14961496
} else if (object instanceof Collection) {

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -229,8 +229,8 @@ public void reverse(){
229229
* Pushes a new Construct onto the end of the array.
230230
* @param c
231231
*/
232-
public void push(Construct c){
233-
push(c, null);
232+
public final void push(Construct c, Target t){
233+
push(c, null, t);
234234
}
235235
/**
236236
* Pushes a new Construct onto the end of the array. If the index is specified, this works like
@@ -243,7 +243,7 @@ public void push(Construct c){
243243
* @throws IndexOutOfBoundsException If the index is not null, and the index specified is out of
244244
* range.
245245
*/
246-
public void push(Construct c, Integer index) throws IllegalArgumentException, IndexOutOfBoundsException {
246+
public void push(Construct c, Integer index, Target t) throws IllegalArgumentException, IndexOutOfBoundsException {
247247
if (!associative_mode) {
248248
if(index != null){
249249
array.add(index, c);
@@ -325,7 +325,7 @@ public void set(Construct index, Construct c, Target t) {
325325
if (indx > next_index || indx < 0) {
326326
throw new ConfigRuntimeException("", ExceptionType.IndexOverflowException, Target.UNKNOWN);
327327
} else if(indx == next_index){
328-
this.push(c);
328+
this.push(c, t);
329329
} else {
330330
array.set(indx, c);
331331
}
@@ -446,13 +446,13 @@ public CArray indexesOf(Construct value){
446446
if(associative_mode){
447447
for(String key : associative_array.keySet()){
448448
if(BasicLogic.equals.doEquals(associative_array.get(key), value)){
449-
ret.push(new CString(key, Target.UNKNOWN));
449+
ret.push(new CString(key, Target.UNKNOWN), Target.UNKNOWN);
450450
}
451451
}
452452
} else {
453453
for(int i = 0; i < array.size(); i++){
454454
if(BasicLogic.equals.doEquals(array.get(i), value)){
455-
ret.push(new CInt(i, Target.UNKNOWN));
455+
ret.push(new CInt(i, Target.UNKNOWN), Target.UNKNOWN);
456456
}
457457
}
458458
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -491,7 +491,7 @@ public void reverse() {
491491
}
492492

493493
@Override
494-
public void push(Construct c) {
494+
public void push(Construct c, Integer i, Target t) {
495495
throw new ROException();
496496
}
497497

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ public void execute(Construct... values) throws ConfigRuntimeException, ProgramF
165165
CArray arguments = new CArray(node.getData().getTarget());
166166
if (values != null) {
167167
for (Construct value : values) {
168-
arguments.push(value);
168+
arguments.push(value, node.getData().getTarget());
169169
}
170170
}
171171
environment.getEnv(GlobalEnv.class).GetVarList().set(new IVariable(new CClassType("array", Target.UNKNOWN), "@arguments", arguments, node.getData().getTarget()));

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ public void execute(Construct... values) throws ConfigRuntimeException, ProgramF
6565
CArray arguments = new CArray(node.getData().getTarget());
6666
if (values != null) {
6767
for (Construct value : values) {
68-
arguments.push(value);
68+
arguments.push(value, node.getData().getTarget());
6969
}
7070
}
7171
environment.getEnv(GlobalEnv.class).GetVarList().set(new IVariable(new CClassType("array", Target.UNKNOWN), "@arguments", arguments, node.getData().getTarget()));

0 commit comments

Comments
 (0)