protected IRubyObject constantTableRemove(String name) {
return getConstantMapForWrite().remove(name);
}
private static void define(RubyModule module, JavaMethodDescriptor desc, DynamicMethod dynamicMethod) {
JRubyMethod jrubyMethod = desc.anno;
if (jrubyMethod.frame()) {
for (String name : jrubyMethod.name()) {
ASTInspector.FRAME_AWARE_METHODS.add(name);
}
}
if(jrubyMethod.compat() == BOTH ||
module.getRuntime().getInstanceConfig().getCompatVersion() == jrubyMethod.compat()) {
RubyModule singletonClass;
if (jrubyMethod.meta()) {
singletonClass = module.getSingletonClass();
dynamicMethod.setImplementationClass(singletonClass);
String baseName;
if (jrubyMethod.name().length == 0) {
baseName = desc.name;
singletonClass.addMethod(baseName, dynamicMethod);
} else {
baseName = jrubyMethod.name()[0];
for (String name : jrubyMethod.name()) {
singletonClass.addMethod(name, dynamicMethod);
}
}
if (jrubyMethod.alias().length > 0) {
for (String alias : jrubyMethod.alias()) {
singletonClass.defineAlias(alias, baseName);
}
}
} else {
String baseName;
if (jrubyMethod.name().length == 0) {
baseName = desc.name;
module.addMethod(baseName, dynamicMethod);
} else {
baseName = jrubyMethod.name()[0];
for (String name : jrubyMethod.name()) {
module.addMethod(name, dynamicMethod);
}
}
if (jrubyMethod.alias().length > 0) {
for (String alias : jrubyMethod.alias()) {
module.defineAlias(alias, baseName);
}
}
if (jrubyMethod.module()) {
singletonClass = module.getSingletonClass();
// module/singleton methods are all defined public
DynamicMethod moduleMethod = dynamicMethod.dup();
moduleMethod.setVisibility(PUBLIC);
if (jrubyMethod.name().length == 0) {
baseName = desc.name;
singletonClass.addMethod(desc.name, moduleMethod);
} else {
baseName = jrubyMethod.name()[0];
for (String name : jrubyMethod.name()) {
singletonClass.addMethod(name, moduleMethod);
}
}
if (jrubyMethod.alias().length > 0) {
for (String alias : jrubyMethod.alias()) {
singletonClass.defineAlias(alias, baseName);
}
}
}
}