mirror of
https://github.com/GTNewHorizons/CraftTweaker.git
synced 2026-11-12 00:07:52 +00:00
format all the things!
This commit is contained in:
1 parent
54ec75fd3d
commit
b36c6dade6
377 files changed
+6833
-6772
No files matched your search
@@ -31,9 +31,9 @@ public class ExpressionJavaLambda extends Expression {
|
||||
private final Class interfaceClass;
|
||||
private final List<ParsedFunctionArgument> arguments;
|
||||
private final List<Statement> statements;
|
||||
|
||||
|
||||
private final ZenType type;
|
||||
|
||||
|
||||
public ExpressionJavaLambda(
|
||||
ZenPosition position,
|
||||
Class interfaceClass,
|
||||
@@ -41,11 +41,11 @@ public class ExpressionJavaLambda extends Expression {
|
||||
List<Statement> statements,
|
||||
ZenType type) {
|
||||
super(position);
|
||||
|
||||
|
||||
this.interfaceClass = interfaceClass;
|
||||
this.arguments = arguments;
|
||||
this.statements = statements;
|
||||
|
||||
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
@@ -56,43 +56,44 @@ public class ExpressionJavaLambda extends Expression {
|
||||
|
||||
@Override
|
||||
public void compile(boolean result, IEnvironmentMethod environment) {
|
||||
if (!result) return;
|
||||
|
||||
if (!result)
|
||||
return;
|
||||
|
||||
Method method = interfaceClass.getMethods()[0];
|
||||
|
||||
|
||||
// generate class
|
||||
String clsName = environment.makeClassName();
|
||||
|
||||
|
||||
ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_FRAMES);
|
||||
cw.visit(Opcodes.V1_6, Opcodes.ACC_PUBLIC, clsName, null, "java/lang/Object", new String[] { internal(interfaceClass) });
|
||||
|
||||
|
||||
MethodOutput constructor = new MethodOutput(cw, Opcodes.ACC_PUBLIC, "<init>", "()V", null, null);
|
||||
constructor.start();
|
||||
constructor.loadObject(0);
|
||||
constructor.invokeSpecial("java/lang/Object", "<init>", "()V");
|
||||
constructor.ret();
|
||||
constructor.end();
|
||||
|
||||
|
||||
MethodOutput output = new MethodOutput(cw, Opcodes.ACC_PUBLIC, method.getName(), descriptor(method), null, null);
|
||||
|
||||
|
||||
IEnvironmentClass environmentClass = new EnvironmentClass(cw, environment);
|
||||
IEnvironmentMethod environmentMethod = new EnvironmentMethod(output, environmentClass);
|
||||
|
||||
|
||||
for (int i = 0; i < arguments.size(); i++) {
|
||||
environmentMethod.putValue(
|
||||
arguments.get(i).getName(),
|
||||
new SymbolArgument(i + 1, environment.getType(method.getGenericParameterTypes()[i])),
|
||||
getPosition());
|
||||
}
|
||||
|
||||
|
||||
output.start();
|
||||
for (Statement statement : statements) {
|
||||
statement.compile(environmentMethod);
|
||||
}
|
||||
output.end();
|
||||
|
||||
|
||||
environment.putClass(clsName, cw.toByteArray());
|
||||
|
||||
|
||||
// make class instance
|
||||
environment.getOutput().newObject(clsName);
|
||||
environment.getOutput().dup();
|
||||
|
||||
Reference in new issue
Block a user