@Override public RubySymbol execute(VirtualFrame frame) { notDesignedForCompilation(); final Object receiverObject = receiver.execute(frame); final RubyMethod methodObject = (RubyMethod) method.execute(frame); RubyModule module; if (receiverObject instanceof RubyModule) { module = (RubyModule) receiverObject; } else { module = ((RubyBasicObject) receiverObject).getSingletonClass(this); } final RubyMethod methodWithDeclaringModule = methodObject.withDeclaringModule(module); if (moduleFunctionFlag(frame)) { module.addMethod(this, methodWithDeclaringModule.withVisibility(Visibility.PRIVATE)); module .getSingletonClass(this) .addMethod(this, methodWithDeclaringModule.withVisibility(Visibility.PUBLIC)); } else { module.addMethod(this, methodWithDeclaringModule); } return getContext().newSymbol(method.getName()); }
@Override public Object execute(VirtualFrame frame) { // TODO(cs): can module ever not evaluate to a RubyModule? final RubyModule moduleObject = (RubyModule) module.execute(frame); final Object rhsValue = rhs.execute(frame); assert rhsValue != null; assert !(rhsValue instanceof String); moduleObject.setModuleConstant(name, rhsValue); return rhsValue; }