use of dyvilx.tools.compiler.ast.type.IType in project Dyvil by Dyvil.
the class AbstractConstructor method checkMatch.
@Override
public void checkMatch(MatchList<IConstructor> list, ArgumentList arguments) {
final int parameterCount = this.parameters.size();
if (arguments == null) {
list.add(new Candidate<>(this));
return;
}
final int argumentCount = arguments.size();
if (argumentCount > parameterCount && !this.isVariadic()) {
return;
}
final int[] matchValues = new int[argumentCount];
final IType[] matchTypes = new IType[argumentCount];
int defaults = 0;
int varargs = 0;
for (int i = 0; i < parameterCount; i++) {
final IParameter parameter = this.parameters.get(i);
final int partialVarargs = arguments.checkMatch(matchValues, matchTypes, 0, i, parameter, list);
switch(partialVarargs) {
case ArgumentList.MISMATCH:
return;
case ArgumentList.DEFAULT:
defaults++;
continue;
default:
varargs += partialVarargs;
}
}
for (int matchValue : matchValues) {
if (matchValue == IValue.MISMATCH) {
return;
}
}
list.add(new Candidate<>(this, matchValues, matchTypes, defaults, varargs));
}
use of dyvilx.tools.compiler.ast.type.IType in project Dyvil by Dyvil.
the class CodeConstructor method resolveInitCall.
private void resolveInitCall(MarkerList markers, IContext context) {
if (this.initializerCall != null) {
this.initializerCall.resolve(markers, context);
return;
}
// No Super Type -> don't try to resolve a Super Constructor
final IType superType = this.enclosingClass.getSuperType();
if (superType == null) {
return;
}
// Implicit Super Constructor
final IConstructor match = IContext.resolveConstructor(context, superType, ArgumentList.EMPTY);
if (match == null) {
markers.add(Markers.semanticError(this.position, "constructor.super"));
return;
}
this.initializerCall = new InitializerCall(this.position, true, ArgumentList.EMPTY, superType, match);
}
use of dyvilx.tools.compiler.ast.type.IType in project Dyvil by Dyvil.
the class CodeConstructor method check.
@Override
public void check(MarkerList markers, IContext context) {
context = context.push(this);
super.check(markers, context);
this.parameters.check(markers, context);
if (this.exceptions != null) {
for (int i = 0; i < this.exceptions.size(); i++) {
final IType exceptionType = this.exceptions.get(i);
exceptionType.check(markers, context);
if (!Types.isSuperType(Types.THROWABLE, exceptionType)) {
final Marker marker = Markers.semanticError(exceptionType.getPosition(), "method.exception.type");
marker.addInfo(Markers.getSemantic("exception.type", exceptionType));
markers.add(marker);
}
}
}
if (this.initializerCall != null) {
this.initializerCall.check(markers, context);
}
if (this.value != null) {
this.value.check(markers, this);
} else if (this.initializerCall == null) {
markers.add(Markers.semanticError(this.position, "constructor.abstract"));
}
if (this.isStatic()) {
markers.add(Markers.semanticError(this.position, "constructor.static", this.name));
}
context.pop();
}
use of dyvilx.tools.compiler.ast.type.IType in project Dyvil by Dyvil.
the class AttributeList method resolveTypes.
// Phases
public void resolveTypes(MarkerList markers, IContext context, Attributable annotated) {
for (int i = 0; i < this.size; i++) {
final Attribute attribute = this.data[i];
attribute.resolveTypes(markers, context);
final IType type = attribute.getType();
if (type != null) {
final String internalName = type.getInternalName();
if (internalName != null && annotated.skipAnnotation(internalName, (Annotation) attribute)) {
this.removeAt(i--);
}
}
}
}
use of dyvilx.tools.compiler.ast.type.IType in project Dyvil by Dyvil.
the class Annotation method resolve.
@Override
public void resolve(MarkerList markers, IContext context) {
this.arguments.resolve(markers, context);
final IClass theClass;
if (this.type == null || (theClass = this.type.getTheClass()) == null) {
return;
}
final ParameterList parameterList = theClass.getParameters();
for (int i = 0, count = parameterList.size(); i < count; i++) {
final IParameter parameter = parameterList.get(i);
final IType parameterType = parameter.getType();
final IValue value = this.arguments.get(parameter);
if (value == null) {
if (parameter.getValue() == null) {
markers.add(Markers.semanticError(this.getPosition(), "annotation.parameter.missing", this.type, parameter.getName()));
}
continue;
}
IValue typedValue = value.withType(parameterType, parameterType, markers, context);
if (typedValue == null) {
markers.add(TypeChecker.typeError(value, parameterType, parameterType, "annotation.parameter.type", parameter.getName()));
continue;
}
typedValue = IValue.toAnnotationConstant(typedValue, markers, context);
if (typedValue != value) {
this.arguments.set(i, parameter.getLabel(), typedValue);
}
}
}
Aggregations