use of dyvilx.tools.compiler.ast.expression.ArrayExpr in project Dyvil by Dyvil.
the class Deprecation method getReplacements.
private static String[] getReplacements(ArgumentList arguments) {
IValue value = arguments.get(DEP_REPLACE_PARAM);
if (value == null) {
return null;
}
assert value.valueTag() == IValue.ARRAY;
final ArrayExpr array = (ArrayExpr) value;
final ArgumentList values = array.getValues();
final int size = values.size();
if (size == 0) {
return null;
}
String[] replacements = new String[size];
for (int i = 0; i < size; i++) {
IValue element = values.get(i);
assert element.valueTag() == IValue.STRING;
replacements[i] = element.stringValue();
}
return replacements;
}
use of dyvilx.tools.compiler.ast.expression.ArrayExpr in project Dyvil by Dyvil.
the class ArgumentList method resolveMissing.
protected void resolveMissing(IParameter param, GenericData genericData, SourcePosition position, MarkerList markers, IContext context) {
if (this == EMPTY) {
// cannot infer missing arguments if the argument list is EMPTY (i.e. not denoted)
final Marker marker = Markers.semanticError(position, "method.access.argument.empty", param.getName());
marker.addInfo(Markers.getSemantic("method.access.argument.empty.info"));
markers.add(marker);
return;
}
if (param.isVarargs()) {
// varargs parameter
final IValue value = convertValue(new ArrayExpr(position, EMPTY), param, genericData, markers, context);
this.add(param.getLabel(), value);
return;
}
if (!param.isImplicit()) {
if (this.resolveDefault(param, context)) {
return;
}
markers.add(Markers.semanticError(position, "method.access.argument.missing", param.getName()));
return;
}
// implicit parameter, possibly default
final IType type;
if (genericData != null) {
genericData.lockAvailable();
type = param.getCovariantType().getConcreteType(genericData);
} else {
type = param.getCovariantType();
}
final IValue implicit = context.resolveImplicit(type);
if (implicit != null) {
// make sure to resolve and type-check the implicit value
// (implicit values should be only field accesses, but might need some capture or "this<Outer" resolution)
final IValue value = convertValue(implicit.resolve(markers, context), param, genericData, markers, context);
this.add(param.getLabel(), value);
return;
}
// default resolution only if implicit resolution fails
if (this.resolveDefault(param, context)) {
return;
}
markers.add(Markers.semanticError(position, "method.access.argument.implicit", param.getName(), type));
return;
}
Aggregations