Search in sources :

Example 16 with IValue

use of dyvilx.tools.compiler.ast.expression.IValue 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 17 with IValue

use of dyvilx.tools.compiler.ast.expression.IValue in project Dyvil by Dyvil.

the class SubscriptAccess method toCompoundAssignment.

@Override
public IValue toCompoundAssignment(IValue rhs, SourcePosition position, MarkerList markers, IContext context, SideEffectHelper helper) {
    // x[y...] (op)= z
    // -> x[y...] = x[y...] (op) z
    // note that x and y... are each only evaluated once
    final IValue subscriptReceiver = helper.processValue(this.receiver);
    final ArgumentList subscriptArguments = helper.processArguments(this.arguments);
    this.receiver = subscriptReceiver;
    this.arguments = subscriptArguments;
    return new SubscriptAssignment(position, subscriptReceiver, subscriptArguments, rhs).resolveCall(markers, context, true);
}
Also used : IValue(dyvilx.tools.compiler.ast.expression.IValue) ArgumentList(dyvilx.tools.compiler.ast.parameter.ArgumentList)

Example 18 with IValue

use of dyvilx.tools.compiler.ast.expression.IValue in project Dyvil by Dyvil.

the class Template method makeMainMethod.

private void makeMainMethod() {
    // func main(args: [String]) -> void = new TemplateName().mainImpl(args)
    final ParameterList params = this.mainMethod.getParameters();
    final CodeParameter argsParam = new CodeParameter(this.mainMethod, null, Name.fromRaw("args"), new ArrayType(Types.STRING));
    params.add(argsParam);
    final IValue newTemplate = new ConstructorCall(null, this.templateClass.getClassType(), ArgumentList.EMPTY);
    this.mainMethod.setValue(new MethodCall(null, newTemplate, Name.fromRaw("mainImpl"), new ArgumentList(new FieldAccess(argsParam))));
}
Also used : ArrayType(dyvilx.tools.compiler.ast.type.compound.ArrayType) IValue(dyvilx.tools.compiler.ast.expression.IValue) ParameterList(dyvilx.tools.compiler.ast.parameter.ParameterList) ConstructorCall(dyvilx.tools.compiler.ast.expression.access.ConstructorCall) ArgumentList(dyvilx.tools.compiler.ast.parameter.ArgumentList) FieldAccess(dyvilx.tools.compiler.ast.expression.access.FieldAccess) CodeParameter(dyvilx.tools.compiler.ast.parameter.CodeParameter) MethodCall(dyvilx.tools.compiler.ast.expression.access.MethodCall)

Example 19 with IValue

use of dyvilx.tools.compiler.ast.expression.IValue in project Dyvil by Dyvil.

the class Template method toString.

@Override
public void toString(@NonNull String indent, @NonNull StringBuilder buffer) {
    for (int i = 0; i < this.importCount; i++) {
        buffer.append(indent);
        appendImport(indent, buffer, this.importDeclarations[i]);
        buffer.append('\n');
    }
    final IValue directives = this.genMethod.getValue();
    if (!(directives instanceof StatementList)) {
        directives.toString(indent, buffer);
        return;
    }
    final StatementList statements = (StatementList) directives;
    for (int i = 0, count = statements.size(); i < count; i++) {
        statements.get(i).toString(indent, buffer);
        buffer.append('\n');
    }
}
Also used : IValue(dyvilx.tools.compiler.ast.expression.IValue) StatementList(dyvilx.tools.compiler.ast.statement.StatementList)

Example 20 with IValue

use of dyvilx.tools.compiler.ast.expression.IValue in project Dyvil by Dyvil.

the class ScopeDirective method toString.

@Override
public void toString(@NonNull String indent, @NonNull StringBuilder buffer) {
    buffer.append('#');
    final IValue value = this.getValue();
    if (value != null) {
        buffer.append('(');
        value.toString(indent, buffer);
        buffer.append(')');
        if (this.block != null) {
            buffer.append(' ');
        }
    }
    if (this.block != null) {
        this.block.toString(indent, buffer);
    }
}
Also used : IValue(dyvilx.tools.compiler.ast.expression.IValue)

Aggregations

IValue (dyvilx.tools.compiler.ast.expression.IValue)79 IType (dyvilx.tools.compiler.ast.type.IType)20 ArgumentList (dyvilx.tools.compiler.ast.parameter.ArgumentList)17 FieldAccess (dyvilx.tools.compiler.ast.expression.access.FieldAccess)11 SourcePosition (dyvil.source.position.SourcePosition)10 IParameter (dyvilx.tools.compiler.ast.parameter.IParameter)9 ArrayExpr (dyvilx.tools.compiler.ast.expression.ArrayExpr)7 Marker (dyvilx.tools.parsing.marker.Marker)7 IMethod (dyvilx.tools.compiler.ast.method.IMethod)6 AttributeList (dyvilx.tools.compiler.ast.attribute.AttributeList)5 IContext (dyvilx.tools.compiler.ast.context.IContext)5 MethodCall (dyvilx.tools.compiler.ast.expression.access.MethodCall)5 CodeParameter (dyvilx.tools.compiler.ast.parameter.CodeParameter)5 Annotation (dyvilx.tools.compiler.ast.attribute.annotation.Annotation)4 IClass (dyvilx.tools.compiler.ast.classes.IClass)4 Variable (dyvilx.tools.compiler.ast.field.Variable)4 ParameterList (dyvilx.tools.compiler.ast.parameter.ParameterList)4 CombiningContext (dyvilx.tools.compiler.ast.context.CombiningContext)3 IVariable (dyvilx.tools.compiler.ast.field.IVariable)3 CodeMethod (dyvilx.tools.compiler.ast.method.CodeMethod)3