Skip to content

Commit

Permalink
Removed Context from every method, moved some of its methods to Scope…
Browse files Browse the repository at this point in the history
…, removed Remapper
  • Loading branch information
LatvianModder committed Mar 23, 2024
1 parent 982e32e commit 0f1bd47
Show file tree
Hide file tree
Showing 137 changed files with 1,222 additions and 1,348 deletions.
7 changes: 4 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,10 @@ repositories {

dependencies {
compileOnly('org.jetbrains:annotations:23.0.0')
testImplementation('org.junit.jupiter:junit-jupiter-api:5.9.0')
testImplementation('org.junit.jupiter:junit-jupiter-engine:5.9.0')
testImplementation('junit:junit:4.13.2')
implementation("org.ow2.asm:asm:9.2")
testImplementation('org.junit.jupiter:junit-jupiter-api:5.10.2')
testImplementation('org.junit.jupiter:junit-jupiter-engine:5.10.2')
// testImplementation('junit:junit:4.13.2')
}

jar {
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/dev/latvian/apps/ichor/Callable.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,17 @@

@FunctionalInterface
public interface Callable {
Object call(Context cx, Scope scope, Object[] args, boolean hasNew);
Object call(Scope scope, Object[] args, boolean hasNew);

default Object[] evalArgs(Context cx, Scope scope, Object[] arguments) {
default Object[] evalArgs(Scope scope, Object[] arguments) {
if (arguments.length == 0) {
return Empty.OBJECTS;
}

var args = arguments;

for (int i = 0; i < args.length; i++) {
var a = cx.eval(scope, args[i]);
var a = scope.eval(args[i]);

if (a != args[i]) {
if (args == arguments) {
Expand Down
9 changes: 3 additions & 6 deletions src/main/java/dev/latvian/apps/ichor/CallableTypeAdapter.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,12 @@
import java.lang.reflect.Proxy;

public interface CallableTypeAdapter extends Callable, TypeAdapter, InvocationHandler {
Context getEvalContext();

Scope getEvalScope();

@Override
@SuppressWarnings("unchecked")
default <T> T adapt(Context cx, Scope scope, Class<T> type) {
return (T) Proxy.newProxyInstance(cx.getClassLoader() == null ? type.getClassLoader() : cx.getClassLoader(), new Class[]{type}, this);
default <T> T adapt(Scope scope, Class<T> type) {
return (T) Proxy.newProxyInstance(scope.root.context.getClassLoader() == null ? type.getClassLoader() : scope.root.context.getClassLoader(), new Class[]{type}, this);
}

@Override
Expand All @@ -32,8 +30,7 @@ default Object invoke(Object proxy, Method method, Object[] args) throws Throwab
return InvocationHandler.invokeDefault(proxy, method, args);
}

var cx = getEvalContext();
var scope = getEvalScope();
return cx.as(scope, call(cx, scope, args == null ? Empty.OBJECTS : args, false), method.getReturnType());
return scope.as(call(scope, args == null ? Empty.OBJECTS : args, false), method.getReturnType());
}
}
Loading

0 comments on commit 0f1bd47

Please sign in to comment.