本文整理了Java中org.jruby.RubyModule.getSuperClass
方法的一些代码示例,展示了RubyModule.getSuperClass
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。RubyModule.getSuperClass
方法的具体详情如下:
包路径:org.jruby.RubyModule
类名称:RubyModule
方法名:getSuperClass
[英]Getter for property superClass.
[中]属性超类的Getter。
代码示例来源:origin: org.jruby/jruby-complete
private boolean hasConstantInHierarchy(final String name) {
for (RubyModule p = this; p != null; p = p.getSuperClass()) {
if (p.hasConstant(name)) {
return true;
}
}
return false;
}
代码示例来源:origin: org.jruby/jruby-complete
/**
* Find the given class in this hierarchy, considering modules along the way.
*
* @param clazz the class to find
* @return The method, or UndefinedMethod if not found
*/
public RubyModule findImplementer(RubyModule clazz) {
for (RubyModule module = this; module != null; module = module.getSuperClass()) {
if (module.isSame(clazz)) return module;
}
return null;
}
代码示例来源:origin: org.jruby/jruby-complete
public boolean hasModuleInPrepends(RubyModule type) {
for (RubyModule module = this; module != methodLocation; module = module.getSuperClass()) {
if (type == module.getNonIncludedClass()) return true;
}
return false;
}
代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby
/**
* Find the given class in this hierarchy, considering modules along the way.
*
* @param clazz the class to find
* @return The method, or UndefinedMethod if not found
*/
public RubyModule findImplementer(RubyModule clazz) {
for (RubyModule module = this; module != null; module = module.getSuperClass()) {
if (module.isSame(clazz)) return module;
}
return null;
}
代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby
private boolean hasConstantInHierarchy(final String name) {
for (RubyModule p = this; p != null; p = p.getSuperClass()) {
if (p.hasConstant(name)) {
return true;
}
}
return false;
}
代码示例来源:origin: org.jruby/jruby-complete
public List<IRubyObject> getAncestorList() {
ArrayList<IRubyObject> list = new ArrayList<IRubyObject>();
for (RubyModule module = this; module != null; module = module.getSuperClass()) {
// FIXME this is silly. figure out how to delegate the getNonIncludedClass()
// call to drop the getDelegate().
if (module.methodLocation == module) list.add(module.getDelegate().getNonIncludedClass());
}
return list;
}
代码示例来源:origin: org.jruby/jruby-complete
private RubyClass getAlreadyActivatedRefinementWrapper(RubyClass classWeAreRefining, RubyModule refinement) {
// We have already encountered at least one refine on this class. Return that wrapper.
RubyClass moduleWrapperForRefinement = activatedRefinements.get(classWeAreRefining);
if (moduleWrapperForRefinement == null) return classWeAreRefining;
for (RubyModule c = moduleWrapperForRefinement; c != null && c.isIncluded(); c = c.getSuperClass()) {
if (c.getNonIncludedClass() == refinement) return null;
}
return moduleWrapperForRefinement;
}
代码示例来源:origin: org.jruby/jruby-complete
@JRubyMethod(name = "class_variable_defined?", required = 1)
public IRubyObject class_variable_defined_p(ThreadContext context, IRubyObject var) {
String id = validateClassVariable(context.runtime, var);
for (RubyModule module = this; module != null; module = module.getSuperClass()) {
if (module.hasClassVariable(id)) return context.tru;
}
return context.fals;
}
代码示例来源:origin: org.jruby/jruby-complete
@Override
protected void addMethodSymbols(Ruby runtime, Set<String> seen, RubyArray ary, boolean not, Visibility visibility) {
// IncludedModuleWrapper needs to search prepended modules too, so search until we find methodLocation
RubyModule module = origin;
RubyModule methodLoc = origin.getMethodLocation();
for (; module != methodLoc; module = module.getSuperClass()) {
module.addMethodSymbols(runtime, seen, ary, not, visibility);
}
// one last add for method location
module.addMethodSymbols(runtime, seen, ary, not, visibility);
}
}
代码示例来源:origin: org.jruby/jruby-complete
@JIT
public static IRubyObject isDefinedSuper(ThreadContext context, IRubyObject receiver, String frameName, RubyModule frameClass, IRubyObject definedMessage) {
boolean defined = frameName != null && frameClass != null &&
Helpers.findImplementerIfNecessary(receiver.getMetaClass(), frameClass).getSuperClass().isMethodBound(frameName, false);
return defined ? definedMessage : context.nil;
}
代码示例来源:origin: org.jruby/jruby-complete
@JRubyMethod
public IRubyObject super_method(ThreadContext context) {
RubyModule superClass = Helpers.findImplementerIfNecessary(receiver.getMetaClass(), implementationModule).getSuperClass();
return super_method(context, receiver, superClass);
}
代码示例来源:origin: org.jruby/jruby-complete
@Interp
public static IRubyObject instanceSuper(ThreadContext context, IRubyObject self, String id, RubyModule definingModule, IRubyObject[] args, Block block) {
RubyClass superClass = definingModule.getMethodLocation().getSuperClass();
DynamicMethod method = superClass != null ? superClass.searchMethod(id) : UndefinedMethod.INSTANCE;
IRubyObject rVal = method.isUndefined() ?
Helpers.callMethodMissing(context, self, method.getVisibility(), id, CallType.SUPER, args, block)
: method.call(context, self, superClass, id, args, block);
return rVal;
}
代码示例来源:origin: org.jruby/jruby-core
private void checkSafeTypeToCopy(RubyClass original) {
Ruby runtime = getRuntime();
if (original == runtime.getBasicObject()) throw runtime.newTypeError("can't copy the root class");
if (getSuperClass() == runtime.getBasicObject()) throw runtime.newTypeError("already initialized class");
if (original.isSingleton()) throw runtime.newTypeError("can't copy singleton class");
}
代码示例来源:origin: org.jruby/jruby-complete
public static IRubyObject invokeSuper(ThreadContext context, IRubyObject self, RubyModule klass, String name, IRubyObject[] args, Block block) {
checkSuperDisabledOrOutOfMethod(context, klass, name);
RubyClass selfClass = getMetaClass(self);
RubyClass superClass = findImplementerIfNecessary(selfClass, klass).getSuperClass();
DynamicMethod method = superClass != null ? superClass.searchMethod(name) : UndefinedMethod.INSTANCE;
if (method.isUndefined()) {
return callMethodMissing(context, self, selfClass, method.getVisibility(), name, CallType.SUPER, args, block);
}
return method.call(context, self, superClass, name, args, block);
}
代码示例来源:origin: org.jruby/jruby-complete
@Interp
public static IRubyObject classSuper(ThreadContext context, IRubyObject self, String id, RubyModule definingModule, IRubyObject[] args, Block block) {
RubyClass superClass = definingModule.getMetaClass().getMethodLocation().getSuperClass();
DynamicMethod method = superClass != null ? superClass.searchMethod(id) : UndefinedMethod.INSTANCE;
IRubyObject rVal = method.isUndefined() ?
Helpers.callMethodMissing(context, self, method.getVisibility(), id, CallType.SUPER, args, block)
: method.call(context, self, superClass, id, args, block);
return rVal;
}
代码示例来源:origin: org.jruby/jruby-complete
public static IRubyObject invokeSuper(ThreadContext context, IRubyObject self, RubyModule klass, String name, IRubyObject arg0, Block block) {
checkSuperDisabledOrOutOfMethod(context, klass, name);
RubyClass selfClass = getMetaClass(self);
RubyClass superClass = findImplementerIfNecessary(selfClass, klass).getSuperClass();
DynamicMethod method = superClass != null ? superClass.searchMethod(name) : UndefinedMethod.INSTANCE;
if (method.isUndefined()) {
return callMethodMissing(context, self, selfClass, method.getVisibility(), name, CallType.SUPER, arg0, block);
}
return method.call(context, self, superClass, name, arg0, block);
}
代码示例来源:origin: org.jruby/jruby-complete
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 selfClass = getMetaClass(self);
RubyClass superClass = findImplementerIfNecessary(selfClass, klazz).getSuperClass();
DynamicMethod method = superClass != null ? superClass.searchMethod(name) : UndefinedMethod.INSTANCE;
if (method.isUndefined()) {
return callMethodMissing(context, self, selfClass, method.getVisibility(), name, CallType.SUPER, arg0, arg1, block);
}
return method.call(context, self, superClass, name, arg0, arg1, block);
}
代码示例来源:origin: org.jruby/jruby-complete
public static IRubyObject invokeSuper(ThreadContext context, IRubyObject self, IRubyObject arg0, IRubyObject arg1, IRubyObject arg2, Block block) {
checkSuperDisabledOrOutOfMethod(context);
RubyModule klazz = context.getFrameKlazz();
String name = context.getFrameName();
RubyClass selfClass = getMetaClass(self);
RubyClass superClass = findImplementerIfNecessary(selfClass, klazz).getSuperClass();
DynamicMethod method = superClass != null ? superClass.searchMethod(name) : UndefinedMethod.INSTANCE;
if (method.isUndefined()) {
return callMethodMissing(context, self, selfClass, method.getVisibility(), name, CallType.SUPER, arg0, arg1, arg2, block);
}
return method.call(context, self, superClass, name, arg0, arg1, arg2, block);
}
代码示例来源:origin: org.jruby/jruby-core
public static IRubyObject invokeSuper(ThreadContext context, IRubyObject self, IRubyObject arg0, IRubyObject arg1, IRubyObject arg2, Block block) {
checkSuperDisabledOrOutOfMethod(context);
RubyModule klazz = context.getFrameKlazz();
String name = context.getFrameName();
RubyClass selfClass = getMetaClass(self);
RubyClass superClass = findImplementerIfNecessary(selfClass, klazz).getSuperClass();
DynamicMethod method = superClass != null ? superClass.searchMethod(name) : UndefinedMethod.INSTANCE;
if (method.isUndefined()) {
return callMethodMissing(context, self, selfClass, method.getVisibility(), name, CallType.SUPER, arg0, arg1, arg2, block);
}
return method.call(context, self, superClass, name, arg0, arg1, arg2, block);
}
代码示例来源:origin: org.jruby/jruby-complete
public static IRubyObject invokeSuper(ThreadContext context, IRubyObject self, IRubyObject arg0, Block block) {
checkSuperDisabledOrOutOfMethod(context);
RubyModule klazz = context.getFrameKlazz();
String name = context.getFrameName();
RubyClass selfClass = getMetaClass(self);
RubyClass superClass = findImplementerIfNecessary(selfClass, klazz).getSuperClass();
DynamicMethod method = superClass != null ? superClass.searchMethod(name) : UndefinedMethod.INSTANCE;
if (method.isUndefined()) {
return callMethodMissing(context, self, selfClass, method.getVisibility(), name, CallType.SUPER, arg0, block);
}
return method.call(context, self, superClass, name, arg0, block);
}
内容来源于网络,如有侵权,请联系作者删除!