use of dyvilx.tools.compiler.ast.classes.IClass in project Dyvil by Dyvil.
the class ConstructorCall method check.
@Override
public void check(MarkerList markers, IContext context) {
this.type.check(markers, context);
this.arguments.check(markers, context);
if (this.type.hasTag(IType.ARRAY)) {
return;
}
if (this.constructor != null) {
final IClass iclass = this.type.getTheClass();
if (iclass.isInterface()) {
markers.add(Markers.semanticError(this.position, "constructor.access.abstract", this.type));
}
this.constructor.checkCall(markers, this.position, context, this.arguments);
}
}
use of dyvilx.tools.compiler.ast.classes.IClass in project Dyvil by Dyvil.
the class CodeTypeParameter method resolveTypes.
@Override
public void resolveTypes(MarkerList markers, IContext context) {
this.attributes.resolveTypes(markers, context, this);
if (this.lowerBound != null) {
this.lowerBound = this.lowerBound.resolveType(markers, context);
}
this.upperBound = this.upperBound.resolveType(markers, context);
this.upperBounds = getUpperBounds(this.upperBound);
// The first upper bound is meant to be a class bound.
IType type = this.upperBounds[0];
IClass typeClass = type.getTheClass();
if (typeClass != null && !typeClass.isInterface()) {
// If the first type is a class type (not an interface), it becomes the erasure type.
this.erasure = type;
}
// Check if the remaining upper bounds are interfaces
for (int i = 1, count = this.upperBounds.length; i < count; i++) {
type = this.upperBounds[i];
typeClass = type.getTheClass();
if (typeClass != null && !typeClass.isInterface()) {
final Marker marker = Markers.semanticError(type.getPosition(), "type_parameter.bound.class");
marker.addInfo(Markers.getSemantic("class.declaration", Util.classSignatureToString(typeClass)));
markers.add(marker);
}
}
}
use of dyvilx.tools.compiler.ast.classes.IClass in project Dyvil by Dyvil.
the class ConstructorCallParser method parseBody.
/**
* Creates the body and initializes parsing for anonymous classes.
*
* @param pm
* the current parsing context manager.
*/
private void parseBody(IParserManager pm) {
final ClassConstructorCall classConstructorCall = this.call.toClassConstructor();
this.call = classConstructorCall;
final IClass nestedClass = classConstructorCall.getNestedClass();
final ClassBody body = nestedClass.getBody();
pm.pushParser(new ClassBodyParser(body), true);
this.mode = ANONYMOUS_CLASS_END;
}
use of dyvilx.tools.compiler.ast.classes.IClass in project Dyvil by Dyvil.
the class AnnotationExpr method writeExpression.
@Override
public void writeExpression(MethodWriter writer, IType type) throws BytecodeException {
final StringBuilder descBuilder = new StringBuilder().append('(');
final ArgumentList arguments = this.annotation.getArguments();
final IClass iclass = this.annotation.getType().getTheClass();
final ParameterList parameterList = iclass.getParameters();
final int count = parameterList.size();
String[] parameterNames = new String[count];
for (int i = 0; i < count; i++) {
final IParameter parameter = parameterList.get(i);
final IType parameterType = parameter.getType();
parameterNames[i] = parameter.getInternalName();
parameterType.appendExtendedName(descBuilder);
arguments.writeValue(i, parameter, writer);
}
descBuilder.append(')');
descBuilder.append('L').append(iclass.getInternalName()).append(';');
writer.visitInvokeDynamicInsn("_", descBuilder.toString(), ANNOTATION_METAFACTORY, (Object[]) parameterNames);
if (type != null) {
this.annotation.getType().writeCast(writer, type, this.lineNumber());
}
}
use of dyvilx.tools.compiler.ast.classes.IClass 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