Support for custom uniforms (#902)

* wip backport of custom uniforms

* Functioning custom uniforms maybe?

* Workon separating dynamic/non-dynamic uniforms and making variables available to custom uniforms (currently the JVM dies horribly)

* wip

* It no longer crashes horrifically

* star imports
This commit is contained in:
Darren Eberly authored and GitHub committed 2025-03-18 10:04:31 -07:00
1 parent 6fa973dbc8
commit bed724ba59
89 files changed
+4622 -266

No files matched your search

@@ -7,6 +7,7 @@ import java.util.Map;
/**
* OpResolver maps the trailing characters identifying an operator to an actual operator.
*
* @param <T>
*/
abstract class OpResolver<T> {
@@ -27,7 +28,7 @@ abstract class OpResolver<T> {
* Adds a new multi-character operator. Calling this with an empty string is equivalent to calling singleChar.
*
* @param trailing every character after the first character of the operator.
* @param op the operator
* @param op the operator
*/
public void multiChar(String trailing, T op) {
T previous = map.put(trailing, op);
@@ -40,14 +41,14 @@ abstract class OpResolver<T> {
public OpResolver<T> build() {
if (map.size() > 2) {
throw new RuntimeException("unimplemented: Cannot currently build an optimized operator resolver " +
"tree when more than two operators start with the same character");
"tree when more than two operators start with the same character");
}
T singleChar = map.get("");
if (singleChar != null) {
if (map.size() == 1) {
return new SingleChar<>(singleChar);
return new OpResolver.SingleChar<>(singleChar);
} else {
for (Map.Entry<String, T> subEntry : map.entrySet()) {
if ("".equals(subEntry.getKey())) {
@@ -57,33 +58,33 @@ abstract class OpResolver<T> {
if (subEntry.getKey().length() != 1) {
throw new RuntimeException("unimplemented: Optimized operator resolver trees can " +
"currently only be built of operators that contain one or two characters.");
"currently only be built of operators that contain one or two characters.");
}
// We can assume that this is the only other entry in the map due to the size check above
return new SingleDualChar<>(
singleChar,
subEntry.getValue(),
subEntry.getKey().charAt(0)
return new OpResolver.SingleDualChar<>(
singleChar,
subEntry.getValue(),
subEntry.getKey().charAt(0)
);
}
}
} else {
if (map.size() > 1) {
throw new RuntimeException("unimplemented: Optimized operator resolver trees can currently only " +
"handle two operators starting with the same character if one operator is a single character");
"handle two operators starting with the same character if one operator is a single character");
}
for (Map.Entry<String, T> subEntry : map.entrySet()) {
if (subEntry.getKey().length() != 1) {
throw new RuntimeException("unimplemented: Optimized operator resolver trees can " +
"currently only be built of operators that contain one or two characters.");
"currently only be built of operators that contain one or two characters.");
}
// We can assume that this is the only entry in the map due to the size check above.
return new DualChar<>(
subEntry.getValue(),
subEntry.getKey().charAt(0)
return new OpResolver.DualChar<>(
subEntry.getValue(),
subEntry.getKey().charAt(0)
);
}
}