All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.jruby.runtime.callsite.ArefCallSite Maven / Gradle / Ivy

package org.jruby.runtime.callsite;

import org.jruby.RubyArray;
import org.jruby.runtime.ThreadContext;
import org.jruby.runtime.builtin.IRubyObject;

public class ArefCallSite extends NormalCachingCallSite {
    public ArefCallSite() {
        super("[]");
    }

    @Override
    public IRubyObject call(ThreadContext context, IRubyObject caller, IRubyObject self, long fixnum) {
        if (self.getMetaClass() == context.getRuntime().getArray()) {
            return ((RubyArray) self).entry(fixnum);
        }
        return super.call(context, caller, self, fixnum);
    }

    @Override
    public IRubyObject call(ThreadContext context, IRubyObject caller, IRubyObject self, IRubyObject arg) {
        if (self.getMetaClass() == context.getRuntime().getArray()) {
            return ((RubyArray) self).aref(arg);
        }
        return super.call(context, caller, self, arg);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy