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

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


        }
       
        // initialize attribute fields to null or a zero
        for (Declaration member : model.getMembers()) {
            if (hasField(member)) {
                Value value = (Value)member;
                if (value.isLate()) {
                    continue;
                }
                // initialize all reference fields to null and all primitive
                // fields to a default value.
                JCExpression nullOrZero;
                if (CodegenUtil.isUnBoxed(value)) {
                    Object literal;
                    ProducedType type = value.getType();
                    if (isCeylonBoolean(type)) {
                        literal = false;
                    } else if (isCeylonByte(type)) {
                        literal = (byte)0;
                    } else if (isCeylonInteger(type)) {
View Full Code Here


        }
       
        // get state from fields
        for (Declaration member : model.getMembers()) {
            if (hasField(member)) {
                Value value = (Value)member;
                final ProducedType serializedValueType;
                JCExpression serializedValue;
                //if (Decl.isValueTypeDecl(simplifyType(value.getType()))) {
               
                if (value.isLate()) {
                    stmts.add(make().If(
                            make().Unary(JCTree.NOT,
                                    naming.makeUnquotedIdent(naming.getInitializationFieldName(value.getName()))),
                            makeThrowAssertionException(make().Literal("instance cannot be serialized: " + member.getQualifiedNameString() + " has not been initialized")),
                            null));
                }
               
                serializedValueType = value.getType();
                if (value.isToplevel() || value.isLate()) {
                    serializedValue = make().Apply(null, naming.makeQualifiedName(naming.makeThis(), value, Naming.NA_MEMBER), List.<JCExpression>nil());
                } else {
                    serializedValue = naming.makeQualifiedName(naming.makeThis(), value, Naming.NA_IDENT);
                }
                serializedValue = expressionGen().applyErasureAndBoxing(serializedValue,
                        value.getType(),
                        !CodegenUtil.isUnBoxed(value),
                        BoxingStrategy.BOXED,
                        value.getType());
                stmts.add(make().Exec(make().Apply(
                        List.of(makeJavaType(serializedValueType, JT_TYPE_ARGUMENT)),
                        naming.makeQualIdent(naming.makeUnquotedIdent(Unfix.deconstructor.toString()), "putValue"),
                        List.of(makeReifiedTypeArgument(serializedValueType),
                                makeValueDeclaration(value),
View Full Code Here

        }
        return false;
    }

    public void transform(AttributeDeclaration decl, ClassDefinitionBuilder classBuilder) {
        final Value model = decl.getDeclarationModel();
        boolean lazy = decl.getSpecifierOrInitializerExpression() instanceof LazySpecifierExpression;
        boolean useField = Strategy.useField(model) && !lazy;
        String attrName = decl.getIdentifier().getText();

        // Only a non-formal or a concrete-non-lazy attribute has a corresponding field
        // and if a captured class parameter exists with the same name we skip this part as well
        Parameter parameter = CodegenUtil.findParamForDecl(decl);
        boolean createField = Strategy.createField(parameter, model) && !lazy;
        boolean concrete = Decl.withinInterface(decl)
                && decl.getSpecifierOrInitializerExpression() != null;
        if (!lazy &&
                (concrete ||
                        (!Decl.isFormal(decl)
                                && createField))) {
            ProducedTypedReference typedRef = getTypedReference(model);
            ProducedTypedReference nonWideningTypedRef = nonWideningTypeDecl(typedRef);
            ProducedType nonWideningType = nonWideningType(typedRef, nonWideningTypedRef);
           
            if (Decl.isIndirect(decl)) {
                attrName = Naming.getAttrClassName(model, 0);
                nonWideningType = getGetterInterfaceType(model);
            }
           
            JCExpression initialValue = null;
            if (decl.getSpecifierOrInitializerExpression() != null) {
                Value declarationModel = model;
                initialValue = expressionGen().transformExpression(decl.getSpecifierOrInitializerExpression().getExpression(),
                        CodegenUtil.getBoxingStrategy(declarationModel),
                        nonWideningType);
            }
View Full Code Here

            if (specOrInit != null) {
                HasErrorException error = errors().getFirstExpressionErrorAndMarkBrokenness(specOrInit.getExpression());
                if (error != null) {
                    builder.getterBlock(make().Block(0, List.<JCStatement>of(this.makeThrowUnresolvedCompilationError(error))));
                } else {
                    Value declarationModel = decl.getDeclarationModel();
                    ProducedTypedReference typedRef = getTypedReference(declarationModel);
                    ProducedTypedReference nonWideningTypedRef = nonWideningTypeDecl(typedRef);
                    ProducedType nonWideningType = nonWideningType(typedRef, nonWideningTypedRef);
                   
                    JCExpression expr = expressionGen().transformExpression(specOrInit.getExpression(),
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.