/** * MRI: rb_funcallv_public */ public IRubyObject invokePublic(ThreadContext context, IRubyObject self, String name, IRubyObject arg) { DynamicMethod method = searchMethod(name); if (shouldCallMethodMissing(method) || method.getVisibility() != PUBLIC) { return Helpers.callMethodMissing(context, self, this, method.getVisibility(), name, CallType.FUNCTIONAL, arg, Block.NULL_BLOCK); } return method.call(context, self, this, name, arg); }
protected final IRubyObject callMethodMissing(ThreadContext context, IRubyObject self, RubyClass selfType, DynamicMethod method, IRubyObject arg0, IRubyObject arg1, IRubyObject arg2, Block block) { return Helpers.selectMethodMissing(context, selfType, method.getVisibility(), methodName, callType).call(context, self, self.getMetaClass(), methodName, arg0, arg1, arg2, block); }
public static IRubyObject invokeSuper(ThreadContext context, IRubyObject self, RubyModule klass, String name, IRubyObject[] args, Block block) { checkSuperDisabledOrOutOfMethod(context, klass, name); RubyClass superClass = findImplementerIfNecessary(self.getMetaClass(), klass).getSuperClass(); DynamicMethod method = superClass != null ? superClass.searchMethod(name) : UndefinedMethod.INSTANCE; if (method.isUndefined()) { return callMethodMissing(context, self, method.getVisibility(), name, CallType.SUPER, args, block); } return method.call(context, self, superClass, name, args, block); }
private boolean isPublic(IRubyObject object, String name) { RubyClass metaClass = object.getMetaClass(); Visibility visibility = metaClass.searchMethod(name).getVisibility(); return visibility != null && !visibility.isPrivate() && !(visibility.isProtected() && metaClass.getRealClass().isInstance(object)); }
/** * MRI: rb_funcallv_public */ public IRubyObject invokePublic(ThreadContext context, IRubyObject self, String name, IRubyObject arg) { DynamicMethod method = searchMethod(name); if (shouldCallMethodMissing(method) || method.getVisibility() != PUBLIC) { return Helpers.callMethodMissing(context, self, this, method.getVisibility(), name, CallType.FUNCTIONAL, arg, Block.NULL_BLOCK); } return method.call(context, self, this, name, arg); }
public static IRubyObject callMethodMissing(CacheEntry entry, CallType callType, ThreadContext context, IRubyObject self, String name, IRubyObject arg) { return Helpers.selectMethodMissing(context, self, entry.method.getVisibility(), name, callType).call(context, self, self.getMetaClass(), name, arg, Block.NULL_BLOCK); }
public static IRubyObject invokeSuper(ThreadContext context, IRubyObject self, RubyModule klass, String name, IRubyObject[] args, Block block) { checkSuperDisabledOrOutOfMethod(context, klass, name); RubyClass superClass = findImplementerIfNecessary(self.getMetaClass(), klass).getSuperClass(); DynamicMethod method = superClass != null ? superClass.searchMethod(name) : UndefinedMethod.INSTANCE; if (method.isUndefined()) { return callMethodMissing(context, self, method.getVisibility(), name, CallType.SUPER, args, block); } return method.call(context, self, superClass, name, args, block); }
private boolean isPublic(IRubyObject object, String name) { RubyClass metaClass = object.getMetaClass(); Visibility visibility = metaClass.searchMethod(name).getVisibility(); return visibility != null && !visibility.isPrivate() && !(visibility.isProtected() && metaClass.getRealClass().isInstance(object)); }
public IRubyObject finvoke(ThreadContext context, IRubyObject self, String name, Block block) { DynamicMethod method = searchMethod(name); if (shouldCallMethodMissing(method)) { return Helpers.callMethodMissing(context, self, this, method.getVisibility(), name, CallType.FUNCTIONAL, block); } return method.call(context, self, this, name, block); }
public static IRubyObject callMethodMissing(CacheEntry entry, CallType callType, ThreadContext context, IRubyObject self, String name, IRubyObject arg0, IRubyObject arg1, Block block) { return Helpers.selectMethodMissing(context, self, entry.method.getVisibility(), name, callType).call(context, self, self.getMetaClass(), name, arg0, arg1, block); }
public static IRubyObject invokeSuper(ThreadContext context, IRubyObject self, IRubyObject arg0, Block block) { checkSuperDisabledOrOutOfMethod(context); RubyModule klazz = context.getFrameKlazz(); String name = context.getFrameName(); RubyClass superClass = findImplementerIfNecessary(self.getMetaClass(), klazz).getSuperClass(); DynamicMethod method = superClass != null ? superClass.searchMethod(name) : UndefinedMethod.INSTANCE; if (method.isUndefined()) { return callMethodMissing(context, self, method.getVisibility(), name, CallType.SUPER, arg0, block); } return method.call(context, self, superClass, name, arg0, block); }
@JIT @Interp public static IRubyObject isDefinedMethod(ThreadContext context, IRubyObject receiver, String name, boolean checkIfPublic, IRubyObject definedMessage) { DynamicMethod method = receiver.getMetaClass().searchMethod(name); boolean defined = !method.isUndefined(); if (defined) { // If we find the method we optionally check if it is public before returning "method". defined = !checkIfPublic || method.getVisibility() == Visibility.PUBLIC; } else { // If we did not find the method, check respond_to_missing? defined = receiver.respondsToMissing(name, checkIfPublic); } return defined ? definedMessage : context.nil; }
public IRubyObject finvoke(ThreadContext context, IRubyObject self, String name, IRubyObject[] args, Block block) { assert args != null; DynamicMethod method = searchMethod(name); if (shouldCallMethodMissing(method)) { return Helpers.callMethodMissing(context, self, this, method.getVisibility(), name, CallType.FUNCTIONAL, args, block); } return method.call(context, self, this, name, args, block); }
protected final IRubyObject callMethodMissing(ThreadContext context, IRubyObject self, RubyClass selfType, DynamicMethod method, IRubyObject arg0, IRubyObject arg1, IRubyObject arg2, Block block) { return Helpers.selectMethodMissing(context, selfType, method.getVisibility(), methodName, callType).call(context, self, self.getMetaClass(), methodName, arg0, arg1, arg2, block); }
public static IRubyObject invokeSuper(ThreadContext context, IRubyObject self, IRubyObject arg0, IRubyObject arg1, Block block) { checkSuperDisabledOrOutOfMethod(context); RubyModule klazz = context.getFrameKlazz(); String name = context.getFrameName(); RubyClass superClass = findImplementerIfNecessary(self.getMetaClass(), klazz).getSuperClass(); DynamicMethod method = superClass != null ? superClass.searchMethod(name) : UndefinedMethod.INSTANCE; if (method.isUndefined()) { return callMethodMissing(context, self, method.getVisibility(), name, CallType.SUPER, arg0, arg1, block); } return method.call(context, self, superClass, name, arg0, arg1, block); }
@JIT @Interp public static IRubyObject isDefinedMethod(ThreadContext context, IRubyObject receiver, String name, boolean checkIfPublic, IRubyObject definedMessage) { DynamicMethod method = receiver.getMetaClass().searchMethod(name); boolean defined = !method.isUndefined(); if (defined) { // If we find the method we optionally check if it is public before returning "method". defined = !checkIfPublic || method.getVisibility() == Visibility.PUBLIC; } else { // If we did not find the method, check respond_to_missing? defined = receiver.respondsToMissing(name, checkIfPublic); } return defined ? definedMessage : context.nil; }
/** * Same behavior as finvoke, but uses the given caller object to check visibility if callType demands it. */ public IRubyObject invokeFrom(ThreadContext context, CallType callType, IRubyObject caller, IRubyObject self, String name) { DynamicMethod method = searchMethod(name); if (shouldCallMethodMissing(method, name, caller, callType)) { return Helpers.callMethodMissing(context, self, this, method.getVisibility(), name, callType, Block.NULL_BLOCK); } return method.call(context, self, this, name); }
public static IRubyObject callMethodMissing(CacheEntry entry, CallType callType, ThreadContext context, IRubyObject self, String name) { return Helpers.selectMethodMissing(context, self, entry.method.getVisibility(), name, callType).call(context, self, self.getMetaClass(), name, Block.NULL_BLOCK); }
public static IRubyObject invokeSuper(ThreadContext context, IRubyObject self, IRubyObject arg0, IRubyObject arg1, Block block) { checkSuperDisabledOrOutOfMethod(context); RubyModule klazz = context.getFrameKlazz(); String name = context.getFrameName(); RubyClass superClass = findImplementerIfNecessary(self.getMetaClass(), klazz).getSuperClass(); DynamicMethod method = superClass != null ? superClass.searchMethod(name) : UndefinedMethod.INSTANCE; if (method.isUndefined()) { return callMethodMissing(context, self, method.getVisibility(), name, CallType.SUPER, arg0, arg1, block); } return method.call(context, self, superClass, name, arg0, arg1, block); }
private LexerSource source(ThreadContext context, IRubyObject src, String filename, int lineno) { // FIXME: respond_to? returns private methods DynamicMethod method = src.getMetaClass().searchMethod("gets"); if (method.isUndefined() || method.getVisibility() == Visibility.PRIVATE) { return new ByteListLexerSource(filename, lineno, src.convertToString().getByteList(), null); } return new GetsLexerSource(filename, lineno, src, null); }