public Object visitDefinedNode(DefinedNode node) {
return createSingleTypeVertex(node, newInstanceOf(runtime.getString()));
}
public Object visitDefnNode(DefnNode node) {
RubyModule cbase = context.getCurrentScope().getModule();
RubyModule klass = context.getFrameModule();
String name = node.getName();
Node bodyNode = node.getBodyNode();
Node argsNode = node.getArgsNode();
Visibility visibility = context.getFrameVisibility();
boolean moduleFunction = visibility == Visibility.MODULE_FUNCTION;
if (name == "initialize" || name == "initialize_copy" || moduleFunction) {
visibility = Visibility.PRIVATE;
}
Method oldMethod = (Method) klass.getMethod(name);
Method newMethod = new DefaultMethod(cbase, name, bodyNode, argsNode, visibility, SourceLocation.of(node));
klass.addMethod(name, newMethod);
if (moduleFunction) {
Method singletonMethod = new DefaultMethod(cbase, name, bodyNode, argsNode, visibility, SourceLocation.of(node));
singletonMethod.setVisibility(Visibility.PUBLIC);
klass.getSingletonClass().addMethod(name, singletonMethod);
}
IRubyObject receiver = newInstanceOf((klass instanceof RubyClass) ? (RubyClass) klass : runtime.getObject());
RuntimeHelper.methodPartialUpdate(this, node, newMethod, oldMethod, receiver);