source • Put a first book in C-language beside of you (ask your friends or Google about good book.) > git clone https://github.com/ruby/ruby ϧϏʔͷιʔείʔυΛखʹೖΕΔ
klass RBasic VALUE RArray flags klass RBasic integer value Flags RObject built-in Object FIXNUM_FLAG : 1 simple ruby value RObject numiv ivptr VALUE flags klass RBasic and RRegexp etc… built-in objects and Symbol ect… Simple values
a Microscopeʱ • translators: Koji Shimada Shintaro Kakutani • ൃߦɿΦʔϜࣾ։ൃ෦ • ץߦ༧ఆɿ2014ळ • I joins as one of reviewers. * ΖΖௐதͷͨΊ·ͩΦʔϜࣾʹ͓͍߹Θͤ͠ͳ͍Ͱ͍ͩ͘͞
Original is written in Japanese, and is translated into English. All contents are available at http://ruby-hacking- guide.github.io/ • Talking about very details on Ruby source code and implementation. • about Ruby ver. 1.7.3… old, but Very Very Useful!!
“How to read source codes” • making a method simple by cutting not essential code off. • understanding object structure before. • and many other wisdoms • It was written for C-programmers. But non C-programmer can learn Basic C essence for reading Ruby Implementation. essence
Ruby is improving. • While reading Ruby source code with RHG, you will find a difference between the description and the current code. => This is a chance to know Why the source has been changed. It’s a trace of improvement of ruby. You can trace it by ChangeLog and <git log> with its commit message.
=> Of cause c code xx.h => header file. Many definitions such as macros, data-structures. xx.y => only parse.y (grammar definition) xx.rb => Of cause ruby file. xx.def => miscellaneous definitions
files. /defs/ … definition files such as keywords, errors… /ext/ … c extensions such as json, socket… /lib/ …ruby libraries such as csv, irb, yaml, rake… /missing/ …implements of C functions need for ruby, but not all Systems have. /test/ … test codes for ruby implementations. /spec/ … RubySpec will be downloaded here. Special directories.
it is easy to find where a method is defined. What Hash#to_a does…? 'PSFYBNQMF JGPOFEBZ*TUBSUUPXPOEFSJOH BOEDBOOPUTMFFQXFMM See “hash.c”, Of course. and GoodNight.
\ 7"-6&BSZ ! BSZSC@BSZ@OFX@DBQB 3)"4)@4*;& IBTI SC@IBTI@GPSFBDI IBTI UP@B@J BSZ 0#+@*/'&$5 BSZ IBTI ! SFUVSOBSZ ^ SC@EFpOF@NFUIPE SC@D)BTI UP@B SC@IBTI@UP@B klass method_name function init arg function name is put on the head of line to search easily. make new array with hash size convert hash’s each pair to array Macro often defined in ***.h. but I can imagine how work from name…
(big) num_entries st_table_entry hash key record next fore back 1 2 3 4 next next fore back (hash is ordered from Ruby 1.9~) 5 6 7 entries_packed (0) back