Search in sources :

Example 6 with IMethod

use of dyvilx.tools.compiler.ast.method.IMethod in project Dyvil by Dyvil.

the class Property method formatBody.

public static void formatBody(IProperty property, String prefix, StringBuilder buffer) {
    // Block Start
    if (Formatting.getBoolean("property.block.newline")) {
        buffer.append('\n').append(prefix);
    } else {
        buffer.append(' ');
    }
    buffer.append('{');
    // Initializer
    final IValue initializer = property.getInitializer();
    final IMethod getter = property.getGetter();
    final IMethod setter = property.getSetter();
    if (initializer != null) {
        formatInitializer(initializer, prefix, buffer);
        if (getter != null || setter != null) {
            buffer.append('\n').append(prefix);
        }
    }
    // Getter
    if (getter != null) {
        formatGetter(getter, prefix, buffer);
        if (setter != null) {
            buffer.append('\n').append(prefix);
        }
    }
    // Setter
    if (setter != null) {
        formatSetter(setter, prefix, buffer);
    }
    // Block End
    buffer.append('\n').append(prefix).append('}');
}
Also used : IValue(dyvilx.tools.compiler.ast.expression.IValue) IMethod(dyvilx.tools.compiler.ast.method.IMethod)

Example 7 with IMethod

use of dyvilx.tools.compiler.ast.method.IMethod in project Dyvil by Dyvil.

the class AbstractCall method addCandidateInfo.

private void addCandidateInfo(Marker marker, Candidate<IMethod> candidate) {
    final StringBuilder builder = new StringBuilder().append('\t');
    final IMethod member = candidate.getMember();
    builder.append(member.getReceiverType()).append(member.isStatic() ? '.' : '#');
    Util.methodSignatureToString(member, this.genericData, builder);
    marker.addInfo(builder.toString());
}
Also used : IMethod(dyvilx.tools.compiler.ast.method.IMethod)

Example 8 with IMethod

use of dyvilx.tools.compiler.ast.method.IMethod in project Dyvil by Dyvil.

the class PrefixCall method resolveCall.

@Override
public IValue resolveCall(MarkerList markers, IContext context, boolean report) {
    // Normal Method Resolution
    final MatchList<IMethod> candidates = this.resolveCandidates(context);
    if (candidates.hasCandidate()) {
        return this.checkArguments(markers, context, candidates.getBestMember());
    }
    // Implicit Resolution
    final IValue implicitCall = this.resolveImplicitCall(markers, context);
    if (implicitCall != null) {
        return implicitCall;
    }
    // No apply Resolution
    if (report) {
        this.reportResolve(markers, candidates);
        return this;
    }
    return null;
}
Also used : IValue(dyvilx.tools.compiler.ast.expression.IValue) IMethod(dyvilx.tools.compiler.ast.method.IMethod)

Example 9 with IMethod

use of dyvilx.tools.compiler.ast.method.IMethod in project Dyvil by Dyvil.

the class TypeChecker method convertValueDirect.

private static IValue convertValueDirect(IValue value, IType type, ITypeContext typeContext, MarkerList markers, IContext context) {
    final IValue typedValue = value.withType(type, typeContext, markers, context);
    if (typedValue != null) {
        return typedValue;
    }
    final IValue converted1 = type.convertFrom(value, value.getType(), typeContext, markers, context);
    if (converted1 != null) {
        return converted1;
    }
    final IValue converted2 = value.getType().convertTo(value, type, typeContext, markers, context);
    if (converted2 != null) {
        return converted2;
    }
    final IMethod converter = IContext.resolveImplicits(context, value, type).getBestMember();
    if (converter == null) {
        return null;
    }
    return new LiteralConversion(value, converter);
}
Also used : IValue(dyvilx.tools.compiler.ast.expression.IValue) LiteralConversion(dyvilx.tools.compiler.ast.expression.LiteralConversion) IMethod(dyvilx.tools.compiler.ast.method.IMethod)

Example 10 with IMethod

use of dyvilx.tools.compiler.ast.method.IMethod in project Dyvil by Dyvil.

the class InterfaceMetadata method processProperty.

protected void processProperty(IProperty property, MarkerList markers) {
    this.processMember(property, markers);
    final IMethod getter = property.getGetter();
    if (getter != null) {
        this.processMethod(getter, markers);
    }
    final IMethod setter = property.getSetter();
    if (setter != null) {
        this.processMethod(setter, markers);
    }
    final SourcePosition initializerPosition = property.getInitializerPosition();
    if (initializerPosition != null) {
        this.processPropertyInitializer(initializerPosition, markers);
    }
}
Also used : SourcePosition(dyvil.source.position.SourcePosition) IMethod(dyvilx.tools.compiler.ast.method.IMethod)

Aggregations

IMethod (dyvilx.tools.compiler.ast.method.IMethod)31 IValue (dyvilx.tools.compiler.ast.expression.IValue)6 IField (dyvilx.tools.compiler.ast.field.IField)4 IProperty (dyvilx.tools.compiler.ast.field.IProperty)4 IType (dyvilx.tools.compiler.ast.type.IType)3 TreeSet (dyvil.collection.mutable.TreeSet)2 Name (dyvil.lang.Name)2 SourcePosition (dyvil.source.position.SourcePosition)2 IContext (dyvilx.tools.compiler.ast.context.IContext)2 FieldAccess (dyvilx.tools.compiler.ast.expression.access.FieldAccess)2 IImportContext (dyvilx.tools.compiler.ast.imports.IImportContext)2 ImportDeclaration (dyvilx.tools.compiler.ast.imports.ImportDeclaration)2 MatchList (dyvilx.tools.compiler.ast.method.MatchList)2 IParameter (dyvilx.tools.compiler.ast.parameter.IParameter)2 PrintStream (java.io.PrintStream)2 ClassBody (dyvilx.tools.compiler.ast.classes.ClassBody)1 IClass (dyvilx.tools.compiler.ast.classes.IClass)1 IConstructor (dyvilx.tools.compiler.ast.constructor.IConstructor)1 CombiningContext (dyvilx.tools.compiler.ast.context.CombiningContext)1 IImplicitContext (dyvilx.tools.compiler.ast.context.IImplicitContext)1