Examples of RubyMethod


Examples of org.jruby.truffle.runtime.methods.RubyMethod

        constantMissingProfile.enter();

        final RubyClass callerClass = ignoreVisibility ? null : box.box(RubyArguments.getSelf(frame.getArguments())).getMetaClass();

        final RubyMethod missingMethod = lookup(callerClass, receiverObject, "const_missing", ignoreVisibility,
                dispatchAction);

        if (missingMethod == null) {
            CompilerDirectives.transferToInterpreter();
            throw new RaiseException(getContext().getCoreLibrary().runtimeError(
                    receiverObject.toString() + " didn't have a #const_missing", this));
        }

        return callNode.call(
                frame,
                missingMethod.getCallTarget(),
                RubyArguments.pack(
                        missingMethod,
                        missingMethod.getDeclarationFrame(),
                        receiverObject,
                        null,
                        new Object[]{toSymbolNode.executeRubySymbol(frame, constantName)}));
    }
View Full Code Here

Examples of org.jruby.truffle.runtime.methods.RubyMethod

        final MethodLike method = RubyArguments.getMethod(arguments);
        lines.add(String.format("      method = %s", method));

        if (method instanceof RubyMethod) {
            final RubyMethod rubyMethod = (RubyMethod) method;

            if (rubyMethod.getDeclaringModule() == null) {
                lines.add(String.format("        declaring module = null"));
            } else {
                lines.add(String.format("        declaring module = %s", rubyMethod.getDeclaringModule().getName()));
            }
        }

        lines.add("      declaration frame:");
        formatDeclarationFrame(context, RubyArguments.getDeclarationFrame(arguments), lines);
View Full Code Here

Examples of org.jruby.truffle.runtime.methods.RubyMethod

            Object blockObject,
            Object argumentsObjects,
            Dispatch.DispatchAction dispatchAction) {
        final RubyClass callerClass = ignoreVisibility ? null : box.box(RubyArguments.getSelf(frame.getArguments())).getMetaClass();

        final RubyMethod method = lookup(callerClass, receiverObject, toJavaStringNode.executeJavaString(frame, methodName),
                ignoreVisibility, dispatchAction);

        if (method != null) {
            if (dispatchAction == Dispatch.DispatchAction.CALL_METHOD) {
                return callNode.call(
                        frame,
                        method.getCallTarget(),
                        RubyArguments.pack(
                                method,
                                method.getDeclarationFrame(),
                                receiverObject,
                                (RubyProc) blockObject,
                                CompilerDirectives.unsafeCast(argumentsObjects, Object[].class, true)));
            } else if (dispatchAction == Dispatch.DispatchAction.RESPOND_TO_METHOD) {
                return true;
            } else {
                throw new UnsupportedOperationException();
            }
        }

        methodMissingProfile.enter();

        final RubyMethod missingMethod = lookup(callerClass, receiverObject, "method_missing", true,
                dispatchAction);

        if (missingMethod == null) {
            if (dispatchAction == Dispatch.DispatchAction.RESPOND_TO_METHOD) {
                return false;
            } else {
                CompilerDirectives.transferToInterpreter();
                throw new RaiseException(getContext().getCoreLibrary().runtimeError(
                        receiverObject.toString() + " didn't have a #method_missing", this));
            }
        }

        if (dispatchAction == Dispatch.DispatchAction.CALL_METHOD) {
            final Object[] argumentsObjectsArray = CompilerDirectives.unsafeCast(argumentsObjects, Object[].class, true);

            final Object[] modifiedArgumentsObjects = new Object[1 + argumentsObjectsArray.length];

            modifiedArgumentsObjects[0] = toSymbolNode.executeRubySymbol(frame, methodName);

            System.arraycopy(argumentsObjectsArray, 0, modifiedArgumentsObjects, 1, argumentsObjectsArray.length);

            return callNode.call(
                    frame,
                    missingMethod.getCallTarget(),
                    RubyArguments.pack(
                            missingMethod,
                            missingMethod.getDeclarationFrame(),
                            receiverObject,
                            (RubyProc) blockObject,
                            modifiedArgumentsObjects));
        } else if (dispatchAction == Dispatch.DispatchAction.RESPOND_TO_METHOD) {
            return false;
View Full Code Here

Examples of org.jruby.truffle.runtime.methods.RubyMethod

    public static Object send(RubyContext context, Object object, String methodName, RubyProc block, Object... arguments) {
        CompilerAsserts.neverPartOfCompilation();

        final RubyBasicObject rubyObject = context.getCoreLibrary().box(object);

        final RubyMethod method = ModuleOperations.lookupMethod(rubyObject.getMetaClass(), methodName);

        if (method == null) {
            return null;
        }

        return method.getCallTarget().call(
                RubyArguments.pack(method, method.getDeclarationFrame(), rubyObject, block, arguments));
    }
View Full Code Here

Examples of org.jruby.truffle.runtime.methods.RubyMethod

    }

    public static RubyMethod lookupMethod(RubyModule module, String name) {
        CompilerAsserts.neverPartOfCompilation();

        RubyMethod method;

        // Look in the current module
        method = module.getMethods().get(name);

        if (method != null) {
View Full Code Here

Examples of org.jruby.truffle.runtime.methods.RubyMethod

        boolean foundDeclaringModule = false;
        for (RubyModule module : objectMetaClass.ancestors()) {
            if (module == declaringModule) {
                foundDeclaringModule = true;
            } else if (foundDeclaringModule) {
                RubyMethod method = module.getMethods().get(name);

                if (method != null) {
                    return method;
                }
            }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.