Search in sources :

Example 6 with Parameter

use of com.redhat.ceylon.model.typechecker.model.Parameter in project ceylon-compiler by ceylon.

the class NamedArgumentInvocation method buildVars.

/**
     * Constructs the vars used in the Let expression
     */
private void buildVars() {
    if (getPrimaryDeclaration() == null) {
        return;
    }
    boolean prev = gen.expressionGen().withinInvocation(false);
    java.util.List<Tree.NamedArgument> namedArguments = namedArgumentList.getNamedArguments();
    SequencedArgument sequencedArgument = namedArgumentList.getSequencedArgument();
    java.util.List<ParameterList> paramLists = ((Functional) getPrimaryDeclaration()).getParameterLists();
    java.util.List<Parameter> declaredParams = paramLists.get(0).getParameters();
    appendVarsForNamedArguments(namedArguments, declaredParams);
    appendVarsForReifiedTypeArguments();
    if (sequencedArgument != null)
        appendVarsForSequencedArguments(sequencedArgument, declaredParams);
    boolean hasDefaulted = appendVarsForDefaulted(declaredParams);
    if (hasDefaulted && !Strategy.defaultParameterMethodStatic(getPrimaryDeclaration()) && !Strategy.defaultParameterMethodOnOuter(getPrimaryDeclaration())) {
        vars.prepend(makeThis());
    }
    gen.expressionGen().withinInvocation(prev);
}
Also used : Functional(com.redhat.ceylon.model.typechecker.model.Functional) ParameterList(com.redhat.ceylon.model.typechecker.model.ParameterList) Parameter(com.redhat.ceylon.model.typechecker.model.Parameter) SequencedArgument(com.redhat.ceylon.compiler.typechecker.tree.Tree.SequencedArgument)

Example 7 with Parameter

use of com.redhat.ceylon.model.typechecker.model.Parameter in project ceylon-compiler by ceylon.

the class AnnotationLoader method decode.

private AnnotationTerm decode(Module moduleScope, List<Parameter> sourceParameters, AnnotationInvocation info, Parameter parameter, AnnotatedMirror dpm, List<AnnotationFieldName> path, int code) {
    AnnotationTerm result;
    if (code == Short.MIN_VALUE) {
        return findLiteralAnnotationTerm(moduleScope, path, parameter, dpm);
    } else if (code < 0) {
        InvocationAnnotationTerm invocation = new InvocationAnnotationTerm();
        result = invocation;
    } else if (code >= 0 && code < 512) {
        ParameterAnnotationTerm parameterArgument = new ParameterAnnotationTerm();
        boolean spread = false;
        if (code >= 256) {
            spread = true;
            code -= 256;
        }
        parameterArgument.setSpread(spread);
        Parameter sourceParameter = sourceParameters.get(code);
        parameterArgument.setSourceParameter(sourceParameter);
        //result.setTargetParameter(sourceParameter);
        result = parameterArgument;
    } else {
        throw new RuntimeException();
    }
    return result;
}
Also used : ParameterAnnotationTerm(com.redhat.ceylon.compiler.java.codegen.ParameterAnnotationTerm) Parameter(com.redhat.ceylon.model.typechecker.model.Parameter) AnnotationConstructorParameter(com.redhat.ceylon.compiler.java.codegen.AnnotationConstructorParameter) InvocationAnnotationTerm(com.redhat.ceylon.compiler.java.codegen.InvocationAnnotationTerm) ObjectLiteralAnnotationTerm(com.redhat.ceylon.compiler.java.codegen.ObjectLiteralAnnotationTerm) CollectionLiteralAnnotationTerm(com.redhat.ceylon.compiler.java.codegen.CollectionLiteralAnnotationTerm) DeclarationLiteralAnnotationTerm(com.redhat.ceylon.compiler.java.codegen.DeclarationLiteralAnnotationTerm) StringLiteralAnnotationTerm(com.redhat.ceylon.compiler.java.codegen.StringLiteralAnnotationTerm) BooleanLiteralAnnotationTerm(com.redhat.ceylon.compiler.java.codegen.BooleanLiteralAnnotationTerm) CharacterLiteralAnnotationTerm(com.redhat.ceylon.compiler.java.codegen.CharacterLiteralAnnotationTerm) LiteralAnnotationTerm(com.redhat.ceylon.compiler.java.codegen.LiteralAnnotationTerm) ParameterAnnotationTerm(com.redhat.ceylon.compiler.java.codegen.ParameterAnnotationTerm) AnnotationTerm(com.redhat.ceylon.compiler.java.codegen.AnnotationTerm) InvocationAnnotationTerm(com.redhat.ceylon.compiler.java.codegen.InvocationAnnotationTerm) FloatLiteralAnnotationTerm(com.redhat.ceylon.compiler.java.codegen.FloatLiteralAnnotationTerm) IntegerLiteralAnnotationTerm(com.redhat.ceylon.compiler.java.codegen.IntegerLiteralAnnotationTerm)

Example 8 with Parameter

use of com.redhat.ceylon.model.typechecker.model.Parameter in project ceylon-compiler by ceylon.

the class UnknownTypeCollector method visit.

public void visit(Tree.BaseMemberOrTypeExpression that) {
    super.visit(that);
    Declaration declaration = that.getDeclaration();
    if (declaration == null)
        return;
    if (declaration instanceof Functional) {
        Functional m = (Functional) declaration;
        collectUnknownTypes(m.getType());
        for (ParameterList pl : m.getParameterLists()) {
            for (Parameter p : pl.getParameters()) {
                collectUnknownTypes(p.getType());
            }
        }
    } else if (declaration instanceof Value) {
        Value v = (Value) declaration;
        collectUnknownTypes(v.getType());
    }
}
Also used : Functional(com.redhat.ceylon.model.typechecker.model.Functional) Value(com.redhat.ceylon.model.typechecker.model.Value) ParameterList(com.redhat.ceylon.model.typechecker.model.ParameterList) Parameter(com.redhat.ceylon.model.typechecker.model.Parameter) Declaration(com.redhat.ceylon.model.typechecker.model.Declaration) TypeDeclaration(com.redhat.ceylon.model.typechecker.model.TypeDeclaration)

Example 9 with Parameter

use of com.redhat.ceylon.model.typechecker.model.Parameter in project ceylon-compiler by ceylon.

the class AbstractTransformer method getTypedSignature.

private java.util.List<Type> getTypedSignature(Type currentType, TypedDeclaration found) {
    // check that its signature is compatible
    java.util.List<ParameterList> parameterLists = ((Function) found).getParameterLists();
    if (parameterLists == null || parameterLists.isEmpty())
        return null;
    // only consider first param list
    java.util.List<Parameter> parameters = parameterLists.get(0).getParameters();
    if (parameters == null)
        return null;
    TypedReference typedMember = currentType.getTypedMember(found, Collections.<Type>emptyList());
    if (typedMember == null)
        return null;
    java.util.List<Type> typedSignature = new ArrayList<Type>(parameters.size());
    for (Parameter p : parameters) {
        Type parameterType = typedMember.getTypedParameter(p).getFullType();
        typedSignature.add(parameterType);
    }
    return typedSignature;
}
Also used : Function(com.redhat.ceylon.model.typechecker.model.Function) Type(com.redhat.ceylon.model.typechecker.model.Type) ModelUtil.appliedType(com.redhat.ceylon.model.typechecker.model.ModelUtil.appliedType) TypedReference(com.redhat.ceylon.model.typechecker.model.TypedReference) ArrayList(java.util.ArrayList) ParameterList(com.redhat.ceylon.model.typechecker.model.ParameterList) TypeParameter(com.redhat.ceylon.model.typechecker.model.TypeParameter) JCTypeParameter(com.sun.tools.javac.tree.JCTree.JCTypeParameter) Parameter(com.redhat.ceylon.model.typechecker.model.Parameter)

Example 10 with Parameter

use of com.redhat.ceylon.model.typechecker.model.Parameter in project ceylon-compiler by ceylon.

the class ClassTransformer method makeAnnotationMethod.

private MethodDefinitionBuilder makeAnnotationMethod(Tree.Parameter parameter) {
    Parameter parameterModel = parameter.getParameterModel();
    JCExpression type = transformAnnotationMethodType(parameter);
    JCExpression defaultValue = parameterModel.isDefaulted() ? transformAnnotationParameterDefault(parameter) : null;
    MethodDefinitionBuilder mdb = MethodDefinitionBuilder.method(this, parameterModel.getModel(), Naming.NA_ANNOTATION_MEMBER);
    if (isMetamodelReference(parameterModel.getType()) || (typeFact().isIterableType(parameterModel.getType()) && isMetamodelReference(typeFact().getIteratedType(parameterModel.getType())))) {
        mdb.modelAnnotations(List.of(make().Annotation(make().Type(syms().ceylonAtDeclarationReferenceType), List.<JCExpression>nil())));
    } else if (Decl.isEnumeratedTypeWithAnonCases(parameterModel.getType()) || (typeFact().isIterableType(parameterModel.getType()) && Decl.isEnumeratedTypeWithAnonCases(typeFact().getIteratedType(parameterModel.getType())))) {
        mdb.modelAnnotations(List.of(make().Annotation(make().Type(syms().ceylonAtEnumerationReferenceType), List.<JCExpression>nil())));
    }
    mdb.modifiers(PUBLIC | ABSTRACT);
    mdb.resultType(null, type);
    mdb.defaultValue(defaultValue);
    mdb.noBody();
    return mdb;
}
Also used : JCExpression(com.sun.tools.javac.tree.JCTree.JCExpression) TypeParameter(com.redhat.ceylon.model.typechecker.model.TypeParameter) Parameter(com.redhat.ceylon.model.typechecker.model.Parameter)

Aggregations

Parameter (com.redhat.ceylon.model.typechecker.model.Parameter)56 TypeParameter (com.redhat.ceylon.model.typechecker.model.TypeParameter)40 JCExpression (com.sun.tools.javac.tree.JCTree.JCExpression)25 Type (com.redhat.ceylon.model.typechecker.model.Type)24 Function (com.redhat.ceylon.model.typechecker.model.Function)19 ParameterList (com.redhat.ceylon.model.typechecker.model.ParameterList)18 Tree (com.redhat.ceylon.compiler.typechecker.tree.Tree)17 JCTree (com.sun.tools.javac.tree.JCTree)15 Class (com.redhat.ceylon.model.typechecker.model.Class)14 ArrayList (java.util.ArrayList)14 FunctionOrValue (com.redhat.ceylon.model.typechecker.model.FunctionOrValue)13 JCNewClass (com.sun.tools.javac.tree.JCTree.JCNewClass)13 TypeDeclaration (com.redhat.ceylon.model.typechecker.model.TypeDeclaration)12 Value (com.redhat.ceylon.model.typechecker.model.Value)12 Declaration (com.redhat.ceylon.model.typechecker.model.Declaration)11 TypedDeclaration (com.redhat.ceylon.model.typechecker.model.TypedDeclaration)11 TypedReference (com.redhat.ceylon.model.typechecker.model.TypedReference)11 JCStatement (com.sun.tools.javac.tree.JCTree.JCStatement)10 JCPrimitiveTypeTree (com.sun.tools.javac.tree.JCTree.JCPrimitiveTypeTree)9 JCTypeParameter (com.sun.tools.javac.tree.JCTree.JCTypeParameter)9