Skip to content

Commit 75f73f1

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

84 files changed

Lines changed: 1225 additions & 1115 deletions

Some content is hidden

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

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -335,9 +335,9 @@ public ArgumentParser getArgumentParser() {
335335

336336
@Override
337337
public void execute(ArgumentParser.ArgumentParserResults parsedArgs) throws Exception {
338-
String buildYear = new Scheduling.simple_date().exec(Target.UNKNOWN, null,
338+
String buildYear = new Scheduling.simple_date().exec(Target.UNKNOWN, null, null,
339339
new CString("yyyy", Target.UNKNOWN),
340-
new Meta.engine_build_date().exec(Target.UNKNOWN, null)).val();
340+
new Meta.engine_build_date().exec(Target.UNKNOWN, null, null)).val();
341341
StreamUtils.GetSystemOut().println("The MIT License (MIT)\n"
342342
+ "\n"
343343
+ "Copyright (c) 2012-" + buildYear + " Methodscript Contributors\n"
@@ -594,7 +594,7 @@ public static void CreateNewFiles(List<String> files, boolean force) throws IOEx
594594
+ "\tstrict;" + li
595595
+ "\tname: " + f.getName() + ";" + li
596596
+ "\tauthor: " + System.getProperty("user.name") + ";" + li
597-
+ "\tcreated: " + new Scheduling.simple_date().exec(Target.UNKNOWN, null, new CString("yyyy-MM-dd", Target.UNKNOWN)).val() + ";" + li
597+
+ "\tcreated: " + new Scheduling.simple_date().exec(Target.UNKNOWN, null, null, new CString("yyyy-MM-dd", Target.UNKNOWN)).val() + ";" + li
598598
+ "\tdescription: " + ";" + li
599599
+ ">" + li + li, f, true);
600600
}
@@ -641,7 +641,7 @@ public void execute(ArgumentParser.ArgumentParserResults parsedArgs) throws Exce
641641
classSimpleName = split[split.length - 1];
642642

643643
String author = System.getProperty("user.name");
644-
String created = new Scheduling.simple_date().exec(Target.UNKNOWN, null,
644+
String created = new Scheduling.simple_date().exec(Target.UNKNOWN, null, null,
645645
new CString("yyyy-MM-dd", Target.UNKNOWN)).val();
646646
File file = new File(clazz.replace(".", "/") + ".ms");
647647
if(file.exists()) {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2699,7 +2699,7 @@ private static void optimize(ParseTree tree, Environment env,
26992699
+ tree.getData().val(), tree.getData().getTarget()));
27002700
result = null;
27012701
} else {
2702-
result = func.exec(tree.getData().getTarget(), env, constructs);
2702+
result = Function.ExecuteFunction(func, tree.getData().getTarget(), env, constructs);
27032703
}
27042704
} else if(isValidNumArgs(func, constructs.length)) {
27052705
result = ((Optimizable) func).optimize(tree.getData().getTarget(), env, constructs);

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -427,7 +427,7 @@ public Mixed eval(ParseTree c, final Environment env) throws CancelCommandExcept
427427
}
428428
Mixed ret;
429429
try {
430-
ret = f.exec(m.getTarget(), env, args);
430+
ret = Function.ExecuteFunction(f, m.getTarget(), env, args);
431431
} finally {
432432
if(p != null) {
433433
p.stop();

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public static BuildArtifact getLatestVersionInfo() throws ApiException, ParseExc
4343
}
4444

4545
public static Boolean isUpdateAvailable() {
46-
Mixed buildDate = new Meta.engine_build_date().exec(null, null, (Mixed[]) null);
46+
Mixed buildDate = new Meta.engine_build_date().exec(null, null, null, (Mixed[]) null);
4747
if(buildDate instanceof CNull) {
4848
return null;
4949
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -554,7 +554,7 @@ public static IRData getIR(IRBuilder builder, ParseTree node, Environment env) t
554554
if(fb instanceof LLVMFunction f) {
555555
builder.functionsUsed.add(f);
556556
return f.buildIR(builder, node.getTarget(), env,
557-
node.getChildren().toArray(new ParseTree[node.getChildren().size()]));
557+
null, node.getChildren().toArray(new ParseTree[node.getChildren().size()]));
558558
} else {
559559
throw new Error("Unexpected function type");
560560
}

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import com.laytonsmith.core.constructs.CClassType;
1616
import com.laytonsmith.core.constructs.CFunction;
1717
import com.laytonsmith.core.constructs.Target;
18+
import com.laytonsmith.core.constructs.generics.GenericParameters;
1819
import com.laytonsmith.core.environments.Environment;
1920
import com.laytonsmith.core.exceptions.ConfigCompileException;
2021
import com.laytonsmith.core.exceptions.ConfigRuntimeException;
@@ -106,7 +107,7 @@ public Boolean runAsync() {
106107
}
107108

108109
@Override
109-
public final Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException {
110+
public final Mixed exec(Target t, Environment environment, GenericParameters generics, Mixed... args) throws ConfigRuntimeException {
110111
throw new UnsupportedOperationException("Not supported.");
111112
}
112113

@@ -228,12 +229,13 @@ public int compareTo(Function o) {
228229
* @param builder The ongoing builder. Functions should append to this as needed.
229230
* @param t The code target this node comes from.
230231
* @param env The Environment
232+
* @param parameters Generic parameters passed to this function call.
231233
* @param nodes The children passed to this function, could be empty array.
232234
* @return Information on the returned value, including things like type (if known) and how to reference the
233235
* output value.
234236
* @throws com.laytonsmith.core.exceptions.ConfigCompileException If there is a compilation error.
235237
*/
236-
public abstract IRData buildIR(IRBuilder builder, Target t, Environment env, ParseTree... nodes) throws ConfigCompileException;
238+
public abstract IRData buildIR(IRBuilder builder, Target t, Environment env, GenericParameters parameters, ParseTree... nodes) throws ConfigCompileException;
237239

238240
@Override
239241
public final boolean useSpecialExec() {

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -823,7 +823,7 @@ public boolean canBeAssociative() {
823823

824824
@Override
825825
public Mixed slice(int begin, int end, Target t) {
826-
return new ArrayHandling.array_get().exec(t, null, new CSlice(begin, end, t));
826+
return new ArrayHandling.array_get().exec(t, null, null, new CSlice(begin, end, t));
827827
}
828828

829829
@Override
@@ -923,13 +923,13 @@ public int compare(Mixed o1, Mixed o2) {
923923
}
924924

925925
public int compareRegular(Mixed o1, Mixed o2) {
926-
if(ArgumentValidation.getBooleanObject(new DataHandling.is_numeric().exec(Target.UNKNOWN, null, o1), Target.UNKNOWN)
927-
&& ArgumentValidation.getBooleanObject(new DataHandling.is_numeric().exec(Target.UNKNOWN, null, o2), Target.UNKNOWN)) {
926+
if(ArgumentValidation.getBooleanObject(new DataHandling.is_numeric().exec(Target.UNKNOWN, null, null, o1), Target.UNKNOWN)
927+
&& ArgumentValidation.getBooleanObject(new DataHandling.is_numeric().exec(Target.UNKNOWN, null, null, o2), Target.UNKNOWN)) {
928928
return compareNumeric(o1, o2);
929-
} else if(ArgumentValidation.getBooleanObject(new DataHandling.is_numeric().exec(Target.UNKNOWN, null, o1), Target.UNKNOWN)) {
929+
} else if(ArgumentValidation.getBooleanObject(new DataHandling.is_numeric().exec(Target.UNKNOWN, null, null, o1), Target.UNKNOWN)) {
930930
//The first is a number, the second is a string
931931
return -1;
932-
} else if(ArgumentValidation.getBooleanObject(new DataHandling.is_numeric().exec(Target.UNKNOWN, null, o2), Target.UNKNOWN)) {
932+
} else if(ArgumentValidation.getBooleanObject(new DataHandling.is_numeric().exec(Target.UNKNOWN, null, null, o2), Target.UNKNOWN)) {
933933
//The second is a number, the first is a string
934934
return 1;
935935
} else {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ public Version since() {
106106

107107
@Override
108108
public void msFinalize() {
109-
new res_free_resource().exec(new Target(0, new File("/Finalizer"), 0), null, this);
109+
new res_free_resource().exec(new Target(0, new File("/Finalizer"), 0), null, null, this);
110110
}
111111

112112
public static interface ResourceToString {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ public CSlice(long from, long to, Target t) {
6969

7070
@Override
7171
public List<Mixed> asList() {
72-
CArray ca = new ArrayHandling.range().exec(Target.UNKNOWN, null, new CInt(start, Target.UNKNOWN), new CInt(finish, Target.UNKNOWN));
72+
CArray ca = new ArrayHandling.range().exec(Target.UNKNOWN, null, null, new CInt(start, Target.UNKNOWN), new CInt(finish, Target.UNKNOWN));
7373
return ca.asList();
7474
}
7575

src/main/java/com/laytonsmith/core/events/drivers/PlayerEvents.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1793,7 +1793,7 @@ public boolean matches(String key, Mixed value, MCPlayerCommandEvent event, Targ
17931793
String command = event.getCommand();
17941794
String prefilter = value.val();
17951795
StringHandling.parse_args pa = new StringHandling.parse_args();
1796-
CArray ca = (CArray) pa.exec(Target.UNKNOWN, null, new CString(command, Target.UNKNOWN));
1796+
CArray ca = (CArray) pa.exec(Target.UNKNOWN, null, null, new CString(command, Target.UNKNOWN));
17971797
if(ca.size() > 0) {
17981798
if(!ca.get(0, Target.UNKNOWN).val().equals(prefilter)) {
17991799
return false;
@@ -1831,7 +1831,7 @@ public Map<String, Mixed> evaluate(BindableEvent e) throws EventException {
18311831
map.put("command", new CString(event.getCommand(), Target.UNKNOWN));
18321832

18331833
StringHandling.parse_args pa = new StringHandling.parse_args();
1834-
CArray ca = (CArray) pa.exec(Target.UNKNOWN, null, new CString(event.getCommand(), Target.UNKNOWN));
1834+
CArray ca = (CArray) pa.exec(Target.UNKNOWN, null, null, new CString(event.getCommand(), Target.UNKNOWN));
18351835
map.put("prefix", new CString(ca.get(0, Target.UNKNOWN).val(), Target.UNKNOWN));
18361836

18371837
return map;

0 commit comments

Comments
 (0)