Package org.jruby.truffle.runtime.core

Examples of org.jruby.truffle.runtime.core.RubyArray


        public RubyArray permutation(RubyArray array, int n) {
            notDesignedForCompilation();

            final List<RubyArray> permutations = new ArrayList<>();
            permutationCommon(n, false, array.slowToArray(), permutations);
            return new RubyArray(getContext().getCoreLibrary().getArrayClass(), permutations.toArray(), permutations.size());
        }
View Full Code Here


        // Apdapted from JRuby's RubyArray - see attribution there

        private void permutationCommon(int r, boolean repeat, Object[] values, List<RubyArray> permutations) {
            if (r == 0) {
                permutations.add(new RubyArray(getContext().getCoreLibrary().getArrayClass(), null, 0));
            } else if (r == 1) {
                for (int i = 0; i < values.length; i++) {
                    permutations.add(new RubyArray(getContext().getCoreLibrary().getArrayClass(), values[i], 1));
                }
            } else if (r >= 0) {
                int n = values.length;
                permute(n, r,
                        new int[r], 0,
View Full Code Here

                        for (int j = 0; j < r; j++) {
                            result[j] = values[p[j]];
                        }

                        permutations.add(new RubyArray(getContext().getCoreLibrary().getArrayClass(), result, r));
                    }
                }
            }
        }
View Full Code Here

            final Object[] pairs = new Object[aLength * bLength];

            for (int an = 0; an < aLength; an++) {
                for (int bn = 0; bn < bLength; bn++) {
                    pairs[an * bLength + bn] = new RubyArray(getContext().getCoreLibrary().getArrayClass(), new Object[]{a[an], b[bn]}, 2);
                }
            }

            return new RubyArray(getContext().getCoreLibrary().getArrayClass(), pairs, pairs.length);
        }
View Full Code Here

            arrayBuilder = prev.arrayBuilder;
        }

        @Specialization(guards = "isNull")
        public Object selectNull(VirtualFrame frame, RubyArray array, RubyProc block) {
            return new RubyArray(getContext().getCoreLibrary().getArrayClass());
        }
View Full Code Here

                if (CompilerDirectives.inInterpreter()) {
                    ((RubyRootNode) getRootNode()).reportLoopCountThroughBlocks(count);
                }
            }

            return new RubyArray(getContext().getCoreLibrary().getArrayClass(), arrayBuilder.finish(selectedStore, selectedSize), selectedSize);
        }
View Full Code Here

                if (CompilerDirectives.inInterpreter()) {
                    ((RubyRootNode) getRootNode()).reportLoopCountThroughBlocks(count);
                }
            }

            return new RubyArray(getContext().getCoreLibrary().getArrayClass(), arrayBuilder.finish(selectedStore, selectedSize), selectedSize);
        }
View Full Code Here

            integerDiv = div;
        }

        if (integerDiv instanceof Long && ((long) integerDiv) >= Integer.MIN_VALUE && ((long) integerDiv) <= Integer.MAX_VALUE && mod >= Integer.MIN_VALUE && mod <= Integer.MAX_VALUE) {
            useFixnumPairProfile.enter();
            return new RubyArray(context.getCoreLibrary().getArrayClass(), new int[]{(int) (long) integerDiv, (int) mod}, 2);
        } else {
            useObjectPairProfile.enter();
            return new RubyArray(context.getCoreLibrary().getArrayClass(), new Object[]{integerDiv, mod}, 2);
        }
    }
View Full Code Here

            bigIntegerFixnumProfile.enter();
            bigIntegerResults[0] = SlowPathBigInteger.subtract(bigIntegerResults[0], BigInteger.ONE);
            bigIntegerResults[1] = SlowPathBigInteger.add(b, bigIntegerResults[1]);
        }

        return new RubyArray(context.getCoreLibrary().getArrayClass(), new Object[]{
                fixnumOrBignumQuotient.fixnumOrBignum(bigIntegerResults[0]),
                fixnumOrBignumRemainder.fixnumOrBignum(bigIntegerResults[1])}, 2);
    }
View Full Code Here

        notDesignedForCompilation();

        final Object arrayObject = array.execute(frame);
        assert arrayObject instanceof RubyArray : getSourceSection();

        final RubyArray originalArray = (RubyArray) arrayObject;

        final RubyArray newArray = new RubyArray(getContext().getCoreLibrary().getArrayClass(), originalArray.slowToArray(), originalArray.getSize());
        newArray.slowPush(pushed.execute(frame));
        return newArray;
    }
View Full Code Here

TOP

Related Classes of org.jruby.truffle.runtime.core.RubyArray

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.