는 Rubinius 소스에서 모듈 등을 담당하는 코드는 어디? (특히, 객체 클래스의 슈퍼 클래스로 모듈을 배치 할 수 있습니다.)Rubinius에서 mixins은 어디에 구현 되었습니까?
3
A
답변
8
당신이 Module#include
에 대한 설명서를 보면, 당신은 찾을 수 있습니다 그것은 위임자는 Module#append_features
:
역순으로 각 매개 변수에
Module.append_features
을 호출합니다. 이 모듈은 다른에 포함되는 경우은 루비를 통과,이 모듈
append_features
호출
Module#append_features
에 대한 문서, 차례로, 기본 루비 믹스 인 알고리즘이 작동하는 방법 (매우 간략하게) 설명 수신 모듈은mod
입니다. 루비의 기본 구현은이 모듈이mod
이나 조상 중 하나에 아직 추가되지 않았다면이 모듈의 상수, 메소드 및 모듈 변수를mod
에 추가하는 것입니다.Module#include
도 참조하십시오.# Called when this Module is being included in another Module. # This may be overridden for custom behaviour. The default # is to add constants, instance methods and module variables # of this Module and all Modules that this one includes to +klass+. # # See also #include. # alias_method :append_features, :include_into
그래서 마지막으로
당신이 Rubinius sourcecode에Module#include_into
이 실제 거래는 다음과 같습니다 :Module#append_features
보면
, 당신은 Module#include_into
의 별칭 인 것을 확인할 수 있습니다
# Add all constants, instance methods and module variables # of this Module and all Modules that this one includes to +klass+ # # This method is aliased as append_features as the default implementation # for that method. Kernel#extend calls this method directly through # Module#extend_object, because Kernel#extend should not use append_features. def include_into(klass) ...
특정 질문 :
정확히
이 this loop에 대한 답변 개체 클래스의 슈퍼 클래스로 모듈을 배치 : insert_at
에 대한
k = klass.direct_superclass while k if k.kind_of? Rubinius::IncludedModule # Oh, we found it. if k == mod # ok, if we're still within the directly included modules # of klass, then put future things after mod, not at the # beginning. insert_at = k unless superclass_seen add = false break end else superclass_seen = true end k = k.direct_superclass end
시계.
+0
위대한 anwser! 감사! –
관련 문제
- 1. Java TextArea 페인트 메소드는 어디에 구현 되었습니까?
- 2. msleep은 어디에 선언 되었습니까?
- 3. DRV_QUERYFUNCTIONINSTANCEID가 어디에 선언 되었습니까?
- 4. Rubinius에서 __respond_to_eh__, 응?
- 5. 혜성은 어떻게 구현 되었습니까?
- 6. 어떤 로고가 구현 되었습니까?
- 7. bash에서 어떻게 구현되고 구현 되었습니까?
- 8. 왜 'is'가 'as'로 구현 되었습니까?
- 9. Digest :: SHA2.hexdigest()는 어디에 정의 되었습니까?
- 10. 다운로드 한 사운드 파일은 어디에 저장 되었습니까?
- 11. Photologue의 Photo.get_previous_by_date_added() 메소드는 어디에 정의 되었습니까?
- 12. drupal -----이 변수들은 어디에 선언 되었습니까?
- 13. 로컬 C++ 벡터의 메모리는 어디에 할당 되었습니까?
- 14. 레일 : "params"는 어디에 정의 되었습니까?
- 15. Java Process.getOutputStream()은 어떻게 구현 되었습니까?
- 16. WinAmp와 같은 미디어 라이브러리는 어떻게 구현 되었습니까?
- 17. cybersyn/cyberstride는 어떤 언어로 구현 되었습니까?
- 18. smtplib은 순수한 파이썬입니까? 아니면 C로 구현 되었습니까?
- 19. java-facebook-api : FB.Canvas.setAutoResize()가 구현 되었습니까?
- 20. List.Foreach (Delegate)는 Mono에서 구현 되었습니까?
- 21. Observer 패턴이 C#에서 델리게이트로 구현 되었습니까?
- 22. PKCS # 1 V2.0이 Java 용으로 구현 되었습니까?
- 23. Tie :: IxHash는 Perl로 어떻게 구현 되었습니까?
- 24. "만 센트"는 어떻게 구현 되었습니까?
- 25. 파이썬의 subprocess.call이 왜 이렇게 구현 되었습니까?
- 26. carmageddon 2의 자동차 물리학은 어떻게 구현 되었습니까?
- 27. Chrome에서 dataTransfer 객체가 부적절하게 구현 되었습니까?
- 28. 이 병렬 정렬 병합이 올바르게 구현 되었습니까?
- 29. 대화 범위가 CDI에서 어떻게 구현 되었습니까?
- 30. Java 내부 클래스 direclty가 Parameter Constructor로 구현 되었습니까?
나는 vm/builtin/*에 두려워하고 cpp로 작성됩니다. –
당신은 Rubinius의 차가움을 과소 평가합니다 :-) –