use of dyvilx.tools.compiler.ast.expression.access.FieldAccess in project Dyvil by Dyvil.
the class Closure method withType.
@Override
public IValue withType(IType type, ITypeContext typeContext, MarkerList markers, IContext context) {
if (this.resolved) {
return super.withType(type, typeContext, markers, context);
}
final IMethod functionalMethod = type.getFunctionalMethod();
if (functionalMethod == null) {
return null;
}
final ParameterList parameterList = functionalMethod.getParameters();
final int parameterCount = parameterList.size();
final IParameter[] parameters = new IParameter[parameterCount];
for (int i = 0; i < parameterCount; i++) {
parameters[i] = new CodeParameter(null, this.position, Name.fromRaw("$" + i), Types.UNKNOWN);
}
final LambdaType functionType = type.extract(LambdaType.class);
if (functionType != null && functionType.isExtension() && parameterCount > 0) {
this.implicitValue = new FieldAccess(parameters[0]);
}
final LambdaExpr lambdaExpr = new LambdaExpr(this.position, parameters, parameterCount);
lambdaExpr.setValue(this);
this.resolved = true;
context = context.push(this);
final IValue typedLambda = lambdaExpr.withType(type, typeContext, markers, context);
context.pop();
return typedLambda;
}
Aggregations