use of dyvilx.tools.compiler.ast.expression.access.AbstractCall in project Dyvil by Dyvil.
the class LambdaExpr method cleanup.
@Override
public IValue cleanup(ICompilableList compilableList, IClassCompilableList classCompilableList) {
this.parameters.cleanup(compilableList, classCompilableList);
if (this.returnType != null && (this.flags & EXPLICIT_RETURN) != 0) {
this.returnType.cleanup(compilableList, classCompilableList);
}
this.value = this.value.cleanup(compilableList, classCompilableList);
if (this.captureHelper == null || !this.captureHelper.hasCaptures()) {
// Check if we can use a direct method reference
if (this.value instanceof AbstractCall) {
final AbstractCall call = (AbstractCall) this.value;
final IMethod method = call.getMethod();
if (method != null && this.checkCall(call.getReceiver(), call.getArguments(), method)) {
this.setHandleType(ClassFormat.insnToHandle(method.getInvokeOpcode()));
this.name = method.getInternalName();
this.owner = method.getEnclosingClass().getInternalName();
this.descriptor = method.getDescriptor();
return this;
}
} else // To avoid trouble with anonymous classes
if (this.value.getClass() == ConstructorCall.class) {
final ConstructorCall call = (ConstructorCall) this.value;
final IConstructor constructor = call.getConstructor();
if (constructor != null && this.checkCall(null, call.getArguments(), constructor)) {
this.setHandleType(ClassFormat.H_NEWINVOKESPECIAL);
this.name = constructor.getInternalName();
this.owner = constructor.getEnclosingClass().getInternalName();
this.descriptor = constructor.getDescriptor();
return this;
}
}
}
this.owner = classCompilableList.getInternalName();
this.name = "lambda$" + classCompilableList.classCompilableCount();
classCompilableList.addClassCompilable(this);
return this;
}
Aggregations