Package org.jruby.truffle.runtime.control

Examples of org.jruby.truffle.runtime.control.RaiseException


        @Override
        protected double doFunction(double a) {
            if (a < -1.0 || a > 1.0) {
                CompilerDirectives.transferToInterpreter();
                throw new RaiseException(getContext().getCoreLibrary().mathDomainError("asin", this));
            }

            return Math.asin(a);
        }
View Full Code Here


        protected double doFunction(double a) {
            // Copied from RubyMath - see copyright notices there

            if (a < -1.0 || a > 1.0) {
                CompilerDirectives.transferToInterpreter();
                throw new RaiseException(getContext().getCoreLibrary().mathDomainError("atanh", this));
            }

            final double y = Math.abs(a);

            if (Double.isNaN(a)) {
View Full Code Here

            if (boxed.isNumeric()) {
                try {
                    return frexp(floatNode.callFloat(frame, boxed, "to_f", null));
                } catch (UseMethodMissingException e) {
                    throw new RaiseException(getContext().getCoreLibrary().typeErrorCantConvertInto(
                            boxed.getLogicalClass().getName(),
                            getContext().getCoreLibrary().getFloatClass().getName(),
                            this));
                }
            } else {
                CompilerDirectives.transferToInterpreter();

                throw new RaiseException(getContext().getCoreLibrary().typeErrorCantConvertInto(
                        boxed.getLogicalClass().getName(),
                        getContext().getCoreLibrary().getFloatClass().getName(),
                        this));
            }
        }
View Full Code Here

                try {
                    return doFunction(
                            floatANode.callFloat(frame, aBoxed, "to_f", null),
                            floatBNode.callFloat(frame, bBoxed, "to_f", null));
                } catch (UseMethodMissingException e) {
                    throw new RaiseException(getContext().getCoreLibrary().typeErrorCantConvertInto(
                            aBoxed.getLogicalClass().getName(),
                            getContext().getCoreLibrary().getFloatClass().getName(),
                            this));
                }
            } else {
                CompilerDirectives.transferToInterpreter();

                throw new RaiseException(getContext().getCoreLibrary().typeErrorCantConvertInto(
                        aBoxed.getLogicalClass().getName(),
                        getContext().getCoreLibrary().getFloatClass().getName(),
                        this));
            }
        }
View Full Code Here

        method = ModuleOperations.lookupSuperMethod(declaringModule, name, selfMetaClass);

        if (method == null || method.isUndefined()) {
            method = null;
            // TODO: should add " for #{receiver.inspect}" in error message
            throw new RaiseException(getContext().getCoreLibrary().noMethodError("super: no superclass method `"+name+"'", this));
        }

        final DirectCallNode newCallNode = Truffle.getRuntime().createDirectCallNode(method.getCallTarget());

        if (callNode == null) {
View Full Code Here

        protected double doFunction(double a) {
            // Copied from RubyMath - see copyright notices there

            if (a == -1) {
                CompilerDirectives.transferToInterpreter();
                throw new RaiseException(getContext().getCoreLibrary().mathDomainError("gamma", this));
            }

            if (Double.isNaN(a)) {
                return Double.NaN;
            }

            if (Double.isInfinite(a)) {
                if (a > 0) {
                    return Double.POSITIVE_INFINITY;
                } else {
                    CompilerDirectives.transferToInterpreter();
                    throw new RaiseException(getContext().getCoreLibrary().mathDomainError("gamma", this));
                }
            }

            double result = RubyMath.nemes_gamma(a);

            if (Double.isInfinite(result)) {
                if (a < 0) {
                    result = Double.NaN;
                } else {
                    if (a == 0 && 1 / a < 0) {
                        result = Double.NEGATIVE_INFINITY;
                    } else {
                        result = Double.POSITIVE_INFINITY;
                    }
                }
            }

            if (Double.isNaN(a)) {
                CompilerDirectives.transferToInterpreter();
                throw new RaiseException(getContext().getCoreLibrary().mathDomainError("gamma", this));
            }

            return result;
        }
View Full Code Here

        @Specialization
        public double function(double a, double b) {
            if (Double.isNaN(b)) {
                CompilerDirectives.transferToInterpreter();
                throw new RaiseException(getContext().getCoreLibrary().rangeError("float", Double.toString(b), "integer", this));
            }

            return a * Math.pow(2, b);
        }
View Full Code Here

                try {
                    return function(
                            floatANode.callFloat(frame, aBoxed, "to_f", null),
                            integerBNode.callLongFixnum(frame, bBoxed, "to_int", null));
                } catch (UseMethodMissingException e) {
                    throw new RaiseException(getContext().getCoreLibrary().typeErrorCantConvertInto(
                           aBoxed.getLogicalClass().getName(),
                            getContext().getCoreLibrary().getIntegerClass().getName(),
                            this));
                }
            } else {
                CompilerDirectives.transferToInterpreter();

                throw new RaiseException(getContext().getCoreLibrary().typeErrorCantConvertInto(
                        aBoxed.getLogicalClass().getName(),
                        getContext().getCoreLibrary().getFloatClass().getName(),
                        this));
            }
        }
View Full Code Here

        public RubyArray lgamma(double a) {
            // Copied from RubyMath - see copyright notices there

            if (a < 0 && Double.isInfinite(a)) {
                CompilerDirectives.transferToInterpreter();
                throw new RaiseException(getContext().getCoreLibrary().mathDomainError("log2", this));
            }

            final RubyMath.NemesLogGamma l = new RubyMath.NemesLogGamma(a);

            return new RubyArray(getContext().getCoreLibrary().getArrayClass(), new Object[]{l.value, l.sign}, 2);
View Full Code Here

            if (boxed.isNumeric()) {
                try {
                    return lgamma(floatNode.callFloat(frame, boxed, "to_f", null));
                } catch (UseMethodMissingException e) {
                    throw new RaiseException(getContext().getCoreLibrary().typeErrorCantConvertInto(
                            boxed.getLogicalClass().getName(),
                            getContext().getCoreLibrary().getFloatClass().getName(),
                            this));
                }
            } else {
                CompilerDirectives.transferToInterpreter();

                throw new RaiseException(getContext().getCoreLibrary().typeErrorCantConvertInto(
                        boxed.getLogicalClass().getName(),
                        getContext().getCoreLibrary().getFloatClass().getName(),
                        this));
            }
        }
View Full Code Here

TOP

Related Classes of org.jruby.truffle.runtime.control.RaiseException

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.