Package org.jruby.runtime.builtin

Examples of org.jruby.runtime.builtin.IRubyObject


import org.objectweb.asm.Type;

public class InvokeDynamicSupport {
    public static Object bootstrap(final CallSite site, Object... args) {
        // dynamic call
        IRubyObject self = (IRubyObject) args[0];
        ThreadContext context = (ThreadContext) args[1];
        String methodName = (String) args[2];
        CallType callType = CallType.NORMAL;
        String siteName = site.name();
        boolean iterator = siteName.length() == 2 && siteName.charAt(1) == 'b';
       
        switch (siteName.charAt(0)) {
        case 'c':
            callType = CallType.NORMAL;
            break;
        case 'f':
            callType = CallType.FUNCTIONAL;
            break;
        case 'v':
            callType = CallType.VARIABLE;
            break;
        }

        DynamicMethod method = self.getMetaClass().searchMethod(methodName);
        IRubyObject caller = context.getFrameSelf();
        if (shouldCallMethodMissing(method, methodName, caller, callType)) {
            return RuntimeHelpers.callMethodMissing(context, self, method, methodName, callType, Block.NULL_BLOCK);
        }

        String dispatcherName = iterator ? "invokeDynamicIter" : "invokeDynamic";
View Full Code Here


    private static boolean notVisibleAndNotMethodMissing(DynamicMethod method, String name, IRubyObject caller, CallType callType) {
        return !method.isCallableFrom(caller, callType) && !name.equals("method_missing");
    }

    public static IRubyObject invokeDynamic(DynamicMethod method, Object selfObj, ThreadContext context, String name) {
        IRubyObject self = (IRubyObject) selfObj;
        return method.call(context, self, self.getMetaClass(), name);
    }
View Full Code Here

        IRubyObject self = (IRubyObject) selfObj;
        return method.call(context, self, self.getMetaClass(), name);
    }

    public static IRubyObject invokeDynamic(DynamicMethod method, Object selfObj, ThreadContext context, String name, Block block) {
        IRubyObject self = (IRubyObject) selfObj;
        RubyClass selfType = pollAndGetClass(context, self);
        try {
            return method.call(context, self, selfType, name, block);
        } catch (JumpException.BreakJump bj) {
            return handleBreakJump(context, bj);
View Full Code Here

            throw retryJumpError(context);
        }
    }

    public static IRubyObject invokeDynamicIter(DynamicMethod method, Object selfObj, ThreadContext context, String name, Block block) {
        IRubyObject self = (IRubyObject) selfObj;
        RubyClass selfType = pollAndGetClass(context, self);
        try {
            return method.call(context, self, selfType, name, block);
        } catch (JumpException.BreakJump bj) {
            return handleBreakJump(context, bj);
View Full Code Here

            block.escape();
        }
    }

    public static IRubyObject invokeDynamic(DynamicMethod method, Object selfObj, ThreadContext context, String name, IRubyObject arg) {
        IRubyObject self = (IRubyObject) selfObj;
        return method.call(context, self, self.getMetaClass(), name, arg);
    }
View Full Code Here

        IRubyObject self = (IRubyObject) selfObj;
        return method.call(context, self, self.getMetaClass(), name, arg);
    }

    public static IRubyObject invokeDynamic(DynamicMethod method, Object selfObj, ThreadContext context, String name, IRubyObject arg, Block block) {
        IRubyObject self = (IRubyObject) selfObj;
        RubyClass selfType = pollAndGetClass(context, self);
        try {
            return method.call(context, self, selfType, name, arg, block);
        } catch (JumpException.BreakJump bj) {
            return handleBreakJump(context, bj);
View Full Code Here

        RubyClass klass = (RubyClass) recv;
        Ruby runtime = context.getRuntime();
        RubyHash hash;

        if (args.length == 1) {
            IRubyObject tmp = TypeConverter.convertToTypeWithCheck(
                    args[0], runtime.getHash(), MethodIndex.TO_HASH, "to_hash");

            if (!tmp.isNil()) {
                RubyHash otherHash = (RubyHash) tmp;
                return new RubyHash(runtime, klass, otherHash);
            }
        }
View Full Code Here

        // if (table[i] != null) collisions++;

        if (checkForExisting) {
            for (RubyHashEntry entry = table[i]; entry != null; entry = entry.next) {
                IRubyObject k;
                if (entry.hash == hash && ((k = entry.key) == key || key.eql(k))) {
                    entry.value = value;
                    return;
                }
            }
View Full Code Here

    }

    private final RubyHashEntry internalGetEntry(IRubyObject key) {
        final int hash = hashValue(key.hashCode());
        for (RubyHashEntry entry = table[bucketIndex(hash, table.length)]; entry != null; entry = entry.next) {
            IRubyObject k;
            if (entry.hash == hash && ((k = entry.key) == key || key.eql(k))) return entry;
        }
        return NO_ENTRY;
    }
View Full Code Here

        try {
            runtime.registerInspecting(this);
            visitAll(new Visitor() {
                public void visit(IRubyObject key, IRubyObject value) {
                    IRubyObject value2 = otherHash.fastARef(key);
                    if (value2 == null ||
                       !(eql ? eqlInternal(context, value, value2) : equalInternal(context, value, value2))) {
                        throw new Mismatch();
                    }
                }
View Full Code Here

TOP

Related Classes of org.jruby.runtime.builtin.IRubyObject

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.