Examples of JCStatement


Examples of com.sun.tools.javac.tree.JCTree.JCStatement

                    make().Type(syms().intType),
                    make().Apply(null,
                            naming.makeQualIdent(stringName.makeIdent(), "codePointAt"),
                            List.<JCExpression>of(indexName.makeIdent()))));
           
            JCStatement block = make().Block(0, transformedBlock);
           
           
            JCForLoop loop = make().ForLoop(
                    List.<JCStatement>of(makeVar(indexName, make().Type(syms().intType), make().Literal(0))),
                    make().Binary(JCTree.LT, indexName.makeIdent(), lengthName.makeIdent()),
View Full Code Here

Examples of com.sun.tools.javac.tree.JCTree.JCStatement

                        makeIndexType(),
                        lengthExpr));
            }
           
            // int i = 0;
            JCStatement iVar = makeVar(indexName,
                    makeIndexType(),
                    makeIndexInit());
            // i < length;
            JCExpression iCond = makeCondition();
            // i++
            JCExpression iIncr = makeIncrement(stepName);
           
            Tree.ControlClause prevControlClause = currentForClause;
            currentForClause = stmt.getForClause();
            List<JCStatement> transformedBlock = transformBlock(getBlock());
            currentForClause = prevControlClause;
           
            // FOO element = java.lang.reflect.Array.get(array, i);
            JCExpression elementGet = makeIndexedAccess();
           
            Tree.ForIterator forIterator = getForIterator();
            if (forIterator instanceof Tree.ValueIterator) {
                String varName = Naming.getVariableName(((Tree.ValueIterator)forIterator).getVariable());
                JCStatement variable = makeVar(FINAL,
                        varName,
                        makeJavaType(elementType),
                        elementGet);
                // Prepend to the block
                transformedBlock = transformedBlock.prepend(variable);
            } else if (forIterator instanceof Tree.KeyValueIterator) {
                SyntheticName entryName = naming.alias("entry");
                JCStatement entryVariable = makeVar(FINAL, entryName,
                        makeJavaType(typeFact().getEntryType(typeFact().getAnythingDeclaration().getType(), typeFact().getAnythingDeclaration().getType()), JT_RAW),
                        elementGet);
                ProducedType entryType = elementType.getSupertype(typeFact().getEntryDeclaration());
                ProducedType keyType = entryType.getTypeArgumentList().get(0);
                String keyName = Naming.getVariableName(((Tree.KeyValueIterator)forIterator).getKeyVariable());
                JCStatement keyVariable = makeVar(FINAL,
                        keyName,
                        makeJavaType(keyType),
                        expressionGen().applyErasureAndBoxing(
                                make().Apply(null, naming.makeQualIdent(entryName.makeIdent(), "getKey"), List.<JCExpression>nil()),
                                typeFact().getAnythingDeclaration().getType(), true, BoxingStrategy.UNBOXED, keyType));
                ProducedType valueType = entryType.getTypeArgumentList().get(1);
                String valueName = Naming.getVariableName(((Tree.KeyValueIterator)forIterator).getValueVariable());
                JCStatement valueVariable = makeVar(FINAL,
                        valueName,
                        makeJavaType(valueType),
                        expressionGen().applyErasureAndBoxing(
                                make().Apply(null, naming.makeQualIdent(entryName.makeIdent(), "getItem"), List.<JCExpression>nil()),
                                typeFact().getAnythingDeclaration().getType(), true, BoxingStrategy.UNBOXED, valueType));
                // Prepend to the block
                transformedBlock = transformedBlock.prepend(valueVariable);
                transformedBlock = transformedBlock.prepend(keyVariable);
                transformedBlock = transformedBlock.prepend(entryVariable);
            }
           
            JCStatement block = make().Block(0, transformedBlock);
            result.add(make().Labelled(this.label, make().ForLoop(
                    List.<JCStatement>of(iVar),
                    iCond,
                    List.<JCExpressionStatement>of(make().Exec(iIncr)),
                    block)));
View Full Code Here

Examples of com.sun.tools.javac.tree.JCTree.JCStatement

        protected final List<JCStatement> transformInnermost(Tree.Condition condition) {
            Cond transformedCond = transformCondition(condition, thenPart);
            // Note: The innermost test happens outside the substitution scope
            JCExpression test = transformedCond.makeTest();
            java.util.List<Tree.Condition> rest = Collections.<Tree.Condition>emptyList();
            JCStatement elseBlock = transformInnermostElse(transformedCond, rest);
            Substitution subs = getSubstitution(transformedCond);
            List<JCStatement> stmts = transformCommonResultDecl(transformedCond, List.<JCStatement>nil());
            stmts = stmts.appendList(transformInnermostThen(transformedCond));
            stmts = transformCommon(transformedCond, rest, test,
                    stmts, elseBlock);
View Full Code Here

Examples of com.sun.tools.javac.tree.JCTree.JCStatement

            Cond intermediate = transformCondition(condition, null);
            JCExpression test = intermediate.makeTest();
            Substitution subs = getSubstitution(intermediate);
            List<JCStatement> stmts = transformList(rest);
            stmts = transformCommonResultDecl(intermediate, stmts);
            JCStatement intermediateElse = transformIntermediateElse(intermediate, rest);
            stmts = transformCommon(intermediate, rest, test,
                    stmts, intermediateElse);
            if (subs != null) {
                subs.close();
            }
View Full Code Here

Examples of com.sun.tools.javac.tree.JCTree.JCStatement

        }
       
        @Override
        protected List<JCStatement> transformCommon(Cond transformedCond,
                java.util.List<Tree.Condition> rest, JCExpression test, List<JCStatement> stmts, JCStatement elseBlock) {
            JCStatement testVarDecl = transformedCond.makeTestVarDecl(0, false);
            if (testVarDecl != null) {
                varDecls.prepend(testVarDecl);
            }
            JCStatement elsePart;
            if (isDeferred()) {
                List<JCStatement> assignDefault = List.<JCStatement>nil();
                for (Cond unassigned : unassignedResultVars.keySet()) {
                    assignDefault = assignDefault.append(
                            make().Exec(make().Assign(unassignedResultVars.get(unassigned).makeIdent(),
View Full Code Here

Examples of com.sun.tools.javac.tree.JCTree.JCStatement

        protected List<JCStatement> transformCommon(Cond transformedCond,
                java.util.List<Tree.Condition> rest, JCExpression test, List<JCStatement> stmts, JCStatement elseBlock) {
            if (transformedCond.makeTestVarDecl(0, false) != null) {
                varDecls.append(transformedCond.makeTestVarDecl(0, false));
            }
            JCStatement elsePart = elseBlock;
            stmts = List.<JCStatement>of(make().If(
                    test,
                    make().Block(0, stmts),
                    elsePart));
            return stmts;
View Full Code Here

Examples of com.sun.tools.javac.tree.JCTree.JCStatement

            stmts = List.<JCStatement>of(make().If(
                    test,
                    make().Block(0, stmts),
                    elseBlock));
           
            JCStatement testVarDecl = cond.makeTestVarDecl(0, true);
            if (testVarDecl != null) {
                stmts = stmts.prepend(testVarDecl);
            }
            return stmts;
        }
View Full Code Here

Examples of com.sun.tools.javac.tree.JCTree.JCStatement

        /**
         * Builds the {@code next()} method of the {@code AbstractIterator}
         */
        private JCMethodDecl makeNextMethod(ProducedType iteratedType) {
            List<JCStatement> of = valueCaptures.append(make().Return(transformExpression(excc.getExpression(), BoxingStrategy.BOXED, iteratedType))).toList();
            JCStatement stmt = make().If(
                    make().Apply(null,
                        ctxtName.makeIdentWithThis(), List.<JCExpression>nil()),
                    make().Block(0, of),
                    make().Return(makeFinished()));
            return make().MethodDef(make().Modifiers(Flags.PUBLIC | Flags.FINAL), names().fromString("next"),
View Full Code Here

Examples of com.sun.tools.javac.tree.JCTree.JCStatement

                //define a variable that records if the expression was already evaluated
                SyntheticName exhaustedName = ctxtName.suffixedBy(Suffix.$exhausted$);
                    JCVariableDecl exhaustedDef = make().VarDef(make().Modifiers(Flags.PRIVATE),
                            exhaustedName.asName(), makeJavaType(typeFact().getBooleanDeclaration().getType()), null);
                    fields.add(exhaustedDef);
                    JCStatement returnIfExhausted = make().If(exhaustedName.makeIdent(), make().Return(makeBoolean(false)), null);
                    JCStatement setExhaustedTrue = make().Exec(make().Assign(exhaustedName.makeIdent(), makeBoolean(true)));
                    initBlock =  List.<JCStatement>of(
                        //if we already evaluated the expression, return
                        returnIfExhausted,
                            //record that we will have evaluated the expression
                            setExhaustedTrue);
              } else {
                assert (ctxtName != null);
                JCStatement returnIfExhausted = make().If(
                    //if the previous comprehension is false or was already evaluated...
                    make().Unary(JCTree.NOT, make().Apply(null,
                        ctxtName.makeIdentWithThis(), List.<JCExpression>nil())),
                    //return false
                        make().Return(makeBoolean(false)), null);
                ctxtName = naming.synthetic(Prefix.$next$, idx);
                initBlock = List.<JCStatement>of(returnIfExhausted);
              }
               
                JCStatement returnTrue = make().Return(makeBoolean(true));
                JCStatement returnFalse = make().Return(makeBoolean(false));
               
                body = new IfComprehensionCondList(clause.getConditionList().getConditions(),
                    initBlock,
                    List.<JCStatement>of(
                        //if the conditions apply: return true
                        returnTrue),
                    List.<JCStatement>of(
                        //the conditions did not apply: return false
                        returnFalse)).getResult();
            } else {
                //Filter contexts need to check if the previous context applies and then check the condition
                JCExpression condExpr = make().Apply(null,
                    ctxtName.makeIdentWithThis(), List.<JCExpression>nil());
                ctxtName = naming.synthetic(Prefix.$next$, idx);
                Name label = names().fromString("ifcomp_"+idx);
                IfComprehensionCondList ifComprehensionCondList = new IfComprehensionCondList(clause.getConditionList().getConditions(), condExpr, label);
                List<JCStatement> ifs = ifComprehensionCondList.getResult();
                JCStatement loop = make().Labelled(label, make().WhileLoop(makeBoolean(true), make().Block(0, ifs)));
                body = List.<JCStatement>of(loop,
                    make().Return(make().Unary(JCTree.NOT, prevItemVar.suffixedBy(Suffix.$exhausted$).makeIdent())));
          }
            MethodDefinitionBuilder mb = MethodDefinitionBuilder.systemMethod(ExpressionTransformer.this, ctxtName.getName())
                .ignoreModelAnnotations()
View Full Code Here

Examples of com.sun.tools.javac.tree.JCTree.JCStatement

           
            protected List<JCStatement> transformCommon(Cond transformedCond,
                    JCExpression test, List<JCStatement> stmts,
                    SyntheticName resultVarName) {
               
                JCStatement decl = transformedCond.makeTestVarDecl(0, true);
                if (decl != null) {
                    varDecls.append(decl);
                }
                if (transformedCond.hasResultDecl()) {
                    fields.add(make().VarDef(make().Modifiers(Flags.PRIVATE),
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.