Search in sources :

Example 6 with ArgumentList

use of dyvilx.tools.compiler.ast.parameter.ArgumentList 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 7 with ArgumentList

use of dyvilx.tools.compiler.ast.parameter.ArgumentList 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 8 with ArgumentList

use of dyvilx.tools.compiler.ast.parameter.ArgumentList in project Dyvil by Dyvil.

the class Deprecation method checkUsageInfo.

private static void checkUsageInfo(IMember member, SourcePosition position, MarkerList markers, Annotation annotation) {
    final ArgumentList arguments = annotation.getArguments();
    final MarkerLevel markerLevel = AnnotationUtil.getEnumValue(arguments, INF_LEVEL_PARAM, MarkerLevel.class);
    if (markerLevel == null || markerLevel == MarkerLevel.IGNORE) {
        return;
    }
    String value = AnnotationUtil.getStringValue(arguments, INF_VALUE_PARAM);
    final String description = AnnotationUtil.getStringValue(arguments, INF_DESC_PARAM);
    value = replaceMember(member, value);
    final Marker marker = Markers.withText(position, markerLevel, value);
    assert marker != null;
    // Description
    if (description != null && !description.isEmpty()) {
        marker.addInfo(Markers.getSemantic("experimental.description", description));
    }
    markers.add(marker);
}
Also used : MarkerLevel(dyvil.util.MarkerLevel) Marker(dyvilx.tools.parsing.marker.Marker) ArgumentList(dyvilx.tools.compiler.ast.parameter.ArgumentList)

Example 9 with ArgumentList

use of dyvilx.tools.compiler.ast.parameter.ArgumentList in project Dyvil by Dyvil.

the class SideEffectHelper method processArguments.

public ArgumentList processArguments(ArgumentList arguments) {
    final ArgumentList copy = arguments.copy();
    for (int i = 0, count = arguments.size(); i < count; i++) {
        final IValue value = arguments.get(i, null);
        copy.set(i, null, this.processValue(value));
    }
    return copy;
}
Also used : IValue(dyvilx.tools.compiler.ast.expression.IValue) ArgumentList(dyvilx.tools.compiler.ast.parameter.ArgumentList)

Example 10 with ArgumentList

use of dyvilx.tools.compiler.ast.parameter.ArgumentList in project Dyvil by Dyvil.

the class AnnotationMetadata method readTargets.

private void readTargets() {
    final Annotation target = this.theClass.getAnnotation(Annotation.LazyFields.TARGET_CLASS);
    if (target == null) {
        return;
    }
    this.targets = EnumSet.noneOf(ElementType.class);
    final IValue argument = target.getArguments().get(0, Names.value);
    if (!(argument instanceof ArrayExpr)) {
        return;
    }
    final ArgumentList values = ((ArrayExpr) argument).getValues();
    final int size = values.size();
    for (int i = 0; i < size; i++) {
        final INamed value = (INamed) values.get(i);
        try {
            this.targets.add(ElementType.valueOf(value.getName().qualified));
        } catch (IllegalArgumentException ignored) {
        // Problematic Target annotation - do not handle this
        }
    }
}
Also used : ElementType(java.lang.annotation.ElementType) ArrayExpr(dyvilx.tools.compiler.ast.expression.ArrayExpr) IValue(dyvilx.tools.compiler.ast.expression.IValue) INamed(dyvilx.tools.compiler.ast.member.INamed) ArgumentList(dyvilx.tools.compiler.ast.parameter.ArgumentList) Annotation(dyvilx.tools.compiler.ast.attribute.annotation.Annotation)

Aggregations

ArgumentList (dyvilx.tools.compiler.ast.parameter.ArgumentList)37 IValue (dyvilx.tools.compiler.ast.expression.IValue)17 IType (dyvilx.tools.compiler.ast.type.IType)10 SourcePosition (dyvil.source.position.SourcePosition)8 CodeParameter (dyvilx.tools.compiler.ast.parameter.CodeParameter)7 AttributeList (dyvilx.tools.compiler.ast.attribute.AttributeList)5 ArrayExpr (dyvilx.tools.compiler.ast.expression.ArrayExpr)5 FieldAccess (dyvilx.tools.compiler.ast.expression.access.FieldAccess)5 CodeMethod (dyvilx.tools.compiler.ast.method.CodeMethod)5 IParameter (dyvilx.tools.compiler.ast.parameter.IParameter)5 Annotation (dyvilx.tools.compiler.ast.attribute.annotation.Annotation)4 ConstructorCall (dyvilx.tools.compiler.ast.expression.access.ConstructorCall)4 MarkerLevel (dyvil.util.MarkerLevel)3 MethodCall (dyvilx.tools.compiler.ast.expression.access.MethodCall)3 StringValue (dyvilx.tools.compiler.ast.expression.constant.StringValue)3 ParameterList (dyvilx.tools.compiler.ast.parameter.ParameterList)3 Marker (dyvilx.tools.parsing.marker.Marker)3 Reason (dyvil.annotation.Deprecated.Reason)2 Name (dyvil.lang.Name)2 IClass (dyvilx.tools.compiler.ast.classes.IClass)2