@TruffleBoundary protected InternalMethod doLookup(InternalMethod currentMethod, DynamicObject selfMetaClass) { assert RubyGuards.isRubyClass(selfMetaClass); InternalMethod superMethod = ModuleOperations.lookupSuperMethod(currentMethod, selfMetaClass); // TODO (eregon, 12 June 2015): Is this correct? if (superMethod != null && superMethod.isUndefined()) { superMethod = null; } return superMethod; }
@Specialization(guards = "isRubyModule(lexicalParentModule)") public Object defineModule(VirtualFrame frame, DynamicObject lexicalParentModule) { final RubyConstant constant = lookupForExistingModule(frame, name, lexicalParentModule); final DynamicObject definingModule; if (needToDefineProfile.profile(constant == null)) { definingModule = ModuleNodes.createModule( getContext(), coreLibrary().getModuleClass(), lexicalParentModule, name, this); } else { final Object constantValue = constant.getValue(); if (!RubyGuards.isRubyModule(constantValue) || RubyGuards.isRubyClass(constantValue)) { errorProfile.enter(); throw new RaiseException(coreExceptions().typeErrorIsNotA(name, "module", this)); } definingModule = (DynamicObject) constantValue; } return definingModule; }