Package com.redhat.ceylon.compiler.java.codegen.Naming

Examples of com.redhat.ceylon.compiler.java.codegen.Naming.Substitution


       
        // The variable holding the result for the code inside the code block
        JCVariableDecl decl2 = at(isCase).VarDef(make().Modifiers(FINAL), substVarName, toTypeExpr, tmpVarExpr);

        // Prepare for variable substitution in the following code block
        Substitution prevSubst = naming.addVariableSubst(isCase.getVariable().getDeclarationModel(), substVarName.toString());

        List<JCStatement> stats = List.<JCStatement> of(decl2);
        stats = stats.appendList(transformBlock(caseClause.getBlock()));
        JCBlock block = at(isCase).Block(0, stats);

        // Deactivate the above variable substitution
        prevSubst.close();

        last = make().If(cond, block, last);
        return last;
    }
View Full Code Here


            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);
            if (subs != null) {
                subs.close();
            }
            return stmts;
        }
View Full Code Here

        protected abstract List<JCStatement> transformInnermostThen(Cond transformedCond);

        protected abstract JCStatement transformInnermostElse(Cond transformedCond, java.util.List<Tree.Condition> rest);

        protected Substitution getSubstitution(Cond cond) {
            Substitution subs;
            if (cond.hasResultDecl()) {
                subs = naming.substituteAlias(cond.getVariable().getDeclarationModel());
            } else {
                subs = null;
            }
View Full Code Here

       
        @Override
        protected List<JCStatement> transformIntermediate(Tree.Condition condition, java.util.List<Tree.Condition> rest) {
            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();
            }
            return stmts;
        }
View Full Code Here

        private boolean isMulti() {
            return this.conditions.size() > 1;
        }
       
        protected Substitution getSubstitution(Cond cond) {
            Substitution subs = super.getSubstitution(cond);
            if (subs == null) {
                return subs;
            }
            Scope scope = cond.getVariable().getScope().getScope();
            while (scope instanceof ConditionScope) {
                scope = scope.getScope();
            }
            subs.scopeClose(scope);
            // make sure we get a variable name now, and that it doesn't change over time, because
            // we will need this variable name in transformCommonResultDecl(), which declares it,
            // and it runs after we process inner conditions, and if we are an assert, inner conditions
            // may declare new substitutions, which do not close until the end of the outer scope,
            // so if we use substitutions we will get substituted names, rather than the name we should
View Full Code Here

TOP

Related Classes of com.redhat.ceylon.compiler.java.codegen.Naming.Substitution

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.