use of dyvilx.tools.compiler.ast.parameter.ParameterList 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;
}
use of dyvilx.tools.compiler.ast.parameter.ParameterList in project Dyvil by Dyvil.
the class IntrinsicData method writeArgument.
static IType writeArgument(MethodWriter writer, IMethod method, int index, IValue receiver, ArgumentList arguments) throws BytecodeException {
final ParameterList params = method.getParameters();
if (receiver == null || receiver.isIgnoredClassAccess()) {
final IParameter parameter = params.get(index);
arguments.writeValue(index, parameter, writer);
return parameter.getCovariantType();
}
if (index == 0) {
final IType type = method.hasModifier(INFIX) ? params.get(0).getCovariantType() : method.getReceiverType();
receiver.writeExpression(writer, type);
return type;
}
final IParameter parameter = params.get(method.hasModifier(INFIX) ? index : index - 1);
arguments.writeValue(index - 1, parameter, writer);
return parameter.getCovariantType();
}
Aggregations