use of dyvilx.tools.compiler.ast.method.IMethod in project Dyvil by Dyvil.
the class AbstractClass method addMethods.
private static void addMethods(Collection<IMethod> methods, IProperty property) {
final IMethod getter = property.getGetter();
if (getter != null) {
methods.add(getter);
}
final IMethod setter = property.getSetter();
if (setter != null) {
methods.add(setter);
}
}
use of dyvilx.tools.compiler.ast.method.IMethod in project Dyvil by Dyvil.
the class ClassBody method checkProperty.
public static void checkProperty(IProperty property, MarkerList markers, IClass checkedClass, ITypeContext typeContext) {
final IMethod getter = property.getGetter();
if (getter != null) {
checkMethod(getter, markers, checkedClass, typeContext);
}
final IMethod setter = property.getSetter();
if (setter != null) {
checkMethod(setter, markers, checkedClass, typeContext);
}
}
use of dyvilx.tools.compiler.ast.method.IMethod in project Dyvil by Dyvil.
the class CodeClass method checkFunctional.
public void checkFunctional(MarkerList markers) {
final boolean hasAnnotation = this.hasModifier(Modifiers.FUNCTIONAL);
if (hasAnnotation && !this.isInterface()) {
// FunctionalInterface annotation on class or object
markers.add(Markers.semanticError(this.position, "interface.functional.class"));
return;
}
if (this.body == null) {
if (hasAnnotation) {
// No abstract method
markers.add(Markers.semanticError(this.position, "interface.functional.not_found", this.name));
}
return;
}
// Partial copy in ExternalClass.getFunctionalMethod
IMethod functionalMethod = null;
for (IMethod method : this.body.allMethods()) {
if (!method.isFunctional()) {
continue;
}
if (functionalMethod == null) {
functionalMethod = method;
continue;
}
if (!hasAnnotation) {
return;
}
// Multiple abstract methods
markers.add(Markers.semanticError(this.position, "interface.functional.multiple", this.name));
return;
}
if (functionalMethod != null) {
this.metadata.setFunctionalMethod(functionalMethod);
return;
}
if (hasAnnotation) {
// No abstract method
markers.add(Markers.semanticError(this.position, "interface.functional.not_found", this.name));
}
}
use of dyvilx.tools.compiler.ast.method.IMethod in project Dyvil by Dyvil.
the class HeaderContext method getImplicitMatches.
@Override
public void getImplicitMatches(MatchList<IMethod> list, IValue value, IType targetType) {
// See comment in getMethodMatches for rationale
this.header.getImplicitMatches(list, value, targetType);
if (list.hasCandidate()) {
return;
}
final ImportDeclaration[] imports = this.header.importDeclarations;
for (int i = 0; i < this.header.importCount; i++) {
final IImportContext importContext = imports[i].getContext();
final MatchList<IMethod> subList = list.emptyCopy();
importContext.getImplicitMatches(subList, value, targetType);
list.addAll(subList);
}
}
use of dyvilx.tools.compiler.ast.method.IMethod in project Dyvil by Dyvil.
the class StatementList method addMethod.
protected void addMethod(MemberStatement memberStatement, MarkerList markers) {
final IClassMember member = memberStatement.member;
final MemberKind memberKind = member.getKind();
if (memberKind != MemberKind.METHOD) {
markers.add(Markers.semantic(member.getPosition(), "statementlist.declaration.invalid", Util.memberNamed(member)));
return;
}
final IMethod method = (IMethod) member;
if (this.methods == null) {
this.methods = new ArrayList<>();
this.methods.add(method);
return;
}
final Name methodName = method.getName();
final int parameterCount = method.getParameters().size();
final String desc = method.getDescriptor();
for (IMethod candidate : this.methods) {
if (// same name
candidate.getName() == methodName && candidate.getParameters().size() == parameterCount && candidate.getDescriptor().equals(desc)) {
markers.add(Markers.semanticError(memberStatement.getPosition(), "method.duplicate", methodName, desc));
}
}
this.methods.add(method);
}
Aggregations