Search in sources :

Example 1 with IClassMember

use of dyvilx.tools.compiler.ast.member.IClassMember 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);
}
Also used : MemberKind(dyvilx.tools.compiler.ast.member.MemberKind) IMethod(dyvilx.tools.compiler.ast.method.IMethod) IClassMember(dyvilx.tools.compiler.ast.member.IClassMember) Name(dyvil.lang.Name)

Aggregations

Name (dyvil.lang.Name)1 IClassMember (dyvilx.tools.compiler.ast.member.IClassMember)1 MemberKind (dyvilx.tools.compiler.ast.member.MemberKind)1 IMethod (dyvilx.tools.compiler.ast.method.IMethod)1