Package r.nodes.exec

Examples of r.nodes.exec.Selector


        protected final Object executeLoop(RArray array, boolean dropVal, int exactVal) {
            while (true) {
                try {
                    return execute(array, dropVal, exactVal);
                } catch (SpecializationException e) {
                    Selector failedSelector = (Selector) e.getResult();
                    for (int i = 0; i < selectorVals.length; ++i) {
                        if (selectorVals[i] == failedSelector) {
                            RAny index = failedSelector.getIndex();
                            SelectorNode newSelector = Selector.createSelectorNode(ast, subset, index, selectorExprs[i], false, failedSelector.getTransition());
                            selectorExprs[i] = adoptChild(newSelector);
                            selectorVals[i] = newSelector.executeSelector(index);
                        }
                    }
                }
View Full Code Here


            this.selectorJExpr = adoptChild(selectorJExpr);
        }

        @Override public Object execute(Frame frame) {
            RAny lhsVal = (RAny) lhs.execute(frame);
            Selector selectorI = selectorIExpr.executeSelector(frame);
            Selector selectorJ = selectorJExpr.executeSelector(frame);
            boolean dropVal = dropExpr.executeLogical(frame) != 0; // FIXME: what is the correct execution order of these args?
            int exactVal = exactExpr.executeLogical(frame);

            if (!(lhsVal instanceof RArray)) { throw RError.getObjectNotSubsettable(ast, lhsVal.typeOf()); }
            RArray array = (RArray) lhsVal;
View Full Code Here

            }
            return super.replaceChild(oldNode, newNode);
        }

        public Object executeLoop(RArray array, Selector selectorI, Selector selectorJ, boolean dropVal, int exactVal) {
            Selector selI = selectorI;
            Selector selJ = selectorJ;
            for (;;) {
                try {
                    return execute(array, selI, selJ, dropVal, exactVal);
                } catch (SpecializationException e) {
                    Selector failedSelector = (Selector) e.getResult();
                    if (failedSelector == selI) {
                        RAny index = selI.getIndex();
                        selectorIExpr.replace(Selector.createSelectorNode(ast, subset, index, selectorIExpr.child, false, selectorI.getTransition()));
                        selI = selectorIExpr.executeSelector(index);
                    } else {
View Full Code Here

            } catch (SpecializationException e) {
                SelectorNode selIExpr = Selector.createSelectorNode(ast, true, null);
                SelectorNode selJExpr = Selector.createSelectorNode(ast, true, columnExpr);
                MatrixRead mr = new MatrixRead(ast, true, lhs, selIExpr, selJExpr, dropExpr, exactExpr);
                replace(mr, "install MatrixRead from MatrixColumnSubset");
                Selector selI = selIExpr.executeSelector(frame);
                Selector selJ = selJExpr.executeSelector(colVal);
                return mr.executeLoop(array, selI, selJ, dropVal, exactVal);
            }
        }
View Full Code Here

            } catch (SpecializationException e) {
                SelectorNode selIExpr = Selector.createSelectorNode(ast, true, rowExpr);
                SelectorNode selJExpr = Selector.createSelectorNode(ast, true, null);
                MatrixRead nn = new MatrixRead(ast, true, lhs, selIExpr, selJExpr, dropExpr, exactExpr);
                replace(nn, "install MatrixRead from MatrixRowSubset");
                Selector selI = selIExpr.executeSelector(rowVal);
                Selector selJ = selJExpr.executeSelector(frame);
                return nn.executeLoop(array, selI, selJ, dropVal, exactVal);
            }
        }
View Full Code Here

                ASTNode colAST = colFromExpr.getAST().getParent();
                Builtin colColon = (Builtin) Primitives.getCallFactory(RSymbol.getSymbol(":"), null).create(colAST, colFromExpr, colToExpr);
                SelectorNode selJExpr = Selector.createSelectorNode(ast, true, colColon);
                MatrixRead nn = new MatrixRead(ast, true, lhs, selIExpr, selJExpr, dropExpr, exactExpr);
                replace(nn, "install MatrixRead from MatrixSequenceSubset");
                Selector selI = selIExpr.executeSelector(rowColon.doBuiltIn(frame, new RAny[]{(RAny) rowFromVal, (RAny) rowToVal}));
                Selector selJ = selJExpr.executeSelector(colColon.doBuiltIn(frame, new RAny[]{(RAny) colFromVal, (RAny) colToVal}));
                return nn.executeLoop(array, selI, selJ, dropVal, exactVal);
            }
        }
View Full Code Here

            }
            while (true) {
                try {
                    return update(lhs, rhs);
                } catch (SpecializationException e) {
                    Selector failedSelector = (Selector) e.getResult();
                    for (int i = 0; i < selectorVals.length; ++i) {
                        if (selectorVals[i] == failedSelector) {
                            RAny index = failedSelector.getIndex();
                            SelectorNode newSelector = Selector.createSelectorNode(ast, subset, index, selectorExprs[i].child, false, failedSelector.getTransition());
                            selectorExprs[i].replace(newSelector);
                            assert Utils.check(selectorExprs[i] == newSelector);
                            selectorVals[i] = newSelector.executeSelector(index);
                            if (DEBUG_UP) Utils.debug("Selector " + i + " changed...");
                        }
View Full Code Here

            checkDimensions(dim, selectorVals.length, ast);
            int mult = 1;
            int offset = 0;
            checkReplacementSize(lhs.size(), rhs.size(), false, ast);
            for (int i = 0; i < selectorVals.length; ++i) {
                Selector s = selectorVals[i];
                s.start(dim[i], ast); // it is ensured by subscript selectors that itemsToReplace is 1
                int k = s.nextIndex(ast);
                assert Utils.check(k != RInt.NA); // ensured by subscript selectors
                offset += k * mult;
                mult *= dim[i];
            }
            return lhs.set(offset, rhs instanceof RList ? rhs : rhs.get(0));
View Full Code Here

        @Override public RAny execute(Frame frame, RAny lhs, RAny rhs) {
            try {
                guard.check(lhs, rhs);
                if (lhs.isShared()) { throw new SpecializationException(null); }
                int lastSel = selectorVals.length - 1;
                Selector columnSel = selectorExprs[lastSel].executeSelector(frame);
                while (true) {
                    try {
                        return update((RArray) lhs, (RArray) rhs, columnSel);
                    } catch (SpecializationException e) {
                        RAny index = columnSel.getIndex();
                        SelectorNode newSelector = Selector.createSelectorNode(ast, subset, index, selectorExprs[lastSel].child, false, columnSel.getTransition());
                        selectorExprs[lastSel].replace(newSelector);
                        assert Utils.check(selectorExprs[lastSel] == newSelector);
                        columnSel = newSelector.executeSelector(index);
                        if (DEBUG_UP) Utils.debug("Column selector changed...");
                    }
View Full Code Here

TOP

Related Classes of r.nodes.exec.Selector

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.