Package r.nodes.ast

Examples of r.nodes.ast.If


            Sequence parentSeq = (Sequence) parent;
            ASTNode[] exprs = parentSeq.getExprs();
            return (exprs[exprs.length - 1] == n) && isTrailingInAFunction(parentSeq);
        }
        if (parent instanceof If) {
            If parentIf = (If) parent;
            ASTNode trueBranch = parentIf.getTrueCase();
            ASTNode falseBranch = parentIf.getFalseCase();
            return ((trueBranch == n || falseBranch == n ) && isTrailingInAFunction(parentIf));
        }
        return false;
    }
View Full Code Here


        int i = from;
        for (; i < to; i++) {
            ASTNode e = exprs[i];

            if (introduceIfReturnRest && e instanceof If && !RETURN_SYMBOL.builtinIsOverridden()) {
                If ifExpr = (If) e;
                if (i < to - 1 && ifExpr.getFalseCase() == null) {
                    // if (cond) { .... } ; remaining   - we don't know yet if there is a return
                    ASTNode trueBranch = ifExpr.getTrueCase();
                    RNode truePart = null;
                    RNode returnCallArg = returnCallArgument(trueBranch);
                    if (returnCallArg != null) {
                        truePart = null;
                    } else if (trueBranch instanceof Sequence) {
                        Sequence trueSequence = (Sequence) trueBranch;
                        ASTNode[] trueExprs = trueSequence.getExprs();
                        if (trueExprs.length > 1) {
                            // FIXME: in theory we could be looking recursively into the tree, but recovery would then become hard
                            ASTNode lastTrueExpr = trueExprs[trueExprs.length - 1];
                            returnCallArg = returnCallArgument(lastTrueExpr);
                            if (returnCallArg != null) {
                                truePart = buildSequence(trueSequence, trueExprs, 0, trueExprs.length - 1, false);
                            }
                        }
                    }

                    if (returnCallArg != null) {
                        // if (cond) { .... ; return(returnCallArg) } ; remaining   (no we know there is a return in the true branch
                        RNode remainingSubsequence = buildSequence(origSequence, exprs, i + 1, to, true);
                        RNode newIf = new r.nodes.exec.If.IfReturnRest.ReturnBuiltin(e, createLazyTree(ifExpr.getCond()), truePart,
                                returnCallArg, remainingSubsequence);
                        rexprs[i - from] = newIf;
                        if (DEBUG_RETURN) System.err.println("Converted if with return, new if is " + PrettyPrinter.prettyPrint(newIf.getAST()));
                        i++;
                        break;
View Full Code Here

TOP

Related Classes of r.nodes.ast.If

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.