public IRubyObject finvoke(ThreadContext context, IRubyObject self, String name) { DynamicMethod method = searchMethod(name); if (shouldCallMethodMissing(method)) { return Helpers.callMethodMissing(context, self, this, method.getVisibility(), name, CallType.FUNCTIONAL, Block.NULL_BLOCK); } return method.call(context, self, this, name); }
public IRubyObject invokeInherited(ThreadContext context, IRubyObject self, IRubyObject subclass) { DynamicMethod method = getMetaClass().searchMethod("inherited"); if (method.isUndefined()) { return Helpers.callMethodMissing(context, self, method.getVisibility(), "inherited", CallType.FUNCTIONAL, Block.NULL_BLOCK); } return method.call(context, self, getMetaClass(), "inherited", subclass, Block.NULL_BLOCK); }
private RubyBoolean checkMetaClassBoundMethod(final ThreadContext context, final String name, final boolean includePrivate) { // getMetaClass().isMethodBound(name, !includePrivate, true) DynamicMethod method = getMetaClass().searchMethod(name); if ( ! method.isUndefined() && ! method.isNotImplemented() ) { if ( ! includePrivate && method.getVisibility() == PRIVATE ) { return context.fals; } return context.tru; } return null; }
private void putPointer(ThreadContext context, long offset, IRubyObject value) { DynamicMethod conversionMethod; if (value instanceof Pointer) { putPointer(context, offset, (Pointer) value); } else if (value.isNil()) { getMemoryIO().putAddress(offset, 0L); } else if (!(conversionMethod = value.getMetaClass().searchMethod("to_ptr")).isUndefined()) { putPointer(context, offset, conversionMethod.call(context, value, value.getMetaClass(), "to_ptr")); } else { throw context.runtime.newTypeError(value, context.runtime.getFFI().pointerClass); } }
public static DynamicMethod selectMethodMissing(ThreadContext context, RubyClass selfClass, Visibility visibility, String name, CallType callType) { final Ruby runtime = context.runtime; if (name.equals("method_missing")) { return selectInternalMM(runtime, visibility, callType); } DynamicMethod methodMissing = selfClass.searchMethod("method_missing"); if (methodMissing.isUndefined() || methodMissing.equals(runtime.getDefaultMethodMissing())) { return selectInternalMM(runtime, visibility, callType); } return new MethodMissingMethod(methodMissing, visibility, callType); }
/** * 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, Block block) { DynamicMethod method = searchMethod(name); if (shouldCallMethodMissing(method, name, caller, callType)) { return Helpers.callMethodMissing(context, self, this, method.getVisibility(), name, callType, block); } return method.call(context, self, this, name, block); }
public IRubyObject invokeInherited(ThreadContext context, IRubyObject self, IRubyObject subclass) { DynamicMethod method = getMetaClass().searchMethod("inherited"); if (method.isUndefined()) { return Helpers.callMethodMissing(context, self, method.getVisibility(), "inherited", CallType.FUNCTIONAL, Block.NULL_BLOCK); } return method.call(context, self, getMetaClass(), "inherited", subclass, Block.NULL_BLOCK); }
private void putPointer(ThreadContext context, long offset, IRubyObject value) { DynamicMethod conversionMethod; if (value instanceof Pointer) { putPointer(context, offset, (Pointer) value); } else if (value.isNil()) { getMemoryIO().putAddress(offset, 0L); } else if (!(conversionMethod = value.getMetaClass().searchMethod("to_ptr")).isUndefined()) { putPointer(context, offset, conversionMethod.call(context, value, value.getMetaClass(), "to_ptr")); } else { throw context.runtime.newTypeError(value, context.runtime.getFFI().pointerClass); } }
private RubyBoolean checkMetaClassBoundMethod(final ThreadContext context, final String name, final boolean includePrivate) { // getMetaClass().isMethodBound(name, !includePrivate, true) DynamicMethod method = getMetaClass().searchMethod(name); if ( ! method.isUndefined() && ! method.isNotImplemented() ) { if ( ! includePrivate && method.getVisibility() == PRIVATE ) { return context.fals; } return context.tru; } return null; }
public static DynamicMethod selectMethodMissing(ThreadContext context, IRubyObject receiver, Visibility visibility, String name, CallType callType) { Ruby runtime = context.runtime; if (name.equals("method_missing")) { return selectInternalMM(runtime, visibility, callType); } DynamicMethod methodMissing = receiver.getMetaClass().searchMethod("method_missing"); if (methodMissing.isUndefined() || methodMissing.equals(runtime.getDefaultMethodMissing())) { return selectInternalMM(runtime, visibility, callType); } return new MethodMissingMethod(methodMissing, visibility, callType); }
/** * 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, IRubyObject arg, Block block) { DynamicMethod method = searchMethod(name); if (shouldCallMethodMissing(method, name, caller, callType)) { return Helpers.callMethodMissing(context, self, this, method.getVisibility(), name, callType, arg, block); } return method.call(context, self, this, name, arg, block); }
public IRubyObject invokeInherited(ThreadContext context, IRubyObject self, IRubyObject subclass) { DynamicMethod method = getMetaClass().searchMethod("inherited"); if (method.isUndefined()) { return Helpers.callMethodMissing(context, self, method.getVisibility(), "inherited", CallType.FUNCTIONAL, Block.NULL_BLOCK); } return method.call(context, self, getMetaClass(), "inherited", subclass, Block.NULL_BLOCK); }
private void putPointer(ThreadContext context, long offset, IRubyObject value) { DynamicMethod conversionMethod; if (value instanceof Pointer) { putPointer(context, offset, (Pointer) value); } else if (value.isNil()) { getMemoryIO().putAddress(offset, 0L); } else if (!(conversionMethod = value.getMetaClass().searchMethod("to_ptr")).isUndefined()) { putPointer(context, offset, conversionMethod.call(context, value, value.getMetaClass(), "to_ptr")); } else { throw context.runtime.newTypeError(value, context.runtime.getFFI().pointerClass); } }
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); }
public static DynamicMethod selectMethodMissing(RubyClass selfClass, Visibility visibility, String name, CallType callType) { Ruby runtime = selfClass.getClassRuntime(); if (name.equals("method_missing")) { return selectInternalMM(runtime, visibility, callType); } DynamicMethod methodMissing = selfClass.searchMethod("method_missing"); if (methodMissing.isUndefined() || methodMissing.equals(runtime.getDefaultMethodMissing())) { return selectInternalMM(runtime, visibility, callType); } return new MethodMissingMethod(methodMissing, visibility, callType); }
/** * 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, IRubyObject[] args) { assert args != null; DynamicMethod method = searchMethod(name); if (shouldCallMethodMissing(method, name, caller, callType)) { return Helpers.callMethodMissing(context, self, this, method.getVisibility(), name, callType, args, Block.NULL_BLOCK); } return method.call(context, self, this, name, args); }
public IRubyObject invokeInherited(ThreadContext context, IRubyObject self, IRubyObject subclass) { DynamicMethod method = getMetaClass().searchMethod("inherited"); if (method.isUndefined()) { return Helpers.callMethodMissing(context, self, method.getVisibility(), "inherited", CallType.FUNCTIONAL, Block.NULL_BLOCK); } return method.call(context, self, getMetaClass(), "inherited", subclass, Block.NULL_BLOCK); }
private void putPointer(ThreadContext context, long offset, IRubyObject value) { DynamicMethod conversionMethod; if (value instanceof Pointer) { putPointer(context, offset, (Pointer) value); } else if (value.isNil()) { getMemoryIO().putAddress(offset, 0L); } else if (!(conversionMethod = value.getMetaClass().searchMethod("to_ptr")).isUndefined()) { putPointer(context, offset, conversionMethod.call(context, value, value.getMetaClass(), "to_ptr")); } else { throw context.runtime.newTypeError(value, context.runtime.getFFI().pointerClass); } }
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); }
private DynamicMethod deepMethodSearch(String id, Ruby runtime) { DynamicMethod method = searchMethod(id); if (method.isUndefined() && isModule()) method = runtime.getObject().searchMethod(id); if (method.isUndefined()) { RubySymbol name = runtime.newSymbol(id); throw runtime.newNameError(undefinedMethodMessage(runtime, name, rubyName(), isModule()), id); } return method; }