Package com.redhat.ceylon.compiler.typechecker.model

Examples of com.redhat.ceylon.compiler.typechecker.model.Value


        this.prefix = prefix;
    }

    @Override
    public void visit(Tree.AttributeGetterDefinition that){
        Value model = that.getDeclarationModel();
        collect(that, model);
        // stop at locals, who get a type generated for them
        if(model.isMember())
            super.visit(that);
    }
View Full Code Here


            collect(that, model);
    }

    @Override
    public void visit(Tree.ObjectDefinition that){
        Value model = that.getDeclarationModel();
        if(model != null)
            collect(that, model.getTypeDeclaration());
    }
View Full Code Here

            collect(that, model.getTypeDeclaration());
    }

    @Override
    public void visit(Tree.ObjectArgument that){
        Value model = that.getDeclarationModel();
        if(model != null)
            collect(that, model.getTypeDeclaration());
    }
View Full Code Here

                        List.<JCTree.JCVariableDecl>nil(), List.<JCExpression>nil(), body, null));
            }
            if (fcl.getForIterator() instanceof Tree.ValueIterator) {
   
                //Add the item variable as a field in the iterator
                Value item = ((Tree.ValueIterator)fcl.getForIterator()).getVariable().getDeclarationModel();
                itemVar = naming.synthetic(item);
                valueCaptures.append(makeVar(Flags.FINAL, itemVar,
                        makeJavaType(item.getType(),JT_NO_PRIMITIVES), itemVar.makeIdentWithThis()));
                fields.add(make().VarDef(make().Modifiers(Flags.PRIVATE), itemVar.asName(),
                        makeJavaType(item.getType(),JT_NO_PRIMITIVES), null));
                fieldNames.add(itemVar.getName());
   
            } else if (fcl.getForIterator() instanceof Tree.KeyValueIterator) {
                //Add the key and value variables as fields in the iterator
                Tree.KeyValueIterator kviter = (Tree.KeyValueIterator)fcl.getForIterator();
                Value kdec = kviter.getKeyVariable().getDeclarationModel();
                Value vdec = kviter.getValueVariable().getDeclarationModel();
                //But we'll use this as the name for the context function and base for the exhausted field
                itemVar = naming.synthetic(Prefix.$kv$, kdec.getName(), vdec.getName());
                fields.add(make().VarDef(make().Modifiers(Flags.PRIVATE), names().fromString(kdec.getName()),
                        makeJavaType(kdec.getType(), JT_NO_PRIMITIVES), null));
                fields.add(make().VarDef(make().Modifiers(Flags.PRIVATE), names().fromString(vdec.getName()),
                        makeJavaType(vdec.getType(), JT_NO_PRIMITIVES), null));
                fieldNames.add(kdec.getName());
                fieldNames.add(vdec.getName());
            } else {
                error = makeErroneous(fcl, "compiler bug: iterators of type " + fcl.getForIterator().getNodeType() + " not yet supported");
                return null;
            }
            fields.add(make().VarDef(make().Modifiers(Flags.PRIVATE), itemVar.suffixedBy(Suffix.$exhausted$).asName(),
                    makeJavaType(typeFact().getBooleanDeclaration().getType()), null));
           
            //Now the context for this iterator
            ListBuffer<JCStatement> contextBody = new ListBuffer<JCStatement>();
   
            //Assign the next item to an Object variable
            Naming.SyntheticName tmpItem = naming.temp("item");
            contextBody.add(make().VarDef(make().Modifiers(Flags.FINAL), tmpItem.asName(),
                    makeJavaType(typeFact().getObjectDeclaration().getType()),
                    make().Apply(null, makeSelect(iterVar.makeIdent(), "next"),
                            List.<JCExpression>nil())));
            //Then we check if it's exhausted
            contextBody.add(make().Exec(make().Assign(itemVar.suffixedBy(Suffix.$exhausted$).makeIdent(),
                    make().Binary(JCTree.EQ, tmpItem.makeIdent(), makeFinished()))));
            //Variables get assigned in the else block
            ListBuffer<JCStatement> elseBody = new ListBuffer<JCStatement>();
            if (fcl.getForIterator() instanceof Tree.ValueIterator) {
                ProducedType itemType = ((Tree.ValueIterator)fcl.getForIterator()).getVariable().getDeclarationModel().getType();
                elseBody.add(make().Exec(make().Assign(itemVar.makeIdent(),
                        make().TypeCast(makeJavaType(itemType,JT_NO_PRIMITIVES), tmpItem.makeIdent()))));
            } else {
                Tree.KeyValueIterator kviter = (Tree.KeyValueIterator)fcl.getForIterator();
                Value key = kviter.getKeyVariable().getDeclarationModel();
                Value item = kviter.getValueVariable().getDeclarationModel();
                //Assign the key and item to the corresponding fields with the proper type casts
                //equivalent to k=(KeyType)((Entry<KeyType,ItemType>)tmpItem).getKey()
                JCExpression castEntryExprKey = make().TypeCast(
                    makeJavaType(typeFact().getIteratedType(iterType)),
                    tmpItem.makeIdent());
                SyntheticName keyName = naming.synthetic(key);
                SyntheticName itemName = naming.synthetic(item);
                valueCaptures.append(makeVar(Flags.FINAL, keyName,
                        makeJavaType(key.getType(), JT_NO_PRIMITIVES),
                        keyName.makeIdentWithThis()));
                valueCaptures.append(makeVar(Flags.FINAL, itemName,
                        makeJavaType(item.getType(), JT_NO_PRIMITIVES),
                        itemName.makeIdentWithThis()));
                elseBody.add(make().Exec(make().Assign(keyName.makeIdent(),
                    make().TypeCast(makeJavaType(key.getType(), JT_NO_PRIMITIVES),
                        make().Apply(null, makeSelect(castEntryExprKey, "getKey"),
                            List.<JCExpression>nil())
                ))));
                //equivalent to v=(ItemType)((Entry<KeyType,ItemType>)tmpItem).getItem()
                JCExpression castEntryExprItem = make().TypeCast(
                        makeJavaType(typeFact().getIteratedType(iterType)),
                        tmpItem.makeIdent());
                elseBody.add(make().Exec(make().Assign(itemName.makeIdent(),
                    make().TypeCast(makeJavaType(item.getType(), JT_NO_PRIMITIVES),
                        make().Apply(null, makeSelect(castEntryExprItem, "getItem"),
                            List.<JCExpression>nil())
                ))));
            }
            elseBody.add(make().Return(makeBoolean(true)));
View Full Code Here

                if (ctor.getAnnotationConstructor() != null) {
                    instantiation.getConstructorParameters().addAll(((AnnotationInvocation)ctor.getAnnotationConstructor()).getConstructorParameters());
                }
            } else if (checkingArguments || checkingDefaults) {
                if (declaration instanceof Value && ((Value)declaration).isParameter()) {
                    Value constructorParameter = (Value)declaration;
                    ParameterAnnotationTerm a = new ParameterAnnotationTerm();
                    a.setSpread(spread);
                    // XXX Is this right?
                    a.setSourceParameter(constructorParameter.getInitializerParameter());
                    this.term = a;
                } else if (isBooleanTrue(declaration)) {
                    LiteralAnnotationTerm argument = new BooleanLiteralAnnotationTerm(true);
                    appendLiteralArgument(bme, argument);
                } else if (isBooleanFalse(declaration)) {
View Full Code Here

    }

    private JCExpression transformJavaStaticMember(Tree.QualifiedMemberOrTypeExpression qmte, ProducedType staticType) {
        Declaration decl = qmte.getDeclaration();
        if (decl instanceof FieldValue) {
            Value member = (Value)decl;
            return naming.makeName(member, Naming.NA_FQ | Naming.NA_WRAPPER_UNQUOTED);
        } else if (decl instanceof Value) {
            Value member = (Value)decl;
            CallBuilder callBuilder = CallBuilder.instance(this);
            ProducedType qualifyingType = ((TypeDeclaration)member.getContainer()).getType();
            callBuilder.invoke(naming.makeQualifiedName(
                    makeJavaType(qualifyingType, JT_RAW | JT_NO_PRIMITIVES),
                    member,
                    Naming.NA_GETTER | Naming.NA_MEMBER));
            return utilInvocation().checkNull(callBuilder.build());
View Full Code Here

    public static String getSetterName(Declaration decl){
        // use the refined decl except when the current declaration is variable and the refined isn't
        Declaration refinedDecl = decl.getRefinedDeclaration();
        if (Decl.isValue(decl) && Decl.isValue(refinedDecl)) {
            Value v = (Value)decl;
            Value rv = (Value)refinedDecl;
            if (!v.isVariable() || rv.isVariable()) {
                decl = refinedDecl;
            }
        } else {
            decl = refinedDecl;
        }
View Full Code Here

            throw new HasTypeException();
    }

    @Override
    public void visit(Tree.ObjectDefinition that){
        Value model = that.getDeclarationModel();
        if(model != null)
            throw new HasTypeException();
    }
View Full Code Here

            throw new HasTypeException();
    }

    @Override
    public void visit(Tree.ObjectArgument that){
        Value model = that.getDeclarationModel();
        if(model != null)
            throw new HasTypeException();
    }
View Full Code Here

    }

    private void bindAttributeArgument(Tree.AttributeArgument attrArg,
            Parameter declaredParam, Naming.SyntheticName argName) {
        ListBuffer<JCStatement> statements;
        final Value model = attrArg.getDeclarationModel();
        final String name = model.getName();
        final Naming.SyntheticName alias = gen.naming.alias(name);
        final List<JCTree> attrClass = gen.gen().transformAttribute(model, alias.getName(), alias.getName(), null, attrArg.getBlock(), attrArg.getSpecifierExpression(), null, null);
        ProducedTypedReference typedRef = gen.getTypedReference(model);
        ProducedTypedReference nonWideningTypedRef = gen.nonWideningTypeDecl(typedRef);
        ProducedType nonWideningType = gen.nonWideningType(typedRef, nonWideningTypedRef);
        ProducedType type = parameterType(declaredParam, model.getType(), 0);
        final BoxingStrategy boxType = getNamedParameterBoxingStrategy(declaredParam);
        JCExpression initValue = gen.make().Apply(null,
                gen.makeSelect(alias.makeIdent(), Naming.getGetterName(model)),
                List.<JCExpression>nil());
        initValue = gen.expressionGen().applyErasureAndBoxing(
View Full Code Here

TOP

Related Classes of com.redhat.ceylon.compiler.typechecker.model.Value

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.