summaryrefslogtreecommitdiff
path: root/bin/racc
diff options
context:
space:
mode:
authorKazuhiro NISHIYAMA <zn@mbf.nifty.com>2021-01-29 11:59:42 +0900
committerKazuhiro NISHIYAMA <zn@mbf.nifty.com>2021-01-29 11:59:42 +0900
commitacb6b395b63ff992ea89ef4dbdff32e5b54e0b20 (patch)
tree21a38083770f20f17d49c9e08417310cd743ee0a /bin/racc
parent522adbc945c209f4993b0d0ee84a44c333de350f (diff)
Fix failure when build in srcdir/build
If `build` directory exists, `rake build` is `Rake::FileTask`. So skip if exists.
Diffstat (limited to 'bin/racc')
0 files changed, 0 insertions, 0 deletions
'upd'>.git-blame-ignore-revs5
-rw-r--r--.github/actions/setup/directories/action.yml137
-rw-r--r--.github/actions/setup/macos/action.yml24
-rw-r--r--.github/actions/setup/ubuntu/action.yml53
-rw-r--r--.github/actions/slack/action.yml39
-rw-r--r--.github/auto_request_review.yml1
-rw-r--r--.github/codeql/codeql-config.yml3
-rw-r--r--.github/dependabot.yml4
-rw-r--r--.github/workflows/annocheck.yml126
-rw-r--r--.github/workflows/auto_request_review.yml4
-rw-r--r--.github/workflows/baseruby.yml64
-rw-r--r--.github/workflows/bundled_gems.yml108
-rw-r--r--.github/workflows/check_dependencies.yml66
-rw-r--r--.github/workflows/check_misc.yml80
-rw-r--r--.github/workflows/cirrus-notify.yml46
-rw-r--r--.github/workflows/codeql-analysis.yml135
-rw-r--r--.github/workflows/compilers.yml168
-rw-r--r--.github/workflows/dependabot_automerge.yml30
-rw-r--r--.github/workflows/macos.yml115
-rw-r--r--.github/workflows/mingw.yml141
-rw-r--r--.github/workflows/mjit-bindgen.yml97
-rw-r--r--.github/workflows/mjit.yml103
-rw-r--r--.github/workflows/rjit-bindgen.yml91
-rw-r--r--.github/workflows/rjit.yml120
-rw-r--r--.github/workflows/scorecards.yml28
-rw-r--r--.github/workflows/spec_guards.yml39
-rw-r--r--.github/workflows/ubuntu.yml129
-rw-r--r--.github/workflows/wasm.yml105
-rw-r--r--.github/workflows/windows.yml142
-rw-r--r--.github/workflows/yjit-macos.yml151
-rw-r--r--.github/workflows/yjit-ubuntu.yml177
-rw-r--r--.gitignore38
-rw-r--r--.travis.yml205
-rw-r--r--NEWS.md503
-rw-r--r--README.ja.md16
-rw-r--r--README.md20
-rw-r--r--addr2line.c819
-rw-r--r--addr2line.h4
-rw-r--r--array.c704
-rw-r--r--array.rb88
-rw-r--r--ast.c284
-rw-r--r--ast.rb20
-rw-r--r--benchmark/enum_sort_by.yml53
-rw-r--r--benchmark/lib/benchmark_driver/runner/mjit.rb34
-rw-r--r--benchmark/mjit_exivar.yml18
-rw-r--r--benchmark/mjit_integer.yml32
-rw-r--r--benchmark/mjit_kernel.yml20
-rw-r--r--benchmark/mjit_leave.yml8
-rw-r--r--benchmark/mjit_opt_cc_insns.yml27
-rw-r--r--benchmark/mjit_struct_aref.yml10
-rw-r--r--benchmark/range_bsearch_bignum.yml10
-rw-r--r--benchmark/range_bsearch_endpointless.yml21
-rw-r--r--benchmark/range_bsearch_fixnum.yml10
-rw-r--r--benchmark/range_count.yml11
-rw-r--r--benchmark/range_overlap.yml19
-rw-r--r--benchmark/range_reverse_each.yml16
-rw-r--r--benchmark/regexp_dup.yml6
-rw-r--r--benchmark/regexp_new.yml7
-rw-r--r--benchmark/so_count_words.yml33
-rw-r--r--benchmark/so_meteor_contest.rb2
-rw-r--r--benchmark/string_dup.yml7
-rw-r--r--benchmark/string_rpartition.yml18
-rw-r--r--benchmark/struct_accessor.yml25
-rw-r--r--benchmark/vm_call_bmethod.yml37
-rw-r--r--benchmark/vm_call_method_missing.yml62
-rw-r--r--benchmark/vm_call_send_iseq.yml77
-rw-r--r--benchmark/vm_call_symproc.yml83
-rw-r--r--benchmark/vm_ivar_ic_miss.yml20
-rw-r--r--benchmark/vm_ivar_memoize.yml85
-rw-r--r--benchmark/vm_method_splat_calls.yml13
-rw-r--r--benchmark/vm_send_cfunc.yml15
-rw-r--r--bignum.c21
-rwxr-xr-xbin/gem2
-rwxr-xr-xbootstraptest/runner.rb18
-rw-r--r--bootstraptest/test_eval.rb10
-rw-r--r--bootstraptest/test_gc.rb2
-rw-r--r--bootstraptest/test_insns.rb14
-rw-r--r--bootstraptest/test_load.rb2
-rw-r--r--bootstraptest/test_method.rb9
-rw-r--r--bootstraptest/test_ractor.rb188
-rw-r--r--bootstraptest/test_rjit.rb58
-rw-r--r--bootstraptest/test_syntax.rb4
-rw-r--r--bootstraptest/test_thread.rb18
-rw-r--r--bootstraptest/test_yjit.rb869
-rw-r--r--builtin.c15
-rw-r--r--builtin.h6
-rw-r--r--ccan/list/list.h6
-rw-r--r--class.c138
-rw-r--r--common.mk4179
-rw-r--r--compar.c25
-rw-r--r--compile.c2274
-rw-r--r--complex.c836
-rw-r--r--configure.ac318
-rw-r--r--constant.h2
-rw-r--r--cont.c262
-rw-r--r--coroutine/amd64/Context.S42
-rw-r--r--coroutine/arm64/Context.S67
-rw-r--r--coroutine/arm64/Context.h24
-rw-r--r--coroutine/loongarch64/Context.S73
-rw-r--r--coroutine/loongarch64/Context.h46
-rw-r--r--coroutine/ppc/Context.S2
-rw-r--r--coroutine/ppc/Context.h2
-rw-r--r--coroutine/ppc64/Context.h2
-rw-r--r--cygwin/GNUmakefile.in12
-rw-r--r--darray.h183
-rw-r--r--debug.c140
-rw-r--r--debug_counter.c2
-rw-r--r--debug_counter.h59
-rw-r--r--defs/gmake.mk138
-rw-r--r--defs/id.def2
-rw-r--r--defs/tags.mk18
-rw-r--r--defs/universal.mk5
-rw-r--r--dir.c853
-rw-r--r--dir.rb377
-rw-r--r--dln.c80
-rw-r--r--dln.h1
-rw-r--r--dln_find.c2
-rw-r--r--dmydln.c9
-rw-r--r--doc/.document5
-rw-r--r--doc/ChangeLog/ChangeLog-0.06_to_0.52 (renamed from doc/ChangeLog-0.06_to_0.52)0
-rw-r--r--doc/ChangeLog/ChangeLog-0.50_to_0.60 (renamed from doc/ChangeLog-0.50_to_0.60)0
-rw-r--r--doc/ChangeLog/ChangeLog-0.60_to_1.1 (renamed from doc/ChangeLog-0.60_to_1.1)0
-rw-r--r--doc/ChangeLog/ChangeLog-1.8.0 (renamed from doc/ChangeLog-1.8.0)0
-rw-r--r--doc/ChangeLog/ChangeLog-1.9.3 (renamed from doc/ChangeLog-1.9.3)0
-rw-r--r--doc/ChangeLog/ChangeLog-2.0.0 (renamed from doc/ChangeLog-2.0.0)0
-rw-r--r--doc/ChangeLog/ChangeLog-2.1.0 (renamed from doc/ChangeLog-2.1.0)0
-rw-r--r--doc/ChangeLog/ChangeLog-2.2.0 (renamed from doc/ChangeLog-2.2.0)0
-rw-r--r--doc/ChangeLog/ChangeLog-2.3.0 (renamed from doc/ChangeLog-2.3.0)0
-rw-r--r--doc/ChangeLog/ChangeLog-2.4.0 (renamed from doc/ChangeLog-2.4.0)0
-rw-r--r--doc/ChangeLog/ChangeLog-YARV (renamed from doc/ChangeLog-YARV)0
-rw-r--r--doc/_regexp.rdoc1276
-rw-r--r--doc/_timezones.rdoc156
-rw-r--r--doc/bsearch.rdoc2
-rw-r--r--doc/case_mapping.rdoc6
-rw-r--r--doc/character_selectors.rdoc6
-rw-r--r--doc/command_injection.rdoc4
-rw-r--r--doc/contributing/building_ruby.md80
-rw-r--r--doc/contributing/documentation_guide.md144
-rw-r--r--doc/contributing/glossary.md41
-rw-r--r--doc/contributing/making_changes_to_stdlibs.md2
-rw-r--r--doc/contributing/testing_ruby.md36
-rw-r--r--doc/csv/options/common/col_sep.rdoc6
-rw-r--r--doc/csv/options/common/row_sep.rdoc9
-rw-r--r--doc/csv/options/generating/write_converters.rdoc8
-rw-r--r--doc/csv/options/generating/write_headers.rdoc2
-rw-r--r--doc/csv/options/parsing/liberal_parsing.rdoc23
-rw-r--r--doc/csv/recipes/filtering.rdoc2
-rw-r--r--doc/csv/recipes/generating.rdoc4
-rw-r--r--doc/csv/recipes/parsing.rdoc4
-rw-r--r--doc/csv/recipes/recipes.rdoc2
-rw-r--r--doc/distribution.md22
-rw-r--r--doc/encodings.rdoc48
-rw-r--r--doc/extension.rdoc57
-rw-r--r--doc/format_specifications.rdoc58
-rw-r--r--doc/globals.rdoc491
-rw-r--r--doc/implicit_conversion.rdoc10
-rw-r--r--doc/irb/indexes.md192
-rw-r--r--doc/irb/irb.rd.ja4
-rw-r--r--doc/keywords.rdoc2
-rw-r--r--doc/maintainers.md520
-rw-r--r--doc/maintainers.rdoc424
-rw-r--r--doc/mjit/mjit.md39
-rw-r--r--doc/net-http/included_setters.rdoc3
-rw-r--r--doc/optparse/argument_converters.rdoc70
-rw-r--r--doc/optparse/option_params.rdoc4
-rw-r--r--doc/optparse/tutorial.rdoc70
-rw-r--r--doc/packed_data.rdoc87
-rw-r--r--doc/rdoc/markup_reference.rb47
-rw-r--r--doc/regexp.rdoc810
-rw-r--r--doc/regexp/methods.rdoc41
-rw-r--r--doc/regexp/unicode_properties.rdoc678
-rw-r--r--doc/reline/face.md111
-rw-r--r--doc/rjit/rjit.md45
-rw-r--r--doc/standard_library.rdoc18
-rw-r--r--doc/strftime_formatting.rdoc48
-rw-r--r--doc/string/length.rdoc1
-rw-r--r--doc/syntax.rdoc3
-rw-r--r--doc/syntax/assignment.rdoc4
-rw-r--r--doc/syntax/calling_methods.rdoc12
-rw-r--r--doc/syntax/comments.rdoc2
-rw-r--r--doc/syntax/control_expressions.rdoc68
-rw-r--r--doc/syntax/literals.rdoc18
-rw-r--r--doc/syntax/modules_and_classes.rdoc28
-rw-r--r--doc/syntax/operators.rdoc75
-rw-r--r--doc/syntax/pattern_matching.rdoc28
-rw-r--r--doc/syntax/refinements.rdoc2
-rw-r--r--doc/timezones.rdoc108
-rw-r--r--doc/windows.md11
-rw-r--r--doc/yjit/yjit.md227
-rw-r--r--enc/cesu_8.c23
-rw-r--r--enc/depend206
-rw-r--r--enc/unicode/15.0.0/name2ctype.h2
-rw-r--r--encoding.c29
-rw-r--r--enum.c263
-rw-r--r--enumerator.c210
-rw-r--r--error.c521
-rw-r--r--eval.c61
-rw-r--r--eval_error.c33
-rw-r--r--eval_intern.h8
-rw-r--r--ext/-test-/RUBY_ALIGNOF/depend3
-rw-r--r--ext/-test-/arith_seq/beg_len_step/depend3
-rw-r--r--ext/-test-/arith_seq/extract/depend3
-rw-r--r--ext/-test-/array/concat/depend3
-rw-r--r--ext/-test-/array/resize/depend3
-rw-r--r--ext/-test-/bignum/depend21
-rw-r--r--ext/-test-/bug-14834/depend3
-rw-r--r--ext/-test-/bug-3571/depend3
-rw-r--r--ext/-test-/bug-5832/depend3
-rw-r--r--ext/-test-/bug_reporter/depend3
-rw-r--r--ext/-test-/class/depend6
-rw-r--r--ext/-test-/debug/depend9
-rw-r--r--ext/-test-/debug/profile_frames.c21
-rw-r--r--ext/-test-/dln/empty/depend3
-rw-r--r--ext/-test-/enumerator_kw/depend3
-rw-r--r--ext/-test-/exception/depend12
-rw-r--r--ext/-test-/fatal/depend3
-rw-r--r--ext/-test-/file/depend9
-rw-r--r--ext/-test-/float/depend6
-rw-r--r--ext/-test-/funcall/depend3
-rw-r--r--ext/-test-/gvl/call_without_gvl/depend3
-rw-r--r--ext/-test-/hash/depend6
-rw-r--r--ext/-test-/integer/depend9
-rw-r--r--ext/-test-/iseq_load/depend3
-rw-r--r--ext/-test-/iter/depend9
-rw-r--r--ext/-test-/load/dot.dot/depend3
-rw-r--r--ext/-test-/load/protect/depend3
-rw-r--r--ext/-test-/load/resolve_symbol_resolver/extconf.rb1
-rw-r--r--ext/-test-/load/resolve_symbol_resolver/resolve_symbol_resolver.c55
-rw-r--r--ext/-test-/load/resolve_symbol_target/extconf.rb1
-rw-r--r--ext/-test-/load/resolve_symbol_target/resolve_symbol_target.c15
-rw-r--r--ext/-test-/load/resolve_symbol_target/resolve_symbol_target.def4
-rw-r--r--ext/-test-/load/resolve_symbol_target/resolve_symbol_target.h4
-rw-r--r--ext/-test-/load/stringify_symbols/extconf.rb1
-rw-r--r--ext/-test-/load/stringify_symbols/stringify_symbols.c29
-rw-r--r--ext/-test-/load/stringify_target/extconf.rb1
-rw-r--r--ext/-test-/load/stringify_target/stringify_target.c15
-rw-r--r--ext/-test-/load/stringify_target/stringify_target.def4
-rw-r--r--ext/-test-/load/stringify_target/stringify_target.h4
-rw-r--r--ext/-test-/marshal/compat/depend3
-rw-r--r--ext/-test-/marshal/internal_ivar/depend3
-rw-r--r--ext/-test-/marshal/usr/depend3
-rw-r--r--ext/-test-/memory_status/depend3
-rw-r--r--ext/-test-/memory_view/depend3
-rw-r--r--ext/-test-/method/depend6
-rw-r--r--ext/-test-/notimplement/depend3
-rw-r--r--ext/-test-/num2int/depend3
-rw-r--r--ext/-test-/path_to_class/depend3
-rw-r--r--ext/-test-/popen_deadlock/depend3
-rw-r--r--ext/-test-/postponed_job/depend3
-rw-r--r--ext/-test-/postponed_job/postponed_job.c131
-rw-r--r--ext/-test-/printf/depend3
-rw-r--r--ext/-test-/proc/depend9
-rw-r--r--ext/-test-/random/depend9
-rw-r--r--ext/-test-/rational/depend3
-rw-r--r--ext/-test-/rb_call_super_kw/depend3
-rw-r--r--ext/-test-/recursion/depend3
-rw-r--r--ext/-test-/regexp/depend6
-rw-r--r--ext/-test-/scan_args/depend3
-rw-r--r--ext/-test-/st/foreach/depend3
-rw-r--r--ext/-test-/st/foreach/foreach.c30
-rw-r--r--ext/-test-/st/numhash/depend3
-rw-r--r--ext/-test-/st/update/depend3
-rw-r--r--ext/-test-/string/cstr.c14
-rw-r--r--ext/-test-/string/depend54
-rw-r--r--ext/-test-/string/fstring.c10
-rw-r--r--ext/-test-/string/set_len.c10
-rw-r--r--ext/-test-/struct/data.c13
-rw-r--r--ext/-test-/struct/depend171
-rw-r--r--ext/-test-/symbol/depend6
-rw-r--r--ext/-test-/thread/instrumentation/depend3
-rw-r--r--ext/-test-/thread/instrumentation/instrumentation.c215
-rw-r--r--ext/-test-/thread_fd/depend3
-rw-r--r--ext/-test-/time/depend9
-rw-r--r--ext/-test-/tracepoint/depend6
-rw-r--r--ext/-test-/tracepoint/gc_hook.c4
-rw-r--r--ext/-test-/typeddata/depend3
-rw-r--r--ext/-test-/vm/depend3
-rw-r--r--ext/-test-/wait/depend3
-rw-r--r--ext/.document3
-rw-r--r--ext/Setup.atheos2
-rw-r--r--ext/Setup.nt2
-rw-r--r--ext/bigdecimal/bigdecimal.c170
-rw-r--r--ext/bigdecimal/bigdecimal.gemspec40
-rw-r--r--ext/bigdecimal/depend7
-rw-r--r--ext/bigdecimal/extconf.rb25
-rw-r--r--ext/bigdecimal/lib/bigdecimal.rb6
-rw-r--r--ext/bigdecimal/lib/bigdecimal/util.rb10
-rw-r--r--ext/cgi/escape/depend3
-rw-r--r--ext/cgi/escape/escape.c35
-rw-r--r--ext/cgi/escape/extconf.rb6
-rw-r--r--ext/continuation/depend3
-rw-r--r--ext/coverage/coverage.c2
-rw-r--r--ext/coverage/depend17
-rw-r--r--ext/date/date_core.c23
-rw-r--r--ext/date/depend12
-rw-r--r--ext/date/lib/date.rb2
-rw-r--r--ext/digest/bubblebabble/depend3
-rw-r--r--ext/digest/depend3
-rw-r--r--ext/digest/digest.h3
-rw-r--r--ext/digest/md5/depend6
-rw-r--r--ext/digest/rmd160/depend6
-rw-r--r--ext/digest/sha1/depend6
-rw-r--r--ext/digest/sha2/depend6
-rw-r--r--ext/etc/depend3
-rw-r--r--ext/etc/etc.c20
-rw-r--r--ext/etc/extconf.rb14
-rwxr-xr-xext/extmk.rb39
-rw-r--r--ext/fcntl/depend3
-rw-r--r--ext/fcntl/fcntl.c6
-rw-r--r--ext/fcntl/fcntl.gemspec12
-rw-r--r--ext/fiddle/closure.c33
-rw-r--r--ext/fiddle/conversions.c55
-rw-r--r--ext/fiddle/conversions.h2
-rw-r--r--ext/fiddle/depend24
-rw-r--r--ext/fiddle/extconf.rb5
-rw-r--r--ext/fiddle/fiddle.c20
-rw-r--r--ext/fiddle/fiddle.h8
-rw-r--r--ext/fiddle/function.c9
-rw-r--r--ext/fiddle/handle.c9
-rw-r--r--ext/fiddle/lib/fiddle/cparser.rb28
-rw-r--r--ext/fiddle/lib/fiddle/import.rb2
-rw-r--r--ext/fiddle/lib/fiddle/pack.rb12
-rw-r--r--ext/fiddle/pointer.c50
-rwxr-xr-xext/fiddle/win32/libffi-config.rb10
-rw-r--r--ext/io/console/.document2
-rw-r--r--ext/io/console/console.c655
-rw-r--r--ext/io/console/depend3
-rw-r--r--ext/io/console/extconf.rb13
-rw-r--r--ext/io/console/io-console.gemspec20
-rw-r--r--ext/io/nonblock/depend3
-rw-r--r--ext/io/nonblock/extconf.rb7
-rw-r--r--ext/io/nonblock/io-nonblock.gemspec2
-rw-r--r--ext/io/nonblock/nonblock.c71
-rw-r--r--ext/io/wait/depend3
-rw-r--r--ext/io/wait/extconf.rb1
-rw-r--r--ext/io/wait/io-wait.gemspec2
-rw-r--r--ext/io/wait/wait.c11
-rw-r--r--ext/json/VERSION1
-rw-r--r--ext/json/generator/depend3
-rw-r--r--ext/json/generator/generator.c103
-rw-r--r--ext/json/generator/generator.h13
-rw-r--r--ext/json/json.gemspec7
-rw-r--r--ext/json/lib/json.rb9
-rw-r--r--ext/json/lib/json/add/bigdecimal.rb45
-rw-r--r--ext/json/lib/json/add/complex.rb33
-rw-r--r--ext/json/lib/json/add/date.rb32
-rw-r--r--ext/json/lib/json/add/date_time.rb33
-rw-r--r--ext/json/lib/json/add/exception.rb30
-rw-r--r--ext/json/lib/json/add/ostruct.rb32
-rw-r--r--ext/json/lib/json/add/range.rb39
-rw-r--r--ext/json/lib/json/add/rational.rb32
-rw-r--r--ext/json/lib/json/add/regexp.rb32
-rw-r--r--ext/json/lib/json/add/set.rb31
-rw-r--r--ext/json/lib/json/add/struct.rb34
-rw-r--r--ext/json/lib/json/add/symbol.rb31
-rw-r--r--ext/json/lib/json/add/time.rb31
-rw-r--r--ext/json/lib/json/common.rb60
-rw-r--r--ext/json/lib/json/version.rb2
-rw-r--r--ext/json/parser/depend3
-rw-r--r--ext/json/parser/parser.c4792
-rw-r--r--ext/json/parser/parser.rl173
-rw-r--r--ext/monitor/depend3
-rw-r--r--ext/monitor/monitor.c2
-rw-r--r--ext/nkf/depend3
-rw-r--r--ext/nkf/nkf.c3
-rw-r--r--ext/nkf/nkf.gemspec13
-rw-r--r--ext/objspace/depend75
-rw-r--r--ext/objspace/lib/objspace.rb35
-rw-r--r--ext/objspace/object_tracing.c2
-rw-r--r--ext/objspace/objspace.c144
-rw-r--r--ext/objspace/objspace_dump.c59
-rw-r--r--ext/openssl/History.md42
-rw-r--r--ext/openssl/depend322
-rw-r--r--ext/openssl/extconf.rb43
-rw-r--r--ext/openssl/lib/openssl/buffering.rb7
-rw-r--r--ext/openssl/lib/openssl/ssl.rb20
-rw-r--r--ext/openssl/lib/openssl/version.rb2
-rw-r--r--ext/openssl/openssl.gemspec20
-rw-r--r--ext/openssl/ossl.c268
-rw-r--r--ext/openssl/ossl.h11
-rw-r--r--ext/openssl/ossl_bn.c2
-rw-r--r--ext/openssl/ossl_cipher.c2
-rw-r--r--ext/openssl/ossl_config.c2
-rw-r--r--ext/openssl/ossl_digest.c2
-rw-r--r--ext/openssl/ossl_engine.c2
-rw-r--r--ext/openssl/ossl_hmac.c2
-rw-r--r--ext/openssl/ossl_kdf.c2
-rw-r--r--ext/openssl/ossl_ns_spki.c2
-rw-r--r--ext/openssl/ossl_ocsp.c12
-rw-r--r--ext/openssl/ossl_pkcs12.c2
-rw-r--r--ext/openssl/ossl_pkcs7.c6
-rw-r--r--ext/openssl/ossl_pkey.c261
-rw-r--r--ext/openssl/ossl_pkey_dh.c29
-rw-r--r--ext/openssl/ossl_pkey_dsa.c65
-rw-r--r--ext/openssl/ossl_pkey_ec.c74
-rw-r--r--ext/openssl/ossl_pkey_rsa.c81
-rw-r--r--ext/openssl/ossl_provider.c211
-rw-r--r--ext/openssl/ossl_provider.h5
-rw-r--r--ext/openssl/ossl_ssl.c148
-rw-r--r--ext/openssl/ossl_ssl_session.c2
-rw-r--r--ext/openssl/ossl_ts.c6
-rw-r--r--ext/openssl/ossl_x509attr.c2
-rw-r--r--ext/openssl/ossl_x509cert.c2
-rw-r--r--ext/openssl/ossl_x509crl.c2
-rw-r--r--ext/openssl/ossl_x509ext.c20
-rw-r--r--ext/openssl/ossl_x509name.c2
-rw-r--r--ext/openssl/ossl_x509req.c2
-rw-r--r--ext/openssl/ossl_x509revoked.c2
-rw-r--r--ext/openssl/ossl_x509store.c17
-rw-r--r--ext/pathname/depend3
-rw-r--r--ext/pathname/lib/pathname.rb2
-rw-r--r--ext/pathname/pathname.c28
-rw-r--r--ext/pathname/pathname.gemspec11
-rw-r--r--ext/psych/depend15
-rw-r--r--ext/psych/lib/psych.rb42
-rw-r--r--ext/psych/lib/psych/versions.rb4
-rw-r--r--ext/psych/lib/psych/visitors/to_ruby.rb2
-rw-r--r--ext/psych/lib/psych/visitors/yaml_tree.rb13
-rw-r--r--ext/psych/psych.gemspec45
-rw-r--r--ext/pty/depend3
-rw-r--r--ext/pty/pty.c63
-rw-r--r--ext/racc/cparse/README11
-rw-r--r--ext/racc/cparse/cparse.c861
-rw-r--r--ext/racc/cparse/depend162
-rw-r--r--ext/racc/cparse/extconf.rb9
-rw-r--r--ext/rbconfig/sizeof/depend6
-rw-r--r--ext/readline/.gitignore1
-rw-r--r--ext/readline/README10
-rw-r--r--ext/readline/README.ja386
-rw-r--r--ext/readline/depend175
-rw-r--r--ext/readline/depend-gem4
-rw-r--r--ext/readline/extconf.rb112
-rw-r--r--ext/readline/readline-ext.gemspec22
-rw-r--r--ext/readline/readline.c2144
-rw-r--r--ext/ripper/README1
-rw-r--r--ext/ripper/depend564
-rw-r--r--ext/ripper/eventids2.c12
-rw-r--r--ext/ripper/eventids2.h8
-rw-r--r--ext/ripper/extconf.rb15
-rw-r--r--ext/ripper/ripper_init.c.tmpl618
-rw-r--r--ext/ripper/ripper_init.h8
-rw-r--r--ext/ripper/tools/dsl.rb21
-rw-r--r--ext/ripper/tools/generate.rb39
-rw-r--r--ext/ripper/tools/preproc.rb70
-rw-r--r--ext/socket/ancdata.c4
-rw-r--r--ext/socket/depend315
-rw-r--r--ext/socket/extconf.rb7
-rw-r--r--ext/socket/getaddrinfo.c3
-rw-r--r--ext/socket/init.c79
-rw-r--r--ext/socket/lib/socket.rb21
-rw-r--r--ext/socket/mkconstants.rb13
-rw-r--r--ext/socket/raddrinfo.c525
-rw-r--r--ext/socket/rubysocket.h5
-rw-r--r--ext/socket/socket.c5
-rw-r--r--ext/stringio/depend3
-rw-r--r--ext/stringio/extconf.rb7
-rw-r--r--ext/stringio/stringio.c227
-rw-r--r--ext/stringio/stringio.gemspec8
-rw-r--r--ext/strscan/depend3
-rw-r--r--ext/strscan/extconf.rb1
-rw-r--r--ext/strscan/strscan.c118
-rw-r--r--ext/syslog/depend3
-rw-r--r--ext/syslog/syslog.c4
-rw-r--r--ext/syslog/syslog.gemspec9
-rw-r--r--ext/win32/lib/win32/registry.rb7
-rw-r--r--ext/win32ole/win32ole.c2
-rw-r--r--ext/win32ole/win32ole.gemspec12
-rw-r--r--ext/zlib/depend3
-rw-r--r--ext/zlib/extconf.rb10
-rw-r--r--ext/zlib/zlib.c8
-rw-r--r--ext/zlib/zlib.gemspec2
-rw-r--r--file.c618
-rw-r--r--gc.c3125
-rw-r--r--gc.h147
-rw-r--r--gc.rb92
-rw-r--r--gem_prelude.rb2
-rw-r--r--gems/bundled_gems23
-rw-r--r--gems/lib/core_assertions.rb1
-rw-r--r--gems/lib/rake/extensiontask.rb10
-rw-r--r--hash.c940
-rw-r--r--id_table.c6
-rw-r--r--include/ruby/atomic.h51
-rw-r--r--include/ruby/backward/2/attributes.h24
-rw-r--r--include/ruby/debug.h171
-rw-r--r--include/ruby/fiber/scheduler.h80
-rw-r--r--include/ruby/intern.h1
-rw-r--r--include/ruby/internal/attr/noexcept.h2
-rw-r--r--include/ruby/internal/attr/packed_struct.h43
-rw-r--r--include/ruby/internal/config.h4
-rw-r--r--include/ruby/internal/core/rarray.h198
-rw-r--r--include/ruby/internal/core/rfile.h4
-rw-r--r--include/ruby/internal/core/rmatch.h14
-rw-r--r--include/ruby/internal/core/robject.h26
-rw-r--r--include/ruby/internal/core/rstring.h118
-rw-r--r--include/ruby/internal/core/rtypeddata.h57
-rw-r--r--include/ruby/internal/dllexport.h34
-rw-r--r--include/ruby/internal/encoding/string.h2
-rw-r--r--include/ruby/internal/error.h36
-rw-r--r--include/ruby/internal/event.h5
-rw-r--r--include/ruby/internal/fl_type.h93
-rw-r--r--include/ruby/internal/gc.h793
-rw-r--r--include/ruby/internal/globals.h2
-rw-r--r--include/ruby/internal/has/c_attribute.h12
-rw-r--r--include/ruby/internal/intern/array.h2
-rw-r--r--include/ruby/internal/intern/bignum.h4
-rw-r--r--include/ruby/internal/intern/error.h2
-rw-r--r--include/ruby/internal/intern/gc.h392
-rw-r--r--include/ruby/internal/intern/load.h37
-rw-r--r--include/ruby/internal/intern/process.h11
-rw-r--r--include/ruby/internal/intern/re.h5
-rw-r--r--include/ruby/internal/intern/select.h2
-rw-r--r--include/ruby/internal/intern/signal.h6
-rw-r--r--include/ruby/internal/intern/struct.h30
-rw-r--r--include/ruby/internal/memory.h2
-rw-r--r--include/ruby/internal/newobj.h4
-rw-r--r--include/ruby/internal/rgengc.h443
-rw-r--r--include/ruby/io.h102
-rw-r--r--include/ruby/io/buffer.h30
-rw-r--r--include/ruby/memory_view.h4
-rw-r--r--include/ruby/onigmo.h4
-rw-r--r--include/ruby/random.h2
-rw-r--r--include/ruby/re.h25
-rw-r--r--include/ruby/ruby.h125
-rw-r--r--include/ruby/st.h6
-rw-r--r--include/ruby/thread.h87
-rw-r--r--include/ruby/thread_native.h5
-rw-r--r--include/ruby/util.h13
-rw-r--r--include/ruby/win32.h8
-rw-r--r--inits.c15
-rw-r--r--insns.def105
-rw-r--r--internal/array.h32
-rw-r--r--internal/basic_operators.h3
-rw-r--r--internal/bignum.h2
-rw-r--r--internal/bits.h31
-rw-r--r--internal/class.h119
-rw-r--r--internal/cmdlineopt.h12
-rw-r--r--internal/compile.h3
-rw-r--r--internal/cont.h3
-rw-r--r--internal/encoding.h3
-rw-r--r--internal/error.h29
-rw-r--r--internal/gc.h208
-rw-r--r--internal/hash.h67
-rw-r--r--internal/imemo.h3
-rw-r--r--internal/io.h99
-rw-r--r--internal/numeric.h2
-rw-r--r--internal/object.h5
-rw-r--r--internal/parse.h97
-rw-r--r--internal/proc.h2
-rw-r--r--internal/process.h14
-rw-r--r--internal/random.h1
-rw-r--r--internal/range.h4
-rw-r--r--internal/re.h4
-rw-r--r--internal/ruby_parser.h69
-rw-r--r--internal/sanitizers.h4
-rw-r--r--internal/signal.h4
-rw-r--r--internal/string.h18
-rw-r--r--internal/struct.h43
-rw-r--r--internal/symbol.h3
-rw-r--r--internal/thread.h27
-rw-r--r--internal/transcode.h3
-rw-r--r--internal/variable.h60
-rw-r--r--internal/vm.h28
-rw-r--r--io.c789
-rw-r--r--io.rb13
-rw-r--r--io_buffer.c2005
-rw-r--r--iseq.c373
-rw-r--r--iseq.h23
-rw-r--r--kernel.rb115
-rw-r--r--lib/English.gemspec4
-rw-r--r--lib/English.rb60
-rw-r--r--lib/abbrev.gemspec11
-rw-r--r--lib/abbrev.rb1
-rw-r--r--lib/base64.gemspec13
-rw-r--r--lib/base64.rb373
-rw-r--r--lib/benchmark.gemspec30
-rw-r--r--lib/benchmark.rb2
-rw-r--r--lib/benchmark/benchmark.gemspec29
-rw-r--r--lib/benchmark/version.rb4
-rw-r--r--lib/bundled_gems.rb192
-rw-r--r--lib/bundler.rb121
-rw-r--r--lib/bundler/build_metadata.rb2
-rw-r--r--lib/bundler/bundler.gemspec8
-rw-r--r--lib/bundler/capistrano.rb2
-rw-r--r--lib/bundler/checksum.rb254
-rw-r--r--lib/bundler/ci_detector.rb75
-rw-r--r--lib/bundler/cli.rb477
-rw-r--r--lib/bundler/cli/add.rb6
-rw-r--r--lib/bundler/cli/binstubs.rb8
-rw-r--r--lib/bundler/cli/cache.rb2
-rw-r--r--lib/bundler/cli/check.rb4
-rw-r--r--lib/bundler/cli/common.rb10
-rw-r--r--lib/bundler/cli/config.rb15
-rw-r--r--lib/bundler/cli/console.rb5
-rw-r--r--lib/bundler/cli/doctor.rb4
-rw-r--r--lib/bundler/cli/exec.rb2
-rw-r--r--lib/bundler/cli/gem.rb58
-rw-r--r--lib/bundler/cli/info.rb15
-rw-r--r--lib/bundler/cli/init.rb4
-rw-r--r--lib/bundler/cli/install.rb13
-rw-r--r--lib/bundler/cli/issue.rb2
-rw-r--r--lib/bundler/cli/lock.rb56
-rw-r--r--lib/bundler/cli/open.rb12
-rw-r--r--lib/bundler/cli/outdated.rb12
-rw-r--r--lib/bundler/cli/plugin.rb24
-rw-r--r--lib/bundler/cli/pristine.rb68
-rw-r--r--lib/bundler/cli/show.rb4
-rw-r--r--lib/bundler/cli/update.rb11
-rw-r--r--lib/bundler/compact_index_client.rb21
-rw-r--r--lib/bundler/compact_index_client/cache.rb38
-rw-r--r--lib/bundler/compact_index_client/cache_file.rb153
-rw-r--r--lib/bundler/compact_index_client/gem_parser.rb10
-rw-r--r--lib/bundler/compact_index_client/updater.rb160
-rw-r--r--lib/bundler/constants.rb2
-rw-r--r--lib/bundler/current_ruby.rb28
-rw-r--r--lib/bundler/definition.rb340
-rw-r--r--lib/bundler/dependency.rb32
-rw-r--r--lib/bundler/digest.rb4
-rw-r--r--lib/bundler/dsl.rb98
-rw-r--r--lib/bundler/endpoint_specification.rb12
-rw-r--r--lib/bundler/env.rb8
-rw-r--r--lib/bundler/environment_preserver.rb6
-rw-r--r--lib/bundler/errors.rb58
-rw-r--r--lib/bundler/feature_flag.rb1
-rw-r--r--lib/bundler/fetcher.rb130
-rw-r--r--lib/bundler/fetcher/base.rb8
-rw-r--r--lib/bundler/fetcher/compact_index.rb16
-rw-r--r--lib/bundler/fetcher/dependency.rb8
-rw-r--r--lib/bundler/fetcher/downloader.rb26
-rw-r--r--lib/bundler/fetcher/gem_remote_fetcher.rb16
-rw-r--r--lib/bundler/fetcher/index.rb5
-rw-r--r--lib/bundler/friendly_errors.rb10
-rw-r--r--lib/bundler/gem_helper.rb2
-rw-r--r--lib/bundler/gem_helpers.rb14
-rw-r--r--lib/bundler/gem_version_promoter.rb82
-rw-r--r--lib/bundler/graph.rb18
-rw-r--r--lib/bundler/index.rb96
-rw-r--r--lib/bundler/injector.rb6
-rw-r--r--lib/bundler/inline.rb6
-rw-r--r--lib/bundler/installer.rb24
-rw-r--r--lib/bundler/installer/gem_installer.rb20
-rw-r--r--lib/bundler/installer/parallel_installer.rb49
-rw-r--r--lib/bundler/installer/standalone.rb35
-rw-r--r--lib/bundler/lazy_specification.rb59
-rw-r--r--lib/bundler/lockfile_generator.rb11
-rw-r--r--lib/bundler/lockfile_parser.rb155
-rw-r--r--lib/bundler/man/bundle-add.129
-rw-r--r--lib/bundler/man/bundle-binstubs.120
-rw-r--r--lib/bundler/man/bundle-cache.131
-rw-r--r--lib/bundler/man/bundle-cache.1.ronn4
-rw-r--r--lib/bundler/man/bundle-check.115
-rw-r--r--lib/bundler/man/bundle-clean.113
-rw-r--r--lib/bundler/man/bundle-config.1238
-rw-r--r--lib/bundler/man/bundle-config.1.ronn13
-rw-r--r--lib/bundler/man/bundle-console.126
-rw-r--r--lib/bundler/man/bundle-doctor.122
-rw-r--r--lib/bundler/man/bundle-exec.187
-rw-r--r--lib/bundler/man/bundle-exec.1.ronn5
-rw-r--r--lib/bundler/man/bundle-gem.162
-rw-r--r--lib/bundler/man/bundle-help.110
-rw-r--r--lib/bundler/man/bundle-info.116
-rw-r--r--lib/bundler/man/bundle-info.1.ronn6
-rw-r--r--lib/bundler/man/bundle-init.117
-rw-r--r--lib/bundler/man/bundle-init.1.ronn2
-rw-r--r--lib/bundler/man/bundle-inject.125
-rw-r--r--lib/bundler/man/bundle-install.1156
-rw-r--r--lib/bundler/man/bundle-install.1.ronn5
-rw-r--r--lib/bundler/man/bundle-list.123
-rw-r--r--lib/bundler/man/bundle-lock.134
-rw-r--r--lib/bundler/man/bundle-open.134
-rw-r--r--lib/bundler/man/bundle-outdated.178
-rw-r--r--lib/bundler/man/bundle-outdated.1.ronn20
-rw-r--r--lib/bundler/man/bundle-platform.132
-rw-r--r--lib/bundler/man/bundle-plugin.171
-rw-r--r--lib/bundler/man/bundle-plugin.1.ronn20
-rw-r--r--lib/bundler/man/bundle-pristine.121
-rw-r--r--lib/bundler/man/bundle-remove.118
-rw-r--r--lib/bundler/man/bundle-show.113
-rw-r--r--lib/bundler/man/bundle-update.1155
-rw-r--r--lib/bundler/man/bundle-version.119
-rw-r--r--lib/bundler/man/bundle-viz.120
-rw-r--r--lib/bundler/man/bundle.149
-rw-r--r--lib/bundler/man/gemfile.5335
-rw-r--r--lib/bundler/man/gemfile.5.ronn20
-rw-r--r--lib/bundler/match_metadata.rb4
-rw-r--r--lib/bundler/match_platform.rb2
-rw-r--r--lib/bundler/mirror.rb6
-rw-r--r--lib/bundler/plugin.rb19
-rw-r--r--lib/bundler/plugin/api/source.rb9
-rw-r--r--lib/bundler/plugin/index.rb8
-rw-r--r--lib/bundler/plugin/installer.rb59
-rw-r--r--lib/bundler/plugin/installer/path.rb18
-rw-r--r--lib/bundler/plugin/source_list.rb8
-rw-r--r--lib/bundler/remote_specification.rb12
-rw-r--r--lib/bundler/resolver.rb190
-rw-r--r--lib/bundler/resolver/base.rb46
-rw-r--r--lib/bundler/resolver/candidate.rb2
-rw-r--r--lib/bundler/resolver/incompatibility.rb2
-rw-r--r--lib/bundler/resolver/package.rb5
-rw-r--r--lib/bundler/resolver/spec_group.rb5
-rw-r--r--lib/bundler/retry.rb2
-rw-r--r--lib/bundler/ruby_dsl.rb49
-rw-r--r--lib/bundler/ruby_version.rb13
-rw-r--r--lib/bundler/rubygems_ext.rb85
-rw-r--r--lib/bundler/rubygems_gem_installer.rb81
-rw-r--r--lib/bundler/rubygems_integration.rb127
-rw-r--r--lib/bundler/runtime.rb8
-rw-r--r--lib/bundler/safe_marshal.rb31
-rw-r--r--lib/bundler/self_manager.rb36
-rw-r--r--lib/bundler/settings.rb170
-rw-r--r--lib/bundler/setup.rb8
-rw-r--r--lib/bundler/shared_helpers.rb65
-rw-r--r--lib/bundler/source.rb4
-rw-r--r--lib/bundler/source/git.rb64
-rw-r--r--lib/bundler/source/git/git_proxy.rb142
-rw-r--r--lib/bundler/source/metadata.rb32
-rw-r--r--lib/bundler/source/path.rb13
-rw-r--r--lib/bundler/source/rubygems.rb107
-rw-r--r--lib/bundler/source/rubygems/remote.rb2
-rw-r--r--lib/bundler/source_list.rb8
-rw-r--r--lib/bundler/spec_set.rb148
-rw-r--r--lib/bundler/stub_specification.rb7
-rw-r--r--lib/bundler/templates/Executable.bundler4
-rw-r--r--lib/bundler/templates/gems.rb5
-rw-r--r--lib/bundler/templates/newgem/Gemfile.tt2
-rw-r--r--lib/bundler/templates/newgem/README.md.tt6
-rw-r--r--lib/bundler/templates/newgem/Rakefile.tt24
-rw-r--r--lib/bundler/templates/newgem/bin/console.tt4
-rw-r--r--lib/bundler/templates/newgem/ext/newgem/Cargo.toml.tt2
-rw-r--r--lib/bundler/templates/newgem/ext/newgem/extconf-c.rb.tt5
-rw-r--r--lib/bundler/templates/newgem/ext/newgem/newgem.c.tt2
-rw-r--r--lib/bundler/templates/newgem/ext/newgem/src/lib.rs.tt8
-rw-r--r--lib/bundler/templates/newgem/github/workflows/main.yml.tt4
-rw-r--r--lib/bundler/templates/newgem/newgem.gemspec.tt8
-rw-r--r--lib/bundler/templates/newgem/rubocop.yml.tt5
-rw-r--r--lib/bundler/templates/newgem/standard.yml.tt2
-rw-r--r--lib/bundler/ui/shell.rb4
-rw-r--r--lib/bundler/uri_credentials_filter.rb4
-rw-r--r--lib/bundler/uri_normalizer.rb23
-rw-r--r--lib/bundler/vendor/connection_pool/.document (renamed from lib/rubygems/optparse/.document)0
-rw-r--r--lib/bundler/vendor/connection_pool/lib/connection_pool.rb59
-rw-r--r--lib/bundler/vendor/connection_pool/lib/connection_pool/version.rb2
-rw-r--r--lib/bundler/vendor/fileutils/.document (renamed from lib/rubygems/tsort/.document)0
-rw-r--r--lib/bundler/vendor/fileutils/lib/fileutils.rb30
-rw-r--r--lib/bundler/vendor/net-http-persistent/.document1
-rw-r--r--lib/bundler/vendor/net-http-persistent/lib/net/http/persistent.rb114
-rw-r--r--lib/bundler/vendor/net-http-persistent/lib/net/http/persistent/connection.rb7
-rw-r--r--lib/bundler/vendor/net-http-persistent/lib/net/http/persistent/pool.rb34
-rw-r--r--lib/bundler/vendor/net-http-persistent/lib/net/http/persistent/timed_stack_multi.rb2
-rw-r--r--lib/bundler/vendor/pub_grub/.document1
-rw-r--r--lib/bundler/vendor/pub_grub/lib/pub_grub/incompatibility.rb13
-rw-r--r--lib/bundler/vendor/pub_grub/lib/pub_grub/static_package_source.rb10
-rw-r--r--lib/bundler/vendor/pub_grub/lib/pub_grub/version_constraint.rb9
-rw-r--r--lib/bundler/vendor/pub_grub/lib/pub_grub/version_range.rb6
-rw-r--r--lib/bundler/vendor/pub_grub/lib/pub_grub/version_solver.rb18
-rw-r--r--lib/bundler/vendor/thor/.document1
-rw-r--r--lib/bundler/vendor/thor/lib/thor.rb163
-rw-r--r--lib/bundler/vendor/thor/lib/thor/actions.rb30
-rw-r--r--lib/bundler/vendor/thor/lib/thor/actions/create_file.rb5
-rw-r--r--lib/bundler/vendor/thor/lib/thor/actions/directory.rb2
-rw-r--r--lib/bundler/vendor/thor/lib/thor/actions/empty_directory.rb2
-rw-r--r--lib/bundler/vendor/thor/lib/thor/actions/file_manipulation.rb18
-rw-r--r--lib/bundler/vendor/thor/lib/thor/actions/inject_into_file.rb19
-rw-r--r--lib/bundler/vendor/thor/lib/thor/base.rb154
-rw-r--r--lib/bundler/vendor/thor/lib/thor/command.rb17
-rw-r--r--lib/bundler/vendor/thor/lib/thor/core_ext/hash_with_indifferent_access.rb4
-rw-r--r--lib/bundler/vendor/thor/lib/thor/error.rb41
-rw-r--r--lib/bundler/vendor/thor/lib/thor/group.rb2
-rw-r--r--lib/bundler/vendor/thor/lib/thor/invocation.rb2
-rw-r--r--lib/bundler/vendor/thor/lib/thor/nested_context.rb4
-rw-r--r--lib/bundler/vendor/thor/lib/thor/parser/argument.rb21
-rw-r--r--lib/bundler/vendor/thor/lib/thor/parser/arguments.rb50
-rw-r--r--lib/bundler/vendor/thor/lib/thor/parser/option.rb35
-rw-r--r--lib/bundler/vendor/thor/lib/thor/parser/options.rb50
-rw-r--r--lib/bundler/vendor/thor/lib/thor/rake_compat.rb4
-rw-r--r--lib/bundler/vendor/thor/lib/thor/runner.rb70
-rw-r--r--lib/bundler/vendor/thor/lib/thor/shell.rb2
-rw-r--r--lib/bundler/vendor/thor/lib/thor/shell/basic.rb176
-rw-r--r--lib/bundler/vendor/thor/lib/thor/shell/color.rb47
-rw-r--r--lib/bundler/vendor/thor/lib/thor/shell/column_printer.rb29
-rw-r--r--lib/bundler/vendor/thor/lib/thor/shell/html.rb45
-rw-r--r--lib/bundler/vendor/thor/lib/thor/shell/table_printer.rb134
-rw-r--r--lib/bundler/vendor/thor/lib/thor/shell/terminal.rb42
-rw-r--r--lib/bundler/vendor/thor/lib/thor/shell/wrapped_printer.rb38
-rw-r--r--lib/bundler/vendor/thor/lib/thor/util.rb15
-rw-r--r--lib/bundler/vendor/thor/lib/thor/version.rb2
-rw-r--r--lib/bundler/vendor/tsort/.document1
-rw-r--r--lib/bundler/vendor/tsort/lib/tsort.rb3
-rw-r--r--lib/bundler/vendor/uri/.document1
-rw-r--r--lib/bundler/vendor/uri/lib/uri/common.rb388
-rw-r--r--lib/bundler/vendor/uri/lib/uri/generic.rb1
-rw-r--r--lib/bundler/vendor/uri/lib/uri/rfc2396_parser.rb4
-rw-r--r--lib/bundler/vendor/uri/lib/uri/rfc3986_parser.rb128
-rw-r--r--lib/bundler/vendor/uri/lib/uri/version.rb2
-rw-r--r--lib/bundler/vendored_net_http.rb12
-rw-r--r--lib/bundler/vendored_persistent.rb4
-rw-r--r--lib/bundler/vendored_timeout.rb12
-rw-r--r--lib/bundler/vendored_uri.rb19
-rw-r--r--lib/bundler/version.rb2
-rw-r--r--lib/bundler/vlad.rb2
-rw-r--r--lib/bundler/yaml_serializer.rb38
-rw-r--r--lib/cgi.rb2
-rw-r--r--lib/cgi/util.rb16
-rw-r--r--lib/csv.rb27
-rw-r--r--lib/csv/delete_suffix.rb18
-rw-r--r--lib/csv/match_p.rb20
-rw-r--r--lib/csv/parser.rb13
-rw-r--r--lib/csv/version.rb2
-rw-r--r--lib/delegate.gemspec29
-rw-r--r--lib/delegate.rb2
-rw-r--r--lib/delegate/delegate.gemspec29
-rw-r--r--lib/drb/drb.rb3
-rw-r--r--lib/drb/ssl.rb10
-rw-r--r--lib/drb/version.rb2
-rw-r--r--lib/erb.rb4
-rw-r--r--lib/erb/compiler.rb1
-rw-r--r--lib/erb/def_method.rb1
-rw-r--r--lib/erb/util.rb1
-rw-r--r--lib/erb/version.rb2
-rw-r--r--lib/error_highlight/version.rb2
-rw-r--r--lib/fileutils.rb30
-rw-r--r--lib/find.gemspec11
-rw-r--r--lib/find.rb2
-rw-r--r--lib/getoptlong.gemspec30
-rw-r--r--lib/getoptlong.rb4
-rw-r--r--lib/getoptlong/getoptlong.gemspec30
-rw-r--r--lib/ipaddr.rb42
-rw-r--r--lib/irb.rb1743
-rw-r--r--lib/irb/cmd/chws.rb4
-rw-r--r--lib/irb/cmd/debug.rb128
-rw-r--r--lib/irb/cmd/edit.rb13
-rw-r--r--lib/irb/cmd/fork.rb34
-rw-r--r--lib/irb/cmd/help.rb58
-rw-r--r--lib/irb/cmd/history.rb47
-rw-r--r--lib/irb/cmd/irb_info.rb33
-rw-r--r--lib/irb/cmd/ls.rb47
-rw-r--r--lib/irb/cmd/measure.rb23
-rw-r--r--lib/irb/cmd/nop.rb27
-rw-r--r--lib/irb/cmd/pushws.rb6
-rw-r--r--lib/irb/cmd/show_cmds.rb26
-rw-r--r--lib/irb/cmd/show_doc.rb48
-rw-r--r--lib/irb/cmd/show_source.rb85
-rw-r--r--lib/irb/cmd/subirb.rb55
-rw-r--r--lib/irb/color.rb16
-rw-r--r--lib/irb/color_printer.rb7
-rw-r--r--lib/irb/completion.rb255
-rw-r--r--lib/irb/context.rb136
-rw-r--r--lib/irb/debug.rb130
-rw-r--r--lib/irb/debug/ui.rb103
-rw-r--r--lib/irb/easter-egg.rb22
-rw-r--r--lib/irb/ext/eval_history.rb149
-rw-r--r--lib/irb/ext/history.rb149
-rw-r--r--lib/irb/ext/loader.rb27
-rw-r--r--lib/irb/ext/save-history.rb125
-rw-r--r--lib/irb/ext/tracer.rb7
-rw-r--r--lib/irb/extend-command.rb108
-rw-r--r--lib/irb/help.rb6
-rw-r--r--lib/irb/history.rb76
-rw-r--r--lib/irb/init.rb84
-rw-r--r--lib/irb/input-method.rb421
-rw-r--r--lib/irb/inspector.rb15
-rw-r--r--lib/irb/irb.gemspec10
-rw-r--r--lib/irb/lc/help-message8
-rw-r--r--lib/irb/lc/ja/encoding_aliases.rb13
-rw-r--r--lib/irb/lc/ja/help-message3
-rw-r--r--lib/irb/locale.rb53
-rw-r--r--lib/irb/magic-file.rb38
-rw-r--r--lib/irb/nesting_parser.rb227
-rw-r--r--lib/irb/pager.rb91
-rw-r--r--lib/irb/ruby-lex.rb1133
-rw-r--r--lib/irb/ruby_logo.aa43
-rw-r--r--lib/irb/source_finder.rb78
-rw-r--r--lib/irb/src_encoding.rb7
-rw-r--r--lib/irb/statement.rb80
-rw-r--r--lib/irb/version.rb4
-rw-r--r--lib/irb/workspace.rb8
-rw-r--r--lib/irb/xmp.rb4
-rw-r--r--lib/logger.rb42
-rw-r--r--lib/logger/logger.gemspec6
-rw-r--r--lib/logger/severity.rb19
-rw-r--r--lib/logger/version.rb2
-rw-r--r--lib/mkmf.rb19
-rw-r--r--lib/mutex_m.rb2
-rw-r--r--lib/net/http.rb1183
-rw-r--r--lib/net/http/backward.rb2
-rw-r--r--lib/net/http/exceptions.rb2
-rw-r--r--lib/net/http/generic_request.rb14
-rw-r--r--lib/net/http/header.rb22
-rw-r--r--lib/net/http/net-http.gemspec13
-rw-r--r--lib/net/http/proxy_delta.rb2
-rw-r--r--lib/net/http/request.rb55
-rw-r--r--lib/net/http/requests.rb32
-rw-r--r--lib/net/http/response.rb62
-rw-r--r--lib/net/http/status.rb13
-rw-r--r--lib/net/https.rb2
-rw-r--r--lib/net/net-protocol.gemspec2
-rw-r--r--lib/net/protocol.rb2
-rw-r--r--lib/observer.gemspec32
-rw-r--r--lib/observer.rb2
-rw-r--r--lib/observer/observer.gemspec32
-rw-r--r--lib/open-uri.gemspec11
-rw-r--r--lib/open-uri.rb10
-rw-r--r--lib/open3.rb1268
-rw-r--r--lib/open3/open3.gemspec2
-rw-r--r--lib/open3/version.rb2
-rw-r--r--lib/optparse.rb16
-rw-r--r--lib/ostruct.gemspec24
-rw-r--r--lib/ostruct.rb14
-rw-r--r--lib/ostruct/ostruct.gemspec27
-rw-r--r--lib/pp.gemspec11
-rw-r--r--lib/pp.rb8
-rw-r--r--lib/prettyprint.gemspec11
-rw-r--r--lib/prettyprint.rb6
-rw-r--r--lib/prism.rb99
-rw-r--r--lib/prism/debug.rb200
-rw-r--r--lib/prism/desugar_compiler.rb207
-rw-r--r--lib/prism/ffi.rb341
-rw-r--r--lib/prism/lex_compat.rb892
-rw-r--r--lib/prism/node_ext.rb189
-rw-r--r--lib/prism/node_inspector.rb68
-rw-r--r--lib/prism/pack.rb224
-rw-r--r--lib/prism/parse_result.rb460
-rw-r--r--lib/prism/parse_result/comments.rb177
-rw-r--r--lib/prism/parse_result/newlines.rb64
-rw-r--r--lib/prism/pattern.rb250
-rw-r--r--lib/prism/prism.gemspec119
-rw-r--r--lib/prism/ripper_compat.rb207
-rw-r--r--lib/pstore.gemspec32
-rw-r--r--lib/pstore.rb14
-rw-r--r--lib/pstore/pstore.gemspec32
-rw-r--r--lib/racc.rb6
-rw-r--r--lib/racc/compat.rb33
-rw-r--r--lib/racc/debugflags.rb60
-rw-r--r--lib/racc/exception.rb16
-rw-r--r--lib/racc/grammar.rb1118
-rw-r--r--lib/racc/grammarfileparser.rb561
-rw-r--r--lib/racc/info.rb17
-rw-r--r--lib/racc/iset.rb92
-rw-r--r--lib/racc/logfilegenerator.rb212
-rw-r--r--lib/racc/parser-text.rb637
-rw-r--r--lib/racc/parser.rb632
-rw-r--r--lib/racc/parserfilegenerator.rb470
-rw-r--r--lib/racc/racc.gemspec58
-rw-r--r--lib/racc/sourcetext.rb35
-rw-r--r--lib/racc/state.rb972
-rw-r--r--lib/racc/statetransitiontable.rb311
-rw-r--r--lib/racc/static.rb5
-rw-r--r--lib/random/formatter.rb134
-rw-r--r--lib/rdoc.rb12
-rw-r--r--lib/rdoc/alias.rb1
-rw-r--r--lib/rdoc/anon_class.rb1
-rw-r--r--lib/rdoc/any_method.rb15
-rw-r--r--lib/rdoc/attr.rb1
-rw-r--r--lib/rdoc/class_module.rb1
-rw-r--r--lib/rdoc/comment.rb61
-rw-r--r--lib/rdoc/constant.rb1
-rw-r--r--lib/rdoc/context/section.rb1
-rw-r--r--lib/rdoc/cross_reference.rb4
-rw-r--r--lib/rdoc/encoding.rb18
-rw-r--r--lib/rdoc/erb_partial.rb1
-rw-r--r--lib/rdoc/erbio.rb9
-rw-r--r--lib/rdoc/extend.rb1
-rw-r--r--lib/rdoc/generator/darkfish.rb8
-rw-r--r--lib/rdoc/generator/json_index.rb4
-rw-r--r--lib/rdoc/generator/markup.rb1
-rw-r--r--lib/rdoc/generator/pot.rb1
-rw-r--r--lib/rdoc/generator/ri.rb1
-rw-r--r--lib/rdoc/generator/template/darkfish/_sidebar_search.rhtml2
-rw-r--r--lib/rdoc/generator/template/darkfish/class.rhtml6
-rw-r--r--lib/rdoc/generator/template/darkfish/css/rdoc.css51
-rw-r--r--lib/rdoc/generator/template/darkfish/js/darkfish.js13
-rw-r--r--lib/rdoc/generator/template/darkfish/js/search.js6
-rw-r--r--lib/rdoc/generator/template/darkfish/table_of_contents.rhtml9
-rw-r--r--lib/rdoc/generator/template/json_index/js/navigation.js16
-rw-r--r--lib/rdoc/ghost_method.rb1
-rw-r--r--lib/rdoc/include.rb1
-rw-r--r--lib/rdoc/markdown.rb2
-rw-r--r--lib/rdoc/markdown/entities.rb1
-rw-r--r--lib/rdoc/markdown/literals.rb1
-rw-r--r--lib/rdoc/markup/attr_changer.rb1
-rw-r--r--lib/rdoc/markup/attr_span.rb1
-rw-r--r--lib/rdoc/markup/attribute_manager.rb26
-rw-r--r--lib/rdoc/markup/attributes.rb1
-rw-r--r--lib/rdoc/markup/blank_line.rb1
-rw-r--r--lib/rdoc/markup/block_quote.rb1
-rw-r--r--lib/rdoc/markup/document.rb1
-rw-r--r--lib/rdoc/markup/formatter.rb3
-rw-r--r--lib/rdoc/markup/hard_break.rb1
-rw-r--r--lib/rdoc/markup/heading.rb1
-rw-r--r--lib/rdoc/markup/include.rb1
-rw-r--r--lib/rdoc/markup/indented_paragraph.rb1
-rw-r--r--lib/rdoc/markup/list.rb1
-rw-r--r--lib/rdoc/markup/list_item.rb1
-rw-r--r--lib/rdoc/markup/paragraph.rb1
-rw-r--r--lib/rdoc/markup/parser.rb6
-rw-r--r--lib/rdoc/markup/raw.rb1
-rw-r--r--lib/rdoc/markup/regexp_handling.rb1
-rw-r--r--lib/rdoc/markup/rule.rb1
-rw-r--r--lib/rdoc/markup/table.rb13
-rw-r--r--lib/rdoc/markup/to_ansi.rb1
-rw-r--r--lib/rdoc/markup/to_html.rb10
-rw-r--r--lib/rdoc/markup/to_html_crossref.rb2
-rw-r--r--lib/rdoc/markup/to_html_snippet.rb4
-rw-r--r--lib/rdoc/markup/to_joined_paragraph.rb5
-rw-r--r--lib/rdoc/markup/to_label.rb1
-rw-r--r--lib/rdoc/markup/to_markdown.rb1
-rw-r--r--lib/rdoc/markup/to_rdoc.rb1
-rw-r--r--lib/rdoc/markup/to_table_of_contents.rb1
-rw-r--r--lib/rdoc/markup/to_test.rb1
-rw-r--r--lib/rdoc/markup/to_tt_only.rb1
-rw-r--r--lib/rdoc/markup/verbatim.rb1
-rw-r--r--lib/rdoc/meta_method.rb1
-rw-r--r--lib/rdoc/method_attr.rb1
-rw-r--r--lib/rdoc/mixin.rb1
-rw-r--r--lib/rdoc/normal_class.rb1
-rw-r--r--lib/rdoc/normal_module.rb1
-rw-r--r--lib/rdoc/options.rb5
-rw-r--r--lib/rdoc/parser/c.rb29
-rw-r--r--lib/rdoc/parser/changelog.rb16
-rw-r--r--lib/rdoc/parser/markdown.rb2
-rw-r--r--lib/rdoc/parser/rd.rb1
-rw-r--r--lib/rdoc/parser/ripper_state_lex.rb12
-rw-r--r--lib/rdoc/parser/ruby.rb11
-rw-r--r--lib/rdoc/parser/ruby_tools.rb2
-rw-r--r--lib/rdoc/parser/text.rb1
-rw-r--r--lib/rdoc/rd/block_parser.rb658
-rw-r--r--lib/rdoc/rd/inline.rb1
-rw-r--r--lib/rdoc/rd/inline_parser.rb656
-rw-r--r--lib/rdoc/rdoc.gemspec6
-rw-r--r--lib/rdoc/rdoc.rb6
-rw-r--r--lib/rdoc/require.rb1
-rw-r--r--lib/rdoc/ri/driver.rb17
-rw-r--r--lib/rdoc/ri/store.rb1
-rw-r--r--lib/rdoc/single_class.rb1
-rw-r--r--lib/rdoc/stats/quiet.rb1
-rw-r--r--lib/rdoc/stats/verbose.rb2
-rw-r--r--lib/rdoc/store.rb48
-rw-r--r--lib/rdoc/task.rb30
-rw-r--r--lib/rdoc/text.rb10
-rw-r--r--lib/rdoc/token_stream.rb3
-rw-r--r--lib/rdoc/top_level.rb4
-rw-r--r--lib/rdoc/version.rb2
-rw-r--r--lib/readline.gemspec2
-rw-r--r--lib/readline.rb2
-rw-r--r--lib/reline.rb179
-rw-r--r--lib/reline/ansi.rb122
-rw-r--r--lib/reline/config.rb2
-rw-r--r--lib/reline/face.rb199
-rw-r--r--lib/reline/general_io.rb13
-rw-r--r--lib/reline/key_stroke.rb57
-rw-r--r--lib/reline/line_editor.rb512
-rw-r--r--lib/reline/terminfo.rb16
-rw-r--r--lib/reline/unicode.rb83
-rw-r--r--lib/reline/unicode/east_asian_width.rb6
-rw-r--r--lib/reline/version.rb2
-rw-r--r--lib/reline/windows.rb6
-rw-r--r--lib/resolv.gemspec11
-rw-r--r--lib/resolv.rb511
-rw-r--r--lib/rinda/rinda.gemspec11
-rw-r--r--lib/rinda/rinda.rb2
-rw-r--r--lib/ruby_vm/mjit/c_pointer.rb335
-rw-r--r--lib/ruby_vm/mjit/c_type.rb91
-rw-r--r--lib/ruby_vm/mjit/compiler.rb952
-rw-r--r--lib/ruby_vm/mjit/hooks.rb32
-rw-r--r--lib/ruby_vm/rjit/.document1
-rw-r--r--lib/ruby_vm/rjit/assembler.rb1140
-rw-r--r--lib/ruby_vm/rjit/block.rb11
-rw-r--r--lib/ruby_vm/rjit/branch_stub.rb24
-rw-r--r--lib/ruby_vm/rjit/c_pointer.rb394
-rw-r--r--lib/ruby_vm/rjit/c_type.rb99
-rw-r--r--lib/ruby_vm/rjit/code_block.rb91
-rw-r--r--lib/ruby_vm/rjit/compiler.rb518
-rw-r--r--lib/ruby_vm/rjit/context.rb377
-rw-r--r--lib/ruby_vm/rjit/entry_stub.rb7
-rw-r--r--lib/ruby_vm/rjit/exit_compiler.rb164
-rw-r--r--lib/ruby_vm/rjit/hooks.rb36
-rw-r--r--lib/ruby_vm/rjit/insn_compiler.rb5972
-rw-r--r--lib/ruby_vm/rjit/invariants.rb155
-rw-r--r--lib/ruby_vm/rjit/jit_state.rb65
-rw-r--r--lib/ruby_vm/rjit/stats.rb191
-rw-r--r--lib/ruby_vm/rjit/type.rb221
-rw-r--r--lib/rubygems.rb115
-rw-r--r--lib/rubygems/available_set.rb11
-rw-r--r--lib/rubygems/basic_specification.rb81
-rw-r--r--lib/rubygems/bundler_version_finder.rb8
-rw-r--r--lib/rubygems/ci_detector.rb75
-rw-r--r--lib/rubygems/command.rb82
-rw-r--r--lib/rubygems/command_manager.rb18
-rw-r--r--lib/rubygems/commands/build_command.rb18
-rw-r--r--lib/rubygems/commands/cert_command.rb12
-rw-r--r--lib/rubygems/commands/check_command.rb15
-rw-r--r--lib/rubygems/commands/cleanup_command.rb29
-rw-r--r--lib/rubygems/commands/contents_command.rb13
-rw-r--r--lib/rubygems/commands/dependency_command.rb15
-rw-r--r--lib/rubygems/commands/environment_command.rb9
-rw-r--r--lib/rubygems/commands/exec_command.rb249
-rw-r--r--lib/rubygems/commands/fetch_command.rb5
-rw-r--r--lib/rubygems/commands/generate_index_command.rb114
-rw-r--r--lib/rubygems/commands/help_command.rb17
-rw-r--r--lib/rubygems/commands/info_command.rb4
-rw-r--r--lib/rubygems/commands/install_command.rb25
-rw-r--r--lib/rubygems/commands/list_command.rb5
-rw-r--r--lib/rubygems/commands/lock_command.rb3
-rw-r--r--lib/rubygems/commands/mirror_command.rb1
-rw-r--r--lib/rubygems/commands/open_command.rb5
-rw-r--r--lib/rubygems/commands/outdated_command.rb1
-rw-r--r--lib/rubygems/commands/owner_command.rb21
-rw-r--r--lib/rubygems/commands/pristine_command.rb32
-rw-r--r--lib/rubygems/commands/push_command.rb5
-rw-r--r--lib/rubygems/commands/query_command.rb10
-rw-r--r--lib/rubygems/commands/rdoc_command.rb14
-rw-r--r--lib/rubygems/commands/rebuild_command.rb264
-rw-r--r--lib/rubygems/commands/search_command.rb5
-rw-r--r--lib/rubygems/commands/server_command.rb1
-rw-r--r--lib/rubygems/commands/setup_command.rb76
-rw-r--r--lib/rubygems/commands/signin_command.rb1
-rw-r--r--lib/rubygems/commands/signout_command.rb1
-rw-r--r--lib/rubygems/commands/sources_command.rb29
-rw-r--r--lib/rubygems/commands/specification_command.rb27
-rw-r--r--lib/rubygems/commands/stale_command.rb5
-rw-r--r--lib/rubygems/commands/uninstall_command.rb36
-rw-r--r--lib/rubygems/commands/unpack_command.rb25
-rw-r--r--lib/rubygems/commands/update_command.rb39
-rw-r--r--lib/rubygems/commands/which_command.rb3
-rw-r--r--lib/rubygems/commands/yank_command.rb5
-rw-r--r--lib/rubygems/compatibility.rb11
-rw-r--r--lib/rubygems/config_file.rb116
-rw-r--r--lib/rubygems/core_ext/kernel_gem.rb6
-rw-r--r--lib/rubygems/core_ext/kernel_require.rb91
-rw-r--r--lib/rubygems/core_ext/kernel_warn.rb9
-rw-r--r--lib/rubygems/core_ext/tcpsocket_init.rb4
-rw-r--r--lib/rubygems/defaults.rb37
-rw-r--r--lib/rubygems/dependency.rb31
-rw-r--r--lib/rubygems/dependency_installer.rb82
-rw-r--r--lib/rubygems/dependency_list.rb5
-rw-r--r--lib/rubygems/deprecate.rb35
-rw-r--r--lib/rubygems/doctor.rb15
-rw-r--r--lib/rubygems/errors.rb11
-rw-r--r--lib/rubygems/exceptions.rb15
-rw-r--r--lib/rubygems/ext.rb1
-rw-r--r--lib/rubygems/ext/build_error.rb1
-rw-r--r--lib/rubygems/ext/builder.rb55
-rw-r--r--lib/rubygems/ext/cargo_builder.rb20
-rw-r--r--lib/rubygems/ext/configure_builder.rb1
-rw-r--r--lib/rubygems/ext/ext_conf_builder.rb10
-rw-r--r--lib/rubygems/ext/rake_builder.rb10
-rw-r--r--lib/rubygems/gem_runner.rb15
-rw-r--r--lib/rubygems/gemcutter_utilities.rb145
-rw-r--r--lib/rubygems/gemcutter_utilities/webauthn_listener.rb105
-rw-r--r--lib/rubygems/gemcutter_utilities/webauthn_listener/response.rb163
-rw-r--r--lib/rubygems/gemcutter_utilities/webauthn_poller.rb78
-rw-r--r--lib/rubygems/gemspec_helpers.rb19
-rw-r--r--lib/rubygems/indexer.rb427
-rw-r--r--lib/rubygems/install_default_message.rb1
-rw-r--r--lib/rubygems/install_message.rb1
-rw-r--r--lib/rubygems/install_update_options.rb40
-rw-r--r--lib/rubygems/installer.rb157
-rw-r--r--lib/rubygems/installer_uninstaller_utils.rb2
-rw-r--r--lib/rubygems/local_remote_options.rb32
-rw-r--r--lib/rubygems/mock_gem_ui.rb85
-rw-r--r--lib/rubygems/name_tuple.rb17
-rw-r--r--lib/rubygems/optparse.rb3
-rw-r--r--lib/rubygems/optparse/lib/optparse.rb2308
-rw-r--r--lib/rubygems/optparse/lib/optparse/uri.rb7
-rw-r--r--lib/rubygems/package.rb96
-rw-r--r--lib/rubygems/package/digest_io.rb3
-rw-r--r--lib/rubygems/package/file_source.rb1
-rw-r--r--lib/rubygems/package/io_source.rb1
-rw-r--r--lib/rubygems/package/old.rb5
-rw-r--r--lib/rubygems/package/source.rb1
-rw-r--r--lib/rubygems/package/tar_header.rb87
-rw-r--r--lib/rubygems/package/tar_reader.rb53
-rw-r--r--lib/rubygems/package/tar_reader/entry.rb127
-rw-r--r--lib/rubygems/package/tar_writer.rb41
-rw-r--r--lib/rubygems/package_task.rb5
-rw-r--r--lib/rubygems/path_support.rb22
-rw-r--r--lib/rubygems/platform.rb118
-rw-r--r--lib/rubygems/psych_tree.rb1
-rw-r--r--lib/rubygems/query_utils.rb26
-rw-r--r--lib/rubygems/rdoc.rb1
-rw-r--r--lib/rubygems/remote_fetcher.rb51
-rw-r--r--lib/rubygems/request.rb54
-rw-r--r--lib/rubygems/request/connection_pools.rb6
-rw-r--r--lib/rubygems/request/http_pool.rb1
-rw-r--r--lib/rubygems/request/https_pool.rb1
-rw-r--r--lib/rubygems/request_set.rb20
-rw-r--r--lib/rubygems/request_set/gem_dependency_api.rb247
-rw-r--r--lib/rubygems/request_set/lockfile.rb18
-rw-r--r--lib/rubygems/request_set/lockfile/parser.rb19
-rw-r--r--lib/rubygems/request_set/lockfile/tokenizer.rb34
-rw-r--r--lib/rubygems/requirement.rb22
-rw-r--r--lib/rubygems/resolver.rb28
-rw-r--r--lib/rubygems/resolver/activation_request.rb11
-rw-r--r--lib/rubygems/resolver/api_set.rb6
-rw-r--r--lib/rubygems/resolver/api_set/gem_parser.rb10
-rw-r--r--lib/rubygems/resolver/api_specification.rb3
-rw-r--r--lib/rubygems/resolver/best_set.rb5
-rw-r--r--lib/rubygems/resolver/composed_set.rb3
-rw-r--r--lib/rubygems/resolver/conflict.rb17
-rw-r--r--lib/rubygems/resolver/current_set.rb1
-rw-r--r--lib/rubygems/resolver/dependency_request.rb1
-rw-r--r--lib/rubygems/resolver/git_set.rb1
-rw-r--r--lib/rubygems/resolver/git_specification.rb1
-rw-r--r--lib/rubygems/resolver/index_set.rb9
-rw-r--r--lib/rubygems/resolver/index_specification.rb5
-rw-r--r--lib/rubygems/resolver/installed_specification.rb3
-rw-r--r--lib/rubygems/resolver/installer_set.rb16
-rw-r--r--lib/rubygems/resolver/local_specification.rb3
-rw-r--r--lib/rubygems/resolver/lock_set.rb3
-rw-r--r--lib/rubygems/resolver/lock_specification.rb1
-rw-r--r--lib/rubygems/resolver/molinillo.rb2
-rw-r--r--lib/rubygems/resolver/molinillo/lib/molinillo.rb11
-rw-r--r--lib/rubygems/resolver/molinillo/lib/molinillo/delegates/resolution_state.rb57
-rw-r--r--lib/rubygems/resolver/molinillo/lib/molinillo/delegates/specification_provider.rb88
-rw-r--r--lib/rubygems/resolver/molinillo/lib/molinillo/dependency_graph.rb255
-rw-r--r--lib/rubygems/resolver/molinillo/lib/molinillo/dependency_graph/action.rb36
-rw-r--r--lib/rubygems/resolver/molinillo/lib/molinillo/dependency_graph/add_edge_no_circular.rb66
-rw-r--r--lib/rubygems/resolver/molinillo/lib/molinillo/dependency_graph/add_vertex.rb62
-rw-r--r--lib/rubygems/resolver/molinillo/lib/molinillo/dependency_graph/delete_edge.rb63
-rw-r--r--lib/rubygems/resolver/molinillo/lib/molinillo/dependency_graph/detach_vertex_named.rb61
-rw-r--r--lib/rubygems/resolver/molinillo/lib/molinillo/dependency_graph/log.rb126
-rw-r--r--lib/rubygems/resolver/molinillo/lib/molinillo/dependency_graph/set_payload.rb46
-rw-r--r--lib/rubygems/resolver/molinillo/lib/molinillo/dependency_graph/tag.rb36
-rw-r--r--lib/rubygems/resolver/molinillo/lib/molinillo/dependency_graph/vertex.rb164
-rw-r--r--lib/rubygems/resolver/molinillo/lib/molinillo/errors.rb149
-rw-r--r--lib/rubygems/resolver/molinillo/lib/molinillo/gem_metadata.rb6
-rw-r--r--lib/rubygems/resolver/molinillo/lib/molinillo/modules/specification_provider.rb112
-rw-r--r--lib/rubygems/resolver/molinillo/lib/molinillo/modules/ui.rb67
-rw-r--r--lib/rubygems/resolver/molinillo/lib/molinillo/resolution.rb839
-rw-r--r--lib/rubygems/resolver/molinillo/lib/molinillo/resolver.rb46
-rw-r--r--lib/rubygems/resolver/molinillo/lib/molinillo/state.rb58
-rw-r--r--lib/rubygems/resolver/requirement_list.rb1
-rw-r--r--lib/rubygems/resolver/set.rb1
-rw-r--r--lib/rubygems/resolver/source_set.rb2
-rw-r--r--lib/rubygems/resolver/spec_specification.rb8
-rw-r--r--lib/rubygems/resolver/specification.rb1
-rw-r--r--lib/rubygems/resolver/stats.rb1
-rw-r--r--lib/rubygems/resolver/vendor_set.rb1
-rw-r--r--lib/rubygems/resolver/vendor_specification.rb1
-rw-r--r--lib/rubygems/s3_uri_signer.rb24
-rw-r--r--lib/rubygems/safe_marshal.rb74
-rw-r--r--lib/rubygems/safe_marshal/elements.rb146
-rw-r--r--lib/rubygems/safe_marshal/reader.rb308
-rw-r--r--lib/rubygems/safe_marshal/visitors/stream_printer.rb31
-rw-r--r--lib/rubygems/safe_marshal/visitors/to_ruby.rb415
-rw-r--r--lib/rubygems/safe_marshal/visitors/visitor.rb74
-rw-r--r--lib/rubygems/safe_yaml.rb40
-rw-r--r--lib/rubygems/security.rb37
-rw-r--r--lib/rubygems/security/policies.rb75
-rw-r--r--lib/rubygems/security/policy.rb19
-rw-r--r--lib/rubygems/security/signer.rb15
-rw-r--r--lib/rubygems/security/trust_dir.rb21
-rw-r--r--lib/rubygems/security_option.rb3
-rw-r--r--lib/rubygems/shellwords.rb3
-rw-r--r--lib/rubygems/source.rb32
-rw-r--r--lib/rubygems/source/git.rb10
-rw-r--r--lib/rubygems/source/installed.rb3
-rw-r--r--lib/rubygems/source/local.rb84
-rw-r--r--lib/rubygems/source/lock.rb5
-rw-r--r--lib/rubygems/source/specific_file.rb2
-rw-r--r--lib/rubygems/source/vendor.rb3
-rw-r--r--lib/rubygems/source_list.rb16
-rw-r--r--lib/rubygems/spec_fetcher.rb87
-rw-r--r--lib/rubygems/specification.rb410
-rw-r--r--lib/rubygems/specification_policy.rb168
-rw-r--r--lib/rubygems/stub_specification.rb36
-rw-r--r--lib/rubygems/text.rb3
-rw-r--r--lib/rubygems/tsort.rb3
-rw-r--r--lib/rubygems/tsort/lib/tsort.rb452
-rw-r--r--lib/rubygems/uninstaller.rb23
-rw-r--r--lib/rubygems/update_suggestion.rb25
-rw-r--r--lib/rubygems/uri.rb12
-rw-r--r--lib/rubygems/uri_formatter.rb2
-rw-r--r--lib/rubygems/user_interaction.rb46
-rw-r--r--lib/rubygems/util.rb15
-rw-r--r--lib/rubygems/util/licenses.rb259
-rw-r--r--lib/rubygems/util/list.rb1
-rw-r--r--lib/rubygems/validator.rb21
-rw-r--r--lib/rubygems/vendor/molinillo/.document1
-rw-r--r--lib/rubygems/vendor/molinillo/lib/molinillo.rb11
-rw-r--r--lib/rubygems/vendor/molinillo/lib/molinillo/delegates/resolution_state.rb57
-rw-r--r--lib/rubygems/vendor/molinillo/lib/molinillo/delegates/specification_provider.rb88
-rw-r--r--lib/rubygems/vendor/molinillo/lib/molinillo/dependency_graph.rb255
-rw-r--r--lib/rubygems/vendor/molinillo/lib/molinillo/dependency_graph/action.rb36
-rw-r--r--lib/rubygems/vendor/molinillo/lib/molinillo/dependency_graph/add_edge_no_circular.rb66
-rw-r--r--lib/rubygems/vendor/molinillo/lib/molinillo/dependency_graph/add_vertex.rb62
-rw-r--r--lib/rubygems/vendor/molinillo/lib/molinillo/dependency_graph/delete_edge.rb63
-rw-r--r--lib/rubygems/vendor/molinillo/lib/molinillo/dependency_graph/detach_vertex_named.rb61
-rw-r--r--lib/rubygems/vendor/molinillo/lib/molinillo/dependency_graph/log.rb126
-rw-r--r--lib/rubygems/vendor/molinillo/lib/molinillo/dependency_graph/set_payload.rb46
-rw-r--r--lib/rubygems/vendor/molinillo/lib/molinillo/dependency_graph/tag.rb36
-rw-r--r--lib/rubygems/vendor/molinillo/lib/molinillo/dependency_graph/vertex.rb164
-rw-r--r--lib/rubygems/vendor/molinillo/lib/molinillo/errors.rb149
-rw-r--r--lib/rubygems/vendor/molinillo/lib/molinillo/gem_metadata.rb6
-rw-r--r--lib/rubygems/vendor/molinillo/lib/molinillo/modules/specification_provider.rb112
-rw-r--r--lib/rubygems/vendor/molinillo/lib/molinillo/modules/ui.rb67
-rw-r--r--lib/rubygems/vendor/molinillo/lib/molinillo/resolution.rb839
-rw-r--r--lib/rubygems/vendor/molinillo/lib/molinillo/resolver.rb46
-rw-r--r--lib/rubygems/vendor/molinillo/lib/molinillo/state.rb58
-rw-r--r--lib/rubygems/vendor/net-http/.document1
-rw-r--r--lib/rubygems/vendor/net-http/lib/net/http.rb2496
-rw-r--r--lib/rubygems/vendor/net-http/lib/net/http/backward.rb40
-rw-r--r--lib/rubygems/vendor/net-http/lib/net/http/exceptions.rb34
-rw-r--r--lib/rubygems/vendor/net-http/lib/net/http/generic_request.rb414
-rw-r--r--lib/rubygems/vendor/net-http/lib/net/http/header.rb981
-rw-r--r--lib/rubygems/vendor/net-http/lib/net/http/proxy_delta.rb17
-rw-r--r--lib/rubygems/vendor/net-http/lib/net/http/request.rb88
-rw-r--r--lib/rubygems/vendor/net-http/lib/net/http/requests.rb425
-rw-r--r--lib/rubygems/vendor/net-http/lib/net/http/response.rb738
-rw-r--r--lib/rubygems/vendor/net-http/lib/net/http/responses.rb1174
-rw-r--r--lib/rubygems/vendor/net-http/lib/net/http/status.rb84
-rw-r--r--lib/rubygems/vendor/net-http/lib/net/https.rb23
-rw-r--r--lib/rubygems/vendor/net-protocol/.document1
-rw-r--r--lib/rubygems/vendor/net-protocol/lib/net/protocol.rb544
-rw-r--r--lib/rubygems/vendor/optparse/.document1
-rw-r--r--lib/rubygems/vendor/optparse/lib/optionparser.rb (renamed from lib/rubygems/optparse/lib/optionparser.rb)0
-rw-r--r--lib/rubygems/vendor/optparse/lib/optparse.rb2330
-rw-r--r--lib/rubygems/vendor/optparse/lib/optparse/ac.rb (renamed from lib/rubygems/optparse/lib/optparse/ac.rb)0
-rw-r--r--lib/rubygems/vendor/optparse/lib/optparse/date.rb (renamed from lib/rubygems/optparse/lib/optparse/date.rb)0
-rw-r--r--lib/rubygems/vendor/optparse/lib/optparse/kwargs.rb (renamed from lib/rubygems/optparse/lib/optparse/kwargs.rb)0
-rw-r--r--lib/rubygems/vendor/optparse/lib/optparse/shellwords.rb (renamed from lib/rubygems/optparse/lib/optparse/shellwords.rb)0
-rw-r--r--lib/rubygems/vendor/optparse/lib/optparse/time.rb (renamed from lib/rubygems/optparse/lib/optparse/time.rb)0
-rw-r--r--lib/rubygems/vendor/optparse/lib/optparse/uri.rb7
-rw-r--r--lib/rubygems/vendor/optparse/lib/optparse/version.rb (renamed from lib/rubygems/optparse/lib/optparse/version.rb)0
-rw-r--r--lib/rubygems/vendor/resolv/.document1
-rw-r--r--lib/rubygems/vendor/resolv/lib/resolv.rb3387
-rw-r--r--lib/rubygems/vendor/timeout/.document1
-rw-r--r--lib/rubygems/vendor/timeout/lib/timeout.rb199
-rw-r--r--lib/rubygems/vendor/tsort/.document1
-rw-r--r--lib/rubygems/vendor/tsort/lib/tsort.rb455
-rw-r--r--lib/rubygems/vendor/uri/.document1
-rw-r--r--lib/rubygems/vendor/uri/lib/uri.rb104
-rw-r--r--lib/rubygems/vendor/uri/lib/uri/common.rb853
-rw-r--r--lib/rubygems/vendor/uri/lib/uri/file.rb100
-rw-r--r--lib/rubygems/vendor/uri/lib/uri/ftp.rb267
-rw-r--r--lib/rubygems/vendor/uri/lib/uri/generic.rb1588
-rw-r--r--lib/rubygems/vendor/uri/lib/uri/http.rb125
-rw-r--r--lib/rubygems/vendor/uri/lib/uri/https.rb23
-rw-r--r--lib/rubygems/vendor/uri/lib/uri/ldap.rb261
-rw-r--r--lib/rubygems/vendor/uri/lib/uri/ldaps.rb22
-rw-r--r--lib/rubygems/vendor/uri/lib/uri/mailto.rb293
-rw-r--r--lib/rubygems/vendor/uri/lib/uri/rfc2396_parser.rb539
-rw-r--r--lib/rubygems/vendor/uri/lib/uri/rfc3986_parser.rb183
-rw-r--r--lib/rubygems/vendor/uri/lib/uri/version.rb6
-rw-r--r--lib/rubygems/vendor/uri/lib/uri/ws.rb83
-rw-r--r--lib/rubygems/vendor/uri/lib/uri/wss.rb23
-rw-r--r--lib/rubygems/vendored_molinillo.rb3
-rw-r--r--lib/rubygems/vendored_net_http.rb5
-rw-r--r--lib/rubygems/vendored_optparse.rb3
-rw-r--r--lib/rubygems/vendored_timeout.rb5
-rw-r--r--lib/rubygems/vendored_tsort.rb3
-rw-r--r--lib/rubygems/version.rb71
-rw-r--r--lib/rubygems/version_option.rb8
-rw-r--r--lib/rubygems/yaml_serializer.rb105
-rw-r--r--lib/securerandom.gemspec11
-rw-r--r--lib/securerandom.rb25
-rw-r--r--lib/set.rb60
-rw-r--r--lib/set/set.gemspec13
-rw-r--r--lib/shellwords.gemspec12
-rw-r--r--lib/shellwords.rb2
-rw-r--r--lib/singleton.gemspec30
-rw-r--r--lib/singleton.rb9
-rw-r--r--lib/singleton/singleton.gemspec30
-rw-r--r--lib/syntax_suggest/api.rb53
-rw-r--r--lib/syntax_suggest/around_block_scan.rb290
-rw-r--r--lib/syntax_suggest/block_expand.rb111
-rw-r--r--lib/syntax_suggest/capture/before_after_keyword_ends.rb85
-rw-r--r--lib/syntax_suggest/capture/falling_indent_lines.rb71
-rw-r--r--lib/syntax_suggest/capture_code_context.rb24
-rw-r--r--lib/syntax_suggest/clean_document.rb18
-rw-r--r--lib/syntax_suggest/code_block.rb2
-rw-r--r--lib/syntax_suggest/code_frontier.rb2
-rw-r--r--lib/syntax_suggest/code_line.rb25
-rw-r--r--lib/syntax_suggest/code_search.rb4
-rw-r--r--lib/syntax_suggest/core_ext.rb4
-rw-r--r--lib/syntax_suggest/display_invalid_blocks.rb2
-rw-r--r--lib/syntax_suggest/explain_syntax.rb22
-rw-r--r--lib/syntax_suggest/lex_all.rb39
-rw-r--r--lib/syntax_suggest/parse_blocks_from_indent_line.rb4
-rw-r--r--lib/syntax_suggest/pathname_from_message.rb2
-rw-r--r--lib/syntax_suggest/ripper_errors.rb5
-rw-r--r--lib/syntax_suggest/scan_history.rb134
-rw-r--r--lib/syntax_suggest/syntax_suggest.gemspec4
-rw-r--r--lib/syntax_suggest/version.rb2
-rw-r--r--lib/tempfile.gemspec13
-rw-r--r--lib/tempfile.rb78
-rw-r--r--lib/time.gemspec13
-rw-r--r--lib/time.rb7
-rw-r--r--lib/timeout.gemspec32
-rw-r--r--lib/timeout.rb38
-rw-r--r--lib/timeout/timeout.gemspec30
-rw-r--r--lib/tmpdir.gemspec4
-rw-r--r--lib/tmpdir.rb16
-rw-r--r--lib/tsort.gemspec11
-rw-r--r--lib/tsort.rb3
-rw-r--r--lib/un.gemspec11
-rw-r--r--lib/un.rb4
-rw-r--r--lib/uri/generic.rb1
-rw-r--r--lib/uri/rfc2396_parser.rb4
-rw-r--r--lib/uri/rfc3986_parser.rb128
-rw-r--r--lib/uri/uri.gemspec18
-rw-r--r--lib/uri/version.rb2
-rw-r--r--lib/weakref.gemspec34
-rw-r--r--lib/weakref.rb2
-rw-r--r--lib/weakref/weakref.gemspec34
-rw-r--r--lib/yaml.rb1
-rw-r--r--lib/yaml/store.rb2
-rw-r--r--lib/yaml/yaml.gemspec13
-rwxr-xr-xlibexec/bundle27
-rwxr-xr-xlibexec/racc320
-rw-r--r--load.c234
-rw-r--r--main.c3
-rw-r--r--man/irb.17
-rw-r--r--man/ruby.178
-rw-r--r--marshal.c73
-rw-r--r--math.c82
-rw-r--r--method.h16
-rw-r--r--mini_builtin.c23
-rw-r--r--miniinit.c7
-rw-r--r--misc/.vscode/launch.json13
-rw-r--r--misc/.vscode/settings.json8
-rw-r--r--misc/.vscode/tasks.json14
-rw-r--r--misc/README1
-rw-r--r--misc/call_fuzzer.rb372
-rwxr-xr-xmisc/call_fuzzer.sh13
-rw-r--r--misc/gdb.py181
-rwxr-xr-xmisc/lldb_cruby.py63
-rw-r--r--misc/lldb_rb/commands/heap_page_command.py4
-rw-r--r--misc/lldb_rb/commands/print_flags_command.py31
-rw-r--r--misc/lldb_rb/commands/rb_id2str_command.py49
-rw-r--r--misc/lldb_rb/commands/rp_command.py15
-rw-r--r--misc/lldb_rb/constants.py2
-rw-r--r--misc/lldb_rb/lldb_interface.py7
-rw-r--r--misc/lldb_rb/rb_base_command.py24
-rw-r--r--misc/lldb_rb/rb_heap_structs.py143
-rw-r--r--misc/lldb_rb/utils.py490
-rw-r--r--missing/dtoa.c11
-rw-r--r--missing/explicit_bzero.c5
-rw-r--r--missing/procstat_vm.c34
-rw-r--r--missing/setproctitle.c1
-rw-r--r--mjit.c1988
-rw-r--r--mjit.h145
-rw-r--r--mjit.rb37
-rw-r--r--mjit_c.c43
-rw-r--r--mjit_c.h97
-rw-r--r--mjit_c.rb807
-rw-r--r--node.c1412
-rw-r--r--node.h544
-rw-r--r--node_dump.c1123
-rw-r--r--numeric.c171
-rw-r--r--numeric.rb329
-rw-r--r--object.c463
-rw-r--r--pack.c3
-rw-r--r--parse.y18683
-rw-r--r--parser_bits.h564
-rw-r--r--parser_node.h32
-rw-r--r--parser_st.c164
-rw-r--r--parser_st.h162
-rw-r--r--parser_value.h106
-rw-r--r--prelude.rb2
-rw-r--r--prism/api_pack.c267
-rw-r--r--prism/config.yml2704
-rw-r--r--prism/defines.h94
-rw-r--r--prism/diagnostic.c355
-rw-r--r--prism/diagnostic.h297
-rw-r--r--prism/encoding.c5137
-rw-r--r--prism/encoding.h248
-rw-r--r--prism/extension.c1055
-rw-r--r--prism/extension.h18
-rw-r--r--prism/node.h57
-rw-r--r--prism/options.c189
-rw-r--r--prism/options.h204
-rw-r--r--prism/pack.c493
-rw-r--r--prism/pack.h152
-rw-r--r--prism/parser.h716
-rw-r--r--prism/prettyprint.h26
-rw-r--r--prism/prism.c17486
-rw-r--r--prism/prism.h272
-rw-r--r--prism/regexp.c638
-rw-r--r--prism/regexp.h33
-rw-r--r--prism/templates/ext/prism/api_node.c.erb221
-rw-r--r--prism/templates/include/prism/ast.h.erb206
-rw-r--r--prism/templates/lib/prism/compiler.rb.erb41
-rw-r--r--prism/templates/lib/prism/dispatcher.rb.erb89
-rw-r--r--prism/templates/lib/prism/dot_visitor.rb.erb186
-rw-r--r--prism/templates/lib/prism/dsl.rb.erb45
-rw-r--r--prism/templates/lib/prism/mutation_compiler.rb.erb19
-rw-r--r--prism/templates/lib/prism/node.rb.erb254
-rw-r--r--prism/templates/lib/prism/serialize.rb.erb310
-rw-r--r--prism/templates/lib/prism/visitor.rb.erb50
-rw-r--r--prism/templates/src/node.c.erb162
-rw-r--r--prism/templates/src/prettyprint.c.erb189
-rw-r--r--prism/templates/src/serialize.c.erb380
-rw-r--r--prism/templates/src/token_type.c.erb20
-rwxr-xr-xprism/templates/template.rb472
-rw-r--r--prism/util/pm_buffer.c179
-rw-r--r--prism/util/pm_buffer.h146
-rw-r--r--prism/util/pm_char.c318
-rw-r--r--prism/util/pm_char.h205
-rw-r--r--prism/util/pm_constant_pool.c296
-rw-r--r--prism/util/pm_constant_pool.h191
-rw-r--r--prism/util/pm_list.c49
-rw-r--r--prism/util/pm_list.h97
-rw-r--r--prism/util/pm_memchr.c35
-rw-r--r--prism/util/pm_memchr.h29
-rw-r--r--prism/util/pm_newline_list.c96
-rw-r--r--prism/util/pm_newline_list.h104
-rw-r--r--prism/util/pm_state_stack.c25
-rw-r--r--prism/util/pm_state_stack.h42
-rw-r--r--prism/util/pm_string.c210
-rw-r--r--prism/util/pm_string.h150
-rw-r--r--prism/util/pm_string_list.c28
-rw-r--r--prism/util/pm_string_list.h44
-rw-r--r--prism/util/pm_strncasecmp.c24
-rw-r--r--prism/util/pm_strncasecmp.h32
-rw-r--r--prism/util/pm_strpbrk.c72
-rw-r--r--prism/util/pm_strpbrk.h43
-rw-r--r--prism/version.h29
-rw-r--r--prism_compile.c6532
-rw-r--r--prism_compile.h29
-rw-r--r--prism_init.c9
-rw-r--r--probes_helper.h2
-rw-r--r--proc.c320
-rw-r--r--process.c3057
-rw-r--r--ractor.c2038
-rw-r--r--ractor.rb17
-rw-r--r--ractor_core.h95
-rw-r--r--random.c6
-rw-r--r--range.c444
-rw-r--r--rational.c21
-rw-r--r--re.c629
-rw-r--r--regcomp.c118
-rw-r--r--regexec.c1042
-rw-r--r--regint.h78
-rw-r--r--regparse.c181
-rw-r--r--regparse.h3
-rw-r--r--rjit.c501
-rw-r--r--rjit.h101
-rw-r--r--rjit.rb41
-rw-r--r--rjit_c.c542
-rw-r--r--rjit_c.h164
-rw-r--r--rjit_c.rb1695
-rw-r--r--ruby-runner.c35
-rw-r--r--ruby.c1073
-rw-r--r--ruby_parser.c911
-rw-r--r--rubyparser.h1403
-rw-r--r--sample/all-ruby-quine.rb24
-rw-r--r--sample/dir.rb11
-rw-r--r--scheduler.c100
-rw-r--r--shape.c925
-rw-r--r--shape.h142
-rw-r--r--signal.c172
-rw-r--r--spec/README.md8
-rw-r--r--spec/bundler/bundler/bundler_spec.rb77
-rw-r--r--spec/bundler/bundler/ci_detector_spec.rb21
-rw-r--r--spec/bundler/bundler/cli_spec.rb32
-rw-r--r--spec/bundler/bundler/compact_index_client/updater_spec.rb205
-rw-r--r--spec/bundler/bundler/definition_spec.rb81
-rw-r--r--spec/bundler/bundler/dependency_spec.rb212
-rw-r--r--spec/bundler/bundler/digest_spec.rb6
-rw-r--r--spec/bundler/bundler/dsl_spec.rb115
-rw-r--r--spec/bundler/bundler/endpoint_specification_spec.rb6
-rw-r--r--spec/bundler/bundler/env_spec.rb18
-rw-r--r--spec/bundler/bundler/environment_preserver_spec.rb16
-rw-r--r--spec/bundler/bundler/fetcher/base_spec.rb11
-rw-r--r--spec/bundler/bundler/fetcher/compact_index_spec.rb9
-rw-r--r--spec/bundler/bundler/fetcher/dependency_spec.rb41
-rw-r--r--spec/bundler/bundler/fetcher/downloader_spec.rb70
-rw-r--r--spec/bundler/bundler/fetcher/index_spec.rb30
-rw-r--r--spec/bundler/bundler/fetcher_spec.rb126
-rw-r--r--spec/bundler/bundler/friendly_errors_spec.rb6
-rw-r--r--spec/bundler/bundler/gem_helper_spec.rb40
-rw-r--r--spec/bundler/bundler/gem_version_promoter_spec.rb235
-rw-r--r--spec/bundler/bundler/installer/gem_installer_spec.rb12
-rw-r--r--spec/bundler/bundler/installer/parallel_installer_spec.rb46
-rw-r--r--spec/bundler/bundler/installer/spec_installation_spec.rb18
-rw-r--r--spec/bundler/bundler/lockfile_parser_spec.rb78
-rw-r--r--spec/bundler/bundler/mirror_spec.rb16
-rw-r--r--spec/bundler/bundler/plugin/api/source_spec.rb4
-rw-r--r--spec/bundler/bundler/plugin/dsl_spec.rb6
-rw-r--r--spec/bundler/bundler/plugin/installer_spec.rb21
-rw-r--r--spec/bundler/bundler/plugin_spec.rb10
-rw-r--r--spec/bundler/bundler/remote_specification_spec.rb12
-rw-r--r--spec/bundler/bundler/resolver/candidate_spec.rb6
-rw-r--r--spec/bundler/bundler/ruby_dsl_spec.rb115
-rw-r--r--spec/bundler/bundler/ruby_version_spec.rb10
-rw-r--r--spec/bundler/bundler/rubygems_integration_spec.rb34
-rw-r--r--spec/bundler/bundler/settings/validator_spec.rb6
-rw-r--r--spec/bundler/bundler/settings_spec.rb25
-rw-r--r--spec/bundler/bundler/shared_helpers_spec.rb77
-rw-r--r--spec/bundler/bundler/source/git/git_proxy_spec.rb108
-rw-r--r--spec/bundler/bundler/source/git_spec.rb4
-rw-r--r--spec/bundler/bundler/source/rubygems/remote_spec.rb20
-rw-r--r--spec/bundler/bundler/source_list_spec.rb6
-rw-r--r--spec/bundler/bundler/source_spec.rb20
-rw-r--r--spec/bundler/bundler/spec_set_spec.rb18
-rw-r--r--spec/bundler/bundler/specifications/foo.gemspec13
-rw-r--r--spec/bundler/bundler/stub_specification_spec.rb11
-rw-r--r--spec/bundler/bundler/uri_credentials_filter_spec.rb10
-rw-r--r--spec/bundler/bundler/yaml_serializer_spec.rb57
-rw-r--r--spec/bundler/cache/gems_spec.rb77
-rw-r--r--spec/bundler/cache/git_spec.rb61
-rw-r--r--spec/bundler/cache/path_spec.rb10
-rw-r--r--spec/bundler/cache/platform_spec.rb2
-rw-r--r--spec/bundler/commands/add_spec.rb40
-rw-r--r--spec/bundler/commands/binstubs_spec.rb77
-rw-r--r--spec/bundler/commands/cache_spec.rb22
-rw-r--r--spec/bundler/commands/check_spec.rb68
-rw-r--r--spec/bundler/commands/clean_spec.rb46
-rw-r--r--spec/bundler/commands/config_spec.rb34
-rw-r--r--spec/bundler/commands/console_spec.rb2
-rw-r--r--spec/bundler/commands/doctor_spec.rb7
-rw-r--r--spec/bundler/commands/exec_spec.rb129
-rw-r--r--spec/bundler/commands/help_spec.rb2
-rw-r--r--spec/bundler/commands/info_spec.rb24
-rw-r--r--spec/bundler/commands/init_spec.rb37
-rw-r--r--spec/bundler/commands/inject_spec.rb10
-rw-r--r--spec/bundler/commands/install_spec.rb393
-rw-r--r--spec/bundler/commands/list_spec.rb12
-rw-r--r--spec/bundler/commands/lock_spec.rb750
-rw-r--r--spec/bundler/commands/newgem_spec.rb116
-rw-r--r--spec/bundler/commands/open_spec.rb54
-rw-r--r--spec/bundler/commands/outdated_spec.rb178
-rw-r--r--spec/bundler/commands/platform_spec.rb140
-rw-r--r--spec/bundler/commands/post_bundle_message_spec.rb16
-rw-r--r--spec/bundler/commands/pristine_spec.rb20
-rw-r--r--spec/bundler/commands/remove_spec.rb22
-rw-r--r--spec/bundler/commands/show_spec.rb22
-rw-r--r--spec/bundler/commands/update_spec.rb484
-rw-r--r--spec/bundler/commands/version_spec.rb16
-rw-r--r--spec/bundler/commands/viz_spec.rb16
-rw-r--r--spec/bundler/install/allow_offline_install_spec.rb18
-rw-r--r--spec/bundler/install/bundler_spec.rb20
-rw-r--r--spec/bundler/install/deploy_spec.rb209
-rw-r--r--spec/bundler/install/failure_spec.rb4
-rw-r--r--spec/bundler/install/gemfile/eval_gemfile_spec.rb8
-rw-r--r--spec/bundler/install/gemfile/force_ruby_platform_spec.rb32
-rw-r--r--spec/bundler/install/gemfile/gemspec_spec.rb169
-rw-r--r--spec/bundler/install/gemfile/git_spec.rb201
-rw-r--r--spec/bundler/install/gemfile/groups_spec.rb42
-rw-r--r--spec/bundler/install/gemfile/install_if_spec.rb9
-rw-r--r--spec/bundler/install/gemfile/lockfile_spec.rb5
-rw-r--r--spec/bundler/install/gemfile/path_spec.rb242
-rw-r--r--spec/bundler/install/gemfile/platform_spec.rb43
-rw-r--r--spec/bundler/install/gemfile/ruby_spec.rb36
-rw-r--r--spec/bundler/install/gemfile/sources_spec.rb530
-rw-r--r--spec/bundler/install/gemfile/specific_platform_spec.rb607
-rw-r--r--spec/bundler/install/gemfile_spec.rb10
-rw-r--r--spec/bundler/install/gems/compact_index_spec.rb389
-rw-r--r--spec/bundler/install/gems/dependency_api_spec.rb142
-rw-r--r--spec/bundler/install/gems/flex_spec.rb31
-rw-r--r--spec/bundler/install/gems/native_extensions_spec.rb8
-rw-r--r--spec/bundler/install/gems/resolving_spec.rb132
-rw-r--r--spec/bundler/install/gems/standalone_spec.rb102
-rw-r--r--spec/bundler/install/gemspecs_spec.rb30
-rw-r--r--spec/bundler/install/git_spec.rb139
-rw-r--r--spec/bundler/install/global_cache_spec.rb44
-rw-r--r--spec/bundler/install/path_spec.rb36
-rw-r--r--spec/bundler/install/redownload_spec.rb2
-rw-r--r--spec/bundler/install/security_policy_spec.rb12
-rw-r--r--spec/bundler/install/yanked_spec.rb22
-rw-r--r--spec/bundler/lock/git_spec.rb31
-rw-r--r--spec/bundler/lock/lockfile_spec.rb516
-rw-r--r--spec/bundler/other/cli_dispatch_spec.rb6
-rw-r--r--spec/bundler/other/ext_spec.rb24
-rw-r--r--spec/bundler/other/major_deprecation_spec.rb193
-rw-r--r--spec/bundler/plugins/command_spec.rb2
-rw-r--r--spec/bundler/plugins/install_spec.rb96
-rw-r--r--spec/bundler/plugins/source/example_spec.rb14
-rw-r--r--spec/bundler/plugins/uninstall_spec.rb25
-rw-r--r--spec/bundler/quality_spec.rb18
-rw-r--r--spec/bundler/realworld/dependency_api_spec.rb16
-rw-r--r--spec/bundler/realworld/double_check_spec.rb6
-rw-r--r--spec/bundler/realworld/edgecases_spec.rb155
-rw-r--r--spec/bundler/realworld/ffi_spec.rb2
-rw-r--r--spec/bundler/realworld/fixtures/warbler/Gemfile2
-rw-r--r--spec/bundler/realworld/gemfile_source_header_spec.rb18
-rw-r--r--spec/bundler/realworld/git_spec.rb2
-rw-r--r--spec/bundler/realworld/mirror_probe_spec.rb22
-rw-r--r--spec/bundler/realworld/parallel_spec.rb8
-rw-r--r--spec/bundler/realworld/slow_perf_spec.rb117
-rw-r--r--spec/bundler/resolver/basic_spec.rb80
-rw-r--r--spec/bundler/resolver/platform_spec.rb2
-rw-r--r--spec/bundler/runtime/executable_spec.rb22
-rw-r--r--spec/bundler/runtime/gem_tasks_spec.rb10
-rw-r--r--spec/bundler/runtime/inline_spec.rb106
-rw-r--r--spec/bundler/runtime/load_spec.rb2
-rw-r--r--spec/bundler/runtime/platform_spec.rb35
-rw-r--r--spec/bundler/runtime/require_spec.rb12
-rw-r--r--spec/bundler/runtime/requiring_spec.rb15
-rw-r--r--spec/bundler/runtime/self_management_spec.rb51
-rw-r--r--spec/bundler/runtime/setup_spec.rb208
-rw-r--r--spec/bundler/runtime/with_unbundled_env_spec.rb16
-rw-r--r--spec/bundler/spec_helper.rb10
-rw-r--r--spec/bundler/support/activate.rb9
-rw-r--r--spec/bundler/support/api_request_limit_hax.rb16
-rw-r--r--spec/bundler/support/artifice/compact_index_checksum_mismatch.rb4
-rw-r--r--spec/bundler/support/artifice/compact_index_concurrent_download.rb7
-rw-r--r--spec/bundler/support/artifice/compact_index_etag_match.rb16
-rw-r--r--spec/bundler/support/artifice/compact_index_host_redirect.rb2
-rw-r--r--spec/bundler/support/artifice/compact_index_partial_update.rb2
-rw-r--r--spec/bundler/support/artifice/compact_index_partial_update_bad_digest.rb40
-rw-r--r--spec/bundler/support/artifice/compact_index_partial_update_no_digest_not_incremental.rb42
-rw-r--r--spec/bundler/support/artifice/compact_index_partial_update_no_etag_not_incremental.rb40
-rw-r--r--spec/bundler/support/artifice/compact_index_range_ignored.rb40
-rw-r--r--spec/bundler/support/artifice/compact_index_strict_basic_authentication.rb2
-rw-r--r--spec/bundler/support/artifice/compact_index_wrong_gem_checksum.rb3
-rw-r--r--spec/bundler/support/artifice/endpoint_500.rb2
-rw-r--r--spec/bundler/support/artifice/endpoint_host_redirect.rb2
-rw-r--r--spec/bundler/support/artifice/endpoint_mirror_source.rb2
-rw-r--r--spec/bundler/support/artifice/endpoint_strict_basic_authentication.rb2
-rw-r--r--spec/bundler/support/artifice/fail.rb14
-rw-r--r--spec/bundler/support/artifice/helpers/artifice.rb6
-rw-r--r--spec/bundler/support/artifice/helpers/compact_index.rb27
-rw-r--r--spec/bundler/support/artifice/helpers/endpoint.rb10
-rw-r--r--spec/bundler/support/artifice/helpers/rack_request.rb24
-rw-r--r--spec/bundler/support/artifice/vcr.rb14
-rw-r--r--spec/bundler/support/artifice/windows.rb2
-rw-r--r--spec/bundler/support/build_metadata.rb14
-rw-r--r--spec/bundler/support/builders.rb114
-rw-r--r--spec/bundler/support/bundle.rb7
-rw-r--r--spec/bundler/support/checksums.rb114
-rw-r--r--spec/bundler/support/command_execution.rb15
-rw-r--r--spec/bundler/support/filters.rb22
-rw-r--r--spec/bundler/support/helpers.rb126
-rw-r--r--spec/bundler/support/indexes.rb16
-rw-r--r--spec/bundler/support/matchers.rb12
-rw-r--r--spec/bundler/support/path.rb36
-rw-r--r--spec/bundler/support/platforms.rb21
-rw-r--r--spec/bundler/support/rubygems_ext.rb11
-rw-r--r--spec/bundler/support/rubygems_version_manager.rb9
-rw-r--r--spec/bundler/update/gemfile_spec.rb10
-rw-r--r--spec/bundler/update/gems/fund_spec.rb2
-rw-r--r--spec/bundler/update/gems/post_install_spec.rb4
-rw-r--r--spec/bundler/update/git_spec.rb71
-rw-r--r--spec/bundler/update/path_spec.rb4
-rw-r--r--spec/bundler/update/redownload_spec.rb14
-rw-r--r--spec/default.mspec69
-rwxr-xr-xspec/mspec/lib/mspec/commands/mspec.rb5
-rw-r--r--spec/mspec/lib/mspec/helpers/io.rb4
-rw-r--r--spec/mspec/lib/mspec/helpers/ruby_exe.rb54
-rw-r--r--spec/mspec/lib/mspec/matchers/complain.rb2
-rw-r--r--spec/mspec/lib/mspec/runner/actions/timeout.rb78
-rw-r--r--spec/mspec/lib/mspec/runner/mspec.rb5
-rw-r--r--spec/mspec/lib/mspec/utils/options.rb2
-rw-r--r--spec/mspec/lib/mspec/utils/warnings.rb43
-rw-r--r--spec/mspec/spec/commands/mspec_spec.rb27
-rw-r--r--spec/mspec/spec/helpers/ruby_exe_spec.rb10
-rw-r--r--spec/mspec/spec/runner/context_spec.rb2
-rwxr-xr-xspec/mspec/tool/check_require_spec_helper.rb34
-rw-r--r--spec/mspec/tool/remove_old_guards.rb51
-rwxr-xr-xspec/mspec/tool/tag_from_output.rb10
-rw-r--r--spec/ruby/.mspec.constants1
-rw-r--r--spec/ruby/.rubocop.yml6
-rw-r--r--spec/ruby/.rubocop_todo.yml1
-rw-r--r--spec/ruby/CONTRIBUTING.md15
-rw-r--r--spec/ruby/README.md11
-rw-r--r--spec/ruby/command_line/backtrace_limit_spec.rb44
-rw-r--r--spec/ruby/command_line/dash_a_spec.rb4
-rw-r--r--spec/ruby/command_line/dash_l_spec.rb8
-rw-r--r--spec/ruby/command_line/dash_n_spec.rb8
-rw-r--r--spec/ruby/command_line/dash_p_spec.rb4
-rw-r--r--spec/ruby/command_line/dash_upper_f_spec.rb2
-rw-r--r--spec/ruby/command_line/dash_upper_u_spec.rb7
-rw-r--r--spec/ruby/command_line/dash_v_spec.rb3
-rw-r--r--spec/ruby/command_line/fixtures/bin/embedded_ruby.txt2
-rw-r--r--spec/ruby/command_line/fixtures/freeze_flag_required_diff_enc.rbbin121 -> 90 bytes-rw-r--r--spec/ruby/command_line/rubyopt_spec.rb14
-rw-r--r--spec/ruby/core/argf/bytes_spec.rb16
-rw-r--r--spec/ruby/core/argf/chars_spec.rb16
-rw-r--r--spec/ruby/core/argf/codepoints_spec.rb16
-rw-r--r--spec/ruby/core/argf/lines_spec.rb16
-rw-r--r--spec/ruby/core/argf/readpartial_spec.rb2
-rw-r--r--spec/ruby/core/array/all_spec.rb13
-rw-r--r--spec/ruby/core/array/any_spec.rb12
-rw-r--r--spec/ruby/core/array/assoc_spec.rb14
-rw-r--r--spec/ruby/core/array/bsearch_index_spec.rb4
-rw-r--r--spec/ruby/core/array/count_spec.rb11
-rw-r--r--spec/ruby/core/array/delete_if_spec.rb30
-rw-r--r--spec/ruby/core/array/drop_spec.rb12
-rw-r--r--spec/ruby/core/array/drop_while_spec.rb16
-rw-r--r--spec/ruby/core/array/each_index_spec.rb16
-rw-r--r--spec/ruby/core/array/each_spec.rb5
-rw-r--r--spec/ruby/core/array/fill_spec.rb80
-rw-r--r--spec/ruby/core/array/fixtures/classes.rb10
-rw-r--r--spec/ruby/core/array/flatten_spec.rb24
-rw-r--r--spec/ruby/core/array/initialize_spec.rb4
-rw-r--r--spec/ruby/core/array/intersect_spec.rb53
-rw-r--r--spec/ruby/core/array/multiply_spec.rb18
-rw-r--r--spec/ruby/core/array/new_spec.rb4
-rw-r--r--spec/ruby/core/array/none_spec.rb13
-rw-r--r--spec/ruby/core/array/one_spec.rb13
-rw-r--r--spec/ruby/core/array/pack/c_spec.rb4
-rw-r--r--spec/ruby/core/array/pack/shared/float.rb16
-rw-r--r--spec/ruby/core/array/pack/shared/integer.rb36
-rw-r--r--spec/ruby/core/array/pack/shared/unicode.rb4
-rw-r--r--spec/ruby/core/array/pack/w_spec.rb4
-rw-r--r--spec/ruby/core/array/plus_spec.rb21
-rw-r--r--spec/ruby/core/array/product_spec.rb5
-rw-r--r--spec/ruby/core/array/rassoc_spec.rb14
-rw-r--r--spec/ruby/core/array/reject_spec.rb15
-rw-r--r--spec/ruby/core/array/reverse_each_spec.rb14
-rw-r--r--spec/ruby/core/array/rindex_spec.rb15
-rw-r--r--spec/ruby/core/array/sample_spec.rb4
-rw-r--r--spec/ruby/core/array/shared/collect.rb32
-rw-r--r--spec/ruby/core/array/shared/index.rb4
-rw-r--r--spec/ruby/core/array/shared/intersection.rb3
-rw-r--r--spec/ruby/core/array/shared/iterable_and_tolerating_size_increasing.rb25
-rw-r--r--spec/ruby/core/array/shared/keep_if.rb35
-rw-r--r--spec/ruby/core/array/shared/select.rb3
-rw-r--r--spec/ruby/core/array/shared/slice.rb400
-rw-r--r--spec/ruby/core/array/shuffle_spec.rb14
-rw-r--r--spec/ruby/core/array/slice_spec.rb60
-rw-r--r--spec/ruby/core/array/sort_by_spec.rb33
-rw-r--r--spec/ruby/core/array/sum_spec.rb21
-rw-r--r--spec/ruby/core/array/take_spec.rb12
-rw-r--r--spec/ruby/core/array/take_while_spec.rb16
-rw-r--r--spec/ruby/core/array/to_h_spec.rb6
-rw-r--r--spec/ruby/core/array/try_convert_spec.rb2
-rw-r--r--spec/ruby/core/array/uniq_spec.rb46
-rw-r--r--spec/ruby/core/basicobject/fixtures/classes.rb228
-rw-r--r--spec/ruby/core/basicobject/instance_eval_spec.rb124
-rw-r--r--spec/ruby/core/basicobject/method_missing_spec.rb1
-rw-r--r--spec/ruby/core/binding/clone_spec.rb6
-rw-r--r--spec/ruby/core/binding/dup_spec.rb6
-rw-r--r--spec/ruby/core/binding/eval_spec.rb99
-rw-r--r--spec/ruby/core/binding/shared/clone.rb22
-rw-r--r--spec/ruby/core/binding/source_location_spec.rb5
-rw-r--r--spec/ruby/core/class/dup_spec.rb3
-rw-r--r--spec/ruby/core/complex/inspect_spec.rb19
-rw-r--r--spec/ruby/core/complex/to_s_spec.rb10
-rw-r--r--spec/ruby/core/data/constants_spec.rb16
-rw-r--r--spec/ruby/core/data/define_spec.rb36
-rw-r--r--spec/ruby/core/data/fixtures/classes.rb5
-rw-r--r--spec/ruby/core/data/initialize_spec.rb58
-rw-r--r--spec/ruby/core/dir/exist_spec.rb8
-rw-r--r--spec/ruby/core/dir/fchdir_spec.rb68
-rw-r--r--spec/ruby/core/dir/glob_spec.rb138
-rw-r--r--spec/ruby/core/dir/home_spec.rb33
-rw-r--r--spec/ruby/core/dir/shared/chroot.rb4
-rw-r--r--spec/ruby/core/dir/shared/exist.rb8
-rw-r--r--spec/ruby/core/dir/shared/glob.rb26
-rw-r--r--spec/ruby/core/encoding/converter/primitive_convert_spec.rb4
-rw-r--r--spec/ruby/core/encoding/default_external_spec.rb8
-rw-r--r--spec/ruby/core/encoding/invalid_byte_sequence_error/destination_encoding_name_spec.rb1
-rw-r--r--spec/ruby/core/encoding/invalid_byte_sequence_error/destination_encoding_spec.rb1
-rw-r--r--spec/ruby/core/encoding/invalid_byte_sequence_error/error_bytes_spec.rb1
-rw-r--r--spec/ruby/core/encoding/invalid_byte_sequence_error/readagain_bytes_spec.rb1
-rw-r--r--spec/ruby/core/encoding/invalid_byte_sequence_error/source_encoding_name_spec.rb1
-rw-r--r--spec/ruby/core/encoding/invalid_byte_sequence_error/source_encoding_spec.rb1
-rw-r--r--spec/ruby/core/encoding/name_spec.rb1
-rw-r--r--spec/ruby/core/encoding/replicate_spec.rb8
-rw-r--r--spec/ruby/core/encoding/to_s_spec.rb1
-rw-r--r--spec/ruby/core/encoding/undefined_conversion_error/destination_encoding_name_spec.rb1
-rw-r--r--spec/ruby/core/encoding/undefined_conversion_error/destination_encoding_spec.rb1
-rw-r--r--spec/ruby/core/encoding/undefined_conversion_error/error_char_spec.rb1
-rw-r--r--spec/ruby/core/encoding/undefined_conversion_error/source_encoding_name_spec.rb1
-rw-r--r--spec/ruby/core/encoding/undefined_conversion_error/source_encoding_spec.rb1
-rw-r--r--spec/ruby/core/enumerable/all_spec.rb6
-rw-r--r--spec/ruby/core/enumerable/any_spec.rb6
-rw-r--r--spec/ruby/core/enumerable/chunk_spec.rb5
-rw-r--r--spec/ruby/core/enumerable/grep_spec.rb49
-rw-r--r--spec/ruby/core/enumerable/grep_v_spec.rb49
-rw-r--r--spec/ruby/core/enumerable/none_spec.rb6
-rw-r--r--spec/ruby/core/enumerable/one_spec.rb7
-rw-r--r--spec/ruby/core/enumerable/shared/inject.rb44
-rw-r--r--spec/ruby/core/enumerable/sum_spec.rb2
-rw-r--r--spec/ruby/core/enumerable/tally_spec.rb13
-rw-r--r--spec/ruby/core/enumerator/chain/initialize_spec.rb4
-rw-r--r--spec/ruby/core/enumerator/chain/inspect_spec.rb4
-rw-r--r--spec/ruby/core/enumerator/each_spec.rb18
-rw-r--r--spec/ruby/core/enumerator/generator/initialize_spec.rb4
-rw-r--r--spec/ruby/core/enumerator/initialize_spec.rb12
-rw-r--r--spec/ruby/core/enumerator/inspect_spec.rb5
-rw-r--r--spec/ruby/core/enumerator/lazy/compact_spec.rb5
-rw-r--r--spec/ruby/core/enumerator/lazy/initialize_spec.rb4
-rw-r--r--spec/ruby/core/enumerator/new_spec.rb47
-rw-r--r--spec/ruby/core/enumerator/product/each_spec.rb73
-rw-r--r--spec/ruby/core/enumerator/product/initialize_copy_spec.rb54
-rw-r--r--spec/ruby/core/enumerator/product/initialize_spec.rb33
-rw-r--r--spec/ruby/core/enumerator/product/inspect_spec.rb22
-rw-r--r--spec/ruby/core/enumerator/product/rewind_spec.rb64
-rw-r--r--spec/ruby/core/enumerator/product/size_spec.rb64
-rw-r--r--spec/ruby/core/enumerator/product_spec.rb93
-rw-r--r--spec/ruby/core/enumerator/rewind_spec.rb4
-rw-r--r--spec/ruby/core/env/clone_spec.rb23
-rw-r--r--spec/ruby/core/env/delete_spec.rb16
-rw-r--r--spec/ruby/core/env/dup_spec.rb11
-rw-r--r--spec/ruby/core/env/except_spec.rb44
-rw-r--r--spec/ruby/core/env/index_spec.rb14
-rw-r--r--spec/ruby/core/env/indexes_spec.rb1
-rw-r--r--spec/ruby/core/env/indices_spec.rb1
-rw-r--r--spec/ruby/core/env/key_spec.rb32
-rw-r--r--spec/ruby/core/env/shared/include.rb7
-rw-r--r--spec/ruby/core/env/shared/key.rb31
-rw-r--r--spec/ruby/core/env/shared/value.rb7
-rw-r--r--spec/ruby/core/env/slice_spec.rb10
-rw-r--r--spec/ruby/core/env/to_a_spec.rb5
-rw-r--r--spec/ruby/core/exception/case_compare_spec.rb2
-rw-r--r--spec/ruby/core/exception/detailed_message_spec.rb43
-rw-r--r--spec/ruby/core/exception/equal_value_spec.rb14
-rw-r--r--spec/ruby/core/exception/fixtures/common.rb4
-rw-r--r--spec/ruby/core/exception/fixtures/thread_fiber_ensure.rb22
-rw-r--r--spec/ruby/core/exception/fixtures/thread_fiber_ensure_non_root_fiber.rb25
-rw-r--r--spec/ruby/core/exception/full_message_spec.rb92
-rw-r--r--spec/ruby/core/exception/no_method_error_spec.rb79
-rw-r--r--spec/ruby/core/exception/top_level_spec.rb12
-rw-r--r--spec/ruby/core/false/singleton_method_spec.rb15
-rw-r--r--spec/ruby/core/fiber/blocking_spec.rb68
-rw-r--r--spec/ruby/core/fiber/inspect_spec.rb36
-rw-r--r--spec/ruby/core/fiber/kill_spec.rb90
-rw-r--r--spec/ruby/core/fiber/raise_spec.rb28
-rw-r--r--spec/ruby/core/fiber/resume_spec.rb15
-rw-r--r--spec/ruby/core/fiber/storage_spec.rb99
-rw-r--r--spec/ruby/core/file/absolute_path_spec.rb2
-rw-r--r--spec/ruby/core/file/dirname_spec.rb39
-rw-r--r--spec/ruby/core/file/exist_spec.rb8
-rw-r--r--spec/ruby/core/file/flock_spec.rb4
-rw-r--r--spec/ruby/core/file/new_spec.rb65
-rw-r--r--spec/ruby/core/file/open_spec.rb17
-rw-r--r--spec/ruby/core/file/realpath_spec.rb4
-rw-r--r--spec/ruby/core/file/shared/fnmatch.rb47
-rw-r--r--spec/ruby/core/file/utime_spec.rb8
-rw-r--r--spec/ruby/core/float/magnitude_spec.rb1
-rw-r--r--spec/ruby/core/gc/auto_compact_spec.rb36
-rw-r--r--spec/ruby/core/hash/compact_spec.rb24
-rw-r--r--spec/ruby/core/hash/constructor_spec.rb18
-rw-r--r--spec/ruby/core/hash/except_spec.rb50
-rw-r--r--spec/ruby/core/hash/fetch_spec.rb2
-rw-r--r--spec/ruby/core/hash/fetch_values_spec.rb2
-rw-r--r--spec/ruby/core/hash/hash_spec.rb2
-rw-r--r--spec/ruby/core/hash/index_spec.rb9
-rw-r--r--spec/ruby/core/hash/new_spec.rb13
-rw-r--r--spec/ruby/core/hash/ruby2_keywords_hash_spec.rb24
-rw-r--r--spec/ruby/core/hash/shared/each.rb37
-rw-r--r--spec/ruby/core/hash/shared/equal.rb90
-rw-r--r--spec/ruby/core/hash/to_a_spec.rb10
-rw-r--r--spec/ruby/core/hash/to_proc_spec.rb16
-rw-r--r--spec/ruby/core/hash/transform_keys_spec.rb32
-rw-r--r--spec/ruby/core/hash/try_convert_spec.rb2
-rw-r--r--spec/ruby/core/integer/bit_and_spec.rb2
-rw-r--r--spec/ruby/core/integer/bit_or_spec.rb6
-rw-r--r--spec/ruby/core/integer/bit_xor_spec.rb4
-rw-r--r--spec/ruby/core/integer/ceildiv_spec.rb22
-rw-r--r--spec/ruby/core/integer/shared/arithmetic_coerce.rb20
-rw-r--r--spec/ruby/core/integer/try_convert_spec.rb12
-rw-r--r--spec/ruby/core/integer/zero_spec.rb12
-rw-r--r--spec/ruby/core/io/binread_spec.rb10
-rw-r--r--spec/ruby/core/io/bytes_spec.rb47
-rw-r--r--spec/ruby/core/io/chars_spec.rb30
-rw-r--r--spec/ruby/core/io/codepoints_spec.rb38
-rw-r--r--spec/ruby/core/io/copy_stream_spec.rb33
-rw-r--r--spec/ruby/core/io/eof_spec.rb2
-rw-r--r--spec/ruby/core/io/flush_spec.rb10
-rw-r--r--spec/ruby/core/io/foreach_spec.rb19
-rw-r--r--spec/ruby/core/io/getbyte_spec.rb16
-rw-r--r--spec/ruby/core/io/gets_spec.rb47
-rw-r--r--spec/ruby/core/io/initialize_spec.rb11
-rw-r--r--spec/ruby/core/io/lines_spec.rb46
-rw-r--r--spec/ruby/core/io/new_spec.rb8
-rw-r--r--spec/ruby/core/io/nonblock_spec.rb46
-rw-r--r--spec/ruby/core/io/open_spec.rb13
-rw-r--r--spec/ruby/core/io/pread_spec.rb79
-rw-r--r--spec/ruby/core/io/pwrite_spec.rb32
-rw-r--r--spec/ruby/core/io/read_spec.rb129
-rw-r--r--spec/ruby/core/io/readline_spec.rb12
-rw-r--r--spec/ruby/core/io/readlines_spec.rb39
-rw-r--r--spec/ruby/core/io/select_spec.rb15
-rw-r--r--spec/ruby/core/io/shared/binwrite.rb13
-rw-r--r--spec/ruby/core/io/shared/each.rb20
-rw-r--r--spec/ruby/core/io/shared/new.rb50
-rw-r--r--spec/ruby/core/io/shared/readlines.rb20
-rw-r--r--spec/ruby/core/io/shared/write.rb65
-rw-r--r--spec/ruby/core/io/syswrite_spec.rb1
-rw-r--r--spec/ruby/core/io/try_convert_spec.rb2
-rw-r--r--spec/ruby/core/io/ungetc_spec.rb16
-rw-r--r--spec/ruby/core/io/write_nonblock_spec.rb1
-rw-r--r--spec/ruby/core/io/write_spec.rb159
-rw-r--r--spec/ruby/core/kernel/Complex_spec.rb4
-rw-r--r--spec/ruby/core/kernel/Integer_spec.rb38
-rw-r--r--spec/ruby/core/kernel/__dir___spec.rb16
-rw-r--r--spec/ruby/core/kernel/at_exit_spec.rb61
-rw-r--r--spec/ruby/core/kernel/clone_spec.rb86
-rw-r--r--spec/ruby/core/kernel/define_singleton_method_spec.rb6
-rw-r--r--spec/ruby/core/kernel/eval_spec.rb48
-rw-r--r--spec/ruby/core/kernel/exec_spec.rb4
-rw-r--r--spec/ruby/core/kernel/exit_spec.rb10
-rw-r--r--spec/ruby/core/kernel/fixtures/at_exit.rb3
-rw-r--r--spec/ruby/core/kernel/initialize_clone_spec.rb10
-rw-r--r--spec/ruby/core/kernel/initialize_copy_spec.rb9
-rw-r--r--spec/ruby/core/kernel/iterator_spec.rb14
-rw-r--r--spec/ruby/core/kernel/lambda_spec.rb74
-rw-r--r--spec/ruby/core/kernel/method_spec.rb21
-rw-r--r--spec/ruby/core/kernel/open_spec.rb87
-rw-r--r--spec/ruby/core/kernel/printf_spec.rb7
-rw-r--r--spec/ruby/core/kernel/proc_spec.rb18
-rw-r--r--spec/ruby/core/kernel/require_relative_spec.rb8
-rw-r--r--spec/ruby/core/kernel/require_spec.rb20
-rw-r--r--spec/ruby/core/kernel/shared/load.rb38
-rw-r--r--spec/ruby/core/kernel/shared/require.rb93
-rw-r--r--spec/ruby/core/kernel/shared/sprintf.rb4
-rw-r--r--spec/ruby/core/kernel/singleton_class_spec.rb49
-rw-r--r--spec/ruby/core/kernel/sleep_spec.rb28
-rw-r--r--spec/ruby/core/kernel/sprintf_spec.rb16
-rw-r--r--spec/ruby/core/kernel/taint_spec.rb16
-rw-r--r--spec/ruby/core/kernel/tainted_spec.rb20
-rw-r--r--spec/ruby/core/kernel/test_spec.rb4
-rw-r--r--spec/ruby/core/kernel/trust_spec.rb18
-rw-r--r--spec/ruby/core/kernel/untaint_spec.rb18
-rw-r--r--spec/ruby/core/kernel/untrust_spec.rb16
-rw-r--r--spec/ruby/core/kernel/untrusted_spec.rb18
-rw-r--r--spec/ruby/core/kernel/warn_spec.rb141
-rw-r--r--spec/ruby/core/main/private_spec.rb12
-rw-r--r--spec/ruby/core/main/public_spec.rb12
-rw-r--r--spec/ruby/core/marshal/dump_spec.rb222
-rw-r--r--spec/ruby/core/marshal/fixtures/marshal_data.rb96
-rw-r--r--spec/ruby/core/marshal/shared/load.rb300
-rw-r--r--spec/ruby/core/matchdata/byteoffset_spec.rb95
-rw-r--r--spec/ruby/core/matchdata/captures_spec.rb13
-rw-r--r--spec/ruby/core/matchdata/deconstruct_keys_spec.rb65
-rw-r--r--spec/ruby/core/matchdata/deconstruct_spec.rb8
-rw-r--r--spec/ruby/core/matchdata/element_reference_spec.rb13
-rw-r--r--spec/ruby/core/matchdata/named_captures_spec.rb12
-rw-r--r--spec/ruby/core/matchdata/post_match_spec.rb8
-rw-r--r--spec/ruby/core/matchdata/pre_match_spec.rb8
-rw-r--r--spec/ruby/core/matchdata/shared/captures.rb13
-rw-r--r--spec/ruby/core/matchdata/to_a_spec.rb8
-rw-r--r--spec/ruby/core/matchdata/to_s_spec.rb8
-rw-r--r--spec/ruby/core/matchdata/values_at_spec.rb4
-rw-r--r--spec/ruby/core/math/cos_spec.rb26
-rw-r--r--spec/ruby/core/method/clone_spec.rb15
-rw-r--r--spec/ruby/core/method/compose_spec.rb3
-rw-r--r--spec/ruby/core/method/dup_spec.rb15
-rw-r--r--spec/ruby/core/method/parameters_spec.rb47
-rw-r--r--spec/ruby/core/method/private_spec.rb11
-rw-r--r--spec/ruby/core/method/protected_spec.rb11
-rw-r--r--spec/ruby/core/method/public_spec.rb11
-rw-r--r--spec/ruby/core/method/shared/dup.rb32
-rw-r--r--spec/ruby/core/method/shared/to_s.rb30
-rw-r--r--spec/ruby/core/method/source_location_spec.rb9
-rw-r--r--spec/ruby/core/method/super_method_spec.rb10
-rw-r--r--spec/ruby/core/module/alias_method_spec.rb20
-rw-r--r--spec/ruby/core/module/attr_accessor_spec.rb16
-rw-r--r--spec/ruby/core/module/attr_reader_spec.rb16
-rw-r--r--spec/ruby/core/module/attr_spec.rb22
-rw-r--r--spec/ruby/core/module/attr_writer_spec.rb16
-rw-r--r--spec/ruby/core/module/const_added_spec.rb35
-rw-r--r--spec/ruby/core/module/const_defined_spec.rb21
-rw-r--r--spec/ruby/core/module/const_get_spec.rb2
-rw-r--r--spec/ruby/core/module/const_set_spec.rb18
-rw-r--r--spec/ruby/core/module/const_source_location_spec.rb14
-rw-r--r--spec/ruby/core/module/define_method_spec.rb46
-rw-r--r--spec/ruby/core/module/fixtures/classes.rb26
-rw-r--r--spec/ruby/core/module/fixtures/module.rb4
-rw-r--r--spec/ruby/core/module/method_added_spec.rb73
-rw-r--r--spec/ruby/core/module/module_function_spec.rb136
-rw-r--r--spec/ruby/core/module/name_spec.rb54
-rw-r--r--spec/ruby/core/module/prepend_spec.rb39
-rw-r--r--spec/ruby/core/module/private_class_method_spec.rb14
-rw-r--r--spec/ruby/core/module/public_class_method_spec.rb20
-rw-r--r--spec/ruby/core/module/refine_spec.rb2
-rw-r--r--spec/ruby/core/module/refinements_spec.rb45
-rw-r--r--spec/ruby/core/module/ruby2_keywords_spec.rb22
-rw-r--r--spec/ruby/core/module/set_temporary_name_spec.rb68
-rw-r--r--spec/ruby/core/module/shared/class_eval.rb6
-rw-r--r--spec/ruby/core/module/shared/set_visibility.rb28
-rw-r--r--spec/ruby/core/module/undefined_instance_methods_spec.rb26
-rw-r--r--spec/ruby/core/module/used_refinements_spec.rb87
-rw-r--r--spec/ruby/core/mutex/lock_spec.rb4
-rw-r--r--spec/ruby/core/mutex/owned_spec.rb18
-rw-r--r--spec/ruby/core/nil/singleton_method_spec.rb15
-rw-r--r--spec/ruby/core/numeric/clone_spec.rb10
-rw-r--r--spec/ruby/core/numeric/fdiv_spec.rb1
-rw-r--r--spec/ruby/core/numeric/magnitude_spec.rb1
-rw-r--r--spec/ruby/core/numeric/quo_spec.rb1
-rw-r--r--spec/ruby/core/numeric/shared/quo.rb7
-rw-r--r--spec/ruby/core/numeric/shared/step.rb8
-rw-r--r--spec/ruby/core/numeric/step_spec.rb85
-rw-r--r--spec/ruby/core/objectspace/define_finalizer_spec.rb78
-rw-r--r--spec/ruby/core/objectspace/weakkeymap/delete_spec.rb40
-rw-r--r--spec/ruby/core/objectspace/weakkeymap/element_reference_spec.rb26
-rw-r--r--spec/ruby/core/objectspace/weakkeymap/element_set_spec.rb71
-rw-r--r--spec/ruby/core/objectspace/weakkeymap/getkey_spec.rb14
-rw-r--r--spec/ruby/core/objectspace/weakkeymap/inspect_spec.rb17
-rw-r--r--spec/ruby/core/objectspace/weakkeymap/key_spec.rb33
-rw-r--r--spec/ruby/core/objectspace/weakmap/delete_spec.rb30
-rw-r--r--spec/ruby/core/proc/clone_spec.rb9
-rw-r--r--spec/ruby/core/proc/compose_spec.rb46
-rw-r--r--spec/ruby/core/proc/dup_spec.rb7
-rw-r--r--spec/ruby/core/proc/eql_spec.rb8
-rw-r--r--spec/ruby/core/proc/equal_value_spec.rb8
-rw-r--r--spec/ruby/core/proc/lambda_spec.rb8
-rw-r--r--spec/ruby/core/proc/new_spec.rb35
-rw-r--r--spec/ruby/core/proc/parameters_spec.rb50
-rw-r--r--spec/ruby/core/proc/ruby2_keywords_spec.rb22
-rw-r--r--spec/ruby/core/proc/shared/dup.rb31
-rw-r--r--spec/ruby/core/proc/shared/equal.rb17
-rw-r--r--spec/ruby/core/proc/source_location_spec.rb13
-rw-r--r--spec/ruby/core/process/argv0_spec.rb25
-rw-r--r--spec/ruby/core/process/constants_spec.rb8
-rw-r--r--spec/ruby/core/process/detach_spec.rb14
-rw-r--r--spec/ruby/core/process/exec_spec.rb44
-rw-r--r--spec/ruby/core/process/exit_spec.rb2
-rw-r--r--spec/ruby/core/process/fixtures/argv0.rb6
-rw-r--r--spec/ruby/core/process/spawn_spec.rb2
-rw-r--r--spec/ruby/core/process/status/wait_spec.rb158
-rw-r--r--spec/ruby/core/process/times_spec.rb20
-rw-r--r--spec/ruby/core/process/wait2_spec.rb4
-rw-r--r--spec/ruby/core/process/wait_spec.rb2
-rw-r--r--spec/ruby/core/process/warmup_spec.rb11
-rw-r--r--spec/ruby/core/queue/deq_spec.rb7
-rw-r--r--spec/ruby/core/queue/initialize_spec.rb33
-rw-r--r--spec/ruby/core/queue/pop_spec.rb7
-rw-r--r--spec/ruby/core/queue/shift_spec.rb7
-rw-r--r--spec/ruby/core/random/bytes_spec.rb1
-rw-r--r--spec/ruby/core/random/default_spec.rb24
-rw-r--r--spec/ruby/core/random/new_spec.rb1
-rw-r--r--spec/ruby/core/range/case_compare_spec.rb6
-rw-r--r--spec/ruby/core/range/cover_spec.rb4
-rw-r--r--spec/ruby/core/range/frozen_spec.rb34
-rw-r--r--spec/ruby/core/range/include_spec.rb4
-rw-r--r--spec/ruby/core/range/initialize_spec.rb15
-rw-r--r--spec/ruby/core/range/max_spec.rb18
-rw-r--r--spec/ruby/core/range/minmax_spec.rb24
-rw-r--r--spec/ruby/core/range/new_spec.rb14
-rw-r--r--spec/ruby/core/range/shared/cover_and_include.rb1
-rw-r--r--spec/ruby/core/range/size_spec.rb4
-rw-r--r--spec/ruby/core/range/step_spec.rb52
-rw-r--r--spec/ruby/core/rational/abs_spec.rb1
-rw-r--r--spec/ruby/core/rational/ceil_spec.rb1
-rw-r--r--spec/ruby/core/rational/coerce_spec.rb1
-rw-r--r--spec/ruby/core/rational/comparison_spec.rb1
-rw-r--r--spec/ruby/core/rational/denominator_spec.rb1
-rw-r--r--spec/ruby/core/rational/div_spec.rb1
-rw-r--r--spec/ruby/core/rational/divide_spec.rb1
-rw-r--r--spec/ruby/core/rational/divmod_spec.rb1
-rw-r--r--spec/ruby/core/rational/equal_value_spec.rb1
-rw-r--r--spec/ruby/core/rational/exponent_spec.rb1
-rw-r--r--spec/ruby/core/rational/fdiv_spec.rb1
-rw-r--r--spec/ruby/core/rational/floor_spec.rb1
-rw-r--r--spec/ruby/core/rational/hash_spec.rb1
-rw-r--r--spec/ruby/core/rational/inspect_spec.rb1
-rw-r--r--spec/ruby/core/rational/integer_spec.rb1
-rw-r--r--spec/ruby/core/rational/magnitude_spec.rb1
-rw-r--r--spec/ruby/core/rational/modulo_spec.rb1
-rw-r--r--spec/ruby/core/rational/multiply_spec.rb1
-rw-r--r--spec/ruby/core/rational/numerator_spec.rb1
-rw-r--r--spec/ruby/core/rational/plus_spec.rb1
-rw-r--r--spec/ruby/core/rational/quo_spec.rb1
-rw-r--r--spec/ruby/core/rational/remainder_spec.rb1
-rw-r--r--spec/ruby/core/rational/to_f_spec.rb1
-rw-r--r--spec/ruby/core/rational/to_i_spec.rb1
-rw-r--r--spec/ruby/core/rational/to_r_spec.rb1
-rw-r--r--spec/ruby/core/rational/to_s_spec.rb1
-rw-r--r--spec/ruby/core/rational/truncate_spec.rb1
-rw-r--r--spec/ruby/core/rational/zero_spec.rb1
-rw-r--r--spec/ruby/core/refinement/extend_object_spec.rb6
-rw-r--r--spec/ruby/core/refinement/fixtures/classes.rb10
-rw-r--r--spec/ruby/core/refinement/import_methods_spec.rb235
-rw-r--r--spec/ruby/core/refinement/refined_class_spec.rb17
-rw-r--r--spec/ruby/core/regexp/initialize_spec.rb12
-rw-r--r--spec/ruby/core/regexp/linear_time_spec.rb25
-rw-r--r--spec/ruby/core/regexp/shared/new.rb4
-rw-r--r--spec/ruby/core/regexp/try_convert_spec.rb6
-rw-r--r--spec/ruby/core/regexp/union_spec.rb51
-rw-r--r--spec/ruby/core/signal/signame_spec.rb12
-rw-r--r--spec/ruby/core/signal/trap_spec.rb19
-rw-r--r--spec/ruby/core/sizedqueue/append_spec.rb7
-rw-r--r--spec/ruby/core/sizedqueue/deq_spec.rb7
-rw-r--r--spec/ruby/core/sizedqueue/enq_spec.rb7
-rw-r--r--spec/ruby/core/sizedqueue/pop_spec.rb7
-rw-r--r--spec/ruby/core/sizedqueue/push_spec.rb7
-rw-r--r--spec/ruby/core/sizedqueue/shift_spec.rb7
-rw-r--r--spec/ruby/core/string/append_spec.rb1
-rw-r--r--spec/ruby/core/string/byteindex_spec.rb304
-rw-r--r--spec/ruby/core/string/byterindex_spec.rb359
-rw-r--r--spec/ruby/core/string/bytesplice_spec.rb133
-rw-r--r--spec/ruby/core/string/capitalize_spec.rb15
-rw-r--r--spec/ruby/core/string/casecmp_spec.rb10
-rw-r--r--spec/ruby/core/string/center_spec.rb25
-rw-r--r--spec/ruby/core/string/chars_spec.rb1
-rw-r--r--spec/ruby/core/string/chomp_spec.rb15
-rw-r--r--spec/ruby/core/string/chop_spec.rb12
-rw-r--r--spec/ruby/core/string/concat_spec.rb1
-rw-r--r--spec/ruby/core/string/dedup_spec.rb2
-rw-r--r--spec/ruby/core/string/delete_prefix_spec.rb15
-rw-r--r--spec/ruby/core/string/delete_spec.rb12
-rw-r--r--spec/ruby/core/string/delete_suffix_spec.rb15
-rw-r--r--spec/ruby/core/string/downcase_spec.rb12
-rw-r--r--spec/ruby/core/string/dump_spec.rb12
-rw-r--r--spec/ruby/core/string/each_char_spec.rb1
-rw-r--r--spec/ruby/core/string/each_grapheme_cluster_spec.rb11
-rw-r--r--spec/ruby/core/string/encode_spec.rb4
-rw-r--r--spec/ruby/core/string/grapheme_clusters_spec.rb1
-rw-r--r--spec/ruby/core/string/gsub_spec.rb21
-rw-r--r--spec/ruby/core/string/index_spec.rb18
-rw-r--r--spec/ruby/core/string/ljust_spec.rb25
-rw-r--r--spec/ruby/core/string/lstrip_spec.rb18
-rw-r--r--spec/ruby/core/string/plus_spec.rb5
-rw-r--r--spec/ruby/core/string/reverse_spec.rb18
-rw-r--r--spec/ruby/core/string/rindex_spec.rb9
-rw-r--r--spec/ruby/core/string/rjust_spec.rb25
-rw-r--r--spec/ruby/core/string/rstrip_spec.rb10
-rw-r--r--spec/ruby/core/string/scan_spec.rb10
-rw-r--r--spec/ruby/core/string/scrub_spec.rb36
-rw-r--r--spec/ruby/core/string/shared/byte_index_common.rb63
-rw-r--r--spec/ruby/core/string/shared/concat.rb32
-rw-r--r--spec/ruby/core/string/shared/dedup.rb8
-rw-r--r--spec/ruby/core/string/shared/each_line.rb18
-rw-r--r--spec/ruby/core/string/shared/partition.rb34
-rw-r--r--spec/ruby/core/string/shared/slice.rb114
-rw-r--r--spec/ruby/core/string/shared/strip.rb18
-rw-r--r--spec/ruby/core/string/shared/succ.rb18
-rw-r--r--spec/ruby/core/string/shared/to_a.rb9
-rw-r--r--spec/ruby/core/string/shared/to_sym.rb2
-rw-r--r--spec/ruby/core/string/slice_spec.rb93
-rw-r--r--spec/ruby/core/string/split_spec.rb112
-rw-r--r--spec/ruby/core/string/squeeze_spec.rb12
-rw-r--r--spec/ruby/core/string/start_with_spec.rb17
-rw-r--r--spec/ruby/core/string/strip_spec.rb16
-rw-r--r--spec/ruby/core/string/sub_spec.rb21
-rw-r--r--spec/ruby/core/string/swapcase_spec.rb15
-rw-r--r--spec/ruby/core/string/to_c_spec.rb12
-rw-r--r--spec/ruby/core/string/tr_s_spec.rb21
-rw-r--r--spec/ruby/core/string/tr_spec.rb21
-rw-r--r--spec/ruby/core/string/try_convert_spec.rb2
-rw-r--r--spec/ruby/core/string/unpack/b_spec.rb8
-rw-r--r--spec/ruby/core/string/unpack/c_spec.rb4
-rw-r--r--spec/ruby/core/string/unpack/h_spec.rb8
-rw-r--r--spec/ruby/core/string/unpack/shared/float.rb20
-rw-r--r--spec/ruby/core/string/unpack/shared/integer.rb28
-rw-r--r--spec/ruby/core/string/unpack/shared/unicode.rb4
-rw-r--r--spec/ruby/core/string/unpack/w_spec.rb4
-rw-r--r--spec/ruby/core/string/upcase_spec.rb12
-rw-r--r--spec/ruby/core/string/uplus_spec.rb3
-rw-r--r--spec/ruby/core/string/upto_spec.rb6
-rw-r--r--spec/ruby/core/string/valid_encoding_spec.rb10
-rw-r--r--spec/ruby/core/struct/constants_spec.rb15
-rw-r--r--spec/ruby/core/struct/deconstruct_keys_spec.rb2
-rw-r--r--spec/ruby/core/struct/fixtures/classes.rb6
-rw-r--r--spec/ruby/core/struct/initialize_spec.rb10
-rw-r--r--spec/ruby/core/struct/inspect_spec.rb5
-rw-r--r--spec/ruby/core/struct/keyword_init_spec.rb19
-rw-r--r--spec/ruby/core/struct/new_spec.rb19
-rw-r--r--spec/ruby/core/struct/shared/inspect.rb35
-rw-r--r--spec/ruby/core/symbol/casecmp_spec.rb8
-rw-r--r--spec/ruby/core/symbol/inspect_spec.rb2
-rw-r--r--spec/ruby/core/symbol/name_spec.rb24
-rw-r--r--spec/ruby/core/symbol/to_proc_spec.rb39
-rw-r--r--spec/ruby/core/thread/backtrace/location/path_spec.rb2
-rw-r--r--spec/ruby/core/thread/each_caller_location_spec.rb49
-rw-r--r--spec/ruby/core/thread/exclusive_spec.rb49
-rw-r--r--spec/ruby/core/thread/ignore_deadlock_spec.rb26
-rw-r--r--spec/ruby/core/thread/kill_spec.rb4
-rw-r--r--spec/ruby/core/thread/native_thread_id_spec.rb40
-rw-r--r--spec/ruby/core/thread/report_on_exception_spec.rb44
-rw-r--r--spec/ruby/core/thread/shared/exit.rb19
-rw-r--r--spec/ruby/core/time/deconstruct_keys_spec.rb44
-rw-r--r--spec/ruby/core/time/new_spec.rb200
-rw-r--r--spec/ruby/core/time/now_spec.rb66
-rw-r--r--spec/ruby/core/time/succ_spec.rb39
-rw-r--r--spec/ruby/core/time/utc_spec.rb10
-rw-r--r--spec/ruby/core/time/zone_spec.rb11
-rw-r--r--spec/ruby/core/tracepoint/enable_spec.rb8
-rw-r--r--spec/ruby/core/tracepoint/inspect_spec.rb8
-rw-r--r--spec/ruby/core/tracepoint/path_spec.rb31
-rw-r--r--spec/ruby/core/true/singleton_method_spec.rb15
-rw-r--r--spec/ruby/core/unboundmethod/bind_call_spec.rb8
-rw-r--r--spec/ruby/core/unboundmethod/bind_spec.rb8
-rw-r--r--spec/ruby/core/unboundmethod/clone_spec.rb13
-rw-r--r--spec/ruby/core/unboundmethod/dup_spec.rb15
-rw-r--r--spec/ruby/core/unboundmethod/fixtures/classes.rb4
-rw-r--r--spec/ruby/core/unboundmethod/private_spec.rb11
-rw-r--r--spec/ruby/core/unboundmethod/protected_spec.rb11
-rw-r--r--spec/ruby/core/unboundmethod/public_spec.rb11
-rw-r--r--spec/ruby/core/unboundmethod/shared/dup.rb32
-rw-r--r--spec/ruby/core/unboundmethod/source_location_spec.rb9
-rw-r--r--spec/ruby/core/unboundmethod/super_method_spec.rb10
-rw-r--r--spec/ruby/core/warning/element_reference_spec.rb13
-rw-r--r--spec/ruby/core/warning/element_set_spec.rb20
-rw-r--r--spec/ruby/core/warning/warn_spec.rb103
-rw-r--r--spec/ruby/fixtures/code/concurrent_require_fixture.rb4
-rw-r--r--spec/ruby/fixtures/code/d/load_fixture.rb.rb1
-rw-r--r--spec/ruby/fixtures/constants.rb3
-rw-r--r--spec/ruby/language/END_spec.rb26
-rw-r--r--spec/ruby/language/alias_spec.rb20
-rw-r--r--spec/ruby/language/block_spec.rb172
-rw-r--r--spec/ruby/language/case_spec.rb104
-rw-r--r--spec/ruby/language/class_spec.rb18
-rw-r--r--spec/ruby/language/class_variable_spec.rb56
-rw-r--r--spec/ruby/language/constants_spec.rb38
-rw-r--r--spec/ruby/language/defined_spec.rb26
-rw-r--r--spec/ruby/language/delegation_spec.rb38
-rw-r--r--spec/ruby/language/file_spec.rb12
-rw-r--r--spec/ruby/language/fixtures/freeze_magic_comment_required_diff_enc.rbbin181 -> 120 bytes-rw-r--r--spec/ruby/language/fixtures/super.rb14
-rw-r--r--spec/ruby/language/fixtures/variables.rb72
-rw-r--r--spec/ruby/language/hash_spec.rb48
-rw-r--r--spec/ruby/language/if_spec.rb43
-rw-r--r--spec/ruby/language/keyword_arguments_spec.rb555
-rw-r--r--spec/ruby/language/lambda_spec.rb68
-rw-r--r--spec/ruby/language/method_spec.rb731
-rw-r--r--spec/ruby/language/module_spec.rb18
-rw-r--r--spec/ruby/language/numbered_parameters_spec.rb66
-rw-r--r--spec/ruby/language/pattern_matching_spec.rb276
-rw-r--r--spec/ruby/language/predefined_spec.rb45
-rw-r--r--spec/ruby/language/proc_spec.rb26
-rw-r--r--spec/ruby/language/regexp/character_classes_spec.rb10
-rw-r--r--spec/ruby/language/regexp/repetition_spec.rb8
-rw-r--r--spec/ruby/language/regexp_spec.rb6
-rw-r--r--spec/ruby/language/return_spec.rb15
-rw-r--r--spec/ruby/language/safe_spec.rb28
-rw-r--r--spec/ruby/language/send_spec.rb36
-rw-r--r--spec/ruby/language/singleton_class_spec.rb24
-rw-r--r--spec/ruby/language/source_encoding_spec.rb2
-rw-r--r--spec/ruby/language/string_spec.rb24
-rw-r--r--spec/ruby/language/super_spec.rb23
-rw-r--r--spec/ruby/language/symbol_spec.rb4
-rw-r--r--spec/ruby/language/undef_spec.rb9
-rw-r--r--spec/ruby/language/variables_spec.rb99
-rw-r--r--spec/ruby/language/yield_spec.rb31
-rw-r--r--spec/ruby/library/English/English_spec.rb16
-rw-r--r--spec/ruby/library/bigdecimal/add_spec.rb2
-rw-r--r--spec/ruby/library/bigdecimal/remainder_spec.rb28
-rw-r--r--spec/ruby/library/bigdecimal/round_spec.rb4
-rw-r--r--spec/ruby/library/bigdecimal/shared/to_int.rb2
-rw-r--r--spec/ruby/library/bigdecimal/to_s_spec.rb27
-rw-r--r--spec/ruby/library/cgi/escapeURIComponent_spec.rb57
-rw-r--r--spec/ruby/library/cgi/initialize_spec.rb2
-rw-r--r--spec/ruby/library/coverage/supported_spec.rb32
-rw-r--r--spec/ruby/library/date/deconstruct_keys_spec.rb44
-rw-r--r--spec/ruby/library/date/iso8601_spec.rb21
-rw-r--r--spec/ruby/library/date/new_spec.rb1
-rw-r--r--spec/ruby/library/date/parse_spec.rb10
-rw-r--r--spec/ruby/library/date/shared/new_bang.rb14
-rw-r--r--spec/ruby/library/date/shared/parse.rb4
-rw-r--r--spec/ruby/library/date/shared/parse_eu.rb8
-rw-r--r--spec/ruby/library/date/shared/parse_us.rb8
-rw-r--r--spec/ruby/library/date/strftime_spec.rb6
-rw-r--r--spec/ruby/library/datetime/deconstruct_keys_spec.rb46
-rw-r--r--spec/ruby/library/datetime/rfc2822_spec.rb4
-rw-r--r--spec/ruby/library/datetime/strftime_spec.rb5
-rw-r--r--spec/ruby/library/datetime/to_time_spec.rb4
-rw-r--r--spec/ruby/library/delegate/delegate_class/respond_to_missing_spec.rb1
-rw-r--r--spec/ruby/library/digest/instance/shared/update.rb2
-rw-r--r--spec/ruby/library/digest/md5/shared/sample.rb17
-rw-r--r--spec/ruby/library/erb/new_spec.rb2
-rw-r--r--spec/ruby/library/etc/confstr_spec.rb2
-rw-r--r--spec/ruby/library/etc/passwd_spec.rb2
-rw-r--r--spec/ruby/library/etc/sysconf_spec.rb2
-rw-r--r--spec/ruby/library/etc/sysconfdir_spec.rb2
-rw-r--r--spec/ruby/library/etc/systmpdir_spec.rb2
-rw-r--r--spec/ruby/library/etc/uname_spec.rb14
-rw-r--r--spec/ruby/library/expect/expect_spec.rb3
-rw-r--r--spec/ruby/library/fiber/current_spec.rb21
-rw-r--r--spec/ruby/library/fiber/resume_spec.rb35
-rw-r--r--spec/ruby/library/fiber/transfer_spec.rb56
-rw-r--r--spec/ruby/library/io-wait/fixtures/classes.rb12
-rw-r--r--spec/ruby/library/io-wait/wait_spec.rb144
-rw-r--r--spec/ruby/library/ipaddr/new_spec.rb10
-rw-r--r--spec/ruby/library/logger/device/close_spec.rb15
-rw-r--r--spec/ruby/library/logger/device/write_spec.rb15
-rw-r--r--spec/ruby/library/matrix/unitary_spec.rb6
-rw-r--r--spec/ruby/library/monitor/exit_spec.rb10
-rw-r--r--spec/ruby/library/net/ftp/shared/getbinaryfile.rb4
-rw-r--r--spec/ruby/library/net/ftp/shared/gettextfile.rb2
-rw-r--r--spec/ruby/library/net/ftp/shared/putbinaryfile.rb4
-rw-r--r--spec/ruby/library/net/ftp/shared/puttextfile.rb2
-rw-r--r--spec/ruby/library/net/ftp/storbinary_spec.rb2
-rw-r--r--spec/ruby/library/net/ftp/storlines_spec.rb2
-rw-r--r--spec/ruby/library/net/http/http/get_spec.rb16
-rw-r--r--spec/ruby/library/objectspace/dump_all_spec.rb112
-rw-r--r--spec/ruby/library/objectspace/dump_spec.rb70
-rw-r--r--spec/ruby/library/openssl/config/freeze_spec.rb22
-rw-r--r--spec/ruby/library/openssl/digest/append_spec.rb6
-rw-r--r--spec/ruby/library/openssl/digest/block_length_spec.rb44
-rw-r--r--spec/ruby/library/openssl/digest/digest_length_spec.rb44
-rw-r--r--spec/ruby/library/openssl/digest/digest_spec.rb62
-rw-r--r--spec/ruby/library/openssl/digest/initialize_spec.rb141
-rw-r--r--spec/ruby/library/openssl/digest/name_spec.rb16
-rw-r--r--spec/ruby/library/openssl/digest/reset_spec.rb36
-rw-r--r--spec/ruby/library/openssl/digest/shared/update.rb123
-rw-r--r--spec/ruby/library/openssl/digest/update_spec.rb6
-rw-r--r--spec/ruby/library/openssl/digest_spec.rb63
-rw-r--r--spec/ruby/library/openssl/fixed_length_secure_compare_spec.rb42
-rw-r--r--spec/ruby/library/openssl/kdf/pbkdf2_hmac_spec.rb168
-rw-r--r--spec/ruby/library/openssl/kdf/scrypt_spec.rb209
-rw-r--r--spec/ruby/library/openssl/random/shared/random_bytes.rb2
-rw-r--r--spec/ruby/library/openssl/secure_compare_spec.rb38
-rw-r--r--spec/ruby/library/openssl/x509/name/verify_spec.rb78
-rw-r--r--spec/ruby/library/openssl/x509/store/verify_spec.rb78
-rw-r--r--spec/ruby/library/pathname/relative_path_from_spec.rb4
-rw-r--r--spec/ruby/library/rexml/attribute/clone_spec.rb14
-rw-r--r--spec/ruby/library/rexml/attribute/element_spec.rb26
-rw-r--r--spec/ruby/library/rexml/attribute/equal_value_spec.rb21
-rw-r--r--spec/ruby/library/rexml/attribute/hash_spec.rb16
-rw-r--r--spec/ruby/library/rexml/attribute/initialize_spec.rb32
-rw-r--r--spec/ruby/library/rexml/attribute/inspect_spec.rb22
-rw-r--r--spec/ruby/library/rexml/attribute/namespace_spec.rb27
-rw-r--r--spec/ruby/library/rexml/attribute/node_type_spec.rb13
-rw-r--r--spec/ruby/library/rexml/attribute/prefix_spec.rb21
-rw-r--r--spec/ruby/library/rexml/attribute/remove_spec.rb23
-rw-r--r--spec/ruby/library/rexml/attribute/to_s_spec.rb17
-rw-r--r--spec/ruby/library/rexml/attribute/to_string_spec.rb17
-rw-r--r--spec/ruby/library/rexml/attribute/value_spec.rb17
-rw-r--r--spec/ruby/library/rexml/attribute/write_spec.rb26
-rw-r--r--spec/ruby/library/rexml/attribute/xpath_spec.rb22
-rw-r--r--spec/ruby/library/rexml/attributes/add_spec.rb10
-rw-r--r--spec/ruby/library/rexml/attributes/append_spec.rb10
-rw-r--r--spec/ruby/library/rexml/attributes/delete_all_spec.rb34
-rw-r--r--spec/ruby/library/rexml/attributes/delete_spec.rb30
-rw-r--r--spec/ruby/library/rexml/attributes/each_attribute_spec.rb25
-rw-r--r--spec/ruby/library/rexml/attributes/each_spec.rb26
-rw-r--r--spec/ruby/library/rexml/attributes/element_reference_spec.rb21
-rw-r--r--spec/ruby/library/rexml/attributes/element_set_spec.rb28
-rw-r--r--spec/ruby/library/rexml/attributes/get_attribute_ns_spec.rb17
-rw-r--r--spec/ruby/library/rexml/attributes/get_attribute_spec.rb32
-rw-r--r--spec/ruby/library/rexml/attributes/initialize_spec.rb21
-rw-r--r--spec/ruby/library/rexml/attributes/length_spec.rb10
-rw-r--r--spec/ruby/library/rexml/attributes/namespaces_spec.rb9
-rw-r--r--spec/ruby/library/rexml/attributes/prefixes_spec.rb27
-rw-r--r--spec/ruby/library/rexml/attributes/shared/add.rb17
-rw-r--r--spec/ruby/library/rexml/attributes/shared/length.rb13
-rw-r--r--spec/ruby/library/rexml/attributes/size_spec.rb10
-rw-r--r--spec/ruby/library/rexml/attributes/to_a_spec.rb22
-rw-r--r--spec/ruby/library/rexml/cdata/clone_spec.rb13
-rw-r--r--spec/ruby/library/rexml/cdata/initialize_spec.rb27
-rw-r--r--spec/ruby/library/rexml/cdata/shared/to_s.rb11
-rw-r--r--spec/ruby/library/rexml/cdata/to_s_spec.rb10
-rw-r--r--spec/ruby/library/rexml/cdata/value_spec.rb10
-rw-r--r--spec/ruby/library/rexml/document/add_element_spec.rb34
-rw-r--r--spec/ruby/library/rexml/document/add_spec.rb60
-rw-r--r--spec/ruby/library/rexml/document/clone_spec.rb23
-rw-r--r--spec/ruby/library/rexml/document/doctype_spec.rb18
-rw-r--r--spec/ruby/library/rexml/document/encoding_spec.rb25
-rw-r--r--spec/ruby/library/rexml/document/expanded_name_spec.rb19
-rw-r--r--spec/ruby/library/rexml/document/new_spec.rb39
-rw-r--r--spec/ruby/library/rexml/document/node_type_spec.rb11
-rw-r--r--spec/ruby/library/rexml/document/root_spec.rb15
-rw-r--r--spec/ruby/library/rexml/document/stand_alone_spec.rb22
-rw-r--r--spec/ruby/library/rexml/document/version_spec.rb17
-rw-r--r--spec/ruby/library/rexml/document/write_spec.rb38
-rw-r--r--spec/ruby/library/rexml/document/xml_decl_spec.rb18
-rw-r--r--spec/ruby/library/rexml/element/add_attribute_spec.rb44
-rw-r--r--spec/ruby/library/rexml/element/add_attributes_spec.rb25
-rw-r--r--spec/ruby/library/rexml/element/add_element_spec.rb41
-rw-r--r--spec/ruby/library/rexml/element/add_namespace_spec.rb26
-rw-r--r--spec/ruby/library/rexml/element/add_text_spec.rb27
-rw-r--r--spec/ruby/library/rexml/element/attribute_spec.rb20
-rw-r--r--spec/ruby/library/rexml/element/attributes_spec.rb22
-rw-r--r--spec/ruby/library/rexml/element/cdatas_spec.rb27
-rw-r--r--spec/ruby/library/rexml/element/clone_spec.rb32
-rw-r--r--spec/ruby/library/rexml/element/comments_spec.rb23
-rw-r--r--spec/ruby/library/rexml/element/delete_attribute_spec.rb42
-rw-r--r--spec/ruby/library/rexml/element/delete_element_spec.rb52
-rw-r--r--spec/ruby/library/rexml/element/delete_namespace_spec.rb28
-rw-r--r--spec/ruby/library/rexml/element/document_spec.rb19
-rw-r--r--spec/ruby/library/rexml/element/each_element_with_attribute_spec.rb38
-rw-r--r--spec/ruby/library/rexml/element/each_element_with_text_spec.rb34
-rw-r--r--spec/ruby/library/rexml/element/element_reference_spec.rb23
-rw-r--r--spec/ruby/library/rexml/element/get_text_spec.rb21
-rw-r--r--spec/ruby/library/rexml/element/has_attributes_spec.rb20
-rw-r--r--spec/ruby/library/rexml/element/has_elements_spec.rb21
-rw-r--r--spec/ruby/library/rexml/element/has_text_spec.rb19
-rw-r--r--spec/ruby/library/rexml/element/inspect_spec.rb30
-rw-r--r--spec/ruby/library/rexml/element/instructions_spec.rb24
-rw-r--r--spec/ruby/library/rexml/element/namespace_spec.rb30
-rw-r--r--spec/ruby/library/rexml/element/namespaces_spec.rb35
-rw-r--r--spec/ruby/library/rexml/element/new_spec.rb38
-rw-r--r--spec/ruby/library/rexml/element/next_element_spec.rb22
-rw-r--r--spec/ruby/library/rexml/element/node_type_spec.rb11
-rw-r--r--spec/ruby/library/rexml/element/prefixes_spec.rb26
-rw-r--r--spec/ruby/library/rexml/element/previous_element_spec.rb23
-rw-r--r--spec/ruby/library/rexml/element/raw_spec.rb27
-rw-r--r--spec/ruby/library/rexml/element/root_spec.rb31
-rw-r--r--spec/ruby/library/rexml/element/text_spec.rb49
-rw-r--r--spec/ruby/library/rexml/element/texts_spec.rb19
-rw-r--r--spec/ruby/library/rexml/element/whitespace_spec.rb26
-rw-r--r--spec/ruby/library/rexml/node/each_recursive_spec.rb24
-rw-r--r--spec/ruby/library/rexml/node/find_first_recursive_spec.rb28
-rw-r--r--spec/ruby/library/rexml/node/index_in_parent_spec.rb18
-rw-r--r--spec/ruby/library/rexml/node/next_sibling_node_spec.rb24
-rw-r--r--spec/ruby/library/rexml/node/parent_spec.rb23
-rw-r--r--spec/ruby/library/rexml/node/previous_sibling_node_spec.rb24
-rw-r--r--spec/ruby/library/rexml/shared/each_element.rb36
-rw-r--r--spec/ruby/library/rexml/shared/elements_to_a.rb34
-rw-r--r--spec/ruby/library/rexml/text/append_spec.rb13
-rw-r--r--spec/ruby/library/rexml/text/clone_spec.rb13
-rw-r--r--spec/ruby/library/rexml/text/comparison_spec.rb28
-rw-r--r--spec/ruby/library/rexml/text/empty_spec.rb15
-rw-r--r--spec/ruby/library/rexml/text/indent_text_spec.rb26
-rw-r--r--spec/ruby/library/rexml/text/inspect_spec.rb11
-rw-r--r--spec/ruby/library/rexml/text/new_spec.rb51
-rw-r--r--spec/ruby/library/rexml/text/node_type_spec.rb11
-rw-r--r--spec/ruby/library/rexml/text/normalize_spec.rb11
-rw-r--r--spec/ruby/library/rexml/text/read_with_substitution_spec.rb15
-rw-r--r--spec/ruby/library/rexml/text/to_s_spec.rb20
-rw-r--r--spec/ruby/library/rexml/text/unnormalize_spec.rb11
-rw-r--r--spec/ruby/library/rexml/text/value_spec.rb40
-rw-r--r--spec/ruby/library/rexml/text/wrap_spec.rb23
-rw-r--r--spec/ruby/library/rexml/text/write_with_substitution_spec.rb36
-rw-r--r--spec/ruby/library/rubygems/gem/load_path_insert_index_spec.rb2
-rw-r--r--spec/ruby/library/set/comparison_spec.rb56
-rw-r--r--spec/ruby/library/set/divide_spec.rb35
-rw-r--r--spec/ruby/library/set/each_spec.rb1
-rw-r--r--spec/ruby/library/set/enumerable/to_set_spec.rb8
-rw-r--r--spec/ruby/library/set/flatten_spec.rb9
-rw-r--r--spec/ruby/library/set/initialize_clone_spec.rb22
-rw-r--r--spec/ruby/library/set/join_spec.rb42
-rw-r--r--spec/ruby/library/set/proper_subset_spec.rb9
-rw-r--r--spec/ruby/library/set/shared/inspect.rb20
-rw-r--r--spec/ruby/library/set/sortedset/add_spec.rb42
-rw-r--r--spec/ruby/library/set/sortedset/append_spec.rb10
-rw-r--r--spec/ruby/library/set/sortedset/case_equality_spec.rb10
-rw-r--r--spec/ruby/library/set/sortedset/classify_spec.rb30
-rw-r--r--spec/ruby/library/set/sortedset/clear_spec.rb20
-rw-r--r--spec/ruby/library/set/sortedset/collect_spec.rb10
-rw-r--r--spec/ruby/library/set/sortedset/constructor_spec.rb18
-rw-r--r--spec/ruby/library/set/sortedset/delete_if_spec.rb41
-rw-r--r--spec/ruby/library/set/sortedset/delete_spec.rb40
-rw-r--r--spec/ruby/library/set/sortedset/difference_spec.rb10
-rw-r--r--spec/ruby/library/set/sortedset/divide_spec.rb37
-rw-r--r--spec/ruby/library/set/sortedset/each_spec.rb29
-rw-r--r--spec/ruby/library/set/sortedset/empty_spec.rb13
-rw-r--r--spec/ruby/library/set/sortedset/eql_spec.rb19
-rw-r--r--spec/ruby/library/set/sortedset/equal_value_spec.rb16
-rw-r--r--spec/ruby/library/set/sortedset/exclusion_spec.rb21
-rw-r--r--spec/ruby/library/set/sortedset/filter_spec.rb10
-rw-r--r--spec/ruby/library/set/sortedset/flatten_merge_spec.rb11
-rw-r--r--spec/ruby/library/set/sortedset/flatten_spec.rb47
-rw-r--r--spec/ruby/library/set/sortedset/hash_spec.rb16
-rw-r--r--spec/ruby/library/set/sortedset/include_spec.rb10
-rw-r--r--spec/ruby/library/set/sortedset/initialize_spec.rb33
-rw-r--r--spec/ruby/library/set/sortedset/inspect_spec.rb13
-rw-r--r--spec/ruby/library/set/sortedset/intersection_spec.rb14
-rw-r--r--spec/ruby/library/set/sortedset/keep_if_spec.rb34
-rw-r--r--spec/ruby/library/set/sortedset/length_spec.rb10
-rw-r--r--spec/ruby/library/set/sortedset/map_spec.rb10
-rw-r--r--spec/ruby/library/set/sortedset/member_spec.rb10
-rw-r--r--spec/ruby/library/set/sortedset/merge_spec.rb22
-rw-r--r--spec/ruby/library/set/sortedset/minus_spec.rb10
-rw-r--r--spec/ruby/library/set/sortedset/plus_spec.rb10
-rw-r--r--spec/ruby/library/set/sortedset/pretty_print_cycle_spec.rb13
-rw-r--r--spec/ruby/library/set/sortedset/pretty_print_spec.rb20
-rw-r--r--spec/ruby/library/set/sortedset/proper_subset_spec.rb36
-rw-r--r--spec/ruby/library/set/sortedset/proper_superset_spec.rb36
-rw-r--r--spec/ruby/library/set/sortedset/reject_spec.rb45
-rw-r--r--spec/ruby/library/set/sortedset/replace_spec.rb20
-rw-r--r--spec/ruby/library/set/sortedset/select_spec.rb10
-rw-r--r--spec/ruby/library/set/sortedset/shared/add.rb14
-rw-r--r--spec/ruby/library/set/sortedset/shared/collect.rb20
-rw-r--r--spec/ruby/library/set/sortedset/shared/difference.rb15
-rw-r--r--spec/ruby/library/set/sortedset/shared/include.rb7
-rw-r--r--spec/ruby/library/set/sortedset/shared/intersection.rb15
-rw-r--r--spec/ruby/library/set/sortedset/shared/length.rb6
-rw-r--r--spec/ruby/library/set/sortedset/shared/select.rb35
-rw-r--r--spec/ruby/library/set/sortedset/shared/union.rb15
-rw-r--r--spec/ruby/library/set/sortedset/size_spec.rb10
-rw-r--r--spec/ruby/library/set/sortedset/sortedset_spec.rb24
-rw-r--r--spec/ruby/library/set/sortedset/subset_spec.rb36
-rw-r--r--spec/ruby/library/set/sortedset/subtract_spec.rb20
-rw-r--r--spec/ruby/library/set/sortedset/superset_spec.rb36
-rw-r--r--spec/ruby/library/set/sortedset/to_a_spec.rb20
-rw-r--r--spec/ruby/library/set/sortedset/union_spec.rb14
-rw-r--r--spec/ruby/library/set/subset_spec.rb9
-rw-r--r--spec/ruby/library/set/to_s_spec.rb1
-rw-r--r--spec/ruby/library/socket/addrinfo/shared/to_sockaddr.rb4
-rw-r--r--spec/ruby/library/socket/basicsocket/recv_spec.rb19
-rw-r--r--spec/ruby/library/socket/basicsocket/send_spec.rb4
-rw-r--r--spec/ruby/library/socket/basicsocket/shutdown_spec.rb20
-rw-r--r--spec/ruby/library/socket/fixtures/classes.rb6
-rw-r--r--spec/ruby/library/socket/ipsocket/getaddress_spec.rb2
-rw-r--r--spec/ruby/library/socket/shared/partially_closable_sockets.rb2
-rw-r--r--spec/ruby/library/socket/socket/getnameinfo_spec.rb2
-rw-r--r--spec/ruby/library/socket/socket/new_spec.rb2
-rw-r--r--spec/ruby/library/socket/tcpserver/new_spec.rb6
-rw-r--r--spec/ruby/library/socket/tcpsocket/initialize_spec.rb21
-rw-r--r--spec/ruby/library/socket/tcpsocket/open_spec.rb1
-rw-r--r--spec/ruby/library/socket/tcpsocket/partially_closable_spec.rb2
-rw-r--r--spec/ruby/library/socket/tcpsocket/shared/new.rb16
-rw-r--r--spec/ruby/library/socket/udpsocket/new_spec.rb6
-rw-r--r--spec/ruby/library/socket/unixserver/accept_nonblock_spec.rb7
-rw-r--r--spec/ruby/library/socket/unixserver/accept_spec.rb2
-rw-r--r--spec/ruby/library/socket/unixserver/for_fd_spec.rb2
-rw-r--r--spec/ruby/library/socket/unixserver/new_spec.rb12
-rw-r--r--spec/ruby/library/socket/unixserver/open_spec.rb6
-rw-r--r--spec/ruby/library/socket/unixserver/shared/new.rb26
-rw-r--r--spec/ruby/library/socket/unixsocket/addr_spec.rb5
-rw-r--r--spec/ruby/library/socket/unixsocket/inspect_spec.rb4
-rw-r--r--spec/ruby/library/socket/unixsocket/local_address_spec.rb2
-rw-r--r--spec/ruby/library/socket/unixsocket/new_spec.rb12
-rw-r--r--spec/ruby/library/socket/unixsocket/open_spec.rb10
-rw-r--r--spec/ruby/library/socket/unixsocket/pair_spec.rb7
-rw-r--r--spec/ruby/library/socket/unixsocket/partially_closable_spec.rb6
-rw-r--r--spec/ruby/library/socket/unixsocket/path_spec.rb6
-rw-r--r--spec/ruby/library/socket/unixsocket/peeraddr_spec.rb6
-rw-r--r--spec/ruby/library/socket/unixsocket/recv_io_spec.rb7
-rw-r--r--spec/ruby/library/socket/unixsocket/recvfrom_spec.rb7
-rw-r--r--spec/ruby/library/socket/unixsocket/send_io_spec.rb7
-rw-r--r--spec/ruby/library/socket/unixsocket/shared/new.rb28
-rw-r--r--spec/ruby/library/stringio/append_spec.rb7
-rw-r--r--spec/ruby/library/stringio/bytes_spec.rb29
-rw-r--r--spec/ruby/library/stringio/chars_spec.rb29
-rw-r--r--spec/ruby/library/stringio/codepoints_spec.rb19
-rw-r--r--spec/ruby/library/stringio/initialize_spec.rb13
-rw-r--r--spec/ruby/library/stringio/lines_spec.rb53
-rw-r--r--spec/ruby/library/stringio/new_spec.rb6
-rw-r--r--spec/ruby/library/stringio/reopen_spec.rb30
-rw-r--r--spec/ruby/library/stringio/set_encoding_spec.rb8
-rw-r--r--spec/ruby/library/stringio/shared/each.rb4
-rw-r--r--spec/ruby/library/stringio/shared/sysread.rb2
-rw-r--r--spec/ruby/library/stringio/shared/write.rb28
-rw-r--r--spec/ruby/library/time/to_datetime_spec.rb5
-rw-r--r--spec/ruby/library/uri/generic/host_spec.rb7
-rw-r--r--spec/ruby/library/uri/generic/to_s_spec.rb7
-rw-r--r--spec/ruby/library/win32ole/win32ole/_getproperty_spec.rb1
-rw-r--r--spec/ruby/library/win32ole/win32ole/_invoke_spec.rb1
-rw-r--r--spec/ruby/library/win32ole/win32ole/codepage_spec.rb1
-rw-r--r--spec/ruby/library/win32ole/win32ole/connect_spec.rb1
-rw-r--r--spec/ruby/library/win32ole/win32ole/const_load_spec.rb1
-rw-r--r--spec/ruby/library/win32ole/win32ole/constants_spec.rb1
-rw-r--r--spec/ruby/library/win32ole/win32ole/create_guid_spec.rb1
-rw-r--r--spec/ruby/library/win32ole/win32ole/invoke_spec.rb1
-rw-r--r--spec/ruby/library/win32ole/win32ole/locale_spec.rb1
-rw-r--r--spec/ruby/library/win32ole/win32ole/new_spec.rb1
-rw-r--r--spec/ruby/library/win32ole/win32ole/ole_func_methods_spec.rb1
-rw-r--r--spec/ruby/library/win32ole/win32ole/ole_get_methods_spec.rb1
-rw-r--r--spec/ruby/library/win32ole/win32ole/ole_method_help_spec.rb1
-rw-r--r--spec/ruby/library/win32ole/win32ole/ole_method_spec.rb1
-rw-r--r--spec/ruby/library/win32ole/win32ole/ole_methods_spec.rb1
-rw-r--r--spec/ruby/library/win32ole/win32ole/ole_obj_help_spec.rb1
-rw-r--r--spec/ruby/library/win32ole/win32ole/ole_put_methods_spec.rb1
-rw-r--r--spec/ruby/library/win32ole/win32ole/setproperty_spec.rb1
-rw-r--r--spec/ruby/library/win32ole/win32ole_event/new_spec.rb1
-rw-r--r--spec/ruby/library/win32ole/win32ole_event/on_event_spec.rb1
-rw-r--r--spec/ruby/library/win32ole/win32ole_method/dispid_spec.rb1
-rw-r--r--spec/ruby/library/win32ole/win32ole_method/event_interface_spec.rb1
-rw-r--r--spec/ruby/library/win32ole/win32ole_method/event_spec.rb1
-rw-r--r--spec/ruby/library/win32ole/win32ole_method/helpcontext_spec.rb1
-rw-r--r--spec/ruby/library/win32ole/win32ole_method/helpfile_spec.rb1
-rw-r--r--spec/ruby/library/win32ole/win32ole_method/helpstring_spec.rb1
-rw-r--r--spec/ruby/library/win32ole/win32ole_method/invkind_spec.rb1
-rw-r--r--spec/ruby/library/win32ole/win32ole_method/invoke_kind_spec.rb1
-rw-r--r--spec/ruby/library/win32ole/win32ole_method/name_spec.rb1
-rw-r--r--spec/ruby/library/win32ole/win32ole_method/new_spec.rb1
-rw-r--r--spec/ruby/library/win32ole/win32ole_method/offset_vtbl_spec.rb1
-rw-r--r--spec/ruby/library/win32ole/win32ole_method/params_spec.rb1
-rw-r--r--spec/ruby/library/win32ole/win32ole_method/return_type_detail_spec.rb1
-rw-r--r--spec/ruby/library/win32ole/win32ole_method/return_type_spec.rb1
-rw-r--r--spec/ruby/library/win32ole/win32ole_method/return_vtype_spec.rb1
-rw-r--r--spec/ruby/library/win32ole/win32ole_method/size_opt_params_spec.rb1
-rw-r--r--spec/ruby/library/win32ole/win32ole_method/size_params_spec.rb1
-rw-r--r--spec/ruby/library/win32ole/win32ole_method/to_s_spec.rb1
-rw-r--r--spec/ruby/library/win32ole/win32ole_method/visible_spec.rb1
-rw-r--r--spec/ruby/library/win32ole/win32ole_param/default_spec.rb1
-rw-r--r--spec/ruby/library/win32ole/win32ole_param/input_spec.rb1
-rw-r--r--spec/ruby/library/win32ole/win32ole_param/name_spec.rb1
-rw-r--r--spec/ruby/library/win32ole/win32ole_param/ole_type_detail_spec.rb1
-rw-r--r--spec/ruby/library/win32ole/win32ole_param/ole_type_spec.rb1
-rw-r--r--spec/ruby/library/win32ole/win32ole_param/optional_spec.rb1
-rw-r--r--spec/ruby/library/win32ole/win32ole_param/retval_spec.rb1
-rw-r--r--spec/ruby/library/win32ole/win32ole_param/to_s_spec.rb1
-rw-r--r--spec/ruby/library/win32ole/win32ole_type/guid_spec.rb1
-rw-r--r--spec/ruby/library/win32ole/win32ole_type/helpcontext_spec.rb1
-rw-r--r--spec/ruby/library/win32ole/win32ole_type/helpfile_spec.rb1
-rw-r--r--spec/ruby/library/win32ole/win32ole_type/helpstring_spec.rb1
-rw-r--r--spec/ruby/library/win32ole/win32ole_type/major_version_spec.rb1
-rw-r--r--spec/ruby/library/win32ole/win32ole_type/minor_version_spec.rb1
-rw-r--r--spec/ruby/library/win32ole/win32ole_type/name_spec.rb1
-rw-r--r--spec/ruby/library/win32ole/win32ole_type/new_spec.rb1
-rw-r--r--spec/ruby/library/win32ole/win32ole_type/ole_classes_spec.rb1
-rw-r--r--spec/ruby/library/win32ole/win32ole_type/ole_methods_spec.rb1
-rw-r--r--spec/ruby/library/win32ole/win32ole_type/ole_type_spec.rb1
-rw-r--r--spec/ruby/library/win32ole/win32ole_type/progid_spec.rb1
-rw-r--r--spec/ruby/library/win32ole/win32ole_type/progids_spec.rb1
-rw-r--r--spec/ruby/library/win32ole/win32ole_type/src_type_spec.rb1
-rw-r--r--spec/ruby/library/win32ole/win32ole_type/to_s_spec.rb1
-rw-r--r--spec/ruby/library/win32ole/win32ole_type/typekind_spec.rb1
-rw-r--r--spec/ruby/library/win32ole/win32ole_type/typelibs_spec.rb1
-rw-r--r--spec/ruby/library/win32ole/win32ole_type/variables_spec.rb1
-rw-r--r--spec/ruby/library/win32ole/win32ole_type/visible_spec.rb1
-rw-r--r--spec/ruby/library/win32ole/win32ole_variable/name_spec.rb1
-rw-r--r--spec/ruby/library/win32ole/win32ole_variable/ole_type_detail_spec.rb1
-rw-r--r--spec/ruby/library/win32ole/win32ole_variable/ole_type_spec.rb1
-rw-r--r--spec/ruby/library/win32ole/win32ole_variable/to_s_spec.rb1
-rw-r--r--spec/ruby/library/win32ole/win32ole_variable/value_spec.rb1
-rw-r--r--spec/ruby/library/win32ole/win32ole_variable/variable_kind_spec.rb1
-rw-r--r--spec/ruby/library/win32ole/win32ole_variable/varkind_spec.rb1
-rw-r--r--spec/ruby/library/win32ole/win32ole_variable/visible_spec.rb1
-rw-r--r--spec/ruby/library/yaml/dump_spec.rb14
-rw-r--r--spec/ruby/library/yaml/dump_stream_spec.rb3
-rw-r--r--spec/ruby/library/yaml/fixtures/common.rb4
-rw-r--r--spec/ruby/library/yaml/load_file_spec.rb13
-rw-r--r--spec/ruby/library/yaml/load_stream_spec.rb3
-rw-r--r--spec/ruby/library/yaml/parse_file_spec.rb8
-rw-r--r--spec/ruby/library/yaml/parse_spec.rb7
-rw-r--r--spec/ruby/library/yaml/shared/each_document.rb3
-rw-r--r--spec/ruby/library/yaml/shared/load.rb10
-rw-r--r--spec/ruby/library/yaml/to_yaml_spec.rb20
-rw-r--r--spec/ruby/library/zlib/deflate/new_spec.rb1
-rw-r--r--spec/ruby/library/zlib/gzipreader/each_line_spec.rb1
-rw-r--r--spec/ruby/library/zlib/gzipreader/each_spec.rb1
-rw-r--r--spec/ruby/library/zlib/gzipreader/mtime_spec.rb11
-rw-r--r--spec/ruby/library/zlib/gzipreader/new_spec.rb1
-rw-r--r--spec/ruby/library/zlib/inflate/finish_spec.rb1
-rw-r--r--spec/ruby/library/zlib/inflate/new_spec.rb1
-rw-r--r--spec/ruby/optional/capi/array_spec.rb34
-rw-r--r--spec/ruby/optional/capi/class_spec.rb32
-rw-r--r--spec/ruby/optional/capi/encoding_spec.rb30
-rw-r--r--spec/ruby/optional/capi/exception_spec.rb34
-rw-r--r--spec/ruby/optional/capi/ext/array_spec.c28
-rw-r--r--spec/ruby/optional/capi/ext/class_spec.c8
-rw-r--r--spec/ruby/optional/capi/ext/debug_spec.c2
-rw-r--r--spec/ruby/optional/capi/ext/encoding_spec.c23
-rw-r--r--spec/ruby/optional/capi/ext/exception_spec.c19
-rw-r--r--spec/ruby/optional/capi/ext/gc_spec.c8
-rw-r--r--spec/ruby/optional/capi/ext/hash_spec.c9
-rw-r--r--spec/ruby/optional/capi/ext/integer_spec.c5
-rw-r--r--spec/ruby/optional/capi/ext/io_spec.c73
-rw-r--r--spec/ruby/optional/capi/ext/kernel_spec.c19
-rw-r--r--spec/ruby/optional/capi/ext/object_spec.c54
-rw-r--r--spec/ruby/optional/capi/ext/proc_spec.c15
-rw-r--r--spec/ruby/optional/capi/ext/range_spec.c2
-rw-r--r--spec/ruby/optional/capi/ext/rbasic_spec.c54
-rw-r--r--spec/ruby/optional/capi/ext/rubyspec.h23
-rw-r--r--spec/ruby/optional/capi/ext/string_spec.c35
-rw-r--r--spec/ruby/optional/capi/ext/struct_spec.c13
-rw-r--r--spec/ruby/optional/capi/ext/thread_spec.c9
-rw-r--r--spec/ruby/optional/capi/ext/tracepoint_spec.c2
-rw-r--r--spec/ruby/optional/capi/ext/typed_data_spec.c12
-rw-r--r--spec/ruby/optional/capi/fixtures/kernel.rb19
-rw-r--r--spec/ruby/optional/capi/hash_spec.rb16
-rw-r--r--spec/ruby/optional/capi/io_spec.rb98
-rw-r--r--spec/ruby/optional/capi/kernel_spec.rb135
-rw-r--r--spec/ruby/optional/capi/object_spec.rb2
-rw-r--r--spec/ruby/optional/capi/proc_spec.rb53
-rw-r--r--spec/ruby/optional/capi/rbasic_spec.rb2
-rw-r--r--spec/ruby/optional/capi/shared/rbasic.rb1
-rw-r--r--spec/ruby/optional/capi/thread_spec.rb28
-rw-r--r--spec/ruby/optional/capi/time_spec.rb5
-rw-r--r--spec/ruby/optional/capi/typed_data_spec.rb12
-rw-r--r--spec/ruby/optional/capi/util_spec.rb93
-rw-r--r--spec/ruby/security/cve_2014_8080_spec.rb34
-rw-r--r--spec/ruby/security/cve_2017_17742_spec.rb37
-rw-r--r--spec/ruby/security/cve_2019_8323_spec.rb14
-rw-r--r--spec/ruby/shared/file/exist.rb5
-rw-r--r--spec/ruby/shared/kernel/at_exit.rb67
-rw-r--r--spec/ruby/shared/kernel/fixtures/END.rb3
-rw-r--r--spec/ruby/shared/kernel/fixtures/at_exit.rb3
-rw-r--r--spec/ruby/shared/process/exit.rb6
-rw-r--r--spec/ruby/shared/queue/deque.rb23
-rw-r--r--spec/ruby/shared/rational/Rational.rb9
-rw-r--r--spec/ruby/shared/rational/marshal_dump.rb5
-rw-r--r--spec/ruby/shared/rational/marshal_load.rb5
-rw-r--r--spec/ruby/shared/rational/quo.rb5
-rw-r--r--spec/ruby/shared/rational/truncate.rb26
-rw-r--r--spec/ruby/shared/sizedqueue/enque.rb26
-rw-r--r--spec/ruby/shared/string/start_with.rb12
-rw-r--r--spec/ruby/shared/string/times.rb18
-rw-r--r--spec/ruby/shared/types/rb_num2dbl_fails.rb17
-rw-r--r--spec/ruby/spec_helper.rb2
-rw-r--r--spec/syntax_suggest/integration/ruby_command_line_spec.rb26
-rw-r--r--spec/syntax_suggest/integration/syntax_suggest_spec.rb54
-rw-r--r--spec/syntax_suggest/spec_helper.rb6
-rw-r--r--spec/syntax_suggest/unit/api_spec.rb6
-rw-r--r--spec/syntax_suggest/unit/around_block_scan_spec.rb14
-rw-r--r--spec/syntax_suggest/unit/block_expand_spec.rb30
-rw-r--r--spec/syntax_suggest/unit/capture/before_after_keyword_ends_spec.rb47
-rw-r--r--spec/syntax_suggest/unit/capture/falling_indent_lines_spec.rb44
-rw-r--r--spec/syntax_suggest/unit/capture_code_context_spec.rb59
-rw-r--r--spec/syntax_suggest/unit/clean_document_spec.rb49
-rw-r--r--spec/syntax_suggest/unit/code_line_spec.rb13
-rw-r--r--spec/syntax_suggest/unit/code_search_spec.rb82
-rw-r--r--spec/syntax_suggest/unit/core_ext_spec.rb34
-rw-r--r--spec/syntax_suggest/unit/display_invalid_blocks_spec.rb2
-rw-r--r--spec/syntax_suggest/unit/explain_syntax_spec.rb4
-rw-r--r--spec/syntax_suggest/unit/lex_all_spec.rb3
-rw-r--r--spec/syntax_suggest/unit/pathname_from_message_spec.rb9
-rw-r--r--spec/syntax_suggest/unit/scan_history_spec.rb114
-rw-r--r--st.c185
-rw-r--r--string.c964
-rw-r--r--string.rb10
-rw-r--r--struct.c156
-rw-r--r--symbol.c85
-rw-r--r--symbol.h5
-rw-r--r--symbol.rb2
-rw-r--r--template/Doxyfile.tmpl363
-rw-r--r--template/GNUmakefile.in9
-rw-r--r--template/Makefile.in107
-rw-r--r--template/builtin_binary.inc.tmpl10
-rw-r--r--template/configure-ext.mk.tmpl2
-rw-r--r--template/extinit.c.tmpl2
-rw-r--r--template/exts.mk.tmpl2
-rw-r--r--template/fake.rb.in10
-rw-r--r--template/id.h.tmpl9
-rw-r--r--template/prelude.c.tmpl30
-rw-r--r--template/ruby.pc.in2
-rwxr-xr-xtemplate/unicode_properties.rdoc.tmpl59
-rw-r--r--test/-ext-/bug_reporter/test_bug_reporter.rb15
-rw-r--r--test/-ext-/debug/test_profile_frames.rb63
-rw-r--r--test/-ext-/iseq_load/test_iseq_load.rb2
-rw-r--r--test/-ext-/load/test_resolve_symbol.rb27
-rw-r--r--test/-ext-/load/test_stringify_symbols.rb35
-rw-r--r--test/-ext-/postponed_job/test_postponed_job.rb72
-rw-r--r--test/-ext-/string/test_capacity.rb8
-rw-r--r--test/-ext-/string/test_fstring.rb4
-rw-r--r--test/-ext-/string/test_set_len.rb29
-rw-r--r--test/-ext-/string/test_too_many_dummy_encodings.rb2
-rw-r--r--test/-ext-/struct/test_data.rb18
-rw-r--r--test/-ext-/symbol/test_type.rb5
-rw-r--r--test/-ext-/thread/helper.rb51
-rw-r--r--test/-ext-/thread/test_instrumentation_api.rb274
-rw-r--r--test/.excludes/TestArray.rb (renamed from test/excludes/TestArray.rb)0
-rw-r--r--test/.excludes/TestArraySubclass.rb1
-rw-r--r--test/.excludes/TestException.rb (renamed from test/excludes/TestException.rb)0
-rw-r--r--test/.excludes/TestGem.rb (renamed from test/excludes/TestGem.rb)0
-rw-r--r--test/.excludes/TestIO_Console.rb (renamed from test/excludes/TestIO_Console.rb)0
-rw-r--r--test/.excludes/TestISeq.rb (renamed from test/excludes/TestISeq.rb)0
-rw-r--r--test/.excludes/TestThread.rb18
-rw-r--r--test/.excludes/TestThreadQueue.rb (renamed from test/excludes/TestThreadQueue.rb)0
-rw-r--r--test/.excludes/_appveyor/TestArray.rb (renamed from test/excludes/_appveyor/TestArray.rb)0
-rw-r--r--test/bigdecimal/test_bigdecimal.rb27
-rw-r--r--test/cgi/test_cgi_util.rb31
-rw-r--r--test/coverage/test_coverage.rb51
-rw-r--r--test/csv/helper.rb2
-rw-r--r--test/csv/interface/test_read.rb6
-rw-r--r--test/csv/parse/test_general.rb27
-rw-r--r--test/csv/parse/test_inputs_scanner.rb2
-rw-r--r--test/csv/parse/test_row_separator.rb2
-rw-r--r--test/csv/parse/test_skip_lines.rb10
-rw-r--r--test/csv/test_encodings.rb8
-rw-r--r--test/csv/write/test_general.rb2
-rw-r--r--test/did_you_mean/core_ext/test_name_error_extension.rb4
-rw-r--r--test/drb/drbtest.rb2
-rw-r--r--test/drb/test_drbssl.rb4
-rw-r--r--test/drb/ut_array_drbssl.rb4
-rw-r--r--test/error_highlight/test_error_highlight.rb132
-rw-r--r--test/excludes/TestThread.rb14
-rw-r--r--test/fiber/scheduler.rb130
-rw-r--r--test/fiber/test_address_resolve.rb2
-rw-r--r--test/fiber/test_io.rb43
-rw-r--r--test/fiber/test_io_buffer.rb74
-rw-r--r--test/fiber/test_process.rb21
-rw-r--r--test/fiber/test_queue.rb20
-rw-r--r--test/fiber/test_scheduler.rb2
-rw-r--r--test/fiber/test_thread.rb22
-rw-r--r--test/fiddle/test_c_struct_entry.rb8
-rw-r--r--test/fiddle/test_closure.rb12
-rw-r--r--test/fiddle/test_cparser.rb40
-rw-r--r--test/fiddle/test_func.rb17
-rw-r--r--test/fiddle/test_pointer.rb16
-rw-r--r--test/fileutils/test_fileutils.rb8
-rw-r--r--test/io/console/test_io_console.rb10
-rw-r--r--test/io/wait/test_io_wait.rb1
-rw-r--r--test/irb/cmd/test_show_source.rb276
-rw-r--r--test/irb/helper.rb155
-rw-r--r--test/irb/test_cmd.rb431
-rw-r--r--test/irb/test_color.rb48
-rw-r--r--test/irb/test_color_printer.rb11
-rw-r--r--test/irb/test_completion.rb279
-rw-r--r--test/irb/test_context.rb207
-rw-r--r--test/irb/test_debug_cmd.rb329
-rw-r--r--test/irb/test_eval_history.rb69
-rw-r--r--test/irb/test_evaluation.rb44
-rw-r--r--test/irb/test_history.rb245
-rw-r--r--test/irb/test_init.rb86
-rw-r--r--test/irb/test_input_method.rb114
-rw-r--r--test/irb/test_irb.rb741
-rw-r--r--test/irb/test_locale.rb118
-rw-r--r--test/irb/test_nesting_parser.rb303
-rw-r--r--test/irb/test_option.rb2
-rw-r--r--test/irb/test_raise_exception.rb74
-rw-r--r--test/irb/test_raise_no_backtrace_exception.rb56
-rw-r--r--test/irb/test_ruby_lex.rb889
-rw-r--r--test/irb/test_type_completor.rb83
-rw-r--r--test/irb/test_workspace.rb3
-rw-r--r--test/irb/yamatanooroti/test_rendering.rb669
-rw-r--r--test/json/json_addition_test.rb4
-rw-r--r--test/json/json_common_interface_test.rb34
-rw-r--r--test/json/json_encoding_test.rb9
-rw-r--r--test/json/json_ext_parser_test.rb21
-rw-r--r--test/json/json_fixtures_test.rb2
-rwxr-xr-x[-rw-r--r--]test/json/json_generator_test.rb67
-rw-r--r--test/json/json_generic_object_test.rb2
-rw-r--r--test/json/json_parser_test.rb12
-rw-r--r--test/json/json_string_matching_test.rb2
-rw-r--r--test/json/ractor_test.rb8
-rw-r--r--test/lib/!Nothing_to_test.rb5
-rw-r--r--test/lib/jit_support.rb93
-rw-r--r--test/logger/test_severity.rb32
-rw-r--r--test/mkmf/base.rb7
-rw-r--r--test/mkmf/test_config.rb29
-rw-r--r--test/mkmf/test_configuration.rb39
-rw-r--r--test/mkmf/test_flags.rb6
-rw-r--r--test/monitor/test_monitor.rb2
-rw-r--r--test/net/fixtures/Makefile6
-rw-r--r--test/net/fixtures/cacert.pem44
-rw-r--r--test/net/fixtures/server.crt99
-rw-r--r--test/net/fixtures/server.key55
-rw-r--r--test/net/http/test_http.rb4
-rw-r--r--test/net/http/test_httpresponse.rb39
-rw-r--r--test/net/http/test_https.rb5
-rw-r--r--test/objspace/test_objspace.rb70
-rw-r--r--test/objspace/test_ractor.rb17
-rw-r--r--test/open-uri/test_open-uri.rb32
-rw-r--r--test/openssl/fixtures/pkey/dh1024.pem5
-rw-r--r--test/openssl/fixtures/pkey/dh2048_ffdhe2048.pem8
-rw-r--r--test/openssl/test_bn.rb4
-rw-r--r--test/openssl/test_cipher.rb2
-rw-r--r--test/openssl/test_config.rb12
-rw-r--r--test/openssl/test_digest.rb2
-rw-r--r--test/openssl/test_engine.rb2
-rw-r--r--test/openssl/test_fips.rb40
-rw-r--r--test/openssl/test_hmac.rb3
-rw-r--r--test/openssl/test_ns_spki.rb6
-rw-r--r--test/openssl/test_ossl.rb13
-rw-r--r--test/openssl/test_pkcs12.rb4
-rw-r--r--test/openssl/test_pkey.rb74
-rw-r--r--test/openssl/test_pkey_dh.rb64
-rw-r--r--test/openssl/test_pkey_dsa.rb2
-rw-r--r--test/openssl/test_pkey_ec.rb29
-rw-r--r--test/openssl/test_pkey_rsa.rb2
-rw-r--r--test/openssl/test_provider.rb67
-rw-r--r--test/openssl/test_ssl.rb34
-rw-r--r--test/openssl/test_ssl_session.rb2
-rw-r--r--test/openssl/test_x509ext.rb37
-rw-r--r--test/openssl/utils.rb61
-rw-r--r--test/ostruct/test_ostruct.rb19
-rw-r--r--test/prism/attribute_write_test.rb60
-rw-r--r--test/prism/bom_test.rb59
-rw-r--r--test/prism/comments_test.rb138
-rw-r--r--test/prism/compiler_test.rb30
-rw-r--r--test/prism/constant_path_node_test.rb56
-rw-r--r--test/prism/desugar_compiler_test.rb86
-rw-r--r--test/prism/dispatcher_test.rb46
-rw-r--r--test/prism/encoding_test.rb349
-rw-r--r--test/prism/errors_test.rb2062
-rw-r--r--test/prism/fixtures/alias.txt23
-rw-r--r--test/prism/fixtures/arithmetic.txt13
-rw-r--r--test/prism/fixtures/arrays.txt142
-rw-r--r--test/prism/fixtures/begin_ensure.txt21
-rw-r--r--test/prism/fixtures/begin_rescue.txt79
-rw-r--r--test/prism/fixtures/blocks.txt54
-rw-r--r--test/prism/fixtures/boolean_operators.txt5
-rw-r--r--test/prism/fixtures/booleans.txt3
-rw-r--r--test/prism/fixtures/break.txt25
-rw-r--r--test/prism/fixtures/case.txt44
-rw-r--r--test/prism/fixtures/classes.txt35
-rw-r--r--test/prism/fixtures/command_method_call.txt41
-rw-r--r--test/prism/fixtures/comments.txt24
-rw-r--r--test/prism/fixtures/constants.txt184
-rw-r--r--test/prism/fixtures/dash_heredocs.txt63
-rw-r--r--test/prism/fixtures/defined.txt10
-rw-r--r--test/prism/fixtures/dos_endings.txt20
-rw-r--r--test/prism/fixtures/embdoc_no_newline_at_end.txt2
-rw-r--r--test/prism/fixtures/endless_methods.txt5
-rw-r--r--test/prism/fixtures/endless_range_in_conditional.txt3
-rw-r--r--test/prism/fixtures/for.txt19
-rw-r--r--test/prism/fixtures/global_variables.txt93
-rw-r--r--test/prism/fixtures/hashes.txt26
-rw-r--r--test/prism/fixtures/heredoc_with_comment.txt3
-rw-r--r--test/prism/fixtures/heredoc_with_escaped_newline_at_start.txt7
-rw-r--r--test/prism/fixtures/heredoc_with_trailing_newline.txt2
-rw-r--r--test/prism/fixtures/heredocs_leading_whitespace.txt19
-rw-r--r--test/prism/fixtures/heredocs_nested.txt22
-rw-r--r--test/prism/fixtures/heredocs_with_ignored_newlines.txt14
-rw-r--r--test/prism/fixtures/heredocs_with_ignored_newlines_and_non_empty.txt4
-rw-r--r--test/prism/fixtures/if.txt42
-rw-r--r--test/prism/fixtures/indented_file_end.txt4
-rw-r--r--test/prism/fixtures/integer_operations.txt63
-rw-r--r--test/prism/fixtures/keyword_method_names.txt29
-rw-r--r--test/prism/fixtures/keywords.txt11
-rw-r--r--test/prism/fixtures/lambda.txt11
-rw-r--r--test/prism/fixtures/method_calls.txt149
-rw-r--r--test/prism/fixtures/methods.txt186
-rw-r--r--test/prism/fixtures/modules.txt18
-rw-r--r--test/prism/fixtures/newline_terminated.txtbin0 -> 212 bytes-rw-r--r--test/prism/fixtures/next.txt24
-rw-r--r--test/prism/fixtures/nils.txt13
-rw-r--r--test/prism/fixtures/non_alphanumeric_methods.txt105
-rw-r--r--test/prism/fixtures/not.txt37
-rw-r--r--test/prism/fixtures/numbers.txt67
-rw-r--r--test/prism/fixtures/patterns.txt202
-rw-r--r--test/prism/fixtures/procs.txt27
-rw-r--r--test/prism/fixtures/range_begin_open_exclusive.txt1
-rw-r--r--test/prism/fixtures/range_begin_open_inclusive.txt1
-rw-r--r--test/prism/fixtures/range_end_open_exclusive.txt1
-rw-r--r--test/prism/fixtures/range_end_open_inclusive.txt1
-rw-r--r--test/prism/fixtures/ranges.txt49
-rw-r--r--test/prism/fixtures/regex.txt40
-rw-r--r--test/prism/fixtures/rescue.txt31
-rw-r--r--test/prism/fixtures/return.txt24
-rw-r--r--test/prism/fixtures/seattlerb/BEGIN.txt1
-rw-r--r--test/prism/fixtures/seattlerb/README.rdoc113
-rw-r--r--test/prism/fixtures/seattlerb/TestRubyParserShared.txt92
-rw-r--r--test/prism/fixtures/seattlerb/__ENCODING__.txt1
-rw-r--r--test/prism/fixtures/seattlerb/alias_gvar_backref.txt1
-rw-r--r--test/prism/fixtures/seattlerb/alias_resword.txt1
-rw-r--r--test/prism/fixtures/seattlerb/and_multi.txt3
-rw-r--r--test/prism/fixtures/seattlerb/aref_args_assocs.txt1
-rw-r--r--test/prism/fixtures/seattlerb/aref_args_lit_assocs.txt1
-rw-r--r--test/prism/fixtures/seattlerb/args_kw_block.txt1
-rw-r--r--test/prism/fixtures/seattlerb/array_line_breaks.txt4
-rw-r--r--test/prism/fixtures/seattlerb/array_lits_trailing_calls.txt3
-rw-r--r--test/prism/fixtures/seattlerb/assoc__bare.txt1
-rw-r--r--test/prism/fixtures/seattlerb/assoc_label.txt1
-rw-r--r--test/prism/fixtures/seattlerb/attr_asgn_colon_id.txt1
-rw-r--r--test/prism/fixtures/seattlerb/attrasgn_array_arg.txt1
-rw-r--r--test/prism/fixtures/seattlerb/attrasgn_array_lhs.txt1
-rw-r--r--test/prism/fixtures/seattlerb/attrasgn_primary_dot_constant.txt1
-rw-r--r--test/prism/fixtures/seattlerb/backticks_interpolation_line.txt1
-rw-r--r--test/prism/fixtures/seattlerb/bang_eq.txt1
-rw-r--r--test/prism/fixtures/seattlerb/bdot2.txt3
-rw-r--r--test/prism/fixtures/seattlerb/bdot3.txt3
-rw-r--r--test/prism/fixtures/seattlerb/begin_ensure_no_bodies.txt3
-rw-r--r--test/prism/fixtures/seattlerb/begin_rescue_else_ensure_bodies.txt9
-rw-r--r--test/prism/fixtures/seattlerb/begin_rescue_else_ensure_no_bodies.txt9
-rw-r--r--test/prism/fixtures/seattlerb/begin_rescue_ensure_no_bodies.txt4
-rw-r--r--test/prism/fixtures/seattlerb/block_arg__bare.txt1
-rw-r--r--test/prism/fixtures/seattlerb/block_arg_kwsplat.txt1
-rw-r--r--test/prism/fixtures/seattlerb/block_arg_opt_arg_block.txt1
-rw-r--r--test/prism/fixtures/seattlerb/block_arg_opt_splat.txt1
-rw-r--r--test/prism/fixtures/seattlerb/block_arg_opt_splat_arg_block_omfg.txt1
-rw-r--r--test/prism/fixtures/seattlerb/block_arg_optional.txt1
-rw-r--r--test/prism/fixtures/seattlerb/block_arg_scope.txt1
-rw-r--r--test/prism/fixtures/seattlerb/block_arg_scope2.txt1
-rw-r--r--test/prism/fixtures/seattlerb/block_arg_splat_arg.txt1
-rw-r--r--test/prism/fixtures/seattlerb/block_args_kwargs.txt1
-rw-r--r--test/prism/fixtures/seattlerb/block_args_no_kwargs.txt1
-rw-r--r--test/prism/fixtures/seattlerb/block_args_opt1.txt1
-rw-r--r--test/prism/fixtures/seattlerb/block_args_opt2.txt1
-rw-r--r--test/prism/fixtures/seattlerb/block_args_opt2_2.txt1
-rw-r--r--test/prism/fixtures/seattlerb/block_args_opt3.txt1
-rw-r--r--test/prism/fixtures/seattlerb/block_break.txt1
-rw-r--r--test/prism/fixtures/seattlerb/block_call_defn_call_block_call.txt4
-rw-r--r--test/prism/fixtures/seattlerb/block_call_dot_op2_brace_block.txt1
-rw-r--r--test/prism/fixtures/seattlerb/block_call_dot_op2_cmd_args_do_block.txt1
-rw-r--r--test/prism/fixtures/seattlerb/block_call_operation_colon.txt1
-rw-r--r--test/prism/fixtures/seattlerb/block_call_operation_dot.txt1
-rw-r--r--test/prism/fixtures/seattlerb/block_call_paren_call_block_call.txt2
-rw-r--r--test/prism/fixtures/seattlerb/block_command_operation_colon.txt1
-rw-r--r--test/prism/fixtures/seattlerb/block_command_operation_dot.txt1
-rw-r--r--test/prism/fixtures/seattlerb/block_decomp_anon_splat_arg.txt1
-rw-r--r--test/prism/fixtures/seattlerb/block_decomp_arg_splat.txt1
-rw-r--r--test/prism/fixtures/seattlerb/block_decomp_arg_splat_arg.txt1
-rw-r--r--test/prism/fixtures/seattlerb/block_decomp_splat.txt1
-rw-r--r--test/prism/fixtures/seattlerb/block_kw.txt1
-rw-r--r--test/prism/fixtures/seattlerb/block_kw__required.txt1
-rw-r--r--test/prism/fixtures/seattlerb/block_kwarg_lvar.txt1
-rw-r--r--test/prism/fixtures/seattlerb/block_kwarg_lvar_multiple.txt1
-rw-r--r--test/prism/fixtures/seattlerb/block_next.txt1
-rw-r--r--test/prism/fixtures/seattlerb/block_opt_arg.txt1
-rw-r--r--test/prism/fixtures/seattlerb/block_opt_splat.txt1
-rw-r--r--test/prism/fixtures/seattlerb/block_opt_splat_arg_block_omfg.txt1
-rw-r--r--test/prism/fixtures/seattlerb/block_optarg.txt1
-rw-r--r--test/prism/fixtures/seattlerb/block_paren_splat.txt1
-rw-r--r--test/prism/fixtures/seattlerb/block_reg_optarg.txt1
-rw-r--r--test/prism/fixtures/seattlerb/block_return.txt1
-rw-r--r--test/prism/fixtures/seattlerb/block_scope.txt1
-rw-r--r--test/prism/fixtures/seattlerb/block_splat_reg.txt1
-rw-r--r--test/prism/fixtures/seattlerb/bug169.txt1
-rw-r--r--test/prism/fixtures/seattlerb/bug179.txt1
-rw-r--r--test/prism/fixtures/seattlerb/bug190.txt1
-rw-r--r--test/prism/fixtures/seattlerb/bug191.txt3
-rw-r--r--test/prism/fixtures/seattlerb/bug202.txt2
-rw-r--r--test/prism/fixtures/seattlerb/bug236.txt3
-rw-r--r--test/prism/fixtures/seattlerb/bug290.txt3
-rw-r--r--test/prism/fixtures/seattlerb/bug_187.txt3
-rw-r--r--test/prism/fixtures/seattlerb/bug_215.txt1
-rw-r--r--test/prism/fixtures/seattlerb/bug_249.txt4
-rw-r--r--test/prism/fixtures/seattlerb/bug_and.txt4
-rw-r--r--test/prism/fixtures/seattlerb/bug_args__19.txt1
-rw-r--r--test/prism/fixtures/seattlerb/bug_args_masgn.txt1
-rw-r--r--test/prism/fixtures/seattlerb/bug_args_masgn2.txt1
-rw-r--r--test/prism/fixtures/seattlerb/bug_args_masgn_outer_parens__19.txt1
-rw-r--r--test/prism/fixtures/seattlerb/bug_call_arglist_parens.txt11
-rw-r--r--test/prism/fixtures/seattlerb/bug_case_when_regexp.txt1
-rw-r--r--test/prism/fixtures/seattlerb/bug_comma.txt1
-rw-r--r--test/prism/fixtures/seattlerb/bug_cond_pct.txt1
-rw-r--r--test/prism/fixtures/seattlerb/bug_hash_args.txt1
-rw-r--r--test/prism/fixtures/seattlerb/bug_hash_args_trailing_comma.txt1
-rw-r--r--test/prism/fixtures/seattlerb/bug_hash_interp_array.txt1
-rw-r--r--test/prism/fixtures/seattlerb/bug_masgn_right.txt1
-rw-r--r--test/prism/fixtures/seattlerb/bug_not_parens.txt1
-rw-r--r--test/prism/fixtures/seattlerb/bug_op_asgn_rescue.txt1
-rw-r--r--test/prism/fixtures/seattlerb/call_and.txt1
-rw-r--r--test/prism/fixtures/seattlerb/call_arg_assoc.txt1
-rw-r--r--test/prism/fixtures/seattlerb/call_arg_assoc_kwsplat.txt1
-rw-r--r--test/prism/fixtures/seattlerb/call_arg_kwsplat.txt1
-rw-r--r--test/prism/fixtures/seattlerb/call_args_assoc_quoted.txt5
-rw-r--r--test/prism/fixtures/seattlerb/call_args_assoc_trailing_comma.txt1
-rw-r--r--test/prism/fixtures/seattlerb/call_args_command.txt1
-rw-r--r--test/prism/fixtures/seattlerb/call_array_arg.txt1
-rw-r--r--test/prism/fixtures/seattlerb/call_array_block_call.txt1
-rw-r--r--test/prism/fixtures/seattlerb/call_array_lambda_block_call.txt2
-rw-r--r--test/prism/fixtures/seattlerb/call_array_lit_inline_hash.txt1
-rw-r--r--test/prism/fixtures/seattlerb/call_assoc.txt1
-rw-r--r--test/prism/fixtures/seattlerb/call_assoc_new.txt1
-rw-r--r--test/prism/fixtures/seattlerb/call_assoc_new_if_multiline.txt5
-rw-r--r--test/prism/fixtures/seattlerb/call_assoc_trailing_comma.txt1
-rw-r--r--test/prism/fixtures/seattlerb/call_bang_command_call.txt1
-rw-r--r--test/prism/fixtures/seattlerb/call_bang_squiggle.txt1
-rw-r--r--test/prism/fixtures/seattlerb/call_begin_call_block_call.txt3
-rw-r--r--test/prism/fixtures/seattlerb/call_block_arg_named.txt1
-rw-r--r--test/prism/fixtures/seattlerb/call_carat.txt1
-rw-r--r--test/prism/fixtures/seattlerb/call_colon2.txt1
-rw-r--r--test/prism/fixtures/seattlerb/call_colon_parens.txt1
-rw-r--r--test/prism/fixtures/seattlerb/call_div.txt1
-rw-r--r--test/prism/fixtures/seattlerb/call_dot_parens.txt1
-rw-r--r--test/prism/fixtures/seattlerb/call_env.txt1
-rw-r--r--test/prism/fixtures/seattlerb/call_eq3.txt1
-rw-r--r--test/prism/fixtures/seattlerb/call_gt.txt1
-rw-r--r--test/prism/fixtures/seattlerb/call_kwsplat.txt1
-rw-r--r--test/prism/fixtures/seattlerb/call_leading_dots.txt3
-rw-r--r--test/prism/fixtures/seattlerb/call_leading_dots_comment.txt4
-rw-r--r--test/prism/fixtures/seattlerb/call_lt.txt1
-rw-r--r--test/prism/fixtures/seattlerb/call_lte.txt1
-rw-r--r--test/prism/fixtures/seattlerb/call_not.txt1
-rw-r--r--test/prism/fixtures/seattlerb/call_pipe.txt1
-rw-r--r--test/prism/fixtures/seattlerb/call_rshift.txt1
-rw-r--r--test/prism/fixtures/seattlerb/call_self_brackets.txt1
-rw-r--r--test/prism/fixtures/seattlerb/call_spaceship.txt1
-rw-r--r--test/prism/fixtures/seattlerb/call_stabby_do_end_with_block.txt1
-rw-r--r--test/prism/fixtures/seattlerb/call_stabby_with_braces_block.txt1
-rw-r--r--test/prism/fixtures/seattlerb/call_star.txt1
-rw-r--r--test/prism/fixtures/seattlerb/call_star2.txt1
-rw-r--r--test/prism/fixtures/seattlerb/call_trailing_comma.txt1
-rw-r--r--test/prism/fixtures/seattlerb/call_trailing_dots.txt3
-rw-r--r--test/prism/fixtures/seattlerb/call_unary_bang.txt1
-rw-r--r--test/prism/fixtures/seattlerb/case_in.txt111
-rw-r--r--test/prism/fixtures/seattlerb/case_in_31.txt4
-rw-r--r--test/prism/fixtures/seattlerb/case_in_37.txt4
-rw-r--r--test/prism/fixtures/seattlerb/case_in_42.txt3
-rw-r--r--test/prism/fixtures/seattlerb/case_in_42_2.txt3
-rw-r--r--test/prism/fixtures/seattlerb/case_in_47.txt4
-rw-r--r--test/prism/fixtures/seattlerb/case_in_67.txt3
-rw-r--r--test/prism/fixtures/seattlerb/case_in_86.txt3
-rw-r--r--test/prism/fixtures/seattlerb/case_in_86_2.txt3
-rw-r--r--test/prism/fixtures/seattlerb/case_in_array_pat_const.txt4
-rw-r--r--test/prism/fixtures/seattlerb/case_in_array_pat_const2.txt4
-rw-r--r--test/prism/fixtures/seattlerb/case_in_array_pat_paren_assign.txt4
-rw-r--r--test/prism/fixtures/seattlerb/case_in_const.txt4
-rw-r--r--test/prism/fixtures/seattlerb/case_in_else.txt7
-rw-r--r--test/prism/fixtures/seattlerb/case_in_find.txt3
-rw-r--r--test/prism/fixtures/seattlerb/case_in_find_array.txt3
-rw-r--r--test/prism/fixtures/seattlerb/case_in_hash_pat.txt5
-rw-r--r--test/prism/fixtures/seattlerb/case_in_hash_pat_assign.txt4
-rw-r--r--test/prism/fixtures/seattlerb/case_in_hash_pat_paren_assign.txt4
-rw-r--r--test/prism/fixtures/seattlerb/case_in_hash_pat_paren_true.txt5
-rw-r--r--test/prism/fixtures/seattlerb/case_in_hash_pat_rest.txt3
-rw-r--r--test/prism/fixtures/seattlerb/case_in_hash_pat_rest_solo.txt3
-rw-r--r--test/prism/fixtures/seattlerb/case_in_if_unless_post_mod.txt6
-rw-r--r--test/prism/fixtures/seattlerb/case_in_multiple.txt6
-rw-r--r--test/prism/fixtures/seattlerb/case_in_or.txt5
-rw-r--r--test/prism/fixtures/seattlerb/class_comments.txt9
-rw-r--r--test/prism/fixtures/seattlerb/cond_unary_minus.txt1
-rw-r--r--test/prism/fixtures/seattlerb/const_2_op_asgn_or2.txt1
-rw-r--r--test/prism/fixtures/seattlerb/const_3_op_asgn_or.txt1
-rw-r--r--test/prism/fixtures/seattlerb/const_op_asgn_and1.txt1
-rw-r--r--test/prism/fixtures/seattlerb/const_op_asgn_and2.txt1
-rw-r--r--test/prism/fixtures/seattlerb/const_op_asgn_or.txt1
-rw-r--r--test/prism/fixtures/seattlerb/dasgn_icky2.txt8
-rw-r--r--test/prism/fixtures/seattlerb/defined_eh_parens.txt1
-rw-r--r--test/prism/fixtures/seattlerb/defn_arg_asplat_arg.txt1
-rw-r--r--test/prism/fixtures/seattlerb/defn_arg_forward_args.txt1
-rw-r--r--test/prism/fixtures/seattlerb/defn_args_forward_args.txt1
-rw-r--r--test/prism/fixtures/seattlerb/defn_comments.txt5
-rw-r--r--test/prism/fixtures/seattlerb/defn_endless_command.txt1
-rw-r--r--test/prism/fixtures/seattlerb/defn_endless_command_rescue.txt1
-rw-r--r--test/prism/fixtures/seattlerb/defn_forward_args.txt1
-rw-r--r--test/prism/fixtures/seattlerb/defn_forward_args__no_parens.txt3
-rw-r--r--test/prism/fixtures/seattlerb/defn_kwarg_env.txt1
-rw-r--r--test/prism/fixtures/seattlerb/defn_kwarg_kwarg.txt1
-rw-r--r--test/prism/fixtures/seattlerb/defn_kwarg_kwsplat.txt1
-rw-r--r--test/prism/fixtures/seattlerb/defn_kwarg_kwsplat_anon.txt1
-rw-r--r--test/prism/fixtures/seattlerb/defn_kwarg_lvar.txt1
-rw-r--r--test/prism/fixtures/seattlerb/defn_kwarg_no_parens.txt2
-rw-r--r--test/prism/fixtures/seattlerb/defn_kwarg_val.txt1
-rw-r--r--test/prism/fixtures/seattlerb/defn_no_kwargs.txt1
-rw-r--r--test/prism/fixtures/seattlerb/defn_oneliner.txt1
-rw-r--r--test/prism/fixtures/seattlerb/defn_oneliner_eq2.txt3
-rw-r--r--test/prism/fixtures/seattlerb/defn_oneliner_noargs.txt1
-rw-r--r--test/prism/fixtures/seattlerb/defn_oneliner_noargs_parentheses.txt1
-rw-r--r--test/prism/fixtures/seattlerb/defn_oneliner_rescue.txt13
-rw-r--r--test/prism/fixtures/seattlerb/defn_opt_last_arg.txt2
-rw-r--r--test/prism/fixtures/seattlerb/defn_opt_reg.txt1
-rw-r--r--test/prism/fixtures/seattlerb/defn_opt_splat_arg.txt1
-rw-r--r--test/prism/fixtures/seattlerb/defn_powarg.txt1
-rw-r--r--test/prism/fixtures/seattlerb/defn_reg_opt_reg.txt1
-rw-r--r--test/prism/fixtures/seattlerb/defn_splat_arg.txt1
-rw-r--r--test/prism/fixtures/seattlerb/defn_unary_not.txt1
-rw-r--r--test/prism/fixtures/seattlerb/defns_reserved.txt1
-rw-r--r--test/prism/fixtures/seattlerb/defs_as_arg_with_do_block_inside.txt1
-rw-r--r--test/prism/fixtures/seattlerb/defs_comments.txt5
-rw-r--r--test/prism/fixtures/seattlerb/defs_endless_command.txt1
-rw-r--r--test/prism/fixtures/seattlerb/defs_endless_command_rescue.txt1
-rw-r--r--test/prism/fixtures/seattlerb/defs_kwarg.txt2
-rw-r--r--test/prism/fixtures/seattlerb/defs_oneliner.txt1
-rw-r--r--test/prism/fixtures/seattlerb/defs_oneliner_eq2.txt3
-rw-r--r--test/prism/fixtures/seattlerb/defs_oneliner_rescue.txt13
-rw-r--r--test/prism/fixtures/seattlerb/difficult0_.txt4
-rw-r--r--test/prism/fixtures/seattlerb/difficult1_line_numbers.txt13
-rw-r--r--test/prism/fixtures/seattlerb/difficult1_line_numbers2.txt8
-rw-r--r--test/prism/fixtures/seattlerb/difficult2_.txt2
-rw-r--r--test/prism/fixtures/seattlerb/difficult3_.txt1
-rw-r--r--test/prism/fixtures/seattlerb/difficult3_2.txt1
-rw-r--r--test/prism/fixtures/seattlerb/difficult3_3.txt1
-rw-r--r--test/prism/fixtures/seattlerb/difficult3_4.txt1
-rw-r--r--test/prism/fixtures/seattlerb/difficult3_5.txt1
-rw-r--r--test/prism/fixtures/seattlerb/difficult3__10.txt1
-rw-r--r--test/prism/fixtures/seattlerb/difficult3__11.txt1
-rw-r--r--test/prism/fixtures/seattlerb/difficult3__12.txt1
-rw-r--r--test/prism/fixtures/seattlerb/difficult3__6.txt1
-rw-r--r--test/prism/fixtures/seattlerb/difficult3__7.txt1
-rw-r--r--test/prism/fixtures/seattlerb/difficult3__8.txt1
-rw-r--r--test/prism/fixtures/seattlerb/difficult3__9.txt1
-rw-r--r--test/prism/fixtures/seattlerb/difficult4__leading_dots.txt2
-rw-r--r--test/prism/fixtures/seattlerb/difficult4__leading_dots2.txt2
-rw-r--r--test/prism/fixtures/seattlerb/difficult6_.txt1
-rw-r--r--test/prism/fixtures/seattlerb/difficult6__7.txt1
-rw-r--r--test/prism/fixtures/seattlerb/difficult6__8.txt1
-rw-r--r--test/prism/fixtures/seattlerb/difficult7_.txt5
-rw-r--r--test/prism/fixtures/seattlerb/do_bug.txt4
-rw-r--r--test/prism/fixtures/seattlerb/do_lambda.txt1
-rw-r--r--test/prism/fixtures/seattlerb/dot2_nil__26.txt1
-rw-r--r--test/prism/fixtures/seattlerb/dot3_nil__26.txt1
-rw-r--r--test/prism/fixtures/seattlerb/dstr_evstr.txt1
-rw-r--r--test/prism/fixtures/seattlerb/dstr_evstr_empty_end.txt1
-rw-r--r--test/prism/fixtures/seattlerb/dstr_lex_state.txt1
-rw-r--r--test/prism/fixtures/seattlerb/dstr_str.txt1
-rw-r--r--test/prism/fixtures/seattlerb/dsym_esc_to_sym.txt1
-rw-r--r--test/prism/fixtures/seattlerb/dsym_to_sym.txt3
-rw-r--r--test/prism/fixtures/seattlerb/eq_begin_line_numbers.txt6
-rw-r--r--test/prism/fixtures/seattlerb/eq_begin_why_wont_people_use_their_spacebar.txt3
-rw-r--r--test/prism/fixtures/seattlerb/evstr_evstr.txt1
-rw-r--r--test/prism/fixtures/seattlerb/evstr_str.txt1
-rw-r--r--test/prism/fixtures/seattlerb/expr_not_bang.txt1
-rw-r--r--test/prism/fixtures/seattlerb/f_kw.txt1
-rw-r--r--test/prism/fixtures/seattlerb/f_kw__required.txt1
-rw-r--r--test/prism/fixtures/seattlerb/flip2_env_lvar.txt1
-rw-r--r--test/prism/fixtures/seattlerb/float_with_if_modifier.txt1
-rw-r--r--test/prism/fixtures/seattlerb/heredoc__backslash_dos_format.txt5
-rw-r--r--test/prism/fixtures/seattlerb/heredoc_backslash_nl.txt8
-rw-r--r--test/prism/fixtures/seattlerb/heredoc_bad_hex_escape.txt3
-rw-r--r--test/prism/fixtures/seattlerb/heredoc_bad_oct_escape.txt5
-rw-r--r--test/prism/fixtures/seattlerb/heredoc_comma_arg.txt7
-rw-r--r--test/prism/fixtures/seattlerb/heredoc_lineno.txt7
-rw-r--r--test/prism/fixtures/seattlerb/heredoc_nested.txt7
-rw-r--r--test/prism/fixtures/seattlerb/heredoc_squiggly.txt7
-rw-r--r--test/prism/fixtures/seattlerb/heredoc_squiggly_blank_line_plus_interpolation.txt4
-rw-r--r--test/prism/fixtures/seattlerb/heredoc_squiggly_blank_lines.txt7
-rw-r--r--test/prism/fixtures/seattlerb/heredoc_squiggly_empty.txt2
-rw-r--r--test/prism/fixtures/seattlerb/heredoc_squiggly_interp.txt5
-rw-r--r--test/prism/fixtures/seattlerb/heredoc_squiggly_no_indent.txt3
-rw-r--r--test/prism/fixtures/seattlerb/heredoc_squiggly_tabs.txt6
-rw-r--r--test/prism/fixtures/seattlerb/heredoc_squiggly_tabs_extra.txt6
-rw-r--r--test/prism/fixtures/seattlerb/heredoc_squiggly_visually_blank_lines.txt7
-rw-r--r--test/prism/fixtures/seattlerb/heredoc_trailing_slash_continued_call.txt4
-rw-r--r--test/prism/fixtures/seattlerb/heredoc_unicode.txt4
-rw-r--r--test/prism/fixtures/seattlerb/heredoc_with_carriage_return_escapes.txt5
-rw-r--r--test/prism/fixtures/seattlerb/heredoc_with_carriage_return_escapes_windows.txt5
-rw-r--r--test/prism/fixtures/seattlerb/heredoc_with_extra_carriage_horrible_mix.txt4
-rw-r--r--test/prism/fixtures/seattlerb/heredoc_with_extra_carriage_returns.txt5
-rw-r--r--test/prism/fixtures/seattlerb/heredoc_with_extra_carriage_returns_windows.txt5
-rw-r--r--test/prism/fixtures/seattlerb/heredoc_with_interpolation_and_carriage_return_escapes.txt4
-rw-r--r--test/prism/fixtures/seattlerb/heredoc_with_interpolation_and_carriage_return_escapes_windows.txt4
-rw-r--r--test/prism/fixtures/seattlerb/heredoc_with_not_global_interpolation.txt3
-rw-r--r--test/prism/fixtures/seattlerb/heredoc_with_only_carriage_returns.txt6
-rw-r--r--test/prism/fixtures/seattlerb/heredoc_with_only_carriage_returns_windows.txt6
-rw-r--r--test/prism/fixtures/seattlerb/if_elsif.txt1
-rw-r--r--test/prism/fixtures/seattlerb/if_symbol.txt1
-rw-r--r--test/prism/fixtures/seattlerb/in_expr_no_case.txt1
-rw-r--r--test/prism/fixtures/seattlerb/index_0.txt1
-rw-r--r--test/prism/fixtures/seattlerb/index_0_opasgn.txt1
-rw-r--r--test/prism/fixtures/seattlerb/integer_with_if_modifier.txt1
-rw-r--r--test/prism/fixtures/seattlerb/interpolated_symbol_array_line_breaks.txt5
-rw-r--r--test/prism/fixtures/seattlerb/interpolated_word_array_line_breaks.txt5
-rw-r--r--test/prism/fixtures/seattlerb/iter_args_1.txt1
-rw-r--r--test/prism/fixtures/seattlerb/iter_args_10_1.txt1
-rw-r--r--test/prism/fixtures/seattlerb/iter_args_10_2.txt1
-rw-r--r--test/prism/fixtures/seattlerb/iter_args_11_1.txt1
-rw-r--r--test/prism/fixtures/seattlerb/iter_args_11_2.txt1
-rw-r--r--test/prism/fixtures/seattlerb/iter_args_2__19.txt1
-rw-r--r--test/prism/fixtures/seattlerb/iter_args_3.txt1
-rw-r--r--test/prism/fixtures/seattlerb/iter_args_4.txt1
-rw-r--r--test/prism/fixtures/seattlerb/iter_args_5.txt1
-rw-r--r--test/prism/fixtures/seattlerb/iter_args_6.txt1
-rw-r--r--test/prism/fixtures/seattlerb/iter_args_7_1.txt1
-rw-r--r--test/prism/fixtures/seattlerb/iter_args_7_2.txt1
-rw-r--r--test/prism/fixtures/seattlerb/iter_args_8_1.txt1
-rw-r--r--test/prism/fixtures/seattlerb/iter_args_8_2.txt1
-rw-r--r--test/prism/fixtures/seattlerb/iter_args_9_1.txt1
-rw-r--r--test/prism/fixtures/seattlerb/iter_args_9_2.txt1
-rw-r--r--test/prism/fixtures/seattlerb/iter_kwarg.txt1
-rw-r--r--test/prism/fixtures/seattlerb/iter_kwarg_kwsplat.txt1
-rw-r--r--test/prism/fixtures/seattlerb/label_vs_string.txt2
-rw-r--r--test/prism/fixtures/seattlerb/lambda_do_vs_brace.txt7
-rw-r--r--test/prism/fixtures/seattlerb/lasgn_arg_rescue_arg.txt1
-rw-r--r--test/prism/fixtures/seattlerb/lasgn_call_bracket_rescue_arg.txt1
-rw-r--r--test/prism/fixtures/seattlerb/lasgn_call_nobracket_rescue_arg.txt1
-rw-r--r--test/prism/fixtures/seattlerb/lasgn_command.txt1
-rw-r--r--test/prism/fixtures/seattlerb/lasgn_env.txt1
-rw-r--r--test/prism/fixtures/seattlerb/lasgn_ivar_env.txt1
-rw-r--r--test/prism/fixtures/seattlerb/lasgn_lasgn_command_call.txt1
-rw-r--r--test/prism/fixtures/seattlerb/lasgn_middle_splat.txt1
-rw-r--r--test/prism/fixtures/seattlerb/magic_encoding_comment.txt4
-rw-r--r--test/prism/fixtures/seattlerb/masgn_anon_splat_arg.txt1
-rw-r--r--test/prism/fixtures/seattlerb/masgn_arg_colon_arg.txt1
-rw-r--r--test/prism/fixtures/seattlerb/masgn_arg_ident.txt1
-rw-r--r--test/prism/fixtures/seattlerb/masgn_arg_splat_arg.txt1
-rw-r--r--test/prism/fixtures/seattlerb/masgn_colon2.txt1
-rw-r--r--test/prism/fixtures/seattlerb/masgn_colon3.txt1
-rw-r--r--test/prism/fixtures/seattlerb/masgn_command_call.txt1
-rw-r--r--test/prism/fixtures/seattlerb/masgn_double_paren.txt1
-rw-r--r--test/prism/fixtures/seattlerb/masgn_lhs_splat.txt1
-rw-r--r--test/prism/fixtures/seattlerb/masgn_paren.txt1
-rw-r--r--test/prism/fixtures/seattlerb/masgn_splat_arg.txt1
-rw-r--r--test/prism/fixtures/seattlerb/masgn_splat_arg_arg.txt1
-rw-r--r--test/prism/fixtures/seattlerb/masgn_star.txt1
-rw-r--r--test/prism/fixtures/seattlerb/masgn_var_star_var.txt1
-rw-r--r--test/prism/fixtures/seattlerb/messy_op_asgn_lineno.txt1
-rw-r--r--test/prism/fixtures/seattlerb/method_call_assoc_trailing_comma.txt1
-rw-r--r--test/prism/fixtures/seattlerb/method_call_trailing_comma.txt1
-rw-r--r--test/prism/fixtures/seattlerb/mlhs_back_anonsplat.txt1
-rw-r--r--test/prism/fixtures/seattlerb/mlhs_back_splat.txt1
-rw-r--r--test/prism/fixtures/seattlerb/mlhs_front_anonsplat.txt1
-rw-r--r--test/prism/fixtures/seattlerb/mlhs_front_splat.txt1
-rw-r--r--test/prism/fixtures/seattlerb/mlhs_keyword.txt1
-rw-r--r--test/prism/fixtures/seattlerb/mlhs_mid_anonsplat.txt1
-rw-r--r--test/prism/fixtures/seattlerb/mlhs_mid_splat.txt1
-rw-r--r--test/prism/fixtures/seattlerb/mlhs_rescue.txt1
-rw-r--r--test/prism/fixtures/seattlerb/module_comments.txt10
-rw-r--r--test/prism/fixtures/seattlerb/multiline_hash_declaration.txt8
-rw-r--r--test/prism/fixtures/seattlerb/non_interpolated_symbol_array_line_breaks.txt5
-rw-r--r--test/prism/fixtures/seattlerb/non_interpolated_word_array_line_breaks.txt5
-rw-r--r--test/prism/fixtures/seattlerb/op_asgn_command_call.txt1
-rw-r--r--test/prism/fixtures/seattlerb/op_asgn_dot_ident_command_call.txt1
-rw-r--r--test/prism/fixtures/seattlerb/op_asgn_index_command_call.txt1
-rw-r--r--test/prism/fixtures/seattlerb/op_asgn_primary_colon_const_command_call.txt1
-rw-r--r--test/prism/fixtures/seattlerb/op_asgn_primary_colon_identifier1.txt1
-rw-r--r--test/prism/fixtures/seattlerb/op_asgn_primary_colon_identifier_command_call.txt1
-rw-r--r--test/prism/fixtures/seattlerb/op_asgn_val_dot_ident_command_call.txt1
-rw-r--r--test/prism/fixtures/seattlerb/parse_def_special_name.txt1
-rw-r--r--test/prism/fixtures/seattlerb/parse_if_not_canonical.txt2
-rw-r--r--test/prism/fixtures/seattlerb/parse_if_not_noncanonical.txt2
-rw-r--r--test/prism/fixtures/seattlerb/parse_line_block.txt2
-rw-r--r--test/prism/fixtures/seattlerb/parse_line_block_inline_comment.txt3
-rw-r--r--test/prism/fixtures/seattlerb/parse_line_block_inline_comment_leading_newlines.txt7
-rw-r--r--test/prism/fixtures/seattlerb/parse_line_block_inline_multiline_comment.txt4
-rw-r--r--test/prism/fixtures/seattlerb/parse_line_call_ivar_arg_no_parens_line_break.txt2
-rw-r--r--test/prism/fixtures/seattlerb/parse_line_call_ivar_line_break_paren.txt2
-rw-r--r--test/prism/fixtures/seattlerb/parse_line_call_no_args.txt3
-rw-r--r--test/prism/fixtures/seattlerb/parse_line_defn_complex.txt5
-rw-r--r--test/prism/fixtures/seattlerb/parse_line_defn_no_parens.txt6
-rw-r--r--test/prism/fixtures/seattlerb/parse_line_defn_no_parens_args.txt2
-rw-r--r--test/prism/fixtures/seattlerb/parse_line_dot2.txt5
-rw-r--r--test/prism/fixtures/seattlerb/parse_line_dot2_open.txt3
-rw-r--r--test/prism/fixtures/seattlerb/parse_line_dot3.txt5
-rw-r--r--test/prism/fixtures/seattlerb/parse_line_dot3_open.txt3
-rw-r--r--test/prism/fixtures/seattlerb/parse_line_dstr_escaped_newline.txt3
-rw-r--r--test/prism/fixtures/seattlerb/parse_line_dstr_soft_newline.txt4
-rw-r--r--test/prism/fixtures/seattlerb/parse_line_evstr_after_break.txt2
-rw-r--r--test/prism/fixtures/seattlerb/parse_line_hash_lit.txt3
-rw-r--r--test/prism/fixtures/seattlerb/parse_line_heredoc.txt5
-rw-r--r--test/prism/fixtures/seattlerb/parse_line_heredoc_evstr.txt4
-rw-r--r--test/prism/fixtures/seattlerb/parse_line_heredoc_hardnewline.txt7
-rw-r--r--test/prism/fixtures/seattlerb/parse_line_heredoc_regexp_chars.txt5
-rw-r--r--test/prism/fixtures/seattlerb/parse_line_iter_call_no_parens.txt3
-rw-r--r--test/prism/fixtures/seattlerb/parse_line_iter_call_parens.txt3
-rw-r--r--test/prism/fixtures/seattlerb/parse_line_multiline_str.txt3
-rw-r--r--test/prism/fixtures/seattlerb/parse_line_multiline_str_literal_n.txt2
-rw-r--r--test/prism/fixtures/seattlerb/parse_line_newlines.txt3
-rw-r--r--test/prism/fixtures/seattlerb/parse_line_op_asgn.txt4
-rw-r--r--test/prism/fixtures/seattlerb/parse_line_postexe.txt3
-rw-r--r--test/prism/fixtures/seattlerb/parse_line_preexe.txt3
-rw-r--r--test/prism/fixtures/seattlerb/parse_line_rescue.txt8
-rw-r--r--test/prism/fixtures/seattlerb/parse_line_return.txt6
-rw-r--r--test/prism/fixtures/seattlerb/parse_line_str_with_newline_escape.txt1
-rw-r--r--test/prism/fixtures/seattlerb/parse_line_to_ary.txt3
-rw-r--r--test/prism/fixtures/seattlerb/parse_line_trailing_newlines.txt2
-rw-r--r--test/prism/fixtures/seattlerb/parse_opt_call_args_assocs_comma.txt1
-rw-r--r--test/prism/fixtures/seattlerb/parse_opt_call_args_lit_comma.txt1
-rw-r--r--test/prism/fixtures/seattlerb/parse_pattern_019.txt5
-rw-r--r--test/prism/fixtures/seattlerb/parse_pattern_044.txt5
-rw-r--r--test/prism/fixtures/seattlerb/parse_pattern_051.txt5
-rw-r--r--test/prism/fixtures/seattlerb/parse_pattern_058.txt5
-rw-r--r--test/prism/fixtures/seattlerb/parse_pattern_058_2.txt5
-rw-r--r--test/prism/fixtures/seattlerb/parse_pattern_069.txt5
-rw-r--r--test/prism/fixtures/seattlerb/parse_pattern_076.txt5
-rw-r--r--test/prism/fixtures/seattlerb/parse_until_not_canonical.txt3
-rw-r--r--test/prism/fixtures/seattlerb/parse_until_not_noncanonical.txt3
-rw-r--r--test/prism/fixtures/seattlerb/parse_while_not_canonical.txt3
-rw-r--r--test/prism/fixtures/seattlerb/parse_while_not_noncanonical.txt3
-rw-r--r--test/prism/fixtures/seattlerb/pctW_lineno.txt5
-rw-r--r--test/prism/fixtures/seattlerb/pct_Q_backslash_nl.txt2
-rw-r--r--test/prism/fixtures/seattlerb/pct_nl.txt3
-rw-r--r--test/prism/fixtures/seattlerb/pct_w_heredoc_interp_nested.txt4
-rw-r--r--test/prism/fixtures/seattlerb/pipe_semicolon.txt1
-rw-r--r--test/prism/fixtures/seattlerb/pipe_space.txt1
-rw-r--r--test/prism/fixtures/seattlerb/qWords_space.txt1
-rw-r--r--test/prism/fixtures/seattlerb/qsymbols.txt1
-rw-r--r--test/prism/fixtures/seattlerb/qsymbols_empty.txt1
-rw-r--r--test/prism/fixtures/seattlerb/qsymbols_empty_space.txt1
-rw-r--r--test/prism/fixtures/seattlerb/qsymbols_interp.txt1
-rw-r--r--test/prism/fixtures/seattlerb/quoted_symbol_hash_arg.txt1
-rw-r--r--test/prism/fixtures/seattlerb/quoted_symbol_keys.txt1
-rw-r--r--test/prism/fixtures/seattlerb/qw_escape.txt1
-rw-r--r--test/prism/fixtures/seattlerb/qw_escape_term.txt1
-rw-r--r--test/prism/fixtures/seattlerb/qwords_empty.txt1
-rw-r--r--test/prism/fixtures/seattlerb/read_escape_unicode_curlies.txt1
-rw-r--r--test/prism/fixtures/seattlerb/read_escape_unicode_h4.txt1
-rw-r--r--test/prism/fixtures/seattlerb/regexp.txt9
-rw-r--r--test/prism/fixtures/seattlerb/regexp_esc_C_slash.txt1
-rw-r--r--test/prism/fixtures/seattlerb/regexp_esc_u.txt1
-rw-r--r--test/prism/fixtures/seattlerb/regexp_escape_extended.txt1
-rw-r--r--test/prism/fixtures/seattlerb/regexp_unicode_curlies.txt3
-rw-r--r--test/prism/fixtures/seattlerb/required_kwarg_no_value.txt2
-rw-r--r--test/prism/fixtures/seattlerb/rescue_do_end_ensure_result.txt5
-rw-r--r--test/prism/fixtures/seattlerb/rescue_do_end_no_raise.txt9
-rw-r--r--test/prism/fixtures/seattlerb/rescue_do_end_raised.txt5
-rw-r--r--test/prism/fixtures/seattlerb/rescue_do_end_rescued.txt9
-rw-r--r--test/prism/fixtures/seattlerb/rescue_in_block.txt4
-rw-r--r--test/prism/fixtures/seattlerb/rescue_parens.txt1
-rw-r--r--test/prism/fixtures/seattlerb/return_call_assocs.txt11
-rw-r--r--test/prism/fixtures/seattlerb/rhs_asgn.txt1
-rw-r--r--test/prism/fixtures/seattlerb/ruby21_numbers.txt1
-rw-r--r--test/prism/fixtures/seattlerb/safe_attrasgn.txt1
-rw-r--r--test/prism/fixtures/seattlerb/safe_attrasgn_constant.txt1
-rw-r--r--test/prism/fixtures/seattlerb/safe_call.txt1
-rw-r--r--test/prism/fixtures/seattlerb/safe_call_after_newline.txt2
-rw-r--r--test/prism/fixtures/seattlerb/safe_call_dot_parens.txt1
-rw-r--r--test/prism/fixtures/seattlerb/safe_call_newline.txt2
-rw-r--r--test/prism/fixtures/seattlerb/safe_call_operator.txt1
-rw-r--r--test/prism/fixtures/seattlerb/safe_call_rhs_newline.txt2
-rw-r--r--test/prism/fixtures/seattlerb/safe_calls.txt1
-rw-r--r--test/prism/fixtures/seattlerb/safe_op_asgn.txt1
-rw-r--r--test/prism/fixtures/seattlerb/safe_op_asgn2.txt2
-rw-r--r--test/prism/fixtures/seattlerb/slashy_newlines_within_string.txt7
-rw-r--r--test/prism/fixtures/seattlerb/stabby_arg_no_paren.txt1
-rw-r--r--test/prism/fixtures/seattlerb/stabby_arg_opt_splat_arg_block_omfg.txt1
-rw-r--r--test/prism/fixtures/seattlerb/stabby_block_iter_call.txt4
-rw-r--r--test/prism/fixtures/seattlerb/stabby_block_iter_call_no_target_with_arg.txt4
-rw-r--r--test/prism/fixtures/seattlerb/stabby_block_kw.txt1
-rw-r--r--test/prism/fixtures/seattlerb/stabby_block_kw__required.txt1
-rw-r--r--test/prism/fixtures/seattlerb/stabby_proc_scope.txt1
-rw-r--r--test/prism/fixtures/seattlerb/str_backslashes.txt1
-rw-r--r--test/prism/fixtures/seattlerb/str_double_double_escaped_newline.txt1
-rw-r--r--test/prism/fixtures/seattlerb/str_double_escaped_newline.txt1
-rw-r--r--test/prism/fixtures/seattlerb/str_double_newline.txt2
-rw-r--r--test/prism/fixtures/seattlerb/str_evstr.txt1
-rw-r--r--test/prism/fixtures/seattlerb/str_evstr_escape.txt1
-rw-r--r--test/prism/fixtures/seattlerb/str_heredoc_interp.txt5
-rw-r--r--test/prism/fixtures/seattlerb/str_interp_ternary_or_label.txt1
-rw-r--r--test/prism/fixtures/seattlerb/str_lit_concat_bad_encodings.txt2
-rw-r--r--test/prism/fixtures/seattlerb/str_newline_hash_line_number.txt2
-rw-r--r--test/prism/fixtures/seattlerb/str_pct_Q_nested.txt1
-rw-r--r--test/prism/fixtures/seattlerb/str_pct_nested_nested.txt1
-rw-r--r--test/prism/fixtures/seattlerb/str_pct_q.txt1
-rw-r--r--test/prism/fixtures/seattlerb/str_single_double_escaped_newline.txt1
-rw-r--r--test/prism/fixtures/seattlerb/str_single_escaped_newline.txt1
-rw-r--r--test/prism/fixtures/seattlerb/str_single_newline.txt2
-rw-r--r--test/prism/fixtures/seattlerb/str_str.txt1
-rw-r--r--test/prism/fixtures/seattlerb/str_str_str.txt1
-rw-r--r--test/prism/fixtures/seattlerb/super_arg.txt1
-rw-r--r--test/prism/fixtures/seattlerb/symbol_empty.txt1
-rw-r--r--test/prism/fixtures/seattlerb/symbol_list.txt1
-rw-r--r--test/prism/fixtures/seattlerb/symbols.txt1
-rw-r--r--test/prism/fixtures/seattlerb/symbols_empty.txt1
-rw-r--r--test/prism/fixtures/seattlerb/symbols_empty_space.txt1
-rw-r--r--test/prism/fixtures/seattlerb/symbols_interp.txt1
-rw-r--r--test/prism/fixtures/seattlerb/thingy.txt3
-rw-r--r--test/prism/fixtures/seattlerb/uminus_float.txt1
-rw-r--r--test/prism/fixtures/seattlerb/unary_minus.txt1
-rw-r--r--test/prism/fixtures/seattlerb/unary_plus.txt1
-rw-r--r--test/prism/fixtures/seattlerb/unary_plus_on_literal.txt1
-rw-r--r--test/prism/fixtures/seattlerb/unary_tilde.txt1
-rw-r--r--test/prism/fixtures/seattlerb/utf8_bom.txt3
-rw-r--r--test/prism/fixtures/seattlerb/when_splat.txt1
-rw-r--r--test/prism/fixtures/seattlerb/words_interp.txt1
-rw-r--r--test/prism/fixtures/seattlerb/yield_arg.txt1
-rw-r--r--test/prism/fixtures/seattlerb/yield_call_assocs.txt11
-rw-r--r--test/prism/fixtures/seattlerb/yield_empty_parens.txt1
-rw-r--r--test/prism/fixtures/single_quote_heredocs.txt3
-rw-r--r--test/prism/fixtures/spanning_heredoc.txt63
-rw-r--r--test/prism/fixtures/strings.txt105
-rw-r--r--test/prism/fixtures/super.txt17
-rw-r--r--test/prism/fixtures/symbols.txt93
-rw-r--r--test/prism/fixtures/ternary_operator.txt15
-rw-r--r--test/prism/fixtures/tilde_heredocs.txt97
-rw-r--r--test/prism/fixtures/undef.txt17
-rw-r--r--test/prism/fixtures/unescaping.txt9
-rw-r--r--test/prism/fixtures/unless.txt14
-rw-r--r--test/prism/fixtures/unparser/LICENSE20
-rw-r--r--test/prism/fixtures/unparser/corpus/literal/alias.txt2
-rw-r--r--test/prism/fixtures/unparser/corpus/literal/assignment.txt53
-rw-r--r--test/prism/fixtures/unparser/corpus/literal/block.txt96
-rw-r--r--test/prism/fixtures/unparser/corpus/literal/case.txt37
-rw-r--r--test/prism/fixtures/unparser/corpus/literal/class.txt35
-rw-r--r--test/prism/fixtures/unparser/corpus/literal/control.txt15
-rw-r--r--test/prism/fixtures/unparser/corpus/literal/def.txt134
-rw-r--r--test/prism/fixtures/unparser/corpus/literal/defined.txt3
-rw-r--r--test/prism/fixtures/unparser/corpus/literal/defs.txt40
-rw-r--r--test/prism/fixtures/unparser/corpus/literal/dstr.txt37
-rw-r--r--test/prism/fixtures/unparser/corpus/literal/empty.txt0
-rw-r--r--test/prism/fixtures/unparser/corpus/literal/empty_begin.txt1
-rw-r--r--test/prism/fixtures/unparser/corpus/literal/flipflop.txt6
-rw-r--r--test/prism/fixtures/unparser/corpus/literal/for.txt12
-rw-r--r--test/prism/fixtures/unparser/corpus/literal/hookexe.txt7
-rw-r--r--test/prism/fixtures/unparser/corpus/literal/if.txt36
-rw-r--r--test/prism/fixtures/unparser/corpus/literal/kwbegin.txt80
-rw-r--r--test/prism/fixtures/unparser/corpus/literal/lambda.txt13
-rw-r--r--test/prism/fixtures/unparser/corpus/literal/literal.txt91
-rw-r--r--test/prism/fixtures/unparser/corpus/literal/module.txt16
-rw-r--r--test/prism/fixtures/unparser/corpus/literal/opasgn.txt24
-rw-r--r--test/prism/fixtures/unparser/corpus/literal/pattern.txt41
-rw-r--r--test/prism/fixtures/unparser/corpus/literal/pragma.txt4
-rw-r--r--test/prism/fixtures/unparser/corpus/literal/range.txt4
-rw-r--r--test/prism/fixtures/unparser/corpus/literal/rescue.txt3
-rw-r--r--test/prism/fixtures/unparser/corpus/literal/send.txt84
-rw-r--r--test/prism/fixtures/unparser/corpus/literal/since/27.txt4
-rw-r--r--test/prism/fixtures/unparser/corpus/literal/since/30.txt4
-rw-r--r--test/prism/fixtures/unparser/corpus/literal/since/31.txt7
-rw-r--r--test/prism/fixtures/unparser/corpus/literal/since/32.txt7
-rw-r--r--test/prism/fixtures/unparser/corpus/literal/singletons.txt4
-rw-r--r--test/prism/fixtures/unparser/corpus/literal/super.txt21
-rw-r--r--test/prism/fixtures/unparser/corpus/literal/unary.txt8
-rw-r--r--test/prism/fixtures/unparser/corpus/literal/undef.txt2
-rw-r--r--test/prism/fixtures/unparser/corpus/literal/variables.txt10
-rw-r--r--test/prism/fixtures/unparser/corpus/literal/while.txt73
-rw-r--r--test/prism/fixtures/unparser/corpus/literal/yield.txt3
-rw-r--r--test/prism/fixtures/unparser/corpus/semantic/and.txt8
-rw-r--r--test/prism/fixtures/unparser/corpus/semantic/block.txt26
-rw-r--r--test/prism/fixtures/unparser/corpus/semantic/def.txt7
-rw-r--r--test/prism/fixtures/unparser/corpus/semantic/dstr.txt127
-rw-r--r--test/prism/fixtures/unparser/corpus/semantic/kwbegin.txt42
-rw-r--r--test/prism/fixtures/unparser/corpus/semantic/literal.txt14
-rw-r--r--test/prism/fixtures/unparser/corpus/semantic/send.txt6
-rw-r--r--test/prism/fixtures/unparser/corpus/semantic/undef.txt2
-rw-r--r--test/prism/fixtures/unparser/corpus/semantic/while.txt25
-rw-r--r--test/prism/fixtures/until.txt13
-rw-r--r--test/prism/fixtures/variables.txt47
-rw-r--r--test/prism/fixtures/while.txt23
-rw-r--r--test/prism/fixtures/whitequark/LICENSE25
-rw-r--r--test/prism/fixtures/whitequark/__ENCODING__.txt1
-rw-r--r--test/prism/fixtures/whitequark/__ENCODING___legacy_.txt1
-rw-r--r--test/prism/fixtures/whitequark/alias.txt1
-rw-r--r--test/prism/fixtures/whitequark/alias_gvar.txt3
-rw-r--r--test/prism/fixtures/whitequark/ambiuous_quoted_label_in_ternary_operator.txt1
-rw-r--r--test/prism/fixtures/whitequark/and.txt3
-rw-r--r--test/prism/fixtures/whitequark/and_asgn.txt3
-rw-r--r--test/prism/fixtures/whitequark/and_or_masgn.txt3
-rw-r--r--test/prism/fixtures/whitequark/anonymous_blockarg.txt1
-rw-r--r--test/prism/fixtures/whitequark/arg.txt3
-rw-r--r--test/prism/fixtures/whitequark/arg_duplicate_ignored.txt3
-rw-r--r--test/prism/fixtures/whitequark/arg_label.txt6
-rw-r--r--test/prism/fixtures/whitequark/arg_scope.txt1
-rw-r--r--test/prism/fixtures/whitequark/args.txt63
-rw-r--r--test/prism/fixtures/whitequark/args_args_assocs.txt3
-rw-r--r--test/prism/fixtures/whitequark/args_args_assocs_comma.txt1
-rw-r--r--test/prism/fixtures/whitequark/args_args_comma.txt1
-rw-r--r--test/prism/fixtures/whitequark/args_args_star.txt3
-rw-r--r--test/prism/fixtures/whitequark/args_assocs.txt11
-rw-r--r--test/prism/fixtures/whitequark/args_assocs_comma.txt1
-rw-r--r--test/prism/fixtures/whitequark/args_assocs_legacy.txt11
-rw-r--r--test/prism/fixtures/whitequark/args_block_pass.txt1
-rw-r--r--test/prism/fixtures/whitequark/args_cmd.txt1
-rw-r--r--test/prism/fixtures/whitequark/args_star.txt3
-rw-r--r--test/prism/fixtures/whitequark/array_assocs.txt3
-rw-r--r--test/prism/fixtures/whitequark/array_plain.txt1
-rw-r--r--test/prism/fixtures/whitequark/array_splat.txt5
-rw-r--r--test/prism/fixtures/whitequark/array_symbols.txt1
-rw-r--r--test/prism/fixtures/whitequark/array_symbols_empty.txt3
-rw-r--r--test/prism/fixtures/whitequark/array_symbols_interp.txt3
-rw-r--r--test/prism/fixtures/whitequark/array_words.txt1
-rw-r--r--test/prism/fixtures/whitequark/array_words_empty.txt3
-rw-r--r--test/prism/fixtures/whitequark/array_words_interp.txt3
-rw-r--r--test/prism/fixtures/whitequark/asgn_cmd.txt3
-rw-r--r--test/prism/fixtures/whitequark/asgn_mrhs.txt5
-rw-r--r--test/prism/fixtures/whitequark/back_ref.txt1
-rw-r--r--test/prism/fixtures/whitequark/bang.txt1
-rw-r--r--test/prism/fixtures/whitequark/bang_cmd.txt1
-rw-r--r--test/prism/fixtures/whitequark/begin_cmdarg.txt1
-rw-r--r--test/prism/fixtures/whitequark/beginless_erange_after_newline.txt2
-rw-r--r--test/prism/fixtures/whitequark/beginless_irange_after_newline.txt2
-rw-r--r--test/prism/fixtures/whitequark/beginless_range.txt3
-rw-r--r--test/prism/fixtures/whitequark/blockarg.txt1
-rw-r--r--test/prism/fixtures/whitequark/blockargs.txt71
-rw-r--r--test/prism/fixtures/whitequark/break.txt7
-rw-r--r--test/prism/fixtures/whitequark/break_block.txt1
-rw-r--r--test/prism/fixtures/whitequark/bug_435.txt1
-rw-r--r--test/prism/fixtures/whitequark/bug_447.txt3
-rw-r--r--test/prism/fixtures/whitequark/bug_452.txt1
-rw-r--r--test/prism/fixtures/whitequark/bug_466.txt1
-rw-r--r--test/prism/fixtures/whitequark/bug_473.txt1
-rw-r--r--test/prism/fixtures/whitequark/bug_480.txt1
-rw-r--r--test/prism/fixtures/whitequark/bug_481.txt1
-rw-r--r--test/prism/fixtures/whitequark/bug_ascii_8bit_in_literal.txt2
-rw-r--r--test/prism/fixtures/whitequark/bug_cmd_string_lookahead.txt1
-rw-r--r--test/prism/fixtures/whitequark/bug_cmdarg.txt5
-rw-r--r--test/prism/fixtures/whitequark/bug_def_no_paren_eql_begin.txt4
-rw-r--r--test/prism/fixtures/whitequark/bug_do_block_in_call_args.txt1
-rw-r--r--test/prism/fixtures/whitequark/bug_do_block_in_cmdarg.txt1
-rw-r--r--test/prism/fixtures/whitequark/bug_do_block_in_hash_brace.txt9
-rw-r--r--test/prism/fixtures/whitequark/bug_heredoc_do.txt3
-rw-r--r--test/prism/fixtures/whitequark/bug_interp_single.txt3
-rw-r--r--test/prism/fixtures/whitequark/bug_lambda_leakage.txt1
-rw-r--r--test/prism/fixtures/whitequark/bug_regex_verification.txt1
-rw-r--r--test/prism/fixtures/whitequark/bug_rescue_empty_else.txt1
-rw-r--r--test/prism/fixtures/whitequark/bug_while_not_parens_do.txt1
-rw-r--r--test/prism/fixtures/whitequark/case_cond.txt1
-rw-r--r--test/prism/fixtures/whitequark/case_cond_else.txt1
-rw-r--r--test/prism/fixtures/whitequark/case_expr.txt1
-rw-r--r--test/prism/fixtures/whitequark/case_expr_else.txt1
-rw-r--r--test/prism/fixtures/whitequark/casgn_scoped.txt1
-rw-r--r--test/prism/fixtures/whitequark/casgn_toplevel.txt1
-rw-r--r--test/prism/fixtures/whitequark/casgn_unscoped.txt1
-rw-r--r--test/prism/fixtures/whitequark/character.txt1
-rw-r--r--test/prism/fixtures/whitequark/class.txt3
-rw-r--r--test/prism/fixtures/whitequark/class_definition_in_while_cond.txt7
-rw-r--r--test/prism/fixtures/whitequark/class_super.txt1
-rw-r--r--test/prism/fixtures/whitequark/class_super_label.txt1
-rw-r--r--test/prism/fixtures/whitequark/comments_before_leading_dot__27.txt19
-rw-r--r--test/prism/fixtures/whitequark/complex.txt7
-rw-r--r--test/prism/fixtures/whitequark/cond_begin.txt1
-rw-r--r--test/prism/fixtures/whitequark/cond_begin_masgn.txt1
-rw-r--r--test/prism/fixtures/whitequark/cond_eflipflop.txt3
-rw-r--r--test/prism/fixtures/whitequark/cond_iflipflop.txt3
-rw-r--r--test/prism/fixtures/whitequark/cond_match_current_line.txt3
-rw-r--r--test/prism/fixtures/whitequark/const_op_asgn.txt9
-rw-r--r--test/prism/fixtures/whitequark/const_scoped.txt1
-rw-r--r--test/prism/fixtures/whitequark/const_toplevel.txt1
-rw-r--r--test/prism/fixtures/whitequark/const_unscoped.txt1
-rw-r--r--test/prism/fixtures/whitequark/cpath.txt3
-rw-r--r--test/prism/fixtures/whitequark/cvar.txt1
-rw-r--r--test/prism/fixtures/whitequark/cvasgn.txt1
-rw-r--r--test/prism/fixtures/whitequark/dedenting_heredoc.txt75
-rw-r--r--test/prism/fixtures/whitequark/dedenting_interpolating_heredoc_fake_line_continuation.txt4
-rw-r--r--test/prism/fixtures/whitequark/dedenting_non_interpolating_heredoc_line_continuation.txt4
-rw-r--r--test/prism/fixtures/whitequark/def.txt11
-rw-r--r--test/prism/fixtures/whitequark/defined.txt5
-rw-r--r--test/prism/fixtures/whitequark/defs.txt9
-rw-r--r--test/prism/fixtures/whitequark/empty_stmt.txt1
-rw-r--r--test/prism/fixtures/whitequark/endless_comparison_method.txt11
-rw-r--r--test/prism/fixtures/whitequark/endless_method.txt7
-rw-r--r--test/prism/fixtures/whitequark/endless_method_command_syntax.txt15
-rw-r--r--test/prism/fixtures/whitequark/endless_method_forwarded_args_legacy.txt1
-rw-r--r--test/prism/fixtures/whitequark/endless_method_with_rescue_mod.txt3
-rw-r--r--test/prism/fixtures/whitequark/endless_method_without_args.txt7
-rw-r--r--test/prism/fixtures/whitequark/ensure.txt1
-rw-r--r--test/prism/fixtures/whitequark/ensure_empty.txt1
-rw-r--r--test/prism/fixtures/whitequark/false.txt1
-rw-r--r--test/prism/fixtures/whitequark/float.txt3
-rw-r--r--test/prism/fixtures/whitequark/for.txt3
-rw-r--r--test/prism/fixtures/whitequark/for_mlhs.txt1
-rw-r--r--test/prism/fixtures/whitequark/forward_arg.txt1
-rw-r--r--test/prism/fixtures/whitequark/forward_arg_with_open_args.txt27
-rw-r--r--test/prism/fixtures/whitequark/forward_args_legacy.txt5
-rw-r--r--test/prism/fixtures/whitequark/forwarded_argument_with_kwrestarg.txt1
-rw-r--r--test/prism/fixtures/whitequark/forwarded_argument_with_restarg.txt1
-rw-r--r--test/prism/fixtures/whitequark/forwarded_kwrestarg.txt1
-rw-r--r--test/prism/fixtures/whitequark/forwarded_kwrestarg_with_additional_kwarg.txt1
-rw-r--r--test/prism/fixtures/whitequark/forwarded_restarg.txt1
-rw-r--r--test/prism/fixtures/whitequark/gvar.txt1
-rw-r--r--test/prism/fixtures/whitequark/gvasgn.txt1
-rw-r--r--test/prism/fixtures/whitequark/hash_empty.txt1
-rw-r--r--test/prism/fixtures/whitequark/hash_hashrocket.txt3
-rw-r--r--test/prism/fixtures/whitequark/hash_kwsplat.txt1
-rw-r--r--test/prism/fixtures/whitequark/hash_label.txt1
-rw-r--r--test/prism/fixtures/whitequark/hash_label_end.txt5
-rw-r--r--test/prism/fixtures/whitequark/hash_pair_value_omission.txt5
-rw-r--r--test/prism/fixtures/whitequark/heredoc.txt14
-rw-r--r--test/prism/fixtures/whitequark/if.txt3
-rw-r--r--test/prism/fixtures/whitequark/if_else.txt3
-rw-r--r--test/prism/fixtures/whitequark/if_elsif.txt1
-rw-r--r--test/prism/fixtures/whitequark/if_masgn__24.txt1
-rw-r--r--test/prism/fixtures/whitequark/if_mod.txt1
-rw-r--r--test/prism/fixtures/whitequark/if_nl_then.txt2
-rw-r--r--test/prism/fixtures/whitequark/if_while_after_class__since_32.txt7
-rw-r--r--test/prism/fixtures/whitequark/int.txt5
-rw-r--r--test/prism/fixtures/whitequark/int___LINE__.txt1
-rw-r--r--test/prism/fixtures/whitequark/interp_digit_var.txt87
-rw-r--r--test/prism/fixtures/whitequark/ivar.txt1
-rw-r--r--test/prism/fixtures/whitequark/ivasgn.txt1
-rw-r--r--test/prism/fixtures/whitequark/keyword_argument_omission.txt1
-rw-r--r--test/prism/fixtures/whitequark/kwarg.txt1
-rw-r--r--test/prism/fixtures/whitequark/kwbegin_compstmt.txt1
-rw-r--r--test/prism/fixtures/whitequark/kwnilarg.txt5
-rw-r--r--test/prism/fixtures/whitequark/kwoptarg.txt1
-rw-r--r--test/prism/fixtures/whitequark/kwoptarg_with_kwrestarg_and_forwarded_args.txt1
-rw-r--r--test/prism/fixtures/whitequark/kwrestarg_named.txt1
-rw-r--r--test/prism/fixtures/whitequark/kwrestarg_unnamed.txt1
-rw-r--r--test/prism/fixtures/whitequark/lbrace_arg_after_command_args.txt1
-rw-r--r--test/prism/fixtures/whitequark/lparenarg_after_lvar__since_25.txt3
-rw-r--r--test/prism/fixtures/whitequark/lvar.txt1
-rw-r--r--test/prism/fixtures/whitequark/lvar_injecting_match.txt1
-rw-r--r--test/prism/fixtures/whitequark/lvasgn.txt1
-rw-r--r--test/prism/fixtures/whitequark/masgn.txt5
-rw-r--r--test/prism/fixtures/whitequark/masgn_attr.txt5
-rw-r--r--test/prism/fixtures/whitequark/masgn_cmd.txt1
-rw-r--r--test/prism/fixtures/whitequark/masgn_const.txt3
-rw-r--r--test/prism/fixtures/whitequark/masgn_nested.txt3
-rw-r--r--test/prism/fixtures/whitequark/masgn_splat.txt19
-rw-r--r--test/prism/fixtures/whitequark/method_definition_in_while_cond.txt7
-rw-r--r--test/prism/fixtures/whitequark/module.txt1
-rw-r--r--test/prism/fixtures/whitequark/multiple_pattern_matches.txt5
-rw-r--r--test/prism/fixtures/whitequark/newline_in_hash_argument.txt14
-rw-r--r--test/prism/fixtures/whitequark/next.txt7
-rw-r--r--test/prism/fixtures/whitequark/next_block.txt1
-rw-r--r--test/prism/fixtures/whitequark/nil.txt1
-rw-r--r--test/prism/fixtures/whitequark/nil_expression.txt3
-rw-r--r--test/prism/fixtures/whitequark/non_lvar_injecting_match.txt1
-rw-r--r--test/prism/fixtures/whitequark/not.txt5
-rw-r--r--test/prism/fixtures/whitequark/not_cmd.txt1
-rw-r--r--test/prism/fixtures/whitequark/not_masgn__24.txt1
-rw-r--r--test/prism/fixtures/whitequark/nth_ref.txt1
-rw-r--r--test/prism/fixtures/whitequark/numbered_args_after_27.txt7
-rw-r--r--test/prism/fixtures/whitequark/numparam_outside_block.txt9
-rw-r--r--test/prism/fixtures/whitequark/op_asgn.txt5
-rw-r--r--test/prism/fixtures/whitequark/op_asgn_cmd.txt7
-rw-r--r--test/prism/fixtures/whitequark/op_asgn_index.txt1
-rw-r--r--test/prism/fixtures/whitequark/op_asgn_index_cmd.txt1
-rw-r--r--test/prism/fixtures/whitequark/optarg.txt3
-rw-r--r--test/prism/fixtures/whitequark/or.txt3
-rw-r--r--test/prism/fixtures/whitequark/or_asgn.txt3
-rw-r--r--test/prism/fixtures/whitequark/parser_bug_272.txt1
-rw-r--r--test/prism/fixtures/whitequark/parser_bug_490.txt5
-rw-r--r--test/prism/fixtures/whitequark/parser_bug_507.txt1
-rw-r--r--test/prism/fixtures/whitequark/parser_bug_518.txt2
-rw-r--r--test/prism/fixtures/whitequark/parser_bug_525.txt1
-rw-r--r--test/prism/fixtures/whitequark/parser_bug_604.txt1
-rw-r--r--test/prism/fixtures/whitequark/parser_bug_640.txt4
-rw-r--r--test/prism/fixtures/whitequark/parser_bug_645.txt1
-rw-r--r--test/prism/fixtures/whitequark/parser_bug_830.txt1
-rw-r--r--test/prism/fixtures/whitequark/parser_drops_truncated_parts_of_squiggly_heredoc.txt3
-rw-r--r--test/prism/fixtures/whitequark/parser_slash_slash_n_escaping_in_literals.txt62
-rw-r--r--test/prism/fixtures/whitequark/pattern_matching__FILE__LINE_literals.txt4
-rw-r--r--test/prism/fixtures/whitequark/pattern_matching_blank_else.txt1
-rw-r--r--test/prism/fixtures/whitequark/pattern_matching_else.txt1
-rw-r--r--test/prism/fixtures/whitequark/pattern_matching_single_line.txt3
-rw-r--r--test/prism/fixtures/whitequark/pattern_matching_single_line_allowed_omission_of_parentheses.txt11
-rw-r--r--test/prism/fixtures/whitequark/postexe.txt1
-rw-r--r--test/prism/fixtures/whitequark/preexe.txt1
-rw-r--r--test/prism/fixtures/whitequark/procarg0.txt3
-rw-r--r--test/prism/fixtures/whitequark/range_exclusive.txt1
-rw-r--r--test/prism/fixtures/whitequark/range_inclusive.txt1
-rw-r--r--test/prism/fixtures/whitequark/rational.txt3
-rw-r--r--test/prism/fixtures/whitequark/redo.txt1
-rw-r--r--test/prism/fixtures/whitequark/regex_interp.txt1
-rw-r--r--test/prism/fixtures/whitequark/regex_plain.txt1
-rw-r--r--test/prism/fixtures/whitequark/resbody_list.txt1
-rw-r--r--test/prism/fixtures/whitequark/resbody_list_mrhs.txt1
-rw-r--r--test/prism/fixtures/whitequark/resbody_list_var.txt1
-rw-r--r--test/prism/fixtures/whitequark/resbody_var.txt3
-rw-r--r--test/prism/fixtures/whitequark/rescue.txt1
-rw-r--r--test/prism/fixtures/whitequark/rescue_else.txt1
-rw-r--r--test/prism/fixtures/whitequark/rescue_else_ensure.txt1
-rw-r--r--test/prism/fixtures/whitequark/rescue_ensure.txt1
-rw-r--r--test/prism/fixtures/whitequark/rescue_in_lambda_block.txt1
-rw-r--r--test/prism/fixtures/whitequark/rescue_mod.txt1
-rw-r--r--test/prism/fixtures/whitequark/rescue_mod_asgn.txt1
-rw-r--r--test/prism/fixtures/whitequark/rescue_mod_masgn.txt1
-rw-r--r--test/prism/fixtures/whitequark/rescue_mod_op_assign.txt1
-rw-r--r--test/prism/fixtures/whitequark/rescue_without_begin_end.txt1
-rw-r--r--test/prism/fixtures/whitequark/restarg_named.txt1
-rw-r--r--test/prism/fixtures/whitequark/restarg_unnamed.txt1
-rw-r--r--test/prism/fixtures/whitequark/retry.txt1
-rw-r--r--test/prism/fixtures/whitequark/return.txt7
-rw-r--r--test/prism/fixtures/whitequark/return_block.txt1
-rw-r--r--test/prism/fixtures/whitequark/ruby_bug_10279.txt1
-rw-r--r--test/prism/fixtures/whitequark/ruby_bug_10653.txt5
-rw-r--r--test/prism/fixtures/whitequark/ruby_bug_11107.txt1
-rw-r--r--test/prism/fixtures/whitequark/ruby_bug_11380.txt1
-rw-r--r--test/prism/fixtures/whitequark/ruby_bug_11873.txt23
-rw-r--r--test/prism/fixtures/whitequark/ruby_bug_11873_a.txt39
-rw-r--r--test/prism/fixtures/whitequark/ruby_bug_11873_b.txt1
-rw-r--r--test/prism/fixtures/whitequark/ruby_bug_11989.txt3
-rw-r--r--test/prism/fixtures/whitequark/ruby_bug_11990.txt3
-rw-r--r--test/prism/fixtures/whitequark/ruby_bug_12073.txt3
-rw-r--r--test/prism/fixtures/whitequark/ruby_bug_12402.txt27
-rw-r--r--test/prism/fixtures/whitequark/ruby_bug_12669.txt7
-rw-r--r--test/prism/fixtures/whitequark/ruby_bug_12686.txt1
-rw-r--r--test/prism/fixtures/whitequark/ruby_bug_13547.txt1
-rw-r--r--test/prism/fixtures/whitequark/ruby_bug_14690.txt1
-rw-r--r--test/prism/fixtures/whitequark/ruby_bug_15789.txt3
-rw-r--r--test/prism/fixtures/whitequark/ruby_bug_9669.txt8
-rw-r--r--test/prism/fixtures/whitequark/sclass.txt1
-rw-r--r--test/prism/fixtures/whitequark/self.txt1
-rw-r--r--test/prism/fixtures/whitequark/send_attr_asgn.txt7
-rw-r--r--test/prism/fixtures/whitequark/send_attr_asgn_conditional.txt1
-rw-r--r--test/prism/fixtures/whitequark/send_binary_op.txt41
-rw-r--r--test/prism/fixtures/whitequark/send_block_chain_cmd.txt13
-rw-r--r--test/prism/fixtures/whitequark/send_block_conditional.txt1
-rw-r--r--test/prism/fixtures/whitequark/send_call.txt3
-rw-r--r--test/prism/fixtures/whitequark/send_conditional.txt1
-rw-r--r--test/prism/fixtures/whitequark/send_index.txt1
-rw-r--r--test/prism/fixtures/whitequark/send_index_asgn.txt1
-rw-r--r--test/prism/fixtures/whitequark/send_index_asgn_legacy.txt1
-rw-r--r--test/prism/fixtures/whitequark/send_index_cmd.txt1
-rw-r--r--test/prism/fixtures/whitequark/send_index_legacy.txt1
-rw-r--r--test/prism/fixtures/whitequark/send_lambda.txt5
-rw-r--r--test/prism/fixtures/whitequark/send_lambda_args.txt3
-rw-r--r--test/prism/fixtures/whitequark/send_lambda_args_noparen.txt3
-rw-r--r--test/prism/fixtures/whitequark/send_lambda_args_shadow.txt1
-rw-r--r--test/prism/fixtures/whitequark/send_lambda_legacy.txt1
-rw-r--r--test/prism/fixtures/whitequark/send_op_asgn_conditional.txt1
-rw-r--r--test/prism/fixtures/whitequark/send_plain.txt5
-rw-r--r--test/prism/fixtures/whitequark/send_plain_cmd.txt5
-rw-r--r--test/prism/fixtures/whitequark/send_self.txt5
-rw-r--r--test/prism/fixtures/whitequark/send_self_block.txt7
-rw-r--r--test/prism/fixtures/whitequark/send_unary_op.txt5
-rw-r--r--test/prism/fixtures/whitequark/slash_newline_in_heredocs.txt13
-rw-r--r--test/prism/fixtures/whitequark/space_args_arg.txt1
-rw-r--r--test/prism/fixtures/whitequark/space_args_arg_block.txt5
-rw-r--r--test/prism/fixtures/whitequark/space_args_arg_call.txt1
-rw-r--r--test/prism/fixtures/whitequark/space_args_arg_newline.txt2
-rw-r--r--test/prism/fixtures/whitequark/space_args_block.txt1
-rw-r--r--test/prism/fixtures/whitequark/space_args_cmd.txt1
-rw-r--r--test/prism/fixtures/whitequark/string___FILE__.txt1
-rw-r--r--test/prism/fixtures/whitequark/string_concat.txt1
-rw-r--r--test/prism/fixtures/whitequark/string_dvar.txt1
-rw-r--r--test/prism/fixtures/whitequark/string_interp.txt1
-rw-r--r--test/prism/fixtures/whitequark/string_plain.txt3
-rw-r--r--test/prism/fixtures/whitequark/super.txt5
-rw-r--r--test/prism/fixtures/whitequark/super_block.txt3
-rw-r--r--test/prism/fixtures/whitequark/symbol_interp.txt1
-rw-r--r--test/prism/fixtures/whitequark/symbol_plain.txt3
-rw-r--r--test/prism/fixtures/whitequark/ternary.txt1
-rw-r--r--test/prism/fixtures/whitequark/ternary_ambiguous_symbol.txt1
-rw-r--r--test/prism/fixtures/whitequark/trailing_forward_arg.txt1
-rw-r--r--test/prism/fixtures/whitequark/true.txt1
-rw-r--r--test/prism/fixtures/whitequark/unary_num_pow_precedence.txt5
-rw-r--r--test/prism/fixtures/whitequark/undef.txt1
-rw-r--r--test/prism/fixtures/whitequark/unless.txt3
-rw-r--r--test/prism/fixtures/whitequark/unless_else.txt3
-rw-r--r--test/prism/fixtures/whitequark/unless_mod.txt1
-rw-r--r--test/prism/fixtures/whitequark/until.txt3
-rw-r--r--test/prism/fixtures/whitequark/until_mod.txt1
-rw-r--r--test/prism/fixtures/whitequark/until_post.txt1
-rw-r--r--test/prism/fixtures/whitequark/var_and_asgn.txt1
-rw-r--r--test/prism/fixtures/whitequark/var_op_asgn.txt7
-rw-r--r--test/prism/fixtures/whitequark/var_op_asgn_cmd.txt1
-rw-r--r--test/prism/fixtures/whitequark/var_or_asgn.txt1
-rw-r--r--test/prism/fixtures/whitequark/when_multi.txt1
-rw-r--r--test/prism/fixtures/whitequark/when_splat.txt1
-rw-r--r--test/prism/fixtures/whitequark/when_then.txt1
-rw-r--r--test/prism/fixtures/whitequark/while.txt3
-rw-r--r--test/prism/fixtures/whitequark/while_mod.txt1
-rw-r--r--test/prism/fixtures/whitequark/while_post.txt1
-rw-r--r--test/prism/fixtures/whitequark/xstring_interp.txt1
-rw-r--r--test/prism/fixtures/whitequark/xstring_plain.txt1
-rw-r--r--test/prism/fixtures/whitequark/yield.txt7
-rw-r--r--test/prism/fixtures/whitequark/zsuper.txt1
-rw-r--r--test/prism/fixtures/xstring.txt7
-rw-r--r--test/prism/fixtures/yield.txt7
-rw-r--r--test/prism/fuzzer_test.rb64
-rw-r--r--test/prism/heredoc_dedent_test.rb27
-rw-r--r--test/prism/library_symbols_test.rb103
-rw-r--r--test/prism/locals_test.rb116
-rw-r--r--test/prism/location_test.rb915
-rw-r--r--test/prism/magic_comment_test.rb37
-rw-r--r--test/prism/memsize_test.rb17
-rw-r--r--test/prism/newline_test.rb93
-rw-r--r--test/prism/parameters_signature_test.rb91
-rw-r--r--test/prism/parse_comments_test.rb21
-rw-r--r--test/prism/parse_test.rb283
-rw-r--r--test/prism/pattern_test.rb132
-rw-r--r--test/prism/regexp_test.rb263
-rw-r--r--test/prism/ripper_compat_test.rb19
-rw-r--r--test/prism/ruby_api_test.rb156
-rw-r--r--test/prism/snapshots/alias.txt193
-rw-r--r--test/prism/snapshots/arithmetic.txt252
-rw-r--r--test/prism/snapshots/arrays.txt2268
-rw-r--r--test/prism/snapshots/begin_ensure.txt253
-rw-r--r--test/prism/snapshots/begin_rescue.txt699
-rw-r--r--test/prism/snapshots/blocks.txt777
-rw-r--r--test/prism/snapshots/boolean_operators.txt54
-rw-r--r--test/prism/snapshots/booleans.txt7
-rw-r--r--test/prism/snapshots/break.txt221
-rw-r--r--test/prism/snapshots/case.txt358
-rw-r--r--test/prism/snapshots/classes.txt358
-rw-r--r--test/prism/snapshots/command_method_call.txt718
-rw-r--r--test/prism/snapshots/comments.txt145
-rw-r--r--test/prism/snapshots/constants.txt1237
-rw-r--r--test/prism/snapshots/dash_heredocs.txt254
-rw-r--r--test/prism/snapshots/defined.txt84
-rw-r--r--test/prism/snapshots/dos_endings.txt108
-rw-r--r--test/prism/snapshots/embdoc_no_newline_at_end.txt5
-rw-r--r--test/prism/snapshots/endless_methods.txt106
-rw-r--r--test/prism/snapshots/endless_range_in_conditional.txt49
-rw-r--r--test/prism/snapshots/for.txt176
-rw-r--r--test/prism/snapshots/global_variables.txt191
-rw-r--r--test/prism/snapshots/hashes.txt366
-rw-r--r--test/prism/snapshots/heredoc_with_comment.txt21
-rw-r--r--test/prism/snapshots/heredoc_with_escaped_newline_at_start.txt67
-rw-r--r--test/prism/snapshots/heredoc_with_trailing_newline.txt11
-rw-r--r--test/prism/snapshots/heredocs_leading_whitespace.txt49
-rw-r--r--test/prism/snapshots/heredocs_nested.txt89
-rw-r--r--test/prism/snapshots/heredocs_with_ignored_newlines.txt63
-rw-r--r--test/prism/snapshots/heredocs_with_ignored_newlines_and_non_empty.txt11
-rw-r--r--test/prism/snapshots/if.txt454
-rw-r--r--test/prism/snapshots/indented_file_end.txt19
-rw-r--r--test/prism/snapshots/integer_operations.txt569
-rw-r--r--test/prism/snapshots/keyword_method_names.txt180
-rw-r--r--test/prism/snapshots/keywords.txt12
-rw-r--r--test/prism/snapshots/lambda.txt200
-rw-r--r--test/prism/snapshots/method_calls.txt2345
-rw-r--r--test/prism/snapshots/methods.txt2072
-rw-r--r--test/prism/snapshots/modules.txt180
-rw-r--r--test/prism/snapshots/newline_terminated.txt107
-rw-r--r--test/prism/snapshots/next.txt132
-rw-r--r--test/prism/snapshots/nils.txt32
-rw-r--r--test/prism/snapshots/non_alphanumeric_methods.txt536
-rw-r--r--test/prism/snapshots/not.txt351
-rw-r--r--test/prism/snapshots/numbers.txt108
-rw-r--r--test/prism/snapshots/patterns.txt4761
-rw-r--r--test/prism/snapshots/procs.txt383
-rw-r--r--test/prism/snapshots/range_begin_open_exclusive.txt12
-rw-r--r--test/prism/snapshots/range_begin_open_inclusive.txt12
-rw-r--r--test/prism/snapshots/range_end_open_exclusive.txt12
-rw-r--r--test/prism/snapshots/range_end_open_inclusive.txt12
-rw-r--r--test/prism/snapshots/ranges.txt492
-rw-r--r--test/prism/snapshots/regex.txt371
-rw-r--r--test/prism/snapshots/rescue.txt390
-rw-r--r--test/prism/snapshots/return.txt138
-rw-r--r--test/prism/snapshots/seattlerb/BEGIN.txt14
-rw-r--r--test/prism/snapshots/seattlerb/TestRubyParserShared.txt357
-rw-r--r--test/prism/snapshots/seattlerb/__ENCODING__.txt6
-rw-r--r--test/prism/snapshots/seattlerb/alias_gvar_backref.txt13
-rw-r--r--test/prism/snapshots/seattlerb/alias_resword.txt21
-rw-r--r--test/prism/snapshots/seattlerb/and_multi.txt26
-rw-r--r--test/prism/snapshots/seattlerb/aref_args_assocs.txt21
-rw-r--r--test/prism/snapshots/seattlerb/aref_args_lit_assocs.txt23
-rw-r--r--test/prism/snapshots/seattlerb/args_kw_block.txt37
-rw-r--r--test/prism/snapshots/seattlerb/array_line_breaks.txt24
-rw-r--r--test/prism/snapshots/seattlerb/array_lits_trailing_calls.txt35
-rw-r--r--test/prism/snapshots/seattlerb/assoc__bare.txt31
-rw-r--r--test/prism/snapshots/seattlerb/assoc_label.txt33
-rw-r--r--test/prism/snapshots/seattlerb/attr_asgn_colon_id.txt22
-rw-r--r--test/prism/snapshots/seattlerb/attrasgn_array_arg.txt39
-rw-r--r--test/prism/snapshots/seattlerb/attrasgn_array_lhs.txt79
-rw-r--r--test/prism/snapshots/seattlerb/attrasgn_primary_dot_constant.txt30
-rw-r--r--test/prism/snapshots/seattlerb/backticks_interpolation_line.txt38
-rw-r--r--test/prism/snapshots/seattlerb/bang_eq.txt22
-rw-r--r--test/prism/snapshots/seattlerb/bdot2.txt37
-rw-r--r--test/prism/snapshots/seattlerb/bdot3.txt37
-rw-r--r--test/prism/snapshots/seattlerb/begin_ensure_no_bodies.txt16
-rw-r--r--test/prism/snapshots/seattlerb/begin_rescue_else_ensure_bodies.txt43
-rw-r--r--test/prism/snapshots/seattlerb/begin_rescue_else_ensure_no_bodies.txt27
-rw-r--r--test/prism/snapshots/seattlerb/begin_rescue_ensure_no_bodies.txt23
-rw-r--r--test/prism/snapshots/seattlerb/block_arg__bare.txt31
-rw-r--r--test/prism/snapshots/seattlerb/block_arg_kwsplat.txt39
-rw-r--r--test/prism/snapshots/seattlerb/block_arg_opt_arg_block.txt50
-rw-r--r--test/prism/snapshots/seattlerb/block_arg_opt_splat.txt48
-rw-r--r--test/prism/snapshots/seattlerb/block_arg_opt_splat_arg_block_omfg.txt54
-rw-r--r--test/prism/snapshots/seattlerb/block_arg_optional.txt42
-rw-r--r--test/prism/snapshots/seattlerb/block_arg_scope.txt39
-rw-r--r--test/prism/snapshots/seattlerb/block_arg_scope2.txt41
-rw-r--r--test/prism/snapshots/seattlerb/block_arg_splat_arg.txt43
-rw-r--r--test/prism/snapshots/seattlerb/block_args_kwargs.txt44
-rw-r--r--test/prism/snapshots/seattlerb/block_args_no_kwargs.txt38
-rw-r--r--test/prism/snapshots/seattlerb/block_args_opt1.txt57
-rw-r--r--test/prism/snapshots/seattlerb/block_args_opt2.txt49
-rw-r--r--test/prism/snapshots/seattlerb/block_args_opt2_2.txt67
-rw-r--r--test/prism/snapshots/seattlerb/block_args_opt3.txt74
-rw-r--r--test/prism/snapshots/seattlerb/block_break.txt56
-rw-r--r--test/prism/snapshots/seattlerb/block_call_defn_call_block_call.txt81
-rw-r--r--test/prism/snapshots/seattlerb/block_call_dot_op2_brace_block.txt101
-rw-r--r--test/prism/snapshots/seattlerb/block_call_dot_op2_cmd_args_do_block.txt114
-rw-r--r--test/prism/snapshots/seattlerb/block_call_operation_colon.txt55
-rw-r--r--test/prism/snapshots/seattlerb/block_call_operation_dot.txt55
-rw-r--r--test/prism/snapshots/seattlerb/block_call_paren_call_block_call.txt61
-rw-r--r--test/prism/snapshots/seattlerb/block_command_operation_colon.txt50
-rw-r--r--test/prism/snapshots/seattlerb/block_command_operation_dot.txt50
-rw-r--r--test/prism/snapshots/seattlerb/block_decomp_anon_splat_arg.txt46
-rw-r--r--test/prism/snapshots/seattlerb/block_decomp_arg_splat.txt46
-rw-r--r--test/prism/snapshots/seattlerb/block_decomp_arg_splat_arg.txt50
-rw-r--r--test/prism/snapshots/seattlerb/block_decomp_splat.txt46
-rw-r--r--test/prism/snapshots/seattlerb/block_kw.txt41
-rw-r--r--test/prism/snapshots/seattlerb/block_kw__required.txt38
-rw-r--r--test/prism/snapshots/seattlerb/block_kwarg_lvar.txt50
-rw-r--r--test/prism/snapshots/seattlerb/block_kwarg_lvar_multiple.txt60
-rw-r--r--test/prism/snapshots/seattlerb/block_next.txt56
-rw-r--r--test/prism/snapshots/seattlerb/block_opt_arg.txt44
-rw-r--r--test/prism/snapshots/seattlerb/block_opt_splat.txt46
-rw-r--r--test/prism/snapshots/seattlerb/block_opt_splat_arg_block_omfg.txt52
-rw-r--r--test/prism/snapshots/seattlerb/block_optarg.txt46
-rw-r--r--test/prism/snapshots/seattlerb/block_paren_splat.txt48
-rw-r--r--test/prism/snapshots/seattlerb/block_reg_optarg.txt48
-rw-r--r--test/prism/snapshots/seattlerb/block_return.txt56
-rw-r--r--test/prism/snapshots/seattlerb/block_scope.txt29
-rw-r--r--test/prism/snapshots/seattlerb/block_splat_reg.txt41
-rw-r--r--test/prism/snapshots/seattlerb/bug169.txt29
-rw-r--r--test/prism/snapshots/seattlerb/bug179.txt28
-rw-r--r--test/prism/snapshots/seattlerb/bug190.txt11
-rw-r--r--test/prism/snapshots/seattlerb/bug191.txt87
-rw-r--r--test/prism/snapshots/seattlerb/bug202.txt20
-rw-r--r--test/prism/snapshots/seattlerb/bug236.txt70
-rw-r--r--test/prism/snapshots/seattlerb/bug290.txt24
-rw-r--r--test/prism/snapshots/seattlerb/bug_187.txt61
-rw-r--r--test/prism/snapshots/seattlerb/bug_215.txt14
-rw-r--r--test/prism/snapshots/seattlerb/bug_249.txt88
-rw-r--r--test/prism/snapshots/seattlerb/bug_and.txt21
-rw-r--r--test/prism/snapshots/seattlerb/bug_args__19.txt57
-rw-r--r--test/prism/snapshots/seattlerb/bug_args_masgn.txt47
-rw-r--r--test/prism/snapshots/seattlerb/bug_args_masgn2.txt55
-rw-r--r--test/prism/snapshots/seattlerb/bug_args_masgn_outer_parens__19.txt53
-rw-r--r--test/prism/snapshots/seattlerb/bug_call_arglist_parens.txt106
-rw-r--r--test/prism/snapshots/seattlerb/bug_case_when_regexp.txt27
-rw-r--r--test/prism/snapshots/seattlerb/bug_comma.txt41
-rw-r--r--test/prism/snapshots/seattlerb/bug_cond_pct.txt21
-rw-r--r--test/prism/snapshots/seattlerb/bug_hash_args.txt38
-rw-r--r--test/prism/snapshots/seattlerb/bug_hash_args_trailing_comma.txt38
-rw-r--r--test/prism/snapshots/seattlerb/bug_hash_interp_array.txt26
-rw-r--r--test/prism/snapshots/seattlerb/bug_masgn_right.txt47
-rw-r--r--test/prism/snapshots/seattlerb/bug_not_parens.txt25
-rw-r--r--test/prism/snapshots/seattlerb/bug_op_asgn_rescue.txt26
-rw-r--r--test/prism/snapshots/seattlerb/call_and.txt22
-rw-r--r--test/prism/snapshots/seattlerb/call_arg_assoc.txt31
-rw-r--r--test/prism/snapshots/seattlerb/call_arg_assoc_kwsplat.txt40
-rw-r--r--test/prism/snapshots/seattlerb/call_arg_kwsplat.txt36
-rw-r--r--test/prism/snapshots/seattlerb/call_args_assoc_quoted.txt103
-rw-r--r--test/prism/snapshots/seattlerb/call_args_assoc_trailing_comma.txt31
-rw-r--r--test/prism/snapshots/seattlerb/call_args_command.txt53
-rw-r--r--test/prism/snapshots/seattlerb/call_array_arg.txt37
-rw-r--r--test/prism/snapshots/seattlerb/call_array_block_call.txt41
-rw-r--r--test/prism/snapshots/seattlerb/call_array_lambda_block_call.txt43
-rw-r--r--test/prism/snapshots/seattlerb/call_array_lit_inline_hash.txt44
-rw-r--r--test/prism/snapshots/seattlerb/call_assoc.txt29
-rw-r--r--test/prism/snapshots/seattlerb/call_assoc_new.txt33
-rw-r--r--test/prism/snapshots/seattlerb/call_assoc_new_if_multiline.txt56
-rw-r--r--test/prism/snapshots/seattlerb/call_assoc_trailing_comma.txt29
-rw-r--r--test/prism/snapshots/seattlerb/call_bang_command_call.txt40
-rw-r--r--test/prism/snapshots/seattlerb/call_bang_squiggle.txt22
-rw-r--r--test/prism/snapshots/seattlerb/call_begin_call_block_call.txt54
-rw-r--r--test/prism/snapshots/seattlerb/call_block_arg_named.txt28
-rw-r--r--test/prism/snapshots/seattlerb/call_carat.txt22
-rw-r--r--test/prism/snapshots/seattlerb/call_colon2.txt17
-rw-r--r--test/prism/snapshots/seattlerb/call_colon_parens.txt17
-rw-r--r--test/prism/snapshots/seattlerb/call_div.txt22
-rw-r--r--test/prism/snapshots/seattlerb/call_dot_parens.txt17
-rw-r--r--test/prism/snapshots/seattlerb/call_env.txt25
-rw-r--r--test/prism/snapshots/seattlerb/call_eq3.txt22
-rw-r--r--test/prism/snapshots/seattlerb/call_gt.txt22
-rw-r--r--test/prism/snapshots/seattlerb/call_kwsplat.txt26
-rw-r--r--test/prism/snapshots/seattlerb/call_leading_dots.txt35
-rw-r--r--test/prism/snapshots/seattlerb/call_leading_dots_comment.txt35
-rw-r--r--test/prism/snapshots/seattlerb/call_lt.txt22
-rw-r--r--test/prism/snapshots/seattlerb/call_lte.txt22
-rw-r--r--test/prism/snapshots/seattlerb/call_not.txt17
-rw-r--r--test/prism/snapshots/seattlerb/call_pipe.txt22
-rw-r--r--test/prism/snapshots/seattlerb/call_rshift.txt22
-rw-r--r--test/prism/snapshots/seattlerb/call_self_brackets.txt21
-rw-r--r--test/prism/snapshots/seattlerb/call_spaceship.txt22
-rw-r--r--test/prism/snapshots/seattlerb/call_stabby_do_end_with_block.txt41
-rw-r--r--test/prism/snapshots/seattlerb/call_stabby_with_braces_block.txt41
-rw-r--r--test/prism/snapshots/seattlerb/call_star.txt22
-rw-r--r--test/prism/snapshots/seattlerb/call_star2.txt22
-rw-r--r--test/prism/snapshots/seattlerb/call_trailing_comma.txt20
-rw-r--r--test/prism/snapshots/seattlerb/call_trailing_dots.txt35
-rw-r--r--test/prism/snapshots/seattlerb/call_unary_bang.txt17
-rw-r--r--test/prism/snapshots/seattlerb/case_in.txt940
-rw-r--r--test/prism/snapshots/seattlerb/case_in_31.txt49
-rw-r--r--test/prism/snapshots/seattlerb/case_in_37.txt58
-rw-r--r--test/prism/snapshots/seattlerb/case_in_42.txt44
-rw-r--r--test/prism/snapshots/seattlerb/case_in_42_2.txt40
-rw-r--r--test/prism/snapshots/seattlerb/case_in_47.txt52
-rw-r--r--test/prism/snapshots/seattlerb/case_in_67.txt32
-rw-r--r--test/prism/snapshots/seattlerb/case_in_86.txt52
-rw-r--r--test/prism/snapshots/seattlerb/case_in_86_2.txt52
-rw-r--r--test/prism/snapshots/seattlerb/case_in_array_pat_const.txt42
-rw-r--r--test/prism/snapshots/seattlerb/case_in_array_pat_const2.txt48
-rw-r--r--test/prism/snapshots/seattlerb/case_in_array_pat_paren_assign.txt48
-rw-r--r--test/prism/snapshots/seattlerb/case_in_const.txt28
-rw-r--r--test/prism/snapshots/seattlerb/case_in_else.txt40
-rw-r--r--test/prism/snapshots/seattlerb/case_in_find.txt47
-rw-r--r--test/prism/snapshots/seattlerb/case_in_find_array.txt44
-rw-r--r--test/prism/snapshots/seattlerb/case_in_hash_pat.txt68
-rw-r--r--test/prism/snapshots/seattlerb/case_in_hash_pat_assign.txt81
-rw-r--r--test/prism/snapshots/seattlerb/case_in_hash_pat_paren_assign.txt50
-rw-r--r--test/prism/snapshots/seattlerb/case_in_hash_pat_paren_true.txt47
-rw-r--r--test/prism/snapshots/seattlerb/case_in_hash_pat_rest.txt55
-rw-r--r--test/prism/snapshots/seattlerb/case_in_hash_pat_rest_solo.txt42
-rw-r--r--test/prism/snapshots/seattlerb/case_in_if_unless_post_mod.txt67
-rw-r--r--test/prism/snapshots/seattlerb/case_in_multiple.txt59
-rw-r--r--test/prism/snapshots/seattlerb/case_in_or.txt38
-rw-r--r--test/prism/snapshots/seattlerb/class_comments.txt32
-rw-r--r--test/prism/snapshots/seattlerb/cond_unary_minus.txt14
-rw-r--r--test/prism/snapshots/seattlerb/const_2_op_asgn_or2.txt23
-rw-r--r--test/prism/snapshots/seattlerb/const_3_op_asgn_or.txt17
-rw-r--r--test/prism/snapshots/seattlerb/const_op_asgn_and1.txt18
-rw-r--r--test/prism/snapshots/seattlerb/const_op_asgn_and2.txt17
-rw-r--r--test/prism/snapshots/seattlerb/const_op_asgn_or.txt19
-rw-r--r--test/prism/snapshots/seattlerb/dasgn_icky2.txt62
-rw-r--r--test/prism/snapshots/seattlerb/defined_eh_parens.txt12
-rw-r--r--test/prism/snapshots/seattlerb/defn_arg_asplat_arg.txt35
-rw-r--r--test/prism/snapshots/seattlerb/defn_arg_forward_args.txt49
-rw-r--r--test/prism/snapshots/seattlerb/defn_args_forward_args.txt59
-rw-r--r--test/prism/snapshots/seattlerb/defn_comments.txt19
-rw-r--r--test/prism/snapshots/seattlerb/defn_endless_command.txt36
-rw-r--r--test/prism/snapshots/seattlerb/defn_endless_command_rescue.txt42
-rw-r--r--test/prism/snapshots/seattlerb/defn_forward_args.txt44
-rw-r--r--test/prism/snapshots/seattlerb/defn_forward_args__no_parens.txt44
-rw-r--r--test/prism/snapshots/seattlerb/defn_kwarg_env.txt55
-rw-r--r--test/prism/snapshots/seattlerb/defn_kwarg_kwarg.txt41
-rw-r--r--test/prism/snapshots/seattlerb/defn_kwarg_kwsplat.txt37
-rw-r--r--test/prism/snapshots/seattlerb/defn_kwarg_kwsplat_anon.txt37
-rw-r--r--test/prism/snapshots/seattlerb/defn_kwarg_lvar.txt42
-rw-r--r--test/prism/snapshots/seattlerb/defn_kwarg_no_parens.txt33
-rw-r--r--test/prism/snapshots/seattlerb/defn_kwarg_val.txt35
-rw-r--r--test/prism/snapshots/seattlerb/defn_no_kwargs.txt30
-rw-r--r--test/prism/snapshots/seattlerb/defn_oneliner.txt47
-rw-r--r--test/prism/snapshots/seattlerb/defn_oneliner_eq2.txt46
-rw-r--r--test/prism/snapshots/seattlerb/defn_oneliner_noargs.txt31
-rw-r--r--test/prism/snapshots/seattlerb/defn_oneliner_noargs_parentheses.txt31
-rw-r--r--test/prism/snapshots/seattlerb/defn_oneliner_rescue.txt158
-rw-r--r--test/prism/snapshots/seattlerb/defn_opt_last_arg.txt33
-rw-r--r--test/prism/snapshots/seattlerb/defn_opt_reg.txt35
-rw-r--r--test/prism/snapshots/seattlerb/defn_opt_splat_arg.txt40
-rw-r--r--test/prism/snapshots/seattlerb/defn_powarg.txt31
-rw-r--r--test/prism/snapshots/seattlerb/defn_reg_opt_reg.txt42
-rw-r--r--test/prism/snapshots/seattlerb/defn_splat_arg.txt33
-rw-r--r--test/prism/snapshots/seattlerb/defn_unary_not.txt22
-rw-r--r--test/prism/snapshots/seattlerb/defns_reserved.txt20
-rw-r--r--test/prism/snapshots/seattlerb/defs_as_arg_with_do_block_inside.txt62
-rw-r--r--test/prism/snapshots/seattlerb/defs_comments.txt20
-rw-r--r--test/prism/snapshots/seattlerb/defs_endless_command.txt46
-rw-r--r--test/prism/snapshots/seattlerb/defs_endless_command_rescue.txt52
-rw-r--r--test/prism/snapshots/seattlerb/defs_kwarg.txt34
-rw-r--r--test/prism/snapshots/seattlerb/defs_oneliner.txt48
-rw-r--r--test/prism/snapshots/seattlerb/defs_oneliner_eq2.txt47
-rw-r--r--test/prism/snapshots/seattlerb/defs_oneliner_rescue.txt161
-rw-r--r--test/prism/snapshots/seattlerb/difficult0_.txt72
-rw-r--r--test/prism/snapshots/seattlerb/difficult1_line_numbers.txt253
-rw-r--r--test/prism/snapshots/seattlerb/difficult1_line_numbers2.txt76
-rw-r--r--test/prism/snapshots/seattlerb/difficult2_.txt71
-rw-r--r--test/prism/snapshots/seattlerb/difficult3_.txt50
-rw-r--r--test/prism/snapshots/seattlerb/difficult3_2.txt41
-rw-r--r--test/prism/snapshots/seattlerb/difficult3_3.txt45
-rw-r--r--test/prism/snapshots/seattlerb/difficult3_4.txt38
-rw-r--r--test/prism/snapshots/seattlerb/difficult3_5.txt50
-rw-r--r--test/prism/snapshots/seattlerb/difficult3__10.txt50
-rw-r--r--test/prism/snapshots/seattlerb/difficult3__11.txt46
-rw-r--r--test/prism/snapshots/seattlerb/difficult3__12.txt48
-rw-r--r--test/prism/snapshots/seattlerb/difficult3__6.txt52
-rw-r--r--test/prism/snapshots/seattlerb/difficult3__7.txt48
-rw-r--r--test/prism/snapshots/seattlerb/difficult3__8.txt50
-rw-r--r--test/prism/snapshots/seattlerb/difficult3__9.txt48
-rw-r--r--test/prism/snapshots/seattlerb/difficult4__leading_dots.txt25
-rw-r--r--test/prism/snapshots/seattlerb/difficult4__leading_dots2.txt14
-rw-r--r--test/prism/snapshots/seattlerb/difficult6_.txt60
-rw-r--r--test/prism/snapshots/seattlerb/difficult6__7.txt55
-rw-r--r--test/prism/snapshots/seattlerb/difficult6__8.txt55
-rw-r--r--test/prism/snapshots/seattlerb/difficult7_.txt94
-rw-r--r--test/prism/snapshots/seattlerb/do_bug.txt62
-rw-r--r--test/prism/snapshots/seattlerb/do_lambda.txt18
-rw-r--r--test/prism/snapshots/seattlerb/dot2_nil__26.txt20
-rw-r--r--test/prism/snapshots/seattlerb/dot3_nil__26.txt20
-rw-r--r--test/prism/snapshots/seattlerb/dstr_evstr.txt37
-rw-r--r--test/prism/snapshots/seattlerb/dstr_evstr_empty_end.txt25
-rw-r--r--test/prism/snapshots/seattlerb/dstr_lex_state.txt34
-rw-r--r--test/prism/snapshots/seattlerb/dstr_str.txt27
-rw-r--r--test/prism/snapshots/seattlerb/dsym_esc_to_sym.txt11
-rw-r--r--test/prism/snapshots/seattlerb/dsym_to_sym.txt37
-rw-r--r--test/prism/snapshots/seattlerb/eq_begin_line_numbers.txt9
-rw-r--r--test/prism/snapshots/seattlerb/eq_begin_why_wont_people_use_their_spacebar.txt49
-rw-r--r--test/prism/snapshots/seattlerb/evstr_evstr.txt41
-rw-r--r--test/prism/snapshots/seattlerb/evstr_str.txt31
-rw-r--r--test/prism/snapshots/seattlerb/expr_not_bang.txt38
-rw-r--r--test/prism/snapshots/seattlerb/f_kw.txt33
-rw-r--r--test/prism/snapshots/seattlerb/f_kw__required.txt30
-rw-r--r--test/prism/snapshots/seattlerb/flip2_env_lvar.txt37
-rw-r--r--test/prism/snapshots/seattlerb/float_with_if_modifier.txt16
-rw-r--r--test/prism/snapshots/seattlerb/heredoc__backslash_dos_format.txt17
-rw-r--r--test/prism/snapshots/seattlerb/heredoc_backslash_nl.txt17
-rw-r--r--test/prism/snapshots/seattlerb/heredoc_bad_hex_escape.txt17
-rw-r--r--test/prism/snapshots/seattlerb/heredoc_bad_oct_escape.txt17
-rw-r--r--test/prism/snapshots/seattlerb/heredoc_comma_arg.txt27
-rw-r--r--test/prism/snapshots/seattlerb/heredoc_lineno.txt25
-rw-r--r--test/prism/snapshots/seattlerb/heredoc_nested.txt40
-rw-r--r--test/prism/snapshots/seattlerb/heredoc_squiggly.txt33
-rw-r--r--test/prism/snapshots/seattlerb/heredoc_squiggly_blank_line_plus_interpolation.txt66
-rw-r--r--test/prism/snapshots/seattlerb/heredoc_squiggly_blank_lines.txt33
-rw-r--r--test/prism/snapshots/seattlerb/heredoc_squiggly_empty.txt11
-rw-r--r--test/prism/snapshots/seattlerb/heredoc_squiggly_interp.txt47
-rw-r--r--test/prism/snapshots/seattlerb/heredoc_squiggly_no_indent.txt11
-rw-r--r--test/prism/snapshots/seattlerb/heredoc_squiggly_tabs.txt27
-rw-r--r--test/prism/snapshots/seattlerb/heredoc_squiggly_tabs_extra.txt27
-rw-r--r--test/prism/snapshots/seattlerb/heredoc_squiggly_visually_blank_lines.txt33
-rw-r--r--test/prism/snapshots/seattlerb/heredoc_trailing_slash_continued_call.txt21
-rw-r--r--test/prism/snapshots/seattlerb/heredoc_unicode.txt11
-rw-r--r--test/prism/snapshots/seattlerb/heredoc_with_carriage_return_escapes.txt11
-rw-r--r--test/prism/snapshots/seattlerb/heredoc_with_carriage_return_escapes_windows.txt11
-rw-r--r--test/prism/snapshots/seattlerb/heredoc_with_extra_carriage_horrible_mix.txt11
-rw-r--r--test/prism/snapshots/seattlerb/heredoc_with_extra_carriage_returns.txt11
-rw-r--r--test/prism/snapshots/seattlerb/heredoc_with_extra_carriage_returns_windows.txt11
-rw-r--r--test/prism/snapshots/seattlerb/heredoc_with_interpolation_and_carriage_return_escapes.txt26
-rw-r--r--test/prism/snapshots/seattlerb/heredoc_with_interpolation_and_carriage_return_escapes_windows.txt26
-rw-r--r--test/prism/snapshots/seattlerb/heredoc_with_not_global_interpolation.txt11
-rw-r--r--test/prism/snapshots/seattlerb/heredoc_with_only_carriage_returns.txt11
-rw-r--r--test/prism/snapshots/seattlerb/heredoc_with_only_carriage_returns_windows.txt11
-rw-r--r--test/prism/snapshots/seattlerb/if_elsif.txt23
-rw-r--r--test/prism/snapshots/seattlerb/if_symbol.txt31
-rw-r--r--test/prism/snapshots/seattlerb/in_expr_no_case.txt17
-rw-r--r--test/prism/snapshots/seattlerb/index_0.txt38
-rw-r--r--test/prism/snapshots/seattlerb/index_0_opasgn.txt36
-rw-r--r--test/prism/snapshots/seattlerb/integer_with_if_modifier.txt17
-rw-r--r--test/prism/snapshots/seattlerb/interpolated_symbol_array_line_breaks.txt24
-rw-r--r--test/prism/snapshots/seattlerb/interpolated_word_array_line_breaks.txt24
-rw-r--r--test/prism/snapshots/seattlerb/iter_args_1.txt39
-rw-r--r--test/prism/snapshots/seattlerb/iter_args_10_1.txt48
-rw-r--r--test/prism/snapshots/seattlerb/iter_args_10_2.txt52
-rw-r--r--test/prism/snapshots/seattlerb/iter_args_11_1.txt50
-rw-r--r--test/prism/snapshots/seattlerb/iter_args_11_2.txt54
-rw-r--r--test/prism/snapshots/seattlerb/iter_args_2__19.txt45
-rw-r--r--test/prism/snapshots/seattlerb/iter_args_3.txt49
-rw-r--r--test/prism/snapshots/seattlerb/iter_args_4.txt43
-rw-r--r--test/prism/snapshots/seattlerb/iter_args_5.txt41
-rw-r--r--test/prism/snapshots/seattlerb/iter_args_6.txt46
-rw-r--r--test/prism/snapshots/seattlerb/iter_args_7_1.txt46
-rw-r--r--test/prism/snapshots/seattlerb/iter_args_7_2.txt50
-rw-r--r--test/prism/snapshots/seattlerb/iter_args_8_1.txt48
-rw-r--r--test/prism/snapshots/seattlerb/iter_args_8_2.txt52
-rw-r--r--test/prism/snapshots/seattlerb/iter_args_9_1.txt44
-rw-r--r--test/prism/snapshots/seattlerb/iter_args_9_2.txt48
-rw-r--r--test/prism/snapshots/seattlerb/iter_kwarg.txt41
-rw-r--r--test/prism/snapshots/seattlerb/iter_kwarg_kwsplat.txt45
-rw-r--r--test/prism/snapshots/seattlerb/label_vs_string.txt34
-rw-r--r--test/prism/snapshots/seattlerb/lambda_do_vs_brace.txt99
-rw-r--r--test/prism/snapshots/seattlerb/lasgn_arg_rescue_arg.txt19
-rw-r--r--test/prism/snapshots/seattlerb/lasgn_call_bracket_rescue_arg.txt32
-rw-r--r--test/prism/snapshots/seattlerb/lasgn_call_nobracket_rescue_arg.txt32
-rw-r--r--test/prism/snapshots/seattlerb/lasgn_command.txt36
-rw-r--r--test/prism/snapshots/seattlerb/lasgn_env.txt13
-rw-r--r--test/prism/snapshots/seattlerb/lasgn_ivar_env.txt12
-rw-r--r--test/prism/snapshots/seattlerb/lasgn_lasgn_command_call.txt32
-rw-r--r--test/prism/snapshots/seattlerb/lasgn_middle_splat.txt49
-rw-r--r--test/prism/snapshots/seattlerb/magic_encoding_comment.txt47
-rw-r--r--test/prism/snapshots/seattlerb/masgn_anon_splat_arg.txt29
-rw-r--r--test/prism/snapshots/seattlerb/masgn_arg_colon_arg.txt42
-rw-r--r--test/prism/snapshots/seattlerb/masgn_arg_ident.txt42
-rw-r--r--test/prism/snapshots/seattlerb/masgn_arg_splat_arg.txt35
-rw-r--r--test/prism/snapshots/seattlerb/masgn_colon2.txt41
-rw-r--r--test/prism/snapshots/seattlerb/masgn_colon3.txt34
-rw-r--r--test/prism/snapshots/seattlerb/masgn_command_call.txt42
-rw-r--r--test/prism/snapshots/seattlerb/masgn_double_paren.txt35
-rw-r--r--test/prism/snapshots/seattlerb/masgn_lhs_splat.txt30
-rw-r--r--test/prism/snapshots/seattlerb/masgn_paren.txt39
-rw-r--r--test/prism/snapshots/seattlerb/masgn_splat_arg.txt32
-rw-r--r--test/prism/snapshots/seattlerb/masgn_splat_arg_arg.txt35
-rw-r--r--test/prism/snapshots/seattlerb/masgn_star.txt18
-rw-r--r--test/prism/snapshots/seattlerb/masgn_var_star_var.txt32
-rw-r--r--test/prism/snapshots/seattlerb/messy_op_asgn_lineno.txt60
-rw-r--r--test/prism/snapshots/seattlerb/method_call_assoc_trailing_comma.txt39
-rw-r--r--test/prism/snapshots/seattlerb/method_call_trailing_comma.txt30
-rw-r--r--test/prism/snapshots/seattlerb/mlhs_back_anonsplat.txt35
-rw-r--r--test/prism/snapshots/seattlerb/mlhs_back_splat.txt38
-rw-r--r--test/prism/snapshots/seattlerb/mlhs_front_anonsplat.txt35
-rw-r--r--test/prism/snapshots/seattlerb/mlhs_front_splat.txt38
-rw-r--r--test/prism/snapshots/seattlerb/mlhs_keyword.txt30
-rw-r--r--test/prism/snapshots/seattlerb/mlhs_mid_anonsplat.txt44
-rw-r--r--test/prism/snapshots/seattlerb/mlhs_mid_splat.txt47
-rw-r--r--test/prism/snapshots/seattlerb/mlhs_rescue.txt35
-rw-r--r--test/prism/snapshots/seattlerb/module_comments.txt30
-rw-r--r--test/prism/snapshots/seattlerb/multiline_hash_declaration.txt95
-rw-r--r--test/prism/snapshots/seattlerb/non_interpolated_symbol_array_line_breaks.txt24
-rw-r--r--test/prism/snapshots/seattlerb/non_interpolated_word_array_line_breaks.txt24
-rw-r--r--test/prism/snapshots/seattlerb/op_asgn_command_call.txt36
-rw-r--r--test/prism/snapshots/seattlerb/op_asgn_dot_ident_command_call.txt31
-rw-r--r--test/prism/snapshots/seattlerb/op_asgn_index_command_call.txt51
-rw-r--r--test/prism/snapshots/seattlerb/op_asgn_primary_colon_const_command_call.txt41
-rw-r--r--test/prism/snapshots/seattlerb/op_asgn_primary_colon_identifier1.txt19
-rw-r--r--test/prism/snapshots/seattlerb/op_asgn_primary_colon_identifier_command_call.txt40
-rw-r--r--test/prism/snapshots/seattlerb/op_asgn_val_dot_ident_command_call.txt39
-rw-r--r--test/prism/snapshots/seattlerb/parse_def_special_name.txt19
-rw-r--r--test/prism/snapshots/seattlerb/parse_if_not_canonical.txt62
-rw-r--r--test/prism/snapshots/seattlerb/parse_if_not_noncanonical.txt62
-rw-r--r--test/prism/snapshots/seattlerb/parse_line_block.txt29
-rw-r--r--test/prism/snapshots/seattlerb/parse_line_block_inline_comment.txt35
-rw-r--r--test/prism/snapshots/seattlerb/parse_line_block_inline_comment_leading_newlines.txt35
-rw-r--r--test/prism/snapshots/seattlerb/parse_line_block_inline_multiline_comment.txt35
-rw-r--r--test/prism/snapshots/seattlerb/parse_line_call_ivar_arg_no_parens_line_break.txt20
-rw-r--r--test/prism/snapshots/seattlerb/parse_line_call_ivar_line_break_paren.txt20
-rw-r--r--test/prism/snapshots/seattlerb/parse_line_call_no_args.txt60
-rw-r--r--test/prism/snapshots/seattlerb/parse_line_defn_complex.txt65
-rw-r--r--test/prism/snapshots/seattlerb/parse_line_defn_no_parens.txt33
-rw-r--r--test/prism/snapshots/seattlerb/parse_line_defn_no_parens_args.txt29
-rw-r--r--test/prism/snapshots/seattlerb/parse_line_dot2.txt49
-rw-r--r--test/prism/snapshots/seattlerb/parse_line_dot2_open.txt37
-rw-r--r--test/prism/snapshots/seattlerb/parse_line_dot3.txt49
-rw-r--r--test/prism/snapshots/seattlerb/parse_line_dot3_open.txt37
-rw-r--r--test/prism/snapshots/seattlerb/parse_line_dstr_escaped_newline.txt20
-rw-r--r--test/prism/snapshots/seattlerb/parse_line_dstr_soft_newline.txt20
-rw-r--r--test/prism/snapshots/seattlerb/parse_line_evstr_after_break.txt35
-rw-r--r--test/prism/snapshots/seattlerb/parse_line_hash_lit.txt21
-rw-r--r--test/prism/snapshots/seattlerb/parse_line_heredoc.txt43
-rw-r--r--test/prism/snapshots/seattlerb/parse_line_heredoc_evstr.txt37
-rw-r--r--test/prism/snapshots/seattlerb/parse_line_heredoc_hardnewline.txt22
-rw-r--r--test/prism/snapshots/seattlerb/parse_line_heredoc_regexp_chars.txt33
-rw-r--r--test/prism/snapshots/seattlerb/parse_line_iter_call_no_parens.txt73
-rw-r--r--test/prism/snapshots/seattlerb/parse_line_iter_call_parens.txt73
-rw-r--r--test/prism/snapshots/seattlerb/parse_line_multiline_str.txt13
-rw-r--r--test/prism/snapshots/seattlerb/parse_line_multiline_str_literal_n.txt13
-rw-r--r--test/prism/snapshots/seattlerb/parse_line_newlines.txt6
-rw-r--r--test/prism/snapshots/seattlerb/parse_line_op_asgn.txt32
-rw-r--r--test/prism/snapshots/seattlerb/parse_line_postexe.txt22
-rw-r--r--test/prism/snapshots/seattlerb/parse_line_preexe.txt22
-rw-r--r--test/prism/snapshots/seattlerb/parse_line_rescue.txt62
-rw-r--r--test/prism/snapshots/seattlerb/parse_line_return.txt39
-rw-r--r--test/prism/snapshots/seattlerb/parse_line_str_with_newline_escape.txt25
-rw-r--r--test/prism/snapshots/seattlerb/parse_line_to_ary.txt39
-rw-r--r--test/prism/snapshots/seattlerb/parse_line_trailing_newlines.txt25
-rw-r--r--test/prism/snapshots/seattlerb/parse_opt_call_args_assocs_comma.txt31
-rw-r--r--test/prism/snapshots/seattlerb/parse_opt_call_args_lit_comma.txt22
-rw-r--r--test/prism/snapshots/seattlerb/parse_pattern_019.txt30
-rw-r--r--test/prism/snapshots/seattlerb/parse_pattern_044.txt38
-rw-r--r--test/prism/snapshots/seattlerb/parse_pattern_051.txt42
-rw-r--r--test/prism/snapshots/seattlerb/parse_pattern_058.txt67
-rw-r--r--test/prism/snapshots/seattlerb/parse_pattern_058_2.txt61
-rw-r--r--test/prism/snapshots/seattlerb/parse_pattern_069.txt46
-rw-r--r--test/prism/snapshots/seattlerb/parse_pattern_076.txt56
-rw-r--r--test/prism/snapshots/seattlerb/parse_until_not_canonical.txt49
-rw-r--r--test/prism/snapshots/seattlerb/parse_until_not_noncanonical.txt49
-rw-r--r--test/prism/snapshots/seattlerb/parse_while_not_canonical.txt49
-rw-r--r--test/prism/snapshots/seattlerb/parse_while_not_noncanonical.txt49
-rw-r--r--test/prism/snapshots/seattlerb/pctW_lineno.txt52
-rw-r--r--test/prism/snapshots/seattlerb/pct_Q_backslash_nl.txt11
-rw-r--r--test/prism/snapshots/seattlerb/pct_nl.txt17
-rw-r--r--test/prism/snapshots/seattlerb/pct_w_heredoc_interp_nested.txt50
-rw-r--r--test/prism/snapshots/seattlerb/pipe_semicolon.txt39
-rw-r--r--test/prism/snapshots/seattlerb/pipe_space.txt37
-rw-r--r--test/prism/snapshots/seattlerb/qWords_space.txt10
-rw-r--r--test/prism/snapshots/seattlerb/qsymbols.txt28
-rw-r--r--test/prism/snapshots/seattlerb/qsymbols_empty.txt10
-rw-r--r--test/prism/snapshots/seattlerb/qsymbols_empty_space.txt10
-rw-r--r--test/prism/snapshots/seattlerb/qsymbols_interp.txt55
-rw-r--r--test/prism/snapshots/seattlerb/quoted_symbol_hash_arg.txt35
-rw-r--r--test/prism/snapshots/seattlerb/quoted_symbol_keys.txt25
-rw-r--r--test/prism/snapshots/seattlerb/qw_escape.txt11
-rw-r--r--test/prism/snapshots/seattlerb/qw_escape_term.txt11
-rw-r--r--test/prism/snapshots/seattlerb/qwords_empty.txt10
-rw-r--r--test/prism/snapshots/seattlerb/read_escape_unicode_curlies.txt11
-rw-r--r--test/prism/snapshots/seattlerb/read_escape_unicode_h4.txt11
-rw-r--r--test/prism/snapshots/seattlerb/regexp.txt35
-rw-r--r--test/prism/snapshots/seattlerb/regexp_esc_C_slash.txt11
-rw-r--r--test/prism/snapshots/seattlerb/regexp_esc_u.txt11
-rw-r--r--test/prism/snapshots/seattlerb/regexp_escape_extended.txt11
-rw-r--r--test/prism/snapshots/seattlerb/regexp_unicode_curlies.txt17
-rw-r--r--test/prism/snapshots/seattlerb/required_kwarg_no_value.txt33
-rw-r--r--test/prism/snapshots/seattlerb/rescue_do_end_ensure_result.txt59
-rw-r--r--test/prism/snapshots/seattlerb/rescue_do_end_no_raise.txt76
-rw-r--r--test/prism/snapshots/seattlerb/rescue_do_end_raised.txt53
-rw-r--r--test/prism/snapshots/seattlerb/rescue_do_end_rescued.txt80
-rw-r--r--test/prism/snapshots/seattlerb/rescue_in_block.txt48
-rw-r--r--test/prism/snapshots/seattlerb/rescue_parens.txt48
-rw-r--r--test/prism/snapshots/seattlerb/return_call_assocs.txt203
-rw-r--r--test/prism/snapshots/seattlerb/rhs_asgn.txt14
-rw-r--r--test/prism/snapshots/seattlerb/ruby21_numbers.txt24
-rw-r--r--test/prism/snapshots/seattlerb/safe_attrasgn.txt30
-rw-r--r--test/prism/snapshots/seattlerb/safe_attrasgn_constant.txt30
-rw-r--r--test/prism/snapshots/seattlerb/safe_call.txt25
-rw-r--r--test/prism/snapshots/seattlerb/safe_call_after_newline.txt25
-rw-r--r--test/prism/snapshots/seattlerb/safe_call_dot_parens.txt25
-rw-r--r--test/prism/snapshots/seattlerb/safe_call_newline.txt25
-rw-r--r--test/prism/snapshots/seattlerb/safe_call_operator.txt30
-rw-r--r--test/prism/snapshots/seattlerb/safe_call_rhs_newline.txt31
-rw-r--r--test/prism/snapshots/seattlerb/safe_calls.txt40
-rw-r--r--test/prism/snapshots/seattlerb/safe_op_asgn.txt40
-rw-r--r--test/prism/snapshots/seattlerb/safe_op_asgn2.txt34
-rw-r--r--test/prism/snapshots/seattlerb/slashy_newlines_within_string.txt57
-rw-r--r--test/prism/snapshots/seattlerb/stabby_arg_no_paren.txt28
-rw-r--r--test/prism/snapshots/seattlerb/stabby_arg_opt_splat_arg_block_omfg.txt45
-rw-r--r--test/prism/snapshots/seattlerb/stabby_block_iter_call.txt60
-rw-r--r--test/prism/snapshots/seattlerb/stabby_block_iter_call_no_target_with_arg.txt55
-rw-r--r--test/prism/snapshots/seattlerb/stabby_block_kw.txt32
-rw-r--r--test/prism/snapshots/seattlerb/stabby_block_kw__required.txt29
-rw-r--r--test/prism/snapshots/seattlerb/stabby_proc_scope.txt30
-rw-r--r--test/prism/snapshots/seattlerb/str_backslashes.txt24
-rw-r--r--test/prism/snapshots/seattlerb/str_double_double_escaped_newline.txt34
-rw-r--r--test/prism/snapshots/seattlerb/str_double_escaped_newline.txt34
-rw-r--r--test/prism/snapshots/seattlerb/str_double_newline.txt34
-rw-r--r--test/prism/snapshots/seattlerb/str_evstr.txt31
-rw-r--r--test/prism/snapshots/seattlerb/str_evstr_escape.txt37
-rw-r--r--test/prism/snapshots/seattlerb/str_heredoc_interp.txt31
-rw-r--r--test/prism/snapshots/seattlerb/str_interp_ternary_or_label.txt104
-rw-r--r--test/prism/snapshots/seattlerb/str_lit_concat_bad_encodings.txt21
-rw-r--r--test/prism/snapshots/seattlerb/str_newline_hash_line_number.txt13
-rw-r--r--test/prism/snapshots/seattlerb/str_pct_Q_nested.txt37
-rw-r--r--test/prism/snapshots/seattlerb/str_pct_nested_nested.txt39
-rw-r--r--test/prism/snapshots/seattlerb/str_pct_q.txt11
-rw-r--r--test/prism/snapshots/seattlerb/str_single_double_escaped_newline.txt34
-rw-r--r--test/prism/snapshots/seattlerb/str_single_escaped_newline.txt34
-rw-r--r--test/prism/snapshots/seattlerb/str_single_newline.txt34
-rw-r--r--test/prism/snapshots/seattlerb/str_str.txt27
-rw-r--r--test/prism/snapshots/seattlerb/str_str_str.txt33
-rw-r--r--test/prism/snapshots/seattlerb/super_arg.txt16
-rw-r--r--test/prism/snapshots/seattlerb/symbol_empty.txt11
-rw-r--r--test/prism/snapshots/seattlerb/symbol_list.txt50
-rw-r--r--test/prism/snapshots/seattlerb/symbols.txt28
-rw-r--r--test/prism/snapshots/seattlerb/symbols_empty.txt10
-rw-r--r--test/prism/snapshots/seattlerb/symbols_empty_space.txt10
-rw-r--r--test/prism/snapshots/seattlerb/symbols_interp.txt28
-rw-r--r--test/prism/snapshots/seattlerb/thingy.txt55
-rw-r--r--test/prism/snapshots/seattlerb/uminus_float.txt6
-rw-r--r--test/prism/snapshots/seattlerb/unary_minus.txt25
-rw-r--r--test/prism/snapshots/seattlerb/unary_plus.txt25
-rw-r--r--test/prism/snapshots/seattlerb/unary_plus_on_literal.txt21
-rw-r--r--test/prism/snapshots/seattlerb/unary_tilde.txt25
-rw-r--r--test/prism/snapshots/seattlerb/utf8_bom.txt20
-rw-r--r--test/prism/snapshots/seattlerb/when_splat.txt38
-rw-r--r--test/prism/snapshots/seattlerb/words_interp.txt28
-rw-r--r--test/prism/snapshots/seattlerb/yield_arg.txt15
-rw-r--r--test/prism/snapshots/seattlerb/yield_call_assocs.txt215
-rw-r--r--test/prism/snapshots/seattlerb/yield_empty_parens.txt10
-rw-r--r--test/prism/snapshots/single_quote_heredocs.txt11
-rw-r--r--test/prism/snapshots/spanning_heredoc.txt409
-rw-r--r--test/prism/snapshots/strings.txt527
-rw-r--r--test/prism/snapshots/super.txt124
-rw-r--r--test/prism/snapshots/symbols.txt456
-rw-r--r--test/prism/snapshots/ternary_operator.txt293
-rw-r--r--test/prism/snapshots/tilde_heredocs.txt381
-rw-r--r--test/prism/snapshots/undef.txt116
-rw-r--r--test/prism/snapshots/unescaping.txt34
-rw-r--r--test/prism/snapshots/unless.txt132
-rw-r--r--test/prism/snapshots/unparser/corpus/literal/alias.txt29
-rw-r--r--test/prism/snapshots/unparser/corpus/literal/assignment.txt1035
-rw-r--r--test/prism/snapshots/unparser/corpus/literal/block.txt1408
-rw-r--r--test/prism/snapshots/unparser/corpus/literal/case.txt434
-rw-r--r--test/prism/snapshots/unparser/corpus/literal/class.txt234
-rw-r--r--test/prism/snapshots/unparser/corpus/literal/control.txt139
-rw-r--r--test/prism/snapshots/unparser/corpus/literal/def.txt1201
-rw-r--r--test/prism/snapshots/unparser/corpus/literal/defined.txt53
-rw-r--r--test/prism/snapshots/unparser/corpus/literal/defs.txt369
-rw-r--r--test/prism/snapshots/unparser/corpus/literal/dstr.txt340
-rw-r--r--test/prism/snapshots/unparser/corpus/literal/empty.txt5
-rw-r--r--test/prism/snapshots/unparser/corpus/literal/empty_begin.txt9
-rw-r--r--test/prism/snapshots/unparser/corpus/literal/flipflop.txt189
-rw-r--r--test/prism/snapshots/unparser/corpus/literal/for.txt171
-rw-r--r--test/prism/snapshots/unparser/corpus/literal/hookexe.txt49
-rw-r--r--test/prism/snapshots/unparser/corpus/literal/if.txt280
-rw-r--r--test/prism/snapshots/unparser/corpus/literal/kwbegin.txt491
-rw-r--r--test/prism/snapshots/unparser/corpus/literal/lambda.txt149
-rw-r--r--test/prism/snapshots/unparser/corpus/literal/literal.txt1144
-rw-r--r--test/prism/snapshots/unparser/corpus/literal/module.txt108
-rw-r--r--test/prism/snapshots/unparser/corpus/literal/opasgn.txt489
-rw-r--r--test/prism/snapshots/unparser/corpus/literal/pattern.txt424
-rw-r--r--test/prism/snapshots/unparser/corpus/literal/pragma.txt19
-rw-r--r--test/prism/snapshots/unparser/corpus/literal/range.txt49
-rw-r--r--test/prism/snapshots/unparser/corpus/literal/rescue.txt101
-rw-r--r--test/prism/snapshots/unparser/corpus/literal/send.txt2183
-rw-r--r--test/prism/snapshots/unparser/corpus/literal/since/27.txt49
-rw-r--r--test/prism/snapshots/unparser/corpus/literal/since/30.txt83
-rw-r--r--test/prism/snapshots/unparser/corpus/literal/since/31.txt89
-rw-r--r--test/prism/snapshots/unparser/corpus/literal/since/32.txt106
-rw-r--r--test/prism/snapshots/unparser/corpus/literal/singletons.txt9
-rw-r--r--test/prism/snapshots/unparser/corpus/literal/super.txt282
-rw-r--r--test/prism/snapshots/unparser/corpus/literal/unary.txt245
-rw-r--r--test/prism/snapshots/unparser/corpus/literal/undef.txt29
-rw-r--r--test/prism/snapshots/unparser/corpus/literal/variables.txt53
-rw-r--r--test/prism/snapshots/unparser/corpus/literal/while.txt705
-rw-r--r--test/prism/snapshots/unparser/corpus/literal/yield.txt56
-rw-r--r--test/prism/snapshots/unparser/corpus/semantic/and.txt235
-rw-r--r--test/prism/snapshots/unparser/corpus/semantic/block.txt195
-rw-r--r--test/prism/snapshots/unparser/corpus/semantic/def.txt92
-rw-r--r--test/prism/snapshots/unparser/corpus/semantic/dstr.txt570
-rw-r--r--test/prism/snapshots/unparser/corpus/semantic/kwbegin.txt259
-rw-r--r--test/prism/snapshots/unparser/corpus/semantic/literal.txt94
-rw-r--r--test/prism/snapshots/unparser/corpus/semantic/send.txt162
-rw-r--r--test/prism/snapshots/unparser/corpus/semantic/undef.txt29
-rw-r--r--test/prism/snapshots/unparser/corpus/semantic/while.txt281
-rw-r--r--test/prism/snapshots/until.txt141
-rw-r--r--test/prism/snapshots/variables.txt379
-rw-r--r--test/prism/snapshots/while.txt365
-rw-r--r--test/prism/snapshots/whitequark/__ENCODING__.txt6
-rw-r--r--test/prism/snapshots/whitequark/__ENCODING___legacy_.txt6
-rw-r--r--test/prism/snapshots/whitequark/alias.txt21
-rw-r--r--test/prism/snapshots/whitequark/alias_gvar.txt21
-rw-r--r--test/prism/snapshots/whitequark/ambiuous_quoted_label_in_ternary_operator.txt60
-rw-r--r--test/prism/snapshots/whitequark/and.txt53
-rw-r--r--test/prism/snapshots/whitequark/and_asgn.txt55
-rw-r--r--test/prism/snapshots/whitequark/and_or_masgn.txt93
-rw-r--r--test/prism/snapshots/whitequark/anonymous_blockarg.txt46
-rw-r--r--test/prism/snapshots/whitequark/arg.txt55
-rw-r--r--test/prism/snapshots/whitequark/arg_duplicate_ignored.txt57
-rw-r--r--test/prism/snapshots/whitequark/arg_label.txt118
-rw-r--r--test/prism/snapshots/whitequark/arg_scope.txt34
-rw-r--r--test/prism/snapshots/whitequark/args.txt1024
-rw-r--r--test/prism/snapshots/whitequark/args_args_assocs.txt94
-rw-r--r--test/prism/snapshots/whitequark/args_args_assocs_comma.txt53
-rw-r--r--test/prism/snapshots/whitequark/args_args_comma.txt38
-rw-r--r--test/prism/snapshots/whitequark/args_args_star.txt90
-rw-r--r--test/prism/snapshots/whitequark/args_assocs.txt189
-rw-r--r--test/prism/snapshots/whitequark/args_assocs_comma.txt43
-rw-r--r--test/prism/snapshots/whitequark/args_assocs_legacy.txt189
-rw-r--r--test/prism/snapshots/whitequark/args_block_pass.txt28
-rw-r--r--test/prism/snapshots/whitequark/args_cmd.txt41
-rw-r--r--test/prism/snapshots/whitequark/args_star.txt70
-rw-r--r--test/prism/snapshots/whitequark/array_assocs.txt39
-rw-r--r--test/prism/snapshots/whitequark/array_plain.txt14
-rw-r--r--test/prism/snapshots/whitequark/array_splat.txt65
-rw-r--r--test/prism/snapshots/whitequark/array_symbols.txt22
-rw-r--r--test/prism/snapshots/whitequark/array_symbols_empty.txt15
-rw-r--r--test/prism/snapshots/whitequark/array_symbols_interp.txt67
-rw-r--r--test/prism/snapshots/whitequark/array_words.txt22
-rw-r--r--test/prism/snapshots/whitequark/array_words_empty.txt15
-rw-r--r--test/prism/snapshots/whitequark/array_words_interp.txt78
-rw-r--r--test/prism/snapshots/whitequark/asgn_cmd.txt55
-rw-r--r--test/prism/snapshots/whitequark/asgn_mrhs.txt86
-rw-r--r--test/prism/snapshots/whitequark/back_ref.txt7
-rw-r--r--test/prism/snapshots/whitequark/bang.txt25
-rw-r--r--test/prism/snapshots/whitequark/bang_cmd.txt38
-rw-r--r--test/prism/snapshots/whitequark/begin_cmdarg.txt50
-rw-r--r--test/prism/snapshots/whitequark/beginless_erange_after_newline.txt22
-rw-r--r--test/prism/snapshots/whitequark/beginless_irange_after_newline.txt22
-rw-r--r--test/prism/snapshots/whitequark/beginless_range.txt19
-rw-r--r--test/prism/snapshots/whitequark/blockarg.txt31
-rw-r--r--test/prism/snapshots/whitequark/blockargs.txt1288
-rw-r--r--test/prism/snapshots/whitequark/break.txt56
-rw-r--r--test/prism/snapshots/whitequark/break_block.txt41
-rw-r--r--test/prism/snapshots/whitequark/bug_435.txt38
-rw-r--r--test/prism/snapshots/whitequark/bug_447.txt57
-rw-r--r--test/prism/snapshots/whitequark/bug_452.txt63
-rw-r--r--test/prism/snapshots/whitequark/bug_466.txt68
-rw-r--r--test/prism/snapshots/whitequark/bug_473.txt33
-rw-r--r--test/prism/snapshots/whitequark/bug_480.txt36
-rw-r--r--test/prism/snapshots/whitequark/bug_481.txt51
-rw-r--r--test/prism/snapshots/whitequark/bug_ascii_8bit_in_literal.txt11
-rw-r--r--test/prism/snapshots/whitequark/bug_cmd_string_lookahead.txt31
-rw-r--r--test/prism/snapshots/whitequark/bug_cmdarg.txt108
-rw-r--r--test/prism/snapshots/whitequark/bug_def_no_paren_eql_begin.txt19
-rw-r--r--test/prism/snapshots/whitequark/bug_do_block_in_call_args.txt52
-rw-r--r--test/prism/snapshots/whitequark/bug_do_block_in_cmdarg.txt41
-rw-r--r--test/prism/snapshots/whitequark/bug_do_block_in_hash_brace.txt394
-rw-r--r--test/prism/snapshots/whitequark/bug_heredoc_do.txt31
-rw-r--r--test/prism/snapshots/whitequark/bug_interp_single.txt34
-rw-r--r--test/prism/snapshots/whitequark/bug_lambda_leakage.txt38
-rw-r--r--test/prism/snapshots/whitequark/bug_regex_verification.txt11
-rw-r--r--test/prism/snapshots/whitequark/bug_rescue_empty_else.txt25
-rw-r--r--test/prism/snapshots/whitequark/bug_while_not_parens_do.txt28
-rw-r--r--test/prism/snapshots/whitequark/case_cond.txt33
-rw-r--r--test/prism/snapshots/whitequark/case_cond_else.txt45
-rw-r--r--test/prism/snapshots/whitequark/case_expr.txt43
-rw-r--r--test/prism/snapshots/whitequark/case_expr_else.txt59
-rw-r--r--test/prism/snapshots/whitequark/casgn_scoped.txt19
-rw-r--r--test/prism/snapshots/whitequark/casgn_toplevel.txt17
-rw-r--r--test/prism/snapshots/whitequark/casgn_unscoped.txt12
-rw-r--r--test/prism/snapshots/whitequark/character.txt11
-rw-r--r--test/prism/snapshots/whitequark/class.txt27
-rw-r--r--test/prism/snapshots/whitequark/class_definition_in_while_cond.txt175
-rw-r--r--test/prism/snapshots/whitequark/class_super.txt18
-rw-r--r--test/prism/snapshots/whitequark/class_super_label.txt35
-rw-r--r--test/prism/snapshots/whitequark/comments_before_leading_dot__27.txt85
-rw-r--r--test/prism/snapshots/whitequark/complex.txt23
-rw-r--r--test/prism/snapshots/whitequark/cond_begin.txt40
-rw-r--r--test/prism/snapshots/whitequark/cond_begin_masgn.txt52
-rw-r--r--test/prism/snapshots/whitequark/cond_eflipflop.txt78
-rw-r--r--test/prism/snapshots/whitequark/cond_iflipflop.txt78
-rw-r--r--test/prism/snapshots/whitequark/cond_match_current_line.txt34
-rw-r--r--test/prism/snapshots/whitequark/const_op_asgn.txt98
-rw-r--r--test/prism/snapshots/whitequark/const_scoped.txt13
-rw-r--r--test/prism/snapshots/whitequark/const_toplevel.txt11
-rw-r--r--test/prism/snapshots/whitequark/const_unscoped.txt7
-rw-r--r--test/prism/snapshots/whitequark/cpath.txt33
-rw-r--r--test/prism/snapshots/whitequark/cvar.txt7
-rw-r--r--test/prism/snapshots/whitequark/cvasgn.txt12
-rw-r--r--test/prism/snapshots/whitequark/dedenting_heredoc.txt485
-rw-r--r--test/prism/snapshots/whitequark/dedenting_interpolating_heredoc_fake_line_continuation.txt21
-rw-r--r--test/prism/snapshots/whitequark/dedenting_non_interpolating_heredoc_line_continuation.txt21
-rw-r--r--test/prism/snapshots/whitequark/def.txt89
-rw-r--r--test/prism/snapshots/whitequark/defined.txt42
-rw-r--r--test/prism/snapshots/whitequark/defs.txt95
-rw-r--r--test/prism/snapshots/whitequark/empty_stmt.txt5
-rw-r--r--test/prism/snapshots/whitequark/endless_comparison_method.txt221
-rw-r--r--test/prism/snapshots/whitequark/endless_method.txt149
-rw-r--r--test/prism/snapshots/whitequark/endless_method_command_syntax.txt396
-rw-r--r--test/prism/snapshots/whitequark/endless_method_forwarded_args_legacy.txt44
-rw-r--r--test/prism/snapshots/whitequark/endless_method_with_rescue_mod.txt54
-rw-r--r--test/prism/snapshots/whitequark/endless_method_without_args.txt89
-rw-r--r--test/prism/snapshots/whitequark/ensure.txt40
-rw-r--r--test/prism/snapshots/whitequark/ensure_empty.txt16
-rw-r--r--test/prism/snapshots/whitequark/false.txt6
-rw-r--r--test/prism/snapshots/whitequark/float.txt7
-rw-r--r--test/prism/snapshots/whitequark/for.txt83
-rw-r--r--test/prism/snapshots/whitequark/for_mlhs.txt56
-rw-r--r--test/prism/snapshots/whitequark/forward_arg.txt44
-rw-r--r--test/prism/snapshots/whitequark/forward_arg_with_open_args.txt404
-rw-r--r--test/prism/snapshots/whitequark/forward_args_legacy.txt102
-rw-r--r--test/prism/snapshots/whitequark/forwarded_argument_with_kwrestarg.txt57
-rw-r--r--test/prism/snapshots/whitequark/forwarded_argument_with_restarg.txt54
-rw-r--r--test/prism/snapshots/whitequark/forwarded_kwrestarg.txt52
-rw-r--r--test/prism/snapshots/whitequark/forwarded_kwrestarg_with_additional_kwarg.txt63
-rw-r--r--test/prism/snapshots/whitequark/forwarded_restarg.txt49
-rw-r--r--test/prism/snapshots/whitequark/gvar.txt7
-rw-r--r--test/prism/snapshots/whitequark/gvasgn.txt12
-rw-r--r--test/prism/snapshots/whitequark/hash_empty.txt9
-rw-r--r--test/prism/snapshots/whitequark/hash_hashrocket.txt45
-rw-r--r--test/prism/snapshots/whitequark/hash_kwsplat.txt34
-rw-r--r--test/prism/snapshots/whitequark/hash_label.txt21
-rw-r--r--test/prism/snapshots/whitequark/hash_label_end.txt97
-rw-r--r--test/prism/snapshots/whitequark/hash_pair_value_omission.txt97
-rw-r--r--test/prism/snapshots/whitequark/heredoc.txt23
-rw-r--r--test/prism/snapshots/whitequark/if.txt63
-rw-r--r--test/prism/snapshots/whitequark/if_else.txt95
-rw-r--r--test/prism/snapshots/whitequark/if_elsif.txt63
-rw-r--r--test/prism/snapshots/whitequark/if_masgn__24.txt42
-rw-r--r--test/prism/snapshots/whitequark/if_mod.txt34
-rw-r--r--test/prism/snapshots/whitequark/if_nl_then.txt34
-rw-r--r--test/prism/snapshots/whitequark/if_while_after_class__since_32.txt119
-rw-r--r--test/prism/snapshots/whitequark/int.txt11
-rw-r--r--test/prism/snapshots/whitequark/int___LINE__.txt6
-rw-r--r--test/prism/snapshots/whitequark/interp_digit_var.txt273
-rw-r--r--test/prism/snapshots/whitequark/ivar.txt7
-rw-r--r--test/prism/snapshots/whitequark/ivasgn.txt12
-rw-r--r--test/prism/snapshots/whitequark/keyword_argument_omission.txt65
-rw-r--r--test/prism/snapshots/whitequark/kwarg.txt30
-rw-r--r--test/prism/snapshots/whitequark/kwbegin_compstmt.txt34
-rw-r--r--test/prism/snapshots/whitequark/kwnilarg.txt87
-rw-r--r--test/prism/snapshots/whitequark/kwoptarg.txt33
-rw-r--r--test/prism/snapshots/whitequark/kwoptarg_with_kwrestarg_and_forwarded_args.txt57
-rw-r--r--test/prism/snapshots/whitequark/kwrestarg_named.txt31
-rw-r--r--test/prism/snapshots/whitequark/kwrestarg_unnamed.txt31
-rw-r--r--test/prism/snapshots/whitequark/lbrace_arg_after_command_args.txt56
-rw-r--r--test/prism/snapshots/whitequark/lparenarg_after_lvar__since_25.txt65
-rw-r--r--test/prism/snapshots/whitequark/lvar.txt15
-rw-r--r--test/prism/snapshots/whitequark/lvar_injecting_match.txt39
-rw-r--r--test/prism/snapshots/whitequark/lvasgn.txt16
-rw-r--r--test/prism/snapshots/whitequark/masgn.txt77
-rw-r--r--test/prism/snapshots/whitequark/masgn_attr.txt80
-rw-r--r--test/prism/snapshots/whitequark/masgn_cmd.txt35
-rw-r--r--test/prism/snapshots/whitequark/masgn_const.txt46
-rw-r--r--test/prism/snapshots/whitequark/masgn_nested.txt66
-rw-r--r--test/prism/snapshots/whitequark/masgn_splat.txt284
-rw-r--r--test/prism/snapshots/whitequark/method_definition_in_while_cond.txt205
-rw-r--r--test/prism/snapshots/whitequark/module.txt14
-rw-r--r--test/prism/snapshots/whitequark/multiple_pattern_matches.txt149
-rw-r--r--test/prism/snapshots/whitequark/newline_in_hash_argument.txt149
-rw-r--r--test/prism/snapshots/whitequark/next.txt56
-rw-r--r--test/prism/snapshots/whitequark/next_block.txt41
-rw-r--r--test/prism/snapshots/whitequark/nil.txt6
-rw-r--r--test/prism/snapshots/whitequark/nil_expression.txt16
-rw-r--r--test/prism/snapshots/whitequark/non_lvar_injecting_match.txt43
-rw-r--r--test/prism/snapshots/whitequark/not.txt55
-rw-r--r--test/prism/snapshots/whitequark/not_cmd.txt38
-rw-r--r--test/prism/snapshots/whitequark/not_masgn__24.txt45
-rw-r--r--test/prism/snapshots/whitequark/nth_ref.txt7
-rw-r--r--test/prism/snapshots/whitequark/numbered_args_after_27.txt147
-rw-r--r--test/prism/snapshots/whitequark/numparam_outside_block.txt115
-rw-r--r--test/prism/snapshots/whitequark/op_asgn.txt71
-rw-r--r--test/prism/snapshots/whitequark/op_asgn_cmd.txt178
-rw-r--r--test/prism/snapshots/whitequark/op_asgn_index.txt35
-rw-r--r--test/prism/snapshots/whitequark/op_asgn_index_cmd.txt56
-rw-r--r--test/prism/snapshots/whitequark/optarg.txt70
-rw-r--r--test/prism/snapshots/whitequark/or.txt53
-rw-r--r--test/prism/snapshots/whitequark/or_asgn.txt55
-rw-r--r--test/prism/snapshots/whitequark/parser_bug_272.txt42
-rw-r--r--test/prism/snapshots/whitequark/parser_bug_490.txt109
-rw-r--r--test/prism/snapshots/whitequark/parser_bug_507.txt36
-rw-r--r--test/prism/snapshots/whitequark/parser_bug_518.txt18
-rw-r--r--test/prism/snapshots/whitequark/parser_bug_525.txt67
-rw-r--r--test/prism/snapshots/whitequark/parser_bug_604.txt58
-rw-r--r--test/prism/snapshots/whitequark/parser_bug_640.txt11
-rw-r--r--test/prism/snapshots/whitequark/parser_bug_645.txt35
-rw-r--r--test/prism/snapshots/whitequark/parser_bug_830.txt11
-rw-r--r--test/prism/snapshots/whitequark/parser_drops_truncated_parts_of_squiggly_heredoc.txt19
-rw-r--r--test/prism/snapshots/whitequark/parser_slash_slash_n_escaping_in_literals.txt139
-rw-r--r--test/prism/snapshots/whitequark/pattern_matching__FILE__LINE_literals.txt51
-rw-r--r--test/prism/snapshots/whitequark/pattern_matching_blank_else.txt28
-rw-r--r--test/prism/snapshots/whitequark/pattern_matching_else.txt32
-rw-r--r--test/prism/snapshots/whitequark/pattern_matching_single_line.txt43
-rw-r--r--test/prism/snapshots/whitequark/pattern_matching_single_line_allowed_omission_of_parentheses.txt233
-rw-r--r--test/prism/snapshots/whitequark/postexe.txt14
-rw-r--r--test/prism/snapshots/whitequark/preexe.txt14
-rw-r--r--test/prism/snapshots/whitequark/procarg0.txt77
-rw-r--r--test/prism/snapshots/whitequark/range_exclusive.txt14
-rw-r--r--test/prism/snapshots/whitequark/range_inclusive.txt14
-rw-r--r--test/prism/snapshots/whitequark/rational.txt12
-rw-r--r--test/prism/snapshots/whitequark/redo.txt6
-rw-r--r--test/prism/snapshots/whitequark/regex_interp.txt38
-rw-r--r--test/prism/snapshots/whitequark/regex_plain.txt11
-rw-r--r--test/prism/snapshots/whitequark/resbody_list.txt45
-rw-r--r--test/prism/snapshots/whitequark/resbody_list_mrhs.txt55
-rw-r--r--test/prism/snapshots/whitequark/resbody_list_var.txt56
-rw-r--r--test/prism/snapshots/whitequark/resbody_var.txt86
-rw-r--r--test/prism/snapshots/whitequark/rescue.txt43
-rw-r--r--test/prism/snapshots/whitequark/rescue_else.txt59
-rw-r--r--test/prism/snapshots/whitequark/rescue_else_ensure.txt75
-rw-r--r--test/prism/snapshots/whitequark/rescue_ensure.txt59
-rw-r--r--test/prism/snapshots/whitequark/rescue_in_lambda_block.txt27
-rw-r--r--test/prism/snapshots/whitequark/rescue_mod.txt29
-rw-r--r--test/prism/snapshots/whitequark/rescue_mod_asgn.txt35
-rw-r--r--test/prism/snapshots/whitequark/rescue_mod_masgn.txt42
-rw-r--r--test/prism/snapshots/whitequark/rescue_mod_op_assign.txt36
-rw-r--r--test/prism/snapshots/whitequark/rescue_without_begin_end.txt60
-rw-r--r--test/prism/snapshots/whitequark/restarg_named.txt31
-rw-r--r--test/prism/snapshots/whitequark/restarg_unnamed.txt31
-rw-r--r--test/prism/snapshots/whitequark/retry.txt6
-rw-r--r--test/prism/snapshots/whitequark/return.txt56
-rw-r--r--test/prism/snapshots/whitequark/return_block.txt41
-rw-r--r--test/prism/snapshots/whitequark/ruby_bug_10279.txt31
-rw-r--r--test/prism/snapshots/whitequark/ruby_bug_10653.txt175
-rw-r--r--test/prism/snapshots/whitequark/ruby_bug_11107.txt50
-rw-r--r--test/prism/snapshots/whitequark/ruby_bug_11380.txt56
-rw-r--r--test/prism/snapshots/whitequark/ruby_bug_11873.txt785
-rw-r--r--test/prism/snapshots/whitequark/ruby_bug_11873_a.txt1245
-rw-r--r--test/prism/snapshots/whitequark/ruby_bug_11873_b.txt100
-rw-r--r--test/prism/snapshots/whitequark/ruby_bug_11989.txt24
-rw-r--r--test/prism/snapshots/whitequark/ruby_bug_11990.txt34
-rw-r--r--test/prism/snapshots/whitequark/ruby_bug_12073.txt94
-rw-r--r--test/prism/snapshots/whitequark/ruby_bug_12402.txt565
-rw-r--r--test/prism/snapshots/whitequark/ruby_bug_12669.txt133
-rw-r--r--test/prism/snapshots/whitequark/ruby_bug_12686.txt39
-rw-r--r--test/prism/snapshots/whitequark/ruby_bug_13547.txt32
-rw-r--r--test/prism/snapshots/whitequark/ruby_bug_14690.txt61
-rw-r--r--test/prism/snapshots/whitequark/ruby_bug_15789.txt122
-rw-r--r--test/prism/snapshots/whitequark/ruby_bug_9669.txt57
-rw-r--r--test/prism/snapshots/whitequark/sclass.txt25
-rw-r--r--test/prism/snapshots/whitequark/self.txt6
-rw-r--r--test/prism/snapshots/whitequark/send_attr_asgn.txt102
-rw-r--r--test/prism/snapshots/whitequark/send_attr_asgn_conditional.txt30
-rw-r--r--test/prism/snapshots/whitequark/send_binary_op.txt530
-rw-r--r--test/prism/snapshots/whitequark/send_block_chain_cmd.txt328
-rw-r--r--test/prism/snapshots/whitequark/send_block_conditional.txt32
-rw-r--r--test/prism/snapshots/whitequark/send_call.txt55
-rw-r--r--test/prism/snapshots/whitequark/send_conditional.txt25
-rw-r--r--test/prism/snapshots/whitequark/send_index.txt32
-rw-r--r--test/prism/snapshots/whitequark/send_index_asgn.txt34
-rw-r--r--test/prism/snapshots/whitequark/send_index_asgn_legacy.txt34
-rw-r--r--test/prism/snapshots/whitequark/send_index_cmd.txt51
-rw-r--r--test/prism/snapshots/whitequark/send_index_legacy.txt32
-rw-r--r--test/prism/snapshots/whitequark/send_lambda.txt46
-rw-r--r--test/prism/snapshots/whitequark/send_lambda_args.txt51
-rw-r--r--test/prism/snapshots/whitequark/send_lambda_args_noparen.txt56
-rw-r--r--test/prism/snapshots/whitequark/send_lambda_args_shadow.txt32
-rw-r--r--test/prism/snapshots/whitequark/send_lambda_legacy.txt13
-rw-r--r--test/prism/snapshots/whitequark/send_op_asgn_conditional.txt26
-rw-r--r--test/prism/snapshots/whitequark/send_plain.txt65
-rw-r--r--test/prism/snapshots/whitequark/send_plain_cmd.txt104
-rw-r--r--test/prism/snapshots/whitequark/send_self.txt40
-rw-r--r--test/prism/snapshots/whitequark/send_self_block.txt78
-rw-r--r--test/prism/snapshots/whitequark/send_unary_op.txt65
-rw-r--r--test/prism/snapshots/whitequark/slash_newline_in_heredocs.txt27
-rw-r--r--test/prism/snapshots/whitequark/space_args_arg.txt26
-rw-r--r--test/prism/snapshots/whitequark/space_args_arg_block.txt109
-rw-r--r--test/prism/snapshots/whitequark/space_args_arg_call.txt36
-rw-r--r--test/prism/snapshots/whitequark/space_args_arg_newline.txt26
-rw-r--r--test/prism/snapshots/whitequark/space_args_block.txt29
-rw-r--r--test/prism/snapshots/whitequark/space_args_cmd.txt47
-rw-r--r--test/prism/snapshots/whitequark/string___FILE__.txt7
-rw-r--r--test/prism/snapshots/whitequark/string_concat.txt30
-rw-r--r--test/prism/snapshots/whitequark/string_dvar.txt36
-rw-r--r--test/prism/snapshots/whitequark/string_interp.txt37
-rw-r--r--test/prism/snapshots/whitequark/string_plain.txt17
-rw-r--r--test/prism/snapshots/whitequark/super.txt49
-rw-r--r--test/prism/snapshots/whitequark/super_block.txt50
-rw-r--r--test/prism/snapshots/whitequark/symbol_interp.txt37
-rw-r--r--test/prism/snapshots/whitequark/symbol_plain.txt17
-rw-r--r--test/prism/snapshots/whitequark/ternary.txt34
-rw-r--r--test/prism/snapshots/whitequark/ternary_ambiguous_symbol.txt49
-rw-r--r--test/prism/snapshots/whitequark/trailing_forward_arg.txt53
-rw-r--r--test/prism/snapshots/whitequark/true.txt6
-rw-r--r--test/prism/snapshots/whitequark/unary_num_pow_precedence.txt74
-rw-r--r--test/prism/snapshots/whitequark/undef.txt38
-rw-r--r--test/prism/snapshots/whitequark/unless.txt63
-rw-r--r--test/prism/snapshots/whitequark/unless_else.txt95
-rw-r--r--test/prism/snapshots/whitequark/unless_mod.txt34
-rw-r--r--test/prism/snapshots/whitequark/until.txt61
-rw-r--r--test/prism/snapshots/whitequark/until_mod.txt33
-rw-r--r--test/prism/snapshots/whitequark/until_post.txt42
-rw-r--r--test/prism/snapshots/whitequark/var_and_asgn.txt13
-rw-r--r--test/prism/snapshots/whitequark/var_op_asgn.txt54
-rw-r--r--test/prism/snapshots/whitequark/var_op_asgn_cmd.txt28
-rw-r--r--test/prism/snapshots/whitequark/var_or_asgn.txt13
-rw-r--r--test/prism/snapshots/whitequark/when_multi.txt49
-rw-r--r--test/prism/snapshots/whitequark/when_splat.txt69
-rw-r--r--test/prism/snapshots/whitequark/when_then.txt43
-rw-r--r--test/prism/snapshots/whitequark/while.txt61
-rw-r--r--test/prism/snapshots/whitequark/while_mod.txt33
-rw-r--r--test/prism/snapshots/whitequark/while_post.txt42
-rw-r--r--test/prism/snapshots/whitequark/xstring_interp.txt37
-rw-r--r--test/prism/snapshots/whitequark/xstring_plain.txt11
-rw-r--r--test/prism/snapshots/whitequark/yield.txt51
-rw-r--r--test/prism/snapshots/whitequark/zsuper.txt7
-rw-r--r--test/prism/snapshots/xstring.txt55
-rw-r--r--test/prism/snapshots/yield.txt39
-rw-r--r--test/prism/test_helper.rb91
-rw-r--r--test/prism/unescape_test.rb235
-rw-r--r--test/prism/version_test.rb11
-rw-r--r--test/psych/test_numeric.rb9
-rw-r--r--test/psych/test_object_references.rb8
-rw-r--r--test/psych/test_parser.rb19
-rw-r--r--test/psych/visitors/test_emitter.rb16
-rw-r--r--test/psych/visitors/test_to_ruby.rb2
-rw-r--r--test/psych/visitors/test_yaml_tree.rb8
-rw-r--r--test/racc/assets/cadenza.y170
-rw-r--r--test/racc/assets/cast.y926
-rw-r--r--test/racc/assets/chk.y126
-rw-r--r--test/racc/assets/conf.y16
-rw-r--r--test/racc/assets/csspool.y729
-rw-r--r--test/racc/assets/digraph.y29
-rw-r--r--test/racc/assets/echk.y118
-rw-r--r--test/racc/assets/edtf.y583
-rw-r--r--test/racc/assets/err.y60
-rw-r--r--test/racc/assets/error_recovery.y35
-rw-r--r--test/racc/assets/expect.y7
-rw-r--r--test/racc/assets/firstline.y4
-rw-r--r--test/racc/assets/huia.y318
-rw-r--r--test/racc/assets/ichk.y102
-rw-r--r--test/racc/assets/ifelse.y14
-rw-r--r--test/racc/assets/intp.y546
-rw-r--r--test/racc/assets/journey.y47
-rw-r--r--test/racc/assets/liquor.y313
-rw-r--r--test/racc/assets/machete.y423
-rw-r--r--test/racc/assets/macruby.y2197
-rw-r--r--test/racc/assets/mailp.y437
-rw-r--r--test/racc/assets/mediacloth.y599
-rw-r--r--test/racc/assets/mof.y649
-rw-r--r--test/racc/assets/namae.y302
-rw-r--r--test/racc/assets/nasl.y626
-rw-r--r--test/racc/assets/newsyn.y25
-rw-r--r--test/racc/assets/noend.y4
-rw-r--r--test/racc/assets/nokogiri-css.y255
-rw-r--r--test/racc/assets/nonass.y41
-rw-r--r--test/racc/assets/normal.y27
-rw-r--r--test/racc/assets/norule.y4
-rw-r--r--test/racc/assets/nullbug1.y25
-rw-r--r--test/racc/assets/nullbug2.y15
-rw-r--r--test/racc/assets/opal.y1807
-rw-r--r--test/racc/assets/opt.y123
-rw-r--r--test/racc/assets/percent.y35
-rw-r--r--test/racc/assets/php_serialization.y98
-rw-r--r--test/racc/assets/recv.y97
-rw-r--r--test/racc/assets/riml.y665
-rw-r--r--test/racc/assets/rrconf.y14
-rw-r--r--test/racc/assets/ruby18.y1943
-rw-r--r--test/racc/assets/ruby19.y2174
-rw-r--r--test/racc/assets/ruby20.y2350
-rw-r--r--test/racc/assets/ruby21.y2359
-rw-r--r--test/racc/assets/ruby22.y2381
-rw-r--r--test/racc/assets/scan.y72
-rw-r--r--test/racc/assets/syntax.y50
-rw-r--r--test/racc/assets/tp_plus.y622
-rw-r--r--test/racc/assets/twowaysql.y278
-rw-r--r--test/racc/assets/unterm.y5
-rw-r--r--test/racc/assets/useless.y12
-rw-r--r--test/racc/assets/yyerr.y46
-rw-r--r--test/racc/bench.y36
-rw-r--r--test/racc/case.rb111
-rw-r--r--test/racc/infini.y8
-rw-r--r--test/racc/regress/README.txt7
-rw-r--r--test/racc/regress/cadenza798
-rw-r--r--test/racc/regress/cast3947
-rw-r--r--test/racc/regress/csspool2316
-rw-r--r--test/racc/regress/edtf1796
-rw-r--r--test/racc/regress/huia1683
-rw-r--r--test/racc/regress/journey224
-rw-r--r--test/racc/regress/liquor887
-rw-r--r--test/racc/regress/machete835
-rw-r--r--test/racc/regress/mediacloth1465
-rw-r--r--test/racc/regress/mof1370
-rw-r--r--test/racc/regress/namae636
-rw-r--r--test/racc/regress/nasl2550
-rw-r--r--test/racc/regress/nokogiri-css838
-rw-r--r--test/racc/regress/opal10109
-rw-r--r--test/racc/regress/php_serialization338
-rw-r--r--test/racc/regress/riml4039
-rw-r--r--test/racc/regress/ruby189947
-rw-r--r--test/racc/regress/ruby2211182
-rw-r--r--test/racc/regress/tp_plus1935
-rw-r--r--test/racc/regress/twowaysql558
-rw-r--r--test/racc/scandata/brace7
-rw-r--r--test/racc/scandata/gvar1
-rw-r--r--test/racc/scandata/normal4
-rw-r--r--test/racc/scandata/percent18
-rw-r--r--test/racc/scandata/slash10
-rw-r--r--test/racc/src.intp34
-rw-r--r--test/racc/start.y20
-rw-r--r--test/racc/test_chk_y.rb52
-rw-r--r--test/racc/test_grammar_file_parser.rb15
-rw-r--r--test/racc/test_racc_command.rb339
-rw-r--r--test/racc/test_scan_y.rb52
-rw-r--r--test/racc/testscanner.rb51
-rw-r--r--test/rdoc/support/text_formatter_test_case.rb1
-rw-r--r--test/rdoc/test_rdoc_any_method.rb38
-rw-r--r--test/rdoc/test_rdoc_comment.rb9
-rw-r--r--test/rdoc/test_rdoc_context_section.rb1
-rw-r--r--test/rdoc/test_rdoc_generator_darkfish.rb35
-rw-r--r--test/rdoc/test_rdoc_generator_json_index.rb14
-rw-r--r--test/rdoc/test_rdoc_generator_markup.rb1
-rw-r--r--test/rdoc/test_rdoc_markup.rb1
-rw-r--r--test/rdoc/test_rdoc_markup_attribute_manager.rb1
-rw-r--r--test/rdoc/test_rdoc_markup_attributes.rb1
-rw-r--r--test/rdoc/test_rdoc_markup_document.rb1
-rw-r--r--test/rdoc/test_rdoc_markup_formatter.rb6
-rw-r--r--test/rdoc/test_rdoc_markup_hard_break.rb1
-rw-r--r--test/rdoc/test_rdoc_markup_heading.rb1
-rw-r--r--test/rdoc/test_rdoc_markup_include.rb1
-rw-r--r--test/rdoc/test_rdoc_markup_indented_paragraph.rb1
-rw-r--r--test/rdoc/test_rdoc_markup_paragraph.rb1
-rw-r--r--test/rdoc/test_rdoc_markup_raw.rb1
-rw-r--r--test/rdoc/test_rdoc_markup_to_ansi.rb1
-rw-r--r--test/rdoc/test_rdoc_markup_to_html.rb41
-rw-r--r--test/rdoc/test_rdoc_markup_to_joined_paragraph.rb1
-rw-r--r--test/rdoc/test_rdoc_markup_to_label.rb1
-rw-r--r--test/rdoc/test_rdoc_markup_to_markdown.rb1
-rw-r--r--test/rdoc/test_rdoc_markup_to_rdoc.rb1
-rw-r--r--test/rdoc/test_rdoc_markup_to_table_of_contents.rb1
-rw-r--r--test/rdoc/test_rdoc_markup_to_tt_only.rb1
-rw-r--r--test/rdoc/test_rdoc_markup_verbatim.rb1
-rw-r--r--test/rdoc/test_rdoc_options.rb20
-rw-r--r--test/rdoc/test_rdoc_parser_c.rb39
-rw-r--r--test/rdoc/test_rdoc_parser_changelog.rb1
-rw-r--r--test/rdoc/test_rdoc_parser_markdown.rb1
-rw-r--r--test/rdoc/test_rdoc_parser_rd.rb1
-rw-r--r--test/rdoc/test_rdoc_parser_ruby.rb15
-rw-r--r--test/rdoc/test_rdoc_parser_simple.rb1
-rw-r--r--test/rdoc/test_rdoc_rd.rb1
-rw-r--r--test/rdoc/test_rdoc_rd_inline.rb1
-rw-r--r--test/rdoc/test_rdoc_rdoc.rb14
-rw-r--r--test/rdoc/test_rdoc_ri_paths.rb1
-rw-r--r--test/rdoc/test_rdoc_single_class.rb1
-rw-r--r--test/rdoc/test_rdoc_stats.rb1
-rw-r--r--test/rdoc/test_rdoc_store.rb8
-rw-r--r--test/rdoc/test_rdoc_task.rb9
-rw-r--r--test/rdoc/test_rdoc_token_stream.rb17
-rw-r--r--test/rdoc/xref_data.rb1
-rw-r--r--test/rdoc/xref_test_case.rb1
-rw-r--r--test/readline/helper.rb29
-rw-r--r--test/readline/test_readline.rb952
-rw-r--r--test/readline/test_readline_history.rb292
-rw-r--r--test/reline/helper.rb75
-rw-r--r--test/reline/test_ansi_with_terminfo.rb32
-rw-r--r--test/reline/test_ansi_without_terminfo.rb4
-rw-r--r--test/reline/test_config.rb21
-rw-r--r--test/reline/test_face.rb257
-rw-r--r--test/reline/test_history.rb2
-rw-r--r--test/reline/test_key_actor_emacs.rb33
-rw-r--r--test/reline/test_key_actor_vi.rb2
-rw-r--r--test/reline/test_key_stroke.rb26
-rw-r--r--test/reline/test_line_editor.rb13
-rw-r--r--test/reline/test_macro.rb2
-rw-r--r--test/reline/test_reline.rb14
-rw-r--r--test/reline/test_reline_key.rb1
-rw-r--r--test/reline/test_string_processing.rb2
-rw-r--r--test/reline/test_unicode.rb40
-rw-r--r--test/reline/test_within_pipe.rb8
-rwxr-xr-xtest/reline/yamatanooroti/multiline_repl25
-rw-r--r--test/reline/yamatanooroti/test_rendering.rb328
-rw-r--r--test/resolv/test_dns.rb201
-rw-r--r--test/resolv/test_resource.rb8
-rw-r--r--test/resolv/test_svcb_https.rb231
-rw-r--r--test/rinda/test_rinda.rb4
-rw-r--r--test/ripper/assert_parse_files.rb25
-rw-r--r--test/ripper/dummyparser.rb53
-rw-r--r--test/ripper/test_lexer.rb70
-rw-r--r--test/ripper/test_parser_events.rb20
-rw-r--r--test/ripper/test_ripper.rb29
-rw-r--r--test/ripper/test_scanner_events.rb21
-rw-r--r--test/ripper/test_sexp.rb26
-rw-r--r--test/ruby/enc/test_case_comprehensive.rb2
-rw-r--r--test/ruby/enc/test_cesu8.rb4
-rw-r--r--test/ruby/enc/test_emoji_breaks.rb2
-rw-r--r--test/ruby/enc/test_grapheme_breaks.rb2
-rw-r--r--test/ruby/enc/test_regex_casefold.rb2
-rw-r--r--test/ruby/rjit/test_assembler.rb368
-rw-r--r--test/ruby/test_arity.rb1
-rw-r--r--test/ruby/test_array.rb25
-rw-r--r--test/ruby/test_ast.rb154
-rw-r--r--test/ruby/test_autoload.rb5
-rw-r--r--test/ruby/test_backtrace.rb6
-rw-r--r--test/ruby/test_beginendblock.rb4
-rw-r--r--test/ruby/test_call.rb1130
-rw-r--r--test/ruby/test_class.rb18
-rw-r--r--test/ruby/test_clone.rb7
-rw-r--r--test/ruby/test_comparable.rb6
-rw-r--r--test/ruby/test_compile_prism.rb2110
-rw-r--r--test/ruby/test_complex.rb65
-rw-r--r--test/ruby/test_data.rb34
-rw-r--r--test/ruby/test_default_gems.rb19
-rw-r--r--test/ruby/test_defined.rb14
-rw-r--r--test/ruby/test_dir.rb96
-rw-r--r--test/ruby/test_econv.rb2
-rw-r--r--test/ruby/test_encoding.rb2
-rw-r--r--test/ruby/test_enumerator.rb54
-rw-r--r--test/ruby/test_eval.rb7
-rw-r--r--test/ruby/test_exception.rb21
-rw-r--r--test/ruby/test_fiber.rb2
-rw-r--r--test/ruby/test_file_exhaustive.rb2
-rw-r--r--test/ruby/test_gc.rb395
-rw-r--r--test/ruby/test_gc_compact.rb129
-rw-r--r--test/ruby/test_hash.rb769
-rw-r--r--test/ruby/test_integer.rb71
-rw-r--r--test/ruby/test_io.rb150
-rw-r--r--test/ruby/test_io_buffer.rb155
-rw-r--r--test/ruby/test_io_m17n.rb32
-rw-r--r--test/ruby/test_iseq.rb54
-rw-r--r--test/ruby/test_keyword.rb36
-rw-r--r--test/ruby/test_lambda.rb26
-rw-r--r--test/ruby/test_lazy_enumerator.rb5
-rw-r--r--test/ruby/test_m17n.rb18
-rw-r--r--test/ruby/test_marshal.rb10
-rw-r--r--test/ruby/test_math.rb10
-rw-r--r--test/ruby/test_method.rb69
-rw-r--r--test/ruby/test_mjit.rb1328
-rw-r--r--test/ruby/test_mjit_debug.rb17
-rw-r--r--test/ruby/test_module.rb71
-rw-r--r--test/ruby/test_nomethod_error.rb2
-rw-r--r--test/ruby/test_numeric.rb3
-rw-r--r--test/ruby/test_object.rb47
-rw-r--r--test/ruby/test_optimization.rb27
-rw-r--r--test/ruby/test_pack.rb40
-rw-r--r--test/ruby/test_parse.rb248
-rw-r--r--test/ruby/test_pattern_matching.rb18
-rw-r--r--test/ruby/test_proc.rb82
-rw-r--r--test/ruby/test_process.rb151
-rw-r--r--test/ruby/test_random_formatter.rb55
-rw-r--r--test/ruby/test_range.rb301
-rw-r--r--test/ruby/test_refinement.rb69
-rw-r--r--test/ruby/test_regexp.rb396
-rw-r--r--test/ruby/test_require.rb56
-rw-r--r--test/ruby/test_require_lib.rb31
-rw-r--r--test/ruby/test_rubyoptions.rb266
-rw-r--r--test/ruby/test_rubyvm_mjit.rb105
-rw-r--r--test/ruby/test_settracefunc.rb181
-rw-r--r--test/ruby/test_shapes.rb646
-rw-r--r--test/ruby/test_signal.rb43
-rw-r--r--test/ruby/test_stack.rb1
-rw-r--r--test/ruby/test_string.rb449
-rw-r--r--test/ruby/test_string_memory.rb55
-rw-r--r--test/ruby/test_struct.rb22
-rw-r--r--test/ruby/test_super.rb12
-rw-r--r--test/ruby/test_symbol.rb6
-rw-r--r--test/ruby/test_syntax.rb264
-rw-r--r--test/ruby/test_system.rb13
-rw-r--r--test/ruby/test_thread.rb41
-rw-r--r--test/ruby/test_thread_cv.rb6
-rw-r--r--test/ruby/test_thread_queue.rb34
-rw-r--r--test/ruby/test_time.rb30
-rw-r--r--test/ruby/test_time_tz.rb10
-rw-r--r--test/ruby/test_transcode.rb498
-rw-r--r--test/ruby/test_variable.rb109
-rw-r--r--test/ruby/test_weakkeymap.rb144
-rw-r--r--test/ruby/test_weakmap.rb81
-rw-r--r--test/ruby/test_yjit.rb493
-rw-r--r--test/ruby/test_yjit_exit_locations.rb20
-rw-r--r--test/rubygems/bad_rake.rb1
-rw-r--r--test/rubygems/bundler_test_gem.rb55
-rw-r--r--test/rubygems/fake_certlib/openssl.rb1
-rw-r--r--test/rubygems/good_rake.rb1
-rw-r--r--test/rubygems/helper.rb325
-rw-r--r--test/rubygems/installer_test_case.rb17
-rw-r--r--test/rubygems/mock_gem_ui.rb86
-rw-r--r--test/rubygems/multifactor_auth_utilities.rb111
-rw-r--r--test/rubygems/package/tar_test_case.rb68
-rw-r--r--test/rubygems/plugin/exception/rubygems_plugin.rb3
-rw-r--r--test/rubygems/plugin/load/rubygems_plugin.rb1
-rw-r--r--test/rubygems/plugin/scripterror/rubygems_plugin.rb4
-rw-r--r--test/rubygems/plugin/standarderror/rubygems_plugin.rb1
-rw-r--r--test/rubygems/rubygems/commands/crash_command.rb1
-rw-r--r--test/rubygems/rubygems_plugin.rb1
-rw-r--r--test/rubygems/simple_gem.rb1
-rw-r--r--test/rubygems/specifications/bar-0.0.2.gemspec2
-rw-r--r--test/rubygems/specifications/rubyforge-0.0.1.gemspec23
-rw-r--r--test/rubygems/test_bundled_ca.rb9
-rw-r--r--test/rubygems/test_config.rb7
-rw-r--r--test/rubygems/test_deprecate.rb11
-rw-r--r--test/rubygems/test_exit.rb2
-rw-r--r--test/rubygems/test_gem.rb222
-rw-r--r--test/rubygems/test_gem_available_set.rb7
-rw-r--r--test/rubygems/test_gem_bundler_version_finder.rb7
-rw-r--r--test/rubygems/test_gem_ci_detector.rb44
-rw-r--r--test/rubygems/test_gem_command.rb48
-rw-r--r--test/rubygems/test_gem_command_manager.rb71
-rw-r--r--test/rubygems/test_gem_commands_build_command.rb18
-rw-r--r--test/rubygems/test_gem_commands_cert_command.rb68
-rw-r--r--test/rubygems/test_gem_commands_check_command.rb1
-rw-r--r--test/rubygems/test_gem_commands_cleanup_command.rb19
-rw-r--r--test/rubygems/test_gem_commands_contents_command.rb15
-rw-r--r--test/rubygems/test_gem_commands_dependency_command.rb1
-rw-r--r--test/rubygems/test_gem_commands_environment_command.rb50
-rw-r--r--test/rubygems/test_gem_commands_exec_command.rb859
-rw-r--r--test/rubygems/test_gem_commands_fetch_command.rb1
-rw-r--r--test/rubygems/test_gem_commands_generate_index_command.rb80
-rw-r--r--test/rubygems/test_gem_commands_help_command.rb5
-rw-r--r--test/rubygems/test_gem_commands_info_command.rb13
-rw-r--r--test/rubygems/test_gem_commands_install_command.rb121
-rw-r--r--test/rubygems/test_gem_commands_list_command.rb1
-rw-r--r--test/rubygems/test_gem_commands_lock_command.rb1
-rw-r--r--test/rubygems/test_gem_commands_mirror.rb3
-rw-r--r--test/rubygems/test_gem_commands_open_command.rb14
-rw-r--r--test/rubygems/test_gem_commands_outdated_command.rb1
-rw-r--r--test/rubygems/test_gem_commands_owner_command.rb142
-rw-r--r--test/rubygems/test_gem_commands_pristine_command.rb70
-rw-r--r--test/rubygems/test_gem_commands_push_command.rb149
-rw-r--r--test/rubygems/test_gem_commands_query_command.rb65
-rw-r--r--test/rubygems/test_gem_commands_rebuild_command.rb145
-rw-r--r--test/rubygems/test_gem_commands_search_command.rb1
-rw-r--r--test/rubygems/test_gem_commands_server_command.rb3
-rw-r--r--test/rubygems/test_gem_commands_setup_command.rb32
-rw-r--r--test/rubygems/test_gem_commands_signin_command.rb100
-rw-r--r--test/rubygems/test_gem_commands_signout_command.rb6
-rw-r--r--test/rubygems/test_gem_commands_sources_command.rb1
-rw-r--r--test/rubygems/test_gem_commands_specification_command.rb31
-rw-r--r--test/rubygems/test_gem_commands_stale_command.rb5
-rw-r--r--test/rubygems/test_gem_commands_uninstall_command.rb76
-rw-r--r--test/rubygems/test_gem_commands_unpack_command.rb9
-rw-r--r--test/rubygems/test_gem_commands_update_command.rb53
-rw-r--r--test/rubygems/test_gem_commands_which_command.rb13
-rw-r--r--test/rubygems/test_gem_commands_yank_command.rb129
-rw-r--r--test/rubygems/test_gem_config_file.rb93
-rw-r--r--test/rubygems/test_gem_console_ui.rb19
-rw-r--r--test/rubygems/test_gem_dependency.rb20
-rw-r--r--test/rubygems/test_gem_dependency_installer.rb214
-rw-r--r--test/rubygems/test_gem_dependency_list.rb13
-rw-r--r--test/rubygems/test_gem_dependency_resolution_error.rb15
-rw-r--r--test/rubygems/test_gem_doctor.rb1
-rw-r--r--test/rubygems/test_gem_ext_builder.rb161
-rw-r--r--test/rubygems/test_gem_ext_cargo_builder.rb21
-rw-r--r--test/rubygems/test_gem_ext_cargo_builder/custom_name/custom_name.gemspec2
-rw-r--r--test/rubygems/test_gem_ext_cargo_builder/custom_name/ext/custom_name_lib/Cargo.lock44
-rw-r--r--test/rubygems/test_gem_ext_cargo_builder/custom_name/ext/custom_name_lib/Cargo.toml2
-rw-r--r--test/rubygems/test_gem_ext_cargo_builder/custom_name/lib/custom_name.rb2
-rw-r--r--test/rubygems/test_gem_ext_cargo_builder/rust_ruby_example/Cargo.lock44
-rw-r--r--test/rubygems/test_gem_ext_cargo_builder/rust_ruby_example/Cargo.toml2
-rw-r--r--test/rubygems/test_gem_ext_cargo_builder/rust_ruby_example/rust_ruby_example.gemspec2
-rw-r--r--test/rubygems/test_gem_ext_cargo_builder_link_flag_converter.rb1
-rw-r--r--test/rubygems/test_gem_ext_cargo_builder_unit.rb2
-rw-r--r--test/rubygems/test_gem_ext_cmake_builder.rb13
-rw-r--r--test/rubygems/test_gem_ext_configure_builder.rb3
-rw-r--r--test/rubygems/test_gem_ext_ext_conf_builder.rb17
-rw-r--r--test/rubygems/test_gem_ext_rake_builder.rb23
-rw-r--r--test/rubygems/test_gem_gem_runner.rb10
-rw-r--r--test/rubygems/test_gem_gemcutter_utilities.rb217
-rw-r--r--test/rubygems/test_gem_impossible_dependencies_error.rb1
-rw-r--r--test/rubygems/test_gem_indexer.rb380
-rw-r--r--test/rubygems/test_gem_install_update_options.rb26
-rw-r--r--test/rubygems/test_gem_installer.rb304
-rw-r--r--test/rubygems/test_gem_local_remote_options.rb13
-rw-r--r--test/rubygems/test_gem_name_tuple.rb34
-rw-r--r--test/rubygems/test_gem_package.rb304
-rw-r--r--test/rubygems/test_gem_package_old.rb7
-rw-r--r--test/rubygems/test_gem_package_tar_header.rb66
-rw-r--r--test/rubygems/test_gem_package_tar_reader.rb69
-rw-r--r--test/rubygems/test_gem_package_tar_reader_entry.rb182
-rw-r--r--test/rubygems/test_gem_package_tar_writer.rb89
-rw-r--r--test/rubygems/test_gem_package_task.rb5
-rw-r--r--test/rubygems/test_gem_path_support.rb1
-rw-r--r--test/rubygems/test_gem_platform.rb23
-rw-r--r--test/rubygems/test_gem_rdoc.rb5
-rw-r--r--test/rubygems/test_gem_remote_fetcher.rb243
-rw-r--r--test/rubygems/test_gem_request.rb121
-rw-r--r--test/rubygems/test_gem_request_connection_pools.rb25
-rw-r--r--test/rubygems/test_gem_request_set.rb59
-rw-r--r--test/rubygems/test_gem_request_set_gem_dependency_api.rb181
-rw-r--r--test/rubygems/test_gem_request_set_lockfile.rb1
-rw-r--r--test/rubygems/test_gem_request_set_lockfile_parser.rb21
-rw-r--r--test/rubygems/test_gem_request_set_lockfile_tokenizer.rb1
-rw-r--r--test/rubygems/test_gem_requirement.rb19
-rw-r--r--test/rubygems/test_gem_resolver.rb81
-rw-r--r--test/rubygems/test_gem_resolver_activation_request.rb15
-rw-r--r--test/rubygems/test_gem_resolver_api_set.rb112
-rw-r--r--test/rubygems/test_gem_resolver_api_specification.rb69
-rw-r--r--test/rubygems/test_gem_resolver_best_set.rb41
-rw-r--r--test/rubygems/test_gem_resolver_composed_set.rb1
-rw-r--r--test/rubygems/test_gem_resolver_conflict.rb11
-rw-r--r--test/rubygems/test_gem_resolver_dependency_request.rb25
-rw-r--r--test/rubygems/test_gem_resolver_git_set.rb19
-rw-r--r--test/rubygems/test_gem_resolver_git_specification.rb8
-rw-r--r--test/rubygems/test_gem_resolver_index_set.rb29
-rw-r--r--test/rubygems/test_gem_resolver_index_specification.rb10
-rw-r--r--test/rubygems/test_gem_resolver_installed_specification.rb1
-rw-r--r--test/rubygems/test_gem_resolver_installer_set.rb23
-rw-r--r--test/rubygems/test_gem_resolver_local_specification.rb1
-rw-r--r--test/rubygems/test_gem_resolver_lock_set.rb7
-rw-r--r--test/rubygems/test_gem_resolver_lock_specification.rb15
-rw-r--r--test/rubygems/test_gem_resolver_requirement_list.rb1
-rw-r--r--test/rubygems/test_gem_resolver_specification.rb3
-rw-r--r--test/rubygems/test_gem_resolver_vendor_set.rb1
-rw-r--r--test/rubygems/test_gem_resolver_vendor_specification.rb4
-rw-r--r--test/rubygems/test_gem_safe_marshal.rb404
-rw-r--r--test/rubygems/test_gem_safe_yaml.rb24
-rw-r--r--test/rubygems/test_gem_security.rb61
-rw-r--r--test/rubygems/test_gem_security_policy.rb60
-rw-r--r--test/rubygems/test_gem_security_signer.rb19
-rw-r--r--test/rubygems/test_gem_security_trust_dir.rb19
-rw-r--r--test/rubygems/test_gem_silent_ui.rb4
-rw-r--r--test/rubygems/test_gem_source.rb41
-rw-r--r--test/rubygems/test_gem_source_fetch_problem.rb1
-rw-r--r--test/rubygems/test_gem_source_git.rb34
-rw-r--r--test/rubygems/test_gem_source_installed.rb5
-rw-r--r--test/rubygems/test_gem_source_list.rb5
-rw-r--r--test/rubygems/test_gem_source_local.rb5
-rw-r--r--test/rubygems/test_gem_source_lock.rb11
-rw-r--r--test/rubygems/test_gem_source_specific_file.rb5
-rw-r--r--test/rubygems/test_gem_source_subpath_problem.rb7
-rw-r--r--test/rubygems/test_gem_source_vendor.rb5
-rw-r--r--test/rubygems/test_gem_spec_fetcher.rb15
-rw-r--r--test/rubygems/test_gem_specification.rb433
-rw-r--r--test/rubygems/test_gem_stream_ui.rb53
-rw-r--r--test/rubygems/test_gem_stub_specification.rb3
-rw-r--r--test/rubygems/test_gem_text.rb1
-rw-r--r--test/rubygems/test_gem_uninstaller.rb105
-rw-r--r--test/rubygems/test_gem_unsatisfiable_dependency_error.rb1
-rw-r--r--test/rubygems/test_gem_update_suggestion.rb153
-rw-r--r--test/rubygems/test_gem_uri.rb2
-rw-r--r--test/rubygems/test_gem_uri_formatter.rb1
-rw-r--r--test/rubygems/test_gem_util.rb7
-rw-r--r--test/rubygems/test_gem_version.rb7
-rw-r--r--test/rubygems/test_gem_version_option.rb49
-rw-r--r--test/rubygems/test_kernel.rb31
-rw-r--r--test/rubygems/test_project_sanity.rb35
-rw-r--r--test/rubygems/test_remote_fetch_error.rb5
-rw-r--r--test/rubygems/test_require.rb99
-rw-r--r--test/rubygems/test_rubygems.rb12
-rw-r--r--test/rubygems/test_webauthn_listener.rb143
-rw-r--r--test/rubygems/test_webauthn_listener_response.rb93
-rw-r--r--test/rubygems/test_webauthn_poller.rb124
-rw-r--r--test/rubygems/utilities.rb73
-rw-r--r--test/runner.rb13
-rw-r--r--test/set/fixtures/fake_sorted_set_gem/sorted_set.rb (renamed from test/fixtures/fake_sorted_set_gem/sorted_set.rb)0
-rw-r--r--test/set/test_set.rb892
-rw-r--r--test/set/test_sorted_set.rb (renamed from test/test_sorted_set.rb)0
-rw-r--r--test/socket/test_addrinfo.rb4
-rw-r--r--test/socket/test_socket.rb36
-rw-r--r--test/socket/test_tcp.rb2
-rw-r--r--test/socket/test_unix.rb68
-rw-r--r--test/stringio/test_stringio.rb38
-rw-r--r--test/strscan/test_stringscanner.rb56
-rw-r--r--test/test_extlibs.rb2
-rw-r--r--test/test_ipaddr.rb20
-rw-r--r--test/test_open3.rb10
-rw-r--r--test/test_pp.rb13
-rw-r--r--test/test_set.rb879
-rw-r--r--test/test_singleton.rb21
-rw-r--r--test/test_tempfile.rb27
-rw-r--r--test/test_time.rb9
-rw-r--r--test/test_timeout.rb110
-rw-r--r--test/test_tmpdir.rb16
-rw-r--r--test/test_trick.rb59
-rw-r--r--test/test_unicode_normalize.rb2
-rw-r--r--test/uri/test_common.rb19
-rw-r--r--test/uri/test_ftp.rb10
-rw-r--r--test/uri/test_generic.rb4
-rw-r--r--test/uri/test_http.rb8
-rw-r--r--test/uri/test_ldap.rb8
-rw-r--r--test/uri/test_parser.rb30
-rw-r--r--test/uri/test_ws.rb8
-rw-r--r--test/uri/test_wss.rb8
-rw-r--r--test/win32ole/test_win32ole.rb2
-rw-r--r--test/zlib/test_zlib.rb11
-rw-r--r--thread.c814
-rw-r--r--thread_none.c60
-rw-r--r--thread_none.h1
-rw-r--r--thread_pthread.c3269
-rw-r--r--thread_pthread.h121
-rw-r--r--thread_pthread_mn.c1046
-rw-r--r--thread_sync.c199
-rw-r--r--thread_win32.c198
-rw-r--r--thread_win32.h7
-rw-r--r--time.c374
-rw-r--r--timev.h11
-rw-r--r--timev.rb65
-rw-r--r--tool/bundler/dev_gems.rb9
-rw-r--r--tool/bundler/dev_gems.rb.lock57
-rw-r--r--tool/bundler/rubocop_gems.rb2
-rw-r--r--tool/bundler/rubocop_gems.rb.lock73
-rw-r--r--tool/bundler/standard_gems.rb.lock81
-rw-r--r--tool/bundler/test_gems.rb10
-rw-r--r--tool/bundler/test_gems.rb.lock45
-rw-r--r--tool/bundler/vendor_gems.rb15
-rw-r--r--tool/bundler/vendor_gems.rb.lock71
-rw-r--r--tool/ci_functions.sh29
-rwxr-xr-xtool/darwin-ar1
-rwxr-xr-xtool/darwin-cc3
-rw-r--r--tool/downloader.rb1
-rw-r--r--tool/dummy-rake-compiler/rake/extensiontask.rb9
-rwxr-xr-xtool/enc-case-folding.rb6
-rwxr-xr-xtool/enc-unicode.rb101
-rwxr-xr-xtool/extlibs.rb2
-rw-r--r--tool/fake.rb9
-rwxr-xr-xtool/fetch-bundled_gems.rb9
-rwxr-xr-xtool/format-release4
-rwxr-xr-xtool/gen-github-release.rb59
-rwxr-xr-xtool/leaked-globals40
-rw-r--r--tool/lib/bundled_gem.rb43
-rw-r--r--tool/lib/colorize.rb32
-rw-r--r--tool/lib/core_assertions.rb103
-rw-r--r--tool/lib/envutil.rb48
-rw-r--r--tool/lib/iseq_loader_checker.rb9
-rw-r--r--tool/lib/leakchecker.rb5
-rw-r--r--tool/lib/memory_status.rb2
-rw-r--r--tool/lib/output.rb12
-rw-r--r--tool/lib/test/unit.rb112
-rw-r--r--tool/lib/test/unit/parallel.rb12
-rw-r--r--tool/lib/test/unit/testcase.rb19
-rw-r--r--tool/lib/vcs.rb59
-rwxr-xr-xtool/ln_sr.rb2
-rw-r--r--tool/lrama/LEGAL.md12
-rw-r--r--tool/lrama/MIT21
-rw-r--r--tool/lrama/NEWS.md167
-rwxr-xr-xtool/lrama/exe/lrama6
-rw-r--r--tool/lrama/lib/lrama.rb17
-rw-r--r--tool/lrama/lib/lrama/bitmap.rb29
-rw-r--r--tool/lrama/lib/lrama/command.rb46
-rw-r--r--tool/lrama/lib/lrama/context.rb517
-rw-r--r--tool/lrama/lib/lrama/counterexamples.rb286
-rw-r--r--tool/lrama/lib/lrama/counterexamples/derivation.rb63
-rw-r--r--tool/lrama/lib/lrama/counterexamples/example.rb124
-rw-r--r--tool/lrama/lib/lrama/counterexamples/path.rb23
-rw-r--r--tool/lrama/lib/lrama/counterexamples/production_path.rb17
-rw-r--r--tool/lrama/lib/lrama/counterexamples/start_path.rb21
-rw-r--r--tool/lrama/lib/lrama/counterexamples/state_item.rb6
-rw-r--r--tool/lrama/lib/lrama/counterexamples/transition_path.rb17
-rw-r--r--tool/lrama/lib/lrama/counterexamples/triple.rb21
-rw-r--r--tool/lrama/lib/lrama/digraph.rb51
-rw-r--r--tool/lrama/lib/lrama/grammar.rb612
-rw-r--r--tool/lrama/lib/lrama/grammar/auxiliary.rb7
-rw-r--r--tool/lrama/lib/lrama/grammar/code.rb38
-rw-r--r--tool/lrama/lib/lrama/grammar/code/initial_action_code.rb28
-rw-r--r--tool/lrama/lib/lrama/grammar/code/no_reference_code.rb24
-rw-r--r--tool/lrama/lib/lrama/grammar/code/printer_code.rb34
-rw-r--r--tool/lrama/lib/lrama/grammar/code/rule_action.rb78
-rw-r--r--tool/lrama/lib/lrama/grammar/counter.rb15
-rw-r--r--tool/lrama/lib/lrama/grammar/error_token.rb9
-rw-r--r--tool/lrama/lib/lrama/grammar/parameterizing_rules/builder.rb60
-rw-r--r--tool/lrama/lib/lrama/grammar/parameterizing_rules/builder/base.rb36
-rw-r--r--tool/lrama/lib/lrama/grammar/parameterizing_rules/builder/list.rb28
-rw-r--r--tool/lrama/lib/lrama/grammar/parameterizing_rules/builder/nonempty_list.rb28
-rw-r--r--tool/lrama/lib/lrama/grammar/parameterizing_rules/builder/option.rb28
-rw-r--r--tool/lrama/lib/lrama/grammar/parameterizing_rules/builder/separated_list.rb39
-rw-r--r--tool/lrama/lib/lrama/grammar/parameterizing_rules/builder/separated_nonempty_list.rb34
-rw-r--r--tool/lrama/lib/lrama/grammar/percent_code.rb12
-rw-r--r--tool/lrama/lib/lrama/grammar/precedence.rb11
-rw-r--r--tool/lrama/lib/lrama/grammar/printer.rb9
-rw-r--r--tool/lrama/lib/lrama/grammar/reference.rb13
-rw-r--r--tool/lrama/lib/lrama/grammar/rule.rb56
-rw-r--r--tool/lrama/lib/lrama/grammar/rule_builder.rb177
-rw-r--r--tool/lrama/lib/lrama/grammar/symbol.rb101
-rw-r--r--tool/lrama/lib/lrama/grammar/type.rb6
-rw-r--r--tool/lrama/lib/lrama/grammar/union.rb10
-rw-r--r--tool/lrama/lib/lrama/lexer.rb174
-rw-r--r--tool/lrama/lib/lrama/lexer/location.rb22
-rw-r--r--tool/lrama/lib/lrama/lexer/token.rb51
-rw-r--r--tool/lrama/lib/lrama/lexer/token/char.rb8
-rw-r--r--tool/lrama/lib/lrama/lexer/token/ident.rb8
-rw-r--r--tool/lrama/lib/lrama/lexer/token/parameterizing.rb34
-rw-r--r--tool/lrama/lib/lrama/lexer/token/tag.rb12
-rw-r--r--tool/lrama/lib/lrama/lexer/token/user_code.rb64
-rw-r--r--tool/lrama/lib/lrama/option_parser.rb128
-rw-r--r--tool/lrama/lib/lrama/options.rb23
-rw-r--r--tool/lrama/lib/lrama/output.rb417
-rw-r--r--tool/lrama/lib/lrama/parser.rb1934
-rw-r--r--tool/lrama/lib/lrama/report.rb2
-rw-r--r--tool/lrama/lib/lrama/report/duration.rb25
-rw-r--r--tool/lrama/lib/lrama/report/profile.rb14
-rw-r--r--tool/lrama/lib/lrama/state.rb166
-rw-r--r--tool/lrama/lib/lrama/state/reduce.rb35
-rw-r--r--tool/lrama/lib/lrama/state/reduce_reduce_conflict.rb9
-rw-r--r--tool/lrama/lib/lrama/state/resolved_conflict.rb29
-rw-r--r--tool/lrama/lib/lrama/state/shift.rb13
-rw-r--r--tool/lrama/lib/lrama/state/shift_reduce_conflict.rb9
-rw-r--r--tool/lrama/lib/lrama/states.rb556
-rw-r--r--tool/lrama/lib/lrama/states/item.rb79
-rw-r--r--tool/lrama/lib/lrama/states_reporter.rb323
-rw-r--r--tool/lrama/lib/lrama/version.rb3
-rw-r--r--tool/lrama/lib/lrama/warning.rb25
-rw-r--r--tool/lrama/template/bison/_yacc.h71
-rw-r--r--tool/lrama/template/bison/yacc.c2052
-rw-r--r--tool/lrama/template/bison/yacc.h40
-rw-r--r--tool/m4/ruby_default_arch.m421
-rw-r--r--tool/m4/ruby_stack_grow_direction.m42
-rw-r--r--tool/m4/ruby_universal_arch.m44
-rwxr-xr-xtool/make-snapshot42
-rwxr-xr-xtool/merger.rb7
-rwxr-xr-xtool/missing-baseruby.bat5
-rwxr-xr-xtool/mjit/bindgen.rb435
-rw-r--r--tool/mjit_archflag.sh40
-rw-r--r--tool/mjit_tabs.rb67
-rw-r--r--tool/mk_builtin_loader.rb79
-rwxr-xr-xtool/mkconfig.rb8
-rwxr-xr-xtool/rbinstall.rb11
-rw-r--r--tool/rbs_skip_tests25
-rwxr-xr-xtool/rjit/bindgen.rb663
-rw-r--r--tool/ruby_vm/helpers/c_escape.rb5
-rw-r--r--tool/ruby_vm/models/attribute.rb2
-rwxr-xr-xtool/ruby_vm/models/bare_instructions.rb16
-rw-r--r--tool/ruby_vm/models/c_expr.rb6
-rw-r--r--tool/ruby_vm/models/operands_unifications.rb8
-rw-r--r--tool/ruby_vm/views/_comptime_insn_stack_increase.erb2
-rw-r--r--tool/ruby_vm/views/_insn_entry.erb9
-rw-r--r--tool/ruby_vm/views/_leaf_helpers.erb2
-rw-r--r--tool/ruby_vm/views/lib/ruby_vm/mjit/instruction.rb.erb40
-rw-r--r--tool/ruby_vm/views/lib/ruby_vm/rjit/instruction.rb.erb14
-rw-r--r--tool/ruby_vm/views/mjit_sp_inc.inc.erb17
-rw-r--r--tool/ruby_vm/views/opt_sc.inc.erb40
-rw-r--r--tool/ruby_vm/views/optinsn.inc.erb4
-rw-r--r--tool/rubyspec_temp.rb13
-rwxr-xr-xtool/runruby.rb9
-rwxr-xr-xtool/sync_default_gems.rb499
-rw-r--r--tool/test-bundled-gems.rb24
-rw-r--r--tool/test/init.rb18
-rw-r--r--tool/test/runner.rb13
-rwxr-xr-xtool/test/test_sync_default_gems.rb221
-rw-r--r--tool/test/testunit/test4test_load_failure.rb1
-rw-r--r--tool/test/testunit/test4test_timeout.rb15
-rw-r--r--tool/test/testunit/test_hideskip.rb4
-rw-r--r--tool/test/testunit/test_load_failure.rb23
-rw-r--r--tool/test/testunit/test_parallel.rb27
-rw-r--r--tool/test/testunit/test_sorting.rb2
-rw-r--r--tool/test/testunit/test_timeout.rb10
-rw-r--r--tool/test/testunit/tests_for_parallel/slow_helper.rb7
-rw-r--r--tool/test/testunit/tests_for_parallel/test4test_slow_0.rb5
-rw-r--r--tool/test/testunit/tests_for_parallel/test4test_slow_1.rb5
-rw-r--r--tool/test/webrick/test_httpserver.rb2
-rw-r--r--tool/test/webrick/test_server.rb2
-rw-r--r--tool/test_for_warn_bundled_gems/.gitignore1
-rw-r--r--tool/test_for_warn_bundled_gems/Gemfile0
-rw-r--r--tool/test_for_warn_bundled_gems/Gemfile.lock11
-rw-r--r--tool/test_for_warn_bundled_gems/README.md3
-rwxr-xr-xtool/test_for_warn_bundled_gems/test.sh31
-rw-r--r--tool/test_for_warn_bundled_gems/test_no_warn_bootsnap.rb11
-rw-r--r--tool/test_for_warn_bundled_gems/test_no_warn_dash_gem.rb8
-rw-r--r--tool/test_for_warn_bundled_gems/test_no_warn_dependency.rb10
-rw-r--r--tool/test_for_warn_bundled_gems/test_no_warn_sub_feature.rb8
-rw-r--r--tool/test_for_warn_bundled_gems/test_warn_bundle_exec.rb1
-rwxr-xr-xtool/test_for_warn_bundled_gems/test_warn_bundle_exec_shebang.rb3
-rw-r--r--tool/test_for_warn_bundled_gems/test_warn_bundled_gems.rb8
-rw-r--r--tool/test_for_warn_bundled_gems/test_warn_dash_gem.rb7
-rw-r--r--tool/test_for_warn_bundled_gems/test_warn_dependency.rb8
-rw-r--r--tool/test_for_warn_bundled_gems/test_warn_sub_feature.rb7
-rw-r--r--tool/transform_mjit_header.rb319
-rwxr-xr-xtool/update-NEWS-gemlist.rb12
-rwxr-xr-xtool/update-bundled_gems.rb39
-rwxr-xr-xtool/update-deps50
-rwxr-xr-xtool/ytab.sed80
-rw-r--r--trace_point.rb14
-rw-r--r--transcode.c32
-rw-r--r--transient_heap.c991
-rw-r--r--transient_heap.h65
-rw-r--r--universal_parser.c375
-rw-r--r--util.c15
-rw-r--r--variable.c1196
-rw-r--r--variable.h16
-rw-r--r--version.c96
-rw-r--r--version.h14
-rw-r--r--vm.c770
-rw-r--r--vm_args.c173
-rw-r--r--vm_backtrace.c155
-rw-r--r--vm_callinfo.h126
-rw-r--r--vm_core.h306
-rw-r--r--vm_dump.c428
-rw-r--r--vm_eval.c168
-rw-r--r--vm_exec.c59
-rw-r--r--vm_exec.h36
-rw-r--r--vm_insnhelper.c1486
-rw-r--r--vm_insnhelper.h31
-rw-r--r--vm_method.c354
-rw-r--r--vm_opts.h6
-rw-r--r--vm_sync.c123
-rw-r--r--vm_trace.c439
-rw-r--r--vsnprintf.c4
-rw-r--r--wasm/runtime.c7
-rw-r--r--wasm/setjmp.c69
-rw-r--r--wasm/setjmp.h2
-rw-r--r--weakmap.c1113
-rw-r--r--win32/.document1
-rw-r--r--win32/Makefile.sub72
-rw-r--r--win32/file.c27
-rw-r--r--win32/file.h3
-rwxr-xr-xwin32/mkexports.rb4
-rw-r--r--win32/setup.mak4
-rw-r--r--win32/win32.c277
-rw-r--r--yjit.c212
-rw-r--r--yjit.h24
-rw-r--r--yjit.rb377
-rw-r--r--yjit/Cargo.lock7
-rw-r--r--yjit/Cargo.toml9
-rw-r--r--yjit/bindgen/Cargo.lock159
-rw-r--r--yjit/bindgen/Cargo.toml2
-rw-r--r--yjit/bindgen/src/main.rs58
-rw-r--r--yjit/src/asm/arm64/arg/bitmask_imm.rs2
-rw-r--r--yjit/src/asm/arm64/arg/condition.rs2
-rw-r--r--yjit/src/asm/arm64/inst/madd.rs73
-rw-r--r--yjit/src/asm/arm64/inst/mod.rs4
-rw-r--r--yjit/src/asm/arm64/inst/smulh.rs60
-rw-r--r--yjit/src/asm/arm64/mod.rs36
-rw-r--r--yjit/src/asm/mod.rs240
-rw-r--r--yjit/src/asm/x86_64/mod.rs80
-rw-r--r--yjit/src/asm/x86_64/tests.rs18
-rw-r--r--yjit/src/backend/arm64/mod.rs571
-rw-r--r--yjit/src/backend/ir.rs650
-rw-r--r--yjit/src/backend/mod.rs6
-rw-r--r--yjit/src/backend/tests.rs47
-rw-r--r--yjit/src/backend/x86_64/mod.rs596
-rw-r--r--yjit/src/codegen.rs6758
-rw-r--r--yjit/src/core.rs2906
-rw-r--r--yjit/src/cruby.rs99
-rw-r--r--yjit/src/cruby_bindings.inc.rs760
-rw-r--r--yjit/src/disasm.rs142
-rw-r--r--yjit/src/invariants.rs225
-rw-r--r--yjit/src/options.rs187
-rw-r--r--yjit/src/stats.rs483
-rw-r--r--yjit/src/utils.rs26
-rw-r--r--yjit/src/virtualmem.rs107
-rw-r--r--yjit/src/yjit.rs133
-rw-r--r--yjit/yjit.mk26
5507 files changed, 329757 insertions, 185561 deletions
diff --git a/.appveyor.yml b/.appveyor.yml
deleted file mode 100644
index 6803edff9b..0000000000
--- a/.appveyor.yml
+++ /dev/null
@@ -1,131 +0,0 @@
----
-version: '{build}'
-init:
- - git config --global user.name git
- - git config --global user.email svn-admin@ruby-lang.org
- - git config --global core.autocrlf false
- - git config --global core.eol lf
- - git config --global advice.detachedHead 0
-shallow_clone: true
-clone_depth: 10
-platform:
- - x64
-skip_commits:
- message: /\[DOC\]/
- files:
- - doc/*
- - '**/*.md'
- - '**/*.rdoc'
- - '**/.document'
- - '**/*.[1-8]'
- - '**/*.ronn'
-environment:
- ruby_version: "24-%Platform%"
- matrix:
- # Test only the oldest supported version because AppVeyor is unstable, its concurrency
- # is limited, and compatibility issues that happen only in newer versions are rare.
- # You may test some other stuff on GitHub Actions instead.
- - build: vs
- vs: 120
- ssl: OpenSSL-v111
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
- GEMS_FOR_TEST: ""
- RELINE_TEST_ENCODING: "UTF-8"
-cache:
- - c:\Tools\vcpkg\installed\
-for:
--
- matrix:
- only:
- - build: vs
- install:
- - ver
- - chcp
- - SET BITS=%Platform:x86=32%
- - SET BITS=%BITS:x=%
- - SET OPENSSL_DIR=C:\%ssl%-Win%BITS%
- - cd C:\Tools\vcpkg
- - git pull -q
- - .\bootstrap-vcpkg.bat
- - cd %APPVEYOR_BUILD_FOLDER%
- - vcpkg --triplet %Platform%-windows install --x-use-aria2 libffi libyaml readline zlib
- - CALL SET vcvars=%%^VS%VS%COMNTOOLS^%%..\..\VC\vcvarsall.bat
- - SET vcvars
- - '"%vcvars%" %Platform:x64=amd64%'
- - SET ruby_path=C:\Ruby%ruby_version:-x86=%
- - SET PATH=\usr\local\bin;%ruby_path%\bin;%PATH%;C:\msys64\mingw64\bin;C:\msys64\usr\bin
- - ruby --version
- - 'cl'
- - echo> Makefile srcdir=.
- - echo>> Makefile MSC_VER=0
- - echo>> Makefile RT=none
- - echo>> Makefile RT_VER=0
- - echo>> Makefile BUILTIN_ENCOBJS=nul
- - type win32\Makefile.sub >> Makefile
- - nmake %mflags% up VCSUP="echo Update OK"
- - nmake %mflags% extract-extlibs
- - del Makefile
- - mkdir \usr\local\bin
- - mkdir \usr\local\include
- - mkdir \usr\local\lib
- - for %%I in (%OPENSSL_DIR%\*.dll) do mklink /h \usr\local\bin\%%~nxI %%I
- - for %%I in (c:\Tools\vcpkg\installed\%Platform%-windows\bin\*.dll) do (
- if not %%~nI == readline mklink \usr\local\bin\%%~nxI %%I
- )
- - attrib +r /s /d
- - mkdir %Platform%-mswin_%vs%
- build_script:
- - cd %APPVEYOR_BUILD_FOLDER%
- - cd %Platform%-mswin_%vs%
- - >-
- ..\win32\configure.bat
- --with-opt-dir="/usr/local;c:/Tools/vcpkg/installed/%Platform%-windows"
- --with-openssl-dir=%OPENSSL_DIR:\=/%
- - nmake -l
- - nmake install-nodoc
- - \usr\bin\ruby -v -e "p :locale => Encoding.find('locale'), :filesystem => Encoding.find('filesystem')"
- - if not "%GEMS_FOR_TEST%" == "" \usr\bin\gem install --no-document %GEMS_FOR_TEST%
- - \usr\bin\ruby -ropenssl -e "puts 'Build ' + OpenSSL::OPENSSL_VERSION, 'Runtime ' + OpenSSL::OPENSSL_LIBRARY_VERSION"
- test_script:
- - set /a JOBS=%NUMBER_OF_PROCESSORS%
- - nmake -l "TESTOPTS=-v -q" btest
- - nmake -l "TESTOPTS=-v -q" test-basic
- - >-
- nmake -l "TESTOPTS=-v --timeout-scale=3.0
- --excludes=../test/excludes/_appveyor -j%JOBS%
- --exclude win32ole
- --exclude test_bignum
- --exclude test_syntax
- --exclude test_open-uri
- --exclude test_bundled_ca
- " test-all
- # separately execute tests without -j which may crash worker with -j.
- - >-
- nmake -l
- "TESTOPTS=-v --timeout-scale=3.0 --excludes=../test/excludes/_appveyor"
- TESTS="
- ../test/win32ole
- ../test/ruby/test_bignum.rb
- ../test/ruby/test_syntax.rb
- ../test/open-uri/test_open-uri.rb
- ../test/rubygems/test_bundled_ca.rb
- " test-all
- - nmake -l test-spec MSPECOPT=-fs # not using `-j` because sometimes `mspec -j` silently dies on Windows
-notifications:
- - provider: Webhook
- method: POST
- url:
- secure: CcFlJNDJ/a6to7u3Z4Fnz6dScEPNx7hTha2GkSRlV+1U6dqmxY/7uBcLXYb9gR3jfQk6w+2o/HrjNAyXMNGU/JOka3s2WRI4VKitzM+lQ08owvJIh0R7LxrGH0J2e81U # ruby-lang slack: ruby/simpler-alerts-bot
- body: >-
- {{^isPullRequest}}
- {
- "ci": "AppVeyor CI",
- "env": "Visual Studio 2013",
- "url": "{{buildUrl}}",
- "commit": "{{commitId}}",
- "branch": "{{branch}}"
- }
- {{/isPullRequest}}
- on_build_success: false
- on_build_failure: true
- on_build_status_changed: false
diff --git a/.cirrus.yml b/.cirrus.yml
deleted file mode 100644
index 20c14f375c..0000000000
--- a/.cirrus.yml
+++ /dev/null
@@ -1,134 +0,0 @@
-# This CI is used to test Arm cases. We can set the maximum 16 tasks.
-# The entire testing design is inspired from .github/workflows/compilers.yml.
-
-# By default, Cirrus mounts an empty volume to `/tmp`
-# which triggers all sorts of warnings like "system temporary path is world-writable: /tmp".
-# Lets workaround it by specifying a custom volume mount point.
-env:
- CIRRUS_VOLUME: /cirrus-ci-volume
- LANG: C.UTF-8
-
-task:
- name: Arm64 Graviton2 / $CC
- skip: "changesIncludeOnly('doc/**', '**.{md,rdoc,ronn,[1-8]}', '.document')"
- arm_container:
- # We use the arm64 images at https://github.com/ruby/ruby-ci-image/pkgs/container/ruby-ci-image .
- image: ghcr.io/ruby/ruby-ci-image:$CC
- # Define the used cpu core in each matrix task. We can use total 16 cpu
- # cores in entire matrix. [cpu] = [total cpu: 16] / [number of tasks]
- cpu: 8
- # We can request maximum 4 GB per cpu.
- # [memory per task] = [memory per cpu: 4 GB] * [cpu]
- memory: 32G
- env:
- CIRRUS_CLONE_DEPTH: 50
- optflags: '-O1'
- debugflags: '-ggdb3'
- RUBY_PREFIX: /tmp/ruby-prefix
- RUBY_DEBUG: ci rgengc
- RUBY_TESTOPTS: >-
- -q
- --color=always
- --tty=no
- matrix:
- CC: clang-12
- CC: gcc-11
- id_script: id
- set_env_script:
- # Set `GNUMAKEFLAGS`, because the flags are GNU make specific. Note using
- # the `make` environment variable used in compilers.yml causes some rubygems
- # tests to fail.
- # https://github.com/rubygems/rubygems/issues/4921
- - echo "GNUMAKEFLAGS=-s -j$((1 + $CIRRUS_CPU))" >> "$CIRRUS_ENV"
- - cat "$CIRRUS_ENV"
- # Arm containers are executed in AWS's EKS, and it's not yet supporting IPv6
- # See https://github.com/aws/containers-roadmap/issues/835
- disable_ipv6_script: sudo ./tool/disable_ipv6.sh
- autogen_script: ./autogen.sh
- configure_script: >-
- ./configure -C
- --enable-debug-env
- --disable-install-doc
- --with-ext=-test-/cxxanyargs,+
- --prefix="$RUBY_PREFIX"
- make_extract-extlibs_script: make extract-extlibs
- make_incs_script: make incs
- make_script: make
- make_leaked-globals_script: make leaked-globals
- make_test_script: make test
- make_install_script: make install
- install_gems_for_test_script: $RUBY_PREFIX/bin/gem install --no-doc timezone tzinfo
- make_test-tool_script: make test-tool
- make_test-all_script: make test-all
- make_test-spec_script: make test-spec
-
-# The following is to test YJIT on ARM64 CPUs available on Cirrus CI
-yjit_task:
- name: Arm64 Graviton2 / $CC YJIT
- auto_cancellation: $CIRRUS_BRANCH != 'master'
- skip: "changesIncludeOnly('doc/**', '**.{md,rdoc,ronn,[1-8]}', '.document')"
- arm_container:
- # We use the arm64 images at https://github.com/ruby/ruby-ci-image/pkgs/container/ruby-ci-image .
- image: ghcr.io/ruby/ruby-ci-image:$CC
- # Define the used cpu core in each matrix task. We can use total 16 cpu
- # cores in entire matrix. [cpu] = [total cpu: 16] / [number of tasks]
- cpu: 8
- # We can request maximum 4 GB per cpu.
- # [memory per task] = [memory per cpu: 4 GB] * [cpu]
- memory: 32G
- env:
- CIRRUS_CLONE_DEPTH: 50
- optflags: '-O1'
- debugflags: '-ggdb3'
- RUBY_PREFIX: /tmp/ruby-prefix
- RUBY_DEBUG: ci rgengc
- RUBY_TESTOPTS: >-
- -q
- --color=always
- --tty=no
- matrix:
- - CC: clang-12
- configure: --enable-yjit=dev
- rustup_init: --default-toolchain=1.58.0
- - CC: gcc-11
- configure: --enable-yjit
- id_script: id
- set_env_script:
- # Set `GNUMAKEFLAGS`, because the flags are GNU make specific. Note using
- # the `make` environment variable used in compilers.yml causes some rubygems
- # tests to fail.
- # https://github.com/rubygems/rubygems/issues/4921
- - echo "GNUMAKEFLAGS=-s -j$((1 + $CIRRUS_CPU))" >> "$CIRRUS_ENV"
- - echo RUST_BACKTRACE=1 >> "$CIRRUS_ENV"
- - cat "$CIRRUS_ENV"
- # Arm containers are executed in AWS's EKS, and it's not yet supporting IPv6
- # See https://github.com/aws/containers-roadmap/issues/835
- disable_ipv6_script: sudo ./tool/disable_ipv6.sh
- install_rust_script:
- - sudo apt-get update -y
- - sudo apt-get install -y curl
- - "curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y $rustup_init"
- autogen_script: ./autogen.sh
- configure_script: >-
- source $HOME/.cargo/env && ./configure -C
- --enable-debug-env
- --disable-install-doc
- --with-ext=-test-/cxxanyargs,+
- --prefix="$RUBY_PREFIX"
- $configure
- make_miniruby_script: source $HOME/.cargo/env && make miniruby
- make_bindgen_script: |
- if [[ "$CC" = "clang-12" ]]; then
- source $HOME/.cargo/env && make yjit-bindgen
- else
- echo "only running bindgen on clang image"
- fi
- boot_miniruby_script: ./miniruby --yjit-call-threshold=1 -e0
- test_dump_insns_script: ./miniruby --yjit-call-threshold=1 --yjit-dump-insns -e0
- output_stats_script: ./miniruby --yjit-call-threshold=1 --yjit-stats -e0
- full_build_script: source $HOME/.cargo/env && make
- cargo_test_script: source $HOME/.cargo/env && cd yjit && cargo test
- make_test_script: source $HOME/.cargo/env && make test RUN_OPTS="--yjit-call-threshold=1 --yjit-verify-ctx"
- make_test_all_script: source $HOME/.cargo/env && make test-all RUN_OPTS="--yjit-call-threshold=1 --yjit-verify-ctx" TESTOPTS="$RUBY_TESTOPTS"
- make_test_spec_script: source $HOME/.cargo/env && make test-spec RUN_OPTS="--yjit-call-threshold=1 --yjit-verify-ctx"
- clippy_script: source $HOME/.cargo/env && cd yjit && cargo clippy --all-targets --all-features
diff --git a/.document b/.document
index 3a6b0c238c..e875e42546 100644
--- a/.document
+++ b/.document
@@ -18,7 +18,7 @@ gc.rb
io.rb
kernel.rb
marshal.rb
-mjit.rb
+rjit.rb
numeric.rb
nilclass.rb
pack.rb
@@ -48,7 +48,4 @@ COPYING.ja
LEGAL
-# win32/README.win32 linked from README.md
-win32
-
doc
diff --git a/.gdbinit b/.gdbinit
index 7657d240c5..7dd3336e28 100644
--- a/.gdbinit
+++ b/.gdbinit
@@ -67,7 +67,7 @@ define rp
printf "%sT_OBJECT%s: ", $color_type, $color_end
print ((struct RObject *)($arg0))->basic
if ($flags & ROBJECT_EMBED)
- print/x *((VALUE*)((struct RObject*)($arg0))->as.ary) @ (ROBJECT_EMBED_LEN_MAX+0)
+ print/x *((VALUE*)((struct RObject*)($arg0))->as.ary) @ (rb_shape_get_shape($arg0)->capacity)
else
print (((struct RObject *)($arg0))->as.heap)
if (((struct RObject*)($arg0))->as.heap.numiv) > 0
@@ -104,8 +104,8 @@ define rp
(($rsflags & (RUBY_FL_USER2|RUBY_FL_USER3|RUBY_FL_USER4|RUBY_FL_USER5|RUBY_FL_USER6)) >> RUBY_FL_USHIFT+2)
set print address off
output *(char *)(($rsflags & RUBY_FL_USER1) ? \
- ((struct RString*)$regsrc)->as.heap.ptr : \
- ((struct RString*)$regsrc)->as.ary) @ $len
+ ((struct RString*)$regsrc)->as.heap.ptr : \
+ ((struct RString*)$regsrc)->as.ary) @ $len
set print address on
printf " len:%ld ", $len
if $flags & RUBY_FL_USER6
@@ -126,26 +126,26 @@ define rp
printf "%sT_ARRAY%s: len=%ld ", $color_type, $color_end, $len
printf "(embed) "
if ($len == 0)
- printf "{(empty)} "
+ printf "{(empty)} "
else
- print/x *((VALUE*)((struct RArray*)($arg0))->as.ary) @ $len
- printf " "
+ print/x *((VALUE*)((struct RArray*)($arg0))->as.ary) @ $len
+ printf " "
end
else
set $len = ((struct RArray*)($arg0))->as.heap.len
printf "%sT_ARRAY%s: len=%ld ", $color_type, $color_end, $len
if ($flags & RUBY_FL_USER2)
- printf "(shared) shared="
- output/x ((struct RArray*)($arg0))->as.heap.aux.shared_root
- printf " "
+ printf "(shared) shared="
+ output/x ((struct RArray*)($arg0))->as.heap.aux.shared_root
+ printf " "
else
- printf "(ownership) capa=%ld ", ((struct RArray*)($arg0))->as.heap.aux.capa
+ printf "(ownership) capa=%ld ", ((struct RArray*)($arg0))->as.heap.aux.capa
end
if ($len == 0)
- printf "{(empty)} "
+ printf "{(empty)} "
else
- print/x *((VALUE*)((struct RArray*)($arg0))->as.heap.ptr) @ $len
- printf " "
+ print/x *((VALUE*)((struct RArray*)($arg0))->as.heap.ptr) @ $len
+ printf " "
end
end
print (struct RArray *)($arg0)
@@ -445,8 +445,8 @@ define output_string
(($flags & (RUBY_FL_USER2|RUBY_FL_USER3|RUBY_FL_USER4|RUBY_FL_USER5|RUBY_FL_USER6)) >> RUBY_FL_USHIFT+2)
if $len > 0
output *(char *)(($flags & RUBY_FL_USER1) ? \
- ((struct RString*)($arg0))->as.heap.ptr : \
- ((struct RString*)($arg0))->as.ary) @ $len
+ ((struct RString*)($arg0))->as.heap.ptr : \
+ ((struct RString*)($arg0))->as.ary) @ $len
else
output ""
end
@@ -459,8 +459,8 @@ define print_string
(($flags & (RUBY_FL_USER2|RUBY_FL_USER3|RUBY_FL_USER4|RUBY_FL_USER5|RUBY_FL_USER6)) >> RUBY_FL_USHIFT+2)
if $len > 0
printf "%s", *(char *)(($flags & RUBY_FL_USER1) ? \
- ((struct RString*)($arg0))->as.heap.ptr : \
- ((struct RString*)($arg0))->as.ary) @ $len
+ ((struct RString*)($arg0))->as.heap.ptr : \
+ ((struct RString*)($arg0))->as.ary) @ $len
end
end
@@ -689,11 +689,6 @@ define nd_stts
end
-define nd_entry
- printf "%su3.entry%s: ", $color_highlite, $color_end
- p ($arg0).u3.entry
-end
-
define nd_vid
printf "%su1.id%s: ", $color_highlite, $color_end
p ($arg0).u1.id
@@ -868,22 +863,22 @@ define rb_numtable_entry
set $rb_numtable_p = $rb_numtable_tbl->as.packed.bins
while $rb_numtable_p && $rb_numtable_p < $rb_numtable_tbl->as.packed.bins+$rb_numtable_tbl->num_entries
if $rb_numtable_p.k == $rb_numtable_id
- set $rb_numtable_key = $rb_numtable_p.k
- set $rb_numtable_rec = $rb_numtable_p.v
- set $rb_numtable_p = 0
+ set $rb_numtable_key = $rb_numtable_p.k
+ set $rb_numtable_rec = $rb_numtable_p.v
+ set $rb_numtable_p = 0
else
- set $rb_numtable_p = $rb_numtable_p + 1
+ set $rb_numtable_p = $rb_numtable_p + 1
end
end
else
set $rb_numtable_p = $rb_numtable_tbl->as.big.bins[st_numhash($rb_numtable_id) % $rb_numtable_tbl->num_bins]
while $rb_numtable_p
if $rb_numtable_p->key == $rb_numtable_id
- set $rb_numtable_key = $rb_numtable_p->key
- set $rb_numtable_rec = $rb_numtable_p->record
- set $rb_numtable_p = 0
+ set $rb_numtable_key = $rb_numtable_p->key
+ set $rb_numtable_rec = $rb_numtable_p->record
+ set $rb_numtable_p = 0
else
- set $rb_numtable_p = $rb_numtable_p->next
+ set $rb_numtable_p = $rb_numtable_p->next
end
end
end
@@ -961,7 +956,7 @@ define iseq
set $operand_size = ((INSN*)($arg0))->operand_size
set $operands = ((INSN*)($arg0))->operands
while $i < $operand_size
- rp $operands[$i++]
+ rp $operands[$i++]
end
end
end
@@ -1279,7 +1274,7 @@ document rb_count_objects
Counts all objects grouped by type.
end
-# Details: https://bugs.ruby-lang.org/projects/ruby-master/wiki/MachineInstructionsTraceWithGDB
+# Details: https://github.com/ruby/ruby/wiki/Machine-Instructions-Trace-with-GDB
define trace_machine_instructions
set logging enabled
set height 0
@@ -1348,3 +1343,5 @@ define print_flags
printf "RUBY_FL_USER17 : %s\n", ((struct RBasic*)($arg0))->flags & RUBY_FL_USER17 ? "1" : "0"
printf "RUBY_FL_USER18 : %s\n", ((struct RBasic*)($arg0))->flags & RUBY_FL_USER18 ? "1" : "0"
end
+
+source misc/gdb.py
diff --git a/.git-blame-ignore-revs b/.git-blame-ignore-revs
index 6c5eac5a0f..1bf7db40ad 100644
--- a/.git-blame-ignore-revs
+++ b/.git-blame-ignore-revs
@@ -5,6 +5,7 @@
# Expand tabs
5b21e94bebed90180d8ff63dad03b8b948361089
+c5e9af9c9d890578182a21e7b71b50334cd5579e
# Enable Style/StringLiterals cop for RubyGems/Bundler
d7ffd3fea402239b16833cc434404a7af82d44f3
@@ -21,3 +22,7 @@ f28287d34c03f472ffe90ea262bdde9affd4b965
# Make benchmark indentation consistent
fc4acf8cae82e5196186d3278d831f2438479d91
+
+# Make prism_compile.c indentation consistent
+40b2c8e5e7e6e5f83cee9276dc9c1922a69292d6
+d2c5867357ed88eccc28c2b3bd4a46e206e7ff85
diff --git a/.github/actions/setup/directories/action.yml b/.github/actions/setup/directories/action.yml
new file mode 100644
index 0000000000..359e5c0d37
--- /dev/null
+++ b/.github/actions/setup/directories/action.yml
@@ -0,0 +1,137 @@
+name: Setup directories etc.
+description: >-
+ Set up the source code and build directories (plus some
+ environmental tweaks)
+
+inputs:
+ srcdir:
+ required: false
+ default: ${{ github.workspace }}
+ description: >-
+ Directory to (re-)checkout source codes. This will be created
+ if absent. If there is no `configure` file that is also
+ generated inside.
+
+ builddir:
+ required: false
+ default: ${{ github.workspace }}
+ description: >-
+ Where binaries and other generated contents go. This will be
+ created if absent.
+
+ makeup:
+ required: false
+ type: boolean
+ # Note that `default: false` evaluates to a string constant
+ # `'false'`, which is a truthy value :sigh:
+ # https://github.com/actions/runner/issues/2238
+ default: ''
+ description: >-
+ If set to true, additionally runs `make up`.
+
+ checkout:
+ required: false
+ type: boolean
+ default: true
+ description: >-
+ If set to '' (false), skip running actions/checkout. This is useful when
+ you don't want to overwrite a GitHub token that is already set up.
+
+ dummy-files:
+ required: false
+ type: boolean
+ default: ''
+ description: >-
+ If set to true, creates dummy files in build dir.
+
+outputs: {} # nothing?
+
+runs:
+ using: composite
+
+ steps:
+ # Note that `shell: bash` works on both Windows and Linux, but not
+ # `shell: sh`. This is because GitHub hosted Windows runners have
+ # their bash manually installed.
+ - shell: bash
+ run: |
+ mkdir -p ${{ inputs.srcdir }}
+ mkdir -p ${{ inputs.builddir }}
+
+ # Did you know that actions/checkout works without git(1)? We are
+ # checking that here.
+ - id: which
+ shell: bash
+ run: |
+ echo "git=`command -v git`" >> "$GITHUB_OUTPUT"
+ echo "sudo=`command -v sudo`" >> "$GITHUB_OUTPUT"
+ echo "autoreconf=`command -v autoreconf`" >> "$GITHUB_OUTPUT"
+
+ - if: steps.which.outputs.git
+ shell: bash
+ run: |
+ git config --global core.autocrlf false
+ git config --global core.eol lf
+ git config --global advice.detachedHead 0
+ git config --global init.defaultBranch garbage
+
+ - if: inputs.checkout
+ uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
+ with:
+ path: ${{ inputs.srcdir }}
+
+ - uses: actions/cache@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8 # v3.3.1
+ with:
+ path: ${{ inputs.srcdir }}/.downloaded-cache
+ key: downloaded-cache
+
+ - if: steps.which.outputs.autoreconf
+ shell: bash
+ working-directory: ${{ inputs.srcdir }}
+ run: ./autogen.sh
+
+ # This is for MinGW.
+ - if: runner.os == 'Windows'
+ shell: bash
+ run: echo "GNUMAKEFLAGS=-j$((2 * NUMBER_OF_PROCESSORS))" >> $GITHUB_ENV
+
+ - if: runner.os == 'Linux'
+ shell: bash
+ run: echo "GNUMAKEFLAGS=-sj$((1 + $(nproc --all)))" >> "$GITHUB_ENV"
+
+ # macOS' GNU make is so old that they doesn't understand `GNUMAKEFLAGS`.
+ - if: runner.os == 'macOS'
+ shell: bash
+ run: echo "MAKEFLAGS=-j$((1 + $(sysctl -n hw.activecpu)))" >> "$GITHUB_ENV"
+
+ - if: inputs.makeup
+ shell: bash
+ working-directory: ${{ inputs.srcdir }}
+ run: |
+ touch config.status
+ touch .rbconfig.time
+ sed -f tool/prereq.status template/Makefile.in > Makefile
+ sed -f tool/prereq.status template/GNUmakefile.in > GNUmakefile
+ make up
+
+ # Cleanup, runs even on failure
+ - if: always() && inputs.makeup
+ shell: bash
+ working-directory: ${{ inputs.srcdir }}
+ run: rm -f config.status Makefile rbconfig.rb .rbconfig.time
+
+ - if: steps.which.outputs.sudo
+ shell: bash
+ run: |
+ sudo chmod -R go-w /usr/share
+ chmod -v go-w $HOME $HOME/.config || :
+ sudo bash -c 'IFS=:; for d in '"$PATH"'; do chmod -v go-w $d; done' || :
+
+ - if: inputs.dummy-files == 'true'
+ shell: bash
+ working-directory: ${{ inputs.builddir }}
+ run: |
+ : Create dummy files in build dir
+ for basename in {a..z} {A..Z} {0..9} foo bar test zzz; do
+ echo > ${basename}.rb "raise %(do not load ${basename}.rb)"
+ done
diff --git a/.github/actions/setup/macos/action.yml b/.github/actions/setup/macos/action.yml
new file mode 100644
index 0000000000..3649a64876
--- /dev/null
+++ b/.github/actions/setup/macos/action.yml
@@ -0,0 +1,24 @@
+name: Setup macOS environment
+description: >-
+ Installs necessary packages via Homebrew.
+
+inputs: {} # nothing?
+
+outputs: {} # nothing?
+
+runs:
+ using: composite
+
+ steps:
+ - name: brew
+ shell: bash
+ run: |
+ brew install --quiet gmp libffi openssl@1.1 zlib autoconf automake libtool readline
+
+ - name: Set ENV
+ shell: bash
+ run: |
+ for lib in openssl@1.1 readline; do
+ CONFIGURE_ARGS="${CONFIGURE_ARGS:+$CONFIGURE_ARGS }--with-${lib%@*}-dir=$(brew --prefix $lib)"
+ done
+ echo CONFIGURE_ARGS="${CONFIGURE_ARGS}" >> $GITHUB_ENV
diff --git a/.github/actions/setup/ubuntu/action.yml b/.github/actions/setup/ubuntu/action.yml
new file mode 100644
index 0000000000..a9e5b41951
--- /dev/null
+++ b/.github/actions/setup/ubuntu/action.yml
@@ -0,0 +1,53 @@
+name: Setup ubuntu environment
+description: >-
+ At the beginning there was no way but to copy & paste `apt-get`
+ everywhere. But now that we have composite actions, it seems better
+ merge them into one.
+
+inputs:
+ arch:
+ required: false
+ default: ''
+ description: >-
+ Architecture. Because we run this on a GitHub-hosted runner
+ acceptable value for this input is very limited.
+
+outputs:
+ arch:
+ value: ${{ steps.uname.outputs.uname }}
+ description: >-
+ Actual architecture. This could be different from the one
+ passed to the `inputs.arch`. For instance giving `i386` to this
+ action yields `i686`.
+
+runs:
+ using: composite
+
+ steps:
+ - name: set SETARCH
+ shell: bash
+ run: echo "SETARCH=${setarch}" >> "$GITHUB_ENV"
+ env:
+ setarch: ${{ inputs.arch && format('setarch {0} --', inputs.arch) }}
+
+ - id: uname
+ name: uname
+ shell: bash
+ run: |
+ echo uname=`${SETARCH} uname -m` >> "$GITHUB_OUTPUT"
+ echo dpkg=`${SETARCH} uname -m | sed s/686/386/` >> "$GITHUB_OUTPUT"
+
+ - name: apt-get
+ shell: bash
+ env:
+ arch: ${{ inputs.arch && format(':{0}', steps.uname.outputs.dpkg) || '' }}
+ run: |
+ set -x
+ ${arch:+sudo dpkg --add-architecture ${arch#:}}
+ sudo apt-get update -qq || :
+ sudo apt-get install --no-install-recommends -qq -y -o=Dpkg::Use-Pty=0 \
+ ${arch:+cross}build-essential${arch/:/-} \
+ libssl-dev${arch} libyaml-dev${arch} libreadline6-dev${arch} \
+ zlib1g-dev${arch} libncurses5-dev${arch} libffi-dev${arch} \
+ autoconf ruby
+ sudo apt-get install -qq -y pkg-config${arch} || :
diff --git a/.github/actions/slack/action.yml b/.github/actions/slack/action.yml
new file mode 100644
index 0000000000..c98be085a8
--- /dev/null
+++ b/.github/actions/slack/action.yml
@@ -0,0 +1,39 @@
+name: Post a message to slack
+description: >-
+ We have our ruby/action-slack webhook. However its arguments are
+ bit verbose to be listed in every workflow files. Better merge them
+ into one.
+
+inputs:
+ SLACK_WEBHOOK_URL:
+ required: true
+ description: >-
+ The URL to post the payload. This is an input because it tends
+ to be stored in a secrets valut and a composite action cannot
+ look into one.
+
+ label:
+ required: false
+ description: >-
+ Human-readable description of the run, something like "DEBUG=1".
+ This need not be unique among runs.
+
+outputs: {} # Nothing?
+
+runs:
+ using: composite
+
+ steps:
+ - uses: ruby/action-slack@0bd85c72233cdbb6a0fe01d37aaeff1d21b5fce1 # v3.2.1
+ with:
+ payload: |
+ {
+ "ci": "GitHub Actions",
+ "env": "${{ github.workflow }}${{ inputs.label && format(' / {0}', inputs.label) }}",
+ "url": "https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}",
+ "commit": "${{ github.sha }}",
+ "branch": "${{ github.ref_name }}"
+ }
+ env:
+ SLACK_WEBHOOK_URL: ${{ inputs.SLACK_WEBHOOK_URL }}
+ if: ${{github.event_name == 'push' && startsWith(github.repository, 'ruby/')}}
diff --git a/.github/auto_request_review.yml b/.github/auto_request_review.yml
index f694a1c72f..8726df577d 100644
--- a/.github/auto_request_review.yml
+++ b/.github/auto_request_review.yml
@@ -5,7 +5,6 @@ files:
'doc/yjit/*': [team:yjit]
'bootstraptest/test_yjit*': [team:yjit]
'test/ruby/test_yjit*': [team:yjit]
- '.github/workflows/yjit*': [team:yjit]
options:
ignore_draft: true
# This currently doesn't work as intended. We want to skip reviews when only
diff --git a/.github/codeql/codeql-config.yml b/.github/codeql/codeql-config.yml
deleted file mode 100644
index 91f82b842b..0000000000
--- a/.github/codeql/codeql-config.yml
+++ /dev/null
@@ -1,3 +0,0 @@
-name: "CodeQL config for the Ruby language"
-
-languages: cpp
diff --git a/.github/dependabot.yml b/.github/dependabot.yml
index bc63aca35b..70a73430d7 100644
--- a/.github/dependabot.yml
+++ b/.github/dependabot.yml
@@ -1,6 +1,6 @@
version: 2
updates:
- package-ecosystem: 'github-actions'
- directory: '/'
+ directory: '/.github'
schedule:
- interval: 'monthly'
+ interval: 'daily'
diff --git a/.github/workflows/annocheck.yml b/.github/workflows/annocheck.yml
new file mode 100644
index 0000000000..aa87166254
--- /dev/null
+++ b/.github/workflows/annocheck.yml
@@ -0,0 +1,126 @@
+name: Annocheck
+
+on:
+ push:
+ paths-ignore:
+ - 'doc/**'
+ - '**/man'
+ - '**.md'
+ - '**.rdoc'
+ - '**/.document'
+ - '.*.yml'
+ pull_request:
+ paths-ignore:
+ - 'doc/**'
+ - '**/man'
+ - '**.md'
+ - '**.rdoc'
+ - '**/.document'
+ - '.*.yml'
+ merge_group:
+ paths-ignore:
+ - 'doc/**'
+ - '**/man'
+ - '**.md'
+ - '**.rdoc'
+ - '**/.document'
+ - '.*.yml'
+
+concurrency:
+ group: ${{ github.workflow }} / ${{ startsWith(github.event_name, 'pull') && github.ref_name || github.sha }}
+ cancel-in-progress: ${{ startsWith(github.event_name, 'pull') }}
+
+permissions:
+ contents: read
+
+jobs:
+ compile:
+ name: gcc-11 annocheck
+
+ runs-on: ubuntu-latest
+
+ container:
+ image: ghcr.io/ruby/ruby-ci-image:gcc-11
+ options: --user root
+
+ if: >-
+ ${{!(false
+ || contains(github.event.head_commit.message, '[DOC]')
+ || contains(github.event.pull_request.title, '[DOC]')
+ || contains(github.event.pull_request.labels.*.name, 'Documentation')
+ || (github.event_name == 'push' && github.actor == 'dependabot[bot]')
+ )}}
+
+ env:
+ CONFIGURE_TTY: never
+ GITPULLOPTIONS: --no-tags origin ${{ github.ref }}
+ RUBY_DEBUG: ci rgengc
+ RUBY_TESTOPTS: >-
+ -q
+ --color=always
+ --tty=no
+ # FIXME: Drop skipping options
+ # https://bugs.ruby-lang.org/issues/18061
+ # https://sourceware.org/annobin/annobin.html/Test-pie.html
+ TEST_ANNOCHECK_OPTS: '--skip-pie --skip-gaps'
+
+ steps:
+ - run: id
+ working-directory:
+
+ - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
+ with:
+ sparse-checkout-cone-mode: false
+ sparse-checkout: /.github
+
+ - uses: ./.github/actions/setup/directories
+ with:
+ srcdir: src
+ builddir: build
+ makeup: true
+
+ # Minimal flags to pass the check.
+ # -g0 disables backtraces when SEGV. Do not set that.
+ - name: Run configure
+ run: >
+ ../src/configure -C
+ --enable-debug-env
+ --disable-install-doc
+ --with-ext=-test-/cxxanyargs,+
+ --without-valgrind
+ --without-jemalloc
+ --without-gmp
+ --with-gcc="gcc-11 -fcf-protection -Wa,--generate-missing-build-notes=yes"
+ --enable-shared
+ debugflags=-ggdb3
+ optflags=-O2
+ LDFLAGS=-Wl,-z,now
+
+ - run: make showflags
+
+ - run: make
+
+ - run: make test
+
+ - run: make install
+
+ - run: make test-tool
+
+ ### test-all doesn't work: https://github.com/ruby/ruby/actions/runs/4340112185/jobs/7578344307
+ # - run: make test-all TESTS='-- ruby -ext-'
+
+ ### test-spec doesn't work: https://github.com/ruby/ruby/actions/runs/4340193212/jobs/7578505652
+ # - run: make test-spec
+ # env:
+ # CHECK_LEAKS: true
+
+ - run: make test-annocheck
+
+ - uses: ./.github/actions/slack
+ with:
+ SLACK_WEBHOOK_URL: ${{ secrets.SIMPLER_ALERTS_URL }} # ruby-lang slack: ruby/simpler-alerts-bot
+ if: ${{ failure() }}
+
+defaults:
+ run:
+ working-directory: build
diff --git a/.github/workflows/auto_request_review.yml b/.github/workflows/auto_request_review.yml
index 340aae4391..998a6ea58a 100644
--- a/.github/workflows/auto_request_review.yml
+++ b/.github/workflows/auto_request_review.yml
@@ -10,10 +10,10 @@ jobs:
auto-request-review:
name: Auto Request Review
runs-on: ubuntu-latest
- if: ${{ github.repository == 'ruby/ruby' }}
+ if: ${{ github.repository == 'ruby/ruby' && github.base_ref == 'master' }}
steps:
- name: Request review based on files changes and/or groups the author belongs to
- uses: necojackarc/auto-request-review@5f91f424cabb3211c669e49e79da8363f7df395b # v0.10.0
+ uses: necojackarc/auto-request-review@6a51cebffe2c084705d9a7b394abd802e0119633 # v0.12.0
with:
# scope: public_repo
token: ${{ secrets.MATZBOT_GITHUB_TOKEN }}
diff --git a/.github/workflows/baseruby.yml b/.github/workflows/baseruby.yml
index 7ba87944c2..860d74aa1a 100644
--- a/.github/workflows/baseruby.yml
+++ b/.github/workflows/baseruby.yml
@@ -8,6 +8,7 @@ on:
- '**.md'
- '**.rdoc'
- '**/.document'
+ - '.*.yml'
pull_request:
paths-ignore:
- 'doc/**'
@@ -15,6 +16,15 @@ on:
- '**.md'
- '**.rdoc'
- '**/.document'
+ - '.*.yml'
+ merge_group:
+ paths-ignore:
+ - 'doc/**'
+ - '**/man'
+ - '**.md'
+ - '**.rdoc'
+ - '**/.document'
+ - '.*.yml'
concurrency:
group: ${{ github.workflow }} / ${{ startsWith(github.event_name, 'pull') && github.ref_name || github.sha }}
@@ -26,15 +36,21 @@ permissions:
jobs:
baseruby:
name: BASERUBY
+
runs-on: ubuntu-20.04
- if: ${{ !contains(github.event.head_commit.message, '[DOC]') && !contains(github.event.pull_request.labels.*.name, 'Documentation') }}
+
+ if: >-
+ ${{!(false
+ || contains(github.event.head_commit.message, '[DOC]')
+ || contains(github.event.pull_request.title, '[DOC]')
+ || contains(github.event.pull_request.labels.*.name, 'Documentation')
+ || (github.event_name == 'push' && github.actor == 'dependabot[bot]')
+ )}}
+
strategy:
matrix:
ruby:
- - ruby-2.2
-# - ruby-2.3
-# - ruby-2.4
-# - ruby-2.5
+ - ruby-2.5
# - ruby-2.6
# - ruby-2.7
- ruby-3.0
@@ -42,33 +58,27 @@ jobs:
- ruby-3.2
steps:
- - uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
- - uses: actions/cache@627f0f41f6904a5b1efbaed9f96d9eb58e92e920 # v3.2.4
- with:
- path: .downloaded-cache
- key: downloaded-cache
- - uses: ruby/setup-ruby@ee26e27437bde475b19a6bf8cb73c9fa658876a2 # v1.134.0
+ - uses: ruby/setup-ruby@036ef458ddccddb148a2b9fb67e95a22fdbf728b # v1.160.0
with:
ruby-version: ${{ matrix.ruby }}
bundler: none
- - run: echo "GNUMAKEFLAGS=-j$((1 + $(nproc --all)))" >> $GITHUB_ENV
- - run: sudo apt-get install build-essential autoconf bison libyaml-dev
- - run: ./autogen.sh
+
+ - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
+
+ - uses: ./.github/actions/setup/ubuntu
+
+ - uses: ./.github/actions/setup/directories
+ with:
+ makeup: true
+
- run: ./configure --disable-install-doc
- - run: make common-srcs
- - run: make incs
+
- run: make all
+
- run: make test
- - uses: ruby/action-slack@b6882ea6ef8f556f9f9af9ec1220d3f1ced74acf # v3.0.0
+
+ - uses: ./.github/actions/slack
with:
- payload: |
- {
- "ci": "GitHub Actions",
- "env": "${{ github.workflow }} / BASERUBY @ ${{ matrix.ruby }}",
- "url": "https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}",
- "commit": "${{ github.sha }}",
- "branch": "${{ github.ref_name }}"
- }
- env:
+ label: ${{ matrix.ruby }}
SLACK_WEBHOOK_URL: ${{ secrets.SIMPLER_ALERTS_URL }} # ruby-lang slack: ruby/simpler-alerts-bot
- if: ${{ failure() && github.event_name == 'push' }}
+ if: ${{ failure() }}
diff --git a/.github/workflows/bundled_gems.yml b/.github/workflows/bundled_gems.yml
index 2850b18d6f..943140e9ef 100644
--- a/.github/workflows/bundled_gems.yml
+++ b/.github/workflows/bundled_gems.yml
@@ -2,10 +2,17 @@ name: bundled_gems
on:
push:
+ branches: ['master']
paths:
- '.github/workflows/bundled_gems.yml'
- 'gems/bundled_gems'
pull_request:
+ branches: ['master']
+ paths:
+ - '.github/workflows/bundled_gems.yml'
+ - 'gems/bundled_gems'
+ merge_group:
+ branches: ['master']
paths:
- '.github/workflows/bundled_gems.yml'
- 'gems/bundled_gems'
@@ -13,36 +20,34 @@ on:
- cron: '45 6 * * *'
workflow_dispatch:
-permissions: # added using https://github.com/step-security/secure-workflows
+permissions: # added using https://github.com/step-security/secure-workflows
contents: read
jobs:
update:
permissions:
- contents: write # for Git to git push
+ contents: write # for Git to git push
+
if: ${{ github.event_name != 'schedule' || github.repository == 'ruby/ruby' }}
+
name: update ${{ github.workflow }}
+
runs-on: ubuntu-latest
+
steps:
- - name: git config
- run: |
- git config --global advice.detachedHead 0
- git config --global init.defaultBranch garbage
+ - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
+ with:
+ token: ${{ (github.repository == 'ruby/ruby' && !startsWith(github.event_name, 'pull')) && secrets.MATZBOT_GITHUB_TOKEN || secrets.GITHUB_TOKEN }}
+
+ - uses: ./.github/actions/setup/directories
+ with:
+ # Skip overwriting MATZBOT_GITHUB_TOKEN
+ checkout: '' # false (ref: https://github.com/actions/runner/issues/2238)
- name: Set ENV
run: |
- echo "GNUMAKEFLAGS=-j$((1 + $(nproc --all)))" >> $GITHUB_ENV
echo "TODAY=$(date +%F)" >> $GITHUB_ENV
- - uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
-
- - uses: actions/cache@627f0f41f6904a5b1efbaed9f96d9eb58e92e920 # v3.2.4
- with:
- path: .downloaded-cache
- key: downloaded-cache-${{ github.sha }}
- restore-keys: |
- downloaded-cache
-
- name: Download previous gems list
run: |
data=bundled_gems.json
@@ -51,8 +56,9 @@ jobs:
curl -O -R -z ./$data https://stdgems.org/$data
- name: Update bundled gems list
+ id: bundled_gems
run: |
- ruby -i~ tool/update-bundled_gems.rb gems/bundled_gems
+ ruby -i~ tool/update-bundled_gems.rb gems/bundled_gems >> $GITHUB_OUTPUT
- name: Maintain updated gems list in NEWS
run: |
@@ -61,71 +67,65 @@ jobs:
- name: Check diffs
id: diff
run: |
- git add -- NEWS.md
- git diff --no-ext-diff --ignore-submodules --quiet -- gems/bundled_gems
- continue-on-error: true
+ news= gems=
+ git diff --color --no-ext-diff --ignore-submodules --exit-code -- NEWS.md ||
+ news=true
+ git diff --color --no-ext-diff --ignore-submodules --exit-code -- gems/bundled_gems ||
+ gems=true
+ git add -- NEWS.md gems/bundled_gems
+ echo news=$news >> $GITHUB_OUTPUT
+ echo gems=$gems >> $GITHUB_OUTPUT
+ echo update=${news:-$gems} >> $GITHUB_OUTPUT
- name: Install libraries
- run: |
- set -x
- sudo apt-get update -q || :
- sudo apt-get install --no-install-recommends -q -y build-essential libssl-dev libyaml-dev libreadline6-dev zlib1g-dev libncurses5-dev libffi-dev bison autoconf ruby
- if: ${{ steps.diff.outcome == 'failure' }}
+ uses: ./.github/actions/setup/ubuntu
+ if: ${{ steps.diff.outputs.gems }}
- name: Build
run: |
./autogen.sh
./configure -C --disable-install-doc
make
- if: ${{ steps.diff.outcome == 'failure' }}
+ if: ${{ steps.diff.outputs.gems }}
- name: Prepare bundled gems
run: |
make -s prepare-gems
- if: ${{ steps.diff.outcome == 'failure' }}
+ if: ${{ steps.diff.outputs.gems }}
- name: Test bundled gems
run: |
make -s test-bundled-gems
- git add -- gems/bundled_gems
timeout-minutes: 30
env:
- RUBY_TESTOPTS: "-q --tty=no"
- TEST_BUNDLED_GEMS_ALLOW_FAILURES: ""
- if: ${{ steps.diff.outcome == 'failure' }}
-
- - name: Show diffs
- id: show
- run: |
- git diff --cached --color --no-ext-diff --ignore-submodules --exit-code --
- continue-on-error: true
+ RUBY_TESTOPTS: '-q --tty=no'
+ TEST_BUNDLED_GEMS_ALLOW_FAILURES: ''
+ if: ${{ steps.diff.outputs.gems }}
- name: Commit
run: |
git pull --ff-only origin ${GITHUB_REF#refs/heads/}
- message="Update bundled gems list at "
- if [ ${{ steps.diff.outcome }} = success ]; then
- git commit --message="${message}${GITHUB_SHA:0:30} [ci skip]"
+ message="Update bundled gems list"
+ if [ -z "${gems}" ]; then
+ git commit --message="${message} at ${GITHUB_SHA:0:30} [ci skip]"
else
- git commit --message="${message}${TODAY}"
+ git commit --message="${message} as of ${TODAY}"
fi
git push origin ${GITHUB_REF#refs/heads/}
env:
+ TODAY: ${{ steps.bundled_gems.outputs.latest_date || env.TODAY }}
EMAIL: svn-admin@ruby-lang.org
GIT_AUTHOR_NAME: git
GIT_COMMITTER_NAME: git
- if: ${{ github.repository == 'ruby/ruby' && !startsWith(github.event_name, 'pull') && steps.show.outcome == 'failure' }}
-
- - uses: ruby/action-slack@b6882ea6ef8f556f9f9af9ec1220d3f1ced74acf # v3.0.0
+ gems: ${{ steps.diff.outputs.gems }}
+ if: >-
+ ${{
+ github.repository == 'ruby/ruby' &&
+ !startsWith(github.event_name, 'pull') &&
+ steps.diff.outputs.update
+ }}
+
+ - uses: ./.github/actions/slack
with:
- payload: |
- {
- "ci": "GitHub Actions",
- "env": "${{ github.workflow }} / update",
- "url": "https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}",
- "commit": "${{ github.sha }}",
- "branch": "${{ github.ref_name }}"
- }
- env:
SLACK_WEBHOOK_URL: ${{ secrets.SIMPLER_ALERTS_URL }} # ruby-lang slack: ruby/simpler-alerts-bot
- if: ${{ failure() && github.event_name == 'push' }}
+ if: ${{ failure() }}
diff --git a/.github/workflows/check_dependencies.yml b/.github/workflows/check_dependencies.yml
index b843d66cc6..10c202c3c1 100644
--- a/.github/workflows/check_dependencies.yml
+++ b/.github/workflows/check_dependencies.yml
@@ -7,6 +7,7 @@ on:
- '**.md'
- '**.rdoc'
- '**/.document'
+ - '.*.yml'
pull_request:
paths-ignore:
- 'doc/**'
@@ -14,6 +15,15 @@ on:
- '**.md'
- '**.rdoc'
- '**/.document'
+ - '.*.yml'
+ merge_group:
+ paths-ignore:
+ - 'doc/**'
+ - '**/man'
+ - '**.md'
+ - '**.rdoc'
+ - '**/.document'
+ - '.*.yml'
concurrency:
group: ${{ github.workflow }} / ${{ startsWith(github.event_name, 'pull') && github.ref_name || github.sha }}
@@ -28,45 +38,39 @@ jobs:
matrix:
os: [ubuntu-20.04]
fail-fast: true
+
runs-on: ${{ matrix.os }}
- if: ${{ !contains(github.event.head_commit.message, '[DOC]') && !contains(github.event.pull_request.labels.*.name, 'Documentation') }}
+
+ if: >-
+ ${{!(false
+ || contains(github.event.head_commit.message, '[DOC]')
+ || contains(github.event.pull_request.title, '[DOC]')
+ || contains(github.event.pull_request.labels.*.name, 'Documentation')
+ || (github.event_name == 'push' && github.actor == 'dependabot[bot]')
+ )}}
+
steps:
- - name: Install libraries
- run: |
- set -x
- sudo apt-get update -q || :
- sudo apt-get install --no-install-recommends -q -y build-essential libssl-dev libyaml-dev libreadline6-dev zlib1g-dev libncurses5-dev libffi-dev bison autoconf ruby
+ - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
+
+ - uses: ./.github/actions/setup/ubuntu
if: ${{ contains(matrix.os, 'ubuntu') }}
- - name: Install libraries
- run: |
- brew upgrade
- brew install gmp libffi openssl@1.1 zlib autoconf automake libtool readline
+
+ - uses: ./.github/actions/setup/macos
if: ${{ contains(matrix.os, 'macos') }}
- - name: git config
- run: |
- git config --global advice.detachedHead 0
- git config --global init.defaultBranch garbage
- - uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
- - uses: actions/cache@627f0f41f6904a5b1efbaed9f96d9eb58e92e920 # v3.2.4
- with:
- path: .downloaded-cache
- key: downloaded-cache
- - run: ./autogen.sh
+
+ - uses: ./.github/actions/setup/directories
+
- name: Run configure
run: ./configure -C --disable-install-doc --disable-rubygems --with-gcc 'optflags=-O0' 'debugflags=-save-temps=obj -g'
+
- run: make all golf
+
- run: ruby tool/update-deps --fix
+
- run: git diff --no-ext-diff --ignore-submodules --exit-code
- - uses: ruby/action-slack@b6882ea6ef8f556f9f9af9ec1220d3f1ced74acf # v3.0.0
+
+ - uses: ./.github/actions/slack
with:
- payload: |
- {
- "ci": "GitHub Actions",
- "env": "${{ matrix.os }} / Dependencies need to update",
- "url": "https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}",
- "commit": "${{ github.sha }}",
- "branch": "${{ github.ref_name }}"
- }
- env:
+ label: ${{ matrix.os }} / Dependencies need to update
SLACK_WEBHOOK_URL: ${{ secrets.SIMPLER_ALERTS_URL }} # ruby-lang slack: ruby/simpler-alerts-bot
- if: ${{ failure() && github.event_name == 'push' }}
+ if: ${{ failure() }}
diff --git a/.github/workflows/check_misc.yml b/.github/workflows/check_misc.yml
index e9e14af2eb..ce4397b35a 100644
--- a/.github/workflows/check_misc.yml
+++ b/.github/workflows/check_misc.yml
@@ -1,5 +1,5 @@
-name: Miscellaneous checks
-on: [push, pull_request]
+name: Misc
+on: [push, pull_request, merge_group]
concurrency:
group: ${{ github.workflow }} / ${{ startsWith(github.event_name, 'pull') && github.ref_name || github.sha }}
@@ -10,34 +10,51 @@ permissions:
jobs:
checks:
+ name: Miscellaneous checks
+
permissions:
- contents: write # for Git to git push
+ contents: write # for Git to git push
+
runs-on: ubuntu-latest
+
steps:
- - uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
+ - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
+ with:
+ token: ${{ (github.repository == 'ruby/ruby' && !startsWith(github.event_name, 'pull')) && secrets.MATZBOT_GITHUB_TOKEN || secrets.GITHUB_TOKEN }}
+
+ - uses: ./.github/actions/setup/directories
+ with:
+ makeup: true
+ # Skip overwriting MATZBOT_GITHUB_TOKEN
+ checkout: '' # false (ref: https://github.com/actions/runner/issues/2238)
+
- name: Check if C-sources are US-ASCII
run: |
- ! grep -r -n '[^ -~]' -- *.[chy] include internal win32/*.[ch]
+ grep -r -n --include='*.[chyS]' --include='*.asm' $'[^\t-~]' -- . && exit 1 || :
+
- name: Check for trailing spaces
run: |
- ! git grep -n '[ ]$' -- '*.rb' '*.[chy]' '*.rs'
- ! git grep -n '^[ ][ ]*$' -- '*.md'
+ git grep -I -n $'[\t ]$' -- '*.rb' '*.[chy]' '*.rs' '*.yml' && exit 1 || :
+ git grep -n $'^[\t ][\t ]*$' -- '*.md' && exit 1 || :
+
- name: Check for bash specific substitution in configure.ac
run: |
- ! git grep -n '\${[A-Za-z_0-9]*/' -- configure.ac
+ git grep -n '\${[A-Za-z_0-9]*/' -- configure.ac && exit 1 || :
+
- name: Check for header macros
run: |
- ! for header in ruby/*.h; do \
- git grep -l -F -e $header -e HAVE_`echo $header | tr a-z./ A-Z__` -- . > /dev/null || echo $header
- done | grep -F .
+ fail=
+ for header in ruby/*.h; do
+ git grep -l -F -e $header -e HAVE_`echo $header | tr a-z./ A-Z__` -- . > /dev/null && continue
+ fail=1
+ echo $header
+ done
+ exit $fail
working-directory: include
- - uses: actions/cache@627f0f41f6904a5b1efbaed9f96d9eb58e92e920 # v3.2.4
- with:
- path: .downloaded-cache
- key: downloaded-cache-${{ github.sha }}
- restore-keys: |
- downloaded-cache
+ - id: gems
+ run: true
+ if: ${{ github.ref == 'refs/heads/master' }}
- name: Download previous gems list
run: |
@@ -45,6 +62,7 @@ jobs:
mkdir -p .downloaded-cache
ln -s .downloaded-cache/$data .
curl -O -R -z ./$data https://stdgems.org/$data
+ if: ${{ steps.gems.outcome == 'success' }}
- name: Make default gems list
run: |
@@ -63,16 +81,20 @@ jobs:
f.puts gems
end
shell: ruby --disable=gems {0}
+ if: ${{ steps.gems.outcome == 'success' }}
- name: Maintain updated gems list in NEWS
run: |
ruby tool/update-NEWS-gemlist.rb default
+ if: ${{ steps.gems.outcome == 'success' }}
- name: Check diffs
id: diff
run: |
- git diff --color --no-ext-diff --ignore-submodules --exit-code NEWS.md
- continue-on-error: true
+ git diff --color --no-ext-diff --ignore-submodules --exit-code NEWS.md ||
+ echo update=true >> $GITHUB_OUTPUT
+ if: ${{ steps.gems.outcome == 'success' }}
+
- name: Commit
run: |
git pull --ff-only origin ${GITHUB_REF#refs/heads/}
@@ -82,18 +104,14 @@ jobs:
EMAIL: svn-admin@ruby-lang.org
GIT_AUTHOR_NAME: git
GIT_COMMITTER_NAME: git
- if: ${{ github.repository == 'ruby/ruby' && !startsWith(github.event_name, 'pull') && steps.diff.outcome == 'failure' }}
+ if: >-
+ ${{
+ github.repository == 'ruby/ruby' &&
+ !startsWith(github.event_name, 'pull') &&
+ steps.diff.outputs.update
+ }}
- - uses: ruby/action-slack@b6882ea6ef8f556f9f9af9ec1220d3f1ced74acf # v3.0.0
+ - uses: ./.github/actions/slack
with:
- payload: |
- {
- "ci": "GitHub Actions",
- "env": "${{ github.workflow }}",
- "url": "https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}",
- "commit": "${{ github.sha }}",
- "branch": "${{ github.ref_name }}"
- }
- env:
SLACK_WEBHOOK_URL: ${{ secrets.SIMPLER_ALERTS_URL }} # ruby-lang slack: ruby/simpler-alerts-bot
- if: ${{ failure() && github.event_name == 'push' }}
+ if: ${{ failure() }}
diff --git a/.github/workflows/cirrus-notify.yml b/.github/workflows/cirrus-notify.yml
deleted file mode 100644
index 55d64b7f39..0000000000
--- a/.github/workflows/cirrus-notify.yml
+++ /dev/null
@@ -1,46 +0,0 @@
-on:
- check_suite:
- type: ['completed']
-name: Cirrus CI failure notification
-
-permissions:
- contents: read
-
-jobs:
- cirrus-notify:
- name: After Cirrus CI Failure
- if: >-
- github.event.check_suite.app.name == 'Cirrus CI'
- && github.event.check_suite.conclusion != 'success'
- && github.event.check_suite.conclusion != 'cancelled'
- && github.event.check_suite.conclusion != 'skipped'
- && github.event.check_suite.head_branch == 'master'
- runs-on: ubuntu-latest
- steps:
- - uses: octokit/request-action@89a1754fe82ca777b044ca8e79e9881a42f15a93 # v2.1.7
- id: get_failed_check_run
- with:
- route: GET /repos/${{ github.repository }}/check-suites/${{ github.event.check_suite.id }}/check-runs?status=completed
- mediaType: '{"previews": ["antiope"]}'
- env:
- GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- - name: Dump GitHub context
- env:
- GITHUB_CONTEXT: ${{ toJson(github) }}
- run: echo "$GITHUB_CONTEXT"
- - name: Dump check_runs
- env:
- CHECK_RUNS: ${{ steps.get_failed_check_run.outputs.data }}
- run: echo "$CHECK_RUNS"
- - uses: ruby/action-slack@b6882ea6ef8f556f9f9af9ec1220d3f1ced74acf # v3.0.0
- with:
- payload: |
- {
- "ci": "Cirrus CI",
- "env": "Cirrus CI",
- "url": "${{ fromJson(steps.get_failed_check_run.outputs.data).check_runs[0].html_url }}",
- "commit": "${{ github.event.check_suite.head_commit.id }}",
- "branch": "${{ github.event.check_suite.head_branch }}"
- }
- env:
- SLACK_WEBHOOK_URL: ${{ secrets.SIMPLER_ALERTS_URL }} # ruby-lang slack: ruby/simpler-alerts-bot
diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml
index f500b33ad1..47104672fe 100644
--- a/.github/workflows/codeql-analysis.yml
+++ b/.github/workflows/codeql-analysis.yml
@@ -1,20 +1,23 @@
-name: "Code scanning - action"
+name: 'CodeQL'
on:
- # push:
- # paths-ignore:
- # - 'doc/**'
- # - '**/man'
- # - '**.md'
- # - '**.rdoc'
- # - '**/.document'
- # pull_request:
- # paths-ignore:
- # - 'doc/**'
- # - '**/man'
- # - '**.md'
- # - '**.rdoc'
- # - '**/.document'
+ push:
+ branches: ['master']
+ paths-ignore:
+ - 'doc/**'
+ - '**/man'
+ - '**.md'
+ - '**.rdoc'
+ - '**/.document'
+ - '.*.yml'
+ pull_request:
+ paths-ignore:
+ - 'doc/**'
+ - '**/man'
+ - '**.md'
+ - '**.rdoc'
+ - '**/.document'
+ - '.*.yml'
schedule:
- cron: '0 12 * * *'
workflow_dispatch:
@@ -23,52 +26,90 @@ concurrency:
group: ${{ github.workflow }} / ${{ startsWith(github.event_name, 'pull') && github.ref_name || github.sha }}
cancel-in-progress: ${{ startsWith(github.event_name, 'pull') }}
-permissions: # added using https://github.com/step-security/secure-workflows
+permissions: # added using https://github.com/step-security/secure-workflows
contents: read
jobs:
- CodeQL-Build:
-
- # CodeQL runs on ubuntu-latest and windows-latest
- permissions:
- actions: read # for github/codeql-action/init to get workflow details
- contents: read # for actions/checkout to fetch code
- security-events: write # for github/codeql-action/autobuild to send a status report
+ analyze:
+ name: Analyze
runs-on: ubuntu-latest
+ permissions:
+ actions: read # for github/codeql-action/init to get workflow details
+ contents: read # for actions/checkout to fetch code
+ security-events: write # for github/codeql-action/autobuild to send a status report
# CodeQL fails to run pull requests from dependabot due to missing write access to upload results.
- if: ${{ !contains(github.event.head_commit.message, '[DOC]') && !contains(github.event.pull_request.labels.*.name, 'Documentation') && github.event.head_commit.pusher.name != 'dependabot[bot]' }}
+ if: >-
+ ${{!(false
+ || contains(github.event.head_commit.message, '[DOC]')
+ || contains(github.event.pull_request.title, '[DOC]')
+ || contains(github.event.pull_request.labels.*.name, 'Documentation')
+ || (github.event_name == 'push' && github.actor == 'dependabot[bot]')
+ )}}
env:
enable_install_doc: no
+ strategy:
+ fail-fast: false
+ matrix:
+ language: ['cpp', 'ruby']
+
steps:
- - name: Install libraries
- run: |
- set -x
- sudo apt-get update -q || :
- sudo apt-get install --no-install-recommends -q -y build-essential libssl-dev libyaml-dev libreadline6-dev zlib1g-dev libncurses5-dev libffi-dev bison autoconf ruby
+ - name: Checkout repository
+ uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
+
+ - name: Install libraries
+ uses: ./.github/actions/setup/ubuntu
- - name: Checkout repository
- uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
+ - uses: ./.github/actions/setup/directories
- - uses: actions/cache@627f0f41f6904a5b1efbaed9f96d9eb58e92e920 # v3.2.4
- with:
- path: .downloaded-cache
- key: downloaded-cache
+ - name: Remove an obsolete rubygems vendored file
+ run: sudo rm /usr/lib/ruby/vendor_ruby/rubygems/defaults/operating_system.rb
- - name: Remove an obsolete rubygems vendored file
- run: sudo rm /usr/lib/ruby/vendor_ruby/rubygems/defaults/operating_system.rb
+ - name: Initialize CodeQL
+ uses: github/codeql-action/init@cdcdbb579706841c47f7063dda365e292e5cad7a # v2.13.4
+ with:
+ languages: ${{ matrix.language }}
- - name: Initialize CodeQL
- uses: github/codeql-action/init@3ebbd71c74ef574dbc558c82f70e52732c8b44fe # v2.2.1
- with:
- config-file: ./.github/codeql/codeql-config.yml
+ - name: Autobuild
+ uses: github/codeql-action/autobuild@cdcdbb579706841c47f7063dda365e292e5cad7a # v2.13.4
- - name: Set ENV
- run: echo "GNUMAKEFLAGS=-j$((1 + $(nproc --all)))" >> $GITHUB_ENV
+ - name: Perform CodeQL Analysis
+ uses: github/codeql-action/analyze@cdcdbb579706841c47f7063dda365e292e5cad7a # v2.13.4
+ with:
+ category: '/language:${{ matrix.language }}'
+ upload: False
+ output: sarif-results
+ ram: 8192
+ # CodeQL randomly hits `OutOfMemoryError "Java heap space"`.
+ # GitHub recommends running a larger runner to fix it, but we don't pay for it.
+ continue-on-error: true
- - name: Autobuild
- uses: github/codeql-action/autobuild@3ebbd71c74ef574dbc558c82f70e52732c8b44fe # v2.2.1
+ - name: filter-sarif
+ uses: advanced-security/filter-sarif@f3b8118a9349d88f7b1c0c488476411145b6270d # v1.0
+ with:
+ patterns: |
+ +**/*.rb
+ -lib/uri/mailto.rb:rb/overly-large-range
+ -lib/uri/rfc3986_parser.rb:rb/overly-large-range
+ -lib/bundler/vendor/uri/lib/uri/mailto.rb:rb/overly-large-range
+ -lib/bundler/vendor/uri/lib/uri/rfc3986_parser.rb:rb/overly-large-range
+ -test/ruby/test_io.rb:rb/non-constant-kernel-open
+ -test/open-uri/test_open-uri.rb:rb/non-constant-kernel-open
+ -test/open-uri/test_ssl.rb:rb/non-constant-kernel-open
+ -spec/ruby/core/io/binread_spec.rb:rb/non-constant-kernel-open
+ -spec/ruby/core/io/readlines_spec.rb:rb/non-constant-kernel-open
+ -spec/ruby/core/io/foreach_spec.rb:rb/non-constant-kernel-open
+ -spec/ruby/core/io/write_spec.rb:rb/non-constant-kernel-open
+ -spec/ruby/core/io/read_spec.rb:rb/non-constant-kernel-open
+ -spec/ruby/core/kernel/open_spec.rb:rb/non-constant-kernel-open
+ input: sarif-results/${{ matrix.language }}.sarif
+ output: sarif-results/${{ matrix.language }}.sarif
+ if: ${{ matrix.language == 'ruby' }}
+ continue-on-error: true
- - name: Perform CodeQL Analysis
- uses: github/codeql-action/analyze@3ebbd71c74ef574dbc558c82f70e52732c8b44fe # v2.2.1
+ - name: Upload SARIF
+ uses: github/codeql-action/upload-sarif@cdcdbb579706841c47f7063dda365e292e5cad7a # v2.13.4
+ with:
+ sarif_file: sarif-results/${{ matrix.language }}.sarif
+ continue-on-error: true
diff --git a/.github/workflows/compilers.yml b/.github/workflows/compilers.yml
index 61985505e9..233f4c5db3 100644
--- a/.github/workflows/compilers.yml
+++ b/.github/workflows/compilers.yml
@@ -8,12 +8,23 @@ on:
- '**.md'
- '**.rdoc'
- '**/.document'
+ - '.*.yml'
pull_request:
paths-ignore:
- 'doc/**'
- '**/man'
+ - '**.md'
+ - '**.rdoc'
+ - '**/.document'
+ - '.*.yml'
+ merge_group:
+ paths-ignore:
+ - 'doc/**'
+ - '**/man'
+ - '**.md'
- '**.rdoc'
- '**/.document'
+ - '.*.yml'
concurrency:
group: ${{ github.workflow }} / ${{ startsWith(github.event_name, 'pull') && github.ref_name || github.sha }}
@@ -23,7 +34,7 @@ concurrency:
# environment variables (plus the "echo $GITHUB_ENV" hack) is to reroute that
# restriction.
env:
- default_cc: clang-15
+ default_cc: clang-17
append_cc: ''
# -O1 is faster than -O3 in our tests... Majority of time are consumed trying
@@ -45,7 +56,7 @@ env:
--without-gmp
CONFIGURE_TTY: never
- GITPULLOPTIONS: --no-tags origin ${{github.ref}}
+ GITPULLOPTIONS: --no-tags origin ${{ github.ref }}
RUBY_DEBUG: ci rgengc
RUBY_TESTOPTS: >-
-q
@@ -63,33 +74,22 @@ jobs:
env:
- {}
entry:
+ - { name: gcc-13, env: { default_cc: gcc-13 } }
- { name: gcc-12, env: { default_cc: gcc-12 } }
- { name: gcc-11, env: { default_cc: gcc-11 } }
- { name: gcc-10, env: { default_cc: gcc-10 } }
- { name: gcc-9, env: { default_cc: gcc-9 } }
- { name: gcc-8, env: { default_cc: gcc-8 } }
- { name: gcc-7, env: { default_cc: gcc-7 } }
- - { name: gcc-6, env: { default_cc: gcc-6 } }
- - { name: gcc-5, env: { default_cc: gcc-5 } }
- - { name: gcc-4.8, env: { default_cc: gcc-4.8 } }
- - name: 'gcc-11 LTO'
- container: gcc-11
+ - name: 'gcc-13 LTO'
+ container: gcc-13
env:
- default_cc: 'gcc-11 -flto=auto -ffat-lto-objects'
+ default_cc: 'gcc-13 -flto=auto -ffat-lto-objects -Werror=lto-type-mismatch'
optflags: '-O2'
shared: disable
# check: true
- - name: 'gcc-11 annocheck'
- container: gcc-11
- env:
- # Minimal flags to pass the check.
- default_cc: 'gcc-11 -O2 -fcf-protection -Wa,--generate-missing-build-notes=yes'
- LDFLAGS: '-Wl,-z,now'
- # FIXME: Drop skipping options
- # https://bugs.ruby-lang.org/issues/18061
- # https://sourceware.org/annobin/annobin.html/Test-pie.html
- TEST_ANNOCHECK_OPTS: "--skip-pie"
- check: true
+ - { name: clang-18, env: { default_cc: clang-18 } }
+ - { name: clang-17, env: { default_cc: clang-17 } }
- { name: clang-16, env: { default_cc: clang-16 } }
- { name: clang-15, env: { default_cc: clang-15 } }
- { name: clang-14, env: { default_cc: clang-14 } }
@@ -97,21 +97,21 @@ jobs:
- { name: clang-12, env: { default_cc: clang-12 } }
- { name: clang-11, env: { default_cc: clang-11 } }
- { name: clang-10, env: { default_cc: clang-10 } }
- - { name: clang-9, env: { default_cc: clang-9 } }
- - { name: clang-8, env: { default_cc: clang-8 } }
- - { name: clang-7, env: { default_cc: clang-7 } }
- - { name: clang-6.0, env: { default_cc: clang-6.0 } }
- - { name: clang-5.0, env: { default_cc: clang-5.0 } }
- - { name: clang-4.0, env: { default_cc: clang-4.0 } }
- - { name: clang-3.9, env: { default_cc: clang-3.9 } }
- - name: 'clang-14 LTO'
- container: clang-14
+ # llvm-objcopy<=9 doesn't have --wildcard. It compiles, but leaves Rust symbols in libyjit.o.
+ - { name: clang-9, env: { default_cc: clang-9, append_configure: '--disable-yjit' } }
+ - { name: clang-8, env: { default_cc: clang-8, append_configure: '--disable-yjit' } }
+ - { name: clang-7, env: { default_cc: clang-7, append_configure: '--disable-yjit' } }
+ - { name: clang-6.0, env: { default_cc: clang-6.0, append_configure: '--disable-yjit' } }
+ - name: 'clang-16 LTO'
+ container: clang-16
env:
- default_cc: 'clang-14 -flto=auto'
+ default_cc: 'clang-16 -flto=auto'
optflags: '-O2'
shared: disable
# check: true
+ - { name: ext/Setup }
+
# - { name: aarch64-linux-gnu, crosshost: aarch64-linux-gnu, container: crossbuild-essential-arm64 }
# - { name: arm-linux-gnueabi, crosshost: arm-linux-gnueabi }
# - { name: arm-linux-gnueabihf, crosshost: arm-linux-gnueabihf }
@@ -127,15 +127,17 @@ jobs:
# warning generates a lot of noise from use of ANYARGS in
# rb_define_method() and friends.
# See: https://github.com/llvm/llvm-project/commit/11da1b53d8cd3507959022cd790d5a7ad4573d94
- - { name: c99, env: { append_cc: '-std=c99 -Werror=pedantic -pedantic-errors -Wno-strict-prototypes' } }
-# - { name: c11, env: { append_cc: '-std=c11 -Werror=pedantic -pedantic-errors -Wno-strict-prototypes' } }
-# - { name: c17, env: { append_cc: '-std=c17 -Werror=pedantic -pedantic-errors -Wno-strict-prototypes' } }
- - { name: c2x, env: { append_cc: '-std=c2x -Werror=pedantic -pedantic-errors -Wno-strict-prototypes' } }
+ - { name: c99, env: { CFLAGS: '-std=c99 -Werror=pedantic -pedantic-errors -Wno-strict-prototypes' } }
+# - { name: c11, env: { CFLAGS: '-std=c11 -Werror=pedantic -pedantic-errors -Wno-strict-prototypes' } }
+# - { name: c17, env: { CFLAGS: '-std=c17 -Werror=pedantic -pedantic-errors -Wno-strict-prototypes' } }
+ - { name: c23, env: { CFLAGS: '-std=c2x -Werror=pedantic -pedantic-errors -Wno-strict-prototypes' } }
- { name: c++98, env: { CXXFLAGS: '-std=c++98 -Werror=pedantic -pedantic-errors -Wno-c++11-long-long' } }
# - { name: c++11, env: { CXXFLAGS: '-std=c++11 -Werror=pedantic -pedantic-errors -Wno-c++11-long-long' } }
# - { name: c++14, env: { CXXFLAGS: '-std=c++14 -Werror=pedantic -pedantic-errors -Wno-c++11-long-long' } }
# - { name: c++17, env: { CXXFLAGS: '-std=c++17 -Werror=pedantic -pedantic-errors -Wno-c++11-long-long' } }
- - { name: c++2a, env: { CXXFLAGS: '-std=c++2a -Werror=pedantic -pedantic-errors -Wno-c++11-long-long' } }
+# - { name: c++20, env: { CXXFLAGS: '-std=c++20 -Werror=pedantic -pedantic-errors -Wno-c++11-long-long' } }
+# - { name: c++23, env: { CXXFLAGS: '-std=c++23 -Werror=pedantic -pedantic-errors -Wno-c++11-long-long' } }
+ - { name: c++26, env: { CXXFLAGS: '-std=c++26 -Werror=pedantic -pedantic-errors -Wno-c++11-long-long' } }
- { name: '-O0', env: { optflags: '-O0 -march=x86-64 -mtune=generic' } }
# - { name: '-O3', env: { optflags: '-O3 -march=x86-64 -mtune=generic' }, check: true }
@@ -145,7 +147,7 @@ jobs:
- { name: valgrind, env: { append_configure: '--with-valgrind' } }
- { name: 'coroutine=ucontext', env: { append_configure: '--with-coroutine=ucontext' } }
- { name: 'coroutine=pthread', env: { append_configure: '--with-coroutine=pthread' } }
- - { name: disable-jit-support, env: { append_configure: '--disable-jit-support' } }
+ - { name: disable-jit, env: { append_configure: '--disable-yjit --disable-rjit' } }
- { name: disable-dln, env: { append_configure: '--disable-dln' } }
- { name: enable-mkmf-verbose, env: { append_configure: '--enable-mkmf-verbose' } }
- { name: disable-rubygems, env: { append_configure: '--disable-rubygems' } }
@@ -169,27 +171,27 @@ jobs:
# - { name: SYMBOL_DEBUG, env: { cppflags: '-DSYMBOL_DEBUG' } }
# - { name: RGENGC_CHECK_MODE, env: { cppflags: '-DRGENGC_CHECK_MODE' } }
-# - { name: TRANSIENT_HEAP_CHECK_MODE, env: { cppflags: '-DTRANSIENT_HEAP_CHECK_MODE' } }
# - { name: VM_CHECK_MODE, env: { cppflags: '-DVM_CHECK_MODE' } }
- - { name: USE_EMBED_CI=0, env: { cppflags: '-DUSE_EMBED_CI=0' } }
- - { name: USE_FLONUM=0, env: { cppflags: '-DUSE_FLONUM=0' } }
+# - { name: USE_EMBED_CI=0, env: { cppflags: '-DUSE_EMBED_CI=0' } }
+ - name: USE_FLONUM=0
+ env:
+ cppflags: '-DUSE_FLONUM=0'
+ # yjit requires FLONUM for the pointer tagging scheme
+ append_configure: '--disable-yjit'
# - { name: USE_GC_MALLOC_OBJ_INFO_DETAILS, env: { cppflags: '-DUSE_GC_MALLOC_OBJ_INFO_DETAILS' } }
- - { name: USE_LAZY_LOAD, env: { cppflags: '-DUSE_LAZY_LOAD' } }
-# - { name: USE_RINCGC=0, env: { cppflags: '-DUSE_RINCGC=0' } }
+# - { name: USE_LAZY_LOAD, env: { cppflags: '-DUSE_LAZY_LOAD' } }
# - { name: USE_SYMBOL_GC=0, env: { cppflags: '-DUSE_SYMBOL_GC=0' } }
# - { name: USE_THREAD_CACHE=0, env: { cppflags: '-DUSE_THREAD_CACHE=0' } }
-# - { name: USE_TRANSIENT_HEAP=0, env: { cppflags: '-DUSE_TRANSIENT_HEAP=0' } }
-# - { name: USE_RUBY_DEBUG_LOG=1, env: { cppflags: '-DUSE_RUBY_DEBUG_LOG=1' } }
- - { name: USE_RVARGC=0, env: { cppflags: '-DUSE_RVARGC=0' } }
-# - { name: USE_RVARGC=1, env: { cppflags: '-DUSE_RVARGC=1' } }
+ - { name: USE_RUBY_DEBUG_LOG=1, env: { cppflags: '-DUSE_RUBY_DEBUG_LOG=1' } }
# - { name: USE_DEBUG_COUNTER, env: { cppflags: '-DUSE_DEBUG_COUNTER=1', RUBY_DEBUG_COUNTER_DISABLE: '1' } }
+ - { name: SHARABLE_MIDDLE_SUBSTRING, env: { cppflags: '-DSHARABLE_MIDDLE_SUBSTRING=1' } }
- - { name: DEBUG_FIND_TIME_NUMGUESS, env: { cppflags: '-DDEBUG_FIND_TIME_NUMGUESS' } }
- - { name: DEBUG_INTEGER_PACK, env: { cppflags: '-DDEBUG_INTEGER_PACK' } }
+# - { name: DEBUG_FIND_TIME_NUMGUESS, env: { cppflags: '-DDEBUG_FIND_TIME_NUMGUESS' } }
+# - { name: DEBUG_INTEGER_PACK, env: { cppflags: '-DDEBUG_INTEGER_PACK' } }
# - { name: ENABLE_PATH_CHECK, env: { cppflags: '-DENABLE_PATH_CHECK' } }
- - { name: GC_DEBUG_STRESS_TO_CLASS, env: { cppflags: '-DGC_DEBUG_STRESS_TO_CLASS' } }
+# - { name: GC_DEBUG_STRESS_TO_CLASS, env: { cppflags: '-DGC_DEBUG_STRESS_TO_CLASS' } }
# - { name: GC_ENABLE_LAZY_SWEEP=0, env: { cppflags: '-DGC_ENABLE_LAZY_SWEEP=0' } }
# - { name: GC_PROFILE_DETAIL_MEMOTY, env: { cppflags: '-DGC_PROFILE_DETAIL_MEMOTY' } }
# - { name: GC_PROFILE_MORE_DETAIL, env: { cppflags: '-DGC_PROFILE_MORE_DETAIL' } }
@@ -202,39 +204,50 @@ jobs:
# - { name: RGENGC_ESTIMATE_OLDMALLOC, env: { cppflags: '-DRGENGC_ESTIMATE_OLDMALLOC' } }
# - { name: RGENGC_FORCE_MAJOR_GC, env: { cppflags: '-DRGENGC_FORCE_MAJOR_GC' } }
# - { name: RGENGC_OBJ_INFO, env: { cppflags: '-DRGENGC_OBJ_INFO' } }
-# - { name: RGENGC_OLD_NEWOBJ_CHECK, env: { cppflags: '-DRGENGC_OLD_NEWOBJ_CHECK' } }
# - { name: RGENGC_PROFILE, env: { cppflags: '-DRGENGC_PROFILE' } }
# - { name: VM_DEBUG_BP_CHECK, env: { cppflags: '-DVM_DEBUG_BP_CHECK' } }
# - { name: VM_DEBUG_VERIFY_METHOD_CACHE, env: { cppflags: '-DVM_DEBUG_VERIFY_METHOD_CACHE' } }
- - { name: MJIT_FORCE_ENABLE, env: { cppflags: '-DMJIT_FORCE_ENABLE' } }
+ - { name: enable-yjit, env: { append_configure: '--enable-yjit --disable-rjit' } }
+ - { name: enable-rjit, env: { append_configure: '--enable-rjit --disable-yjit' } }
- { name: YJIT_FORCE_ENABLE, env: { cppflags: '-DYJIT_FORCE_ENABLE' } }
+# - { name: RJIT_FORCE_ENABLE, env: { cppflags: '-DRJIT_FORCE_ENABLE' } }
+ - { name: UNIVERSAL_PARSER, env: { cppflags: '-DUNIVERSAL_PARSER' } }
name: ${{ matrix.entry.name }}
+
runs-on: ubuntu-latest
+
container:
- image: ghcr.io/ruby/ruby-ci-image:${{ matrix.entry.container || matrix.entry.env.default_cc || 'clang-15' }}
+ image: ghcr.io/ruby/ruby-ci-image:${{ matrix.entry.container || matrix.entry.env.default_cc || 'clang-17' }}
options: --user root
- if: ${{ !contains(github.event.head_commit.message, '[DOC]') && !contains(github.event.pull_request.labels.*.name, 'Documentation') }}
+
+ if: >-
+ ${{!(false
+ || contains(github.event.head_commit.message, '[DOC]')
+ || contains(github.event.pull_request.title, '[DOC]')
+ || contains(github.event.pull_request.labels.*.name, 'Documentation')
+ || (github.event_name == 'push' && github.actor == 'dependabot[bot]')
+ )}}
+
env: ${{ matrix.entry.env || matrix.env }}
+
steps:
- run: id
working-directory:
- - run: mkdir build
- working-directory:
- - name: setenv
- run: |
- echo "GNUMAKEFLAGS=-sj$((1 + $(nproc --all)))" >> $GITHUB_ENV
- - uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
+
+ - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
with:
- path: src
- - uses: actions/cache@627f0f41f6904a5b1efbaed9f96d9eb58e92e920 # v3.2.4
+ sparse-checkout-cone-mode: false
+ sparse-checkout: /.github
+
+ - uses: ./.github/actions/setup/directories
with:
- path: src/.downloaded-cache
- key: downloaded-cache
- - run: ./autogen.sh
- working-directory: src
+ srcdir: src
+ builddir: build
+ makeup: true
+
- name: Run configure
run: >
../src/configure -C ${default_configure} ${append_configure}
@@ -244,38 +257,39 @@ jobs:
matrix.entry.crosshost || '"${default_cc}${append_cc:+ $append_cc}"'
}}
--${{ matrix.entry.shared || 'enable' }}-shared
- - run: make extract-extlibs
- - run: make incs
+
+ - name: Add to ext/Setup # statically link just the etc extension
+ run: mkdir ext && echo etc >> ext/Setup
+ if: ${{ matrix.entry.name == 'ext/Setup' }}
+
- run: make showflags
+
- run: make
- - run: make leaked-globals
+
- run: make test
+
- run: make install
if: ${{ matrix.entry.check }}
+
- run: make test-tool
if: ${{ matrix.entry.check }}
+
- run: make test-all TESTS='-- ruby -ext-'
if: ${{ matrix.entry.check }}
+
- run: make test-spec
env:
CHECK_LEAKS: true
if: ${{ matrix.entry.check }}
+
- run: make test-annocheck
if: ${{ matrix.entry.check && endsWith(matrix.entry.name, 'annocheck') }}
- - uses: ruby/action-slack@b6882ea6ef8f556f9f9af9ec1220d3f1ced74acf # v3.0.0
+ - uses: ./.github/actions/slack
with:
- payload: |
- {
- "ci": "GitHub Actions",
- "env": "${{ github.workflow }} / ${{ matrix.entry.name }}",
- "url": "https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}",
- "commit": "${{ github.sha }}",
- "branch": "${{ github.ref_name }}"
- }
- env:
+ label: ${{ matrix.entry.name }}
SLACK_WEBHOOK_URL: ${{ secrets.SIMPLER_ALERTS_URL }} # ruby-lang slack: ruby/simpler-alerts-bot
- if: ${{ failure() && github.event_name == 'push' }}
+ if: ${{ failure() }}
defaults:
run:
diff --git a/.github/workflows/dependabot_automerge.yml b/.github/workflows/dependabot_automerge.yml
new file mode 100644
index 0000000000..6259199b11
--- /dev/null
+++ b/.github/workflows/dependabot_automerge.yml
@@ -0,0 +1,30 @@
+# from https://github.com/gofiber/swagger/blob/main/.github/workflows/dependabot_automerge.yml
+name: Dependabot auto-merge
+on:
+ pull_request_target:
+
+jobs:
+ automerge:
+ runs-on: ubuntu-latest
+
+ if: ${{ github.actor == 'dependabot[bot]' }}
+
+ steps:
+ - name: Dependabot metadata
+ uses: dependabot/fetch-metadata@c9c4182bf1b97f5224aee3906fd373f6b61b4526 # v1.6.0
+ id: metadata
+
+ - name: Wait for status checks
+ uses: lewagon/wait-on-check-action@e106e5c43e8ca1edea6383a39a01c5ca495fd812 # v1.3.1
+ with:
+ repo-token: ${{ secrets.MATZBOT_GITHUB_TOKEN }}
+ ref: ${{ github.event.pull_request.head.sha || github.sha }}
+ check-regexp: 'make \(check, .*\)'
+ wait-interval: 30
+
+ - name: Auto-merge for Dependabot PRs
+ if: ${{ steps.metadata.outputs.update-type == 'version-update:semver-minor' || steps.metadata.outputs.update-type == 'version-update:semver-patch' }}
+ run: gh pr merge --auto --rebase "$PR_URL"
+ env:
+ PR_URL: ${{ github.event.pull_request.html_url }}
+ GITHUB_TOKEN: ${{ secrets.MATZBOT_GITHUB_TOKEN }}
diff --git a/.github/workflows/macos.yml b/.github/workflows/macos.yml
index 68a0bd404c..6411a02d2b 100644
--- a/.github/workflows/macos.yml
+++ b/.github/workflows/macos.yml
@@ -7,13 +7,18 @@ on:
- '**.md'
- '**.rdoc'
- '**/.document'
+ - '.*.yml'
pull_request:
+ # Do not use paths-ignore for required status checks
+ # https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/collaborating-on-repositories-with-code-quality-features/troubleshooting-required-status-checks#handling-skipped-but-required-checks
+ merge_group:
paths-ignore:
- 'doc/**'
- '**/man'
- '**.md'
- '**.rdoc'
- '**/.document'
+ - '.*.yml'
concurrency:
group: ${{ github.workflow }} / ${{ startsWith(github.event_name, 'pull') && github.ref_name || github.sha }}
@@ -26,84 +31,86 @@ jobs:
make:
strategy:
matrix:
- test_task: ["check"] # "test-bundler-parallel", "test-bundled-gems"
- os:
- - macos-11
- - macos-12
+ test_task: ['check']
+ configure: ['']
+ os: ${{ fromJSON(format('["macos-11","macos-12"{0}]', (github.repository == 'ruby/ruby' && ',"macos-arm-oss"' || ''))) }}
+ include:
+ - test_task: test-all TESTS=--repeat-count=2
+ os: ${{ github.repository == 'ruby/ruby' && 'macos-arm-oss' || 'macos-12' }}
fail-fast: false
+
env:
- GITPULLOPTIONS: --no-tags origin ${{github.ref}}
+ GITPULLOPTIONS: --no-tags origin ${{ github.ref }}
+
runs-on: ${{ matrix.os }}
- if: ${{ !contains(github.event.head_commit.message, '[DOC]') && !contains(github.event.pull_request.labels.*.name, 'Documentation') }}
+
+ if: >-
+ ${{!(false
+ || contains(github.event.head_commit.message, '[DOC]')
+ || contains(github.event.pull_request.title, '[DOC]')
+ || contains(github.event.pull_request.labels.*.name, 'Documentation')
+ || (github.event_name == 'push' && github.actor == 'dependabot[bot]')
+ )}}
+
steps:
- - run: mkdir build
- working-directory:
- - name: git config
- run: |
- git config --global advice.detachedHead 0
- git config --global init.defaultBranch garbage
- - uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
+ - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
with:
- path: src
- - uses: actions/cache@627f0f41f6904a5b1efbaed9f96d9eb58e92e920 # v3.2.4
- with:
- path: src/.downloaded-cache
- key: downloaded-cache
+ sparse-checkout-cone-mode: false
+ sparse-checkout: /.github
+
- name: Install libraries
- run: |
- brew upgrade
- brew install gmp libffi openssl@1.1 zlib autoconf automake libtool readline bison
- working-directory: src
- - name: Set ENV
- run: |
- echo "MAKEFLAGS=-j$((1 + $(sysctl -n hw.activecpu)))" >> $GITHUB_ENV
- echo "PATH="/usr/local/opt/bison/bin:$PATH"" >> $GITHUB_ENV
- for lib in openssl@1.1 readline; do
- CONFIGURE_ARGS="${CONFIGURE_ARGS:+$CONFIGURE_ARGS }--with-${lib%@*}-dir=$(brew --prefix $lib)"
- done
- echo CONFIGURE_ARGS="${CONFIGURE_ARGS}" >> $GITHUB_ENV
- - run: ./autogen.sh
- working-directory: src
+ uses: ./.github/actions/setup/macos
+
+ - uses: ./.github/actions/setup/directories
+ with:
+ srcdir: src
+ builddir: build
+ makeup: true
+ dummy-files: ${{ matrix.test_task == 'check' }}
+
- name: Run configure
- run: ../src/configure -C --disable-install-doc
- - run: make incs
+ run: ../src/configure -C --disable-install-doc ${{ matrix.configure }}
+
- run: make prepare-gems
if: ${{ matrix.test_task == 'test-bundled-gems' }}
+
- run: make
- - run: make leaked-globals
- if: ${{ matrix.test_task == 'check' }}
+
- name: make ${{ matrix.test_task }}
run: |
make -s ${{ matrix.test_task }} ${TESTS:+TESTS=`echo "$TESTS" | sed 's| |$$/ -n!/|g;s|^|-n!/|;s|$|$$/|'`}
- timeout-minutes: 40
+ timeout-minutes: 60
env:
- RUBY_TESTOPTS: "-q --tty=no"
+ RUBY_TESTOPTS: '-q --tty=no'
TESTS: ${{ matrix.test_task == 'check' && matrix.skipped_tests || '' }}
- TEST_BUNDLED_GEMS_ALLOW_FAILURES: ""
- PRECHECK_BUNDLED_GEMS: "no"
+ TEST_BUNDLED_GEMS_ALLOW_FAILURES: ''
+ PRECHECK_BUNDLED_GEMS: 'no'
+
- name: make skipped tests
run: |
make -s test-all TESTS=`echo "$TESTS" | sed 's| |$$/ -n/|g;s|^|-n/|;s|$|$$/|'`
env:
- GNUMAKEFLAGS: ""
- RUBY_TESTOPTS: "-v --tty=no"
+ GNUMAKEFLAGS: ''
+ RUBY_TESTOPTS: '-v --tty=no'
TESTS: ${{ matrix.skipped_tests }}
- PRECHECK_BUNDLED_GEMS: "no"
+ PRECHECK_BUNDLED_GEMS: 'no'
if: ${{ matrix.test_task == 'check' && matrix.skipped_tests != '' }}
continue-on-error: ${{ matrix.continue-on-skipped_tests || false }}
- - uses: ruby/action-slack@b6882ea6ef8f556f9f9af9ec1220d3f1ced74acf # v3.0.0
+
+ - uses: ./.github/actions/slack
with:
- payload: |
- {
- "ci": "GitHub Actions",
- "env": "${{ matrix.os }} / ${{ matrix.test_task }}${{ matrix.configure }}",
- "url": "https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}",
- "commit": "${{ github.sha }}",
- "branch": "${{ github.ref_name }}"
- }
- env:
+ label: ${{ matrix.os }} / ${{ matrix.test_task }} ${{ matrix.configure }}
SLACK_WEBHOOK_URL: ${{ secrets.SIMPLER_ALERTS_URL }} # ruby-lang slack: ruby/simpler-alerts-bot
- if: ${{ failure() && github.event_name == 'push' }}
+ if: ${{ failure() }}
+
+ result:
+ if: ${{ always() }}
+ name: ${{ github.workflow }} result
+ runs-on: macos-latest
+ needs: [make]
+ steps:
+ - run: exit 1
+ if: ${{ contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled') }}
defaults:
run:
diff --git a/.github/workflows/mingw.yml b/.github/workflows/mingw.yml
index e5d1ffb565..df879f56b6 100644
--- a/.github/workflows/mingw.yml
+++ b/.github/workflows/mingw.yml
@@ -7,6 +7,8 @@ on:
- '**.md'
- '**.rdoc'
- '**/.document'
+ - '.*.yml'
+ - '.*.yml'
pull_request:
paths-ignore:
- 'doc/**'
@@ -14,6 +16,17 @@ on:
- '**.md'
- '**.rdoc'
- '**/.document'
+ - '.*.yml'
+ - '.*.yml'
+ merge_group:
+ paths-ignore:
+ - 'doc/**'
+ - '**/man'
+ - '**.md'
+ - '**.rdoc'
+ - '**/.document'
+ - '.*.yml'
+ - '.*.yml'
concurrency:
group: ${{ github.workflow }} / ${{ startsWith(github.event_name, 'pull') && github.ref_name || github.sha }}
@@ -28,49 +41,42 @@ permissions:
jobs:
make:
runs-on: windows-2022
+
name: ${{ github.workflow }} (${{ matrix.msystem }})
+
env:
MSYSTEM: ${{ matrix.msystem }}
MSYS2_ARCH: x86_64
- CHOST: "x86_64-w64-mingw32"
- CFLAGS: "-march=x86-64 -mtune=generic -O3 -pipe"
- CXXFLAGS: "-march=x86-64 -mtune=generic -O3 -pipe"
- CPPFLAGS: "-D_FORTIFY_SOURCE=2 -D__USE_MINGW_ANSI_STDIO=1 -DFD_SETSIZE=2048"
- LDFLAGS: "-pipe"
- GITPULLOPTIONS: --no-tags origin ${{github.ref}}
+ CHOST: 'x86_64-w64-mingw32'
+ CFLAGS: '-march=x86-64 -mtune=generic -O3 -pipe'
+ CXXFLAGS: '-march=x86-64 -mtune=generic -O3 -pipe'
+ CPPFLAGS: '-D_FORTIFY_SOURCE=2 -D__USE_MINGW_ANSI_STDIO=1 -DFD_SETSIZE=2048'
+ LDFLAGS: '-pipe'
+ GITPULLOPTIONS: --no-tags origin ${{ github.ref }}
+
strategy:
matrix:
include:
# To mitigate flakiness of MinGW CI, we test only one runtime that newer MSYS2 uses.
- - msystem: "UCRT64"
+ - msystem: 'UCRT64'
base_ruby: head
- test_task: "check"
- test-all-opts: "--name=!/TestObjSpace#test_reachable_objects_during_iteration/"
+ test_task: 'check'
+ test-all-opts: '--name=!/TestObjSpace#test_reachable_objects_during_iteration/'
fail-fast: false
- if: ${{ !contains(github.event.head_commit.message, '[DOC]') && !contains(github.event.pull_request.labels.*.name, 'Documentation') }}
+
+ if: >-
+ ${{!(false
+ || contains(github.event.head_commit.message, '[DOC]')
+ || contains(github.event.pull_request.title, '[DOC]')
+ || contains(github.event.pull_request.labels.*.name, 'Documentation')
+ || (github.event_name == 'push' && github.actor == 'dependabot[bot]')
+ )}}
+
steps:
- - run: mkdir build
- working-directory:
- - name: git config
- run: |
- git config --global core.autocrlf false
- git config --global core.eol lf
- git config --global advice.detachedHead 0
- git config --global init.defaultBranch garbage
- - uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
- with:
- path: src
- - uses: actions/cache@627f0f41f6904a5b1efbaed9f96d9eb58e92e920 # v3.2.4
- with:
- path: src/.downloaded-cache
- key: downloaded-cache
- name: Set up Ruby & MSYS2
- uses: ruby/setup-ruby@ee26e27437bde475b19a6bf8cb73c9fa658876a2 # v1.134.0
+ uses: ruby/setup-ruby@036ef458ddccddb148a2b9fb67e95a22fdbf728b # v1.160.0
with:
ruby-version: ${{ matrix.base_ruby }}
- - name: set env
- run: |
- echo "GNUMAKEFLAGS=-j$((2 * NUMBER_OF_PROCESSORS))" >> $GITHUB_ENV
- name: where check
run: |
@@ -78,92 +84,83 @@ jobs:
mv /c/Windows/System32/libcrypto-1_1-x64.dll /c/Windows/System32/libcrypto-1_1-x64.dll_
mv /c/Windows/System32/libssl-1_1-x64.dll /c/Windows/System32/libssl-1_1-x64.dll_
result=true
- for e in gcc.exe ragel.exe make.exe bison.exe libcrypto-1_1-x64.dll libssl-1_1-x64.dll; do
- echo '##['group']'$'\033[93m'$e$'\033[m'
+ for e in gcc.exe ragel.exe make.exe libcrypto-1_1-x64.dll libssl-1_1-x64.dll; do
+ echo ::group::$'\033[93m'$e$'\033[m'
where $e || result=false
- echo '##['endgroup']'
+ echo ::endgroup::
done
$result
+ working-directory:
- name: version check
run: |
# show version
result=true
- for e in gcc ragel make bison "openssl version"; do
+ for e in gcc ragel make "openssl version"; do
case "$e" in *" "*) ;; *) e="$e --version";; esac
- echo '##['group']'$'\033[93m'$e$'\033[m'
+ echo ::group::$'\033[93m'$e$'\033[m'
$e || result=false
- echo '##['endgroup']'
+ echo ::endgroup::
done
$result
+ working-directory:
- - name: autogen
- run: |
- ./autogen.sh
- working-directory: src
+ - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
+ with:
+ sparse-checkout-cone-mode: false
+ sparse-checkout: /.github
+
+ - uses: ./.github/actions/setup/directories
+ with:
+ srcdir: src
+ builddir: build
+ makeup: true
- name: configure
run: >
../src/configure --disable-install-doc --prefix=/.
--build=$CHOST --host=$CHOST --target=$CHOST
- - name: update
- run: |
- make incs
-
- - name: download gems
- run: |
- make update-gems
-
- name: make all
timeout-minutes: 30
- run: |
- make
-
- - run: make leaked-globals
+ run: make
- name: make install
- run: |
- make DESTDIR=../install install-nodoc
+ run: make DESTDIR=../install install-nodoc
- name: test
- timeout-minutes: 5
- run: |
- make test
- if: ${{matrix.test_task == 'check' || matrix.test_task == 'test'}}
+ timeout-minutes: 30
+ run: make test
+ shell: cmd
+ env:
+ GNUMAKEFLAGS: ''
+ RUBY_TESTOPTS: '-v --tty=no'
+ if: ${{ matrix.test_task == 'check' || matrix.test_task == 'test' }}
- name: test-all
timeout-minutes: 45
+ shell: cmd
run: |
- # Actions uses UTF8, causes test failures, similar to normal OS setup
- chcp.com 437
make ${{ StartsWith(matrix.test_task, 'test/') && matrix.test_task || 'test-all' }}
env:
RUBY_TESTOPTS: >-
--retry --job-status=normal --show-skip --timeout-scale=1.5
${{ matrix.test-all-opts }}
BUNDLER_VERSION:
- if: ${{matrix.test_task == 'check' || matrix.test_task == 'test-all' || StartsWith(matrix.test_task, 'test/')}}
+ if: ${{ matrix.test_task == 'check' || matrix.test_task == 'test-all' || StartsWith(matrix.test_task, 'test/') }}
- name: test-spec
timeout-minutes: 10
run: |
make ${{ StartsWith(matrix.test_task, 'spec/') && matrix.test_task || 'test-spec' }}
- if: ${{matrix.test_task == 'check' || matrix.test_task == 'test-spec' || StartsWith(matrix.test_task, 'spec/')}}
+ shell: cmd
+ if: ${{ matrix.test_task == 'check' || matrix.test_task == 'test-spec' || StartsWith(matrix.test_task, 'spec/') }}
- - uses: ruby/action-slack@b6882ea6ef8f556f9f9af9ec1220d3f1ced74acf # v3.0.0
+ - uses: ./src/.github/actions/slack
with:
- payload: |
- {
- "ci": "GitHub Actions",
- "env": "${{ github.workflow }} ${{ matrix.msystem }} / ${{ matrix.test_task }}",
- "url": "https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}",
- "commit": "${{ github.sha }}",
- "branch": "${{ github.ref_name }}"
- }
- env:
+ label: ${{ matrix.msystem }} / ${{ matrix.test_task }}
SLACK_WEBHOOK_URL: ${{ secrets.SIMPLER_ALERTS_URL }} # ruby-lang slack: ruby/simpler-alerts-bot
- if: ${{ failure() && github.event_name == 'push' }}
+ if: ${{ failure() }}
defaults:
run:
diff --git a/.github/workflows/mjit-bindgen.yml b/.github/workflows/mjit-bindgen.yml
deleted file mode 100644
index 4528c086ad..0000000000
--- a/.github/workflows/mjit-bindgen.yml
+++ /dev/null
@@ -1,97 +0,0 @@
-name: MJIT bindgen
-on:
- push:
- paths-ignore:
- - 'doc/**'
- - '**/man'
- - '**.md'
- - '**.rdoc'
- - '**/.document'
- pull_request:
- paths-ignore:
- - 'doc/**'
- - '**/man'
- - '**.md'
- - '**.rdoc'
- - '**/.document'
-
-concurrency:
- group: ${{ github.workflow }} / ${{ startsWith(github.event_name, 'pull') && github.ref_name || github.sha }}
- cancel-in-progress: ${{ startsWith(github.event_name, 'pull') }}
-
-permissions:
- contents: read
-
-jobs:
- make:
- strategy:
- matrix:
- include:
- - task: mjit-bindgen
- fail-fast: false
- runs-on: ubuntu-20.04
- if: ${{ !contains(github.event.head_commit.message, '[DOC]') && !contains(github.event.pull_request.labels.*.name, 'Documentation') }}
- steps:
- - run: mkdir build
- working-directory:
- - name: Set ENV
- run: |
- echo "GNUMAKEFLAGS=-j$((1 + $(nproc --all)))" >> $GITHUB_ENV
- - name: Install libraries
- run: |
- set -x
- sudo apt-get update -q || :
- sudo apt-get install --no-install-recommends -q -y \
- build-essential \
- libssl-dev libyaml-dev libreadline6-dev \
- zlib1g-dev libncurses5-dev libffi-dev \
- libclang1-10 \
- bison autoconf
- sudo apt-get install -q -y pkg-config || :
- - name: Set up Ruby
- uses: ruby/setup-ruby@ee26e27437bde475b19a6bf8cb73c9fa658876a2 # v1.134.0
- with:
- ruby-version: '3.1'
- - name: git config
- run: |
- git config --global advice.detachedHead 0
- git config --global init.defaultBranch garbage
- - uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
- with:
- path: src
- - uses: actions/cache@627f0f41f6904a5b1efbaed9f96d9eb58e92e920 # v3.2.4
- with:
- path: src/.downloaded-cache
- key: downloaded-cache
- - name: Fixed world writable dirs
- run: |
- chmod -v go-w $HOME $HOME/.config
- sudo chmod -R go-w /usr/share
- sudo bash -c 'IFS=:; for d in '"$PATH"'; do chmod -v go-w $d; done' || :
- - run: ./autogen.sh
- working-directory: src
- - name: Run configure
- run: ../src/configure -C --disable-install-doc --prefix=$(pwd)/install --enable-yjit=dev_nodebug
- - run: make incs
- - run: make
- - run: make install
- - run: make ${{ matrix.task }}
- - run: git diff --exit-code
- working-directory: src
- - uses: ruby/action-slack@b6882ea6ef8f556f9f9af9ec1220d3f1ced74acf # v3.0.0
- with:
- payload: |
- {
- "ci": "GitHub Actions",
- "env": "${{ matrix.os }} / ${{ matrix.test_task }}${{ matrix.configure }}",
- "url": "https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}",
- "commit": "${{ github.sha }}",
- "branch": "${{ github.ref_name }}"
- }
- env:
- SLACK_WEBHOOK_URL: ${{ secrets.SIMPLER_ALERTS_URL }} # ruby-lang slack: ruby/simpler-alerts-bot
- if: ${{ failure() && github.event_name == 'push' }}
-
-defaults:
- run:
- working-directory: build
diff --git a/.github/workflows/mjit.yml b/.github/workflows/mjit.yml
deleted file mode 100644
index 2dac2b7b6b..0000000000
--- a/.github/workflows/mjit.yml
+++ /dev/null
@@ -1,103 +0,0 @@
-name: MJIT
-on:
- push:
- paths-ignore:
- - 'doc/**'
- - '**/man'
- - '**.md'
- - '**.rdoc'
- - '**/.document'
- pull_request:
- paths-ignore:
- - 'doc/**'
- - '**/man'
- - '**.md'
- - '**.rdoc'
- - '**/.document'
-
-concurrency:
- group: ${{ github.workflow }} / ${{ startsWith(github.event_name, 'pull') && github.ref_name || github.sha }}
- cancel-in-progress: ${{ startsWith(github.event_name, 'pull') }}
-
-permissions:
- contents: read
-
-jobs:
- make:
- strategy:
- matrix:
- test_task: [check] # to make job names consistent
- mjit_opts: [--mjit-wait]
- fail-fast: false
- runs-on: ubuntu-latest
- if: ${{ !contains(github.event.head_commit.message, '[DOC]') && !contains(github.event.pull_request.labels.*.name, 'Documentation') }}
- env:
- TESTOPTS: '-q --tty=no'
- RUN_OPTS: '--disable-gems ${{ matrix.mjit_opts }} --mjit-debug=-ggdb3'
- GITPULLOPTIONS: --no-tags origin ${{github.ref}}
- steps:
- - run: mkdir build
- working-directory:
- - name: Install libraries
- run: |
- set -x
- sudo apt-get update -q || :
- sudo apt-get install --no-install-recommends -q -y build-essential libssl-dev libyaml-dev libreadline6-dev zlib1g-dev libncurses5-dev libffi-dev bison autoconf ruby
- - name: git config
- run: |
- git config --global advice.detachedHead 0
- git config --global init.defaultBranch garbage
- - uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
- with:
- path: src
- - uses: actions/cache@627f0f41f6904a5b1efbaed9f96d9eb58e92e920 # v3.2.4
- with:
- path: src/.downloaded-cache
- key: downloaded-cache
- - name: Fixed world writable dirs
- run: |
- chmod -v go-w $HOME $HOME/.config
- sudo chmod -R go-w /usr/share
- sudo bash -c 'IFS=:; for d in '"$PATH"'; do chmod -v go-w $d; done' || :
- - name: Set ENV
- run: |
- echo "GNUMAKEFLAGS=-j$((1 + $(nproc --all)))" >> $GITHUB_ENV
- - run: ./autogen.sh
- working-directory: src
- - name: Run configure
- run: ../src/configure -C --disable-install-doc cppflags=-DVM_CHECK_MODE
- - run: make incs
- - run: make
- - run: sudo make -s install
- - name: Run test
- run: |
- unset GNUMAKEFLAGS
- make -s test RUN_OPTS="$RUN_OPTS"
- timeout-minutes: 60
- # - name: Run test-all
- # run: |
- # ulimit -c unlimited
- # make -s test-all RUN_OPTS="$RUN_OPTS"
- # timeout-minutes: 60
- - name: Run test-spec
- run: |
- unset GNUMAKEFLAGS
- make -s test-spec RUN_OPTS="$RUN_OPTS"
- timeout-minutes: 60
- - uses: ruby/action-slack@b6882ea6ef8f556f9f9af9ec1220d3f1ced74acf # v3.0.0
- with:
- payload: |
- {
- "ci": "GitHub Actions",
- "env": "${{ github.workflow }} / ${{ matrix.test_task }} ${{ matrix.mjit_opts }}",
- "url": "https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}",
- "commit": "${{ github.sha }}",
- "branch": "${{ github.ref_name }}"
- }
- env:
- SLACK_WEBHOOK_URL: ${{ secrets.SIMPLER_ALERTS_URL }} # ruby-lang slack: ruby/simpler-alerts-bot
- if: ${{ failure() && github.event_name == 'push' }}
-
-defaults:
- run:
- working-directory: build
diff --git a/.github/workflows/rjit-bindgen.yml b/.github/workflows/rjit-bindgen.yml
new file mode 100644
index 0000000000..bf3c752e7b
--- /dev/null
+++ b/.github/workflows/rjit-bindgen.yml
@@ -0,0 +1,91 @@
+name: RJIT bindgen
+on:
+ push:
+ paths-ignore:
+ - 'doc/**'
+ - '**/man'
+ - '**.md'
+ - '**.rdoc'
+ - '**/.document'
+ - '.*.yml'
+ pull_request:
+ paths-ignore:
+ - 'doc/**'
+ - '**/man'
+ - '**.md'
+ - '**.rdoc'
+ - '**/.document'
+ - '.*.yml'
+ merge_group:
+ paths-ignore:
+ - 'doc/**'
+ - '**/man'
+ - '**.md'
+ - '**.rdoc'
+ - '**/.document'
+ - '.*.yml'
+
+concurrency:
+ group: ${{ github.workflow }} / ${{ startsWith(github.event_name, 'pull') && github.ref_name || github.sha }}
+ cancel-in-progress: ${{ startsWith(github.event_name, 'pull') }}
+
+permissions:
+ contents: read
+
+jobs:
+ make:
+ strategy:
+ matrix:
+ include:
+ - task: rjit-bindgen
+ fail-fast: false
+
+ runs-on: ubuntu-20.04
+
+ if: >-
+ ${{!(false
+ || contains(github.event.head_commit.message, '[DOC]')
+ || contains(github.event.pull_request.title, '[DOC]')
+ || contains(github.event.pull_request.labels.*.name, 'Documentation')
+ || (github.event_name == 'push' && github.actor == 'dependabot[bot]')
+ )}}
+
+ steps:
+ - name: Set up Ruby
+ uses: ruby/setup-ruby@036ef458ddccddb148a2b9fb67e95a22fdbf728b # v1.160.0
+ with:
+ ruby-version: '3.1'
+
+ - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
+ with:
+ sparse-checkout-cone-mode: false
+ sparse-checkout: /.github
+
+ - uses: ./.github/actions/setup/ubuntu
+
+ - uses: ./.github/actions/setup/directories
+ with:
+ srcdir: src
+ builddir: build
+ makeup: true
+
+ - name: Run configure
+ run: ../src/configure -C --disable-install-doc --prefix=$(pwd)/install --enable-yjit=dev_nodebug
+
+ - run: make
+
+ - run: make install
+
+ - run: make ${{ matrix.task }}
+
+ - run: git diff --exit-code
+ working-directory: src
+
+ - uses: ./.github/actions/slack
+ with:
+ SLACK_WEBHOOK_URL: ${{ secrets.SIMPLER_ALERTS_URL }} # ruby-lang slack: ruby/simpler-alerts-bot
+ if: ${{ failure() }}
+
+defaults:
+ run:
+ working-directory: build
diff --git a/.github/workflows/rjit.yml b/.github/workflows/rjit.yml
new file mode 100644
index 0000000000..bf9122f581
--- /dev/null
+++ b/.github/workflows/rjit.yml
@@ -0,0 +1,120 @@
+name: RJIT
+on:
+ push:
+ paths-ignore:
+ - 'doc/**'
+ - '**.md'
+ - '**.rdoc'
+ - '**/.document'
+ - '**.[1-8]'
+ - '**.ronn'
+ - '.*.yml'
+ pull_request:
+ paths-ignore:
+ - 'doc/**'
+ - '**.md'
+ - '**.rdoc'
+ - '**/.document'
+ - '**.[1-8]'
+ - '**.ronn'
+ - '.*.yml'
+ merge_group:
+ paths-ignore:
+ - 'doc/**'
+ - '**.md'
+ - '**.rdoc'
+ - '**/.document'
+ - '**.[1-8]'
+ - '**.ronn'
+ - '.*.yml'
+
+concurrency:
+ group: ${{ github.workflow }} / ${{ startsWith(github.event_name, 'pull') && github.ref_name || github.sha }}
+ cancel-in-progress: ${{ startsWith(github.event_name, 'pull') }}
+
+permissions:
+ contents: read
+
+jobs:
+ make:
+ strategy:
+ matrix:
+ # main variables included in the job name
+ test_task: [check]
+ run_opts: ['--rjit-call-threshold=1']
+ arch: ['']
+ fail-fast: false
+
+ env:
+ GITPULLOPTIONS: --no-tags origin ${{ github.ref }}
+ RUBY_DEBUG: ci
+ SETARCH: ${{ matrix.arch && format('setarch {0}', matrix.arch) }}
+
+ runs-on: ubuntu-22.04
+
+ if: >-
+ ${{!(false
+ || contains(github.event.head_commit.message, '[DOC]')
+ || contains(github.event.pull_request.title, '[DOC]')
+ || contains(github.event.pull_request.labels.*.name, 'Documentation')
+ || (github.event_name == 'push' && github.actor == 'dependabot[bot]')
+ )}}
+
+ steps:
+ - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
+ with:
+ sparse-checkout-cone-mode: false
+ sparse-checkout: /.github
+
+ - uses: ./.github/actions/setup/ubuntu
+
+ - uses: ./.github/actions/setup/directories
+ with:
+ srcdir: src
+ builddir: build
+ makeup: true
+
+ - name: Run configure
+ env:
+ arch: ${{ matrix.arch }}
+ run: >-
+ $SETARCH ../src/configure -C --disable-install-doc cppflags=-DRUBY_DEBUG
+ ${arch:+--target=$arch-$OSTYPE --host=$arch-$OSTYPE}
+
+ - run: $SETARCH make
+
+ - name: make test
+ run: |
+ $SETARCH make -s test RUN_OPTS="$RUN_OPTS"
+ timeout-minutes: 30
+ env:
+ GNUMAKEFLAGS: ''
+ RUBY_TESTOPTS: '-v --tty=no'
+ RUN_OPTS: ${{ matrix.run_opts }}
+
+ - name: make test-all
+ run: |
+ $SETARCH make -s test-all RUN_OPTS="$RUN_OPTS"
+ timeout-minutes: 40
+ env:
+ GNUMAKEFLAGS: ''
+ RUBY_TESTOPTS: '-q --tty=no'
+ RUN_OPTS: ${{ matrix.run_opts }}
+
+ - name: make test-spec
+ run: |
+ $SETARCH make -s test-spec RUN_OPTS="$RUN_OPTS"
+ timeout-minutes: 10
+ env:
+ GNUMAKEFLAGS: ''
+ RUN_OPTS: ${{ matrix.run_opts }}
+
+ - uses: ./.github/actions/slack
+ with:
+ label: ${{ matrix.run_opts }}
+ SLACK_WEBHOOK_URL: ${{ secrets.SIMPLER_ALERTS_URL }} # ruby-lang slack: ruby/simpler-alerts-bot
+ if: ${{ failure() }}
+
+defaults:
+ run:
+ working-directory: build
diff --git a/.github/workflows/scorecards.yml b/.github/workflows/scorecards.yml
index c41bd60736..51ce54a518 100644
--- a/.github/workflows/scorecards.yml
+++ b/.github/workflows/scorecards.yml
@@ -11,8 +11,8 @@ on:
# https://github.com/ossf/scorecard/blob/main/docs/checks.md#maintained
schedule:
- cron: '22 4 * * 2'
- push:
- branches: [ "master" ]
+ # push:
+ # branches: [ "master" ]
# Declare default permissions as read only.
permissions: read-all
@@ -31,13 +31,13 @@ jobs:
# actions: read
steps:
- - name: "Checkout code"
- uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
+ - name: 'Checkout code'
+ uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
with:
persist-credentials: false
- - name: "Run analysis"
- uses: ossf/scorecard-action@e38b1902ae4f44df626f11ba0734b14fb91f8f86 # v2.1.2
+ - name: 'Run analysis'
+ uses: ossf/scorecard-action@0864cf19026789058feabb7e87baa5f140aac736 # v2.3.1
with:
results_file: results.sarif
results_format: sarif
@@ -58,15 +58,15 @@ jobs:
# Upload the results as artifacts (optional). Commenting out will disable uploads of run results in SARIF
# format to the repository Actions tab.
- - name: "Upload artifact"
- uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v3.1.2
- with:
- name: SARIF file
- path: results.sarif
- retention-days: 5
+ # - name: "Upload artifact"
+ # uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v3.1.2
+ # with:
+ # name: SARIF file
+ # path: results.sarif
+ # retention-days: 5
# Upload the results to GitHub's code scanning dashboard.
- - name: "Upload to code-scanning"
- uses: github/codeql-action/upload-sarif@3ebbd71c74ef574dbc558c82f70e52732c8b44fe # v2.1.27
+ - name: 'Upload to code-scanning'
+ uses: github/codeql-action/upload-sarif@cdcdbb579706841c47f7063dda365e292e5cad7a # v2.1.27
with:
sarif_file: results.sarif
diff --git a/.github/workflows/spec_guards.yml b/.github/workflows/spec_guards.yml
index ed89b5e159..e14e7818a6 100644
--- a/.github/workflows/spec_guards.yml
+++ b/.github/workflows/spec_guards.yml
@@ -9,6 +9,10 @@ on:
paths-ignore:
- 'spec/**'
- '!spec/*.md'
+ merge_group:
+ paths-ignore:
+ - 'spec/**'
+ - '!spec/*.md'
concurrency:
group: ${{ github.workflow }} / ${{ startsWith(github.event_name, 'pull') && github.ref_name || github.sha }}
@@ -20,38 +24,43 @@ permissions:
jobs:
rubyspec:
name: Rubyspec
+
runs-on: ubuntu-20.04
- if: ${{ !contains(github.event.head_commit.message, '[DOC]') && !contains(github.event.pull_request.labels.*.name, 'Documentation') }}
+
+ if: >-
+ ${{!(false
+ || contains(github.event.head_commit.message, '[DOC]')
+ || contains(github.event.pull_request.title, '[DOC]')
+ || contains(github.event.pull_request.labels.*.name, 'Documentation')
+ || (github.event_name == 'push' && github.actor == 'dependabot[bot]')
+ )}}
+
strategy:
matrix:
# Specs from ruby/spec should still run on all supported Ruby versions.
# This also ensures the needed ruby_version_is guards are there, see spec/README.md.
ruby:
- - ruby-2.7
+ - ruby-3.0
- ruby-3.1
- ruby-3.2
steps:
- - uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
- - uses: ruby/setup-ruby@ee26e27437bde475b19a6bf8cb73c9fa658876a2 # v1.134.0
+ - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
+
+ - uses: ruby/setup-ruby@036ef458ddccddb148a2b9fb67e95a22fdbf728b # v1.160.0
with:
ruby-version: ${{ matrix.ruby }}
bundler: none
+
- run: gem install webrick
+
- run: ruby ../mspec/bin/mspec
working-directory: spec/ruby
env:
CHECK_LEAKS: true
- - uses: ruby/action-slack@b6882ea6ef8f556f9f9af9ec1220d3f1ced74acf # v3.0.0
+
+ - uses: ./.github/actions/slack
with:
- payload: |
- {
- "ci": "GitHub Actions",
- "env": "${{ github.workflow }} / rubyspec @ ${{ matrix.ruby }}",
- "url": "https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}",
- "commit": "${{ github.sha }}",
- "branch": "${{ github.ref_name }}"
- }
- env:
+ label: ${{ matrix.ruby }}
SLACK_WEBHOOK_URL: ${{ secrets.SIMPLER_ALERTS_URL }} # ruby-lang slack: ruby/simpler-alerts-bot
- if: ${{ failure() && github.event_name == 'push' }}
+ if: ${{ failure() }}
diff --git a/.github/workflows/ubuntu.yml b/.github/workflows/ubuntu.yml
index 045a952e20..93ced0d1d2 100644
--- a/.github/workflows/ubuntu.yml
+++ b/.github/workflows/ubuntu.yml
@@ -7,13 +7,18 @@ on:
- '**.md'
- '**.rdoc'
- '**/.document'
+ - '.*.yml'
pull_request:
+ # Do not use paths-ignore for required status checks
+ # https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/collaborating-on-repositories-with-code-quality-features/troubleshooting-required-status-checks#handling-skipped-but-required-checks
+ merge_group:
paths-ignore:
- 'doc/**'
- '**/man'
- '**.md'
- '**.rdoc'
- '**/.document'
+ - '.*.yml'
concurrency:
group: ${{ github.workflow }} / ${{ startsWith(github.event_name, 'pull') && github.ref_name || github.sha }}
@@ -29,108 +34,98 @@ jobs:
test_task: [check]
arch: ['']
configure: ['cppflags=-DVM_CHECK_MODE']
- # specifying everything else with `include` to avoid redundant tests
+ # specifying other jobs with `include` to avoid redundant tests
include:
- test_task: check
arch: i686
- test_task: check
+ configure: '--disable-yjit'
+ - test_task: check
configure: '--enable-shared --enable-load-relative'
- - test_task: test-all TESTS=--repeat-count=2
- test_task: test-bundler-parallel
- test_task: test-bundled-gems
fail-fast: false
+
env:
- GITPULLOPTIONS: --no-tags origin ${{github.ref}}
+ GITPULLOPTIONS: --no-tags origin ${{ github.ref }}
RUBY_DEBUG: ci
- SETARCH: ${{ matrix.arch && format('setarch {0}', matrix.arch) }}
+
runs-on: ubuntu-20.04
- if: ${{ !contains(github.event.head_commit.message, '[DOC]') && !contains(github.event.pull_request.labels.*.name, 'Documentation') }}
+
+ if: >-
+ ${{!(false
+ || contains(github.event.head_commit.message, '[DOC]')
+ || contains(github.event.pull_request.title, '[DOC]')
+ || contains(github.event.pull_request.labels.*.name, 'Documentation')
+ || (github.event_name == 'push' && github.actor == 'dependabot[bot]')
+ )}}
+
steps:
- - run: mkdir build
- working-directory:
- - name: Set ENV
- run: |
- echo "GNUMAKEFLAGS=-j$((1 + $(nproc --all)))" >> $GITHUB_ENV
- - name: Install libraries
- env:
- arch: ${{matrix.arch}}
- run: |
- set -x
- arch=${arch:+:${arch/i[3-6]86/i386}}
- ${arch:+sudo dpkg --add-architecture ${arch#:}}
- sudo apt-get update -q || :
- sudo apt-get install --no-install-recommends -q -y \
- ${arch:+cross}build-essential${arch/:/-} \
- libssl-dev${arch} libyaml-dev${arch} libreadline6-dev${arch} \
- zlib1g-dev${arch} libncurses5-dev${arch} libffi-dev${arch} \
- bison autoconf ruby
- sudo apt-get install -q -y pkg-config${arch} || :
- - name: git config
- run: |
- git config --global advice.detachedHead 0
- git config --global init.defaultBranch garbage
- - uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
+ - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
+ with:
+ sparse-checkout-cone-mode: false
+ sparse-checkout: /.github
+
+ - uses: ./.github/actions/setup/ubuntu
with:
- path: src
- - uses: actions/cache@627f0f41f6904a5b1efbaed9f96d9eb58e92e920 # v3.2.4
+ arch: ${{ matrix.arch }}
+
+ - uses: ./.github/actions/setup/directories
with:
- path: src/.downloaded-cache
- key: downloaded-cache
- - name: Fixed world writable dirs
- run: |
- chmod -v go-w $HOME $HOME/.config
- sudo chmod -R go-w /usr/share
- sudo bash -c 'IFS=:; for d in '"$PATH"'; do chmod -v go-w $d; done' || :
- - run: ./autogen.sh
- working-directory: src
+ srcdir: src
+ builddir: build
+ makeup: true
+ dummy-files: ${{ matrix.test_task == 'check' }}
+
- name: Run configure
env:
- arch: ${{matrix.arch}}
- configure: ${{matrix.configure}}
+ arch: ${{ matrix.arch }}
+ configure: ${{ matrix.configure }}
run: >-
$SETARCH ../src/configure -C --disable-install-doc ${configure:-cppflags=-DRUBY_DEBUG}
${arch:+--target=$arch-$OSTYPE --host=$arch-$OSTYPE}
- - run: $SETARCH make incs
+
- run: $SETARCH make prepare-gems
if: ${{ matrix.test_task == 'test-bundled-gems' }}
+
- run: $SETARCH make
- - run: $SETARCH make leaked-globals
- if: ${{ matrix.test_task == 'check' }}
- - name: Create dummy files in build dir
- run: |
- $SETARCH ./miniruby -e '(("a".."z").to_a+("A".."Z").to_a+("0".."9").to_a+%w[foo bar test zzz]).each{|basename|File.write("#{basename}.rb", "raise %(do not load #{basename}.rb)")}'
- if: ${{ matrix.test_task == 'check' }}
+
- name: make ${{ matrix.test_task }}
- run: |
- $SETARCH make -s ${{ matrix.test_task }} ${TESTS:+TESTS=`echo "$TESTS" | sed 's| |$$/ -n!/|g;s|^|-n!/|;s|$|$$/|'`}
+ run: >-
+ $SETARCH make -s ${{ matrix.test_task }}
+ ${TESTS:+TESTS=`echo "$TESTS" | sed 's| |$$/ -n!/|g;s|^|-n!/|;s|$|$$/|'`}
+ ${{ !contains(matrix.test_task, 'bundle') && 'RUBYOPT=-w' || '' }}
timeout-minutes: 40
env:
- RUBY_TESTOPTS: "-q --tty=no"
+ RUBY_TESTOPTS: '-q --tty=no'
TESTS: ${{ matrix.test_task == 'check' && matrix.skipped_tests || '' }}
- TEST_BUNDLED_GEMS_ALLOW_FAILURES: ""
- PRECHECK_BUNDLED_GEMS: "no"
+ TEST_BUNDLED_GEMS_ALLOW_FAILURES: ''
+ PRECHECK_BUNDLED_GEMS: 'no'
+
- name: make skipped tests
run: |
$SETARCH make -s test-all TESTS=`echo "$TESTS" | sed 's| |$$/ -n/|g;s|^|-n/|;s|$|$$/|'`
env:
- GNUMAKEFLAGS: ""
- RUBY_TESTOPTS: "-v --tty=no"
+ GNUMAKEFLAGS: ''
+ RUBY_TESTOPTS: '-v --tty=no'
TESTS: ${{ matrix.skipped_tests }}
if: ${{ matrix.test_task == 'check' && matrix.skipped_tests != '' }}
continue-on-error: ${{ matrix.continue-on-skipped_tests || false }}
- - uses: ruby/action-slack@b6882ea6ef8f556f9f9af9ec1220d3f1ced74acf # v3.0.0
+
+ - uses: ./.github/actions/slack
with:
- payload: |
- {
- "ci": "GitHub Actions",
- "env": "${{ github.workflow }} / ${{ matrix.test_task }} ${{ matrix.configure }}${{ matrix.arch }}",
- "url": "https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}",
- "commit": "${{ github.sha }}",
- "branch": "${{ github.ref_name }}"
- }
- env:
+ label: ${{ matrix.test_task }} ${{ matrix.configure }}${{ matrix.arch }}
SLACK_WEBHOOK_URL: ${{ secrets.SIMPLER_ALERTS_URL }} # ruby-lang slack: ruby/simpler-alerts-bot
- if: ${{ failure() && github.event_name == 'push' }}
+ if: ${{ failure() }}
+
+ result:
+ if: ${{ always() }}
+ name: ${{ github.workflow }} result
+ runs-on: ubuntu-latest
+ needs: [make]
+ steps:
+ - run: exit 1
+ if: ${{ contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled') }}
defaults:
run:
diff --git a/.github/workflows/wasm.yml b/.github/workflows/wasm.yml
index 2f69e001b6..f69df0f58d 100644
--- a/.github/workflows/wasm.yml
+++ b/.github/workflows/wasm.yml
@@ -7,6 +7,7 @@ on:
- '**.md'
- '**.rdoc'
- '**/.document'
+ - '.*.yml'
pull_request:
paths-ignore:
- 'doc/**'
@@ -14,12 +15,21 @@ on:
- '**.md'
- '**.rdoc'
- '**/.document'
+ - '.*.yml'
+ merge_group:
+ paths-ignore:
+ - 'doc/**'
+ - '**/man'
+ - '**.md'
+ - '**.rdoc'
+ - '**/.document'
+ - '.*.yml'
concurrency:
group: ${{ github.workflow }} / ${{ startsWith(github.event_name, 'pull') && github.ref_name || github.sha }}
cancel-in-progress: ${{ startsWith(github.event_name, 'pull') }}
-permissions: # added using https://github.com/step-security/secure-workflows
+permissions: # added using https://github.com/step-security/secure-workflows
contents: read
jobs:
@@ -28,38 +38,50 @@ jobs:
matrix:
entry:
# # wasmtime can't compile non-optimized Asyncified binary due to locals explosion
-# - { name: O0-debuginfo, optflags: "-O0", debugflags: "-g", wasmoptflags: "-O1" }
-# - { name: O1, optflags: "-O1", debugflags: "" , wasmoptflags: "-O1" }
- - { name: O2, optflags: "-O2", debugflags: "" , wasmoptflags: "-O2" }
-# - { name: O3, optflags: "-O3", debugflags: "" , wasmoptflags: "-O3" }
+# - { name: O0-debuginfo, optflags: '-O0', debugflags: '-g', wasmoptflags: '-O1' }
+# - { name: O1, optflags: '-O1', debugflags: '' , wasmoptflags: '-O1' }
+ - { name: O2, optflags: '-O2', debugflags: '', wasmoptflags: '-O2' }
+# - { name: O3, optflags: '-O3', debugflags: '' , wasmoptflags: '-O3' }
# # -O4 is equivalent to -O3 in clang, but it's different in wasm-opt
-# - { name: O4, optflags: "-O3", debugflags: "" , wasmoptflags: "-O4" }
-# - { name: Oz, optflags: "-Oz", debugflags: "" , wasmoptflags: "-Oz" }
+# - { name: O4, optflags: '-O3', debugflags: '' , wasmoptflags: '-O4' }
+# - { name: Oz, optflags: '-Oz', debugflags: '' , wasmoptflags: '-Oz' }
fail-fast: false
+
env:
RUBY_TESTOPTS: '-q --tty=no'
- GITPULLOPTIONS: --no-tags origin ${{github.ref}}
- WASI_SDK_VERSION_MAJOR: 14
+ GITPULLOPTIONS: --no-tags origin ${{ github.ref }}
+ WASI_SDK_VERSION_MAJOR: 20
WASI_SDK_VERSION_MINOR: 0
- BINARYEN_VERSION: 109
- WASMTIME_VERSION: v0.33.0
+ BINARYEN_VERSION: 113
+ WASMTIME_VERSION: v15.0.0
+
runs-on: ubuntu-20.04
- if: ${{ !contains(github.event.head_commit.message, '[DOC]') && !contains(github.event.pull_request.labels.*.name, 'Documentation') }}
+
+ if: >-
+ ${{!(false
+ || contains(github.event.head_commit.message, '[DOC]')
+ || contains(github.event.pull_request.title, '[DOC]')
+ || contains(github.event.pull_request.labels.*.name, 'Documentation')
+ || (github.event_name == 'push' && github.actor == 'dependabot[bot]')
+ )}}
+
steps:
- - run: mkdir build
- working-directory:
- - name: git config
- run: |
- git config --global advice.detachedHead 0
- git config --global init.defaultBranch garbage
- - uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
+ - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
+ with:
+ sparse-checkout-cone-mode: false
+ sparse-checkout: /.github
+
+ - uses: ./.github/actions/setup/directories
with:
- path: src
+ srcdir: src
+ builddir: build
+ makeup: true
+
- name: Install libraries
run: |
set -ex
sudo apt-get update -q || :
- sudo apt-get install --no-install-recommends -q -y ruby bison make autoconf git wget
+ sudo apt-get install --no-install-recommends -q -y ruby make autoconf git wget
wasi_sdk_deb="wasi-sdk_${WASI_SDK_VERSION_MAJOR}.${WASI_SDK_VERSION_MINOR}_amd64.deb"
wget "https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-${WASI_SDK_VERSION_MAJOR}/${wasi_sdk_deb}"
@@ -78,17 +100,27 @@ jobs:
wget -O - "$binaryen_url" | tar xfz -
sudo ln -fs "$PWD/binaryen-version_${BINARYEN_VERSION}/bin/wasm-opt" /usr/local/bin/wasm-opt
working-directory: src
+
- name: Set ENV
run: |
- echo "MAKEFLAGS=-j$((1 + $(sysctl -n hw.activecpu)))" >> $GITHUB_ENV
echo "WASI_SDK_PATH=/opt/wasi-sdk" >> $GITHUB_ENV
- - run: ./autogen.sh
- working-directory: src
+
+ - name: Build baseruby
+ run: |
+ set -ex
+ mkdir ../baseruby
+ pushd ../baseruby
+ ../src/configure --prefix=$PWD/install
+ make
+ make install
+
- name: Run configure
run: |
../src/configure \
--host wasm32-unknown-wasi \
+ --with-baseruby=$PWD/../baseruby/install/bin/ruby \
--with-static-linked-ext \
+ --with-ext=bigdecimal,cgi/escape,continuation,coverage,date,dbm,digest/bubblebabble,digest,digest/md5,digest/rmd160,digest/sha1,digest/sha2,etc,fcntl,fiber,gdbm,json,json/generator,json/parser,nkf,objspace,pathname,racc/cparse,rbconfig/sizeof,ripper,stringio,strscan,monitor \
LDFLAGS=" \
-Xlinker --stack-first \
-Xlinker -z -Xlinker stack-size=16777216 \
@@ -99,28 +131,31 @@ jobs:
# miniruby may not be built when cross-compling
- run: make mini ruby
+
+ - run: make install DESTDIR=$PWD/../install
+ - run: tar cfz ../install.tar.gz -C ../install .
+
+ - name: Upload artifacts
+ uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 # v3.1.3
+ with:
+ name: ruby-wasm-install
+ path: ${{ github.workspace }}/install.tar.gz
+
- name: Run basictest
run: wasmtime run ./../build/miniruby --mapdir /::./ -- basictest/test.rb
working-directory: src
+
- name: Run bootstraptest (no thread)
run: |
NO_THREAD_TESTS="$(grep -L Thread -R ./bootstraptest | awk -F/ '{ print $NF }' | uniq | sed -n 's/test_\(.*\).rb/\1/p' | paste -s -d, -)"
ruby ./bootstraptest/runner.rb --ruby="$(which wasmtime) run $PWD/../build/ruby --mapdir /::./ -- " --verbose "--sets=$NO_THREAD_TESTS"
working-directory: src
- - uses: ruby/action-slack@b6882ea6ef8f556f9f9af9ec1220d3f1ced74acf # v3.0.0
+ - uses: ./.github/actions/slack
with:
- payload: |
- {
- "ci": "GitHub Actions",
- "env": "${{ github.workflow }} / ${{ matrix.name }}",
- "url": "https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}",
- "commit": "${{ github.sha }}",
- "branch": "${{ github.ref_name }}"
- }
- env:
+ label: ${{ matrix.entry.name }}
SLACK_WEBHOOK_URL: ${{ secrets.SIMPLER_ALERTS_URL }} # ruby-lang slack: ruby/simpler-alerts-bot
- if: ${{ failure() && github.event_name == 'push' }}
+ if: ${{ failure() }}
defaults:
run:
diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml
index 195786be1a..8b34f962fe 100644
--- a/.github/workflows/windows.yml
+++ b/.github/workflows/windows.yml
@@ -7,6 +7,7 @@ on:
- '**.md'
- '**.rdoc'
- '**/.document'
+ - '.*.yml'
pull_request:
paths-ignore:
- 'doc/**'
@@ -14,6 +15,15 @@ on:
- '**.md'
- '**.rdoc'
- '**/.document'
+ - '.*.yml'
+ merge_group:
+ paths-ignore:
+ - 'doc/**'
+ - '**/man'
+ - '**.md'
+ - '**.rdoc'
+ - '**/.document'
+ - '.*.yml'
concurrency:
group: ${{ github.workflow }} / ${{ startsWith(github.event_name, 'pull') && github.ref_name || github.sha }}
@@ -30,128 +40,160 @@ jobs:
- vs: 2019
- vs: 2022
fail-fast: false
+
runs-on: windows-${{ matrix.vs < 2022 && '2019' || matrix.vs }}
- if: ${{ !contains(github.event.head_commit.message, '[DOC]') && !contains(github.event.pull_request.labels.*.name, 'Documentation') }}
+
+ if: >-
+ ${{!(false
+ || contains(github.event.head_commit.message, '[DOC]')
+ || contains(github.event.pull_request.title, '[DOC]')
+ || contains(github.event.pull_request.labels.*.name, 'Documentation')
+ || (github.event_name == 'push' && github.actor == 'dependabot[bot]')
+ )}}
+
name: VisualStudio ${{ matrix.vs }}
+
env:
- GITPULLOPTIONS: --no-tags origin ${{github.ref}}
- PATCH: C:\msys64\usr\bin\patch.exe
+ GITPULLOPTIONS: --no-tags origin ${{ github.ref }}
OS_VER: windows-${{ matrix.vs < 2022 && '2019' || matrix.vs }}
+ # FIXME: This is a workaround for the vcpkg's issue present as of openssl 3.1.1
+ # where OpenSSL's default modules directory is incorrectly set to C:\vcpkg\packages\openssl_x64-windows\bin
+ # cf. https://github.com/ruby/openssl/pull/635#issuecomment-1596833720
+ OPENSSL_MODULES: C:\vcpkg\installed\x64-windows\bin
+
steps:
- run: md build
working-directory:
+
+ - name: find tools
+ id: find-tools
+ run: |
+ ::- find needed tools
+ set NEEDS=
+ for %%I in (%NEEDED_TOOLS%) do if "%%~$PATH:I" == "" (
+ call set NEEDS=%%NEEDS%% %%~nI
+ ) else (
+ echo %%I: %%~$PATH:I
+ )
+ echo.needs=%NEEDS%>>%GITHUB_OUTPUT%
+ if "%NEEDS%" == "" (
+ echo [debug] All needed tools found
+ ) else (
+ echo [warning^]Needs%NEEDS%
+ )
+ env:
+ NEEDED_TOOLS: >-
+ patch.exe
+
- uses: msys2/setup-msys2@d40200dc2db4c351366b048a9565ad82919e1c24 # v2
id: setup-msys2
with:
update: true
install: >-
- patch
- if: ${{ env.OS_VER != 'windows-2019' }}
- - name: patch path
- shell: msys2 {0}
- run: echo PATCH=$(cygpath -wa $(command -v patch)) >> $GITHUB_ENV
- if: ${{ steps.setup-msys2.outcome == 'success' }}
- - uses: actions/cache@627f0f41f6904a5b1efbaed9f96d9eb58e92e920 # v3.2.4
+ ${{ steps.find-tools.outputs.needs }}
+ if: ${{ steps.find-tools.outputs.needs != '' }}
+
+ - uses: actions/cache@704facf57e6136b1bc63b828d79edcd491f0ee84 # v3.3.2
with:
path: C:\vcpkg\downloads
key: ${{ runner.os }}-vcpkg-download-${{ env.OS_VER }}-${{ github.sha }}
restore-keys: |
${{ runner.os }}-vcpkg-download-${{ env.OS_VER }}-
${{ runner.os }}-vcpkg-download-
- - uses: actions/cache@627f0f41f6904a5b1efbaed9f96d9eb58e92e920 # v3.2.4
+
+ - uses: actions/cache@704facf57e6136b1bc63b828d79edcd491f0ee84 # v3.3.2
with:
path: C:\vcpkg\installed
- key: ${{ runner.os }}-vcpkg-installed-${{ matrix.os }}-${{ github.sha }}
+ key: ${{ runner.os }}-vcpkg-installed-${{ env.OS_VER }}-${{ github.sha }}
restore-keys: |
- ${{ runner.os }}-vcpkg-installed-${{ matrix.os }}-
+ ${{ runner.os }}-vcpkg-installed-${{ env.OS_VER }}-
${{ runner.os }}-vcpkg-installed-
+
- name: Install libraries with vcpkg
run: |
vcpkg --triplet x64-windows install libffi libyaml openssl readline zlib
- - uses: actions/cache@627f0f41f6904a5b1efbaed9f96d9eb58e92e920 # v3.2.4
- with:
- path: C:\Users\runneradmin\AppData\Local\Temp\chocolatey
- key: ${{ runner.os }}-chocolatey-${{ env.OS_VER }}-${{ github.sha }}
- restore-keys: |
- ${{ runner.os }}-chocolatey-${{ env.OS_VER }}-
- ${{ runner.os }}-chocolatey-
- - name: Install libraries with chocolatey
+
+ - name: Install libraries with scoop
run: |
- # Using Choco-Install for retries, but it doesn't detect failures properly
- # if you pass multiple package names in a single command.
- Choco-Install -PackageName winflexbison3
+ iex "& {$(irm get.scoop.sh)} -RunAsAdmin"
+ Join-Path (Resolve-Path ~).Path "scoop\shims" >> $Env:GITHUB_PATH
shell: pwsh
- - name: git config
- run: |
- git config --global core.autocrlf false
- git config --global core.eol lf
- git config --global advice.detachedHead 0
- git config --global init.defaultBranch garbage
- - uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
+
+ - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
with:
- path: src
- - uses: actions/cache@627f0f41f6904a5b1efbaed9f96d9eb58e92e920 # v3.2.4
+ sparse-checkout-cone-mode: false
+ sparse-checkout: /.github
+
+ - uses: ./.github/actions/setup/directories
with:
- path: src/.downloaded-cache
- key: downloaded-cache
+ srcdir: src
+ builddir: build
+
- name: setup env
# %TEMP% is inconsistent with %TMP% and test-all expects they are consistent.
# https://github.com/actions/virtual-environments/issues/712#issuecomment-613004302
run: |
set VS=${{ matrix.vs }}
- set VCVARS=${{ matrix.vcvars }}
+ set VCVARS=${{ matrix.vcvars || '' }}
if not "%VCVARS%" == "" goto :vcset
set VCVARS="C:\Program Files (x86)\Microsoft Visual Studio\%VS%\Enterprise\VC\Auxiliary\Build\vcvars64.bat"
if not exist %VCVARS% set VCVARS="C:\Program Files\Microsoft Visual Studio\%VS%\Enterprise\VC\Auxiliary\Build\vcvars64.bat"
:vcset
set | C:\msys64\usr\bin\sort > old.env
call %VCVARS%
+ nmake -f nul
set TMP=%USERPROFILE%\AppData\Local\Temp
set TEMP=%USERPROFILE%\AppData\Local\Temp
+ set MAKEFLAGS=l
set /a TEST_JOBS=(15 * %NUMBER_OF_PROCESSORS% / 10) > nul
set | C:\msys64\usr\bin\sort > new.env
C:\msys64\usr\bin\comm -13 old.env new.env >> %GITHUB_ENV%
del *.env
+
- name: compiler version
run: cl
+
- name: link libraries
run: |
for %%I in (C:\vcpkg\installed\x64-windows\bin\*.dll) do (
if not %%~nI == readline mklink %%~nxI %%I
)
+ # We use OpenSSL instealled by vcpkg instead
+ - name: disable system OpenSSL
+ run: |
for %%I in (libcrypto-1_1-x64 libssl-1_1-x64) do (
ren c:\Windows\System32\%%I.dll %%I.dll_
)
+ # windows-2019 image doesn't have OpenSSL as of 2023/9/14
+ if: ${{ matrix.vs != 2019 }}
+
- name: Configure
run: >-
../src/win32/configure.bat --disable-install-doc
--with-opt-dir=C:/vcpkg/installed/x64-windows
+
- run: nmake incs
+
- run: nmake extract-extlibs
+
- run: nmake
- env:
- YACC: win_bison
+
- run: nmake test
timeout-minutes: 5
+
- run: nmake test-spec
timeout-minutes: 10
+
- run: nmake test-all
env:
- RUBY_TESTOPTS: -j${{env.TEST_JOBS}} --job-status=normal
+ RUBY_TESTOPTS: -j${{ env.TEST_JOBS || 4 }} --job-status=normal
timeout-minutes: 60
- - uses: ruby/action-slack@b6882ea6ef8f556f9f9af9ec1220d3f1ced74acf # v3.0.0
+
+ - uses: ./.github/actions/slack
with:
- payload: |
- {
- "ci": "GitHub Actions",
- "env": "VS${{ matrix.vs }} / ${{ matrix.test_task || 'check' }}",
- "url": "https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}",
- "commit": "${{ github.sha }}",
- "branch": "${{ github.ref_name }}"
- }
- env:
+ label: VS${{ matrix.vs }} / ${{ matrix.test_task || 'check' }}
SLACK_WEBHOOK_URL: ${{ secrets.SIMPLER_ALERTS_URL }} # ruby-lang slack: ruby/simpler-alerts-bot
- if: ${{ failure() && github.event_name == 'push' }}
+ if: ${{ failure() }}
defaults:
run:
diff --git a/.github/workflows/yjit-macos.yml b/.github/workflows/yjit-macos.yml
new file mode 100644
index 0000000000..11e200a619
--- /dev/null
+++ b/.github/workflows/yjit-macos.yml
@@ -0,0 +1,151 @@
+name: YJIT macOS Arm64
+on:
+ push:
+ paths-ignore:
+ - 'doc/**'
+ - '**/man'
+ - '**.md'
+ - '**.rdoc'
+ - '**/.document'
+ - '.*.yml'
+ pull_request:
+ # Do not use paths-ignore for required status checks
+ # https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/collaborating-on-repositories-with-code-quality-features/troubleshooting-required-status-checks#handling-skipped-but-required-checks
+ merge_group:
+ paths-ignore:
+ - 'doc/**'
+ - '**/man'
+ - '**.md'
+ - '**.rdoc'
+ - '**/.document'
+ - '.*.yml'
+
+concurrency:
+ group: ${{ github.workflow }} / ${{ startsWith(github.event_name, 'pull') && github.ref_name || github.sha }}
+ cancel-in-progress: ${{ startsWith(github.event_name, 'pull') }}
+
+permissions:
+ contents: read
+
+jobs:
+ cargo:
+ name: cargo test
+
+ runs-on: macos-arm-oss
+
+ if: >-
+ ${{github.repository == 'ruby/ruby' &&
+ !(false
+ || contains(github.event.head_commit.message, '[DOC]')
+ || contains(github.event.pull_request.title, '[DOC]')
+ || contains(github.event.pull_request.labels.*.name, 'Documentation')
+ || (github.event_name == 'push' && github.actor == 'dependabot[bot]')
+ )}}
+
+ steps:
+ - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
+
+ - run: RUST_BACKTRACE=1 cargo test
+ working-directory: yjit
+
+ # Also compile and test with all features enabled
+ - run: RUST_BACKTRACE=1 cargo test --all-features
+ working-directory: yjit
+
+ # Check that we can build in release mode too
+ - run: cargo build --release
+ working-directory: yjit
+
+ make:
+ strategy:
+ matrix:
+ include:
+ - test_task: 'check'
+ configure: '--enable-yjit'
+ yjit_opts: '--yjit'
+ - test_task: 'check'
+ configure: '--enable-yjit=dev'
+ yjit_opts: '--yjit-call-threshold=1 --yjit-verify-ctx --yjit-code-gc'
+ fail-fast: false
+
+ env:
+ GITPULLOPTIONS: --no-tags origin ${{ github.ref }}
+ RUN_OPTS: ${{ matrix.yjit_opts }}
+
+ runs-on: macos-arm-oss
+
+ if: >-
+ ${{github.repository == 'ruby/ruby' &&
+ !(false
+ || contains(github.event.head_commit.message, '[DOC]')
+ || contains(github.event.pull_request.title, '[DOC]')
+ || contains(github.event.pull_request.labels.*.name, 'Documentation')
+ || (github.event_name == 'push' && github.actor == 'dependabot[bot]')
+ )}}
+
+ steps:
+ - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
+ with:
+ sparse-checkout-cone-mode: false
+ sparse-checkout: /.github
+
+ - name: Install libraries
+ uses: ./.github/actions/setup/macos
+
+ - uses: ./.github/actions/setup/directories
+ with:
+ srcdir: src
+ builddir: build
+ makeup: true
+ dummy-files: ${{ matrix.test_task == 'check' }}
+
+ - name: Run configure
+ run: ../src/configure -C --disable-install-doc ${{ matrix.configure }}
+
+ - run: make prepare-gems
+ if: ${{ matrix.test_task == 'test-bundled-gems' }}
+
+ - run: make
+
+ - name: Enable YJIT through ENV
+ run: echo "RUBY_YJIT_ENABLE=1" >> $GITHUB_ENV
+
+ - name: make ${{ matrix.test_task }}
+ run: |
+ make -s ${{ matrix.test_task }} ${TESTS:+TESTS=`echo "$TESTS" | sed 's| |$$/ -n!/|g;s|^|-n!/|;s|$|$$/|'`}
+ timeout-minutes: 60
+ env:
+ RUBY_TESTOPTS: '-q --tty=no'
+ TESTS: ${{ matrix.test_task == 'check' && matrix.skipped_tests || '' }}
+ TEST_BUNDLED_GEMS_ALLOW_FAILURES: ''
+ PRECHECK_BUNDLED_GEMS: 'no'
+
+ - name: make skipped tests
+ run: |
+ make -s test-all TESTS=`echo "$TESTS" | sed 's| |$$/ -n/|g;s|^|-n/|;s|$|$$/|'`
+ env:
+ GNUMAKEFLAGS: ''
+ RUBY_TESTOPTS: '-v --tty=no'
+ TESTS: ${{ matrix.skipped_tests }}
+ PRECHECK_BUNDLED_GEMS: 'no'
+ if: ${{ matrix.test_task == 'check' && matrix.skipped_tests != '' }}
+ continue-on-error: ${{ matrix.continue-on-skipped_tests || false }}
+
+ - uses: ./.github/actions/slack
+ with:
+ label: ${{ matrix.test_task }} ${{ matrix.configure }} ${{ matrix.yjit_opts }}
+ SLACK_WEBHOOK_URL: ${{ secrets.SIMPLER_ALERTS_URL }} # ruby-lang slack: ruby/simpler-alerts-bot
+ if: ${{ failure() }}
+
+ result:
+ if: ${{ always() && github.repository == 'ruby/ruby' }}
+ name: ${{ github.workflow }} result
+ runs-on: macos-arm-oss
+ needs: [make]
+ steps:
+ - run: exit 1
+ if: ${{ contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled') }}
+
+defaults:
+ run:
+ working-directory: build
diff --git a/.github/workflows/yjit-ubuntu.yml b/.github/workflows/yjit-ubuntu.yml
index a1e0b67a47..ec8483b7d1 100644
--- a/.github/workflows/yjit-ubuntu.yml
+++ b/.github/workflows/yjit-ubuntu.yml
@@ -7,13 +7,18 @@ on:
- '**.md'
- '**.rdoc'
- '**/.document'
+ - '.*.yml'
pull_request:
+ # Do not use paths-ignore for required status checks
+ # https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/collaborating-on-repositories-with-code-quality-features/troubleshooting-required-status-checks#handling-skipped-but-required-checks
+ merge_group:
paths-ignore:
- 'doc/**'
- '**/man'
- '**.md'
- '**.rdoc'
- '**/.document'
+ - '.*.yml'
concurrency:
group: ${{ github.workflow }} / ${{ startsWith(github.event_name, 'pull') && github.ref_name || github.sha }}
@@ -24,147 +29,173 @@ permissions:
jobs:
cargo:
- name: Rust cargo test
+ name: cargo test
+
# GitHub Action's image seems to already contain a Rust 1.58.0.
runs-on: ubuntu-20.04
+
+ if: >-
+ ${{!(false
+ || contains(github.event.head_commit.message, '[DOC]')
+ || contains(github.event.pull_request.title, '[DOC]')
+ || contains(github.event.pull_request.labels.*.name, 'Documentation')
+ || (github.event_name == 'push' && github.actor == 'dependabot[bot]')
+ )}}
+
steps:
- - uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
+ - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
+
# For now we can't run cargo test --offline because it complains about the
# capstone dependency, even though the dependency is optional
#- run: cargo test --offline
+
- run: RUST_BACKTRACE=1 cargo test
working-directory: yjit
+
# Also compile and test with all features enabled
- run: RUST_BACKTRACE=1 cargo test --all-features
working-directory: yjit
+
# Check that we can build in release mode too
- run: cargo build --release
working-directory: yjit
+
lint:
- name: Rust lint
+ name: cargo clippy
+
# GitHub Action's image seems to already contain a Rust 1.58.0.
runs-on: ubuntu-20.04
+
+ if: >-
+ ${{!(false
+ || contains(github.event.head_commit.message, '[DOC]')
+ || contains(github.event.pull_request.title, '[DOC]')
+ || contains(github.event.pull_request.labels.*.name, 'Documentation')
+ || (github.event_name == 'push' && github.actor == 'dependabot[bot]')
+ )}}
+
steps:
- - uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
+ - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
+
# Check that we don't have linting errors in release mode, too
- run: cargo clippy --all-targets --all-features
working-directory: yjit
+
make:
strategy:
fail-fast: false
matrix:
include:
- - test_task: "yjit-bindgen"
- hint: "To fix: use patch in logs"
- configure: "--with-gcc=clang-12 --enable-yjit=dev"
+ - test_task: 'yjit-bindgen'
+ hint: 'To fix: use patch in logs'
+ configure: '--with-gcc=clang-12 --enable-yjit=dev'
- - test_task: "check"
+ - test_task: 'check'
# YJIT should be automatically built in release mode on x86-64 Linux with rustc present
#configure: "--enable-yjit RUSTC='rustc +1.58.0'"
configure: "RUSTC='rustc +1.58.0'"
- rust_version: "1.58.0"
+ rust_version: '1.58.0'
- - test_task: "check"
- configure: "--enable-yjit=dev"
+ - test_task: 'check'
+ configure: '--enable-yjit=dev'
- - test_task: "check"
- configure: "--enable-yjit=dev"
- yjit_opts: "--yjit-call-threshold=1 --yjit-verify-ctx"
+ - test_task: 'check'
+ configure: '--enable-yjit=dev'
+ yjit_opts: '--yjit-call-threshold=1 --yjit-verify-ctx --yjit-code-gc'
- - test_task: "test-all TESTS=--repeat-count=2"
- configure: "--enable-yjit=dev"
+ - test_task: 'test-bundled-gems'
+ configure: '--enable-yjit=dev'
- - test_task: "test-bundled-gems"
- configure: "--enable-yjit=dev"
+ - test_task: 'yjit-bench'
+ configure: '--enable-yjit=dev'
+ yjit_bench_opts: '--yjit-stats'
- - test_task: "yjit-bench"
- configure: "--enable-yjit=dev"
- yjit_bench_opts: "--yjit-stats"
env:
- GITPULLOPTIONS: --no-tags origin ${{github.ref}}
+ GITPULLOPTIONS: --no-tags origin ${{ github.ref }}
RUN_OPTS: ${{ matrix.yjit_opts }}
YJIT_BENCH_OPTS: ${{ matrix.yjit_bench_opts }}
RUBY_DEBUG: ci
BUNDLE_JOBS: 8 # for yjit-bench
RUST_BACKTRACE: 1
+
runs-on: ubuntu-20.04
- if: ${{ !contains(github.event.head_commit.message, '[DOC]') && !contains(github.event.pull_request.labels.*.name, 'Documentation') }}
+
+ if: >-
+ ${{!(false
+ || contains(github.event.head_commit.message, '[DOC]')
+ || contains(github.event.pull_request.title, '[DOC]')
+ || contains(github.event.pull_request.labels.*.name, 'Documentation')
+ || (github.event_name == 'push' && github.actor == 'dependabot[bot]')
+ )}}
+
steps:
- - run: mkdir build
- working-directory:
- - name: Install libraries
- run: |
- set -x
- sudo apt-get update -q || :
- sudo apt-get install --no-install-recommends -q -y build-essential libssl-dev libyaml-dev libreadline6-dev zlib1g-dev libncurses5-dev libffi-dev bison autoconf ruby
+ - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
+ with:
+ sparse-checkout-cone-mode: false
+ sparse-checkout: /.github
+
+ - uses: ./.github/actions/setup/ubuntu
+
+ - uses: ./.github/actions/setup/directories
+ with:
+ srcdir: src
+ builddir: build
+ makeup: true
+ dummy-files: ${{ matrix.test_task == 'check' }}
+
- name: Install Rust
if: ${{ matrix.rust_version }}
run: rustup install ${{ matrix.rust_version }} --profile minimal
- - name: git config
- run: |
- git config --global advice.detachedHead 0
- git config --global init.defaultBranch garbage
- - uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
- with:
- path: src
- - uses: actions/cache@627f0f41f6904a5b1efbaed9f96d9eb58e92e920 # v3.2.4
- with:
- path: src/.downloaded-cache
- key: downloaded-cache
- - name: Fixed world writable dirs
- run: |
- chmod -v go-w $HOME $HOME/.config
- sudo chmod -R go-w /usr/share
- sudo bash -c 'IFS=:; for d in '"$PATH"'; do chmod -v go-w $d; done' || :
- - name: Set ENV
- run: |
- echo "GNUMAKEFLAGS=-j$((1 + $(nproc --all)))" >> $GITHUB_ENV
- - run: ./autogen.sh
- working-directory: src
+
- name: Run configure
run: ../src/configure -C --disable-install-doc --prefix=$(pwd)/install ${{ matrix.configure }}
+
- run: make incs
+
- run: make prepare-gems
if: ${{ matrix.test_task == 'test-bundled-gems' }}
- - run: make -j
- - run: make leaked-globals
- if: ${{ matrix.test_task == 'check' }}
- - name: Create dummy files in build dir
- run: |
- ./miniruby -e '(("a".."z").to_a+("A".."Z").to_a+("0".."9").to_a+%w[foo bar test zzz]).each{|basename|File.write("#{basename}.rb", "raise %(do not load #{basename}.rb)")}'
- if: ${{ matrix.test_task == 'check' }}
+
+ - run: make
+
- name: Enable YJIT through ENV
run: echo "RUBY_YJIT_ENABLE=1" >> $GITHUB_ENV
+
# Check that the binary was built with YJIT
- name: Check YJIT enabled
run: ./miniruby --yjit -v | grep "+YJIT"
+
- name: make ${{ matrix.test_task }}
- run: make -s -j ${{ matrix.test_task }} RUN_OPTS="$RUN_OPTS" YJIT_BENCH_OPTS="$YJIT_BENCH_OPTS"
+ run: make -s -j ${{ matrix.test_task }} RUN_OPTS="$RUN_OPTS" MSPECOPT=--debug YJIT_BENCH_OPTS="$YJIT_BENCH_OPTS" YJIT_BINDGEN_DIFF_OPTS="$YJIT_BINDGEN_DIFF_OPTS"
timeout-minutes: 60
env:
- RUBY_TESTOPTS: "-q --tty=no"
- TEST_BUNDLED_GEMS_ALLOW_FAILURES: ""
- PRECHECK_BUNDLED_GEMS: "no"
+ RUBY_TESTOPTS: '-q --tty=no'
+ TEST_BUNDLED_GEMS_ALLOW_FAILURES: 'rbs'
+ PRECHECK_BUNDLED_GEMS: 'no'
+ SYNTAX_SUGGEST_TIMEOUT: '5'
+ YJIT_BINDGEN_DIFF_OPTS: '--exit-code'
continue-on-error: ${{ matrix.test_task == 'yjit-bench' }}
+
- name: Show ${{ github.event.pull_request.base.ref }} GitHub URL for yjit-bench comparison
run: echo "https://github.com/${BASE_REPO}/commit/${BASE_SHA}"
env:
BASE_REPO: ${{ github.event.pull_request.base.repo.full_name }}
BASE_SHA: ${{ github.event.pull_request.base.sha }}
if: ${{ matrix.test_task == 'yjit-bench' && startsWith(github.event_name, 'pull') }}
- - uses: ruby/action-slack@b6882ea6ef8f556f9f9af9ec1220d3f1ced74acf # v3.0.0
+
+ - uses: ./.github/actions/slack
with:
- payload: |
- {
- "ci": "GitHub Actions",
- "env": "${{ github.workflow }} / ${{ matrix.test_task }} ${{ matrix.configure }}",
- "url": "https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}",
- "commit": "${{ github.sha }}",
- "branch": "${{ github.ref_name }}"
- }
- env:
+ label: ${{ matrix.test_task }} ${{ matrix.configure }}
SLACK_WEBHOOK_URL: ${{ secrets.SIMPLER_ALERTS_URL }} # ruby-lang slack: ruby/simpler-alerts-bot
- if: ${{ failure() && github.event_name == 'push' }}
+ if: ${{ failure() }}
+
+ result:
+ if: ${{ always() }}
+ name: ${{ github.workflow }} result
+ runs-on: ubuntu-latest
+ needs: [make]
+ steps:
+ - run: exit 1
+ if: ${{ contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled') }}
defaults:
run:
diff --git a/.gitignore b/.gitignore
index 58a01b86d8..f402bf2155 100644
--- a/.gitignore
+++ b/.gitignore
@@ -50,6 +50,7 @@ y.tab.c
*.gcno
*.gcov
*.vscode
+!misc/.vscode
lcov*.info
# /
@@ -204,8 +205,10 @@ lcov*.info
# /ext/ripper/
/ext/ripper/eventids1.c
+/ext/ripper/eventids1.h
/ext/ripper/.eventids2-check
/ext/ripper/eventids2table.c
+/ext/ripper/ripper_init.c
/ext/ripper/ripper.*
/ext/ripper/ids1
/ext/ripper/ids2
@@ -227,8 +230,9 @@ lcov*.info
# /misc/
/misc/**/__pycache__
-# /spec/bundler
+# for `make test-bundler`
/.rspec_status
+/tool/bundler/*.lock
# /tool/
/tool/config.guess
@@ -237,11 +241,12 @@ lcov*.info
# /win32/
/win32/*.ico
-# MJIT
-/include/ruby-*/*/rb_mjit_min_header-*.h
-/lib/ruby_vm/mjit/instruction.rb
-/mjit_config.h
-/rb_mjit_header.h*
+# RJIT
+/include/ruby-*/*/rb_rjit_min_header-*.h
+/lib/ruby_vm/rjit/instruction.rb
+/lib/ruby_vm/rjit/instruction.rb
+/rjit_config.h
+/rb_rjit_header.h*
# YJIT
/yjit-bench
@@ -249,3 +254,24 @@ lcov*.info
# /wasm/
/wasm/tests/*.wasm
+
+# prism
+/lib/prism/compiler.rb
+/lib/prism/dispatcher.rb
+/lib/prism/dot_visitor.rb
+/lib/prism/dsl.rb
+/lib/prism/mutation_compiler.rb
+/lib/prism/node.rb
+/lib/prism/serialize.rb
+/lib/prism/visitor.rb
+/prism/api_node.c
+/prism/ast.h
+/prism/node.c
+/prism/prettyprint.c
+/prism/serialize.c
+/prism/token_type.c
+
+# tool/update-NEWS-gemlist.rb
+/bundled_gems.json
+/default_gems.json
+/gems/default_gems
diff --git a/.travis.yml b/.travis.yml
index 665feba914..741c0a32ef 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -6,63 +6,46 @@
# conditions mentioned in the file COPYING are met. Consult the file for
# details.
-# We only manage non-amd64 free pipelines.
-# https://docs.travis-ci.com/user/billing-overview/
+# When you see Travis CI issues, or you are interested in understanding how to
+# manage, please check the link below.
+# https://github.com/ruby/ruby/wiki/CI-Servers#travis-ci
+
+# We enable Travis on the specific branches or forked repositories here.
+if: >-
+ (repo != ruby/ruby OR branch = master OR branch =~ /^ruby_\d_\d$/)
+ AND (commit_message !~ /\[DOC\]/)
language: c
os: linux
-if: commit_message !~ /\[DOC\]/
-
-dist: focal
+dist: jammy
git:
quiet: true
-cache:
- ccache: true
- directories:
- - $HOME/config_2nd
- - $HOME/.downloaded-cache
-
env:
global:
- # The tests skipped in `make test-all`.
- - TEST_ALL_SKIPPED_TESTS=
- # The tests executed separately by `make test-all`.
- - TEST_ALL_SEPARATED_TESTS=
- # Reset timestamps early
- - _=$(touch NEWS && find . -type f -exec touch -r NEWS {} +)
- - CONFIGURE_TTY=no
- - CCACHE_COMPILERCHECK=none
- - CCACHE_NOCOMPRESS=1
- - CCACHE_MAXSIZE=512Mi
- - NPROC="`nproc`"
- # JOBS and SETARCH are overridden when necessary; see below.
- - JOBS=-j$((1+${NPROC}))
+ - NPROC="$(nproc)"
+ - JOBS="-j${NPROC}"
+ # SETARCH are overridden when necessary. See below.
- SETARCH=
- - RUBY_PREFIX=/tmp/ruby-prefix
- - GEMS_FOR_TEST='timezone tzinfo'
# https://github.com/travis-ci/travis-build/blob/e411371dda21430a60f61b8f3f57943d2fe4d344/lib/travis/build/bash/travis_apt_get_options.bash#L7
- travis_apt_get_options='--allow-downgrades --allow-remove-essential --allow-change-held-packages'
- travis_apt_get_options="-yq --no-install-suggests --no-install-recommends $travis_apt_get_options"
- # -O1 is faster than -O3 in our tests.
- - optflags=-O1
- # -g0 disables backtraces when SEGV. Do not set that.
+ # -g0 disables backtraces when SEGV. Do not set that.
- debugflags=-ggdb3
+ - RUBY_TESTOPTS="$JOBS -q --tty=no"
.org.ruby-lang.ci.matrix-definitions:
-
- - &gcc-10
- compiler: gcc-10
+ - &gcc-11
+ compiler: gcc-11
before_install:
- tool/travis_retry.sh sudo bash -c "rm -rf '${TRAVIS_ROOT}/var/lib/apt/lists/'* && exec apt-get update -yq"
- >-
tool/travis_retry.sh sudo -E apt-get $travis_apt_get_options install
- ccache
- gcc-10
- g++-10
+ gcc-11
+ g++-11
libffi-dev
libncurses-dev
libncursesw5-dev
@@ -71,40 +54,42 @@ env:
libyaml-dev
openssl
zlib1g-dev
-
- # --------
-
+ - gcc-11 --version
- &arm64-linux
name: arm64-linux
arch: arm64
- <<: *gcc-10
-
+ <<: *gcc-11
- &ppc64le-linux
name: ppc64le-linux
arch: ppc64le
- <<: *gcc-10
-
+ <<: *gcc-11
- &s390x-linux
name: s390x-linux
arch: s390x
- <<: *gcc-10
-
+ <<: *gcc-11
+ env:
+ # Avoid possible test failures with the zlib applying the following patch
+ # on s390x CPU architecture.
+ # https://github.com/madler/zlib/pull/410
+ - DFLTCC=0
- &arm32-linux
name: arm32-linux
arch: arm64
- # https://packages.ubuntu.com/focal/crossbuild-essential-armhf
+ # https://packages.ubuntu.com/jammy/crossbuild-essential-armhf
compiler: arm-linux-gnueabihf-gcc
env:
- SETARCH='setarch linux32 --verbose --32bit'
- # The "TestReadline#test_interrupt_in_other_thread" started failing on arm32
- # from https://www.travis-ci.com/github/ruby/ruby/jobs/529005145
- - TEST_ALL_SKIPPED_TESTS=test_interrupt_in_other_thread
+ # Still keep the -O1 for only arm32, while we want to test with the
+ # default optflags -O3.
+ # Because bootstraptest/test_ractor.rb fails with segfualt with the
+ # default -O3.
+ # https://bugs.ruby-lang.org/issues/19981
+ - optflags=-O1
before_install:
- sudo dpkg --add-architecture armhf
- tool/travis_retry.sh sudo bash -c "rm -rf '${TRAVIS_ROOT}/var/lib/apt/lists/'* && exec apt-get update -yq"
- >-
tool/travis_retry.sh sudo -E apt-get $travis_apt_get_options install
- ccache
crossbuild-essential-armhf
libc6:armhf
libstdc++-10-dev:armhf
@@ -119,117 +104,49 @@ env:
matrix:
include:
- # Build every commit (Allowed Failures):
- - <<: *arm32-linux
- # Comment out as the 2nd arm64 pipeline is unstable.
- # - <<: *arm64-linux
+ - <<: *arm64-linux
- <<: *ppc64le-linux
- <<: *s390x-linux
+ # FIXME: lib/rubygems/util.rb:104 glob_files_in_dir -
+ # <internal:dir>:411:in glob: File name too long - (Errno::ENAMETOOLONG)
+ # https://github.com/rubygems/rubygems/issues/7132
+ - <<: *arm32-linux
allow_failures:
- # We see multiple errors indicating errors on the Travis environment itself in a short while:
- # https://app.travis-ci.com/github/ruby/ruby/jobs/544382885
- # https://app.travis-ci.com/github/ruby/ruby/jobs/544361370
- # It's not a fault of Ruby's arm32 support but just Travis arm32 seems unsable.
- - name: arm32-linux
+ # Allow failures for the unstable jobs.
# - name: arm64-linux
- # We see "Some worker was crashed." in about 40% of recent ppc64le-linux jobs
- # e.g. https://app.travis-ci.com/github/ruby/ruby/jobs/530959548
- - name: ppc64le-linux
- # Tentatively disable, because often hungs up **after** all tests
- # have finished successfully and saving caches.
- - name: s390x-linux
+ # - name: ppc64le-linux
+ # - name: s390x-linux
+ # The 2nd arm64 pipeline may be unstable.
+ # - name: arm32-linux
fast_finish: true
before_script:
- - . tool/ci_functions.sh
- - |-
- if [ -n "${TEST_ALL_SKIPPED_TESTS}" ]; then
- TEST_ALL_OPTS="${TEST_ALL_OPTS} $(ci_to_excluded_test_opts "${TEST_ALL_SKIPPED_TESTS}")"
- if [ -z "${TEST_ALL_SEPARATED_TESTS}" ]; then
- TEST_ALL_SEPARATED_TESTS="${TEST_ALL_SKIPPED_TESTS}"
- fi
- fi
- - |-
- if [ -n "${TEST_ALL_SEPARATED_TESTS}" ]; then
- TEST_ALL_OPTS_SEPARATED="$(ci_to_included_test_opts "${TEST_ALL_SEPARATED_TESTS}")"
- fi
- - echo TEST_ALL_OPTS="${TEST_ALL_OPTS}" TEST_ALL_OPTS_SEPARATED="${TEST_ALL_OPTS_SEPARATED}"
- - rm -fr .ext autom4te.cache
- - |-
- [ -d ~/.downloaded-cache ] ||
- mkdir ~/.downloaded-cache
- - ln -s ~/.downloaded-cache
- - "> config.status"
- - "> .rbconfig.time"
- - sed -f tool/prereq.status template/Makefile.in common.mk > Makefile
- - make -s $JOBS up
- - make -s $JOBS srcs
- - rm -f config.status Makefile rbconfig.rb .rbconfig.time
- - |-
- if [ -d ~/config_2nd ]; then
- cp -pr ~/config_2nd build
- else
- mkdir build
- fi
- - mkdir config_1st config_2nd gems/src
- - chmod -R a-w .
- - chmod -R u+w build config_1st config_2nd gems/src
+ - ./autogen.sh
+ - mkdir build
- cd build
- - |-
- case "$CC" in
- gcc*) CC="ccache $CC${GCC_FLAGS:+ }$GCC_FLAGS -fno-diagnostics-color";;
- clang*) CC="ccache $CC${GCC_FLAGS:+ }$GCC_FLAGS -fno-color-diagnostics";;
- esac
- - |-
- [ ! -f config.cache ] ||
- [ "$CC" = "`sed -n s/^ac_cv_prog_CC=//p config.cache`" ] ||
- (set -x; exec rm config.cache)
- - $SETARCH ../configure -C --disable-install-doc --prefix=$RUBY_PREFIX $CONFIG_FLAG
- - cp -pr config.cache config.status .ext/include ../config_1st
- - $SETARCH make reconfig
- - cp -pr config.cache config.status .ext/include ../config_2nd
- - (cd .. && exec diff -ru config_1st config_2nd)
- - chmod u+w ..
- - rm -rf ~/config_2nd
- - mv ../config_2nd ~
- - chmod u-w ..
+ - $SETARCH ../configure -C --disable-install-doc --prefix=$(pwd)/install
- $SETARCH make -s $JOBS
- - make -s install
- - |-
- [ -z "${GEMS_FOR_TEST}" ] ||
- $RUBY_PREFIX/bin/gem install --no-document $GEMS_FOR_TEST
- - echo "raise 'do not load ~/.irbrc in test'" > ~/.irbrc
+ - make -s $JOBS install
+ # Useful info to report issues to the Ruby.
+ - $SETARCH $(pwd)/install/bin/ruby -v
+ # Useful info To report issues to the RubyGems.
+ - $SETARCH $(pwd)/install/bin/gem env
script:
- - $SETARCH make -s test -o showflags TESTOPTS="${TESTOPTS=$JOBS -q --tty=no}"
- - ../tool/travis_wait.sh $SETARCH make -s test-all -o exts TESTOPTS="$JOBS -q --tty=no ${TEST_ALL_OPTS}" RUBYOPT="-w"
- # Run the failing tests separately returning ok status to check if it works,
- # visualize them.
- - |
- if [ -n "${TEST_ALL_OPTS_SEPARATED}" ]; then
- $SETARCH make -s test-all -o exts TESTOPTS="$JOBS -v --tty=no ${TEST_ALL_OPTS_SEPARATED}" RUBYOPT="-w" || :
- fi
- - $SETARCH make -s test-spec MSPECOPT=-ff # not using `-j` because sometimes `mspec -j` silently dies
- - $SETARCH make -s -o showflags leaked-globals
-
-# We enable Travis on the specific branches or forked repositories here.
-if: (repo = ruby/ruby AND (branch = master OR branch =~ /^ruby_\d_\d$/)) OR repo != ruby/ruby
+ - $SETARCH make -s test
+ - ../tool/travis_wait.sh $SETARCH make -s test-all RUBYOPT="-w"
+ - $SETARCH make -s test-spec
# We want to be notified when something happens.
notifications:
- irc:
- channels:
- - "chat.freenode.net#ruby-core"
- on_success: change # [always|never|change] # default: always
- on_failure: always # [always|never|change] # default: always
- template:
- - "%{message} by @%{author}: See %{build_url}"
-
webhooks:
urls:
- - secure: mRsoS/UbqDkKkW5p3AEqM27d4SZnV6Gsylo3bm8T/deltQzTsGzZwrm7OIBXZv0UFZdE68XmPlyHfZFLSP2V9QZ7apXMf9/vw0GtcSe1gchtnjpAPF6lYBn7nMCbVPPx9cS0dwL927fjdRM1vj7IKZ2bk4F0lAJ25R25S6teqdk= # ruby-lang slack: ruby/simpler-alerts-bot (travis)
+ # ruby-lang slack: ruby/simpler-alerts-bot (travis)
+ - secure: mRsoS/UbqDkKkW5p3AEqM27d4SZnV6Gsylo3bm8T/deltQzTsGzZwrm7OIBXZv0UFZdE68XmPlyHfZFLSP2V9QZ7apXMf9/vw0GtcSe1gchtnjpAPF6lYBn7nMCbVPPx9cS0dwL927fjdRM1vj7IKZ2bk4F0lAJ25R25S6teqdk=
on_success: never
on_failure: always
-
email:
- - jaruga@ruby-lang.org
+ recipients:
+ - jaruga@ruby-lang.org
+ on_success: never
+ on_failure: always
diff --git a/NEWS.md b/NEWS.md
index 9b16fc8416..364786d754 100644
--- a/NEWS.md
+++ b/NEWS.md
@@ -5,7 +5,15 @@ since the **3.2.0** release, except for bug fixes.
Note that each entry is kept to a minimum, see links for details.
-## Language changes
+## Command line options
+
+* A new `performance` warning category was introduced.
+ They are not displayed by default even in verbose mode.
+ Turn them on with `-W:performance` or `Warning[:performance] = true`. [[Feature #19538]]
+
+* A new `RUBY_CRASH_REPORT` environment variable was introduced to allow
+ redirecting Ruby crash reports to a file or sub command. See the `BUG REPORT ENVIRONMENT`
+ section of the ruby manpage for further details. [[Feature #19790]]
## Core classes updates
@@ -13,46 +21,509 @@ Note: We're only listing outstanding class updates.
* Array
- * `Array#pack` now raises ArgumentError for unknown directives. [[Bug #19150]]
+ * Array#pack now raises ArgumentError for unknown directives. [[Bug #19150]]
+
+* Dir
+
+ * Dir.for_fd added for returning a Dir object for the directory specified
+ by the provided directory file descriptor. [[Feature #19347]]
+ * Dir.fchdir added for changing the directory to the directory specified
+ by the provided directory file descriptor. [[Feature #19347]]
+ * Dir#chdir added for changing the directory to the directory specified by
+ the provided `Dir` object. [[Feature #19347]]
+
+* Encoding
+
+ * `Encoding#replicate` has been removed, it was already deprecated. [[Feature #18949]]
+
+* Fiber
+
+ * Introduce Fiber#kill. [[Bug #595]]
+
+ ```ruby
+ fiber = Fiber.new do
+ while true
+ puts "Yielding..."
+ Fiber.yield
+ end
+ ensure
+ puts "Exiting..."
+ end
+
+ fiber.resume
+ # Yielding...
+ fiber.kill
+ # Exiting...
+ ```
+
+* MatchData
+
+ * MatchData#named_captures now accepts optional `symbolize_names`
+ keyword. [[Feature #19591]]
+
+* Module
+
+ * Module#set_temporary_name added for setting a temporary name for a
+ module. [[Feature #19521]]
+
+* ObjectSpace::WeakKeyMap
+
+ * New core class to build collections with weak references.
+ The class use equality semantic to lookup keys like a regular hash,
+ but it doesn't hold strong references on the keys. [[Feature #18498]]
+
+* ObjectSpace::WeakMap
+
+ * ObjectSpace::WeakMap#delete was added to eagerly clear weak map
+ entries. [[Feature #19561]]
+
+* Proc
+ * Now Proc#dup and Proc#clone call `#initialize_dup` and `#initialize_clone`
+ hooks respectively. [[Feature #19362]]
+
+* Process
+
+ * New Process.warmup method that notify the Ruby virtual machine that the boot sequence is finished,
+ and that now is a good time to optimize the application. This is useful
+ for long-running applications. The actual optimizations performed are entirely
+ implementation-specific and may change in the future without notice. [[Feature #18885]]
+
+* Process::Status
+
+ * Process::Status#& and Process::Status#>> are deprecated. [[Bug #19868]]
+
+* Range
+
+ * Range#reverse_each can now process beginless ranges with an Integer endpoint. [[Feature #18515]]
+ * Range#reverse_each now raises TypeError for endless ranges. [[Feature #18551]]
+ * Range#overlap? added for checking if two ranges overlap. [[Feature #19839]]
+
+* Refinement
+
+ * Add Refinement#target as an alternative of Refinement#refined_class.
+ Refinement#refined_class is deprecated and will be removed in Ruby
+ 3.4. [[Feature #19714]]
+
+* Regexp
+
+ * The cache-based optimization now supports lookarounds and atomic groupings. That is, match
+ for Regexp containing these extensions can now also be performed in linear time to the length
+ of the input string. However, these cannot contain captures and cannot be nested. [[Feature #19725]]
* String
- * `String#unpack` now raises ArgumentError for unknown directives. [[Bug #19150]]
- * `String#bytesplice` now accepts new arguments index/length or range of the source string to be copied. [[Feature #19314]]
+ * String#unpack now raises ArgumentError for unknown directives. [[Bug #19150]]
+ * String#bytesplice now accepts new arguments index/length or range of the
+ source string to be copied. [[Feature #19314]]
+
+* Thread::Queue
+
+ * Thread::Queue#freeze now raises TypeError. [[Bug #17146]]
+
+* Thread::SizedQueue
+
+ * Thread::SizedQueue#freeze now raises TypeError. [[Bug #17146]]
+
+* Time
+
+ * Time.new with a string argument became stricter. [[Bug #19293]]
+
+ ```ruby
+ Time.new('2023-12-20')
+ # no time information (ArgumentError)
+ ```
+
+* TracePoint
+
+ * TracePoint supports `rescue` event. When the raised exception was rescued,
+ the TracePoint will fire the hook. `rescue` event only supports Ruby-level
+ `rescue`. [[Feature #19572]]
## Stdlib updates
+* RubyGems and Bundler warn if users do `require` the following gems without adding them to Gemfile or gemspec.
+ This is because they will become the bundled gems in the future version of Ruby. This warning is suppressed
+ if you use bootsnap gem. We recommend to run your application with `DISABLE_BOOTSNAP=1` environmental variable
+ at least once. This is limitation of this version.
+ [[Feature #19351]] [[Feature #19776]] [[Feature #19843]]
+ * abbrev
+ * base64
+ * bigdecimal
+ * csv
+ * drb
+ * getoptlong
+ * mutex_m
+ * nkf
+ * observer
+ * racc
+ * resolv-replace
+ * rinda
+ * syslog
+
+* Socket#recv and Socket#recv_nonblock returns `nil` instead of an empty string on closed
+ connections. Socket#recvmsg and Socket#recvmsg_nonblock returns `nil` instead of an empty packet on closed
+ connections. [[Bug #19012]]
+
+* Name resolution such as Socket.getaddrinfo, Socket.getnameinfo, Addrinfo.getaddrinfo, etc.
+ can now be interrupted. [[Feature #19965]]
+
+* Random::Formatter#alphanumeric is extended to accept optional `chars`
+ keyword argument. [[Feature #18183]]
+
+The following default gem is added.
+
+* prism 0.19.0
+
The following default gems are updated.
-* RubyGems 3.5.0.dev
-* bundler 2.5.0.dev
-* csv 3.2.7
+* RubyGems 3.5.3
+* abbrev 0.1.2
+* base64 0.2.0
+* benchmark 0.3.0
+* bigdecimal 3.1.5
+* bundler 2.5.3
+* cgi 0.4.1
+* csv 3.2.8
+* date 3.3.4
+* delegate 0.3.1
+* drb 2.2.0
+* english 0.8.0
+* erb 4.0.3
+* error_highlight 0.6.0
+* etc 1.4.3
+* fcntl 1.1.0
* fiddle 1.1.2
-* optparse 0.4.0.pre.1
-* psych 5.0.2
-* stringio 3.0.5
-* strscan 3.0.6
+* fileutils 1.7.2
+* find 0.2.0
+* getoptlong 0.2.1
+* io-console 0.7.1
+* io-nonblock 0.3.0
+* io-wait 0.3.1
+* ipaddr 1.2.6
+* irb 1.11.0
+* json 2.7.1
+* logger 1.6.0
+* mutex_m 0.2.0
+* net-http 0.4.0
+* net-protocol 0.2.2
+* nkf 0.1.3
+* observer 0.1.2
+* open-uri 0.4.1
+* open3 0.2.1
+* openssl 3.2.0
+* optparse 0.4.0
+* ostruct 0.6.0
+* pathname 0.3.0
+* pp 0.5.0
+* prettyprint 0.2.0
+* pstore 0.1.3
+* psych 5.1.2
+* rdoc 6.6.2
+* readline 0.0.4
+* reline 0.4.1
+* resolv 0.3.0
+* rinda 0.2.0
+* securerandom 0.3.1
+* set 1.1.0
+* shellwords 0.2.0
+* singleton 0.2.0
+* stringio 3.1.0
+* strscan 3.0.7
+* syntax_suggest 2.0.0
+* syslog 0.1.2
+* tempfile 0.2.1
+* time 0.3.0
+* timeout 0.4.1
+* tmpdir 0.2.0
+* tsort 0.2.0
+* un 0.3.0
+* uri 0.13.0
+* weakref 0.1.3
+* win32ole 1.8.10
+* yaml 0.3.0
+* zlib 3.1.0
+
+The following bundled gem is promoted from default gems.
+
+* racc 1.7.3
The following bundled gems are updated.
-* minitest 5.17.0
-* rbs 2.8.4
-* typeprof 0.21.4
+* minitest 5.20.0
+* rake 13.1.0
+* test-unit 3.6.1
+* rexml 3.2.6
+* rss 0.3.0
+* net-ftp 0.3.3
+* net-imap 0.4.9
+* net-smtp 0.4.0
+* rbs 3.4.0
+* typeprof 0.21.9
+* debug 1.9.1
See GitHub releases like [Logger](https://github.com/ruby/logger/releases) or
changelog for details of the default gems or bundled gems.
-## Supported platforms
+### Prism
+
+* Introduced [the Prism parser](https://github.com/ruby/prism) as a default gem
+ * Prism is a portable, error tolerant, and maintainable recursive descent parser for the Ruby language
+* Prism is production ready and actively maintained, you can use it in place of Ripper
+ * There is [extensive documentation](https://ruby.github.io/prism/) on how to use Prism
+ * Prism is both a C library that will be used internally by CRuby and a Ruby gem that can be used by any tooling which needs to parse Ruby code
+ * Notable methods in the Prism API are:
+ * `Prism.parse(source)` which returns the AST as part of a parse result object
+ * `Prism.parse_comments(source)` which returns the comments
+ * `Prism.parse_success?(source)` which returns true if there are no errors
+* You can make pull requests or issues directly on [the Prism repository](https://github.com/ruby/prism) if you are interested in contributing
+* You can now use `ruby --parser=prism` or `RUBYOPT="--parser=prism"` to experiment with the Prism compiler. Please note that this flag is for debugging only.
## Compatibility issues
+* Subprocess creation/forking via the following file open methods is deprecated. [[Feature #19630]]
+ * Kernel#open
+ * URI.open
+ * IO.binread
+ * IO.foreach
+ * IO.readlines
+ * IO.read
+ * IO.write
+
+* When given a non-lambda, non-literal block, Kernel#lambda with now raises
+ ArgumentError instead of returning it unmodified. These usages have been
+ issuing warnings under the `Warning[:deprecated]` category since Ruby 3.0.0.
+ [[Feature #19777]]
+
+* The `RUBY_GC_HEAP_INIT_SLOTS` environment variable has been deprecated and
+ removed. Environment variables `RUBY_GC_HEAP_%d_INIT_SLOTS` should be
+ used instead. [[Feature #19785]]
+
+* `it` calls without arguments in a block with no ordinary parameters are
+ deprecated. `it` will be a reference to the first block parameter in Ruby 3.4.
+ [[Feature #18980]]
+
+* Error message for NoMethodError have changed to not use the target object's `#inspect`
+ for efficiency, and says "instance of ClassName" instead. [[Feature #18285]]
+
+ ```ruby
+ ([1] * 100).nonexisting
+ # undefined method `nonexisting' for an instance of Array (NoMethodError)
+ ```
+
+* Now anonymous parameters forwarding is disallowed inside a block
+ that uses anonymous parameters. [[Feature #19370]]
+
## Stdlib compatibility issues
+* `racc` is promoted to bundled gems.
+ * You need to add `racc` to your `Gemfile` if you use `racc` under bundler environment.
+* `ext/readline` is retired
+ * We have `reline` that is pure Ruby implementation compatible with `ext/readline` API.
+ We rely on `reline` in the future. If you need to use `ext/readline`, you can install
+ `ext/readline` via rubygems.org with `gem install readline-ext`.
+ * We no longer need to install libraries like `libreadline` or `libedit`.
+
## C API updates
+* `rb_postponed_job` updates
+ * New APIs and deprecated APIs (see comments for details)
+ * added: `rb_postponed_job_preregister()`
+ * added: `rb_postponed_job_trigger()`
+ * deprecated: `rb_postponed_job_register()` (and semantic change. see below)
+ * deprecated: `rb_postponed_job_register_one()`
+ * The postponed job APIs have been changed to address some rare crashes.
+ To solve the issue, we introduced new two APIs and deprecated current APIs.
+ The semantics of these functions have also changed slightly; `rb_postponed_job_register`
+ now behaves like the `once` variant in that multiple calls with the same
+ `func` might be coalesced into a single execution of the `func`
+ [[Feature #20057]]
+
+* Some updates for internal thread event hook APIs
+ * `rb_internal_thread_event_data_t` with a target Ruby thread (VALUE)
+ and callback functions (`rb_internal_thread_event_callback`) receive it.
+ https://github.com/ruby/ruby/pull/8885
+ * The following functions are introduced to manipulate Ruby thread local data
+ from internal thread event hook APIs (they are introduced since Ruby 3.2).
+ https://github.com/ruby/ruby/pull/8936
+ * `rb_internal_thread_specific_key_create()`
+ * `rb_internal_thread_specific_get()`
+ * `rb_internal_thread_specific_set()`
+
+* `rb_profile_thread_frames()` is introduced to get a frames from
+ a specific thread.
+ [[Feature #10602]]
+
+* `rb_data_define()` is introduced to define `Data`. [[Feature #19757]]
+
+* `rb_ext_resolve_symbol()` is introduced to search a function from
+ extension libraries. [[Feature #20005]]
+
+* IO related updates:
+ * The details of `rb_io_t` will be hidden and deprecated attributes
+ are added for each members. [[Feature #19057]]
+ * `rb_io_path(VALUE io)` is introduced to get a path of `io`.
+ * `rb_io_closed_p(VALUE io)` to get opening or closing of `io`.
+ * `rb_io_mode(VALUE io)` to get the mode of `io`.
+ * `rb_io_open_descriptor()` is introduced to make an IO object from a file
+ descriptor.
+
## Implementation improvements
-## JIT
+### Parser
+
+* Replace Bison with [Lrama LALR parser generator](https://github.com/ruby/lrama).
+ No need to install Bison to build Ruby from source code anymore.
+ We will no longer suffer bison compatibility issues and we can use new features by just implementing it to Lrama. [[Feature #19637]]
+ * See [The future vision of Ruby Parser](https://rubykaigi.org/2023/presentations/spikeolaf.html) for detail.
+ * Lrama internal parser is a LR parser generated by Racc for maintainability.
+ * Parameterizing Rules `(?, *, +)` are supported, it will be used in Ruby parse.y.
+
+### GC / Memory management
+
+* Major performance improvements over Ruby 3.2
+ * Young objects referenced by old objects are no longer immediately
+ promoted to the old generation. This significantly reduces the frequency of
+ major GC collections. [[Feature #19678]]
+ * A new `REMEMBERED_WB_UNPROTECTED_OBJECTS_LIMIT_RATIO` tuning variable was
+ introduced to control the number of unprotected objects cause a major GC
+ collection to trigger. The default is set to `0.01` (1%). This significantly
+ reduces the frequency of major GC collection. [[Feature #19571]]
+ * Write Barriers were implemented for many core types that were missing them,
+ notably `Time`, `Enumerator`, `MatchData`, `Method`, `File::Stat`, `BigDecimal`
+ and several others. This significantly reduces minor GC collection time and major
+ GC collection frequency.
+ * Most core classes are now using Variable Width Allocation, notably `Hash`, `Time`,
+ `Thread::Backtrace`, `Thread::Backtrace::Location`, `File::Stat`, `Method`.
+ This makes these classes faster to allocate and free, use less memory and reduce
+ heap fragmentation.
+* `defined?(@ivar)` is optimized with Object Shapes.
+
+### YJIT
+
+* Major performance improvements over Ruby 3.2
+ * Support for splat and rest arguments has been improved.
+ * Registers are allocated for stack operations of the virtual machine.
+ * More calls with optional arguments are compiled. Exception handlers are also compiled.
+ * Unsupported call types and megamorphic call sites no longer exit to the interpreter.
+ * Basic methods like Rails `#blank?` and
+ [specialized `#present?`](https://github.com/rails/rails/pull/49909) are inlined.
+ * `Integer#*`, `Integer#!=`, `String#!=`, `String#getbyte`,
+ `Kernel#block_given?`, `Kernel#is_a?`, `Kernel#instance_of?`, and `Module#===`
+ are specially optimized.
+ * Compilation speed is now slightly faster than Ruby 3.2.
+ * Now more than 3x faster than the interpreter on Optcarrot!
+* Significantly improved memory usage over Ruby 3.2
+ * Metadata for compiled code uses a lot less memory.
+ * `--yjit-call-threshold` is automatically raised from 30 to 120
+ when the application has more than 40,000 ISEQs.
+ * `--yjit-cold-threshold` is added to skip compiling cold ISEQs.
+ * More compact code is generated on Arm64.
+* Code GC is now disabled by default
+ * `--yjit-exec-mem-size` is treated as a hard limit where compilation of new code stops.
+ * No sudden drops in performance due to code GC.
+ Better copy-on-write behavior on servers reforking with
+ [Pitchfork](https://github.com/shopify/pitchfork).
+ * You can still enable code GC if desired with `--yjit-code-gc`
+* Add `RubyVM::YJIT.enable` that can enable YJIT at run-time
+ * You can start YJIT without modifying command-line arguments or environment variables.
+ Rails 7.2 will [enable YJIT by default](https://github.com/rails/rails/pull/49947)
+ using this method.
+ * This can also be used to enable YJIT only once your application is
+ done booting. `--yjit-disable` can be used if you want to use other
+ YJIT options while disabling YJIT at boot.
+* More YJIT stats are available by default
+ * `yjit_alloc_size` and several more metadata-related stats are now available by default.
+ * `ratio_in_yjit` stat produced by `--yjit-stats` is now available in release builds,
+ a special stats or dev build is no longer required to access most stats.
+* Add more profiling capabilities
+ * `--yjit-perf` is added to facilitate profiling with Linux perf.
+ * `--yjit-trace-exits` now supports sampling with `--yjit-trace-exits-sample-rate=N`
+* More thorough testing and multiple bug fixes
+* `--yjit-stats=quiet` is added to avoid printing stats on exit.
+
+### MJIT
+
+* MJIT is removed.
+ * `--disable-jit-support` is removed. Consider using `--disable-yjit --disable-rjit` instead.
+
+### RJIT
+
+* Introduced a pure-Ruby JIT compiler RJIT.
+ * RJIT supports only x86\_64 architecture on Unix platforms.
+ * Unlike MJIT, it doesn't require a C compiler at runtime.
+* RJIT exists only for experimental purposes.
+ * You should keep using YJIT in production.
+
+### M:N Thread scheduler
+
+* M:N Thread scheduler is introduced. [[Feature #19842]]
+ * Background: Ruby 1.8 and before, M:1 thread scheduler (M Ruby threads
+ with 1 native thread. Called as User level threads or Green threads)
+ is used. Ruby 1.9 and later, 1:1 thread scheduler (1 Ruby thread with
+ 1 native thread). M:1 threads takes lower resources compare with 1:1
+ threads because it needs only 1 native threads. However it is difficult
+ to support context switching for all of blocking operation so 1:1
+ threads are employed from Ruby 1.9. M:N thread scheduler uses N native
+ threads for M Ruby threads (N is small number in general). It doesn't
+ need same number of native threads as Ruby threads (similar to the M:1
+ thread scheduler). Also our M:N threads supports blocking operations
+ well same as 1:1 threads. See the ticket for more details.
+ Our M:N thread scheduler refers on the goroutine scheduler in the
+ Go language.
+ * In a ractor, only 1 thread can run in a same time because of
+ implementation. Therefore, applications that use only one Ractor
+ (most applications) M:N thread scheduler works as M:1 thread scheduler
+ with further extension from Ruby 1.8.
+ * M:N thread scheduler can introduce incompatibility for C-extensions,
+ so it is disabled by default on the main Ractors.
+ `RUBY_MN_THREADS=1` environment variable will enable it.
+ On non-main Ractors, M:N thread scheduler is enabled (and can not
+ disable it now).
+ * `N` (the number of native threads) can be specified with `RUBY_MAX_CPU`
+ environment variable. The default is 8.
+ Note that more than `N` native threads are used to support many kind of
+ blocking operations.
+[Bug #595]: https://bugs.ruby-lang.org/issues/595
+[Feature #10602]: https://bugs.ruby-lang.org/issues/10602
+[Bug #17146]: https://bugs.ruby-lang.org/issues/17146
+[Feature #18183]: https://bugs.ruby-lang.org/issues/18183
+[Feature #18285]: https://bugs.ruby-lang.org/issues/18285
+[Feature #18498]: https://bugs.ruby-lang.org/issues/18498
+[Feature #18515]: https://bugs.ruby-lang.org/issues/18515
+[Feature #18551]: https://bugs.ruby-lang.org/issues/18551
+[Feature #18885]: https://bugs.ruby-lang.org/issues/18885
+[Feature #18949]: https://bugs.ruby-lang.org/issues/18949
+[Feature #18980]: https://bugs.ruby-lang.org/issues/18980
+[Bug #19012]: https://bugs.ruby-lang.org/issues/19012
+[Feature #19057]: https://bugs.ruby-lang.org/issues/19057
[Bug #19150]: https://bugs.ruby-lang.org/issues/19150
+[Bug #19293]: https://bugs.ruby-lang.org/issues/19293
[Feature #19314]: https://bugs.ruby-lang.org/issues/19314
+[Feature #19347]: https://bugs.ruby-lang.org/issues/19347
+[Feature #19351]: https://bugs.ruby-lang.org/issues/19351
+[Feature #19362]: https://bugs.ruby-lang.org/issues/19362
+[Feature #19370]: https://bugs.ruby-lang.org/issues/19370
+[Feature #19521]: https://bugs.ruby-lang.org/issues/19521
+[Feature #19538]: https://bugs.ruby-lang.org/issues/19538
+[Feature #19561]: https://bugs.ruby-lang.org/issues/19561
+[Feature #19571]: https://bugs.ruby-lang.org/issues/19571
+[Feature #19572]: https://bugs.ruby-lang.org/issues/19572
+[Feature #19591]: https://bugs.ruby-lang.org/issues/19591
+[Feature #19630]: https://bugs.ruby-lang.org/issues/19630
+[Feature #19637]: https://bugs.ruby-lang.org/issues/19637
+[Feature #19678]: https://bugs.ruby-lang.org/issues/19678
+[Feature #19714]: https://bugs.ruby-lang.org/issues/19714
+[Feature #19725]: https://bugs.ruby-lang.org/issues/19725
+[Feature #19757]: https://bugs.ruby-lang.org/issues/19757
+[Feature #19776]: https://bugs.ruby-lang.org/issues/19776
+[Feature #19777]: https://bugs.ruby-lang.org/issues/19777
+[Feature #19785]: https://bugs.ruby-lang.org/issues/19785
+[Feature #19790]: https://bugs.ruby-lang.org/issues/19790
+[Feature #19839]: https://bugs.ruby-lang.org/issues/19839
+[Feature #19842]: https://bugs.ruby-lang.org/issues/19842
+[Feature #19843]: https://bugs.ruby-lang.org/issues/19843
+[Bug #19868]: https://bugs.ruby-lang.org/issues/19868
+[Feature #19965]: https://bugs.ruby-lang.org/issues/19965
+[Feature #20005]: https://bugs.ruby-lang.org/issues/20005
+[Feature #20057]: https://bugs.ruby-lang.org/issues/20057
diff --git a/README.ja.md b/README.ja.md
index eab96b0b0b..0d2d309fb8 100644
--- a/README.ja.md
+++ b/README.ja.md
@@ -1,5 +1,5 @@
[![Actions Status: MinGW](https://github.com/ruby/ruby/workflows/MinGW/badge.svg)](https://github.com/ruby/ruby/actions?query=workflow%3A"MinGW")
-[![Actions Status: MJIT](https://github.com/ruby/ruby/workflows/MJIT/badge.svg)](https://github.com/ruby/ruby/actions?query=workflow%3A"MJIT")
+[![Actions Status: RJIT](https://github.com/ruby/ruby/workflows/RJIT/badge.svg)](https://github.com/ruby/ruby/actions?query=workflow%3A"RJIT")
[![Actions Status: Ubuntu](https://github.com/ruby/ruby/workflows/Ubuntu/badge.svg)](https://github.com/ruby/ruby/actions?query=workflow%3A"Ubuntu")
[![Actions Status: Windows](https://github.com/ruby/ruby/workflows/Windows/badge.svg)](https://github.com/ruby/ruby/actions?query=workflow%3A"Windows")
[![AppVeyor status](https://ci.appveyor.com/api/projects/status/0sy8rrxut4o0k960/branch/master?svg=true)](https://ci.appveyor.com/project/ruby/ruby/branch/master)
@@ -26,7 +26,7 @@ Rubyはテキスト処理関係の能力などに優れ,Perlと同じくらい
* ダイナミックローディング (アーキテクチャによる)
* 移植性が高い.多くのUnix-like/POSIX互換プラットフォーム上で動くだけでなく,Windows, macOS,
Haikuなどの上でも動く cf.
- https://github.com/ruby/ruby/blob/master/doc/contributing.rdoc#platform-maintainers
+ https://docs.ruby-lang.org/en/master/maintainers_md.html#label-Platform+Maintainers
## 入手法
@@ -60,20 +60,20 @@ https://www.ruby-lang.org/
## メーリングリスト
-Rubyのメーリングリストがあります.参加希望の方は [ruby-list-request@ruby-lang.org] まで本文に
+Rubyのメーリングリストがあります.参加希望の方は [ruby-list-request@ml.ruby-lang.org] まで件名に
- subscribe
+ join
と書いて送って下さい.
Ruby開発者向けメーリングリストもあります.こちらではrubyのバグ,将来の仕様拡張など実装上の問題について議論されています.
-参加希望の方は [ruby-dev-request@ruby-lang.org] までruby-listと同様の方法でメールしてください.
+参加希望の方は [ruby-dev-request@ml.ruby-lang.org] までruby-listと同様の方法でメールしてください.
Ruby拡張モジュールについて話し合うruby-extメーリングリストと数学関係の話題について話し合うruby-mathメーリングリストと
英語でrubyについて話し合うruby-talkメーリングリストもあります.参加方法はどれも同じです.
-[ruby-list-request@ruby-lang.org]: mailto:ruby-list-request@ruby-lang.org?subject=Join%20Ruby%20Mailing%20List&body=subscribe
-[ruby-dev-request@ruby-lang.org]: mailto:ruby-dev-request@ruby-lang.org?subject=Join%20Ruby%20Mailing%20List&body=subscribe
+[ruby-list-request@ml.ruby-lang.org]: mailto:ruby-list-request@ml.ruby-lang.org?subject=join
+[ruby-dev-request@ml.ruby-lang.org]: mailto:ruby-dev-request@ml.ruby-lang.org?subject=join
## コンパイル・インストール
@@ -152,7 +152,7 @@ UNIXであれば `configure` がほとんどの差異を吸収してくれるは
## 配布条件
-[COPYING.ja](COPYING.ja) ファイルを参照してください.
+[COPYING.ja](https://docs.ruby-lang.org/en/master/COPYING_ja.html) ファイルを参照してください.
## フィードバック
diff --git a/README.md b/README.md
index 35ef2d9e89..8fb3786691 100644
--- a/README.md
+++ b/README.md
@@ -1,10 +1,9 @@
[![Actions Status: MinGW](https://github.com/ruby/ruby/workflows/MinGW/badge.svg)](https://github.com/ruby/ruby/actions?query=workflow%3A"MinGW")
-[![Actions Status: MJIT](https://github.com/ruby/ruby/workflows/MJIT/badge.svg)](https://github.com/ruby/ruby/actions?query=workflow%3A"MJIT")
+[![Actions Status: RJIT](https://github.com/ruby/ruby/workflows/RJIT/badge.svg)](https://github.com/ruby/ruby/actions?query=workflow%3A"RJIT")
[![Actions Status: Ubuntu](https://github.com/ruby/ruby/workflows/Ubuntu/badge.svg)](https://github.com/ruby/ruby/actions?query=workflow%3A"Ubuntu")
[![Actions Status: Windows](https://github.com/ruby/ruby/workflows/Windows/badge.svg)](https://github.com/ruby/ruby/actions?query=workflow%3A"Windows")
[![AppVeyor status](https://ci.appveyor.com/api/projects/status/0sy8rrxut4o0k960/branch/master?svg=true)](https://ci.appveyor.com/project/ruby/ruby/branch/master)
[![Travis Status](https://app.travis-ci.com/ruby/ruby.svg?branch=master)](https://app.travis-ci.com/ruby/ruby)
-[![Cirrus Status](https://api.cirrus-ci.com/github/ruby/ruby.svg)](https://cirrus-ci.com/github/ruby/ruby/master)
# What is Ruby?
@@ -25,15 +24,20 @@ It is simple, straightforward, and extensible.
* Dynamic Loading of Object Files (on some architectures)
* Highly Portable (works on many Unix-like/POSIX compatible platforms as
well as Windows, macOS, etc.) cf.
- https://github.com/ruby/ruby/blob/master/doc/maintainers.rdoc#label-Platform+Maintainers
+ https://docs.ruby-lang.org/en/master/maintainers_md.html#label-Platform+Maintainers
-## How to get Ruby with Git
+## How to get Ruby
For a complete list of ways to install Ruby, including using third-party tools
like rvm, see:
https://www.ruby-lang.org/en/downloads/
+You can download release packages and the snapshot of the repository. If you want to
+download whole versions of Ruby, please visit https://www.ruby-lang.org/en/downloads/releases/.
+
+### Download with Git
+
The mirror of the Ruby source tree can be checked out with the following command:
$ git clone https://github.com/ruby/ruby.git
@@ -48,7 +52,7 @@ if you are a committer.
## How to build
-see [Building Ruby](doc/contributing/building_ruby.md)
+See [Building Ruby](https://docs.ruby-lang.org/en/master/contributing/building_ruby_md.html)
## Ruby home page
@@ -64,11 +68,11 @@ https://www.ruby-lang.org/
There is a mailing list to discuss Ruby. To subscribe to this list, please
send the following phrase:
- subscribe
+ join
-in the mail body (not subject) to the address [ruby-talk-request@ruby-lang.org].
+in the mail subject (not body) to the address [ruby-talk-request@ml.ruby-lang.org].
-[ruby-talk-request@ruby-lang.org]: mailto:ruby-talk-request@ruby-lang.org?subject=Join%20Ruby%20Mailing%20List&body=subscribe
+[ruby-talk-request@ml.ruby-lang.org]: mailto:ruby-talk-request@ml.ruby-lang.org?subject=join
## Copying
diff --git a/addr2line.c b/addr2line.c
index 1c8de350d9..2a69dd0966 100644
--- a/addr2line.c
+++ b/addr2line.c
@@ -8,10 +8,14 @@
**********************************************************************/
-#if defined(__clang__)
+#if defined(__clang__) && defined(__has_warning)
+#if __has_warning("-Wgnu-empty-initializer")
#pragma clang diagnostic ignored "-Wgnu-empty-initializer"
+#endif
+#if __has_warning("-Wgcc-compat")
#pragma clang diagnostic ignored "-Wgcc-compat"
#endif
+#endif
#include "ruby/internal/config.h"
#include "ruby/defines.h"
@@ -57,8 +61,21 @@ void *alloca();
# endif
# endif /* AIX */
# endif /* HAVE_ALLOCA_H */
+# ifndef UNREACHABLE
+# define UNREACHABLE __builtin_unreachable()
+# endif
+# ifndef UNREACHABLE_RETURN
+# define UNREACHABLE_RETURN(_) __builtin_unreachable()
+# endif
#endif /* __GNUC__ */
+#ifndef UNREACHABLE
+# define UNREACHABLE abort()
+#endif
+#ifndef UNREACHABLE_RETURN
+# define UNREACHABLE_RETURN(_) return (abort(), (_))
+#endif
+
#ifdef HAVE_DLADDR
# include <dlfcn.h>
#endif
@@ -127,7 +144,7 @@ void *alloca();
#define DW_LNE_define_file 0x03
#define DW_LNE_set_discriminator 0x04 /* DWARF4 */
-PRINTF_ARGS(static int kprintf(const char *fmt, ...), 1, 2);
+#define kprintf(...) fprintf(errout, "" __VA_ARGS__)
typedef struct line_info {
const char *dirname;
@@ -184,7 +201,7 @@ obj_dwarf_section_at(obj_info_t *obj, int n)
&obj->debug_line_str
};
if (n < 0 || DWARF_SECTION_COUNT <= n) {
- abort();
+ UNREACHABLE_RETURN(0);
}
return ary[n];
}
@@ -237,7 +254,7 @@ sleb128(const char **p)
}
static const char *
-get_nth_dirname(unsigned long dir, const char *p)
+get_nth_dirname(unsigned long dir, const char *p, FILE *errout)
{
if (!dir--) {
return "";
@@ -254,10 +271,14 @@ get_nth_dirname(unsigned long dir, const char *p)
return p;
}
-static const char *parse_ver5_debug_line_header(const char *p, int idx, uint8_t format, obj_info_t *obj, const char **out_path, uint64_t *out_directory_index);
+static const char *parse_ver5_debug_line_header(
+ const char *p, int idx, uint8_t format,
+ obj_info_t *obj, const char **out_path,
+ uint64_t *out_directory_index, FILE *errout);
static void
-fill_filename(int file, uint8_t format, uint16_t version, const char *include_directories, const char *filenames, line_info_t *line, obj_info_t *obj)
+fill_filename(int file, uint8_t format, uint16_t version, const char *include_directories,
+ const char *filenames, line_info_t *line, obj_info_t *obj, FILE *errout)
{
int i;
const char *p = filenames;
@@ -266,9 +287,9 @@ fill_filename(int file, uint8_t format, uint16_t version, const char *include_di
if (version >= 5) {
const char *path;
uint64_t directory_index = -1;
- parse_ver5_debug_line_header(filenames, file, format, obj, &path, &directory_index);
+ parse_ver5_debug_line_header(filenames, file, format, obj, &path, &directory_index, errout);
line->filename = path;
- parse_ver5_debug_line_header(include_directories, (int)directory_index, format, obj, &path, NULL);
+ parse_ver5_debug_line_header(include_directories, (int)directory_index, format, obj, &path, NULL, errout);
line->dirname = path;
}
else {
@@ -290,7 +311,7 @@ fill_filename(int file, uint8_t format, uint16_t version, const char *include_di
if (i == file) {
line->filename = filename;
- line->dirname = get_nth_dirname(dir, include_directories);
+ line->dirname = get_nth_dirname(dir, include_directories, errout);
}
}
}
@@ -299,7 +320,7 @@ fill_filename(int file, uint8_t format, uint16_t version, const char *include_di
static void
fill_line(int num_traces, void **traces, uintptr_t addr, int file, int line,
uint8_t format, uint16_t version, const char *include_directories, const char *filenames,
- obj_info_t *obj, line_info_t *lines, int offset)
+ obj_info_t *obj, line_info_t *lines, int offset, FILE *errout)
{
int i;
addr += obj->base_addr - obj->vmaddr;
@@ -308,7 +329,7 @@ fill_line(int num_traces, void **traces, uintptr_t addr, int file, int line,
/* We assume one line code doesn't result >100 bytes of native code.
We may want more reliable way eventually... */
if (addr < a && a < addr + 100) {
- fill_filename(file, format, version, include_directories, filenames, &lines[i], obj);
+ fill_filename(file, format, version, include_directories, filenames, &lines[i], obj, errout);
lines[i].line = line;
}
}
@@ -333,7 +354,7 @@ struct LineNumberProgramHeader {
};
static int
-parse_debug_line_header(obj_info_t *obj, const char **pp, struct LineNumberProgramHeader *header)
+parse_debug_line_header(obj_info_t *obj, const char **pp, struct LineNumberProgramHeader *header, FILE *errout)
{
const char *p = *pp;
header->unit_length = *(uint32_t *)p;
@@ -379,7 +400,7 @@ parse_debug_line_header(obj_info_t *obj, const char **pp, struct LineNumberProgr
if (header->version >= 5) {
header->include_directories = p;
- p = parse_ver5_debug_line_header(p, -1, header->format, obj, NULL, NULL);
+ p = parse_ver5_debug_line_header(p, -1, header->format, obj, NULL, NULL, errout);
header->filenames = p;
}
else {
@@ -406,7 +427,7 @@ parse_debug_line_header(obj_info_t *obj, const char **pp, struct LineNumberProgr
static int
parse_debug_line_cu(int num_traces, void **traces, const char **debug_line,
- obj_info_t *obj, line_info_t *lines, int offset)
+ obj_info_t *obj, line_info_t *lines, int offset, FILE *errout)
{
const char *p = (const char *)*debug_line;
struct LineNumberProgramHeader header;
@@ -423,7 +444,7 @@ parse_debug_line_cu(int num_traces, void **traces, const char **debug_line,
/* int epilogue_begin = 0; */
/* unsigned int isa = 0; */
- if (parse_debug_line_header(obj, &p, &header))
+ if (parse_debug_line_header(obj, &p, &header, errout))
return -1;
is_stmt = header.default_is_stmt;
@@ -434,7 +455,7 @@ parse_debug_line_cu(int num_traces, void **traces, const char **debug_line,
header.version, \
header.include_directories, \
header.filenames, \
- obj, lines, offset); \
+ obj, lines, offset, errout); \
/*basic_block = prologue_end = epilogue_begin = 0;*/ \
} while (0)
@@ -534,11 +555,11 @@ parse_debug_line_cu(int num_traces, void **traces, const char **debug_line,
static int
parse_debug_line(int num_traces, void **traces,
const char *debug_line, unsigned long size,
- obj_info_t *obj, line_info_t *lines, int offset)
+ obj_info_t *obj, line_info_t *lines, int offset, FILE *errout)
{
const char *debug_line_end = debug_line + size;
while (debug_line < debug_line_end) {
- if (parse_debug_line_cu(num_traces, traces, &debug_line, obj, lines, offset))
+ if (parse_debug_line_cu(num_traces, traces, &debug_line, obj, lines, offset, errout))
return -1;
}
if (debug_line != debug_line_end) {
@@ -551,7 +572,7 @@ parse_debug_line(int num_traces, void **traces,
/* read file and fill lines */
static uintptr_t
fill_lines(int num_traces, void **traces, int check_debuglink,
- obj_info_t **objp, line_info_t *lines, int offset);
+ obj_info_t **objp, line_info_t *lines, int offset, FILE *errout);
static void
append_obj(obj_info_t **objp)
@@ -579,7 +600,7 @@ append_obj(obj_info_t **objp)
// check the path pattern of "/usr/lib/debug/usr/bin/ruby.debug"
static void
follow_debuglink(const char *debuglink, int num_traces, void **traces,
- obj_info_t **objp, line_info_t *lines, int offset)
+ obj_info_t **objp, line_info_t *lines, int offset, FILE *errout)
{
static const char global_debug_dir[] = "/usr/lib/debug";
const size_t global_debug_dir_len = sizeof(global_debug_dir) - 1;
@@ -605,13 +626,13 @@ follow_debuglink(const char *debuglink, int num_traces, void **traces,
o2 = *objp;
o2->base_addr = o1->base_addr;
o2->path = o1->path;
- fill_lines(num_traces, traces, 0, objp, lines, offset);
+ fill_lines(num_traces, traces, 0, objp, lines, offset, errout);
}
// check the path pattern of "/usr/lib/debug/.build-id/ab/cdef1234.debug"
static void
follow_debuglink_build_id(const char *build_id, size_t build_id_size, int num_traces, void **traces,
- obj_info_t **objp, line_info_t *lines, int offset)
+ obj_info_t **objp, line_info_t *lines, int offset, FILE *errout)
{
static const char global_debug_dir[] = "/usr/lib/debug/.build-id/";
const size_t global_debug_dir_len = sizeof(global_debug_dir) - 1;
@@ -636,7 +657,7 @@ follow_debuglink_build_id(const char *build_id, size_t build_id_size, int num_tr
o2 = *objp;
o2->base_addr = o1->base_addr;
o2->path = o1->path;
- fill_lines(num_traces, traces, 0, objp, lines, offset);
+ fill_lines(num_traces, traces, 0, objp, lines, offset, errout);
}
#endif
@@ -840,7 +861,11 @@ enum
DW_FORM_addrx1 = 0x29,
DW_FORM_addrx2 = 0x2a,
DW_FORM_addrx3 = 0x2b,
- DW_FORM_addrx4 = 0x2c
+ DW_FORM_addrx4 = 0x2c,
+
+ /* GNU extensions for referring to .gnu_debugaltlink dwz-compressed info */
+ DW_FORM_GNU_ref_alt = 0x1f20,
+ DW_FORM_GNU_strp_alt = 0x1f21
};
/* Range list entry encodings */
@@ -1058,13 +1083,13 @@ di_read_debug_abbrev_cu(DebugInfoReader *reader)
}
static int
-di_read_debug_line_cu(DebugInfoReader *reader)
+di_read_debug_line_cu(DebugInfoReader *reader, FILE *errout)
{
const char *p;
struct LineNumberProgramHeader header;
p = (const char *)reader->debug_line_cu_end;
- if (parse_debug_line_header(reader->obj, &p, &header))
+ if (parse_debug_line_header(reader->obj, &p, &header, errout))
return -1;
reader->debug_line_cu_end = (char *)header.cu_end;
@@ -1144,19 +1169,32 @@ resolve_strx(DebugInfoReader *reader, uint64_t idx)
return reader->obj->debug_str.ptr + off;
}
-static void
-debug_info_reader_read_value(DebugInfoReader *reader, uint64_t form, DebugInfoValue *v)
+static bool
+debug_info_reader_read_addr_value_member(DebugInfoReader *reader, DebugInfoValue *v, int size)
+{
+ if (size == 4) {
+ set_uint_value(v, read_uint32(&reader->p));
+ } else if (size == 8) {
+ set_uint_value(v, read_uint64(&reader->p));
+ } else {
+ return false;
+ }
+ return true;
+}
+
+#define debug_info_reader_read_addr_value(reader, v, mem) \
+ if (!debug_info_reader_read_addr_value_member((reader), (v), (reader)->mem)) { \
+ kprintf("unknown " #mem ":%d", (reader)->mem); \
+ return false; \
+ }
+
+
+static bool
+debug_info_reader_read_value(DebugInfoReader *reader, uint64_t form, DebugInfoValue *v, FILE *errout)
{
switch (form) {
case DW_FORM_addr:
- if (reader->address_size == 4) {
- set_uint_value(v, read_uint32(&reader->p));
- } else if (reader->address_size == 8) {
- set_uint_value(v, read_uint64(&reader->p));
- } else {
- fprintf(stderr,"unknown address_size:%d", reader->address_size);
- abort();
- }
+ debug_info_reader_read_addr_value(reader, v, address_size);
break;
case DW_FORM_block2:
v->size = read_uint16(&reader->p);
@@ -1208,13 +1246,12 @@ debug_info_reader_read_value(DebugInfoReader *reader, uint64_t form, DebugInfoVa
set_uint_value(v, read_uleb128(reader));
break;
case DW_FORM_ref_addr:
- if (reader->format == 4) {
- set_uint_value(v, read_uint32(&reader->p));
- } else if (reader->format == 8) {
- set_uint_value(v, read_uint64(&reader->p));
+ if (reader->current_version <= 2) {
+ // DWARF Version 2 specifies that references have
+ // the same size as an address on the target system
+ debug_info_reader_read_addr_value(reader, v, address_size);
} else {
- fprintf(stderr,"unknown format:%d", reader->format);
- abort();
+ debug_info_reader_read_addr_value(reader, v, format);
}
break;
case DW_FORM_ref1:
@@ -1315,20 +1352,28 @@ debug_info_reader_read_value(DebugInfoReader *reader, uint64_t form, DebugInfoVa
case DW_FORM_addrx4:
set_addr_idx_value(v, read_uint32(&reader->p));
break;
+ /* we have no support for actually reading the real values of these refs out
+ * of the .gnu_debugaltlink dwz-compressed debuginfo at the moment, but "read"
+ * them anyway so that we advance the reader by the right amount. */
+ case DW_FORM_GNU_ref_alt:
+ case DW_FORM_GNU_strp_alt:
+ read_uint(reader);
+ set_uint_value(v, 0);
+ break;
case 0:
goto fail;
break;
}
- return;
+ return true;
fail:
- fprintf(stderr, "%d: unsupported form: %#"PRIx64"\n", __LINE__, form);
- exit(1);
+ kprintf("%d: unsupported form: %#"PRIx64"\n", __LINE__, form);
+ return false;
}
/* find abbrev in current compilation unit */
static const char *
-di_find_abbrev(DebugInfoReader *reader, uint64_t abbrev_number)
+di_find_abbrev(DebugInfoReader *reader, uint64_t abbrev_number, FILE *errout)
{
const char *p;
if (abbrev_number < ABBREV_TABLE_SIZE) {
@@ -1341,8 +1386,8 @@ di_find_abbrev(DebugInfoReader *reader, uint64_t abbrev_number)
di_skip_die_attributes(&p);
for (uint64_t n = uleb128(&p); abbrev_number != n; n = uleb128(&p)) {
if (n == 0) {
- fprintf(stderr,"%d: Abbrev Number %"PRId64" not found\n",__LINE__, abbrev_number);
- exit(1);
+ kprintf("%d: Abbrev Number %"PRId64" not found\n",__LINE__, abbrev_number);
+ return NULL;
}
uleb128(&p); /* tag */
p++; /* has_children */
@@ -1353,52 +1398,52 @@ di_find_abbrev(DebugInfoReader *reader, uint64_t abbrev_number)
#if 0
static void
-hexdump0(const unsigned char *p, size_t n)
+hexdump0(const unsigned char *p, size_t n, FILE *errout)
{
size_t i;
- fprintf(stderr, " 0 1 2 3 4 5 6 7 8 9 A B C D E F\n");
+ kprintf(" 0 1 2 3 4 5 6 7 8 9 A B C D E F\n");
for (i=0; i < n; i++){
switch (i & 15) {
case 0:
- fprintf(stderr, "%02" PRIdSIZE ": %02X ", i/16, p[i]);
+ kprintf("%02" PRIdSIZE ": %02X ", i/16, p[i]);
break;
case 15:
- fprintf(stderr, "%02X\n", p[i]);
+ kprintf("%02X\n", p[i]);
break;
default:
- fprintf(stderr, "%02X ", p[i]);
+ kprintf("%02X ", p[i]);
break;
}
}
if ((i & 15) != 15) {
- fprintf(stderr, "\n");
+ kprintf("\n");
}
}
-#define hexdump(p,n) hexdump0((const unsigned char *)p, n)
+#define hexdump(p,n,e) hexdump0((const unsigned char *)p, n, e)
static void
-div_inspect(DebugInfoValue *v)
+div_inspect(DebugInfoValue *v, FILE *errout)
{
switch (v->type) {
case VAL_uint:
- fprintf(stderr,"%d: type:%d size:%" PRIxSIZE " v:%"PRIx64"\n",__LINE__,v->type,v->size,v->as.uint64);
+ kprintf("%d: type:%d size:%" PRIxSIZE " v:%"PRIx64"\n",__LINE__,v->type,v->size,v->as.uint64);
break;
case VAL_int:
- fprintf(stderr,"%d: type:%d size:%" PRIxSIZE " v:%"PRId64"\n",__LINE__,v->type,v->size,(int64_t)v->as.uint64);
+ kprintf("%d: type:%d size:%" PRIxSIZE " v:%"PRId64"\n",__LINE__,v->type,v->size,(int64_t)v->as.uint64);
break;
case VAL_cstr:
- fprintf(stderr,"%d: type:%d size:%" PRIxSIZE " v:'%s'\n",__LINE__,v->type,v->size,v->as.ptr);
+ kprintf("%d: type:%d size:%" PRIxSIZE " v:'%s'\n",__LINE__,v->type,v->size,v->as.ptr);
break;
case VAL_data:
- fprintf(stderr,"%d: type:%d size:%" PRIxSIZE " v:\n",__LINE__,v->type,v->size);
- hexdump(v->as.ptr, 16);
+ kprintf("%d: type:%d size:%" PRIxSIZE " v:\n",__LINE__,v->type,v->size);
+ hexdump(v->as.ptr, 16, errout);
break;
}
}
#endif
static DIE *
-di_read_die(DebugInfoReader *reader, DIE *die)
+di_read_die(DebugInfoReader *reader, DIE *die, FILE *errout)
{
uint64_t abbrev_number = uleb128(&reader->p);
if (abbrev_number == 0) {
@@ -1406,7 +1451,7 @@ di_read_die(DebugInfoReader *reader, DIE *die)
return NULL;
}
- reader->q = di_find_abbrev(reader, abbrev_number);
+ if (!(reader->q = di_find_abbrev(reader, abbrev_number, errout))) return NULL;
die->pos = reader->p - reader->obj->debug_info.ptr - 1;
die->tag = (int)uleb128(&reader->q); /* tag */
@@ -1418,26 +1463,26 @@ di_read_die(DebugInfoReader *reader, DIE *die)
}
static DebugInfoValue *
-di_read_record(DebugInfoReader *reader, DebugInfoValue *vp)
+di_read_record(DebugInfoReader *reader, DebugInfoValue *vp, FILE *errout)
{
uint64_t at = uleb128(&reader->q);
uint64_t form = uleb128(&reader->q);
if (!at || !form) return NULL;
vp->at = at;
vp->form = form;
- debug_info_reader_read_value(reader, form, vp);
+ if (!debug_info_reader_read_value(reader, form, vp, errout)) return NULL;
return vp;
}
-static void
-di_skip_records(DebugInfoReader *reader)
+static bool
+di_skip_records(DebugInfoReader *reader, FILE *errout)
{
for (;;) {
- DebugInfoValue v = {{}};
+ DebugInfoValue v = {{0}};
uint64_t at = uleb128(&reader->q);
uint64_t form = uleb128(&reader->q);
- if (!at || !form) return;
- debug_info_reader_read_value(reader, form, &v);
+ if (!at || !form) return true;
+ if (!debug_info_reader_read_value(reader, form, &v, errout)) return false;
}
}
@@ -1449,13 +1494,14 @@ typedef struct addr_header {
/* uint8_t segment_selector_size; */
} addr_header_t;
-static void
-addr_header_init(obj_info_t *obj, addr_header_t *header) {
+static bool
+addr_header_init(obj_info_t *obj, addr_header_t *header, FILE *errout)
+{
const char *p = obj->debug_addr.ptr;
header->ptr = p;
- if (!p) return;
+ if (!p) return true;
header->unit_length = *(uint32_t *)p;
p += sizeof(uint32_t);
@@ -1469,7 +1515,12 @@ addr_header_init(obj_info_t *obj, addr_header_t *header) {
p += 2; /* version */
header->address_size = *p++;
+ if (header->address_size != 4 && header->address_size != 8) {
+ kprintf("unknown address_size:%d", header->address_size);
+ return false;
+ }
p++; /* segment_selector_size */
+ return true;
}
static uint64_t
@@ -1489,11 +1540,12 @@ typedef struct rnglists_header {
uint32_t offset_entry_count;
} rnglists_header_t;
-static void
-rnglists_header_init(obj_info_t *obj, rnglists_header_t *header) {
+static bool
+rnglists_header_init(obj_info_t *obj, rnglists_header_t *header, FILE *errout)
+{
const char *p = obj->debug_rnglists.ptr;
- if (!p) return;
+ if (!p) return true;
header->unit_length = *(uint32_t *)p;
p += sizeof(uint32_t);
@@ -1507,8 +1559,13 @@ rnglists_header_init(obj_info_t *obj, rnglists_header_t *header) {
p += 2; /* version */
header->address_size = *p++;
+ if (header->address_size != 4 && header->address_size != 8) {
+ kprintf("unknown address_size:%d", header->address_size);
+ return false;
+ }
p++; /* segment_selector_size */
header->offset_entry_count = *(uint32_t *)p;
+ return true;
}
typedef struct {
@@ -1552,26 +1609,23 @@ ranges_set(ranges_t *ptr, DebugInfoValue *v, addr_header_t *addr_header, uint64_
}
static uint64_t
-read_dw_form_addr(DebugInfoReader *reader, const char **ptr)
+read_dw_form_addr(DebugInfoReader *reader, const char **ptr, FILE *errout)
{
const char *p = *ptr;
*ptr = p + reader->address_size;
if (reader->address_size == 4) {
return read_uint32(&p);
- } else if (reader->address_size == 8) {
- return read_uint64(&p);
} else {
- fprintf(stderr,"unknown address_size:%d", reader->address_size);
- abort();
+ return read_uint64(&p);
}
}
static uintptr_t
-ranges_include(DebugInfoReader *reader, ranges_t *ptr, uint64_t addr, rnglists_header_t *rnglists_header)
+ranges_include(DebugInfoReader *reader, ranges_t *ptr, uint64_t addr, rnglists_header_t *rnglists_header, FILE *errout)
{
if (ptr->high_pc_set) {
if (ptr->ranges_set || !ptr->low_pc_set) {
- exit(1);
+ return UINTPTR_MAX;
}
if (ptr->low_pc <= addr && addr <= ptr->high_pc) {
return (uintptr_t)ptr->low_pc;
@@ -1620,15 +1674,15 @@ ranges_include(DebugInfoReader *reader, ranges_t *ptr, uint64_t addr, rnglists_h
to = (uintptr_t)base + uleb128(&p);
break;
case DW_RLE_base_address:
- base = read_dw_form_addr(reader, &p);
+ base = read_dw_form_addr(reader, &p, errout);
base_valid = true;
break;
case DW_RLE_start_end:
- from = (uintptr_t)read_dw_form_addr(reader, &p);
- to = (uintptr_t)read_dw_form_addr(reader, &p);
+ from = (uintptr_t)read_dw_form_addr(reader, &p, errout);
+ to = (uintptr_t)read_dw_form_addr(reader, &p, errout);
break;
case DW_RLE_start_length:
- from = (uintptr_t)read_dw_form_addr(reader, &p);
+ from = (uintptr_t)read_dw_form_addr(reader, &p, errout);
to = from + uleb128(&p);
break;
}
@@ -1636,7 +1690,7 @@ ranges_include(DebugInfoReader *reader, ranges_t *ptr, uint64_t addr, rnglists_h
return from;
}
}
- return false;
+ return 0;
}
p = reader->obj->debug_ranges.ptr + ptr->ranges;
for (;;) {
@@ -1657,42 +1711,42 @@ ranges_include(DebugInfoReader *reader, ranges_t *ptr, uint64_t addr, rnglists_h
return (uintptr_t)ptr->low_pc;
}
}
- return false;
+ return 0;
}
#if 0
static void
-ranges_inspect(DebugInfoReader *reader, ranges_t *ptr)
+ranges_inspect(DebugInfoReader *reader, ranges_t *ptr, FILE *errout)
{
if (ptr->high_pc_set) {
if (ptr->ranges_set || !ptr->low_pc_set) {
- fprintf(stderr,"low_pc_set:%d high_pc_set:%d ranges_set:%d\n",ptr->low_pc_set,ptr->high_pc_set,ptr->ranges_set);
- exit(1);
+ kprintf("low_pc_set:%d high_pc_set:%d ranges_set:%d\n",ptr->low_pc_set,ptr->high_pc_set,ptr->ranges_set);
+ return;
}
- fprintf(stderr,"low_pc:%"PRIx64" high_pc:%"PRIx64"\n",ptr->low_pc,ptr->high_pc);
+ kprintf("low_pc:%"PRIx64" high_pc:%"PRIx64"\n",ptr->low_pc,ptr->high_pc);
}
else if (ptr->ranges_set) {
char *p = reader->obj->debug_ranges.ptr + ptr->ranges;
- fprintf(stderr,"low_pc:%"PRIx64" ranges:%"PRIx64" %lx ",ptr->low_pc,ptr->ranges, p-reader->obj->mapped);
+ kprintf("low_pc:%"PRIx64" ranges:%"PRIx64" %lx ",ptr->low_pc,ptr->ranges, p-reader->obj->mapped);
for (;;) {
uintptr_t from = read_uintptr(&p);
uintptr_t to = read_uintptr(&p);
if (!from && !to) break;
- fprintf(stderr,"%"PRIx64"-%"PRIx64" ",ptr->low_pc+from,ptr->low_pc+to);
+ kprintf("%"PRIx64"-%"PRIx64" ",ptr->low_pc+from,ptr->low_pc+to);
}
- fprintf(stderr,"\n");
+ kprintf("\n");
}
else if (ptr->low_pc_set) {
- fprintf(stderr,"low_pc:%"PRIx64"\n",ptr->low_pc);
+ kprintf("low_pc:%"PRIx64"\n",ptr->low_pc);
}
else {
- fprintf(stderr,"empty\n");
+ kprintf("empty\n");
}
}
#endif
static int
-di_read_cu(DebugInfoReader *reader)
+di_read_cu(DebugInfoReader *reader, FILE *errout)
{
uint64_t unit_length;
uint16_t version;
@@ -1719,19 +1773,23 @@ di_read_cu(DebugInfoReader *reader)
debug_abbrev_offset = read_uint(reader);
reader->address_size = read_uint8(&reader->p);
}
+ if (reader->address_size != 4 && reader->address_size != 8) {
+ kprintf("unknown address_size:%d", reader->address_size);
+ return -1;
+ }
reader->q0 = reader->obj->debug_abbrev.ptr + debug_abbrev_offset;
reader->level = 0;
di_read_debug_abbrev_cu(reader);
- if (di_read_debug_line_cu(reader)) return -1;
+ if (di_read_debug_line_cu(reader, errout)) return -1;
do {
DIE die;
- if (!di_read_die(reader, &die)) continue;
+ if (!di_read_die(reader, &die, errout)) continue;
if (die.tag != DW_TAG_compile_unit) {
- di_skip_records(reader);
+ if (!di_skip_records(reader, errout)) return -1;
break;
}
@@ -1739,11 +1797,11 @@ di_read_cu(DebugInfoReader *reader)
reader->current_addr_base = 0;
reader->current_rnglists_base = 0;
- DebugInfoValue low_pc = {{}};
+ DebugInfoValue low_pc = {{0}};
/* enumerate abbrev */
for (;;) {
- DebugInfoValue v = {{}};
- if (!di_read_record(reader, &v)) break;
+ DebugInfoValue v = {{0}};
+ if (!di_read_record(reader, &v, errout)) break;
switch (v.at) {
case DW_AT_low_pc:
// clang may output DW_AT_addr_base after DW_AT_low_pc.
@@ -1768,8 +1826,8 @@ di_read_cu(DebugInfoReader *reader)
break;
case VAL_addr:
{
- addr_header_t header = {};
- addr_header_init(reader->obj, &header);
+ addr_header_t header = {0};
+ if (!addr_header_init(reader->obj, &header, errout)) return -1;
reader->current_low_pc = read_addr(&header, reader->current_addr_base, low_pc.as.addr_idx);
}
break;
@@ -1780,7 +1838,7 @@ di_read_cu(DebugInfoReader *reader)
}
static void
-read_abstract_origin(DebugInfoReader *reader, uint64_t form, uint64_t abstract_origin, line_info_t *line)
+read_abstract_origin(DebugInfoReader *reader, uint64_t form, uint64_t abstract_origin, line_info_t *line, FILE *errout)
{
const char *p = reader->p;
const char *q = reader->q;
@@ -1805,12 +1863,12 @@ read_abstract_origin(DebugInfoReader *reader, uint64_t form, uint64_t abstract_o
default:
goto finish;
}
- if (!di_read_die(reader, &die)) goto finish;
+ if (!di_read_die(reader, &die, errout)) goto finish;
/* enumerate abbrev */
for (;;) {
- DebugInfoValue v = {{}};
- if (!di_read_record(reader, &v)) break;
+ DebugInfoValue v = {{0}};
+ if (!di_read_record(reader, &v, errout)) break;
switch (v.at) {
case DW_AT_name:
line->sname = get_cstr_value(&v);
@@ -1824,43 +1882,44 @@ read_abstract_origin(DebugInfoReader *reader, uint64_t form, uint64_t abstract_o
reader->level = level;
}
-static void
+static bool
debug_info_read(DebugInfoReader *reader, int num_traces, void **traces,
- line_info_t *lines, int offset) {
+ line_info_t *lines, int offset, FILE *errout)
+{
- addr_header_t addr_header = {};
- addr_header_init(reader->obj, &addr_header);
+ addr_header_t addr_header = {0};
+ if (!addr_header_init(reader->obj, &addr_header, errout)) return false;
- rnglists_header_t rnglists_header = {};
- rnglists_header_init(reader->obj, &rnglists_header);
+ rnglists_header_t rnglists_header = {0};
+ if (!rnglists_header_init(reader->obj, &rnglists_header, errout)) return false;
while (reader->p < reader->cu_end) {
DIE die;
- ranges_t ranges = {};
- line_info_t line = {};
+ ranges_t ranges = {0};
+ line_info_t line = {0};
- if (!di_read_die(reader, &die)) continue;
- /* fprintf(stderr,"%d:%tx: <%d>\n",__LINE__,die.pos,reader->level,die.tag); */
+ if (!di_read_die(reader, &die, errout)) continue;
+ /* kprintf("%d:%tx: <%d>\n",__LINE__,die.pos,reader->level,die.tag); */
if (die.tag != DW_TAG_subprogram && die.tag != DW_TAG_inlined_subroutine) {
skip_die:
- di_skip_records(reader);
+ if (!di_skip_records(reader, errout)) return false;
continue;
}
/* enumerate abbrev */
for (;;) {
- DebugInfoValue v = {{}};
+ DebugInfoValue v = {{0}};
/* ptrdiff_t pos = reader->p - reader->p0; */
- if (!di_read_record(reader, &v)) break;
- /* fprintf(stderr,"\n%d:%tx: AT:%lx FORM:%lx\n",__LINE__,pos,v.at,v.form); */
- /* div_inspect(&v); */
+ if (!di_read_record(reader, &v, errout)) break;
+ /* kprintf("\n%d:%tx: AT:%lx FORM:%lx\n",__LINE__,pos,v.at,v.form); */
+ /* div_inspect(&v, errout); */
switch (v.at) {
case DW_AT_name:
line.sname = get_cstr_value(&v);
break;
case DW_AT_call_file:
- fill_filename((int)v.as.uint64, reader->debug_line_format, reader->debug_line_version, reader->debug_line_directories, reader->debug_line_files, &line, reader->obj);
+ fill_filename((int)v.as.uint64, reader->debug_line_format, reader->debug_line_version, reader->debug_line_directories, reader->debug_line_files, &line, reader->obj, errout);
break;
case DW_AT_call_line:
line.line = (int)v.as.uint64;
@@ -1876,18 +1935,19 @@ debug_info_read(DebugInfoReader *reader, int num_traces, void **traces,
/* 1 or 3 */
break; /* goto skip_die; */
case DW_AT_abstract_origin:
- read_abstract_origin(reader, v.form, v.as.uint64, &line);
+ read_abstract_origin(reader, v.form, v.as.uint64, &line, errout);
break; /* goto skip_die; */
}
}
- /* ranges_inspect(reader, &ranges); */
- /* fprintf(stderr,"%d:%tx: %x ",__LINE__,diepos,die.tag); */
+ /* ranges_inspect(reader, &ranges, errout); */
+ /* kprintf("%d:%tx: %x ",__LINE__,diepos,die.tag); */
for (int i=offset; i < num_traces; i++) {
uintptr_t addr = (uintptr_t)traces[i];
uintptr_t offset = addr - reader->obj->base_addr + reader->obj->vmaddr;
- uintptr_t saddr = ranges_include(reader, &ranges, offset, &rnglists_header);
+ uintptr_t saddr = ranges_include(reader, &ranges, offset, &rnglists_header, errout);
+ if (saddr == UINTPTR_MAX) return false;
if (saddr) {
- /* fprintf(stdout, "%d:%tx: %d %lx->%lx %x %s: %s/%s %d %s %s %s\n",__LINE__,die.pos, i,addr,offset, die.tag,line.sname,line.dirname,line.filename,line.line,reader->obj->path,line.sname,lines[i].sname); */
+ /* kprintf("%d:%tx: %d %lx->%lx %x %s: %s/%s %d %s %s %s\n",__LINE__,die.pos, i,addr,offset, die.tag,line.sname,line.dirname,line.filename,line.line,reader->obj->path,line.sname,lines[i].sname); */
if (lines[i].sname) {
line_info_t *lp = malloc(sizeof(line_info_t));
memcpy(lp, &lines[i], sizeof(line_info_t));
@@ -1904,6 +1964,7 @@ debug_info_read(DebugInfoReader *reader, int num_traces, void **traces,
}
}
}
+ return true;
}
// This function parses the following attributes of Line Number Program Header in DWARF 5:
@@ -1922,7 +1983,10 @@ debug_info_read(DebugInfoReader *reader, int num_traces, void **traces,
//
// It records DW_LNCT_path and DW_LNCT_directory_index at the index "idx".
static const char *
-parse_ver5_debug_line_header(const char *p, int idx, uint8_t format, obj_info_t *obj, const char **out_path, uint64_t *out_directory_index) {
+parse_ver5_debug_line_header(const char *p, int idx, uint8_t format,
+ obj_info_t *obj, const char **out_path,
+ uint64_t *out_directory_index, FILE *errout)
+{
int i, j;
int entry_format_count = *(uint8_t *)p++;
const char *entry_format = p;
@@ -1932,17 +1996,17 @@ parse_ver5_debug_line_header(const char *p, int idx, uint8_t format, obj_info_t
int entry_count = (int)uleb128(&p);
- DebugInfoReader reader;
+ DebugInfoReader reader = {0};
debug_info_reader_init(&reader, obj);
reader.format = format;
reader.p = p;
for (j = 0; j < entry_count; j++) {
const char *format = entry_format;
for (i = 0; i < entry_format_count; i++) {
- DebugInfoValue v = {{}};
+ DebugInfoValue v = {{0}};
unsigned long dw_lnct = uleb128(&format);
unsigned long dw_form = uleb128(&format);
- debug_info_reader_read_value(&reader, dw_form, &v);
+ if (!debug_info_reader_read_value(&reader, dw_form, &v, errout)) return 0;
if (dw_lnct == 1 /* DW_LNCT_path */ && v.type == VAL_cstr && out_path)
*out_path = v.as.ptr + v.off;
if (dw_lnct == 2 /* DW_LNCT_directory_index */ && v.type == VAL_uint && out_directory_index)
@@ -1987,7 +2051,7 @@ fail:
/* read file and fill lines */
static uintptr_t
fill_lines(int num_traces, void **traces, int check_debuglink,
- obj_info_t **objp, line_info_t *lines, int offset)
+ obj_info_t **objp, line_info_t *lines, int offset, FILE *errout)
{
int i, j;
char *shstr;
@@ -2147,9 +2211,10 @@ fill_lines(int num_traces, void **traces, int check_debuglink,
debug_info_reader_init(&reader, obj);
i = 0;
while (reader.p < reader.pend) {
- /* fprintf(stderr, "%d:%tx: CU[%d]\n", __LINE__, reader.p - reader.obj->debug_info.ptr, i++); */
- if (di_read_cu(&reader)) goto use_symtab;
- debug_info_read(&reader, num_traces, traces, lines, offset);
+ /* kprintf("%d:%tx: CU[%d]\n", __LINE__, reader.p - reader.obj->debug_info.ptr, i++); */
+ if (di_read_cu(&reader, errout)) goto use_symtab;
+ if (!debug_info_read(&reader, num_traces, traces, lines, offset, errout))
+ goto use_symtab;
}
}
else {
@@ -2189,14 +2254,14 @@ use_symtab:
if (gnu_debuglink_shdr && check_debuglink) {
follow_debuglink(file + gnu_debuglink_shdr->sh_offset,
num_traces, traces,
- objp, lines, offset);
+ objp, lines, offset, errout);
}
if (note_gnu_build_id && check_debuglink) {
ElfW(Nhdr) *nhdr = (ElfW(Nhdr)*) (file + note_gnu_build_id->sh_offset);
const char *build_id = (char *)(nhdr + 1) + nhdr->n_namesz;
follow_debuglink_build_id(build_id, nhdr->n_descsz,
num_traces, traces,
- objp, lines, offset);
+ objp, lines, offset, errout);
}
goto finish;
}
@@ -2204,7 +2269,7 @@ use_symtab:
if (parse_debug_line(num_traces, traces,
obj->debug_line.ptr,
obj->debug_line.size,
- obj, lines, offset) == -1)
+ obj, lines, offset, errout) == -1)
goto fail;
finish:
@@ -2216,7 +2281,7 @@ fail:
/* read file and fill lines */
static uintptr_t
fill_lines(int num_traces, void **traces, int check_debuglink,
- obj_info_t **objp, line_info_t *lines, int offset)
+ obj_info_t **objp, line_info_t *lines, int offset, FILE *errout)
{
# ifdef __LP64__
# define LP(x) x##_64
@@ -2295,13 +2360,13 @@ fill_lines(int num_traces, void **traces, int check_debuglink,
struct fat_header *fat = (struct fat_header *)file;
char *q = file + sizeof(*fat);
uint32_t nfat_arch = __builtin_bswap32(fat->nfat_arch);
- /* fprintf(stderr,"%d: fat:%s %d\n",__LINE__, binary_filename,nfat_arch); */
+ /* kprintf("%d: fat:%s %d\n",__LINE__, binary_filename,nfat_arch); */
for (uint32_t i = 0; i < nfat_arch; i++) {
struct fat_arch *arch = (struct fat_arch *)q;
cpu_type_t cputype = __builtin_bswap32(arch->cputype);
cpu_subtype_t cpusubtype = __builtin_bswap32(arch->cpusubtype);
uint32_t offset = __builtin_bswap32(arch->offset);
- /* fprintf(stderr,"%d: fat %d %x/%x %x/%x\n",__LINE__, i, mhp->cputype,mhp->cpusubtype, cputype,cpusubtype); */
+ /* kprintf("%d: fat %d %x/%x %x/%x\n",__LINE__, i, mhp->cputype,mhp->cpusubtype, cputype,cpusubtype); */
if (mhp->cputype == cputype &&
(cpu_subtype_t)(mhp->cpusubtype & ~CPU_SUBTYPE_MASK) == cpusubtype) {
p = file + offset;
@@ -2417,15 +2482,16 @@ found_mach_header:
DebugInfoReader reader;
debug_info_reader_init(&reader, obj);
while (reader.p < reader.pend) {
- if (di_read_cu(&reader)) goto fail;
- debug_info_read(&reader, num_traces, traces, lines, offset);
+ if (di_read_cu(&reader, errout)) goto fail;
+ if (!debug_info_read(&reader, num_traces, traces, lines, offset, errout))
+ goto fail;
}
}
if (parse_debug_line(num_traces, traces,
obj->debug_line.ptr,
obj->debug_line.size,
- obj, lines, offset) == -1)
+ obj, lines, offset, errout) == -1)
goto fail;
return dladdr_fbase;
@@ -2438,7 +2504,7 @@ fail:
#if defined(__FreeBSD__) || defined(__DragonFly__)
# include <sys/sysctl.h>
#endif
-/* ssize_t main_exe_path(void)
+/* ssize_t main_exe_path(FILE *errout)
*
* store the path of the main executable to `binary_filename`,
* and returns strlen(binary_filename).
@@ -2446,7 +2512,7 @@ fail:
*/
#if defined(__linux__) || defined(__NetBSD__)
static ssize_t
-main_exe_path(void)
+main_exe_path(FILE *errout)
{
# if defined(__linux__)
# define PROC_SELF_EXE "/proc/self/exe"
@@ -2460,7 +2526,7 @@ main_exe_path(void)
}
#elif defined(__FreeBSD__) || defined(__DragonFly__)
static ssize_t
-main_exe_path(void)
+main_exe_path(FILE *errout)
{
int mib[4] = {CTL_KERN, KERN_PROC, KERN_PROC_PATHNAME, -1};
size_t len = PATH_MAX;
@@ -2474,7 +2540,7 @@ main_exe_path(void)
}
#elif defined(HAVE_LIBPROC_H)
static ssize_t
-main_exe_path(void)
+main_exe_path(FILE *errout)
{
int len = proc_pidpath(getpid(), binary_filename, PATH_MAX);
if (len == 0) return 0;
@@ -2486,7 +2552,7 @@ main_exe_path(void)
#endif
static void
-print_line0(line_info_t *line, void *address)
+print_line0(line_info_t *line, void *address, FILE *errout)
{
uintptr_t addr = (uintptr_t)address;
uintptr_t d = addr - line->saddr;
@@ -2527,16 +2593,16 @@ print_line0(line_info_t *line, void *address)
}
static void
-print_line(line_info_t *line, void *address)
+print_line(line_info_t *line, void *address, FILE *errout)
{
- print_line0(line, address);
+ print_line0(line, address, errout);
if (line->next) {
- print_line(line->next, NULL);
+ print_line(line->next, NULL, errout);
}
}
void
-rb_dump_backtrace_with_lines(int num_traces, void **traces)
+rb_dump_backtrace_with_lines(int num_traces, void **traces, FILE *errout)
{
int i;
/* async-signal unsafe */
@@ -2548,14 +2614,14 @@ rb_dump_backtrace_with_lines(int num_traces, void **traces)
#ifdef HAVE_MAIN_EXE_PATH
char *main_path = NULL; /* used on printing backtrace */
ssize_t len;
- if ((len = main_exe_path()) > 0) {
+ if ((len = main_exe_path(errout)) > 0) {
main_path = (char *)alloca(len + 1);
if (main_path) {
uintptr_t addr;
memcpy(main_path, binary_filename, len+1);
append_obj(&obj);
obj->path = main_path;
- addr = fill_lines(num_traces, traces, 1, &obj, lines, -1);
+ addr = fill_lines(num_traces, traces, 1, &obj, lines, -1, errout);
if (addr != (uintptr_t)-1) {
dladdr_fbases[0] = (void *)addr;
}
@@ -2592,7 +2658,7 @@ rb_dump_backtrace_with_lines(int num_traces, void **traces)
lines[i].saddr = (uintptr_t)info.dli_saddr;
}
strlcpy(binary_filename, path, PATH_MAX);
- if (fill_lines(num_traces, traces, 1, &obj, lines, i) == (uintptr_t)-1)
+ if (fill_lines(num_traces, traces, 1, &obj, lines, i, errout) == (uintptr_t)-1)
break;
}
next_line:
@@ -2601,7 +2667,7 @@ next_line:
/* output */
for (i = 0; i < num_traces; i++) {
- print_line(&lines[i], traces[i]);
+ print_line(&lines[i], traces[i], errout);
/* FreeBSD's backtrace may show _start and so on */
if (lines[i].sname && strcmp("main", lines[i].sname) == 0)
@@ -2635,435 +2701,8 @@ next_line:
free(dladdr_fbases);
}
-/* From FreeBSD's lib/libstand/printf.c */
-/*-
- * Copyright (c) 1986, 1988, 1991, 1993
- * The Regents of the University of California. All rights reserved.
- * (c) UNIX System Laboratories, Inc.
- * All or some portions of this file are derived from material licensed
- * to the University of California by American Telephone and Telegraph
- * Co. or Unix System Laboratories, Inc. and are reproduced herein with
- * the permission of UNIX System Laboratories, Inc.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * @(#)subr_prf.c 8.3 (Berkeley) 1/21/94
- */
-
-#include <stdarg.h>
-#define MAXNBUF (sizeof(intmax_t) * CHAR_BIT + 1)
-static inline int toupper(int c) { return ('A' <= c && c <= 'Z') ? (c&0x5f) : c; }
-#define hex2ascii(hex) (hex2ascii_data[hex])
-static const char hex2ascii_data[] = "0123456789abcdefghijklmnopqrstuvwxyz";
-static inline int imax(int a, int b) { return (a > b ? a : b); }
-static int kvprintf(char const *fmt, void (*func)(int), void *arg, int radix, va_list ap);
-
-static void putce(int c)
-{
- char s[1];
- ssize_t ret;
-
- s[0] = (char)c;
- ret = write(2, s, 1);
- (void)ret;
-}
-
-static int
-kprintf(const char *fmt, ...)
-{
- va_list ap;
- int retval;
-
- va_start(ap, fmt);
- retval = kvprintf(fmt, putce, NULL, 10, ap);
- va_end(ap);
- return retval;
-}
-
-/*
- * Put a NUL-terminated ASCII number (base <= 36) in a buffer in reverse
- * order; return an optional length and a pointer to the last character
- * written in the buffer (i.e., the first character of the string).
- * The buffer pointed to by `nbuf' must have length >= MAXNBUF.
- */
-static char *
-ksprintn(char *nbuf, uintmax_t num, int base, int *lenp, int upper)
-{
- char *p, c;
+#undef kprintf
- p = nbuf;
- *p = '\0';
- do {
- c = hex2ascii(num % base);
- *++p = upper ? toupper(c) : c;
- } while (num /= base);
- if (lenp)
- *lenp = (int)(p - nbuf);
- return (p);
-}
-
-/*
- * Scaled down version of printf(3).
- *
- * Two additional formats:
- *
- * The format %b is supported to decode error registers.
- * Its usage is:
- *
- * printf("reg=%b\n", regval, "<base><arg>*");
- *
- * where <base> is the output base expressed as a control character, e.g.
- * \10 gives octal; \20 gives hex. Each arg is a sequence of characters,
- * the first of which gives the bit number to be inspected (origin 1), and
- * the next characters (up to a control character, i.e. a character <= 32),
- * give the name of the register. Thus:
- *
- * kvprintf("reg=%b\n", 3, "\10\2BITTWO\1BITONE\n");
- *
- * would produce output:
- *
- * reg=3<BITTWO,BITONE>
- *
- * XXX: %D -- Hexdump, takes pointer and separator string:
- * ("%6D", ptr, ":") -> XX:XX:XX:XX:XX:XX
- * ("%*D", len, ptr, " " -> XX XX XX XX ...
- */
-static int
-kvprintf(char const *fmt, void (*func)(int), void *arg, int radix, va_list ap)
-{
-#define PCHAR(c) {int cc=(c); if (func) (*func)(cc); else *d++ = cc; retval++; }
- char nbuf[MAXNBUF];
- char *d;
- const char *p, *percent, *q;
- unsigned char *up;
- int ch, n;
- uintmax_t num;
- int base, lflag, qflag, tmp, width, ladjust, sharpflag, neg, sign, dot;
- int cflag, hflag, jflag, tflag, zflag;
- int dwidth, upper;
- char padc;
- int stop = 0, retval = 0;
-
- num = 0;
- if (!func)
- d = (char *) arg;
- else
- d = NULL;
-
- if (fmt == NULL)
- fmt = "(fmt null)\n";
-
- if (radix < 2 || radix > 36)
- radix = 10;
-
- for (;;) {
- padc = ' ';
- width = 0;
- while ((ch = (unsigned char)*fmt++) != '%' || stop) {
- if (ch == '\0')
- return (retval);
- PCHAR(ch);
- }
- percent = fmt - 1;
- qflag = 0; lflag = 0; ladjust = 0; sharpflag = 0; neg = 0;
- sign = 0; dot = 0; dwidth = 0; upper = 0;
- cflag = 0; hflag = 0; jflag = 0; tflag = 0; zflag = 0;
-reswitch: switch (ch = (unsigned char)*fmt++) {
- case '.':
- dot = 1;
- goto reswitch;
- case '#':
- sharpflag = 1;
- goto reswitch;
- case '+':
- sign = 1;
- goto reswitch;
- case '-':
- ladjust = 1;
- goto reswitch;
- case '%':
- PCHAR(ch);
- break;
- case '*':
- if (!dot) {
- width = va_arg(ap, int);
- if (width < 0) {
- ladjust = !ladjust;
- width = -width;
- }
- } else {
- dwidth = va_arg(ap, int);
- }
- goto reswitch;
- case '0':
- if (!dot) {
- padc = '0';
- goto reswitch;
- }
- case '1': case '2': case '3': case '4':
- case '5': case '6': case '7': case '8': case '9':
- for (n = 0;; ++fmt) {
- n = n * 10 + ch - '0';
- ch = *fmt;
- if (ch < '0' || ch > '9')
- break;
- }
- if (dot)
- dwidth = n;
- else
- width = n;
- goto reswitch;
- case 'b':
- num = (unsigned int)va_arg(ap, int);
- p = va_arg(ap, char *);
- for (q = ksprintn(nbuf, num, *p++, NULL, 0); *q;)
- PCHAR(*q--);
-
- if (num == 0)
- break;
-
- for (tmp = 0; *p;) {
- n = *p++;
- if (num & (1 << (n - 1))) {
- PCHAR(tmp ? ',' : '<');
- for (; (n = *p) > ' '; ++p)
- PCHAR(n);
- tmp = 1;
- } else
- for (; *p > ' '; ++p)
- continue;
- }
- if (tmp)
- PCHAR('>');
- break;
- case 'c':
- PCHAR(va_arg(ap, int));
- break;
- case 'D':
- up = va_arg(ap, unsigned char *);
- p = va_arg(ap, char *);
- if (!width)
- width = 16;
- while(width--) {
- PCHAR(hex2ascii(*up >> 4));
- PCHAR(hex2ascii(*up & 0x0f));
- up++;
- if (width)
- for (q=p;*q;q++)
- PCHAR(*q);
- }
- break;
- case 'd':
- case 'i':
- base = 10;
- sign = 1;
- goto handle_sign;
- case 'h':
- if (hflag) {
- hflag = 0;
- cflag = 1;
- } else
- hflag = 1;
- goto reswitch;
- case 'j':
- jflag = 1;
- goto reswitch;
- case 'l':
- if (lflag) {
- lflag = 0;
- qflag = 1;
- } else
- lflag = 1;
- goto reswitch;
- case 'n':
- if (jflag)
- *(va_arg(ap, intmax_t *)) = retval;
- else if (qflag)
- *(va_arg(ap, int64_t *)) = retval;
- else if (lflag)
- *(va_arg(ap, long *)) = retval;
- else if (zflag)
- *(va_arg(ap, size_t *)) = retval;
- else if (hflag)
- *(va_arg(ap, short *)) = retval;
- else if (cflag)
- *(va_arg(ap, char *)) = retval;
- else
- *(va_arg(ap, int *)) = retval;
- break;
- case 'o':
- base = 8;
- goto handle_nosign;
- case 'p':
- base = 16;
- sharpflag = (width == 0);
- sign = 0;
- num = (uintptr_t)va_arg(ap, void *);
- goto number;
- case 'q':
- qflag = 1;
- goto reswitch;
- case 'r':
- base = radix;
- if (sign)
- goto handle_sign;
- goto handle_nosign;
- case 's':
- p = va_arg(ap, char *);
- if (p == NULL)
- p = "(null)";
- if (!dot)
- n = (int)strlen (p);
- else
- for (n = 0; n < dwidth && p[n]; n++)
- continue;
-
- width -= n;
-
- if (!ladjust && width > 0)
- while (width--)
- PCHAR(padc);
- while (n--)
- PCHAR(*p++);
- if (ladjust && width > 0)
- while (width--)
- PCHAR(padc);
- break;
- case 't':
- tflag = 1;
- goto reswitch;
- case 'u':
- base = 10;
- goto handle_nosign;
- case 'X':
- upper = 1;
- case 'x':
- base = 16;
- goto handle_nosign;
- case 'y':
- base = 16;
- sign = 1;
- goto handle_sign;
- case 'z':
- zflag = 1;
- goto reswitch;
-handle_nosign:
- sign = 0;
- if (jflag)
- num = va_arg(ap, uintmax_t);
- else if (qflag)
- num = va_arg(ap, uint64_t);
- else if (tflag)
- num = va_arg(ap, ptrdiff_t);
- else if (lflag)
- num = va_arg(ap, unsigned long);
- else if (zflag)
- num = va_arg(ap, size_t);
- else if (hflag)
- num = (unsigned short)va_arg(ap, int);
- else if (cflag)
- num = (unsigned char)va_arg(ap, int);
- else
- num = va_arg(ap, unsigned int);
- goto number;
-handle_sign:
- if (jflag)
- num = va_arg(ap, intmax_t);
- else if (qflag)
- num = va_arg(ap, int64_t);
- else if (tflag)
- num = va_arg(ap, ptrdiff_t);
- else if (lflag)
- num = va_arg(ap, long);
- else if (zflag)
- num = va_arg(ap, ssize_t);
- else if (hflag)
- num = (short)va_arg(ap, int);
- else if (cflag)
- num = (char)va_arg(ap, int);
- else
- num = va_arg(ap, int);
-number:
- if (sign && (intmax_t)num < 0) {
- neg = 1;
- num = -(intmax_t)num;
- }
- p = ksprintn(nbuf, num, base, &n, upper);
- tmp = 0;
- if (sharpflag && num != 0) {
- if (base == 8)
- tmp++;
- else if (base == 16)
- tmp += 2;
- }
- if (neg)
- tmp++;
-
- if (!ladjust && padc == '0')
- dwidth = width - tmp;
- width -= tmp + imax(dwidth, n);
- dwidth -= n;
- if (!ladjust)
- while (width-- > 0)
- PCHAR(' ');
- if (neg)
- PCHAR('-');
- if (sharpflag && num != 0) {
- if (base == 8) {
- PCHAR('0');
- } else if (base == 16) {
- PCHAR('0');
- PCHAR('x');
- }
- }
- while (dwidth-- > 0)
- PCHAR('0');
-
- while (*p)
- PCHAR(*p--);
-
- if (ladjust)
- while (width-- > 0)
- PCHAR(' ');
-
- break;
- default:
- while (percent < fmt)
- PCHAR(*percent++);
- /*
- * Since we ignore an formatting argument it is no
- * longer safe to obey the remaining formatting
- * arguments as the arguments will no longer match
- * the format specs.
- */
- stop = 1;
- break;
- }
- }
-#undef PCHAR
-}
#else /* defined(USE_ELF) */
#error not supported
#endif
diff --git a/addr2line.h b/addr2line.h
index f09b665800..ff8e476b92 100644
--- a/addr2line.h
+++ b/addr2line.h
@@ -12,8 +12,10 @@
#if (defined(USE_ELF) || defined(HAVE_MACH_O_LOADER_H))
+#include <stdio.h>
+
void
-rb_dump_backtrace_with_lines(int num_traces, void **traces);
+rb_dump_backtrace_with_lines(int num_traces, void **traces, FILE *errout);
#endif /* USE_ELF */
diff --git a/array.c b/array.c
index 514eb5be77..d029d44b39 100644
--- a/array.c
+++ b/array.c
@@ -28,7 +28,6 @@
#include "ruby/encoding.h"
#include "ruby/st.h"
#include "ruby/util.h"
-#include "transient_heap.h"
#include "builtin.h"
#if !ARRAY_DEBUG
@@ -47,13 +46,8 @@ VALUE rb_cArray;
* 2: RARRAY_SHARED_FLAG (equal to ELTS_SHARED)
* The array is shared. The buffer this array points to is owned by
* another array (the shared root).
- * if USE_RVARGC
* 3-9: RARRAY_EMBED_LEN
* The length of the array when RARRAY_EMBED_FLAG is set.
- * else
- * 3-4: RARRAY_EMBED_LEN
- * The length of the array when RARRAY_EMBED_FLAG is set.
- * endif
* 12: RARRAY_SHARED_ROOT_FLAG
* The array is a shared root that does reference counting. The buffer
* this array points to is owned by this array but may be pointed to
@@ -63,8 +57,6 @@ VALUE rb_cArray;
* they cannot be modified. Not updating the reference count
* improves copy-on-write performance. Their reference count is
* assumed to be infinity.
- * 13: RARRAY_TRANSIENT_FLAG
- * The buffer of the array is allocated on the transient heap.
* 14: RARRAY_PTR_IN_USE_FLAG
* The buffer of the array is in use. This is only used during
* debugging.
@@ -102,7 +94,6 @@ should_be_T_ARRAY(VALUE ary)
#define FL_SET_EMBED(a) do { \
assert(!ARY_SHARED_P(a)); \
FL_SET((a), RARRAY_EMBED_FLAG); \
- RARY_TRANSIENT_UNSET(a); \
ary_verify(a); \
} while (0)
@@ -171,7 +162,6 @@ should_be_T_ARRAY(VALUE ary)
#define FL_SET_SHARED_ROOT(ary) do { \
assert(!OBJ_FROZEN(ary)); \
assert(!ARY_EMBED_P(ary)); \
- assert(!RARRAY_TRANSIENT_P(ary)); \
FL_SET((ary), RARRAY_SHARED_ROOT_FLAG); \
} while (0)
@@ -188,13 +178,9 @@ ARY_SET(VALUE a, long i, VALUE v)
static long
ary_embed_capa(VALUE ary)
{
-#if USE_RVARGC
size_t size = rb_gc_obj_slot_size(ary) - offsetof(struct RArray, as.ary);
assert(size % sizeof(VALUE) == 0);
return size / sizeof(VALUE);
-#else
- return RARRAY_EMBED_LEN_MAX;
-#endif
}
static size_t
@@ -206,11 +192,7 @@ ary_embed_size(long capa)
static bool
ary_embeddable_p(long capa)
{
-#if USE_RVARGC
return rb_gc_size_allocatable_p(ary_embed_size(capa));
-#else
- return capa <= RARRAY_EMBED_LEN_MAX;
-#endif
}
bool
@@ -256,20 +238,18 @@ ary_verify_(VALUE ary, const char *file, int line)
if (ARY_SHARED_P(ary)) {
VALUE root = ARY_SHARED_ROOT(ary);
const VALUE *ptr = ARY_HEAP_PTR(ary);
- const VALUE *root_ptr = RARRAY_CONST_PTR_TRANSIENT(root);
+ const VALUE *root_ptr = RARRAY_CONST_PTR(root);
long len = ARY_HEAP_LEN(ary), root_len = RARRAY_LEN(root);
assert(ARY_SHARED_ROOT_P(root) || OBJ_FROZEN(root));
assert(root_ptr <= ptr && ptr + len <= root_ptr + root_len);
ary_verify(root);
}
else if (ARY_EMBED_P(ary)) {
- assert(!RARRAY_TRANSIENT_P(ary));
assert(!ARY_SHARED_P(ary));
assert(RARRAY_LEN(ary) <= ary_embed_capa(ary));
}
else {
-#if 1
- const VALUE *ptr = RARRAY_CONST_PTR_TRANSIENT(ary);
+ const VALUE *ptr = RARRAY_CONST_PTR(ary);
long i, len = RARRAY_LEN(ary);
volatile VALUE v;
if (len > 1) len = 1; /* check only HEAD */
@@ -277,17 +257,8 @@ ary_verify_(VALUE ary, const char *file, int line)
v = ptr[i]; /* access check */
}
v = v;
-#endif
}
-#if USE_TRANSIENT_HEAP
- if (RARRAY_TRANSIENT_P(ary)) {
- assert(rb_transient_heap_managed_ptr_p(RARRAY_CONST_PTR_TRANSIENT(ary)));
- }
-#endif
-
- rb_transient_heap_verify();
-
return ary;
}
@@ -306,7 +277,7 @@ rb_ary_ptr_use_start(VALUE ary)
#if ARRAY_DEBUG
FL_SET_RAW(ary, RARRAY_PTR_IN_USE_FLAG);
#endif
- return (VALUE *)RARRAY_CONST_PTR_TRANSIENT(ary);
+ return (VALUE *)RARRAY_CONST_PTR(ary);
}
void
@@ -328,7 +299,7 @@ rb_mem_clear(VALUE *mem, long size)
static void
ary_mem_clear(VALUE ary, long beg, long size)
{
- RARRAY_PTR_USE_TRANSIENT(ary, ptr, {
+ RARRAY_PTR_USE(ary, ptr, {
rb_mem_clear(ptr + beg, size);
});
}
@@ -344,7 +315,7 @@ memfill(register VALUE *mem, register long size, register VALUE val)
static void
ary_memfill(VALUE ary, long beg, long size, VALUE val)
{
- RARRAY_PTR_USE_TRANSIENT(ary, ptr, {
+ RARRAY_PTR_USE(ary, ptr, {
memfill(ptr + beg, size, val);
RB_OBJ_WRITTEN(ary, Qundef, val);
});
@@ -357,13 +328,13 @@ ary_memcpy0(VALUE ary, long beg, long argc, const VALUE *argv, VALUE buff_owner_
if (argc > (int)(128/sizeof(VALUE)) /* is magic number (cache line size) */) {
rb_gc_writebarrier_remember(buff_owner_ary);
- RARRAY_PTR_USE_TRANSIENT(ary, ptr, {
+ RARRAY_PTR_USE(ary, ptr, {
MEMCPY(ptr+beg, argv, VALUE, argc);
});
}
else {
int i;
- RARRAY_PTR_USE_TRANSIENT(ary, ptr, {
+ RARRAY_PTR_USE(ary, ptr, {
for (i=0; i<argc; i++) {
RB_OBJ_WRITE(buff_owner_ary, &ptr[i+beg], argv[i]);
}
@@ -378,143 +349,46 @@ ary_memcpy(VALUE ary, long beg, long argc, const VALUE *argv)
}
static VALUE *
-ary_heap_alloc(VALUE ary, size_t capa)
+ary_heap_alloc(size_t capa)
{
- VALUE *ptr = rb_transient_heap_alloc(ary, sizeof(VALUE) * capa);
-
- if (ptr != NULL) {
- RARY_TRANSIENT_SET(ary);
- }
- else {
- RARY_TRANSIENT_UNSET(ary);
- ptr = ALLOC_N(VALUE, capa);
- }
-
- return ptr;
+ return ALLOC_N(VALUE, capa);
}
static void
ary_heap_free_ptr(VALUE ary, const VALUE *ptr, long size)
{
- if (RARRAY_TRANSIENT_P(ary)) {
- /* ignore it */
- }
- else {
- ruby_sized_xfree((void *)ptr, size);
- }
+ ruby_sized_xfree((void *)ptr, size);
}
static void
ary_heap_free(VALUE ary)
{
- if (RARRAY_TRANSIENT_P(ary)) {
- RARY_TRANSIENT_UNSET(ary);
- }
- else {
- ary_heap_free_ptr(ary, ARY_HEAP_PTR(ary), ARY_HEAP_SIZE(ary));
- }
+ ary_heap_free_ptr(ary, ARY_HEAP_PTR(ary), ARY_HEAP_SIZE(ary));
}
static size_t
ary_heap_realloc(VALUE ary, size_t new_capa)
{
- size_t alloc_capa = new_capa;
- size_t old_capa = ARY_HEAP_CAPA(ary);
-
- if (RARRAY_TRANSIENT_P(ary)) {
- if (new_capa <= old_capa) {
- /* do nothing */
- alloc_capa = old_capa;
- }
- else {
- VALUE *new_ptr = rb_transient_heap_alloc(ary, sizeof(VALUE) * new_capa);
-
- if (new_ptr == NULL) {
- new_ptr = ALLOC_N(VALUE, new_capa);
- RARY_TRANSIENT_UNSET(ary);
- }
-
- MEMCPY(new_ptr, ARY_HEAP_PTR(ary), VALUE, old_capa);
- ARY_SET_PTR(ary, new_ptr);
- }
- }
- else {
- SIZED_REALLOC_N(RARRAY(ary)->as.heap.ptr, VALUE, new_capa, old_capa);
- }
+ SIZED_REALLOC_N(RARRAY(ary)->as.heap.ptr, VALUE, new_capa, ARY_HEAP_CAPA(ary));
ary_verify(ary);
- return alloc_capa;
-}
-
-#if USE_TRANSIENT_HEAP
-static inline void
-rb_ary_transient_heap_evacuate_(VALUE ary, int transient, int promote)
-{
- if (transient) {
- assert(!ARY_SHARED_ROOT_P(ary));
-
- VALUE *new_ptr;
- const VALUE *old_ptr = ARY_HEAP_PTR(ary);
- long capa = ARY_HEAP_CAPA(ary);
-
- assert(ARY_OWNS_HEAP_P(ary));
- assert(RARRAY_TRANSIENT_P(ary));
- assert(!ARY_PTR_USING_P(ary));
-
- if (promote) {
- new_ptr = ALLOC_N(VALUE, capa);
- RARY_TRANSIENT_UNSET(ary);
- }
- else {
- new_ptr = ary_heap_alloc(ary, capa);
- }
-
- MEMCPY(new_ptr, old_ptr, VALUE, capa);
- /* do not use ARY_SET_PTR() because they assert !frozen */
- RARRAY(ary)->as.heap.ptr = new_ptr;
- }
-
- ary_verify(ary);
+ return new_capa;
}
void
-rb_ary_transient_heap_evacuate(VALUE ary, int promote)
-{
- rb_ary_transient_heap_evacuate_(ary, RARRAY_TRANSIENT_P(ary), promote);
-}
-
-void
-rb_ary_detransient(VALUE ary)
-{
- assert(RARRAY_TRANSIENT_P(ary));
- rb_ary_transient_heap_evacuate_(ary, TRUE, TRUE);
-}
-#else
-void
-rb_ary_detransient(VALUE ary)
-{
- /* do nothing */
-}
-#endif
-
-void
rb_ary_make_embedded(VALUE ary)
{
assert(rb_ary_embeddable_p(ary));
if (!ARY_EMBED_P(ary)) {
const VALUE *buf = ARY_HEAP_PTR(ary);
long len = ARY_HEAP_LEN(ary);
- bool was_transient = RARRAY_TRANSIENT_P(ary);
- // FL_SET_EMBED also unsets the transient flag
FL_SET_EMBED(ary);
ARY_SET_EMBED_LEN(ary, len);
MEMCPY((void *)ARY_EMBED_PTR(ary), (void *)buf, VALUE, len);
- if (!was_transient) {
- ary_heap_free_ptr(ary, buf, len * sizeof(VALUE));
- }
+ ary_heap_free_ptr(ary, buf, len * sizeof(VALUE));
}
}
@@ -529,7 +403,7 @@ ary_resize_capa(VALUE ary, long capacity)
size_t new_capa = capacity;
if (ARY_EMBED_P(ary)) {
long len = ARY_EMBED_LEN(ary);
- VALUE *ptr = ary_heap_alloc(ary, capacity);
+ VALUE *ptr = ary_heap_alloc(capacity);
MEMCPY(ptr, ARY_EMBED_PTR(ary), VALUE, len);
FL_UNSET_EMBED(ary);
@@ -669,18 +543,18 @@ rb_ary_cancel_sharing(VALUE ary)
ARY_SET_EMBED_LEN(ary, len);
}
else if (ARY_SHARED_ROOT_OCCUPIED(shared_root) && len > ((shared_len = RARRAY_LEN(shared_root))>>1)) {
- long shift = RARRAY_CONST_PTR_TRANSIENT(ary) - RARRAY_CONST_PTR_TRANSIENT(shared_root);
+ long shift = RARRAY_CONST_PTR(ary) - RARRAY_CONST_PTR(shared_root);
FL_UNSET_SHARED(ary);
- ARY_SET_PTR(ary, RARRAY_CONST_PTR_TRANSIENT(shared_root));
+ ARY_SET_PTR(ary, RARRAY_CONST_PTR(shared_root));
ARY_SET_CAPA(ary, shared_len);
- RARRAY_PTR_USE_TRANSIENT(ary, ptr, {
+ RARRAY_PTR_USE(ary, ptr, {
MEMMOVE(ptr, ptr+shift, VALUE, len);
});
FL_SET_EMBED(shared_root);
rb_ary_decrement_share(shared_root);
}
else {
- VALUE *ptr = ary_heap_alloc(ary, len);
+ VALUE *ptr = ary_heap_alloc(len);
MEMCPY(ptr, ARY_HEAP_PTR(ary), VALUE, len);
rb_ary_unshare(ary);
ARY_SET_CAPA(ary, len);
@@ -713,7 +587,7 @@ ary_ensure_room_for_push(VALUE ary, long add_len)
if (new_len > ary_embed_capa(ary)) {
VALUE shared_root = ARY_SHARED_ROOT(ary);
if (ARY_SHARED_ROOT_OCCUPIED(shared_root)) {
- if (ARY_HEAP_PTR(ary) - RARRAY_CONST_PTR_TRANSIENT(shared_root) + new_len <= RARRAY_LEN(shared_root)) {
+ if (ARY_HEAP_PTR(ary) - RARRAY_CONST_PTR(shared_root) + new_len <= RARRAY_LEN(shared_root)) {
rb_ary_modify_check(ary);
ary_verify(ary);
@@ -791,12 +665,9 @@ ary_alloc_embed(VALUE klass, long capa)
{
size_t size = ary_embed_size(capa);
assert(rb_gc_size_allocatable_p(size));
-#if !USE_RVARGC
- assert(size <= sizeof(struct RArray));
-#endif
- RVARGC_NEWOBJ_OF(ary, struct RArray, klass,
+ NEWOBJ_OF(ary, struct RArray, klass,
T_ARRAY | RARRAY_EMBED_FLAG | (RGENGC_WB_PROTECTED_ARRAY ? FL_WB_PROTECTED : 0),
- size);
+ size, 0);
/* Created array is:
* FL_SET_EMBED((VALUE)ary);
* ARY_SET_EMBED_LEN((VALUE)ary, 0);
@@ -807,9 +678,9 @@ ary_alloc_embed(VALUE klass, long capa)
static VALUE
ary_alloc_heap(VALUE klass)
{
- RVARGC_NEWOBJ_OF(ary, struct RArray, klass,
+ NEWOBJ_OF(ary, struct RArray, klass,
T_ARRAY | (RGENGC_WB_PROTECTED_ARRAY ? FL_WB_PROTECTED : 0),
- sizeof(struct RArray));
+ sizeof(struct RArray), 0);
return (VALUE)ary;
}
@@ -823,7 +694,7 @@ empty_ary_alloc(VALUE klass)
static VALUE
ary_new(VALUE klass, long capa)
{
- VALUE ary,*ptr;
+ VALUE ary;
if (capa < 0) {
rb_raise(rb_eArgError, "negative array size (or size too big)");
@@ -842,8 +713,7 @@ ary_new(VALUE klass, long capa)
ARY_SET_CAPA(ary, capa);
assert(!ARY_EMBED_P(ary));
- ptr = ary_heap_alloc(ary, capa);
- ARY_SET_PTR(ary, ptr);
+ ARY_SET_PTR(ary, ary_heap_alloc(capa));
ARY_SET_HEAP_LEN(ary, 0);
}
@@ -881,7 +751,7 @@ VALUE
return ary;
}
-MJIT_FUNC_EXPORTED VALUE
+VALUE
rb_ary_tmp_new_from_values(VALUE klass, long n, const VALUE *elts)
{
VALUE ary;
@@ -906,12 +776,9 @@ ec_ary_alloc_embed(rb_execution_context_t *ec, VALUE klass, long capa)
{
size_t size = ary_embed_size(capa);
assert(rb_gc_size_allocatable_p(size));
-#if !USE_RVARGC
- assert(size <= sizeof(struct RArray));
-#endif
- RB_RVARGC_EC_NEWOBJ_OF(ec, ary, struct RArray, klass,
- T_ARRAY | RARRAY_EMBED_FLAG | (RGENGC_WB_PROTECTED_ARRAY ? FL_WB_PROTECTED : 0),
- size);
+ NEWOBJ_OF(ary, struct RArray, klass,
+ T_ARRAY | RARRAY_EMBED_FLAG | (RGENGC_WB_PROTECTED_ARRAY ? FL_WB_PROTECTED : 0),
+ size, ec);
/* Created array is:
* FL_SET_EMBED((VALUE)ary);
* ARY_SET_EMBED_LEN((VALUE)ary, 0);
@@ -922,16 +789,16 @@ ec_ary_alloc_embed(rb_execution_context_t *ec, VALUE klass, long capa)
static VALUE
ec_ary_alloc_heap(rb_execution_context_t *ec, VALUE klass)
{
- RB_RVARGC_EC_NEWOBJ_OF(ec, ary, struct RArray, klass,
- T_ARRAY | (RGENGC_WB_PROTECTED_ARRAY ? FL_WB_PROTECTED : 0),
- sizeof(struct RArray));
+ NEWOBJ_OF(ary, struct RArray, klass,
+ T_ARRAY | (RGENGC_WB_PROTECTED_ARRAY ? FL_WB_PROTECTED : 0),
+ sizeof(struct RArray), ec);
return (VALUE)ary;
}
static VALUE
ec_ary_new(rb_execution_context_t *ec, VALUE klass, long capa)
{
- VALUE ary,*ptr;
+ VALUE ary;
if (capa < 0) {
rb_raise(rb_eArgError, "negative array size (or size too big)");
@@ -950,8 +817,7 @@ ec_ary_new(rb_execution_context_t *ec, VALUE klass, long capa)
ARY_SET_CAPA(ary, capa);
assert(!ARY_EMBED_P(ary));
- ptr = ary_heap_alloc(ary, capa);
- ARY_SET_PTR(ary, ptr);
+ ARY_SET_PTR(ary, ary_heap_alloc(capa));
ARY_SET_HEAP_LEN(ary, 0);
}
@@ -976,7 +842,6 @@ VALUE
rb_ary_hidden_new(long capa)
{
VALUE ary = ary_new(0, capa);
- rb_ary_transient_heap_evacuate(ary, TRUE);
return ary;
}
@@ -999,13 +864,8 @@ rb_ary_free(VALUE ary)
RB_DEBUG_COUNTER_INC(obj_ary_extracapa);
}
- if (RARRAY_TRANSIENT_P(ary)) {
- RB_DEBUG_COUNTER_INC(obj_ary_transient);
- }
- else {
- RB_DEBUG_COUNTER_INC(obj_ary_ptr);
- ary_heap_free(ary);
- }
+ RB_DEBUG_COUNTER_INC(obj_ary_ptr);
+ ary_heap_free(ary);
}
else {
RB_DEBUG_COUNTER_INC(obj_ary_embed);
@@ -1033,7 +893,6 @@ rb_ary_memsize(VALUE ary)
static VALUE
ary_make_shared(VALUE ary)
{
- assert(USE_RVARGC || !ARY_EMBED_P(ary));
ary_verify(ary);
if (ARY_SHARED_P(ary)) {
@@ -1044,14 +903,11 @@ ary_make_shared(VALUE ary)
}
else if (OBJ_FROZEN(ary)) {
if (!ARY_EMBED_P(ary)) {
- rb_ary_transient_heap_evacuate(ary, TRUE);
ary_shrink_capa(ary);
}
return ary;
}
else {
- rb_ary_transient_heap_evacuate(ary, TRUE);
-
long capa = ARY_CAPA(ary);
long len = RARRAY_LEN(ary);
@@ -1061,9 +917,7 @@ ary_make_shared(VALUE ary)
FL_SET_SHARED_ROOT(shared);
if (ARY_EMBED_P(ary)) {
- /* Cannot use ary_heap_alloc because we don't want to allocate
- * on the transient heap. */
- VALUE *ptr = ALLOC_N(VALUE, capa);
+ VALUE *ptr = ary_heap_alloc(capa);
ARY_SET_PTR(shared, ptr);
ary_memcpy(shared, 0, len, RARRAY_CONST_PTR(ary));
@@ -1095,7 +949,7 @@ ary_make_substitution(VALUE ary)
VALUE subst = rb_ary_new_capa(len);
assert(ARY_EMBED_P(subst));
- ary_memcpy(subst, 0, len, RARRAY_CONST_PTR_TRANSIENT(ary));
+ ary_memcpy(subst, 0, len, RARRAY_CONST_PTR(ary));
ARY_SET_EMBED_LEN(subst, len);
return subst;
}
@@ -1123,7 +977,7 @@ rb_check_array_type(VALUE ary)
return rb_check_convert_type_with_id(ary, T_ARRAY, "Array", idTo_ary);
}
-MJIT_FUNC_EXPORTED VALUE
+VALUE
rb_check_to_array(VALUE ary)
{
return rb_check_convert_type_with_id(ary, T_ARRAY, "Array", idTo_a);
@@ -1198,7 +1052,7 @@ rb_ary_s_new(int argc, VALUE *argv, VALUE klass)
* a.class # => Array
* a # => [:foo, "bar", 2]
*
- * With no block and a single \Integer argument +size+,
+ * With no block and a single Integer argument +size+,
* returns a new \Array of the given size
* whose elements are all +nil+:
*
@@ -1338,21 +1192,22 @@ ary_make_partial(VALUE ary, VALUE klass, long offset, long len)
assert(len >= 0);
assert(offset+len <= RARRAY_LEN(ary));
- const size_t rarray_embed_capa_max = (sizeof(struct RArray) - offsetof(struct RArray, as.ary)) / sizeof(VALUE);
-
- if ((size_t)len <= rarray_embed_capa_max && ary_embeddable_p(len)) {
- VALUE result = ary_alloc_embed(klass, len);
- ary_memcpy(result, 0, len, RARRAY_CONST_PTR_TRANSIENT(ary) + offset);
+ VALUE result = ary_alloc_heap(klass);
+ size_t embed_capa = ary_embed_capa(result);
+ if ((size_t)len <= embed_capa) {
+ FL_SET_EMBED(result);
+ ary_memcpy(result, 0, len, RARRAY_CONST_PTR(ary) + offset);
ARY_SET_EMBED_LEN(result, len);
- return result;
}
else {
VALUE shared = ary_make_shared(ary);
- VALUE result = ary_alloc_heap(klass);
- assert(!ARY_EMBED_P(result));
+ /* The ary_make_shared call may allocate, which can trigger a GC
+ * compaction. This can cause the array to be embedded because it has
+ * a length of 0. */
+ FL_UNSET_EMBED(result);
- ARY_SET_PTR(result, RARRAY_CONST_PTR_TRANSIENT(ary));
+ ARY_SET_PTR(result, RARRAY_CONST_PTR(ary));
ARY_SET_LEN(result, RARRAY_LEN(ary));
rb_ary_set_shared(result, shared);
@@ -1360,9 +1215,10 @@ ary_make_partial(VALUE ary, VALUE klass, long offset, long len)
ARY_SET_LEN(result, len);
ary_verify(shared);
- ary_verify(result);
- return result;
}
+
+ ary_verify(result);
+ return result;
}
static VALUE
@@ -1373,12 +1229,13 @@ ary_make_partial_step(VALUE ary, VALUE klass, long offset, long len, long step)
assert(offset+len <= RARRAY_LEN(ary));
assert(step != 0);
- const VALUE *values = RARRAY_CONST_PTR_TRANSIENT(ary);
const long orig_len = len;
if (step > 0 && step >= len) {
VALUE result = ary_new(klass, 1);
VALUE *ptr = (VALUE *)ARY_EMBED_PTR(result);
+ const VALUE *values = RARRAY_CONST_PTR(ary);
+
RB_OBJ_WRITE(result, ptr, values[offset]);
ARY_SET_EMBED_LEN(result, 1);
return result;
@@ -1396,6 +1253,8 @@ ary_make_partial_step(VALUE ary, VALUE klass, long offset, long len, long step)
VALUE result = ary_new(klass, len);
if (ARY_EMBED_P(result)) {
VALUE *ptr = (VALUE *)ARY_EMBED_PTR(result);
+ const VALUE *values = RARRAY_CONST_PTR(ary);
+
for (i = 0; i < len; ++i) {
RB_OBJ_WRITE(result, ptr+i, values[j]);
j += step;
@@ -1403,7 +1262,9 @@ ary_make_partial_step(VALUE ary, VALUE klass, long offset, long len, long step)
ARY_SET_EMBED_LEN(result, len);
}
else {
- RARRAY_PTR_USE_TRANSIENT(result, ptr, {
+ const VALUE *values = RARRAY_CONST_PTR(ary);
+
+ RARRAY_PTR_USE(result, ptr, {
for (i = 0; i < len; ++i) {
RB_OBJ_WRITE(result, ptr+i, values[j]);
j += step;
@@ -1428,20 +1289,11 @@ enum ary_take_pos_flags
};
static VALUE
-ary_take_first_or_last(int argc, const VALUE *argv, VALUE ary, enum ary_take_pos_flags last)
+ary_take_first_or_last_n(VALUE ary, long n, enum ary_take_pos_flags last)
{
- long n;
- long len;
+ long len = RARRAY_LEN(ary);
long offset = 0;
- argc = rb_check_arity(argc, 0, 1);
- /* the case optional argument is omitted should be handled in
- * callers of this function. if another arity case is added,
- * this arity check needs to rewrite. */
- RUBY_ASSERT_ALWAYS(argc == 1);
-
- n = NUM2LONG(argv[0]);
- len = RARRAY_LEN(ary);
if (n > len) {
n = len;
}
@@ -1454,6 +1306,17 @@ ary_take_first_or_last(int argc, const VALUE *argv, VALUE ary, enum ary_take_pos
return ary_make_partial(ary, rb_cArray, offset, n);
}
+static VALUE
+ary_take_first_or_last(int argc, const VALUE *argv, VALUE ary, enum ary_take_pos_flags last)
+{
+ argc = rb_check_arity(argc, 0, 1);
+ /* the case optional argument is omitted should be handled in
+ * callers of this function. if another arity case is added,
+ * this arity check needs to rewrite. */
+ RUBY_ASSERT_ALWAYS(argc == 1);
+ return ary_take_first_or_last_n(ary, NUM2LONG(argv[0]), last);
+}
+
/*
* call-seq:
* array << object -> self
@@ -1476,7 +1339,7 @@ rb_ary_push(VALUE ary, VALUE item)
{
long idx = RARRAY_LEN((ary_verify(ary), ary));
VALUE target_ary = ary_ensure_room_for_push(ary, 1);
- RARRAY_PTR_USE_TRANSIENT(ary, ptr, {
+ RARRAY_PTR_USE(ary, ptr, {
RB_OBJ_WRITE(target_ary, &ptr[idx], item);
});
ARY_SET_LEN(ary, idx + 1);
@@ -1511,8 +1374,6 @@ rb_ary_cat(VALUE ary, const VALUE *argv, long len)
* a1 = a.push([:baz, :bat], [:bam, :bad])
* a1 # => [:foo, "bar", 2, [:baz, :bat], [:bam, :bad]]
*
- * Array#append is an alias for Array#push.
- *
* Related: #pop, #shift, #unshift.
*/
@@ -1557,7 +1418,7 @@ rb_ary_pop(VALUE ary)
*
* Returns +nil+ if the array is empty.
*
- * When a non-negative \Integer argument +n+ is given and is in range,
+ * When a non-negative Integer argument +n+ is given and is in range,
*
* removes and returns the last +n+ elements in a new \Array:
* a = [:foo, 'bar', 2]
@@ -1621,7 +1482,7 @@ rb_ary_shift(VALUE ary)
*
* Returns +nil+ if +self+ is empty.
*
- * When positive \Integer argument +n+ is given, removes the first +n+ elements;
+ * When positive Integer argument +n+ is given, removes the first +n+ elements;
* returns those elements in a new \Array:
*
* a = [:foo, 'bar', 2]
@@ -1657,7 +1518,7 @@ rb_ary_shift_m(int argc, VALUE *argv, VALUE ary)
return result;
}
-MJIT_FUNC_EXPORTED VALUE
+VALUE
rb_ary_behead(VALUE ary, long n)
{
if (n <= 0) {
@@ -1668,7 +1529,7 @@ rb_ary_behead(VALUE ary, long n)
if (!ARY_SHARED_P(ary)) {
if (ARY_EMBED_P(ary) || RARRAY_LEN(ary) < ARY_DEFAULT_SIZE) {
- RARRAY_PTR_USE_TRANSIENT(ary, ptr, {
+ RARRAY_PTR_USE(ary, ptr, {
MEMMOVE(ptr, ptr + n, VALUE, RARRAY_LEN(ary) - n);
}); /* WB: no new reference */
ARY_INCREASE_LEN(ary, -n);
@@ -1729,12 +1590,12 @@ ary_modify_for_unshift(VALUE ary, int argc)
capa = ARY_CAPA(ary);
ary_make_shared(ary);
- head = sharedp = RARRAY_CONST_PTR_TRANSIENT(ary);
+ head = sharedp = RARRAY_CONST_PTR(ary);
return make_room_for_unshift(ary, head, (void *)sharedp, argc, capa, len);
}
else {
/* sliding items */
- RARRAY_PTR_USE_TRANSIENT(ary, ptr, {
+ RARRAY_PTR_USE(ary, ptr, {
MEMMOVE(ptr + argc, ptr, VALUE, len);
});
@@ -1766,8 +1627,8 @@ ary_ensure_room_for_unshift(VALUE ary, int argc)
return ary_modify_for_unshift(ary, argc);
}
else {
- const VALUE * head = RARRAY_CONST_PTR_TRANSIENT(ary);
- void *sharedp = (void *)RARRAY_CONST_PTR_TRANSIENT(shared_root);
+ const VALUE * head = RARRAY_CONST_PTR(ary);
+ void *sharedp = (void *)RARRAY_CONST_PTR(shared_root);
rb_ary_modify_check(ary);
return make_room_for_unshift(ary, head, sharedp, argc, capa, len);
@@ -1784,12 +1645,10 @@ ary_ensure_room_for_unshift(VALUE ary, int argc)
* a = [:foo, 'bar', 2]
* a.unshift(:bam, :bat) # => [:bam, :bat, :foo, "bar", 2]
*
- * Array#prepend is an alias for Array#unshift.
- *
* Related: #push, #pop, #shift.
*/
-static VALUE
+VALUE
rb_ary_unshift_m(int argc, VALUE *argv, VALUE ary)
{
long len = RARRAY_LEN(ary);
@@ -1809,7 +1668,7 @@ rb_ary_unshift_m(int argc, VALUE *argv, VALUE ary)
VALUE
rb_ary_unshift(VALUE ary, VALUE item)
{
- return rb_ary_unshift_m(1,&item,ary);
+ return rb_ary_unshift_m(1, &item, ary);
}
/* faster version - use this if you don't need to treat negative offset */
@@ -1873,7 +1732,7 @@ static VALUE rb_ary_aref2(VALUE ary, VALUE b, VALUE e);
*
* Returns elements from +self+; does not modify +self+.
*
- * When a single \Integer argument +index+ is given, returns the element at offset +index+:
+ * When a single Integer argument +index+ is given, returns the element at offset +index+:
*
* a = [:foo, 'bar', 2]
* a[0] # => :foo
@@ -1888,7 +1747,7 @@ static VALUE rb_ary_aref2(VALUE ary, VALUE b, VALUE e);
*
* If +index+ is out of range, returns +nil+.
*
- * When two \Integer arguments +start+ and +length+ are given,
+ * When two Integer arguments +start+ and +length+ are given,
* returns a new \Array of size +length+ containing successive elements beginning at offset +start+:
*
* a = [:foo, 'bar', 2]
@@ -1908,7 +1767,7 @@ static VALUE rb_ary_aref2(VALUE ary, VALUE b, VALUE e);
*
* If +length+ is negative, returns +nil+.
*
- * When a single \Range argument +range+ is given,
+ * When a single Range argument +range+ is given,
* treats <tt>range.min</tt> as +start+ above
* and <tt>range.size</tt> as +length+ above:
*
@@ -1962,7 +1821,6 @@ static VALUE rb_ary_aref2(VALUE ary, VALUE b, VALUE e);
* # Raises TypeError (no implicit conversion of Symbol into Integer):
* a[:foo]
*
- * Array#slice is an alias for Array#[].
*/
VALUE
@@ -1986,7 +1844,7 @@ rb_ary_aref2(VALUE ary, VALUE b, VALUE e)
return rb_ary_subseq(ary, beg, len);
}
-MJIT_FUNC_EXPORTED VALUE
+VALUE
rb_ary_aref1(VALUE ary, VALUE arg)
{
long beg, len, step;
@@ -2012,7 +1870,7 @@ rb_ary_aref1(VALUE ary, VALUE arg)
* call-seq:
* array.at(index) -> object
*
- * Returns the element at \Integer offset +index+; does not modify +self+.
+ * Returns the element at Integer offset +index+; does not modify +self+.
* a = [:foo, 'bar', 2]
* a.at(0) # => :foo
* a.at(2) # => 2
@@ -2025,39 +1883,7 @@ rb_ary_at(VALUE ary, VALUE pos)
return rb_ary_entry(ary, NUM2LONG(pos));
}
-/*
- * call-seq:
- * array.first -> object or nil
- * array.first(n) -> new_array
- *
- * Returns elements from +self+; does not modify +self+.
- *
- * When no argument is given, returns the first element:
- *
- * a = [:foo, 'bar', 2]
- * a.first # => :foo
- * a # => [:foo, "bar", 2]
- *
- * If +self+ is empty, returns +nil+.
- *
- * When non-negative \Integer argument +n+ is given,
- * returns the first +n+ elements in a new \Array:
- *
- * a = [:foo, 'bar', 2]
- * a.first(2) # => [:foo, "bar"]
- *
- * If <tt>n >= array.size</tt>, returns all elements:
- *
- * a = [:foo, 'bar', 2]
- * a.first(50) # => [:foo, "bar", 2]
- *
- * If <tt>n == 0</tt> returns an new empty \Array:
- *
- * a = [:foo, 'bar', 2]
- * a.first(0) # []
- *
- * Related: #last.
- */
+#if 0
static VALUE
rb_ary_first(int argc, VALUE *argv, VALUE ary)
{
@@ -2069,48 +1895,26 @@ rb_ary_first(int argc, VALUE *argv, VALUE ary)
return ary_take_first_or_last(argc, argv, ary, ARY_TAKE_FIRST);
}
}
+#endif
-/*
- * call-seq:
- * array.last -> object or nil
- * array.last(n) -> new_array
- *
- * Returns elements from +self+; +self+ is not modified.
- *
- * When no argument is given, returns the last element:
- *
- * a = [:foo, 'bar', 2]
- * a.last # => 2
- * a # => [:foo, "bar", 2]
- *
- * If +self+ is empty, returns +nil+.
- *
- * When non-negative \Integer argument +n+ is given,
- * returns the last +n+ elements in a new \Array:
- *
- * a = [:foo, 'bar', 2]
- * a.last(2) # => ["bar", 2]
- *
- * If <tt>n >= array.size</tt>, returns all elements:
- *
- * a = [:foo, 'bar', 2]
- * a.last(50) # => [:foo, "bar", 2]
- *
- * If <tt>n == 0</tt>, returns an new empty \Array:
- *
- * a = [:foo, 'bar', 2]
- * a.last(0) # []
- *
- * Related: #first.
- */
+static VALUE
+ary_first(VALUE self)
+{
+ return (RARRAY_LEN(self) == 0) ? Qnil : RARRAY_AREF(self, 0);
+}
+
+static VALUE
+ary_last(VALUE self)
+{
+ long len = RARRAY_LEN(self);
+ return (len == 0) ? Qnil : RARRAY_AREF(self, len-1);
+}
VALUE
-rb_ary_last(int argc, const VALUE *argv, VALUE ary)
+rb_ary_last(int argc, const VALUE *argv, VALUE ary) // used by parse.y
{
if (argc == 0) {
- long len = RARRAY_LEN(ary);
- if (len == 0) return Qnil;
- return RARRAY_AREF(ary, len-1);
+ return ary_last(ary);
}
else {
return ary_take_first_or_last(argc, argv, ary, ARY_TAKE_LAST);
@@ -2125,7 +1929,7 @@ rb_ary_last(int argc, const VALUE *argv, VALUE ary)
*
* Returns the element at offset +index+.
*
- * With the single \Integer argument +index+,
+ * With the single Integer argument +index+,
* returns the element at offset +index+:
*
* a = [:foo, 'bar', 2]
@@ -2215,8 +2019,6 @@ rb_ary_fetch(int argc, VALUE *argv, VALUE ary)
* e # => #<Enumerator: [:foo, "bar", 2]:index>
* e.each {|element| element == 'bar' } # => 1
*
- * Array#find_index is an alias for Array#index.
- *
* Related: #rindex.
*/
@@ -2271,7 +2073,7 @@ rb_ary_index(int argc, VALUE *argv, VALUE ary)
*
* Returns +nil+ if the block never returns a truthy value.
*
- * When neither an argument nor a block is given, returns a new \Enumerator:
+ * When neither an argument nor a block is given, returns a new Enumerator:
*
* a = [:foo, 'bar', 2, 'bar']
* e = a.rindex
@@ -2343,7 +2145,7 @@ rb_ary_splice(VALUE ary, long beg, long len, const VALUE *rptr, long rlen)
}
{
- const VALUE *optr = RARRAY_CONST_PTR_TRANSIENT(ary);
+ const VALUE *optr = RARRAY_CONST_PTR(ary);
rofs = (rptr >= optr && rptr < optr + olen) ? rptr - optr : -1;
}
@@ -2356,7 +2158,7 @@ rb_ary_splice(VALUE ary, long beg, long len, const VALUE *rptr, long rlen)
len = beg + rlen;
ary_mem_clear(ary, olen, beg - olen);
if (rlen > 0) {
- if (rofs != -1) rptr = RARRAY_CONST_PTR_TRANSIENT(ary) + rofs;
+ if (rofs != -1) rptr = RARRAY_CONST_PTR(ary) + rofs;
ary_memcpy0(ary, beg, rlen, rptr, target_ary);
}
ARY_SET_LEN(ary, len);
@@ -2374,20 +2176,25 @@ rb_ary_splice(VALUE ary, long beg, long len, const VALUE *rptr, long rlen)
}
if (len != rlen) {
- RARRAY_PTR_USE_TRANSIENT(ary, ptr,
+ RARRAY_PTR_USE(ary, ptr,
MEMMOVE(ptr + beg + rlen, ptr + beg + len,
VALUE, olen - (beg + len)));
ARY_SET_LEN(ary, alen);
}
if (rlen > 0) {
- if (rofs != -1) rptr = RARRAY_CONST_PTR_TRANSIENT(ary) + rofs;
- /* give up wb-protected ary */
- RB_OBJ_WB_UNPROTECT_FOR(ARRAY, ary);
+ if (rofs == -1) {
+ rb_gc_writebarrier_remember(ary);
+ }
+ else {
+ /* In this case, we're copying from a region in this array, so
+ * we don't need to fire the write barrier. */
+ rptr = RARRAY_CONST_PTR(ary) + rofs;
+ }
/* do not use RARRAY_PTR() because it can causes GC.
* ary can contain T_NONE object because it is not cleared.
*/
- RARRAY_PTR_USE_TRANSIENT(ary, ptr,
+ RARRAY_PTR_USE(ary, ptr,
MEMMOVE(ptr + beg, rptr, VALUE, rlen));
}
}
@@ -2432,9 +2239,8 @@ rb_ary_resize(VALUE ary, long len)
else if (len <= ary_embed_capa(ary)) {
const VALUE *ptr = ARY_HEAP_PTR(ary);
long ptr_capa = ARY_HEAP_SIZE(ary);
- bool is_malloc_ptr = !ARY_SHARED_P(ary) && !RARRAY_TRANSIENT_P(ary);
+ bool is_malloc_ptr = !ARY_SHARED_P(ary);
- FL_UNSET(ary, RARRAY_TRANSIENT_FLAG);
FL_SET_EMBED(ary);
MEMCPY((VALUE *)ARY_EMBED_PTR(ary), ptr, VALUE, len); /* WB: no new reference */
@@ -2464,7 +2270,7 @@ static VALUE
ary_aset_by_rb_ary_splice(VALUE ary, long beg, long len, VALUE val)
{
VALUE rpl = rb_ary_to_ary(val);
- rb_ary_splice(ary, beg, len, RARRAY_CONST_PTR_TRANSIENT(rpl), RARRAY_LEN(rpl));
+ rb_ary_splice(ary, beg, len, RARRAY_CONST_PTR(rpl), RARRAY_LEN(rpl));
RB_GC_GUARD(rpl);
return val;
}
@@ -2477,7 +2283,7 @@ ary_aset_by_rb_ary_splice(VALUE ary, long beg, long len, VALUE val)
*
* Assigns elements in +self+; returns the given +object+.
*
- * When \Integer argument +index+ is given, assigns +object+ to an element in +self+.
+ * When Integer argument +index+ is given, assigns +object+ to an element in +self+.
*
* If +index+ is non-negative, assigns +object+ the element at offset +index+:
*
@@ -2497,7 +2303,7 @@ ary_aset_by_rb_ary_splice(VALUE ary, long beg, long len, VALUE val)
* a[-1] = 'two' # => "two"
* a # => [:foo, "bar", "two"]
*
- * When \Integer arguments +start+ and +length+ are given and +object+ is not an \Array,
+ * When Integer arguments +start+ and +length+ are given and +object+ is not an \Array,
* removes <tt>length - 1</tt> elements beginning at offset +start+,
* and assigns +object+ at offset +start+:
*
@@ -2532,7 +2338,7 @@ ary_aset_by_rb_ary_splice(VALUE ary, long beg, long len, VALUE val)
* a[1, 5] = 'foo' # => "foo"
* a # => [:foo, "foo"]
*
- * When \Range argument +range+ is given and +object+ is an \Array,
+ * When Range argument +range+ is given and +object+ is an \Array,
* removes <tt>length - 1</tt> elements beginning at offset +start+,
* and assigns +object+ at offset +start+:
*
@@ -2612,7 +2418,7 @@ rb_ary_aset(int argc, VALUE *argv, VALUE ary)
* call-seq:
* array.insert(index, *objects) -> self
*
- * Inserts given +objects+ before or after the element at \Integer index +offset+;
+ * Inserts given +objects+ before or after the element at Integer index +offset+;
* returns +self+.
*
* When +index+ is non-negative, inserts all given +objects+
@@ -2706,7 +2512,7 @@ ary_enum_length(VALUE ary, VALUE args, VALUE eobj)
* foo
* bar
*
- * When no block given, returns a new \Enumerator:
+ * When no block given, returns a new Enumerator:
* a = [:foo, 'bar', 2]
*
* e = a.each
@@ -2763,7 +2569,7 @@ rb_ary_each(VALUE ary)
* 0
* 1
*
- * When no block given, returns a new \Enumerator:
+ * When no block given, returns a new Enumerator:
*
* a = [:foo, 'bar', 2]
* e = a.each_index
@@ -2820,7 +2626,7 @@ rb_ary_each_index(VALUE ary)
* 2
* bar
*
- * When no block given, returns a new \Enumerator:
+ * When no block given, returns a new Enumerator:
*
* a = [:foo, 'bar', 2]
* e = a.reverse_each
@@ -2887,7 +2693,7 @@ rb_ary_dup(VALUE ary)
{
long len = RARRAY_LEN(ary);
VALUE dup = rb_ary_new2(len);
- ary_memcpy(dup, 0, len, RARRAY_CONST_PTR_TRANSIENT(ary));
+ ary_memcpy(dup, 0, len, RARRAY_CONST_PTR(ary));
ARY_SET_LEN(dup, len);
ary_verify(ary);
@@ -3040,7 +2846,7 @@ rb_ary_join(VALUE ary, VALUE sep)
* array.join ->new_string
* array.join(separator = $,) -> new_string
*
- * Returns the new \String formed by joining the array elements after conversion.
+ * Returns the new String formed by joining the array elements after conversion.
* For each element +element+:
*
* - Uses <tt>element.to_s</tt> if +element+ is not a <tt>kind_of?(Array)</tt>.
@@ -3100,13 +2906,12 @@ inspect_ary(VALUE ary, VALUE dummy, int recur)
* call-seq:
* array.inspect -> new_string
*
- * Returns the new \String formed by calling method <tt>#inspect</tt>
+ * Returns the new String formed by calling method <tt>#inspect</tt>
* on each array element:
*
* a = [:foo, 'bar', 2]
* a.inspect # => "[:foo, \"bar\", 2]"
*
- * Array#to_s is an alias for Array#inspect.
*/
static VALUE
@@ -3159,18 +2964,18 @@ rb_ary_to_a(VALUE ary)
* array.to_h -> new_hash
* array.to_h {|item| ... } -> new_hash
*
- * Returns a new \Hash formed from +self+.
+ * Returns a new Hash formed from +self+.
*
* When a block is given, calls the block with each array element;
* the block must return a 2-element \Array whose two elements
- * form a key-value pair in the returned \Hash:
+ * form a key-value pair in the returned Hash:
*
* a = ['foo', :bar, 1, [2, 3], {baz: 4}]
* h = a.to_h {|item| [item, item] }
* h # => {"foo"=>"foo", :bar=>:bar, 1=>1, [2, 3]=>[2, 3], {:baz=>4}=>{:baz=>4}}
*
* When no block is given, +self+ must be an \Array of 2-element sub-arrays,
- * each sub-array is formed into a key-value pair in the new \Hash:
+ * each sub-array is formed into a key-value pair in the new Hash:
*
* [].to_h # => {}
* a = [['foo', 'zero'], ['bar', 'one'], ['baz', 'two']]
@@ -3234,7 +3039,7 @@ rb_ary_reverse(VALUE ary)
rb_ary_modify(ary);
if (len > 1) {
- RARRAY_PTR_USE_TRANSIENT(ary, p1, {
+ RARRAY_PTR_USE(ary, p1, {
p2 = p1 + len - 1; /* points last item */
ary_reverse(p1, p2);
}); /* WB: no new reference */
@@ -3278,8 +3083,8 @@ rb_ary_reverse_m(VALUE ary)
VALUE dup = rb_ary_new2(len);
if (len > 0) {
- const VALUE *p1 = RARRAY_CONST_PTR_TRANSIENT(ary);
- VALUE *p2 = (VALUE *)RARRAY_CONST_PTR_TRANSIENT(dup) + len - 1;
+ const VALUE *p1 = RARRAY_CONST_PTR(ary);
+ VALUE *p2 = (VALUE *)RARRAY_CONST_PTR(dup) + len - 1;
do *p2-- = *p1++; while (--len > 0);
}
ARY_SET_LEN(dup, RARRAY_LEN(ary));
@@ -3321,7 +3126,7 @@ rb_ary_rotate(VALUE ary, long cnt)
if (cnt != 0) {
long len = RARRAY_LEN(ary);
if (len > 1 && (cnt = rotate_count(cnt, len)) > 0) {
- RARRAY_PTR_USE_TRANSIENT(ary, ptr, ary_rotate_ptr(ptr, len, cnt));
+ RARRAY_PTR_USE(ary, ptr, ary_rotate_ptr(ptr, len, cnt));
return ary;
}
}
@@ -3340,7 +3145,7 @@ rb_ary_rotate(VALUE ary, long cnt)
* a = [:foo, 'bar', 2, 'bar']
* a.rotate! # => ["bar", 2, "bar", :foo]
*
- * When given a non-negative \Integer +count+,
+ * When given a non-negative Integer +count+,
* rotates +count+ elements from the beginning to the end:
*
* a = [:foo, 'bar', 2]
@@ -3397,7 +3202,7 @@ rb_ary_rotate_bang(int argc, VALUE *argv, VALUE ary)
* a1 = a.rotate
* a1 # => ["bar", 2, "bar", :foo]
*
- * When given a non-negative \Integer +count+,
+ * When given a non-negative Integer +count+,
* returns a new \Array with +count+ elements rotated from the beginning to the end:
*
* a = [:foo, 'bar', 2]
@@ -3416,7 +3221,7 @@ rb_ary_rotate_bang(int argc, VALUE *argv, VALUE ary)
* a1 = a.rotate(0)
* a1 # => [:foo, "bar", 2]
*
- * When given a negative \Integer +count+, rotates in the opposite direction,
+ * When given a negative Integer +count+, rotates in the opposite direction,
* from end to beginning:
*
* a = [:foo, 'bar', 2]
@@ -3443,7 +3248,7 @@ rb_ary_rotate_m(int argc, VALUE *argv, VALUE ary)
rotated = rb_ary_new2(len);
if (len > 0) {
cnt = rotate_count(cnt, len);
- ptr = RARRAY_CONST_PTR_TRANSIENT(ary);
+ ptr = RARRAY_CONST_PTR(ary);
len -= cnt;
ary_memcpy(rotated, 0, len, ptr + cnt);
ary_memcpy(rotated, len, cnt, ptr);
@@ -3728,8 +3533,8 @@ rb_ary_bsearch_index(VALUE ary)
const VALUE zero = INT2FIX(0);
switch (rb_cmpint(rb_funcallv(v, id_cmp, 1, &zero), v, zero)) {
case 0: return INT2FIX(mid);
- case 1: smaller = 1; break;
- case -1: smaller = 0;
+ case 1: smaller = 0; break;
+ case -1: smaller = 1;
}
}
else {
@@ -3774,7 +3579,7 @@ sort_by_i(RB_BLOCK_CALL_FUNC_ARGLIST(i, dummy))
* a.sort_by! {|element| element.size }
* a # => ["d", "cc", "bbb", "aaaa"]
*
- * Returns a new \Enumerator if no block given:
+ * Returns a new Enumerator if no block given:
*
* a = ['aaaa', 'bbb', 'cc', 'd']
* a.sort_by! # => #<Enumerator: ["aaaa", "bbb", "cc", "d"]:sort_by!>
@@ -3806,12 +3611,11 @@ rb_ary_sort_by_bang(VALUE ary)
* a1 = a.map {|element| element.class }
* a1 # => [Symbol, String, Integer]
*
- * Returns a new \Enumerator if no block given:
+ * Returns a new Enumerator if no block given:
* a = [:foo, 'bar', 2]
* a1 = a.map
* a1 # => #<Enumerator: [:foo, "bar", 2]:map>
*
- * Array#collect is an alias for Array#map.
*/
static VALUE
@@ -3840,13 +3644,12 @@ rb_ary_collect(VALUE ary)
* a = [:foo, 'bar', 2]
* a.map! { |element| element.class } # => [Symbol, String, Integer]
*
- * Returns a new \Enumerator if no block given:
+ * Returns a new Enumerator if no block given:
*
* a = [:foo, 'bar', 2]
* a1 = a.map!
* a1 # => #<Enumerator: [:foo, "bar", 2]:map!>
*
- * Array#collect! is an alias for Array#map!.
*/
static VALUE
@@ -3898,7 +3701,7 @@ append_values_at_single(VALUE result, VALUE ary, long olen, VALUE idx)
/* check if idx is Range */
else if (rb_range_beg_len(idx, &beg, &len, olen, 1)) {
if (len > 0) {
- const VALUE *const src = RARRAY_CONST_PTR_TRANSIENT(ary);
+ const VALUE *const src = RARRAY_CONST_PTR(ary);
const long end = beg + len;
const long prevlen = RARRAY_LEN(result);
if (beg < olen) {
@@ -3921,7 +3724,7 @@ append_values_at_single(VALUE result, VALUE ary, long olen, VALUE idx)
* array.values_at(*indexes) -> new_array
*
* Returns a new \Array whose elements are the elements
- * of +self+ at the given \Integer or \Range +indexes+.
+ * of +self+ at the given Integer or Range +indexes+.
*
* For each positive +index+, returns the element at offset +index+:
*
@@ -3985,12 +3788,11 @@ rb_ary_values_at(int argc, VALUE *argv, VALUE ary)
* a1 = a.select {|element| element.to_s.start_with?('b') }
* a1 # => ["bar", :bam]
*
- * Returns a new \Enumerator if no block given:
+ * Returns a new Enumerator if no block given:
*
* a = [:foo, 'bar', 2, :bam]
* a.select # => #<Enumerator: [:foo, "bar", 2, :bam]:select>
*
- * Array#filter is an alias for Array#select.
*/
static VALUE
@@ -4045,7 +3847,7 @@ select_bang_ensure(VALUE a)
rb_ary_modify(ary);
if (i1 < len) {
tail = len - i1;
- RARRAY_PTR_USE_TRANSIENT(ary, ptr, {
+ RARRAY_PTR_USE(ary, ptr, {
MEMMOVE(ptr + i2, ptr + i1, VALUE, tail);
});
}
@@ -4069,12 +3871,11 @@ select_bang_ensure(VALUE a)
*
* Returns +nil+ if no elements were removed.
*
- * Returns a new \Enumerator if no block given:
+ * Returns a new Enumerator if no block given:
*
* a = [:foo, 'bar', 2, :bam]
* a.select! # => #<Enumerator: [:foo, "bar", 2, :bam]:select!>
*
- * Array#filter! is an alias for Array#select!.
*/
static VALUE
@@ -4101,7 +3902,7 @@ rb_ary_select_bang(VALUE ary)
* a = [:foo, 'bar', 2, :bam]
* a.keep_if {|element| element.to_s.start_with?('b') } # => ["bar", :bam]
*
- * Returns a new \Enumerator if no block given:
+ * Returns a new Enumerator if no block given:
*
* a = [:foo, 'bar', 2, :bam]
* a.keep_if # => #<Enumerator: [:foo, "bar", 2, :bam]:keep_if>
@@ -4233,7 +4034,7 @@ rb_ary_delete_at(VALUE ary, long pos)
rb_ary_modify(ary);
del = RARRAY_AREF(ary, pos);
- RARRAY_PTR_USE_TRANSIENT(ary, ptr, {
+ RARRAY_PTR_USE(ary, ptr, {
MEMMOVE(ptr+pos, ptr+pos+1, VALUE, len-pos-1);
});
ARY_INCREASE_LEN(ary, -1);
@@ -4245,7 +4046,7 @@ rb_ary_delete_at(VALUE ary, long pos)
* call-seq:
* array.delete_at(index) -> deleted_object or nil
*
- * Deletes an element from +self+, per the given \Integer +index+.
+ * Deletes an element from +self+, per the given Integer +index+.
*
* When +index+ is non-negative, deletes the element at offset +index+:
*
@@ -4294,7 +4095,7 @@ ary_slice_bang_by_rb_ary_splice(VALUE ary, long pos, long len)
return rb_ary_new2(0);
}
else {
- VALUE arg2 = rb_ary_new4(len, RARRAY_CONST_PTR_TRANSIENT(ary)+pos);
+ VALUE arg2 = rb_ary_new4(len, RARRAY_CONST_PTR(ary)+pos);
rb_ary_splice(ary, pos, len, 0, 0);
return arg2;
}
@@ -4308,7 +4109,7 @@ ary_slice_bang_by_rb_ary_splice(VALUE ary, long pos, long len)
*
* Removes and returns elements from +self+.
*
- * When the only argument is an \Integer +n+,
+ * When the only argument is an Integer +n+,
* removes and returns the _nth_ element in +self+:
*
* a = [:foo, 'bar', 2]
@@ -4343,7 +4144,7 @@ ary_slice_bang_by_rb_ary_splice(VALUE ary, long pos, long len)
*
* If +length+ is negative, returns +nil+.
*
- * When the only argument is a \Range object +range+,
+ * When the only argument is a Range object +range+,
* treats <tt>range.min</tt> as +start+ above and <tt>range.size</tt> as +length+ above:
*
* a = [:foo, 'bar', 2]
@@ -4459,7 +4260,7 @@ ary_reject_bang(VALUE ary)
*
* Returns +nil+ if no elements removed.
*
- * Returns a new \Enumerator if no block given:
+ * Returns a new Enumerator if no block given:
*
* a = [:foo, 'bar', 2]
* a.reject! # => #<Enumerator: [:foo, "bar", 2]:reject!>
@@ -4486,7 +4287,7 @@ rb_ary_reject_bang(VALUE ary)
* a1 = a.reject {|element| element.to_s.start_with?('b') }
* a1 # => [:foo, 2]
*
- * Returns a new \Enumerator if no block given:
+ * Returns a new Enumerator if no block given:
*
* a = [:foo, 'bar', 2]
* a.reject # => #<Enumerator: [:foo, "bar", 2]:reject>
@@ -4515,12 +4316,12 @@ rb_ary_reject(VALUE ary)
* a = [:foo, 'bar', 2, 'bat']
* a.delete_if {|element| element.to_s.start_with?('b') } # => [:foo, 2]
*
- * Returns a new \Enumerator if no block given:
+ * Returns a new Enumerator if no block given:
*
* a = [:foo, 'bar', 2]
* a.delete_if # => #<Enumerator: [:foo, "bar", 2]:delete_if>
*
-3 */
+ */
static VALUE
rb_ary_delete_if(VALUE ary)
@@ -4735,15 +4536,14 @@ rb_ary_replace(VALUE copy, VALUE orig)
/* orig has enough space to embed the contents of orig. */
if (RARRAY_LEN(orig) <= ary_embed_capa(copy)) {
assert(ARY_EMBED_P(copy));
- ary_memcpy(copy, 0, RARRAY_LEN(orig), RARRAY_CONST_PTR_TRANSIENT(orig));
+ ary_memcpy(copy, 0, RARRAY_LEN(orig), RARRAY_CONST_PTR(orig));
ARY_SET_EMBED_LEN(copy, RARRAY_LEN(orig));
}
-#if USE_RVARGC
/* orig is embedded but copy does not have enough space to embed the
* contents of orig. */
else if (ARY_EMBED_P(orig)) {
long len = ARY_EMBED_LEN(orig);
- VALUE *ptr = ary_heap_alloc(copy, len);
+ VALUE *ptr = ary_heap_alloc(len);
FL_UNSET_EMBED(copy);
ARY_SET_PTR(copy, ptr);
@@ -4752,9 +4552,8 @@ rb_ary_replace(VALUE copy, VALUE orig)
// No allocation and exception expected that could leave `copy` in a
// bad state from the edits above.
- ary_memcpy(copy, 0, len, RARRAY_CONST_PTR_TRANSIENT(orig));
+ ary_memcpy(copy, 0, len, RARRAY_CONST_PTR(orig));
}
-#endif
/* Otherwise, orig is on heap and copy does not have enough space to embed
* the contents of orig. */
else {
@@ -4819,7 +4618,7 @@ rb_ary_clear(VALUE ary)
* a # => ["a", "b", "c", "d"]
* a.fill(:X) # => [:X, :X, :X, :X]
*
- * With arguments +obj+ and \Integer +start+, and no block given,
+ * With arguments +obj+ and Integer +start+, and no block given,
* replaces elements based on the given start.
*
* If +start+ is in range (<tt>0 <= start < array.size</tt>),
@@ -4847,7 +4646,7 @@ rb_ary_clear(VALUE ary)
* a = ['a', 'b', 'c', 'd']
* a.fill(:X, -50) # => [:X, :X, :X, :X]
*
- * With arguments +obj+, \Integer +start+, and \Integer +length+, and no block given,
+ * With arguments +obj+, Integer +start+, and Integer +length+, and no block given,
* replaces elements based on the given +start+ and +length+.
*
* If +start+ is in range, replaces +length+ elements beginning at offset +start+:
@@ -4873,7 +4672,7 @@ rb_ary_clear(VALUE ary)
* a.fill(:X, 1, 0) # => ["a", "b", "c", "d"]
* a.fill(:X, 1, -1) # => ["a", "b", "c", "d"]
*
- * With arguments +obj+ and \Range +range+, and no block given,
+ * With arguments +obj+ and Range +range+, and no block given,
* replaces elements based on the given range.
*
* If the range is positive and ascending (<tt>0 < range.begin <= range.end</tt>),
@@ -5085,8 +4884,8 @@ rb_ary_plus(VALUE x, VALUE y)
len = xlen + ylen;
z = rb_ary_new2(len);
- ary_memcpy(z, 0, xlen, RARRAY_CONST_PTR_TRANSIENT(x));
- ary_memcpy(z, xlen, ylen, RARRAY_CONST_PTR_TRANSIENT(y));
+ ary_memcpy(z, 0, xlen, RARRAY_CONST_PTR(x));
+ ary_memcpy(z, xlen, ylen, RARRAY_CONST_PTR(y));
ARY_SET_LEN(z, len);
return z;
}
@@ -5096,7 +4895,7 @@ ary_append(VALUE x, VALUE y)
{
long n = RARRAY_LEN(y);
if (n > 0) {
- rb_ary_splice(x, RARRAY_LEN(x), 0, RARRAY_CONST_PTR_TRANSIENT(y), n);
+ rb_ary_splice(x, RARRAY_LEN(x), 0, RARRAY_CONST_PTR(y), n);
}
RB_GC_GUARD(y);
return x;
@@ -5144,13 +4943,13 @@ rb_ary_concat(VALUE x, VALUE y)
* array * n -> new_array
* array * string_separator -> new_string
*
- * When non-negative argument \Integer +n+ is given,
+ * When non-negative argument Integer +n+ is given,
* returns a new \Array built by concatenating the +n+ copies of +self+:
*
* a = ['x', 'y']
* a * 3 # => ["x", "y", "x", "y", "x", "y"]
*
- * When \String argument +string_separator+ is given,
+ * When String argument +string_separator+ is given,
* equivalent to <tt>array.join(string_separator)</tt>:
*
* [0, [0, 1], {foo: 0}] * ', ' # => "0, 0, 1, {:foo=>0}"
@@ -5185,16 +4984,16 @@ rb_ary_times(VALUE ary, VALUE times)
ary2 = ary_new(rb_cArray, len);
ARY_SET_LEN(ary2, len);
- ptr = RARRAY_CONST_PTR_TRANSIENT(ary);
+ ptr = RARRAY_CONST_PTR(ary);
t = RARRAY_LEN(ary);
if (0 < t) {
ary_memcpy(ary2, 0, t, ptr);
while (t <= len/2) {
- ary_memcpy(ary2, t, t, RARRAY_CONST_PTR_TRANSIENT(ary2));
+ ary_memcpy(ary2, t, t, RARRAY_CONST_PTR(ary2));
t *= 2;
}
if (t < len) {
- ary_memcpy(ary2, t, len-t, RARRAY_CONST_PTR_TRANSIENT(ary2));
+ ary_memcpy(ary2, t, len-t, RARRAY_CONST_PTR(ary2));
}
}
out:
@@ -5253,7 +5052,7 @@ rb_ary_rassoc(VALUE ary, VALUE value)
VALUE v;
for (i = 0; i < RARRAY_LEN(ary); ++i) {
- v = RARRAY_AREF(ary, i);
+ v = rb_check_array_type(RARRAY_AREF(ary, i));
if (RB_TYPE_P(v, T_ARRAY) &&
RARRAY_LEN(v) > 1 &&
rb_equal(RARRAY_AREF(v, 1), value))
@@ -5325,7 +5124,7 @@ rb_ary_equal(VALUE ary1, VALUE ary2)
return rb_equal(ary2, ary1);
}
if (RARRAY_LEN(ary1) != RARRAY_LEN(ary2)) return Qfalse;
- if (RARRAY_CONST_PTR_TRANSIENT(ary1) == RARRAY_CONST_PTR_TRANSIENT(ary2)) return Qtrue;
+ if (RARRAY_CONST_PTR(ary1) == RARRAY_CONST_PTR(ary2)) return Qtrue;
return rb_exec_recursive_paired(recursive_equal, ary1, ary2, ary2);
}
@@ -5365,10 +5164,27 @@ rb_ary_eql(VALUE ary1, VALUE ary2)
if (ary1 == ary2) return Qtrue;
if (!RB_TYPE_P(ary2, T_ARRAY)) return Qfalse;
if (RARRAY_LEN(ary1) != RARRAY_LEN(ary2)) return Qfalse;
- if (RARRAY_CONST_PTR_TRANSIENT(ary1) == RARRAY_CONST_PTR_TRANSIENT(ary2)) return Qtrue;
+ if (RARRAY_CONST_PTR(ary1) == RARRAY_CONST_PTR(ary2)) return Qtrue;
return rb_exec_recursive_paired(recursive_eql, ary1, ary2, ary2);
}
+VALUE
+rb_ary_hash_values(long len, const VALUE *elements)
+{
+ long i;
+ st_index_t h;
+ VALUE n;
+
+ h = rb_hash_start(len);
+ h = rb_hash_uint(h, (st_index_t)rb_ary_hash_values);
+ for (i=0; i<len; i++) {
+ n = rb_hash(elements[i]);
+ h = rb_hash_uint(h, NUM2LONG(n));
+ }
+ h = rb_hash_end(h);
+ return ST2FIX(h);
+}
+
/*
* call-seq:
* array.hash -> integer
@@ -5385,18 +5201,7 @@ rb_ary_eql(VALUE ary1, VALUE ary2)
static VALUE
rb_ary_hash(VALUE ary)
{
- long i;
- st_index_t h;
- VALUE n;
-
- h = rb_hash_start(RARRAY_LEN(ary));
- h = rb_hash_uint(h, (st_index_t)rb_ary_hash);
- for (i=0; i<RARRAY_LEN(ary); i++) {
- n = rb_hash(RARRAY_AREF(ary, i));
- h = rb_hash_uint(h, NUM2LONG(n));
- }
- h = rb_hash_end(h);
- return ST2FIX(h);
+ return rb_ary_hash_values(RARRAY_LEN(ary), RARRAY_CONST_PTR(ary));
}
/*
@@ -5660,7 +5465,8 @@ rb_ary_difference_multi(int argc, VALUE *argv, VALUE ary)
* array & other_array -> new_array
*
* Returns a new \Array containing each element found in both +array+ and \Array +other_array+;
- * duplicates are omitted; items are compared using <tt>eql?</tt>:
+ * duplicates are omitted; items are compared using <tt>eql?</tt>
+ * (items must also implement +hash+ correctly):
*
* [0, 1, 2, 3] & [1, 2] # => [1, 2]
* [0, 1, 0, 1] & [0, 1] # => [0, 1]
@@ -5713,7 +5519,8 @@ rb_ary_and(VALUE ary1, VALUE ary2)
*
* Returns a new \Array containing each element found both in +self+
* and in all of the given Arrays +other_arrays+;
- * duplicates are omitted; items are compared using <tt>eql?</tt>:
+ * duplicates are omitted; items are compared using <tt>eql?</tt>
+ * (items must also implement +hash+ correctly):
*
* [0, 1, 2, 3].intersection([0, 1, 2], [0, 1, 3]) # => [0, 1]
* [0, 0, 1, 1, 2, 3].intersection([0, 1, 2], [0, 1, 3]) # => [0, 1]
@@ -5862,6 +5669,8 @@ rb_ary_union_multi(int argc, VALUE *argv, VALUE ary)
* a.intersect?(b) #=> true
* a.intersect?(c) #=> false
*
+ * Array elements are compared using <tt>eql?</tt>
+ * (items must also implement +hash+ correctly).
*/
static VALUE
@@ -6006,20 +5815,20 @@ ary_max_opt_string(VALUE ary, long i, VALUE vmax)
* - A new \Array of maximum-valued elements selected from +self+.
*
* When no block is given, each element in +self+ must respond to method <tt><=></tt>
- * with an \Integer.
+ * with an Integer.
*
* With no argument and no block, returns the element in +self+
* having the maximum value per method <tt><=></tt>:
*
* [0, 1, 2].max # => 2
*
- * With an argument \Integer +n+ and no block, returns a new \Array with at most +n+ elements,
+ * With an argument Integer +n+ and no block, returns a new \Array with at most +n+ elements,
* in descending order per method <tt><=></tt>:
*
* [0, 1, 2, 3].max(3) # => [3, 2, 1]
* [0, 1, 2, 3].max(6) # => [3, 2, 1, 0]
*
- * When a block is given, the block must return an \Integer.
+ * When a block is given, the block must return an Integer.
*
* With a block and no argument, calls the block <tt>self.size-1</tt> times to compare elements;
* returns the element having the maximum value per the block:
@@ -6174,14 +5983,14 @@ ary_min_opt_string(VALUE ary, long i, VALUE vmin)
* - A new \Array of minimum-valued elements selected from +self+.
*
* When no block is given, each element in +self+ must respond to method <tt><=></tt>
- * with an \Integer.
+ * with an Integer.
*
* With no argument and no block, returns the element in +self+
* having the minimum value per method <tt><=></tt>:
*
* [0, 1, 2].min # => 0
*
- * With \Integer argument +n+ and no block, returns a new \Array with at most +n+ elements,
+ * With Integer argument +n+ and no block, returns a new \Array with at most +n+ elements,
* in ascending order per method <tt><=></tt>:
*
* [0, 1, 2, 3].min(3) # => [0, 1, 2]
@@ -6249,13 +6058,13 @@ rb_ary_min(int argc, VALUE *argv, VALUE ary)
* from +self+, either per method <tt><=></tt> or per a given block:.
*
* When no block is given, each element in +self+ must respond to method <tt><=></tt>
- * with an \Integer;
+ * with an Integer;
* returns a new 2-element \Array containing the minimum and maximum values
* from +self+, per method <tt><=></tt>:
*
* [0, 1, 2].minmax # => [0, 2]
*
- * When a block is given, the block must return an \Integer;
+ * When a block is given, the block must return an Integer;
* the block is called <tt>self.size-1</tt> times to compare elements;
* returns a new 2-element \Array containing the minimum and maximum values
* from +self+, per the block:
@@ -6398,14 +6207,14 @@ rb_ary_compact_bang(VALUE ary)
long n;
rb_ary_modify(ary);
- p = t = (VALUE *)RARRAY_CONST_PTR_TRANSIENT(ary); /* WB: no new reference */
+ p = t = (VALUE *)RARRAY_CONST_PTR(ary); /* WB: no new reference */
end = p + RARRAY_LEN(ary);
while (t < end) {
if (NIL_P(*t)) t++;
else *p++ = *t++;
}
- n = p - RARRAY_CONST_PTR_TRANSIENT(ary);
+ n = p - RARRAY_CONST_PTR(ary);
if (RARRAY_LEN(ary) == n) {
return Qnil;
}
@@ -6493,9 +6302,8 @@ static VALUE
flatten(VALUE ary, int level)
{
long i;
- VALUE stack, result, tmp = 0, elt, vmemo;
- st_table *memo = 0;
- st_data_t id;
+ VALUE stack, result, tmp = 0, elt;
+ VALUE memo = Qfalse;
for (i = 0; i < RARRAY_LEN(ary); i++) {
elt = RARRAY_AREF(ary, i);
@@ -6509,7 +6317,7 @@ flatten(VALUE ary, int level)
}
result = ary_new(0, RARRAY_LEN(ary));
- ary_memcpy(result, 0, i, RARRAY_CONST_PTR_TRANSIENT(ary));
+ ary_memcpy(result, 0, i, RARRAY_CONST_PTR(ary));
ARY_SET_LEN(result, i);
stack = ary_new(0, ARY_DEFAULT_SIZE);
@@ -6517,12 +6325,9 @@ flatten(VALUE ary, int level)
rb_ary_push(stack, LONG2NUM(i + 1));
if (level < 0) {
- vmemo = rb_hash_new();
- RBASIC_CLEAR_CLASS(vmemo);
- memo = st_init_numtable();
- rb_hash_st_table_set(vmemo, memo);
- st_insert(memo, (st_data_t)ary, (st_data_t)Qtrue);
- st_insert(memo, (st_data_t)tmp, (st_data_t)Qtrue);
+ memo = rb_obj_hide(rb_ident_hash_new());
+ rb_hash_aset(memo, ary, Qtrue);
+ rb_hash_aset(memo, tmp, Qtrue);
}
ary = tmp;
@@ -6537,9 +6342,8 @@ flatten(VALUE ary, int level)
}
tmp = rb_check_array_type(elt);
if (RBASIC(result)->klass) {
- if (memo) {
- RB_GC_GUARD(vmemo);
- st_clear(memo);
+ if (RTEST(memo)) {
+ rb_hash_clear(memo);
}
rb_raise(rb_eRuntimeError, "flatten reentered");
}
@@ -6548,12 +6352,11 @@ flatten(VALUE ary, int level)
}
else {
if (memo) {
- id = (st_data_t)tmp;
- if (st_is_member(memo, id)) {
- st_clear(memo);
+ if (rb_hash_aref(memo, tmp) == Qtrue) {
+ rb_hash_clear(memo);
rb_raise(rb_eArgError, "tried to flatten recursive array");
}
- st_insert(memo, id, (st_data_t)Qtrue);
+ rb_hash_aset(memo, tmp, Qtrue);
}
rb_ary_push(stack, ary);
rb_ary_push(stack, LONG2NUM(i));
@@ -6565,8 +6368,7 @@ flatten(VALUE ary, int level)
break;
}
if (memo) {
- id = (st_data_t)ary;
- st_delete(memo, &id, 0);
+ rb_hash_delete(memo, ary);
}
tmp = rb_ary_pop(stack);
i = NUM2LONG(tmp);
@@ -6574,7 +6376,7 @@ flatten(VALUE ary, int level)
}
if (memo) {
- st_clear(memo);
+ rb_hash_clear(memo);
}
RBASIC_SET_CLASS(result, rb_cArray);
@@ -6589,7 +6391,7 @@ flatten(VALUE ary, int level)
* Replaces each nested \Array in +self+ with the elements from that \Array;
* returns +self+ if any changes, +nil+ otherwise.
*
- * With non-negative \Integer argument +level+, flattens recursively through +level+ levels:
+ * With non-negative Integer argument +level+, flattens recursively through +level+ levels:
*
* a = [ 0, [ 1, [2, 3], 4 ], 5 ]
* a.flatten!(1) # => [0, 1, [2, 3], 4, 5]
@@ -6643,7 +6445,7 @@ rb_ary_flatten_bang(int argc, VALUE *argv, VALUE ary)
* - Each non-Array element is unchanged.
* - Each \Array is replaced by its individual elements.
*
- * With non-negative \Integer argument +level+, flattens recursively through +level+ levels:
+ * With non-negative Integer argument +level+, flattens recursively through +level+ levels:
*
* a = [ 0, [ 1, [2, 3], 4 ], 5 ]
* a.flatten(0) # => [0, [1, [2, 3], 4], 5]
@@ -6699,7 +6501,7 @@ rb_ary_shuffle_bang(rb_execution_context_t *ec, VALUE ary, VALUE randgen)
while (i) {
long j = RAND_UPTO(i);
VALUE tmp;
- if (len != RARRAY_LEN(ary) || ptr != RARRAY_CONST_PTR_TRANSIENT(ary)) {
+ if (len != RARRAY_LEN(ary) || ptr != RARRAY_CONST_PTR(ary)) {
rb_raise(rb_eRuntimeError, "modified during shuffle");
}
tmp = ptr[--i];
@@ -6791,7 +6593,7 @@ ary_sample(rb_execution_context_t *ec, VALUE ary, VALUE randgen, VALUE nv, VALUE
sorted[j] = idx[i] = k;
}
result = rb_ary_new_capa(n);
- RARRAY_PTR_USE_TRANSIENT(result, ptr_result, {
+ RARRAY_PTR_USE(result, ptr_result, {
for (i=0; i<n; i++) {
ptr_result[i] = RARRAY_AREF(ary, idx[i]);
}
@@ -6814,7 +6616,7 @@ ary_sample(rb_execution_context_t *ec, VALUE ary, VALUE randgen, VALUE nv, VALUE
len = RARRAY_LEN(ary);
if (len <= max_idx) n = 0;
else if (n > len) n = len;
- RARRAY_PTR_USE_TRANSIENT(ary, ptr_ary, {
+ RARRAY_PTR_USE(ary, ptr_ary, {
for (i=0; i<n; i++) {
long j2 = j = ptr_result[i];
long i2 = i;
@@ -6877,7 +6679,7 @@ rb_ary_cycle_size(VALUE self, VALUE args, VALUE eobj)
* array.cycle -> new_enumerator
* array.cycle(count) -> new_enumerator
*
- * When called with positive \Integer argument +count+ and a block,
+ * When called with positive Integer argument +count+ and a block,
* calls the block with each element, then does so again,
* until it has done so +count+ times; returns +nil+:
*
@@ -6896,7 +6698,7 @@ rb_ary_cycle_size(VALUE self, VALUE args, VALUE eobj)
* [0, 1].cycle {|element| puts element }
* [0, 1].cycle(nil) {|element| puts element }
*
- * When no block is given, returns a new \Enumerator:
+ * When no block is given, returns a new Enumerator:
*
* [0, 1].cycle(2) # => #<Enumerator: [0, 1]:cycle(2)>
* [0, 1].cycle # => # => #<Enumerator: [0, 1]:cycle>
@@ -7053,7 +6855,7 @@ rb_ary_permutation_size(VALUE ary, VALUE args, VALUE eobj)
* When invoked with a block, yield all permutations of elements of +self+; returns +self+.
* The order of permutations is indeterminate.
*
- * When a block and an in-range positive \Integer argument +n+ (<tt>0 < n <= self.size</tt>)
+ * When a block and an in-range positive Integer argument +n+ (<tt>0 < n <= self.size</tt>)
* are given, calls the block with all +n+-tuple permutations of +self+.
*
* Example:
@@ -7115,7 +6917,7 @@ rb_ary_permutation_size(VALUE ary, VALUE args, VALUE eobj)
* [2, 0, 1]
* [2, 1, 0]
*
- * Returns a new \Enumerator if no block given:
+ * Returns a new Enumerator if no block given:
*
* a = [0, 1, 2]
* a.permutation # => #<Enumerator: [0, 1, 2]:permutation>
@@ -7199,7 +7001,7 @@ rb_ary_combination_size(VALUE ary, VALUE args, VALUE eobj)
* Calls the block, if given, with combinations of elements of +self+;
* returns +self+. The order of combinations is indeterminate.
*
- * When a block and an in-range positive \Integer argument +n+ (<tt>0 < n <= self.size</tt>)
+ * When a block and an in-range positive Integer argument +n+ (<tt>0 < n <= self.size</tt>)
* are given, calls the block with all +n+-tuple combinations of +self+.
*
* Example:
@@ -7238,7 +7040,7 @@ rb_ary_combination_size(VALUE ary, VALUE args, VALUE eobj)
* a.combination(-1) {|combination| fail 'Cannot happen' }
* a.combination(4) {|combination| fail 'Cannot happen' }
*
- * Returns a new \Enumerator if no block given:
+ * Returns a new Enumerator if no block given:
*
* a = [0, 1, 2]
* a.combination(2) # => #<Enumerator: [0, 1, 2]:combination(2)>
@@ -7336,7 +7138,7 @@ rb_ary_repeated_permutation_size(VALUE ary, VALUE args, VALUE eobj)
* each permutation is an \Array;
* returns +self+. The order of the permutations is indeterminate.
*
- * When a block and a positive \Integer argument +n+ are given, calls the block with each
+ * When a block and a positive Integer argument +n+ are given, calls the block with each
* +n+-tuple repeated permutation of the elements of +self+.
* The number of permutations is <tt>self.size**n</tt>.
*
@@ -7373,7 +7175,7 @@ rb_ary_repeated_permutation_size(VALUE ary, VALUE args, VALUE eobj)
*
* a.repeated_permutation(-1) {|permutation| fail 'Cannot happen' }
*
- * Returns a new \Enumerator if no block given:
+ * Returns a new Enumerator if no block given:
*
* a = [0, 1, 2]
* a.repeated_permutation(2) # => #<Enumerator: [0, 1, 2]:permutation(2)>
@@ -7468,7 +7270,7 @@ rb_ary_repeated_combination_size(VALUE ary, VALUE args, VALUE eobj)
* each combination is an \Array;
* returns +self+. The order of the combinations is indeterminate.
*
- * When a block and a positive \Integer argument +n+ are given, calls the block with each
+ * When a block and a positive Integer argument +n+ are given, calls the block with each
* +n+-tuple repeated combination of the elements of +self+.
* The number of combinations is <tt>(n+1)(n+2)/2</tt>.
*
@@ -7502,7 +7304,7 @@ rb_ary_repeated_combination_size(VALUE ary, VALUE args, VALUE eobj)
*
* a.repeated_combination(-1) {|combination| fail 'Cannot happen' }
*
- * Returns a new \Enumerator if no block given:
+ * Returns a new Enumerator if no block given:
*
* a = [0, 1, 2]
* a.repeated_combination(2) # => #<Enumerator: [0, 1, 2]:combination(2)>
@@ -7710,7 +7512,7 @@ done:
* array.take(n) -> new_array
*
* Returns a new \Array containing the first +n+ element of +self+,
- * where +n+ is a non-negative \Integer;
+ * where +n+ is a non-negative Integer;
* does not modify +self+.
*
* Examples:
@@ -7750,7 +7552,7 @@ rb_ary_take(VALUE obj, VALUE n)
* a.take_while {|element| true } # => [0, 1, 2, 3, 4, 5]
* a # => [0, 1, 2, 3, 4, 5]
*
- * With no block given, returns a new \Enumerator:
+ * With no block given, returns a new Enumerator:
*
* [0, 1].take_while # => #<Enumerator: [0, 1]:take_while>
*
@@ -7773,7 +7575,7 @@ rb_ary_take_while(VALUE ary)
* array.drop(n) -> new_array
*
* Returns a new \Array containing all but the first +n+ element of +self+,
- * where +n+ is a non-negative \Integer;
+ * where +n+ is a non-negative Integer;
* does not modify +self+.
*
* Examples:
@@ -7814,7 +7616,7 @@ rb_ary_drop(VALUE ary, VALUE n)
* a = [0, 1, 2, 3, 4, 5]
* a.drop_while {|element| element < 3 } # => [3, 4, 5]
*
- * With no block given, returns a new \Enumerator:
+ * With no block given, returns a new Enumerator:
*
* [0, 1].drop_while # => # => #<Enumerator: [0, 1]:drop_while>
*
@@ -7840,6 +7642,9 @@ rb_ary_drop_while(VALUE ary)
*
* Returns +true+ if any element of +self+ meets a given criterion.
*
+ * If +self+ has no element, returns +false+ and argument or block
+ * are not used.
+ *
* With no block given and no argument, returns +true+ if +self+ has any truthy element,
* +false+ otherwise:
*
@@ -7901,6 +7706,9 @@ rb_ary_any_p(int argc, VALUE *argv, VALUE ary)
*
* Returns +true+ if all elements of +self+ meet a given criterion.
*
+ * If +self+ has no element, returns +true+ and argument or block
+ * are not used.
+ *
* With no block given and no argument, returns +true+ if +self+ contains only truthy elements,
* +false+ otherwise:
*
@@ -8186,6 +7994,12 @@ rb_ary_sum(int argc, VALUE *argv, VALUE ary)
n = 0;
r = Qundef;
+
+ if (!FIXNUM_P(v) && !RB_BIGNUM_TYPE_P(v) && !RB_TYPE_P(v, T_RATIONAL)) {
+ i = 0;
+ goto init_is_a_value;
+ }
+
for (i = 0; i < RARRAY_LEN(ary); i++) {
e = RARRAY_AREF(ary, i);
if (block_given)
@@ -8270,6 +8084,7 @@ rb_ary_sum(int argc, VALUE *argv, VALUE ary)
}
goto has_some_value;
+ init_is_a_value:
for (; i < RARRAY_LEN(ary); i++) {
e = RARRAY_AREF(ary, i);
if (block_given)
@@ -8280,6 +8095,7 @@ rb_ary_sum(int argc, VALUE *argv, VALUE ary)
return v;
}
+/* :nodoc: */
static VALUE
rb_ary_deconstruct(VALUE ary)
{
@@ -8807,8 +8623,6 @@ Init_Array(void)
rb_define_method(rb_cArray, "[]=", rb_ary_aset, -1);
rb_define_method(rb_cArray, "at", rb_ary_at, 1);
rb_define_method(rb_cArray, "fetch", rb_ary_fetch, -1);
- rb_define_method(rb_cArray, "first", rb_ary_first, -1);
- rb_define_method(rb_cArray, "last", rb_ary_last, -1);
rb_define_method(rb_cArray, "concat", rb_ary_concat_multi, -1);
rb_define_method(rb_cArray, "union", rb_ary_union_multi, -1);
rb_define_method(rb_cArray, "difference", rb_ary_difference_multi, -1);
diff --git a/array.rb b/array.rb
index b9fa9844e6..d17f374235 100644
--- a/array.rb
+++ b/array.rb
@@ -66,4 +66,92 @@ class Array
Primitive.ary_sample(random, n, ary)
end
end
+
+ # call-seq:
+ # array.first -> object or nil
+ # array.first(n) -> new_array
+ #
+ # Returns elements from +self+; does not modify +self+.
+ #
+ # When no argument is given, returns the first element:
+ #
+ # a = [:foo, 'bar', 2]
+ # a.first # => :foo
+ # a # => [:foo, "bar", 2]
+ #
+ # If +self+ is empty, returns +nil+.
+ #
+ # When non-negative Integer argument +n+ is given,
+ # returns the first +n+ elements in a new \Array:
+ #
+ # a = [:foo, 'bar', 2]
+ # a.first(2) # => [:foo, "bar"]
+ #
+ # If <tt>n >= array.size</tt>, returns all elements:
+ #
+ # a = [:foo, 'bar', 2]
+ # a.first(50) # => [:foo, "bar", 2]
+ #
+ # If <tt>n == 0</tt> returns an new empty \Array:
+ #
+ # a = [:foo, 'bar', 2]
+ # a.first(0) # []
+ #
+ # Related: #last.
+ def first n = unspecified = true
+ if Primitive.mandatory_only?
+ Primitive.attr! :leaf
+ Primitive.cexpr! %q{ ary_first(self) }
+ else
+ if unspecified
+ Primitive.cexpr! %q{ ary_first(self) }
+ else
+ Primitive.cexpr! %q{ ary_take_first_or_last_n(self, NUM2LONG(n), ARY_TAKE_FIRST) }
+ end
+ end
+ end
+
+ # call-seq:
+ # array.last -> object or nil
+ # array.last(n) -> new_array
+ #
+ # Returns elements from +self+; +self+ is not modified.
+ #
+ # When no argument is given, returns the last element:
+ #
+ # a = [:foo, 'bar', 2]
+ # a.last # => 2
+ # a # => [:foo, "bar", 2]
+ #
+ # If +self+ is empty, returns +nil+.
+ #
+ # When non-negative Integer argument +n+ is given,
+ # returns the last +n+ elements in a new \Array:
+ #
+ # a = [:foo, 'bar', 2]
+ # a.last(2) # => ["bar", 2]
+ #
+ # If <tt>n >= array.size</tt>, returns all elements:
+ #
+ # a = [:foo, 'bar', 2]
+ # a.last(50) # => [:foo, "bar", 2]
+ #
+ # If <tt>n == 0</tt>, returns an new empty \Array:
+ #
+ # a = [:foo, 'bar', 2]
+ # a.last(0) # []
+ #
+ # Related: #first.
+ def last n = unspecified = true
+ if Primitive.mandatory_only?
+ Primitive.attr! :leaf
+ Primitive.cexpr! %q{ ary_last(self) }
+ else
+ if unspecified
+ Primitive.cexpr! %q{ ary_last(self) }
+ else
+ Primitive.cexpr! %q{ ary_take_first_or_last_n(self, NUM2LONG(n), ARY_TAKE_LAST) }
+ end
+ end
+ end
end
diff --git a/ast.c b/ast.c
index adb7287ed3..50a54a9f4b 100644
--- a/ast.c
+++ b/ast.c
@@ -1,6 +1,6 @@
/* indent-tabs-mode: nil */
#include "internal.h"
-#include "internal/parse.h"
+#include "internal/ruby_parser.h"
#include "internal/symbol.h"
#include "internal/warnings.h"
#include "iseq.h"
@@ -97,7 +97,7 @@ rb_ast_parse_str(VALUE str, VALUE keep_script_lines, VALUE error_tolerant, VALUE
StringValue(str);
VALUE vparser = ast_parse_new();
- if (RTEST(keep_script_lines)) rb_parser_keep_script_lines(vparser);
+ if (RTEST(keep_script_lines)) rb_parser_set_script_lines(vparser, Qtrue);
if (RTEST(error_tolerant)) rb_parser_error_tolerant(vparser);
if (RTEST(keep_tokens)) rb_parser_keep_tokens(vparser);
ast = rb_parser_compile_string_path(vparser, Qnil, str, 1);
@@ -117,11 +117,10 @@ rb_ast_parse_file(VALUE path, VALUE keep_script_lines, VALUE error_tolerant, VAL
rb_ast_t *ast = 0;
rb_encoding *enc = rb_utf8_encoding();
- FilePathValue(path);
f = rb_file_open_str(path, "r");
rb_funcall(f, rb_intern("set_encoding"), 2, rb_enc_from_encoding(enc), rb_str_new_cstr("-"));
VALUE vparser = ast_parse_new();
- if (RTEST(keep_script_lines)) rb_parser_keep_script_lines(vparser);
+ if (RTEST(keep_script_lines)) rb_parser_set_script_lines(vparser, Qtrue);
if (RTEST(error_tolerant)) rb_parser_error_tolerant(vparser);
if (RTEST(keep_tokens)) rb_parser_keep_tokens(vparser);
ast = rb_parser_compile_file_path(vparser, Qnil, f, 1);
@@ -149,7 +148,7 @@ rb_ast_parse_array(VALUE array, VALUE keep_script_lines, VALUE error_tolerant, V
array = rb_check_array_type(array);
VALUE vparser = ast_parse_new();
- if (RTEST(keep_script_lines)) rb_parser_keep_script_lines(vparser);
+ if (RTEST(keep_script_lines)) rb_parser_set_script_lines(vparser, Qtrue);
if (RTEST(error_tolerant)) rb_parser_error_tolerant(vparser);
if (RTEST(keep_tokens)) rb_parser_keep_tokens(vparser);
ast = rb_parser_compile_generic(vparser, lex_array, Qnil, array, 1);
@@ -184,8 +183,8 @@ node_find(VALUE self, const int node_id)
extern VALUE rb_e_script;
-static VALUE
-script_lines(VALUE path)
+VALUE
+rb_script_lines_for(VALUE path, bool add)
{
VALUE hash, lines;
ID script_lines;
@@ -193,10 +192,19 @@ script_lines(VALUE path)
if (!rb_const_defined_at(rb_cObject, script_lines)) return Qnil;
hash = rb_const_get_at(rb_cObject, script_lines);
if (!RB_TYPE_P(hash, T_HASH)) return Qnil;
- lines = rb_hash_lookup(hash, path);
- if (!RB_TYPE_P(lines, T_ARRAY)) return Qnil;
+ if (add) {
+ rb_hash_aset(hash, path, lines = rb_ary_new());
+ }
+ else if (!RB_TYPE_P((lines = rb_hash_lookup(hash, path)), T_ARRAY)) {
+ return Qnil;
+ }
return lines;
}
+static VALUE
+script_lines(VALUE path)
+{
+ return rb_script_lines_for(path, false);
+}
static VALUE
node_id_for_backtrace_location(rb_execution_context_t *ec, VALUE module, VALUE location)
@@ -322,14 +330,14 @@ rb_ary_new_from_node_args(rb_ast_t *ast, long n, ...)
}
static VALUE
-dump_block(rb_ast_t *ast, const NODE *node)
+dump_block(rb_ast_t *ast, const struct RNode_BLOCK *node)
{
VALUE ary = rb_ary_new();
do {
rb_ary_push(ary, NEW_CHILD(ast, node->nd_head));
} while (node->nd_next &&
nd_type_p(node->nd_next, NODE_BLOCK) &&
- (node = node->nd_next, 1));
+ (node = RNODE_BLOCK(node->nd_next), 1));
if (node->nd_next) {
rb_ary_push(ary, NEW_CHILD(ast, node->nd_next));
}
@@ -338,13 +346,13 @@ dump_block(rb_ast_t *ast, const NODE *node)
}
static VALUE
-dump_array(rb_ast_t *ast, const NODE *node)
+dump_array(rb_ast_t *ast, const struct RNode_LIST *node)
{
VALUE ary = rb_ary_new();
rb_ary_push(ary, NEW_CHILD(ast, node->nd_head));
while (node->nd_next && nd_type_p(node->nd_next, NODE_LIST)) {
- node = node->nd_next;
+ node = RNODE_LIST(node->nd_next);
rb_ary_push(ary, NEW_CHILD(ast, node->nd_head));
}
rb_ary_push(ary, NEW_CHILD(ast, node->nd_next));
@@ -377,211 +385,229 @@ rest_arg(rb_ast_t *ast, const NODE *rest_arg)
static VALUE
node_children(rb_ast_t *ast, const NODE *node)
{
- char name[DECIMAL_SIZE_OF_BITS(sizeof(long) * CHAR_BIT) + 2]; /* including '$' */
+ char name[sizeof("$") + DECIMAL_SIZE_OF(long)];
enum node_type type = nd_type(node);
switch (type) {
case NODE_BLOCK:
- return dump_block(ast, node);
+ return dump_block(ast, RNODE_BLOCK(node));
case NODE_IF:
- return rb_ary_new_from_node_args(ast, 3, node->nd_cond, node->nd_body, node->nd_else);
+ return rb_ary_new_from_node_args(ast, 3, RNODE_IF(node)->nd_cond, RNODE_IF(node)->nd_body, RNODE_IF(node)->nd_else);
case NODE_UNLESS:
- return rb_ary_new_from_node_args(ast, 3, node->nd_cond, node->nd_body, node->nd_else);
+ return rb_ary_new_from_node_args(ast, 3, RNODE_UNLESS(node)->nd_cond, RNODE_UNLESS(node)->nd_body, RNODE_UNLESS(node)->nd_else);
case NODE_CASE:
- return rb_ary_new_from_node_args(ast, 2, node->nd_head, node->nd_body);
+ return rb_ary_new_from_node_args(ast, 2, RNODE_CASE(node)->nd_head, RNODE_CASE(node)->nd_body);
case NODE_CASE2:
- return rb_ary_new_from_node_args(ast, 2, node->nd_head, node->nd_body);
+ return rb_ary_new_from_node_args(ast, 2, RNODE_CASE2(node)->nd_head, RNODE_CASE2(node)->nd_body);
case NODE_CASE3:
- return rb_ary_new_from_node_args(ast, 2, node->nd_head, node->nd_body);
+ return rb_ary_new_from_node_args(ast, 2, RNODE_CASE3(node)->nd_head, RNODE_CASE3(node)->nd_body);
case NODE_WHEN:
- return rb_ary_new_from_node_args(ast, 3, node->nd_head, node->nd_body, node->nd_next);
+ return rb_ary_new_from_node_args(ast, 3, RNODE_WHEN(node)->nd_head, RNODE_WHEN(node)->nd_body, RNODE_WHEN(node)->nd_next);
case NODE_IN:
- return rb_ary_new_from_node_args(ast, 3, node->nd_head, node->nd_body, node->nd_next);
+ return rb_ary_new_from_node_args(ast, 3, RNODE_IN(node)->nd_head, RNODE_IN(node)->nd_body, RNODE_IN(node)->nd_next);
case NODE_WHILE:
case NODE_UNTIL:
- return rb_ary_push(rb_ary_new_from_node_args(ast, 2, node->nd_cond, node->nd_body),
- RBOOL(node->nd_state));
+ return rb_ary_push(rb_ary_new_from_node_args(ast, 2, RNODE_WHILE(node)->nd_cond, RNODE_WHILE(node)->nd_body),
+ RBOOL(RNODE_WHILE(node)->nd_state));
case NODE_ITER:
case NODE_FOR:
- return rb_ary_new_from_node_args(ast, 2, node->nd_iter, node->nd_body);
+ return rb_ary_new_from_node_args(ast, 2, RNODE_ITER(node)->nd_iter, RNODE_ITER(node)->nd_body);
case NODE_FOR_MASGN:
- return rb_ary_new_from_node_args(ast, 1, node->nd_var);
+ return rb_ary_new_from_node_args(ast, 1, RNODE_FOR_MASGN(node)->nd_var);
case NODE_BREAK:
+ return rb_ary_new_from_node_args(ast, 1, RNODE_BREAK(node)->nd_stts);
case NODE_NEXT:
+ return rb_ary_new_from_node_args(ast, 1, RNODE_NEXT(node)->nd_stts);
case NODE_RETURN:
- return rb_ary_new_from_node_args(ast, 1, node->nd_stts);
+ return rb_ary_new_from_node_args(ast, 1, RNODE_RETURN(node)->nd_stts);
case NODE_REDO:
return rb_ary_new_from_node_args(ast, 0);
case NODE_RETRY:
return rb_ary_new_from_node_args(ast, 0);
case NODE_BEGIN:
- return rb_ary_new_from_node_args(ast, 1, node->nd_body);
+ return rb_ary_new_from_node_args(ast, 1, RNODE_BEGIN(node)->nd_body);
case NODE_RESCUE:
- return rb_ary_new_from_node_args(ast, 3, node->nd_head, node->nd_resq, node->nd_else);
+ return rb_ary_new_from_node_args(ast, 3, RNODE_RESCUE(node)->nd_head, RNODE_RESCUE(node)->nd_resq, RNODE_RESCUE(node)->nd_else);
case NODE_RESBODY:
- return rb_ary_new_from_node_args(ast, 3, node->nd_args, node->nd_body, node->nd_head);
+ return rb_ary_new_from_node_args(ast, 3, RNODE_RESBODY(node)->nd_args, RNODE_RESBODY(node)->nd_body, RNODE_RESBODY(node)->nd_head);
case NODE_ENSURE:
- return rb_ary_new_from_node_args(ast, 2, node->nd_head, node->nd_ensr);
+ return rb_ary_new_from_node_args(ast, 2, RNODE_ENSURE(node)->nd_head, RNODE_ENSURE(node)->nd_ensr);
case NODE_AND:
case NODE_OR:
{
VALUE ary = rb_ary_new();
while (1) {
- rb_ary_push(ary, NEW_CHILD(ast, node->nd_1st));
- if (!node->nd_2nd || !nd_type_p(node->nd_2nd, type))
+ rb_ary_push(ary, NEW_CHILD(ast, RNODE_AND(node)->nd_1st));
+ if (!RNODE_AND(node)->nd_2nd || !nd_type_p(RNODE_AND(node)->nd_2nd, type))
break;
- node = node->nd_2nd;
+ node = RNODE_AND(node)->nd_2nd;
}
- rb_ary_push(ary, NEW_CHILD(ast, node->nd_2nd));
+ rb_ary_push(ary, NEW_CHILD(ast, RNODE_AND(node)->nd_2nd));
return ary;
}
case NODE_MASGN:
- if (NODE_NAMED_REST_P(node->nd_args)) {
- return rb_ary_new_from_node_args(ast, 3, node->nd_value, node->nd_head, node->nd_args);
+ if (NODE_NAMED_REST_P(RNODE_MASGN(node)->nd_args)) {
+ return rb_ary_new_from_node_args(ast, 3, RNODE_MASGN(node)->nd_value, RNODE_MASGN(node)->nd_head, RNODE_MASGN(node)->nd_args);
}
else {
- return rb_ary_new_from_args(3, NEW_CHILD(ast, node->nd_value),
- NEW_CHILD(ast, node->nd_head),
+ return rb_ary_new_from_args(3, NEW_CHILD(ast, RNODE_MASGN(node)->nd_value),
+ NEW_CHILD(ast, RNODE_MASGN(node)->nd_head),
no_name_rest());
}
case NODE_LASGN:
+ if (NODE_REQUIRED_KEYWORD_P(RNODE_LASGN(node)->nd_value)) {
+ return rb_ary_new_from_args(2, var_name(RNODE_LASGN(node)->nd_vid), ID2SYM(rb_intern("NODE_SPECIAL_REQUIRED_KEYWORD")));
+ }
+ return rb_ary_new_from_args(2, var_name(RNODE_LASGN(node)->nd_vid), NEW_CHILD(ast, RNODE_LASGN(node)->nd_value));
case NODE_DASGN:
+ if (NODE_REQUIRED_KEYWORD_P(RNODE_DASGN(node)->nd_value)) {
+ return rb_ary_new_from_args(2, var_name(RNODE_DASGN(node)->nd_vid), ID2SYM(rb_intern("NODE_SPECIAL_REQUIRED_KEYWORD")));
+ }
+ return rb_ary_new_from_args(2, var_name(RNODE_DASGN(node)->nd_vid), NEW_CHILD(ast, RNODE_DASGN(node)->nd_value));
case NODE_IASGN:
+ return rb_ary_new_from_args(2, var_name(RNODE_IASGN(node)->nd_vid), NEW_CHILD(ast, RNODE_IASGN(node)->nd_value));
case NODE_CVASGN:
+ return rb_ary_new_from_args(2, var_name(RNODE_CVASGN(node)->nd_vid), NEW_CHILD(ast, RNODE_CVASGN(node)->nd_value));
case NODE_GASGN:
- if (NODE_REQUIRED_KEYWORD_P(node)) {
- return rb_ary_new_from_args(2, var_name(node->nd_vid), ID2SYM(rb_intern("NODE_SPECIAL_REQUIRED_KEYWORD")));
- }
- return rb_ary_new_from_args(2, var_name(node->nd_vid), NEW_CHILD(ast, node->nd_value));
+ return rb_ary_new_from_args(2, var_name(RNODE_GASGN(node)->nd_vid), NEW_CHILD(ast, RNODE_GASGN(node)->nd_value));
case NODE_CDECL:
- if (node->nd_vid) {
- return rb_ary_new_from_args(2, ID2SYM(node->nd_vid), NEW_CHILD(ast, node->nd_value));
+ if (RNODE_CDECL(node)->nd_vid) {
+ return rb_ary_new_from_args(2, ID2SYM(RNODE_CDECL(node)->nd_vid), NEW_CHILD(ast, RNODE_CDECL(node)->nd_value));
}
- return rb_ary_new_from_args(3, NEW_CHILD(ast, node->nd_else), ID2SYM(node->nd_else->nd_mid), NEW_CHILD(ast, node->nd_value));
+ return rb_ary_new_from_args(3, NEW_CHILD(ast, RNODE_CDECL(node)->nd_else), ID2SYM(RNODE_COLON2(RNODE_CDECL(node)->nd_else)->nd_mid), NEW_CHILD(ast, RNODE_CDECL(node)->nd_value));
case NODE_OP_ASGN1:
- return rb_ary_new_from_args(4, NEW_CHILD(ast, node->nd_recv),
- ID2SYM(node->nd_mid),
- NEW_CHILD(ast, node->nd_args->nd_head),
- NEW_CHILD(ast, node->nd_args->nd_body));
+ return rb_ary_new_from_args(4, NEW_CHILD(ast, RNODE_OP_ASGN1(node)->nd_recv),
+ ID2SYM(RNODE_OP_ASGN1(node)->nd_mid),
+ NEW_CHILD(ast, RNODE_OP_ASGN1(node)->nd_index),
+ NEW_CHILD(ast, RNODE_OP_ASGN1(node)->nd_rvalue));
case NODE_OP_ASGN2:
- return rb_ary_new_from_args(5, NEW_CHILD(ast, node->nd_recv),
- RBOOL(node->nd_next->nd_aid),
- ID2SYM(node->nd_next->nd_vid),
- ID2SYM(node->nd_next->nd_mid),
- NEW_CHILD(ast, node->nd_value));
+ return rb_ary_new_from_args(5, NEW_CHILD(ast, RNODE_OP_ASGN2(node)->nd_recv),
+ RBOOL(RNODE_OP_ASGN2(node)->nd_aid),
+ ID2SYM(RNODE_OP_ASGN2(node)->nd_vid),
+ ID2SYM(RNODE_OP_ASGN2(node)->nd_mid),
+ NEW_CHILD(ast, RNODE_OP_ASGN2(node)->nd_value));
case NODE_OP_ASGN_AND:
- return rb_ary_new_from_args(3, NEW_CHILD(ast, node->nd_head), ID2SYM(idANDOP),
- NEW_CHILD(ast, node->nd_value));
+ return rb_ary_new_from_args(3, NEW_CHILD(ast, RNODE_OP_ASGN_AND(node)->nd_head), ID2SYM(idANDOP),
+ NEW_CHILD(ast, RNODE_OP_ASGN_AND(node)->nd_value));
case NODE_OP_ASGN_OR:
- return rb_ary_new_from_args(3, NEW_CHILD(ast, node->nd_head), ID2SYM(idOROP),
- NEW_CHILD(ast, node->nd_value));
+ return rb_ary_new_from_args(3, NEW_CHILD(ast, RNODE_OP_ASGN_OR(node)->nd_head), ID2SYM(idOROP),
+ NEW_CHILD(ast, RNODE_OP_ASGN_OR(node)->nd_value));
case NODE_OP_CDECL:
- return rb_ary_new_from_args(3, NEW_CHILD(ast, node->nd_head),
- ID2SYM(node->nd_aid),
- NEW_CHILD(ast, node->nd_value));
+ return rb_ary_new_from_args(3, NEW_CHILD(ast, RNODE_OP_CDECL(node)->nd_head),
+ ID2SYM(RNODE_OP_CDECL(node)->nd_aid),
+ NEW_CHILD(ast, RNODE_OP_CDECL(node)->nd_value));
case NODE_CALL:
+ return rb_ary_new_from_args(3, NEW_CHILD(ast, RNODE_CALL(node)->nd_recv),
+ ID2SYM(RNODE_CALL(node)->nd_mid),
+ NEW_CHILD(ast, RNODE_CALL(node)->nd_args));
case NODE_OPCALL:
+ return rb_ary_new_from_args(3, NEW_CHILD(ast, RNODE_OPCALL(node)->nd_recv),
+ ID2SYM(RNODE_OPCALL(node)->nd_mid),
+ NEW_CHILD(ast, RNODE_OPCALL(node)->nd_args));
case NODE_QCALL:
- return rb_ary_new_from_args(3, NEW_CHILD(ast, node->nd_recv),
- ID2SYM(node->nd_mid),
- NEW_CHILD(ast, node->nd_args));
+ return rb_ary_new_from_args(3, NEW_CHILD(ast, RNODE_QCALL(node)->nd_recv),
+ ID2SYM(RNODE_QCALL(node)->nd_mid),
+ NEW_CHILD(ast, RNODE_QCALL(node)->nd_args));
case NODE_FCALL:
- return rb_ary_new_from_args(2, ID2SYM(node->nd_mid),
- NEW_CHILD(ast, node->nd_args));
+ return rb_ary_new_from_args(2, ID2SYM(RNODE_FCALL(node)->nd_mid),
+ NEW_CHILD(ast, RNODE_FCALL(node)->nd_args));
case NODE_VCALL:
- return rb_ary_new_from_args(1, ID2SYM(node->nd_mid));
+ return rb_ary_new_from_args(1, ID2SYM(RNODE_VCALL(node)->nd_mid));
case NODE_SUPER:
- return rb_ary_new_from_node_args(ast, 1, node->nd_args);
+ return rb_ary_new_from_node_args(ast, 1, RNODE_SUPER(node)->nd_args);
case NODE_ZSUPER:
return rb_ary_new_from_node_args(ast, 0);
case NODE_LIST:
- case NODE_VALUES:
- return dump_array(ast, node);
+ return dump_array(ast, RNODE_LIST(node));
case NODE_ZLIST:
return rb_ary_new_from_node_args(ast, 0);
case NODE_HASH:
- return rb_ary_new_from_node_args(ast, 1, node->nd_head);
+ return rb_ary_new_from_node_args(ast, 1, RNODE_HASH(node)->nd_head);
case NODE_YIELD:
- return rb_ary_new_from_node_args(ast, 1, node->nd_head);
+ return rb_ary_new_from_node_args(ast, 1, RNODE_YIELD(node)->nd_head);
case NODE_LVAR:
+ return rb_ary_new_from_args(1, var_name(RNODE_LVAR(node)->nd_vid));
case NODE_DVAR:
- return rb_ary_new_from_args(1, var_name(node->nd_vid));
+ return rb_ary_new_from_args(1, var_name(RNODE_DVAR(node)->nd_vid));
case NODE_IVAR:
+ return rb_ary_new_from_args(1, ID2SYM(RNODE_IVAR(node)->nd_vid));
case NODE_CONST:
+ return rb_ary_new_from_args(1, ID2SYM(RNODE_CONST(node)->nd_vid));
case NODE_CVAR:
+ return rb_ary_new_from_args(1, ID2SYM(RNODE_CVAR(node)->nd_vid));
case NODE_GVAR:
- return rb_ary_new_from_args(1, ID2SYM(node->nd_vid));
+ return rb_ary_new_from_args(1, ID2SYM(RNODE_GVAR(node)->nd_vid));
case NODE_NTH_REF:
- snprintf(name, sizeof(name), "$%ld", node->nd_nth);
+ snprintf(name, sizeof(name), "$%ld", RNODE_NTH_REF(node)->nd_nth);
return rb_ary_new_from_args(1, ID2SYM(rb_intern(name)));
case NODE_BACK_REF:
name[0] = '$';
- name[1] = (char)node->nd_nth;
+ name[1] = (char)RNODE_BACK_REF(node)->nd_nth;
name[2] = '\0';
return rb_ary_new_from_args(1, ID2SYM(rb_intern(name)));
case NODE_MATCH2:
- if (node->nd_args) {
- return rb_ary_new_from_node_args(ast, 3, node->nd_recv, node->nd_value, node->nd_args);
+ if (RNODE_MATCH2(node)->nd_args) {
+ return rb_ary_new_from_node_args(ast, 3, RNODE_MATCH2(node)->nd_recv, RNODE_MATCH2(node)->nd_value, RNODE_MATCH2(node)->nd_args);
}
- return rb_ary_new_from_node_args(ast, 2, node->nd_recv, node->nd_value);
+ return rb_ary_new_from_node_args(ast, 2, RNODE_MATCH2(node)->nd_recv, RNODE_MATCH2(node)->nd_value);
case NODE_MATCH3:
- return rb_ary_new_from_node_args(ast, 2, node->nd_recv, node->nd_value);
+ return rb_ary_new_from_node_args(ast, 2, RNODE_MATCH3(node)->nd_recv, RNODE_MATCH3(node)->nd_value);
case NODE_MATCH:
case NODE_LIT:
case NODE_STR:
case NODE_XSTR:
- return rb_ary_new_from_args(1, node->nd_lit);
+ return rb_ary_new_from_args(1, RNODE_LIT(node)->nd_lit);
case NODE_ONCE:
- return rb_ary_new_from_node_args(ast, 1, node->nd_body);
+ return rb_ary_new_from_node_args(ast, 1, RNODE_ONCE(node)->nd_body);
case NODE_DSTR:
case NODE_DXSTR:
case NODE_DREGX:
case NODE_DSYM:
{
- NODE *n = node->nd_next;
+ struct RNode_LIST *n = RNODE_DSTR(node)->nd_next;
VALUE head = Qnil, next = Qnil;
if (n) {
head = NEW_CHILD(ast, n->nd_head);
next = NEW_CHILD(ast, n->nd_next);
}
- return rb_ary_new_from_args(3, node->nd_lit, head, next);
+ return rb_ary_new_from_args(3, RNODE_DSTR(node)->nd_lit, head, next);
}
case NODE_EVSTR:
- return rb_ary_new_from_node_args(ast, 1, node->nd_body);
+ return rb_ary_new_from_node_args(ast, 1, RNODE_EVSTR(node)->nd_body);
case NODE_ARGSCAT:
- return rb_ary_new_from_node_args(ast, 2, node->nd_head, node->nd_body);
+ return rb_ary_new_from_node_args(ast, 2, RNODE_ARGSCAT(node)->nd_head, RNODE_ARGSCAT(node)->nd_body);
case NODE_ARGSPUSH:
- return rb_ary_new_from_node_args(ast, 2, node->nd_head, node->nd_body);
+ return rb_ary_new_from_node_args(ast, 2, RNODE_ARGSPUSH(node)->nd_head, RNODE_ARGSPUSH(node)->nd_body);
case NODE_SPLAT:
- return rb_ary_new_from_node_args(ast, 1, node->nd_head);
+ return rb_ary_new_from_node_args(ast, 1, RNODE_SPLAT(node)->nd_head);
case NODE_BLOCK_PASS:
- return rb_ary_new_from_node_args(ast, 2, node->nd_head, node->nd_body);
+ return rb_ary_new_from_node_args(ast, 2, RNODE_BLOCK_PASS(node)->nd_head, RNODE_BLOCK_PASS(node)->nd_body);
case NODE_DEFN:
- return rb_ary_new_from_args(2, ID2SYM(node->nd_mid), NEW_CHILD(ast, node->nd_defn));
+ return rb_ary_new_from_args(2, ID2SYM(RNODE_DEFN(node)->nd_mid), NEW_CHILD(ast, RNODE_DEFN(node)->nd_defn));
case NODE_DEFS:
- return rb_ary_new_from_args(3, NEW_CHILD(ast, node->nd_recv), ID2SYM(node->nd_mid), NEW_CHILD(ast, node->nd_defn));
+ return rb_ary_new_from_args(3, NEW_CHILD(ast, RNODE_DEFS(node)->nd_recv), ID2SYM(RNODE_DEFS(node)->nd_mid), NEW_CHILD(ast, RNODE_DEFS(node)->nd_defn));
case NODE_ALIAS:
- return rb_ary_new_from_node_args(ast, 2, node->nd_1st, node->nd_2nd);
+ return rb_ary_new_from_node_args(ast, 2, RNODE_ALIAS(node)->nd_1st, RNODE_ALIAS(node)->nd_2nd);
case NODE_VALIAS:
- return rb_ary_new_from_args(2, ID2SYM(node->nd_alias), ID2SYM(node->nd_orig));
+ return rb_ary_new_from_args(2, ID2SYM(RNODE_VALIAS(node)->nd_alias), ID2SYM(RNODE_VALIAS(node)->nd_orig));
case NODE_UNDEF:
- return rb_ary_new_from_node_args(ast, 1, node->nd_undef);
+ return rb_ary_new_from_node_args(ast, 1, RNODE_UNDEF(node)->nd_undef);
case NODE_CLASS:
- return rb_ary_new_from_node_args(ast, 3, node->nd_cpath, node->nd_super, node->nd_body);
+ return rb_ary_new_from_node_args(ast, 3, RNODE_CLASS(node)->nd_cpath, RNODE_CLASS(node)->nd_super, RNODE_CLASS(node)->nd_body);
case NODE_MODULE:
- return rb_ary_new_from_node_args(ast, 2, node->nd_cpath, node->nd_body);
+ return rb_ary_new_from_node_args(ast, 2, RNODE_MODULE(node)->nd_cpath, RNODE_MODULE(node)->nd_body);
case NODE_SCLASS:
- return rb_ary_new_from_node_args(ast, 2, node->nd_recv, node->nd_body);
+ return rb_ary_new_from_node_args(ast, 2, RNODE_SCLASS(node)->nd_recv, RNODE_SCLASS(node)->nd_body);
case NODE_COLON2:
- return rb_ary_new_from_args(2, NEW_CHILD(ast, node->nd_head), ID2SYM(node->nd_mid));
+ return rb_ary_new_from_args(2, NEW_CHILD(ast, RNODE_COLON2(node)->nd_head), ID2SYM(RNODE_COLON2(node)->nd_mid));
case NODE_COLON3:
- return rb_ary_new_from_args(1, ID2SYM(node->nd_mid));
+ return rb_ary_new_from_args(1, ID2SYM(RNODE_COLON3(node)->nd_mid));
case NODE_DOT2:
case NODE_DOT3:
case NODE_FLIP2:
case NODE_FLIP3:
- return rb_ary_new_from_node_args(ast, 2, node->nd_beg, node->nd_end);
+ return rb_ary_new_from_node_args(ast, 2, RNODE_DOT2(node)->nd_beg, RNODE_DOT2(node)->nd_end);
case NODE_SELF:
return rb_ary_new_from_node_args(ast, 0);
case NODE_NIL:
@@ -593,84 +619,84 @@ node_children(rb_ast_t *ast, const NODE *node)
case NODE_ERRINFO:
return rb_ary_new_from_node_args(ast, 0);
case NODE_DEFINED:
- return rb_ary_new_from_node_args(ast, 1, node->nd_head);
+ return rb_ary_new_from_node_args(ast, 1, RNODE_DEFINED(node)->nd_head);
case NODE_POSTEXE:
- return rb_ary_new_from_node_args(ast, 1, node->nd_body);
+ return rb_ary_new_from_node_args(ast, 1, RNODE_POSTEXE(node)->nd_body);
case NODE_ATTRASGN:
- return rb_ary_new_from_args(3, NEW_CHILD(ast, node->nd_recv), ID2SYM(node->nd_mid), NEW_CHILD(ast, node->nd_args));
+ return rb_ary_new_from_args(3, NEW_CHILD(ast, RNODE_ATTRASGN(node)->nd_recv), ID2SYM(RNODE_ATTRASGN(node)->nd_mid), NEW_CHILD(ast, RNODE_ATTRASGN(node)->nd_args));
case NODE_LAMBDA:
- return rb_ary_new_from_node_args(ast, 1, node->nd_body);
+ return rb_ary_new_from_node_args(ast, 1, RNODE_LAMBDA(node)->nd_body);
case NODE_OPT_ARG:
- return rb_ary_new_from_node_args(ast, 2, node->nd_body, node->nd_next);
+ return rb_ary_new_from_node_args(ast, 2, RNODE_OPT_ARG(node)->nd_body, RNODE_OPT_ARG(node)->nd_next);
case NODE_KW_ARG:
- return rb_ary_new_from_node_args(ast, 2, node->nd_body, node->nd_next);
+ return rb_ary_new_from_node_args(ast, 2, RNODE_KW_ARG(node)->nd_body, RNODE_KW_ARG(node)->nd_next);
case NODE_POSTARG:
- if (NODE_NAMED_REST_P(node->nd_1st)) {
- return rb_ary_new_from_node_args(ast, 2, node->nd_1st, node->nd_2nd);
+ if (NODE_NAMED_REST_P(RNODE_POSTARG(node)->nd_1st)) {
+ return rb_ary_new_from_node_args(ast, 2, RNODE_POSTARG(node)->nd_1st, RNODE_POSTARG(node)->nd_2nd);
}
return rb_ary_new_from_args(2, no_name_rest(),
- NEW_CHILD(ast, node->nd_2nd));
+ NEW_CHILD(ast, RNODE_POSTARG(node)->nd_2nd));
case NODE_ARGS:
{
- struct rb_args_info *ainfo = node->nd_ainfo;
+ struct rb_args_info *ainfo = &RNODE_ARGS(node)->nd_ainfo;
return rb_ary_new_from_args(10,
INT2NUM(ainfo->pre_args_num),
NEW_CHILD(ast, ainfo->pre_init),
- NEW_CHILD(ast, ainfo->opt_args),
+ NEW_CHILD(ast, (NODE *)ainfo->opt_args),
var_name(ainfo->first_post_arg),
INT2NUM(ainfo->post_args_num),
NEW_CHILD(ast, ainfo->post_init),
(ainfo->rest_arg == NODE_SPECIAL_EXCESSIVE_COMMA
? ID2SYM(rb_intern("NODE_SPECIAL_EXCESSIVE_COMMA"))
: var_name(ainfo->rest_arg)),
- (ainfo->no_kwarg ? Qfalse : NEW_CHILD(ast, ainfo->kw_args)),
+ (ainfo->no_kwarg ? Qfalse : NEW_CHILD(ast, (NODE *)ainfo->kw_args)),
(ainfo->no_kwarg ? Qfalse : NEW_CHILD(ast, ainfo->kw_rest_arg)),
var_name(ainfo->block_arg));
}
case NODE_SCOPE:
{
- rb_ast_id_table_t *tbl = node->nd_tbl;
+ rb_ast_id_table_t *tbl = RNODE_SCOPE(node)->nd_tbl;
int i, size = tbl ? tbl->size : 0;
VALUE locals = rb_ary_new_capa(size);
for (i = 0; i < size; i++) {
rb_ary_push(locals, var_name(tbl->ids[i]));
}
- return rb_ary_new_from_args(3, locals, NEW_CHILD(ast, node->nd_args), NEW_CHILD(ast, node->nd_body));
+ return rb_ary_new_from_args(3, locals, NEW_CHILD(ast, (NODE *)RNODE_SCOPE(node)->nd_args), NEW_CHILD(ast, RNODE_SCOPE(node)->nd_body));
}
case NODE_ARYPTN:
{
- struct rb_ary_pattern_info *apinfo = node->nd_apinfo;
- VALUE rest = rest_arg(ast, apinfo->rest_arg);
+ VALUE rest = rest_arg(ast, RNODE_ARYPTN(node)->rest_arg);
return rb_ary_new_from_args(4,
- NEW_CHILD(ast, node->nd_pconst),
- NEW_CHILD(ast, apinfo->pre_args),
+ NEW_CHILD(ast, RNODE_ARYPTN(node)->nd_pconst),
+ NEW_CHILD(ast, RNODE_ARYPTN(node)->pre_args),
rest,
- NEW_CHILD(ast, apinfo->post_args));
+ NEW_CHILD(ast, RNODE_ARYPTN(node)->post_args));
}
case NODE_FNDPTN:
{
- struct rb_fnd_pattern_info *fpinfo = node->nd_fpinfo;
- VALUE pre_rest = rest_arg(ast, fpinfo->pre_rest_arg);
- VALUE post_rest = rest_arg(ast, fpinfo->post_rest_arg);
+ VALUE pre_rest = rest_arg(ast, RNODE_FNDPTN(node)->pre_rest_arg);
+ VALUE post_rest = rest_arg(ast, RNODE_FNDPTN(node)->post_rest_arg);
return rb_ary_new_from_args(4,
- NEW_CHILD(ast, node->nd_pconst),
+ NEW_CHILD(ast, RNODE_FNDPTN(node)->nd_pconst),
pre_rest,
- NEW_CHILD(ast, fpinfo->args),
+ NEW_CHILD(ast, RNODE_FNDPTN(node)->args),
post_rest);
}
case NODE_HSHPTN:
{
- VALUE kwrest = node->nd_pkwrestarg == NODE_SPECIAL_NO_REST_KEYWORD ? ID2SYM(rb_intern("NODE_SPECIAL_NO_REST_KEYWORD")) :
- NEW_CHILD(ast, node->nd_pkwrestarg);
+ VALUE kwrest = RNODE_HSHPTN(node)->nd_pkwrestarg == NODE_SPECIAL_NO_REST_KEYWORD ? ID2SYM(rb_intern("NODE_SPECIAL_NO_REST_KEYWORD")) :
+ NEW_CHILD(ast, RNODE_HSHPTN(node)->nd_pkwrestarg);
return rb_ary_new_from_args(3,
- NEW_CHILD(ast, node->nd_pconst),
- NEW_CHILD(ast, node->nd_pkwargs),
+ NEW_CHILD(ast, RNODE_HSHPTN(node)->nd_pconst),
+ NEW_CHILD(ast, RNODE_HSHPTN(node)->nd_pkwargs),
kwrest);
}
case NODE_ERROR:
return rb_ary_new_from_node_args(ast, 0);
case NODE_ARGS_AUX:
+ case NODE_RIPPER:
+ case NODE_RIPPER_VALUES:
case NODE_LAST:
break;
}
diff --git a/ast.rb b/ast.rb
index f3f72c747f..51ee5b3d59 100644
--- a/ast.rb
+++ b/ast.rb
@@ -20,7 +20,7 @@
module RubyVM::AbstractSyntaxTree
# call-seq:
- # RubyVM::AbstractSyntaxTree.parse(string, keep_script_lines: false, error_tolerant: false, keep_tokens: false) -> RubyVM::AbstractSyntaxTree::Node
+ # RubyVM::AbstractSyntaxTree.parse(string, keep_script_lines: RubyVM.keep_script_lines, error_tolerant: false, keep_tokens: false) -> RubyVM::AbstractSyntaxTree::Node
#
# Parses the given _string_ into an abstract syntax tree,
# returning the root node of that tree.
@@ -53,14 +53,14 @@ module RubyVM::AbstractSyntaxTree
# # (ERROR@1:7-1:11),
# # (LASGN@1:12-1:15 :y (LIT@1:14-1:15 2))]
#
- # Note that parsing continues even after the errored expresion.
+ # Note that parsing continues even after the errored expression.
#
- def self.parse string, keep_script_lines: false, error_tolerant: false, keep_tokens: false
+ def self.parse string, keep_script_lines: RubyVM.keep_script_lines, error_tolerant: false, keep_tokens: false
Primitive.ast_s_parse string, keep_script_lines, error_tolerant, keep_tokens
end
# call-seq:
- # RubyVM::AbstractSyntaxTree.parse_file(pathname, keep_script_lines: false, error_tolerant: false, keep_tokens: false) -> RubyVM::AbstractSyntaxTree::Node
+ # RubyVM::AbstractSyntaxTree.parse_file(pathname, keep_script_lines: RubyVM.keep_script_lines, error_tolerant: false, keep_tokens: false) -> RubyVM::AbstractSyntaxTree::Node
#
# Reads the file from _pathname_, then parses it like ::parse,
# returning the root node of the abstract syntax tree.
@@ -72,13 +72,13 @@ module RubyVM::AbstractSyntaxTree
# # => #<RubyVM::AbstractSyntaxTree::Node:SCOPE@1:0-31:3>
#
# See ::parse for explanation of keyword argument meaning and usage.
- def self.parse_file pathname, keep_script_lines: false, error_tolerant: false, keep_tokens: false
+ def self.parse_file pathname, keep_script_lines: RubyVM.keep_script_lines, error_tolerant: false, keep_tokens: false
Primitive.ast_s_parse_file pathname, keep_script_lines, error_tolerant, keep_tokens
end
# call-seq:
- # RubyVM::AbstractSyntaxTree.of(proc, keep_script_lines: false, error_tolerant: false, keep_tokens: false) -> RubyVM::AbstractSyntaxTree::Node
- # RubyVM::AbstractSyntaxTree.of(method, keep_script_lines: false, error_tolerant: false, keep_tokens: false) -> RubyVM::AbstractSyntaxTree::Node
+ # RubyVM::AbstractSyntaxTree.of(proc, keep_script_lines: RubyVM.keep_script_lines, error_tolerant: false, keep_tokens: false) -> RubyVM::AbstractSyntaxTree::Node
+ # RubyVM::AbstractSyntaxTree.of(method, keep_script_lines: RubyVM.keep_script_lines, error_tolerant: false, keep_tokens: false) -> RubyVM::AbstractSyntaxTree::Node
#
# Returns AST nodes of the given _proc_ or _method_.
#
@@ -93,7 +93,7 @@ module RubyVM::AbstractSyntaxTree
# # => #<RubyVM::AbstractSyntaxTree::Node:SCOPE@1:0-3:3>
#
# See ::parse for explanation of keyword argument meaning and usage.
- def self.of body, keep_script_lines: false, error_tolerant: false, keep_tokens: false
+ def self.of body, keep_script_lines: RubyVM.keep_script_lines, error_tolerant: false, keep_tokens: false
Primitive.ast_s_of body, keep_script_lines, error_tolerant, keep_tokens
end
@@ -265,8 +265,8 @@ module RubyVM::AbstractSyntaxTree
lines = script_lines
if lines
lines = lines[first_lineno - 1 .. last_lineno - 1]
- lines[-1] = lines[-1][0...last_column]
- lines[0] = lines[0][first_column..-1]
+ lines[-1] = lines[-1].byteslice(0...last_column)
+ lines[0] = lines[0].byteslice(first_column..-1)
lines.join
else
nil
diff --git a/benchmark/enum_sort_by.yml b/benchmark/enum_sort_by.yml
new file mode 100644
index 0000000000..d386353888
--- /dev/null
+++ b/benchmark/enum_sort_by.yml
@@ -0,0 +1,53 @@
+prelude: |
+ array_length = 2
+ fixnum_array2 = array_length.times.to_a.map {rand(10000)}
+ float_array2 = array_length.times.to_a.map {rand(10000.0).to_f}
+ string_array2 = array_length.times.to_a.map {"r" * rand(1..10000)}
+ mix_array2 = array_length.times.to_a.map {if rand(1..100) <= 50 then rand(1..10000).to_f else rand(1..10000) end}
+ all_zero_array2 =array_length.times.to_a.map {0}
+
+ array_length = 10
+ fixnum_array10 = array_length.times.to_a.map {rand(10000)}
+ float_array10 = array_length.times.to_a.map {rand(10000.0).to_f}
+ string_array10 = array_length.times.to_a.map {"r" * rand(1..10000)}
+ mix_array10 = array_length.times.to_a.map {if rand(1..100) <= 50 then rand(1..10000).to_f else rand(1..10000) end}
+ all_zero_array10 =array_length.times.to_a.map {0}
+
+ array_length = 1000
+ fixnum_array1000 = array_length.times.to_a.map {rand(10000)}
+ float_array1000 = array_length.times.to_a.map {rand(10000.0).to_f}
+ string_array1000 = array_length.times.to_a.map {"r" * rand(1..10000)}
+ mix_array1000 = array_length.times.to_a.map {if rand(1..100) <= 50 then rand(1..10000).to_f else rand(1..10000) end}
+ all_zero_array1000 =array_length.times.to_a.map {0}
+
+ array_length = 100000
+ fixnum_array100000 = array_length.times.to_a.map {rand(10000)}
+ float_array100000 = array_length.times.to_a.map {rand(10000.0).to_f}
+ string_array100000 = array_length.times.to_a.map {"r" * rand(1..10000)}
+ mix_array100000 = array_length.times.to_a.map {if rand(1..100) <= 50 then rand(1..10000).to_f else rand(1..10000) end}
+ all_zero_array100000 =array_length.times.to_a.map {0}
+
+benchmark:
+ fixnum_array2.sort_by: fixnum_array2.sort_by {|a| a}
+ float_array2.sort_by: float_array2.sort_by {|a| a}
+ string_length2.sort_by: string_array2.sort_by {|a| a.length}
+ mix_array2.sort_by: mix_array2.sort_by {|a| a}
+ all_zero2.sort_by: all_zero_array2.sort_by{|a| a}
+
+ fixnum_array10.sort_by: fixnum_array10.sort_by {|a| a}
+ float_array10.sort_by: float_array10.sort_by {|a| a}
+ string_length10.sort_by: string_array10.sort_by {|a| a.length}
+ mix_array10.sort_by: mix_array10.sort_by {|a| a}
+ all_zero10.sort_by: all_zero_array10.sort_by{|a| a}
+
+ fixnum_array1000.sort_by: fixnum_array1000.sort_by {|a| a}
+ float_array1000.sort_by: float_array1000.sort_by {|a| a}
+ string_length1000.sort_by: string_array1000.sort_by {|a| a.length}
+ mix_array1000.sort_by: mix_array1000.sort_by {|a| a}
+ all_zero1000.sort_by: all_zero_array1000.sort_by{|a| a}
+
+ fixnum_array100000.sort_by: fixnum_array100000.sort_by {|a| a}
+ float_array100000.sort_by: float_array100000.sort_by {|a| a}
+ string_length100000.sort_by: string_array100000.sort_by {|a| a.length}
+ mix_array100000.sort_by: mix_array100000.sort_by {|a| a}
+ all_zero100000.sort_by: all_zero_array100000.sort_by{|a| a}
diff --git a/benchmark/lib/benchmark_driver/runner/mjit.rb b/benchmark/lib/benchmark_driver/runner/mjit.rb
deleted file mode 100644
index 3a58a620de..0000000000
--- a/benchmark/lib/benchmark_driver/runner/mjit.rb
+++ /dev/null
@@ -1,34 +0,0 @@
-require 'benchmark_driver/struct'
-require 'benchmark_driver/metric'
-require 'erb'
-
-# A runner to measure after-JIT performance easily
-class BenchmarkDriver::Runner::Mjit < BenchmarkDriver::Runner::Ips
- # JobParser returns this, `BenchmarkDriver::Runner.runner_for` searches "*::Job"
- Job = Class.new(BenchmarkDriver::DefaultJob)
-
- # Dynamically fetched and used by `BenchmarkDriver::JobParser.parse`
- JobParser = BenchmarkDriver::DefaultJobParser.for(klass: Job, metrics: [METRIC]).extend(Module.new{
- def parse(**)
- jobs = super
- jobs.map do |job|
- job = job.dup
- job.prelude = "#{job.prelude}\n#{<<~EOS}"
- if defined?(RubyVM::MJIT) && RubyVM::MJIT.enabled?
- __bmdv_ruby_i = 0
- while __bmdv_ruby_i < 10000 # MJIT call threshold
- #{job.script}
- __bmdv_ruby_i += 1
- end
- RubyVM::MJIT.pause # compile
- #{job.script}
- RubyVM::MJIT.resume; RubyVM::MJIT.pause # recompile
- #{job.script}
- RubyVM::MJIT.resume; RubyVM::MJIT.pause # recompile 2
- end
- EOS
- job
- end
- end
- })
-end
diff --git a/benchmark/mjit_exivar.yml b/benchmark/mjit_exivar.yml
deleted file mode 100644
index 2584fa6410..0000000000
--- a/benchmark/mjit_exivar.yml
+++ /dev/null
@@ -1,18 +0,0 @@
-type: lib/benchmark_driver/runner/mjit
-prelude: |
- class Bench < Hash
- def initialize
- @exivar = nil
- end
-
- def exivar
- @exivar
- end
- end
-
- bench = Bench.new
-
-benchmark:
- mjit_exivar: bench.exivar
-
-loop_count: 200000000
diff --git a/benchmark/mjit_integer.yml b/benchmark/mjit_integer.yml
deleted file mode 100644
index a6b5c9ee16..0000000000
--- a/benchmark/mjit_integer.yml
+++ /dev/null
@@ -1,32 +0,0 @@
-type: lib/benchmark_driver/runner/mjit
-prelude: |
- def mjit_abs(int) int.abs end
- def mjit_bit_length(int) int.bit_length end
- def mjit_comp(int) ~int end
- def mjit_even?(int) int.even? end
- def mjit_integer?(int) int.integer? end
- def mjit_magnitude(int) int.magnitude end
- def mjit_odd?(int) int.odd? end
- def mjit_ord(int) int.ord end
- def mjit_size(int) int.size end
- def mjit_to_i(int) int.to_i end
- def mjit_to_int(int) int.to_int end
- def mjit_uminus(int) -int end
- def mjit_zero?(int) int.zero? end
-
-benchmark:
- - mjit_abs(-1)
- - mjit_bit_length(100)
- - mjit_comp(1)
- - mjit_even?(2)
- - mjit_integer?(0)
- - mjit_magnitude(-1)
- - mjit_odd?(1)
- - mjit_ord(1)
- - mjit_size(1)
- - mjit_to_i(1)
- - mjit_to_int(1)
- - mjit_uminus(1)
- - mjit_zero?(0)
-
-loop_count: 40000000
diff --git a/benchmark/mjit_kernel.yml b/benchmark/mjit_kernel.yml
deleted file mode 100644
index 7720e65c2c..0000000000
--- a/benchmark/mjit_kernel.yml
+++ /dev/null
@@ -1,20 +0,0 @@
-type: lib/benchmark_driver/runner/mjit
-prelude: |
- def mjit_class(obj)
- obj.class
- end
-
- def mjit_frozen?(obj)
- obj.frozen?
- end
-
- str = ""
- fstr = "".freeze
-
-benchmark:
- - mjit_class(self)
- - mjit_class(1)
- - mjit_frozen?(str)
- - mjit_frozen?(fstr)
-
-loop_count: 40000000
diff --git a/benchmark/mjit_leave.yml b/benchmark/mjit_leave.yml
deleted file mode 100644
index 9ac68b164b..0000000000
--- a/benchmark/mjit_leave.yml
+++ /dev/null
@@ -1,8 +0,0 @@
-type: lib/benchmark_driver/runner/mjit
-prelude: |
- def leave
- nil
- end
-benchmark:
- mjit_leave: leave
-loop_count: 200000000
diff --git a/benchmark/mjit_opt_cc_insns.yml b/benchmark/mjit_opt_cc_insns.yml
deleted file mode 100644
index fed6d34bd5..0000000000
--- a/benchmark/mjit_opt_cc_insns.yml
+++ /dev/null
@@ -1,27 +0,0 @@
-# opt_* insns using vm_method_cfunc_is with send-compatible operands:
-# * opt_nil_p
-# * opt_not
-# * opt_eq
-type: lib/benchmark_driver/runner/mjit
-prelude: |
- def mjit_nil?(obj)
- obj.nil?
- end
-
- def mjit_not(obj)
- !obj
- end
-
- def mjit_eq(a, b)
- a == b
- end
-
-benchmark:
- - script: mjit_nil?(1)
- loop_count: 40000000
- - script: mjit_not(1)
- loop_count: 40000000
- - script: mjit_eq(1, nil)
- loop_count: 8000000
- - script: mjit_eq(nil, 1)
- loop_count: 8000000
diff --git a/benchmark/mjit_struct_aref.yml b/benchmark/mjit_struct_aref.yml
deleted file mode 100644
index bfba1323f2..0000000000
--- a/benchmark/mjit_struct_aref.yml
+++ /dev/null
@@ -1,10 +0,0 @@
-type: lib/benchmark_driver/runner/mjit
-prelude: |
- def mjit_struct_aref(struct)
- struct.aa
- end
- struct = Struct.new(:a0, :a1, :a2, :a3, :a4, :a5, :a6, :a7, :a8, :a9, :aa).new
-
-benchmark: mjit_struct_aref(struct)
-
-loop_count: 40000000
diff --git a/benchmark/range_bsearch_bignum.yml b/benchmark/range_bsearch_bignum.yml
new file mode 100644
index 0000000000..5730c93fcf
--- /dev/null
+++ b/benchmark/range_bsearch_bignum.yml
@@ -0,0 +1,10 @@
+prelude: |
+ first = 2**100
+ last = 2**1000
+ mid = (first + last) / 2
+ r = first..last
+
+benchmark:
+ first: r.bsearch { |x| x >= first }
+ mid: r.bsearch { |x| x >= mid }
+ last: r.bsearch { |x| x >= last }
diff --git a/benchmark/range_bsearch_endpointless.yml b/benchmark/range_bsearch_endpointless.yml
new file mode 100644
index 0000000000..8d7bedb662
--- /dev/null
+++ b/benchmark/range_bsearch_endpointless.yml
@@ -0,0 +1,21 @@
+prelude: |
+ re = (1..)
+ rb = (..0)
+
+benchmark:
+ 'endless 10**0': re.bsearch { |x| x >= 1 }
+ 'endless 10**1': re.bsearch { |x| x >= 10 }
+ 'endless 10**2': re.bsearch { |x| x >= 100 }
+ 'endless 10**3': re.bsearch { |x| x >= 1000 }
+ 'endless 10**4': re.bsearch { |x| x >= 10000 }
+ 'endless 10**5': re.bsearch { |x| x >= 100000 }
+ 'endless 10**10': re.bsearch { |x| x >= 10000000000 }
+ 'endless 10**100': re.bsearch { |x| x >= 10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 }
+ 'beginless -10**0': rb.bsearch { |x| x >= -1 }
+ 'beginless -10**1': rb.bsearch { |x| x >= -10 }
+ 'beginless -10**2': rb.bsearch { |x| x >= -100 }
+ 'beginless -10**3': rb.bsearch { |x| x >= -1000 }
+ 'beginless -10**4': rb.bsearch { |x| x >= -10000 }
+ 'beginless -10**5': rb.bsearch { |x| x >= -100000 }
+ 'beginless -10**10': rb.bsearch { |x| x >= -10000000000 }
+ 'beginless -10**100': rb.bsearch { |x| x >= -10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 }
diff --git a/benchmark/range_bsearch_fixnum.yml b/benchmark/range_bsearch_fixnum.yml
new file mode 100644
index 0000000000..59416531b9
--- /dev/null
+++ b/benchmark/range_bsearch_fixnum.yml
@@ -0,0 +1,10 @@
+prelude: |
+ first = 1
+ last = 10000
+ mid = (first + last) / 2
+ r = first..last
+
+benchmark:
+ first: r.bsearch { |x| x >= first }
+ mid: r.bsearch { |x| x >= mid }
+ last: r.bsearch { |x| x >= last }
diff --git a/benchmark/range_count.yml b/benchmark/range_count.yml
new file mode 100644
index 0000000000..58f53a0236
--- /dev/null
+++ b/benchmark/range_count.yml
@@ -0,0 +1,11 @@
+prelude: |
+ r_1 = 1..1
+ r_1k = 1..1000
+ r_1m = 1..1000000
+ r_str = 'a'..'z'
+
+benchmark:
+ 'int 1': r_1.count
+ 'int 1K': r_1k.count
+ 'int 1M': r_1m.count
+ string: r_str.count
diff --git a/benchmark/range_overlap.yml b/benchmark/range_overlap.yml
new file mode 100644
index 0000000000..700a00053c
--- /dev/null
+++ b/benchmark/range_overlap.yml
@@ -0,0 +1,19 @@
+prelude: |
+ class Range
+ unless method_defined?(:overlap?)
+ def overlap?(other)
+ other.begin == self.begin || cover?(other.begin) || other.cover?(self.begin)
+ end
+ end
+ end
+
+benchmark:
+ - (2..3).overlap?(1..1)
+ - (2..3).overlap?(2..4)
+ - (2..3).overlap?(4..5)
+ - (2..3).overlap?(2..1)
+ - (2..3).overlap?(0..1)
+ - (2..3).overlap?(...1)
+ - (2...3).overlap?(..2)
+ - (2...3).overlap?(3...)
+ - (2..3).overlap?('a'..'d')
diff --git a/benchmark/range_reverse_each.yml b/benchmark/range_reverse_each.yml
new file mode 100644
index 0000000000..a32efeccc6
--- /dev/null
+++ b/benchmark/range_reverse_each.yml
@@ -0,0 +1,16 @@
+prelude: |
+ rf_1 = 0..1
+ rf_1k = 0..1000
+ rf_1m = 0..1000000
+ big = 2**1000
+ rb_1 = big..big+1
+ rb_1k = big..big+1000
+ rb_1m = big..big+1000000
+
+benchmark:
+ "Fixnum 1": rf_1.reverse_each { _1 }
+ "Fixnum 1K": rf_1k.reverse_each { _1 }
+ "Fixnum 1M": rf_1m.reverse_each { _1 }
+ "Bignum 1": rb_1.reverse_each { _1 }
+ "Bignum 1K": rb_1k.reverse_each { _1 }
+ "Bignum 1M": rb_1m.reverse_each { _1 }
diff --git a/benchmark/regexp_dup.yml b/benchmark/regexp_dup.yml
new file mode 100644
index 0000000000..52f89991cd
--- /dev/null
+++ b/benchmark/regexp_dup.yml
@@ -0,0 +1,6 @@
+prelude: |
+ str = "a" * 1000
+ re = Regexp.new(str)
+
+benchmark:
+ dup: re.dup
diff --git a/benchmark/regexp_new.yml b/benchmark/regexp_new.yml
new file mode 100644
index 0000000000..bc9ab3ca21
--- /dev/null
+++ b/benchmark/regexp_new.yml
@@ -0,0 +1,7 @@
+prelude: |
+ str = "a" * 1000
+ re = Regexp.new(str)
+
+benchmark:
+ string: Regexp.new(str)
+ regexp: Regexp.new(re)
diff --git a/benchmark/so_count_words.yml b/benchmark/so_count_words.yml
index 99683505f9..f7322a8541 100644
--- a/benchmark/so_count_words.yml
+++ b/benchmark/so_count_words.yml
@@ -15,13 +15,13 @@ prelude: |
Newsgroups: rec.games.roguelike.nethack
X-Mailer: Mozilla 1.1N (Macintosh; I; 68K)
- Hello there, Izchak Miller was my father. When I was younger I spent
- many a night, hunched over the keyboard with a cup of tea, playing
- nethack with him and my brother. my dad was a philosopher with a strong
- weakness for fantasy/sci fi. I remember when he started to get involved
- with the Nethack team- my brother's Dungeons and Dragons monster book
- found a regular place beside my dad's desk. it's nice to see him living
- on in the game he loved so much :-).
+ Hello there, Izchak Miller was my father. When I was younger I spent
+ many a night, hunched over the keyboard with a cup of tea, playing
+ nethack with him and my brother. my dad was a philosopher with a strong
+ weakness for fantasy/sci fi. I remember when he started to get involved
+ with the Nethack team- my brother's Dungeons and Dragons monster book
+ found a regular place beside my dad's desk. it's nice to see him living
+ on in the game he loved so much :-).
Tamar Miller
The following is a really long word of 5000 characters:
@@ -38,8 +38,9 @@ prelude: |
13.times{
data << data
}
- open(wcinput, 'w'){|f| f.write data}
+ File.write(wcinput, data)
end
+ at_exit {File.unlink(wcinput) rescue nil}
end
prepare_wc_input(wc_input_base)
@@ -49,16 +50,16 @@ benchmark:
# $Id: wc-ruby.code,v 1.4 2004/11/13 07:43:32 bfulgham Exp $
# http://www.bagley.org/~doug/shootout/
# with help from Paul Brannan
- input = open(File.join(File.dirname($0), 'wc.input'), 'rb')
nl = nw = nc = 0
- while true
- tmp = input.read(4096) or break
- data = tmp << (input.gets || "")
- nc += data.length
- nl += data.count("\n")
- ((data.strip! || data).tr!("\n", " ") || data).squeeze!
- nw += data.count(" ") + 1
+ File.open(File.join(File.dirname($0), 'wc.input'), 'rb') do |input|
+ while tmp = input.read(4096)
+ data = tmp << (input.gets || "")
+ nc += data.length
+ nl += data.count("\n")
+ ((data.strip! || data).tr!("\n", " ") || data).squeeze!
+ nw += data.count(" ") + 1
+ end
end
# STDERR.puts "#{nl} #{nw} #{nc}"
diff --git a/benchmark/so_meteor_contest.rb b/benchmark/so_meteor_contest.rb
index 8c136baa6c..d8c8e3ab9c 100644
--- a/benchmark/so_meteor_contest.rb
+++ b/benchmark/so_meteor_contest.rb
@@ -447,7 +447,7 @@ end
# as an inverse. The inverse will ALWAYS be 3 one of the piece configurations that is exactly 3 rotations away
# (an odd number). Checking even vs odd then produces a higher probability of finding more pieces earlier
# in the cycle. We still need to keep checking all the permutations, but our probability of finding one will
-# diminsh over time. Since we are TOLD how many to search for this lets us exit before checking all pieces
+# diminish over time. Since we are TOLD how many to search for this lets us exit before checking all pieces
# this bennifit is very great when seeking small numbers of solutions and is 0 when looking for more than the
# maximum number
def find_top( rotation_skip)
diff --git a/benchmark/string_dup.yml b/benchmark/string_dup.yml
new file mode 100644
index 0000000000..90793f9f2a
--- /dev/null
+++ b/benchmark/string_dup.yml
@@ -0,0 +1,7 @@
+prelude: |
+ # frozen_string_literal: true
+benchmark:
+ uplus: |
+ +"A"
+ dup: |
+ "A".dup
diff --git a/benchmark/string_rpartition.yml b/benchmark/string_rpartition.yml
new file mode 100644
index 0000000000..37e9d1b071
--- /dev/null
+++ b/benchmark/string_rpartition.yml
@@ -0,0 +1,18 @@
+prelude: |
+ str1 = [*"a".."z",*"0".."9"].join("")
+ str10 = str1 * 10 + ":"
+ str100 = str1 * 100 + ":"
+ str1000 = str1 * 1000 + ":"
+ nonascii1 = [*"\u{e0}".."\u{ff}"].join("")
+ nonascii10 = nonascii1 * 10 + ":"
+ nonascii100 = nonascii1 * 100 + ":"
+ nonascii1000 = nonascii1 * 1000 + ":"
+benchmark:
+ rpartition-1: str1.rpartition(":")
+ rpartition-10: str10.rpartition(":")
+ rpartition-100: str100.rpartition(":")
+ rpartition-1000: str1000.rpartition(":")
+ rpartition-nonascii1: nonascii1.rpartition(":")
+ rpartition-nonascii10: nonascii10.rpartition(":")
+ rpartition-nonascii100: nonascii100.rpartition(":")
+ rpartition-nonascii1000: nonascii1000.rpartition(":")
diff --git a/benchmark/struct_accessor.yml b/benchmark/struct_accessor.yml
new file mode 100644
index 0000000000..61176cfdd4
--- /dev/null
+++ b/benchmark/struct_accessor.yml
@@ -0,0 +1,25 @@
+prelude: |
+ C = Struct.new(:x) do
+ class_eval <<-END
+ def r
+ #{'x;'*256}
+ end
+ def w
+ #{'self.x = nil;'*256}
+ end
+ def rm
+ m = method(:x)
+ #{'m.call;'*256}
+ end
+ def wm
+ m = method(:x=)
+ #{'m.call(nil);'*256}
+ end
+ END
+ end
+ obj = C.new(nil)
+benchmark:
+ member_reader: "obj.r"
+ member_writer: "obj.w"
+ member_reader_method: "obj.rm"
+ member_writer_method: "obj.wm"
diff --git a/benchmark/vm_call_bmethod.yml b/benchmark/vm_call_bmethod.yml
new file mode 100644
index 0000000000..40136e5aa4
--- /dev/null
+++ b/benchmark/vm_call_bmethod.yml
@@ -0,0 +1,37 @@
+prelude: |
+ define_method(:a0){}
+ define_method(:a1){|a| a}
+ define_method(:s){|*a| a}
+ define_method(:b){|kw: 1| kw}
+
+ t0 = 0.times.to_a
+ t1 = 1.times.to_a
+ t10 = 10.times.to_a
+ t100 = 100.times.to_a
+ kw = {kw: 2}
+benchmark:
+ bmethod_simple_0: |
+ a0
+ bmethod_simple_1: |
+ a1(1)
+ bmethod_simple_0_splat: |
+ a0(*t0)
+ bmethod_simple_1_splat: |
+ a1(*t1)
+ bmethod_no_splat: |
+ s
+ bmethod_0_splat: |
+ s(*t0)
+ bmethod_1_splat: |
+ s(*t1)
+ bmethod_10_splat: |
+ s(*t10)
+ bmethod_100_splat: |
+ s(*t100)
+ bmethod_kw: |
+ b(kw: 1)
+ bmethod_no_kw: |
+ b
+ bmethod_kw_splat: |
+ b(**kw)
+loop_count: 6000000
diff --git a/benchmark/vm_call_method_missing.yml b/benchmark/vm_call_method_missing.yml
new file mode 100644
index 0000000000..f890796f11
--- /dev/null
+++ b/benchmark/vm_call_method_missing.yml
@@ -0,0 +1,62 @@
+prelude: |
+ class A0
+ def method_missing(m); m end
+ end
+ class A1
+ def method_missing(m, a) a; end
+ end
+ class S
+ def method_missing(m, *a) a; end
+ end
+ class B
+ def method_missing(m, kw: 1) kw end
+ end
+ class SB
+ def method_missing(m, *a, kw: 1) kw end
+ end
+
+ t0 = 0.times.to_a
+ t1 = 1.times.to_a
+ t10 = 10.times.to_a
+ t200 = 200.times.to_a
+ kw = {kw: 2}
+
+ a0 = A0.new
+ a1 = A1.new
+ s = S.new
+ b = B.new
+ sb = SB.new
+benchmark:
+ method_missing_simple_0: |
+ a0.()
+ method_missing_simple_1: |
+ a1.x(1)
+ method_missing_simple_0_splat: |
+ a0.(*t0)
+ method_missing_simple_1_splat: |
+ a1.(*t1)
+ method_missing_no_splat: |
+ s.()
+ method_missing_0_splat: |
+ s.(*t0)
+ method_missing_1_splat: |
+ s.(*t1)
+ method_missing_10_splat: |
+ s.(*t10)
+ method_missing_200_splat: |
+ s.(*t200)
+ method_missing_kw: |
+ b.(kw: 1)
+ method_missing_no_kw: |
+ b.()
+ method_missing_kw_splat: |
+ b.(**kw)
+ method_missing_0_splat_kw: |
+ sb.(*t0, **kw)
+ method_missing_1_splat_kw: |
+ sb.(*t1, **kw)
+ method_missing_10_splat_kw: |
+ sb.(*t10, **kw)
+ method_missing_200_splat_kw: |
+ sb.(*t200, **kw)
+loop_count: 1000000
diff --git a/benchmark/vm_call_send_iseq.yml b/benchmark/vm_call_send_iseq.yml
new file mode 100644
index 0000000000..60ff23c475
--- /dev/null
+++ b/benchmark/vm_call_send_iseq.yml
@@ -0,0 +1,77 @@
+prelude: |
+ def a0; end
+ def a1(a) a; end
+ def s(*a) a; end
+ def b(kw: 1) kw end
+ def sb(*a, kw: 1) kw end
+
+ t0 = 0.times.to_a
+ t1 = 1.times.to_a
+ t10 = 10.times.to_a
+ t200 = 200.times.to_a
+
+ a0_t0 = [:a0, *t0]
+ a1_t1 = [:a1, *t1]
+ s_t0 = [:s, *t0]
+ s_t1 = [:s, *t1]
+ s_t10 = [:s, *t10]
+ s_t200 = [:s, *t200]
+ sb_t0 = [:sb, *t0]
+ sb_t1 = [:sb, *t1]
+ sb_t10 = [:sb, *t10]
+ sb_t200 = [:sb, *t200]
+ kw = {kw: 2}
+benchmark:
+ send_simple_0: |
+ send(:a0)
+ send_simple_1: |
+ send(:a1, 1)
+ send_simple_0_splat: |
+ send(:a0, *t0)
+ send_simple_1_splat: |
+ send(:a1, *t1)
+ send_simple_0_splat_comb: |
+ send(*a0_t0)
+ send_simple_1_splat_comb: |
+ send(*a1_t1)
+ send_no_splat: |
+ send(:s)
+ send_0_splat: |
+ send(:s, *t0)
+ send_1_splat: |
+ send(:s, *t1)
+ send_10_splat: |
+ send(:s, *t10)
+ send_200_splat: |
+ send(:s, *t200)
+ send_0_splat_comb: |
+ send(*s_t0)
+ send_1_splat_comb: |
+ send(*s_t1)
+ send_10_splat_comb: |
+ send(*s_t10)
+ send_200_splat_comb: |
+ send(*s_t200)
+ send_kw: |
+ send(:b, kw: 1)
+ send_no_kw: |
+ send(:b)
+ send_kw_splat: |
+ send(:b, **kw)
+ send_0_splat_kw: |
+ send(:sb, *t0, **kw)
+ send_1_splat_kw: |
+ send(:sb, *t1, **kw)
+ send_10_splat_kw: |
+ send(:sb, *t10, **kw)
+ send_200_splat_kw: |
+ send(:sb, *t200, **kw)
+ send_0_splat_comb_kw: |
+ send(*sb_t0, **kw)
+ send_1_splat_comb_kw: |
+ send(*sb_t1, **kw)
+ send_10_splat_comb_kw: |
+ send(*sb_t10, **kw)
+ send_200_splat_comb_kw: |
+ send(*sb_t200, **kw)
+loop_count: 3000000
diff --git a/benchmark/vm_call_symproc.yml b/benchmark/vm_call_symproc.yml
new file mode 100644
index 0000000000..16e0ac579e
--- /dev/null
+++ b/benchmark/vm_call_symproc.yml
@@ -0,0 +1,83 @@
+prelude: |
+ def self.a0; end
+ def self.a1(a) a; end
+ def self.s(*a) a; end
+ def self.b(kw: 1) kw end
+ def self.sb(*a, kw: 1) kw end
+
+ t0 = 0.times.to_a
+ t1 = 1.times.to_a
+ t10 = 10.times.to_a
+ t200 = 200.times.to_a
+
+ a0_t0 = [self, *t0]
+ a1_t1 = [self, *t1]
+ s_t0 = [self, *t0]
+ s_t1 = [self, *t1]
+ s_t10 = [self, *t10]
+ s_t200 = [self, *t200]
+ sb_t0 = [self, *t0]
+ sb_t1 = [self, *t1]
+ sb_t10 = [self, *t10]
+ sb_t200 = [self, *t200]
+ kw = {kw: 2}
+
+ a0 = :a0.to_proc
+ a1 = :a1.to_proc
+ s = :s.to_proc
+ b = :b.to_proc
+ sb = :sb.to_proc
+benchmark:
+ symproc_simple_0: |
+ a0.(self)
+ symproc_simple_1: |
+ a1.(self, 1)
+ symproc_simple_0_splat: |
+ a0.(self, *t0)
+ symproc_simple_1_splat: |
+ a1.(self, *t1)
+ symproc_simple_0_splat_comb: |
+ a0.(*a0_t0)
+ symproc_simple_1_splat_comb: |
+ a1.(*a1_t1)
+ symproc_no_splat: |
+ s.(self)
+ symproc_0_splat: |
+ s.(self, *t0)
+ symproc_1_splat: |
+ s.(self, *t1)
+ symproc_10_splat: |
+ s.(self, *t10)
+ symproc_200_splat: |
+ s.(self, *t200)
+ symproc_0_splat_comb: |
+ s.(*s_t0)
+ symproc_1_splat_comb: |
+ s.(*s_t1)
+ symproc_10_splat_comb: |
+ s.(*s_t10)
+ symproc_200_splat_comb: |
+ s.(*s_t200)
+ symproc_kw: |
+ b.(self, kw: 1)
+ symproc_no_kw: |
+ b.(self)
+ symproc_kw_splat: |
+ b.(self, **kw)
+ symproc_0_splat_kw: |
+ sb.(self, *t0, **kw)
+ symproc_1_splat_kw: |
+ sb.(self, *t1, **kw)
+ symproc_10_splat_kw: |
+ sb.(self, *t10, **kw)
+ symproc_200_splat_kw: |
+ sb.(self, *t200, **kw)
+ symproc_0_splat_comb_kw: |
+ sb.(*sb_t0, **kw)
+ symproc_1_splat_comb_kw: |
+ sb.(*sb_t1, **kw)
+ symproc_10_splat_comb_kw: |
+ sb.(*sb_t10, **kw)
+ symproc_200_splat_comb_kw: |
+ sb.(*sb_t200, **kw)
+loop_count: 1000000
diff --git a/benchmark/vm_ivar_ic_miss.yml b/benchmark/vm_ivar_ic_miss.yml
new file mode 100644
index 0000000000..944fb1a9e6
--- /dev/null
+++ b/benchmark/vm_ivar_ic_miss.yml
@@ -0,0 +1,20 @@
+prelude: |
+ class Foo
+ def initialize diverge
+ if diverge
+ @a = 1
+ end
+
+ @a0 = @a1 = @a2 = @a3 = @a4 = @a5 = @a6 = @a7 = @a8 = @a9 = @a10 = @a11 = @a12 = @a13 = @a14 = @a15 = @a16 = @a17 = @a18 = @a19 = @a20 = @a21 = @a22 = @a23 = @a24 = @a25 = @a26 = @a27 = @a28 = @a29 = @a30 = @a31 = @a32 = @a33 = @a34 = @a35 = @a36 = @a37 = @a38 = @a39 = @a40 = @a41 = @a42 = @a43 = @a44 = @a45 = @a46 = @a47 = @a48 = @a49 = @a50 = @a51 = @a52 = @a53 = @a54 = @a55 = @a56 = @a57 = @a58 = @a59 = @a60 = @a61 = @a62 = @a63 = @a64 = @a65 = @a66 = @a67 = @a68 = @a69 = @a70 = @a71 = @a72 = @a73 = @a74 = @b = 1
+ end
+
+ def b; @b; end
+ end
+
+ a = Foo.new false
+ b = Foo.new true
+benchmark:
+ vm_ivar_ic_miss: |
+ a.b
+ b.b
+loop_count: 30000000
diff --git a/benchmark/vm_ivar_memoize.yml b/benchmark/vm_ivar_memoize.yml
new file mode 100644
index 0000000000..90f6b07f05
--- /dev/null
+++ b/benchmark/vm_ivar_memoize.yml
@@ -0,0 +1,85 @@
+prelude: |
+ IVARS = 60
+ class Record
+ def initialize(offset = false)
+ @offset = 1 if offset
+ @first = 0
+ IVARS.times do |i|
+ instance_variable_set("@ivar_#{i}", i)
+ end
+ end
+
+ def first
+ @first
+ end
+
+ def lazy_set
+ @lazy_set ||= 123
+ end
+
+ def undef
+ @undef
+ end
+ end
+
+ Record.new # Need one alloc to right size
+
+ BASE = Record.new
+ LAZY = Record.new
+ LAZY.lazy_set
+
+ class Miss < Record
+ @first = 0
+ IVARS.times do |i|
+ instance_variable_set("@i_#{i}", i)
+ end
+ end
+
+ Miss.new # Need one alloc to right size
+ MISS = Miss.new
+
+ DIVERGENT = Record.new(true)
+
+benchmark:
+ vm_ivar_stable_shape: |
+ BASE.first
+ BASE.first
+ BASE.first
+ BASE.first
+ BASE.first
+ BASE.first
+ vm_ivar_memoize_unstable_shape: |
+ BASE.first
+ LAZY.first
+ BASE.first
+ LAZY.first
+ BASE.first
+ LAZY.first
+ vm_ivar_memoize_unstable_shape_miss: |
+ BASE.first
+ MISS.first
+ BASE.first
+ MISS.first
+ BASE.first
+ MISS.first
+ vm_ivar_unstable_undef: |
+ BASE.undef
+ LAZY.undef
+ BASE.undef
+ LAZY.undef
+ BASE.undef
+ LAZY.undef
+ vm_ivar_divergent_shape: |
+ BASE.first
+ DIVERGENT.first
+ BASE.first
+ DIVERGENT.first
+ BASE.first
+ DIVERGENT.first
+ vm_ivar_divergent_shape_imbalanced: |
+ BASE.first
+ DIVERGENT.first
+ DIVERGENT.first
+ DIVERGENT.first
+ DIVERGENT.first
+ DIVERGENT.first
diff --git a/benchmark/vm_method_splat_calls.yml b/benchmark/vm_method_splat_calls.yml
new file mode 100644
index 0000000000..f2f366e99c
--- /dev/null
+++ b/benchmark/vm_method_splat_calls.yml
@@ -0,0 +1,13 @@
+prelude: |
+ def f(x=0, y: 0) end
+ a = [1]
+ ea = []
+ kw = {y: 1}
+ b = lambda{}
+benchmark:
+ arg_splat: "f(1, *ea)"
+ arg_splat_block: "f(1, *ea, &b)"
+ splat_kw_splat: "f(*a, **kw)"
+ splat_kw_splat_block: "f(*a, **kw, &b)"
+ splat_kw: "f(*a, y: 1)"
+ splat_kw_block: "f(*a, y: 1, &b)"
diff --git a/benchmark/vm_send_cfunc.yml b/benchmark/vm_send_cfunc.yml
index b114ac317d..6f12b65176 100644
--- a/benchmark/vm_send_cfunc.yml
+++ b/benchmark/vm_send_cfunc.yml
@@ -1,3 +1,14 @@
+prelude: |
+ ary = []
+ kw = {a: 1}
+ empty_kw = {}
+ kw_ary = [Hash.ruby2_keywords_hash(a: 1)]
+ empty_kw_ary = [Hash.ruby2_keywords_hash({})]
benchmark:
- vm_send_cfunc: self.class
-loop_count: 100000000
+ vm_send_cfunc: itself
+ vm_send_cfunc_splat: itself(*ary)
+ vm_send_cfunc_splat_kw_hash: equal?(*kw_ary)
+ vm_send_cfunc_splat_empty_kw_hash: itself(*empty_kw_ary)
+ vm_send_cfunc_splat_kw: equal?(*ary, **kw)
+ vm_send_cfunc_splat_empty_kw: itself(*ary, **empty_kw)
+loop_count: 20000000
diff --git a/bignum.c b/bignum.c
index cb2c3b6f07..e9bf37d206 100644
--- a/bignum.c
+++ b/bignum.c
@@ -48,6 +48,14 @@
#include "ruby/util.h"
#include "ruby_assert.h"
+static const bool debug_integer_pack = (
+#ifdef DEBUG_INTEGER_PACK
+ DEBUG_INTEGER_PACK+0
+#else
+ RUBY_DEBUG
+#endif
+ ) != 0;
+
const char ruby_digitmap[] = "0123456789abcdefghijklmnopqrstuvwxyz";
#ifndef SIZEOF_BDIGIT_DBL
@@ -1049,15 +1057,13 @@ integer_unpack_num_bdigits(size_t numwords, size_t wordsize, size_t nails, int *
if (numwords <= (SIZE_MAX - (BITSPERDIG-1)) / CHAR_BIT / wordsize) {
num_bdigits = integer_unpack_num_bdigits_small(numwords, wordsize, nails, nlp_bits_ret);
-#ifdef DEBUG_INTEGER_PACK
- {
+ if (debug_integer_pack) {
int nlp_bits1;
size_t num_bdigits1 = integer_unpack_num_bdigits_generic(numwords, wordsize, nails, &nlp_bits1);
assert(num_bdigits == num_bdigits1);
assert(*nlp_bits_ret == nlp_bits1);
(void)num_bdigits1;
}
-#endif
}
else {
num_bdigits = integer_unpack_num_bdigits_generic(numwords, wordsize, nails, nlp_bits_ret);
@@ -3023,7 +3029,8 @@ rb_big_resize(VALUE big, size_t len)
static VALUE
bignew_1(VALUE klass, size_t len, int sign)
{
- NEWOBJ_OF(big, struct RBignum, klass, T_BIGNUM | (RGENGC_WB_PROTECTED_BIGNUM ? FL_WB_PROTECTED : 0));
+ NEWOBJ_OF(big, struct RBignum, klass,
+ T_BIGNUM | (RGENGC_WB_PROTECTED_BIGNUM ? FL_WB_PROTECTED : 0), sizeof(struct RBignum), 0);
VALUE bigv = (VALUE)big;
BIGNUM_SET_SIGN(bigv, sign);
if (len <= BIGNUM_EMBED_LEN_MAX) {
@@ -3422,15 +3429,13 @@ rb_absint_numwords(VALUE val, size_t word_numbits, size_t *nlz_bits_ret)
if (numbytes <= SIZE_MAX / CHAR_BIT) {
numwords = absint_numwords_small(numbytes, nlz_bits_in_msbyte, word_numbits, &nlz_bits);
-#ifdef DEBUG_INTEGER_PACK
- {
+ if (debug_integer_pack) {
size_t numwords0, nlz_bits0;
numwords0 = absint_numwords_generic(numbytes, nlz_bits_in_msbyte, word_numbits, &nlz_bits0);
assert(numwords0 == numwords);
assert(nlz_bits0 == nlz_bits);
(void)numwords0;
}
-#endif
}
else {
numwords = absint_numwords_generic(numbytes, nlz_bits_in_msbyte, word_numbits, &nlz_bits);
@@ -4541,7 +4546,7 @@ rb_uint128t2big(uint128_t n)
return big;
}
-MJIT_FUNC_EXPORTED VALUE
+VALUE
rb_int128t2big(int128_t n)
{
int neg = 0;
diff --git a/bin/gem b/bin/gem
index 1c16ea7ddd..3ac1d9e623 100755
--- a/bin/gem
+++ b/bin/gem
@@ -1,4 +1,6 @@
#!/usr/bin/env ruby
+# frozen_string_literal: true
+
#--
# Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others.
# All rights reserved.
diff --git a/bootstraptest/runner.rb b/bootstraptest/runner.rb
index f9b3e919b8..a34527d2fa 100755
--- a/bootstraptest/runner.rb
+++ b/bootstraptest/runner.rb
@@ -118,7 +118,7 @@ BT = Class.new(bt) do
r = IO.for_fd($1.to_i(10), "rb", autoclose: false)
w = IO.for_fd($2.to_i(10), "wb", autoclose: false)
end
- rescue => e
+ rescue
r.close if r
else
r.close_on_exec = true
@@ -552,8 +552,13 @@ class Assertion < Struct.new(:src, :path, :lineno, :proc)
filename = "bootstraptest.#{self.path}_#{self.lineno}_#{self.id}.rb"
File.open(filename, 'w') {|f|
f.puts "#frozen_string_literal:true" if frozen_string_literal
- f.puts "GC.stress = true" if $stress
- f.puts "print(begin; #{self.src}; end)"
+ if $stress
+ f.puts "GC.stress = true" if $stress
+ else
+ f.puts ""
+ end
+ f.puts "class BT_Skip < Exception; end; def skip(msg) = raise(BT_Skip, msg.to_s)"
+ f.puts "print(begin; #{self.src}; rescue BT_Skip; $!.message; end)"
}
filename
end
@@ -669,7 +674,7 @@ end
def assert_finish(timeout_seconds, testsrc, message = '')
add_assertion testsrc, -> as do
- if defined?(RubyVM::MJIT) && RubyVM::MJIT.enabled? # for --jit-wait
+ if defined?(RubyVM::RJIT) && RubyVM::RJIT.enabled? # for --jit-wait
timeout_seconds *= 3
end
@@ -784,4 +789,9 @@ def check_coredump
end
end
+def rjit_enabled?
+ # Don't check `RubyVM::RJIT.enabled?`. On btest-bruby, target Ruby != runner Ruby.
+ ENV.fetch('RUN_OPTS', '').include?('rjit')
+end
+
exit main
diff --git a/bootstraptest/test_eval.rb b/bootstraptest/test_eval.rb
index a9f389c673..47e2924846 100644
--- a/bootstraptest/test_eval.rb
+++ b/bootstraptest/test_eval.rb
@@ -227,6 +227,16 @@ assert_equal %q{[10, main]}, %q{
}, '[ruby-dev:31372]'
end
+assert_normal_exit %{
+ $stderr = STDOUT
+ 5000.times do
+ begin
+ eval "0 rescue break"
+ rescue SyntaxError
+ end
+ end
+}
+
assert_normal_exit %q{
$stderr = STDOUT
class Foo
diff --git a/bootstraptest/test_gc.rb b/bootstraptest/test_gc.rb
index eb68c9845e..17bc497822 100644
--- a/bootstraptest/test_gc.rb
+++ b/bootstraptest/test_gc.rb
@@ -14,7 +14,7 @@ ms = "a".."k"
o.send(meth)
end
end
-}, '[ruby-dev:39453]'
+}, '[ruby-dev:39453]' unless rjit_enabled? # speed up RJIT CI
assert_normal_exit %q{
a = []
diff --git a/bootstraptest/test_insns.rb b/bootstraptest/test_insns.rb
index 91fba9b011..d2e799f855 100644
--- a/bootstraptest/test_insns.rb
+++ b/bootstraptest/test_insns.rb
@@ -214,9 +214,11 @@ tests = [
'true'.freeze
},
- [ 'opt_newarray_max', %q{ [ ].max.nil? }, ],
- [ 'opt_newarray_max', %q{ [1, x = 2, 3].max == 3 }, ],
- [ 'opt_newarray_max', <<-'},', ], # {
+ [ 'opt_newarray_send', %q{ ![ ].hash.nil? }, ],
+
+ [ 'opt_newarray_send', %q{ [ ].max.nil? }, ],
+ [ 'opt_newarray_send', %q{ [1, x = 2, 3].max == 3 }, ],
+ [ 'opt_newarray_send', <<-'},', ], # {
class Array
def max
true
@@ -224,9 +226,9 @@ tests = [
end
[1, x = 2, 3].max
},
- [ 'opt_newarray_min', %q{ [ ].min.nil? }, ],
- [ 'opt_newarray_min', %q{ [3, x = 2, 1].min == 1 }, ],
- [ 'opt_newarray_min', <<-'},', ], # {
+ [ 'opt_newarray_send', %q{ [ ].min.nil? }, ],
+ [ 'opt_newarray_send', %q{ [3, x = 2, 1].min == 1 }, ],
+ [ 'opt_newarray_send', <<-'},', ], # {
class Array
def min
true
diff --git a/bootstraptest/test_load.rb b/bootstraptest/test_load.rb
index e63c93a8f4..3253582a32 100644
--- a/bootstraptest/test_load.rb
+++ b/bootstraptest/test_load.rb
@@ -12,7 +12,7 @@ assert_equal 'ok', %q{
}
}.map {|t| t.value }
vs[0] == M && vs[1] == M ? :ok : :ng
-}, '[ruby-dev:32048]'
+}, '[ruby-dev:32048]' unless ENV.fetch('RUN_OPTS', '').include?('rjit') # Thread seems to be switching during JIT. To be fixed later.
assert_equal 'ok', %q{
%w[a a/foo b].each {|d| Dir.mkdir(d)}
diff --git a/bootstraptest/test_method.rb b/bootstraptest/test_method.rb
index 04c9eb2d11..964bf39d98 100644
--- a/bootstraptest/test_method.rb
+++ b/bootstraptest/test_method.rb
@@ -1190,3 +1190,12 @@ assert_equal 'DC', %q{
test2 o1, [], block
$result.join
}
+
+assert_equal 'ok', %q{
+ def foo
+ binding
+ ["ok"].first
+ end
+ foo
+ foo
+}, '[Bug #20178]'
diff --git a/bootstraptest/test_ractor.rb b/bootstraptest/test_ractor.rb
index 459ba260e9..4383795dc1 100644
--- a/bootstraptest/test_ractor.rb
+++ b/bootstraptest/test_ractor.rb
@@ -283,9 +283,7 @@ assert_equal 30.times.map { 'ok' }.to_s, %q{
30.times.map{|i|
test i
}
-} unless ENV['RUN_OPTS'] =~ /--mjit-call-threshold=5/ || # This always fails with --mjit-wait --mjit-call-threshold=5
- (ENV.key?('TRAVIS') && ENV['TRAVIS_CPU_ARCH'] == 'arm64') || # https://bugs.ruby-lang.org/issues/17878
- true # too flaky everywhere http://ci.rvm.jp/results/trunk@ruby-sp1/4321096
+} unless (ENV.key?('TRAVIS') && ENV['TRAVIS_CPU_ARCH'] == 'arm64') # https://bugs.ruby-lang.org/issues/17878
# Exception for empty select
assert_match /specify at least one ractor/, %q{
@@ -480,7 +478,6 @@ assert_equal 'ok', %q{
}
# multiple Ractors can receive (wait) from one Ractor
-yjit_enabled = ENV.key?('RUBY_YJIT_ENABLE') || ENV.fetch('RUN_OPTS', '').include?('yjit')
assert_equal '[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]', %q{
pipe = Ractor.new do
loop do
@@ -503,8 +500,7 @@ assert_equal '[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]', %q{
rs.delete r
n
}.sort
-} unless /mswin/ =~ RUBY_PLATFORM || # randomly hangs on mswin https://github.com/ruby/ruby/actions/runs/3753871445/jobs/6377551069#step:20:131
- yjit_enabled # flaky with YJIT https://github.com/ruby/ruby/actions/runs/3603398545/jobs/6071549328#step:18:33
+} unless /mswin/ =~ RUBY_PLATFORM # randomly hangs on mswin https://github.com/ruby/ruby/actions/runs/3753871445/jobs/6377551069#step:20:131
# Ractor.select also support multiple take, receive and yield
assert_equal '[true, true, true]', %q{
@@ -518,9 +514,9 @@ assert_equal '[true, true, true]', %q{
end
}
received = []
- take = []
+ taken = []
yielded = []
- until rs.empty?
+ until received.size == RN && taken.size == RN && yielded.size == RN
r, v = Ractor.select(CR, *rs, yield_value: 'yield')
case r
when :receive
@@ -528,11 +524,17 @@ assert_equal '[true, true, true]', %q{
when :yield
yielded << v
else
- take << v
+ taken << v
rs.delete r
end
end
- [received.all?('sendyield'), yielded.all?(nil), take.all?('take')]
+ r = [received == ['sendyield'] * RN,
+ yielded == [nil] * RN,
+ taken == ['take'] * RN,
+ ]
+
+ STDERR.puts [received, yielded, taken].inspect
+ r
}
# multiple Ractors can send to one Ractor
@@ -1399,7 +1401,7 @@ assert_equal '[false, false, true, true]', %q{
}
# TracePoint with normal Proc should be Ractor local
-assert_equal '[4, 8]', %q{
+assert_equal '[6, 10]', %q{
rs = []
TracePoint.new(:line){|tp| rs << tp.lineno if tp.path == __FILE__}.enable do
Ractor.new{ # line 4
@@ -1488,12 +1490,13 @@ assert_equal "#{n}#{n}", %Q{
end
end
}.map{|r| r.take}.join
-} unless yjit_enabled # flaky with YJIT https://github.com/ruby/ruby/actions/runs/3692339025/jobs/6251137785
+}
# NameError
assert_equal "ok", %q{
+ obj = "".freeze # NameError refers the receiver indirectly
begin
- bar
+ obj.bar
rescue => err
end
begin
@@ -1529,7 +1532,7 @@ assert_equal "ok", %q{
1_000.times { idle_worker, tmp_reporter = Ractor.select(*workers) }
"ok"
-} unless yjit_enabled # flaky with YJIT https://github.com/ruby/ruby/actions/runs/3575374374/jobs/6011846425
+} unless ENV['RUN_OPTS'] =~ /rjit/ # flaky
assert_equal "ok", %q{
def foo(*); ->{ super }; end
@@ -1567,6 +1570,7 @@ assert_equal "ok", %q{
end
}
+# check method cache invalidation
assert_equal "ok", %q{
module M
def foo
@@ -1606,10 +1610,166 @@ assert_equal "ok", %q{
"ok"
}
+# check method cache invalidation
+assert_equal 'true', %q{
+ class C1; def self.foo = 1; end
+ class C2; def self.foo = 2; end
+ class C3; def self.foo = 3; end
+ class C4; def self.foo = 5; end
+ class C5; def self.foo = 7; end
+ class C6; def self.foo = 11; end
+ class C7; def self.foo = 13; end
+ class C8; def self.foo = 17; end
+
+ LN = 10_000
+ RN = 10
+ CS = [C1, C2, C3, C4, C5, C6, C7, C8]
+ rs = RN.times.map{|i|
+ Ractor.new(CS.shuffle){|cs|
+ LN.times.sum{
+ cs.inject(1){|r, c| r * c.foo} # c.foo invalidates method cache entry
+ }
+ }
+ }
+
+ n = CS.inject(1){|r, c| r * c.foo} * LN
+ rs.map{|r| r.take} == Array.new(RN){n}
+}
+
+# check experimental warning
assert_match /\Atest_ractor\.rb:1:\s+warning:\s+Ractor is experimental/, %q{
Warning[:experimental] = $VERBOSE = true
STDERR.reopen(STDOUT)
eval("Ractor.new{}.take", nil, "test_ractor.rb", 1)
}
+# check moved object
+assert_equal 'ok', %q{
+ r = Ractor.new do
+ Ractor.receive
+ GC.start
+ :ok
+ end
+
+ obj = begin
+ raise
+ rescue => e
+ e = Marshal.load(Marshal.dump(e))
+ end
+
+ r.send obj, move: true
+ r.take
+}
+
+## Ractor::Selector
+
+# Selector#empty? returns true
+assert_equal 'true', %q{
+ skip true unless defined? Ractor::Selector
+
+ s = Ractor::Selector.new
+ s.empty?
+}
+
+# Selector#empty? returns false if there is target ractors
+assert_equal 'false', %q{
+ skip false unless defined? Ractor::Selector
+
+ s = Ractor::Selector.new
+ s.add Ractor.new{}
+ s.empty?
+}
+
+# Selector#clear removes all ractors from the waiting list
+assert_equal 'true', %q{
+ skip true unless defined? Ractor::Selector
+
+ s = Ractor::Selector.new
+ s.add Ractor.new{10}
+ s.add Ractor.new{20}
+ s.clear
+ s.empty?
+}
+
+# Selector#wait can wait multiple ractors
+assert_equal '[10, 20, true]', %q{
+ skip [10, 20, true] unless defined? Ractor::Selector
+
+ s = Ractor::Selector.new
+ s.add Ractor.new{10}
+ s.add Ractor.new{20}
+ r, v = s.wait
+ vs = []
+ vs << v
+ r, v = s.wait
+ vs << v
+ [*vs.sort, s.empty?]
+} if defined? Ractor::Selector
+
+# Selector#wait can wait multiple ractors with receiving.
+assert_equal '30', %q{
+ skip 30 unless defined? Ractor::Selector
+
+ RN = 30
+ rs = RN.times.map{
+ Ractor.new{ :v }
+ }
+ s = Ractor::Selector.new(*rs)
+
+ results = []
+ until s.empty?
+ results << s.wait
+
+ # Note that s.wait can raise an exception because other Ractors/Threads
+ # can take from the same ractors in the waiting set.
+ # In this case there is no other takers so `s.wait` doesn't raise an error.
+ end
+
+ results.size
+} if defined? Ractor::Selector
+
+# Selector#wait can support dynamic addition
+yjit_enabled = ENV.key?('RUBY_YJIT_ENABLE') || ENV.fetch('RUN_OPTS', '').include?('yjit') || BT.ruby.include?('yjit')
+assert_equal '600', %q{
+ skip 600 unless defined? Ractor::Selector
+
+ RN = 100
+ s = Ractor::Selector.new
+ rs = RN.times.map{
+ Ractor.new{
+ Ractor.main << Ractor.new{ Ractor.yield :v3; :v4 }
+ Ractor.main << Ractor.new{ Ractor.yield :v5; :v6 }
+ Ractor.yield :v1
+ :v2
+ }
+ }
+
+ rs.each{|r| s.add(r)}
+ h = {v1: 0, v2: 0, v3: 0, v4: 0, v5: 0, v6: 0}
+
+ loop do
+ case s.wait receive: true
+ in :receive, r
+ s.add r
+ in r, v
+ h[v] += 1
+ break if h.all?{|k, v| v == RN}
+ end
+ end
+
+ h.sum{|k, v| v}
+} unless yjit_enabled # http://ci.rvm.jp/results/trunk-yjit@ruby-sp2-docker/4466770
+
+# Selector should be GCed (free'ed) without trouble
+assert_equal 'ok', %q{
+ skip :ok unless defined? Ractor::Selector
+
+ RN = 30
+ rs = RN.times.map{
+ Ractor.new{ :v }
+ }
+ s = Ractor::Selector.new(*rs)
+ :ok
+}
+
end # if !ENV['GITHUB_WORKFLOW']
diff --git a/bootstraptest/test_rjit.rb b/bootstraptest/test_rjit.rb
new file mode 100644
index 0000000000..e123f35160
--- /dev/null
+++ b/bootstraptest/test_rjit.rb
@@ -0,0 +1,58 @@
+# VM_CALL_OPT_SEND + VM_METHOD_TYPE_ATTRSET
+assert_equal '1', %q{
+ class Foo
+ attr_writer :foo
+
+ def bar
+ send(:foo=, 1)
+ end
+ end
+
+ Foo.new.bar
+}
+
+# VM_CALL_OPT_SEND + OPTIMIZED_METHOD_TYPE_CALL
+assert_equal 'foo', %q{
+ def bar(&foo)
+ foo.send(:call)
+ end
+
+ bar { :foo }
+}
+
+# VM_CALL_OPT_SEND + OPTIMIZED_METHOD_TYPE_STRUCT_AREF
+assert_equal 'bar', %q{
+ def bar(foo)
+ foo.send(:bar)
+ end
+
+ bar(Struct.new(:bar).new(:bar))
+}
+
+# kwargs default w/ checkkeyword + locals (which shouldn't overwrite unspecified_bits)
+assert_equal '1', %q{
+ def foo(bar: 1.to_s)
+ _ = 1
+ bar
+ end
+
+ def entry
+ foo
+ end
+
+ entry
+}
+
+# Updating local type in Context
+assert_normal_exit %q{
+ def foo(flag, object)
+ klass = if flag
+ object
+ end
+ klass ||= object
+ return klass.new
+ end
+
+ foo(false, Object)
+ foo(true, Object)
+}
diff --git a/bootstraptest/test_syntax.rb b/bootstraptest/test_syntax.rb
index 948e2d7809..59fdae651f 100644
--- a/bootstraptest/test_syntax.rb
+++ b/bootstraptest/test_syntax.rb
@@ -535,8 +535,8 @@ assert_syntax_error "unterminated string meets end of file", '().."', '[ruby-dev
assert_equal %q{[]}, %q{$&;[]}, '[ruby-dev:31068]'
assert_syntax_error "syntax error, unexpected *, expecting '}'", %q{{*0}}, '[ruby-dev:31072]'
assert_syntax_error "`@0' is not allowed as an instance variable name", %q{@0..0}, '[ruby-dev:31095]'
-assert_syntax_error "identifier $00 is not valid to get", %q{$00..0}, '[ruby-dev:31100]'
-assert_syntax_error "identifier $00 is not valid to set", %q{0..$00=1}
+assert_syntax_error "`$00' is not allowed as a global variable name", %q{$00..0}, '[ruby-dev:31100]'
+assert_syntax_error "`$00' is not allowed as a global variable name", %q{0..$00=1}
assert_equal %q{0}, %q{[*0];0}, '[ruby-dev:31102]'
assert_syntax_error "syntax error, unexpected ')'", %q{v0,(*,v1,) = 0}, '[ruby-dev:31104]'
assert_equal %q{1}, %q{
diff --git a/bootstraptest/test_thread.rb b/bootstraptest/test_thread.rb
index 5361828403..a4d46e2f10 100644
--- a/bootstraptest/test_thread.rb
+++ b/bootstraptest/test_thread.rb
@@ -242,6 +242,20 @@ assert_equal 'true', %{
end
}
+assert_equal 'true', %{
+ Thread.new{}.join
+ begin
+ Process.waitpid2 fork{
+ Thread.new{
+ sleep 0.1
+ }.join
+ }
+ true
+ rescue NotImplementedError
+ true
+ end
+}
+
assert_equal 'ok', %{
open("zzz_t1.rb", "w") do |f|
f.puts <<-END
@@ -289,7 +303,7 @@ assert_normal_exit %q{
}.each {|t|
t.join
}
-}
+} unless rjit_enabled? # flaky
assert_equal 'ok', %q{
def m
@@ -483,7 +497,7 @@ assert_equal 'foo', %q{
[th1, th2].each {|t| t.join }
GC.start
f.call.source
-}
+} unless rjit_enabled? # flaky
assert_normal_exit %q{
class C
def inspect
diff --git a/bootstraptest/test_yjit.rb b/bootstraptest/test_yjit.rb
index cbb3f145b0..c0f382fc37 100644
--- a/bootstraptest/test_yjit.rb
+++ b/bootstraptest/test_yjit.rb
@@ -1,3 +1,216 @@
+# regression test for send stack shifting
+assert_normal_exit %q{
+ def foo(a, b)
+ a.singleton_methods(b)
+ end
+
+ def call_foo
+ [1, 1, 1, 1, 1, 1, send(:foo, 1, 1)]
+ end
+
+ call_foo
+}
+
+# regression test for arity check with splat
+assert_equal '[:ae, :ae]', %q{
+ def req_one(a_, b_ = 1) = raise
+
+ def test(args)
+ req_one *args
+ rescue ArgumentError
+ :ae
+ end
+
+ [test(Array.new 5), test([])]
+} unless rjit_enabled? # Not yet working on RJIT
+
+# regression test for arity check with splat and send
+assert_equal '[:ae, :ae]', %q{
+ def two_reqs(a, b_, _ = 1) = a.gsub(a, a)
+
+ def test(name, args)
+ send(name, *args)
+ rescue ArgumentError
+ :ae
+ end
+
+ [test(:two_reqs, ["g", nil, nil, nil]), test(:two_reqs, ["g"])]
+}
+
+# regression test for GC marking stubs in invalidated code
+assert_normal_exit %q{
+ garbage = Array.new(10_000) { [] } # create garbage to cause iseq movement
+ eval(<<~RUBY)
+ def foo(n, garbage)
+ if n == 2
+ # 1.times.each to create a cfunc frame to preserve the JIT frame
+ # which will return to a stub housed in an invalidated block
+ return 1.times.each do
+ Object.define_method(:foo) {}
+ garbage.clear
+ GC.verify_compaction_references(toward: :empty, expand_heap: true)
+ end
+ end
+
+ foo(n + 1, garbage)
+ end
+ RUBY
+
+ foo(1, garbage)
+}
+
+# regression test for callee block handler overlapping with arguments
+assert_equal '3', %q{
+ def foo(_req, *args) = args.last
+
+ def call_foo = foo(0, 1, 2, 3, &->{})
+
+ call_foo
+}
+
+# call leaf builtin with a block argument
+assert_equal '0', "0.abs(&nil)"
+
+# regression test for invokeblock iseq guard
+assert_equal 'ok', %q{
+ return :ok unless defined?(GC.compact)
+ def foo = yield
+ 10.times do |i|
+ ret = eval("foo { #{i} }")
+ raise "failed at #{i}" unless ret == i
+ GC.compact
+ end
+ :ok
+} unless rjit_enabled? # Not yet working on RJIT
+
+# regression test for overly generous guard elision
+assert_equal '[0, :sum, 0, :sum]', %q{
+ # In faulty versions, the following happens:
+ # 1. YJIT puts object on the temp stack with type knowledge
+ # (CArray or CString) about RBASIC_CLASS(object).
+ # 2. In iter=0, due to the type knowledge, YJIT generates
+ # a call to sum() without any guard on RBASIC_CLASS(object).
+ # 3. In iter=1, a singleton class is added to the object,
+ # changing RBASIC_CLASS(object), falsifying the type knowledge.
+ # 4. Because the code from (1) has no class guard, it is incorrectly
+ # reused and the wrong method is invoked.
+ # Putting a literal is important for gaining type knowledge.
+ def carray(iter)
+ array = []
+ array.sum(iter.times { def array.sum(_) = :sum })
+ end
+
+ def cstring(iter)
+ string = ""
+ string.sum(iter.times { def string.sum(_) = :sum })
+ end
+
+ [carray(0), carray(1), cstring(0), cstring(1)]
+}
+
+# regression test for return type of Integer#/
+# It can return a T_BIGNUM when inputs are T_FIXNUM.
+assert_equal 0x3fffffffffffffff.to_s, %q{
+ def call(fixnum_min)
+ (fixnum_min / -1) - 1
+ end
+
+ call(-(2**62))
+}
+
+# regression test for return type of String#<<
+assert_equal 'Sub', %q{
+ def call(sub) = (sub << sub).itself
+
+ class Sub < String; end
+
+ call(Sub.new('o')).class
+}
+
+# test splat filling required and feeding rest
+assert_equal '[0, 1, 2, [3, 4]]', %q{
+ public def lead_rest(a, b, *rest)
+ [self, a, b, rest]
+ end
+
+ def call(args) = 0.lead_rest(*args)
+
+ call([1, 2, 3, 4])
+}
+
+# test missing opts are nil initialized
+assert_equal '[[0, 1, nil, 3], [0, 1, nil, 3], [0, 1, nil, 3, []], [0, 1, nil, 3, []]]', %q{
+ public def lead_opts(a, b=binding.local_variable_get(:c), c=3)
+ [self, a, b, c]
+ end
+
+ public def opts_rest(a=raise, b=binding.local_variable_get(:c), c=3, *rest)
+ [self, a, b, c, rest]
+ end
+
+ def call(args)
+ [
+ 0.lead_opts(1),
+ 0.lead_opts(*args),
+
+ 0.opts_rest(1),
+ 0.opts_rest(*args),
+ ]
+ end
+
+ call([1])
+}
+
+# test filled optionals with unspecified keyword param
+assert_equal 'ok', %q{
+ def opt_rest_opt_kw(_=1, *, k: :ok) = k
+
+ def call = opt_rest_opt_kw(0)
+
+ call
+}
+
+# test splat empty array with rest param
+assert_equal '[0, 1, 2, []]', %q{
+ public def foo(a=1, b=2, *rest)
+ [self, a, b, rest]
+ end
+
+ def call(args) = 0.foo(*args)
+
+ call([])
+}
+
+# Regression test for yielding with autosplat to block with
+# optional parameters. https://github.com/Shopify/yjit/issues/313
+assert_equal '[:a, :b, :a, :b]', %q{
+ def yielder(arg) = yield(arg) + yield(arg)
+
+ yielder([:a, :b]) do |c = :c, d = :d|
+ [c, d]
+ end
+}
+
+# Regression test for GC mishap while doing shape transition
+assert_equal '[:ok]', %q{
+ # [Bug #19601]
+ class RegressionTest
+ def initialize
+ @a = @b = @fourth_ivar_does_shape_transition = nil
+ end
+
+ def extender
+ @first_extended_ivar = [:ok]
+ end
+ end
+
+ GC.stress = true
+
+ # Used to crash due to GC run in rb_ensure_iv_list_size()
+ # not marking the newly allocated [:ok].
+ RegressionTest.new.extender.itself
+} unless rjit_enabled? # Skip on RJIT since this uncovers a crash
+
assert_equal 'true', %q{
# regression test for tracking type of locals for too long
def local_setting_cmp(five)
@@ -46,7 +259,7 @@ assert_normal_exit %q{
}
assert_normal_exit %q{
- # Test to ensure send on overriden c functions
+ # Test to ensure send on overridden c functions
# doesn't corrupt the stack
class Bar
def bar(x)
@@ -79,6 +292,80 @@ assert_equal '[nil, nil, nil, nil, nil, nil]', %q{
end
}
+assert_equal '[nil, nil, nil, nil, nil, nil]', %q{
+ # Tests defined? on non-heap objects
+ [NilClass, TrueClass, FalseClass, Integer, Float, Symbol].each do |klass|
+ klass.class_eval("def foo = defined?(@foo)")
+ end
+
+ [nil, true, false, 0xFABCAFE, 0.42, :cake].map do |instance|
+ instance.foo
+ instance.foo
+ end
+}
+
+assert_equal '[nil, "instance-variable", nil, "instance-variable"]', %q{
+ # defined? on object that changes shape between calls
+ class Foo
+ def foo
+ defined?(@foo)
+ end
+
+ def add
+ @foo = 1
+ end
+
+ def remove
+ self.remove_instance_variable(:@foo)
+ end
+ end
+
+ obj = Foo.new
+ [obj.foo, (obj.add; obj.foo), (obj.remove; obj.foo), (obj.add; obj.foo)]
+}
+
+assert_equal '["instance-variable", 5]', %q{
+ # defined? on object too complex for shape information
+ class Foo
+ def initialize
+ 100.times { |i| instance_variable_set("@foo#{i}", i) }
+ end
+
+ def foo
+ [defined?(@foo5), @foo5]
+ end
+ end
+
+ Foo.new.foo
+}
+
+# getinstancevariable with shape too complex
+assert_normal_exit %q{
+ class Foo
+ def initialize
+ @a = 1
+ end
+
+ def getter
+ @foobar
+ end
+ end
+
+ # Initialize ivars in changing order, making the Foo
+ # class have shape too complex
+ 100.times do |x|
+ foo = Foo.new
+ foo.instance_variable_set(:"@a#{x}", 1)
+ foo.instance_variable_set(:"@foobar", 777)
+
+ # The getter method eventually sees shape too complex
+ r = foo.getter
+ if r != 777
+ raise "error"
+ end
+ end
+}
+
assert_equal '0', %q{
# This is a regression test for incomplete invalidation from
# opt_setinlinecache. This test might be brittle, so
@@ -374,6 +661,45 @@ assert_equal 'false', %q{
less_than 2
}
+# BOP redefinition works on Integer#<=
+assert_equal 'false', %q{
+ def le(x, y) = x <= y
+
+ le(2, 2)
+
+ class Integer
+ def <=(_) = false
+ end
+
+ le(2, 2)
+}
+
+# BOP redefinition works on Integer#>
+assert_equal 'false', %q{
+ def gt(x, y) = x > y
+
+ gt(3, 2)
+
+ class Integer
+ def >(_) = false
+ end
+
+ gt(3, 2)
+}
+
+# BOP redefinition works on Integer#>=
+assert_equal 'false', %q{
+ def ge(x, y) = x >= y
+
+ ge(2, 2)
+
+ class Integer
+ def >=(_) = false
+ end
+
+ ge(2, 2)
+}
+
# Putobject, less-than operator, fixnums
assert_equal '2', %q{
def check_index(index)
@@ -984,6 +1310,18 @@ assert_equal '[42, :default]', %q{
]
}
+# Test default value block for Hash with opt_aref_with
+assert_equal "false", %q{
+ def index_with_string(h)
+ h["foo"]
+ end
+
+ h = Hash.new { |h, k| k.frozen? }
+
+ index_with_string(h)
+ index_with_string(h)
+}
+
# A regression test for making sure cfp->sp is proper when
# hitting stubs. See :stub-sp-flush:
assert_equal 'ok', %q{
@@ -1141,6 +1479,38 @@ assert_equal '42', %q{
run
}
+# splatting an empty array on a specialized method
+assert_equal 'ok', %q{
+ def run
+ "ok".to_s(*[])
+ end
+
+ run
+ run
+}
+
+# splatting an single element array on a specialized method
+assert_equal '[1]', %q{
+ def run
+ [].<<(*[1])
+ end
+
+ run
+ run
+}
+
+# specialized method with wrong args
+assert_equal 'ok', %q{
+ def run(x)
+ "bad".to_s(123) if x
+ rescue
+ :ok
+ end
+
+ run(false)
+ run(true)
+}
+
# getinstancevariable on Symbol
assert_equal '[nil, nil]', %q{
# @foo to exercise the getinstancevariable instruction
@@ -1574,6 +1944,24 @@ assert_equal 'true', %q{
jittable_method
}
+# test getbyte on string class
+assert_equal '[97, :nil, 97, :nil, :raised]', %q{
+ def getbyte(s, i)
+ byte = begin
+ s.getbyte(i)
+ rescue TypeError
+ :raised
+ end
+
+ byte || :nil
+ end
+
+ getbyte("a", 0)
+ getbyte("a", 0)
+
+ [getbyte("a", 0), getbyte("a", 1), getbyte("a", -1), getbyte("a", -2), getbyte("a", "a")]
+} unless rjit_enabled? # Not yet working on RJIT
+
# Test << operator on string subclass
assert_equal 'abab', %q{
class MyString < String; end
@@ -1940,6 +2328,38 @@ assert_equal '[:A, :Btwo]', %q{
ins.foo
}
+# invokesuper with a block
+assert_equal 'true', %q{
+ class A
+ def foo = block_given?
+ end
+
+ class B < A
+ def foo = super()
+ end
+
+ B.new.foo { }
+ B.new.foo { }
+}
+
+# invokesuper in a block
+assert_equal '[0, 2]', %q{
+ class A
+ def foo(x) = x * 2
+ end
+
+ class B < A
+ def foo
+ 2.times.map do |x|
+ super(x)
+ end
+ end
+ end
+
+ B.new.foo
+ B.new.foo
+}
+
# Call to fixnum
assert_equal '[true, false]', %q{
def is_odd(obj)
@@ -2020,6 +2440,18 @@ assert_equal '[1, 2, 3, 4, 5]', %q{
splatarray
}
+# splatkw
+assert_equal '[1, 2]', %q{
+ def foo(a:) = [a, yield]
+
+ def entry(&block)
+ a = { a: 1 }
+ foo(**a, &block)
+ end
+
+ entry { 2 }
+}
+
assert_equal '[1, 1, 2, 1, 2, 3]', %q{
def expandarray
arr = [1, 2, 3]
@@ -2084,6 +2516,17 @@ assert_equal '[1, 2, nil]', %q{
expandarray_rhs_too_small
}
+assert_equal '[nil, 2, nil]', %q{
+ def foo(arr)
+ a, b, c = arr
+ end
+
+ a, b, c1 = foo([0, 1])
+ a, b, c2 = foo([0, 1, 2])
+ a, b, c3 = foo([0, 1])
+ [c1, c2, c3]
+}
+
assert_equal '[1, [2]]', %q{
def expandarray_splat
a, *b = [1, 2]
@@ -2173,7 +2616,7 @@ assert_equal '[[:c_return, :String, :string_alias, "events_to_str"]]', %q{
events.compiled(events)
events
-} unless defined?(RubyVM::MJIT) && RubyVM::MJIT.enabled? # MJIT calls extra Ruby methods
+} unless rjit_enabled? # RJIT calls extra Ruby methods
# test enabling a TracePoint that targets a particular line in a C method call
assert_equal '[true]', %q{
@@ -2255,7 +2698,7 @@ assert_equal '[[:c_call, :itself]]', %q{
tp.enable { shouldnt_compile }
events
-} unless defined?(RubyVM::MJIT) && RubyVM::MJIT.enabled? # MJIT calls extra Ruby methods
+} unless rjit_enabled? # RJIT calls extra Ruby methods
# test enabling c_return tracing before compiling
assert_equal '[[:c_return, :itself, main]]', %q{
@@ -2270,7 +2713,7 @@ assert_equal '[[:c_return, :itself, main]]', %q{
tp.enable { shouldnt_compile }
events
-} unless defined?(RubyVM::MJIT) && RubyVM::MJIT.enabled? # MJIT calls extra Ruby methods
+} unless rjit_enabled? # RJIT calls extra Ruby methods
# test c_call invalidation
assert_equal '[[:c_call, :itself]]', %q{
@@ -3481,3 +3924,421 @@ assert_equal 'threw', %q{
bar([Hash.ruby2_keywords_hash({})])
}
+
+# Test instance_of? and is_a?
+assert_equal 'true', %q{
+ 1.instance_of?(Integer) && 1.is_a?(Integer)
+}
+
+# Test instance_of? and is_a? for singleton classes
+assert_equal 'true', %q{
+ a = []
+ def a.test = :test
+ a.instance_of?(Array) && a.is_a?(Array)
+}
+
+# Test instance_of? for singleton_class
+# Yes this does really return false
+assert_equal 'false', %q{
+ a = []
+ def a.test = :test
+ a.instance_of?(a.singleton_class)
+}
+
+# Test is_a? for singleton_class
+assert_equal 'true', %q{
+ a = []
+ def a.test = :test
+ a.is_a?(a.singleton_class)
+}
+
+# Test send with splat to a cfunc
+assert_equal 'true', %q{
+ 1.send(:==, 1, *[])
+}
+
+# Test empty splat with cfunc
+assert_equal '2', %q{
+ def foo
+ Integer.sqrt(4, *[])
+ end
+ # call twice to deal with constant exiting
+ foo
+ foo
+}
+
+# Test non-empty splat with cfunc
+assert_equal 'Hello World', %q{
+ def bar
+ args = ["Hello "]
+ greeting = "World"
+ greeting.insert(0, *args)
+ greeting
+ end
+ bar
+}
+
+# Regression: this creates a temp stack with > 127 elements
+assert_normal_exit %q{
+ def foo(a)
+ [
+ a, a, a, a, a, a, a, a, a, a,
+ a, a, a, a, a, a, a, a, a, a,
+ a, a, a, a, a, a, a, a, a, a,
+ a, a, a, a, a, a, a, a, a, a,
+ a, a, a, a, a, a, a, a, a, a,
+ a, a, a, a, a, a, a, a, a, a,
+ a, a, a, a, a, a, a, a, a, a,
+ a, a, a, a, a, a, a, a, a, a,
+ a, a, a, a, a, a, a, a, a, a,
+ a, a, a, a, a, a, a, a, a, a,
+ a, a, a, a, a, a, a, a, a, a,
+ a, a, a, a, a, a, a, a, a, a,
+ a, a, a, a, a, a, a, a,
+ ]
+ end
+
+ def entry
+ foo(1)
+ end
+
+ entry
+}
+
+# Test that splat and rest combined
+# properly dupe the array
+assert_equal "[]", %q{
+ def foo(*rest)
+ rest << 1
+ end
+
+ def test(splat)
+ foo(*splat)
+ end
+
+ EMPTY = []
+ custom = Object.new
+ def custom.to_a
+ EMPTY
+ end
+
+ test(custom)
+ test(custom)
+ EMPTY
+}
+
+# Rest with send
+assert_equal '[1, 2, 3]', %q{
+ def bar(x, *rest)
+ rest.insert(0, x)
+ end
+ send(:bar, 1, 2, 3)
+}
+
+# Fix splat block arg bad compilation
+assert_equal "foo", %q{
+ def literal(*args, &block)
+ s = ''.dup
+ literal_append(s, *args, &block)
+ s
+ end
+
+ def literal_append(sql, v)
+ sql << v
+ end
+
+ literal("foo")
+}
+
+# regression test for accidentally having a parameter truncated
+# due to Rust/C signature mismatch. Used to crash with
+# > [BUG] rb_vm_insn_addr2insn: invalid insn address ...
+# or
+# > ... `Err` value: TryFromIntError(())'
+assert_normal_exit %q{
+ n = 16384
+ eval(
+ "def foo(arg); " + "_=arg;" * n + '_=1;' + "Object; end"
+ )
+ foo 1
+}
+
+# Regression test for CantCompile not using starting_ctx
+assert_normal_exit %q{
+ class Integer
+ def ===(other)
+ false
+ end
+ end
+
+ def my_func(x)
+ case x
+ when 1
+ 1
+ when 2
+ 2
+ else
+ 3
+ end
+ end
+
+ my_func(1)
+}
+
+# Regression test for CantCompile not using starting_ctx
+assert_equal "ArgumentError", %q{
+ def literal(*args, &block)
+ s = ''.dup
+ args = [1, 2, 3]
+ literal_append(s, *args, &block)
+ s
+ end
+
+ def literal_append(sql, v)
+ [sql.inspect, v.inspect]
+ end
+
+ begin
+ literal("foo")
+ rescue ArgumentError
+ "ArgumentError"
+ end
+}
+
+# Rest with block
+# Simplified code from railsbench
+assert_equal '[{"/a"=>"b", :as=>:c, :via=>:post}, [], nil]', %q{
+ def match(path, *rest, &block)
+ [path, rest, block]
+ end
+
+ def map_method(method, args, &block)
+ options = args.last
+ args.pop
+ options[:via] = method
+ match(*args, options, &block)
+ end
+
+ def post(*args, &block)
+ map_method(:post, args, &block)
+ end
+
+ post "/a" => "b", as: :c
+}
+
+# Test rest and kw_args
+assert_equal '[true, true, true, true]', %q{
+ def my_func(*args, base: nil, sort: true)
+ [args, base, sort]
+ end
+
+ def calling_my_func
+ results = []
+ results << (my_func("test") == [["test"], nil, true])
+ results << (my_func("test", base: :base) == [["test"], :base, true])
+ results << (my_func("test", sort: false) == [["test"], nil, false])
+ results << (my_func("test", "other", base: :base) == [["test", "other"], :base, true])
+ results
+ end
+ calling_my_func
+}
+
+# Test Integer#[] with 2 args
+assert_equal '0', %q{
+ 3[0, 0]
+}
+
+# unspecified_bits + checkkeyword
+assert_equal '2', %q{
+ def callee = 1
+
+ # checkkeyword should see unspecified_bits=0 (use bar), not Integer 1 (set bar = foo).
+ def foo(foo, bar: foo) = bar
+
+ def entry(&block)
+ # write 1 at stack[3]. Calling #callee spills stack[3].
+ 1 + (1 + (1 + (1 + callee)))
+ # &block is written to a register instead of stack[3]. When &block is popped and
+ # unspecified_bits is pushed, it must be written to stack[3], not to a register.
+ foo(1, bar: 2, &block)
+ end
+
+ entry # call branch_stub_hit (spill temps)
+ entry # doesn't call branch_stub_hit (not spill temps)
+}
+
+# Test rest and optional_params
+assert_equal '[true, true, true, true]', %q{
+ def my_func(stuff, base=nil, sort=true, *args)
+ [stuff, base, sort, args]
+ end
+
+ def calling_my_func
+ results = []
+ results << (my_func("test") == ["test", nil, true, []])
+ results << (my_func("test", :base) == ["test", :base, true, []])
+ results << (my_func("test", :base, false) == ["test", :base, false, []])
+ results << (my_func("test", :base, false, "other", "other") == ["test", :base, false, ["other", "other"]])
+ results
+ end
+ calling_my_func
+}
+
+# Test rest and optional_params and splat
+assert_equal '[true, true, true, true, true]', %q{
+ def my_func(stuff, base=nil, sort=true, *args)
+ [stuff, base, sort, args]
+ end
+
+ def calling_my_func
+ results = []
+ splat = ["test"]
+ results << (my_func(*splat) == ["test", nil, true, []])
+ splat = [:base]
+ results << (my_func("test", *splat) == ["test", :base, true, []])
+ splat = [:base, false]
+ results << (my_func("test", *splat) == ["test", :base, false, []])
+ splat = [:base, false, "other", "other"]
+ results << (my_func("test", *splat) == ["test", :base, false, ["other", "other"]])
+ splat = ["test", :base, false, "other", "other"]
+ results << (my_func(*splat) == ["test", :base, false, ["other", "other"]])
+ results
+ end
+ calling_my_func
+}
+
+# Regression test: rest and optional and splat
+assert_equal 'true', %q{
+ def my_func(base=nil, *args)
+ [base, args]
+ end
+
+ def calling_my_func
+ array = []
+ my_func(:base, :rest1, *array) == [:base, [:rest1]]
+ end
+
+ calling_my_func
+}
+
+# Fix failed case for large splat
+assert_equal 'true', %q{
+ def d(a, b=:b)
+ end
+
+ def calling_func
+ ary = 1380888.times;
+ d(*ary)
+ end
+ begin
+ calling_func
+ rescue ArgumentError
+ true
+ end
+} unless rjit_enabled? # Not yet working on RJIT
+
+# Regression test: register allocator on expandarray
+assert_equal '[]', %q{
+ func = proc { [] }
+ proc do
+ _x, _y = func.call
+ end.call
+}
+
+# Catch TAG_BREAK in a non-FINISH frame with JIT code
+assert_equal '1', %q{
+ def entry
+ catch_break
+ end
+
+ def catch_break
+ while_true do
+ break
+ end
+ 1
+ end
+
+ def while_true
+ while true
+ yield
+ end
+ end
+
+ entry
+}
+
+assert_equal '6', %q{
+ class Base
+ def number = 1 + yield
+ end
+
+ class Sub < Base
+ def number = super + 2
+ end
+
+ Sub.new.number { 3 }
+}
+
+# Integer multiplication and overflow
+assert_equal '[6, -6, 9671406556917033397649408, -9671406556917033397649408, 21267647932558653966460912964485513216]', %q{
+ def foo(a, b)
+ a * b
+ end
+
+ r1 = foo(2, 3)
+ r2 = foo(2, -3)
+ r3 = foo(2 << 40, 2 << 41)
+ r4 = foo(2 << 40, -2 << 41)
+ r5 = foo(1 << 62, 1 << 62)
+
+ [r1, r2, r3, r4, r5]
+}
+
+# Integer multiplication and overflow (minimized regression test from test-basic)
+assert_equal '8515157028618240000', %q{2128789257154560000 * 4}
+
+# Inlined method calls
+assert_equal 'nil', %q{
+ def putnil = nil
+ def entry = putnil
+ entry.inspect
+}
+assert_equal '1', %q{
+ def putobject_1 = 1
+ def entry = putobject_1
+ entry
+}
+assert_equal 'false', %q{
+ def putobject(_unused_arg1) = false
+ def entry = putobject(nil)
+ entry
+}
+assert_equal 'true', %q{
+ def entry = yield
+ entry { true }
+}
+
+assert_normal_exit %q{
+ ivars = 1024.times.map { |i| "@iv_#{i} = #{i}\n" }.join
+ Foo = Class.new
+ Foo.class_eval "def initialize() #{ivars} end"
+ Foo.new
+}
+
+assert_equal '0', %q{
+ def spill
+ 1.to_i # not inlined
+ end
+
+ def inline(_stack1, _stack2, _stack3, _stack4, _stack5)
+ 0 # inlined
+ end
+
+ def entry
+ # RegTemps is 00111110 prior to the #inline call.
+ # Its return value goes to stack_idx=0, which conflicts with stack_idx=5.
+ inline(spill, 2, 3, 4, 5)
+ end
+
+ entry
+}
diff --git a/builtin.c b/builtin.c
index 21fff95650..4fc2ab43d1 100644
--- a/builtin.c
+++ b/builtin.c
@@ -3,15 +3,15 @@
#include "iseq.h"
#include "builtin.h"
-#ifdef CROSS_COMPILING
+#include "builtin_binary.inc"
+
+#ifndef BUILTIN_BINARY_SIZE
#define INCLUDED_BY_BUILTIN_C 1
#include "mini_builtin.c"
#else
-#include "builtin_binary.inc"
-
static const unsigned char *
bin4feature(const struct builtin_binary *bb, const char *feature, size_t *psize)
{
@@ -39,7 +39,7 @@ rb_load_with_builtin_functions(const char *feature_name, const struct rb_builtin
size_t size;
const unsigned char *bin = builtin_lookup(feature_name, &size);
if (! bin) {
- rb_bug("builtin_lookup: can not find %s\n", feature_name);
+ rb_bug("builtin_lookup: can not find %s", feature_name);
}
// load binary
@@ -48,6 +48,7 @@ rb_load_with_builtin_functions(const char *feature_name, const struct rb_builtin
vm->builtin_function_table = table;
vm->builtin_inline_index = 0;
const rb_iseq_t *iseq = rb_iseq_ibf_load_bytes((const char *)bin, size);
+ ASSUME(iseq); // otherwise an exception should have raised
vm->builtin_function_table = NULL;
// exec
@@ -57,6 +58,12 @@ rb_load_with_builtin_functions(const char *feature_name, const struct rb_builtin
#endif
void
+rb_free_loaded_builtin_table(void)
+{
+ // do nothing
+}
+
+void
Init_builtin(void)
{
// nothing
diff --git a/builtin.h b/builtin.h
index 38ad5a1629..85fd1a009a 100644
--- a/builtin.h
+++ b/builtin.h
@@ -11,17 +11,13 @@ struct rb_builtin_function {
// for load
const int index;
const char * const name;
-
- // for jit
- void (*compiler)(VALUE, long, unsigned, bool);
};
-#define RB_BUILTIN_FUNCTION(_i, _name, _fname, _arity, _compiler) {\
+#define RB_BUILTIN_FUNCTION(_i, _name, _fname, _arity) {\
.name = _i < 0 ? NULL : #_name, \
.func_ptr = (void *)_fname, \
.argc = _arity, \
.index = _i, \
- .compiler = _compiler, \
}
void rb_load_with_builtin_functions(const char *feature_name, const struct rb_builtin_function *table);
diff --git a/ccan/list/list.h b/ccan/list/list.h
index 30b2af04e9..bf692a6937 100644
--- a/ccan/list/list.h
+++ b/ccan/list/list.h
@@ -635,14 +635,16 @@ static inline void ccan_list_prepend_list_(struct ccan_list_head *to,
/* internal macros, do not use directly */
#define ccan_list_for_each_off_dir_(h, i, off, dir) \
- for (i = ccan_list_node_to_off_(ccan_list_debug(h, CCAN_LIST_LOC)->n.dir, \
+ for (i = 0, \
+ i = ccan_list_node_to_off_(ccan_list_debug(h, CCAN_LIST_LOC)->n.dir, \
(off)); \
ccan_list_node_from_off_((void *)i, (off)) != &(h)->n; \
i = ccan_list_node_to_off_(ccan_list_node_from_off_((void *)i, (off))->dir, \
(off)))
#define ccan_list_for_each_safe_off_dir_(h, i, nxt, off, dir) \
- for (i = ccan_list_node_to_off_(ccan_list_debug(h, CCAN_LIST_LOC)->n.dir, \
+ for (i = 0, \
+ i = ccan_list_node_to_off_(ccan_list_debug(h, CCAN_LIST_LOC)->n.dir, \
(off)), \
nxt = ccan_list_node_to_off_(ccan_list_node_from_off_(i, (off))->dir, \
(off)); \
diff --git a/class.c b/class.c
index 333a9d78e5..f8cf4b832a 100644
--- a/class.c
+++ b/class.c
@@ -30,7 +30,41 @@
#include "ruby/st.h"
#include "vm_core.h"
-#define id_attached id__attached__
+/* Flags of T_CLASS
+ *
+ * 2: RCLASS_SUPERCLASSES_INCLUDE_SELF
+ * The RCLASS_SUPERCLASSES contains the class as the last element.
+ * This means that this class owns the RCLASS_SUPERCLASSES list.
+ * if !SHAPE_IN_BASIC_FLAGS
+ * 4-19: SHAPE_FLAG_MASK
+ * Shape ID for the class.
+ * endif
+ */
+
+/* Flags of T_ICLASS
+ *
+ * 0: RICLASS_IS_ORIGIN
+ * 3: RICLASS_ORIGIN_SHARED_MTBL
+ * The T_ICLASS does not own the method table.
+ * if !SHAPE_IN_BASIC_FLAGS
+ * 4-19: SHAPE_FLAG_MASK
+ * Shape ID. This is set but not used.
+ * endif
+ */
+
+/* Flags of T_MODULE
+ *
+ * 1: RMODULE_ALLOCATED_BUT_NOT_INITIALIZED
+ * Module has not been initialized.
+ * 2: RCLASS_SUPERCLASSES_INCLUDE_SELF
+ * See RCLASS_SUPERCLASSES_INCLUDE_SELF in T_CLASS.
+ * 3: RMODULE_IS_REFINEMENT
+ * Module is used for refinements.
+ * if !SHAPE_IN_BASIC_FLAGS
+ * 4-19: SHAPE_FLAG_MASK
+ * Shape ID for the module.
+ * endif
+ */
#define METACLASS_OF(k) RBASIC(k)->klass
#define SET_METACLASS_OF(k, cls) RBASIC_SET_CLASS(k, cls)
@@ -195,22 +229,13 @@ rb_class_detach_module_subclasses(VALUE klass)
static VALUE
class_alloc(VALUE flags, VALUE klass)
{
- size_t alloc_size = sizeof(struct RClass);
-
-#if RCLASS_EXT_EMBEDDED
- alloc_size += sizeof(rb_classext_t);
-#endif
+ size_t alloc_size = sizeof(struct RClass) + sizeof(rb_classext_t);
flags &= T_MASK;
- flags |= FL_PROMOTED1 /* start from age == 2 */;
if (RGENGC_WB_PROTECTED_CLASS) flags |= FL_WB_PROTECTED;
- RVARGC_NEWOBJ_OF(obj, struct RClass, klass, flags, alloc_size);
+ NEWOBJ_OF(obj, struct RClass, klass, flags, alloc_size, 0);
-#if RCLASS_EXT_EMBEDDED
memset(RCLASS_EXT(obj), 0, sizeof(rb_classext_t));
-#else
- obj->ptr = ZALLOC(rb_classext_t);
-#endif
/* ZALLOC
RCLASS_CONST_TBL(obj) = 0;
@@ -223,7 +248,7 @@ class_alloc(VALUE flags, VALUE klass)
*/
RCLASS_SET_ORIGIN((VALUE)obj, (VALUE)obj);
RB_OBJ_WRITE(obj, &RCLASS_REFINED_CLASS(obj), Qnil);
- RCLASS_ALLOCATOR(obj) = 0;
+ RCLASS_SET_ALLOCATOR((VALUE)obj, 0);
return (VALUE)obj;
}
@@ -404,6 +429,31 @@ class_init_copy_check(VALUE clone, VALUE orig)
}
}
+struct cvc_table_copy_ctx {
+ VALUE clone;
+ struct rb_id_table * new_table;
+};
+
+static enum rb_id_table_iterator_result
+cvc_table_copy(ID id, VALUE val, void *data)
+{
+ struct cvc_table_copy_ctx *ctx = (struct cvc_table_copy_ctx *)data;
+ struct rb_cvar_class_tbl_entry * orig_entry;
+ orig_entry = (struct rb_cvar_class_tbl_entry *)val;
+
+ struct rb_cvar_class_tbl_entry *ent;
+
+ ent = ALLOC(struct rb_cvar_class_tbl_entry);
+ ent->class_value = ctx->clone;
+ ent->cref = orig_entry->cref;
+ ent->global_cvar_state = orig_entry->global_cvar_state;
+ rb_id_table_insert(ctx->new_table, id, (VALUE)ent);
+
+ RB_OBJ_WRITTEN(ctx->clone, Qundef, ent->cref);
+
+ return ID_TABLE_CONTINUE;
+}
+
static void
copy_tables(VALUE clone, VALUE orig)
{
@@ -411,6 +461,17 @@ copy_tables(VALUE clone, VALUE orig)
rb_free_const_table(RCLASS_CONST_TBL(clone));
RCLASS_CONST_TBL(clone) = 0;
}
+ if (RCLASS_CVC_TBL(orig)) {
+ struct rb_id_table *rb_cvc_tbl = RCLASS_CVC_TBL(orig);
+ struct rb_id_table *rb_cvc_tbl_dup = rb_id_table_create(rb_id_table_size(rb_cvc_tbl));
+
+ struct cvc_table_copy_ctx ctx;
+ ctx.clone = clone;
+ ctx.new_table = rb_cvc_tbl_dup;
+ rb_id_table_foreach(rb_cvc_tbl, cvc_table_copy, &ctx);
+ RCLASS_CVC_TBL(clone) = rb_cvc_tbl_dup;
+ }
+ rb_id_table_free(RCLASS_M_TBL(clone));
RCLASS_M_TBL(clone) = 0;
if (!RB_TYPE_P(clone, T_ICLASS)) {
st_data_t id;
@@ -435,7 +496,7 @@ static bool ensure_origin(VALUE klass);
/**
* If this flag is set, that module is allocated but not initialized yet.
*/
-enum {RMODULE_ALLOCATED_BUT_NOT_INITIALIZED = RUBY_FL_USER5};
+enum {RMODULE_ALLOCATED_BUT_NOT_INITIALIZED = RUBY_FL_USER1};
static inline bool
RMODULE_UNINITIALIZED(VALUE module)
@@ -478,14 +539,14 @@ rb_mod_init_copy(VALUE clone, VALUE orig)
/* cloned flag is refer at constant inline cache
* see vm_get_const_key_cref() in vm_insnhelper.c
*/
- FL_SET(clone, RCLASS_CLONED);
- FL_SET(orig , RCLASS_CLONED);
+ RCLASS_EXT(clone)->cloned = true;
+ RCLASS_EXT(orig)->cloned = true;
if (!FL_TEST(CLASS_OF(clone), FL_SINGLETON)) {
RBASIC_SET_CLASS(clone, rb_singleton_class_clone(orig));
rb_singleton_class_attached(METACLASS_OF(clone), (VALUE)clone);
}
- RCLASS_ALLOCATOR(clone) = RCLASS_ALLOCATOR(orig);
+ RCLASS_SET_ALLOCATOR(clone, RCLASS_ALLOCATOR(orig));
copy_tables(clone, orig);
if (RCLASS_M_TBL(orig)) {
struct clone_method_arg arg;
@@ -517,11 +578,14 @@ rb_mod_init_copy(VALUE clone, VALUE orig)
rb_bug("non iclass between module/class and origin");
}
clone_p = class_alloc(RBASIC(p)->flags, METACLASS_OF(p));
+ /* We should set the m_tbl right after allocation before anything
+ * that can trigger GC to avoid clone_p from becoming old and
+ * needing to fire write barriers. */
+ RCLASS_SET_M_TBL(clone_p, RCLASS_M_TBL(p));
RCLASS_SET_SUPER(prev_clone_p, clone_p);
prev_clone_p = clone_p;
- RCLASS_M_TBL(clone_p) = RCLASS_M_TBL(p);
RCLASS_CONST_TBL(clone_p) = RCLASS_CONST_TBL(p);
- RCLASS_ALLOCATOR(clone_p) = RCLASS_ALLOCATOR(p);
+ RCLASS_SET_ALLOCATOR(clone_p, RCLASS_ALLOCATOR(p));
if (RB_TYPE_P(clone, T_CLASS)) {
RCLASS_SET_INCLUDER(clone_p, clone);
}
@@ -584,7 +648,7 @@ rb_singleton_class_clone_and_attach(VALUE obj, VALUE attach)
// attached to an object other than `obj`. In which case `obj` does not have
// a material singleton class attached yet and there is no singleton class
// to clone.
- if (!(FL_TEST(klass, FL_SINGLETON) && rb_attr_get(klass, id_attached) == obj)) {
+ if (!(FL_TEST(klass, FL_SINGLETON) && RCLASS_ATTACHED_OBJECT(klass) == obj)) {
// nothing to clone
return klass;
}
@@ -606,7 +670,6 @@ rb_singleton_class_clone_and_attach(VALUE obj, VALUE attach)
}
RCLASS_SET_SUPER(clone, RCLASS_SUPER(klass));
- RCLASS_ALLOCATOR(clone) = RCLASS_ALLOCATOR(klass);
rb_iv_tbl_copy(clone, klass);
if (RCLASS_CONST_TBL(klass)) {
struct clone_const_arg arg;
@@ -637,7 +700,7 @@ void
rb_singleton_class_attached(VALUE klass, VALUE obj)
{
if (FL_TEST(klass, FL_SINGLETON)) {
- rb_class_ivar_set(klass, id_attached, obj);
+ RCLASS_SET_ATTACHED_OBJECT(klass, obj);
}
}
@@ -651,13 +714,13 @@ rb_singleton_class_attached(VALUE klass, VALUE obj)
static int
rb_singleton_class_has_metaclass_p(VALUE sklass)
{
- return rb_attr_get(METACLASS_OF(sklass), id_attached) == sklass;
+ return RCLASS_ATTACHED_OBJECT(METACLASS_OF(sklass)) == sklass;
}
int
rb_singleton_class_internal_p(VALUE sklass)
{
- return (RB_TYPE_P(rb_attr_get(sklass, id_attached), T_CLASS) &&
+ return (RB_TYPE_P(RCLASS_ATTACHED_OBJECT(sklass), T_CLASS) &&
!rb_singleton_class_has_metaclass_p(sklass));
}
@@ -896,7 +959,7 @@ rb_define_class_id(ID id, VALUE super)
* \return the value \c Class#inherited's returns
* \pre Each of \a super and \a klass must be a \c Class object.
*/
-MJIT_FUNC_EXPORTED VALUE
+VALUE
rb_class_inherited(VALUE super, VALUE klass)
{
ID inherited;
@@ -944,7 +1007,7 @@ rb_define_class_under(VALUE outer, const char *name, VALUE super)
}
VALUE
-rb_define_class_id_under(VALUE outer, ID id, VALUE super)
+rb_define_class_id_under_no_pin(VALUE outer, ID id, VALUE super)
{
VALUE klass;
@@ -961,8 +1024,6 @@ rb_define_class_id_under(VALUE outer, ID id, VALUE super)
" (%"PRIsVALUE" is given but was %"PRIsVALUE")",
outer, rb_id2str(id), RCLASS_SUPER(klass), super);
}
- /* Class may have been defined in Ruby and not pin-rooted */
- rb_vm_add_root_module(klass);
return klass;
}
@@ -974,12 +1035,19 @@ rb_define_class_id_under(VALUE outer, ID id, VALUE super)
rb_set_class_path_string(klass, outer, rb_id2str(id));
rb_const_set(outer, id, klass);
rb_class_inherited(super, klass);
- rb_vm_add_root_module(klass);
return klass;
}
VALUE
+rb_define_class_id_under(VALUE outer, ID id, VALUE super)
+{
+ VALUE klass = rb_define_class_id_under_no_pin(outer, id, super);
+ rb_vm_add_root_module(klass);
+ return klass;
+}
+
+VALUE
rb_module_s_alloc(VALUE klass)
{
VALUE mod = class_alloc(T_MODULE, klass);
@@ -1074,7 +1142,7 @@ rb_include_class_new(VALUE module, VALUE super)
{
VALUE klass = class_alloc(T_ICLASS, rb_cClass);
- RCLASS_M_TBL(klass) = RCLASS_M_TBL(module);
+ RCLASS_SET_M_TBL(klass, RCLASS_M_TBL(module));
RCLASS_SET_ORIGIN(klass, klass);
if (BUILTIN_TYPE(module) == T_ICLASS) {
@@ -1350,10 +1418,10 @@ ensure_origin(VALUE klass)
VALUE origin = RCLASS_ORIGIN(klass);
if (origin == klass) {
origin = class_alloc(T_ICLASS, klass);
+ RCLASS_SET_M_TBL(origin, RCLASS_M_TBL(klass));
RCLASS_SET_SUPER(origin, RCLASS_SUPER(klass));
RCLASS_SET_SUPER(klass, origin);
RCLASS_SET_ORIGIN(klass, origin);
- RCLASS_M_TBL(origin) = RCLASS_M_TBL(klass);
RCLASS_M_TBL_INIT(klass);
rb_id_table_foreach(RCLASS_M_TBL(origin), cache_clear_refined_method, (void *)klass);
rb_id_table_foreach(RCLASS_M_TBL(origin), move_refined_method, (void *)klass);
@@ -1646,7 +1714,7 @@ rb_class_attached_object(VALUE klass)
rb_raise(rb_eTypeError, "`%"PRIsVALUE"' is not a singleton class", klass);
}
- return rb_attr_get(klass, id_attached);
+ return RCLASS_ATTACHED_OBJECT(klass);
}
static void
@@ -2175,7 +2243,7 @@ singleton_class_of(VALUE obj)
klass = METACLASS_OF(obj);
if (!(FL_TEST(klass, FL_SINGLETON) &&
- rb_attr_get(klass, id_attached) == obj)) {
+ RCLASS_ATTACHED_OBJECT(klass) == obj)) {
klass = rb_make_metaclass(obj, klass);
}
@@ -2214,7 +2282,7 @@ rb_singleton_class_get(VALUE obj)
}
klass = METACLASS_OF(obj);
if (!FL_TEST(klass, FL_SINGLETON)) return Qnil;
- if (rb_attr_get(klass, id_attached) != obj) return Qnil;
+ if (RCLASS_ATTACHED_OBJECT(klass) != obj) return Qnil;
return klass;
}
@@ -2278,7 +2346,7 @@ rb_define_attr(VALUE klass, const char *name, int read, int write)
rb_attr(klass, rb_intern(name), read, write, FALSE);
}
-MJIT_FUNC_EXPORTED VALUE
+VALUE
rb_keyword_error_new(const char *error, VALUE keys)
{
long i = 0, len = RARRAY_LEN(keys);
diff --git a/common.mk b/common.mk
index fc688055d1..83f10f7a58 100644
--- a/common.mk
+++ b/common.mk
@@ -1,4 +1,6 @@
# -*- mode: makefile-gmake; indent-tabs-mode: t -*-
+# This fragment can be used with nmake.exe and with bsdmake.
+# Avoid features specific to GNU Make.
bin: $(PROGRAM) $(WPROGRAM)
lib: $(LIBRUBY)
@@ -43,7 +45,8 @@ RUN_OPTS = --disable-gems
# GITPULLOPTIONS = --no-tags
-INCFLAGS = -I. -I$(arch_hdrdir) -I$(hdrdir) -I$(srcdir) -I$(UNICODE_HDR_DIR)
+PRISM_SRCDIR = $(srcdir)/prism
+INCFLAGS = -I. -I$(arch_hdrdir) -I$(hdrdir) -I$(srcdir) -I$(PRISM_SRCDIR) -I$(UNICODE_HDR_DIR) $(incflags)
GEM_HOME =
GEM_PATH =
@@ -80,6 +83,34 @@ ENC_MK = enc.mk
MAKE_ENC = -f $(ENC_MK) V="$(V)" UNICODE_HDR_DIR="$(UNICODE_HDR_DIR)" \
RUBY="$(BOOTSTRAPRUBY)" MINIRUBY="$(BOOTSTRAPRUBY)" $(mflags)
+PRISM_BUILD_DIR = prism
+
+PRISM_FILES = prism/api_node.$(OBJEXT) \
+ prism/api_pack.$(OBJEXT) \
+ prism/diagnostic.$(OBJEXT) \
+ prism/encoding.$(OBJEXT) \
+ prism/extension.$(OBJEXT) \
+ prism/node.$(OBJEXT) \
+ prism/options.$(OBJEXT) \
+ prism/pack.$(OBJEXT) \
+ prism/prettyprint.$(OBJEXT) \
+ prism/regexp.$(OBJEXT) \
+ prism/serialize.$(OBJEXT) \
+ prism/token_type.$(OBJEXT) \
+ prism/util/pm_buffer.$(OBJEXT) \
+ prism/util/pm_char.$(OBJEXT) \
+ prism/util/pm_constant_pool.$(OBJEXT) \
+ prism/util/pm_list.$(OBJEXT) \
+ prism/util/pm_memchr.$(OBJEXT) \
+ prism/util/pm_newline_list.$(OBJEXT) \
+ prism/util/pm_state_stack.$(OBJEXT) \
+ prism/util/pm_string.$(OBJEXT) \
+ prism/util/pm_string_list.$(OBJEXT) \
+ prism/util/pm_strncasecmp.$(OBJEXT) \
+ prism/util/pm_strpbrk.$(OBJEXT) \
+ prism/prism.$(OBJEXT) \
+ prism_init.$(OBJEXT)
+
COMMONOBJS = array.$(OBJEXT) \
ast.$(OBJEXT) \
bignum.$(OBJEXT) \
@@ -108,13 +139,15 @@ COMMONOBJS = array.$(OBJEXT) \
marshal.$(OBJEXT) \
math.$(OBJEXT) \
memory_view.$(OBJEXT) \
- mjit.$(OBJEXT) \
- mjit_c.$(OBJEXT) \
+ rjit.$(OBJEXT) \
+ rjit_c.$(OBJEXT) \
node.$(OBJEXT) \
+ node_dump.$(OBJEXT) \
numeric.$(OBJEXT) \
object.$(OBJEXT) \
pack.$(OBJEXT) \
parse.$(OBJEXT) \
+ parser_st.$(OBJEXT) \
proc.$(OBJEXT) \
process.$(OBJEXT) \
ractor.$(OBJEXT) \
@@ -129,6 +162,7 @@ COMMONOBJS = array.$(OBJEXT) \
regparse.$(OBJEXT) \
regsyntax.$(OBJEXT) \
ruby.$(OBJEXT) \
+ ruby_parser.$(OBJEXT) \
scheduler.$(OBJEXT) \
shape.$(OBJEXT) \
signal.$(OBJEXT) \
@@ -141,7 +175,6 @@ COMMONOBJS = array.$(OBJEXT) \
thread.$(OBJEXT) \
time.$(OBJEXT) \
transcode.$(OBJEXT) \
- transient_heap.$(OBJEXT) \
util.$(OBJEXT) \
variable.$(OBJEXT) \
version.$(OBJEXT) \
@@ -150,6 +183,8 @@ COMMONOBJS = array.$(OBJEXT) \
vm_dump.$(OBJEXT) \
vm_sync.$(OBJEXT) \
vm_trace.$(OBJEXT) \
+ weakmap.$(OBJEXT) \
+ $(PRISM_FILES) \
$(YJIT_OBJ) \
$(YJIT_LIBOBJ) \
$(COROUTINE_OBJ) \
@@ -158,6 +193,71 @@ COMMONOBJS = array.$(OBJEXT) \
$(BUILTIN_TRANSOBJS) \
$(MISSING)
+$(PRISM_FILES): $(PRISM_BUILD_DIR)/.time $(PRISM_BUILD_DIR)/util/.time
+
+$(PRISM_BUILD_DIR)/.time $(PRISM_BUILD_DIR)/util/.time:
+ $(Q) $(MAKEDIRS) $(@D)
+ @$(NULLCMD) > $@
+
+main: $(srcdir)/lib/prism/compiler.rb
+srcs: $(srcdir)/lib/prism/compiler.rb
+$(srcdir)/lib/prism/compiler.rb: $(PRISM_SRCDIR)/config.yml $(PRISM_SRCDIR)/templates/template.rb $(PRISM_SRCDIR)/templates/lib/prism/compiler.rb.erb
+ $(Q) $(BASERUBY) $(PRISM_SRCDIR)/templates/template.rb lib/prism/compiler.rb $(srcdir)/lib/prism/compiler.rb
+
+main: $(srcdir)/lib/prism/dispatcher.rb
+srcs: $(srcdir)/lib/prism/dispatcher.rb
+$(srcdir)/lib/prism/dispatcher.rb: $(PRISM_SRCDIR)/config.yml $(PRISM_SRCDIR)/templates/template.rb $(PRISM_SRCDIR)/templates/lib/prism/dispatcher.rb.erb
+ $(Q) $(BASERUBY) $(PRISM_SRCDIR)/templates/template.rb lib/prism/dispatcher.rb $(srcdir)/lib/prism/dispatcher.rb
+
+main: $(srcdir)/lib/prism/dsl.rb
+srcs: $(srcdir)/lib/prism/dsl.rb
+$(srcdir)/lib/prism/dsl.rb: $(PRISM_SRCDIR)/config.yml $(PRISM_SRCDIR)/templates/template.rb $(PRISM_SRCDIR)/templates/lib/prism/dsl.rb.erb
+ $(Q) $(BASERUBY) $(PRISM_SRCDIR)/templates/template.rb lib/prism/dsl.rb $(srcdir)/lib/prism/dsl.rb
+
+main: $(srcdir)/lib/prism/mutation_compiler.rb
+srcs: $(srcdir)/lib/prism/mutation_compiler.rb
+$(srcdir)/lib/prism/mutation_compiler.rb: $(PRISM_SRCDIR)/config.yml $(PRISM_SRCDIR)/templates/template.rb $(PRISM_SRCDIR)/templates/lib/prism/mutation_compiler.rb.erb
+ $(Q) $(BASERUBY) $(PRISM_SRCDIR)/templates/template.rb lib/prism/mutation_compiler.rb $(srcdir)/lib/prism/mutation_compiler.rb
+
+main: $(srcdir)/lib/prism/node.rb
+srcs: $(srcdir)/lib/prism/node.rb
+$(srcdir)/lib/prism/node.rb: $(PRISM_SRCDIR)/config.yml $(PRISM_SRCDIR)/templates/template.rb $(PRISM_SRCDIR)/templates/lib/prism/node.rb.erb
+ $(Q) $(BASERUBY) $(PRISM_SRCDIR)/templates/template.rb lib/prism/node.rb $(srcdir)/lib/prism/node.rb
+
+main: $(srcdir)/lib/prism/serialize.rb
+srcs: $(srcdir)/lib/prism/serialize.rb
+$(srcdir)/lib/prism/serialize.rb: $(PRISM_SRCDIR)/config.yml $(PRISM_SRCDIR)/templates/template.rb $(PRISM_SRCDIR)/templates/lib/prism/serialize.rb.erb
+ $(Q) $(BASERUBY) $(PRISM_SRCDIR)/templates/template.rb lib/prism/serialize.rb $(srcdir)/lib/prism/serialize.rb
+
+main: $(srcdir)/lib/prism/visitor.rb
+srcs: $(srcdir)/lib/prism/visitor.rb
+$(srcdir)/lib/prism/visitor.rb: $(PRISM_SRCDIR)/config.yml $(PRISM_SRCDIR)/templates/template.rb $(PRISM_SRCDIR)/templates/lib/prism/visitor.rb.erb
+ $(Q) $(BASERUBY) $(PRISM_SRCDIR)/templates/template.rb lib/prism/visitor.rb $(srcdir)/lib/prism/visitor.rb
+
+srcs: prism/api_node.c
+prism/api_node.c: $(PRISM_SRCDIR)/config.yml $(PRISM_SRCDIR)/templates/template.rb $(PRISM_SRCDIR)/templates/ext/prism/api_node.c.erb
+ $(Q) $(BASERUBY) $(PRISM_SRCDIR)/templates/template.rb ext/prism/api_node.c $@
+
+srcs: prism/ast.h
+prism/ast.h: $(PRISM_SRCDIR)/config.yml $(PRISM_SRCDIR)/templates/template.rb $(PRISM_SRCDIR)/templates/include/prism/ast.h.erb
+ $(Q) $(BASERUBY) $(PRISM_SRCDIR)/templates/template.rb include/prism/ast.h $@
+
+srcs: prism/node.c
+prism/node.c: $(PRISM_SRCDIR)/config.yml $(PRISM_SRCDIR)/templates/template.rb $(PRISM_SRCDIR)/templates/src/node.c.erb
+ $(Q) $(BASERUBY) $(PRISM_SRCDIR)/templates/template.rb src/node.c $@
+
+srcs: prism/prettyprint.c
+prism/prettyprint.c: $(PRISM_SRCDIR)/config.yml $(PRISM_SRCDIR)/templates/template.rb $(PRISM_SRCDIR)/templates/src/prettyprint.c.erb
+ $(Q) $(BASERUBY) $(PRISM_SRCDIR)/templates/template.rb src/prettyprint.c $@
+
+srcs: prism/serialize.c
+prism/serialize.c: $(PRISM_SRCDIR)/config.yml $(PRISM_SRCDIR)/templates/template.rb $(PRISM_SRCDIR)/templates/src/serialize.c.erb
+ $(Q) $(BASERUBY) $(PRISM_SRCDIR)/templates/template.rb src/serialize.c $@
+
+srcs: prism/token_type.c
+prism/token_type.c: $(PRISM_SRCDIR)/config.yml $(PRISM_SRCDIR)/templates/template.rb $(PRISM_SRCDIR)/templates/src/token_type.c.erb
+ $(Q) $(BASERUBY) $(PRISM_SRCDIR)/templates/template.rb src/token_type.c $@
+
EXPORTOBJS = $(DLNOBJ) \
localeinit.$(OBJEXT) \
loadpath.$(OBJEXT) \
@@ -196,7 +296,7 @@ INSTALL_DATA_MODE = 0644
BOOTSTRAPRUBY_COMMAND = $(BOOTSTRAPRUBY) $(BOOTSTRAPRUBY_OPT)
TESTSDIR = $(srcdir)/test
TOOL_TESTSDIR = $(tooldir)/test
-TEST_EXCLUDES = --excludes-dir=$(TESTSDIR)/excludes --name=!/memory_leak/
+TEST_EXCLUDES = --excludes-dir=$(TESTSDIR)/.excludes --name=!/memory_leak/
TESTWORKDIR = testwork
TESTOPTS = $(RUBY_TESTOPTS)
@@ -231,45 +331,15 @@ all: $(SHOWFLAGS) main docs
main: $(SHOWFLAGS) exts $(ENCSTATIC:static=lib)encs
@$(NULLCMD)
-main: $(srcdir)/lib/ruby_vm/mjit/instruction.rb
-srcs: $(srcdir)/lib/ruby_vm/mjit/instruction.rb
-$(srcdir)/lib/ruby_vm/mjit/instruction.rb: $(tooldir)/insns2vm.rb $(tooldir)/ruby_vm/views/lib/ruby_vm/mjit/instruction.rb.erb $(srcdir)/insns.def
+main: $(srcdir)/lib/ruby_vm/rjit/instruction.rb
+srcs: $(srcdir)/lib/ruby_vm/rjit/instruction.rb
+$(srcdir)/lib/ruby_vm/rjit/instruction.rb: $(tooldir)/insns2vm.rb $(tooldir)/ruby_vm/views/lib/ruby_vm/rjit/instruction.rb.erb $(srcdir)/insns.def
$(ECHO) generating $@
$(Q) $(BASERUBY) -Ku $(tooldir)/insns2vm.rb --basedir="$(srcdir)" $(INSNS2VMOPT) $@
-mjit-headers: $(MJIT_SUPPORT)-mjit-headers
-no-mjit-headers: PHONY
-yes-mjit-headers: mjit_config.h PHONY
-
-mjit.$(OBJEXT): mjit_config.h
-mjit_config.h: Makefile
-
-.PHONY: mjit-bindgen
-mjit-bindgen:
- $(Q) $(BASERUBY) -rrubygems -C $(srcdir)/tool/mjit bindgen.rb $(CURDIR)
-
-# These rules using MJIT_HEADER_SUFFIX must be in common.mk, not
-# Makefile.in, in order to override the macro in defs/universal.mk.
-
-# Other `-Dxxx`s preceding `-DMJIT_HEADER` will be removed in transform_mjit_header.rb.
-# So `-DMJIT_HEADER` should be passed first when rb_mjit_header.h is generated.
-$(TIMESTAMPDIR)/$(MJIT_HEADER:.h=)$(MJIT_HEADER_SUFFIX).time: probes.h vm.$(OBJEXT) \
- $(TIMESTAMPDIR)/$(arch)/.time $(tooldir)/mjit_tabs.rb $(PREP) $(RBCONFIG)
- $(ECHO) building $(@F:.time=.h)
- $(Q)$(MINIRUBY) $(tooldir)/mjit_tabs.rb "$(MJIT_TABS)" \
- $(CPP) -DMJIT_HEADER $(MJIT_HEADER_FLAGS) $(CFLAGS) $(XCFLAGS) $(CPPFLAGS) $(srcdir)/vm.c $(CPPOUTFLAG)$(@F:.time=.h).new
- $(Q) $(IFCHANGE) "--timestamp=$@" $(@F:.time=.h) $(@F:.time=.h).new
-
-$(MJIT_HEADER:.h=)$(MJIT_HEADER_SUFFIX).h: $(TIMESTAMPDIR)/$(MJIT_HEADER:.h=)$(MJIT_HEADER_SUFFIX).time
-
-$(MJIT_MIN_HEADER:.h=)$(MJIT_HEADER_SUFFIX).h: \
- $(TIMESTAMPDIR)/$(MJIT_HEADER:.h=)$(MJIT_HEADER_SUFFIX).time \
- $(tooldir)/transform_mjit_header.rb $(PREP) \
- $(MJIT_HEADER:.h=)$(MJIT_HEADER_SUFFIX).h
- $(ECHO) building $@
- $(Q)$(MINIRUBY) $(tooldir)/transform_mjit_header.rb "$(CC) $(CFLAGS) -w" $(MJIT_HEADER:.h=)$(MJIT_HEADER_ARCH).h $@
- $(Q) $(MAKEDIRS) $(MJIT_HEADER_INSTALL_DIR)
- $(Q) $(MAKE_LINK) $@ $(MJIT_HEADER_INSTALL_DIR)/$(@F)
+.PHONY: rjit-bindgen
+rjit-bindgen:
+ $(Q) $(BASERUBY) -rrubygems -C $(srcdir)/tool/rjit bindgen.rb $(CURDIR)
.PHONY: showflags
exts enc trans: $(SHOWFLAGS)
@@ -325,7 +395,8 @@ configure-ext: $(EXTS_MK)
build-ext: $(EXTS_MK)
$(Q)$(MAKE) -f $(EXTS_MK) $(mflags) libdir="$(libdir)" LIBRUBY_EXTS=$(LIBRUBY_EXTS) \
- EXTENCS="$(ENCOBJS)" MINIRUBY="$(MINIRUBY)" UPDATE_LIBRARIES=no $(EXTSTATIC)
+ EXTENCS="$(ENCOBJS)" BASERUBY="$(BASERUBY)" MINIRUBY="$(MINIRUBY)" \
+ UPDATE_LIBRARIES=no $(EXTSTATIC)
$(Q)$(MAKE) $(EXTS_NOTE)
exts-note: $(EXTS_MK)
@@ -368,8 +439,8 @@ Doxyfile: $(srcdir)/template/Doxyfile.tmpl $(PREP) $(tooldir)/generic_erb.rb $(R
$(Q) $(MINIRUBY) $(tooldir)/generic_erb.rb -o $@ $(srcdir)/template/Doxyfile.tmpl \
--srcdir="$(srcdir)" --miniruby="$(MINIRUBY)"
-program: $(SHOWFLAGS) $(PROGRAM)
-wprogram: $(SHOWFLAGS) $(WPROGRAM)
+program: $(SHOWFLAGS) $(DOT_WAIT) $(PROGRAM)
+wprogram: $(SHOWFLAGS) $(DOT_WAIT) $(WPROGRAM)
mini: PHONY miniruby$(EXEEXT)
$(PROGRAM) $(WPROGRAM): $(LIBRUBY) $(MAINOBJ) $(OBJS) $(EXTOBJS) $(SETUP) $(PREP)
@@ -390,12 +461,12 @@ ruby.imp: $(COMMONOBJS)
$(NM) -Pgp $(COMMONOBJS) | \
awk 'BEGIN{print "#!"}; $$2~/^[A-TV-Z]$$/&&$$1!~/^$(SYMBOL_PREFIX)(Init_|InitVM_|ruby_static_id_|.*_threadptr_|rb_ec_)|^\./{print $$1}'; \
($(CHDIR) $(srcdir) && \
- exec sed -n '/^MJIT_FUNC_EXPORTED/!d;N;s/.*\n\(rb_[a-zA-Z_0-9]*\).*/$(SYMBOL_PREFIX)\1/p' cont.c gc.c thread*c vm*.c) \
+ exec sed -n '/^RJIT_FUNC_EXPORTED/!d;N;s/.*\n\(rb_[a-zA-Z_0-9]*\).*/$(SYMBOL_PREFIX)\1/p' cont.c gc.c thread*c vm*.c) \
} | \
sort -u -o $@
install: install-$(INSTALLDOC)
-docs: $(DOCTARGETS)
+docs: srcs-doc $(DOCTARGETS)
pkgconfig-data: $(ruby_pc)
$(ruby_pc): $(srcdir)/template/ruby.pc.in config.status
@@ -589,18 +660,24 @@ do-install-dbg: $(PROGRAM) pre-install-dbg
post-install-dbg::
@$(NULLCMD)
-rdoc: PHONY main
+rdoc: PHONY main srcs-doc
@echo Generating RDoc documentation
$(Q) $(RDOC) --ri --op "$(RDOCOUT)" $(RDOC_GEN_OPTS) $(RDOCFLAGS) "$(srcdir)"
-html: PHONY main
+html: PHONY main srcs-doc
@echo Generating RDoc HTML files
$(Q) $(RDOC) --op "$(HTMLOUT)" $(RDOC_GEN_OPTS) $(RDOCFLAGS) "$(srcdir)"
-rdoc-coverage: PHONY main
+rdoc-coverage: PHONY main srcs-doc
@echo Generating RDoc coverage report
$(Q) $(RDOC) --quiet -C $(RDOCFLAGS) "$(srcdir)"
+undocumented: PHONY main srcs-doc
+ $(Q) $(RDOC) --quiet -C $(RDOCFLAGS) "$(srcdir)" | \
+ sed -n \
+ -e '/^ *# in file /{' -e 's///;N;s/\n/: /p' -e '}' \
+ -e 's/^ *\(.*[^ ]\) *# in file \(.*\)/\2: \1/p'
+
RDOCBENCHOUT=/tmp/rdocbench
GCBENCH_ITEM=null
@@ -635,8 +712,11 @@ clean-local:: clean-runnable
$(Q)$(RM) y.tab.c y.output encdb.h transdb.h config.log rbconfig.rb $(ruby_pc) $(COROUTINE_H:/Context.h=/.time)
$(Q)$(RM) probes.h probes.$(OBJEXT) probes.stamp ruby-glommed.$(OBJEXT) ruby.imp ChangeLog $(STATIC_RUBY)$(EXEEXT)
$(Q)$(RM) GNUmakefile.old Makefile.old $(arch)-fake.rb bisect.sh $(ENC_TRANS_D) builtin_binary.inc
+ $(Q)$(RM) $(PRISM_BUILD_DIR)/.time $(PRISM_BUILD_DIR)/*/.time
-$(Q)$(RMALL) yjit/target
- -$(Q) $(RMDIR) enc/jis enc/trans enc $(COROUTINE_H:/Context.h=) coroutine yjit 2> $(NULL) || $(NULLCMD)
+ -$(Q) $(RMDIR) enc/jis enc/trans enc $(COROUTINE_H:/Context.h=) coroutine yjit \
+ $(PRISM_BUILD_DIR)/*/ $(PRISM_BUILD_DIR) tmp \
+ 2> $(NULL) || $(NULLCMD)
bin/clean-runnable:: PHONY
$(Q)$(CHDIR) bin 2>$(NULL) && $(RM) $(PROGRAM) $(WPROGRAM) $(GORUBY)$(EXEEXT) bin/*.$(DLEXT) 2>$(NULL) || $(NULLCMD)
@@ -684,8 +764,6 @@ clean-srcs-local::
$(Q)$(RM) parse.c parse.h lex.c enc/trans/newline.c revision.h
$(Q)$(RM) id.c id.h probes.dmyh probes.h
$(Q)$(RM) encdb.h transdb.h verconf.h ruby-runner.h
- $(Q)$(RM) mjit_config.h rb_mjit_header.h
- $(Q)$(RM) $(MJIT_MIN_HEADER) $(MJIT_MIN_HEADER:.h=)$(MJIT_HEADER_SUFFIX:%=*).h
realclean-srcs-local:: clean-srcs-local
$(Q)$(CHDIR) $(srcdir) && $(RM) \
@@ -780,17 +858,19 @@ $(HAVE_BASERUBY:no=)$(arch)-fake.rb: miniruby$(EXEEXT)
# actually depending on other headers more.
$(arch:noarch=ignore)-fake.rb: $(top_srcdir)/revision.h $(top_srcdir)/version.h $(srcdir)/version.c
-$(arch:noarch=ignore)-fake.rb: {$(VPATH)}id.h {$(VPATH)}vm_opts.h
+$(arch:noarch=ignore)-fake.rb: {$(VPATH)}id.h {$(VPATH)}vm_opts.h $(REVISION_H)
$(arch:noarch=ignore)-fake.rb: $(srcdir)/template/fake.rb.in $(tooldir)/generic_erb.rb
$(ECHO) generating $@
$(Q) $(CPP) -DRUBY_EXPORT $(INCFLAGS) $(CPPFLAGS) "$(srcdir)/version.c" | \
$(BOOTSTRAPRUBY) "$(tooldir)/generic_erb.rb" -o $@ "$(srcdir)/template/fake.rb.in" \
- i=- srcdir="$(srcdir)" BASERUBY="$(BASERUBY)"
+ i=- srcdir="$(srcdir)" BASERUBY="$(BASERUBY)" \
+ LIBPATHENV="$(LIBPATHENV)" PRELOADENV="$(PRELOADENV)" LIBRUBY_SO="$(LIBRUBY_SO)"
noarch-fake.rb: # prerequisite of yes-fake
$(Q) exit > $@
+# runner: BASERUBY, target: miniruby
btest: $(TEST_RUNNABLE)-btest
no-btest: PHONY
yes-btest: yes-fake miniruby$(EXEEXT) PHONY
@@ -798,6 +878,7 @@ yes-btest: yes-fake miniruby$(EXEEXT) PHONY
$(Q)$(gnumake_recursive)$(exec) $(BOOTSTRAPRUBY) "$(srcdir)/bootstraptest/runner.rb" --ruby="$(BTESTRUBY) $(RUN_OPTS)" $(OPTS) $(TESTOPTS) $(BTESTS)
$(ACTIONS_ENDGROUP)
+# runner: ruby, target: ruby
btest-ruby: $(TEST_RUNNABLE)-btest-ruby
no-btest-ruby: PHONY
yes-btest-ruby: prog PHONY
@@ -805,6 +886,12 @@ yes-btest-ruby: prog PHONY
$(Q)$(gnumake_recursive)$(exec) $(RUNRUBY) "$(srcdir)/bootstraptest/runner.rb" --ruby="$(PROGRAM) -I$(srcdir)/lib $(RUN_OPTS)" $(OPTS) $(TESTOPTS) $(BTESTS)
$(ACTIONS_ENDGROUP)
+# runner: BASERUBY, target: ruby
+btest-bruby: prog PHONY
+ $(ACTIONS_GROUP)
+ $(Q)$(gnumake_recursive)$(exec) $(BOOTSTRAPRUBY) "$(srcdir)/bootstraptest/runner.rb" --ruby="$(PROGRAM) -I$(srcdir)/lib $(RUN_OPTS)" $(OPTS) $(TESTOPTS) $(BTESTS)
+ $(ACTIONS_ENDGROUP)
+
rtest: yes-fake miniruby$(EXEEXT) PHONY
$(ACTIONS_GROUP)
$(Q)$(exec) $(BOOTSTRAPRUBY) "$(srcdir)/bootstraptest/runner.rb" --ruby="$(BTESTRUBY) $(RUN_OPTS)" --sets=ractor -v
@@ -843,10 +930,17 @@ test-sample: test-basic # backward compatibility for mswin-build
test-short: btest-ruby $(DOT_WAIT) test-knownbug $(DOT_WAIT) test-basic
test: test-short
+# Separate to skip updating encs and exts by `make -o test-precheck`
+# for GNU make.
+test-precheck: encs exts PHONY $(DOT_WAIT)
+yes-test-all-precheck: programs $(DOT_WAIT) test-precheck
+
+PRECHECK_TEST_ALL = yes-test-all-precheck
+
# $ make test-all TESTOPTS="--help" displays more detail
# for example, make test-all TESTOPTS="-j2 -v -n test-name -- test-file-name"
test-all: $(TEST_RUNNABLE)-test-all
-yes-test-all: programs PHONY
+yes-test-all: $(PRECHECK_TEST_ALL)
$(ACTIONS_GROUP)
$(gnumake_recursive)$(Q)$(exec) $(RUNRUBY) "$(TESTSDIR)/runner.rb" --ruby="$(RUNRUBY)" $(TEST_EXCLUDES) $(TESTOPTS) $(TESTS)
$(ACTIONS_ENDGROUP)
@@ -888,13 +982,14 @@ $(RBCONFIG): $(tooldir)/mkconfig.rb config.status $(srcdir)/version.h $(srcdir)/
test-rubyspec: test-spec
yes-test-rubyspec: yes-test-spec
-test-spec-precheck: programs yes-fake
+yes-test-spec-precheck: yes-test-all-precheck yes-fake
test-spec: $(TEST_RUNNABLE)-test-spec
-yes-test-spec: test-spec-precheck
+yes-test-spec: yes-test-spec-precheck
$(ACTIONS_GROUP)
$(gnumake_recursive)$(Q) \
- $(RUNRUBY) -r./$(arch)-fake $(srcdir)/spec/mspec/bin/mspec run -B $(srcdir)/spec/default.mspec $(MSPECOPT) $(SPECOPTS)
+ $(RUNRUBY) -r./$(arch)-fake -r$(tooldir)/rubyspec_temp \
+ $(srcdir)/spec/mspec/bin/mspec run -B $(srcdir)/spec/default.mspec $(MSPECOPT) $(SPECOPTS)
$(ACTIONS_ENDGROUP)
no-test-spec:
@@ -938,23 +1033,19 @@ $(ENC_MK): $(srcdir)/enc/make_encmake.rb $(srcdir)/enc/Makefile.in $(srcdir)/enc
PHONY:
-{$(VPATH)}parse.c: {$(VPATH)}parse.y $(tooldir)/ytab.sed {$(VPATH)}id.h
+{$(VPATH)}parse.c: {$(VPATH)}parse.y {$(VPATH)}id.h
{$(VPATH)}parse.h: {$(VPATH)}parse.c
{$(srcdir)}.y.c:
$(ECHO) generating $@
- $(Q)$(BASERUBY) $(tooldir)/id2token.rb $(SRC_FILE) > parse.tmp.y
- $(Q)$(YACC) -d $(YFLAGS) -o y.tab.c parse.tmp.y
- $(Q)$(RM) parse.tmp.y
- $(Q)sed -f $(tooldir)/ytab.sed -e "/^#/s|parse\.tmp\.[iy]|$(SRC_FILE)|" -e "/^#/s!y\.tab\.c!$@!" y.tab.c > $@.new
- $(Q)$(MV) $@.new $@
- $(Q)sed -e "/^#line.*y\.tab\.h/d;/^#line.*parse.*\.y/d" y.tab.h > $(@:.c=.h)
- $(Q)$(RM) y.tab.c y.tab.h
+ $(Q)$(BASERUBY) $(tooldir)/id2token.rb $(SRC_FILE) | \
+ $(YACC) $(YFLAGS) -o$@ -H$*.h - parse.y
$(PLATFORM_D):
$(Q) $(MAKEDIRS) $(PLATFORM_DIR) $(@D)
@$(NULLCMD) > $@
+exe/$(PROGRAM): $(TIMESTAMPDIR)/$(arch)/.time
exe/$(PROGRAM): ruby-runner.c ruby-runner.h exe/.time $(PREP) {$(VPATH)}config.h
$(Q) $(CC) $(CFLAGS) $(INCFLAGS) $(CPPFLAGS) -DRUBY_INSTALL_NAME=$(@F) $(COUTFLAG)ruby-runner.$(OBJEXT) -c $(CSRCFLAG)$(srcdir)/ruby-runner.c
$(Q) $(PURIFY) $(CC) $(CFLAGS) $(LDFLAGS) $(OUTFLAG)$@ ruby-runner.$(OBJEXT) $(LIBS)
@@ -967,6 +1058,8 @@ exe/$(PROGRAM): ruby-runner.c ruby-runner.h exe/.time $(PREP) {$(VPATH)}config.h
-e ' File.symlink(prog, dest)' \
-e 'end' \
$(@F) $(@D) $(RUBY_INSTALL_NAME)$(EXEEXT)
+ $(Q) $(BOOTSTRAPRUBY) -r$(srcdir)/lib/fileutils \
+ -e 'FileUtils::Verbose.ln_sr(*ARGV, force: true)' rbconfig.rb $(EXTOUT)/$(arch)
exe/.time:
$(Q) $(MAKEDIRS) $(@D)
@@ -1034,7 +1127,7 @@ parse.$(OBJEXT): {$(VPATH)}parse.c
miniprelude.$(OBJEXT): {$(VPATH)}miniprelude.c
# dependencies for optional sources.
-compile.$(OBJEXT): {$(VPATH)}opt_sc.inc {$(VPATH)}optunifs.inc
+compile.$(OBJEXT): {$(VPATH)}optunifs.inc
win32/win32.$(OBJEXT): {$(VPATH)}win32/win32.c {$(VPATH)}win32/file.h \
{$(VPATH)}dln.h {$(VPATH)}dln_find.c {$(VPATH)}encindex.h \
@@ -1061,7 +1154,6 @@ INSNS2VMOPT = --srcdir="$(srcdir)"
srcs_vpath = {$(VPATH)}
inc_common_headers = $(tooldir)/ruby_vm/views/_copyright.erb $(tooldir)/ruby_vm/views/_notice.erb
-$(srcs_vpath)opt_sc.inc: $(tooldir)/ruby_vm/views/opt_sc.inc.erb $(inc_common_headers)
$(srcs_vpath)optinsn.inc: $(tooldir)/ruby_vm/views/optinsn.inc.erb $(inc_common_headers)
$(srcs_vpath)optunifs.inc: $(tooldir)/ruby_vm/views/optunifs.inc.erb $(inc_common_headers)
$(srcs_vpath)insns.inc: $(tooldir)/ruby_vm/views/insns.inc.erb $(inc_common_headers)
@@ -1073,7 +1165,6 @@ $(srcs_vpath)insns_info.inc: $(tooldir)/ruby_vm/views/insns_info.inc.erb $(inc_c
$(srcs_vpath)vmtc.inc: $(tooldir)/ruby_vm/views/vmtc.inc.erb $(inc_common_headers)
$(srcs_vpath)vm.inc: $(tooldir)/ruby_vm/views/vm.inc.erb $(inc_common_headers) \
$(tooldir)/ruby_vm/views/_insn_entry.erb $(tooldir)/ruby_vm/views/_trace_instruction.erb
-$(srcs_vpath)mjit_sp_inc.inc: $(tooldir)/ruby_vm/views/mjit_sp_inc.inc.erb
BUILTIN_RB_SRCS = \
$(srcdir)/ast.rb \
@@ -1082,8 +1173,8 @@ BUILTIN_RB_SRCS = \
$(srcdir)/numeric.rb \
$(srcdir)/io.rb \
$(srcdir)/marshal.rb \
- $(srcdir)/mjit.rb \
- $(srcdir)/mjit_c.rb \
+ $(srcdir)/rjit.rb \
+ $(srcdir)/rjit_c.rb \
$(srcdir)/pack.rb \
$(srcdir)/trace_point.rb \
$(srcdir)/warning.rb \
@@ -1106,9 +1197,16 @@ common-srcs: $(srcs_vpath)parse.c $(srcs_vpath)lex.c $(srcs_vpath)enc/trans/newl
missing-srcs: $(srcdir)/missing/des_tables.c
-srcs: common-srcs missing-srcs srcs-enc
+srcs: common-srcs missing-srcs srcs-enc srcs-doc
+
+RIPPER_SRCS = $(srcdir)/ext/ripper/ripper.c \
+ $(srcdir)/ext/ripper/ripper_init.c \
+ $(srcdir)/ext/ripper/eventids1.h \
+ $(srcdir)/ext/ripper/eventids1.c \
+ $(srcdir)/ext/ripper/eventids2table.c \
+ # RIPPER_SRCS
-EXT_SRCS = $(srcdir)/ext/ripper/ripper.c \
+EXT_SRCS = ripper_srcs \
$(srcdir)/ext/rbconfig/sizeof/sizes.c \
$(srcdir)/ext/rbconfig/sizeof/limits.c \
$(srcdir)/ext/socket/constdefs.c \
@@ -1154,9 +1252,9 @@ id.c: $(tooldir)/generic_erb.rb $(srcdir)/template/id.c.tmpl $(srcdir)/defs/id.d
$(Q) $(BASERUBY) $(tooldir)/generic_erb.rb --output=$@ \
$(srcdir)/template/id.c.tmpl
-node_name.inc: $(tooldir)/node_name.rb $(srcdir)/node.h
+node_name.inc: $(tooldir)/node_name.rb $(srcdir)/rubyparser.h
$(ECHO) generating $@
- $(Q) $(BASERUBY) -n $(tooldir)/node_name.rb < $(srcdir)/node.h > $@
+ $(Q) $(BASERUBY) -n $(tooldir)/node_name.rb < $(srcdir)/rubyparser.h > $@
encdb.h: $(RBCONFIG) $(tooldir)/generic_erb.rb $(srcdir)/template/encdb.h.tmpl
$(ECHO) generating $@
@@ -1208,9 +1306,13 @@ preludes: {$(srcdir)}golf_prelude.c
$(ECHO) making $@
$(Q) $(BASERUBY) $(tooldir)/mk_builtin_loader.rb $<
-builtin_binary.inc: $(PREP) $(BUILTIN_RB_SRCS) $(srcdir)/template/builtin_binary.inc.tmpl
+$(BUILTIN_BINARY:yes=built)in_binary.inc: $(PREP) $(BUILTIN_RB_SRCS) $(srcdir)/template/builtin_binary.inc.tmpl
$(Q) $(MINIRUBY) $(tooldir)/generic_erb.rb -o $@ \
- $(srcdir)/template/builtin_binary.inc.tmpl -- --cross=$(CROSS_COMPILING)
+ $(srcdir)/template/builtin_binary.inc.tmpl
+ -$(Q) sha256sum $@ 2> $(NULL) || $(NULLCMD)
+
+$(BUILTIN_BINARY:no=builtin)_binary.inc:
+ $(Q) echo> $@ // empty $(@F)
$(BUILTIN_RB_INCS): $(top_srcdir)/tool/mk_builtin_loader.rb
@@ -1224,13 +1326,17 @@ $(REVISION_H)$(yes_baseruby:yes=~disabled~):
# uncommon.mk: $(REVISION_H)
# $(MKFILES): $(REVISION_H)
-$(srcdir)/ext/ripper/ripper.c: $(srcdir)/ext/ripper/tools/preproc.rb $(srcdir)/parse.y $(srcdir)/defs/id.def $(srcdir)/ext/ripper/depend
+ripper_srcs: $(RIPPER_SRCS)
+
+$(RIPPER_SRCS): $(srcdir)/parse.y $(srcdir)/defs/id.def
+$(RIPPER_SRCS): $(srcdir)/ext/ripper/tools/preproc.rb $(srcdir)/ext/ripper/tools/dsl.rb
+$(RIPPER_SRCS): $(srcdir)/ext/ripper/ripper_init.c.tmpl $(srcdir)/ext/ripper/eventids2.c
$(ECHO) generating $@
$(Q) $(CHDIR) $(@D) && \
$(CAT_DEPEND) depend | \
$(exec) $(MAKE) -f - $(mflags) \
- Q=$(Q) ECHO=$(ECHO) RM="$(RM1)" BISON="$(YACC)" top_srcdir=../.. srcdir=. VPATH=../.. \
- RUBY="$(BASERUBY)" PATH_SEPARATOR="$(PATH_SEPARATOR)" LANG=C
+ Q=$(Q) ECHO=$(ECHO) RM="$(RM1)" top_srcdir=../.. srcdir=. VPATH=../.. \
+ RUBY="$(BASERUBY)" BASERUBY="$(BASERUBY)" PATH_SEPARATOR="$(PATH_SEPARATOR)" LANG=C
$(srcdir)/ext/json/parser/parser.c: $(srcdir)/ext/json/parser/parser.rl $(srcdir)/ext/json/parser/prereq.mk
$(ECHO) generating $@
@@ -1258,7 +1364,7 @@ $(srcdir)/ext/rbconfig/sizeof/limits.c: $(srcdir)/ext/rbconfig/sizeof/depend \
$(exec) $(MAKE) -f - $(mflags) \
Q=$(Q) ECHO=$(ECHO) top_srcdir=../../.. srcdir=. VPATH=../../.. RUBY="$(BASERUBY)" $(@F)
-$(srcdir)/ext/socket/constdefs.c: $(srcdir)/ext/socket/depend
+$(srcdir)/ext/socket/constdefs.c: $(srcdir)/ext/socket/depend $(srcdir)/ext/socket/mkconstants.rb
$(Q) $(CHDIR) $(@D) && \
$(CAT_DEPEND) depend | \
$(exec) $(MAKE) -f - $(mflags) \
@@ -1411,6 +1517,20 @@ extract-gems$(gnumake:yes=-sequential): PHONY
-e 'end' \
gems/bundled_gems
+extract-gems$(gnumake:yes=-sequential): $(HAVE_GIT:yes=clone-bundled-gems-src)
+
+clone-bundled-gems-src: PHONY
+ $(Q) $(BASERUBY) -C "$(srcdir)" \
+ -Itool/lib -rbundled_gem -answ \
+ -e 'BEGIN {git = $$git}' \
+ -e 'gem, _, repo, rev = *$$F' \
+ -e 'next if !rev or /^#/=~gem' \
+ -e 'gemdir = "gems/src/#{gem}"' \
+ -e 'BundledGem.checkout(gemdir, repo, rev, git: git)' \
+ -e 'BundledGem.dummy_gemspec("#{gemdir}/#{gem}.gemspec")' \
+ -- -git="$(GIT)" \
+ gems/bundled_gems
+
outdate-bundled-gems: PHONY
$(Q) $(BASERUBY) $(tooldir)/$@.rb --make="$(MAKE)" --mflags="$(MFLAGS)" "$(srcdir)"
@@ -1440,7 +1560,7 @@ no-test-bundled-gems-prepare: no-test-bundled-gems-precheck
yes-test-bundled-gems-prepare: yes-test-bundled-gems-precheck
$(ACTIONS_GROUP)
$(XRUBY) -C "$(srcdir)" bin/gem install --no-document \
- --install-dir .bundle --conservative "bundler" "minitest:~> 5" "test-unit" "rake" "hoe" "yard" "pry" "packnga" "rexml" "json-schema" "test-unit-rr"
+ --install-dir .bundle --conservative "hoe" "json-schema" "test-unit-rr"
$(ACTIONS_ENDGROUP)
PREPARE_BUNDLED_GEMS = test-bundled-gems-prepare
@@ -1464,25 +1584,30 @@ no-test-syntax-suggest-prepare: no-test-syntax-suggest-precheck
yes-test-syntax-suggest-prepare: yes-test-syntax-suggest-precheck
$(ACTIONS_GROUP)
$(XRUBY) -C "$(srcdir)" bin/gem install --no-document \
- --install-dir .bundle --conservative "bundler" "rake" "rspec:~> 3" #"ruby-prof"
+ --install-dir .bundle --conservative "rspec:~> 3"
$(ACTIONS_ENDGROUP)
RSPECOPTS =
SYNTAX_SUGGEST_SPECS =
-PREPARE_SYNTAX_SUGGEST = test-syntax-suggest-prepare
+PREPARE_SYNTAX_SUGGEST = $(TEST_RUNNABLE)-test-syntax-suggest-prepare
test-syntax-suggest: $(TEST_RUNNABLE)-test-syntax-suggest
-yes-test-syntax-suggest: yes-$(PREPARE_SYNTAX_SUGGEST)
+yes-test-syntax-suggest: $(PREPARE_SYNTAX_SUGGEST)
+ $(ACTIONS_GROUP)
$(XRUBY) -C $(srcdir) -Ispec/syntax_suggest:spec/lib .bundle/bin/rspec \
+ --require rspec/expectations \
--require spec_helper --require formatter_overrides --require spec_coverage \
$(RSPECOPTS) spec/syntax_suggest/$(SYNTAX_SUGGEST_SPECS)
+ $(ACTIONS_ENDGROUP)
no-test-syntax-suggest:
-check: $(DOT_WAIT) $(TEST_RUNNABLE)-$(PREPARE_SYNTAX_SUGGEST) test-syntax-suggest
+check: $(DOT_WAIT) $(PREPARE_SYNTAX_SUGGEST) test-syntax-suggest
test-bundler-precheck: $(TEST_RUNNABLE)-test-bundler-precheck
no-test-bundler-precheck:
yes-test-bundler-precheck: main $(arch)-fake.rb
+yes-test-bundler-parallel-precheck: yes-test-bundler-precheck
+test-bundler-prepare: $(TEST_RUNNABLE)-test-bundler-prepare
no-test-bundler-prepare: no-test-bundler-precheck
yes-test-bundler-prepare: yes-test-bundler-precheck
$(ACTIONS_GROUP)
@@ -1496,7 +1621,7 @@ yes-test-bundler-prepare: yes-test-bundler-precheck
RSPECOPTS =
BUNDLER_SPECS =
-PREPARE_BUNDLER = yes-test-bundler-prepare
+PREPARE_BUNDLER = $(TEST_RUNNABLE)-test-bundler-prepare
test-bundler: $(TEST_RUNNABLE)-test-bundler
yes-test-bundler: $(PREPARE_BUNDLER)
$(gnumake_recursive)$(XRUBY) \
@@ -1668,6 +1793,16 @@ $(UNICODE_HDR_DIR)/name2ctype.h:
$(UNICODE_SRC_DATA_DIR) $(UNICODE_SRC_EMOJI_DATA_DIR) > $@.new
$(MV) $@.new $@
+srcs-doc: $(srcdir)/doc/regexp/unicode_properties.rdoc
+$(srcdir)/doc/regexp/$(ALWAYS_UPDATE_UNICODE:yes=unicode_properties.rdoc): \
+ $(UNICODE_HDR_DIR)/name2ctype.h $(UNICODE_PROPERTY_FILES)
+
+$(srcdir)/doc/regexp/unicode_properties.rdoc:
+ $(Q) $(BOOTSTRAPRUBY) $(tooldir)/generic_erb.rb -c -o $@ \
+ $(srcdir)/template/unicode_properties.rdoc.tmpl \
+ $(UNICODE_SRC_DATA_DIR) $(UNICODE_HDR_DIR)/name2ctype.h || \
+ $(TOUCH) $@
+
# the next non-comment line was:
# $(UNICODE_HDR_DIR)/casefold.h: $(tooldir)/enc-case-folding.rb \
# but was changed to make sure CI works on systems that don't have gperf
@@ -1733,7 +1868,7 @@ update-man-date: PHONY
ChangeLog:
$(ECHO) Generating $@
-$(Q) $(BASERUBY) -I"$(tooldir)/lib" -rvcs \
- -e 'VCS.detect(ARGV[0]).export_changelog("@", nil, nil, ARGV[1])' \
+ -e 'VCS.detect(ARGV[0]).export_changelog(path: ARGV[1])' \
"$(srcdir)" $@
HELP_EXTRA_TASKS = ""
@@ -1754,6 +1889,7 @@ help: PHONY
" runruby: runs test.rb by ruby you just built" \
" gdb: runs test.rb by miniruby under gdb" \
" gdb-ruby: runs test.rb by ruby under gdb" \
+ " runirb: starts irb on built ruby (not installed ruby)" \
" exam: equals make check test-bundler-parallel test-bundled-gems" \
" check: equals make test test-tool test-all test-spec test-syntax-suggest" \
" test: ruby core tests [BTESTS=<bootstraptest files>]" \
@@ -1773,12 +1909,12 @@ help: PHONY
" install: install all ruby distributions" \
" install-nodoc: install without rdoc" \
" install-cross: install cross compiling stuff" \
- " clean: clean for tarball" \
- " distclean: clean for repository" \
+ " clean: clean up to the state before build" \
+ " distclean: clean up to the state before configure" \
" golf: build goruby for golfers" \
$(HELP_EXTRA_TASKS) \
"see DeveloperHowto for more detail: " \
- " https://bugs.ruby-lang.org/projects/ruby/wiki/DeveloperHowto" \
+ " https://github.com/ruby/ruby/wiki/Developer-How-To" \
$(MESSAGE_END)
$(CROSS_COMPILING:yes=)builtin.$(OBJEXT): {$(VPATH)}mini_builtin.c
@@ -1810,6 +1946,7 @@ addr2line.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
addr2line.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
addr2line.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
addr2line.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
+addr2line.$(OBJEXT): {$(VPATH)}internal/attr/packed_struct.h
addr2line.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
addr2line.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
addr2line.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
@@ -1839,6 +1976,10 @@ addr2line.$(OBJEXT): {$(VPATH)}internal/stdbool.h
addr2line.$(OBJEXT): {$(VPATH)}internal/warning_push.h
addr2line.$(OBJEXT): {$(VPATH)}internal/xmalloc.h
addr2line.$(OBJEXT): {$(VPATH)}missing.h
+array.$(OBJEXT): $(CCAN_DIR)/check_type/check_type.h
+array.$(OBJEXT): $(CCAN_DIR)/container_of/container_of.h
+array.$(OBJEXT): $(CCAN_DIR)/list/list.h
+array.$(OBJEXT): $(CCAN_DIR)/str/str.h
array.$(OBJEXT): $(hdrdir)/ruby/ruby.h
array.$(OBJEXT): $(top_srcdir)/internal/array.h
array.$(OBJEXT): $(top_srcdir)/internal/basic_operators.h
@@ -1851,6 +1992,7 @@ array.$(OBJEXT): $(top_srcdir)/internal/enum.h
array.$(OBJEXT): $(top_srcdir)/internal/fixnum.h
array.$(OBJEXT): $(top_srcdir)/internal/gc.h
array.$(OBJEXT): $(top_srcdir)/internal/hash.h
+array.$(OBJEXT): $(top_srcdir)/internal/imemo.h
array.$(OBJEXT): $(top_srcdir)/internal/numeric.h
array.$(OBJEXT): $(top_srcdir)/internal/object.h
array.$(OBJEXT): $(top_srcdir)/internal/proc.h
@@ -1863,6 +2005,7 @@ array.$(OBJEXT): $(top_srcdir)/internal/warnings.h
array.$(OBJEXT): {$(VPATH)}array.c
array.$(OBJEXT): {$(VPATH)}array.rbinc
array.$(OBJEXT): {$(VPATH)}assert.h
+array.$(OBJEXT): {$(VPATH)}atomic.h
array.$(OBJEXT): {$(VPATH)}backward/2/assume.h
array.$(OBJEXT): {$(VPATH)}backward/2/attributes.h
array.$(OBJEXT): {$(VPATH)}backward/2/bool.h
@@ -1920,6 +2063,7 @@ array.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
array.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
array.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
array.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
+array.$(OBJEXT): {$(VPATH)}internal/attr/packed_struct.h
array.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
array.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
array.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
@@ -1988,7 +2132,6 @@ array.$(OBJEXT): {$(VPATH)}internal/intern/enumerator.h
array.$(OBJEXT): {$(VPATH)}internal/intern/error.h
array.$(OBJEXT): {$(VPATH)}internal/intern/eval.h
array.$(OBJEXT): {$(VPATH)}internal/intern/file.h
-array.$(OBJEXT): {$(VPATH)}internal/intern/gc.h
array.$(OBJEXT): {$(VPATH)}internal/intern/hash.h
array.$(OBJEXT): {$(VPATH)}internal/intern/io.h
array.$(OBJEXT): {$(VPATH)}internal/intern/load.h
@@ -2019,7 +2162,6 @@ array.$(OBJEXT): {$(VPATH)}internal/memory.h
array.$(OBJEXT): {$(VPATH)}internal/method.h
array.$(OBJEXT): {$(VPATH)}internal/module.h
array.$(OBJEXT): {$(VPATH)}internal/newobj.h
-array.$(OBJEXT): {$(VPATH)}internal/rgengc.h
array.$(OBJEXT): {$(VPATH)}internal/scan_args.h
array.$(OBJEXT): {$(VPATH)}internal/special_consts.h
array.$(OBJEXT): {$(VPATH)}internal/static_assert.h
@@ -2031,17 +2173,24 @@ array.$(OBJEXT): {$(VPATH)}internal/value_type.h
array.$(OBJEXT): {$(VPATH)}internal/variable.h
array.$(OBJEXT): {$(VPATH)}internal/warning_push.h
array.$(OBJEXT): {$(VPATH)}internal/xmalloc.h
+array.$(OBJEXT): {$(VPATH)}method.h
array.$(OBJEXT): {$(VPATH)}missing.h
+array.$(OBJEXT): {$(VPATH)}node.h
array.$(OBJEXT): {$(VPATH)}onigmo.h
array.$(OBJEXT): {$(VPATH)}oniguruma.h
array.$(OBJEXT): {$(VPATH)}probes.dmyh
array.$(OBJEXT): {$(VPATH)}probes.h
array.$(OBJEXT): {$(VPATH)}ruby_assert.h
+array.$(OBJEXT): {$(VPATH)}ruby_atomic.h
+array.$(OBJEXT): {$(VPATH)}rubyparser.h
array.$(OBJEXT): {$(VPATH)}shape.h
array.$(OBJEXT): {$(VPATH)}st.h
array.$(OBJEXT): {$(VPATH)}subst.h
-array.$(OBJEXT): {$(VPATH)}transient_heap.h
+array.$(OBJEXT): {$(VPATH)}thread_$(THREAD_MODEL).h
+array.$(OBJEXT): {$(VPATH)}thread_native.h
array.$(OBJEXT): {$(VPATH)}util.h
+array.$(OBJEXT): {$(VPATH)}vm_core.h
+array.$(OBJEXT): {$(VPATH)}vm_opts.h
ast.$(OBJEXT): $(CCAN_DIR)/check_type/check_type.h
ast.$(OBJEXT): $(CCAN_DIR)/container_of/container_of.h
ast.$(OBJEXT): $(CCAN_DIR)/list/list.h
@@ -2054,12 +2203,34 @@ ast.$(OBJEXT): $(top_srcdir)/internal/compilers.h
ast.$(OBJEXT): $(top_srcdir)/internal/gc.h
ast.$(OBJEXT): $(top_srcdir)/internal/imemo.h
ast.$(OBJEXT): $(top_srcdir)/internal/parse.h
+ast.$(OBJEXT): $(top_srcdir)/internal/ruby_parser.h
ast.$(OBJEXT): $(top_srcdir)/internal/serial.h
ast.$(OBJEXT): $(top_srcdir)/internal/static_assert.h
ast.$(OBJEXT): $(top_srcdir)/internal/symbol.h
ast.$(OBJEXT): $(top_srcdir)/internal/variable.h
ast.$(OBJEXT): $(top_srcdir)/internal/vm.h
ast.$(OBJEXT): $(top_srcdir)/internal/warnings.h
+ast.$(OBJEXT): $(top_srcdir)/prism/defines.h
+ast.$(OBJEXT): $(top_srcdir)/prism/diagnostic.h
+ast.$(OBJEXT): $(top_srcdir)/prism/encoding.h
+ast.$(OBJEXT): $(top_srcdir)/prism/node.h
+ast.$(OBJEXT): $(top_srcdir)/prism/options.h
+ast.$(OBJEXT): $(top_srcdir)/prism/pack.h
+ast.$(OBJEXT): $(top_srcdir)/prism/parser.h
+ast.$(OBJEXT): $(top_srcdir)/prism/prettyprint.h
+ast.$(OBJEXT): $(top_srcdir)/prism/prism.h
+ast.$(OBJEXT): $(top_srcdir)/prism/regexp.h
+ast.$(OBJEXT): $(top_srcdir)/prism/util/pm_buffer.h
+ast.$(OBJEXT): $(top_srcdir)/prism/util/pm_char.h
+ast.$(OBJEXT): $(top_srcdir)/prism/util/pm_constant_pool.h
+ast.$(OBJEXT): $(top_srcdir)/prism/util/pm_list.h
+ast.$(OBJEXT): $(top_srcdir)/prism/util/pm_memchr.h
+ast.$(OBJEXT): $(top_srcdir)/prism/util/pm_newline_list.h
+ast.$(OBJEXT): $(top_srcdir)/prism/util/pm_state_stack.h
+ast.$(OBJEXT): $(top_srcdir)/prism/util/pm_string.h
+ast.$(OBJEXT): $(top_srcdir)/prism/util/pm_string_list.h
+ast.$(OBJEXT): $(top_srcdir)/prism/util/pm_strncasecmp.h
+ast.$(OBJEXT): $(top_srcdir)/prism/util/pm_strpbrk.h
ast.$(OBJEXT): {$(VPATH)}assert.h
ast.$(OBJEXT): {$(VPATH)}ast.c
ast.$(OBJEXT): {$(VPATH)}ast.rbinc
@@ -2120,6 +2291,7 @@ ast.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
ast.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
ast.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
ast.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
+ast.$(OBJEXT): {$(VPATH)}internal/attr/packed_struct.h
ast.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
ast.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
ast.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
@@ -2188,7 +2360,6 @@ ast.$(OBJEXT): {$(VPATH)}internal/intern/enumerator.h
ast.$(OBJEXT): {$(VPATH)}internal/intern/error.h
ast.$(OBJEXT): {$(VPATH)}internal/intern/eval.h
ast.$(OBJEXT): {$(VPATH)}internal/intern/file.h
-ast.$(OBJEXT): {$(VPATH)}internal/intern/gc.h
ast.$(OBJEXT): {$(VPATH)}internal/intern/hash.h
ast.$(OBJEXT): {$(VPATH)}internal/intern/io.h
ast.$(OBJEXT): {$(VPATH)}internal/intern/load.h
@@ -2219,7 +2390,6 @@ ast.$(OBJEXT): {$(VPATH)}internal/memory.h
ast.$(OBJEXT): {$(VPATH)}internal/method.h
ast.$(OBJEXT): {$(VPATH)}internal/module.h
ast.$(OBJEXT): {$(VPATH)}internal/newobj.h
-ast.$(OBJEXT): {$(VPATH)}internal/rgengc.h
ast.$(OBJEXT): {$(VPATH)}internal/scan_args.h
ast.$(OBJEXT): {$(VPATH)}internal/special_consts.h
ast.$(OBJEXT): {$(VPATH)}internal/static_assert.h
@@ -2237,8 +2407,12 @@ ast.$(OBJEXT): {$(VPATH)}missing.h
ast.$(OBJEXT): {$(VPATH)}node.h
ast.$(OBJEXT): {$(VPATH)}onigmo.h
ast.$(OBJEXT): {$(VPATH)}oniguruma.h
+ast.$(OBJEXT): {$(VPATH)}prism/ast.h
+ast.$(OBJEXT): {$(VPATH)}prism/version.h
+ast.$(OBJEXT): {$(VPATH)}prism_compile.h
ast.$(OBJEXT): {$(VPATH)}ruby_assert.h
ast.$(OBJEXT): {$(VPATH)}ruby_atomic.h
+ast.$(OBJEXT): {$(VPATH)}rubyparser.h
ast.$(OBJEXT): {$(VPATH)}shape.h
ast.$(OBJEXT): {$(VPATH)}st.h
ast.$(OBJEXT): {$(VPATH)}subst.h
@@ -2247,7 +2421,13 @@ ast.$(OBJEXT): {$(VPATH)}thread_native.h
ast.$(OBJEXT): {$(VPATH)}util.h
ast.$(OBJEXT): {$(VPATH)}vm_core.h
ast.$(OBJEXT): {$(VPATH)}vm_opts.h
+bignum.$(OBJEXT): $(CCAN_DIR)/check_type/check_type.h
+bignum.$(OBJEXT): $(CCAN_DIR)/container_of/container_of.h
+bignum.$(OBJEXT): $(CCAN_DIR)/list/list.h
+bignum.$(OBJEXT): $(CCAN_DIR)/str/str.h
bignum.$(OBJEXT): $(hdrdir)/ruby/ruby.h
+bignum.$(OBJEXT): $(top_srcdir)/internal/array.h
+bignum.$(OBJEXT): $(top_srcdir)/internal/basic_operators.h
bignum.$(OBJEXT): $(top_srcdir)/internal/bignum.h
bignum.$(OBJEXT): $(top_srcdir)/internal/bits.h
bignum.$(OBJEXT): $(top_srcdir)/internal/class.h
@@ -2255,6 +2435,7 @@ bignum.$(OBJEXT): $(top_srcdir)/internal/compilers.h
bignum.$(OBJEXT): $(top_srcdir)/internal/complex.h
bignum.$(OBJEXT): $(top_srcdir)/internal/fixnum.h
bignum.$(OBJEXT): $(top_srcdir)/internal/gc.h
+bignum.$(OBJEXT): $(top_srcdir)/internal/imemo.h
bignum.$(OBJEXT): $(top_srcdir)/internal/numeric.h
bignum.$(OBJEXT): $(top_srcdir)/internal/object.h
bignum.$(OBJEXT): $(top_srcdir)/internal/sanitizers.h
@@ -2264,6 +2445,7 @@ bignum.$(OBJEXT): $(top_srcdir)/internal/variable.h
bignum.$(OBJEXT): $(top_srcdir)/internal/vm.h
bignum.$(OBJEXT): $(top_srcdir)/internal/warnings.h
bignum.$(OBJEXT): {$(VPATH)}assert.h
+bignum.$(OBJEXT): {$(VPATH)}atomic.h
bignum.$(OBJEXT): {$(VPATH)}backward/2/assume.h
bignum.$(OBJEXT): {$(VPATH)}backward/2/attributes.h
bignum.$(OBJEXT): {$(VPATH)}backward/2/bool.h
@@ -2277,6 +2459,7 @@ bignum.$(OBJEXT): {$(VPATH)}bignum.c
bignum.$(OBJEXT): {$(VPATH)}config.h
bignum.$(OBJEXT): {$(VPATH)}constant.h
bignum.$(OBJEXT): {$(VPATH)}defines.h
+bignum.$(OBJEXT): {$(VPATH)}encoding.h
bignum.$(OBJEXT): {$(VPATH)}id.h
bignum.$(OBJEXT): {$(VPATH)}id_table.h
bignum.$(OBJEXT): {$(VPATH)}intern.h
@@ -2319,6 +2502,7 @@ bignum.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
bignum.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
bignum.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
bignum.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
+bignum.$(OBJEXT): {$(VPATH)}internal/attr/packed_struct.h
bignum.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
bignum.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
bignum.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
@@ -2351,6 +2535,15 @@ bignum.$(OBJEXT): {$(VPATH)}internal/core/rtypeddata.h
bignum.$(OBJEXT): {$(VPATH)}internal/ctype.h
bignum.$(OBJEXT): {$(VPATH)}internal/dllexport.h
bignum.$(OBJEXT): {$(VPATH)}internal/dosish.h
+bignum.$(OBJEXT): {$(VPATH)}internal/encoding/coderange.h
+bignum.$(OBJEXT): {$(VPATH)}internal/encoding/ctype.h
+bignum.$(OBJEXT): {$(VPATH)}internal/encoding/encoding.h
+bignum.$(OBJEXT): {$(VPATH)}internal/encoding/pathname.h
+bignum.$(OBJEXT): {$(VPATH)}internal/encoding/re.h
+bignum.$(OBJEXT): {$(VPATH)}internal/encoding/sprintf.h
+bignum.$(OBJEXT): {$(VPATH)}internal/encoding/string.h
+bignum.$(OBJEXT): {$(VPATH)}internal/encoding/symbol.h
+bignum.$(OBJEXT): {$(VPATH)}internal/encoding/transcode.h
bignum.$(OBJEXT): {$(VPATH)}internal/error.h
bignum.$(OBJEXT): {$(VPATH)}internal/eval.h
bignum.$(OBJEXT): {$(VPATH)}internal/event.h
@@ -2378,7 +2571,6 @@ bignum.$(OBJEXT): {$(VPATH)}internal/intern/enumerator.h
bignum.$(OBJEXT): {$(VPATH)}internal/intern/error.h
bignum.$(OBJEXT): {$(VPATH)}internal/intern/eval.h
bignum.$(OBJEXT): {$(VPATH)}internal/intern/file.h
-bignum.$(OBJEXT): {$(VPATH)}internal/intern/gc.h
bignum.$(OBJEXT): {$(VPATH)}internal/intern/hash.h
bignum.$(OBJEXT): {$(VPATH)}internal/intern/io.h
bignum.$(OBJEXT): {$(VPATH)}internal/intern/load.h
@@ -2409,7 +2601,6 @@ bignum.$(OBJEXT): {$(VPATH)}internal/memory.h
bignum.$(OBJEXT): {$(VPATH)}internal/method.h
bignum.$(OBJEXT): {$(VPATH)}internal/module.h
bignum.$(OBJEXT): {$(VPATH)}internal/newobj.h
-bignum.$(OBJEXT): {$(VPATH)}internal/rgengc.h
bignum.$(OBJEXT): {$(VPATH)}internal/scan_args.h
bignum.$(OBJEXT): {$(VPATH)}internal/special_consts.h
bignum.$(OBJEXT): {$(VPATH)}internal/static_assert.h
@@ -2421,13 +2612,23 @@ bignum.$(OBJEXT): {$(VPATH)}internal/value_type.h
bignum.$(OBJEXT): {$(VPATH)}internal/variable.h
bignum.$(OBJEXT): {$(VPATH)}internal/warning_push.h
bignum.$(OBJEXT): {$(VPATH)}internal/xmalloc.h
+bignum.$(OBJEXT): {$(VPATH)}method.h
bignum.$(OBJEXT): {$(VPATH)}missing.h
+bignum.$(OBJEXT): {$(VPATH)}node.h
+bignum.$(OBJEXT): {$(VPATH)}onigmo.h
+bignum.$(OBJEXT): {$(VPATH)}oniguruma.h
bignum.$(OBJEXT): {$(VPATH)}ruby_assert.h
+bignum.$(OBJEXT): {$(VPATH)}ruby_atomic.h
+bignum.$(OBJEXT): {$(VPATH)}rubyparser.h
bignum.$(OBJEXT): {$(VPATH)}shape.h
bignum.$(OBJEXT): {$(VPATH)}st.h
bignum.$(OBJEXT): {$(VPATH)}subst.h
bignum.$(OBJEXT): {$(VPATH)}thread.h
+bignum.$(OBJEXT): {$(VPATH)}thread_$(THREAD_MODEL).h
+bignum.$(OBJEXT): {$(VPATH)}thread_native.h
bignum.$(OBJEXT): {$(VPATH)}util.h
+bignum.$(OBJEXT): {$(VPATH)}vm_core.h
+bignum.$(OBJEXT): {$(VPATH)}vm_opts.h
builtin.$(OBJEXT): $(CCAN_DIR)/check_type/check_type.h
builtin.$(OBJEXT): $(CCAN_DIR)/container_of/container_of.h
builtin.$(OBJEXT): $(CCAN_DIR)/list/list.h
@@ -2443,6 +2644,27 @@ builtin.$(OBJEXT): $(top_srcdir)/internal/static_assert.h
builtin.$(OBJEXT): $(top_srcdir)/internal/variable.h
builtin.$(OBJEXT): $(top_srcdir)/internal/vm.h
builtin.$(OBJEXT): $(top_srcdir)/internal/warnings.h
+builtin.$(OBJEXT): $(top_srcdir)/prism/defines.h
+builtin.$(OBJEXT): $(top_srcdir)/prism/diagnostic.h
+builtin.$(OBJEXT): $(top_srcdir)/prism/encoding.h
+builtin.$(OBJEXT): $(top_srcdir)/prism/node.h
+builtin.$(OBJEXT): $(top_srcdir)/prism/options.h
+builtin.$(OBJEXT): $(top_srcdir)/prism/pack.h
+builtin.$(OBJEXT): $(top_srcdir)/prism/parser.h
+builtin.$(OBJEXT): $(top_srcdir)/prism/prettyprint.h
+builtin.$(OBJEXT): $(top_srcdir)/prism/prism.h
+builtin.$(OBJEXT): $(top_srcdir)/prism/regexp.h
+builtin.$(OBJEXT): $(top_srcdir)/prism/util/pm_buffer.h
+builtin.$(OBJEXT): $(top_srcdir)/prism/util/pm_char.h
+builtin.$(OBJEXT): $(top_srcdir)/prism/util/pm_constant_pool.h
+builtin.$(OBJEXT): $(top_srcdir)/prism/util/pm_list.h
+builtin.$(OBJEXT): $(top_srcdir)/prism/util/pm_memchr.h
+builtin.$(OBJEXT): $(top_srcdir)/prism/util/pm_newline_list.h
+builtin.$(OBJEXT): $(top_srcdir)/prism/util/pm_state_stack.h
+builtin.$(OBJEXT): $(top_srcdir)/prism/util/pm_string.h
+builtin.$(OBJEXT): $(top_srcdir)/prism/util/pm_string_list.h
+builtin.$(OBJEXT): $(top_srcdir)/prism/util/pm_strncasecmp.h
+builtin.$(OBJEXT): $(top_srcdir)/prism/util/pm_strpbrk.h
builtin.$(OBJEXT): {$(VPATH)}assert.h
builtin.$(OBJEXT): {$(VPATH)}atomic.h
builtin.$(OBJEXT): {$(VPATH)}backward/2/assume.h
@@ -2460,6 +2682,7 @@ builtin.$(OBJEXT): {$(VPATH)}builtin_binary.inc
builtin.$(OBJEXT): {$(VPATH)}config.h
builtin.$(OBJEXT): {$(VPATH)}constant.h
builtin.$(OBJEXT): {$(VPATH)}defines.h
+builtin.$(OBJEXT): {$(VPATH)}encoding.h
builtin.$(OBJEXT): {$(VPATH)}id.h
builtin.$(OBJEXT): {$(VPATH)}id_table.h
builtin.$(OBJEXT): {$(VPATH)}intern.h
@@ -2502,6 +2725,7 @@ builtin.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
builtin.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
builtin.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
builtin.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
+builtin.$(OBJEXT): {$(VPATH)}internal/attr/packed_struct.h
builtin.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
builtin.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
builtin.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
@@ -2534,6 +2758,15 @@ builtin.$(OBJEXT): {$(VPATH)}internal/core/rtypeddata.h
builtin.$(OBJEXT): {$(VPATH)}internal/ctype.h
builtin.$(OBJEXT): {$(VPATH)}internal/dllexport.h
builtin.$(OBJEXT): {$(VPATH)}internal/dosish.h
+builtin.$(OBJEXT): {$(VPATH)}internal/encoding/coderange.h
+builtin.$(OBJEXT): {$(VPATH)}internal/encoding/ctype.h
+builtin.$(OBJEXT): {$(VPATH)}internal/encoding/encoding.h
+builtin.$(OBJEXT): {$(VPATH)}internal/encoding/pathname.h
+builtin.$(OBJEXT): {$(VPATH)}internal/encoding/re.h
+builtin.$(OBJEXT): {$(VPATH)}internal/encoding/sprintf.h
+builtin.$(OBJEXT): {$(VPATH)}internal/encoding/string.h
+builtin.$(OBJEXT): {$(VPATH)}internal/encoding/symbol.h
+builtin.$(OBJEXT): {$(VPATH)}internal/encoding/transcode.h
builtin.$(OBJEXT): {$(VPATH)}internal/error.h
builtin.$(OBJEXT): {$(VPATH)}internal/eval.h
builtin.$(OBJEXT): {$(VPATH)}internal/event.h
@@ -2561,7 +2794,6 @@ builtin.$(OBJEXT): {$(VPATH)}internal/intern/enumerator.h
builtin.$(OBJEXT): {$(VPATH)}internal/intern/error.h
builtin.$(OBJEXT): {$(VPATH)}internal/intern/eval.h
builtin.$(OBJEXT): {$(VPATH)}internal/intern/file.h
-builtin.$(OBJEXT): {$(VPATH)}internal/intern/gc.h
builtin.$(OBJEXT): {$(VPATH)}internal/intern/hash.h
builtin.$(OBJEXT): {$(VPATH)}internal/intern/io.h
builtin.$(OBJEXT): {$(VPATH)}internal/intern/load.h
@@ -2592,7 +2824,6 @@ builtin.$(OBJEXT): {$(VPATH)}internal/memory.h
builtin.$(OBJEXT): {$(VPATH)}internal/method.h
builtin.$(OBJEXT): {$(VPATH)}internal/module.h
builtin.$(OBJEXT): {$(VPATH)}internal/newobj.h
-builtin.$(OBJEXT): {$(VPATH)}internal/rgengc.h
builtin.$(OBJEXT): {$(VPATH)}internal/scan_args.h
builtin.$(OBJEXT): {$(VPATH)}internal/special_consts.h
builtin.$(OBJEXT): {$(VPATH)}internal/static_assert.h
@@ -2608,8 +2839,14 @@ builtin.$(OBJEXT): {$(VPATH)}iseq.h
builtin.$(OBJEXT): {$(VPATH)}method.h
builtin.$(OBJEXT): {$(VPATH)}missing.h
builtin.$(OBJEXT): {$(VPATH)}node.h
+builtin.$(OBJEXT): {$(VPATH)}onigmo.h
+builtin.$(OBJEXT): {$(VPATH)}oniguruma.h
+builtin.$(OBJEXT): {$(VPATH)}prism/ast.h
+builtin.$(OBJEXT): {$(VPATH)}prism/version.h
+builtin.$(OBJEXT): {$(VPATH)}prism_compile.h
builtin.$(OBJEXT): {$(VPATH)}ruby_assert.h
builtin.$(OBJEXT): {$(VPATH)}ruby_atomic.h
+builtin.$(OBJEXT): {$(VPATH)}rubyparser.h
builtin.$(OBJEXT): {$(VPATH)}shape.h
builtin.$(OBJEXT): {$(VPATH)}st.h
builtin.$(OBJEXT): {$(VPATH)}subst.h
@@ -2696,6 +2933,7 @@ class.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
class.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
class.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
class.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
+class.$(OBJEXT): {$(VPATH)}internal/attr/packed_struct.h
class.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
class.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
class.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
@@ -2764,7 +3002,6 @@ class.$(OBJEXT): {$(VPATH)}internal/intern/enumerator.h
class.$(OBJEXT): {$(VPATH)}internal/intern/error.h
class.$(OBJEXT): {$(VPATH)}internal/intern/eval.h
class.$(OBJEXT): {$(VPATH)}internal/intern/file.h
-class.$(OBJEXT): {$(VPATH)}internal/intern/gc.h
class.$(OBJEXT): {$(VPATH)}internal/intern/hash.h
class.$(OBJEXT): {$(VPATH)}internal/intern/io.h
class.$(OBJEXT): {$(VPATH)}internal/intern/load.h
@@ -2795,7 +3032,6 @@ class.$(OBJEXT): {$(VPATH)}internal/memory.h
class.$(OBJEXT): {$(VPATH)}internal/method.h
class.$(OBJEXT): {$(VPATH)}internal/module.h
class.$(OBJEXT): {$(VPATH)}internal/newobj.h
-class.$(OBJEXT): {$(VPATH)}internal/rgengc.h
class.$(OBJEXT): {$(VPATH)}internal/scan_args.h
class.$(OBJEXT): {$(VPATH)}internal/special_consts.h
class.$(OBJEXT): {$(VPATH)}internal/static_assert.h
@@ -2814,14 +3050,18 @@ class.$(OBJEXT): {$(VPATH)}onigmo.h
class.$(OBJEXT): {$(VPATH)}oniguruma.h
class.$(OBJEXT): {$(VPATH)}ruby_assert.h
class.$(OBJEXT): {$(VPATH)}ruby_atomic.h
+class.$(OBJEXT): {$(VPATH)}rubyparser.h
class.$(OBJEXT): {$(VPATH)}shape.h
class.$(OBJEXT): {$(VPATH)}st.h
class.$(OBJEXT): {$(VPATH)}subst.h
class.$(OBJEXT): {$(VPATH)}thread_$(THREAD_MODEL).h
class.$(OBJEXT): {$(VPATH)}thread_native.h
class.$(OBJEXT): {$(VPATH)}vm_core.h
+class.$(OBJEXT): {$(VPATH)}vm_debug.h
class.$(OBJEXT): {$(VPATH)}vm_opts.h
+class.$(OBJEXT): {$(VPATH)}vm_sync.h
compar.$(OBJEXT): $(hdrdir)/ruby/ruby.h
+compar.$(OBJEXT): $(hdrdir)/ruby/version.h
compar.$(OBJEXT): $(top_srcdir)/internal/basic_operators.h
compar.$(OBJEXT): $(top_srcdir)/internal/compar.h
compar.$(OBJEXT): $(top_srcdir)/internal/compilers.h
@@ -2885,6 +3125,7 @@ compar.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
compar.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
compar.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
compar.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
+compar.$(OBJEXT): {$(VPATH)}internal/attr/packed_struct.h
compar.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
compar.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
compar.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
@@ -2953,7 +3194,6 @@ compar.$(OBJEXT): {$(VPATH)}internal/intern/enumerator.h
compar.$(OBJEXT): {$(VPATH)}internal/intern/error.h
compar.$(OBJEXT): {$(VPATH)}internal/intern/eval.h
compar.$(OBJEXT): {$(VPATH)}internal/intern/file.h
-compar.$(OBJEXT): {$(VPATH)}internal/intern/gc.h
compar.$(OBJEXT): {$(VPATH)}internal/intern/hash.h
compar.$(OBJEXT): {$(VPATH)}internal/intern/io.h
compar.$(OBJEXT): {$(VPATH)}internal/intern/load.h
@@ -2984,7 +3224,6 @@ compar.$(OBJEXT): {$(VPATH)}internal/memory.h
compar.$(OBJEXT): {$(VPATH)}internal/method.h
compar.$(OBJEXT): {$(VPATH)}internal/module.h
compar.$(OBJEXT): {$(VPATH)}internal/newobj.h
-compar.$(OBJEXT): {$(VPATH)}internal/rgengc.h
compar.$(OBJEXT): {$(VPATH)}internal/scan_args.h
compar.$(OBJEXT): {$(VPATH)}internal/special_consts.h
compar.$(OBJEXT): {$(VPATH)}internal/static_assert.h
@@ -3006,6 +3245,7 @@ compile.$(OBJEXT): $(CCAN_DIR)/container_of/container_of.h
compile.$(OBJEXT): $(CCAN_DIR)/list/list.h
compile.$(OBJEXT): $(CCAN_DIR)/str/str.h
compile.$(OBJEXT): $(hdrdir)/ruby/ruby.h
+compile.$(OBJEXT): $(hdrdir)/ruby/version.h
compile.$(OBJEXT): $(top_srcdir)/internal/array.h
compile.$(OBJEXT): $(top_srcdir)/internal/basic_operators.h
compile.$(OBJEXT): $(top_srcdir)/internal/bignum.h
@@ -3032,6 +3272,28 @@ compile.$(OBJEXT): $(top_srcdir)/internal/thread.h
compile.$(OBJEXT): $(top_srcdir)/internal/variable.h
compile.$(OBJEXT): $(top_srcdir)/internal/vm.h
compile.$(OBJEXT): $(top_srcdir)/internal/warnings.h
+compile.$(OBJEXT): $(top_srcdir)/prism/defines.h
+compile.$(OBJEXT): $(top_srcdir)/prism/diagnostic.h
+compile.$(OBJEXT): $(top_srcdir)/prism/encoding.h
+compile.$(OBJEXT): $(top_srcdir)/prism/node.h
+compile.$(OBJEXT): $(top_srcdir)/prism/options.h
+compile.$(OBJEXT): $(top_srcdir)/prism/pack.h
+compile.$(OBJEXT): $(top_srcdir)/prism/parser.h
+compile.$(OBJEXT): $(top_srcdir)/prism/prettyprint.h
+compile.$(OBJEXT): $(top_srcdir)/prism/prism.h
+compile.$(OBJEXT): $(top_srcdir)/prism/regexp.h
+compile.$(OBJEXT): $(top_srcdir)/prism/util/pm_buffer.h
+compile.$(OBJEXT): $(top_srcdir)/prism/util/pm_char.h
+compile.$(OBJEXT): $(top_srcdir)/prism/util/pm_constant_pool.h
+compile.$(OBJEXT): $(top_srcdir)/prism/util/pm_list.h
+compile.$(OBJEXT): $(top_srcdir)/prism/util/pm_memchr.h
+compile.$(OBJEXT): $(top_srcdir)/prism/util/pm_newline_list.h
+compile.$(OBJEXT): $(top_srcdir)/prism/util/pm_state_stack.h
+compile.$(OBJEXT): $(top_srcdir)/prism/util/pm_string.h
+compile.$(OBJEXT): $(top_srcdir)/prism/util/pm_string_list.h
+compile.$(OBJEXT): $(top_srcdir)/prism/util/pm_strncasecmp.h
+compile.$(OBJEXT): $(top_srcdir)/prism/util/pm_strpbrk.h
+compile.$(OBJEXT): $(top_srcdir)/prism_compile.c
compile.$(OBJEXT): {$(VPATH)}assert.h
compile.$(OBJEXT): {$(VPATH)}atomic.h
compile.$(OBJEXT): {$(VPATH)}backward/2/assume.h
@@ -3051,7 +3313,6 @@ compile.$(OBJEXT): {$(VPATH)}debug_counter.h
compile.$(OBJEXT): {$(VPATH)}defines.h
compile.$(OBJEXT): {$(VPATH)}encindex.h
compile.$(OBJEXT): {$(VPATH)}encoding.h
-compile.$(OBJEXT): {$(VPATH)}gc.h
compile.$(OBJEXT): {$(VPATH)}id.h
compile.$(OBJEXT): {$(VPATH)}id_table.h
compile.$(OBJEXT): {$(VPATH)}insns.def
@@ -3097,6 +3358,7 @@ compile.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
compile.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
compile.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
compile.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
+compile.$(OBJEXT): {$(VPATH)}internal/attr/packed_struct.h
compile.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
compile.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
compile.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
@@ -3166,7 +3428,6 @@ compile.$(OBJEXT): {$(VPATH)}internal/intern/enumerator.h
compile.$(OBJEXT): {$(VPATH)}internal/intern/error.h
compile.$(OBJEXT): {$(VPATH)}internal/intern/eval.h
compile.$(OBJEXT): {$(VPATH)}internal/intern/file.h
-compile.$(OBJEXT): {$(VPATH)}internal/intern/gc.h
compile.$(OBJEXT): {$(VPATH)}internal/intern/hash.h
compile.$(OBJEXT): {$(VPATH)}internal/intern/io.h
compile.$(OBJEXT): {$(VPATH)}internal/intern/load.h
@@ -3197,7 +3458,6 @@ compile.$(OBJEXT): {$(VPATH)}internal/memory.h
compile.$(OBJEXT): {$(VPATH)}internal/method.h
compile.$(OBJEXT): {$(VPATH)}internal/module.h
compile.$(OBJEXT): {$(VPATH)}internal/newobj.h
-compile.$(OBJEXT): {$(VPATH)}internal/rgengc.h
compile.$(OBJEXT): {$(VPATH)}internal/scan_args.h
compile.$(OBJEXT): {$(VPATH)}internal/special_consts.h
compile.$(OBJEXT): {$(VPATH)}internal/static_assert.h
@@ -3216,10 +3476,16 @@ compile.$(OBJEXT): {$(VPATH)}node.h
compile.$(OBJEXT): {$(VPATH)}onigmo.h
compile.$(OBJEXT): {$(VPATH)}oniguruma.h
compile.$(OBJEXT): {$(VPATH)}optinsn.inc
+compile.$(OBJEXT): {$(VPATH)}prism/ast.h
+compile.$(OBJEXT): {$(VPATH)}prism/prism.h
+compile.$(OBJEXT): {$(VPATH)}prism/version.h
+compile.$(OBJEXT): {$(VPATH)}prism_compile.c
+compile.$(OBJEXT): {$(VPATH)}prism_compile.h
compile.$(OBJEXT): {$(VPATH)}re.h
compile.$(OBJEXT): {$(VPATH)}regex.h
compile.$(OBJEXT): {$(VPATH)}ruby_assert.h
compile.$(OBJEXT): {$(VPATH)}ruby_atomic.h
+compile.$(OBJEXT): {$(VPATH)}rubyparser.h
compile.$(OBJEXT): {$(VPATH)}shape.h
compile.$(OBJEXT): {$(VPATH)}st.h
compile.$(OBJEXT): {$(VPATH)}subst.h
@@ -3230,8 +3496,15 @@ compile.$(OBJEXT): {$(VPATH)}vm_callinfo.h
compile.$(OBJEXT): {$(VPATH)}vm_core.h
compile.$(OBJEXT): {$(VPATH)}vm_debug.h
compile.$(OBJEXT): {$(VPATH)}vm_opts.h
+compile.$(OBJEXT): {$(VPATH)}vm_sync.h
+compile.$(OBJEXT): {$(VPATH)}yjit.h
+complex.$(OBJEXT): $(CCAN_DIR)/check_type/check_type.h
+complex.$(OBJEXT): $(CCAN_DIR)/container_of/container_of.h
+complex.$(OBJEXT): $(CCAN_DIR)/list/list.h
+complex.$(OBJEXT): $(CCAN_DIR)/str/str.h
complex.$(OBJEXT): $(hdrdir)/ruby/ruby.h
complex.$(OBJEXT): $(top_srcdir)/internal/array.h
+complex.$(OBJEXT): $(top_srcdir)/internal/basic_operators.h
complex.$(OBJEXT): $(top_srcdir)/internal/bignum.h
complex.$(OBJEXT): $(top_srcdir)/internal/bits.h
complex.$(OBJEXT): $(top_srcdir)/internal/class.h
@@ -3239,16 +3512,19 @@ complex.$(OBJEXT): $(top_srcdir)/internal/compilers.h
complex.$(OBJEXT): $(top_srcdir)/internal/complex.h
complex.$(OBJEXT): $(top_srcdir)/internal/fixnum.h
complex.$(OBJEXT): $(top_srcdir)/internal/gc.h
+complex.$(OBJEXT): $(top_srcdir)/internal/imemo.h
complex.$(OBJEXT): $(top_srcdir)/internal/math.h
complex.$(OBJEXT): $(top_srcdir)/internal/numeric.h
complex.$(OBJEXT): $(top_srcdir)/internal/object.h
complex.$(OBJEXT): $(top_srcdir)/internal/rational.h
complex.$(OBJEXT): $(top_srcdir)/internal/serial.h
complex.$(OBJEXT): $(top_srcdir)/internal/static_assert.h
+complex.$(OBJEXT): $(top_srcdir)/internal/string.h
complex.$(OBJEXT): $(top_srcdir)/internal/variable.h
complex.$(OBJEXT): $(top_srcdir)/internal/vm.h
complex.$(OBJEXT): $(top_srcdir)/internal/warnings.h
complex.$(OBJEXT): {$(VPATH)}assert.h
+complex.$(OBJEXT): {$(VPATH)}atomic.h
complex.$(OBJEXT): {$(VPATH)}backward/2/assume.h
complex.$(OBJEXT): {$(VPATH)}backward/2/attributes.h
complex.$(OBJEXT): {$(VPATH)}backward/2/bool.h
@@ -3261,7 +3537,9 @@ complex.$(OBJEXT): {$(VPATH)}backward/2/stdarg.h
complex.$(OBJEXT): {$(VPATH)}complex.c
complex.$(OBJEXT): {$(VPATH)}config.h
complex.$(OBJEXT): {$(VPATH)}constant.h
+complex.$(OBJEXT): {$(VPATH)}debug_counter.h
complex.$(OBJEXT): {$(VPATH)}defines.h
+complex.$(OBJEXT): {$(VPATH)}encoding.h
complex.$(OBJEXT): {$(VPATH)}id.h
complex.$(OBJEXT): {$(VPATH)}id_table.h
complex.$(OBJEXT): {$(VPATH)}intern.h
@@ -3304,6 +3582,7 @@ complex.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
complex.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
complex.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
complex.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
+complex.$(OBJEXT): {$(VPATH)}internal/attr/packed_struct.h
complex.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
complex.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
complex.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
@@ -3336,6 +3615,15 @@ complex.$(OBJEXT): {$(VPATH)}internal/core/rtypeddata.h
complex.$(OBJEXT): {$(VPATH)}internal/ctype.h
complex.$(OBJEXT): {$(VPATH)}internal/dllexport.h
complex.$(OBJEXT): {$(VPATH)}internal/dosish.h
+complex.$(OBJEXT): {$(VPATH)}internal/encoding/coderange.h
+complex.$(OBJEXT): {$(VPATH)}internal/encoding/ctype.h
+complex.$(OBJEXT): {$(VPATH)}internal/encoding/encoding.h
+complex.$(OBJEXT): {$(VPATH)}internal/encoding/pathname.h
+complex.$(OBJEXT): {$(VPATH)}internal/encoding/re.h
+complex.$(OBJEXT): {$(VPATH)}internal/encoding/sprintf.h
+complex.$(OBJEXT): {$(VPATH)}internal/encoding/string.h
+complex.$(OBJEXT): {$(VPATH)}internal/encoding/symbol.h
+complex.$(OBJEXT): {$(VPATH)}internal/encoding/transcode.h
complex.$(OBJEXT): {$(VPATH)}internal/error.h
complex.$(OBJEXT): {$(VPATH)}internal/eval.h
complex.$(OBJEXT): {$(VPATH)}internal/event.h
@@ -3363,7 +3651,6 @@ complex.$(OBJEXT): {$(VPATH)}internal/intern/enumerator.h
complex.$(OBJEXT): {$(VPATH)}internal/intern/error.h
complex.$(OBJEXT): {$(VPATH)}internal/intern/eval.h
complex.$(OBJEXT): {$(VPATH)}internal/intern/file.h
-complex.$(OBJEXT): {$(VPATH)}internal/intern/gc.h
complex.$(OBJEXT): {$(VPATH)}internal/intern/hash.h
complex.$(OBJEXT): {$(VPATH)}internal/intern/io.h
complex.$(OBJEXT): {$(VPATH)}internal/intern/load.h
@@ -3394,7 +3681,6 @@ complex.$(OBJEXT): {$(VPATH)}internal/memory.h
complex.$(OBJEXT): {$(VPATH)}internal/method.h
complex.$(OBJEXT): {$(VPATH)}internal/module.h
complex.$(OBJEXT): {$(VPATH)}internal/newobj.h
-complex.$(OBJEXT): {$(VPATH)}internal/rgengc.h
complex.$(OBJEXT): {$(VPATH)}internal/scan_args.h
complex.$(OBJEXT): {$(VPATH)}internal/special_consts.h
complex.$(OBJEXT): {$(VPATH)}internal/static_assert.h
@@ -3406,17 +3692,30 @@ complex.$(OBJEXT): {$(VPATH)}internal/value_type.h
complex.$(OBJEXT): {$(VPATH)}internal/variable.h
complex.$(OBJEXT): {$(VPATH)}internal/warning_push.h
complex.$(OBJEXT): {$(VPATH)}internal/xmalloc.h
+complex.$(OBJEXT): {$(VPATH)}method.h
complex.$(OBJEXT): {$(VPATH)}missing.h
+complex.$(OBJEXT): {$(VPATH)}node.h
+complex.$(OBJEXT): {$(VPATH)}onigmo.h
+complex.$(OBJEXT): {$(VPATH)}oniguruma.h
complex.$(OBJEXT): {$(VPATH)}ruby_assert.h
+complex.$(OBJEXT): {$(VPATH)}ruby_atomic.h
+complex.$(OBJEXT): {$(VPATH)}rubyparser.h
complex.$(OBJEXT): {$(VPATH)}shape.h
complex.$(OBJEXT): {$(VPATH)}st.h
complex.$(OBJEXT): {$(VPATH)}subst.h
+complex.$(OBJEXT): {$(VPATH)}thread_$(THREAD_MODEL).h
+complex.$(OBJEXT): {$(VPATH)}thread_native.h
+complex.$(OBJEXT): {$(VPATH)}vm_core.h
+complex.$(OBJEXT): {$(VPATH)}vm_debug.h
+complex.$(OBJEXT): {$(VPATH)}vm_opts.h
+complex.$(OBJEXT): {$(VPATH)}vm_sync.h
cont.$(OBJEXT): $(CCAN_DIR)/check_type/check_type.h
cont.$(OBJEXT): $(CCAN_DIR)/container_of/container_of.h
cont.$(OBJEXT): $(CCAN_DIR)/list/list.h
cont.$(OBJEXT): $(CCAN_DIR)/str/str.h
cont.$(OBJEXT): $(hdrdir)/ruby.h
cont.$(OBJEXT): $(hdrdir)/ruby/ruby.h
+cont.$(OBJEXT): $(hdrdir)/ruby/version.h
cont.$(OBJEXT): $(top_srcdir)/internal/array.h
cont.$(OBJEXT): $(top_srcdir)/internal/basic_operators.h
cont.$(OBJEXT): $(top_srcdir)/internal/compilers.h
@@ -3429,9 +3728,31 @@ cont.$(OBJEXT): $(top_srcdir)/internal/sanitizers.h
cont.$(OBJEXT): $(top_srcdir)/internal/serial.h
cont.$(OBJEXT): $(top_srcdir)/internal/static_assert.h
cont.$(OBJEXT): $(top_srcdir)/internal/string.h
+cont.$(OBJEXT): $(top_srcdir)/internal/thread.h
cont.$(OBJEXT): $(top_srcdir)/internal/variable.h
cont.$(OBJEXT): $(top_srcdir)/internal/vm.h
cont.$(OBJEXT): $(top_srcdir)/internal/warnings.h
+cont.$(OBJEXT): $(top_srcdir)/prism/defines.h
+cont.$(OBJEXT): $(top_srcdir)/prism/diagnostic.h
+cont.$(OBJEXT): $(top_srcdir)/prism/encoding.h
+cont.$(OBJEXT): $(top_srcdir)/prism/node.h
+cont.$(OBJEXT): $(top_srcdir)/prism/options.h
+cont.$(OBJEXT): $(top_srcdir)/prism/pack.h
+cont.$(OBJEXT): $(top_srcdir)/prism/parser.h
+cont.$(OBJEXT): $(top_srcdir)/prism/prettyprint.h
+cont.$(OBJEXT): $(top_srcdir)/prism/prism.h
+cont.$(OBJEXT): $(top_srcdir)/prism/regexp.h
+cont.$(OBJEXT): $(top_srcdir)/prism/util/pm_buffer.h
+cont.$(OBJEXT): $(top_srcdir)/prism/util/pm_char.h
+cont.$(OBJEXT): $(top_srcdir)/prism/util/pm_constant_pool.h
+cont.$(OBJEXT): $(top_srcdir)/prism/util/pm_list.h
+cont.$(OBJEXT): $(top_srcdir)/prism/util/pm_memchr.h
+cont.$(OBJEXT): $(top_srcdir)/prism/util/pm_newline_list.h
+cont.$(OBJEXT): $(top_srcdir)/prism/util/pm_state_stack.h
+cont.$(OBJEXT): $(top_srcdir)/prism/util/pm_string.h
+cont.$(OBJEXT): $(top_srcdir)/prism/util/pm_string_list.h
+cont.$(OBJEXT): $(top_srcdir)/prism/util/pm_strncasecmp.h
+cont.$(OBJEXT): $(top_srcdir)/prism/util/pm_strpbrk.h
cont.$(OBJEXT): {$(VPATH)}$(COROUTINE_H)
cont.$(OBJEXT): {$(VPATH)}assert.h
cont.$(OBJEXT): {$(VPATH)}atomic.h
@@ -3452,7 +3773,6 @@ cont.$(OBJEXT): {$(VPATH)}defines.h
cont.$(OBJEXT): {$(VPATH)}encoding.h
cont.$(OBJEXT): {$(VPATH)}eval_intern.h
cont.$(OBJEXT): {$(VPATH)}fiber/scheduler.h
-cont.$(OBJEXT): {$(VPATH)}gc.h
cont.$(OBJEXT): {$(VPATH)}id.h
cont.$(OBJEXT): {$(VPATH)}id_table.h
cont.$(OBJEXT): {$(VPATH)}intern.h
@@ -3495,6 +3815,7 @@ cont.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
cont.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
cont.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
cont.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
+cont.$(OBJEXT): {$(VPATH)}internal/attr/packed_struct.h
cont.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
cont.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
cont.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
@@ -3563,7 +3884,6 @@ cont.$(OBJEXT): {$(VPATH)}internal/intern/enumerator.h
cont.$(OBJEXT): {$(VPATH)}internal/intern/error.h
cont.$(OBJEXT): {$(VPATH)}internal/intern/eval.h
cont.$(OBJEXT): {$(VPATH)}internal/intern/file.h
-cont.$(OBJEXT): {$(VPATH)}internal/intern/gc.h
cont.$(OBJEXT): {$(VPATH)}internal/intern/hash.h
cont.$(OBJEXT): {$(VPATH)}internal/intern/io.h
cont.$(OBJEXT): {$(VPATH)}internal/intern/load.h
@@ -3594,7 +3914,6 @@ cont.$(OBJEXT): {$(VPATH)}internal/memory.h
cont.$(OBJEXT): {$(VPATH)}internal/method.h
cont.$(OBJEXT): {$(VPATH)}internal/module.h
cont.$(OBJEXT): {$(VPATH)}internal/newobj.h
-cont.$(OBJEXT): {$(VPATH)}internal/rgengc.h
cont.$(OBJEXT): {$(VPATH)}internal/scan_args.h
cont.$(OBJEXT): {$(VPATH)}internal/special_consts.h
cont.$(OBJEXT): {$(VPATH)}internal/static_assert.h
@@ -3609,14 +3928,18 @@ cont.$(OBJEXT): {$(VPATH)}internal/xmalloc.h
cont.$(OBJEXT): {$(VPATH)}iseq.h
cont.$(OBJEXT): {$(VPATH)}method.h
cont.$(OBJEXT): {$(VPATH)}missing.h
-cont.$(OBJEXT): {$(VPATH)}mjit.h
cont.$(OBJEXT): {$(VPATH)}node.h
cont.$(OBJEXT): {$(VPATH)}onigmo.h
cont.$(OBJEXT): {$(VPATH)}oniguruma.h
+cont.$(OBJEXT): {$(VPATH)}prism/ast.h
+cont.$(OBJEXT): {$(VPATH)}prism/version.h
+cont.$(OBJEXT): {$(VPATH)}prism_compile.h
cont.$(OBJEXT): {$(VPATH)}ractor.h
cont.$(OBJEXT): {$(VPATH)}ractor_core.h
+cont.$(OBJEXT): {$(VPATH)}rjit.h
cont.$(OBJEXT): {$(VPATH)}ruby_assert.h
cont.$(OBJEXT): {$(VPATH)}ruby_atomic.h
+cont.$(OBJEXT): {$(VPATH)}rubyparser.h
cont.$(OBJEXT): {$(VPATH)}shape.h
cont.$(OBJEXT): {$(VPATH)}st.h
cont.$(OBJEXT): {$(VPATH)}subst.h
@@ -3663,7 +3986,6 @@ debug.$(OBJEXT): {$(VPATH)}defines.h
debug.$(OBJEXT): {$(VPATH)}encindex.h
debug.$(OBJEXT): {$(VPATH)}encoding.h
debug.$(OBJEXT): {$(VPATH)}eval_intern.h
-debug.$(OBJEXT): {$(VPATH)}gc.h
debug.$(OBJEXT): {$(VPATH)}id.h
debug.$(OBJEXT): {$(VPATH)}id_table.h
debug.$(OBJEXT): {$(VPATH)}intern.h
@@ -3706,6 +4028,7 @@ debug.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
debug.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
debug.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
debug.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
+debug.$(OBJEXT): {$(VPATH)}internal/attr/packed_struct.h
debug.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
debug.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
debug.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
@@ -3774,7 +4097,6 @@ debug.$(OBJEXT): {$(VPATH)}internal/intern/enumerator.h
debug.$(OBJEXT): {$(VPATH)}internal/intern/error.h
debug.$(OBJEXT): {$(VPATH)}internal/intern/eval.h
debug.$(OBJEXT): {$(VPATH)}internal/intern/file.h
-debug.$(OBJEXT): {$(VPATH)}internal/intern/gc.h
debug.$(OBJEXT): {$(VPATH)}internal/intern/hash.h
debug.$(OBJEXT): {$(VPATH)}internal/intern/io.h
debug.$(OBJEXT): {$(VPATH)}internal/intern/load.h
@@ -3805,7 +4127,6 @@ debug.$(OBJEXT): {$(VPATH)}internal/memory.h
debug.$(OBJEXT): {$(VPATH)}internal/method.h
debug.$(OBJEXT): {$(VPATH)}internal/module.h
debug.$(OBJEXT): {$(VPATH)}internal/newobj.h
-debug.$(OBJEXT): {$(VPATH)}internal/rgengc.h
debug.$(OBJEXT): {$(VPATH)}internal/scan_args.h
debug.$(OBJEXT): {$(VPATH)}internal/special_consts.h
debug.$(OBJEXT): {$(VPATH)}internal/static_assert.h
@@ -3827,6 +4148,7 @@ debug.$(OBJEXT): {$(VPATH)}ractor.h
debug.$(OBJEXT): {$(VPATH)}ractor_core.h
debug.$(OBJEXT): {$(VPATH)}ruby_assert.h
debug.$(OBJEXT): {$(VPATH)}ruby_atomic.h
+debug.$(OBJEXT): {$(VPATH)}rubyparser.h
debug.$(OBJEXT): {$(VPATH)}shape.h
debug.$(OBJEXT): {$(VPATH)}st.h
debug.$(OBJEXT): {$(VPATH)}subst.h
@@ -3838,6 +4160,7 @@ debug.$(OBJEXT): {$(VPATH)}vm_callinfo.h
debug.$(OBJEXT): {$(VPATH)}vm_core.h
debug.$(OBJEXT): {$(VPATH)}vm_debug.h
debug.$(OBJEXT): {$(VPATH)}vm_opts.h
+debug.$(OBJEXT): {$(VPATH)}vm_sync.h
debug_counter.$(OBJEXT): $(hdrdir)/ruby/ruby.h
debug_counter.$(OBJEXT): {$(VPATH)}assert.h
debug_counter.$(OBJEXT): {$(VPATH)}backward/2/assume.h
@@ -3892,6 +4215,7 @@ debug_counter.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
debug_counter.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
debug_counter.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
debug_counter.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
+debug_counter.$(OBJEXT): {$(VPATH)}internal/attr/packed_struct.h
debug_counter.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
debug_counter.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
debug_counter.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
@@ -3951,7 +4275,6 @@ debug_counter.$(OBJEXT): {$(VPATH)}internal/intern/enumerator.h
debug_counter.$(OBJEXT): {$(VPATH)}internal/intern/error.h
debug_counter.$(OBJEXT): {$(VPATH)}internal/intern/eval.h
debug_counter.$(OBJEXT): {$(VPATH)}internal/intern/file.h
-debug_counter.$(OBJEXT): {$(VPATH)}internal/intern/gc.h
debug_counter.$(OBJEXT): {$(VPATH)}internal/intern/hash.h
debug_counter.$(OBJEXT): {$(VPATH)}internal/intern/io.h
debug_counter.$(OBJEXT): {$(VPATH)}internal/intern/load.h
@@ -3982,7 +4305,6 @@ debug_counter.$(OBJEXT): {$(VPATH)}internal/memory.h
debug_counter.$(OBJEXT): {$(VPATH)}internal/method.h
debug_counter.$(OBJEXT): {$(VPATH)}internal/module.h
debug_counter.$(OBJEXT): {$(VPATH)}internal/newobj.h
-debug_counter.$(OBJEXT): {$(VPATH)}internal/rgengc.h
debug_counter.$(OBJEXT): {$(VPATH)}internal/scan_args.h
debug_counter.$(OBJEXT): {$(VPATH)}internal/special_consts.h
debug_counter.$(OBJEXT): {$(VPATH)}internal/static_assert.h
@@ -3998,8 +4320,14 @@ debug_counter.$(OBJEXT): {$(VPATH)}missing.h
debug_counter.$(OBJEXT): {$(VPATH)}st.h
debug_counter.$(OBJEXT): {$(VPATH)}subst.h
debug_counter.$(OBJEXT): {$(VPATH)}thread_native.h
+dir.$(OBJEXT): $(CCAN_DIR)/check_type/check_type.h
+dir.$(OBJEXT): $(CCAN_DIR)/container_of/container_of.h
+dir.$(OBJEXT): $(CCAN_DIR)/list/list.h
+dir.$(OBJEXT): $(CCAN_DIR)/str/str.h
dir.$(OBJEXT): $(hdrdir)/ruby/ruby.h
+dir.$(OBJEXT): $(hdrdir)/ruby/version.h
dir.$(OBJEXT): $(top_srcdir)/internal/array.h
+dir.$(OBJEXT): $(top_srcdir)/internal/basic_operators.h
dir.$(OBJEXT): $(top_srcdir)/internal/class.h
dir.$(OBJEXT): $(top_srcdir)/internal/compilers.h
dir.$(OBJEXT): $(top_srcdir)/internal/dir.h
@@ -4007,6 +4335,7 @@ dir.$(OBJEXT): $(top_srcdir)/internal/encoding.h
dir.$(OBJEXT): $(top_srcdir)/internal/error.h
dir.$(OBJEXT): $(top_srcdir)/internal/file.h
dir.$(OBJEXT): $(top_srcdir)/internal/gc.h
+dir.$(OBJEXT): $(top_srcdir)/internal/imemo.h
dir.$(OBJEXT): $(top_srcdir)/internal/io.h
dir.$(OBJEXT): $(top_srcdir)/internal/object.h
dir.$(OBJEXT): $(top_srcdir)/internal/serial.h
@@ -4016,6 +4345,7 @@ dir.$(OBJEXT): $(top_srcdir)/internal/variable.h
dir.$(OBJEXT): $(top_srcdir)/internal/vm.h
dir.$(OBJEXT): $(top_srcdir)/internal/warnings.h
dir.$(OBJEXT): {$(VPATH)}assert.h
+dir.$(OBJEXT): {$(VPATH)}atomic.h
dir.$(OBJEXT): {$(VPATH)}backward/2/assume.h
dir.$(OBJEXT): {$(VPATH)}backward/2/attributes.h
dir.$(OBJEXT): {$(VPATH)}backward/2/bool.h
@@ -4075,6 +4405,7 @@ dir.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
dir.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
dir.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
dir.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
+dir.$(OBJEXT): {$(VPATH)}internal/attr/packed_struct.h
dir.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
dir.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
dir.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
@@ -4143,7 +4474,6 @@ dir.$(OBJEXT): {$(VPATH)}internal/intern/enumerator.h
dir.$(OBJEXT): {$(VPATH)}internal/intern/error.h
dir.$(OBJEXT): {$(VPATH)}internal/intern/eval.h
dir.$(OBJEXT): {$(VPATH)}internal/intern/file.h
-dir.$(OBJEXT): {$(VPATH)}internal/intern/gc.h
dir.$(OBJEXT): {$(VPATH)}internal/intern/hash.h
dir.$(OBJEXT): {$(VPATH)}internal/intern/io.h
dir.$(OBJEXT): {$(VPATH)}internal/intern/load.h
@@ -4174,7 +4504,6 @@ dir.$(OBJEXT): {$(VPATH)}internal/memory.h
dir.$(OBJEXT): {$(VPATH)}internal/method.h
dir.$(OBJEXT): {$(VPATH)}internal/module.h
dir.$(OBJEXT): {$(VPATH)}internal/newobj.h
-dir.$(OBJEXT): {$(VPATH)}internal/rgengc.h
dir.$(OBJEXT): {$(VPATH)}internal/scan_args.h
dir.$(OBJEXT): {$(VPATH)}internal/special_consts.h
dir.$(OBJEXT): {$(VPATH)}internal/static_assert.h
@@ -4187,14 +4516,23 @@ dir.$(OBJEXT): {$(VPATH)}internal/variable.h
dir.$(OBJEXT): {$(VPATH)}internal/warning_push.h
dir.$(OBJEXT): {$(VPATH)}internal/xmalloc.h
dir.$(OBJEXT): {$(VPATH)}io.h
+dir.$(OBJEXT): {$(VPATH)}method.h
dir.$(OBJEXT): {$(VPATH)}missing.h
+dir.$(OBJEXT): {$(VPATH)}node.h
dir.$(OBJEXT): {$(VPATH)}onigmo.h
dir.$(OBJEXT): {$(VPATH)}oniguruma.h
+dir.$(OBJEXT): {$(VPATH)}ruby_assert.h
+dir.$(OBJEXT): {$(VPATH)}ruby_atomic.h
+dir.$(OBJEXT): {$(VPATH)}rubyparser.h
dir.$(OBJEXT): {$(VPATH)}shape.h
dir.$(OBJEXT): {$(VPATH)}st.h
dir.$(OBJEXT): {$(VPATH)}subst.h
dir.$(OBJEXT): {$(VPATH)}thread.h
+dir.$(OBJEXT): {$(VPATH)}thread_$(THREAD_MODEL).h
+dir.$(OBJEXT): {$(VPATH)}thread_native.h
dir.$(OBJEXT): {$(VPATH)}util.h
+dir.$(OBJEXT): {$(VPATH)}vm_core.h
+dir.$(OBJEXT): {$(VPATH)}vm_opts.h
dln.$(OBJEXT): $(hdrdir)/ruby/ruby.h
dln.$(OBJEXT): $(top_srcdir)/internal/compilers.h
dln.$(OBJEXT): $(top_srcdir)/internal/warnings.h
@@ -4252,6 +4590,7 @@ dln.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
dln.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
dln.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
dln.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
+dln.$(OBJEXT): {$(VPATH)}internal/attr/packed_struct.h
dln.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
dln.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
dln.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
@@ -4311,7 +4650,6 @@ dln.$(OBJEXT): {$(VPATH)}internal/intern/enumerator.h
dln.$(OBJEXT): {$(VPATH)}internal/intern/error.h
dln.$(OBJEXT): {$(VPATH)}internal/intern/eval.h
dln.$(OBJEXT): {$(VPATH)}internal/intern/file.h
-dln.$(OBJEXT): {$(VPATH)}internal/intern/gc.h
dln.$(OBJEXT): {$(VPATH)}internal/intern/hash.h
dln.$(OBJEXT): {$(VPATH)}internal/intern/io.h
dln.$(OBJEXT): {$(VPATH)}internal/intern/load.h
@@ -4342,7 +4680,6 @@ dln.$(OBJEXT): {$(VPATH)}internal/memory.h
dln.$(OBJEXT): {$(VPATH)}internal/method.h
dln.$(OBJEXT): {$(VPATH)}internal/module.h
dln.$(OBJEXT): {$(VPATH)}internal/newobj.h
-dln.$(OBJEXT): {$(VPATH)}internal/rgengc.h
dln.$(OBJEXT): {$(VPATH)}internal/scan_args.h
dln.$(OBJEXT): {$(VPATH)}internal/special_consts.h
dln.$(OBJEXT): {$(VPATH)}internal/static_assert.h
@@ -4410,6 +4747,7 @@ dln_find.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
dln_find.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
dln_find.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
dln_find.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
+dln_find.$(OBJEXT): {$(VPATH)}internal/attr/packed_struct.h
dln_find.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
dln_find.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
dln_find.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
@@ -4469,7 +4807,6 @@ dln_find.$(OBJEXT): {$(VPATH)}internal/intern/enumerator.h
dln_find.$(OBJEXT): {$(VPATH)}internal/intern/error.h
dln_find.$(OBJEXT): {$(VPATH)}internal/intern/eval.h
dln_find.$(OBJEXT): {$(VPATH)}internal/intern/file.h
-dln_find.$(OBJEXT): {$(VPATH)}internal/intern/gc.h
dln_find.$(OBJEXT): {$(VPATH)}internal/intern/hash.h
dln_find.$(OBJEXT): {$(VPATH)}internal/intern/io.h
dln_find.$(OBJEXT): {$(VPATH)}internal/intern/load.h
@@ -4500,7 +4837,6 @@ dln_find.$(OBJEXT): {$(VPATH)}internal/memory.h
dln_find.$(OBJEXT): {$(VPATH)}internal/method.h
dln_find.$(OBJEXT): {$(VPATH)}internal/module.h
dln_find.$(OBJEXT): {$(VPATH)}internal/newobj.h
-dln_find.$(OBJEXT): {$(VPATH)}internal/rgengc.h
dln_find.$(OBJEXT): {$(VPATH)}internal/scan_args.h
dln_find.$(OBJEXT): {$(VPATH)}internal/special_consts.h
dln_find.$(OBJEXT): {$(VPATH)}internal/static_assert.h
@@ -4567,6 +4903,7 @@ dmydln.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
dmydln.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
dmydln.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
dmydln.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
+dmydln.$(OBJEXT): {$(VPATH)}internal/attr/packed_struct.h
dmydln.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
dmydln.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
dmydln.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
@@ -4626,7 +4963,6 @@ dmydln.$(OBJEXT): {$(VPATH)}internal/intern/enumerator.h
dmydln.$(OBJEXT): {$(VPATH)}internal/intern/error.h
dmydln.$(OBJEXT): {$(VPATH)}internal/intern/eval.h
dmydln.$(OBJEXT): {$(VPATH)}internal/intern/file.h
-dmydln.$(OBJEXT): {$(VPATH)}internal/intern/gc.h
dmydln.$(OBJEXT): {$(VPATH)}internal/intern/hash.h
dmydln.$(OBJEXT): {$(VPATH)}internal/intern/io.h
dmydln.$(OBJEXT): {$(VPATH)}internal/intern/load.h
@@ -4657,7 +4993,6 @@ dmydln.$(OBJEXT): {$(VPATH)}internal/memory.h
dmydln.$(OBJEXT): {$(VPATH)}internal/method.h
dmydln.$(OBJEXT): {$(VPATH)}internal/module.h
dmydln.$(OBJEXT): {$(VPATH)}internal/newobj.h
-dmydln.$(OBJEXT): {$(VPATH)}internal/rgengc.h
dmydln.$(OBJEXT): {$(VPATH)}internal/scan_args.h
dmydln.$(OBJEXT): {$(VPATH)}internal/special_consts.h
dmydln.$(OBJEXT): {$(VPATH)}internal/static_assert.h
@@ -4795,7 +5130,6 @@ enc/ascii.$(OBJEXT): {$(VPATH)}internal/intern/enumerator.h
enc/ascii.$(OBJEXT): {$(VPATH)}internal/intern/error.h
enc/ascii.$(OBJEXT): {$(VPATH)}internal/intern/eval.h
enc/ascii.$(OBJEXT): {$(VPATH)}internal/intern/file.h
-enc/ascii.$(OBJEXT): {$(VPATH)}internal/intern/gc.h
enc/ascii.$(OBJEXT): {$(VPATH)}internal/intern/hash.h
enc/ascii.$(OBJEXT): {$(VPATH)}internal/intern/io.h
enc/ascii.$(OBJEXT): {$(VPATH)}internal/intern/load.h
@@ -4826,7 +5160,6 @@ enc/ascii.$(OBJEXT): {$(VPATH)}internal/memory.h
enc/ascii.$(OBJEXT): {$(VPATH)}internal/method.h
enc/ascii.$(OBJEXT): {$(VPATH)}internal/module.h
enc/ascii.$(OBJEXT): {$(VPATH)}internal/newobj.h
-enc/ascii.$(OBJEXT): {$(VPATH)}internal/rgengc.h
enc/ascii.$(OBJEXT): {$(VPATH)}internal/scan_args.h
enc/ascii.$(OBJEXT): {$(VPATH)}internal/special_consts.h
enc/ascii.$(OBJEXT): {$(VPATH)}internal/static_assert.h
@@ -4954,7 +5287,6 @@ enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/intern/enumerator.h
enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/intern/error.h
enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/intern/eval.h
enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/intern/file.h
-enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/intern/gc.h
enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/intern/hash.h
enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/intern/io.h
enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/intern/load.h
@@ -4985,7 +5317,6 @@ enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/memory.h
enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/method.h
enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/module.h
enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/newobj.h
-enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/rgengc.h
enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/scan_args.h
enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/special_consts.h
enc/trans/newline.$(OBJEXT): {$(VPATH)}internal/static_assert.h
@@ -5113,7 +5444,6 @@ enc/unicode.$(OBJEXT): {$(VPATH)}internal/intern/enumerator.h
enc/unicode.$(OBJEXT): {$(VPATH)}internal/intern/error.h
enc/unicode.$(OBJEXT): {$(VPATH)}internal/intern/eval.h
enc/unicode.$(OBJEXT): {$(VPATH)}internal/intern/file.h
-enc/unicode.$(OBJEXT): {$(VPATH)}internal/intern/gc.h
enc/unicode.$(OBJEXT): {$(VPATH)}internal/intern/hash.h
enc/unicode.$(OBJEXT): {$(VPATH)}internal/intern/io.h
enc/unicode.$(OBJEXT): {$(VPATH)}internal/intern/load.h
@@ -5144,7 +5474,6 @@ enc/unicode.$(OBJEXT): {$(VPATH)}internal/memory.h
enc/unicode.$(OBJEXT): {$(VPATH)}internal/method.h
enc/unicode.$(OBJEXT): {$(VPATH)}internal/module.h
enc/unicode.$(OBJEXT): {$(VPATH)}internal/newobj.h
-enc/unicode.$(OBJEXT): {$(VPATH)}internal/rgengc.h
enc/unicode.$(OBJEXT): {$(VPATH)}internal/scan_args.h
enc/unicode.$(OBJEXT): {$(VPATH)}internal/special_consts.h
enc/unicode.$(OBJEXT): {$(VPATH)}internal/static_assert.h
@@ -5283,7 +5612,6 @@ enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/intern/enumerator.h
enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/intern/error.h
enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/intern/eval.h
enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/intern/file.h
-enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/intern/gc.h
enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/intern/hash.h
enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/intern/io.h
enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/intern/load.h
@@ -5314,7 +5642,6 @@ enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/memory.h
enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/method.h
enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/module.h
enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/newobj.h
-enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/rgengc.h
enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/scan_args.h
enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/special_consts.h
enc/us_ascii.$(OBJEXT): {$(VPATH)}internal/static_assert.h
@@ -5453,7 +5780,6 @@ enc/utf_8.$(OBJEXT): {$(VPATH)}internal/intern/enumerator.h
enc/utf_8.$(OBJEXT): {$(VPATH)}internal/intern/error.h
enc/utf_8.$(OBJEXT): {$(VPATH)}internal/intern/eval.h
enc/utf_8.$(OBJEXT): {$(VPATH)}internal/intern/file.h
-enc/utf_8.$(OBJEXT): {$(VPATH)}internal/intern/gc.h
enc/utf_8.$(OBJEXT): {$(VPATH)}internal/intern/hash.h
enc/utf_8.$(OBJEXT): {$(VPATH)}internal/intern/io.h
enc/utf_8.$(OBJEXT): {$(VPATH)}internal/intern/load.h
@@ -5484,7 +5810,6 @@ enc/utf_8.$(OBJEXT): {$(VPATH)}internal/memory.h
enc/utf_8.$(OBJEXT): {$(VPATH)}internal/method.h
enc/utf_8.$(OBJEXT): {$(VPATH)}internal/module.h
enc/utf_8.$(OBJEXT): {$(VPATH)}internal/newobj.h
-enc/utf_8.$(OBJEXT): {$(VPATH)}internal/rgengc.h
enc/utf_8.$(OBJEXT): {$(VPATH)}internal/scan_args.h
enc/utf_8.$(OBJEXT): {$(VPATH)}internal/special_consts.h
enc/utf_8.$(OBJEXT): {$(VPATH)}internal/static_assert.h
@@ -5502,14 +5827,22 @@ enc/utf_8.$(OBJEXT): {$(VPATH)}oniguruma.h
enc/utf_8.$(OBJEXT): {$(VPATH)}regenc.h
enc/utf_8.$(OBJEXT): {$(VPATH)}st.h
enc/utf_8.$(OBJEXT): {$(VPATH)}subst.h
+encoding.$(OBJEXT): $(CCAN_DIR)/check_type/check_type.h
+encoding.$(OBJEXT): $(CCAN_DIR)/container_of/container_of.h
+encoding.$(OBJEXT): $(CCAN_DIR)/list/list.h
+encoding.$(OBJEXT): $(CCAN_DIR)/str/str.h
encoding.$(OBJEXT): $(hdrdir)/ruby.h
encoding.$(OBJEXT): $(hdrdir)/ruby/ruby.h
+encoding.$(OBJEXT): $(hdrdir)/ruby/version.h
+encoding.$(OBJEXT): $(top_srcdir)/internal/array.h
+encoding.$(OBJEXT): $(top_srcdir)/internal/basic_operators.h
encoding.$(OBJEXT): $(top_srcdir)/internal/class.h
encoding.$(OBJEXT): $(top_srcdir)/internal/compilers.h
encoding.$(OBJEXT): $(top_srcdir)/internal/enc.h
encoding.$(OBJEXT): $(top_srcdir)/internal/encoding.h
encoding.$(OBJEXT): $(top_srcdir)/internal/error.h
encoding.$(OBJEXT): $(top_srcdir)/internal/gc.h
+encoding.$(OBJEXT): $(top_srcdir)/internal/imemo.h
encoding.$(OBJEXT): $(top_srcdir)/internal/inits.h
encoding.$(OBJEXT): $(top_srcdir)/internal/load.h
encoding.$(OBJEXT): $(top_srcdir)/internal/object.h
@@ -5520,6 +5853,7 @@ encoding.$(OBJEXT): $(top_srcdir)/internal/variable.h
encoding.$(OBJEXT): $(top_srcdir)/internal/vm.h
encoding.$(OBJEXT): $(top_srcdir)/internal/warnings.h
encoding.$(OBJEXT): {$(VPATH)}assert.h
+encoding.$(OBJEXT): {$(VPATH)}atomic.h
encoding.$(OBJEXT): {$(VPATH)}backward/2/assume.h
encoding.$(OBJEXT): {$(VPATH)}backward/2/attributes.h
encoding.$(OBJEXT): {$(VPATH)}backward/2/bool.h
@@ -5536,6 +5870,7 @@ encoding.$(OBJEXT): {$(VPATH)}defines.h
encoding.$(OBJEXT): {$(VPATH)}encindex.h
encoding.$(OBJEXT): {$(VPATH)}encoding.c
encoding.$(OBJEXT): {$(VPATH)}encoding.h
+encoding.$(OBJEXT): {$(VPATH)}id.h
encoding.$(OBJEXT): {$(VPATH)}id_table.h
encoding.$(OBJEXT): {$(VPATH)}intern.h
encoding.$(OBJEXT): {$(VPATH)}internal.h
@@ -5577,6 +5912,7 @@ encoding.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
encoding.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
encoding.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
encoding.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
+encoding.$(OBJEXT): {$(VPATH)}internal/attr/packed_struct.h
encoding.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
encoding.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
encoding.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
@@ -5645,7 +5981,6 @@ encoding.$(OBJEXT): {$(VPATH)}internal/intern/enumerator.h
encoding.$(OBJEXT): {$(VPATH)}internal/intern/error.h
encoding.$(OBJEXT): {$(VPATH)}internal/intern/eval.h
encoding.$(OBJEXT): {$(VPATH)}internal/intern/file.h
-encoding.$(OBJEXT): {$(VPATH)}internal/intern/gc.h
encoding.$(OBJEXT): {$(VPATH)}internal/intern/hash.h
encoding.$(OBJEXT): {$(VPATH)}internal/intern/io.h
encoding.$(OBJEXT): {$(VPATH)}internal/intern/load.h
@@ -5676,7 +6011,6 @@ encoding.$(OBJEXT): {$(VPATH)}internal/memory.h
encoding.$(OBJEXT): {$(VPATH)}internal/method.h
encoding.$(OBJEXT): {$(VPATH)}internal/module.h
encoding.$(OBJEXT): {$(VPATH)}internal/newobj.h
-encoding.$(OBJEXT): {$(VPATH)}internal/rgengc.h
encoding.$(OBJEXT): {$(VPATH)}internal/scan_args.h
encoding.$(OBJEXT): {$(VPATH)}internal/special_consts.h
encoding.$(OBJEXT): {$(VPATH)}internal/static_assert.h
@@ -5688,16 +6022,24 @@ encoding.$(OBJEXT): {$(VPATH)}internal/value_type.h
encoding.$(OBJEXT): {$(VPATH)}internal/variable.h
encoding.$(OBJEXT): {$(VPATH)}internal/warning_push.h
encoding.$(OBJEXT): {$(VPATH)}internal/xmalloc.h
+encoding.$(OBJEXT): {$(VPATH)}method.h
encoding.$(OBJEXT): {$(VPATH)}missing.h
+encoding.$(OBJEXT): {$(VPATH)}node.h
encoding.$(OBJEXT): {$(VPATH)}onigmo.h
encoding.$(OBJEXT): {$(VPATH)}oniguruma.h
encoding.$(OBJEXT): {$(VPATH)}regenc.h
encoding.$(OBJEXT): {$(VPATH)}ruby_assert.h
+encoding.$(OBJEXT): {$(VPATH)}ruby_atomic.h
+encoding.$(OBJEXT): {$(VPATH)}rubyparser.h
encoding.$(OBJEXT): {$(VPATH)}shape.h
encoding.$(OBJEXT): {$(VPATH)}st.h
encoding.$(OBJEXT): {$(VPATH)}subst.h
+encoding.$(OBJEXT): {$(VPATH)}thread_$(THREAD_MODEL).h
+encoding.$(OBJEXT): {$(VPATH)}thread_native.h
encoding.$(OBJEXT): {$(VPATH)}util.h
+encoding.$(OBJEXT): {$(VPATH)}vm_core.h
encoding.$(OBJEXT): {$(VPATH)}vm_debug.h
+encoding.$(OBJEXT): {$(VPATH)}vm_opts.h
encoding.$(OBJEXT): {$(VPATH)}vm_sync.h
enum.$(OBJEXT): $(hdrdir)/ruby/ruby.h
enum.$(OBJEXT): $(top_srcdir)/internal/array.h
@@ -5779,6 +6121,7 @@ enum.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
enum.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
enum.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
enum.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
+enum.$(OBJEXT): {$(VPATH)}internal/attr/packed_struct.h
enum.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
enum.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
enum.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
@@ -5847,7 +6190,6 @@ enum.$(OBJEXT): {$(VPATH)}internal/intern/enumerator.h
enum.$(OBJEXT): {$(VPATH)}internal/intern/error.h
enum.$(OBJEXT): {$(VPATH)}internal/intern/eval.h
enum.$(OBJEXT): {$(VPATH)}internal/intern/file.h
-enum.$(OBJEXT): {$(VPATH)}internal/intern/gc.h
enum.$(OBJEXT): {$(VPATH)}internal/intern/hash.h
enum.$(OBJEXT): {$(VPATH)}internal/intern/io.h
enum.$(OBJEXT): {$(VPATH)}internal/intern/load.h
@@ -5878,7 +6220,6 @@ enum.$(OBJEXT): {$(VPATH)}internal/memory.h
enum.$(OBJEXT): {$(VPATH)}internal/method.h
enum.$(OBJEXT): {$(VPATH)}internal/module.h
enum.$(OBJEXT): {$(VPATH)}internal/newobj.h
-enum.$(OBJEXT): {$(VPATH)}internal/rgengc.h
enum.$(OBJEXT): {$(VPATH)}internal/scan_args.h
enum.$(OBJEXT): {$(VPATH)}internal/special_consts.h
enum.$(OBJEXT): {$(VPATH)}internal/static_assert.h
@@ -5899,8 +6240,14 @@ enum.$(OBJEXT): {$(VPATH)}st.h
enum.$(OBJEXT): {$(VPATH)}subst.h
enum.$(OBJEXT): {$(VPATH)}symbol.h
enum.$(OBJEXT): {$(VPATH)}util.h
+enumerator.$(OBJEXT): $(CCAN_DIR)/check_type/check_type.h
+enumerator.$(OBJEXT): $(CCAN_DIR)/container_of/container_of.h
+enumerator.$(OBJEXT): $(CCAN_DIR)/list/list.h
+enumerator.$(OBJEXT): $(CCAN_DIR)/str/str.h
enumerator.$(OBJEXT): $(hdrdir)/ruby/ruby.h
+enumerator.$(OBJEXT): $(hdrdir)/ruby/version.h
enumerator.$(OBJEXT): $(top_srcdir)/internal/array.h
+enumerator.$(OBJEXT): $(top_srcdir)/internal/basic_operators.h
enumerator.$(OBJEXT): $(top_srcdir)/internal/bignum.h
enumerator.$(OBJEXT): $(top_srcdir)/internal/bits.h
enumerator.$(OBJEXT): $(top_srcdir)/internal/class.h
@@ -5918,9 +6265,11 @@ enumerator.$(OBJEXT): $(top_srcdir)/internal/serial.h
enumerator.$(OBJEXT): $(top_srcdir)/internal/static_assert.h
enumerator.$(OBJEXT): $(top_srcdir)/internal/string.h
enumerator.$(OBJEXT): $(top_srcdir)/internal/struct.h
+enumerator.$(OBJEXT): $(top_srcdir)/internal/variable.h
enumerator.$(OBJEXT): $(top_srcdir)/internal/vm.h
enumerator.$(OBJEXT): $(top_srcdir)/internal/warnings.h
enumerator.$(OBJEXT): {$(VPATH)}assert.h
+enumerator.$(OBJEXT): {$(VPATH)}atomic.h
enumerator.$(OBJEXT): {$(VPATH)}backward/2/assume.h
enumerator.$(OBJEXT): {$(VPATH)}backward/2/attributes.h
enumerator.$(OBJEXT): {$(VPATH)}backward/2/bool.h
@@ -5931,6 +6280,8 @@ enumerator.$(OBJEXT): {$(VPATH)}backward/2/long_long.h
enumerator.$(OBJEXT): {$(VPATH)}backward/2/stdalign.h
enumerator.$(OBJEXT): {$(VPATH)}backward/2/stdarg.h
enumerator.$(OBJEXT): {$(VPATH)}config.h
+enumerator.$(OBJEXT): {$(VPATH)}constant.h
+enumerator.$(OBJEXT): {$(VPATH)}debug_counter.h
enumerator.$(OBJEXT): {$(VPATH)}defines.h
enumerator.$(OBJEXT): {$(VPATH)}encoding.h
enumerator.$(OBJEXT): {$(VPATH)}enumerator.c
@@ -5976,6 +6327,7 @@ enumerator.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
enumerator.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
enumerator.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
enumerator.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
+enumerator.$(OBJEXT): {$(VPATH)}internal/attr/packed_struct.h
enumerator.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
enumerator.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
enumerator.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
@@ -6044,7 +6396,6 @@ enumerator.$(OBJEXT): {$(VPATH)}internal/intern/enumerator.h
enumerator.$(OBJEXT): {$(VPATH)}internal/intern/error.h
enumerator.$(OBJEXT): {$(VPATH)}internal/intern/eval.h
enumerator.$(OBJEXT): {$(VPATH)}internal/intern/file.h
-enumerator.$(OBJEXT): {$(VPATH)}internal/intern/gc.h
enumerator.$(OBJEXT): {$(VPATH)}internal/intern/hash.h
enumerator.$(OBJEXT): {$(VPATH)}internal/intern/io.h
enumerator.$(OBJEXT): {$(VPATH)}internal/intern/load.h
@@ -6075,7 +6426,6 @@ enumerator.$(OBJEXT): {$(VPATH)}internal/memory.h
enumerator.$(OBJEXT): {$(VPATH)}internal/method.h
enumerator.$(OBJEXT): {$(VPATH)}internal/module.h
enumerator.$(OBJEXT): {$(VPATH)}internal/newobj.h
-enumerator.$(OBJEXT): {$(VPATH)}internal/rgengc.h
enumerator.$(OBJEXT): {$(VPATH)}internal/scan_args.h
enumerator.$(OBJEXT): {$(VPATH)}internal/special_consts.h
enumerator.$(OBJEXT): {$(VPATH)}internal/static_assert.h
@@ -6087,18 +6437,29 @@ enumerator.$(OBJEXT): {$(VPATH)}internal/value_type.h
enumerator.$(OBJEXT): {$(VPATH)}internal/variable.h
enumerator.$(OBJEXT): {$(VPATH)}internal/warning_push.h
enumerator.$(OBJEXT): {$(VPATH)}internal/xmalloc.h
+enumerator.$(OBJEXT): {$(VPATH)}method.h
enumerator.$(OBJEXT): {$(VPATH)}missing.h
+enumerator.$(OBJEXT): {$(VPATH)}node.h
enumerator.$(OBJEXT): {$(VPATH)}onigmo.h
enumerator.$(OBJEXT): {$(VPATH)}oniguruma.h
enumerator.$(OBJEXT): {$(VPATH)}ruby_assert.h
+enumerator.$(OBJEXT): {$(VPATH)}ruby_atomic.h
+enumerator.$(OBJEXT): {$(VPATH)}rubyparser.h
enumerator.$(OBJEXT): {$(VPATH)}shape.h
enumerator.$(OBJEXT): {$(VPATH)}st.h
enumerator.$(OBJEXT): {$(VPATH)}subst.h
+enumerator.$(OBJEXT): {$(VPATH)}thread_$(THREAD_MODEL).h
+enumerator.$(OBJEXT): {$(VPATH)}thread_native.h
+enumerator.$(OBJEXT): {$(VPATH)}vm_core.h
+enumerator.$(OBJEXT): {$(VPATH)}vm_debug.h
+enumerator.$(OBJEXT): {$(VPATH)}vm_opts.h
+enumerator.$(OBJEXT): {$(VPATH)}vm_sync.h
error.$(OBJEXT): $(CCAN_DIR)/check_type/check_type.h
error.$(OBJEXT): $(CCAN_DIR)/container_of/container_of.h
error.$(OBJEXT): $(CCAN_DIR)/list/list.h
error.$(OBJEXT): $(CCAN_DIR)/str/str.h
error.$(OBJEXT): $(hdrdir)/ruby/ruby.h
+error.$(OBJEXT): $(hdrdir)/ruby/version.h
error.$(OBJEXT): $(top_srcdir)/internal/array.h
error.$(OBJEXT): $(top_srcdir)/internal/basic_operators.h
error.$(OBJEXT): $(top_srcdir)/internal/class.h
@@ -6111,6 +6472,7 @@ error.$(OBJEXT): $(top_srcdir)/internal/imemo.h
error.$(OBJEXT): $(top_srcdir)/internal/io.h
error.$(OBJEXT): $(top_srcdir)/internal/load.h
error.$(OBJEXT): $(top_srcdir)/internal/object.h
+error.$(OBJEXT): $(top_srcdir)/internal/process.h
error.$(OBJEXT): $(top_srcdir)/internal/serial.h
error.$(OBJEXT): $(top_srcdir)/internal/static_assert.h
error.$(OBJEXT): $(top_srcdir)/internal/string.h
@@ -6178,6 +6540,7 @@ error.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
error.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
error.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
error.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
+error.$(OBJEXT): {$(VPATH)}internal/attr/packed_struct.h
error.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
error.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
error.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
@@ -6246,7 +6609,6 @@ error.$(OBJEXT): {$(VPATH)}internal/intern/enumerator.h
error.$(OBJEXT): {$(VPATH)}internal/intern/error.h
error.$(OBJEXT): {$(VPATH)}internal/intern/eval.h
error.$(OBJEXT): {$(VPATH)}internal/intern/file.h
-error.$(OBJEXT): {$(VPATH)}internal/intern/gc.h
error.$(OBJEXT): {$(VPATH)}internal/intern/hash.h
error.$(OBJEXT): {$(VPATH)}internal/intern/io.h
error.$(OBJEXT): {$(VPATH)}internal/intern/load.h
@@ -6277,7 +6639,6 @@ error.$(OBJEXT): {$(VPATH)}internal/memory.h
error.$(OBJEXT): {$(VPATH)}internal/method.h
error.$(OBJEXT): {$(VPATH)}internal/module.h
error.$(OBJEXT): {$(VPATH)}internal/newobj.h
-error.$(OBJEXT): {$(VPATH)}internal/rgengc.h
error.$(OBJEXT): {$(VPATH)}internal/scan_args.h
error.$(OBJEXT): {$(VPATH)}internal/special_consts.h
error.$(OBJEXT): {$(VPATH)}internal/static_assert.h
@@ -6298,11 +6659,13 @@ error.$(OBJEXT): {$(VPATH)}onigmo.h
error.$(OBJEXT): {$(VPATH)}oniguruma.h
error.$(OBJEXT): {$(VPATH)}ruby_assert.h
error.$(OBJEXT): {$(VPATH)}ruby_atomic.h
+error.$(OBJEXT): {$(VPATH)}rubyparser.h
error.$(OBJEXT): {$(VPATH)}shape.h
error.$(OBJEXT): {$(VPATH)}st.h
error.$(OBJEXT): {$(VPATH)}subst.h
error.$(OBJEXT): {$(VPATH)}thread_$(THREAD_MODEL).h
error.$(OBJEXT): {$(VPATH)}thread_native.h
+error.$(OBJEXT): {$(VPATH)}util.h
error.$(OBJEXT): {$(VPATH)}vm_core.h
error.$(OBJEXT): {$(VPATH)}vm_opts.h
error.$(OBJEXT): {$(VPATH)}warning.rbinc
@@ -6312,6 +6675,7 @@ eval.$(OBJEXT): $(CCAN_DIR)/list/list.h
eval.$(OBJEXT): $(CCAN_DIR)/str/str.h
eval.$(OBJEXT): $(hdrdir)/ruby.h
eval.$(OBJEXT): $(hdrdir)/ruby/ruby.h
+eval.$(OBJEXT): $(hdrdir)/ruby/version.h
eval.$(OBJEXT): $(top_srcdir)/internal/array.h
eval.$(OBJEXT): $(top_srcdir)/internal/basic_operators.h
eval.$(OBJEXT): $(top_srcdir)/internal/class.h
@@ -6332,6 +6696,27 @@ eval.$(OBJEXT): $(top_srcdir)/internal/thread.h
eval.$(OBJEXT): $(top_srcdir)/internal/variable.h
eval.$(OBJEXT): $(top_srcdir)/internal/vm.h
eval.$(OBJEXT): $(top_srcdir)/internal/warnings.h
+eval.$(OBJEXT): $(top_srcdir)/prism/defines.h
+eval.$(OBJEXT): $(top_srcdir)/prism/diagnostic.h
+eval.$(OBJEXT): $(top_srcdir)/prism/encoding.h
+eval.$(OBJEXT): $(top_srcdir)/prism/node.h
+eval.$(OBJEXT): $(top_srcdir)/prism/options.h
+eval.$(OBJEXT): $(top_srcdir)/prism/pack.h
+eval.$(OBJEXT): $(top_srcdir)/prism/parser.h
+eval.$(OBJEXT): $(top_srcdir)/prism/prettyprint.h
+eval.$(OBJEXT): $(top_srcdir)/prism/prism.h
+eval.$(OBJEXT): $(top_srcdir)/prism/regexp.h
+eval.$(OBJEXT): $(top_srcdir)/prism/util/pm_buffer.h
+eval.$(OBJEXT): $(top_srcdir)/prism/util/pm_char.h
+eval.$(OBJEXT): $(top_srcdir)/prism/util/pm_constant_pool.h
+eval.$(OBJEXT): $(top_srcdir)/prism/util/pm_list.h
+eval.$(OBJEXT): $(top_srcdir)/prism/util/pm_memchr.h
+eval.$(OBJEXT): $(top_srcdir)/prism/util/pm_newline_list.h
+eval.$(OBJEXT): $(top_srcdir)/prism/util/pm_state_stack.h
+eval.$(OBJEXT): $(top_srcdir)/prism/util/pm_string.h
+eval.$(OBJEXT): $(top_srcdir)/prism/util/pm_string_list.h
+eval.$(OBJEXT): $(top_srcdir)/prism/util/pm_strncasecmp.h
+eval.$(OBJEXT): $(top_srcdir)/prism/util/pm_strpbrk.h
eval.$(OBJEXT): {$(VPATH)}assert.h
eval.$(OBJEXT): {$(VPATH)}atomic.h
eval.$(OBJEXT): {$(VPATH)}backward/2/assume.h
@@ -6353,7 +6738,6 @@ eval.$(OBJEXT): {$(VPATH)}eval_error.c
eval.$(OBJEXT): {$(VPATH)}eval_intern.h
eval.$(OBJEXT): {$(VPATH)}eval_jump.c
eval.$(OBJEXT): {$(VPATH)}fiber/scheduler.h
-eval.$(OBJEXT): {$(VPATH)}gc.h
eval.$(OBJEXT): {$(VPATH)}id.h
eval.$(OBJEXT): {$(VPATH)}id_table.h
eval.$(OBJEXT): {$(VPATH)}intern.h
@@ -6396,6 +6780,7 @@ eval.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
eval.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
eval.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
eval.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
+eval.$(OBJEXT): {$(VPATH)}internal/attr/packed_struct.h
eval.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
eval.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
eval.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
@@ -6464,7 +6849,6 @@ eval.$(OBJEXT): {$(VPATH)}internal/intern/enumerator.h
eval.$(OBJEXT): {$(VPATH)}internal/intern/error.h
eval.$(OBJEXT): {$(VPATH)}internal/intern/eval.h
eval.$(OBJEXT): {$(VPATH)}internal/intern/file.h
-eval.$(OBJEXT): {$(VPATH)}internal/intern/gc.h
eval.$(OBJEXT): {$(VPATH)}internal/intern/hash.h
eval.$(OBJEXT): {$(VPATH)}internal/intern/io.h
eval.$(OBJEXT): {$(VPATH)}internal/intern/load.h
@@ -6495,7 +6879,6 @@ eval.$(OBJEXT): {$(VPATH)}internal/memory.h
eval.$(OBJEXT): {$(VPATH)}internal/method.h
eval.$(OBJEXT): {$(VPATH)}internal/module.h
eval.$(OBJEXT): {$(VPATH)}internal/newobj.h
-eval.$(OBJEXT): {$(VPATH)}internal/rgengc.h
eval.$(OBJEXT): {$(VPATH)}internal/scan_args.h
eval.$(OBJEXT): {$(VPATH)}internal/special_consts.h
eval.$(OBJEXT): {$(VPATH)}internal/static_assert.h
@@ -6511,17 +6894,21 @@ eval.$(OBJEXT): {$(VPATH)}io.h
eval.$(OBJEXT): {$(VPATH)}iseq.h
eval.$(OBJEXT): {$(VPATH)}method.h
eval.$(OBJEXT): {$(VPATH)}missing.h
-eval.$(OBJEXT): {$(VPATH)}mjit.h
eval.$(OBJEXT): {$(VPATH)}node.h
eval.$(OBJEXT): {$(VPATH)}onigmo.h
eval.$(OBJEXT): {$(VPATH)}oniguruma.h
+eval.$(OBJEXT): {$(VPATH)}prism/ast.h
+eval.$(OBJEXT): {$(VPATH)}prism/version.h
+eval.$(OBJEXT): {$(VPATH)}prism_compile.h
eval.$(OBJEXT): {$(VPATH)}probes.dmyh
eval.$(OBJEXT): {$(VPATH)}probes.h
eval.$(OBJEXT): {$(VPATH)}probes_helper.h
eval.$(OBJEXT): {$(VPATH)}ractor.h
eval.$(OBJEXT): {$(VPATH)}ractor_core.h
+eval.$(OBJEXT): {$(VPATH)}rjit.h
eval.$(OBJEXT): {$(VPATH)}ruby_assert.h
eval.$(OBJEXT): {$(VPATH)}ruby_atomic.h
+eval.$(OBJEXT): {$(VPATH)}rubyparser.h
eval.$(OBJEXT): {$(VPATH)}shape.h
eval.$(OBJEXT): {$(VPATH)}st.h
eval.$(OBJEXT): {$(VPATH)}subst.h
@@ -6531,6 +6918,7 @@ eval.$(OBJEXT): {$(VPATH)}vm.h
eval.$(OBJEXT): {$(VPATH)}vm_core.h
eval.$(OBJEXT): {$(VPATH)}vm_debug.h
eval.$(OBJEXT): {$(VPATH)}vm_opts.h
+eval.$(OBJEXT): {$(VPATH)}vm_sync.h
explicit_bzero.$(OBJEXT): {$(VPATH)}config.h
explicit_bzero.$(OBJEXT): {$(VPATH)}explicit_bzero.c
explicit_bzero.$(OBJEXT): {$(VPATH)}internal/attr/format.h
@@ -6546,7 +6934,12 @@ explicit_bzero.$(OBJEXT): {$(VPATH)}internal/config.h
explicit_bzero.$(OBJEXT): {$(VPATH)}internal/dllexport.h
explicit_bzero.$(OBJEXT): {$(VPATH)}internal/has/attribute.h
explicit_bzero.$(OBJEXT): {$(VPATH)}missing.h
+file.$(OBJEXT): $(CCAN_DIR)/check_type/check_type.h
+file.$(OBJEXT): $(CCAN_DIR)/container_of/container_of.h
+file.$(OBJEXT): $(CCAN_DIR)/list/list.h
+file.$(OBJEXT): $(CCAN_DIR)/str/str.h
file.$(OBJEXT): $(hdrdir)/ruby/ruby.h
+file.$(OBJEXT): $(hdrdir)/ruby/version.h
file.$(OBJEXT): $(top_srcdir)/internal/array.h
file.$(OBJEXT): $(top_srcdir)/internal/class.h
file.$(OBJEXT): $(top_srcdir)/internal/compilers.h
@@ -6625,6 +7018,7 @@ file.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
file.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
file.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
file.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
+file.$(OBJEXT): {$(VPATH)}internal/attr/packed_struct.h
file.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
file.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
file.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
@@ -6693,7 +7087,6 @@ file.$(OBJEXT): {$(VPATH)}internal/intern/enumerator.h
file.$(OBJEXT): {$(VPATH)}internal/intern/error.h
file.$(OBJEXT): {$(VPATH)}internal/intern/eval.h
file.$(OBJEXT): {$(VPATH)}internal/intern/file.h
-file.$(OBJEXT): {$(VPATH)}internal/intern/gc.h
file.$(OBJEXT): {$(VPATH)}internal/intern/hash.h
file.$(OBJEXT): {$(VPATH)}internal/intern/io.h
file.$(OBJEXT): {$(VPATH)}internal/intern/load.h
@@ -6724,7 +7117,6 @@ file.$(OBJEXT): {$(VPATH)}internal/memory.h
file.$(OBJEXT): {$(VPATH)}internal/method.h
file.$(OBJEXT): {$(VPATH)}internal/module.h
file.$(OBJEXT): {$(VPATH)}internal/newobj.h
-file.$(OBJEXT): {$(VPATH)}internal/rgengc.h
file.$(OBJEXT): {$(VPATH)}internal/scan_args.h
file.$(OBJEXT): {$(VPATH)}internal/special_consts.h
file.$(OBJEXT): {$(VPATH)}internal/static_assert.h
@@ -6744,6 +7136,7 @@ file.$(OBJEXT): {$(VPATH)}shape.h
file.$(OBJEXT): {$(VPATH)}st.h
file.$(OBJEXT): {$(VPATH)}subst.h
file.$(OBJEXT): {$(VPATH)}thread.h
+file.$(OBJEXT): {$(VPATH)}thread_native.h
file.$(OBJEXT): {$(VPATH)}util.h
gc.$(OBJEXT): $(CCAN_DIR)/check_type/check_type.h
gc.$(OBJEXT): $(CCAN_DIR)/container_of/container_of.h
@@ -6751,11 +7144,13 @@ gc.$(OBJEXT): $(CCAN_DIR)/list/list.h
gc.$(OBJEXT): $(CCAN_DIR)/str/str.h
gc.$(OBJEXT): $(hdrdir)/ruby.h
gc.$(OBJEXT): $(hdrdir)/ruby/ruby.h
+gc.$(OBJEXT): $(hdrdir)/ruby/version.h
gc.$(OBJEXT): $(top_srcdir)/internal/array.h
gc.$(OBJEXT): $(top_srcdir)/internal/basic_operators.h
gc.$(OBJEXT): $(top_srcdir)/internal/bignum.h
gc.$(OBJEXT): $(top_srcdir)/internal/bits.h
gc.$(OBJEXT): $(top_srcdir)/internal/class.h
+gc.$(OBJEXT): $(top_srcdir)/internal/compile.h
gc.$(OBJEXT): $(top_srcdir)/internal/compilers.h
gc.$(OBJEXT): $(top_srcdir)/internal/complex.h
gc.$(OBJEXT): $(top_srcdir)/internal/cont.h
@@ -6780,6 +7175,27 @@ gc.$(OBJEXT): $(top_srcdir)/internal/thread.h
gc.$(OBJEXT): $(top_srcdir)/internal/variable.h
gc.$(OBJEXT): $(top_srcdir)/internal/vm.h
gc.$(OBJEXT): $(top_srcdir)/internal/warnings.h
+gc.$(OBJEXT): $(top_srcdir)/prism/defines.h
+gc.$(OBJEXT): $(top_srcdir)/prism/diagnostic.h
+gc.$(OBJEXT): $(top_srcdir)/prism/encoding.h
+gc.$(OBJEXT): $(top_srcdir)/prism/node.h
+gc.$(OBJEXT): $(top_srcdir)/prism/options.h
+gc.$(OBJEXT): $(top_srcdir)/prism/pack.h
+gc.$(OBJEXT): $(top_srcdir)/prism/parser.h
+gc.$(OBJEXT): $(top_srcdir)/prism/prettyprint.h
+gc.$(OBJEXT): $(top_srcdir)/prism/prism.h
+gc.$(OBJEXT): $(top_srcdir)/prism/regexp.h
+gc.$(OBJEXT): $(top_srcdir)/prism/util/pm_buffer.h
+gc.$(OBJEXT): $(top_srcdir)/prism/util/pm_char.h
+gc.$(OBJEXT): $(top_srcdir)/prism/util/pm_constant_pool.h
+gc.$(OBJEXT): $(top_srcdir)/prism/util/pm_list.h
+gc.$(OBJEXT): $(top_srcdir)/prism/util/pm_memchr.h
+gc.$(OBJEXT): $(top_srcdir)/prism/util/pm_newline_list.h
+gc.$(OBJEXT): $(top_srcdir)/prism/util/pm_state_stack.h
+gc.$(OBJEXT): $(top_srcdir)/prism/util/pm_string.h
+gc.$(OBJEXT): $(top_srcdir)/prism/util/pm_string_list.h
+gc.$(OBJEXT): $(top_srcdir)/prism/util/pm_strncasecmp.h
+gc.$(OBJEXT): $(top_srcdir)/prism/util/pm_strpbrk.h
gc.$(OBJEXT): {$(VPATH)}assert.h
gc.$(OBJEXT): {$(VPATH)}atomic.h
gc.$(OBJEXT): {$(VPATH)}backward/2/assume.h
@@ -6794,13 +7210,13 @@ gc.$(OBJEXT): {$(VPATH)}backward/2/stdarg.h
gc.$(OBJEXT): {$(VPATH)}builtin.h
gc.$(OBJEXT): {$(VPATH)}config.h
gc.$(OBJEXT): {$(VPATH)}constant.h
+gc.$(OBJEXT): {$(VPATH)}darray.h
gc.$(OBJEXT): {$(VPATH)}debug.h
gc.$(OBJEXT): {$(VPATH)}debug_counter.h
gc.$(OBJEXT): {$(VPATH)}defines.h
gc.$(OBJEXT): {$(VPATH)}encoding.h
gc.$(OBJEXT): {$(VPATH)}eval_intern.h
gc.$(OBJEXT): {$(VPATH)}gc.c
-gc.$(OBJEXT): {$(VPATH)}gc.h
gc.$(OBJEXT): {$(VPATH)}gc.rbinc
gc.$(OBJEXT): {$(VPATH)}id.h
gc.$(OBJEXT): {$(VPATH)}id_table.h
@@ -6844,6 +7260,7 @@ gc.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
gc.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
gc.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
gc.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
+gc.$(OBJEXT): {$(VPATH)}internal/attr/packed_struct.h
gc.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
gc.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
gc.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
@@ -6913,7 +7330,6 @@ gc.$(OBJEXT): {$(VPATH)}internal/intern/enumerator.h
gc.$(OBJEXT): {$(VPATH)}internal/intern/error.h
gc.$(OBJEXT): {$(VPATH)}internal/intern/eval.h
gc.$(OBJEXT): {$(VPATH)}internal/intern/file.h
-gc.$(OBJEXT): {$(VPATH)}internal/intern/gc.h
gc.$(OBJEXT): {$(VPATH)}internal/intern/hash.h
gc.$(OBJEXT): {$(VPATH)}internal/intern/io.h
gc.$(OBJEXT): {$(VPATH)}internal/intern/load.h
@@ -6944,7 +7360,6 @@ gc.$(OBJEXT): {$(VPATH)}internal/memory.h
gc.$(OBJEXT): {$(VPATH)}internal/method.h
gc.$(OBJEXT): {$(VPATH)}internal/module.h
gc.$(OBJEXT): {$(VPATH)}internal/newobj.h
-gc.$(OBJEXT): {$(VPATH)}internal/rgengc.h
gc.$(OBJEXT): {$(VPATH)}internal/scan_args.h
gc.$(OBJEXT): {$(VPATH)}internal/special_consts.h
gc.$(OBJEXT): {$(VPATH)}internal/static_assert.h
@@ -6960,10 +7375,12 @@ gc.$(OBJEXT): {$(VPATH)}io.h
gc.$(OBJEXT): {$(VPATH)}iseq.h
gc.$(OBJEXT): {$(VPATH)}method.h
gc.$(OBJEXT): {$(VPATH)}missing.h
-gc.$(OBJEXT): {$(VPATH)}mjit.h
gc.$(OBJEXT): {$(VPATH)}node.h
gc.$(OBJEXT): {$(VPATH)}onigmo.h
gc.$(OBJEXT): {$(VPATH)}oniguruma.h
+gc.$(OBJEXT): {$(VPATH)}prism/ast.h
+gc.$(OBJEXT): {$(VPATH)}prism/version.h
+gc.$(OBJEXT): {$(VPATH)}prism_compile.h
gc.$(OBJEXT): {$(VPATH)}probes.dmyh
gc.$(OBJEXT): {$(VPATH)}probes.h
gc.$(OBJEXT): {$(VPATH)}ractor.h
@@ -6972,8 +7389,10 @@ gc.$(OBJEXT): {$(VPATH)}re.h
gc.$(OBJEXT): {$(VPATH)}regenc.h
gc.$(OBJEXT): {$(VPATH)}regex.h
gc.$(OBJEXT): {$(VPATH)}regint.h
+gc.$(OBJEXT): {$(VPATH)}rjit.h
gc.$(OBJEXT): {$(VPATH)}ruby_assert.h
gc.$(OBJEXT): {$(VPATH)}ruby_atomic.h
+gc.$(OBJEXT): {$(VPATH)}rubyparser.h
gc.$(OBJEXT): {$(VPATH)}shape.h
gc.$(OBJEXT): {$(VPATH)}st.h
gc.$(OBJEXT): {$(VPATH)}subst.h
@@ -6981,7 +7400,6 @@ gc.$(OBJEXT): {$(VPATH)}symbol.h
gc.$(OBJEXT): {$(VPATH)}thread.h
gc.$(OBJEXT): {$(VPATH)}thread_$(THREAD_MODEL).h
gc.$(OBJEXT): {$(VPATH)}thread_native.h
-gc.$(OBJEXT): {$(VPATH)}transient_heap.h
gc.$(OBJEXT): {$(VPATH)}util.h
gc.$(OBJEXT): {$(VPATH)}vm_callinfo.h
gc.$(OBJEXT): {$(VPATH)}vm_core.h
@@ -6999,11 +7417,33 @@ goruby.$(OBJEXT): $(top_srcdir)/internal/basic_operators.h
goruby.$(OBJEXT): $(top_srcdir)/internal/compilers.h
goruby.$(OBJEXT): $(top_srcdir)/internal/gc.h
goruby.$(OBJEXT): $(top_srcdir)/internal/imemo.h
+goruby.$(OBJEXT): $(top_srcdir)/internal/ruby_parser.h
goruby.$(OBJEXT): $(top_srcdir)/internal/serial.h
goruby.$(OBJEXT): $(top_srcdir)/internal/static_assert.h
goruby.$(OBJEXT): $(top_srcdir)/internal/variable.h
goruby.$(OBJEXT): $(top_srcdir)/internal/vm.h
goruby.$(OBJEXT): $(top_srcdir)/internal/warnings.h
+goruby.$(OBJEXT): $(top_srcdir)/prism/defines.h
+goruby.$(OBJEXT): $(top_srcdir)/prism/diagnostic.h
+goruby.$(OBJEXT): $(top_srcdir)/prism/encoding.h
+goruby.$(OBJEXT): $(top_srcdir)/prism/node.h
+goruby.$(OBJEXT): $(top_srcdir)/prism/options.h
+goruby.$(OBJEXT): $(top_srcdir)/prism/pack.h
+goruby.$(OBJEXT): $(top_srcdir)/prism/parser.h
+goruby.$(OBJEXT): $(top_srcdir)/prism/prettyprint.h
+goruby.$(OBJEXT): $(top_srcdir)/prism/prism.h
+goruby.$(OBJEXT): $(top_srcdir)/prism/regexp.h
+goruby.$(OBJEXT): $(top_srcdir)/prism/util/pm_buffer.h
+goruby.$(OBJEXT): $(top_srcdir)/prism/util/pm_char.h
+goruby.$(OBJEXT): $(top_srcdir)/prism/util/pm_constant_pool.h
+goruby.$(OBJEXT): $(top_srcdir)/prism/util/pm_list.h
+goruby.$(OBJEXT): $(top_srcdir)/prism/util/pm_memchr.h
+goruby.$(OBJEXT): $(top_srcdir)/prism/util/pm_newline_list.h
+goruby.$(OBJEXT): $(top_srcdir)/prism/util/pm_state_stack.h
+goruby.$(OBJEXT): $(top_srcdir)/prism/util/pm_string.h
+goruby.$(OBJEXT): $(top_srcdir)/prism/util/pm_string_list.h
+goruby.$(OBJEXT): $(top_srcdir)/prism/util/pm_strncasecmp.h
+goruby.$(OBJEXT): $(top_srcdir)/prism/util/pm_strpbrk.h
goruby.$(OBJEXT): {$(VPATH)}assert.h
goruby.$(OBJEXT): {$(VPATH)}atomic.h
goruby.$(OBJEXT): {$(VPATH)}backward.h
@@ -7019,6 +7459,7 @@ goruby.$(OBJEXT): {$(VPATH)}backward/2/stdarg.h
goruby.$(OBJEXT): {$(VPATH)}config.h
goruby.$(OBJEXT): {$(VPATH)}constant.h
goruby.$(OBJEXT): {$(VPATH)}defines.h
+goruby.$(OBJEXT): {$(VPATH)}encoding.h
goruby.$(OBJEXT): {$(VPATH)}golf_prelude.c
goruby.$(OBJEXT): {$(VPATH)}goruby.c
goruby.$(OBJEXT): {$(VPATH)}id.h
@@ -7063,6 +7504,7 @@ goruby.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
goruby.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
goruby.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
goruby.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
+goruby.$(OBJEXT): {$(VPATH)}internal/attr/packed_struct.h
goruby.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
goruby.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
goruby.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
@@ -7095,6 +7537,15 @@ goruby.$(OBJEXT): {$(VPATH)}internal/core/rtypeddata.h
goruby.$(OBJEXT): {$(VPATH)}internal/ctype.h
goruby.$(OBJEXT): {$(VPATH)}internal/dllexport.h
goruby.$(OBJEXT): {$(VPATH)}internal/dosish.h
+goruby.$(OBJEXT): {$(VPATH)}internal/encoding/coderange.h
+goruby.$(OBJEXT): {$(VPATH)}internal/encoding/ctype.h
+goruby.$(OBJEXT): {$(VPATH)}internal/encoding/encoding.h
+goruby.$(OBJEXT): {$(VPATH)}internal/encoding/pathname.h
+goruby.$(OBJEXT): {$(VPATH)}internal/encoding/re.h
+goruby.$(OBJEXT): {$(VPATH)}internal/encoding/sprintf.h
+goruby.$(OBJEXT): {$(VPATH)}internal/encoding/string.h
+goruby.$(OBJEXT): {$(VPATH)}internal/encoding/symbol.h
+goruby.$(OBJEXT): {$(VPATH)}internal/encoding/transcode.h
goruby.$(OBJEXT): {$(VPATH)}internal/error.h
goruby.$(OBJEXT): {$(VPATH)}internal/eval.h
goruby.$(OBJEXT): {$(VPATH)}internal/event.h
@@ -7122,7 +7573,6 @@ goruby.$(OBJEXT): {$(VPATH)}internal/intern/enumerator.h
goruby.$(OBJEXT): {$(VPATH)}internal/intern/error.h
goruby.$(OBJEXT): {$(VPATH)}internal/intern/eval.h
goruby.$(OBJEXT): {$(VPATH)}internal/intern/file.h
-goruby.$(OBJEXT): {$(VPATH)}internal/intern/gc.h
goruby.$(OBJEXT): {$(VPATH)}internal/intern/hash.h
goruby.$(OBJEXT): {$(VPATH)}internal/intern/io.h
goruby.$(OBJEXT): {$(VPATH)}internal/intern/load.h
@@ -7153,7 +7603,6 @@ goruby.$(OBJEXT): {$(VPATH)}internal/memory.h
goruby.$(OBJEXT): {$(VPATH)}internal/method.h
goruby.$(OBJEXT): {$(VPATH)}internal/module.h
goruby.$(OBJEXT): {$(VPATH)}internal/newobj.h
-goruby.$(OBJEXT): {$(VPATH)}internal/rgengc.h
goruby.$(OBJEXT): {$(VPATH)}internal/scan_args.h
goruby.$(OBJEXT): {$(VPATH)}internal/special_consts.h
goruby.$(OBJEXT): {$(VPATH)}internal/static_assert.h
@@ -7170,8 +7619,14 @@ goruby.$(OBJEXT): {$(VPATH)}main.c
goruby.$(OBJEXT): {$(VPATH)}method.h
goruby.$(OBJEXT): {$(VPATH)}missing.h
goruby.$(OBJEXT): {$(VPATH)}node.h
+goruby.$(OBJEXT): {$(VPATH)}onigmo.h
+goruby.$(OBJEXT): {$(VPATH)}oniguruma.h
+goruby.$(OBJEXT): {$(VPATH)}prism/ast.h
+goruby.$(OBJEXT): {$(VPATH)}prism/version.h
+goruby.$(OBJEXT): {$(VPATH)}prism_compile.h
goruby.$(OBJEXT): {$(VPATH)}ruby_assert.h
goruby.$(OBJEXT): {$(VPATH)}ruby_atomic.h
+goruby.$(OBJEXT): {$(VPATH)}rubyparser.h
goruby.$(OBJEXT): {$(VPATH)}shape.h
goruby.$(OBJEXT): {$(VPATH)}st.h
goruby.$(OBJEXT): {$(VPATH)}subst.h
@@ -7185,6 +7640,7 @@ hash.$(OBJEXT): $(CCAN_DIR)/container_of/container_of.h
hash.$(OBJEXT): $(CCAN_DIR)/list/list.h
hash.$(OBJEXT): $(CCAN_DIR)/str/str.h
hash.$(OBJEXT): $(hdrdir)/ruby/ruby.h
+hash.$(OBJEXT): $(hdrdir)/ruby/version.h
hash.$(OBJEXT): $(top_srcdir)/internal/array.h
hash.$(OBJEXT): $(top_srcdir)/internal/basic_operators.h
hash.$(OBJEXT): $(top_srcdir)/internal/bignum.h
@@ -7207,6 +7663,27 @@ hash.$(OBJEXT): $(top_srcdir)/internal/time.h
hash.$(OBJEXT): $(top_srcdir)/internal/variable.h
hash.$(OBJEXT): $(top_srcdir)/internal/vm.h
hash.$(OBJEXT): $(top_srcdir)/internal/warnings.h
+hash.$(OBJEXT): $(top_srcdir)/prism/defines.h
+hash.$(OBJEXT): $(top_srcdir)/prism/diagnostic.h
+hash.$(OBJEXT): $(top_srcdir)/prism/encoding.h
+hash.$(OBJEXT): $(top_srcdir)/prism/node.h
+hash.$(OBJEXT): $(top_srcdir)/prism/options.h
+hash.$(OBJEXT): $(top_srcdir)/prism/pack.h
+hash.$(OBJEXT): $(top_srcdir)/prism/parser.h
+hash.$(OBJEXT): $(top_srcdir)/prism/prettyprint.h
+hash.$(OBJEXT): $(top_srcdir)/prism/prism.h
+hash.$(OBJEXT): $(top_srcdir)/prism/regexp.h
+hash.$(OBJEXT): $(top_srcdir)/prism/util/pm_buffer.h
+hash.$(OBJEXT): $(top_srcdir)/prism/util/pm_char.h
+hash.$(OBJEXT): $(top_srcdir)/prism/util/pm_constant_pool.h
+hash.$(OBJEXT): $(top_srcdir)/prism/util/pm_list.h
+hash.$(OBJEXT): $(top_srcdir)/prism/util/pm_memchr.h
+hash.$(OBJEXT): $(top_srcdir)/prism/util/pm_newline_list.h
+hash.$(OBJEXT): $(top_srcdir)/prism/util/pm_state_stack.h
+hash.$(OBJEXT): $(top_srcdir)/prism/util/pm_string.h
+hash.$(OBJEXT): $(top_srcdir)/prism/util/pm_string_list.h
+hash.$(OBJEXT): $(top_srcdir)/prism/util/pm_strncasecmp.h
+hash.$(OBJEXT): $(top_srcdir)/prism/util/pm_strpbrk.h
hash.$(OBJEXT): {$(VPATH)}assert.h
hash.$(OBJEXT): {$(VPATH)}atomic.h
hash.$(OBJEXT): {$(VPATH)}backward/2/assume.h
@@ -7266,6 +7743,7 @@ hash.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
hash.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
hash.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
hash.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
+hash.$(OBJEXT): {$(VPATH)}internal/attr/packed_struct.h
hash.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
hash.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
hash.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
@@ -7334,7 +7812,6 @@ hash.$(OBJEXT): {$(VPATH)}internal/intern/enumerator.h
hash.$(OBJEXT): {$(VPATH)}internal/intern/error.h
hash.$(OBJEXT): {$(VPATH)}internal/intern/eval.h
hash.$(OBJEXT): {$(VPATH)}internal/intern/file.h
-hash.$(OBJEXT): {$(VPATH)}internal/intern/gc.h
hash.$(OBJEXT): {$(VPATH)}internal/intern/hash.h
hash.$(OBJEXT): {$(VPATH)}internal/intern/io.h
hash.$(OBJEXT): {$(VPATH)}internal/intern/load.h
@@ -7365,7 +7842,6 @@ hash.$(OBJEXT): {$(VPATH)}internal/memory.h
hash.$(OBJEXT): {$(VPATH)}internal/method.h
hash.$(OBJEXT): {$(VPATH)}internal/module.h
hash.$(OBJEXT): {$(VPATH)}internal/newobj.h
-hash.$(OBJEXT): {$(VPATH)}internal/rgengc.h
hash.$(OBJEXT): {$(VPATH)}internal/scan_args.h
hash.$(OBJEXT): {$(VPATH)}internal/special_consts.h
hash.$(OBJEXT): {$(VPATH)}internal/static_assert.h
@@ -7383,18 +7859,21 @@ hash.$(OBJEXT): {$(VPATH)}missing.h
hash.$(OBJEXT): {$(VPATH)}node.h
hash.$(OBJEXT): {$(VPATH)}onigmo.h
hash.$(OBJEXT): {$(VPATH)}oniguruma.h
+hash.$(OBJEXT): {$(VPATH)}prism/ast.h
+hash.$(OBJEXT): {$(VPATH)}prism/version.h
+hash.$(OBJEXT): {$(VPATH)}prism_compile.h
hash.$(OBJEXT): {$(VPATH)}probes.dmyh
hash.$(OBJEXT): {$(VPATH)}probes.h
hash.$(OBJEXT): {$(VPATH)}ractor.h
hash.$(OBJEXT): {$(VPATH)}ruby_assert.h
hash.$(OBJEXT): {$(VPATH)}ruby_atomic.h
+hash.$(OBJEXT): {$(VPATH)}rubyparser.h
hash.$(OBJEXT): {$(VPATH)}shape.h
hash.$(OBJEXT): {$(VPATH)}st.h
hash.$(OBJEXT): {$(VPATH)}subst.h
hash.$(OBJEXT): {$(VPATH)}symbol.h
hash.$(OBJEXT): {$(VPATH)}thread_$(THREAD_MODEL).h
hash.$(OBJEXT): {$(VPATH)}thread_native.h
-hash.$(OBJEXT): {$(VPATH)}transient_heap.h
hash.$(OBJEXT): {$(VPATH)}util.h
hash.$(OBJEXT): {$(VPATH)}vm_core.h
hash.$(OBJEXT): {$(VPATH)}vm_debug.h
@@ -7458,6 +7937,7 @@ inits.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
inits.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
inits.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
inits.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
+inits.$(OBJEXT): {$(VPATH)}internal/attr/packed_struct.h
inits.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
inits.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
inits.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
@@ -7517,7 +7997,6 @@ inits.$(OBJEXT): {$(VPATH)}internal/intern/enumerator.h
inits.$(OBJEXT): {$(VPATH)}internal/intern/error.h
inits.$(OBJEXT): {$(VPATH)}internal/intern/eval.h
inits.$(OBJEXT): {$(VPATH)}internal/intern/file.h
-inits.$(OBJEXT): {$(VPATH)}internal/intern/gc.h
inits.$(OBJEXT): {$(VPATH)}internal/intern/hash.h
inits.$(OBJEXT): {$(VPATH)}internal/intern/io.h
inits.$(OBJEXT): {$(VPATH)}internal/intern/load.h
@@ -7548,7 +8027,6 @@ inits.$(OBJEXT): {$(VPATH)}internal/memory.h
inits.$(OBJEXT): {$(VPATH)}internal/method.h
inits.$(OBJEXT): {$(VPATH)}internal/module.h
inits.$(OBJEXT): {$(VPATH)}internal/newobj.h
-inits.$(OBJEXT): {$(VPATH)}internal/rgengc.h
inits.$(OBJEXT): {$(VPATH)}internal/scan_args.h
inits.$(OBJEXT): {$(VPATH)}internal/special_consts.h
inits.$(OBJEXT): {$(VPATH)}internal/static_assert.h
@@ -7569,6 +8047,7 @@ io.$(OBJEXT): $(CCAN_DIR)/container_of/container_of.h
io.$(OBJEXT): $(CCAN_DIR)/list/list.h
io.$(OBJEXT): $(CCAN_DIR)/str/str.h
io.$(OBJEXT): $(hdrdir)/ruby/ruby.h
+io.$(OBJEXT): $(hdrdir)/ruby/version.h
io.$(OBJEXT): $(top_srcdir)/internal/array.h
io.$(OBJEXT): $(top_srcdir)/internal/basic_operators.h
io.$(OBJEXT): $(top_srcdir)/internal/bignum.h
@@ -7654,6 +8133,7 @@ io.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
io.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
io.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
io.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
+io.$(OBJEXT): {$(VPATH)}internal/attr/packed_struct.h
io.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
io.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
io.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
@@ -7722,7 +8202,6 @@ io.$(OBJEXT): {$(VPATH)}internal/intern/enumerator.h
io.$(OBJEXT): {$(VPATH)}internal/intern/error.h
io.$(OBJEXT): {$(VPATH)}internal/intern/eval.h
io.$(OBJEXT): {$(VPATH)}internal/intern/file.h
-io.$(OBJEXT): {$(VPATH)}internal/intern/gc.h
io.$(OBJEXT): {$(VPATH)}internal/intern/hash.h
io.$(OBJEXT): {$(VPATH)}internal/intern/io.h
io.$(OBJEXT): {$(VPATH)}internal/intern/load.h
@@ -7753,7 +8232,6 @@ io.$(OBJEXT): {$(VPATH)}internal/memory.h
io.$(OBJEXT): {$(VPATH)}internal/method.h
io.$(OBJEXT): {$(VPATH)}internal/module.h
io.$(OBJEXT): {$(VPATH)}internal/newobj.h
-io.$(OBJEXT): {$(VPATH)}internal/rgengc.h
io.$(OBJEXT): {$(VPATH)}internal/scan_args.h
io.$(OBJEXT): {$(VPATH)}internal/special_consts.h
io.$(OBJEXT): {$(VPATH)}internal/static_assert.h
@@ -7777,6 +8255,7 @@ io.$(OBJEXT): {$(VPATH)}oniguruma.h
io.$(OBJEXT): {$(VPATH)}ractor.h
io.$(OBJEXT): {$(VPATH)}ruby_assert.h
io.$(OBJEXT): {$(VPATH)}ruby_atomic.h
+io.$(OBJEXT): {$(VPATH)}rubyparser.h
io.$(OBJEXT): {$(VPATH)}shape.h
io.$(OBJEXT): {$(VPATH)}st.h
io.$(OBJEXT): {$(VPATH)}subst.h
@@ -7786,7 +8265,12 @@ io.$(OBJEXT): {$(VPATH)}thread_native.h
io.$(OBJEXT): {$(VPATH)}util.h
io.$(OBJEXT): {$(VPATH)}vm_core.h
io.$(OBJEXT): {$(VPATH)}vm_opts.h
+io_buffer.$(OBJEXT): $(CCAN_DIR)/check_type/check_type.h
+io_buffer.$(OBJEXT): $(CCAN_DIR)/container_of/container_of.h
+io_buffer.$(OBJEXT): $(CCAN_DIR)/list/list.h
+io_buffer.$(OBJEXT): $(CCAN_DIR)/str/str.h
io_buffer.$(OBJEXT): $(hdrdir)/ruby/ruby.h
+io_buffer.$(OBJEXT): $(hdrdir)/ruby/version.h
io_buffer.$(OBJEXT): $(top_srcdir)/internal/array.h
io_buffer.$(OBJEXT): $(top_srcdir)/internal/bignum.h
io_buffer.$(OBJEXT): $(top_srcdir)/internal/bits.h
@@ -7853,6 +8337,7 @@ io_buffer.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
io_buffer.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
io_buffer.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
io_buffer.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
+io_buffer.$(OBJEXT): {$(VPATH)}internal/attr/packed_struct.h
io_buffer.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
io_buffer.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
io_buffer.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
@@ -7921,7 +8406,6 @@ io_buffer.$(OBJEXT): {$(VPATH)}internal/intern/enumerator.h
io_buffer.$(OBJEXT): {$(VPATH)}internal/intern/error.h
io_buffer.$(OBJEXT): {$(VPATH)}internal/intern/eval.h
io_buffer.$(OBJEXT): {$(VPATH)}internal/intern/file.h
-io_buffer.$(OBJEXT): {$(VPATH)}internal/intern/gc.h
io_buffer.$(OBJEXT): {$(VPATH)}internal/intern/hash.h
io_buffer.$(OBJEXT): {$(VPATH)}internal/intern/io.h
io_buffer.$(OBJEXT): {$(VPATH)}internal/intern/load.h
@@ -7952,7 +8436,6 @@ io_buffer.$(OBJEXT): {$(VPATH)}internal/memory.h
io_buffer.$(OBJEXT): {$(VPATH)}internal/method.h
io_buffer.$(OBJEXT): {$(VPATH)}internal/module.h
io_buffer.$(OBJEXT): {$(VPATH)}internal/newobj.h
-io_buffer.$(OBJEXT): {$(VPATH)}internal/rgengc.h
io_buffer.$(OBJEXT): {$(VPATH)}internal/scan_args.h
io_buffer.$(OBJEXT): {$(VPATH)}internal/special_consts.h
io_buffer.$(OBJEXT): {$(VPATH)}internal/static_assert.h
@@ -7972,12 +8455,14 @@ io_buffer.$(OBJEXT): {$(VPATH)}onigmo.h
io_buffer.$(OBJEXT): {$(VPATH)}oniguruma.h
io_buffer.$(OBJEXT): {$(VPATH)}st.h
io_buffer.$(OBJEXT): {$(VPATH)}subst.h
+io_buffer.$(OBJEXT): {$(VPATH)}thread_native.h
iseq.$(OBJEXT): $(CCAN_DIR)/check_type/check_type.h
iseq.$(OBJEXT): $(CCAN_DIR)/container_of/container_of.h
iseq.$(OBJEXT): $(CCAN_DIR)/list/list.h
iseq.$(OBJEXT): $(CCAN_DIR)/str/str.h
iseq.$(OBJEXT): $(hdrdir)/ruby.h
iseq.$(OBJEXT): $(hdrdir)/ruby/ruby.h
+iseq.$(OBJEXT): $(hdrdir)/ruby/version.h
iseq.$(OBJEXT): $(top_srcdir)/internal/array.h
iseq.$(OBJEXT): $(top_srcdir)/internal/basic_operators.h
iseq.$(OBJEXT): $(top_srcdir)/internal/bits.h
@@ -7990,6 +8475,7 @@ iseq.$(OBJEXT): $(top_srcdir)/internal/gc.h
iseq.$(OBJEXT): $(top_srcdir)/internal/hash.h
iseq.$(OBJEXT): $(top_srcdir)/internal/imemo.h
iseq.$(OBJEXT): $(top_srcdir)/internal/parse.h
+iseq.$(OBJEXT): $(top_srcdir)/internal/ruby_parser.h
iseq.$(OBJEXT): $(top_srcdir)/internal/sanitizers.h
iseq.$(OBJEXT): $(top_srcdir)/internal/serial.h
iseq.$(OBJEXT): $(top_srcdir)/internal/static_assert.h
@@ -7999,6 +8485,27 @@ iseq.$(OBJEXT): $(top_srcdir)/internal/thread.h
iseq.$(OBJEXT): $(top_srcdir)/internal/variable.h
iseq.$(OBJEXT): $(top_srcdir)/internal/vm.h
iseq.$(OBJEXT): $(top_srcdir)/internal/warnings.h
+iseq.$(OBJEXT): $(top_srcdir)/prism/defines.h
+iseq.$(OBJEXT): $(top_srcdir)/prism/diagnostic.h
+iseq.$(OBJEXT): $(top_srcdir)/prism/encoding.h
+iseq.$(OBJEXT): $(top_srcdir)/prism/node.h
+iseq.$(OBJEXT): $(top_srcdir)/prism/options.h
+iseq.$(OBJEXT): $(top_srcdir)/prism/pack.h
+iseq.$(OBJEXT): $(top_srcdir)/prism/parser.h
+iseq.$(OBJEXT): $(top_srcdir)/prism/prettyprint.h
+iseq.$(OBJEXT): $(top_srcdir)/prism/prism.h
+iseq.$(OBJEXT): $(top_srcdir)/prism/regexp.h
+iseq.$(OBJEXT): $(top_srcdir)/prism/util/pm_buffer.h
+iseq.$(OBJEXT): $(top_srcdir)/prism/util/pm_char.h
+iseq.$(OBJEXT): $(top_srcdir)/prism/util/pm_constant_pool.h
+iseq.$(OBJEXT): $(top_srcdir)/prism/util/pm_list.h
+iseq.$(OBJEXT): $(top_srcdir)/prism/util/pm_memchr.h
+iseq.$(OBJEXT): $(top_srcdir)/prism/util/pm_newline_list.h
+iseq.$(OBJEXT): $(top_srcdir)/prism/util/pm_state_stack.h
+iseq.$(OBJEXT): $(top_srcdir)/prism/util/pm_string.h
+iseq.$(OBJEXT): $(top_srcdir)/prism/util/pm_string_list.h
+iseq.$(OBJEXT): $(top_srcdir)/prism/util/pm_strncasecmp.h
+iseq.$(OBJEXT): $(top_srcdir)/prism/util/pm_strpbrk.h
iseq.$(OBJEXT): {$(VPATH)}assert.h
iseq.$(OBJEXT): {$(VPATH)}atomic.h
iseq.$(OBJEXT): {$(VPATH)}backward/2/assume.h
@@ -8017,7 +8524,6 @@ iseq.$(OBJEXT): {$(VPATH)}debug_counter.h
iseq.$(OBJEXT): {$(VPATH)}defines.h
iseq.$(OBJEXT): {$(VPATH)}encoding.h
iseq.$(OBJEXT): {$(VPATH)}eval_intern.h
-iseq.$(OBJEXT): {$(VPATH)}gc.h
iseq.$(OBJEXT): {$(VPATH)}id.h
iseq.$(OBJEXT): {$(VPATH)}id_table.h
iseq.$(OBJEXT): {$(VPATH)}insns.def
@@ -8063,6 +8569,7 @@ iseq.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
iseq.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
iseq.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
iseq.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
+iseq.$(OBJEXT): {$(VPATH)}internal/attr/packed_struct.h
iseq.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
iseq.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
iseq.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
@@ -8131,7 +8638,6 @@ iseq.$(OBJEXT): {$(VPATH)}internal/intern/enumerator.h
iseq.$(OBJEXT): {$(VPATH)}internal/intern/error.h
iseq.$(OBJEXT): {$(VPATH)}internal/intern/eval.h
iseq.$(OBJEXT): {$(VPATH)}internal/intern/file.h
-iseq.$(OBJEXT): {$(VPATH)}internal/intern/gc.h
iseq.$(OBJEXT): {$(VPATH)}internal/intern/hash.h
iseq.$(OBJEXT): {$(VPATH)}internal/intern/io.h
iseq.$(OBJEXT): {$(VPATH)}internal/intern/load.h
@@ -8162,7 +8668,6 @@ iseq.$(OBJEXT): {$(VPATH)}internal/memory.h
iseq.$(OBJEXT): {$(VPATH)}internal/method.h
iseq.$(OBJEXT): {$(VPATH)}internal/module.h
iseq.$(OBJEXT): {$(VPATH)}internal/newobj.h
-iseq.$(OBJEXT): {$(VPATH)}internal/rgengc.h
iseq.$(OBJEXT): {$(VPATH)}internal/scan_args.h
iseq.$(OBJEXT): {$(VPATH)}internal/special_consts.h
iseq.$(OBJEXT): {$(VPATH)}internal/static_assert.h
@@ -8178,14 +8683,18 @@ iseq.$(OBJEXT): {$(VPATH)}iseq.c
iseq.$(OBJEXT): {$(VPATH)}iseq.h
iseq.$(OBJEXT): {$(VPATH)}method.h
iseq.$(OBJEXT): {$(VPATH)}missing.h
-iseq.$(OBJEXT): {$(VPATH)}mjit.h
iseq.$(OBJEXT): {$(VPATH)}node.h
-iseq.$(OBJEXT): {$(VPATH)}node_name.inc
iseq.$(OBJEXT): {$(VPATH)}onigmo.h
iseq.$(OBJEXT): {$(VPATH)}oniguruma.h
+iseq.$(OBJEXT): {$(VPATH)}prism/ast.h
+iseq.$(OBJEXT): {$(VPATH)}prism/prism.h
+iseq.$(OBJEXT): {$(VPATH)}prism/version.h
+iseq.$(OBJEXT): {$(VPATH)}prism_compile.h
iseq.$(OBJEXT): {$(VPATH)}ractor.h
+iseq.$(OBJEXT): {$(VPATH)}rjit.h
iseq.$(OBJEXT): {$(VPATH)}ruby_assert.h
iseq.$(OBJEXT): {$(VPATH)}ruby_atomic.h
+iseq.$(OBJEXT): {$(VPATH)}rubyparser.h
iseq.$(OBJEXT): {$(VPATH)}shape.h
iseq.$(OBJEXT): {$(VPATH)}st.h
iseq.$(OBJEXT): {$(VPATH)}subst.h
@@ -8194,23 +8703,29 @@ iseq.$(OBJEXT): {$(VPATH)}thread_native.h
iseq.$(OBJEXT): {$(VPATH)}util.h
iseq.$(OBJEXT): {$(VPATH)}vm_callinfo.h
iseq.$(OBJEXT): {$(VPATH)}vm_core.h
+iseq.$(OBJEXT): {$(VPATH)}vm_debug.h
iseq.$(OBJEXT): {$(VPATH)}vm_opts.h
+iseq.$(OBJEXT): {$(VPATH)}vm_sync.h
iseq.$(OBJEXT): {$(VPATH)}yjit.h
load.$(OBJEXT): $(CCAN_DIR)/check_type/check_type.h
load.$(OBJEXT): $(CCAN_DIR)/container_of/container_of.h
load.$(OBJEXT): $(CCAN_DIR)/list/list.h
load.$(OBJEXT): $(CCAN_DIR)/str/str.h
load.$(OBJEXT): $(hdrdir)/ruby/ruby.h
+load.$(OBJEXT): $(hdrdir)/ruby/version.h
load.$(OBJEXT): $(top_srcdir)/internal/array.h
load.$(OBJEXT): $(top_srcdir)/internal/basic_operators.h
+load.$(OBJEXT): $(top_srcdir)/internal/bits.h
load.$(OBJEXT): $(top_srcdir)/internal/compilers.h
load.$(OBJEXT): $(top_srcdir)/internal/dir.h
load.$(OBJEXT): $(top_srcdir)/internal/error.h
load.$(OBJEXT): $(top_srcdir)/internal/file.h
load.$(OBJEXT): $(top_srcdir)/internal/gc.h
+load.$(OBJEXT): $(top_srcdir)/internal/hash.h
load.$(OBJEXT): $(top_srcdir)/internal/imemo.h
load.$(OBJEXT): $(top_srcdir)/internal/load.h
load.$(OBJEXT): $(top_srcdir)/internal/parse.h
+load.$(OBJEXT): $(top_srcdir)/internal/ruby_parser.h
load.$(OBJEXT): $(top_srcdir)/internal/serial.h
load.$(OBJEXT): $(top_srcdir)/internal/static_assert.h
load.$(OBJEXT): $(top_srcdir)/internal/string.h
@@ -8218,6 +8733,27 @@ load.$(OBJEXT): $(top_srcdir)/internal/thread.h
load.$(OBJEXT): $(top_srcdir)/internal/variable.h
load.$(OBJEXT): $(top_srcdir)/internal/vm.h
load.$(OBJEXT): $(top_srcdir)/internal/warnings.h
+load.$(OBJEXT): $(top_srcdir)/prism/defines.h
+load.$(OBJEXT): $(top_srcdir)/prism/diagnostic.h
+load.$(OBJEXT): $(top_srcdir)/prism/encoding.h
+load.$(OBJEXT): $(top_srcdir)/prism/node.h
+load.$(OBJEXT): $(top_srcdir)/prism/options.h
+load.$(OBJEXT): $(top_srcdir)/prism/pack.h
+load.$(OBJEXT): $(top_srcdir)/prism/parser.h
+load.$(OBJEXT): $(top_srcdir)/prism/prettyprint.h
+load.$(OBJEXT): $(top_srcdir)/prism/prism.h
+load.$(OBJEXT): $(top_srcdir)/prism/regexp.h
+load.$(OBJEXT): $(top_srcdir)/prism/util/pm_buffer.h
+load.$(OBJEXT): $(top_srcdir)/prism/util/pm_char.h
+load.$(OBJEXT): $(top_srcdir)/prism/util/pm_constant_pool.h
+load.$(OBJEXT): $(top_srcdir)/prism/util/pm_list.h
+load.$(OBJEXT): $(top_srcdir)/prism/util/pm_memchr.h
+load.$(OBJEXT): $(top_srcdir)/prism/util/pm_newline_list.h
+load.$(OBJEXT): $(top_srcdir)/prism/util/pm_state_stack.h
+load.$(OBJEXT): $(top_srcdir)/prism/util/pm_string.h
+load.$(OBJEXT): $(top_srcdir)/prism/util/pm_string_list.h
+load.$(OBJEXT): $(top_srcdir)/prism/util/pm_strncasecmp.h
+load.$(OBJEXT): $(top_srcdir)/prism/util/pm_strpbrk.h
load.$(OBJEXT): {$(VPATH)}assert.h
load.$(OBJEXT): {$(VPATH)}atomic.h
load.$(OBJEXT): {$(VPATH)}backward/2/assume.h
@@ -8278,6 +8814,7 @@ load.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
load.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
load.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
load.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
+load.$(OBJEXT): {$(VPATH)}internal/attr/packed_struct.h
load.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
load.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
load.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
@@ -8346,7 +8883,6 @@ load.$(OBJEXT): {$(VPATH)}internal/intern/enumerator.h
load.$(OBJEXT): {$(VPATH)}internal/intern/error.h
load.$(OBJEXT): {$(VPATH)}internal/intern/eval.h
load.$(OBJEXT): {$(VPATH)}internal/intern/file.h
-load.$(OBJEXT): {$(VPATH)}internal/intern/gc.h
load.$(OBJEXT): {$(VPATH)}internal/intern/hash.h
load.$(OBJEXT): {$(VPATH)}internal/intern/io.h
load.$(OBJEXT): {$(VPATH)}internal/intern/load.h
@@ -8377,7 +8913,6 @@ load.$(OBJEXT): {$(VPATH)}internal/memory.h
load.$(OBJEXT): {$(VPATH)}internal/method.h
load.$(OBJEXT): {$(VPATH)}internal/module.h
load.$(OBJEXT): {$(VPATH)}internal/newobj.h
-load.$(OBJEXT): {$(VPATH)}internal/rgengc.h
load.$(OBJEXT): {$(VPATH)}internal/scan_args.h
load.$(OBJEXT): {$(VPATH)}internal/special_consts.h
load.$(OBJEXT): {$(VPATH)}internal/static_assert.h
@@ -8396,10 +8931,14 @@ load.$(OBJEXT): {$(VPATH)}missing.h
load.$(OBJEXT): {$(VPATH)}node.h
load.$(OBJEXT): {$(VPATH)}onigmo.h
load.$(OBJEXT): {$(VPATH)}oniguruma.h
+load.$(OBJEXT): {$(VPATH)}prism/ast.h
+load.$(OBJEXT): {$(VPATH)}prism/version.h
+load.$(OBJEXT): {$(VPATH)}prism_compile.h
load.$(OBJEXT): {$(VPATH)}probes.dmyh
load.$(OBJEXT): {$(VPATH)}probes.h
load.$(OBJEXT): {$(VPATH)}ruby_assert.h
load.$(OBJEXT): {$(VPATH)}ruby_atomic.h
+load.$(OBJEXT): {$(VPATH)}rubyparser.h
load.$(OBJEXT): {$(VPATH)}shape.h
load.$(OBJEXT): {$(VPATH)}st.h
load.$(OBJEXT): {$(VPATH)}subst.h
@@ -8461,6 +9000,7 @@ loadpath.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
loadpath.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
loadpath.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
loadpath.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
+loadpath.$(OBJEXT): {$(VPATH)}internal/attr/packed_struct.h
loadpath.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
loadpath.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
loadpath.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
@@ -8520,7 +9060,6 @@ loadpath.$(OBJEXT): {$(VPATH)}internal/intern/enumerator.h
loadpath.$(OBJEXT): {$(VPATH)}internal/intern/error.h
loadpath.$(OBJEXT): {$(VPATH)}internal/intern/eval.h
loadpath.$(OBJEXT): {$(VPATH)}internal/intern/file.h
-loadpath.$(OBJEXT): {$(VPATH)}internal/intern/gc.h
loadpath.$(OBJEXT): {$(VPATH)}internal/intern/hash.h
loadpath.$(OBJEXT): {$(VPATH)}internal/intern/io.h
loadpath.$(OBJEXT): {$(VPATH)}internal/intern/load.h
@@ -8551,7 +9090,6 @@ loadpath.$(OBJEXT): {$(VPATH)}internal/memory.h
loadpath.$(OBJEXT): {$(VPATH)}internal/method.h
loadpath.$(OBJEXT): {$(VPATH)}internal/module.h
loadpath.$(OBJEXT): {$(VPATH)}internal/newobj.h
-loadpath.$(OBJEXT): {$(VPATH)}internal/rgengc.h
loadpath.$(OBJEXT): {$(VPATH)}internal/scan_args.h
loadpath.$(OBJEXT): {$(VPATH)}internal/special_consts.h
loadpath.$(OBJEXT): {$(VPATH)}internal/static_assert.h
@@ -8622,6 +9160,7 @@ localeinit.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
localeinit.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
localeinit.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
localeinit.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
+localeinit.$(OBJEXT): {$(VPATH)}internal/attr/packed_struct.h
localeinit.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
localeinit.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
localeinit.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
@@ -8690,7 +9229,6 @@ localeinit.$(OBJEXT): {$(VPATH)}internal/intern/enumerator.h
localeinit.$(OBJEXT): {$(VPATH)}internal/intern/error.h
localeinit.$(OBJEXT): {$(VPATH)}internal/intern/eval.h
localeinit.$(OBJEXT): {$(VPATH)}internal/intern/file.h
-localeinit.$(OBJEXT): {$(VPATH)}internal/intern/gc.h
localeinit.$(OBJEXT): {$(VPATH)}internal/intern/hash.h
localeinit.$(OBJEXT): {$(VPATH)}internal/intern/io.h
localeinit.$(OBJEXT): {$(VPATH)}internal/intern/load.h
@@ -8721,7 +9259,6 @@ localeinit.$(OBJEXT): {$(VPATH)}internal/memory.h
localeinit.$(OBJEXT): {$(VPATH)}internal/method.h
localeinit.$(OBJEXT): {$(VPATH)}internal/module.h
localeinit.$(OBJEXT): {$(VPATH)}internal/newobj.h
-localeinit.$(OBJEXT): {$(VPATH)}internal/rgengc.h
localeinit.$(OBJEXT): {$(VPATH)}internal/scan_args.h
localeinit.$(OBJEXT): {$(VPATH)}internal/special_consts.h
localeinit.$(OBJEXT): {$(VPATH)}internal/static_assert.h
@@ -8792,6 +9329,7 @@ main.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
main.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
main.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
main.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
+main.$(OBJEXT): {$(VPATH)}internal/attr/packed_struct.h
main.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
main.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
main.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
@@ -8851,7 +9389,6 @@ main.$(OBJEXT): {$(VPATH)}internal/intern/enumerator.h
main.$(OBJEXT): {$(VPATH)}internal/intern/error.h
main.$(OBJEXT): {$(VPATH)}internal/intern/eval.h
main.$(OBJEXT): {$(VPATH)}internal/intern/file.h
-main.$(OBJEXT): {$(VPATH)}internal/intern/gc.h
main.$(OBJEXT): {$(VPATH)}internal/intern/hash.h
main.$(OBJEXT): {$(VPATH)}internal/intern/io.h
main.$(OBJEXT): {$(VPATH)}internal/intern/load.h
@@ -8882,7 +9419,6 @@ main.$(OBJEXT): {$(VPATH)}internal/memory.h
main.$(OBJEXT): {$(VPATH)}internal/method.h
main.$(OBJEXT): {$(VPATH)}internal/module.h
main.$(OBJEXT): {$(VPATH)}internal/newobj.h
-main.$(OBJEXT): {$(VPATH)}internal/rgengc.h
main.$(OBJEXT): {$(VPATH)}internal/scan_args.h
main.$(OBJEXT): {$(VPATH)}internal/special_consts.h
main.$(OBJEXT): {$(VPATH)}internal/static_assert.h
@@ -8899,8 +9435,14 @@ main.$(OBJEXT): {$(VPATH)}missing.h
main.$(OBJEXT): {$(VPATH)}st.h
main.$(OBJEXT): {$(VPATH)}subst.h
main.$(OBJEXT): {$(VPATH)}vm_debug.h
+marshal.$(OBJEXT): $(CCAN_DIR)/check_type/check_type.h
+marshal.$(OBJEXT): $(CCAN_DIR)/container_of/container_of.h
+marshal.$(OBJEXT): $(CCAN_DIR)/list/list.h
+marshal.$(OBJEXT): $(CCAN_DIR)/str/str.h
marshal.$(OBJEXT): $(hdrdir)/ruby/ruby.h
+marshal.$(OBJEXT): $(hdrdir)/ruby/version.h
marshal.$(OBJEXT): $(top_srcdir)/internal/array.h
+marshal.$(OBJEXT): $(top_srcdir)/internal/basic_operators.h
marshal.$(OBJEXT): $(top_srcdir)/internal/bignum.h
marshal.$(OBJEXT): $(top_srcdir)/internal/bits.h
marshal.$(OBJEXT): $(top_srcdir)/internal/class.h
@@ -8910,6 +9452,7 @@ marshal.$(OBJEXT): $(top_srcdir)/internal/error.h
marshal.$(OBJEXT): $(top_srcdir)/internal/fixnum.h
marshal.$(OBJEXT): $(top_srcdir)/internal/gc.h
marshal.$(OBJEXT): $(top_srcdir)/internal/hash.h
+marshal.$(OBJEXT): $(top_srcdir)/internal/imemo.h
marshal.$(OBJEXT): $(top_srcdir)/internal/numeric.h
marshal.$(OBJEXT): $(top_srcdir)/internal/object.h
marshal.$(OBJEXT): $(top_srcdir)/internal/serial.h
@@ -8922,6 +9465,7 @@ marshal.$(OBJEXT): $(top_srcdir)/internal/variable.h
marshal.$(OBJEXT): $(top_srcdir)/internal/vm.h
marshal.$(OBJEXT): $(top_srcdir)/internal/warnings.h
marshal.$(OBJEXT): {$(VPATH)}assert.h
+marshal.$(OBJEXT): {$(VPATH)}atomic.h
marshal.$(OBJEXT): {$(VPATH)}backward/2/assume.h
marshal.$(OBJEXT): {$(VPATH)}backward/2/attributes.h
marshal.$(OBJEXT): {$(VPATH)}backward/2/bool.h
@@ -8934,9 +9478,11 @@ marshal.$(OBJEXT): {$(VPATH)}backward/2/stdarg.h
marshal.$(OBJEXT): {$(VPATH)}builtin.h
marshal.$(OBJEXT): {$(VPATH)}config.h
marshal.$(OBJEXT): {$(VPATH)}constant.h
+marshal.$(OBJEXT): {$(VPATH)}debug_counter.h
marshal.$(OBJEXT): {$(VPATH)}defines.h
marshal.$(OBJEXT): {$(VPATH)}encindex.h
marshal.$(OBJEXT): {$(VPATH)}encoding.h
+marshal.$(OBJEXT): {$(VPATH)}id.h
marshal.$(OBJEXT): {$(VPATH)}id_table.h
marshal.$(OBJEXT): {$(VPATH)}intern.h
marshal.$(OBJEXT): {$(VPATH)}internal.h
@@ -8978,6 +9524,7 @@ marshal.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
marshal.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
marshal.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
marshal.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
+marshal.$(OBJEXT): {$(VPATH)}internal/attr/packed_struct.h
marshal.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
marshal.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
marshal.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
@@ -9046,7 +9593,6 @@ marshal.$(OBJEXT): {$(VPATH)}internal/intern/enumerator.h
marshal.$(OBJEXT): {$(VPATH)}internal/intern/error.h
marshal.$(OBJEXT): {$(VPATH)}internal/intern/eval.h
marshal.$(OBJEXT): {$(VPATH)}internal/intern/file.h
-marshal.$(OBJEXT): {$(VPATH)}internal/intern/gc.h
marshal.$(OBJEXT): {$(VPATH)}internal/intern/hash.h
marshal.$(OBJEXT): {$(VPATH)}internal/intern/io.h
marshal.$(OBJEXT): {$(VPATH)}internal/intern/load.h
@@ -9077,7 +9623,6 @@ marshal.$(OBJEXT): {$(VPATH)}internal/memory.h
marshal.$(OBJEXT): {$(VPATH)}internal/method.h
marshal.$(OBJEXT): {$(VPATH)}internal/module.h
marshal.$(OBJEXT): {$(VPATH)}internal/newobj.h
-marshal.$(OBJEXT): {$(VPATH)}internal/rgengc.h
marshal.$(OBJEXT): {$(VPATH)}internal/scan_args.h
marshal.$(OBJEXT): {$(VPATH)}internal/special_consts.h
marshal.$(OBJEXT): {$(VPATH)}internal/static_assert.h
@@ -9092,13 +9637,24 @@ marshal.$(OBJEXT): {$(VPATH)}internal/xmalloc.h
marshal.$(OBJEXT): {$(VPATH)}io.h
marshal.$(OBJEXT): {$(VPATH)}marshal.c
marshal.$(OBJEXT): {$(VPATH)}marshal.rbinc
+marshal.$(OBJEXT): {$(VPATH)}method.h
marshal.$(OBJEXT): {$(VPATH)}missing.h
+marshal.$(OBJEXT): {$(VPATH)}node.h
marshal.$(OBJEXT): {$(VPATH)}onigmo.h
marshal.$(OBJEXT): {$(VPATH)}oniguruma.h
+marshal.$(OBJEXT): {$(VPATH)}ruby_assert.h
+marshal.$(OBJEXT): {$(VPATH)}ruby_atomic.h
+marshal.$(OBJEXT): {$(VPATH)}rubyparser.h
marshal.$(OBJEXT): {$(VPATH)}shape.h
marshal.$(OBJEXT): {$(VPATH)}st.h
marshal.$(OBJEXT): {$(VPATH)}subst.h
+marshal.$(OBJEXT): {$(VPATH)}thread_$(THREAD_MODEL).h
+marshal.$(OBJEXT): {$(VPATH)}thread_native.h
marshal.$(OBJEXT): {$(VPATH)}util.h
+marshal.$(OBJEXT): {$(VPATH)}vm_core.h
+marshal.$(OBJEXT): {$(VPATH)}vm_debug.h
+marshal.$(OBJEXT): {$(VPATH)}vm_opts.h
+marshal.$(OBJEXT): {$(VPATH)}vm_sync.h
math.$(OBJEXT): $(hdrdir)/ruby/ruby.h
math.$(OBJEXT): $(top_srcdir)/internal/bignum.h
math.$(OBJEXT): $(top_srcdir)/internal/class.h
@@ -9166,6 +9722,7 @@ math.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
math.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
math.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
math.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
+math.$(OBJEXT): {$(VPATH)}internal/attr/packed_struct.h
math.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
math.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
math.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
@@ -9225,7 +9782,6 @@ math.$(OBJEXT): {$(VPATH)}internal/intern/enumerator.h
math.$(OBJEXT): {$(VPATH)}internal/intern/error.h
math.$(OBJEXT): {$(VPATH)}internal/intern/eval.h
math.$(OBJEXT): {$(VPATH)}internal/intern/file.h
-math.$(OBJEXT): {$(VPATH)}internal/intern/gc.h
math.$(OBJEXT): {$(VPATH)}internal/intern/hash.h
math.$(OBJEXT): {$(VPATH)}internal/intern/io.h
math.$(OBJEXT): {$(VPATH)}internal/intern/load.h
@@ -9256,7 +9812,6 @@ math.$(OBJEXT): {$(VPATH)}internal/memory.h
math.$(OBJEXT): {$(VPATH)}internal/method.h
math.$(OBJEXT): {$(VPATH)}internal/module.h
math.$(OBJEXT): {$(VPATH)}internal/newobj.h
-math.$(OBJEXT): {$(VPATH)}internal/rgengc.h
math.$(OBJEXT): {$(VPATH)}internal/scan_args.h
math.$(OBJEXT): {$(VPATH)}internal/special_consts.h
math.$(OBJEXT): {$(VPATH)}internal/static_assert.h
@@ -9273,13 +9828,24 @@ math.$(OBJEXT): {$(VPATH)}missing.h
math.$(OBJEXT): {$(VPATH)}shape.h
math.$(OBJEXT): {$(VPATH)}st.h
math.$(OBJEXT): {$(VPATH)}subst.h
+memory_view.$(OBJEXT): $(CCAN_DIR)/check_type/check_type.h
+memory_view.$(OBJEXT): $(CCAN_DIR)/container_of/container_of.h
+memory_view.$(OBJEXT): $(CCAN_DIR)/list/list.h
+memory_view.$(OBJEXT): $(CCAN_DIR)/str/str.h
memory_view.$(OBJEXT): $(hdrdir)/ruby/ruby.h
+memory_view.$(OBJEXT): $(top_srcdir)/internal/array.h
+memory_view.$(OBJEXT): $(top_srcdir)/internal/basic_operators.h
memory_view.$(OBJEXT): $(top_srcdir)/internal/compilers.h
memory_view.$(OBJEXT): $(top_srcdir)/internal/gc.h
memory_view.$(OBJEXT): $(top_srcdir)/internal/hash.h
+memory_view.$(OBJEXT): $(top_srcdir)/internal/imemo.h
+memory_view.$(OBJEXT): $(top_srcdir)/internal/serial.h
+memory_view.$(OBJEXT): $(top_srcdir)/internal/static_assert.h
memory_view.$(OBJEXT): $(top_srcdir)/internal/variable.h
+memory_view.$(OBJEXT): $(top_srcdir)/internal/vm.h
memory_view.$(OBJEXT): $(top_srcdir)/internal/warnings.h
memory_view.$(OBJEXT): {$(VPATH)}assert.h
+memory_view.$(OBJEXT): {$(VPATH)}atomic.h
memory_view.$(OBJEXT): {$(VPATH)}backward/2/assume.h
memory_view.$(OBJEXT): {$(VPATH)}backward/2/attributes.h
memory_view.$(OBJEXT): {$(VPATH)}backward/2/bool.h
@@ -9293,6 +9859,8 @@ memory_view.$(OBJEXT): {$(VPATH)}config.h
memory_view.$(OBJEXT): {$(VPATH)}constant.h
memory_view.$(OBJEXT): {$(VPATH)}debug_counter.h
memory_view.$(OBJEXT): {$(VPATH)}defines.h
+memory_view.$(OBJEXT): {$(VPATH)}encoding.h
+memory_view.$(OBJEXT): {$(VPATH)}id.h
memory_view.$(OBJEXT): {$(VPATH)}id_table.h
memory_view.$(OBJEXT): {$(VPATH)}intern.h
memory_view.$(OBJEXT): {$(VPATH)}internal.h
@@ -9334,6 +9902,7 @@ memory_view.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
memory_view.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
memory_view.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
memory_view.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
+memory_view.$(OBJEXT): {$(VPATH)}internal/attr/packed_struct.h
memory_view.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
memory_view.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
memory_view.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
@@ -9366,6 +9935,15 @@ memory_view.$(OBJEXT): {$(VPATH)}internal/core/rtypeddata.h
memory_view.$(OBJEXT): {$(VPATH)}internal/ctype.h
memory_view.$(OBJEXT): {$(VPATH)}internal/dllexport.h
memory_view.$(OBJEXT): {$(VPATH)}internal/dosish.h
+memory_view.$(OBJEXT): {$(VPATH)}internal/encoding/coderange.h
+memory_view.$(OBJEXT): {$(VPATH)}internal/encoding/ctype.h
+memory_view.$(OBJEXT): {$(VPATH)}internal/encoding/encoding.h
+memory_view.$(OBJEXT): {$(VPATH)}internal/encoding/pathname.h
+memory_view.$(OBJEXT): {$(VPATH)}internal/encoding/re.h
+memory_view.$(OBJEXT): {$(VPATH)}internal/encoding/sprintf.h
+memory_view.$(OBJEXT): {$(VPATH)}internal/encoding/string.h
+memory_view.$(OBJEXT): {$(VPATH)}internal/encoding/symbol.h
+memory_view.$(OBJEXT): {$(VPATH)}internal/encoding/transcode.h
memory_view.$(OBJEXT): {$(VPATH)}internal/error.h
memory_view.$(OBJEXT): {$(VPATH)}internal/eval.h
memory_view.$(OBJEXT): {$(VPATH)}internal/event.h
@@ -9393,7 +9971,6 @@ memory_view.$(OBJEXT): {$(VPATH)}internal/intern/enumerator.h
memory_view.$(OBJEXT): {$(VPATH)}internal/intern/error.h
memory_view.$(OBJEXT): {$(VPATH)}internal/intern/eval.h
memory_view.$(OBJEXT): {$(VPATH)}internal/intern/file.h
-memory_view.$(OBJEXT): {$(VPATH)}internal/intern/gc.h
memory_view.$(OBJEXT): {$(VPATH)}internal/intern/hash.h
memory_view.$(OBJEXT): {$(VPATH)}internal/intern/io.h
memory_view.$(OBJEXT): {$(VPATH)}internal/intern/load.h
@@ -9424,7 +10001,6 @@ memory_view.$(OBJEXT): {$(VPATH)}internal/memory.h
memory_view.$(OBJEXT): {$(VPATH)}internal/method.h
memory_view.$(OBJEXT): {$(VPATH)}internal/module.h
memory_view.$(OBJEXT): {$(VPATH)}internal/newobj.h
-memory_view.$(OBJEXT): {$(VPATH)}internal/rgengc.h
memory_view.$(OBJEXT): {$(VPATH)}internal/scan_args.h
memory_view.$(OBJEXT): {$(VPATH)}internal/special_consts.h
memory_view.$(OBJEXT): {$(VPATH)}internal/static_assert.h
@@ -9438,29 +10014,62 @@ memory_view.$(OBJEXT): {$(VPATH)}internal/warning_push.h
memory_view.$(OBJEXT): {$(VPATH)}internal/xmalloc.h
memory_view.$(OBJEXT): {$(VPATH)}memory_view.c
memory_view.$(OBJEXT): {$(VPATH)}memory_view.h
+memory_view.$(OBJEXT): {$(VPATH)}method.h
memory_view.$(OBJEXT): {$(VPATH)}missing.h
+memory_view.$(OBJEXT): {$(VPATH)}node.h
+memory_view.$(OBJEXT): {$(VPATH)}onigmo.h
+memory_view.$(OBJEXT): {$(VPATH)}oniguruma.h
+memory_view.$(OBJEXT): {$(VPATH)}ruby_assert.h
+memory_view.$(OBJEXT): {$(VPATH)}ruby_atomic.h
+memory_view.$(OBJEXT): {$(VPATH)}rubyparser.h
memory_view.$(OBJEXT): {$(VPATH)}shape.h
memory_view.$(OBJEXT): {$(VPATH)}st.h
memory_view.$(OBJEXT): {$(VPATH)}subst.h
+memory_view.$(OBJEXT): {$(VPATH)}thread_$(THREAD_MODEL).h
+memory_view.$(OBJEXT): {$(VPATH)}thread_native.h
memory_view.$(OBJEXT): {$(VPATH)}util.h
+memory_view.$(OBJEXT): {$(VPATH)}vm_core.h
memory_view.$(OBJEXT): {$(VPATH)}vm_debug.h
+memory_view.$(OBJEXT): {$(VPATH)}vm_opts.h
memory_view.$(OBJEXT): {$(VPATH)}vm_sync.h
miniinit.$(OBJEXT): $(CCAN_DIR)/check_type/check_type.h
miniinit.$(OBJEXT): $(CCAN_DIR)/container_of/container_of.h
miniinit.$(OBJEXT): $(CCAN_DIR)/list/list.h
miniinit.$(OBJEXT): $(CCAN_DIR)/str/str.h
miniinit.$(OBJEXT): $(hdrdir)/ruby/ruby.h
-miniinit.$(OBJEXT): $(srcdir)/mjit_c.rb
+miniinit.$(OBJEXT): $(srcdir)/rjit_c.rb
miniinit.$(OBJEXT): $(top_srcdir)/internal/array.h
miniinit.$(OBJEXT): $(top_srcdir)/internal/basic_operators.h
miniinit.$(OBJEXT): $(top_srcdir)/internal/compilers.h
miniinit.$(OBJEXT): $(top_srcdir)/internal/gc.h
miniinit.$(OBJEXT): $(top_srcdir)/internal/imemo.h
+miniinit.$(OBJEXT): $(top_srcdir)/internal/ruby_parser.h
miniinit.$(OBJEXT): $(top_srcdir)/internal/serial.h
miniinit.$(OBJEXT): $(top_srcdir)/internal/static_assert.h
miniinit.$(OBJEXT): $(top_srcdir)/internal/variable.h
miniinit.$(OBJEXT): $(top_srcdir)/internal/vm.h
miniinit.$(OBJEXT): $(top_srcdir)/internal/warnings.h
+miniinit.$(OBJEXT): $(top_srcdir)/prism/defines.h
+miniinit.$(OBJEXT): $(top_srcdir)/prism/diagnostic.h
+miniinit.$(OBJEXT): $(top_srcdir)/prism/encoding.h
+miniinit.$(OBJEXT): $(top_srcdir)/prism/node.h
+miniinit.$(OBJEXT): $(top_srcdir)/prism/options.h
+miniinit.$(OBJEXT): $(top_srcdir)/prism/pack.h
+miniinit.$(OBJEXT): $(top_srcdir)/prism/parser.h
+miniinit.$(OBJEXT): $(top_srcdir)/prism/prettyprint.h
+miniinit.$(OBJEXT): $(top_srcdir)/prism/prism.h
+miniinit.$(OBJEXT): $(top_srcdir)/prism/regexp.h
+miniinit.$(OBJEXT): $(top_srcdir)/prism/util/pm_buffer.h
+miniinit.$(OBJEXT): $(top_srcdir)/prism/util/pm_char.h
+miniinit.$(OBJEXT): $(top_srcdir)/prism/util/pm_constant_pool.h
+miniinit.$(OBJEXT): $(top_srcdir)/prism/util/pm_list.h
+miniinit.$(OBJEXT): $(top_srcdir)/prism/util/pm_memchr.h
+miniinit.$(OBJEXT): $(top_srcdir)/prism/util/pm_newline_list.h
+miniinit.$(OBJEXT): $(top_srcdir)/prism/util/pm_state_stack.h
+miniinit.$(OBJEXT): $(top_srcdir)/prism/util/pm_string.h
+miniinit.$(OBJEXT): $(top_srcdir)/prism/util/pm_string_list.h
+miniinit.$(OBJEXT): $(top_srcdir)/prism/util/pm_strncasecmp.h
+miniinit.$(OBJEXT): $(top_srcdir)/prism/util/pm_strpbrk.h
miniinit.$(OBJEXT): {$(VPATH)}array.rb
miniinit.$(OBJEXT): {$(VPATH)}assert.h
miniinit.$(OBJEXT): {$(VPATH)}ast.rb
@@ -9524,6 +10133,7 @@ miniinit.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
miniinit.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
miniinit.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
miniinit.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
+miniinit.$(OBJEXT): {$(VPATH)}internal/attr/packed_struct.h
miniinit.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
miniinit.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
miniinit.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
@@ -9592,7 +10202,6 @@ miniinit.$(OBJEXT): {$(VPATH)}internal/intern/enumerator.h
miniinit.$(OBJEXT): {$(VPATH)}internal/intern/error.h
miniinit.$(OBJEXT): {$(VPATH)}internal/intern/eval.h
miniinit.$(OBJEXT): {$(VPATH)}internal/intern/file.h
-miniinit.$(OBJEXT): {$(VPATH)}internal/intern/gc.h
miniinit.$(OBJEXT): {$(VPATH)}internal/intern/hash.h
miniinit.$(OBJEXT): {$(VPATH)}internal/intern/io.h
miniinit.$(OBJEXT): {$(VPATH)}internal/intern/load.h
@@ -9623,7 +10232,6 @@ miniinit.$(OBJEXT): {$(VPATH)}internal/memory.h
miniinit.$(OBJEXT): {$(VPATH)}internal/method.h
miniinit.$(OBJEXT): {$(VPATH)}internal/module.h
miniinit.$(OBJEXT): {$(VPATH)}internal/newobj.h
-miniinit.$(OBJEXT): {$(VPATH)}internal/rgengc.h
miniinit.$(OBJEXT): {$(VPATH)}internal/scan_args.h
miniinit.$(OBJEXT): {$(VPATH)}internal/special_consts.h
miniinit.$(OBJEXT): {$(VPATH)}internal/static_assert.h
@@ -9644,8 +10252,6 @@ miniinit.$(OBJEXT): {$(VPATH)}mini_builtin.c
miniinit.$(OBJEXT): {$(VPATH)}miniinit.c
miniinit.$(OBJEXT): {$(VPATH)}miniprelude.c
miniinit.$(OBJEXT): {$(VPATH)}missing.h
-miniinit.$(OBJEXT): {$(VPATH)}mjit.rb
-miniinit.$(OBJEXT): {$(VPATH)}mjit_c.rb
miniinit.$(OBJEXT): {$(VPATH)}nilclass.rb
miniinit.$(OBJEXT): {$(VPATH)}node.h
miniinit.$(OBJEXT): {$(VPATH)}numeric.rb
@@ -9653,9 +10259,15 @@ miniinit.$(OBJEXT): {$(VPATH)}onigmo.h
miniinit.$(OBJEXT): {$(VPATH)}oniguruma.h
miniinit.$(OBJEXT): {$(VPATH)}pack.rb
miniinit.$(OBJEXT): {$(VPATH)}prelude.rb
+miniinit.$(OBJEXT): {$(VPATH)}prism/ast.h
+miniinit.$(OBJEXT): {$(VPATH)}prism/version.h
+miniinit.$(OBJEXT): {$(VPATH)}prism_compile.h
miniinit.$(OBJEXT): {$(VPATH)}ractor.rb
+miniinit.$(OBJEXT): {$(VPATH)}rjit.rb
+miniinit.$(OBJEXT): {$(VPATH)}rjit_c.rb
miniinit.$(OBJEXT): {$(VPATH)}ruby_assert.h
miniinit.$(OBJEXT): {$(VPATH)}ruby_atomic.h
+miniinit.$(OBJEXT): {$(VPATH)}rubyparser.h
miniinit.$(OBJEXT): {$(VPATH)}shape.h
miniinit.$(OBJEXT): {$(VPATH)}st.h
miniinit.$(OBJEXT): {$(VPATH)}subst.h
@@ -9669,441 +10281,6 @@ miniinit.$(OBJEXT): {$(VPATH)}vm_core.h
miniinit.$(OBJEXT): {$(VPATH)}vm_opts.h
miniinit.$(OBJEXT): {$(VPATH)}warning.rb
miniinit.$(OBJEXT): {$(VPATH)}yjit.rb
-mjit.$(OBJEXT): $(CCAN_DIR)/check_type/check_type.h
-mjit.$(OBJEXT): $(CCAN_DIR)/container_of/container_of.h
-mjit.$(OBJEXT): $(CCAN_DIR)/list/list.h
-mjit.$(OBJEXT): $(CCAN_DIR)/str/str.h
-mjit.$(OBJEXT): $(hdrdir)/ruby.h
-mjit.$(OBJEXT): $(hdrdir)/ruby/ruby.h
-mjit.$(OBJEXT): $(hdrdir)/ruby/version.h
-mjit.$(OBJEXT): $(top_srcdir)/internal/array.h
-mjit.$(OBJEXT): $(top_srcdir)/internal/basic_operators.h
-mjit.$(OBJEXT): $(top_srcdir)/internal/class.h
-mjit.$(OBJEXT): $(top_srcdir)/internal/cmdlineopt.h
-mjit.$(OBJEXT): $(top_srcdir)/internal/compile.h
-mjit.$(OBJEXT): $(top_srcdir)/internal/compilers.h
-mjit.$(OBJEXT): $(top_srcdir)/internal/cont.h
-mjit.$(OBJEXT): $(top_srcdir)/internal/file.h
-mjit.$(OBJEXT): $(top_srcdir)/internal/gc.h
-mjit.$(OBJEXT): $(top_srcdir)/internal/hash.h
-mjit.$(OBJEXT): $(top_srcdir)/internal/imemo.h
-mjit.$(OBJEXT): $(top_srcdir)/internal/process.h
-mjit.$(OBJEXT): $(top_srcdir)/internal/serial.h
-mjit.$(OBJEXT): $(top_srcdir)/internal/static_assert.h
-mjit.$(OBJEXT): $(top_srcdir)/internal/variable.h
-mjit.$(OBJEXT): $(top_srcdir)/internal/vm.h
-mjit.$(OBJEXT): $(top_srcdir)/internal/warnings.h
-mjit.$(OBJEXT): {$(VPATH)}assert.h
-mjit.$(OBJEXT): {$(VPATH)}atomic.h
-mjit.$(OBJEXT): {$(VPATH)}backward/2/assume.h
-mjit.$(OBJEXT): {$(VPATH)}backward/2/attributes.h
-mjit.$(OBJEXT): {$(VPATH)}backward/2/bool.h
-mjit.$(OBJEXT): {$(VPATH)}backward/2/gcc_version_since.h
-mjit.$(OBJEXT): {$(VPATH)}backward/2/inttypes.h
-mjit.$(OBJEXT): {$(VPATH)}backward/2/limits.h
-mjit.$(OBJEXT): {$(VPATH)}backward/2/long_long.h
-mjit.$(OBJEXT): {$(VPATH)}backward/2/stdalign.h
-mjit.$(OBJEXT): {$(VPATH)}backward/2/stdarg.h
-mjit.$(OBJEXT): {$(VPATH)}builtin.h
-mjit.$(OBJEXT): {$(VPATH)}config.h
-mjit.$(OBJEXT): {$(VPATH)}constant.h
-mjit.$(OBJEXT): {$(VPATH)}debug.h
-mjit.$(OBJEXT): {$(VPATH)}debug_counter.h
-mjit.$(OBJEXT): {$(VPATH)}defines.h
-mjit.$(OBJEXT): {$(VPATH)}dln.h
-mjit.$(OBJEXT): {$(VPATH)}encoding.h
-mjit.$(OBJEXT): {$(VPATH)}gc.h
-mjit.$(OBJEXT): {$(VPATH)}id.h
-mjit.$(OBJEXT): {$(VPATH)}id_table.h
-mjit.$(OBJEXT): {$(VPATH)}insns.def
-mjit.$(OBJEXT): {$(VPATH)}insns.inc
-mjit.$(OBJEXT): {$(VPATH)}insns_info.inc
-mjit.$(OBJEXT): {$(VPATH)}intern.h
-mjit.$(OBJEXT): {$(VPATH)}internal.h
-mjit.$(OBJEXT): {$(VPATH)}internal/abi.h
-mjit.$(OBJEXT): {$(VPATH)}internal/anyargs.h
-mjit.$(OBJEXT): {$(VPATH)}internal/arithmetic.h
-mjit.$(OBJEXT): {$(VPATH)}internal/arithmetic/char.h
-mjit.$(OBJEXT): {$(VPATH)}internal/arithmetic/double.h
-mjit.$(OBJEXT): {$(VPATH)}internal/arithmetic/fixnum.h
-mjit.$(OBJEXT): {$(VPATH)}internal/arithmetic/gid_t.h
-mjit.$(OBJEXT): {$(VPATH)}internal/arithmetic/int.h
-mjit.$(OBJEXT): {$(VPATH)}internal/arithmetic/intptr_t.h
-mjit.$(OBJEXT): {$(VPATH)}internal/arithmetic/long.h
-mjit.$(OBJEXT): {$(VPATH)}internal/arithmetic/long_long.h
-mjit.$(OBJEXT): {$(VPATH)}internal/arithmetic/mode_t.h
-mjit.$(OBJEXT): {$(VPATH)}internal/arithmetic/off_t.h
-mjit.$(OBJEXT): {$(VPATH)}internal/arithmetic/pid_t.h
-mjit.$(OBJEXT): {$(VPATH)}internal/arithmetic/short.h
-mjit.$(OBJEXT): {$(VPATH)}internal/arithmetic/size_t.h
-mjit.$(OBJEXT): {$(VPATH)}internal/arithmetic/st_data_t.h
-mjit.$(OBJEXT): {$(VPATH)}internal/arithmetic/uid_t.h
-mjit.$(OBJEXT): {$(VPATH)}internal/assume.h
-mjit.$(OBJEXT): {$(VPATH)}internal/attr/alloc_size.h
-mjit.$(OBJEXT): {$(VPATH)}internal/attr/artificial.h
-mjit.$(OBJEXT): {$(VPATH)}internal/attr/cold.h
-mjit.$(OBJEXT): {$(VPATH)}internal/attr/const.h
-mjit.$(OBJEXT): {$(VPATH)}internal/attr/constexpr.h
-mjit.$(OBJEXT): {$(VPATH)}internal/attr/deprecated.h
-mjit.$(OBJEXT): {$(VPATH)}internal/attr/diagnose_if.h
-mjit.$(OBJEXT): {$(VPATH)}internal/attr/enum_extensibility.h
-mjit.$(OBJEXT): {$(VPATH)}internal/attr/error.h
-mjit.$(OBJEXT): {$(VPATH)}internal/attr/flag_enum.h
-mjit.$(OBJEXT): {$(VPATH)}internal/attr/forceinline.h
-mjit.$(OBJEXT): {$(VPATH)}internal/attr/format.h
-mjit.$(OBJEXT): {$(VPATH)}internal/attr/maybe_unused.h
-mjit.$(OBJEXT): {$(VPATH)}internal/attr/noalias.h
-mjit.$(OBJEXT): {$(VPATH)}internal/attr/nodiscard.h
-mjit.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
-mjit.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
-mjit.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
-mjit.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
-mjit.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
-mjit.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
-mjit.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
-mjit.$(OBJEXT): {$(VPATH)}internal/attr/warning.h
-mjit.$(OBJEXT): {$(VPATH)}internal/attr/weakref.h
-mjit.$(OBJEXT): {$(VPATH)}internal/cast.h
-mjit.$(OBJEXT): {$(VPATH)}internal/compiler_is.h
-mjit.$(OBJEXT): {$(VPATH)}internal/compiler_is/apple.h
-mjit.$(OBJEXT): {$(VPATH)}internal/compiler_is/clang.h
-mjit.$(OBJEXT): {$(VPATH)}internal/compiler_is/gcc.h
-mjit.$(OBJEXT): {$(VPATH)}internal/compiler_is/intel.h
-mjit.$(OBJEXT): {$(VPATH)}internal/compiler_is/msvc.h
-mjit.$(OBJEXT): {$(VPATH)}internal/compiler_is/sunpro.h
-mjit.$(OBJEXT): {$(VPATH)}internal/compiler_since.h
-mjit.$(OBJEXT): {$(VPATH)}internal/config.h
-mjit.$(OBJEXT): {$(VPATH)}internal/constant_p.h
-mjit.$(OBJEXT): {$(VPATH)}internal/core.h
-mjit.$(OBJEXT): {$(VPATH)}internal/core/rarray.h
-mjit.$(OBJEXT): {$(VPATH)}internal/core/rbasic.h
-mjit.$(OBJEXT): {$(VPATH)}internal/core/rbignum.h
-mjit.$(OBJEXT): {$(VPATH)}internal/core/rclass.h
-mjit.$(OBJEXT): {$(VPATH)}internal/core/rdata.h
-mjit.$(OBJEXT): {$(VPATH)}internal/core/rfile.h
-mjit.$(OBJEXT): {$(VPATH)}internal/core/rhash.h
-mjit.$(OBJEXT): {$(VPATH)}internal/core/robject.h
-mjit.$(OBJEXT): {$(VPATH)}internal/core/rregexp.h
-mjit.$(OBJEXT): {$(VPATH)}internal/core/rstring.h
-mjit.$(OBJEXT): {$(VPATH)}internal/core/rstruct.h
-mjit.$(OBJEXT): {$(VPATH)}internal/core/rtypeddata.h
-mjit.$(OBJEXT): {$(VPATH)}internal/ctype.h
-mjit.$(OBJEXT): {$(VPATH)}internal/dllexport.h
-mjit.$(OBJEXT): {$(VPATH)}internal/dosish.h
-mjit.$(OBJEXT): {$(VPATH)}internal/encoding/coderange.h
-mjit.$(OBJEXT): {$(VPATH)}internal/encoding/ctype.h
-mjit.$(OBJEXT): {$(VPATH)}internal/encoding/encoding.h
-mjit.$(OBJEXT): {$(VPATH)}internal/encoding/pathname.h
-mjit.$(OBJEXT): {$(VPATH)}internal/encoding/re.h
-mjit.$(OBJEXT): {$(VPATH)}internal/encoding/sprintf.h
-mjit.$(OBJEXT): {$(VPATH)}internal/encoding/string.h
-mjit.$(OBJEXT): {$(VPATH)}internal/encoding/symbol.h
-mjit.$(OBJEXT): {$(VPATH)}internal/encoding/transcode.h
-mjit.$(OBJEXT): {$(VPATH)}internal/error.h
-mjit.$(OBJEXT): {$(VPATH)}internal/eval.h
-mjit.$(OBJEXT): {$(VPATH)}internal/event.h
-mjit.$(OBJEXT): {$(VPATH)}internal/fl_type.h
-mjit.$(OBJEXT): {$(VPATH)}internal/gc.h
-mjit.$(OBJEXT): {$(VPATH)}internal/glob.h
-mjit.$(OBJEXT): {$(VPATH)}internal/globals.h
-mjit.$(OBJEXT): {$(VPATH)}internal/has/attribute.h
-mjit.$(OBJEXT): {$(VPATH)}internal/has/builtin.h
-mjit.$(OBJEXT): {$(VPATH)}internal/has/c_attribute.h
-mjit.$(OBJEXT): {$(VPATH)}internal/has/cpp_attribute.h
-mjit.$(OBJEXT): {$(VPATH)}internal/has/declspec_attribute.h
-mjit.$(OBJEXT): {$(VPATH)}internal/has/extension.h
-mjit.$(OBJEXT): {$(VPATH)}internal/has/feature.h
-mjit.$(OBJEXT): {$(VPATH)}internal/has/warning.h
-mjit.$(OBJEXT): {$(VPATH)}internal/intern/array.h
-mjit.$(OBJEXT): {$(VPATH)}internal/intern/bignum.h
-mjit.$(OBJEXT): {$(VPATH)}internal/intern/class.h
-mjit.$(OBJEXT): {$(VPATH)}internal/intern/compar.h
-mjit.$(OBJEXT): {$(VPATH)}internal/intern/complex.h
-mjit.$(OBJEXT): {$(VPATH)}internal/intern/cont.h
-mjit.$(OBJEXT): {$(VPATH)}internal/intern/dir.h
-mjit.$(OBJEXT): {$(VPATH)}internal/intern/enum.h
-mjit.$(OBJEXT): {$(VPATH)}internal/intern/enumerator.h
-mjit.$(OBJEXT): {$(VPATH)}internal/intern/error.h
-mjit.$(OBJEXT): {$(VPATH)}internal/intern/eval.h
-mjit.$(OBJEXT): {$(VPATH)}internal/intern/file.h
-mjit.$(OBJEXT): {$(VPATH)}internal/intern/gc.h
-mjit.$(OBJEXT): {$(VPATH)}internal/intern/hash.h
-mjit.$(OBJEXT): {$(VPATH)}internal/intern/io.h
-mjit.$(OBJEXT): {$(VPATH)}internal/intern/load.h
-mjit.$(OBJEXT): {$(VPATH)}internal/intern/marshal.h
-mjit.$(OBJEXT): {$(VPATH)}internal/intern/numeric.h
-mjit.$(OBJEXT): {$(VPATH)}internal/intern/object.h
-mjit.$(OBJEXT): {$(VPATH)}internal/intern/parse.h
-mjit.$(OBJEXT): {$(VPATH)}internal/intern/proc.h
-mjit.$(OBJEXT): {$(VPATH)}internal/intern/process.h
-mjit.$(OBJEXT): {$(VPATH)}internal/intern/random.h
-mjit.$(OBJEXT): {$(VPATH)}internal/intern/range.h
-mjit.$(OBJEXT): {$(VPATH)}internal/intern/rational.h
-mjit.$(OBJEXT): {$(VPATH)}internal/intern/re.h
-mjit.$(OBJEXT): {$(VPATH)}internal/intern/ruby.h
-mjit.$(OBJEXT): {$(VPATH)}internal/intern/select.h
-mjit.$(OBJEXT): {$(VPATH)}internal/intern/select/largesize.h
-mjit.$(OBJEXT): {$(VPATH)}internal/intern/signal.h
-mjit.$(OBJEXT): {$(VPATH)}internal/intern/sprintf.h
-mjit.$(OBJEXT): {$(VPATH)}internal/intern/string.h
-mjit.$(OBJEXT): {$(VPATH)}internal/intern/struct.h
-mjit.$(OBJEXT): {$(VPATH)}internal/intern/thread.h
-mjit.$(OBJEXT): {$(VPATH)}internal/intern/time.h
-mjit.$(OBJEXT): {$(VPATH)}internal/intern/variable.h
-mjit.$(OBJEXT): {$(VPATH)}internal/intern/vm.h
-mjit.$(OBJEXT): {$(VPATH)}internal/interpreter.h
-mjit.$(OBJEXT): {$(VPATH)}internal/iterator.h
-mjit.$(OBJEXT): {$(VPATH)}internal/memory.h
-mjit.$(OBJEXT): {$(VPATH)}internal/method.h
-mjit.$(OBJEXT): {$(VPATH)}internal/module.h
-mjit.$(OBJEXT): {$(VPATH)}internal/newobj.h
-mjit.$(OBJEXT): {$(VPATH)}internal/rgengc.h
-mjit.$(OBJEXT): {$(VPATH)}internal/scan_args.h
-mjit.$(OBJEXT): {$(VPATH)}internal/special_consts.h
-mjit.$(OBJEXT): {$(VPATH)}internal/static_assert.h
-mjit.$(OBJEXT): {$(VPATH)}internal/stdalign.h
-mjit.$(OBJEXT): {$(VPATH)}internal/stdbool.h
-mjit.$(OBJEXT): {$(VPATH)}internal/symbol.h
-mjit.$(OBJEXT): {$(VPATH)}internal/value.h
-mjit.$(OBJEXT): {$(VPATH)}internal/value_type.h
-mjit.$(OBJEXT): {$(VPATH)}internal/variable.h
-mjit.$(OBJEXT): {$(VPATH)}internal/warning_push.h
-mjit.$(OBJEXT): {$(VPATH)}internal/xmalloc.h
-mjit.$(OBJEXT): {$(VPATH)}iseq.h
-mjit.$(OBJEXT): {$(VPATH)}method.h
-mjit.$(OBJEXT): {$(VPATH)}missing.h
-mjit.$(OBJEXT): {$(VPATH)}mjit.c
-mjit.$(OBJEXT): {$(VPATH)}mjit.h
-mjit.$(OBJEXT): {$(VPATH)}mjit.rbinc
-mjit.$(OBJEXT): {$(VPATH)}mjit_c.h
-mjit.$(OBJEXT): {$(VPATH)}mjit_config.h
-mjit.$(OBJEXT): {$(VPATH)}node.h
-mjit.$(OBJEXT): {$(VPATH)}onigmo.h
-mjit.$(OBJEXT): {$(VPATH)}oniguruma.h
-mjit.$(OBJEXT): {$(VPATH)}ractor.h
-mjit.$(OBJEXT): {$(VPATH)}ractor_core.h
-mjit.$(OBJEXT): {$(VPATH)}ruby_assert.h
-mjit.$(OBJEXT): {$(VPATH)}ruby_atomic.h
-mjit.$(OBJEXT): {$(VPATH)}shape.h
-mjit.$(OBJEXT): {$(VPATH)}st.h
-mjit.$(OBJEXT): {$(VPATH)}subst.h
-mjit.$(OBJEXT): {$(VPATH)}thread.h
-mjit.$(OBJEXT): {$(VPATH)}thread_$(THREAD_MODEL).h
-mjit.$(OBJEXT): {$(VPATH)}thread_native.h
-mjit.$(OBJEXT): {$(VPATH)}util.h
-mjit.$(OBJEXT): {$(VPATH)}vm_callinfo.h
-mjit.$(OBJEXT): {$(VPATH)}vm_core.h
-mjit.$(OBJEXT): {$(VPATH)}vm_debug.h
-mjit.$(OBJEXT): {$(VPATH)}vm_opts.h
-mjit.$(OBJEXT): {$(VPATH)}vm_sync.h
-mjit.$(OBJEXT): {$(VPATH)}yjit.h
-mjit_c.$(OBJEXT): $(CCAN_DIR)/check_type/check_type.h
-mjit_c.$(OBJEXT): $(CCAN_DIR)/container_of/container_of.h
-mjit_c.$(OBJEXT): $(CCAN_DIR)/list/list.h
-mjit_c.$(OBJEXT): $(CCAN_DIR)/str/str.h
-mjit_c.$(OBJEXT): $(hdrdir)/ruby.h
-mjit_c.$(OBJEXT): $(hdrdir)/ruby/ruby.h
-mjit_c.$(OBJEXT): $(srcdir)/mjit_c.rb
-mjit_c.$(OBJEXT): $(top_srcdir)/internal/array.h
-mjit_c.$(OBJEXT): $(top_srcdir)/internal/basic_operators.h
-mjit_c.$(OBJEXT): $(top_srcdir)/internal/class.h
-mjit_c.$(OBJEXT): $(top_srcdir)/internal/compile.h
-mjit_c.$(OBJEXT): $(top_srcdir)/internal/compilers.h
-mjit_c.$(OBJEXT): $(top_srcdir)/internal/gc.h
-mjit_c.$(OBJEXT): $(top_srcdir)/internal/hash.h
-mjit_c.$(OBJEXT): $(top_srcdir)/internal/imemo.h
-mjit_c.$(OBJEXT): $(top_srcdir)/internal/object.h
-mjit_c.$(OBJEXT): $(top_srcdir)/internal/serial.h
-mjit_c.$(OBJEXT): $(top_srcdir)/internal/static_assert.h
-mjit_c.$(OBJEXT): $(top_srcdir)/internal/variable.h
-mjit_c.$(OBJEXT): $(top_srcdir)/internal/vm.h
-mjit_c.$(OBJEXT): $(top_srcdir)/internal/warnings.h
-mjit_c.$(OBJEXT): {$(VPATH)}assert.h
-mjit_c.$(OBJEXT): {$(VPATH)}atomic.h
-mjit_c.$(OBJEXT): {$(VPATH)}backward/2/assume.h
-mjit_c.$(OBJEXT): {$(VPATH)}backward/2/attributes.h
-mjit_c.$(OBJEXT): {$(VPATH)}backward/2/bool.h
-mjit_c.$(OBJEXT): {$(VPATH)}backward/2/gcc_version_since.h
-mjit_c.$(OBJEXT): {$(VPATH)}backward/2/inttypes.h
-mjit_c.$(OBJEXT): {$(VPATH)}backward/2/limits.h
-mjit_c.$(OBJEXT): {$(VPATH)}backward/2/long_long.h
-mjit_c.$(OBJEXT): {$(VPATH)}backward/2/stdalign.h
-mjit_c.$(OBJEXT): {$(VPATH)}backward/2/stdarg.h
-mjit_c.$(OBJEXT): {$(VPATH)}builtin.h
-mjit_c.$(OBJEXT): {$(VPATH)}config.h
-mjit_c.$(OBJEXT): {$(VPATH)}constant.h
-mjit_c.$(OBJEXT): {$(VPATH)}debug_counter.h
-mjit_c.$(OBJEXT): {$(VPATH)}defines.h
-mjit_c.$(OBJEXT): {$(VPATH)}id.h
-mjit_c.$(OBJEXT): {$(VPATH)}id_table.h
-mjit_c.$(OBJEXT): {$(VPATH)}insns.def
-mjit_c.$(OBJEXT): {$(VPATH)}insns.inc
-mjit_c.$(OBJEXT): {$(VPATH)}insns_info.inc
-mjit_c.$(OBJEXT): {$(VPATH)}intern.h
-mjit_c.$(OBJEXT): {$(VPATH)}internal.h
-mjit_c.$(OBJEXT): {$(VPATH)}internal/abi.h
-mjit_c.$(OBJEXT): {$(VPATH)}internal/anyargs.h
-mjit_c.$(OBJEXT): {$(VPATH)}internal/arithmetic.h
-mjit_c.$(OBJEXT): {$(VPATH)}internal/arithmetic/char.h
-mjit_c.$(OBJEXT): {$(VPATH)}internal/arithmetic/double.h
-mjit_c.$(OBJEXT): {$(VPATH)}internal/arithmetic/fixnum.h
-mjit_c.$(OBJEXT): {$(VPATH)}internal/arithmetic/gid_t.h
-mjit_c.$(OBJEXT): {$(VPATH)}internal/arithmetic/int.h
-mjit_c.$(OBJEXT): {$(VPATH)}internal/arithmetic/intptr_t.h
-mjit_c.$(OBJEXT): {$(VPATH)}internal/arithmetic/long.h
-mjit_c.$(OBJEXT): {$(VPATH)}internal/arithmetic/long_long.h
-mjit_c.$(OBJEXT): {$(VPATH)}internal/arithmetic/mode_t.h
-mjit_c.$(OBJEXT): {$(VPATH)}internal/arithmetic/off_t.h
-mjit_c.$(OBJEXT): {$(VPATH)}internal/arithmetic/pid_t.h
-mjit_c.$(OBJEXT): {$(VPATH)}internal/arithmetic/short.h
-mjit_c.$(OBJEXT): {$(VPATH)}internal/arithmetic/size_t.h
-mjit_c.$(OBJEXT): {$(VPATH)}internal/arithmetic/st_data_t.h
-mjit_c.$(OBJEXT): {$(VPATH)}internal/arithmetic/uid_t.h
-mjit_c.$(OBJEXT): {$(VPATH)}internal/assume.h
-mjit_c.$(OBJEXT): {$(VPATH)}internal/attr/alloc_size.h
-mjit_c.$(OBJEXT): {$(VPATH)}internal/attr/artificial.h
-mjit_c.$(OBJEXT): {$(VPATH)}internal/attr/cold.h
-mjit_c.$(OBJEXT): {$(VPATH)}internal/attr/const.h
-mjit_c.$(OBJEXT): {$(VPATH)}internal/attr/constexpr.h
-mjit_c.$(OBJEXT): {$(VPATH)}internal/attr/deprecated.h
-mjit_c.$(OBJEXT): {$(VPATH)}internal/attr/diagnose_if.h
-mjit_c.$(OBJEXT): {$(VPATH)}internal/attr/enum_extensibility.h
-mjit_c.$(OBJEXT): {$(VPATH)}internal/attr/error.h
-mjit_c.$(OBJEXT): {$(VPATH)}internal/attr/flag_enum.h
-mjit_c.$(OBJEXT): {$(VPATH)}internal/attr/forceinline.h
-mjit_c.$(OBJEXT): {$(VPATH)}internal/attr/format.h
-mjit_c.$(OBJEXT): {$(VPATH)}internal/attr/maybe_unused.h
-mjit_c.$(OBJEXT): {$(VPATH)}internal/attr/noalias.h
-mjit_c.$(OBJEXT): {$(VPATH)}internal/attr/nodiscard.h
-mjit_c.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
-mjit_c.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
-mjit_c.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
-mjit_c.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
-mjit_c.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
-mjit_c.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
-mjit_c.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
-mjit_c.$(OBJEXT): {$(VPATH)}internal/attr/warning.h
-mjit_c.$(OBJEXT): {$(VPATH)}internal/attr/weakref.h
-mjit_c.$(OBJEXT): {$(VPATH)}internal/cast.h
-mjit_c.$(OBJEXT): {$(VPATH)}internal/compiler_is.h
-mjit_c.$(OBJEXT): {$(VPATH)}internal/compiler_is/apple.h
-mjit_c.$(OBJEXT): {$(VPATH)}internal/compiler_is/clang.h
-mjit_c.$(OBJEXT): {$(VPATH)}internal/compiler_is/gcc.h
-mjit_c.$(OBJEXT): {$(VPATH)}internal/compiler_is/intel.h
-mjit_c.$(OBJEXT): {$(VPATH)}internal/compiler_is/msvc.h
-mjit_c.$(OBJEXT): {$(VPATH)}internal/compiler_is/sunpro.h
-mjit_c.$(OBJEXT): {$(VPATH)}internal/compiler_since.h
-mjit_c.$(OBJEXT): {$(VPATH)}internal/config.h
-mjit_c.$(OBJEXT): {$(VPATH)}internal/constant_p.h
-mjit_c.$(OBJEXT): {$(VPATH)}internal/core.h
-mjit_c.$(OBJEXT): {$(VPATH)}internal/core/rarray.h
-mjit_c.$(OBJEXT): {$(VPATH)}internal/core/rbasic.h
-mjit_c.$(OBJEXT): {$(VPATH)}internal/core/rbignum.h
-mjit_c.$(OBJEXT): {$(VPATH)}internal/core/rclass.h
-mjit_c.$(OBJEXT): {$(VPATH)}internal/core/rdata.h
-mjit_c.$(OBJEXT): {$(VPATH)}internal/core/rfile.h
-mjit_c.$(OBJEXT): {$(VPATH)}internal/core/rhash.h
-mjit_c.$(OBJEXT): {$(VPATH)}internal/core/robject.h
-mjit_c.$(OBJEXT): {$(VPATH)}internal/core/rregexp.h
-mjit_c.$(OBJEXT): {$(VPATH)}internal/core/rstring.h
-mjit_c.$(OBJEXT): {$(VPATH)}internal/core/rstruct.h
-mjit_c.$(OBJEXT): {$(VPATH)}internal/core/rtypeddata.h
-mjit_c.$(OBJEXT): {$(VPATH)}internal/ctype.h
-mjit_c.$(OBJEXT): {$(VPATH)}internal/dllexport.h
-mjit_c.$(OBJEXT): {$(VPATH)}internal/dosish.h
-mjit_c.$(OBJEXT): {$(VPATH)}internal/error.h
-mjit_c.$(OBJEXT): {$(VPATH)}internal/eval.h
-mjit_c.$(OBJEXT): {$(VPATH)}internal/event.h
-mjit_c.$(OBJEXT): {$(VPATH)}internal/fl_type.h
-mjit_c.$(OBJEXT): {$(VPATH)}internal/gc.h
-mjit_c.$(OBJEXT): {$(VPATH)}internal/glob.h
-mjit_c.$(OBJEXT): {$(VPATH)}internal/globals.h
-mjit_c.$(OBJEXT): {$(VPATH)}internal/has/attribute.h
-mjit_c.$(OBJEXT): {$(VPATH)}internal/has/builtin.h
-mjit_c.$(OBJEXT): {$(VPATH)}internal/has/c_attribute.h
-mjit_c.$(OBJEXT): {$(VPATH)}internal/has/cpp_attribute.h
-mjit_c.$(OBJEXT): {$(VPATH)}internal/has/declspec_attribute.h
-mjit_c.$(OBJEXT): {$(VPATH)}internal/has/extension.h
-mjit_c.$(OBJEXT): {$(VPATH)}internal/has/feature.h
-mjit_c.$(OBJEXT): {$(VPATH)}internal/has/warning.h
-mjit_c.$(OBJEXT): {$(VPATH)}internal/intern/array.h
-mjit_c.$(OBJEXT): {$(VPATH)}internal/intern/bignum.h
-mjit_c.$(OBJEXT): {$(VPATH)}internal/intern/class.h
-mjit_c.$(OBJEXT): {$(VPATH)}internal/intern/compar.h
-mjit_c.$(OBJEXT): {$(VPATH)}internal/intern/complex.h
-mjit_c.$(OBJEXT): {$(VPATH)}internal/intern/cont.h
-mjit_c.$(OBJEXT): {$(VPATH)}internal/intern/dir.h
-mjit_c.$(OBJEXT): {$(VPATH)}internal/intern/enum.h
-mjit_c.$(OBJEXT): {$(VPATH)}internal/intern/enumerator.h
-mjit_c.$(OBJEXT): {$(VPATH)}internal/intern/error.h
-mjit_c.$(OBJEXT): {$(VPATH)}internal/intern/eval.h
-mjit_c.$(OBJEXT): {$(VPATH)}internal/intern/file.h
-mjit_c.$(OBJEXT): {$(VPATH)}internal/intern/gc.h
-mjit_c.$(OBJEXT): {$(VPATH)}internal/intern/hash.h
-mjit_c.$(OBJEXT): {$(VPATH)}internal/intern/io.h
-mjit_c.$(OBJEXT): {$(VPATH)}internal/intern/load.h
-mjit_c.$(OBJEXT): {$(VPATH)}internal/intern/marshal.h
-mjit_c.$(OBJEXT): {$(VPATH)}internal/intern/numeric.h
-mjit_c.$(OBJEXT): {$(VPATH)}internal/intern/object.h
-mjit_c.$(OBJEXT): {$(VPATH)}internal/intern/parse.h
-mjit_c.$(OBJEXT): {$(VPATH)}internal/intern/proc.h
-mjit_c.$(OBJEXT): {$(VPATH)}internal/intern/process.h
-mjit_c.$(OBJEXT): {$(VPATH)}internal/intern/random.h
-mjit_c.$(OBJEXT): {$(VPATH)}internal/intern/range.h
-mjit_c.$(OBJEXT): {$(VPATH)}internal/intern/rational.h
-mjit_c.$(OBJEXT): {$(VPATH)}internal/intern/re.h
-mjit_c.$(OBJEXT): {$(VPATH)}internal/intern/ruby.h
-mjit_c.$(OBJEXT): {$(VPATH)}internal/intern/select.h
-mjit_c.$(OBJEXT): {$(VPATH)}internal/intern/select/largesize.h
-mjit_c.$(OBJEXT): {$(VPATH)}internal/intern/signal.h
-mjit_c.$(OBJEXT): {$(VPATH)}internal/intern/sprintf.h
-mjit_c.$(OBJEXT): {$(VPATH)}internal/intern/string.h
-mjit_c.$(OBJEXT): {$(VPATH)}internal/intern/struct.h
-mjit_c.$(OBJEXT): {$(VPATH)}internal/intern/thread.h
-mjit_c.$(OBJEXT): {$(VPATH)}internal/intern/time.h
-mjit_c.$(OBJEXT): {$(VPATH)}internal/intern/variable.h
-mjit_c.$(OBJEXT): {$(VPATH)}internal/intern/vm.h
-mjit_c.$(OBJEXT): {$(VPATH)}internal/interpreter.h
-mjit_c.$(OBJEXT): {$(VPATH)}internal/iterator.h
-mjit_c.$(OBJEXT): {$(VPATH)}internal/memory.h
-mjit_c.$(OBJEXT): {$(VPATH)}internal/method.h
-mjit_c.$(OBJEXT): {$(VPATH)}internal/module.h
-mjit_c.$(OBJEXT): {$(VPATH)}internal/newobj.h
-mjit_c.$(OBJEXT): {$(VPATH)}internal/rgengc.h
-mjit_c.$(OBJEXT): {$(VPATH)}internal/scan_args.h
-mjit_c.$(OBJEXT): {$(VPATH)}internal/special_consts.h
-mjit_c.$(OBJEXT): {$(VPATH)}internal/static_assert.h
-mjit_c.$(OBJEXT): {$(VPATH)}internal/stdalign.h
-mjit_c.$(OBJEXT): {$(VPATH)}internal/stdbool.h
-mjit_c.$(OBJEXT): {$(VPATH)}internal/symbol.h
-mjit_c.$(OBJEXT): {$(VPATH)}internal/value.h
-mjit_c.$(OBJEXT): {$(VPATH)}internal/value_type.h
-mjit_c.$(OBJEXT): {$(VPATH)}internal/variable.h
-mjit_c.$(OBJEXT): {$(VPATH)}internal/warning_push.h
-mjit_c.$(OBJEXT): {$(VPATH)}internal/xmalloc.h
-mjit_c.$(OBJEXT): {$(VPATH)}iseq.h
-mjit_c.$(OBJEXT): {$(VPATH)}method.h
-mjit_c.$(OBJEXT): {$(VPATH)}missing.h
-mjit_c.$(OBJEXT): {$(VPATH)}mjit.h
-mjit_c.$(OBJEXT): {$(VPATH)}mjit_c.c
-mjit_c.$(OBJEXT): {$(VPATH)}mjit_c.h
-mjit_c.$(OBJEXT): {$(VPATH)}mjit_c.rb
-mjit_c.$(OBJEXT): {$(VPATH)}mjit_c.rbinc
-mjit_c.$(OBJEXT): {$(VPATH)}mjit_sp_inc.inc
-mjit_c.$(OBJEXT): {$(VPATH)}node.h
-mjit_c.$(OBJEXT): {$(VPATH)}ruby_assert.h
-mjit_c.$(OBJEXT): {$(VPATH)}ruby_atomic.h
-mjit_c.$(OBJEXT): {$(VPATH)}shape.h
-mjit_c.$(OBJEXT): {$(VPATH)}st.h
-mjit_c.$(OBJEXT): {$(VPATH)}subst.h
-mjit_c.$(OBJEXT): {$(VPATH)}thread_$(THREAD_MODEL).h
-mjit_c.$(OBJEXT): {$(VPATH)}thread_native.h
-mjit_c.$(OBJEXT): {$(VPATH)}vm_callinfo.h
-mjit_c.$(OBJEXT): {$(VPATH)}vm_core.h
-mjit_c.$(OBJEXT): {$(VPATH)}vm_exec.h
-mjit_c.$(OBJEXT): {$(VPATH)}vm_insnhelper.h
-mjit_c.$(OBJEXT): {$(VPATH)}vm_opts.h
-mjit_c.$(OBJEXT): {$(VPATH)}yjit.h
node.$(OBJEXT): $(CCAN_DIR)/check_type/check_type.h
node.$(OBJEXT): $(CCAN_DIR)/container_of/container_of.h
node.$(OBJEXT): $(CCAN_DIR)/list/list.h
@@ -10134,6 +10311,7 @@ node.$(OBJEXT): {$(VPATH)}backward/2/stdarg.h
node.$(OBJEXT): {$(VPATH)}config.h
node.$(OBJEXT): {$(VPATH)}constant.h
node.$(OBJEXT): {$(VPATH)}defines.h
+node.$(OBJEXT): {$(VPATH)}encoding.h
node.$(OBJEXT): {$(VPATH)}id.h
node.$(OBJEXT): {$(VPATH)}id_table.h
node.$(OBJEXT): {$(VPATH)}intern.h
@@ -10176,6 +10354,7 @@ node.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
node.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
node.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
node.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
+node.$(OBJEXT): {$(VPATH)}internal/attr/packed_struct.h
node.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
node.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
node.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
@@ -10208,6 +10387,15 @@ node.$(OBJEXT): {$(VPATH)}internal/core/rtypeddata.h
node.$(OBJEXT): {$(VPATH)}internal/ctype.h
node.$(OBJEXT): {$(VPATH)}internal/dllexport.h
node.$(OBJEXT): {$(VPATH)}internal/dosish.h
+node.$(OBJEXT): {$(VPATH)}internal/encoding/coderange.h
+node.$(OBJEXT): {$(VPATH)}internal/encoding/ctype.h
+node.$(OBJEXT): {$(VPATH)}internal/encoding/encoding.h
+node.$(OBJEXT): {$(VPATH)}internal/encoding/pathname.h
+node.$(OBJEXT): {$(VPATH)}internal/encoding/re.h
+node.$(OBJEXT): {$(VPATH)}internal/encoding/sprintf.h
+node.$(OBJEXT): {$(VPATH)}internal/encoding/string.h
+node.$(OBJEXT): {$(VPATH)}internal/encoding/symbol.h
+node.$(OBJEXT): {$(VPATH)}internal/encoding/transcode.h
node.$(OBJEXT): {$(VPATH)}internal/error.h
node.$(OBJEXT): {$(VPATH)}internal/eval.h
node.$(OBJEXT): {$(VPATH)}internal/event.h
@@ -10235,7 +10423,6 @@ node.$(OBJEXT): {$(VPATH)}internal/intern/enumerator.h
node.$(OBJEXT): {$(VPATH)}internal/intern/error.h
node.$(OBJEXT): {$(VPATH)}internal/intern/eval.h
node.$(OBJEXT): {$(VPATH)}internal/intern/file.h
-node.$(OBJEXT): {$(VPATH)}internal/intern/gc.h
node.$(OBJEXT): {$(VPATH)}internal/intern/hash.h
node.$(OBJEXT): {$(VPATH)}internal/intern/io.h
node.$(OBJEXT): {$(VPATH)}internal/intern/load.h
@@ -10266,7 +10453,6 @@ node.$(OBJEXT): {$(VPATH)}internal/memory.h
node.$(OBJEXT): {$(VPATH)}internal/method.h
node.$(OBJEXT): {$(VPATH)}internal/module.h
node.$(OBJEXT): {$(VPATH)}internal/newobj.h
-node.$(OBJEXT): {$(VPATH)}internal/rgengc.h
node.$(OBJEXT): {$(VPATH)}internal/scan_args.h
node.$(OBJEXT): {$(VPATH)}internal/special_consts.h
node.$(OBJEXT): {$(VPATH)}internal/static_assert.h
@@ -10282,8 +10468,12 @@ node.$(OBJEXT): {$(VPATH)}method.h
node.$(OBJEXT): {$(VPATH)}missing.h
node.$(OBJEXT): {$(VPATH)}node.c
node.$(OBJEXT): {$(VPATH)}node.h
+node.$(OBJEXT): {$(VPATH)}node_name.inc
+node.$(OBJEXT): {$(VPATH)}onigmo.h
+node.$(OBJEXT): {$(VPATH)}oniguruma.h
node.$(OBJEXT): {$(VPATH)}ruby_assert.h
node.$(OBJEXT): {$(VPATH)}ruby_atomic.h
+node.$(OBJEXT): {$(VPATH)}rubyparser.h
node.$(OBJEXT): {$(VPATH)}shape.h
node.$(OBJEXT): {$(VPATH)}st.h
node.$(OBJEXT): {$(VPATH)}subst.h
@@ -10291,8 +10481,212 @@ node.$(OBJEXT): {$(VPATH)}thread_$(THREAD_MODEL).h
node.$(OBJEXT): {$(VPATH)}thread_native.h
node.$(OBJEXT): {$(VPATH)}vm_core.h
node.$(OBJEXT): {$(VPATH)}vm_opts.h
+node_dump.$(OBJEXT): $(CCAN_DIR)/check_type/check_type.h
+node_dump.$(OBJEXT): $(CCAN_DIR)/container_of/container_of.h
+node_dump.$(OBJEXT): $(CCAN_DIR)/list/list.h
+node_dump.$(OBJEXT): $(CCAN_DIR)/str/str.h
+node_dump.$(OBJEXT): $(hdrdir)/ruby/ruby.h
+node_dump.$(OBJEXT): $(top_srcdir)/internal/array.h
+node_dump.$(OBJEXT): $(top_srcdir)/internal/basic_operators.h
+node_dump.$(OBJEXT): $(top_srcdir)/internal/compilers.h
+node_dump.$(OBJEXT): $(top_srcdir)/internal/gc.h
+node_dump.$(OBJEXT): $(top_srcdir)/internal/hash.h
+node_dump.$(OBJEXT): $(top_srcdir)/internal/imemo.h
+node_dump.$(OBJEXT): $(top_srcdir)/internal/serial.h
+node_dump.$(OBJEXT): $(top_srcdir)/internal/static_assert.h
+node_dump.$(OBJEXT): $(top_srcdir)/internal/variable.h
+node_dump.$(OBJEXT): $(top_srcdir)/internal/vm.h
+node_dump.$(OBJEXT): $(top_srcdir)/internal/warnings.h
+node_dump.$(OBJEXT): {$(VPATH)}assert.h
+node_dump.$(OBJEXT): {$(VPATH)}atomic.h
+node_dump.$(OBJEXT): {$(VPATH)}backward/2/assume.h
+node_dump.$(OBJEXT): {$(VPATH)}backward/2/attributes.h
+node_dump.$(OBJEXT): {$(VPATH)}backward/2/bool.h
+node_dump.$(OBJEXT): {$(VPATH)}backward/2/gcc_version_since.h
+node_dump.$(OBJEXT): {$(VPATH)}backward/2/inttypes.h
+node_dump.$(OBJEXT): {$(VPATH)}backward/2/limits.h
+node_dump.$(OBJEXT): {$(VPATH)}backward/2/long_long.h
+node_dump.$(OBJEXT): {$(VPATH)}backward/2/stdalign.h
+node_dump.$(OBJEXT): {$(VPATH)}backward/2/stdarg.h
+node_dump.$(OBJEXT): {$(VPATH)}config.h
+node_dump.$(OBJEXT): {$(VPATH)}constant.h
+node_dump.$(OBJEXT): {$(VPATH)}defines.h
+node_dump.$(OBJEXT): {$(VPATH)}encoding.h
+node_dump.$(OBJEXT): {$(VPATH)}id.h
+node_dump.$(OBJEXT): {$(VPATH)}id_table.h
+node_dump.$(OBJEXT): {$(VPATH)}intern.h
+node_dump.$(OBJEXT): {$(VPATH)}internal.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/abi.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/anyargs.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/arithmetic.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/arithmetic/char.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/arithmetic/double.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/arithmetic/fixnum.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/arithmetic/gid_t.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/arithmetic/int.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/arithmetic/intptr_t.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/arithmetic/long.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/arithmetic/long_long.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/arithmetic/mode_t.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/arithmetic/off_t.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/arithmetic/pid_t.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/arithmetic/short.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/arithmetic/size_t.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/arithmetic/st_data_t.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/arithmetic/uid_t.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/assume.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/attr/alloc_size.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/attr/artificial.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/attr/cold.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/attr/const.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/attr/constexpr.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/attr/deprecated.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/attr/diagnose_if.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/attr/enum_extensibility.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/attr/error.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/attr/flag_enum.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/attr/forceinline.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/attr/format.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/attr/maybe_unused.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/attr/noalias.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/attr/nodiscard.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/attr/packed_struct.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/attr/warning.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/attr/weakref.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/cast.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/compiler_is.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/compiler_is/apple.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/compiler_is/clang.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/compiler_is/gcc.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/compiler_is/intel.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/compiler_is/msvc.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/compiler_is/sunpro.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/compiler_since.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/config.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/constant_p.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/core.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/core/rarray.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/core/rbasic.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/core/rbignum.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/core/rclass.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/core/rdata.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/core/rfile.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/core/rhash.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/core/robject.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/core/rregexp.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/core/rstring.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/core/rstruct.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/core/rtypeddata.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/ctype.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/dllexport.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/dosish.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/encoding/coderange.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/encoding/ctype.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/encoding/encoding.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/encoding/pathname.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/encoding/re.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/encoding/sprintf.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/encoding/string.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/encoding/symbol.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/encoding/transcode.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/error.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/eval.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/event.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/fl_type.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/gc.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/glob.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/globals.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/has/attribute.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/has/builtin.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/has/c_attribute.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/has/cpp_attribute.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/has/declspec_attribute.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/has/extension.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/has/feature.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/has/warning.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/intern/array.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/intern/bignum.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/intern/class.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/intern/compar.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/intern/complex.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/intern/cont.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/intern/dir.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/intern/enum.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/intern/enumerator.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/intern/error.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/intern/eval.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/intern/file.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/intern/hash.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/intern/io.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/intern/load.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/intern/marshal.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/intern/numeric.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/intern/object.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/intern/parse.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/intern/proc.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/intern/process.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/intern/random.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/intern/range.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/intern/rational.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/intern/re.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/intern/ruby.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/intern/select.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/intern/select/largesize.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/intern/signal.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/intern/sprintf.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/intern/string.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/intern/struct.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/intern/thread.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/intern/time.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/intern/variable.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/intern/vm.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/interpreter.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/iterator.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/memory.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/method.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/module.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/newobj.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/scan_args.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/special_consts.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/static_assert.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/stdalign.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/stdbool.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/symbol.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/value.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/value_type.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/variable.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/warning_push.h
+node_dump.$(OBJEXT): {$(VPATH)}internal/xmalloc.h
+node_dump.$(OBJEXT): {$(VPATH)}method.h
+node_dump.$(OBJEXT): {$(VPATH)}missing.h
+node_dump.$(OBJEXT): {$(VPATH)}node.h
+node_dump.$(OBJEXT): {$(VPATH)}node_dump.c
+node_dump.$(OBJEXT): {$(VPATH)}onigmo.h
+node_dump.$(OBJEXT): {$(VPATH)}oniguruma.h
+node_dump.$(OBJEXT): {$(VPATH)}ruby_assert.h
+node_dump.$(OBJEXT): {$(VPATH)}ruby_atomic.h
+node_dump.$(OBJEXT): {$(VPATH)}rubyparser.h
+node_dump.$(OBJEXT): {$(VPATH)}shape.h
+node_dump.$(OBJEXT): {$(VPATH)}st.h
+node_dump.$(OBJEXT): {$(VPATH)}subst.h
+node_dump.$(OBJEXT): {$(VPATH)}thread_$(THREAD_MODEL).h
+node_dump.$(OBJEXT): {$(VPATH)}thread_native.h
+node_dump.$(OBJEXT): {$(VPATH)}vm_core.h
+node_dump.$(OBJEXT): {$(VPATH)}vm_opts.h
+numeric.$(OBJEXT): $(CCAN_DIR)/check_type/check_type.h
+numeric.$(OBJEXT): $(CCAN_DIR)/container_of/container_of.h
+numeric.$(OBJEXT): $(CCAN_DIR)/list/list.h
+numeric.$(OBJEXT): $(CCAN_DIR)/str/str.h
numeric.$(OBJEXT): $(hdrdir)/ruby/ruby.h
numeric.$(OBJEXT): $(top_srcdir)/internal/array.h
+numeric.$(OBJEXT): $(top_srcdir)/internal/basic_operators.h
numeric.$(OBJEXT): $(top_srcdir)/internal/bignum.h
numeric.$(OBJEXT): $(top_srcdir)/internal/bits.h
numeric.$(OBJEXT): $(top_srcdir)/internal/class.h
@@ -10302,6 +10696,7 @@ numeric.$(OBJEXT): $(top_srcdir)/internal/enumerator.h
numeric.$(OBJEXT): $(top_srcdir)/internal/fixnum.h
numeric.$(OBJEXT): $(top_srcdir)/internal/gc.h
numeric.$(OBJEXT): $(top_srcdir)/internal/hash.h
+numeric.$(OBJEXT): $(top_srcdir)/internal/imemo.h
numeric.$(OBJEXT): $(top_srcdir)/internal/numeric.h
numeric.$(OBJEXT): $(top_srcdir)/internal/object.h
numeric.$(OBJEXT): $(top_srcdir)/internal/rational.h
@@ -10313,6 +10708,7 @@ numeric.$(OBJEXT): $(top_srcdir)/internal/variable.h
numeric.$(OBJEXT): $(top_srcdir)/internal/vm.h
numeric.$(OBJEXT): $(top_srcdir)/internal/warnings.h
numeric.$(OBJEXT): {$(VPATH)}assert.h
+numeric.$(OBJEXT): {$(VPATH)}atomic.h
numeric.$(OBJEXT): {$(VPATH)}backward/2/assume.h
numeric.$(OBJEXT): {$(VPATH)}backward/2/attributes.h
numeric.$(OBJEXT): {$(VPATH)}backward/2/bool.h
@@ -10369,6 +10765,7 @@ numeric.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
numeric.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
numeric.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
numeric.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
+numeric.$(OBJEXT): {$(VPATH)}internal/attr/packed_struct.h
numeric.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
numeric.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
numeric.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
@@ -10437,7 +10834,6 @@ numeric.$(OBJEXT): {$(VPATH)}internal/intern/enumerator.h
numeric.$(OBJEXT): {$(VPATH)}internal/intern/error.h
numeric.$(OBJEXT): {$(VPATH)}internal/intern/eval.h
numeric.$(OBJEXT): {$(VPATH)}internal/intern/file.h
-numeric.$(OBJEXT): {$(VPATH)}internal/intern/gc.h
numeric.$(OBJEXT): {$(VPATH)}internal/intern/hash.h
numeric.$(OBJEXT): {$(VPATH)}internal/intern/io.h
numeric.$(OBJEXT): {$(VPATH)}internal/intern/load.h
@@ -10468,7 +10864,6 @@ numeric.$(OBJEXT): {$(VPATH)}internal/memory.h
numeric.$(OBJEXT): {$(VPATH)}internal/method.h
numeric.$(OBJEXT): {$(VPATH)}internal/module.h
numeric.$(OBJEXT): {$(VPATH)}internal/newobj.h
-numeric.$(OBJEXT): {$(VPATH)}internal/rgengc.h
numeric.$(OBJEXT): {$(VPATH)}internal/scan_args.h
numeric.$(OBJEXT): {$(VPATH)}internal/special_consts.h
numeric.$(OBJEXT): {$(VPATH)}internal/static_assert.h
@@ -10480,18 +10875,32 @@ numeric.$(OBJEXT): {$(VPATH)}internal/value_type.h
numeric.$(OBJEXT): {$(VPATH)}internal/variable.h
numeric.$(OBJEXT): {$(VPATH)}internal/warning_push.h
numeric.$(OBJEXT): {$(VPATH)}internal/xmalloc.h
+numeric.$(OBJEXT): {$(VPATH)}method.h
numeric.$(OBJEXT): {$(VPATH)}missing.h
+numeric.$(OBJEXT): {$(VPATH)}node.h
numeric.$(OBJEXT): {$(VPATH)}numeric.c
numeric.$(OBJEXT): {$(VPATH)}numeric.rbinc
numeric.$(OBJEXT): {$(VPATH)}onigmo.h
numeric.$(OBJEXT): {$(VPATH)}oniguruma.h
numeric.$(OBJEXT): {$(VPATH)}ruby_assert.h
+numeric.$(OBJEXT): {$(VPATH)}ruby_atomic.h
+numeric.$(OBJEXT): {$(VPATH)}rubyparser.h
numeric.$(OBJEXT): {$(VPATH)}shape.h
numeric.$(OBJEXT): {$(VPATH)}st.h
numeric.$(OBJEXT): {$(VPATH)}subst.h
+numeric.$(OBJEXT): {$(VPATH)}thread_$(THREAD_MODEL).h
+numeric.$(OBJEXT): {$(VPATH)}thread_native.h
numeric.$(OBJEXT): {$(VPATH)}util.h
+numeric.$(OBJEXT): {$(VPATH)}vm_core.h
+numeric.$(OBJEXT): {$(VPATH)}vm_opts.h
+object.$(OBJEXT): $(CCAN_DIR)/check_type/check_type.h
+object.$(OBJEXT): $(CCAN_DIR)/container_of/container_of.h
+object.$(OBJEXT): $(CCAN_DIR)/list/list.h
+object.$(OBJEXT): $(CCAN_DIR)/str/str.h
object.$(OBJEXT): $(hdrdir)/ruby/ruby.h
+object.$(OBJEXT): $(hdrdir)/ruby/version.h
object.$(OBJEXT): $(top_srcdir)/internal/array.h
+object.$(OBJEXT): $(top_srcdir)/internal/basic_operators.h
object.$(OBJEXT): $(top_srcdir)/internal/bignum.h
object.$(OBJEXT): $(top_srcdir)/internal/bits.h
object.$(OBJEXT): $(top_srcdir)/internal/class.h
@@ -10500,6 +10909,7 @@ object.$(OBJEXT): $(top_srcdir)/internal/error.h
object.$(OBJEXT): $(top_srcdir)/internal/eval.h
object.$(OBJEXT): $(top_srcdir)/internal/fixnum.h
object.$(OBJEXT): $(top_srcdir)/internal/gc.h
+object.$(OBJEXT): $(top_srcdir)/internal/imemo.h
object.$(OBJEXT): $(top_srcdir)/internal/inits.h
object.$(OBJEXT): $(top_srcdir)/internal/numeric.h
object.$(OBJEXT): $(top_srcdir)/internal/object.h
@@ -10512,6 +10922,7 @@ object.$(OBJEXT): $(top_srcdir)/internal/variable.h
object.$(OBJEXT): $(top_srcdir)/internal/vm.h
object.$(OBJEXT): $(top_srcdir)/internal/warnings.h
object.$(OBJEXT): {$(VPATH)}assert.h
+object.$(OBJEXT): {$(VPATH)}atomic.h
object.$(OBJEXT): {$(VPATH)}backward/2/assume.h
object.$(OBJEXT): {$(VPATH)}backward/2/attributes.h
object.$(OBJEXT): {$(VPATH)}backward/2/bool.h
@@ -10524,6 +10935,7 @@ object.$(OBJEXT): {$(VPATH)}backward/2/stdarg.h
object.$(OBJEXT): {$(VPATH)}builtin.h
object.$(OBJEXT): {$(VPATH)}config.h
object.$(OBJEXT): {$(VPATH)}constant.h
+object.$(OBJEXT): {$(VPATH)}debug_counter.h
object.$(OBJEXT): {$(VPATH)}defines.h
object.$(OBJEXT): {$(VPATH)}encoding.h
object.$(OBJEXT): {$(VPATH)}id.h
@@ -10568,6 +10980,7 @@ object.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
object.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
object.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
object.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
+object.$(OBJEXT): {$(VPATH)}internal/attr/packed_struct.h
object.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
object.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
object.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
@@ -10636,7 +11049,6 @@ object.$(OBJEXT): {$(VPATH)}internal/intern/enumerator.h
object.$(OBJEXT): {$(VPATH)}internal/intern/error.h
object.$(OBJEXT): {$(VPATH)}internal/intern/eval.h
object.$(OBJEXT): {$(VPATH)}internal/intern/file.h
-object.$(OBJEXT): {$(VPATH)}internal/intern/gc.h
object.$(OBJEXT): {$(VPATH)}internal/intern/hash.h
object.$(OBJEXT): {$(VPATH)}internal/intern/io.h
object.$(OBJEXT): {$(VPATH)}internal/intern/load.h
@@ -10667,7 +11079,6 @@ object.$(OBJEXT): {$(VPATH)}internal/memory.h
object.$(OBJEXT): {$(VPATH)}internal/method.h
object.$(OBJEXT): {$(VPATH)}internal/module.h
object.$(OBJEXT): {$(VPATH)}internal/newobj.h
-object.$(OBJEXT): {$(VPATH)}internal/rgengc.h
object.$(OBJEXT): {$(VPATH)}internal/scan_args.h
object.$(OBJEXT): {$(VPATH)}internal/special_consts.h
object.$(OBJEXT): {$(VPATH)}internal/static_assert.h
@@ -10680,29 +11091,49 @@ object.$(OBJEXT): {$(VPATH)}internal/variable.h
object.$(OBJEXT): {$(VPATH)}internal/warning_push.h
object.$(OBJEXT): {$(VPATH)}internal/xmalloc.h
object.$(OBJEXT): {$(VPATH)}kernel.rbinc
+object.$(OBJEXT): {$(VPATH)}method.h
object.$(OBJEXT): {$(VPATH)}missing.h
object.$(OBJEXT): {$(VPATH)}nilclass.rbinc
+object.$(OBJEXT): {$(VPATH)}node.h
object.$(OBJEXT): {$(VPATH)}object.c
object.$(OBJEXT): {$(VPATH)}onigmo.h
object.$(OBJEXT): {$(VPATH)}oniguruma.h
object.$(OBJEXT): {$(VPATH)}probes.dmyh
object.$(OBJEXT): {$(VPATH)}probes.h
+object.$(OBJEXT): {$(VPATH)}ruby_assert.h
+object.$(OBJEXT): {$(VPATH)}ruby_atomic.h
+object.$(OBJEXT): {$(VPATH)}rubyparser.h
object.$(OBJEXT): {$(VPATH)}shape.h
object.$(OBJEXT): {$(VPATH)}st.h
object.$(OBJEXT): {$(VPATH)}subst.h
+object.$(OBJEXT): {$(VPATH)}thread_$(THREAD_MODEL).h
+object.$(OBJEXT): {$(VPATH)}thread_native.h
object.$(OBJEXT): {$(VPATH)}util.h
object.$(OBJEXT): {$(VPATH)}variable.h
+object.$(OBJEXT): {$(VPATH)}vm_core.h
+object.$(OBJEXT): {$(VPATH)}vm_debug.h
+object.$(OBJEXT): {$(VPATH)}vm_opts.h
+object.$(OBJEXT): {$(VPATH)}vm_sync.h
+pack.$(OBJEXT): $(CCAN_DIR)/check_type/check_type.h
+pack.$(OBJEXT): $(CCAN_DIR)/container_of/container_of.h
+pack.$(OBJEXT): $(CCAN_DIR)/list/list.h
+pack.$(OBJEXT): $(CCAN_DIR)/str/str.h
pack.$(OBJEXT): $(hdrdir)/ruby/ruby.h
pack.$(OBJEXT): $(top_srcdir)/internal/array.h
+pack.$(OBJEXT): $(top_srcdir)/internal/basic_operators.h
pack.$(OBJEXT): $(top_srcdir)/internal/bits.h
pack.$(OBJEXT): $(top_srcdir)/internal/compilers.h
pack.$(OBJEXT): $(top_srcdir)/internal/gc.h
+pack.$(OBJEXT): $(top_srcdir)/internal/imemo.h
+pack.$(OBJEXT): $(top_srcdir)/internal/serial.h
pack.$(OBJEXT): $(top_srcdir)/internal/static_assert.h
pack.$(OBJEXT): $(top_srcdir)/internal/string.h
pack.$(OBJEXT): $(top_srcdir)/internal/symbol.h
pack.$(OBJEXT): $(top_srcdir)/internal/variable.h
+pack.$(OBJEXT): $(top_srcdir)/internal/vm.h
pack.$(OBJEXT): $(top_srcdir)/internal/warnings.h
pack.$(OBJEXT): {$(VPATH)}assert.h
+pack.$(OBJEXT): {$(VPATH)}atomic.h
pack.$(OBJEXT): {$(VPATH)}backward/2/assume.h
pack.$(OBJEXT): {$(VPATH)}backward/2/attributes.h
pack.$(OBJEXT): {$(VPATH)}backward/2/bool.h
@@ -10717,6 +11148,7 @@ pack.$(OBJEXT): {$(VPATH)}config.h
pack.$(OBJEXT): {$(VPATH)}constant.h
pack.$(OBJEXT): {$(VPATH)}defines.h
pack.$(OBJEXT): {$(VPATH)}encoding.h
+pack.$(OBJEXT): {$(VPATH)}id.h
pack.$(OBJEXT): {$(VPATH)}id_table.h
pack.$(OBJEXT): {$(VPATH)}intern.h
pack.$(OBJEXT): {$(VPATH)}internal.h
@@ -10758,6 +11190,7 @@ pack.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
pack.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
pack.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
pack.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
+pack.$(OBJEXT): {$(VPATH)}internal/attr/packed_struct.h
pack.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
pack.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
pack.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
@@ -10826,7 +11259,6 @@ pack.$(OBJEXT): {$(VPATH)}internal/intern/enumerator.h
pack.$(OBJEXT): {$(VPATH)}internal/intern/error.h
pack.$(OBJEXT): {$(VPATH)}internal/intern/eval.h
pack.$(OBJEXT): {$(VPATH)}internal/intern/file.h
-pack.$(OBJEXT): {$(VPATH)}internal/intern/gc.h
pack.$(OBJEXT): {$(VPATH)}internal/intern/hash.h
pack.$(OBJEXT): {$(VPATH)}internal/intern/io.h
pack.$(OBJEXT): {$(VPATH)}internal/intern/load.h
@@ -10857,7 +11289,6 @@ pack.$(OBJEXT): {$(VPATH)}internal/memory.h
pack.$(OBJEXT): {$(VPATH)}internal/method.h
pack.$(OBJEXT): {$(VPATH)}internal/module.h
pack.$(OBJEXT): {$(VPATH)}internal/newobj.h
-pack.$(OBJEXT): {$(VPATH)}internal/rgengc.h
pack.$(OBJEXT): {$(VPATH)}internal/scan_args.h
pack.$(OBJEXT): {$(VPATH)}internal/special_consts.h
pack.$(OBJEXT): {$(VPATH)}internal/static_assert.h
@@ -10869,18 +11300,33 @@ pack.$(OBJEXT): {$(VPATH)}internal/value_type.h
pack.$(OBJEXT): {$(VPATH)}internal/variable.h
pack.$(OBJEXT): {$(VPATH)}internal/warning_push.h
pack.$(OBJEXT): {$(VPATH)}internal/xmalloc.h
+pack.$(OBJEXT): {$(VPATH)}method.h
pack.$(OBJEXT): {$(VPATH)}missing.h
+pack.$(OBJEXT): {$(VPATH)}node.h
pack.$(OBJEXT): {$(VPATH)}onigmo.h
pack.$(OBJEXT): {$(VPATH)}oniguruma.h
pack.$(OBJEXT): {$(VPATH)}pack.c
pack.$(OBJEXT): {$(VPATH)}pack.rbinc
+pack.$(OBJEXT): {$(VPATH)}ruby_assert.h
+pack.$(OBJEXT): {$(VPATH)}ruby_atomic.h
+pack.$(OBJEXT): {$(VPATH)}rubyparser.h
pack.$(OBJEXT): {$(VPATH)}shape.h
pack.$(OBJEXT): {$(VPATH)}st.h
pack.$(OBJEXT): {$(VPATH)}subst.h
+pack.$(OBJEXT): {$(VPATH)}thread_$(THREAD_MODEL).h
+pack.$(OBJEXT): {$(VPATH)}thread_native.h
pack.$(OBJEXT): {$(VPATH)}util.h
+pack.$(OBJEXT): {$(VPATH)}vm_core.h
+pack.$(OBJEXT): {$(VPATH)}vm_opts.h
+parse.$(OBJEXT): $(CCAN_DIR)/check_type/check_type.h
+parse.$(OBJEXT): $(CCAN_DIR)/container_of/container_of.h
+parse.$(OBJEXT): $(CCAN_DIR)/list/list.h
+parse.$(OBJEXT): $(CCAN_DIR)/str/str.h
parse.$(OBJEXT): $(hdrdir)/ruby.h
parse.$(OBJEXT): $(hdrdir)/ruby/ruby.h
+parse.$(OBJEXT): $(hdrdir)/ruby/version.h
parse.$(OBJEXT): $(top_srcdir)/internal/array.h
+parse.$(OBJEXT): $(top_srcdir)/internal/basic_operators.h
parse.$(OBJEXT): $(top_srcdir)/internal/bignum.h
parse.$(OBJEXT): $(top_srcdir)/internal/bits.h
parse.$(OBJEXT): $(top_srcdir)/internal/compile.h
@@ -10897,6 +11343,7 @@ parse.$(OBJEXT): $(top_srcdir)/internal/numeric.h
parse.$(OBJEXT): $(top_srcdir)/internal/parse.h
parse.$(OBJEXT): $(top_srcdir)/internal/rational.h
parse.$(OBJEXT): $(top_srcdir)/internal/re.h
+parse.$(OBJEXT): $(top_srcdir)/internal/ruby_parser.h
parse.$(OBJEXT): $(top_srcdir)/internal/serial.h
parse.$(OBJEXT): $(top_srcdir)/internal/static_assert.h
parse.$(OBJEXT): $(top_srcdir)/internal/string.h
@@ -10906,6 +11353,7 @@ parse.$(OBJEXT): $(top_srcdir)/internal/variable.h
parse.$(OBJEXT): $(top_srcdir)/internal/vm.h
parse.$(OBJEXT): $(top_srcdir)/internal/warnings.h
parse.$(OBJEXT): {$(VPATH)}assert.h
+parse.$(OBJEXT): {$(VPATH)}atomic.h
parse.$(OBJEXT): {$(VPATH)}backward/2/assume.h
parse.$(OBJEXT): {$(VPATH)}backward/2/attributes.h
parse.$(OBJEXT): {$(VPATH)}backward/2/bool.h
@@ -10962,6 +11410,7 @@ parse.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
parse.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
parse.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
parse.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
+parse.$(OBJEXT): {$(VPATH)}internal/attr/packed_struct.h
parse.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
parse.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
parse.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
@@ -11030,7 +11479,6 @@ parse.$(OBJEXT): {$(VPATH)}internal/intern/enumerator.h
parse.$(OBJEXT): {$(VPATH)}internal/intern/error.h
parse.$(OBJEXT): {$(VPATH)}internal/intern/eval.h
parse.$(OBJEXT): {$(VPATH)}internal/intern/file.h
-parse.$(OBJEXT): {$(VPATH)}internal/intern/gc.h
parse.$(OBJEXT): {$(VPATH)}internal/intern/hash.h
parse.$(OBJEXT): {$(VPATH)}internal/intern/io.h
parse.$(OBJEXT): {$(VPATH)}internal/intern/load.h
@@ -11061,7 +11509,6 @@ parse.$(OBJEXT): {$(VPATH)}internal/memory.h
parse.$(OBJEXT): {$(VPATH)}internal/method.h
parse.$(OBJEXT): {$(VPATH)}internal/module.h
parse.$(OBJEXT): {$(VPATH)}internal/newobj.h
-parse.$(OBJEXT): {$(VPATH)}internal/rgengc.h
parse.$(OBJEXT): {$(VPATH)}internal/scan_args.h
parse.$(OBJEXT): {$(VPATH)}internal/special_consts.h
parse.$(OBJEXT): {$(VPATH)}internal/static_assert.h
@@ -11075,6 +11522,7 @@ parse.$(OBJEXT): {$(VPATH)}internal/warning_push.h
parse.$(OBJEXT): {$(VPATH)}internal/xmalloc.h
parse.$(OBJEXT): {$(VPATH)}io.h
parse.$(OBJEXT): {$(VPATH)}lex.c
+parse.$(OBJEXT): {$(VPATH)}method.h
parse.$(OBJEXT): {$(VPATH)}missing.h
parse.$(OBJEXT): {$(VPATH)}node.h
parse.$(OBJEXT): {$(VPATH)}onigmo.h
@@ -11082,22 +11530,1059 @@ parse.$(OBJEXT): {$(VPATH)}oniguruma.h
parse.$(OBJEXT): {$(VPATH)}parse.c
parse.$(OBJEXT): {$(VPATH)}parse.h
parse.$(OBJEXT): {$(VPATH)}parse.y
+parse.$(OBJEXT): {$(VPATH)}parser_node.h
+parse.$(OBJEXT): {$(VPATH)}parser_st.h
parse.$(OBJEXT): {$(VPATH)}probes.dmyh
parse.$(OBJEXT): {$(VPATH)}probes.h
parse.$(OBJEXT): {$(VPATH)}ractor.h
parse.$(OBJEXT): {$(VPATH)}regenc.h
parse.$(OBJEXT): {$(VPATH)}regex.h
parse.$(OBJEXT): {$(VPATH)}ruby_assert.h
+parse.$(OBJEXT): {$(VPATH)}ruby_atomic.h
+parse.$(OBJEXT): {$(VPATH)}rubyparser.h
parse.$(OBJEXT): {$(VPATH)}shape.h
parse.$(OBJEXT): {$(VPATH)}st.h
parse.$(OBJEXT): {$(VPATH)}subst.h
parse.$(OBJEXT): {$(VPATH)}symbol.h
+parse.$(OBJEXT): {$(VPATH)}thread_$(THREAD_MODEL).h
+parse.$(OBJEXT): {$(VPATH)}thread_native.h
parse.$(OBJEXT): {$(VPATH)}util.h
+parse.$(OBJEXT): {$(VPATH)}vm_core.h
+parse.$(OBJEXT): {$(VPATH)}vm_opts.h
+parser_st.$(OBJEXT): $(top_srcdir)/internal/compilers.h
+parser_st.$(OBJEXT): $(top_srcdir)/internal/static_assert.h
+parser_st.$(OBJEXT): $(top_srcdir)/internal/warnings.h
+parser_st.$(OBJEXT): {$(VPATH)}assert.h
+parser_st.$(OBJEXT): {$(VPATH)}backward/2/assume.h
+parser_st.$(OBJEXT): {$(VPATH)}backward/2/attributes.h
+parser_st.$(OBJEXT): {$(VPATH)}backward/2/bool.h
+parser_st.$(OBJEXT): {$(VPATH)}backward/2/gcc_version_since.h
+parser_st.$(OBJEXT): {$(VPATH)}backward/2/long_long.h
+parser_st.$(OBJEXT): {$(VPATH)}backward/2/stdalign.h
+parser_st.$(OBJEXT): {$(VPATH)}backward/2/stdarg.h
+parser_st.$(OBJEXT): {$(VPATH)}config.h
+parser_st.$(OBJEXT): {$(VPATH)}defines.h
+parser_st.$(OBJEXT): {$(VPATH)}internal/assume.h
+parser_st.$(OBJEXT): {$(VPATH)}internal/attr/alloc_size.h
+parser_st.$(OBJEXT): {$(VPATH)}internal/attr/cold.h
+parser_st.$(OBJEXT): {$(VPATH)}internal/attr/const.h
+parser_st.$(OBJEXT): {$(VPATH)}internal/attr/deprecated.h
+parser_st.$(OBJEXT): {$(VPATH)}internal/attr/error.h
+parser_st.$(OBJEXT): {$(VPATH)}internal/attr/forceinline.h
+parser_st.$(OBJEXT): {$(VPATH)}internal/attr/format.h
+parser_st.$(OBJEXT): {$(VPATH)}internal/attr/maybe_unused.h
+parser_st.$(OBJEXT): {$(VPATH)}internal/attr/nodiscard.h
+parser_st.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
+parser_st.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
+parser_st.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
+parser_st.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
+parser_st.$(OBJEXT): {$(VPATH)}internal/attr/packed_struct.h
+parser_st.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
+parser_st.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
+parser_st.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
+parser_st.$(OBJEXT): {$(VPATH)}internal/attr/warning.h
+parser_st.$(OBJEXT): {$(VPATH)}internal/cast.h
+parser_st.$(OBJEXT): {$(VPATH)}internal/compiler_is.h
+parser_st.$(OBJEXT): {$(VPATH)}internal/compiler_is/apple.h
+parser_st.$(OBJEXT): {$(VPATH)}internal/compiler_is/clang.h
+parser_st.$(OBJEXT): {$(VPATH)}internal/compiler_is/gcc.h
+parser_st.$(OBJEXT): {$(VPATH)}internal/compiler_is/intel.h
+parser_st.$(OBJEXT): {$(VPATH)}internal/compiler_is/msvc.h
+parser_st.$(OBJEXT): {$(VPATH)}internal/compiler_is/sunpro.h
+parser_st.$(OBJEXT): {$(VPATH)}internal/compiler_since.h
+parser_st.$(OBJEXT): {$(VPATH)}internal/config.h
+parser_st.$(OBJEXT): {$(VPATH)}internal/dllexport.h
+parser_st.$(OBJEXT): {$(VPATH)}internal/dosish.h
+parser_st.$(OBJEXT): {$(VPATH)}internal/has/attribute.h
+parser_st.$(OBJEXT): {$(VPATH)}internal/has/builtin.h
+parser_st.$(OBJEXT): {$(VPATH)}internal/has/c_attribute.h
+parser_st.$(OBJEXT): {$(VPATH)}internal/has/cpp_attribute.h
+parser_st.$(OBJEXT): {$(VPATH)}internal/has/declspec_attribute.h
+parser_st.$(OBJEXT): {$(VPATH)}internal/has/extension.h
+parser_st.$(OBJEXT): {$(VPATH)}internal/has/feature.h
+parser_st.$(OBJEXT): {$(VPATH)}internal/has/warning.h
+parser_st.$(OBJEXT): {$(VPATH)}internal/static_assert.h
+parser_st.$(OBJEXT): {$(VPATH)}internal/stdalign.h
+parser_st.$(OBJEXT): {$(VPATH)}internal/stdbool.h
+parser_st.$(OBJEXT): {$(VPATH)}internal/warning_push.h
+parser_st.$(OBJEXT): {$(VPATH)}internal/xmalloc.h
+parser_st.$(OBJEXT): {$(VPATH)}missing.h
+parser_st.$(OBJEXT): {$(VPATH)}parser_bits.h
+parser_st.$(OBJEXT): {$(VPATH)}parser_st.c
+parser_st.$(OBJEXT): {$(VPATH)}parser_st.h
+parser_st.$(OBJEXT): {$(VPATH)}parser_value.h
+parser_st.$(OBJEXT): {$(VPATH)}st.c
+prism/api_node.$(OBJEXT): $(hdrdir)/ruby.h
+prism/api_node.$(OBJEXT): $(hdrdir)/ruby/ruby.h
+prism/api_node.$(OBJEXT): $(top_srcdir)/prism/defines.h
+prism/api_node.$(OBJEXT): $(top_srcdir)/prism/diagnostic.h
+prism/api_node.$(OBJEXT): $(top_srcdir)/prism/encoding.h
+prism/api_node.$(OBJEXT): $(top_srcdir)/prism/extension.h
+prism/api_node.$(OBJEXT): $(top_srcdir)/prism/node.h
+prism/api_node.$(OBJEXT): $(top_srcdir)/prism/options.h
+prism/api_node.$(OBJEXT): $(top_srcdir)/prism/pack.h
+prism/api_node.$(OBJEXT): $(top_srcdir)/prism/parser.h
+prism/api_node.$(OBJEXT): $(top_srcdir)/prism/prettyprint.h
+prism/api_node.$(OBJEXT): $(top_srcdir)/prism/prism.h
+prism/api_node.$(OBJEXT): $(top_srcdir)/prism/regexp.h
+prism/api_node.$(OBJEXT): $(top_srcdir)/prism/util/pm_buffer.h
+prism/api_node.$(OBJEXT): $(top_srcdir)/prism/util/pm_char.h
+prism/api_node.$(OBJEXT): $(top_srcdir)/prism/util/pm_constant_pool.h
+prism/api_node.$(OBJEXT): $(top_srcdir)/prism/util/pm_list.h
+prism/api_node.$(OBJEXT): $(top_srcdir)/prism/util/pm_memchr.h
+prism/api_node.$(OBJEXT): $(top_srcdir)/prism/util/pm_newline_list.h
+prism/api_node.$(OBJEXT): $(top_srcdir)/prism/util/pm_state_stack.h
+prism/api_node.$(OBJEXT): $(top_srcdir)/prism/util/pm_string.h
+prism/api_node.$(OBJEXT): $(top_srcdir)/prism/util/pm_string_list.h
+prism/api_node.$(OBJEXT): $(top_srcdir)/prism/util/pm_strncasecmp.h
+prism/api_node.$(OBJEXT): $(top_srcdir)/prism/util/pm_strpbrk.h
+prism/api_node.$(OBJEXT): {$(VPATH)}assert.h
+prism/api_node.$(OBJEXT): {$(VPATH)}backward/2/assume.h
+prism/api_node.$(OBJEXT): {$(VPATH)}backward/2/attributes.h
+prism/api_node.$(OBJEXT): {$(VPATH)}backward/2/bool.h
+prism/api_node.$(OBJEXT): {$(VPATH)}backward/2/inttypes.h
+prism/api_node.$(OBJEXT): {$(VPATH)}backward/2/limits.h
+prism/api_node.$(OBJEXT): {$(VPATH)}backward/2/long_long.h
+prism/api_node.$(OBJEXT): {$(VPATH)}backward/2/stdalign.h
+prism/api_node.$(OBJEXT): {$(VPATH)}backward/2/stdarg.h
+prism/api_node.$(OBJEXT): {$(VPATH)}config.h
+prism/api_node.$(OBJEXT): {$(VPATH)}defines.h
+prism/api_node.$(OBJEXT): {$(VPATH)}encoding.h
+prism/api_node.$(OBJEXT): {$(VPATH)}intern.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/abi.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/anyargs.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/arithmetic.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/arithmetic/char.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/arithmetic/double.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/arithmetic/fixnum.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/arithmetic/gid_t.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/arithmetic/int.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/arithmetic/intptr_t.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/arithmetic/long.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/arithmetic/long_long.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/arithmetic/mode_t.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/arithmetic/off_t.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/arithmetic/pid_t.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/arithmetic/short.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/arithmetic/size_t.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/arithmetic/st_data_t.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/arithmetic/uid_t.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/assume.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/attr/alloc_size.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/attr/artificial.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/attr/cold.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/attr/const.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/attr/constexpr.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/attr/deprecated.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/attr/diagnose_if.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/attr/enum_extensibility.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/attr/error.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/attr/flag_enum.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/attr/forceinline.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/attr/format.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/attr/maybe_unused.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/attr/noalias.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/attr/nodiscard.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/attr/packed_struct.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/attr/warning.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/attr/weakref.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/cast.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/compiler_is.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/compiler_is/apple.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/compiler_is/clang.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/compiler_is/gcc.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/compiler_is/intel.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/compiler_is/msvc.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/compiler_is/sunpro.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/compiler_since.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/config.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/constant_p.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/core.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/core/rarray.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/core/rbasic.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/core/rbignum.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/core/rclass.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/core/rdata.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/core/rfile.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/core/rhash.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/core/robject.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/core/rregexp.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/core/rstring.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/core/rstruct.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/core/rtypeddata.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/ctype.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/dllexport.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/dosish.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/encoding/coderange.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/encoding/ctype.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/encoding/encoding.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/encoding/pathname.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/encoding/re.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/encoding/sprintf.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/encoding/string.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/encoding/symbol.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/encoding/transcode.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/error.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/eval.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/event.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/fl_type.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/gc.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/glob.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/globals.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/has/attribute.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/has/builtin.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/has/c_attribute.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/has/cpp_attribute.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/has/declspec_attribute.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/has/extension.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/has/feature.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/has/warning.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/intern/array.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/intern/bignum.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/intern/class.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/intern/compar.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/intern/complex.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/intern/cont.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/intern/dir.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/intern/enum.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/intern/enumerator.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/intern/error.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/intern/eval.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/intern/file.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/intern/hash.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/intern/io.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/intern/load.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/intern/marshal.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/intern/numeric.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/intern/object.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/intern/parse.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/intern/proc.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/intern/process.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/intern/random.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/intern/range.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/intern/rational.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/intern/re.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/intern/ruby.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/intern/select.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/intern/select/largesize.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/intern/signal.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/intern/sprintf.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/intern/string.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/intern/struct.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/intern/thread.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/intern/time.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/intern/variable.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/intern/vm.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/interpreter.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/iterator.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/memory.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/method.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/module.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/newobj.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/scan_args.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/special_consts.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/static_assert.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/stdalign.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/stdbool.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/symbol.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/value.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/value_type.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/variable.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/warning_push.h
+prism/api_node.$(OBJEXT): {$(VPATH)}internal/xmalloc.h
+prism/api_node.$(OBJEXT): {$(VPATH)}missing.h
+prism/api_node.$(OBJEXT): {$(VPATH)}onigmo.h
+prism/api_node.$(OBJEXT): {$(VPATH)}oniguruma.h
+prism/api_node.$(OBJEXT): {$(VPATH)}prism/api_node.c
+prism/api_node.$(OBJEXT): {$(VPATH)}prism/ast.h
+prism/api_node.$(OBJEXT): {$(VPATH)}prism/version.h
+prism/api_node.$(OBJEXT): {$(VPATH)}st.h
+prism/api_node.$(OBJEXT): {$(VPATH)}subst.h
+prism/api_pack.$(OBJEXT): $(hdrdir)/ruby.h
+prism/api_pack.$(OBJEXT): $(hdrdir)/ruby/ruby.h
+prism/api_pack.$(OBJEXT): $(top_srcdir)/prism/api_pack.c
+prism/api_pack.$(OBJEXT): $(top_srcdir)/prism/defines.h
+prism/api_pack.$(OBJEXT): $(top_srcdir)/prism/diagnostic.h
+prism/api_pack.$(OBJEXT): $(top_srcdir)/prism/encoding.h
+prism/api_pack.$(OBJEXT): $(top_srcdir)/prism/extension.h
+prism/api_pack.$(OBJEXT): $(top_srcdir)/prism/node.h
+prism/api_pack.$(OBJEXT): $(top_srcdir)/prism/options.h
+prism/api_pack.$(OBJEXT): $(top_srcdir)/prism/pack.h
+prism/api_pack.$(OBJEXT): $(top_srcdir)/prism/parser.h
+prism/api_pack.$(OBJEXT): $(top_srcdir)/prism/prettyprint.h
+prism/api_pack.$(OBJEXT): $(top_srcdir)/prism/prism.h
+prism/api_pack.$(OBJEXT): $(top_srcdir)/prism/regexp.h
+prism/api_pack.$(OBJEXT): $(top_srcdir)/prism/util/pm_buffer.h
+prism/api_pack.$(OBJEXT): $(top_srcdir)/prism/util/pm_char.h
+prism/api_pack.$(OBJEXT): $(top_srcdir)/prism/util/pm_constant_pool.h
+prism/api_pack.$(OBJEXT): $(top_srcdir)/prism/util/pm_list.h
+prism/api_pack.$(OBJEXT): $(top_srcdir)/prism/util/pm_memchr.h
+prism/api_pack.$(OBJEXT): $(top_srcdir)/prism/util/pm_newline_list.h
+prism/api_pack.$(OBJEXT): $(top_srcdir)/prism/util/pm_state_stack.h
+prism/api_pack.$(OBJEXT): $(top_srcdir)/prism/util/pm_string.h
+prism/api_pack.$(OBJEXT): $(top_srcdir)/prism/util/pm_string_list.h
+prism/api_pack.$(OBJEXT): $(top_srcdir)/prism/util/pm_strncasecmp.h
+prism/api_pack.$(OBJEXT): $(top_srcdir)/prism/util/pm_strpbrk.h
+prism/api_pack.$(OBJEXT): {$(VPATH)}assert.h
+prism/api_pack.$(OBJEXT): {$(VPATH)}backward/2/assume.h
+prism/api_pack.$(OBJEXT): {$(VPATH)}backward/2/attributes.h
+prism/api_pack.$(OBJEXT): {$(VPATH)}backward/2/bool.h
+prism/api_pack.$(OBJEXT): {$(VPATH)}backward/2/inttypes.h
+prism/api_pack.$(OBJEXT): {$(VPATH)}backward/2/limits.h
+prism/api_pack.$(OBJEXT): {$(VPATH)}backward/2/long_long.h
+prism/api_pack.$(OBJEXT): {$(VPATH)}backward/2/stdalign.h
+prism/api_pack.$(OBJEXT): {$(VPATH)}backward/2/stdarg.h
+prism/api_pack.$(OBJEXT): {$(VPATH)}config.h
+prism/api_pack.$(OBJEXT): {$(VPATH)}defines.h
+prism/api_pack.$(OBJEXT): {$(VPATH)}encoding.h
+prism/api_pack.$(OBJEXT): {$(VPATH)}intern.h
+prism/api_pack.$(OBJEXT): {$(VPATH)}internal/abi.h
+prism/api_pack.$(OBJEXT): {$(VPATH)}internal/anyargs.h
+prism/api_pack.$(OBJEXT): {$(VPATH)}internal/arithmetic.h
+prism/api_pack.$(OBJEXT): {$(VPATH)}internal/arithmetic/char.h
+prism/api_pack.$(OBJEXT): {$(VPATH)}internal/arithmetic/double.h
+prism/api_pack.$(OBJEXT): {$(VPATH)}internal/arithmetic/fixnum.h
+prism/api_pack.$(OBJEXT): {$(VPATH)}internal/arithmetic/gid_t.h
+prism/api_pack.$(OBJEXT): {$(VPATH)}internal/arithmetic/int.h
+prism/api_pack.$(OBJEXT): {$(VPATH)}internal/arithmetic/intptr_t.h
+prism/api_pack.$(OBJEXT): {$(VPATH)}internal/arithmetic/long.h
+prism/api_pack.$(OBJEXT): {$(VPATH)}internal/arithmetic/long_long.h
+prism/api_pack.$(OBJEXT): {$(VPATH)}internal/arithmetic/mode_t.h
+prism/api_pack.$(OBJEXT): {$(VPATH)}internal/arithmetic/off_t.h
+prism/api_pack.$(OBJEXT): {$(VPATH)}internal/arithmetic/pid_t.h
+prism/api_pack.$(OBJEXT): {$(VPATH)}internal/arithmetic/short.h
+prism/api_pack.$(OBJEXT): {$(VPATH)}internal/arithmetic/size_t.h
+prism/api_pack.$(OBJEXT): {$(VPATH)}internal/arithmetic/st_data_t.h
+prism/api_pack.$(OBJEXT): {$(VPATH)}internal/arithmetic/uid_t.h
+prism/api_pack.$(OBJEXT): {$(VPATH)}internal/assume.h
+prism/api_pack.$(OBJEXT): {$(VPATH)}internal/attr/alloc_size.h
+prism/api_pack.$(OBJEXT): {$(VPATH)}internal/attr/artificial.h
+prism/api_pack.$(OBJEXT): {$(VPATH)}internal/attr/cold.h
+prism/api_pack.$(OBJEXT): {$(VPATH)}internal/attr/const.h
+prism/api_pack.$(OBJEXT): {$(VPATH)}internal/attr/constexpr.h
+prism/api_pack.$(OBJEXT): {$(VPATH)}internal/attr/deprecated.h
+prism/api_pack.$(OBJEXT): {$(VPATH)}internal/attr/diagnose_if.h
+prism/api_pack.$(OBJEXT): {$(VPATH)}internal/attr/enum_extensibility.h
+prism/api_pack.$(OBJEXT): {$(VPATH)}internal/attr/error.h
+prism/api_pack.$(OBJEXT): {$(VPATH)}internal/attr/flag_enum.h
+prism/api_pack.$(OBJEXT): {$(VPATH)}internal/attr/forceinline.h
+prism/api_pack.$(OBJEXT): {$(VPATH)}internal/attr/format.h
+prism/api_pack.$(OBJEXT): {$(VPATH)}internal/attr/maybe_unused.h
+prism/api_pack.$(OBJEXT): {$(VPATH)}internal/attr/noalias.h
+prism/api_pack.$(OBJEXT): {$(VPATH)}internal/attr/nodiscard.h
+prism/api_pack.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
+prism/api_pack.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
+prism/api_pack.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
+prism/api_pack.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
+prism/api_pack.$(OBJEXT): {$(VPATH)}internal/attr/packed_struct.h
+prism/api_pack.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
+prism/api_pack.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
+prism/api_pack.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
+prism/api_pack.$(OBJEXT): {$(VPATH)}internal/attr/warning.h
+prism/api_pack.$(OBJEXT): {$(VPATH)}internal/attr/weakref.h
+prism/api_pack.$(OBJEXT): {$(VPATH)}internal/cast.h
+prism/api_pack.$(OBJEXT): {$(VPATH)}internal/compiler_is.h
+prism/api_pack.$(OBJEXT): {$(VPATH)}internal/compiler_is/apple.h
+prism/api_pack.$(OBJEXT): {$(VPATH)}internal/compiler_is/clang.h
+prism/api_pack.$(OBJEXT): {$(VPATH)}internal/compiler_is/gcc.h
+prism/api_pack.$(OBJEXT): {$(VPATH)}internal/compiler_is/intel.h
+prism/api_pack.$(OBJEXT): {$(VPATH)}internal/compiler_is/msvc.h
+prism/api_pack.$(OBJEXT): {$(VPATH)}internal/compiler_is/sunpro.h
+prism/api_pack.$(OBJEXT): {$(VPATH)}internal/compiler_since.h
+prism/api_pack.$(OBJEXT): {$(VPATH)}internal/config.h
+prism/api_pack.$(OBJEXT): {$(VPATH)}internal/constant_p.h
+prism/api_pack.$(OBJEXT): {$(VPATH)}internal/core.h
+prism/api_pack.$(OBJEXT): {$(VPATH)}internal/core/rarray.h
+prism/api_pack.$(OBJEXT): {$(VPATH)}internal/core/rbasic.h
+prism/api_pack.$(OBJEXT): {$(VPATH)}internal/core/rbignum.h
+prism/api_pack.$(OBJEXT): {$(VPATH)}internal/core/rclass.h
+prism/api_pack.$(OBJEXT): {$(VPATH)}internal/core/rdata.h
+prism/api_pack.$(OBJEXT): {$(VPATH)}internal/core/rfile.h
+prism/api_pack.$(OBJEXT): {$(VPATH)}internal/core/rhash.h
+prism/api_pack.$(OBJEXT): {$(VPATH)}internal/core/robject.h
+prism/api_pack.$(OBJEXT): {$(VPATH)}internal/core/rregexp.h
+prism/api_pack.$(OBJEXT): {$(VPATH)}internal/core/rstring.h
+prism/api_pack.$(OBJEXT): {$(VPATH)}internal/core/rstruct.h
+prism/api_pack.$(OBJEXT): {$(VPATH)}internal/core/rtypeddata.h
+prism/api_pack.$(OBJEXT): {$(VPATH)}internal/ctype.h
+prism/api_pack.$(OBJEXT): {$(VPATH)}internal/dllexport.h
+prism/api_pack.$(OBJEXT): {$(VPATH)}internal/dosish.h
+prism/api_pack.$(OBJEXT): {$(VPATH)}internal/encoding/coderange.h
+prism/api_pack.$(OBJEXT): {$(VPATH)}internal/encoding/ctype.h
+prism/api_pack.$(OBJEXT): {$(VPATH)}internal/encoding/encoding.h
+prism/api_pack.$(OBJEXT): {$(VPATH)}internal/encoding/pathname.h
+prism/api_pack.$(OBJEXT): {$(VPATH)}internal/encoding/re.h
+prism/api_pack.$(OBJEXT): {$(VPATH)}internal/encoding/sprintf.h
+prism/api_pack.$(OBJEXT): {$(VPATH)}internal/encoding/string.h
+prism/api_pack.$(OBJEXT): {$(VPATH)}internal/encoding/symbol.h
+prism/api_pack.$(OBJEXT): {$(VPATH)}internal/encoding/transcode.h
+prism/api_pack.$(OBJEXT): {$(VPATH)}internal/error.h
+prism/api_pack.$(OBJEXT): {$(VPATH)}internal/eval.h
+prism/api_pack.$(OBJEXT): {$(VPATH)}internal/event.h
+prism/api_pack.$(OBJEXT): {$(VPATH)}internal/fl_type.h
+prism/api_pack.$(OBJEXT): {$(VPATH)}internal/gc.h
+prism/api_pack.$(OBJEXT): {$(VPATH)}internal/glob.h
+prism/api_pack.$(OBJEXT): {$(VPATH)}internal/globals.h
+prism/api_pack.$(OBJEXT): {$(VPATH)}internal/has/attribute.h
+prism/api_pack.$(OBJEXT): {$(VPATH)}internal/has/builtin.h
+prism/api_pack.$(OBJEXT): {$(VPATH)}internal/has/c_attribute.h
+prism/api_pack.$(OBJEXT): {$(VPATH)}internal/has/cpp_attribute.h
+prism/api_pack.$(OBJEXT): {$(VPATH)}internal/has/declspec_attribute.h
+prism/api_pack.$(OBJEXT): {$(VPATH)}internal/has/extension.h
+prism/api_pack.$(OBJEXT): {$(VPATH)}internal/has/feature.h
+prism/api_pack.$(OBJEXT): {$(VPATH)}internal/has/warning.h
+prism/api_pack.$(OBJEXT): {$(VPATH)}internal/intern/array.h
+prism/api_pack.$(OBJEXT): {$(VPATH)}internal/intern/bignum.h
+prism/api_pack.$(OBJEXT): {$(VPATH)}internal/intern/class.h
+prism/api_pack.$(OBJEXT): {$(VPATH)}internal/intern/compar.h
+prism/api_pack.$(OBJEXT): {$(VPATH)}internal/intern/complex.h
+prism/api_pack.$(OBJEXT): {$(VPATH)}internal/intern/cont.h
+prism/api_pack.$(OBJEXT): {$(VPATH)}internal/intern/dir.h
+prism/api_pack.$(OBJEXT): {$(VPATH)}internal/intern/enum.h
+prism/api_pack.$(OBJEXT): {$(VPATH)}internal/intern/enumerator.h
+prism/api_pack.$(OBJEXT): {$(VPATH)}internal/intern/error.h
+prism/api_pack.$(OBJEXT): {$(VPATH)}internal/intern/eval.h
+prism/api_pack.$(OBJEXT): {$(VPATH)}internal/intern/file.h
+prism/api_pack.$(OBJEXT): {$(VPATH)}internal/intern/hash.h
+prism/api_pack.$(OBJEXT): {$(VPATH)}internal/intern/io.h
+prism/api_pack.$(OBJEXT): {$(VPATH)}internal/intern/load.h
+prism/api_pack.$(OBJEXT): {$(VPATH)}internal/intern/marshal.h
+prism/api_pack.$(OBJEXT): {$(VPATH)}internal/intern/numeric.h
+prism/api_pack.$(OBJEXT): {$(VPATH)}internal/intern/object.h
+prism/api_pack.$(OBJEXT): {$(VPATH)}internal/intern/parse.h
+prism/api_pack.$(OBJEXT): {$(VPATH)}internal/intern/proc.h
+prism/api_pack.$(OBJEXT): {$(VPATH)}internal/intern/process.h
+prism/api_pack.$(OBJEXT): {$(VPATH)}internal/intern/random.h
+prism/api_pack.$(OBJEXT): {$(VPATH)}internal/intern/range.h
+prism/api_pack.$(OBJEXT): {$(VPATH)}internal/intern/rational.h
+prism/api_pack.$(OBJEXT): {$(VPATH)}internal/intern/re.h
+prism/api_pack.$(OBJEXT): {$(VPATH)}internal/intern/ruby.h
+prism/api_pack.$(OBJEXT): {$(VPATH)}internal/intern/select.h
+prism/api_pack.$(OBJEXT): {$(VPATH)}internal/intern/select/largesize.h
+prism/api_pack.$(OBJEXT): {$(VPATH)}internal/intern/signal.h
+prism/api_pack.$(OBJEXT): {$(VPATH)}internal/intern/sprintf.h
+prism/api_pack.$(OBJEXT): {$(VPATH)}internal/intern/string.h
+prism/api_pack.$(OBJEXT): {$(VPATH)}internal/intern/struct.h
+prism/api_pack.$(OBJEXT): {$(VPATH)}internal/intern/thread.h
+prism/api_pack.$(OBJEXT): {$(VPATH)}internal/intern/time.h
+prism/api_pack.$(OBJEXT): {$(VPATH)}internal/intern/variable.h
+prism/api_pack.$(OBJEXT): {$(VPATH)}internal/intern/vm.h
+prism/api_pack.$(OBJEXT): {$(VPATH)}internal/interpreter.h
+prism/api_pack.$(OBJEXT): {$(VPATH)}internal/iterator.h
+prism/api_pack.$(OBJEXT): {$(VPATH)}internal/memory.h
+prism/api_pack.$(OBJEXT): {$(VPATH)}internal/method.h
+prism/api_pack.$(OBJEXT): {$(VPATH)}internal/module.h
+prism/api_pack.$(OBJEXT): {$(VPATH)}internal/newobj.h
+prism/api_pack.$(OBJEXT): {$(VPATH)}internal/scan_args.h
+prism/api_pack.$(OBJEXT): {$(VPATH)}internal/special_consts.h
+prism/api_pack.$(OBJEXT): {$(VPATH)}internal/static_assert.h
+prism/api_pack.$(OBJEXT): {$(VPATH)}internal/stdalign.h
+prism/api_pack.$(OBJEXT): {$(VPATH)}internal/stdbool.h
+prism/api_pack.$(OBJEXT): {$(VPATH)}internal/symbol.h
+prism/api_pack.$(OBJEXT): {$(VPATH)}internal/value.h
+prism/api_pack.$(OBJEXT): {$(VPATH)}internal/value_type.h
+prism/api_pack.$(OBJEXT): {$(VPATH)}internal/variable.h
+prism/api_pack.$(OBJEXT): {$(VPATH)}internal/warning_push.h
+prism/api_pack.$(OBJEXT): {$(VPATH)}internal/xmalloc.h
+prism/api_pack.$(OBJEXT): {$(VPATH)}missing.h
+prism/api_pack.$(OBJEXT): {$(VPATH)}onigmo.h
+prism/api_pack.$(OBJEXT): {$(VPATH)}oniguruma.h
+prism/api_pack.$(OBJEXT): {$(VPATH)}prism/ast.h
+prism/api_pack.$(OBJEXT): {$(VPATH)}prism/version.h
+prism/api_pack.$(OBJEXT): {$(VPATH)}st.h
+prism/api_pack.$(OBJEXT): {$(VPATH)}subst.h
+prism/diagnostic.$(OBJEXT): $(top_srcdir)/prism/defines.h
+prism/diagnostic.$(OBJEXT): $(top_srcdir)/prism/diagnostic.c
+prism/diagnostic.$(OBJEXT): $(top_srcdir)/prism/diagnostic.h
+prism/diagnostic.$(OBJEXT): $(top_srcdir)/prism/util/pm_constant_pool.h
+prism/diagnostic.$(OBJEXT): $(top_srcdir)/prism/util/pm_list.h
+prism/diagnostic.$(OBJEXT): $(top_srcdir)/prism/util/pm_string.h
+prism/diagnostic.$(OBJEXT): {$(VPATH)}config.h
+prism/diagnostic.$(OBJEXT): {$(VPATH)}prism/ast.h
+prism/encoding.$(OBJEXT): $(top_srcdir)/prism/defines.h
+prism/encoding.$(OBJEXT): $(top_srcdir)/prism/encoding.c
+prism/encoding.$(OBJEXT): $(top_srcdir)/prism/encoding.h
+prism/encoding.$(OBJEXT): $(top_srcdir)/prism/util/pm_strncasecmp.h
+prism/encoding.$(OBJEXT): {$(VPATH)}config.h
+prism/extension.$(OBJEXT): $(hdrdir)/ruby.h
+prism/extension.$(OBJEXT): $(hdrdir)/ruby/ruby.h
+prism/extension.$(OBJEXT): $(top_srcdir)/prism/defines.h
+prism/extension.$(OBJEXT): $(top_srcdir)/prism/diagnostic.h
+prism/extension.$(OBJEXT): $(top_srcdir)/prism/encoding.h
+prism/extension.$(OBJEXT): $(top_srcdir)/prism/extension.c
+prism/extension.$(OBJEXT): $(top_srcdir)/prism/extension.h
+prism/extension.$(OBJEXT): $(top_srcdir)/prism/node.h
+prism/extension.$(OBJEXT): $(top_srcdir)/prism/options.h
+prism/extension.$(OBJEXT): $(top_srcdir)/prism/pack.h
+prism/extension.$(OBJEXT): $(top_srcdir)/prism/parser.h
+prism/extension.$(OBJEXT): $(top_srcdir)/prism/prettyprint.h
+prism/extension.$(OBJEXT): $(top_srcdir)/prism/prism.h
+prism/extension.$(OBJEXT): $(top_srcdir)/prism/regexp.h
+prism/extension.$(OBJEXT): $(top_srcdir)/prism/util/pm_buffer.h
+prism/extension.$(OBJEXT): $(top_srcdir)/prism/util/pm_char.h
+prism/extension.$(OBJEXT): $(top_srcdir)/prism/util/pm_constant_pool.h
+prism/extension.$(OBJEXT): $(top_srcdir)/prism/util/pm_list.h
+prism/extension.$(OBJEXT): $(top_srcdir)/prism/util/pm_memchr.h
+prism/extension.$(OBJEXT): $(top_srcdir)/prism/util/pm_newline_list.h
+prism/extension.$(OBJEXT): $(top_srcdir)/prism/util/pm_state_stack.h
+prism/extension.$(OBJEXT): $(top_srcdir)/prism/util/pm_string.h
+prism/extension.$(OBJEXT): $(top_srcdir)/prism/util/pm_string_list.h
+prism/extension.$(OBJEXT): $(top_srcdir)/prism/util/pm_strncasecmp.h
+prism/extension.$(OBJEXT): $(top_srcdir)/prism/util/pm_strpbrk.h
+prism/extension.$(OBJEXT): {$(VPATH)}assert.h
+prism/extension.$(OBJEXT): {$(VPATH)}backward/2/assume.h
+prism/extension.$(OBJEXT): {$(VPATH)}backward/2/attributes.h
+prism/extension.$(OBJEXT): {$(VPATH)}backward/2/bool.h
+prism/extension.$(OBJEXT): {$(VPATH)}backward/2/inttypes.h
+prism/extension.$(OBJEXT): {$(VPATH)}backward/2/limits.h
+prism/extension.$(OBJEXT): {$(VPATH)}backward/2/long_long.h
+prism/extension.$(OBJEXT): {$(VPATH)}backward/2/stdalign.h
+prism/extension.$(OBJEXT): {$(VPATH)}backward/2/stdarg.h
+prism/extension.$(OBJEXT): {$(VPATH)}config.h
+prism/extension.$(OBJEXT): {$(VPATH)}defines.h
+prism/extension.$(OBJEXT): {$(VPATH)}encoding.h
+prism/extension.$(OBJEXT): {$(VPATH)}intern.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/abi.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/anyargs.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/arithmetic.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/arithmetic/char.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/arithmetic/double.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/arithmetic/fixnum.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/arithmetic/gid_t.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/arithmetic/int.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/arithmetic/intptr_t.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/arithmetic/long.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/arithmetic/long_long.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/arithmetic/mode_t.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/arithmetic/off_t.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/arithmetic/pid_t.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/arithmetic/short.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/arithmetic/size_t.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/arithmetic/st_data_t.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/arithmetic/uid_t.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/assume.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/attr/alloc_size.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/attr/artificial.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/attr/cold.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/attr/const.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/attr/constexpr.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/attr/deprecated.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/attr/diagnose_if.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/attr/enum_extensibility.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/attr/error.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/attr/flag_enum.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/attr/forceinline.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/attr/format.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/attr/maybe_unused.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/attr/noalias.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/attr/nodiscard.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/attr/packed_struct.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/attr/warning.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/attr/weakref.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/cast.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/compiler_is.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/compiler_is/apple.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/compiler_is/clang.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/compiler_is/gcc.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/compiler_is/intel.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/compiler_is/msvc.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/compiler_is/sunpro.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/compiler_since.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/config.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/constant_p.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/core.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/core/rarray.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/core/rbasic.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/core/rbignum.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/core/rclass.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/core/rdata.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/core/rfile.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/core/rhash.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/core/robject.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/core/rregexp.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/core/rstring.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/core/rstruct.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/core/rtypeddata.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/ctype.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/dllexport.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/dosish.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/encoding/coderange.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/encoding/ctype.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/encoding/encoding.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/encoding/pathname.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/encoding/re.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/encoding/sprintf.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/encoding/string.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/encoding/symbol.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/encoding/transcode.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/error.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/eval.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/event.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/fl_type.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/gc.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/glob.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/globals.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/has/attribute.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/has/builtin.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/has/c_attribute.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/has/cpp_attribute.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/has/declspec_attribute.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/has/extension.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/has/feature.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/has/warning.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/intern/array.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/intern/bignum.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/intern/class.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/intern/compar.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/intern/complex.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/intern/cont.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/intern/dir.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/intern/enum.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/intern/enumerator.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/intern/error.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/intern/eval.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/intern/file.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/intern/hash.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/intern/io.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/intern/load.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/intern/marshal.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/intern/numeric.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/intern/object.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/intern/parse.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/intern/proc.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/intern/process.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/intern/random.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/intern/range.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/intern/rational.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/intern/re.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/intern/ruby.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/intern/select.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/intern/select/largesize.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/intern/signal.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/intern/sprintf.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/intern/string.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/intern/struct.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/intern/thread.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/intern/time.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/intern/variable.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/intern/vm.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/interpreter.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/iterator.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/memory.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/method.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/module.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/newobj.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/scan_args.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/special_consts.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/static_assert.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/stdalign.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/stdbool.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/symbol.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/value.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/value_type.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/variable.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/warning_push.h
+prism/extension.$(OBJEXT): {$(VPATH)}internal/xmalloc.h
+prism/extension.$(OBJEXT): {$(VPATH)}missing.h
+prism/extension.$(OBJEXT): {$(VPATH)}onigmo.h
+prism/extension.$(OBJEXT): {$(VPATH)}oniguruma.h
+prism/extension.$(OBJEXT): {$(VPATH)}prism/ast.h
+prism/extension.$(OBJEXT): {$(VPATH)}prism/version.h
+prism/extension.$(OBJEXT): {$(VPATH)}st.h
+prism/extension.$(OBJEXT): {$(VPATH)}subst.h
+prism/node.$(OBJEXT): $(top_srcdir)/prism/defines.h
+prism/node.$(OBJEXT): $(top_srcdir)/prism/diagnostic.h
+prism/node.$(OBJEXT): $(top_srcdir)/prism/encoding.h
+prism/node.$(OBJEXT): $(top_srcdir)/prism/node.h
+prism/node.$(OBJEXT): $(top_srcdir)/prism/options.h
+prism/node.$(OBJEXT): $(top_srcdir)/prism/pack.h
+prism/node.$(OBJEXT): $(top_srcdir)/prism/parser.h
+prism/node.$(OBJEXT): $(top_srcdir)/prism/prism.h
+prism/node.$(OBJEXT): $(top_srcdir)/prism/regexp.h
+prism/node.$(OBJEXT): $(top_srcdir)/prism/util/pm_buffer.h
+prism/node.$(OBJEXT): $(top_srcdir)/prism/util/pm_char.h
+prism/node.$(OBJEXT): $(top_srcdir)/prism/util/pm_constant_pool.h
+prism/node.$(OBJEXT): $(top_srcdir)/prism/util/pm_list.h
+prism/node.$(OBJEXT): $(top_srcdir)/prism/util/pm_newline_list.h
+prism/node.$(OBJEXT): $(top_srcdir)/prism/util/pm_state_stack.h
+prism/node.$(OBJEXT): $(top_srcdir)/prism/util/pm_string.h
+prism/node.$(OBJEXT): $(top_srcdir)/prism/util/pm_string_list.h
+prism/node.$(OBJEXT): $(top_srcdir)/prism/util/pm_strncasecmp.h
+prism/node.$(OBJEXT): $(top_srcdir)/prism/util/pm_strpbrk.h
+prism/node.$(OBJEXT): {$(VPATH)}config.h
+prism/node.$(OBJEXT): {$(VPATH)}prism/ast.h
+prism/node.$(OBJEXT): {$(VPATH)}prism/node.c
+prism/options.$(OBJEXT): $(top_srcdir)/prism/defines.h
+prism/options.$(OBJEXT): $(top_srcdir)/prism/options.c
+prism/options.$(OBJEXT): $(top_srcdir)/prism/options.h
+prism/options.$(OBJEXT): $(top_srcdir)/prism/util/pm_string.h
+prism/pack.$(OBJEXT): $(top_srcdir)/prism/defines.h
+prism/pack.$(OBJEXT): $(top_srcdir)/prism/pack.c
+prism/pack.$(OBJEXT): $(top_srcdir)/prism/pack.h
+prism/pack.$(OBJEXT): {$(VPATH)}config.h
+prism/prettyprint.$(OBJEXT): $(top_srcdir)/prism/defines.h
+prism/prettyprint.$(OBJEXT): $(top_srcdir)/prism/encoding.h
+prism/prettyprint.$(OBJEXT): $(top_srcdir)/prism/parser.h
+prism/prettyprint.$(OBJEXT): $(top_srcdir)/prism/prettyprint.h
+prism/prettyprint.$(OBJEXT): $(top_srcdir)/prism/util/pm_buffer.h
+prism/prettyprint.$(OBJEXT): $(top_srcdir)/prism/util/pm_constant_pool.h
+prism/prettyprint.$(OBJEXT): $(top_srcdir)/prism/util/pm_list.h
+prism/prettyprint.$(OBJEXT): $(top_srcdir)/prism/util/pm_newline_list.h
+prism/prettyprint.$(OBJEXT): $(top_srcdir)/prism/util/pm_state_stack.h
+prism/prettyprint.$(OBJEXT): $(top_srcdir)/prism/util/pm_string.h
+prism/prettyprint.$(OBJEXT): $(top_srcdir)/prism/util/pm_strncasecmp.h
+prism/prettyprint.$(OBJEXT): {$(VPATH)}config.h
+prism/prettyprint.$(OBJEXT): {$(VPATH)}prism/ast.h
+prism/prettyprint.$(OBJEXT): {$(VPATH)}prism/prettyprint.c
+prism/prism.$(OBJEXT): $(top_srcdir)/prism/defines.h
+prism/prism.$(OBJEXT): $(top_srcdir)/prism/diagnostic.h
+prism/prism.$(OBJEXT): $(top_srcdir)/prism/encoding.h
+prism/prism.$(OBJEXT): $(top_srcdir)/prism/node.h
+prism/prism.$(OBJEXT): $(top_srcdir)/prism/options.h
+prism/prism.$(OBJEXT): $(top_srcdir)/prism/pack.h
+prism/prism.$(OBJEXT): $(top_srcdir)/prism/parser.h
+prism/prism.$(OBJEXT): $(top_srcdir)/prism/prettyprint.h
+prism/prism.$(OBJEXT): $(top_srcdir)/prism/prism.c
+prism/prism.$(OBJEXT): $(top_srcdir)/prism/prism.h
+prism/prism.$(OBJEXT): $(top_srcdir)/prism/regexp.h
+prism/prism.$(OBJEXT): $(top_srcdir)/prism/util/pm_buffer.h
+prism/prism.$(OBJEXT): $(top_srcdir)/prism/util/pm_char.h
+prism/prism.$(OBJEXT): $(top_srcdir)/prism/util/pm_constant_pool.h
+prism/prism.$(OBJEXT): $(top_srcdir)/prism/util/pm_list.h
+prism/prism.$(OBJEXT): $(top_srcdir)/prism/util/pm_memchr.h
+prism/prism.$(OBJEXT): $(top_srcdir)/prism/util/pm_newline_list.h
+prism/prism.$(OBJEXT): $(top_srcdir)/prism/util/pm_state_stack.h
+prism/prism.$(OBJEXT): $(top_srcdir)/prism/util/pm_string.h
+prism/prism.$(OBJEXT): $(top_srcdir)/prism/util/pm_string_list.h
+prism/prism.$(OBJEXT): $(top_srcdir)/prism/util/pm_strncasecmp.h
+prism/prism.$(OBJEXT): $(top_srcdir)/prism/util/pm_strpbrk.h
+prism/prism.$(OBJEXT): $(top_srcdir)/prism/version.h
+prism/prism.$(OBJEXT): {$(VPATH)}config.h
+prism/prism.$(OBJEXT): {$(VPATH)}prism/ast.h
+prism/prism.$(OBJEXT): {$(VPATH)}prism/version.h
+prism/regexp.$(OBJEXT): $(top_srcdir)/prism/defines.h
+prism/regexp.$(OBJEXT): $(top_srcdir)/prism/encoding.h
+prism/regexp.$(OBJEXT): $(top_srcdir)/prism/parser.h
+prism/regexp.$(OBJEXT): $(top_srcdir)/prism/regexp.c
+prism/regexp.$(OBJEXT): $(top_srcdir)/prism/regexp.h
+prism/regexp.$(OBJEXT): $(top_srcdir)/prism/util/pm_constant_pool.h
+prism/regexp.$(OBJEXT): $(top_srcdir)/prism/util/pm_list.h
+prism/regexp.$(OBJEXT): $(top_srcdir)/prism/util/pm_memchr.h
+prism/regexp.$(OBJEXT): $(top_srcdir)/prism/util/pm_newline_list.h
+prism/regexp.$(OBJEXT): $(top_srcdir)/prism/util/pm_state_stack.h
+prism/regexp.$(OBJEXT): $(top_srcdir)/prism/util/pm_string.h
+prism/regexp.$(OBJEXT): $(top_srcdir)/prism/util/pm_string_list.h
+prism/regexp.$(OBJEXT): $(top_srcdir)/prism/util/pm_strncasecmp.h
+prism/regexp.$(OBJEXT): {$(VPATH)}config.h
+prism/regexp.$(OBJEXT): {$(VPATH)}prism/ast.h
+prism/serialize.$(OBJEXT): $(top_srcdir)/prism/defines.h
+prism/serialize.$(OBJEXT): $(top_srcdir)/prism/diagnostic.h
+prism/serialize.$(OBJEXT): $(top_srcdir)/prism/encoding.h
+prism/serialize.$(OBJEXT): $(top_srcdir)/prism/node.h
+prism/serialize.$(OBJEXT): $(top_srcdir)/prism/options.h
+prism/serialize.$(OBJEXT): $(top_srcdir)/prism/pack.h
+prism/serialize.$(OBJEXT): $(top_srcdir)/prism/parser.h
+prism/serialize.$(OBJEXT): $(top_srcdir)/prism/prettyprint.h
+prism/serialize.$(OBJEXT): $(top_srcdir)/prism/prism.h
+prism/serialize.$(OBJEXT): $(top_srcdir)/prism/regexp.h
+prism/serialize.$(OBJEXT): $(top_srcdir)/prism/util/pm_buffer.h
+prism/serialize.$(OBJEXT): $(top_srcdir)/prism/util/pm_char.h
+prism/serialize.$(OBJEXT): $(top_srcdir)/prism/util/pm_constant_pool.h
+prism/serialize.$(OBJEXT): $(top_srcdir)/prism/util/pm_list.h
+prism/serialize.$(OBJEXT): $(top_srcdir)/prism/util/pm_memchr.h
+prism/serialize.$(OBJEXT): $(top_srcdir)/prism/util/pm_newline_list.h
+prism/serialize.$(OBJEXT): $(top_srcdir)/prism/util/pm_state_stack.h
+prism/serialize.$(OBJEXT): $(top_srcdir)/prism/util/pm_string.h
+prism/serialize.$(OBJEXT): $(top_srcdir)/prism/util/pm_string_list.h
+prism/serialize.$(OBJEXT): $(top_srcdir)/prism/util/pm_strncasecmp.h
+prism/serialize.$(OBJEXT): $(top_srcdir)/prism/util/pm_strpbrk.h
+prism/serialize.$(OBJEXT): {$(VPATH)}config.h
+prism/serialize.$(OBJEXT): {$(VPATH)}prism/ast.h
+prism/serialize.$(OBJEXT): {$(VPATH)}prism/serialize.c
+prism/serialize.$(OBJEXT): {$(VPATH)}prism/version.h
+prism/token_type.$(OBJEXT): $(top_srcdir)/prism/defines.h
+prism/token_type.$(OBJEXT): $(top_srcdir)/prism/util/pm_constant_pool.h
+prism/token_type.$(OBJEXT): $(top_srcdir)/prism/util/pm_string.h
+prism/token_type.$(OBJEXT): {$(VPATH)}config.h
+prism/token_type.$(OBJEXT): {$(VPATH)}prism/ast.h
+prism/token_type.$(OBJEXT): {$(VPATH)}prism/token_type.c
+prism/util/pm_buffer.$(OBJEXT): $(top_srcdir)/prism/defines.h
+prism/util/pm_buffer.$(OBJEXT): $(top_srcdir)/prism/util/pm_buffer.c
+prism/util/pm_buffer.$(OBJEXT): $(top_srcdir)/prism/util/pm_buffer.h
+prism/util/pm_buffer.$(OBJEXT): {$(VPATH)}config.h
+prism/util/pm_char.$(OBJEXT): $(top_srcdir)/prism/defines.h
+prism/util/pm_char.$(OBJEXT): $(top_srcdir)/prism/util/pm_char.c
+prism/util/pm_char.$(OBJEXT): $(top_srcdir)/prism/util/pm_char.h
+prism/util/pm_char.$(OBJEXT): $(top_srcdir)/prism/util/pm_newline_list.h
+prism/util/pm_char.$(OBJEXT): {$(VPATH)}config.h
+prism/util/pm_constant_pool.$(OBJEXT): $(top_srcdir)/prism/defines.h
+prism/util/pm_constant_pool.$(OBJEXT): $(top_srcdir)/prism/util/pm_constant_pool.c
+prism/util/pm_constant_pool.$(OBJEXT): $(top_srcdir)/prism/util/pm_constant_pool.h
+prism/util/pm_constant_pool.$(OBJEXT): {$(VPATH)}config.h
+prism/util/pm_list.$(OBJEXT): $(top_srcdir)/prism/defines.h
+prism/util/pm_list.$(OBJEXT): $(top_srcdir)/prism/util/pm_list.c
+prism/util/pm_list.$(OBJEXT): $(top_srcdir)/prism/util/pm_list.h
+prism/util/pm_list.$(OBJEXT): {$(VPATH)}config.h
+prism/util/pm_memchr.$(OBJEXT): $(top_srcdir)/prism/defines.h
+prism/util/pm_memchr.$(OBJEXT): $(top_srcdir)/prism/encoding.h
+prism/util/pm_memchr.$(OBJEXT): $(top_srcdir)/prism/parser.h
+prism/util/pm_memchr.$(OBJEXT): $(top_srcdir)/prism/util/pm_constant_pool.h
+prism/util/pm_memchr.$(OBJEXT): $(top_srcdir)/prism/util/pm_list.h
+prism/util/pm_memchr.$(OBJEXT): $(top_srcdir)/prism/util/pm_memchr.c
+prism/util/pm_memchr.$(OBJEXT): $(top_srcdir)/prism/util/pm_memchr.h
+prism/util/pm_memchr.$(OBJEXT): $(top_srcdir)/prism/util/pm_newline_list.h
+prism/util/pm_memchr.$(OBJEXT): $(top_srcdir)/prism/util/pm_state_stack.h
+prism/util/pm_memchr.$(OBJEXT): $(top_srcdir)/prism/util/pm_string.h
+prism/util/pm_memchr.$(OBJEXT): $(top_srcdir)/prism/util/pm_strncasecmp.h
+prism/util/pm_memchr.$(OBJEXT): {$(VPATH)}config.h
+prism/util/pm_memchr.$(OBJEXT): {$(VPATH)}prism/ast.h
+prism/util/pm_newline_list.$(OBJEXT): $(top_srcdir)/prism/defines.h
+prism/util/pm_newline_list.$(OBJEXT): $(top_srcdir)/prism/util/pm_newline_list.c
+prism/util/pm_newline_list.$(OBJEXT): $(top_srcdir)/prism/util/pm_newline_list.h
+prism/util/pm_newline_list.$(OBJEXT): {$(VPATH)}config.h
+prism/util/pm_state_stack.$(OBJEXT): $(top_srcdir)/prism/defines.h
+prism/util/pm_state_stack.$(OBJEXT): $(top_srcdir)/prism/util/pm_state_stack.c
+prism/util/pm_state_stack.$(OBJEXT): $(top_srcdir)/prism/util/pm_state_stack.h
+prism/util/pm_state_stack.$(OBJEXT): {$(VPATH)}config.h
+prism/util/pm_string.$(OBJEXT): $(top_srcdir)/prism/defines.h
+prism/util/pm_string.$(OBJEXT): $(top_srcdir)/prism/util/pm_string.c
+prism/util/pm_string.$(OBJEXT): $(top_srcdir)/prism/util/pm_string.h
+prism/util/pm_string.$(OBJEXT): {$(VPATH)}config.h
+prism/util/pm_string_list.$(OBJEXT): $(top_srcdir)/prism/defines.h
+prism/util/pm_string_list.$(OBJEXT): $(top_srcdir)/prism/util/pm_string.h
+prism/util/pm_string_list.$(OBJEXT): $(top_srcdir)/prism/util/pm_string_list.c
+prism/util/pm_string_list.$(OBJEXT): $(top_srcdir)/prism/util/pm_string_list.h
+prism/util/pm_string_list.$(OBJEXT): {$(VPATH)}config.h
+prism/util/pm_strncasecmp.$(OBJEXT): $(top_srcdir)/prism/defines.h
+prism/util/pm_strncasecmp.$(OBJEXT): $(top_srcdir)/prism/util/pm_strncasecmp.c
+prism/util/pm_strncasecmp.$(OBJEXT): $(top_srcdir)/prism/util/pm_strncasecmp.h
+prism/util/pm_strpbrk.$(OBJEXT): $(top_srcdir)/prism/defines.h
+prism/util/pm_strpbrk.$(OBJEXT): $(top_srcdir)/prism/encoding.h
+prism/util/pm_strpbrk.$(OBJEXT): $(top_srcdir)/prism/parser.h
+prism/util/pm_strpbrk.$(OBJEXT): $(top_srcdir)/prism/util/pm_constant_pool.h
+prism/util/pm_strpbrk.$(OBJEXT): $(top_srcdir)/prism/util/pm_list.h
+prism/util/pm_strpbrk.$(OBJEXT): $(top_srcdir)/prism/util/pm_newline_list.h
+prism/util/pm_strpbrk.$(OBJEXT): $(top_srcdir)/prism/util/pm_state_stack.h
+prism/util/pm_strpbrk.$(OBJEXT): $(top_srcdir)/prism/util/pm_string.h
+prism/util/pm_strpbrk.$(OBJEXT): $(top_srcdir)/prism/util/pm_strncasecmp.h
+prism/util/pm_strpbrk.$(OBJEXT): $(top_srcdir)/prism/util/pm_strpbrk.c
+prism/util/pm_strpbrk.$(OBJEXT): $(top_srcdir)/prism/util/pm_strpbrk.h
+prism/util/pm_strpbrk.$(OBJEXT): {$(VPATH)}config.h
+prism/util/pm_strpbrk.$(OBJEXT): {$(VPATH)}prism/ast.h
+prism_init.$(OBJEXT): $(hdrdir)/ruby.h
+prism_init.$(OBJEXT): $(hdrdir)/ruby/ruby.h
+prism_init.$(OBJEXT): $(top_srcdir)/prism/defines.h
+prism_init.$(OBJEXT): $(top_srcdir)/prism/diagnostic.h
+prism_init.$(OBJEXT): $(top_srcdir)/prism/encoding.h
+prism_init.$(OBJEXT): $(top_srcdir)/prism/extension.h
+prism_init.$(OBJEXT): $(top_srcdir)/prism/node.h
+prism_init.$(OBJEXT): $(top_srcdir)/prism/options.h
+prism_init.$(OBJEXT): $(top_srcdir)/prism/pack.h
+prism_init.$(OBJEXT): $(top_srcdir)/prism/parser.h
+prism_init.$(OBJEXT): $(top_srcdir)/prism/prettyprint.h
+prism_init.$(OBJEXT): $(top_srcdir)/prism/prism.h
+prism_init.$(OBJEXT): $(top_srcdir)/prism/regexp.h
+prism_init.$(OBJEXT): $(top_srcdir)/prism/util/pm_buffer.h
+prism_init.$(OBJEXT): $(top_srcdir)/prism/util/pm_char.h
+prism_init.$(OBJEXT): $(top_srcdir)/prism/util/pm_constant_pool.h
+prism_init.$(OBJEXT): $(top_srcdir)/prism/util/pm_list.h
+prism_init.$(OBJEXT): $(top_srcdir)/prism/util/pm_memchr.h
+prism_init.$(OBJEXT): $(top_srcdir)/prism/util/pm_newline_list.h
+prism_init.$(OBJEXT): $(top_srcdir)/prism/util/pm_state_stack.h
+prism_init.$(OBJEXT): $(top_srcdir)/prism/util/pm_string.h
+prism_init.$(OBJEXT): $(top_srcdir)/prism/util/pm_string_list.h
+prism_init.$(OBJEXT): $(top_srcdir)/prism/util/pm_strncasecmp.h
+prism_init.$(OBJEXT): $(top_srcdir)/prism/util/pm_strpbrk.h
+prism_init.$(OBJEXT): $(top_srcdir)/prism_init.c
+prism_init.$(OBJEXT): {$(VPATH)}assert.h
+prism_init.$(OBJEXT): {$(VPATH)}backward/2/assume.h
+prism_init.$(OBJEXT): {$(VPATH)}backward/2/attributes.h
+prism_init.$(OBJEXT): {$(VPATH)}backward/2/bool.h
+prism_init.$(OBJEXT): {$(VPATH)}backward/2/inttypes.h
+prism_init.$(OBJEXT): {$(VPATH)}backward/2/limits.h
+prism_init.$(OBJEXT): {$(VPATH)}backward/2/long_long.h
+prism_init.$(OBJEXT): {$(VPATH)}backward/2/stdalign.h
+prism_init.$(OBJEXT): {$(VPATH)}backward/2/stdarg.h
+prism_init.$(OBJEXT): {$(VPATH)}config.h
+prism_init.$(OBJEXT): {$(VPATH)}defines.h
+prism_init.$(OBJEXT): {$(VPATH)}encoding.h
+prism_init.$(OBJEXT): {$(VPATH)}intern.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/abi.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/anyargs.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/arithmetic.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/arithmetic/char.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/arithmetic/double.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/arithmetic/fixnum.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/arithmetic/gid_t.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/arithmetic/int.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/arithmetic/intptr_t.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/arithmetic/long.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/arithmetic/long_long.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/arithmetic/mode_t.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/arithmetic/off_t.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/arithmetic/pid_t.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/arithmetic/short.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/arithmetic/size_t.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/arithmetic/st_data_t.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/arithmetic/uid_t.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/assume.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/attr/alloc_size.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/attr/artificial.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/attr/cold.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/attr/const.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/attr/constexpr.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/attr/deprecated.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/attr/diagnose_if.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/attr/enum_extensibility.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/attr/error.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/attr/flag_enum.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/attr/forceinline.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/attr/format.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/attr/maybe_unused.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/attr/noalias.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/attr/nodiscard.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/attr/packed_struct.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/attr/warning.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/attr/weakref.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/cast.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/compiler_is.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/compiler_is/apple.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/compiler_is/clang.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/compiler_is/gcc.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/compiler_is/intel.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/compiler_is/msvc.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/compiler_is/sunpro.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/compiler_since.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/config.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/constant_p.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/core.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/core/rarray.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/core/rbasic.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/core/rbignum.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/core/rclass.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/core/rdata.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/core/rfile.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/core/rhash.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/core/robject.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/core/rregexp.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/core/rstring.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/core/rstruct.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/core/rtypeddata.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/ctype.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/dllexport.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/dosish.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/encoding/coderange.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/encoding/ctype.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/encoding/encoding.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/encoding/pathname.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/encoding/re.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/encoding/sprintf.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/encoding/string.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/encoding/symbol.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/encoding/transcode.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/error.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/eval.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/event.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/fl_type.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/gc.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/glob.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/globals.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/has/attribute.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/has/builtin.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/has/c_attribute.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/has/cpp_attribute.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/has/declspec_attribute.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/has/extension.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/has/feature.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/has/warning.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/intern/array.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/intern/bignum.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/intern/class.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/intern/compar.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/intern/complex.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/intern/cont.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/intern/dir.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/intern/enum.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/intern/enumerator.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/intern/error.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/intern/eval.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/intern/file.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/intern/hash.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/intern/io.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/intern/load.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/intern/marshal.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/intern/numeric.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/intern/object.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/intern/parse.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/intern/proc.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/intern/process.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/intern/random.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/intern/range.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/intern/rational.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/intern/re.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/intern/ruby.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/intern/select.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/intern/select/largesize.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/intern/signal.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/intern/sprintf.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/intern/string.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/intern/struct.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/intern/thread.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/intern/time.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/intern/variable.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/intern/vm.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/interpreter.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/iterator.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/memory.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/method.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/module.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/newobj.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/scan_args.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/special_consts.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/static_assert.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/stdalign.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/stdbool.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/symbol.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/value.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/value_type.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/variable.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/warning_push.h
+prism_init.$(OBJEXT): {$(VPATH)}internal/xmalloc.h
+prism_init.$(OBJEXT): {$(VPATH)}missing.h
+prism_init.$(OBJEXT): {$(VPATH)}onigmo.h
+prism_init.$(OBJEXT): {$(VPATH)}oniguruma.h
+prism_init.$(OBJEXT): {$(VPATH)}prism/ast.h
+prism_init.$(OBJEXT): {$(VPATH)}prism/version.h
+prism_init.$(OBJEXT): {$(VPATH)}prism_init.c
+prism_init.$(OBJEXT): {$(VPATH)}st.h
+prism_init.$(OBJEXT): {$(VPATH)}subst.h
proc.$(OBJEXT): $(CCAN_DIR)/check_type/check_type.h
proc.$(OBJEXT): $(CCAN_DIR)/container_of/container_of.h
proc.$(OBJEXT): $(CCAN_DIR)/list/list.h
proc.$(OBJEXT): $(CCAN_DIR)/str/str.h
proc.$(OBJEXT): $(hdrdir)/ruby/ruby.h
+proc.$(OBJEXT): $(hdrdir)/ruby/version.h
proc.$(OBJEXT): $(top_srcdir)/internal/array.h
proc.$(OBJEXT): $(top_srcdir)/internal/basic_operators.h
proc.$(OBJEXT): $(top_srcdir)/internal/class.h
@@ -11115,6 +12600,27 @@ proc.$(OBJEXT): $(top_srcdir)/internal/symbol.h
proc.$(OBJEXT): $(top_srcdir)/internal/variable.h
proc.$(OBJEXT): $(top_srcdir)/internal/vm.h
proc.$(OBJEXT): $(top_srcdir)/internal/warnings.h
+proc.$(OBJEXT): $(top_srcdir)/prism/defines.h
+proc.$(OBJEXT): $(top_srcdir)/prism/diagnostic.h
+proc.$(OBJEXT): $(top_srcdir)/prism/encoding.h
+proc.$(OBJEXT): $(top_srcdir)/prism/node.h
+proc.$(OBJEXT): $(top_srcdir)/prism/options.h
+proc.$(OBJEXT): $(top_srcdir)/prism/pack.h
+proc.$(OBJEXT): $(top_srcdir)/prism/parser.h
+proc.$(OBJEXT): $(top_srcdir)/prism/prettyprint.h
+proc.$(OBJEXT): $(top_srcdir)/prism/prism.h
+proc.$(OBJEXT): $(top_srcdir)/prism/regexp.h
+proc.$(OBJEXT): $(top_srcdir)/prism/util/pm_buffer.h
+proc.$(OBJEXT): $(top_srcdir)/prism/util/pm_char.h
+proc.$(OBJEXT): $(top_srcdir)/prism/util/pm_constant_pool.h
+proc.$(OBJEXT): $(top_srcdir)/prism/util/pm_list.h
+proc.$(OBJEXT): $(top_srcdir)/prism/util/pm_memchr.h
+proc.$(OBJEXT): $(top_srcdir)/prism/util/pm_newline_list.h
+proc.$(OBJEXT): $(top_srcdir)/prism/util/pm_state_stack.h
+proc.$(OBJEXT): $(top_srcdir)/prism/util/pm_string.h
+proc.$(OBJEXT): $(top_srcdir)/prism/util/pm_string_list.h
+proc.$(OBJEXT): $(top_srcdir)/prism/util/pm_strncasecmp.h
+proc.$(OBJEXT): $(top_srcdir)/prism/util/pm_strpbrk.h
proc.$(OBJEXT): {$(VPATH)}assert.h
proc.$(OBJEXT): {$(VPATH)}atomic.h
proc.$(OBJEXT): {$(VPATH)}backward/2/assume.h
@@ -11128,10 +12634,10 @@ proc.$(OBJEXT): {$(VPATH)}backward/2/stdalign.h
proc.$(OBJEXT): {$(VPATH)}backward/2/stdarg.h
proc.$(OBJEXT): {$(VPATH)}config.h
proc.$(OBJEXT): {$(VPATH)}constant.h
+proc.$(OBJEXT): {$(VPATH)}debug_counter.h
proc.$(OBJEXT): {$(VPATH)}defines.h
proc.$(OBJEXT): {$(VPATH)}encoding.h
proc.$(OBJEXT): {$(VPATH)}eval_intern.h
-proc.$(OBJEXT): {$(VPATH)}gc.h
proc.$(OBJEXT): {$(VPATH)}id.h
proc.$(OBJEXT): {$(VPATH)}id_table.h
proc.$(OBJEXT): {$(VPATH)}intern.h
@@ -11174,6 +12680,7 @@ proc.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
proc.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
proc.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
proc.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
+proc.$(OBJEXT): {$(VPATH)}internal/attr/packed_struct.h
proc.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
proc.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
proc.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
@@ -11242,7 +12749,6 @@ proc.$(OBJEXT): {$(VPATH)}internal/intern/enumerator.h
proc.$(OBJEXT): {$(VPATH)}internal/intern/error.h
proc.$(OBJEXT): {$(VPATH)}internal/intern/eval.h
proc.$(OBJEXT): {$(VPATH)}internal/intern/file.h
-proc.$(OBJEXT): {$(VPATH)}internal/intern/gc.h
proc.$(OBJEXT): {$(VPATH)}internal/intern/hash.h
proc.$(OBJEXT): {$(VPATH)}internal/intern/io.h
proc.$(OBJEXT): {$(VPATH)}internal/intern/load.h
@@ -11273,7 +12779,6 @@ proc.$(OBJEXT): {$(VPATH)}internal/memory.h
proc.$(OBJEXT): {$(VPATH)}internal/method.h
proc.$(OBJEXT): {$(VPATH)}internal/module.h
proc.$(OBJEXT): {$(VPATH)}internal/newobj.h
-proc.$(OBJEXT): {$(VPATH)}internal/rgengc.h
proc.$(OBJEXT): {$(VPATH)}internal/scan_args.h
proc.$(OBJEXT): {$(VPATH)}internal/special_consts.h
proc.$(OBJEXT): {$(VPATH)}internal/static_assert.h
@@ -11291,16 +12796,22 @@ proc.$(OBJEXT): {$(VPATH)}missing.h
proc.$(OBJEXT): {$(VPATH)}node.h
proc.$(OBJEXT): {$(VPATH)}onigmo.h
proc.$(OBJEXT): {$(VPATH)}oniguruma.h
+proc.$(OBJEXT): {$(VPATH)}prism/ast.h
+proc.$(OBJEXT): {$(VPATH)}prism/version.h
+proc.$(OBJEXT): {$(VPATH)}prism_compile.h
proc.$(OBJEXT): {$(VPATH)}proc.c
proc.$(OBJEXT): {$(VPATH)}ruby_assert.h
proc.$(OBJEXT): {$(VPATH)}ruby_atomic.h
+proc.$(OBJEXT): {$(VPATH)}rubyparser.h
proc.$(OBJEXT): {$(VPATH)}shape.h
proc.$(OBJEXT): {$(VPATH)}st.h
proc.$(OBJEXT): {$(VPATH)}subst.h
proc.$(OBJEXT): {$(VPATH)}thread_$(THREAD_MODEL).h
proc.$(OBJEXT): {$(VPATH)}thread_native.h
proc.$(OBJEXT): {$(VPATH)}vm_core.h
+proc.$(OBJEXT): {$(VPATH)}vm_debug.h
proc.$(OBJEXT): {$(VPATH)}vm_opts.h
+proc.$(OBJEXT): {$(VPATH)}vm_sync.h
proc.$(OBJEXT): {$(VPATH)}yjit.h
process.$(OBJEXT): $(CCAN_DIR)/check_type/check_type.h
process.$(OBJEXT): $(CCAN_DIR)/container_of/container_of.h
@@ -11308,6 +12819,7 @@ process.$(OBJEXT): $(CCAN_DIR)/list/list.h
process.$(OBJEXT): $(CCAN_DIR)/str/str.h
process.$(OBJEXT): $(hdrdir)/ruby.h
process.$(OBJEXT): $(hdrdir)/ruby/ruby.h
+process.$(OBJEXT): $(hdrdir)/ruby/version.h
process.$(OBJEXT): $(top_srcdir)/internal/array.h
process.$(OBJEXT): $(top_srcdir)/internal/basic_operators.h
process.$(OBJEXT): $(top_srcdir)/internal/bignum.h
@@ -11321,6 +12833,7 @@ process.$(OBJEXT): $(top_srcdir)/internal/fixnum.h
process.$(OBJEXT): $(top_srcdir)/internal/gc.h
process.$(OBJEXT): $(top_srcdir)/internal/hash.h
process.$(OBJEXT): $(top_srcdir)/internal/imemo.h
+process.$(OBJEXT): $(top_srcdir)/internal/io.h
process.$(OBJEXT): $(top_srcdir)/internal/numeric.h
process.$(OBJEXT): $(top_srcdir)/internal/object.h
process.$(OBJEXT): $(top_srcdir)/internal/process.h
@@ -11393,6 +12906,7 @@ process.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
process.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
process.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
process.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
+process.$(OBJEXT): {$(VPATH)}internal/attr/packed_struct.h
process.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
process.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
process.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
@@ -11461,7 +12975,6 @@ process.$(OBJEXT): {$(VPATH)}internal/intern/enumerator.h
process.$(OBJEXT): {$(VPATH)}internal/intern/error.h
process.$(OBJEXT): {$(VPATH)}internal/intern/eval.h
process.$(OBJEXT): {$(VPATH)}internal/intern/file.h
-process.$(OBJEXT): {$(VPATH)}internal/intern/gc.h
process.$(OBJEXT): {$(VPATH)}internal/intern/hash.h
process.$(OBJEXT): {$(VPATH)}internal/intern/io.h
process.$(OBJEXT): {$(VPATH)}internal/intern/load.h
@@ -11492,7 +13005,6 @@ process.$(OBJEXT): {$(VPATH)}internal/memory.h
process.$(OBJEXT): {$(VPATH)}internal/method.h
process.$(OBJEXT): {$(VPATH)}internal/module.h
process.$(OBJEXT): {$(VPATH)}internal/newobj.h
-process.$(OBJEXT): {$(VPATH)}internal/rgengc.h
process.$(OBJEXT): {$(VPATH)}internal/scan_args.h
process.$(OBJEXT): {$(VPATH)}internal/special_consts.h
process.$(OBJEXT): {$(VPATH)}internal/static_assert.h
@@ -11507,14 +13019,15 @@ process.$(OBJEXT): {$(VPATH)}internal/xmalloc.h
process.$(OBJEXT): {$(VPATH)}io.h
process.$(OBJEXT): {$(VPATH)}method.h
process.$(OBJEXT): {$(VPATH)}missing.h
-process.$(OBJEXT): {$(VPATH)}mjit.h
process.$(OBJEXT): {$(VPATH)}node.h
process.$(OBJEXT): {$(VPATH)}onigmo.h
process.$(OBJEXT): {$(VPATH)}oniguruma.h
process.$(OBJEXT): {$(VPATH)}process.c
process.$(OBJEXT): {$(VPATH)}ractor.h
+process.$(OBJEXT): {$(VPATH)}rjit.h
process.$(OBJEXT): {$(VPATH)}ruby_assert.h
process.$(OBJEXT): {$(VPATH)}ruby_atomic.h
+process.$(OBJEXT): {$(VPATH)}rubyparser.h
process.$(OBJEXT): {$(VPATH)}shape.h
process.$(OBJEXT): {$(VPATH)}st.h
process.$(OBJEXT): {$(VPATH)}subst.h
@@ -11523,13 +13036,16 @@ process.$(OBJEXT): {$(VPATH)}thread_$(THREAD_MODEL).h
process.$(OBJEXT): {$(VPATH)}thread_native.h
process.$(OBJEXT): {$(VPATH)}util.h
process.$(OBJEXT): {$(VPATH)}vm_core.h
+process.$(OBJEXT): {$(VPATH)}vm_debug.h
process.$(OBJEXT): {$(VPATH)}vm_opts.h
+process.$(OBJEXT): {$(VPATH)}vm_sync.h
ractor.$(OBJEXT): $(CCAN_DIR)/check_type/check_type.h
ractor.$(OBJEXT): $(CCAN_DIR)/container_of/container_of.h
ractor.$(OBJEXT): $(CCAN_DIR)/list/list.h
ractor.$(OBJEXT): $(CCAN_DIR)/str/str.h
ractor.$(OBJEXT): $(hdrdir)/ruby.h
ractor.$(OBJEXT): $(hdrdir)/ruby/ruby.h
+ractor.$(OBJEXT): $(hdrdir)/ruby/version.h
ractor.$(OBJEXT): $(top_srcdir)/internal/array.h
ractor.$(OBJEXT): $(top_srcdir)/internal/basic_operators.h
ractor.$(OBJEXT): $(top_srcdir)/internal/bignum.h
@@ -11568,7 +13084,7 @@ ractor.$(OBJEXT): {$(VPATH)}constant.h
ractor.$(OBJEXT): {$(VPATH)}debug_counter.h
ractor.$(OBJEXT): {$(VPATH)}defines.h
ractor.$(OBJEXT): {$(VPATH)}encoding.h
-ractor.$(OBJEXT): {$(VPATH)}gc.h
+ractor.$(OBJEXT): {$(VPATH)}eval_intern.h
ractor.$(OBJEXT): {$(VPATH)}id.h
ractor.$(OBJEXT): {$(VPATH)}id_table.h
ractor.$(OBJEXT): {$(VPATH)}intern.h
@@ -11611,6 +13127,7 @@ ractor.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
ractor.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
ractor.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
ractor.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
+ractor.$(OBJEXT): {$(VPATH)}internal/attr/packed_struct.h
ractor.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
ractor.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
ractor.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
@@ -11679,7 +13196,6 @@ ractor.$(OBJEXT): {$(VPATH)}internal/intern/enumerator.h
ractor.$(OBJEXT): {$(VPATH)}internal/intern/error.h
ractor.$(OBJEXT): {$(VPATH)}internal/intern/eval.h
ractor.$(OBJEXT): {$(VPATH)}internal/intern/file.h
-ractor.$(OBJEXT): {$(VPATH)}internal/intern/gc.h
ractor.$(OBJEXT): {$(VPATH)}internal/intern/hash.h
ractor.$(OBJEXT): {$(VPATH)}internal/intern/io.h
ractor.$(OBJEXT): {$(VPATH)}internal/intern/load.h
@@ -11710,7 +13226,6 @@ ractor.$(OBJEXT): {$(VPATH)}internal/memory.h
ractor.$(OBJEXT): {$(VPATH)}internal/method.h
ractor.$(OBJEXT): {$(VPATH)}internal/module.h
ractor.$(OBJEXT): {$(VPATH)}internal/newobj.h
-ractor.$(OBJEXT): {$(VPATH)}internal/rgengc.h
ractor.$(OBJEXT): {$(VPATH)}internal/scan_args.h
ractor.$(OBJEXT): {$(VPATH)}internal/special_consts.h
ractor.$(OBJEXT): {$(VPATH)}internal/static_assert.h
@@ -11724,7 +13239,6 @@ ractor.$(OBJEXT): {$(VPATH)}internal/warning_push.h
ractor.$(OBJEXT): {$(VPATH)}internal/xmalloc.h
ractor.$(OBJEXT): {$(VPATH)}method.h
ractor.$(OBJEXT): {$(VPATH)}missing.h
-ractor.$(OBJEXT): {$(VPATH)}mjit.h
ractor.$(OBJEXT): {$(VPATH)}node.h
ractor.$(OBJEXT): {$(VPATH)}onigmo.h
ractor.$(OBJEXT): {$(VPATH)}oniguruma.h
@@ -11732,28 +13246,35 @@ ractor.$(OBJEXT): {$(VPATH)}ractor.c
ractor.$(OBJEXT): {$(VPATH)}ractor.h
ractor.$(OBJEXT): {$(VPATH)}ractor.rbinc
ractor.$(OBJEXT): {$(VPATH)}ractor_core.h
+ractor.$(OBJEXT): {$(VPATH)}rjit.h
ractor.$(OBJEXT): {$(VPATH)}ruby_assert.h
ractor.$(OBJEXT): {$(VPATH)}ruby_atomic.h
+ractor.$(OBJEXT): {$(VPATH)}rubyparser.h
ractor.$(OBJEXT): {$(VPATH)}shape.h
ractor.$(OBJEXT): {$(VPATH)}st.h
ractor.$(OBJEXT): {$(VPATH)}subst.h
ractor.$(OBJEXT): {$(VPATH)}thread.h
ractor.$(OBJEXT): {$(VPATH)}thread_$(THREAD_MODEL).h
ractor.$(OBJEXT): {$(VPATH)}thread_native.h
-ractor.$(OBJEXT): {$(VPATH)}transient_heap.h
ractor.$(OBJEXT): {$(VPATH)}variable.h
ractor.$(OBJEXT): {$(VPATH)}vm_core.h
ractor.$(OBJEXT): {$(VPATH)}vm_debug.h
ractor.$(OBJEXT): {$(VPATH)}vm_opts.h
ractor.$(OBJEXT): {$(VPATH)}vm_sync.h
ractor.$(OBJEXT): {$(VPATH)}yjit.h
+random.$(OBJEXT): $(CCAN_DIR)/check_type/check_type.h
+random.$(OBJEXT): $(CCAN_DIR)/container_of/container_of.h
+random.$(OBJEXT): $(CCAN_DIR)/list/list.h
+random.$(OBJEXT): $(CCAN_DIR)/str/str.h
random.$(OBJEXT): $(hdrdir)/ruby/ruby.h
random.$(OBJEXT): $(top_srcdir)/internal/array.h
+random.$(OBJEXT): $(top_srcdir)/internal/basic_operators.h
random.$(OBJEXT): $(top_srcdir)/internal/bignum.h
random.$(OBJEXT): $(top_srcdir)/internal/bits.h
random.$(OBJEXT): $(top_srcdir)/internal/compilers.h
random.$(OBJEXT): $(top_srcdir)/internal/fixnum.h
random.$(OBJEXT): $(top_srcdir)/internal/gc.h
+random.$(OBJEXT): $(top_srcdir)/internal/imemo.h
random.$(OBJEXT): $(top_srcdir)/internal/numeric.h
random.$(OBJEXT): $(top_srcdir)/internal/random.h
random.$(OBJEXT): $(top_srcdir)/internal/sanitizers.h
@@ -11776,6 +13297,8 @@ random.$(OBJEXT): {$(VPATH)}backward/2/stdarg.h
random.$(OBJEXT): {$(VPATH)}config.h
random.$(OBJEXT): {$(VPATH)}constant.h
random.$(OBJEXT): {$(VPATH)}defines.h
+random.$(OBJEXT): {$(VPATH)}encoding.h
+random.$(OBJEXT): {$(VPATH)}id.h
random.$(OBJEXT): {$(VPATH)}id_table.h
random.$(OBJEXT): {$(VPATH)}intern.h
random.$(OBJEXT): {$(VPATH)}internal.h
@@ -11817,6 +13340,7 @@ random.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
random.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
random.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
random.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
+random.$(OBJEXT): {$(VPATH)}internal/attr/packed_struct.h
random.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
random.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
random.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
@@ -11849,6 +13373,15 @@ random.$(OBJEXT): {$(VPATH)}internal/core/rtypeddata.h
random.$(OBJEXT): {$(VPATH)}internal/ctype.h
random.$(OBJEXT): {$(VPATH)}internal/dllexport.h
random.$(OBJEXT): {$(VPATH)}internal/dosish.h
+random.$(OBJEXT): {$(VPATH)}internal/encoding/coderange.h
+random.$(OBJEXT): {$(VPATH)}internal/encoding/ctype.h
+random.$(OBJEXT): {$(VPATH)}internal/encoding/encoding.h
+random.$(OBJEXT): {$(VPATH)}internal/encoding/pathname.h
+random.$(OBJEXT): {$(VPATH)}internal/encoding/re.h
+random.$(OBJEXT): {$(VPATH)}internal/encoding/sprintf.h
+random.$(OBJEXT): {$(VPATH)}internal/encoding/string.h
+random.$(OBJEXT): {$(VPATH)}internal/encoding/symbol.h
+random.$(OBJEXT): {$(VPATH)}internal/encoding/transcode.h
random.$(OBJEXT): {$(VPATH)}internal/error.h
random.$(OBJEXT): {$(VPATH)}internal/eval.h
random.$(OBJEXT): {$(VPATH)}internal/event.h
@@ -11876,7 +13409,6 @@ random.$(OBJEXT): {$(VPATH)}internal/intern/enumerator.h
random.$(OBJEXT): {$(VPATH)}internal/intern/error.h
random.$(OBJEXT): {$(VPATH)}internal/intern/eval.h
random.$(OBJEXT): {$(VPATH)}internal/intern/file.h
-random.$(OBJEXT): {$(VPATH)}internal/intern/gc.h
random.$(OBJEXT): {$(VPATH)}internal/intern/hash.h
random.$(OBJEXT): {$(VPATH)}internal/intern/io.h
random.$(OBJEXT): {$(VPATH)}internal/intern/load.h
@@ -11907,7 +13439,6 @@ random.$(OBJEXT): {$(VPATH)}internal/memory.h
random.$(OBJEXT): {$(VPATH)}internal/method.h
random.$(OBJEXT): {$(VPATH)}internal/module.h
random.$(OBJEXT): {$(VPATH)}internal/newobj.h
-random.$(OBJEXT): {$(VPATH)}internal/rgengc.h
random.$(OBJEXT): {$(VPATH)}internal/scan_args.h
random.$(OBJEXT): {$(VPATH)}internal/special_consts.h
random.$(OBJEXT): {$(VPATH)}internal/static_assert.h
@@ -11919,18 +13450,29 @@ random.$(OBJEXT): {$(VPATH)}internal/value_type.h
random.$(OBJEXT): {$(VPATH)}internal/variable.h
random.$(OBJEXT): {$(VPATH)}internal/warning_push.h
random.$(OBJEXT): {$(VPATH)}internal/xmalloc.h
+random.$(OBJEXT): {$(VPATH)}method.h
random.$(OBJEXT): {$(VPATH)}missing.h
random.$(OBJEXT): {$(VPATH)}mt19937.c
+random.$(OBJEXT): {$(VPATH)}node.h
+random.$(OBJEXT): {$(VPATH)}onigmo.h
+random.$(OBJEXT): {$(VPATH)}oniguruma.h
random.$(OBJEXT): {$(VPATH)}ractor.h
random.$(OBJEXT): {$(VPATH)}random.c
random.$(OBJEXT): {$(VPATH)}random.h
+random.$(OBJEXT): {$(VPATH)}ruby_assert.h
random.$(OBJEXT): {$(VPATH)}ruby_atomic.h
+random.$(OBJEXT): {$(VPATH)}rubyparser.h
random.$(OBJEXT): {$(VPATH)}shape.h
random.$(OBJEXT): {$(VPATH)}siphash.c
random.$(OBJEXT): {$(VPATH)}siphash.h
random.$(OBJEXT): {$(VPATH)}st.h
random.$(OBJEXT): {$(VPATH)}subst.h
+random.$(OBJEXT): {$(VPATH)}thread_$(THREAD_MODEL).h
+random.$(OBJEXT): {$(VPATH)}thread_native.h
+random.$(OBJEXT): {$(VPATH)}vm_core.h
+random.$(OBJEXT): {$(VPATH)}vm_opts.h
range.$(OBJEXT): $(hdrdir)/ruby/ruby.h
+range.$(OBJEXT): $(hdrdir)/ruby/version.h
range.$(OBJEXT): $(top_srcdir)/internal/array.h
range.$(OBJEXT): $(top_srcdir)/internal/basic_operators.h
range.$(OBJEXT): $(top_srcdir)/internal/bignum.h
@@ -12004,6 +13546,7 @@ range.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
range.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
range.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
range.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
+range.$(OBJEXT): {$(VPATH)}internal/attr/packed_struct.h
range.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
range.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
range.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
@@ -12072,7 +13615,6 @@ range.$(OBJEXT): {$(VPATH)}internal/intern/enumerator.h
range.$(OBJEXT): {$(VPATH)}internal/intern/error.h
range.$(OBJEXT): {$(VPATH)}internal/intern/eval.h
range.$(OBJEXT): {$(VPATH)}internal/intern/file.h
-range.$(OBJEXT): {$(VPATH)}internal/intern/gc.h
range.$(OBJEXT): {$(VPATH)}internal/intern/hash.h
range.$(OBJEXT): {$(VPATH)}internal/intern/io.h
range.$(OBJEXT): {$(VPATH)}internal/intern/load.h
@@ -12103,7 +13645,6 @@ range.$(OBJEXT): {$(VPATH)}internal/memory.h
range.$(OBJEXT): {$(VPATH)}internal/method.h
range.$(OBJEXT): {$(VPATH)}internal/module.h
range.$(OBJEXT): {$(VPATH)}internal/newobj.h
-range.$(OBJEXT): {$(VPATH)}internal/rgengc.h
range.$(OBJEXT): {$(VPATH)}internal/scan_args.h
range.$(OBJEXT): {$(VPATH)}internal/special_consts.h
range.$(OBJEXT): {$(VPATH)}internal/static_assert.h
@@ -12122,8 +13663,13 @@ range.$(OBJEXT): {$(VPATH)}range.c
range.$(OBJEXT): {$(VPATH)}shape.h
range.$(OBJEXT): {$(VPATH)}st.h
range.$(OBJEXT): {$(VPATH)}subst.h
+rational.$(OBJEXT): $(CCAN_DIR)/check_type/check_type.h
+rational.$(OBJEXT): $(CCAN_DIR)/container_of/container_of.h
+rational.$(OBJEXT): $(CCAN_DIR)/list/list.h
+rational.$(OBJEXT): $(CCAN_DIR)/str/str.h
rational.$(OBJEXT): $(hdrdir)/ruby/ruby.h
rational.$(OBJEXT): $(top_srcdir)/internal/array.h
+rational.$(OBJEXT): $(top_srcdir)/internal/basic_operators.h
rational.$(OBJEXT): $(top_srcdir)/internal/bignum.h
rational.$(OBJEXT): $(top_srcdir)/internal/bits.h
rational.$(OBJEXT): $(top_srcdir)/internal/class.h
@@ -12131,6 +13677,7 @@ rational.$(OBJEXT): $(top_srcdir)/internal/compilers.h
rational.$(OBJEXT): $(top_srcdir)/internal/complex.h
rational.$(OBJEXT): $(top_srcdir)/internal/fixnum.h
rational.$(OBJEXT): $(top_srcdir)/internal/gc.h
+rational.$(OBJEXT): $(top_srcdir)/internal/imemo.h
rational.$(OBJEXT): $(top_srcdir)/internal/numeric.h
rational.$(OBJEXT): $(top_srcdir)/internal/object.h
rational.$(OBJEXT): $(top_srcdir)/internal/rational.h
@@ -12140,6 +13687,7 @@ rational.$(OBJEXT): $(top_srcdir)/internal/variable.h
rational.$(OBJEXT): $(top_srcdir)/internal/vm.h
rational.$(OBJEXT): $(top_srcdir)/internal/warnings.h
rational.$(OBJEXT): {$(VPATH)}assert.h
+rational.$(OBJEXT): {$(VPATH)}atomic.h
rational.$(OBJEXT): {$(VPATH)}backward/2/assume.h
rational.$(OBJEXT): {$(VPATH)}backward/2/attributes.h
rational.$(OBJEXT): {$(VPATH)}backward/2/bool.h
@@ -12152,6 +13700,7 @@ rational.$(OBJEXT): {$(VPATH)}backward/2/stdarg.h
rational.$(OBJEXT): {$(VPATH)}config.h
rational.$(OBJEXT): {$(VPATH)}constant.h
rational.$(OBJEXT): {$(VPATH)}defines.h
+rational.$(OBJEXT): {$(VPATH)}encoding.h
rational.$(OBJEXT): {$(VPATH)}id.h
rational.$(OBJEXT): {$(VPATH)}id_table.h
rational.$(OBJEXT): {$(VPATH)}intern.h
@@ -12194,6 +13743,7 @@ rational.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
rational.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
rational.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
rational.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
+rational.$(OBJEXT): {$(VPATH)}internal/attr/packed_struct.h
rational.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
rational.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
rational.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
@@ -12226,6 +13776,15 @@ rational.$(OBJEXT): {$(VPATH)}internal/core/rtypeddata.h
rational.$(OBJEXT): {$(VPATH)}internal/ctype.h
rational.$(OBJEXT): {$(VPATH)}internal/dllexport.h
rational.$(OBJEXT): {$(VPATH)}internal/dosish.h
+rational.$(OBJEXT): {$(VPATH)}internal/encoding/coderange.h
+rational.$(OBJEXT): {$(VPATH)}internal/encoding/ctype.h
+rational.$(OBJEXT): {$(VPATH)}internal/encoding/encoding.h
+rational.$(OBJEXT): {$(VPATH)}internal/encoding/pathname.h
+rational.$(OBJEXT): {$(VPATH)}internal/encoding/re.h
+rational.$(OBJEXT): {$(VPATH)}internal/encoding/sprintf.h
+rational.$(OBJEXT): {$(VPATH)}internal/encoding/string.h
+rational.$(OBJEXT): {$(VPATH)}internal/encoding/symbol.h
+rational.$(OBJEXT): {$(VPATH)}internal/encoding/transcode.h
rational.$(OBJEXT): {$(VPATH)}internal/error.h
rational.$(OBJEXT): {$(VPATH)}internal/eval.h
rational.$(OBJEXT): {$(VPATH)}internal/event.h
@@ -12253,7 +13812,6 @@ rational.$(OBJEXT): {$(VPATH)}internal/intern/enumerator.h
rational.$(OBJEXT): {$(VPATH)}internal/intern/error.h
rational.$(OBJEXT): {$(VPATH)}internal/intern/eval.h
rational.$(OBJEXT): {$(VPATH)}internal/intern/file.h
-rational.$(OBJEXT): {$(VPATH)}internal/intern/gc.h
rational.$(OBJEXT): {$(VPATH)}internal/intern/hash.h
rational.$(OBJEXT): {$(VPATH)}internal/intern/io.h
rational.$(OBJEXT): {$(VPATH)}internal/intern/load.h
@@ -12284,7 +13842,6 @@ rational.$(OBJEXT): {$(VPATH)}internal/memory.h
rational.$(OBJEXT): {$(VPATH)}internal/method.h
rational.$(OBJEXT): {$(VPATH)}internal/module.h
rational.$(OBJEXT): {$(VPATH)}internal/newobj.h
-rational.$(OBJEXT): {$(VPATH)}internal/rgengc.h
rational.$(OBJEXT): {$(VPATH)}internal/scan_args.h
rational.$(OBJEXT): {$(VPATH)}internal/special_consts.h
rational.$(OBJEXT): {$(VPATH)}internal/static_assert.h
@@ -12296,15 +13853,30 @@ rational.$(OBJEXT): {$(VPATH)}internal/value_type.h
rational.$(OBJEXT): {$(VPATH)}internal/variable.h
rational.$(OBJEXT): {$(VPATH)}internal/warning_push.h
rational.$(OBJEXT): {$(VPATH)}internal/xmalloc.h
+rational.$(OBJEXT): {$(VPATH)}method.h
rational.$(OBJEXT): {$(VPATH)}missing.h
+rational.$(OBJEXT): {$(VPATH)}node.h
+rational.$(OBJEXT): {$(VPATH)}onigmo.h
+rational.$(OBJEXT): {$(VPATH)}oniguruma.h
rational.$(OBJEXT): {$(VPATH)}rational.c
rational.$(OBJEXT): {$(VPATH)}ruby_assert.h
+rational.$(OBJEXT): {$(VPATH)}ruby_atomic.h
+rational.$(OBJEXT): {$(VPATH)}rubyparser.h
rational.$(OBJEXT): {$(VPATH)}shape.h
rational.$(OBJEXT): {$(VPATH)}st.h
rational.$(OBJEXT): {$(VPATH)}subst.h
+rational.$(OBJEXT): {$(VPATH)}thread_$(THREAD_MODEL).h
+rational.$(OBJEXT): {$(VPATH)}thread_native.h
+rational.$(OBJEXT): {$(VPATH)}vm_core.h
+rational.$(OBJEXT): {$(VPATH)}vm_opts.h
+re.$(OBJEXT): $(CCAN_DIR)/check_type/check_type.h
+re.$(OBJEXT): $(CCAN_DIR)/container_of/container_of.h
+re.$(OBJEXT): $(CCAN_DIR)/list/list.h
+re.$(OBJEXT): $(CCAN_DIR)/str/str.h
re.$(OBJEXT): $(hdrdir)/ruby.h
re.$(OBJEXT): $(hdrdir)/ruby/ruby.h
re.$(OBJEXT): $(top_srcdir)/internal/array.h
+re.$(OBJEXT): $(top_srcdir)/internal/basic_operators.h
re.$(OBJEXT): $(top_srcdir)/internal/bits.h
re.$(OBJEXT): $(top_srcdir)/internal/class.h
re.$(OBJEXT): $(top_srcdir)/internal/compilers.h
@@ -12320,8 +13892,10 @@ re.$(OBJEXT): $(top_srcdir)/internal/static_assert.h
re.$(OBJEXT): $(top_srcdir)/internal/string.h
re.$(OBJEXT): $(top_srcdir)/internal/time.h
re.$(OBJEXT): $(top_srcdir)/internal/variable.h
+re.$(OBJEXT): $(top_srcdir)/internal/vm.h
re.$(OBJEXT): $(top_srcdir)/internal/warnings.h
re.$(OBJEXT): {$(VPATH)}assert.h
+re.$(OBJEXT): {$(VPATH)}atomic.h
re.$(OBJEXT): {$(VPATH)}backward/2/assume.h
re.$(OBJEXT): {$(VPATH)}backward/2/attributes.h
re.$(OBJEXT): {$(VPATH)}backward/2/bool.h
@@ -12337,6 +13911,7 @@ re.$(OBJEXT): {$(VPATH)}defines.h
re.$(OBJEXT): {$(VPATH)}encindex.h
re.$(OBJEXT): {$(VPATH)}encoding.h
re.$(OBJEXT): {$(VPATH)}hrtime.h
+re.$(OBJEXT): {$(VPATH)}id.h
re.$(OBJEXT): {$(VPATH)}id_table.h
re.$(OBJEXT): {$(VPATH)}intern.h
re.$(OBJEXT): {$(VPATH)}internal.h
@@ -12378,6 +13953,7 @@ re.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
re.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
re.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
re.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
+re.$(OBJEXT): {$(VPATH)}internal/attr/packed_struct.h
re.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
re.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
re.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
@@ -12447,7 +14023,6 @@ re.$(OBJEXT): {$(VPATH)}internal/intern/enumerator.h
re.$(OBJEXT): {$(VPATH)}internal/intern/error.h
re.$(OBJEXT): {$(VPATH)}internal/intern/eval.h
re.$(OBJEXT): {$(VPATH)}internal/intern/file.h
-re.$(OBJEXT): {$(VPATH)}internal/intern/gc.h
re.$(OBJEXT): {$(VPATH)}internal/intern/hash.h
re.$(OBJEXT): {$(VPATH)}internal/intern/io.h
re.$(OBJEXT): {$(VPATH)}internal/intern/load.h
@@ -12478,7 +14053,6 @@ re.$(OBJEXT): {$(VPATH)}internal/memory.h
re.$(OBJEXT): {$(VPATH)}internal/method.h
re.$(OBJEXT): {$(VPATH)}internal/module.h
re.$(OBJEXT): {$(VPATH)}internal/newobj.h
-re.$(OBJEXT): {$(VPATH)}internal/rgengc.h
re.$(OBJEXT): {$(VPATH)}internal/scan_args.h
re.$(OBJEXT): {$(VPATH)}internal/special_consts.h
re.$(OBJEXT): {$(VPATH)}internal/static_assert.h
@@ -12490,7 +14064,9 @@ re.$(OBJEXT): {$(VPATH)}internal/value_type.h
re.$(OBJEXT): {$(VPATH)}internal/variable.h
re.$(OBJEXT): {$(VPATH)}internal/warning_push.h
re.$(OBJEXT): {$(VPATH)}internal/xmalloc.h
+re.$(OBJEXT): {$(VPATH)}method.h
re.$(OBJEXT): {$(VPATH)}missing.h
+re.$(OBJEXT): {$(VPATH)}node.h
re.$(OBJEXT): {$(VPATH)}onigmo.h
re.$(OBJEXT): {$(VPATH)}oniguruma.h
re.$(OBJEXT): {$(VPATH)}re.c
@@ -12498,10 +14074,17 @@ re.$(OBJEXT): {$(VPATH)}re.h
re.$(OBJEXT): {$(VPATH)}regenc.h
re.$(OBJEXT): {$(VPATH)}regex.h
re.$(OBJEXT): {$(VPATH)}regint.h
+re.$(OBJEXT): {$(VPATH)}ruby_assert.h
+re.$(OBJEXT): {$(VPATH)}ruby_atomic.h
+re.$(OBJEXT): {$(VPATH)}rubyparser.h
re.$(OBJEXT): {$(VPATH)}shape.h
re.$(OBJEXT): {$(VPATH)}st.h
re.$(OBJEXT): {$(VPATH)}subst.h
+re.$(OBJEXT): {$(VPATH)}thread_$(THREAD_MODEL).h
+re.$(OBJEXT): {$(VPATH)}thread_native.h
re.$(OBJEXT): {$(VPATH)}util.h
+re.$(OBJEXT): {$(VPATH)}vm_core.h
+re.$(OBJEXT): {$(VPATH)}vm_opts.h
regcomp.$(OBJEXT): $(hdrdir)/ruby.h
regcomp.$(OBJEXT): $(hdrdir)/ruby/ruby.h
regcomp.$(OBJEXT): {$(VPATH)}assert.h
@@ -12554,6 +14137,7 @@ regcomp.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
regcomp.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
regcomp.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
regcomp.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
+regcomp.$(OBJEXT): {$(VPATH)}internal/attr/packed_struct.h
regcomp.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
regcomp.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
regcomp.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
@@ -12613,7 +14197,6 @@ regcomp.$(OBJEXT): {$(VPATH)}internal/intern/enumerator.h
regcomp.$(OBJEXT): {$(VPATH)}internal/intern/error.h
regcomp.$(OBJEXT): {$(VPATH)}internal/intern/eval.h
regcomp.$(OBJEXT): {$(VPATH)}internal/intern/file.h
-regcomp.$(OBJEXT): {$(VPATH)}internal/intern/gc.h
regcomp.$(OBJEXT): {$(VPATH)}internal/intern/hash.h
regcomp.$(OBJEXT): {$(VPATH)}internal/intern/io.h
regcomp.$(OBJEXT): {$(VPATH)}internal/intern/load.h
@@ -12644,7 +14227,6 @@ regcomp.$(OBJEXT): {$(VPATH)}internal/memory.h
regcomp.$(OBJEXT): {$(VPATH)}internal/method.h
regcomp.$(OBJEXT): {$(VPATH)}internal/module.h
regcomp.$(OBJEXT): {$(VPATH)}internal/newobj.h
-regcomp.$(OBJEXT): {$(VPATH)}internal/rgengc.h
regcomp.$(OBJEXT): {$(VPATH)}internal/scan_args.h
regcomp.$(OBJEXT): {$(VPATH)}internal/special_consts.h
regcomp.$(OBJEXT): {$(VPATH)}internal/static_assert.h
@@ -12716,6 +14298,7 @@ regenc.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
regenc.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
regenc.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
regenc.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
+regenc.$(OBJEXT): {$(VPATH)}internal/attr/packed_struct.h
regenc.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
regenc.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
regenc.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
@@ -12775,7 +14358,6 @@ regenc.$(OBJEXT): {$(VPATH)}internal/intern/enumerator.h
regenc.$(OBJEXT): {$(VPATH)}internal/intern/error.h
regenc.$(OBJEXT): {$(VPATH)}internal/intern/eval.h
regenc.$(OBJEXT): {$(VPATH)}internal/intern/file.h
-regenc.$(OBJEXT): {$(VPATH)}internal/intern/gc.h
regenc.$(OBJEXT): {$(VPATH)}internal/intern/hash.h
regenc.$(OBJEXT): {$(VPATH)}internal/intern/io.h
regenc.$(OBJEXT): {$(VPATH)}internal/intern/load.h
@@ -12806,7 +14388,6 @@ regenc.$(OBJEXT): {$(VPATH)}internal/memory.h
regenc.$(OBJEXT): {$(VPATH)}internal/method.h
regenc.$(OBJEXT): {$(VPATH)}internal/module.h
regenc.$(OBJEXT): {$(VPATH)}internal/newobj.h
-regenc.$(OBJEXT): {$(VPATH)}internal/rgengc.h
regenc.$(OBJEXT): {$(VPATH)}internal/scan_args.h
regenc.$(OBJEXT): {$(VPATH)}internal/special_consts.h
regenc.$(OBJEXT): {$(VPATH)}internal/static_assert.h
@@ -12877,6 +14458,7 @@ regerror.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
regerror.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
regerror.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
regerror.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
+regerror.$(OBJEXT): {$(VPATH)}internal/attr/packed_struct.h
regerror.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
regerror.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
regerror.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
@@ -12936,7 +14518,6 @@ regerror.$(OBJEXT): {$(VPATH)}internal/intern/enumerator.h
regerror.$(OBJEXT): {$(VPATH)}internal/intern/error.h
regerror.$(OBJEXT): {$(VPATH)}internal/intern/eval.h
regerror.$(OBJEXT): {$(VPATH)}internal/intern/file.h
-regerror.$(OBJEXT): {$(VPATH)}internal/intern/gc.h
regerror.$(OBJEXT): {$(VPATH)}internal/intern/hash.h
regerror.$(OBJEXT): {$(VPATH)}internal/intern/io.h
regerror.$(OBJEXT): {$(VPATH)}internal/intern/load.h
@@ -12967,7 +14548,6 @@ regerror.$(OBJEXT): {$(VPATH)}internal/memory.h
regerror.$(OBJEXT): {$(VPATH)}internal/method.h
regerror.$(OBJEXT): {$(VPATH)}internal/module.h
regerror.$(OBJEXT): {$(VPATH)}internal/newobj.h
-regerror.$(OBJEXT): {$(VPATH)}internal/rgengc.h
regerror.$(OBJEXT): {$(VPATH)}internal/scan_args.h
regerror.$(OBJEXT): {$(VPATH)}internal/special_consts.h
regerror.$(OBJEXT): {$(VPATH)}internal/static_assert.h
@@ -13038,6 +14618,7 @@ regexec.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
regexec.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
regexec.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
regexec.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
+regexec.$(OBJEXT): {$(VPATH)}internal/attr/packed_struct.h
regexec.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
regexec.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
regexec.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
@@ -13097,7 +14678,6 @@ regexec.$(OBJEXT): {$(VPATH)}internal/intern/enumerator.h
regexec.$(OBJEXT): {$(VPATH)}internal/intern/error.h
regexec.$(OBJEXT): {$(VPATH)}internal/intern/eval.h
regexec.$(OBJEXT): {$(VPATH)}internal/intern/file.h
-regexec.$(OBJEXT): {$(VPATH)}internal/intern/gc.h
regexec.$(OBJEXT): {$(VPATH)}internal/intern/hash.h
regexec.$(OBJEXT): {$(VPATH)}internal/intern/io.h
regexec.$(OBJEXT): {$(VPATH)}internal/intern/load.h
@@ -13128,7 +14708,6 @@ regexec.$(OBJEXT): {$(VPATH)}internal/memory.h
regexec.$(OBJEXT): {$(VPATH)}internal/method.h
regexec.$(OBJEXT): {$(VPATH)}internal/module.h
regexec.$(OBJEXT): {$(VPATH)}internal/newobj.h
-regexec.$(OBJEXT): {$(VPATH)}internal/rgengc.h
regexec.$(OBJEXT): {$(VPATH)}internal/scan_args.h
regexec.$(OBJEXT): {$(VPATH)}internal/special_consts.h
regexec.$(OBJEXT): {$(VPATH)}internal/static_assert.h
@@ -13203,6 +14782,7 @@ regparse.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
regparse.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
regparse.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
regparse.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
+regparse.$(OBJEXT): {$(VPATH)}internal/attr/packed_struct.h
regparse.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
regparse.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
regparse.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
@@ -13262,7 +14842,6 @@ regparse.$(OBJEXT): {$(VPATH)}internal/intern/enumerator.h
regparse.$(OBJEXT): {$(VPATH)}internal/intern/error.h
regparse.$(OBJEXT): {$(VPATH)}internal/intern/eval.h
regparse.$(OBJEXT): {$(VPATH)}internal/intern/file.h
-regparse.$(OBJEXT): {$(VPATH)}internal/intern/gc.h
regparse.$(OBJEXT): {$(VPATH)}internal/intern/hash.h
regparse.$(OBJEXT): {$(VPATH)}internal/intern/io.h
regparse.$(OBJEXT): {$(VPATH)}internal/intern/load.h
@@ -13293,7 +14872,6 @@ regparse.$(OBJEXT): {$(VPATH)}internal/memory.h
regparse.$(OBJEXT): {$(VPATH)}internal/method.h
regparse.$(OBJEXT): {$(VPATH)}internal/module.h
regparse.$(OBJEXT): {$(VPATH)}internal/newobj.h
-regparse.$(OBJEXT): {$(VPATH)}internal/rgengc.h
regparse.$(OBJEXT): {$(VPATH)}internal/scan_args.h
regparse.$(OBJEXT): {$(VPATH)}internal/special_consts.h
regparse.$(OBJEXT): {$(VPATH)}internal/static_assert.h
@@ -13365,6 +14943,7 @@ regsyntax.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
regsyntax.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
regsyntax.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
regsyntax.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
+regsyntax.$(OBJEXT): {$(VPATH)}internal/attr/packed_struct.h
regsyntax.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
regsyntax.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
regsyntax.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
@@ -13424,7 +15003,6 @@ regsyntax.$(OBJEXT): {$(VPATH)}internal/intern/enumerator.h
regsyntax.$(OBJEXT): {$(VPATH)}internal/intern/error.h
regsyntax.$(OBJEXT): {$(VPATH)}internal/intern/eval.h
regsyntax.$(OBJEXT): {$(VPATH)}internal/intern/file.h
-regsyntax.$(OBJEXT): {$(VPATH)}internal/intern/gc.h
regsyntax.$(OBJEXT): {$(VPATH)}internal/intern/hash.h
regsyntax.$(OBJEXT): {$(VPATH)}internal/intern/io.h
regsyntax.$(OBJEXT): {$(VPATH)}internal/intern/load.h
@@ -13455,7 +15033,6 @@ regsyntax.$(OBJEXT): {$(VPATH)}internal/memory.h
regsyntax.$(OBJEXT): {$(VPATH)}internal/method.h
regsyntax.$(OBJEXT): {$(VPATH)}internal/module.h
regsyntax.$(OBJEXT): {$(VPATH)}internal/newobj.h
-regsyntax.$(OBJEXT): {$(VPATH)}internal/rgengc.h
regsyntax.$(OBJEXT): {$(VPATH)}internal/scan_args.h
regsyntax.$(OBJEXT): {$(VPATH)}internal/special_consts.h
regsyntax.$(OBJEXT): {$(VPATH)}internal/static_assert.h
@@ -13474,6 +15051,511 @@ regsyntax.$(OBJEXT): {$(VPATH)}regint.h
regsyntax.$(OBJEXT): {$(VPATH)}regsyntax.c
regsyntax.$(OBJEXT): {$(VPATH)}st.h
regsyntax.$(OBJEXT): {$(VPATH)}subst.h
+rjit.$(OBJEXT): $(CCAN_DIR)/check_type/check_type.h
+rjit.$(OBJEXT): $(CCAN_DIR)/container_of/container_of.h
+rjit.$(OBJEXT): $(CCAN_DIR)/list/list.h
+rjit.$(OBJEXT): $(CCAN_DIR)/str/str.h
+rjit.$(OBJEXT): $(hdrdir)/ruby.h
+rjit.$(OBJEXT): $(hdrdir)/ruby/ruby.h
+rjit.$(OBJEXT): $(hdrdir)/ruby/version.h
+rjit.$(OBJEXT): $(top_srcdir)/internal/array.h
+rjit.$(OBJEXT): $(top_srcdir)/internal/basic_operators.h
+rjit.$(OBJEXT): $(top_srcdir)/internal/class.h
+rjit.$(OBJEXT): $(top_srcdir)/internal/cmdlineopt.h
+rjit.$(OBJEXT): $(top_srcdir)/internal/compile.h
+rjit.$(OBJEXT): $(top_srcdir)/internal/compilers.h
+rjit.$(OBJEXT): $(top_srcdir)/internal/cont.h
+rjit.$(OBJEXT): $(top_srcdir)/internal/file.h
+rjit.$(OBJEXT): $(top_srcdir)/internal/gc.h
+rjit.$(OBJEXT): $(top_srcdir)/internal/hash.h
+rjit.$(OBJEXT): $(top_srcdir)/internal/imemo.h
+rjit.$(OBJEXT): $(top_srcdir)/internal/process.h
+rjit.$(OBJEXT): $(top_srcdir)/internal/serial.h
+rjit.$(OBJEXT): $(top_srcdir)/internal/static_assert.h
+rjit.$(OBJEXT): $(top_srcdir)/internal/string.h
+rjit.$(OBJEXT): $(top_srcdir)/internal/struct.h
+rjit.$(OBJEXT): $(top_srcdir)/internal/variable.h
+rjit.$(OBJEXT): $(top_srcdir)/internal/vm.h
+rjit.$(OBJEXT): $(top_srcdir)/internal/warnings.h
+rjit.$(OBJEXT): $(top_srcdir)/prism/defines.h
+rjit.$(OBJEXT): $(top_srcdir)/prism/diagnostic.h
+rjit.$(OBJEXT): $(top_srcdir)/prism/encoding.h
+rjit.$(OBJEXT): $(top_srcdir)/prism/node.h
+rjit.$(OBJEXT): $(top_srcdir)/prism/options.h
+rjit.$(OBJEXT): $(top_srcdir)/prism/pack.h
+rjit.$(OBJEXT): $(top_srcdir)/prism/parser.h
+rjit.$(OBJEXT): $(top_srcdir)/prism/prettyprint.h
+rjit.$(OBJEXT): $(top_srcdir)/prism/prism.h
+rjit.$(OBJEXT): $(top_srcdir)/prism/regexp.h
+rjit.$(OBJEXT): $(top_srcdir)/prism/util/pm_buffer.h
+rjit.$(OBJEXT): $(top_srcdir)/prism/util/pm_char.h
+rjit.$(OBJEXT): $(top_srcdir)/prism/util/pm_constant_pool.h
+rjit.$(OBJEXT): $(top_srcdir)/prism/util/pm_list.h
+rjit.$(OBJEXT): $(top_srcdir)/prism/util/pm_memchr.h
+rjit.$(OBJEXT): $(top_srcdir)/prism/util/pm_newline_list.h
+rjit.$(OBJEXT): $(top_srcdir)/prism/util/pm_state_stack.h
+rjit.$(OBJEXT): $(top_srcdir)/prism/util/pm_string.h
+rjit.$(OBJEXT): $(top_srcdir)/prism/util/pm_string_list.h
+rjit.$(OBJEXT): $(top_srcdir)/prism/util/pm_strncasecmp.h
+rjit.$(OBJEXT): $(top_srcdir)/prism/util/pm_strpbrk.h
+rjit.$(OBJEXT): {$(VPATH)}assert.h
+rjit.$(OBJEXT): {$(VPATH)}atomic.h
+rjit.$(OBJEXT): {$(VPATH)}backward/2/assume.h
+rjit.$(OBJEXT): {$(VPATH)}backward/2/attributes.h
+rjit.$(OBJEXT): {$(VPATH)}backward/2/bool.h
+rjit.$(OBJEXT): {$(VPATH)}backward/2/gcc_version_since.h
+rjit.$(OBJEXT): {$(VPATH)}backward/2/inttypes.h
+rjit.$(OBJEXT): {$(VPATH)}backward/2/limits.h
+rjit.$(OBJEXT): {$(VPATH)}backward/2/long_long.h
+rjit.$(OBJEXT): {$(VPATH)}backward/2/stdalign.h
+rjit.$(OBJEXT): {$(VPATH)}backward/2/stdarg.h
+rjit.$(OBJEXT): {$(VPATH)}builtin.h
+rjit.$(OBJEXT): {$(VPATH)}config.h
+rjit.$(OBJEXT): {$(VPATH)}constant.h
+rjit.$(OBJEXT): {$(VPATH)}debug.h
+rjit.$(OBJEXT): {$(VPATH)}debug_counter.h
+rjit.$(OBJEXT): {$(VPATH)}defines.h
+rjit.$(OBJEXT): {$(VPATH)}dln.h
+rjit.$(OBJEXT): {$(VPATH)}encoding.h
+rjit.$(OBJEXT): {$(VPATH)}id.h
+rjit.$(OBJEXT): {$(VPATH)}id_table.h
+rjit.$(OBJEXT): {$(VPATH)}insns.def
+rjit.$(OBJEXT): {$(VPATH)}insns.inc
+rjit.$(OBJEXT): {$(VPATH)}insns_info.inc
+rjit.$(OBJEXT): {$(VPATH)}intern.h
+rjit.$(OBJEXT): {$(VPATH)}internal.h
+rjit.$(OBJEXT): {$(VPATH)}internal/abi.h
+rjit.$(OBJEXT): {$(VPATH)}internal/anyargs.h
+rjit.$(OBJEXT): {$(VPATH)}internal/arithmetic.h
+rjit.$(OBJEXT): {$(VPATH)}internal/arithmetic/char.h
+rjit.$(OBJEXT): {$(VPATH)}internal/arithmetic/double.h
+rjit.$(OBJEXT): {$(VPATH)}internal/arithmetic/fixnum.h
+rjit.$(OBJEXT): {$(VPATH)}internal/arithmetic/gid_t.h
+rjit.$(OBJEXT): {$(VPATH)}internal/arithmetic/int.h
+rjit.$(OBJEXT): {$(VPATH)}internal/arithmetic/intptr_t.h
+rjit.$(OBJEXT): {$(VPATH)}internal/arithmetic/long.h
+rjit.$(OBJEXT): {$(VPATH)}internal/arithmetic/long_long.h
+rjit.$(OBJEXT): {$(VPATH)}internal/arithmetic/mode_t.h
+rjit.$(OBJEXT): {$(VPATH)}internal/arithmetic/off_t.h
+rjit.$(OBJEXT): {$(VPATH)}internal/arithmetic/pid_t.h
+rjit.$(OBJEXT): {$(VPATH)}internal/arithmetic/short.h
+rjit.$(OBJEXT): {$(VPATH)}internal/arithmetic/size_t.h
+rjit.$(OBJEXT): {$(VPATH)}internal/arithmetic/st_data_t.h
+rjit.$(OBJEXT): {$(VPATH)}internal/arithmetic/uid_t.h
+rjit.$(OBJEXT): {$(VPATH)}internal/assume.h
+rjit.$(OBJEXT): {$(VPATH)}internal/attr/alloc_size.h
+rjit.$(OBJEXT): {$(VPATH)}internal/attr/artificial.h
+rjit.$(OBJEXT): {$(VPATH)}internal/attr/cold.h
+rjit.$(OBJEXT): {$(VPATH)}internal/attr/const.h
+rjit.$(OBJEXT): {$(VPATH)}internal/attr/constexpr.h
+rjit.$(OBJEXT): {$(VPATH)}internal/attr/deprecated.h
+rjit.$(OBJEXT): {$(VPATH)}internal/attr/diagnose_if.h
+rjit.$(OBJEXT): {$(VPATH)}internal/attr/enum_extensibility.h
+rjit.$(OBJEXT): {$(VPATH)}internal/attr/error.h
+rjit.$(OBJEXT): {$(VPATH)}internal/attr/flag_enum.h
+rjit.$(OBJEXT): {$(VPATH)}internal/attr/forceinline.h
+rjit.$(OBJEXT): {$(VPATH)}internal/attr/format.h
+rjit.$(OBJEXT): {$(VPATH)}internal/attr/maybe_unused.h
+rjit.$(OBJEXT): {$(VPATH)}internal/attr/noalias.h
+rjit.$(OBJEXT): {$(VPATH)}internal/attr/nodiscard.h
+rjit.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
+rjit.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
+rjit.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
+rjit.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
+rjit.$(OBJEXT): {$(VPATH)}internal/attr/packed_struct.h
+rjit.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
+rjit.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
+rjit.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
+rjit.$(OBJEXT): {$(VPATH)}internal/attr/warning.h
+rjit.$(OBJEXT): {$(VPATH)}internal/attr/weakref.h
+rjit.$(OBJEXT): {$(VPATH)}internal/cast.h
+rjit.$(OBJEXT): {$(VPATH)}internal/compiler_is.h
+rjit.$(OBJEXT): {$(VPATH)}internal/compiler_is/apple.h
+rjit.$(OBJEXT): {$(VPATH)}internal/compiler_is/clang.h
+rjit.$(OBJEXT): {$(VPATH)}internal/compiler_is/gcc.h
+rjit.$(OBJEXT): {$(VPATH)}internal/compiler_is/intel.h
+rjit.$(OBJEXT): {$(VPATH)}internal/compiler_is/msvc.h
+rjit.$(OBJEXT): {$(VPATH)}internal/compiler_is/sunpro.h
+rjit.$(OBJEXT): {$(VPATH)}internal/compiler_since.h
+rjit.$(OBJEXT): {$(VPATH)}internal/config.h
+rjit.$(OBJEXT): {$(VPATH)}internal/constant_p.h
+rjit.$(OBJEXT): {$(VPATH)}internal/core.h
+rjit.$(OBJEXT): {$(VPATH)}internal/core/rarray.h
+rjit.$(OBJEXT): {$(VPATH)}internal/core/rbasic.h
+rjit.$(OBJEXT): {$(VPATH)}internal/core/rbignum.h
+rjit.$(OBJEXT): {$(VPATH)}internal/core/rclass.h
+rjit.$(OBJEXT): {$(VPATH)}internal/core/rdata.h
+rjit.$(OBJEXT): {$(VPATH)}internal/core/rfile.h
+rjit.$(OBJEXT): {$(VPATH)}internal/core/rhash.h
+rjit.$(OBJEXT): {$(VPATH)}internal/core/robject.h
+rjit.$(OBJEXT): {$(VPATH)}internal/core/rregexp.h
+rjit.$(OBJEXT): {$(VPATH)}internal/core/rstring.h
+rjit.$(OBJEXT): {$(VPATH)}internal/core/rstruct.h
+rjit.$(OBJEXT): {$(VPATH)}internal/core/rtypeddata.h
+rjit.$(OBJEXT): {$(VPATH)}internal/ctype.h
+rjit.$(OBJEXT): {$(VPATH)}internal/dllexport.h
+rjit.$(OBJEXT): {$(VPATH)}internal/dosish.h
+rjit.$(OBJEXT): {$(VPATH)}internal/encoding/coderange.h
+rjit.$(OBJEXT): {$(VPATH)}internal/encoding/ctype.h
+rjit.$(OBJEXT): {$(VPATH)}internal/encoding/encoding.h
+rjit.$(OBJEXT): {$(VPATH)}internal/encoding/pathname.h
+rjit.$(OBJEXT): {$(VPATH)}internal/encoding/re.h
+rjit.$(OBJEXT): {$(VPATH)}internal/encoding/sprintf.h
+rjit.$(OBJEXT): {$(VPATH)}internal/encoding/string.h
+rjit.$(OBJEXT): {$(VPATH)}internal/encoding/symbol.h
+rjit.$(OBJEXT): {$(VPATH)}internal/encoding/transcode.h
+rjit.$(OBJEXT): {$(VPATH)}internal/error.h
+rjit.$(OBJEXT): {$(VPATH)}internal/eval.h
+rjit.$(OBJEXT): {$(VPATH)}internal/event.h
+rjit.$(OBJEXT): {$(VPATH)}internal/fl_type.h
+rjit.$(OBJEXT): {$(VPATH)}internal/gc.h
+rjit.$(OBJEXT): {$(VPATH)}internal/glob.h
+rjit.$(OBJEXT): {$(VPATH)}internal/globals.h
+rjit.$(OBJEXT): {$(VPATH)}internal/has/attribute.h
+rjit.$(OBJEXT): {$(VPATH)}internal/has/builtin.h
+rjit.$(OBJEXT): {$(VPATH)}internal/has/c_attribute.h
+rjit.$(OBJEXT): {$(VPATH)}internal/has/cpp_attribute.h
+rjit.$(OBJEXT): {$(VPATH)}internal/has/declspec_attribute.h
+rjit.$(OBJEXT): {$(VPATH)}internal/has/extension.h
+rjit.$(OBJEXT): {$(VPATH)}internal/has/feature.h
+rjit.$(OBJEXT): {$(VPATH)}internal/has/warning.h
+rjit.$(OBJEXT): {$(VPATH)}internal/intern/array.h
+rjit.$(OBJEXT): {$(VPATH)}internal/intern/bignum.h
+rjit.$(OBJEXT): {$(VPATH)}internal/intern/class.h
+rjit.$(OBJEXT): {$(VPATH)}internal/intern/compar.h
+rjit.$(OBJEXT): {$(VPATH)}internal/intern/complex.h
+rjit.$(OBJEXT): {$(VPATH)}internal/intern/cont.h
+rjit.$(OBJEXT): {$(VPATH)}internal/intern/dir.h
+rjit.$(OBJEXT): {$(VPATH)}internal/intern/enum.h
+rjit.$(OBJEXT): {$(VPATH)}internal/intern/enumerator.h
+rjit.$(OBJEXT): {$(VPATH)}internal/intern/error.h
+rjit.$(OBJEXT): {$(VPATH)}internal/intern/eval.h
+rjit.$(OBJEXT): {$(VPATH)}internal/intern/file.h
+rjit.$(OBJEXT): {$(VPATH)}internal/intern/hash.h
+rjit.$(OBJEXT): {$(VPATH)}internal/intern/io.h
+rjit.$(OBJEXT): {$(VPATH)}internal/intern/load.h
+rjit.$(OBJEXT): {$(VPATH)}internal/intern/marshal.h
+rjit.$(OBJEXT): {$(VPATH)}internal/intern/numeric.h
+rjit.$(OBJEXT): {$(VPATH)}internal/intern/object.h
+rjit.$(OBJEXT): {$(VPATH)}internal/intern/parse.h
+rjit.$(OBJEXT): {$(VPATH)}internal/intern/proc.h
+rjit.$(OBJEXT): {$(VPATH)}internal/intern/process.h
+rjit.$(OBJEXT): {$(VPATH)}internal/intern/random.h
+rjit.$(OBJEXT): {$(VPATH)}internal/intern/range.h
+rjit.$(OBJEXT): {$(VPATH)}internal/intern/rational.h
+rjit.$(OBJEXT): {$(VPATH)}internal/intern/re.h
+rjit.$(OBJEXT): {$(VPATH)}internal/intern/ruby.h
+rjit.$(OBJEXT): {$(VPATH)}internal/intern/select.h
+rjit.$(OBJEXT): {$(VPATH)}internal/intern/select/largesize.h
+rjit.$(OBJEXT): {$(VPATH)}internal/intern/signal.h
+rjit.$(OBJEXT): {$(VPATH)}internal/intern/sprintf.h
+rjit.$(OBJEXT): {$(VPATH)}internal/intern/string.h
+rjit.$(OBJEXT): {$(VPATH)}internal/intern/struct.h
+rjit.$(OBJEXT): {$(VPATH)}internal/intern/thread.h
+rjit.$(OBJEXT): {$(VPATH)}internal/intern/time.h
+rjit.$(OBJEXT): {$(VPATH)}internal/intern/variable.h
+rjit.$(OBJEXT): {$(VPATH)}internal/intern/vm.h
+rjit.$(OBJEXT): {$(VPATH)}internal/interpreter.h
+rjit.$(OBJEXT): {$(VPATH)}internal/iterator.h
+rjit.$(OBJEXT): {$(VPATH)}internal/memory.h
+rjit.$(OBJEXT): {$(VPATH)}internal/method.h
+rjit.$(OBJEXT): {$(VPATH)}internal/module.h
+rjit.$(OBJEXT): {$(VPATH)}internal/newobj.h
+rjit.$(OBJEXT): {$(VPATH)}internal/scan_args.h
+rjit.$(OBJEXT): {$(VPATH)}internal/special_consts.h
+rjit.$(OBJEXT): {$(VPATH)}internal/static_assert.h
+rjit.$(OBJEXT): {$(VPATH)}internal/stdalign.h
+rjit.$(OBJEXT): {$(VPATH)}internal/stdbool.h
+rjit.$(OBJEXT): {$(VPATH)}internal/symbol.h
+rjit.$(OBJEXT): {$(VPATH)}internal/value.h
+rjit.$(OBJEXT): {$(VPATH)}internal/value_type.h
+rjit.$(OBJEXT): {$(VPATH)}internal/variable.h
+rjit.$(OBJEXT): {$(VPATH)}internal/warning_push.h
+rjit.$(OBJEXT): {$(VPATH)}internal/xmalloc.h
+rjit.$(OBJEXT): {$(VPATH)}iseq.h
+rjit.$(OBJEXT): {$(VPATH)}method.h
+rjit.$(OBJEXT): {$(VPATH)}missing.h
+rjit.$(OBJEXT): {$(VPATH)}node.h
+rjit.$(OBJEXT): {$(VPATH)}onigmo.h
+rjit.$(OBJEXT): {$(VPATH)}oniguruma.h
+rjit.$(OBJEXT): {$(VPATH)}prism/ast.h
+rjit.$(OBJEXT): {$(VPATH)}prism/version.h
+rjit.$(OBJEXT): {$(VPATH)}prism_compile.h
+rjit.$(OBJEXT): {$(VPATH)}ractor.h
+rjit.$(OBJEXT): {$(VPATH)}ractor_core.h
+rjit.$(OBJEXT): {$(VPATH)}rjit.c
+rjit.$(OBJEXT): {$(VPATH)}rjit.h
+rjit.$(OBJEXT): {$(VPATH)}rjit.rbinc
+rjit.$(OBJEXT): {$(VPATH)}rjit_c.h
+rjit.$(OBJEXT): {$(VPATH)}ruby_assert.h
+rjit.$(OBJEXT): {$(VPATH)}ruby_atomic.h
+rjit.$(OBJEXT): {$(VPATH)}rubyparser.h
+rjit.$(OBJEXT): {$(VPATH)}shape.h
+rjit.$(OBJEXT): {$(VPATH)}st.h
+rjit.$(OBJEXT): {$(VPATH)}subst.h
+rjit.$(OBJEXT): {$(VPATH)}thread.h
+rjit.$(OBJEXT): {$(VPATH)}thread_$(THREAD_MODEL).h
+rjit.$(OBJEXT): {$(VPATH)}thread_native.h
+rjit.$(OBJEXT): {$(VPATH)}util.h
+rjit.$(OBJEXT): {$(VPATH)}vm_callinfo.h
+rjit.$(OBJEXT): {$(VPATH)}vm_core.h
+rjit.$(OBJEXT): {$(VPATH)}vm_debug.h
+rjit.$(OBJEXT): {$(VPATH)}vm_opts.h
+rjit.$(OBJEXT): {$(VPATH)}vm_sync.h
+rjit.$(OBJEXT): {$(VPATH)}yjit.h
+rjit_c.$(OBJEXT): $(CCAN_DIR)/check_type/check_type.h
+rjit_c.$(OBJEXT): $(CCAN_DIR)/container_of/container_of.h
+rjit_c.$(OBJEXT): $(CCAN_DIR)/list/list.h
+rjit_c.$(OBJEXT): $(CCAN_DIR)/str/str.h
+rjit_c.$(OBJEXT): $(hdrdir)/ruby.h
+rjit_c.$(OBJEXT): $(hdrdir)/ruby/ruby.h
+rjit_c.$(OBJEXT): $(srcdir)/rjit_c.rb
+rjit_c.$(OBJEXT): $(top_srcdir)/internal/array.h
+rjit_c.$(OBJEXT): $(top_srcdir)/internal/basic_operators.h
+rjit_c.$(OBJEXT): $(top_srcdir)/internal/class.h
+rjit_c.$(OBJEXT): $(top_srcdir)/internal/compile.h
+rjit_c.$(OBJEXT): $(top_srcdir)/internal/compilers.h
+rjit_c.$(OBJEXT): $(top_srcdir)/internal/fixnum.h
+rjit_c.$(OBJEXT): $(top_srcdir)/internal/gc.h
+rjit_c.$(OBJEXT): $(top_srcdir)/internal/hash.h
+rjit_c.$(OBJEXT): $(top_srcdir)/internal/imemo.h
+rjit_c.$(OBJEXT): $(top_srcdir)/internal/object.h
+rjit_c.$(OBJEXT): $(top_srcdir)/internal/proc.h
+rjit_c.$(OBJEXT): $(top_srcdir)/internal/sanitizers.h
+rjit_c.$(OBJEXT): $(top_srcdir)/internal/serial.h
+rjit_c.$(OBJEXT): $(top_srcdir)/internal/static_assert.h
+rjit_c.$(OBJEXT): $(top_srcdir)/internal/string.h
+rjit_c.$(OBJEXT): $(top_srcdir)/internal/struct.h
+rjit_c.$(OBJEXT): $(top_srcdir)/internal/variable.h
+rjit_c.$(OBJEXT): $(top_srcdir)/internal/vm.h
+rjit_c.$(OBJEXT): $(top_srcdir)/internal/warnings.h
+rjit_c.$(OBJEXT): $(top_srcdir)/prism/defines.h
+rjit_c.$(OBJEXT): $(top_srcdir)/prism/diagnostic.h
+rjit_c.$(OBJEXT): $(top_srcdir)/prism/encoding.h
+rjit_c.$(OBJEXT): $(top_srcdir)/prism/node.h
+rjit_c.$(OBJEXT): $(top_srcdir)/prism/options.h
+rjit_c.$(OBJEXT): $(top_srcdir)/prism/pack.h
+rjit_c.$(OBJEXT): $(top_srcdir)/prism/parser.h
+rjit_c.$(OBJEXT): $(top_srcdir)/prism/prettyprint.h
+rjit_c.$(OBJEXT): $(top_srcdir)/prism/prism.h
+rjit_c.$(OBJEXT): $(top_srcdir)/prism/regexp.h
+rjit_c.$(OBJEXT): $(top_srcdir)/prism/util/pm_buffer.h
+rjit_c.$(OBJEXT): $(top_srcdir)/prism/util/pm_char.h
+rjit_c.$(OBJEXT): $(top_srcdir)/prism/util/pm_constant_pool.h
+rjit_c.$(OBJEXT): $(top_srcdir)/prism/util/pm_list.h
+rjit_c.$(OBJEXT): $(top_srcdir)/prism/util/pm_memchr.h
+rjit_c.$(OBJEXT): $(top_srcdir)/prism/util/pm_newline_list.h
+rjit_c.$(OBJEXT): $(top_srcdir)/prism/util/pm_state_stack.h
+rjit_c.$(OBJEXT): $(top_srcdir)/prism/util/pm_string.h
+rjit_c.$(OBJEXT): $(top_srcdir)/prism/util/pm_string_list.h
+rjit_c.$(OBJEXT): $(top_srcdir)/prism/util/pm_strncasecmp.h
+rjit_c.$(OBJEXT): $(top_srcdir)/prism/util/pm_strpbrk.h
+rjit_c.$(OBJEXT): {$(VPATH)}assert.h
+rjit_c.$(OBJEXT): {$(VPATH)}atomic.h
+rjit_c.$(OBJEXT): {$(VPATH)}backward/2/assume.h
+rjit_c.$(OBJEXT): {$(VPATH)}backward/2/attributes.h
+rjit_c.$(OBJEXT): {$(VPATH)}backward/2/bool.h
+rjit_c.$(OBJEXT): {$(VPATH)}backward/2/gcc_version_since.h
+rjit_c.$(OBJEXT): {$(VPATH)}backward/2/inttypes.h
+rjit_c.$(OBJEXT): {$(VPATH)}backward/2/limits.h
+rjit_c.$(OBJEXT): {$(VPATH)}backward/2/long_long.h
+rjit_c.$(OBJEXT): {$(VPATH)}backward/2/stdalign.h
+rjit_c.$(OBJEXT): {$(VPATH)}backward/2/stdarg.h
+rjit_c.$(OBJEXT): {$(VPATH)}builtin.h
+rjit_c.$(OBJEXT): {$(VPATH)}config.h
+rjit_c.$(OBJEXT): {$(VPATH)}constant.h
+rjit_c.$(OBJEXT): {$(VPATH)}debug.h
+rjit_c.$(OBJEXT): {$(VPATH)}debug_counter.h
+rjit_c.$(OBJEXT): {$(VPATH)}defines.h
+rjit_c.$(OBJEXT): {$(VPATH)}encoding.h
+rjit_c.$(OBJEXT): {$(VPATH)}id.h
+rjit_c.$(OBJEXT): {$(VPATH)}id_table.h
+rjit_c.$(OBJEXT): {$(VPATH)}insns.def
+rjit_c.$(OBJEXT): {$(VPATH)}insns.inc
+rjit_c.$(OBJEXT): {$(VPATH)}insns_info.inc
+rjit_c.$(OBJEXT): {$(VPATH)}intern.h
+rjit_c.$(OBJEXT): {$(VPATH)}internal.h
+rjit_c.$(OBJEXT): {$(VPATH)}internal/abi.h
+rjit_c.$(OBJEXT): {$(VPATH)}internal/anyargs.h
+rjit_c.$(OBJEXT): {$(VPATH)}internal/arithmetic.h
+rjit_c.$(OBJEXT): {$(VPATH)}internal/arithmetic/char.h
+rjit_c.$(OBJEXT): {$(VPATH)}internal/arithmetic/double.h
+rjit_c.$(OBJEXT): {$(VPATH)}internal/arithmetic/fixnum.h
+rjit_c.$(OBJEXT): {$(VPATH)}internal/arithmetic/gid_t.h
+rjit_c.$(OBJEXT): {$(VPATH)}internal/arithmetic/int.h
+rjit_c.$(OBJEXT): {$(VPATH)}internal/arithmetic/intptr_t.h
+rjit_c.$(OBJEXT): {$(VPATH)}internal/arithmetic/long.h
+rjit_c.$(OBJEXT): {$(VPATH)}internal/arithmetic/long_long.h
+rjit_c.$(OBJEXT): {$(VPATH)}internal/arithmetic/mode_t.h
+rjit_c.$(OBJEXT): {$(VPATH)}internal/arithmetic/off_t.h
+rjit_c.$(OBJEXT): {$(VPATH)}internal/arithmetic/pid_t.h
+rjit_c.$(OBJEXT): {$(VPATH)}internal/arithmetic/short.h
+rjit_c.$(OBJEXT): {$(VPATH)}internal/arithmetic/size_t.h
+rjit_c.$(OBJEXT): {$(VPATH)}internal/arithmetic/st_data_t.h
+rjit_c.$(OBJEXT): {$(VPATH)}internal/arithmetic/uid_t.h
+rjit_c.$(OBJEXT): {$(VPATH)}internal/assume.h
+rjit_c.$(OBJEXT): {$(VPATH)}internal/attr/alloc_size.h
+rjit_c.$(OBJEXT): {$(VPATH)}internal/attr/artificial.h
+rjit_c.$(OBJEXT): {$(VPATH)}internal/attr/cold.h
+rjit_c.$(OBJEXT): {$(VPATH)}internal/attr/const.h
+rjit_c.$(OBJEXT): {$(VPATH)}internal/attr/constexpr.h
+rjit_c.$(OBJEXT): {$(VPATH)}internal/attr/deprecated.h
+rjit_c.$(OBJEXT): {$(VPATH)}internal/attr/diagnose_if.h
+rjit_c.$(OBJEXT): {$(VPATH)}internal/attr/enum_extensibility.h
+rjit_c.$(OBJEXT): {$(VPATH)}internal/attr/error.h
+rjit_c.$(OBJEXT): {$(VPATH)}internal/attr/flag_enum.h
+rjit_c.$(OBJEXT): {$(VPATH)}internal/attr/forceinline.h
+rjit_c.$(OBJEXT): {$(VPATH)}internal/attr/format.h
+rjit_c.$(OBJEXT): {$(VPATH)}internal/attr/maybe_unused.h
+rjit_c.$(OBJEXT): {$(VPATH)}internal/attr/noalias.h
+rjit_c.$(OBJEXT): {$(VPATH)}internal/attr/nodiscard.h
+rjit_c.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
+rjit_c.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
+rjit_c.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
+rjit_c.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
+rjit_c.$(OBJEXT): {$(VPATH)}internal/attr/packed_struct.h
+rjit_c.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
+rjit_c.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
+rjit_c.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
+rjit_c.$(OBJEXT): {$(VPATH)}internal/attr/warning.h
+rjit_c.$(OBJEXT): {$(VPATH)}internal/attr/weakref.h
+rjit_c.$(OBJEXT): {$(VPATH)}internal/cast.h
+rjit_c.$(OBJEXT): {$(VPATH)}internal/compiler_is.h
+rjit_c.$(OBJEXT): {$(VPATH)}internal/compiler_is/apple.h
+rjit_c.$(OBJEXT): {$(VPATH)}internal/compiler_is/clang.h
+rjit_c.$(OBJEXT): {$(VPATH)}internal/compiler_is/gcc.h
+rjit_c.$(OBJEXT): {$(VPATH)}internal/compiler_is/intel.h
+rjit_c.$(OBJEXT): {$(VPATH)}internal/compiler_is/msvc.h
+rjit_c.$(OBJEXT): {$(VPATH)}internal/compiler_is/sunpro.h
+rjit_c.$(OBJEXT): {$(VPATH)}internal/compiler_since.h
+rjit_c.$(OBJEXT): {$(VPATH)}internal/config.h
+rjit_c.$(OBJEXT): {$(VPATH)}internal/constant_p.h
+rjit_c.$(OBJEXT): {$(VPATH)}internal/core.h
+rjit_c.$(OBJEXT): {$(VPATH)}internal/core/rarray.h
+rjit_c.$(OBJEXT): {$(VPATH)}internal/core/rbasic.h
+rjit_c.$(OBJEXT): {$(VPATH)}internal/core/rbignum.h
+rjit_c.$(OBJEXT): {$(VPATH)}internal/core/rclass.h
+rjit_c.$(OBJEXT): {$(VPATH)}internal/core/rdata.h
+rjit_c.$(OBJEXT): {$(VPATH)}internal/core/rfile.h
+rjit_c.$(OBJEXT): {$(VPATH)}internal/core/rhash.h
+rjit_c.$(OBJEXT): {$(VPATH)}internal/core/robject.h
+rjit_c.$(OBJEXT): {$(VPATH)}internal/core/rregexp.h
+rjit_c.$(OBJEXT): {$(VPATH)}internal/core/rstring.h
+rjit_c.$(OBJEXT): {$(VPATH)}internal/core/rstruct.h
+rjit_c.$(OBJEXT): {$(VPATH)}internal/core/rtypeddata.h
+rjit_c.$(OBJEXT): {$(VPATH)}internal/ctype.h
+rjit_c.$(OBJEXT): {$(VPATH)}internal/dllexport.h
+rjit_c.$(OBJEXT): {$(VPATH)}internal/dosish.h
+rjit_c.$(OBJEXT): {$(VPATH)}internal/encoding/coderange.h
+rjit_c.$(OBJEXT): {$(VPATH)}internal/encoding/ctype.h
+rjit_c.$(OBJEXT): {$(VPATH)}internal/encoding/encoding.h
+rjit_c.$(OBJEXT): {$(VPATH)}internal/encoding/pathname.h
+rjit_c.$(OBJEXT): {$(VPATH)}internal/encoding/re.h
+rjit_c.$(OBJEXT): {$(VPATH)}internal/encoding/sprintf.h
+rjit_c.$(OBJEXT): {$(VPATH)}internal/encoding/string.h
+rjit_c.$(OBJEXT): {$(VPATH)}internal/encoding/symbol.h
+rjit_c.$(OBJEXT): {$(VPATH)}internal/encoding/transcode.h
+rjit_c.$(OBJEXT): {$(VPATH)}internal/error.h
+rjit_c.$(OBJEXT): {$(VPATH)}internal/eval.h
+rjit_c.$(OBJEXT): {$(VPATH)}internal/event.h
+rjit_c.$(OBJEXT): {$(VPATH)}internal/fl_type.h
+rjit_c.$(OBJEXT): {$(VPATH)}internal/gc.h
+rjit_c.$(OBJEXT): {$(VPATH)}internal/glob.h
+rjit_c.$(OBJEXT): {$(VPATH)}internal/globals.h
+rjit_c.$(OBJEXT): {$(VPATH)}internal/has/attribute.h
+rjit_c.$(OBJEXT): {$(VPATH)}internal/has/builtin.h
+rjit_c.$(OBJEXT): {$(VPATH)}internal/has/c_attribute.h
+rjit_c.$(OBJEXT): {$(VPATH)}internal/has/cpp_attribute.h
+rjit_c.$(OBJEXT): {$(VPATH)}internal/has/declspec_attribute.h
+rjit_c.$(OBJEXT): {$(VPATH)}internal/has/extension.h
+rjit_c.$(OBJEXT): {$(VPATH)}internal/has/feature.h
+rjit_c.$(OBJEXT): {$(VPATH)}internal/has/warning.h
+rjit_c.$(OBJEXT): {$(VPATH)}internal/intern/array.h
+rjit_c.$(OBJEXT): {$(VPATH)}internal/intern/bignum.h
+rjit_c.$(OBJEXT): {$(VPATH)}internal/intern/class.h
+rjit_c.$(OBJEXT): {$(VPATH)}internal/intern/compar.h
+rjit_c.$(OBJEXT): {$(VPATH)}internal/intern/complex.h
+rjit_c.$(OBJEXT): {$(VPATH)}internal/intern/cont.h
+rjit_c.$(OBJEXT): {$(VPATH)}internal/intern/dir.h
+rjit_c.$(OBJEXT): {$(VPATH)}internal/intern/enum.h
+rjit_c.$(OBJEXT): {$(VPATH)}internal/intern/enumerator.h
+rjit_c.$(OBJEXT): {$(VPATH)}internal/intern/error.h
+rjit_c.$(OBJEXT): {$(VPATH)}internal/intern/eval.h
+rjit_c.$(OBJEXT): {$(VPATH)}internal/intern/file.h
+rjit_c.$(OBJEXT): {$(VPATH)}internal/intern/hash.h
+rjit_c.$(OBJEXT): {$(VPATH)}internal/intern/io.h
+rjit_c.$(OBJEXT): {$(VPATH)}internal/intern/load.h
+rjit_c.$(OBJEXT): {$(VPATH)}internal/intern/marshal.h
+rjit_c.$(OBJEXT): {$(VPATH)}internal/intern/numeric.h
+rjit_c.$(OBJEXT): {$(VPATH)}internal/intern/object.h
+rjit_c.$(OBJEXT): {$(VPATH)}internal/intern/parse.h
+rjit_c.$(OBJEXT): {$(VPATH)}internal/intern/proc.h
+rjit_c.$(OBJEXT): {$(VPATH)}internal/intern/process.h
+rjit_c.$(OBJEXT): {$(VPATH)}internal/intern/random.h
+rjit_c.$(OBJEXT): {$(VPATH)}internal/intern/range.h
+rjit_c.$(OBJEXT): {$(VPATH)}internal/intern/rational.h
+rjit_c.$(OBJEXT): {$(VPATH)}internal/intern/re.h
+rjit_c.$(OBJEXT): {$(VPATH)}internal/intern/ruby.h
+rjit_c.$(OBJEXT): {$(VPATH)}internal/intern/select.h
+rjit_c.$(OBJEXT): {$(VPATH)}internal/intern/select/largesize.h
+rjit_c.$(OBJEXT): {$(VPATH)}internal/intern/signal.h
+rjit_c.$(OBJEXT): {$(VPATH)}internal/intern/sprintf.h
+rjit_c.$(OBJEXT): {$(VPATH)}internal/intern/string.h
+rjit_c.$(OBJEXT): {$(VPATH)}internal/intern/struct.h
+rjit_c.$(OBJEXT): {$(VPATH)}internal/intern/thread.h
+rjit_c.$(OBJEXT): {$(VPATH)}internal/intern/time.h
+rjit_c.$(OBJEXT): {$(VPATH)}internal/intern/variable.h
+rjit_c.$(OBJEXT): {$(VPATH)}internal/intern/vm.h
+rjit_c.$(OBJEXT): {$(VPATH)}internal/interpreter.h
+rjit_c.$(OBJEXT): {$(VPATH)}internal/iterator.h
+rjit_c.$(OBJEXT): {$(VPATH)}internal/memory.h
+rjit_c.$(OBJEXT): {$(VPATH)}internal/method.h
+rjit_c.$(OBJEXT): {$(VPATH)}internal/module.h
+rjit_c.$(OBJEXT): {$(VPATH)}internal/newobj.h
+rjit_c.$(OBJEXT): {$(VPATH)}internal/scan_args.h
+rjit_c.$(OBJEXT): {$(VPATH)}internal/special_consts.h
+rjit_c.$(OBJEXT): {$(VPATH)}internal/static_assert.h
+rjit_c.$(OBJEXT): {$(VPATH)}internal/stdalign.h
+rjit_c.$(OBJEXT): {$(VPATH)}internal/stdbool.h
+rjit_c.$(OBJEXT): {$(VPATH)}internal/symbol.h
+rjit_c.$(OBJEXT): {$(VPATH)}internal/value.h
+rjit_c.$(OBJEXT): {$(VPATH)}internal/value_type.h
+rjit_c.$(OBJEXT): {$(VPATH)}internal/variable.h
+rjit_c.$(OBJEXT): {$(VPATH)}internal/warning_push.h
+rjit_c.$(OBJEXT): {$(VPATH)}internal/xmalloc.h
+rjit_c.$(OBJEXT): {$(VPATH)}iseq.h
+rjit_c.$(OBJEXT): {$(VPATH)}method.h
+rjit_c.$(OBJEXT): {$(VPATH)}missing.h
+rjit_c.$(OBJEXT): {$(VPATH)}node.h
+rjit_c.$(OBJEXT): {$(VPATH)}onigmo.h
+rjit_c.$(OBJEXT): {$(VPATH)}oniguruma.h
+rjit_c.$(OBJEXT): {$(VPATH)}prism/ast.h
+rjit_c.$(OBJEXT): {$(VPATH)}prism/version.h
+rjit_c.$(OBJEXT): {$(VPATH)}prism_compile.h
+rjit_c.$(OBJEXT): {$(VPATH)}probes.dmyh
+rjit_c.$(OBJEXT): {$(VPATH)}probes.h
+rjit_c.$(OBJEXT): {$(VPATH)}probes_helper.h
+rjit_c.$(OBJEXT): {$(VPATH)}rjit.h
+rjit_c.$(OBJEXT): {$(VPATH)}rjit_c.c
+rjit_c.$(OBJEXT): {$(VPATH)}rjit_c.h
+rjit_c.$(OBJEXT): {$(VPATH)}rjit_c.rb
+rjit_c.$(OBJEXT): {$(VPATH)}rjit_c.rbinc
+rjit_c.$(OBJEXT): {$(VPATH)}ruby_assert.h
+rjit_c.$(OBJEXT): {$(VPATH)}ruby_atomic.h
+rjit_c.$(OBJEXT): {$(VPATH)}rubyparser.h
+rjit_c.$(OBJEXT): {$(VPATH)}shape.h
+rjit_c.$(OBJEXT): {$(VPATH)}st.h
+rjit_c.$(OBJEXT): {$(VPATH)}subst.h
+rjit_c.$(OBJEXT): {$(VPATH)}thread_$(THREAD_MODEL).h
+rjit_c.$(OBJEXT): {$(VPATH)}thread_native.h
+rjit_c.$(OBJEXT): {$(VPATH)}vm_callinfo.h
+rjit_c.$(OBJEXT): {$(VPATH)}vm_core.h
+rjit_c.$(OBJEXT): {$(VPATH)}vm_debug.h
+rjit_c.$(OBJEXT): {$(VPATH)}vm_exec.h
+rjit_c.$(OBJEXT): {$(VPATH)}vm_insnhelper.h
+rjit_c.$(OBJEXT): {$(VPATH)}vm_opts.h
+rjit_c.$(OBJEXT): {$(VPATH)}vm_sync.h
+rjit_c.$(OBJEXT): {$(VPATH)}yjit.h
ruby-runner.$(OBJEXT): {$(VPATH)}config.h
ruby-runner.$(OBJEXT): {$(VPATH)}internal/compiler_is.h
ruby-runner.$(OBJEXT): {$(VPATH)}internal/compiler_is/apple.h
@@ -13510,13 +15592,35 @@ ruby.$(OBJEXT): $(top_srcdir)/internal/loadpath.h
ruby.$(OBJEXT): $(top_srcdir)/internal/missing.h
ruby.$(OBJEXT): $(top_srcdir)/internal/object.h
ruby.$(OBJEXT): $(top_srcdir)/internal/parse.h
-ruby.$(OBJEXT): $(top_srcdir)/internal/process.h
+ruby.$(OBJEXT): $(top_srcdir)/internal/ruby_parser.h
ruby.$(OBJEXT): $(top_srcdir)/internal/serial.h
ruby.$(OBJEXT): $(top_srcdir)/internal/static_assert.h
ruby.$(OBJEXT): $(top_srcdir)/internal/string.h
+ruby.$(OBJEXT): $(top_srcdir)/internal/thread.h
ruby.$(OBJEXT): $(top_srcdir)/internal/variable.h
ruby.$(OBJEXT): $(top_srcdir)/internal/vm.h
ruby.$(OBJEXT): $(top_srcdir)/internal/warnings.h
+ruby.$(OBJEXT): $(top_srcdir)/prism/defines.h
+ruby.$(OBJEXT): $(top_srcdir)/prism/diagnostic.h
+ruby.$(OBJEXT): $(top_srcdir)/prism/encoding.h
+ruby.$(OBJEXT): $(top_srcdir)/prism/node.h
+ruby.$(OBJEXT): $(top_srcdir)/prism/options.h
+ruby.$(OBJEXT): $(top_srcdir)/prism/pack.h
+ruby.$(OBJEXT): $(top_srcdir)/prism/parser.h
+ruby.$(OBJEXT): $(top_srcdir)/prism/prettyprint.h
+ruby.$(OBJEXT): $(top_srcdir)/prism/prism.h
+ruby.$(OBJEXT): $(top_srcdir)/prism/regexp.h
+ruby.$(OBJEXT): $(top_srcdir)/prism/util/pm_buffer.h
+ruby.$(OBJEXT): $(top_srcdir)/prism/util/pm_char.h
+ruby.$(OBJEXT): $(top_srcdir)/prism/util/pm_constant_pool.h
+ruby.$(OBJEXT): $(top_srcdir)/prism/util/pm_list.h
+ruby.$(OBJEXT): $(top_srcdir)/prism/util/pm_memchr.h
+ruby.$(OBJEXT): $(top_srcdir)/prism/util/pm_newline_list.h
+ruby.$(OBJEXT): $(top_srcdir)/prism/util/pm_state_stack.h
+ruby.$(OBJEXT): $(top_srcdir)/prism/util/pm_string.h
+ruby.$(OBJEXT): $(top_srcdir)/prism/util/pm_string_list.h
+ruby.$(OBJEXT): $(top_srcdir)/prism/util/pm_strncasecmp.h
+ruby.$(OBJEXT): $(top_srcdir)/prism/util/pm_strpbrk.h
ruby.$(OBJEXT): {$(VPATH)}assert.h
ruby.$(OBJEXT): {$(VPATH)}atomic.h
ruby.$(OBJEXT): {$(VPATH)}backward/2/assume.h
@@ -13577,6 +15681,7 @@ ruby.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
ruby.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
ruby.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
ruby.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
+ruby.$(OBJEXT): {$(VPATH)}internal/attr/packed_struct.h
ruby.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
ruby.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
ruby.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
@@ -13645,7 +15750,6 @@ ruby.$(OBJEXT): {$(VPATH)}internal/intern/enumerator.h
ruby.$(OBJEXT): {$(VPATH)}internal/intern/error.h
ruby.$(OBJEXT): {$(VPATH)}internal/intern/eval.h
ruby.$(OBJEXT): {$(VPATH)}internal/intern/file.h
-ruby.$(OBJEXT): {$(VPATH)}internal/intern/gc.h
ruby.$(OBJEXT): {$(VPATH)}internal/intern/hash.h
ruby.$(OBJEXT): {$(VPATH)}internal/intern/io.h
ruby.$(OBJEXT): {$(VPATH)}internal/intern/load.h
@@ -13676,7 +15780,6 @@ ruby.$(OBJEXT): {$(VPATH)}internal/memory.h
ruby.$(OBJEXT): {$(VPATH)}internal/method.h
ruby.$(OBJEXT): {$(VPATH)}internal/module.h
ruby.$(OBJEXT): {$(VPATH)}internal/newobj.h
-ruby.$(OBJEXT): {$(VPATH)}internal/rgengc.h
ruby.$(OBJEXT): {$(VPATH)}internal/scan_args.h
ruby.$(OBJEXT): {$(VPATH)}internal/special_consts.h
ruby.$(OBJEXT): {$(VPATH)}internal/static_assert.h
@@ -13692,13 +15795,17 @@ ruby.$(OBJEXT): {$(VPATH)}io.h
ruby.$(OBJEXT): {$(VPATH)}iseq.h
ruby.$(OBJEXT): {$(VPATH)}method.h
ruby.$(OBJEXT): {$(VPATH)}missing.h
-ruby.$(OBJEXT): {$(VPATH)}mjit.h
ruby.$(OBJEXT): {$(VPATH)}node.h
ruby.$(OBJEXT): {$(VPATH)}onigmo.h
ruby.$(OBJEXT): {$(VPATH)}oniguruma.h
+ruby.$(OBJEXT): {$(VPATH)}prism/ast.h
+ruby.$(OBJEXT): {$(VPATH)}prism/version.h
+ruby.$(OBJEXT): {$(VPATH)}prism_compile.h
+ruby.$(OBJEXT): {$(VPATH)}rjit.h
ruby.$(OBJEXT): {$(VPATH)}ruby.c
ruby.$(OBJEXT): {$(VPATH)}ruby_assert.h
ruby.$(OBJEXT): {$(VPATH)}ruby_atomic.h
+ruby.$(OBJEXT): {$(VPATH)}rubyparser.h
ruby.$(OBJEXT): {$(VPATH)}shape.h
ruby.$(OBJEXT): {$(VPATH)}st.h
ruby.$(OBJEXT): {$(VPATH)}subst.h
@@ -13709,6 +15816,7 @@ ruby.$(OBJEXT): {$(VPATH)}util.h
ruby.$(OBJEXT): {$(VPATH)}vm_core.h
ruby.$(OBJEXT): {$(VPATH)}vm_opts.h
ruby.$(OBJEXT): {$(VPATH)}yjit.h
+ruby_parser.$(OBJEXT): {$(VPATH)}ruby_parser.c
scheduler.$(OBJEXT): $(CCAN_DIR)/check_type/check_type.h
scheduler.$(OBJEXT): $(CCAN_DIR)/container_of/container_of.h
scheduler.$(OBJEXT): $(CCAN_DIR)/list/list.h
@@ -13783,6 +15891,7 @@ scheduler.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
scheduler.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
scheduler.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
scheduler.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
+scheduler.$(OBJEXT): {$(VPATH)}internal/attr/packed_struct.h
scheduler.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
scheduler.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
scheduler.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
@@ -13851,7 +15960,6 @@ scheduler.$(OBJEXT): {$(VPATH)}internal/intern/enumerator.h
scheduler.$(OBJEXT): {$(VPATH)}internal/intern/error.h
scheduler.$(OBJEXT): {$(VPATH)}internal/intern/eval.h
scheduler.$(OBJEXT): {$(VPATH)}internal/intern/file.h
-scheduler.$(OBJEXT): {$(VPATH)}internal/intern/gc.h
scheduler.$(OBJEXT): {$(VPATH)}internal/intern/hash.h
scheduler.$(OBJEXT): {$(VPATH)}internal/intern/io.h
scheduler.$(OBJEXT): {$(VPATH)}internal/intern/load.h
@@ -13882,7 +15990,6 @@ scheduler.$(OBJEXT): {$(VPATH)}internal/memory.h
scheduler.$(OBJEXT): {$(VPATH)}internal/method.h
scheduler.$(OBJEXT): {$(VPATH)}internal/module.h
scheduler.$(OBJEXT): {$(VPATH)}internal/newobj.h
-scheduler.$(OBJEXT): {$(VPATH)}internal/rgengc.h
scheduler.$(OBJEXT): {$(VPATH)}internal/scan_args.h
scheduler.$(OBJEXT): {$(VPATH)}internal/special_consts.h
scheduler.$(OBJEXT): {$(VPATH)}internal/static_assert.h
@@ -13903,6 +16010,7 @@ scheduler.$(OBJEXT): {$(VPATH)}onigmo.h
scheduler.$(OBJEXT): {$(VPATH)}oniguruma.h
scheduler.$(OBJEXT): {$(VPATH)}ruby_assert.h
scheduler.$(OBJEXT): {$(VPATH)}ruby_atomic.h
+scheduler.$(OBJEXT): {$(VPATH)}rubyparser.h
scheduler.$(OBJEXT): {$(VPATH)}scheduler.c
scheduler.$(OBJEXT): {$(VPATH)}shape.h
scheduler.$(OBJEXT): {$(VPATH)}st.h
@@ -13963,6 +16071,7 @@ setproctitle.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
setproctitle.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
setproctitle.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
setproctitle.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
+setproctitle.$(OBJEXT): {$(VPATH)}internal/attr/packed_struct.h
setproctitle.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
setproctitle.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
setproctitle.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
@@ -14022,7 +16131,6 @@ setproctitle.$(OBJEXT): {$(VPATH)}internal/intern/enumerator.h
setproctitle.$(OBJEXT): {$(VPATH)}internal/intern/error.h
setproctitle.$(OBJEXT): {$(VPATH)}internal/intern/eval.h
setproctitle.$(OBJEXT): {$(VPATH)}internal/intern/file.h
-setproctitle.$(OBJEXT): {$(VPATH)}internal/intern/gc.h
setproctitle.$(OBJEXT): {$(VPATH)}internal/intern/hash.h
setproctitle.$(OBJEXT): {$(VPATH)}internal/intern/io.h
setproctitle.$(OBJEXT): {$(VPATH)}internal/intern/load.h
@@ -14053,7 +16161,6 @@ setproctitle.$(OBJEXT): {$(VPATH)}internal/memory.h
setproctitle.$(OBJEXT): {$(VPATH)}internal/method.h
setproctitle.$(OBJEXT): {$(VPATH)}internal/module.h
setproctitle.$(OBJEXT): {$(VPATH)}internal/newobj.h
-setproctitle.$(OBJEXT): {$(VPATH)}internal/rgengc.h
setproctitle.$(OBJEXT): {$(VPATH)}internal/scan_args.h
setproctitle.$(OBJEXT): {$(VPATH)}internal/special_consts.h
setproctitle.$(OBJEXT): {$(VPATH)}internal/static_assert.h
@@ -14075,14 +16182,18 @@ shape.$(OBJEXT): $(CCAN_DIR)/container_of/container_of.h
shape.$(OBJEXT): $(CCAN_DIR)/list/list.h
shape.$(OBJEXT): $(CCAN_DIR)/str/str.h
shape.$(OBJEXT): $(hdrdir)/ruby/ruby.h
+shape.$(OBJEXT): $(hdrdir)/ruby/version.h
shape.$(OBJEXT): $(top_srcdir)/internal/array.h
shape.$(OBJEXT): $(top_srcdir)/internal/basic_operators.h
shape.$(OBJEXT): $(top_srcdir)/internal/class.h
shape.$(OBJEXT): $(top_srcdir)/internal/compilers.h
+shape.$(OBJEXT): $(top_srcdir)/internal/error.h
shape.$(OBJEXT): $(top_srcdir)/internal/gc.h
shape.$(OBJEXT): $(top_srcdir)/internal/imemo.h
+shape.$(OBJEXT): $(top_srcdir)/internal/object.h
shape.$(OBJEXT): $(top_srcdir)/internal/serial.h
shape.$(OBJEXT): $(top_srcdir)/internal/static_assert.h
+shape.$(OBJEXT): $(top_srcdir)/internal/string.h
shape.$(OBJEXT): $(top_srcdir)/internal/symbol.h
shape.$(OBJEXT): $(top_srcdir)/internal/variable.h
shape.$(OBJEXT): $(top_srcdir)/internal/vm.h
@@ -14103,7 +16214,6 @@ shape.$(OBJEXT): {$(VPATH)}constant.h
shape.$(OBJEXT): {$(VPATH)}debug_counter.h
shape.$(OBJEXT): {$(VPATH)}defines.h
shape.$(OBJEXT): {$(VPATH)}encoding.h
-shape.$(OBJEXT): {$(VPATH)}gc.h
shape.$(OBJEXT): {$(VPATH)}id.h
shape.$(OBJEXT): {$(VPATH)}id_table.h
shape.$(OBJEXT): {$(VPATH)}intern.h
@@ -14146,6 +16256,7 @@ shape.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
shape.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
shape.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
shape.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
+shape.$(OBJEXT): {$(VPATH)}internal/attr/packed_struct.h
shape.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
shape.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
shape.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
@@ -14214,7 +16325,6 @@ shape.$(OBJEXT): {$(VPATH)}internal/intern/enumerator.h
shape.$(OBJEXT): {$(VPATH)}internal/intern/error.h
shape.$(OBJEXT): {$(VPATH)}internal/intern/eval.h
shape.$(OBJEXT): {$(VPATH)}internal/intern/file.h
-shape.$(OBJEXT): {$(VPATH)}internal/intern/gc.h
shape.$(OBJEXT): {$(VPATH)}internal/intern/hash.h
shape.$(OBJEXT): {$(VPATH)}internal/intern/io.h
shape.$(OBJEXT): {$(VPATH)}internal/intern/load.h
@@ -14245,7 +16355,6 @@ shape.$(OBJEXT): {$(VPATH)}internal/memory.h
shape.$(OBJEXT): {$(VPATH)}internal/method.h
shape.$(OBJEXT): {$(VPATH)}internal/module.h
shape.$(OBJEXT): {$(VPATH)}internal/newobj.h
-shape.$(OBJEXT): {$(VPATH)}internal/rgengc.h
shape.$(OBJEXT): {$(VPATH)}internal/scan_args.h
shape.$(OBJEXT): {$(VPATH)}internal/special_consts.h
shape.$(OBJEXT): {$(VPATH)}internal/static_assert.h
@@ -14264,6 +16373,7 @@ shape.$(OBJEXT): {$(VPATH)}onigmo.h
shape.$(OBJEXT): {$(VPATH)}oniguruma.h
shape.$(OBJEXT): {$(VPATH)}ruby_assert.h
shape.$(OBJEXT): {$(VPATH)}ruby_atomic.h
+shape.$(OBJEXT): {$(VPATH)}rubyparser.h
shape.$(OBJEXT): {$(VPATH)}shape.c
shape.$(OBJEXT): {$(VPATH)}shape.h
shape.$(OBJEXT): {$(VPATH)}st.h
@@ -14281,9 +16391,11 @@ signal.$(OBJEXT): $(CCAN_DIR)/container_of/container_of.h
signal.$(OBJEXT): $(CCAN_DIR)/list/list.h
signal.$(OBJEXT): $(CCAN_DIR)/str/str.h
signal.$(OBJEXT): $(hdrdir)/ruby/ruby.h
+signal.$(OBJEXT): $(hdrdir)/ruby/version.h
signal.$(OBJEXT): $(top_srcdir)/internal/array.h
signal.$(OBJEXT): $(top_srcdir)/internal/basic_operators.h
signal.$(OBJEXT): $(top_srcdir)/internal/compilers.h
+signal.$(OBJEXT): $(top_srcdir)/internal/error.h
signal.$(OBJEXT): $(top_srcdir)/internal/eval.h
signal.$(OBJEXT): $(top_srcdir)/internal/gc.h
signal.$(OBJEXT): $(top_srcdir)/internal/imemo.h
@@ -14355,6 +16467,7 @@ signal.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
signal.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
signal.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
signal.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
+signal.$(OBJEXT): {$(VPATH)}internal/attr/packed_struct.h
signal.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
signal.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
signal.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
@@ -14423,7 +16536,6 @@ signal.$(OBJEXT): {$(VPATH)}internal/intern/enumerator.h
signal.$(OBJEXT): {$(VPATH)}internal/intern/error.h
signal.$(OBJEXT): {$(VPATH)}internal/intern/eval.h
signal.$(OBJEXT): {$(VPATH)}internal/intern/file.h
-signal.$(OBJEXT): {$(VPATH)}internal/intern/gc.h
signal.$(OBJEXT): {$(VPATH)}internal/intern/hash.h
signal.$(OBJEXT): {$(VPATH)}internal/intern/io.h
signal.$(OBJEXT): {$(VPATH)}internal/intern/load.h
@@ -14454,7 +16566,6 @@ signal.$(OBJEXT): {$(VPATH)}internal/memory.h
signal.$(OBJEXT): {$(VPATH)}internal/method.h
signal.$(OBJEXT): {$(VPATH)}internal/module.h
signal.$(OBJEXT): {$(VPATH)}internal/newobj.h
-signal.$(OBJEXT): {$(VPATH)}internal/rgengc.h
signal.$(OBJEXT): {$(VPATH)}internal/scan_args.h
signal.$(OBJEXT): {$(VPATH)}internal/special_consts.h
signal.$(OBJEXT): {$(VPATH)}internal/static_assert.h
@@ -14475,6 +16586,7 @@ signal.$(OBJEXT): {$(VPATH)}ractor.h
signal.$(OBJEXT): {$(VPATH)}ractor_core.h
signal.$(OBJEXT): {$(VPATH)}ruby_assert.h
signal.$(OBJEXT): {$(VPATH)}ruby_atomic.h
+signal.$(OBJEXT): {$(VPATH)}rubyparser.h
signal.$(OBJEXT): {$(VPATH)}shape.h
signal.$(OBJEXT): {$(VPATH)}signal.c
signal.$(OBJEXT): {$(VPATH)}st.h
@@ -14485,6 +16597,7 @@ signal.$(OBJEXT): {$(VPATH)}vm_core.h
signal.$(OBJEXT): {$(VPATH)}vm_debug.h
signal.$(OBJEXT): {$(VPATH)}vm_opts.h
sprintf.$(OBJEXT): $(hdrdir)/ruby/ruby.h
+sprintf.$(OBJEXT): $(hdrdir)/ruby/version.h
sprintf.$(OBJEXT): $(top_srcdir)/internal/bignum.h
sprintf.$(OBJEXT): $(top_srcdir)/internal/bits.h
sprintf.$(OBJEXT): $(top_srcdir)/internal/class.h
@@ -14559,6 +16672,7 @@ sprintf.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
sprintf.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
sprintf.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
sprintf.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
+sprintf.$(OBJEXT): {$(VPATH)}internal/attr/packed_struct.h
sprintf.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
sprintf.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
sprintf.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
@@ -14628,7 +16742,6 @@ sprintf.$(OBJEXT): {$(VPATH)}internal/intern/enumerator.h
sprintf.$(OBJEXT): {$(VPATH)}internal/intern/error.h
sprintf.$(OBJEXT): {$(VPATH)}internal/intern/eval.h
sprintf.$(OBJEXT): {$(VPATH)}internal/intern/file.h
-sprintf.$(OBJEXT): {$(VPATH)}internal/intern/gc.h
sprintf.$(OBJEXT): {$(VPATH)}internal/intern/hash.h
sprintf.$(OBJEXT): {$(VPATH)}internal/intern/io.h
sprintf.$(OBJEXT): {$(VPATH)}internal/intern/load.h
@@ -14659,7 +16772,6 @@ sprintf.$(OBJEXT): {$(VPATH)}internal/memory.h
sprintf.$(OBJEXT): {$(VPATH)}internal/method.h
sprintf.$(OBJEXT): {$(VPATH)}internal/module.h
sprintf.$(OBJEXT): {$(VPATH)}internal/newobj.h
-sprintf.$(OBJEXT): {$(VPATH)}internal/rgengc.h
sprintf.$(OBJEXT): {$(VPATH)}internal/scan_args.h
sprintf.$(OBJEXT): {$(VPATH)}internal/special_consts.h
sprintf.$(OBJEXT): {$(VPATH)}internal/static_assert.h
@@ -14741,6 +16853,7 @@ st.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
st.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
st.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
st.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
+st.$(OBJEXT): {$(VPATH)}internal/attr/packed_struct.h
st.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
st.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
st.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
@@ -14800,7 +16913,6 @@ st.$(OBJEXT): {$(VPATH)}internal/intern/enumerator.h
st.$(OBJEXT): {$(VPATH)}internal/intern/error.h
st.$(OBJEXT): {$(VPATH)}internal/intern/eval.h
st.$(OBJEXT): {$(VPATH)}internal/intern/file.h
-st.$(OBJEXT): {$(VPATH)}internal/intern/gc.h
st.$(OBJEXT): {$(VPATH)}internal/intern/hash.h
st.$(OBJEXT): {$(VPATH)}internal/intern/io.h
st.$(OBJEXT): {$(VPATH)}internal/intern/load.h
@@ -14831,7 +16943,6 @@ st.$(OBJEXT): {$(VPATH)}internal/memory.h
st.$(OBJEXT): {$(VPATH)}internal/method.h
st.$(OBJEXT): {$(VPATH)}internal/module.h
st.$(OBJEXT): {$(VPATH)}internal/newobj.h
-st.$(OBJEXT): {$(VPATH)}internal/rgengc.h
st.$(OBJEXT): {$(VPATH)}internal/scan_args.h
st.$(OBJEXT): {$(VPATH)}internal/special_consts.h
st.$(OBJEXT): {$(VPATH)}internal/static_assert.h
@@ -14907,6 +17018,7 @@ strftime.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
strftime.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
strftime.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
strftime.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
+strftime.$(OBJEXT): {$(VPATH)}internal/attr/packed_struct.h
strftime.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
strftime.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
strftime.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
@@ -14975,7 +17087,6 @@ strftime.$(OBJEXT): {$(VPATH)}internal/intern/enumerator.h
strftime.$(OBJEXT): {$(VPATH)}internal/intern/error.h
strftime.$(OBJEXT): {$(VPATH)}internal/intern/eval.h
strftime.$(OBJEXT): {$(VPATH)}internal/intern/file.h
-strftime.$(OBJEXT): {$(VPATH)}internal/intern/gc.h
strftime.$(OBJEXT): {$(VPATH)}internal/intern/hash.h
strftime.$(OBJEXT): {$(VPATH)}internal/intern/io.h
strftime.$(OBJEXT): {$(VPATH)}internal/intern/load.h
@@ -15006,7 +17117,6 @@ strftime.$(OBJEXT): {$(VPATH)}internal/memory.h
strftime.$(OBJEXT): {$(VPATH)}internal/method.h
strftime.$(OBJEXT): {$(VPATH)}internal/module.h
strftime.$(OBJEXT): {$(VPATH)}internal/newobj.h
-strftime.$(OBJEXT): {$(VPATH)}internal/rgengc.h
strftime.$(OBJEXT): {$(VPATH)}internal/scan_args.h
strftime.$(OBJEXT): {$(VPATH)}internal/special_consts.h
strftime.$(OBJEXT): {$(VPATH)}internal/static_assert.h
@@ -15026,7 +17136,12 @@ strftime.$(OBJEXT): {$(VPATH)}strftime.c
strftime.$(OBJEXT): {$(VPATH)}subst.h
strftime.$(OBJEXT): {$(VPATH)}timev.h
strftime.$(OBJEXT): {$(VPATH)}util.h
+string.$(OBJEXT): $(CCAN_DIR)/check_type/check_type.h
+string.$(OBJEXT): $(CCAN_DIR)/container_of/container_of.h
+string.$(OBJEXT): $(CCAN_DIR)/list/list.h
+string.$(OBJEXT): $(CCAN_DIR)/str/str.h
string.$(OBJEXT): $(hdrdir)/ruby/ruby.h
+string.$(OBJEXT): $(hdrdir)/ruby/version.h
string.$(OBJEXT): $(top_srcdir)/internal/array.h
string.$(OBJEXT): $(top_srcdir)/internal/basic_operators.h
string.$(OBJEXT): $(top_srcdir)/internal/bignum.h
@@ -15038,6 +17153,7 @@ string.$(OBJEXT): $(top_srcdir)/internal/encoding.h
string.$(OBJEXT): $(top_srcdir)/internal/error.h
string.$(OBJEXT): $(top_srcdir)/internal/fixnum.h
string.$(OBJEXT): $(top_srcdir)/internal/gc.h
+string.$(OBJEXT): $(top_srcdir)/internal/imemo.h
string.$(OBJEXT): $(top_srcdir)/internal/numeric.h
string.$(OBJEXT): $(top_srcdir)/internal/object.h
string.$(OBJEXT): $(top_srcdir)/internal/proc.h
@@ -15067,7 +17183,6 @@ string.$(OBJEXT): {$(VPATH)}debug_counter.h
string.$(OBJEXT): {$(VPATH)}defines.h
string.$(OBJEXT): {$(VPATH)}encindex.h
string.$(OBJEXT): {$(VPATH)}encoding.h
-string.$(OBJEXT): {$(VPATH)}gc.h
string.$(OBJEXT): {$(VPATH)}id.h
string.$(OBJEXT): {$(VPATH)}id_table.h
string.$(OBJEXT): {$(VPATH)}intern.h
@@ -15110,6 +17225,7 @@ string.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
string.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
string.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
string.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
+string.$(OBJEXT): {$(VPATH)}internal/attr/packed_struct.h
string.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
string.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
string.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
@@ -15179,7 +17295,6 @@ string.$(OBJEXT): {$(VPATH)}internal/intern/enumerator.h
string.$(OBJEXT): {$(VPATH)}internal/intern/error.h
string.$(OBJEXT): {$(VPATH)}internal/intern/eval.h
string.$(OBJEXT): {$(VPATH)}internal/intern/file.h
-string.$(OBJEXT): {$(VPATH)}internal/intern/gc.h
string.$(OBJEXT): {$(VPATH)}internal/intern/hash.h
string.$(OBJEXT): {$(VPATH)}internal/intern/io.h
string.$(OBJEXT): {$(VPATH)}internal/intern/load.h
@@ -15210,7 +17325,6 @@ string.$(OBJEXT): {$(VPATH)}internal/memory.h
string.$(OBJEXT): {$(VPATH)}internal/method.h
string.$(OBJEXT): {$(VPATH)}internal/module.h
string.$(OBJEXT): {$(VPATH)}internal/newobj.h
-string.$(OBJEXT): {$(VPATH)}internal/rgengc.h
string.$(OBJEXT): {$(VPATH)}internal/scan_args.h
string.$(OBJEXT): {$(VPATH)}internal/special_consts.h
string.$(OBJEXT): {$(VPATH)}internal/static_assert.h
@@ -15222,7 +17336,9 @@ string.$(OBJEXT): {$(VPATH)}internal/value_type.h
string.$(OBJEXT): {$(VPATH)}internal/variable.h
string.$(OBJEXT): {$(VPATH)}internal/warning_push.h
string.$(OBJEXT): {$(VPATH)}internal/xmalloc.h
+string.$(OBJEXT): {$(VPATH)}method.h
string.$(OBJEXT): {$(VPATH)}missing.h
+string.$(OBJEXT): {$(VPATH)}node.h
string.$(OBJEXT): {$(VPATH)}onigmo.h
string.$(OBJEXT): {$(VPATH)}oniguruma.h
string.$(OBJEXT): {$(VPATH)}probes.dmyh
@@ -15230,13 +17346,18 @@ string.$(OBJEXT): {$(VPATH)}probes.h
string.$(OBJEXT): {$(VPATH)}re.h
string.$(OBJEXT): {$(VPATH)}regex.h
string.$(OBJEXT): {$(VPATH)}ruby_assert.h
+string.$(OBJEXT): {$(VPATH)}ruby_atomic.h
+string.$(OBJEXT): {$(VPATH)}rubyparser.h
string.$(OBJEXT): {$(VPATH)}shape.h
string.$(OBJEXT): {$(VPATH)}st.h
string.$(OBJEXT): {$(VPATH)}string.c
string.$(OBJEXT): {$(VPATH)}subst.h
+string.$(OBJEXT): {$(VPATH)}thread_$(THREAD_MODEL).h
string.$(OBJEXT): {$(VPATH)}thread_native.h
string.$(OBJEXT): {$(VPATH)}util.h
+string.$(OBJEXT): {$(VPATH)}vm_core.h
string.$(OBJEXT): {$(VPATH)}vm_debug.h
+string.$(OBJEXT): {$(VPATH)}vm_opts.h
string.$(OBJEXT): {$(VPATH)}vm_sync.h
strlcat.$(OBJEXT): {$(VPATH)}config.h
strlcat.$(OBJEXT): {$(VPATH)}internal/attr/format.h
@@ -15273,6 +17394,7 @@ struct.$(OBJEXT): $(CCAN_DIR)/container_of/container_of.h
struct.$(OBJEXT): $(CCAN_DIR)/list/list.h
struct.$(OBJEXT): $(CCAN_DIR)/str/str.h
struct.$(OBJEXT): $(hdrdir)/ruby/ruby.h
+struct.$(OBJEXT): $(hdrdir)/ruby/version.h
struct.$(OBJEXT): $(top_srcdir)/internal/array.h
struct.$(OBJEXT): $(top_srcdir)/internal/basic_operators.h
struct.$(OBJEXT): $(top_srcdir)/internal/class.h
@@ -15305,6 +17427,7 @@ struct.$(OBJEXT): {$(VPATH)}backward/2/stdarg.h
struct.$(OBJEXT): {$(VPATH)}builtin.h
struct.$(OBJEXT): {$(VPATH)}config.h
struct.$(OBJEXT): {$(VPATH)}constant.h
+struct.$(OBJEXT): {$(VPATH)}debug_counter.h
struct.$(OBJEXT): {$(VPATH)}defines.h
struct.$(OBJEXT): {$(VPATH)}encoding.h
struct.$(OBJEXT): {$(VPATH)}id.h
@@ -15349,6 +17472,7 @@ struct.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
struct.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
struct.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
struct.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
+struct.$(OBJEXT): {$(VPATH)}internal/attr/packed_struct.h
struct.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
struct.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
struct.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
@@ -15417,7 +17541,6 @@ struct.$(OBJEXT): {$(VPATH)}internal/intern/enumerator.h
struct.$(OBJEXT): {$(VPATH)}internal/intern/error.h
struct.$(OBJEXT): {$(VPATH)}internal/intern/eval.h
struct.$(OBJEXT): {$(VPATH)}internal/intern/file.h
-struct.$(OBJEXT): {$(VPATH)}internal/intern/gc.h
struct.$(OBJEXT): {$(VPATH)}internal/intern/hash.h
struct.$(OBJEXT): {$(VPATH)}internal/intern/io.h
struct.$(OBJEXT): {$(VPATH)}internal/intern/load.h
@@ -15448,7 +17571,6 @@ struct.$(OBJEXT): {$(VPATH)}internal/memory.h
struct.$(OBJEXT): {$(VPATH)}internal/method.h
struct.$(OBJEXT): {$(VPATH)}internal/module.h
struct.$(OBJEXT): {$(VPATH)}internal/newobj.h
-struct.$(OBJEXT): {$(VPATH)}internal/rgengc.h
struct.$(OBJEXT): {$(VPATH)}internal/scan_args.h
struct.$(OBJEXT): {$(VPATH)}internal/special_consts.h
struct.$(OBJEXT): {$(VPATH)}internal/static_assert.h
@@ -15467,21 +17589,31 @@ struct.$(OBJEXT): {$(VPATH)}onigmo.h
struct.$(OBJEXT): {$(VPATH)}oniguruma.h
struct.$(OBJEXT): {$(VPATH)}ruby_assert.h
struct.$(OBJEXT): {$(VPATH)}ruby_atomic.h
+struct.$(OBJEXT): {$(VPATH)}rubyparser.h
struct.$(OBJEXT): {$(VPATH)}shape.h
struct.$(OBJEXT): {$(VPATH)}st.h
struct.$(OBJEXT): {$(VPATH)}struct.c
struct.$(OBJEXT): {$(VPATH)}subst.h
struct.$(OBJEXT): {$(VPATH)}thread_$(THREAD_MODEL).h
struct.$(OBJEXT): {$(VPATH)}thread_native.h
-struct.$(OBJEXT): {$(VPATH)}transient_heap.h
struct.$(OBJEXT): {$(VPATH)}vm_core.h
+struct.$(OBJEXT): {$(VPATH)}vm_debug.h
struct.$(OBJEXT): {$(VPATH)}vm_opts.h
+struct.$(OBJEXT): {$(VPATH)}vm_sync.h
+symbol.$(OBJEXT): $(CCAN_DIR)/check_type/check_type.h
+symbol.$(OBJEXT): $(CCAN_DIR)/container_of/container_of.h
+symbol.$(OBJEXT): $(CCAN_DIR)/list/list.h
+symbol.$(OBJEXT): $(CCAN_DIR)/str/str.h
symbol.$(OBJEXT): $(hdrdir)/ruby/ruby.h
+symbol.$(OBJEXT): $(hdrdir)/ruby/version.h
+symbol.$(OBJEXT): $(top_srcdir)/internal/array.h
+symbol.$(OBJEXT): $(top_srcdir)/internal/basic_operators.h
symbol.$(OBJEXT): $(top_srcdir)/internal/class.h
symbol.$(OBJEXT): $(top_srcdir)/internal/compilers.h
symbol.$(OBJEXT): $(top_srcdir)/internal/error.h
symbol.$(OBJEXT): $(top_srcdir)/internal/gc.h
symbol.$(OBJEXT): $(top_srcdir)/internal/hash.h
+symbol.$(OBJEXT): $(top_srcdir)/internal/imemo.h
symbol.$(OBJEXT): $(top_srcdir)/internal/object.h
symbol.$(OBJEXT): $(top_srcdir)/internal/serial.h
symbol.$(OBJEXT): $(top_srcdir)/internal/static_assert.h
@@ -15491,6 +17623,7 @@ symbol.$(OBJEXT): $(top_srcdir)/internal/variable.h
symbol.$(OBJEXT): $(top_srcdir)/internal/vm.h
symbol.$(OBJEXT): $(top_srcdir)/internal/warnings.h
symbol.$(OBJEXT): {$(VPATH)}assert.h
+symbol.$(OBJEXT): {$(VPATH)}atomic.h
symbol.$(OBJEXT): {$(VPATH)}backward/2/assume.h
symbol.$(OBJEXT): {$(VPATH)}backward/2/attributes.h
symbol.$(OBJEXT): {$(VPATH)}backward/2/bool.h
@@ -15506,7 +17639,6 @@ symbol.$(OBJEXT): {$(VPATH)}constant.h
symbol.$(OBJEXT): {$(VPATH)}debug_counter.h
symbol.$(OBJEXT): {$(VPATH)}defines.h
symbol.$(OBJEXT): {$(VPATH)}encoding.h
-symbol.$(OBJEXT): {$(VPATH)}gc.h
symbol.$(OBJEXT): {$(VPATH)}id.c
symbol.$(OBJEXT): {$(VPATH)}id.h
symbol.$(OBJEXT): {$(VPATH)}id_table.c
@@ -15551,6 +17683,7 @@ symbol.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
symbol.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
symbol.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
symbol.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
+symbol.$(OBJEXT): {$(VPATH)}internal/attr/packed_struct.h
symbol.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
symbol.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
symbol.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
@@ -15619,7 +17752,6 @@ symbol.$(OBJEXT): {$(VPATH)}internal/intern/enumerator.h
symbol.$(OBJEXT): {$(VPATH)}internal/intern/error.h
symbol.$(OBJEXT): {$(VPATH)}internal/intern/eval.h
symbol.$(OBJEXT): {$(VPATH)}internal/intern/file.h
-symbol.$(OBJEXT): {$(VPATH)}internal/intern/gc.h
symbol.$(OBJEXT): {$(VPATH)}internal/intern/hash.h
symbol.$(OBJEXT): {$(VPATH)}internal/intern/io.h
symbol.$(OBJEXT): {$(VPATH)}internal/intern/load.h
@@ -15650,7 +17782,6 @@ symbol.$(OBJEXT): {$(VPATH)}internal/memory.h
symbol.$(OBJEXT): {$(VPATH)}internal/method.h
symbol.$(OBJEXT): {$(VPATH)}internal/module.h
symbol.$(OBJEXT): {$(VPATH)}internal/newobj.h
-symbol.$(OBJEXT): {$(VPATH)}internal/rgengc.h
symbol.$(OBJEXT): {$(VPATH)}internal/scan_args.h
symbol.$(OBJEXT): {$(VPATH)}internal/special_consts.h
symbol.$(OBJEXT): {$(VPATH)}internal/static_assert.h
@@ -15662,12 +17793,16 @@ symbol.$(OBJEXT): {$(VPATH)}internal/value_type.h
symbol.$(OBJEXT): {$(VPATH)}internal/variable.h
symbol.$(OBJEXT): {$(VPATH)}internal/warning_push.h
symbol.$(OBJEXT): {$(VPATH)}internal/xmalloc.h
+symbol.$(OBJEXT): {$(VPATH)}method.h
symbol.$(OBJEXT): {$(VPATH)}missing.h
+symbol.$(OBJEXT): {$(VPATH)}node.h
symbol.$(OBJEXT): {$(VPATH)}onigmo.h
symbol.$(OBJEXT): {$(VPATH)}oniguruma.h
symbol.$(OBJEXT): {$(VPATH)}probes.dmyh
symbol.$(OBJEXT): {$(VPATH)}probes.h
symbol.$(OBJEXT): {$(VPATH)}ruby_assert.h
+symbol.$(OBJEXT): {$(VPATH)}ruby_atomic.h
+symbol.$(OBJEXT): {$(VPATH)}rubyparser.h
symbol.$(OBJEXT): {$(VPATH)}shape.h
symbol.$(OBJEXT): {$(VPATH)}st.h
symbol.$(OBJEXT): {$(VPATH)}subst.h
@@ -15675,7 +17810,11 @@ symbol.$(OBJEXT): {$(VPATH)}symbol.c
symbol.$(OBJEXT): {$(VPATH)}symbol.h
symbol.$(OBJEXT): {$(VPATH)}symbol.rb
symbol.$(OBJEXT): {$(VPATH)}symbol.rbinc
+symbol.$(OBJEXT): {$(VPATH)}thread_$(THREAD_MODEL).h
+symbol.$(OBJEXT): {$(VPATH)}thread_native.h
+symbol.$(OBJEXT): {$(VPATH)}vm_core.h
symbol.$(OBJEXT): {$(VPATH)}vm_debug.h
+symbol.$(OBJEXT): {$(VPATH)}vm_opts.h
symbol.$(OBJEXT): {$(VPATH)}vm_sync.h
thread.$(OBJEXT): $(CCAN_DIR)/check_type/check_type.h
thread.$(OBJEXT): $(CCAN_DIR)/container_of/container_of.h
@@ -15683,6 +17822,7 @@ thread.$(OBJEXT): $(CCAN_DIR)/list/list.h
thread.$(OBJEXT): $(CCAN_DIR)/str/str.h
thread.$(OBJEXT): $(hdrdir)/ruby.h
thread.$(OBJEXT): $(hdrdir)/ruby/ruby.h
+thread.$(OBJEXT): $(hdrdir)/ruby/version.h
thread.$(OBJEXT): $(top_srcdir)/internal/array.h
thread.$(OBJEXT): $(top_srcdir)/internal/basic_operators.h
thread.$(OBJEXT): $(top_srcdir)/internal/bits.h
@@ -15705,6 +17845,28 @@ thread.$(OBJEXT): $(top_srcdir)/internal/time.h
thread.$(OBJEXT): $(top_srcdir)/internal/variable.h
thread.$(OBJEXT): $(top_srcdir)/internal/vm.h
thread.$(OBJEXT): $(top_srcdir)/internal/warnings.h
+thread.$(OBJEXT): $(top_srcdir)/prism/defines.h
+thread.$(OBJEXT): $(top_srcdir)/prism/diagnostic.h
+thread.$(OBJEXT): $(top_srcdir)/prism/encoding.h
+thread.$(OBJEXT): $(top_srcdir)/prism/node.h
+thread.$(OBJEXT): $(top_srcdir)/prism/options.h
+thread.$(OBJEXT): $(top_srcdir)/prism/pack.h
+thread.$(OBJEXT): $(top_srcdir)/prism/parser.h
+thread.$(OBJEXT): $(top_srcdir)/prism/prettyprint.h
+thread.$(OBJEXT): $(top_srcdir)/prism/prism.h
+thread.$(OBJEXT): $(top_srcdir)/prism/regexp.h
+thread.$(OBJEXT): $(top_srcdir)/prism/util/pm_buffer.h
+thread.$(OBJEXT): $(top_srcdir)/prism/util/pm_char.h
+thread.$(OBJEXT): $(top_srcdir)/prism/util/pm_constant_pool.h
+thread.$(OBJEXT): $(top_srcdir)/prism/util/pm_list.h
+thread.$(OBJEXT): $(top_srcdir)/prism/util/pm_memchr.h
+thread.$(OBJEXT): $(top_srcdir)/prism/util/pm_newline_list.h
+thread.$(OBJEXT): $(top_srcdir)/prism/util/pm_state_stack.h
+thread.$(OBJEXT): $(top_srcdir)/prism/util/pm_string.h
+thread.$(OBJEXT): $(top_srcdir)/prism/util/pm_string_list.h
+thread.$(OBJEXT): $(top_srcdir)/prism/util/pm_strncasecmp.h
+thread.$(OBJEXT): $(top_srcdir)/prism/util/pm_strpbrk.h
+thread.$(OBJEXT): {$(VPATH)}$(COROUTINE_H)
thread.$(OBJEXT): {$(VPATH)}assert.h
thread.$(OBJEXT): {$(VPATH)}atomic.h
thread.$(OBJEXT): {$(VPATH)}backward/2/assume.h
@@ -15725,7 +17887,6 @@ thread.$(OBJEXT): {$(VPATH)}defines.h
thread.$(OBJEXT): {$(VPATH)}encoding.h
thread.$(OBJEXT): {$(VPATH)}eval_intern.h
thread.$(OBJEXT): {$(VPATH)}fiber/scheduler.h
-thread.$(OBJEXT): {$(VPATH)}gc.h
thread.$(OBJEXT): {$(VPATH)}hrtime.h
thread.$(OBJEXT): {$(VPATH)}id.h
thread.$(OBJEXT): {$(VPATH)}id_table.h
@@ -15769,6 +17930,7 @@ thread.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
thread.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
thread.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
thread.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
+thread.$(OBJEXT): {$(VPATH)}internal/attr/packed_struct.h
thread.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
thread.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
thread.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
@@ -15837,7 +17999,6 @@ thread.$(OBJEXT): {$(VPATH)}internal/intern/enumerator.h
thread.$(OBJEXT): {$(VPATH)}internal/intern/error.h
thread.$(OBJEXT): {$(VPATH)}internal/intern/eval.h
thread.$(OBJEXT): {$(VPATH)}internal/intern/file.h
-thread.$(OBJEXT): {$(VPATH)}internal/intern/gc.h
thread.$(OBJEXT): {$(VPATH)}internal/intern/hash.h
thread.$(OBJEXT): {$(VPATH)}internal/intern/io.h
thread.$(OBJEXT): {$(VPATH)}internal/intern/load.h
@@ -15868,7 +18029,6 @@ thread.$(OBJEXT): {$(VPATH)}internal/memory.h
thread.$(OBJEXT): {$(VPATH)}internal/method.h
thread.$(OBJEXT): {$(VPATH)}internal/module.h
thread.$(OBJEXT): {$(VPATH)}internal/newobj.h
-thread.$(OBJEXT): {$(VPATH)}internal/rgengc.h
thread.$(OBJEXT): {$(VPATH)}internal/scan_args.h
thread.$(OBJEXT): {$(VPATH)}internal/special_consts.h
thread.$(OBJEXT): {$(VPATH)}internal/static_assert.h
@@ -15884,14 +18044,18 @@ thread.$(OBJEXT): {$(VPATH)}io.h
thread.$(OBJEXT): {$(VPATH)}iseq.h
thread.$(OBJEXT): {$(VPATH)}method.h
thread.$(OBJEXT): {$(VPATH)}missing.h
-thread.$(OBJEXT): {$(VPATH)}mjit.h
thread.$(OBJEXT): {$(VPATH)}node.h
thread.$(OBJEXT): {$(VPATH)}onigmo.h
thread.$(OBJEXT): {$(VPATH)}oniguruma.h
+thread.$(OBJEXT): {$(VPATH)}prism/ast.h
+thread.$(OBJEXT): {$(VPATH)}prism/version.h
+thread.$(OBJEXT): {$(VPATH)}prism_compile.h
thread.$(OBJEXT): {$(VPATH)}ractor.h
thread.$(OBJEXT): {$(VPATH)}ractor_core.h
+thread.$(OBJEXT): {$(VPATH)}rjit.h
thread.$(OBJEXT): {$(VPATH)}ruby_assert.h
thread.$(OBJEXT): {$(VPATH)}ruby_atomic.h
+thread.$(OBJEXT): {$(VPATH)}rubyparser.h
thread.$(OBJEXT): {$(VPATH)}shape.h
thread.$(OBJEXT): {$(VPATH)}st.h
thread.$(OBJEXT): {$(VPATH)}subst.h
@@ -15900,6 +18064,7 @@ thread.$(OBJEXT): {$(VPATH)}thread.h
thread.$(OBJEXT): {$(VPATH)}thread_$(THREAD_MODEL).c
thread.$(OBJEXT): {$(VPATH)}thread_$(THREAD_MODEL).h
thread.$(OBJEXT): {$(VPATH)}thread_native.h
+thread.$(OBJEXT): {$(VPATH)}thread_pthread_mn.c
thread.$(OBJEXT): {$(VPATH)}thread_sync.c
thread.$(OBJEXT): {$(VPATH)}thread_sync.rbinc
thread.$(OBJEXT): {$(VPATH)}timev.h
@@ -15907,6 +18072,10 @@ thread.$(OBJEXT): {$(VPATH)}vm_core.h
thread.$(OBJEXT): {$(VPATH)}vm_debug.h
thread.$(OBJEXT): {$(VPATH)}vm_opts.h
thread.$(OBJEXT): {$(VPATH)}vm_sync.h
+time.$(OBJEXT): $(CCAN_DIR)/check_type/check_type.h
+time.$(OBJEXT): $(CCAN_DIR)/container_of/container_of.h
+time.$(OBJEXT): $(CCAN_DIR)/list/list.h
+time.$(OBJEXT): $(CCAN_DIR)/str/str.h
time.$(OBJEXT): $(hdrdir)/ruby/ruby.h
time.$(OBJEXT): $(top_srcdir)/internal/array.h
time.$(OBJEXT): $(top_srcdir)/internal/basic_operators.h
@@ -15917,6 +18086,7 @@ time.$(OBJEXT): $(top_srcdir)/internal/compilers.h
time.$(OBJEXT): $(top_srcdir)/internal/fixnum.h
time.$(OBJEXT): $(top_srcdir)/internal/gc.h
time.$(OBJEXT): $(top_srcdir)/internal/hash.h
+time.$(OBJEXT): $(top_srcdir)/internal/imemo.h
time.$(OBJEXT): $(top_srcdir)/internal/numeric.h
time.$(OBJEXT): $(top_srcdir)/internal/rational.h
time.$(OBJEXT): $(top_srcdir)/internal/serial.h
@@ -15927,6 +18097,7 @@ time.$(OBJEXT): $(top_srcdir)/internal/variable.h
time.$(OBJEXT): $(top_srcdir)/internal/vm.h
time.$(OBJEXT): $(top_srcdir)/internal/warnings.h
time.$(OBJEXT): {$(VPATH)}assert.h
+time.$(OBJEXT): {$(VPATH)}atomic.h
time.$(OBJEXT): {$(VPATH)}backward/2/assume.h
time.$(OBJEXT): {$(VPATH)}backward/2/attributes.h
time.$(OBJEXT): {$(VPATH)}backward/2/bool.h
@@ -15983,6 +18154,7 @@ time.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
time.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
time.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
time.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
+time.$(OBJEXT): {$(VPATH)}internal/attr/packed_struct.h
time.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
time.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
time.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
@@ -16051,7 +18223,6 @@ time.$(OBJEXT): {$(VPATH)}internal/intern/enumerator.h
time.$(OBJEXT): {$(VPATH)}internal/intern/error.h
time.$(OBJEXT): {$(VPATH)}internal/intern/eval.h
time.$(OBJEXT): {$(VPATH)}internal/intern/file.h
-time.$(OBJEXT): {$(VPATH)}internal/intern/gc.h
time.$(OBJEXT): {$(VPATH)}internal/intern/hash.h
time.$(OBJEXT): {$(VPATH)}internal/intern/io.h
time.$(OBJEXT): {$(VPATH)}internal/intern/load.h
@@ -16082,7 +18253,6 @@ time.$(OBJEXT): {$(VPATH)}internal/memory.h
time.$(OBJEXT): {$(VPATH)}internal/method.h
time.$(OBJEXT): {$(VPATH)}internal/module.h
time.$(OBJEXT): {$(VPATH)}internal/newobj.h
-time.$(OBJEXT): {$(VPATH)}internal/rgengc.h
time.$(OBJEXT): {$(VPATH)}internal/scan_args.h
time.$(OBJEXT): {$(VPATH)}internal/special_consts.h
time.$(OBJEXT): {$(VPATH)}internal/static_assert.h
@@ -16094,16 +18264,24 @@ time.$(OBJEXT): {$(VPATH)}internal/value_type.h
time.$(OBJEXT): {$(VPATH)}internal/variable.h
time.$(OBJEXT): {$(VPATH)}internal/warning_push.h
time.$(OBJEXT): {$(VPATH)}internal/xmalloc.h
+time.$(OBJEXT): {$(VPATH)}method.h
time.$(OBJEXT): {$(VPATH)}missing.h
+time.$(OBJEXT): {$(VPATH)}node.h
time.$(OBJEXT): {$(VPATH)}onigmo.h
time.$(OBJEXT): {$(VPATH)}oniguruma.h
time.$(OBJEXT): {$(VPATH)}ruby_assert.h
+time.$(OBJEXT): {$(VPATH)}ruby_atomic.h
+time.$(OBJEXT): {$(VPATH)}rubyparser.h
time.$(OBJEXT): {$(VPATH)}shape.h
time.$(OBJEXT): {$(VPATH)}st.h
time.$(OBJEXT): {$(VPATH)}subst.h
+time.$(OBJEXT): {$(VPATH)}thread_$(THREAD_MODEL).h
+time.$(OBJEXT): {$(VPATH)}thread_native.h
time.$(OBJEXT): {$(VPATH)}time.c
time.$(OBJEXT): {$(VPATH)}timev.h
time.$(OBJEXT): {$(VPATH)}timev.rbinc
+time.$(OBJEXT): {$(VPATH)}vm_core.h
+time.$(OBJEXT): {$(VPATH)}vm_opts.h
transcode.$(OBJEXT): $(hdrdir)/ruby/ruby.h
transcode.$(OBJEXT): $(top_srcdir)/internal/array.h
transcode.$(OBJEXT): $(top_srcdir)/internal/class.h
@@ -16173,6 +18351,7 @@ transcode.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
transcode.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
transcode.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
transcode.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
+transcode.$(OBJEXT): {$(VPATH)}internal/attr/packed_struct.h
transcode.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
transcode.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
transcode.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
@@ -16241,7 +18420,6 @@ transcode.$(OBJEXT): {$(VPATH)}internal/intern/enumerator.h
transcode.$(OBJEXT): {$(VPATH)}internal/intern/error.h
transcode.$(OBJEXT): {$(VPATH)}internal/intern/eval.h
transcode.$(OBJEXT): {$(VPATH)}internal/intern/file.h
-transcode.$(OBJEXT): {$(VPATH)}internal/intern/gc.h
transcode.$(OBJEXT): {$(VPATH)}internal/intern/hash.h
transcode.$(OBJEXT): {$(VPATH)}internal/intern/io.h
transcode.$(OBJEXT): {$(VPATH)}internal/intern/load.h
@@ -16272,7 +18450,6 @@ transcode.$(OBJEXT): {$(VPATH)}internal/memory.h
transcode.$(OBJEXT): {$(VPATH)}internal/method.h
transcode.$(OBJEXT): {$(VPATH)}internal/module.h
transcode.$(OBJEXT): {$(VPATH)}internal/newobj.h
-transcode.$(OBJEXT): {$(VPATH)}internal/rgengc.h
transcode.$(OBJEXT): {$(VPATH)}internal/scan_args.h
transcode.$(OBJEXT): {$(VPATH)}internal/special_consts.h
transcode.$(OBJEXT): {$(VPATH)}internal/static_assert.h
@@ -16292,184 +18469,6 @@ transcode.$(OBJEXT): {$(VPATH)}st.h
transcode.$(OBJEXT): {$(VPATH)}subst.h
transcode.$(OBJEXT): {$(VPATH)}transcode.c
transcode.$(OBJEXT): {$(VPATH)}transcode_data.h
-transient_heap.$(OBJEXT): $(hdrdir)/ruby/ruby.h
-transient_heap.$(OBJEXT): $(top_srcdir)/internal/array.h
-transient_heap.$(OBJEXT): $(top_srcdir)/internal/compilers.h
-transient_heap.$(OBJEXT): $(top_srcdir)/internal/gc.h
-transient_heap.$(OBJEXT): $(top_srcdir)/internal/hash.h
-transient_heap.$(OBJEXT): $(top_srcdir)/internal/sanitizers.h
-transient_heap.$(OBJEXT): $(top_srcdir)/internal/static_assert.h
-transient_heap.$(OBJEXT): $(top_srcdir)/internal/struct.h
-transient_heap.$(OBJEXT): $(top_srcdir)/internal/variable.h
-transient_heap.$(OBJEXT): $(top_srcdir)/internal/warnings.h
-transient_heap.$(OBJEXT): {$(VPATH)}assert.h
-transient_heap.$(OBJEXT): {$(VPATH)}backward/2/assume.h
-transient_heap.$(OBJEXT): {$(VPATH)}backward/2/attributes.h
-transient_heap.$(OBJEXT): {$(VPATH)}backward/2/bool.h
-transient_heap.$(OBJEXT): {$(VPATH)}backward/2/gcc_version_since.h
-transient_heap.$(OBJEXT): {$(VPATH)}backward/2/inttypes.h
-transient_heap.$(OBJEXT): {$(VPATH)}backward/2/limits.h
-transient_heap.$(OBJEXT): {$(VPATH)}backward/2/long_long.h
-transient_heap.$(OBJEXT): {$(VPATH)}backward/2/stdalign.h
-transient_heap.$(OBJEXT): {$(VPATH)}backward/2/stdarg.h
-transient_heap.$(OBJEXT): {$(VPATH)}config.h
-transient_heap.$(OBJEXT): {$(VPATH)}constant.h
-transient_heap.$(OBJEXT): {$(VPATH)}debug.h
-transient_heap.$(OBJEXT): {$(VPATH)}debug_counter.h
-transient_heap.$(OBJEXT): {$(VPATH)}defines.h
-transient_heap.$(OBJEXT): {$(VPATH)}gc.h
-transient_heap.$(OBJEXT): {$(VPATH)}id_table.h
-transient_heap.$(OBJEXT): {$(VPATH)}intern.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/abi.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/anyargs.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/arithmetic.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/arithmetic/char.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/arithmetic/double.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/arithmetic/fixnum.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/arithmetic/gid_t.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/arithmetic/int.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/arithmetic/intptr_t.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/arithmetic/long.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/arithmetic/long_long.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/arithmetic/mode_t.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/arithmetic/off_t.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/arithmetic/pid_t.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/arithmetic/short.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/arithmetic/size_t.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/arithmetic/st_data_t.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/arithmetic/uid_t.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/assume.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/attr/alloc_size.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/attr/artificial.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/attr/cold.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/attr/const.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/attr/constexpr.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/attr/deprecated.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/attr/diagnose_if.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/attr/enum_extensibility.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/attr/error.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/attr/flag_enum.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/attr/forceinline.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/attr/format.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/attr/maybe_unused.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/attr/noalias.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/attr/nodiscard.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/attr/warning.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/attr/weakref.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/cast.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/compiler_is.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/compiler_is/apple.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/compiler_is/clang.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/compiler_is/gcc.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/compiler_is/intel.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/compiler_is/msvc.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/compiler_is/sunpro.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/compiler_since.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/config.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/constant_p.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/core.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/core/rarray.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/core/rbasic.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/core/rbignum.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/core/rclass.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/core/rdata.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/core/rfile.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/core/rhash.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/core/robject.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/core/rregexp.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/core/rstring.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/core/rstruct.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/core/rtypeddata.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/ctype.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/dllexport.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/dosish.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/error.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/eval.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/event.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/fl_type.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/gc.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/glob.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/globals.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/has/attribute.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/has/builtin.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/has/c_attribute.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/has/cpp_attribute.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/has/declspec_attribute.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/has/extension.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/has/feature.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/has/warning.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/intern/array.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/intern/bignum.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/intern/class.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/intern/compar.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/intern/complex.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/intern/cont.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/intern/dir.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/intern/enum.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/intern/enumerator.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/intern/error.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/intern/eval.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/intern/file.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/intern/gc.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/intern/hash.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/intern/io.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/intern/load.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/intern/marshal.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/intern/numeric.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/intern/object.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/intern/parse.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/intern/proc.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/intern/process.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/intern/random.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/intern/range.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/intern/rational.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/intern/re.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/intern/ruby.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/intern/select.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/intern/select/largesize.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/intern/signal.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/intern/sprintf.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/intern/string.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/intern/struct.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/intern/thread.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/intern/time.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/intern/variable.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/intern/vm.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/interpreter.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/iterator.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/memory.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/method.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/module.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/newobj.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/rgengc.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/scan_args.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/special_consts.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/static_assert.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/stdalign.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/stdbool.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/symbol.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/value.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/value_type.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/variable.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/warning_push.h
-transient_heap.$(OBJEXT): {$(VPATH)}internal/xmalloc.h
-transient_heap.$(OBJEXT): {$(VPATH)}missing.h
-transient_heap.$(OBJEXT): {$(VPATH)}ruby_assert.h
-transient_heap.$(OBJEXT): {$(VPATH)}shape.h
-transient_heap.$(OBJEXT): {$(VPATH)}st.h
-transient_heap.$(OBJEXT): {$(VPATH)}subst.h
-transient_heap.$(OBJEXT): {$(VPATH)}transient_heap.c
-transient_heap.$(OBJEXT): {$(VPATH)}transient_heap.h
-transient_heap.$(OBJEXT): {$(VPATH)}vm_debug.h
-transient_heap.$(OBJEXT): {$(VPATH)}vm_sync.h
util.$(OBJEXT): $(hdrdir)/ruby/ruby.h
util.$(OBJEXT): $(top_srcdir)/internal/compilers.h
util.$(OBJEXT): $(top_srcdir)/internal/sanitizers.h
@@ -16529,6 +18528,7 @@ util.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
util.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
util.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
util.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
+util.$(OBJEXT): {$(VPATH)}internal/attr/packed_struct.h
util.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
util.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
util.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
@@ -16588,7 +18588,6 @@ util.$(OBJEXT): {$(VPATH)}internal/intern/enumerator.h
util.$(OBJEXT): {$(VPATH)}internal/intern/error.h
util.$(OBJEXT): {$(VPATH)}internal/intern/eval.h
util.$(OBJEXT): {$(VPATH)}internal/intern/file.h
-util.$(OBJEXT): {$(VPATH)}internal/intern/gc.h
util.$(OBJEXT): {$(VPATH)}internal/intern/hash.h
util.$(OBJEXT): {$(VPATH)}internal/intern/io.h
util.$(OBJEXT): {$(VPATH)}internal/intern/load.h
@@ -16619,7 +18618,6 @@ util.$(OBJEXT): {$(VPATH)}internal/memory.h
util.$(OBJEXT): {$(VPATH)}internal/method.h
util.$(OBJEXT): {$(VPATH)}internal/module.h
util.$(OBJEXT): {$(VPATH)}internal/newobj.h
-util.$(OBJEXT): {$(VPATH)}internal/rgengc.h
util.$(OBJEXT): {$(VPATH)}internal/scan_args.h
util.$(OBJEXT): {$(VPATH)}internal/special_consts.h
util.$(OBJEXT): {$(VPATH)}internal/static_assert.h
@@ -16642,6 +18640,7 @@ variable.$(OBJEXT): $(CCAN_DIR)/container_of/container_of.h
variable.$(OBJEXT): $(CCAN_DIR)/list/list.h
variable.$(OBJEXT): $(CCAN_DIR)/str/str.h
variable.$(OBJEXT): $(hdrdir)/ruby/ruby.h
+variable.$(OBJEXT): $(hdrdir)/ruby/version.h
variable.$(OBJEXT): $(top_srcdir)/internal/array.h
variable.$(OBJEXT): $(top_srcdir)/internal/basic_operators.h
variable.$(OBJEXT): $(top_srcdir)/internal/class.h
@@ -16719,6 +18718,7 @@ variable.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
variable.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
variable.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
variable.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
+variable.$(OBJEXT): {$(VPATH)}internal/attr/packed_struct.h
variable.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
variable.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
variable.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
@@ -16787,7 +18787,6 @@ variable.$(OBJEXT): {$(VPATH)}internal/intern/enumerator.h
variable.$(OBJEXT): {$(VPATH)}internal/intern/error.h
variable.$(OBJEXT): {$(VPATH)}internal/intern/eval.h
variable.$(OBJEXT): {$(VPATH)}internal/intern/file.h
-variable.$(OBJEXT): {$(VPATH)}internal/intern/gc.h
variable.$(OBJEXT): {$(VPATH)}internal/intern/hash.h
variable.$(OBJEXT): {$(VPATH)}internal/intern/io.h
variable.$(OBJEXT): {$(VPATH)}internal/intern/load.h
@@ -16818,7 +18817,6 @@ variable.$(OBJEXT): {$(VPATH)}internal/memory.h
variable.$(OBJEXT): {$(VPATH)}internal/method.h
variable.$(OBJEXT): {$(VPATH)}internal/module.h
variable.$(OBJEXT): {$(VPATH)}internal/newobj.h
-variable.$(OBJEXT): {$(VPATH)}internal/rgengc.h
variable.$(OBJEXT): {$(VPATH)}internal/scan_args.h
variable.$(OBJEXT): {$(VPATH)}internal/special_consts.h
variable.$(OBJEXT): {$(VPATH)}internal/static_assert.h
@@ -16839,12 +18837,13 @@ variable.$(OBJEXT): {$(VPATH)}ractor.h
variable.$(OBJEXT): {$(VPATH)}ractor_core.h
variable.$(OBJEXT): {$(VPATH)}ruby_assert.h
variable.$(OBJEXT): {$(VPATH)}ruby_atomic.h
+variable.$(OBJEXT): {$(VPATH)}rubyparser.h
variable.$(OBJEXT): {$(VPATH)}shape.h
variable.$(OBJEXT): {$(VPATH)}st.h
variable.$(OBJEXT): {$(VPATH)}subst.h
+variable.$(OBJEXT): {$(VPATH)}symbol.h
variable.$(OBJEXT): {$(VPATH)}thread_$(THREAD_MODEL).h
variable.$(OBJEXT): {$(VPATH)}thread_native.h
-variable.$(OBJEXT): {$(VPATH)}transient_heap.h
variable.$(OBJEXT): {$(VPATH)}util.h
variable.$(OBJEXT): {$(VPATH)}variable.c
variable.$(OBJEXT): {$(VPATH)}variable.h
@@ -16886,6 +18885,7 @@ version.$(OBJEXT): {$(VPATH)}config.h
version.$(OBJEXT): {$(VPATH)}constant.h
version.$(OBJEXT): {$(VPATH)}debug_counter.h
version.$(OBJEXT): {$(VPATH)}defines.h
+version.$(OBJEXT): {$(VPATH)}encoding.h
version.$(OBJEXT): {$(VPATH)}id.h
version.$(OBJEXT): {$(VPATH)}id_table.h
version.$(OBJEXT): {$(VPATH)}intern.h
@@ -16928,6 +18928,7 @@ version.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
version.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
version.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
version.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
+version.$(OBJEXT): {$(VPATH)}internal/attr/packed_struct.h
version.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
version.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
version.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
@@ -16960,6 +18961,15 @@ version.$(OBJEXT): {$(VPATH)}internal/core/rtypeddata.h
version.$(OBJEXT): {$(VPATH)}internal/ctype.h
version.$(OBJEXT): {$(VPATH)}internal/dllexport.h
version.$(OBJEXT): {$(VPATH)}internal/dosish.h
+version.$(OBJEXT): {$(VPATH)}internal/encoding/coderange.h
+version.$(OBJEXT): {$(VPATH)}internal/encoding/ctype.h
+version.$(OBJEXT): {$(VPATH)}internal/encoding/encoding.h
+version.$(OBJEXT): {$(VPATH)}internal/encoding/pathname.h
+version.$(OBJEXT): {$(VPATH)}internal/encoding/re.h
+version.$(OBJEXT): {$(VPATH)}internal/encoding/sprintf.h
+version.$(OBJEXT): {$(VPATH)}internal/encoding/string.h
+version.$(OBJEXT): {$(VPATH)}internal/encoding/symbol.h
+version.$(OBJEXT): {$(VPATH)}internal/encoding/transcode.h
version.$(OBJEXT): {$(VPATH)}internal/error.h
version.$(OBJEXT): {$(VPATH)}internal/eval.h
version.$(OBJEXT): {$(VPATH)}internal/event.h
@@ -16987,7 +18997,6 @@ version.$(OBJEXT): {$(VPATH)}internal/intern/enumerator.h
version.$(OBJEXT): {$(VPATH)}internal/intern/error.h
version.$(OBJEXT): {$(VPATH)}internal/intern/eval.h
version.$(OBJEXT): {$(VPATH)}internal/intern/file.h
-version.$(OBJEXT): {$(VPATH)}internal/intern/gc.h
version.$(OBJEXT): {$(VPATH)}internal/intern/hash.h
version.$(OBJEXT): {$(VPATH)}internal/intern/io.h
version.$(OBJEXT): {$(VPATH)}internal/intern/load.h
@@ -17018,7 +19027,6 @@ version.$(OBJEXT): {$(VPATH)}internal/memory.h
version.$(OBJEXT): {$(VPATH)}internal/method.h
version.$(OBJEXT): {$(VPATH)}internal/module.h
version.$(OBJEXT): {$(VPATH)}internal/newobj.h
-version.$(OBJEXT): {$(VPATH)}internal/rgengc.h
version.$(OBJEXT): {$(VPATH)}internal/scan_args.h
version.$(OBJEXT): {$(VPATH)}internal/special_consts.h
version.$(OBJEXT): {$(VPATH)}internal/static_assert.h
@@ -17032,11 +19040,14 @@ version.$(OBJEXT): {$(VPATH)}internal/warning_push.h
version.$(OBJEXT): {$(VPATH)}internal/xmalloc.h
version.$(OBJEXT): {$(VPATH)}method.h
version.$(OBJEXT): {$(VPATH)}missing.h
-version.$(OBJEXT): {$(VPATH)}mjit.h
version.$(OBJEXT): {$(VPATH)}node.h
+version.$(OBJEXT): {$(VPATH)}onigmo.h
+version.$(OBJEXT): {$(VPATH)}oniguruma.h
version.$(OBJEXT): {$(VPATH)}revision.h
+version.$(OBJEXT): {$(VPATH)}rjit.h
version.$(OBJEXT): {$(VPATH)}ruby_assert.h
version.$(OBJEXT): {$(VPATH)}ruby_atomic.h
+version.$(OBJEXT): {$(VPATH)}rubyparser.h
version.$(OBJEXT): {$(VPATH)}shape.h
version.$(OBJEXT): {$(VPATH)}st.h
version.$(OBJEXT): {$(VPATH)}subst.h
@@ -17052,6 +19063,7 @@ vm.$(OBJEXT): $(CCAN_DIR)/list/list.h
vm.$(OBJEXT): $(CCAN_DIR)/str/str.h
vm.$(OBJEXT): $(hdrdir)/ruby.h
vm.$(OBJEXT): $(hdrdir)/ruby/ruby.h
+vm.$(OBJEXT): $(hdrdir)/ruby/version.h
vm.$(OBJEXT): $(top_srcdir)/internal/array.h
vm.$(OBJEXT): $(top_srcdir)/internal/basic_operators.h
vm.$(OBJEXT): $(top_srcdir)/internal/bignum.h
@@ -17061,6 +19073,7 @@ vm.$(OBJEXT): $(top_srcdir)/internal/compar.h
vm.$(OBJEXT): $(top_srcdir)/internal/compile.h
vm.$(OBJEXT): $(top_srcdir)/internal/compilers.h
vm.$(OBJEXT): $(top_srcdir)/internal/cont.h
+vm.$(OBJEXT): $(top_srcdir)/internal/encoding.h
vm.$(OBJEXT): $(top_srcdir)/internal/error.h
vm.$(OBJEXT): $(top_srcdir)/internal/eval.h
vm.$(OBJEXT): $(top_srcdir)/internal/fixnum.h
@@ -17074,6 +19087,7 @@ vm.$(OBJEXT): $(top_srcdir)/internal/parse.h
vm.$(OBJEXT): $(top_srcdir)/internal/proc.h
vm.$(OBJEXT): $(top_srcdir)/internal/random.h
vm.$(OBJEXT): $(top_srcdir)/internal/re.h
+vm.$(OBJEXT): $(top_srcdir)/internal/ruby_parser.h
vm.$(OBJEXT): $(top_srcdir)/internal/sanitizers.h
vm.$(OBJEXT): $(top_srcdir)/internal/serial.h
vm.$(OBJEXT): $(top_srcdir)/internal/static_assert.h
@@ -17081,9 +19095,31 @@ vm.$(OBJEXT): $(top_srcdir)/internal/string.h
vm.$(OBJEXT): $(top_srcdir)/internal/struct.h
vm.$(OBJEXT): $(top_srcdir)/internal/symbol.h
vm.$(OBJEXT): $(top_srcdir)/internal/thread.h
+vm.$(OBJEXT): $(top_srcdir)/internal/transcode.h
vm.$(OBJEXT): $(top_srcdir)/internal/variable.h
vm.$(OBJEXT): $(top_srcdir)/internal/vm.h
vm.$(OBJEXT): $(top_srcdir)/internal/warnings.h
+vm.$(OBJEXT): $(top_srcdir)/prism/defines.h
+vm.$(OBJEXT): $(top_srcdir)/prism/diagnostic.h
+vm.$(OBJEXT): $(top_srcdir)/prism/encoding.h
+vm.$(OBJEXT): $(top_srcdir)/prism/node.h
+vm.$(OBJEXT): $(top_srcdir)/prism/options.h
+vm.$(OBJEXT): $(top_srcdir)/prism/pack.h
+vm.$(OBJEXT): $(top_srcdir)/prism/parser.h
+vm.$(OBJEXT): $(top_srcdir)/prism/prettyprint.h
+vm.$(OBJEXT): $(top_srcdir)/prism/prism.h
+vm.$(OBJEXT): $(top_srcdir)/prism/regexp.h
+vm.$(OBJEXT): $(top_srcdir)/prism/util/pm_buffer.h
+vm.$(OBJEXT): $(top_srcdir)/prism/util/pm_char.h
+vm.$(OBJEXT): $(top_srcdir)/prism/util/pm_constant_pool.h
+vm.$(OBJEXT): $(top_srcdir)/prism/util/pm_list.h
+vm.$(OBJEXT): $(top_srcdir)/prism/util/pm_memchr.h
+vm.$(OBJEXT): $(top_srcdir)/prism/util/pm_newline_list.h
+vm.$(OBJEXT): $(top_srcdir)/prism/util/pm_state_stack.h
+vm.$(OBJEXT): $(top_srcdir)/prism/util/pm_string.h
+vm.$(OBJEXT): $(top_srcdir)/prism/util/pm_string_list.h
+vm.$(OBJEXT): $(top_srcdir)/prism/util/pm_strncasecmp.h
+vm.$(OBJEXT): $(top_srcdir)/prism/util/pm_strpbrk.h
vm.$(OBJEXT): {$(VPATH)}assert.h
vm.$(OBJEXT): {$(VPATH)}atomic.h
vm.$(OBJEXT): {$(VPATH)}backward/2/assume.h
@@ -17103,7 +19139,6 @@ vm.$(OBJEXT): {$(VPATH)}defines.h
vm.$(OBJEXT): {$(VPATH)}defs/opt_operand.def
vm.$(OBJEXT): {$(VPATH)}encoding.h
vm.$(OBJEXT): {$(VPATH)}eval_intern.h
-vm.$(OBJEXT): {$(VPATH)}gc.h
vm.$(OBJEXT): {$(VPATH)}id.h
vm.$(OBJEXT): {$(VPATH)}id_table.h
vm.$(OBJEXT): {$(VPATH)}insns.def
@@ -17149,6 +19184,7 @@ vm.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
vm.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
vm.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
vm.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
+vm.$(OBJEXT): {$(VPATH)}internal/attr/packed_struct.h
vm.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
vm.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
vm.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
@@ -17217,7 +19253,6 @@ vm.$(OBJEXT): {$(VPATH)}internal/intern/enumerator.h
vm.$(OBJEXT): {$(VPATH)}internal/intern/error.h
vm.$(OBJEXT): {$(VPATH)}internal/intern/eval.h
vm.$(OBJEXT): {$(VPATH)}internal/intern/file.h
-vm.$(OBJEXT): {$(VPATH)}internal/intern/gc.h
vm.$(OBJEXT): {$(VPATH)}internal/intern/hash.h
vm.$(OBJEXT): {$(VPATH)}internal/intern/io.h
vm.$(OBJEXT): {$(VPATH)}internal/intern/load.h
@@ -17248,7 +19283,6 @@ vm.$(OBJEXT): {$(VPATH)}internal/memory.h
vm.$(OBJEXT): {$(VPATH)}internal/method.h
vm.$(OBJEXT): {$(VPATH)}internal/module.h
vm.$(OBJEXT): {$(VPATH)}internal/newobj.h
-vm.$(OBJEXT): {$(VPATH)}internal/rgengc.h
vm.$(OBJEXT): {$(VPATH)}internal/scan_args.h
vm.$(OBJEXT): {$(VPATH)}internal/special_consts.h
vm.$(OBJEXT): {$(VPATH)}internal/static_assert.h
@@ -17263,17 +19297,21 @@ vm.$(OBJEXT): {$(VPATH)}internal/xmalloc.h
vm.$(OBJEXT): {$(VPATH)}iseq.h
vm.$(OBJEXT): {$(VPATH)}method.h
vm.$(OBJEXT): {$(VPATH)}missing.h
-vm.$(OBJEXT): {$(VPATH)}mjit.h
vm.$(OBJEXT): {$(VPATH)}node.h
vm.$(OBJEXT): {$(VPATH)}onigmo.h
vm.$(OBJEXT): {$(VPATH)}oniguruma.h
+vm.$(OBJEXT): {$(VPATH)}prism/ast.h
+vm.$(OBJEXT): {$(VPATH)}prism/version.h
+vm.$(OBJEXT): {$(VPATH)}prism_compile.h
vm.$(OBJEXT): {$(VPATH)}probes.dmyh
vm.$(OBJEXT): {$(VPATH)}probes.h
vm.$(OBJEXT): {$(VPATH)}probes_helper.h
vm.$(OBJEXT): {$(VPATH)}ractor.h
vm.$(OBJEXT): {$(VPATH)}ractor_core.h
+vm.$(OBJEXT): {$(VPATH)}rjit.h
vm.$(OBJEXT): {$(VPATH)}ruby_assert.h
vm.$(OBJEXT): {$(VPATH)}ruby_atomic.h
+vm.$(OBJEXT): {$(VPATH)}rubyparser.h
vm.$(OBJEXT): {$(VPATH)}shape.h
vm.$(OBJEXT): {$(VPATH)}st.h
vm.$(OBJEXT): {$(VPATH)}subst.h
@@ -17303,8 +19341,10 @@ vm_backtrace.$(OBJEXT): $(CCAN_DIR)/container_of/container_of.h
vm_backtrace.$(OBJEXT): $(CCAN_DIR)/list/list.h
vm_backtrace.$(OBJEXT): $(CCAN_DIR)/str/str.h
vm_backtrace.$(OBJEXT): $(hdrdir)/ruby/ruby.h
+vm_backtrace.$(OBJEXT): $(hdrdir)/ruby/version.h
vm_backtrace.$(OBJEXT): $(top_srcdir)/internal/array.h
vm_backtrace.$(OBJEXT): $(top_srcdir)/internal/basic_operators.h
+vm_backtrace.$(OBJEXT): $(top_srcdir)/internal/class.h
vm_backtrace.$(OBJEXT): $(top_srcdir)/internal/compilers.h
vm_backtrace.$(OBJEXT): $(top_srcdir)/internal/error.h
vm_backtrace.$(OBJEXT): $(top_srcdir)/internal/gc.h
@@ -17315,6 +19355,27 @@ vm_backtrace.$(OBJEXT): $(top_srcdir)/internal/string.h
vm_backtrace.$(OBJEXT): $(top_srcdir)/internal/variable.h
vm_backtrace.$(OBJEXT): $(top_srcdir)/internal/vm.h
vm_backtrace.$(OBJEXT): $(top_srcdir)/internal/warnings.h
+vm_backtrace.$(OBJEXT): $(top_srcdir)/prism/defines.h
+vm_backtrace.$(OBJEXT): $(top_srcdir)/prism/diagnostic.h
+vm_backtrace.$(OBJEXT): $(top_srcdir)/prism/encoding.h
+vm_backtrace.$(OBJEXT): $(top_srcdir)/prism/node.h
+vm_backtrace.$(OBJEXT): $(top_srcdir)/prism/options.h
+vm_backtrace.$(OBJEXT): $(top_srcdir)/prism/pack.h
+vm_backtrace.$(OBJEXT): $(top_srcdir)/prism/parser.h
+vm_backtrace.$(OBJEXT): $(top_srcdir)/prism/prettyprint.h
+vm_backtrace.$(OBJEXT): $(top_srcdir)/prism/prism.h
+vm_backtrace.$(OBJEXT): $(top_srcdir)/prism/regexp.h
+vm_backtrace.$(OBJEXT): $(top_srcdir)/prism/util/pm_buffer.h
+vm_backtrace.$(OBJEXT): $(top_srcdir)/prism/util/pm_char.h
+vm_backtrace.$(OBJEXT): $(top_srcdir)/prism/util/pm_constant_pool.h
+vm_backtrace.$(OBJEXT): $(top_srcdir)/prism/util/pm_list.h
+vm_backtrace.$(OBJEXT): $(top_srcdir)/prism/util/pm_memchr.h
+vm_backtrace.$(OBJEXT): $(top_srcdir)/prism/util/pm_newline_list.h
+vm_backtrace.$(OBJEXT): $(top_srcdir)/prism/util/pm_state_stack.h
+vm_backtrace.$(OBJEXT): $(top_srcdir)/prism/util/pm_string.h
+vm_backtrace.$(OBJEXT): $(top_srcdir)/prism/util/pm_string_list.h
+vm_backtrace.$(OBJEXT): $(top_srcdir)/prism/util/pm_strncasecmp.h
+vm_backtrace.$(OBJEXT): $(top_srcdir)/prism/util/pm_strpbrk.h
vm_backtrace.$(OBJEXT): {$(VPATH)}assert.h
vm_backtrace.$(OBJEXT): {$(VPATH)}atomic.h
vm_backtrace.$(OBJEXT): {$(VPATH)}backward/2/assume.h
@@ -17329,6 +19390,7 @@ vm_backtrace.$(OBJEXT): {$(VPATH)}backward/2/stdarg.h
vm_backtrace.$(OBJEXT): {$(VPATH)}config.h
vm_backtrace.$(OBJEXT): {$(VPATH)}constant.h
vm_backtrace.$(OBJEXT): {$(VPATH)}debug.h
+vm_backtrace.$(OBJEXT): {$(VPATH)}debug_counter.h
vm_backtrace.$(OBJEXT): {$(VPATH)}defines.h
vm_backtrace.$(OBJEXT): {$(VPATH)}encoding.h
vm_backtrace.$(OBJEXT): {$(VPATH)}eval_intern.h
@@ -17374,6 +19436,7 @@ vm_backtrace.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
vm_backtrace.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
vm_backtrace.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
vm_backtrace.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
+vm_backtrace.$(OBJEXT): {$(VPATH)}internal/attr/packed_struct.h
vm_backtrace.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
vm_backtrace.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
vm_backtrace.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
@@ -17442,7 +19505,6 @@ vm_backtrace.$(OBJEXT): {$(VPATH)}internal/intern/enumerator.h
vm_backtrace.$(OBJEXT): {$(VPATH)}internal/intern/error.h
vm_backtrace.$(OBJEXT): {$(VPATH)}internal/intern/eval.h
vm_backtrace.$(OBJEXT): {$(VPATH)}internal/intern/file.h
-vm_backtrace.$(OBJEXT): {$(VPATH)}internal/intern/gc.h
vm_backtrace.$(OBJEXT): {$(VPATH)}internal/intern/hash.h
vm_backtrace.$(OBJEXT): {$(VPATH)}internal/intern/io.h
vm_backtrace.$(OBJEXT): {$(VPATH)}internal/intern/load.h
@@ -17473,7 +19535,6 @@ vm_backtrace.$(OBJEXT): {$(VPATH)}internal/memory.h
vm_backtrace.$(OBJEXT): {$(VPATH)}internal/method.h
vm_backtrace.$(OBJEXT): {$(VPATH)}internal/module.h
vm_backtrace.$(OBJEXT): {$(VPATH)}internal/newobj.h
-vm_backtrace.$(OBJEXT): {$(VPATH)}internal/rgengc.h
vm_backtrace.$(OBJEXT): {$(VPATH)}internal/scan_args.h
vm_backtrace.$(OBJEXT): {$(VPATH)}internal/special_consts.h
vm_backtrace.$(OBJEXT): {$(VPATH)}internal/static_assert.h
@@ -17491,8 +19552,12 @@ vm_backtrace.$(OBJEXT): {$(VPATH)}missing.h
vm_backtrace.$(OBJEXT): {$(VPATH)}node.h
vm_backtrace.$(OBJEXT): {$(VPATH)}onigmo.h
vm_backtrace.$(OBJEXT): {$(VPATH)}oniguruma.h
+vm_backtrace.$(OBJEXT): {$(VPATH)}prism/ast.h
+vm_backtrace.$(OBJEXT): {$(VPATH)}prism/version.h
+vm_backtrace.$(OBJEXT): {$(VPATH)}prism_compile.h
vm_backtrace.$(OBJEXT): {$(VPATH)}ruby_assert.h
vm_backtrace.$(OBJEXT): {$(VPATH)}ruby_atomic.h
+vm_backtrace.$(OBJEXT): {$(VPATH)}rubyparser.h
vm_backtrace.$(OBJEXT): {$(VPATH)}shape.h
vm_backtrace.$(OBJEXT): {$(VPATH)}st.h
vm_backtrace.$(OBJEXT): {$(VPATH)}subst.h
@@ -17500,7 +19565,9 @@ vm_backtrace.$(OBJEXT): {$(VPATH)}thread_$(THREAD_MODEL).h
vm_backtrace.$(OBJEXT): {$(VPATH)}thread_native.h
vm_backtrace.$(OBJEXT): {$(VPATH)}vm_backtrace.c
vm_backtrace.$(OBJEXT): {$(VPATH)}vm_core.h
+vm_backtrace.$(OBJEXT): {$(VPATH)}vm_debug.h
vm_backtrace.$(OBJEXT): {$(VPATH)}vm_opts.h
+vm_backtrace.$(OBJEXT): {$(VPATH)}vm_sync.h
vm_dump.$(OBJEXT): $(CCAN_DIR)/check_type/check_type.h
vm_dump.$(OBJEXT): $(CCAN_DIR)/container_of/container_of.h
vm_dump.$(OBJEXT): $(CCAN_DIR)/list/list.h
@@ -17516,6 +19583,27 @@ vm_dump.$(OBJEXT): $(top_srcdir)/internal/static_assert.h
vm_dump.$(OBJEXT): $(top_srcdir)/internal/variable.h
vm_dump.$(OBJEXT): $(top_srcdir)/internal/vm.h
vm_dump.$(OBJEXT): $(top_srcdir)/internal/warnings.h
+vm_dump.$(OBJEXT): $(top_srcdir)/prism/defines.h
+vm_dump.$(OBJEXT): $(top_srcdir)/prism/diagnostic.h
+vm_dump.$(OBJEXT): $(top_srcdir)/prism/encoding.h
+vm_dump.$(OBJEXT): $(top_srcdir)/prism/node.h
+vm_dump.$(OBJEXT): $(top_srcdir)/prism/options.h
+vm_dump.$(OBJEXT): $(top_srcdir)/prism/pack.h
+vm_dump.$(OBJEXT): $(top_srcdir)/prism/parser.h
+vm_dump.$(OBJEXT): $(top_srcdir)/prism/prettyprint.h
+vm_dump.$(OBJEXT): $(top_srcdir)/prism/prism.h
+vm_dump.$(OBJEXT): $(top_srcdir)/prism/regexp.h
+vm_dump.$(OBJEXT): $(top_srcdir)/prism/util/pm_buffer.h
+vm_dump.$(OBJEXT): $(top_srcdir)/prism/util/pm_char.h
+vm_dump.$(OBJEXT): $(top_srcdir)/prism/util/pm_constant_pool.h
+vm_dump.$(OBJEXT): $(top_srcdir)/prism/util/pm_list.h
+vm_dump.$(OBJEXT): $(top_srcdir)/prism/util/pm_memchr.h
+vm_dump.$(OBJEXT): $(top_srcdir)/prism/util/pm_newline_list.h
+vm_dump.$(OBJEXT): $(top_srcdir)/prism/util/pm_state_stack.h
+vm_dump.$(OBJEXT): $(top_srcdir)/prism/util/pm_string.h
+vm_dump.$(OBJEXT): $(top_srcdir)/prism/util/pm_string_list.h
+vm_dump.$(OBJEXT): $(top_srcdir)/prism/util/pm_strncasecmp.h
+vm_dump.$(OBJEXT): $(top_srcdir)/prism/util/pm_strpbrk.h
vm_dump.$(OBJEXT): {$(VPATH)}addr2line.h
vm_dump.$(OBJEXT): {$(VPATH)}assert.h
vm_dump.$(OBJEXT): {$(VPATH)}atomic.h
@@ -17531,7 +19619,7 @@ vm_dump.$(OBJEXT): {$(VPATH)}backward/2/stdarg.h
vm_dump.$(OBJEXT): {$(VPATH)}config.h
vm_dump.$(OBJEXT): {$(VPATH)}constant.h
vm_dump.$(OBJEXT): {$(VPATH)}defines.h
-vm_dump.$(OBJEXT): {$(VPATH)}gc.h
+vm_dump.$(OBJEXT): {$(VPATH)}encoding.h
vm_dump.$(OBJEXT): {$(VPATH)}id.h
vm_dump.$(OBJEXT): {$(VPATH)}id_table.h
vm_dump.$(OBJEXT): {$(VPATH)}intern.h
@@ -17574,6 +19662,7 @@ vm_dump.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
vm_dump.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
vm_dump.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
vm_dump.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
+vm_dump.$(OBJEXT): {$(VPATH)}internal/attr/packed_struct.h
vm_dump.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
vm_dump.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
vm_dump.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
@@ -17606,6 +19695,15 @@ vm_dump.$(OBJEXT): {$(VPATH)}internal/core/rtypeddata.h
vm_dump.$(OBJEXT): {$(VPATH)}internal/ctype.h
vm_dump.$(OBJEXT): {$(VPATH)}internal/dllexport.h
vm_dump.$(OBJEXT): {$(VPATH)}internal/dosish.h
+vm_dump.$(OBJEXT): {$(VPATH)}internal/encoding/coderange.h
+vm_dump.$(OBJEXT): {$(VPATH)}internal/encoding/ctype.h
+vm_dump.$(OBJEXT): {$(VPATH)}internal/encoding/encoding.h
+vm_dump.$(OBJEXT): {$(VPATH)}internal/encoding/pathname.h
+vm_dump.$(OBJEXT): {$(VPATH)}internal/encoding/re.h
+vm_dump.$(OBJEXT): {$(VPATH)}internal/encoding/sprintf.h
+vm_dump.$(OBJEXT): {$(VPATH)}internal/encoding/string.h
+vm_dump.$(OBJEXT): {$(VPATH)}internal/encoding/symbol.h
+vm_dump.$(OBJEXT): {$(VPATH)}internal/encoding/transcode.h
vm_dump.$(OBJEXT): {$(VPATH)}internal/error.h
vm_dump.$(OBJEXT): {$(VPATH)}internal/eval.h
vm_dump.$(OBJEXT): {$(VPATH)}internal/event.h
@@ -17633,7 +19731,6 @@ vm_dump.$(OBJEXT): {$(VPATH)}internal/intern/enumerator.h
vm_dump.$(OBJEXT): {$(VPATH)}internal/intern/error.h
vm_dump.$(OBJEXT): {$(VPATH)}internal/intern/eval.h
vm_dump.$(OBJEXT): {$(VPATH)}internal/intern/file.h
-vm_dump.$(OBJEXT): {$(VPATH)}internal/intern/gc.h
vm_dump.$(OBJEXT): {$(VPATH)}internal/intern/hash.h
vm_dump.$(OBJEXT): {$(VPATH)}internal/intern/io.h
vm_dump.$(OBJEXT): {$(VPATH)}internal/intern/load.h
@@ -17664,7 +19761,6 @@ vm_dump.$(OBJEXT): {$(VPATH)}internal/memory.h
vm_dump.$(OBJEXT): {$(VPATH)}internal/method.h
vm_dump.$(OBJEXT): {$(VPATH)}internal/module.h
vm_dump.$(OBJEXT): {$(VPATH)}internal/newobj.h
-vm_dump.$(OBJEXT): {$(VPATH)}internal/rgengc.h
vm_dump.$(OBJEXT): {$(VPATH)}internal/scan_args.h
vm_dump.$(OBJEXT): {$(VPATH)}internal/special_consts.h
vm_dump.$(OBJEXT): {$(VPATH)}internal/static_assert.h
@@ -17680,11 +19776,17 @@ vm_dump.$(OBJEXT): {$(VPATH)}iseq.h
vm_dump.$(OBJEXT): {$(VPATH)}method.h
vm_dump.$(OBJEXT): {$(VPATH)}missing.h
vm_dump.$(OBJEXT): {$(VPATH)}node.h
+vm_dump.$(OBJEXT): {$(VPATH)}onigmo.h
+vm_dump.$(OBJEXT): {$(VPATH)}oniguruma.h
+vm_dump.$(OBJEXT): {$(VPATH)}prism/ast.h
+vm_dump.$(OBJEXT): {$(VPATH)}prism/version.h
+vm_dump.$(OBJEXT): {$(VPATH)}prism_compile.h
vm_dump.$(OBJEXT): {$(VPATH)}procstat_vm.c
vm_dump.$(OBJEXT): {$(VPATH)}ractor.h
vm_dump.$(OBJEXT): {$(VPATH)}ractor_core.h
vm_dump.$(OBJEXT): {$(VPATH)}ruby_assert.h
vm_dump.$(OBJEXT): {$(VPATH)}ruby_atomic.h
+vm_dump.$(OBJEXT): {$(VPATH)}rubyparser.h
vm_dump.$(OBJEXT): {$(VPATH)}shape.h
vm_dump.$(OBJEXT): {$(VPATH)}st.h
vm_dump.$(OBJEXT): {$(VPATH)}subst.h
@@ -17706,6 +19808,7 @@ vm_sync.$(OBJEXT): $(top_srcdir)/internal/gc.h
vm_sync.$(OBJEXT): $(top_srcdir)/internal/imemo.h
vm_sync.$(OBJEXT): $(top_srcdir)/internal/serial.h
vm_sync.$(OBJEXT): $(top_srcdir)/internal/static_assert.h
+vm_sync.$(OBJEXT): $(top_srcdir)/internal/thread.h
vm_sync.$(OBJEXT): $(top_srcdir)/internal/variable.h
vm_sync.$(OBJEXT): $(top_srcdir)/internal/vm.h
vm_sync.$(OBJEXT): $(top_srcdir)/internal/warnings.h
@@ -17724,7 +19827,7 @@ vm_sync.$(OBJEXT): {$(VPATH)}config.h
vm_sync.$(OBJEXT): {$(VPATH)}constant.h
vm_sync.$(OBJEXT): {$(VPATH)}debug_counter.h
vm_sync.$(OBJEXT): {$(VPATH)}defines.h
-vm_sync.$(OBJEXT): {$(VPATH)}gc.h
+vm_sync.$(OBJEXT): {$(VPATH)}encoding.h
vm_sync.$(OBJEXT): {$(VPATH)}id.h
vm_sync.$(OBJEXT): {$(VPATH)}id_table.h
vm_sync.$(OBJEXT): {$(VPATH)}intern.h
@@ -17767,6 +19870,7 @@ vm_sync.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
vm_sync.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
vm_sync.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
vm_sync.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
+vm_sync.$(OBJEXT): {$(VPATH)}internal/attr/packed_struct.h
vm_sync.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
vm_sync.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
vm_sync.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
@@ -17799,6 +19903,15 @@ vm_sync.$(OBJEXT): {$(VPATH)}internal/core/rtypeddata.h
vm_sync.$(OBJEXT): {$(VPATH)}internal/ctype.h
vm_sync.$(OBJEXT): {$(VPATH)}internal/dllexport.h
vm_sync.$(OBJEXT): {$(VPATH)}internal/dosish.h
+vm_sync.$(OBJEXT): {$(VPATH)}internal/encoding/coderange.h
+vm_sync.$(OBJEXT): {$(VPATH)}internal/encoding/ctype.h
+vm_sync.$(OBJEXT): {$(VPATH)}internal/encoding/encoding.h
+vm_sync.$(OBJEXT): {$(VPATH)}internal/encoding/pathname.h
+vm_sync.$(OBJEXT): {$(VPATH)}internal/encoding/re.h
+vm_sync.$(OBJEXT): {$(VPATH)}internal/encoding/sprintf.h
+vm_sync.$(OBJEXT): {$(VPATH)}internal/encoding/string.h
+vm_sync.$(OBJEXT): {$(VPATH)}internal/encoding/symbol.h
+vm_sync.$(OBJEXT): {$(VPATH)}internal/encoding/transcode.h
vm_sync.$(OBJEXT): {$(VPATH)}internal/error.h
vm_sync.$(OBJEXT): {$(VPATH)}internal/eval.h
vm_sync.$(OBJEXT): {$(VPATH)}internal/event.h
@@ -17826,7 +19939,6 @@ vm_sync.$(OBJEXT): {$(VPATH)}internal/intern/enumerator.h
vm_sync.$(OBJEXT): {$(VPATH)}internal/intern/error.h
vm_sync.$(OBJEXT): {$(VPATH)}internal/intern/eval.h
vm_sync.$(OBJEXT): {$(VPATH)}internal/intern/file.h
-vm_sync.$(OBJEXT): {$(VPATH)}internal/intern/gc.h
vm_sync.$(OBJEXT): {$(VPATH)}internal/intern/hash.h
vm_sync.$(OBJEXT): {$(VPATH)}internal/intern/io.h
vm_sync.$(OBJEXT): {$(VPATH)}internal/intern/load.h
@@ -17857,7 +19969,6 @@ vm_sync.$(OBJEXT): {$(VPATH)}internal/memory.h
vm_sync.$(OBJEXT): {$(VPATH)}internal/method.h
vm_sync.$(OBJEXT): {$(VPATH)}internal/module.h
vm_sync.$(OBJEXT): {$(VPATH)}internal/newobj.h
-vm_sync.$(OBJEXT): {$(VPATH)}internal/rgengc.h
vm_sync.$(OBJEXT): {$(VPATH)}internal/scan_args.h
vm_sync.$(OBJEXT): {$(VPATH)}internal/special_consts.h
vm_sync.$(OBJEXT): {$(VPATH)}internal/static_assert.h
@@ -17872,10 +19983,13 @@ vm_sync.$(OBJEXT): {$(VPATH)}internal/xmalloc.h
vm_sync.$(OBJEXT): {$(VPATH)}method.h
vm_sync.$(OBJEXT): {$(VPATH)}missing.h
vm_sync.$(OBJEXT): {$(VPATH)}node.h
+vm_sync.$(OBJEXT): {$(VPATH)}onigmo.h
+vm_sync.$(OBJEXT): {$(VPATH)}oniguruma.h
vm_sync.$(OBJEXT): {$(VPATH)}ractor.h
vm_sync.$(OBJEXT): {$(VPATH)}ractor_core.h
vm_sync.$(OBJEXT): {$(VPATH)}ruby_assert.h
vm_sync.$(OBJEXT): {$(VPATH)}ruby_atomic.h
+vm_sync.$(OBJEXT): {$(VPATH)}rubyparser.h
vm_sync.$(OBJEXT): {$(VPATH)}shape.h
vm_sync.$(OBJEXT): {$(VPATH)}st.h
vm_sync.$(OBJEXT): {$(VPATH)}subst.h
@@ -17894,6 +20008,8 @@ vm_trace.$(OBJEXT): $(hdrdir)/ruby.h
vm_trace.$(OBJEXT): $(hdrdir)/ruby/ruby.h
vm_trace.$(OBJEXT): $(top_srcdir)/internal/array.h
vm_trace.$(OBJEXT): $(top_srcdir)/internal/basic_operators.h
+vm_trace.$(OBJEXT): $(top_srcdir)/internal/bits.h
+vm_trace.$(OBJEXT): $(top_srcdir)/internal/class.h
vm_trace.$(OBJEXT): $(top_srcdir)/internal/compilers.h
vm_trace.$(OBJEXT): $(top_srcdir)/internal/gc.h
vm_trace.$(OBJEXT): $(top_srcdir)/internal/hash.h
@@ -17901,9 +20017,31 @@ vm_trace.$(OBJEXT): $(top_srcdir)/internal/imemo.h
vm_trace.$(OBJEXT): $(top_srcdir)/internal/serial.h
vm_trace.$(OBJEXT): $(top_srcdir)/internal/static_assert.h
vm_trace.$(OBJEXT): $(top_srcdir)/internal/symbol.h
+vm_trace.$(OBJEXT): $(top_srcdir)/internal/thread.h
vm_trace.$(OBJEXT): $(top_srcdir)/internal/variable.h
vm_trace.$(OBJEXT): $(top_srcdir)/internal/vm.h
vm_trace.$(OBJEXT): $(top_srcdir)/internal/warnings.h
+vm_trace.$(OBJEXT): $(top_srcdir)/prism/defines.h
+vm_trace.$(OBJEXT): $(top_srcdir)/prism/diagnostic.h
+vm_trace.$(OBJEXT): $(top_srcdir)/prism/encoding.h
+vm_trace.$(OBJEXT): $(top_srcdir)/prism/node.h
+vm_trace.$(OBJEXT): $(top_srcdir)/prism/options.h
+vm_trace.$(OBJEXT): $(top_srcdir)/prism/pack.h
+vm_trace.$(OBJEXT): $(top_srcdir)/prism/parser.h
+vm_trace.$(OBJEXT): $(top_srcdir)/prism/prettyprint.h
+vm_trace.$(OBJEXT): $(top_srcdir)/prism/prism.h
+vm_trace.$(OBJEXT): $(top_srcdir)/prism/regexp.h
+vm_trace.$(OBJEXT): $(top_srcdir)/prism/util/pm_buffer.h
+vm_trace.$(OBJEXT): $(top_srcdir)/prism/util/pm_char.h
+vm_trace.$(OBJEXT): $(top_srcdir)/prism/util/pm_constant_pool.h
+vm_trace.$(OBJEXT): $(top_srcdir)/prism/util/pm_list.h
+vm_trace.$(OBJEXT): $(top_srcdir)/prism/util/pm_memchr.h
+vm_trace.$(OBJEXT): $(top_srcdir)/prism/util/pm_newline_list.h
+vm_trace.$(OBJEXT): $(top_srcdir)/prism/util/pm_state_stack.h
+vm_trace.$(OBJEXT): $(top_srcdir)/prism/util/pm_string.h
+vm_trace.$(OBJEXT): $(top_srcdir)/prism/util/pm_string_list.h
+vm_trace.$(OBJEXT): $(top_srcdir)/prism/util/pm_strncasecmp.h
+vm_trace.$(OBJEXT): $(top_srcdir)/prism/util/pm_strpbrk.h
vm_trace.$(OBJEXT): {$(VPATH)}assert.h
vm_trace.$(OBJEXT): {$(VPATH)}atomic.h
vm_trace.$(OBJEXT): {$(VPATH)}backward/2/assume.h
@@ -17965,6 +20103,7 @@ vm_trace.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
vm_trace.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
vm_trace.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
vm_trace.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
+vm_trace.$(OBJEXT): {$(VPATH)}internal/attr/packed_struct.h
vm_trace.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
vm_trace.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
vm_trace.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
@@ -18033,7 +20172,6 @@ vm_trace.$(OBJEXT): {$(VPATH)}internal/intern/enumerator.h
vm_trace.$(OBJEXT): {$(VPATH)}internal/intern/error.h
vm_trace.$(OBJEXT): {$(VPATH)}internal/intern/eval.h
vm_trace.$(OBJEXT): {$(VPATH)}internal/intern/file.h
-vm_trace.$(OBJEXT): {$(VPATH)}internal/intern/gc.h
vm_trace.$(OBJEXT): {$(VPATH)}internal/intern/hash.h
vm_trace.$(OBJEXT): {$(VPATH)}internal/intern/io.h
vm_trace.$(OBJEXT): {$(VPATH)}internal/intern/load.h
@@ -18064,7 +20202,6 @@ vm_trace.$(OBJEXT): {$(VPATH)}internal/memory.h
vm_trace.$(OBJEXT): {$(VPATH)}internal/method.h
vm_trace.$(OBJEXT): {$(VPATH)}internal/module.h
vm_trace.$(OBJEXT): {$(VPATH)}internal/newobj.h
-vm_trace.$(OBJEXT): {$(VPATH)}internal/rgengc.h
vm_trace.$(OBJEXT): {$(VPATH)}internal/scan_args.h
vm_trace.$(OBJEXT): {$(VPATH)}internal/special_consts.h
vm_trace.$(OBJEXT): {$(VPATH)}internal/static_assert.h
@@ -18079,13 +20216,17 @@ vm_trace.$(OBJEXT): {$(VPATH)}internal/xmalloc.h
vm_trace.$(OBJEXT): {$(VPATH)}iseq.h
vm_trace.$(OBJEXT): {$(VPATH)}method.h
vm_trace.$(OBJEXT): {$(VPATH)}missing.h
-vm_trace.$(OBJEXT): {$(VPATH)}mjit.h
vm_trace.$(OBJEXT): {$(VPATH)}node.h
vm_trace.$(OBJEXT): {$(VPATH)}onigmo.h
vm_trace.$(OBJEXT): {$(VPATH)}oniguruma.h
+vm_trace.$(OBJEXT): {$(VPATH)}prism/ast.h
+vm_trace.$(OBJEXT): {$(VPATH)}prism/version.h
+vm_trace.$(OBJEXT): {$(VPATH)}prism_compile.h
vm_trace.$(OBJEXT): {$(VPATH)}ractor.h
+vm_trace.$(OBJEXT): {$(VPATH)}rjit.h
vm_trace.$(OBJEXT): {$(VPATH)}ruby_assert.h
vm_trace.$(OBJEXT): {$(VPATH)}ruby_atomic.h
+vm_trace.$(OBJEXT): {$(VPATH)}rubyparser.h
vm_trace.$(OBJEXT): {$(VPATH)}shape.h
vm_trace.$(OBJEXT): {$(VPATH)}st.h
vm_trace.$(OBJEXT): {$(VPATH)}subst.h
@@ -18093,9 +20234,208 @@ vm_trace.$(OBJEXT): {$(VPATH)}thread_$(THREAD_MODEL).h
vm_trace.$(OBJEXT): {$(VPATH)}thread_native.h
vm_trace.$(OBJEXT): {$(VPATH)}trace_point.rbinc
vm_trace.$(OBJEXT): {$(VPATH)}vm_core.h
+vm_trace.$(OBJEXT): {$(VPATH)}vm_debug.h
vm_trace.$(OBJEXT): {$(VPATH)}vm_opts.h
+vm_trace.$(OBJEXT): {$(VPATH)}vm_sync.h
vm_trace.$(OBJEXT): {$(VPATH)}vm_trace.c
vm_trace.$(OBJEXT): {$(VPATH)}yjit.h
+weakmap.$(OBJEXT): $(CCAN_DIR)/check_type/check_type.h
+weakmap.$(OBJEXT): $(CCAN_DIR)/container_of/container_of.h
+weakmap.$(OBJEXT): $(CCAN_DIR)/list/list.h
+weakmap.$(OBJEXT): $(CCAN_DIR)/str/str.h
+weakmap.$(OBJEXT): $(hdrdir)/ruby/ruby.h
+weakmap.$(OBJEXT): $(top_srcdir)/internal/array.h
+weakmap.$(OBJEXT): $(top_srcdir)/internal/basic_operators.h
+weakmap.$(OBJEXT): $(top_srcdir)/internal/compilers.h
+weakmap.$(OBJEXT): $(top_srcdir)/internal/gc.h
+weakmap.$(OBJEXT): $(top_srcdir)/internal/hash.h
+weakmap.$(OBJEXT): $(top_srcdir)/internal/imemo.h
+weakmap.$(OBJEXT): $(top_srcdir)/internal/proc.h
+weakmap.$(OBJEXT): $(top_srcdir)/internal/sanitizers.h
+weakmap.$(OBJEXT): $(top_srcdir)/internal/serial.h
+weakmap.$(OBJEXT): $(top_srcdir)/internal/static_assert.h
+weakmap.$(OBJEXT): $(top_srcdir)/internal/vm.h
+weakmap.$(OBJEXT): $(top_srcdir)/internal/warnings.h
+weakmap.$(OBJEXT): {$(VPATH)}assert.h
+weakmap.$(OBJEXT): {$(VPATH)}atomic.h
+weakmap.$(OBJEXT): {$(VPATH)}backward/2/assume.h
+weakmap.$(OBJEXT): {$(VPATH)}backward/2/attributes.h
+weakmap.$(OBJEXT): {$(VPATH)}backward/2/bool.h
+weakmap.$(OBJEXT): {$(VPATH)}backward/2/gcc_version_since.h
+weakmap.$(OBJEXT): {$(VPATH)}backward/2/inttypes.h
+weakmap.$(OBJEXT): {$(VPATH)}backward/2/limits.h
+weakmap.$(OBJEXT): {$(VPATH)}backward/2/long_long.h
+weakmap.$(OBJEXT): {$(VPATH)}backward/2/stdalign.h
+weakmap.$(OBJEXT): {$(VPATH)}backward/2/stdarg.h
+weakmap.$(OBJEXT): {$(VPATH)}config.h
+weakmap.$(OBJEXT): {$(VPATH)}defines.h
+weakmap.$(OBJEXT): {$(VPATH)}encoding.h
+weakmap.$(OBJEXT): {$(VPATH)}id.h
+weakmap.$(OBJEXT): {$(VPATH)}intern.h
+weakmap.$(OBJEXT): {$(VPATH)}internal.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/abi.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/anyargs.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/arithmetic.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/arithmetic/char.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/arithmetic/double.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/arithmetic/fixnum.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/arithmetic/gid_t.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/arithmetic/int.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/arithmetic/intptr_t.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/arithmetic/long.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/arithmetic/long_long.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/arithmetic/mode_t.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/arithmetic/off_t.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/arithmetic/pid_t.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/arithmetic/short.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/arithmetic/size_t.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/arithmetic/st_data_t.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/arithmetic/uid_t.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/assume.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/attr/alloc_size.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/attr/artificial.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/attr/cold.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/attr/const.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/attr/constexpr.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/attr/deprecated.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/attr/diagnose_if.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/attr/enum_extensibility.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/attr/error.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/attr/flag_enum.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/attr/forceinline.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/attr/format.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/attr/maybe_unused.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/attr/noalias.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/attr/nodiscard.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/attr/packed_struct.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/attr/warning.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/attr/weakref.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/cast.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/compiler_is.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/compiler_is/apple.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/compiler_is/clang.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/compiler_is/gcc.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/compiler_is/intel.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/compiler_is/msvc.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/compiler_is/sunpro.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/compiler_since.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/config.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/constant_p.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/core.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/core/rarray.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/core/rbasic.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/core/rbignum.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/core/rclass.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/core/rdata.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/core/rfile.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/core/rhash.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/core/robject.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/core/rregexp.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/core/rstring.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/core/rstruct.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/core/rtypeddata.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/ctype.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/dllexport.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/dosish.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/encoding/coderange.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/encoding/ctype.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/encoding/encoding.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/encoding/pathname.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/encoding/re.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/encoding/sprintf.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/encoding/string.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/encoding/symbol.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/encoding/transcode.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/error.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/eval.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/event.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/fl_type.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/gc.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/glob.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/globals.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/has/attribute.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/has/builtin.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/has/c_attribute.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/has/cpp_attribute.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/has/declspec_attribute.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/has/extension.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/has/feature.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/has/warning.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/intern/array.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/intern/bignum.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/intern/class.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/intern/compar.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/intern/complex.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/intern/cont.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/intern/dir.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/intern/enum.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/intern/enumerator.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/intern/error.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/intern/eval.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/intern/file.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/intern/hash.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/intern/io.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/intern/load.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/intern/marshal.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/intern/numeric.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/intern/object.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/intern/parse.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/intern/proc.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/intern/process.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/intern/random.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/intern/range.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/intern/rational.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/intern/re.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/intern/ruby.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/intern/select.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/intern/select/largesize.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/intern/signal.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/intern/sprintf.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/intern/string.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/intern/struct.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/intern/thread.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/intern/time.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/intern/variable.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/intern/vm.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/interpreter.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/iterator.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/memory.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/method.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/module.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/newobj.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/scan_args.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/special_consts.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/static_assert.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/stdalign.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/stdbool.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/symbol.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/value.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/value_type.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/variable.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/warning_push.h
+weakmap.$(OBJEXT): {$(VPATH)}internal/xmalloc.h
+weakmap.$(OBJEXT): {$(VPATH)}method.h
+weakmap.$(OBJEXT): {$(VPATH)}missing.h
+weakmap.$(OBJEXT): {$(VPATH)}node.h
+weakmap.$(OBJEXT): {$(VPATH)}onigmo.h
+weakmap.$(OBJEXT): {$(VPATH)}oniguruma.h
+weakmap.$(OBJEXT): {$(VPATH)}ruby_assert.h
+weakmap.$(OBJEXT): {$(VPATH)}ruby_atomic.h
+weakmap.$(OBJEXT): {$(VPATH)}rubyparser.h
+weakmap.$(OBJEXT): {$(VPATH)}st.h
+weakmap.$(OBJEXT): {$(VPATH)}subst.h
+weakmap.$(OBJEXT): {$(VPATH)}thread_$(THREAD_MODEL).h
+weakmap.$(OBJEXT): {$(VPATH)}thread_native.h
+weakmap.$(OBJEXT): {$(VPATH)}vm_core.h
+weakmap.$(OBJEXT): {$(VPATH)}vm_opts.h
+weakmap.$(OBJEXT): {$(VPATH)}weakmap.c
yjit.$(OBJEXT): $(CCAN_DIR)/check_type/check_type.h
yjit.$(OBJEXT): $(CCAN_DIR)/container_of/container_of.h
yjit.$(OBJEXT): $(CCAN_DIR)/list/list.h
@@ -18103,6 +20443,8 @@ yjit.$(OBJEXT): $(CCAN_DIR)/str/str.h
yjit.$(OBJEXT): $(hdrdir)/ruby/ruby.h
yjit.$(OBJEXT): $(top_srcdir)/internal/array.h
yjit.$(OBJEXT): $(top_srcdir)/internal/basic_operators.h
+yjit.$(OBJEXT): $(top_srcdir)/internal/bignum.h
+yjit.$(OBJEXT): $(top_srcdir)/internal/bits.h
yjit.$(OBJEXT): $(top_srcdir)/internal/class.h
yjit.$(OBJEXT): $(top_srcdir)/internal/compile.h
yjit.$(OBJEXT): $(top_srcdir)/internal/compilers.h
@@ -18111,6 +20453,7 @@ yjit.$(OBJEXT): $(top_srcdir)/internal/fixnum.h
yjit.$(OBJEXT): $(top_srcdir)/internal/gc.h
yjit.$(OBJEXT): $(top_srcdir)/internal/hash.h
yjit.$(OBJEXT): $(top_srcdir)/internal/imemo.h
+yjit.$(OBJEXT): $(top_srcdir)/internal/numeric.h
yjit.$(OBJEXT): $(top_srcdir)/internal/sanitizers.h
yjit.$(OBJEXT): $(top_srcdir)/internal/serial.h
yjit.$(OBJEXT): $(top_srcdir)/internal/static_assert.h
@@ -18118,6 +20461,27 @@ yjit.$(OBJEXT): $(top_srcdir)/internal/string.h
yjit.$(OBJEXT): $(top_srcdir)/internal/variable.h
yjit.$(OBJEXT): $(top_srcdir)/internal/vm.h
yjit.$(OBJEXT): $(top_srcdir)/internal/warnings.h
+yjit.$(OBJEXT): $(top_srcdir)/prism/defines.h
+yjit.$(OBJEXT): $(top_srcdir)/prism/diagnostic.h
+yjit.$(OBJEXT): $(top_srcdir)/prism/encoding.h
+yjit.$(OBJEXT): $(top_srcdir)/prism/node.h
+yjit.$(OBJEXT): $(top_srcdir)/prism/options.h
+yjit.$(OBJEXT): $(top_srcdir)/prism/pack.h
+yjit.$(OBJEXT): $(top_srcdir)/prism/parser.h
+yjit.$(OBJEXT): $(top_srcdir)/prism/prettyprint.h
+yjit.$(OBJEXT): $(top_srcdir)/prism/prism.h
+yjit.$(OBJEXT): $(top_srcdir)/prism/regexp.h
+yjit.$(OBJEXT): $(top_srcdir)/prism/util/pm_buffer.h
+yjit.$(OBJEXT): $(top_srcdir)/prism/util/pm_char.h
+yjit.$(OBJEXT): $(top_srcdir)/prism/util/pm_constant_pool.h
+yjit.$(OBJEXT): $(top_srcdir)/prism/util/pm_list.h
+yjit.$(OBJEXT): $(top_srcdir)/prism/util/pm_memchr.h
+yjit.$(OBJEXT): $(top_srcdir)/prism/util/pm_newline_list.h
+yjit.$(OBJEXT): $(top_srcdir)/prism/util/pm_state_stack.h
+yjit.$(OBJEXT): $(top_srcdir)/prism/util/pm_string.h
+yjit.$(OBJEXT): $(top_srcdir)/prism/util/pm_string_list.h
+yjit.$(OBJEXT): $(top_srcdir)/prism/util/pm_strncasecmp.h
+yjit.$(OBJEXT): $(top_srcdir)/prism/util/pm_strpbrk.h
yjit.$(OBJEXT): {$(VPATH)}assert.h
yjit.$(OBJEXT): {$(VPATH)}atomic.h
yjit.$(OBJEXT): {$(VPATH)}backward/2/assume.h
@@ -18136,7 +20500,6 @@ yjit.$(OBJEXT): {$(VPATH)}debug.h
yjit.$(OBJEXT): {$(VPATH)}debug_counter.h
yjit.$(OBJEXT): {$(VPATH)}defines.h
yjit.$(OBJEXT): {$(VPATH)}encoding.h
-yjit.$(OBJEXT): {$(VPATH)}gc.h
yjit.$(OBJEXT): {$(VPATH)}id.h
yjit.$(OBJEXT): {$(VPATH)}id_table.h
yjit.$(OBJEXT): {$(VPATH)}insns.def
@@ -18182,6 +20545,7 @@ yjit.$(OBJEXT): {$(VPATH)}internal/attr/noexcept.h
yjit.$(OBJEXT): {$(VPATH)}internal/attr/noinline.h
yjit.$(OBJEXT): {$(VPATH)}internal/attr/nonnull.h
yjit.$(OBJEXT): {$(VPATH)}internal/attr/noreturn.h
+yjit.$(OBJEXT): {$(VPATH)}internal/attr/packed_struct.h
yjit.$(OBJEXT): {$(VPATH)}internal/attr/pure.h
yjit.$(OBJEXT): {$(VPATH)}internal/attr/restrict.h
yjit.$(OBJEXT): {$(VPATH)}internal/attr/returns_nonnull.h
@@ -18250,7 +20614,6 @@ yjit.$(OBJEXT): {$(VPATH)}internal/intern/enumerator.h
yjit.$(OBJEXT): {$(VPATH)}internal/intern/error.h
yjit.$(OBJEXT): {$(VPATH)}internal/intern/eval.h
yjit.$(OBJEXT): {$(VPATH)}internal/intern/file.h
-yjit.$(OBJEXT): {$(VPATH)}internal/intern/gc.h
yjit.$(OBJEXT): {$(VPATH)}internal/intern/hash.h
yjit.$(OBJEXT): {$(VPATH)}internal/intern/io.h
yjit.$(OBJEXT): {$(VPATH)}internal/intern/load.h
@@ -18281,7 +20644,7 @@ yjit.$(OBJEXT): {$(VPATH)}internal/memory.h
yjit.$(OBJEXT): {$(VPATH)}internal/method.h
yjit.$(OBJEXT): {$(VPATH)}internal/module.h
yjit.$(OBJEXT): {$(VPATH)}internal/newobj.h
-yjit.$(OBJEXT): {$(VPATH)}internal/rgengc.h
+yjit.$(OBJEXT): {$(VPATH)}internal/numeric.h
yjit.$(OBJEXT): {$(VPATH)}internal/scan_args.h
yjit.$(OBJEXT): {$(VPATH)}internal/special_consts.h
yjit.$(OBJEXT): {$(VPATH)}internal/static_assert.h
@@ -18299,11 +20662,15 @@ yjit.$(OBJEXT): {$(VPATH)}missing.h
yjit.$(OBJEXT): {$(VPATH)}node.h
yjit.$(OBJEXT): {$(VPATH)}onigmo.h
yjit.$(OBJEXT): {$(VPATH)}oniguruma.h
+yjit.$(OBJEXT): {$(VPATH)}prism/ast.h
+yjit.$(OBJEXT): {$(VPATH)}prism/version.h
+yjit.$(OBJEXT): {$(VPATH)}prism_compile.h
yjit.$(OBJEXT): {$(VPATH)}probes.dmyh
yjit.$(OBJEXT): {$(VPATH)}probes.h
yjit.$(OBJEXT): {$(VPATH)}probes_helper.h
yjit.$(OBJEXT): {$(VPATH)}ruby_assert.h
yjit.$(OBJEXT): {$(VPATH)}ruby_atomic.h
+yjit.$(OBJEXT): {$(VPATH)}rubyparser.h
yjit.$(OBJEXT): {$(VPATH)}shape.h
yjit.$(OBJEXT): {$(VPATH)}st.h
yjit.$(OBJEXT): {$(VPATH)}subst.h
diff --git a/compar.c b/compar.c
index dc157fd241..081b4e2dea 100644
--- a/compar.c
+++ b/compar.c
@@ -187,6 +187,12 @@ cmp_between(VALUE x, VALUE min, VALUE max)
* 'd'.clamp('a', 'f') #=> 'd'
* 'z'.clamp('a', 'f') #=> 'f'
*
+ * If _min_ is +nil+, it is considered smaller than _obj_,
+ * and if _max_ is +nil+, it is considered greater than _obj_.
+ *
+ * -20.clamp(0, nil) #=> 0
+ * 523.clamp(nil, 100) #=> 100
+ *
* In <code>(range)</code> form, returns _range.begin_ if _obj_
* <code><=></code> _range.begin_ is less than zero, _range.end_
* if _obj_ <code><=></code> _range.end_ is greater than zero, and
@@ -257,25 +263,28 @@ cmp_clamp(int argc, VALUE *argv, VALUE x)
* <code>==</code>, <code>>=</code>, and <code>></code>) and the
* method <code>between?</code>.
*
- * class SizeMatters
+ * class StringSorter
* include Comparable
+ *
* attr :str
* def <=>(other)
* str.size <=> other.str.size
* end
+ *
* def initialize(str)
* @str = str
* end
+ *
* def inspect
* @str
* end
* end
*
- * s1 = SizeMatters.new("Z")
- * s2 = SizeMatters.new("YY")
- * s3 = SizeMatters.new("XXX")
- * s4 = SizeMatters.new("WWWW")
- * s5 = SizeMatters.new("VVVVV")
+ * s1 = StringSorter.new("Z")
+ * s2 = StringSorter.new("YY")
+ * s3 = StringSorter.new("XXX")
+ * s4 = StringSorter.new("WWWW")
+ * s5 = StringSorter.new("VVVVV")
*
* s1 < s2 #=> true
* s4.between?(s1, s3) #=> false
@@ -289,8 +298,8 @@ cmp_clamp(int argc, VALUE *argv, VALUE x)
* - #<: Returns whether +self+ is less than the given object.
* - #<=: Returns whether +self+ is less than or equal to the given object.
* - #==: Returns whether +self+ is equal to the given object.
- * - #>: Returns whether +self+ is greater than or equal to the given object.
- * - #>=: Returns whether +self+ is greater than the given object.
+ * - #>: Returns whether +self+ is greater than the given object.
+ * - #>=: Returns whether +self+ is greater than or equal to the given object.
* - #between?: Returns +true+ if +self+ is between two given objects.
* - #clamp: For given objects +min+ and +max+, or range <tt>(min..max)</tt>, returns:
*
diff --git a/compile.c b/compile.c
index 997ec75dfb..4fd562a678 100644
--- a/compile.c
+++ b/compile.c
@@ -17,7 +17,6 @@
#endif
#include "encindex.h"
-#include "gc.h"
#include "id_table.h"
#include "internal.h"
#include "internal/array.h"
@@ -25,6 +24,7 @@
#include "internal/complex.h"
#include "internal/encoding.h"
#include "internal/error.h"
+#include "internal/gc.h"
#include "internal/hash.h"
#include "internal/numeric.h"
#include "internal/object.h"
@@ -39,6 +39,7 @@
#include "vm_core.h"
#include "vm_callinfo.h"
#include "vm_debug.h"
+#include "yjit.h"
#include "builtin.h"
#include "insns.inc"
@@ -118,7 +119,7 @@ struct ensure_range {
};
struct iseq_compile_data_ensure_node_stack {
- const NODE *ensure_node;
+ const void *ensure_node;
struct iseq_compile_data_ensure_node_stack *prev;
struct ensure_range *erange;
};
@@ -332,10 +333,10 @@ static void iseq_add_setlocal(rb_iseq_t *iseq, LINK_ANCHOR *const seq, const NOD
(debug_compile("== " desc "\n", \
iseq_compile_each(iseq, (anchor), (node), (popped))))
-#define COMPILE_RECV(anchor, desc, node) \
+#define COMPILE_RECV(anchor, desc, node, recv) \
(private_recv_p(node) ? \
(ADD_INSN(anchor, node, putself), VM_CALL_FCALL) : \
- COMPILE(anchor, desc, node->nd_recv) ? 0 : -1)
+ COMPILE(anchor, desc, recv) ? 0 : -1)
#define OPERAND_AT(insn, idx) \
(((INSN*)(insn))->operands[(idx)])
@@ -486,7 +487,6 @@ static int iseq_set_local_table(rb_iseq_t *iseq, const rb_ast_id_table_t *tbl);
static int iseq_set_exception_local_table(rb_iseq_t *iseq);
static int iseq_set_arguments(rb_iseq_t *iseq, LINK_ANCHOR *const anchor, const NODE *const node);
-static int iseq_set_sequence_stackcaching(rb_iseq_t *iseq, LINK_ANCHOR *const anchor);
static int iseq_set_sequence(rb_iseq_t *iseq, LINK_ANCHOR *const anchor);
static int iseq_set_exception_table(rb_iseq_t *iseq);
static int iseq_set_optargs_table(rb_iseq_t *iseq);
@@ -721,6 +721,117 @@ validate_labels(rb_iseq_t *iseq, st_table *labels_table)
st_free_table(labels_table);
}
+static NODE *
+get_nd_recv(const NODE *node)
+{
+ switch (nd_type(node)) {
+ case NODE_CALL:
+ return RNODE_CALL(node)->nd_recv;
+ case NODE_OPCALL:
+ return RNODE_OPCALL(node)->nd_recv;
+ case NODE_FCALL:
+ return 0;
+ case NODE_QCALL:
+ return RNODE_QCALL(node)->nd_recv;
+ case NODE_VCALL:
+ return 0;
+ case NODE_ATTRASGN:
+ return RNODE_ATTRASGN(node)->nd_recv;
+ case NODE_OP_ASGN1:
+ return RNODE_OP_ASGN1(node)->nd_recv;
+ case NODE_OP_ASGN2:
+ return RNODE_OP_ASGN2(node)->nd_recv;
+ default:
+ rb_bug("unexpected node: %s", ruby_node_name(nd_type(node)));
+ }
+}
+
+static ID
+get_node_call_nd_mid(const NODE *node)
+{
+ switch (nd_type(node)) {
+ case NODE_CALL:
+ return RNODE_CALL(node)->nd_mid;
+ case NODE_OPCALL:
+ return RNODE_OPCALL(node)->nd_mid;
+ case NODE_FCALL:
+ return RNODE_FCALL(node)->nd_mid;
+ case NODE_QCALL:
+ return RNODE_QCALL(node)->nd_mid;
+ case NODE_VCALL:
+ return RNODE_VCALL(node)->nd_mid;
+ case NODE_ATTRASGN:
+ return RNODE_ATTRASGN(node)->nd_mid;
+ default:
+ rb_bug("unexpected node: %s", ruby_node_name(nd_type(node)));
+ }
+}
+
+static NODE *
+get_nd_args(const NODE *node)
+{
+ switch (nd_type(node)) {
+ case NODE_CALL:
+ return RNODE_CALL(node)->nd_args;
+ case NODE_OPCALL:
+ return RNODE_OPCALL(node)->nd_args;
+ case NODE_FCALL:
+ return RNODE_FCALL(node)->nd_args;
+ case NODE_QCALL:
+ return RNODE_QCALL(node)->nd_args;
+ case NODE_VCALL:
+ return 0;
+ case NODE_ATTRASGN:
+ return RNODE_ATTRASGN(node)->nd_args;
+ default:
+ rb_bug("unexpected node: %s", ruby_node_name(nd_type(node)));
+ }
+}
+
+static ID
+get_node_colon_nd_mid(const NODE *node)
+{
+ switch (nd_type(node)) {
+ case NODE_COLON2:
+ return RNODE_COLON2(node)->nd_mid;
+ case NODE_COLON3:
+ return RNODE_COLON3(node)->nd_mid;
+ default:
+ rb_bug("unexpected node: %s", ruby_node_name(nd_type(node)));
+ }
+}
+
+static ID
+get_nd_vid(const NODE *node)
+{
+ switch (nd_type(node)) {
+ case NODE_LASGN:
+ return RNODE_LASGN(node)->nd_vid;
+ case NODE_DASGN:
+ return RNODE_DASGN(node)->nd_vid;
+ case NODE_IASGN:
+ return RNODE_IASGN(node)->nd_vid;
+ case NODE_CVASGN:
+ return RNODE_CVASGN(node)->nd_vid;
+ default:
+ rb_bug("unexpected node: %s", ruby_node_name(nd_type(node)));
+ }
+}
+
+
+static NODE *
+get_nd_value(const NODE *node)
+{
+ switch (nd_type(node)) {
+ case NODE_LASGN:
+ return RNODE_LASGN(node)->nd_value;
+ case NODE_DASGN:
+ return RNODE_DASGN(node)->nd_value;
+ default:
+ rb_bug("unexpected node: %s", ruby_node_name(nd_type(node)));
+ }
+}
+
VALUE
rb_iseq_compile_callback(rb_iseq_t *iseq, const struct rb_iseq_new_with_callback_callback_func * ifunc)
{
@@ -753,8 +864,8 @@ rb_iseq_compile_node(rb_iseq_t *iseq, const NODE *node)
/* assume node is T_NODE */
else if (nd_type_p(node, NODE_SCOPE)) {
/* iseq type of top, method, class, block */
- iseq_set_local_table(iseq, node->nd_tbl);
- iseq_set_arguments(iseq, ret, node->nd_args);
+ iseq_set_local_table(iseq, RNODE_SCOPE(node)->nd_tbl);
+ iseq_set_arguments(iseq, ret, (NODE *)RNODE_SCOPE(node)->nd_args);
switch (ISEQ_BODY(iseq)->type) {
case ISEQ_TYPE_BLOCK:
@@ -769,7 +880,7 @@ rb_iseq_compile_node(rb_iseq_t *iseq, const NODE *node)
NODE dummy_line_node = generate_dummy_line_node(ISEQ_BODY(iseq)->location.first_lineno, -1);
ADD_INSN (ret, &dummy_line_node, nop);
ADD_LABEL(ret, start);
- CHECK(COMPILE(ret, "block body", node->nd_body));
+ CHECK(COMPILE(ret, "block body", RNODE_SCOPE(node)->nd_body));
ADD_LABEL(ret, end);
ADD_TRACE(ret, RUBY_EVENT_B_RETURN);
ISEQ_COMPILE_DATA(iseq)->last_line = ISEQ_BODY(iseq)->location.code_location.end_pos.lineno;
@@ -782,23 +893,23 @@ rb_iseq_compile_node(rb_iseq_t *iseq, const NODE *node)
case ISEQ_TYPE_CLASS:
{
ADD_TRACE(ret, RUBY_EVENT_CLASS);
- CHECK(COMPILE(ret, "scoped node", node->nd_body));
+ CHECK(COMPILE(ret, "scoped node", RNODE_SCOPE(node)->nd_body));
ADD_TRACE(ret, RUBY_EVENT_END);
ISEQ_COMPILE_DATA(iseq)->last_line = nd_line(node);
break;
}
case ISEQ_TYPE_METHOD:
{
- ISEQ_COMPILE_DATA(iseq)->root_node = node->nd_body;
+ ISEQ_COMPILE_DATA(iseq)->root_node = RNODE_SCOPE(node)->nd_body;
ADD_TRACE(ret, RUBY_EVENT_CALL);
- CHECK(COMPILE(ret, "scoped node", node->nd_body));
- ISEQ_COMPILE_DATA(iseq)->root_node = node->nd_body;
+ CHECK(COMPILE(ret, "scoped node", RNODE_SCOPE(node)->nd_body));
+ ISEQ_COMPILE_DATA(iseq)->root_node = RNODE_SCOPE(node)->nd_body;
ADD_TRACE(ret, RUBY_EVENT_RETURN);
ISEQ_COMPILE_DATA(iseq)->last_line = nd_line(node);
break;
}
default: {
- CHECK(COMPILE(ret, "scoped node", node->nd_body));
+ CHECK(COMPILE(ret, "scoped node", RNODE_SCOPE(node)->nd_body));
break;
}
}
@@ -856,6 +967,20 @@ rb_iseq_compile_node(rb_iseq_t *iseq, const NODE *node)
return iseq_setup(iseq, ret);
}
+static VALUE rb_translate_prism(pm_parser_t *parser, rb_iseq_t *iseq, pm_scope_node_t *scope_node, LINK_ANCHOR *const ret);
+
+VALUE
+rb_iseq_compile_prism_node(rb_iseq_t * iseq, pm_scope_node_t *scope_node, pm_parser_t *parser)
+{
+ DECL_ANCHOR(ret);
+ INIT_ANCHOR(ret);
+
+ CHECK(rb_translate_prism(parser, iseq, scope_node, ret));
+
+ CHECK(iseq_setup_insn(iseq, ret));
+ return iseq_setup(iseq, ret);
+}
+
static int
rb_iseq_translate_threaded_code(rb_iseq_t *iseq)
{
@@ -872,6 +997,11 @@ rb_iseq_translate_threaded_code(rb_iseq_t *iseq)
}
FL_SET((VALUE)iseq, ISEQ_TRANSLATED);
#endif
+
+#if USE_YJIT
+ rb_yjit_live_iseq_count++;
+#endif
+
return COMPILE_OK;
}
@@ -1243,6 +1373,32 @@ new_adjust_body(rb_iseq_t *iseq, LABEL *label, int line)
return adjust;
}
+static void
+iseq_insn_each_markable_object(INSN *insn, void (*func)(VALUE, VALUE), VALUE data)
+{
+ const char *types = insn_op_types(insn->insn_id);
+ for (int j = 0; types[j]; j++) {
+ char type = types[j];
+ switch (type) {
+ case TS_CDHASH:
+ case TS_ISEQ:
+ case TS_VALUE:
+ case TS_IC: // constant path array
+ case TS_CALLDATA: // ci is stored.
+ func(OPERAND_AT(insn, j), data);
+ break;
+ default:
+ break;
+ }
+ }
+}
+
+static void
+iseq_insn_each_object_write_barrier(VALUE obj, VALUE iseq)
+{
+ RB_OBJ_WRITTEN(iseq, Qundef, obj);
+}
+
static INSN *
new_insn_core(rb_iseq_t *iseq, const NODE *line_node,
int insn_id, int argc, VALUE *argv)
@@ -1260,6 +1416,9 @@ new_insn_core(rb_iseq_t *iseq, const NODE *line_node,
iobj->operands = argv;
iobj->operand_size = argc;
iobj->sc_state = 0;
+
+ iseq_insn_each_markable_object(iobj, iseq_insn_each_object_write_barrier, (VALUE)iseq);
+
return iobj;
}
@@ -1326,7 +1485,8 @@ new_child_iseq(rb_iseq_t *iseq, const NODE *const node,
rb_ast_body_t ast;
ast.root = node;
- ast.compile_option = 0;
+ ast.frozen_string_literal = -1;
+ ast.coverage_enabled = -1;
ast.script_lines = ISEQ_BODY(iseq)->variable.script_lines;
debugs("[new_child_iseq]> ---------------------------------------\n");
@@ -1355,11 +1515,14 @@ new_child_iseq_with_callback(rb_iseq_t *iseq, const struct rb_iseq_new_with_call
}
static void
-set_catch_except_p(struct rb_iseq_constant_body *body)
+set_catch_except_p(rb_iseq_t *iseq)
{
- body->catch_except_p = true;
- if (body->parent_iseq != NULL) {
- set_catch_except_p(ISEQ_BODY(body->parent_iseq));
+ RUBY_ASSERT(ISEQ_COMPILE_DATA(iseq));
+ ISEQ_COMPILE_DATA(iseq)->catch_except_p = true;
+ if (ISEQ_BODY(iseq)->parent_iseq != NULL) {
+ if (ISEQ_COMPILE_DATA(ISEQ_BODY(iseq)->parent_iseq)) {
+ set_catch_except_p((rb_iseq_t *) ISEQ_BODY(iseq)->parent_iseq);
+ }
}
}
@@ -1371,7 +1534,7 @@ set_catch_except_p(struct rb_iseq_constant_body *body)
So this function sets true for limited ISeqs with break/next/redo catch table entries
whose child ISeq would really raise an exception. */
static void
-update_catch_except_flags(struct rb_iseq_constant_body *body)
+update_catch_except_flags(rb_iseq_t *iseq, struct rb_iseq_constant_body *body)
{
unsigned int pos;
size_t i;
@@ -1384,7 +1547,7 @@ update_catch_except_flags(struct rb_iseq_constant_body *body)
while (pos < body->iseq_size) {
insn = rb_vm_insn_decode(body->iseq_encoded[pos]);
if (insn == BIN(throw)) {
- set_catch_except_p(body);
+ set_catch_except_p(iseq);
break;
}
pos += insn_len(insn);
@@ -1399,7 +1562,8 @@ update_catch_except_flags(struct rb_iseq_constant_body *body)
if (entry->type != CATCH_TYPE_BREAK
&& entry->type != CATCH_TYPE_NEXT
&& entry->type != CATCH_TYPE_REDO) {
- body->catch_except_p = true;
+ RUBY_ASSERT(ISEQ_COMPILE_DATA(iseq));
+ ISEQ_COMPILE_DATA(iseq)->catch_except_p = true;
break;
}
}
@@ -1411,9 +1575,9 @@ iseq_insert_nop_between_end_and_cont(rb_iseq_t *iseq)
VALUE catch_table_ary = ISEQ_COMPILE_DATA(iseq)->catch_table_ary;
if (NIL_P(catch_table_ary)) return;
unsigned int i, tlen = (unsigned int)RARRAY_LEN(catch_table_ary);
- const VALUE *tptr = RARRAY_CONST_PTR_TRANSIENT(catch_table_ary);
+ const VALUE *tptr = RARRAY_CONST_PTR(catch_table_ary);
for (i = 0; i < tlen; i++) {
- const VALUE *ptr = RARRAY_CONST_PTR_TRANSIENT(tptr[i]);
+ const VALUE *ptr = RARRAY_CONST_PTR(tptr[i]);
LINK_ELEMENT *end = (LINK_ELEMENT *)(ptr[2] & ~1);
LINK_ELEMENT *cont = (LINK_ELEMENT *)(ptr[4] & ~1);
LINK_ELEMENT *e;
@@ -1460,13 +1624,6 @@ iseq_setup_insn(rb_iseq_t *iseq, LINK_ANCHOR *const anchor)
dump_disasm_list(FIRST_ELEMENT(anchor));
}
- if (ISEQ_COMPILE_DATA(iseq)->option->stack_caching) {
- debugs("[compile step 3.3 (iseq_set_sequence_stackcaching)]\n");
- iseq_set_sequence_stackcaching(iseq, anchor);
- if (compile_debug > 5)
- dump_disasm_list(FIRST_ELEMENT(anchor));
- }
-
debugs("[compile step 3.4 (iseq_insert_nop_between_end_and_cont)]\n");
iseq_insert_nop_between_end_and_cont(iseq);
if (compile_debug > 5)
@@ -1496,10 +1653,12 @@ iseq_setup(rb_iseq_t *iseq, LINK_ANCHOR *const anchor)
if (!rb_iseq_translate_threaded_code(iseq)) return COMPILE_NG;
debugs("[compile step 6 (update_catch_except_flags)] \n");
- update_catch_except_flags(ISEQ_BODY(iseq));
+ RUBY_ASSERT(ISEQ_COMPILE_DATA(iseq));
+ update_catch_except_flags(iseq, ISEQ_BODY(iseq));
debugs("[compile step 6.1 (remove unused catch tables)] \n");
- if (!ISEQ_BODY(iseq)->catch_except_p && ISEQ_BODY(iseq)->catch_table) {
+ RUBY_ASSERT(ISEQ_COMPILE_DATA(iseq));
+ if (!ISEQ_COMPILE_DATA(iseq)->catch_except_p && ISEQ_BODY(iseq)->catch_table) {
xfree(ISEQ_BODY(iseq)->catch_table);
ISEQ_BODY(iseq)->catch_table = NULL;
}
@@ -1740,7 +1899,7 @@ static int
iseq_set_arguments_keywords(rb_iseq_t *iseq, LINK_ANCHOR *const optargs,
const struct rb_args_info *args, int arg_size)
{
- const NODE *node = args->kw_args;
+ const rb_node_kw_arg_t *node = args->kw_args;
struct rb_iseq_constant_body *const body = ISEQ_BODY(iseq);
struct rb_iseq_param_keyword *keyword;
const VALUE default_values = rb_ary_hidden_new(1);
@@ -1759,7 +1918,7 @@ iseq_set_arguments_keywords(rb_iseq_t *iseq, LINK_ANCHOR *const optargs,
node = args->kw_args;
while (node) {
- const NODE *val_node = node->nd_body->nd_value;
+ const NODE *val_node = get_nd_value(node->nd_body);
VALUE dv;
if (val_node == NODE_SPECIAL_REQUIRED_KEYWORD) {
@@ -1768,7 +1927,7 @@ iseq_set_arguments_keywords(rb_iseq_t *iseq, LINK_ANCHOR *const optargs,
else {
switch (nd_type(val_node)) {
case NODE_LIT:
- dv = val_node->nd_lit;
+ dv = RNODE_LIT(val_node)->nd_lit;
break;
case NODE_NIL:
dv = Qnil;
@@ -1780,7 +1939,7 @@ iseq_set_arguments_keywords(rb_iseq_t *iseq, LINK_ANCHOR *const optargs,
dv = Qfalse;
break;
default:
- NO_CHECK(COMPILE_POPPED(optargs, "kwarg", node)); /* nd_type_p(node, NODE_KW_ARG) */
+ NO_CHECK(COMPILE_POPPED(optargs, "kwarg", RNODE(node))); /* nd_type_p(node, NODE_KW_ARG) */
dv = complex_mark;
}
@@ -1793,7 +1952,7 @@ iseq_set_arguments_keywords(rb_iseq_t *iseq, LINK_ANCHOR *const optargs,
keyword->num = kw;
- if (args->kw_rest_arg->nd_vid != 0) {
+ if (RNODE_DVAR(args->kw_rest_arg)->nd_vid != 0) {
keyword->rest_start = arg_size++;
body->param.flags.has_kwrest = TRUE;
}
@@ -1824,7 +1983,7 @@ iseq_set_arguments(rb_iseq_t *iseq, LINK_ANCHOR *const optargs, const NODE *cons
if (node_args) {
struct rb_iseq_constant_body *const body = ISEQ_BODY(iseq);
- struct rb_args_info *args = node_args->nd_ainfo;
+ struct rb_args_info *args = &RNODE_ARGS(node_args)->nd_ainfo;
ID rest_id = 0;
int last_comma = 0;
ID block_id = 0;
@@ -1845,14 +2004,14 @@ iseq_set_arguments(rb_iseq_t *iseq, LINK_ANCHOR *const optargs, const NODE *cons
block_id = args->block_arg;
if (args->opt_args) {
- const NODE *node = args->opt_args;
+ const rb_node_opt_arg_t *node = args->opt_args;
LABEL *label;
VALUE labels = rb_ary_hidden_new(1);
VALUE *opt_table;
int i = 0, j;
while (node) {
- label = NEW_LABEL(nd_line(node));
+ label = NEW_LABEL(nd_line(RNODE(node)));
rb_ary_push(labels, (VALUE)label | 1);
ADD_LABEL(optargs, label);
NO_CHECK(COMPILE_POPPED(optargs, "optarg", node->nd_body));
@@ -1867,7 +2026,7 @@ iseq_set_arguments(rb_iseq_t *iseq, LINK_ANCHOR *const optargs, const NODE *cons
opt_table = ALLOC_N(VALUE, i+1);
- MEMCPY(opt_table, RARRAY_CONST_PTR_TRANSIENT(labels), VALUE, i+1);
+ MEMCPY(opt_table, RARRAY_CONST_PTR(labels), VALUE, i+1);
for (j = 0; j < i+1; j++) {
opt_table[j] &= ~1;
}
@@ -2353,7 +2512,12 @@ iseq_set_sequence(rb_iseq_t *iseq, LINK_ANCHOR *const anchor)
generated_iseq = ALLOC_N(VALUE, code_index);
insns_info = ALLOC_N(struct iseq_insn_info_entry, insn_num);
positions = ALLOC_N(unsigned int, insn_num);
- body->is_entries = ZALLOC_N(union iseq_inline_storage_entry, ISEQ_IS_SIZE(body));
+ if (ISEQ_IS_SIZE(body)) {
+ body->is_entries = ZALLOC_N(union iseq_inline_storage_entry, ISEQ_IS_SIZE(body));
+ }
+ else {
+ body->is_entries = NULL;
+ }
body->call_data = ZALLOC_N(struct rb_call_data, body->ci_size);
ISEQ_COMPILE_DATA(iseq)->ci_index = 0;
@@ -2492,8 +2656,8 @@ iseq_set_sequence(rb_iseq_t *iseq, LINK_ANCHOR *const anchor)
case TS_CALLDATA:
{
const struct rb_callinfo *source_ci = (const struct rb_callinfo *)operands[j];
- struct rb_call_data *cd = &body->call_data[ISEQ_COMPILE_DATA(iseq)->ci_index++];
assert(ISEQ_COMPILE_DATA(iseq)->ci_index <= body->ci_size);
+ struct rb_call_data *cd = &body->call_data[ISEQ_COMPILE_DATA(iseq)->ci_index++];
cd->ci = source_ci;
cd->cc = vm_cc_empty();
generated_iseq[code_index + 1 + j] = (VALUE)cd;
@@ -2631,16 +2795,18 @@ iseq_set_exception_table(rb_iseq_t *iseq)
struct iseq_catch_table_entry *entry;
ISEQ_BODY(iseq)->catch_table = NULL;
- if (NIL_P(ISEQ_COMPILE_DATA(iseq)->catch_table_ary)) return COMPILE_OK;
- tlen = (int)RARRAY_LEN(ISEQ_COMPILE_DATA(iseq)->catch_table_ary);
- tptr = RARRAY_CONST_PTR_TRANSIENT(ISEQ_COMPILE_DATA(iseq)->catch_table_ary);
+
+ VALUE catch_table_ary = ISEQ_COMPILE_DATA(iseq)->catch_table_ary;
+ if (NIL_P(catch_table_ary)) return COMPILE_OK;
+ tlen = (int)RARRAY_LEN(catch_table_ary);
+ tptr = RARRAY_CONST_PTR(catch_table_ary);
if (tlen > 0) {
struct iseq_catch_table *table = xmalloc(iseq_catch_table_bytes(tlen));
table->size = tlen;
for (i = 0; i < table->size; i++) {
- ptr = RARRAY_CONST_PTR_TRANSIENT(tptr[i]);
+ ptr = RARRAY_CONST_PTR(tptr[i]);
entry = UNALIGNED_MEMBER_PTR(table, entries[i]);
entry->type = (enum rb_catch_type)(ptr[0] & 0xffff);
entry->start = label_get_position((LABEL *)(ptr[1] & ~1));
@@ -2669,6 +2835,8 @@ iseq_set_exception_table(rb_iseq_t *iseq)
RB_OBJ_WRITE(iseq, &ISEQ_COMPILE_DATA(iseq)->catch_table_ary, 0); /* free */
}
+ RB_GC_GUARD(catch_table_ary);
+
return COMPILE_OK;
}
@@ -3319,7 +3487,7 @@ iseq_peephole_optimize(rb_iseq_t *iseq, LINK_ELEMENT *list, const int do_tailcal
previ == BIN(getlocal) ||
previ == BIN(getblockparam) ||
previ == BIN(getblockparamproxy) ||
- /* getinstancevariable may issue a warning */
+ previ == BIN(getinstancevariable) ||
previ == BIN(duparray)) {
/* just push operand or static value and pop soon, no
* side effects */
@@ -3646,6 +3814,10 @@ iseq_peephole_optimize(rb_iseq_t *iseq, LINK_ELEMENT *list, const int do_tailcal
if (IS_TRACE(iobj->link.next)) {
if (IS_NEXT_INSN_ID(iobj->link.next, leave)) {
iobj->insn_id = BIN(opt_invokebuiltin_delegate_leave);
+ const struct rb_builtin_function *bf = (const struct rb_builtin_function *)iobj->operands[0];
+ if (iobj == (INSN *)list && bf->argc == 0 && (iseq->body->builtin_attrs & BUILTIN_ATTR_LEAF)) {
+ iseq->body->builtin_attrs |= BUILTIN_ATTR_SINGLE_NOARG_INLINE;
+ }
}
}
}
@@ -3663,6 +3835,166 @@ iseq_peephole_optimize(rb_iseq_t *iseq, LINK_ELEMENT *list, const int do_tailcal
}
}
+ if (IS_INSN_ID(iobj, splatarray) && OPERAND_AT(iobj, 0) == Qtrue) {
+ LINK_ELEMENT *niobj = &iobj->link;
+
+ /*
+ * Eliminate array allocation for f(1, *a)
+ *
+ * splatarray true
+ * send ARGS_SPLAT and not KW_SPLAT|ARGS_BLOCKARG
+ * =>
+ * splatarray false
+ * send
+ */
+ if (IS_NEXT_INSN_ID(niobj, send)) {
+ niobj = niobj->next;
+ unsigned int flag = vm_ci_flag((const struct rb_callinfo *)OPERAND_AT(niobj, 0));
+ if ((flag & VM_CALL_ARGS_SPLAT) && !(flag & (VM_CALL_KW_SPLAT|VM_CALL_ARGS_BLOCKARG))) {
+ OPERAND_AT(iobj, 0) = Qfalse;
+ }
+ } else if (IS_NEXT_INSN_ID(niobj, getlocal) || IS_NEXT_INSN_ID(niobj, getinstancevariable)) {
+ niobj = niobj->next;
+
+ if (IS_NEXT_INSN_ID(niobj, send)) {
+ niobj = niobj->next;
+ unsigned int flag = vm_ci_flag((const struct rb_callinfo *)OPERAND_AT(niobj, 0));
+
+ if ((flag & VM_CALL_ARGS_SPLAT)) {
+ /*
+ * Eliminate array allocation for f(1, *a, &lvar) and f(1, *a, &@iv)
+ *
+ * splatarray true
+ * getlocal / getinstancevariable
+ * send ARGS_SPLAT|ARGS_BLOCKARG and not KW_SPLAT
+ * =>
+ * splatarray false
+ * getlocal / getinstancevariable
+ * send
+ */
+ if ((flag & VM_CALL_ARGS_BLOCKARG) && !(flag & VM_CALL_KW_SPLAT)) {
+ OPERAND_AT(iobj, 0) = Qfalse;
+ }
+
+ /*
+ * Eliminate array allocation for f(*a, **lvar) and f(*a, **@iv)
+ *
+ * splatarray true
+ * getlocal / getinstancevariable
+ * send ARGS_SPLAT|KW_SPLAT and not ARGS_BLOCKARG
+ * =>
+ * splatarray false
+ * getlocal / getinstancevariable
+ * send
+ */
+ else if (!(flag & VM_CALL_ARGS_BLOCKARG) && (flag & VM_CALL_KW_SPLAT)) {
+ OPERAND_AT(iobj, 0) = Qfalse;
+ }
+ }
+ }
+ else if (IS_NEXT_INSN_ID(niobj, getlocal) || IS_NEXT_INSN_ID(niobj, getinstancevariable) ||
+ IS_NEXT_INSN_ID(niobj, getblockparamproxy)) {
+ niobj = niobj->next;
+
+ /*
+ * Eliminate array allocation for f(*a, **lvar, &lvar) and f(*a, **@iv, &@iv)
+ *
+ * splatarray true
+ * getlocal / getinstancevariable
+ * getlocal / getinstancevariable / getblockparamproxy
+ * send ARGS_SPLAT|KW_SPLAT|ARGS_BLOCKARG
+ * =>
+ * splatarray false
+ * getlocal / getinstancevariable
+ * getlocal / getinstancevariable / getblockparamproxy
+ * send
+ */
+ if (IS_NEXT_INSN_ID(niobj, send)) {
+ niobj = niobj->next;
+ unsigned int flag = vm_ci_flag((const struct rb_callinfo *)OPERAND_AT(niobj, 0));
+
+ if ((flag & VM_CALL_ARGS_SPLAT) && (flag & VM_CALL_KW_SPLAT) && (flag & VM_CALL_ARGS_BLOCKARG)) {
+ OPERAND_AT(iobj, 0) = Qfalse;
+ }
+ }
+ }
+ }
+ else if (IS_NEXT_INSN_ID(niobj, getblockparamproxy)) {
+ niobj = niobj->next;
+
+ if (IS_NEXT_INSN_ID(niobj, send)) {
+ niobj = niobj->next;
+ unsigned int flag = vm_ci_flag((const struct rb_callinfo *)OPERAND_AT(niobj, 0));
+
+ /*
+ * Eliminate array allocation for f(1, *a, &arg)
+ *
+ * splatarray true
+ * getblockparamproxy
+ * send ARGS_SPLAT|ARGS_BLOCKARG and not KW_SPLAT
+ * =>
+ * splatarray false
+ * getblockparamproxy
+ * send
+ */
+ if ((flag & VM_CALL_ARGS_BLOCKARG) & (flag & VM_CALL_ARGS_SPLAT) && !(flag & VM_CALL_KW_SPLAT)) {
+ OPERAND_AT(iobj, 0) = Qfalse;
+ }
+ }
+ }
+ else if (IS_NEXT_INSN_ID(niobj, duphash)) {
+ niobj = niobj->next;
+
+ /*
+ * Eliminate array allocation for f(*a, kw: 1)
+ *
+ * splatarray true
+ * duphash
+ * send ARGS_SPLAT|KW_SPLAT|KW_SPLAT_MUT and not ARGS_BLOCKARG
+ * =>
+ * splatarray false
+ * duphash
+ * send
+ */
+ if (IS_NEXT_INSN_ID(niobj, send)) {
+ niobj = niobj->next;
+ unsigned int flag = vm_ci_flag((const struct rb_callinfo *)OPERAND_AT(niobj, 0));
+
+ if ((flag & VM_CALL_ARGS_SPLAT) && (flag & VM_CALL_KW_SPLAT) &&
+ (flag & VM_CALL_KW_SPLAT_MUT) && !(flag & VM_CALL_ARGS_BLOCKARG)) {
+ OPERAND_AT(iobj, 0) = Qfalse;
+ }
+ }
+ else if (IS_NEXT_INSN_ID(niobj, getlocal) || IS_NEXT_INSN_ID(niobj, getinstancevariable) ||
+ IS_NEXT_INSN_ID(niobj, getblockparamproxy)) {
+ niobj = niobj->next;
+
+ /*
+ * Eliminate array allocation for f(*a, kw: 1, &lvar) and f(*a, kw: 1, &@iv)
+ *
+ * splatarray true
+ * duphash
+ * getlocal / getinstancevariable / getblockparamproxy
+ * send ARGS_SPLAT|KW_SPLAT|KW_SPLAT_MUT|ARGS_BLOCKARG
+ * =>
+ * splatarray false
+ * duphash
+ * getlocal / getinstancevariable / getblockparamproxy
+ * send
+ */
+ if (IS_NEXT_INSN_ID(niobj, send)) {
+ niobj = niobj->next;
+ unsigned int flag = vm_ci_flag((const struct rb_callinfo *)OPERAND_AT(niobj, 0));
+
+ if ((flag & VM_CALL_ARGS_SPLAT) && (flag & VM_CALL_KW_SPLAT) &&
+ (flag & VM_CALL_KW_SPLAT_MUT) && (flag & VM_CALL_ARGS_BLOCKARG)) {
+ OPERAND_AT(iobj, 0) = Qfalse;
+ }
+ }
+ }
+ }
+ }
+
return COMPILE_OK;
}
@@ -3698,13 +4030,18 @@ iseq_specialized_instruction(rb_iseq_t *iseq, INSN *iobj)
if ((vm_ci_flag(ci) & VM_CALL_ARGS_SIMPLE) && vm_ci_argc(ci) == 0) {
switch (vm_ci_mid(ci)) {
case idMax:
- iobj->insn_id = BIN(opt_newarray_max);
- ELEM_REMOVE(&niobj->link);
- return COMPILE_OK;
case idMin:
- iobj->insn_id = BIN(opt_newarray_min);
- ELEM_REMOVE(&niobj->link);
- return COMPILE_OK;
+ case idHash:
+ {
+ VALUE num = iobj->operands[0];
+ iobj->insn_id = BIN(opt_newarray_send);
+ iobj->operands = compile_data_calloc2(iseq, insn_len(iobj->insn_id) - 1, sizeof(VALUE));
+ iobj->operands[0] = num;
+ iobj->operands[1] = rb_id2sym(vm_ci_mid(ci));
+ iobj->operand_size = insn_len(iobj->insn_id) - 1;
+ ELEM_REMOVE(&niobj->link);
+ return COMPILE_OK;
+ }
}
}
}
@@ -3798,7 +4135,7 @@ iseq_optimize(rb_iseq_t *iseq, LINK_ANCHOR *const anchor)
int do_block_optimization = 0;
- if (ISEQ_BODY(iseq)->type == ISEQ_TYPE_BLOCK && !ISEQ_BODY(iseq)->catch_except_p) {
+ if (ISEQ_BODY(iseq)->type == ISEQ_TYPE_BLOCK && !ISEQ_COMPILE_DATA(iseq)->catch_except_p) {
do_block_optimization = 1;
}
@@ -3936,167 +4273,6 @@ iseq_insns_unification(rb_iseq_t *iseq, LINK_ANCHOR *const anchor)
return COMPILE_OK;
}
-#if OPT_STACK_CACHING
-
-#define SC_INSN(insn, stat) sc_insn_info[(insn)][(stat)]
-#define SC_NEXT(insn) sc_insn_next[(insn)]
-
-#include "opt_sc.inc"
-
-static int
-insn_set_sc_state(rb_iseq_t *iseq, const LINK_ELEMENT *anchor, INSN *iobj, int state)
-{
- int nstate;
- int insn_id;
-
- insn_id = iobj->insn_id;
- iobj->insn_id = SC_INSN(insn_id, state);
- nstate = SC_NEXT(iobj->insn_id);
-
- if (insn_id == BIN(jump) ||
- insn_id == BIN(branchif) || insn_id == BIN(branchunless)) {
- LABEL *lobj = (LABEL *)OPERAND_AT(iobj, 0);
-
- if (lobj->sc_state != 0) {
- if (lobj->sc_state != nstate) {
- BADINSN_DUMP(anchor, iobj, lobj);
- COMPILE_ERROR(iseq, iobj->insn_info.line_no,
- "insn_set_sc_state error: %d at "LABEL_FORMAT
- ", %d expected\n",
- lobj->sc_state, lobj->label_no, nstate);
- return COMPILE_NG;
- }
- }
- else {
- lobj->sc_state = nstate;
- }
- if (insn_id == BIN(jump)) {
- nstate = SCS_XX;
- }
- }
- else if (insn_id == BIN(leave)) {
- nstate = SCS_XX;
- }
-
- return nstate;
-}
-
-static int
-label_set_sc_state(LABEL *lobj, int state)
-{
- if (lobj->sc_state != 0) {
- if (lobj->sc_state != state) {
- state = lobj->sc_state;
- }
- }
- else {
- lobj->sc_state = state;
- }
-
- return state;
-}
-
-
-#endif
-
-static int
-iseq_set_sequence_stackcaching(rb_iseq_t *iseq, LINK_ANCHOR *const anchor)
-{
-#if OPT_STACK_CACHING
- LINK_ELEMENT *list;
- int state, insn_id;
-
- /* initialize */
- state = SCS_XX;
- list = FIRST_ELEMENT(anchor);
- /* dump_disasm_list(list); */
-
- /* for each list element */
- while (list) {
- redo_point:
- switch (list->type) {
- case ISEQ_ELEMENT_INSN:
- {
- INSN *iobj = (INSN *)list;
- insn_id = iobj->insn_id;
-
- /* dump_disasm_list(list); */
-
- switch (insn_id) {
- case BIN(nop):
- {
- /* exception merge point */
- if (state != SCS_AX) {
- NODE dummy_line_node = generate_dummy_line_node(0, -1);
- INSN *rpobj =
- new_insn_body(iseq, &dummy_line_node, BIN(reput), 0);
-
- /* replace this insn */
- ELEM_REPLACE(list, (LINK_ELEMENT *)rpobj);
- list = (LINK_ELEMENT *)rpobj;
- goto redo_point;
- }
- break;
- }
- case BIN(swap):
- {
- if (state == SCS_AB || state == SCS_BA) {
- state = (state == SCS_AB ? SCS_BA : SCS_AB);
-
- ELEM_REMOVE(list);
- list = list->next;
- goto redo_point;
- }
- break;
- }
- case BIN(pop):
- {
- switch (state) {
- case SCS_AX:
- case SCS_BX:
- state = SCS_XX;
- break;
- case SCS_AB:
- state = SCS_AX;
- break;
- case SCS_BA:
- state = SCS_BX;
- break;
- case SCS_XX:
- goto normal_insn;
- default:
- COMPILE_ERROR(iseq, iobj->insn_info.line_no,
- "unreachable");
- return COMPILE_NG;
- }
- /* remove useless pop */
- ELEM_REMOVE(list);
- list = list->next;
- goto redo_point;
- }
- default:;
- /* none */
- } /* end of switch */
- normal_insn:
- state = insn_set_sc_state(iseq, anchor, iobj, state);
- break;
- }
- case ISEQ_ELEMENT_LABEL:
- {
- LABEL *lobj;
- lobj = (LABEL *)list;
-
- state = label_set_sc_state(lobj, state);
- }
- default:
- break;
- }
- list = list->next;
- }
-#endif
- return COMPILE_OK;
-}
-
static int
all_string_result_p(const NODE *node)
{
@@ -4105,16 +4281,16 @@ all_string_result_p(const NODE *node)
case NODE_STR: case NODE_DSTR:
return TRUE;
case NODE_IF: case NODE_UNLESS:
- if (!node->nd_body || !node->nd_else) return FALSE;
- if (all_string_result_p(node->nd_body))
- return all_string_result_p(node->nd_else);
+ if (!RNODE_IF(node)->nd_body || !RNODE_IF(node)->nd_else) return FALSE;
+ if (all_string_result_p(RNODE_IF(node)->nd_body))
+ return all_string_result_p(RNODE_IF(node)->nd_else);
return FALSE;
case NODE_AND: case NODE_OR:
- if (!node->nd_2nd)
- return all_string_result_p(node->nd_1st);
- if (!all_string_result_p(node->nd_1st))
+ if (!RNODE_AND(node)->nd_2nd)
+ return all_string_result_p(RNODE_AND(node)->nd_1st);
+ if (!all_string_result_p(RNODE_AND(node)->nd_1st))
return FALSE;
- return all_string_result_p(node->nd_2nd);
+ return all_string_result_p(RNODE_AND(node)->nd_2nd);
default:
return FALSE;
}
@@ -4123,8 +4299,8 @@ all_string_result_p(const NODE *node)
static int
compile_dstr_fragments(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const node, int *cntp)
{
- const NODE *list = node->nd_next;
- VALUE lit = node->nd_lit;
+ const struct RNode_LIST *list = RNODE_DSTR(node)->nd_next;
+ VALUE lit = RNODE_DSTR(node)->nd_lit;
LINK_ELEMENT *first_lit = 0;
int cnt = 0;
@@ -4145,7 +4321,7 @@ compile_dstr_fragments(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *cons
while (list) {
const NODE *const head = list->nd_head;
if (nd_type_p(head, NODE_STR)) {
- lit = rb_fstring(head->nd_lit);
+ lit = rb_fstring(RNODE_STR(head)->nd_lit);
ADD_INSN1(ret, head, putobject, lit);
RB_OBJ_WRITTEN(iseq, Qundef, lit);
lit = Qnil;
@@ -4154,7 +4330,7 @@ compile_dstr_fragments(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *cons
CHECK(COMPILE(ret, "each string", head));
}
cnt++;
- list = list->nd_next;
+ list = (struct RNode_LIST *)list->nd_next;
}
if (NIL_P(lit) && first_lit) {
ELEM_REMOVE(first_lit);
@@ -4169,12 +4345,12 @@ static int
compile_block(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *node, int popped)
{
while (node && nd_type_p(node, NODE_BLOCK)) {
- CHECK(COMPILE_(ret, "BLOCK body", node->nd_head,
- (node->nd_next ? 1 : popped)));
- node = node->nd_next;
+ CHECK(COMPILE_(ret, "BLOCK body", RNODE_BLOCK(node)->nd_head,
+ (RNODE_BLOCK(node)->nd_next ? 1 : popped)));
+ node = RNODE_BLOCK(node)->nd_next;
}
if (node) {
- CHECK(COMPILE_(ret, "BLOCK next", node->nd_next, popped));
+ CHECK(COMPILE_(ret, "BLOCK next", RNODE_BLOCK(node)->nd_next, popped));
}
return COMPILE_OK;
}
@@ -4183,8 +4359,8 @@ static int
compile_dstr(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const node)
{
int cnt;
- if (!node->nd_next) {
- VALUE lit = rb_fstring(node->nd_lit);
+ if (!RNODE_DSTR(node)->nd_next) {
+ VALUE lit = rb_fstring(RNODE_DSTR(node)->nd_lit);
ADD_INSN1(ret, node, putstring, lit);
RB_OBJ_WRITTEN(iseq, Qundef, lit);
}
@@ -4196,11 +4372,28 @@ compile_dstr(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const node)
}
static int
-compile_dregx(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const node)
+compile_dregx(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const node, int popped)
{
int cnt;
+
+ if (!RNODE_DREGX(node)->nd_next) {
+ VALUE match = RNODE_DREGX(node)->nd_lit;
+ if (RB_TYPE_P(match, T_REGEXP)) {
+ if (!popped) {
+ ADD_INSN1(ret, node, putobject, match);
+ RB_OBJ_WRITTEN(iseq, Qundef, match);
+ }
+ return COMPILE_OK;
+ }
+ }
+
CHECK(compile_dstr_fragments(iseq, ret, node, &cnt));
- ADD_INSN2(ret, node, toregexp, INT2FIX(node->nd_cflag), INT2FIX(cnt));
+ ADD_INSN2(ret, node, toregexp, INT2FIX(RNODE_DREGX(node)->nd_cflag), INT2FIX(cnt));
+
+ if (popped) {
+ ADD_INSN(ret, node, pop);
+ }
+
return COMPILE_OK;
}
@@ -4218,7 +4411,7 @@ compile_flip_flop(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const nod
ADD_INSNL(ret, node, branchif, lend);
/* *flip == 0 */
- CHECK(COMPILE(ret, "flip2 beg", node->nd_beg));
+ CHECK(COMPILE(ret, "flip2 beg", RNODE_FLIP2(node)->nd_beg));
ADD_INSNL(ret, node, branchunless, else_label);
ADD_INSN1(ret, node, putobject, Qtrue);
ADD_INSN1(ret, node, setspecial, key);
@@ -4228,7 +4421,7 @@ compile_flip_flop(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const nod
/* *flip == 1 */
ADD_LABEL(ret, lend);
- CHECK(COMPILE(ret, "flip2 end", node->nd_end));
+ CHECK(COMPILE(ret, "flip2 end", RNODE_FLIP2(node)->nd_end));
ADD_INSNL(ret, node, branchunless, then_label);
ADD_INSN1(ret, node, putobject, Qfalse);
ADD_INSN1(ret, node, setspecial, key);
@@ -4238,37 +4431,62 @@ compile_flip_flop(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const nod
}
static int
-compile_branch_condition(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *cond,
+compile_branch_condition(rb_iseq_t *iseq, LINK_ANCHOR *ret, const NODE *cond,
+ LABEL *then_label, LABEL *else_label);
+
+#define COMPILE_SINGLE 2
+static int
+compile_logical(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *cond,
+ LABEL *then_label, LABEL *else_label)
+{
+ DECL_ANCHOR(seq);
+ INIT_ANCHOR(seq);
+ LABEL *label = NEW_LABEL(nd_line(cond));
+ if (!then_label) then_label = label;
+ else if (!else_label) else_label = label;
+
+ CHECK(compile_branch_condition(iseq, seq, cond, then_label, else_label));
+
+ if (LIST_INSN_SIZE_ONE(seq)) {
+ INSN *insn = (INSN *)ELEM_FIRST_INSN(FIRST_ELEMENT(seq));
+ if (insn->insn_id == BIN(jump) && (LABEL *)(insn->operands[0]) == label)
+ return COMPILE_OK;
+ }
+ if (!label->refcnt) {
+ return COMPILE_SINGLE;
+ }
+ ADD_LABEL(seq, label);
+ ADD_SEQ(ret, seq);
+ return COMPILE_OK;
+}
+
+static int
+compile_branch_condition(rb_iseq_t *iseq, LINK_ANCHOR *ret, const NODE *cond,
LABEL *then_label, LABEL *else_label)
{
+ int ok;
+ DECL_ANCHOR(ignore);
+
again:
switch (nd_type(cond)) {
case NODE_AND:
- {
- LABEL *label = NEW_LABEL(nd_line(cond));
- CHECK(compile_branch_condition(iseq, ret, cond->nd_1st, label,
- else_label));
- if (!label->refcnt) {
- ADD_INSN(ret, cond, putnil);
- break;
- }
- ADD_LABEL(ret, label);
- cond = cond->nd_2nd;
- goto again;
- }
+ CHECK(ok = compile_logical(iseq, ret, RNODE_AND(cond)->nd_1st, NULL, else_label));
+ cond = RNODE_AND(cond)->nd_2nd;
+ if (ok == COMPILE_SINGLE) {
+ INIT_ANCHOR(ignore);
+ ret = ignore;
+ then_label = NEW_LABEL(nd_line(cond));
+ }
+ goto again;
case NODE_OR:
- {
- LABEL *label = NEW_LABEL(nd_line(cond));
- CHECK(compile_branch_condition(iseq, ret, cond->nd_1st, then_label,
- label));
- if (!label->refcnt) {
- ADD_INSN(ret, cond, putnil);
- break;
- }
- ADD_LABEL(ret, label);
- cond = cond->nd_2nd;
- goto again;
- }
+ CHECK(ok = compile_logical(iseq, ret, RNODE_OR(cond)->nd_1st, then_label, NULL));
+ cond = RNODE_OR(cond)->nd_2nd;
+ if (ok == COMPILE_SINGLE) {
+ INIT_ANCHOR(ignore);
+ ret = ignore;
+ else_label = NEW_LABEL(nd_line(cond));
+ }
+ goto again;
case NODE_LIT: /* NODE_LIT is always true */
case NODE_TRUE:
case NODE_STR:
@@ -4299,7 +4517,28 @@ compile_branch_condition(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *co
CHECK(compile_defined_expr(iseq, ret, cond, Qfalse));
break;
default:
- CHECK(COMPILE(ret, "branch condition", cond));
+ {
+ DECL_ANCHOR(cond_seq);
+ INIT_ANCHOR(cond_seq);
+
+ CHECK(COMPILE(cond_seq, "branch condition", cond));
+
+ if (LIST_INSN_SIZE_ONE(cond_seq)) {
+ INSN *insn = (INSN *)ELEM_FIRST_INSN(FIRST_ELEMENT(cond_seq));
+ if (insn->insn_id == BIN(putobject)) {
+ if (RTEST(insn->operands[0])) {
+ ADD_INSNL(ret, cond, jump, then_label);
+ // maybe unreachable
+ return COMPILE_OK;
+ }
+ else {
+ ADD_INSNL(ret, cond, jump, else_label);
+ return COMPILE_OK;
+ }
+ }
+ }
+ ADD_SEQ(ret, cond_seq);
+ }
break;
}
@@ -4313,33 +4552,35 @@ compile_branch_condition(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *co
static int
keyword_node_p(const NODE *const node)
{
- return nd_type_p(node, NODE_HASH) && (node->nd_brace & HASH_BRACE) != HASH_BRACE;
+ return nd_type_p(node, NODE_HASH) && (RNODE_HASH(node)->nd_brace & HASH_BRACE) != HASH_BRACE;
}
static int
compile_keyword_arg(rb_iseq_t *iseq, LINK_ANCHOR *const ret,
- const NODE *const root_node,
- struct rb_callinfo_kwarg **const kw_arg_ptr,
- unsigned int *flag)
+ const NODE *const root_node,
+ struct rb_callinfo_kwarg **const kw_arg_ptr,
+ unsigned int *flag)
{
- if (kw_arg_ptr == NULL) return FALSE;
+ RUBY_ASSERT(nd_type_p(root_node, NODE_HASH));
+ RUBY_ASSERT(kw_arg_ptr != NULL);
+ RUBY_ASSERT(flag != NULL);
- if (root_node->nd_head && nd_type_p(root_node->nd_head, NODE_LIST)) {
- const NODE *node = root_node->nd_head;
+ if (RNODE_HASH(root_node)->nd_head && nd_type_p(RNODE_HASH(root_node)->nd_head, NODE_LIST)) {
+ const NODE *node = RNODE_HASH(root_node)->nd_head;
int seen_nodes = 0;
while (node) {
- const NODE *key_node = node->nd_head;
+ const NODE *key_node = RNODE_LIST(node)->nd_head;
seen_nodes++;
assert(nd_type_p(node, NODE_LIST));
- if (key_node && nd_type_p(key_node, NODE_LIT) && SYMBOL_P(key_node->nd_lit)) {
+ if (key_node && nd_type_p(key_node, NODE_LIT) && SYMBOL_P(RNODE_LIT(key_node)->nd_lit)) {
/* can be keywords */
}
else {
if (flag) {
*flag |= VM_CALL_KW_SPLAT;
- if (seen_nodes > 1 || node->nd_next->nd_next) {
+ if (seen_nodes > 1 || RNODE_LIST(RNODE_LIST(node)->nd_next)->nd_next) {
/* A new hash will be created for the keyword arguments
* in this case, so mark the method as passing mutable
* keyword splat.
@@ -4349,26 +4590,27 @@ compile_keyword_arg(rb_iseq_t *iseq, LINK_ANCHOR *const ret,
}
return FALSE;
}
- node = node->nd_next; /* skip value node */
- node = node->nd_next;
+ node = RNODE_LIST(node)->nd_next; /* skip value node */
+ node = RNODE_LIST(node)->nd_next;
}
/* may be keywords */
- node = root_node->nd_head;
+ node = RNODE_HASH(root_node)->nd_head;
{
- int len = (int)node->nd_alen / 2;
+ int len = (int)RNODE_LIST(node)->as.nd_alen / 2;
struct rb_callinfo_kwarg *kw_arg =
rb_xmalloc_mul_add(len, sizeof(VALUE), sizeof(struct rb_callinfo_kwarg));
VALUE *keywords = kw_arg->keywords;
int i = 0;
+ kw_arg->references = 0;
kw_arg->keyword_len = len;
*kw_arg_ptr = kw_arg;
- for (i=0; node != NULL; i++, node = node->nd_next->nd_next) {
- const NODE *key_node = node->nd_head;
- const NODE *val_node = node->nd_next->nd_head;
- keywords[i] = key_node->nd_lit;
+ for (i=0; node != NULL; i++, node = RNODE_LIST(RNODE_LIST(node)->nd_next)->nd_next) {
+ const NODE *key_node = RNODE_LIST(node)->nd_head;
+ const NODE *val_node = RNODE_LIST(RNODE_LIST(node)->nd_next)->nd_head;
+ keywords[i] = RNODE_LIT(key_node)->nd_lit;
NO_CHECK(COMPILE(ret, "keyword values", val_node));
}
assert(i == len);
@@ -4379,26 +4621,21 @@ compile_keyword_arg(rb_iseq_t *iseq, LINK_ANCHOR *const ret,
}
static int
-compile_args(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *node,
- struct rb_callinfo_kwarg **keywords_ptr, unsigned int *flag)
+compile_args(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *node, NODE **kwnode_ptr)
{
int len = 0;
- for (; node; len++, node = node->nd_next) {
+ for (; node; len++, node = RNODE_LIST(node)->nd_next) {
if (CPDEBUG > 0) {
EXPECT_NODE("compile_args", node, NODE_LIST, -1);
}
- if (node->nd_next == NULL && keyword_node_p(node->nd_head)) { /* last node */
- if (compile_keyword_arg(iseq, ret, node->nd_head, keywords_ptr, flag)) {
- len--;
- }
- else {
- compile_hash(iseq, ret, node->nd_head, TRUE, FALSE);
- }
+ if (RNODE_LIST(node)->nd_next == NULL && keyword_node_p(RNODE_LIST(node)->nd_head)) { /* last node is kwnode */
+ *kwnode_ptr = RNODE_LIST(node)->nd_head;
}
else {
- NO_CHECK(COMPILE_(ret, "array element", node->nd_head, FALSE));
+ RUBY_ASSERT(!keyword_node_p(RNODE_LIST(node)->nd_head));
+ NO_CHECK(COMPILE_(ret, "array element", RNODE_LIST(node)->nd_head, FALSE));
}
}
@@ -4435,15 +4672,15 @@ static_literal_value(const NODE *node, rb_iseq_t *iseq)
if (ISEQ_COMPILE_DATA(iseq)->option->debug_frozen_string_literal || RTEST(ruby_debug)) {
VALUE lit;
VALUE debug_info = rb_ary_new_from_args(2, rb_iseq_path(iseq), INT2FIX((int)nd_line(node)));
- lit = rb_str_dup(node->nd_lit);
+ lit = rb_str_dup(RNODE_STR(node)->nd_lit);
rb_ivar_set(lit, id_debug_created_info, rb_obj_freeze(debug_info));
return rb_str_freeze(lit);
}
else {
- return rb_fstring(node->nd_lit);
+ return rb_fstring(RNODE_STR(node)->nd_lit);
}
default:
- return node->nd_lit;
+ return RNODE_LIT(node)->nd_lit;
}
}
@@ -4462,8 +4699,8 @@ compile_array(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *node, int pop
EXPECT_NODE("compile_array", node, NODE_LIST, -1);
if (popped) {
- for (; node; node = node->nd_next) {
- NO_CHECK(COMPILE_(ret, "array element", node->nd_head, popped));
+ for (; node; node = RNODE_LIST(node)->nd_next) {
+ NO_CHECK(COMPILE_(ret, "array element", RNODE_LIST(node)->nd_head, popped));
}
return 1;
}
@@ -4522,10 +4759,10 @@ compile_array(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *node, int pop
int count = 1;
/* pre-allocation check (this branch can be omittable) */
- if (static_literal_node_p(node->nd_head, iseq)) {
+ if (static_literal_node_p(RNODE_LIST(node)->nd_head, iseq)) {
/* count the elements that are optimizable */
- const NODE *node_tmp = node->nd_next;
- for (; node_tmp && static_literal_node_p(node_tmp->nd_head, iseq); node_tmp = node_tmp->nd_next)
+ const NODE *node_tmp = RNODE_LIST(node)->nd_next;
+ for (; node_tmp && static_literal_node_p(RNODE_LIST(node_tmp)->nd_head, iseq); node_tmp = RNODE_LIST(node_tmp)->nd_next)
count++;
if ((first_chunk && stack_len == 0 && !node_tmp) || count >= min_tmp_ary_len) {
@@ -4533,8 +4770,8 @@ compile_array(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *node, int pop
VALUE ary = rb_ary_hidden_new(count);
/* Create a hidden array */
- for (; count; count--, node = node->nd_next)
- rb_ary_push(ary, static_literal_value(node->nd_head, iseq));
+ for (; count; count--, node = RNODE_LIST(node)->nd_next)
+ rb_ary_push(ary, static_literal_value(RNODE_LIST(node)->nd_head, iseq));
OBJ_FREEZE(ary);
/* Emit optimized code */
@@ -4552,15 +4789,15 @@ compile_array(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *node, int pop
}
/* Base case: Compile "count" elements */
- for (; count; count--, node = node->nd_next) {
+ for (; count; count--, node = RNODE_LIST(node)->nd_next) {
if (CPDEBUG > 0) {
EXPECT_NODE("compile_array", node, NODE_LIST, -1);
}
- NO_CHECK(COMPILE_(ret, "array element", node->nd_head, 0));
+ NO_CHECK(COMPILE_(ret, "array element", RNODE_LIST(node)->nd_head, 0));
stack_len++;
- if (!node->nd_next && keyword_node_p(node->nd_head)) {
+ if (!RNODE_LIST(node)->nd_next && keyword_node_p(RNODE_LIST(node)->nd_head)) {
/* Reached the end, and the last element is a keyword */
FLUSH_CHUNK(newarraykwsplat);
return 1;
@@ -4598,7 +4835,7 @@ compile_array_1(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *node)
static inline int
static_literal_node_pair_p(const NODE *node, const rb_iseq_t *iseq)
{
- return node->nd_head && static_literal_node_p(node->nd_head, iseq) && static_literal_node_p(node->nd_next->nd_head, iseq);
+ return RNODE_LIST(node)->nd_head && static_literal_node_p(RNODE_LIST(node)->nd_head, iseq) && static_literal_node_p(RNODE_LIST(RNODE_LIST(node)->nd_next)->nd_head, iseq);
}
static int
@@ -4606,7 +4843,7 @@ compile_hash(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *node, int meth
{
const NODE *line_node = node;
- node = node->nd_head;
+ node = RNODE_HASH(node)->nd_head;
if (!node || nd_type_p(node, NODE_ZLIST)) {
if (!popped) {
@@ -4618,8 +4855,8 @@ compile_hash(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *node, int meth
EXPECT_NODE("compile_hash", node, NODE_LIST, -1);
if (popped) {
- for (; node; node = node->nd_next) {
- NO_CHECK(COMPILE_(ret, "hash element", node->nd_head, popped));
+ for (; node; node = RNODE_LIST(node)->nd_next) {
+ NO_CHECK(COMPILE_(ret, "hash element", RNODE_LIST(node)->nd_head, popped));
}
return 1;
}
@@ -4672,8 +4909,8 @@ compile_hash(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *node, int meth
/* pre-allocation check (this branch can be omittable) */
if (static_literal_node_pair_p(node, iseq)) {
/* count the elements that are optimizable */
- const NODE *node_tmp = node->nd_next->nd_next;
- for (; node_tmp && static_literal_node_pair_p(node_tmp, iseq); node_tmp = node_tmp->nd_next->nd_next)
+ const NODE *node_tmp = RNODE_LIST(RNODE_LIST(node)->nd_next)->nd_next;
+ for (; node_tmp && static_literal_node_pair_p(node_tmp, iseq); node_tmp = RNODE_LIST(RNODE_LIST(node_tmp)->nd_next)->nd_next)
count++;
if ((first_chunk && stack_len == 0 && !node_tmp) || count >= min_tmp_hash_len) {
@@ -4681,14 +4918,14 @@ compile_hash(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *node, int meth
VALUE ary = rb_ary_hidden_new(count);
/* Create a hidden hash */
- for (; count; count--, node = node->nd_next->nd_next) {
+ for (; count; count--, node = RNODE_LIST(RNODE_LIST(node)->nd_next)->nd_next) {
VALUE elem[2];
- elem[0] = static_literal_value(node->nd_head, iseq);
- elem[1] = static_literal_value(node->nd_next->nd_head, iseq);
+ elem[0] = static_literal_value(RNODE_LIST(node)->nd_head, iseq);
+ elem[1] = static_literal_value(RNODE_LIST(RNODE_LIST(node)->nd_next)->nd_head, iseq);
rb_ary_cat(ary, elem, 2);
}
VALUE hash = rb_hash_new_with_size(RARRAY_LEN(ary) / 2);
- rb_hash_bulk_insert(RARRAY_LEN(ary), RARRAY_CONST_PTR_TRANSIENT(ary), hash);
+ rb_hash_bulk_insert(RARRAY_LEN(ary), RARRAY_CONST_PTR(ary), hash);
hash = rb_obj_hide(hash);
OBJ_FREEZE(hash);
@@ -4711,16 +4948,16 @@ compile_hash(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *node, int meth
}
/* Base case: Compile "count" elements */
- for (; count; count--, node = node->nd_next->nd_next) {
+ for (; count; count--, node = RNODE_LIST(RNODE_LIST(node)->nd_next)->nd_next) {
if (CPDEBUG > 0) {
EXPECT_NODE("compile_hash", node, NODE_LIST, -1);
}
- if (node->nd_head) {
+ if (RNODE_LIST(node)->nd_head) {
/* Normal key-value pair */
- NO_CHECK(COMPILE_(anchor, "hash key element", node->nd_head, 0));
- NO_CHECK(COMPILE_(anchor, "hash value element", node->nd_next->nd_head, 0));
+ NO_CHECK(COMPILE_(anchor, "hash key element", RNODE_LIST(node)->nd_head, 0));
+ NO_CHECK(COMPILE_(anchor, "hash value element", RNODE_LIST(RNODE_LIST(node)->nd_next)->nd_head, 0));
stack_len += 2;
/* If there are many pushed elements, flush them to avoid stack overflow */
@@ -4730,10 +4967,10 @@ compile_hash(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *node, int meth
/* kwsplat case: foo(..., **kw, ...) */
FLUSH_CHUNK();
- const NODE *kw = node->nd_next->nd_head;
- int empty_kw = nd_type_p(kw, NODE_LIT) && RB_TYPE_P(kw->nd_lit, T_HASH); /* foo( ..., **{}, ...) */
+ const NODE *kw = RNODE_LIST(RNODE_LIST(node)->nd_next)->nd_head;
+ int empty_kw = nd_type_p(kw, NODE_LIT) && RB_TYPE_P(RNODE_LIT(kw)->nd_lit, T_HASH); /* foo( ..., **{}, ...) */
int first_kw = first_chunk && stack_len == 0; /* foo(1,2,3, **kw, ...) */
- int last_kw = !node->nd_next->nd_next; /* foo( ..., **kw) */
+ int last_kw = !RNODE_LIST(RNODE_LIST(node)->nd_next)->nd_next; /* foo( ..., **kw) */
int only_kw = last_kw && first_kw; /* foo(1,2,3, **kw) */
if (empty_kw) {
@@ -4796,7 +5033,7 @@ rb_node_case_when_optimizable_literal(const NODE *const node)
{
switch (nd_type(node)) {
case NODE_LIT: {
- VALUE v = node->nd_lit;
+ VALUE v = RNODE_LIT(node)->nd_lit;
double ival;
if (RB_FLOAT_TYPE_P(v) &&
modf(RFLOAT_VALUE(v), &ival) == 0.0) {
@@ -4817,7 +5054,7 @@ rb_node_case_when_optimizable_literal(const NODE *const node)
case NODE_FALSE:
return Qfalse;
case NODE_STR:
- return rb_fstring(node->nd_lit);
+ return rb_fstring(RNODE_STR(node)->nd_lit);
}
return Qundef;
}
@@ -4827,7 +5064,7 @@ when_vals(rb_iseq_t *iseq, LINK_ANCHOR *const cond_seq, const NODE *vals,
LABEL *l1, int only_special_literals, VALUE literals)
{
while (vals) {
- const NODE *val = vals->nd_head;
+ const NODE *val = RNODE_LIST(vals)->nd_head;
VALUE lit = rb_node_case_when_optimizable_literal(val);
if (UNDEF_P(lit)) {
@@ -4838,8 +5075,8 @@ when_vals(rb_iseq_t *iseq, LINK_ANCHOR *const cond_seq, const NODE *vals,
}
if (nd_type_p(val, NODE_STR)) {
- debugp_param("nd_lit", val->nd_lit);
- lit = rb_fstring(val->nd_lit);
+ debugp_param("nd_lit", RNODE_STR(val)->nd_lit);
+ lit = rb_fstring(RNODE_STR(val)->nd_lit);
ADD_INSN1(cond_seq, val, putobject, lit);
RB_OBJ_WRITTEN(iseq, Qundef, lit);
}
@@ -4847,11 +5084,11 @@ when_vals(rb_iseq_t *iseq, LINK_ANCHOR *const cond_seq, const NODE *vals,
if (!COMPILE(cond_seq, "when cond", val)) return -1;
}
- // Emit patern === target
+ // Emit pattern === target
ADD_INSN1(cond_seq, vals, topn, INT2FIX(1));
ADD_CALL(cond_seq, vals, idEqq, INT2FIX(1));
ADD_INSNL(cond_seq, val, branchif, l1);
- vals = vals->nd_next;
+ vals = RNODE_LIST(vals)->nd_next;
}
return only_special_literals;
}
@@ -4869,19 +5106,19 @@ when_splat_vals(rb_iseq_t *iseq, LINK_ANCHOR *const cond_seq, const NODE *vals,
break;
case NODE_SPLAT:
ADD_INSN (cond_seq, line_node, dup);
- CHECK(COMPILE(cond_seq, "when splat", vals->nd_head));
+ CHECK(COMPILE(cond_seq, "when splat", RNODE_SPLAT(vals)->nd_head));
ADD_INSN1(cond_seq, line_node, splatarray, Qfalse);
ADD_INSN1(cond_seq, line_node, checkmatch, INT2FIX(VM_CHECKMATCH_TYPE_CASE | VM_CHECKMATCH_ARRAY));
ADD_INSNL(cond_seq, line_node, branchif, l1);
break;
case NODE_ARGSCAT:
- CHECK(when_splat_vals(iseq, cond_seq, vals->nd_head, l1, only_special_literals, literals));
- CHECK(when_splat_vals(iseq, cond_seq, vals->nd_body, l1, only_special_literals, literals));
+ CHECK(when_splat_vals(iseq, cond_seq, RNODE_ARGSCAT(vals)->nd_head, l1, only_special_literals, literals));
+ CHECK(when_splat_vals(iseq, cond_seq, RNODE_ARGSCAT(vals)->nd_body, l1, only_special_literals, literals));
break;
case NODE_ARGSPUSH:
- CHECK(when_splat_vals(iseq, cond_seq, vals->nd_head, l1, only_special_literals, literals));
+ CHECK(when_splat_vals(iseq, cond_seq, RNODE_ARGSPUSH(vals)->nd_head, l1, only_special_literals, literals));
ADD_INSN (cond_seq, line_node, dup);
- CHECK(COMPILE(cond_seq, "when argspush body", vals->nd_body));
+ CHECK(COMPILE(cond_seq, "when argspush body", RNODE_ARGSPUSH(vals)->nd_body));
ADD_INSN1(cond_seq, line_node, checkmatch, INT2FIX(VM_CHECKMATCH_TYPE_CASE));
ADD_INSNL(cond_seq, line_node, branchif, l1);
break;
@@ -5101,7 +5338,7 @@ compile_massign_lhs(rb_iseq_t *iseq, LINK_ANCHOR *const pre, LINK_ANCHOR *const
break;
}
case NODE_CDECL:
- if (!node->nd_vid) {
+ if (!RNODE_CDECL(node)->nd_vid) {
/* Special handling only needed for expr::C, not for C */
INSN *iobj;
@@ -5139,8 +5376,8 @@ static int
compile_massign_opt_lhs(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *lhsn)
{
if (lhsn) {
- CHECK(compile_massign_opt_lhs(iseq, ret, lhsn->nd_next));
- CHECK(compile_massign_lhs(iseq, ret, ret, ret, ret, lhsn->nd_head, NULL, 0));
+ CHECK(compile_massign_opt_lhs(iseq, ret, RNODE_LIST(lhsn)->nd_next));
+ CHECK(compile_massign_lhs(iseq, ret, ret, ret, ret, RNODE_LIST(lhsn)->nd_head, NULL, 0));
}
return COMPILE_OK;
}
@@ -5170,31 +5407,29 @@ compile_massign_opt(rb_iseq_t *iseq, LINK_ANCHOR *const ret,
}
while (lhsn) {
- const NODE *ln = lhsn->nd_head;
+ const NODE *ln = RNODE_LIST(lhsn)->nd_head;
switch (nd_type(ln)) {
case NODE_LASGN:
- MEMORY(ln->nd_vid);
- break;
case NODE_DASGN:
case NODE_IASGN:
case NODE_CVASGN:
- MEMORY(ln->nd_vid);
+ MEMORY(get_nd_vid(ln));
break;
default:
return 0;
}
- lhsn = lhsn->nd_next;
+ lhsn = RNODE_LIST(lhsn)->nd_next;
llen++;
}
while (rhsn) {
if (llen <= rlen) {
- NO_CHECK(COMPILE_POPPED(ret, "masgn val (popped)", rhsn->nd_head));
+ NO_CHECK(COMPILE_POPPED(ret, "masgn val (popped)", RNODE_LIST(rhsn)->nd_head));
}
else {
- NO_CHECK(COMPILE(ret, "masgn val", rhsn->nd_head));
+ NO_CHECK(COMPILE(ret, "masgn val", RNODE_LIST(rhsn)->nd_head));
}
- rhsn = rhsn->nd_next;
+ rhsn = RNODE_LIST(rhsn)->nd_next;
rlen++;
}
@@ -5211,32 +5446,31 @@ compile_massign_opt(rb_iseq_t *iseq, LINK_ANCHOR *const ret,
static int
compile_massign0(rb_iseq_t *iseq, LINK_ANCHOR *const pre, LINK_ANCHOR *const rhs, LINK_ANCHOR *const lhs, LINK_ANCHOR *const post, const NODE *const node, struct masgn_state *state, int popped)
{
- const NODE *rhsn = node->nd_value;
- const NODE *splatn = node->nd_args;
- const NODE *lhsn = node->nd_head;
+ const NODE *rhsn = RNODE_MASGN(node)->nd_value;
+ const NODE *splatn = RNODE_MASGN(node)->nd_args;
+ const NODE *lhsn = RNODE_MASGN(node)->nd_head;
const NODE *lhsn_count = lhsn;
int lhs_splat = (splatn && NODE_NAMED_REST_P(splatn)) ? 1 : 0;
int llen = 0;
int lpos = 0;
- int expand = 1;
while (lhsn_count) {
llen++;
- lhsn_count = lhsn_count->nd_next;
+ lhsn_count = RNODE_LIST(lhsn_count)->nd_next;
}
while (lhsn) {
- CHECK(compile_massign_lhs(iseq, pre, rhs, lhs, post, lhsn->nd_head, state, (llen - lpos) + lhs_splat + state->lhs_level));
+ CHECK(compile_massign_lhs(iseq, pre, rhs, lhs, post, RNODE_LIST(lhsn)->nd_head, state, (llen - lpos) + lhs_splat + state->lhs_level));
lpos++;
- lhsn = lhsn->nd_next;
+ lhsn = RNODE_LIST(lhsn)->nd_next;
}
if (lhs_splat) {
if (nd_type_p(splatn, NODE_POSTARG)) {
/*a, b, *r, p1, p2 */
- const NODE *postn = splatn->nd_2nd;
- const NODE *restn = splatn->nd_1st;
- int plen = (int)postn->nd_alen;
+ const NODE *postn = RNODE_POSTARG(splatn)->nd_2nd;
+ const NODE *restn = RNODE_POSTARG(splatn)->nd_1st;
+ int plen = (int)RNODE_LIST(postn)->as.nd_alen;
int ppos = 0;
int flag = 0x02 | (NODE_NAMED_REST_P(restn) ? 0x01 : 0x00);
@@ -5246,9 +5480,9 @@ compile_massign0(rb_iseq_t *iseq, LINK_ANCHOR *const pre, LINK_ANCHOR *const rhs
CHECK(compile_massign_lhs(iseq, pre, rhs, lhs, post, restn, state, 1 + plen + state->lhs_level));
}
while (postn) {
- CHECK(compile_massign_lhs(iseq, pre, rhs, lhs, post, postn->nd_head, state, (plen - ppos) + state->lhs_level));
+ CHECK(compile_massign_lhs(iseq, pre, rhs, lhs, post, RNODE_LIST(postn)->nd_head, state, (plen - ppos) + state->lhs_level));
ppos++;
- postn = postn->nd_next;
+ postn = RNODE_LIST(postn)->nd_next;
}
}
else {
@@ -5257,7 +5491,6 @@ compile_massign0(rb_iseq_t *iseq, LINK_ANCHOR *const pre, LINK_ANCHOR *const rhs
}
}
-
if (!state->nested) {
NO_CHECK(COMPILE(rhs, "normal masgn rhs", rhsn));
}
@@ -5265,16 +5498,14 @@ compile_massign0(rb_iseq_t *iseq, LINK_ANCHOR *const pre, LINK_ANCHOR *const rhs
if (!popped) {
ADD_INSN(rhs, node, dup);
}
- if (expand) {
- ADD_INSN2(rhs, node, expandarray, INT2FIX(llen), INT2FIX(lhs_splat));
- }
+ ADD_INSN2(rhs, node, expandarray, INT2FIX(llen), INT2FIX(lhs_splat));
return COMPILE_OK;
}
static int
compile_massign(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const node, int popped)
{
- if (!popped || node->nd_args || !compile_massign_opt(iseq, ret, node->nd_value, node->nd_head)) {
+ if (!popped || RNODE_MASGN(node)->nd_args || !compile_massign_opt(iseq, ret, RNODE_MASGN(node)->nd_value, RNODE_MASGN(node)->nd_head)) {
struct masgn_state state;
state.lhs_level = popped ? 0 : 1;
state.nested = 0;
@@ -5323,15 +5554,15 @@ collect_const_segments(rb_iseq_t *iseq, const NODE *node)
for (;;) {
switch (nd_type(node)) {
case NODE_CONST:
- rb_ary_unshift(arr, ID2SYM(node->nd_vid));
+ rb_ary_unshift(arr, ID2SYM(RNODE_CONST(node)->nd_vid));
return arr;
case NODE_COLON3:
- rb_ary_unshift(arr, ID2SYM(node->nd_mid));
+ rb_ary_unshift(arr, ID2SYM(RNODE_COLON3(node)->nd_mid));
rb_ary_unshift(arr, ID2SYM(idNULL));
return arr;
case NODE_COLON2:
- rb_ary_unshift(arr, ID2SYM(node->nd_mid));
- node = node->nd_head;
+ rb_ary_unshift(arr, ID2SYM(RNODE_COLON2(node)->nd_mid));
+ node = RNODE_COLON2(node)->nd_head;
break;
default:
return Qfalse;
@@ -5345,22 +5576,22 @@ compile_const_prefix(rb_iseq_t *iseq, const NODE *const node,
{
switch (nd_type(node)) {
case NODE_CONST:
- debugi("compile_const_prefix - colon", node->nd_vid);
+ debugi("compile_const_prefix - colon", RNODE_CONST(node)->nd_vid);
ADD_INSN1(body, node, putobject, Qtrue);
- ADD_INSN1(body, node, getconstant, ID2SYM(node->nd_vid));
+ ADD_INSN1(body, node, getconstant, ID2SYM(RNODE_CONST(node)->nd_vid));
break;
case NODE_COLON3:
- debugi("compile_const_prefix - colon3", node->nd_mid);
+ debugi("compile_const_prefix - colon3", RNODE_COLON3(node)->nd_mid);
ADD_INSN(body, node, pop);
ADD_INSN1(body, node, putobject, rb_cObject);
ADD_INSN1(body, node, putobject, Qtrue);
- ADD_INSN1(body, node, getconstant, ID2SYM(node->nd_mid));
+ ADD_INSN1(body, node, getconstant, ID2SYM(RNODE_COLON3(node)->nd_mid));
break;
case NODE_COLON2:
- CHECK(compile_const_prefix(iseq, node->nd_head, pref, body));
- debugi("compile_const_prefix - colon2", node->nd_mid);
+ CHECK(compile_const_prefix(iseq, RNODE_COLON2(node)->nd_head, pref, body));
+ debugi("compile_const_prefix - colon2", RNODE_COLON2(node)->nd_mid);
ADD_INSN1(body, node, putobject, Qfalse);
- ADD_INSN1(body, node, getconstant, ID2SYM(node->nd_mid));
+ ADD_INSN1(body, node, getconstant, ID2SYM(RNODE_COLON2(node)->nd_mid));
break;
default:
CHECK(COMPILE(pref, "const colon2 prefix", node));
@@ -5377,9 +5608,9 @@ compile_cpath(LINK_ANCHOR *const ret, rb_iseq_t *iseq, const NODE *cpath)
ADD_INSN1(ret, cpath, putobject, rb_cObject);
return VM_DEFINECLASS_FLAG_SCOPED;
}
- else if (cpath->nd_head) {
+ else if (nd_type_p(cpath, NODE_COLON2) && RNODE_COLON2(cpath)->nd_head) {
/* Bar::Foo */
- NO_CHECK(COMPILE(ret, "nd_else->nd_head", cpath->nd_head));
+ NO_CHECK(COMPILE(ret, "nd_else->nd_head", RNODE_COLON2(cpath)->nd_head));
return VM_DEFINECLASS_FLAG_SCOPED;
}
else {
@@ -5393,9 +5624,9 @@ compile_cpath(LINK_ANCHOR *const ret, rb_iseq_t *iseq, const NODE *cpath)
static inline int
private_recv_p(const NODE *node)
{
- if (nd_type_p(node->nd_recv, NODE_SELF)) {
- NODE *self = node->nd_recv;
- return self->nd_state != 0;
+ NODE *recv = get_nd_recv(node);
+ if (recv && nd_type_p(recv, NODE_SELF)) {
+ return RNODE_SELF(recv)->nd_state != 0;
}
return 0;
}
@@ -5437,13 +5668,13 @@ defined_expr0(rb_iseq_t *iseq, LINK_ANCHOR *const ret,
const NODE *vals = node;
do {
- defined_expr0(iseq, ret, vals->nd_head, lfinish, Qfalse, false);
+ defined_expr0(iseq, ret, RNODE_LIST(vals)->nd_head, lfinish, Qfalse, false);
if (!lfinish[1]) {
lfinish[1] = NEW_LABEL(line);
}
ADD_INSNL(ret, line_node, branchunless, lfinish[1]);
- } while ((vals = vals->nd_next) != NULL);
+ } while ((vals = RNODE_LIST(vals)->nd_next) != NULL);
}
/* fall through */
case NODE_STR:
@@ -5463,49 +5694,48 @@ defined_expr0(rb_iseq_t *iseq, LINK_ANCHOR *const ret,
#define PUSH_VAL(type) (needstr == Qfalse ? Qtrue : rb_iseq_defined_string(type))
case NODE_IVAR:
- ADD_INSN(ret, line_node, putnil);
- ADD_INSN3(ret, line_node, defined, INT2FIX(DEFINED_IVAR),
- ID2SYM(node->nd_vid), PUSH_VAL(DEFINED_IVAR));
+ ADD_INSN3(ret, line_node, definedivar,
+ ID2SYM(RNODE_IVAR(node)->nd_vid), get_ivar_ic_value(iseq,RNODE_IVAR(node)->nd_vid), PUSH_VAL(DEFINED_IVAR));
return;
case NODE_GVAR:
ADD_INSN(ret, line_node, putnil);
ADD_INSN3(ret, line_node, defined, INT2FIX(DEFINED_GVAR),
- ID2SYM(node->nd_entry), PUSH_VAL(DEFINED_GVAR));
+ ID2SYM(RNODE_GVAR(node)->nd_vid), PUSH_VAL(DEFINED_GVAR));
return;
case NODE_CVAR:
ADD_INSN(ret, line_node, putnil);
ADD_INSN3(ret, line_node, defined, INT2FIX(DEFINED_CVAR),
- ID2SYM(node->nd_vid), PUSH_VAL(DEFINED_CVAR));
+ ID2SYM(RNODE_CVAR(node)->nd_vid), PUSH_VAL(DEFINED_CVAR));
return;
case NODE_CONST:
ADD_INSN(ret, line_node, putnil);
ADD_INSN3(ret, line_node, defined, INT2FIX(DEFINED_CONST),
- ID2SYM(node->nd_vid), PUSH_VAL(DEFINED_CONST));
+ ID2SYM(RNODE_CONST(node)->nd_vid), PUSH_VAL(DEFINED_CONST));
return;
case NODE_COLON2:
if (!lfinish[1]) {
lfinish[1] = NEW_LABEL(line);
}
- defined_expr0(iseq, ret, node->nd_head, lfinish, Qfalse, false);
+ defined_expr0(iseq, ret, RNODE_COLON2(node)->nd_head, lfinish, Qfalse, false);
ADD_INSNL(ret, line_node, branchunless, lfinish[1]);
- NO_CHECK(COMPILE(ret, "defined/colon2#nd_head", node->nd_head));
+ NO_CHECK(COMPILE(ret, "defined/colon2#nd_head", RNODE_COLON2(node)->nd_head));
- if (rb_is_const_id(node->nd_mid)) {
+ if (rb_is_const_id(RNODE_COLON2(node)->nd_mid)) {
ADD_INSN3(ret, line_node, defined, INT2FIX(DEFINED_CONST_FROM),
- ID2SYM(node->nd_mid), PUSH_VAL(DEFINED_CONST));
+ ID2SYM(RNODE_COLON2(node)->nd_mid), PUSH_VAL(DEFINED_CONST));
}
else {
ADD_INSN3(ret, line_node, defined, INT2FIX(DEFINED_METHOD),
- ID2SYM(node->nd_mid), PUSH_VAL(DEFINED_METHOD));
+ ID2SYM(RNODE_COLON2(node)->nd_mid), PUSH_VAL(DEFINED_METHOD));
}
return;
case NODE_COLON3:
ADD_INSN1(ret, line_node, putobject, rb_cObject);
ADD_INSN3(ret, line_node, defined,
- INT2FIX(DEFINED_CONST_FROM), ID2SYM(node->nd_mid), PUSH_VAL(DEFINED_CONST));
+ INT2FIX(DEFINED_CONST_FROM), ID2SYM(RNODE_COLON3(node)->nd_mid), PUSH_VAL(DEFINED_CONST));
return;
/* method dispatch */
@@ -5518,7 +5748,7 @@ defined_expr0(rb_iseq_t *iseq, LINK_ANCHOR *const ret,
(type == NODE_CALL || type == NODE_OPCALL ||
(type == NODE_ATTRASGN && !private_recv_p(node)));
- if (node->nd_args || explicit_receiver) {
+ if (get_nd_args(node) || explicit_receiver) {
if (!lfinish[1]) {
lfinish[1] = NEW_LABEL(line);
}
@@ -5526,31 +5756,31 @@ defined_expr0(rb_iseq_t *iseq, LINK_ANCHOR *const ret,
lfinish[2] = NEW_LABEL(line);
}
}
- if (node->nd_args) {
- defined_expr0(iseq, ret, node->nd_args, lfinish, Qfalse, false);
+ if (get_nd_args(node)) {
+ defined_expr0(iseq, ret, get_nd_args(node), lfinish, Qfalse, false);
ADD_INSNL(ret, line_node, branchunless, lfinish[1]);
}
if (explicit_receiver) {
- defined_expr0(iseq, ret, node->nd_recv, lfinish, Qfalse, true);
- switch (nd_type(node->nd_recv)) {
+ defined_expr0(iseq, ret, get_nd_recv(node), lfinish, Qfalse, true);
+ switch (nd_type(get_nd_recv(node))) {
case NODE_CALL:
case NODE_OPCALL:
case NODE_VCALL:
case NODE_FCALL:
case NODE_ATTRASGN:
ADD_INSNL(ret, line_node, branchunless, lfinish[2]);
- compile_call(iseq, ret, node->nd_recv, nd_type(node->nd_recv), line_node, 0, true);
+ compile_call(iseq, ret, get_nd_recv(node), nd_type(get_nd_recv(node)), line_node, 0, true);
break;
default:
ADD_INSNL(ret, line_node, branchunless, lfinish[1]);
- NO_CHECK(COMPILE(ret, "defined/recv", node->nd_recv));
+ NO_CHECK(COMPILE(ret, "defined/recv", get_nd_recv(node)));
break;
}
if (keep_result) {
ADD_INSN(ret, line_node, dup);
}
ADD_INSN3(ret, line_node, defined, INT2FIX(DEFINED_METHOD),
- ID2SYM(node->nd_mid), PUSH_VAL(DEFINED_METHOD));
+ ID2SYM(get_node_call_nd_mid(node)), PUSH_VAL(DEFINED_METHOD));
}
else {
ADD_INSN(ret, line_node, putself);
@@ -5558,7 +5788,7 @@ defined_expr0(rb_iseq_t *iseq, LINK_ANCHOR *const ret,
ADD_INSN(ret, line_node, dup);
}
ADD_INSN3(ret, line_node, defined, INT2FIX(DEFINED_FUNC),
- ID2SYM(node->nd_mid), PUSH_VAL(DEFINED_METHOD));
+ ID2SYM(get_node_call_nd_mid(node)), PUSH_VAL(DEFINED_METHOD));
}
return;
}
@@ -5573,7 +5803,7 @@ defined_expr0(rb_iseq_t *iseq, LINK_ANCHOR *const ret,
case NODE_NTH_REF:
ADD_INSN(ret, line_node, putnil);
ADD_INSN3(ret, line_node, defined, INT2FIX(DEFINED_REF),
- INT2FIX((node->nd_nth << 1) | (type == NODE_BACK_REF)),
+ INT2FIX((RNODE_BACK_REF(node)->nd_nth << 1) | (type == NODE_BACK_REF)),
PUSH_VAL(DEFINED_GVAR));
return;
@@ -5649,7 +5879,7 @@ compile_defined_expr(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const
{
const int line = nd_line(node);
const NODE *line_node = node;
- if (!node->nd_head) {
+ if (!RNODE_DEFINED(node)->nd_head) {
VALUE str = rb_iseq_defined_string(DEFINED_NIL);
ADD_INSN1(ret, line_node, putobject, str);
}
@@ -5659,7 +5889,7 @@ compile_defined_expr(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const
lfinish[0] = NEW_LABEL(line);
lfinish[1] = 0;
lfinish[2] = 0;
- defined_expr(iseq, ret, node->nd_head, lfinish, needstr);
+ defined_expr(iseq, ret, RNODE_DEFINED(node)->nd_head, lfinish, needstr);
if (lfinish[1]) {
ELEM_INSERT_NEXT(last, &new_insn_body(iseq, line_node, BIN(putnil), 0)->link);
ADD_INSN(ret, line_node, swap);
@@ -5700,7 +5930,7 @@ make_name_for_block(const rb_iseq_t *orig_iseq)
static void
push_ensure_entry(rb_iseq_t *iseq,
struct iseq_compile_data_ensure_node_stack *enl,
- struct ensure_range *er, const NODE *const node)
+ struct ensure_range *er, const void *const node)
{
enl->ensure_node = node;
enl->prev = ISEQ_COMPILE_DATA(iseq)->ensure_node_stack; /* prev */
@@ -5776,79 +6006,138 @@ add_ensure_iseq(LINK_ANCHOR *const ret, rb_iseq_t *iseq, int is_return)
ADD_SEQ(ret, ensure);
}
+#if RUBY_DEBUG
static int
check_keyword(const NODE *node)
{
/* This check is essentially a code clone of compile_keyword_arg. */
if (nd_type_p(node, NODE_LIST)) {
- while (node->nd_next) {
- node = node->nd_next;
+ while (RNODE_LIST(node)->nd_next) {
+ node = RNODE_LIST(node)->nd_next;
}
- node = node->nd_head;
+ node = RNODE_LIST(node)->nd_head;
}
return keyword_node_p(node);
}
+#endif
-static VALUE
+static bool
+keyword_node_single_splat_p(NODE *kwnode)
+{
+ RUBY_ASSERT(keyword_node_p(kwnode));
+
+ NODE *node = RNODE_HASH(kwnode)->nd_head;
+ return RNODE_LIST(node)->nd_head == NULL &&
+ RNODE_LIST(RNODE_LIST(node)->nd_next)->nd_next == NULL;
+}
+
+static int
setup_args_core(rb_iseq_t *iseq, LINK_ANCHOR *const args, const NODE *argn,
- int dup_rest, unsigned int *flag, struct rb_callinfo_kwarg **keywords)
-{
- if (argn) {
- switch (nd_type(argn)) {
- case NODE_SPLAT: {
- NO_CHECK(COMPILE(args, "args (splat)", argn->nd_head));
- ADD_INSN1(args, argn, splatarray, RBOOL(dup_rest));
- if (flag) *flag |= VM_CALL_ARGS_SPLAT;
- return INT2FIX(1);
- }
- case NODE_ARGSCAT:
- case NODE_ARGSPUSH: {
- int next_is_list = (nd_type_p(argn->nd_head, NODE_LIST));
- VALUE argc = setup_args_core(iseq, args, argn->nd_head, 1, NULL, NULL);
- if (nd_type_p(argn->nd_body, NODE_LIST)) {
- /* This branch is needed to avoid "newarraykwsplat" [Bug #16442] */
- int rest_len = compile_args(iseq, args, argn->nd_body, NULL, NULL);
- ADD_INSN1(args, argn, newarray, INT2FIX(rest_len));
+ int dup_rest, unsigned int *flag_ptr, struct rb_callinfo_kwarg **kwarg_ptr)
+{
+ if (!argn) return 0;
+
+ NODE *kwnode = NULL;
+
+ switch (nd_type(argn)) {
+ case NODE_LIST: {
+ // f(x, y, z)
+ int len = compile_args(iseq, args, argn, &kwnode);
+ RUBY_ASSERT(flag_ptr == NULL || (*flag_ptr & VM_CALL_ARGS_SPLAT) == 0);
+
+ if (kwnode) {
+ if (compile_keyword_arg(iseq, args, kwnode, kwarg_ptr, flag_ptr)) {
+ len -= 1;
}
else {
- NO_CHECK(COMPILE(args, "args (cat: splat)", argn->nd_body));
- }
- if (flag) {
- *flag |= VM_CALL_ARGS_SPLAT;
- /* This is a dirty hack. It traverses the AST twice.
- * In a long term, it should be fixed by a redesign of keyword arguments */
- if (check_keyword(argn->nd_body))
- *flag |= VM_CALL_KW_SPLAT;
+ compile_hash(iseq, args, kwnode, TRUE, FALSE);
}
- if (nd_type_p(argn, NODE_ARGSCAT)) {
- if (next_is_list) {
- ADD_INSN1(args, argn, splatarray, Qtrue);
- return INT2FIX(FIX2INT(argc) + 1);
- }
- else {
- ADD_INSN1(args, argn, splatarray, Qfalse);
- ADD_INSN(args, argn, concatarray);
- return argc;
- }
+ }
+
+ return len;
+ }
+ case NODE_SPLAT: {
+ // f(*a)
+ NO_CHECK(COMPILE(args, "args (splat)", RNODE_SPLAT(argn)->nd_head));
+ ADD_INSN1(args, argn, splatarray, RBOOL(dup_rest));
+ if (flag_ptr) *flag_ptr |= VM_CALL_ARGS_SPLAT;
+ RUBY_ASSERT(flag_ptr == NULL || (*flag_ptr & VM_CALL_KW_SPLAT) == 0);
+ return 1;
+ }
+ case NODE_ARGSCAT: {
+ if (flag_ptr) *flag_ptr |= VM_CALL_ARGS_SPLAT;
+ int argc = setup_args_core(iseq, args, RNODE_ARGSCAT(argn)->nd_head, 1, NULL, NULL);
+
+ if (nd_type_p(RNODE_ARGSCAT(argn)->nd_body, NODE_LIST)) {
+ int rest_len = compile_args(iseq, args, RNODE_ARGSCAT(argn)->nd_body, &kwnode);
+ if (kwnode) rest_len--;
+ ADD_INSN1(args, argn, newarray, INT2FIX(rest_len));
+ }
+ else {
+ RUBY_ASSERT(!check_keyword(RNODE_ARGSCAT(argn)->nd_body));
+ NO_CHECK(COMPILE(args, "args (cat: splat)", RNODE_ARGSCAT(argn)->nd_body));
+ }
+
+ if (nd_type_p(RNODE_ARGSCAT(argn)->nd_head, NODE_LIST)) {
+ ADD_INSN1(args, argn, splatarray, Qtrue);
+ argc += 1;
+ }
+ else {
+ ADD_INSN1(args, argn, splatarray, Qfalse);
+ ADD_INSN(args, argn, concatarray);
+ }
+
+ // f(..., *a, ..., k1:1, ...) #=> f(..., *[*a, ...], **{k1:1, ...})
+ if (kwnode) {
+ // kwsplat
+ *flag_ptr |= VM_CALL_KW_SPLAT;
+ *flag_ptr |= VM_CALL_KW_SPLAT_MUT;
+ compile_hash(iseq, args, kwnode, TRUE, FALSE);
+ argc += 1;
+ }
+
+ return argc;
+ }
+ case NODE_ARGSPUSH: {
+ if (flag_ptr) *flag_ptr |= VM_CALL_ARGS_SPLAT;
+ int argc = setup_args_core(iseq, args, RNODE_ARGSPUSH(argn)->nd_head, 1, NULL, NULL);
+
+ if (nd_type_p(RNODE_ARGSPUSH(argn)->nd_body, NODE_LIST)) {
+ int rest_len = compile_args(iseq, args, RNODE_ARGSPUSH(argn)->nd_body, &kwnode);
+ if (kwnode) rest_len--;
+ ADD_INSN1(args, argn, newarray, INT2FIX(rest_len));
+ ADD_INSN1(args, argn, newarray, INT2FIX(1));
+ ADD_INSN(args, argn, concatarray);
+ }
+ else {
+ if (keyword_node_p(RNODE_ARGSPUSH(argn)->nd_body)) {
+ kwnode = RNODE_ARGSPUSH(argn)->nd_body;
}
else {
+ NO_CHECK(COMPILE(args, "args (cat: splat)", RNODE_ARGSPUSH(argn)->nd_body));
ADD_INSN1(args, argn, newarray, INT2FIX(1));
ADD_INSN(args, argn, concatarray);
- return argc;
}
- }
- case NODE_LIST: {
- int len = compile_args(iseq, args, argn, keywords, flag);
- return INT2FIX(len);
- }
- default: {
- UNKNOWN_NODE("setup_arg", argn, Qnil);
- }
}
+
+ if (kwnode) {
+ // f(*a, k:1)
+ *flag_ptr |= VM_CALL_KW_SPLAT;
+ if (!keyword_node_single_splat_p(kwnode)) {
+ *flag_ptr |= VM_CALL_KW_SPLAT_MUT;
+ }
+ compile_hash(iseq, args, kwnode, TRUE, FALSE);
+ argc += 1;
+ }
+
+ return argc;
+ }
+ default: {
+ UNKNOWN_NODE("setup_arg", argn, Qnil);
+ }
}
- return INT2FIX(0);
}
static VALUE
@@ -5860,7 +6149,7 @@ setup_args(rb_iseq_t *iseq, LINK_ANCHOR *const args, const NODE *argn,
unsigned int dup_rest = 1;
DECL_ANCHOR(arg_block);
INIT_ANCHOR(arg_block);
- NO_CHECK(COMPILE(arg_block, "block", argn->nd_body));
+ NO_CHECK(COMPILE(arg_block, "block", RNODE_BLOCK_PASS(argn)->nd_body));
*flag |= VM_CALL_ARGS_BLOCKARG;
@@ -5874,11 +6163,11 @@ setup_args(rb_iseq_t *iseq, LINK_ANCHOR *const args, const NODE *argn,
dup_rest = 0;
}
}
- ret = setup_args_core(iseq, args, argn->nd_head, dup_rest, flag, keywords);
+ ret = INT2FIX(setup_args_core(iseq, args, RNODE_BLOCK_PASS(argn)->nd_head, dup_rest, flag, keywords));
ADD_SEQ(args, arg_block);
}
else {
- ret = setup_args_core(iseq, args, argn, 0, flag, keywords);
+ ret = INT2FIX(setup_args_core(iseq, args, argn, 0, flag, keywords));
}
return ret;
}
@@ -5914,19 +6203,19 @@ compile_named_capture_assign(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE
ADD_INSN(ret, line_node, dup);
ADD_INSNL(ret, line_node, branchunless, fail_label);
- for (vars = node; vars; vars = vars->nd_next) {
+ for (vars = node; vars; vars = RNODE_BLOCK(vars)->nd_next) {
INSN *cap;
- if (vars->nd_next) {
+ if (RNODE_BLOCK(vars)->nd_next) {
ADD_INSN(ret, line_node, dup);
}
last = ret->last;
- NO_CHECK(COMPILE_POPPED(ret, "capture", vars->nd_head));
+ NO_CHECK(COMPILE_POPPED(ret, "capture", RNODE_BLOCK(vars)->nd_head));
last = last->next; /* putobject :var */
cap = new_insn_send(iseq, line_node, idAREF, INT2FIX(1),
NULL, INT2FIX(0), NULL);
ELEM_INSERT_PREV(last->next, (LINK_ELEMENT *)cap);
#if !defined(NAMED_CAPTURE_SINGLE_OPT) || NAMED_CAPTURE_SINGLE_OPT-0
- if (!vars->nd_next && vars == node) {
+ if (!RNODE_BLOCK(vars)->nd_next && vars == node) {
/* only one name */
DECL_ANCHOR(nom);
@@ -5947,9 +6236,9 @@ compile_named_capture_assign(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE
ADD_INSNL(ret, line_node, jump, end_label);
ADD_LABEL(ret, fail_label);
ADD_INSN(ret, line_node, pop);
- for (vars = node; vars; vars = vars->nd_next) {
+ for (vars = node; vars; vars = RNODE_BLOCK(vars)->nd_next) {
last = ret->last;
- NO_CHECK(COMPILE_POPPED(ret, "capture", vars->nd_head));
+ NO_CHECK(COMPILE_POPPED(ret, "capture", RNODE_BLOCK(vars)->nd_head));
last = last->next; /* putobject :var */
((INSN*)last)->insn_id = BIN(putnil);
((INSN*)last)->operand_size = 0;
@@ -5963,7 +6252,7 @@ optimizable_range_item_p(const NODE *n)
if (!n) return FALSE;
switch (nd_type(n)) {
case NODE_LIT:
- return RB_INTEGER_TYPE_P(n->nd_lit);
+ return RB_INTEGER_TYPE_P(RNODE_LIT(n)->nd_lit);
case NODE_NIL:
return TRUE;
default:
@@ -5974,53 +6263,21 @@ optimizable_range_item_p(const NODE *n)
static int
compile_if(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const node, int popped, const enum node_type type)
{
- struct rb_iseq_constant_body *const body = ISEQ_BODY(iseq);
- const NODE *const node_body = type == NODE_IF ? node->nd_body : node->nd_else;
- const NODE *const node_else = type == NODE_IF ? node->nd_else : node->nd_body;
+ const NODE *const node_body = type == NODE_IF ? RNODE_IF(node)->nd_body : RNODE_UNLESS(node)->nd_else;
+ const NODE *const node_else = type == NODE_IF ? RNODE_IF(node)->nd_else : RNODE_UNLESS(node)->nd_body;
const int line = nd_line(node);
const NODE *line_node = node;
DECL_ANCHOR(cond_seq);
- DECL_ANCHOR(then_seq);
- DECL_ANCHOR(else_seq);
LABEL *then_label, *else_label, *end_label;
VALUE branches = Qfalse;
- int ci_size;
- VALUE catch_table = ISEQ_COMPILE_DATA(iseq)->catch_table_ary;
- long catch_table_size = NIL_P(catch_table) ? 0 : RARRAY_LEN(catch_table);
INIT_ANCHOR(cond_seq);
- INIT_ANCHOR(then_seq);
- INIT_ANCHOR(else_seq);
then_label = NEW_LABEL(line);
else_label = NEW_LABEL(line);
end_label = 0;
- compile_branch_condition(iseq, cond_seq, node->nd_cond,
- then_label, else_label);
-
- ci_size = body->ci_size;
- CHECK(COMPILE_(then_seq, "then", node_body, popped));
- catch_table = ISEQ_COMPILE_DATA(iseq)->catch_table_ary;
- if (!then_label->refcnt) {
- body->ci_size = ci_size;
- if (!NIL_P(catch_table)) rb_ary_set_len(catch_table, catch_table_size);
- }
- else {
- if (!NIL_P(catch_table)) catch_table_size = RARRAY_LEN(catch_table);
- }
-
- ci_size = body->ci_size;
- CHECK(COMPILE_(else_seq, "else", node_else, popped));
- catch_table = ISEQ_COMPILE_DATA(iseq)->catch_table_ary;
- if (!else_label->refcnt) {
- body->ci_size = ci_size;
- if (!NIL_P(catch_table)) rb_ary_set_len(catch_table, catch_table_size);
- }
- else {
- if (!NIL_P(catch_table)) catch_table_size = RARRAY_LEN(catch_table);
- }
-
+ compile_branch_condition(iseq, cond_seq, RNODE_IF(node)->nd_cond, then_label, else_label);
ADD_SEQ(ret, cond_seq);
if (then_label->refcnt && else_label->refcnt) {
@@ -6029,6 +6286,11 @@ compile_if(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const node, int
if (then_label->refcnt) {
ADD_LABEL(ret, then_label);
+
+ DECL_ANCHOR(then_seq);
+ INIT_ANCHOR(then_seq);
+ CHECK(COMPILE_(then_seq, "then", node_body, popped));
+
if (else_label->refcnt) {
add_trace_branch_coverage(
iseq,
@@ -6048,6 +6310,11 @@ compile_if(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const node, int
if (else_label->refcnt) {
ADD_LABEL(ret, else_label);
+
+ DECL_ANCHOR(else_seq);
+ INIT_ANCHOR(else_seq);
+ CHECK(COMPILE_(else_seq, "else", node_else, popped));
+
if (then_label->refcnt) {
add_trace_branch_coverage(
iseq,
@@ -6090,11 +6357,11 @@ compile_case(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const orig_nod
RHASH_TBL_RAW(literals)->type = &cdhash_type;
- CHECK(COMPILE(head, "case base", node->nd_head));
+ CHECK(COMPILE(head, "case base", RNODE_CASE(node)->nd_head));
branches = decl_branch_base(iseq, node, "case");
- node = node->nd_body;
+ node = RNODE_CASE(node)->nd_body;
EXPECT_NODE("NODE_CASE", node, NODE_WHEN, COMPILE_NG);
type = nd_type(node);
line = nd_line(node);
@@ -6114,14 +6381,14 @@ compile_case(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const orig_nod
add_trace_branch_coverage(
iseq,
body_seq,
- node->nd_body ? node->nd_body : node,
+ RNODE_WHEN(node)->nd_body ? RNODE_WHEN(node)->nd_body : node,
branch_id++,
"when",
branches);
- CHECK(COMPILE_(body_seq, "when body", node->nd_body, popped));
+ CHECK(COMPILE_(body_seq, "when body", RNODE_WHEN(node)->nd_body, popped));
ADD_INSNL(body_seq, line_node, jump, endlabel);
- vals = node->nd_head;
+ vals = RNODE_WHEN(node)->nd_head;
if (vals) {
switch (nd_type(vals)) {
case NODE_LIST:
@@ -6142,7 +6409,7 @@ compile_case(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const orig_nod
EXPECT_NODE_NONULL("NODE_CASE", node, NODE_LIST, COMPILE_NG);
}
- node = node->nd_next;
+ node = RNODE_WHEN(node)->nd_next;
if (!node) {
break;
}
@@ -6187,7 +6454,7 @@ compile_case2(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const orig_no
{
const NODE *vals;
const NODE *val;
- const NODE *node = orig_node->nd_body;
+ const NODE *node = RNODE_CASE2(orig_node)->nd_body;
LABEL *endlabel;
DECL_ANCHOR(body_seq);
VALUE branches = Qfalse;
@@ -6205,14 +6472,14 @@ compile_case2(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const orig_no
add_trace_branch_coverage(
iseq,
body_seq,
- node->nd_body ? node->nd_body : node,
+ RNODE_WHEN(node)->nd_body ? RNODE_WHEN(node)->nd_body : node,
branch_id++,
"when",
branches);
- CHECK(COMPILE_(body_seq, "when", node->nd_body, popped));
+ CHECK(COMPILE_(body_seq, "when", RNODE_WHEN(node)->nd_body, popped));
ADD_INSNL(body_seq, node, jump, endlabel);
- vals = node->nd_head;
+ vals = RNODE_WHEN(node)->nd_head;
if (!vals) {
EXPECT_NODE_NONULL("NODE_WHEN", node, NODE_LIST, COMPILE_NG);
}
@@ -6220,12 +6487,12 @@ compile_case2(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const orig_no
case NODE_LIST:
while (vals) {
LABEL *lnext;
- val = vals->nd_head;
+ val = RNODE_LIST(vals)->nd_head;
lnext = NEW_LABEL(nd_line(val));
debug_compile("== when2\n", (void)0);
CHECK(compile_branch_condition(iseq, ret, val, l1, lnext));
ADD_LABEL(ret, lnext);
- vals = vals->nd_next;
+ vals = RNODE_LIST(vals)->nd_next;
}
break;
case NODE_SPLAT:
@@ -6239,7 +6506,7 @@ compile_case2(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const orig_no
default:
UNKNOWN_NODE("NODE_WHEN", vals, COMPILE_NG);
}
- node = node->nd_next;
+ node = RNODE_WHEN(node)->nd_next;
}
/* else */
add_trace_branch_coverage(
@@ -6331,14 +6598,13 @@ iseq_compile_pattern_each(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *c
* match_failed:
* goto unmatched
*/
- struct rb_ary_pattern_info *apinfo = node->nd_apinfo;
- const NODE *args = apinfo->pre_args;
- const int pre_args_num = apinfo->pre_args ? rb_long2int(apinfo->pre_args->nd_alen) : 0;
- const int post_args_num = apinfo->post_args ? rb_long2int(apinfo->post_args->nd_alen) : 0;
+ const NODE *args = RNODE_ARYPTN(node)->pre_args;
+ const int pre_args_num = RNODE_ARYPTN(node)->pre_args ? rb_long2int(RNODE_LIST(RNODE_ARYPTN(node)->pre_args)->as.nd_alen) : 0;
+ const int post_args_num = RNODE_ARYPTN(node)->post_args ? rb_long2int(RNODE_LIST(RNODE_ARYPTN(node)->post_args)->as.nd_alen) : 0;
const int min_argc = pre_args_num + post_args_num;
- const int use_rest_num = apinfo->rest_arg && (NODE_NAMED_REST_P(apinfo->rest_arg) ||
- (!NODE_NAMED_REST_P(apinfo->rest_arg) && post_args_num > 0));
+ const int use_rest_num = RNODE_ARYPTN(node)->rest_arg && (NODE_NAMED_REST_P(RNODE_ARYPTN(node)->rest_arg) ||
+ (!NODE_NAMED_REST_P(RNODE_ARYPTN(node)->rest_arg) && post_args_num > 0));
LABEL *match_failed, *type_error, *deconstruct, *deconstructed;
int i;
@@ -6362,10 +6628,10 @@ iseq_compile_pattern_each(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *c
ADD_INSN(ret, line_node, dup);
ADD_SEND(ret, line_node, idLength, INT2FIX(0));
ADD_INSN1(ret, line_node, putobject, INT2FIX(min_argc));
- ADD_SEND(ret, line_node, apinfo->rest_arg ? idGE : idEq, INT2FIX(1)); // (1)
+ ADD_SEND(ret, line_node, RNODE_ARYPTN(node)->rest_arg ? idGE : idEq, INT2FIX(1)); // (1)
if (in_single_pattern) {
CHECK(iseq_compile_pattern_set_length_errmsg(iseq, ret, node,
- apinfo->rest_arg ? rb_fstring_lit("%p length mismatch (given %p, expected %p+)") :
+ RNODE_ARYPTN(node)->rest_arg ? rb_fstring_lit("%p length mismatch (given %p, expected %p+)") :
rb_fstring_lit("%p length mismatch (given %p, expected %p)"),
INT2FIX(min_argc), base_index + 1 /* (1) */));
}
@@ -6375,12 +6641,12 @@ iseq_compile_pattern_each(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *c
ADD_INSN(ret, line_node, dup);
ADD_INSN1(ret, line_node, putobject, INT2FIX(i));
ADD_SEND(ret, line_node, idAREF, INT2FIX(1)); // (2)
- CHECK(iseq_compile_pattern_match(iseq, ret, args->nd_head, match_failed, in_single_pattern, in_alt_pattern, base_index + 1 /* (2) */, false));
- args = args->nd_next;
+ CHECK(iseq_compile_pattern_match(iseq, ret, RNODE_LIST(args)->nd_head, match_failed, in_single_pattern, in_alt_pattern, base_index + 1 /* (2) */, false));
+ args = RNODE_LIST(args)->nd_next;
}
- if (apinfo->rest_arg) {
- if (NODE_NAMED_REST_P(apinfo->rest_arg)) {
+ if (RNODE_ARYPTN(node)->rest_arg) {
+ if (NODE_NAMED_REST_P(RNODE_ARYPTN(node)->rest_arg)) {
ADD_INSN(ret, line_node, dup);
ADD_INSN1(ret, line_node, putobject, INT2FIX(pre_args_num));
ADD_INSN1(ret, line_node, topn, INT2FIX(1));
@@ -6390,7 +6656,7 @@ iseq_compile_pattern_each(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *c
ADD_INSN1(ret, line_node, setn, INT2FIX(4));
ADD_SEND(ret, line_node, idAREF, INT2FIX(2)); // (3)
- CHECK(iseq_compile_pattern_match(iseq, ret, apinfo->rest_arg, match_failed, in_single_pattern, in_alt_pattern, base_index + 1 /* (3) */, false));
+ CHECK(iseq_compile_pattern_match(iseq, ret, RNODE_ARYPTN(node)->rest_arg, match_failed, in_single_pattern, in_alt_pattern, base_index + 1 /* (3) */, false));
}
else {
if (post_args_num > 0) {
@@ -6404,7 +6670,7 @@ iseq_compile_pattern_each(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *c
}
}
- args = apinfo->post_args;
+ args = RNODE_ARYPTN(node)->post_args;
for (i = 0; i < post_args_num; i++) {
ADD_INSN(ret, line_node, dup);
@@ -6413,8 +6679,8 @@ iseq_compile_pattern_each(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *c
ADD_SEND(ret, line_node, idPLUS, INT2FIX(1));
ADD_SEND(ret, line_node, idAREF, INT2FIX(1)); // (4)
- CHECK(iseq_compile_pattern_match(iseq, ret, args->nd_head, match_failed, in_single_pattern, in_alt_pattern, base_index + 1 /* (4) */, false));
- args = args->nd_next;
+ CHECK(iseq_compile_pattern_match(iseq, ret, RNODE_LIST(args)->nd_head, match_failed, in_single_pattern, in_alt_pattern, base_index + 1 /* (4) */, false));
+ args = RNODE_LIST(args)->nd_next;
}
ADD_INSN(ret, line_node, pop);
@@ -6492,9 +6758,8 @@ iseq_compile_pattern_each(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *c
* match_failed:
* goto unmatched
*/
- struct rb_fnd_pattern_info *fpinfo = node->nd_fpinfo;
- const NODE *args = fpinfo->args;
- const int args_num = fpinfo->args ? rb_long2int(fpinfo->args->nd_alen) : 0;
+ const NODE *args = RNODE_FNDPTN(node)->args;
+ const int args_num = RNODE_FNDPTN(node)->args ? rb_long2int(RNODE_LIST(RNODE_FNDPTN(node)->args)->as.nd_alen) : 0;
LABEL *match_failed, *type_error, *deconstruct, *deconstructed;
match_failed = NEW_LABEL(line);
@@ -6547,25 +6812,25 @@ iseq_compile_pattern_each(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *c
}
ADD_SEND(ret, line_node, idAREF, INT2FIX(1)); // (5)
- CHECK(iseq_compile_pattern_match(iseq, ret, args->nd_head, next_loop, in_single_pattern, in_alt_pattern, base_index + 4 /* (2), (3), (4), (5) */, false));
- args = args->nd_next;
+ CHECK(iseq_compile_pattern_match(iseq, ret, RNODE_LIST(args)->nd_head, next_loop, in_single_pattern, in_alt_pattern, base_index + 4 /* (2), (3), (4), (5) */, false));
+ args = RNODE_LIST(args)->nd_next;
}
- if (NODE_NAMED_REST_P(fpinfo->pre_rest_arg)) {
+ if (NODE_NAMED_REST_P(RNODE_FNDPTN(node)->pre_rest_arg)) {
ADD_INSN1(ret, line_node, topn, INT2FIX(3));
ADD_INSN1(ret, line_node, putobject, INT2FIX(0));
ADD_INSN1(ret, line_node, topn, INT2FIX(2));
ADD_SEND(ret, line_node, idAREF, INT2FIX(2)); // (6)
- CHECK(iseq_compile_pattern_match(iseq, ret, fpinfo->pre_rest_arg, find_failed, in_single_pattern, in_alt_pattern, base_index + 4 /* (2), (3), (4), (6) */, false));
+ CHECK(iseq_compile_pattern_match(iseq, ret, RNODE_FNDPTN(node)->pre_rest_arg, find_failed, in_single_pattern, in_alt_pattern, base_index + 4 /* (2), (3), (4), (6) */, false));
}
- if (NODE_NAMED_REST_P(fpinfo->post_rest_arg)) {
+ if (NODE_NAMED_REST_P(RNODE_FNDPTN(node)->post_rest_arg)) {
ADD_INSN1(ret, line_node, topn, INT2FIX(3));
ADD_INSN1(ret, line_node, topn, INT2FIX(1));
ADD_INSN1(ret, line_node, putobject, INT2FIX(args_num));
ADD_SEND(ret, line_node, idPLUS, INT2FIX(1));
ADD_INSN1(ret, line_node, topn, INT2FIX(3));
ADD_SEND(ret, line_node, idAREF, INT2FIX(2)); // (7)
- CHECK(iseq_compile_pattern_match(iseq, ret, fpinfo->post_rest_arg, find_failed, in_single_pattern, in_alt_pattern, base_index + 4 /* (2), (3),(4), (7) */, false));
+ CHECK(iseq_compile_pattern_match(iseq, ret, RNODE_FNDPTN(node)->post_rest_arg, find_failed, in_single_pattern, in_alt_pattern, base_index + 4 /* (2), (3),(4), (7) */, false));
}
ADD_INSNL(ret, line_node, jump, find_succeeded);
@@ -6679,12 +6944,12 @@ iseq_compile_pattern_each(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *c
match_failed = NEW_LABEL(line);
type_error = NEW_LABEL(line);
- if (node->nd_pkwargs && !node->nd_pkwrestarg) {
- const NODE *kw_args = node->nd_pkwargs->nd_head;
- keys = rb_ary_new_capa(kw_args ? kw_args->nd_alen/2 : 0);
+ if (RNODE_HSHPTN(node)->nd_pkwargs && !RNODE_HSHPTN(node)->nd_pkwrestarg) {
+ const NODE *kw_args = RNODE_HASH(RNODE_HSHPTN(node)->nd_pkwargs)->nd_head;
+ keys = rb_ary_new_capa(kw_args ? RNODE_LIST(kw_args)->as.nd_alen/2 : 0);
while (kw_args) {
- rb_ary_push(keys, kw_args->nd_head->nd_lit);
- kw_args = kw_args->nd_next->nd_next;
+ rb_ary_push(keys, RNODE_LIT(RNODE_LIST(kw_args)->nd_head)->nd_lit);
+ kw_args = RNODE_LIST(RNODE_LIST(kw_args)->nd_next)->nd_next;
}
}
@@ -6711,28 +6976,28 @@ iseq_compile_pattern_each(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *c
ADD_INSN1(ret, line_node, checktype, INT2FIX(T_HASH));
ADD_INSNL(ret, line_node, branchunless, type_error);
- if (node->nd_pkwrestarg) {
+ if (RNODE_HSHPTN(node)->nd_pkwrestarg) {
ADD_SEND(ret, line_node, rb_intern("dup"), INT2FIX(0));
}
- if (node->nd_pkwargs) {
+ if (RNODE_HSHPTN(node)->nd_pkwargs) {
int i;
int keys_num;
const NODE *args;
- args = node->nd_pkwargs->nd_head;
+ args = RNODE_HASH(RNODE_HSHPTN(node)->nd_pkwargs)->nd_head;
if (args) {
DECL_ANCHOR(match_values);
INIT_ANCHOR(match_values);
- keys_num = rb_long2int(args->nd_alen) / 2;
+ keys_num = rb_long2int(RNODE_LIST(args)->as.nd_alen) / 2;
for (i = 0; i < keys_num; i++) {
- NODE *key_node = args->nd_head;
- NODE *value_node = args->nd_next->nd_head;
+ NODE *key_node = RNODE_LIST(args)->nd_head;
+ NODE *value_node = RNODE_LIST(RNODE_LIST(args)->nd_next)->nd_head;
VALUE key;
if (!nd_type_p(key_node, NODE_LIT)) {
UNKNOWN_NODE("NODE_IN", key_node, COMPILE_NG);
}
- key = key_node->nd_lit;
+ key = RNODE_LIT(key_node)->nd_lit;
ADD_INSN(ret, line_node, dup);
ADD_INSN1(ret, line_node, putobject, key);
@@ -6761,9 +7026,9 @@ iseq_compile_pattern_each(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *c
ADD_INSN(match_values, line_node, dup);
ADD_INSN1(match_values, line_node, putobject, key);
- ADD_SEND(match_values, line_node, node->nd_pkwrestarg ? rb_intern("delete") : idAREF, INT2FIX(1)); // (8)
+ ADD_SEND(match_values, line_node, RNODE_HSHPTN(node)->nd_pkwrestarg ? rb_intern("delete") : idAREF, INT2FIX(1)); // (8)
CHECK(iseq_compile_pattern_match(iseq, match_values, value_node, match_failed, in_single_pattern, in_alt_pattern, base_index + 1 /* (8) */, false));
- args = args->nd_next->nd_next;
+ args = RNODE_LIST(RNODE_LIST(args)->nd_next)->nd_next;
}
ADD_SEQ(ret, match_values);
}
@@ -6777,8 +7042,8 @@ iseq_compile_pattern_each(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *c
ADD_INSNL(ret, line_node, branchunless, match_failed);
}
- if (node->nd_pkwrestarg) {
- if (node->nd_pkwrestarg == NODE_SPECIAL_NO_REST_KEYWORD) {
+ if (RNODE_HSHPTN(node)->nd_pkwrestarg) {
+ if (RNODE_HSHPTN(node)->nd_pkwrestarg == NODE_SPECIAL_NO_REST_KEYWORD) {
ADD_INSN(ret, line_node, dup);
ADD_SEND(ret, line_node, idEmptyP, INT2FIX(0)); // (10)
if (in_single_pattern) {
@@ -6788,7 +7053,7 @@ iseq_compile_pattern_each(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *c
}
else {
ADD_INSN(ret, line_node, dup); // (11)
- CHECK(iseq_compile_pattern_match(iseq, ret, node->nd_pkwrestarg, match_failed, in_single_pattern, in_alt_pattern, base_index + 1 /* (11) */, false));
+ CHECK(iseq_compile_pattern_match(iseq, ret, RNODE_HSHPTN(node)->nd_pkwrestarg, match_failed, in_single_pattern, in_alt_pattern, base_index + 1 /* (11) */, false));
}
}
@@ -6845,7 +7110,7 @@ iseq_compile_pattern_each(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *c
break;
case NODE_LASGN: {
struct rb_iseq_constant_body *const body = ISEQ_BODY(iseq);
- ID id = node->nd_vid;
+ ID id = RNODE_LASGN(node)->nd_vid;
int idx = ISEQ_BODY(body->local_iseq)->local_table_size - get_local_var_idx(iseq, id);
if (in_alt_pattern) {
@@ -6863,7 +7128,7 @@ iseq_compile_pattern_each(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *c
}
case NODE_DASGN: {
int idx, lv, ls;
- ID id = node->nd_vid;
+ ID id = RNODE_DASGN(node)->nd_vid;
idx = get_dyna_var_idx(iseq, id, &lv, &ls);
@@ -6889,8 +7154,8 @@ iseq_compile_pattern_each(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *c
case NODE_UNLESS: {
LABEL *match_failed;
match_failed = unmatched;
- CHECK(iseq_compile_pattern_match(iseq, ret, node->nd_body, unmatched, in_single_pattern, in_alt_pattern, base_index, use_deconstructed_cache));
- CHECK(COMPILE(ret, "case in if", node->nd_cond));
+ CHECK(iseq_compile_pattern_match(iseq, ret, RNODE_IF(node)->nd_body, unmatched, in_single_pattern, in_alt_pattern, base_index, use_deconstructed_cache));
+ CHECK(COMPILE(ret, "case in if", RNODE_IF(node)->nd_cond));
if (in_single_pattern) {
LABEL *match_succeeded;
match_succeeded = NEW_LABEL(line);
@@ -6927,15 +7192,15 @@ iseq_compile_pattern_each(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *c
LABEL *match_failed;
match_failed = NEW_LABEL(line);
- n = node->nd_head;
- if (! (nd_type_p(n, NODE_LIST) && n->nd_alen == 2)) {
+ n = RNODE_HASH(node)->nd_head;
+ if (! (nd_type_p(n, NODE_LIST) && RNODE_LIST(n)->as.nd_alen == 2)) {
COMPILE_ERROR(ERROR_ARGS "unexpected node");
return COMPILE_NG;
}
ADD_INSN(ret, line_node, dup); // (1)
- CHECK(iseq_compile_pattern_match(iseq, ret, n->nd_head, match_failed, in_single_pattern, in_alt_pattern, base_index + 1 /* (1) */, use_deconstructed_cache));
- CHECK(iseq_compile_pattern_each(iseq, ret, n->nd_next->nd_head, matched, match_failed, in_single_pattern, in_alt_pattern, base_index, false));
+ CHECK(iseq_compile_pattern_match(iseq, ret, RNODE_LIST(n)->nd_head, match_failed, in_single_pattern, in_alt_pattern, base_index + 1 /* (1) */, use_deconstructed_cache));
+ CHECK(iseq_compile_pattern_each(iseq, ret, RNODE_LIST(RNODE_LIST(n)->nd_next)->nd_head, matched, match_failed, in_single_pattern, in_alt_pattern, base_index, false));
ADD_INSN(ret, line_node, putnil);
ADD_LABEL(ret, match_failed);
@@ -6949,13 +7214,13 @@ iseq_compile_pattern_each(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *c
fin = NEW_LABEL(line);
ADD_INSN(ret, line_node, dup); // (1)
- CHECK(iseq_compile_pattern_each(iseq, ret, node->nd_1st, match_succeeded, fin, in_single_pattern, true, base_index + 1 /* (1) */, use_deconstructed_cache));
+ CHECK(iseq_compile_pattern_each(iseq, ret, RNODE_OR(node)->nd_1st, match_succeeded, fin, in_single_pattern, true, base_index + 1 /* (1) */, use_deconstructed_cache));
ADD_LABEL(ret, match_succeeded);
ADD_INSN(ret, line_node, pop);
ADD_INSNL(ret, line_node, jump, matched);
ADD_INSN(ret, line_node, putnil);
ADD_LABEL(ret, fin);
- CHECK(iseq_compile_pattern_each(iseq, ret, node->nd_2nd, matched, unmatched, in_single_pattern, true, base_index, use_deconstructed_cache));
+ CHECK(iseq_compile_pattern_each(iseq, ret, RNODE_OR(node)->nd_2nd, matched, unmatched, in_single_pattern, true, base_index, use_deconstructed_cache));
break;
}
default:
@@ -6978,9 +7243,9 @@ iseq_compile_pattern_constant(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NOD
{
const NODE *line_node = node;
- if (node->nd_pconst) {
+ if (RNODE_ARYPTN(node)->nd_pconst) {
ADD_INSN(ret, line_node, dup); // (1)
- CHECK(COMPILE(ret, "constant", node->nd_pconst)); // (2)
+ CHECK(COMPILE(ret, "constant", RNODE_ARYPTN(node)->nd_pconst)); // (2)
if (in_single_pattern) {
ADD_INSN1(ret, line_node, dupn, INT2FIX(2));
}
@@ -7183,12 +7448,12 @@ compile_case3(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const orig_no
branches = decl_branch_base(iseq, node, "case");
- node = node->nd_body;
+ node = RNODE_CASE3(node)->nd_body;
EXPECT_NODE("NODE_CASE3", node, NODE_IN, COMPILE_NG);
type = nd_type(node);
line = nd_line(node);
line_node = node;
- single_pattern = !node->nd_next;
+ single_pattern = !RNODE_IN(node)->nd_next;
endlabel = NEW_LABEL(line);
elselabel = NEW_LABEL(line);
@@ -7202,7 +7467,7 @@ compile_case3(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const orig_no
}
ADD_INSN(head, line_node, putnil); /* allocate stack for cached #deconstruct value */
- CHECK(COMPILE(head, "case base", orig_node->nd_head));
+ CHECK(COMPILE(head, "case base", RNODE_CASE3(orig_node)->nd_head));
ADD_SEQ(ret, head); /* case VAL */
@@ -7218,14 +7483,14 @@ compile_case3(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const orig_no
add_trace_branch_coverage(
iseq,
body_seq,
- node->nd_body ? node->nd_body : node,
+ RNODE_IN(node)->nd_body ? RNODE_IN(node)->nd_body : node,
branch_id++,
"in",
branches);
- CHECK(COMPILE_(body_seq, "in body", node->nd_body, popped));
+ CHECK(COMPILE_(body_seq, "in body", RNODE_IN(node)->nd_body, popped));
ADD_INSNL(body_seq, line_node, jump, endlabel);
- pattern = node->nd_head;
+ pattern = RNODE_IN(node)->nd_head;
if (pattern) {
int pat_line = nd_line(pattern);
LABEL *next_pat = NEW_LABEL(pat_line);
@@ -7240,7 +7505,7 @@ compile_case3(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const orig_no
return COMPILE_NG;
}
- node = node->nd_next;
+ node = RNODE_IN(node)->nd_next;
if (!node) {
break;
}
@@ -7282,6 +7547,7 @@ compile_case3(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const orig_no
fin = NEW_LABEL(line);
kw_arg = rb_xmalloc_mul_add(2, sizeof(VALUE), sizeof(struct rb_callinfo_kwarg));
+ kw_arg->references = 0;
kw_arg->keyword_len = 2;
kw_arg->keywords[0] = ID2SYM(rb_intern("matchee"));
kw_arg->keywords[1] = ID2SYM(rb_intern("key"));
@@ -7365,7 +7631,7 @@ compile_loop(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const node, in
ISEQ_COMPILE_DATA(iseq)->loopval_popped = 0;
push_ensure_entry(iseq, &enl, NULL, NULL);
- if (node->nd_state == 1) {
+ if (RNODE_WHILE(node)->nd_state == 1) {
ADD_INSNL(ret, line_node, jump, next_label);
}
else {
@@ -7384,27 +7650,27 @@ compile_loop(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const node, in
add_trace_branch_coverage(
iseq,
ret,
- node->nd_body ? node->nd_body : node,
+ RNODE_WHILE(node)->nd_body ? RNODE_WHILE(node)->nd_body : node,
0,
"body",
branches);
- CHECK(COMPILE_POPPED(ret, "while body", node->nd_body));
+ CHECK(COMPILE_POPPED(ret, "while body", RNODE_WHILE(node)->nd_body));
ADD_LABEL(ret, next_label); /* next */
if (type == NODE_WHILE) {
- compile_branch_condition(iseq, ret, node->nd_cond,
+ compile_branch_condition(iseq, ret, RNODE_WHILE(node)->nd_cond,
redo_label, end_label);
}
else {
/* until */
- compile_branch_condition(iseq, ret, node->nd_cond,
+ compile_branch_condition(iseq, ret, RNODE_WHILE(node)->nd_cond,
end_label, redo_label);
}
ADD_LABEL(ret, end_label);
ADD_ADJUST_RESTORE(ret, adjust_label);
- if (UNDEF_P(node->nd_state)) {
+ if (UNDEF_P(RNODE_WHILE(node)->nd_state)) {
/* ADD_INSN(ret, line_node, putundef); */
COMPILE_ERROR(ERROR_ARGS "unsupported: putundef");
return COMPILE_NG;
@@ -7446,18 +7712,18 @@ compile_iter(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const node, in
ADD_LABEL(ret, retry_label);
if (nd_type_p(node, NODE_FOR)) {
- CHECK(COMPILE(ret, "iter caller (for)", node->nd_iter));
+ CHECK(COMPILE(ret, "iter caller (for)", RNODE_FOR(node)->nd_iter));
ISEQ_COMPILE_DATA(iseq)->current_block = child_iseq =
- NEW_CHILD_ISEQ(node->nd_body, make_name_for_block(iseq),
+ NEW_CHILD_ISEQ(RNODE_FOR(node)->nd_body, make_name_for_block(iseq),
ISEQ_TYPE_BLOCK, line);
ADD_SEND_WITH_BLOCK(ret, line_node, idEach, INT2FIX(0), child_iseq);
}
else {
ISEQ_COMPILE_DATA(iseq)->current_block = child_iseq =
- NEW_CHILD_ISEQ(node->nd_body, make_name_for_block(iseq),
+ NEW_CHILD_ISEQ(RNODE_ITER(node)->nd_body, make_name_for_block(iseq),
ISEQ_TYPE_BLOCK, line);
- CHECK(COMPILE(ret, "iter caller", node->nd_iter));
+ CHECK(COMPILE(ret, "iter caller", RNODE_ITER(node)->nd_iter));
}
{
@@ -7501,7 +7767,7 @@ compile_for_masgn(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const nod
* (args.length == 1 && Array.try_convert(args[0])) || args
*/
const NODE *line_node = node;
- const NODE *var = node->nd_var;
+ const NODE *var = RNODE_FOR_MASGN(node)->nd_var;
LABEL *not_single = NEW_LABEL(nd_line(var));
LABEL *not_ary = NEW_LABEL(nd_line(var));
CHECK(COMPILE(ret, "for var", var));
@@ -7536,7 +7802,7 @@ compile_break(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const node, i
LABEL *splabel = NEW_LABEL(0);
ADD_LABEL(ret, splabel);
ADD_ADJUST(ret, line_node, ISEQ_COMPILE_DATA(iseq)->redo_label);
- CHECK(COMPILE_(ret, "break val (while/until)", node->nd_stts,
+ CHECK(COMPILE_(ret, "break val (while/until)", RNODE_BREAK(node)->nd_stts,
ISEQ_COMPILE_DATA(iseq)->loopval_popped));
add_ensure_iseq(ret, iseq, 0);
ADD_INSNL(ret, line_node, jump, ISEQ_COMPILE_DATA(iseq)->end_label);
@@ -7571,7 +7837,7 @@ compile_break(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const node, i
}
/* escape from block */
- CHECK(COMPILE(ret, "break val (block)", node->nd_stts));
+ CHECK(COMPILE(ret, "break val (block)", RNODE_BREAK(node)->nd_stts));
ADD_INSN1(ret, line_node, throw, INT2FIX(throw_flag | TAG_BREAK));
if (popped) {
ADD_INSN(ret, line_node, pop);
@@ -7594,7 +7860,7 @@ compile_next(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const node, in
LABEL *splabel = NEW_LABEL(0);
debugs("next in while loop\n");
ADD_LABEL(ret, splabel);
- CHECK(COMPILE(ret, "next val/valid syntax?", node->nd_stts));
+ CHECK(COMPILE(ret, "next val/valid syntax?", RNODE_NEXT(node)->nd_stts));
add_ensure_iseq(ret, iseq, 0);
ADD_ADJUST(ret, line_node, ISEQ_COMPILE_DATA(iseq)->redo_label);
ADD_INSNL(ret, line_node, jump, ISEQ_COMPILE_DATA(iseq)->start_label);
@@ -7608,7 +7874,7 @@ compile_next(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const node, in
debugs("next in block\n");
ADD_LABEL(ret, splabel);
ADD_ADJUST(ret, line_node, ISEQ_COMPILE_DATA(iseq)->start_label);
- CHECK(COMPILE(ret, "next val", node->nd_stts));
+ CHECK(COMPILE(ret, "next val", RNODE_NEXT(node)->nd_stts));
add_ensure_iseq(ret, iseq, 0);
ADD_INSNL(ret, line_node, jump, ISEQ_COMPILE_DATA(iseq)->end_label);
ADD_ADJUST_RESTORE(ret, splabel);
@@ -7643,7 +7909,7 @@ compile_next(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const node, in
ip = ISEQ_BODY(ip)->parent_iseq;
}
if (ip != 0) {
- CHECK(COMPILE(ret, "next val", node->nd_stts));
+ CHECK(COMPILE(ret, "next val", RNODE_NEXT(node)->nd_stts));
ADD_INSN1(ret, line_node, throw, INT2FIX(throw_flag | TAG_NEXT));
if (popped) {
@@ -7755,7 +8021,7 @@ compile_rescue(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const node,
LABEL *lstart = NEW_LABEL(line);
LABEL *lend = NEW_LABEL(line);
LABEL *lcont = NEW_LABEL(line);
- const rb_iseq_t *rescue = NEW_CHILD_ISEQ(node->nd_resq,
+ const rb_iseq_t *rescue = NEW_CHILD_ISEQ(RNODE_RESCUE(node)->nd_resq,
rb_str_concat(rb_str_new2("rescue in "),
ISEQ_BODY(iseq)->location.label),
ISEQ_TYPE_RESCUE, line);
@@ -7767,14 +8033,14 @@ compile_rescue(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const node,
bool prev_in_rescue = ISEQ_COMPILE_DATA(iseq)->in_rescue;
ISEQ_COMPILE_DATA(iseq)->in_rescue = true;
{
- CHECK(COMPILE(ret, "rescue head", node->nd_head));
+ CHECK(COMPILE(ret, "rescue head", RNODE_RESCUE(node)->nd_head));
}
ISEQ_COMPILE_DATA(iseq)->in_rescue = prev_in_rescue;
ADD_LABEL(ret, lend);
- if (node->nd_else) {
+ if (RNODE_RESCUE(node)->nd_else) {
ADD_INSN(ret, line_node, pop);
- CHECK(COMPILE(ret, "rescue else", node->nd_else));
+ CHECK(COMPILE(ret, "rescue else", RNODE_RESCUE(node)->nd_else));
}
ADD_INSN(ret, line_node, nop);
ADD_LABEL(ret, lcont);
@@ -7802,16 +8068,16 @@ compile_resbody(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const node,
label_miss = NEW_LABEL(line);
label_hit = NEW_LABEL(line);
- narg = resq->nd_args;
+ narg = RNODE_RESBODY(resq)->nd_args;
if (narg) {
switch (nd_type(narg)) {
case NODE_LIST:
while (narg) {
ADD_GETLOCAL(ret, line_node, LVAR_ERRINFO, 0);
- CHECK(COMPILE(ret, "rescue arg", narg->nd_head));
+ CHECK(COMPILE(ret, "rescue arg", RNODE_LIST(narg)->nd_head));
ADD_INSN1(ret, line_node, checkmatch, INT2FIX(VM_CHECKMATCH_TYPE_RESCUE));
ADD_INSNL(ret, line_node, branchif, label_hit);
- narg = narg->nd_next;
+ narg = RNODE_LIST(narg)->nd_next;
}
break;
case NODE_SPLAT:
@@ -7834,13 +8100,24 @@ compile_resbody(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const node,
}
ADD_INSNL(ret, line_node, jump, label_miss);
ADD_LABEL(ret, label_hit);
- CHECK(COMPILE(ret, "resbody body", resq->nd_body));
+ ADD_TRACE(ret, RUBY_EVENT_RESCUE);
+
+ if (nd_type(RNODE_RESBODY(resq)->nd_body) == NODE_BEGIN && RNODE_BEGIN(RNODE_RESBODY(resq)->nd_body)->nd_body == NULL) {
+ // empty body
+ int lineno = nd_line(RNODE_RESBODY(resq)->nd_body);
+ NODE dummy_line_node = generate_dummy_line_node(lineno, -1);
+ ADD_INSN(ret, &dummy_line_node, putnil);
+ }
+ else {
+ CHECK(COMPILE(ret, "resbody body", RNODE_RESBODY(resq)->nd_body));
+ }
+
if (ISEQ_COMPILE_DATA(iseq)->option->tailcall_optimization) {
ADD_INSN(ret, line_node, nop);
}
ADD_INSN(ret, line_node, leave);
ADD_LABEL(ret, label_miss);
- resq = resq->nd_head;
+ resq = RNODE_RESBODY(resq)->nd_head;
}
return COMPILE_OK;
}
@@ -7851,7 +8128,7 @@ compile_ensure(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const node,
const int line = nd_line(node);
const NODE *line_node = node;
DECL_ANCHOR(ensr);
- const rb_iseq_t *ensure = NEW_CHILD_ISEQ(node->nd_ensr,
+ const rb_iseq_t *ensure = NEW_CHILD_ISEQ(RNODE_ENSURE(node)->nd_ensr,
rb_str_concat(rb_str_new2 ("ensure in "), ISEQ_BODY(iseq)->location.label),
ISEQ_TYPE_ENSURE, line);
LABEL *lstart = NEW_LABEL(line);
@@ -7864,17 +8141,17 @@ compile_ensure(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const node,
struct ensure_range *erange;
INIT_ANCHOR(ensr);
- CHECK(COMPILE_POPPED(ensr, "ensure ensr", node->nd_ensr));
+ CHECK(COMPILE_POPPED(ensr, "ensure ensr", RNODE_ENSURE(node)->nd_ensr));
last = ensr->last;
last_leave = last && IS_INSN(last) && IS_INSN_ID(last, leave);
er.begin = lstart;
er.end = lend;
er.next = 0;
- push_ensure_entry(iseq, &enl, &er, node->nd_ensr);
+ push_ensure_entry(iseq, &enl, &er, RNODE_ENSURE(node)->nd_ensr);
ADD_LABEL(ret, lstart);
- CHECK(COMPILE_(ret, "ensure head", node->nd_head, (popped | last_leave)));
+ CHECK(COMPILE_(ret, "ensure head", RNODE_ENSURE(node)->nd_head, (popped | last_leave)));
ADD_LABEL(ret, lend);
ADD_SEQ(ret, ensr);
if (!popped && last_leave) ADD_INSN(ret, line_node, putnil);
@@ -7903,7 +8180,7 @@ compile_return(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const node,
enum rb_iseq_type type = ISEQ_BODY(iseq)->type;
const rb_iseq_t *is = iseq;
enum rb_iseq_type t = type;
- const NODE *retval = node->nd_stts;
+ const NODE *retval = RNODE_RETURN(node)->nd_stts;
LABEL *splabel = 0;
while (t == ISEQ_TYPE_RESCUE || t == ISEQ_TYPE_ENSURE) {
@@ -8012,13 +8289,13 @@ compile_call_precheck_freeze(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE
/* optimization shortcut
* "literal".freeze -> opt_str_freeze("literal")
*/
- if (node->nd_recv && nd_type_p(node->nd_recv, NODE_STR) &&
- (node->nd_mid == idFreeze || node->nd_mid == idUMinus) &&
- node->nd_args == NULL &&
+ if (get_nd_recv(node) && nd_type_p(get_nd_recv(node), NODE_STR) &&
+ (get_node_call_nd_mid(node) == idFreeze || get_node_call_nd_mid(node) == idUMinus) &&
+ get_nd_args(node) == NULL &&
ISEQ_COMPILE_DATA(iseq)->current_block == NULL &&
ISEQ_COMPILE_DATA(iseq)->option->specialized_instruction) {
- VALUE str = rb_fstring(node->nd_recv->nd_lit);
- if (node->nd_mid == idUMinus) {
+ VALUE str = rb_fstring(RNODE_STR(get_nd_recv(node))->nd_lit);
+ if (get_node_call_nd_mid(node) == idUMinus) {
ADD_INSN2(ret, line_node, opt_str_uminus, str,
new_callinfo(iseq, idUMinus, 0, 0, NULL, FALSE));
}
@@ -8035,14 +8312,14 @@ compile_call_precheck_freeze(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE
/* optimization shortcut
* obj["literal"] -> opt_aref_with(obj, "literal")
*/
- if (node->nd_mid == idAREF && !private_recv_p(node) && node->nd_args &&
- nd_type_p(node->nd_args, NODE_LIST) && node->nd_args->nd_alen == 1 &&
- nd_type_p(node->nd_args->nd_head, NODE_STR) &&
+ if (get_node_call_nd_mid(node) == idAREF && !private_recv_p(node) && get_nd_args(node) &&
+ nd_type_p(get_nd_args(node), NODE_LIST) && RNODE_LIST(get_nd_args(node))->as.nd_alen == 1 &&
+ nd_type_p(RNODE_LIST(get_nd_args(node))->nd_head, NODE_STR) &&
ISEQ_COMPILE_DATA(iseq)->current_block == NULL &&
!ISEQ_COMPILE_DATA(iseq)->option->frozen_string_literal &&
ISEQ_COMPILE_DATA(iseq)->option->specialized_instruction) {
- VALUE str = rb_fstring(node->nd_args->nd_head->nd_lit);
- CHECK(COMPILE(ret, "recv", node->nd_recv));
+ VALUE str = rb_fstring(RNODE_STR(RNODE_LIST(get_nd_args(node))->nd_head)->nd_lit);
+ CHECK(COMPILE(ret, "recv", get_nd_recv(node)));
ADD_INSN2(ret, line_node, opt_aref_with, str,
new_callinfo(iseq, idAREF, 1, 0, NULL, FALSE));
RB_OBJ_WRITTEN(iseq, Qundef, str);
@@ -8085,12 +8362,12 @@ iseq_builtin_function_name(const enum node_type type, const NODE *recv, ID mid)
if (recv) {
switch (nd_type(recv)) {
case NODE_VCALL:
- if (recv->nd_mid == rb_intern("__builtin")) {
+ if (RNODE_VCALL(recv)->nd_mid == rb_intern("__builtin")) {
return name;
}
break;
case NODE_CONST:
- if (recv->nd_vid == rb_intern("Primitive")) {
+ if (RNODE_CONST(recv)->nd_vid == rb_intern("Primitive")) {
return name;
}
break;
@@ -8171,16 +8448,60 @@ delegate_call_p(const rb_iseq_t *iseq, unsigned int argc, const LINK_ANCHOR *arg
}
}
+// Compile Primitive.attr! :leaf, ...
+static int
+compile_builtin_attr(rb_iseq_t *iseq, const NODE *node)
+{
+ VALUE symbol;
+ VALUE string;
+ if (!node) goto no_arg;
+ while (node) {
+ if (!nd_type_p(node, NODE_LIST)) goto bad_arg;
+ const NODE *next = RNODE_LIST(node)->nd_next;
+
+ node = RNODE_LIST(node)->nd_head;
+ if (!node) goto no_arg;
+ if (!nd_type_p(node, NODE_LIT)) goto bad_arg;
+
+ symbol = RNODE_LIT(node)->nd_lit;
+ if (!SYMBOL_P(symbol)) goto non_symbol_arg;
+
+ string = rb_sym_to_s(symbol);
+ if (strcmp(RSTRING_PTR(string), "leaf") == 0) {
+ ISEQ_BODY(iseq)->builtin_attrs |= BUILTIN_ATTR_LEAF;
+ }
+ else if (strcmp(RSTRING_PTR(string), "no_gc") == 0) {
+ ISEQ_BODY(iseq)->builtin_attrs |= BUILTIN_ATTR_NO_GC;
+ }
+ else {
+ goto unknown_arg;
+ }
+ node = next;
+ }
+ return COMPILE_OK;
+ no_arg:
+ COMPILE_ERROR(ERROR_ARGS "attr!: no argument");
+ return COMPILE_NG;
+ non_symbol_arg:
+ COMPILE_ERROR(ERROR_ARGS "non symbol argument to attr!: %s", rb_builtin_class_name(symbol));
+ return COMPILE_NG;
+ unknown_arg:
+ COMPILE_ERROR(ERROR_ARGS "unknown argument to attr!: %s", RSTRING_PTR(string));
+ return COMPILE_NG;
+ bad_arg:
+ UNKNOWN_NODE("attr!", node, COMPILE_NG);
+}
+
static int
compile_builtin_arg(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *node, const NODE *line_node, int popped)
{
if (!node) goto no_arg;
if (!nd_type_p(node, NODE_LIST)) goto bad_arg;
- if (node->nd_next) goto too_many_arg;
- node = node->nd_head;
+ if (RNODE_LIST(node)->nd_next) goto too_many_arg;
+ node = RNODE_LIST(node)->nd_head;
if (!node) goto no_arg;
if (!nd_type_p(node, NODE_LIT)) goto bad_arg;
- VALUE name = node->nd_lit;
+ VALUE name = RNODE_LIT(node)->nd_lit;
if (!SYMBOL_P(name)) goto non_symbol_arg;
if (!popped) {
compile_lvar(iseq, ret, line_node, SYM2ID(name));
@@ -8204,8 +8525,8 @@ static NODE *
mandatory_node(const rb_iseq_t *iseq, const NODE *cond_node)
{
const NODE *node = ISEQ_COMPILE_DATA(iseq)->root_node;
- if (nd_type(node) == NODE_IF && node->nd_cond == cond_node) {
- return node->nd_body;
+ if (nd_type(node) == NODE_IF && RNODE_IF(node)->nd_cond == cond_node) {
+ return RNODE_IF(node)->nd_body;
}
else {
rb_bug("mandatory_node: can't find mandatory node");
@@ -8219,8 +8540,9 @@ compile_builtin_mandatory_only_method(rb_iseq_t *iseq, const NODE *node, const N
struct rb_args_info args = {
.pre_args_num = ISEQ_BODY(iseq)->param.lead_num,
};
- NODE args_node;
- rb_node_init(&args_node, NODE_ARGS, 0, 0, (VALUE)&args);
+ rb_node_args_t args_node;
+ rb_node_init(RNODE(&args_node), NODE_ARGS);
+ args_node.nd_ainfo = args;
// local table without non-mandatory parameters
const int skip_local_size = ISEQ_BODY(iseq)->param.size - ISEQ_BODY(iseq)->param.lead_num;
@@ -8241,24 +8563,25 @@ compile_builtin_mandatory_only_method(rb_iseq_t *iseq, const NODE *node, const N
tbl->ids[i] = ISEQ_BODY(iseq)->local_table[i + skip_local_size];
}
- NODE scope_node;
- rb_node_init(&scope_node, NODE_SCOPE, (VALUE)tbl, (VALUE)mandatory_node(iseq, node), (VALUE)&args_node);
+ rb_node_scope_t scope_node;
+ rb_node_init(RNODE(&scope_node), NODE_SCOPE);
+ scope_node.nd_tbl = tbl;
+ scope_node.nd_body = mandatory_node(iseq, node);
+ scope_node.nd_args = &args_node;
rb_ast_body_t ast = {
- .root = &scope_node,
- .compile_option = 0,
+ .root = RNODE(&scope_node),
+ .frozen_string_literal = -1,
+ .coverage_enabled = -1,
.script_lines = ISEQ_BODY(iseq)->variable.script_lines,
};
- int prev_inline_index = GET_VM()->builtin_inline_index;
-
ISEQ_BODY(iseq)->mandatory_only_iseq =
rb_iseq_new_with_opt(&ast, rb_iseq_base_label(iseq),
rb_iseq_path(iseq), rb_iseq_realpath(iseq),
nd_line(line_node), NULL, 0,
ISEQ_TYPE_METHOD, ISEQ_COMPILE_DATA(iseq)->option);
- GET_VM()->builtin_inline_index = prev_inline_index;
ALLOCV_END(idtmp);
return COMPILE_OK;
}
@@ -8267,15 +8590,15 @@ static int
compile_builtin_function_call(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const node, const NODE *line_node, int popped,
const rb_iseq_t *parent_block, LINK_ANCHOR *args, const char *builtin_func)
{
- NODE *args_node = node->nd_args;
+ NODE *args_node = get_nd_args(node);
if (parent_block != NULL) {
- COMPILE_ERROR(iseq, nd_line(line_node), "should not call builtins here.");
+ COMPILE_ERROR(ERROR_ARGS_AT(line_node) "should not call builtins here.");
return COMPILE_NG;
}
else {
# define BUILTIN_INLINE_PREFIX "_bi"
- char inline_func[DECIMAL_SIZE_OF_BITS(sizeof(int) * CHAR_BIT) + sizeof(BUILTIN_INLINE_PREFIX)];
+ char inline_func[sizeof(BUILTIN_INLINE_PREFIX) + DECIMAL_SIZE_OF(int)];
bool cconst = false;
retry:;
const struct rb_builtin_function *bf = iseq_builtin_function_lookup(iseq, builtin_func);
@@ -8294,9 +8617,7 @@ compile_builtin_function_call(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NOD
return COMPILE_OK;
}
else if (strcmp("attr!", builtin_func) == 0) {
- // There's only "inline" attribute for now
- ISEQ_BODY(iseq)->builtin_inline_p = true;
- return COMPILE_OK;
+ return compile_builtin_attr(iseq, args_node);
}
else if (strcmp("arg!", builtin_func) == 0) {
return compile_builtin_arg(iseq, ret, args_node, line_node, popped);
@@ -8372,7 +8693,7 @@ compile_call(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const node, co
*/
DECL_ANCHOR(recv);
DECL_ANCHOR(args);
- ID mid = node->nd_mid;
+ ID mid = get_node_call_nd_mid(node);
VALUE argc;
unsigned int flag = 0;
struct rb_callinfo_kwarg *keywords = NULL;
@@ -8451,7 +8772,7 @@ compile_call(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const node, co
const char *builtin_func;
if (UNLIKELY(iseq_has_builtin_function_table(iseq)) &&
- (builtin_func = iseq_builtin_function_name(type, node->nd_recv, mid)) != NULL) {
+ (builtin_func = iseq_builtin_function_name(type, get_nd_recv(node), mid)) != NULL) {
return compile_builtin_function_call(iseq, ret, node, line_node, popped, parent_block, args, builtin_func);
}
@@ -8461,16 +8782,16 @@ compile_call(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const node, co
int idx, level;
if (mid == idCall &&
- nd_type_p(node->nd_recv, NODE_LVAR) &&
- iseq_block_param_id_p(iseq, node->nd_recv->nd_vid, &idx, &level)) {
- ADD_INSN2(recv, node->nd_recv, getblockparamproxy, INT2FIX(idx + VM_ENV_DATA_SIZE - 1), INT2FIX(level));
+ nd_type_p(get_nd_recv(node), NODE_LVAR) &&
+ iseq_block_param_id_p(iseq, RNODE_LVAR(get_nd_recv(node))->nd_vid, &idx, &level)) {
+ ADD_INSN2(recv, get_nd_recv(node), getblockparamproxy, INT2FIX(idx + VM_ENV_DATA_SIZE - 1), INT2FIX(level));
}
else if (private_recv_p(node)) {
ADD_INSN(recv, node, putself);
flag |= VM_CALL_FCALL;
}
else {
- CHECK(COMPILE(recv, "recv", node->nd_recv));
+ CHECK(COMPILE(recv, "recv", get_nd_recv(node)));
}
if (type == NODE_QCALL) {
@@ -8484,7 +8805,7 @@ compile_call(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const node, co
/* args */
if (type != NODE_VCALL) {
- argc = setup_args(iseq, args, node->nd_args, &flag, &keywords);
+ argc = setup_args(iseq, args, get_nd_args(node), &flag, &keywords);
CHECK(!NIL_P(argc));
}
else {
@@ -8505,6 +8826,9 @@ compile_call(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const node, co
flag |= VM_CALL_FCALL;
}
+ if ((flag & VM_CALL_ARGS_BLOCKARG) && (flag & VM_CALL_KW_SPLAT) && !(flag & VM_CALL_KW_SPLAT_MUT)) {
+ ADD_INSN(ret, line_node, splatkw);
+ }
ADD_SEND_R(ret, line_node, mid, argc, parent_block, INT2FIX(flag), keywords);
qcall_branch_end(iseq, ret, else_label, branches, node, line_node);
@@ -8521,8 +8845,10 @@ compile_op_asgn1(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const node
VALUE argc;
unsigned int flag = 0;
int asgnflag = 0;
- ID id = node->nd_mid;
+ ID id = RNODE_OP_ASGN1(node)->nd_mid;
int boff = 0;
+ int keyword_len = 0;
+ struct rb_callinfo_kwarg *keywords = NULL;
/*
* a[x] (op)= y
@@ -8550,9 +8876,9 @@ compile_op_asgn1(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const node
if (!popped) {
ADD_INSN(ret, node, putnil);
}
- asgnflag = COMPILE_RECV(ret, "NODE_OP_ASGN1 recv", node);
+ asgnflag = COMPILE_RECV(ret, "NODE_OP_ASGN1 recv", node, RNODE_OP_ASGN1(node)->nd_recv);
CHECK(asgnflag != -1);
- switch (nd_type(node->nd_args->nd_head)) {
+ switch (nd_type(RNODE_OP_ASGN1(node)->nd_index)) {
case NODE_ZLIST:
argc = INT2FIX(0);
break;
@@ -8560,12 +8886,28 @@ compile_op_asgn1(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const node
boff = 1;
/* fall through */
default:
- argc = setup_args(iseq, ret, node->nd_args->nd_head, &flag, NULL);
+ argc = setup_args(iseq, ret, RNODE_OP_ASGN1(node)->nd_index, &flag, &keywords);
+ if (flag & VM_CALL_KW_SPLAT) {
+ if (boff) {
+ ADD_INSN(ret, node, splatkw);
+ }
+ else {
+ /* Make sure to_hash is only called once and not twice */
+ ADD_INSN(ret, node, dup);
+ ADD_INSN(ret, node, splatkw);
+ ADD_INSN(ret, node, pop);
+ }
+ }
CHECK(!NIL_P(argc));
}
- ADD_INSN1(ret, node, dupn, FIXNUM_INC(argc, 1 + boff));
+ int dup_argn = FIX2INT(argc) + 1 + boff;
+ if (keywords) {
+ keyword_len = keywords->keyword_len;
+ dup_argn += keyword_len;
+ }
+ ADD_INSN1(ret, node, dupn, INT2FIX(dup_argn));
flag |= asgnflag;
- ADD_SEND_WITH_FLAG(ret, node, idAREF, argc, INT2FIX(flag));
+ ADD_SEND_R(ret, node, idAREF, argc, NULL, INT2FIX(flag & ~VM_CALL_KW_SPLAT_MUT), keywords);
if (id == idOROP || id == idANDOP) {
/* a[x] ||= y or a[x] &&= y
@@ -8588,64 +8930,116 @@ compile_op_asgn1(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const node
}
ADD_INSN(ret, node, pop);
- CHECK(COMPILE(ret, "NODE_OP_ASGN1 args->body: ", node->nd_args->nd_body));
+ CHECK(COMPILE(ret, "NODE_OP_ASGN1 nd_rvalue: ", RNODE_OP_ASGN1(node)->nd_rvalue));
if (!popped) {
- ADD_INSN1(ret, node, setn, FIXNUM_INC(argc, 2+boff));
+ ADD_INSN1(ret, node, setn, INT2FIX(dup_argn+1));
}
if (flag & VM_CALL_ARGS_SPLAT) {
- ADD_INSN1(ret, node, newarray, INT2FIX(1));
- if (boff > 0) {
- ADD_INSN1(ret, node, dupn, INT2FIX(3));
+ if (flag & VM_CALL_KW_SPLAT) {
+ ADD_INSN1(ret, node, topn, INT2FIX(2 + boff));
ADD_INSN(ret, node, swap);
+ ADD_INSN1(ret, node, newarray, INT2FIX(1));
+ ADD_INSN(ret, node, concatarray);
+ ADD_INSN1(ret, node, setn, INT2FIX(2 + boff));
ADD_INSN(ret, node, pop);
}
- ADD_INSN(ret, node, concatarray);
+ else {
+ ADD_INSN1(ret, node, newarray, INT2FIX(1));
+ if (boff > 0) {
+ ADD_INSN1(ret, node, dupn, INT2FIX(3));
+ ADD_INSN(ret, node, swap);
+ ADD_INSN(ret, node, pop);
+ }
+ ADD_INSN(ret, node, concatarray);
+ if (boff > 0) {
+ ADD_INSN1(ret, node, setn, INT2FIX(3));
+ ADD_INSN(ret, node, pop);
+ ADD_INSN(ret, node, pop);
+ }
+ }
+ ADD_SEND_R(ret, node, idASET, argc, NULL, INT2FIX(flag), keywords);
+ }
+ else if (flag & VM_CALL_KW_SPLAT) {
if (boff > 0) {
+ ADD_INSN1(ret, node, topn, INT2FIX(2));
+ ADD_INSN(ret, node, swap);
ADD_INSN1(ret, node, setn, INT2FIX(3));
ADD_INSN(ret, node, pop);
- ADD_INSN(ret, node, pop);
}
- ADD_SEND_WITH_FLAG(ret, node, idASET, argc, INT2FIX(flag));
+ ADD_INSN(ret, node, swap);
+ ADD_SEND_R(ret, node, idASET, FIXNUM_INC(argc, 1), NULL, INT2FIX(flag), keywords);
+ }
+ else if (keyword_len) {
+ ADD_INSN1(ret, node, opt_reverse, INT2FIX(keyword_len+boff+1));
+ ADD_INSN1(ret, node, opt_reverse, INT2FIX(keyword_len+boff+0));
+ ADD_SEND_R(ret, node, idASET, FIXNUM_INC(argc, 1), NULL, INT2FIX(flag), keywords);
}
else {
if (boff > 0)
ADD_INSN(ret, node, swap);
- ADD_SEND_WITH_FLAG(ret, node, idASET, FIXNUM_INC(argc, 1), INT2FIX(flag));
+ ADD_SEND_R(ret, node, idASET, FIXNUM_INC(argc, 1), NULL, INT2FIX(flag), keywords);
}
ADD_INSN(ret, node, pop);
ADD_INSNL(ret, node, jump, lfin);
ADD_LABEL(ret, label);
if (!popped) {
- ADD_INSN1(ret, node, setn, FIXNUM_INC(argc, 2+boff));
+ ADD_INSN1(ret, node, setn, INT2FIX(dup_argn+1));
}
- ADD_INSN1(ret, node, adjuststack, FIXNUM_INC(argc, 2+boff));
+ ADD_INSN1(ret, node, adjuststack, INT2FIX(dup_argn+1));
ADD_LABEL(ret, lfin);
}
else {
- CHECK(COMPILE(ret, "NODE_OP_ASGN1 args->body: ", node->nd_args->nd_body));
+ CHECK(COMPILE(ret, "NODE_OP_ASGN1 nd_rvalue: ", RNODE_OP_ASGN1(node)->nd_rvalue));
ADD_SEND(ret, node, id, INT2FIX(1));
if (!popped) {
- ADD_INSN1(ret, node, setn, FIXNUM_INC(argc, 2+boff));
+ ADD_INSN1(ret, node, setn, INT2FIX(dup_argn+1));
}
if (flag & VM_CALL_ARGS_SPLAT) {
- ADD_INSN1(ret, node, newarray, INT2FIX(1));
- if (boff > 0) {
- ADD_INSN1(ret, node, dupn, INT2FIX(3));
+ if (flag & VM_CALL_KW_SPLAT) {
+ ADD_INSN1(ret, node, topn, INT2FIX(2 + boff));
ADD_INSN(ret, node, swap);
+ ADD_INSN1(ret, node, newarray, INT2FIX(1));
+ ADD_INSN(ret, node, concatarray);
+ ADD_INSN1(ret, node, setn, INT2FIX(2 + boff));
ADD_INSN(ret, node, pop);
}
- ADD_INSN(ret, node, concatarray);
+ else {
+ ADD_INSN1(ret, node, newarray, INT2FIX(1));
+ if (boff > 0) {
+ ADD_INSN1(ret, node, dupn, INT2FIX(3));
+ ADD_INSN(ret, node, swap);
+ ADD_INSN(ret, node, pop);
+ }
+ ADD_INSN(ret, node, concatarray);
+ if (boff > 0) {
+ ADD_INSN1(ret, node, setn, INT2FIX(3));
+ ADD_INSN(ret, node, pop);
+ ADD_INSN(ret, node, pop);
+ }
+ }
+ ADD_SEND_R(ret, node, idASET, argc, NULL, INT2FIX(flag), keywords);
+ }
+ else if (flag & VM_CALL_KW_SPLAT) {
if (boff > 0) {
+ ADD_INSN1(ret, node, topn, INT2FIX(2));
+ ADD_INSN(ret, node, swap);
ADD_INSN1(ret, node, setn, INT2FIX(3));
ADD_INSN(ret, node, pop);
- ADD_INSN(ret, node, pop);
}
- ADD_SEND_WITH_FLAG(ret, node, idASET, argc, INT2FIX(flag));
+ ADD_INSN(ret, node, swap);
+ ADD_SEND_R(ret, node, idASET, FIXNUM_INC(argc, 1), NULL, INT2FIX(flag), keywords);
+ }
+ else if (keyword_len) {
+ ADD_INSN(ret, node, dup);
+ ADD_INSN1(ret, node, opt_reverse, INT2FIX(keyword_len+boff+2));
+ ADD_INSN1(ret, node, opt_reverse, INT2FIX(keyword_len+boff+1));
+ ADD_INSN(ret, node, pop);
+ ADD_SEND_R(ret, node, idASET, FIXNUM_INC(argc, 1), NULL, INT2FIX(flag), keywords);
}
else {
if (boff > 0)
ADD_INSN(ret, node, swap);
- ADD_SEND_WITH_FLAG(ret, node, idASET, FIXNUM_INC(argc, 1), INT2FIX(flag));
+ ADD_SEND_R(ret, node, idASET, FIXNUM_INC(argc, 1), NULL, INT2FIX(flag), keywords);
}
ADD_INSN(ret, node, pop);
}
@@ -8656,8 +9050,8 @@ static int
compile_op_asgn2(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const node, int popped)
{
const int line = nd_line(node);
- ID atype = node->nd_next->nd_mid;
- ID vid = node->nd_next->nd_vid, aid = rb_id_attrset(vid);
+ ID atype = RNODE_OP_ASGN2(node)->nd_mid;
+ ID vid = RNODE_OP_ASGN2(node)->nd_vid, aid = rb_id_attrset(vid);
int asgnflag;
LABEL *lfin = NEW_LABEL(line);
LABEL *lcfin = NEW_LABEL(line);
@@ -8715,9 +9109,9 @@ compile_op_asgn2(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const node
*/
- asgnflag = COMPILE_RECV(ret, "NODE_OP_ASGN2#recv", node);
+ asgnflag = COMPILE_RECV(ret, "NODE_OP_ASGN2#recv", node, RNODE_OP_ASGN2(node)->nd_recv);
CHECK(asgnflag != -1);
- if (node->nd_next->nd_aid) {
+ if (RNODE_OP_ASGN2(node)->nd_aid) {
lskip = NEW_LABEL(line);
ADD_INSN(ret, node, dup);
ADD_INSNL(ret, node, branchnil, lskip);
@@ -8738,7 +9132,7 @@ compile_op_asgn2(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const node
if (!popped) {
ADD_INSN(ret, node, pop);
}
- CHECK(COMPILE(ret, "NODE_OP_ASGN2 val", node->nd_value));
+ CHECK(COMPILE(ret, "NODE_OP_ASGN2 val", RNODE_OP_ASGN2(node)->nd_value));
if (!popped) {
ADD_INSN(ret, node, swap);
ADD_INSN1(ret, node, topn, INT2FIX(1));
@@ -8754,7 +9148,7 @@ compile_op_asgn2(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const node
ADD_LABEL(ret, lfin);
}
else {
- CHECK(COMPILE(ret, "NODE_OP_ASGN2 val", node->nd_value));
+ CHECK(COMPILE(ret, "NODE_OP_ASGN2 val", RNODE_OP_ASGN2(node)->nd_value));
ADD_SEND(ret, node, atype, INT2FIX(1));
if (!popped) {
ADD_INSN(ret, node, swap);
@@ -8780,21 +9174,21 @@ compile_op_cdecl(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const node
LABEL *lassign = 0;
ID mid;
- switch (nd_type(node->nd_head)) {
+ switch (nd_type(RNODE_OP_CDECL(node)->nd_head)) {
case NODE_COLON3:
ADD_INSN1(ret, node, putobject, rb_cObject);
break;
case NODE_COLON2:
- CHECK(COMPILE(ret, "NODE_OP_CDECL/colon2#nd_head", node->nd_head->nd_head));
+ CHECK(COMPILE(ret, "NODE_OP_CDECL/colon2#nd_head", RNODE_COLON2(RNODE_OP_CDECL(node)->nd_head)->nd_head));
break;
default:
COMPILE_ERROR(ERROR_ARGS "%s: invalid node in NODE_OP_CDECL",
- ruby_node_name(nd_type(node->nd_head)));
+ ruby_node_name(nd_type(RNODE_OP_CDECL(node)->nd_head)));
return COMPILE_NG;
}
- mid = node->nd_head->nd_mid;
+ mid = get_node_colon_nd_mid(RNODE_OP_CDECL(node)->nd_head);
/* cref */
- if (node->nd_aid == idOROP) {
+ if (RNODE_OP_CDECL(node)->nd_aid == idOROP) {
lassign = NEW_LABEL(line);
ADD_INSN(ret, node, dup); /* cref cref */
ADD_INSN3(ret, node, defined, INT2FIX(DEFINED_CONST_FROM),
@@ -8805,17 +9199,17 @@ compile_op_cdecl(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const node
ADD_INSN1(ret, node, putobject, Qtrue);
ADD_INSN1(ret, node, getconstant, ID2SYM(mid)); /* cref obj */
- if (node->nd_aid == idOROP || node->nd_aid == idANDOP) {
+ if (RNODE_OP_CDECL(node)->nd_aid == idOROP || RNODE_OP_CDECL(node)->nd_aid == idANDOP) {
lfin = NEW_LABEL(line);
if (!popped) ADD_INSN(ret, node, dup); /* cref [obj] obj */
- if (node->nd_aid == idOROP)
+ if (RNODE_OP_CDECL(node)->nd_aid == idOROP)
ADD_INSNL(ret, node, branchif, lfin);
else /* idANDOP */
ADD_INSNL(ret, node, branchunless, lfin);
/* cref [obj] */
if (!popped) ADD_INSN(ret, node, pop); /* cref */
if (lassign) ADD_LABEL(ret, lassign);
- CHECK(COMPILE(ret, "NODE_OP_CDECL#nd_value", node->nd_value));
+ CHECK(COMPILE(ret, "NODE_OP_CDECL#nd_value", RNODE_OP_CDECL(node)->nd_value));
/* cref value */
if (popped)
ADD_INSN1(ret, node, topn, INT2FIX(1)); /* cref value cref */
@@ -8829,9 +9223,9 @@ compile_op_cdecl(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const node
ADD_INSN(ret, node, pop); /* [value] */
}
else {
- CHECK(COMPILE(ret, "NODE_OP_CDECL#nd_value", node->nd_value));
+ CHECK(COMPILE(ret, "NODE_OP_CDECL#nd_value", RNODE_OP_CDECL(node)->nd_value));
/* cref obj value */
- ADD_CALL(ret, node, node->nd_aid, INT2FIX(1));
+ ADD_CALL(ret, node, RNODE_OP_CDECL(node)->nd_aid, INT2FIX(1));
/* cref value */
ADD_INSN(ret, node, swap); /* value cref */
if (!popped) {
@@ -8850,11 +9244,11 @@ compile_op_log(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const node,
LABEL *lfin = NEW_LABEL(line);
LABEL *lassign;
- if (type == NODE_OP_ASGN_OR && !nd_type_p(node->nd_head, NODE_IVAR)) {
+ if (type == NODE_OP_ASGN_OR && !nd_type_p(RNODE_OP_ASGN_OR(node)->nd_head, NODE_IVAR)) {
LABEL *lfinish[2];
lfinish[0] = lfin;
lfinish[1] = 0;
- defined_expr(iseq, ret, node->nd_head, lfinish, Qfalse);
+ defined_expr(iseq, ret, RNODE_OP_ASGN_OR(node)->nd_head, lfinish, Qfalse);
lassign = lfinish[1];
if (!lassign) {
lassign = NEW_LABEL(line);
@@ -8865,7 +9259,7 @@ compile_op_log(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const node,
lassign = NEW_LABEL(line);
}
- CHECK(COMPILE(ret, "NODE_OP_ASGN_AND/OR#nd_head", node->nd_head));
+ CHECK(COMPILE(ret, "NODE_OP_ASGN_AND/OR#nd_head", RNODE_OP_ASGN_OR(node)->nd_head));
if (!popped) {
ADD_INSN(ret, node, dup);
@@ -8883,7 +9277,7 @@ compile_op_log(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const node,
}
ADD_LABEL(ret, lassign);
- CHECK(COMPILE_(ret, "NODE_OP_ASGN_AND/OR#nd_value", node->nd_value, popped));
+ CHECK(COMPILE_(ret, "NODE_OP_ASGN_AND/OR#nd_value", RNODE_OP_ASGN_OR(node)->nd_value, popped));
ADD_LABEL(ret, lfin);
return COMPILE_OK;
}
@@ -8901,9 +9295,12 @@ compile_super(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const node, i
INIT_ANCHOR(args);
ISEQ_COMPILE_DATA(iseq)->current_block = NULL;
if (type == NODE_SUPER) {
- VALUE vargc = setup_args(iseq, args, node->nd_args, &flag, &keywords);
+ VALUE vargc = setup_args(iseq, args, RNODE_SUPER(node)->nd_args, &flag, &keywords);
CHECK(!NIL_P(vargc));
argc = FIX2INT(vargc);
+ if ((flag & VM_CALL_ARGS_BLOCKARG) && (flag & VM_CALL_KW_SPLAT) && !(flag & VM_CALL_KW_SPLAT_MUT)) {
+ ADD_INSN(args, node, splatkw);
+ }
}
else {
/* NODE_ZSUPER */
@@ -8974,14 +9371,11 @@ compile_super(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const node, i
if (local_body->param.flags.has_kwrest) {
int idx = local_body->local_table_size - local_kwd->rest_start;
ADD_GETLOCAL(args, node, idx, lvar_level);
- if (local_kwd->num > 0) {
- ADD_SEND (args, node, rb_intern("dup"), INT2FIX(0));
- flag |= VM_CALL_KW_SPLAT_MUT;
- }
+ assert(local_kwd->num > 0);
+ ADD_SEND (args, node, rb_intern("dup"), INT2FIX(0));
}
else {
ADD_INSN1(args, node, newhash, INT2FIX(0));
- flag |= VM_CALL_KW_SPLAT_MUT;
}
for (i = 0; i < local_kwd->num; ++i) {
ID id = local_kwd->table[i];
@@ -8990,24 +9384,12 @@ compile_super(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const node, i
ADD_GETLOCAL(args, node, idx, lvar_level);
}
ADD_SEND(args, node, id_core_hash_merge_ptr, INT2FIX(i * 2 + 1));
- if (local_body->param.flags.has_rest) {
- ADD_INSN1(args, node, newarray, INT2FIX(1));
- ADD_INSN (args, node, concatarray);
- --argc;
- }
- flag |= VM_CALL_KW_SPLAT;
+ flag |= VM_CALL_KW_SPLAT| VM_CALL_KW_SPLAT_MUT;
}
else if (local_body->param.flags.has_kwrest) {
int idx = local_body->local_table_size - local_kwd->rest_start;
ADD_GETLOCAL(args, node, idx, lvar_level);
-
- if (local_body->param.flags.has_rest) {
- ADD_INSN1(args, node, newarray, INT2FIX(1));
- ADD_INSN (args, node, concatarray);
- }
- else {
- argc++;
- }
+ argc++;
flag |= VM_CALL_KW_SPLAT;
}
}
@@ -9045,8 +9427,8 @@ compile_yield(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const node, i
default: /* valid */;
}
- if (node->nd_head) {
- argc = setup_args(iseq, args, node->nd_head, &flag, &keywords);
+ if (RNODE_YIELD(node)->nd_head) {
+ argc = setup_args(iseq, args, RNODE_YIELD(node)->nd_head, &flag, &keywords);
CHECK(!NIL_P(argc));
}
else {
@@ -9080,17 +9462,17 @@ compile_match(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const node, i
INIT_ANCHOR(val);
switch ((int)type) {
case NODE_MATCH:
- ADD_INSN1(recv, node, putobject, node->nd_lit);
+ ADD_INSN1(recv, node, putobject, RNODE_MATCH(node)->nd_lit);
ADD_INSN2(val, node, getspecial, INT2FIX(0),
INT2FIX(0));
break;
case NODE_MATCH2:
- CHECK(COMPILE(recv, "receiver", node->nd_recv));
- CHECK(COMPILE(val, "value", node->nd_value));
+ CHECK(COMPILE(recv, "receiver", RNODE_MATCH2(node)->nd_recv));
+ CHECK(COMPILE(val, "value", RNODE_MATCH2(node)->nd_value));
break;
case NODE_MATCH3:
- CHECK(COMPILE(recv, "receiver", node->nd_value));
- CHECK(COMPILE(val, "value", node->nd_recv));
+ CHECK(COMPILE(recv, "receiver", RNODE_MATCH3(node)->nd_value));
+ CHECK(COMPILE(val, "value", RNODE_MATCH3(node)->nd_recv));
break;
}
@@ -9098,8 +9480,8 @@ compile_match(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const node, i
ADD_SEQ(ret, val);
ADD_SEND(ret, node, idEqTilde, INT2FIX(1));
- if (node->nd_args) {
- compile_named_capture_assign(iseq, ret, node->nd_args);
+ if (nd_type_p(node, NODE_MATCH2) && RNODE_MATCH2(node)->nd_args) {
+ compile_named_capture_assign(iseq, ret, RNODE_MATCH2(node)->nd_args);
}
if (popped) {
@@ -9111,7 +9493,7 @@ compile_match(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const node, i
static int
compile_colon2(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const node, int popped)
{
- if (rb_is_const_id(node->nd_mid)) {
+ if (rb_is_const_id(RNODE_COLON2(node)->nd_mid)) {
/* constant */
VALUE segments;
if (ISEQ_COMPILE_DATA(iseq)->option->inline_const_cache &&
@@ -9141,8 +9523,8 @@ compile_colon2(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const node,
else {
/* function call */
ADD_CALL_RECEIVER(ret, node);
- CHECK(COMPILE(ret, "colon2#nd_head", node->nd_head));
- ADD_CALL(ret, node, node->nd_mid, INT2FIX(1));
+ CHECK(COMPILE(ret, "colon2#nd_head", RNODE_COLON2(node)->nd_head));
+ ADD_CALL(ret, node, RNODE_COLON2(node)->nd_mid, INT2FIX(1));
}
if (popped) {
ADD_INSN(ret, node, pop);
@@ -9153,19 +9535,19 @@ compile_colon2(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const node,
static int
compile_colon3(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const node, int popped)
{
- debugi("colon3#nd_mid", node->nd_mid);
+ debugi("colon3#nd_mid", RNODE_COLON3(node)->nd_mid);
/* add cache insn */
if (ISEQ_COMPILE_DATA(iseq)->option->inline_const_cache) {
ISEQ_BODY(iseq)->ic_size++;
- VALUE segments = rb_ary_new_from_args(2, ID2SYM(idNULL), ID2SYM(node->nd_mid));
+ VALUE segments = rb_ary_new_from_args(2, ID2SYM(idNULL), ID2SYM(RNODE_COLON3(node)->nd_mid));
ADD_INSN1(ret, node, opt_getconstant_path, segments);
RB_OBJ_WRITTEN(iseq, Qundef, segments);
}
else {
ADD_INSN1(ret, node, putobject, rb_cObject);
ADD_INSN1(ret, node, putobject, Qtrue);
- ADD_INSN1(ret, node, getconstant, ID2SYM(node->nd_mid));
+ ADD_INSN1(ret, node, getconstant, ID2SYM(RNODE_COLON3(node)->nd_mid));
}
if (popped) {
@@ -9178,13 +9560,13 @@ static int
compile_dots(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const node, int popped, const int excl)
{
VALUE flag = INT2FIX(excl);
- const NODE *b = node->nd_beg;
- const NODE *e = node->nd_end;
+ const NODE *b = RNODE_DOT2(node)->nd_beg;
+ const NODE *e = RNODE_DOT2(node)->nd_end;
if (optimizable_range_item_p(b) && optimizable_range_item_p(e)) {
if (!popped) {
- VALUE bv = nd_type_p(b, NODE_LIT) ? b->nd_lit : Qnil;
- VALUE ev = nd_type_p(e, NODE_LIT) ? e->nd_lit : Qnil;
+ VALUE bv = nd_type_p(b, NODE_LIT) ? RNODE_LIT(b)->nd_lit : Qnil;
+ VALUE ev = nd_type_p(e, NODE_LIT) ? RNODE_LIT(e)->nd_lit : Qnil;
VALUE val = rb_range_new(bv, ev, excl);
ADD_INSN1(ret, node, putobject, val);
RB_OBJ_WRITTEN(iseq, Qundef, val);
@@ -9233,7 +9615,7 @@ compile_kw_arg(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const node,
{
struct rb_iseq_constant_body *const body = ISEQ_BODY(iseq);
LABEL *end_label = NEW_LABEL(nd_line(node));
- const NODE *default_value = node->nd_body->nd_value;
+ const NODE *default_value = get_nd_value(RNODE_KW_ARG(node)->nd_body);
if (default_value == NODE_SPECIAL_REQUIRED_KEYWORD) {
/* required argument. do nothing */
@@ -9257,7 +9639,7 @@ compile_kw_arg(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const node,
ADD_INSN2(ret, node, checkkeyword, INT2FIX(kw_bits_idx + VM_ENV_DATA_SIZE - 1), INT2FIX(keyword_idx));
ADD_INSNL(ret, node, branchif, end_label);
- CHECK(COMPILE_POPPED(ret, "keyword default argument", node->nd_body));
+ CHECK(COMPILE_POPPED(ret, "keyword default argument", RNODE_KW_ARG(node)->nd_body));
ADD_LABEL(ret, end_label);
}
return COMPILE_OK;
@@ -9269,7 +9651,7 @@ compile_attrasgn(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const node
DECL_ANCHOR(recv);
DECL_ANCHOR(args);
unsigned int flag = 0;
- ID mid = node->nd_mid;
+ ID mid = RNODE_ATTRASGN(node)->nd_mid;
VALUE argc;
LABEL *else_label = NULL;
VALUE branches = Qfalse;
@@ -9277,16 +9659,16 @@ compile_attrasgn(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const node
/* optimization shortcut
* obj["literal"] = value -> opt_aset_with(obj, "literal", value)
*/
- if (mid == idASET && !private_recv_p(node) && node->nd_args &&
- nd_type_p(node->nd_args, NODE_LIST) && node->nd_args->nd_alen == 2 &&
- nd_type_p(node->nd_args->nd_head, NODE_STR) &&
+ if (mid == idASET && !private_recv_p(node) && RNODE_ATTRASGN(node)->nd_args &&
+ nd_type_p(RNODE_ATTRASGN(node)->nd_args, NODE_LIST) && RNODE_LIST(RNODE_ATTRASGN(node)->nd_args)->as.nd_alen == 2 &&
+ nd_type_p(RNODE_LIST(RNODE_ATTRASGN(node)->nd_args)->nd_head, NODE_STR) &&
ISEQ_COMPILE_DATA(iseq)->current_block == NULL &&
!ISEQ_COMPILE_DATA(iseq)->option->frozen_string_literal &&
ISEQ_COMPILE_DATA(iseq)->option->specialized_instruction)
{
- VALUE str = rb_fstring(node->nd_args->nd_head->nd_lit);
- CHECK(COMPILE(ret, "recv", node->nd_recv));
- CHECK(COMPILE(ret, "value", node->nd_args->nd_next->nd_head));
+ VALUE str = rb_fstring(RNODE_STR(RNODE_LIST(RNODE_ATTRASGN(node)->nd_args)->nd_head)->nd_lit);
+ CHECK(COMPILE(ret, "recv", RNODE_ATTRASGN(node)->nd_recv));
+ CHECK(COMPILE(ret, "value", RNODE_LIST(RNODE_LIST(RNODE_ATTRASGN(node)->nd_args)->nd_next)->nd_head));
if (!popped) {
ADD_INSN(ret, node, swap);
ADD_INSN1(ret, node, topn, INT2FIX(1));
@@ -9300,10 +9682,10 @@ compile_attrasgn(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const node
INIT_ANCHOR(recv);
INIT_ANCHOR(args);
- argc = setup_args(iseq, args, node->nd_args, &flag, NULL);
+ argc = setup_args(iseq, args, RNODE_ATTRASGN(node)->nd_args, &flag, NULL);
CHECK(!NIL_P(argc));
- int asgnflag = COMPILE_RECV(recv, "recv", node);
+ int asgnflag = COMPILE_RECV(recv, "recv", node, RNODE_ATTRASGN(node)->nd_recv);
CHECK(asgnflag != -1);
flag |= (unsigned int)asgnflag;
@@ -9385,7 +9767,7 @@ iseq_compile_each0(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const no
/* ignore */
}
else {
- if (node->flags & NODE_FL_NEWLINE) {
+ if (nd_fl_newline(node)) {
int event = RUBY_EVENT_LINE;
ISEQ_COMPILE_DATA(iseq)->last_line = line;
if (ISEQ_COVERAGE(iseq) && ISEQ_LINE_COVERAGE(iseq)) {
@@ -9440,7 +9822,7 @@ iseq_compile_each0(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const no
CHECK(compile_retry(iseq, ret, node, popped));
break;
case NODE_BEGIN:{
- CHECK(COMPILE_(ret, "NODE_BEGIN", node->nd_body, popped));
+ CHECK(COMPILE_(ret, "NODE_BEGIN", RNODE_BEGIN(node)->nd_body, popped));
break;
}
case NODE_RESCUE:
@@ -9456,7 +9838,7 @@ iseq_compile_each0(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const no
case NODE_AND:
case NODE_OR:{
LABEL *end_label = NEW_LABEL(line);
- CHECK(COMPILE(ret, "nd_1st", node->nd_1st));
+ CHECK(COMPILE(ret, "nd_1st", RNODE_OR(node)->nd_1st));
if (!popped) {
ADD_INSN(ret, node, dup);
}
@@ -9469,7 +9851,7 @@ iseq_compile_each0(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const no
if (!popped) {
ADD_INSN(ret, node, pop);
}
- CHECK(COMPILE_(ret, "nd_2nd", node->nd_2nd, popped));
+ CHECK(COMPILE_(ret, "nd_2nd", RNODE_OR(node)->nd_2nd, popped));
ADD_LABEL(ret, end_label);
break;
}
@@ -9480,11 +9862,11 @@ iseq_compile_each0(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const no
}
case NODE_LASGN:{
- ID id = node->nd_vid;
+ ID id = RNODE_LASGN(node)->nd_vid;
int idx = ISEQ_BODY(body->local_iseq)->local_table_size - get_local_var_idx(iseq, id);
debugs("lvar: %s idx: %d\n", rb_id2name(id), idx);
- CHECK(COMPILE(ret, "rvalue", node->nd_value));
+ CHECK(COMPILE(ret, "rvalue", RNODE_LASGN(node)->nd_value));
if (!popped) {
ADD_INSN(ret, node, dup);
@@ -9494,8 +9876,8 @@ iseq_compile_each0(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const no
}
case NODE_DASGN: {
int idx, lv, ls;
- ID id = node->nd_vid;
- CHECK(COMPILE(ret, "dvalue", node->nd_value));
+ ID id = RNODE_DASGN(node)->nd_vid;
+ CHECK(COMPILE(ret, "dvalue", RNODE_DASGN(node)->nd_value));
debugi("dassn id", rb_id2str(id) ? id : '*');
if (!popped) {
@@ -9513,27 +9895,27 @@ iseq_compile_each0(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const no
break;
}
case NODE_GASGN:{
- CHECK(COMPILE(ret, "lvalue", node->nd_value));
+ CHECK(COMPILE(ret, "lvalue", RNODE_GASGN(node)->nd_value));
if (!popped) {
ADD_INSN(ret, node, dup);
}
- ADD_INSN1(ret, node, setglobal, ID2SYM(node->nd_entry));
+ ADD_INSN1(ret, node, setglobal, ID2SYM(RNODE_GASGN(node)->nd_vid));
break;
}
case NODE_IASGN:{
- CHECK(COMPILE(ret, "lvalue", node->nd_value));
+ CHECK(COMPILE(ret, "lvalue", RNODE_IASGN(node)->nd_value));
if (!popped) {
ADD_INSN(ret, node, dup);
}
ADD_INSN2(ret, node, setinstancevariable,
- ID2SYM(node->nd_vid),
- get_ivar_ic_value(iseq,node->nd_vid));
+ ID2SYM(RNODE_IASGN(node)->nd_vid),
+ get_ivar_ic_value(iseq,RNODE_IASGN(node)->nd_vid));
break;
}
case NODE_CDECL:{
- if (node->nd_vid) {
- CHECK(COMPILE(ret, "lvalue", node->nd_value));
+ if (RNODE_CDECL(node)->nd_vid) {
+ CHECK(COMPILE(ret, "lvalue", RNODE_CDECL(node)->nd_value));
if (!popped) {
ADD_INSN(ret, node, dup);
@@ -9541,11 +9923,11 @@ iseq_compile_each0(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const no
ADD_INSN1(ret, node, putspecialobject,
INT2FIX(VM_SPECIAL_OBJECT_CONST_BASE));
- ADD_INSN1(ret, node, setconstant, ID2SYM(node->nd_vid));
+ ADD_INSN1(ret, node, setconstant, ID2SYM(RNODE_CDECL(node)->nd_vid));
}
else {
- compile_cpath(ret, iseq, node->nd_else);
- CHECK(COMPILE(ret, "lvalue", node->nd_value));
+ compile_cpath(ret, iseq, RNODE_CDECL(node)->nd_else);
+ CHECK(COMPILE(ret, "lvalue", RNODE_CDECL(node)->nd_value));
ADD_INSN(ret, node, swap);
if (!popped) {
@@ -9553,18 +9935,18 @@ iseq_compile_each0(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const no
ADD_INSN(ret, node, swap);
}
- ADD_INSN1(ret, node, setconstant, ID2SYM(node->nd_else->nd_mid));
+ ADD_INSN1(ret, node, setconstant, ID2SYM(get_node_colon_nd_mid(RNODE_CDECL(node)->nd_else)));
}
break;
}
case NODE_CVASGN:{
- CHECK(COMPILE(ret, "cvasgn val", node->nd_value));
+ CHECK(COMPILE(ret, "cvasgn val", RNODE_CVASGN(node)->nd_value));
if (!popped) {
ADD_INSN(ret, node, dup);
}
ADD_INSN2(ret, node, setclassvariable,
- ID2SYM(node->nd_vid),
- get_cvar_ic_value(iseq,node->nd_vid));
+ ID2SYM(RNODE_CVASGN(node)->nd_vid),
+ get_cvar_ic_value(iseq, RNODE_CVASGN(node)->nd_vid));
break;
}
case NODE_OP_ASGN1:
@@ -9606,18 +9988,6 @@ iseq_compile_each0(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const no
}
break;
}
- case NODE_VALUES:{
- const NODE *n = node;
- if (popped) {
- COMPILE_ERROR(ERROR_ARGS "NODE_VALUES: must not be popped");
- }
- while (n) {
- CHECK(COMPILE(ret, "values item", n->nd_head));
- n = n->nd_next;
- }
- ADD_INSN1(ret, node, newarray, INT2FIX(node->nd_alen));
- break;
- }
case NODE_HASH:
CHECK(compile_hash(iseq, ret, node, FALSE, popped) >= 0);
break;
@@ -9629,18 +9999,18 @@ iseq_compile_each0(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const no
break;
case NODE_LVAR:{
if (!popped) {
- compile_lvar(iseq, ret, node, node->nd_vid);
+ compile_lvar(iseq, ret, node, RNODE_LVAR(node)->nd_vid);
}
break;
}
case NODE_DVAR:{
int lv, idx, ls;
- debugi("nd_vid", node->nd_vid);
+ debugi("nd_vid", RNODE_DVAR(node)->nd_vid);
if (!popped) {
- idx = get_dyna_var_idx(iseq, node->nd_vid, &lv, &ls);
+ idx = get_dyna_var_idx(iseq, RNODE_DVAR(node)->nd_vid, &lv, &ls);
if (idx < 0) {
COMPILE_ERROR(ERROR_ARGS "unknown dvar (%"PRIsVALUE")",
- rb_id2str(node->nd_vid));
+ rb_id2str(RNODE_DVAR(node)->nd_vid));
goto ng;
}
ADD_GETLOCAL(ret, node, ls - idx, lv);
@@ -9648,34 +10018,34 @@ iseq_compile_each0(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const no
break;
}
case NODE_GVAR:{
- ADD_INSN1(ret, node, getglobal, ID2SYM(node->nd_entry));
+ ADD_INSN1(ret, node, getglobal, ID2SYM(RNODE_GVAR(node)->nd_vid));
if (popped) {
ADD_INSN(ret, node, pop);
}
break;
}
case NODE_IVAR:{
- debugi("nd_vid", node->nd_vid);
+ debugi("nd_vid", RNODE_IVAR(node)->nd_vid);
if (!popped) {
ADD_INSN2(ret, node, getinstancevariable,
- ID2SYM(node->nd_vid),
- get_ivar_ic_value(iseq,node->nd_vid));
+ ID2SYM(RNODE_IVAR(node)->nd_vid),
+ get_ivar_ic_value(iseq, RNODE_IVAR(node)->nd_vid));
}
break;
}
case NODE_CONST:{
- debugi("nd_vid", node->nd_vid);
+ debugi("nd_vid", RNODE_CONST(node)->nd_vid);
if (ISEQ_COMPILE_DATA(iseq)->option->inline_const_cache) {
body->ic_size++;
- VALUE segments = rb_ary_new_from_args(1, ID2SYM(node->nd_vid));
+ VALUE segments = rb_ary_new_from_args(1, ID2SYM(RNODE_CONST(node)->nd_vid));
ADD_INSN1(ret, node, opt_getconstant_path, segments);
RB_OBJ_WRITTEN(iseq, Qundef, segments);
}
else {
ADD_INSN(ret, node, putnil);
ADD_INSN1(ret, node, putobject, Qtrue);
- ADD_INSN1(ret, node, getconstant, ID2SYM(node->nd_vid));
+ ADD_INSN1(ret, node, getconstant, ID2SYM(RNODE_CONST(node)->nd_vid));
}
if (popped) {
@@ -9686,26 +10056,26 @@ iseq_compile_each0(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const no
case NODE_CVAR:{
if (!popped) {
ADD_INSN2(ret, node, getclassvariable,
- ID2SYM(node->nd_vid),
- get_cvar_ic_value(iseq,node->nd_vid));
+ ID2SYM(RNODE_CVAR(node)->nd_vid),
+ get_cvar_ic_value(iseq, RNODE_CVAR(node)->nd_vid));
}
break;
}
case NODE_NTH_REF:{
if (!popped) {
- if (!node->nd_nth) {
+ if (!RNODE_NTH_REF(node)->nd_nth) {
ADD_INSN(ret, node, putnil);
break;
}
ADD_INSN2(ret, node, getspecial, INT2FIX(1) /* '~' */,
- INT2FIX(node->nd_nth << 1));
+ INT2FIX(RNODE_NTH_REF(node)->nd_nth << 1));
}
break;
}
case NODE_BACK_REF:{
if (!popped) {
ADD_INSN2(ret, node, getspecial, INT2FIX(1) /* '~' */,
- INT2FIX(0x01 | (node->nd_nth << 1)));
+ INT2FIX(0x01 | (RNODE_BACK_REF(node)->nd_nth << 1)));
}
break;
}
@@ -9715,17 +10085,17 @@ iseq_compile_each0(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const no
CHECK(compile_match(iseq, ret, node, popped, type));
break;
case NODE_LIT:{
- debugp_param("lit", node->nd_lit);
+ debugp_param("lit", RNODE_LIT(node)->nd_lit);
if (!popped) {
- ADD_INSN1(ret, node, putobject, node->nd_lit);
- RB_OBJ_WRITTEN(iseq, Qundef, node->nd_lit);
+ ADD_INSN1(ret, node, putobject, RNODE_LIT(node)->nd_lit);
+ RB_OBJ_WRITTEN(iseq, Qundef, RNODE_LIT(node)->nd_lit);
}
break;
}
case NODE_STR:{
- debugp_param("nd_lit", node->nd_lit);
+ debugp_param("nd_lit", RNODE_STR(node)->nd_lit);
if (!popped) {
- VALUE lit = node->nd_lit;
+ VALUE lit = RNODE_STR(node)->nd_lit;
if (!ISEQ_COMPILE_DATA(iseq)->option->frozen_string_literal) {
lit = rb_fstring(lit);
ADD_INSN1(ret, node, putstring, lit);
@@ -9757,7 +10127,7 @@ iseq_compile_each0(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const no
}
case NODE_XSTR:{
ADD_CALL_RECEIVER(ret, node);
- VALUE str = rb_fstring(node->nd_lit);
+ VALUE str = rb_fstring(RNODE_XSTR(node)->nd_lit);
ADD_INSN1(ret, node, putobject, str);
RB_OBJ_WRITTEN(iseq, Qundef, str);
ADD_CALL(ret, node, idBackquote, INT2FIX(1));
@@ -9778,20 +10148,15 @@ iseq_compile_each0(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const no
break;
}
case NODE_EVSTR:
- CHECK(compile_evstr(iseq, ret, node->nd_body, popped));
+ CHECK(compile_evstr(iseq, ret, RNODE_EVSTR(node)->nd_body, popped));
break;
- case NODE_DREGX:{
- compile_dregx(iseq, ret, node);
-
- if (popped) {
- ADD_INSN(ret, node, pop);
- }
+ case NODE_DREGX:
+ compile_dregx(iseq, ret, node, popped);
break;
- }
case NODE_ONCE:{
int ic_index = body->ise_size++;
const rb_iseq_t *block_iseq;
- block_iseq = NEW_CHILD_ISEQ(node->nd_body, make_name_for_block(iseq), ISEQ_TYPE_PLAIN, line);
+ block_iseq = NEW_CHILD_ISEQ(RNODE_ONCE(node)->nd_body, make_name_for_block(iseq), ISEQ_TYPE_PLAIN, line);
ADD_INSN2(ret, node, once, block_iseq, INT2FIX(ic_index));
RB_OBJ_WRITTEN(iseq, Qundef, (VALUE)block_iseq);
@@ -9803,36 +10168,36 @@ iseq_compile_each0(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const no
}
case NODE_ARGSCAT:{
if (popped) {
- CHECK(COMPILE(ret, "argscat head", node->nd_head));
+ CHECK(COMPILE(ret, "argscat head", RNODE_ARGSCAT(node)->nd_head));
ADD_INSN1(ret, node, splatarray, Qfalse);
ADD_INSN(ret, node, pop);
- CHECK(COMPILE(ret, "argscat body", node->nd_body));
+ CHECK(COMPILE(ret, "argscat body", RNODE_ARGSCAT(node)->nd_body));
ADD_INSN1(ret, node, splatarray, Qfalse);
ADD_INSN(ret, node, pop);
}
else {
- CHECK(COMPILE(ret, "argscat head", node->nd_head));
- CHECK(COMPILE(ret, "argscat body", node->nd_body));
+ CHECK(COMPILE(ret, "argscat head", RNODE_ARGSCAT(node)->nd_head));
+ CHECK(COMPILE(ret, "argscat body", RNODE_ARGSCAT(node)->nd_body));
ADD_INSN(ret, node, concatarray);
}
break;
}
case NODE_ARGSPUSH:{
if (popped) {
- CHECK(COMPILE(ret, "argspush head", node->nd_head));
+ CHECK(COMPILE(ret, "argspush head", RNODE_ARGSPUSH(node)->nd_head));
ADD_INSN1(ret, node, splatarray, Qfalse);
ADD_INSN(ret, node, pop);
- CHECK(COMPILE_(ret, "argspush body", node->nd_body, popped));
+ CHECK(COMPILE_(ret, "argspush body", RNODE_ARGSPUSH(node)->nd_body, popped));
}
else {
- CHECK(COMPILE(ret, "argspush head", node->nd_head));
- CHECK(compile_array_1(iseq, ret, node->nd_body));
+ CHECK(COMPILE(ret, "argspush head", RNODE_ARGSPUSH(node)->nd_head));
+ CHECK(compile_array_1(iseq, ret, RNODE_ARGSPUSH(node)->nd_body));
ADD_INSN(ret, node, concatarray);
}
break;
}
case NODE_SPLAT:{
- CHECK(COMPILE(ret, "splat", node->nd_head));
+ CHECK(COMPILE(ret, "splat", RNODE_SPLAT(node)->nd_head));
ADD_INSN1(ret, node, splatarray, Qtrue);
if (popped) {
@@ -9841,8 +10206,8 @@ iseq_compile_each0(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const no
break;
}
case NODE_DEFN:{
- ID mid = node->nd_mid;
- const rb_iseq_t *method_iseq = NEW_ISEQ(node->nd_defn,
+ ID mid = RNODE_DEFN(node)->nd_mid;
+ const rb_iseq_t *method_iseq = NEW_ISEQ(RNODE_DEFN(node)->nd_defn,
rb_id2str(mid),
ISEQ_TYPE_METHOD, line);
@@ -9857,13 +10222,13 @@ iseq_compile_each0(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const no
break;
}
case NODE_DEFS:{
- ID mid = node->nd_mid;
- const rb_iseq_t * singleton_method_iseq = NEW_ISEQ(node->nd_defn,
+ ID mid = RNODE_DEFS(node)->nd_mid;
+ const rb_iseq_t * singleton_method_iseq = NEW_ISEQ(RNODE_DEFS(node)->nd_defn,
rb_id2str(mid),
ISEQ_TYPE_METHOD, line);
debugp_param("defs/iseq", rb_iseqw_new(singleton_method_iseq));
- CHECK(COMPILE(ret, "defs: recv", node->nd_recv));
+ CHECK(COMPILE(ret, "defs: recv", RNODE_DEFS(node)->nd_recv));
ADD_INSN2(ret, node, definesmethod, ID2SYM(mid), singleton_method_iseq);
RB_OBJ_WRITTEN(iseq, Qundef, (VALUE)singleton_method_iseq);
@@ -9875,8 +10240,8 @@ iseq_compile_each0(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const no
case NODE_ALIAS:{
ADD_INSN1(ret, node, putspecialobject, INT2FIX(VM_SPECIAL_OBJECT_VMCORE));
ADD_INSN1(ret, node, putspecialobject, INT2FIX(VM_SPECIAL_OBJECT_CBASE));
- CHECK(COMPILE(ret, "alias arg1", node->nd_1st));
- CHECK(COMPILE(ret, "alias arg2", node->nd_2nd));
+ CHECK(COMPILE(ret, "alias arg1", RNODE_ALIAS(node)->nd_1st));
+ CHECK(COMPILE(ret, "alias arg2", RNODE_ALIAS(node)->nd_2nd));
ADD_SEND(ret, node, id_core_set_method_alias, INT2FIX(3));
if (popped) {
@@ -9886,8 +10251,8 @@ iseq_compile_each0(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const no
}
case NODE_VALIAS:{
ADD_INSN1(ret, node, putspecialobject, INT2FIX(VM_SPECIAL_OBJECT_VMCORE));
- ADD_INSN1(ret, node, putobject, ID2SYM(node->nd_alias));
- ADD_INSN1(ret, node, putobject, ID2SYM(node->nd_orig));
+ ADD_INSN1(ret, node, putobject, ID2SYM(RNODE_VALIAS(node)->nd_alias));
+ ADD_INSN1(ret, node, putobject, ID2SYM(RNODE_VALIAS(node)->nd_orig));
ADD_SEND(ret, node, id_core_set_variable_alias, INT2FIX(2));
if (popped) {
@@ -9898,7 +10263,7 @@ iseq_compile_each0(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const no
case NODE_UNDEF:{
ADD_INSN1(ret, node, putspecialobject, INT2FIX(VM_SPECIAL_OBJECT_VMCORE));
ADD_INSN1(ret, node, putspecialobject, INT2FIX(VM_SPECIAL_OBJECT_CBASE));
- CHECK(COMPILE(ret, "undef arg", node->nd_undef));
+ CHECK(COMPILE(ret, "undef arg", RNODE_UNDEF(node)->nd_undef));
ADD_SEND(ret, node, id_core_undef_method, INT2FIX(2));
if (popped) {
@@ -9907,15 +10272,15 @@ iseq_compile_each0(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const no
break;
}
case NODE_CLASS:{
- const rb_iseq_t *class_iseq = NEW_CHILD_ISEQ(node->nd_body,
- rb_str_freeze(rb_sprintf("<class:%"PRIsVALUE">", rb_id2str(node->nd_cpath->nd_mid))),
+ const rb_iseq_t *class_iseq = NEW_CHILD_ISEQ(RNODE_CLASS(node)->nd_body,
+ rb_str_freeze(rb_sprintf("<class:%"PRIsVALUE">", rb_id2str(get_node_colon_nd_mid(RNODE_CLASS(node)->nd_cpath)))),
ISEQ_TYPE_CLASS, line);
const int flags = VM_DEFINECLASS_TYPE_CLASS |
- (node->nd_super ? VM_DEFINECLASS_FLAG_HAS_SUPERCLASS : 0) |
- compile_cpath(ret, iseq, node->nd_cpath);
+ (RNODE_CLASS(node)->nd_super ? VM_DEFINECLASS_FLAG_HAS_SUPERCLASS : 0) |
+ compile_cpath(ret, iseq, RNODE_CLASS(node)->nd_cpath);
- CHECK(COMPILE(ret, "super", node->nd_super));
- ADD_INSN3(ret, node, defineclass, ID2SYM(node->nd_cpath->nd_mid), class_iseq, INT2FIX(flags));
+ CHECK(COMPILE(ret, "super", RNODE_CLASS(node)->nd_super));
+ ADD_INSN3(ret, node, defineclass, ID2SYM(get_node_colon_nd_mid(RNODE_CLASS(node)->nd_cpath)), class_iseq, INT2FIX(flags));
RB_OBJ_WRITTEN(iseq, Qundef, (VALUE)class_iseq);
if (popped) {
@@ -9924,14 +10289,14 @@ iseq_compile_each0(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const no
break;
}
case NODE_MODULE:{
- const rb_iseq_t *module_iseq = NEW_CHILD_ISEQ(node->nd_body,
- rb_str_freeze(rb_sprintf("<module:%"PRIsVALUE">", rb_id2str(node->nd_cpath->nd_mid))),
+ const rb_iseq_t *module_iseq = NEW_CHILD_ISEQ(RNODE_MODULE(node)->nd_body,
+ rb_str_freeze(rb_sprintf("<module:%"PRIsVALUE">", rb_id2str(get_node_colon_nd_mid(RNODE_MODULE(node)->nd_cpath)))),
ISEQ_TYPE_CLASS, line);
const int flags = VM_DEFINECLASS_TYPE_MODULE |
- compile_cpath(ret, iseq, node->nd_cpath);
+ compile_cpath(ret, iseq, RNODE_MODULE(node)->nd_cpath);
ADD_INSN (ret, node, putnil); /* dummy */
- ADD_INSN3(ret, node, defineclass, ID2SYM(node->nd_cpath->nd_mid), module_iseq, INT2FIX(flags));
+ ADD_INSN3(ret, node, defineclass, ID2SYM(get_node_colon_nd_mid(RNODE_MODULE(node)->nd_cpath)), module_iseq, INT2FIX(flags));
RB_OBJ_WRITTEN(iseq, Qundef, (VALUE)module_iseq);
if (popped) {
@@ -9941,10 +10306,10 @@ iseq_compile_each0(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const no
}
case NODE_SCLASS:{
ID singletonclass;
- const rb_iseq_t *singleton_class = NEW_ISEQ(node->nd_body, rb_fstring_lit("singleton class"),
+ const rb_iseq_t *singleton_class = NEW_ISEQ(RNODE_SCLASS(node)->nd_body, rb_fstring_lit("singleton class"),
ISEQ_TYPE_CLASS, line);
- CHECK(COMPILE(ret, "sclass#recv", node->nd_recv));
+ CHECK(COMPILE(ret, "sclass#recv", RNODE_SCLASS(node)->nd_recv));
ADD_INSN (ret, node, putnil);
CONST_ID(singletonclass, "singletonclass");
ADD_INSN3(ret, node, defineclass,
@@ -10022,7 +10387,7 @@ iseq_compile_each0(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const no
*/
int is_index = body->ise_size++;
struct rb_iseq_new_with_callback_callback_func *ifunc =
- rb_iseq_new_with_callback_new_callback(build_postexe_iseq, node->nd_body);
+ rb_iseq_new_with_callback_new_callback(build_postexe_iseq, RNODE_POSTEXE(node)->nd_body);
const rb_iseq_t *once_iseq =
new_child_iseq_with_callback(iseq, ifunc,
rb_fstring(make_name_for_block(iseq)), iseq, ISEQ_TYPE_BLOCK, line);
@@ -10053,7 +10418,7 @@ iseq_compile_each0(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const no
break;
case NODE_LAMBDA:{
/* compile same as lambda{...} */
- const rb_iseq_t *block = NEW_CHILD_ISEQ(node->nd_body, make_name_for_block(iseq), ISEQ_TYPE_BLOCK, line);
+ const rb_iseq_t *block = NEW_CHILD_ISEQ(RNODE_LAMBDA(node)->nd_body, make_name_for_block(iseq), ISEQ_TYPE_BLOCK, line);
VALUE argc = INT2FIX(0);
ADD_INSN1(ret, node, putspecialobject, INT2FIX(VM_SPECIAL_OBJECT_VMCORE));
@@ -10264,6 +10629,12 @@ dump_disasm_list_with_cursor(const LINK_ELEMENT *link, const LINK_ELEMENT *curr,
fflush(stdout);
}
+int
+rb_insn_len(VALUE insn)
+{
+ return insn_len(insn);
+}
+
const char *
rb_insns_name(int i)
{
@@ -10427,6 +10798,7 @@ iseq_build_callinfo_from_hash(rb_iseq_t *iseq, VALUE op)
size_t n = rb_callinfo_kwarg_bytes(len);
kw_arg = xmalloc(n);
+ kw_arg->references = 0;
kw_arg->keyword_len = len;
for (i = 0; i < len; i++) {
VALUE kw = RARRAY_AREF(vkw_arg, i);
@@ -10452,6 +10824,7 @@ event_name_to_flag(VALUE sym)
CHECK_EVENT(RUBY_EVENT_RETURN);
CHECK_EVENT(RUBY_EVENT_B_CALL);
CHECK_EVENT(RUBY_EVENT_B_RETURN);
+ CHECK_EVENT(RUBY_EVENT_RESCUE);
#undef CHECK_EVENT
return RUBY_EVENT_NONE;
}
@@ -10735,8 +11108,14 @@ iseq_build_kw(rb_iseq_t *iseq, VALUE params, VALUE keywords)
return keyword;
}
+static void
+iseq_insn_each_object_mark_and_pin(VALUE obj, VALUE _)
+{
+ rb_gc_mark(obj);
+}
+
void
-rb_iseq_mark_and_update_insn_storage(struct iseq_compile_data_storage *storage)
+rb_iseq_mark_and_pin_insn_storage(struct iseq_compile_data_storage *storage)
{
INSN *iobj = 0;
size_t size = sizeof(INSN);
@@ -10761,23 +11140,7 @@ rb_iseq_mark_and_update_insn_storage(struct iseq_compile_data_storage *storage)
iobj = (INSN *)&storage->buff[pos];
if (iobj->operands) {
- int j;
- const char *types = insn_op_types(iobj->insn_id);
-
- for (j = 0; types[j]; j++) {
- char type = types[j];
- switch (type) {
- case TS_CDHASH:
- case TS_ISEQ:
- case TS_VALUE:
- case TS_IC: // constant path array
- case TS_CALLDATA: // ci is stored.
- rb_gc_mark_and_move(&OPERAND_AT(iobj, j));
- break;
- default:
- break;
- }
- }
+ iseq_insn_each_markable_object(iobj, iseq_insn_each_object_mark_and_pin, (VALUE)0);
}
pos += (int)size;
}
@@ -10950,7 +11313,7 @@ rb_local_defined(ID id, const rb_iseq_t *iseq)
#define IBF_ISEQ_ENABLE_LOCAL_BUFFER 0
#endif
-typedef unsigned int ibf_offset_t;
+typedef uint32_t ibf_offset_t;
#define IBF_OFFSET(ptr) ((ibf_offset_t)(VALUE)(ptr))
#define IBF_MAJOR_VERSION ISEQ_MAJOR_VERSION
@@ -10961,17 +11324,27 @@ typedef unsigned int ibf_offset_t;
#define IBF_MINOR_VERSION ISEQ_MINOR_VERSION
#endif
+static const char IBF_ENDIAN_MARK =
+#ifdef WORDS_BIGENDIAN
+ 'b'
+#else
+ 'l'
+#endif
+ ;
+
struct ibf_header {
char magic[4]; /* YARB */
- unsigned int major_version;
- unsigned int minor_version;
- unsigned int size;
- unsigned int extra_size;
+ uint32_t major_version;
+ uint32_t minor_version;
+ uint32_t size;
+ uint32_t extra_size;
- unsigned int iseq_list_size;
- unsigned int global_object_list_size;
+ uint32_t iseq_list_size;
+ uint32_t global_object_list_size;
ibf_offset_t iseq_list_offset;
ibf_offset_t global_object_list_offset;
+ uint8_t endian;
+ uint8_t wordsize; /* assume no 2048-bit CPU */
};
struct ibf_dump_buffer {
@@ -11006,7 +11379,7 @@ struct ibf_load {
struct pinned_list {
long size;
- VALUE * buffer;
+ VALUE buffer[1];
};
static void
@@ -11021,25 +11394,14 @@ pinned_list_mark(void *ptr)
}
}
-static void
-pinned_list_free(void *ptr)
-{
- struct pinned_list *list = (struct pinned_list *)ptr;
- xfree(list->buffer);
- xfree(ptr);
-}
-
-static size_t
-pinned_list_memsize(const void *ptr)
-{
- struct pinned_list *list = (struct pinned_list *)ptr;
- return sizeof(struct pinned_list) + (list->size * sizeof(VALUE *));
-}
-
static const rb_data_type_t pinned_list_type = {
"pinned_list",
- {pinned_list_mark, pinned_list_free, pinned_list_memsize,},
- 0, 0, RUBY_TYPED_WB_PROTECTED | RUBY_TYPED_FREE_IMMEDIATELY
+ {
+ pinned_list_mark,
+ RUBY_DEFAULT_FREE,
+ NULL, // No external memory to report,
+ },
+ 0, 0, RUBY_TYPED_WB_PROTECTED | RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_EMBEDDABLE
};
static VALUE
@@ -11073,13 +11435,10 @@ pinned_list_store(VALUE list, long offset, VALUE object)
static VALUE
pinned_list_new(long size)
{
- struct pinned_list * ptr;
- VALUE obj_list =
- TypedData_Make_Struct(0, struct pinned_list, &pinned_list_type, ptr);
-
- ptr->buffer = xcalloc(size, sizeof(VALUE));
+ size_t memsize = offsetof(struct pinned_list, buffer) + size * sizeof(VALUE);
+ VALUE obj_list = rb_data_typed_object_zalloc(0, memsize, &pinned_list_type);
+ struct pinned_list * ptr = RTYPEDDATA_GET_DATA(obj_list);
ptr->size = size;
-
return obj_list;
}
@@ -11872,15 +12231,36 @@ ibf_dump_ci_entries(struct ibf_dump *dump, const rb_iseq_t *iseq)
return offset;
}
+struct outer_variable_pair {
+ ID id;
+ VALUE name;
+ VALUE val;
+};
+
+struct outer_variable_list {
+ size_t num;
+ struct outer_variable_pair pairs[1];
+};
+
static enum rb_id_table_iterator_result
-dump_outer_variable(ID id, VALUE val, void *dump)
+store_outer_variable(ID id, VALUE val, void *dump)
{
- ibf_dump_write_small_value(dump, ibf_dump_id(dump, id));
- ibf_dump_write_small_value(dump, val);
-
+ struct outer_variable_list *ovlist = dump;
+ struct outer_variable_pair *pair = &ovlist->pairs[ovlist->num++];
+ pair->id = id;
+ pair->name = rb_id2str(id);
+ pair->val = val;
return ID_TABLE_CONTINUE;
}
+static int
+outer_variable_cmp(const void *a, const void *b, void *arg)
+{
+ const struct outer_variable_pair *ap = (const struct outer_variable_pair *)a;
+ const struct outer_variable_pair *bp = (const struct outer_variable_pair *)b;
+ return rb_str_cmp(ap->name, bp->name);
+}
+
static ibf_offset_t
ibf_dump_outer_variables(struct ibf_dump *dump, const rb_iseq_t *iseq)
{
@@ -11888,12 +12268,24 @@ ibf_dump_outer_variables(struct ibf_dump *dump, const rb_iseq_t *iseq)
ibf_offset_t offset = ibf_dump_pos(dump);
- if (ovs) {
- ibf_dump_write_small_value(dump, (VALUE)rb_id_table_size(ovs));
- rb_id_table_foreach(ovs, dump_outer_variable, (void *)dump);
- }
- else {
- ibf_dump_write_small_value(dump, (VALUE)0);
+ size_t size = ovs ? rb_id_table_size(ovs) : 0;
+ ibf_dump_write_small_value(dump, (VALUE)size);
+ if (size > 0) {
+ VALUE buff;
+ size_t buffsize =
+ rb_size_mul_add_or_raise(sizeof(struct outer_variable_pair), size,
+ offsetof(struct outer_variable_list, pairs),
+ rb_eArgError);
+ struct outer_variable_list *ovlist = RB_ALLOCV(buff, buffsize);
+ ovlist->num = 0;
+ rb_id_table_foreach(ovs, store_outer_variable, ovlist);
+ ruby_qsort(ovlist->pairs, size, sizeof(struct outer_variable_pair), outer_variable_cmp, NULL);
+ for (size_t i = 0; i < size; ++i) {
+ ID id = ovlist->pairs[i].id;
+ ID val = ovlist->pairs[i].val;
+ ibf_dump_write_small_value(dump, ibf_dump_id(dump, id));
+ ibf_dump_write_small_value(dump, val);
+ }
}
return offset;
@@ -11924,6 +12316,7 @@ ibf_load_ci_entries(const struct ibf_load *load,
int kwlen = (int)ibf_load_small_value(load, &reading_pos);
if (kwlen > 0) {
kwarg = rb_xmalloc_mul_add(kwlen, sizeof(VALUE), sizeof(struct rb_callinfo_kwarg));
+ kwarg->references = 0;
kwarg->keyword_len = kwlen;
for (int j=0; j<kwlen; j++) {
VALUE keyword = ibf_load_small_value(load, &reading_pos);
@@ -12078,8 +12471,7 @@ ibf_dump_iseq_each(struct ibf_dump *dump, const rb_iseq_t *iseq)
ibf_dump_write_small_value(dump, body->ic_size);
ibf_dump_write_small_value(dump, body->ci_size);
ibf_dump_write_small_value(dump, body->stack_max);
- ibf_dump_write_small_value(dump, body->catch_except_p);
- ibf_dump_write_small_value(dump, body->builtin_inline_p);
+ ibf_dump_write_small_value(dump, body->builtin_attrs);
#undef IBF_BODY_OFFSET
@@ -12191,8 +12583,7 @@ ibf_load_iseq_each(struct ibf_load *load, rb_iseq_t *iseq, ibf_offset_t offset)
const unsigned int ci_size = (unsigned int)ibf_load_small_value(load, &reading_pos);
const unsigned int stack_max = (unsigned int)ibf_load_small_value(load, &reading_pos);
- const char catch_except_p = (char)ibf_load_small_value(load, &reading_pos);
- const bool builtin_inline_p = (bool)ibf_load_small_value(load, &reading_pos);
+ const unsigned int builtin_attrs = (unsigned int)ibf_load_small_value(load, &reading_pos);
// setup fname and dummy frame
VALUE path = ibf_load_object(load, location_pathobj_index);
@@ -12264,14 +12655,19 @@ ibf_load_iseq_each(struct ibf_load *load, rb_iseq_t *iseq, ibf_offset_t offset)
load_body->location.code_location.beg_pos.column = location_code_location_beg_pos_column;
load_body->location.code_location.end_pos.lineno = location_code_location_end_pos_lineno;
load_body->location.code_location.end_pos.column = location_code_location_end_pos_column;
- load_body->catch_except_p = catch_except_p;
- load_body->builtin_inline_p = builtin_inline_p;
+ load_body->builtin_attrs = builtin_attrs;
load_body->ivc_size = ivc_size;
load_body->icvarc_size = icvarc_size;
load_body->ise_size = ise_size;
load_body->ic_size = ic_size;
- load_body->is_entries = ZALLOC_N(union iseq_inline_storage_entry, ISEQ_IS_SIZE(load_body));
+
+ if (ISEQ_IS_SIZE(load_body)) {
+ load_body->is_entries = ZALLOC_N(union iseq_inline_storage_entry, ISEQ_IS_SIZE(load_body));
+ }
+ else {
+ load_body->is_entries = NULL;
+ }
ibf_load_ci_entries(load, ci_entries_offset, ci_size, &load_body->call_data);
load_body->outer_variables = ibf_load_outer_variables(load, outer_variables_offset);
load_body->param.opt_table = ibf_load_param_opt_table(load, param_opt_table_offset, param_opt_num);
@@ -12711,8 +13107,12 @@ ibf_load_object_bignum(const struct ibf_load *load, const struct ibf_object_head
const struct ibf_object_bignum *bignum = IBF_OBJBODY(struct ibf_object_bignum, offset);
int sign = bignum->slen > 0;
ssize_t len = sign > 0 ? bignum->slen : -1 * bignum->slen;
- VALUE obj = rb_integer_unpack(bignum->digits, len * 2, 2, 0,
- INTEGER_PACK_LITTLE_ENDIAN | (sign == 0 ? INTEGER_PACK_NEGATIVE : 0));
+ const int big_unpack_flags = /* c.f. rb_big_unpack() */
+ INTEGER_PACK_LSWORD_FIRST |
+ INTEGER_PACK_NATIVE_BYTE_ORDER;
+ VALUE obj = rb_integer_unpack(bignum->digits, len, sizeof(BDIGIT), 0,
+ big_unpack_flags |
+ (sign == 0 ? INTEGER_PACK_NEGATIVE : 0));
if (header->internal) rb_obj_hide(obj);
if (header->frozen) rb_obj_freeze(obj);
return obj;
@@ -12804,7 +13204,7 @@ ibf_load_object_symbol(const struct ibf_load *load, const struct ibf_object_head
}
typedef void (*ibf_dump_object_function)(struct ibf_dump *dump, VALUE obj);
-static ibf_dump_object_function dump_object_functions[RUBY_T_MASK+1] = {
+static const ibf_dump_object_function dump_object_functions[RUBY_T_MASK+1] = {
ibf_dump_object_unsupported, /* T_NONE */
ibf_dump_object_unsupported, /* T_OBJECT */
ibf_dump_object_class, /* T_CLASS */
@@ -12897,7 +13297,7 @@ ibf_dump_object_object(struct ibf_dump *dump, VALUE obj)
}
typedef VALUE (*ibf_load_object_function)(const struct ibf_load *load, const struct ibf_object_header *header, ibf_offset_t offset);
-static ibf_load_object_function load_object_functions[RUBY_T_MASK+1] = {
+static const ibf_load_object_function load_object_functions[RUBY_T_MASK+1] = {
ibf_load_object_unsupported, /* T_NONE */
ibf_load_object_unsupported, /* T_OBJECT */
ibf_load_object_class, /* T_CLASS */
@@ -13040,14 +13440,13 @@ ibf_dump_free(void *ptr)
st_free_table(dump->iseq_table);
dump->iseq_table = 0;
}
- ruby_xfree(dump);
}
static size_t
ibf_dump_memsize(const void *ptr)
{
struct ibf_dump *dump = (struct ibf_dump *)ptr;
- size_t size = sizeof(*dump);
+ size_t size = 0;
if (dump->iseq_table) size += st_memsize(dump->iseq_table);
if (dump->global_buffer.obj_table) size += st_memsize(dump->global_buffer.obj_table);
return size;
@@ -13056,7 +13455,7 @@ ibf_dump_memsize(const void *ptr)
static const rb_data_type_t ibf_dump_type = {
"ibf_dump",
{ibf_dump_mark, ibf_dump_free, ibf_dump_memsize,},
- 0, 0, RUBY_TYPED_WB_PROTECTED | RUBY_TYPED_FREE_IMMEDIATELY
+ 0, 0, RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_EMBEDDABLE
};
static void
@@ -13092,7 +13491,6 @@ rb_iseq_ibf_dump(const rb_iseq_t *iseq, VALUE opt)
ibf_dump_setup(dump, dump_obj);
ibf_dump_write(dump, &header, sizeof(header));
- ibf_dump_write(dump, RUBY_PLATFORM, strlen(RUBY_PLATFORM) + 1);
ibf_dump_iseq(dump, iseq);
header.magic[0] = 'Y'; /* YARB */
@@ -13101,6 +13499,8 @@ rb_iseq_ibf_dump(const rb_iseq_t *iseq, VALUE opt)
header.magic[3] = 'B';
header.major_version = IBF_MAJOR_VERSION;
header.minor_version = IBF_MINOR_VERSION;
+ header.endian = IBF_ENDIAN_MARK;
+ header.wordsize = (uint8_t)SIZEOF_VALUE;
ibf_dump_iseq_list(dump, &header);
ibf_dump_object_list(dump, &header.global_object_list_offset, &header.global_object_list_size);
header.size = ibf_dump_pos(dump);
@@ -13118,8 +13518,6 @@ rb_iseq_ibf_dump(const rb_iseq_t *iseq, VALUE opt)
ibf_dump_overwrite(dump, &header, sizeof(header), 0);
str = dump->global_buffer.str;
- ibf_dump_free(dump);
- DATA_PTR(dump_obj) = NULL;
RB_GC_GUARD(dump_obj);
return str;
}
@@ -13150,7 +13548,7 @@ rb_ibf_load_iseq_complete(rb_iseq_t *iseq)
}
#if USE_LAZY_LOAD
-MJIT_FUNC_EXPORTED const rb_iseq_t *
+const rb_iseq_t *
rb_iseq_complete(const rb_iseq_t *iseq)
{
rb_ibf_load_iseq_complete((rb_iseq_t *)iseq);
@@ -13193,16 +13591,12 @@ ibf_load_iseq(const struct ibf_load *load, const rb_iseq_t *index_iseq)
#endif
pinned_list_store(load->iseq_list, iseq_index, (VALUE)iseq);
-#if !USE_LAZY_LOAD
+ if (!USE_LAZY_LOAD || GET_VM()->builtin_function_table) {
#if IBF_ISEQ_DEBUG
- fprintf(stderr, "ibf_load_iseq: loading iseq=%p\n", (void *)iseq);
+ fprintf(stderr, "ibf_load_iseq: loading iseq=%p\n", (void *)iseq);
#endif
- rb_ibf_load_iseq_complete(iseq);
-#else
- if (GET_VM()->builtin_function_table) {
rb_ibf_load_iseq_complete(iseq);
}
-#endif /* !USE_LAZY_LOAD */
#if IBF_ISEQ_DEBUG
fprintf(stderr, "ibf_load_iseq: iseq=%p loaded %p\n",
@@ -13216,35 +13610,39 @@ ibf_load_iseq(const struct ibf_load *load, const rb_iseq_t *index_iseq)
static void
ibf_load_setup_bytes(struct ibf_load *load, VALUE loader_obj, const char *bytes, size_t size)
{
+ struct ibf_header *header = (struct ibf_header *)bytes;
load->loader_obj = loader_obj;
load->global_buffer.buff = bytes;
- load->header = (struct ibf_header *)load->global_buffer.buff;
- load->global_buffer.size = load->header->size;
- load->global_buffer.obj_list_offset = load->header->global_object_list_offset;
- load->global_buffer.obj_list_size = load->header->global_object_list_size;
- RB_OBJ_WRITE(loader_obj, &load->iseq_list, pinned_list_new(load->header->iseq_list_size));
+ load->header = header;
+ load->global_buffer.size = header->size;
+ load->global_buffer.obj_list_offset = header->global_object_list_offset;
+ load->global_buffer.obj_list_size = header->global_object_list_size;
+ RB_OBJ_WRITE(loader_obj, &load->iseq_list, pinned_list_new(header->iseq_list_size));
RB_OBJ_WRITE(loader_obj, &load->global_buffer.obj_list, pinned_list_new(load->global_buffer.obj_list_size));
load->iseq = NULL;
load->current_buffer = &load->global_buffer;
- if (size < load->header->size) {
+ if (size < header->size) {
rb_raise(rb_eRuntimeError, "broken binary format");
}
- if (strncmp(load->header->magic, "YARB", 4) != 0) {
+ if (strncmp(header->magic, "YARB", 4) != 0) {
rb_raise(rb_eRuntimeError, "unknown binary format");
}
- if (load->header->major_version != IBF_MAJOR_VERSION ||
- load->header->minor_version != IBF_MINOR_VERSION) {
+ if (header->major_version != IBF_MAJOR_VERSION ||
+ header->minor_version != IBF_MINOR_VERSION) {
rb_raise(rb_eRuntimeError, "unmatched version file (%u.%u for %u.%u)",
- load->header->major_version, load->header->minor_version, IBF_MAJOR_VERSION, IBF_MINOR_VERSION);
+ header->major_version, header->minor_version, IBF_MAJOR_VERSION, IBF_MINOR_VERSION);
}
- if (strcmp(load->global_buffer.buff + sizeof(struct ibf_header), RUBY_PLATFORM) != 0) {
- rb_raise(rb_eRuntimeError, "unmatched platform");
+ if (header->endian != IBF_ENDIAN_MARK) {
+ rb_raise(rb_eRuntimeError, "unmatched endian: %c", header->endian);
}
- if (load->header->iseq_list_offset % RUBY_ALIGNOF(ibf_offset_t)) {
+ if (header->wordsize != SIZEOF_VALUE) {
+ rb_raise(rb_eRuntimeError, "unmatched word size: %d", header->wordsize);
+ }
+ if (header->iseq_list_offset % RUBY_ALIGNOF(ibf_offset_t)) {
rb_raise(rb_eArgError, "unaligned iseq list offset: %u",
- load->header->iseq_list_offset);
+ header->iseq_list_offset);
}
if (load->global_buffer.obj_list_offset % RUBY_ALIGNOF(ibf_offset_t)) {
rb_raise(rb_eArgError, "unaligned object list offset: %u",
@@ -13259,9 +13657,9 @@ ibf_load_setup(struct ibf_load *load, VALUE loader_obj, VALUE str)
rb_raise(rb_eRuntimeError, "broken binary format");
}
-#if USE_LAZY_LOAD
- str = rb_str_new(RSTRING_PTR(str), RSTRING_LEN(str));
-#endif
+ if (USE_LAZY_LOAD) {
+ str = rb_str_new(RSTRING_PTR(str), RSTRING_LEN(str));
+ }
ibf_load_setup_bytes(load, loader_obj, StringValuePtr(str), RSTRING_LEN(str));
RB_OBJ_WRITE(loader_obj, &load->str, str);
@@ -13335,3 +13733,5 @@ rb_iseq_ibf_load_extra_data(VALUE str)
RB_GC_GUARD(loader_obj);
return extra_str;
}
+
+#include "prism_compile.c"
diff --git a/complex.c b/complex.c
index 57962f9013..d29189e367 100644
--- a/complex.c
+++ b/complex.c
@@ -24,6 +24,7 @@
#include "internal/numeric.h"
#include "internal/object.h"
#include "internal/rational.h"
+#include "internal/string.h"
#include "ruby_assert.h"
#define ZERO INT2FIX(0)
@@ -391,7 +392,8 @@ k_numeric_p(VALUE x)
inline static VALUE
nucomp_s_new_internal(VALUE klass, VALUE real, VALUE imag)
{
- NEWOBJ_OF(obj, struct RComplex, klass, T_COMPLEX | (RGENGC_WB_PROTECTED_COMPLEX ? FL_WB_PROTECTED : 0));
+ NEWOBJ_OF(obj, struct RComplex, klass,
+ T_COMPLEX | (RGENGC_WB_PROTECTED_COMPLEX ? FL_WB_PROTECTED : 0), sizeof(struct RComplex), 0);
RCOMPLEX_SET_REAL(obj, real);
RCOMPLEX_SET_IMAG(obj, imag);
@@ -473,12 +475,19 @@ nucomp_s_canonicalize_internal(VALUE klass, VALUE real, VALUE imag)
/*
* call-seq:
- * Complex.rect(real[, imag]) -> complex
- * Complex.rectangular(real[, imag]) -> complex
+ * Complex.rect(real, imag = 0) -> complex
*
- * Returns a complex object which denotes the given rectangular form.
+ * Returns a new \Complex object formed from the arguments,
+ * each of which must be an instance of Numeric,
+ * or an instance of one of its subclasses:
+ * \Complex, Float, Integer, Rational;
+ * see {Rectangular Coordinates}[rdoc-ref:Complex@Rectangular+Coordinates]:
*
- * Complex.rectangular(1, 2) #=> (1+2i)
+ * Complex.rect(3) # => (3+0i)
+ * Complex.rect(3, Math::PI) # => (3+3.141592653589793i)
+ * Complex.rect(-3, -Math::PI) # => (-3-3.141592653589793i)
+ *
+ * \Complex.rectangular is an alias for \Complex.rect.
*/
static VALUE
nucomp_s_new(int argc, VALUE *argv, VALUE klass)
@@ -515,39 +524,54 @@ static VALUE nucomp_s_convert(int argc, VALUE *argv, VALUE klass);
/*
* call-seq:
- * Complex(x[, y], exception: true) -> numeric or nil
- *
- * Returns x+i*y;
- *
- * Complex(1, 2) #=> (1+2i)
- * Complex('1+2i') #=> (1+2i)
- * Complex(nil) #=> TypeError
- * Complex(1, nil) #=> TypeError
- *
- * Complex(1, nil, exception: false) #=> nil
- * Complex('1+2', exception: false) #=> nil
- *
- * Syntax of string form:
- *
- * string form = extra spaces , complex , extra spaces ;
- * complex = real part | [ sign ] , imaginary part
- * | real part , sign , imaginary part
- * | rational , "@" , rational ;
- * real part = rational ;
- * imaginary part = imaginary unit | unsigned rational , imaginary unit ;
- * rational = [ sign ] , unsigned rational ;
- * unsigned rational = numerator | numerator , "/" , denominator ;
- * numerator = integer part | fractional part | integer part , fractional part ;
- * denominator = digits ;
- * integer part = digits ;
- * fractional part = "." , digits , [ ( "e" | "E" ) , [ sign ] , digits ] ;
- * imaginary unit = "i" | "I" | "j" | "J" ;
- * sign = "-" | "+" ;
- * digits = digit , { digit | "_" , digit };
- * digit = "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9" ;
- * extra spaces = ? \s* ? ;
- *
- * See String#to_c.
+ * Complex(real, imag = 0, exception: true) -> complex or nil
+ * Complex(s, exception: true) -> complex or nil
+ *
+ * Returns a new \Complex object if the arguments are valid;
+ * otherwise raises an exception if +exception+ is +true+;
+ * otherwise returns +nil+.
+ *
+ * With Numeric arguments +real+ and +imag+,
+ * returns <tt>Complex.rect(real, imag)</tt> if the arguments are valid.
+ *
+ * With string argument +s+, returns a new \Complex object if the argument is valid;
+ * the string may have:
+ *
+ * - One or two numeric substrings,
+ * each of which specifies a Complex, Float, Integer, Numeric, or Rational value,
+ * specifying {rectangular coordinates}[rdoc-ref:Complex@Rectangular+Coordinates]:
+ *
+ * - Sign-separated real and imaginary numeric substrings
+ * (with trailing character <tt>'i'</tt>):
+ *
+ * Complex('1+2i') # => (1+2i)
+ * Complex('+1+2i') # => (1+2i)
+ * Complex('+1-2i') # => (1-2i)
+ * Complex('-1+2i') # => (-1+2i)
+ * Complex('-1-2i') # => (-1-2i)
+ *
+ * - Real-only numeric string (without trailing character <tt>'i'</tt>):
+ *
+ * Complex('1') # => (1+0i)
+ * Complex('+1') # => (1+0i)
+ * Complex('-1') # => (-1+0i)
+ *
+ * - Imaginary-only numeric string (with trailing character <tt>'i'</tt>):
+ *
+ * Complex('1i') # => (0+1i)
+ * Complex('+1i') # => (0+1i)
+ * Complex('-1i') # => (0-1i)
+ *
+ * - At-sign separated real and imaginary rational substrings,
+ * each of which specifies a Rational value,
+ * specifying {polar coordinates}[rdoc-ref:Complex@Polar+Coordinates]:
+ *
+ * Complex('1/2@3/4') # => (0.36584443443691045+0.34081938001166706i)
+ * Complex('+1/2@+3/4') # => (0.36584443443691045+0.34081938001166706i)
+ * Complex('+1/2@-3/4') # => (0.36584443443691045-0.34081938001166706i)
+ * Complex('-1/2@+3/4') # => (-0.36584443443691045-0.34081938001166706i)
+ * Complex('-1/2@-3/4') # => (-0.36584443443691045+0.34081938001166706i)
+ *
*/
static VALUE
nucomp_f_complex(int argc, VALUE *argv, VALUE klass)
@@ -697,14 +721,19 @@ rb_dbl_complex_new_polar_pi(double abs, double ang)
/*
* call-seq:
- * Complex.polar(abs[, arg]) -> complex
+ * Complex.polar(abs, arg = 0) -> complex
*
- * Returns a complex object which denotes the given polar form.
+ * Returns a new \Complex object formed from the arguments,
+ * each of which must be an instance of Numeric,
+ * or an instance of one of its subclasses:
+ * \Complex, Float, Integer, Rational.
+ * Argument +arg+ is given in radians;
+ * see {Polar Coordinates}[rdoc-ref:Complex@Polar+Coordinates]:
+ *
+ * Complex.polar(3) # => (3+0i)
+ * Complex.polar(3, 2.0) # => (-1.2484405096414273+2.727892280477045i)
+ * Complex.polar(-3, -2.0) # => (1.2484405096414273+2.727892280477045i)
*
- * Complex.polar(3, 0) #=> (3.0+0.0i)
- * Complex.polar(3, Math::PI/2) #=> (1.836909530733566e-16+3.0i)
- * Complex.polar(3, Math::PI) #=> (-3.0+3.673819061467132e-16i)
- * Complex.polar(3, -Math::PI/2) #=> (1.836909530733566e-16-3.0i)
*/
static VALUE
nucomp_s_polar(int argc, VALUE *argv, VALUE klass)
@@ -724,12 +753,19 @@ nucomp_s_polar(int argc, VALUE *argv, VALUE klass)
/*
* call-seq:
- * cmp.real -> real
+ * real -> numeric
+ *
+ * Returns the real value for +self+:
*
- * Returns the real part.
+ * Complex(7).real #=> 7
+ * Complex(9, -4).real #=> 9
+ *
+ * If +self+ was created with
+ * {polar coordinates}[rdoc-ref:Complex@Polar+Coordinates], the returned value
+ * is computed, and may be inexact:
+ *
+ * Complex.polar(1, Math::PI/4).real # => 0.7071067811865476 # Square root of 2.
*
- * Complex(7).real #=> 7
- * Complex(9, -4).real #=> 9
*/
VALUE
rb_complex_real(VALUE self)
@@ -740,13 +776,19 @@ rb_complex_real(VALUE self)
/*
* call-seq:
- * cmp.imag -> real
- * cmp.imaginary -> real
+ * imag -> numeric
*
- * Returns the imaginary part.
+ * Returns the imaginary value for +self+:
*
* Complex(7).imaginary #=> 0
* Complex(9, -4).imaginary #=> -4
+ *
+ * If +self+ was created with
+ * {polar coordinates}[rdoc-ref:Complex@Polar+Coordinates], the returned value
+ * is computed, and may be inexact:
+ *
+ * Complex.polar(1, Math::PI/4).imag # => 0.7071067811865476 # Square root of 2.
+ *
*/
VALUE
rb_complex_imag(VALUE self)
@@ -757,11 +799,13 @@ rb_complex_imag(VALUE self)
/*
* call-seq:
- * -cmp -> complex
+ * -complex -> new_complex
+ *
+ * Returns the negation of +self+, which is the negation of each of its parts:
*
- * Returns negation of the value.
+ * -Complex(1, 2) # => (-1-2i)
+ * -Complex(-1, -2) # => (1+2i)
*
- * -Complex(1, 2) #=> (-1-2i)
*/
VALUE
rb_complex_uminus(VALUE self)
@@ -773,15 +817,16 @@ rb_complex_uminus(VALUE self)
/*
* call-seq:
- * cmp + numeric -> complex
+ * complex + numeric -> new_complex
*
- * Performs addition.
+ * Returns the sum of +self+ and +numeric+:
+ *
+ * Complex(2, 3) + Complex(2, 3) # => (4+6i)
+ * Complex(900) + Complex(1) # => (901+0i)
+ * Complex(-2, 9) + Complex(-9, 2) # => (-11+11i)
+ * Complex(9, 8) + 4 # => (13+8i)
+ * Complex(20, 9) + 9.8 # => (29.8+9i)
*
- * Complex(2, 3) + Complex(2, 3) #=> (4+6i)
- * Complex(900) + Complex(1) #=> (901+0i)
- * Complex(-2, 9) + Complex(-9, 2) #=> (-11+11i)
- * Complex(9, 8) + 4 #=> (13+8i)
- * Complex(20, 9) + 9.8 #=> (29.8+9i)
*/
VALUE
rb_complex_plus(VALUE self, VALUE other)
@@ -807,15 +852,16 @@ rb_complex_plus(VALUE self, VALUE other)
/*
* call-seq:
- * cmp - numeric -> complex
+ * complex - numeric -> new_complex
+ *
+ * Returns the difference of +self+ and +numeric+:
*
- * Performs subtraction.
+ * Complex(2, 3) - Complex(2, 3) # => (0+0i)
+ * Complex(900) - Complex(1) # => (899+0i)
+ * Complex(-2, 9) - Complex(-9, 2) # => (7+7i)
+ * Complex(9, 8) - 4 # => (5+8i)
+ * Complex(20, 9) - 9.8 # => (10.2+9i)
*
- * Complex(2, 3) - Complex(2, 3) #=> (0+0i)
- * Complex(900) - Complex(1) #=> (899+0i)
- * Complex(-2, 9) - Complex(-9, 2) #=> (7+7i)
- * Complex(9, 8) - 4 #=> (5+8i)
- * Complex(20, 9) - 9.8 #=> (10.2+9i)
*/
VALUE
rb_complex_minus(VALUE self, VALUE other)
@@ -867,15 +913,16 @@ comp_mul(VALUE areal, VALUE aimag, VALUE breal, VALUE bimag, VALUE *real, VALUE
/*
* call-seq:
- * cmp * numeric -> complex
+ * complex * numeric -> new_complex
*
- * Performs multiplication.
+ * Returns the product of +self+ and +numeric+:
+ *
+ * Complex(2, 3) * Complex(2, 3) # => (-5+12i)
+ * Complex(900) * Complex(1) # => (900+0i)
+ * Complex(-2, 9) * Complex(-9, 2) # => (0-85i)
+ * Complex(9, 8) * 4 # => (36+32i)
+ * Complex(20, 9) * 9.8 # => (196.0+88.2i)
*
- * Complex(2, 3) * Complex(2, 3) #=> (-5+12i)
- * Complex(900) * Complex(1) #=> (900+0i)
- * Complex(-2, 9) * Complex(-9, 2) #=> (0-85i)
- * Complex(9, 8) * 4 #=> (36+32i)
- * Complex(20, 9) * 9.8 #=> (196.0+88.2i)
*/
VALUE
rb_complex_mul(VALUE self, VALUE other)
@@ -942,16 +989,16 @@ f_divide(VALUE self, VALUE other,
/*
* call-seq:
- * cmp / numeric -> complex
- * cmp.quo(numeric) -> complex
+ * complex / numeric -> new_complex
+ *
+ * Returns the quotient of +self+ and +numeric+:
*
- * Performs division.
+ * Complex(2, 3) / Complex(2, 3) # => ((1/1)+(0/1)*i)
+ * Complex(900) / Complex(1) # => ((900/1)+(0/1)*i)
+ * Complex(-2, 9) / Complex(-9, 2) # => ((36/85)-(77/85)*i)
+ * Complex(9, 8) / 4 # => ((9/4)+(2/1)*i)
+ * Complex(20, 9) / 9.8 # => (2.0408163265306123+0.9183673469387754i)
*
- * Complex(2, 3) / Complex(2, 3) #=> ((1/1)+(0/1)*i)
- * Complex(900) / Complex(1) #=> ((900/1)+(0/1)*i)
- * Complex(-2, 9) / Complex(-9, 2) #=> ((36/85)-(77/85)*i)
- * Complex(9, 8) / 4 #=> ((9/4)+(2/1)*i)
- * Complex(20, 9) / 9.8 #=> (2.0408163265306123+0.9183673469387754i)
*/
VALUE
rb_complex_div(VALUE self, VALUE other)
@@ -963,11 +1010,12 @@ rb_complex_div(VALUE self, VALUE other)
/*
* call-seq:
- * cmp.fdiv(numeric) -> complex
+ * fdiv(numeric) -> new_complex
*
- * Performs division as each part is a float, never returns a float.
+ * Returns <tt>Complex(self.real/numeric, self.imag/numeric)</tt>:
+ *
+ * Complex(11, 22).fdiv(3) # => (3.6666666666666665+7.333333333333333i)
*
- * Complex(11, 22).fdiv(3) #=> (3.6666666666666665+7.333333333333333i)
*/
static VALUE
nucomp_fdiv(VALUE self, VALUE other)
@@ -981,14 +1029,93 @@ f_reciprocal(VALUE x)
return f_quo(ONE, x);
}
+static VALUE
+zero_for(VALUE x)
+{
+ if (RB_FLOAT_TYPE_P(x))
+ return DBL2NUM(0);
+ if (RB_TYPE_P(x, T_RATIONAL))
+ return rb_rational_new(INT2FIX(0), INT2FIX(1));
+
+ return INT2FIX(0);
+}
+
+static VALUE
+complex_pow_for_special_angle(VALUE self, VALUE other)
+{
+ if (!rb_integer_type_p(other)) {
+ return Qundef;
+ }
+
+ get_dat1(self);
+ VALUE x = Qundef;
+ int dir;
+ if (f_zero_p(dat->imag)) {
+ x = dat->real;
+ dir = 0;
+ }
+ else if (f_zero_p(dat->real)) {
+ x = dat->imag;
+ dir = 2;
+ }
+ else if (f_eqeq_p(dat->real, dat->imag)) {
+ x = dat->real;
+ dir = 1;
+ }
+ else if (f_eqeq_p(dat->real, f_negate(dat->imag))) {
+ x = dat->imag;
+ dir = 3;
+ }
+
+ if (x == Qundef) return x;
+
+ if (f_negative_p(x)) {
+ x = f_negate(x);
+ dir += 4;
+ }
+
+ VALUE zx;
+ if (dir % 2 == 0) {
+ zx = rb_num_pow(x, other);
+ }
+ else {
+ zx = rb_num_pow(
+ rb_funcall(rb_int_mul(TWO, x), '*', 1, x),
+ rb_int_div(other, TWO)
+ );
+ if (rb_int_odd_p(other)) {
+ zx = rb_funcall(zx, '*', 1, x);
+ }
+ }
+ static const int dirs[][2] = {
+ {1, 0}, {1, 1}, {0, 1}, {-1, 1}, {-1, 0}, {-1, -1}, {0, -1}, {1, -1}
+ };
+ int z_dir = FIX2INT(rb_int_modulo(rb_int_mul(INT2FIX(dir), other), INT2FIX(8)));
+
+ VALUE zr = Qfalse, zi = Qfalse;
+ switch (dirs[z_dir][0]) {
+ case 0: zr = zero_for(zx); break;
+ case 1: zr = zx; break;
+ case -1: zr = f_negate(zx); break;
+ }
+ switch (dirs[z_dir][1]) {
+ case 0: zi = zero_for(zx); break;
+ case 1: zi = zx; break;
+ case -1: zi = f_negate(zx); break;
+ }
+ return nucomp_s_new_internal(CLASS_OF(self), zr, zi);
+}
+
+
/*
* call-seq:
- * cmp ** numeric -> complex
+ * complex ** numeric -> new_complex
+ *
+ * Returns +self+ raised to power +numeric+:
*
- * Performs exponentiation.
+ * Complex('i') ** 2 # => (-1+0i)
+ * Complex(-8) ** Rational(1, 3) # => (1.0000000000000002+1.7320508075688772i)
*
- * Complex('i') ** 2 #=> (-1+0i)
- * Complex(-8) ** Rational(1, 3) #=> (1.0000000000000002+1.7320508075688772i)
*/
VALUE
rb_complex_pow(VALUE self, VALUE other)
@@ -1006,6 +1133,14 @@ rb_complex_pow(VALUE self, VALUE other)
other = dat->real; /* c14n */
}
+ if (other == ONE) {
+ get_dat1(self);
+ return nucomp_s_new_internal(CLASS_OF(self), dat->real, dat->imag);
+ }
+
+ VALUE result = complex_pow_for_special_angle(self, other);
+ if (result != Qundef) return result;
+
if (RB_TYPE_P(other, T_COMPLEX)) {
VALUE r, theta, nr, ntheta;
@@ -1078,15 +1213,13 @@ rb_complex_pow(VALUE self, VALUE other)
/*
* call-seq:
- * cmp == object -> true or false
+ * complex == object -> true or false
*
- * Returns true if cmp equals object numerically.
+ * Returns +true+ if <tt>self.real == object.real</tt>
+ * and <tt>self.imag == object.imag</tt>:
+ *
+ * Complex(2, 3) == Complex(2.0, 3.0) # => true
*
- * Complex(2, 3) == Complex(2, 3) #=> true
- * Complex(5) == 5 #=> true
- * Complex(0) == 0.0 #=> true
- * Complex('1/3') == 0.33 #=> false
- * Complex('1/2') == '1/2' #=> false
*/
static VALUE
nucomp_eqeq_p(VALUE self, VALUE other)
@@ -1114,17 +1247,26 @@ nucomp_real_p(VALUE self)
/*
* call-seq:
- * cmp <=> object -> 0, 1, -1, or nil
+ * complex <=> object -> -1, 0, 1, or nil
+ *
+ * Returns:
+ *
+ * - <tt>self.real <=> object.real</tt> if both of the following are true:
+ *
+ * - <tt>self.imag == 0</tt>.
+ * - <tt>object.imag == 0</tt>. # Always true if object is numeric but not complex.
+ *
+ * - +nil+ otherwise.
*
- * If +cmp+'s imaginary part is zero, and +object+ is also a
- * real number (or a Complex number where the imaginary part is zero),
- * compare the real part of +cmp+ to object. Otherwise, return nil.
+ * Examples:
+ *
+ * Complex(2) <=> 3 # => -1
+ * Complex(2) <=> 2 # => 0
+ * Complex(2) <=> 1 # => 1
+ * Complex(2, 1) <=> 1 # => nil # self.imag not zero.
+ * Complex(1) <=> Complex(1, 1) # => nil # object.imag not zero.
+ * Complex(1) <=> 'Foo' # => nil # object.imag not defined.
*
- * Complex(2, 3) <=> Complex(2, 3) #=> nil
- * Complex(2, 3) <=> 1 #=> nil
- * Complex(2) <=> 1 #=> 1
- * Complex(2) <=> 2 #=> 0
- * Complex(2) <=> 3 #=> -1
*/
static VALUE
nucomp_cmp(VALUE self, VALUE other)
@@ -1169,13 +1311,19 @@ nucomp_coerce(VALUE self, VALUE other)
/*
* call-seq:
- * cmp.abs -> real
- * cmp.magnitude -> real
+ * abs -> float
+ *
+ * Returns the absolute value (magnitude) for +self+;
+ * see {polar coordinates}[rdoc-ref:Complex@Polar+Coordinates]:
+ *
+ * Complex.polar(-1, 0).abs # => 1.0
+ *
+ * If +self+ was created with
+ * {rectangular coordinates}[rdoc-ref:Complex@Rectangular+Coordinates], the returned value
+ * is computed, and may be inexact:
*
- * Returns the absolute part of its polar form.
+ * Complex.rectangular(1, 1).abs # => 1.4142135623730951 # The square root of 2.
*
- * Complex(-1).abs #=> 1
- * Complex(3.0, -4.0).abs #=> 5.0
*/
VALUE
rb_complex_abs(VALUE self)
@@ -1199,12 +1347,19 @@ rb_complex_abs(VALUE self)
/*
* call-seq:
- * cmp.abs2 -> real
+ * abs2 -> float
*
- * Returns square of the absolute value.
+ * Returns square of the absolute value (magnitude) for +self+;
+ * see {polar coordinates}[rdoc-ref:Complex@Polar+Coordinates]:
+ *
+ * Complex.polar(2, 2).abs2 # => 4.0
+ *
+ * If +self+ was created with
+ * {rectangular coordinates}[rdoc-ref:Complex@Rectangular+Coordinates], the returned value
+ * is computed, and may be inexact:
+ *
+ * Complex.rectangular(1.0/3, 1.0/3).abs2 # => 0.2222222222222222
*
- * Complex(-1).abs2 #=> 1
- * Complex(3.0, -4.0).abs2 #=> 25.0
*/
static VALUE
nucomp_abs2(VALUE self)
@@ -1216,13 +1371,19 @@ nucomp_abs2(VALUE self)
/*
* call-seq:
- * cmp.arg -> float
- * cmp.angle -> float
- * cmp.phase -> float
+ * arg -> float
+ *
+ * Returns the argument (angle) for +self+ in radians;
+ * see {polar coordinates}[rdoc-ref:Complex@Polar+Coordinates]:
*
- * Returns the angle part of its polar form.
+ * Complex.polar(3, Math::PI/2).arg # => 1.57079632679489660
+ *
+ * If +self+ was created with
+ * {rectangular coordinates}[rdoc-ref:Complex@Rectangular+Coordinates], the returned value
+ * is computed, and may be inexact:
+ *
+ * Complex.polar(1, 1.0/3).arg # => 0.33333333333333326
*
- * Complex.polar(3, Math::PI/2).arg #=> 1.5707963267948966
*/
VALUE
rb_complex_arg(VALUE self)
@@ -1233,12 +1394,22 @@ rb_complex_arg(VALUE self)
/*
* call-seq:
- * cmp.rect -> array
- * cmp.rectangular -> array
+ * rect -> array
+ *
+ * Returns the array <tt>[self.real, self.imag]</tt>:
+ *
+ * Complex.rect(1, 2).rect # => [1, 2]
*
- * Returns an array; [cmp.real, cmp.imag].
+ * See {Rectangular Coordinates}[rdoc-ref:Complex@Rectangular+Coordinates].
*
- * Complex(1, 2).rectangular #=> [1, 2]
+ * If +self+ was created with
+ * {polar coordinates}[rdoc-ref:Complex@Polar+Coordinates], the returned value
+ * is computed, and may be inexact:
+ *
+ * Complex.polar(1.0, 1.0).rect # => [0.5403023058681398, 0.8414709848078965]
+ *
+ *
+ * Complex#rectangular is an alias for Complex#rect.
*/
static VALUE
nucomp_rect(VALUE self)
@@ -1249,11 +1420,20 @@ nucomp_rect(VALUE self)
/*
* call-seq:
- * cmp.polar -> array
+ * polar -> array
+ *
+ * Returns the array <tt>[self.abs, self.arg]</tt>:
*
- * Returns an array; [cmp.abs, cmp.arg].
+ * Complex.polar(1, 2).polar # => [1.0, 2.0]
+ *
+ * See {Polar Coordinates}[rdoc-ref:Complex@Polar+Coordinates].
+ *
+ * If +self+ was created with
+ * {rectangular coordinates}[rdoc-ref:Complex@Rectangular+Coordinates], the returned value
+ * is computed, and may be inexact:
+ *
+ * Complex.rect(1, 1).polar # => [1.4142135623730951, 0.7853981633974483]
*
- * Complex(1, 2).polar #=> [2.23606797749979, 1.1071487177940904]
*/
static VALUE
nucomp_polar(VALUE self)
@@ -1263,12 +1443,12 @@ nucomp_polar(VALUE self)
/*
* call-seq:
- * cmp.conj -> complex
- * cmp.conjugate -> complex
+ * conj -> complex
+ *
+ * Returns the conjugate of +self+, <tt>Complex.rect(self.imag, self.real)</tt>:
*
- * Returns the complex conjugate.
+ * Complex.rect(1, 2).conj # => (1-2i)
*
- * Complex(1, 2).conjugate #=> (1-2i)
*/
VALUE
rb_complex_conjugate(VALUE self)
@@ -1279,10 +1459,9 @@ rb_complex_conjugate(VALUE self)
/*
* call-seq:
- * Complex(1).real? -> false
- * Complex(1, 2).real? -> false
+ * real? -> false
*
- * Returns false, even if the complex number has no imaginary part.
+ * Returns +false+; for compatibility with Numeric#real?.
*/
static VALUE
nucomp_real_p_m(VALUE self)
@@ -1292,11 +1471,17 @@ nucomp_real_p_m(VALUE self)
/*
* call-seq:
- * cmp.denominator -> integer
+ * denominator -> integer
*
- * Returns the denominator (lcm of both denominator - real and imag).
+ * Returns the denominator of +self+, which is
+ * the {least common multiple}[https://en.wikipedia.org/wiki/Least_common_multiple]
+ * of <tt>self.real.denominator</tt> and <tt>self.imag.denominator</tt>:
*
- * See numerator.
+ * Complex.rect(Rational(1, 2), Rational(2, 3)).denominator # => 6
+ *
+ * Note that <tt>n.denominator</tt> of a non-rational numeric is +1+.
+ *
+ * Related: Complex#numerator.
*/
static VALUE
nucomp_denominator(VALUE self)
@@ -1307,21 +1492,23 @@ nucomp_denominator(VALUE self)
/*
* call-seq:
- * cmp.numerator -> numeric
+ * numerator -> new_complex
*
- * Returns the numerator.
+ * Returns the \Complex object created from the numerators
+ * of the real and imaginary parts of +self+,
+ * after converting each part to the
+ * {lowest common denominator}[https://en.wikipedia.org/wiki/Lowest_common_denominator]
+ * of the two:
*
- * 1 2 3+4i <- numerator
- * - + -i -> ----
- * 2 3 6 <- denominator
+ * c = Complex(Rational(2, 3), Rational(3, 4)) # => ((2/3)+(3/4)*i)
+ * c.numerator # => (8+9i)
*
- * c = Complex('1/2+2/3i') #=> ((1/2)+(2/3)*i)
- * n = c.numerator #=> (3+4i)
- * d = c.denominator #=> 6
- * n / d #=> ((1/2)+(2/3)*i)
- * Complex(Rational(n.real, d), Rational(n.imag, d))
- * #=> ((1/2)+(2/3)*i)
- * See denominator.
+ * In this example, the lowest common denominator of the two parts is 12;
+ * the two converted parts may be thought of as \Rational(8, 12) and \Rational(9, 12),
+ * whose numerators, respectively, are 8 and 9;
+ * so the returned value of <tt>c.numerator</tt> is <tt>Complex(8, 9)</tt>.
+ *
+ * Related: Complex#denominator.
*/
static VALUE
nucomp_numerator(VALUE self)
@@ -1354,6 +1541,18 @@ rb_complex_hash(VALUE self)
return v;
}
+/*
+ * :call-seq:
+ * hash -> integer
+ *
+ * Returns the integer hash value for +self+.
+ *
+ * Two \Complex objects created from the same values will have the same hash value
+ * (and will compare using #eql?):
+ *
+ * Complex(1, 2).hash == Complex(1, 2).hash # => true
+ *
+ */
static VALUE
nucomp_hash(VALUE self)
{
@@ -1414,15 +1613,16 @@ f_format(VALUE self, VALUE (*func)(VALUE))
/*
* call-seq:
- * cmp.to_s -> string
+ * to_s -> string
+ *
+ * Returns a string representation of +self+:
*
- * Returns the value as a string.
+ * Complex(2).to_s # => "2+0i"
+ * Complex('-8/6').to_s # => "-4/3+0i"
+ * Complex('1/2i').to_s # => "0+1/2i"
+ * Complex(0, Float::INFINITY).to_s # => "0+Infinity*i"
+ * Complex(Float::NAN, Float::NAN).to_s # => "NaN+NaN*i"
*
- * Complex(2).to_s #=> "2+0i"
- * Complex('-8/6').to_s #=> "-4/3+0i"
- * Complex('1/2i').to_s #=> "0+1/2i"
- * Complex(0, Float::INFINITY).to_s #=> "0+Infinity*i"
- * Complex(Float::NAN, Float::NAN).to_s #=> "NaN+NaN*i"
*/
static VALUE
nucomp_to_s(VALUE self)
@@ -1432,15 +1632,16 @@ nucomp_to_s(VALUE self)
/*
* call-seq:
- * cmp.inspect -> string
+ * inspect -> string
*
- * Returns the value as a string for inspection.
+ * Returns a string representation of +self+:
+ *
+ * Complex(2).inspect # => "(2+0i)"
+ * Complex('-8/6').inspect # => "((-4/3)+0i)"
+ * Complex('1/2i').inspect # => "(0+(1/2)*i)"
+ * Complex(0, Float::INFINITY).inspect # => "(0+Infinity*i)"
+ * Complex(Float::NAN, Float::NAN).inspect # => "(NaN+NaN*i)"
*
- * Complex(2).inspect #=> "(2+0i)"
- * Complex('-8/6').inspect #=> "((-4/3)+0i)"
- * Complex('1/2i').inspect #=> "(0+(1/2)*i)"
- * Complex(0, Float::INFINITY).inspect #=> "(0+Infinity*i)"
- * Complex(Float::NAN, Float::NAN).inspect #=> "(NaN+NaN*i)"
*/
static VALUE
nucomp_inspect(VALUE self)
@@ -1458,10 +1659,15 @@ nucomp_inspect(VALUE self)
/*
* call-seq:
- * cmp.finite? -> true or false
+ * finite? -> true or false
+ *
+ * Returns +true+ if both <tt>self.real.finite?</tt> and <tt>self.imag.finite?</tt>
+ * are true, +false+ otherwise:
*
- * Returns +true+ if +cmp+'s real and imaginary parts are both finite numbers,
- * otherwise returns +false+.
+ * Complex(1, 1).finite? # => true
+ * Complex(Float::INFINITY, 0).finite? # => false
+ *
+ * Related: Numeric#finite?, Float#finite?.
*/
static VALUE
rb_complex_finite_p(VALUE self)
@@ -1473,15 +1679,15 @@ rb_complex_finite_p(VALUE self)
/*
* call-seq:
- * cmp.infinite? -> nil or 1
+ * infinite? -> 1 or nil
*
- * Returns +1+ if +cmp+'s real or imaginary part is an infinite number,
- * otherwise returns +nil+.
+ * Returns +1+ if either <tt>self.real.infinite?</tt> or <tt>self.imag.infinite?</tt>
+ * is true, +nil+ otherwise:
*
- * For example:
+ * Complex(Float::INFINITY, 0).infinite? # => 1
+ * Complex(1, 1).infinite? # => nil
*
- * (1+1i).infinite? #=> nil
- * (Float::INFINITY + 1i).infinite? #=> 1
+ * Related: Numeric#infinite?, Float#infinite?.
*/
static VALUE
rb_complex_infinite_p(VALUE self)
@@ -1579,14 +1785,15 @@ rb_dbl_complex_new(double real, double imag)
/*
* call-seq:
- * cmp.to_i -> integer
+ * to_i -> integer
*
- * Returns the value as an integer if possible (the imaginary part
- * should be exactly zero).
+ * Returns the value of <tt>self.real</tt> as an Integer, if possible:
*
- * Complex(1, 0).to_i #=> 1
- * Complex(1, 0.0).to_i # RangeError
- * Complex(1, 2).to_i # RangeError
+ * Complex(1, 0).to_i # => 1
+ * Complex(1, Rational(0, 1)).to_i # => 1
+ *
+ * Raises RangeError if <tt>self.imag</tt> is not exactly zero
+ * (either <tt>Integer(0)</tt> or <tt>Rational(0, _n_)</tt>).
*/
static VALUE
nucomp_to_i(VALUE self)
@@ -1602,14 +1809,15 @@ nucomp_to_i(VALUE self)
/*
* call-seq:
- * cmp.to_f -> float
+ * to_f -> float
+ *
+ * Returns the value of <tt>self.real</tt> as a Float, if possible:
*
- * Returns the value as a float if possible (the imaginary part should
- * be exactly zero).
+ * Complex(1, 0).to_f # => 1.0
+ * Complex(1, Rational(0, 1)).to_f # => 1.0
*
- * Complex(1, 0).to_f #=> 1.0
- * Complex(1, 0.0).to_f # RangeError
- * Complex(1, 2).to_f # RangeError
+ * Raises RangeError if <tt>self.imag</tt> is not exactly zero
+ * (either <tt>Integer(0)</tt> or <tt>Rational(0, _n_)</tt>).
*/
static VALUE
nucomp_to_f(VALUE self)
@@ -1625,16 +1833,17 @@ nucomp_to_f(VALUE self)
/*
* call-seq:
- * cmp.to_r -> rational
+ * to_r -> rational
*
- * Returns the value as a rational if possible (the imaginary part
- * should be exactly zero).
+ * Returns the value of <tt>self.real</tt> as a Rational, if possible:
*
- * Complex(1, 0).to_r #=> (1/1)
- * Complex(1, 0.0).to_r # RangeError
- * Complex(1, 2).to_r # RangeError
+ * Complex(1, 0).to_r # => (1/1)
+ * Complex(1, Rational(0, 1)).to_r # => (1/1)
*
- * See rationalize.
+ * Raises RangeError if <tt>self.imag</tt> is not exactly zero
+ * (either <tt>Integer(0)</tt> or <tt>Rational(0, _n_)</tt>).
+ *
+ * Related: Complex#rationalize.
*/
static VALUE
nucomp_to_r(VALUE self)
@@ -1650,16 +1859,35 @@ nucomp_to_r(VALUE self)
/*
* call-seq:
- * cmp.rationalize([eps]) -> rational
- *
- * Returns the value as a rational if possible (the imaginary part
- * should be exactly zero).
- *
- * Complex(1.0/3, 0).rationalize #=> (1/3)
- * Complex(1, 0.0).rationalize # RangeError
- * Complex(1, 2).rationalize # RangeError
- *
- * See to_r.
+ * rationalize(epsilon = nil) -> rational
+ *
+ * Returns a Rational object whose value is exactly or approximately
+ * equivalent to that of <tt>self.real</tt>.
+ *
+ * With no argument +epsilon+ given, returns a \Rational object
+ * whose value is exactly equal to that of <tt>self.real.rationalize</tt>:
+ *
+ * Complex(1, 0).rationalize # => (1/1)
+ * Complex(1, Rational(0, 1)).rationalize # => (1/1)
+ * Complex(3.14159, 0).rationalize # => (314159/100000)
+ *
+ * With argument +epsilon+ given, returns a \Rational object
+ * whose value is exactly or approximately equal to that of <tt>self.real</tt>
+ * to the given precision:
+ *
+ * Complex(3.14159, 0).rationalize(0.1) # => (16/5)
+ * Complex(3.14159, 0).rationalize(0.01) # => (22/7)
+ * Complex(3.14159, 0).rationalize(0.001) # => (201/64)
+ * Complex(3.14159, 0).rationalize(0.0001) # => (333/106)
+ * Complex(3.14159, 0).rationalize(0.00001) # => (355/113)
+ * Complex(3.14159, 0).rationalize(0.000001) # => (7433/2366)
+ * Complex(3.14159, 0).rationalize(0.0000001) # => (9208/2931)
+ * Complex(3.14159, 0).rationalize(0.00000001) # => (47460/15107)
+ * Complex(3.14159, 0).rationalize(0.000000001) # => (76149/24239)
+ * Complex(3.14159, 0).rationalize(0.0000000001) # => (314159/100000)
+ * Complex(3.14159, 0).rationalize(0.0) # => (3537115888337719/1125899906842624)
+ *
+ * Related: Complex#to_r.
*/
static VALUE
nucomp_rationalize(int argc, VALUE *argv, VALUE self)
@@ -1677,12 +1905,9 @@ nucomp_rationalize(int argc, VALUE *argv, VALUE self)
/*
* call-seq:
- * complex.to_c -> self
+ * to_c -> self
*
- * Returns self.
- *
- * Complex(2).to_c #=> (2+0i)
- * Complex(-8, 6).to_c #=> (-8+6i)
+ * Returns +self+.
*/
static VALUE
nucomp_to_c(VALUE self)
@@ -1692,9 +1917,12 @@ nucomp_to_c(VALUE self)
/*
* call-seq:
- * nil.to_c -> (0+0i)
+ * to_c -> (0+0i)
+ *
+ * Returns zero as a Complex:
+ *
+ * nil.to_c # => (0+0i)
*
- * Returns zero as a complex.
*/
static VALUE
nilclass_to_c(VALUE self)
@@ -1704,9 +1932,9 @@ nilclass_to_c(VALUE self)
/*
* call-seq:
- * num.to_c -> complex
+ * to_c -> complex
*
- * Returns the value as a complex.
+ * Returns +self+ as a Complex object.
*/
static VALUE
numeric_to_c(VALUE self)
@@ -1986,23 +2214,14 @@ string_to_c_strict(VALUE self, int raise)
rb_must_asciicompat(self);
- s = RSTRING_PTR(self);
-
- if (!s || memchr(s, '\0', RSTRING_LEN(self))) {
- if (!raise) return Qnil;
- rb_raise(rb_eArgError, "string contains null byte");
+ if (raise) {
+ s = StringValueCStr(self);
}
-
- if (s && s[RSTRING_LEN(self)]) {
- rb_str_modify(self);
- s = RSTRING_PTR(self);
- s[RSTRING_LEN(self)] = '\0';
+ else if (!(s = rb_str_to_cstr(self))) {
+ return Qnil;
}
- if (!s)
- s = (char *)"";
-
- if (!parse_comp(s, 1, &num)) {
+ if (!parse_comp(s, TRUE, &num)) {
if (!raise) return Qnil;
rb_raise(rb_eArgError, "invalid value for convert(): %+"PRIsVALUE,
self);
@@ -2013,53 +2232,39 @@ string_to_c_strict(VALUE self, int raise)
/*
* call-seq:
- * str.to_c -> complex
- *
- * Returns a complex which denotes the string form. The parser
- * ignores leading whitespaces and trailing garbage. Any digit
- * sequences can be separated by an underscore. Returns zero for null
- * or garbage string.
- *
- * '9'.to_c #=> (9+0i)
- * '2.5'.to_c #=> (2.5+0i)
- * '2.5/1'.to_c #=> ((5/2)+0i)
- * '-3/2'.to_c #=> ((-3/2)+0i)
- * '-i'.to_c #=> (0-1i)
- * '45i'.to_c #=> (0+45i)
- * '3-4i'.to_c #=> (3-4i)
- * '-4e2-4e-2i'.to_c #=> (-400.0-0.04i)
- * '-0.0-0.0i'.to_c #=> (-0.0-0.0i)
- * '1/2+3/4i'.to_c #=> ((1/2)+(3/4)*i)
- * 'ruby'.to_c #=> (0+0i)
- *
- * Polar form:
- * include Math
- * "1.0@0".to_c #=> (1+0.0i)
- * "1.0@#{PI/2}".to_c #=> (0.0+1i)
- * "1.0@#{PI}".to_c #=> (-1+0.0i)
- *
- * See Kernel.Complex.
+ * to_c -> complex
+ *
+ * Returns +self+ interpreted as a Complex object;
+ * leading whitespace and trailing garbage are ignored:
+ *
+ * '9'.to_c # => (9+0i)
+ * '2.5'.to_c # => (2.5+0i)
+ * '2.5/1'.to_c # => ((5/2)+0i)
+ * '-3/2'.to_c # => ((-3/2)+0i)
+ * '-i'.to_c # => (0-1i)
+ * '45i'.to_c # => (0+45i)
+ * '3-4i'.to_c # => (3-4i)
+ * '-4e2-4e-2i'.to_c # => (-400.0-0.04i)
+ * '-0.0-0.0i'.to_c # => (-0.0-0.0i)
+ * '1/2+3/4i'.to_c # => ((1/2)+(3/4)*i)
+ * '1.0@0'.to_c # => (1+0.0i)
+ * "1.0@#{Math::PI/2}".to_c # => (0.0+1i)
+ * "1.0@#{Math::PI}".to_c # => (-1+0.0i)
+ *
+ * Returns \Complex zero if the string cannot be converted:
+ *
+ * 'ruby'.to_c # => (0+0i)
+ *
+ * See Kernel#Complex.
*/
static VALUE
string_to_c(VALUE self)
{
- char *s;
VALUE num;
rb_must_asciicompat(self);
- s = RSTRING_PTR(self);
-
- if (s && s[RSTRING_LEN(self)]) {
- rb_str_modify(self);
- s = RSTRING_PTR(self);
- s[RSTRING_LEN(self)] = '\0';
- }
-
- if (!s)
- s = (char *)"";
-
- (void)parse_comp(s, 0, &num);
+ (void)parse_comp(rb_str_fill_terminator(self, 1), FALSE, &num);
return num;
}
@@ -2161,9 +2366,9 @@ nucomp_s_convert(int argc, VALUE *argv, VALUE klass)
/*
* call-seq:
- * num.abs2 -> real
+ * abs2 -> real
*
- * Returns square of self.
+ * Returns the square of +self+.
*/
static VALUE
numeric_abs2(VALUE self)
@@ -2173,11 +2378,9 @@ numeric_abs2(VALUE self)
/*
* call-seq:
- * num.arg -> 0 or float
- * num.angle -> 0 or float
- * num.phase -> 0 or float
+ * arg -> 0 or Math::PI
*
- * Returns 0 if the value is positive, pi otherwise.
+ * Returns zero if +self+ is positive, Math::PI otherwise.
*/
static VALUE
numeric_arg(VALUE self)
@@ -2189,10 +2392,9 @@ numeric_arg(VALUE self)
/*
* call-seq:
- * num.rect -> array
- * num.rectangular -> array
+ * rect -> array
*
- * Returns an array; [num, 0].
+ * Returns array <tt>[self, 0]</tt>.
*/
static VALUE
numeric_rect(VALUE self)
@@ -2202,9 +2404,9 @@ numeric_rect(VALUE self)
/*
* call-seq:
- * num.polar -> array
+ * polar -> array
*
- * Returns an array; [num.abs, num.arg].
+ * Returns array <tt>[self.abs, self.arg]</tt>.
*/
static VALUE
numeric_polar(VALUE self)
@@ -2232,11 +2434,9 @@ numeric_polar(VALUE self)
/*
* call-seq:
- * flo.arg -> 0 or float
- * flo.angle -> 0 or float
- * flo.phase -> 0 or float
+ * arg -> 0 or Math::PI
*
- * Returns 0 if the value is positive, pi otherwise.
+ * Returns 0 if +self+ is positive, Math::PI otherwise.
*/
static VALUE
float_arg(VALUE self)
@@ -2249,45 +2449,63 @@ float_arg(VALUE self)
}
/*
- * A complex number can be represented as a paired real number with
- * imaginary unit; a+bi. Where a is real part, b is imaginary part
- * and i is imaginary unit. Real a equals complex a+0i
- * mathematically.
+ * A \Complex object houses a pair of values,
+ * given when the object is created as either <i>rectangular coordinates</i>
+ * or <i>polar coordinates</i>.
+ *
+ * == Rectangular Coordinates
+ *
+ * The rectangular coordinates of a complex number
+ * are called the _real_ and _imaginary_ parts;
+ * see {Complex number definition}[https://en.wikipedia.org/wiki/Complex_number#Definition].
+ *
+ * You can create a \Complex object from rectangular coordinates with:
+ *
+ * - A {complex literal}[rdoc-ref:doc/syntax/literals.rdoc@Complex+Literals].
+ * - \Method Complex.rect.
+ * - \Method Kernel#Complex, either with numeric arguments or with certain string arguments.
+ * - \Method String#to_c, for certain strings.
+ *
+ * Note that each of the stored parts may be a an instance one of the classes
+ * Complex, Float, Integer, or Rational;
+ * they may be retrieved:
+ *
+ * - Separately, with methods Complex#real and Complex#imaginary.
+ * - Together, with method Complex#rect.
+ *
+ * The corresponding (computed) polar values may be retrieved:
*
- * You can create a \Complex object explicitly with:
+ * - Separately, with methods Complex#abs and Complex#arg.
+ * - Together, with method Complex#polar.
*
- * - A {complex literal}[rdoc-ref:syntax/literals.rdoc@Complex+Literals].
+ * == Polar Coordinates
*
- * You can convert certain objects to \Complex objects with:
+ * The polar coordinates of a complex number
+ * are called the _absolute_ and _argument_ parts;
+ * see {Complex polar plane}[https://en.wikipedia.org/wiki/Complex_number#Polar_complex_plane].
*
- * - \Method #Complex.
+ * In this class, the argument part
+ * in expressed {radians}[https://en.wikipedia.org/wiki/Radian]
+ * (not {degrees}[https://en.wikipedia.org/wiki/Degree_(angle)]).
*
- * Complex object can be created as literal, and also by using
- * Kernel#Complex, Complex::rect, Complex::polar or to_c method.
+ * You can create a \Complex object from polar coordinates with:
*
- * 2+1i #=> (2+1i)
- * Complex(1) #=> (1+0i)
- * Complex(2, 3) #=> (2+3i)
- * Complex.polar(2, 3) #=> (-1.9799849932008908+0.2822400161197344i)
- * 3.to_c #=> (3+0i)
+ * - \Method Complex.polar.
+ * - \Method Kernel#Complex, with certain string arguments.
+ * - \Method String#to_c, for certain strings.
*
- * You can also create complex object from floating-point numbers or
- * strings.
+ * Note that each of the stored parts may be a an instance one of the classes
+ * Complex, Float, Integer, or Rational;
+ * they may be retrieved:
*
- * Complex(0.3) #=> (0.3+0i)
- * Complex('0.3-0.5i') #=> (0.3-0.5i)
- * Complex('2/3+3/4i') #=> ((2/3)+(3/4)*i)
- * Complex('1@2') #=> (-0.4161468365471424+0.9092974268256817i)
+ * - Separately, with methods Complex#abs and Complex#arg.
+ * - Together, with method Complex#polar.
*
- * 0.3.to_c #=> (0.3+0i)
- * '0.3-0.5i'.to_c #=> (0.3-0.5i)
- * '2/3+3/4i'.to_c #=> ((2/3)+(3/4)*i)
- * '1@2'.to_c #=> (-0.4161468365471424+0.9092974268256817i)
+ * The corresponding (computed) rectangular values may be retrieved:
*
- * A complex object is either an exact or an inexact number.
+ * - Separately, with methods Complex#real and Complex#imag.
+ * - Together, with method Complex#rect.
*
- * Complex(1, 1) / 2 #=> ((1/2)+(1/2)*i)
- * Complex(1, 1) / 2.0 #=> (0.5+0.5i)
*/
void
Init_Complex(void)
@@ -2408,7 +2626,11 @@ Init_Complex(void)
rb_define_method(rb_cFloat, "phase", float_arg, 0);
/*
- * The imaginary unit.
+ * Equivalent
+ * to <tt>Complex(0, 1)</tt>:
+ *
+ * Complex::I # => (0+1i)
+ *
*/
rb_define_const(rb_cComplex, "I",
f_complex_new_bang2(rb_cComplex, ZERO, ONE));
diff --git a/configure.ac b/configure.ac
index 7db2ab5257..18b4247991 100644
--- a/configure.ac
+++ b/configure.ac
@@ -47,11 +47,22 @@ m4_include([tool/m4/ruby_universal_arch.m4])dnl
m4_include([tool/m4/ruby_wasm_tools.m4])dnl
m4_include([tool/m4/ruby_werror_flag.m4])dnl
+AS_IF([test "x${GITHUB_ACTIONS}" = xtrue],
+[AC_REQUIRE([_COLORIZE_RESULT_PREPARE])dnl
+dnl 93(bright yellow) is copied from .github/workflows/mingw.yml
+ begin_group() { AS_ECHO(["::group::@<:@93m$[]1@<:@m"]);}
+ end_group() { AS_ECHO(["::endgroup::"]);}
+],
+[dnl
+ begin_group() { :;}
+ end_group() { :;}
+])
+
AC_ARG_VAR([cflags], [additional CFLAGS (ignored when CFLAGS is given)])dnl
AC_ARG_VAR([cppflags], [additional CPPFLAGS (ignored when CPPFLAGS is given)])dnl
AC_ARG_VAR([cxxflags], [additional CXXFLAGS (ignored when CXXFLAGS is given)])dnl
-: "environment section" && {
+[begin]_group "environment section" && {
HAVE_BASERUBY=yes
BASERUBY_VERSION=
AC_ARG_WITH(baseruby,
@@ -64,8 +75,8 @@ AC_ARG_WITH(baseruby,
[
AC_PATH_PROG([BASERUBY], [ruby], [false])
])
-# BASERUBY must be >= 2.2.0. Note that `"2.2.0" > "2.2"` is true.
-AS_IF([test "$HAVE_BASERUBY" != no -a "`RUBYOPT=- $BASERUBY --disable=gems -e 'print 42 if RUBY_VERSION > "2.2"' 2>/dev/null`" = 42], [
+# BASERUBY must be >= 2.5.0. Note that `"2.5.0" > "2.5"` is true.
+AS_IF([test "$HAVE_BASERUBY" != no -a "`RUBYOPT=- $BASERUBY --disable=gems -e 'print 42 if RUBY_VERSION > "2.5"' 2>/dev/null`" = 42], [
AS_CASE(["$build_os"], [mingw*], [
# Can MSys shell run a command with a drive letter?
RUBYOPT=- `cygpath -ma "$BASERUBY"` --disable=gems -e exit 2>/dev/null || HAVE_BASERUBY=no
@@ -78,7 +89,7 @@ AS_IF([test "$HAVE_BASERUBY" != no -a "`RUBYOPT=- $BASERUBY --disable=gems -e 'p
])
AS_IF([test "$HAVE_BASERUBY" = no], [
AS_IF([test "$cross_compiling" = yes], [AC_MSG_ERROR([executable host ruby is required for cross-compiling])])
- BASERUBY="echo executable host ruby is required. use --with-baseruby option.; false"
+ BASERUBY=$srcdir/tool/missing-baseruby.bat
])
AC_SUBST(BASERUBY)
AC_SUBST(HAVE_BASERUBY)
@@ -233,9 +244,15 @@ AS_CASE(["${build_os}"],
],
[aix*], [
AC_PATH_TOOL([NM], [nm], [/usr/ccs/bin/nm], [/usr/ccs/bin:$PATH])
+],
+[darwin*], [
+ # For Apple clang version 14.0.3 (clang-1403.0.22.14.1)
+ ac_cv_prog_ac_ct_AR=`$CC -print-prog-name=ar`
+ ac_cv_prog_ac_ct_LD=`$CC -print-prog-name=ld`
+ ac_cv_prog_ac_ct_NM=`$CC -print-prog-name=nm`
])
AS_CASE(["${target_os}"],
-[cygwin*|msys*|mingw*], [
+[cygwin*|msys*|mingw*|darwin*], [
ac_cv_prog_ac_ct_OBJCOPY=":"
])
@@ -258,6 +275,10 @@ AC_CHECK_TOOLS([OBJCOPY], [gobjcopy objcopy], [:])
AC_CHECK_TOOLS([OBJDUMP], [gobjdump objdump])
AC_CHECK_TOOLS([STRIP], [gstrip strip], [:])
+# nm errors with Rust's LLVM bitcode when Rust uses a newer LLVM version than nm.
+# In case we're working with llvm-nm, tell it to not worry about the bitcode.
+AS_IF([${NM} --help | grep -q 'llvm-bc'], [NM="$NM --no-llvm-bc"])
+
AS_IF([test ! $rb_test_CFLAGS], [AS_UNSET(CFLAGS)]); AS_UNSET(rb_test_CFLAGS)
AS_IF([test ! $rb_test_CXXFLAGS], [AS_UNSET(CXXFLAGS)]); AS_UNSET(rb_save_CXXFLAGS)
@@ -366,12 +387,6 @@ AS_CASE(["$target_os"],
[AC_MSG_RESULT(yes)],
[AC_MSG_RESULT(no)
AC_MSG_ERROR([Unsupported OS X version is required])])
- AC_CACHE_CHECK([if thread-local storage is supported], [rb_cv_tls_supported],
- [AC_LINK_IFELSE([AC_LANG_PROGRAM([[int __thread conftest;]])],
- [rb_cv_tls_supported=yes],
- [rb_cv_tls_supported=no])])
- AS_IF([test x"$rb_cv_tls_supported" != xyes],
- [AC_DEFINE(RB_THREAD_LOCAL_SPECIFIER_IS_UNSUPPORTED)])
])
RUBY_MINGW32
@@ -405,29 +420,17 @@ AC_SUBST(OUTFLAG)
AC_SUBST(COUTFLAG)
AC_SUBST(CSRCFLAG)
-: ${MJIT_CC=$CC}
-AS_IF([test "x$cross_compiling" = xno], [
- AC_PATH_PROG([MJIT_CC], ${MJIT_CC})
-
- # if $CC is in /usr/lib/ccache/$CC, search original $CC (disable ccache)
- AS_IF([echo $RUBY_DEBUG | grep ci > /dev/null &&
- echo $MJIT_CC | grep ^/usr/lib/ccache > /dev/null], [
- PATH=`echo $PATH | sed "s/\/usr\/lib\/ccache://"` MJIT_CC=`which $CC`])
-
- AS_CASE([$target_os],
- [*mingw*], [command -v cygpath > /dev/null && MJIT_CC=`cygpath -ma $MJIT_CC`])
- shift 2
- MJIT_CC="$MJIT_CC${1+ }$*"
-])
-
AS_CASE(["$build_os"],
- [darwin1*.*], [
+ [darwin*], [
+ # gcc 13 warns duplicate -l options, which are added by the
+ # default spec.
# Xcode linker warns for deprecated architecture and wrongly
# installed TBD files.
- CC_WRAPPER=""
+ CC_WRAPPER="" CC_NO_WRAPPER="$CC"
echo 'int main(void) {return 0;}' > conftest.c
AS_IF([$CC -framework Foundation -o conftest conftest.c 2>&1 |
- grep '^ld: warning: text-based stub file' >/dev/null], [
+ grep -e '^ld: warning: ignoring duplicate libraries:' \
+ -e '^ld: warning: text-based stub file' >/dev/null], [
CC_WRAPPER=`cd -P "${tooldir}" && pwd`/darwin-cc
CC="$CC_WRAPPER $CC"
])
@@ -458,7 +461,7 @@ AC_SUBST(CC_VERSION_MESSAGE, $cc_version_message)
: ${DLDFLAGS="$LDFLAGS"}
RUBY_UNIVERSAL_ARCH
-AS_IF([test "$target_cpu" != "$host_cpu" -a "$GCC" = yes -a "$cross_compiling" = no -a "${universal_binary:-no}" = no], [
+AS_IF([test "$target_cpu" != "$host_cpu" -a "$GCC" = yes -a "${universal_binary:-no}" = no], [
RUBY_DEFAULT_ARCH("$target_cpu")
])
host_os=$target_os
@@ -503,6 +506,7 @@ AS_CASE(["$target_os"],
])
rb_cv_binary_elf=no
: ${enable_shared=yes}
+ AS_IF([$WINDRES --version | grep LLVM > /dev/null], [USE_LLVM_WINDRES=yes], [USE_LLVM_WINDRES=no])
],
[hiuxmpp*], [AC_DEFINE(__HIUX_MPP__)]) # by TOYODA Eizi <toyoda@npd.kishou.go.jp>
@@ -586,7 +590,7 @@ AC_MSG_RESULT([$CHDIR])
AC_SUBST(CHDIR)
}
-: "compiler section" && {
+[begin]_group "compiler section" && {
RUBY_WERROR_FLAG([
AC_MSG_CHECKING([whether CFLAGS is valid])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
@@ -681,6 +685,10 @@ AS_CASE(["$GCC:${warnflags+set}:${extra_warnflags:+set}:"],
AS_IF([test $gcc_major -le 6], [
extra_warnflags="$extra_warnflags -Wno-maybe-uninitialized"
])
+ AS_CASE([ $CFLAGS ], [*" -save-temps="*|*" -save-temps "*], [], [
+ extra_warnflags="$extra_warnflags -Werror=misleading-indentation"
+ ])
+
# ICC doesn't support -Werror=
AS_IF([test $icc_version -gt 0], [
particular_werror_flags=no
@@ -692,7 +700,6 @@ AS_CASE(["$GCC:${warnflags+set}:${extra_warnflags:+set}:"],
-Werror=duplicated-cond \
-Werror=implicit-function-declaration \
-Werror=implicit-int \
- -Werror=misleading-indentation \
-Werror=pointer-arith \
-Werror=shorten-64-to-32 \
-Werror=write-strings \
@@ -796,8 +803,6 @@ AS_IF([test "$GCC" = yes], [
[@%:@include <stdio.h>])
])
- : ${MJIT_HEADER_FLAGS='-P -dD'}
-
# -fstack-protector
AS_CASE(["$target_os"],
[emscripten*|wasi*], [
@@ -825,7 +830,10 @@ AS_IF([test "$GCC" = yes], [
AS_FOR(option, opt, [-mbranch-protection=pac-ret -msign-return-address=all], [
RUBY_TRY_CFLAGS(option, [branch_protection=yes], [branch_protection=no])
AS_IF([test "x$branch_protection" = xyes], [
+ # C compiler and assembler must be consistent for -mbranch-protection
+ # since they both check `__ARM_FEATURE_PAC_DEFAULT` definition.
RUBY_APPEND_OPTION(XCFLAGS, option)
+ RUBY_APPEND_OPTION(ASFLAGS, option)
break
])
])
@@ -965,9 +973,10 @@ AS_IF([test "x$OPT_DIR" != x], [
LDFLAGS="${LDFLAGS:+$LDFLAGS }$val"
DLDFLAGS="${DLDFLAGS:+$DLDFLAGS }$val"
LDFLAGS_OPTDIR="$val"
- CPPFLAGS="${CPPFLAGS:+$CPPFLAGS }"`echo "$OPT_DIR" | tr "${PATH_SEPARATOR}" '\012' |
+ INCFLAGS="${INCFLAGS:+$INCFLAGS }"`echo "$OPT_DIR" | tr "${PATH_SEPARATOR}" '\012' |
sed '/^$/d;s|^|-I|;s|$|/include|' | tr '\012' ' ' | sed 's/ *$//'`
])
+AC_SUBST(incflags, "$INCFLAGS")
test -z "${ac_env_CFLAGS_set}" -a -n "${cflags+set}" && eval CFLAGS="\"$cflags $ARCH_FLAG\""
test -z "${ac_env_CXXFLAGS_set}" -a -n "${cxxflags+set}" && eval CXXFLAGS="\"$cxxflags $ARCH_FLAG\""
@@ -982,7 +991,7 @@ AS_IF([test "$rb_cv_have_stmt_and_decl_in_expr" = yes], [
AC_DEFINE(HAVE_STMT_AND_DECL_IN_EXPR)
])
-: "header and library section" && {
+[begin]_group "header and library section" && {
AC_ARG_WITH(winnt-ver,
AS_HELP_STRING([--with-winnt-ver=0xXXXX], [target Windows NT version (default to 0x0600)]),
[with_winnt_ver="$withval"], [with_winnt_ver="0x0600"])
@@ -1085,12 +1094,18 @@ main()
])
POSTLINK=""
AC_CHECK_PROGS(codesign, codesign)
- AC_CHECK_PROGS(dsymutil, dsymutil)
+ dsymutils=
+ AS_CASE("$CC_NO_WRAPPER", [gcc*-1[[3-9]]], [
+ dsymutils=${CC_NO_WRAPPER@%:@gcc}
+ dsymutils=dsymutil${dsymutils%-1*}
+ dsymutils="$dsymutils-19 $dsymutils-18 $dsymutils-17"
+ ])
+ AC_CHECK_PROGS(dsymutil, $dsymutils dsymutil)
AS_IF([test -n "$codesign"], [
POSTLINK="{ test -z '\$(RUBY_CODESIGN)' || $codesign -s '\$(RUBY_CODESIGN)' -f \$@; }${POSTLINK:+; $POSTLINK}"
])
AS_IF([test -n "$dsymutil"], [
- POSTLINK="$dsymutil \$@${POSTLINK:+; $POSTLINK}"
+ POSTLINK="$dsymutil \$@ 2>/dev/null${POSTLINK:+; $POSTLINK}"
])
AS_IF([test -n "${POSTLINK}"], [
LINK_SO="$LINK_SO
@@ -1237,7 +1252,7 @@ main()
AS_CASE(["$target_cpu"], [powerpc64*], [
ac_cv_func___builtin_setjmp=no
])
- # With gcc-8's -fcf-protection, MJIT's __builtin_longjmp fails.
+ # With gcc-8's -fcf-protection, RJIT's __builtin_longjmp fails.
AS_CASE(["$CC $CFLAGS "], [*" -fcf-protection "*], [cf_protection=yes], [cf_protection=no])
AS_IF([test "$cf_protection" = yes], [
ac_cv_func___builtin_setjmp=no
@@ -1339,6 +1354,9 @@ AC_CHECK_HEADERS(syscall.h)
AC_CHECK_HEADERS(time.h)
AC_CHECK_HEADERS(ucontext.h)
AC_CHECK_HEADERS(utime.h)
+AC_CHECK_HEADERS(sys/epoll.h)
+AC_CHECK_HEADERS(sys/event.h)
+
AS_CASE("$target_cpu", [x64|x86_64|i[3-6]86*], [
AC_CHECK_HEADERS(x86intrin.h)
])
@@ -1472,6 +1490,25 @@ RUBY_CHECK_SIZEOF(float)
RUBY_CHECK_SIZEOF(double)
RUBY_CHECK_SIZEOF(time_t, [long "long long"], [], [@%:@include <time.h>])
RUBY_CHECK_SIZEOF(clock_t, [], [], [@%:@include <time.h>])
+AC_SUBST(X_BUILTIN_BINARY, yes)
+AS_IF([test "$cross_compiling" = yes],
+[dnl miniruby cannot run if cross compiling
+ X_BUILTIN_BINARY=no
+],
+[
+ AS_CASE([ac_cv_sizeof_voidp],
+ [[1-9]*], [dnl fixed value
+ ],
+ [
+ AC_CACHE_CHECK([word size], [rb_cv_word_size],
+ [for w in 4 8; do
+ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[@%:@if SIZEOF_VOIDP != ${w}
+ @%:@error SIZEOF_VOIDP
+ @%:@endif]])], [rb_cv_word_size=${w}; break])
+ done])
+ AS_IF([test -z $rb_cv_word_size], [X_BUILTIN_BINARY=no])
+ ])
+])
AC_CACHE_CHECK(packed struct attribute, rb_cv_packed_struct,
[rb_cv_packed_struct=no
@@ -1484,10 +1521,9 @@ AC_CACHE_CHECK(packed struct attribute, rb_cv_packed_struct,
[rb_cv_packed_struct=$mac; break])
done])
AS_IF([test "$rb_cv_packed_struct" != no], [
- AC_DEFINE_UNQUOTED([PACKED_STRUCT(x)], [$rb_cv_packed_struct])
+ AC_DEFINE_UNQUOTED([RBIMPL_ATTR_PACKED_STRUCT_BEGIN()], [`echo " $rb_cv_packed_struct " | sed 's/ x .*//;s/^ *//'`])
+ AC_DEFINE_UNQUOTED([RBIMPL_ATTR_PACKED_STRUCT_END()], [`echo " $rb_cv_packed_struct " | sed 's/.* x //;s/ *$//'`])
RUBY_TRY_CFLAGS(-Wno-address-of-packed-member, [AC_DEFINE(USE_UNALIGNED_MEMBER_ACCESS)])
-], [
- AC_DEFINE_UNQUOTED([PACKED_STRUCT(x)], x)
])
AS_IF([test "x$ac_cv_type_long_long" = xyes], [
@@ -2019,6 +2055,7 @@ AC_CHECK_FUNCS(execv)
AC_CHECK_FUNCS(execve)
AC_CHECK_FUNCS(explicit_memset)
AC_CHECK_FUNCS(fcopyfile)
+AC_CHECK_FUNCS(fchdir)
AC_CHECK_FUNCS(fchmod)
AC_CHECK_FUNCS(fchown)
AC_CHECK_FUNCS(fcntl)
@@ -2076,6 +2113,7 @@ AC_CHECK_FUNCS(lstat)
AC_CHECK_FUNCS(lutimes)
AC_CHECK_FUNCS(malloc_usable_size)
AC_CHECK_FUNCS(malloc_size)
+AC_CHECK_FUNCS(malloc_trim)
AC_CHECK_FUNCS(mblen)
AC_CHECK_FUNCS(memalign)
AC_CHECK_FUNCS(memset_s)
@@ -2129,6 +2167,7 @@ AC_CHECK_FUNCS(sigaction)
AC_CHECK_FUNCS(sigaltstack)
AC_CHECK_FUNCS(sigprocmask)
AC_CHECK_FUNCS(sinh)
+AC_CHECK_FUNCS(snprintf)
AC_CHECK_FUNCS(spawnv)
AC_CHECK_FUNCS(symlink)
AC_CHECK_FUNCS(syscall)
@@ -2153,9 +2192,6 @@ AC_CHECK_FUNCS(__sinpi)
AS_IF([test "x$ac_cv_member_struct_statx_stx_btime" = xyes],
[AC_CHECK_FUNCS(statx)])
-AS_CASE(["$ac_cv_func_memset_s:$ac_cv_func_qsort_s"], [*yes*],
- [RUBY_DEFINE_IF([!defined __STDC_WANT_LIB_EXT1__], [__STDC_WANT_LIB_EXT1__], 1)])
-
AS_IF([test "$ac_cv_func_getcwd" = yes], [
AC_CACHE_CHECK(if getcwd allocates buffer if NULL is given, [rb_cv_getcwd_malloc],
[AC_RUN_IFELSE([AC_LANG_SOURCE([[
@@ -2224,6 +2260,27 @@ RUBY_CHECK_BUILTIN_FUNC(__builtin_types_compatible_p, [__builtin_types_compatibl
RUBY_CHECK_BUILTIN_FUNC(__builtin_trap, [__builtin_trap()])
RUBY_CHECK_BUILTIN_FUNC(__builtin_expect, [__builtin_expect(0, 0)])
+AS_IF([test "$rb_cv_builtin___builtin_mul_overflow" != no], [
+ AC_CACHE_CHECK(for __builtin_mul_overflow with long long arguments, rb_cv_use___builtin_mul_overflow_long_long, [
+ AC_LINK_IFELSE([AC_LANG_SOURCE([[
+#pragma clang optimize off
+
+int
+main(void)
+{
+ long long x = 0, y;
+ __builtin_mul_overflow(x, x, &y);
+
+ return 0;
+}
+]])],
+ rb_cv_use___builtin_mul_overflow_long_long=yes,
+ rb_cv_use___builtin_mul_overflow_long_long=no)])
+])
+AS_IF([test "$rb_cv_use___builtin_mul_overflow_long_long" = yes], [
+ AC_DEFINE(USE___BUILTIN_MUL_OVERFLOW_LONG_LONG, 1)
+])
+
AS_IF([test "$ac_cv_func_qsort_r" != no], [
AC_CACHE_CHECK(whether qsort_r is GNU version, rb_cv_gnu_qsort_r,
[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
@@ -2611,6 +2668,9 @@ AS_CASE([$coroutine_type], [yes|''], [
[*86-mingw*], [
coroutine_type=win32
],
+ [aarch64-mingw*], [
+ coroutine_type=arm64
+ ],
[arm*-linux*], [
coroutine_type=arm32
],
@@ -2623,6 +2683,9 @@ AS_CASE([$coroutine_type], [yes|''], [
[riscv64-linux*], [
coroutine_type=riscv64
],
+ [loongarch64-linux*], [
+ coroutine_type=loongarch64
+ ],
[x86_64-freebsd*], [
coroutine_type=amd64
],
@@ -2747,6 +2810,22 @@ AS_IF([test "$THREAD_MODEL" = pthread], [
AC_DEFINE_UNQUOTED(SET_ANOTHER_THREAD_NAME(thid,name), $set_another_thread_name)
])
])
+
+ AC_CACHE_CHECK([for thread-local storage sepcifier], [rb_cv_tls_specifier],
+ rb_cv_tls_specifier=none
+ RUBY_WERROR_FLAG([
+ for attr in \
+ _Thread_local \
+ __thread \
+ ; do
+ AC_LINK_IFELSE([AC_LANG_PROGRAM([[$attr int conftest;]])],
+ [rb_cv_tls_specifier=$attr; break])
+ done
+ ])
+ )
+ AS_IF([test x"${rb_cv_tls_specifier}" != xnone],
+ [AC_DEFINE_UNQUOTED(RB_THREAD_LOCAL_SPECIFIER, ${rb_cv_tls_specifier})]
+ )
])
AS_IF([test x"$ac_cv_header_ucontext_h" = xno], [
@@ -2890,7 +2969,7 @@ AS_IF([test "x$ac_cv_func_ioctl" = xyes], [
}
-: "runtime section" && {
+[begin]_group "runtime section" && {
dnl wheather use dln_a_out or not
AC_ARG_WITH(dln-a-out,
AS_HELP_STRING([--with-dln-a-out], [dln_a_out is deprecated]),
@@ -2924,22 +3003,8 @@ AS_CASE(["$target_os"],
])])
LIBEXT=a
-AC_ARG_WITH(mjit-tabs,
- AS_HELP_STRING([--without-mjit-tabs], [expand tabs in mjit header]),
- [AS_IF([test $withval = no], [MJIT_TABS=false])])
-AC_SUBST(MJIT_TABS)dnl
AC_SUBST(DLDFLAGS)dnl
AC_SUBST(ARCH_FLAG)dnl
-AC_SUBST(MJIT_HEADER_FLAGS)dnl
-AC_SUBST(MJIT_HEADER_INSTALL_DIR)dnl
-AC_SUBST(MJIT_CC)dnl
-AS_CASE(["$GCC:$target_os"],
- [yes:aix*], [mjit_std_cflag="-std=gnu99"],
- [mjit_std_cflag=])
-AC_SUBST(MJIT_CFLAGS, [${MJIT_CFLAGS-"-w ${mjit_std_cflag} ${orig_cflags}"}])dnl
-AC_SUBST(MJIT_OPTFLAGS, [${MJIT_OPTFLAGS-'$(optflags)'}])dnl
-AC_SUBST(MJIT_DEBUGFLAGS, [${MJIT_DEBUGFLAGS-'$(debugflags)'}])dnl
-AC_SUBST(MJIT_LDSHARED)dnl
AC_SUBST(STATIC)dnl
AC_SUBST(CCDLFLAGS)dnl
@@ -3053,11 +3118,10 @@ AC_SUBST(EXTOBJS)
[darwin*], [ : ${LDSHARED='$(CC) -dynamic -bundle'}
: ${DLDSHARED='$(CC) -dynamiclib'}
: ${LDFLAGS=""}
- : ${LIBPATHENV=DYLD_FALLBACK_LIBRARY_PATH}
+ : ${LIBPATHENV=DYLD_LIBRARY_PATH}
: ${PRELOADENV=DYLD_INSERT_LIBRARIES}
AS_IF([test x"$enable_shared" = xyes], [
- # Resolve symbols from libruby.dylib when --enable-shared
- EXTDLDFLAGS='$(LIBRUBYARG_SHARED)'
+ # Resolve symbols from libruby.dylib in $(LIBS) when --enable-shared
], [test "x$EXTSTATIC" = x], [
# When building exts as bundles, a mach-o bundle needs to know its loader
# program to bind symbols from the ruby executable
@@ -3406,9 +3470,6 @@ AC_ARG_ENABLE(multiarch,
[multiarch=], [unset multiarch])
AS_IF([test ${multiarch+set}], [
AC_DEFINE(ENABLE_MULTIARCH)
- MJIT_HEADER_INSTALL_DIR=include/'${arch}/${RUBY_VERSION_NAME}'
-], [
- MJIT_HEADER_INSTALL_DIR=include/'${RUBY_VERSION_NAME}/${arch}'
])
archlibdir='${libdir}/${arch}'
@@ -3688,7 +3749,7 @@ AS_IF([test x"$gcov" = xyes], [
RUBY_SETJMP_TYPE
}
-: "build section" && {
+[begin]_group "installation section" && {
dnl build rdoc index if requested
RDOCTARGET=""
CAPITARGET=""
@@ -3736,20 +3797,19 @@ AC_SUBST(CAPITARGET)
AS_CASE(["$RDOCTARGET:$CAPITARGET"],[nodoc:nodoc],[INSTALLDOC=nodoc],[INSTALLDOC=all])
AC_SUBST(INSTALLDOC)
-AC_ARG_ENABLE(jit-support,
- AS_HELP_STRING([--disable-jit-support], [disable JIT features]),
- [MJIT_SUPPORT=$enableval],
- [AS_CASE(["$target_os"],
- [wasi | mingw* | solaris*], [MJIT_SUPPORT=no],
- [MJIT_SUPPORT=yes]
- )])
-
-AS_IF([test x"$MJIT_SUPPORT" = "xyes"],
- [AC_DEFINE(USE_MJIT, 1)],
- [AC_DEFINE(USE_MJIT, 0)])
-
-AC_SUBST(MJIT_SUPPORT)
+AC_ARG_ENABLE(install-static-library,
+ AS_HELP_STRING([--disable-install-static-library], [do not install static ruby library]),
+ [INSTALL_STATIC_LIBRARY=$enableval
+ AS_IF([test x"$enable_shared" = xno -a x"$INSTALL_STATIC_LIBRARY" = xno],
+ [AC_MSG_ERROR([must install either static or shared library])],
+ [])],
+ AS_IF([test x"$enable_shared" = xyes],
+ [INSTALL_STATIC_LIBRARY=no],
+ [INSTALL_STATIC_LIBRARY=yes]))
+AC_SUBST(INSTALL_STATIC_LIBRARY)
+}
+[begin]_group "JIT section" && {
AC_CHECK_PROG(RUSTC, [rustc], [rustc], [no]) dnl no ac_tool_prefix
dnl check if rustc is recent enough to build YJIT (rustc >= 1.58.0)
@@ -3795,8 +3855,8 @@ AC_ARG_ENABLE(yjit,
AS_HELP_STRING([--enable-yjit],
[enable in-process JIT compiler that requires Rust build tools. enabled by default on supported platforms if rustc 1.58.0+ is available]),
[YJIT_SUPPORT=$enableval],
- [AS_CASE(["$enable_jit_support:$YJIT_TARGET_OK:$YJIT_RUSTC_OK"],
- [yes:yes:yes|:yes:yes], [
+ [AS_CASE(["$YJIT_TARGET_OK:$YJIT_RUSTC_OK"],
+ [yes:yes], [
YJIT_SUPPORT=yes
],
[YJIT_SUPPORT=no]
@@ -3808,9 +3868,6 @@ CARGO_BUILD_ARGS=
YJIT_LIBS=
AS_CASE(["${YJIT_SUPPORT}"],
[yes|dev|stats|dev_nodebug], [
- AS_IF([test x"$enable_jit_support" = "xno"],
- AC_MSG_ERROR([--disable-jit-support but --enable-yjit. YJIT requires JIT support])
- )
AS_IF([test x"$RUSTC" = "xno"],
AC_MSG_ERROR([rustc is required. Installation instructions available at https://www.rust-lang.org/tools/install])
)
@@ -3827,6 +3884,7 @@ AS_CASE(["${YJIT_SUPPORT}"],
[dev_nodebug], [
rb_rust_target_subdir=dev_nodebug
CARGO_BUILD_ARGS='--profile dev_nodebug --features stats,disasm'
+ AC_DEFINE(YJIT_STATS, 1)
],
[stats], [
rb_rust_target_subdir=stats
@@ -3850,7 +3908,9 @@ AS_CASE(["${YJIT_SUPPORT}"],
AC_DEFINE_UNQUOTED(YJIT_SUPPORT, [$YJIT_SUPPORT])
])
AC_DEFINE(USE_YJIT, 1)
-], [AC_DEFINE(USE_YJIT, 0)])
+], [
+ AC_DEFINE(USE_YJIT, 0)
+])
dnl These variables end up in ::RbConfig::CONFIG
AC_SUBST(YJIT_SUPPORT)dnl what flavor of YJIT the Ruby build includes
@@ -3860,17 +3920,53 @@ AC_SUBST(CARGO_BUILD_ARGS)dnl for selecting Rust build profiles
AC_SUBST(YJIT_LIBS)dnl for optionally building the Rust parts of YJIT
AC_SUBST(YJIT_OBJ)dnl for optionally building the C parts of YJIT
-AC_ARG_ENABLE(install-static-library,
- AS_HELP_STRING([--disable-install-static-library], [do not install static ruby library]),
- [INSTALL_STATIC_LIBRARY=$enableval
- AS_IF([test x"$enable_shared" = xno -a x"$INSTALL_STATIC_LIBRARY" = xno],
- [AC_MSG_ERROR([must install either static or shared library])],
- [])],
- AS_IF([test x"$enable_shared" = xyes],
- [INSTALL_STATIC_LIBRARY=no],
- [INSTALL_STATIC_LIBRARY=yes]))
-AC_SUBST(INSTALL_STATIC_LIBRARY)
+dnl RJIT supports only x86_64 platforms, but allows arm64/aarch64 for custom JITs.
+RJIT_TARGET_OK=no
+AS_IF([test "$cross_compiling" = no],
+ AS_CASE(["$target_cpu-$target_os"],
+ [*android*], [
+ RJIT_TARGET_OK=no
+ ],
+ [arm64-darwin*|aarch64-darwin*|x86_64-darwin*], [
+ RJIT_TARGET_OK=yes
+ ],
+ [arm64-*linux*|aarch64-*linux*|x86_64-*linux*], [
+ RJIT_TARGET_OK=yes
+ ],
+ [arm64-*bsd*|aarch64-*bsd*|x86_64-*bsd*], [
+ RJIT_TARGET_OK=yes
+ ]
+ )
+)
+dnl Build RJIT on supported platforms or if --enable-rjit is specified.
+AC_ARG_ENABLE(rjit,
+ AS_HELP_STRING([--enable-rjit],
+ [enable pure-Ruby JIT compiler. enabled by default on Unix x86_64 platforms]),
+ [RJIT_SUPPORT=$enableval],
+ [AS_CASE(["$RJIT_TARGET_OK"],
+ [yes], [RJIT_SUPPORT=yes],
+ [RJIT_SUPPORT=no]
+ )]
+)
+
+AS_CASE(["$RJIT_SUPPORT"],
+[yes|dev], [
+ AS_CASE(["$RJIT_SUPPORT"],
+ [dev], [
+ # Link libcapstone for --rjit-dump-disasm
+ AC_CHECK_LIB([capstone], [cs_disasm])
+ ])
+
+ AC_DEFINE(USE_RJIT, 1)
+], [
+ AC_DEFINE(USE_RJIT, 0)
+])
+
+AC_SUBST(RJIT_SUPPORT)
+}
+
+[begin]_group "build section" && {
AC_CACHE_CHECK([for prefix of external symbols], rb_cv_symbol_prefix, [
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[extern void conftest_external(void) {}]], [[]])],[
rb_cv_symbol_prefix=`$NM conftest.$ac_objext |
@@ -3881,6 +3977,23 @@ AC_CACHE_CHECK([for prefix of external symbols], rb_cv_symbol_prefix, [
])
SYMBOL_PREFIX="$rb_cv_symbol_prefix"
test "x$SYMBOL_PREFIX" = xNONE && SYMBOL_PREFIX=''
+
+AS_IF([test x"$enable_shared" = xyes], [
+ AC_CACHE_CHECK([for default symbols in empty shared library], rb_cv_symbols_in_emptylib, [
+ save_CC="$CC"
+ eval CC=\"`printf "%s" "${DLDSHARED}" | sed ['s/\$(CC)/${CC}/']`\"
+ AC_LINK_IFELSE([AC_LANG_PROGRAM()],[
+ rb_cv_symbols_in_emptylib=`$NM -Pgp conftest$ac_exeext |
+ sed ["/ [A-TV-Z] .*/!d;s///;s/^${SYMBOL_PREFIX}//;/^main$/d"]`
+ ])
+ set dummy ${rb_cv_symbols_in_emptylib}
+ shift
+ rb_cv_symbols_in_emptylib="$*"
+ CC="$save_CC"
+ ])
+])
+AC_SUBST(XSYMBOLS_IN_EMPTYLIB, "${rb_cv_symbols_in_emptylib}")
+
DLNOBJ=dln.o
AC_ARG_ENABLE(dln,
AS_HELP_STRING([--disable-dln], [disable dynamic link feature]),
@@ -4058,8 +4171,9 @@ AS_IF([test "${universal_binary-no}" = yes ], [
const char arch[[]] = __ARCHITECTURE__;]], [[puts(arch);]])],
[rb_cv_architecture_available=yes], [rb_cv_architecture_available=no]))
])
+}
-: ${MJIT_LDSHARED=`echo "$LDSHARED" | sed ['s|\$(LD)|'"${LD}"'|g;s|\$(CC)|$(MJIT_CC)|g']`}
+[end]_group
MAINLIBS="$LIBS"
LIBS=$ORIG_LIBS
@@ -4125,6 +4239,7 @@ AC_SUBST(MINIOBJS)
AC_SUBST(THREAD_MODEL)
AC_SUBST(COROUTINE_TYPE, ${coroutine_type})
AC_SUBST(PLATFORM_DIR)
+AC_SUBST(USE_LLVM_WINDRES)
firstmf=`echo $FIRSTMAKEFILE | sed 's/:.*//'`
firsttmpl=`echo $FIRSTMAKEFILE | sed 's/.*://'`
@@ -4276,6 +4391,10 @@ AS_IF([test "${universal_binary-no}" = yes ], [
arch="${target_cpu}-${target_os}"
])
AC_DEFINE_UNQUOTED(RUBY_PLATFORM, "$arch")
+
+ AS_IF([test "$arch" = "s390x-linux"], [
+ AC_DEFINE_UNQUOTED(USE_MN_THREADS, 0)
+ ])
])
unset sitearch
@@ -4380,7 +4499,7 @@ guard=INCLUDE_RUBY_CONFIG_H
{
echo "#ifndef $guard"
echo "#define $guard 1"
- grep -v "^#define PACKAGE_" confdefs.h
+ sed "/^@%:@define PACKAGE_/d;s/ *$//" confdefs.h
echo "#endif /* $guard */"
} | tr -d '\015' |
(
@@ -4498,7 +4617,6 @@ AC_SUBST(DESTDIR)
AC_OUTPUT
}
-}
AS_IF([test "$silent" = yes], [], [
AS_IF([${FOLD+:} false], [], [
@@ -4546,8 +4664,8 @@ config_summary "debugflags" "$debugflags"
config_summary "warnflags" "$warnflags"
config_summary "strip command" "$STRIP"
config_summary "install doc" "$DOCTARGETS"
-config_summary "MJIT support" "$MJIT_SUPPORT"
config_summary "YJIT support" "$YJIT_SUPPORT"
+config_summary "RJIT support" "$RJIT_SUPPORT"
config_summary "man page type" "$MANTYPE"
config_summary "search path" "$search_path"
config_summary "static-linked-ext" ${EXTSTATIC:+"yes"}
diff --git a/constant.h b/constant.h
index e0d36909e1..90a68d447a 100644
--- a/constant.h
+++ b/constant.h
@@ -43,13 +43,11 @@ VALUE rb_mod_deprecate_constant(int argc, const VALUE *argv, VALUE obj);
void rb_free_const_table(struct rb_id_table *tbl);
VALUE rb_const_source_location(VALUE, ID);
-MJIT_SYMBOL_EXPORT_BEGIN
int rb_autoloading_value(VALUE mod, ID id, VALUE *value, rb_const_flag_t *flag);
rb_const_entry_t *rb_const_lookup(VALUE klass, ID id);
VALUE rb_public_const_get_at(VALUE klass, ID id);
VALUE rb_public_const_get_from(VALUE klass, ID id);
int rb_public_const_defined_from(VALUE klass, ID id);
VALUE rb_const_source_location_at(VALUE, ID);
-MJIT_SYMBOL_EXPORT_END
#endif /* CONSTANT_H */
diff --git a/cont.c b/cont.c
index a1cb1c8ba0..2b60860edd 100644
--- a/cont.c
+++ b/cont.c
@@ -26,15 +26,16 @@ extern int madvise(caddr_t, size_t, int);
#include COROUTINE_H
#include "eval_intern.h"
-#include "gc.h"
#include "internal.h"
#include "internal/cont.h"
+#include "internal/thread.h"
#include "internal/error.h"
+#include "internal/gc.h"
#include "internal/proc.h"
#include "internal/sanitizers.h"
#include "internal/warnings.h"
#include "ruby/fiber/scheduler.h"
-#include "mjit.h"
+#include "rjit.h"
#include "yjit.h"
#include "vm_core.h"
#include "vm_sync.h"
@@ -70,8 +71,6 @@ static VALUE rb_cFiberPool;
#define FIBER_POOL_ALLOCATION_FREE
#endif
-#define jit_cont_enabled (mjit_enabled || rb_yjit_enabled_p())
-
enum context_type {
CONTINUATION_CONTEXT = 0,
FIBER_CONTEXT = 1
@@ -178,7 +177,7 @@ struct fiber_pool {
// A singly-linked list of allocations which contain 1 or more stacks each.
struct fiber_pool_allocation * allocations;
- // Provides O(1) stack "allocation":
+ // Free list that provides O(1) stack "allocation".
struct fiber_pool_vacancy * vacancies;
// The size of the stack allocations (excluding any guard page).
@@ -190,13 +189,15 @@ struct fiber_pool {
// The initial number of stacks to allocate.
size_t initial_count;
- // Whether to madvise(free) the stack or not:
+ // Whether to madvise(free) the stack or not.
+ // If this value is set to 1, the stack will be madvise(free)ed
+ // (or equivalent), where possible, when it is returned to the pool.
int free_stacks;
// The number of stacks that have been used in this pool.
size_t used;
- // The amount to allocate for the vm_stack:
+ // The amount to allocate for the vm_stack.
size_t vm_stack_size;
};
@@ -229,18 +230,18 @@ typedef struct rb_context_struct {
struct rb_jit_cont *jit_cont; // Continuation contexts for JITs
} rb_context_t;
-
/*
* Fiber status:
- * [Fiber.new] ------> FIBER_CREATED
- * | [Fiber#resume]
- * v
- * +--> FIBER_RESUMED ----+
- * [Fiber#resume] | | [Fiber.yield] |
- * | v |
- * +-- FIBER_SUSPENDED | [Terminate]
- * |
- * FIBER_TERMINATED <-+
+ * [Fiber.new] ------> FIBER_CREATED ----> [Fiber#kill] --> |
+ * | [Fiber#resume] |
+ * v |
+ * +--> FIBER_RESUMED ----> [return] ------> |
+ * [Fiber#resume] | | [Fiber.yield/transfer] |
+ * [Fiber#transfer] | v |
+ * +--- FIBER_SUSPENDED --> [Fiber#kill] --> |
+ * |
+ * |
+ * FIBER_TERMINATED <-------------------+
*/
enum fiber_status {
FIBER_CREATED,
@@ -266,12 +267,20 @@ struct rb_fiber_struct {
unsigned int yielding : 1;
unsigned int blocking : 1;
+ unsigned int killed : 1;
+
struct coroutine_context context;
struct fiber_pool_stack stack;
};
static struct fiber_pool shared_fiber_pool = {NULL, NULL, 0, 0, 0, 0};
+void
+rb_free_shared_fiber_pool(void)
+{
+ xfree(shared_fiber_pool.allocations);
+}
+
static ID fiber_initialize_keywords[3] = {0};
/*
@@ -692,7 +701,9 @@ fiber_pool_stack_free(struct fiber_pool_stack * stack)
// If this is not true, the vacancy information will almost certainly be destroyed:
VM_ASSERT(size <= (stack->size - RB_PAGE_SIZE));
- if (DEBUG) fprintf(stderr, "fiber_pool_stack_free: %p+%"PRIuSIZE" [base=%p, size=%"PRIuSIZE"]\n", base, size, stack->base, stack->size);
+ int advice = stack->pool->free_stacks >> 1;
+
+ if (DEBUG) fprintf(stderr, "fiber_pool_stack_free: %p+%"PRIuSIZE" [base=%p, size=%"PRIuSIZE"] advice=%d\n", base, size, stack->base, stack->size, advice);
// The pages being used by the stack can be returned back to the system.
// That doesn't change the page mapping, but it does allow the system to
@@ -706,24 +717,29 @@ fiber_pool_stack_free(struct fiber_pool_stack * stack)
#ifdef __wasi__
// WebAssembly doesn't support madvise, so we just don't do anything.
#elif VM_CHECK_MODE > 0 && defined(MADV_DONTNEED)
+ if (!advice) advice = MADV_DONTNEED;
// This immediately discards the pages and the memory is reset to zero.
- madvise(base, size, MADV_DONTNEED);
+ madvise(base, size, advice);
#elif defined(MADV_FREE_REUSABLE)
+ if (!advice) advice = MADV_FREE_REUSABLE;
// Darwin / macOS / iOS.
// Acknowledge the kernel down to the task info api we make this
// page reusable for future use.
- // As for MADV_FREE_REUSE below we ensure in the rare occasions the task was not
+ // As for MADV_FREE_REUSABLE below we ensure in the rare occasions the task was not
// completed at the time of the call to re-iterate.
- while (madvise(base, size, MADV_FREE_REUSABLE) == -1 && errno == EAGAIN);
+ while (madvise(base, size, advice) == -1 && errno == EAGAIN);
#elif defined(MADV_FREE)
+ if (!advice) advice = MADV_FREE;
// Recent Linux.
- madvise(base, size, MADV_FREE);
+ madvise(base, size, advice);
#elif defined(MADV_DONTNEED)
+ if (!advice) advice = MADV_DONTNEED;
// Old Linux.
- madvise(base, size, MADV_DONTNEED);
+ madvise(base, size, advice);
#elif defined(POSIX_MADV_DONTNEED)
+ if (!advice) advice = POSIX_MADV_DONTNEED;
// Solaris?
- posix_madvise(base, size, POSIX_MADV_DONTNEED);
+ posix_madvise(base, size, advice);
#elif defined(_WIN32)
VirtualAlloc(base, size, MEM_RESET, PAGE_READWRITE);
// Not available in all versions of Windows.
@@ -1050,10 +1066,8 @@ cont_free(void *ptr)
RUBY_FREE_UNLESS_NULL(cont->saved_vm_stack.ptr);
- if (jit_cont_enabled) {
- VM_ASSERT(cont->jit_cont != NULL);
- jit_cont_free(cont->jit_cont);
- }
+ VM_ASSERT(cont->jit_cont != NULL);
+ jit_cont_free(cont->jit_cont);
/* free rb_cont_t or rb_fiber_t */
ruby_xfree(ptr);
RUBY_FREE_LEAVE("cont");
@@ -1255,6 +1269,8 @@ jit_cont_new(rb_execution_context_t *ec)
static void
jit_cont_free(struct rb_jit_cont *cont)
{
+ if (!cont) return;
+
rb_native_mutex_lock(&jit_cont_lock);
if (cont == first_jit_cont) {
first_jit_cont = cont->next;
@@ -1280,26 +1296,42 @@ rb_jit_cont_each_iseq(rb_iseq_callback callback, void *data)
if (cont->ec->vm_stack == NULL)
continue;
- const rb_control_frame_t *cfp;
- for (cfp = RUBY_VM_END_CONTROL_FRAME(cont->ec) - 1; ; cfp = RUBY_VM_NEXT_CONTROL_FRAME(cfp)) {
- const rb_iseq_t *iseq;
- if (cfp->pc && (iseq = cfp->iseq) != NULL && imemo_type((VALUE)iseq) == imemo_iseq) {
- callback(iseq, data);
+ const rb_control_frame_t *cfp = cont->ec->cfp;
+ while (!RUBY_VM_CONTROL_FRAME_STACK_OVERFLOW_P(cont->ec, cfp)) {
+ if (cfp->pc && cfp->iseq && imemo_type((VALUE)cfp->iseq) == imemo_iseq) {
+ callback(cfp->iseq, data);
}
+ cfp = RUBY_VM_PREVIOUS_CONTROL_FRAME(cfp);
+ }
+ }
+}
- if (cfp == cont->ec->cfp)
- break; // reached the most recent cfp
+#if USE_YJIT
+// Update the jit_return of all CFPs to leave_exit unless it's leave_exception or not set.
+// This prevents jit_exec_exception from jumping to the caller after invalidation.
+void
+rb_yjit_cancel_jit_return(void *leave_exit, void *leave_exception)
+{
+ struct rb_jit_cont *cont;
+ for (cont = first_jit_cont; cont != NULL; cont = cont->next) {
+ if (cont->ec->vm_stack == NULL)
+ continue;
+
+ const rb_control_frame_t *cfp = cont->ec->cfp;
+ while (!RUBY_VM_CONTROL_FRAME_STACK_OVERFLOW_P(cont->ec, cfp)) {
+ if (cfp->jit_return && cfp->jit_return != leave_exception) {
+ ((rb_control_frame_t *)cfp)->jit_return = leave_exit;
+ }
+ cfp = RUBY_VM_PREVIOUS_CONTROL_FRAME(cfp);
}
}
}
+#endif
// Finish working with jit_cont.
void
rb_jit_cont_finish(void)
{
- if (!jit_cont_enabled)
- return;
-
struct rb_jit_cont *cont, *next;
for (cont = first_jit_cont; cont != NULL; cont = next) {
next = cont->next;
@@ -1312,9 +1344,8 @@ static void
cont_init_jit_cont(rb_context_t *cont)
{
VM_ASSERT(cont->jit_cont == NULL);
- if (jit_cont_enabled) {
- cont->jit_cont = jit_cont_new(&(cont->saved_ec));
- }
+ // We always allocate this since YJIT may be enabled later
+ cont->jit_cont = jit_cont_new(&(cont->saved_ec));
}
struct rb_execution_context_struct *
@@ -1361,15 +1392,11 @@ rb_fiberptr_blocking(struct rb_fiber_struct *fiber)
return fiber->blocking;
}
-// Start working with jit_cont.
+// Initialize the jit_cont_lock
void
rb_jit_cont_init(void)
{
- if (!jit_cont_enabled)
- return;
-
rb_native_mutex_initialize(&jit_cont_lock);
- cont_init_jit_cont(&GET_EC()->fiber_ptr->cont);
}
#if 0
@@ -1994,6 +2021,7 @@ fiber_t_alloc(VALUE fiber_value, unsigned int blocking)
fiber->cont.self = fiber_value;
fiber->cont.type = FIBER_CONTEXT;
fiber->blocking = blocking;
+ fiber->killed = 0;
cont_init(&fiber->cont, th);
fiber->cont.saved_ec.fiber_ptr = fiber;
@@ -2059,10 +2087,10 @@ fiber_storage_set(struct rb_fiber_struct *fiber, VALUE storage)
}
static inline VALUE
-fiber_storage_get(rb_fiber_t *fiber)
+fiber_storage_get(rb_fiber_t *fiber, int allocate)
{
VALUE storage = fiber->cont.saved_ec.storage;
- if (storage == Qnil) {
+ if (storage == Qnil && allocate) {
storage = rb_hash_new();
fiber_storage_set(fiber, storage);
}
@@ -2089,13 +2117,21 @@ static VALUE
rb_fiber_storage_get(VALUE self)
{
storage_access_must_be_from_same_fiber(self);
- return rb_obj_dup(fiber_storage_get(fiber_ptr(self)));
+
+ VALUE storage = fiber_storage_get(fiber_ptr(self), FALSE);
+
+ if (storage == Qnil) {
+ return Qnil;
+ }
+ else {
+ return rb_obj_dup(storage);
+ }
}
static int
fiber_storage_validate_each(VALUE key, VALUE value, VALUE _argument)
{
- rb_check_id(&key);
+ Check_Type(key, T_SYMBOL);
return ST_CONTINUE;
}
@@ -2167,11 +2203,9 @@ rb_fiber_storage_set(VALUE self, VALUE value)
static VALUE
rb_fiber_storage_aref(VALUE class, VALUE key)
{
- ID id = rb_check_id(&key);
- if (!id) return Qnil;
-
- VALUE storage = fiber_storage_get(fiber_current());
+ Check_Type(key, T_SYMBOL);
+ VALUE storage = fiber_storage_get(fiber_current(), FALSE);
if (storage == Qnil) return Qnil;
return rb_hash_aref(storage, key);
@@ -2190,12 +2224,17 @@ rb_fiber_storage_aref(VALUE class, VALUE key)
static VALUE
rb_fiber_storage_aset(VALUE class, VALUE key, VALUE value)
{
- ID id = rb_check_id(&key);
- if (!id) return Qnil;
+ Check_Type(key, T_SYMBOL);
- VALUE storage = fiber_storage_get(fiber_current());
+ VALUE storage = fiber_storage_get(fiber_current(), value != Qnil);
+ if (storage == Qnil) return Qnil;
- return rb_hash_aset(storage, key, value);
+ if (value == Qnil) {
+ return rb_hash_delete(storage, key);
+ }
+ else {
+ return rb_hash_aset(storage, key, value);
+ }
}
static VALUE
@@ -2473,7 +2512,6 @@ rb_fiber_start(rb_fiber_t *fiber)
rb_proc_t *proc;
enum ruby_tag_type state;
- int need_interrupt = TRUE;
VM_ASSERT(th->ec == GET_EC());
VM_ASSERT(FIBER_RESUMED_P(fiber));
@@ -2499,6 +2537,7 @@ rb_fiber_start(rb_fiber_t *fiber)
}
EC_POP_TAG();
+ int need_interrupt = TRUE;
VALUE err = Qfalse;
if (state) {
err = th->ec->errinfo;
@@ -2507,13 +2546,16 @@ rb_fiber_start(rb_fiber_t *fiber)
if (state == TAG_RAISE) {
// noop...
}
+ else if (state == TAG_FATAL && err == RUBY_FATAL_FIBER_KILLED) {
+ need_interrupt = FALSE;
+ err = Qfalse;
+ }
else if (state == TAG_FATAL) {
rb_threadptr_pending_interrupt_enque(th, err);
}
else {
err = rb_vm_make_jump_tag_but_local_jump(state, err);
}
- need_interrupt = TRUE;
}
rb_fiber_terminate(fiber, need_interrupt, err);
@@ -2532,12 +2574,9 @@ rb_threadptr_root_fiber_setup(rb_thread_t *th)
fiber->cont.saved_ec.fiber_ptr = fiber;
fiber->cont.saved_ec.thread_ptr = th;
fiber->blocking = 1;
+ fiber->killed = 0;
fiber_status_set(fiber, FIBER_RESUMED); /* skip CREATED */
th->ec = &fiber->cont.saved_ec;
- // When rb_threadptr_root_fiber_setup is called for the first time, mjit_enabled and
- // rb_yjit_enabled_p() are still false. So this does nothing and rb_jit_cont_init() that is
- // called later will take care of it. However, you still have to call cont_init_jit_cont()
- // here for other Ractors, which are not initialized by rb_jit_cont_init().
cont_init_jit_cont(&fiber->cont);
}
@@ -2548,12 +2587,12 @@ rb_threadptr_root_fiber_release(rb_thread_t *th)
/* ignore. A root fiber object will free th->ec */
}
else {
- rb_execution_context_t *ec = GET_EC();
+ rb_execution_context_t *ec = rb_current_execution_context(false);
VM_ASSERT(th->ec->fiber_ptr->cont.type == FIBER_CONTEXT);
VM_ASSERT(th->ec->fiber_ptr->cont.self == 0);
- if (th->ec == ec) {
+ if (ec && th->ec == ec) {
rb_ractor_set_current_ec(th->ractor, NULL);
}
fiber_free(th->ec->fiber_ptr);
@@ -2634,6 +2673,19 @@ fiber_store(rb_fiber_t *next_fiber, rb_thread_t *th)
fiber_setcontext(next_fiber, fiber);
}
+static void
+fiber_check_killed(rb_fiber_t *fiber)
+{
+ VM_ASSERT(fiber == fiber_current());
+
+ if (fiber->killed) {
+ rb_thread_t *thread = fiber->cont.saved_ec.thread_ptr;
+
+ thread->ec->errinfo = RUBY_FATAL_FIBER_KILLED;
+ EC_JUMP_TAG(thread->ec, RUBY_TAG_FATAL);
+ }
+}
+
static inline VALUE
fiber_switch(rb_fiber_t *fiber, int argc, const VALUE *argv, int kw_splat, rb_fiber_t *resuming_fiber, bool yielding)
{
@@ -2722,7 +2774,14 @@ fiber_switch(rb_fiber_t *fiber, int argc, const VALUE *argv, int kw_splat, rb_fi
current_fiber = th->ec->fiber_ptr;
value = current_fiber->cont.value;
- if (current_fiber->cont.argc == -1) rb_exc_raise(value);
+
+ fiber_check_killed(current_fiber);
+
+ if (current_fiber->cont.argc == -1) {
+ // Fiber#raise will trigger this path.
+ rb_exc_raise(value);
+ }
+
return value;
}
@@ -2758,6 +2817,8 @@ fiber_blocking_yield(VALUE fiber_value)
rb_fiber_t *fiber = fiber_ptr(fiber_value);
rb_thread_t * volatile th = fiber->cont.saved_ec.thread_ptr;
+ VM_ASSERT(fiber->blocking == 0);
+
// fiber->blocking is `unsigned int : 1`, so we use it as a boolean:
fiber->blocking = 1;
@@ -2799,7 +2860,8 @@ rb_fiber_blocking(VALUE class)
// If we are already blocking, this is essentially a no-op:
if (fiber->blocking) {
return rb_yield(fiber_value);
- } else {
+ }
+ else {
return rb_ensure(fiber_blocking_yield, fiber_value, fiber_blocking_ensure, fiber_value);
}
}
@@ -3159,14 +3221,9 @@ rb_fiber_s_yield(int argc, VALUE *argv, VALUE klass)
}
static VALUE
-fiber_raise(rb_fiber_t *fiber, int argc, const VALUE *argv)
+fiber_raise(rb_fiber_t *fiber, VALUE exception)
{
- VALUE exception = rb_make_exception(argc, argv);
-
- if (fiber->resuming_fiber) {
- rb_raise(rb_eFiberError, "attempt to raise a resuming fiber");
- }
- else if (FIBER_SUSPENDED_P(fiber) && !fiber->yielding) {
+ if (FIBER_SUSPENDED_P(fiber) && !fiber->yielding) {
return fiber_transfer_kw(fiber, -1, &exception, RB_NO_KEYWORDS);
}
else {
@@ -3177,7 +3234,9 @@ fiber_raise(rb_fiber_t *fiber, int argc, const VALUE *argv)
VALUE
rb_fiber_raise(VALUE fiber, int argc, const VALUE *argv)
{
- return fiber_raise(fiber_ptr(fiber), argc, argv);
+ VALUE exception = rb_make_exception(argc, argv);
+
+ return fiber_raise(fiber_ptr(fiber), exception);
}
/*
@@ -3200,6 +3259,8 @@ rb_fiber_raise(VALUE fiber, int argc, const VALUE *argv)
* the exception, and the third parameter is an array of callback information.
* Exceptions are caught by the +rescue+ clause of <code>begin...end</code>
* blocks.
+ *
+ * Raises +FiberError+ if called on a Fiber belonging to another +Thread+.
*/
static VALUE
rb_fiber_m_raise(int argc, VALUE *argv, VALUE self)
@@ -3209,6 +3270,45 @@ rb_fiber_m_raise(int argc, VALUE *argv, VALUE self)
/*
* call-seq:
+ * fiber.kill -> nil
+ *
+ * Terminates the fiber by raising an uncatchable exception.
+ * It only terminates the given fiber and no other fiber, returning +nil+ to
+ * another fiber if that fiber was calling #resume or #transfer.
+ *
+ * <tt>Fiber#kill</tt> only interrupts another fiber when it is in Fiber.yield.
+ * If called on the current fiber then it raises that exception at the <tt>Fiber#kill</tt> call site.
+ *
+ * If the fiber has not been started, transition directly to the terminated state.
+ *
+ * If the fiber is already terminated, does nothing.
+ *
+ * Raises FiberError if called on a fiber belonging to another thread.
+ */
+static VALUE
+rb_fiber_m_kill(VALUE self)
+{
+ rb_fiber_t *fiber = fiber_ptr(self);
+
+ if (fiber->killed) return Qfalse;
+ fiber->killed = 1;
+
+ if (fiber->status == FIBER_CREATED) {
+ fiber->status = FIBER_TERMINATED;
+ }
+ else if (fiber->status != FIBER_TERMINATED) {
+ if (fiber_current() == fiber) {
+ fiber_check_killed(fiber);
+ } else {
+ fiber_raise(fiber_ptr(self), Qnil);
+ }
+ }
+
+ return self;
+}
+
+/*
+ * call-seq:
* Fiber.current -> fiber
*
* Returns the current fiber. If you are not running in the context of
@@ -3365,6 +3465,15 @@ Init_Cont(void)
const char *fiber_shared_fiber_pool_free_stacks = getenv("RUBY_SHARED_FIBER_POOL_FREE_STACKS");
if (fiber_shared_fiber_pool_free_stacks) {
shared_fiber_pool.free_stacks = atoi(fiber_shared_fiber_pool_free_stacks);
+
+ if (shared_fiber_pool.free_stacks < 0) {
+ rb_warn("Setting RUBY_SHARED_FIBER_POOL_FREE_STACKS to a negative value is not allowed.");
+ shared_fiber_pool.free_stacks = 0;
+ }
+
+ if (shared_fiber_pool.free_stacks > 1) {
+ rb_warn("Setting RUBY_SHARED_FIBER_POOL_FREE_STACKS to a value greater than 1 is operating system specific, and may cause crashes.");
+ }
}
rb_cFiber = rb_define_class("Fiber", rb_cObject);
@@ -3382,6 +3491,7 @@ Init_Cont(void)
rb_define_method(rb_cFiber, "storage=", rb_fiber_storage_set, 1);
rb_define_method(rb_cFiber, "resume", rb_fiber_m_resume, -1);
rb_define_method(rb_cFiber, "raise", rb_fiber_m_raise, -1);
+ rb_define_method(rb_cFiber, "kill", rb_fiber_m_kill, 0);
rb_define_method(rb_cFiber, "backtrace", rb_fiber_backtrace, -1);
rb_define_method(rb_cFiber, "backtrace_locations", rb_fiber_backtrace_locations, -1);
rb_define_method(rb_cFiber, "to_s", fiber_to_s, 0);
diff --git a/coroutine/amd64/Context.S b/coroutine/amd64/Context.S
index d50732adbc..056c276a31 100644
--- a/coroutine/amd64/Context.S
+++ b/coroutine/amd64/Context.S
@@ -13,29 +13,35 @@
.globl PREFIXED_SYMBOL(SYMBOL_PREFIX,coroutine_transfer)
PREFIXED_SYMBOL(SYMBOL_PREFIX,coroutine_transfer):
- # Save caller state
- pushq %rbp
- pushq %rbx
- pushq %r12
- pushq %r13
- pushq %r14
- pushq %r15
-
- # Save caller stack pointer
+ # Make space on the stack for 6 registers:
+ subq $48, %rsp
+
+ # Save caller state:
+ movq %rbp, 40(%rsp)
+ movq %rbx, 32(%rsp)
+ movq %r12, 24(%rsp)
+ movq %r13, 16(%rsp)
+ movq %r14, 8(%rsp)
+ movq %r15, (%rsp)
+
+ # Save caller stack pointer:
movq %rsp, (%rdi)
- # Restore callee stack pointer
+ # Restore callee stack pointer:
movq (%rsi), %rsp
# Restore callee state
- popq %r15
- popq %r14
- popq %r13
- popq %r12
- popq %rbx
- popq %rbp
-
- # Put the first argument into the return value
+ movq 40(%rsp), %rbp
+ movq 32(%rsp), %rbx
+ movq 24(%rsp), %r12
+ movq 16(%rsp), %r13
+ movq 8(%rsp), %r14
+ movq (%rsp), %r15
+
+ # Adjust stack pointer back:
+ addq $48, %rsp
+
+ # Put the first argument into the return value:
movq %rdi, %rax
# We pop the return address and jump to it
diff --git a/coroutine/arm64/Context.S b/coroutine/arm64/Context.S
index 07d50d30df..eeb0f774a3 100644
--- a/coroutine/arm64/Context.S
+++ b/coroutine/arm64/Context.S
@@ -18,11 +18,25 @@
.align 2
#endif
+## NOTE(PAC): Use we HINT mnemonics instead of PAC mnemonics to
+## keep compatibility with those assemblers that don't support PAC.
+##
+## See "Providing protection for complex software" for more details about PAC/BTI
+## https://developer.arm.com/architectures/learn-the-architecture/providing-protection-for-complex-software
+
.global PREFIXED_SYMBOL(SYMBOL_PREFIX,coroutine_transfer)
PREFIXED_SYMBOL(SYMBOL_PREFIX,coroutine_transfer):
+#if defined(__ARM_FEATURE_PAC_DEFAULT) && (__ARM_FEATURE_PAC_DEFAULT != 0)
+ # paciasp (it also acts as BTI landing pad, so no need to insert BTI also)
+ hint #25
+#elif defined(__ARM_FEATURE_BTI_DEFAULT) && (__ARM_FEATURE_BTI_DEFAULT != 0)
+ # For the the case PAC is not enabled but BTI is.
+ # bti c
+ hint #34
+#endif
# Make space on the stack for caller registers
- sub sp, sp, 0xb0
+ sub sp, sp, 0xa0
# Save caller registers
stp d8, d9, [sp, 0x00]
@@ -36,9 +50,6 @@ PREFIXED_SYMBOL(SYMBOL_PREFIX,coroutine_transfer):
stp x27, x28, [sp, 0x80]
stp x29, x30, [sp, 0x90]
- # Save return address
- str x30, [sp, 0xa0]
-
# Save stack pointer to x0 (first argument)
mov x2, sp
str x2, [x0, 0]
@@ -59,15 +70,51 @@ PREFIXED_SYMBOL(SYMBOL_PREFIX,coroutine_transfer):
ldp x27, x28, [sp, 0x80]
ldp x29, x30, [sp, 0x90]
- # Load return address into x4
- ldr x4, [sp, 0xa0]
-
# Pop stack frame
- add sp, sp, 0xb0
+ add sp, sp, 0xa0
- # Jump to return address (in x4)
- ret x4
+#if defined(__ARM_FEATURE_PAC_DEFAULT) && (__ARM_FEATURE_PAC_DEFAULT != 0)
+ # autiasp: Authenticate x30 (LR) with SP and key A
+ hint #29
+#endif
+
+ # Jump to return address (in x30)
+ ret
#if defined(__linux__) && defined(__ELF__)
.section .note.GNU-stack,"",%progbits
#endif
+
+#if __ARM_FEATURE_BTI_DEFAULT != 0 || __ARM_FEATURE_PAC_DEFAULT != 0
+/* See "ELF for the Arm 64-bit Architecture (AArch64)"
+ https://github.com/ARM-software/abi-aa/blob/2023Q3/aaelf64/aaelf64.rst#program-property */
+# define GNU_PROPERTY_AARCH64_FEATURE_1_BTI (1<<0)
+# define GNU_PROPERTY_AARCH64_FEATURE_1_PAC (1<<1)
+
+# if __ARM_FEATURE_BTI_DEFAULT != 0
+# define BTI_FLAG GNU_PROPERTY_AARCH64_FEATURE_1_BTI
+# else
+# define BTI_FLAG 0
+# endif
+# if __ARM_FEATURE_PAC_DEFAULT != 0
+# define PAC_FLAG GNU_PROPERTY_AARCH64_FEATURE_1_PAC
+# else
+# define PAC_FLAG 0
+# endif
+
+ # The note section format is described by Note Section in Chapter 5
+ # of "System V Application Binary Interface, Edition 4.1".
+ .pushsection .note.gnu.property, "a"
+ .p2align 3
+ .long 0x4 /* Name size ("GNU\0") */
+ .long 0x10 /* Descriptor size */
+ .long 0x5 /* Type: NT_GNU_PROPERTY_TYPE_0 */
+ .asciz "GNU" /* Name */
+ # Begin descriptor
+ .long 0xc0000000 /* Property type: GNU_PROPERTY_AARCH64_FEATURE_1_AND */
+ .long 0x4 /* Property size */
+ .long (BTI_FLAG|PAC_FLAG)
+ .long 0x0 /* 8-byte alignment padding */
+ # End descriptor
+ .popsection
+#endif
diff --git a/coroutine/arm64/Context.h b/coroutine/arm64/Context.h
index 1472621f48..1819fa5be9 100644
--- a/coroutine/arm64/Context.h
+++ b/coroutine/arm64/Context.h
@@ -17,7 +17,7 @@
#define COROUTINE __attribute__((noreturn)) void
-enum {COROUTINE_REGISTERS = 0xb0 / 8};
+enum {COROUTINE_REGISTERS = 0xa0 / 8};
#if defined(__SANITIZE_ADDRESS__)
#define COROUTINE_SANITIZE_ADDRESS
@@ -50,6 +50,23 @@ static inline void coroutine_initialize_main(struct coroutine_context * context)
context->stack_pointer = NULL;
}
+#if defined(__ARM_FEATURE_PAC_DEFAULT) && __ARM_FEATURE_PAC_DEFAULT != 0
+// Sign the given instruction address with the given modifier and key A
+static inline void *ptrauth_sign_instruction_addr(void *addr, void *modifier) {
+ register void *r17 __asm("r17") = addr;
+ register void *r16 __asm("r16") = modifier;
+ // Use HINT mnemonic instead of PACIA1716 for compatibility with older assemblers.
+ asm ("hint #8;" : "+r"(r17) : "r"(r16));
+ addr = r17;
+ return addr;
+}
+#else
+// No-op if PAC is not enabled
+static inline void *ptrauth_sign_instruction_addr(void *addr, void *modifier) {
+ return addr;
+}
+#endif
+
static inline void coroutine_initialize(
struct coroutine_context *context,
coroutine_start start,
@@ -66,12 +83,13 @@ static inline void coroutine_initialize(
// Stack grows down. Force 16-byte alignment.
char * top = (char*)stack + size;
- context->stack_pointer = (void**)((uintptr_t)top & ~0xF);
+ top = (char *)((uintptr_t)top & ~0xF);
+ context->stack_pointer = (void**)top;
context->stack_pointer -= COROUTINE_REGISTERS;
memset(context->stack_pointer, 0, sizeof(void*) * COROUTINE_REGISTERS);
- context->stack_pointer[0xa0 / 8] = (void*)start;
+ context->stack_pointer[0x98 / 8] = ptrauth_sign_instruction_addr((void*)start, (void*)top);
}
struct coroutine_context * coroutine_transfer(struct coroutine_context * current, struct coroutine_context * target);
diff --git a/coroutine/loongarch64/Context.S b/coroutine/loongarch64/Context.S
new file mode 100644
index 0000000000..662f5dfb6c
--- /dev/null
+++ b/coroutine/loongarch64/Context.S
@@ -0,0 +1,73 @@
+#define TOKEN_PASTE(x,y) x##y
+#define PREFIXED_SYMBOL(prefix,name) TOKEN_PASTE(prefix,name)
+
+.text
+.align 2
+
+.global PREFIXED_SYMBOL(SYMBOL_PREFIX,coroutine_transfer)
+PREFIXED_SYMBOL(SYMBOL_PREFIX,coroutine_transfer):
+
+ # Make space on the stack for caller registers
+ addi.d $sp, $sp, -0xa0
+
+ # Save caller registers
+ st.d $s0, $sp, 0x00
+ st.d $s1, $sp, 0x08
+ st.d $s2, $sp, 0x10
+ st.d $s3, $sp, 0x18
+ st.d $s4, $sp, 0x20
+ st.d $s5, $sp, 0x28
+ st.d $s6, $sp, 0x30
+ st.d $s7, $sp, 0x38
+ st.d $s8, $sp, 0x40
+ st.d $fp, $sp, 0x48
+ fst.d $fs0, $sp, 0x50
+ fst.d $fs1, $sp, 0x58
+ fst.d $fs2, $sp, 0x60
+ fst.d $fs3, $sp, 0x68
+ fst.d $fs4, $sp, 0x70
+ fst.d $fs5, $sp, 0x78
+ fst.d $fs6, $sp, 0x80
+ fst.d $fs7, $sp, 0x88
+
+ # Save return address
+ st.d $ra, $sp, 0x90
+
+ # Save stack pointer to a0 (first argument)
+ st.d $sp, $a0, 0x00
+
+ # Load stack pointer from a1 (second argument)
+ ld.d $sp, $a1, 0x00
+
+ # Restore caller registers
+ ld.d $s0, $sp, 0x00
+ ld.d $s1, $sp, 0x08
+ ld.d $s2, $sp, 0x10
+ ld.d $s3, $sp, 0x18
+ ld.d $s4, $sp, 0x20
+ ld.d $s5, $sp, 0x28
+ ld.d $s6, $sp, 0x30
+ ld.d $s7, $sp, 0x38
+ ld.d $s8, $sp, 0x40
+ ld.d $fp, $sp, 0x48
+ fld.d $fs0, $sp, 0x50
+ fld.d $fs1, $sp, 0x58
+ fld.d $fs2, $sp, 0x60
+ fld.d $fs3, $sp, 0x68
+ fld.d $fs4, $sp, 0x70
+ fld.d $fs5, $sp, 0x78
+ fld.d $fs6, $sp, 0x80
+ fld.d $fs7, $sp, 0x88
+
+ # Load return address
+ ld.d $ra, $sp, 0x90
+
+ # Pop stack frame
+ addi.d $sp, $sp, 0xa0
+
+ # Jump to return address
+ jr $ra
+
+#if defined(__linux__) && defined(__ELF__)
+.section .note.GNU-stack,"",%progbits
+#endif
diff --git a/coroutine/loongarch64/Context.h b/coroutine/loongarch64/Context.h
new file mode 100644
index 0000000000..668c9a965e
--- /dev/null
+++ b/coroutine/loongarch64/Context.h
@@ -0,0 +1,46 @@
+#pragma once
+
+#include <assert.h>
+#include <stddef.h>
+#include <stdint.h>
+#include <string.h>
+
+#define COROUTINE __attribute__((noreturn)) void
+
+enum {COROUTINE_REGISTERS = 0xa0 / 8};
+
+struct coroutine_context
+{
+ void **stack_pointer;
+ void *argument;
+};
+
+typedef COROUTINE(* coroutine_start)(struct coroutine_context *from, struct coroutine_context *self);
+
+static inline void coroutine_initialize_main(struct coroutine_context * context) {
+ context->stack_pointer = NULL;
+}
+
+static inline void coroutine_initialize(
+ struct coroutine_context *context,
+ coroutine_start start,
+ void *stack,
+ size_t size
+) {
+ assert(start && stack && size >= 1024);
+
+ // Stack grows down. Force 16-byte alignment.
+ char * top = (char*)stack + size;
+ context->stack_pointer = (void**)((uintptr_t)top & ~0xF);
+
+ context->stack_pointer -= COROUTINE_REGISTERS;
+ memset(context->stack_pointer, 0, sizeof(void*) * COROUTINE_REGISTERS);
+
+ context->stack_pointer[0x90 / 8] = (void*)start;
+}
+
+struct coroutine_context * coroutine_transfer(struct coroutine_context * current, struct coroutine_context * target);
+
+static inline void coroutine_destroy(struct coroutine_context * context)
+{
+}
diff --git a/coroutine/ppc/Context.S b/coroutine/ppc/Context.S
index cdda93e179..e2431a9250 100644
--- a/coroutine/ppc/Context.S
+++ b/coroutine/ppc/Context.S
@@ -3,7 +3,7 @@
; Some relevant examples: https://github.com/gcc-mirror/gcc/blob/master/libphobos/libdruntime/config/powerpc/switchcontext.S
; https://github.com/gcc-mirror/gcc/blob/master/libgcc/config/rs6000/darwin-gpsave.S
; https://www.ibm.com/docs/en/aix/7.2?topic=epilogs-saving-gprs-only
-; ppc32 version may be re-written compactly with stmw/lwm, but the code wonʼt be faster, see: https://github.com/ruby/ruby/pull/5927#issuecomment-1139730541
+; ppc32 version may be re-written compactly with stmw/lwm, but the code won't be faster, see: https://github.com/ruby/ruby/pull/5927#issuecomment-1139730541
; Notice that this code is only for Darwin (macOS). Darwin ABI differs from AIX and ELF.
; To add support for AIX, *BSD or *Linux, please make separate implementations.
diff --git a/coroutine/ppc/Context.h b/coroutine/ppc/Context.h
index 1fce112579..8035d08556 100644
--- a/coroutine/ppc/Context.h
+++ b/coroutine/ppc/Context.h
@@ -13,7 +13,7 @@
enum {
COROUTINE_REGISTERS =
- 20 /* 19 general purpose registers (r13–r31) and 1 return address */
+ 20 /* 19 general purpose registers (r13-r31) and 1 return address */
+ 4 /* space for fiber_entry() to store the link register */
};
diff --git a/coroutine/ppc64/Context.h b/coroutine/ppc64/Context.h
index 3e6f77f55a..085b475ed5 100644
--- a/coroutine/ppc64/Context.h
+++ b/coroutine/ppc64/Context.h
@@ -12,7 +12,7 @@
enum {
COROUTINE_REGISTERS =
- 20 /* 19 general purpose registers (r13–r31) and 1 return address */
+ 20 /* 19 general purpose registers (r13-r31) and 1 return address */
+ 4 /* space for fiber_entry() to store the link register */
};
diff --git a/cygwin/GNUmakefile.in b/cygwin/GNUmakefile.in
index 43e92a27f0..192a8cc711 100644
--- a/cygwin/GNUmakefile.in
+++ b/cygwin/GNUmakefile.in
@@ -3,9 +3,14 @@ gnumake = yes
include Makefile
DLLWRAP = @DLLWRAP@ --target=$(target_os) --driver-name="$(CC)"
-windres-cpp := $(CPP) -xc
-windres-cpp := --preprocessor=$(firstword $(windres-cpp)) \
- $(addprefix --preprocessor-arg=,$(wordlist 2,$(words $(windres-cpp)),$(windres-cpp)))
+ifeq (@USE_LLVM_WINDRES@,yes) # USE_LLVM_WINDRES
+ # llvm-windres fails when preprocessor options are added
+ windres-cpp :=
+else
+ windres-cpp := $(CPP) -xc
+ windres-cpp := --preprocessor=$(firstword $(windres-cpp)) \
+ $(addprefix --preprocessor-arg=,$(wordlist 2,$(words $(windres-cpp)),$(windres-cpp)))
+endif
WINDRES = @WINDRES@ $(windres-cpp) -DRC_INVOKED
STRIP = @STRIP@
@@ -41,6 +46,7 @@ SOLIBS := $(DLL_BASE_NAME).res.$(OBJEXT) $(SOLIBS)
override EXTOBJS += $(if $(filter-out $(RUBYW_INSTALL_NAME),$(@:$(EXEEXT)=)),$(RUBY_INSTALL_NAME),$(@:$(EXEEXT)=)).res.$(OBJEXT)
RCFILES = $(RUBY_INSTALL_NAME).rc $(RUBYW_INSTALL_NAME).rc $(DLL_BASE_NAME).rc
RUBYDEF = $(DLL_BASE_NAME).def
+override LIBRUBY_FOR_LEAKED_GLOBALS := # DLL shows symbols from import library
ruby: $(PROGRAM)
rubyw: $(WPROGRAM)
diff --git a/darray.h b/darray.h
index c9a53f1e01..8e1e576355 100644
--- a/darray.h
+++ b/darray.h
@@ -5,6 +5,9 @@
#include <stddef.h>
#include <stdlib.h>
+#include "internal/bits.h"
+#include "internal/gc.h"
+
// Type for a dynamic array. Use to declare a dynamic array.
// It is a pointer so it fits in st_table nicely. Designed
// to be fairly type-safe.
@@ -37,66 +40,79 @@
//
#define rb_darray_ref(ary, idx) (&((ary)->data[(idx)]))
-// Copy a new element into the array. ptr_to_ary is evaluated multiple times.
-//
-// void rb_darray_append(rb_darray(T) *ptr_to_ary, T element);
-//
-#define rb_darray_append(ptr_to_ary, element) do { \
- rb_darray_ensure_space((ptr_to_ary), sizeof(**(ptr_to_ary)), \
- sizeof((*(ptr_to_ary))->data[0])); \
+/* Copy a new element into the array. ptr_to_ary is evaluated multiple times.
+ *
+ * void rb_darray_append(rb_darray(T) *ptr_to_ary, T element);
+ */
+#define rb_darray_append(ptr_to_ary, element) \
+ rb_darray_append_impl(ptr_to_ary, element, rb_xrealloc_mul_add)
+
+#define rb_darray_append_without_gc(ptr_to_ary, element) \
+ rb_darray_append_impl(ptr_to_ary, element, rb_darray_realloc_mul_add_without_gc)
+
+#define rb_darray_append_impl(ptr_to_ary, element, realloc_func) do { \
+ rb_darray_ensure_space((ptr_to_ary), \
+ sizeof(**(ptr_to_ary)), \
+ sizeof((*(ptr_to_ary))->data[0]), \
+ realloc_func); \
rb_darray_set(*(ptr_to_ary), \
(*(ptr_to_ary))->meta.size, \
(element)); \
(*(ptr_to_ary))->meta.size++; \
} while (0)
-
-// Last element of the array
-//
-#define rb_darray_back(ary) ((ary)->data[(ary)->meta.size - 1])
-
-// Remove the last element of the array.
-//
-#define rb_darray_pop_back(ary) ((ary)->meta.size--)
-
-// Remove element at idx and replace it by the last element
-#define rb_darray_remove_unordered(ary, idx) do { \
- rb_darray_set(ary, idx, rb_darray_back(ary)); \
- rb_darray_pop_back(ary); \
-} while (0);
-
// Iterate over items of the array in a for loop
//
#define rb_darray_foreach(ary, idx_name, elem_ptr_var) \
for (size_t idx_name = 0; idx_name < rb_darray_size(ary) && ((elem_ptr_var) = rb_darray_ref(ary, idx_name)); ++idx_name)
-// Iterate over valid indicies in the array in a for loop
+// Iterate over valid indices in the array in a for loop
//
#define rb_darray_for(ary, idx_name) \
for (size_t idx_name = 0; idx_name < rb_darray_size(ary); ++idx_name)
-// Make a dynamic array of a certain size. All bytes backing the elements are set to zero.
-//
-// Note that NULL is a valid empty dynamic array.
-//
-// void rb_darray_make(rb_darray(T) *ptr_to_ary, size_t size);
-//
+/* Make a dynamic array of a certain size. All bytes backing the elements are set to zero.
+ * Return 1 on success and 0 on failure.
+ *
+ * Note that NULL is a valid empty dynamic array.
+ *
+ * void rb_darray_make(rb_darray(T) *ptr_to_ary, size_t size);
+ */
#define rb_darray_make(ptr_to_ary, size) \
rb_darray_make_impl((ptr_to_ary), size, sizeof(**(ptr_to_ary)), \
- sizeof((*(ptr_to_ary))->data[0]))
+ sizeof((*(ptr_to_ary))->data[0]), rb_xcalloc_mul_add)
-#define rb_darray_data_ptr(ary) ((ary)->data)
+#define rb_darray_make_without_gc(ptr_to_ary, size) \
+ rb_darray_make_impl((ptr_to_ary), size, sizeof(**(ptr_to_ary)), \
+ sizeof((*(ptr_to_ary))->data[0]), rb_darray_calloc_mul_add_without_gc)
-// Set the size of the array to zero without freeing the backing memory.
-// Allows reusing the same array.
-//
-#define rb_darray_clear(ary) (ary->meta.size = 0)
+/* Resize the darray to a new capacity. The new capacity must be greater than
+ * or equal to the size of the darray.
+ *
+ * void rb_darray_resize_capa(rb_darray(T) *ptr_to_ary, size_t capa);
+ */
+#define rb_darray_resize_capa_without_gc(ptr_to_ary, capa) \
+ rb_darray_resize_capa_impl((ptr_to_ary), rb_darray_next_power_of_two(capa), sizeof(**(ptr_to_ary)), \
+ sizeof((*(ptr_to_ary))->data[0]), rb_darray_realloc_mul_add_without_gc)
+
+#define rb_darray_data_ptr(ary) ((ary)->data)
typedef struct rb_darray_meta {
size_t size;
size_t capa;
} rb_darray_meta_t;
+/* Set the size of the array to zero without freeing the backing memory.
+ * Allows reusing the same array. */
+static inline void
+rb_darray_clear(void *ary)
+{
+ rb_darray_meta_t *meta = ary;
+ if (meta) {
+ meta->size = 0;
+ }
+}
+
// Get the size of the dynamic array.
//
static inline size_t
@@ -115,20 +131,86 @@ rb_darray_capa(const void *ary)
return meta ? meta->capa : 0;
}
-// Free the dynamic array.
-//
+/* Free the dynamic array. */
static inline void
rb_darray_free(void *ary)
{
rb_darray_meta_t *meta = ary;
- ruby_sized_xfree(ary, meta->capa);
+ if (meta) ruby_sized_xfree(ary, meta->capa);
+}
+
+static inline void
+rb_darray_free_without_gc(void *ary)
+{
+ free(ary);
+}
+
+/* Internal function. Like rb_xcalloc_mul_add but does not trigger GC and does
+ * not check for overflow in arithmetic. */
+static inline void *
+rb_darray_calloc_mul_add_without_gc(size_t x, size_t y, size_t z)
+{
+ size_t size = (x * y) + z;
+
+ void *ptr = calloc(1, size);
+ if (ptr == NULL) rb_bug("rb_darray_calloc_mul_add_without_gc: failed");
+
+ return ptr;
+}
+
+/* Internal function. Like rb_xrealloc_mul_add but does not trigger GC and does
+ * not check for overflow in arithmetic. */
+static inline void *
+rb_darray_realloc_mul_add_without_gc(const void *orig_ptr, size_t x, size_t y, size_t z)
+{
+ size_t size = (x * y) + z;
+
+ void *ptr = realloc((void *)orig_ptr, size);
+ if (ptr == NULL) rb_bug("rb_darray_realloc_mul_add_without_gc: failed");
+
+ return ptr;
+}
+
+/* Internal function. Returns the next power of two that is greater than or
+ * equal to n. */
+static inline size_t
+rb_darray_next_power_of_two(size_t n)
+{
+ return (size_t)(1 << (64 - nlz_int64(n)));
+}
+
+/* Internal function. Resizes the capacity of a darray. The new capacity must
+ * be greater than or equal to the size of the darray. */
+static inline void
+rb_darray_resize_capa_impl(void *ptr_to_ary, size_t new_capa, size_t header_size, size_t element_size,
+ void *(*realloc_mul_add_impl)(const void *, size_t, size_t, size_t))
+{
+ rb_darray_meta_t **ptr_to_ptr_to_meta = ptr_to_ary;
+ rb_darray_meta_t *meta = *ptr_to_ptr_to_meta;
+
+ rb_darray_meta_t *new_ary = realloc_mul_add_impl(meta, new_capa, element_size, header_size);
+
+ if (meta == NULL) {
+ /* First allocation. Initialize size. On subsequence allocations
+ * realloc takes care of carrying over the size. */
+ new_ary->size = 0;
+ }
+
+ assert(new_ary->size <= new_capa);
+
+ new_ary->capa = new_capa;
+
+ // We don't have access to the type of the dynamic array in function context.
+ // Write out result with memcpy to avoid strict aliasing issue.
+ memcpy(ptr_to_ary, &new_ary, sizeof(new_ary));
}
// Internal function
// Ensure there is space for one more element.
// Note: header_size can be bigger than sizeof(rb_darray_meta_t) when T is __int128_t, for example.
static inline void
-rb_darray_ensure_space(void *ptr_to_ary, size_t header_size, size_t element_size)
+rb_darray_ensure_space(void *ptr_to_ary, size_t header_size, size_t element_size,
+ void *(*realloc_mul_add_impl)(const void *, size_t, size_t, size_t))
{
rb_darray_meta_t **ptr_to_ptr_to_meta = ptr_to_ary;
rb_darray_meta_t *meta = *ptr_to_ptr_to_meta;
@@ -138,25 +220,12 @@ rb_darray_ensure_space(void *ptr_to_ary, size_t header_size, size_t element_size
// Double the capacity
size_t new_capa = current_capa == 0 ? 1 : current_capa * 2;
- rb_darray_meta_t *doubled_ary = rb_xrealloc_mul_add(meta, new_capa, element_size, header_size);
- // rb_xrealloc functions guarantee that NULL is not returned
- assert(doubled_ary != NULL);
-
- if (meta == NULL) {
- // First allocation. Initialize size. On subsequence allocations
- // realloc takes care of carrying over the size.
- doubled_ary->size = 0;
- }
-
- doubled_ary->capa = new_capa;
-
- // We don't have access to the type of the dynamic array in function context.
- // Write out result with memcpy to avoid strict aliasing issue.
- memcpy(ptr_to_ary, &doubled_ary, sizeof(doubled_ary));
+ rb_darray_resize_capa_impl(ptr_to_ary, new_capa, header_size, element_size, realloc_mul_add_impl);
}
static inline void
-rb_darray_make_impl(void *ptr_to_ary, size_t array_size, size_t header_size, size_t element_size)
+rb_darray_make_impl(void *ptr_to_ary, size_t array_size, size_t header_size, size_t element_size,
+ void *(*calloc_mul_add_impl)(size_t, size_t, size_t))
{
rb_darray_meta_t **ptr_to_ptr_to_meta = ptr_to_ary;
if (array_size == 0) {
@@ -164,9 +233,7 @@ rb_darray_make_impl(void *ptr_to_ary, size_t array_size, size_t header_size, siz
return;
}
- rb_darray_meta_t *meta = rb_xcalloc_mul_add(array_size, element_size, header_size);
- // rb_xcalloc functions guarantee that NULL is not returned
- assert(meta != NULL);
+ rb_darray_meta_t *meta = calloc_mul_add_impl(array_size, element_size, header_size);
meta->size = array_size;
meta->capa = array_size;
diff --git a/debug.c b/debug.c
index 3dd0f71906..e84e3d602a 100644
--- a/debug.c
+++ b/debug.c
@@ -53,14 +53,8 @@ const union {
rb_econv_result_t econv_result;
enum ruby_preserved_encindex encoding_index;
enum ruby_robject_flags robject_flags;
-#if !USE_RVARGC
- enum ruby_robject_consts robject_consts;
-#endif
enum ruby_rmodule_flags rmodule_flags;
enum ruby_rstring_flags rstring_flags;
-#if !USE_RVARGC
- enum ruby_rstring_consts rstring_consts;
-#endif
enum ruby_rarray_flags rarray_flags;
enum ruby_rarray_consts rarray_consts;
enum {
@@ -76,7 +70,7 @@ const union {
RUBY_FMODE_NOREVLOOKUP = 0x00000100,
RUBY_FMODE_TRUNC = FMODE_TRUNC,
RUBY_FMODE_TEXTMODE = FMODE_TEXTMODE,
- RUBY_FMODE_PREP = 0x00010000,
+ RUBY_FMODE_EXTERNAL = 0x00010000,
RUBY_FMODE_SETENC_BY_BOM = FMODE_SETENC_BY_BOM,
RUBY_FMODE_UNIX = 0x00200000,
RUBY_FMODE_INET = 0x00400000,
@@ -118,7 +112,7 @@ ruby_debug_printf(const char *format, ...)
va_end(ap);
}
-#include "gc.h"
+#include "internal/gc.h"
VALUE
ruby_debug_print_value(int level, int debug_level, const char *header, VALUE obj)
@@ -291,12 +285,20 @@ static const char *dlf_type_names[] = {
"func",
};
+#ifdef MAX_PATH
+#define DEBUG_LOG_MAX_PATH (MAX_PATH-1)
+#else
+#define DEBUG_LOG_MAX_PATH 255
+#endif
+
static struct {
char *mem;
unsigned int cnt;
struct debug_log_filter filters[MAX_DEBUG_LOG_FILTER_NUM];
unsigned int filters_num;
+ bool show_pid;
rb_nativethread_lock_t lock;
+ char output_file[DEBUG_LOG_MAX_PATH+1];
FILE *output;
} debug_log;
@@ -398,7 +400,39 @@ setup_debug_log(void)
}
else {
ruby_debug_log_mode |= ruby_debug_log_file;
- if ((debug_log.output = fopen(log_config, "w")) == NULL) {
+
+ // pid extension with %p
+ unsigned long len = strlen(log_config);
+
+ for (unsigned long i=0, j=0; i<len; i++) {
+ const char c = log_config[i];
+
+ if (c == '%') {
+ i++;
+ switch (log_config[i]) {
+ case '%':
+ debug_log.output_file[j++] = '%';
+ break;
+ case 'p':
+ snprintf(debug_log.output_file + j, DEBUG_LOG_MAX_PATH - j, "%d", getpid());
+ j = strlen(debug_log.output_file);
+ break;
+ default:
+ fprintf(stderr, "can not parse RUBY_DEBUG_LOG filename: %s\n", log_config);
+ exit(1);
+ }
+ }
+ else {
+ debug_log.output_file[j++] = c;
+ }
+
+ if (j >= DEBUG_LOG_MAX_PATH) {
+ fprintf(stderr, "RUBY_DEBUG_LOG=%s is too long\n", log_config);
+ exit(1);
+ }
+ }
+
+ if ((debug_log.output = fopen(debug_log.output_file, "w")) == NULL) {
fprintf(stderr, "can not open %s for RUBY_DEBUG_LOG\n", log_config);
exit(1);
}
@@ -409,9 +443,17 @@ setup_debug_log(void)
(ruby_debug_log_mode & ruby_debug_log_memory) ? "[mem]" : "",
(ruby_debug_log_mode & ruby_debug_log_stderr) ? "[stderr]" : "",
(ruby_debug_log_mode & ruby_debug_log_file) ? "[file]" : "");
+ if (debug_log.output_file[0]) {
+ fprintf(stderr, "RUBY_DEBUG_LOG filename=%s\n", debug_log.output_file);
+ }
+
rb_nativethread_lock_initialize(&debug_log.lock);
setup_debug_log_filter();
+
+ if (getenv("RUBY_DEBUG_LOG_PID")) {
+ debug_log.show_pid = true;
+ }
}
}
@@ -450,7 +492,7 @@ check_filter(const char *str, const struct debug_log_filter *filter, bool *state
// (func_name or file_name) contains baz or boo
//
// RUBY_DEBUG_LOG_FILTER=foo,bar,-baz,-boo
-// retunrs true if
+// returns true if
// (func_name or file_name) contains foo or bar
// or
// (func_name or file_name) doesn't contain baz and
@@ -507,10 +549,16 @@ ruby_debug_log(const char *file, int line, const char *func_name, const char *fm
int len = 0;
int r = 0;
+ if (debug_log.show_pid) {
+ r = snprintf(buff + len, MAX_DEBUG_LOG_MESSAGE_LEN, "pid:%d\t", getpid());
+ if (r < 0) rb_bug("ruby_debug_log returns %d", r);
+ len += r;
+ }
+
// message title
if (func_name && len < MAX_DEBUG_LOG_MESSAGE_LEN) {
r = snprintf(buff + len, MAX_DEBUG_LOG_MESSAGE_LEN, "%s\t", func_name);
- if (r < 0) rb_bug("ruby_debug_log returns %d\n", r);
+ if (r < 0) rb_bug("ruby_debug_log returns %d", r);
len += r;
}
@@ -529,41 +577,67 @@ ruby_debug_log(const char *file, int line, const char *func_name, const char *fm
// C location
if (file && len < MAX_DEBUG_LOG_MESSAGE_LEN) {
r = snprintf(buff + len, MAX_DEBUG_LOG_MESSAGE_LEN, "\t%s:%d", pretty_filename(file), line);
- if (r < 0) rb_bug("ruby_debug_log returns %d\n", r);
+ if (r < 0) rb_bug("ruby_debug_log returns %d", r);
len += r;
}
- if (rb_current_execution_context(false)) {
- // Ruby location
- int ruby_line;
- const char *ruby_file = rb_source_location_cstr(&ruby_line);
- if (len < MAX_DEBUG_LOG_MESSAGE_LEN) {
- if (ruby_file) {
- r = snprintf(buff + len, MAX_DEBUG_LOG_MESSAGE_LEN - len, "\t%s:%d", pretty_filename(ruby_file), ruby_line);
- }
- else {
- r = snprintf(buff + len, MAX_DEBUG_LOG_MESSAGE_LEN - len, "\t");
- }
- if (r < 0) rb_bug("ruby_debug_log returns %d\n", r);
- len += r;
+ rb_execution_context_t *ec = rb_current_execution_context(false);
+
+ // Ruby location
+ int ruby_line;
+ const char *ruby_file = ec ? rb_source_location_cstr(&ruby_line) : NULL;
+
+ if (len < MAX_DEBUG_LOG_MESSAGE_LEN) {
+ if (ruby_file) {
+ r = snprintf(buff + len, MAX_DEBUG_LOG_MESSAGE_LEN - len, "\t%s:%d", pretty_filename(ruby_file), ruby_line);
}
+ else {
+ r = snprintf(buff + len, MAX_DEBUG_LOG_MESSAGE_LEN - len, "\t");
+ }
+ if (r < 0) rb_bug("ruby_debug_log returns %d", r);
+ len += r;
+ }
+
+#ifdef RUBY_NT_SERIAL
+ // native thread information
+ if (len < MAX_DEBUG_LOG_MESSAGE_LEN) {
+ r = snprintf(buff + len, MAX_DEBUG_LOG_MESSAGE_LEN - len, "\tnt:%d", ruby_nt_serial);
+ if (r < 0) rb_bug("ruby_debug_log returns %d", r);
+ len += r;
+ }
+#endif
+
+ if (ec) {
+ rb_thread_t *th = ec ? rb_ec_thread_ptr(ec) : NULL;
// ractor information
if (ruby_single_main_ractor == NULL) {
- rb_ractor_t *cr = GET_RACTOR();
+ rb_ractor_t *cr = th ? th->ractor : NULL;
+ rb_vm_t *vm = GET_VM();
+
if (r && len < MAX_DEBUG_LOG_MESSAGE_LEN) {
- r = snprintf(buff + len, MAX_DEBUG_LOG_MESSAGE_LEN - len, "\tr:#%u/%u",
- (unsigned int)rb_ractor_id(cr), GET_VM()->ractor.cnt);
- if (r < 0) rb_bug("ruby_debug_log returns %d\n", r);
+ r = snprintf(buff + len, MAX_DEBUG_LOG_MESSAGE_LEN - len, "\tr:#%d/%u (%u)",
+ cr ? (int)rb_ractor_id(cr) : -1, vm->ractor.cnt, vm->ractor.sched.running_cnt);
+
+ if (r < 0) rb_bug("ruby_debug_log returns %d", r);
len += r;
}
}
// thread information
- const rb_thread_t *th = GET_THREAD();
- if (r && len < MAX_DEBUG_LOG_MESSAGE_LEN) {
- r = snprintf(buff + len, MAX_DEBUG_LOG_MESSAGE_LEN - len, "\tth:%u", rb_th_serial(th));
- if (r < 0) rb_bug("ruby_debug_log returns %d\n", r);
+ if (th && r && len < MAX_DEBUG_LOG_MESSAGE_LEN) {
+ rb_execution_context_t *rec = th->ractor ? th->ractor->threads.running_ec : NULL;
+ const rb_thread_t *rth = rec ? rec->thread_ptr : NULL;
+ const rb_thread_t *sth = th->ractor ? th->ractor->threads.sched.running : NULL;
+
+ if (rth != th || sth != th) {
+ r = snprintf(buff + len, MAX_DEBUG_LOG_MESSAGE_LEN - len, "\tth:%u (rth:%d,sth:%d)",
+ rb_th_serial(th), rth ? (int)rb_th_serial(rth) : -1, sth ? (int)rb_th_serial(sth) : -1);
+ }
+ else {
+ r = snprintf(buff + len, MAX_DEBUG_LOG_MESSAGE_LEN - len, "\tth:%u", rb_th_serial(th));
+ }
+ if (r < 0) rb_bug("ruby_debug_log returns %d", r);
len += r;
}
}
diff --git a/debug_counter.c b/debug_counter.c
index 463bebf849..3dcc4c6a3a 100644
--- a/debug_counter.c
+++ b/debug_counter.c
@@ -25,10 +25,8 @@ const char *const rb_debug_counter_names[] = {
#undef RB_DEBUG_COUNTER
};
-MJIT_SYMBOL_EXPORT_BEGIN
size_t rb_debug_counter[numberof(rb_debug_counter_names)];
void rb_debug_counter_add_atomic(enum rb_debug_counter_type type, int add);
-MJIT_SYMBOL_EXPORT_END
static rb_nativethread_lock_t debug_counter_lock;
diff --git a/debug_counter.h b/debug_counter.h
index 6e0b8dee60..a8b95edded 100644
--- a/debug_counter.h
+++ b/debug_counter.h
@@ -100,6 +100,13 @@ RB_DEBUG_COUNTER(ccf_opt_block_call)
RB_DEBUG_COUNTER(ccf_opt_struct_aref)
RB_DEBUG_COUNTER(ccf_opt_struct_aset)
RB_DEBUG_COUNTER(ccf_super_method)
+RB_DEBUG_COUNTER(ccf_cfunc_other)
+RB_DEBUG_COUNTER(ccf_cfunc_only_splat)
+RB_DEBUG_COUNTER(ccf_cfunc_only_splat_kw)
+RB_DEBUG_COUNTER(ccf_iseq_bmethod)
+RB_DEBUG_COUNTER(ccf_noniseq_bmethod)
+RB_DEBUG_COUNTER(ccf_opt_send_complex)
+RB_DEBUG_COUNTER(ccf_opt_send_simple)
/*
* control frame push counts.
@@ -127,29 +134,22 @@ RB_DEBUG_COUNTER(frame_R2C)
RB_DEBUG_COUNTER(frame_C2C)
RB_DEBUG_COUNTER(frame_C2R)
-/* instance variable counts
- *
- * * ivar_get_ic_hit/miss: ivar_get inline cache (ic) hit/miss counts (VM insn)
- * * ivar_get_ic_miss_unset: ... by unset (VM insn)
- * * ivar_get_ic_miss_noobject: ... by "not T_OBJECT" (VM insn)
- * * ivar_set_...: same counts with ivar_set (VM insn)
- * * ivar_get/set_base: call counts of "rb_ivar_get/set()".
- * because of (1) ic miss.
- * (2) direct call by C extensions.
- */
-RB_DEBUG_COUNTER(ivar_get_ic_hit)
-RB_DEBUG_COUNTER(ivar_get_ic_miss)
-RB_DEBUG_COUNTER(ivar_get_ic_miss_noobject)
-RB_DEBUG_COUNTER(ivar_set_ic_hit)
-RB_DEBUG_COUNTER(ivar_set_ic_miss)
-RB_DEBUG_COUNTER(ivar_set_ic_miss_iv_hit)
-RB_DEBUG_COUNTER(ivar_set_ic_miss_noobject)
-RB_DEBUG_COUNTER(ivar_get_base)
-RB_DEBUG_COUNTER(ivar_set_base)
-RB_DEBUG_COUNTER(ivar_get_ic_miss_set)
-RB_DEBUG_COUNTER(ivar_get_cc_miss_set)
-RB_DEBUG_COUNTER(ivar_get_ic_miss_unset)
-RB_DEBUG_COUNTER(ivar_get_cc_miss_unset)
+/* instance variable counts */
+RB_DEBUG_COUNTER(ivar_get_obj_hit) // Only T_OBJECT hits
+RB_DEBUG_COUNTER(ivar_get_obj_miss) // Only T_OBJECT misses
+RB_DEBUG_COUNTER(ivar_get_ic_hit) // All hits
+RB_DEBUG_COUNTER(ivar_get_ic_miss) // All misses
+RB_DEBUG_COUNTER(ivar_set_ic_hit) // All hits
+RB_DEBUG_COUNTER(ivar_set_obj_hit) // Only T_OBJECT hits
+RB_DEBUG_COUNTER(ivar_set_obj_miss) // Only T_OBJECT misses
+RB_DEBUG_COUNTER(ivar_set_ic_miss) // All misses
+RB_DEBUG_COUNTER(ivar_set_ic_miss_noobject) // Miss because non T_OBJECT
+RB_DEBUG_COUNTER(ivar_get_base) // Calls to `rb_ivar_get` (very slow path)
+RB_DEBUG_COUNTER(ivar_set_base) // Calls to `ivar_set` (very slow path)
+RB_DEBUG_COUNTER(ivar_get_ic_miss_set) // Misses on IV reads where the cache was wrong
+RB_DEBUG_COUNTER(ivar_get_cc_miss_set) // Misses on attr_reader where the cache was wrong
+RB_DEBUG_COUNTER(ivar_get_ic_miss_unset) // Misses on IV read where the cache wasn't set
+RB_DEBUG_COUNTER(ivar_get_cc_miss_unset) // Misses on attr_reader where the cache wasn't set
/* local variable counts
*
@@ -185,8 +185,7 @@ RB_DEBUG_COUNTER(gc_major_force)
RB_DEBUG_COUNTER(gc_major_oldmalloc)
RB_DEBUG_COUNTER(gc_enter_start)
-RB_DEBUG_COUNTER(gc_enter_mark_continue)
-RB_DEBUG_COUNTER(gc_enter_sweep_continue)
+RB_DEBUG_COUNTER(gc_enter_continue)
RB_DEBUG_COUNTER(gc_enter_rest)
RB_DEBUG_COUNTER(gc_enter_finalizer)
@@ -215,7 +214,6 @@ RB_DEBUG_COUNTER(gc_isptr_maybe)
* * [attr]
* * _ptr: R?? is not embed.
* * _embed: R?? is embed.
- * * _transient: R?? uses transient heap.
* * type specific attr.
* * str_shared: str is shared.
* * str_nofree: nofree
@@ -241,7 +239,6 @@ RB_DEBUG_COUNTER(obj_promote)
RB_DEBUG_COUNTER(obj_wb_unprotect)
RB_DEBUG_COUNTER(obj_obj_embed)
-RB_DEBUG_COUNTER(obj_obj_transient)
RB_DEBUG_COUNTER(obj_obj_ptr)
RB_DEBUG_COUNTER(obj_obj_too_complex)
@@ -252,7 +249,6 @@ RB_DEBUG_COUNTER(obj_str_nofree)
RB_DEBUG_COUNTER(obj_str_fstr)
RB_DEBUG_COUNTER(obj_ary_embed)
-RB_DEBUG_COUNTER(obj_ary_transient)
RB_DEBUG_COUNTER(obj_ary_ptr)
RB_DEBUG_COUNTER(obj_ary_extracapa)
/*
@@ -276,11 +272,9 @@ RB_DEBUG_COUNTER(obj_hash_g8)
RB_DEBUG_COUNTER(obj_hash_null)
RB_DEBUG_COUNTER(obj_hash_ar)
RB_DEBUG_COUNTER(obj_hash_st)
-RB_DEBUG_COUNTER(obj_hash_transient)
RB_DEBUG_COUNTER(obj_hash_force_convert)
RB_DEBUG_COUNTER(obj_struct_embed)
-RB_DEBUG_COUNTER(obj_struct_transient)
RB_DEBUG_COUNTER(obj_struct_ptr)
RB_DEBUG_COUNTER(obj_data_empty)
@@ -335,11 +329,6 @@ RB_DEBUG_COUNTER(heap_xmalloc)
RB_DEBUG_COUNTER(heap_xrealloc)
RB_DEBUG_COUNTER(heap_xfree)
-/* transient_heap */
-RB_DEBUG_COUNTER(theap_alloc)
-RB_DEBUG_COUNTER(theap_alloc_fail)
-RB_DEBUG_COUNTER(theap_evacuate)
-
// VM sync
RB_DEBUG_COUNTER(vm_sync_lock)
RB_DEBUG_COUNTER(vm_sync_lock_enter)
diff --git a/defs/gmake.mk b/defs/gmake.mk
index 2b3d46e25c..5489b017b3 100644
--- a/defs/gmake.mk
+++ b/defs/gmake.mk
@@ -1,20 +1,19 @@
# -*- mode: makefile-gmake; indent-tabs-mode: t -*-
reconfig config.status: export MAKE:=$(MAKE)
+export BASERUBY:=$(BASERUBY)
override gnumake_recursive := $(if $(findstring n,$(firstword $(MFLAGS))),,+)
override mflags := $(filter-out -j%,$(MFLAGS))
MSPECOPT += $(if $(filter -j%,$(MFLAGS)),-j)
nproc = $(subst -j,,$(filter -j%,$(MFLAGS)))
ifeq ($(GITHUB_ACTIONS),true)
-override ACTIONS_GROUP = @echo "\#\#[group]$(patsubst yes-%,%,$@)"
-override ACTIONS_ENDGROUP = @echo "\#\#[endgroup]"
+# 93(bright yellow) is copied from .github/workflows/mingw.yml
+override ACTIONS_GROUP = @echo "::group::$(@:yes-%=%)"
+override ACTIONS_ENDGROUP = @echo "::endgroup::"
endif
ifneq ($(filter darwin%,$(target_os)),)
-# Remove debug option not to generate thousands of .dSYM
-MJIT_DEBUGFLAGS := $(filter-out -g%,$(MJIT_DEBUGFLAGS))
-
INSTRUBY_ENV += SDKROOT=
endif
INSTRUBY_ARGS += --gnumake
@@ -26,7 +25,7 @@ TEST_TARGETS := $(filter $(CHECK_TARGETS),$(MAKECMDGOALS))
TEST_DEPENDS := $(filter-out commit $(TEST_TARGETS),$(MAKECMDGOALS))
TEST_TARGETS := $(patsubst great,exam,$(TEST_TARGETS))
TEST_DEPENDS := $(filter-out great $(TEST_TARGETS),$(TEST_DEPENDS))
-TEST_TARGETS := $(patsubst exam,test-bundled-gems yes-test-bundler-parallel check,$(TEST_TARGETS))
+TEST_TARGETS := $(patsubst exam,test-bundled-gems test-bundler-parallel check,$(TEST_TARGETS))
TEST_TARGETS := $(patsubst check,test-syntax-suggest test-spec test-all test-tool test-short,$(TEST_TARGETS))
TEST_TARGETS := $(patsubst test-rubyspec,test-spec,$(TEST_TARGETS))
TEST_DEPENDS := $(filter-out exam check test-spec $(TEST_TARGETS),$(TEST_DEPENDS))
@@ -37,6 +36,7 @@ TEST_DEPENDS := $(filter-out test-all $(TEST_TARGETS),$(TEST_DEPENDS))
TEST_TARGETS := $(patsubst test,test-short,$(TEST_TARGETS))
TEST_DEPENDS := $(filter-out test $(TEST_TARGETS),$(TEST_DEPENDS))
TEST_TARGETS := $(patsubst test-short,btest-ruby test-knownbug test-basic,$(TEST_TARGETS))
+TEST_TARGETS := $(patsubst test-basic,test-basic test-leaked-globals,$(TEST_TARGETS))
TEST_TARGETS := $(patsubst test-bundled-gems,test-bundled-gems-run,$(TEST_TARGETS))
TEST_TARGETS := $(patsubst test-bundled-gems-run,test-bundled-gems-run $(PREPARE_BUNDLED_GEMS),$(TEST_TARGETS))
TEST_TARGETS := $(patsubst test-bundled-gems-prepare,test-bundled-gems-prepare $(PRECHECK_BUNDLED_GEMS) test-bundled-gems-fetch,$(TEST_TARGETS))
@@ -44,6 +44,7 @@ TEST_TARGETS := $(patsubst test-bundler-parallel,test-bundler-parallel $(PREPARE
TEST_TARGETS := $(patsubst test-syntax-suggest,test-syntax-suggest $(PREPARE_SYNTAX_SUGGEST),$(TEST_TARGETS))
TEST_DEPENDS := $(filter-out test-short $(TEST_TARGETS),$(TEST_DEPENDS))
TEST_DEPENDS += $(if $(filter great exam love check,$(MAKECMDGOALS)),all exts)
+TEST_TARGETS := $(patsubst yes-%,%,$(filter-out no-%,$(TEST_TARGETS)))
endif
in-srcdir := $(if $(filter-out .,$(srcdir)),$(CHDIR) $(srcdir) &&)
@@ -56,6 +57,13 @@ ifeq ($(if $(filter all main exts enc trans libencs libenc libtrans \
-include $(SHOWFLAGS)
endif
+ifeq ($(HAVE_BASERUBY):$(HAVE_GIT),yes:yes)
+override modified := $(shell $(BASERUBY) -C $(srcdir) tool/file2lastrev.rb --modified='%Y %m %d')
+override RUBY_RELEASE_YEAR := $(word 1,$(modified))
+override RUBY_RELEASE_MONTH := $(word 2,$(modified))
+override RUBY_RELEASE_DAY := $(word 3,$(modified))
+endif
+
ifneq ($(filter universal-%,$(arch)),)
define archcmd
%.$(1).S: %.c
@@ -71,7 +79,7 @@ define archcmd
%.i: %.$(1).i
endef
-$(foreach arch,$(arch_flags),\
+$(foreach arch,$(filter -arch=%,$(subst -arch ,-arch=,$(ARCH_FLAG))),\
$(eval $(call archcmd,$(patsubst -arch=%,%,$(value arch)),$(patsubst -arch=%,-arch %,$(value arch)))))
endif
@@ -83,16 +91,31 @@ $(addprefix yes-,$(TEST_TARGETS)): $(TEST_DEPENDS)
endif
ORDERED_TEST_TARGETS := $(filter $(TEST_TARGETS), \
- btest-ruby test-knownbug test-basic \
+ btest-ruby test-knownbug test-leaked-globals test-basic \
test-testframework test-tool test-ruby test-all \
test-spec test-syntax-suggest-prepare test-syntax-suggest \
test-bundler-prepare test-bundler test-bundler-parallel \
test-bundled-gems-precheck test-bundled-gems-fetch \
test-bundled-gems-prepare test-bundled-gems-run \
)
-prev_test := $(if $(filter test-spec,$(ORDERED_TEST_TARGETS)),test-spec-precheck)
+
+# grep ^yes-test-.*-precheck: template/Makefile.in defs/gmake.mk common.mk
+test_prechecks := $(filter $(ORDERED_TEST_TARGETS),\
+ test-leaked-globals \
+ test-all \
+ test-spec \
+ test-syntax-suggest \
+ test-bundler \
+ test-bundler-parallel \
+ test-bundled-gems\
+ )
+prev_test := $(subst test-bundler-parallel,test-bundler,$(test_prechecks))
+prev_test := $(addsuffix -precheck,$(prev_test))
+first_test_prechecks := $(prev_test)
+
$(foreach test,$(ORDERED_TEST_TARGETS), \
- $(eval yes-$(value test) no-$(value test): $(value prev_test)); \
+ $(eval yes-$(value test): $(addprefix yes-,$(value prev_test))); \
+ $(eval no-$(value test): $(addprefix no-,$(value prev_test))); \
$(eval prev_test := $(value test)))
endif
@@ -170,15 +193,22 @@ $(SCRIPTBINDIR):
$(Q) mkdir $@
.PHONY: commit
-commit: $(if $(filter commit,$(MAKECMDGOALS)),$(filter-out commit,$(MAKECMDGOALS))) up
+COMMIT_PREPARE := $(filter-out commit do-commit,$(MAKECMDGOALS)) up
+
+commit: pre-commit $(DOT_WAIT) do-commit $(DOT_WAIT) post_commit
+pre-commit: $(COMMIT_PREPARE)
+do-commit: $(if $(DOT_WAIT),,pre-commit)
@$(BASERUBY) -C "$(srcdir)" -I./tool/lib -rvcs -e 'VCS.detect(".").commit'
+post-commit: $(if $(DOT_WAIT),,do-commit)
+$(Q) \
{ \
$(in-srcdir) \
exec sed -f tool/prereq.status defs/gmake.mk template/Makefile.in common.mk; \
} | \
- $(MAKE) $(mflags) Q=$(Q) ECHO=$(ECHO) srcdir="$(srcdir)" srcs_vpath="" CHDIR="$(CHDIR)" \
- BOOTSTRAPRUBY="$(BOOTSTRAPRUBY)" MINIRUBY="$(BASERUBY)" BASERUBY="$(BASERUBY)" \
+ $(MAKE) $(mflags) Q=$(Q) ECHO=$(ECHO) \
+ top_srcdir="$(top_srcdir)" srcdir="$(srcdir)" srcs_vpath="" CHDIR="$(CHDIR)" \
+ BOOTSTRAPRUBY="$(BOOTSTRAPRUBY)" BOOTSTRAPRUBY_OPT="$(BOOTSTRAPRUBY_OPT)" \
+ MINIRUBY="$(BASERUBY)" BASERUBY="$(BASERUBY)" HAVE_BASERUBY="$(HAVE_BASERUBY)" \
VCSUP="" ENC_MK=.top-enc.mk REVISION_FORCE=PHONY CONFIGURE="$(CONFIGURE)" -f - \
update-src srcs all-incs
@@ -269,6 +299,7 @@ HELP_EXTRA_TASKS = \
" checkout-github: checkout GitHub Pull Request [PR=1234]" \
" pull-github: rebase GitHub Pull Request to new worktree [PR=1234]" \
" update-github: merge master branch and push it to Pull Request [PR=1234]" \
+ " tags: generate TAGS file" \
""
# 1. squeeze spaces
@@ -295,6 +326,7 @@ foreach-bundled-gems-rev-0 = \
bundled-gem-gemfile = $(srcdir)/gems/$(1)-$(2).gem
bundled-gem-gemspec = $(srcdir)/gems/src/$(1)/$(1).gemspec
bundled-gem-extracted = $(srcdir)/.bundle/gems/$(1)-$(2)
+bundled-gem-revision = $(srcdir)/.bundle/.timestamp/$(1).revision
update-gems: | $(patsubst %,$(srcdir)/gems/%.gem,$(bundled-gems))
update-gems: | $(call foreach-bundled-gems-rev,bundled-gem-gemfile)
@@ -330,26 +362,33 @@ $(srcdir)/.bundle/.timestamp:
$(MAKEDIRS) $@
define build-gem
-$(srcdir)/gems/src/$(1)/$(1).gemspec: | $(srcdir)/gems/src
+$(srcdir)/gems/src/$(1)/.git: | $(srcdir)/gems/src
$(ECHO) Cloning $(4)
$(Q) $(GIT) clone $(4) $$(@D)
-$(srcdir)/.bundle/.timestamp/$(1).revision: $(srcdir)/gems/src/$(1)/$(1).gemspec \
+$(bundled-gem-revision): \
$(if $(if $(wildcard $$(@)),$(filter $(3),$(shell cat $$(@)))),,PHONY) \
- | $$(@D)
+ | $(srcdir)/.bundle/.timestamp $(srcdir)/gems/src/$(1)/.git
$(ECHO) Update $(1) to $(3)
$(Q) $(CHDIR) "$(srcdir)/gems/src/$(1)" && \
- $(GIT) fetch origin $(3) && \
- $(GIT) checkout --detach $(3) && \
- :
+ if [ `$(GIT) rev-parse HEAD` != $(3) ]; then \
+ $(GIT) fetch origin $(3) && \
+ $(GIT) checkout --detach $(3) && \
+ :; \
+ fi
echo $(3) | $(IFCHANGE) $$(@) -
-$(srcdir)/gems/$(1)-$(2).gem: $(srcdir)/gems/src/$(1)/$(1).gemspec \
- $(srcdir)/.bundle/.timestamp/$(1).revision
+# The repository of minitest does not include minitest.gemspec because it uses hoe.
+# This creates a dummy gemspec.
+$(bundled-gem-gemspec): $(bundled-gem-revision) \
+ | $(srcdir)/gems/src/$(1)/.git
+ $(Q) $(BASERUBY) -I$(tooldir)/lib -rbundled_gem -e 'BundledGem.dummy_gemspec(*ARGV)' $$(@)
+
+$(bundled-gem-gemfile): $(bundled-gem-gemspec) $(bundled-gem-revision)
$(ECHO) Building $(1)@$(3) to $$(@)
$(Q) $(BASERUBY) -C "$(srcdir)" \
-Itool/lib -rbundled_gem \
- -e 'BundledGem.build("gems/src/$(1)/$(1).gemspec", "$(2)", "gems")'
+ -e 'BundledGem.build("gems/src/$(1)/$(1).gemspec", "$(2)", "gems", validation: false)'
endef
define build-gem-0
@@ -372,39 +411,22 @@ ifneq ($(filter update-bundled_gems refresh-gems,$(MAKECMDGOALS)),)
update-gems: update-bundled_gems
endif
-ifeq ($(filter 0 1,$(words $(arch_flags))),)
-$(foreach x,$(patsubst -arch=%,%,$(arch_flags)), \
- $(eval $$(MJIT_HEADER:.h=)-$(value x).h \
- $$(MJIT_MIN_HEADER:.h=)-$(value x).h \
- $$(TIMESTAMPDIR)/$$(MJIT_HEADER:.h=)-$(value x).time \
- : ARCH_FLAG := -arch $(value x)))
-
-$(foreach x,$(patsubst -arch=%,%,$(arch_flags)), \
- $(eval $$(MJIT_HEADER:.h=)-$(value x).h: \
- $$(TIMESTAMPDIR)/$$(MJIT_HEADER:.h=)-$(value x).time))
-
-mjit_min_headers := $(patsubst -arch=%,$(MJIT_MIN_HEADER:.h=-%.h),$(arch_flags))
-$(MJIT_MIN_HEADER): $(mjit_min_headers) $(PREP)
- @ set -e; set $(patsubst -arch=%,%,$(arch_flags)); \
- cd $(@D); h=$(@F:.h=); \
- exec > $(@F).new; \
- echo '#if 0'; \
- for arch; do\
- echo "#elif defined __$${arch}__"; \
- echo "# include \"$$h-$$arch.h\""; \
- done; \
- echo "#else"; echo "# error unsupported platform"; echo "#endif"
- $(IFCHANGE) $@ $@.new
- $(Q) $(MAKEDIRS) $(MJIT_HEADER_INSTALL_DIR)
- $(Q) $(MAKE_LINK) $@ $(MJIT_HEADER_INSTALL_DIR)/$(@F)
-
-endif
-
.SECONDARY: update-unicode-files
.SECONDARY: update-unicode-auxiliary-files
.SECONDARY: update-unicode-ucd-emoji-files
.SECONDARY: update-unicode-emoji-files
+ifneq ($(DOT_WAIT),)
+.NOTPARALLEL: update-unicode
+.NOTPARALLEL: update-unicode-files
+.NOTPARALLEL: update-unicode-auxiliary-files
+.NOTPARALLEL: update-unicode-ucd-emoji-files
+.NOTPARALLEL: update-unicode-emoji-files
+.NOTPARALLEL: $(UNICODE_FILES) $(UNICODE_PROPERTY_FILES)
+.NOTPARALLEL: $(UNICODE_AUXILIARY_FILES)
+.NOTPARALLEL: $(UNICODE_UCD_EMOJI_FILES) $(UNICODE_EMOJI_FILES)
+endif
+
ifeq ($(HAVE_GIT),yes)
REVISION_LATEST := $(shell $(CHDIR) $(srcdir) && $(GIT) log -1 --format=%H 2>/dev/null)
else
@@ -505,3 +527,19 @@ matz: up
-e "s/^\(#define RUBY_ABI_VERSION\) .*/\1 0/" \
$(files:%=$(srcdir)/%)
$(GIT) -C $(srcdir) commit -m "$(message)" $(files)
+
+tags:
+ $(MAKE) GIT="$(GIT)" -C "$(srcdir)" -f defs/tags.mk
+
+
+# ripper_srcs makes all sources at once. invoking this target multiple
+# times in parallel means all sources will be built for the number of
+# sources times respectively.
+ifneq ($(DOT_WAIT),)
+.NOTPARALLEL: ripper_srcs
+else
+ripper_src =
+$(foreach r,$(RIPPER_SRCS),$(eval $(value r): | $(value ripper_src))\
+ $(eval ripper_src := $(value r)))
+ripper_srcs: $(ripper_src)
+endif
diff --git a/defs/id.def b/defs/id.def
index ebf00506ea..2ddde7be70 100644
--- a/defs/id.def
+++ b/defs/id.def
@@ -2,6 +2,7 @@
firstline, predefined = __LINE__+1, %[\
max
min
+ hash
freeze
nil?
inspect
@@ -25,7 +26,6 @@ firstline, predefined = __LINE__+1, %[\
lambda
send
__send__
- __attached__
__recursive_key__
initialize
initialize_copy
diff --git a/defs/tags.mk b/defs/tags.mk
new file mode 100644
index 0000000000..d29260c294
--- /dev/null
+++ b/defs/tags.mk
@@ -0,0 +1,18 @@
+# -*- mode: makefile-gmake; indent-tabs-mode: t -*-
+
+SRCS := $(shell $(GIT) ls-files \
+ *.[chy] *.def *.inc *.rb \
+ ccan/ coroutine/ include/ internal/ missing/ \
+ 'enc/**/*.[ch]' 'win32/**/*.[ch]' \
+ )
+
+TAGS: $(SRCS)
+ @echo updating $@
+ @tmp=$$(mktemp); \
+ trap 'rm -f "$$tmp"' 0; \
+ { \
+ $(GIT) grep -h --no-line-number -o '^ *# *define *RBIMPL_ATTR_[A-Z_]*(*' -- include | \
+ sed 's/^ *# *define *//;/_H$$/d;y/(/+/' | sort -u && \
+ echo 'NORETURN+'; \
+ } > "$$tmp" && \
+ ctags -e -I@"$$tmp" -h .def.inc --langmap=c:+.y.def.inc $(^)
diff --git a/defs/universal.mk b/defs/universal.mk
deleted file mode 100644
index c34a31b356..0000000000
--- a/defs/universal.mk
+++ /dev/null
@@ -1,5 +0,0 @@
-arch_flags := $(filter -arch=%,$(subst -arch ,-arch=,$(ARCH_FLAG)))
-ifeq ($(filter 0 1,$(words $(arch_flags))),)
-override MJIT_HEADER_SUFFIX = -%
-override MJIT_HEADER_ARCH = -$(word 2,$(ARCH_FLAG))
-endif
diff --git a/dir.c b/dir.c
index 3f73f83fc5..96c1a455b3 100644
--- a/dir.c
+++ b/dir.c
@@ -466,31 +466,26 @@ struct dir_data {
};
static void
-dir_mark(void *ptr)
-{
- struct dir_data *dir = ptr;
- rb_gc_mark(dir->path);
-}
-
-static void
dir_free(void *ptr)
{
struct dir_data *dir = ptr;
if (dir->dir) closedir(dir->dir);
- xfree(dir);
}
-static size_t
-dir_memsize(const void *ptr)
-{
- return sizeof(struct dir_data);
-}
+RUBY_REFERENCES(dir_refs) = {
+ RUBY_REF_EDGE(struct dir_data, path),
+ RUBY_REF_END
+};
static const rb_data_type_t dir_data_type = {
"dir",
- {dir_mark, dir_free, dir_memsize,},
- 0, 0, RUBY_TYPED_WB_PROTECTED | RUBY_TYPED_FREE_IMMEDIATELY
+ {
+ RUBY_REFS_LIST_PTR(dir_refs),
+ dir_free,
+ NULL, // Nothing allocated externally, so don't need a memsize function
+ },
+ 0, NULL, RUBY_TYPED_WB_PROTECTED | RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_DECL_MARKING | RUBY_TYPED_EMBEDDABLE
};
static VALUE dir_close(VALUE);
@@ -591,6 +586,45 @@ dir_s_close(rb_execution_context_t *ec, VALUE klass, VALUE dir)
return dir_close(dir);
}
+# if defined(HAVE_FDOPENDIR) && defined(HAVE_DIRFD)
+/*
+ * call-seq:
+ * Dir.for_fd(fd) -> dir
+ *
+ * Returns a new \Dir object representing the directory specified by the given
+ * integer directory file descriptor +fd+:
+ *
+ * d0 = Dir.new('..')
+ * d1 = Dir.for_fd(d0.fileno)
+ *
+ * Note that the returned +d1+ does not have an associated path:
+ *
+ * d0.path # => '..'
+ * d1.path # => nil
+ *
+ * This method uses the
+ * {fdopendir()}[https://www.man7.org/linux/man-pages/man3/fdopendir.3p.html]
+ * function defined by POSIX 2008;
+ * the method is not implemented on non-POSIX platforms (raises NotImplementedError).
+ */
+static VALUE
+dir_s_for_fd(VALUE klass, VALUE fd)
+{
+ struct dir_data *dp;
+ VALUE dir = TypedData_Make_Struct(klass, struct dir_data, &dir_data_type, dp);
+
+ if (!(dp->dir = fdopendir(NUM2INT(fd)))) {
+ rb_sys_fail("fdopendir");
+ UNREACHABLE_RETURN(Qnil);
+ }
+
+ RB_OBJ_WRITE(dir, &dp->path, Qnil);
+ return dir;
+}
+#else
+#define dir_s_for_fd rb_f_notimplement
+#endif
+
NORETURN(static void dir_closed(void));
static void
@@ -618,10 +652,13 @@ dir_check(VALUE dir)
/*
- * call-seq:
- * dir.inspect -> string
+ * call-seq:
+ * inspect -> string
+ *
+ * Returns a string description of +self+:
+ *
+ * Dir.new('example').inspect # => "#<Dir:example>"
*
- * Return a string describing this Dir object.
*/
static VALUE
dir_inspect(VALUE dir)
@@ -655,18 +692,18 @@ dir_inspect(VALUE dir)
#ifdef HAVE_DIRFD
/*
- * call-seq:
- * dir.fileno -> integer
- *
- * Returns the file descriptor used in <em>dir</em>.
+ * call-seq:
+ * fileno -> integer
*
- * d = Dir.new("..")
- * d.fileno #=> 8
+ * Returns the file descriptor used in <em>dir</em>.
*
- * This method uses dirfd() function defined by POSIX 2008.
- * NotImplementedError is raised on other platforms, such as Windows,
- * which doesn't provide the function.
+ * d = Dir.new('..')
+ * d.fileno # => 8
*
+ * This method uses the
+ * {dirfd()}[https://www.man7.org/linux/man-pages/man3/dirfd.3.html]
+ * function defined by POSIX 2008;
+ * the method is not implemented on non-POSIX platforms (raises NotImplementedError).
*/
static VALUE
dir_fileno(VALUE dir)
@@ -685,14 +722,14 @@ dir_fileno(VALUE dir)
#endif
/*
- * call-seq:
- * dir.path -> string or nil
- * dir.to_path -> string or nil
+ * call-seq:
+ * path -> string or nil
*
- * Returns the path parameter passed to <em>dir</em>'s constructor.
+ * Returns the +dirpath+ string that was used to create +self+
+ * (or +nil+ if created by method Dir.for_fd):
+ *
+ * Dir.new('example').path # => "example"
*
- * d = Dir.new("..")
- * d.path #=> ".."
*/
static VALUE
dir_path(VALUE dir)
@@ -746,16 +783,18 @@ to_be_skipped(const struct dirent *dp)
}
/*
- * call-seq:
- * dir.read -> string or nil
+ * call-seq:
+ * read -> string or nil
+ *
+ * Reads and returns the next entry name from +self+;
+ * returns +nil+ if at end-of-stream;
+ * see {Dir As Stream-Like}[rdoc-ref:Dir@Dir+As+Stream-Like]:
*
- * Reads the next entry from <em>dir</em> and returns it as a string.
- * Returns <code>nil</code> at the end of the stream.
+ * dir = Dir.new('example')
+ * dir.read # => "."
+ * dir.read # => ".."
+ * dir.read # => "config.h"
*
- * d = Dir.new("testdir")
- * d.read #=> "."
- * d.read #=> ".."
- * d.read #=> "config.h"
*/
static VALUE
dir_read(VALUE dir)
@@ -764,7 +803,7 @@ dir_read(VALUE dir)
struct dirent *dp;
GetDIR(dir, dirp);
- errno = 0;
+ rb_errno_set(0);
if ((dp = READDIR(dirp->dir, dirp->enc)) != NULL) {
return rb_external_str_new_with_enc(dp->d_name, NAMLEN(dp), dirp->enc);
}
@@ -784,24 +823,23 @@ dir_yield(VALUE arg, VALUE path)
}
/*
- * call-seq:
- * dir.each { |filename| block } -> dir
- * dir.each -> an_enumerator
+ * call-seq:
+ * each {|entry_name| ... } -> self
*
- * Calls the block once for each entry in this directory, passing the
- * filename of each entry as a parameter to the block.
+ * Calls the block with each entry name in +self+:
*
- * If no block is given, an enumerator is returned instead.
+ * Dir.new('example').each {|entry_name| p entry_name }
*
- * d = Dir.new("testdir")
- * d.each {|x| puts "Got #{x}" }
+ * Output:
+
+ * "."
+ * ".."
+ * "config.h"
+ * "lib"
+ * "main.rb"
*
- * <em>produces:</em>
+ * With no block given, returns an Enumerator.
*
- * Got .
- * Got ..
- * Got config.h
- * Got main.rb
*/
static VALUE
dir_each(VALUE dir)
@@ -844,16 +882,17 @@ dir_each_entry(VALUE dir, VALUE (*each)(VALUE, VALUE), VALUE arg, int children_o
#ifdef HAVE_TELLDIR
/*
- * call-seq:
- * dir.pos -> integer
- * dir.tell -> integer
+ * call-seq:
+ * tell -> integer
*
- * Returns the current position in <em>dir</em>. See also Dir#seek.
+ * Returns the current position of +self+;
+ * see {Dir As Stream-Like}[rdoc-ref:Dir@Dir+As+Stream-Like]:
+ *
+ * dir = Dir.new('example')
+ * dir.tell # => 0
+ * dir.read # => "."
+ * dir.tell # => 1
*
- * d = Dir.new("testdir")
- * d.tell #=> 0
- * d.read #=> "."
- * d.tell #=> 12
*/
static VALUE
dir_tell(VALUE dir)
@@ -871,18 +910,24 @@ dir_tell(VALUE dir)
#ifdef HAVE_SEEKDIR
/*
- * call-seq:
- * dir.seek( integer ) -> dir
- *
- * Seeks to a particular location in <em>dir</em>. <i>integer</i>
- * must be a value returned by Dir#tell.
- *
- * d = Dir.new("testdir") #=> #<Dir:0x401b3c40>
- * d.read #=> "."
- * i = d.tell #=> 12
- * d.read #=> ".."
- * d.seek(i) #=> #<Dir:0x401b3c40>
- * d.read #=> ".."
+ * call-seq:
+ * seek(position) -> self
+ *
+ * Sets the position in +self+ and returns +self+.
+ * The value of +position+ should have been returned from an earlier call to #tell;
+ * if not, the return values from subsequent calls to #read are unspecified.
+ *
+ * See {Dir As Stream-Like}[rdoc-ref:Dir@Dir+As+Stream-Like].
+ *
+ * Examples:
+ *
+ * dir = Dir.new('example')
+ * dir.pos # => 0
+ * dir.seek(3) # => #<Dir:example>
+ * dir.pos # => 3
+ * dir.seek(30) # => #<Dir:example>
+ * dir.pos # => 5
+ *
*/
static VALUE
dir_seek(VALUE dir, VALUE pos)
@@ -900,17 +945,24 @@ dir_seek(VALUE dir, VALUE pos)
#ifdef HAVE_SEEKDIR
/*
- * call-seq:
- * dir.pos = integer -> integer
+ * call-seq:
+ * pos = position -> integer
+ *
+ * Sets the position in +self+ and returns +position+.
+ * The value of +position+ should have been returned from an earlier call to #tell;
+ * if not, the return values from subsequent calls to #read are unspecified.
*
- * Synonym for Dir#seek, but returns the position parameter.
+ * See {Dir As Stream-Like}[rdoc-ref:Dir@Dir+As+Stream-Like].
+ *
+ * Examples:
+ *
+ * dir = Dir.new('example')
+ * dir.pos # => 0
+ * dir.pos = 3 # => 3
+ * dir.pos # => 3
+ * dir.pos = 30 # => 30
+ * dir.pos # => 5
*
- * d = Dir.new("testdir") #=> #<Dir:0x401b3c40>
- * d.read #=> "."
- * i = d.pos #=> 12
- * d.read #=> ".."
- * d.pos = i #=> 12
- * d.read #=> ".."
*/
static VALUE
dir_set_pos(VALUE dir, VALUE pos)
@@ -923,15 +975,19 @@ dir_set_pos(VALUE dir, VALUE pos)
#endif
/*
- * call-seq:
- * dir.rewind -> dir
+ * call-seq:
+ * rewind -> self
+ *
+ * Sets the position in +self+ to zero;
+ * see {Dir As Stream-Like}[rdoc-ref:Dir@Dir+As+Stream-Like]:
*
- * Repositions <em>dir</em> to the first entry.
+ * dir = Dir.new('example')
+ * dir.read # => "."
+ * dir.read # => ".."
+ * dir.pos # => 2
+ * dir.rewind # => #<Dir:example>
+ * dir.pos # => 0
*
- * d = Dir.new("testdir")
- * d.read #=> "."
- * d.rewind #=> #<Dir:0x401b3fb0>
- * d.read #=> "."
*/
static VALUE
dir_rewind(VALUE dir)
@@ -944,14 +1000,18 @@ dir_rewind(VALUE dir)
}
/*
- * call-seq:
- * dir.close -> nil
+ * call-seq:
+ * close -> nil
+ *
+ * Closes the stream in +self+, if it is open, and returns +nil+;
+ * ignored if +self+ is already closed:
*
- * Closes the directory stream.
- * Calling this method on closed Dir object is ignored since Ruby 2.3.
+ * dir = Dir.new('example')
+ * dir.read # => "."
+ * dir.close # => nil
+ * dir.close # => nil
+ * dir.read # Raises IOError.
*
- * d = Dir.new("testdir")
- * d.close #=> nil
*/
static VALUE
dir_close(VALUE dir)
@@ -975,7 +1035,7 @@ nogvl_chdir(void *ptr)
}
static void
-dir_chdir(VALUE path)
+dir_chdir0(VALUE path)
{
if (chdir(RSTRING_PTR(path)) < 0)
rb_sys_fail_path(path);
@@ -987,18 +1047,19 @@ static VALUE chdir_thread = Qnil;
struct chdir_data {
VALUE old_path, new_path;
int done;
+ bool yield_path;
};
static VALUE
chdir_yield(VALUE v)
{
struct chdir_data *args = (void *)v;
- dir_chdir(args->new_path);
+ dir_chdir0(args->new_path);
args->done = TRUE;
chdir_blocking++;
if (NIL_P(chdir_thread))
chdir_thread = rb_thread_current();
- return rb_yield(args->new_path);
+ return args->yield_path ? rb_yield(args->new_path) : rb_yield_values2(0, NULL);
}
static VALUE
@@ -1009,50 +1070,103 @@ chdir_restore(VALUE v)
chdir_blocking--;
if (chdir_blocking == 0)
chdir_thread = Qnil;
- dir_chdir(args->old_path);
+ dir_chdir0(args->old_path);
}
return Qnil;
}
+static VALUE
+chdir_path(VALUE path, bool yield_path)
+{
+ if (chdir_blocking > 0) {
+ if (rb_thread_current() != chdir_thread)
+ rb_raise(rb_eRuntimeError, "conflicting chdir during another chdir block");
+ if (!rb_block_given_p())
+ rb_warn("conflicting chdir during another chdir block");
+ }
+
+ if (rb_block_given_p()) {
+ struct chdir_data args;
+
+ args.old_path = rb_str_encode_ospath(rb_dir_getwd());
+ args.new_path = path;
+ args.done = FALSE;
+ args.yield_path = yield_path;
+ return rb_ensure(chdir_yield, (VALUE)&args, chdir_restore, (VALUE)&args);
+ }
+ else {
+ char *p = RSTRING_PTR(path);
+ int r = (int)(VALUE)rb_thread_call_without_gvl(nogvl_chdir, p,
+ RUBY_UBF_IO, 0);
+ if (r < 0)
+ rb_sys_fail_path(path);
+ }
+
+ return INT2FIX(0);
+}
+
/*
- * call-seq:
- * Dir.chdir( [ string] ) -> 0
- * Dir.chdir( [ string] ) {| path | block } -> anObject
- *
- * Changes the current working directory of the process to the given
- * string. When called without an argument, changes the directory to
- * the value of the environment variable <code>HOME</code>, or
- * <code>LOGDIR</code>. SystemCallError (probably Errno::ENOENT) if
- * the target directory does not exist.
- *
- * If a block is given, it is passed the name of the new current
- * directory, and the block is executed with that as the current
- * directory. The original working directory is restored when the block
- * exits. The return value of <code>chdir</code> is the value of the
- * block. <code>chdir</code> blocks can be nested, but in a
- * multi-threaded program an error will be raised if a thread attempts
- * to open a <code>chdir</code> block while another thread has one
- * open or a call to <code>chdir</code> without a block occurs inside
- * a block passed to <code>chdir</code> (even in the same thread).
- *
- * Dir.chdir("/var/spool/mail")
- * puts Dir.pwd
- * Dir.chdir("/tmp") do
- * puts Dir.pwd
- * Dir.chdir("/usr") do
- * puts Dir.pwd
- * end
- * puts Dir.pwd
+ * call-seq:
+ * Dir.chdir(new_dirpath) -> 0
+ * Dir.chdir -> 0
+ * Dir.chdir(new_dirpath) {|new_dirpath| ... } -> object
+ * Dir.chdir {|cur_dirpath| ... } -> object
+ *
+ * Changes the current working directory.
+ *
+ * With argument +new_dirpath+ and no block,
+ * changes to the given +dirpath+:
+ *
+ * Dir.pwd # => "/example"
+ * Dir.chdir('..') # => 0
+ * Dir.pwd # => "/"
+ *
+ * With no argument and no block:
+ *
+ * - Changes to the value of environment variable +HOME+ if defined.
+ * - Otherwise changes to the value of environment variable +LOGDIR+ if defined.
+ * - Otherwise makes no change.
+ *
+ * With argument +new_dirpath+ and a block, temporarily changes the working directory:
+ *
+ * - Calls the block with the argument.
+ * - Changes to the given directory.
+ * - Executes the block (yielding the new path).
+ * - Restores the previous working directory.
+ * - Returns the block's return value.
+ *
+ * Example:
+ *
+ * Dir.chdir('/var/spool/mail')
+ * Dir.pwd # => "/var/spool/mail"
+ * Dir.chdir('/tmp') do
+ * Dir.pwd # => "/tmp"
+ * end
+ * Dir.pwd # => "/var/spool/mail"
+ *
+ * With no argument and a block,
+ * calls the block with the current working directory (string)
+ * and returns the block's return value.
+ *
+ * Calls to \Dir.chdir with blocks may be nested:
+ *
+ * Dir.chdir('/var/spool/mail')
+ * Dir.pwd # => "/var/spool/mail"
+ * Dir.chdir('/tmp') do
+ * Dir.pwd # => "/tmp"
+ * Dir.chdir('/usr') do
+ * Dir.pwd # => "/usr"
* end
- * puts Dir.pwd
+ * Dir.pwd # => "/tmp"
+ * end
+ * Dir.pwd # => "/var/spool/mail"
*
- * <em>produces:</em>
+ * In a multi-threaded program an error is raised if a thread attempts
+ * to open a +chdir+ block while another thread has one open,
+ * or a call to +chdir+ without a block occurs inside
+ * a block passed to +chdir+ (even in the same thread).
*
- * /var/spool/mail
- * /tmp
- * /usr
- * /tmp
- * /var/spool/mail
+ * Raises an exception if the target directory does not exist.
*/
static VALUE
dir_s_chdir(int argc, VALUE *argv, VALUE obj)
@@ -1071,6 +1185,114 @@ dir_s_chdir(int argc, VALUE *argv, VALUE obj)
path = rb_str_new2(dist);
}
+ return chdir_path(path, true);
+}
+
+#if defined(HAVE_FCHDIR) && defined(HAVE_DIRFD) && HAVE_FCHDIR && HAVE_DIRFD
+static void *
+nogvl_fchdir(void *ptr)
+{
+ const int *fd = ptr;
+
+ return (void *)(VALUE)fchdir(*fd);
+}
+
+static void
+dir_fchdir(int fd)
+{
+ if (fchdir(fd) < 0)
+ rb_sys_fail("fchdir");
+}
+
+struct fchdir_data {
+ VALUE old_dir;
+ int fd;
+ int done;
+};
+
+static VALUE
+fchdir_yield(VALUE v)
+{
+ struct fchdir_data *args = (void *)v;
+ dir_fchdir(args->fd);
+ args->done = TRUE;
+ chdir_blocking++;
+ if (NIL_P(chdir_thread))
+ chdir_thread = rb_thread_current();
+ return rb_yield_values(0);
+}
+
+static VALUE
+fchdir_restore(VALUE v)
+{
+ struct fchdir_data *args = (void *)v;
+ if (args->done) {
+ chdir_blocking--;
+ if (chdir_blocking == 0)
+ chdir_thread = Qnil;
+ dir_fchdir(RB_NUM2INT(dir_fileno(args->old_dir)));
+ }
+ dir_close(args->old_dir);
+ return Qnil;
+}
+
+/*
+ * call-seq:
+ * Dir.fchdir(fd) -> 0
+ * Dir.fchdir(fd) { ... } -> object
+ *
+ * Changes the current working directory to the directory
+ * specified by the integer file descriptor +fd+.
+ *
+ * When passing a file descriptor over a UNIX socket or to a child process,
+ * using +fchdir+ instead of +chdir+ avoids the
+ * {time-of-check to time-of-use vulnerability}[https://en.wikipedia.org/wiki/Time-of-check_to_time-of-use]
+ *
+ * With no block, changes to the directory given by +fd+:
+ *
+ * Dir.chdir('/var/spool/mail')
+ * Dir.pwd # => "/var/spool/mail"
+ * dir = Dir.new('/usr')
+ * fd = dir.fileno
+ * Dir.fchdir(fd)
+ * Dir.pwd # => "/usr"
+ *
+ * With a block, temporarily changes the working directory:
+ *
+ * - Calls the block with the argument.
+ * - Changes to the given directory.
+ * - Executes the block (yields no args).
+ * - Restores the previous working directory.
+ * - Returns the block's return value.
+ *
+ * Example:
+ *
+ * Dir.chdir('/var/spool/mail')
+ * Dir.pwd # => "/var/spool/mail"
+ * dir = Dir.new('/tmp')
+ * fd = dir.fileno
+ * Dir.fchdir(fd) do
+ * Dir.pwd # => "/tmp"
+ * end
+ * Dir.pwd # => "/var/spool/mail"
+ *
+ * This method uses the
+ * {fchdir()}[https://www.man7.org/linux/man-pages/man3/fchdir.3p.html]
+ * function defined by POSIX 2008;
+ * the method is not implemented on non-POSIX platforms (raises NotImplementedError).
+ *
+ * Raises an exception if the file descriptor is not valid.
+ *
+ * In a multi-threaded program an error is raised if a thread attempts
+ * to open a +chdir+ block while another thread has one open,
+ * or a call to +chdir+ without a block occurs inside
+ * a block passed to +chdir+ (even in the same thread).
+ */
+static VALUE
+dir_s_fchdir(VALUE klass, VALUE fd_value)
+{
+ int fd = RB_NUM2INT(fd_value);
+
if (chdir_blocking > 0) {
if (rb_thread_current() != chdir_thread)
rb_raise(rb_eRuntimeError, "conflicting chdir during another chdir block");
@@ -1079,23 +1301,58 @@ dir_s_chdir(int argc, VALUE *argv, VALUE obj)
}
if (rb_block_given_p()) {
- struct chdir_data args;
-
- args.old_path = rb_str_encode_ospath(rb_dir_getwd());
- args.new_path = path;
+ struct fchdir_data args;
+ args.old_dir = dir_s_alloc(klass);
+ dir_initialize(NULL, args.old_dir, rb_fstring_cstr("."), Qnil);
+ args.fd = fd;
args.done = FALSE;
- return rb_ensure(chdir_yield, (VALUE)&args, chdir_restore, (VALUE)&args);
+ return rb_ensure(fchdir_yield, (VALUE)&args, fchdir_restore, (VALUE)&args);
}
else {
- char *p = RSTRING_PTR(path);
- int r = (int)(VALUE)rb_thread_call_without_gvl(nogvl_chdir, p,
- RUBY_UBF_IO, 0);
+ int r = (int)(VALUE)rb_thread_call_without_gvl(nogvl_fchdir, &fd,
+ RUBY_UBF_IO, 0);
if (r < 0)
- rb_sys_fail_path(path);
+ rb_sys_fail("fchdir");
}
return INT2FIX(0);
}
+#else
+#define dir_s_fchdir rb_f_notimplement
+#endif
+
+/*
+ * call-seq:
+ * chdir -> 0
+ * chdir { ... } -> object
+ *
+ * Changes the current working directory to +self+:
+ *
+ * Dir.pwd # => "/"
+ * dir = Dir.new('example')
+ * dir.chdir
+ * Dir.pwd # => "/example"
+ *
+ * With a block, temporarily changes the working directory:
+ *
+ * - Calls the block.
+ * - Changes to the given directory.
+ * - Executes the block (yields no args).
+ * - Restores the previous working directory.
+ * - Returns the block's return value.
+ *
+ * Uses Dir.fchdir if available, and Dir.chdir if not, see those
+ * methods for caveats.
+ */
+static VALUE
+dir_chdir(VALUE dir)
+{
+#if defined(HAVE_FCHDIR) && defined(HAVE_DIRFD) && HAVE_FCHDIR && HAVE_DIRFD
+ return dir_s_fchdir(rb_cDir, dir_fileno(dir));
+#else
+ return chdir_path(dir_get(dir)->path, false);
+#endif
+}
#ifndef _WIN32
VALUE
@@ -1143,16 +1400,14 @@ rb_dir_getwd(void)
}
/*
- * call-seq:
- * Dir.getwd -> string
- * Dir.pwd -> string
+ * call-seq:
+ * Dir.pwd -> string
+ *
+ * Returns the path to the current working directory:
*
- * Returns the path to the current working directory of this process as
- * a string.
+ * Dir.chdir("/tmp") # => 0
+ * Dir.pwd # => "/tmp"
*
- * Dir.chdir("/tmp") #=> 0
- * Dir.getwd #=> "/tmp"
- * Dir.pwd #=> "/tmp"
*/
static VALUE
dir_s_getwd(VALUE dir)
@@ -1182,13 +1437,16 @@ check_dirname(VALUE dir)
#if defined(HAVE_CHROOT)
/*
- * call-seq:
- * Dir.chroot( string ) -> 0
+ * call-seq:
+ * Dir.chroot(dirpath) -> 0
+ *
+ * Changes the root directory of the calling process to that specified in +dirpath+.
+ * The new root directory is used for pathnames beginning with <tt>'/'</tt>.
+ * The root directory is inherited by all children of the calling process.
+ *
+ * Only a privileged process may call +chroot+.
*
- * Changes this process's idea of the file system root. Only a
- * privileged process may make this call. Not available on all
- * platforms. On Unix systems, see <code>chroot(2)</code> for more
- * information.
+ * See {Linux chroot}[https://man7.org/linux/man-pages/man2/chroot.2.html].
*/
static VALUE
dir_s_chroot(VALUE dir, VALUE path)
@@ -1217,18 +1475,20 @@ nogvl_mkdir(void *ptr)
}
/*
- * call-seq:
- * Dir.mkdir( string [, integer] ) -> 0
+ * call-seq:
+ * Dir.mkdir(dirpath, permissions = 0775) -> 0
*
- * Makes a new directory named by <i>string</i>, with permissions
- * specified by the optional parameter <i>anInteger</i>. The
- * permissions may be modified by the value of File::umask, and are
- * ignored on NT. Raises a SystemCallError if the directory cannot be
- * created. See also the discussion of permissions in the class
- * documentation for File.
+ * Creates a directory in the underlying file system
+ * at +dirpath+ with the given +permissions+;
+ * returns zero:
*
- * Dir.mkdir(File.join(Dir.home, ".foo"), 0700) #=> 0
+ * Dir.mkdir('foo')
+ * File.stat(Dir.new('foo')).mode.to_s(8)[1..4] # => "0755"
+ * Dir.mkdir('bar', 0644)
+ * File.stat(Dir.new('bar')).mode.to_s(8)[1..4] # => "0644"
*
+ * See {File Permissions}[rdoc-ref:File@File+Permissions].
+ * Note that argument +permissions+ is ignored on Windows.
*/
static VALUE
dir_s_mkdir(int argc, VALUE *argv, VALUE obj)
@@ -1262,13 +1522,14 @@ nogvl_rmdir(void *ptr)
}
/*
- * call-seq:
- * Dir.delete( string ) -> 0
- * Dir.rmdir( string ) -> 0
- * Dir.unlink( string ) -> 0
+ * call-seq:
+ * Dir.rmdir(dirpath) -> 0
+ *
+ * Removes the directory at +dirpath+ from the underlying file system:
*
- * Deletes the named directory. Raises a subclass of SystemCallError
- * if the directory isn't empty.
+ * Dir.rmdir('foo') # => 0
+ *
+ * Raises an exception if the directory is not empty.
*/
static VALUE
dir_s_rmdir(VALUE obj, VALUE dir)
@@ -1476,7 +1737,7 @@ nogvl_opendir_at(void *ptr)
/* fallthrough*/
case 0:
if (fd >= 0) close(fd);
- errno = e;
+ rb_errno_set(e);
}
}
#else /* !USE_OPENDIR_AT */
@@ -2869,7 +3130,7 @@ push_glob(VALUE ary, VALUE str, VALUE base, int flags)
fd = AT_FDCWD;
if (!NIL_P(base)) {
if (!RB_TYPE_P(base, T_STRING) || !rb_enc_check(str, base)) {
- struct dir_data *dirp = DATA_PTR(base);
+ struct dir_data *dirp = RTYPEDDATA_GET_DATA(base);
if (!dirp->dir) dir_closed();
#ifdef HAVE_DIRFD
if ((fd = dirfd(dirp->dir)) == -1)
@@ -2993,26 +3254,35 @@ dir_open_dir(int argc, VALUE *argv)
/*
- * call-seq:
- * Dir.foreach( dirname ) {| filename | block } -> nil
- * Dir.foreach( dirname, encoding: enc ) {| filename | block } -> nil
- * Dir.foreach( dirname ) -> an_enumerator
- * Dir.foreach( dirname, encoding: enc ) -> an_enumerator
+ * call-seq:
+ * Dir.foreach(dirpath, encoding: 'UTF-8') {|entry_name| ... } -> nil
+ *
+ * Calls the block with each entry name in the directory at +dirpath+;
+ * sets the given encoding onto each passed +entry_name+:
+ *
+ * Dir.foreach('/example') {|entry_name| p entry_name }
+ *
+ * Output:
*
- * Calls the block once for each entry in the named directory, passing
- * the filename of each entry as a parameter to the block.
+ * "config.h"
+ * "lib"
+ * "main.rb"
+ * ".."
+ * "."
*
- * If no block is given, an enumerator is returned instead.
+ * Encoding:
*
- * Dir.foreach("testdir") {|x| puts "Got #{x}" }
+ * Dir.foreach('/example') {|entry_name| p entry_name.encoding; break }
+ * Dir.foreach('/example', encoding: 'US-ASCII') {|entry_name| p entry_name.encoding; break }
*
- * <em>produces:</em>
+ * Output:
*
- * Got .
- * Got ..
- * Got config.h
- * Got main.rb
+ * #<Encoding:UTF-8>
+ * #<Encoding:US-ASCII>
*
+ * See {String Encoding}[rdoc-ref:encodings.rdoc@String+Encoding].
+ *
+ * Returns an enumerator if no block is given.
*/
static VALUE
dir_foreach(int argc, VALUE *argv, VALUE io)
@@ -3034,19 +3304,21 @@ dir_collect(VALUE dir)
}
/*
- * call-seq:
- * Dir.entries( dirname ) -> array
- * Dir.entries( dirname, encoding: enc ) -> array
+ * call-seq:
+ * Dir.entries(dirname, encoding: 'UTF-8') -> array
*
- * Returns an array containing all of the filenames in the given
- * directory. Will raise a SystemCallError if the named directory
- * doesn't exist.
+ * Returns an array of the entry names in the directory at +dirpath+;
+ * sets the given encoding onto each returned entry name:
*
- * The optional <i>encoding</i> keyword argument specifies the encoding of the
- * directory. If not specified, the filesystem encoding is used.
+ * Dir.entries('/example') # => ["config.h", "lib", "main.rb", "..", "."]
+ * Dir.entries('/example').first.encoding
+ * # => #<Encoding:UTF-8>
+ * Dir.entries('/example', encoding: 'US-ASCII').first.encoding
+ * # => #<Encoding:US-ASCII>
*
- * Dir.entries("testdir") #=> [".", "..", "config.h", "main.rb"]
+ * See {String Encoding}[rdoc-ref:encodings.rdoc@String+Encoding].
*
+ * Raises an exception if the directory does not exist.
*/
static VALUE
dir_entries(int argc, VALUE *argv, VALUE io)
@@ -3064,25 +3336,12 @@ dir_each_child(VALUE dir)
}
/*
- * call-seq:
- * Dir.each_child( dirname ) {| filename | block } -> nil
- * Dir.each_child( dirname, encoding: enc ) {| filename | block } -> nil
- * Dir.each_child( dirname ) -> an_enumerator
- * Dir.each_child( dirname, encoding: enc ) -> an_enumerator
- *
- * Calls the block once for each entry except for "." and ".." in the
- * named directory, passing the filename of each entry as a parameter
- * to the block.
- *
- * If no block is given, an enumerator is returned instead.
- *
- * Dir.each_child("testdir") {|x| puts "Got #{x}" }
- *
- * <em>produces:</em>
- *
- * Got config.h
- * Got main.rb
+ * call-seq:
+ * Dir.each_child(dirpath) {|entry_name| ... } -> nil
+ * Dir.each_child(dirpath, encoding: 'UTF-8') {|entry_name| ... } -> nil
*
+ * Like Dir.foreach, except that entries <tt>'.'</tt> and <tt>'..'</tt>
+ * are not included.
*/
static VALUE
dir_s_each_child(int argc, VALUE *argv, VALUE io)
@@ -3096,24 +3355,22 @@ dir_s_each_child(int argc, VALUE *argv, VALUE io)
}
/*
- * call-seq:
- * dir.each_child {| filename | block } -> dir
- * dir.each_child -> an_enumerator
- *
- * Calls the block once for each entry except for "." and ".." in
- * this directory, passing the filename of each entry as a parameter
- * to the block.
+ * call-seq:
+ * each_child {|entry_name| ... } -> self
*
- * If no block is given, an enumerator is returned instead.
+ * Calls the block with each entry name in +self+
+ * except <tt>'.'</tt> and <tt>'..'</tt>:
*
- * d = Dir.new("testdir")
- * d.each_child {|x| puts "Got #{x}" }
+ * dir = Dir.new('/example')
+ * dir.each_child {|entry_name| p entry_name }
*
- * <em>produces:</em>
+ * Output:
*
- * Got config.h
- * Got main.rb
+ * "config.h"
+ * "lib"
+ * "main.rb"
*
+ * If no block is given, returns an enumerator.
*/
static VALUE
dir_each_child_m(VALUE dir)
@@ -3123,14 +3380,14 @@ dir_each_child_m(VALUE dir)
}
/*
- * call-seq:
- * dir.children -> array
+ * call-seq:
+ * children -> array
*
- * Returns an array containing all of the filenames except for "."
- * and ".." in this directory.
+ * Returns an array of the entry names in +self+
+ * except for <tt>'.'</tt> and <tt>'..'</tt>:
*
- * d = Dir.new("testdir")
- * d.children #=> ["config.h", "main.rb"]
+ * dir = Dir.new('/example')
+ * dir.children # => ["config.h", "lib", "main.rb"]
*
*/
static VALUE
@@ -3142,19 +3399,23 @@ dir_collect_children(VALUE dir)
}
/*
- * call-seq:
- * Dir.children( dirname ) -> array
- * Dir.children( dirname, encoding: enc ) -> array
+ * call-seq:
+ * Dir.children(dirpath) -> array
+ * Dir.children(dirpath, encoding: 'UTF-8') -> array
*
- * Returns an array containing all of the filenames except for "."
- * and ".." in the given directory. Will raise a SystemCallError if
- * the named directory doesn't exist.
+ * Returns an array of the entry names in the directory at +dirpath+
+ * except for <tt>'.'</tt> and <tt>'..'</tt>;
+ * sets the given encoding onto each returned entry name:
*
- * The optional <i>encoding</i> keyword argument specifies the encoding of the
- * directory. If not specified, the filesystem encoding is used.
+ * Dir.children('/example') # => ["config.h", "lib", "main.rb"]
+ * Dir.children('/example').first.encoding
+ * # => #<Encoding:UTF-8>
+ * Dir.children('/example', encoding: 'US-ASCII').first.encoding
+ * # => #<Encoding:US-ASCII>
*
- * Dir.children("testdir") #=> ["config.h", "main.rb"]
+ * See {String Encoding}[rdoc-ref:encodings.rdoc@String+Encoding].
*
+ * Raises an exception if the directory does not exist.
*/
static VALUE
dir_s_children(int argc, VALUE *argv, VALUE io)
@@ -3228,12 +3489,16 @@ file_s_fnmatch(int argc, VALUE *argv, VALUE obj)
}
/*
- * call-seq:
- * Dir.home() -> "/home/me"
- * Dir.home("root") -> "/root"
+ * call-seq:
+ * Dir.home(user_name = nil) -> dirpath
*
- * Returns the home directory of the current user or the named user
- * if given.
+ * Retruns the home directory path of the user specified with +user_name+
+ * if it is not +nil+, or the current login user:
+ *
+ * Dir.home # => "/home/me"
+ * Dir.home('root') # => "/root"
+ *
+ * Raises ArgumentError if +user_name+ is not a user name.
*/
static VALUE
dir_s_home(int argc, VALUE *argv, VALUE obj)
@@ -3258,10 +3523,15 @@ dir_s_home(int argc, VALUE *argv, VALUE obj)
#if 0
/*
* call-seq:
- * Dir.exist?(file_name) -> true or false
+ * Dir.exist?(dirpath) -> true or false
+ *
+ * Returns whether +dirpath+ is a directory in the underlying file system:
*
- * Returns <code>true</code> if the named file is a directory,
- * <code>false</code> otherwise.
+ * Dir.exist?('/example') # => true
+ * Dir.exist?('/nosuch') # => false
+ * Dir.exist?('/example/main.rb') # => false
+ *
+ * Same as File.directory?.
*
*/
VALUE
@@ -3288,8 +3558,7 @@ nogvl_dir_empty_p(void *ptr)
/* fall through */
case 0:
if (e == ENOTDIR) return (void *)Qfalse;
- errno = e; /* for rb_sys_fail_path */
- return (void *)Qundef;
+ return (void *)INT2FIX(e);
}
}
while ((dp = READDIR(dir, NULL)) != NULL) {
@@ -3304,10 +3573,18 @@ nogvl_dir_empty_p(void *ptr)
/*
* call-seq:
- * Dir.empty?(path_name) -> true or false
+ * Dir.empty?(dirpath) -> true or false
+ *
+ * Returns whether +dirpath+ specifies an empty directory:
+ *
+ * dirpath = '/tmp/foo'
+ * Dir.mkdir(dirpath)
+ * Dir.empty?(dirpath) # => true
+ * Dir.empty?('/example') # => false
+ * Dir.empty?('/example/main.rb') # => false
*
- * Returns <code>true</code> if the named file is an empty directory,
- * <code>false</code> if it is not a directory or non-empty.
+ * Raises an exception if +dirpath+ does not specify a directory or file
+ * in the underlying file system.
*/
static VALUE
rb_dir_s_empty_p(VALUE obj, VALUE dirname)
@@ -3343,8 +3620,8 @@ rb_dir_s_empty_p(VALUE obj, VALUE dirname)
result = (VALUE)rb_thread_call_without_gvl(nogvl_dir_empty_p, (void *)path,
RUBY_UBF_IO, 0);
- if (UNDEF_P(result)) {
- rb_sys_fail_path(orig);
+ if (FIXNUM_P(result)) {
+ rb_syserr_fail_path((int)FIX2LONG(result), orig);
}
return result;
}
@@ -3357,6 +3634,7 @@ Init_Dir(void)
rb_include_module(rb_cDir, rb_mEnumerable);
rb_define_alloc_func(rb_cDir, dir_s_alloc);
+ rb_define_singleton_method(rb_cDir,"for_fd", dir_s_for_fd, 1);
rb_define_singleton_method(rb_cDir, "foreach", dir_foreach, -1);
rb_define_singleton_method(rb_cDir, "entries", dir_entries, -1);
rb_define_singleton_method(rb_cDir, "each_child", dir_s_each_child, -1);
@@ -3376,7 +3654,9 @@ Init_Dir(void)
rb_define_method(rb_cDir,"pos", dir_tell, 0);
rb_define_method(rb_cDir,"pos=", dir_set_pos, 1);
rb_define_method(rb_cDir,"close", dir_close, 0);
+ rb_define_method(rb_cDir,"chdir", dir_chdir, 0);
+ rb_define_singleton_method(rb_cDir,"fchdir", dir_s_fchdir, 1);
rb_define_singleton_method(rb_cDir,"chdir", dir_s_chdir, -1);
rb_define_singleton_method(rb_cDir,"getwd", dir_s_getwd, 0);
rb_define_singleton_method(rb_cDir,"pwd", dir_s_getwd, 0);
@@ -3393,51 +3673,26 @@ Init_Dir(void)
rb_define_singleton_method(rb_cFile,"fnmatch", file_s_fnmatch, -1);
rb_define_singleton_method(rb_cFile,"fnmatch?", file_s_fnmatch, -1);
- /* Document-const: File::Constants::FNM_NOESCAPE
- *
- * Disables escapes in File.fnmatch and Dir.glob patterns
- */
+ /* Document-const: FNM_NOESCAPE
+ * {File::FNM_NOESCAPE}[rdoc-ref:File::Constants@File-3A-3AFNM_NOESCAPE] */
rb_file_const("FNM_NOESCAPE", INT2FIX(FNM_NOESCAPE));
-
- /* Document-const: File::Constants::FNM_PATHNAME
- *
- * Wildcards in File.fnmatch and Dir.glob patterns do not match directory
- * separators
- */
+ /* Document-const: FNM_PATHNAME
+ * {File::FNM_PATHNAME}[rdoc-ref:File::Constants@File-3A-3AFNM_PATHNAME] */
rb_file_const("FNM_PATHNAME", INT2FIX(FNM_PATHNAME));
-
- /* Document-const: File::Constants::FNM_DOTMATCH
- *
- * The '*' wildcard matches filenames starting with "." in File.fnmatch
- * and Dir.glob patterns
- */
+ /* Document-const: FNM_DOTMATCH
+ * {File::FNM_DOTMATCH}[rdoc-ref:File::Constants@File-3A-3AFNM_DOTMATCH] */
rb_file_const("FNM_DOTMATCH", INT2FIX(FNM_DOTMATCH));
-
- /* Document-const: File::Constants::FNM_CASEFOLD
- *
- * Makes File.fnmatch patterns case insensitive (but not Dir.glob
- * patterns).
- */
+ /* Document-const: FNM_CASEFOLD
+ * {File::FNM_CASEFOLD}[rdoc-ref:File::Constants@File-3A-3AFNM_CASEFOLD] */
rb_file_const("FNM_CASEFOLD", INT2FIX(FNM_CASEFOLD));
-
- /* Document-const: File::Constants::FNM_EXTGLOB
- *
- * Allows file globbing through "{a,b}" in File.fnmatch patterns.
- */
+ /* Document-const: FNM_EXTGLOB
+ * {File::FNM_EXTGLOB}[rdoc-ref:File::Constants@File-3A-3AFNM_EXTGLOB] */
rb_file_const("FNM_EXTGLOB", INT2FIX(FNM_EXTGLOB));
-
- /* Document-const: File::Constants::FNM_SYSCASE
- *
- * System default case insensitiveness, equals to FNM_CASEFOLD or
- * 0.
- */
+ /* Document-const: FNM_SYSCASE
+ * {File::FNM_SYSCASE}[rdoc-ref:File::Constants@File-3A-3AFNM_SYSCASE] */
rb_file_const("FNM_SYSCASE", INT2FIX(FNM_SYSCASE));
-
- /* Document-const: File::Constants::FNM_SHORTNAME
- *
- * Makes patterns to match short names if existing. Valid only
- * on Microsoft Windows.
- */
+ /* Document-const: FNM_SHORTNAME
+ * {File::FNM_SHORTNAME}[rdoc-ref:File::Constants@File-3A-3AFNM_SHORTNAME] */
rb_file_const("FNM_SHORTNAME", INT2FIX(FNM_SHORTNAME));
}
diff --git a/dir.rb b/dir.rb
index 2e426b0881..632c49eee9 100644
--- a/dir.rb
+++ b/dir.rb
@@ -1,11 +1,85 @@
-# Objects of class Dir are directory streams representing
-# directories in the underlying file system. They provide a variety
-# of ways to list directories and their contents. See also File.
+# An object of class \Dir represents a directory in the underlying file system.
#
-# The directory used in these examples contains the two regular files
-# (<code>config.h</code> and <code>main.rb</code>), the parent
-# directory (<code>..</code>), and the directory itself
-# (<code>.</code>).
+# It consists mainly of:
+#
+# - A string _path_, given when the object is created,
+# that specifies a directory in the underlying file system;
+# method #path returns the path.
+# - A collection of string <i>entry names</i>,
+# each of which is the name of a directory or file in the underlying file system;
+# the entry names may be retrieved
+# in an {array-like fashion}[rdoc-ref:Dir@Dir+As+Array-Like]
+# or in a {stream-like fashion}[rdoc-ref:Dir@Dir+As+Stream-Like].
+#
+# == About the Examples
+#
+# Some examples on this page use this simple file tree:
+#
+# example/
+# ├── config.h
+# ├── lib/
+# │ ├── song/
+# │ │ └── karaoke.rb
+# │ └── song.rb
+# └── main.rb
+#
+# Others use the file tree for the
+# {Ruby project itself}[https://github.com/ruby/ruby].
+#
+# == \Dir As \Array-Like
+#
+# A \Dir object is in some ways array-like:
+#
+# - It has instance methods #children, #each, and #each_child.
+# - It includes {module Enumerable}[rdoc-ref:Enumerable@What-27s+Here].
+#
+# == \Dir As Stream-Like
+#
+# A \Dir object is in some ways stream-like.
+#
+# The stream is initially open for reading,
+# but may be closed manually (using method #close),
+# and will be closed on block exit if created by Dir.open called with a block.
+# The closed stream may not be further manipulated,
+# and may not be reopened.
+#
+# The stream has a _position_, which is the index of an entry in the directory:
+#
+# - The initial position is zero (before the first entry).
+# - \Method #tell (aliased as #pos) returns the position.
+# - \Method #pos= sets the position (but ignores a value outside the stream),
+# and returns the position.
+# - \Method #seek is like #pos=, but returns +self+ (convenient for chaining).
+# - \Method #read, if not at end-of-stream, reads the next entry and increments
+# the position;
+# if at end-of-stream, does not increment the position.
+# - \Method #rewind sets the position to zero.
+#
+# Examples (using the {simple file tree}[rdoc-ref:Dir@About+the+Examples]):
+#
+# dir = Dir.new('example') # => #<Dir:example>
+# dir.pos # => 0
+#
+# dir.read # => "."
+# dir.read # => ".."
+# dir.read # => "config.h"
+# dir.read # => "lib"
+# dir.read # => "main.rb"
+# dir.pos # => 5
+# dir.read # => nil
+# dir.pos # => 5
+#
+# dir.rewind # => #<Dir:example>
+# dir.pos # => 0
+#
+# dir.pos = 3 # => 3
+# dir.pos # => 3
+#
+# dir.seek(4) # => #<Dir:example>
+# dir.pos # => 4
+#
+# dir.close # => nil
+# dir.read # Raises IOError.
#
# == What's Here
#
@@ -80,20 +154,32 @@
# closing it upon block exit.
# - ::unlink (aliased as ::delete and ::rmdir): Removes the given directory.
# - #inspect: Returns a string description of +self+.
+#
class Dir
# call-seq:
- # Dir.open( string ) -> aDir
- # Dir.open( string, encoding: enc ) -> aDir
- # Dir.open( string ) {| aDir | block } -> anObject
- # Dir.open( string, encoding: enc ) {| aDir | block } -> anObject
- #
- # The optional <i>encoding</i> keyword argument specifies the encoding of the directory.
- # If not specified, the filesystem encoding is used.
- #
- # With no block, <code>open</code> is a synonym for Dir::new. If a
- # block is present, it is passed <i>aDir</i> as a parameter. The
- # directory is closed at the end of the block, and Dir::open returns
- # the value of the block.
+ # Dir.open(dirpath) -> dir
+ # Dir.open(dirpath, encoding: nil) -> dir
+ # Dir.open(dirpath) {|dir| ... } -> object
+ # Dir.open(dirpath, encoding: nil) {|dir| ... } -> object
+ #
+ # Creates a new \Dir object _dir_ for the directory at +dirpath+.
+ #
+ # With no block, the method equivalent to Dir.new(dirpath, encoding):
+ #
+ # Dir.open('.') # => #<Dir:.>
+ #
+ # With a block given, the block is called with the created _dir_;
+ # on block exit _dir_ is closed and the block's value is returned:
+ #
+ # Dir.open('.') {|dir| dir.inspect } # => "#<Dir:.>"
+ #
+ # The value given with optional keyword argument +encoding+
+ # specifies the encoding for the directory entry names;
+ # if +nil+ (the default), the file system's encoding is used:
+ #
+ # Dir.open('.').read.encoding # => #<Encoding:UTF-8>
+ # Dir.open('.', encoding: 'US-ASCII').read.encoding # => #<Encoding:US-ASCII>
+ #
def self.open(name, encoding: nil, &block)
dir = Primitive.dir_s_open(name, encoding)
if block
@@ -108,114 +194,219 @@ class Dir
end
# call-seq:
- # Dir.new( string ) -> aDir
- # Dir.new( string, encoding: enc ) -> aDir
+ # Dir.new(dirpath) -> dir
+ # Dir.new(dirpath, encoding: nil) -> dir
+ #
+ # Returns a new \Dir object for the directory at +dirpath+:
+ #
+ # Dir.new('.') # => #<Dir:.>
#
- # Returns a new directory object for the named directory.
+ # The value given with optional keyword argument +encoding+
+ # specifies the encoding for the directory entry names;
+ # if +nil+ (the default), the file system's encoding is used:
+ #
+ # Dir.new('.').read.encoding # => #<Encoding:UTF-8>
+ # Dir.new('.', encoding: 'US-ASCII').read.encoding # => #<Encoding:US-ASCII>
#
- # The optional <i>encoding</i> keyword argument specifies the encoding of the directory.
- # If not specified, the filesystem encoding is used.
def initialize(name, encoding: nil)
Primitive.dir_initialize(name, encoding)
end
# call-seq:
- # Dir[ string [, string ...] [, base: path] [, sort: true] ] -> array
+ # Dir[*patterns, base: nil, sort: true] -> array
+ #
+ # Calls Dir.glob with argument +patterns+
+ # and the values of keyword arguments +base+ and +sort+;
+ # returns the array of selected entry names.
#
- # Equivalent to calling
- # <code>Dir.glob([</code><i>string,...</i><code>], 0)</code>.
def self.[](*args, base: nil, sort: true)
Primitive.dir_s_aref(args, base, sort)
end
# call-seq:
- # Dir.glob( pattern, [flags], [base: path] [, sort: true] ) -> array
- # Dir.glob( pattern, [flags], [base: path] [, sort: true] ) { |filename| block } -> nil
+ # Dir.glob(*patterns, flags: 0, base: nil, sort: true) -> array
+ # Dir.glob(*patterns, flags: 0, base: nil, sort: true) {|entry_name| ... } -> nil
#
- # Expands +pattern+, which is a pattern string or an Array of pattern
- # strings, and returns an array containing the matching filenames.
- # If a block is given, calls the block once for each matching filename,
- # passing the filename as a parameter to the block.
+ # Forms an array _entry_names_ of the entry names selected by the arguments.
#
- # The optional +base+ keyword argument specifies the base directory for
- # interpreting relative pathnames instead of the current working directory.
- # As the results are not prefixed with the base directory name in this
- # case, you will need to prepend the base directory name if you want real
- # paths.
+ # Argument +patterns+ is a string pattern or an array of string patterns;
+ # note that these are not regexps; see below.
#
- # The results which matched single wildcard or character set are sorted in
- # binary ascending order, unless +false+ is given as the optional +sort+
- # keyword argument. The order of an Array of pattern strings and braces
- # are preserved.
+ # Notes for the following examples:
#
- # Note that the pattern is not a regexp, it's closer to a shell glob.
- # See File::fnmatch for the meaning of the +flags+ parameter.
- # Case sensitivity depends on your system (+File::FNM_CASEFOLD+ is ignored).
+ # - <tt>'*'</tt> is the pattern that matches any entry name
+ # except those that begin with <tt>'.'</tt>.
+ # - We use method Array#take to shorten returned arrays
+ # that otherwise would be very large.
#
- # <code>*</code>::
- # Matches any file. Can be restricted by other values in the glob.
- # Equivalent to <code>/.*/mx</code> in regexp.
+ # With no block, returns array _entry_names_;
+ # example (using the {simple file tree}[rdoc-ref:Dir@About+the+Examples]):
#
- # <code>*</code>:: Matches all files
- # <code>c*</code>:: Matches all files beginning with <code>c</code>
- # <code>*c</code>:: Matches all files ending with <code>c</code>
- # <code>\*c\*</code>:: Match all files that have <code>c</code> in them
- # (including at the beginning or end).
+ # Dir.glob('*') # => ["config.h", "lib", "main.rb"]
#
- # Note, this will not match Unix-like hidden files (dotfiles). In order
- # to include those in the match results, you must use the
- # File::FNM_DOTMATCH flag or something like <code>"{*,.*}"</code>.
+ # With a block, calls the block with each of the _entry_names_
+ # and returns +nil+:
#
- # <code>**</code>::
- # Matches directories recursively if followed by <code>/</code>. If
- # this path segment contains any other characters, it is the same as the
- # usual <code>*</code>.
+ # Dir.glob('*') {|entry_name| puts entry_name } # => nil
#
- # <code>?</code>::
- # Matches any one character. Equivalent to <code>/.{1}/</code> in regexp.
+ # Output:
#
- # <code>[set]</code>::
- # Matches any one character in +set+. Behaves exactly like character sets
- # in Regexp, including set negation (<code>[^a-z]</code>).
+ # config.h
+ # lib
+ # main.rb
#
- # <code>{p,q}</code>::
- # Matches either literal <code>p</code> or literal <code>q</code>.
- # Equivalent to pattern alternation in regexp.
+ # If optional keyword argument +flags+ is given,
+ # the value modifies the matching; see below.
#
- # Matching literals may be more than one character in length. More than
- # two literals may be specified.
+ # If optional keyword argument +base+ is given,
+ # its value specifies the base directory.
+ # Each pattern string specifies entries relative to the base directory;
+ # the default is <tt>'.'</tt>.
+ # The base directory is not prepended to the entry names in the result:
#
- # <code>\\</code>::
- # Escapes the next metacharacter.
+ # Dir.glob(pattern, base: 'lib').take(5)
+ # # => ["abbrev.gemspec", "abbrev.rb", "base64.gemspec", "base64.rb", "benchmark.gemspec"]
+ # Dir.glob(pattern, base: 'lib/irb').take(5)
+ # # => ["cmd", "color.rb", "color_printer.rb", "completion.rb", "context.rb"]
#
- # Note that this means you cannot use backslash on windows as part of a
- # glob, i.e. <code>Dir["c:\\foo*"]</code> will not work, use
- # <code>Dir["c:/foo*"]</code> instead.
+ # If optional keyword +sort+ is given, its value specifies whether
+ # the array is to be sorted; the default is +true+.
+ # Passing value +false+ with that keyword disables sorting
+ # (though the underlying file system may already have sorted the array).
#
- # Examples:
+ # <b>Patterns</b>
+ #
+ # Each pattern string is expanded
+ # according to certain metacharacters;
+ # examples below use the {Ruby file tree}[rdoc-ref:Dir@About+the+Examples]:
+ #
+ # - <tt>'*'</tt>: Matches any substring in an entry name,
+ # similar in meaning to regexp <tt>/.*/mx</tt>;
+ # may be restricted by other values in the pattern strings:
+ #
+ # - <tt>'*'</tt> matches all entry names:
+ #
+ # Dir.glob('*').take(3) # => ["BSDL", "CONTRIBUTING.md", "COPYING"]
+ #
+ # - <tt>'c*'</tt> matches entry names beginning with <tt>'c'</tt>:
+ #
+ # Dir.glob('c*').take(3) # => ["CONTRIBUTING.md", "COPYING", "COPYING.ja"]
+ #
+ # - <tt>'*c'</tt> matches entry names ending with <tt>'c'</tt>:
+ #
+ # Dir.glob('*c').take(3) # => ["addr2line.c", "array.c", "ast.c"]
+ #
+ # - <tt>'\*c\*'</tt> matches entry names that contain <tt>'c'</tt>,
+ # even at the beginning or end:
+ #
+ # Dir.glob('*c*').take(3) # => ["CONTRIBUTING.md", "COPYING", "COPYING.ja"]
+ #
+ # Does not match Unix-like hidden entry names ("dot files").
+ # To include those in the matched entry names,
+ # use flag IO::FNM_DOTMATCH or something like <tt>'{*,.*}'</tt>.
+ #
+ # - <tt>'**'</tt>: Matches entry names recursively
+ # if followed by the slash character <tt>'/'</tt>:
+ #
+ # Dir.glob('**/').take(3) # => ["basictest/", "benchmark/", "benchmark/gc/"]
+ #
+ # If the string pattern contains other characters
+ # or is not followed by a slash character,
+ # it is equivalent to <tt>'*'</tt>.
+ #
+ # - <tt>'?'</tt> Matches any single character;
+ # similar in meaning to regexp <tt>/./</tt>:
+ #
+ # Dir.glob('io.?') # => ["io.c"]
+ #
+ # - <tt>'[_set_]'</tt>: Matches any one character in the string _set_;
+ # behaves like a {Regexp character class}[rdoc-ref:Regexp@Character+Classes],
+ # including set negation (<tt>'[^a-z]'</tt>):
+ #
+ # Dir.glob('*.[a-z][a-z]').take(3)
+ # # => ["CONTRIBUTING.md", "COPYING.ja", "KNOWNBUGS.rb"]
+ #
+ # - <tt>'{_abc_,_xyz_}'</tt>:
+ # Matches either string _abc_ or string _xyz_;
+ # behaves like {Regexp alternation}[rdoc-ref:Regexp@Alternation]:
+ #
+ # Dir.glob('{LEGAL,BSDL}') # => ["LEGAL", "BSDL"]
+ #
+ # More than two alternatives may be given.
+ #
+ # - <tt>\\</tt>: Escapes the following metacharacter.
+ #
+ # Note that on Windows, the backslash character may not be used
+ # in a string pattern:
+ # <tt>Dir['c:\\foo*']</tt> will not work, use <tt>Dir['c:/foo*']</tt> instead.
+ #
+ # More examples (using the {simple file tree}[rdoc-ref:Dir@About+the+Examples]):
+ #
+ # # We're in the example directory.
+ # File.basename(Dir.pwd) # => "example"
+ # Dir.glob('config.?') # => ["config.h"]
+ # Dir.glob('*.[a-z][a-z]') # => ["main.rb"]
+ # Dir.glob('*.[^r]*') # => ["config.h"]
+ # Dir.glob('*.{rb,h}') # => ["main.rb", "config.h"]
+ # Dir.glob('*') # => ["config.h", "lib", "main.rb"]
+ # Dir.glob('*', File::FNM_DOTMATCH) # => [".", "config.h", "lib", "main.rb"]
+ # Dir.glob(["*.rb", "*.h"]) # => ["main.rb", "config.h"]
+ #
+ # Dir.glob('**/*.rb')
+ # => ["lib/song/karaoke.rb", "lib/song.rb", "main.rb"]
+ #
+ # Dir.glob('**/*.rb', base: 'lib') # => ["song/karaoke.rb", "song.rb"]
+ #
+ # Dir.glob('**/lib') # => ["lib"]
+ #
+ # Dir.glob('**/lib/**/*.rb') # => ["lib/song/karaoke.rb", "lib/song.rb"]
+ #
+ # Dir.glob('**/lib/*.rb') # => ["lib/song.rb"]
+ #
+ # <b>Flags</b>
+ #
+ # If optional keyword argument +flags+ is given (the default is zero -- no flags),
+ # its value should be the bitwise OR of one or more of the constants
+ # defined in module File::Constants.
+ #
+ # Example:
+ #
+ # flags = File::FNM_EXTGLOB | File::FNM_DOTMATCH
+ #
+ # Specifying flags can extend, restrict, or otherwise modify the matching.
+ #
+ # The flags for this method (other constants in File::Constants do not apply):
+ #
+ # - File::FNM_DOTMATCH:
+ # specifies that entry names beginning with <tt>'.'</tt>
+ # should be considered for matching:
+ #
+ # Dir.glob('*').take(5)
+ # # => ["BSDL", "CONTRIBUTING.md", "COPYING", "COPYING.ja", "GPL"]
+ # Dir.glob('*', flags: File::FNM_DOTMATCH).take(5)
+ # # => [".", ".appveyor.yml", ".cirrus.yml", ".dir-locals.el", ".document"]
#
- # Dir["config.?"] #=> ["config.h"]
- # Dir.glob("config.?") #=> ["config.h"]
- # Dir.glob("*.[a-z][a-z]") #=> ["main.rb"]
- # Dir.glob("*.[^r]*") #=> ["config.h"]
- # Dir.glob("*.{rb,h}") #=> ["main.rb", "config.h"]
- # Dir.glob("*") #=> ["config.h", "main.rb"]
- # Dir.glob("*", File::FNM_DOTMATCH) #=> [".", "config.h", "main.rb"]
- # Dir.glob(["*.rb", "*.h"]) #=> ["main.rb", "config.h"]
+ # - File::FNM_EXTGLOB:
+ # enables the pattern extension
+ # <tt>'{_a_,_b_}'</tt>, which matches pattern _a_ and pattern _b_;
+ # behaves like a
+ # {regexp union}[rdoc-ref:Regexp.union]
+ # (e.g., <tt>'(?:_a_|_b_)'</tt>):
#
- # Dir.glob("**/*.rb") #=> ["main.rb",
- # # "lib/song.rb",
- # # "lib/song/karaoke.rb"]
+ # pattern = '{LEGAL,BSDL}'
+ # Dir.glob(pattern) # => ["LEGAL", "BSDL"]
#
- # Dir.glob("**/*.rb", base: "lib") #=> ["song.rb",
- # # "song/karaoke.rb"]
+ # - File::FNM_NOESCAPE:
+ # specifies that escaping with the backslash character <tt>'\'</tt>
+ # is disabled; the character is not an escape character.
#
- # Dir.glob("**/lib") #=> ["lib"]
+ # - File::FNM_PATHNAME:
+ # specifies that metacharacters <tt>'*'</tt> and <tt>'?'</tt>
+ # do not match directory separators.
#
- # Dir.glob("**/lib/**/*.rb") #=> ["lib/song.rb",
- # # "lib/song/karaoke.rb"]
+ # - File::FNM_SHORTNAME:
+ # specifies that patterns may match short names if they exist; Windows only.
#
- # Dir.glob("**/lib/*.rb") #=> ["lib/song.rb"]
def self.glob(pattern, _flags = 0, flags: _flags, base: nil, sort: true)
Primitive.dir_s_glob(pattern, flags, base, sort)
end
diff --git a/dln.c b/dln.c
index 0edd709bbe..b4c2fb9423 100644
--- a/dln.c
+++ b/dln.c
@@ -272,13 +272,15 @@ rb_w32_check_imported(HMODULE ext, HMODULE mine)
static bool
dln_incompatible_func(void *handle, const char *funcname, void *const fp, const char **libname)
{
- Dl_info dli;
void *ex = dlsym(handle, funcname);
if (!ex) return false;
if (ex == fp) return false;
+# if defined(HAVE_DLADDR)
+ Dl_info dli;
if (dladdr(ex, &dli)) {
*libname = dli.dli_fname;
}
+# endif
return true;
}
@@ -392,6 +394,12 @@ dln_open(const char *file)
dln_fatalerror("%s - %s", incompatible, file);
}
else {
+ if (libruby_name) {
+ const size_t len = strlen(libruby_name);
+ char *const tmp = ALLOCA_N(char, len + 1);
+ if (tmp) memcpy(tmp, libruby_name, len + 1);
+ libruby_name = tmp;
+ }
dlclose(handle);
if (libruby_name) {
dln_loaderror("linked to incompatible %s - %s", libruby_name, file);
@@ -413,33 +421,63 @@ dln_open(const char *file)
static void *
dln_sym(void *handle, const char *symbol)
{
- void *func;
- const char *error;
-
#if defined(_WIN32)
- char message[1024];
+ return GetProcAddress(handle, symbol);
+#elif defined(USE_DLN_DLOPEN)
+ return dlsym(handle, symbol);
+#endif
+}
+
+static void *
+dln_sym_func(void *handle, const char *symbol)
+{
+ void *func = dln_sym(handle, symbol);
- func = GetProcAddress(handle, symbol);
if (func == NULL) {
+ const char *error;
+#if defined(_WIN32)
+ char message[1024];
error = dln_strerror();
- goto failed;
- }
-
#elif defined(USE_DLN_DLOPEN)
- func = dlsym(handle, symbol);
- if (func == NULL) {
const size_t errlen = strlen(error = dln_strerror()) + 1;
error = memcpy(ALLOCA_N(char, errlen), error, errlen);
- goto failed;
- }
#endif
-
+ dln_loaderror("%s - %s", error, symbol);
+ }
return func;
-
- failed:
- dln_loaderror("%s - %s", error, symbol);
}
+
+#define dln_sym_callable(rettype, argtype, handle, symbol) \
+ (*(rettype (*)argtype)dln_sym_func(handle, symbol))
+#endif
+
+void *
+dln_symbol(void *handle, const char *symbol)
+{
+#if defined(_WIN32) || defined(USE_DLN_DLOPEN)
+ if (EXTERNAL_PREFIX[0]) {
+ const size_t symlen = strlen(symbol);
+ char *const tmp = ALLOCA_N(char, symlen + sizeof(EXTERNAL_PREFIX));
+ if (!tmp) dln_memerror();
+ memcpy(tmp, EXTERNAL_PREFIX, sizeof(EXTERNAL_PREFIX) - 1);
+ memcpy(tmp + sizeof(EXTERNAL_PREFIX) - 1, symbol, symlen + 1);
+ symbol = tmp;
+ }
+ if (handle == NULL) {
+# if defined(USE_DLN_DLOPEN)
+ handle = dlopen(NULL, RTLD_LAZY | RTLD_GLOBAL);
+# elif defined(_WIN32)
+ handle = rb_libruby_handle();
+# else
+ return NULL;
+# endif
+ }
+ return dln_sym(handle, symbol);
+#else
+ return NULL;
#endif
+}
+
#if defined(RUBY_DLN_CHECK_ABI) && defined(USE_DLN_DLOPEN)
static bool
@@ -457,8 +495,9 @@ dln_load(const char *file)
void *handle = dln_open(file);
#ifdef RUBY_DLN_CHECK_ABI
- unsigned long long (*abi_version_fct)(void) = (unsigned long long(*)(void))dln_sym(handle, "ruby_abi_version");
- unsigned long long binary_abi_version = (*abi_version_fct)();
+ typedef unsigned long long abi_version_number;
+ abi_version_number binary_abi_version =
+ dln_sym_callable(abi_version_number, (void), handle, EXTERNAL_PREFIX "ruby_abi_version")();
if (binary_abi_version != ruby_abi_version() && abi_check_enabled_p()) {
dln_loaderror("incompatible ABI version of binary - %s", file);
}
@@ -466,10 +505,9 @@ dln_load(const char *file)
char *init_fct_name;
init_funcname(&init_fct_name, file);
- void (*init_fct)(void) = (void(*)(void))dln_sym(handle, init_fct_name);
/* Call the init code */
- (*init_fct)();
+ dln_sym_callable(void, (void), handle, init_fct_name)();
return handle;
diff --git a/dln.h b/dln.h
index 902f753450..d624bb6611 100644
--- a/dln.h
+++ b/dln.h
@@ -25,6 +25,7 @@ RUBY_SYMBOL_EXPORT_BEGIN
char *dln_find_exe_r(const char*,const char*,char*,size_t DLN_FIND_EXTRA_ARG_DECL);
char *dln_find_file_r(const char*,const char*,char*,size_t DLN_FIND_EXTRA_ARG_DECL);
void *dln_load(const char*);
+void *dln_symbol(void*,const char*);
RUBY_SYMBOL_EXPORT_END
diff --git a/dln_find.c b/dln_find.c
index 5d380f5d39..91c51394a9 100644
--- a/dln_find.c
+++ b/dln_find.c
@@ -75,7 +75,7 @@ dln_find_exe_r(const char *fname, const char *path, char *buf, size_t size
".";
}
buf = dln_find_1(fname, path, buf, size, 1 DLN_FIND_EXTRA_ARG);
- if (envpath) free(envpath);
+ free(envpath);
return buf;
}
diff --git a/dmydln.c b/dmydln.c
index d05cda0b8e..b1516937d3 100644
--- a/dmydln.c
+++ b/dmydln.c
@@ -8,3 +8,12 @@ dln_load(const char *file)
UNREACHABLE_RETURN(NULL);
}
+
+NORETURN(void *dln_symbol(void*,const char*));
+void*
+dln_symbol(void *handle, const char *symbol)
+{
+ rb_loaderror("this executable file can't load extension libraries");
+
+ UNREACHABLE_RETURN(NULL);
+}
diff --git a/doc/.document b/doc/.document
index 5ef2d99651..5a58e6e3ad 100644
--- a/doc/.document
+++ b/doc/.document
@@ -1,8 +1,11 @@
*.md
*.rb
-*.rdoc
+[^_]*.rdoc
contributing
NEWS
syntax
optparse
rdoc
+regexp
+rjit
+yjit
diff --git a/doc/ChangeLog-0.06_to_0.52 b/doc/ChangeLog/ChangeLog-0.06_to_0.52
index 63826081b3..63826081b3 100644
--- a/doc/ChangeLog-0.06_to_0.52
+++ b/doc/ChangeLog/ChangeLog-0.06_to_0.52
diff --git a/doc/ChangeLog-0.50_to_0.60 b/doc/ChangeLog/ChangeLog-0.50_to_0.60
index 5f5b03ff40..5f5b03ff40 100644
--- a/doc/ChangeLog-0.50_to_0.60
+++ b/doc/ChangeLog/ChangeLog-0.50_to_0.60
diff --git a/doc/ChangeLog-0.60_to_1.1 b/doc/ChangeLog/ChangeLog-0.60_to_1.1
index 59d195e780..59d195e780 100644
--- a/doc/ChangeLog-0.60_to_1.1
+++ b/doc/ChangeLog/ChangeLog-0.60_to_1.1
diff --git a/doc/ChangeLog-1.8.0 b/doc/ChangeLog/ChangeLog-1.8.0
index 6d9453d011..6d9453d011 100644
--- a/doc/ChangeLog-1.8.0
+++ b/doc/ChangeLog/ChangeLog-1.8.0
diff --git a/doc/ChangeLog-1.9.3 b/doc/ChangeLog/ChangeLog-1.9.3
index 0f80eed2d5..0f80eed2d5 100644
--- a/doc/ChangeLog-1.9.3
+++ b/doc/ChangeLog/ChangeLog-1.9.3
diff --git a/doc/ChangeLog-2.0.0 b/doc/ChangeLog/ChangeLog-2.0.0
index 9e654db189..9e654db189 100644
--- a/doc/ChangeLog-2.0.0
+++ b/doc/ChangeLog/ChangeLog-2.0.0
diff --git a/doc/ChangeLog-2.1.0 b/doc/ChangeLog/ChangeLog-2.1.0
index 5b670b31c9..5b670b31c9 100644
--- a/doc/ChangeLog-2.1.0
+++ b/doc/ChangeLog/ChangeLog-2.1.0
diff --git a/doc/ChangeLog-2.2.0 b/doc/ChangeLog/ChangeLog-2.2.0
index 5a7dbf826d..5a7dbf826d 100644
--- a/doc/ChangeLog-2.2.0
+++ b/doc/ChangeLog/ChangeLog-2.2.0
diff --git a/doc/ChangeLog-2.3.0 b/doc/ChangeLog/ChangeLog-2.3.0
index 94996cffd0..94996cffd0 100644
--- a/doc/ChangeLog-2.3.0
+++ b/doc/ChangeLog/ChangeLog-2.3.0
diff --git a/doc/ChangeLog-2.4.0 b/doc/ChangeLog/ChangeLog-2.4.0
index a297a579d1..a297a579d1 100644
--- a/doc/ChangeLog-2.4.0
+++ b/doc/ChangeLog/ChangeLog-2.4.0
diff --git a/doc/ChangeLog-YARV b/doc/ChangeLog/ChangeLog-YARV
index 83df05c52c..83df05c52c 100644
--- a/doc/ChangeLog-YARV
+++ b/doc/ChangeLog/ChangeLog-YARV
diff --git a/doc/_regexp.rdoc b/doc/_regexp.rdoc
new file mode 100644
index 0000000000..7b71eee984
--- /dev/null
+++ b/doc/_regexp.rdoc
@@ -0,0 +1,1276 @@
+A {regular expression}[https://en.wikipedia.org/wiki/Regular_expression]
+(also called a _regexp_) is a <i>match pattern</i> (also simply called a _pattern_).
+
+A common notation for a regexp uses enclosing slash characters:
+
+ /foo/
+
+A regexp may be applied to a <i>target string</i>;
+The part of the string (if any) that matches the pattern is called a _match_,
+and may be said <i>to match</i>:
+
+ re = /red/
+ re.match?('redirect') # => true # Match at beginning of target.
+ re.match?('bored') # => true # Match at end of target.
+ re.match?('credit') # => true # Match within target.
+ re.match?('foo') # => false # No match.
+
+== \Regexp Uses
+
+A regexp may be used:
+
+- To extract substrings based on a given pattern:
+
+ re = /foo/ # => /foo/
+ re.match('food') # => #<MatchData "foo">
+ re.match('good') # => nil
+
+ See sections {Method match}[rdoc-ref:Regexp@Method+match]
+ and {Operator =~}[rdoc-ref:Regexp@Operator+-3D~].
+
+- To determine whether a string matches a given pattern:
+
+ re.match?('food') # => true
+ re.match?('good') # => false
+
+ See section {Method match?}[rdoc-ref:Regexp@Method+match-3F].
+
+- As an argument for calls to certain methods in other classes and modules;
+ most such methods accept an argument that may be either a string
+ or the (much more powerful) regexp.
+
+ See {Regexp Methods}[rdoc-ref:regexp/methods.rdoc].
+
+== \Regexp Objects
+
+A regexp object has:
+
+- A source; see {Sources}[rdoc-ref:Regexp@Sources].
+
+- Several modes; see {Modes}[rdoc-ref:Regexp@Modes].
+
+- A timeout; see {Timeouts}[rdoc-ref:Regexp@Timeouts].
+
+- An encoding; see {Encodings}[rdoc-ref:Regexp@Encodings].
+
+== Creating a \Regexp
+
+A regular expression may be created with:
+
+- A regexp literal using slash characters
+ (see {Regexp Literals}[rdoc-ref:syntax/literals.rdoc@Regexp+Literals]):
+
+ # This is a very common usage.
+ /foo/ # => /foo/
+
+- A <tt>%r</tt> regexp literal
+ (see {%r: Regexp Literals}[rdoc-ref:syntax/literals.rdoc@25r-3A+Regexp+Literals]):
+
+ # Same delimiter character at beginning and end;
+ # useful for avoiding escaping characters
+ %r/name\/value pair/ # => /name\/value pair/
+ %r:name/value pair: # => /name\/value pair/
+ %r|name/value pair| # => /name\/value pair/
+
+ # Certain "paired" characters can be delimiters.
+ %r[foo] # => /foo/
+ %r{foo} # => /foo/
+ %r(foo) # => /foo/
+ %r<foo> # => /foo/
+
+- \Method Regexp.new.
+
+== \Method <tt>match</tt>
+
+Each of the methods Regexp#match, String#match, and Symbol#match
+returns a MatchData object if a match was found, +nil+ otherwise;
+each also sets {global variables}[rdoc-ref:Regexp@Global+Variables]:
+
+ 'food'.match(/foo/) # => #<MatchData "foo">
+ 'food'.match(/bar/) # => nil
+
+== Operator <tt>=~</tt>
+
+Each of the operators Regexp#=~, String#=~, and Symbol#=~
+returns an integer offset if a match was found, +nil+ otherwise;
+each also sets {global variables}[rdoc-ref:Regexp@Global+Variables]:
+
+ /bar/ =~ 'foo bar' # => 4
+ 'foo bar' =~ /bar/ # => 4
+ /baz/ =~ 'foo bar' # => nil
+
+== \Method <tt>match?</tt>
+
+Each of the methods Regexp#match?, String#match?, and Symbol#match?
+returns +true+ if a match was found, +false+ otherwise;
+none sets {global variables}[rdoc-ref:Regexp@Global+Variables]:
+
+ 'food'.match?(/foo/) # => true
+ 'food'.match?(/bar/) # => false
+
+== Global Variables
+
+Certain regexp-oriented methods assign values to global variables:
+
+- <tt>#match</tt>: see {Method match}[rdoc-ref:Regexp@Method+match].
+- <tt>#=~</tt>: see {Operator =~}[rdoc-ref:Regexp@Operator+-3D~].
+
+The affected global variables are:
+
+- <tt>$~</tt>: Returns a MatchData object, or +nil+.
+- <tt>$&</tt>: Returns the matched part of the string, or +nil+.
+- <tt>$`</tt>: Returns the part of the string to the left of the match, or +nil+.
+- <tt>$'</tt>: Returns the part of the string to the right of the match, or +nil+.
+- <tt>$+</tt>: Returns the last group matched, or +nil+.
+- <tt>$1</tt>, <tt>$2</tt>, etc.: Returns the first, second, etc.,
+ matched group, or +nil+.
+ Note that <tt>$0</tt> is quite different;
+ it returns the name of the currently executing program.
+
+Examples:
+
+ # Matched string, but no matched groups.
+ 'foo bar bar baz'.match('bar')
+ $~ # => #<MatchData "bar">
+ $& # => "bar"
+ $` # => "foo "
+ $' # => " bar baz"
+ $+ # => nil
+ $1 # => nil
+
+ # Matched groups.
+ /s(\w{2}).*(c)/.match('haystack')
+ $~ # => #<MatchData "stac" 1:"ta" 2:"c">
+ $& # => "stac"
+ $` # => "hay"
+ $' # => "k"
+ $+ # => "c"
+ $1 # => "ta"
+ $2 # => "c"
+ $3 # => nil
+
+ # No match.
+ 'foo'.match('bar')
+ $~ # => nil
+ $& # => nil
+ $` # => nil
+ $' # => nil
+ $+ # => nil
+ $1 # => nil
+
+Note that Regexp#match?, String#match?, and Symbol#match?
+do not set global variables.
+
+== Sources
+
+As seen above, the simplest regexp uses a literal expression as its source:
+
+ re = /foo/ # => /foo/
+ re.match('food') # => #<MatchData "foo">
+ re.match('good') # => nil
+
+A rich collection of available _subexpressions_
+gives the regexp great power and flexibility:
+
+- {Special characters}[rdoc-ref:Regexp@Special+Characters]
+- {Source literals}[rdoc-ref:Regexp@Source+Literals]
+- {Character classes}[rdoc-ref:Regexp@Character+Classes]
+- {Shorthand character classes}[rdoc-ref:Regexp@Shorthand+Character+Classes]
+- {Anchors}[rdoc-ref:Regexp@Anchors]
+- {Alternation}[rdoc-ref:Regexp@Alternation]
+- {Quantifiers}[rdoc-ref:Regexp@Quantifiers]
+- {Groups and captures}[rdoc-ref:Regexp@Groups+and+Captures]
+- {Unicode}[rdoc-ref:Regexp@Unicode]
+- {POSIX Bracket Expressions}[rdoc-ref:Regexp@POSIX+Bracket+Expressions]
+- {Comments}[rdoc-ref:Regexp@Comments]
+
+=== Special Characters
+
+\Regexp special characters, called _metacharacters_,
+have special meanings in certain contexts;
+depending on the context, these are sometimes metacharacters:
+
+ . ? - + * ^ \ | $ ( ) [ ] { }
+
+To match a metacharacter literally, backslash-escape it:
+
+ # Matches one or more 'o' characters.
+ /o+/.match('foo') # => #<MatchData "oo">
+ # Would match 'o+'.
+ /o\+/.match('foo') # => nil
+
+To match a backslash literally, backslash-escape it:
+
+ /\./.match('\.') # => #<MatchData ".">
+ /\\./.match('\.') # => #<MatchData "\\.">
+
+Method Regexp.escape returns an escaped string:
+
+ Regexp.escape('.?-+*^\|$()[]{}')
+ # => "\\.\\?\\-\\+\\*\\^\\\\\\|\\$\\(\\)\\[\\]\\{\\}"
+
+=== Source Literals
+
+The source literal largely behaves like a double-quoted string;
+see {String Literals}[rdoc-ref:syntax/literals.rdoc@String+Literals].
+
+In particular, a source literal may contain interpolated expressions:
+
+ s = 'foo' # => "foo"
+ /#{s}/ # => /foo/
+ /#{s.capitalize}/ # => /Foo/
+ /#{2 + 2}/ # => /4/
+
+There are differences between an ordinary string literal and a source literal;
+see {Shorthand Character Classes}[rdoc-ref:Regexp@Shorthand+Character+Classes].
+
+- <tt>\s</tt> in an ordinary string literal is equivalent to a space character;
+ in a source literal, it's shorthand for matching a whitespace character.
+- In an ordinary string literal, these are (needlessly) escaped characters;
+ in a source literal, they are shorthands for various matching characters:
+
+ \w \W \d \D \h \H \S \R
+
+=== Character Classes
+
+A <i>character class</i> is delimited by square brackets;
+it specifies that certain characters match at a given point in the target string:
+
+ # This character class will match any vowel.
+ re = /B[aeiou]rd/
+ re.match('Bird') # => #<MatchData "Bird">
+ re.match('Bard') # => #<MatchData "Bard">
+ re.match('Byrd') # => nil
+
+A character class may contain hyphen characters to specify ranges of characters:
+
+ # These regexps have the same effect.
+ /[abcdef]/.match('foo') # => #<MatchData "f">
+ /[a-f]/.match('foo') # => #<MatchData "f">
+ /[a-cd-f]/.match('foo') # => #<MatchData "f">
+
+When the first character of a character class is a caret (<tt>^</tt>),
+the sense of the class is inverted: it matches any character _except_ those specified.
+
+ /[^a-eg-z]/.match('f') # => #<MatchData "f">
+
+A character class may contain another character class.
+By itself this isn't useful because <tt>[a-z[0-9]]</tt>
+describes the same set as <tt>[a-z0-9]</tt>.
+
+However, character classes also support the <tt>&&</tt> operator,
+which performs set intersection on its arguments.
+The two can be combined as follows:
+
+ /[a-w&&[^c-g]z]/ # ([a-w] AND ([^c-g] OR z))
+
+This is equivalent to:
+
+ /[abh-w]/
+
+=== Shorthand Character Classes
+
+Each of the following metacharacters serves as a shorthand
+for a character class:
+
+- <tt>/./</tt>: Matches any character except a newline:
+
+ /./.match('foo') # => #<MatchData "f">
+ /./.match("\n") # => nil
+
+- <tt>/./m</tt>: Matches any character, including a newline;
+ see {Multiline Mode}[rdoc-ref:Regexp@Multiline+Mode]:
+
+ /./m.match("\n") # => #<MatchData "\n">
+
+- <tt>/\w/</tt>: Matches a word character: equivalent to <tt>[a-zA-Z0-9_]</tt>:
+
+ /\w/.match(' foo') # => #<MatchData "f">
+ /\w/.match(' _') # => #<MatchData "_">
+ /\w/.match(' ') # => nil
+
+- <tt>/\W/</tt>: Matches a non-word character: equivalent to <tt>[^a-zA-Z0-9_]</tt>:
+
+ /\W/.match(' ') # => #<MatchData " ">
+ /\W/.match('_') # => nil
+
+- <tt>/\d/</tt>: Matches a digit character: equivalent to <tt>[0-9]</tt>:
+
+ /\d/.match('THX1138') # => #<MatchData "1">
+ /\d/.match('foo') # => nil
+
+- <tt>/\D/</tt>: Matches a non-digit character: equivalent to <tt>[^0-9]</tt>:
+
+ /\D/.match('123Jump!') # => #<MatchData "J">
+ /\D/.match('123') # => nil
+
+- <tt>/\h/</tt>: Matches a hexdigit character: equivalent to <tt>[0-9a-fA-F]</tt>:
+
+ /\h/.match('xyz fedcba9876543210') # => #<MatchData "f">
+ /\h/.match('xyz') # => nil
+
+- <tt>/\H/</tt>: Matches a non-hexdigit character: equivalent to <tt>[^0-9a-fA-F]</tt>:
+
+ /\H/.match('fedcba9876543210xyz') # => #<MatchData "x">
+ /\H/.match('fedcba9876543210') # => nil
+
+- <tt>/\s/</tt>: Matches a whitespace character: equivalent to <tt>/[ \t\r\n\f\v]/</tt>:
+
+ /\s/.match('foo bar') # => #<MatchData " ">
+ /\s/.match('foo') # => nil
+
+- <tt>/\S/</tt>: Matches a non-whitespace character: equivalent to <tt>/[^ \t\r\n\f\v]/</tt>:
+
+ /\S/.match(" \t\r\n\f\v foo") # => #<MatchData "f">
+ /\S/.match(" \t\r\n\f\v") # => nil
+
+- <tt>/\R/</tt>: Matches a linebreak, platform-independently:
+
+ /\R/.match("\r") # => #<MatchData "\r"> # Carriage return (CR)
+ /\R/.match("\n") # => #<MatchData "\n"> # Newline (LF)
+ /\R/.match("\f") # => #<MatchData "\f"> # Formfeed (FF)
+ /\R/.match("\v") # => #<MatchData "\v"> # Vertical tab (VT)
+ /\R/.match("\r\n") # => #<MatchData "\r\n"> # CRLF
+ /\R/.match("\u0085") # => #<MatchData "\u0085"> # Next line (NEL)
+ /\R/.match("\u2028") # => #<MatchData "\u2028"> # Line separator (LSEP)
+ /\R/.match("\u2029") # => #<MatchData "\u2029"> # Paragraph separator (PSEP)
+
+=== Anchors
+
+An anchor is a metasequence that matches a zero-width position between
+characters in the target string.
+
+For a subexpression with no anchor,
+matching may begin anywhere in the target string:
+
+ /real/.match('surrealist') # => #<MatchData "real">
+
+For a subexpression with an anchor,
+matching must begin at the matched anchor.
+
+==== Boundary Anchors
+
+Each of these anchors matches a boundary:
+
+- <tt>^</tt>: Matches the beginning of a line:
+
+ /^bar/.match("foo\nbar") # => #<MatchData "bar">
+ /^ar/.match("foo\nbar") # => nil
+
+- <tt>$</tt>: Matches the end of a line:
+
+ /bar$/.match("foo\nbar") # => #<MatchData "bar">
+ /ba$/.match("foo\nbar") # => nil
+
+- <tt>\A</tt>: Matches the beginning of the string:
+
+ /\Afoo/.match('foo bar') # => #<MatchData "foo">
+ /\Afoo/.match(' foo bar') # => nil
+
+- <tt>\Z</tt>: Matches the end of the string;
+ if string ends with a single newline,
+ it matches just before the ending newline:
+
+ /foo\Z/.match('bar foo') # => #<MatchData "foo">
+ /foo\Z/.match('foo bar') # => nil
+ /foo\Z/.match("bar foo\n") # => #<MatchData "foo">
+ /foo\Z/.match("bar foo\n\n") # => nil
+
+- <tt>\z</tt>: Matches the end of the string:
+
+ /foo\z/.match('bar foo') # => #<MatchData "foo">
+ /foo\z/.match('foo bar') # => nil
+ /foo\z/.match("bar foo\n") # => nil
+
+- <tt>\b</tt>: Matches word boundary when not inside brackets;
+ matches backspace (<tt>"0x08"</tt>) when inside brackets:
+
+ /foo\b/.match('foo bar') # => #<MatchData "foo">
+ /foo\b/.match('foobar') # => nil
+
+- <tt>\B</tt>: Matches non-word boundary:
+
+ /foo\B/.match('foobar') # => #<MatchData "foo">
+ /foo\B/.match('foo bar') # => nil
+
+- <tt>\G</tt>: Matches first matching position:
+
+ In methods like String#gsub and String#scan, it changes on each iteration.
+ It initially matches the beginning of subject, and in each following iteration it matches where the last match finished.
+
+ " a b c".gsub(/ /, '_') # => "____a_b_c"
+ " a b c".gsub(/\G /, '_') # => "____a b c"
+
+ In methods like Regexp#match and String#match
+ that take an optional offset, it matches where the search begins.
+
+ "hello, world".match(/,/, 3) # => #<MatchData ",">
+ "hello, world".match(/\G,/, 3) # => nil
+
+==== Lookaround Anchors
+
+Lookahead anchors:
+
+- <tt>(?=_pat_)</tt>: Positive lookahead assertion:
+ ensures that the following characters match _pat_,
+ but doesn't include those characters in the matched substring.
+
+- <tt>(?!_pat_)</tt>: Negative lookahead assertion:
+ ensures that the following characters <i>do not</i> match _pat_,
+ but doesn't include those characters in the matched substring.
+
+Lookbehind anchors:
+
+- <tt>(?<=_pat_)</tt>: Positive lookbehind assertion:
+ ensures that the preceding characters match _pat_, but
+ doesn't include those characters in the matched substring.
+
+- <tt>(?<!_pat_)</tt>: Negative lookbehind assertion:
+ ensures that the preceding characters do not match
+ _pat_, but doesn't include those characters in the matched substring.
+
+The pattern below uses positive lookahead and positive lookbehind to match
+text appearing in <tt><b></tt>...<tt></b></tt> tags
+without including the tags in the match:
+
+ /(?<=<b>)\w+(?=<\/b>)/.match("Fortune favors the <b>bold</b>.")
+ # => #<MatchData "bold">
+
+==== Match-Reset Anchor
+
+- <tt>\K</tt>: Match reset:
+ the matched content preceding <tt>\K</tt> in the regexp is excluded from the result.
+ For example, the following two regexps are almost equivalent:
+
+ /ab\Kc/.match('abc') # => #<MatchData "c">
+ /(?<=ab)c/.match('abc') # => #<MatchData "c">
+
+ These match same string and <tt>$&</tt> equals <tt>'c'</tt>,
+ while the matched position is different.
+
+ As are the following two regexps:
+
+ /(a)\K(b)\Kc/
+ /(?<=(?<=(a))(b))c/
+
+=== Alternation
+
+The vertical bar metacharacter (<tt>|</tt>) may be used within parentheses
+to express alternation:
+two or more subexpressions any of which may match the target string.
+
+Two alternatives:
+
+ re = /(a|b)/
+ re.match('foo') # => nil
+ re.match('bar') # => #<MatchData "b" 1:"b">
+
+Four alternatives:
+
+ re = /(a|b|c|d)/
+ re.match('shazam') # => #<MatchData "a" 1:"a">
+ re.match('cold') # => #<MatchData "c" 1:"c">
+
+Each alternative is a subexpression, and may be composed of other subexpressions:
+
+ re = /([a-c]|[x-z])/
+ re.match('bar') # => #<MatchData "b" 1:"b">
+ re.match('ooz') # => #<MatchData "z" 1:"z">
+
+\Method Regexp.union provides a convenient way to construct
+a regexp with alternatives.
+
+=== Quantifiers
+
+A simple regexp matches one character:
+
+ /\w/.match('Hello') # => #<MatchData "H">
+
+An added _quantifier_ specifies how many matches are required or allowed:
+
+- <tt>*</tt> - Matches zero or more times:
+
+ /\w*/.match('')
+ # => #<MatchData "">
+ /\w*/.match('x')
+ # => #<MatchData "x">
+ /\w*/.match('xyz')
+ # => #<MatchData "yz">
+
+- <tt>+</tt> - Matches one or more times:
+
+ /\w+/.match('') # => nil
+ /\w+/.match('x') # => #<MatchData "x">
+ /\w+/.match('xyz') # => #<MatchData "xyz">
+
+- <tt>?</tt> - Matches zero or one times:
+
+ /\w?/.match('') # => #<MatchData "">
+ /\w?/.match('x') # => #<MatchData "x">
+ /\w?/.match('xyz') # => #<MatchData "x">
+
+- <tt>{</tt>_n_<tt>}</tt> - Matches exactly _n_ times:
+
+ /\w{2}/.match('') # => nil
+ /\w{2}/.match('x') # => nil
+ /\w{2}/.match('xyz') # => #<MatchData "xy">
+
+- <tt>{</tt>_min_<tt>,}</tt> - Matches _min_ or more times:
+
+ /\w{2,}/.match('') # => nil
+ /\w{2,}/.match('x') # => nil
+ /\w{2,}/.match('xy') # => #<MatchData "xy">
+ /\w{2,}/.match('xyz') # => #<MatchData "xyz">
+
+- <tt>{,</tt>_max_<tt>}</tt> - Matches _max_ or fewer times:
+
+ /\w{,2}/.match('') # => #<MatchData "">
+ /\w{,2}/.match('x') # => #<MatchData "x">
+ /\w{,2}/.match('xyz') # => #<MatchData "xy">
+
+- <tt>{</tt>_min_<tt>,</tt>_max_<tt>}</tt> -
+ Matches at least _min_ times and at most _max_ times:
+
+ /\w{1,2}/.match('') # => nil
+ /\w{1,2}/.match('x') # => #<MatchData "x">
+ /\w{1,2}/.match('xyz') # => #<MatchData "xy">
+
+==== Greedy, Lazy, or Possessive Matching
+
+Quantifier matching may be greedy, lazy, or possessive:
+
+- In _greedy_ matching, as many occurrences as possible are matched
+ while still allowing the overall match to succeed.
+ Greedy quantifiers: <tt>*</tt>, <tt>+</tt>, <tt>?</tt>,
+ <tt>{min, max}</tt> and its variants.
+- In _lazy_ matching, the minimum number of occurrences are matched.
+ Lazy quantifiers: <tt>*?</tt>, <tt>+?</tt>, <tt>??</tt>,
+ <tt>{min, max}?</tt> and its variants.
+- In _possessive_ matching, once a match is found, there is no backtracking;
+ that match is retained, even if it jeopardises the overall match.
+ Possessive quantifiers: <tt>*+</tt>, <tt>++</tt>, <tt>?+</tt>.
+ Note that <tt>{min, max}</tt> and its variants do _not_ support possessive matching.
+
+More:
+
+- About greedy and lazy matching, see
+ {Choosing Minimal or Maximal Repetition}[https://doc.lagout.org/programmation/Regular%20Expressions/Regular%20Expressions%20Cookbook_%20Detailed%20Solutions%20in%20Eight%20Programming%20Languages%20%282nd%20ed.%29%20%5BGoyvaerts%20%26%20Levithan%202012-09-06%5D.pdf#tutorial-backtrack].
+- About possessive matching, see
+ {Eliminate Needless Backtracking}[https://doc.lagout.org/programmation/Regular%20Expressions/Regular%20Expressions%20Cookbook_%20Detailed%20Solutions%20in%20Eight%20Programming%20Languages%20%282nd%20ed.%29%20%5BGoyvaerts%20%26%20Levithan%202012-09-06%5D.pdf#tutorial-backtrack].
+
+=== Groups and Captures
+
+A simple regexp has (at most) one match:
+
+ re = /\d\d\d\d-\d\d-\d\d/
+ re.match('1943-02-04') # => #<MatchData "1943-02-04">
+ re.match('1943-02-04').size # => 1
+ re.match('foo') # => nil
+
+Adding one or more pairs of parentheses, <tt>(_subexpression_)</tt>,
+defines _groups_, which may result in multiple matched substrings,
+called _captures_:
+
+ re = /(\d\d\d\d)-(\d\d)-(\d\d)/
+ re.match('1943-02-04') # => #<MatchData "1943-02-04" 1:"1943" 2:"02" 3:"04">
+ re.match('1943-02-04').size # => 4
+
+The first capture is the entire matched string;
+the other captures are the matched substrings from the groups.
+
+A group may have a {quantifier}[rdoc-ref:Regexp@Quantifiers]:
+
+ re = /July 4(th)?/
+ re.match('July 4') # => #<MatchData "July 4" 1:nil>
+ re.match('July 4th') # => #<MatchData "July 4th" 1:"th">
+
+ re = /(foo)*/
+ re.match('') # => #<MatchData "" 1:nil>
+ re.match('foo') # => #<MatchData "foo" 1:"foo">
+ re.match('foofoo') # => #<MatchData "foofoo" 1:"foo">
+
+ re = /(foo)+/
+ re.match('') # => nil
+ re.match('foo') # => #<MatchData "foo" 1:"foo">
+ re.match('foofoo') # => #<MatchData "foofoo" 1:"foo">
+
+The returned \MatchData object gives access to the matched substrings:
+
+ re = /(\d\d\d\d)-(\d\d)-(\d\d)/
+ md = re.match('1943-02-04')
+ # => #<MatchData "1943-02-04" 1:"1943" 2:"02" 3:"04">
+ md[0] # => "1943-02-04"
+ md[1] # => "1943"
+ md[2] # => "02"
+ md[3] # => "04"
+
+==== Non-Capturing Groups
+
+A group may be made non-capturing;
+it is still a group (and, for example, can have a quantifier),
+but its matching substring is not included among the captures.
+
+A non-capturing group begins with <tt>?:</tt> (inside the parentheses):
+
+ # Don't capture the year.
+ re = /(?:\d\d\d\d)-(\d\d)-(\d\d)/
+ md = re.match('1943-02-04') # => #<MatchData "1943-02-04" 1:"02" 2:"04">
+
+==== Backreferences
+
+A group match may also be referenced within the regexp itself;
+such a reference is called a +backreference+:
+
+ /[csh](..) [csh]\1 in/.match('The cat sat in the hat')
+ # => #<MatchData "cat sat in" 1:"at">
+
+This table shows how each subexpression in the regexp above
+matches a substring in the target string:
+
+ | Subexpression in Regexp | Matching Substring in Target String |
+ |---------------------------|-------------------------------------|
+ | First '[csh]' | Character 'c' |
+ | '(..)' | First substring 'at' |
+ | First space ' ' | First space character ' ' |
+ | Second '[csh]' | Character 's' |
+ | '\1' (backreference 'at') | Second substring 'at' |
+ | ' in' | Substring ' in' |
+
+A regexp may contain any number of groups:
+
+- For a large number of groups:
+
+ - The ordinary <tt>\\_n_</tt> notation applies only for _n_ in range (1..9).
+ - The <tt>MatchData[_n_]</tt> notation applies for any non-negative _n_.
+
+- <tt>\0</tt> is a special backreference, referring to the entire matched string;
+ it may not be used within the regexp itself,
+ but may be used outside it (for example, in a substitution method call):
+
+ 'The cat sat in the hat'.gsub(/[csh]at/, '\0s')
+ # => "The cats sats in the hats"
+
+==== Named Captures
+
+As seen above, a capture can be referred to by its number.
+A capture can also have a name,
+prefixed as <tt>?<_name_></tt> or <tt>?'_name_'</tt>,
+and the name (symbolized) may be used as an index in <tt>MatchData[]</tt>:
+
+ md = /\$(?<dollars>\d+)\.(?'cents'\d+)/.match("$3.67")
+ # => #<MatchData "$3.67" dollars:"3" cents:"67">
+ md[:dollars] # => "3"
+ md[:cents] # => "67"
+ # The capture numbers are still valid.
+ md[2] # => "67"
+
+When a regexp contains a named capture, there are no unnamed captures:
+
+ /\$(?<dollars>\d+)\.(\d+)/.match("$3.67")
+ # => #<MatchData "$3.67" dollars:"3">
+
+A named group may be backreferenced as <tt>\k<_name_></tt>:
+
+ /(?<vowel>[aeiou]).\k<vowel>.\k<vowel>/.match('ototomy')
+ # => #<MatchData "ototo" vowel:"o">
+
+When (and only when) a regexp contains named capture groups
+and appears before the <tt>=~</tt> operator,
+the captured substrings are assigned to local variables with corresponding names:
+
+ /\$(?<dollars>\d+)\.(?<cents>\d+)/ =~ '$3.67'
+ dollars # => "3"
+ cents # => "67"
+
+\Method Regexp#named_captures returns a hash of the capture names and substrings;
+method Regexp#names returns an array of the capture names.
+
+==== Atomic Grouping
+
+A group may be made _atomic_ with <tt>(?></tt>_subexpression_<tt>)</tt>.
+
+This causes the subexpression to be matched
+independently of the rest of the expression,
+so that the matched substring becomes fixed for the remainder of the match,
+unless the entire subexpression must be abandoned and subsequently revisited.
+
+In this way _subexpression_ is treated as a non-divisible whole.
+Atomic grouping is typically used to optimise patterns
+to prevent needless backtracking .
+
+Example (without atomic grouping):
+
+ /".*"/.match('"Quote"') # => #<MatchData "\"Quote\"">
+
+Analysis:
+
+1. The leading subexpression <tt>"</tt> in the pattern matches the first character
+ <tt>"</tt> in the target string.
+2. The next subexpression <tt>.*</tt> matches the next substring <tt>Quote“</tt>
+ (including the trailing double-quote).
+3. Now there is nothing left in the target string to match
+ the trailing subexpression <tt>"</tt> in the pattern;
+ this would cause the overall match to fail.
+4. The matched substring is backtracked by one position: <tt>Quote</tt>.
+5. The final subexpression <tt>"</tt> now matches the final substring <tt>"</tt>,
+ and the overall match succeeds.
+
+If subexpression <tt>.*</tt> is grouped atomically,
+the backtracking is disabled, and the overall match fails:
+
+ /"(?>.*)"/.match('"Quote"') # => nil
+
+Atomic grouping can affect performance;
+see {Atomic Group}[https://www.regular-expressions.info/atomic.html].
+
+==== Subexpression Calls
+
+As seen above, a backreference number (<tt>\\_n_</tt>) or name (<tt>\k<_name_></tt>)
+gives access to a captured _substring_;
+the corresponding regexp _subexpression_ may also be accessed,
+via the number (<tt>\\g<i>n</i></tt>) or name (<tt>\g<_name_></tt>):
+
+ /\A(?<paren>\(\g<paren>*\))*\z/.match('(())')
+ # ^1
+ # ^2
+ # ^3
+ # ^4
+ # ^5
+ # ^6
+ # ^7
+ # ^8
+ # ^9
+ # ^10
+
+The pattern:
+
+1. Matches at the beginning of the string, i.e. before the first character.
+2. Enters a named group +paren+.
+3. Matches the first character in the string, <tt>'('</tt>.
+4. Calls the +paren+ group again, i.e. recurses back to the second step.
+5. Re-enters the +paren+ group.
+6. Matches the second character in the string, <tt>'('</tt>.
+7. Attempts to call +paren+ a third time,
+ but fails because doing so would prevent an overall successful match.
+8. Matches the third character in the string, <tt>')'</tt>;
+ marks the end of the second recursive call
+9. Matches the fourth character in the string, <tt>')'</tt>.
+10. Matches the end of the string.
+
+See {Subexpression calls}[https://learnbyexample.github.io/Ruby_Regexp/groupings-and-backreferences.html?highlight=subexpression#subexpression-calls].
+
+==== Conditionals
+
+The conditional construct takes the form <tt>(?(_cond_)_yes_|_no_)</tt>, where:
+
+- _cond_ may be a capture number or name.
+- The match to be applied is _yes_ if _cond_ is captured;
+ otherwise the match to be applied is _no_.
+- If not needed, <tt>|_no_</tt> may be omitted.
+
+Examples:
+
+ re = /\A(foo)?(?(1)(T)|(F))\z/
+ re.match('fooT') # => #<MatchData "fooT" 1:"foo" 2:"T" 3:nil>
+ re.match('F') # => #<MatchData "F" 1:nil 2:nil 3:"F">
+ re.match('fooF') # => nil
+ re.match('T') # => nil
+
+ re = /\A(?<xyzzy>foo)?(?(<xyzzy>)(T)|(F))\z/
+ re.match('fooT') # => #<MatchData "fooT" xyzzy:"foo">
+ re.match('F') # => #<MatchData "F" xyzzy:nil>
+ re.match('fooF') # => nil
+ re.match('T') # => nil
+
+
+==== Absence Operator
+
+The absence operator is a special group that matches anything which does _not_ match the contained subexpressions.
+
+ /(?~real)/.match('surrealist') # => #<MatchData "surrea">
+ /(?~real)ist/.match('surrealist') # => #<MatchData "ealist">
+ /sur(?~real)ist/.match('surrealist') # => nil
+
+=== Unicode
+
+==== Unicode Properties
+
+The <tt>/\p{_property_name_}/</tt> construct (with lowercase +p+)
+matches characters using a Unicode property name,
+much like a character class;
+property +Alpha+ specifies alphabetic characters:
+
+ /\p{Alpha}/.match('a') # => #<MatchData "a">
+ /\p{Alpha}/.match('1') # => nil
+
+A property can be inverted
+by prefixing the name with a caret character (<tt>^</tt>):
+
+ /\p{^Alpha}/.match('1') # => #<MatchData "1">
+ /\p{^Alpha}/.match('a') # => nil
+
+Or by using <tt>\P</tt> (uppercase +P+):
+
+ /\P{Alpha}/.match('1') # => #<MatchData "1">
+ /\P{Alpha}/.match('a') # => nil
+
+See {Unicode Properties}[rdoc-ref:regexp/unicode_properties.rdoc]
+for regexps based on the numerous properties.
+
+Some commonly-used properties correspond to POSIX bracket expressions:
+
+- <tt>/\p{Alnum}/</tt>: Alphabetic and numeric character
+- <tt>/\p{Alpha}/</tt>: Alphabetic character
+- <tt>/\p{Blank}/</tt>: Space or tab
+- <tt>/\p{Cntrl}/</tt>: Control character
+- <tt>/\p{Digit}/</tt>: Digit
+ characters, and similar)
+- <tt>/\p{Lower}/</tt>: Lowercase alphabetical character
+- <tt>/\p{Print}/</tt>: Like <tt>\p{Graph}</tt>, but includes the space character
+- <tt>/\p{Punct}/</tt>: Punctuation character
+- <tt>/\p{Space}/</tt>: Whitespace character (<tt>[:blank:]</tt>, newline,
+ carriage return, etc.)
+- <tt>/\p{Upper}/</tt>: Uppercase alphabetical
+- <tt>/\p{XDigit}/</tt>: Digit allowed in a hexadecimal number (i.e., 0-9a-fA-F)
+
+These are also commonly used:
+
+- <tt>/\p{Emoji}/</tt>: Unicode emoji.
+- <tt>/\p{Graph}/</tt>: Non-blank character
+ (excludes spaces, control characters, and similar).
+- <tt>/\p{Word}/</tt>: A member in one of these Unicode character
+ categories (see below) or having one of these Unicode properties:
+
+ - Unicode categories:
+ - +Mark+ (+M+).
+ - <tt>Decimal Number</tt> (+Nd+)
+ - <tt>Connector Punctuation</tt> (+Pc+).
+
+ - Unicode properties:
+ - +Alpha+
+ - <tt>Join_Control</tt>
+
+- <tt>/\p{ASCII}/</tt>: A character in the ASCII character set.
+- <tt>/\p{Any}/</tt>: Any Unicode character (including unassigned characters).
+- <tt>/\p{Assigned}/</tt>: An assigned character.
+
+==== Unicode Character Categories
+
+A Unicode character category name:
+
+- May be either its full name or its abbreviated name.
+- Is case-insensitive.
+- Treats a space, a hyphen, and an underscore as equivalent.
+
+Examples:
+
+ /\p{lu}/ # => /\p{lu}/
+ /\p{LU}/ # => /\p{LU}/
+ /\p{Uppercase Letter}/ # => /\p{Uppercase Letter}/
+ /\p{Uppercase_Letter}/ # => /\p{Uppercase_Letter}/
+ /\p{UPPERCASE-LETTER}/ # => /\p{UPPERCASE-LETTER}/
+
+Below are the Unicode character category abbreviations and names.
+Enumerations of characters in each category are at the links.
+
+Letters:
+
+- +L+, +Letter+: +LC+, +Lm+, or +Lo+.
+- +LC+, +Cased_Letter+: +Ll+, +Lt+, or +Lu+.
+- {Lu, Lowercase_Letter}[https://www.compart.com/en/unicode/category/Ll].
+- {Lu, Modifier_Letter}[https://www.compart.com/en/unicode/category/Lm].
+- {Lu, Other_Letter}[https://www.compart.com/en/unicode/category/Lo].
+- {Lu, Titlecase_Letter}[https://www.compart.com/en/unicode/category/Lt].
+- {Lu, Uppercase_Letter}[https://www.compart.com/en/unicode/category/Lu].
+
+Marks:
+
+- +M+, +Mark+: +Mc+, +Me+, or +Mn+.
+- {Mc, Spacing_Mark}[https://www.compart.com/en/unicode/category/Mc].
+- {Me, Enclosing_Mark}[https://www.compart.com/en/unicode/category/Me].
+- {Mn, Nonapacing_Mark}[https://www.compart.com/en/unicode/category/Mn].
+
+Numbers:
+
+- +N+, +Number+: +Nd+, +Nl+, or +No+.
+- {Nd, Decimal_Number}[https://www.compart.com/en/unicode/category/Nd].
+- {Nl, Letter_Number}[https://www.compart.com/en/unicode/category/Nl].
+- {No, Other_Number}[https://www.compart.com/en/unicode/category/No].
+
+Punctation:
+
+- +P+, +Punctuation+: +Pc+, +Pd+, +Pe+, +Pf+, +Pi+, +Po+, or +Ps+.
+- {Pc, Connector_Punctuation}[https://www.compart.com/en/unicode/category/Pc].
+- {Pd, Dash_Punctuation}[https://www.compart.com/en/unicode/category/Pd].
+- {Pe, Close_Punctuation}[https://www.compart.com/en/unicode/category/Pe].
+- {Pf, Final_Punctuation}[https://www.compart.com/en/unicode/category/Pf].
+- {Pi, Initial_Punctuation}[https://www.compart.com/en/unicode/category/Pi].
+- {Po, Other_Punctuation}[https://www.compart.com/en/unicode/category/Po].
+- {Ps, Open_Punctuation}[https://www.compart.com/en/unicode/category/Ps].
+
+- +S+, +Symbol+: +Sc+, +Sk+, +Sm+, or +So+.
+- {Sc, Currency_Symbol}[https://www.compart.com/en/unicode/category/Sc].
+- {Sk, Modifier_Symbol}[https://www.compart.com/en/unicode/category/Sk].
+- {Sm, Math_Symbol}[https://www.compart.com/en/unicode/category/Sm].
+- {So, Other_Symbol}[https://www.compart.com/en/unicode/category/So].
+
+- +Z+, +Separator+: +Zl+, +Zp+, or +Zs+.
+- {Zl, Line_Separator}[https://www.compart.com/en/unicode/category/Zl].
+- {Zp, Paragraph_Separator}[https://www.compart.com/en/unicode/category/Zp].
+- {Zs, Space_Separator}[https://www.compart.com/en/unicode/category/Zs].
+
+- +C+, +Other+: +Cc+, +Cf+, +Cn+, +Co+, or +Cs+.
+- {Cc, Control}[https://www.compart.com/en/unicode/category/Cc].
+- {Cf, Format}[https://www.compart.com/en/unicode/category/Cf].
+- {Cn, Unassigned}[https://www.compart.com/en/unicode/category/Cn].
+- {Co, Private_Use}[https://www.compart.com/en/unicode/category/Co].
+- {Cs, Surrogate}[https://www.compart.com/en/unicode/category/Cs].
+
+==== Unicode Scripts and Blocks
+
+Among the Unicode properties are:
+
+- {Unicode scripts}[https://en.wikipedia.org/wiki/Script_(Unicode)];
+ see {supported scripts}[https://www.unicode.org/standard/supported.html].
+- {Unicode blocks}[https://en.wikipedia.org/wiki/Unicode_block];
+ see {supported blocks}[http://www.unicode.org/Public/UNIDATA/Blocks.txt].
+
+=== POSIX Bracket Expressions
+
+A POSIX <i>bracket expression</i> is also similar to a character class.
+These expressions provide a portable alternative to the above,
+with the added benefit of encompassing non-ASCII characters:
+
+- <tt>/\d/</tt> matches only ASCII decimal digits +0+ through +9+.
+- <tt>/[[:digit:]]/</tt> matches any character in the Unicode
+ <tt>Decimal Number</tt> (+Nd+) category;
+ see below.
+
+The POSIX bracket expressions:
+
+- <tt>/[[:digit:]]/</tt>: Matches a {Unicode digit}[https://www.compart.com/en/unicode/category/Nd]:
+
+ /[[:digit:]]/.match('9') # => #<MatchData "9">
+ /[[:digit:]]/.match("\u1fbf9") # => #<MatchData "9">
+
+- <tt>/[[:xdigit:]]/</tt>: Matches a digit allowed in a hexadecimal number;
+ equivalent to <tt>[0-9a-fA-F]</tt>.
+
+- <tt>/[[:upper:]]/</tt>: Matches a {Unicode uppercase letter}[https://www.compart.com/en/unicode/category/Lu]:
+
+ /[[:upper:]]/.match('A') # => #<MatchData "A">
+ /[[:upper:]]/.match("\u00c6") # => #<MatchData "Æ">
+
+- <tt>/[[:lower:]]/</tt>: Matches a {Unicode lowercase letter}[https://www.compart.com/en/unicode/category/Ll]:
+
+ /[[:lower:]]/.match('a') # => #<MatchData "a">
+ /[[:lower:]]/.match("\u01fd") # => #<MatchData "ǽ">
+
+- <tt>/[[:alpha:]]/</tt>: Matches <tt>/[[:upper:]]/</tt> or <tt>/[[:lower:]]/</tt>.
+
+- <tt>/[[:alnum:]]/</tt>: Matches <tt>/[[:alpha:]]/</tt> or <tt>/[[:digit:]]/</tt>.
+
+- <tt>/[[:space:]]/</tt>: Matches {Unicode space character}[https://www.compart.com/en/unicode/category/Zs]:
+
+ /[[:space:]]/.match(' ') # => #<MatchData " ">
+ /[[:space:]]/.match("\u2005") # => #<MatchData " ">
+
+- <tt>/[[:blank:]]/</tt>: Matches <tt>/[[:space:]]/</tt> or tab character:
+
+ /[[:blank:]]/.match(' ') # => #<MatchData " ">
+ /[[:blank:]]/.match("\u2005") # => #<MatchData " ">
+ /[[:blank:]]/.match("\t") # => #<MatchData "\t">
+
+- <tt>/[[:cntrl:]]/</tt>: Matches {Unicode control character}[https://www.compart.com/en/unicode/category/Cc]:
+
+ /[[:cntrl:]]/.match("\u0000") # => #<MatchData "\u0000">
+ /[[:cntrl:]]/.match("\u009f") # => #<MatchData "\u009F">
+
+- <tt>/[[:graph:]]/</tt>: Matches any character
+ except <tt>/[[:space:]]/</tt> or <tt>/[[:cntrl:]]/</tt>.
+
+- <tt>/[[:print:]]/</tt>: Matches <tt>/[[:graph:]]/</tt> or space character.
+
+- <tt>/[[:punct:]]/</tt>: Matches any (Unicode punctuation character}[https://www.compart.com/en/unicode/category/Po]:
+
+Ruby also supports these (non-POSIX) bracket expressions:
+
+- <tt>/[[:ascii:]]/</tt>: Matches a character in the ASCII character set.
+- <tt>/[[:word:]]/</tt>: Matches a character in one of these Unicode character
+ categories or having one of these Unicode properties:
+
+ - Unicode categories:
+ - +Mark+ (+M+).
+ - <tt>Decimal Number</tt> (+Nd+)
+ - <tt>Connector Punctuation</tt> (+Pc+).
+
+ - Unicode properties:
+ - +Alpha+
+ - <tt>Join_Control</tt>
+
+=== Comments
+
+A comment may be included in a regexp pattern
+using the <tt>(?#</tt>_comment_<tt>)</tt> construct,
+where _comment_ is a substring that is to be ignored.
+arbitrary text ignored by the regexp engine:
+
+ /foo(?#Ignore me)bar/.match('foobar') # => #<MatchData "foobar">
+
+The comment may not include an unescaped terminator character.
+
+See also {Extended Mode}[rdoc-ref:Regexp@Extended+Mode].
+
+== Modes
+
+Each of these modifiers sets a mode for the regexp:
+
+- +i+: <tt>/_pattern_/i</tt> sets
+ {Case-Insensitive Mode}[rdoc-ref:Regexp@Case-Insensitive+Mode].
+- +m+: <tt>/_pattern_/m</tt> sets
+ {Multiline Mode}[rdoc-ref:Regexp@Multiline+Mode].
+- +x+: <tt>/_pattern_/x</tt> sets
+ {Extended Mode}[rdoc-ref:Regexp@Extended+Mode].
+- +o+: <tt>/_pattern_/o</tt> sets
+ {Interpolation Mode}[rdoc-ref:Regexp@Interpolation+Mode].
+
+Any, all, or none of these may be applied.
+
+Modifiers +i+, +m+, and +x+ may be applied to subexpressions:
+
+- <tt>(?_modifier_)</tt> turns the mode "on" for ensuing subexpressions
+- <tt>(?-_modifier_)</tt> turns the mode "off" for ensuing subexpressions
+- <tt>(?_modifier_:_subexp_)</tt> turns the mode "on" for _subexp_ within the group
+- <tt>(?-_modifier_:_subexp_)</tt> turns the mode "off" for _subexp_ within the group
+
+Example:
+
+ re = /(?i)te(?-i)st/
+ re.match('test') # => #<MatchData "test">
+ re.match('TEst') # => #<MatchData "TEst">
+ re.match('TEST') # => nil
+ re.match('teST') # => nil
+
+ re = /t(?i:e)st/
+ re.match('test') # => #<MatchData "test">
+ re.match('tEst') # => #<MatchData "tEst">
+ re.match('tEST') # => nil
+
+\Method Regexp#options returns an integer whose value showing
+the settings for case-insensitivity mode, multiline mode, and extended mode.
+
+=== Case-Insensitive Mode
+
+By default, a regexp is case-sensitive:
+
+ /foo/.match('FOO') # => nil
+
+Modifier +i+ enables case-insensitive mode:
+
+ /foo/i.match('FOO')
+ # => #<MatchData "FOO">
+
+\Method Regexp#casefold? returns whether the mode is case-insensitive.
+
+=== Multiline Mode
+
+The multiline-mode in Ruby is what is commonly called a "dot-all mode":
+
+- Without the +m+ modifier, the subexpression <tt>.</tt> does not match newlines:
+
+ /a.c/.match("a\nc") # => nil
+
+- With the modifier, it does match:
+
+ /a.c/m.match("a\nc") # => #<MatchData "a\nc">
+
+Unlike other languages, the modifier +m+ does not affect the anchors <tt>^</tt> and <tt>$</tt>.
+These anchors always match at line-boundaries in Ruby.
+
+=== Extended Mode
+
+Modifier +x+ enables extended mode, which means that:
+
+- Literal white space in the pattern is to be ignored.
+- Character <tt>#</tt> marks the remainder of its containing line as a comment,
+ which is also to be ignored for matching purposes.
+
+In extended mode, whitespace and comments may be used
+to form a self-documented regexp.
+
+Regexp not in extended mode (matches some Roman numerals):
+
+ pattern = '^M{0,3}(CM|CD|D?C{0,3})(XC|XL|L?X{0,3})(IX|IV|V?I{0,3})$'
+ re = /#{pattern}/
+ re.match('MCMXLIII') # => #<MatchData "MCMXLIII" 1:"CM" 2:"XL" 3:"III">
+
+Regexp in extended mode:
+
+ pattern = <<-EOT
+ ^ # beginning of string
+ M{0,3} # thousands - 0 to 3 Ms
+ (CM|CD|D?C{0,3}) # hundreds - 900 (CM), 400 (CD), 0-300 (0 to 3 Cs),
+ # or 500-800 (D, followed by 0 to 3 Cs)
+ (XC|XL|L?X{0,3}) # tens - 90 (XC), 40 (XL), 0-30 (0 to 3 Xs),
+ # or 50-80 (L, followed by 0 to 3 Xs)
+ (IX|IV|V?I{0,3}) # ones - 9 (IX), 4 (IV), 0-3 (0 to 3 Is),
+ # or 5-8 (V, followed by 0 to 3 Is)
+ $ # end of string
+ EOT
+ re = /#{pattern}/x
+ re.match('MCMXLIII') # => #<MatchData "MCMXLIII" 1:"CM" 2:"XL" 3:"III">
+
+=== Interpolation Mode
+
+Modifier +o+ means that the first time a literal regexp with interpolations
+is encountered,
+the generated Regexp object is saved and used for all future evaluations
+of that literal regexp.
+Without modifier +o+, the generated Regexp is not saved,
+so each evaluation of the literal regexp generates a new Regexp object.
+
+Without modifier +o+:
+
+ def letters; sleep 5; /[A-Z][a-z]/; end
+ words = %w[abc def xyz]
+ start = Time.now
+ words.each {|word| word.match(/\A[#{letters}]+\z/) }
+ Time.now - start # => 15.0174892
+
+With modifier +o+:
+
+ start = Time.now
+ words.each {|word| word.match(/\A[#{letters}]+\z/o) }
+ Time.now - start # => 5.0010866
+
+Note that if the literal regexp does not have interpolations,
+the +o+ behavior is the default.
+
+== Encodings
+
+By default, a regexp with only US-ASCII characters has US-ASCII encoding:
+
+ re = /foo/
+ re.source.encoding # => #<Encoding:US-ASCII>
+ re.encoding # => #<Encoding:US-ASCII>
+
+A regular expression containing non-US-ASCII characters
+is assumed to use the source encoding.
+This can be overridden with one of the following modifiers.
+
+- <tt>/_pat_/n</tt>: US-ASCII if only containing US-ASCII characters,
+ otherwise ASCII-8BIT:
+
+ /foo/n.encoding # => #<Encoding:US-ASCII>
+ /foo\xff/n.encoding # => #<Encoding:ASCII-8BIT>
+ /foo\x7f/n.encoding # => #<Encoding:US-ASCII>
+
+- <tt>/_pat_/u</tt>: UTF-8
+
+ /foo/u.encoding # => #<Encoding:UTF-8>
+
+- <tt>/_pat_/e</tt>: EUC-JP
+
+ /foo/e.encoding # => #<Encoding:EUC-JP>
+
+- <tt>/_pat_/s</tt>: Windows-31J
+
+ /foo/s.encoding # => #<Encoding:Windows-31J>
+
+A regexp can be matched against a target string when either:
+
+- They have the same encoding.
+- The regexp's encoding is a fixed encoding and the string
+ contains only ASCII characters.
+ Method Regexp#fixed_encoding? returns whether the regexp
+ has a <i>fixed</i> encoding.
+
+If a match between incompatible encodings is attempted an
+<tt>Encoding::CompatibilityError</tt> exception is raised.
+
+Example:
+
+ re = eval("# encoding: ISO-8859-1\n/foo\\xff?/")
+ re.encoding # => #<Encoding:ISO-8859-1>
+ re =~ "foo".encode("UTF-8") # => 0
+ re =~ "foo\u0100" # Raises Encoding::CompatibilityError
+
+The encoding may be explicitly fixed by including Regexp::FIXEDENCODING
+in the second argument for Regexp.new:
+
+ # Regexp with encoding ISO-8859-1.
+ re = Regexp.new("a".force_encoding('iso-8859-1'), Regexp::FIXEDENCODING)
+ re.encoding # => #<Encoding:ISO-8859-1>
+ # Target string with encoding UTF-8.
+ s = "a\u3042"
+ s.encoding # => #<Encoding:UTF-8>
+ re.match(s) # Raises Encoding::CompatibilityError.
+
+== Timeouts
+
+When either a regexp source or a target string comes from untrusted input,
+malicious values could become a denial-of-service attack;
+to prevent such an attack, it is wise to set a timeout.
+
+\Regexp has two timeout values:
+
+- A class default timeout, used for a regexp whose instance timeout is +nil+;
+ this default is initially +nil+, and may be set by method Regexp.timeout=:
+
+ Regexp.timeout # => nil
+ Regexp.timeout = 3.0
+ Regexp.timeout # => 3.0
+
+- An instance timeout, which defaults to +nil+ and may be set in Regexp.new:
+
+ re = Regexp.new('foo', timeout: 5.0)
+ re.timeout # => 5.0
+
+When regexp.timeout is +nil+, the timeout "falls through" to Regexp.timeout;
+when regexp.timeout is non-+nil+, that value controls timing out:
+
+ | regexp.timeout Value | Regexp.timeout Value | Result |
+ |----------------------|----------------------|-----------------------------|
+ | nil | nil | Never times out. |
+ | nil | Float | Times out in Float seconds. |
+ | Float | Any | Times out in Float seconds. |
+
+== Optimization
+
+For certain values of the pattern and target string,
+matching time can grow polynomially or exponentially in relation to the input size;
+the potential vulnerability arising from this is the {regular expression denial-of-service}[https://en.wikipedia.org/wiki/ReDoS] (ReDoS) attack.
+
+\Regexp matching can apply an optimization to prevent ReDoS attacks.
+When the optimization is applied, matching time increases linearly (not polynomially or exponentially)
+in relation to the input size, and a ReDoS attach is not possible.
+
+This optimization is applied if the pattern meets these criteria:
+
+- No backreferences.
+- No subexpression calls.
+- No nested lookaround anchors or atomic groups.
+- No nested quantifiers with counting (i.e. no nested <tt>{n}</tt>,
+ <tt>{min,}</tt>, <tt>{,max}</tt>, or <tt>{min,max}</tt> style quantifiers)
+
+You can use method Regexp.linear_time? to determine whether a pattern meets these criteria:
+
+ Regexp.linear_time?(/a*/) # => true
+ Regexp.linear_time?('a*') # => true
+ Regexp.linear_time?(/(a*)\1/) # => false
+
+However, an untrusted source may not be safe even if the method returns +true+,
+because the optimization uses memoization (which may invoke large memory consumption).
+
+== References
+
+Read (online PDF books):
+
+- {Mastering Regular Expressions}[https://ia902508.us.archive.org/10/items/allitebooks-02/Mastering%20Regular%20Expressions%2C%203rd%20Edition.pdf]
+ by Jeffrey E.F. Friedl.
+- {Regular Expressions Cookbook}[https://doc.lagout.org/programmation/Regular%20Expressions/Regular%20Expressions%20Cookbook_%20Detailed%20Solutions%20in%20Eight%20Programming%20Languages%20%282nd%20ed.%29%20%5BGoyvaerts%20%26%20Levithan%202012-09-06%5D.pdf]
+ by Jan Goyvaerts & Steven Levithan.
+
+Explore, test (interactive online editor):
+
+- {Rubular}[https://rubular.com/].
diff --git a/doc/_timezones.rdoc b/doc/_timezones.rdoc
new file mode 100644
index 0000000000..c5230ea67d
--- /dev/null
+++ b/doc/_timezones.rdoc
@@ -0,0 +1,156 @@
+== Timezone Specifiers
+
+Certain +Time+ methods accept arguments that specify timezones:
+
+- Time.at: keyword argument +in:+.
+- Time.new: positional argument +zone+ or keyword argument +in:+.
+- Time.now: keyword argument +in:+.
+- Time#getlocal: positional argument +zone+.
+- Time#localtime: positional argument +zone+.
+
+The value given with any of these must be one of the following
+(each detailed below):
+
+- {Hours/minutes offset}[rdoc-ref:Time@Hours-2FMinutes+Offsets].
+- {Single-letter offset}[rdoc-ref:Time@Single-Letter+Offsets].
+- {Integer offset}[rdoc-ref:Time@Integer+Offsets].
+- {Timezone object}[rdoc-ref:Time@Timezone+Objects].
+- {Timezone name}[rdoc-ref:Time@Timezone+Names].
+
+=== Hours/Minutes Offsets
+
+The zone value may be a string offset from UTC
+in the form <tt>'+HH:MM'</tt> or <tt>'-HH:MM'</tt>,
+where:
+
+- +HH+ is the 2-digit hour in the range <tt>0..23</tt>.
+- +MM+ is the 2-digit minute in the range <tt>0..59</tt>.
+
+Examples:
+
+ t = Time.utc(2000, 1, 1, 20, 15, 1) # => 2000-01-01 20:15:01 UTC
+ Time.at(t, in: '-23:59') # => 1999-12-31 20:16:01 -2359
+ Time.at(t, in: '+23:59') # => 2000-01-02 20:14:01 +2359
+
+=== Single-Letter Offsets
+
+The zone value may be a letter in the range <tt>'A'..'I'</tt>
+or <tt>'K'..'Z'</tt>;
+see {List of military time zones}[https://en.wikipedia.org/wiki/List_of_military_time_zones]:
+
+ t = Time.utc(2000, 1, 1, 20, 15, 1) # => 2000-01-01 20:15:01 UTC
+ Time.at(t, in: 'A') # => 2000-01-01 21:15:01 +0100
+ Time.at(t, in: 'I') # => 2000-01-02 05:15:01 +0900
+ Time.at(t, in: 'K') # => 2000-01-02 06:15:01 +1000
+ Time.at(t, in: 'Y') # => 2000-01-01 08:15:01 -1200
+ Time.at(t, in: 'Z') # => 2000-01-01 20:15:01 UTC
+
+=== \Integer Offsets
+
+The zone value may be an integer number of seconds
+in the range <tt>-86399..86399</tt>:
+
+ t = Time.utc(2000, 1, 1, 20, 15, 1) # => 2000-01-01 20:15:01 UTC
+ Time.at(t, in: -86399) # => 1999-12-31 20:15:02 -235959
+ Time.at(t, in: 86399) # => 2000-01-02 20:15:00 +235959
+
+=== Timezone Objects
+
+The zone value may be an object responding to certain timezone methods, an
+instance of {Timezone}[https://github.com/panthomakos/timezone] and
+{TZInfo}[https://tzinfo.github.io] for example.
+
+The timezone methods are:
+
+- +local_to_utc+:
+
+ - Called when Time.new is invoked with +tz+
+ as the value of positional argument +zone+ or keyword argument +in:+.
+ - Argument: a {Time-like object}[rdoc-ref:Time@Time-Like+Objects].
+ - Returns: a {Time-like object}[rdoc-ref:Time@Time-Like+Objects] in the UTC timezone.
+
+- +utc_to_local+:
+
+ - Called when Time.at or Time.now is invoked with +tz+
+ as the value for keyword argument +in:+,
+ and when Time#getlocal or Time#localtime is called with +tz+
+ as the value for positional argument +zone+.
+ - Argument: a {Time-like object}[rdoc-ref:Time@Time-Like+Objects].
+ - Returns: a {Time-like object}[rdoc-ref:Time@Time-Like+Objects] in the local timezone.
+
+A custom timezone class may have these instance methods,
+which will be called if defined:
+
+- +abbr+:
+
+ - Called when Time#strftime is invoked with a format involving <tt>%Z</tt>.
+ - Argument: a {Time-like object}[rdoc-ref:Time@Time-Like+Objects].
+ - Returns: a string abbreviation for the timezone name.
+
+- +dst?+:
+
+ - Called when Time.at or Time.now is invoked with +tz+
+ as the value for keyword argument +in:+,
+ and when Time#getlocal or Time#localtime is called with +tz+
+ as the value for positional argument +zone+.
+ - Argument: a {Time-like object}[rdoc-ref:Time@Time-Like+Objects].
+ - Returns: whether the time is daylight saving time.
+
+- +name+:
+
+ - Called when <tt>Marshal.dump(t)</tt> is invoked
+ - Argument: none.
+ - Returns: the string name of the timezone.
+
+==== +Time+-Like Objects
+
+A +Time+-like object is a container object capable of interfacing with
+timezone libraries for timezone conversion.
+
+The argument to the timezone conversion methods above will have attributes
+similar to Time, except that timezone related attributes are meaningless.
+
+The objects returned by +local_to_utc+ and +utc_to_local+ methods of the
+timezone object may be of the same class as their arguments, of arbitrary
+object classes, or of class Integer.
+
+For a returned class other than +Integer+, the class must have the
+following methods:
+
+- +year+
+- +mon+
+- +mday+
+- +hour+
+- +min+
+- +sec+
+- +isdst+
+- +to_i+
+
+For a returned +Integer+, its components, decomposed in UTC, are
+interpreted as times in the specified timezone.
+
+=== Timezone Names
+
+If the class (the receiver of class methods, or the class of the receiver
+of instance methods) has +find_timezone+ singleton method, this method is
+called to achieve the corresponding timezone object from a timezone name.
+
+For example, using {Timezone}[https://github.com/panthomakos/timezone]:
+ class TimeWithTimezone < Time
+ require 'timezone'
+ def self.find_timezone(z) = Timezone[z]
+ end
+
+ TimeWithTimezone.now(in: "America/New_York") #=> 2023-12-25 00:00:00 -0500
+ TimeWithTimezone.new("2023-12-25 America/New_York") #=> 2023-12-25 00:00:00 -0500
+
+Or, using {TZInfo}[https://tzinfo.github.io]:
+ class TimeWithTZInfo < Time
+ require 'tzinfo'
+ def self.find_timezone(z) = TZInfo::Timezone.get(z)
+ end
+
+ TimeWithTZInfo.now(in: "America/New_York") #=> 2023-12-25 00:00:00 -0500
+ TimeWithTZInfo.new("2023-12-25 America/New_York") #=> 2023-12-25 00:00:00 -0500
+
+You can define this method per subclasses, or on the toplevel Time class.
diff --git a/doc/bsearch.rdoc b/doc/bsearch.rdoc
index ca8091fc0d..90705853d7 100644
--- a/doc/bsearch.rdoc
+++ b/doc/bsearch.rdoc
@@ -1,4 +1,4 @@
-== Binary Searching
+= Binary Searching
A few Ruby methods support binary searching in a collection:
diff --git a/doc/case_mapping.rdoc b/doc/case_mapping.rdoc
index 3c42154973..57c037b9d8 100644
--- a/doc/case_mapping.rdoc
+++ b/doc/case_mapping.rdoc
@@ -1,4 +1,4 @@
-== Case Mapping
+= Case Mapping
Some string-oriented methods use case mapping.
@@ -24,7 +24,7 @@ In Symbol:
- Symbol#swapcase
- Symbol#upcase
-=== Default Case Mapping
+== Default Case Mapping
By default, all of these methods use full Unicode case mapping,
which is suitable for most languages.
@@ -60,7 +60,7 @@ Case changes may not be reversible:
Case changing methods may not maintain Unicode normalization.
See String#unicode_normalize).
-=== Options for Case Mapping
+== Options for Case Mapping
Except for +casecmp+ and +casecmp?+,
each of the case-mapping methods listed above
diff --git a/doc/character_selectors.rdoc b/doc/character_selectors.rdoc
index e01b0e6a25..47cf242be7 100644
--- a/doc/character_selectors.rdoc
+++ b/doc/character_selectors.rdoc
@@ -1,6 +1,6 @@
-== Character Selectors
+= Character Selectors
-=== Character Selector
+== Character Selector
A _character_ _selector_ is a string argument accepted by certain Ruby methods.
Each of these instance methods accepts one or more character selectors:
@@ -70,7 +70,7 @@ In a character selector, these three characters get special treatment:
"hello\r\nworld".delete("\\r") # => "hello\r\nwold"
"hello\r\nworld".delete("\\\r") # => "hello\nworld"
-=== Multiple Character Selectors
+== Multiple Character Selectors
These instance methods accept multiple character selectors:
diff --git a/doc/command_injection.rdoc b/doc/command_injection.rdoc
index af09be23f0..246b2e6afe 100644
--- a/doc/command_injection.rdoc
+++ b/doc/command_injection.rdoc
@@ -1,4 +1,4 @@
-== Command Injection
+= Command Injection
Some Ruby core methods accept string data
that includes text to be executed as a system command.
@@ -8,6 +8,7 @@ They should not be called with unknown or unsanitized commands.
These methods include:
- Kernel.system
+- Kernel.open
- {\`command` (backtick method)}[rdoc-ref:Kernel#`]
(also called by the expression <tt>%x[command]</tt>).
- IO.popen(command).
@@ -17,6 +18,7 @@ These methods include:
- IO.binwrite(command).
- IO.readlines(command).
- IO.foreach(command).
+- URI.open(command).
Note that some of these methods do not execute commands when called
from subclass \File:
diff --git a/doc/contributing/building_ruby.md b/doc/contributing/building_ruby.md
index ffe4c46160..b2a7b007eb 100644
--- a/doc/contributing/building_ruby.md
+++ b/doc/contributing/building_ruby.md
@@ -5,21 +5,28 @@
1. Install the prerequisite dependencies for building the CRuby interpreter:
* C compiler
- * autoconf - 2.67 or later
- * bison - 3.0 or later
- * gperf - 3.0.3 or later
- * ruby - 2.2 or later
- * We can upgrade this version to system ruby version of the latest Ubuntu LTS.
+
+ For RubyGems, you will also need:
+
* OpenSSL 1.1.x or 3.0.x / LibreSSL
* libyaml 0.1.7 or later
* zlib
+ If you want to build from the git repository, you will also need:
+
+ * autoconf - 2.67 or later
+ * gperf - 3.1 or later
+ * Usually unneeded; only if you edit some source files using gperf
+ * ruby - 2.5 or later
+ * We can upgrade this version to system ruby version of the latest Ubuntu LTS.
+
2. Install optional, recommended dependencies:
- * readline/editline (libedit)
- * libffi
+ * libffi (to build fiddle)
+ * gmp (if you with to accelerate Bignum operations)
* libexecinfo (FreeBSD)
- * rustc - 1.58.0 or later (if you wish to build [YJIT](/doc/yjit/yjit.md))
+ * rustc - 1.58.0 or later, if you wish to build
+ [YJIT](https://docs.ruby-lang.org/en/master/RubyVM/YJIT.html).
If you installed the libraries needed for extensions (openssl, readline, libyaml, zlib) into other than the OS default place,
typically using Homebrew on macOS, add `--with-EXTLIB-dir` options to `CONFIGURE_ARGS` environment variable.
@@ -33,19 +40,36 @@
## Quick start guide
-1. Checkout the CRuby source code:
+1. Download ruby source code:
- ``` shell
- git clone https://github.com/ruby/ruby.git
- ```
+ Select one of the bellow.
-2. Generate the configure file:
+ 1. Build from the tarball:
- ``` shell
- ./autogen.sh
- ```
+ Download the latest tarball from [ruby-lang.org](https://www.ruby-lang.org/en/downloads/) and
+ extract it. Example for Ruby 3.0.2:
+
+ ``` shell
+ tar -xzf ruby-3.0.2.tar.gz
+ cd ruby-3.0.2
+ ```
-3. Create a `build` directory outside of the source directory:
+ 2. Build from the git repository:
+
+ Checkout the CRuby source code:
+
+ ``` shell
+ git clone https://github.com/ruby/ruby.git
+ cd ruby
+ ```
+
+ Generate the configure file:
+
+ ``` shell
+ ./autogen.sh
+ ```
+
+2. Create a `build` directory separate from the source directory:
``` shell
mkdir build && cd build
@@ -53,13 +77,13 @@
While it's not necessary to build in a separate directory, it's good practice to do so.
-4. We'll install Ruby in `~/.rubies/ruby-master`, so create the directory:
+3. We'll install Ruby in `~/.rubies/ruby-master`, so create the directory:
``` shell
mkdir ~/.rubies
```
-5. Run configure:
+4. Run configure:
``` shell
../configure --prefix="${HOME}/.rubies/ruby-master"
@@ -67,18 +91,24 @@
- If you are frequently building Ruby, add the `--disable-install-doc` flag to not build documentation which will speed up the build process.
-6. Build Ruby:
+ - Also `-C` (or `--config-cache`) would reduce time to configure from the next time.
+
+5. Build Ruby:
``` shell
make install
```
-7. [Run tests](testing_ruby.md) to confirm your build succeeded.
+6. [Run tests](testing_ruby.md) to confirm your build succeeded.
### Unexplainable Build Errors
If you are having unexplainable build errors, after saving all your work, try running `git clean -xfd` in the source root to remove all git ignored local files. If you are working from a source directory that's been updated several times, you may have temporary build artifacts from previous releases which can cause build failures.
+## Building on Windows
+
+The documentation for building on Windows can be found [here](../windows.md).
+
## More details
If you're interested in continuing development on Ruby, here are more details
@@ -133,6 +163,14 @@ with the Ruby script you'd like to run. You can use the following make targets:
* `make lldb-ruby`: Runs `test.rb` using Ruby in lldb
* `make gdb-ruby`: Runs `test.rb` using Ruby in gdb
+### Compiling for Debugging
+
+You should configure Ruby without optimization and other flags that may interfere with debugging:
+
+``` shell
+./configure --enable-debug-env optflags="-O0 -fno-omit-frame-pointer"
+```
+
### Building with Address Sanitizer
Using the address sanitizer is a great way to detect memory issues.
diff --git a/doc/contributing/documentation_guide.md b/doc/contributing/documentation_guide.md
index 9cfd59d629..027be34775 100644
--- a/doc/contributing/documentation_guide.md
+++ b/doc/contributing/documentation_guide.md
@@ -20,14 +20,16 @@ build directory:
make html
```
+If you don't have a build directory, follow the [quick start
+guide](building_ruby.md#label-Quick+start+guide) up to step 4.
+
Then you can preview your changes by opening
`{build folder}/.ext/html/index.html` file in your browser.
-
## Goal
The goal of Ruby documentation is to impart the most important
-and relevant in the shortest time.
+and relevant information in the shortest time.
The reader should be able to quickly understand the usefulness
of the subject code and how to use it.
@@ -41,16 +43,17 @@ Use your judgment about what the user needs to know.
- Write short declarative or imperative sentences.
- Group sentences into (ideally short) paragraphs,
each covering a single topic.
-- Organize material with [headers](rdoc-ref:RDoc::Markup@Headers).
+- Organize material with
+ [headings](rdoc-ref:RDoc::MarkupReference@Headings).
- Refer to authoritative and relevant sources using
- [links](rdoc-ref:RDoc::Markup@Links).
+ [links](rdoc-ref:RDoc::MarkupReference@Links).
- Use simple verb tenses: simple present, simple past, simple future.
- Use simple sentence structure, not compound or complex structure.
- Avoid:
- Excessive comma-separated phrases;
- consider a [list](rdoc-ref:RDoc::Markup@Simple+Lists).
+ consider a [list](rdoc-ref:RDoc::MarkupReference@Lists).
- Idioms and culture-specific references.
- - Overuse of headers.
+ - Overuse of headings.
- Using US-ASCII-incompatible characters in C source files;
see [Characters](#label-Characters) below.
@@ -124,16 +127,23 @@ a.shuffle! #=> [2, 3, 1]
a #=> [2, 3, 1]
```
-### Headers
+### Headings
+
+Organize a long discussion for a class or module with [headings](rdoc-ref:RDoc::MarkupReference@Headings).
-Organize a long discussion with [headers](rdoc-ref:RDoc::Markup@Headers).
+Do not use formal headings in the documentation for a method or constant.
+
+In the rare case where heading-like structures are needed
+within the documentation for a method or constant, use
+[bold text](rdoc-ref:RDoc::MarkupReference@Bold)
+as pseudo-headings.
### Blank Lines
A blank line begins a new paragraph.
-A [code block](rdoc-ref:RDoc::Markup@Paragraphs+and+Verbatim)
-or [list](rdoc-ref:RDoc::Markup@Simple+Lists)
+A [code block](rdoc-ref:RDoc::MarkupReference@Code+Blocks)
+or [list](rdoc-ref:RDoc::MarkupReference@Lists)
should be preceded by and followed by a blank line.
This is unnecessary for the HTML output, but helps in the `ri` output.
@@ -150,6 +160,14 @@ For a method name in text:
or a hash mark for an instance method:
<tt>Foo.bar</tt>, <tt>Foo#baz</tt>.
+### Embedded Code and Commands
+
+Code or commands embedded in running text (i.e., not in a code block)
+should marked up as
+[monofont](rdoc-ref:RDoc::MarkupReference@Monofont).
+
+Code that is a simple string should include the quote marks.
+
### Auto-Linking
In general, \RDoc's auto-linking should not be suppressed.
@@ -163,6 +181,61 @@ We might consider whether to suppress when:
(e.g., _Array_ in the documentation for class `Array`).
- The same reference is repeated many times
(e.g., _RDoc_ on this page).
+- The reference is to a class or module that users
+ usually don't deal with, including these:
+
+ - \Class.
+ - \Method.
+ - \Module.
+
+Most often, the name of a class, module, or method
+will be autolinked:
+
+- Array.
+- Enumerable.
+- File.new
+- File#read.
+
+If not, or if you suppress autolinking, consider forcing
+[monofont](rdoc-ref:RDoc::MarkupReference@Monofont).
+
+### Explicit Links
+
+When writing an explicit link, follow these guidelines.
+
+#### +rdoc-ref+ Scheme
+
+Use the +rdoc-ref+ scheme for:
+
+- A link in core documentation to other core documentation.
+- A link in core documentation to documentation in a standard library package.
+- A link in a standard library package to other documentation in that same
+ standard library package.
+
+See section "+rdoc-ref+ Scheme" in {Links}[rdoc-ref:RDoc::MarkupReference@Links].
+
+#### URL-Based Link
+
+Use a full URL-based link for:
+
+- A link in standard library documentation to documentation in the core.
+- A link in standard library documentation to documentation in a different
+ standard library package.
+
+Doing so ensures that the link will valid even when the package documentation
+is built independently (separately from the core documentation).
+
+The link should lead to a target in https://docs.ruby-lang.org/en/master/.
+
+Also use a full URL-based link for a link to an off-site document.
+
+### Variable Names
+
+The name of a variable (as specified in its call-seq) should be marked up as
+[monofont](rdoc-ref:RDoc::MarkupReference@Monofont).
+
+Also, use monofont text for the name of a transient variable
+(i.e., one defined and used only in the discussion, such as +n+).
### HTML Tags
@@ -175,16 +248,21 @@ may not render them properly.
In particular, avoid building tables with HTML tags
(<tt><table></tt>, etc.).
-Alternatives are:
-
-- The GFM (GitHub Flavored Markdown) table extension,
- which is enabled by default. See
- {GFM tables extension}[https://github.github.com/gfm/#tables-extension-].
+Alternatives:
- A {verbatim text block}[rdoc-ref:RDoc::MarkupReference@Verbatim+Text+Blocks],
- using spaces and punctuation to format the text.
- Note that {text markup}[rdoc-ref:RDoc::MarkupReference@Text+Markup]
- will not be honored.
+ using spaces and punctuation to format the text;
+ note that {text markup}[rdoc-ref:RDoc::MarkupReference@Text+Markup]
+ will not be honored:
+
+ - Example {source}[https://github.com/ruby/ruby/blob/34d802f32f00df1ac0220b62f72605827c16bad8/file.c#L6570-L6596].
+ - Corresponding {output}[rdoc-ref:File@Read-2FWrite+Mode].
+
+- (Markdown format only): A {Github Flavored Markdown (GFM) table}[https://github.github.com/gfm/#tables-extension-],
+ using special formatting for the text:
+
+ - Example {source}[https://github.com/ruby/ruby/blob/34d802f32f00df1ac0220b62f72605827c16bad8/doc/contributing/glossary.md?plain=1].
+ - Corresponding {output}[https://docs.ruby-lang.org/en/master/contributing/glossary_md.html].
## Documenting Classes and Modules
@@ -214,9 +292,12 @@ Guidelines:
- The section title is `What's Here`.
- Consider listing the parent class and any included modules; consider
- [links](rdoc-ref:RDoc::Markup@Links)
+ [links](rdoc-ref:RDoc::MarkupReference@Links)
to their "What's Here" sections if those exist.
-- List methods as a bullet list:
+- All methods mentioned in the left-pane table of contents
+ should be listed (including any methods extended from another class).
+- Attributes (which are not included in the TOC) may also be listed.
+- Display methods as items in one or more bullet lists:
- Begin each item with the method name, followed by a colon
and a short description.
@@ -224,9 +305,9 @@ Guidelines:
(and do not list the aliases separately).
- Check the rendered documentation to determine whether \RDoc has recognized
the method and linked to it; if not, manually insert a
- [link](rdoc-ref:RDoc::Markup@Links).
+ [link](rdoc-ref:RDoc::MarkupReference@Links).
-- If there are numerous entries, consider grouping them into subsections with headers.
+- If there are numerous entries, consider grouping them into subsections with headings.
- If there are more than a few such subsections,
consider adding a table of contents just below the main section title.
@@ -241,7 +322,6 @@ The general structure of the method documentation should be:
- Details and examples.
- Argument description (if necessary).
- Corner cases and exceptions.
-- Aliases.
- Related methods (optional).
### Calling Sequence (for methods written in C)
@@ -250,7 +330,7 @@ For methods written in Ruby, \RDoc documents the calling sequence automatically.
For methods written in C, \RDoc cannot determine what arguments
the method accepts, so those need to be documented using \RDoc directive
-[`call-seq:`](rdoc-ref:RDoc::Markup@Method+arguments).
+[`call-seq:`](rdoc-ref:RDoc::MarkupReference@Directives+for+Method+Documentation).
For a singleton method, use the form:
@@ -328,7 +408,11 @@ Return types:
Aliases:
-- Omit aliases from the `call-seq`, but mention them near the end (see below).
+- Omit aliases from the `call-seq`, unless the alias is an
+ operator method. If listing both a regular method and an
+ operator method in the `call-seq`, explain in the details and
+ examples section when it is recommended to use the regular method
+ and when it is recommended to use the operator method.
### Synopsis
@@ -385,7 +469,7 @@ argument passed if it is not obvious, not explicitly mentioned in the
details, and not implicitly shown in the examples.
If there is more than one argument or block argument, use a
-[labeled list](rdoc-ref:RDoc::Markup@Labeled+Lists).
+[labeled list](rdoc-ref:RDoc::MarkupReference@Labeled+Lists).
### Corner Cases and Exceptions
@@ -398,14 +482,6 @@ you do not need to document that a `TypeError` is raised if a non-integer
is passed. Do not provide examples of exceptions being raised unless
that is a common case, such as `Hash#fetch` raising a `KeyError`.
-### Aliases
-
-Mention aliases in the form
-
-```
-// Array#find_index is an alias for Array#index.
-```
-
### Related Methods (optional)
In some cases, it is useful to document which methods are related to
diff --git a/doc/contributing/glossary.md b/doc/contributing/glossary.md
new file mode 100644
index 0000000000..86c6671fbd
--- /dev/null
+++ b/doc/contributing/glossary.md
@@ -0,0 +1,41 @@
+# Ruby Internals Glossary
+
+Just a list of acronyms I've run across in the Ruby source code and their meanings.
+
+| Term | Definition |
+| --- | -----------|
+| `BIN` | Basic Instruction Name. Used as a macro to reference the YARV instruction. Converts pop into YARVINSN_pop. |
+| `bop` | Basic Operator. Relates to methods like `Integer` plus and minus which can be optimized as long as they haven't been redefined. |
+| `cc` | Call Cache. An inline cache structure for the call site. Stored in the `cd` |
+| `cd` | Call Data. A data structure that points at the `ci` and the `cc`. `iseq` objects points at the `cd`, and access call information and call caches via this structure |
+| `cfp`| Control Frame Pointer. Represents a Ruby stack frame. Calling a method pushes a new frame (cfp), returning pops a frame. Points at the `pc`, `sp`, `ep`, and the corresponding `iseq`|
+| `ci` | Call Information. Refers to an `rb_callinfo` struct. Contains call information about the call site, including number of parameters to be passed, whether it they are keyword arguments or not, etc. Used in conjunction with the `cc` and `cd`. |
+| `cref` | Class reference. A structure pointing to the class reference where `klass_or_self`, visibility scope, and refinements are stored. It also stores a pointer to the next class in the hierarchy referenced by `rb_cref_struct * next`. The Class reference is lexically scoped. |
+| CRuby | Implementation of Ruby written in C |
+| `cvar` | Class Variable. Refers to a Ruby class variable like `@@foo` |
+| `dvar` | Dynamic Variable. Used by the parser to refer to local variables that are defined outside of the current lexical scope. For example `def foo; bar = 1; -> { p bar }; end` the "bar" inside the block is a `dvar` |
+| `ec` | Execution Context. The top level VM context, points at the current `cfp` |
+| `ep` | Environment Pointer. Local variables, including method parameters are stored in the `ep` array. The `ep` is pointed to by the `cfp` |
+| GC | Garbage Collector |
+| `gvar` | Global Variable. Refers to a Ruby global variable like `$$`, etc |
+| `ICLASS` | Internal Class. When a module is included, the target class gets a new superclass which is an instance of an `ICLASS`. The `ICLASS` represents the module in the inheritance chain. |
+| `ifunc` | Internal FUNCtion. A block implemented in C. |
+| `iseq` | Instruction Sequence. Usually "iseq" in the C code will refer to an `rb_iseq_t` object that holds a reference to the actual instruction sequences which are executed by the VM. The object also holds information about the code, like the method name associated with the code. |
+| `insn` | Instruction. Refers to a YARV instruction. |
+| `insns` | Instructions. Usually an array of YARV instructions. |
+| `ivar` | Instance Variable. Refers to a Ruby instance variable like `@foo` |
+| `imemo` | Internal Memo. A tagged struct whose memory is managed by Ruby's GC, but contains internal information and isn't meant to be exposed to Ruby programs. Contains various information depending on the type. See the `imemo_type` enum for different types. |
+| JIT | Just In Time compiler |
+| `lep` | Local Environment Pointer. An `ep` which is tagged `VM_ENV_FLAG_LOCAL`. Usually this is the `ep` of a method (rather than a block, whose `ep` isn't "local") |
+| `local` | Local. Refers to a local variable. |
+| `me` | Method Entry. Refers to an `rb_method_entry_t` struct, the internal representation of a Ruby method.
+| MRI | Matz's Ruby Implementation |
+| `pc` | Program Counter. Usually the instruction that will be executed _next_ by the VM. Pointed to by the `cfp` and incremented by the VM |
+| `sp` | Stack Pointer. The top of the stack. The VM executes instructions in the `iseq` and instructions will push and pop values on the stack. The VM updates the `sp` on the `cfp` to point at the top of the stack|
+| `svar` | Special Variable. Refers to special local variables like `$~` and `$_`. See the `getspecial` instruction in `insns.def` |
+| `VALUE` | VALUE is a pointer to a ruby object from the Ruby C code. |
+| VM | Virtual Machine. In MRI's case YARV (Yet Another Ruby VM)
+| WB | Write Barrier. To do with GC write barriers |
+| WC | Wild Card. As seen in instructions like `getlocal_WC_0`. It means this instruction takes a "wild card" for the parameter (in this case an index for a local) |
+| YARV | Yet Another Ruby VM. The virtual machine that CRuby uses |
+| ZOMBIE | A zombie object. An object that has a finalizer which hasn't been executed yet. The object has been collected, so is "dead", but the finalizer hasn't run yet so it's still somewhat alive. |
diff --git a/doc/contributing/making_changes_to_stdlibs.md b/doc/contributing/making_changes_to_stdlibs.md
index ef3811ea12..3b33092fea 100644
--- a/doc/contributing/making_changes_to_stdlibs.md
+++ b/doc/contributing/making_changes_to_stdlibs.md
@@ -8,7 +8,7 @@ For example, CSV lives in [a separate repository](https://github.com/ruby/csv) a
## Maintainers
-You can find the list of maintainers [here](https://docs.ruby-lang.org/en/master/maintainers_rdoc.html#label-Maintainers).
+You can find the list of maintainers [here](https://docs.ruby-lang.org/en/master/maintainers_md.html#label-Maintainers).
## Build
diff --git a/doc/contributing/testing_ruby.md b/doc/contributing/testing_ruby.md
index 6247686efc..dfb7fb3a65 100644
--- a/doc/contributing/testing_ruby.md
+++ b/doc/contributing/testing_ruby.md
@@ -70,7 +70,7 @@ We can run any of the make scripts [in parallel](building_ruby.md#label-Running+
first the file name, and then the test name, prefixed with `--name`. For example:
```
- make test-all TESTS="../test/ruby/test_alias.rb --name=/test_alias_with_zsuper_method/"
+ make test-all TESTS="../test/ruby/test_alias.rb --name=TestAlias#test_alias_with_zsuper_method"
```
To run these specs with logs, we can use:
@@ -79,7 +79,13 @@ We can run any of the make scripts [in parallel](building_ruby.md#label-Running+
make test-all TESTS=-v
```
- If we would like to run both the `test/` and `bootstraptest/` test suites, we can run
+ We can display the help of the `TESTS` option:
+
+ ```
+ make test-all TESTS=--help
+ ```
+
+ If we would like to run the `test/`, `bootstraptest/` and `spec/` test suites (the `spec/` is explained in a later section), we can run
```
make check
@@ -93,28 +99,28 @@ We can run any of the make scripts [in parallel](building_ruby.md#label-Running+
make test-spec
```
- To run a specific directory, we can use `MSPECOPT` to specify the directory:
+ To run a specific directory, we can use `SPECOPTS` to specify the directory:
```
- make test-spec MSPECOPT=spec/ruby/core/array
+ make test-spec SPECOPTS=spec/ruby/core/array
```
- To run a specific file, we can also use `MSPECOPT` to specify the file:
+ To run a specific file, we can also use `SPECOPTS` to specify the file:
```
- make test-spec MSPECOPT=spec/ruby/core/array/any_spec.rb
+ make test-spec SPECOPTS=spec/ruby/core/array/any_spec.rb
```
To run a specific test, we can use the `--example` flag to match against the test name:
```
- make test-spec MSPECOPT="../spec/ruby/core/array/any_spec.rb --example='is false if the array is empty'"
+ make test-spec SPECOPTS="../spec/ruby/core/array/any_spec.rb --example='is false if the array is empty'"
```
To run these specs with logs, we can use:
```
- make test-spec MSPECOPT=-Vfs
+ make test-spec SPECOPTS=-Vfs
```
To run a ruby-spec file or directory with GNU make, we can use
@@ -134,5 +140,17 @@ We can run any of the make scripts [in parallel](building_ruby.md#label-Running+
To run a specific bundler spec file, we can use `BUNDLER_SPECS` as follows:
```
- $ make test-bundler BUNDLER_SPECS=commands/exec_spec.rb
+ make test-bundler BUNDLER_SPECS=commands/exec_spec.rb
```
+
+## Troubleshooting
+
+### Running test suites on s390x CPU Architecture
+
+If we see failing tests related to the zlib library on s390x CPU architecture, we can run the test suites with `DFLTCC=0` to pass:
+
+```
+DFLTCC=0 make check
+```
+
+The failures can happen with the zlib library applying the patch [madler/zlib#410](https://github.com/madler/zlib/pull/410) to enable the deflate algorithm producing a different compressed byte stream. We manage this issue at [[ruby-core:114942][Bug #19909]](https://bugs.ruby-lang.org/issues/19909).
diff --git a/doc/csv/options/common/col_sep.rdoc b/doc/csv/options/common/col_sep.rdoc
index 05769b5773..3f23c6d2d3 100644
--- a/doc/csv/options/common/col_sep.rdoc
+++ b/doc/csv/options/common/col_sep.rdoc
@@ -55,9 +55,3 @@ Raises an exception if parsing with the empty \String:
# Raises ArgumentError (:col_sep must be 1 or more characters: "")
CSV.parse("foo0\nbar1\nbaz2\n", col_sep: col_sep)
-Raises an exception if the given value is not String-convertible:
- col_sep = BasicObject.new
- # Raises NoMethodError (undefined method `to_s' for #<BasicObject:>)
- CSV.generate(line, col_sep: col_sep)
- # Raises NoMethodError (undefined method `to_s' for #<BasicObject:>)
- CSV.parse(str, col_sep: col_sep)
diff --git a/doc/csv/options/common/row_sep.rdoc b/doc/csv/options/common/row_sep.rdoc
index 872d9d1f3f..eae15b4a84 100644
--- a/doc/csv/options/common/row_sep.rdoc
+++ b/doc/csv/options/common/row_sep.rdoc
@@ -89,12 +89,3 @@ if any of the following is true:
* The stream is only available for output.
Obviously, discovery takes a little time. Set manually if speed is important. Also note that IO objects should be opened in binary mode on Windows if this feature will be used as the line-ending translation can cause problems with resetting the document position to where it was before the read ahead.
-
----
-
-Raises an exception if the given value is not String-convertible:
- row_sep = BasicObject.new
- # Raises NoMethodError (undefined method `to_s' for #<BasicObject:>)
- CSV.generate(ary, row_sep: row_sep)
- # Raises NoMethodError (undefined method `to_s' for #<BasicObject:>)
- CSV.parse(str, row_sep: row_sep)
diff --git a/doc/csv/options/generating/write_converters.rdoc b/doc/csv/options/generating/write_converters.rdoc
index 6e5fae5fda..d1a9cc748f 100644
--- a/doc/csv/options/generating/write_converters.rdoc
+++ b/doc/csv/options/generating/write_converters.rdoc
@@ -23,11 +23,3 @@ With two write converters (called in order):
str # => "a,b,c\n"
See also {Write Converters}[#class-CSV-label-Write+Converters]
-
----
-
-Raises an exception if the converter returns a value that is neither +nil+
-nor \String-convertible:
- bad_converter = proc {|field| BasicObject.new }
- # Raises NoMethodError (undefined method `is_a?' for #<BasicObject:>)
- CSV.generate_line(['a', 'b', 'c'], write_converters: bad_converter) \ No newline at end of file
diff --git a/doc/csv/options/generating/write_headers.rdoc b/doc/csv/options/generating/write_headers.rdoc
index f9faa9d438..c56aa48adb 100644
--- a/doc/csv/options/generating/write_headers.rdoc
+++ b/doc/csv/options/generating/write_headers.rdoc
@@ -19,7 +19,7 @@ Without +write_headers+:
With +write_headers+":
CSV.open(file_path,'w',
- :write_headers=> true,
+ :write_headers => true,
:headers => ['Name','Value']
) do |csv|
csv << ['foo', '0']
diff --git a/doc/csv/options/parsing/liberal_parsing.rdoc b/doc/csv/options/parsing/liberal_parsing.rdoc
index b8b9b00c98..603de28613 100644
--- a/doc/csv/options/parsing/liberal_parsing.rdoc
+++ b/doc/csv/options/parsing/liberal_parsing.rdoc
@@ -1,13 +1,13 @@
====== Option +liberal_parsing+
-Specifies the boolean value that determines whether
+Specifies the boolean or hash value that determines whether
CSV will attempt to parse input not conformant with RFC 4180,
such as double quotes in unquoted fields.
Default value:
CSV::DEFAULT_OPTIONS.fetch(:liberal_parsing) # => false
-For examples in this section:
+For the next two examples:
str = 'is,this "three, or four",fields'
Without +liberal_parsing+:
@@ -17,3 +17,22 @@ Without +liberal_parsing+:
With +liberal_parsing+:
ary = CSV.parse_line(str, liberal_parsing: true)
ary # => ["is", "this \"three", " or four\"", "fields"]
+
+Use the +backslash_quote+ sub-option to parse values that use
+a backslash to escape a double-quote character. This
+causes the parser to treat <code>\"</code> as if it were
+<code>""</code>.
+
+For the next two examples:
+ str = 'Show,"Harry \"Handcuff\" Houdini, the one and only","Tampa Theater"'
+
+With +liberal_parsing+, but without the +backslash_quote+ sub-option:
+ # Incorrect interpretation of backslash; incorrectly interprets the quoted comma as a field separator.
+ ary = CSV.parse_line(str, liberal_parsing: true)
+ ary # => ["Show", "\"Harry \\\"Handcuff\\\" Houdini", " the one and only\"", "Tampa Theater"]
+ puts ary[1] # => "Harry \"Handcuff\" Houdini
+
+With +liberal_parsing+ and its +backslash_quote+ sub-option:
+ ary = CSV.parse_line(str, liberal_parsing: { backslash_quote: true })
+ ary # => ["Show", "Harry \"Handcuff\" Houdini, the one and only", "Tampa Theater"]
+ puts ary[1] # => Harry "Handcuff" Houdini, the one and only
diff --git a/doc/csv/recipes/filtering.rdoc b/doc/csv/recipes/filtering.rdoc
index 470649d09a..1552bf0fb8 100644
--- a/doc/csv/recipes/filtering.rdoc
+++ b/doc/csv/recipes/filtering.rdoc
@@ -1,5 +1,7 @@
== Recipes for Filtering \CSV
+These recipes are specific code examples for specific \CSV filtering tasks.
+
For other recipes, see {Recipes for CSV}[./recipes_rdoc.html].
All code snippets on this page assume that the following has been executed:
diff --git a/doc/csv/recipes/generating.rdoc b/doc/csv/recipes/generating.rdoc
index 3ef6df99b4..a6bd88a714 100644
--- a/doc/csv/recipes/generating.rdoc
+++ b/doc/csv/recipes/generating.rdoc
@@ -1,5 +1,7 @@
== Recipes for Generating \CSV
+These recipes are specific code examples for specific \CSV generating tasks.
+
For other recipes, see {Recipes for CSV}[./recipes_rdoc.html].
All code snippets on this page assume that the following has been executed:
@@ -144,7 +146,7 @@ This example defines and uses a custom write converter to strip whitespace from
==== Recipe: Specify Multiple Write Converters
-Use option <tt>:write_converters</tt> and multiple custom coverters
+Use option <tt>:write_converters</tt> and multiple custom converters
to convert field values when generating \CSV.
This example defines and uses two custom write converters to strip and upcase generated fields:
diff --git a/doc/csv/recipes/parsing.rdoc b/doc/csv/recipes/parsing.rdoc
index 7ac96a934b..f3528fbdf1 100644
--- a/doc/csv/recipes/parsing.rdoc
+++ b/doc/csv/recipes/parsing.rdoc
@@ -1,5 +1,7 @@
== Recipes for Parsing \CSV
+These recipes are specific code examples for specific \CSV parsing tasks.
+
For other recipes, see {Recipes for CSV}[./recipes_rdoc.html].
All code snippets on this page assume that the following has been executed:
@@ -518,7 +520,7 @@ Apply multiple header converters by defining and registering a custom header con
To capture unconverted field values, use option +:unconverted_fields+:
source = "Name,Value\nfoo,0\nbar,1\nbaz,2\n"
parsed = CSV.parse(source, converters: :integer, unconverted_fields: true)
- parsed # => [["foo", "0"], ["bar", "1"], ["baz", "2"]]
+ parsed # => [["Name", "Value"], ["foo", 0], ["bar", 1], ["baz", 2]]
parsed.each {|row| p row.unconverted_fields }
Output:
["Name", "Value"]
diff --git a/doc/csv/recipes/recipes.rdoc b/doc/csv/recipes/recipes.rdoc
index 9e4eaa1da4..9bf7885b1e 100644
--- a/doc/csv/recipes/recipes.rdoc
+++ b/doc/csv/recipes/recipes.rdoc
@@ -1,6 +1,6 @@
== Recipes for \CSV
-See:
+The recipes are specific code examples for specific tasks. See:
- {Recipes for Parsing CSV}[./parsing_rdoc.html]
- {Recipes for Generating CSV}[./generating_rdoc.html]
- {Recipes for Filtering CSV}[./filtering_rdoc.html]
diff --git a/doc/distribution.md b/doc/distribution.md
index fd918576e7..bc89a7500a 100644
--- a/doc/distribution.md
+++ b/doc/distribution.md
@@ -2,9 +2,21 @@
This document outlines the expected way to distribute Ruby, with a specific focus on building Ruby packages.
-## Building a Ruby Tarball
+## Getting the Ruby Tarball
-The standard way to build a package for distribution is to build a tarball. This tarball includes all the related files need to build and install Ruby correctly. This includes the Ruby source code, the Ruby standard library, and the Ruby documentation.
+### Official Releases
+
+The tarball for official releases is created by the release manager. The release manager uploads the tarball to the [Ruby website](https://www.ruby-lang.org/en/downloads/).
+
+Downstream distributors should use the official release tarballs as part of their build process. This ensures that the tarball is created in a consistent way, and that the tarball is crytographically verified.
+
+### Using the nightly tarball for testing
+
+See the Snapshots section of the [Ruby website](https://www.ruby-lang.org/en/downloads/).
+
+### Building a manual snapshot tarball for testing
+
+This can be useful if the nightly tarball does not have all changes yet.
At Ruby source tree cloned using git:
```sh-session
@@ -16,11 +28,9 @@ $ make dist
This will create several tarball in the `tmp` directory. The tarball will be named e.g. `ruby-<version>.tar.gz` (several different compression formats will be generated).
-### Official Releases
+## Building the Tarball
-The tarball for official releases is created by the release manager. The release manager will run the above commands to create the tarball. The release manager will then upload the tarball to the [Ruby website](https://www.ruby-lang.org/en/downloads/).
-
-Downstream distributors should use the official release tarballs as part of their build process. This ensures that the tarball is created in a consistent way, and that the tarball is crytographically verified.
+See [Building Ruby](contributing/building_ruby.md).
## Updating the Ruby Standard Library
diff --git a/doc/encodings.rdoc b/doc/encodings.rdoc
index 1f3c54d740..97c0d22616 100644
--- a/doc/encodings.rdoc
+++ b/doc/encodings.rdoc
@@ -1,6 +1,6 @@
-== Encodings
+= Encodings
-=== The Basics
+== The Basics
A {character encoding}[https://en.wikipedia.org/wiki/Character_encoding],
often shortened to _encoding_, is a mapping between:
@@ -30,9 +30,9 @@ Other characters, such as the Euro symbol, are multi-byte:
s = "\u20ac" # => "€"
s.bytes # => [226, 130, 172]
-=== The \Encoding \Class
+== The \Encoding \Class
-==== \Encoding Objects
+=== \Encoding Objects
Ruby encodings are defined by constants in class \Encoding.
There can be only one instance of \Encoding for each of these constants.
@@ -43,7 +43,7 @@ There can be only one instance of \Encoding for each of these constants.
Encoding.list.take(3)
# => [#<Encoding:ASCII-8BIT>, #<Encoding:UTF-8>, #<Encoding:US-ASCII>]
-==== Names and Aliases
+=== Names and Aliases
\Method Encoding#name returns the name of an \Encoding:
@@ -78,7 +78,7 @@ because it includes both the names and their aliases.
Encoding.find("US-ASCII") # => #<Encoding:US-ASCII>
Encoding.find("US-ASCII").class # => Encoding
-==== Default Encodings
+=== Default Encodings
\Method Encoding.find, above, also returns a default \Encoding
for each of these special names:
@@ -118,7 +118,7 @@ for each of these special names:
Encoding.default_internal = 'US-ASCII' # => "US-ASCII"
Encoding.default_internal # => #<Encoding:US-ASCII>
-==== Compatible Encodings
+=== Compatible Encodings
\Method Encoding.compatible? returns whether two given objects are encoding-compatible
(that is, whether they can be concatenated);
@@ -132,20 +132,21 @@ returns the \Encoding of the concatenated string, or +nil+ if incompatible:
s1 = "\xa1\xa1".force_encoding('euc-jp') # => "\x{A1A1}"
Encoding.compatible?(s0, s1) # => nil
-=== \String \Encoding
+== \String \Encoding
A Ruby String object has an encoding that is an instance of class \Encoding.
The encoding may be retrieved by method String#encoding.
-The default encoding for a string literal is the script encoding
-(see Encoding@Script+encoding):
+The default encoding for a string literal is the script encoding;
+see {Script Encoding}[rdoc-ref:encodings.rdoc@Script+Encoding].
's'.encoding # => #<Encoding:UTF-8>
The default encoding for a string created with method String.new is:
- For a \String object argument, the encoding of that string.
-- For a string literal, the script encoding (see Encoding@Script+encoding).
+- For a string literal, the script encoding;
+ see {Script Encoding}[rdoc-ref:encodings.rdoc@Script+Encoding].
In either case, any encoding may be specified:
@@ -182,7 +183,7 @@ Here are a couple of useful query methods:
s = "\xc2".force_encoding("UTF-8") # => "\xC2"
s.valid_encoding? # => false
-=== \Symbol and \Regexp Encodings
+== \Symbol and \Regexp Encodings
The string stored in a Symbol or Regexp object also has an encoding;
the encoding may be retrieved by method Symbol#encoding or Regexp#encoding.
@@ -190,22 +191,23 @@ the encoding may be retrieved by method Symbol#encoding or Regexp#encoding.
The default encoding for these, however, is:
- US-ASCII, if all characters are US-ASCII.
-- The script encoding, otherwise (see Encoding@Script+encoding).
+- The script encoding, otherwise;
+ see (Script Encoding)[rdoc-ref:encodings.rdoc@Script+Encoding].
-=== Filesystem \Encoding
+== Filesystem \Encoding
The filesystem encoding is the default \Encoding for a string from the filesystem:
Encoding.find("filesystem") # => #<Encoding:UTF-8>
-=== Locale \Encoding
+== Locale \Encoding
The locale encoding is the default encoding for a string from the environment,
other than from the filesystem:
Encoding.find('locale') # => #<Encoding:IBM437>
-=== Stream Encodings
+== Stream Encodings
Certain stream objects can have two encodings; these objects include instances of:
@@ -220,7 +222,7 @@ The two encodings are:
- An _internal_ _encoding_, which (if not +nil+) specifies the encoding
to be used for the string constructed from the stream.
-==== External \Encoding
+=== External \Encoding
The external encoding, which is an \Encoding object, specifies how bytes read
from the stream are to be interpreted as characters.
@@ -248,7 +250,7 @@ For an \IO, \File, \ARGF, or \StringIO object, the external encoding may be set
- \Methods +set_encoding+ or (except for \ARGF) +set_encoding_by_bom+.
-==== Internal \Encoding
+=== Internal \Encoding
The internal encoding, which is an \Encoding object or +nil+,
specifies how characters read from the stream
@@ -274,7 +276,7 @@ For an \IO, \File, \ARGF, or \StringIO object, the internal encoding may be set
- \Method +set_encoding+.
-=== Script \Encoding
+== Script \Encoding
A Ruby script has a script encoding, which may be retrieved by:
@@ -289,7 +291,7 @@ followed by a colon, space and the Encoding name or alias:
# encoding: ISO-8859-1
__ENCODING__ #=> #<Encoding:ISO-8859-1>
-=== Transcoding
+== Transcoding
_Transcoding_ is the process of changing a sequence of characters
from one encoding to another.
@@ -300,7 +302,7 @@ but the bytes that represent them may change.
The handling for characters that cannot be represented in the destination encoding
may be specified by @Encoding+Options.
-==== Transcoding a \String
+=== Transcoding a \String
Each of these methods transcodes a string:
@@ -315,7 +317,7 @@ Each of these methods transcodes a string:
- String#unicode_normalize!: Like String#unicode_normalize,
but transcodes +self+ in place.
-=== Transcoding a Stream
+== Transcoding a Stream
Each of these methods may transcode a stream;
whether it does so depends on the external and internal encodings:
@@ -350,7 +352,7 @@ Output:
"R\xE9sum\xE9"
"Résumé"
-=== \Encoding Options
+== \Encoding Options
A number of methods in the Ruby core accept keyword arguments as encoding options.
diff --git a/doc/extension.rdoc b/doc/extension.rdoc
index c0360ae625..f0e12f27f2 100644
--- a/doc/extension.rdoc
+++ b/doc/extension.rdoc
@@ -771,6 +771,63 @@ Arguments klass and data_type work like their counterparts in
TypedData_Wrap_Struct(). A pointer to the allocated structure will
be assigned to sval, which should be a pointer of the type specified.
+==== Declaratively marking/compacting struct references
+
+In the case where your struct refers to Ruby objects that are simple values,
+not wrapped in conditional logic or complex data structures an alternative
+approach to marking and reference updating is provided, by declaring offset
+references to the VALUES in your struct.
+
+Doing this allows the Ruby GC to support marking these references and GC
+compaction without the need to define the +dmark+ and +dcompact+ callbacks.
+
+You must define a static list of VALUE pointers to the offsets within your
+struct where the references are located, and set the "data" member to point to
+this reference list. The reference list must end with +RUBY_END_REFS+.
+
+Some Macros have been provided to make edge referencing easier:
+
+* <code>RUBY_TYPED_DECL_MARKING</code> =A flag that can be set on the +ruby_data_type_t+ to indicate that references are being declared as edges.
+
+* <code>RUBY_REFERENCES(ref_list_name)</code> - Define _ref_list_name_ as a list of references
+
+* <code>RUBY_REF_END</code> - The end mark of the references list.
+
+* <code>RUBY_REF_EDGE(struct, member)</code> - Declare _member_ as a VALUE edge from _struct_. Use this after +RUBY_REFERENCES_START+
+
+* +RUBY_REFS_LIST_PTR+ - Coerce the reference list into a format that can be
+ accepted by the existing +dmark+ interface.
+
+The example below is from Dir (defined in +dir.c+)
+
+ // The struct being wrapped. Notice this contains 3 members of which the second
+ // is a VALUE reference to another ruby object.
+ struct dir_data {
+ DIR *dir;
+ const VALUE path;
+ rb_encoding *enc;
+ }
+
+ // Define a reference list `dir_refs` containing a single entry to `path`.
+ // Needs terminating with RUBY_REF_END
+ RUBY_REFERENCES(dir_refs) = {
+ RUBY_REF_EDGE(dir_data, path),
+ RUBY_REF_END
+ };
+
+ // Override the "dmark" field with the defined reference list now that we
+ // no longer need a marking callback and add RUBY_TYPED_DECL_MARKING to the
+ // flags field
+ static const rb_data_type_t dir_data_type = {
+ "dir",
+ {RUBY_REFS_LIST_PTR(dir_refs), dir_free, dir_memsize,},
+ 0, NULL, RUBY_TYPED_WB_PROTECTED | RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_DECL_MARKING
+ };
+
+Declaring simple references declaratively in this manner allows the GC to both
+mark, and move the underlying object, and automatically update the reference to
+it during compaction.
+
==== Ruby object to C struct
To retrieve the C pointer from the T_DATA object, use the macro
diff --git a/doc/format_specifications.rdoc b/doc/format_specifications.rdoc
index e589524f27..1111575e74 100644
--- a/doc/format_specifications.rdoc
+++ b/doc/format_specifications.rdoc
@@ -1,4 +1,4 @@
-== Format Specifications
+= Format Specifications
Several Ruby core classes have instance method +printf+ or +sprintf+:
@@ -37,12 +37,12 @@ It consists of:
Except for the leading percent character,
the only required part is the type specifier, so we begin with that.
-=== Type Specifiers
+== Type Specifiers
This section provides a brief explanation of each type specifier.
The links lead to the details and examples.
-==== \Integer Type Specifiers
+=== \Integer Type Specifiers
- +b+ or +B+: Format +argument+ as a binary integer.
See {Specifiers b and B}[rdoc-ref:format_specifications.rdoc@Specifiers+b+and+B].
@@ -54,7 +54,7 @@ The links lead to the details and examples.
- +x+ or +X+: Format +argument+ as a hexadecimal integer.
See {Specifiers x and X}[rdoc-ref:format_specifications.rdoc@Specifiers+x+and+X].
-==== Floating-Point Type Specifiers
+=== Floating-Point Type Specifiers
- +a+ or +A+: Format +argument+ as hexadecimal floating-point number.
See {Specifiers a and A}[rdoc-ref:format_specifications.rdoc@Specifiers+a+and+A].
@@ -65,7 +65,7 @@ The links lead to the details and examples.
- +g+ or +G+: Format +argument+ in a "general" format.
See {Specifiers g and G}[rdoc-ref:format_specifications.rdoc@Specifiers+g+and+G].
-==== Other Type Specifiers
+=== Other Type Specifiers
- +c+: Format +argument+ as a character.
See {Specifier c}[rdoc-ref:format_specifications.rdoc@Specifier+c].
@@ -76,7 +76,7 @@ The links lead to the details and examples.
- <tt>%</tt>: Format +argument+ (<tt>'%'</tt>) as a single percent character.
See {Specifier %}[rdoc-ref:format_specifications.rdoc@Specifier+-25].
-=== Flags
+== Flags
The effect of a flag may vary greatly among type specifiers.
These remarks are general in nature.
@@ -85,7 +85,7 @@ See {type-specific details}[rdoc-ref:format_specifications.rdoc@Type+Specifier+D
Multiple flags may be given with single type specifier;
order does not matter.
-==== <tt>' '</tt> Flag
+=== <tt>' '</tt> Flag
Insert a space before a non-negative number:
@@ -97,49 +97,49 @@ Insert a minus sign for negative value:
sprintf('%d', -10) # => "-10"
sprintf('% d', -10) # => "-10"
-==== <tt>'#'</tt> Flag
+=== <tt>'#'</tt> Flag
Use an alternate format; varies among types:
sprintf('%x', 100) # => "64"
sprintf('%#x', 100) # => "0x64"
-==== <tt>'+'</tt> Flag
+=== <tt>'+'</tt> Flag
Add a leading plus sign for a non-negative number:
sprintf('%x', 100) # => "64"
sprintf('%+x', 100) # => "+64"
-==== <tt>'-'</tt> Flag
+=== <tt>'-'</tt> Flag
Left justify the value in its field:
sprintf('%6d', 100) # => " 100"
sprintf('%-6d', 100) # => "100 "
-==== <tt>'0'</tt> Flag
+=== <tt>'0'</tt> Flag
Left-pad with zeros instead of spaces:
sprintf('%6d', 100) # => " 100"
sprintf('%06d', 100) # => "000100"
-==== <tt>'*'</tt> Flag
+=== <tt>'*'</tt> Flag
Use the next argument as the field width:
sprintf('%d', 20, 14) # => "20"
sprintf('%*d', 20, 14) # => " 14"
-==== <tt>'n$'</tt> Flag
+=== <tt>'n$'</tt> Flag
Format the (1-based) <tt>n</tt>th argument into this field:
sprintf("%s %s", 'world', 'hello') # => "world hello"
sprintf("%2$s %1$s", 'world', 'hello') # => "hello world"
-=== Width Specifier
+== Width Specifier
In general, a width specifier determines the minimum width (in characters)
of the formatted field:
@@ -152,7 +152,7 @@ of the formatted field:
# Ignore if too small.
sprintf('%1d', 100) # => "100"
-=== Precision Specifier
+== Precision Specifier
A precision specifier is a decimal point followed by zero or more
decimal digits.
@@ -194,9 +194,9 @@ the number of characters to write:
sprintf('%s', Time.now) # => "2022-05-04 11:59:16 -0400"
sprintf('%.10s', Time.now) # => "2022-05-04"
-=== Type Specifier Details and Examples
+== Type Specifier Details and Examples
-==== Specifiers +a+ and +A+
+=== Specifiers +a+ and +A+
Format +argument+ as hexadecimal floating-point number:
@@ -209,7 +209,7 @@ Format +argument+ as hexadecimal floating-point number:
sprintf('%A', 4096) # => "0X1P+12"
sprintf('%A', -4096) # => "-0X1P+12"
-==== Specifiers +b+ and +B+
+=== Specifiers +b+ and +B+
The two specifiers +b+ and +B+ behave identically
except when flag <tt>'#'</tt>+ is used.
@@ -226,14 +226,14 @@ Format +argument+ as a binary integer:
sprintf('%#b', 4) # => "0b100"
sprintf('%#B', 4) # => "0B100"
-==== Specifier +c+
+=== Specifier +c+
Format +argument+ as a single character:
sprintf('%c', 'A') # => "A"
sprintf('%c', 65) # => "A"
-==== Specifier +d+
+=== Specifier +d+
Format +argument+ as a decimal integer:
@@ -242,7 +242,7 @@ Format +argument+ as a decimal integer:
Flag <tt>'#'</tt> does not apply.
-==== Specifiers +e+ and +E+
+=== Specifiers +e+ and +E+
Format +argument+ in
{scientific notation}[https://en.wikipedia.org/wiki/Scientific_notation]:
@@ -250,7 +250,7 @@ Format +argument+ in
sprintf('%e', 3.14159) # => "3.141590e+00"
sprintf('%E', -3.14159) # => "-3.141590E+00"
-==== Specifier +f+
+=== Specifier +f+
Format +argument+ as a floating-point number:
@@ -259,7 +259,7 @@ Format +argument+ as a floating-point number:
Flag <tt>'#'</tt> does not apply.
-==== Specifiers +g+ and +G+
+=== Specifiers +g+ and +G+
Format +argument+ using exponential form (+e+/+E+ specifier)
if the exponent is less than -4 or greater than or equal to the precision.
@@ -281,7 +281,7 @@ Otherwise format +argument+ using floating-point form (+f+ specifier):
sprintf('%#G', 100000000000) # => "1.00000E+11"
sprintf('%#G', 0.000000000001) # => "1.00000E-12"
-==== Specifier +o+
+=== Specifier +o+
Format +argument+ as an octal integer.
If +argument+ is negative, it will be formatted as a two's complement
@@ -296,14 +296,14 @@ prefixed with +..7+:
sprintf('%#o', 16) # => "020"
sprintf('%#o', -16) # => "..760"
-==== Specifier +p+
+=== Specifier +p+
Format +argument+ as a string via <tt>argument.inspect</tt>:
t = Time.now
sprintf('%p', t) # => "2022-05-01 13:42:07.1645683 -0500"
-==== Specifier +s+
+=== Specifier +s+
Format +argument+ as a string via <tt>argument.to_s</tt>:
@@ -312,7 +312,7 @@ Format +argument+ as a string via <tt>argument.to_s</tt>:
Flag <tt>'#'</tt> does not apply.
-==== Specifiers +x+ and +X+
+=== Specifiers +x+ and +X+
Format +argument+ as a hexadecimal integer.
If +argument+ is negative, it will be formatted as a two's complement
@@ -329,7 +329,7 @@ prefixed with +..f+:
# Alternate format for negative value.
sprintf('%#x', -100) # => "0x..f9c"
-==== Specifier <tt>%</tt>
+=== Specifier <tt>%</tt>
Format +argument+ (<tt>'%'</tt>) as a single percent character:
@@ -337,7 +337,7 @@ Format +argument+ (<tt>'%'</tt>) as a single percent character:
Flags do not apply.
-=== Reference by Name
+== Reference by Name
For more complex formatting, Ruby supports a reference by name.
%<name>s style uses format style, but %{name} style doesn't.
diff --git a/doc/globals.rdoc b/doc/globals.rdoc
index 1d7cda69f9..1bf78a60ab 100644
--- a/doc/globals.rdoc
+++ b/doc/globals.rdoc
@@ -1,69 +1,422 @@
-# -*- mode: rdoc; coding: utf-8; fill-column: 74; -*-
-
-== Pre-defined global variables
-
-$!:: The Exception object set by Kernel#raise.
-$@:: The same as <code>$!.backtrace</code>.
-$~:: The information about the last match in the current scope (thread-local and frame-local).
-$&:: The string matched by the last successful match.
-$`:: The string to the left of the last successful match.
-$':: The string to the right of the last successful match.
-$+:: The highest group matched by the last successful match.
-$1:: The Nth group of the last successful match. May be > 1.
-$=:: This variable is no longer effective. Deprecated.
-$/:: The input record separator, newline by default. Aliased to $-0.
-$\:: The output record separator for Kernel#print and IO#write. Default is +nil+.
-$,:: The output field separator for Kernel#print and Array#join. Non-nil $, will be deprecated.
-$;:: The default separator for String#split. Non-nil $; will be deprecated. Aliased to $-F.
-$.:: The current input line number of the last file that was read.
-$<:: The same as ARGF.
-$>:: The default output stream for Kernel#print and Kernel#printf. $stdout by default.
-$_:: The last input line of string by gets or readline.
-$0:: Contains the name of the script being executed. May be assignable.
-$*:: The same as ARGV.
-$$:: The process number of the Ruby running this script. Same as Process.pid.
-$?:: The status of the last executed child process (thread-local).
-$LOAD_PATH:: Load path for searching Ruby scripts and extension libraries used
- by Kernel#load and Kernel#require. Aliased to $: and $-I.
- Has a singleton method <code>$LOAD_PATH.resolve_feature_path(feature)</code>
- that returns [+:rb+ or +:so+, path], which resolves the feature to
- the path the original Kernel#require method would load.
-$LOADED_FEATURES:: The array contains the module names loaded by require.
- Aliased to $".
-$DEBUG:: The debug flag, which is set by the <tt>-d</tt> switch. Enabling debug
- output prints each exception raised to $stderr (but not its
- backtrace). Setting this to a true value enables debug output as
- if <tt>-d</tt> were given on the command line. Setting this to a false
- value disables debug output. Aliased to $-d.
-$FILENAME:: Current input filename from ARGF. Same as ARGF.filename.
-$stderr:: The current standard error output.
-$stdin:: The current standard input.
-$stdout:: The current standard output.
-$VERBOSE:: The verbose flag, which is set by the <tt>-w</tt> or <tt>-v</tt> switch.
- Setting this to a true value enables warnings as if <tt>-w</tt> or <tt>-v</tt> were given
- on the command line. Setting this to +nil+ disables warnings,
- including from Kernel#warn. Aliased to $-v and $-w.
-$-a:: True if option <tt>-a</tt> is set. Read-only variable.
-$-i:: In in-place-edit mode, this variable holds the extension, otherwise +nil+.
-$-l:: True if option <tt>-l</tt> is set. Read-only variable.
-$-p:: True if option <tt>-p</tt> is set. Read-only variable.
-
-== Pre-defined global constants
-
-STDIN:: The standard input. The default value for $stdin.
-STDOUT:: The standard output. The default value for $stdout.
-STDERR:: The standard error output. The default value for $stderr.
-ENV:: The hash contains current environment variables.
-ARGF:: The virtual concatenation of the files given on command line (or from $stdin if no files were given).
-ARGV:: An Array of command line arguments given for the script.
-DATA:: The file object of the script, pointing just after <code>__END__</code>.
-TOPLEVEL_BINDING:: The Binding of the top level scope.
-RUBY_VERSION:: The Ruby language version.
-RUBY_RELEASE_DATE:: The release date string.
-RUBY_PLATFORM:: The platform identifier.
-RUBY_PATCHLEVEL:: The patchlevel for this Ruby. If this is a development build of Ruby the patchlevel will be -1.
-RUBY_REVISION:: The GIT commit hash for this Ruby.
-RUBY_COPYRIGHT:: The copyright string for Ruby.
-RUBY_ENGINE:: The name of the Ruby implementation.
-RUBY_ENGINE_VERSION:: The version of the Ruby implementation.
-RUBY_DESCRIPTION:: The same as <tt>ruby --version</tt>, a String describing various aspects of the Ruby implementation.
+= Pre-Defined Global Variables
+
+Some of the pre-defined global variables have synonyms
+that are available via module Engish.
+For each of those, the \English synonym is given.
+
+To use the module:
+
+ require 'English'
+
+== Exceptions
+
+=== <tt>$!</tt> (\Exception)
+
+Contains the Exception object set by Kernel#raise:
+
+ begin
+ raise RuntimeError.new('Boo!')
+ rescue RuntimeError
+ p $!
+ end
+
+Output:
+
+ #<RuntimeError: Boo!>
+
+English - <tt>$ERROR_INFO</tt>
+
+=== <tt>$@</tt> (Backtrace)
+
+Same as <tt>$!.backtrace</tt>;
+returns an array of backtrace positions:
+
+ begin
+ raise RuntimeError.new('Boo!')
+ rescue RuntimeError
+ pp $@.take(4)
+ end
+
+Output:
+
+ ["(irb):338:in `<top (required)>'",
+ "/snap/ruby/317/lib/ruby/3.2.0/irb/workspace.rb:119:in `eval'",
+ "/snap/ruby/317/lib/ruby/3.2.0/irb/workspace.rb:119:in `evaluate'",
+ "/snap/ruby/317/lib/ruby/3.2.0/irb/context.rb:502:in `evaluate'"]
+
+English - <tt>$ERROR_POSITION</tt>.
+
+== Pattern Matching
+
+These global variables store information about the most recent
+successful match in the current scope.
+
+For details and examples,
+see {Regexp Global Variables}[rdoc-ref:Regexp@Global+Variables].
+
+=== <tt>$~</tt> (\MatchData)
+
+MatchData object created from the match;
+thread-local and frame-local.
+
+English - <tt>$LAST_MATCH_INFO</tt>.
+
+=== <tt>$&</tt> (Matched Substring)
+
+The matched string.
+
+English - <tt>$MATCH</tt>.
+
+=== <tt>$`</tt> (Pre-Match Substring)
+
+The string to the left of the match.
+
+English - <tt>$PREMATCH</tt>.
+
+=== <tt>$'</tt> (Post-Match Substring)
+
+The string to the right of the match.
+
+English - <tt>$POSTMATCH</tt>.
+
+=== <tt>$+</tt> (Last Matched Group)
+
+The last group matched.
+
+English - <tt>$LAST_PAREN_MATCH</tt>.
+
+=== <tt>$1</tt>, <tt>$2</tt>, \Etc. (Matched Group)
+
+For <tt>$_n_</tt> the _nth_ group of the match.
+
+No \English.
+
+== Separators
+
+=== <tt>$/</tt> (Input Record Separator)
+
+An input record separator, initially newline.
+
+English - <tt>$INPUT_RECORD_SEPARATOR</tt>, <tt>$RS</tt>.
+
+Aliased as <tt>$-0</tt>.
+
+=== <tt>$;</tt> (Input Field Separator)
+
+An input field separator, initially +nil+.
+
+English - <tt>$FIELD_SEPARATOR</tt>, <tt>$FS</tt>.
+
+Aliased as <tt>$-F</tt>.
+
+=== <tt>$\\</tt> (Output Record Separator)
+
+An output record separator, initially +nil+.
+
+English - <tt>$OUTPUT_RECORD_SEPARATOR</tt>, <tt>$ORS</tt>.
+
+== Streams
+
+=== <tt>$stdin</tt> (Standard Input)
+
+The current standard input stream; initially:
+
+ $stdin # => #<IO:<STDIN>>
+
+=== <tt>$stdout</tt> (Standard Output)
+
+The current standard output stream; initially:
+
+ $stdout # => #<IO:<STDOUT>>
+
+=== <tt>$stderr</tt> (Standard Error)
+
+The current standard error stream; initially:
+
+ $stderr # => #<IO:<STDERR>>
+
+=== <tt>$<</tt> (\ARGF or $stdin)
+
+Points to stream ARGF if not empty, else to stream $stdin; read-only.
+
+English - <tt>$DEFAULT_INPUT</tt>.
+
+=== <tt>$></tt> (Default Standard Output)
+
+An output stream, initially <tt>$stdout</tt>.
+
+English - <tt>$DEFAULT_OUTPUT
+
+=== <tt>$.</tt> (Input Position)
+
+The input position (line number) in the most recently read stream.
+
+English - <tt>$INPUT_LINE_NUMBER</tt>, <tt>$NR</tt>
+
+=== <tt>$_</tt> (Last Read Line)
+
+The line (string) from the most recently read stream.
+
+English - <tt>$LAST_READ_LINE</tt>.
+
+== Processes
+
+=== <tt>$0</tt>
+
+Initially, contains the name of the script being executed;
+may be reassigned.
+
+=== <tt>$*</tt> (\ARGV)
+
+Points to ARGV.
+
+English - <tt>$ARGV</tt>.
+
+=== <tt>$$</tt> (Process ID)
+
+The process ID of the current process. Same as Process.pid.
+
+English - <tt>$PROCESS_ID</tt>, <tt>$PID</tt>.
+
+=== <tt>$?</tt> (Child Status)
+
+Initially +nil+, otherwise the Process::Status object
+created for the most-recently exited child process;
+thread-local.
+
+English - <tt>$CHILD_STATUS</tt>.
+
+=== <tt>$LOAD_PATH</tt> (Load Path)
+
+Contains the array of paths to be searched
+by Kernel#load and Kernel#require.
+
+Singleton method <tt>$LOAD_PATH.resolve_feature_path(feature)</tt>
+returns:
+
+- <tt>[:rb, _path_]</tt>, where +path+ is the path to the Ruby file
+ to be loaded for the given +feature+.
+- <tt>[:so+ _path_]</tt>, where +path+ is the path to the shared object file
+ to be loaded for the given +feature+.
+- +nil+ if there is no such +feature+ and +path+.
+
+Examples:
+
+ $LOAD_PATH.resolve_feature_path('timeout')
+ # => [:rb, "/snap/ruby/317/lib/ruby/3.2.0/timeout.rb"]
+ $LOAD_PATH.resolve_feature_path('date_core')
+ # => [:so, "/snap/ruby/317/lib/ruby/3.2.0/x86_64-linux/date_core.so"]
+ $LOAD_PATH.resolve_feature_path('foo')
+ # => nil
+
+Aliased as <tt>$:</tt> and <tt>$-I</tt>.
+
+=== <tt>$LOADED_FEATURES</tt>
+
+Contains an array of the paths to the loaded files:
+
+ $LOADED_FEATURES.take(10)
+ # =>
+ ["enumerator.so",
+ "thread.rb",
+ "fiber.so",
+ "rational.so",
+ "complex.so",
+ "ruby2_keywords.rb",
+ "/snap/ruby/317/lib/ruby/3.2.0/x86_64-linux/enc/encdb.so",
+ "/snap/ruby/317/lib/ruby/3.2.0/x86_64-linux/enc/trans/transdb.so",
+ "/snap/ruby/317/lib/ruby/3.2.0/x86_64-linux/rbconfig.rb",
+ "/snap/ruby/317/lib/ruby/3.2.0/rubygems/compatibility.rb"]
+
+Aliased as <tt>$"</tt>.
+
+== Debugging
+
+=== <tt>$FILENAME</tt>
+
+The value returned by method ARGF.filename.
+
+=== <tt>$DEBUG</tt>
+
+Initially +true+ if command-line option <tt>-d</tt> or <tt>--debug</tt> is given,
+otherwise initially +false+;
+may be set to either value in the running program.
+
+When +true+, prints each raised exception to <tt>$stderr</tt>.
+
+Aliased as <tt>$-d</tt>.
+
+=== <tt>$VERBOSE</tt>
+
+Initially +true+ if command-line option <tt>-v</tt> or <tt>-w</tt> is given,
+otherwise initially +false+;
+may be set to either value, or to +nil+, in the running program.
+
+When +true+, enables Ruby warnings.
+
+When +nil+, disables warnings, including those from Kernel#warn.
+
+Aliased as <tt>$-v</tt> and <tt>$-w</tt>.
+
+== Other Variables
+
+=== <tt>$-a</tt>
+
+Whether command-line option <tt>-a</tt> was given; read-only.
+
+=== <tt>$-i</tt>
+
+Contains the extension given with command-line option <tt>-i</tt>,
+or +nil+ if none.
+
+An alias of ARGF.inplace_mode.
+
+=== <tt>$-l</tt>
+
+Whether command-line option <tt>-l</tt> was set; read-only.
+
+=== <tt>$-p</tt>
+
+Whether command-line option <tt>-p</tt> was given; read-only.
+
+== Deprecated
+
+=== <tt>$=</tt>
+
+=== <tt>$,</tt>
+
+= Pre-Defined Global Constants
+
+= Streams
+
+=== <tt>STDIN</tt>
+
+The standard input stream (the default value for <tt>$stdin</tt>):
+
+ STDIN # => #<IO:<STDIN>>
+
+=== <tt>STDOUT</tt>
+
+The standard output stream (the default value for <tt>$stdout</tt>):
+
+ STDOUT # => #<IO:<STDOUT>>
+
+=== <tt>STDERR</tt>
+
+The standard error stream (the default value for <tt>$stderr</tt>):
+
+ STDERR # => #<IO:<STDERR>>
+
+== Environment
+
+=== ENV
+
+A hash of the contains current environment variables names and values:
+
+ ENV.take(5)
+ # =>
+ [["COLORTERM", "truecolor"],
+ ["DBUS_SESSION_BUS_ADDRESS", "unix:path=/run/user/1000/bus"],
+ ["DESKTOP_SESSION", "ubuntu"],
+ ["DISPLAY", ":0"],
+ ["GDMSESSION", "ubuntu"]]
+
+=== ARGF
+
+The virtual concatenation of the files given on the command line, or from
+<tt>$stdin</tt> if no files were given, <tt>"-"</tt> is given, or after
+all files have been read.
+
+=== <tt>ARGV</tt>
+
+An array of the given command-line arguments.
+
+=== <tt>TOPLEVEL_BINDING</tt>
+
+The Binding of the top level scope:
+
+ TOPLEVEL_BINDING # => #<Binding:0x00007f58da0da7c0>
+
+=== <tt>RUBY_VERSION</tt>
+
+The Ruby version:
+
+ RUBY_VERSION # => "3.2.2"
+
+=== <tt>RUBY_RELEASE_DATE</tt>
+
+The release date string:
+
+ RUBY_RELEASE_DATE # => "2023-03-30"
+
+=== <tt>RUBY_PLATFORM</tt>
+
+The platform identifier:
+
+ RUBY_PLATFORM # => "x86_64-linux"
+
+=== <tt>RUBY_PATCHLEVEL</tt>
+
+The integer patch level for this Ruby:
+
+ RUBY_PATCHLEVEL # => 53
+
+For a development build the patch level will be -1.
+
+=== <tt>RUBY_REVISION</tt>
+
+The git commit hash for this Ruby:
+
+ RUBY_REVISION # => "e51014f9c05aa65cbf203442d37fef7c12390015"
+
+=== <tt>RUBY_COPYRIGHT</tt>
+
+The copyright string:
+
+ RUBY_COPYRIGHT
+ # => "ruby - Copyright (C) 1993-2023 Yukihiro Matsumoto"
+
+=== <tt>RUBY_ENGINE</tt>
+
+The name of the Ruby implementation:
+
+ RUBY_ENGINE # => "ruby"
+
+=== <tt>RUBY_ENGINE_VERSION</tt>
+
+The version of the Ruby implementation:
+
+ RUBY_ENGINE_VERSION # => "3.2.2"
+
+=== <tt>RUBY_DESCRIPTION</tt>
+
+The description of the Ruby implementation:
+
+ RUBY_DESCRIPTION
+ # => "ruby 3.2.2 (2023-03-30 revision e51014f9c0) [x86_64-linux]"
+
+== Embedded \Data
+
+=== <tt>DATA</tt>
+
+Defined if and only if the program has this line:
+
+ __END__
+
+When defined, <tt>DATA</tt> is a File object
+containing the lines following the <tt>__END__</tt>,
+positioned at the first of those lines:
+
+ p DATA
+ DATA.each_line { |line| p line }
+ __END__
+ Foo
+ Bar
+ Baz
+
+Output:
+
+ #<File:t.rb>
+ "Foo\n"
+ "Bar\n"
+ "Baz\n"
diff --git a/doc/implicit_conversion.rdoc b/doc/implicit_conversion.rdoc
index ba15fa4bf4..e244096125 100644
--- a/doc/implicit_conversion.rdoc
+++ b/doc/implicit_conversion.rdoc
@@ -1,4 +1,4 @@
-== Implicit Conversions
+= Implicit Conversions
Some Ruby methods accept one or more objects
that can be either:
@@ -15,7 +15,7 @@ a specific conversion method:
* Integer: +to_int+
* String: +to_str+
-=== Array-Convertible Objects
+== Array-Convertible Objects
An <i>Array-convertible object</i> is an object that:
@@ -69,7 +69,7 @@ This class is not Array-convertible (method +to_ary+ returns non-Array):
# Raises TypeError (can't convert NotArrayConvertible to Array (NotArrayConvertible#to_ary gives Symbol))
a.replace(NotArrayConvertible.new)
-=== Hash-Convertible Objects
+== Hash-Convertible Objects
A <i>Hash-convertible object</i> is an object that:
@@ -123,7 +123,7 @@ This class is not Hash-convertible (method +to_hash+ returns non-Hash):
# Raises TypeError (can't convert NotHashConvertible to Hash (ToHashReturnsNonHash#to_hash gives Symbol))
h.merge(NotHashConvertible.new)
-=== Integer-Convertible Objects
+== Integer-Convertible Objects
An <i>Integer-convertible object</i> is an object that:
@@ -171,7 +171,7 @@ This class is not Integer-convertible (method +to_int+ returns non-Integer):
# Raises TypeError (can't convert NotIntegerConvertible to Integer (NotIntegerConvertible#to_int gives Symbol))
Array.new(NotIntegerConvertible.new)
-=== String-Convertible Objects
+== String-Convertible Objects
A <i>String-convertible object</i> is an object that:
* Has instance method +to_str+.
diff --git a/doc/irb/indexes.md b/doc/irb/indexes.md
new file mode 100644
index 0000000000..9659db8c0b
--- /dev/null
+++ b/doc/irb/indexes.md
@@ -0,0 +1,192 @@
+## Indexes
+
+### Index of Command-Line Options
+
+These are the \IRB command-line options, with links to explanatory text:
+
+- `-d`: Set `$DEBUG` and {$VERBOSE}[rdoc-ref:IRB@Verbosity]
+ to `true`.
+- `-E _ex_[:_in_]`: Set initial external (ex) and internal (in)
+ {encodings}[rdoc-ref:IRB@Encodings] (same as `ruby -E>`).
+- `-f`: Don't initialize from {configuration file}[rdoc-ref:IRB@Configuration+File].
+- `-I _dirpath_`: Specify {$LOAD_PATH directory}[rdoc-ref:IRB@Load+Modules]
+ (same as `ruby -I`).
+- `-r _load-module_`: Require {load-module}[rdoc-ref:IRB@Load+Modules]
+ (same as `ruby -r`).
+- `-U`: Set external and internal {encodings}[rdoc-ref:IRB@Encodings] to UTF-8.
+- `-w`: Suppress {warnings}[rdoc-ref:IRB@Warnings] (same as `ruby -w`).
+- `-W[_level_]`: Set {warning level}[rdoc-ref:IRB@Warnings];
+ 0=silence, 1=medium, 2=verbose (same as `ruby -W`).
+- `--autocomplete`: Use {auto-completion}[rdoc-ref:IRB@Automatic+Completion].
+- `--back-trace-limit _n_`: Set a {backtrace limit}[rdoc-ref:IRB@Tracer];
+ display at most the top `n` and bottom `n` entries.
+- `--colorize`: Use {color-highlighting}[rdoc-ref:IRB@Color+Highlighting]
+ for input and output.
+- `--context-mode _n_`: Select method to create Binding object
+ for new {workspace}[rdoc-ref:IRB@Commands]; `n` in range `0..4`.
+- `--echo`: Print ({echo}[rdoc-ref:IRB@Return-Value+Printing+-28Echoing-29])
+ return values.
+- `--extra-doc-dir _dirpath_`:
+ Add a {documentation directory}[rdoc-ref:IRB@RI+Documentation+Directories]
+ for the documentation dialog.
+- `--inf-ruby-mode`: Set prompt mode to {:INF_RUBY}[rdoc-ref:IRB@Pre-Defined+Prompts]
+ (appropriate for `inf-ruby-mode` on Emacs);
+ suppresses --multiline and --singleline.
+- `--inspect`: Use method `inspect` for printing ({echoing}[rdoc-ref:IRB@Return-Value+Printing+-28Echoing-29])
+ return values.
+- `--multiline`: Use the multiline editor as the {input method}[rdoc-ref:IRB@Input+Method].
+- `--noautocomplete`: Don't use {auto-completion}[rdoc-ref:IRB@Automatic+Completion].
+- `--nocolorize`: Don't use {color-highlighting}[rdoc-ref:IRB@Color+Highlighting]
+ for input and output.
+- `--noecho`: Don't print ({echo}[rdoc-ref:IRB@Return-Value+Printing+-28Echoing-29])
+ return values.
+- `--noecho-on-assignment`: Don't print ({echo}[rdoc-ref:IRB@Return-Value+Printing+-28Echoing-29])
+ result on assignment.
+- `--noinspect`: Don't se method `inspect` for printing ({echoing}[rdoc-ref:IRB@Return-Value+Printing+-28Echoing-29])
+ return values.
+- `--nomultiline`: Don't use the multiline editor as the {input method}[rdoc-ref:IRB@Input+Method].
+- `--noprompt`: Don't print {prompts}[rdoc-ref:IRB@Prompt+and+Return+Formats].
+- `--noscript`: Treat the first command-line argument as a normal
+ {command-line argument}[rdoc-ref:IRB@Initialization+Script],
+ and include it in `ARGV`.
+- `--nosingleline`: Don't use the singleline editor as the {input method}[rdoc-ref:IRB@Input+Method].
+- `--noverbose`Don't print {verbose}[rdoc-ref:IRB@Verbosity] details.
+- `--prompt _mode_`, `--prompt-mode _mode_`:
+ Set {prompt and return formats}[rdoc-ref:IRB@Prompt+and+Return+Formats];
+ `mode` may be a {pre-defined prompt}[rdoc-ref:IRB@Pre-Defined+Prompts]
+ or the name of a {custom prompt}[rdoc-ref:IRB@Custom+Prompts].
+- `--script`: Treat the first command-line argument as the path to an
+ {initialization script}[rdoc-ref:IRB@Initialization+Script],
+ and omit it from `ARGV`.
+- `--simple-prompt`, `--sample-book-mode`:
+ Set prompt mode to {:SIMPLE}[rdoc-ref:IRB@Pre-Defined+Prompts].
+- `--singleline`: Use the singleline editor as the {input method}[rdoc-ref:IRB@Input+Method].
+- `--tracer`: Use {Tracer}[rdoc-ref:IRB@Tracer] to print a stack trace for each input command.
+- `--truncate-echo-on-assignment`: Print ({echo}[rdoc-ref:IRB@Return-Value+Printing+-28Echoing-29])
+ truncated result on assignment.
+- `--verbose`Print {verbose}[rdoc-ref:IRB@Verbosity] details.
+- `-v`, `--version`: Print the {IRB version}[rdoc-ref:IRB@Version].
+- `-h`, `--help`: Print the {IRB help text}[rdoc-ref:IRB@Help].
+- `--`: Separate options from {arguments}[rdoc-ref:IRB@Command-Line+Arguments]
+ on the command-line.
+
+### Index of \IRB.conf Entries
+
+These are the keys for hash \IRB.conf entries, with links to explanatory text;
+for each entry that is pre-defined, the initial value is given:
+
+- `:AP_NAME`: \IRB {application name}[rdoc-ref:IRB@Application+Name];
+ initial value: `'irb'`.
+- `:AT_EXIT`: Array of hooks to call
+ {at exit}[rdoc-ref:IRB@IRB];
+ initial value: `[]`.
+- `:AUTO_INDENT`: Whether {automatic indentation}[rdoc-ref:IRB@Automatic+Indentation]
+ is enabled; initial value: `true`.
+- `:BACK_TRACE_LIMIT`: Sets the {back trace limit}[rdoc-ref:IRB@Tracer];
+ initial value: `16`.
+- `:COMMAND_ALIASES`: Defines input {command aliases}[rdoc-ref:IRB@Command+Aliases];
+ initial value:
+
+ {
+ "$": :show_source,
+ "@": :whereami,
+ }
+
+- `:CONTEXT_MODE`: Sets the {context mode}[rdoc-ref:IRB@Context+Mode],
+ the type of binding to be used when evaluating statements;
+ initial value: `4`.
+- `:ECHO`: Whether to print ({echo}[rdoc-ref:IRB@Return-Value+Printing+-28Echoing-29])
+ return values;
+ initial value: `nil`, which would set `conf.echo` to `true`.
+- `:ECHO_ON_ASSIGNMENT`: Whether to print ({echo}[rdoc-ref:IRB@Return-Value+Printing+-28Echoing-29])
+ return values on assignment;
+ initial value: `nil`, which would set `conf.echo_on_assignment` to `:truncate`.
+- `:EVAL_HISTORY`: How much {evaluation history}[rdoc-ref:IRB@Evaluation+History]
+ is to be stored; initial value: `nil`.
+- `:EXTRA_DOC_DIRS`: \Array of
+ {RI documentation directories}[rdoc-ref:IRB@RI+Documentation+Directories]
+ to be parsed for the documentation dialog;
+ initial value: `[]`.
+- `:IGNORE_EOF`: Whether to ignore {end-of-file}[rdoc-ref:IRB@End-of-File];
+ initial value: `false`.
+- `:IGNORE_SIGINT`: Whether to ignore {SIGINT}[rdoc-ref:IRB@SIGINT];
+ initial value: `true`.
+- `:INSPECT_MODE`: Whether to use method `inspect` for printing
+ ({echoing}[rdoc-ref:IRB@Return-Value+Printing+-28Echoing-29]) return values;
+ initial value: `true`.
+- `:IRB_LIB_PATH`: The path to the {IRB library directory}[rdoc-ref:IRB@IRB+Library+Directory]; initial value:
+
+ - `"<i>RUBY_DIR</i>/lib/ruby/gems/<i>RUBY_VER_NUM</i>/gems/irb-<i>IRB_VER_NUM</i>/lib/irb"`,
+
+ where:
+
+ - <i>RUBY_DIR</i> is the Ruby installation dirpath.
+ - <i>RUBY_VER_NUM</i> is the Ruby version number.
+ - <i>IRB_VER_NUM</i> is the \IRB version number.
+
+- `:IRB_NAME`: {IRB name}[rdoc-ref:IRB@IRB+Name];
+ initial value: `'irb'`.
+- `:IRB_RC`: {Configuration monitor}[rdoc-ref:IRB@Configuration+Monitor];
+ initial value: `nil`.
+- `:LC_MESSAGES`: {Locale}[rdoc-ref:IRB@Locale];
+ initial value: IRB::Locale object.
+- `:LOAD_MODULES`: deprecated.
+- `:MAIN_CONTEXT`: The {context}[rdoc-ref:IRB@Session+Context] for the main \IRB session;
+ initial value: IRB::Context object.
+- `:MEASURE`: Whether to
+ {measure performance}[rdoc-ref:IRB@Performance+Measurement];
+ initial value: `false`.
+- `:MEASURE_CALLBACKS`: Callback methods for
+ {performance measurement}[rdoc-ref:IRB@Performance+Measurement];
+ initial value: `[]`.
+- `:MEASURE_PROC`: Procs for
+ {performance measurement}[rdoc-ref:IRB@Performance+Measurement];
+ initial value:
+
+ {
+ :TIME=>#<Proc:0x0000556e271c6598 /var/lib/gems/3.0.0/gems/irb-1.8.3/lib/irb/init.rb:106>,
+ :STACKPROF=>#<Proc:0x0000556e271c6548 /var/lib/gems/3.0.0/gems/irb-1.8.3/lib/irb/init.rb:116>
+ }
+
+- `:PROMPT`: \Hash of {defined prompts}[rdoc-ref:IRB@Prompt+and+Return+Formats];
+ initial value:
+
+ {
+ :NULL=>{:PROMPT_I=>nil, :PROMPT_S=>nil, :PROMPT_C=>nil, :RETURN=>"%s\n"},
+ :DEFAULT=>{:PROMPT_I=>"%N(%m):%03n> ", :PROMPT_S=>"%N(%m):%03n%l ", :PROMPT_C=>"%N(%m):%03n* ", :RETURN=>"=> %s\n"},
+ :CLASSIC=>{:PROMPT_I=>"%N(%m):%03n:%i> ", :PROMPT_S=>"%N(%m):%03n:%i%l ", :PROMPT_C=>"%N(%m):%03n:%i* ", :RETURN=>"%s\n"},
+ :SIMPLE=>{:PROMPT_I=>">> ", :PROMPT_S=>"%l> ", :PROMPT_C=>"?> ", :RETURN=>"=> %s\n"},
+ :INF_RUBY=>{:PROMPT_I=>"%N(%m):%03n> ", :PROMPT_S=>nil, :PROMPT_C=>nil, :RETURN=>"%s\n", :AUTO_INDENT=>true},
+ :XMP=>{:PROMPT_I=>nil, :PROMPT_S=>nil, :PROMPT_C=>nil, :RETURN=>" ==>%s\n"}
+ }
+
+- `:PROMPT_MODE`: Name of {current prompt}[rdoc-ref:IRB@Prompt+and+Return+Formats];
+ initial value: `:DEFAULT`.
+- `:RC`: Whether a {configuration file}[rdoc-ref:IRB@Configuration+File]
+ was found and interpreted;
+ initial value: `true` if a configuration file was found, `false` otherwise.
+- `:RC_NAME_GENERATOR`: \Proc to generate paths of potential
+ {configuration files}[rdoc-ref:IRB@Configuration+File];
+ initial value: `=> #<Proc:0x000055f9bebfed80 /var/lib/gems/3.0.0/gems/irb-1.8.3/lib/irb/init.rb:401>`.
+- `:SAVE_HISTORY`: Number of commands to save in
+ {input command history}[rdoc-ref:IRB@Input+Command+History];
+ initial value: `1000`.
+- `:SINGLE_IRB`: Whether command-line option `--single-irb` was given;
+ initial value: `true` if the option was given, `false` otherwise.
+ See {Single-IRB Mode}[rdoc-ref:IRB@Single-IRB+Mode].
+- `:USE_AUTOCOMPLETE`: Whether to use
+ {automatic completion}[rdoc-ref:IRB@Automatic+Completion];
+ initial value: `true`.
+- `:USE_COLORIZE`: Whether to use
+ {color highlighting}[rdoc-ref:IRB@Color+Highlighting];
+ initial value: `true`.
+- `:USE_LOADER`: Whether to use the
+ {IRB loader}[rdoc-ref:IRB@IRB+Loader] for `require` and `load`;
+ initial value: `false`.
+- `:USE_TRACER`: Whether to use the
+ {IRB tracer}[rdoc-ref:IRB@Tracer];
+ initial value: `false`.
+- `:VERBOSE`: Whether to print {verbose output}[rdoc-ref:IRB@Verbosity];
+ initial value: `nil`.
+- `:__MAIN__`: The main \IRB object;
+ initial value: `main`.
diff --git a/doc/irb/irb.rd.ja b/doc/irb/irb.rd.ja
index 633c08cbd4..c51e0bd60d 100644
--- a/doc/irb/irb.rd.ja
+++ b/doc/irb/irb.rd.ja
@@ -125,7 +125,6 @@ irb起動時に``~/.irbrc''を読み込みます. もし存在しない場合は
IRB.conf[:PROMPT][:MY_PROMPT] = { # プロンプトモードの名前
:PROMPT_I => nil, # 通常のプロンプト
- :PROMPT_N => nil, # 継続行のプロンプト
:PROMPT_S => nil, # 文字列などの継続行のプロンプト
:PROMPT_C => nil, # 式が継続している時のプロンプト
:RETURN => " ==>%s\n" # リターン時のプロンプト
@@ -140,7 +139,7 @@ OKです.
IRB.conf[:PROMPT_MODE] = :MY_PROMPT
-PROMPT_I, PROMPT_N, PROMPT_S, PROMPT_Cは, フォーマットを指定します.
+PROMPT_I, PROMPT_S, PROMPT_Cは, フォーマットを指定します.
%N 起動しているコマンド名が出力される.
%m mainオブジェクト(self)がto_sで出力される.
@@ -155,7 +154,6 @@ PROMPT_I, PROMPT_N, PROMPT_S, PROMPT_Cは, フォーマットを指定します.
IRB.conf[:PROMPT][:DEFAULT] = {
:PROMPT_I => "%N(%m):%03n:%i> ",
- :PROMPT_N => "%N(%m):%03n:%i> ",
:PROMPT_S => "%N(%m):%03n:%i%l ",
:PROMPT_C => "%N(%m):%03n:%i* ",
:RETURN => "=> %s\n"
diff --git a/doc/keywords.rdoc b/doc/keywords.rdoc
index cb1cff33f0..7c368205ef 100644
--- a/doc/keywords.rdoc
+++ b/doc/keywords.rdoc
@@ -1,4 +1,4 @@
-== Keywords
+= Keywords
The following keywords are used by Ruby.
diff --git a/doc/maintainers.md b/doc/maintainers.md
new file mode 100644
index 0000000000..631371e178
--- /dev/null
+++ b/doc/maintainers.md
@@ -0,0 +1,520 @@
+# Maintainers
+This page describes the current module, library, and extension maintainers of Ruby.
+
+## Module Maintainers
+A module maintainer is responsible for a certain part of Ruby.
+
+* The maintainer fixes bugs of the part. Particularly, they should fix
+ security vulnerabilities as soon as possible.
+* They handle issues related the module on the Redmine or ML.
+* They may be discharged by the 3 months rule [[ruby-core:25764]](https://blade.ruby-lang.org/ruby-core/25764).
+* They have commit right to Ruby's repository to modify their part in the
+ repository.
+* They have "developer" role on the Redmine to modify issues.
+* They have authority to decide the feature of their part. But they should
+ always respect discussions on ruby-core/ruby-dev.
+
+A submaintainer of a module is like a maintainer. But the submaintainer does
+not have authority to change/add a feature on his/her part. They need
+consensus on ruby-core/ruby-dev before changing/adding. Some of submaintainers
+have commit right, others don't.
+
+### Language core features including security
+* Yukihiro Matsumoto (matz)
+
+### Evaluator
+* Koichi Sasada (ko1)
+
+### Core classes
+* Yukihiro Matsumoto (matz)
+
+## Standard Library Maintainers
+### Libraries
+#### lib/mkmf.rb
+* *unmaintained*
+
+#### lib/rubygems.rb, lib/rubygems/*
+* Eric Hodel (drbrain)
+* Hiroshi SHIBATA (hsbt)
+* https://github.com/rubygems/rubygems
+
+#### lib/unicode_normalize.rb, lib/unicode_normalize/*
+* Martin J. Dürst
+
+### Extensions
+#### ext/continuation
+* Koichi Sasada (ko1)
+
+#### ext/coverage
+* Yusuke Endoh (mame)
+
+#### ext/fiber
+* Koichi Sasada (ko1)
+
+#### ext/monitor
+* Koichi Sasada (ko1)
+
+#### ext/objspace
+* *unmaintained*
+
+#### ext/pty
+* *unmaintained*
+
+#### ext/ripper
+* *unmaintained*
+
+#### ext/socket
+* Tanaka Akira (akr)
+* API change needs matz's approval
+
+#### ext/win32
+* NAKAMURA Usaku (usa)
+
+## Default gems Maintainers
+### Libraries
+#### lib/abbrev.rb
+* Akinori MUSHA (knu)
+* https://github.com/ruby/abbrev
+* https://rubygems.org/gems/abbrev
+
+#### lib/base64.rb
+* Yusuke Endoh (mame)
+* https://github.com/ruby/base64
+* https://rubygems.org/gems/base64
+
+#### lib/benchmark.rb
+* *unmaintained*
+* https://github.com/ruby/benchmark
+* https://rubygems.org/gems/benchmark
+
+#### lib/bundler.rb, lib/bundler/*
+* Hiroshi SHIBATA (hsbt)
+* https://github.com/rubygems/rubygems
+* https://rubygems.org/gems/bundler
+
+#### lib/cgi.rb, lib/cgi/*
+* *unmaintained*
+* https://github.com/ruby/cgi
+* https://rubygems.org/gems/cgi
+
+#### lib/csv.rb
+* Kenta Murata (mrkn)
+* Kouhei Sutou (kou)
+* https://github.com/ruby/csv
+* https://rubygems.org/gems/csv
+
+#### lib/English.rb
+* *unmaintained*
+* https://github.com/ruby/English
+* https://rubygems.org/gems/English
+
+#### lib/delegate.rb
+* *unmaintained*
+* https://github.com/ruby/delegate
+* https://rubygems.org/gems/delegate
+
+#### lib/did_you_mean.rb
+* Yuki Nishijima (yuki24)
+* https://github.com/ruby/did_you_mean
+* https://rubygems.org/gems/did_you_mean
+
+#### ext/digest, ext/digest/*
+* Akinori MUSHA (knu)
+* https://github.com/ruby/digest
+* https://rubygems.org/gems/digest
+
+#### lib/drb.rb, lib/drb/*
+* Masatoshi SEKI (seki)
+* https://github.com/ruby/drb
+* https://rubygems.org/gems/drb
+
+#### lib/erb.rb
+* Masatoshi SEKI (seki)
+* Takashi Kokubun (k0kubun)
+* https://github.com/ruby/erb
+* https://rubygems.org/gems/erb
+
+#### lib/error_highlight.rb, lib/error_highlight/*
+* Yusuke Endoh (mame)
+* https://github.com/ruby/error_highlight
+* https://rubygems.org/gems/error_highlight
+
+#### lib/fileutils.rb
+* *unmaintained*
+* https://github.com/ruby/fileutils
+* https://rubygems.org/gems/fileutils
+
+#### lib/find.rb
+* Kazuki Tsujimoto (ktsj)
+* https://github.com/ruby/find
+* https://rubygems.org/gems/find
+
+#### lib/forwardable.rb
+* Keiju ISHITSUKA (keiju)
+* https://github.com/ruby/forwardable
+* https://rubygems.org/gems/forwardable
+
+#### lib/getoptlong.rb
+* *unmaintained*
+* https://github.com/ruby/getoptlong
+* https://rubygems.org/gems/getoptlong
+
+#### lib/ipaddr.rb
+* Akinori MUSHA (knu)
+* https://github.com/ruby/ipaddr
+* https://rubygems.org/gems/ipaddr
+
+#### lib/irb.rb, lib/irb/*
+* Stan Lo (st0012)
+* Tomoya Ishida (tompng)
+* Mari Imaizumi (ima1zumi)
+* Hitoshi Hasumi (hasumikin)
+* https://github.com/ruby/irb
+* https://rubygems.org/gems/irb
+
+#### lib/optparse.rb, lib/optparse/*
+* Nobuyuki Nakada (nobu)
+* https://github.com/ruby/optparse
+
+#### lib/logger.rb
+* Naotoshi Seo (sonots)
+* https://github.com/ruby/logger
+* https://rubygems.org/gems/logger
+
+#### lib/mutex_m.rb
+* Keiju ISHITSUKA (keiju)
+* https://github.com/ruby/mutex_m
+* https://rubygems.org/gems/mutex_m
+
+#### lib/net/http.rb, lib/net/https.rb
+* NARUSE, Yui (naruse)
+* https://github.com/ruby/net-http
+* https://rubygems.org/gems/net-http
+
+#### lib/net/protocol.rb
+* *unmaintained*
+* https://github.com/ruby/net-protocol
+* https://rubygems.org/gems/net-protocol
+
+#### lib/observer.rb
+* *unmaintained*
+* https://github.com/ruby/observer
+* https://rubygems.org/gems/observer
+
+#### lib/open3.rb
+* *unmaintained*
+* https://github.com/ruby/open3
+* https://rubygems.org/gems/open3
+
+#### lib/open-uri.rb
+* Tanaka Akira (akr)
+* https://github.com/ruby/open-uri
+
+#### lib/ostruct.rb
+* Marc-André Lafortune (marcandre)
+* https://github.com/ruby/ostruct
+* https://rubygems.org/gems/ostruct
+
+#### lib/pp.rb
+* Tanaka Akira (akr)
+* https://github.com/ruby/pp
+* https://rubygems.org/gems/pp
+
+#### lib/prettyprint.rb
+* Tanaka Akira (akr)
+* https://github.com/ruby/prettyprint
+* https://rubygems.org/gems/prettyprint
+
+#### lib/prism.rb
+* Kevin Newton (kddnewton)
+* Jemma Issroff (jemmaissroff)
+* https://github.com/ruby/prism
+* https://rubygems.org/gems/prism
+
+#### lib/pstore.rb
+* *unmaintained*
+* https://github.com/ruby/pstore
+* https://rubygems.org/gems/pstore
+
+#### lib/readline.rb
+* aycabta
+* https://github.com/ruby/readline
+* https://rubygems.org/gems/readline
+
+#### lib/resolv.rb
+* Tanaka Akira (akr)
+* https://github.com/ruby/resolv
+* https://rubygems.org/gems/resolv
+
+#### lib/resolv-replace.rb
+* Tanaka Akira (akr)
+* https://github.com/ruby/resolv-replace
+* https://rubygems.org/gems/resolv-replace
+
+#### lib/rdoc.rb, lib/rdoc/*
+* Eric Hodel (drbrain)
+* Hiroshi SHIBATA (hsbt)
+* https://github.com/ruby/rdoc
+* https://rubygems.org/gems/rdoc
+
+#### lib/reline.rb, lib/reline/*
+* Tomoya Ishida (tompng)
+* Mari Imaizumi (ima1zumi)
+* Stan Lo (st0012)
+* Hitoshi Hasumi (hasumikin)
+* https://github.com/ruby/reline
+* https://rubygems.org/gems/reline
+
+#### lib/rinda/*
+* Masatoshi SEKI (seki)
+* https://github.com/ruby/rinda
+* https://rubygems.org/gems/rinda
+
+#### lib/securerandom.rb
+* Tanaka Akira (akr)
+* https://github.com/ruby/securerandom
+* https://rubygems.org/gems/securerandom
+
+#### lib/set.rb
+* Akinori MUSHA (knu)
+* https://github.com/ruby/set
+* https://rubygems.org/gems/set
+
+#### lib/shellwords.rb
+* Akinori MUSHA (knu)
+* https://github.com/ruby/shellwords
+* https://rubygems.org/gems/shellwords
+
+#### lib/singleton.rb
+* Yukihiro Matsumoto (matz)
+* https://github.com/ruby/singleton
+* https://rubygems.org/gems/singleton
+
+#### lib/tempfile.rb
+* *unmaintained*
+* https://github.com/ruby/tempfile
+* https://rubygems.org/gems/tempfile
+
+#### lib/time.rb
+* Tanaka Akira (akr)
+* https://github.com/ruby/time
+* https://rubygems.org/gems/time
+
+#### lib/timeout.rb
+* Yukihiro Matsumoto (matz)
+* https://github.com/ruby/timeout
+* https://rubygems.org/gems/timeout
+
+#### lib/thwait.rb
+* Keiju ISHITSUKA (keiju)
+* https://github.com/ruby/thwait
+* https://rubygems.org/gems/thwait
+
+#### lib/tmpdir.rb
+* *unmaintained*
+* https://github.com/ruby/tmpdir
+* https://rubygems.org/gems/tmpdir
+
+#### lib/tsort.rb
+* Tanaka Akira (akr)
+* https://github.com/ruby/tsort
+* https://rubygems.org/gems/tsort
+
+#### lib/un.rb
+* WATANABE Hirofumi (eban)
+* https://github.com/ruby/un
+* https://rubygems.org/gems/un
+
+#### lib/uri.rb, lib/uri/*
+* NARUSE, Yui (naruse)
+* https://github.com/ruby/uri
+* https://rubygems.org/gems/uri
+
+#### lib/yaml.rb, lib/yaml/*
+* Aaron Patterson (tenderlove)
+* Hiroshi SHIBATA (hsbt)
+* https://github.com/ruby/yaml
+* https://rubygems.org/gems/yaml
+
+#### lib/weakref.rb
+* *unmaintained*
+* https://github.com/ruby/weakref
+* https://rubygems.org/gems/weakref
+
+### Extensions
+#### ext/bigdecimal
+* Kenta Murata (mrkn) https://github.com/ruby/bigdecimal
+* https://rubygems.org/gems/bigdecimal
+
+#### ext/cgi
+* Nobuyoshi Nakada (nobu)
+* https://github.com/ruby/cgi
+* https://rubygems.org/gems/cgi
+
+#### ext/date
+* *unmaintained*
+* https://github.com/ruby/date
+* https://rubygems.org/gems/date
+
+#### ext/etc
+* *unmaintained*
+* https://github.com/ruby/etc
+* https://rubygems.org/gems/etc
+
+#### ext/fcntl
+* *unmaintained*
+* https://github.com/ruby/fcntl
+* https://rubygems.org/gems/fcntl
+
+#### ext/fiddle
+* Aaron Patterson (tenderlove)
+* https://github.com/ruby/fiddle
+* https://rubygems.org/gems/fiddle
+
+#### ext/io/console
+* Nobuyuki Nakada (nobu)
+* https://github.com/ruby/io-console
+* https://rubygems.org/gems/io-console
+
+#### ext/io/nonblock
+* Nobuyuki Nakada (nobu)
+* https://github.com/ruby/io-nonblock
+* https://rubygems.org/gems/io-nonblock
+
+#### ext/io/wait
+* Nobuyuki Nakada (nobu)
+* https://github.com/ruby/io-wait
+* https://rubygems.org/gems/io-wait
+
+#### ext/json
+* NARUSE, Yui (naruse)
+* Hiroshi SHIBATA (hsbt)
+* https://github.com/flori/json
+* https://rubygems.org/gems/json
+
+#### ext/nkf
+* NARUSE, Yui (naruse)
+* https://github.com/ruby/nkf
+* https://rubygems.org/gems/nkf
+
+#### ext/openssl
+* Kazuki Yamaguchi (rhe)
+* https://github.com/ruby/openssl
+* https://rubygems.org/gems/openssl
+
+#### ext/pathname
+* Tanaka Akira (akr)
+* https://github.com/ruby/pathname
+* https://rubygems.org/gems/pathname
+
+#### ext/psych
+* Aaron Patterson (tenderlove)
+* Hiroshi SHIBATA (hsbt)
+* https://github.com/ruby/psych
+* https://rubygems.org/gems/psych
+
+#### ext/stringio
+* Nobuyuki Nakada (nobu)
+* https://github.com/ruby/stringio
+* https://rubygems.org/gems/stringio
+
+#### ext/strscan
+* Kouhei Sutou (kou)
+* https://github.com/ruby/strscan
+* https://rubygems.org/gems/strscan
+
+#### ext/syslog
+* Akinori MUSHA (knu)
+* https://github.com/ruby/syslog
+* https://rubygems.org/gems/syslog
+
+#### ext/win32ole
+* Masaki Suketa (suke)
+* https://github.com/ruby/win32ole
+* https://rubygems.org/gems/win32ole
+
+#### ext/zlib
+* NARUSE, Yui (naruse)
+* https://github.com/ruby/zlib
+* https://rubygems.org/gems/zlib
+
+## Bundled gems upstream repositories
+### minitest
+* https://github.com/seattlerb/minitest
+
+### power_assert
+* https://github.com/ruby/power_assert
+
+### rake
+* https://github.com/ruby/rake
+
+### test-unit
+* https://github.com/test-unit/test-unit
+
+### rexml
+* https://github.com/ruby/rexml
+
+### rss
+* https://github.com/ruby/rss
+
+### net-ftp
+* https://github.com/ruby/net-ftp
+
+### net-imap
+* https://github.com/ruby/net-imap
+
+### net-pop
+* https://github.com/ruby/net-pop
+
+### net-smtp
+* https://github.com/ruby/net-smtp
+
+### matrix
+* https://github.com/ruby/matrix
+
+### prime
+* https://github.com/ruby/prime
+
+### rbs
+* https://github.com/ruby/rbs
+
+### typeprof
+* https://github.com/ruby/typeprof
+
+### debug
+* https://github.com/ruby/debug
+
+### racc
+* https://github.com/ruby/racc
+
+
+## Platform Maintainers
+### mswin64 (Microsoft Windows)
+* NAKAMURA Usaku (usa)
+
+### mingw32 (Minimalist GNU for Windows)
+* Nobuyoshi Nakada (nobu)
+
+### AIX
+* Yutaka Kanemoto (kanemoto)
+
+### FreeBSD
+* Akinori MUSHA (knu)
+
+### Solaris
+* Naohisa Goto (ngoto)
+
+### RHEL, CentOS
+* KOSAKI Motohiro (kosaki)
+
+### macOS
+* Kenta Murata (mrkn)
+
+### OpenBSD
+* Jeremy Evans (jeremyevans0)
+
+### cygwin, ...
+* none. (Maintainer WANTED)
+
+### WebAssembly/WASI
+* Yuta Saito (katei)
diff --git a/doc/maintainers.rdoc b/doc/maintainers.rdoc
deleted file mode 100644
index 7e0c35194f..0000000000
--- a/doc/maintainers.rdoc
+++ /dev/null
@@ -1,424 +0,0 @@
-= Maintainers
-
-This page describes the current module, library, and extension maintainers of Ruby.
-
-== Module Maintainers
-
-A module maintainer is responsible for a certain part of Ruby.
-
-* The maintainer fixes bugs of the part. Particularly, they should fix security vulnerabilities as soon as possible.
-* They handle issues related the module on the Redmine or ML.
-* They may be discharged by the 3 months rule [ruby-core:25764].
-* They have commit right to Ruby's repository to modify their part in the repository.
-* They have "developer" role on the Redmine to modify issues.
-* They have authority to decide the feature of their part. But they should always respect discussions on ruby-core/ruby-dev.
-
-A submaintainer of a module is like a maintainer. But the submaintainer does
-not have authority to change/add a feature on his/her part. They need consensus
-on ruby-core/ruby-dev before changing/adding. Some of submaintainers have
-commit right, others don't.
-
-=== Language core features including security
-
-Yukihiro Matsumoto (matz)
-
-=== Evaluator
-
-Koichi Sasada (ko1)
-
-=== Core classes
-
-Yukihiro Matsumoto (matz)
-
-== Standard Library Maintainers
-
-=== Libraries
-
-[lib/mkmf.rb]
- _unmaintained_
-[lib/rubygems.rb, lib/rubygems/*]
- Eric Hodel (drbrain), Hiroshi SHIBATA (hsbt)
- https://github.com/rubygems/rubygems
-[lib/unicode_normalize.rb, lib/unicode_normalize/*]
- Martin J. Dürst
-
-=== Extensions
-
-[ext/continuation]
- Koichi Sasada (ko1)
-[ext/coverage]
- Yusuke Endoh (mame)
-[ext/fiber]
- Koichi Sasada (ko1)
-[ext/monitor]
- Koichi Sasada (ko1)
-[ext/objspace]
- _unmaintained_
-[ext/pty]
- _unmaintained_
-[ext/ripper]
- _unmaintained_
-[ext/socket]
- * Tanaka Akira (akr)
- * API change needs matz's approval
-[ext/win32]
- NAKAMURA Usaku (usa)
-
-== Default gems Maintainers
-
-=== Libraries
-
-[lib/abbrev.rb]
- Akinori MUSHA (knu)
- https://github.com/ruby/abbrev
- https://rubygems.org/gems/abbrev
-[lib/base64.rb]
- Yusuke Endoh (mame)
- https://github.com/ruby/base64
- https://rubygems.org/gems/base64
-[lib/benchmark.rb]
- _unmaintained_
- https://github.com/ruby/benchmark
- https://rubygems.org/gems/benchmark
-[lib/bundler.rb, lib/bundler/*]
- Hiroshi SHIBATA (hsbt)
- https://github.com/rubygems/rubygems
- https://rubygems.org/gems/bundler
-[lib/cgi.rb, lib/cgi/*]
- _unmaintained_
- https://github.com/ruby/cgi
- https://rubygems.org/gems/cgi
-[lib/csv.rb]
- Kenta Murata (mrkn), Kouhei Sutou (kou)
- https://github.com/ruby/csv
- https://rubygems.org/gems/csv
-[lib/English.rb]
- _unmaintained_
- https://github.com/ruby/English
- https://rubygems.org/gems/English
-[lib/debug.rb]
- _unmaintained_
- https://github.com/ruby/debug
-[lib/delegate.rb]
- _unmaintained_
- https://github.com/ruby/delegate
- https://rubygems.org/gems/delegate
-[lib/did_you_mean.rb]
- Yuki Nishijima (yuki24)
- https://github.com/ruby/did_you_mean
- https://rubygems.org/gems/did_you_mean
-[ext/digest, ext/digest/*]
- Akinori MUSHA (knu)
- https://github.com/ruby/digest
- https://rubygems.org/gems/digest
-[lib/drb.rb, lib/drb/*]
- Masatoshi SEKI (seki)
- https://github.com/ruby/drb
- https://rubygems.org/gems/drb
-[lib/erb.rb]
- Masatoshi SEKI (seki), Takashi Kokubun (k0kubun)
- https://github.com/ruby/erb
- https://rubygems.org/gems/erb
-[lib/error_highlight.rb, lib/error_highlight/*]
- Yusuke Endoh (mame)
- https://github.com/ruby/error_highlight
- https://rubygems.org/gems/error_highlight
-[lib/fileutils.rb]
- _unmaintained_
- https://github.com/ruby/fileutils
- https://rubygems.org/gems/fileutils
-[lib/find.rb]
- Kazuki Tsujimoto (ktsj)
- https://github.com/ruby/find
- https://rubygems.org/gems/find
-[lib/forwardable.rb]
- Keiju ISHITSUKA (keiju)
- https://github.com/ruby/forwardable
- https://rubygems.org/gems/forwardable
-[lib/getoptlong.rb]
- _unmaintained_
- https://github.com/ruby/getoptlong
- https://rubygems.org/gems/getoptlong
-[lib/ipaddr.rb]
- Akinori MUSHA (knu)
- https://github.com/ruby/ipaddr
- https://rubygems.org/gems/ipaddr
-[lib/irb.rb, lib/irb/*]
- aycabta
- https://github.com/ruby/irb
- https://rubygems.org/gems/irb
-[lib/optparse.rb, lib/optparse/*]
- Nobuyuki Nakada (nobu)
- https://github.com/ruby/optparse
-[lib/logger.rb]
- Naotoshi Seo (sonots)
- https://github.com/ruby/logger
- https://rubygems.org/gems/logger
-[lib/mutex_m.rb]
- Keiju ISHITSUKA (keiju)
- https://github.com/ruby/mutex_m
- https://rubygems.org/gems/mutex_m
-[lib/net/http.rb, lib/net/https.rb]
- NARUSE, Yui (naruse)
- https://github.com/ruby/net-http
- https://rubygems.org/gems/net-http
-[lib/net/protocol.rb]
- _unmaintained_
- https://github.com/ruby/net-protocol
- https://rubygems.org/gems/net-protocol
-[lib/observer.rb]
- _unmaintained_
- https://github.com/ruby/observer
- https://rubygems.org/gems/observer
-[lib/open3.rb]
- _unmaintained_
- https://github.com/ruby/open3
- https://rubygems.org/gems/open3
-[lib/open-uri.rb]
- Tanaka Akira (akr)
- https://github.com/ruby/open-uri
-[lib/ostruct.rb]
- Marc-André Lafortune (marcandre)
- https://github.com/ruby/ostruct
- https://rubygems.org/gems/ostruct
-[lib/pp.rb]
- Tanaka Akira (akr)
- https://github.com/ruby/pp
- https://rubygems.org/gems/pp
-[lib/prettyprint.rb]
- Tanaka Akira (akr)
- https://github.com/ruby/prettyprint
- https://rubygems.org/gems/prettyprint
-[lib/pstore.rb]
- _unmaintained_
- https://github.com/ruby/pstore
- https://rubygems.org/gems/pstore
-[lib/racc.rb, lib/racc/*]
- Aaron Patterson (tenderlove), Hiroshi SHIBATA (hsbt)
- https://github.com/ruby/racc
- https://rubygems.org/gems/racc
-[lib/readline.rb]
- aycabta
- https://github.com/ruby/readline
- https://rubygems.org/gems/readline
-[lib/resolv.rb]
- Tanaka Akira (akr)
- https://github.com/ruby/resolv
- https://rubygems.org/gems/resolv
-[lib/resolv-replace.rb]
- Tanaka Akira (akr)
- https://github.com/ruby/resolv-replace
- https://rubygems.org/gems/resolv-replace
-[lib/rdoc.rb, lib/rdoc/*]
- Eric Hodel (drbrain), Hiroshi SHIBATA (hsbt)
- https://github.com/ruby/rdoc
- https://rubygems.org/gems/rdoc
-[lib/readline.rb]
- aycabta
- https://github.com/ruby/readline
- https://rubygems.org/gems/readline
-[lib/reline.rb, lib/reline/*]
- aycabta
- https://github.com/ruby/reline
- https://rubygems.org/gems/reline
-[lib/rinda/*]
- Masatoshi SEKI (seki)
- https://github.com/ruby/rinda
- https://rubygems.org/gems/rinda
-[lib/securerandom.rb]
- Tanaka Akira (akr)
- https://github.com/ruby/securerandom
- https://rubygems.org/gems/securerandom
-[lib/set.rb]
- Akinori MUSHA (knu)
- https://github.com/ruby/set
- https://rubygems.org/gems/set
-[lib/shellwords.rb]
- Akinori MUSHA (knu)
- https://github.com/ruby/shellwords
- https://rubygems.org/gems/shellwords
-[lib/singleton.rb]
- Yukihiro Matsumoto (matz)
- https://github.com/ruby/singleton
- https://rubygems.org/gems/singleton
-[lib/tempfile.rb]
- _unmaintained_
- https://github.com/ruby/tempfile
- https://rubygems.org/gems/tempfile
-[lib/time.rb]
- Tanaka Akira (akr)
- https://github.com/ruby/time
- https://rubygems.org/gems/time
-[lib/timeout.rb]
- Yukihiro Matsumoto (matz)
- https://github.com/ruby/timeout
- https://rubygems.org/gems/timeout
-[lib/thwait.rb]
- Keiju ISHITSUKA (keiju)
- https://github.com/ruby/thwait
- https://rubygems.org/gems/thwait
-[lib/tmpdir.rb]
- _unmaintained_
- https://github.com/ruby/tmpdir
- https://rubygems.org/gems/tmpdir
-[lib/tsort.rb]
- Tanaka Akira (akr)
- https://github.com/ruby/tsort
- https://rubygems.org/gems/tsort
-[lib/un.rb]
- WATANABE Hirofumi (eban)
- https://github.com/ruby/un
- https://rubygems.org/gems/un
-[lib/uri.rb, lib/uri/*]
- YAMADA, Akira (akira)
- https://github.com/ruby/uri
- https://rubygems.org/gems/uri
-[lib/yaml.rb, lib/yaml/*]
- Aaron Patterson (tenderlove), Hiroshi SHIBATA (hsbt)
- https://github.com/ruby/yaml
- https://rubygems.org/gems/yaml
-[lib/weakref.rb]
- _unmaintained_
- https://github.com/ruby/weakref
- https://rubygems.org/gems/weakref
-
-=== Extensions
-
-[ext/bigdecimal]
- Kenta Murata (mrkn)
- https://github.com/ruby/bigdecimal
- https://rubygems.org/gems/bigdecimal
-[ext/cgi]
- Nobuyoshi Nakada (nobu)
- https://github.com/ruby/cgi
- https://rubygems.org/gems/cgi
-[ext/date]
- _unmaintained_
- https://github.com/ruby/date
- https://rubygems.org/gems/date
-[ext/etc]
- Ruby core team
- https://github.com/ruby/etc
- https://rubygems.org/gems/etc
-[ext/fcntl]
- Ruby core team
- https://github.com/ruby/fcntl
- https://rubygems.org/gems/fcntl
-[ext/fiddle]
- Aaron Patterson (tenderlove)
- https://github.com/ruby/fiddle
- https://rubygems.org/gems/fiddle
-[ext/io/console]
- Nobuyuki Nakada (nobu)
- https://github.com/ruby/io-console
- https://rubygems.org/gems/io-console
-[ext/io/nonblock]
- Nobuyuki Nakada (nobu)
- https://github.com/ruby/io-nonblock
- https://rubygems.org/gems/io-nonblock
-[ext/io/wait]
- Nobuyuki Nakada (nobu)
- https://github.com/ruby/io-wait
- https://rubygems.org/gems/io-wait
-[ext/json]
- NARUSE, Yui (naruse), Hiroshi SHIBATA (hsbt)
- https://github.com/flori/json
- https://rubygems.org/gems/json
-[ext/nkf]
- NARUSE, Yui (naruse)
- https://github.com/ruby/nkf
- https://rubygems.org/gems/nkf
-[ext/openssl]
- Kazuki Yamaguchi (rhe)
- https://github.com/ruby/openssl
- https://rubygems.org/gems/openssl
-[ext/pathname]
- Tanaka Akira (akr)
- https://github.com/ruby/pathname
- https://rubygems.org/gems/pathname
-[ext/psych]
- Aaron Patterson (tenderlove), Hiroshi SHIBATA (hsbt)
- https://github.com/ruby/psych
- https://rubygems.org/gems/psych
-[ext/racc]
- Aaron Patterson (tenderlove), Hiroshi SHIBATA (hsbt)
- https://github.com/ruby/racc
- https://rubygems.org/gems/racc
-[ext/readline]
- TAKAO Kouji (kouji)
- https://github.com/ruby/readline-ext
- https://rubygems.org/gems/readline-ext
-[ext/stringio]
- Nobuyuki Nakada (nobu)
- https://github.com/ruby/stringio
- https://rubygems.org/gems/stringio
-[ext/strscan]
- Kouhei Sutou (kou)
- https://github.com/ruby/strscan
- https://rubygems.org/gems/strscan
-[ext/syslog]
- Akinori MUSHA (knu)
- https://github.com/ruby/syslog
- https://rubygems.org/gems/syslog
-[ext/win32ole]
- Masaki Suketa (suke)
- https://github.com/ruby/win32ole
- https://rubygems.org/gems/win32ole
-[ext/zlib]
- NARUSE, Yui (naruse)
- https://github.com/ruby/zlib
- https://rubygems.org/gems/zlib
-
-== Bundled gems upstream repositories
-
-[minitest]
- https://github.com/seattlerb/minitest
-[power_assert]
- https://github.com/ruby/power_assert
-[rake]
- https://github.com/ruby/rake
-[test-unit]
- https://github.com/test-unit/test-unit
-[rexml]
- https://github.com/ruby/rexml
-[rss]
- https://github.com/ruby/rss
-[net-ftp]
- https://github.com/ruby/net-ftp
-[net-imap]
- https://github.com/ruby/net-imap
-[net-pop]
- https://github.com/ruby/net-pop
-[net-smtp]
- https://github.com/ruby/net-smtp
-[matrix]
- https://github.com/ruby/matrix
-[prime]
- https://github.com/ruby/prime
-[rbs]
- https://github.com/ruby/rbs
-[typeprof]
- https://github.com/ruby/typeprof
-
-=== Platform Maintainers
-
-[mswin64 (Microsoft Windows)]
- NAKAMURA Usaku (usa)
-[mingw32 (Minimalist GNU for Windows)]
- Nobuyoshi Nakada (nobu)
-[AIX]
- Yutaka Kanemoto (kanemoto)
-[FreeBSD]
- Akinori MUSHA (knu)
-[Solaris]
- Naohisa Goto (ngoto)
-[RHEL, CentOS]
- KOSAKI Motohiro (kosaki)
-[macOS]
- Kenta Murata (mrkn)
-[OpenBSD]
- Jeremy Evans (jeremyevans0)
-[cygwin, ...]
- none. (Maintainer WANTED)
-[WebAssembly/WASI]
- Yuta Saito (katei)
diff --git a/doc/mjit/mjit.md b/doc/mjit/mjit.md
deleted file mode 100644
index 6f19ab3ea7..0000000000
--- a/doc/mjit/mjit.md
+++ /dev/null
@@ -1,39 +0,0 @@
-# MJIT
-
-This document has some tips that might be useful when you work on MJIT.
-
-## Supported platforms
-
-The following platforms are either tested on CI or assumed to work.
-
-* OS: Linux, macOS
-* Arch: x86\_64, aarch64, arm64, i686, i386
-
-### Not supported
-
-The MJIT support for the following platforms is no longer maintained.
-
-* OS: Windows (mswin, MinGW), Solaris
-* Arch: SPARC, s390x
-
-## Developing MJIT
-
-### Bindgen
-
-If you see an "MJIT bindgen" GitHub Actions failure, please commit the `git diff` shown on the failed job.
-
-For doing the same thing locally, run `make mjit-bindgen` after installing libclang.
-macOS seems to have libclang by default. On Ubuntu, you can install it with `apt install libclang1`.
-
-### Always run make install
-
-Always run `make install` before running MJIT. It could easily cause a SEGV if you don't.
-MJIT looks for the installed header for security reasons.
-
-### --mjit-debug vs --mjit-debug=-ggdb3
-
-`--mjit-debug=[flags]` allows you to specify arbitrary flags while keeping other compiler flags like `-O3`,
-which is useful for profiling benchmarks.
-
-`--mjit-debug` alone, on the other hand, disables `-O3` and adds debug flags.
-If you're debugging MJIT, what you need to use is not `--mjit-debug=-ggdb3` but `--mjit-debug`.
diff --git a/doc/net-http/included_setters.rdoc b/doc/net-http/included_setters.rdoc
deleted file mode 100644
index 4af977cae3..0000000000
--- a/doc/net-http/included_setters.rdoc
+++ /dev/null
@@ -1,3 +0,0 @@
-This class also includes (indirectly) module Net::HTTPHeader,
-which gives access to its
-{methods for setting headers}[rdoc-ref:Net::HTTPHeader@Setters].
diff --git a/doc/optparse/argument_converters.rdoc b/doc/optparse/argument_converters.rdoc
index ac659da8c5..4b4b30e8de 100644
--- a/doc/optparse/argument_converters.rdoc
+++ b/doc/optparse/argument_converters.rdoc
@@ -1,7 +1,7 @@
== Argument Converters
An option can specify that its argument is to be converted
-from the default \String to an instance of another class.
+from the default +String+ to an instance of another class.
=== Contents
@@ -27,13 +27,13 @@ from the default \String to an instance of another class.
=== Built-In Argument Converters
-\OptionParser has a number of built-in argument converters,
++OptionParser+ has a number of built-in argument converters,
which are demonstrated below.
-==== \Date
+==== +Date+
File +date.rb+
-defines an option whose argument is to be converted to a \Date object.
+defines an option whose argument is to be converted to a +Date+ object.
The argument is converted by method Date#parse.
:include: ruby/date.rb
@@ -47,10 +47,10 @@ Executions:
$ ruby date.rb --date "3rd Feb 2001"
[#<Date: 2001-02-03 ((2451944j,0s,0n),+0s,2299161j)>, Date]
-==== \DateTime
+==== +DateTime+
File +datetime.rb+
-defines an option whose argument is to be converted to a \DateTime object.
+defines an option whose argument is to be converted to a +DateTime+ object.
The argument is converted by method DateTime#parse.
:include: ruby/datetime.rb
@@ -64,10 +64,10 @@ Executions:
$ ruby datetime.rb --datetime "3rd Feb 2001 04:05:06 PM"
[#<DateTime: 2001-02-03T16:05:06+00:00 ((2451944j,57906s,0n),+0s,2299161j)>, DateTime]
-==== \Time
+==== +Time+
File +time.rb+
-defines an option whose argument is to be converted to a \Time object.
+defines an option whose argument is to be converted to a +Time+ object.
The argument is converted by method Time#httpdate or Time#parse.
:include: ruby/time.rb
@@ -79,10 +79,10 @@ Executions:
$ ruby time.rb --time 2010-10-31
[2010-10-31 00:00:00 -0500, Time]
-==== \URI
+==== +URI+
File +uri.rb+
-defines an option whose argument is to be converted to a \URI object.
+defines an option whose argument is to be converted to a +URI+ object.
The argument is converted by method URI#parse.
:include: ruby/uri.rb
@@ -96,10 +96,10 @@ Executions:
$ ruby uri.rb --uri file://~/var
[#<URI::File file://~/var>, URI::File]
-==== \Shellwords
+==== +Shellwords+
File +shellwords.rb+
-defines an option whose argument is to be converted to an \Array object by method
+defines an option whose argument is to be converted to an +Array+ object by method
Shellwords#shellwords.
:include: ruby/shellwords.rb
@@ -111,10 +111,10 @@ Executions:
$ ruby shellwords.rb --shellwords "here are 'two words'"
[["here", "are", "two words"], Array]
-==== \Integer
+==== +Integer+
File +integer.rb+
-defines an option whose argument is to be converted to an \Integer object.
+defines an option whose argument is to be converted to an +Integer+ object.
The argument is converted by method Kernel#Integer.
:include: ruby/integer.rb
@@ -132,10 +132,10 @@ Executions:
$ ruby integer.rb --integer 0b100
[4, Integer]
-==== \Float
+==== +Float+
File +float.rb+
-defines an option whose argument is to be converted to a \Float object.
+defines an option whose argument is to be converted to a +Float+ object.
The argument is converted by method Kernel#Float.
:include: ruby/float.rb
@@ -151,11 +151,11 @@ Executions:
$ ruby float.rb --float 1.234E-2
[0.01234, Float]
-==== \Numeric
+==== +Numeric+
File +numeric.rb+
defines an option whose argument is to be converted to an instance
-of \Rational, \Float, or \Integer.
+of +Rational+, +Float+, or +Integer+.
The argument is converted by method Kernel#Rational,
Kernel#Float, or Kernel#Integer.
@@ -170,10 +170,10 @@ Executions:
$ ruby numeric.rb --numeric 3
[3, Integer]
-==== \DecimalInteger
+==== +DecimalInteger+
File +decimal_integer.rb+
-defines an option whose argument is to be converted to an \Integer object.
+defines an option whose argument is to be converted to an +Integer+ object.
The argument is converted by method Kernel#Integer.
:include: ruby/decimal_integer.rb
@@ -192,10 +192,10 @@ Executions:
$ ruby decimal_integer.rb --decimal_integer -0100
[-100, Integer]
-==== \OctalInteger
+==== +OctalInteger+
File +octal_integer.rb+
-defines an option whose argument is to be converted to an \Integer object.
+defines an option whose argument is to be converted to an +Integer+ object.
The argument is converted by method Kernel#Integer.
:include: ruby/octal_integer.rb
@@ -212,10 +212,10 @@ Executions:
$ ruby octal_integer.rb --octal_integer 0100
[64, Integer]
-==== \DecimalNumeric
+==== +DecimalNumeric+
File +decimal_numeric.rb+
-defines an option whose argument is to be converted to an \Integer object.
+defines an option whose argument is to be converted to an +Integer+ object.
The argument is converted by method Kernel#Integer
:include: ruby/decimal_numeric.rb
@@ -232,7 +232,7 @@ Executions:
$ ruby decimal_numeric.rb --decimal_numeric 0100
[64, Integer]
-==== \TrueClass
+==== +TrueClass+
File +true_class.rb+
defines an option whose argument is to be converted to +true+ or +false+.
@@ -259,7 +259,7 @@ Executions:
$ ruby true_class.rb --true_class nil
[false, FalseClass]
-==== \FalseClass
+==== +FalseClass+
File +false_class.rb+
defines an option whose argument is to be converted to +true+ or +false+.
@@ -286,10 +286,10 @@ Executions:
$ ruby false_class.rb --false_class +
[true, TrueClass]
-==== \Object
+==== +Object+
File +object.rb+
-defines an option whose argument is not to be converted from \String.
+defines an option whose argument is not to be converted from +String+.
:include: ruby/object.rb
@@ -300,10 +300,10 @@ Executions:
$ ruby object.rb --object nil
["nil", String]
-==== \String
+==== +String+
File +string.rb+
-defines an option whose argument is not to be converted from \String.
+defines an option whose argument is not to be converted from +String+.
:include: ruby/string.rb
@@ -314,10 +314,10 @@ Executions:
$ ruby string.rb --string nil
["nil", String]
-==== \Array
+==== +Array+
File +array.rb+
-defines an option whose argument is to be converted from \String
+defines an option whose argument is to be converted from +String+
to an array of strings, based on comma-separated substrings.
:include: ruby/array.rb
@@ -331,10 +331,10 @@ Executions:
$ ruby array.rb --array "foo, bar, baz"
[["foo", " bar", " baz"], Array]
-==== \Regexp
+==== +Regexp+
File +regexp.rb+
-defines an option whose argument is to be converted to a \Regexp object.
+defines an option whose argument is to be converted to a +Regexp+ object.
:include: ruby/regexp.rb
@@ -352,7 +352,7 @@ To create a custom converter, call OptionParser#accept with:
- A block that accepts the argument and returns the converted value.
This custom converter accepts any argument and converts it,
-if possible, to a \Complex object.
+if possible, to a +Complex+ object.
:include: ruby/custom_converter.rb
diff --git a/doc/optparse/option_params.rdoc b/doc/optparse/option_params.rdoc
index ace2c4283f..55f9b53dff 100644
--- a/doc/optparse/option_params.rdoc
+++ b/doc/optparse/option_params.rdoc
@@ -1,6 +1,6 @@
== Parameters for New Options
-Option-creating methods in \OptionParser
+Option-creating methods in +OptionParser+
accept arguments that determine the behavior of a new option:
- OptionParser#on
@@ -405,7 +405,7 @@ Executions:
=== Argument Converters
An option can specify that its argument is to be converted
-from the default \String to an instance of another class.
+from the default +String+ to an instance of another class.
There are a number of built-in converters.
You can also define custom converters.
diff --git a/doc/optparse/tutorial.rdoc b/doc/optparse/tutorial.rdoc
index b95089826d..b104379cf7 100644
--- a/doc/optparse/tutorial.rdoc
+++ b/doc/optparse/tutorial.rdoc
@@ -1,10 +1,10 @@
== Tutorial
-=== Why \OptionParser?
+=== Why +OptionParser+?
When a Ruby program executes, it captures its command-line arguments
and options into variable ARGV.
-This simple program just prints its \ARGV:
+This simple program just prints its +ARGV+:
:include: ruby/argv.rb
@@ -18,7 +18,7 @@ the command-line options.
OptionParser offers methods for parsing and handling those options.
-With \OptionParser, you can define options so that for each option:
+With +OptionParser+, you can define options so that for each option:
- The code that defines the option and code that handles that option
are in the same place.
@@ -55,7 +55,7 @@ The class also has method #help, which displays automatically-generated help tex
- {Argument Converters}[#label-Argument+Converters]
- {Help}[#label-Help]
- {Top List and Base List}[#label-Top+List+and+Base+List]
-- {Defining Options}[#label-Defining+Options]
+- {Methods for Defining Options}[#label-Methods+for+Defining+Options]
- {Parsing}[#label-Parsing]
- {Method parse!}[#label-Method+parse-21]
- {Method parse}[#label-Method+parse]
@@ -66,10 +66,10 @@ The class also has method #help, which displays automatically-generated help tex
=== To Begin With
-To use \OptionParser:
+To use +OptionParser+:
-1. Require the \OptionParser code.
-2. Create an \OptionParser object.
+1. Require the +OptionParser+ code.
+2. Create an +OptionParser+ object.
3. Define one or more options.
4. Parse the command line.
@@ -92,9 +92,9 @@ the block defined for the option is called with the argument value.
An invalid option raises an exception.
Method #parse!, which is used most often in this tutorial,
-removes from \ARGV the options and arguments it finds,
+removes from +ARGV+ the options and arguments it finds,
leaving other non-option arguments for the program to handle on its own.
-The method returns the possibly-reduced \ARGV array.
+The method returns the possibly-reduced +ARGV+ array.
Executions:
@@ -115,7 +115,7 @@ Executions:
=== Defining Options
-A common way to define an option in \OptionParser
+A common way to define an option in +OptionParser+
is with instance method OptionParser#on.
The method may be called with any number of arguments
@@ -522,11 +522,11 @@ Executions:
=== Argument Converters
An option can specify that its argument is to be converted
-from the default \String to an instance of another class.
+from the default +String+ to an instance of another class.
There are a number of built-in converters.
Example: File +date.rb+
-defines an option whose argument is to be converted to a \Date object.
+defines an option whose argument is to be converted to a +Date+ object.
The argument is converted by method Date#parse.
:include: ruby/date.rb
@@ -546,7 +546,7 @@ for both built-in and custom converters.
=== Help
-\OptionParser makes automatically generated help text available.
++OptionParser+ makes automatically generated help text available.
The help text consists of:
@@ -614,49 +614,49 @@ Execution:
=== Top List and Base List
-An \OptionParser object maintains a stack of \OptionParser::List objects,
+An +OptionParser+ object maintains a stack of OptionParser::List objects,
each of which has a collection of zero or more options.
It is unlikely that you'll need to add or take away from that stack.
The stack includes:
-- The <em>top list</em>, given by \OptionParser#top.
-- The <em>base list</em>, given by \OptionParser#base.
+- The <em>top list</em>, given by OptionParser#top.
+- The <em>base list</em>, given by OptionParser#base.
-When \OptionParser builds its help text, the options in the top list
+When +OptionParser+ builds its help text, the options in the top list
precede those in the base list.
-=== Defining Options
+=== Methods for Defining Options
Option-defining methods allow you to create an option, and also append/prepend it
to the top list or append it to the base list.
Each of these next three methods accepts a sequence of parameter arguments and a block,
-creates an option object using method \Option#make_switch (see below),
+creates an option object using method OptionParser#make_switch (see below),
and returns the created option:
-- \Method \OptionParser#define appends the created option to the top list.
+- \Method OptionParser#define appends the created option to the top list.
-- \Method \OptionParser#define_head prepends the created option to the top list.
+- \Method OptionParser#define_head prepends the created option to the top list.
-- \Method \OptionParser#define_tail appends the created option to the base list.
+- \Method OptionParser#define_tail appends the created option to the base list.
These next three methods are identical to the three above,
except for their return values:
-- \Method \OptionParser#on is identical to method \OptionParser#define,
+- \Method OptionParser#on is identical to method OptionParser#define,
except that it returns the parser object +self+.
-- \Method \OptionParser#on_head is identical to method \OptionParser#define_head,
+- \Method OptionParser#on_head is identical to method OptionParser#define_head,
except that it returns the parser object +self+.
-- \Method \OptionParser#on_tail is identical to method \OptionParser#define_tail,
+- \Method OptionParser#on_tail is identical to method OptionParser#define_tail,
except that it returns the parser object +self+.
Though you may never need to call it directly,
here's the core method for defining an option:
-- \Method \OptionParser#make_switch accepts an array of parameters and a block.
+- \Method OptionParser#make_switch accepts an array of parameters and a block.
See {Parameters for New Options}[optparse/option_params.rdoc].
This method is unlike others here in that it:
- Accepts an <em>array of parameters</em>;
@@ -668,7 +668,7 @@ here's the core method for defining an option:
=== Parsing
-\OptionParser has six instance methods for parsing.
++OptionParser+ has six instance methods for parsing.
Three have names ending with a "bang" (<tt>!</tt>):
@@ -699,9 +699,9 @@ Each of these methods:
(see {Keyword Argument into}[#label-Keyword+Argument+into]).
- Returns +argv+, possibly with some elements removed.
-==== \Method parse!
+==== \Method +parse!+
-\Method parse!:
+\Method +parse!+:
- Accepts an optional array of string arguments +argv+;
if not given, +argv+ defaults to the value of OptionParser#default_argv,
@@ -756,9 +756,9 @@ Processing ended by non-option found when +POSIXLY_CORRECT+ is defined:
["--xxx", true]
Returned: ["input_file.txt", "output_file.txt", "-yyy", "FOO"] (Array)
-==== \Method parse
+==== \Method +parse+
-\Method parse:
+\Method +parse+:
- Accepts an array of string arguments
_or_ zero or more string arguments.
@@ -810,25 +810,25 @@ Processing ended by non-option found when +POSIXLY_CORRECT+ is defined:
["--xxx", true]
Returned: ["input_file.txt", "output_file.txt", "-yyy", "FOO"] (Array)
-==== \Method order!
+==== \Method +order!+
Calling method OptionParser#order! gives exactly the same result as
calling method OptionParser#parse! with environment variable
+POSIXLY_CORRECT+ defined.
-==== \Method order
+==== \Method +order+
Calling method OptionParser#order gives exactly the same result as
calling method OptionParser#parse with environment variable
+POSIXLY_CORRECT+ defined.
-==== \Method permute!
+==== \Method +permute!+
Calling method OptionParser#permute! gives exactly the same result as
calling method OptionParser#parse! with environment variable
+POSIXLY_CORRECT+ _not_ defined.
-==== \Method permute
+==== \Method +permute+
Calling method OptionParser#permute gives exactly the same result as
calling method OptionParser#parse with environment variable
diff --git a/doc/packed_data.rdoc b/doc/packed_data.rdoc
index ec13b24c69..59d8c99a3a 100644
--- a/doc/packed_data.rdoc
+++ b/doc/packed_data.rdoc
@@ -1,4 +1,4 @@
-== Packed \Data
+= Packed \Data
Certain Ruby core methods deal with packing and unpacking data:
@@ -64,7 +64,7 @@ If elements don't fit the provided directive, only least significant bits are en
[257].pack("C").unpack("C") # => [1]
-=== Packing \Method
+== Packing \Method
\Method Array#pack accepts optional keyword argument
+buffer+ that specifies the target string (instead of a new string):
@@ -76,7 +76,7 @@ The method can accept a block:
# Packed string is passed to the block.
[65, 66].pack('C*') {|s| p s } # => "AB"
-=== Unpacking Methods
+== Unpacking Methods
Methods String#unpack and String#unpack1 each accept
an optional keyword argument +offset+ that specifies an offset
@@ -95,12 +95,12 @@ Both methods can accept a block:
# The single unpacked object is passed to the block.
'AB'.unpack1('C*') {|ele| p ele } # => 65
-=== \Integer Directives
+== \Integer Directives
Each integer directive specifies the packing or unpacking
for one element in the input or output array.
-==== 8-Bit \Integer Directives
+=== 8-Bit \Integer Directives
- <tt>'c'</tt> - 8-bit signed integer
(like C <tt>signed char</tt>):
@@ -109,14 +109,14 @@ for one element in the input or output array.
s = [0, 1, -1].pack('c*') # => "\x00\x01\xFF"
s.unpack('c*') # => [0, 1, -1]
-- <tt>'C'</tt> - 8-bit signed integer
+- <tt>'C'</tt> - 8-bit unsigned integer
(like C <tt>unsigned char</tt>):
[0, 1, 255].pack('C*') # => "\x00\x01\xFF"
s = [0, 1, -1].pack('C*') # => "\x00\x01\xFF"
s.unpack('C*') # => [0, 1, 255]
-==== 16-Bit \Integer Directives
+=== 16-Bit \Integer Directives
- <tt>'s'</tt> - 16-bit signed integer, native-endian
(like C <tt>int16_t</tt>):
@@ -146,7 +146,7 @@ for one element in the input or output array.
s.unpack('v*')
# => [0, 1, 65535, 32767, 32768, 65535]
-==== 32-Bit \Integer Directives
+=== 32-Bit \Integer Directives
- <tt>'l'</tt> - 32-bit signed integer, native-endian
(like C <tt>int32_t</tt>):
@@ -178,7 +178,7 @@ for one element in the input or output array.
s.unpack('v*')
# => [0, 0, 1, 0, 65535, 65535]
-==== 64-Bit \Integer Directives
+=== 64-Bit \Integer Directives
- <tt>'q'</tt> - 64-bit signed integer, native-endian
(like C <tt>int64_t</tt>):
@@ -196,7 +196,7 @@ for one element in the input or output array.
s.unpack('Q*')
# => [578437695752307201, 17940646550795321087]
-==== Platform-Dependent \Integer Directives
+=== Platform-Dependent \Integer Directives
- <tt>'i'</tt> - Platform-dependent width signed integer,
native-endian (like C <tt>int</tt>):
@@ -214,26 +214,24 @@ for one element in the input or output array.
s.unpack('I*')
# => [67305985, 4244504319]
-==== Pointer Directives
-
-- <tt>'j'</tt> - 64-bit pointer-width signed integer,
- native-endian (like C <tt>intptr_t</tt>):
+- <tt>'j'</tt> - Pointer-width signed integer, native-endian
+ (like C <tt>intptr_t</tt>):
s = [67305985, -50462977].pack('j*')
# => "\x01\x02\x03\x04\x00\x00\x00\x00\xFF\xFE\xFD\xFC\xFF\xFF\xFF\xFF"
s.unpack('j*')
# => [67305985, -50462977]
-- <tt>'j'</tt> - 64-bit pointer-width unsigned integer,
- native-endian (like C <tt>uintptr_t</tt>):
+- <tt>'J'</tt> - Pointer-width unsigned integer, native-endian
+ (like C <tt>uintptr_t</tt>):
s = [67305985, 4244504319].pack('J*')
# => "\x01\x02\x03\x04\x00\x00\x00\x00\xFF\xFE\xFD\xFC\x00\x00\x00\x00"
s.unpack('J*')
# => [67305985, 4244504319]
-==== Other \Integer Directives
-:
+=== Other \Integer Directives
+
- <tt>'U'</tt> - UTF-8 character:
s = [4194304].pack('U*')
@@ -249,31 +247,30 @@ for one element in the input or output array.
s.unpack('w*')
# => [1073741823]
-==== Modifiers for \Integer Directives
-
-For directives in
-<tt>'i'</tt>,
-<tt>'I'</tt>,
-<tt>'s'</tt>,
-<tt>'S'</tt>,
-<tt>'l'</tt>,
-<tt>'L'</tt>,
-<tt>'q'</tt>,
-<tt>'Q'</tt>,
-<tt>'j'</tt>, and
-<tt>'J'</tt>,
-these modifiers may be suffixed:
-
-- <tt>'!'</tt> or <tt>'_'</tt> - Underlying platform’s native size.
+=== Modifiers for \Integer Directives
+
+For the following directives, <tt>'!'</tt> or <tt>'_'</tt> modifiers may be
+suffixed as underlying platform’s native size.
+
+- <tt>'i'</tt>, <tt>'I'</tt> - C <tt>int</tt>, always native size.
+- <tt>'s'</tt>, <tt>'S'</tt> - C <tt>short</tt>.
+- <tt>'l'</tt>, <tt>'L'</tt> - C <tt>long</tt>.
+- <tt>'q'</tt>, <tt>'Q'</tt> - C <tt>long long</tt>, if available.
+- <tt>'j'</tt>, <tt>'J'</tt> - C <tt>intptr_t</tt>, always native size.
+
+Native size modifiers are silently ignored for always native size directives.
+
+The endian modifiers also may be suffixed in the directives above:
+
- <tt>'>'</tt> - Big-endian.
- <tt>'<'</tt> - Little-endian.
-=== \Float Directives
+== \Float Directives
Each float directive specifies the packing or unpacking
for one element in the input or output array.
-==== Single-Precision \Float Directives
+=== Single-Precision \Float Directives
- <tt>'F'</tt> or <tt>'f'</tt> - Native format:
@@ -290,7 +287,7 @@ for one element in the input or output array.
s = [3.0].pack('g') # => "@@\x00\x00"
s.unpack('g') # => [3.0]
-==== Double-Precision \Float Directives
+=== Double-Precision \Float Directives
- <tt>'D'</tt> or <tt>'d'</tt> - Native format:
@@ -317,12 +314,12 @@ A float directive may be infinity or not-a-number:
[nan].pack('f') # => "\x00\x00\xC0\x7F"
"\x00\x00\xC0\x7F".unpack('f') # => [NaN]
-=== \String Directives
+== \String Directives
Each string directive specifies the packing or unpacking
for one byte in the input or output string.
-==== Binary \String Directives
+=== Binary \String Directives
- <tt>'A'</tt> - Arbitrary binary string (space padded; count is width);
+nil+ is treated as the empty string:
@@ -380,7 +377,7 @@ for one byte in the input or output string.
"foo".unpack('Z*') # => ["foo"]
"foo\0bar".unpack('Z*') # => ["foo"] # Does not read past "\0".
-==== Bit \String Directives
+=== Bit \String Directives
- <tt>'B'</tt> - Bit string (high byte first):
@@ -424,7 +421,7 @@ for one byte in the input or output string.
"\x01".unpack("b2") # => ["10"]
"\x01".unpack("b3") # => ["100"]
-==== Hex \String Directives
+=== Hex \String Directives
- <tt>'H'</tt> - Hex string (high nibble first):
@@ -470,7 +467,7 @@ for one byte in the input or output string.
"\x01\xfe".unpack('h4') # => ["10ef"]
"\x01\xfe".unpack('h5') # => ["10ef"]
-==== Pointer \String Directives
+=== Pointer \String Directives
- <tt>'P'</tt> - Pointer to a structure (fixed-length string):
@@ -488,7 +485,7 @@ for one byte in the input or output string.
("\0" * 8).unpack("p") # => [nil]
[nil].pack("p") # => "\x00\x00\x00\x00\x00\x00\x00\x00"
-==== Other \String Directives
+=== Other \String Directives
- <tt>'M'</tt> - Quoted printable, MIME encoding;
text mode, but input must use LF and output LF;
@@ -562,7 +559,7 @@ for one byte in the input or output string.
[0x40000000].pack("U") # => "\xFD\x80\x80\x80\x80\x80"
[0x7fffffff].pack("U") # => "\xFD\xBF\xBF\xBF\xBF\xBF"
-=== Offset Directives
+== Offset Directives
- <tt>'@'</tt> - Begin packing at the given byte offset;
for packing, null fill if necessary:
@@ -580,7 +577,7 @@ for one byte in the input or output string.
[0, 1, 2].pack("CCX2C") # => "\x02"
"\x00\x02".unpack("CCXC") # => [0, 2, 2]
-=== Null Byte Direcive
+== Null Byte Direcive
- <tt>'x'</tt> - Null byte:
diff --git a/doc/rdoc/markup_reference.rb b/doc/rdoc/markup_reference.rb
index 66ec6786c0..a1bbe13e2d 100644
--- a/doc/rdoc/markup_reference.rb
+++ b/doc/rdoc/markup_reference.rb
@@ -26,7 +26,7 @@ require 'rdoc'
# - Single-line or multi-line comments that precede certain definitions;
# see {Markup in Comments}[rdoc-ref:RDoc::MarkupReference@Markup+in+Comments].
# - \RDoc directives in trailing comments (on the same line as code);
-# see <tt>:nodoc:</tt>, <tt>:doc:</tt>, and <tt>:notnew</tt>.
+# see <tt>:nodoc:</tt>, <tt>:doc:</tt>, and <tt>:notnew:</tt>.
# - \RDoc directives in single-line comments;
# see other {Directives}[rdoc-ref:RDoc::MarkupReference@Directives].
# - The Ruby code itself (but not from C code);
@@ -66,7 +66,7 @@ require 'rdoc'
# In a multi-line comment,
# \RDoc looks for the comment's natural left margin,
# which becomes the <em>base margin</em> for the comment
-# and is the initial <em>current margin</em> for for the comment.
+# and is the initial <em>current margin</em> for the comment.
#
# The current margin can change, and does so, for example in a list.
#
@@ -346,7 +346,7 @@ require 'rdoc'
#
# ===== Lettered Lists
#
-# A numbered list item begins with a letters and a period.
+# A lettered list item begins with letters and a period.
#
# The items are automatically "re-lettered."
#
@@ -467,8 +467,32 @@ require 'rdoc'
#
# - Appended to a line of code
# that defines a class, module, method, alias, constant, or attribute.
+#
# - Specifies that the defined object should not be documented.
#
+# - For method definitions in C code, it must be placed before the
+# implementation:
+#
+# /* :nodoc: */
+# static VALUE
+# some_method(VALUE self)
+# {
+# return self;
+# }
+#
+# Note that this directive has <em>no effect at all</em> at method
+# definition places. E.g.,
+#
+# /* :nodoc: */
+# rb_define_method(cMyClass, "do_something", something_func, 0);
+#
+# The above comment is just a comment and has nothing to do with \RDoc.
+# Therefore, +do_something+ method will be reported as "undocumented"
+# unless that method or function is documented elsewhere.
+#
+# - For constant definitions in C code, this directive <em>can not work</em>
+# because there is no "implementation" place for constants.
+#
# - <tt># :nodoc: all</tt>:
#
# - Appended to a line of code
@@ -502,8 +526,8 @@ require 'rdoc'
# #++
# # Documented.
#
-# For C code, any of directives <tt>:startdoc:</tt>, <tt>:enddoc:</tt>,
-# and <tt>:nodoc:</tt> may appear in a stand-alone comment:
+# For C code, any of directives <tt>:startdoc:</tt>, <tt>:stopdoc:</tt>,
+# and <tt>:enddoc:</tt> may appear in a stand-alone comment:
#
# /* :startdoc: */
# /* :stopdoc: */
@@ -1192,13 +1216,26 @@ require 'rdoc'
#
class RDoc::MarkupReference
+ # example class
class DummyClass; end
+
+ # example module
module DummyModule; end
+
+ # example singleton method
def self.dummy_singleton_method(foo, bar); end
+
+ # example instance method
def dummy_instance_method(foo, bar); end;
+
alias dummy_instance_alias dummy_instance_method
+
+ # example attribute
attr_accessor :dummy_attribute
+
alias dummy_attribute_alias dummy_attribute
+
+ # example constant
DUMMY_CONSTANT = ''
# :call-seq:
diff --git a/doc/regexp.rdoc b/doc/regexp.rdoc
deleted file mode 100644
index 51ea772062..0000000000
--- a/doc/regexp.rdoc
+++ /dev/null
@@ -1,810 +0,0 @@
-# -*- mode: rdoc; coding: utf-8; fill-column: 74; -*-
-
-Regular expressions (<i>regexp</i>s) are patterns which describe the
-contents of a string. They're used for testing whether a string contains a
-given pattern, or extracting the portions that match. They are created
-with the <tt>/</tt><i>pat</i><tt>/</tt> and
-<tt>%r{</tt><i>pat</i><tt>}</tt> literals or the <tt>Regexp.new</tt>
-constructor.
-
-A regexp is usually delimited with forward slashes (<tt>/</tt>). For
-example:
-
- /hay/ =~ 'haystack' #=> 0
- /y/.match('haystack') #=> #<MatchData "y">
-
-If a string contains the pattern it is said to <i>match</i>. A literal
-string matches itself.
-
-Here 'haystack' does not contain the pattern 'needle', so it doesn't match:
-
- /needle/.match('haystack') #=> nil
-
-Here 'haystack' contains the pattern 'hay', so it matches:
-
- /hay/.match('haystack') #=> #<MatchData "hay">
-
-Specifically, <tt>/st/</tt> requires that the string contains the letter
-_s_ followed by the letter _t_, so it matches _haystack_, also.
-
-Note that any Regexp matching will raise a RuntimeError if timeout is set and
-exceeded. See {"Timeout"}[#label-Timeout] section in detail.
-
-== \Regexp Interpolation
-
-A regexp may contain interpolated strings; trivially:
-
- foo = 'bar'
- /#{foo}/ # => /bar/
-
-== <tt>=~</tt> and Regexp#match
-
-Pattern matching may be achieved by using <tt>=~</tt> operator or Regexp#match
-method.
-
-=== <tt>=~</tt> Operator
-
-<tt>=~</tt> is Ruby's basic pattern-matching operator. When one operand is a
-regular expression and the other is a string then the regular expression is
-used as a pattern to match against the string. (This operator is equivalently
-defined by Regexp and String so the order of String and Regexp do not matter.
-Other classes may have different implementations of <tt>=~</tt>.) If a match
-is found, the operator returns index of first match in string, otherwise it
-returns +nil+.
-
- /hay/ =~ 'haystack' #=> 0
- 'haystack' =~ /hay/ #=> 0
- /a/ =~ 'haystack' #=> 1
- /u/ =~ 'haystack' #=> nil
-
-Using <tt>=~</tt> operator with a String and Regexp the <tt>$~</tt> global
-variable is set after a successful match. <tt>$~</tt> holds a MatchData
-object. Regexp.last_match is equivalent to <tt>$~</tt>.
-
-=== Regexp#match Method
-
-The #match method returns a MatchData object:
-
- /st/.match('haystack') #=> #<MatchData "st">
-
-== Metacharacters and Escapes
-
-The following are <i>metacharacters</i> <tt>(</tt>, <tt>)</tt>,
-<tt>[</tt>, <tt>]</tt>, <tt>{</tt>, <tt>}</tt>, <tt>.</tt>, <tt>?</tt>,
-<tt>+</tt>, <tt>*</tt>. They have a specific meaning when appearing in a
-pattern. To match them literally they must be backslash-escaped. To match
-a backslash literally, backslash-escape it: <tt>\\\\</tt>.
-
- /1 \+ 2 = 3\?/.match('Does 1 + 2 = 3?') #=> #<MatchData "1 + 2 = 3?">
- /a\\\\b/.match('a\\\\b') #=> #<MatchData "a\\b">
-
-Patterns behave like double-quoted strings and can contain the same
-backslash escapes (the meaning of <tt>\s</tt> is different, however,
-see below[#label-Character+Classes]).
-
- /\s\u{6771 4eac 90fd}/.match("Go to 東京都")
- #=> #<MatchData " 東京都">
-
-Arbitrary Ruby expressions can be embedded into patterns with the
-<tt>#{...}</tt> construct.
-
- place = "東京都"
- /#{place}/.match("Go to 東京都")
- #=> #<MatchData "東京都">
-
-== Character Classes
-
-A <i>character class</i> is delimited with square brackets (<tt>[</tt>,
-<tt>]</tt>) and lists characters that may appear at that point in the
-match. <tt>/[ab]/</tt> means _a_ or _b_, as opposed to <tt>/ab/</tt> which
-means _a_ followed by _b_.
-
- /W[aeiou]rd/.match("Word") #=> #<MatchData "Word">
-
-Within a character class the hyphen (<tt>-</tt>) is a metacharacter
-denoting an inclusive range of characters. <tt>[abcd]</tt> is equivalent
-to <tt>[a-d]</tt>. A range can be followed by another range, so
-<tt>[abcdwxyz]</tt> is equivalent to <tt>[a-dw-z]</tt>. The order in which
-ranges or individual characters appear inside a character class is
-irrelevant.
-
- /[0-9a-f]/.match('9f') #=> #<MatchData "9">
- /[9f]/.match('9f') #=> #<MatchData "9">
-
-If the first character of a character class is a caret (<tt>^</tt>) the
-class is inverted: it matches any character _except_ those named.
-
- /[^a-eg-z]/.match('f') #=> #<MatchData "f">
-
-A character class may contain another character class. By itself this
-isn't useful because <tt>[a-z[0-9]]</tt> describes the same set as
-<tt>[a-z0-9]</tt>. However, character classes also support the <tt>&&</tt>
-operator which performs set intersection on its arguments. The two can be
-combined as follows:
-
- /[a-w&&[^c-g]z]/ # ([a-w] AND ([^c-g] OR z))
-
-This is equivalent to:
-
- /[abh-w]/
-
-The following metacharacters also behave like character classes:
-
-* <tt>/./</tt> - Any character except a newline.
-* <tt>/./m</tt> - Any character (the +m+ modifier enables multiline mode)
-* <tt>/\w/</tt> - A word character (<tt>[a-zA-Z0-9_]</tt>)
-* <tt>/\W/</tt> - A non-word character (<tt>[^a-zA-Z0-9_]</tt>).
- Please take a look at {Bug #4044}[https://bugs.ruby-lang.org/issues/4044] if
- using <tt>/\W/</tt> with the <tt>/i</tt> modifier.
-* <tt>/\d/</tt> - A digit character (<tt>[0-9]</tt>)
-* <tt>/\D/</tt> - A non-digit character (<tt>[^0-9]</tt>)
-* <tt>/\h/</tt> - A hexdigit character (<tt>[0-9a-fA-F]</tt>)
-* <tt>/\H/</tt> - A non-hexdigit character (<tt>[^0-9a-fA-F]</tt>)
-* <tt>/\s/</tt> - A whitespace character: <tt>/[ \t\r\n\f\v]/</tt>
-* <tt>/\S/</tt> - A non-whitespace character: <tt>/[^ \t\r\n\f\v]/</tt>
-* <tt>/\R/</tt> - A linebreak: <tt>\n</tt>, <tt>\v</tt>, <tt>\f</tt>, <tt>\r</tt>
- <tt>\u0085</tt> (NEXT LINE), <tt>\u2028</tt> (LINE SEPARATOR), <tt>\u2029</tt> (PARAGRAPH SEPARATOR)
- or <tt>\r\n</tt>.
-
-POSIX <i>bracket expressions</i> are also similar to character classes.
-They provide a portable alternative to the above, with the added benefit
-that they encompass non-ASCII characters. For instance, <tt>/\d/</tt>
-matches only the ASCII decimal digits (0-9); whereas <tt>/[[:digit:]]/</tt>
-matches any character in the Unicode _Nd_ category.
-
-* <tt>/[[:alnum:]]/</tt> - Alphabetic and numeric character
-* <tt>/[[:alpha:]]/</tt> - Alphabetic character
-* <tt>/[[:blank:]]/</tt> - Space or tab
-* <tt>/[[:cntrl:]]/</tt> - Control character
-* <tt>/[[:digit:]]/</tt> - Digit
-* <tt>/[[:graph:]]/</tt> - Non-blank character (excludes spaces, control
- characters, and similar)
-* <tt>/[[:lower:]]/</tt> - Lowercase alphabetical character
-* <tt>/[[:print:]]/</tt> - Like [:graph:], but includes the space character
-* <tt>/[[:punct:]]/</tt> - Punctuation character
-* <tt>/[[:space:]]/</tt> - Whitespace character (<tt>[:blank:]</tt>, newline,
- carriage return, etc.)
-* <tt>/[[:upper:]]/</tt> - Uppercase alphabetical
-* <tt>/[[:xdigit:]]/</tt> - Digit allowed in a hexadecimal number (i.e.,
- 0-9a-fA-F)
-
-Ruby also supports the following non-POSIX character classes:
-
-* <tt>/[[:word:]]/</tt> - A character in one of the following Unicode
- general categories _Letter_, _Mark_, _Number_,
- <i>Connector_Punctuation</i>
-* <tt>/[[:ascii:]]/</tt> - A character in the ASCII character set
-
- # U+06F2 is "EXTENDED ARABIC-INDIC DIGIT TWO"
- /[[:digit:]]/.match("\u06F2") #=> #<MatchData "\u{06F2}">
- /[[:upper:]][[:lower:]]/.match("Hello") #=> #<MatchData "He">
- /[[:xdigit:]][[:xdigit:]]/.match("A6") #=> #<MatchData "A6">
-
-== Repetition
-
-The constructs described so far match a single character. They can be
-followed by a repetition metacharacter to specify how many times they need
-to occur. Such metacharacters are called <i>quantifiers</i>.
-
-* <tt>*</tt> - Zero or more times
-* <tt>+</tt> - One or more times
-* <tt>?</tt> - Zero or one times (optional)
-* <tt>{</tt><i>n</i><tt>}</tt> - Exactly <i>n</i> times
-* <tt>{</tt><i>n</i><tt>,}</tt> - <i>n</i> or more times
-* <tt>{,</tt><i>m</i><tt>}</tt> - <i>m</i> or less times
-* <tt>{</tt><i>n</i><tt>,</tt><i>m</i><tt>}</tt> - At least <i>n</i> and
- at most <i>m</i> times
-
-At least one uppercase character ('H'), at least one lowercase character
-('e'), two 'l' characters, then one 'o':
-
- "Hello".match(/[[:upper:]]+[[:lower:]]+l{2}o/) #=> #<MatchData "Hello">
-
-=== Greedy Match
-
-Repetition is <i>greedy</i> by default: as many occurrences as possible
-are matched while still allowing the overall match to succeed. By
-contrast, <i>lazy</i> matching makes the minimal amount of matches
-necessary for overall success. Most greedy metacharacters can be made lazy
-by following them with <tt>?</tt>. For the <tt>{n}</tt> pattern, because
-it specifies an exact number of characters to match and not a variable
-number of characters, the <tt>?</tt> metacharacter instead makes the
-repeated pattern optional.
-
-Both patterns below match the string. The first uses a greedy quantifier so
-'.+' matches '<a><b>'; the second uses a lazy quantifier so '.+?' matches
-'<a>':
-
- /<.+>/.match("<a><b>") #=> #<MatchData "<a><b>">
- /<.+?>/.match("<a><b>") #=> #<MatchData "<a>">
-
-=== Possessive Match
-
-A quantifier followed by <tt>+</tt> matches <i>possessively</i>: once it
-has matched it does not backtrack. They behave like greedy quantifiers,
-but having matched they refuse to "give up" their match even if this
-jeopardises the overall match.
-
- /<.*><.+>/.match("<a><b>") #=> #<MatchData "<a><b>">
- /<.*+><.+>/.match("<a><b>") #=> nil
- /<.*><.++>/.match("<a><b>") #=> nil
-
-== Capturing
-
-Parentheses can be used for <i>capturing</i>. The text enclosed by the
-<i>n</i>th group of parentheses can be subsequently referred to
-with <i>n</i>. Within a pattern use the <i>backreference</i>
-<tt>\n</tt> (e.g. <tt>\1</tt>); outside of the pattern use
-<tt>MatchData[n]</tt> (e.g. <tt>MatchData[1]</tt>).
-
-In this example, <tt>'at'</tt> is captured by the first group of
-parentheses, then referred to later with <tt>\1</tt>:
-
- /[csh](..) [csh]\1 in/.match("The cat sat in the hat")
- #=> #<MatchData "cat sat in" 1:"at">
-
-Regexp#match returns a MatchData object which makes the captured text
-available with its #[] method:
-
- /[csh](..) [csh]\1 in/.match("The cat sat in the hat")[1] #=> 'at'
-
-While Ruby supports an arbitrary number of numbered captured groups,
-only groups 1-9 are supported using the <tt>\n</tt> backreference
-syntax.
-
-Ruby also supports <tt>\0</tt> as a special backreference, which
-references the entire matched string. This is also available at
-<tt>MatchData[0]</tt>. Note that the <tt>\0</tt> backreference cannot
-be used inside the regexp, as backreferences can only be used after the
-end of the capture group, and the <tt>\0</tt> backreference uses the
-implicit capture group of the entire match. However, you can use
-this backreference when doing substitution:
-
- "The cat sat in the hat".gsub(/[csh]at/, '\0s')
- # => "The cats sats in the hats"
-
-=== Named Captures
-
-Capture groups can be referred to by name when defined with the
-<tt>(?<</tt><i>name</i><tt>>)</tt> or <tt>(?'</tt><i>name</i><tt>')</tt>
-constructs.
-
- /\$(?<dollars>\d+)\.(?<cents>\d+)/.match("$3.67")
- #=> #<MatchData "$3.67" dollars:"3" cents:"67">
- /\$(?<dollars>\d+)\.(?<cents>\d+)/.match("$3.67")[:dollars] #=> "3"
-
-Named groups can be backreferenced with <tt>\k<</tt><i>name</i><tt>></tt>,
-where _name_ is the group name.
-
- /(?<vowel>[aeiou]).\k<vowel>.\k<vowel>/.match('ototomy')
- #=> #<MatchData "ototo" vowel:"o">
-
-*Note*: A regexp can't use named backreferences and numbered
-backreferences simultaneously. Also, if a named capture is used in a
-regexp, then parentheses used for grouping which would otherwise result
-in a unnamed capture are treated as non-capturing.
-
- /(\w)(\w)/.match("ab").captures # => ["a", "b"]
- /(\w)(\w)/.match("ab").named_captures # => {}
-
- /(?<c>\w)(\w)/.match("ab").captures # => ["a"]
- /(?<c>\w)(\w)/.match("ab").named_captures # => {"c"=>"a"}
-
-When named capture groups are used with a literal regexp on the left-hand
-side of an expression and the <tt>=~</tt> operator, the captured text is
-also assigned to local variables with corresponding names.
-
- /\$(?<dollars>\d+)\.(?<cents>\d+)/ =~ "$3.67" #=> 0
- dollars #=> "3"
-
-== Grouping
-
-Parentheses also <i>group</i> the terms they enclose, allowing them to be
-quantified as one <i>atomic</i> whole.
-
-The pattern below matches a vowel followed by 2 word characters:
-
- /[aeiou]\w{2}/.match("Caenorhabditis elegans") #=> #<MatchData "aen">
-
-Whereas the following pattern matches a vowel followed by a word character,
-twice, i.e. <tt>[aeiou]\w[aeiou]\w</tt>: 'enor'.
-
- /([aeiou]\w){2}/.match("Caenorhabditis elegans")
- #=> #<MatchData "enor" 1:"or">
-
-The <tt>(?:</tt>...<tt>)</tt> construct provides grouping without
-capturing. That is, it combines the terms it contains into an atomic whole
-without creating a backreference. This benefits performance at the slight
-expense of readability.
-
-The first group of parentheses captures 'n' and the second 'ti'. The second
-group is referred to later with the backreference <tt>\2</tt>:
-
- /I(n)ves(ti)ga\2ons/.match("Investigations")
- #=> #<MatchData "Investigations" 1:"n" 2:"ti">
-
-The first group of parentheses is now made non-capturing with '?:', so it
-still matches 'n', but doesn't create the backreference. Thus, the
-backreference <tt>\1</tt> now refers to 'ti'.
-
- /I(?:n)ves(ti)ga\1ons/.match("Investigations")
- #=> #<MatchData "Investigations" 1:"ti">
-
-=== Atomic Grouping
-
-Grouping can be made <i>atomic</i> with
-<tt>(?></tt><i>pat</i><tt>)</tt>. This causes the subexpression <i>pat</i>
-to be matched independently of the rest of the expression such that what
-it matches becomes fixed for the remainder of the match, unless the entire
-subexpression must be abandoned and subsequently revisited. In this
-way <i>pat</i> is treated as a non-divisible whole. Atomic grouping is
-typically used to optimise patterns so as to prevent the regular
-expression engine from backtracking needlessly.
-
-The <tt>"</tt> in the pattern below matches the first character of the string,
-then <tt>.*</tt> matches <i>Quote"</i>. This causes the overall match to fail,
-so the text matched by <tt>.*</tt> is backtracked by one position, which
-leaves the final character of the string available to match <tt>"</tt>
-
- /".*"/.match('"Quote"') #=> #<MatchData "\"Quote\"">
-
-If <tt>.*</tt> is grouped atomically, it refuses to backtrack <i>Quote"</i>,
-even though this means that the overall match fails
-
- /"(?>.*)"/.match('"Quote"') #=> nil
-
-== Subexpression Calls
-
-The <tt>\g<</tt><i>name</i><tt>></tt> syntax matches the previous
-subexpression named _name_, which can be a group name or number, again.
-This differs from backreferences in that it re-executes the group rather
-than simply trying to re-match the same text.
-
-This pattern matches a <i>(</i> character and assigns it to the <tt>paren</tt>
-group, tries to call that the <tt>paren</tt> sub-expression again but fails,
-then matches a literal <i>)</i>:
-
- /\A(?<paren>\(\g<paren>*\))*\z/ =~ '()'
-
-
- /\A(?<paren>\(\g<paren>*\))*\z/ =~ '(())' #=> 0
- # ^1
- # ^2
- # ^3
- # ^4
- # ^5
- # ^6
- # ^7
- # ^8
- # ^9
- # ^10
-
-1. Matches at the beginning of the string, i.e. before the first
- character.
-2. Enters a named capture group called <tt>paren</tt>
-3. Matches a literal <i>(</i>, the first character in the string
-4. Calls the <tt>paren</tt> group again, i.e. recurses back to the
- second step
-5. Re-enters the <tt>paren</tt> group
-6. Matches a literal <i>(</i>, the second character in the
- string
-7. Try to call <tt>paren</tt> a third time, but fail because
- doing so would prevent an overall successful match
-8. Match a literal <i>)</i>, the third character in the string.
- Marks the end of the second recursive call
-9. Match a literal <i>)</i>, the fourth character in the string
-10. Match the end of the string
-
-== Alternation
-
-The vertical bar metacharacter (<tt>|</tt>) combines several expressions into
-a single one that matches any of the expressions. Each expression is an
-<i>alternative</i>.
-
- /\w(and|or)\w/.match("Feliformia") #=> #<MatchData "form" 1:"or">
- /\w(and|or)\w/.match("furandi") #=> #<MatchData "randi" 1:"and">
- /\w(and|or)\w/.match("dissemblance") #=> nil
-
-== Condition
-
-The <tt>(?(</tt><i>cond</i><tt>)</tt><i>yes</i><tt>|</tt><i>no</i><tt>)</tt>
-syntax matches _yes_ part if _cond_ is captured, otherwise matches _no_ part.
-In the case _no_ part is empty, also <tt>|</tt> can be omitted.
-
-The _cond_ may be a backreference number or a captured name. A backreference
-number is an absolute position, but can not be a relative position.
-
-== Character Properties
-
-The <tt>\p{}</tt> construct matches characters with the named property,
-much like POSIX bracket classes.
-
-* <tt>/\p{Alnum}/</tt> - Alphabetic and numeric character
-* <tt>/\p{Alpha}/</tt> - Alphabetic character
-* <tt>/\p{Blank}/</tt> - Space or tab
-* <tt>/\p{Cntrl}/</tt> - Control character
-* <tt>/\p{Digit}/</tt> - Digit
-* <tt>/\p{Emoji}/</tt> - Unicode emoji
-* <tt>/\p{Graph}/</tt> - Non-blank character (excludes spaces, control
- characters, and similar)
-* <tt>/\p{Lower}/</tt> - Lowercase alphabetical character
-* <tt>/\p{Print}/</tt> - Like <tt>\p{Graph}</tt>, but includes the space character
-* <tt>/\p{Punct}/</tt> - Punctuation character
-* <tt>/\p{Space}/</tt> - Whitespace character (<tt>[:blank:]</tt>, newline,
- carriage return, etc.)
-* <tt>/\p{Upper}/</tt> - Uppercase alphabetical
-* <tt>/\p{XDigit}/</tt> - Digit allowed in a hexadecimal number (i.e., 0-9a-fA-F)
-* <tt>/\p{Word}/</tt> - A member of one of the following Unicode general
- category <i>Letter</i>, <i>Mark</i>, <i>Number</i>,
- <i>Connector\_Punctuation</i>
-* <tt>/\p{ASCII}/</tt> - A character in the ASCII character set
-* <tt>/\p{Any}/</tt> - Any Unicode character (including unassigned
- characters)
-* <tt>/\p{Assigned}/</tt> - An assigned character
-
-A Unicode character's <i>General Category</i> value can also be matched
-with <tt>\p{</tt><i>Ab</i><tt>}</tt> where <i>Ab</i> is the category's
-abbreviation as described below:
-
-* <tt>/\p{L}/</tt> - 'Letter'
-* <tt>/\p{Ll}/</tt> - 'Letter: Lowercase'
-* <tt>/\p{Lm}/</tt> - 'Letter: Mark'
-* <tt>/\p{Lo}/</tt> - 'Letter: Other'
-* <tt>/\p{Lt}/</tt> - 'Letter: Titlecase'
-* <tt>/\p{Lu}/</tt> - 'Letter: Uppercase
-* <tt>/\p{Lo}/</tt> - 'Letter: Other'
-* <tt>/\p{M}/</tt> - 'Mark'
-* <tt>/\p{Mn}/</tt> - 'Mark: Nonspacing'
-* <tt>/\p{Mc}/</tt> - 'Mark: Spacing Combining'
-* <tt>/\p{Me}/</tt> - 'Mark: Enclosing'
-* <tt>/\p{N}/</tt> - 'Number'
-* <tt>/\p{Nd}/</tt> - 'Number: Decimal Digit'
-* <tt>/\p{Nl}/</tt> - 'Number: Letter'
-* <tt>/\p{No}/</tt> - 'Number: Other'
-* <tt>/\p{P}/</tt> - 'Punctuation'
-* <tt>/\p{Pc}/</tt> - 'Punctuation: Connector'
-* <tt>/\p{Pd}/</tt> - 'Punctuation: Dash'
-* <tt>/\p{Ps}/</tt> - 'Punctuation: Open'
-* <tt>/\p{Pe}/</tt> - 'Punctuation: Close'
-* <tt>/\p{Pi}/</tt> - 'Punctuation: Initial Quote'
-* <tt>/\p{Pf}/</tt> - 'Punctuation: Final Quote'
-* <tt>/\p{Po}/</tt> - 'Punctuation: Other'
-* <tt>/\p{S}/</tt> - 'Symbol'
-* <tt>/\p{Sm}/</tt> - 'Symbol: Math'
-* <tt>/\p{Sc}/</tt> - 'Symbol: Currency'
-* <tt>/\p{Sc}/</tt> - 'Symbol: Currency'
-* <tt>/\p{Sk}/</tt> - 'Symbol: Modifier'
-* <tt>/\p{So}/</tt> - 'Symbol: Other'
-* <tt>/\p{Z}/</tt> - 'Separator'
-* <tt>/\p{Zs}/</tt> - 'Separator: Space'
-* <tt>/\p{Zl}/</tt> - 'Separator: Line'
-* <tt>/\p{Zp}/</tt> - 'Separator: Paragraph'
-* <tt>/\p{C}/</tt> - 'Other'
-* <tt>/\p{Cc}/</tt> - 'Other: Control'
-* <tt>/\p{Cf}/</tt> - 'Other: Format'
-* <tt>/\p{Cn}/</tt> - 'Other: Not Assigned'
-* <tt>/\p{Co}/</tt> - 'Other: Private Use'
-* <tt>/\p{Cs}/</tt> - 'Other: Surrogate'
-
-Lastly, <tt>\p{}</tt> matches a character's Unicode <i>script</i>. The
-following scripts are supported: <i>Arabic</i>, <i>Armenian</i>,
-<i>Balinese</i>, <i>Bengali</i>, <i>Bopomofo</i>, <i>Braille</i>,
-<i>Buginese</i>, <i>Buhid</i>, <i>Canadian_Aboriginal</i>, <i>Carian</i>,
-<i>Cham</i>, <i>Cherokee</i>, <i>Common</i>, <i>Coptic</i>,
-<i>Cuneiform</i>, <i>Cypriot</i>, <i>Cyrillic</i>, <i>Deseret</i>,
-<i>Devanagari</i>, <i>Ethiopic</i>, <i>Georgian</i>, <i>Glagolitic</i>,
-<i>Gothic</i>, <i>Greek</i>, <i>Gujarati</i>, <i>Gurmukhi</i>, <i>Han</i>,
-<i>Hangul</i>, <i>Hanunoo</i>, <i>Hebrew</i>, <i>Hiragana</i>,
-<i>Inherited</i>, <i>Kannada</i>, <i>Katakana</i>, <i>Kayah_Li</i>,
-<i>Kharoshthi</i>, <i>Khmer</i>, <i>Lao</i>, <i>Latin</i>, <i>Lepcha</i>,
-<i>Limbu</i>, <i>Linear_B</i>, <i>Lycian</i>, <i>Lydian</i>,
-<i>Malayalam</i>, <i>Mongolian</i>, <i>Myanmar</i>, <i>New_Tai_Lue</i>,
-<i>Nko</i>, <i>Ogham</i>, <i>Ol_Chiki</i>, <i>Old_Italic</i>,
-<i>Old_Persian</i>, <i>Oriya</i>, <i>Osmanya</i>, <i>Phags_Pa</i>,
-<i>Phoenician</i>, <i>Rejang</i>, <i>Runic</i>, <i>Saurashtra</i>,
-<i>Shavian</i>, <i>Sinhala</i>, <i>Sundanese</i>, <i>Syloti_Nagri</i>,
-<i>Syriac</i>, <i>Tagalog</i>, <i>Tagbanwa</i>, <i>Tai_Le</i>,
-<i>Tamil</i>, <i>Telugu</i>, <i>Thaana</i>, <i>Thai</i>, <i>Tibetan</i>,
-<i>Tifinagh</i>, <i>Ugaritic</i>, <i>Vai</i>, and <i>Yi</i>.
-
-Unicode codepoint U+06E9 is named "ARABIC PLACE OF SAJDAH" and belongs to the
-Arabic script:
-
- /\p{Arabic}/.match("\u06E9") #=> #<MatchData "\u06E9">
-
-All character properties can be inverted by prefixing their name with a
-caret (<tt>^</tt>).
-
-Letter 'A' is not in the Unicode Ll (Letter; Lowercase) category, so this
-match succeeds:
-
- /\p{^Ll}/.match("A") #=> #<MatchData "A">
-
-== Anchors
-
-Anchors are metacharacter that match the zero-width positions between
-characters, <i>anchoring</i> the match to a specific position.
-
-* <tt>^</tt> - Matches beginning of line
-* <tt>$</tt> - Matches end of line
-* <tt>\A</tt> - Matches beginning of string.
-* <tt>\Z</tt> - Matches end of string. If string ends with a newline,
- it matches just before newline
-* <tt>\z</tt> - Matches end of string
-* <tt>\G</tt> - Matches first matching position:
-
- In methods like <tt>String#gsub</tt> and <tt>String#scan</tt>, it changes on each iteration.
- It initially matches the beginning of subject, and in each following iteration it matches where the last match finished.
-
- " a b c".gsub(/ /, '_') #=> "____a_b_c"
- " a b c".gsub(/\G /, '_') #=> "____a b c"
-
- In methods like <tt>Regexp#match</tt> and <tt>String#match</tt> that take an (optional) offset, it matches where the search begins.
-
- "hello, world".match(/,/, 3) #=> #<MatchData ",">
- "hello, world".match(/\G,/, 3) #=> nil
-
-* <tt>\b</tt> - Matches word boundaries when outside brackets;
- backspace (0x08) when inside brackets
-* <tt>\B</tt> - Matches non-word boundaries
-* <tt>(?=</tt><i>pat</i><tt>)</tt> - <i>Positive lookahead</i> assertion:
- ensures that the following characters match <i>pat</i>, but doesn't
- include those characters in the matched text
-* <tt>(?!</tt><i>pat</i><tt>)</tt> - <i>Negative lookahead</i> assertion:
- ensures that the following characters do not match <i>pat</i>, but
- doesn't include those characters in the matched text
-* <tt>(?<=</tt><i>pat</i><tt>)</tt> - <i>Positive lookbehind</i>
- assertion: ensures that the preceding characters match <i>pat</i>, but
- doesn't include those characters in the matched text
-* <tt>(?<!</tt><i>pat</i><tt>)</tt> - <i>Negative lookbehind</i>
- assertion: ensures that the preceding characters do not match
- <i>pat</i>, but doesn't include those characters in the matched text
-
-* <tt>\K</tt> - <i>Match reset</i>: the matched content preceding
- <tt>\K</tt> in the regexp is excluded from the result. For example,
- the following two regexps are almost equivalent:
-
- /ab\Kc/ =~ "abc" #=> 0
- /(?<=ab)c/ =~ "abc" #=> 2
-
- These match same string and <i>$&</i> equals <tt>"c"</tt>, while the
- matched position is different.
-
- As are the following two regexps:
-
- /(a)\K(b)\Kc/
- /(?<=(?<=(a))(b))c/
-
-If a pattern isn't anchored it can begin at any point in the string:
-
- /real/.match("surrealist") #=> #<MatchData "real">
-
-Anchoring the pattern to the beginning of the string forces the match to start
-there. 'real' doesn't occur at the beginning of the string, so now the match
-fails:
-
- /\Areal/.match("surrealist") #=> nil
-
-The match below fails because although 'Demand' contains 'and', the pattern
-does not occur at a word boundary.
-
- /\band/.match("Demand")
-
-Whereas in the following example 'and' has been anchored to a non-word
-boundary so instead of matching the first 'and' it matches from the fourth
-letter of 'demand' instead:
-
- /\Band.+/.match("Supply and demand curve") #=> #<MatchData "and curve">
-
-The pattern below uses positive lookahead and positive lookbehind to match
-text appearing in <b></b> tags without including the tags in the match:
-
- /(?<=<b>)\w+(?=<\/b>)/.match("Fortune favours the <b>bold</b>")
- #=> #<MatchData "bold">
-
-== Options
-
-The end delimiter for a regexp can be followed by one or more single-letter
-options which control how the pattern can match.
-
-* <tt>/pat/i</tt> - Ignore case
-* <tt>/pat/m</tt> - Treat a newline as a character matched by <tt>.</tt>
-* <tt>/pat/x</tt> - Ignore whitespace and comments in the pattern
-* <tt>/pat/o</tt> - Perform <tt>#{}</tt> interpolation only once
-
-<tt>i</tt>, <tt>m</tt>, and <tt>x</tt> can also be applied on the
-subexpression level with the
-<tt>(?</tt><i>on</i><tt>-</tt><i>off</i><tt>)</tt> construct, which
-enables options <i>on</i>, and disables options <i>off</i> for the
-expression enclosed by the parentheses:
-
- /a(?i:b)c/.match('aBc') #=> #<MatchData "aBc">
- /a(?-i:b)c/i.match('ABC') #=> nil
-
-Additionally, these options can also be toggled for the remainder of the
-pattern:
-
- /a(?i)bc/.match('abC') #=> #<MatchData "abC">
-
-Options may also be used with <tt>Regexp.new</tt>:
-
- Regexp.new("abc", Regexp::IGNORECASE) #=> /abc/i
- Regexp.new("abc", Regexp::MULTILINE) #=> /abc/m
- Regexp.new("abc # Comment", Regexp::EXTENDED) #=> /abc # Comment/x
- Regexp.new("abc", Regexp::IGNORECASE | Regexp::MULTILINE) #=> /abc/mi
-
- Regexp.new("abc", "i") #=> /abc/i
- Regexp.new("abc", "m") #=> /abc/m
- Regexp.new("abc # Comment", "x") #=> /abc # Comment/x
- Regexp.new("abc", "im") #=> /abc/mi
-
-== Free-Spacing Mode and Comments
-
-As mentioned above, the <tt>x</tt> option enables <i>free-spacing</i>
-mode. Literal white space inside the pattern is ignored, and the
-octothorpe (<tt>#</tt>) character introduces a comment until the end of
-the line. This allows the components of the pattern to be organized in a
-potentially more readable fashion.
-
-A contrived pattern to match a number with optional decimal places:
-
- float_pat = /\A
- [[:digit:]]+ # 1 or more digits before the decimal point
- (\. # Decimal point
- [[:digit:]]+ # 1 or more digits after the decimal point
- )? # The decimal point and following digits are optional
- \Z/x
- float_pat.match('3.14') #=> #<MatchData "3.14" 1:".14">
-
-There are a number of strategies for matching whitespace:
-
-* Use a pattern such as <tt>\s</tt> or <tt>\p{Space}</tt>.
-* Use escaped whitespace such as <tt>\ </tt>, i.e. a space preceded by a backslash.
-* Use a character class such as <tt>[ ]</tt>.
-
-Comments can be included in a non-<tt>x</tt> pattern with the
-<tt>(?#</tt><i>comment</i><tt>)</tt> construct, where <i>comment</i> is
-arbitrary text ignored by the regexp engine.
-
-Comments in regexp literals cannot include unescaped terminator
-characters.
-
-== Encoding
-
-Regular expressions are assumed to use the source encoding. This can be
-overridden with one of the following modifiers.
-
-* <tt>/</tt><i>pat</i><tt>/u</tt> - UTF-8
-* <tt>/</tt><i>pat</i><tt>/e</tt> - EUC-JP
-* <tt>/</tt><i>pat</i><tt>/s</tt> - Windows-31J
-* <tt>/</tt><i>pat</i><tt>/n</tt> - ASCII-8BIT
-
-A regexp can be matched against a string when they either share an
-encoding, or the regexp's encoding is _US-ASCII_ and the string's encoding
-is ASCII-compatible.
-
-If a match between incompatible encodings is attempted an
-<tt>Encoding::CompatibilityError</tt> exception is raised.
-
-The <tt>Regexp#fixed_encoding?</tt> predicate indicates whether the regexp
-has a <i>fixed</i> encoding, that is one incompatible with ASCII. A
-regexp's encoding can be explicitly fixed by supplying
-<tt>Regexp::FIXEDENCODING</tt> as the second argument of
-<tt>Regexp.new</tt>:
-
- r = Regexp.new("a".force_encoding("iso-8859-1"),Regexp::FIXEDENCODING)
- r =~ "a\u3042"
- # raises Encoding::CompatibilityError: incompatible encoding regexp match
- # (ISO-8859-1 regexp with UTF-8 string)
-
-== \Regexp Global Variables
-
-Pattern matching sets some global variables :
-
-* <tt>$~</tt> is equivalent to Regexp.last_match;
-* <tt>$&</tt> contains the complete matched text;
-* <tt>$`</tt> contains string before match;
-* <tt>$'</tt> contains string after match;
-* <tt>$1</tt>, <tt>$2</tt> and so on contain text matching first, second, etc
- capture group;
-* <tt>$+</tt> contains last capture group.
-
-Example:
-
- m = /s(\w{2}).*(c)/.match('haystack') #=> #<MatchData "stac" 1:"ta" 2:"c">
- $~ #=> #<MatchData "stac" 1:"ta" 2:"c">
- Regexp.last_match #=> #<MatchData "stac" 1:"ta" 2:"c">
-
- $& #=> "stac"
- # same as m[0]
- $` #=> "hay"
- # same as m.pre_match
- $' #=> "k"
- # same as m.post_match
- $1 #=> "ta"
- # same as m[1]
- $2 #=> "c"
- # same as m[2]
- $3 #=> nil
- # no third group in pattern
- $+ #=> "c"
- # same as m[-1]
-
-These global variables are thread-local and method-local variables.
-
-== Performance
-
-Certain pathological combinations of constructs can lead to abysmally bad
-performance.
-
-Consider a string of 25 <i>a</i>s, a <i>d</i>, 4 <i>a</i>s, and a
-<i>c</i>.
-
- s = 'a' * 25 + 'd' + 'a' * 4 + 'c'
- #=> "aaaaaaaaaaaaaaaaaaaaaaaaadaaaac"
-
-The following patterns match instantly as you would expect:
-
- /(b|a)/ =~ s #=> 0
- /(b|a+)/ =~ s #=> 0
- /(b|a+)*/ =~ s #=> 0
-
-However, the following pattern takes appreciably longer:
-
- /(b|a+)*c/ =~ s #=> 26
-
-This happens because an atom in the regexp is quantified by both an
-immediate <tt>+</tt> and an enclosing <tt>*</tt> with nothing to
-differentiate which is in control of any particular character. The
-nondeterminism that results produces super-linear performance. (Consult
-<i>Mastering Regular Expressions</i> (3rd ed.), pp 222, by
-<i>Jeffery Friedl</i>, for an in-depth analysis). This particular case
-can be fixed by use of atomic grouping, which prevents the unnecessary
-backtracking:
-
- (start = Time.now) && /(b|a+)*c/ =~ s && (Time.now - start)
- #=> 24.702736882
- (start = Time.now) && /(?>b|a+)*c/ =~ s && (Time.now - start)
- #=> 0.000166571
-
-A similar case is typified by the following example, which takes
-approximately 60 seconds to execute for me:
-
-Match a string of 29 <i>a</i>s against a pattern of 29 optional <i>a</i>s
-followed by 29 mandatory <i>a</i>s:
-
- Regexp.new('a?' * 29 + 'a' * 29) =~ 'a' * 29
-
-The 29 optional <i>a</i>s match the string, but this prevents the 29
-mandatory <i>a</i>s that follow from matching. Ruby must then backtrack
-repeatedly so as to satisfy as many of the optional matches as it can
-while still matching the mandatory 29. It is plain to us that none of the
-optional matches can succeed, but this fact unfortunately eludes Ruby.
-
-The best way to improve performance is to significantly reduce the amount of
-backtracking needed. For this case, instead of individually matching 29
-optional <i>a</i>s, a range of optional <i>a</i>s can be matched all at once
-with <i>a{0,29}</i>:
-
- Regexp.new('a{0,29}' + 'a' * 29) =~ 'a' * 29
-
-== Timeout
-
-There are two APIs to set timeout. One is Regexp.timeout=, which is
-process-global configuration of timeout for Regexp matching.
-
- Regexp.timeout = 3
- s = 'a' * 25 + 'd' + 'a' * 4 + 'c'
- /(b|a+)*c/ =~ s #=> This raises an exception in three seconds
-
-The other is timeout keyword of Regexp.new.
-
- re = Regexp.new("(b|a+)*c", timeout: 3)
- s = 'a' * 25 + 'd' + 'a' * 4 + 'c'
- /(b|a+)*c/ =~ s #=> This raises an exception in three seconds
-
-When using Regexps to process untrusted input, you should use the timeout
-feature to avoid excessive backtracking. Otherwise, a malicious user can
-provide input to Regexp causing Denial-of-Service attack.
-Note that the timeout is not set by default because an appropriate limit
-highly depends on an application requirement and context.
diff --git a/doc/regexp/methods.rdoc b/doc/regexp/methods.rdoc
new file mode 100644
index 0000000000..356156ac9a
--- /dev/null
+++ b/doc/regexp/methods.rdoc
@@ -0,0 +1,41 @@
+== \Regexp Methods
+
+Each of these Ruby core methods can accept a regexp as an argument:
+
+- Enumerable#all?
+- Enumerable#any?
+- Enumerable#grep
+- Enumerable#grep_v
+- Enumerable#none?
+- Enumerable#one?
+- Enumerable#slice_after
+- Enumerable#slice_before
+- Regexp#=~
+- Regexp#match
+- Regexp#match?
+- Regexp.new
+- Regexp.union
+- String#=~
+- String#[]=
+- String#byteindex
+- String#byterindex
+- String#gsub
+- String#gsub!
+- String#index
+- String#match
+- String#match?
+- String#partition
+- String#rindex
+- String#rpartition
+- String#scan
+- String#slice
+- String#slice!
+- String#split
+- String#start_with?
+- String#sub
+- String#sub!
+- Symbol#=~
+- Symbol#match
+- Symbol#match?
+- Symbol#slice
+- Symbol#start_with?
diff --git a/doc/regexp/unicode_properties.rdoc b/doc/regexp/unicode_properties.rdoc
new file mode 100644
index 0000000000..a1d7ecc380
--- /dev/null
+++ b/doc/regexp/unicode_properties.rdoc
@@ -0,0 +1,678 @@
+== \Regexps Based on Unicode Properties
+
+The properties shown here are those currently supported in Ruby.
+Older versions may not support all of these.
+
+=== POSIX brackets
+
+- <tt>\p{ASCII}</tt>
+- <tt>\p{Alnum}</tt>
+- <tt>\p{Alphabetic}</tt>, <tt>\p{Alpha}</tt>
+- <tt>\p{Blank}</tt>
+- <tt>\p{Cntrl}</tt>
+- <tt>\p{Digit}</tt>
+- <tt>\p{Graph}</tt>
+- <tt>\p{Lowercase}</tt>, <tt>\p{Lower}</tt>
+- <tt>\p{Print}</tt>
+- <tt>\p{Punct}</tt>
+- <tt>\p{Space}</tt>
+- <tt>\p{Uppercase}</tt>, <tt>\p{Upper}</tt>
+- <tt>\p{Word}</tt>
+- <tt>\p{XDigit}</tt>
+- <tt>\p{XPosixPunct}</tt>
+
+=== Special
+
+- <tt>\p{Any}</tt>
+- <tt>\p{Assigned}</tt>
+
+=== Major and General Categories
+
+- <tt>\p{Cased_Letter}</tt>, <tt>\p{LC}</tt>
+- <tt>\p{Close_Punctuation}</tt>, <tt>\p{Pe}</tt>
+- <tt>\p{Connector_Punctuation}</tt>, <tt>\p{Pc}</tt>
+- <tt>\p{Control}</tt>, <tt>\p{Cc}</tt>
+- <tt>\p{Currency_Symbol}</tt>, <tt>\p{Sc}</tt>
+- <tt>\p{Dash_Punctuation}</tt>, <tt>\p{Pd}</tt>
+- <tt>\p{Decimal_Number}</tt>, <tt>\p{Nd}</tt>
+- <tt>\p{Enclosing_Mark}</tt>, <tt>\p{Me}</tt>
+- <tt>\p{Final_Punctuation}</tt>, <tt>\p{Pf}</tt>
+- <tt>\p{Format}</tt>, <tt>\p{Cf}</tt>
+- <tt>\p{Initial_Punctuation}</tt>, <tt>\p{Pi}</tt>
+- <tt>\p{Letter}</tt>, <tt>\p{L}</tt>
+- <tt>\p{Letter_Number}</tt>, <tt>\p{Nl}</tt>
+- <tt>\p{Line_Separator}</tt>, <tt>\p{Zl}</tt>
+- <tt>\p{Lowercase_Letter}</tt>, <tt>\p{Ll}</tt>
+- <tt>\p{Mark}</tt>, <tt>\p{M}</tt>
+- <tt>\p{Math_Symbol}</tt>, <tt>\p{Sm}</tt>
+- <tt>\p{Modifier_Letter}</tt>, <tt>\p{Lm}</tt>
+- <tt>\p{Modifier_Symbol}</tt>, <tt>\p{Sk}</tt>
+- <tt>\p{Nonspacing_Mark}</tt>, <tt>\p{Mn}</tt>
+- <tt>\p{Number}</tt>, <tt>\p{N}</tt>
+- <tt>\p{Open_Punctuation}</tt>, <tt>\p{Ps}</tt>
+- <tt>\p{Other}</tt>, <tt>\p{C}</tt>
+- <tt>\p{Other_Letter}</tt>, <tt>\p{Lo}</tt>
+- <tt>\p{Other_Number}</tt>, <tt>\p{No}</tt>
+- <tt>\p{Other_Punctuation}</tt>, <tt>\p{Po}</tt>
+- <tt>\p{Other_Symbol}</tt>, <tt>\p{So}</tt>
+- <tt>\p{Paragraph_Separator}</tt>, <tt>\p{Zp}</tt>
+- <tt>\p{Private_Use}</tt>, <tt>\p{Co}</tt>
+- <tt>\p{Punctuation}</tt>, <tt>\p{P}</tt>
+- <tt>\p{Separator}</tt>, <tt>\p{Z}</tt>
+- <tt>\p{Space_Separator}</tt>, <tt>\p{Zs}</tt>
+- <tt>\p{Spacing_Mark}</tt>, <tt>\p{Mc}</tt>
+- <tt>\p{Surrogate}</tt>, <tt>\p{Cs}</tt>
+- <tt>\p{Symbol}</tt>, <tt>\p{S}</tt>
+- <tt>\p{Titlecase_Letter}</tt>, <tt>\p{Lt}</tt>
+- <tt>\p{Unassigned}</tt>, <tt>\p{Cn}</tt>
+- <tt>\p{Uppercase_Letter}</tt>, <tt>\p{Lu}</tt>
+
+=== Prop List
+
+- <tt>\p{ASCII_Hex_Digit}</tt>, <tt>\p{AHex}</tt>
+- <tt>\p{Bidi_Control}</tt>, <tt>\p{Bidi_C}</tt>
+- <tt>\p{Dash}</tt>
+- <tt>\p{Deprecated}</tt>, <tt>\p{Dep}</tt>
+- <tt>\p{Diacritic}</tt>, <tt>\p{Dia}</tt>
+- <tt>\p{Extender}</tt>, <tt>\p{Ext}</tt>
+- <tt>\p{Hex_Digit}</tt>, <tt>\p{Hex}</tt>
+- <tt>\p{Hyphen}</tt>
+- <tt>\p{IDS_Binary_Operator}</tt>, <tt>\p{IDSB}</tt>
+- <tt>\p{IDS_Trinary_Operator}</tt>, <tt>\p{IDST}</tt>
+- <tt>\p{Ideographic}</tt>, <tt>\p{Ideo}</tt>
+- <tt>\p{Join_Control}</tt>, <tt>\p{Join_C}</tt>
+- <tt>\p{Logical_Order_Exception}</tt>, <tt>\p{LOE}</tt>
+- <tt>\p{Noncharacter_Code_Point}</tt>, <tt>\p{NChar}</tt>
+- <tt>\p{Other_Alphabetic}</tt>, <tt>\p{OAlpha}</tt>
+- <tt>\p{Other_Default_Ignorable_Code_Point}</tt>, <tt>\p{ODI}</tt>
+- <tt>\p{Other_Grapheme_Extend}</tt>, <tt>\p{OGr_Ext}</tt>
+- <tt>\p{Other_ID_Continue}</tt>, <tt>\p{OIDC}</tt>
+- <tt>\p{Other_ID_Start}</tt>, <tt>\p{OIDS}</tt>
+- <tt>\p{Other_Lowercase}</tt>, <tt>\p{OLower}</tt>
+- <tt>\p{Other_Math}</tt>, <tt>\p{OMath}</tt>
+- <tt>\p{Other_Uppercase}</tt>, <tt>\p{OUpper}</tt>
+- <tt>\p{Pattern_Syntax}</tt>, <tt>\p{Pat_Syn}</tt>
+- <tt>\p{Pattern_White_Space}</tt>, <tt>\p{Pat_WS}</tt>
+- <tt>\p{Prepended_Concatenation_Mark}</tt>, <tt>\p{PCM}</tt>
+- <tt>\p{Quotation_Mark}</tt>, <tt>\p{QMark}</tt>
+- <tt>\p{Radical}</tt>
+- <tt>\p{Regional_Indicator}</tt>, <tt>\p{RI}</tt>
+- <tt>\p{Sentence_Terminal}</tt>, <tt>\p{STerm}</tt>
+- <tt>\p{Soft_Dotted}</tt>, <tt>\p{SD}</tt>
+- <tt>\p{Terminal_Punctuation}</tt>, <tt>\p{Term}</tt>
+- <tt>\p{Unified_Ideograph}</tt>, <tt>\p{UIdeo}</tt>
+- <tt>\p{Variation_Selector}</tt>, <tt>\p{VS}</tt>
+- <tt>\p{White_Space}</tt>, <tt>\p{WSpace}</tt>
+
+=== Derived Core Properties
+
+- <tt>\p{Alphabetic}</tt>, <tt>\p{Alpha}</tt>
+- <tt>\p{Case_Ignorable}</tt>, <tt>\p{CI}</tt>
+- <tt>\p{Cased}</tt>
+- <tt>\p{Changes_When_Casefolded}</tt>, <tt>\p{CWCF}</tt>
+- <tt>\p{Changes_When_Casemapped}</tt>, <tt>\p{CWCM}</tt>
+- <tt>\p{Changes_When_Lowercased}</tt>, <tt>\p{CWL}</tt>
+- <tt>\p{Changes_When_Titlecased}</tt>, <tt>\p{CWT}</tt>
+- <tt>\p{Changes_When_Uppercased}</tt>, <tt>\p{CWU}</tt>
+- <tt>\p{Default_Ignorable_Code_Point}</tt>, <tt>\p{DI}</tt>
+- <tt>\p{Grapheme_Base}</tt>, <tt>\p{Gr_Base}</tt>
+- <tt>\p{Grapheme_Extend}</tt>, <tt>\p{Gr_Ext}</tt>
+- <tt>\p{Grapheme_Link}</tt>, <tt>\p{Gr_Link}</tt>
+- <tt>\p{ID_Continue}</tt>, <tt>\p{IDC}</tt>
+- <tt>\p{ID_Start}</tt>, <tt>\p{IDS}</tt>
+- <tt>\p{Lowercase}</tt>, <tt>\p{Lower}</tt>
+- <tt>\p{Math}</tt>
+- <tt>\p{Uppercase}</tt>, <tt>\p{Upper}</tt>
+- <tt>\p{XID_Continue}</tt>, <tt>\p{XIDC}</tt>
+- <tt>\p{XID_Start}</tt>, <tt>\p{XIDS}</tt>
+
+=== Scripts
+
+- <tt>\p{Adlam}</tt>, <tt>\p{Adlm}</tt>
+- <tt>\p{Ahom}</tt>
+- <tt>\p{Anatolian_Hieroglyphs}</tt>, <tt>\p{Hluw}</tt>
+- <tt>\p{Arabic}</tt>, <tt>\p{Arab}</tt>
+- <tt>\p{Armenian}</tt>, <tt>\p{Armn}</tt>
+- <tt>\p{Avestan}</tt>, <tt>\p{Avst}</tt>
+- <tt>\p{Balinese}</tt>, <tt>\p{Bali}</tt>
+- <tt>\p{Bamum}</tt>, <tt>\p{Bamu}</tt>
+- <tt>\p{Bassa_Vah}</tt>, <tt>\p{Bass}</tt>
+- <tt>\p{Batak}</tt>, <tt>\p{Batk}</tt>
+- <tt>\p{Bengali}</tt>, <tt>\p{Beng}</tt>
+- <tt>\p{Bhaiksuki}</tt>, <tt>\p{Bhks}</tt>
+- <tt>\p{Bopomofo}</tt>, <tt>\p{Bopo}</tt>
+- <tt>\p{Brahmi}</tt>, <tt>\p{Brah}</tt>
+- <tt>\p{Braille}</tt>, <tt>\p{Brai}</tt>
+- <tt>\p{Buginese}</tt>, <tt>\p{Bugi}</tt>
+- <tt>\p{Buhid}</tt>, <tt>\p{Buhd}</tt>
+- <tt>\p{Canadian_Aboriginal}</tt>, <tt>\p{Cans}</tt>
+- <tt>\p{Carian}</tt>, <tt>\p{Cari}</tt>
+- <tt>\p{Caucasian_Albanian}</tt>, <tt>\p{Aghb}</tt>
+- <tt>\p{Chakma}</tt>, <tt>\p{Cakm}</tt>
+- <tt>\p{Cham}</tt>
+- <tt>\p{Cherokee}</tt>, <tt>\p{Cher}</tt>
+- <tt>\p{Chorasmian}</tt>, <tt>\p{Chrs}</tt>
+- <tt>\p{Common}</tt>, <tt>\p{Zyyy}</tt>
+- <tt>\p{Coptic}</tt>, <tt>\p{Copt}</tt>
+- <tt>\p{Cuneiform}</tt>, <tt>\p{Xsux}</tt>
+- <tt>\p{Cypriot}</tt>, <tt>\p{Cprt}</tt>
+- <tt>\p{Cypro_Minoan}</tt>, <tt>\p{Cpmn}</tt>
+- <tt>\p{Cyrillic}</tt>, <tt>\p{Cyrl}</tt>
+- <tt>\p{Deseret}</tt>, <tt>\p{Dsrt}</tt>
+- <tt>\p{Devanagari}</tt>, <tt>\p{Deva}</tt>
+- <tt>\p{Dives_Akuru}</tt>, <tt>\p{Diak}</tt>
+- <tt>\p{Dogra}</tt>, <tt>\p{Dogr}</tt>
+- <tt>\p{Duployan}</tt>, <tt>\p{Dupl}</tt>
+- <tt>\p{Egyptian_Hieroglyphs}</tt>, <tt>\p{Egyp}</tt>
+- <tt>\p{Elbasan}</tt>, <tt>\p{Elba}</tt>
+- <tt>\p{Elymaic}</tt>, <tt>\p{Elym}</tt>
+- <tt>\p{Ethiopic}</tt>, <tt>\p{Ethi}</tt>
+- <tt>\p{Georgian}</tt>, <tt>\p{Geor}</tt>
+- <tt>\p{Glagolitic}</tt>, <tt>\p{Glag}</tt>
+- <tt>\p{Gothic}</tt>, <tt>\p{Goth}</tt>
+- <tt>\p{Grantha}</tt>, <tt>\p{Gran}</tt>
+- <tt>\p{Greek}</tt>, <tt>\p{Grek}</tt>
+- <tt>\p{Gujarati}</tt>, <tt>\p{Gujr}</tt>
+- <tt>\p{Gunjala_Gondi}</tt>, <tt>\p{Gong}</tt>
+- <tt>\p{Gurmukhi}</tt>, <tt>\p{Guru}</tt>
+- <tt>\p{Han}</tt>, <tt>\p{Hani}</tt>
+- <tt>\p{Hangul}</tt>, <tt>\p{Hang}</tt>
+- <tt>\p{Hanifi_Rohingya}</tt>, <tt>\p{Rohg}</tt>
+- <tt>\p{Hanunoo}</tt>, <tt>\p{Hano}</tt>
+- <tt>\p{Hatran}</tt>, <tt>\p{Hatr}</tt>
+- <tt>\p{Hebrew}</tt>, <tt>\p{Hebr}</tt>
+- <tt>\p{Hiragana}</tt>, <tt>\p{Hira}</tt>
+- <tt>\p{Imperial_Aramaic}</tt>, <tt>\p{Armi}</tt>
+- <tt>\p{Inherited}</tt>, <tt>\p{Zinh}</tt>
+- <tt>\p{Inscriptional_Pahlavi}</tt>, <tt>\p{Phli}</tt>
+- <tt>\p{Inscriptional_Parthian}</tt>, <tt>\p{Prti}</tt>
+- <tt>\p{Javanese}</tt>, <tt>\p{Java}</tt>
+- <tt>\p{Kaithi}</tt>, <tt>\p{Kthi}</tt>
+- <tt>\p{Kannada}</tt>, <tt>\p{Knda}</tt>
+- <tt>\p{Katakana}</tt>, <tt>\p{Kana}</tt>
+- <tt>\p{Kawi}</tt>
+- <tt>\p{Kayah_Li}</tt>, <tt>\p{Kali}</tt>
+- <tt>\p{Kharoshthi}</tt>, <tt>\p{Khar}</tt>
+- <tt>\p{Khitan_Small_Script}</tt>, <tt>\p{Kits}</tt>
+- <tt>\p{Khmer}</tt>, <tt>\p{Khmr}</tt>
+- <tt>\p{Khojki}</tt>, <tt>\p{Khoj}</tt>
+- <tt>\p{Khudawadi}</tt>, <tt>\p{Sind}</tt>
+- <tt>\p{Lao}</tt>, <tt>\p{Laoo}</tt>
+- <tt>\p{Latin}</tt>, <tt>\p{Latn}</tt>
+- <tt>\p{Lepcha}</tt>, <tt>\p{Lepc}</tt>
+- <tt>\p{Limbu}</tt>, <tt>\p{Limb}</tt>
+- <tt>\p{Linear_A}</tt>, <tt>\p{Lina}</tt>
+- <tt>\p{Linear_B}</tt>, <tt>\p{Linb}</tt>
+- <tt>\p{Lisu}</tt>
+- <tt>\p{Lycian}</tt>, <tt>\p{Lyci}</tt>
+- <tt>\p{Lydian}</tt>, <tt>\p{Lydi}</tt>
+- <tt>\p{Mahajani}</tt>, <tt>\p{Mahj}</tt>
+- <tt>\p{Makasar}</tt>, <tt>\p{Maka}</tt>
+- <tt>\p{Malayalam}</tt>, <tt>\p{Mlym}</tt>
+- <tt>\p{Mandaic}</tt>, <tt>\p{Mand}</tt>
+- <tt>\p{Manichaean}</tt>, <tt>\p{Mani}</tt>
+- <tt>\p{Marchen}</tt>, <tt>\p{Marc}</tt>
+- <tt>\p{Masaram_Gondi}</tt>, <tt>\p{Gonm}</tt>
+- <tt>\p{Medefaidrin}</tt>, <tt>\p{Medf}</tt>
+- <tt>\p{Meetei_Mayek}</tt>, <tt>\p{Mtei}</tt>
+- <tt>\p{Mende_Kikakui}</tt>, <tt>\p{Mend}</tt>
+- <tt>\p{Meroitic_Cursive}</tt>, <tt>\p{Merc}</tt>
+- <tt>\p{Meroitic_Hieroglyphs}</tt>, <tt>\p{Mero}</tt>
+- <tt>\p{Miao}</tt>, <tt>\p{Plrd}</tt>
+- <tt>\p{Modi}</tt>
+- <tt>\p{Mongolian}</tt>, <tt>\p{Mong}</tt>
+- <tt>\p{Mro}</tt>, <tt>\p{Mroo}</tt>
+- <tt>\p{Multani}</tt>, <tt>\p{Mult}</tt>
+- <tt>\p{Myanmar}</tt>, <tt>\p{Mymr}</tt>
+- <tt>\p{Nabataean}</tt>, <tt>\p{Nbat}</tt>
+- <tt>\p{Nag_Mundari}</tt>, <tt>\p{Nagm}</tt>
+- <tt>\p{Nandinagari}</tt>, <tt>\p{Nand}</tt>
+- <tt>\p{New_Tai_Lue}</tt>, <tt>\p{Talu}</tt>
+- <tt>\p{Newa}</tt>
+- <tt>\p{Nko}</tt>, <tt>\p{Nkoo}</tt>
+- <tt>\p{Nushu}</tt>, <tt>\p{Nshu}</tt>
+- <tt>\p{Nyiakeng_Puachue_Hmong}</tt>, <tt>\p{Hmnp}</tt>
+- <tt>\p{Ogham}</tt>, <tt>\p{Ogam}</tt>
+- <tt>\p{Ol_Chiki}</tt>, <tt>\p{Olck}</tt>
+- <tt>\p{Old_Hungarian}</tt>, <tt>\p{Hung}</tt>
+- <tt>\p{Old_Italic}</tt>, <tt>\p{Ital}</tt>
+- <tt>\p{Old_North_Arabian}</tt>, <tt>\p{Narb}</tt>
+- <tt>\p{Old_Permic}</tt>, <tt>\p{Perm}</tt>
+- <tt>\p{Old_Persian}</tt>, <tt>\p{Xpeo}</tt>
+- <tt>\p{Old_Sogdian}</tt>, <tt>\p{Sogo}</tt>
+- <tt>\p{Old_South_Arabian}</tt>, <tt>\p{Sarb}</tt>
+- <tt>\p{Old_Turkic}</tt>, <tt>\p{Orkh}</tt>
+- <tt>\p{Old_Uyghur}</tt>, <tt>\p{Ougr}</tt>
+- <tt>\p{Oriya}</tt>, <tt>\p{Orya}</tt>
+- <tt>\p{Osage}</tt>, <tt>\p{Osge}</tt>
+- <tt>\p{Osmanya}</tt>, <tt>\p{Osma}</tt>
+- <tt>\p{Pahawh_Hmong}</tt>, <tt>\p{Hmng}</tt>
+- <tt>\p{Palmyrene}</tt>, <tt>\p{Palm}</tt>
+- <tt>\p{Pau_Cin_Hau}</tt>, <tt>\p{Pauc}</tt>
+- <tt>\p{Phags_Pa}</tt>, <tt>\p{Phag}</tt>
+- <tt>\p{Phoenician}</tt>, <tt>\p{Phnx}</tt>
+- <tt>\p{Psalter_Pahlavi}</tt>, <tt>\p{Phlp}</tt>
+- <tt>\p{Rejang}</tt>, <tt>\p{Rjng}</tt>
+- <tt>\p{Runic}</tt>, <tt>\p{Runr}</tt>
+- <tt>\p{Samaritan}</tt>, <tt>\p{Samr}</tt>
+- <tt>\p{Saurashtra}</tt>, <tt>\p{Saur}</tt>
+- <tt>\p{Sharada}</tt>, <tt>\p{Shrd}</tt>
+- <tt>\p{Shavian}</tt>, <tt>\p{Shaw}</tt>
+- <tt>\p{Siddham}</tt>, <tt>\p{Sidd}</tt>
+- <tt>\p{SignWriting}</tt>, <tt>\p{Sgnw}</tt>
+- <tt>\p{Sinhala}</tt>, <tt>\p{Sinh}</tt>
+- <tt>\p{Sogdian}</tt>, <tt>\p{Sogd}</tt>
+- <tt>\p{Sora_Sompeng}</tt>, <tt>\p{Sora}</tt>
+- <tt>\p{Soyombo}</tt>, <tt>\p{Soyo}</tt>
+- <tt>\p{Sundanese}</tt>, <tt>\p{Sund}</tt>
+- <tt>\p{Syloti_Nagri}</tt>, <tt>\p{Sylo}</tt>
+- <tt>\p{Syriac}</tt>, <tt>\p{Syrc}</tt>
+- <tt>\p{Tagalog}</tt>, <tt>\p{Tglg}</tt>
+- <tt>\p{Tagbanwa}</tt>, <tt>\p{Tagb}</tt>
+- <tt>\p{Tai_Le}</tt>, <tt>\p{Tale}</tt>
+- <tt>\p{Tai_Tham}</tt>, <tt>\p{Lana}</tt>
+- <tt>\p{Tai_Viet}</tt>, <tt>\p{Tavt}</tt>
+- <tt>\p{Takri}</tt>, <tt>\p{Takr}</tt>
+- <tt>\p{Tamil}</tt>, <tt>\p{Taml}</tt>
+- <tt>\p{Tangsa}</tt>, <tt>\p{Tnsa}</tt>
+- <tt>\p{Tangut}</tt>, <tt>\p{Tang}</tt>
+- <tt>\p{Telugu}</tt>, <tt>\p{Telu}</tt>
+- <tt>\p{Thaana}</tt>, <tt>\p{Thaa}</tt>
+- <tt>\p{Thai}</tt>
+- <tt>\p{Tibetan}</tt>, <tt>\p{Tibt}</tt>
+- <tt>\p{Tifinagh}</tt>, <tt>\p{Tfng}</tt>
+- <tt>\p{Tirhuta}</tt>, <tt>\p{Tirh}</tt>
+- <tt>\p{Toto}</tt>
+- <tt>\p{Ugaritic}</tt>, <tt>\p{Ugar}</tt>
+- <tt>\p{Unknown}</tt>, <tt>\p{Zzzz}</tt>
+- <tt>\p{Vai}</tt>, <tt>\p{Vaii}</tt>
+- <tt>\p{Vithkuqi}</tt>, <tt>\p{Vith}</tt>
+- <tt>\p{Wancho}</tt>, <tt>\p{Wcho}</tt>
+- <tt>\p{Warang_Citi}</tt>, <tt>\p{Wara}</tt>
+- <tt>\p{Yezidi}</tt>, <tt>\p{Yezi}</tt>
+- <tt>\p{Yi}</tt>, <tt>\p{Yiii}</tt>
+- <tt>\p{Zanabazar_Square}</tt>, <tt>\p{Zanb}</tt>
+
+=== Blocks
+
+- <tt>\p{In_Adlam}</tt>
+- <tt>\p{In_Aegean_Numbers}</tt>
+- <tt>\p{In_Ahom}</tt>
+- <tt>\p{In_Alchemical_Symbols}</tt>
+- <tt>\p{In_Alphabetic_Presentation_Forms}</tt>
+- <tt>\p{In_Anatolian_Hieroglyphs}</tt>
+- <tt>\p{In_Ancient_Greek_Musical_Notation}</tt>
+- <tt>\p{In_Ancient_Greek_Numbers}</tt>
+- <tt>\p{In_Ancient_Symbols}</tt>
+- <tt>\p{In_Arabic}</tt>
+- <tt>\p{In_Arabic_Extended_A}</tt>
+- <tt>\p{In_Arabic_Extended_B}</tt>
+- <tt>\p{In_Arabic_Extended_C}</tt>
+- <tt>\p{In_Arabic_Mathematical_Alphabetic_Symbols}</tt>
+- <tt>\p{In_Arabic_Presentation_Forms_A}</tt>
+- <tt>\p{In_Arabic_Presentation_Forms_B}</tt>
+- <tt>\p{In_Arabic_Supplement}</tt>
+- <tt>\p{In_Armenian}</tt>
+- <tt>\p{In_Arrows}</tt>
+- <tt>\p{In_Avestan}</tt>
+- <tt>\p{In_Balinese}</tt>
+- <tt>\p{In_Bamum}</tt>
+- <tt>\p{In_Bamum_Supplement}</tt>
+- <tt>\p{In_Basic_Latin}</tt>
+- <tt>\p{In_Bassa_Vah}</tt>
+- <tt>\p{In_Batak}</tt>
+- <tt>\p{In_Bengali}</tt>
+- <tt>\p{In_Bhaiksuki}</tt>
+- <tt>\p{In_Block_Elements}</tt>
+- <tt>\p{In_Bopomofo}</tt>
+- <tt>\p{In_Bopomofo_Extended}</tt>
+- <tt>\p{In_Box_Drawing}</tt>
+- <tt>\p{In_Brahmi}</tt>
+- <tt>\p{In_Braille_Patterns}</tt>
+- <tt>\p{In_Buginese}</tt>
+- <tt>\p{In_Buhid}</tt>
+- <tt>\p{In_Byzantine_Musical_Symbols}</tt>
+- <tt>\p{In_CJK_Compatibility}</tt>
+- <tt>\p{In_CJK_Compatibility_Forms}</tt>
+- <tt>\p{In_CJK_Compatibility_Ideographs}</tt>
+- <tt>\p{In_CJK_Compatibility_Ideographs_Supplement}</tt>
+- <tt>\p{In_CJK_Radicals_Supplement}</tt>
+- <tt>\p{In_CJK_Strokes}</tt>
+- <tt>\p{In_CJK_Symbols_and_Punctuation}</tt>
+- <tt>\p{In_CJK_Unified_Ideographs}</tt>
+- <tt>\p{In_CJK_Unified_Ideographs_Extension_A}</tt>
+- <tt>\p{In_CJK_Unified_Ideographs_Extension_B}</tt>
+- <tt>\p{In_CJK_Unified_Ideographs_Extension_C}</tt>
+- <tt>\p{In_CJK_Unified_Ideographs_Extension_D}</tt>
+- <tt>\p{In_CJK_Unified_Ideographs_Extension_E}</tt>
+- <tt>\p{In_CJK_Unified_Ideographs_Extension_F}</tt>
+- <tt>\p{In_CJK_Unified_Ideographs_Extension_G}</tt>
+- <tt>\p{In_CJK_Unified_Ideographs_Extension_H}</tt>
+- <tt>\p{In_Carian}</tt>
+- <tt>\p{In_Caucasian_Albanian}</tt>
+- <tt>\p{In_Chakma}</tt>
+- <tt>\p{In_Cham}</tt>
+- <tt>\p{In_Cherokee}</tt>
+- <tt>\p{In_Cherokee_Supplement}</tt>
+- <tt>\p{In_Chess_Symbols}</tt>
+- <tt>\p{In_Chorasmian}</tt>
+- <tt>\p{In_Combining_Diacritical_Marks}</tt>
+- <tt>\p{In_Combining_Diacritical_Marks_Extended}</tt>
+- <tt>\p{In_Combining_Diacritical_Marks_Supplement}</tt>
+- <tt>\p{In_Combining_Diacritical_Marks_for_Symbols}</tt>
+- <tt>\p{In_Combining_Half_Marks}</tt>
+- <tt>\p{In_Common_Indic_Number_Forms}</tt>
+- <tt>\p{In_Control_Pictures}</tt>
+- <tt>\p{In_Coptic}</tt>
+- <tt>\p{In_Coptic_Epact_Numbers}</tt>
+- <tt>\p{In_Counting_Rod_Numerals}</tt>
+- <tt>\p{In_Cuneiform}</tt>
+- <tt>\p{In_Cuneiform_Numbers_and_Punctuation}</tt>
+- <tt>\p{In_Currency_Symbols}</tt>
+- <tt>\p{In_Cypriot_Syllabary}</tt>
+- <tt>\p{In_Cypro_Minoan}</tt>
+- <tt>\p{In_Cyrillic}</tt>
+- <tt>\p{In_Cyrillic_Extended_A}</tt>
+- <tt>\p{In_Cyrillic_Extended_B}</tt>
+- <tt>\p{In_Cyrillic_Extended_C}</tt>
+- <tt>\p{In_Cyrillic_Extended_D}</tt>
+- <tt>\p{In_Cyrillic_Supplement}</tt>
+- <tt>\p{In_Deseret}</tt>
+- <tt>\p{In_Devanagari}</tt>
+- <tt>\p{In_Devanagari_Extended}</tt>
+- <tt>\p{In_Devanagari_Extended_A}</tt>
+- <tt>\p{In_Dingbats}</tt>
+- <tt>\p{In_Dives_Akuru}</tt>
+- <tt>\p{In_Dogra}</tt>
+- <tt>\p{In_Domino_Tiles}</tt>
+- <tt>\p{In_Duployan}</tt>
+- <tt>\p{In_Early_Dynastic_Cuneiform}</tt>
+- <tt>\p{In_Egyptian_Hieroglyph_Format_Controls}</tt>
+- <tt>\p{In_Egyptian_Hieroglyphs}</tt>
+- <tt>\p{In_Elbasan}</tt>
+- <tt>\p{In_Elymaic}</tt>
+- <tt>\p{In_Emoticons}</tt>
+- <tt>\p{In_Enclosed_Alphanumeric_Supplement}</tt>
+- <tt>\p{In_Enclosed_Alphanumerics}</tt>
+- <tt>\p{In_Enclosed_CJK_Letters_and_Months}</tt>
+- <tt>\p{In_Enclosed_Ideographic_Supplement}</tt>
+- <tt>\p{In_Ethiopic}</tt>
+- <tt>\p{In_Ethiopic_Extended}</tt>
+- <tt>\p{In_Ethiopic_Extended_A}</tt>
+- <tt>\p{In_Ethiopic_Extended_B}</tt>
+- <tt>\p{In_Ethiopic_Supplement}</tt>
+- <tt>\p{In_General_Punctuation}</tt>
+- <tt>\p{In_Geometric_Shapes}</tt>
+- <tt>\p{In_Geometric_Shapes_Extended}</tt>
+- <tt>\p{In_Georgian}</tt>
+- <tt>\p{In_Georgian_Extended}</tt>
+- <tt>\p{In_Georgian_Supplement}</tt>
+- <tt>\p{In_Glagolitic}</tt>
+- <tt>\p{In_Glagolitic_Supplement}</tt>
+- <tt>\p{In_Gothic}</tt>
+- <tt>\p{In_Grantha}</tt>
+- <tt>\p{In_Greek_Extended}</tt>
+- <tt>\p{In_Greek_and_Coptic}</tt>
+- <tt>\p{In_Gujarati}</tt>
+- <tt>\p{In_Gunjala_Gondi}</tt>
+- <tt>\p{In_Gurmukhi}</tt>
+- <tt>\p{In_Halfwidth_and_Fullwidth_Forms}</tt>
+- <tt>\p{In_Hangul_Compatibility_Jamo}</tt>
+- <tt>\p{In_Hangul_Jamo}</tt>
+- <tt>\p{In_Hangul_Jamo_Extended_A}</tt>
+- <tt>\p{In_Hangul_Jamo_Extended_B}</tt>
+- <tt>\p{In_Hangul_Syllables}</tt>
+- <tt>\p{In_Hanifi_Rohingya}</tt>
+- <tt>\p{In_Hanunoo}</tt>
+- <tt>\p{In_Hatran}</tt>
+- <tt>\p{In_Hebrew}</tt>
+- <tt>\p{In_High_Private_Use_Surrogates}</tt>
+- <tt>\p{In_High_Surrogates}</tt>
+- <tt>\p{In_Hiragana}</tt>
+- <tt>\p{In_IPA_Extensions}</tt>
+- <tt>\p{In_Ideographic_Description_Characters}</tt>
+- <tt>\p{In_Ideographic_Symbols_and_Punctuation}</tt>
+- <tt>\p{In_Imperial_Aramaic}</tt>
+- <tt>\p{In_Indic_Siyaq_Numbers}</tt>
+- <tt>\p{In_Inscriptional_Pahlavi}</tt>
+- <tt>\p{In_Inscriptional_Parthian}</tt>
+- <tt>\p{In_Javanese}</tt>
+- <tt>\p{In_Kaithi}</tt>
+- <tt>\p{In_Kaktovik_Numerals}</tt>
+- <tt>\p{In_Kana_Extended_A}</tt>
+- <tt>\p{In_Kana_Extended_B}</tt>
+- <tt>\p{In_Kana_Supplement}</tt>
+- <tt>\p{In_Kanbun}</tt>
+- <tt>\p{In_Kangxi_Radicals}</tt>
+- <tt>\p{In_Kannada}</tt>
+- <tt>\p{In_Katakana}</tt>
+- <tt>\p{In_Katakana_Phonetic_Extensions}</tt>
+- <tt>\p{In_Kawi}</tt>
+- <tt>\p{In_Kayah_Li}</tt>
+- <tt>\p{In_Kharoshthi}</tt>
+- <tt>\p{In_Khitan_Small_Script}</tt>
+- <tt>\p{In_Khmer}</tt>
+- <tt>\p{In_Khmer_Symbols}</tt>
+- <tt>\p{In_Khojki}</tt>
+- <tt>\p{In_Khudawadi}</tt>
+- <tt>\p{In_Lao}</tt>
+- <tt>\p{In_Latin_1_Supplement}</tt>
+- <tt>\p{In_Latin_Extended_A}</tt>
+- <tt>\p{In_Latin_Extended_Additional}</tt>
+- <tt>\p{In_Latin_Extended_B}</tt>
+- <tt>\p{In_Latin_Extended_C}</tt>
+- <tt>\p{In_Latin_Extended_D}</tt>
+- <tt>\p{In_Latin_Extended_E}</tt>
+- <tt>\p{In_Latin_Extended_F}</tt>
+- <tt>\p{In_Latin_Extended_G}</tt>
+- <tt>\p{In_Lepcha}</tt>
+- <tt>\p{In_Letterlike_Symbols}</tt>
+- <tt>\p{In_Limbu}</tt>
+- <tt>\p{In_Linear_A}</tt>
+- <tt>\p{In_Linear_B_Ideograms}</tt>
+- <tt>\p{In_Linear_B_Syllabary}</tt>
+- <tt>\p{In_Lisu}</tt>
+- <tt>\p{In_Lisu_Supplement}</tt>
+- <tt>\p{In_Low_Surrogates}</tt>
+- <tt>\p{In_Lycian}</tt>
+- <tt>\p{In_Lydian}</tt>
+- <tt>\p{In_Mahajani}</tt>
+- <tt>\p{In_Mahjong_Tiles}</tt>
+- <tt>\p{In_Makasar}</tt>
+- <tt>\p{In_Malayalam}</tt>
+- <tt>\p{In_Mandaic}</tt>
+- <tt>\p{In_Manichaean}</tt>
+- <tt>\p{In_Marchen}</tt>
+- <tt>\p{In_Masaram_Gondi}</tt>
+- <tt>\p{In_Mathematical_Alphanumeric_Symbols}</tt>
+- <tt>\p{In_Mathematical_Operators}</tt>
+- <tt>\p{In_Mayan_Numerals}</tt>
+- <tt>\p{In_Medefaidrin}</tt>
+- <tt>\p{In_Meetei_Mayek}</tt>
+- <tt>\p{In_Meetei_Mayek_Extensions}</tt>
+- <tt>\p{In_Mende_Kikakui}</tt>
+- <tt>\p{In_Meroitic_Cursive}</tt>
+- <tt>\p{In_Meroitic_Hieroglyphs}</tt>
+- <tt>\p{In_Miao}</tt>
+- <tt>\p{In_Miscellaneous_Mathematical_Symbols_A}</tt>
+- <tt>\p{In_Miscellaneous_Mathematical_Symbols_B}</tt>
+- <tt>\p{In_Miscellaneous_Symbols}</tt>
+- <tt>\p{In_Miscellaneous_Symbols_and_Arrows}</tt>
+- <tt>\p{In_Miscellaneous_Symbols_and_Pictographs}</tt>
+- <tt>\p{In_Miscellaneous_Technical}</tt>
+- <tt>\p{In_Modi}</tt>
+- <tt>\p{In_Modifier_Tone_Letters}</tt>
+- <tt>\p{In_Mongolian}</tt>
+- <tt>\p{In_Mongolian_Supplement}</tt>
+- <tt>\p{In_Mro}</tt>
+- <tt>\p{In_Multani}</tt>
+- <tt>\p{In_Musical_Symbols}</tt>
+- <tt>\p{In_Myanmar}</tt>
+- <tt>\p{In_Myanmar_Extended_A}</tt>
+- <tt>\p{In_Myanmar_Extended_B}</tt>
+- <tt>\p{In_NKo}</tt>
+- <tt>\p{In_Nabataean}</tt>
+- <tt>\p{In_Nag_Mundari}</tt>
+- <tt>\p{In_Nandinagari}</tt>
+- <tt>\p{In_New_Tai_Lue}</tt>
+- <tt>\p{In_Newa}</tt>
+- <tt>\p{In_No_Block}</tt>
+- <tt>\p{In_Number_Forms}</tt>
+- <tt>\p{In_Nushu}</tt>
+- <tt>\p{In_Nyiakeng_Puachue_Hmong}</tt>
+- <tt>\p{In_Ogham}</tt>
+- <tt>\p{In_Ol_Chiki}</tt>
+- <tt>\p{In_Old_Hungarian}</tt>
+- <tt>\p{In_Old_Italic}</tt>
+- <tt>\p{In_Old_North_Arabian}</tt>
+- <tt>\p{In_Old_Permic}</tt>
+- <tt>\p{In_Old_Persian}</tt>
+- <tt>\p{In_Old_Sogdian}</tt>
+- <tt>\p{In_Old_South_Arabian}</tt>
+- <tt>\p{In_Old_Turkic}</tt>
+- <tt>\p{In_Old_Uyghur}</tt>
+- <tt>\p{In_Optical_Character_Recognition}</tt>
+- <tt>\p{In_Oriya}</tt>
+- <tt>\p{In_Ornamental_Dingbats}</tt>
+- <tt>\p{In_Osage}</tt>
+- <tt>\p{In_Osmanya}</tt>
+- <tt>\p{In_Ottoman_Siyaq_Numbers}</tt>
+- <tt>\p{In_Pahawh_Hmong}</tt>
+- <tt>\p{In_Palmyrene}</tt>
+- <tt>\p{In_Pau_Cin_Hau}</tt>
+- <tt>\p{In_Phags_pa}</tt>
+- <tt>\p{In_Phaistos_Disc}</tt>
+- <tt>\p{In_Phoenician}</tt>
+- <tt>\p{In_Phonetic_Extensions}</tt>
+- <tt>\p{In_Phonetic_Extensions_Supplement}</tt>
+- <tt>\p{In_Playing_Cards}</tt>
+- <tt>\p{In_Private_Use_Area}</tt>
+- <tt>\p{In_Psalter_Pahlavi}</tt>
+- <tt>\p{In_Rejang}</tt>
+- <tt>\p{In_Rumi_Numeral_Symbols}</tt>
+- <tt>\p{In_Runic}</tt>
+- <tt>\p{In_Samaritan}</tt>
+- <tt>\p{In_Saurashtra}</tt>
+- <tt>\p{In_Sharada}</tt>
+- <tt>\p{In_Shavian}</tt>
+- <tt>\p{In_Shorthand_Format_Controls}</tt>
+- <tt>\p{In_Siddham}</tt>
+- <tt>\p{In_Sinhala}</tt>
+- <tt>\p{In_Sinhala_Archaic_Numbers}</tt>
+- <tt>\p{In_Small_Form_Variants}</tt>
+- <tt>\p{In_Small_Kana_Extension}</tt>
+- <tt>\p{In_Sogdian}</tt>
+- <tt>\p{In_Sora_Sompeng}</tt>
+- <tt>\p{In_Soyombo}</tt>
+- <tt>\p{In_Spacing_Modifier_Letters}</tt>
+- <tt>\p{In_Specials}</tt>
+- <tt>\p{In_Sundanese}</tt>
+- <tt>\p{In_Sundanese_Supplement}</tt>
+- <tt>\p{In_Superscripts_and_Subscripts}</tt>
+- <tt>\p{In_Supplemental_Arrows_A}</tt>
+- <tt>\p{In_Supplemental_Arrows_B}</tt>
+- <tt>\p{In_Supplemental_Arrows_C}</tt>
+- <tt>\p{In_Supplemental_Mathematical_Operators}</tt>
+- <tt>\p{In_Supplemental_Punctuation}</tt>
+- <tt>\p{In_Supplemental_Symbols_and_Pictographs}</tt>
+- <tt>\p{In_Supplementary_Private_Use_Area_A}</tt>
+- <tt>\p{In_Supplementary_Private_Use_Area_B}</tt>
+- <tt>\p{In_Sutton_SignWriting}</tt>
+- <tt>\p{In_Syloti_Nagri}</tt>
+- <tt>\p{In_Symbols_and_Pictographs_Extended_A}</tt>
+- <tt>\p{In_Symbols_for_Legacy_Computing}</tt>
+- <tt>\p{In_Syriac}</tt>
+- <tt>\p{In_Syriac_Supplement}</tt>
+- <tt>\p{In_Tagalog}</tt>
+- <tt>\p{In_Tagbanwa}</tt>
+- <tt>\p{In_Tags}</tt>
+- <tt>\p{In_Tai_Le}</tt>
+- <tt>\p{In_Tai_Tham}</tt>
+- <tt>\p{In_Tai_Viet}</tt>
+- <tt>\p{In_Tai_Xuan_Jing_Symbols}</tt>
+- <tt>\p{In_Takri}</tt>
+- <tt>\p{In_Tamil}</tt>
+- <tt>\p{In_Tamil_Supplement}</tt>
+- <tt>\p{In_Tangsa}</tt>
+- <tt>\p{In_Tangut}</tt>
+- <tt>\p{In_Tangut_Components}</tt>
+- <tt>\p{In_Tangut_Supplement}</tt>
+- <tt>\p{In_Telugu}</tt>
+- <tt>\p{In_Thaana}</tt>
+- <tt>\p{In_Thai}</tt>
+- <tt>\p{In_Tibetan}</tt>
+- <tt>\p{In_Tifinagh}</tt>
+- <tt>\p{In_Tirhuta}</tt>
+- <tt>\p{In_Toto}</tt>
+- <tt>\p{In_Transport_and_Map_Symbols}</tt>
+- <tt>\p{In_Ugaritic}</tt>
+- <tt>\p{In_Unified_Canadian_Aboriginal_Syllabics}</tt>
+- <tt>\p{In_Unified_Canadian_Aboriginal_Syllabics_Extended}</tt>
+- <tt>\p{In_Unified_Canadian_Aboriginal_Syllabics_Extended_A}</tt>
+- <tt>\p{In_Vai}</tt>
+- <tt>\p{In_Variation_Selectors}</tt>
+- <tt>\p{In_Variation_Selectors_Supplement}</tt>
+- <tt>\p{In_Vedic_Extensions}</tt>
+- <tt>\p{In_Vertical_Forms}</tt>
+- <tt>\p{In_Vithkuqi}</tt>
+- <tt>\p{In_Wancho}</tt>
+- <tt>\p{In_Warang_Citi}</tt>
+- <tt>\p{In_Yezidi}</tt>
+- <tt>\p{In_Yi_Radicals}</tt>
+- <tt>\p{In_Yi_Syllables}</tt>
+- <tt>\p{In_Yijing_Hexagram_Symbols}</tt>
+- <tt>\p{In_Zanabazar_Square}</tt>
+- <tt>\p{In_Znamenny_Musical_Notation}</tt>
+
+=== Emoji
+
+- <tt>\p{Emoji}</tt>
+- <tt>\p{Emoji_Component}</tt>, <tt>\p{EComp}</tt>
+- <tt>\p{Emoji_Modifier}</tt>, <tt>\p{EMod}</tt>
+- <tt>\p{Emoji_Modifier_Base}</tt>, <tt>\p{EBase}</tt>
+- <tt>\p{Emoji_Presentation}</tt>, <tt>\p{EPres}</tt>
+- <tt>\p{Extended_Pictographic}</tt>, <tt>\p{ExtPict}</tt>
+
+=== Graphemes
+
+- <tt>\p{Grapheme_Cluster_Break_CR}</tt>
+- <tt>\p{Grapheme_Cluster_Break_Control}</tt>
+- <tt>\p{Grapheme_Cluster_Break_Extend}</tt>
+- <tt>\p{Grapheme_Cluster_Break_L}</tt>
+- <tt>\p{Grapheme_Cluster_Break_LF}</tt>
+- <tt>\p{Grapheme_Cluster_Break_LV}</tt>
+- <tt>\p{Grapheme_Cluster_Break_LVT}</tt>
+- <tt>\p{Grapheme_Cluster_Break_Prepend}</tt>
+- <tt>\p{Grapheme_Cluster_Break_Regional_Indicator}</tt>
+- <tt>\p{Grapheme_Cluster_Break_SpacingMark}</tt>
+- <tt>\p{Grapheme_Cluster_Break_T}</tt>
+- <tt>\p{Grapheme_Cluster_Break_V}</tt>
+- <tt>\p{Grapheme_Cluster_Break_ZWJ}</tt>
+
+=== Derived Ages
+
+- <tt>\p{Age_10_0}</tt>
+- <tt>\p{Age_11_0}</tt>
+- <tt>\p{Age_12_0}</tt>
+- <tt>\p{Age_12_1}</tt>
+- <tt>\p{Age_13_0}</tt>
+- <tt>\p{Age_14_0}</tt>
+- <tt>\p{Age_15_0}</tt>
+- <tt>\p{Age_1_1}</tt>
+- <tt>\p{Age_2_0}</tt>
+- <tt>\p{Age_2_1}</tt>
+- <tt>\p{Age_3_0}</tt>
+- <tt>\p{Age_3_1}</tt>
+- <tt>\p{Age_3_2}</tt>
+- <tt>\p{Age_4_0}</tt>
+- <tt>\p{Age_4_1}</tt>
+- <tt>\p{Age_5_0}</tt>
+- <tt>\p{Age_5_1}</tt>
+- <tt>\p{Age_5_2}</tt>
+- <tt>\p{Age_6_0}</tt>
+- <tt>\p{Age_6_1}</tt>
+- <tt>\p{Age_6_2}</tt>
+- <tt>\p{Age_6_3}</tt>
+- <tt>\p{Age_7_0}</tt>
+- <tt>\p{Age_8_0}</tt>
+- <tt>\p{Age_9_0}</tt>
diff --git a/doc/reline/face.md b/doc/reline/face.md
new file mode 100644
index 0000000000..1fa916123b
--- /dev/null
+++ b/doc/reline/face.md
@@ -0,0 +1,111 @@
+# Face
+
+With the `Reline::Face` class, you can modify the text color and text decorations in your terminal emulator.
+This is primarily used to customize the appearance of the method completion dialog in IRB.
+
+## Usage
+
+### ex: Change the background color of the completion dialog cyan to blue
+
+```ruby
+Reline::Face.config(:completion_dialog) do |conf|
+ conf.define :default, foreground: :white, background: :blue
+ # ^^^^^ `:cyan` by default
+ conf.define :enhanced, foreground: :white, background: :magenta
+ conf.define :scrollbar, foreground: :white, background: :blue
+end
+```
+
+If you provide the above code to an IRB session in some way, you can apply the configuration.
+It's generally done by writing it in `.irbrc`.
+
+Regarding `.irbrc`, please refer to the following link: [https://docs.ruby-lang.org/en/master/IRB.html](https://docs.ruby-lang.org/en/master/IRB.html)
+
+## Available parameters
+
+`Reline::Face` internally creates SGR (Select Graphic Rendition) code according to the block parameter of `Reline::Face.config` method.
+
+| Key | Value | SGR Code (numeric part following "\e[")|
+|:------------|:------------------|-----:|
+| :foreground | :black | 30 |
+| | :red | 31 |
+| | :green | 32 |
+| | :yellow | 33 |
+| | :blue | 34 |
+| | :magenta | 35 |
+| | :cyan | 36 |
+| | :white | 37 |
+| | :bright_black | 90 |
+| | :gray | 90 |
+| | :bright_red | 91 |
+| | :bright_green | 92 |
+| | :bright_yellow | 93 |
+| | :bright_blue | 94 |
+| | :bright_magenta | 95 |
+| | :bright_cyan | 96 |
+| | :bright_white | 97 |
+| :background | :black | 40 |
+| | :red | 41 |
+| | :green | 42 |
+| | :yellow | 43 |
+| | :blue | 44 |
+| | :magenta | 45 |
+| | :cyan | 46 |
+| | :white | 47 |
+| | :bright_black | 100 |
+| | :gray | 100 |
+| | :bright_red | 101 |
+| | :bright_green | 102 |
+| | :bright_yellow | 103 |
+| | :bright_blue | 104 |
+| | :bright_magenta | 105 |
+| | :bright_cyan | 106 |
+| | :bright_white | 107 |
+| :style | :reset | 0 |
+| | :bold | 1 |
+| | :faint | 2 |
+| | :italicized | 3 |
+| | :underlined | 4 |
+| | :slowly_blinking | 5 |
+| | :blinking | 5 |
+| | :rapidly_blinking | 6 |
+| | :negative | 7 |
+| | :concealed | 8 |
+| | :crossed_out | 9 |
+
+- The value for `:style` can be both a Symbol and an Array
+ ```ruby
+ # Single symbol
+ conf.define :default, style: :bold
+ # Array
+ conf.define :default, style: [:bold, :negative]
+ ```
+- The availability of specific SGR codes depends on your terminal emulator
+- You can specify a hex color code to `:foreground` and `:background` color like `foreground: "#FF1020"`. Its availability also depends on your terminal emulator
+
+## Debugging
+
+You can see the current Face configuration by `Reline::Face.configs` method
+
+Example:
+
+```ruby
+irb(main):001:0> Reline::Face.configs
+=>
+{:default=>
+ {:default=>{:style=>:reset, :escape_sequence=>"\e[0m"},
+ :enhanced=>{:style=>:reset, :escape_sequence=>"\e[0m"},
+ :scrollbar=>{:style=>:reset, :escape_sequence=>"\e[0m"}},
+ :completion_dialog=>
+ {:default=>{:foreground=>:white, :background=>:cyan, :escape_sequence=>"\e[0m\e[37;46m"},
+ :enhanced=>{:foreground=>:white, :background=>:magenta, :escape_sequence=>"\e[0m\e[37;45m"},
+ :scrollbar=>{:foreground=>:white, :background=>:cyan, :escape_sequence=>"\e[0m\e[37;46m"}}}
+```
+
+## 256-Color and TrueColor
+
+Reline will automatically detect if your terminal emulator supports truecolor with `ENV['COLORTERM] in 'truecolor' | '24bit'`. When this env is not set, Reline will fallback to 256-color.
+If your terminal emulator supports truecolor but does not set COLORTERM env, add this line to `.irbrc`.
+```ruby
+Reline::Face.force_truecolor
+```
diff --git a/doc/rjit/rjit.md b/doc/rjit/rjit.md
new file mode 100644
index 0000000000..9e60e43ce3
--- /dev/null
+++ b/doc/rjit/rjit.md
@@ -0,0 +1,45 @@
+# RJIT: Ruby JIT
+
+This document has some tips that might be useful when you work on RJIT.
+
+## Project purpose
+
+This project is for experimental purposes.
+For production deployment, consider using YJIT instead.
+
+## Supported platforms
+
+The following platforms are assumed to work. `linux-x86_64` is tested on CI.
+
+* OS: Linux, macOS, BSD
+* Arch: x86\_64
+
+## configure
+### --enable-rjit
+
+On supported platforms, `--enable-rjit` is set by default. You usually don't need to specify this.
+You may still manually pass `--enable-rjit` to try RJIT on unsupported platforms.
+
+### --enable-rjit=dev
+
+It enables `--rjit-dump-disasm` if libcapstone is available.
+
+## make
+### rjit-bindgen
+
+If you see an "RJIT bindgen" GitHub Actions failure, please commit the `git diff` shown on the failed job.
+
+For doing the same thing locally, run `make rjit-bindgen` after installing libclang.
+macOS seems to have libclang by default. On Ubuntu, you can install it with `apt install libclang1`.
+
+## ruby
+### --rjit-stats
+
+This prints RJIT stats at exit.
+
+### --rjit-dump-disasm
+
+This dumps all JIT code. You need to install libcapstone before configure and use `--enable-rjit=dev` on configure.
+
+* Ubuntu: `sudo apt-get install -y libcapstone-dev`
+* macOS: `brew install capstone`
diff --git a/doc/standard_library.rdoc b/doc/standard_library.rdoc
index 7c9938c5b0..2282d7226b 100644
--- a/doc/standard_library.rdoc
+++ b/doc/standard_library.rdoc
@@ -23,6 +23,14 @@ Socket:: Access underlying OS socket implementations
= Default gems
+* default gems are shipped with Ruby releases and also available as rubygems.
+* default gems are not uninstallable from Ruby installation.
+* default gems can be updated used by rubygems.
+ * e.g. `gem update json`
+* default gems can be used with bundler environment like `unbundled_env`.
+* default gems can be used any version on Gemfile.
+ * e.g. `gem "json", ">= 2.6"`
+
== Libraries
Abbrev:: Calculates a set of unique abbreviations for a given set of strings
@@ -53,6 +61,7 @@ OpenStruct:: Class to build custom data structures, similar to a Hash
OpenURI:: An easy-to-use wrapper for Net::HTTP, Net::HTTPS and Net::FTP
PP:: Provides a PrettyPrinter for Ruby objects
PrettyPrinter:: Implements a pretty printing algorithm for readable structure
+Prism:: A portable, error-tolerant Ruby parser
PStore:: Implements a file based persistence mechanism based on a Hash
Readline:: Wrapper for Readline extencion and Reline
Reline:: GNU Readline and Editline by pure Ruby implementation.
@@ -89,8 +98,6 @@ NKF:: Ruby extension for Network Kanji Filter
OpenSSL:: Provides SSL, TLS and general purpose cryptography for Ruby
Pathname:: Representation of the name of a file or directory on the filesystem
Psych:: A YAML parser and emitter for Ruby
-Racc:: A LALR(1) parser generator written in Ruby.
-Readline:: Provides an interface for GNU Readline and Edit Line (libedit)
StringIO:: Pseudo I/O on String objects
StringScanner:: Provides lexical scanning operations on a String
Syslog:: Ruby interface for the POSIX system logging facility
@@ -99,6 +106,12 @@ Zlib:: Ruby interface for the zlib compression/decompression library
= Bundled gems
+* bundled gems are shipped with Ruby releases and also available as rubygems.
+* bundled gems are same as normal gems like `rails`, `rack`.
+ * They are only bundled with Ruby releases.
+ * They can be uninstallable from Ruby installation.
+ * They are needed to declare in Gemfile when use with bundler.
+
== Libraries
MiniTest:: A test suite with TDD, BDD, mocking and benchmarking
@@ -116,3 +129,4 @@ Prime:: Prime numbers and factorization library
RBS:: RBS is a language to describe the structure of Ruby programs
TypeProf:: A type analysis tool for Ruby code based on abstract interpretation
DEBUGGER__:: Debugging functionality for Ruby
+Racc:: A LALR(1) parser generator written in Ruby.
diff --git a/doc/strftime_formatting.rdoc b/doc/strftime_formatting.rdoc
index 30a629bf68..7694752a21 100644
--- a/doc/strftime_formatting.rdoc
+++ b/doc/strftime_formatting.rdoc
@@ -1,4 +1,4 @@
-== Formats for Dates and Times
+= Formats for Dates and Times
Several Ruby time-related classes have instance method +strftime+,
which returns a formatted string representing all or part of a date or time:
@@ -32,9 +32,9 @@ It consists of:
Except for the leading percent character,
the only required part is the conversion specifier, so we begin with that.
-=== Conversion Specifiers
+== Conversion Specifiers
-==== \Date (Year, Month, Day)
+=== \Date (Year, Month, Day)
- <tt>%Y</tt> - Year including century, zero-padded:
@@ -87,7 +87,7 @@ the only required part is the conversion specifier, so we begin with that.
Time.new(2002, 1, 1).strftime('%j') # => "001"
Time.new(2002, 12, 31).strftime('%j') # => "365"
-==== \Time (Hour, Minute, Second, Subsecond)
+=== \Time (Hour, Minute, Second, Subsecond)
- <tt>%H</tt> - Hour of the day, in range (0..23), zero-padded:
@@ -152,7 +152,7 @@ the only required part is the conversion specifier, so we begin with that.
Time.now.strftime('%s') # => "1656505136"
-==== Timezone
+=== Timezone
- <tt>%z</tt> - Timezone as hour and minute offset from UTC:
@@ -162,7 +162,7 @@ the only required part is the conversion specifier, so we begin with that.
Time.now.strftime('%Z') # => "Central Daylight Time"
-==== Weekday
+=== Weekday
- <tt>%A</tt> - Full weekday name:
@@ -184,7 +184,7 @@ the only required part is the conversion specifier, so we begin with that.
t.strftime('%a') # => "Sun"
t.strftime('%w') # => "0"
-==== Week Number
+=== Week Number
- <tt>%U</tt> - Week number of the year, in range (0..53), zero-padded,
where each week begins on a Sunday:
@@ -200,7 +200,7 @@ the only required part is the conversion specifier, so we begin with that.
t.strftime('%a') # => "Sun"
t.strftime('%W') # => "25"
-==== Week Dates
+=== Week Dates
See {ISO 8601 week dates}[https://en.wikipedia.org/wiki/ISO_8601#Week_dates].
@@ -223,7 +223,7 @@ See {ISO 8601 week dates}[https://en.wikipedia.org/wiki/ISO_8601#Week_dates].
t0.strftime('%V') # => "52"
t1.strftime('%V') # => "01"
-==== Literals
+=== Literals
- <tt>%n</tt> - Newline character "\n":
@@ -237,7 +237,7 @@ See {ISO 8601 week dates}[https://en.wikipedia.org/wiki/ISO_8601#Week_dates].
Time.now.strftime('%%') # => "%"
-==== Shorthand Conversion Specifiers
+=== Shorthand Conversion Specifiers
Each shorthand specifier here is shown with its corresponding
longhand specifier.
@@ -294,14 +294,14 @@ longhand specifier.
DateTime.now.strftime('%a %b %e %H:%M:%S %Z %Y')
# => "Wed Jun 29 08:32:18 -05:00 2022"
-=== Flags
+== Flags
Flags may affect certain formatting specifications.
Multiple flags may be given with a single conversion specified;
order does not matter.
-==== Padding Flags
+=== Padding Flags
- <tt>0</tt> - Pad with zeroes:
@@ -315,7 +315,7 @@ order does not matter.
Time.new(10).strftime('%-Y') # => "10"
-==== Casing Flags
+=== Casing Flags
- <tt>^</tt> - Upcase result:
@@ -328,7 +328,7 @@ order does not matter.
Time.now.strftime('%^p') # => "AM"
Time.now.strftime('%#p') # => "am"
-==== Timezone Flags
+=== Timezone Flags
- <tt>:</tt> - Put timezone as colon-separated hours and minutes:
@@ -338,7 +338,7 @@ order does not matter.
Time.now.strftime('%::z') # => "-05:00:00"
-=== Width Specifiers
+== Width Specifiers
The integer width specifier gives a minimum width for the returned string:
@@ -348,12 +348,12 @@ The integer width specifier gives a minimum width for the returned string:
Time.new(2002, 12).strftime('%10B') # => " December"
Time.new(2002, 12).strftime('%3B') # => "December" # Ignored if too small.
-== Specialized Format Strings
+= Specialized Format Strings
Here are a few specialized format strings,
each based on an external standard.
-=== HTTP Format
+== HTTP Format
The HTTP date format is based on
{RFC 2616}[https://datatracker.ietf.org/doc/html/rfc2616],
@@ -368,7 +368,7 @@ and treats dates in the format <tt>'%a, %d %b %Y %T GMT'</tt>:
Date._httpdate(httpdate)
# => {:wday=>6, :mday=>3, :mon=>2, :year=>2001, :hour=>0, :min=>0, :sec=>0, :zone=>"GMT", :offset=>0}
-=== RFC 3339 Format
+== RFC 3339 Format
The RFC 3339 date format is based on
{RFC 3339}[https://datatracker.ietf.org/doc/html/rfc3339]:
@@ -382,7 +382,7 @@ The RFC 3339 date format is based on
Date._rfc3339(rfc3339)
# => {:year=>2001, :mon=>2, :mday=>3, :hour=>0, :min=>0, :sec=>0, :zone=>"+00:00", :offset=>0}
-=== RFC 2822 Format
+== RFC 2822 Format
The RFC 2822 date format is based on
{RFC 2822}[https://datatracker.ietf.org/doc/html/rfc2822],
@@ -397,7 +397,7 @@ and treats dates in the format <tt>'%a, %-d %b %Y %T %z'</tt>]:
Date._rfc2822(rfc2822)
# => {:wday=>6, :mday=>3, :mon=>2, :year=>2001, :hour=>0, :min=>0, :sec=>0, :zone=>"+0000", :offset=>0}
-=== JIS X 0301 Format
+== JIS X 0301 Format
The JIS X 0301 format includes the
{Japanese era name}[https://en.wikipedia.org/wiki/Japanese_era_name],
@@ -412,7 +412,7 @@ with the first letter of the romanized era name prefixed:
# Return hash parsed from 0301-formatted string.
Date._jisx0301(jisx0301) # => {:year=>2001, :mon=>2, :mday=>3}
-=== ISO 8601 Format Specifications
+== ISO 8601 Format Specifications
This section shows format specifications that are compatible with
{ISO 8601}[https://en.wikipedia.org/wiki/ISO_8601].
@@ -422,7 +422,7 @@ Examples in this section assume:
t = Time.now # => 2022-06-29 16:49:25.465246 -0500
-==== Dates
+=== Dates
See {ISO 8601 dates}[https://en.wikipedia.org/wiki/ISO_8601#Dates].
@@ -473,7 +473,7 @@ See {ISO 8601 dates}[https://en.wikipedia.org/wiki/ISO_8601#Dates].
t.strftime('%Y-%j') # => "2022-180"
-==== Times
+=== Times
See {ISO 8601 times}[https://en.wikipedia.org/wiki/ISO_8601#Times].
@@ -514,7 +514,7 @@ See {ISO 8601 times}[https://en.wikipedia.org/wiki/ISO_8601#Times].
- {Coordinated Universal Time (UTC)}[https://en.wikipedia.org/wiki/ISO_8601#Coordinated_Universal_Time_(UTC)].
- {Time offsets from UTC}[https://en.wikipedia.org/wiki/ISO_8601#Time_offsets_from_UTC].
-==== Combined \Date and \Time
+=== Combined \Date and \Time
See {ISO 8601 Combined date and time representations}[https://en.wikipedia.org/wiki/ISO_8601#Combined_date_and_time_representations].
diff --git a/doc/string/length.rdoc b/doc/string/length.rdoc
index 0a7e17f7dc..544bca269f 100644
--- a/doc/string/length.rdoc
+++ b/doc/string/length.rdoc
@@ -10,4 +10,3 @@ Contrast with String#bytesize:
'тест'.bytesize # => 8
'こんにちは'.bytesize # => 15
-String#size is an alias for String#length.
diff --git a/doc/syntax.rdoc b/doc/syntax.rdoc
index 5895673f36..6ca5843512 100644
--- a/doc/syntax.rdoc
+++ b/doc/syntax.rdoc
@@ -37,3 +37,6 @@ Miscellaneous[rdoc-ref:syntax/miscellaneous.rdoc] ::
Comments[rdoc-ref:syntax/comments.rdoc] ::
Line and block code comments
+
+Operators[rdoc-ref:syntax/operators.rdoc] ::
+ Operator method behaviors
diff --git a/doc/syntax/assignment.rdoc b/doc/syntax/assignment.rdoc
index 037c2032a8..e30cb35adf 100644
--- a/doc/syntax/assignment.rdoc
+++ b/doc/syntax/assignment.rdoc
@@ -403,6 +403,10 @@ assigning. This is similar to multiple assignment:
p a # prints [1, 2, 3]
+ b = *1
+
+ p b # prints [1]
+
You can splat anywhere in the right-hand side of the assignment:
a = 1, *[2, 3]
diff --git a/doc/syntax/calling_methods.rdoc b/doc/syntax/calling_methods.rdoc
index da061dbfdb..6cc8678450 100644
--- a/doc/syntax/calling_methods.rdoc
+++ b/doc/syntax/calling_methods.rdoc
@@ -322,18 +322,6 @@ Both are equivalent to:
my_method(1, 2, 3)
-If the method accepts keyword arguments, the splat operator will convert a
-hash at the end of the array into keyword arguments:
-
- def my_method(a, b, c: 3)
- end
-
- arguments = [1, 2, { c: 4 }]
- my_method(*arguments)
-
-Note that this behavior is currently deprecated and will emit a warning.
-This behavior will be removed in Ruby 3.0.
-
You may also use the <code>**</code> (described next) to convert a Hash into
keyword arguments.
diff --git a/doc/syntax/comments.rdoc b/doc/syntax/comments.rdoc
index dbc7816984..00d19d588a 100644
--- a/doc/syntax/comments.rdoc
+++ b/doc/syntax/comments.rdoc
@@ -196,7 +196,7 @@ The method Module#const_set is not affected.
In this mode, all values assigned to constants are deeply copied and
made shareable. It is safer mode than +experimental_everything+.
- # shareable_constant_value: experimental_everything
+ # shareable_constant_value: experimental_copy
var = [{foo: []}]
var.frozen? # => false (assignment was made to local variable)
X = var # => calls `Ractor.make_shareable(var, copy: true)`
diff --git a/doc/syntax/control_expressions.rdoc b/doc/syntax/control_expressions.rdoc
index df3b5ced38..5350585f15 100644
--- a/doc/syntax/control_expressions.rdoc
+++ b/doc/syntax/control_expressions.rdoc
@@ -569,3 +569,71 @@ evaluated on the following iteration:
Here, the flip-flop turns on when +value+ equals 2, but doesn't turn off on the
same iteration. The `off' condition isn't evaluated until the following
iteration and +value+ will never be two again.
+
+== throw/catch
+
++throw+ and +catch+ are used to implement non-local control flow in Ruby. They
+operate similarly to exceptions, allowing control to pass directly from the
+place where +throw+ is called to the place where the matching +catch+ is
+called. The main difference between +throw+/+catch+ and the use of exceptions
+is that +throw+/+catch+ are designed for expected non-local control flow,
+while exceptions are designed for exceptional control flow situations, such
+as handling unexpected errors.
+
+When using +throw+, you provide 1-2 arguments. The first argument is the
+value for the matching +catch+. The second argument is optional (defaults to
++nil+), and will be the value that +catch+ returns if there is a matching
++throw+ inside the +catch+ block. If no matching +throw+ method is called
+inside a +catch+ block, the +catch+ method returns the return value of the
+block passed to it.
+
+ def a(n)
+ throw :d, :a if n == 0
+ b(n)
+ end
+
+ def b(n)
+ throw :d, :b if n == 1
+ c(n)
+ end
+
+ def c(n)
+ throw :d if n == 2
+ end
+
+ 4.times.map do |i|
+ catch(:d) do
+ a(i)
+ :default
+ end
+ end
+ # => [:a, :b, nil, :default]
+
+If the first argument you pass to +throw+ is not handled by a matching
++catch+, an UncaughtThrowError exception will be raised. This is because
++throw+/+catch+ should only be used for expected control flow changes, so
+using a value that is not already expected is an error.
+
++throw+/+catch+ are implemented as Kernel methods (Kernel#throw and
+Kernel#catch), not as keywords. So they are not usable directly if you are
+in a BasicObject context. You can use Kernel.throw and Kernel.catch in
+this case:
+
+ BasicObject.new.instance_exec do
+ def a
+ b
+ end
+
+ def b
+ c
+ end
+
+ def c
+ ::Kernel.throw :d, :e
+ end
+
+ result = ::Kernel.catch(:d) do
+ a
+ end
+ result # => :e
+ end
diff --git a/doc/syntax/literals.rdoc b/doc/syntax/literals.rdoc
index 5e10e6a140..0c1e4a434b 100644
--- a/doc/syntax/literals.rdoc
+++ b/doc/syntax/literals.rdoc
@@ -277,6 +277,12 @@ the content. Note that empty lines and lines consisting solely of literal tabs
and spaces will be ignored for the purposes of determining indentation, but
escaped tabs and spaces are considered non-indentation characters.
+For the purpose of measuring an indentation, a horizontal tab is regarded as a
+sequence of one to eight spaces such that the column position corresponding to
+its end is a multiple of eight. The amount to be removed is counted in terms
+of the number of spaces. If the boundary appears in the middle of a tab, that
+tab is not removed.
+
A heredoc allows interpolation and escaped characters. You may disable
interpolation and escaping by surrounding the opening identifier with single
quotes:
@@ -408,9 +414,9 @@ slash (<tt>'/'</tt>) characters:
re = /foo/ # => /foo/
re.class # => Regexp
-The trailing slash may be followed by one or more _flag_ characters
-that modify the behavior.
-See {Regexp options}[rdoc-ref:Regexp@Options] for details.
+The trailing slash may be followed by one or more modifiers characters
+that set modes for the regexp.
+See {Regexp modes}[rdoc-ref:Regexp@Modes] for details.
Interpolation may be used inside regular expressions along with escaped
characters. Note that a regular expression may require additional escaped
@@ -517,9 +523,9 @@ A few "symmetrical" character pairs may be used as delimiters:
%r(foo) # => /foo/
%r<foo> # => /foo/
-The trailing delimiter may be followed by one or more _flag_ characters
-that modify the behavior.
-See {Regexp options}[rdoc-ref:Regexp@Options] for details.
+The trailing delimiter may be followed by one or more modifier characters
+that set modes for the regexp.
+See {Regexp modes}[rdoc-ref:Regexp@Modes] for details.
=== <tt>%x</tt>: Backtick Literals
diff --git a/doc/syntax/modules_and_classes.rdoc b/doc/syntax/modules_and_classes.rdoc
index 024815a5a6..9e05c5c774 100644
--- a/doc/syntax/modules_and_classes.rdoc
+++ b/doc/syntax/modules_and_classes.rdoc
@@ -40,9 +40,9 @@ functionality:
remove_method :my_method
end
-Reopening classes is a very powerful feature of Ruby, but it is best to only
-reopen classes you own. Reopening classes you do not own may lead to naming
-conflicts or difficult to diagnose bugs.
+Reopening modules (or classes) is a very powerful feature of Ruby, but it is
+best to only reopen modules you own. Reopening modules you do not own may lead
+to naming conflicts or difficult to diagnose bugs.
== Nesting
@@ -259,6 +259,28 @@ includes a minimum of built-in methods. You can use BasicObject to create an
independent inheritance structure. See the BasicObject documentation for
further details.
+Just like modules, classes can also be reopened. You can omit its superclass
+when you reopen a class. Specifying a different superclass than the previous
+definition will raise an error.
+
+ class C
+ end
+
+ class D < C
+ end
+
+ # OK
+ class D < C
+ end
+
+ # OK
+ class D
+ end
+
+ # TypeError: superclass mismatch for class D
+ class D < String
+ end
+
== Inheritance
Any method defined on a class is callable from its subclass:
diff --git a/doc/syntax/operators.rdoc b/doc/syntax/operators.rdoc
new file mode 100644
index 0000000000..236b3413b5
--- /dev/null
+++ b/doc/syntax/operators.rdoc
@@ -0,0 +1,75 @@
+= Operators
+
+In Ruby, operators such as <code>+</code>, are defined as methods on the class.
+Literals[rdoc-ref:syntax/literals.rdoc] define their methods within the lower
+level, C language. String class, for example.
+
+Ruby objects can define or overload their own implementation for most operators.
+
+Here is an example:
+
+ class Foo < String
+ def +(str)
+ self.concat(str).concat("another string")
+ end
+ end
+
+ foobar = Foo.new("test ")
+ puts foobar + "baz "
+
+This prints:
+
+ test baz another string
+
+What operators are available is dependent on the implementing class.
+
+== Operator Behavior
+
+How a class behaves to a given operator is specific to that class, since
+operators are method implementations.
+
+When using an operator, it's the expression on the left-hand side of the
+operation that specifies the behavior.
+
+ 'a' * 3 #=> "aaa"
+ 3 * 'a' # TypeError: String can't be coerced into Integer
+
+== Logical Operators
+
+Logical operators are not methods, and therefor cannot be
+redefined/overloaded. They are tokenized at a lower level.
+
+Short-circuit logical operators (<code>&&</code>, <code>||</code>,
+<code>and</code>, and <code>or</code>) do not always result in a boolean value.
+Similar to blocks, it's the last evaluated expression that defines the result
+of the operation.
+
+=== <code>&&</code>, <code>and</code>
+
+Both <code>&&</code>/<code>and</code> operators provide short-circuiting by executing each
+side of the operator, left to right, and stopping at the first occurrence of a
+falsey expression. The expression that defines the result is the last one
+executed, whether it be the final expression, or the first occurrence of a falsey
+expression.
+
+Some examples:
+
+ true && 9 && "string" #=> "string"
+ (1 + 2) && nil && "string" #=> nil
+ (a = 1) && (b = false) && (c = "string") #=> false
+
+ puts a #=> 1
+ puts b #=> false
+ puts c #=> nil
+
+In this last example, <code>c</code> was initialized, but not defined.
+
+=== <code>||</code>, <code>or</code>
+
+The means by which <code>||</code>/<code>or</code> short-circuits, is to return the result of
+the first expression that is truthy.
+
+Some examples:
+
+ (1 + 2) || true || "string" #=> 3
+ false || nil || "string" #=> "string"
diff --git a/doc/syntax/pattern_matching.rdoc b/doc/syntax/pattern_matching.rdoc
index b7d614770c..e49c09a1f8 100644
--- a/doc/syntax/pattern_matching.rdoc
+++ b/doc/syntax/pattern_matching.rdoc
@@ -415,6 +415,11 @@ Additionally, when matching custom classes, the expected class can be specified
end
#=> "matched: 1"
+These core and library classes implement deconstruction:
+
+* MatchData#deconstruct and MatchData#deconstruct_keys;
+* Time#deconstruct_keys, Date#deconstruct_keys, DateTime#deconstruct_keys.
+
== Guard clauses
+if+ can be used to attach an additional condition (guard clause) when the pattern matches. This condition may use bound variables:
@@ -445,29 +450,6 @@ Additionally, when matching custom classes, the expected class can be specified
end
#=> "matched"
-== Current feature status
-
-As of Ruby 3.1, find patterns are considered _experimental_: its syntax can change in the future. Every time you use these features in code, a warning will be printed:
-
- [0] => [*, 0, *]
- # warning: Find pattern is experimental, and the behavior may change in future versions of Ruby!
- # warning: One-line pattern matching is experimental, and the behavior may change in future versions of Ruby!
-
-To suppress this warning, one may use the Warning::[]= method:
-
- Warning[:experimental] = false
- eval('[0] => [*, 0, *]')
- # ...no warning printed...
-
-Note that pattern-matching warnings are raised at compile time, so this will not suppress the warning:
-
- Warning[:experimental] = false # At the time this line is evaluated, the parsing happened and warning emitted
- [0] => [*, 0, *]
-
-So, only subsequently loaded files or `eval`-ed code is affected by switching the flag.
-
-Alternatively, the command line option <code>-W:no-experimental</code> can be used to turn off "experimental" feature warnings.
-
== Appendix A. Pattern syntax
Approximate syntax is:
diff --git a/doc/syntax/refinements.rdoc b/doc/syntax/refinements.rdoc
index c900ab1bdc..17d5e67c21 100644
--- a/doc/syntax/refinements.rdoc
+++ b/doc/syntax/refinements.rdoc
@@ -279,6 +279,6 @@ Refinements in descendants have higher precedence than those of ancestors.
== Further Reading
-See https://bugs.ruby-lang.org/projects/ruby-master/wiki/RefinementsSpec for the
+See https://github.com/ruby/ruby/wiki/Refinements-Spec for the
current specification for implementing refinements. The specification also
contains more details.
diff --git a/doc/timezones.rdoc b/doc/timezones.rdoc
deleted file mode 100644
index c3aae88fde..0000000000
--- a/doc/timezones.rdoc
+++ /dev/null
@@ -1,108 +0,0 @@
-== Timezones
-
-=== Timezone Specifiers
-
-Certain \Time methods accept arguments that specify timezones:
-
-- Time.at: keyword argument +in:+.
-- Time.new: positional argument +zone+ or keyword argument +in:+.
-- Time.now: keyword argument +in:+.
-- Time#getlocal: positional argument +zone+.
-- Time#localtime: positional argument +zone+.
-
-The value given with any of these must be one of the following
-(each detailed below):
-
-- {Hours/minutes offset}[rdoc-ref:timezones.rdoc@Hours-2FMinutes+Offsets].
-- {Single-letter offset}[rdoc-ref:timezones.rdoc@Single-Letter+Offsets].
-- {Integer offset}[rdoc-ref:timezones.rdoc@Integer+Offsets].
-- {Timezone object}[rdoc-ref:timezones.rdoc@Timezone+Objects].
-
-==== Hours/Minutes Offsets
-
-The zone value may be a string offset from UTC
-in the form <tt>'+HH:MM'</tt> or <tt>'-HH:MM'</tt>,
-where:
-
-- +HH+ is the 2-digit hour in the range <tt>0..23</tt>.
-- +MM+ is the 2-digit minute in the range <tt>0..59</tt>.
-
-Examples:
-
- t = Time.utc(2000, 1, 1, 20, 15, 1) # => 2000-01-01 20:15:01 UTC
- Time.at(t, in: '-23:59') # => 1999-12-31 20:16:01 -2359
- Time.at(t, in: '+23:59') # => 2000-01-02 20:14:01 +2359
-
-==== Single-Letter Offsets
-
-The zone value may be a letter in the range <tt>'A'..'I'</tt>
-or <tt>'K'..'Z'</tt>;
-see {List of military time zones}[https://en.wikipedia.org/wiki/List_of_military_time_zones]:
-
- t = Time.utc(2000, 1, 1, 20, 15, 1) # => 2000-01-01 20:15:01 UTC
- Time.at(t, in: 'A') # => 2000-01-01 21:15:01 +0100
- Time.at(t, in: 'I') # => 2000-01-02 05:15:01 +0900
- Time.at(t, in: 'K') # => 2000-01-02 06:15:01 +1000
- Time.at(t, in: 'Y') # => 2000-01-01 08:15:01 -1200
- Time.at(t, in: 'Z') # => 2000-01-01 20:15:01 UTC
-
-==== \Integer Offsets
-
-The zone value may be an integer number of seconds
-in the range <tt>-86399..86399</tt>:
-
- t = Time.utc(2000, 1, 1, 20, 15, 1) # => 2000-01-01 20:15:01 UTC
- Time.at(t, in: -86399) # => 1999-12-31 20:15:02 -235959
- Time.at(t, in: 86399) # => 2000-01-02 20:15:00 +235959
-
-==== Timezone Objects
-
-In most cases, the zone value may be an object
-responding to certain timezone methods.
-
-\Exceptions (timezone object not allowed):
-
-- Time.new with positional argument +zone+.
-- Time.now with keyword argument +in:+.
-
-The timezone methods are:
-
-- +local_to_utc+:
-
- - Called when Time.new is invoked with +tz+
- as the value of positional argument +zone+ or keyword argument +in:+.
- - Argument: a <tt>Time::tm</tt> object.
- - Returns: a \Time-like object in the UTC timezone.
-
-- +utc_to_local+:
-
- - Called when Time.at or Time.now is invoked with +tz+
- as the value for keyword argument +in:+,
- and when Time#getlocal or Time#localtime is called with +tz+
- as the value for positional argument +zone+.
- - Argument: a <tt>Time::tm</tt> object.
- - Returns: a \Time-like object in the local timezone.
-
-A custom timezone class may have these instance methods,
-which will be called if defined:
-
-- +abbr+:
-
- - Called when Time#strftime is invoked with a format involving <tt>%Z</tt>.
- - Argument: a <tt>Time::tm</tt> object.
- - Returns: a string abbreviation for the timezone name.
-
-- +dst?+:
-
- - Called when Time.at or Time.now is invoked with +tz+
- as the value for keyword argument +in:+,
- and when Time#getlocal or Time#localtime is called with +tz+
- as the value for positional argument +zone+.
- - Argument: a <tt>Time::tm</tt> object.
- - Returns: whether the time is daylight saving time.
-
-- +name+:
-
- - Called when <tt>Marshal.dump(t) is invoked
- - Argument: none.
- - Returns: the string name of the timezone.
diff --git a/doc/windows.md b/doc/windows.md
index d0f447350e..65c6b15c45 100644
--- a/doc/windows.md
+++ b/doc/windows.md
@@ -2,9 +2,9 @@
Ruby supports a few native build platforms for Windows.
-* mswin: Build using Microsoft Visual C++ compiler
+* mswin: Build using Microsoft Visual C++ compiler with vcruntimeXXX.dll
* mingw-msvcrt: Build using compiler for Mingw with msvcrtXX.dll
-* mingw-ucrt: Build using compiler for Mingw with vcruntime.dll
+* mingw-ucrt: Build using compiler for Mingw with Windows Universal CRT
## Building Ruby using Mingw with UCRT
@@ -19,7 +19,7 @@ Ruby core development can be done either in Windows `cmd` like:
```
ridk enable ucrt64
-pacman -S --needed bison %MINGW_PACKAGE_PREFIX%-openssl %MINGW_PACKAGE_PREFIX%-libyaml %MINGW_PACKAGE_PREFIX%-readline
+pacman -S --needed %MINGW_PACKAGE_PREFIX%-openssl %MINGW_PACKAGE_PREFIX%-libyaml %MINGW_PACKAGE_PREFIX%-libffi
cd c:\
mkdir work
@@ -38,7 +38,7 @@ or in MSYS2 `bash` like:
ridk enable ucrt64
bash
-pacman -S --needed bison $MINGW_PACKAGE_PREFIX-openssl $MINGW_PACKAGE_PREFIX-libyaml $MINGW_PACKAGE_PREFIX-readline
+pacman -S --needed $MINGW_PACKAGE_PREFIX-openssl $MINGW_PACKAGE_PREFIX-libyaml $MINGW_PACKAGE_PREFIX-libffi
cd /c/
mkdir work
@@ -78,7 +78,6 @@ make
* dumpbin
4. If you want to build from GIT source, following commands are required.
- * bison
* patch
* sed
* ruby 2.0 or later
@@ -86,7 +85,7 @@ make
You can use [scoop](https://scoop.sh/) to install them like:
```
- scoop install git ruby winflexbison sed patch
+ scoop install git ruby sed patch
```
5. You need to install required libraries using [vcpkg](https://vcpkg.io/) like:
diff --git a/doc/yjit/yjit.md b/doc/yjit/yjit.md
index 407680cc69..e6446e3ed1 100644
--- a/doc/yjit/yjit.md
+++ b/doc/yjit/yjit.md
@@ -4,26 +4,27 @@
</a>
</p>
-
YJIT - Yet Another Ruby JIT
===========================
YJIT is a lightweight, minimalistic Ruby JIT built inside CRuby.
-It lazily compiles code using a Basic Block Versioning (BBV) architecture. The target use case is that of servers running
-Ruby on Rails, an area where MJIT has not yet managed to deliver speedups.
+It lazily compiles code using a Basic Block Versioning (BBV) architecture.
YJIT is currently supported for macOS, Linux and BSD on x86-64 and arm64/aarch64 CPUs.
This project is open source and falls under the same license as CRuby.
<p align="center"><b>
If you're using YJIT in production, please
<a href="mailto:maxime.chevalierboisvert@shopify.com">share your success stories with us!</a>
- </b></p>
+</b></p>
If you wish to learn more about the approach taken, here are some conference talks and publications:
+- RubyKaigi 2023 keynote: [Optimizing YJIT’s Performance, from Inception to Production](https://www.youtube.com/watch?v=X0JRhh8w_4I)
+- RubyKaigi 2023 keynote: [Fitting Rust YJIT into CRuby](https://www.youtube.com/watch?v=GI7vvAgP_Qs)
- RubyKaigi 2022 keynote: [Stories from developing YJIT](https://www.youtube.com/watch?v=EMchdR9C8XM)
- RubyKaigi 2022 talk: [Building a Lightweight IR and Backend for YJIT](https://www.youtube.com/watch?v=BbLGqTxTRp0)
- RubyKaigi 2021 talk: [YJIT: Building a New JIT Compiler Inside CRuby](https://www.youtube.com/watch?v=PBVLf3yfMs8)
- Blog post: [YJIT: Building a New JIT Compiler Inside CRuby](https://pointersgonewild.com/2021/06/02/yjit-building-a-new-jit-compiler-inside-cruby/)
+- MPLR 2023 paper: [Evaluating YJIT’s Performance in a Production Context: A Pragmatic Approach](https://dl.acm.org/doi/10.1145/3617651.3622982)
- VMIL 2021 paper: [YJIT: A Basic Block Versioning JIT Compiler for CRuby](https://dl.acm.org/doi/10.1145/3486606.3486781)
- MoreVMs 2021 talk: [YJIT: Building a New JIT Compiler Inside CRuby](https://www.youtube.com/watch?v=vucLAqv7qpc)
- ECOOP 2016 talk: [Interprocedural Type Specialization of JavaScript Programs Without Type Analysis](https://www.youtube.com/watch?v=sRNBY7Ss97A)
@@ -31,32 +32,31 @@ If you wish to learn more about the approach taken, here are some conference tal
- ECOOP 2015 talk: [Simple and Effective Type Check Removal through Lazy Basic Block Versioning](https://www.youtube.com/watch?v=S-aHBuoiYE0)
- ECOOP 2015 paper: [Simple and Effective Type Check Removal through Lazy Basic Block Versioning](https://arxiv.org/pdf/1411.0352.pdf)
-To cite YJIT in your publications, please cite the VMIL 2021 paper:
+To cite YJIT in your publications, please cite the MPLR 2023 paper:
```
-@inproceedings{yjit_vmil2021,
-author = {Chevalier-Boisvert, Maxime and Gibbs, Noah and Boussier, Jean and Wu, Si Xing (Alan) and Patterson, Aaron and Newton, Kevin and Hawthorn, John},
-title = {YJIT: A Basic Block Versioning JIT Compiler for CRuby},
-year = {2021},
-isbn = {9781450391092},
+@inproceedings{yjit_mplr_2023,
+author = {Chevalier-Boisvert, Maxime and Kokubun, Takashi and Gibbs, Noah and Wu, Si Xing (Alan) and Patterson, Aaron and Issroff, Jemma},
+title = {Evaluating YJIT’s Performance in a Production Context: A Pragmatic Approach},
+year = {2023},
+isbn = {9798400703805},
publisher = {Association for Computing Machinery},
address = {New York, NY, USA},
-url = {https://doi.org/10.1145/3486606.3486781},
-doi = {10.1145/3486606.3486781},
-booktitle = {Proceedings of the 13th ACM SIGPLAN International Workshop on Virtual Machines and Intermediate Languages},
-pages = {25–32},
-numpages = {8},
-keywords = {ruby, dynamically typed, compiler, optimization, just-in-time, bytecode},
-location = {Chicago, IL, USA},
-series = {VMIL 2021}
+url = {https://doi.org/10.1145/3617651.3622982},
+doi = {10.1145/3617651.3622982},
+booktitle = {Proceedings of the 20th ACM SIGPLAN International Conference on Managed Programming Languages and Runtimes},
+pages = {20–33},
+numpages = {14},
+keywords = {dynamically typed, optimization, just-in-time, virtual machine, ruby, compiler, bytecode},
+location = {Cascais, Portugal},
+series = {MPLR 2023}
}
```
## Current Limitations
-YJIT may not be suitable for certain applications. It currently only supports macOS and Linux on x86-64 and arm64/aarch64 CPUs. YJIT will use more memory than the Ruby interpreter because the JIT compiler needs to generate machine code in memory and maintain additional state
-information.
-You can change how much executable memory is allocated using [YJIT's command-line options](#command-line-options). There is a slight performance tradeoff because allocating less executable memory could result in the generated machine code being collected more often.
+YJIT may not be suitable for certain applications. It currently only supports macOS, Linux and BSD on x86-64 and arm64/aarch64 CPUs. YJIT will use more memory than the Ruby interpreter because the JIT compiler needs to generate machine code in memory and maintain additional state information.
+You can change how much executable memory is allocated using [YJIT's command-line options](#command-line-options).
## Installation
@@ -82,34 +82,43 @@ git clone https://github.com/ruby/ruby yjit
cd yjit
```
-The YJIT `ruby` binary can be built with either GCC or Clang. It can be built either in dev (debug) mode or in release mode. For maximum performance, compile YJIT in release mode with GCC. More detailed build instructions are provided in the [Ruby README](https://github.com/ruby/ruby#how-to-compile-and-install).
+The YJIT `ruby` binary can be built with either GCC or Clang. It can be built either in dev (debug) mode or in release mode. For maximum performance, compile YJIT in release mode with GCC. More detailed build instructions are provided in the [Ruby README](https://github.com/ruby/ruby#how-to-build).
```sh
# Configure in release mode for maximum performance, build and install
./autogen.sh
./configure --enable-yjit --prefix=$HOME/.rubies/ruby-yjit --disable-install-doc
-make -j install
+make -j && make install
```
or
```sh
-# Configure in dev (debug) mode for development, build and install
+# Configure in lower-performance dev (debug) mode for development, build and install
./autogen.sh
./configure --enable-yjit=dev --prefix=$HOME/.rubies/ruby-yjit --disable-install-doc
-make -j install
+make -j && make install
+```
+
+Dev mode includes extended YJIT statistics, but can be slow. For only statistics you can configure in stats mode:
+
+```sh
+# Configure in extended-stats mode without slow runtime checks, build and install
+./autogen.sh
+./configure --enable-yjit=stats --prefix=$HOME/.rubies/ruby-yjit --disable-install-doc
+make -j && make install
```
On macOS, you may need to specify where to find some libraries:
```sh
# Install dependencies
-brew install openssl readline libyaml
+brew install openssl libyaml
# Configure in dev (debug) mode for development, build and install
./autogen.sh
./configure --enable-yjit=dev --prefix=$HOME/.rubies/ruby-yjit --disable-install-doc --with-opt-dir="$(brew --prefix openssl):$(brew --prefix readline):$(brew --prefix libyaml)"
-make -j install
+make -j && make install
```
Typically configure will choose the default C compiler. To specify the C compiler, use
@@ -156,40 +165,109 @@ The machine code generated for a given method can be printed by adding `puts Rub
YJIT supports all command-line options supported by upstream CRuby, but also adds a few YJIT-specific options:
- `--yjit`: enable YJIT (disabled by default)
-- `--yjit-call-threshold=N`: number of calls after which YJIT begins to compile a function (default 30)
-- `--yjit-exec-mem-size=N`: size of the executable memory block to allocate, in MiB (default 64 MiB)
-- `--yjit-stats`: produce statistics after the execution of a program (incurs a run-time cost)
-- `--yjit-trace-exits`: produce a Marshal dump of backtraces from specific exits. Automatically enables `--yjit-stats` (must configure and build with `--enable-yjit=stats` to use this)
-- `--yjit-max-versions=N`: maximum number of versions to generate per basic block (default 4)
-- `--yjit-greedy-versioning`: greedy versioning mode (disabled by default, may increase code size)
+- `--yjit-exec-mem-size=N`: size of the executable memory block to allocate, in MiB (default 48 MiB)
+- `--yjit-call-threshold=N`: number of calls after which YJIT begins to compile a function.
+ It defaults to 30, and it's then increased to 120 when the number of ISEQs in the process reaches 40,000.
+- `--yjit-cold-threshold=N`: number of global calls after which an ISEQ is considered cold and not
+ compiled, lower values mean less code is compiled (default 200K)
+- `--yjit-stats`: print statistics after the execution of a program (incurs a run-time cost)
+- `--yjit-stats=quiet`: gather statistics while running a program but don't print them. Stats are accessible through `RubyVM::YJIT.runtime_stats`. (incurs a run-time cost)
+- `--yjit-disable`: disable YJIT despite other `--yjit*` flags for lazily enabling it with `RubyVM::YJIT.enable`
+- `--yjit-code-gc`: enable code GC (disabled by default as of Ruby 3.3).
+ It will cause all machine code to be discarded when the executable memory size limit is hit, meaning JIT compilation will then start over.
+ This can allow you to use a lower executable memory size limit, but may cause a slight drop in performance when the limit is hit.
+- `--yjit-perf`: enable frame pointers and profiling with the `perf` tool
+- `--yjit-trace-exits`: produce a Marshal dump of backtraces from specific exits. Automatically enables `--yjit-stats`
+- `--yjit-trace-exits-sample-rate=N`: trace exit locations only every Nth occurrence
Note that there is also an environment variable `RUBY_YJIT_ENABLE` which can be used to enable YJIT.
This can be useful for some deployment scripts where specifying an extra command-line option to Ruby is not practical.
-You can verify that YJIT is enabled by checking that `ruby -v --yjit` includes the string `+YJIT`:
+You can also enable YJIT at run-time using `RubyVM::YJIT.enable`. This can allow you to enable YJIT after your application is done
+booting, which makes it possible to avoid compiling any initialization code.
+
+You can verify that YJIT is enabled using `RubyVM::YJIT.enabled?` or by checking that `ruby --yjit -v` includes the string `+YJIT`:
```sh
-ruby -v --yjit
+ruby --yjit -v
ruby 3.3.0dev (2023-01-31T15:11:10Z master 2a0bf269c9) +YJIT dev [x86_64-darwin22]
+
+ruby --yjit -e "p RubyVM::YJIT.enabled?"
+true
+
+ruby -e "RubyVM::YJIT.enable; p RubyVM::YJIT.enabled?"
+true
```
### Benchmarking
-We have collected a set of benchmarks and implemented a simple benchmarking harness in the [yjit-bench](https://github.com/Shopify/yjit-bench) repository. This benchmarking harness is designed to disable CPU frequency scaling, set process affinity and disable address space randomization so that the variance between benchmarking runs will be as small as possible. Please kindly note that we are at an early stage in this project.
+We have collected a set of benchmarks and implemented a simple benchmarking harness in the [yjit-bench](https://github.com/Shopify/yjit-bench) repository. This benchmarking harness is designed to disable CPU frequency scaling, set process affinity and disable address space randomization so that the variance between benchmarking runs will be as small as possible.
+
+## Performance Tips for Production Deployments
+
+While YJIT options default to what we think would work well for most workloads,
+they might not necessarily be the best configuration for your application.
+This section covers tips on improving YJIT performance in case YJIT does not
+speed up your application in production.
+
+### Increasing --yjit-exec-mem-size
+
+When JIT code size (`RubyVM::YJIT.runtime_stats[:code_region_size]`) reaches this value,
+YJIT stops compiling new code. Increasing the executable memory size means more code
+can be optimized by YJIT, at the cost of more memory usage.
+
+If you start Ruby with `--yjit-stats`, e.g. using an environment variable `RUBYOPT=--yjit-stats`,
+`RubyVM::YJIT.runtime_stats[:ratio_in_yjit]` shows the ratio of YJIT-executed instructions in %.
+Ideally, `ratio_in_yjit` should be as large as 99%, and increasing `--yjit-exec-mem-size` often
+helps improving `ratio_in_yjit`.
+
+### Running workers as long as possible
+
+It's helpful to call the same code as many times as possible before a process restarts.
+If a process is killed too frequently, the time taken for compiling methods may outweigh
+the speedup obtained by compiling them.
+
+You should monitor the number of requests each process has served.
+If you're periodically killing worker processes, e.g. with `unicorn-worker-killer` or `puma_worker_killer`,
+you may want to reduce the killing frequency or increase the limit.
-### Performance Tips
+## Reducing YJIT Memory Usage
+
+YJIT allocates memory for JIT code and metadata. Enabling YJIT generally results in more memory usage.
+This section goes over tips on minimizing YJIT memory usage in case it uses more than your capacity.
+
+### Decreasing --yjit-exec-mem-size
+
+The `--yjit-exec-mem-size` option specifies the JIT code size, but YJIT also uses memory for its metadata,
+which often consumes more memory than JIT code. Generally, YJIT adds memory overhead by roughly
+3-4x of `--yjit-exec-mem-size` in production as of Ruby 3.3. You should multiply that by the number
+of worker processes to estimate the worst case memory overhead.
+
+`--yjit-exec-mem-size=48` is the default since Ruby 3.3.1,
+but smaller values like 32 MiB might make sense for your application.
+While doing so, you may want to monitor `RubyVM::YJIT.runtime_stats[:ratio_in_yjit]` as explained above.
+
+### Enabling YJIT lazily
+
+If you enable YJIT by `--yjit` options or `RUBY_YJIT_ENABLE=1`, YJIT may compile code that is
+used only during the application boot. `RubyVM::YJIT.enable` allows you to enable YJIT from Ruby code,
+and you can call this after your application is initialized, e.g. on Unicorn's `after_fork` hook.
+If you use any YJIT options (`--yjit-*`), YJIT will start at boot by default, but `--yjit-disable`
+allows you to start Ruby with the YJIT-disabled mode while passing YJIT tuning options.
+
+## Code Optimization Tips
This section contains tips on writing Ruby code that will run as fast as possible on YJIT. Some of this advice is based on current limitations of YJIT, while other advice is broadly applicable. It probably won't be practical to apply these tips everywhere in your codebase. You should ideally start by profiling your application using a tool such as [stackprof](https://github.com/tmm1/stackprof) so that you can determine which methods make up most of the execution time. You can then refactor the specific methods that make up the largest fractions of the execution time. We do not recommend modifying your entire codebase based on the current limitations of YJIT.
-- Use exceptions for error recovery only, not as part of normal control-flow
+- Avoid using `OpenStruct`
- Avoid redefining basic integer operations (i.e. +, -, <, >, etc.)
- Avoid redefining the meaning of `nil`, equality, etc.
- Avoid allocating objects in the hot parts of your code
- Minimize layers of indirection
- Avoid classes that wrap objects if you can
- - Avoid methods that just call another method, trivial one liner methods
+ - Avoid methods that just call another method, trivial one-liner methods
- Try to write code so that the same variables always have the same type
-- Use while loops if you can, instead of `integer.times`
+- Use `while` loops if you can, instead of C methods like `Array#each`
- This is not idiomatic Ruby, but could help in hot methods
- CRuby method calls are costly. Avoid things such as methods that only return a value from a hash or return a constant.
@@ -197,16 +275,16 @@ You can also use the `--yjit-stats` command-line option to see which bytecodes c
### Other Statistics
-If you compile Ruby with `RUBY_DEBUG` and/or `YJIT_STATS` defined and run with `--yjit --yjit-stats`, YJIT will track and return performance statistics in `RubyVM::YJIT.runtime_stats`.
+If you run `ruby` with `--yjit-stats`, YJIT will track and return performance statistics in `RubyVM::YJIT.runtime_stats`.
```rb
-$ RUBYOPT="--yjit --yjit-stats" irb
+$ RUBYOPT="--yjit-stats" irb
irb(main):001:0> RubyVM::YJIT.runtime_stats
=>
{:inline_code_size=>340745,
:outlined_code_size=>297664,
:all_stats=>true,
- :exec_instruction=>1547816,
+ :yjit_insns_count=>1547816,
:send_callsite_not_simple=>7267,
:send_kw_splat=>7,
:send_ivar_set_method=>72,
@@ -215,29 +293,38 @@ irb(main):001:0> RubyVM::YJIT.runtime_stats
Some of the counters include:
-:exec_instruction - how many Ruby bytecode instructions have been executed
-:binding_allocations - number of bindings allocated
-:binding_set - number of variables set via a binding
-:vm_insns_count - number of instructions executed by the Ruby interpreter
-:compiled_iseq_count - number of bytecode sequences compiled
+* :yjit_insns_count - how many Ruby bytecode instructions have been executed
+* :binding_allocations - number of bindings allocated
+* :binding_set - number of variables set via a binding
+* :code_gc_count - number of garbage collections of compiled code since process start
+* :vm_insns_count - number of instructions executed by the Ruby interpreter
+* :compiled_iseq_count - number of bytecode sequences compiled
+* :inline_code_size - size in bytes of compiled YJIT blocks
+* :outline_code_size - size in bytes of YJIT error-handling compiled code
+* :side_exit_count - number of side exits taken at runtime
+* :total_exit_count - number of exits, including side exits, taken at runtime
+* :avg_len_in_yjit - avg. number of instructions in compiled blocks before exiting to interpreter
-Counters starting with "exit_" show reasons for YJIT code taking a side exit (return to the interpreter.) See yjit_hacking.md for more details.
+Counters starting with "exit_" show reasons for YJIT code taking a side exit (return to the interpreter.)
-Performance counter names are not guaranteed to remain the same between Ruby versions. If you're curious what one does, it's usually best to search the source code for it &mdash; but it may change in a later Ruby version.
+Performance counter names are not guaranteed to remain the same between Ruby versions. If you're curious what each counter means,
+it's usually best to search the source code for it &mdash; but it may change in a later Ruby version.
+
+The printed text after a `--yjit-stats` run includes other information that may be named differently than the information in `RubyVM::YJIT.runtime_stats`.
## Contributing
-We welcome open source contributors. You should feel free to open new issues to report bugs or just to ask questions.
+We welcome open source contributions. You should feel free to open new issues to report bugs or just to ask questions.
Suggestions on how to make this readme file more helpful for new contributors are most welcome.
Bug fixes and bug reports are very valuable to us. If you find a bug in YJIT, it's very possible be that nobody has reported it before,
or that we don't have a good reproduction for it, so please open an issue and provide as much information as you can about your configuration and a description of how you encountered the problem. List the commands you used to run YJIT so that we can easily reproduce the issue on our end and investigate it. If you are able to produce a small program reproducing the error to help us track it down, that is very much appreciated as well.
-If you would like to contribute a large patch to YJIT, we suggest opening an issue or a discussion on this repository so that
+If you would like to contribute a large patch to YJIT, we suggest opening an issue or a discussion on the [Shopify/ruby repository](https://github.com/Shopify/ruby/issues) so that
we can have an active discussion. A common problem is that sometimes people submit large pull requests to open source projects
without prior communication, and we have to reject them because the work they implemented does not fit within the design of the
-project. We want to save you time and frustration, so please reach out and we can have a productive discussion as to how
-you can contribute things we will want to merge into YJIT.
+project. We want to save you time and frustration, so please reach out so we can have a productive discussion as to how
+you can contribute patches we will want to merge into YJIT.
### Source Code Organization
@@ -250,8 +337,8 @@ The YJIT source code is divided between:
- `yjit/src/core.rb`: basic block versioning logic, core structure of YJIT
- `yjit/src/stats.rs`: gathering of run-time statistics
- `yjit/src/options.rs`: handling of command-line options
-- `yjit/bindgen/src/main.rs`: C bindings exposed to the Rust codebase through bindgen
- `yjit/src/cruby.rs`: C bindings manually exposed to the Rust codebase
+- `yjit/bindgen/src/main.rs`: C bindings exposed to the Rust codebase through bindgen
The core of CRuby's interpreter logic is found in:
- `insns.def`: defines Ruby's bytecode instructions (gets compiled into `vm.inc`)
@@ -274,11 +361,12 @@ add them to `yjit/cruby.rs` instead.
### Coding & Debugging Protips
-There are 3 test suites:
+There are multiple test suites:
- `make btest` (see `/bootstraptest`)
- `make test-all`
- `make test-spec`
- `make check` runs all of the above
+- `make yjit-smoke-test` runs quick checks to see that YJIT is working correctly
The tests can be run in parallel like this:
@@ -358,3 +446,30 @@ While in your i386 shell, install Cargo and Homebrew, then hack away!
2. Cargo will install in $HOME/.cargo by default, and I don't know a good way to change architectures after install
If you use Fish shell you can [read this link](https://tenderlovemaking.com/2022/01/07/homebrew-rosetta-and-ruby.html) for information on making the dev environment easier.
+
+## Profiling with Linux perf
+
+`--yjit-perf` allows you to profile JIT-ed methods along with other native functions using Linux perf.
+When you run Ruby with `perf record`, perf looks up `/tmp/perf-{pid}.map` to resolve symbols in JIT code,
+and this option lets YJIT write method symbols into that file as well as enabling frame pointers.
+
+Here's an example way to use this option with [Firefox Profiler](https://profiler.firefox.com)
+(See also: [Profiling with Linux perf](https://profiler.firefox.com/docs/#/./guide-perf-profiling)):
+
+```bash
+# Compile the interpreter with frame pointers enabled
+./configure --enable-yjit --prefix=$HOME/.rubies/ruby-yjit --disable-install-doc cflags=-fno-omit-frame-pointer
+make -j && make install
+
+# [Optional] Allow running perf without sudo
+echo 0 | sudo tee /proc/sys/kernel/kptr_restrict
+echo -1 | sudo tee /proc/sys/kernel/perf_event_paranoid
+
+# Profile Ruby with --yjit-perf
+cd ../yjit-bench
+perf record --call-graph fp -- ruby --yjit-perf -Iharness-perf benchmarks/liquid-render/benchmark.rb
+
+# View results on Firefox Profiler https://profiler.firefox.com.
+# Create /tmp/test.perf as below and upload it using "Load a profile from file".
+perf script --fields +pid > /tmp/test.perf
+```
diff --git a/enc/cesu_8.c b/enc/cesu_8.c
index decbb928f4..75f62df280 100644
--- a/enc/cesu_8.c
+++ b/enc/cesu_8.c
@@ -42,6 +42,8 @@
#define VALID_CODE_LIMIT 0x0010ffff
#define utf8_islead(c) ((UChar )((c) & 0xc0) != 0x80)
+#define utf16_is_high_surrogate(v) ((v >> 10) == 0x36)
+#define utf16_is_low_surrogate(v) ((v >> 10) == 0x37)
static const int EncLen_CESU8[] = {
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
@@ -283,6 +285,12 @@ is_mbc_newline(const UChar* p, const UChar* end, OnigEncoding enc)
return 0;
}
+static int
+utf8_decode_3byte_sequence(const UChar* p)
+{
+ return ((p[0] & 0xF) << 12) | ((p[1] & 0x3f) << 6) | (p[2] & 0x3f);
+}
+
static OnigCodePoint
mbc_to_code(const UChar* p, const UChar* end, OnigEncoding enc)
{
@@ -295,11 +303,11 @@ mbc_to_code(const UChar* p, const UChar* end, OnigEncoding enc)
case 2:
return ((p[0] & 0x1F) << 6) | (p[1] & 0x3f);
case 3:
- return ((p[0] & 0xF) << 12) | ((p[1] & 0x3f) << 6) | (p[2] & 0x3f);
+ return utf8_decode_3byte_sequence(p);
case 6:
{
- int high = ((p[0] & 0xF) << 12) | ((p[1] & 0x3f) << 6) | (p[2] & 0x3f);
- int low = ((p[3] & 0xF) << 12) | ((p[4] & 0x3f) << 6) | (p[5] & 0x3f);
+ int high = utf8_decode_3byte_sequence(p);
+ int low = utf8_decode_3byte_sequence(p + 3);
return ((high & 0x03ff) << 10) + (low & 0x03ff) + 0x10000;
}
}
@@ -410,7 +418,6 @@ get_ctype_code_range(OnigCtype ctype, OnigCodePoint *sb_out,
return onigenc_unicode_ctype_code_range(ctype, ranges);
}
-
static UChar*
left_adjust_char_head(const UChar* start, const UChar* s, const UChar* end, OnigEncoding enc ARG_UNUSED)
{
@@ -420,6 +427,14 @@ left_adjust_char_head(const UChar* start, const UChar* s, const UChar* end, Onig
p = s;
while (!utf8_islead(*p) && p > start) p--;
+
+ if (p > start && s - p == 2 && utf16_is_low_surrogate(utf8_decode_3byte_sequence(p))) {
+ const UChar *p_surrogate_pair = p - 1;
+ while (!utf8_islead(*p_surrogate_pair) && p_surrogate_pair > start) p_surrogate_pair--;
+ if (p - p_surrogate_pair == 3 && utf16_is_high_surrogate(utf8_decode_3byte_sequence(p_surrogate_pair))) {
+ return (UChar* )p_surrogate_pair;
+ }
+ }
return (UChar* )p;
}
diff --git a/enc/depend b/enc/depend
index 60c5a3ebb2..12ddbc223a 100644
--- a/enc/depend
+++ b/enc/depend
@@ -58,12 +58,8 @@ TRANSCLEANOBJS = <%=cleanobjs.map {|clean|
LIBTRANS=enc/libtrans.$(LIBEXT)
UNICODE_HDR_DIR = --missing-unicode-header-dir--
-encs: all
-% if MODULE_TYPE == :static
-all: libenc libtrans
-% else
-all: enc trans
-%end
+encs all: <%= MODULE_TYPE == :static ? "lib" : "mod" %>encs
+modencs: enc trans
libencs: libenc libtrans
enc: $(ENCSOS)
libenc: $(LIBENC)
@@ -234,6 +230,7 @@ enc/ascii.$(OBJEXT): internal/attr/noexcept.h
enc/ascii.$(OBJEXT): internal/attr/noinline.h
enc/ascii.$(OBJEXT): internal/attr/nonnull.h
enc/ascii.$(OBJEXT): internal/attr/noreturn.h
+enc/ascii.$(OBJEXT): internal/attr/packed_struct.h
enc/ascii.$(OBJEXT): internal/attr/pure.h
enc/ascii.$(OBJEXT): internal/attr/restrict.h
enc/ascii.$(OBJEXT): internal/attr/returns_nonnull.h
@@ -302,7 +299,6 @@ enc/ascii.$(OBJEXT): internal/intern/enumerator.h
enc/ascii.$(OBJEXT): internal/intern/error.h
enc/ascii.$(OBJEXT): internal/intern/eval.h
enc/ascii.$(OBJEXT): internal/intern/file.h
-enc/ascii.$(OBJEXT): internal/intern/gc.h
enc/ascii.$(OBJEXT): internal/intern/hash.h
enc/ascii.$(OBJEXT): internal/intern/io.h
enc/ascii.$(OBJEXT): internal/intern/load.h
@@ -333,7 +329,6 @@ enc/ascii.$(OBJEXT): internal/memory.h
enc/ascii.$(OBJEXT): internal/method.h
enc/ascii.$(OBJEXT): internal/module.h
enc/ascii.$(OBJEXT): internal/newobj.h
-enc/ascii.$(OBJEXT): internal/rgengc.h
enc/ascii.$(OBJEXT): internal/scan_args.h
enc/ascii.$(OBJEXT): internal/special_consts.h
enc/ascii.$(OBJEXT): internal/static_assert.h
@@ -405,6 +400,7 @@ enc/big5.$(OBJEXT): internal/attr/noexcept.h
enc/big5.$(OBJEXT): internal/attr/noinline.h
enc/big5.$(OBJEXT): internal/attr/nonnull.h
enc/big5.$(OBJEXT): internal/attr/noreturn.h
+enc/big5.$(OBJEXT): internal/attr/packed_struct.h
enc/big5.$(OBJEXT): internal/attr/pure.h
enc/big5.$(OBJEXT): internal/attr/restrict.h
enc/big5.$(OBJEXT): internal/attr/returns_nonnull.h
@@ -464,7 +460,6 @@ enc/big5.$(OBJEXT): internal/intern/enumerator.h
enc/big5.$(OBJEXT): internal/intern/error.h
enc/big5.$(OBJEXT): internal/intern/eval.h
enc/big5.$(OBJEXT): internal/intern/file.h
-enc/big5.$(OBJEXT): internal/intern/gc.h
enc/big5.$(OBJEXT): internal/intern/hash.h
enc/big5.$(OBJEXT): internal/intern/io.h
enc/big5.$(OBJEXT): internal/intern/load.h
@@ -495,7 +490,6 @@ enc/big5.$(OBJEXT): internal/memory.h
enc/big5.$(OBJEXT): internal/method.h
enc/big5.$(OBJEXT): internal/module.h
enc/big5.$(OBJEXT): internal/newobj.h
-enc/big5.$(OBJEXT): internal/rgengc.h
enc/big5.$(OBJEXT): internal/scan_args.h
enc/big5.$(OBJEXT): internal/special_consts.h
enc/big5.$(OBJEXT): internal/static_assert.h
@@ -568,6 +562,7 @@ enc/cesu_8.$(OBJEXT): internal/attr/noexcept.h
enc/cesu_8.$(OBJEXT): internal/attr/noinline.h
enc/cesu_8.$(OBJEXT): internal/attr/nonnull.h
enc/cesu_8.$(OBJEXT): internal/attr/noreturn.h
+enc/cesu_8.$(OBJEXT): internal/attr/packed_struct.h
enc/cesu_8.$(OBJEXT): internal/attr/pure.h
enc/cesu_8.$(OBJEXT): internal/attr/restrict.h
enc/cesu_8.$(OBJEXT): internal/attr/returns_nonnull.h
@@ -636,7 +631,6 @@ enc/cesu_8.$(OBJEXT): internal/intern/enumerator.h
enc/cesu_8.$(OBJEXT): internal/intern/error.h
enc/cesu_8.$(OBJEXT): internal/intern/eval.h
enc/cesu_8.$(OBJEXT): internal/intern/file.h
-enc/cesu_8.$(OBJEXT): internal/intern/gc.h
enc/cesu_8.$(OBJEXT): internal/intern/hash.h
enc/cesu_8.$(OBJEXT): internal/intern/io.h
enc/cesu_8.$(OBJEXT): internal/intern/load.h
@@ -667,7 +661,6 @@ enc/cesu_8.$(OBJEXT): internal/memory.h
enc/cesu_8.$(OBJEXT): internal/method.h
enc/cesu_8.$(OBJEXT): internal/module.h
enc/cesu_8.$(OBJEXT): internal/newobj.h
-enc/cesu_8.$(OBJEXT): internal/rgengc.h
enc/cesu_8.$(OBJEXT): internal/scan_args.h
enc/cesu_8.$(OBJEXT): internal/special_consts.h
enc/cesu_8.$(OBJEXT): internal/static_assert.h
@@ -739,6 +732,7 @@ enc/cp949.$(OBJEXT): internal/attr/noexcept.h
enc/cp949.$(OBJEXT): internal/attr/noinline.h
enc/cp949.$(OBJEXT): internal/attr/nonnull.h
enc/cp949.$(OBJEXT): internal/attr/noreturn.h
+enc/cp949.$(OBJEXT): internal/attr/packed_struct.h
enc/cp949.$(OBJEXT): internal/attr/pure.h
enc/cp949.$(OBJEXT): internal/attr/restrict.h
enc/cp949.$(OBJEXT): internal/attr/returns_nonnull.h
@@ -798,7 +792,6 @@ enc/cp949.$(OBJEXT): internal/intern/enumerator.h
enc/cp949.$(OBJEXT): internal/intern/error.h
enc/cp949.$(OBJEXT): internal/intern/eval.h
enc/cp949.$(OBJEXT): internal/intern/file.h
-enc/cp949.$(OBJEXT): internal/intern/gc.h
enc/cp949.$(OBJEXT): internal/intern/hash.h
enc/cp949.$(OBJEXT): internal/intern/io.h
enc/cp949.$(OBJEXT): internal/intern/load.h
@@ -829,7 +822,6 @@ enc/cp949.$(OBJEXT): internal/memory.h
enc/cp949.$(OBJEXT): internal/method.h
enc/cp949.$(OBJEXT): internal/module.h
enc/cp949.$(OBJEXT): internal/newobj.h
-enc/cp949.$(OBJEXT): internal/rgengc.h
enc/cp949.$(OBJEXT): internal/scan_args.h
enc/cp949.$(OBJEXT): internal/special_consts.h
enc/cp949.$(OBJEXT): internal/static_assert.h
@@ -900,6 +892,7 @@ enc/emacs_mule.$(OBJEXT): internal/attr/noexcept.h
enc/emacs_mule.$(OBJEXT): internal/attr/noinline.h
enc/emacs_mule.$(OBJEXT): internal/attr/nonnull.h
enc/emacs_mule.$(OBJEXT): internal/attr/noreturn.h
+enc/emacs_mule.$(OBJEXT): internal/attr/packed_struct.h
enc/emacs_mule.$(OBJEXT): internal/attr/pure.h
enc/emacs_mule.$(OBJEXT): internal/attr/restrict.h
enc/emacs_mule.$(OBJEXT): internal/attr/returns_nonnull.h
@@ -959,7 +952,6 @@ enc/emacs_mule.$(OBJEXT): internal/intern/enumerator.h
enc/emacs_mule.$(OBJEXT): internal/intern/error.h
enc/emacs_mule.$(OBJEXT): internal/intern/eval.h
enc/emacs_mule.$(OBJEXT): internal/intern/file.h
-enc/emacs_mule.$(OBJEXT): internal/intern/gc.h
enc/emacs_mule.$(OBJEXT): internal/intern/hash.h
enc/emacs_mule.$(OBJEXT): internal/intern/io.h
enc/emacs_mule.$(OBJEXT): internal/intern/load.h
@@ -990,7 +982,6 @@ enc/emacs_mule.$(OBJEXT): internal/memory.h
enc/emacs_mule.$(OBJEXT): internal/method.h
enc/emacs_mule.$(OBJEXT): internal/module.h
enc/emacs_mule.$(OBJEXT): internal/newobj.h
-enc/emacs_mule.$(OBJEXT): internal/rgengc.h
enc/emacs_mule.$(OBJEXT): internal/scan_args.h
enc/emacs_mule.$(OBJEXT): internal/special_consts.h
enc/emacs_mule.$(OBJEXT): internal/static_assert.h
@@ -1062,6 +1053,7 @@ enc/encdb.$(OBJEXT): internal/attr/noexcept.h
enc/encdb.$(OBJEXT): internal/attr/noinline.h
enc/encdb.$(OBJEXT): internal/attr/nonnull.h
enc/encdb.$(OBJEXT): internal/attr/noreturn.h
+enc/encdb.$(OBJEXT): internal/attr/packed_struct.h
enc/encdb.$(OBJEXT): internal/attr/pure.h
enc/encdb.$(OBJEXT): internal/attr/restrict.h
enc/encdb.$(OBJEXT): internal/attr/returns_nonnull.h
@@ -1130,7 +1122,6 @@ enc/encdb.$(OBJEXT): internal/intern/enumerator.h
enc/encdb.$(OBJEXT): internal/intern/error.h
enc/encdb.$(OBJEXT): internal/intern/eval.h
enc/encdb.$(OBJEXT): internal/intern/file.h
-enc/encdb.$(OBJEXT): internal/intern/gc.h
enc/encdb.$(OBJEXT): internal/intern/hash.h
enc/encdb.$(OBJEXT): internal/intern/io.h
enc/encdb.$(OBJEXT): internal/intern/load.h
@@ -1161,7 +1152,6 @@ enc/encdb.$(OBJEXT): internal/memory.h
enc/encdb.$(OBJEXT): internal/method.h
enc/encdb.$(OBJEXT): internal/module.h
enc/encdb.$(OBJEXT): internal/newobj.h
-enc/encdb.$(OBJEXT): internal/rgengc.h
enc/encdb.$(OBJEXT): internal/scan_args.h
enc/encdb.$(OBJEXT): internal/special_consts.h
enc/encdb.$(OBJEXT): internal/static_assert.h
@@ -1235,6 +1225,7 @@ enc/euc_jp.$(OBJEXT): internal/attr/noexcept.h
enc/euc_jp.$(OBJEXT): internal/attr/noinline.h
enc/euc_jp.$(OBJEXT): internal/attr/nonnull.h
enc/euc_jp.$(OBJEXT): internal/attr/noreturn.h
+enc/euc_jp.$(OBJEXT): internal/attr/packed_struct.h
enc/euc_jp.$(OBJEXT): internal/attr/pure.h
enc/euc_jp.$(OBJEXT): internal/attr/restrict.h
enc/euc_jp.$(OBJEXT): internal/attr/returns_nonnull.h
@@ -1294,7 +1285,6 @@ enc/euc_jp.$(OBJEXT): internal/intern/enumerator.h
enc/euc_jp.$(OBJEXT): internal/intern/error.h
enc/euc_jp.$(OBJEXT): internal/intern/eval.h
enc/euc_jp.$(OBJEXT): internal/intern/file.h
-enc/euc_jp.$(OBJEXT): internal/intern/gc.h
enc/euc_jp.$(OBJEXT): internal/intern/hash.h
enc/euc_jp.$(OBJEXT): internal/intern/io.h
enc/euc_jp.$(OBJEXT): internal/intern/load.h
@@ -1325,7 +1315,6 @@ enc/euc_jp.$(OBJEXT): internal/memory.h
enc/euc_jp.$(OBJEXT): internal/method.h
enc/euc_jp.$(OBJEXT): internal/module.h
enc/euc_jp.$(OBJEXT): internal/newobj.h
-enc/euc_jp.$(OBJEXT): internal/rgengc.h
enc/euc_jp.$(OBJEXT): internal/scan_args.h
enc/euc_jp.$(OBJEXT): internal/special_consts.h
enc/euc_jp.$(OBJEXT): internal/static_assert.h
@@ -1396,6 +1385,7 @@ enc/euc_kr.$(OBJEXT): internal/attr/noexcept.h
enc/euc_kr.$(OBJEXT): internal/attr/noinline.h
enc/euc_kr.$(OBJEXT): internal/attr/nonnull.h
enc/euc_kr.$(OBJEXT): internal/attr/noreturn.h
+enc/euc_kr.$(OBJEXT): internal/attr/packed_struct.h
enc/euc_kr.$(OBJEXT): internal/attr/pure.h
enc/euc_kr.$(OBJEXT): internal/attr/restrict.h
enc/euc_kr.$(OBJEXT): internal/attr/returns_nonnull.h
@@ -1455,7 +1445,6 @@ enc/euc_kr.$(OBJEXT): internal/intern/enumerator.h
enc/euc_kr.$(OBJEXT): internal/intern/error.h
enc/euc_kr.$(OBJEXT): internal/intern/eval.h
enc/euc_kr.$(OBJEXT): internal/intern/file.h
-enc/euc_kr.$(OBJEXT): internal/intern/gc.h
enc/euc_kr.$(OBJEXT): internal/intern/hash.h
enc/euc_kr.$(OBJEXT): internal/intern/io.h
enc/euc_kr.$(OBJEXT): internal/intern/load.h
@@ -1486,7 +1475,6 @@ enc/euc_kr.$(OBJEXT): internal/memory.h
enc/euc_kr.$(OBJEXT): internal/method.h
enc/euc_kr.$(OBJEXT): internal/module.h
enc/euc_kr.$(OBJEXT): internal/newobj.h
-enc/euc_kr.$(OBJEXT): internal/rgengc.h
enc/euc_kr.$(OBJEXT): internal/scan_args.h
enc/euc_kr.$(OBJEXT): internal/special_consts.h
enc/euc_kr.$(OBJEXT): internal/static_assert.h
@@ -1557,6 +1545,7 @@ enc/euc_tw.$(OBJEXT): internal/attr/noexcept.h
enc/euc_tw.$(OBJEXT): internal/attr/noinline.h
enc/euc_tw.$(OBJEXT): internal/attr/nonnull.h
enc/euc_tw.$(OBJEXT): internal/attr/noreturn.h
+enc/euc_tw.$(OBJEXT): internal/attr/packed_struct.h
enc/euc_tw.$(OBJEXT): internal/attr/pure.h
enc/euc_tw.$(OBJEXT): internal/attr/restrict.h
enc/euc_tw.$(OBJEXT): internal/attr/returns_nonnull.h
@@ -1616,7 +1605,6 @@ enc/euc_tw.$(OBJEXT): internal/intern/enumerator.h
enc/euc_tw.$(OBJEXT): internal/intern/error.h
enc/euc_tw.$(OBJEXT): internal/intern/eval.h
enc/euc_tw.$(OBJEXT): internal/intern/file.h
-enc/euc_tw.$(OBJEXT): internal/intern/gc.h
enc/euc_tw.$(OBJEXT): internal/intern/hash.h
enc/euc_tw.$(OBJEXT): internal/intern/io.h
enc/euc_tw.$(OBJEXT): internal/intern/load.h
@@ -1647,7 +1635,6 @@ enc/euc_tw.$(OBJEXT): internal/memory.h
enc/euc_tw.$(OBJEXT): internal/method.h
enc/euc_tw.$(OBJEXT): internal/module.h
enc/euc_tw.$(OBJEXT): internal/newobj.h
-enc/euc_tw.$(OBJEXT): internal/rgengc.h
enc/euc_tw.$(OBJEXT): internal/scan_args.h
enc/euc_tw.$(OBJEXT): internal/special_consts.h
enc/euc_tw.$(OBJEXT): internal/static_assert.h
@@ -1718,6 +1705,7 @@ enc/gb18030.$(OBJEXT): internal/attr/noexcept.h
enc/gb18030.$(OBJEXT): internal/attr/noinline.h
enc/gb18030.$(OBJEXT): internal/attr/nonnull.h
enc/gb18030.$(OBJEXT): internal/attr/noreturn.h
+enc/gb18030.$(OBJEXT): internal/attr/packed_struct.h
enc/gb18030.$(OBJEXT): internal/attr/pure.h
enc/gb18030.$(OBJEXT): internal/attr/restrict.h
enc/gb18030.$(OBJEXT): internal/attr/returns_nonnull.h
@@ -1777,7 +1765,6 @@ enc/gb18030.$(OBJEXT): internal/intern/enumerator.h
enc/gb18030.$(OBJEXT): internal/intern/error.h
enc/gb18030.$(OBJEXT): internal/intern/eval.h
enc/gb18030.$(OBJEXT): internal/intern/file.h
-enc/gb18030.$(OBJEXT): internal/intern/gc.h
enc/gb18030.$(OBJEXT): internal/intern/hash.h
enc/gb18030.$(OBJEXT): internal/intern/io.h
enc/gb18030.$(OBJEXT): internal/intern/load.h
@@ -1808,7 +1795,6 @@ enc/gb18030.$(OBJEXT): internal/memory.h
enc/gb18030.$(OBJEXT): internal/method.h
enc/gb18030.$(OBJEXT): internal/module.h
enc/gb18030.$(OBJEXT): internal/newobj.h
-enc/gb18030.$(OBJEXT): internal/rgengc.h
enc/gb18030.$(OBJEXT): internal/scan_args.h
enc/gb18030.$(OBJEXT): internal/special_consts.h
enc/gb18030.$(OBJEXT): internal/static_assert.h
@@ -1879,6 +1865,7 @@ enc/gb2312.$(OBJEXT): internal/attr/noexcept.h
enc/gb2312.$(OBJEXT): internal/attr/noinline.h
enc/gb2312.$(OBJEXT): internal/attr/nonnull.h
enc/gb2312.$(OBJEXT): internal/attr/noreturn.h
+enc/gb2312.$(OBJEXT): internal/attr/packed_struct.h
enc/gb2312.$(OBJEXT): internal/attr/pure.h
enc/gb2312.$(OBJEXT): internal/attr/restrict.h
enc/gb2312.$(OBJEXT): internal/attr/returns_nonnull.h
@@ -1938,7 +1925,6 @@ enc/gb2312.$(OBJEXT): internal/intern/enumerator.h
enc/gb2312.$(OBJEXT): internal/intern/error.h
enc/gb2312.$(OBJEXT): internal/intern/eval.h
enc/gb2312.$(OBJEXT): internal/intern/file.h
-enc/gb2312.$(OBJEXT): internal/intern/gc.h
enc/gb2312.$(OBJEXT): internal/intern/hash.h
enc/gb2312.$(OBJEXT): internal/intern/io.h
enc/gb2312.$(OBJEXT): internal/intern/load.h
@@ -1969,7 +1955,6 @@ enc/gb2312.$(OBJEXT): internal/memory.h
enc/gb2312.$(OBJEXT): internal/method.h
enc/gb2312.$(OBJEXT): internal/module.h
enc/gb2312.$(OBJEXT): internal/newobj.h
-enc/gb2312.$(OBJEXT): internal/rgengc.h
enc/gb2312.$(OBJEXT): internal/scan_args.h
enc/gb2312.$(OBJEXT): internal/special_consts.h
enc/gb2312.$(OBJEXT): internal/static_assert.h
@@ -2040,6 +2025,7 @@ enc/gbk.$(OBJEXT): internal/attr/noexcept.h
enc/gbk.$(OBJEXT): internal/attr/noinline.h
enc/gbk.$(OBJEXT): internal/attr/nonnull.h
enc/gbk.$(OBJEXT): internal/attr/noreturn.h
+enc/gbk.$(OBJEXT): internal/attr/packed_struct.h
enc/gbk.$(OBJEXT): internal/attr/pure.h
enc/gbk.$(OBJEXT): internal/attr/restrict.h
enc/gbk.$(OBJEXT): internal/attr/returns_nonnull.h
@@ -2099,7 +2085,6 @@ enc/gbk.$(OBJEXT): internal/intern/enumerator.h
enc/gbk.$(OBJEXT): internal/intern/error.h
enc/gbk.$(OBJEXT): internal/intern/eval.h
enc/gbk.$(OBJEXT): internal/intern/file.h
-enc/gbk.$(OBJEXT): internal/intern/gc.h
enc/gbk.$(OBJEXT): internal/intern/hash.h
enc/gbk.$(OBJEXT): internal/intern/io.h
enc/gbk.$(OBJEXT): internal/intern/load.h
@@ -2130,7 +2115,6 @@ enc/gbk.$(OBJEXT): internal/memory.h
enc/gbk.$(OBJEXT): internal/method.h
enc/gbk.$(OBJEXT): internal/module.h
enc/gbk.$(OBJEXT): internal/newobj.h
-enc/gbk.$(OBJEXT): internal/rgengc.h
enc/gbk.$(OBJEXT): internal/scan_args.h
enc/gbk.$(OBJEXT): internal/special_consts.h
enc/gbk.$(OBJEXT): internal/static_assert.h
@@ -2202,6 +2186,7 @@ enc/iso_8859_1.$(OBJEXT): internal/attr/noexcept.h
enc/iso_8859_1.$(OBJEXT): internal/attr/noinline.h
enc/iso_8859_1.$(OBJEXT): internal/attr/nonnull.h
enc/iso_8859_1.$(OBJEXT): internal/attr/noreturn.h
+enc/iso_8859_1.$(OBJEXT): internal/attr/packed_struct.h
enc/iso_8859_1.$(OBJEXT): internal/attr/pure.h
enc/iso_8859_1.$(OBJEXT): internal/attr/restrict.h
enc/iso_8859_1.$(OBJEXT): internal/attr/returns_nonnull.h
@@ -2261,7 +2246,6 @@ enc/iso_8859_1.$(OBJEXT): internal/intern/enumerator.h
enc/iso_8859_1.$(OBJEXT): internal/intern/error.h
enc/iso_8859_1.$(OBJEXT): internal/intern/eval.h
enc/iso_8859_1.$(OBJEXT): internal/intern/file.h
-enc/iso_8859_1.$(OBJEXT): internal/intern/gc.h
enc/iso_8859_1.$(OBJEXT): internal/intern/hash.h
enc/iso_8859_1.$(OBJEXT): internal/intern/io.h
enc/iso_8859_1.$(OBJEXT): internal/intern/load.h
@@ -2292,7 +2276,6 @@ enc/iso_8859_1.$(OBJEXT): internal/memory.h
enc/iso_8859_1.$(OBJEXT): internal/method.h
enc/iso_8859_1.$(OBJEXT): internal/module.h
enc/iso_8859_1.$(OBJEXT): internal/newobj.h
-enc/iso_8859_1.$(OBJEXT): internal/rgengc.h
enc/iso_8859_1.$(OBJEXT): internal/scan_args.h
enc/iso_8859_1.$(OBJEXT): internal/special_consts.h
enc/iso_8859_1.$(OBJEXT): internal/static_assert.h
@@ -2364,6 +2347,7 @@ enc/iso_8859_10.$(OBJEXT): internal/attr/noexcept.h
enc/iso_8859_10.$(OBJEXT): internal/attr/noinline.h
enc/iso_8859_10.$(OBJEXT): internal/attr/nonnull.h
enc/iso_8859_10.$(OBJEXT): internal/attr/noreturn.h
+enc/iso_8859_10.$(OBJEXT): internal/attr/packed_struct.h
enc/iso_8859_10.$(OBJEXT): internal/attr/pure.h
enc/iso_8859_10.$(OBJEXT): internal/attr/restrict.h
enc/iso_8859_10.$(OBJEXT): internal/attr/returns_nonnull.h
@@ -2423,7 +2407,6 @@ enc/iso_8859_10.$(OBJEXT): internal/intern/enumerator.h
enc/iso_8859_10.$(OBJEXT): internal/intern/error.h
enc/iso_8859_10.$(OBJEXT): internal/intern/eval.h
enc/iso_8859_10.$(OBJEXT): internal/intern/file.h
-enc/iso_8859_10.$(OBJEXT): internal/intern/gc.h
enc/iso_8859_10.$(OBJEXT): internal/intern/hash.h
enc/iso_8859_10.$(OBJEXT): internal/intern/io.h
enc/iso_8859_10.$(OBJEXT): internal/intern/load.h
@@ -2454,7 +2437,6 @@ enc/iso_8859_10.$(OBJEXT): internal/memory.h
enc/iso_8859_10.$(OBJEXT): internal/method.h
enc/iso_8859_10.$(OBJEXT): internal/module.h
enc/iso_8859_10.$(OBJEXT): internal/newobj.h
-enc/iso_8859_10.$(OBJEXT): internal/rgengc.h
enc/iso_8859_10.$(OBJEXT): internal/scan_args.h
enc/iso_8859_10.$(OBJEXT): internal/special_consts.h
enc/iso_8859_10.$(OBJEXT): internal/static_assert.h
@@ -2525,6 +2507,7 @@ enc/iso_8859_11.$(OBJEXT): internal/attr/noexcept.h
enc/iso_8859_11.$(OBJEXT): internal/attr/noinline.h
enc/iso_8859_11.$(OBJEXT): internal/attr/nonnull.h
enc/iso_8859_11.$(OBJEXT): internal/attr/noreturn.h
+enc/iso_8859_11.$(OBJEXT): internal/attr/packed_struct.h
enc/iso_8859_11.$(OBJEXT): internal/attr/pure.h
enc/iso_8859_11.$(OBJEXT): internal/attr/restrict.h
enc/iso_8859_11.$(OBJEXT): internal/attr/returns_nonnull.h
@@ -2584,7 +2567,6 @@ enc/iso_8859_11.$(OBJEXT): internal/intern/enumerator.h
enc/iso_8859_11.$(OBJEXT): internal/intern/error.h
enc/iso_8859_11.$(OBJEXT): internal/intern/eval.h
enc/iso_8859_11.$(OBJEXT): internal/intern/file.h
-enc/iso_8859_11.$(OBJEXT): internal/intern/gc.h
enc/iso_8859_11.$(OBJEXT): internal/intern/hash.h
enc/iso_8859_11.$(OBJEXT): internal/intern/io.h
enc/iso_8859_11.$(OBJEXT): internal/intern/load.h
@@ -2615,7 +2597,6 @@ enc/iso_8859_11.$(OBJEXT): internal/memory.h
enc/iso_8859_11.$(OBJEXT): internal/method.h
enc/iso_8859_11.$(OBJEXT): internal/module.h
enc/iso_8859_11.$(OBJEXT): internal/newobj.h
-enc/iso_8859_11.$(OBJEXT): internal/rgengc.h
enc/iso_8859_11.$(OBJEXT): internal/scan_args.h
enc/iso_8859_11.$(OBJEXT): internal/special_consts.h
enc/iso_8859_11.$(OBJEXT): internal/static_assert.h
@@ -2687,6 +2668,7 @@ enc/iso_8859_13.$(OBJEXT): internal/attr/noexcept.h
enc/iso_8859_13.$(OBJEXT): internal/attr/noinline.h
enc/iso_8859_13.$(OBJEXT): internal/attr/nonnull.h
enc/iso_8859_13.$(OBJEXT): internal/attr/noreturn.h
+enc/iso_8859_13.$(OBJEXT): internal/attr/packed_struct.h
enc/iso_8859_13.$(OBJEXT): internal/attr/pure.h
enc/iso_8859_13.$(OBJEXT): internal/attr/restrict.h
enc/iso_8859_13.$(OBJEXT): internal/attr/returns_nonnull.h
@@ -2746,7 +2728,6 @@ enc/iso_8859_13.$(OBJEXT): internal/intern/enumerator.h
enc/iso_8859_13.$(OBJEXT): internal/intern/error.h
enc/iso_8859_13.$(OBJEXT): internal/intern/eval.h
enc/iso_8859_13.$(OBJEXT): internal/intern/file.h
-enc/iso_8859_13.$(OBJEXT): internal/intern/gc.h
enc/iso_8859_13.$(OBJEXT): internal/intern/hash.h
enc/iso_8859_13.$(OBJEXT): internal/intern/io.h
enc/iso_8859_13.$(OBJEXT): internal/intern/load.h
@@ -2777,7 +2758,6 @@ enc/iso_8859_13.$(OBJEXT): internal/memory.h
enc/iso_8859_13.$(OBJEXT): internal/method.h
enc/iso_8859_13.$(OBJEXT): internal/module.h
enc/iso_8859_13.$(OBJEXT): internal/newobj.h
-enc/iso_8859_13.$(OBJEXT): internal/rgengc.h
enc/iso_8859_13.$(OBJEXT): internal/scan_args.h
enc/iso_8859_13.$(OBJEXT): internal/special_consts.h
enc/iso_8859_13.$(OBJEXT): internal/static_assert.h
@@ -2849,6 +2829,7 @@ enc/iso_8859_14.$(OBJEXT): internal/attr/noexcept.h
enc/iso_8859_14.$(OBJEXT): internal/attr/noinline.h
enc/iso_8859_14.$(OBJEXT): internal/attr/nonnull.h
enc/iso_8859_14.$(OBJEXT): internal/attr/noreturn.h
+enc/iso_8859_14.$(OBJEXT): internal/attr/packed_struct.h
enc/iso_8859_14.$(OBJEXT): internal/attr/pure.h
enc/iso_8859_14.$(OBJEXT): internal/attr/restrict.h
enc/iso_8859_14.$(OBJEXT): internal/attr/returns_nonnull.h
@@ -2908,7 +2889,6 @@ enc/iso_8859_14.$(OBJEXT): internal/intern/enumerator.h
enc/iso_8859_14.$(OBJEXT): internal/intern/error.h
enc/iso_8859_14.$(OBJEXT): internal/intern/eval.h
enc/iso_8859_14.$(OBJEXT): internal/intern/file.h
-enc/iso_8859_14.$(OBJEXT): internal/intern/gc.h
enc/iso_8859_14.$(OBJEXT): internal/intern/hash.h
enc/iso_8859_14.$(OBJEXT): internal/intern/io.h
enc/iso_8859_14.$(OBJEXT): internal/intern/load.h
@@ -2939,7 +2919,6 @@ enc/iso_8859_14.$(OBJEXT): internal/memory.h
enc/iso_8859_14.$(OBJEXT): internal/method.h
enc/iso_8859_14.$(OBJEXT): internal/module.h
enc/iso_8859_14.$(OBJEXT): internal/newobj.h
-enc/iso_8859_14.$(OBJEXT): internal/rgengc.h
enc/iso_8859_14.$(OBJEXT): internal/scan_args.h
enc/iso_8859_14.$(OBJEXT): internal/special_consts.h
enc/iso_8859_14.$(OBJEXT): internal/static_assert.h
@@ -3011,6 +2990,7 @@ enc/iso_8859_15.$(OBJEXT): internal/attr/noexcept.h
enc/iso_8859_15.$(OBJEXT): internal/attr/noinline.h
enc/iso_8859_15.$(OBJEXT): internal/attr/nonnull.h
enc/iso_8859_15.$(OBJEXT): internal/attr/noreturn.h
+enc/iso_8859_15.$(OBJEXT): internal/attr/packed_struct.h
enc/iso_8859_15.$(OBJEXT): internal/attr/pure.h
enc/iso_8859_15.$(OBJEXT): internal/attr/restrict.h
enc/iso_8859_15.$(OBJEXT): internal/attr/returns_nonnull.h
@@ -3070,7 +3050,6 @@ enc/iso_8859_15.$(OBJEXT): internal/intern/enumerator.h
enc/iso_8859_15.$(OBJEXT): internal/intern/error.h
enc/iso_8859_15.$(OBJEXT): internal/intern/eval.h
enc/iso_8859_15.$(OBJEXT): internal/intern/file.h
-enc/iso_8859_15.$(OBJEXT): internal/intern/gc.h
enc/iso_8859_15.$(OBJEXT): internal/intern/hash.h
enc/iso_8859_15.$(OBJEXT): internal/intern/io.h
enc/iso_8859_15.$(OBJEXT): internal/intern/load.h
@@ -3101,7 +3080,6 @@ enc/iso_8859_15.$(OBJEXT): internal/memory.h
enc/iso_8859_15.$(OBJEXT): internal/method.h
enc/iso_8859_15.$(OBJEXT): internal/module.h
enc/iso_8859_15.$(OBJEXT): internal/newobj.h
-enc/iso_8859_15.$(OBJEXT): internal/rgengc.h
enc/iso_8859_15.$(OBJEXT): internal/scan_args.h
enc/iso_8859_15.$(OBJEXT): internal/special_consts.h
enc/iso_8859_15.$(OBJEXT): internal/static_assert.h
@@ -3173,6 +3151,7 @@ enc/iso_8859_16.$(OBJEXT): internal/attr/noexcept.h
enc/iso_8859_16.$(OBJEXT): internal/attr/noinline.h
enc/iso_8859_16.$(OBJEXT): internal/attr/nonnull.h
enc/iso_8859_16.$(OBJEXT): internal/attr/noreturn.h
+enc/iso_8859_16.$(OBJEXT): internal/attr/packed_struct.h
enc/iso_8859_16.$(OBJEXT): internal/attr/pure.h
enc/iso_8859_16.$(OBJEXT): internal/attr/restrict.h
enc/iso_8859_16.$(OBJEXT): internal/attr/returns_nonnull.h
@@ -3232,7 +3211,6 @@ enc/iso_8859_16.$(OBJEXT): internal/intern/enumerator.h
enc/iso_8859_16.$(OBJEXT): internal/intern/error.h
enc/iso_8859_16.$(OBJEXT): internal/intern/eval.h
enc/iso_8859_16.$(OBJEXT): internal/intern/file.h
-enc/iso_8859_16.$(OBJEXT): internal/intern/gc.h
enc/iso_8859_16.$(OBJEXT): internal/intern/hash.h
enc/iso_8859_16.$(OBJEXT): internal/intern/io.h
enc/iso_8859_16.$(OBJEXT): internal/intern/load.h
@@ -3263,7 +3241,6 @@ enc/iso_8859_16.$(OBJEXT): internal/memory.h
enc/iso_8859_16.$(OBJEXT): internal/method.h
enc/iso_8859_16.$(OBJEXT): internal/module.h
enc/iso_8859_16.$(OBJEXT): internal/newobj.h
-enc/iso_8859_16.$(OBJEXT): internal/rgengc.h
enc/iso_8859_16.$(OBJEXT): internal/scan_args.h
enc/iso_8859_16.$(OBJEXT): internal/special_consts.h
enc/iso_8859_16.$(OBJEXT): internal/static_assert.h
@@ -3335,6 +3312,7 @@ enc/iso_8859_2.$(OBJEXT): internal/attr/noexcept.h
enc/iso_8859_2.$(OBJEXT): internal/attr/noinline.h
enc/iso_8859_2.$(OBJEXT): internal/attr/nonnull.h
enc/iso_8859_2.$(OBJEXT): internal/attr/noreturn.h
+enc/iso_8859_2.$(OBJEXT): internal/attr/packed_struct.h
enc/iso_8859_2.$(OBJEXT): internal/attr/pure.h
enc/iso_8859_2.$(OBJEXT): internal/attr/restrict.h
enc/iso_8859_2.$(OBJEXT): internal/attr/returns_nonnull.h
@@ -3394,7 +3372,6 @@ enc/iso_8859_2.$(OBJEXT): internal/intern/enumerator.h
enc/iso_8859_2.$(OBJEXT): internal/intern/error.h
enc/iso_8859_2.$(OBJEXT): internal/intern/eval.h
enc/iso_8859_2.$(OBJEXT): internal/intern/file.h
-enc/iso_8859_2.$(OBJEXT): internal/intern/gc.h
enc/iso_8859_2.$(OBJEXT): internal/intern/hash.h
enc/iso_8859_2.$(OBJEXT): internal/intern/io.h
enc/iso_8859_2.$(OBJEXT): internal/intern/load.h
@@ -3425,7 +3402,6 @@ enc/iso_8859_2.$(OBJEXT): internal/memory.h
enc/iso_8859_2.$(OBJEXT): internal/method.h
enc/iso_8859_2.$(OBJEXT): internal/module.h
enc/iso_8859_2.$(OBJEXT): internal/newobj.h
-enc/iso_8859_2.$(OBJEXT): internal/rgengc.h
enc/iso_8859_2.$(OBJEXT): internal/scan_args.h
enc/iso_8859_2.$(OBJEXT): internal/special_consts.h
enc/iso_8859_2.$(OBJEXT): internal/static_assert.h
@@ -3497,6 +3473,7 @@ enc/iso_8859_3.$(OBJEXT): internal/attr/noexcept.h
enc/iso_8859_3.$(OBJEXT): internal/attr/noinline.h
enc/iso_8859_3.$(OBJEXT): internal/attr/nonnull.h
enc/iso_8859_3.$(OBJEXT): internal/attr/noreturn.h
+enc/iso_8859_3.$(OBJEXT): internal/attr/packed_struct.h
enc/iso_8859_3.$(OBJEXT): internal/attr/pure.h
enc/iso_8859_3.$(OBJEXT): internal/attr/restrict.h
enc/iso_8859_3.$(OBJEXT): internal/attr/returns_nonnull.h
@@ -3556,7 +3533,6 @@ enc/iso_8859_3.$(OBJEXT): internal/intern/enumerator.h
enc/iso_8859_3.$(OBJEXT): internal/intern/error.h
enc/iso_8859_3.$(OBJEXT): internal/intern/eval.h
enc/iso_8859_3.$(OBJEXT): internal/intern/file.h
-enc/iso_8859_3.$(OBJEXT): internal/intern/gc.h
enc/iso_8859_3.$(OBJEXT): internal/intern/hash.h
enc/iso_8859_3.$(OBJEXT): internal/intern/io.h
enc/iso_8859_3.$(OBJEXT): internal/intern/load.h
@@ -3587,7 +3563,6 @@ enc/iso_8859_3.$(OBJEXT): internal/memory.h
enc/iso_8859_3.$(OBJEXT): internal/method.h
enc/iso_8859_3.$(OBJEXT): internal/module.h
enc/iso_8859_3.$(OBJEXT): internal/newobj.h
-enc/iso_8859_3.$(OBJEXT): internal/rgengc.h
enc/iso_8859_3.$(OBJEXT): internal/scan_args.h
enc/iso_8859_3.$(OBJEXT): internal/special_consts.h
enc/iso_8859_3.$(OBJEXT): internal/static_assert.h
@@ -3659,6 +3634,7 @@ enc/iso_8859_4.$(OBJEXT): internal/attr/noexcept.h
enc/iso_8859_4.$(OBJEXT): internal/attr/noinline.h
enc/iso_8859_4.$(OBJEXT): internal/attr/nonnull.h
enc/iso_8859_4.$(OBJEXT): internal/attr/noreturn.h
+enc/iso_8859_4.$(OBJEXT): internal/attr/packed_struct.h
enc/iso_8859_4.$(OBJEXT): internal/attr/pure.h
enc/iso_8859_4.$(OBJEXT): internal/attr/restrict.h
enc/iso_8859_4.$(OBJEXT): internal/attr/returns_nonnull.h
@@ -3718,7 +3694,6 @@ enc/iso_8859_4.$(OBJEXT): internal/intern/enumerator.h
enc/iso_8859_4.$(OBJEXT): internal/intern/error.h
enc/iso_8859_4.$(OBJEXT): internal/intern/eval.h
enc/iso_8859_4.$(OBJEXT): internal/intern/file.h
-enc/iso_8859_4.$(OBJEXT): internal/intern/gc.h
enc/iso_8859_4.$(OBJEXT): internal/intern/hash.h
enc/iso_8859_4.$(OBJEXT): internal/intern/io.h
enc/iso_8859_4.$(OBJEXT): internal/intern/load.h
@@ -3749,7 +3724,6 @@ enc/iso_8859_4.$(OBJEXT): internal/memory.h
enc/iso_8859_4.$(OBJEXT): internal/method.h
enc/iso_8859_4.$(OBJEXT): internal/module.h
enc/iso_8859_4.$(OBJEXT): internal/newobj.h
-enc/iso_8859_4.$(OBJEXT): internal/rgengc.h
enc/iso_8859_4.$(OBJEXT): internal/scan_args.h
enc/iso_8859_4.$(OBJEXT): internal/special_consts.h
enc/iso_8859_4.$(OBJEXT): internal/static_assert.h
@@ -3820,6 +3794,7 @@ enc/iso_8859_5.$(OBJEXT): internal/attr/noexcept.h
enc/iso_8859_5.$(OBJEXT): internal/attr/noinline.h
enc/iso_8859_5.$(OBJEXT): internal/attr/nonnull.h
enc/iso_8859_5.$(OBJEXT): internal/attr/noreturn.h
+enc/iso_8859_5.$(OBJEXT): internal/attr/packed_struct.h
enc/iso_8859_5.$(OBJEXT): internal/attr/pure.h
enc/iso_8859_5.$(OBJEXT): internal/attr/restrict.h
enc/iso_8859_5.$(OBJEXT): internal/attr/returns_nonnull.h
@@ -3879,7 +3854,6 @@ enc/iso_8859_5.$(OBJEXT): internal/intern/enumerator.h
enc/iso_8859_5.$(OBJEXT): internal/intern/error.h
enc/iso_8859_5.$(OBJEXT): internal/intern/eval.h
enc/iso_8859_5.$(OBJEXT): internal/intern/file.h
-enc/iso_8859_5.$(OBJEXT): internal/intern/gc.h
enc/iso_8859_5.$(OBJEXT): internal/intern/hash.h
enc/iso_8859_5.$(OBJEXT): internal/intern/io.h
enc/iso_8859_5.$(OBJEXT): internal/intern/load.h
@@ -3910,7 +3884,6 @@ enc/iso_8859_5.$(OBJEXT): internal/memory.h
enc/iso_8859_5.$(OBJEXT): internal/method.h
enc/iso_8859_5.$(OBJEXT): internal/module.h
enc/iso_8859_5.$(OBJEXT): internal/newobj.h
-enc/iso_8859_5.$(OBJEXT): internal/rgengc.h
enc/iso_8859_5.$(OBJEXT): internal/scan_args.h
enc/iso_8859_5.$(OBJEXT): internal/special_consts.h
enc/iso_8859_5.$(OBJEXT): internal/static_assert.h
@@ -3981,6 +3954,7 @@ enc/iso_8859_6.$(OBJEXT): internal/attr/noexcept.h
enc/iso_8859_6.$(OBJEXT): internal/attr/noinline.h
enc/iso_8859_6.$(OBJEXT): internal/attr/nonnull.h
enc/iso_8859_6.$(OBJEXT): internal/attr/noreturn.h
+enc/iso_8859_6.$(OBJEXT): internal/attr/packed_struct.h
enc/iso_8859_6.$(OBJEXT): internal/attr/pure.h
enc/iso_8859_6.$(OBJEXT): internal/attr/restrict.h
enc/iso_8859_6.$(OBJEXT): internal/attr/returns_nonnull.h
@@ -4040,7 +4014,6 @@ enc/iso_8859_6.$(OBJEXT): internal/intern/enumerator.h
enc/iso_8859_6.$(OBJEXT): internal/intern/error.h
enc/iso_8859_6.$(OBJEXT): internal/intern/eval.h
enc/iso_8859_6.$(OBJEXT): internal/intern/file.h
-enc/iso_8859_6.$(OBJEXT): internal/intern/gc.h
enc/iso_8859_6.$(OBJEXT): internal/intern/hash.h
enc/iso_8859_6.$(OBJEXT): internal/intern/io.h
enc/iso_8859_6.$(OBJEXT): internal/intern/load.h
@@ -4071,7 +4044,6 @@ enc/iso_8859_6.$(OBJEXT): internal/memory.h
enc/iso_8859_6.$(OBJEXT): internal/method.h
enc/iso_8859_6.$(OBJEXT): internal/module.h
enc/iso_8859_6.$(OBJEXT): internal/newobj.h
-enc/iso_8859_6.$(OBJEXT): internal/rgengc.h
enc/iso_8859_6.$(OBJEXT): internal/scan_args.h
enc/iso_8859_6.$(OBJEXT): internal/special_consts.h
enc/iso_8859_6.$(OBJEXT): internal/static_assert.h
@@ -4142,6 +4114,7 @@ enc/iso_8859_7.$(OBJEXT): internal/attr/noexcept.h
enc/iso_8859_7.$(OBJEXT): internal/attr/noinline.h
enc/iso_8859_7.$(OBJEXT): internal/attr/nonnull.h
enc/iso_8859_7.$(OBJEXT): internal/attr/noreturn.h
+enc/iso_8859_7.$(OBJEXT): internal/attr/packed_struct.h
enc/iso_8859_7.$(OBJEXT): internal/attr/pure.h
enc/iso_8859_7.$(OBJEXT): internal/attr/restrict.h
enc/iso_8859_7.$(OBJEXT): internal/attr/returns_nonnull.h
@@ -4201,7 +4174,6 @@ enc/iso_8859_7.$(OBJEXT): internal/intern/enumerator.h
enc/iso_8859_7.$(OBJEXT): internal/intern/error.h
enc/iso_8859_7.$(OBJEXT): internal/intern/eval.h
enc/iso_8859_7.$(OBJEXT): internal/intern/file.h
-enc/iso_8859_7.$(OBJEXT): internal/intern/gc.h
enc/iso_8859_7.$(OBJEXT): internal/intern/hash.h
enc/iso_8859_7.$(OBJEXT): internal/intern/io.h
enc/iso_8859_7.$(OBJEXT): internal/intern/load.h
@@ -4232,7 +4204,6 @@ enc/iso_8859_7.$(OBJEXT): internal/memory.h
enc/iso_8859_7.$(OBJEXT): internal/method.h
enc/iso_8859_7.$(OBJEXT): internal/module.h
enc/iso_8859_7.$(OBJEXT): internal/newobj.h
-enc/iso_8859_7.$(OBJEXT): internal/rgengc.h
enc/iso_8859_7.$(OBJEXT): internal/scan_args.h
enc/iso_8859_7.$(OBJEXT): internal/special_consts.h
enc/iso_8859_7.$(OBJEXT): internal/static_assert.h
@@ -4303,6 +4274,7 @@ enc/iso_8859_8.$(OBJEXT): internal/attr/noexcept.h
enc/iso_8859_8.$(OBJEXT): internal/attr/noinline.h
enc/iso_8859_8.$(OBJEXT): internal/attr/nonnull.h
enc/iso_8859_8.$(OBJEXT): internal/attr/noreturn.h
+enc/iso_8859_8.$(OBJEXT): internal/attr/packed_struct.h
enc/iso_8859_8.$(OBJEXT): internal/attr/pure.h
enc/iso_8859_8.$(OBJEXT): internal/attr/restrict.h
enc/iso_8859_8.$(OBJEXT): internal/attr/returns_nonnull.h
@@ -4362,7 +4334,6 @@ enc/iso_8859_8.$(OBJEXT): internal/intern/enumerator.h
enc/iso_8859_8.$(OBJEXT): internal/intern/error.h
enc/iso_8859_8.$(OBJEXT): internal/intern/eval.h
enc/iso_8859_8.$(OBJEXT): internal/intern/file.h
-enc/iso_8859_8.$(OBJEXT): internal/intern/gc.h
enc/iso_8859_8.$(OBJEXT): internal/intern/hash.h
enc/iso_8859_8.$(OBJEXT): internal/intern/io.h
enc/iso_8859_8.$(OBJEXT): internal/intern/load.h
@@ -4393,7 +4364,6 @@ enc/iso_8859_8.$(OBJEXT): internal/memory.h
enc/iso_8859_8.$(OBJEXT): internal/method.h
enc/iso_8859_8.$(OBJEXT): internal/module.h
enc/iso_8859_8.$(OBJEXT): internal/newobj.h
-enc/iso_8859_8.$(OBJEXT): internal/rgengc.h
enc/iso_8859_8.$(OBJEXT): internal/scan_args.h
enc/iso_8859_8.$(OBJEXT): internal/special_consts.h
enc/iso_8859_8.$(OBJEXT): internal/static_assert.h
@@ -4465,6 +4435,7 @@ enc/iso_8859_9.$(OBJEXT): internal/attr/noexcept.h
enc/iso_8859_9.$(OBJEXT): internal/attr/noinline.h
enc/iso_8859_9.$(OBJEXT): internal/attr/nonnull.h
enc/iso_8859_9.$(OBJEXT): internal/attr/noreturn.h
+enc/iso_8859_9.$(OBJEXT): internal/attr/packed_struct.h
enc/iso_8859_9.$(OBJEXT): internal/attr/pure.h
enc/iso_8859_9.$(OBJEXT): internal/attr/restrict.h
enc/iso_8859_9.$(OBJEXT): internal/attr/returns_nonnull.h
@@ -4524,7 +4495,6 @@ enc/iso_8859_9.$(OBJEXT): internal/intern/enumerator.h
enc/iso_8859_9.$(OBJEXT): internal/intern/error.h
enc/iso_8859_9.$(OBJEXT): internal/intern/eval.h
enc/iso_8859_9.$(OBJEXT): internal/intern/file.h
-enc/iso_8859_9.$(OBJEXT): internal/intern/gc.h
enc/iso_8859_9.$(OBJEXT): internal/intern/hash.h
enc/iso_8859_9.$(OBJEXT): internal/intern/io.h
enc/iso_8859_9.$(OBJEXT): internal/intern/load.h
@@ -4555,7 +4525,6 @@ enc/iso_8859_9.$(OBJEXT): internal/memory.h
enc/iso_8859_9.$(OBJEXT): internal/method.h
enc/iso_8859_9.$(OBJEXT): internal/module.h
enc/iso_8859_9.$(OBJEXT): internal/newobj.h
-enc/iso_8859_9.$(OBJEXT): internal/rgengc.h
enc/iso_8859_9.$(OBJEXT): internal/scan_args.h
enc/iso_8859_9.$(OBJEXT): internal/special_consts.h
enc/iso_8859_9.$(OBJEXT): internal/static_assert.h
@@ -4626,6 +4595,7 @@ enc/koi8_r.$(OBJEXT): internal/attr/noexcept.h
enc/koi8_r.$(OBJEXT): internal/attr/noinline.h
enc/koi8_r.$(OBJEXT): internal/attr/nonnull.h
enc/koi8_r.$(OBJEXT): internal/attr/noreturn.h
+enc/koi8_r.$(OBJEXT): internal/attr/packed_struct.h
enc/koi8_r.$(OBJEXT): internal/attr/pure.h
enc/koi8_r.$(OBJEXT): internal/attr/restrict.h
enc/koi8_r.$(OBJEXT): internal/attr/returns_nonnull.h
@@ -4685,7 +4655,6 @@ enc/koi8_r.$(OBJEXT): internal/intern/enumerator.h
enc/koi8_r.$(OBJEXT): internal/intern/error.h
enc/koi8_r.$(OBJEXT): internal/intern/eval.h
enc/koi8_r.$(OBJEXT): internal/intern/file.h
-enc/koi8_r.$(OBJEXT): internal/intern/gc.h
enc/koi8_r.$(OBJEXT): internal/intern/hash.h
enc/koi8_r.$(OBJEXT): internal/intern/io.h
enc/koi8_r.$(OBJEXT): internal/intern/load.h
@@ -4716,7 +4685,6 @@ enc/koi8_r.$(OBJEXT): internal/memory.h
enc/koi8_r.$(OBJEXT): internal/method.h
enc/koi8_r.$(OBJEXT): internal/module.h
enc/koi8_r.$(OBJEXT): internal/newobj.h
-enc/koi8_r.$(OBJEXT): internal/rgengc.h
enc/koi8_r.$(OBJEXT): internal/scan_args.h
enc/koi8_r.$(OBJEXT): internal/special_consts.h
enc/koi8_r.$(OBJEXT): internal/static_assert.h
@@ -4787,6 +4755,7 @@ enc/koi8_u.$(OBJEXT): internal/attr/noexcept.h
enc/koi8_u.$(OBJEXT): internal/attr/noinline.h
enc/koi8_u.$(OBJEXT): internal/attr/nonnull.h
enc/koi8_u.$(OBJEXT): internal/attr/noreturn.h
+enc/koi8_u.$(OBJEXT): internal/attr/packed_struct.h
enc/koi8_u.$(OBJEXT): internal/attr/pure.h
enc/koi8_u.$(OBJEXT): internal/attr/restrict.h
enc/koi8_u.$(OBJEXT): internal/attr/returns_nonnull.h
@@ -4846,7 +4815,6 @@ enc/koi8_u.$(OBJEXT): internal/intern/enumerator.h
enc/koi8_u.$(OBJEXT): internal/intern/error.h
enc/koi8_u.$(OBJEXT): internal/intern/eval.h
enc/koi8_u.$(OBJEXT): internal/intern/file.h
-enc/koi8_u.$(OBJEXT): internal/intern/gc.h
enc/koi8_u.$(OBJEXT): internal/intern/hash.h
enc/koi8_u.$(OBJEXT): internal/intern/io.h
enc/koi8_u.$(OBJEXT): internal/intern/load.h
@@ -4877,7 +4845,6 @@ enc/koi8_u.$(OBJEXT): internal/memory.h
enc/koi8_u.$(OBJEXT): internal/method.h
enc/koi8_u.$(OBJEXT): internal/module.h
enc/koi8_u.$(OBJEXT): internal/newobj.h
-enc/koi8_u.$(OBJEXT): internal/rgengc.h
enc/koi8_u.$(OBJEXT): internal/scan_args.h
enc/koi8_u.$(OBJEXT): internal/special_consts.h
enc/koi8_u.$(OBJEXT): internal/static_assert.h
@@ -4951,6 +4918,7 @@ enc/shift_jis.$(OBJEXT): internal/attr/noexcept.h
enc/shift_jis.$(OBJEXT): internal/attr/noinline.h
enc/shift_jis.$(OBJEXT): internal/attr/nonnull.h
enc/shift_jis.$(OBJEXT): internal/attr/noreturn.h
+enc/shift_jis.$(OBJEXT): internal/attr/packed_struct.h
enc/shift_jis.$(OBJEXT): internal/attr/pure.h
enc/shift_jis.$(OBJEXT): internal/attr/restrict.h
enc/shift_jis.$(OBJEXT): internal/attr/returns_nonnull.h
@@ -5010,7 +4978,6 @@ enc/shift_jis.$(OBJEXT): internal/intern/enumerator.h
enc/shift_jis.$(OBJEXT): internal/intern/error.h
enc/shift_jis.$(OBJEXT): internal/intern/eval.h
enc/shift_jis.$(OBJEXT): internal/intern/file.h
-enc/shift_jis.$(OBJEXT): internal/intern/gc.h
enc/shift_jis.$(OBJEXT): internal/intern/hash.h
enc/shift_jis.$(OBJEXT): internal/intern/io.h
enc/shift_jis.$(OBJEXT): internal/intern/load.h
@@ -5041,7 +5008,6 @@ enc/shift_jis.$(OBJEXT): internal/memory.h
enc/shift_jis.$(OBJEXT): internal/method.h
enc/shift_jis.$(OBJEXT): internal/module.h
enc/shift_jis.$(OBJEXT): internal/newobj.h
-enc/shift_jis.$(OBJEXT): internal/rgengc.h
enc/shift_jis.$(OBJEXT): internal/scan_args.h
enc/shift_jis.$(OBJEXT): internal/special_consts.h
enc/shift_jis.$(OBJEXT): internal/static_assert.h
@@ -5111,6 +5077,7 @@ enc/trans/big5.$(OBJEXT): internal/attr/noexcept.h
enc/trans/big5.$(OBJEXT): internal/attr/noinline.h
enc/trans/big5.$(OBJEXT): internal/attr/nonnull.h
enc/trans/big5.$(OBJEXT): internal/attr/noreturn.h
+enc/trans/big5.$(OBJEXT): internal/attr/packed_struct.h
enc/trans/big5.$(OBJEXT): internal/attr/pure.h
enc/trans/big5.$(OBJEXT): internal/attr/restrict.h
enc/trans/big5.$(OBJEXT): internal/attr/returns_nonnull.h
@@ -5170,7 +5137,6 @@ enc/trans/big5.$(OBJEXT): internal/intern/enumerator.h
enc/trans/big5.$(OBJEXT): internal/intern/error.h
enc/trans/big5.$(OBJEXT): internal/intern/eval.h
enc/trans/big5.$(OBJEXT): internal/intern/file.h
-enc/trans/big5.$(OBJEXT): internal/intern/gc.h
enc/trans/big5.$(OBJEXT): internal/intern/hash.h
enc/trans/big5.$(OBJEXT): internal/intern/io.h
enc/trans/big5.$(OBJEXT): internal/intern/load.h
@@ -5201,7 +5167,6 @@ enc/trans/big5.$(OBJEXT): internal/memory.h
enc/trans/big5.$(OBJEXT): internal/method.h
enc/trans/big5.$(OBJEXT): internal/module.h
enc/trans/big5.$(OBJEXT): internal/newobj.h
-enc/trans/big5.$(OBJEXT): internal/rgengc.h
enc/trans/big5.$(OBJEXT): internal/scan_args.h
enc/trans/big5.$(OBJEXT): internal/special_consts.h
enc/trans/big5.$(OBJEXT): internal/static_assert.h
@@ -5270,6 +5235,7 @@ enc/trans/cesu_8.$(OBJEXT): internal/attr/noexcept.h
enc/trans/cesu_8.$(OBJEXT): internal/attr/noinline.h
enc/trans/cesu_8.$(OBJEXT): internal/attr/nonnull.h
enc/trans/cesu_8.$(OBJEXT): internal/attr/noreturn.h
+enc/trans/cesu_8.$(OBJEXT): internal/attr/packed_struct.h
enc/trans/cesu_8.$(OBJEXT): internal/attr/pure.h
enc/trans/cesu_8.$(OBJEXT): internal/attr/restrict.h
enc/trans/cesu_8.$(OBJEXT): internal/attr/returns_nonnull.h
@@ -5329,7 +5295,6 @@ enc/trans/cesu_8.$(OBJEXT): internal/intern/enumerator.h
enc/trans/cesu_8.$(OBJEXT): internal/intern/error.h
enc/trans/cesu_8.$(OBJEXT): internal/intern/eval.h
enc/trans/cesu_8.$(OBJEXT): internal/intern/file.h
-enc/trans/cesu_8.$(OBJEXT): internal/intern/gc.h
enc/trans/cesu_8.$(OBJEXT): internal/intern/hash.h
enc/trans/cesu_8.$(OBJEXT): internal/intern/io.h
enc/trans/cesu_8.$(OBJEXT): internal/intern/load.h
@@ -5360,7 +5325,6 @@ enc/trans/cesu_8.$(OBJEXT): internal/memory.h
enc/trans/cesu_8.$(OBJEXT): internal/method.h
enc/trans/cesu_8.$(OBJEXT): internal/module.h
enc/trans/cesu_8.$(OBJEXT): internal/newobj.h
-enc/trans/cesu_8.$(OBJEXT): internal/rgengc.h
enc/trans/cesu_8.$(OBJEXT): internal/scan_args.h
enc/trans/cesu_8.$(OBJEXT): internal/special_consts.h
enc/trans/cesu_8.$(OBJEXT): internal/static_assert.h
@@ -5429,6 +5393,7 @@ enc/trans/chinese.$(OBJEXT): internal/attr/noexcept.h
enc/trans/chinese.$(OBJEXT): internal/attr/noinline.h
enc/trans/chinese.$(OBJEXT): internal/attr/nonnull.h
enc/trans/chinese.$(OBJEXT): internal/attr/noreturn.h
+enc/trans/chinese.$(OBJEXT): internal/attr/packed_struct.h
enc/trans/chinese.$(OBJEXT): internal/attr/pure.h
enc/trans/chinese.$(OBJEXT): internal/attr/restrict.h
enc/trans/chinese.$(OBJEXT): internal/attr/returns_nonnull.h
@@ -5488,7 +5453,6 @@ enc/trans/chinese.$(OBJEXT): internal/intern/enumerator.h
enc/trans/chinese.$(OBJEXT): internal/intern/error.h
enc/trans/chinese.$(OBJEXT): internal/intern/eval.h
enc/trans/chinese.$(OBJEXT): internal/intern/file.h
-enc/trans/chinese.$(OBJEXT): internal/intern/gc.h
enc/trans/chinese.$(OBJEXT): internal/intern/hash.h
enc/trans/chinese.$(OBJEXT): internal/intern/io.h
enc/trans/chinese.$(OBJEXT): internal/intern/load.h
@@ -5519,7 +5483,6 @@ enc/trans/chinese.$(OBJEXT): internal/memory.h
enc/trans/chinese.$(OBJEXT): internal/method.h
enc/trans/chinese.$(OBJEXT): internal/module.h
enc/trans/chinese.$(OBJEXT): internal/newobj.h
-enc/trans/chinese.$(OBJEXT): internal/rgengc.h
enc/trans/chinese.$(OBJEXT): internal/scan_args.h
enc/trans/chinese.$(OBJEXT): internal/special_consts.h
enc/trans/chinese.$(OBJEXT): internal/static_assert.h
@@ -5588,6 +5551,7 @@ enc/trans/ebcdic.$(OBJEXT): internal/attr/noexcept.h
enc/trans/ebcdic.$(OBJEXT): internal/attr/noinline.h
enc/trans/ebcdic.$(OBJEXT): internal/attr/nonnull.h
enc/trans/ebcdic.$(OBJEXT): internal/attr/noreturn.h
+enc/trans/ebcdic.$(OBJEXT): internal/attr/packed_struct.h
enc/trans/ebcdic.$(OBJEXT): internal/attr/pure.h
enc/trans/ebcdic.$(OBJEXT): internal/attr/restrict.h
enc/trans/ebcdic.$(OBJEXT): internal/attr/returns_nonnull.h
@@ -5647,7 +5611,6 @@ enc/trans/ebcdic.$(OBJEXT): internal/intern/enumerator.h
enc/trans/ebcdic.$(OBJEXT): internal/intern/error.h
enc/trans/ebcdic.$(OBJEXT): internal/intern/eval.h
enc/trans/ebcdic.$(OBJEXT): internal/intern/file.h
-enc/trans/ebcdic.$(OBJEXT): internal/intern/gc.h
enc/trans/ebcdic.$(OBJEXT): internal/intern/hash.h
enc/trans/ebcdic.$(OBJEXT): internal/intern/io.h
enc/trans/ebcdic.$(OBJEXT): internal/intern/load.h
@@ -5678,7 +5641,6 @@ enc/trans/ebcdic.$(OBJEXT): internal/memory.h
enc/trans/ebcdic.$(OBJEXT): internal/method.h
enc/trans/ebcdic.$(OBJEXT): internal/module.h
enc/trans/ebcdic.$(OBJEXT): internal/newobj.h
-enc/trans/ebcdic.$(OBJEXT): internal/rgengc.h
enc/trans/ebcdic.$(OBJEXT): internal/scan_args.h
enc/trans/ebcdic.$(OBJEXT): internal/special_consts.h
enc/trans/ebcdic.$(OBJEXT): internal/static_assert.h
@@ -5747,6 +5709,7 @@ enc/trans/emoji.$(OBJEXT): internal/attr/noexcept.h
enc/trans/emoji.$(OBJEXT): internal/attr/noinline.h
enc/trans/emoji.$(OBJEXT): internal/attr/nonnull.h
enc/trans/emoji.$(OBJEXT): internal/attr/noreturn.h
+enc/trans/emoji.$(OBJEXT): internal/attr/packed_struct.h
enc/trans/emoji.$(OBJEXT): internal/attr/pure.h
enc/trans/emoji.$(OBJEXT): internal/attr/restrict.h
enc/trans/emoji.$(OBJEXT): internal/attr/returns_nonnull.h
@@ -5806,7 +5769,6 @@ enc/trans/emoji.$(OBJEXT): internal/intern/enumerator.h
enc/trans/emoji.$(OBJEXT): internal/intern/error.h
enc/trans/emoji.$(OBJEXT): internal/intern/eval.h
enc/trans/emoji.$(OBJEXT): internal/intern/file.h
-enc/trans/emoji.$(OBJEXT): internal/intern/gc.h
enc/trans/emoji.$(OBJEXT): internal/intern/hash.h
enc/trans/emoji.$(OBJEXT): internal/intern/io.h
enc/trans/emoji.$(OBJEXT): internal/intern/load.h
@@ -5837,7 +5799,6 @@ enc/trans/emoji.$(OBJEXT): internal/memory.h
enc/trans/emoji.$(OBJEXT): internal/method.h
enc/trans/emoji.$(OBJEXT): internal/module.h
enc/trans/emoji.$(OBJEXT): internal/newobj.h
-enc/trans/emoji.$(OBJEXT): internal/rgengc.h
enc/trans/emoji.$(OBJEXT): internal/scan_args.h
enc/trans/emoji.$(OBJEXT): internal/special_consts.h
enc/trans/emoji.$(OBJEXT): internal/static_assert.h
@@ -5906,6 +5867,7 @@ enc/trans/emoji_iso2022_kddi.$(OBJEXT): internal/attr/noexcept.h
enc/trans/emoji_iso2022_kddi.$(OBJEXT): internal/attr/noinline.h
enc/trans/emoji_iso2022_kddi.$(OBJEXT): internal/attr/nonnull.h
enc/trans/emoji_iso2022_kddi.$(OBJEXT): internal/attr/noreturn.h
+enc/trans/emoji_iso2022_kddi.$(OBJEXT): internal/attr/packed_struct.h
enc/trans/emoji_iso2022_kddi.$(OBJEXT): internal/attr/pure.h
enc/trans/emoji_iso2022_kddi.$(OBJEXT): internal/attr/restrict.h
enc/trans/emoji_iso2022_kddi.$(OBJEXT): internal/attr/returns_nonnull.h
@@ -5965,7 +5927,6 @@ enc/trans/emoji_iso2022_kddi.$(OBJEXT): internal/intern/enumerator.h
enc/trans/emoji_iso2022_kddi.$(OBJEXT): internal/intern/error.h
enc/trans/emoji_iso2022_kddi.$(OBJEXT): internal/intern/eval.h
enc/trans/emoji_iso2022_kddi.$(OBJEXT): internal/intern/file.h
-enc/trans/emoji_iso2022_kddi.$(OBJEXT): internal/intern/gc.h
enc/trans/emoji_iso2022_kddi.$(OBJEXT): internal/intern/hash.h
enc/trans/emoji_iso2022_kddi.$(OBJEXT): internal/intern/io.h
enc/trans/emoji_iso2022_kddi.$(OBJEXT): internal/intern/load.h
@@ -5996,7 +5957,6 @@ enc/trans/emoji_iso2022_kddi.$(OBJEXT): internal/memory.h
enc/trans/emoji_iso2022_kddi.$(OBJEXT): internal/method.h
enc/trans/emoji_iso2022_kddi.$(OBJEXT): internal/module.h
enc/trans/emoji_iso2022_kddi.$(OBJEXT): internal/newobj.h
-enc/trans/emoji_iso2022_kddi.$(OBJEXT): internal/rgengc.h
enc/trans/emoji_iso2022_kddi.$(OBJEXT): internal/scan_args.h
enc/trans/emoji_iso2022_kddi.$(OBJEXT): internal/special_consts.h
enc/trans/emoji_iso2022_kddi.$(OBJEXT): internal/static_assert.h
@@ -6065,6 +6025,7 @@ enc/trans/emoji_sjis_docomo.$(OBJEXT): internal/attr/noexcept.h
enc/trans/emoji_sjis_docomo.$(OBJEXT): internal/attr/noinline.h
enc/trans/emoji_sjis_docomo.$(OBJEXT): internal/attr/nonnull.h
enc/trans/emoji_sjis_docomo.$(OBJEXT): internal/attr/noreturn.h
+enc/trans/emoji_sjis_docomo.$(OBJEXT): internal/attr/packed_struct.h
enc/trans/emoji_sjis_docomo.$(OBJEXT): internal/attr/pure.h
enc/trans/emoji_sjis_docomo.$(OBJEXT): internal/attr/restrict.h
enc/trans/emoji_sjis_docomo.$(OBJEXT): internal/attr/returns_nonnull.h
@@ -6124,7 +6085,6 @@ enc/trans/emoji_sjis_docomo.$(OBJEXT): internal/intern/enumerator.h
enc/trans/emoji_sjis_docomo.$(OBJEXT): internal/intern/error.h
enc/trans/emoji_sjis_docomo.$(OBJEXT): internal/intern/eval.h
enc/trans/emoji_sjis_docomo.$(OBJEXT): internal/intern/file.h
-enc/trans/emoji_sjis_docomo.$(OBJEXT): internal/intern/gc.h
enc/trans/emoji_sjis_docomo.$(OBJEXT): internal/intern/hash.h
enc/trans/emoji_sjis_docomo.$(OBJEXT): internal/intern/io.h
enc/trans/emoji_sjis_docomo.$(OBJEXT): internal/intern/load.h
@@ -6155,7 +6115,6 @@ enc/trans/emoji_sjis_docomo.$(OBJEXT): internal/memory.h
enc/trans/emoji_sjis_docomo.$(OBJEXT): internal/method.h
enc/trans/emoji_sjis_docomo.$(OBJEXT): internal/module.h
enc/trans/emoji_sjis_docomo.$(OBJEXT): internal/newobj.h
-enc/trans/emoji_sjis_docomo.$(OBJEXT): internal/rgengc.h
enc/trans/emoji_sjis_docomo.$(OBJEXT): internal/scan_args.h
enc/trans/emoji_sjis_docomo.$(OBJEXT): internal/special_consts.h
enc/trans/emoji_sjis_docomo.$(OBJEXT): internal/static_assert.h
@@ -6224,6 +6183,7 @@ enc/trans/emoji_sjis_kddi.$(OBJEXT): internal/attr/noexcept.h
enc/trans/emoji_sjis_kddi.$(OBJEXT): internal/attr/noinline.h
enc/trans/emoji_sjis_kddi.$(OBJEXT): internal/attr/nonnull.h
enc/trans/emoji_sjis_kddi.$(OBJEXT): internal/attr/noreturn.h
+enc/trans/emoji_sjis_kddi.$(OBJEXT): internal/attr/packed_struct.h
enc/trans/emoji_sjis_kddi.$(OBJEXT): internal/attr/pure.h
enc/trans/emoji_sjis_kddi.$(OBJEXT): internal/attr/restrict.h
enc/trans/emoji_sjis_kddi.$(OBJEXT): internal/attr/returns_nonnull.h
@@ -6283,7 +6243,6 @@ enc/trans/emoji_sjis_kddi.$(OBJEXT): internal/intern/enumerator.h
enc/trans/emoji_sjis_kddi.$(OBJEXT): internal/intern/error.h
enc/trans/emoji_sjis_kddi.$(OBJEXT): internal/intern/eval.h
enc/trans/emoji_sjis_kddi.$(OBJEXT): internal/intern/file.h
-enc/trans/emoji_sjis_kddi.$(OBJEXT): internal/intern/gc.h
enc/trans/emoji_sjis_kddi.$(OBJEXT): internal/intern/hash.h
enc/trans/emoji_sjis_kddi.$(OBJEXT): internal/intern/io.h
enc/trans/emoji_sjis_kddi.$(OBJEXT): internal/intern/load.h
@@ -6314,7 +6273,6 @@ enc/trans/emoji_sjis_kddi.$(OBJEXT): internal/memory.h
enc/trans/emoji_sjis_kddi.$(OBJEXT): internal/method.h
enc/trans/emoji_sjis_kddi.$(OBJEXT): internal/module.h
enc/trans/emoji_sjis_kddi.$(OBJEXT): internal/newobj.h
-enc/trans/emoji_sjis_kddi.$(OBJEXT): internal/rgengc.h
enc/trans/emoji_sjis_kddi.$(OBJEXT): internal/scan_args.h
enc/trans/emoji_sjis_kddi.$(OBJEXT): internal/special_consts.h
enc/trans/emoji_sjis_kddi.$(OBJEXT): internal/static_assert.h
@@ -6383,6 +6341,7 @@ enc/trans/emoji_sjis_softbank.$(OBJEXT): internal/attr/noexcept.h
enc/trans/emoji_sjis_softbank.$(OBJEXT): internal/attr/noinline.h
enc/trans/emoji_sjis_softbank.$(OBJEXT): internal/attr/nonnull.h
enc/trans/emoji_sjis_softbank.$(OBJEXT): internal/attr/noreturn.h
+enc/trans/emoji_sjis_softbank.$(OBJEXT): internal/attr/packed_struct.h
enc/trans/emoji_sjis_softbank.$(OBJEXT): internal/attr/pure.h
enc/trans/emoji_sjis_softbank.$(OBJEXT): internal/attr/restrict.h
enc/trans/emoji_sjis_softbank.$(OBJEXT): internal/attr/returns_nonnull.h
@@ -6442,7 +6401,6 @@ enc/trans/emoji_sjis_softbank.$(OBJEXT): internal/intern/enumerator.h
enc/trans/emoji_sjis_softbank.$(OBJEXT): internal/intern/error.h
enc/trans/emoji_sjis_softbank.$(OBJEXT): internal/intern/eval.h
enc/trans/emoji_sjis_softbank.$(OBJEXT): internal/intern/file.h
-enc/trans/emoji_sjis_softbank.$(OBJEXT): internal/intern/gc.h
enc/trans/emoji_sjis_softbank.$(OBJEXT): internal/intern/hash.h
enc/trans/emoji_sjis_softbank.$(OBJEXT): internal/intern/io.h
enc/trans/emoji_sjis_softbank.$(OBJEXT): internal/intern/load.h
@@ -6473,7 +6431,6 @@ enc/trans/emoji_sjis_softbank.$(OBJEXT): internal/memory.h
enc/trans/emoji_sjis_softbank.$(OBJEXT): internal/method.h
enc/trans/emoji_sjis_softbank.$(OBJEXT): internal/module.h
enc/trans/emoji_sjis_softbank.$(OBJEXT): internal/newobj.h
-enc/trans/emoji_sjis_softbank.$(OBJEXT): internal/rgengc.h
enc/trans/emoji_sjis_softbank.$(OBJEXT): internal/scan_args.h
enc/trans/emoji_sjis_softbank.$(OBJEXT): internal/special_consts.h
enc/trans/emoji_sjis_softbank.$(OBJEXT): internal/static_assert.h
@@ -6542,6 +6499,7 @@ enc/trans/escape.$(OBJEXT): internal/attr/noexcept.h
enc/trans/escape.$(OBJEXT): internal/attr/noinline.h
enc/trans/escape.$(OBJEXT): internal/attr/nonnull.h
enc/trans/escape.$(OBJEXT): internal/attr/noreturn.h
+enc/trans/escape.$(OBJEXT): internal/attr/packed_struct.h
enc/trans/escape.$(OBJEXT): internal/attr/pure.h
enc/trans/escape.$(OBJEXT): internal/attr/restrict.h
enc/trans/escape.$(OBJEXT): internal/attr/returns_nonnull.h
@@ -6601,7 +6559,6 @@ enc/trans/escape.$(OBJEXT): internal/intern/enumerator.h
enc/trans/escape.$(OBJEXT): internal/intern/error.h
enc/trans/escape.$(OBJEXT): internal/intern/eval.h
enc/trans/escape.$(OBJEXT): internal/intern/file.h
-enc/trans/escape.$(OBJEXT): internal/intern/gc.h
enc/trans/escape.$(OBJEXT): internal/intern/hash.h
enc/trans/escape.$(OBJEXT): internal/intern/io.h
enc/trans/escape.$(OBJEXT): internal/intern/load.h
@@ -6632,7 +6589,6 @@ enc/trans/escape.$(OBJEXT): internal/memory.h
enc/trans/escape.$(OBJEXT): internal/method.h
enc/trans/escape.$(OBJEXT): internal/module.h
enc/trans/escape.$(OBJEXT): internal/newobj.h
-enc/trans/escape.$(OBJEXT): internal/rgengc.h
enc/trans/escape.$(OBJEXT): internal/scan_args.h
enc/trans/escape.$(OBJEXT): internal/special_consts.h
enc/trans/escape.$(OBJEXT): internal/static_assert.h
@@ -6701,6 +6657,7 @@ enc/trans/gb18030.$(OBJEXT): internal/attr/noexcept.h
enc/trans/gb18030.$(OBJEXT): internal/attr/noinline.h
enc/trans/gb18030.$(OBJEXT): internal/attr/nonnull.h
enc/trans/gb18030.$(OBJEXT): internal/attr/noreturn.h
+enc/trans/gb18030.$(OBJEXT): internal/attr/packed_struct.h
enc/trans/gb18030.$(OBJEXT): internal/attr/pure.h
enc/trans/gb18030.$(OBJEXT): internal/attr/restrict.h
enc/trans/gb18030.$(OBJEXT): internal/attr/returns_nonnull.h
@@ -6760,7 +6717,6 @@ enc/trans/gb18030.$(OBJEXT): internal/intern/enumerator.h
enc/trans/gb18030.$(OBJEXT): internal/intern/error.h
enc/trans/gb18030.$(OBJEXT): internal/intern/eval.h
enc/trans/gb18030.$(OBJEXT): internal/intern/file.h
-enc/trans/gb18030.$(OBJEXT): internal/intern/gc.h
enc/trans/gb18030.$(OBJEXT): internal/intern/hash.h
enc/trans/gb18030.$(OBJEXT): internal/intern/io.h
enc/trans/gb18030.$(OBJEXT): internal/intern/load.h
@@ -6791,7 +6747,6 @@ enc/trans/gb18030.$(OBJEXT): internal/memory.h
enc/trans/gb18030.$(OBJEXT): internal/method.h
enc/trans/gb18030.$(OBJEXT): internal/module.h
enc/trans/gb18030.$(OBJEXT): internal/newobj.h
-enc/trans/gb18030.$(OBJEXT): internal/rgengc.h
enc/trans/gb18030.$(OBJEXT): internal/scan_args.h
enc/trans/gb18030.$(OBJEXT): internal/special_consts.h
enc/trans/gb18030.$(OBJEXT): internal/static_assert.h
@@ -6860,6 +6815,7 @@ enc/trans/gbk.$(OBJEXT): internal/attr/noexcept.h
enc/trans/gbk.$(OBJEXT): internal/attr/noinline.h
enc/trans/gbk.$(OBJEXT): internal/attr/nonnull.h
enc/trans/gbk.$(OBJEXT): internal/attr/noreturn.h
+enc/trans/gbk.$(OBJEXT): internal/attr/packed_struct.h
enc/trans/gbk.$(OBJEXT): internal/attr/pure.h
enc/trans/gbk.$(OBJEXT): internal/attr/restrict.h
enc/trans/gbk.$(OBJEXT): internal/attr/returns_nonnull.h
@@ -6919,7 +6875,6 @@ enc/trans/gbk.$(OBJEXT): internal/intern/enumerator.h
enc/trans/gbk.$(OBJEXT): internal/intern/error.h
enc/trans/gbk.$(OBJEXT): internal/intern/eval.h
enc/trans/gbk.$(OBJEXT): internal/intern/file.h
-enc/trans/gbk.$(OBJEXT): internal/intern/gc.h
enc/trans/gbk.$(OBJEXT): internal/intern/hash.h
enc/trans/gbk.$(OBJEXT): internal/intern/io.h
enc/trans/gbk.$(OBJEXT): internal/intern/load.h
@@ -6950,7 +6905,6 @@ enc/trans/gbk.$(OBJEXT): internal/memory.h
enc/trans/gbk.$(OBJEXT): internal/method.h
enc/trans/gbk.$(OBJEXT): internal/module.h
enc/trans/gbk.$(OBJEXT): internal/newobj.h
-enc/trans/gbk.$(OBJEXT): internal/rgengc.h
enc/trans/gbk.$(OBJEXT): internal/scan_args.h
enc/trans/gbk.$(OBJEXT): internal/special_consts.h
enc/trans/gbk.$(OBJEXT): internal/static_assert.h
@@ -7019,6 +6973,7 @@ enc/trans/iso2022.$(OBJEXT): internal/attr/noexcept.h
enc/trans/iso2022.$(OBJEXT): internal/attr/noinline.h
enc/trans/iso2022.$(OBJEXT): internal/attr/nonnull.h
enc/trans/iso2022.$(OBJEXT): internal/attr/noreturn.h
+enc/trans/iso2022.$(OBJEXT): internal/attr/packed_struct.h
enc/trans/iso2022.$(OBJEXT): internal/attr/pure.h
enc/trans/iso2022.$(OBJEXT): internal/attr/restrict.h
enc/trans/iso2022.$(OBJEXT): internal/attr/returns_nonnull.h
@@ -7078,7 +7033,6 @@ enc/trans/iso2022.$(OBJEXT): internal/intern/enumerator.h
enc/trans/iso2022.$(OBJEXT): internal/intern/error.h
enc/trans/iso2022.$(OBJEXT): internal/intern/eval.h
enc/trans/iso2022.$(OBJEXT): internal/intern/file.h
-enc/trans/iso2022.$(OBJEXT): internal/intern/gc.h
enc/trans/iso2022.$(OBJEXT): internal/intern/hash.h
enc/trans/iso2022.$(OBJEXT): internal/intern/io.h
enc/trans/iso2022.$(OBJEXT): internal/intern/load.h
@@ -7109,7 +7063,6 @@ enc/trans/iso2022.$(OBJEXT): internal/memory.h
enc/trans/iso2022.$(OBJEXT): internal/method.h
enc/trans/iso2022.$(OBJEXT): internal/module.h
enc/trans/iso2022.$(OBJEXT): internal/newobj.h
-enc/trans/iso2022.$(OBJEXT): internal/rgengc.h
enc/trans/iso2022.$(OBJEXT): internal/scan_args.h
enc/trans/iso2022.$(OBJEXT): internal/special_consts.h
enc/trans/iso2022.$(OBJEXT): internal/static_assert.h
@@ -7178,6 +7131,7 @@ enc/trans/japanese.$(OBJEXT): internal/attr/noexcept.h
enc/trans/japanese.$(OBJEXT): internal/attr/noinline.h
enc/trans/japanese.$(OBJEXT): internal/attr/nonnull.h
enc/trans/japanese.$(OBJEXT): internal/attr/noreturn.h
+enc/trans/japanese.$(OBJEXT): internal/attr/packed_struct.h
enc/trans/japanese.$(OBJEXT): internal/attr/pure.h
enc/trans/japanese.$(OBJEXT): internal/attr/restrict.h
enc/trans/japanese.$(OBJEXT): internal/attr/returns_nonnull.h
@@ -7237,7 +7191,6 @@ enc/trans/japanese.$(OBJEXT): internal/intern/enumerator.h
enc/trans/japanese.$(OBJEXT): internal/intern/error.h
enc/trans/japanese.$(OBJEXT): internal/intern/eval.h
enc/trans/japanese.$(OBJEXT): internal/intern/file.h
-enc/trans/japanese.$(OBJEXT): internal/intern/gc.h
enc/trans/japanese.$(OBJEXT): internal/intern/hash.h
enc/trans/japanese.$(OBJEXT): internal/intern/io.h
enc/trans/japanese.$(OBJEXT): internal/intern/load.h
@@ -7268,7 +7221,6 @@ enc/trans/japanese.$(OBJEXT): internal/memory.h
enc/trans/japanese.$(OBJEXT): internal/method.h
enc/trans/japanese.$(OBJEXT): internal/module.h
enc/trans/japanese.$(OBJEXT): internal/newobj.h
-enc/trans/japanese.$(OBJEXT): internal/rgengc.h
enc/trans/japanese.$(OBJEXT): internal/scan_args.h
enc/trans/japanese.$(OBJEXT): internal/special_consts.h
enc/trans/japanese.$(OBJEXT): internal/static_assert.h
@@ -7337,6 +7289,7 @@ enc/trans/japanese_euc.$(OBJEXT): internal/attr/noexcept.h
enc/trans/japanese_euc.$(OBJEXT): internal/attr/noinline.h
enc/trans/japanese_euc.$(OBJEXT): internal/attr/nonnull.h
enc/trans/japanese_euc.$(OBJEXT): internal/attr/noreturn.h
+enc/trans/japanese_euc.$(OBJEXT): internal/attr/packed_struct.h
enc/trans/japanese_euc.$(OBJEXT): internal/attr/pure.h
enc/trans/japanese_euc.$(OBJEXT): internal/attr/restrict.h
enc/trans/japanese_euc.$(OBJEXT): internal/attr/returns_nonnull.h
@@ -7396,7 +7349,6 @@ enc/trans/japanese_euc.$(OBJEXT): internal/intern/enumerator.h
enc/trans/japanese_euc.$(OBJEXT): internal/intern/error.h
enc/trans/japanese_euc.$(OBJEXT): internal/intern/eval.h
enc/trans/japanese_euc.$(OBJEXT): internal/intern/file.h
-enc/trans/japanese_euc.$(OBJEXT): internal/intern/gc.h
enc/trans/japanese_euc.$(OBJEXT): internal/intern/hash.h
enc/trans/japanese_euc.$(OBJEXT): internal/intern/io.h
enc/trans/japanese_euc.$(OBJEXT): internal/intern/load.h
@@ -7427,7 +7379,6 @@ enc/trans/japanese_euc.$(OBJEXT): internal/memory.h
enc/trans/japanese_euc.$(OBJEXT): internal/method.h
enc/trans/japanese_euc.$(OBJEXT): internal/module.h
enc/trans/japanese_euc.$(OBJEXT): internal/newobj.h
-enc/trans/japanese_euc.$(OBJEXT): internal/rgengc.h
enc/trans/japanese_euc.$(OBJEXT): internal/scan_args.h
enc/trans/japanese_euc.$(OBJEXT): internal/special_consts.h
enc/trans/japanese_euc.$(OBJEXT): internal/static_assert.h
@@ -7496,6 +7447,7 @@ enc/trans/japanese_sjis.$(OBJEXT): internal/attr/noexcept.h
enc/trans/japanese_sjis.$(OBJEXT): internal/attr/noinline.h
enc/trans/japanese_sjis.$(OBJEXT): internal/attr/nonnull.h
enc/trans/japanese_sjis.$(OBJEXT): internal/attr/noreturn.h
+enc/trans/japanese_sjis.$(OBJEXT): internal/attr/packed_struct.h
enc/trans/japanese_sjis.$(OBJEXT): internal/attr/pure.h
enc/trans/japanese_sjis.$(OBJEXT): internal/attr/restrict.h
enc/trans/japanese_sjis.$(OBJEXT): internal/attr/returns_nonnull.h
@@ -7555,7 +7507,6 @@ enc/trans/japanese_sjis.$(OBJEXT): internal/intern/enumerator.h
enc/trans/japanese_sjis.$(OBJEXT): internal/intern/error.h
enc/trans/japanese_sjis.$(OBJEXT): internal/intern/eval.h
enc/trans/japanese_sjis.$(OBJEXT): internal/intern/file.h
-enc/trans/japanese_sjis.$(OBJEXT): internal/intern/gc.h
enc/trans/japanese_sjis.$(OBJEXT): internal/intern/hash.h
enc/trans/japanese_sjis.$(OBJEXT): internal/intern/io.h
enc/trans/japanese_sjis.$(OBJEXT): internal/intern/load.h
@@ -7586,7 +7537,6 @@ enc/trans/japanese_sjis.$(OBJEXT): internal/memory.h
enc/trans/japanese_sjis.$(OBJEXT): internal/method.h
enc/trans/japanese_sjis.$(OBJEXT): internal/module.h
enc/trans/japanese_sjis.$(OBJEXT): internal/newobj.h
-enc/trans/japanese_sjis.$(OBJEXT): internal/rgengc.h
enc/trans/japanese_sjis.$(OBJEXT): internal/scan_args.h
enc/trans/japanese_sjis.$(OBJEXT): internal/special_consts.h
enc/trans/japanese_sjis.$(OBJEXT): internal/static_assert.h
@@ -7655,6 +7605,7 @@ enc/trans/korean.$(OBJEXT): internal/attr/noexcept.h
enc/trans/korean.$(OBJEXT): internal/attr/noinline.h
enc/trans/korean.$(OBJEXT): internal/attr/nonnull.h
enc/trans/korean.$(OBJEXT): internal/attr/noreturn.h
+enc/trans/korean.$(OBJEXT): internal/attr/packed_struct.h
enc/trans/korean.$(OBJEXT): internal/attr/pure.h
enc/trans/korean.$(OBJEXT): internal/attr/restrict.h
enc/trans/korean.$(OBJEXT): internal/attr/returns_nonnull.h
@@ -7714,7 +7665,6 @@ enc/trans/korean.$(OBJEXT): internal/intern/enumerator.h
enc/trans/korean.$(OBJEXT): internal/intern/error.h
enc/trans/korean.$(OBJEXT): internal/intern/eval.h
enc/trans/korean.$(OBJEXT): internal/intern/file.h
-enc/trans/korean.$(OBJEXT): internal/intern/gc.h
enc/trans/korean.$(OBJEXT): internal/intern/hash.h
enc/trans/korean.$(OBJEXT): internal/intern/io.h
enc/trans/korean.$(OBJEXT): internal/intern/load.h
@@ -7745,7 +7695,6 @@ enc/trans/korean.$(OBJEXT): internal/memory.h
enc/trans/korean.$(OBJEXT): internal/method.h
enc/trans/korean.$(OBJEXT): internal/module.h
enc/trans/korean.$(OBJEXT): internal/newobj.h
-enc/trans/korean.$(OBJEXT): internal/rgengc.h
enc/trans/korean.$(OBJEXT): internal/scan_args.h
enc/trans/korean.$(OBJEXT): internal/special_consts.h
enc/trans/korean.$(OBJEXT): internal/static_assert.h
@@ -7813,6 +7762,7 @@ enc/trans/newline.$(OBJEXT): internal/attr/noexcept.h
enc/trans/newline.$(OBJEXT): internal/attr/noinline.h
enc/trans/newline.$(OBJEXT): internal/attr/nonnull.h
enc/trans/newline.$(OBJEXT): internal/attr/noreturn.h
+enc/trans/newline.$(OBJEXT): internal/attr/packed_struct.h
enc/trans/newline.$(OBJEXT): internal/attr/pure.h
enc/trans/newline.$(OBJEXT): internal/attr/restrict.h
enc/trans/newline.$(OBJEXT): internal/attr/returns_nonnull.h
@@ -7872,7 +7822,6 @@ enc/trans/newline.$(OBJEXT): internal/intern/enumerator.h
enc/trans/newline.$(OBJEXT): internal/intern/error.h
enc/trans/newline.$(OBJEXT): internal/intern/eval.h
enc/trans/newline.$(OBJEXT): internal/intern/file.h
-enc/trans/newline.$(OBJEXT): internal/intern/gc.h
enc/trans/newline.$(OBJEXT): internal/intern/hash.h
enc/trans/newline.$(OBJEXT): internal/intern/io.h
enc/trans/newline.$(OBJEXT): internal/intern/load.h
@@ -7903,7 +7852,6 @@ enc/trans/newline.$(OBJEXT): internal/memory.h
enc/trans/newline.$(OBJEXT): internal/method.h
enc/trans/newline.$(OBJEXT): internal/module.h
enc/trans/newline.$(OBJEXT): internal/newobj.h
-enc/trans/newline.$(OBJEXT): internal/rgengc.h
enc/trans/newline.$(OBJEXT): internal/scan_args.h
enc/trans/newline.$(OBJEXT): internal/special_consts.h
enc/trans/newline.$(OBJEXT): internal/static_assert.h
@@ -7972,6 +7920,7 @@ enc/trans/single_byte.$(OBJEXT): internal/attr/noexcept.h
enc/trans/single_byte.$(OBJEXT): internal/attr/noinline.h
enc/trans/single_byte.$(OBJEXT): internal/attr/nonnull.h
enc/trans/single_byte.$(OBJEXT): internal/attr/noreturn.h
+enc/trans/single_byte.$(OBJEXT): internal/attr/packed_struct.h
enc/trans/single_byte.$(OBJEXT): internal/attr/pure.h
enc/trans/single_byte.$(OBJEXT): internal/attr/restrict.h
enc/trans/single_byte.$(OBJEXT): internal/attr/returns_nonnull.h
@@ -8031,7 +7980,6 @@ enc/trans/single_byte.$(OBJEXT): internal/intern/enumerator.h
enc/trans/single_byte.$(OBJEXT): internal/intern/error.h
enc/trans/single_byte.$(OBJEXT): internal/intern/eval.h
enc/trans/single_byte.$(OBJEXT): internal/intern/file.h
-enc/trans/single_byte.$(OBJEXT): internal/intern/gc.h
enc/trans/single_byte.$(OBJEXT): internal/intern/hash.h
enc/trans/single_byte.$(OBJEXT): internal/intern/io.h
enc/trans/single_byte.$(OBJEXT): internal/intern/load.h
@@ -8062,7 +8010,6 @@ enc/trans/single_byte.$(OBJEXT): internal/memory.h
enc/trans/single_byte.$(OBJEXT): internal/method.h
enc/trans/single_byte.$(OBJEXT): internal/module.h
enc/trans/single_byte.$(OBJEXT): internal/newobj.h
-enc/trans/single_byte.$(OBJEXT): internal/rgengc.h
enc/trans/single_byte.$(OBJEXT): internal/scan_args.h
enc/trans/single_byte.$(OBJEXT): internal/special_consts.h
enc/trans/single_byte.$(OBJEXT): internal/static_assert.h
@@ -8131,6 +8078,7 @@ enc/trans/transdb.$(OBJEXT): internal/attr/noexcept.h
enc/trans/transdb.$(OBJEXT): internal/attr/noinline.h
enc/trans/transdb.$(OBJEXT): internal/attr/nonnull.h
enc/trans/transdb.$(OBJEXT): internal/attr/noreturn.h
+enc/trans/transdb.$(OBJEXT): internal/attr/packed_struct.h
enc/trans/transdb.$(OBJEXT): internal/attr/pure.h
enc/trans/transdb.$(OBJEXT): internal/attr/restrict.h
enc/trans/transdb.$(OBJEXT): internal/attr/returns_nonnull.h
@@ -8190,7 +8138,6 @@ enc/trans/transdb.$(OBJEXT): internal/intern/enumerator.h
enc/trans/transdb.$(OBJEXT): internal/intern/error.h
enc/trans/transdb.$(OBJEXT): internal/intern/eval.h
enc/trans/transdb.$(OBJEXT): internal/intern/file.h
-enc/trans/transdb.$(OBJEXT): internal/intern/gc.h
enc/trans/transdb.$(OBJEXT): internal/intern/hash.h
enc/trans/transdb.$(OBJEXT): internal/intern/io.h
enc/trans/transdb.$(OBJEXT): internal/intern/load.h
@@ -8221,7 +8168,6 @@ enc/trans/transdb.$(OBJEXT): internal/memory.h
enc/trans/transdb.$(OBJEXT): internal/method.h
enc/trans/transdb.$(OBJEXT): internal/module.h
enc/trans/transdb.$(OBJEXT): internal/newobj.h
-enc/trans/transdb.$(OBJEXT): internal/rgengc.h
enc/trans/transdb.$(OBJEXT): internal/scan_args.h
enc/trans/transdb.$(OBJEXT): internal/special_consts.h
enc/trans/transdb.$(OBJEXT): internal/static_assert.h
@@ -8291,6 +8237,7 @@ enc/trans/utf8_mac.$(OBJEXT): internal/attr/noexcept.h
enc/trans/utf8_mac.$(OBJEXT): internal/attr/noinline.h
enc/trans/utf8_mac.$(OBJEXT): internal/attr/nonnull.h
enc/trans/utf8_mac.$(OBJEXT): internal/attr/noreturn.h
+enc/trans/utf8_mac.$(OBJEXT): internal/attr/packed_struct.h
enc/trans/utf8_mac.$(OBJEXT): internal/attr/pure.h
enc/trans/utf8_mac.$(OBJEXT): internal/attr/restrict.h
enc/trans/utf8_mac.$(OBJEXT): internal/attr/returns_nonnull.h
@@ -8350,7 +8297,6 @@ enc/trans/utf8_mac.$(OBJEXT): internal/intern/enumerator.h
enc/trans/utf8_mac.$(OBJEXT): internal/intern/error.h
enc/trans/utf8_mac.$(OBJEXT): internal/intern/eval.h
enc/trans/utf8_mac.$(OBJEXT): internal/intern/file.h
-enc/trans/utf8_mac.$(OBJEXT): internal/intern/gc.h
enc/trans/utf8_mac.$(OBJEXT): internal/intern/hash.h
enc/trans/utf8_mac.$(OBJEXT): internal/intern/io.h
enc/trans/utf8_mac.$(OBJEXT): internal/intern/load.h
@@ -8381,7 +8327,6 @@ enc/trans/utf8_mac.$(OBJEXT): internal/memory.h
enc/trans/utf8_mac.$(OBJEXT): internal/method.h
enc/trans/utf8_mac.$(OBJEXT): internal/module.h
enc/trans/utf8_mac.$(OBJEXT): internal/newobj.h
-enc/trans/utf8_mac.$(OBJEXT): internal/rgengc.h
enc/trans/utf8_mac.$(OBJEXT): internal/scan_args.h
enc/trans/utf8_mac.$(OBJEXT): internal/special_consts.h
enc/trans/utf8_mac.$(OBJEXT): internal/static_assert.h
@@ -8450,6 +8395,7 @@ enc/trans/utf_16_32.$(OBJEXT): internal/attr/noexcept.h
enc/trans/utf_16_32.$(OBJEXT): internal/attr/noinline.h
enc/trans/utf_16_32.$(OBJEXT): internal/attr/nonnull.h
enc/trans/utf_16_32.$(OBJEXT): internal/attr/noreturn.h
+enc/trans/utf_16_32.$(OBJEXT): internal/attr/packed_struct.h
enc/trans/utf_16_32.$(OBJEXT): internal/attr/pure.h
enc/trans/utf_16_32.$(OBJEXT): internal/attr/restrict.h
enc/trans/utf_16_32.$(OBJEXT): internal/attr/returns_nonnull.h
@@ -8509,7 +8455,6 @@ enc/trans/utf_16_32.$(OBJEXT): internal/intern/enumerator.h
enc/trans/utf_16_32.$(OBJEXT): internal/intern/error.h
enc/trans/utf_16_32.$(OBJEXT): internal/intern/eval.h
enc/trans/utf_16_32.$(OBJEXT): internal/intern/file.h
-enc/trans/utf_16_32.$(OBJEXT): internal/intern/gc.h
enc/trans/utf_16_32.$(OBJEXT): internal/intern/hash.h
enc/trans/utf_16_32.$(OBJEXT): internal/intern/io.h
enc/trans/utf_16_32.$(OBJEXT): internal/intern/load.h
@@ -8540,7 +8485,6 @@ enc/trans/utf_16_32.$(OBJEXT): internal/memory.h
enc/trans/utf_16_32.$(OBJEXT): internal/method.h
enc/trans/utf_16_32.$(OBJEXT): internal/module.h
enc/trans/utf_16_32.$(OBJEXT): internal/newobj.h
-enc/trans/utf_16_32.$(OBJEXT): internal/rgengc.h
enc/trans/utf_16_32.$(OBJEXT): internal/scan_args.h
enc/trans/utf_16_32.$(OBJEXT): internal/special_consts.h
enc/trans/utf_16_32.$(OBJEXT): internal/static_assert.h
@@ -8612,6 +8556,7 @@ enc/unicode.$(OBJEXT): internal/attr/noexcept.h
enc/unicode.$(OBJEXT): internal/attr/noinline.h
enc/unicode.$(OBJEXT): internal/attr/nonnull.h
enc/unicode.$(OBJEXT): internal/attr/noreturn.h
+enc/unicode.$(OBJEXT): internal/attr/packed_struct.h
enc/unicode.$(OBJEXT): internal/attr/pure.h
enc/unicode.$(OBJEXT): internal/attr/restrict.h
enc/unicode.$(OBJEXT): internal/attr/returns_nonnull.h
@@ -8671,7 +8616,6 @@ enc/unicode.$(OBJEXT): internal/intern/enumerator.h
enc/unicode.$(OBJEXT): internal/intern/error.h
enc/unicode.$(OBJEXT): internal/intern/eval.h
enc/unicode.$(OBJEXT): internal/intern/file.h
-enc/unicode.$(OBJEXT): internal/intern/gc.h
enc/unicode.$(OBJEXT): internal/intern/hash.h
enc/unicode.$(OBJEXT): internal/intern/io.h
enc/unicode.$(OBJEXT): internal/intern/load.h
@@ -8702,7 +8646,6 @@ enc/unicode.$(OBJEXT): internal/memory.h
enc/unicode.$(OBJEXT): internal/method.h
enc/unicode.$(OBJEXT): internal/module.h
enc/unicode.$(OBJEXT): internal/newobj.h
-enc/unicode.$(OBJEXT): internal/rgengc.h
enc/unicode.$(OBJEXT): internal/scan_args.h
enc/unicode.$(OBJEXT): internal/special_consts.h
enc/unicode.$(OBJEXT): internal/static_assert.h
@@ -8774,6 +8717,7 @@ enc/us_ascii.$(OBJEXT): internal/attr/noexcept.h
enc/us_ascii.$(OBJEXT): internal/attr/noinline.h
enc/us_ascii.$(OBJEXT): internal/attr/nonnull.h
enc/us_ascii.$(OBJEXT): internal/attr/noreturn.h
+enc/us_ascii.$(OBJEXT): internal/attr/packed_struct.h
enc/us_ascii.$(OBJEXT): internal/attr/pure.h
enc/us_ascii.$(OBJEXT): internal/attr/restrict.h
enc/us_ascii.$(OBJEXT): internal/attr/returns_nonnull.h
@@ -8842,7 +8786,6 @@ enc/us_ascii.$(OBJEXT): internal/intern/enumerator.h
enc/us_ascii.$(OBJEXT): internal/intern/error.h
enc/us_ascii.$(OBJEXT): internal/intern/eval.h
enc/us_ascii.$(OBJEXT): internal/intern/file.h
-enc/us_ascii.$(OBJEXT): internal/intern/gc.h
enc/us_ascii.$(OBJEXT): internal/intern/hash.h
enc/us_ascii.$(OBJEXT): internal/intern/io.h
enc/us_ascii.$(OBJEXT): internal/intern/load.h
@@ -8873,7 +8816,6 @@ enc/us_ascii.$(OBJEXT): internal/memory.h
enc/us_ascii.$(OBJEXT): internal/method.h
enc/us_ascii.$(OBJEXT): internal/module.h
enc/us_ascii.$(OBJEXT): internal/newobj.h
-enc/us_ascii.$(OBJEXT): internal/rgengc.h
enc/us_ascii.$(OBJEXT): internal/scan_args.h
enc/us_ascii.$(OBJEXT): internal/special_consts.h
enc/us_ascii.$(OBJEXT): internal/static_assert.h
@@ -8946,6 +8888,7 @@ enc/utf_16be.$(OBJEXT): internal/attr/noexcept.h
enc/utf_16be.$(OBJEXT): internal/attr/noinline.h
enc/utf_16be.$(OBJEXT): internal/attr/nonnull.h
enc/utf_16be.$(OBJEXT): internal/attr/noreturn.h
+enc/utf_16be.$(OBJEXT): internal/attr/packed_struct.h
enc/utf_16be.$(OBJEXT): internal/attr/pure.h
enc/utf_16be.$(OBJEXT): internal/attr/restrict.h
enc/utf_16be.$(OBJEXT): internal/attr/returns_nonnull.h
@@ -9005,7 +8948,6 @@ enc/utf_16be.$(OBJEXT): internal/intern/enumerator.h
enc/utf_16be.$(OBJEXT): internal/intern/error.h
enc/utf_16be.$(OBJEXT): internal/intern/eval.h
enc/utf_16be.$(OBJEXT): internal/intern/file.h
-enc/utf_16be.$(OBJEXT): internal/intern/gc.h
enc/utf_16be.$(OBJEXT): internal/intern/hash.h
enc/utf_16be.$(OBJEXT): internal/intern/io.h
enc/utf_16be.$(OBJEXT): internal/intern/load.h
@@ -9036,7 +8978,6 @@ enc/utf_16be.$(OBJEXT): internal/memory.h
enc/utf_16be.$(OBJEXT): internal/method.h
enc/utf_16be.$(OBJEXT): internal/module.h
enc/utf_16be.$(OBJEXT): internal/newobj.h
-enc/utf_16be.$(OBJEXT): internal/rgengc.h
enc/utf_16be.$(OBJEXT): internal/scan_args.h
enc/utf_16be.$(OBJEXT): internal/special_consts.h
enc/utf_16be.$(OBJEXT): internal/static_assert.h
@@ -9108,6 +9049,7 @@ enc/utf_16le.$(OBJEXT): internal/attr/noexcept.h
enc/utf_16le.$(OBJEXT): internal/attr/noinline.h
enc/utf_16le.$(OBJEXT): internal/attr/nonnull.h
enc/utf_16le.$(OBJEXT): internal/attr/noreturn.h
+enc/utf_16le.$(OBJEXT): internal/attr/packed_struct.h
enc/utf_16le.$(OBJEXT): internal/attr/pure.h
enc/utf_16le.$(OBJEXT): internal/attr/restrict.h
enc/utf_16le.$(OBJEXT): internal/attr/returns_nonnull.h
@@ -9167,7 +9109,6 @@ enc/utf_16le.$(OBJEXT): internal/intern/enumerator.h
enc/utf_16le.$(OBJEXT): internal/intern/error.h
enc/utf_16le.$(OBJEXT): internal/intern/eval.h
enc/utf_16le.$(OBJEXT): internal/intern/file.h
-enc/utf_16le.$(OBJEXT): internal/intern/gc.h
enc/utf_16le.$(OBJEXT): internal/intern/hash.h
enc/utf_16le.$(OBJEXT): internal/intern/io.h
enc/utf_16le.$(OBJEXT): internal/intern/load.h
@@ -9198,7 +9139,6 @@ enc/utf_16le.$(OBJEXT): internal/memory.h
enc/utf_16le.$(OBJEXT): internal/method.h
enc/utf_16le.$(OBJEXT): internal/module.h
enc/utf_16le.$(OBJEXT): internal/newobj.h
-enc/utf_16le.$(OBJEXT): internal/rgengc.h
enc/utf_16le.$(OBJEXT): internal/scan_args.h
enc/utf_16le.$(OBJEXT): internal/special_consts.h
enc/utf_16le.$(OBJEXT): internal/static_assert.h
@@ -9270,6 +9210,7 @@ enc/utf_32be.$(OBJEXT): internal/attr/noexcept.h
enc/utf_32be.$(OBJEXT): internal/attr/noinline.h
enc/utf_32be.$(OBJEXT): internal/attr/nonnull.h
enc/utf_32be.$(OBJEXT): internal/attr/noreturn.h
+enc/utf_32be.$(OBJEXT): internal/attr/packed_struct.h
enc/utf_32be.$(OBJEXT): internal/attr/pure.h
enc/utf_32be.$(OBJEXT): internal/attr/restrict.h
enc/utf_32be.$(OBJEXT): internal/attr/returns_nonnull.h
@@ -9329,7 +9270,6 @@ enc/utf_32be.$(OBJEXT): internal/intern/enumerator.h
enc/utf_32be.$(OBJEXT): internal/intern/error.h
enc/utf_32be.$(OBJEXT): internal/intern/eval.h
enc/utf_32be.$(OBJEXT): internal/intern/file.h
-enc/utf_32be.$(OBJEXT): internal/intern/gc.h
enc/utf_32be.$(OBJEXT): internal/intern/hash.h
enc/utf_32be.$(OBJEXT): internal/intern/io.h
enc/utf_32be.$(OBJEXT): internal/intern/load.h
@@ -9360,7 +9300,6 @@ enc/utf_32be.$(OBJEXT): internal/memory.h
enc/utf_32be.$(OBJEXT): internal/method.h
enc/utf_32be.$(OBJEXT): internal/module.h
enc/utf_32be.$(OBJEXT): internal/newobj.h
-enc/utf_32be.$(OBJEXT): internal/rgengc.h
enc/utf_32be.$(OBJEXT): internal/scan_args.h
enc/utf_32be.$(OBJEXT): internal/special_consts.h
enc/utf_32be.$(OBJEXT): internal/static_assert.h
@@ -9432,6 +9371,7 @@ enc/utf_32le.$(OBJEXT): internal/attr/noexcept.h
enc/utf_32le.$(OBJEXT): internal/attr/noinline.h
enc/utf_32le.$(OBJEXT): internal/attr/nonnull.h
enc/utf_32le.$(OBJEXT): internal/attr/noreturn.h
+enc/utf_32le.$(OBJEXT): internal/attr/packed_struct.h
enc/utf_32le.$(OBJEXT): internal/attr/pure.h
enc/utf_32le.$(OBJEXT): internal/attr/restrict.h
enc/utf_32le.$(OBJEXT): internal/attr/returns_nonnull.h
@@ -9491,7 +9431,6 @@ enc/utf_32le.$(OBJEXT): internal/intern/enumerator.h
enc/utf_32le.$(OBJEXT): internal/intern/error.h
enc/utf_32le.$(OBJEXT): internal/intern/eval.h
enc/utf_32le.$(OBJEXT): internal/intern/file.h
-enc/utf_32le.$(OBJEXT): internal/intern/gc.h
enc/utf_32le.$(OBJEXT): internal/intern/hash.h
enc/utf_32le.$(OBJEXT): internal/intern/io.h
enc/utf_32le.$(OBJEXT): internal/intern/load.h
@@ -9522,7 +9461,6 @@ enc/utf_32le.$(OBJEXT): internal/memory.h
enc/utf_32le.$(OBJEXT): internal/method.h
enc/utf_32le.$(OBJEXT): internal/module.h
enc/utf_32le.$(OBJEXT): internal/newobj.h
-enc/utf_32le.$(OBJEXT): internal/rgengc.h
enc/utf_32le.$(OBJEXT): internal/scan_args.h
enc/utf_32le.$(OBJEXT): internal/special_consts.h
enc/utf_32le.$(OBJEXT): internal/static_assert.h
@@ -9594,6 +9532,7 @@ enc/utf_8.$(OBJEXT): internal/attr/noexcept.h
enc/utf_8.$(OBJEXT): internal/attr/noinline.h
enc/utf_8.$(OBJEXT): internal/attr/nonnull.h
enc/utf_8.$(OBJEXT): internal/attr/noreturn.h
+enc/utf_8.$(OBJEXT): internal/attr/packed_struct.h
enc/utf_8.$(OBJEXT): internal/attr/pure.h
enc/utf_8.$(OBJEXT): internal/attr/restrict.h
enc/utf_8.$(OBJEXT): internal/attr/returns_nonnull.h
@@ -9662,7 +9601,6 @@ enc/utf_8.$(OBJEXT): internal/intern/enumerator.h
enc/utf_8.$(OBJEXT): internal/intern/error.h
enc/utf_8.$(OBJEXT): internal/intern/eval.h
enc/utf_8.$(OBJEXT): internal/intern/file.h
-enc/utf_8.$(OBJEXT): internal/intern/gc.h
enc/utf_8.$(OBJEXT): internal/intern/hash.h
enc/utf_8.$(OBJEXT): internal/intern/io.h
enc/utf_8.$(OBJEXT): internal/intern/load.h
@@ -9693,7 +9631,6 @@ enc/utf_8.$(OBJEXT): internal/memory.h
enc/utf_8.$(OBJEXT): internal/method.h
enc/utf_8.$(OBJEXT): internal/module.h
enc/utf_8.$(OBJEXT): internal/newobj.h
-enc/utf_8.$(OBJEXT): internal/rgengc.h
enc/utf_8.$(OBJEXT): internal/scan_args.h
enc/utf_8.$(OBJEXT): internal/special_consts.h
enc/utf_8.$(OBJEXT): internal/static_assert.h
@@ -9766,6 +9703,7 @@ enc/windows_1250.$(OBJEXT): internal/attr/noexcept.h
enc/windows_1250.$(OBJEXT): internal/attr/noinline.h
enc/windows_1250.$(OBJEXT): internal/attr/nonnull.h
enc/windows_1250.$(OBJEXT): internal/attr/noreturn.h
+enc/windows_1250.$(OBJEXT): internal/attr/packed_struct.h
enc/windows_1250.$(OBJEXT): internal/attr/pure.h
enc/windows_1250.$(OBJEXT): internal/attr/restrict.h
enc/windows_1250.$(OBJEXT): internal/attr/returns_nonnull.h
@@ -9825,7 +9763,6 @@ enc/windows_1250.$(OBJEXT): internal/intern/enumerator.h
enc/windows_1250.$(OBJEXT): internal/intern/error.h
enc/windows_1250.$(OBJEXT): internal/intern/eval.h
enc/windows_1250.$(OBJEXT): internal/intern/file.h
-enc/windows_1250.$(OBJEXT): internal/intern/gc.h
enc/windows_1250.$(OBJEXT): internal/intern/hash.h
enc/windows_1250.$(OBJEXT): internal/intern/io.h
enc/windows_1250.$(OBJEXT): internal/intern/load.h
@@ -9856,7 +9793,6 @@ enc/windows_1250.$(OBJEXT): internal/memory.h
enc/windows_1250.$(OBJEXT): internal/method.h
enc/windows_1250.$(OBJEXT): internal/module.h
enc/windows_1250.$(OBJEXT): internal/newobj.h
-enc/windows_1250.$(OBJEXT): internal/rgengc.h
enc/windows_1250.$(OBJEXT): internal/scan_args.h
enc/windows_1250.$(OBJEXT): internal/special_consts.h
enc/windows_1250.$(OBJEXT): internal/static_assert.h
@@ -9927,6 +9863,7 @@ enc/windows_1251.$(OBJEXT): internal/attr/noexcept.h
enc/windows_1251.$(OBJEXT): internal/attr/noinline.h
enc/windows_1251.$(OBJEXT): internal/attr/nonnull.h
enc/windows_1251.$(OBJEXT): internal/attr/noreturn.h
+enc/windows_1251.$(OBJEXT): internal/attr/packed_struct.h
enc/windows_1251.$(OBJEXT): internal/attr/pure.h
enc/windows_1251.$(OBJEXT): internal/attr/restrict.h
enc/windows_1251.$(OBJEXT): internal/attr/returns_nonnull.h
@@ -9986,7 +9923,6 @@ enc/windows_1251.$(OBJEXT): internal/intern/enumerator.h
enc/windows_1251.$(OBJEXT): internal/intern/error.h
enc/windows_1251.$(OBJEXT): internal/intern/eval.h
enc/windows_1251.$(OBJEXT): internal/intern/file.h
-enc/windows_1251.$(OBJEXT): internal/intern/gc.h
enc/windows_1251.$(OBJEXT): internal/intern/hash.h
enc/windows_1251.$(OBJEXT): internal/intern/io.h
enc/windows_1251.$(OBJEXT): internal/intern/load.h
@@ -10017,7 +9953,6 @@ enc/windows_1251.$(OBJEXT): internal/memory.h
enc/windows_1251.$(OBJEXT): internal/method.h
enc/windows_1251.$(OBJEXT): internal/module.h
enc/windows_1251.$(OBJEXT): internal/newobj.h
-enc/windows_1251.$(OBJEXT): internal/rgengc.h
enc/windows_1251.$(OBJEXT): internal/scan_args.h
enc/windows_1251.$(OBJEXT): internal/special_consts.h
enc/windows_1251.$(OBJEXT): internal/static_assert.h
@@ -10089,6 +10024,7 @@ enc/windows_1252.$(OBJEXT): internal/attr/noexcept.h
enc/windows_1252.$(OBJEXT): internal/attr/noinline.h
enc/windows_1252.$(OBJEXT): internal/attr/nonnull.h
enc/windows_1252.$(OBJEXT): internal/attr/noreturn.h
+enc/windows_1252.$(OBJEXT): internal/attr/packed_struct.h
enc/windows_1252.$(OBJEXT): internal/attr/pure.h
enc/windows_1252.$(OBJEXT): internal/attr/restrict.h
enc/windows_1252.$(OBJEXT): internal/attr/returns_nonnull.h
@@ -10148,7 +10084,6 @@ enc/windows_1252.$(OBJEXT): internal/intern/enumerator.h
enc/windows_1252.$(OBJEXT): internal/intern/error.h
enc/windows_1252.$(OBJEXT): internal/intern/eval.h
enc/windows_1252.$(OBJEXT): internal/intern/file.h
-enc/windows_1252.$(OBJEXT): internal/intern/gc.h
enc/windows_1252.$(OBJEXT): internal/intern/hash.h
enc/windows_1252.$(OBJEXT): internal/intern/io.h
enc/windows_1252.$(OBJEXT): internal/intern/load.h
@@ -10179,7 +10114,6 @@ enc/windows_1252.$(OBJEXT): internal/memory.h
enc/windows_1252.$(OBJEXT): internal/method.h
enc/windows_1252.$(OBJEXT): internal/module.h
enc/windows_1252.$(OBJEXT): internal/newobj.h
-enc/windows_1252.$(OBJEXT): internal/rgengc.h
enc/windows_1252.$(OBJEXT): internal/scan_args.h
enc/windows_1252.$(OBJEXT): internal/special_consts.h
enc/windows_1252.$(OBJEXT): internal/static_assert.h
@@ -10250,6 +10184,7 @@ enc/windows_1253.$(OBJEXT): internal/attr/noexcept.h
enc/windows_1253.$(OBJEXT): internal/attr/noinline.h
enc/windows_1253.$(OBJEXT): internal/attr/nonnull.h
enc/windows_1253.$(OBJEXT): internal/attr/noreturn.h
+enc/windows_1253.$(OBJEXT): internal/attr/packed_struct.h
enc/windows_1253.$(OBJEXT): internal/attr/pure.h
enc/windows_1253.$(OBJEXT): internal/attr/restrict.h
enc/windows_1253.$(OBJEXT): internal/attr/returns_nonnull.h
@@ -10309,7 +10244,6 @@ enc/windows_1253.$(OBJEXT): internal/intern/enumerator.h
enc/windows_1253.$(OBJEXT): internal/intern/error.h
enc/windows_1253.$(OBJEXT): internal/intern/eval.h
enc/windows_1253.$(OBJEXT): internal/intern/file.h
-enc/windows_1253.$(OBJEXT): internal/intern/gc.h
enc/windows_1253.$(OBJEXT): internal/intern/hash.h
enc/windows_1253.$(OBJEXT): internal/intern/io.h
enc/windows_1253.$(OBJEXT): internal/intern/load.h
@@ -10340,7 +10274,6 @@ enc/windows_1253.$(OBJEXT): internal/memory.h
enc/windows_1253.$(OBJEXT): internal/method.h
enc/windows_1253.$(OBJEXT): internal/module.h
enc/windows_1253.$(OBJEXT): internal/newobj.h
-enc/windows_1253.$(OBJEXT): internal/rgengc.h
enc/windows_1253.$(OBJEXT): internal/scan_args.h
enc/windows_1253.$(OBJEXT): internal/special_consts.h
enc/windows_1253.$(OBJEXT): internal/static_assert.h
@@ -10412,6 +10345,7 @@ enc/windows_1254.$(OBJEXT): internal/attr/noexcept.h
enc/windows_1254.$(OBJEXT): internal/attr/noinline.h
enc/windows_1254.$(OBJEXT): internal/attr/nonnull.h
enc/windows_1254.$(OBJEXT): internal/attr/noreturn.h
+enc/windows_1254.$(OBJEXT): internal/attr/packed_struct.h
enc/windows_1254.$(OBJEXT): internal/attr/pure.h
enc/windows_1254.$(OBJEXT): internal/attr/restrict.h
enc/windows_1254.$(OBJEXT): internal/attr/returns_nonnull.h
@@ -10471,7 +10405,6 @@ enc/windows_1254.$(OBJEXT): internal/intern/enumerator.h
enc/windows_1254.$(OBJEXT): internal/intern/error.h
enc/windows_1254.$(OBJEXT): internal/intern/eval.h
enc/windows_1254.$(OBJEXT): internal/intern/file.h
-enc/windows_1254.$(OBJEXT): internal/intern/gc.h
enc/windows_1254.$(OBJEXT): internal/intern/hash.h
enc/windows_1254.$(OBJEXT): internal/intern/io.h
enc/windows_1254.$(OBJEXT): internal/intern/load.h
@@ -10502,7 +10435,6 @@ enc/windows_1254.$(OBJEXT): internal/memory.h
enc/windows_1254.$(OBJEXT): internal/method.h
enc/windows_1254.$(OBJEXT): internal/module.h
enc/windows_1254.$(OBJEXT): internal/newobj.h
-enc/windows_1254.$(OBJEXT): internal/rgengc.h
enc/windows_1254.$(OBJEXT): internal/scan_args.h
enc/windows_1254.$(OBJEXT): internal/special_consts.h
enc/windows_1254.$(OBJEXT): internal/static_assert.h
@@ -10574,6 +10506,7 @@ enc/windows_1257.$(OBJEXT): internal/attr/noexcept.h
enc/windows_1257.$(OBJEXT): internal/attr/noinline.h
enc/windows_1257.$(OBJEXT): internal/attr/nonnull.h
enc/windows_1257.$(OBJEXT): internal/attr/noreturn.h
+enc/windows_1257.$(OBJEXT): internal/attr/packed_struct.h
enc/windows_1257.$(OBJEXT): internal/attr/pure.h
enc/windows_1257.$(OBJEXT): internal/attr/restrict.h
enc/windows_1257.$(OBJEXT): internal/attr/returns_nonnull.h
@@ -10633,7 +10566,6 @@ enc/windows_1257.$(OBJEXT): internal/intern/enumerator.h
enc/windows_1257.$(OBJEXT): internal/intern/error.h
enc/windows_1257.$(OBJEXT): internal/intern/eval.h
enc/windows_1257.$(OBJEXT): internal/intern/file.h
-enc/windows_1257.$(OBJEXT): internal/intern/gc.h
enc/windows_1257.$(OBJEXT): internal/intern/hash.h
enc/windows_1257.$(OBJEXT): internal/intern/io.h
enc/windows_1257.$(OBJEXT): internal/intern/load.h
@@ -10664,7 +10596,6 @@ enc/windows_1257.$(OBJEXT): internal/memory.h
enc/windows_1257.$(OBJEXT): internal/method.h
enc/windows_1257.$(OBJEXT): internal/module.h
enc/windows_1257.$(OBJEXT): internal/newobj.h
-enc/windows_1257.$(OBJEXT): internal/rgengc.h
enc/windows_1257.$(OBJEXT): internal/scan_args.h
enc/windows_1257.$(OBJEXT): internal/special_consts.h
enc/windows_1257.$(OBJEXT): internal/static_assert.h
@@ -10738,6 +10669,7 @@ enc/windows_31j.$(OBJEXT): internal/attr/noexcept.h
enc/windows_31j.$(OBJEXT): internal/attr/noinline.h
enc/windows_31j.$(OBJEXT): internal/attr/nonnull.h
enc/windows_31j.$(OBJEXT): internal/attr/noreturn.h
+enc/windows_31j.$(OBJEXT): internal/attr/packed_struct.h
enc/windows_31j.$(OBJEXT): internal/attr/pure.h
enc/windows_31j.$(OBJEXT): internal/attr/restrict.h
enc/windows_31j.$(OBJEXT): internal/attr/returns_nonnull.h
@@ -10797,7 +10729,6 @@ enc/windows_31j.$(OBJEXT): internal/intern/enumerator.h
enc/windows_31j.$(OBJEXT): internal/intern/error.h
enc/windows_31j.$(OBJEXT): internal/intern/eval.h
enc/windows_31j.$(OBJEXT): internal/intern/file.h
-enc/windows_31j.$(OBJEXT): internal/intern/gc.h
enc/windows_31j.$(OBJEXT): internal/intern/hash.h
enc/windows_31j.$(OBJEXT): internal/intern/io.h
enc/windows_31j.$(OBJEXT): internal/intern/load.h
@@ -10828,7 +10759,6 @@ enc/windows_31j.$(OBJEXT): internal/memory.h
enc/windows_31j.$(OBJEXT): internal/method.h
enc/windows_31j.$(OBJEXT): internal/module.h
enc/windows_31j.$(OBJEXT): internal/newobj.h
-enc/windows_31j.$(OBJEXT): internal/rgengc.h
enc/windows_31j.$(OBJEXT): internal/scan_args.h
enc/windows_31j.$(OBJEXT): internal/special_consts.h
enc/windows_31j.$(OBJEXT): internal/static_assert.h
diff --git a/enc/unicode/15.0.0/name2ctype.h b/enc/unicode/15.0.0/name2ctype.h
index a2c996423d..6bbbb3512f 100644
--- a/enc/unicode/15.0.0/name2ctype.h
+++ b/enc/unicode/15.0.0/name2ctype.h
@@ -5402,7 +5402,7 @@ static const OnigCodePoint CR_ASCII[] = {
0x0000, 0x007f,
}; /* CR_ASCII */
-/* 'Punct' */
+/* 'Punct': [[:Punct:]] */
static const OnigCodePoint CR_Punct[] = {
191,
0x0021, 0x0023,
diff --git a/encoding.c b/encoding.c
index 469ec47db5..a0be931c97 100644
--- a/encoding.c
+++ b/encoding.c
@@ -71,6 +71,24 @@ static struct enc_table {
st_table *names;
} global_enc_table;
+static int
+enc_names_free_i(st_data_t name, st_data_t idx, st_data_t args)
+{
+ ruby_xfree((void *)name);
+ return ST_DELETE;
+}
+
+void
+rb_free_global_enc_table(void)
+{
+ for (size_t i = 0; i < ENCODING_LIST_CAPA; i++) {
+ xfree((void *)global_enc_table.list[i].enc);
+ }
+
+ st_foreach(global_enc_table.names, enc_names_free_i, (st_data_t)0);
+ st_free_table(global_enc_table.names);
+}
+
static rb_encoding *global_enc_ascii,
*global_enc_utf_8,
*global_enc_us_ascii;
@@ -102,7 +120,7 @@ static rb_encoding *global_enc_ascii,
static const rb_data_type_t encoding_data_type = {
"encoding",
{0, 0, 0,},
- 0, 0, RUBY_TYPED_FREE_IMMEDIATELY
+ 0, 0, RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_WB_PROTECTED
};
#define is_data_encoding(obj) (RTYPEDDATA_P(obj) && RTYPEDDATA_TYPE(obj) == &encoding_data_type)
@@ -1525,7 +1543,14 @@ enc_set_default_encoding(struct default_encoding *def, VALUE encoding, const cha
if (NIL_P(encoding)) {
def->index = -1;
def->enc = 0;
- st_insert(enc_table->names, (st_data_t)strdup(name),
+ char *name_dup = strdup(name);
+
+ st_data_t existing_name = (st_data_t)name_dup;
+ if (st_delete(enc_table->names, &existing_name, NULL)) {
+ xfree((void *)existing_name);
+ }
+
+ st_insert(enc_table->names, (st_data_t)name_dup,
(st_data_t)UNSPECIFIED_ENCODING);
}
else {
diff --git a/enum.c b/enum.c
index 391de0b337..7f15836ba8 100644
--- a/enum.c
+++ b/enum.c
@@ -354,7 +354,7 @@ find_i(RB_BLOCK_CALL_FUNC_ARGLIST(i, memop))
* {foo: 0, bar: 1, baz: 2}.find {|key, value| key.start_with?('b') } # => [:bar, 1]
* {foo: 0, bar: 1, baz: 2}.find(proc {[]}) {|key, value| key.start_with?('c') } # => []
*
- * With no block given, returns an \Enumerator.
+ * With no block given, returns an Enumerator.
*
*/
static VALUE
@@ -424,7 +424,7 @@ find_index_iter_i(RB_BLOCK_CALL_FUNC_ARGLIST(i, memop))
* ['a', 'b', 'c', 'b'].find_index {|element| element.start_with?('b') } # => 1
* {foo: 0, bar: 1, baz: 2}.find_index {|key, value| value > 1 } # => 2
*
- * With no argument and no block given, returns an \Enumerator.
+ * With no argument and no block given, returns an Enumerator.
*
*/
@@ -501,7 +501,7 @@ enum_size_over_p(VALUE obj, long n)
* a = {foo: 0, bar: 1, baz: 2}.select {|key, value| key.start_with?('b') }
* a # => {:bar=>1, :baz=>2}
*
- * With no block given, returns an \Enumerator.
+ * With no block given, returns an Enumerator.
*
* Related: #reject.
*/
@@ -543,7 +543,7 @@ filter_map_i(RB_BLOCK_CALL_FUNC_ARGLIST(i, ary))
* (0..9).filter_map {|i| i * 2 if i.even? } # => [0, 4, 8, 12, 16]
* {foo: 0, bar: 1, baz: 2}.filter_map {|key, value| key if value.even? } # => [:foo, :baz]
*
- * When no block given, returns an \Enumerator.
+ * When no block given, returns an Enumerator.
*
*/
static VALUE
@@ -584,7 +584,7 @@ reject_i(RB_BLOCK_CALL_FUNC_ARGLIST(i, ary))
* (0..9).reject {|i| i * 2 if i.even? } # => [1, 3, 5, 7, 9]
* {foo: 0, bar: 1, baz: 2}.reject {|key, value| key if value.odd? } # => {:foo=>0, :baz=>2}
*
- * When no block given, returns an \Enumerator.
+ * When no block given, returns an Enumerator.
*
* Related: #select.
*/
@@ -631,7 +631,7 @@ collect_all(RB_BLOCK_CALL_FUNC_ARGLIST(i, ary))
* (0..4).map {|i| i*i } # => [0, 1, 4, 9, 16]
* {foo: 0, bar: 1, baz: 2}.map {|key, value| value*2} # => [0, 2, 4]
*
- * With no block given, returns an \Enumerator.
+ * With no block given, returns an Enumerator.
*
*/
static VALUE
@@ -681,7 +681,7 @@ flat_map_i(RB_BLOCK_CALL_FUNC_ARGLIST(i, ary))
* [[0, 1], [2, 3]].flat_map {|e| e + [100] } # => [0, 1, 100, 2, 3, 100]
* {foo: 0, bar: 1, baz: 2}.flat_map {|key, value| [key, value] } # => [:foo, 0, :bar, 1, :baz, 2]
*
- * With no block given, returns an \Enumerator.
+ * With no block given, returns an Enumerator.
*
* Alias: #collect_concat.
*/
@@ -700,13 +700,12 @@ enum_flat_map(VALUE obj)
/*
* call-seq:
- * to_a -> array
+ * to_a(*args) -> array
*
* Returns an array containing the items in +self+:
*
* (0..4).to_a # => [0, 1, 2, 3, 4]
*
- * Enumerable#entries is an alias for Enumerable#to_a.
*/
static VALUE
enum_to_a(int argc, VALUE *argv, VALUE obj)
@@ -746,8 +745,8 @@ enum_to_h_ii(RB_BLOCK_CALL_FUNC_ARGLIST(i, hash))
/*
* call-seq:
- * to_h -> hash
- * to_h {|element| ... } -> hash
+ * to_h(*args) -> hash
+ * to_h(*args) {|element| ... } -> hash
*
* When +self+ consists of 2-element arrays,
* returns a hash each of whose entries is the key-value pair
@@ -1000,7 +999,6 @@ ary_inject_op(VALUE ary, VALUE init, VALUE op)
* "Memo: 3; element: 3"
* "Memo: 6; element: 4"
*
- * Enumerable#reduce is an alias for Enumerable#inject.
*
*/
static VALUE
@@ -1336,10 +1334,12 @@ enum_sort(VALUE obj)
}
#define SORT_BY_BUFSIZE 16
+#define SORT_BY_UNIFORMED(num, flo, fix) (((num&1)<<2)|((flo&1)<<1)|fix)
struct sort_by_data {
const VALUE ary;
const VALUE buf;
- long n;
+ uint8_t n;
+ uint8_t primitive_uniformed;
};
static VALUE
@@ -1360,6 +1360,11 @@ sort_by_i(RB_BLOCK_CALL_FUNC_ARGLIST(i, _data))
rb_raise(rb_eRuntimeError, "sort_by reentered");
}
+ if (data->primitive_uniformed) {
+ data->primitive_uniformed &= SORT_BY_UNIFORMED((FIXNUM_P(v)) || (RB_FLOAT_TYPE_P(v)),
+ RB_FLOAT_TYPE_P(v),
+ FIXNUM_P(v));
+ }
RARRAY_ASET(data->buf, data->n*2, v);
RARRAY_ASET(data->buf, data->n*2+1, i);
data->n++;
@@ -1387,6 +1392,179 @@ sort_by_cmp(const void *ap, const void *bp, void *data)
return OPTIMIZED_CMP(a, b);
}
+
+/*
+ This is parts of uniform sort
+*/
+
+#define uless rb_uniform_is_less
+#define UNIFORM_SWAP(a,b)\
+ do{struct rb_uniform_sort_data tmp = a; a = b; b = tmp;} while(0)
+
+struct rb_uniform_sort_data {
+ VALUE v;
+ VALUE i;
+};
+
+static inline bool
+rb_uniform_is_less(VALUE a, VALUE b)
+{
+
+ if (FIXNUM_P(a) && FIXNUM_P(b)) {
+ return (SIGNED_VALUE)a < (SIGNED_VALUE)b;
+ }
+ else if (FIXNUM_P(a)) {
+ RUBY_ASSERT(RB_FLOAT_TYPE_P(b));
+ return rb_float_cmp(b, a) > 0;
+ }
+ else {
+ RUBY_ASSERT(RB_FLOAT_TYPE_P(a));
+ return rb_float_cmp(a, b) < 0;
+ }
+}
+
+static inline bool
+rb_uniform_is_larger(VALUE a, VALUE b)
+{
+
+ if (FIXNUM_P(a) && FIXNUM_P(b)) {
+ return (SIGNED_VALUE)a > (SIGNED_VALUE)b;
+ }
+ else if (FIXNUM_P(a)) {
+ RUBY_ASSERT(RB_FLOAT_TYPE_P(b));
+ return rb_float_cmp(b, a) < 0;
+ }
+ else {
+ RUBY_ASSERT(RB_FLOAT_TYPE_P(a));
+ return rb_float_cmp(a, b) > 0;
+ }
+}
+
+#define med3_val(a,b,c) (uless(a,b)?(uless(b,c)?b:uless(c,a)?a:c):(uless(c,b)?b:uless(a,c)?a:c))
+
+static void
+rb_uniform_insertionsort_2(struct rb_uniform_sort_data* ptr_begin,
+ struct rb_uniform_sort_data* ptr_end)
+{
+ if ((ptr_end - ptr_begin) < 2) return;
+ struct rb_uniform_sort_data tmp, *j, *k,
+ *index = ptr_begin+1;
+ for (; index < ptr_end; index++) {
+ tmp = *index;
+ j = k = index;
+ if (uless(tmp.v, ptr_begin->v)) {
+ while (ptr_begin < j) {
+ *j = *(--k);
+ j = k;
+ }
+ }
+ else {
+ while (uless(tmp.v, (--k)->v)) {
+ *j = *k;
+ j = k;
+ }
+ }
+ *j = tmp;
+ }
+}
+
+static inline void
+rb_uniform_heap_down_2(struct rb_uniform_sort_data* ptr_begin,
+ size_t offset, size_t len)
+{
+ size_t c;
+ struct rb_uniform_sort_data tmp = ptr_begin[offset];
+ while ((c = (offset<<1)+1) <= len) {
+ if (c < len && uless(ptr_begin[c].v, ptr_begin[c+1].v)) {
+ c++;
+ }
+ if (!uless(tmp.v, ptr_begin[c].v)) break;
+ ptr_begin[offset] = ptr_begin[c];
+ offset = c;
+ }
+ ptr_begin[offset] = tmp;
+}
+
+static void
+rb_uniform_heapsort_2(struct rb_uniform_sort_data* ptr_begin,
+ struct rb_uniform_sort_data* ptr_end)
+{
+ size_t n = ptr_end - ptr_begin;
+ if (n < 2) return;
+
+ for (size_t offset = n>>1; offset > 0;) {
+ rb_uniform_heap_down_2(ptr_begin, --offset, n-1);
+ }
+ for (size_t offset = n-1; offset > 0;) {
+ UNIFORM_SWAP(*ptr_begin, ptr_begin[offset]);
+ rb_uniform_heap_down_2(ptr_begin, 0, --offset);
+ }
+}
+
+
+static void
+rb_uniform_quicksort_intro_2(struct rb_uniform_sort_data* ptr_begin,
+ struct rb_uniform_sort_data* ptr_end, size_t d)
+{
+
+ if (ptr_end - ptr_begin <= 16) {
+ rb_uniform_insertionsort_2(ptr_begin, ptr_end);
+ return;
+ }
+ if (d == 0) {
+ rb_uniform_heapsort_2(ptr_begin, ptr_end);
+ return;
+ }
+
+ VALUE x = med3_val(ptr_begin->v,
+ ptr_begin[(ptr_end - ptr_begin)>>1].v,
+ ptr_end[-1].v);
+ struct rb_uniform_sort_data *i = ptr_begin;
+ struct rb_uniform_sort_data *j = ptr_end-1;
+
+ do {
+ while (uless(i->v, x)) i++;
+ while (uless(x, j->v)) j--;
+ if (i <= j) {
+ UNIFORM_SWAP(*i, *j);
+ i++;
+ j--;
+ }
+ } while (i <= j);
+ j++;
+ if (ptr_end - j > 1) rb_uniform_quicksort_intro_2(j, ptr_end, d-1);
+ if (i - ptr_begin > 1) rb_uniform_quicksort_intro_2(ptr_begin, i, d-1);
+}
+
+/**
+ * Direct primitive data compare sort. Implement with intro sort.
+ * @param[in] ptr_begin The begin address of target rb_ary's raw pointer.
+ * @param[in] ptr_end The end address of target rb_ary's raw pointer.
+**/
+static void
+rb_uniform_intro_sort_2(struct rb_uniform_sort_data* ptr_begin,
+ struct rb_uniform_sort_data* ptr_end)
+{
+ size_t n = ptr_end - ptr_begin;
+ size_t d = CHAR_BIT * sizeof(n) - nlz_intptr(n) - 1;
+ bool sorted_flag = true;
+
+ for (struct rb_uniform_sort_data* ptr = ptr_begin+1; ptr < ptr_end; ptr++) {
+ if (rb_uniform_is_larger((ptr-1)->v, (ptr)->v)) {
+ sorted_flag = false;
+ break;
+ }
+ }
+
+ if (sorted_flag) {
+ return;
+ }
+ rb_uniform_quicksort_intro_2(ptr_begin, ptr_end, d<<1);
+}
+
+#undef uless
+
+
/*
* call-seq:
* sort_by {|element| ... } -> array
@@ -1493,6 +1671,9 @@ enum_sort_by(VALUE obj)
RB_OBJ_WRITE(memo, &data->ary, ary);
RB_OBJ_WRITE(memo, &data->buf, buf);
data->n = 0;
+ data->primitive_uniformed = SORT_BY_UNIFORMED((CMP_OPTIMIZABLE(FLOAT) && CMP_OPTIMIZABLE(INTEGER)),
+ CMP_OPTIMIZABLE(FLOAT),
+ CMP_OPTIMIZABLE(INTEGER));
rb_block_call(obj, id_each, 0, 0, sort_by_i, (VALUE)memo);
ary = data->ary;
buf = data->buf;
@@ -1501,9 +1682,16 @@ enum_sort_by(VALUE obj)
rb_ary_concat(ary, buf);
}
if (RARRAY_LEN(ary) > 2) {
- RARRAY_PTR_USE(ary, ptr,
- ruby_qsort(ptr, RARRAY_LEN(ary)/2, 2*sizeof(VALUE),
- sort_by_cmp, (void *)ary));
+ if (data->primitive_uniformed) {
+ RARRAY_PTR_USE(ary, ptr,
+ rb_uniform_intro_sort_2((struct rb_uniform_sort_data*)ptr,
+ (struct rb_uniform_sort_data*)(ptr + RARRAY_LEN(ary))));
+ }
+ else {
+ RARRAY_PTR_USE(ary, ptr,
+ ruby_qsort(ptr, RARRAY_LEN(ary)/2, 2*sizeof(VALUE),
+ sort_by_cmp, (void *)ary));
+ }
}
if (RBASIC(ary)->klass) {
rb_raise(rb_eRuntimeError, "sort_by reentered");
@@ -1569,6 +1757,9 @@ DEFINE_ENUMFUNCS(all)
*
* Returns whether every element meets a given criterion.
*
+ * If +self+ has no element, returns +true+ and argument or block
+ * are not used.
+ *
* With no argument and no block,
* returns whether every element is truthy:
*
@@ -1630,6 +1821,9 @@ DEFINE_ENUMFUNCS(any)
*
* Returns whether any element meets a given criterion.
*
+ * If +self+ has no element, returns +false+ and argument or block
+ * are not used.
+ *
* With no argument and no block,
* returns whether any element is truthy:
*
@@ -1660,7 +1854,6 @@ DEFINE_ENUMFUNCS(any)
* {foo: 0, bar: 1, baz: 2}.any? {|key, value| value < 1 } # => true
* {foo: 0, bar: 1, baz: 2}.any? {|key, value| value < 0 } # => false
*
- *
* Related: #all?, #none?, #one?.
*/
@@ -2722,8 +2915,6 @@ member_i(RB_BLOCK_CALL_FUNC_ARGLIST(iter, args))
* {foo: 0, bar: 1, baz: 2}.include?('foo') # => false
* {foo: 0, bar: 1, baz: 2}.include?(0) # => false
*
- * Enumerable#member? is an alias for Enumerable#include?.
- *
*/
static VALUE
@@ -4633,13 +4824,13 @@ uniq_iter(RB_BLOCK_CALL_FUNC_ARGLIST(i, hash))
* %w[a b c c b a a b c].uniq # => ["a", "b", "c"]
* [0, 1, 2, 2, 1, 0, 0, 1, 2].uniq # => [0, 1, 2]
*
- * With a block, returns a new array containing only for which the block
+ * With a block, returns a new array containing elements only for which the block
* returns a unique value:
*
* a = [0, 1, 2, 3, 4, 5, 5, 4, 3, 2, 1]
* a.uniq {|i| i.even? ? i : 0 } # => [0, 2, 4]
* a = %w[a b c d e e d c b a a b c d e]
- a.uniq {|c| c < 'c' } # => ["a", "c"]
+ * a.uniq {|c| c < 'c' } # => ["a", "c"]
*
*/
@@ -4698,7 +4889,7 @@ enum_compact(VALUE obj)
*
* - {Querying}[rdoc-ref:Enumerable@Methods+for+Querying]
* - {Fetching}[rdoc-ref:Enumerable@Methods+for+Fetching]
- * - {Searching}[rdoc-ref:Enumerable@Methods+for+Searching]
+ * - {Searching and Filtering}[rdoc-ref:Enumerable@Methods+for+Searching+and+Filtering]
* - {Sorting}[rdoc-ref:Enumerable@Methods+for+Sorting]
* - {Iterating}[rdoc-ref:Enumerable@Methods+for+Iterating]
* - {And more....}[rdoc-ref:Enumerable@Other+Methods]
@@ -4714,7 +4905,7 @@ enum_compact(VALUE obj)
* - #one?: Returns +true+ if exactly one element meets a specified criterion; +false+ otherwise.
* - #count: Returns the count of elements,
* based on an argument or block criterion, if given.
- * - #tally: Returns a new \Hash containing the counts of occurrences of each element.
+ * - #tally: Returns a new Hash containing the counts of occurrences of each element.
*
* === Methods for Fetching
*
@@ -4735,21 +4926,21 @@ enum_compact(VALUE obj)
* as determined by <tt><=></tt> or a given block.
* - #max: Returns the elements whose values are largest among the elements,
* as determined by <tt><=></tt> or a given block.
- * - #minmax: Returns a 2-element \Array containing the smallest and largest elements.
+ * - #minmax: Returns a 2-element Array containing the smallest and largest elements.
* - #min_by: Returns the smallest element, as determined by the given block.
* - #max_by: Returns the largest element, as determined by the given block.
* - #minmax_by: Returns the smallest and largest elements, as determined by the given block.
*
* <i>Groups, slices, and partitions</i>:
*
- * - #group_by: Returns a \Hash that partitions the elements into groups.
+ * - #group_by: Returns a Hash that partitions the elements into groups.
* - #partition: Returns elements partitioned into two new Arrays, as determined by the given block.
- * - #slice_after: Returns a new \Enumerator whose entries are a partition of +self+,
- based either on a given +object+ or a given block.
- * - #slice_before: Returns a new \Enumerator whose entries are a partition of +self+,
- based either on a given +object+ or a given block.
- * - #slice_when: Returns a new \Enumerator whose entries are a partition of +self+
- based on the given block.
+ * - #slice_after: Returns a new Enumerator whose entries are a partition of +self+,
+ * based either on a given +object+ or a given block.
+ * - #slice_before: Returns a new Enumerator whose entries are a partition of +self+,
+ * based either on a given +object+ or a given block.
+ * - #slice_when: Returns a new Enumerator whose entries are a partition of +self+
+ * based on the given block.
* - #chunk: Returns elements organized into chunks as specified by the given block.
* - #chunk_while: Returns elements organized into chunks as specified by the given block.
*
@@ -4849,18 +5040,18 @@ enum_compact(VALUE obj)
*
* Virtually all methods in \Enumerable call method +#each+ in the including class:
*
- * - <tt>Hash#each</tt> yields the next key-value pair as a 2-element \Array.
- * - <tt>Struct#each</tt> yields the next name-value pair as a 2-element \Array.
+ * - <tt>Hash#each</tt> yields the next key-value pair as a 2-element Array.
+ * - <tt>Struct#each</tt> yields the next name-value pair as a 2-element Array.
* - For the other classes above, +#each+ yields the next object from the collection.
*
* == About the Examples
*
* The example code snippets for the \Enumerable methods:
*
- * - Always show the use of one or more \Array-like classes (often \Array itself).
- * - Sometimes show the use of a \Hash-like class.
+ * - Always show the use of one or more Array-like classes (often Array itself).
+ * - Sometimes show the use of a Hash-like class.
* For some methods, though, the usage would not make sense,
- * and so it is not shown. Example: #tally would find exactly one of each \Hash entry.
+ * and so it is not shown. Example: #tally would find exactly one of each Hash entry.
*
*/
diff --git a/enumerator.c b/enumerator.c
index b2f8855503..d2819e4049 100644
--- a/enumerator.c
+++ b/enumerator.c
@@ -85,12 +85,16 @@
* puts e.next # => 3
* puts e.next # raises StopIteration
*
- * +next+, +next_values+, +peek+ and +peek_values+ are the only methods
- * which use external iteration (and Array#zip(Enumerable-not-Array) which uses +next+).
+ * +next+, +next_values+, +peek+, and +peek_values+ are the only methods
+ * which use external iteration (and Array#zip(Enumerable-not-Array) which uses +next+ internally).
*
* These methods do not affect other internal enumeration methods,
* unless the underlying iteration method itself has side-effect, e.g. IO#each_line.
*
+ * FrozenError will be raised if these methods are called against a frozen enumerator.
+ * Since +rewind+ and +feed+ also change state for external iteration,
+ * these methods may raise FrozenError too.
+ *
* External iteration differs *significantly* from internal iteration
* due to using a Fiber:
* - The Fiber adds some overhead compared to internal enumeration.
@@ -165,7 +169,10 @@ static VALUE sym_each, sym_cycle, sym_yield;
static VALUE lazy_use_super_method;
+extern ID ruby_static_id_cause;
+
#define id_call idCall
+#define id_cause ruby_static_id_cause
#define id_each idEach
#define id_eqq idEqq
#define id_initialize idInitialize
@@ -188,6 +195,19 @@ struct enumerator {
int kw_splat;
};
+RUBY_REFERENCES(enumerator_refs) = {
+ RUBY_REF_EDGE(struct enumerator, obj),
+ RUBY_REF_EDGE(struct enumerator, args),
+ RUBY_REF_EDGE(struct enumerator, fib),
+ RUBY_REF_EDGE(struct enumerator, dst),
+ RUBY_REF_EDGE(struct enumerator, lookahead),
+ RUBY_REF_EDGE(struct enumerator, feedvalue),
+ RUBY_REF_EDGE(struct enumerator, stop_exc),
+ RUBY_REF_EDGE(struct enumerator, size),
+ RUBY_REF_EDGE(struct enumerator, procs),
+ RUBY_REF_END
+};
+
static VALUE rb_cGenerator, rb_cYielder, rb_cEnumProducer;
struct generator {
@@ -237,56 +257,15 @@ struct enum_product {
VALUE rb_cArithSeq;
-/*
- * Enumerator
- */
-static void
-enumerator_mark(void *p)
-{
- struct enumerator *ptr = p;
- rb_gc_mark_movable(ptr->obj);
- rb_gc_mark_movable(ptr->args);
- rb_gc_mark_movable(ptr->fib);
- rb_gc_mark_movable(ptr->dst);
- rb_gc_mark_movable(ptr->lookahead);
- rb_gc_mark_movable(ptr->feedvalue);
- rb_gc_mark_movable(ptr->stop_exc);
- rb_gc_mark_movable(ptr->size);
- rb_gc_mark_movable(ptr->procs);
-}
-
-static void
-enumerator_compact(void *p)
-{
- struct enumerator *ptr = p;
- ptr->obj = rb_gc_location(ptr->obj);
- ptr->args = rb_gc_location(ptr->args);
- ptr->fib = rb_gc_location(ptr->fib);
- ptr->dst = rb_gc_location(ptr->dst);
- ptr->lookahead = rb_gc_location(ptr->lookahead);
- ptr->feedvalue = rb_gc_location(ptr->feedvalue);
- ptr->stop_exc = rb_gc_location(ptr->stop_exc);
- ptr->size = rb_gc_location(ptr->size);
- ptr->procs = rb_gc_location(ptr->procs);
-}
-
-#define enumerator_free RUBY_TYPED_DEFAULT_FREE
-
-static size_t
-enumerator_memsize(const void *p)
-{
- return sizeof(struct enumerator);
-}
-
static const rb_data_type_t enumerator_data_type = {
"enumerator",
{
- enumerator_mark,
- enumerator_free,
- enumerator_memsize,
- enumerator_compact,
+ RUBY_REFS_LIST_PTR(enumerator_refs),
+ RUBY_TYPED_DEFAULT_FREE,
+ NULL, // Nothing allocated externally, so don't need a memsize function
+ NULL,
},
- 0, 0, RUBY_TYPED_FREE_IMMEDIATELY
+ 0, NULL, RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_WB_PROTECTED | RUBY_TYPED_DECL_MARKING | RUBY_TYPED_EMBEDDABLE
};
static struct enumerator *
@@ -317,22 +296,15 @@ proc_entry_compact(void *p)
ptr->memo = rb_gc_location(ptr->memo);
}
-#define proc_entry_free RUBY_TYPED_DEFAULT_FREE
-
-static size_t
-proc_entry_memsize(const void *p)
-{
- return p ? sizeof(struct proc_entry) : 0;
-}
-
static const rb_data_type_t proc_entry_data_type = {
"proc_entry",
{
proc_entry_mark,
- proc_entry_free,
- proc_entry_memsize,
+ RUBY_TYPED_DEFAULT_FREE,
+ NULL, // Nothing allocated externally, so don't need a memsize function
proc_entry_compact,
},
+ 0, 0, RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_WB_PROTECTED | RUBY_TYPED_EMBEDDABLE
};
static struct proc_entry *
@@ -417,7 +389,7 @@ obj_to_enum(int argc, VALUE *argv, VALUE obj)
}
enumerator = rb_enumeratorize_with_size(obj, meth, argc, argv, 0);
if (rb_block_given_p()) {
- enumerator_ptr(enumerator)->size = rb_block_proc();
+ RB_OBJ_WRITE(enumerator, &enumerator_ptr(enumerator)->size, rb_block_proc());
}
return enumerator;
}
@@ -446,15 +418,15 @@ enumerator_init(VALUE enum_obj, VALUE obj, VALUE meth, int argc, const VALUE *ar
rb_raise(rb_eArgError, "unallocated enumerator");
}
- ptr->obj = obj;
+ RB_OBJ_WRITE(enum_obj, &ptr->obj, obj);
ptr->meth = rb_to_id(meth);
- if (argc) ptr->args = rb_ary_new4(argc, argv);
+ if (argc) RB_OBJ_WRITE(enum_obj, &ptr->args, rb_ary_new4(argc, argv));
ptr->fib = 0;
ptr->dst = Qnil;
ptr->lookahead = Qundef;
ptr->feedvalue = Qundef;
ptr->stop_exc = Qfalse;
- ptr->size = size;
+ RB_OBJ_WRITE(enum_obj, &ptr->size, size);
ptr->size_fn = size_fn;
ptr->kw_splat = kw_splat;
@@ -533,13 +505,13 @@ enumerator_init_copy(VALUE obj, VALUE orig)
rb_raise(rb_eArgError, "unallocated enumerator");
}
- ptr1->obj = ptr0->obj;
- ptr1->meth = ptr0->meth;
- ptr1->args = ptr0->args;
+ RB_OBJ_WRITE(obj, &ptr1->obj, ptr0->obj);
+ RB_OBJ_WRITE(obj, &ptr1->meth, ptr0->meth);
+ RB_OBJ_WRITE(obj, &ptr1->args, ptr0->args);
ptr1->fib = 0;
ptr1->lookahead = Qundef;
ptr1->feedvalue = Qundef;
- ptr1->size = ptr0->size;
+ RB_OBJ_WRITE(obj, &ptr1->size, ptr0->size);
ptr1->size_fn = ptr0->size_fn;
return obj;
@@ -587,11 +559,17 @@ enumerator_block_call(VALUE obj, rb_block_call_func *func, VALUE arg)
const struct enumerator *e = enumerator_ptr(obj);
ID meth = e->meth;
- if (e->args) {
- argc = RARRAY_LENINT(e->args);
- argv = RARRAY_CONST_PTR(e->args);
+ VALUE args = e->args;
+ if (args) {
+ argc = RARRAY_LENINT(args);
+ argv = RARRAY_CONST_PTR(args);
}
- return rb_block_call_kw(e->obj, meth, argc, argv, func, arg, e->kw_splat);
+
+ VALUE ret = rb_block_call_kw(e->obj, meth, argc, argv, func, arg, e->kw_splat);
+
+ RB_GC_GUARD(args);
+
+ return ret;
}
/*
@@ -648,7 +626,7 @@ enumerator_each(int argc, VALUE *argv, VALUE obj)
else {
args = rb_ary_new4(argc, argv);
}
- e->args = args;
+ RB_OBJ_WRITE(obj, &e->args, args);
e->size = Qnil;
e->size_fn = 0;
}
@@ -789,7 +767,7 @@ next_i(RB_BLOCK_CALL_FUNC_ARGLIST(_, obj))
VALUE result;
result = rb_block_call(obj, id_each, 0, 0, next_ii, obj);
- e->stop_exc = rb_exc_new2(rb_eStopIteration, "iteration reached an end");
+ RB_OBJ_WRITE(obj, &e->stop_exc, rb_exc_new2(rb_eStopIteration, "iteration reached an end"));
rb_ivar_set(e->stop_exc, id_result, result);
return rb_fiber_yield(1, &nil);
}
@@ -798,8 +776,8 @@ static void
next_init(VALUE obj, struct enumerator *e)
{
VALUE curr = rb_fiber_current();
- e->dst = curr;
- e->fib = rb_fiber_new(next_i, obj);
+ RB_OBJ_WRITE(obj, &e->dst, curr);
+ RB_OBJ_WRITE(obj, &e->fib, rb_fiber_new(next_i, obj));
e->lookahead = Qundef;
}
@@ -808,8 +786,16 @@ get_next_values(VALUE obj, struct enumerator *e)
{
VALUE curr, vs;
- if (e->stop_exc)
- rb_exc_raise(e->stop_exc);
+ if (e->stop_exc) {
+ VALUE exc = e->stop_exc;
+ VALUE result = rb_attr_get(exc, id_result);
+ VALUE mesg = rb_attr_get(exc, idMesg);
+ if (!NIL_P(mesg)) mesg = rb_str_dup(mesg);
+ VALUE stop_exc = rb_exc_new_str(rb_eStopIteration, mesg);
+ rb_ivar_set(stop_exc, id_cause, exc);
+ rb_ivar_set(stop_exc, id_result, result);
+ rb_exc_raise(stop_exc);
+ }
curr = rb_fiber_current();
@@ -879,6 +865,8 @@ enumerator_next_values(VALUE obj)
struct enumerator *e = enumerator_ptr(obj);
VALUE vs;
+ rb_check_frozen(obj);
+
if (!UNDEF_P(e->lookahead)) {
vs = e->lookahead;
e->lookahead = Qundef;
@@ -940,9 +928,12 @@ enumerator_peek_values(VALUE obj)
{
struct enumerator *e = enumerator_ptr(obj);
+ rb_check_frozen(obj);
+
if (UNDEF_P(e->lookahead)) {
- e->lookahead = get_next_values(obj, e);
+ RB_OBJ_WRITE(obj, &e->lookahead, get_next_values(obj, e));
}
+
return e->lookahead;
}
@@ -1064,10 +1055,12 @@ enumerator_feed(VALUE obj, VALUE v)
{
struct enumerator *e = enumerator_ptr(obj);
+ rb_check_frozen(obj);
+
if (!UNDEF_P(e->feedvalue)) {
rb_raise(rb_eTypeError, "feed value already set");
}
- e->feedvalue = v;
+ RB_OBJ_WRITE(obj, &e->feedvalue, v);
return Qnil;
}
@@ -1086,6 +1079,8 @@ enumerator_rewind(VALUE obj)
{
struct enumerator *e = enumerator_ptr(obj);
+ rb_check_frozen(obj);
+
rb_check_funcall(e->obj, id_rewind, 0, 0);
e->fib = 0;
@@ -1299,23 +1294,15 @@ yielder_compact(void *p)
ptr->proc = rb_gc_location(ptr->proc);
}
-#define yielder_free RUBY_TYPED_DEFAULT_FREE
-
-static size_t
-yielder_memsize(const void *p)
-{
- return sizeof(struct yielder);
-}
-
static const rb_data_type_t yielder_data_type = {
"yielder",
{
yielder_mark,
- yielder_free,
- yielder_memsize,
+ RUBY_TYPED_DEFAULT_FREE,
+ NULL,
yielder_compact,
},
- 0, 0, RUBY_TYPED_FREE_IMMEDIATELY
+ 0, 0, RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_WB_PROTECTED | RUBY_TYPED_EMBEDDABLE
};
static struct yielder *
@@ -1354,7 +1341,7 @@ yielder_init(VALUE obj, VALUE proc)
rb_raise(rb_eArgError, "unallocated yielder");
}
- ptr->proc = proc;
+ RB_OBJ_WRITE(obj, &ptr->proc, proc);
return obj;
}
@@ -1439,23 +1426,15 @@ generator_compact(void *p)
ptr->obj = rb_gc_location(ptr->obj);
}
-#define generator_free RUBY_TYPED_DEFAULT_FREE
-
-static size_t
-generator_memsize(const void *p)
-{
- return sizeof(struct generator);
-}
-
static const rb_data_type_t generator_data_type = {
"generator",
{
generator_mark,
- generator_free,
- generator_memsize,
+ RUBY_TYPED_DEFAULT_FREE,
+ NULL,
generator_compact,
},
- 0, 0, RUBY_TYPED_FREE_IMMEDIATELY
+ 0, 0, RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_WB_PROTECTED | RUBY_TYPED_EMBEDDABLE
};
static struct generator *
@@ -1495,7 +1474,7 @@ generator_init(VALUE obj, VALUE proc)
rb_raise(rb_eArgError, "unallocated generator");
}
- ptr->proc = proc;
+ RB_OBJ_WRITE(obj, &ptr->proc, proc);
return obj;
}
@@ -1543,7 +1522,7 @@ generator_init_copy(VALUE obj, VALUE orig)
rb_raise(rb_eArgError, "unallocated generator");
}
- ptr1->proc = ptr0->proc;
+ RB_OBJ_WRITE(obj, &ptr1->proc, ptr0->proc);
return obj;
}
@@ -1710,7 +1689,7 @@ lazy_generator_init(VALUE enumerator, VALUE procs)
lazy_init_block, rb_ary_new3(2, obj, procs));
gen_ptr = generator_ptr(generator);
- gen_ptr->obj = obj;
+ RB_OBJ_WRITE(generator, &gen_ptr->obj, obj);
return generator;
}
@@ -1895,10 +1874,10 @@ lazy_add_method(VALUE obj, int argc, VALUE *argv, VALUE args, VALUE memo,
VALUE entry_obj = TypedData_Make_Struct(rb_cObject, struct proc_entry,
&proc_entry_data_type, entry);
if (rb_block_given_p()) {
- entry->proc = rb_block_proc();
+ RB_OBJ_WRITE(entry_obj, &entry->proc, rb_block_proc());
}
entry->fn = fn;
- entry->memo = args;
+ RB_OBJ_WRITE(entry_obj, &entry->memo, args);
lazy_set_args(entry_obj, memo);
@@ -1907,9 +1886,9 @@ lazy_add_method(VALUE obj, int argc, VALUE *argv, VALUE args, VALUE memo,
rb_ary_push(new_procs, entry_obj);
new_obj = enumerator_init_copy(enumerator_allocate(rb_cLazy), obj);
- new_e = DATA_PTR(new_obj);
- new_e->obj = new_generator;
- new_e->procs = new_procs;
+ new_e = RTYPEDDATA_GET_DATA(new_obj);
+ RB_OBJ_WRITE(new_obj, &new_e->obj, new_generator);
+ RB_OBJ_WRITE(new_obj, &new_e->procs, new_procs);
if (argc > 0) {
new_e->meth = rb_to_id(*argv++);
@@ -1918,7 +1897,9 @@ lazy_add_method(VALUE obj, int argc, VALUE *argv, VALUE args, VALUE memo,
else {
new_e->meth = id_each;
}
- new_e->args = rb_ary_new4(argc, argv);
+
+ RB_OBJ_WRITE(new_obj, &new_e->args, rb_ary_new4(argc, argv));
+
return new_obj;
}
@@ -2004,7 +1985,7 @@ lazy_to_enum(int argc, VALUE *argv, VALUE self)
}
lazy = lazy_to_enum_i(self, meth, argc, argv, 0, rb_keyword_given_p());
if (rb_block_given_p()) {
- enumerator_ptr(lazy)->size = rb_block_proc();
+ RB_OBJ_WRITE(lazy, &enumerator_ptr(lazy)->size, rb_block_proc());
}
return lazy;
}
@@ -2390,7 +2371,6 @@ lazy_zip_arrays_func(VALUE proc_entry, struct MEMO *result, VALUE memos, long me
rb_ary_push(ary, rb_ary_entry(RARRAY_AREF(arrays, i), count));
}
LAZY_MEMO_SET_VALUE(result, ary);
- LAZY_MEMO_SET_PACKED(result);
rb_ary_store(memos, memo_index, LONG2NUM(++count));
return result;
}
@@ -2965,7 +2945,7 @@ static const rb_data_type_t producer_data_type = {
producer_memsize,
producer_compact,
},
- 0, 0, RUBY_TYPED_FREE_IMMEDIATELY
+ 0, 0, RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_WB_PROTECTED | RUBY_TYPED_EMBEDDABLE
};
static struct producer *
@@ -3005,8 +2985,8 @@ producer_init(VALUE obj, VALUE init, VALUE proc)
rb_raise(rb_eArgError, "unallocated producer");
}
- ptr->init = init;
- ptr->proc = proc;
+ RB_OBJ_WRITE(obj, &ptr->init, init);
+ RB_OBJ_WRITE(obj, &ptr->proc, proc);
return obj;
}
diff --git a/error.c b/error.c
index 8aa081c198..29f0f27ab9 100644
--- a/error.c
+++ b/error.c
@@ -23,6 +23,10 @@
# include <unistd.h>
#endif
+#ifdef HAVE_SYS_WAIT_H
+# include <sys/wait.h>
+#endif
+
#if defined __APPLE__
# include <AvailabilityMacros.h>
#endif
@@ -34,12 +38,14 @@
#include "internal/io.h"
#include "internal/load.h"
#include "internal/object.h"
+#include "internal/process.h"
#include "internal/string.h"
#include "internal/symbol.h"
#include "internal/thread.h"
#include "internal/variable.h"
#include "ruby/encoding.h"
#include "ruby/st.h"
+#include "ruby/util.h"
#include "ruby_assert.h"
#include "vm_core.h"
@@ -77,6 +83,7 @@ static ID id_warn;
static ID id_category;
static ID id_deprecated;
static ID id_experimental;
+static ID id_performance;
static VALUE sym_category;
static VALUE sym_highlight;
static struct {
@@ -148,8 +155,8 @@ rb_syntax_error_append(VALUE exc, VALUE file, int line, int column,
}
static unsigned int warning_disabled_categories = (
- 1U << RB_WARN_CATEGORY_DEPRECATED |
- 0);
+ (1U << RB_WARN_CATEGORY_DEPRECATED) |
+ ~RB_WARN_CATEGORY_DEFAULT_BITS);
static unsigned int
rb_warning_category_mask(VALUE category)
@@ -187,7 +194,7 @@ rb_warning_category_update(unsigned int mask, unsigned int bits)
warning_disabled_categories |= mask & ~bits;
}
-MJIT_FUNC_EXPORTED bool
+bool
rb_warning_category_enabled_p(rb_warning_category_t category)
{
return !(warning_disabled_categories & (1U << category));
@@ -200,14 +207,19 @@ rb_warning_category_enabled_p(rb_warning_category_t category)
* Returns the flag to show the warning messages for +category+.
* Supported categories are:
*
- * +:deprecated+ :: deprecation warnings
- * * assignment of non-nil value to <code>$,</code> and <code>$;</code>
- * * keyword arguments
- * * proc/lambda without block
- * etc.
+ * +:deprecated+ ::
+ * deprecation warnings
+ * * assignment of non-nil value to <code>$,</code> and <code>$;</code>
+ * * keyword arguments
+ * etc.
*
- * +:experimental+ :: experimental features
- * * Pattern matching
+ * +:experimental+ ::
+ * experimental features
+ * * Pattern matching
+ *
+ * +:performance+ ::
+ * performance hints
+ * * Shape variation limit
*/
static VALUE
@@ -279,11 +291,11 @@ rb_warning_s_warn(int argc, VALUE *argv, VALUE mod)
*
* Changing the behavior of Warning.warn is useful to customize how warnings are
* handled by Ruby, for instance by filtering some warnings, and/or outputting
- * warnings somewhere other than $stderr.
+ * warnings somewhere other than <tt>$stderr</tt>.
*
* If you want to change the behavior of Warning.warn you should use
- * +Warning.extend(MyNewModuleWithWarnMethod)+ and you can use `super`
- * to get the default behavior of printing the warning to $stderr.
+ * <tt>Warning.extend(MyNewModuleWithWarnMethod)</tt> and you can use +super+
+ * to get the default behavior of printing the warning to <tt>$stderr</tt>.
*
* Example:
* module MyWarningFilter
@@ -300,7 +312,7 @@ rb_warning_s_warn(int argc, VALUE *argv, VALUE mod)
* You should never redefine Warning#warn (the instance method), as that will
* then no longer provide a way to use the default behavior.
*
- * The +warning+ gem provides convenient ways to customize Warning.warn.
+ * The warning[https://rubygems.org/gems/warning] gem provides convenient ways to customize Warning.warn.
*/
static VALUE
@@ -616,18 +628,239 @@ rb_bug_reporter_add(void (*func)(FILE *, void *), void *data)
return 1;
}
+/* returns true if x can not be used as file name */
+static bool
+path_sep_p(char x)
+{
+#if defined __CYGWIN__ || defined DOSISH
+# define PATH_SEP_ENCODING 1
+ // Assume that "/" is only the first byte in any encoding.
+ if (x == ':') return true; // drive letter or ADS
+ if (x == '\\') return true;
+#endif
+ return x == '/';
+}
+
+struct path_string {
+ const char *ptr;
+ size_t len;
+};
+
+static const char PATHSEP_REPLACE = '!';
+
+static char *
+append_pathname(char *p, const char *pe, VALUE str)
+{
+#ifdef PATH_SEP_ENCODING
+ rb_encoding *enc = rb_enc_get(str);
+#endif
+ const char *s = RSTRING_PTR(str);
+ const char *const se = s + RSTRING_LEN(str);
+ char c;
+
+ --pe; // for terminator
+
+ while (p < pe && s < se && (c = *s) != '\0') {
+ if (c == '.') {
+ if (s == se || !*s) break; // chomp "." basename
+ if (path_sep_p(s[1])) goto skipsep; // skip "./"
+ }
+ else if (path_sep_p(c)) {
+ // squeeze successive separators
+ *p++ = PATHSEP_REPLACE;
+ skipsep:
+ while (++s < se && path_sep_p(*s));
+ continue;
+ }
+ const char *const ss = s;
+ while (p < pe && s < se && *s && !path_sep_p(*s)) {
+#ifdef PATH_SEP_ENCODING
+ int n = rb_enc_mbclen(s, se, enc);
+#else
+ const int n = 1;
+#endif
+ p += n;
+ s += n;
+ }
+ if (s > ss) memcpy(p - (s - ss), ss, s - ss);
+ }
+
+ return p;
+}
+
+static char *
+append_basename(char *p, const char *pe, struct path_string *path, VALUE str)
+{
+ if (!path->ptr) {
+#ifdef PATH_SEP_ENCODING
+ rb_encoding *enc = rb_enc_get(str);
+#endif
+ const char *const b = RSTRING_PTR(str), *const e = RSTRING_END(str), *p = e;
+
+ while (p > b) {
+ if (path_sep_p(p[-1])) {
+#ifdef PATH_SEP_ENCODING
+ const char *t = rb_enc_prev_char(b, p, e, enc);
+ if (t == p-1) break;
+ p = t;
+#else
+ break;
+#endif
+ }
+ else {
+ --p;
+ }
+ }
+
+ path->ptr = p;
+ path->len = e - p;
+ }
+ size_t n = path->len;
+ if (p + n > pe) n = pe - p;
+ memcpy(p, path->ptr, n);
+ return p + n;
+}
+
+static void
+finish_report(FILE *out, rb_pid_t pid)
+{
+ if (out != stdout && out != stderr) fclose(out);
+#ifdef HAVE_WORKING_FORK
+ if (pid > 0) waitpid(pid, NULL, 0);
+#endif
+}
+
+struct report_expansion {
+ struct path_string exe, script;
+ rb_pid_t pid;
+ time_t time;
+};
+
+/*
+ * Open a bug report file to write. The `RUBY_CRASH_REPORT`
+ * environment variable can be set to define a template that is used
+ * to name bug report files. The template can contain % specifiers
+ * which are substituted by the following values when a bug report
+ * file is created:
+ *
+ * %% A single % character.
+ * %e The base name of the executable filename.
+ * %E Pathname of executable, with slashes ('/') replaced by
+ * exclamation marks ('!').
+ * %f Similar to %e with the main script filename.
+ * %F Similar to %E with the main script filename.
+ * %p PID of dumped process in decimal.
+ * %t Time of dump, expressed as seconds since the Epoch,
+ * 1970-01-01 00:00:00 +0000 (UTC).
+ * %NNN Octal char code, upto 3 digits.
+ */
+static char *
+expand_report_argument(const char **input_template, struct report_expansion *values,
+ char *buf, size_t size, bool word)
+{
+ char *p = buf;
+ char *end = buf + size;
+ const char *template = *input_template;
+ bool store = true;
+
+ if (p >= end-1 || !*template) return NULL;
+ do {
+ char c = *template++;
+ if (word && ISSPACE(c)) break;
+ if (!store) continue;
+ if (c == '%') {
+ size_t n;
+ switch (c = *template++) {
+ case 'e':
+ p = append_basename(p, end, &values->exe, rb_argv0);
+ continue;
+ case 'E':
+ p = append_pathname(p, end, rb_argv0);
+ continue;
+ case 'f':
+ p = append_basename(p, end, &values->script, GET_VM()->orig_progname);
+ continue;
+ case 'F':
+ p = append_pathname(p, end, GET_VM()->orig_progname);
+ continue;
+ case 'p':
+ if (!values->pid) values->pid = getpid();
+ snprintf(p, end-p, "%" PRI_PIDT_PREFIX "d", values->pid);
+ p += strlen(p);
+ continue;
+ case 't':
+ if (!values->time) values->time = time(NULL);
+ snprintf(p, end-p, "%" PRI_TIMET_PREFIX "d", values->time);
+ p += strlen(p);
+ continue;
+ default:
+ if (c >= '0' && c <= '7') {
+ c = (unsigned char)ruby_scan_oct(template-1, 3, &n);
+ template += n - 1;
+ if (!c) store = false;
+ }
+ break;
+ }
+ }
+ if (p < end-1) *p++ = c;
+ } while (*template);
+ *input_template = template;
+ *p = '\0';
+ return ++p;
+}
+
+FILE *ruby_popen_writer(char *const *argv, rb_pid_t *pid);
+
+static FILE *
+open_report_path(const char *template, char *buf, size_t size, rb_pid_t *pid)
+{
+ struct report_expansion values = {{0}};
+
+ if (!template) return NULL;
+ if (0) fprintf(stderr, "RUBY_CRASH_REPORT=%s\n", buf);
+ if (*template == '|') {
+ char *argv[16], *bufend = buf + size, *p;
+ int argc;
+ template++;
+ for (argc = 0; argc < numberof(argv) - 1; ++argc) {
+ while (*template && ISSPACE(*template)) template++;
+ p = expand_report_argument(&template, &values, buf, bufend-buf, true);
+ if (!p) break;
+ argv[argc] = buf;
+ buf = p;
+ }
+ argv[argc] = NULL;
+ if (!p) return ruby_popen_writer(argv, pid);
+ }
+ else if (*template) {
+ expand_report_argument(&template, &values, buf, size, false);
+ return fopen(buf, "w");
+ }
+ return NULL;
+}
+
+static const char *crash_report;
+
/* SIGSEGV handler might have a very small stack. Thus we need to use it carefully. */
#define REPORT_BUG_BUFSIZ 256
static FILE *
-bug_report_file(const char *file, int line)
+bug_report_file(const char *file, int line, rb_pid_t *pid)
{
char buf[REPORT_BUG_BUFSIZ];
- FILE *out = stderr;
+ const char *report = crash_report;
+ if (!report) report = getenv("RUBY_CRASH_REPORT");
+ FILE *out = open_report_path(report, buf, sizeof(buf), pid);
int len = err_position_0(buf, sizeof(buf), file, line);
- if ((ssize_t)fwrite(buf, 1, len, out) == (ssize_t)len ||
- (ssize_t)fwrite(buf, 1, len, (out = stdout)) == (ssize_t)len) {
- return out;
+ if (out) {
+ if ((ssize_t)fwrite(buf, 1, len, out) == (ssize_t)len) return out;
+ fclose(out);
+ }
+ if ((ssize_t)fwrite(buf, 1, len, stderr) == (ssize_t)len) {
+ return stderr;
+ }
+ if ((ssize_t)fwrite(buf, 1, len, stdout) == (ssize_t)len) {
+ return stdout;
}
return NULL;
@@ -734,7 +967,7 @@ bug_report_begin_valist(FILE *out, const char *fmt, va_list args)
} while (0)
static void
-bug_report_end(FILE *out)
+bug_report_end(FILE *out, rb_pid_t pid)
{
/* call additional bug reporters */
{
@@ -745,26 +978,45 @@ bug_report_end(FILE *out)
}
}
postscript_dump(out);
+ finish_report(out, pid);
}
#define report_bug(file, line, fmt, ctx) do { \
- FILE *out = bug_report_file(file, line); \
+ rb_pid_t pid = -1; \
+ FILE *out = bug_report_file(file, line, &pid); \
if (out) { \
bug_report_begin(out, fmt); \
- rb_vm_bugreport(ctx); \
- bug_report_end(out); \
+ rb_vm_bugreport(ctx, out); \
+ bug_report_end(out, pid); \
} \
} while (0) \
#define report_bug_valist(file, line, fmt, ctx, args) do { \
- FILE *out = bug_report_file(file, line); \
+ rb_pid_t pid = -1; \
+ FILE *out = bug_report_file(file, line, &pid); \
if (out) { \
bug_report_begin_valist(out, fmt, args); \
- rb_vm_bugreport(ctx); \
- bug_report_end(out); \
+ rb_vm_bugreport(ctx, out); \
+ bug_report_end(out, pid); \
} \
} while (0) \
+void
+ruby_set_crash_report(const char *template)
+{
+ crash_report = template;
+#if RUBY_DEBUG
+ rb_pid_t pid = -1;
+ char buf[REPORT_BUG_BUFSIZ];
+ FILE *out = open_report_path(template, buf, sizeof(buf), &pid);
+ if (out) {
+ time_t t = time(NULL);
+ fprintf(out, "ruby_test_bug_report: %s", ctime(&t));
+ finish_report(out, pid);
+ }
+#endif
+}
+
NORETURN(static void die(void));
static void
die(void)
@@ -814,6 +1066,7 @@ rb_bug_for_fatal_signal(ruby_sighandler_t default_sighandler, int sig, const voi
if (default_sighandler) default_sighandler(sig);
+ ruby_default_signal(sig);
die();
}
@@ -867,7 +1120,7 @@ rb_report_bug_valist(VALUE file, int line, const char *fmt, va_list args)
report_bug_valist(RSTRING_PTR(file), line, fmt, NULL, args);
}
-MJIT_FUNC_EXPORTED void
+void
rb_assert_failure(const char *file, int line, const char *name, const char *expr)
{
FILE *out = stderr;
@@ -875,8 +1128,8 @@ rb_assert_failure(const char *file, int line, const char *name, const char *expr
if (name) fprintf(out, "%s:", name);
fprintf(out, "%s\n%s\n\n", expr, rb_dynamic_description);
preface_dump(out);
- rb_vm_bugreport(NULL);
- bug_report_end(out);
+ rb_vm_bugreport(NULL, out);
+ bug_report_end(out, -1);
die();
}
@@ -1070,7 +1323,7 @@ rb_check_typeddata(VALUE obj, const rb_data_type_t *data_type)
actual = rb_str_new_cstr(name); /* or rb_fstring_cstr? not sure... */
}
else {
- return DATA_PTR(obj);
+ return RTYPEDDATA_GET_DATA(obj);
}
const char *expected = data_type->wrap_struct_name;
@@ -1582,7 +1835,7 @@ exc_set_backtrace(VALUE exc, VALUE bt)
return rb_ivar_set(exc, id_bt, rb_check_backtrace(bt));
}
-MJIT_FUNC_EXPORTED VALUE
+VALUE
rb_exc_set_backtrace(VALUE exc, VALUE bt)
{
return exc_set_backtrace(exc, bt);
@@ -1818,7 +2071,9 @@ name_err_init_attr(VALUE exc, VALUE recv, VALUE method)
cfp = rb_vm_get_ruby_level_next_cfp(ec, cfp);
rb_ivar_set(exc, id_name, method);
err_init_recv(exc, recv);
- if (cfp) rb_ivar_set(exc, id_iseq, rb_iseqw_new(cfp->iseq));
+ if (cfp && VM_FRAME_TYPE(cfp) != VM_FRAME_MAGIC_DUMMY) {
+ rb_ivar_set(exc, id_iseq, rb_iseqw_new(cfp->iseq));
+ }
return exc;
}
@@ -1948,50 +2203,50 @@ rb_nomethod_err_new(VALUE mesg, VALUE recv, VALUE method, VALUE args, int priv)
return nometh_err_init_attr(exc, args, priv);
}
-/* :nodoc: */
-enum {
- NAME_ERR_MESG__MESG,
- NAME_ERR_MESG__RECV,
- NAME_ERR_MESG__NAME,
- NAME_ERR_MESG_COUNT
-};
+typedef struct name_error_message_struct {
+ VALUE mesg;
+ VALUE recv;
+ VALUE name;
+} name_error_message_t;
static void
name_err_mesg_mark(void *p)
{
- VALUE *ptr = p;
- rb_gc_mark_locations(ptr, ptr+NAME_ERR_MESG_COUNT);
+ name_error_message_t *ptr = (name_error_message_t *)p;
+ rb_gc_mark_movable(ptr->mesg);
+ rb_gc_mark_movable(ptr->recv);
+ rb_gc_mark_movable(ptr->name);
}
-#define name_err_mesg_free RUBY_TYPED_DEFAULT_FREE
-
-static size_t
-name_err_mesg_memsize(const void *p)
+static void
+name_err_mesg_update(void *p)
{
- return NAME_ERR_MESG_COUNT * sizeof(VALUE);
+ name_error_message_t *ptr = (name_error_message_t *)p;
+ ptr->mesg = rb_gc_location(ptr->mesg);
+ ptr->recv = rb_gc_location(ptr->recv);
+ ptr->name = rb_gc_location(ptr->name);
}
static const rb_data_type_t name_err_mesg_data_type = {
"name_err_mesg",
{
name_err_mesg_mark,
- name_err_mesg_free,
- name_err_mesg_memsize,
+ RUBY_TYPED_DEFAULT_FREE,
+ NULL, // No external memory to report,
+ name_err_mesg_update,
},
- 0, 0, RUBY_TYPED_FREE_IMMEDIATELY
+ 0, 0, RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_WB_PROTECTED | RUBY_TYPED_EMBEDDABLE
};
/* :nodoc: */
static VALUE
-rb_name_err_mesg_init(VALUE klass, VALUE mesg, VALUE recv, VALUE method)
+rb_name_err_mesg_init(VALUE klass, VALUE mesg, VALUE recv, VALUE name)
{
- VALUE result = TypedData_Wrap_Struct(klass, &name_err_mesg_data_type, 0);
- VALUE *ptr = ALLOC_N(VALUE, NAME_ERR_MESG_COUNT);
-
- ptr[NAME_ERR_MESG__MESG] = mesg;
- ptr[NAME_ERR_MESG__RECV] = recv;
- ptr[NAME_ERR_MESG__NAME] = method;
- RTYPEDDATA_DATA(result) = ptr;
+ name_error_message_t *message;
+ VALUE result = TypedData_Make_Struct(klass, name_error_message_t, &name_err_mesg_data_type, message);
+ RB_OBJ_WRITE(result, &message->mesg, mesg);
+ RB_OBJ_WRITE(result, &message->recv, recv);
+ RB_OBJ_WRITE(result, &message->name, name);
return result;
}
@@ -2013,14 +2268,16 @@ name_err_mesg_alloc(VALUE klass)
static VALUE
name_err_mesg_init_copy(VALUE obj1, VALUE obj2)
{
- VALUE *ptr1, *ptr2;
-
if (obj1 == obj2) return obj1;
rb_obj_init_copy(obj1, obj2);
- TypedData_Get_Struct(obj1, VALUE, &name_err_mesg_data_type, ptr1);
- TypedData_Get_Struct(obj2, VALUE, &name_err_mesg_data_type, ptr2);
- MEMCPY(ptr1, ptr2, VALUE, NAME_ERR_MESG_COUNT);
+ name_error_message_t *ptr1, *ptr2;
+ TypedData_Get_Struct(obj1, name_error_message_t, &name_err_mesg_data_type, ptr1);
+ TypedData_Get_Struct(obj2, name_error_message_t, &name_err_mesg_data_type, ptr2);
+
+ RB_OBJ_WRITE(obj1, &ptr1->mesg, ptr2->mesg);
+ RB_OBJ_WRITE(obj1, &ptr1->recv, ptr2->recv);
+ RB_OBJ_WRITE(obj1, &ptr1->name, ptr2->name);
return obj1;
}
@@ -2028,19 +2285,18 @@ name_err_mesg_init_copy(VALUE obj1, VALUE obj2)
static VALUE
name_err_mesg_equal(VALUE obj1, VALUE obj2)
{
- VALUE *ptr1, *ptr2;
- int i;
-
if (obj1 == obj2) return Qtrue;
+
if (rb_obj_class(obj2) != rb_cNameErrorMesg)
return Qfalse;
- TypedData_Get_Struct(obj1, VALUE, &name_err_mesg_data_type, ptr1);
- TypedData_Get_Struct(obj2, VALUE, &name_err_mesg_data_type, ptr2);
- for (i=0; i<NAME_ERR_MESG_COUNT; i++) {
- if (!rb_equal(ptr1[i], ptr2[i]))
- return Qfalse;
- }
+ name_error_message_t *ptr1, *ptr2;
+ TypedData_Get_Struct(obj1, name_error_message_t, &name_err_mesg_data_type, ptr1);
+ TypedData_Get_Struct(obj2, name_error_message_t, &name_err_mesg_data_type, ptr2);
+
+ if (!rb_equal(ptr1->mesg, ptr2->mesg)) return Qfalse;
+ if (!rb_equal(ptr1->recv, ptr2->recv)) return Qfalse;
+ if (!rb_equal(ptr1->name, ptr2->name)) return Qfalse;
return Qtrue;
}
@@ -2059,51 +2315,91 @@ name_err_mesg_receiver_name(VALUE obj)
static VALUE
name_err_mesg_to_str(VALUE obj)
{
- VALUE *ptr, mesg;
- TypedData_Get_Struct(obj, VALUE, &name_err_mesg_data_type, ptr);
+ name_error_message_t *ptr;
+ TypedData_Get_Struct(obj, name_error_message_t, &name_err_mesg_data_type, ptr);
- mesg = ptr[NAME_ERR_MESG__MESG];
+ VALUE mesg = ptr->mesg;
if (NIL_P(mesg)) return Qnil;
else {
- struct RString s_str, d_str;
- VALUE c, s, d = 0, args[4];
- int state = 0, singleton = 0;
+ struct RString s_str, c_str, d_str;
+ VALUE c, s, d = 0, args[4], c2;
+ int state = 0;
rb_encoding *usascii = rb_usascii_encoding();
#define FAKE_CSTR(v, str) rb_setup_fake_str((v), (str), rb_strlen_lit(str), usascii)
- obj = ptr[NAME_ERR_MESG__RECV];
+ c = s = FAKE_CSTR(&s_str, "");
+ obj = ptr->recv;
switch (obj) {
case Qnil:
- d = FAKE_CSTR(&d_str, "nil");
+ c = d = FAKE_CSTR(&d_str, "nil");
break;
case Qtrue:
- d = FAKE_CSTR(&d_str, "true");
+ c = d = FAKE_CSTR(&d_str, "true");
break;
case Qfalse:
- d = FAKE_CSTR(&d_str, "false");
+ c = d = FAKE_CSTR(&d_str, "false");
break;
default:
- d = rb_protect(name_err_mesg_receiver_name, obj, &state);
- if (state || NIL_OR_UNDEF_P(d))
- d = rb_protect(rb_inspect, obj, &state);
+ if (strstr(RSTRING_PTR(mesg), "%2$s")) {
+ d = rb_protect(name_err_mesg_receiver_name, obj, &state);
+ if (state || NIL_OR_UNDEF_P(d))
+ d = rb_protect(rb_inspect, obj, &state);
+ if (state) {
+ rb_set_errinfo(Qnil);
+ }
+ d = rb_check_string_type(d);
+ if (NIL_P(d)) {
+ d = rb_any_to_s(obj);
+ }
+ }
+
+ if (!RB_SPECIAL_CONST_P(obj)) {
+ switch (RB_BUILTIN_TYPE(obj)) {
+ case T_MODULE:
+ s = FAKE_CSTR(&s_str, "module ");
+ c = obj;
+ break;
+ case T_CLASS:
+ s = FAKE_CSTR(&s_str, "class ");
+ c = obj;
+ break;
+ default:
+ goto object;
+ }
+ }
+ else {
+ VALUE klass;
+ object:
+ klass = CLASS_OF(obj);
+ if (RB_TYPE_P(klass, T_CLASS) && FL_TEST(klass, FL_SINGLETON)) {
+ s = FAKE_CSTR(&s_str, "");
+ if (obj == rb_vm_top_self()) {
+ c = FAKE_CSTR(&c_str, "main");
+ }
+ else {
+ c = rb_any_to_s(obj);
+ }
+ break;
+ }
+ else {
+ s = FAKE_CSTR(&s_str, "an instance of ");
+ c = rb_class_real(klass);
+ }
+ }
+ c2 = rb_protect(name_err_mesg_receiver_name, c, &state);
+ if (state || NIL_OR_UNDEF_P(c2))
+ c2 = rb_protect(rb_inspect, c, &state);
if (state) {
rb_set_errinfo(Qnil);
}
- d = rb_check_string_type(d);
- if (NIL_P(d)) {
- d = rb_any_to_s(obj);
+ c2 = rb_check_string_type(c2);
+ if (NIL_P(c2)) {
+ c2 = rb_any_to_s(c);
}
- singleton = (RSTRING_LEN(d) > 0 && RSTRING_PTR(d)[0] == '#');
+ c = c2;
break;
}
- if (!singleton) {
- s = FAKE_CSTR(&s_str, ":");
- c = rb_class_name(CLASS_OF(obj));
- }
- else {
- c = s = FAKE_CSTR(&s_str, "");
- }
- args[0] = rb_obj_as_string(ptr[NAME_ERR_MESG__NAME]);
+ args[0] = rb_obj_as_string(ptr->name);
args[1] = d;
args[2] = s;
args[3] = c;
@@ -2136,17 +2432,17 @@ name_err_mesg_load(VALUE klass, VALUE str)
static VALUE
name_err_receiver(VALUE self)
{
- VALUE *ptr, recv, mesg;
-
- recv = rb_ivar_lookup(self, id_recv, Qundef);
+ VALUE recv = rb_ivar_lookup(self, id_recv, Qundef);
if (!UNDEF_P(recv)) return recv;
- mesg = rb_attr_get(self, id_mesg);
+ VALUE mesg = rb_attr_get(self, id_mesg);
if (!rb_typeddata_is_kind_of(mesg, &name_err_mesg_data_type)) {
rb_raise(rb_eArgError, "no receiver is available");
}
- ptr = DATA_PTR(mesg);
- return ptr[NAME_ERR_MESG__RECV];
+
+ name_error_message_t *ptr;
+ TypedData_Get_Struct(mesg, name_error_message_t, &name_err_mesg_data_type, ptr);
+ return ptr->recv;
}
/*
@@ -2398,6 +2694,14 @@ syntax_error_with_path(VALUE exc, VALUE path, VALUE *mesg, rb_encoding *enc)
static st_table *syserr_tbl;
+void
+rb_free_warning(void)
+{
+ st_free_table(warning_categories.id2enum);
+ st_free_table(warning_categories.enum2id);
+ st_free_table(syserr_tbl);
+}
+
static VALUE
set_syserr(int n, const char *name)
{
@@ -2757,7 +3061,7 @@ syserr_eqq(VALUE self, VALUE exc)
*
* <em>raises the exception:</em>
*
- * NoMethodError: undefined method `to_ary' for "hello":String
+ * NoMethodError: undefined method `to_ary' for an instance of String
*/
/*
@@ -2953,9 +3257,9 @@ exception_dumper(VALUE exc)
}
static int
-ivar_copy_i(st_data_t key, st_data_t val, st_data_t exc)
+ivar_copy_i(ID key, VALUE val, st_data_t exc)
{
- rb_ivar_set((VALUE) exc, (ID) key, (VALUE) val);
+ rb_ivar_set((VALUE)exc, key, val);
return ST_CONTINUE;
}
@@ -3107,6 +3411,7 @@ Init_Exception(void)
id_category = rb_intern_const("category");
id_deprecated = rb_intern_const("deprecated");
id_experimental = rb_intern_const("experimental");
+ id_performance = rb_intern_const("performance");
id_top = rb_intern_const("top");
id_bottom = rb_intern_const("bottom");
id_iseq = rb_make_internal_id();
@@ -3118,11 +3423,13 @@ Init_Exception(void)
warning_categories.id2enum = rb_init_identtable();
st_add_direct(warning_categories.id2enum, id_deprecated, RB_WARN_CATEGORY_DEPRECATED);
st_add_direct(warning_categories.id2enum, id_experimental, RB_WARN_CATEGORY_EXPERIMENTAL);
+ st_add_direct(warning_categories.id2enum, id_performance, RB_WARN_CATEGORY_PERFORMANCE);
warning_categories.enum2id = rb_init_identtable();
st_add_direct(warning_categories.enum2id, RB_WARN_CATEGORY_NONE, 0);
st_add_direct(warning_categories.enum2id, RB_WARN_CATEGORY_DEPRECATED, id_deprecated);
st_add_direct(warning_categories.enum2id, RB_WARN_CATEGORY_EXPERIMENTAL, id_experimental);
+ st_add_direct(warning_categories.enum2id, RB_WARN_CATEGORY_PERFORMANCE, id_performance);
}
void
@@ -3205,7 +3512,7 @@ rb_fatal(const char *fmt, ...)
/* The thread has no GVL. Object allocation impossible (cant run GC),
* thus no message can be printed out. */
fprintf(stderr, "[FATAL] rb_fatal() outside of GVL\n");
- rb_print_backtrace();
+ rb_print_backtrace(stderr);
die();
}
@@ -3268,12 +3575,14 @@ rb_syserr_fail_str(int e, VALUE mesg)
rb_exc_raise(rb_syserr_new_str(e, mesg));
}
+#undef rb_sys_fail
void
rb_sys_fail(const char *mesg)
{
rb_exc_raise(make_errno_exc(mesg));
}
+#undef rb_sys_fail_str
void
rb_sys_fail_str(VALUE mesg)
{
diff --git a/eval.c b/eval.c
index ff17ad343c..15b6567aff 100644
--- a/eval.c
+++ b/eval.c
@@ -18,12 +18,12 @@
#endif
#include "eval_intern.h"
-#include "gc.h"
#include "internal.h"
#include "internal/class.h"
#include "internal/cont.h"
#include "internal/error.h"
#include "internal/eval.h"
+#include "internal/gc.h"
#include "internal/hash.h"
#include "internal/inits.h"
#include "internal/io.h"
@@ -32,7 +32,7 @@
#include "internal/variable.h"
#include "ruby/fiber/scheduler.h"
#include "iseq.h"
-#include "mjit.h"
+#include "rjit.h"
#include "probes.h"
#include "probes_helper.h"
#include "ruby/vm.h"
@@ -257,8 +257,6 @@ rb_ec_cleanup(rb_execution_context_t *ec, enum ruby_tag_type ex)
}
}
- mjit_finish(true); // We still need ISeqs here, so it's before rb_ec_finalize().
-
rb_ec_finalize(ec);
/* unlock again if finalizer took mutexes. */
@@ -441,7 +439,7 @@ rb_class_modify_check(VALUE klass)
if (FL_TEST(klass, FL_SINGLETON)) {
desc = "object";
- klass = rb_ivar_get(klass, id__attached__);
+ klass = RCLASS_ATTACHED_OBJECT(klass);
if (!SPECIAL_CONST_P(klass)) {
switch (BUILTIN_TYPE(klass)) {
case T_MODULE:
@@ -647,6 +645,10 @@ rb_ec_setup_exception(const rb_execution_context_t *ec, VALUE mesg, VALUE cause)
cause = get_ec_errinfo(ec);
}
if (cause != mesg) {
+ if (THROW_DATA_P(cause)) {
+ cause = Qnil;
+ }
+
rb_ivar_set(mesg, id_cause, cause);
}
}
@@ -1339,14 +1341,21 @@ rb_using_module(const rb_cref_t *cref, VALUE module)
{
Check_Type(module, T_MODULE);
using_module_recursive(cref, module);
- rb_clear_method_cache_all();
+ rb_clear_all_refinement_method_cache();
}
/*
* call-seq:
- * refined_class -> class
+ * target -> class_or_module
*
- * Return the class refined by the receiver.
+ * Return the class or module refined by the receiver.
+ *
+ * module M
+ * refine String do
+ * end
+ * end
+ *
+ * M.refinements[0].target # => String
*/
VALUE
rb_refinement_module_get_refined_class(VALUE module)
@@ -1357,6 +1366,21 @@ rb_refinement_module_get_refined_class(VALUE module)
return rb_attr_get(module, id_refined_class);
}
+/*
+ * call-seq:
+ * refined_class -> class
+ *
+ * Deprecated; prefer #target.
+ *
+ * Return the class refined by the receiver.
+ */
+static VALUE
+rb_refinement_refined_class(VALUE module)
+{
+ rb_warn_deprecated_to_remove("3.4", "Refinement#refined_class", "Refinement#target");
+ return rb_refinement_module_get_refined_class(module);
+}
+
static void
add_activated_refinement(VALUE activated_refinements,
VALUE klass, VALUE refinement)
@@ -2065,7 +2089,8 @@ Init_eval(void)
rb_mod_s_used_refinements, 0);
rb_undef_method(rb_cClass, "refine");
rb_define_private_method(rb_cRefinement, "import_methods", refinement_import_methods, -1);
- rb_define_method(rb_cRefinement, "refined_class", rb_refinement_module_get_refined_class, 0);
+ rb_define_method(rb_cRefinement, "target", rb_refinement_module_get_refined_class, 0);
+ rb_define_method(rb_cRefinement, "refined_class", rb_refinement_refined_class, 0);
rb_undef_method(rb_cRefinement, "append_features");
rb_undef_method(rb_cRefinement, "prepend_features");
rb_undef_method(rb_cRefinement, "extend_object");
@@ -2094,3 +2119,21 @@ Init_eval(void)
id_signo = rb_intern_const("signo");
id_status = rb_intern_const("status");
}
+
+int
+rb_errno(void)
+{
+ return *rb_orig_errno_ptr();
+}
+
+void
+rb_errno_set(int e)
+{
+ *rb_orig_errno_ptr() = e;
+}
+
+int *
+rb_errno_ptr(void)
+{
+ return rb_orig_errno_ptr();
+}
diff --git a/eval_error.c b/eval_error.c
index 948a205dd9..bdce295f6e 100644
--- a/eval_error.c
+++ b/eval_error.c
@@ -7,6 +7,8 @@
(NIL_P(str) ? warn_print(x) : (void)rb_str_cat_cstr(str, x))
#define write_warn2(str, x, l) \
(NIL_P(str) ? warn_print2(x, l) : (void)rb_str_cat(str, x, l))
+#define write_warn_enc(str, x, l, enc) \
+ (NIL_P(str) ? warn_print2(x, l) : (void)rb_enc_str_buf_cat(str, x, l, enc))
#ifdef HAVE_BUILTIN___BUILTIN_CONSTANT_P
#define warn_print(x) RB_GNUC_EXTENSION_BLOCK( \
(__builtin_constant_p(x)) ? \
@@ -103,7 +105,7 @@ print_errinfo(const VALUE eclass, const VALUE errat, const VALUE emesg, const VA
if (highlight) write_warn(str, underline);
write_warn(str, "unhandled exception");
if (highlight) write_warn(str, reset);
- write_warn2(str, "\n", 1);
+ write_warn(str, "\n");
}
else {
VALUE epath;
@@ -127,13 +129,17 @@ rb_decorate_message(const VALUE eclass, const VALUE emesg, int highlight)
{
const char *einfo = "";
long elen = 0;
+ rb_encoding *eenc;
- VALUE str = rb_str_new2("");
+ VALUE str = rb_usascii_str_new_cstr("");
- if (!NIL_P(emesg)) {
+ if (!NIL_P(emesg) && rb_enc_asciicompat(eenc = rb_enc_get(emesg))) {
einfo = RSTRING_PTR(emesg);
elen = RSTRING_LEN(emesg);
}
+ else {
+ eenc = NULL;
+ }
if (eclass == rb_eRuntimeError && elen == 0) {
if (highlight) write_warn(str, underline);
write_warn(str, "unhandled exception");
@@ -156,7 +162,7 @@ rb_decorate_message(const VALUE eclass, const VALUE emesg, int highlight)
if (RSTRING_PTR(epath)[0] == '#')
epath = 0;
if ((tail = memchr(einfo, '\n', elen)) != 0) {
- write_warn2(str, einfo, tail - einfo);
+ write_warn_enc(str, einfo, tail - einfo, eenc);
tail++; /* skip newline */
}
else {
@@ -170,23 +176,23 @@ rb_decorate_message(const VALUE eclass, const VALUE emesg, int highlight)
write_warn(str, reset);
write_warn(str, bold);
}
- write_warn2(str, ")", 1);
+ write_warn(str, ")");
if (highlight) write_warn(str, reset);
}
if (tail && einfo+elen > tail) {
if (!highlight) {
- write_warn2(str, "\n", 1);
- write_warn2(str, tail, einfo+elen-tail);
+ write_warn(str, "\n");
+ write_warn_enc(str, tail, einfo+elen-tail, eenc);
}
else {
elen -= tail - einfo;
einfo = tail;
- write_warn2(str, "\n", 1);
+ write_warn(str, "\n");
while (elen > 0) {
tail = memchr(einfo, '\n', elen);
if (!tail || tail > einfo) {
write_warn(str, bold);
- write_warn2(str, einfo, tail ? tail-einfo : elen);
+ write_warn_enc(str, einfo, tail ? tail-einfo : elen, eenc);
write_warn(str, reset);
if (!tail) {
break;
@@ -195,7 +201,7 @@ rb_decorate_message(const VALUE eclass, const VALUE emesg, int highlight)
elen -= tail - einfo;
einfo = tail;
do ++tail; while (tail < einfo+elen && *tail == '\n');
- write_warn2(str, einfo, tail-einfo);
+ write_warn_enc(str, einfo, tail-einfo, eenc);
elen -= tail - einfo;
einfo = tail;
}
@@ -455,7 +461,12 @@ exiting_split(VALUE errinfo, volatile int *exitcode, volatile int *sigstatus)
if (NIL_P(errinfo)) return 0;
- if (rb_obj_is_kind_of(errinfo, rb_eSystemExit)) {
+ if (THROW_DATA_P(errinfo)) {
+ int throw_state = ((const struct vm_throw_data *)errinfo)->throw_state;
+ ex = throw_state & VM_THROW_STATE_MASK;
+ result |= EXITING_WITH_STATUS;
+ }
+ else if (rb_obj_is_kind_of(errinfo, rb_eSystemExit)) {
ex = sysexit_status(errinfo);
result |= EXITING_WITH_STATUS;
}
diff --git a/eval_intern.h b/eval_intern.h
index 6cbaa51361..d008b17ca1 100644
--- a/eval_intern.h
+++ b/eval_intern.h
@@ -110,9 +110,11 @@ extern int select_large_fdset(int, fd_set *, fd_set *, fd_set *, struct timeval
_tag.tag = Qundef; \
_tag.prev = _ec->tag; \
_tag.lock_rec = rb_ec_vm_lock_rec(_ec); \
+ rb_vm_tag_jmpbuf_init(&_tag.buf); \
#define EC_POP_TAG() \
_ec->tag = _tag.prev; \
+ rb_vm_tag_jmpbuf_deinit(&_tag.buf); \
} while (0)
#define EC_TMPPOP_TAG() \
@@ -151,6 +153,7 @@ rb_ec_tag_state(const rb_execution_context_t *ec)
enum ruby_tag_type state = tag->state;
tag->state = TAG_NONE;
rb_ec_vm_lock_rec_check(ec, tag->lock_rec);
+ RBIMPL_ASSUME(state != TAG_NONE);
return state;
}
@@ -158,8 +161,9 @@ NORETURN(static inline void rb_ec_tag_jump(const rb_execution_context_t *ec, enu
static inline void
rb_ec_tag_jump(const rb_execution_context_t *ec, enum ruby_tag_type st)
{
+ RUBY_ASSERT(st != TAG_NONE);
ec->tag->state = st;
- ruby_longjmp(ec->tag->buf, 1);
+ ruby_longjmp(RB_VM_TAG_JMPBUF_GET(ec->tag->buf), 1);
}
/*
@@ -167,7 +171,7 @@ rb_ec_tag_jump(const rb_execution_context_t *ec, enum ruby_tag_type st)
[ISO/IEC 9899:1999] 7.13.1.1
*/
#define EC_EXEC_TAG() \
- (ruby_setjmp(_tag.buf) ? rb_ec_tag_state(VAR_FROM_MEMORY(_ec)) : (EC_REPUSH_TAG(), 0))
+ (UNLIKELY(ruby_setjmp(RB_VM_TAG_JMPBUF_GET(_tag.buf))) ? rb_ec_tag_state(VAR_FROM_MEMORY(_ec)) : (EC_REPUSH_TAG(), 0))
#define EC_JUMP_TAG(ec, st) rb_ec_tag_jump(ec, st)
diff --git a/ext/-test-/RUBY_ALIGNOF/depend b/ext/-test-/RUBY_ALIGNOF/depend
index 21ef8c6dd0..3011b637e5 100644
--- a/ext/-test-/RUBY_ALIGNOF/depend
+++ b/ext/-test-/RUBY_ALIGNOF/depend
@@ -52,6 +52,7 @@ c.o: $(hdrdir)/ruby/internal/attr/noexcept.h
c.o: $(hdrdir)/ruby/internal/attr/noinline.h
c.o: $(hdrdir)/ruby/internal/attr/nonnull.h
c.o: $(hdrdir)/ruby/internal/attr/noreturn.h
+c.o: $(hdrdir)/ruby/internal/attr/packed_struct.h
c.o: $(hdrdir)/ruby/internal/attr/pure.h
c.o: $(hdrdir)/ruby/internal/attr/restrict.h
c.o: $(hdrdir)/ruby/internal/attr/returns_nonnull.h
@@ -111,7 +112,6 @@ c.o: $(hdrdir)/ruby/internal/intern/enumerator.h
c.o: $(hdrdir)/ruby/internal/intern/error.h
c.o: $(hdrdir)/ruby/internal/intern/eval.h
c.o: $(hdrdir)/ruby/internal/intern/file.h
-c.o: $(hdrdir)/ruby/internal/intern/gc.h
c.o: $(hdrdir)/ruby/internal/intern/hash.h
c.o: $(hdrdir)/ruby/internal/intern/io.h
c.o: $(hdrdir)/ruby/internal/intern/load.h
@@ -142,7 +142,6 @@ c.o: $(hdrdir)/ruby/internal/memory.h
c.o: $(hdrdir)/ruby/internal/method.h
c.o: $(hdrdir)/ruby/internal/module.h
c.o: $(hdrdir)/ruby/internal/newobj.h
-c.o: $(hdrdir)/ruby/internal/rgengc.h
c.o: $(hdrdir)/ruby/internal/scan_args.h
c.o: $(hdrdir)/ruby/internal/special_consts.h
c.o: $(hdrdir)/ruby/internal/static_assert.h
diff --git a/ext/-test-/arith_seq/beg_len_step/depend b/ext/-test-/arith_seq/beg_len_step/depend
index 36a2c4c71b..dc807eaa99 100644
--- a/ext/-test-/arith_seq/beg_len_step/depend
+++ b/ext/-test-/arith_seq/beg_len_step/depend
@@ -51,6 +51,7 @@ beg_len_step.o: $(hdrdir)/ruby/internal/attr/noexcept.h
beg_len_step.o: $(hdrdir)/ruby/internal/attr/noinline.h
beg_len_step.o: $(hdrdir)/ruby/internal/attr/nonnull.h
beg_len_step.o: $(hdrdir)/ruby/internal/attr/noreturn.h
+beg_len_step.o: $(hdrdir)/ruby/internal/attr/packed_struct.h
beg_len_step.o: $(hdrdir)/ruby/internal/attr/pure.h
beg_len_step.o: $(hdrdir)/ruby/internal/attr/restrict.h
beg_len_step.o: $(hdrdir)/ruby/internal/attr/returns_nonnull.h
@@ -110,7 +111,6 @@ beg_len_step.o: $(hdrdir)/ruby/internal/intern/enumerator.h
beg_len_step.o: $(hdrdir)/ruby/internal/intern/error.h
beg_len_step.o: $(hdrdir)/ruby/internal/intern/eval.h
beg_len_step.o: $(hdrdir)/ruby/internal/intern/file.h
-beg_len_step.o: $(hdrdir)/ruby/internal/intern/gc.h
beg_len_step.o: $(hdrdir)/ruby/internal/intern/hash.h
beg_len_step.o: $(hdrdir)/ruby/internal/intern/io.h
beg_len_step.o: $(hdrdir)/ruby/internal/intern/load.h
@@ -141,7 +141,6 @@ beg_len_step.o: $(hdrdir)/ruby/internal/memory.h
beg_len_step.o: $(hdrdir)/ruby/internal/method.h
beg_len_step.o: $(hdrdir)/ruby/internal/module.h
beg_len_step.o: $(hdrdir)/ruby/internal/newobj.h
-beg_len_step.o: $(hdrdir)/ruby/internal/rgengc.h
beg_len_step.o: $(hdrdir)/ruby/internal/scan_args.h
beg_len_step.o: $(hdrdir)/ruby/internal/special_consts.h
beg_len_step.o: $(hdrdir)/ruby/internal/static_assert.h
diff --git a/ext/-test-/arith_seq/extract/depend b/ext/-test-/arith_seq/extract/depend
index 57cbaa9a0c..231736b277 100644
--- a/ext/-test-/arith_seq/extract/depend
+++ b/ext/-test-/arith_seq/extract/depend
@@ -51,6 +51,7 @@ extract.o: $(hdrdir)/ruby/internal/attr/noexcept.h
extract.o: $(hdrdir)/ruby/internal/attr/noinline.h
extract.o: $(hdrdir)/ruby/internal/attr/nonnull.h
extract.o: $(hdrdir)/ruby/internal/attr/noreturn.h
+extract.o: $(hdrdir)/ruby/internal/attr/packed_struct.h
extract.o: $(hdrdir)/ruby/internal/attr/pure.h
extract.o: $(hdrdir)/ruby/internal/attr/restrict.h
extract.o: $(hdrdir)/ruby/internal/attr/returns_nonnull.h
@@ -110,7 +111,6 @@ extract.o: $(hdrdir)/ruby/internal/intern/enumerator.h
extract.o: $(hdrdir)/ruby/internal/intern/error.h
extract.o: $(hdrdir)/ruby/internal/intern/eval.h
extract.o: $(hdrdir)/ruby/internal/intern/file.h
-extract.o: $(hdrdir)/ruby/internal/intern/gc.h
extract.o: $(hdrdir)/ruby/internal/intern/hash.h
extract.o: $(hdrdir)/ruby/internal/intern/io.h
extract.o: $(hdrdir)/ruby/internal/intern/load.h
@@ -141,7 +141,6 @@ extract.o: $(hdrdir)/ruby/internal/memory.h
extract.o: $(hdrdir)/ruby/internal/method.h
extract.o: $(hdrdir)/ruby/internal/module.h
extract.o: $(hdrdir)/ruby/internal/newobj.h
-extract.o: $(hdrdir)/ruby/internal/rgengc.h
extract.o: $(hdrdir)/ruby/internal/scan_args.h
extract.o: $(hdrdir)/ruby/internal/special_consts.h
extract.o: $(hdrdir)/ruby/internal/static_assert.h
diff --git a/ext/-test-/array/concat/depend b/ext/-test-/array/concat/depend
index 79c833738e..d66e7a540f 100644
--- a/ext/-test-/array/concat/depend
+++ b/ext/-test-/array/concat/depend
@@ -52,6 +52,7 @@ to_ary_concat.o: $(hdrdir)/ruby/internal/attr/noexcept.h
to_ary_concat.o: $(hdrdir)/ruby/internal/attr/noinline.h
to_ary_concat.o: $(hdrdir)/ruby/internal/attr/nonnull.h
to_ary_concat.o: $(hdrdir)/ruby/internal/attr/noreturn.h
+to_ary_concat.o: $(hdrdir)/ruby/internal/attr/packed_struct.h
to_ary_concat.o: $(hdrdir)/ruby/internal/attr/pure.h
to_ary_concat.o: $(hdrdir)/ruby/internal/attr/restrict.h
to_ary_concat.o: $(hdrdir)/ruby/internal/attr/returns_nonnull.h
@@ -111,7 +112,6 @@ to_ary_concat.o: $(hdrdir)/ruby/internal/intern/enumerator.h
to_ary_concat.o: $(hdrdir)/ruby/internal/intern/error.h
to_ary_concat.o: $(hdrdir)/ruby/internal/intern/eval.h
to_ary_concat.o: $(hdrdir)/ruby/internal/intern/file.h
-to_ary_concat.o: $(hdrdir)/ruby/internal/intern/gc.h
to_ary_concat.o: $(hdrdir)/ruby/internal/intern/hash.h
to_ary_concat.o: $(hdrdir)/ruby/internal/intern/io.h
to_ary_concat.o: $(hdrdir)/ruby/internal/intern/load.h
@@ -142,7 +142,6 @@ to_ary_concat.o: $(hdrdir)/ruby/internal/memory.h
to_ary_concat.o: $(hdrdir)/ruby/internal/method.h
to_ary_concat.o: $(hdrdir)/ruby/internal/module.h
to_ary_concat.o: $(hdrdir)/ruby/internal/newobj.h
-to_ary_concat.o: $(hdrdir)/ruby/internal/rgengc.h
to_ary_concat.o: $(hdrdir)/ruby/internal/scan_args.h
to_ary_concat.o: $(hdrdir)/ruby/internal/special_consts.h
to_ary_concat.o: $(hdrdir)/ruby/internal/static_assert.h
diff --git a/ext/-test-/array/resize/depend b/ext/-test-/array/resize/depend
index 49e0f346d3..a9c02b3db2 100644
--- a/ext/-test-/array/resize/depend
+++ b/ext/-test-/array/resize/depend
@@ -51,6 +51,7 @@ resize.o: $(hdrdir)/ruby/internal/attr/noexcept.h
resize.o: $(hdrdir)/ruby/internal/attr/noinline.h
resize.o: $(hdrdir)/ruby/internal/attr/nonnull.h
resize.o: $(hdrdir)/ruby/internal/attr/noreturn.h
+resize.o: $(hdrdir)/ruby/internal/attr/packed_struct.h
resize.o: $(hdrdir)/ruby/internal/attr/pure.h
resize.o: $(hdrdir)/ruby/internal/attr/restrict.h
resize.o: $(hdrdir)/ruby/internal/attr/returns_nonnull.h
@@ -110,7 +111,6 @@ resize.o: $(hdrdir)/ruby/internal/intern/enumerator.h
resize.o: $(hdrdir)/ruby/internal/intern/error.h
resize.o: $(hdrdir)/ruby/internal/intern/eval.h
resize.o: $(hdrdir)/ruby/internal/intern/file.h
-resize.o: $(hdrdir)/ruby/internal/intern/gc.h
resize.o: $(hdrdir)/ruby/internal/intern/hash.h
resize.o: $(hdrdir)/ruby/internal/intern/io.h
resize.o: $(hdrdir)/ruby/internal/intern/load.h
@@ -141,7 +141,6 @@ resize.o: $(hdrdir)/ruby/internal/memory.h
resize.o: $(hdrdir)/ruby/internal/method.h
resize.o: $(hdrdir)/ruby/internal/module.h
resize.o: $(hdrdir)/ruby/internal/newobj.h
-resize.o: $(hdrdir)/ruby/internal/rgengc.h
resize.o: $(hdrdir)/ruby/internal/scan_args.h
resize.o: $(hdrdir)/ruby/internal/special_consts.h
resize.o: $(hdrdir)/ruby/internal/static_assert.h
diff --git a/ext/-test-/bignum/depend b/ext/-test-/bignum/depend
index d4072fb35c..d4392bb6a1 100644
--- a/ext/-test-/bignum/depend
+++ b/ext/-test-/bignum/depend
@@ -51,6 +51,7 @@ big2str.o: $(hdrdir)/ruby/internal/attr/noexcept.h
big2str.o: $(hdrdir)/ruby/internal/attr/noinline.h
big2str.o: $(hdrdir)/ruby/internal/attr/nonnull.h
big2str.o: $(hdrdir)/ruby/internal/attr/noreturn.h
+big2str.o: $(hdrdir)/ruby/internal/attr/packed_struct.h
big2str.o: $(hdrdir)/ruby/internal/attr/pure.h
big2str.o: $(hdrdir)/ruby/internal/attr/restrict.h
big2str.o: $(hdrdir)/ruby/internal/attr/returns_nonnull.h
@@ -110,7 +111,6 @@ big2str.o: $(hdrdir)/ruby/internal/intern/enumerator.h
big2str.o: $(hdrdir)/ruby/internal/intern/error.h
big2str.o: $(hdrdir)/ruby/internal/intern/eval.h
big2str.o: $(hdrdir)/ruby/internal/intern/file.h
-big2str.o: $(hdrdir)/ruby/internal/intern/gc.h
big2str.o: $(hdrdir)/ruby/internal/intern/hash.h
big2str.o: $(hdrdir)/ruby/internal/intern/io.h
big2str.o: $(hdrdir)/ruby/internal/intern/load.h
@@ -141,7 +141,6 @@ big2str.o: $(hdrdir)/ruby/internal/memory.h
big2str.o: $(hdrdir)/ruby/internal/method.h
big2str.o: $(hdrdir)/ruby/internal/module.h
big2str.o: $(hdrdir)/ruby/internal/newobj.h
-big2str.o: $(hdrdir)/ruby/internal/rgengc.h
big2str.o: $(hdrdir)/ruby/internal/scan_args.h
big2str.o: $(hdrdir)/ruby/internal/special_consts.h
big2str.o: $(hdrdir)/ruby/internal/static_assert.h
@@ -211,6 +210,7 @@ bigzero.o: $(hdrdir)/ruby/internal/attr/noexcept.h
bigzero.o: $(hdrdir)/ruby/internal/attr/noinline.h
bigzero.o: $(hdrdir)/ruby/internal/attr/nonnull.h
bigzero.o: $(hdrdir)/ruby/internal/attr/noreturn.h
+bigzero.o: $(hdrdir)/ruby/internal/attr/packed_struct.h
bigzero.o: $(hdrdir)/ruby/internal/attr/pure.h
bigzero.o: $(hdrdir)/ruby/internal/attr/restrict.h
bigzero.o: $(hdrdir)/ruby/internal/attr/returns_nonnull.h
@@ -270,7 +270,6 @@ bigzero.o: $(hdrdir)/ruby/internal/intern/enumerator.h
bigzero.o: $(hdrdir)/ruby/internal/intern/error.h
bigzero.o: $(hdrdir)/ruby/internal/intern/eval.h
bigzero.o: $(hdrdir)/ruby/internal/intern/file.h
-bigzero.o: $(hdrdir)/ruby/internal/intern/gc.h
bigzero.o: $(hdrdir)/ruby/internal/intern/hash.h
bigzero.o: $(hdrdir)/ruby/internal/intern/io.h
bigzero.o: $(hdrdir)/ruby/internal/intern/load.h
@@ -301,7 +300,6 @@ bigzero.o: $(hdrdir)/ruby/internal/memory.h
bigzero.o: $(hdrdir)/ruby/internal/method.h
bigzero.o: $(hdrdir)/ruby/internal/module.h
bigzero.o: $(hdrdir)/ruby/internal/newobj.h
-bigzero.o: $(hdrdir)/ruby/internal/rgengc.h
bigzero.o: $(hdrdir)/ruby/internal/scan_args.h
bigzero.o: $(hdrdir)/ruby/internal/special_consts.h
bigzero.o: $(hdrdir)/ruby/internal/static_assert.h
@@ -371,6 +369,7 @@ div.o: $(hdrdir)/ruby/internal/attr/noexcept.h
div.o: $(hdrdir)/ruby/internal/attr/noinline.h
div.o: $(hdrdir)/ruby/internal/attr/nonnull.h
div.o: $(hdrdir)/ruby/internal/attr/noreturn.h
+div.o: $(hdrdir)/ruby/internal/attr/packed_struct.h
div.o: $(hdrdir)/ruby/internal/attr/pure.h
div.o: $(hdrdir)/ruby/internal/attr/restrict.h
div.o: $(hdrdir)/ruby/internal/attr/returns_nonnull.h
@@ -430,7 +429,6 @@ div.o: $(hdrdir)/ruby/internal/intern/enumerator.h
div.o: $(hdrdir)/ruby/internal/intern/error.h
div.o: $(hdrdir)/ruby/internal/intern/eval.h
div.o: $(hdrdir)/ruby/internal/intern/file.h
-div.o: $(hdrdir)/ruby/internal/intern/gc.h
div.o: $(hdrdir)/ruby/internal/intern/hash.h
div.o: $(hdrdir)/ruby/internal/intern/io.h
div.o: $(hdrdir)/ruby/internal/intern/load.h
@@ -461,7 +459,6 @@ div.o: $(hdrdir)/ruby/internal/memory.h
div.o: $(hdrdir)/ruby/internal/method.h
div.o: $(hdrdir)/ruby/internal/module.h
div.o: $(hdrdir)/ruby/internal/newobj.h
-div.o: $(hdrdir)/ruby/internal/rgengc.h
div.o: $(hdrdir)/ruby/internal/scan_args.h
div.o: $(hdrdir)/ruby/internal/special_consts.h
div.o: $(hdrdir)/ruby/internal/static_assert.h
@@ -532,6 +529,7 @@ init.o: $(hdrdir)/ruby/internal/attr/noexcept.h
init.o: $(hdrdir)/ruby/internal/attr/noinline.h
init.o: $(hdrdir)/ruby/internal/attr/nonnull.h
init.o: $(hdrdir)/ruby/internal/attr/noreturn.h
+init.o: $(hdrdir)/ruby/internal/attr/packed_struct.h
init.o: $(hdrdir)/ruby/internal/attr/pure.h
init.o: $(hdrdir)/ruby/internal/attr/restrict.h
init.o: $(hdrdir)/ruby/internal/attr/returns_nonnull.h
@@ -591,7 +589,6 @@ init.o: $(hdrdir)/ruby/internal/intern/enumerator.h
init.o: $(hdrdir)/ruby/internal/intern/error.h
init.o: $(hdrdir)/ruby/internal/intern/eval.h
init.o: $(hdrdir)/ruby/internal/intern/file.h
-init.o: $(hdrdir)/ruby/internal/intern/gc.h
init.o: $(hdrdir)/ruby/internal/intern/hash.h
init.o: $(hdrdir)/ruby/internal/intern/io.h
init.o: $(hdrdir)/ruby/internal/intern/load.h
@@ -622,7 +619,6 @@ init.o: $(hdrdir)/ruby/internal/memory.h
init.o: $(hdrdir)/ruby/internal/method.h
init.o: $(hdrdir)/ruby/internal/module.h
init.o: $(hdrdir)/ruby/internal/newobj.h
-init.o: $(hdrdir)/ruby/internal/rgengc.h
init.o: $(hdrdir)/ruby/internal/scan_args.h
init.o: $(hdrdir)/ruby/internal/special_consts.h
init.o: $(hdrdir)/ruby/internal/static_assert.h
@@ -691,6 +687,7 @@ intpack.o: $(hdrdir)/ruby/internal/attr/noexcept.h
intpack.o: $(hdrdir)/ruby/internal/attr/noinline.h
intpack.o: $(hdrdir)/ruby/internal/attr/nonnull.h
intpack.o: $(hdrdir)/ruby/internal/attr/noreturn.h
+intpack.o: $(hdrdir)/ruby/internal/attr/packed_struct.h
intpack.o: $(hdrdir)/ruby/internal/attr/pure.h
intpack.o: $(hdrdir)/ruby/internal/attr/restrict.h
intpack.o: $(hdrdir)/ruby/internal/attr/returns_nonnull.h
@@ -750,7 +747,6 @@ intpack.o: $(hdrdir)/ruby/internal/intern/enumerator.h
intpack.o: $(hdrdir)/ruby/internal/intern/error.h
intpack.o: $(hdrdir)/ruby/internal/intern/eval.h
intpack.o: $(hdrdir)/ruby/internal/intern/file.h
-intpack.o: $(hdrdir)/ruby/internal/intern/gc.h
intpack.o: $(hdrdir)/ruby/internal/intern/hash.h
intpack.o: $(hdrdir)/ruby/internal/intern/io.h
intpack.o: $(hdrdir)/ruby/internal/intern/load.h
@@ -781,7 +777,6 @@ intpack.o: $(hdrdir)/ruby/internal/memory.h
intpack.o: $(hdrdir)/ruby/internal/method.h
intpack.o: $(hdrdir)/ruby/internal/module.h
intpack.o: $(hdrdir)/ruby/internal/newobj.h
-intpack.o: $(hdrdir)/ruby/internal/rgengc.h
intpack.o: $(hdrdir)/ruby/internal/scan_args.h
intpack.o: $(hdrdir)/ruby/internal/special_consts.h
intpack.o: $(hdrdir)/ruby/internal/static_assert.h
@@ -851,6 +846,7 @@ mul.o: $(hdrdir)/ruby/internal/attr/noexcept.h
mul.o: $(hdrdir)/ruby/internal/attr/noinline.h
mul.o: $(hdrdir)/ruby/internal/attr/nonnull.h
mul.o: $(hdrdir)/ruby/internal/attr/noreturn.h
+mul.o: $(hdrdir)/ruby/internal/attr/packed_struct.h
mul.o: $(hdrdir)/ruby/internal/attr/pure.h
mul.o: $(hdrdir)/ruby/internal/attr/restrict.h
mul.o: $(hdrdir)/ruby/internal/attr/returns_nonnull.h
@@ -910,7 +906,6 @@ mul.o: $(hdrdir)/ruby/internal/intern/enumerator.h
mul.o: $(hdrdir)/ruby/internal/intern/error.h
mul.o: $(hdrdir)/ruby/internal/intern/eval.h
mul.o: $(hdrdir)/ruby/internal/intern/file.h
-mul.o: $(hdrdir)/ruby/internal/intern/gc.h
mul.o: $(hdrdir)/ruby/internal/intern/hash.h
mul.o: $(hdrdir)/ruby/internal/intern/io.h
mul.o: $(hdrdir)/ruby/internal/intern/load.h
@@ -941,7 +936,6 @@ mul.o: $(hdrdir)/ruby/internal/memory.h
mul.o: $(hdrdir)/ruby/internal/method.h
mul.o: $(hdrdir)/ruby/internal/module.h
mul.o: $(hdrdir)/ruby/internal/newobj.h
-mul.o: $(hdrdir)/ruby/internal/rgengc.h
mul.o: $(hdrdir)/ruby/internal/scan_args.h
mul.o: $(hdrdir)/ruby/internal/special_consts.h
mul.o: $(hdrdir)/ruby/internal/static_assert.h
@@ -1011,6 +1005,7 @@ str2big.o: $(hdrdir)/ruby/internal/attr/noexcept.h
str2big.o: $(hdrdir)/ruby/internal/attr/noinline.h
str2big.o: $(hdrdir)/ruby/internal/attr/nonnull.h
str2big.o: $(hdrdir)/ruby/internal/attr/noreturn.h
+str2big.o: $(hdrdir)/ruby/internal/attr/packed_struct.h
str2big.o: $(hdrdir)/ruby/internal/attr/pure.h
str2big.o: $(hdrdir)/ruby/internal/attr/restrict.h
str2big.o: $(hdrdir)/ruby/internal/attr/returns_nonnull.h
@@ -1070,7 +1065,6 @@ str2big.o: $(hdrdir)/ruby/internal/intern/enumerator.h
str2big.o: $(hdrdir)/ruby/internal/intern/error.h
str2big.o: $(hdrdir)/ruby/internal/intern/eval.h
str2big.o: $(hdrdir)/ruby/internal/intern/file.h
-str2big.o: $(hdrdir)/ruby/internal/intern/gc.h
str2big.o: $(hdrdir)/ruby/internal/intern/hash.h
str2big.o: $(hdrdir)/ruby/internal/intern/io.h
str2big.o: $(hdrdir)/ruby/internal/intern/load.h
@@ -1101,7 +1095,6 @@ str2big.o: $(hdrdir)/ruby/internal/memory.h
str2big.o: $(hdrdir)/ruby/internal/method.h
str2big.o: $(hdrdir)/ruby/internal/module.h
str2big.o: $(hdrdir)/ruby/internal/newobj.h
-str2big.o: $(hdrdir)/ruby/internal/rgengc.h
str2big.o: $(hdrdir)/ruby/internal/scan_args.h
str2big.o: $(hdrdir)/ruby/internal/special_consts.h
str2big.o: $(hdrdir)/ruby/internal/static_assert.h
diff --git a/ext/-test-/bug-14834/depend b/ext/-test-/bug-14834/depend
index 7bac8409e8..bf26a571aa 100644
--- a/ext/-test-/bug-14834/depend
+++ b/ext/-test-/bug-14834/depend
@@ -52,6 +52,7 @@ bug-14384.o: $(hdrdir)/ruby/internal/attr/noexcept.h
bug-14384.o: $(hdrdir)/ruby/internal/attr/noinline.h
bug-14384.o: $(hdrdir)/ruby/internal/attr/nonnull.h
bug-14384.o: $(hdrdir)/ruby/internal/attr/noreturn.h
+bug-14384.o: $(hdrdir)/ruby/internal/attr/packed_struct.h
bug-14384.o: $(hdrdir)/ruby/internal/attr/pure.h
bug-14384.o: $(hdrdir)/ruby/internal/attr/restrict.h
bug-14384.o: $(hdrdir)/ruby/internal/attr/returns_nonnull.h
@@ -111,7 +112,6 @@ bug-14384.o: $(hdrdir)/ruby/internal/intern/enumerator.h
bug-14384.o: $(hdrdir)/ruby/internal/intern/error.h
bug-14384.o: $(hdrdir)/ruby/internal/intern/eval.h
bug-14384.o: $(hdrdir)/ruby/internal/intern/file.h
-bug-14384.o: $(hdrdir)/ruby/internal/intern/gc.h
bug-14384.o: $(hdrdir)/ruby/internal/intern/hash.h
bug-14384.o: $(hdrdir)/ruby/internal/intern/io.h
bug-14384.o: $(hdrdir)/ruby/internal/intern/load.h
@@ -142,7 +142,6 @@ bug-14384.o: $(hdrdir)/ruby/internal/memory.h
bug-14384.o: $(hdrdir)/ruby/internal/method.h
bug-14384.o: $(hdrdir)/ruby/internal/module.h
bug-14384.o: $(hdrdir)/ruby/internal/newobj.h
-bug-14384.o: $(hdrdir)/ruby/internal/rgengc.h
bug-14384.o: $(hdrdir)/ruby/internal/scan_args.h
bug-14384.o: $(hdrdir)/ruby/internal/special_consts.h
bug-14384.o: $(hdrdir)/ruby/internal/static_assert.h
diff --git a/ext/-test-/bug-3571/depend b/ext/-test-/bug-3571/depend
index 2303f47594..9105093b0d 100644
--- a/ext/-test-/bug-3571/depend
+++ b/ext/-test-/bug-3571/depend
@@ -52,6 +52,7 @@ bug.o: $(hdrdir)/ruby/internal/attr/noexcept.h
bug.o: $(hdrdir)/ruby/internal/attr/noinline.h
bug.o: $(hdrdir)/ruby/internal/attr/nonnull.h
bug.o: $(hdrdir)/ruby/internal/attr/noreturn.h
+bug.o: $(hdrdir)/ruby/internal/attr/packed_struct.h
bug.o: $(hdrdir)/ruby/internal/attr/pure.h
bug.o: $(hdrdir)/ruby/internal/attr/restrict.h
bug.o: $(hdrdir)/ruby/internal/attr/returns_nonnull.h
@@ -111,7 +112,6 @@ bug.o: $(hdrdir)/ruby/internal/intern/enumerator.h
bug.o: $(hdrdir)/ruby/internal/intern/error.h
bug.o: $(hdrdir)/ruby/internal/intern/eval.h
bug.o: $(hdrdir)/ruby/internal/intern/file.h
-bug.o: $(hdrdir)/ruby/internal/intern/gc.h
bug.o: $(hdrdir)/ruby/internal/intern/hash.h
bug.o: $(hdrdir)/ruby/internal/intern/io.h
bug.o: $(hdrdir)/ruby/internal/intern/load.h
@@ -142,7 +142,6 @@ bug.o: $(hdrdir)/ruby/internal/memory.h
bug.o: $(hdrdir)/ruby/internal/method.h
bug.o: $(hdrdir)/ruby/internal/module.h
bug.o: $(hdrdir)/ruby/internal/newobj.h
-bug.o: $(hdrdir)/ruby/internal/rgengc.h
bug.o: $(hdrdir)/ruby/internal/scan_args.h
bug.o: $(hdrdir)/ruby/internal/special_consts.h
bug.o: $(hdrdir)/ruby/internal/static_assert.h
diff --git a/ext/-test-/bug-5832/depend b/ext/-test-/bug-5832/depend
index 2303f47594..9105093b0d 100644
--- a/ext/-test-/bug-5832/depend
+++ b/ext/-test-/bug-5832/depend
@@ -52,6 +52,7 @@ bug.o: $(hdrdir)/ruby/internal/attr/noexcept.h
bug.o: $(hdrdir)/ruby/internal/attr/noinline.h
bug.o: $(hdrdir)/ruby/internal/attr/nonnull.h
bug.o: $(hdrdir)/ruby/internal/attr/noreturn.h
+bug.o: $(hdrdir)/ruby/internal/attr/packed_struct.h
bug.o: $(hdrdir)/ruby/internal/attr/pure.h
bug.o: $(hdrdir)/ruby/internal/attr/restrict.h
bug.o: $(hdrdir)/ruby/internal/attr/returns_nonnull.h
@@ -111,7 +112,6 @@ bug.o: $(hdrdir)/ruby/internal/intern/enumerator.h
bug.o: $(hdrdir)/ruby/internal/intern/error.h
bug.o: $(hdrdir)/ruby/internal/intern/eval.h
bug.o: $(hdrdir)/ruby/internal/intern/file.h
-bug.o: $(hdrdir)/ruby/internal/intern/gc.h
bug.o: $(hdrdir)/ruby/internal/intern/hash.h
bug.o: $(hdrdir)/ruby/internal/intern/io.h
bug.o: $(hdrdir)/ruby/internal/intern/load.h
@@ -142,7 +142,6 @@ bug.o: $(hdrdir)/ruby/internal/memory.h
bug.o: $(hdrdir)/ruby/internal/method.h
bug.o: $(hdrdir)/ruby/internal/module.h
bug.o: $(hdrdir)/ruby/internal/newobj.h
-bug.o: $(hdrdir)/ruby/internal/rgengc.h
bug.o: $(hdrdir)/ruby/internal/scan_args.h
bug.o: $(hdrdir)/ruby/internal/special_consts.h
bug.o: $(hdrdir)/ruby/internal/static_assert.h
diff --git a/ext/-test-/bug_reporter/depend b/ext/-test-/bug_reporter/depend
index 603dd53ebf..20882708d1 100644
--- a/ext/-test-/bug_reporter/depend
+++ b/ext/-test-/bug_reporter/depend
@@ -52,6 +52,7 @@ bug_reporter.o: $(hdrdir)/ruby/internal/attr/noexcept.h
bug_reporter.o: $(hdrdir)/ruby/internal/attr/noinline.h
bug_reporter.o: $(hdrdir)/ruby/internal/attr/nonnull.h
bug_reporter.o: $(hdrdir)/ruby/internal/attr/noreturn.h
+bug_reporter.o: $(hdrdir)/ruby/internal/attr/packed_struct.h
bug_reporter.o: $(hdrdir)/ruby/internal/attr/pure.h
bug_reporter.o: $(hdrdir)/ruby/internal/attr/restrict.h
bug_reporter.o: $(hdrdir)/ruby/internal/attr/returns_nonnull.h
@@ -111,7 +112,6 @@ bug_reporter.o: $(hdrdir)/ruby/internal/intern/enumerator.h
bug_reporter.o: $(hdrdir)/ruby/internal/intern/error.h
bug_reporter.o: $(hdrdir)/ruby/internal/intern/eval.h
bug_reporter.o: $(hdrdir)/ruby/internal/intern/file.h
-bug_reporter.o: $(hdrdir)/ruby/internal/intern/gc.h
bug_reporter.o: $(hdrdir)/ruby/internal/intern/hash.h
bug_reporter.o: $(hdrdir)/ruby/internal/intern/io.h
bug_reporter.o: $(hdrdir)/ruby/internal/intern/load.h
@@ -142,7 +142,6 @@ bug_reporter.o: $(hdrdir)/ruby/internal/memory.h
bug_reporter.o: $(hdrdir)/ruby/internal/method.h
bug_reporter.o: $(hdrdir)/ruby/internal/module.h
bug_reporter.o: $(hdrdir)/ruby/internal/newobj.h
-bug_reporter.o: $(hdrdir)/ruby/internal/rgengc.h
bug_reporter.o: $(hdrdir)/ruby/internal/scan_args.h
bug_reporter.o: $(hdrdir)/ruby/internal/special_consts.h
bug_reporter.o: $(hdrdir)/ruby/internal/static_assert.h
diff --git a/ext/-test-/class/depend b/ext/-test-/class/depend
index a615eacd74..0a805f815e 100644
--- a/ext/-test-/class/depend
+++ b/ext/-test-/class/depend
@@ -51,6 +51,7 @@ class2name.o: $(hdrdir)/ruby/internal/attr/noexcept.h
class2name.o: $(hdrdir)/ruby/internal/attr/noinline.h
class2name.o: $(hdrdir)/ruby/internal/attr/nonnull.h
class2name.o: $(hdrdir)/ruby/internal/attr/noreturn.h
+class2name.o: $(hdrdir)/ruby/internal/attr/packed_struct.h
class2name.o: $(hdrdir)/ruby/internal/attr/pure.h
class2name.o: $(hdrdir)/ruby/internal/attr/restrict.h
class2name.o: $(hdrdir)/ruby/internal/attr/returns_nonnull.h
@@ -110,7 +111,6 @@ class2name.o: $(hdrdir)/ruby/internal/intern/enumerator.h
class2name.o: $(hdrdir)/ruby/internal/intern/error.h
class2name.o: $(hdrdir)/ruby/internal/intern/eval.h
class2name.o: $(hdrdir)/ruby/internal/intern/file.h
-class2name.o: $(hdrdir)/ruby/internal/intern/gc.h
class2name.o: $(hdrdir)/ruby/internal/intern/hash.h
class2name.o: $(hdrdir)/ruby/internal/intern/io.h
class2name.o: $(hdrdir)/ruby/internal/intern/load.h
@@ -141,7 +141,6 @@ class2name.o: $(hdrdir)/ruby/internal/memory.h
class2name.o: $(hdrdir)/ruby/internal/method.h
class2name.o: $(hdrdir)/ruby/internal/module.h
class2name.o: $(hdrdir)/ruby/internal/newobj.h
-class2name.o: $(hdrdir)/ruby/internal/rgengc.h
class2name.o: $(hdrdir)/ruby/internal/scan_args.h
class2name.o: $(hdrdir)/ruby/internal/special_consts.h
class2name.o: $(hdrdir)/ruby/internal/static_assert.h
@@ -211,6 +210,7 @@ init.o: $(hdrdir)/ruby/internal/attr/noexcept.h
init.o: $(hdrdir)/ruby/internal/attr/noinline.h
init.o: $(hdrdir)/ruby/internal/attr/nonnull.h
init.o: $(hdrdir)/ruby/internal/attr/noreturn.h
+init.o: $(hdrdir)/ruby/internal/attr/packed_struct.h
init.o: $(hdrdir)/ruby/internal/attr/pure.h
init.o: $(hdrdir)/ruby/internal/attr/restrict.h
init.o: $(hdrdir)/ruby/internal/attr/returns_nonnull.h
@@ -270,7 +270,6 @@ init.o: $(hdrdir)/ruby/internal/intern/enumerator.h
init.o: $(hdrdir)/ruby/internal/intern/error.h
init.o: $(hdrdir)/ruby/internal/intern/eval.h
init.o: $(hdrdir)/ruby/internal/intern/file.h
-init.o: $(hdrdir)/ruby/internal/intern/gc.h
init.o: $(hdrdir)/ruby/internal/intern/hash.h
init.o: $(hdrdir)/ruby/internal/intern/io.h
init.o: $(hdrdir)/ruby/internal/intern/load.h
@@ -301,7 +300,6 @@ init.o: $(hdrdir)/ruby/internal/memory.h
init.o: $(hdrdir)/ruby/internal/method.h
init.o: $(hdrdir)/ruby/internal/module.h
init.o: $(hdrdir)/ruby/internal/newobj.h
-init.o: $(hdrdir)/ruby/internal/rgengc.h
init.o: $(hdrdir)/ruby/internal/scan_args.h
init.o: $(hdrdir)/ruby/internal/special_consts.h
init.o: $(hdrdir)/ruby/internal/static_assert.h
diff --git a/ext/-test-/debug/depend b/ext/-test-/debug/depend
index c3a0c278aa..5feeea6d98 100644
--- a/ext/-test-/debug/depend
+++ b/ext/-test-/debug/depend
@@ -52,6 +52,7 @@ init.o: $(hdrdir)/ruby/internal/attr/noexcept.h
init.o: $(hdrdir)/ruby/internal/attr/noinline.h
init.o: $(hdrdir)/ruby/internal/attr/nonnull.h
init.o: $(hdrdir)/ruby/internal/attr/noreturn.h
+init.o: $(hdrdir)/ruby/internal/attr/packed_struct.h
init.o: $(hdrdir)/ruby/internal/attr/pure.h
init.o: $(hdrdir)/ruby/internal/attr/restrict.h
init.o: $(hdrdir)/ruby/internal/attr/returns_nonnull.h
@@ -111,7 +112,6 @@ init.o: $(hdrdir)/ruby/internal/intern/enumerator.h
init.o: $(hdrdir)/ruby/internal/intern/error.h
init.o: $(hdrdir)/ruby/internal/intern/eval.h
init.o: $(hdrdir)/ruby/internal/intern/file.h
-init.o: $(hdrdir)/ruby/internal/intern/gc.h
init.o: $(hdrdir)/ruby/internal/intern/hash.h
init.o: $(hdrdir)/ruby/internal/intern/io.h
init.o: $(hdrdir)/ruby/internal/intern/load.h
@@ -142,7 +142,6 @@ init.o: $(hdrdir)/ruby/internal/memory.h
init.o: $(hdrdir)/ruby/internal/method.h
init.o: $(hdrdir)/ruby/internal/module.h
init.o: $(hdrdir)/ruby/internal/newobj.h
-init.o: $(hdrdir)/ruby/internal/rgengc.h
init.o: $(hdrdir)/ruby/internal/scan_args.h
init.o: $(hdrdir)/ruby/internal/special_consts.h
init.o: $(hdrdir)/ruby/internal/static_assert.h
@@ -212,6 +211,7 @@ inspector.o: $(hdrdir)/ruby/internal/attr/noexcept.h
inspector.o: $(hdrdir)/ruby/internal/attr/noinline.h
inspector.o: $(hdrdir)/ruby/internal/attr/nonnull.h
inspector.o: $(hdrdir)/ruby/internal/attr/noreturn.h
+inspector.o: $(hdrdir)/ruby/internal/attr/packed_struct.h
inspector.o: $(hdrdir)/ruby/internal/attr/pure.h
inspector.o: $(hdrdir)/ruby/internal/attr/restrict.h
inspector.o: $(hdrdir)/ruby/internal/attr/returns_nonnull.h
@@ -271,7 +271,6 @@ inspector.o: $(hdrdir)/ruby/internal/intern/enumerator.h
inspector.o: $(hdrdir)/ruby/internal/intern/error.h
inspector.o: $(hdrdir)/ruby/internal/intern/eval.h
inspector.o: $(hdrdir)/ruby/internal/intern/file.h
-inspector.o: $(hdrdir)/ruby/internal/intern/gc.h
inspector.o: $(hdrdir)/ruby/internal/intern/hash.h
inspector.o: $(hdrdir)/ruby/internal/intern/io.h
inspector.o: $(hdrdir)/ruby/internal/intern/load.h
@@ -302,7 +301,6 @@ inspector.o: $(hdrdir)/ruby/internal/memory.h
inspector.o: $(hdrdir)/ruby/internal/method.h
inspector.o: $(hdrdir)/ruby/internal/module.h
inspector.o: $(hdrdir)/ruby/internal/newobj.h
-inspector.o: $(hdrdir)/ruby/internal/rgengc.h
inspector.o: $(hdrdir)/ruby/internal/scan_args.h
inspector.o: $(hdrdir)/ruby/internal/special_consts.h
inspector.o: $(hdrdir)/ruby/internal/static_assert.h
@@ -372,6 +370,7 @@ profile_frames.o: $(hdrdir)/ruby/internal/attr/noexcept.h
profile_frames.o: $(hdrdir)/ruby/internal/attr/noinline.h
profile_frames.o: $(hdrdir)/ruby/internal/attr/nonnull.h
profile_frames.o: $(hdrdir)/ruby/internal/attr/noreturn.h
+profile_frames.o: $(hdrdir)/ruby/internal/attr/packed_struct.h
profile_frames.o: $(hdrdir)/ruby/internal/attr/pure.h
profile_frames.o: $(hdrdir)/ruby/internal/attr/restrict.h
profile_frames.o: $(hdrdir)/ruby/internal/attr/returns_nonnull.h
@@ -431,7 +430,6 @@ profile_frames.o: $(hdrdir)/ruby/internal/intern/enumerator.h
profile_frames.o: $(hdrdir)/ruby/internal/intern/error.h
profile_frames.o: $(hdrdir)/ruby/internal/intern/eval.h
profile_frames.o: $(hdrdir)/ruby/internal/intern/file.h
-profile_frames.o: $(hdrdir)/ruby/internal/intern/gc.h
profile_frames.o: $(hdrdir)/ruby/internal/intern/hash.h
profile_frames.o: $(hdrdir)/ruby/internal/intern/io.h
profile_frames.o: $(hdrdir)/ruby/internal/intern/load.h
@@ -462,7 +460,6 @@ profile_frames.o: $(hdrdir)/ruby/internal/memory.h
profile_frames.o: $(hdrdir)/ruby/internal/method.h
profile_frames.o: $(hdrdir)/ruby/internal/module.h
profile_frames.o: $(hdrdir)/ruby/internal/newobj.h
-profile_frames.o: $(hdrdir)/ruby/internal/rgengc.h
profile_frames.o: $(hdrdir)/ruby/internal/scan_args.h
profile_frames.o: $(hdrdir)/ruby/internal/special_consts.h
profile_frames.o: $(hdrdir)/ruby/internal/static_assert.h
diff --git a/ext/-test-/debug/profile_frames.c b/ext/-test-/debug/profile_frames.c
index d2bba7d183..f9a77a5a78 100644
--- a/ext/-test-/debug/profile_frames.c
+++ b/ext/-test-/debug/profile_frames.c
@@ -37,8 +37,29 @@ profile_frames(VALUE self, VALUE start_v, VALUE num_v)
return result;
}
+static VALUE
+profile_thread_frames(VALUE self, VALUE thread, VALUE start_v, VALUE num_v)
+{
+ int i, collected_size;
+ int start = NUM2INT(start_v);
+ int buff_size = NUM2INT(num_v);
+ VALUE buff[MAX_BUF_SIZE];
+ int lines[MAX_BUF_SIZE];
+ VALUE result = rb_ary_new();
+
+ if (buff_size > MAX_BUF_SIZE) rb_raise(rb_eRuntimeError, "too long buff_size");
+
+ collected_size = rb_profile_thread_frames(thread, start, buff_size, buff, lines);
+ for (i=0; i<collected_size; i++) {
+ rb_ary_push(result, rb_profile_frame_full_label(buff[i]));
+ }
+
+ return result;
+}
+
void
Init_profile_frames(VALUE klass)
{
rb_define_module_function(klass, "profile_frames", profile_frames, 2);
+ rb_define_module_function(klass, "profile_thread_frames", profile_thread_frames, 3);
}
diff --git a/ext/-test-/dln/empty/depend b/ext/-test-/dln/empty/depend
index e16082a7dc..a460159087 100644
--- a/ext/-test-/dln/empty/depend
+++ b/ext/-test-/dln/empty/depend
@@ -52,6 +52,7 @@ empty.o: $(hdrdir)/ruby/internal/attr/noexcept.h
empty.o: $(hdrdir)/ruby/internal/attr/noinline.h
empty.o: $(hdrdir)/ruby/internal/attr/nonnull.h
empty.o: $(hdrdir)/ruby/internal/attr/noreturn.h
+empty.o: $(hdrdir)/ruby/internal/attr/packed_struct.h
empty.o: $(hdrdir)/ruby/internal/attr/pure.h
empty.o: $(hdrdir)/ruby/internal/attr/restrict.h
empty.o: $(hdrdir)/ruby/internal/attr/returns_nonnull.h
@@ -111,7 +112,6 @@ empty.o: $(hdrdir)/ruby/internal/intern/enumerator.h
empty.o: $(hdrdir)/ruby/internal/intern/error.h
empty.o: $(hdrdir)/ruby/internal/intern/eval.h
empty.o: $(hdrdir)/ruby/internal/intern/file.h
-empty.o: $(hdrdir)/ruby/internal/intern/gc.h
empty.o: $(hdrdir)/ruby/internal/intern/hash.h
empty.o: $(hdrdir)/ruby/internal/intern/io.h
empty.o: $(hdrdir)/ruby/internal/intern/load.h
@@ -142,7 +142,6 @@ empty.o: $(hdrdir)/ruby/internal/memory.h
empty.o: $(hdrdir)/ruby/internal/method.h
empty.o: $(hdrdir)/ruby/internal/module.h
empty.o: $(hdrdir)/ruby/internal/newobj.h
-empty.o: $(hdrdir)/ruby/internal/rgengc.h
empty.o: $(hdrdir)/ruby/internal/scan_args.h
empty.o: $(hdrdir)/ruby/internal/special_consts.h
empty.o: $(hdrdir)/ruby/internal/static_assert.h
diff --git a/ext/-test-/enumerator_kw/depend b/ext/-test-/enumerator_kw/depend
index 14a9557e41..49ea495421 100644
--- a/ext/-test-/enumerator_kw/depend
+++ b/ext/-test-/enumerator_kw/depend
@@ -52,6 +52,7 @@ enumerator_kw.o: $(hdrdir)/ruby/internal/attr/noexcept.h
enumerator_kw.o: $(hdrdir)/ruby/internal/attr/noinline.h
enumerator_kw.o: $(hdrdir)/ruby/internal/attr/nonnull.h
enumerator_kw.o: $(hdrdir)/ruby/internal/attr/noreturn.h
+enumerator_kw.o: $(hdrdir)/ruby/internal/attr/packed_struct.h
enumerator_kw.o: $(hdrdir)/ruby/internal/attr/pure.h
enumerator_kw.o: $(hdrdir)/ruby/internal/attr/restrict.h
enumerator_kw.o: $(hdrdir)/ruby/internal/attr/returns_nonnull.h
@@ -111,7 +112,6 @@ enumerator_kw.o: $(hdrdir)/ruby/internal/intern/enumerator.h
enumerator_kw.o: $(hdrdir)/ruby/internal/intern/error.h
enumerator_kw.o: $(hdrdir)/ruby/internal/intern/eval.h
enumerator_kw.o: $(hdrdir)/ruby/internal/intern/file.h
-enumerator_kw.o: $(hdrdir)/ruby/internal/intern/gc.h
enumerator_kw.o: $(hdrdir)/ruby/internal/intern/hash.h
enumerator_kw.o: $(hdrdir)/ruby/internal/intern/io.h
enumerator_kw.o: $(hdrdir)/ruby/internal/intern/load.h
@@ -142,7 +142,6 @@ enumerator_kw.o: $(hdrdir)/ruby/internal/memory.h
enumerator_kw.o: $(hdrdir)/ruby/internal/method.h
enumerator_kw.o: $(hdrdir)/ruby/internal/module.h
enumerator_kw.o: $(hdrdir)/ruby/internal/newobj.h
-enumerator_kw.o: $(hdrdir)/ruby/internal/rgengc.h
enumerator_kw.o: $(hdrdir)/ruby/internal/scan_args.h
enumerator_kw.o: $(hdrdir)/ruby/internal/special_consts.h
enumerator_kw.o: $(hdrdir)/ruby/internal/static_assert.h
diff --git a/ext/-test-/exception/depend b/ext/-test-/exception/depend
index e00f0b279d..818b4c79df 100644
--- a/ext/-test-/exception/depend
+++ b/ext/-test-/exception/depend
@@ -51,6 +51,7 @@ dataerror.o: $(hdrdir)/ruby/internal/attr/noexcept.h
dataerror.o: $(hdrdir)/ruby/internal/attr/noinline.h
dataerror.o: $(hdrdir)/ruby/internal/attr/nonnull.h
dataerror.o: $(hdrdir)/ruby/internal/attr/noreturn.h
+dataerror.o: $(hdrdir)/ruby/internal/attr/packed_struct.h
dataerror.o: $(hdrdir)/ruby/internal/attr/pure.h
dataerror.o: $(hdrdir)/ruby/internal/attr/restrict.h
dataerror.o: $(hdrdir)/ruby/internal/attr/returns_nonnull.h
@@ -110,7 +111,6 @@ dataerror.o: $(hdrdir)/ruby/internal/intern/enumerator.h
dataerror.o: $(hdrdir)/ruby/internal/intern/error.h
dataerror.o: $(hdrdir)/ruby/internal/intern/eval.h
dataerror.o: $(hdrdir)/ruby/internal/intern/file.h
-dataerror.o: $(hdrdir)/ruby/internal/intern/gc.h
dataerror.o: $(hdrdir)/ruby/internal/intern/hash.h
dataerror.o: $(hdrdir)/ruby/internal/intern/io.h
dataerror.o: $(hdrdir)/ruby/internal/intern/load.h
@@ -141,7 +141,6 @@ dataerror.o: $(hdrdir)/ruby/internal/memory.h
dataerror.o: $(hdrdir)/ruby/internal/method.h
dataerror.o: $(hdrdir)/ruby/internal/module.h
dataerror.o: $(hdrdir)/ruby/internal/newobj.h
-dataerror.o: $(hdrdir)/ruby/internal/rgengc.h
dataerror.o: $(hdrdir)/ruby/internal/scan_args.h
dataerror.o: $(hdrdir)/ruby/internal/special_consts.h
dataerror.o: $(hdrdir)/ruby/internal/static_assert.h
@@ -212,6 +211,7 @@ enc_raise.o: $(hdrdir)/ruby/internal/attr/noexcept.h
enc_raise.o: $(hdrdir)/ruby/internal/attr/noinline.h
enc_raise.o: $(hdrdir)/ruby/internal/attr/nonnull.h
enc_raise.o: $(hdrdir)/ruby/internal/attr/noreturn.h
+enc_raise.o: $(hdrdir)/ruby/internal/attr/packed_struct.h
enc_raise.o: $(hdrdir)/ruby/internal/attr/pure.h
enc_raise.o: $(hdrdir)/ruby/internal/attr/restrict.h
enc_raise.o: $(hdrdir)/ruby/internal/attr/returns_nonnull.h
@@ -280,7 +280,6 @@ enc_raise.o: $(hdrdir)/ruby/internal/intern/enumerator.h
enc_raise.o: $(hdrdir)/ruby/internal/intern/error.h
enc_raise.o: $(hdrdir)/ruby/internal/intern/eval.h
enc_raise.o: $(hdrdir)/ruby/internal/intern/file.h
-enc_raise.o: $(hdrdir)/ruby/internal/intern/gc.h
enc_raise.o: $(hdrdir)/ruby/internal/intern/hash.h
enc_raise.o: $(hdrdir)/ruby/internal/intern/io.h
enc_raise.o: $(hdrdir)/ruby/internal/intern/load.h
@@ -311,7 +310,6 @@ enc_raise.o: $(hdrdir)/ruby/internal/memory.h
enc_raise.o: $(hdrdir)/ruby/internal/method.h
enc_raise.o: $(hdrdir)/ruby/internal/module.h
enc_raise.o: $(hdrdir)/ruby/internal/newobj.h
-enc_raise.o: $(hdrdir)/ruby/internal/rgengc.h
enc_raise.o: $(hdrdir)/ruby/internal/scan_args.h
enc_raise.o: $(hdrdir)/ruby/internal/special_consts.h
enc_raise.o: $(hdrdir)/ruby/internal/static_assert.h
@@ -383,6 +381,7 @@ ensured.o: $(hdrdir)/ruby/internal/attr/noexcept.h
ensured.o: $(hdrdir)/ruby/internal/attr/noinline.h
ensured.o: $(hdrdir)/ruby/internal/attr/nonnull.h
ensured.o: $(hdrdir)/ruby/internal/attr/noreturn.h
+ensured.o: $(hdrdir)/ruby/internal/attr/packed_struct.h
ensured.o: $(hdrdir)/ruby/internal/attr/pure.h
ensured.o: $(hdrdir)/ruby/internal/attr/restrict.h
ensured.o: $(hdrdir)/ruby/internal/attr/returns_nonnull.h
@@ -442,7 +441,6 @@ ensured.o: $(hdrdir)/ruby/internal/intern/enumerator.h
ensured.o: $(hdrdir)/ruby/internal/intern/error.h
ensured.o: $(hdrdir)/ruby/internal/intern/eval.h
ensured.o: $(hdrdir)/ruby/internal/intern/file.h
-ensured.o: $(hdrdir)/ruby/internal/intern/gc.h
ensured.o: $(hdrdir)/ruby/internal/intern/hash.h
ensured.o: $(hdrdir)/ruby/internal/intern/io.h
ensured.o: $(hdrdir)/ruby/internal/intern/load.h
@@ -473,7 +471,6 @@ ensured.o: $(hdrdir)/ruby/internal/memory.h
ensured.o: $(hdrdir)/ruby/internal/method.h
ensured.o: $(hdrdir)/ruby/internal/module.h
ensured.o: $(hdrdir)/ruby/internal/newobj.h
-ensured.o: $(hdrdir)/ruby/internal/rgengc.h
ensured.o: $(hdrdir)/ruby/internal/scan_args.h
ensured.o: $(hdrdir)/ruby/internal/special_consts.h
ensured.o: $(hdrdir)/ruby/internal/static_assert.h
@@ -543,6 +540,7 @@ init.o: $(hdrdir)/ruby/internal/attr/noexcept.h
init.o: $(hdrdir)/ruby/internal/attr/noinline.h
init.o: $(hdrdir)/ruby/internal/attr/nonnull.h
init.o: $(hdrdir)/ruby/internal/attr/noreturn.h
+init.o: $(hdrdir)/ruby/internal/attr/packed_struct.h
init.o: $(hdrdir)/ruby/internal/attr/pure.h
init.o: $(hdrdir)/ruby/internal/attr/restrict.h
init.o: $(hdrdir)/ruby/internal/attr/returns_nonnull.h
@@ -602,7 +600,6 @@ init.o: $(hdrdir)/ruby/internal/intern/enumerator.h
init.o: $(hdrdir)/ruby/internal/intern/error.h
init.o: $(hdrdir)/ruby/internal/intern/eval.h
init.o: $(hdrdir)/ruby/internal/intern/file.h
-init.o: $(hdrdir)/ruby/internal/intern/gc.h
init.o: $(hdrdir)/ruby/internal/intern/hash.h
init.o: $(hdrdir)/ruby/internal/intern/io.h
init.o: $(hdrdir)/ruby/internal/intern/load.h
@@ -633,7 +630,6 @@ init.o: $(hdrdir)/ruby/internal/memory.h
init.o: $(hdrdir)/ruby/internal/method.h
init.o: $(hdrdir)/ruby/internal/module.h
init.o: $(hdrdir)/ruby/internal/newobj.h
-init.o: $(hdrdir)/ruby/internal/rgengc.h
init.o: $(hdrdir)/ruby/internal/scan_args.h
init.o: $(hdrdir)/ruby/internal/special_consts.h
init.o: $(hdrdir)/ruby/internal/static_assert.h
diff --git a/ext/-test-/fatal/depend b/ext/-test-/fatal/depend
index 5b1adb6607..730a72e52a 100644
--- a/ext/-test-/fatal/depend
+++ b/ext/-test-/fatal/depend
@@ -52,6 +52,7 @@ rb_fatal.o: $(hdrdir)/ruby/internal/attr/noexcept.h
rb_fatal.o: $(hdrdir)/ruby/internal/attr/noinline.h
rb_fatal.o: $(hdrdir)/ruby/internal/attr/nonnull.h
rb_fatal.o: $(hdrdir)/ruby/internal/attr/noreturn.h
+rb_fatal.o: $(hdrdir)/ruby/internal/attr/packed_struct.h
rb_fatal.o: $(hdrdir)/ruby/internal/attr/pure.h
rb_fatal.o: $(hdrdir)/ruby/internal/attr/restrict.h
rb_fatal.o: $(hdrdir)/ruby/internal/attr/returns_nonnull.h
@@ -111,7 +112,6 @@ rb_fatal.o: $(hdrdir)/ruby/internal/intern/enumerator.h
rb_fatal.o: $(hdrdir)/ruby/internal/intern/error.h
rb_fatal.o: $(hdrdir)/ruby/internal/intern/eval.h
rb_fatal.o: $(hdrdir)/ruby/internal/intern/file.h
-rb_fatal.o: $(hdrdir)/ruby/internal/intern/gc.h
rb_fatal.o: $(hdrdir)/ruby/internal/intern/hash.h
rb_fatal.o: $(hdrdir)/ruby/internal/intern/io.h
rb_fatal.o: $(hdrdir)/ruby/internal/intern/load.h
@@ -142,7 +142,6 @@ rb_fatal.o: $(hdrdir)/ruby/internal/memory.h
rb_fatal.o: $(hdrdir)/ruby/internal/method.h
rb_fatal.o: $(hdrdir)/ruby/internal/module.h
rb_fatal.o: $(hdrdir)/ruby/internal/newobj.h
-rb_fatal.o: $(hdrdir)/ruby/internal/rgengc.h
rb_fatal.o: $(hdrdir)/ruby/internal/scan_args.h
rb_fatal.o: $(hdrdir)/ruby/internal/special_consts.h
rb_fatal.o: $(hdrdir)/ruby/internal/static_assert.h
diff --git a/ext/-test-/file/depend b/ext/-test-/file/depend
index f0fffc2485..662136f1ba 100644
--- a/ext/-test-/file/depend
+++ b/ext/-test-/file/depend
@@ -52,6 +52,7 @@ fs.o: $(hdrdir)/ruby/internal/attr/noexcept.h
fs.o: $(hdrdir)/ruby/internal/attr/noinline.h
fs.o: $(hdrdir)/ruby/internal/attr/nonnull.h
fs.o: $(hdrdir)/ruby/internal/attr/noreturn.h
+fs.o: $(hdrdir)/ruby/internal/attr/packed_struct.h
fs.o: $(hdrdir)/ruby/internal/attr/pure.h
fs.o: $(hdrdir)/ruby/internal/attr/restrict.h
fs.o: $(hdrdir)/ruby/internal/attr/returns_nonnull.h
@@ -120,7 +121,6 @@ fs.o: $(hdrdir)/ruby/internal/intern/enumerator.h
fs.o: $(hdrdir)/ruby/internal/intern/error.h
fs.o: $(hdrdir)/ruby/internal/intern/eval.h
fs.o: $(hdrdir)/ruby/internal/intern/file.h
-fs.o: $(hdrdir)/ruby/internal/intern/gc.h
fs.o: $(hdrdir)/ruby/internal/intern/hash.h
fs.o: $(hdrdir)/ruby/internal/intern/io.h
fs.o: $(hdrdir)/ruby/internal/intern/load.h
@@ -151,7 +151,6 @@ fs.o: $(hdrdir)/ruby/internal/memory.h
fs.o: $(hdrdir)/ruby/internal/method.h
fs.o: $(hdrdir)/ruby/internal/module.h
fs.o: $(hdrdir)/ruby/internal/newobj.h
-fs.o: $(hdrdir)/ruby/internal/rgengc.h
fs.o: $(hdrdir)/ruby/internal/scan_args.h
fs.o: $(hdrdir)/ruby/internal/special_consts.h
fs.o: $(hdrdir)/ruby/internal/static_assert.h
@@ -224,6 +223,7 @@ init.o: $(hdrdir)/ruby/internal/attr/noexcept.h
init.o: $(hdrdir)/ruby/internal/attr/noinline.h
init.o: $(hdrdir)/ruby/internal/attr/nonnull.h
init.o: $(hdrdir)/ruby/internal/attr/noreturn.h
+init.o: $(hdrdir)/ruby/internal/attr/packed_struct.h
init.o: $(hdrdir)/ruby/internal/attr/pure.h
init.o: $(hdrdir)/ruby/internal/attr/restrict.h
init.o: $(hdrdir)/ruby/internal/attr/returns_nonnull.h
@@ -283,7 +283,6 @@ init.o: $(hdrdir)/ruby/internal/intern/enumerator.h
init.o: $(hdrdir)/ruby/internal/intern/error.h
init.o: $(hdrdir)/ruby/internal/intern/eval.h
init.o: $(hdrdir)/ruby/internal/intern/file.h
-init.o: $(hdrdir)/ruby/internal/intern/gc.h
init.o: $(hdrdir)/ruby/internal/intern/hash.h
init.o: $(hdrdir)/ruby/internal/intern/io.h
init.o: $(hdrdir)/ruby/internal/intern/load.h
@@ -314,7 +313,6 @@ init.o: $(hdrdir)/ruby/internal/memory.h
init.o: $(hdrdir)/ruby/internal/method.h
init.o: $(hdrdir)/ruby/internal/module.h
init.o: $(hdrdir)/ruby/internal/newobj.h
-init.o: $(hdrdir)/ruby/internal/rgengc.h
init.o: $(hdrdir)/ruby/internal/scan_args.h
init.o: $(hdrdir)/ruby/internal/special_consts.h
init.o: $(hdrdir)/ruby/internal/static_assert.h
@@ -384,6 +382,7 @@ stat.o: $(hdrdir)/ruby/internal/attr/noexcept.h
stat.o: $(hdrdir)/ruby/internal/attr/noinline.h
stat.o: $(hdrdir)/ruby/internal/attr/nonnull.h
stat.o: $(hdrdir)/ruby/internal/attr/noreturn.h
+stat.o: $(hdrdir)/ruby/internal/attr/packed_struct.h
stat.o: $(hdrdir)/ruby/internal/attr/pure.h
stat.o: $(hdrdir)/ruby/internal/attr/restrict.h
stat.o: $(hdrdir)/ruby/internal/attr/returns_nonnull.h
@@ -452,7 +451,6 @@ stat.o: $(hdrdir)/ruby/internal/intern/enumerator.h
stat.o: $(hdrdir)/ruby/internal/intern/error.h
stat.o: $(hdrdir)/ruby/internal/intern/eval.h
stat.o: $(hdrdir)/ruby/internal/intern/file.h
-stat.o: $(hdrdir)/ruby/internal/intern/gc.h
stat.o: $(hdrdir)/ruby/internal/intern/hash.h
stat.o: $(hdrdir)/ruby/internal/intern/io.h
stat.o: $(hdrdir)/ruby/internal/intern/load.h
@@ -483,7 +481,6 @@ stat.o: $(hdrdir)/ruby/internal/memory.h
stat.o: $(hdrdir)/ruby/internal/method.h
stat.o: $(hdrdir)/ruby/internal/module.h
stat.o: $(hdrdir)/ruby/internal/newobj.h
-stat.o: $(hdrdir)/ruby/internal/rgengc.h
stat.o: $(hdrdir)/ruby/internal/scan_args.h
stat.o: $(hdrdir)/ruby/internal/special_consts.h
stat.o: $(hdrdir)/ruby/internal/static_assert.h
diff --git a/ext/-test-/float/depend b/ext/-test-/float/depend
index 9391a445a3..9580a0416c 100644
--- a/ext/-test-/float/depend
+++ b/ext/-test-/float/depend
@@ -55,6 +55,7 @@ init.o: $(hdrdir)/ruby/internal/attr/noexcept.h
init.o: $(hdrdir)/ruby/internal/attr/noinline.h
init.o: $(hdrdir)/ruby/internal/attr/nonnull.h
init.o: $(hdrdir)/ruby/internal/attr/noreturn.h
+init.o: $(hdrdir)/ruby/internal/attr/packed_struct.h
init.o: $(hdrdir)/ruby/internal/attr/pure.h
init.o: $(hdrdir)/ruby/internal/attr/restrict.h
init.o: $(hdrdir)/ruby/internal/attr/returns_nonnull.h
@@ -114,7 +115,6 @@ init.o: $(hdrdir)/ruby/internal/intern/enumerator.h
init.o: $(hdrdir)/ruby/internal/intern/error.h
init.o: $(hdrdir)/ruby/internal/intern/eval.h
init.o: $(hdrdir)/ruby/internal/intern/file.h
-init.o: $(hdrdir)/ruby/internal/intern/gc.h
init.o: $(hdrdir)/ruby/internal/intern/hash.h
init.o: $(hdrdir)/ruby/internal/intern/io.h
init.o: $(hdrdir)/ruby/internal/intern/load.h
@@ -145,7 +145,6 @@ init.o: $(hdrdir)/ruby/internal/memory.h
init.o: $(hdrdir)/ruby/internal/method.h
init.o: $(hdrdir)/ruby/internal/module.h
init.o: $(hdrdir)/ruby/internal/newobj.h
-init.o: $(hdrdir)/ruby/internal/rgengc.h
init.o: $(hdrdir)/ruby/internal/scan_args.h
init.o: $(hdrdir)/ruby/internal/special_consts.h
init.o: $(hdrdir)/ruby/internal/static_assert.h
@@ -215,6 +214,7 @@ nextafter.o: $(hdrdir)/ruby/internal/attr/noexcept.h
nextafter.o: $(hdrdir)/ruby/internal/attr/noinline.h
nextafter.o: $(hdrdir)/ruby/internal/attr/nonnull.h
nextafter.o: $(hdrdir)/ruby/internal/attr/noreturn.h
+nextafter.o: $(hdrdir)/ruby/internal/attr/packed_struct.h
nextafter.o: $(hdrdir)/ruby/internal/attr/pure.h
nextafter.o: $(hdrdir)/ruby/internal/attr/restrict.h
nextafter.o: $(hdrdir)/ruby/internal/attr/returns_nonnull.h
@@ -274,7 +274,6 @@ nextafter.o: $(hdrdir)/ruby/internal/intern/enumerator.h
nextafter.o: $(hdrdir)/ruby/internal/intern/error.h
nextafter.o: $(hdrdir)/ruby/internal/intern/eval.h
nextafter.o: $(hdrdir)/ruby/internal/intern/file.h
-nextafter.o: $(hdrdir)/ruby/internal/intern/gc.h
nextafter.o: $(hdrdir)/ruby/internal/intern/hash.h
nextafter.o: $(hdrdir)/ruby/internal/intern/io.h
nextafter.o: $(hdrdir)/ruby/internal/intern/load.h
@@ -305,7 +304,6 @@ nextafter.o: $(hdrdir)/ruby/internal/memory.h
nextafter.o: $(hdrdir)/ruby/internal/method.h
nextafter.o: $(hdrdir)/ruby/internal/module.h
nextafter.o: $(hdrdir)/ruby/internal/newobj.h
-nextafter.o: $(hdrdir)/ruby/internal/rgengc.h
nextafter.o: $(hdrdir)/ruby/internal/scan_args.h
nextafter.o: $(hdrdir)/ruby/internal/special_consts.h
nextafter.o: $(hdrdir)/ruby/internal/static_assert.h
diff --git a/ext/-test-/funcall/depend b/ext/-test-/funcall/depend
index 24e8c54bd9..6719e4e676 100644
--- a/ext/-test-/funcall/depend
+++ b/ext/-test-/funcall/depend
@@ -52,6 +52,7 @@ funcall.o: $(hdrdir)/ruby/internal/attr/noexcept.h
funcall.o: $(hdrdir)/ruby/internal/attr/noinline.h
funcall.o: $(hdrdir)/ruby/internal/attr/nonnull.h
funcall.o: $(hdrdir)/ruby/internal/attr/noreturn.h
+funcall.o: $(hdrdir)/ruby/internal/attr/packed_struct.h
funcall.o: $(hdrdir)/ruby/internal/attr/pure.h
funcall.o: $(hdrdir)/ruby/internal/attr/restrict.h
funcall.o: $(hdrdir)/ruby/internal/attr/returns_nonnull.h
@@ -111,7 +112,6 @@ funcall.o: $(hdrdir)/ruby/internal/intern/enumerator.h
funcall.o: $(hdrdir)/ruby/internal/intern/error.h
funcall.o: $(hdrdir)/ruby/internal/intern/eval.h
funcall.o: $(hdrdir)/ruby/internal/intern/file.h
-funcall.o: $(hdrdir)/ruby/internal/intern/gc.h
funcall.o: $(hdrdir)/ruby/internal/intern/hash.h
funcall.o: $(hdrdir)/ruby/internal/intern/io.h
funcall.o: $(hdrdir)/ruby/internal/intern/load.h
@@ -142,7 +142,6 @@ funcall.o: $(hdrdir)/ruby/internal/memory.h
funcall.o: $(hdrdir)/ruby/internal/method.h
funcall.o: $(hdrdir)/ruby/internal/module.h
funcall.o: $(hdrdir)/ruby/internal/newobj.h
-funcall.o: $(hdrdir)/ruby/internal/rgengc.h
funcall.o: $(hdrdir)/ruby/internal/scan_args.h
funcall.o: $(hdrdir)/ruby/internal/special_consts.h
funcall.o: $(hdrdir)/ruby/internal/static_assert.h
diff --git a/ext/-test-/gvl/call_without_gvl/depend b/ext/-test-/gvl/call_without_gvl/depend
index cd184aa01c..a4987a65ca 100644
--- a/ext/-test-/gvl/call_without_gvl/depend
+++ b/ext/-test-/gvl/call_without_gvl/depend
@@ -51,6 +51,7 @@ call_without_gvl.o: $(hdrdir)/ruby/internal/attr/noexcept.h
call_without_gvl.o: $(hdrdir)/ruby/internal/attr/noinline.h
call_without_gvl.o: $(hdrdir)/ruby/internal/attr/nonnull.h
call_without_gvl.o: $(hdrdir)/ruby/internal/attr/noreturn.h
+call_without_gvl.o: $(hdrdir)/ruby/internal/attr/packed_struct.h
call_without_gvl.o: $(hdrdir)/ruby/internal/attr/pure.h
call_without_gvl.o: $(hdrdir)/ruby/internal/attr/restrict.h
call_without_gvl.o: $(hdrdir)/ruby/internal/attr/returns_nonnull.h
@@ -110,7 +111,6 @@ call_without_gvl.o: $(hdrdir)/ruby/internal/intern/enumerator.h
call_without_gvl.o: $(hdrdir)/ruby/internal/intern/error.h
call_without_gvl.o: $(hdrdir)/ruby/internal/intern/eval.h
call_without_gvl.o: $(hdrdir)/ruby/internal/intern/file.h
-call_without_gvl.o: $(hdrdir)/ruby/internal/intern/gc.h
call_without_gvl.o: $(hdrdir)/ruby/internal/intern/hash.h
call_without_gvl.o: $(hdrdir)/ruby/internal/intern/io.h
call_without_gvl.o: $(hdrdir)/ruby/internal/intern/load.h
@@ -141,7 +141,6 @@ call_without_gvl.o: $(hdrdir)/ruby/internal/memory.h
call_without_gvl.o: $(hdrdir)/ruby/internal/method.h
call_without_gvl.o: $(hdrdir)/ruby/internal/module.h
call_without_gvl.o: $(hdrdir)/ruby/internal/newobj.h
-call_without_gvl.o: $(hdrdir)/ruby/internal/rgengc.h
call_without_gvl.o: $(hdrdir)/ruby/internal/scan_args.h
call_without_gvl.o: $(hdrdir)/ruby/internal/special_consts.h
call_without_gvl.o: $(hdrdir)/ruby/internal/static_assert.h
diff --git a/ext/-test-/hash/depend b/ext/-test-/hash/depend
index a8bc47e640..58d9a6247e 100644
--- a/ext/-test-/hash/depend
+++ b/ext/-test-/hash/depend
@@ -52,6 +52,7 @@ delete.o: $(hdrdir)/ruby/internal/attr/noexcept.h
delete.o: $(hdrdir)/ruby/internal/attr/noinline.h
delete.o: $(hdrdir)/ruby/internal/attr/nonnull.h
delete.o: $(hdrdir)/ruby/internal/attr/noreturn.h
+delete.o: $(hdrdir)/ruby/internal/attr/packed_struct.h
delete.o: $(hdrdir)/ruby/internal/attr/pure.h
delete.o: $(hdrdir)/ruby/internal/attr/restrict.h
delete.o: $(hdrdir)/ruby/internal/attr/returns_nonnull.h
@@ -111,7 +112,6 @@ delete.o: $(hdrdir)/ruby/internal/intern/enumerator.h
delete.o: $(hdrdir)/ruby/internal/intern/error.h
delete.o: $(hdrdir)/ruby/internal/intern/eval.h
delete.o: $(hdrdir)/ruby/internal/intern/file.h
-delete.o: $(hdrdir)/ruby/internal/intern/gc.h
delete.o: $(hdrdir)/ruby/internal/intern/hash.h
delete.o: $(hdrdir)/ruby/internal/intern/io.h
delete.o: $(hdrdir)/ruby/internal/intern/load.h
@@ -142,7 +142,6 @@ delete.o: $(hdrdir)/ruby/internal/memory.h
delete.o: $(hdrdir)/ruby/internal/method.h
delete.o: $(hdrdir)/ruby/internal/module.h
delete.o: $(hdrdir)/ruby/internal/newobj.h
-delete.o: $(hdrdir)/ruby/internal/rgengc.h
delete.o: $(hdrdir)/ruby/internal/scan_args.h
delete.o: $(hdrdir)/ruby/internal/special_consts.h
delete.o: $(hdrdir)/ruby/internal/static_assert.h
@@ -212,6 +211,7 @@ init.o: $(hdrdir)/ruby/internal/attr/noexcept.h
init.o: $(hdrdir)/ruby/internal/attr/noinline.h
init.o: $(hdrdir)/ruby/internal/attr/nonnull.h
init.o: $(hdrdir)/ruby/internal/attr/noreturn.h
+init.o: $(hdrdir)/ruby/internal/attr/packed_struct.h
init.o: $(hdrdir)/ruby/internal/attr/pure.h
init.o: $(hdrdir)/ruby/internal/attr/restrict.h
init.o: $(hdrdir)/ruby/internal/attr/returns_nonnull.h
@@ -271,7 +271,6 @@ init.o: $(hdrdir)/ruby/internal/intern/enumerator.h
init.o: $(hdrdir)/ruby/internal/intern/error.h
init.o: $(hdrdir)/ruby/internal/intern/eval.h
init.o: $(hdrdir)/ruby/internal/intern/file.h
-init.o: $(hdrdir)/ruby/internal/intern/gc.h
init.o: $(hdrdir)/ruby/internal/intern/hash.h
init.o: $(hdrdir)/ruby/internal/intern/io.h
init.o: $(hdrdir)/ruby/internal/intern/load.h
@@ -302,7 +301,6 @@ init.o: $(hdrdir)/ruby/internal/memory.h
init.o: $(hdrdir)/ruby/internal/method.h
init.o: $(hdrdir)/ruby/internal/module.h
init.o: $(hdrdir)/ruby/internal/newobj.h
-init.o: $(hdrdir)/ruby/internal/rgengc.h
init.o: $(hdrdir)/ruby/internal/scan_args.h
init.o: $(hdrdir)/ruby/internal/special_consts.h
init.o: $(hdrdir)/ruby/internal/static_assert.h
diff --git a/ext/-test-/integer/depend b/ext/-test-/integer/depend
index b12159f308..b68a68ce73 100644
--- a/ext/-test-/integer/depend
+++ b/ext/-test-/integer/depend
@@ -52,6 +52,7 @@ core_ext.o: $(hdrdir)/ruby/internal/attr/noexcept.h
core_ext.o: $(hdrdir)/ruby/internal/attr/noinline.h
core_ext.o: $(hdrdir)/ruby/internal/attr/nonnull.h
core_ext.o: $(hdrdir)/ruby/internal/attr/noreturn.h
+core_ext.o: $(hdrdir)/ruby/internal/attr/packed_struct.h
core_ext.o: $(hdrdir)/ruby/internal/attr/pure.h
core_ext.o: $(hdrdir)/ruby/internal/attr/restrict.h
core_ext.o: $(hdrdir)/ruby/internal/attr/returns_nonnull.h
@@ -111,7 +112,6 @@ core_ext.o: $(hdrdir)/ruby/internal/intern/enumerator.h
core_ext.o: $(hdrdir)/ruby/internal/intern/error.h
core_ext.o: $(hdrdir)/ruby/internal/intern/eval.h
core_ext.o: $(hdrdir)/ruby/internal/intern/file.h
-core_ext.o: $(hdrdir)/ruby/internal/intern/gc.h
core_ext.o: $(hdrdir)/ruby/internal/intern/hash.h
core_ext.o: $(hdrdir)/ruby/internal/intern/io.h
core_ext.o: $(hdrdir)/ruby/internal/intern/load.h
@@ -142,7 +142,6 @@ core_ext.o: $(hdrdir)/ruby/internal/memory.h
core_ext.o: $(hdrdir)/ruby/internal/method.h
core_ext.o: $(hdrdir)/ruby/internal/module.h
core_ext.o: $(hdrdir)/ruby/internal/newobj.h
-core_ext.o: $(hdrdir)/ruby/internal/rgengc.h
core_ext.o: $(hdrdir)/ruby/internal/scan_args.h
core_ext.o: $(hdrdir)/ruby/internal/special_consts.h
core_ext.o: $(hdrdir)/ruby/internal/static_assert.h
@@ -220,6 +219,7 @@ init.o: $(hdrdir)/ruby/internal/attr/noexcept.h
init.o: $(hdrdir)/ruby/internal/attr/noinline.h
init.o: $(hdrdir)/ruby/internal/attr/nonnull.h
init.o: $(hdrdir)/ruby/internal/attr/noreturn.h
+init.o: $(hdrdir)/ruby/internal/attr/packed_struct.h
init.o: $(hdrdir)/ruby/internal/attr/pure.h
init.o: $(hdrdir)/ruby/internal/attr/restrict.h
init.o: $(hdrdir)/ruby/internal/attr/returns_nonnull.h
@@ -279,7 +279,6 @@ init.o: $(hdrdir)/ruby/internal/intern/enumerator.h
init.o: $(hdrdir)/ruby/internal/intern/error.h
init.o: $(hdrdir)/ruby/internal/intern/eval.h
init.o: $(hdrdir)/ruby/internal/intern/file.h
-init.o: $(hdrdir)/ruby/internal/intern/gc.h
init.o: $(hdrdir)/ruby/internal/intern/hash.h
init.o: $(hdrdir)/ruby/internal/intern/io.h
init.o: $(hdrdir)/ruby/internal/intern/load.h
@@ -310,7 +309,6 @@ init.o: $(hdrdir)/ruby/internal/memory.h
init.o: $(hdrdir)/ruby/internal/method.h
init.o: $(hdrdir)/ruby/internal/module.h
init.o: $(hdrdir)/ruby/internal/newobj.h
-init.o: $(hdrdir)/ruby/internal/rgengc.h
init.o: $(hdrdir)/ruby/internal/scan_args.h
init.o: $(hdrdir)/ruby/internal/special_consts.h
init.o: $(hdrdir)/ruby/internal/static_assert.h
@@ -380,6 +378,7 @@ my_integer.o: $(hdrdir)/ruby/internal/attr/noexcept.h
my_integer.o: $(hdrdir)/ruby/internal/attr/noinline.h
my_integer.o: $(hdrdir)/ruby/internal/attr/nonnull.h
my_integer.o: $(hdrdir)/ruby/internal/attr/noreturn.h
+my_integer.o: $(hdrdir)/ruby/internal/attr/packed_struct.h
my_integer.o: $(hdrdir)/ruby/internal/attr/pure.h
my_integer.o: $(hdrdir)/ruby/internal/attr/restrict.h
my_integer.o: $(hdrdir)/ruby/internal/attr/returns_nonnull.h
@@ -439,7 +438,6 @@ my_integer.o: $(hdrdir)/ruby/internal/intern/enumerator.h
my_integer.o: $(hdrdir)/ruby/internal/intern/error.h
my_integer.o: $(hdrdir)/ruby/internal/intern/eval.h
my_integer.o: $(hdrdir)/ruby/internal/intern/file.h
-my_integer.o: $(hdrdir)/ruby/internal/intern/gc.h
my_integer.o: $(hdrdir)/ruby/internal/intern/hash.h
my_integer.o: $(hdrdir)/ruby/internal/intern/io.h
my_integer.o: $(hdrdir)/ruby/internal/intern/load.h
@@ -470,7 +468,6 @@ my_integer.o: $(hdrdir)/ruby/internal/memory.h
my_integer.o: $(hdrdir)/ruby/internal/method.h
my_integer.o: $(hdrdir)/ruby/internal/module.h
my_integer.o: $(hdrdir)/ruby/internal/newobj.h
-my_integer.o: $(hdrdir)/ruby/internal/rgengc.h
my_integer.o: $(hdrdir)/ruby/internal/scan_args.h
my_integer.o: $(hdrdir)/ruby/internal/special_consts.h
my_integer.o: $(hdrdir)/ruby/internal/static_assert.h
diff --git a/ext/-test-/iseq_load/depend b/ext/-test-/iseq_load/depend
index 308956550c..30deb6e039 100644
--- a/ext/-test-/iseq_load/depend
+++ b/ext/-test-/iseq_load/depend
@@ -52,6 +52,7 @@ iseq_load.o: $(hdrdir)/ruby/internal/attr/noexcept.h
iseq_load.o: $(hdrdir)/ruby/internal/attr/noinline.h
iseq_load.o: $(hdrdir)/ruby/internal/attr/nonnull.h
iseq_load.o: $(hdrdir)/ruby/internal/attr/noreturn.h
+iseq_load.o: $(hdrdir)/ruby/internal/attr/packed_struct.h
iseq_load.o: $(hdrdir)/ruby/internal/attr/pure.h
iseq_load.o: $(hdrdir)/ruby/internal/attr/restrict.h
iseq_load.o: $(hdrdir)/ruby/internal/attr/returns_nonnull.h
@@ -111,7 +112,6 @@ iseq_load.o: $(hdrdir)/ruby/internal/intern/enumerator.h
iseq_load.o: $(hdrdir)/ruby/internal/intern/error.h
iseq_load.o: $(hdrdir)/ruby/internal/intern/eval.h
iseq_load.o: $(hdrdir)/ruby/internal/intern/file.h
-iseq_load.o: $(hdrdir)/ruby/internal/intern/gc.h
iseq_load.o: $(hdrdir)/ruby/internal/intern/hash.h
iseq_load.o: $(hdrdir)/ruby/internal/intern/io.h
iseq_load.o: $(hdrdir)/ruby/internal/intern/load.h
@@ -142,7 +142,6 @@ iseq_load.o: $(hdrdir)/ruby/internal/memory.h
iseq_load.o: $(hdrdir)/ruby/internal/method.h
iseq_load.o: $(hdrdir)/ruby/internal/module.h
iseq_load.o: $(hdrdir)/ruby/internal/newobj.h
-iseq_load.o: $(hdrdir)/ruby/internal/rgengc.h
iseq_load.o: $(hdrdir)/ruby/internal/scan_args.h
iseq_load.o: $(hdrdir)/ruby/internal/special_consts.h
iseq_load.o: $(hdrdir)/ruby/internal/static_assert.h
diff --git a/ext/-test-/iter/depend b/ext/-test-/iter/depend
index d14c164cd4..077a283532 100644
--- a/ext/-test-/iter/depend
+++ b/ext/-test-/iter/depend
@@ -52,6 +52,7 @@ break.o: $(hdrdir)/ruby/internal/attr/noexcept.h
break.o: $(hdrdir)/ruby/internal/attr/noinline.h
break.o: $(hdrdir)/ruby/internal/attr/nonnull.h
break.o: $(hdrdir)/ruby/internal/attr/noreturn.h
+break.o: $(hdrdir)/ruby/internal/attr/packed_struct.h
break.o: $(hdrdir)/ruby/internal/attr/pure.h
break.o: $(hdrdir)/ruby/internal/attr/restrict.h
break.o: $(hdrdir)/ruby/internal/attr/returns_nonnull.h
@@ -111,7 +112,6 @@ break.o: $(hdrdir)/ruby/internal/intern/enumerator.h
break.o: $(hdrdir)/ruby/internal/intern/error.h
break.o: $(hdrdir)/ruby/internal/intern/eval.h
break.o: $(hdrdir)/ruby/internal/intern/file.h
-break.o: $(hdrdir)/ruby/internal/intern/gc.h
break.o: $(hdrdir)/ruby/internal/intern/hash.h
break.o: $(hdrdir)/ruby/internal/intern/io.h
break.o: $(hdrdir)/ruby/internal/intern/load.h
@@ -142,7 +142,6 @@ break.o: $(hdrdir)/ruby/internal/memory.h
break.o: $(hdrdir)/ruby/internal/method.h
break.o: $(hdrdir)/ruby/internal/module.h
break.o: $(hdrdir)/ruby/internal/newobj.h
-break.o: $(hdrdir)/ruby/internal/rgengc.h
break.o: $(hdrdir)/ruby/internal/scan_args.h
break.o: $(hdrdir)/ruby/internal/special_consts.h
break.o: $(hdrdir)/ruby/internal/static_assert.h
@@ -212,6 +211,7 @@ init.o: $(hdrdir)/ruby/internal/attr/noexcept.h
init.o: $(hdrdir)/ruby/internal/attr/noinline.h
init.o: $(hdrdir)/ruby/internal/attr/nonnull.h
init.o: $(hdrdir)/ruby/internal/attr/noreturn.h
+init.o: $(hdrdir)/ruby/internal/attr/packed_struct.h
init.o: $(hdrdir)/ruby/internal/attr/pure.h
init.o: $(hdrdir)/ruby/internal/attr/restrict.h
init.o: $(hdrdir)/ruby/internal/attr/returns_nonnull.h
@@ -271,7 +271,6 @@ init.o: $(hdrdir)/ruby/internal/intern/enumerator.h
init.o: $(hdrdir)/ruby/internal/intern/error.h
init.o: $(hdrdir)/ruby/internal/intern/eval.h
init.o: $(hdrdir)/ruby/internal/intern/file.h
-init.o: $(hdrdir)/ruby/internal/intern/gc.h
init.o: $(hdrdir)/ruby/internal/intern/hash.h
init.o: $(hdrdir)/ruby/internal/intern/io.h
init.o: $(hdrdir)/ruby/internal/intern/load.h
@@ -302,7 +301,6 @@ init.o: $(hdrdir)/ruby/internal/memory.h
init.o: $(hdrdir)/ruby/internal/method.h
init.o: $(hdrdir)/ruby/internal/module.h
init.o: $(hdrdir)/ruby/internal/newobj.h
-init.o: $(hdrdir)/ruby/internal/rgengc.h
init.o: $(hdrdir)/ruby/internal/scan_args.h
init.o: $(hdrdir)/ruby/internal/special_consts.h
init.o: $(hdrdir)/ruby/internal/static_assert.h
@@ -372,6 +370,7 @@ yield.o: $(hdrdir)/ruby/internal/attr/noexcept.h
yield.o: $(hdrdir)/ruby/internal/attr/noinline.h
yield.o: $(hdrdir)/ruby/internal/attr/nonnull.h
yield.o: $(hdrdir)/ruby/internal/attr/noreturn.h
+yield.o: $(hdrdir)/ruby/internal/attr/packed_struct.h
yield.o: $(hdrdir)/ruby/internal/attr/pure.h
yield.o: $(hdrdir)/ruby/internal/attr/restrict.h
yield.o: $(hdrdir)/ruby/internal/attr/returns_nonnull.h
@@ -431,7 +430,6 @@ yield.o: $(hdrdir)/ruby/internal/intern/enumerator.h
yield.o: $(hdrdir)/ruby/internal/intern/error.h
yield.o: $(hdrdir)/ruby/internal/intern/eval.h
yield.o: $(hdrdir)/ruby/internal/intern/file.h
-yield.o: $(hdrdir)/ruby/internal/intern/gc.h
yield.o: $(hdrdir)/ruby/internal/intern/hash.h
yield.o: $(hdrdir)/ruby/internal/intern/io.h
yield.o: $(hdrdir)/ruby/internal/intern/load.h
@@ -462,7 +460,6 @@ yield.o: $(hdrdir)/ruby/internal/memory.h
yield.o: $(hdrdir)/ruby/internal/method.h
yield.o: $(hdrdir)/ruby/internal/module.h
yield.o: $(hdrdir)/ruby/internal/newobj.h
-yield.o: $(hdrdir)/ruby/internal/rgengc.h
yield.o: $(hdrdir)/ruby/internal/scan_args.h
yield.o: $(hdrdir)/ruby/internal/special_consts.h
yield.o: $(hdrdir)/ruby/internal/static_assert.h
diff --git a/ext/-test-/load/dot.dot/depend b/ext/-test-/load/dot.dot/depend
index d8b8937c3c..be835d3ea5 100644
--- a/ext/-test-/load/dot.dot/depend
+++ b/ext/-test-/load/dot.dot/depend
@@ -52,6 +52,7 @@ dot.dot.o: $(hdrdir)/ruby/internal/attr/noexcept.h
dot.dot.o: $(hdrdir)/ruby/internal/attr/noinline.h
dot.dot.o: $(hdrdir)/ruby/internal/attr/nonnull.h
dot.dot.o: $(hdrdir)/ruby/internal/attr/noreturn.h
+dot.dot.o: $(hdrdir)/ruby/internal/attr/packed_struct.h
dot.dot.o: $(hdrdir)/ruby/internal/attr/pure.h
dot.dot.o: $(hdrdir)/ruby/internal/attr/restrict.h
dot.dot.o: $(hdrdir)/ruby/internal/attr/returns_nonnull.h
@@ -111,7 +112,6 @@ dot.dot.o: $(hdrdir)/ruby/internal/intern/enumerator.h
dot.dot.o: $(hdrdir)/ruby/internal/intern/error.h
dot.dot.o: $(hdrdir)/ruby/internal/intern/eval.h
dot.dot.o: $(hdrdir)/ruby/internal/intern/file.h
-dot.dot.o: $(hdrdir)/ruby/internal/intern/gc.h
dot.dot.o: $(hdrdir)/ruby/internal/intern/hash.h
dot.dot.o: $(hdrdir)/ruby/internal/intern/io.h
dot.dot.o: $(hdrdir)/ruby/internal/intern/load.h
@@ -142,7 +142,6 @@ dot.dot.o: $(hdrdir)/ruby/internal/memory.h
dot.dot.o: $(hdrdir)/ruby/internal/method.h
dot.dot.o: $(hdrdir)/ruby/internal/module.h
dot.dot.o: $(hdrdir)/ruby/internal/newobj.h
-dot.dot.o: $(hdrdir)/ruby/internal/rgengc.h
dot.dot.o: $(hdrdir)/ruby/internal/scan_args.h
dot.dot.o: $(hdrdir)/ruby/internal/special_consts.h
dot.dot.o: $(hdrdir)/ruby/internal/static_assert.h
diff --git a/ext/-test-/load/protect/depend b/ext/-test-/load/protect/depend
index dd4ee71b62..57cf029901 100644
--- a/ext/-test-/load/protect/depend
+++ b/ext/-test-/load/protect/depend
@@ -52,6 +52,7 @@ protect.o: $(hdrdir)/ruby/internal/attr/noexcept.h
protect.o: $(hdrdir)/ruby/internal/attr/noinline.h
protect.o: $(hdrdir)/ruby/internal/attr/nonnull.h
protect.o: $(hdrdir)/ruby/internal/attr/noreturn.h
+protect.o: $(hdrdir)/ruby/internal/attr/packed_struct.h
protect.o: $(hdrdir)/ruby/internal/attr/pure.h
protect.o: $(hdrdir)/ruby/internal/attr/restrict.h
protect.o: $(hdrdir)/ruby/internal/attr/returns_nonnull.h
@@ -111,7 +112,6 @@ protect.o: $(hdrdir)/ruby/internal/intern/enumerator.h
protect.o: $(hdrdir)/ruby/internal/intern/error.h
protect.o: $(hdrdir)/ruby/internal/intern/eval.h
protect.o: $(hdrdir)/ruby/internal/intern/file.h
-protect.o: $(hdrdir)/ruby/internal/intern/gc.h
protect.o: $(hdrdir)/ruby/internal/intern/hash.h
protect.o: $(hdrdir)/ruby/internal/intern/io.h
protect.o: $(hdrdir)/ruby/internal/intern/load.h
@@ -142,7 +142,6 @@ protect.o: $(hdrdir)/ruby/internal/memory.h
protect.o: $(hdrdir)/ruby/internal/method.h
protect.o: $(hdrdir)/ruby/internal/module.h
protect.o: $(hdrdir)/ruby/internal/newobj.h
-protect.o: $(hdrdir)/ruby/internal/rgengc.h
protect.o: $(hdrdir)/ruby/internal/scan_args.h
protect.o: $(hdrdir)/ruby/internal/special_consts.h
protect.o: $(hdrdir)/ruby/internal/static_assert.h
diff --git a/ext/-test-/load/resolve_symbol_resolver/extconf.rb b/ext/-test-/load/resolve_symbol_resolver/extconf.rb
new file mode 100644
index 0000000000..2299efcfd3
--- /dev/null
+++ b/ext/-test-/load/resolve_symbol_resolver/extconf.rb
@@ -0,0 +1 @@
+create_makefile('-test-/load/resolve_symbol_resolver')
diff --git a/ext/-test-/load/resolve_symbol_resolver/resolve_symbol_resolver.c b/ext/-test-/load/resolve_symbol_resolver/resolve_symbol_resolver.c
new file mode 100644
index 0000000000..a856319cfb
--- /dev/null
+++ b/ext/-test-/load/resolve_symbol_resolver/resolve_symbol_resolver.c
@@ -0,0 +1,55 @@
+#include <ruby.h>
+#include "ruby/internal/intern/load.h"
+
+typedef VALUE(*target_func)(VALUE);
+
+static target_func rst_any_method;
+
+VALUE
+rsr_any_method(VALUE klass)
+{
+ return rst_any_method((VALUE)NULL);
+}
+
+VALUE
+rsr_try_resolve_fname(VALUE klass)
+{
+ target_func rst_something_missing =
+ (target_func) rb_ext_resolve_symbol("-test-/load/resolve_symbol_missing", "rst_any_method");
+ if (rst_something_missing == NULL) {
+ // This should be done in Init_*, so the error is LoadError
+ rb_raise(rb_eLoadError, "symbol not found: missing fname");
+ }
+ return Qtrue;
+}
+
+VALUE
+rsr_try_resolve_sname(VALUE klass)
+{
+ target_func rst_something_missing =
+ (target_func)rb_ext_resolve_symbol("-test-/load/resolve_symbol_target", "rst_something_missing");
+ if (rst_something_missing == NULL) {
+ // This should be done in Init_*, so the error is LoadError
+ rb_raise(rb_eLoadError, "symbol not found: missing sname");
+ }
+ return Qtrue;
+}
+
+void
+Init_resolve_symbol_resolver(void)
+{
+ /*
+ * Resolving symbols at the head of Init_ because it raises LoadError (in cases).
+ * If the module and methods are defined before raising LoadError, retrying `require "this.so"` will
+ * cause re-defining those methods (and will be warned).
+ */
+ rst_any_method = (target_func)rb_ext_resolve_symbol("-test-/load/resolve_symbol_target", "rst_any_method");
+ if (rst_any_method == NULL) {
+ rb_raise(rb_eLoadError, "resolve_symbol_target is not loaded");
+ }
+
+ VALUE mod = rb_define_module("ResolveSymbolResolver");
+ rb_define_singleton_method(mod, "any_method", rsr_any_method, 0);
+ rb_define_singleton_method(mod, "try_resolve_fname", rsr_try_resolve_fname, 0);
+ rb_define_singleton_method(mod, "try_resolve_sname", rsr_try_resolve_sname, 0);
+}
diff --git a/ext/-test-/load/resolve_symbol_target/extconf.rb b/ext/-test-/load/resolve_symbol_target/extconf.rb
new file mode 100644
index 0000000000..b5a99ca7f1
--- /dev/null
+++ b/ext/-test-/load/resolve_symbol_target/extconf.rb
@@ -0,0 +1 @@
+create_makefile('-test-/load/resolve_symbol_target')
diff --git a/ext/-test-/load/resolve_symbol_target/resolve_symbol_target.c b/ext/-test-/load/resolve_symbol_target/resolve_symbol_target.c
new file mode 100644
index 0000000000..b5bc9e8ee0
--- /dev/null
+++ b/ext/-test-/load/resolve_symbol_target/resolve_symbol_target.c
@@ -0,0 +1,15 @@
+#include <ruby.h>
+#include "resolve_symbol_target.h"
+
+VALUE
+rst_any_method(VALUE klass)
+{
+ return rb_str_new_cstr("from target");
+}
+
+void
+Init_resolve_symbol_target(void)
+{
+ VALUE mod = rb_define_module("ResolveSymbolTarget");
+ rb_define_singleton_method(mod, "any_method", rst_any_method, 0);
+}
diff --git a/ext/-test-/load/resolve_symbol_target/resolve_symbol_target.def b/ext/-test-/load/resolve_symbol_target/resolve_symbol_target.def
new file mode 100644
index 0000000000..c2ed3610fe
--- /dev/null
+++ b/ext/-test-/load/resolve_symbol_target/resolve_symbol_target.def
@@ -0,0 +1,4 @@
+LIBRARY resolve_symbol_target
+EXPORTS
+ Init_resolve_symbol_target
+ rst_any_method
diff --git a/ext/-test-/load/resolve_symbol_target/resolve_symbol_target.h b/ext/-test-/load/resolve_symbol_target/resolve_symbol_target.h
new file mode 100644
index 0000000000..7d471bf360
--- /dev/null
+++ b/ext/-test-/load/resolve_symbol_target/resolve_symbol_target.h
@@ -0,0 +1,4 @@
+#include <ruby.h>
+#include "ruby/internal/dllexport.h"
+
+RUBY_EXTERN VALUE rst_any_method(VALUE);
diff --git a/ext/-test-/load/stringify_symbols/extconf.rb b/ext/-test-/load/stringify_symbols/extconf.rb
new file mode 100644
index 0000000000..ac39c15f09
--- /dev/null
+++ b/ext/-test-/load/stringify_symbols/extconf.rb
@@ -0,0 +1 @@
+create_makefile('-test-/load/stringify_symbols')
diff --git a/ext/-test-/load/stringify_symbols/stringify_symbols.c b/ext/-test-/load/stringify_symbols/stringify_symbols.c
new file mode 100644
index 0000000000..11a5ee3bc5
--- /dev/null
+++ b/ext/-test-/load/stringify_symbols/stringify_symbols.c
@@ -0,0 +1,29 @@
+#include <ruby.h>
+#include "ruby/internal/intern/load.h"
+#include "ruby/util.h"
+
+#if SIZEOF_INTPTR_T == SIZEOF_LONG_LONG
+# define UINTPTR2NUM ULL2NUM
+#elif SIZEOF_INTPTR_T == SIZEOF_LONG
+# define UINTPTR2NUM ULONG2NUM
+#else
+# define UINTPTR2NUM UINT2NUM
+#endif
+
+static VALUE
+stringify_symbol(VALUE klass, VALUE fname, VALUE sname)
+{
+ void *ptr = rb_ext_resolve_symbol(StringValueCStr(fname), StringValueCStr(sname));
+ if (ptr == NULL) {
+ return Qnil;
+ }
+ uintptr_t uintptr = (uintptr_t)ptr;
+ return UINTPTR2NUM(uintptr);
+}
+
+void
+Init_stringify_symbols(void)
+{
+ VALUE mod = rb_define_module("StringifySymbols");
+ rb_define_singleton_method(mod, "stringify_symbol", stringify_symbol, 2);
+}
diff --git a/ext/-test-/load/stringify_target/extconf.rb b/ext/-test-/load/stringify_target/extconf.rb
new file mode 100644
index 0000000000..4aa201cb09
--- /dev/null
+++ b/ext/-test-/load/stringify_target/extconf.rb
@@ -0,0 +1 @@
+create_makefile('-test-/load/stringify_target')
diff --git a/ext/-test-/load/stringify_target/stringify_target.c b/ext/-test-/load/stringify_target/stringify_target.c
new file mode 100644
index 0000000000..ce09b8fd77
--- /dev/null
+++ b/ext/-test-/load/stringify_target/stringify_target.c
@@ -0,0 +1,15 @@
+#include <ruby.h>
+#include "stringify_target.h"
+
+VALUE
+stt_any_method(VALUE klass)
+{
+ return rb_str_new_cstr("from target");
+}
+
+void
+Init_stringify_target(void)
+{
+ VALUE mod = rb_define_module("StringifyTarget");
+ rb_define_singleton_method(mod, "any_method", stt_any_method, 0);
+}
diff --git a/ext/-test-/load/stringify_target/stringify_target.def b/ext/-test-/load/stringify_target/stringify_target.def
new file mode 100644
index 0000000000..89c2b762de
--- /dev/null
+++ b/ext/-test-/load/stringify_target/stringify_target.def
@@ -0,0 +1,4 @@
+LIBRARY stringify_target
+EXPORTS
+ Init_stringify_target
+ stt_any_method
diff --git a/ext/-test-/load/stringify_target/stringify_target.h b/ext/-test-/load/stringify_target/stringify_target.h
new file mode 100644
index 0000000000..5081f8cbd6
--- /dev/null
+++ b/ext/-test-/load/stringify_target/stringify_target.h
@@ -0,0 +1,4 @@
+#include <ruby.h>
+#include "ruby/internal/dllexport.h"
+
+RUBY_EXTERN VALUE stt_any_method(VALUE);
diff --git a/ext/-test-/marshal/compat/depend b/ext/-test-/marshal/compat/depend
index 2c3ecf1ab9..ff675ccabb 100644
--- a/ext/-test-/marshal/compat/depend
+++ b/ext/-test-/marshal/compat/depend
@@ -52,6 +52,7 @@ usrcompat.o: $(hdrdir)/ruby/internal/attr/noexcept.h
usrcompat.o: $(hdrdir)/ruby/internal/attr/noinline.h
usrcompat.o: $(hdrdir)/ruby/internal/attr/nonnull.h
usrcompat.o: $(hdrdir)/ruby/internal/attr/noreturn.h
+usrcompat.o: $(hdrdir)/ruby/internal/attr/packed_struct.h
usrcompat.o: $(hdrdir)/ruby/internal/attr/pure.h
usrcompat.o: $(hdrdir)/ruby/internal/attr/restrict.h
usrcompat.o: $(hdrdir)/ruby/internal/attr/returns_nonnull.h
@@ -111,7 +112,6 @@ usrcompat.o: $(hdrdir)/ruby/internal/intern/enumerator.h
usrcompat.o: $(hdrdir)/ruby/internal/intern/error.h
usrcompat.o: $(hdrdir)/ruby/internal/intern/eval.h
usrcompat.o: $(hdrdir)/ruby/internal/intern/file.h
-usrcompat.o: $(hdrdir)/ruby/internal/intern/gc.h
usrcompat.o: $(hdrdir)/ruby/internal/intern/hash.h
usrcompat.o: $(hdrdir)/ruby/internal/intern/io.h
usrcompat.o: $(hdrdir)/ruby/internal/intern/load.h
@@ -142,7 +142,6 @@ usrcompat.o: $(hdrdir)/ruby/internal/memory.h
usrcompat.o: $(hdrdir)/ruby/internal/method.h
usrcompat.o: $(hdrdir)/ruby/internal/module.h
usrcompat.o: $(hdrdir)/ruby/internal/newobj.h
-usrcompat.o: $(hdrdir)/ruby/internal/rgengc.h
usrcompat.o: $(hdrdir)/ruby/internal/scan_args.h
usrcompat.o: $(hdrdir)/ruby/internal/special_consts.h
usrcompat.o: $(hdrdir)/ruby/internal/static_assert.h
diff --git a/ext/-test-/marshal/internal_ivar/depend b/ext/-test-/marshal/internal_ivar/depend
index cacb54a1a7..4fe36834d8 100644
--- a/ext/-test-/marshal/internal_ivar/depend
+++ b/ext/-test-/marshal/internal_ivar/depend
@@ -52,6 +52,7 @@ internal_ivar.o: $(hdrdir)/ruby/internal/attr/noexcept.h
internal_ivar.o: $(hdrdir)/ruby/internal/attr/noinline.h
internal_ivar.o: $(hdrdir)/ruby/internal/attr/nonnull.h
internal_ivar.o: $(hdrdir)/ruby/internal/attr/noreturn.h
+internal_ivar.o: $(hdrdir)/ruby/internal/attr/packed_struct.h
internal_ivar.o: $(hdrdir)/ruby/internal/attr/pure.h
internal_ivar.o: $(hdrdir)/ruby/internal/attr/restrict.h
internal_ivar.o: $(hdrdir)/ruby/internal/attr/returns_nonnull.h
@@ -111,7 +112,6 @@ internal_ivar.o: $(hdrdir)/ruby/internal/intern/enumerator.h
internal_ivar.o: $(hdrdir)/ruby/internal/intern/error.h
internal_ivar.o: $(hdrdir)/ruby/internal/intern/eval.h
internal_ivar.o: $(hdrdir)/ruby/internal/intern/file.h
-internal_ivar.o: $(hdrdir)/ruby/internal/intern/gc.h
internal_ivar.o: $(hdrdir)/ruby/internal/intern/hash.h
internal_ivar.o: $(hdrdir)/ruby/internal/intern/io.h
internal_ivar.o: $(hdrdir)/ruby/internal/intern/load.h
@@ -142,7 +142,6 @@ internal_ivar.o: $(hdrdir)/ruby/internal/memory.h
internal_ivar.o: $(hdrdir)/ruby/internal/method.h
internal_ivar.o: $(hdrdir)/ruby/internal/module.h
internal_ivar.o: $(hdrdir)/ruby/internal/newobj.h
-internal_ivar.o: $(hdrdir)/ruby/internal/rgengc.h
internal_ivar.o: $(hdrdir)/ruby/internal/scan_args.h
internal_ivar.o: $(hdrdir)/ruby/internal/special_consts.h
internal_ivar.o: $(hdrdir)/ruby/internal/static_assert.h
diff --git a/ext/-test-/marshal/usr/depend b/ext/-test-/marshal/usr/depend
index 717101cbcf..1d56cc8202 100644
--- a/ext/-test-/marshal/usr/depend
+++ b/ext/-test-/marshal/usr/depend
@@ -52,6 +52,7 @@ usrmarshal.o: $(hdrdir)/ruby/internal/attr/noexcept.h
usrmarshal.o: $(hdrdir)/ruby/internal/attr/noinline.h
usrmarshal.o: $(hdrdir)/ruby/internal/attr/nonnull.h
usrmarshal.o: $(hdrdir)/ruby/internal/attr/noreturn.h
+usrmarshal.o: $(hdrdir)/ruby/internal/attr/packed_struct.h
usrmarshal.o: $(hdrdir)/ruby/internal/attr/pure.h
usrmarshal.o: $(hdrdir)/ruby/internal/attr/restrict.h
usrmarshal.o: $(hdrdir)/ruby/internal/attr/returns_nonnull.h
@@ -111,7 +112,6 @@ usrmarshal.o: $(hdrdir)/ruby/internal/intern/enumerator.h
usrmarshal.o: $(hdrdir)/ruby/internal/intern/error.h
usrmarshal.o: $(hdrdir)/ruby/internal/intern/eval.h
usrmarshal.o: $(hdrdir)/ruby/internal/intern/file.h
-usrmarshal.o: $(hdrdir)/ruby/internal/intern/gc.h
usrmarshal.o: $(hdrdir)/ruby/internal/intern/hash.h
usrmarshal.o: $(hdrdir)/ruby/internal/intern/io.h
usrmarshal.o: $(hdrdir)/ruby/internal/intern/load.h
@@ -142,7 +142,6 @@ usrmarshal.o: $(hdrdir)/ruby/internal/memory.h
usrmarshal.o: $(hdrdir)/ruby/internal/method.h
usrmarshal.o: $(hdrdir)/ruby/internal/module.h
usrmarshal.o: $(hdrdir)/ruby/internal/newobj.h
-usrmarshal.o: $(hdrdir)/ruby/internal/rgengc.h
usrmarshal.o: $(hdrdir)/ruby/internal/scan_args.h
usrmarshal.o: $(hdrdir)/ruby/internal/special_consts.h
usrmarshal.o: $(hdrdir)/ruby/internal/static_assert.h
diff --git a/ext/-test-/memory_status/depend b/ext/-test-/memory_status/depend
index a65fe66ae3..52e2fe8e1f 100644
--- a/ext/-test-/memory_status/depend
+++ b/ext/-test-/memory_status/depend
@@ -52,6 +52,7 @@ memory_status.o: $(hdrdir)/ruby/internal/attr/noexcept.h
memory_status.o: $(hdrdir)/ruby/internal/attr/noinline.h
memory_status.o: $(hdrdir)/ruby/internal/attr/nonnull.h
memory_status.o: $(hdrdir)/ruby/internal/attr/noreturn.h
+memory_status.o: $(hdrdir)/ruby/internal/attr/packed_struct.h
memory_status.o: $(hdrdir)/ruby/internal/attr/pure.h
memory_status.o: $(hdrdir)/ruby/internal/attr/restrict.h
memory_status.o: $(hdrdir)/ruby/internal/attr/returns_nonnull.h
@@ -111,7 +112,6 @@ memory_status.o: $(hdrdir)/ruby/internal/intern/enumerator.h
memory_status.o: $(hdrdir)/ruby/internal/intern/error.h
memory_status.o: $(hdrdir)/ruby/internal/intern/eval.h
memory_status.o: $(hdrdir)/ruby/internal/intern/file.h
-memory_status.o: $(hdrdir)/ruby/internal/intern/gc.h
memory_status.o: $(hdrdir)/ruby/internal/intern/hash.h
memory_status.o: $(hdrdir)/ruby/internal/intern/io.h
memory_status.o: $(hdrdir)/ruby/internal/intern/load.h
@@ -142,7 +142,6 @@ memory_status.o: $(hdrdir)/ruby/internal/memory.h
memory_status.o: $(hdrdir)/ruby/internal/method.h
memory_status.o: $(hdrdir)/ruby/internal/module.h
memory_status.o: $(hdrdir)/ruby/internal/newobj.h
-memory_status.o: $(hdrdir)/ruby/internal/rgengc.h
memory_status.o: $(hdrdir)/ruby/internal/scan_args.h
memory_status.o: $(hdrdir)/ruby/internal/special_consts.h
memory_status.o: $(hdrdir)/ruby/internal/static_assert.h
diff --git a/ext/-test-/memory_view/depend b/ext/-test-/memory_view/depend
index 7ce2d0374c..c9ef06a15c 100644
--- a/ext/-test-/memory_view/depend
+++ b/ext/-test-/memory_view/depend
@@ -52,6 +52,7 @@ memory_view.o: $(hdrdir)/ruby/internal/attr/noexcept.h
memory_view.o: $(hdrdir)/ruby/internal/attr/noinline.h
memory_view.o: $(hdrdir)/ruby/internal/attr/nonnull.h
memory_view.o: $(hdrdir)/ruby/internal/attr/noreturn.h
+memory_view.o: $(hdrdir)/ruby/internal/attr/packed_struct.h
memory_view.o: $(hdrdir)/ruby/internal/attr/pure.h
memory_view.o: $(hdrdir)/ruby/internal/attr/restrict.h
memory_view.o: $(hdrdir)/ruby/internal/attr/returns_nonnull.h
@@ -111,7 +112,6 @@ memory_view.o: $(hdrdir)/ruby/internal/intern/enumerator.h
memory_view.o: $(hdrdir)/ruby/internal/intern/error.h
memory_view.o: $(hdrdir)/ruby/internal/intern/eval.h
memory_view.o: $(hdrdir)/ruby/internal/intern/file.h
-memory_view.o: $(hdrdir)/ruby/internal/intern/gc.h
memory_view.o: $(hdrdir)/ruby/internal/intern/hash.h
memory_view.o: $(hdrdir)/ruby/internal/intern/io.h
memory_view.o: $(hdrdir)/ruby/internal/intern/load.h
@@ -142,7 +142,6 @@ memory_view.o: $(hdrdir)/ruby/internal/memory.h
memory_view.o: $(hdrdir)/ruby/internal/method.h
memory_view.o: $(hdrdir)/ruby/internal/module.h
memory_view.o: $(hdrdir)/ruby/internal/newobj.h
-memory_view.o: $(hdrdir)/ruby/internal/rgengc.h
memory_view.o: $(hdrdir)/ruby/internal/scan_args.h
memory_view.o: $(hdrdir)/ruby/internal/special_consts.h
memory_view.o: $(hdrdir)/ruby/internal/static_assert.h
diff --git a/ext/-test-/method/depend b/ext/-test-/method/depend
index 85cf4d174a..dbf513f48f 100644
--- a/ext/-test-/method/depend
+++ b/ext/-test-/method/depend
@@ -52,6 +52,7 @@ arity.o: $(hdrdir)/ruby/internal/attr/noexcept.h
arity.o: $(hdrdir)/ruby/internal/attr/noinline.h
arity.o: $(hdrdir)/ruby/internal/attr/nonnull.h
arity.o: $(hdrdir)/ruby/internal/attr/noreturn.h
+arity.o: $(hdrdir)/ruby/internal/attr/packed_struct.h
arity.o: $(hdrdir)/ruby/internal/attr/pure.h
arity.o: $(hdrdir)/ruby/internal/attr/restrict.h
arity.o: $(hdrdir)/ruby/internal/attr/returns_nonnull.h
@@ -111,7 +112,6 @@ arity.o: $(hdrdir)/ruby/internal/intern/enumerator.h
arity.o: $(hdrdir)/ruby/internal/intern/error.h
arity.o: $(hdrdir)/ruby/internal/intern/eval.h
arity.o: $(hdrdir)/ruby/internal/intern/file.h
-arity.o: $(hdrdir)/ruby/internal/intern/gc.h
arity.o: $(hdrdir)/ruby/internal/intern/hash.h
arity.o: $(hdrdir)/ruby/internal/intern/io.h
arity.o: $(hdrdir)/ruby/internal/intern/load.h
@@ -142,7 +142,6 @@ arity.o: $(hdrdir)/ruby/internal/memory.h
arity.o: $(hdrdir)/ruby/internal/method.h
arity.o: $(hdrdir)/ruby/internal/module.h
arity.o: $(hdrdir)/ruby/internal/newobj.h
-arity.o: $(hdrdir)/ruby/internal/rgengc.h
arity.o: $(hdrdir)/ruby/internal/scan_args.h
arity.o: $(hdrdir)/ruby/internal/special_consts.h
arity.o: $(hdrdir)/ruby/internal/static_assert.h
@@ -212,6 +211,7 @@ init.o: $(hdrdir)/ruby/internal/attr/noexcept.h
init.o: $(hdrdir)/ruby/internal/attr/noinline.h
init.o: $(hdrdir)/ruby/internal/attr/nonnull.h
init.o: $(hdrdir)/ruby/internal/attr/noreturn.h
+init.o: $(hdrdir)/ruby/internal/attr/packed_struct.h
init.o: $(hdrdir)/ruby/internal/attr/pure.h
init.o: $(hdrdir)/ruby/internal/attr/restrict.h
init.o: $(hdrdir)/ruby/internal/attr/returns_nonnull.h
@@ -271,7 +271,6 @@ init.o: $(hdrdir)/ruby/internal/intern/enumerator.h
init.o: $(hdrdir)/ruby/internal/intern/error.h
init.o: $(hdrdir)/ruby/internal/intern/eval.h
init.o: $(hdrdir)/ruby/internal/intern/file.h
-init.o: $(hdrdir)/ruby/internal/intern/gc.h
init.o: $(hdrdir)/ruby/internal/intern/hash.h
init.o: $(hdrdir)/ruby/internal/intern/io.h
init.o: $(hdrdir)/ruby/internal/intern/load.h
@@ -302,7 +301,6 @@ init.o: $(hdrdir)/ruby/internal/memory.h
init.o: $(hdrdir)/ruby/internal/method.h
init.o: $(hdrdir)/ruby/internal/module.h
init.o: $(hdrdir)/ruby/internal/newobj.h
-init.o: $(hdrdir)/ruby/internal/rgengc.h
init.o: $(hdrdir)/ruby/internal/scan_args.h
init.o: $(hdrdir)/ruby/internal/special_consts.h
init.o: $(hdrdir)/ruby/internal/static_assert.h
diff --git a/ext/-test-/notimplement/depend b/ext/-test-/notimplement/depend
index 2303f47594..9105093b0d 100644
--- a/ext/-test-/notimplement/depend
+++ b/ext/-test-/notimplement/depend
@@ -52,6 +52,7 @@ bug.o: $(hdrdir)/ruby/internal/attr/noexcept.h
bug.o: $(hdrdir)/ruby/internal/attr/noinline.h
bug.o: $(hdrdir)/ruby/internal/attr/nonnull.h
bug.o: $(hdrdir)/ruby/internal/attr/noreturn.h
+bug.o: $(hdrdir)/ruby/internal/attr/packed_struct.h
bug.o: $(hdrdir)/ruby/internal/attr/pure.h
bug.o: $(hdrdir)/ruby/internal/attr/restrict.h
bug.o: $(hdrdir)/ruby/internal/attr/returns_nonnull.h
@@ -111,7 +112,6 @@ bug.o: $(hdrdir)/ruby/internal/intern/enumerator.h
bug.o: $(hdrdir)/ruby/internal/intern/error.h
bug.o: $(hdrdir)/ruby/internal/intern/eval.h
bug.o: $(hdrdir)/ruby/internal/intern/file.h
-bug.o: $(hdrdir)/ruby/internal/intern/gc.h
bug.o: $(hdrdir)/ruby/internal/intern/hash.h
bug.o: $(hdrdir)/ruby/internal/intern/io.h
bug.o: $(hdrdir)/ruby/internal/intern/load.h
@@ -142,7 +142,6 @@ bug.o: $(hdrdir)/ruby/internal/memory.h
bug.o: $(hdrdir)/ruby/internal/method.h
bug.o: $(hdrdir)/ruby/internal/module.h
bug.o: $(hdrdir)/ruby/internal/newobj.h
-bug.o: $(hdrdir)/ruby/internal/rgengc.h
bug.o: $(hdrdir)/ruby/internal/scan_args.h
bug.o: $(hdrdir)/ruby/internal/special_consts.h
bug.o: $(hdrdir)/ruby/internal/static_assert.h
diff --git a/ext/-test-/num2int/depend b/ext/-test-/num2int/depend
index a3283838dd..4e05d1e8c1 100644
--- a/ext/-test-/num2int/depend
+++ b/ext/-test-/num2int/depend
@@ -52,6 +52,7 @@ num2int.o: $(hdrdir)/ruby/internal/attr/noexcept.h
num2int.o: $(hdrdir)/ruby/internal/attr/noinline.h
num2int.o: $(hdrdir)/ruby/internal/attr/nonnull.h
num2int.o: $(hdrdir)/ruby/internal/attr/noreturn.h
+num2int.o: $(hdrdir)/ruby/internal/attr/packed_struct.h
num2int.o: $(hdrdir)/ruby/internal/attr/pure.h
num2int.o: $(hdrdir)/ruby/internal/attr/restrict.h
num2int.o: $(hdrdir)/ruby/internal/attr/returns_nonnull.h
@@ -111,7 +112,6 @@ num2int.o: $(hdrdir)/ruby/internal/intern/enumerator.h
num2int.o: $(hdrdir)/ruby/internal/intern/error.h
num2int.o: $(hdrdir)/ruby/internal/intern/eval.h
num2int.o: $(hdrdir)/ruby/internal/intern/file.h
-num2int.o: $(hdrdir)/ruby/internal/intern/gc.h
num2int.o: $(hdrdir)/ruby/internal/intern/hash.h
num2int.o: $(hdrdir)/ruby/internal/intern/io.h
num2int.o: $(hdrdir)/ruby/internal/intern/load.h
@@ -142,7 +142,6 @@ num2int.o: $(hdrdir)/ruby/internal/memory.h
num2int.o: $(hdrdir)/ruby/internal/method.h
num2int.o: $(hdrdir)/ruby/internal/module.h
num2int.o: $(hdrdir)/ruby/internal/newobj.h
-num2int.o: $(hdrdir)/ruby/internal/rgengc.h
num2int.o: $(hdrdir)/ruby/internal/scan_args.h
num2int.o: $(hdrdir)/ruby/internal/special_consts.h
num2int.o: $(hdrdir)/ruby/internal/static_assert.h
diff --git a/ext/-test-/path_to_class/depend b/ext/-test-/path_to_class/depend
index 17f8e957c3..8fe6ee37c2 100644
--- a/ext/-test-/path_to_class/depend
+++ b/ext/-test-/path_to_class/depend
@@ -52,6 +52,7 @@ path_to_class.o: $(hdrdir)/ruby/internal/attr/noexcept.h
path_to_class.o: $(hdrdir)/ruby/internal/attr/noinline.h
path_to_class.o: $(hdrdir)/ruby/internal/attr/nonnull.h
path_to_class.o: $(hdrdir)/ruby/internal/attr/noreturn.h
+path_to_class.o: $(hdrdir)/ruby/internal/attr/packed_struct.h
path_to_class.o: $(hdrdir)/ruby/internal/attr/pure.h
path_to_class.o: $(hdrdir)/ruby/internal/attr/restrict.h
path_to_class.o: $(hdrdir)/ruby/internal/attr/returns_nonnull.h
@@ -111,7 +112,6 @@ path_to_class.o: $(hdrdir)/ruby/internal/intern/enumerator.h
path_to_class.o: $(hdrdir)/ruby/internal/intern/error.h
path_to_class.o: $(hdrdir)/ruby/internal/intern/eval.h
path_to_class.o: $(hdrdir)/ruby/internal/intern/file.h
-path_to_class.o: $(hdrdir)/ruby/internal/intern/gc.h
path_to_class.o: $(hdrdir)/ruby/internal/intern/hash.h
path_to_class.o: $(hdrdir)/ruby/internal/intern/io.h
path_to_class.o: $(hdrdir)/ruby/internal/intern/load.h
@@ -142,7 +142,6 @@ path_to_class.o: $(hdrdir)/ruby/internal/memory.h
path_to_class.o: $(hdrdir)/ruby/internal/method.h
path_to_class.o: $(hdrdir)/ruby/internal/module.h
path_to_class.o: $(hdrdir)/ruby/internal/newobj.h
-path_to_class.o: $(hdrdir)/ruby/internal/rgengc.h
path_to_class.o: $(hdrdir)/ruby/internal/scan_args.h
path_to_class.o: $(hdrdir)/ruby/internal/special_consts.h
path_to_class.o: $(hdrdir)/ruby/internal/static_assert.h
diff --git a/ext/-test-/popen_deadlock/depend b/ext/-test-/popen_deadlock/depend
index 22da87f2fe..fb58ca30e9 100644
--- a/ext/-test-/popen_deadlock/depend
+++ b/ext/-test-/popen_deadlock/depend
@@ -52,6 +52,7 @@ infinite_loop_dlsym.o: $(hdrdir)/ruby/internal/attr/noexcept.h
infinite_loop_dlsym.o: $(hdrdir)/ruby/internal/attr/noinline.h
infinite_loop_dlsym.o: $(hdrdir)/ruby/internal/attr/nonnull.h
infinite_loop_dlsym.o: $(hdrdir)/ruby/internal/attr/noreturn.h
+infinite_loop_dlsym.o: $(hdrdir)/ruby/internal/attr/packed_struct.h
infinite_loop_dlsym.o: $(hdrdir)/ruby/internal/attr/pure.h
infinite_loop_dlsym.o: $(hdrdir)/ruby/internal/attr/restrict.h
infinite_loop_dlsym.o: $(hdrdir)/ruby/internal/attr/returns_nonnull.h
@@ -111,7 +112,6 @@ infinite_loop_dlsym.o: $(hdrdir)/ruby/internal/intern/enumerator.h
infinite_loop_dlsym.o: $(hdrdir)/ruby/internal/intern/error.h
infinite_loop_dlsym.o: $(hdrdir)/ruby/internal/intern/eval.h
infinite_loop_dlsym.o: $(hdrdir)/ruby/internal/intern/file.h
-infinite_loop_dlsym.o: $(hdrdir)/ruby/internal/intern/gc.h
infinite_loop_dlsym.o: $(hdrdir)/ruby/internal/intern/hash.h
infinite_loop_dlsym.o: $(hdrdir)/ruby/internal/intern/io.h
infinite_loop_dlsym.o: $(hdrdir)/ruby/internal/intern/load.h
@@ -142,7 +142,6 @@ infinite_loop_dlsym.o: $(hdrdir)/ruby/internal/memory.h
infinite_loop_dlsym.o: $(hdrdir)/ruby/internal/method.h
infinite_loop_dlsym.o: $(hdrdir)/ruby/internal/module.h
infinite_loop_dlsym.o: $(hdrdir)/ruby/internal/newobj.h
-infinite_loop_dlsym.o: $(hdrdir)/ruby/internal/rgengc.h
infinite_loop_dlsym.o: $(hdrdir)/ruby/internal/scan_args.h
infinite_loop_dlsym.o: $(hdrdir)/ruby/internal/special_consts.h
infinite_loop_dlsym.o: $(hdrdir)/ruby/internal/static_assert.h
diff --git a/ext/-test-/postponed_job/depend b/ext/-test-/postponed_job/depend
index 35aca7f2b0..e44d9d51b7 100644
--- a/ext/-test-/postponed_job/depend
+++ b/ext/-test-/postponed_job/depend
@@ -53,6 +53,7 @@ postponed_job.o: $(hdrdir)/ruby/internal/attr/noexcept.h
postponed_job.o: $(hdrdir)/ruby/internal/attr/noinline.h
postponed_job.o: $(hdrdir)/ruby/internal/attr/nonnull.h
postponed_job.o: $(hdrdir)/ruby/internal/attr/noreturn.h
+postponed_job.o: $(hdrdir)/ruby/internal/attr/packed_struct.h
postponed_job.o: $(hdrdir)/ruby/internal/attr/pure.h
postponed_job.o: $(hdrdir)/ruby/internal/attr/restrict.h
postponed_job.o: $(hdrdir)/ruby/internal/attr/returns_nonnull.h
@@ -112,7 +113,6 @@ postponed_job.o: $(hdrdir)/ruby/internal/intern/enumerator.h
postponed_job.o: $(hdrdir)/ruby/internal/intern/error.h
postponed_job.o: $(hdrdir)/ruby/internal/intern/eval.h
postponed_job.o: $(hdrdir)/ruby/internal/intern/file.h
-postponed_job.o: $(hdrdir)/ruby/internal/intern/gc.h
postponed_job.o: $(hdrdir)/ruby/internal/intern/hash.h
postponed_job.o: $(hdrdir)/ruby/internal/intern/io.h
postponed_job.o: $(hdrdir)/ruby/internal/intern/load.h
@@ -143,7 +143,6 @@ postponed_job.o: $(hdrdir)/ruby/internal/memory.h
postponed_job.o: $(hdrdir)/ruby/internal/method.h
postponed_job.o: $(hdrdir)/ruby/internal/module.h
postponed_job.o: $(hdrdir)/ruby/internal/newobj.h
-postponed_job.o: $(hdrdir)/ruby/internal/rgengc.h
postponed_job.o: $(hdrdir)/ruby/internal/scan_args.h
postponed_job.o: $(hdrdir)/ruby/internal/special_consts.h
postponed_job.o: $(hdrdir)/ruby/internal/static_assert.h
diff --git a/ext/-test-/postponed_job/postponed_job.c b/ext/-test-/postponed_job/postponed_job.c
index fa57bef6f5..9ac866ae77 100644
--- a/ext/-test-/postponed_job/postponed_job.c
+++ b/ext/-test-/postponed_job/postponed_job.c
@@ -1,6 +1,29 @@
#include "ruby.h"
#include "ruby/debug.h"
+// We're testing deprecated things, don't print the compiler warnings
+#if 0
+
+#elif defined(_MSC_VER)
+#pragma warning(disable : 4996)
+
+#elif defined(__INTEL_COMPILER)
+#pragma warning(disable : 1786)
+
+#elif defined(__clang__)
+#pragma clang diagnostic ignored "-Wdeprecated-declarations"
+
+#elif defined(__GNUC__)
+#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
+
+#elif defined(__SUNPRO_CC)
+#pragma error_messages (off,symdeprecated)
+
+#else
+// :FIXME: improve here for your compiler.
+
+#endif
+
static int counter;
static void
@@ -58,6 +81,22 @@ pjob_call_direct(VALUE self, VALUE obj)
return self;
}
+static void pjob_noop_callback(void *data) { }
+
+static VALUE
+pjob_register_one_same(VALUE self)
+{
+ rb_gc_start();
+ int r1 = rb_postponed_job_register_one(0, pjob_noop_callback, NULL);
+ int r2 = rb_postponed_job_register_one(0, pjob_noop_callback, NULL);
+ int r3 = rb_postponed_job_register_one(0, pjob_noop_callback, NULL);
+ VALUE ary = rb_ary_new();
+ rb_ary_push(ary, INT2FIX(r1));
+ rb_ary_push(ary, INT2FIX(r2));
+ rb_ary_push(ary, INT2FIX(r3));
+ return ary;
+}
+
#ifdef HAVE_PTHREAD_H
#include <pthread.h>
@@ -86,6 +125,93 @@ pjob_register_in_c_thread(VALUE self, VALUE obj)
}
#endif
+static void
+pjob_preregistered_callback(void *data)
+{
+ VALUE ary = (VALUE)data;
+ Check_Type(ary, T_ARRAY);
+ rb_ary_push(ary, INT2FIX(counter));
+}
+
+static VALUE
+pjob_preregister_and_call_with_sleep(VALUE self, VALUE obj)
+{
+ counter = 0;
+ rb_postponed_job_handle_t h = rb_postponed_job_preregister(0, pjob_preregistered_callback, (void *)obj);
+ counter++;
+ rb_postponed_job_trigger(h);
+ rb_thread_sleep(0);
+ counter++;
+ rb_postponed_job_trigger(h);
+ rb_thread_sleep(0);
+ counter++;
+ rb_postponed_job_trigger(h);
+ rb_thread_sleep(0);
+ return self;
+}
+
+static VALUE
+pjob_preregister_and_call_without_sleep(VALUE self, VALUE obj)
+{
+ counter = 0;
+ rb_postponed_job_handle_t h = rb_postponed_job_preregister(0, pjob_preregistered_callback, (void *)obj);
+ counter = 3;
+ rb_postponed_job_trigger(h);
+ rb_postponed_job_trigger(h);
+ rb_postponed_job_trigger(h);
+ return self;
+}
+
+static VALUE
+pjob_preregister_multiple_times(VALUE self)
+{
+ int r1 = rb_postponed_job_preregister(0, pjob_noop_callback, NULL);
+ int r2 = rb_postponed_job_preregister(0, pjob_noop_callback, NULL);
+ int r3 = rb_postponed_job_preregister(0, pjob_noop_callback, NULL);
+ VALUE ary = rb_ary_new();
+ rb_ary_push(ary, INT2FIX(r1));
+ rb_ary_push(ary, INT2FIX(r2));
+ rb_ary_push(ary, INT2FIX(r3));
+ return ary;
+
+}
+
+struct pjob_append_data_args {
+ VALUE ary;
+ VALUE data;
+};
+
+static void
+pjob_append_data_callback(void *vctx) {
+ struct pjob_append_data_args *ctx = (struct pjob_append_data_args *)vctx;
+ Check_Type(ctx->ary, T_ARRAY);
+ rb_ary_push(ctx->ary, ctx->data);
+}
+
+static VALUE
+pjob_preregister_calls_with_last_argument(VALUE self)
+{
+ VALUE ary = rb_ary_new();
+
+ struct pjob_append_data_args arg1 = { .ary = ary, .data = INT2FIX(1) };
+ struct pjob_append_data_args arg2 = { .ary = ary, .data = INT2FIX(2) };
+ struct pjob_append_data_args arg3 = { .ary = ary, .data = INT2FIX(3) };
+ struct pjob_append_data_args arg4 = { .ary = ary, .data = INT2FIX(4) };
+
+ rb_postponed_job_handle_t h;
+ h = rb_postponed_job_preregister(0, pjob_append_data_callback, &arg1);
+ rb_postponed_job_preregister(0, pjob_append_data_callback, &arg2);
+ rb_postponed_job_trigger(h);
+ rb_postponed_job_preregister(0, pjob_append_data_callback, &arg3);
+ rb_thread_sleep(0); // should execute with arg3
+
+ rb_postponed_job_preregister(0, pjob_append_data_callback, &arg4);
+ rb_postponed_job_trigger(h);
+ rb_thread_sleep(0); // should execute with arg4
+
+ return ary;
+}
+
void
Init_postponed_job(VALUE self)
{
@@ -93,8 +219,13 @@ Init_postponed_job(VALUE self)
rb_define_module_function(mBug, "postponed_job_register", pjob_register, 1);
rb_define_module_function(mBug, "postponed_job_register_one", pjob_register_one, 1);
rb_define_module_function(mBug, "postponed_job_call_direct", pjob_call_direct, 1);
+ rb_define_module_function(mBug, "postponed_job_register_one_same", pjob_register_one_same, 0);
#ifdef HAVE_PTHREAD_H
rb_define_module_function(mBug, "postponed_job_register_in_c_thread", pjob_register_in_c_thread, 1);
#endif
+ rb_define_module_function(mBug, "postponed_job_preregister_and_call_with_sleep", pjob_preregister_and_call_with_sleep, 1);
+ rb_define_module_function(mBug, "postponed_job_preregister_and_call_without_sleep", pjob_preregister_and_call_without_sleep, 1);
+ rb_define_module_function(mBug, "postponed_job_preregister_multiple_times", pjob_preregister_multiple_times, 0);
+ rb_define_module_function(mBug, "postponed_job_preregister_calls_with_last_argument", pjob_preregister_calls_with_last_argument, 0);
}
diff --git a/ext/-test-/printf/depend b/ext/-test-/printf/depend
index 6dfe1fe03d..b397041103 100644
--- a/ext/-test-/printf/depend
+++ b/ext/-test-/printf/depend
@@ -53,6 +53,7 @@ printf.o: $(hdrdir)/ruby/internal/attr/noexcept.h
printf.o: $(hdrdir)/ruby/internal/attr/noinline.h
printf.o: $(hdrdir)/ruby/internal/attr/nonnull.h
printf.o: $(hdrdir)/ruby/internal/attr/noreturn.h
+printf.o: $(hdrdir)/ruby/internal/attr/packed_struct.h
printf.o: $(hdrdir)/ruby/internal/attr/pure.h
printf.o: $(hdrdir)/ruby/internal/attr/restrict.h
printf.o: $(hdrdir)/ruby/internal/attr/returns_nonnull.h
@@ -121,7 +122,6 @@ printf.o: $(hdrdir)/ruby/internal/intern/enumerator.h
printf.o: $(hdrdir)/ruby/internal/intern/error.h
printf.o: $(hdrdir)/ruby/internal/intern/eval.h
printf.o: $(hdrdir)/ruby/internal/intern/file.h
-printf.o: $(hdrdir)/ruby/internal/intern/gc.h
printf.o: $(hdrdir)/ruby/internal/intern/hash.h
printf.o: $(hdrdir)/ruby/internal/intern/io.h
printf.o: $(hdrdir)/ruby/internal/intern/load.h
@@ -152,7 +152,6 @@ printf.o: $(hdrdir)/ruby/internal/memory.h
printf.o: $(hdrdir)/ruby/internal/method.h
printf.o: $(hdrdir)/ruby/internal/module.h
printf.o: $(hdrdir)/ruby/internal/newobj.h
-printf.o: $(hdrdir)/ruby/internal/rgengc.h
printf.o: $(hdrdir)/ruby/internal/scan_args.h
printf.o: $(hdrdir)/ruby/internal/special_consts.h
printf.o: $(hdrdir)/ruby/internal/static_assert.h
diff --git a/ext/-test-/proc/depend b/ext/-test-/proc/depend
index e3f1cf6ce9..7e78aa6f83 100644
--- a/ext/-test-/proc/depend
+++ b/ext/-test-/proc/depend
@@ -52,6 +52,7 @@ init.o: $(hdrdir)/ruby/internal/attr/noexcept.h
init.o: $(hdrdir)/ruby/internal/attr/noinline.h
init.o: $(hdrdir)/ruby/internal/attr/nonnull.h
init.o: $(hdrdir)/ruby/internal/attr/noreturn.h
+init.o: $(hdrdir)/ruby/internal/attr/packed_struct.h
init.o: $(hdrdir)/ruby/internal/attr/pure.h
init.o: $(hdrdir)/ruby/internal/attr/restrict.h
init.o: $(hdrdir)/ruby/internal/attr/returns_nonnull.h
@@ -111,7 +112,6 @@ init.o: $(hdrdir)/ruby/internal/intern/enumerator.h
init.o: $(hdrdir)/ruby/internal/intern/error.h
init.o: $(hdrdir)/ruby/internal/intern/eval.h
init.o: $(hdrdir)/ruby/internal/intern/file.h
-init.o: $(hdrdir)/ruby/internal/intern/gc.h
init.o: $(hdrdir)/ruby/internal/intern/hash.h
init.o: $(hdrdir)/ruby/internal/intern/io.h
init.o: $(hdrdir)/ruby/internal/intern/load.h
@@ -142,7 +142,6 @@ init.o: $(hdrdir)/ruby/internal/memory.h
init.o: $(hdrdir)/ruby/internal/method.h
init.o: $(hdrdir)/ruby/internal/module.h
init.o: $(hdrdir)/ruby/internal/newobj.h
-init.o: $(hdrdir)/ruby/internal/rgengc.h
init.o: $(hdrdir)/ruby/internal/scan_args.h
init.o: $(hdrdir)/ruby/internal/special_consts.h
init.o: $(hdrdir)/ruby/internal/static_assert.h
@@ -212,6 +211,7 @@ receiver.o: $(hdrdir)/ruby/internal/attr/noexcept.h
receiver.o: $(hdrdir)/ruby/internal/attr/noinline.h
receiver.o: $(hdrdir)/ruby/internal/attr/nonnull.h
receiver.o: $(hdrdir)/ruby/internal/attr/noreturn.h
+receiver.o: $(hdrdir)/ruby/internal/attr/packed_struct.h
receiver.o: $(hdrdir)/ruby/internal/attr/pure.h
receiver.o: $(hdrdir)/ruby/internal/attr/restrict.h
receiver.o: $(hdrdir)/ruby/internal/attr/returns_nonnull.h
@@ -271,7 +271,6 @@ receiver.o: $(hdrdir)/ruby/internal/intern/enumerator.h
receiver.o: $(hdrdir)/ruby/internal/intern/error.h
receiver.o: $(hdrdir)/ruby/internal/intern/eval.h
receiver.o: $(hdrdir)/ruby/internal/intern/file.h
-receiver.o: $(hdrdir)/ruby/internal/intern/gc.h
receiver.o: $(hdrdir)/ruby/internal/intern/hash.h
receiver.o: $(hdrdir)/ruby/internal/intern/io.h
receiver.o: $(hdrdir)/ruby/internal/intern/load.h
@@ -302,7 +301,6 @@ receiver.o: $(hdrdir)/ruby/internal/memory.h
receiver.o: $(hdrdir)/ruby/internal/method.h
receiver.o: $(hdrdir)/ruby/internal/module.h
receiver.o: $(hdrdir)/ruby/internal/newobj.h
-receiver.o: $(hdrdir)/ruby/internal/rgengc.h
receiver.o: $(hdrdir)/ruby/internal/scan_args.h
receiver.o: $(hdrdir)/ruby/internal/special_consts.h
receiver.o: $(hdrdir)/ruby/internal/static_assert.h
@@ -372,6 +370,7 @@ super.o: $(hdrdir)/ruby/internal/attr/noexcept.h
super.o: $(hdrdir)/ruby/internal/attr/noinline.h
super.o: $(hdrdir)/ruby/internal/attr/nonnull.h
super.o: $(hdrdir)/ruby/internal/attr/noreturn.h
+super.o: $(hdrdir)/ruby/internal/attr/packed_struct.h
super.o: $(hdrdir)/ruby/internal/attr/pure.h
super.o: $(hdrdir)/ruby/internal/attr/restrict.h
super.o: $(hdrdir)/ruby/internal/attr/returns_nonnull.h
@@ -431,7 +430,6 @@ super.o: $(hdrdir)/ruby/internal/intern/enumerator.h
super.o: $(hdrdir)/ruby/internal/intern/error.h
super.o: $(hdrdir)/ruby/internal/intern/eval.h
super.o: $(hdrdir)/ruby/internal/intern/file.h
-super.o: $(hdrdir)/ruby/internal/intern/gc.h
super.o: $(hdrdir)/ruby/internal/intern/hash.h
super.o: $(hdrdir)/ruby/internal/intern/io.h
super.o: $(hdrdir)/ruby/internal/intern/load.h
@@ -462,7 +460,6 @@ super.o: $(hdrdir)/ruby/internal/memory.h
super.o: $(hdrdir)/ruby/internal/method.h
super.o: $(hdrdir)/ruby/internal/module.h
super.o: $(hdrdir)/ruby/internal/newobj.h
-super.o: $(hdrdir)/ruby/internal/rgengc.h
super.o: $(hdrdir)/ruby/internal/scan_args.h
super.o: $(hdrdir)/ruby/internal/special_consts.h
super.o: $(hdrdir)/ruby/internal/static_assert.h
diff --git a/ext/-test-/random/depend b/ext/-test-/random/depend
index f2cbf7fc14..3f9a52be44 100644
--- a/ext/-test-/random/depend
+++ b/ext/-test-/random/depend
@@ -51,6 +51,7 @@ bad_version.o: $(hdrdir)/ruby/internal/attr/noexcept.h
bad_version.o: $(hdrdir)/ruby/internal/attr/noinline.h
bad_version.o: $(hdrdir)/ruby/internal/attr/nonnull.h
bad_version.o: $(hdrdir)/ruby/internal/attr/noreturn.h
+bad_version.o: $(hdrdir)/ruby/internal/attr/packed_struct.h
bad_version.o: $(hdrdir)/ruby/internal/attr/pure.h
bad_version.o: $(hdrdir)/ruby/internal/attr/restrict.h
bad_version.o: $(hdrdir)/ruby/internal/attr/returns_nonnull.h
@@ -110,7 +111,6 @@ bad_version.o: $(hdrdir)/ruby/internal/intern/enumerator.h
bad_version.o: $(hdrdir)/ruby/internal/intern/error.h
bad_version.o: $(hdrdir)/ruby/internal/intern/eval.h
bad_version.o: $(hdrdir)/ruby/internal/intern/file.h
-bad_version.o: $(hdrdir)/ruby/internal/intern/gc.h
bad_version.o: $(hdrdir)/ruby/internal/intern/hash.h
bad_version.o: $(hdrdir)/ruby/internal/intern/io.h
bad_version.o: $(hdrdir)/ruby/internal/intern/load.h
@@ -141,7 +141,6 @@ bad_version.o: $(hdrdir)/ruby/internal/memory.h
bad_version.o: $(hdrdir)/ruby/internal/method.h
bad_version.o: $(hdrdir)/ruby/internal/module.h
bad_version.o: $(hdrdir)/ruby/internal/newobj.h
-bad_version.o: $(hdrdir)/ruby/internal/rgengc.h
bad_version.o: $(hdrdir)/ruby/internal/scan_args.h
bad_version.o: $(hdrdir)/ruby/internal/special_consts.h
bad_version.o: $(hdrdir)/ruby/internal/static_assert.h
@@ -212,6 +211,7 @@ init.o: $(hdrdir)/ruby/internal/attr/noexcept.h
init.o: $(hdrdir)/ruby/internal/attr/noinline.h
init.o: $(hdrdir)/ruby/internal/attr/nonnull.h
init.o: $(hdrdir)/ruby/internal/attr/noreturn.h
+init.o: $(hdrdir)/ruby/internal/attr/packed_struct.h
init.o: $(hdrdir)/ruby/internal/attr/pure.h
init.o: $(hdrdir)/ruby/internal/attr/restrict.h
init.o: $(hdrdir)/ruby/internal/attr/returns_nonnull.h
@@ -271,7 +271,6 @@ init.o: $(hdrdir)/ruby/internal/intern/enumerator.h
init.o: $(hdrdir)/ruby/internal/intern/error.h
init.o: $(hdrdir)/ruby/internal/intern/eval.h
init.o: $(hdrdir)/ruby/internal/intern/file.h
-init.o: $(hdrdir)/ruby/internal/intern/gc.h
init.o: $(hdrdir)/ruby/internal/intern/hash.h
init.o: $(hdrdir)/ruby/internal/intern/io.h
init.o: $(hdrdir)/ruby/internal/intern/load.h
@@ -302,7 +301,6 @@ init.o: $(hdrdir)/ruby/internal/memory.h
init.o: $(hdrdir)/ruby/internal/method.h
init.o: $(hdrdir)/ruby/internal/module.h
init.o: $(hdrdir)/ruby/internal/newobj.h
-init.o: $(hdrdir)/ruby/internal/rgengc.h
init.o: $(hdrdir)/ruby/internal/scan_args.h
init.o: $(hdrdir)/ruby/internal/special_consts.h
init.o: $(hdrdir)/ruby/internal/static_assert.h
@@ -371,6 +369,7 @@ loop.o: $(hdrdir)/ruby/internal/attr/noexcept.h
loop.o: $(hdrdir)/ruby/internal/attr/noinline.h
loop.o: $(hdrdir)/ruby/internal/attr/nonnull.h
loop.o: $(hdrdir)/ruby/internal/attr/noreturn.h
+loop.o: $(hdrdir)/ruby/internal/attr/packed_struct.h
loop.o: $(hdrdir)/ruby/internal/attr/pure.h
loop.o: $(hdrdir)/ruby/internal/attr/restrict.h
loop.o: $(hdrdir)/ruby/internal/attr/returns_nonnull.h
@@ -430,7 +429,6 @@ loop.o: $(hdrdir)/ruby/internal/intern/enumerator.h
loop.o: $(hdrdir)/ruby/internal/intern/error.h
loop.o: $(hdrdir)/ruby/internal/intern/eval.h
loop.o: $(hdrdir)/ruby/internal/intern/file.h
-loop.o: $(hdrdir)/ruby/internal/intern/gc.h
loop.o: $(hdrdir)/ruby/internal/intern/hash.h
loop.o: $(hdrdir)/ruby/internal/intern/io.h
loop.o: $(hdrdir)/ruby/internal/intern/load.h
@@ -461,7 +459,6 @@ loop.o: $(hdrdir)/ruby/internal/memory.h
loop.o: $(hdrdir)/ruby/internal/method.h
loop.o: $(hdrdir)/ruby/internal/module.h
loop.o: $(hdrdir)/ruby/internal/newobj.h
-loop.o: $(hdrdir)/ruby/internal/rgengc.h
loop.o: $(hdrdir)/ruby/internal/scan_args.h
loop.o: $(hdrdir)/ruby/internal/special_consts.h
loop.o: $(hdrdir)/ruby/internal/static_assert.h
diff --git a/ext/-test-/rational/depend b/ext/-test-/rational/depend
index ce977821b8..cff2eae38d 100644
--- a/ext/-test-/rational/depend
+++ b/ext/-test-/rational/depend
@@ -56,6 +56,7 @@ rat.o: $(hdrdir)/ruby/internal/attr/noexcept.h
rat.o: $(hdrdir)/ruby/internal/attr/noinline.h
rat.o: $(hdrdir)/ruby/internal/attr/nonnull.h
rat.o: $(hdrdir)/ruby/internal/attr/noreturn.h
+rat.o: $(hdrdir)/ruby/internal/attr/packed_struct.h
rat.o: $(hdrdir)/ruby/internal/attr/pure.h
rat.o: $(hdrdir)/ruby/internal/attr/restrict.h
rat.o: $(hdrdir)/ruby/internal/attr/returns_nonnull.h
@@ -115,7 +116,6 @@ rat.o: $(hdrdir)/ruby/internal/intern/enumerator.h
rat.o: $(hdrdir)/ruby/internal/intern/error.h
rat.o: $(hdrdir)/ruby/internal/intern/eval.h
rat.o: $(hdrdir)/ruby/internal/intern/file.h
-rat.o: $(hdrdir)/ruby/internal/intern/gc.h
rat.o: $(hdrdir)/ruby/internal/intern/hash.h
rat.o: $(hdrdir)/ruby/internal/intern/io.h
rat.o: $(hdrdir)/ruby/internal/intern/load.h
@@ -146,7 +146,6 @@ rat.o: $(hdrdir)/ruby/internal/memory.h
rat.o: $(hdrdir)/ruby/internal/method.h
rat.o: $(hdrdir)/ruby/internal/module.h
rat.o: $(hdrdir)/ruby/internal/newobj.h
-rat.o: $(hdrdir)/ruby/internal/rgengc.h
rat.o: $(hdrdir)/ruby/internal/scan_args.h
rat.o: $(hdrdir)/ruby/internal/special_consts.h
rat.o: $(hdrdir)/ruby/internal/static_assert.h
diff --git a/ext/-test-/rb_call_super_kw/depend b/ext/-test-/rb_call_super_kw/depend
index 3512a081c9..a42ddc85ac 100644
--- a/ext/-test-/rb_call_super_kw/depend
+++ b/ext/-test-/rb_call_super_kw/depend
@@ -52,6 +52,7 @@ rb_call_super_kw.o: $(hdrdir)/ruby/internal/attr/noexcept.h
rb_call_super_kw.o: $(hdrdir)/ruby/internal/attr/noinline.h
rb_call_super_kw.o: $(hdrdir)/ruby/internal/attr/nonnull.h
rb_call_super_kw.o: $(hdrdir)/ruby/internal/attr/noreturn.h
+rb_call_super_kw.o: $(hdrdir)/ruby/internal/attr/packed_struct.h
rb_call_super_kw.o: $(hdrdir)/ruby/internal/attr/pure.h
rb_call_super_kw.o: $(hdrdir)/ruby/internal/attr/restrict.h
rb_call_super_kw.o: $(hdrdir)/ruby/internal/attr/returns_nonnull.h
@@ -111,7 +112,6 @@ rb_call_super_kw.o: $(hdrdir)/ruby/internal/intern/enumerator.h
rb_call_super_kw.o: $(hdrdir)/ruby/internal/intern/error.h
rb_call_super_kw.o: $(hdrdir)/ruby/internal/intern/eval.h
rb_call_super_kw.o: $(hdrdir)/ruby/internal/intern/file.h
-rb_call_super_kw.o: $(hdrdir)/ruby/internal/intern/gc.h
rb_call_super_kw.o: $(hdrdir)/ruby/internal/intern/hash.h
rb_call_super_kw.o: $(hdrdir)/ruby/internal/intern/io.h
rb_call_super_kw.o: $(hdrdir)/ruby/internal/intern/load.h
@@ -142,7 +142,6 @@ rb_call_super_kw.o: $(hdrdir)/ruby/internal/memory.h
rb_call_super_kw.o: $(hdrdir)/ruby/internal/method.h
rb_call_super_kw.o: $(hdrdir)/ruby/internal/module.h
rb_call_super_kw.o: $(hdrdir)/ruby/internal/newobj.h
-rb_call_super_kw.o: $(hdrdir)/ruby/internal/rgengc.h
rb_call_super_kw.o: $(hdrdir)/ruby/internal/scan_args.h
rb_call_super_kw.o: $(hdrdir)/ruby/internal/special_consts.h
rb_call_super_kw.o: $(hdrdir)/ruby/internal/static_assert.h
diff --git a/ext/-test-/recursion/depend b/ext/-test-/recursion/depend
index e499f95e73..49377250ef 100644
--- a/ext/-test-/recursion/depend
+++ b/ext/-test-/recursion/depend
@@ -52,6 +52,7 @@ recursion.o: $(hdrdir)/ruby/internal/attr/noexcept.h
recursion.o: $(hdrdir)/ruby/internal/attr/noinline.h
recursion.o: $(hdrdir)/ruby/internal/attr/nonnull.h
recursion.o: $(hdrdir)/ruby/internal/attr/noreturn.h
+recursion.o: $(hdrdir)/ruby/internal/attr/packed_struct.h
recursion.o: $(hdrdir)/ruby/internal/attr/pure.h
recursion.o: $(hdrdir)/ruby/internal/attr/restrict.h
recursion.o: $(hdrdir)/ruby/internal/attr/returns_nonnull.h
@@ -111,7 +112,6 @@ recursion.o: $(hdrdir)/ruby/internal/intern/enumerator.h
recursion.o: $(hdrdir)/ruby/internal/intern/error.h
recursion.o: $(hdrdir)/ruby/internal/intern/eval.h
recursion.o: $(hdrdir)/ruby/internal/intern/file.h
-recursion.o: $(hdrdir)/ruby/internal/intern/gc.h
recursion.o: $(hdrdir)/ruby/internal/intern/hash.h
recursion.o: $(hdrdir)/ruby/internal/intern/io.h
recursion.o: $(hdrdir)/ruby/internal/intern/load.h
@@ -142,7 +142,6 @@ recursion.o: $(hdrdir)/ruby/internal/memory.h
recursion.o: $(hdrdir)/ruby/internal/method.h
recursion.o: $(hdrdir)/ruby/internal/module.h
recursion.o: $(hdrdir)/ruby/internal/newobj.h
-recursion.o: $(hdrdir)/ruby/internal/rgengc.h
recursion.o: $(hdrdir)/ruby/internal/scan_args.h
recursion.o: $(hdrdir)/ruby/internal/special_consts.h
recursion.o: $(hdrdir)/ruby/internal/static_assert.h
diff --git a/ext/-test-/regexp/depend b/ext/-test-/regexp/depend
index fa431e013a..484f0320dd 100644
--- a/ext/-test-/regexp/depend
+++ b/ext/-test-/regexp/depend
@@ -52,6 +52,7 @@ init.o: $(hdrdir)/ruby/internal/attr/noexcept.h
init.o: $(hdrdir)/ruby/internal/attr/noinline.h
init.o: $(hdrdir)/ruby/internal/attr/nonnull.h
init.o: $(hdrdir)/ruby/internal/attr/noreturn.h
+init.o: $(hdrdir)/ruby/internal/attr/packed_struct.h
init.o: $(hdrdir)/ruby/internal/attr/pure.h
init.o: $(hdrdir)/ruby/internal/attr/restrict.h
init.o: $(hdrdir)/ruby/internal/attr/returns_nonnull.h
@@ -111,7 +112,6 @@ init.o: $(hdrdir)/ruby/internal/intern/enumerator.h
init.o: $(hdrdir)/ruby/internal/intern/error.h
init.o: $(hdrdir)/ruby/internal/intern/eval.h
init.o: $(hdrdir)/ruby/internal/intern/file.h
-init.o: $(hdrdir)/ruby/internal/intern/gc.h
init.o: $(hdrdir)/ruby/internal/intern/hash.h
init.o: $(hdrdir)/ruby/internal/intern/io.h
init.o: $(hdrdir)/ruby/internal/intern/load.h
@@ -142,7 +142,6 @@ init.o: $(hdrdir)/ruby/internal/memory.h
init.o: $(hdrdir)/ruby/internal/method.h
init.o: $(hdrdir)/ruby/internal/module.h
init.o: $(hdrdir)/ruby/internal/newobj.h
-init.o: $(hdrdir)/ruby/internal/rgengc.h
init.o: $(hdrdir)/ruby/internal/scan_args.h
init.o: $(hdrdir)/ruby/internal/special_consts.h
init.o: $(hdrdir)/ruby/internal/static_assert.h
@@ -212,6 +211,7 @@ parse_depth_limit.o: $(hdrdir)/ruby/internal/attr/noexcept.h
parse_depth_limit.o: $(hdrdir)/ruby/internal/attr/noinline.h
parse_depth_limit.o: $(hdrdir)/ruby/internal/attr/nonnull.h
parse_depth_limit.o: $(hdrdir)/ruby/internal/attr/noreturn.h
+parse_depth_limit.o: $(hdrdir)/ruby/internal/attr/packed_struct.h
parse_depth_limit.o: $(hdrdir)/ruby/internal/attr/pure.h
parse_depth_limit.o: $(hdrdir)/ruby/internal/attr/restrict.h
parse_depth_limit.o: $(hdrdir)/ruby/internal/attr/returns_nonnull.h
@@ -271,7 +271,6 @@ parse_depth_limit.o: $(hdrdir)/ruby/internal/intern/enumerator.h
parse_depth_limit.o: $(hdrdir)/ruby/internal/intern/error.h
parse_depth_limit.o: $(hdrdir)/ruby/internal/intern/eval.h
parse_depth_limit.o: $(hdrdir)/ruby/internal/intern/file.h
-parse_depth_limit.o: $(hdrdir)/ruby/internal/intern/gc.h
parse_depth_limit.o: $(hdrdir)/ruby/internal/intern/hash.h
parse_depth_limit.o: $(hdrdir)/ruby/internal/intern/io.h
parse_depth_limit.o: $(hdrdir)/ruby/internal/intern/load.h
@@ -302,7 +301,6 @@ parse_depth_limit.o: $(hdrdir)/ruby/internal/memory.h
parse_depth_limit.o: $(hdrdir)/ruby/internal/method.h
parse_depth_limit.o: $(hdrdir)/ruby/internal/module.h
parse_depth_limit.o: $(hdrdir)/ruby/internal/newobj.h
-parse_depth_limit.o: $(hdrdir)/ruby/internal/rgengc.h
parse_depth_limit.o: $(hdrdir)/ruby/internal/scan_args.h
parse_depth_limit.o: $(hdrdir)/ruby/internal/special_consts.h
parse_depth_limit.o: $(hdrdir)/ruby/internal/static_assert.h
diff --git a/ext/-test-/scan_args/depend b/ext/-test-/scan_args/depend
index 2194936b04..3bedc6a7cf 100644
--- a/ext/-test-/scan_args/depend
+++ b/ext/-test-/scan_args/depend
@@ -52,6 +52,7 @@ scan_args.o: $(hdrdir)/ruby/internal/attr/noexcept.h
scan_args.o: $(hdrdir)/ruby/internal/attr/noinline.h
scan_args.o: $(hdrdir)/ruby/internal/attr/nonnull.h
scan_args.o: $(hdrdir)/ruby/internal/attr/noreturn.h
+scan_args.o: $(hdrdir)/ruby/internal/attr/packed_struct.h
scan_args.o: $(hdrdir)/ruby/internal/attr/pure.h
scan_args.o: $(hdrdir)/ruby/internal/attr/restrict.h
scan_args.o: $(hdrdir)/ruby/internal/attr/returns_nonnull.h
@@ -111,7 +112,6 @@ scan_args.o: $(hdrdir)/ruby/internal/intern/enumerator.h
scan_args.o: $(hdrdir)/ruby/internal/intern/error.h
scan_args.o: $(hdrdir)/ruby/internal/intern/eval.h
scan_args.o: $(hdrdir)/ruby/internal/intern/file.h
-scan_args.o: $(hdrdir)/ruby/internal/intern/gc.h
scan_args.o: $(hdrdir)/ruby/internal/intern/hash.h
scan_args.o: $(hdrdir)/ruby/internal/intern/io.h
scan_args.o: $(hdrdir)/ruby/internal/intern/load.h
@@ -142,7 +142,6 @@ scan_args.o: $(hdrdir)/ruby/internal/memory.h
scan_args.o: $(hdrdir)/ruby/internal/method.h
scan_args.o: $(hdrdir)/ruby/internal/module.h
scan_args.o: $(hdrdir)/ruby/internal/newobj.h
-scan_args.o: $(hdrdir)/ruby/internal/rgengc.h
scan_args.o: $(hdrdir)/ruby/internal/scan_args.h
scan_args.o: $(hdrdir)/ruby/internal/special_consts.h
scan_args.o: $(hdrdir)/ruby/internal/static_assert.h
diff --git a/ext/-test-/st/foreach/depend b/ext/-test-/st/foreach/depend
index 0464ee3c53..fdfe356805 100644
--- a/ext/-test-/st/foreach/depend
+++ b/ext/-test-/st/foreach/depend
@@ -52,6 +52,7 @@ foreach.o: $(hdrdir)/ruby/internal/attr/noexcept.h
foreach.o: $(hdrdir)/ruby/internal/attr/noinline.h
foreach.o: $(hdrdir)/ruby/internal/attr/nonnull.h
foreach.o: $(hdrdir)/ruby/internal/attr/noreturn.h
+foreach.o: $(hdrdir)/ruby/internal/attr/packed_struct.h
foreach.o: $(hdrdir)/ruby/internal/attr/pure.h
foreach.o: $(hdrdir)/ruby/internal/attr/restrict.h
foreach.o: $(hdrdir)/ruby/internal/attr/returns_nonnull.h
@@ -111,7 +112,6 @@ foreach.o: $(hdrdir)/ruby/internal/intern/enumerator.h
foreach.o: $(hdrdir)/ruby/internal/intern/error.h
foreach.o: $(hdrdir)/ruby/internal/intern/eval.h
foreach.o: $(hdrdir)/ruby/internal/intern/file.h
-foreach.o: $(hdrdir)/ruby/internal/intern/gc.h
foreach.o: $(hdrdir)/ruby/internal/intern/hash.h
foreach.o: $(hdrdir)/ruby/internal/intern/io.h
foreach.o: $(hdrdir)/ruby/internal/intern/load.h
@@ -142,7 +142,6 @@ foreach.o: $(hdrdir)/ruby/internal/memory.h
foreach.o: $(hdrdir)/ruby/internal/method.h
foreach.o: $(hdrdir)/ruby/internal/module.h
foreach.o: $(hdrdir)/ruby/internal/newobj.h
-foreach.o: $(hdrdir)/ruby/internal/rgengc.h
foreach.o: $(hdrdir)/ruby/internal/scan_args.h
foreach.o: $(hdrdir)/ruby/internal/special_consts.h
foreach.o: $(hdrdir)/ruby/internal/static_assert.h
diff --git a/ext/-test-/st/foreach/foreach.c b/ext/-test-/st/foreach/foreach.c
index cde49fb26d..7fbf064694 100644
--- a/ext/-test-/st/foreach/foreach.c
+++ b/ext/-test-/st/foreach/foreach.c
@@ -14,20 +14,20 @@ force_unpack_check(struct checker *c, st_data_t key, st_data_t val)
if (c->nr == 0) {
st_data_t i;
- if (c->tbl->bins != NULL) rb_bug("should be packed\n");
+ if (c->tbl->bins != NULL) rb_bug("should be packed");
/* force unpacking during iteration: */
for (i = 1; i < expect_size; i++)
st_add_direct(c->tbl, i, i);
- if (c->tbl->bins == NULL) rb_bug("should be unpacked\n");
+ if (c->tbl->bins == NULL) rb_bug("should be unpacked");
}
if (key != c->nr) {
- rb_bug("unexpected key: %"PRIuVALUE" (expected %"PRIuVALUE")\n", (VALUE)key, (VALUE)c->nr);
+ rb_bug("unexpected key: %"PRIuVALUE" (expected %"PRIuVALUE")", (VALUE)key, (VALUE)c->nr);
}
if (val != c->nr) {
- rb_bug("unexpected val: %"PRIuVALUE" (expected %"PRIuVALUE")\n", (VALUE)val, (VALUE)c->nr);
+ rb_bug("unexpected val: %"PRIuVALUE" (expected %"PRIuVALUE")", (VALUE)val, (VALUE)c->nr);
}
c->nr++;
@@ -60,7 +60,7 @@ unp_fec_i(st_data_t key, st_data_t val, st_data_t args, int error)
st_data_t v;
if (!st_delete(c->tbl, &k, &v)) {
- rb_bug("failed to delete\n");
+ rb_bug("failed to delete");
}
if (v != 0) {
rb_bug("unexpected value deleted: %"PRIuVALUE" (expected 0)", (VALUE)v);
@@ -84,21 +84,21 @@ unp_fec(VALUE self, VALUE test)
st_add_direct(tbl, 0, 0);
- if (tbl->bins != NULL) rb_bug("should still be packed\n");
+ if (tbl->bins != NULL) rb_bug("should still be packed");
st_foreach_check(tbl, unp_fec_i, (st_data_t)&c, -1);
if (c.test == ID2SYM(rb_intern("delete2"))) {
if (c.nr != 1) {
- rb_bug("mismatched iteration: %"PRIuVALUE" (expected 1)\n", (VALUE)c.nr);
+ rb_bug("mismatched iteration: %"PRIuVALUE" (expected 1)", (VALUE)c.nr);
}
}
else if (c.nr != expect_size) {
- rb_bug("mismatched iteration: %"PRIuVALUE" (expected %"PRIuVALUE")\n",
+ rb_bug("mismatched iteration: %"PRIuVALUE" (expected %"PRIuVALUE")",
(VALUE)c.nr, (VALUE)expect_size);
}
- if (tbl->bins == NULL) rb_bug("should be unpacked\n");
+ if (tbl->bins == NULL) rb_bug("should be unpacked");
st_free_table(tbl);
@@ -120,14 +120,14 @@ unp_fe_i(st_data_t key, st_data_t val, st_data_t args)
st_data_t v;
if (!st_delete(c->tbl, &k, &v)) {
- rb_bug("failed to delete\n");
+ rb_bug("failed to delete");
}
if (v != 0) {
rb_bug("unexpected value deleted: %"PRIuVALUE" (expected 0)", (VALUE)v);
}
return ST_CONTINUE;
}
- rb_bug("should never get here\n");
+ rb_bug("should never get here");
}
rb_raise(rb_eArgError, "unexpected arg: %+"PRIsVALUE, c->test);
@@ -145,21 +145,21 @@ unp_fe(VALUE self, VALUE test)
st_add_direct(tbl, 0, 0);
- if (tbl->bins != NULL) rb_bug("should still be packed\n");
+ if (tbl->bins != NULL) rb_bug("should still be packed");
st_foreach(tbl, unp_fe_i, (st_data_t)&c);
if (c.test == ID2SYM(rb_intern("unpack_delete"))) {
if (c.nr != 1) {
- rb_bug("mismatched iteration: %"PRIuVALUE" (expected 1)\n", (VALUE)c.nr);
+ rb_bug("mismatched iteration: %"PRIuVALUE" (expected 1)", (VALUE)c.nr);
}
}
else if (c.nr != expect_size) {
- rb_bug("mismatched iteration: %"PRIuVALUE" (expected %"PRIuVALUE"o)\n",
+ rb_bug("mismatched iteration: %"PRIuVALUE" (expected %"PRIuVALUE"o)",
(VALUE)c.nr, (VALUE)expect_size);
}
- if (tbl->bins == NULL) rb_bug("should be unpacked\n");
+ if (tbl->bins == NULL) rb_bug("should be unpacked");
st_free_table(tbl);
diff --git a/ext/-test-/st/numhash/depend b/ext/-test-/st/numhash/depend
index 9665ed6e39..ef28c892f3 100644
--- a/ext/-test-/st/numhash/depend
+++ b/ext/-test-/st/numhash/depend
@@ -52,6 +52,7 @@ numhash.o: $(hdrdir)/ruby/internal/attr/noexcept.h
numhash.o: $(hdrdir)/ruby/internal/attr/noinline.h
numhash.o: $(hdrdir)/ruby/internal/attr/nonnull.h
numhash.o: $(hdrdir)/ruby/internal/attr/noreturn.h
+numhash.o: $(hdrdir)/ruby/internal/attr/packed_struct.h
numhash.o: $(hdrdir)/ruby/internal/attr/pure.h
numhash.o: $(hdrdir)/ruby/internal/attr/restrict.h
numhash.o: $(hdrdir)/ruby/internal/attr/returns_nonnull.h
@@ -111,7 +112,6 @@ numhash.o: $(hdrdir)/ruby/internal/intern/enumerator.h
numhash.o: $(hdrdir)/ruby/internal/intern/error.h
numhash.o: $(hdrdir)/ruby/internal/intern/eval.h
numhash.o: $(hdrdir)/ruby/internal/intern/file.h
-numhash.o: $(hdrdir)/ruby/internal/intern/gc.h
numhash.o: $(hdrdir)/ruby/internal/intern/hash.h
numhash.o: $(hdrdir)/ruby/internal/intern/io.h
numhash.o: $(hdrdir)/ruby/internal/intern/load.h
@@ -142,7 +142,6 @@ numhash.o: $(hdrdir)/ruby/internal/memory.h
numhash.o: $(hdrdir)/ruby/internal/method.h
numhash.o: $(hdrdir)/ruby/internal/module.h
numhash.o: $(hdrdir)/ruby/internal/newobj.h
-numhash.o: $(hdrdir)/ruby/internal/rgengc.h
numhash.o: $(hdrdir)/ruby/internal/scan_args.h
numhash.o: $(hdrdir)/ruby/internal/special_consts.h
numhash.o: $(hdrdir)/ruby/internal/static_assert.h
diff --git a/ext/-test-/st/update/depend b/ext/-test-/st/update/depend
index 01960df965..2d5ff224a2 100644
--- a/ext/-test-/st/update/depend
+++ b/ext/-test-/st/update/depend
@@ -52,6 +52,7 @@ update.o: $(hdrdir)/ruby/internal/attr/noexcept.h
update.o: $(hdrdir)/ruby/internal/attr/noinline.h
update.o: $(hdrdir)/ruby/internal/attr/nonnull.h
update.o: $(hdrdir)/ruby/internal/attr/noreturn.h
+update.o: $(hdrdir)/ruby/internal/attr/packed_struct.h
update.o: $(hdrdir)/ruby/internal/attr/pure.h
update.o: $(hdrdir)/ruby/internal/attr/restrict.h
update.o: $(hdrdir)/ruby/internal/attr/returns_nonnull.h
@@ -111,7 +112,6 @@ update.o: $(hdrdir)/ruby/internal/intern/enumerator.h
update.o: $(hdrdir)/ruby/internal/intern/error.h
update.o: $(hdrdir)/ruby/internal/intern/eval.h
update.o: $(hdrdir)/ruby/internal/intern/file.h
-update.o: $(hdrdir)/ruby/internal/intern/gc.h
update.o: $(hdrdir)/ruby/internal/intern/hash.h
update.o: $(hdrdir)/ruby/internal/intern/io.h
update.o: $(hdrdir)/ruby/internal/intern/load.h
@@ -142,7 +142,6 @@ update.o: $(hdrdir)/ruby/internal/memory.h
update.o: $(hdrdir)/ruby/internal/method.h
update.o: $(hdrdir)/ruby/internal/module.h
update.o: $(hdrdir)/ruby/internal/newobj.h
-update.o: $(hdrdir)/ruby/internal/rgengc.h
update.o: $(hdrdir)/ruby/internal/scan_args.h
update.o: $(hdrdir)/ruby/internal/special_consts.h
update.o: $(hdrdir)/ruby/internal/static_assert.h
diff --git a/ext/-test-/string/cstr.c b/ext/-test-/string/cstr.c
index 468ee7a3b1..b0b1ef5374 100644
--- a/ext/-test-/string/cstr.c
+++ b/ext/-test-/string/cstr.c
@@ -61,18 +61,12 @@ bug_str_unterminated_substring(VALUE str, VALUE vbeg, VALUE vlen)
if (RSTRING_LEN(str) < beg) rb_raise(rb_eIndexError, "beg: %ld", beg);
if (RSTRING_LEN(str) < beg + len) rb_raise(rb_eIndexError, "end: %ld", beg + len);
str = rb_str_new_shared(str);
+ RSTRING(str)->len = len;
if (STR_EMBED_P(str)) {
-#if USE_RVARGC
- RSTRING(str)->as.embed.len = (short)len;
-#else
- RSTRING(str)->basic.flags &= ~RSTRING_EMBED_LEN_MASK;
- RSTRING(str)->basic.flags |= len << RSTRING_EMBED_LEN_SHIFT;
-#endif
memmove(RSTRING(str)->as.embed.ary, RSTRING(str)->as.embed.ary + beg, len);
}
else {
RSTRING(str)->as.heap.ptr += beg;
- RSTRING(str)->as.heap.len = len;
}
return str;
}
@@ -116,14 +110,10 @@ bug_str_s_cstr_noembed(VALUE self, VALUE str)
Check_Type(str, T_STRING);
FL_SET((str2), STR_NOEMBED);
memcpy(buf, RSTRING_PTR(str), capacity);
-#if USE_RVARGC
RBASIC(str2)->flags &= ~(STR_SHARED | FL_USER5 | FL_USER6);
-#else
- RBASIC(str2)->flags &= ~RSTRING_EMBED_LEN_MASK;
-#endif
RSTRING(str2)->as.heap.aux.capa = capacity;
RSTRING(str2)->as.heap.ptr = buf;
- RSTRING(str2)->as.heap.len = RSTRING_LEN(str);
+ RSTRING(str2)->len = RSTRING_LEN(str);
TERM_FILL(RSTRING_END(str2), TERM_LEN(str));
return str2;
}
diff --git a/ext/-test-/string/depend b/ext/-test-/string/depend
index 60b94d2351..eeb4914346 100644
--- a/ext/-test-/string/depend
+++ b/ext/-test-/string/depend
@@ -54,6 +54,7 @@ capacity.o: $(hdrdir)/ruby/internal/attr/noexcept.h
capacity.o: $(hdrdir)/ruby/internal/attr/noinline.h
capacity.o: $(hdrdir)/ruby/internal/attr/nonnull.h
capacity.o: $(hdrdir)/ruby/internal/attr/noreturn.h
+capacity.o: $(hdrdir)/ruby/internal/attr/packed_struct.h
capacity.o: $(hdrdir)/ruby/internal/attr/pure.h
capacity.o: $(hdrdir)/ruby/internal/attr/restrict.h
capacity.o: $(hdrdir)/ruby/internal/attr/returns_nonnull.h
@@ -122,7 +123,6 @@ capacity.o: $(hdrdir)/ruby/internal/intern/enumerator.h
capacity.o: $(hdrdir)/ruby/internal/intern/error.h
capacity.o: $(hdrdir)/ruby/internal/intern/eval.h
capacity.o: $(hdrdir)/ruby/internal/intern/file.h
-capacity.o: $(hdrdir)/ruby/internal/intern/gc.h
capacity.o: $(hdrdir)/ruby/internal/intern/hash.h
capacity.o: $(hdrdir)/ruby/internal/intern/io.h
capacity.o: $(hdrdir)/ruby/internal/intern/load.h
@@ -153,7 +153,6 @@ capacity.o: $(hdrdir)/ruby/internal/memory.h
capacity.o: $(hdrdir)/ruby/internal/method.h
capacity.o: $(hdrdir)/ruby/internal/module.h
capacity.o: $(hdrdir)/ruby/internal/newobj.h
-capacity.o: $(hdrdir)/ruby/internal/rgengc.h
capacity.o: $(hdrdir)/ruby/internal/scan_args.h
capacity.o: $(hdrdir)/ruby/internal/special_consts.h
capacity.o: $(hdrdir)/ruby/internal/static_assert.h
@@ -227,6 +226,7 @@ coderange.o: $(hdrdir)/ruby/internal/attr/noexcept.h
coderange.o: $(hdrdir)/ruby/internal/attr/noinline.h
coderange.o: $(hdrdir)/ruby/internal/attr/nonnull.h
coderange.o: $(hdrdir)/ruby/internal/attr/noreturn.h
+coderange.o: $(hdrdir)/ruby/internal/attr/packed_struct.h
coderange.o: $(hdrdir)/ruby/internal/attr/pure.h
coderange.o: $(hdrdir)/ruby/internal/attr/restrict.h
coderange.o: $(hdrdir)/ruby/internal/attr/returns_nonnull.h
@@ -295,7 +295,6 @@ coderange.o: $(hdrdir)/ruby/internal/intern/enumerator.h
coderange.o: $(hdrdir)/ruby/internal/intern/error.h
coderange.o: $(hdrdir)/ruby/internal/intern/eval.h
coderange.o: $(hdrdir)/ruby/internal/intern/file.h
-coderange.o: $(hdrdir)/ruby/internal/intern/gc.h
coderange.o: $(hdrdir)/ruby/internal/intern/hash.h
coderange.o: $(hdrdir)/ruby/internal/intern/io.h
coderange.o: $(hdrdir)/ruby/internal/intern/load.h
@@ -326,7 +325,6 @@ coderange.o: $(hdrdir)/ruby/internal/memory.h
coderange.o: $(hdrdir)/ruby/internal/method.h
coderange.o: $(hdrdir)/ruby/internal/module.h
coderange.o: $(hdrdir)/ruby/internal/newobj.h
-coderange.o: $(hdrdir)/ruby/internal/rgengc.h
coderange.o: $(hdrdir)/ruby/internal/scan_args.h
coderange.o: $(hdrdir)/ruby/internal/special_consts.h
coderange.o: $(hdrdir)/ruby/internal/static_assert.h
@@ -399,6 +397,7 @@ cstr.o: $(hdrdir)/ruby/internal/attr/noexcept.h
cstr.o: $(hdrdir)/ruby/internal/attr/noinline.h
cstr.o: $(hdrdir)/ruby/internal/attr/nonnull.h
cstr.o: $(hdrdir)/ruby/internal/attr/noreturn.h
+cstr.o: $(hdrdir)/ruby/internal/attr/packed_struct.h
cstr.o: $(hdrdir)/ruby/internal/attr/pure.h
cstr.o: $(hdrdir)/ruby/internal/attr/restrict.h
cstr.o: $(hdrdir)/ruby/internal/attr/returns_nonnull.h
@@ -467,7 +466,6 @@ cstr.o: $(hdrdir)/ruby/internal/intern/enumerator.h
cstr.o: $(hdrdir)/ruby/internal/intern/error.h
cstr.o: $(hdrdir)/ruby/internal/intern/eval.h
cstr.o: $(hdrdir)/ruby/internal/intern/file.h
-cstr.o: $(hdrdir)/ruby/internal/intern/gc.h
cstr.o: $(hdrdir)/ruby/internal/intern/hash.h
cstr.o: $(hdrdir)/ruby/internal/intern/io.h
cstr.o: $(hdrdir)/ruby/internal/intern/load.h
@@ -498,7 +496,6 @@ cstr.o: $(hdrdir)/ruby/internal/memory.h
cstr.o: $(hdrdir)/ruby/internal/method.h
cstr.o: $(hdrdir)/ruby/internal/module.h
cstr.o: $(hdrdir)/ruby/internal/newobj.h
-cstr.o: $(hdrdir)/ruby/internal/rgengc.h
cstr.o: $(hdrdir)/ruby/internal/scan_args.h
cstr.o: $(hdrdir)/ruby/internal/special_consts.h
cstr.o: $(hdrdir)/ruby/internal/static_assert.h
@@ -573,6 +570,7 @@ ellipsize.o: $(hdrdir)/ruby/internal/attr/noexcept.h
ellipsize.o: $(hdrdir)/ruby/internal/attr/noinline.h
ellipsize.o: $(hdrdir)/ruby/internal/attr/nonnull.h
ellipsize.o: $(hdrdir)/ruby/internal/attr/noreturn.h
+ellipsize.o: $(hdrdir)/ruby/internal/attr/packed_struct.h
ellipsize.o: $(hdrdir)/ruby/internal/attr/pure.h
ellipsize.o: $(hdrdir)/ruby/internal/attr/restrict.h
ellipsize.o: $(hdrdir)/ruby/internal/attr/returns_nonnull.h
@@ -632,7 +630,6 @@ ellipsize.o: $(hdrdir)/ruby/internal/intern/enumerator.h
ellipsize.o: $(hdrdir)/ruby/internal/intern/error.h
ellipsize.o: $(hdrdir)/ruby/internal/intern/eval.h
ellipsize.o: $(hdrdir)/ruby/internal/intern/file.h
-ellipsize.o: $(hdrdir)/ruby/internal/intern/gc.h
ellipsize.o: $(hdrdir)/ruby/internal/intern/hash.h
ellipsize.o: $(hdrdir)/ruby/internal/intern/io.h
ellipsize.o: $(hdrdir)/ruby/internal/intern/load.h
@@ -663,7 +660,6 @@ ellipsize.o: $(hdrdir)/ruby/internal/memory.h
ellipsize.o: $(hdrdir)/ruby/internal/method.h
ellipsize.o: $(hdrdir)/ruby/internal/module.h
ellipsize.o: $(hdrdir)/ruby/internal/newobj.h
-ellipsize.o: $(hdrdir)/ruby/internal/rgengc.h
ellipsize.o: $(hdrdir)/ruby/internal/scan_args.h
ellipsize.o: $(hdrdir)/ruby/internal/special_consts.h
ellipsize.o: $(hdrdir)/ruby/internal/static_assert.h
@@ -734,6 +730,7 @@ enc_associate.o: $(hdrdir)/ruby/internal/attr/noexcept.h
enc_associate.o: $(hdrdir)/ruby/internal/attr/noinline.h
enc_associate.o: $(hdrdir)/ruby/internal/attr/nonnull.h
enc_associate.o: $(hdrdir)/ruby/internal/attr/noreturn.h
+enc_associate.o: $(hdrdir)/ruby/internal/attr/packed_struct.h
enc_associate.o: $(hdrdir)/ruby/internal/attr/pure.h
enc_associate.o: $(hdrdir)/ruby/internal/attr/restrict.h
enc_associate.o: $(hdrdir)/ruby/internal/attr/returns_nonnull.h
@@ -802,7 +799,6 @@ enc_associate.o: $(hdrdir)/ruby/internal/intern/enumerator.h
enc_associate.o: $(hdrdir)/ruby/internal/intern/error.h
enc_associate.o: $(hdrdir)/ruby/internal/intern/eval.h
enc_associate.o: $(hdrdir)/ruby/internal/intern/file.h
-enc_associate.o: $(hdrdir)/ruby/internal/intern/gc.h
enc_associate.o: $(hdrdir)/ruby/internal/intern/hash.h
enc_associate.o: $(hdrdir)/ruby/internal/intern/io.h
enc_associate.o: $(hdrdir)/ruby/internal/intern/load.h
@@ -833,7 +829,6 @@ enc_associate.o: $(hdrdir)/ruby/internal/memory.h
enc_associate.o: $(hdrdir)/ruby/internal/method.h
enc_associate.o: $(hdrdir)/ruby/internal/module.h
enc_associate.o: $(hdrdir)/ruby/internal/newobj.h
-enc_associate.o: $(hdrdir)/ruby/internal/rgengc.h
enc_associate.o: $(hdrdir)/ruby/internal/scan_args.h
enc_associate.o: $(hdrdir)/ruby/internal/special_consts.h
enc_associate.o: $(hdrdir)/ruby/internal/static_assert.h
@@ -906,6 +901,7 @@ enc_dummy.o: $(hdrdir)/ruby/internal/attr/noexcept.h
enc_dummy.o: $(hdrdir)/ruby/internal/attr/noinline.h
enc_dummy.o: $(hdrdir)/ruby/internal/attr/nonnull.h
enc_dummy.o: $(hdrdir)/ruby/internal/attr/noreturn.h
+enc_dummy.o: $(hdrdir)/ruby/internal/attr/packed_struct.h
enc_dummy.o: $(hdrdir)/ruby/internal/attr/pure.h
enc_dummy.o: $(hdrdir)/ruby/internal/attr/restrict.h
enc_dummy.o: $(hdrdir)/ruby/internal/attr/returns_nonnull.h
@@ -974,7 +970,6 @@ enc_dummy.o: $(hdrdir)/ruby/internal/intern/enumerator.h
enc_dummy.o: $(hdrdir)/ruby/internal/intern/error.h
enc_dummy.o: $(hdrdir)/ruby/internal/intern/eval.h
enc_dummy.o: $(hdrdir)/ruby/internal/intern/file.h
-enc_dummy.o: $(hdrdir)/ruby/internal/intern/gc.h
enc_dummy.o: $(hdrdir)/ruby/internal/intern/hash.h
enc_dummy.o: $(hdrdir)/ruby/internal/intern/io.h
enc_dummy.o: $(hdrdir)/ruby/internal/intern/load.h
@@ -1005,7 +1000,6 @@ enc_dummy.o: $(hdrdir)/ruby/internal/memory.h
enc_dummy.o: $(hdrdir)/ruby/internal/method.h
enc_dummy.o: $(hdrdir)/ruby/internal/module.h
enc_dummy.o: $(hdrdir)/ruby/internal/newobj.h
-enc_dummy.o: $(hdrdir)/ruby/internal/rgengc.h
enc_dummy.o: $(hdrdir)/ruby/internal/scan_args.h
enc_dummy.o: $(hdrdir)/ruby/internal/special_consts.h
enc_dummy.o: $(hdrdir)/ruby/internal/static_assert.h
@@ -1077,6 +1071,7 @@ enc_str_buf_cat.o: $(hdrdir)/ruby/internal/attr/noexcept.h
enc_str_buf_cat.o: $(hdrdir)/ruby/internal/attr/noinline.h
enc_str_buf_cat.o: $(hdrdir)/ruby/internal/attr/nonnull.h
enc_str_buf_cat.o: $(hdrdir)/ruby/internal/attr/noreturn.h
+enc_str_buf_cat.o: $(hdrdir)/ruby/internal/attr/packed_struct.h
enc_str_buf_cat.o: $(hdrdir)/ruby/internal/attr/pure.h
enc_str_buf_cat.o: $(hdrdir)/ruby/internal/attr/restrict.h
enc_str_buf_cat.o: $(hdrdir)/ruby/internal/attr/returns_nonnull.h
@@ -1145,7 +1140,6 @@ enc_str_buf_cat.o: $(hdrdir)/ruby/internal/intern/enumerator.h
enc_str_buf_cat.o: $(hdrdir)/ruby/internal/intern/error.h
enc_str_buf_cat.o: $(hdrdir)/ruby/internal/intern/eval.h
enc_str_buf_cat.o: $(hdrdir)/ruby/internal/intern/file.h
-enc_str_buf_cat.o: $(hdrdir)/ruby/internal/intern/gc.h
enc_str_buf_cat.o: $(hdrdir)/ruby/internal/intern/hash.h
enc_str_buf_cat.o: $(hdrdir)/ruby/internal/intern/io.h
enc_str_buf_cat.o: $(hdrdir)/ruby/internal/intern/load.h
@@ -1176,7 +1170,6 @@ enc_str_buf_cat.o: $(hdrdir)/ruby/internal/memory.h
enc_str_buf_cat.o: $(hdrdir)/ruby/internal/method.h
enc_str_buf_cat.o: $(hdrdir)/ruby/internal/module.h
enc_str_buf_cat.o: $(hdrdir)/ruby/internal/newobj.h
-enc_str_buf_cat.o: $(hdrdir)/ruby/internal/rgengc.h
enc_str_buf_cat.o: $(hdrdir)/ruby/internal/scan_args.h
enc_str_buf_cat.o: $(hdrdir)/ruby/internal/special_consts.h
enc_str_buf_cat.o: $(hdrdir)/ruby/internal/static_assert.h
@@ -1203,6 +1196,7 @@ fstring.o: $(hdrdir)/ruby/backward.h
fstring.o: $(hdrdir)/ruby/backward/2/assume.h
fstring.o: $(hdrdir)/ruby/backward/2/attributes.h
fstring.o: $(hdrdir)/ruby/backward/2/bool.h
+fstring.o: $(hdrdir)/ruby/backward/2/gcc_version_since.h
fstring.o: $(hdrdir)/ruby/backward/2/inttypes.h
fstring.o: $(hdrdir)/ruby/backward/2/limits.h
fstring.o: $(hdrdir)/ruby/backward/2/long_long.h
@@ -1249,6 +1243,7 @@ fstring.o: $(hdrdir)/ruby/internal/attr/noexcept.h
fstring.o: $(hdrdir)/ruby/internal/attr/noinline.h
fstring.o: $(hdrdir)/ruby/internal/attr/nonnull.h
fstring.o: $(hdrdir)/ruby/internal/attr/noreturn.h
+fstring.o: $(hdrdir)/ruby/internal/attr/packed_struct.h
fstring.o: $(hdrdir)/ruby/internal/attr/pure.h
fstring.o: $(hdrdir)/ruby/internal/attr/restrict.h
fstring.o: $(hdrdir)/ruby/internal/attr/returns_nonnull.h
@@ -1317,7 +1312,6 @@ fstring.o: $(hdrdir)/ruby/internal/intern/enumerator.h
fstring.o: $(hdrdir)/ruby/internal/intern/error.h
fstring.o: $(hdrdir)/ruby/internal/intern/eval.h
fstring.o: $(hdrdir)/ruby/internal/intern/file.h
-fstring.o: $(hdrdir)/ruby/internal/intern/gc.h
fstring.o: $(hdrdir)/ruby/internal/intern/hash.h
fstring.o: $(hdrdir)/ruby/internal/intern/io.h
fstring.o: $(hdrdir)/ruby/internal/intern/load.h
@@ -1348,7 +1342,6 @@ fstring.o: $(hdrdir)/ruby/internal/memory.h
fstring.o: $(hdrdir)/ruby/internal/method.h
fstring.o: $(hdrdir)/ruby/internal/module.h
fstring.o: $(hdrdir)/ruby/internal/newobj.h
-fstring.o: $(hdrdir)/ruby/internal/rgengc.h
fstring.o: $(hdrdir)/ruby/internal/scan_args.h
fstring.o: $(hdrdir)/ruby/internal/special_consts.h
fstring.o: $(hdrdir)/ruby/internal/static_assert.h
@@ -1366,6 +1359,8 @@ fstring.o: $(hdrdir)/ruby/oniguruma.h
fstring.o: $(hdrdir)/ruby/ruby.h
fstring.o: $(hdrdir)/ruby/st.h
fstring.o: $(hdrdir)/ruby/subst.h
+fstring.o: $(top_srcdir)/internal/compilers.h
+fstring.o: $(top_srcdir)/internal/string.h
fstring.o: fstring.c
init.o: $(RUBY_EXTCONF_H)
init.o: $(arch_hdrdir)/ruby/config.h
@@ -1420,6 +1415,7 @@ init.o: $(hdrdir)/ruby/internal/attr/noexcept.h
init.o: $(hdrdir)/ruby/internal/attr/noinline.h
init.o: $(hdrdir)/ruby/internal/attr/nonnull.h
init.o: $(hdrdir)/ruby/internal/attr/noreturn.h
+init.o: $(hdrdir)/ruby/internal/attr/packed_struct.h
init.o: $(hdrdir)/ruby/internal/attr/pure.h
init.o: $(hdrdir)/ruby/internal/attr/restrict.h
init.o: $(hdrdir)/ruby/internal/attr/returns_nonnull.h
@@ -1479,7 +1475,6 @@ init.o: $(hdrdir)/ruby/internal/intern/enumerator.h
init.o: $(hdrdir)/ruby/internal/intern/error.h
init.o: $(hdrdir)/ruby/internal/intern/eval.h
init.o: $(hdrdir)/ruby/internal/intern/file.h
-init.o: $(hdrdir)/ruby/internal/intern/gc.h
init.o: $(hdrdir)/ruby/internal/intern/hash.h
init.o: $(hdrdir)/ruby/internal/intern/io.h
init.o: $(hdrdir)/ruby/internal/intern/load.h
@@ -1510,7 +1505,6 @@ init.o: $(hdrdir)/ruby/internal/memory.h
init.o: $(hdrdir)/ruby/internal/method.h
init.o: $(hdrdir)/ruby/internal/module.h
init.o: $(hdrdir)/ruby/internal/newobj.h
-init.o: $(hdrdir)/ruby/internal/rgengc.h
init.o: $(hdrdir)/ruby/internal/scan_args.h
init.o: $(hdrdir)/ruby/internal/special_consts.h
init.o: $(hdrdir)/ruby/internal/static_assert.h
@@ -1580,6 +1574,7 @@ modify.o: $(hdrdir)/ruby/internal/attr/noexcept.h
modify.o: $(hdrdir)/ruby/internal/attr/noinline.h
modify.o: $(hdrdir)/ruby/internal/attr/nonnull.h
modify.o: $(hdrdir)/ruby/internal/attr/noreturn.h
+modify.o: $(hdrdir)/ruby/internal/attr/packed_struct.h
modify.o: $(hdrdir)/ruby/internal/attr/pure.h
modify.o: $(hdrdir)/ruby/internal/attr/restrict.h
modify.o: $(hdrdir)/ruby/internal/attr/returns_nonnull.h
@@ -1639,7 +1634,6 @@ modify.o: $(hdrdir)/ruby/internal/intern/enumerator.h
modify.o: $(hdrdir)/ruby/internal/intern/error.h
modify.o: $(hdrdir)/ruby/internal/intern/eval.h
modify.o: $(hdrdir)/ruby/internal/intern/file.h
-modify.o: $(hdrdir)/ruby/internal/intern/gc.h
modify.o: $(hdrdir)/ruby/internal/intern/hash.h
modify.o: $(hdrdir)/ruby/internal/intern/io.h
modify.o: $(hdrdir)/ruby/internal/intern/load.h
@@ -1670,7 +1664,6 @@ modify.o: $(hdrdir)/ruby/internal/memory.h
modify.o: $(hdrdir)/ruby/internal/method.h
modify.o: $(hdrdir)/ruby/internal/module.h
modify.o: $(hdrdir)/ruby/internal/newobj.h
-modify.o: $(hdrdir)/ruby/internal/rgengc.h
modify.o: $(hdrdir)/ruby/internal/scan_args.h
modify.o: $(hdrdir)/ruby/internal/special_consts.h
modify.o: $(hdrdir)/ruby/internal/static_assert.h
@@ -1741,6 +1734,7 @@ new.o: $(hdrdir)/ruby/internal/attr/noexcept.h
new.o: $(hdrdir)/ruby/internal/attr/noinline.h
new.o: $(hdrdir)/ruby/internal/attr/nonnull.h
new.o: $(hdrdir)/ruby/internal/attr/noreturn.h
+new.o: $(hdrdir)/ruby/internal/attr/packed_struct.h
new.o: $(hdrdir)/ruby/internal/attr/pure.h
new.o: $(hdrdir)/ruby/internal/attr/restrict.h
new.o: $(hdrdir)/ruby/internal/attr/returns_nonnull.h
@@ -1809,7 +1803,6 @@ new.o: $(hdrdir)/ruby/internal/intern/enumerator.h
new.o: $(hdrdir)/ruby/internal/intern/error.h
new.o: $(hdrdir)/ruby/internal/intern/eval.h
new.o: $(hdrdir)/ruby/internal/intern/file.h
-new.o: $(hdrdir)/ruby/internal/intern/gc.h
new.o: $(hdrdir)/ruby/internal/intern/hash.h
new.o: $(hdrdir)/ruby/internal/intern/io.h
new.o: $(hdrdir)/ruby/internal/intern/load.h
@@ -1840,7 +1833,6 @@ new.o: $(hdrdir)/ruby/internal/memory.h
new.o: $(hdrdir)/ruby/internal/method.h
new.o: $(hdrdir)/ruby/internal/module.h
new.o: $(hdrdir)/ruby/internal/newobj.h
-new.o: $(hdrdir)/ruby/internal/rgengc.h
new.o: $(hdrdir)/ruby/internal/scan_args.h
new.o: $(hdrdir)/ruby/internal/special_consts.h
new.o: $(hdrdir)/ruby/internal/static_assert.h
@@ -1912,6 +1904,7 @@ nofree.o: $(hdrdir)/ruby/internal/attr/noexcept.h
nofree.o: $(hdrdir)/ruby/internal/attr/noinline.h
nofree.o: $(hdrdir)/ruby/internal/attr/nonnull.h
nofree.o: $(hdrdir)/ruby/internal/attr/noreturn.h
+nofree.o: $(hdrdir)/ruby/internal/attr/packed_struct.h
nofree.o: $(hdrdir)/ruby/internal/attr/pure.h
nofree.o: $(hdrdir)/ruby/internal/attr/restrict.h
nofree.o: $(hdrdir)/ruby/internal/attr/returns_nonnull.h
@@ -1971,7 +1964,6 @@ nofree.o: $(hdrdir)/ruby/internal/intern/enumerator.h
nofree.o: $(hdrdir)/ruby/internal/intern/error.h
nofree.o: $(hdrdir)/ruby/internal/intern/eval.h
nofree.o: $(hdrdir)/ruby/internal/intern/file.h
-nofree.o: $(hdrdir)/ruby/internal/intern/gc.h
nofree.o: $(hdrdir)/ruby/internal/intern/hash.h
nofree.o: $(hdrdir)/ruby/internal/intern/io.h
nofree.o: $(hdrdir)/ruby/internal/intern/load.h
@@ -2002,7 +1994,6 @@ nofree.o: $(hdrdir)/ruby/internal/memory.h
nofree.o: $(hdrdir)/ruby/internal/method.h
nofree.o: $(hdrdir)/ruby/internal/module.h
nofree.o: $(hdrdir)/ruby/internal/newobj.h
-nofree.o: $(hdrdir)/ruby/internal/rgengc.h
nofree.o: $(hdrdir)/ruby/internal/scan_args.h
nofree.o: $(hdrdir)/ruby/internal/special_consts.h
nofree.o: $(hdrdir)/ruby/internal/static_assert.h
@@ -2072,6 +2063,7 @@ normalize.o: $(hdrdir)/ruby/internal/attr/noexcept.h
normalize.o: $(hdrdir)/ruby/internal/attr/noinline.h
normalize.o: $(hdrdir)/ruby/internal/attr/nonnull.h
normalize.o: $(hdrdir)/ruby/internal/attr/noreturn.h
+normalize.o: $(hdrdir)/ruby/internal/attr/packed_struct.h
normalize.o: $(hdrdir)/ruby/internal/attr/pure.h
normalize.o: $(hdrdir)/ruby/internal/attr/restrict.h
normalize.o: $(hdrdir)/ruby/internal/attr/returns_nonnull.h
@@ -2140,7 +2132,6 @@ normalize.o: $(hdrdir)/ruby/internal/intern/enumerator.h
normalize.o: $(hdrdir)/ruby/internal/intern/error.h
normalize.o: $(hdrdir)/ruby/internal/intern/eval.h
normalize.o: $(hdrdir)/ruby/internal/intern/file.h
-normalize.o: $(hdrdir)/ruby/internal/intern/gc.h
normalize.o: $(hdrdir)/ruby/internal/intern/hash.h
normalize.o: $(hdrdir)/ruby/internal/intern/io.h
normalize.o: $(hdrdir)/ruby/internal/intern/load.h
@@ -2171,7 +2162,6 @@ normalize.o: $(hdrdir)/ruby/internal/memory.h
normalize.o: $(hdrdir)/ruby/internal/method.h
normalize.o: $(hdrdir)/ruby/internal/module.h
normalize.o: $(hdrdir)/ruby/internal/newobj.h
-normalize.o: $(hdrdir)/ruby/internal/rgengc.h
normalize.o: $(hdrdir)/ruby/internal/scan_args.h
normalize.o: $(hdrdir)/ruby/internal/special_consts.h
normalize.o: $(hdrdir)/ruby/internal/static_assert.h
@@ -2245,6 +2235,7 @@ qsort.o: $(hdrdir)/ruby/internal/attr/noexcept.h
qsort.o: $(hdrdir)/ruby/internal/attr/noinline.h
qsort.o: $(hdrdir)/ruby/internal/attr/nonnull.h
qsort.o: $(hdrdir)/ruby/internal/attr/noreturn.h
+qsort.o: $(hdrdir)/ruby/internal/attr/packed_struct.h
qsort.o: $(hdrdir)/ruby/internal/attr/pure.h
qsort.o: $(hdrdir)/ruby/internal/attr/restrict.h
qsort.o: $(hdrdir)/ruby/internal/attr/returns_nonnull.h
@@ -2313,7 +2304,6 @@ qsort.o: $(hdrdir)/ruby/internal/intern/enumerator.h
qsort.o: $(hdrdir)/ruby/internal/intern/error.h
qsort.o: $(hdrdir)/ruby/internal/intern/eval.h
qsort.o: $(hdrdir)/ruby/internal/intern/file.h
-qsort.o: $(hdrdir)/ruby/internal/intern/gc.h
qsort.o: $(hdrdir)/ruby/internal/intern/hash.h
qsort.o: $(hdrdir)/ruby/internal/intern/io.h
qsort.o: $(hdrdir)/ruby/internal/intern/load.h
@@ -2344,7 +2334,6 @@ qsort.o: $(hdrdir)/ruby/internal/memory.h
qsort.o: $(hdrdir)/ruby/internal/method.h
qsort.o: $(hdrdir)/ruby/internal/module.h
qsort.o: $(hdrdir)/ruby/internal/newobj.h
-qsort.o: $(hdrdir)/ruby/internal/rgengc.h
qsort.o: $(hdrdir)/ruby/internal/scan_args.h
qsort.o: $(hdrdir)/ruby/internal/special_consts.h
qsort.o: $(hdrdir)/ruby/internal/static_assert.h
@@ -2417,6 +2406,7 @@ rb_interned_str.o: $(hdrdir)/ruby/internal/attr/noexcept.h
rb_interned_str.o: $(hdrdir)/ruby/internal/attr/noinline.h
rb_interned_str.o: $(hdrdir)/ruby/internal/attr/nonnull.h
rb_interned_str.o: $(hdrdir)/ruby/internal/attr/noreturn.h
+rb_interned_str.o: $(hdrdir)/ruby/internal/attr/packed_struct.h
rb_interned_str.o: $(hdrdir)/ruby/internal/attr/pure.h
rb_interned_str.o: $(hdrdir)/ruby/internal/attr/restrict.h
rb_interned_str.o: $(hdrdir)/ruby/internal/attr/returns_nonnull.h
@@ -2476,7 +2466,6 @@ rb_interned_str.o: $(hdrdir)/ruby/internal/intern/enumerator.h
rb_interned_str.o: $(hdrdir)/ruby/internal/intern/error.h
rb_interned_str.o: $(hdrdir)/ruby/internal/intern/eval.h
rb_interned_str.o: $(hdrdir)/ruby/internal/intern/file.h
-rb_interned_str.o: $(hdrdir)/ruby/internal/intern/gc.h
rb_interned_str.o: $(hdrdir)/ruby/internal/intern/hash.h
rb_interned_str.o: $(hdrdir)/ruby/internal/intern/io.h
rb_interned_str.o: $(hdrdir)/ruby/internal/intern/load.h
@@ -2507,7 +2496,6 @@ rb_interned_str.o: $(hdrdir)/ruby/internal/memory.h
rb_interned_str.o: $(hdrdir)/ruby/internal/method.h
rb_interned_str.o: $(hdrdir)/ruby/internal/module.h
rb_interned_str.o: $(hdrdir)/ruby/internal/newobj.h
-rb_interned_str.o: $(hdrdir)/ruby/internal/rgengc.h
rb_interned_str.o: $(hdrdir)/ruby/internal/scan_args.h
rb_interned_str.o: $(hdrdir)/ruby/internal/special_consts.h
rb_interned_str.o: $(hdrdir)/ruby/internal/static_assert.h
@@ -2577,6 +2565,7 @@ rb_str_dup.o: $(hdrdir)/ruby/internal/attr/noexcept.h
rb_str_dup.o: $(hdrdir)/ruby/internal/attr/noinline.h
rb_str_dup.o: $(hdrdir)/ruby/internal/attr/nonnull.h
rb_str_dup.o: $(hdrdir)/ruby/internal/attr/noreturn.h
+rb_str_dup.o: $(hdrdir)/ruby/internal/attr/packed_struct.h
rb_str_dup.o: $(hdrdir)/ruby/internal/attr/pure.h
rb_str_dup.o: $(hdrdir)/ruby/internal/attr/restrict.h
rb_str_dup.o: $(hdrdir)/ruby/internal/attr/returns_nonnull.h
@@ -2636,7 +2625,6 @@ rb_str_dup.o: $(hdrdir)/ruby/internal/intern/enumerator.h
rb_str_dup.o: $(hdrdir)/ruby/internal/intern/error.h
rb_str_dup.o: $(hdrdir)/ruby/internal/intern/eval.h
rb_str_dup.o: $(hdrdir)/ruby/internal/intern/file.h
-rb_str_dup.o: $(hdrdir)/ruby/internal/intern/gc.h
rb_str_dup.o: $(hdrdir)/ruby/internal/intern/hash.h
rb_str_dup.o: $(hdrdir)/ruby/internal/intern/io.h
rb_str_dup.o: $(hdrdir)/ruby/internal/intern/load.h
@@ -2667,7 +2655,6 @@ rb_str_dup.o: $(hdrdir)/ruby/internal/memory.h
rb_str_dup.o: $(hdrdir)/ruby/internal/method.h
rb_str_dup.o: $(hdrdir)/ruby/internal/module.h
rb_str_dup.o: $(hdrdir)/ruby/internal/newobj.h
-rb_str_dup.o: $(hdrdir)/ruby/internal/rgengc.h
rb_str_dup.o: $(hdrdir)/ruby/internal/scan_args.h
rb_str_dup.o: $(hdrdir)/ruby/internal/special_consts.h
rb_str_dup.o: $(hdrdir)/ruby/internal/static_assert.h
@@ -2737,6 +2724,7 @@ set_len.o: $(hdrdir)/ruby/internal/attr/noexcept.h
set_len.o: $(hdrdir)/ruby/internal/attr/noinline.h
set_len.o: $(hdrdir)/ruby/internal/attr/nonnull.h
set_len.o: $(hdrdir)/ruby/internal/attr/noreturn.h
+set_len.o: $(hdrdir)/ruby/internal/attr/packed_struct.h
set_len.o: $(hdrdir)/ruby/internal/attr/pure.h
set_len.o: $(hdrdir)/ruby/internal/attr/restrict.h
set_len.o: $(hdrdir)/ruby/internal/attr/returns_nonnull.h
@@ -2796,7 +2784,6 @@ set_len.o: $(hdrdir)/ruby/internal/intern/enumerator.h
set_len.o: $(hdrdir)/ruby/internal/intern/error.h
set_len.o: $(hdrdir)/ruby/internal/intern/eval.h
set_len.o: $(hdrdir)/ruby/internal/intern/file.h
-set_len.o: $(hdrdir)/ruby/internal/intern/gc.h
set_len.o: $(hdrdir)/ruby/internal/intern/hash.h
set_len.o: $(hdrdir)/ruby/internal/intern/io.h
set_len.o: $(hdrdir)/ruby/internal/intern/load.h
@@ -2827,7 +2814,6 @@ set_len.o: $(hdrdir)/ruby/internal/memory.h
set_len.o: $(hdrdir)/ruby/internal/method.h
set_len.o: $(hdrdir)/ruby/internal/module.h
set_len.o: $(hdrdir)/ruby/internal/newobj.h
-set_len.o: $(hdrdir)/ruby/internal/rgengc.h
set_len.o: $(hdrdir)/ruby/internal/scan_args.h
set_len.o: $(hdrdir)/ruby/internal/special_consts.h
set_len.o: $(hdrdir)/ruby/internal/static_assert.h
diff --git a/ext/-test-/string/fstring.c b/ext/-test-/string/fstring.c
index 2374319fe3..7ee14a8570 100644
--- a/ext/-test-/string/fstring.c
+++ b/ext/-test-/string/fstring.c
@@ -1,5 +1,6 @@
#include "ruby.h"
#include "ruby/encoding.h"
+#include "internal/string.h"
VALUE rb_fstring(VALUE str);
@@ -10,6 +11,14 @@ bug_s_fstring(VALUE self, VALUE str)
}
VALUE
+bug_s_fstring_fake_str(VALUE self)
+{
+ static const char literal[] = "abcdefghijklmnopqrstuvwxyz";
+ struct RString fake_str;
+ return rb_fstring(rb_setup_fake_str(&fake_str, literal, sizeof(literal) - 1, 0));
+}
+
+VALUE
bug_s_rb_enc_interned_str(VALUE self, VALUE encoding)
{
return rb_enc_interned_str("foo", 3, RDATA(encoding)->data);
@@ -25,6 +34,7 @@ void
Init_string_fstring(VALUE klass)
{
rb_define_singleton_method(klass, "fstring", bug_s_fstring, 1);
+ rb_define_singleton_method(klass, "fstring_fake_str", bug_s_fstring_fake_str, 0);
rb_define_singleton_method(klass, "rb_enc_interned_str", bug_s_rb_enc_interned_str, 1);
rb_define_singleton_method(klass, "rb_enc_str_new", bug_s_rb_enc_str_new, 1);
}
diff --git a/ext/-test-/string/set_len.c b/ext/-test-/string/set_len.c
index 219cea404c..049da2cdb5 100644
--- a/ext/-test-/string/set_len.c
+++ b/ext/-test-/string/set_len.c
@@ -7,8 +7,18 @@ bug_str_set_len(VALUE str, VALUE len)
return str;
}
+static VALUE
+bug_str_append(VALUE str, VALUE addendum)
+{
+ StringValue(addendum);
+ rb_str_modify_expand(str, RSTRING_LEN(addendum));
+ memcpy(RSTRING_END(str), RSTRING_PTR(addendum), RSTRING_LEN(addendum));
+ return str;
+}
+
void
Init_string_set_len(VALUE klass)
{
rb_define_method(klass, "set_len", bug_str_set_len, 1);
+ rb_define_method(klass, "append", bug_str_append, 1);
}
diff --git a/ext/-test-/struct/data.c b/ext/-test-/struct/data.c
new file mode 100644
index 0000000000..5841c342e7
--- /dev/null
+++ b/ext/-test-/struct/data.c
@@ -0,0 +1,13 @@
+#include "ruby.h"
+
+static VALUE
+bug_data_new(VALUE self, VALUE super)
+{
+ return rb_data_define(super, "mem1", "mem2", NULL);
+}
+
+void
+Init_data(VALUE klass)
+{
+ rb_define_singleton_method(klass, "data_new", bug_data_new, 1);
+}
diff --git a/ext/-test-/struct/depend b/ext/-test-/struct/depend
index 920a065216..5db943e286 100644
--- a/ext/-test-/struct/depend
+++ b/ext/-test-/struct/depend
@@ -1,4 +1,163 @@
# AUTOGENERATED DEPENDENCIES START
+data.o: $(RUBY_EXTCONF_H)
+data.o: $(arch_hdrdir)/ruby/config.h
+data.o: $(hdrdir)/ruby.h
+data.o: $(hdrdir)/ruby/assert.h
+data.o: $(hdrdir)/ruby/backward.h
+data.o: $(hdrdir)/ruby/backward/2/assume.h
+data.o: $(hdrdir)/ruby/backward/2/attributes.h
+data.o: $(hdrdir)/ruby/backward/2/bool.h
+data.o: $(hdrdir)/ruby/backward/2/inttypes.h
+data.o: $(hdrdir)/ruby/backward/2/limits.h
+data.o: $(hdrdir)/ruby/backward/2/long_long.h
+data.o: $(hdrdir)/ruby/backward/2/stdalign.h
+data.o: $(hdrdir)/ruby/backward/2/stdarg.h
+data.o: $(hdrdir)/ruby/defines.h
+data.o: $(hdrdir)/ruby/intern.h
+data.o: $(hdrdir)/ruby/internal/abi.h
+data.o: $(hdrdir)/ruby/internal/anyargs.h
+data.o: $(hdrdir)/ruby/internal/arithmetic.h
+data.o: $(hdrdir)/ruby/internal/arithmetic/char.h
+data.o: $(hdrdir)/ruby/internal/arithmetic/double.h
+data.o: $(hdrdir)/ruby/internal/arithmetic/fixnum.h
+data.o: $(hdrdir)/ruby/internal/arithmetic/gid_t.h
+data.o: $(hdrdir)/ruby/internal/arithmetic/int.h
+data.o: $(hdrdir)/ruby/internal/arithmetic/intptr_t.h
+data.o: $(hdrdir)/ruby/internal/arithmetic/long.h
+data.o: $(hdrdir)/ruby/internal/arithmetic/long_long.h
+data.o: $(hdrdir)/ruby/internal/arithmetic/mode_t.h
+data.o: $(hdrdir)/ruby/internal/arithmetic/off_t.h
+data.o: $(hdrdir)/ruby/internal/arithmetic/pid_t.h
+data.o: $(hdrdir)/ruby/internal/arithmetic/short.h
+data.o: $(hdrdir)/ruby/internal/arithmetic/size_t.h
+data.o: $(hdrdir)/ruby/internal/arithmetic/st_data_t.h
+data.o: $(hdrdir)/ruby/internal/arithmetic/uid_t.h
+data.o: $(hdrdir)/ruby/internal/assume.h
+data.o: $(hdrdir)/ruby/internal/attr/alloc_size.h
+data.o: $(hdrdir)/ruby/internal/attr/artificial.h
+data.o: $(hdrdir)/ruby/internal/attr/cold.h
+data.o: $(hdrdir)/ruby/internal/attr/const.h
+data.o: $(hdrdir)/ruby/internal/attr/constexpr.h
+data.o: $(hdrdir)/ruby/internal/attr/deprecated.h
+data.o: $(hdrdir)/ruby/internal/attr/diagnose_if.h
+data.o: $(hdrdir)/ruby/internal/attr/enum_extensibility.h
+data.o: $(hdrdir)/ruby/internal/attr/error.h
+data.o: $(hdrdir)/ruby/internal/attr/flag_enum.h
+data.o: $(hdrdir)/ruby/internal/attr/forceinline.h
+data.o: $(hdrdir)/ruby/internal/attr/format.h
+data.o: $(hdrdir)/ruby/internal/attr/maybe_unused.h
+data.o: $(hdrdir)/ruby/internal/attr/noalias.h
+data.o: $(hdrdir)/ruby/internal/attr/nodiscard.h
+data.o: $(hdrdir)/ruby/internal/attr/noexcept.h
+data.o: $(hdrdir)/ruby/internal/attr/noinline.h
+data.o: $(hdrdir)/ruby/internal/attr/nonnull.h
+data.o: $(hdrdir)/ruby/internal/attr/noreturn.h
+data.o: $(hdrdir)/ruby/internal/attr/packed_struct.h
+data.o: $(hdrdir)/ruby/internal/attr/pure.h
+data.o: $(hdrdir)/ruby/internal/attr/restrict.h
+data.o: $(hdrdir)/ruby/internal/attr/returns_nonnull.h
+data.o: $(hdrdir)/ruby/internal/attr/warning.h
+data.o: $(hdrdir)/ruby/internal/attr/weakref.h
+data.o: $(hdrdir)/ruby/internal/cast.h
+data.o: $(hdrdir)/ruby/internal/compiler_is.h
+data.o: $(hdrdir)/ruby/internal/compiler_is/apple.h
+data.o: $(hdrdir)/ruby/internal/compiler_is/clang.h
+data.o: $(hdrdir)/ruby/internal/compiler_is/gcc.h
+data.o: $(hdrdir)/ruby/internal/compiler_is/intel.h
+data.o: $(hdrdir)/ruby/internal/compiler_is/msvc.h
+data.o: $(hdrdir)/ruby/internal/compiler_is/sunpro.h
+data.o: $(hdrdir)/ruby/internal/compiler_since.h
+data.o: $(hdrdir)/ruby/internal/config.h
+data.o: $(hdrdir)/ruby/internal/constant_p.h
+data.o: $(hdrdir)/ruby/internal/core.h
+data.o: $(hdrdir)/ruby/internal/core/rarray.h
+data.o: $(hdrdir)/ruby/internal/core/rbasic.h
+data.o: $(hdrdir)/ruby/internal/core/rbignum.h
+data.o: $(hdrdir)/ruby/internal/core/rclass.h
+data.o: $(hdrdir)/ruby/internal/core/rdata.h
+data.o: $(hdrdir)/ruby/internal/core/rfile.h
+data.o: $(hdrdir)/ruby/internal/core/rhash.h
+data.o: $(hdrdir)/ruby/internal/core/robject.h
+data.o: $(hdrdir)/ruby/internal/core/rregexp.h
+data.o: $(hdrdir)/ruby/internal/core/rstring.h
+data.o: $(hdrdir)/ruby/internal/core/rstruct.h
+data.o: $(hdrdir)/ruby/internal/core/rtypeddata.h
+data.o: $(hdrdir)/ruby/internal/ctype.h
+data.o: $(hdrdir)/ruby/internal/dllexport.h
+data.o: $(hdrdir)/ruby/internal/dosish.h
+data.o: $(hdrdir)/ruby/internal/error.h
+data.o: $(hdrdir)/ruby/internal/eval.h
+data.o: $(hdrdir)/ruby/internal/event.h
+data.o: $(hdrdir)/ruby/internal/fl_type.h
+data.o: $(hdrdir)/ruby/internal/gc.h
+data.o: $(hdrdir)/ruby/internal/glob.h
+data.o: $(hdrdir)/ruby/internal/globals.h
+data.o: $(hdrdir)/ruby/internal/has/attribute.h
+data.o: $(hdrdir)/ruby/internal/has/builtin.h
+data.o: $(hdrdir)/ruby/internal/has/c_attribute.h
+data.o: $(hdrdir)/ruby/internal/has/cpp_attribute.h
+data.o: $(hdrdir)/ruby/internal/has/declspec_attribute.h
+data.o: $(hdrdir)/ruby/internal/has/extension.h
+data.o: $(hdrdir)/ruby/internal/has/feature.h
+data.o: $(hdrdir)/ruby/internal/has/warning.h
+data.o: $(hdrdir)/ruby/internal/intern/array.h
+data.o: $(hdrdir)/ruby/internal/intern/bignum.h
+data.o: $(hdrdir)/ruby/internal/intern/class.h
+data.o: $(hdrdir)/ruby/internal/intern/compar.h
+data.o: $(hdrdir)/ruby/internal/intern/complex.h
+data.o: $(hdrdir)/ruby/internal/intern/cont.h
+data.o: $(hdrdir)/ruby/internal/intern/dir.h
+data.o: $(hdrdir)/ruby/internal/intern/enum.h
+data.o: $(hdrdir)/ruby/internal/intern/enumerator.h
+data.o: $(hdrdir)/ruby/internal/intern/error.h
+data.o: $(hdrdir)/ruby/internal/intern/eval.h
+data.o: $(hdrdir)/ruby/internal/intern/file.h
+data.o: $(hdrdir)/ruby/internal/intern/hash.h
+data.o: $(hdrdir)/ruby/internal/intern/io.h
+data.o: $(hdrdir)/ruby/internal/intern/load.h
+data.o: $(hdrdir)/ruby/internal/intern/marshal.h
+data.o: $(hdrdir)/ruby/internal/intern/numeric.h
+data.o: $(hdrdir)/ruby/internal/intern/object.h
+data.o: $(hdrdir)/ruby/internal/intern/parse.h
+data.o: $(hdrdir)/ruby/internal/intern/proc.h
+data.o: $(hdrdir)/ruby/internal/intern/process.h
+data.o: $(hdrdir)/ruby/internal/intern/random.h
+data.o: $(hdrdir)/ruby/internal/intern/range.h
+data.o: $(hdrdir)/ruby/internal/intern/rational.h
+data.o: $(hdrdir)/ruby/internal/intern/re.h
+data.o: $(hdrdir)/ruby/internal/intern/ruby.h
+data.o: $(hdrdir)/ruby/internal/intern/select.h
+data.o: $(hdrdir)/ruby/internal/intern/select/largesize.h
+data.o: $(hdrdir)/ruby/internal/intern/signal.h
+data.o: $(hdrdir)/ruby/internal/intern/sprintf.h
+data.o: $(hdrdir)/ruby/internal/intern/string.h
+data.o: $(hdrdir)/ruby/internal/intern/struct.h
+data.o: $(hdrdir)/ruby/internal/intern/thread.h
+data.o: $(hdrdir)/ruby/internal/intern/time.h
+data.o: $(hdrdir)/ruby/internal/intern/variable.h
+data.o: $(hdrdir)/ruby/internal/intern/vm.h
+data.o: $(hdrdir)/ruby/internal/interpreter.h
+data.o: $(hdrdir)/ruby/internal/iterator.h
+data.o: $(hdrdir)/ruby/internal/memory.h
+data.o: $(hdrdir)/ruby/internal/method.h
+data.o: $(hdrdir)/ruby/internal/module.h
+data.o: $(hdrdir)/ruby/internal/newobj.h
+data.o: $(hdrdir)/ruby/internal/scan_args.h
+data.o: $(hdrdir)/ruby/internal/special_consts.h
+data.o: $(hdrdir)/ruby/internal/static_assert.h
+data.o: $(hdrdir)/ruby/internal/stdalign.h
+data.o: $(hdrdir)/ruby/internal/stdbool.h
+data.o: $(hdrdir)/ruby/internal/symbol.h
+data.o: $(hdrdir)/ruby/internal/value.h
+data.o: $(hdrdir)/ruby/internal/value_type.h
+data.o: $(hdrdir)/ruby/internal/variable.h
+data.o: $(hdrdir)/ruby/internal/warning_push.h
+data.o: $(hdrdir)/ruby/internal/xmalloc.h
+data.o: $(hdrdir)/ruby/missing.h
+data.o: $(hdrdir)/ruby/ruby.h
+data.o: $(hdrdir)/ruby/st.h
+data.o: $(hdrdir)/ruby/subst.h
+data.o: data.c
duplicate.o: $(RUBY_EXTCONF_H)
duplicate.o: $(arch_hdrdir)/ruby/config.h
duplicate.o: $(hdrdir)/ruby.h
@@ -52,6 +211,7 @@ duplicate.o: $(hdrdir)/ruby/internal/attr/noexcept.h
duplicate.o: $(hdrdir)/ruby/internal/attr/noinline.h
duplicate.o: $(hdrdir)/ruby/internal/attr/nonnull.h
duplicate.o: $(hdrdir)/ruby/internal/attr/noreturn.h
+duplicate.o: $(hdrdir)/ruby/internal/attr/packed_struct.h
duplicate.o: $(hdrdir)/ruby/internal/attr/pure.h
duplicate.o: $(hdrdir)/ruby/internal/attr/restrict.h
duplicate.o: $(hdrdir)/ruby/internal/attr/returns_nonnull.h
@@ -111,7 +271,6 @@ duplicate.o: $(hdrdir)/ruby/internal/intern/enumerator.h
duplicate.o: $(hdrdir)/ruby/internal/intern/error.h
duplicate.o: $(hdrdir)/ruby/internal/intern/eval.h
duplicate.o: $(hdrdir)/ruby/internal/intern/file.h
-duplicate.o: $(hdrdir)/ruby/internal/intern/gc.h
duplicate.o: $(hdrdir)/ruby/internal/intern/hash.h
duplicate.o: $(hdrdir)/ruby/internal/intern/io.h
duplicate.o: $(hdrdir)/ruby/internal/intern/load.h
@@ -142,7 +301,6 @@ duplicate.o: $(hdrdir)/ruby/internal/memory.h
duplicate.o: $(hdrdir)/ruby/internal/method.h
duplicate.o: $(hdrdir)/ruby/internal/module.h
duplicate.o: $(hdrdir)/ruby/internal/newobj.h
-duplicate.o: $(hdrdir)/ruby/internal/rgengc.h
duplicate.o: $(hdrdir)/ruby/internal/scan_args.h
duplicate.o: $(hdrdir)/ruby/internal/special_consts.h
duplicate.o: $(hdrdir)/ruby/internal/static_assert.h
@@ -212,6 +370,7 @@ init.o: $(hdrdir)/ruby/internal/attr/noexcept.h
init.o: $(hdrdir)/ruby/internal/attr/noinline.h
init.o: $(hdrdir)/ruby/internal/attr/nonnull.h
init.o: $(hdrdir)/ruby/internal/attr/noreturn.h
+init.o: $(hdrdir)/ruby/internal/attr/packed_struct.h
init.o: $(hdrdir)/ruby/internal/attr/pure.h
init.o: $(hdrdir)/ruby/internal/attr/restrict.h
init.o: $(hdrdir)/ruby/internal/attr/returns_nonnull.h
@@ -271,7 +430,6 @@ init.o: $(hdrdir)/ruby/internal/intern/enumerator.h
init.o: $(hdrdir)/ruby/internal/intern/error.h
init.o: $(hdrdir)/ruby/internal/intern/eval.h
init.o: $(hdrdir)/ruby/internal/intern/file.h
-init.o: $(hdrdir)/ruby/internal/intern/gc.h
init.o: $(hdrdir)/ruby/internal/intern/hash.h
init.o: $(hdrdir)/ruby/internal/intern/io.h
init.o: $(hdrdir)/ruby/internal/intern/load.h
@@ -302,7 +460,6 @@ init.o: $(hdrdir)/ruby/internal/memory.h
init.o: $(hdrdir)/ruby/internal/method.h
init.o: $(hdrdir)/ruby/internal/module.h
init.o: $(hdrdir)/ruby/internal/newobj.h
-init.o: $(hdrdir)/ruby/internal/rgengc.h
init.o: $(hdrdir)/ruby/internal/scan_args.h
init.o: $(hdrdir)/ruby/internal/special_consts.h
init.o: $(hdrdir)/ruby/internal/static_assert.h
@@ -372,6 +529,7 @@ len.o: $(hdrdir)/ruby/internal/attr/noexcept.h
len.o: $(hdrdir)/ruby/internal/attr/noinline.h
len.o: $(hdrdir)/ruby/internal/attr/nonnull.h
len.o: $(hdrdir)/ruby/internal/attr/noreturn.h
+len.o: $(hdrdir)/ruby/internal/attr/packed_struct.h
len.o: $(hdrdir)/ruby/internal/attr/pure.h
len.o: $(hdrdir)/ruby/internal/attr/restrict.h
len.o: $(hdrdir)/ruby/internal/attr/returns_nonnull.h
@@ -431,7 +589,6 @@ len.o: $(hdrdir)/ruby/internal/intern/enumerator.h
len.o: $(hdrdir)/ruby/internal/intern/error.h
len.o: $(hdrdir)/ruby/internal/intern/eval.h
len.o: $(hdrdir)/ruby/internal/intern/file.h
-len.o: $(hdrdir)/ruby/internal/intern/gc.h
len.o: $(hdrdir)/ruby/internal/intern/hash.h
len.o: $(hdrdir)/ruby/internal/intern/io.h
len.o: $(hdrdir)/ruby/internal/intern/load.h
@@ -462,7 +619,6 @@ len.o: $(hdrdir)/ruby/internal/memory.h
len.o: $(hdrdir)/ruby/internal/method.h
len.o: $(hdrdir)/ruby/internal/module.h
len.o: $(hdrdir)/ruby/internal/newobj.h
-len.o: $(hdrdir)/ruby/internal/rgengc.h
len.o: $(hdrdir)/ruby/internal/scan_args.h
len.o: $(hdrdir)/ruby/internal/special_consts.h
len.o: $(hdrdir)/ruby/internal/static_assert.h
@@ -532,6 +688,7 @@ member.o: $(hdrdir)/ruby/internal/attr/noexcept.h
member.o: $(hdrdir)/ruby/internal/attr/noinline.h
member.o: $(hdrdir)/ruby/internal/attr/nonnull.h
member.o: $(hdrdir)/ruby/internal/attr/noreturn.h
+member.o: $(hdrdir)/ruby/internal/attr/packed_struct.h
member.o: $(hdrdir)/ruby/internal/attr/pure.h
member.o: $(hdrdir)/ruby/internal/attr/restrict.h
member.o: $(hdrdir)/ruby/internal/attr/returns_nonnull.h
@@ -591,7 +748,6 @@ member.o: $(hdrdir)/ruby/internal/intern/enumerator.h
member.o: $(hdrdir)/ruby/internal/intern/error.h
member.o: $(hdrdir)/ruby/internal/intern/eval.h
member.o: $(hdrdir)/ruby/internal/intern/file.h
-member.o: $(hdrdir)/ruby/internal/intern/gc.h
member.o: $(hdrdir)/ruby/internal/intern/hash.h
member.o: $(hdrdir)/ruby/internal/intern/io.h
member.o: $(hdrdir)/ruby/internal/intern/load.h
@@ -622,7 +778,6 @@ member.o: $(hdrdir)/ruby/internal/memory.h
member.o: $(hdrdir)/ruby/internal/method.h
member.o: $(hdrdir)/ruby/internal/module.h
member.o: $(hdrdir)/ruby/internal/newobj.h
-member.o: $(hdrdir)/ruby/internal/rgengc.h
member.o: $(hdrdir)/ruby/internal/scan_args.h
member.o: $(hdrdir)/ruby/internal/special_consts.h
member.o: $(hdrdir)/ruby/internal/static_assert.h
diff --git a/ext/-test-/symbol/depend b/ext/-test-/symbol/depend
index b94e4ce821..dd1b5c305f 100644
--- a/ext/-test-/symbol/depend
+++ b/ext/-test-/symbol/depend
@@ -52,6 +52,7 @@ init.o: $(hdrdir)/ruby/internal/attr/noexcept.h
init.o: $(hdrdir)/ruby/internal/attr/noinline.h
init.o: $(hdrdir)/ruby/internal/attr/nonnull.h
init.o: $(hdrdir)/ruby/internal/attr/noreturn.h
+init.o: $(hdrdir)/ruby/internal/attr/packed_struct.h
init.o: $(hdrdir)/ruby/internal/attr/pure.h
init.o: $(hdrdir)/ruby/internal/attr/restrict.h
init.o: $(hdrdir)/ruby/internal/attr/returns_nonnull.h
@@ -111,7 +112,6 @@ init.o: $(hdrdir)/ruby/internal/intern/enumerator.h
init.o: $(hdrdir)/ruby/internal/intern/error.h
init.o: $(hdrdir)/ruby/internal/intern/eval.h
init.o: $(hdrdir)/ruby/internal/intern/file.h
-init.o: $(hdrdir)/ruby/internal/intern/gc.h
init.o: $(hdrdir)/ruby/internal/intern/hash.h
init.o: $(hdrdir)/ruby/internal/intern/io.h
init.o: $(hdrdir)/ruby/internal/intern/load.h
@@ -142,7 +142,6 @@ init.o: $(hdrdir)/ruby/internal/memory.h
init.o: $(hdrdir)/ruby/internal/method.h
init.o: $(hdrdir)/ruby/internal/module.h
init.o: $(hdrdir)/ruby/internal/newobj.h
-init.o: $(hdrdir)/ruby/internal/rgengc.h
init.o: $(hdrdir)/ruby/internal/scan_args.h
init.o: $(hdrdir)/ruby/internal/special_consts.h
init.o: $(hdrdir)/ruby/internal/static_assert.h
@@ -212,6 +211,7 @@ type.o: $(hdrdir)/ruby/internal/attr/noexcept.h
type.o: $(hdrdir)/ruby/internal/attr/noinline.h
type.o: $(hdrdir)/ruby/internal/attr/nonnull.h
type.o: $(hdrdir)/ruby/internal/attr/noreturn.h
+type.o: $(hdrdir)/ruby/internal/attr/packed_struct.h
type.o: $(hdrdir)/ruby/internal/attr/pure.h
type.o: $(hdrdir)/ruby/internal/attr/restrict.h
type.o: $(hdrdir)/ruby/internal/attr/returns_nonnull.h
@@ -271,7 +271,6 @@ type.o: $(hdrdir)/ruby/internal/intern/enumerator.h
type.o: $(hdrdir)/ruby/internal/intern/error.h
type.o: $(hdrdir)/ruby/internal/intern/eval.h
type.o: $(hdrdir)/ruby/internal/intern/file.h
-type.o: $(hdrdir)/ruby/internal/intern/gc.h
type.o: $(hdrdir)/ruby/internal/intern/hash.h
type.o: $(hdrdir)/ruby/internal/intern/io.h
type.o: $(hdrdir)/ruby/internal/intern/load.h
@@ -302,7 +301,6 @@ type.o: $(hdrdir)/ruby/internal/memory.h
type.o: $(hdrdir)/ruby/internal/method.h
type.o: $(hdrdir)/ruby/internal/module.h
type.o: $(hdrdir)/ruby/internal/newobj.h
-type.o: $(hdrdir)/ruby/internal/rgengc.h
type.o: $(hdrdir)/ruby/internal/scan_args.h
type.o: $(hdrdir)/ruby/internal/special_consts.h
type.o: $(hdrdir)/ruby/internal/static_assert.h
diff --git a/ext/-test-/thread/instrumentation/depend b/ext/-test-/thread/instrumentation/depend
index e2fcd060d8..b03f51870f 100644
--- a/ext/-test-/thread/instrumentation/depend
+++ b/ext/-test-/thread/instrumentation/depend
@@ -52,6 +52,7 @@ instrumentation.o: $(hdrdir)/ruby/internal/attr/noexcept.h
instrumentation.o: $(hdrdir)/ruby/internal/attr/noinline.h
instrumentation.o: $(hdrdir)/ruby/internal/attr/nonnull.h
instrumentation.o: $(hdrdir)/ruby/internal/attr/noreturn.h
+instrumentation.o: $(hdrdir)/ruby/internal/attr/packed_struct.h
instrumentation.o: $(hdrdir)/ruby/internal/attr/pure.h
instrumentation.o: $(hdrdir)/ruby/internal/attr/restrict.h
instrumentation.o: $(hdrdir)/ruby/internal/attr/returns_nonnull.h
@@ -111,7 +112,6 @@ instrumentation.o: $(hdrdir)/ruby/internal/intern/enumerator.h
instrumentation.o: $(hdrdir)/ruby/internal/intern/error.h
instrumentation.o: $(hdrdir)/ruby/internal/intern/eval.h
instrumentation.o: $(hdrdir)/ruby/internal/intern/file.h
-instrumentation.o: $(hdrdir)/ruby/internal/intern/gc.h
instrumentation.o: $(hdrdir)/ruby/internal/intern/hash.h
instrumentation.o: $(hdrdir)/ruby/internal/intern/io.h
instrumentation.o: $(hdrdir)/ruby/internal/intern/load.h
@@ -142,7 +142,6 @@ instrumentation.o: $(hdrdir)/ruby/internal/memory.h
instrumentation.o: $(hdrdir)/ruby/internal/method.h
instrumentation.o: $(hdrdir)/ruby/internal/module.h
instrumentation.o: $(hdrdir)/ruby/internal/newobj.h
-instrumentation.o: $(hdrdir)/ruby/internal/rgengc.h
instrumentation.o: $(hdrdir)/ruby/internal/scan_args.h
instrumentation.o: $(hdrdir)/ruby/internal/special_consts.h
instrumentation.o: $(hdrdir)/ruby/internal/static_assert.h
diff --git a/ext/-test-/thread/instrumentation/instrumentation.c b/ext/-test-/thread/instrumentation/instrumentation.c
index d2a2c2740b..d81bc0f2a7 100644
--- a/ext/-test-/thread/instrumentation/instrumentation.c
+++ b/ext/-test-/thread/instrumentation/instrumentation.c
@@ -2,90 +2,137 @@
#include "ruby/atomic.h"
#include "ruby/thread.h"
-static rb_atomic_t started_count = 0;
-static rb_atomic_t ready_count = 0;
-static rb_atomic_t resumed_count = 0;
-static rb_atomic_t suspended_count = 0;
-static rb_atomic_t exited_count = 0;
-
-#if __STDC_VERSION__ >= 201112
- #define RB_THREAD_LOCAL_SPECIFIER _Thread_local
-#elif defined(__GNUC__) && !defined(RB_THREAD_LOCAL_SPECIFIER_IS_UNSUPPORTED)
- /* note that ICC (linux) and Clang are covered by __GNUC__ */
- #define RB_THREAD_LOCAL_SPECIFIER __thread
-#else
- #define RB_THREAD_LOCAL_SPECIFIER
+#ifndef RB_THREAD_LOCAL_SPECIFIER
+# define RB_THREAD_LOCAL_SPECIFIER
#endif
-static RB_THREAD_LOCAL_SPECIFIER unsigned int local_ready_count = 0;
-static RB_THREAD_LOCAL_SPECIFIER unsigned int local_resumed_count = 0;
-static RB_THREAD_LOCAL_SPECIFIER unsigned int local_suspended_count = 0;
+static VALUE last_thread = Qnil;
+static VALUE timeline_value = Qnil;
+
+struct thread_event {
+ VALUE thread;
+ rb_event_flag_t event;
+};
+
+#define MAX_EVENTS 1024
+static struct thread_event event_timeline[MAX_EVENTS];
+static rb_atomic_t timeline_cursor;
static void
-ex_callback(rb_event_flag_t event, const rb_internal_thread_event_data_t *event_data, void *user_data)
+event_timeline_gc_mark(void *ptr) {
+ rb_atomic_t cursor;
+ for (cursor = 0; cursor < timeline_cursor; cursor++) {
+ rb_gc_mark(event_timeline[cursor].thread);
+ }
+}
+
+static const rb_data_type_t event_timeline_type = {
+ "TestThreadInstrumentation/event_timeline",
+ {event_timeline_gc_mark, NULL, NULL,},
+ 0, 0,
+ RUBY_TYPED_FREE_IMMEDIATELY,
+};
+
+static void
+reset_timeline(void)
+{
+ timeline_cursor = 0;
+ memset(event_timeline, 0, sizeof(struct thread_event) * MAX_EVENTS);
+}
+
+static rb_event_flag_t
+find_last_event(VALUE thread)
+{
+ rb_atomic_t cursor = timeline_cursor;
+ if (cursor) {
+ do {
+ if (event_timeline[cursor].thread == thread){
+ return event_timeline[cursor].event;
+ }
+ cursor--;
+ } while (cursor > 0);
+ }
+ return 0;
+}
+
+static const char *
+event_name(rb_event_flag_t event)
{
switch (event) {
case RUBY_INTERNAL_THREAD_EVENT_STARTED:
- RUBY_ATOMIC_INC(started_count);
- break;
+ return "started";
case RUBY_INTERNAL_THREAD_EVENT_READY:
- RUBY_ATOMIC_INC(ready_count);
- local_ready_count++;
- break;
+ return "ready";
case RUBY_INTERNAL_THREAD_EVENT_RESUMED:
- RUBY_ATOMIC_INC(resumed_count);
- local_resumed_count++;
- break;
+ return "resumed";
case RUBY_INTERNAL_THREAD_EVENT_SUSPENDED:
- RUBY_ATOMIC_INC(suspended_count);
- local_suspended_count++;
- break;
+ return "suspended";
case RUBY_INTERNAL_THREAD_EVENT_EXITED:
- RUBY_ATOMIC_INC(exited_count);
- break;
+ return "exited";
}
+ return "no-event";
}
-static rb_internal_thread_event_hook_t * single_hook = NULL;
-
-static VALUE
-thread_counters(VALUE thread)
+static void
+unexpected(bool strict, const char *format, VALUE thread, rb_event_flag_t last_event)
{
- VALUE array = rb_ary_new2(5);
- rb_ary_push(array, UINT2NUM(started_count));
- rb_ary_push(array, UINT2NUM(ready_count));
- rb_ary_push(array, UINT2NUM(resumed_count));
- rb_ary_push(array, UINT2NUM(suspended_count));
- rb_ary_push(array, UINT2NUM(exited_count));
- return array;
+ const char *last_event_name = event_name(last_event);
+ if (strict) {
+ rb_bug(format, thread, last_event_name);
+ }
+ else {
+ fprintf(stderr, format, thread, last_event_name);
+ fprintf(stderr, "\n");
+ }
}
-static VALUE
-thread_local_counters(VALUE thread)
+static void
+ex_callback(rb_event_flag_t event, const rb_internal_thread_event_data_t *event_data, void *user_data)
{
- VALUE array = rb_ary_new2(3);
- rb_ary_push(array, UINT2NUM(local_ready_count));
- rb_ary_push(array, UINT2NUM(local_resumed_count));
- rb_ary_push(array, UINT2NUM(local_suspended_count));
- return array;
-}
+ rb_event_flag_t last_event = find_last_event(event_data->thread);
+ bool strict = (bool)user_data;
-static VALUE
-thread_reset_counters(VALUE thread)
-{
- RUBY_ATOMIC_SET(started_count, 0);
- RUBY_ATOMIC_SET(ready_count, 0);
- RUBY_ATOMIC_SET(resumed_count, 0);
- RUBY_ATOMIC_SET(suspended_count, 0);
- RUBY_ATOMIC_SET(exited_count, 0);
- local_ready_count = 0;
- local_resumed_count = 0;
- local_suspended_count = 0;
- return Qtrue;
+ if (last_event != 0) {
+ switch (event) {
+ case RUBY_INTERNAL_THREAD_EVENT_STARTED:
+ unexpected(strict, "[thread=%"PRIxVALUE"] `started` event can't be preceded by `%s`", event_data->thread, last_event);
+ break;
+ case RUBY_INTERNAL_THREAD_EVENT_READY:
+ if (last_event != RUBY_INTERNAL_THREAD_EVENT_STARTED && last_event != RUBY_INTERNAL_THREAD_EVENT_SUSPENDED) {
+ unexpected(strict, "[thread=%"PRIxVALUE"] `ready` must be preceded by `started` or `suspended`, got: `%s`", event_data->thread, last_event);
+ }
+ break;
+ case RUBY_INTERNAL_THREAD_EVENT_RESUMED:
+ if (last_event != RUBY_INTERNAL_THREAD_EVENT_READY) {
+ unexpected(strict, "[thread=%"PRIxVALUE"] `resumed` must be preceded by `ready`, got: `%s`", event_data->thread, last_event);
+ }
+ break;
+ case RUBY_INTERNAL_THREAD_EVENT_SUSPENDED:
+ if (last_event != RUBY_INTERNAL_THREAD_EVENT_RESUMED) {
+ unexpected(strict, "[thread=%"PRIxVALUE"] `suspended` must be preceded by `resumed`, got: `%s`", event_data->thread, last_event);
+ }
+ break;
+ case RUBY_INTERNAL_THREAD_EVENT_EXITED:
+ if (last_event != RUBY_INTERNAL_THREAD_EVENT_RESUMED && last_event != RUBY_INTERNAL_THREAD_EVENT_SUSPENDED) {
+ unexpected(strict, "[thread=%"PRIxVALUE"] `exited` must be preceded by `resumed` or `suspended`, got: `%s`", event_data->thread, last_event);
+ }
+ break;
+ }
+ }
+
+ rb_atomic_t cursor = RUBY_ATOMIC_FETCH_ADD(timeline_cursor, 1);
+ if (cursor >= MAX_EVENTS) {
+ rb_bug("TestThreadInstrumentation: ran out of event_timeline space");
+ }
+
+ event_timeline[cursor].thread = event_data->thread;
+ event_timeline[cursor].event = event;
}
+static rb_internal_thread_event_hook_t * single_hook = NULL;
+
static VALUE
-thread_register_callback(VALUE thread)
+thread_register_callback(VALUE thread, VALUE strict)
{
single_hook = rb_internal_thread_add_event_hook(
ex_callback,
@@ -94,13 +141,33 @@ thread_register_callback(VALUE thread)
RUBY_INTERNAL_THREAD_EVENT_RESUMED |
RUBY_INTERNAL_THREAD_EVENT_SUSPENDED |
RUBY_INTERNAL_THREAD_EVENT_EXITED,
- NULL
+ (void *)RTEST(strict)
);
return Qnil;
}
static VALUE
+event_symbol(rb_event_flag_t event)
+{
+ switch (event) {
+ case RUBY_INTERNAL_THREAD_EVENT_STARTED:
+ return rb_id2sym(rb_intern("started"));
+ case RUBY_INTERNAL_THREAD_EVENT_READY:
+ return rb_id2sym(rb_intern("ready"));
+ case RUBY_INTERNAL_THREAD_EVENT_RESUMED:
+ return rb_id2sym(rb_intern("resumed"));
+ case RUBY_INTERNAL_THREAD_EVENT_SUSPENDED:
+ return rb_id2sym(rb_intern("suspended"));
+ case RUBY_INTERNAL_THREAD_EVENT_EXITED:
+ return rb_id2sym(rb_intern("exited"));
+ default:
+ rb_bug("TestThreadInstrumentation: Unexpected event");
+ break;
+ }
+}
+
+static VALUE
thread_unregister_callback(VALUE thread)
{
if (single_hook) {
@@ -108,7 +175,18 @@ thread_unregister_callback(VALUE thread)
single_hook = NULL;
}
- return Qnil;
+ VALUE events = rb_ary_new_capa(timeline_cursor);
+ rb_atomic_t cursor;
+ for (cursor = 0; cursor < timeline_cursor; cursor++) {
+ VALUE pair = rb_ary_new_capa(2);
+ rb_ary_push(pair, event_timeline[cursor].thread);
+ rb_ary_push(pair, event_symbol(event_timeline[cursor].event));
+ rb_ary_push(events, pair);
+ }
+
+ reset_timeline();
+
+ return events;
}
static VALUE
@@ -132,10 +210,11 @@ Init_instrumentation(void)
{
VALUE mBug = rb_define_module("Bug");
VALUE klass = rb_define_module_under(mBug, "ThreadInstrumentation");
- rb_define_singleton_method(klass, "counters", thread_counters, 0);
- rb_define_singleton_method(klass, "local_counters", thread_local_counters, 0);
- rb_define_singleton_method(klass, "reset_counters", thread_reset_counters, 0);
- rb_define_singleton_method(klass, "register_callback", thread_register_callback, 0);
+ rb_global_variable(&timeline_value);
+ timeline_value = TypedData_Wrap_Struct(0, &event_timeline_type, 0);
+
+ rb_global_variable(&last_thread);
+ rb_define_singleton_method(klass, "register_callback", thread_register_callback, 1);
rb_define_singleton_method(klass, "unregister_callback", thread_unregister_callback, 0);
rb_define_singleton_method(klass, "register_and_unregister_callbacks", thread_register_and_unregister_callback, 0);
}
diff --git a/ext/-test-/thread_fd/depend b/ext/-test-/thread_fd/depend
index ecf738108a..d4cc772526 100644
--- a/ext/-test-/thread_fd/depend
+++ b/ext/-test-/thread_fd/depend
@@ -51,6 +51,7 @@ thread_fd.o: $(hdrdir)/ruby/internal/attr/noexcept.h
thread_fd.o: $(hdrdir)/ruby/internal/attr/noinline.h
thread_fd.o: $(hdrdir)/ruby/internal/attr/nonnull.h
thread_fd.o: $(hdrdir)/ruby/internal/attr/noreturn.h
+thread_fd.o: $(hdrdir)/ruby/internal/attr/packed_struct.h
thread_fd.o: $(hdrdir)/ruby/internal/attr/pure.h
thread_fd.o: $(hdrdir)/ruby/internal/attr/restrict.h
thread_fd.o: $(hdrdir)/ruby/internal/attr/returns_nonnull.h
@@ -110,7 +111,6 @@ thread_fd.o: $(hdrdir)/ruby/internal/intern/enumerator.h
thread_fd.o: $(hdrdir)/ruby/internal/intern/error.h
thread_fd.o: $(hdrdir)/ruby/internal/intern/eval.h
thread_fd.o: $(hdrdir)/ruby/internal/intern/file.h
-thread_fd.o: $(hdrdir)/ruby/internal/intern/gc.h
thread_fd.o: $(hdrdir)/ruby/internal/intern/hash.h
thread_fd.o: $(hdrdir)/ruby/internal/intern/io.h
thread_fd.o: $(hdrdir)/ruby/internal/intern/load.h
@@ -141,7 +141,6 @@ thread_fd.o: $(hdrdir)/ruby/internal/memory.h
thread_fd.o: $(hdrdir)/ruby/internal/method.h
thread_fd.o: $(hdrdir)/ruby/internal/module.h
thread_fd.o: $(hdrdir)/ruby/internal/newobj.h
-thread_fd.o: $(hdrdir)/ruby/internal/rgengc.h
thread_fd.o: $(hdrdir)/ruby/internal/scan_args.h
thread_fd.o: $(hdrdir)/ruby/internal/special_consts.h
thread_fd.o: $(hdrdir)/ruby/internal/static_assert.h
diff --git a/ext/-test-/time/depend b/ext/-test-/time/depend
index b7d1a2b114..c015588b09 100644
--- a/ext/-test-/time/depend
+++ b/ext/-test-/time/depend
@@ -52,6 +52,7 @@ init.o: $(hdrdir)/ruby/internal/attr/noexcept.h
init.o: $(hdrdir)/ruby/internal/attr/noinline.h
init.o: $(hdrdir)/ruby/internal/attr/nonnull.h
init.o: $(hdrdir)/ruby/internal/attr/noreturn.h
+init.o: $(hdrdir)/ruby/internal/attr/packed_struct.h
init.o: $(hdrdir)/ruby/internal/attr/pure.h
init.o: $(hdrdir)/ruby/internal/attr/restrict.h
init.o: $(hdrdir)/ruby/internal/attr/returns_nonnull.h
@@ -111,7 +112,6 @@ init.o: $(hdrdir)/ruby/internal/intern/enumerator.h
init.o: $(hdrdir)/ruby/internal/intern/error.h
init.o: $(hdrdir)/ruby/internal/intern/eval.h
init.o: $(hdrdir)/ruby/internal/intern/file.h
-init.o: $(hdrdir)/ruby/internal/intern/gc.h
init.o: $(hdrdir)/ruby/internal/intern/hash.h
init.o: $(hdrdir)/ruby/internal/intern/io.h
init.o: $(hdrdir)/ruby/internal/intern/load.h
@@ -142,7 +142,6 @@ init.o: $(hdrdir)/ruby/internal/memory.h
init.o: $(hdrdir)/ruby/internal/method.h
init.o: $(hdrdir)/ruby/internal/module.h
init.o: $(hdrdir)/ruby/internal/newobj.h
-init.o: $(hdrdir)/ruby/internal/rgengc.h
init.o: $(hdrdir)/ruby/internal/scan_args.h
init.o: $(hdrdir)/ruby/internal/special_consts.h
init.o: $(hdrdir)/ruby/internal/static_assert.h
@@ -213,6 +212,7 @@ leap_second.o: $(hdrdir)/ruby/internal/attr/noexcept.h
leap_second.o: $(hdrdir)/ruby/internal/attr/noinline.h
leap_second.o: $(hdrdir)/ruby/internal/attr/nonnull.h
leap_second.o: $(hdrdir)/ruby/internal/attr/noreturn.h
+leap_second.o: $(hdrdir)/ruby/internal/attr/packed_struct.h
leap_second.o: $(hdrdir)/ruby/internal/attr/pure.h
leap_second.o: $(hdrdir)/ruby/internal/attr/restrict.h
leap_second.o: $(hdrdir)/ruby/internal/attr/returns_nonnull.h
@@ -272,7 +272,6 @@ leap_second.o: $(hdrdir)/ruby/internal/intern/enumerator.h
leap_second.o: $(hdrdir)/ruby/internal/intern/error.h
leap_second.o: $(hdrdir)/ruby/internal/intern/eval.h
leap_second.o: $(hdrdir)/ruby/internal/intern/file.h
-leap_second.o: $(hdrdir)/ruby/internal/intern/gc.h
leap_second.o: $(hdrdir)/ruby/internal/intern/hash.h
leap_second.o: $(hdrdir)/ruby/internal/intern/io.h
leap_second.o: $(hdrdir)/ruby/internal/intern/load.h
@@ -303,7 +302,6 @@ leap_second.o: $(hdrdir)/ruby/internal/memory.h
leap_second.o: $(hdrdir)/ruby/internal/method.h
leap_second.o: $(hdrdir)/ruby/internal/module.h
leap_second.o: $(hdrdir)/ruby/internal/newobj.h
-leap_second.o: $(hdrdir)/ruby/internal/rgengc.h
leap_second.o: $(hdrdir)/ruby/internal/scan_args.h
leap_second.o: $(hdrdir)/ruby/internal/special_consts.h
leap_second.o: $(hdrdir)/ruby/internal/static_assert.h
@@ -377,6 +375,7 @@ new.o: $(hdrdir)/ruby/internal/attr/noexcept.h
new.o: $(hdrdir)/ruby/internal/attr/noinline.h
new.o: $(hdrdir)/ruby/internal/attr/nonnull.h
new.o: $(hdrdir)/ruby/internal/attr/noreturn.h
+new.o: $(hdrdir)/ruby/internal/attr/packed_struct.h
new.o: $(hdrdir)/ruby/internal/attr/pure.h
new.o: $(hdrdir)/ruby/internal/attr/restrict.h
new.o: $(hdrdir)/ruby/internal/attr/returns_nonnull.h
@@ -436,7 +435,6 @@ new.o: $(hdrdir)/ruby/internal/intern/enumerator.h
new.o: $(hdrdir)/ruby/internal/intern/error.h
new.o: $(hdrdir)/ruby/internal/intern/eval.h
new.o: $(hdrdir)/ruby/internal/intern/file.h
-new.o: $(hdrdir)/ruby/internal/intern/gc.h
new.o: $(hdrdir)/ruby/internal/intern/hash.h
new.o: $(hdrdir)/ruby/internal/intern/io.h
new.o: $(hdrdir)/ruby/internal/intern/load.h
@@ -467,7 +465,6 @@ new.o: $(hdrdir)/ruby/internal/memory.h
new.o: $(hdrdir)/ruby/internal/method.h
new.o: $(hdrdir)/ruby/internal/module.h
new.o: $(hdrdir)/ruby/internal/newobj.h
-new.o: $(hdrdir)/ruby/internal/rgengc.h
new.o: $(hdrdir)/ruby/internal/scan_args.h
new.o: $(hdrdir)/ruby/internal/special_consts.h
new.o: $(hdrdir)/ruby/internal/static_assert.h
diff --git a/ext/-test-/tracepoint/depend b/ext/-test-/tracepoint/depend
index 8e2aa7eab6..396004926e 100644
--- a/ext/-test-/tracepoint/depend
+++ b/ext/-test-/tracepoint/depend
@@ -52,6 +52,7 @@ gc_hook.o: $(hdrdir)/ruby/internal/attr/noexcept.h
gc_hook.o: $(hdrdir)/ruby/internal/attr/noinline.h
gc_hook.o: $(hdrdir)/ruby/internal/attr/nonnull.h
gc_hook.o: $(hdrdir)/ruby/internal/attr/noreturn.h
+gc_hook.o: $(hdrdir)/ruby/internal/attr/packed_struct.h
gc_hook.o: $(hdrdir)/ruby/internal/attr/pure.h
gc_hook.o: $(hdrdir)/ruby/internal/attr/restrict.h
gc_hook.o: $(hdrdir)/ruby/internal/attr/returns_nonnull.h
@@ -111,7 +112,6 @@ gc_hook.o: $(hdrdir)/ruby/internal/intern/enumerator.h
gc_hook.o: $(hdrdir)/ruby/internal/intern/error.h
gc_hook.o: $(hdrdir)/ruby/internal/intern/eval.h
gc_hook.o: $(hdrdir)/ruby/internal/intern/file.h
-gc_hook.o: $(hdrdir)/ruby/internal/intern/gc.h
gc_hook.o: $(hdrdir)/ruby/internal/intern/hash.h
gc_hook.o: $(hdrdir)/ruby/internal/intern/io.h
gc_hook.o: $(hdrdir)/ruby/internal/intern/load.h
@@ -142,7 +142,6 @@ gc_hook.o: $(hdrdir)/ruby/internal/memory.h
gc_hook.o: $(hdrdir)/ruby/internal/method.h
gc_hook.o: $(hdrdir)/ruby/internal/module.h
gc_hook.o: $(hdrdir)/ruby/internal/newobj.h
-gc_hook.o: $(hdrdir)/ruby/internal/rgengc.h
gc_hook.o: $(hdrdir)/ruby/internal/scan_args.h
gc_hook.o: $(hdrdir)/ruby/internal/special_consts.h
gc_hook.o: $(hdrdir)/ruby/internal/static_assert.h
@@ -212,6 +211,7 @@ tracepoint.o: $(hdrdir)/ruby/internal/attr/noexcept.h
tracepoint.o: $(hdrdir)/ruby/internal/attr/noinline.h
tracepoint.o: $(hdrdir)/ruby/internal/attr/nonnull.h
tracepoint.o: $(hdrdir)/ruby/internal/attr/noreturn.h
+tracepoint.o: $(hdrdir)/ruby/internal/attr/packed_struct.h
tracepoint.o: $(hdrdir)/ruby/internal/attr/pure.h
tracepoint.o: $(hdrdir)/ruby/internal/attr/restrict.h
tracepoint.o: $(hdrdir)/ruby/internal/attr/returns_nonnull.h
@@ -271,7 +271,6 @@ tracepoint.o: $(hdrdir)/ruby/internal/intern/enumerator.h
tracepoint.o: $(hdrdir)/ruby/internal/intern/error.h
tracepoint.o: $(hdrdir)/ruby/internal/intern/eval.h
tracepoint.o: $(hdrdir)/ruby/internal/intern/file.h
-tracepoint.o: $(hdrdir)/ruby/internal/intern/gc.h
tracepoint.o: $(hdrdir)/ruby/internal/intern/hash.h
tracepoint.o: $(hdrdir)/ruby/internal/intern/io.h
tracepoint.o: $(hdrdir)/ruby/internal/intern/load.h
@@ -302,7 +301,6 @@ tracepoint.o: $(hdrdir)/ruby/internal/memory.h
tracepoint.o: $(hdrdir)/ruby/internal/method.h
tracepoint.o: $(hdrdir)/ruby/internal/module.h
tracepoint.o: $(hdrdir)/ruby/internal/newobj.h
-tracepoint.o: $(hdrdir)/ruby/internal/rgengc.h
tracepoint.o: $(hdrdir)/ruby/internal/scan_args.h
tracepoint.o: $(hdrdir)/ruby/internal/special_consts.h
tracepoint.o: $(hdrdir)/ruby/internal/static_assert.h
diff --git a/ext/-test-/tracepoint/gc_hook.c b/ext/-test-/tracepoint/gc_hook.c
index a3f4e7f68a..54c06c54a5 100644
--- a/ext/-test-/tracepoint/gc_hook.c
+++ b/ext/-test-/tracepoint/gc_hook.c
@@ -33,7 +33,9 @@ gc_start_end_i(VALUE tpval, void *data)
}
if (invoking == 0) {
- rb_postponed_job_register(0, invoke_proc, data);
+ /* will overwrite the existing handle with new data on the second and subsequent call */
+ rb_postponed_job_handle_t h = rb_postponed_job_preregister(0, invoke_proc, data);
+ rb_postponed_job_trigger(h);
}
}
diff --git a/ext/-test-/typeddata/depend b/ext/-test-/typeddata/depend
index 02f6de6e20..cbeafa8000 100644
--- a/ext/-test-/typeddata/depend
+++ b/ext/-test-/typeddata/depend
@@ -52,6 +52,7 @@ typeddata.o: $(hdrdir)/ruby/internal/attr/noexcept.h
typeddata.o: $(hdrdir)/ruby/internal/attr/noinline.h
typeddata.o: $(hdrdir)/ruby/internal/attr/nonnull.h
typeddata.o: $(hdrdir)/ruby/internal/attr/noreturn.h
+typeddata.o: $(hdrdir)/ruby/internal/attr/packed_struct.h
typeddata.o: $(hdrdir)/ruby/internal/attr/pure.h
typeddata.o: $(hdrdir)/ruby/internal/attr/restrict.h
typeddata.o: $(hdrdir)/ruby/internal/attr/returns_nonnull.h
@@ -111,7 +112,6 @@ typeddata.o: $(hdrdir)/ruby/internal/intern/enumerator.h
typeddata.o: $(hdrdir)/ruby/internal/intern/error.h
typeddata.o: $(hdrdir)/ruby/internal/intern/eval.h
typeddata.o: $(hdrdir)/ruby/internal/intern/file.h
-typeddata.o: $(hdrdir)/ruby/internal/intern/gc.h
typeddata.o: $(hdrdir)/ruby/internal/intern/hash.h
typeddata.o: $(hdrdir)/ruby/internal/intern/io.h
typeddata.o: $(hdrdir)/ruby/internal/intern/load.h
@@ -142,7 +142,6 @@ typeddata.o: $(hdrdir)/ruby/internal/memory.h
typeddata.o: $(hdrdir)/ruby/internal/method.h
typeddata.o: $(hdrdir)/ruby/internal/module.h
typeddata.o: $(hdrdir)/ruby/internal/newobj.h
-typeddata.o: $(hdrdir)/ruby/internal/rgengc.h
typeddata.o: $(hdrdir)/ruby/internal/scan_args.h
typeddata.o: $(hdrdir)/ruby/internal/special_consts.h
typeddata.o: $(hdrdir)/ruby/internal/static_assert.h
diff --git a/ext/-test-/vm/depend b/ext/-test-/vm/depend
index 7f110d48eb..f0b3f3b1f4 100644
--- a/ext/-test-/vm/depend
+++ b/ext/-test-/vm/depend
@@ -51,6 +51,7 @@ at_exit.o: $(hdrdir)/ruby/internal/attr/noexcept.h
at_exit.o: $(hdrdir)/ruby/internal/attr/noinline.h
at_exit.o: $(hdrdir)/ruby/internal/attr/nonnull.h
at_exit.o: $(hdrdir)/ruby/internal/attr/noreturn.h
+at_exit.o: $(hdrdir)/ruby/internal/attr/packed_struct.h
at_exit.o: $(hdrdir)/ruby/internal/attr/pure.h
at_exit.o: $(hdrdir)/ruby/internal/attr/restrict.h
at_exit.o: $(hdrdir)/ruby/internal/attr/returns_nonnull.h
@@ -110,7 +111,6 @@ at_exit.o: $(hdrdir)/ruby/internal/intern/enumerator.h
at_exit.o: $(hdrdir)/ruby/internal/intern/error.h
at_exit.o: $(hdrdir)/ruby/internal/intern/eval.h
at_exit.o: $(hdrdir)/ruby/internal/intern/file.h
-at_exit.o: $(hdrdir)/ruby/internal/intern/gc.h
at_exit.o: $(hdrdir)/ruby/internal/intern/hash.h
at_exit.o: $(hdrdir)/ruby/internal/intern/io.h
at_exit.o: $(hdrdir)/ruby/internal/intern/load.h
@@ -141,7 +141,6 @@ at_exit.o: $(hdrdir)/ruby/internal/memory.h
at_exit.o: $(hdrdir)/ruby/internal/method.h
at_exit.o: $(hdrdir)/ruby/internal/module.h
at_exit.o: $(hdrdir)/ruby/internal/newobj.h
-at_exit.o: $(hdrdir)/ruby/internal/rgengc.h
at_exit.o: $(hdrdir)/ruby/internal/scan_args.h
at_exit.o: $(hdrdir)/ruby/internal/special_consts.h
at_exit.o: $(hdrdir)/ruby/internal/static_assert.h
diff --git a/ext/-test-/wait/depend b/ext/-test-/wait/depend
index e71bda9968..2e4887559c 100644
--- a/ext/-test-/wait/depend
+++ b/ext/-test-/wait/depend
@@ -52,6 +52,7 @@ wait.o: $(hdrdir)/ruby/internal/attr/noexcept.h
wait.o: $(hdrdir)/ruby/internal/attr/noinline.h
wait.o: $(hdrdir)/ruby/internal/attr/nonnull.h
wait.o: $(hdrdir)/ruby/internal/attr/noreturn.h
+wait.o: $(hdrdir)/ruby/internal/attr/packed_struct.h
wait.o: $(hdrdir)/ruby/internal/attr/pure.h
wait.o: $(hdrdir)/ruby/internal/attr/restrict.h
wait.o: $(hdrdir)/ruby/internal/attr/returns_nonnull.h
@@ -120,7 +121,6 @@ wait.o: $(hdrdir)/ruby/internal/intern/enumerator.h
wait.o: $(hdrdir)/ruby/internal/intern/error.h
wait.o: $(hdrdir)/ruby/internal/intern/eval.h
wait.o: $(hdrdir)/ruby/internal/intern/file.h
-wait.o: $(hdrdir)/ruby/internal/intern/gc.h
wait.o: $(hdrdir)/ruby/internal/intern/hash.h
wait.o: $(hdrdir)/ruby/internal/intern/io.h
wait.o: $(hdrdir)/ruby/internal/intern/load.h
@@ -151,7 +151,6 @@ wait.o: $(hdrdir)/ruby/internal/memory.h
wait.o: $(hdrdir)/ruby/internal/method.h
wait.o: $(hdrdir)/ruby/internal/module.h
wait.o: $(hdrdir)/ruby/internal/newobj.h
-wait.o: $(hdrdir)/ruby/internal/rgengc.h
wait.o: $(hdrdir)/ruby/internal/scan_args.h
wait.o: $(hdrdir)/ruby/internal/special_consts.h
wait.o: $(hdrdir)/ruby/internal/static_assert.h
diff --git a/ext/.document b/ext/.document
index f2fa5b5ba2..0efd511a61 100644
--- a/ext/.document
+++ b/ext/.document
@@ -29,8 +29,7 @@ fiddle/pinned.c
fiddle/pointer.c
fiddle/handle.c
fiddle/lib
-io/console/console.c
-io/console/lib
+io/console/
io/nonblock/nonblock.c
io/wait/wait.c
json/generator/generator.c
diff --git a/ext/Setup.atheos b/ext/Setup.atheos
index 6a8b9903af..91f73f32f9 100644
--- a/ext/Setup.atheos
+++ b/ext/Setup.atheos
@@ -13,7 +13,7 @@ io/wait
nkf
#openssl
pty
-racc/cparse
+#racc/cparse
readline
ripper
socket
diff --git a/ext/Setup.nt b/ext/Setup.nt
index 067f153d36..1278f183e4 100644
--- a/ext/Setup.nt
+++ b/ext/Setup.nt
@@ -14,7 +14,7 @@ fcntl
nkf
#openssl
#pty
-racc/cparse
+#racc/cparse
#readline
#ripper
socket
diff --git a/ext/bigdecimal/bigdecimal.c b/ext/bigdecimal/bigdecimal.c
index ce50e780f8..cb8874d31a 100644
--- a/ext/bigdecimal/bigdecimal.c
+++ b/ext/bigdecimal/bigdecimal.c
@@ -31,6 +31,8 @@
#include "bits.h"
#include "static_assert.h"
+#define BIGDECIMAL_VERSION "3.1.5"
+
/* #define ENABLE_NUMERIC_STRING */
#define SIGNED_VALUE_MAX INTPTR_MAX
@@ -655,7 +657,7 @@ BigDecimal_precision(VALUE self)
* Returns the number of decimal digits following the decimal digits in +self+.
*
* BigDecimal("0").scale # => 0
- * BigDecimal("1").scale # => 1
+ * BigDecimal("1").scale # => 0
* BigDecimal("1.1").scale # => 1
* BigDecimal("3.1415").scale # => 4
* BigDecimal("-1e20").precision # => 0
@@ -2082,6 +2084,13 @@ BigDecimal_divremain(VALUE self, VALUE r, Real **dv, Real **rv)
if (!b) return DoSomeOne(self, r, rb_intern("remainder"));
SAVE(b);
+ if (VpIsPosInf(b) || VpIsNegInf(b)) {
+ GUARD_OBJ(*dv, NewZeroWrapLimited(1, 1));
+ VpSetZero(*dv, 1);
+ *rv = a;
+ return Qnil;
+ }
+
mx = (a->MaxPrec + b->MaxPrec) *VpBaseFig();
GUARD_OBJ(c, NewZeroWrapLimited(1, mx));
GUARD_OBJ(res, NewZeroWrapNolimit(1, (mx+1) * 2 + (VpBaseFig() + 1)));
@@ -2680,7 +2689,7 @@ BigDecimal_ceil(int argc, VALUE *argv, VALUE self)
* A space at the start of s returns positive values with a leading space.
*
* If s contains a number, a space is inserted after each group of that many
- * fractional digits.
+ * digits, starting from '.' and counting outwards.
*
* If s ends with an 'E', engineering notation (0.xxxxEnn) is used.
*
@@ -2688,14 +2697,14 @@ BigDecimal_ceil(int argc, VALUE *argv, VALUE self)
*
* Examples:
*
- * BigDecimal('-123.45678901234567890').to_s('5F')
- * #=> '-123.45678 90123 45678 9'
+ * BigDecimal('-1234567890123.45678901234567890').to_s('5F')
+ * #=> '-123 45678 90123.45678 90123 45678 9'
*
- * BigDecimal('123.45678901234567890').to_s('+8F')
- * #=> '+123.45678901 23456789'
+ * BigDecimal('1234567890123.45678901234567890').to_s('+8F')
+ * #=> '+12345 67890123.45678901 23456789'
*
- * BigDecimal('123.45678901234567890').to_s(' F')
- * #=> ' 123.4567890123456789'
+ * BigDecimal('1234567890123.45678901234567890').to_s(' F')
+ * #=> ' 1234567890123.4567890123456789'
*/
static VALUE
BigDecimal_to_s(int argc, VALUE *argv, VALUE self)
@@ -3713,7 +3722,7 @@ rb_convert_to_BigDecimal(VALUE val, size_t digs, int raise_exception)
* - Other type:
*
* - Raises an exception if keyword argument +exception+ is +true+.
- * - Returns +nil+ if keyword argument +exception+ is +true+.
+ * - Returns +nil+ if keyword argument +exception+ is +false+.
*
* Raises an exception if +value+ evaluates to a Float
* and +digits+ is larger than Float::DIG + 1.
@@ -4133,11 +4142,11 @@ get_vp_value:
}
x = VpCheckGetValue(vx);
- RB_GC_GUARD(one) = VpCheckGetValue(NewOneWrapLimited(1, 1));
- RB_GC_GUARD(two) = VpCheckGetValue(VpCreateRbObject(1, "2", true));
+ one = VpCheckGetValue(NewOneWrapLimited(1, 1));
+ two = VpCheckGetValue(VpCreateRbObject(1, "2", true));
n = prec + BIGDECIMAL_DOUBLE_FIGURES;
- RB_GC_GUARD(vn) = SSIZET2NUM(n);
+ vn = SSIZET2NUM(n);
expo = VpExponent10(vx);
if (expo < 0 || expo >= 3) {
char buf[DECIMAL_SIZE_OF_BITS(SIZEOF_VALUE * CHAR_BIT) + 4];
@@ -4149,9 +4158,9 @@ get_vp_value:
}
w = BigDecimal_sub(x, one);
x = BigDecimal_div2(w, BigDecimal_add(x, one), vn);
- RB_GC_GUARD(x2) = BigDecimal_mult2(x, x, vn);
- RB_GC_GUARD(y) = x;
- RB_GC_GUARD(d) = y;
+ x2 = BigDecimal_mult2(x, x, vn);
+ y = x;
+ d = y;
i = 1;
while (!VpIsZero((Real*)DATA_PTR(d))) {
SIGNED_VALUE const ey = VpExponent10(DATA_PTR(y));
@@ -4179,6 +4188,13 @@ get_vp_value:
y = BigDecimal_add(y, dy);
}
+ RB_GC_GUARD(one);
+ RB_GC_GUARD(two);
+ RB_GC_GUARD(vn);
+ RB_GC_GUARD(x2);
+ RB_GC_GUARD(y);
+ RB_GC_GUARD(d);
+
return y;
}
@@ -4347,7 +4363,20 @@ BigDecimal_negative_zero(void)
* (2/3r).to_d(3) # => 0.667e0
* "0.5".to_d # => 0.5e0
*
- * == License
+ * == Methods for Working with \JSON
+ *
+ * - {::json_create}[rdoc-ref:BigDecimal.json_create]:
+ * Returns a new \BigDecimal object constructed from the given object.
+ * - {#as_json}[rdoc-ref:BigDecimal#as_json]:
+ * Returns a 2-element hash representing +self+.
+ * - {#to_json}[rdoc-ref:BigDecimal#to_json]:
+ * Returns a \JSON string representing +self+.
+ *
+ * These methods are provided by the {JSON gem}[https://github.com/flori/json]. To make these methods available:
+ *
+ * require 'json/add/bigdecimal'
+ *
+ * * == License
*
* Copyright (C) 2002 by Shigeo Kobayashi <shigeo@tinyforest.gr.jp>.
*
@@ -4395,13 +4424,10 @@ Init_bigdecimal(void)
/* Constants definition */
-#ifndef RUBY_BIGDECIMAL_VERSION
-# error RUBY_BIGDECIMAL_VERSION is not defined
-#endif
/*
* The version of bigdecimal library
*/
- rb_define_const(rb_cBigDecimal, "VERSION", rb_str_new2(RUBY_BIGDECIMAL_VERSION));
+ rb_define_const(rb_cBigDecimal, "VERSION", rb_str_new2(BIGDECIMAL_VERSION));
/*
* Base value used in internal calculations. On a 32 bit system, BASE
@@ -6693,95 +6719,90 @@ VpToFString(Real *a, char *buf, size_t buflen, size_t fFmt, int fPlus)
/* fPlus = 0: default, 1: set ' ' before digits, 2: set '+' before digits. */
{
size_t i, n;
- DECDIG m, e, nn;
+ DECDIG m, e;
char *p = buf;
- size_t plen = buflen;
+ size_t plen = buflen, delim = fFmt;
ssize_t ex;
if (VpToSpecialString(a, buf, buflen, fPlus)) return;
-#define ADVANCE(n) do { \
- if (plen < n) goto overflow; \
- p += n; \
- plen -= n; \
+#define APPEND(c, group) do { \
+ if (plen < 1) goto overflow; \
+ if (group && delim == 0) { \
+ *p = ' '; \
+ p += 1; \
+ plen -= 1; \
+ } \
+ if (plen < 1) goto overflow; \
+ *p = c; \
+ p += 1; \
+ plen -= 1; \
+ if (group) delim = (delim + 1) % fFmt; \
} while (0)
if (BIGDECIMAL_NEGATIVE_P(a)) {
- *p = '-';
- ADVANCE(1);
+ APPEND('-', false);
}
else if (fPlus == 1) {
- *p = ' ';
- ADVANCE(1);
+ APPEND(' ', false);
}
else if (fPlus == 2) {
- *p = '+';
- ADVANCE(1);
+ APPEND('+', false);
}
n = a->Prec;
ex = a->exponent;
if (ex <= 0) {
- *p = '0'; ADVANCE(1);
- *p = '.'; ADVANCE(1);
- while (ex < 0) {
- for (i=0; i < BASE_FIG; ++i) {
- *p = '0'; ADVANCE(1);
- }
- ++ex;
+ APPEND('0', false);
+ APPEND('.', false);
+ }
+ while (ex < 0) {
+ for (i=0; i < BASE_FIG; ++i) {
+ APPEND('0', fFmt > 0);
}
- ex = -1;
+ ++ex;
}
for (i = 0; i < n; ++i) {
- --ex;
- if (i == 0 && ex >= 0) {
- size_t n = snprintf(p, plen, "%lu", (unsigned long)a->frac[i]);
- if (n > plen) goto overflow;
- ADVANCE(n);
- }
- else {
- m = BASE1;
- e = a->frac[i];
- while (m) {
- nn = e / m;
- *p = (char)(nn + '0');
- ADVANCE(1);
- e = e - nn * m;
+ m = BASE1;
+ e = a->frac[i];
+ if (i == 0 && ex > 0) {
+ for (delim = 0; e / m == 0; delim++) {
m /= 10;
}
+ if (fFmt > 0) {
+ delim = 2*fFmt - (ex * BASE_FIG - delim) % fFmt;
+ }
+ }
+ while (m && (e || (i < n - 1) || ex > 0)) {
+ APPEND((char)(e / m + '0'), fFmt > 0);
+ e %= m;
+ m /= 10;
}
- if (ex == 0) {
- *p = '.';
- ADVANCE(1);
+ if (--ex == 0) {
+ APPEND('.', false);
+ delim = fFmt;
}
}
- while (--ex>=0) {
- m = BASE;
- while (m /= 10) {
- *p = '0';
- ADVANCE(1);
+
+ while (ex > 0) {
+ for (i=0; i < BASE_FIG; ++i) {
+ APPEND('0', fFmt > 0);
}
- if (ex == 0) {
- *p = '.';
- ADVANCE(1);
+ if (--ex == 0) {
+ APPEND('.', false);
}
}
*p = '\0';
- while (p - 1 > buf && p[-1] == '0') {
- *(--p) = '\0';
- ++plen;
- }
if (p - 1 > buf && p[-1] == '.') {
snprintf(p, plen, "0");
}
- if (fFmt) VpFormatSt(buf, fFmt);
overflow:
return;
-#undef ADVANCE
+#undef APPEND
}
/*
@@ -7158,7 +7179,6 @@ VpSqrt(Real *y, Real *x)
Real *r = NULL;
size_t y_prec;
SIGNED_VALUE n, e;
- SIGNED_VALUE prec;
ssize_t nr;
double val;
@@ -7197,12 +7217,6 @@ VpSqrt(Real *y, Real *x)
nr = 0;
y_prec = y->MaxPrec;
- prec = x->exponent - (ssize_t)y_prec;
- if (x->exponent > 0)
- ++prec;
- else
- --prec;
-
VpVtoD(&val, &e, x); /* val <- x */
e /= (SIGNED_VALUE)BASE_FIG;
n = e / 2;
diff --git a/ext/bigdecimal/bigdecimal.gemspec b/ext/bigdecimal/bigdecimal.gemspec
index d215757188..f9f3b45616 100644
--- a/ext/bigdecimal/bigdecimal.gemspec
+++ b/ext/bigdecimal/bigdecimal.gemspec
@@ -1,28 +1,29 @@
# coding: utf-8
+name = File.basename(__FILE__, '.*')
+source_version = ["", "ext/#{name}/"].find do |dir|
+ begin
+ break File.foreach(File.join(__dir__, "#{dir}#{name}.c")) {|line|
+ break $1.sub("-", ".") if /^#define\s+#{name.upcase}_VERSION\s+"(.+)"/o =~ line
+ }
+ rescue Errno::ENOENT
+ end
+end or raise "can't find #{name.upcase}_VERSION"
+
Gem::Specification.new do |s|
- s.name = "bigdecimal"
- s.version = "3.1.3"
+ s.name = name
+ s.version = source_version
s.authors = ["Kenta Murata", "Zachary Scott", "Shigeo Kobayashi"]
s.email = ["mrkn@mrkn.jp"]
s.summary = "Arbitrary-precision decimal floating-point number library."
s.description = "This library provides arbitrary-precision decimal floating-point number class."
s.homepage = "https://github.com/ruby/bigdecimal"
- s.licenses = ["Ruby", "bsd-2-clause"]
+ s.licenses = ["Ruby", "BSD-2-Clause"]
s.require_paths = %w[lib]
- s.extensions = %w[ext/bigdecimal/extconf.rb]
s.files = %w[
bigdecimal.gemspec
- ext/bigdecimal/bigdecimal.c
- ext/bigdecimal/bigdecimal.h
- ext/bigdecimal/bits.h
- ext/bigdecimal/feature.h
- ext/bigdecimal/missing.c
- ext/bigdecimal/missing.h
- ext/bigdecimal/missing/dtoa.c
- ext/bigdecimal/static_assert.h
lib/bigdecimal.rb
lib/bigdecimal/jacobian.rb
lib/bigdecimal/ludcmp.rb
@@ -33,6 +34,21 @@ Gem::Specification.new do |s|
sample/nlsolve.rb
sample/pi.rb
]
+ if Gem::Platform === s.platform and s.platform =~ 'java' or RUBY_ENGINE == 'jruby'
+ s.platform = 'java'
+ else
+ s.extensions = %w[ext/bigdecimal/extconf.rb]
+ s.files += %w[
+ ext/bigdecimal/bigdecimal.c
+ ext/bigdecimal/bigdecimal.h
+ ext/bigdecimal/bits.h
+ ext/bigdecimal/feature.h
+ ext/bigdecimal/missing.c
+ ext/bigdecimal/missing.h
+ ext/bigdecimal/missing/dtoa.c
+ ext/bigdecimal/static_assert.h
+ ]
+ end
s.required_ruby_version = Gem::Requirement.new(">= 2.5.0")
end
diff --git a/ext/bigdecimal/depend b/ext/bigdecimal/depend
index ee892162f2..a2455ebbda 100644
--- a/ext/bigdecimal/depend
+++ b/ext/bigdecimal/depend
@@ -1,4 +1,3 @@
-extconf.h: $(srcdir)/$(GEMSPEC)
Makefile: $(BIGDECIMAL_RB)
# AUTOGENERATED DEPENDENCIES START
@@ -53,6 +52,7 @@ bigdecimal.o: $(hdrdir)/ruby/internal/attr/noexcept.h
bigdecimal.o: $(hdrdir)/ruby/internal/attr/noinline.h
bigdecimal.o: $(hdrdir)/ruby/internal/attr/nonnull.h
bigdecimal.o: $(hdrdir)/ruby/internal/attr/noreturn.h
+bigdecimal.o: $(hdrdir)/ruby/internal/attr/packed_struct.h
bigdecimal.o: $(hdrdir)/ruby/internal/attr/pure.h
bigdecimal.o: $(hdrdir)/ruby/internal/attr/restrict.h
bigdecimal.o: $(hdrdir)/ruby/internal/attr/returns_nonnull.h
@@ -112,7 +112,6 @@ bigdecimal.o: $(hdrdir)/ruby/internal/intern/enumerator.h
bigdecimal.o: $(hdrdir)/ruby/internal/intern/error.h
bigdecimal.o: $(hdrdir)/ruby/internal/intern/eval.h
bigdecimal.o: $(hdrdir)/ruby/internal/intern/file.h
-bigdecimal.o: $(hdrdir)/ruby/internal/intern/gc.h
bigdecimal.o: $(hdrdir)/ruby/internal/intern/hash.h
bigdecimal.o: $(hdrdir)/ruby/internal/intern/io.h
bigdecimal.o: $(hdrdir)/ruby/internal/intern/load.h
@@ -143,7 +142,6 @@ bigdecimal.o: $(hdrdir)/ruby/internal/memory.h
bigdecimal.o: $(hdrdir)/ruby/internal/method.h
bigdecimal.o: $(hdrdir)/ruby/internal/module.h
bigdecimal.o: $(hdrdir)/ruby/internal/newobj.h
-bigdecimal.o: $(hdrdir)/ruby/internal/rgengc.h
bigdecimal.o: $(hdrdir)/ruby/internal/scan_args.h
bigdecimal.o: $(hdrdir)/ruby/internal/special_consts.h
bigdecimal.o: $(hdrdir)/ruby/internal/static_assert.h
@@ -219,6 +217,7 @@ missing.o: $(hdrdir)/ruby/internal/attr/noexcept.h
missing.o: $(hdrdir)/ruby/internal/attr/noinline.h
missing.o: $(hdrdir)/ruby/internal/attr/nonnull.h
missing.o: $(hdrdir)/ruby/internal/attr/noreturn.h
+missing.o: $(hdrdir)/ruby/internal/attr/packed_struct.h
missing.o: $(hdrdir)/ruby/internal/attr/pure.h
missing.o: $(hdrdir)/ruby/internal/attr/restrict.h
missing.o: $(hdrdir)/ruby/internal/attr/returns_nonnull.h
@@ -278,7 +277,6 @@ missing.o: $(hdrdir)/ruby/internal/intern/enumerator.h
missing.o: $(hdrdir)/ruby/internal/intern/error.h
missing.o: $(hdrdir)/ruby/internal/intern/eval.h
missing.o: $(hdrdir)/ruby/internal/intern/file.h
-missing.o: $(hdrdir)/ruby/internal/intern/gc.h
missing.o: $(hdrdir)/ruby/internal/intern/hash.h
missing.o: $(hdrdir)/ruby/internal/intern/io.h
missing.o: $(hdrdir)/ruby/internal/intern/load.h
@@ -309,7 +307,6 @@ missing.o: $(hdrdir)/ruby/internal/memory.h
missing.o: $(hdrdir)/ruby/internal/method.h
missing.o: $(hdrdir)/ruby/internal/module.h
missing.o: $(hdrdir)/ruby/internal/newobj.h
-missing.o: $(hdrdir)/ruby/internal/rgengc.h
missing.o: $(hdrdir)/ruby/internal/scan_args.h
missing.o: $(hdrdir)/ruby/internal/special_consts.h
missing.o: $(hdrdir)/ruby/internal/static_assert.h
diff --git a/ext/bigdecimal/extconf.rb b/ext/bigdecimal/extconf.rb
index 17e7905dd6..23904ed60e 100644
--- a/ext/bigdecimal/extconf.rb
+++ b/ext/bigdecimal/extconf.rb
@@ -1,18 +1,6 @@
# frozen_string_literal: false
require 'mkmf'
-def check_bigdecimal_version(gemspec_path)
- message "checking RUBY_BIGDECIMAL_VERSION... "
- bigdecimal_version = File.read(gemspec_path).match(/^\s*s\.version\s+=\s+['"]([^'"]+)['"]\s*$/)[1]
-
- version_components = bigdecimal_version.split('.')
- bigdecimal_version = version_components[0, 3].join('.')
- bigdecimal_version << "-#{version_components[3]}" if version_components[3]
- $defs << %Q[-DRUBY_BIGDECIMAL_VERSION=\\"#{bigdecimal_version}\\"]
-
- message "#{bigdecimal_version}\n"
-end
-
def have_builtin_func(name, check_expr, opt = "", &b)
checking_for checking_message(name.funcall_style, nil, opt) do
if try_compile(<<SRC, opt, &b)
@@ -27,18 +15,6 @@ SRC
end
end
-gemspec_name = gemspec_path = nil
-unless ['', '../../'].any? {|dir|
- gemspec_name = "#{dir}bigdecimal.gemspec"
- gemspec_path = File.expand_path("../#{gemspec_name}", __FILE__)
- File.file?(gemspec_path)
- }
- $stderr.puts "Unable to find bigdecimal.gemspec"
- abort
-end
-
-check_bigdecimal_version(gemspec_path)
-
have_builtin_func("__builtin_clz", "__builtin_clz(0)")
have_builtin_func("__builtin_clzl", "__builtin_clzl(0)")
have_builtin_func("__builtin_clzll", "__builtin_clzll(0)")
@@ -82,6 +58,5 @@ else
end
create_makefile('bigdecimal') {|mf|
- mf << "GEMSPEC = #{gemspec_name}\n"
mf << "BIGDECIMAL_RB = #{bigdecimal_rb}\n"
}
diff --git a/ext/bigdecimal/lib/bigdecimal.rb b/ext/bigdecimal/lib/bigdecimal.rb
index 8fd2587c84..82b3e1b7b9 100644
--- a/ext/bigdecimal/lib/bigdecimal.rb
+++ b/ext/bigdecimal/lib/bigdecimal.rb
@@ -1 +1,5 @@
-require 'bigdecimal.so'
+if RUBY_ENGINE == 'jruby'
+ JRuby::Util.load_ext("org.jruby.ext.bigdecimal.BigDecimalLibrary")
+else
+ require 'bigdecimal.so'
+end
diff --git a/ext/bigdecimal/lib/bigdecimal/util.rb b/ext/bigdecimal/lib/bigdecimal/util.rb
index ad92f7cfe6..8bfc0ed8ed 100644
--- a/ext/bigdecimal/lib/bigdecimal/util.rb
+++ b/ext/bigdecimal/lib/bigdecimal/util.rb
@@ -18,7 +18,7 @@ class Integer < Numeric
#
# 42.to_d # => 0.42e2
#
- # See also BigDecimal::new.
+ # See also Kernel.BigDecimal.
#
def to_d
BigDecimal(self)
@@ -45,7 +45,7 @@ class Float < Numeric
# 1.234.to_d # => 0.1234e1
# 1.234.to_d(2) # => 0.12e1
#
- # See also BigDecimal::new.
+ # See also Kernel.BigDecimal.
#
def to_d(precision=0)
BigDecimal(self, precision)
@@ -67,7 +67,7 @@ class String
# "123.45e1".to_d # => 0.12345e4
# "45.67 degrees".to_d # => 0.4567e2
#
- # See also BigDecimal::new.
+ # See also Kernel.BigDecimal.
#
def to_d
BigDecimal.interpret_loosely(self)
@@ -127,7 +127,7 @@ class Rational < Numeric
#
# Rational(22, 7).to_d(3) # => 0.314e1
#
- # See also BigDecimal::new.
+ # See also Kernel.BigDecimal.
#
def to_d(precision)
BigDecimal(self, precision)
@@ -152,7 +152,7 @@ class Complex < Numeric
# Complex(0.1234567, 0).to_d(4) # => 0.1235e0
# Complex(Rational(22, 7), 0).to_d(3) # => 0.314e1
#
- # See also BigDecimal::new.
+ # See also Kernel.BigDecimal.
#
def to_d(*args)
BigDecimal(self) unless self.imag.zero? # to raise eerror
diff --git a/ext/cgi/escape/depend b/ext/cgi/escape/depend
index e3904d0695..37304a24f4 100644
--- a/ext/cgi/escape/depend
+++ b/ext/cgi/escape/depend
@@ -53,6 +53,7 @@ escape.o: $(hdrdir)/ruby/internal/attr/noexcept.h
escape.o: $(hdrdir)/ruby/internal/attr/noinline.h
escape.o: $(hdrdir)/ruby/internal/attr/nonnull.h
escape.o: $(hdrdir)/ruby/internal/attr/noreturn.h
+escape.o: $(hdrdir)/ruby/internal/attr/packed_struct.h
escape.o: $(hdrdir)/ruby/internal/attr/pure.h
escape.o: $(hdrdir)/ruby/internal/attr/restrict.h
escape.o: $(hdrdir)/ruby/internal/attr/returns_nonnull.h
@@ -121,7 +122,6 @@ escape.o: $(hdrdir)/ruby/internal/intern/enumerator.h
escape.o: $(hdrdir)/ruby/internal/intern/error.h
escape.o: $(hdrdir)/ruby/internal/intern/eval.h
escape.o: $(hdrdir)/ruby/internal/intern/file.h
-escape.o: $(hdrdir)/ruby/internal/intern/gc.h
escape.o: $(hdrdir)/ruby/internal/intern/hash.h
escape.o: $(hdrdir)/ruby/internal/intern/io.h
escape.o: $(hdrdir)/ruby/internal/intern/load.h
@@ -152,7 +152,6 @@ escape.o: $(hdrdir)/ruby/internal/memory.h
escape.o: $(hdrdir)/ruby/internal/method.h
escape.o: $(hdrdir)/ruby/internal/module.h
escape.o: $(hdrdir)/ruby/internal/newobj.h
-escape.o: $(hdrdir)/ruby/internal/rgengc.h
escape.o: $(hdrdir)/ruby/internal/scan_args.h
escape.o: $(hdrdir)/ruby/internal/special_consts.h
escape.o: $(hdrdir)/ruby/internal/static_assert.h
diff --git a/ext/cgi/escape/escape.c b/ext/cgi/escape/escape.c
index c5b76de596..495ad83aa3 100644
--- a/ext/cgi/escape/escape.c
+++ b/ext/cgi/escape/escape.c
@@ -83,7 +83,7 @@ optimized_unescape_html(VALUE str)
unsigned long charlimit = (strcasecmp(rb_enc_name(enc), "UTF-8") == 0 ? UNICODE_MAX :
strcasecmp(rb_enc_name(enc), "ISO-8859-1") == 0 ? 256 :
128);
- long i, len, beg = 0;
+ long i, j, len, beg = 0;
size_t clen, plen;
int overflow;
const char *cstr;
@@ -100,6 +100,7 @@ optimized_unescape_html(VALUE str)
plen = i - beg;
if (++i >= len) break;
c = (unsigned char)cstr[i];
+ j = i;
#define MATCH(s) (len - i >= (int)rb_strlen_lit(s) && \
memcmp(&cstr[i], s, rb_strlen_lit(s)) == 0 && \
(i += rb_strlen_lit(s) - 1, 1))
@@ -112,28 +113,40 @@ optimized_unescape_html(VALUE str)
else if (MATCH("mp;")) {
c = '&';
}
- else continue;
+ else {
+ i = j;
+ continue;
+ }
break;
case 'q':
++i;
if (MATCH("uot;")) {
c = '"';
}
- else continue;
+ else {
+ i = j;
+ continue;
+ }
break;
case 'g':
++i;
if (MATCH("t;")) {
c = '>';
}
- else continue;
+ else {
+ i = j;
+ continue;
+ }
break;
case 'l':
++i;
if (MATCH("t;")) {
c = '<';
}
- else continue;
+ else {
+ i = j;
+ continue;
+ }
break;
case '#':
if (len - ++i >= 2 && ISDIGIT(cstr[i])) {
@@ -142,9 +155,15 @@ optimized_unescape_html(VALUE str)
else if ((cstr[i] == 'x' || cstr[i] == 'X') && len - ++i >= 2 && ISXDIGIT(cstr[i])) {
cc = ruby_scan_digits(&cstr[i], len-i, 16, &clen, &overflow);
}
- else continue;
+ else {
+ i = j;
+ continue;
+ }
i += clen;
- if (overflow || cc >= charlimit || cstr[i] != ';') continue;
+ if (overflow || cc >= charlimit || cstr[i] != ';') {
+ i = j;
+ continue;
+ }
if (!dest) {
dest = rb_str_buf_new(len);
}
@@ -458,7 +477,9 @@ InitVM_escape(void)
rb_define_method(rb_mEscape, "escapeHTML", cgiesc_escape_html, 1);
rb_define_method(rb_mEscape, "unescapeHTML", cgiesc_unescape_html, 1);
rb_define_method(rb_mEscape, "escapeURIComponent", cgiesc_escape_uri_component, 1);
+ rb_define_alias(rb_mEscape, "escape_uri_component", "escapeURIComponent");
rb_define_method(rb_mEscape, "unescapeURIComponent", cgiesc_unescape_uri_component, -1);
+ rb_define_alias(rb_mEscape, "unescape_uri_component", "unescapeURIComponent");
rb_define_method(rb_mEscape, "escape", cgiesc_escape, 1);
rb_define_method(rb_mEscape, "unescape", cgiesc_unescape, -1);
rb_prepend_module(rb_mUtil, rb_mEscape);
diff --git a/ext/cgi/escape/extconf.rb b/ext/cgi/escape/extconf.rb
index 16e8ff224d..73acd89ca8 100644
--- a/ext/cgi/escape/extconf.rb
+++ b/ext/cgi/escape/extconf.rb
@@ -1,3 +1,7 @@
require 'mkmf'
-create_makefile 'cgi/escape'
+if RUBY_ENGINE == 'truffleruby'
+ File.write("Makefile", dummy_makefile($srcdir).join(""))
+else
+ create_makefile 'cgi/escape'
+end
diff --git a/ext/continuation/depend b/ext/continuation/depend
index 81218f9965..f0333d7fe6 100644
--- a/ext/continuation/depend
+++ b/ext/continuation/depend
@@ -51,6 +51,7 @@ continuation.o: $(hdrdir)/ruby/internal/attr/noexcept.h
continuation.o: $(hdrdir)/ruby/internal/attr/noinline.h
continuation.o: $(hdrdir)/ruby/internal/attr/nonnull.h
continuation.o: $(hdrdir)/ruby/internal/attr/noreturn.h
+continuation.o: $(hdrdir)/ruby/internal/attr/packed_struct.h
continuation.o: $(hdrdir)/ruby/internal/attr/pure.h
continuation.o: $(hdrdir)/ruby/internal/attr/restrict.h
continuation.o: $(hdrdir)/ruby/internal/attr/returns_nonnull.h
@@ -110,7 +111,6 @@ continuation.o: $(hdrdir)/ruby/internal/intern/enumerator.h
continuation.o: $(hdrdir)/ruby/internal/intern/error.h
continuation.o: $(hdrdir)/ruby/internal/intern/eval.h
continuation.o: $(hdrdir)/ruby/internal/intern/file.h
-continuation.o: $(hdrdir)/ruby/internal/intern/gc.h
continuation.o: $(hdrdir)/ruby/internal/intern/hash.h
continuation.o: $(hdrdir)/ruby/internal/intern/io.h
continuation.o: $(hdrdir)/ruby/internal/intern/load.h
@@ -141,7 +141,6 @@ continuation.o: $(hdrdir)/ruby/internal/memory.h
continuation.o: $(hdrdir)/ruby/internal/method.h
continuation.o: $(hdrdir)/ruby/internal/module.h
continuation.o: $(hdrdir)/ruby/internal/newobj.h
-continuation.o: $(hdrdir)/ruby/internal/rgengc.h
continuation.o: $(hdrdir)/ruby/internal/scan_args.h
continuation.o: $(hdrdir)/ruby/internal/special_consts.h
continuation.o: $(hdrdir)/ruby/internal/static_assert.h
diff --git a/ext/coverage/coverage.c b/ext/coverage/coverage.c
index 399e28cdab..a3381901ee 100644
--- a/ext/coverage/coverage.c
+++ b/ext/coverage/coverage.c
@@ -8,7 +8,7 @@
************************************************/
-#include "gc.h"
+#include "internal/gc.h"
#include "internal/hash.h"
#include "internal/thread.h"
#include "internal/sanitizers.h"
diff --git a/ext/coverage/depend b/ext/coverage/depend
index e7fab16484..0a6c61d5c6 100644
--- a/ext/coverage/depend
+++ b/ext/coverage/depend
@@ -15,6 +15,7 @@ coverage.o: $(hdrdir)/ruby/backward/2/long_long.h
coverage.o: $(hdrdir)/ruby/backward/2/stdalign.h
coverage.o: $(hdrdir)/ruby/backward/2/stdarg.h
coverage.o: $(hdrdir)/ruby/defines.h
+coverage.o: $(hdrdir)/ruby/encoding.h
coverage.o: $(hdrdir)/ruby/intern.h
coverage.o: $(hdrdir)/ruby/internal/abi.h
coverage.o: $(hdrdir)/ruby/internal/anyargs.h
@@ -54,6 +55,7 @@ coverage.o: $(hdrdir)/ruby/internal/attr/noexcept.h
coverage.o: $(hdrdir)/ruby/internal/attr/noinline.h
coverage.o: $(hdrdir)/ruby/internal/attr/nonnull.h
coverage.o: $(hdrdir)/ruby/internal/attr/noreturn.h
+coverage.o: $(hdrdir)/ruby/internal/attr/packed_struct.h
coverage.o: $(hdrdir)/ruby/internal/attr/pure.h
coverage.o: $(hdrdir)/ruby/internal/attr/restrict.h
coverage.o: $(hdrdir)/ruby/internal/attr/returns_nonnull.h
@@ -86,6 +88,15 @@ coverage.o: $(hdrdir)/ruby/internal/core/rtypeddata.h
coverage.o: $(hdrdir)/ruby/internal/ctype.h
coverage.o: $(hdrdir)/ruby/internal/dllexport.h
coverage.o: $(hdrdir)/ruby/internal/dosish.h
+coverage.o: $(hdrdir)/ruby/internal/encoding/coderange.h
+coverage.o: $(hdrdir)/ruby/internal/encoding/ctype.h
+coverage.o: $(hdrdir)/ruby/internal/encoding/encoding.h
+coverage.o: $(hdrdir)/ruby/internal/encoding/pathname.h
+coverage.o: $(hdrdir)/ruby/internal/encoding/re.h
+coverage.o: $(hdrdir)/ruby/internal/encoding/sprintf.h
+coverage.o: $(hdrdir)/ruby/internal/encoding/string.h
+coverage.o: $(hdrdir)/ruby/internal/encoding/symbol.h
+coverage.o: $(hdrdir)/ruby/internal/encoding/transcode.h
coverage.o: $(hdrdir)/ruby/internal/error.h
coverage.o: $(hdrdir)/ruby/internal/eval.h
coverage.o: $(hdrdir)/ruby/internal/event.h
@@ -113,7 +124,6 @@ coverage.o: $(hdrdir)/ruby/internal/intern/enumerator.h
coverage.o: $(hdrdir)/ruby/internal/intern/error.h
coverage.o: $(hdrdir)/ruby/internal/intern/eval.h
coverage.o: $(hdrdir)/ruby/internal/intern/file.h
-coverage.o: $(hdrdir)/ruby/internal/intern/gc.h
coverage.o: $(hdrdir)/ruby/internal/intern/hash.h
coverage.o: $(hdrdir)/ruby/internal/intern/io.h
coverage.o: $(hdrdir)/ruby/internal/intern/load.h
@@ -144,7 +154,6 @@ coverage.o: $(hdrdir)/ruby/internal/memory.h
coverage.o: $(hdrdir)/ruby/internal/method.h
coverage.o: $(hdrdir)/ruby/internal/module.h
coverage.o: $(hdrdir)/ruby/internal/newobj.h
-coverage.o: $(hdrdir)/ruby/internal/rgengc.h
coverage.o: $(hdrdir)/ruby/internal/scan_args.h
coverage.o: $(hdrdir)/ruby/internal/special_consts.h
coverage.o: $(hdrdir)/ruby/internal/static_assert.h
@@ -157,6 +166,8 @@ coverage.o: $(hdrdir)/ruby/internal/variable.h
coverage.o: $(hdrdir)/ruby/internal/warning_push.h
coverage.o: $(hdrdir)/ruby/internal/xmalloc.h
coverage.o: $(hdrdir)/ruby/missing.h
+coverage.o: $(hdrdir)/ruby/onigmo.h
+coverage.o: $(hdrdir)/ruby/oniguruma.h
coverage.o: $(hdrdir)/ruby/ruby.h
coverage.o: $(hdrdir)/ruby/st.h
coverage.o: $(hdrdir)/ruby/subst.h
@@ -166,7 +177,6 @@ coverage.o: $(top_srcdir)/ccan/container_of/container_of.h
coverage.o: $(top_srcdir)/ccan/list/list.h
coverage.o: $(top_srcdir)/ccan/str/str.h
coverage.o: $(top_srcdir)/constant.h
-coverage.o: $(top_srcdir)/gc.h
coverage.o: $(top_srcdir)/id_table.h
coverage.o: $(top_srcdir)/internal.h
coverage.o: $(top_srcdir)/internal/array.h
@@ -186,6 +196,7 @@ coverage.o: $(top_srcdir)/method.h
coverage.o: $(top_srcdir)/node.h
coverage.o: $(top_srcdir)/ruby_assert.h
coverage.o: $(top_srcdir)/ruby_atomic.h
+coverage.o: $(top_srcdir)/rubyparser.h
coverage.o: $(top_srcdir)/shape.h
coverage.o: $(top_srcdir)/thread_pthread.h
coverage.o: $(top_srcdir)/vm_core.h
diff --git a/ext/date/date_core.c b/ext/date/date_core.c
index 21367c0ddf..f4b390584b 100644
--- a/ext/date/date_core.c
+++ b/ext/date/date_core.c
@@ -2589,8 +2589,6 @@ date_s__valid_civil_p(int argc, VALUE *argv, VALUE klass)
*
* See argument {start}[rdoc-ref:calendars.rdoc@Argument+start].
*
- * Date.valid_date? is an alias for Date.valid_civil?.
- *
* Related: Date.jd, Date.new.
*/
static VALUE
@@ -2986,8 +2984,6 @@ date_s_julian_leap_p(VALUE klass, VALUE y)
* Date.gregorian_leap?(2000) # => true
* Date.gregorian_leap?(2001) # => false
*
- * Date.leap? is an alias for Date.gregorian_leap?.
- *
* Related: Date.julian_leap?.
*/
static VALUE
@@ -3493,8 +3489,6 @@ date_s_civil(int argc, VALUE *argv, VALUE klass)
*
* See argument {start}[rdoc-ref:calendars.rdoc@Argument+start].
*
- * Date.civil is an alias for Date.new.
- *
* Related: Date.jd.
*/
static VALUE
@@ -4832,8 +4826,6 @@ date_s_xmlschema(int argc, VALUE *argv, VALUE klass)
*
* See argument {limit}[rdoc-ref:Date@Argument+limit].
*
- * Date._rfc822 is an alias for Date._rfc2822.
- *
* Related: Date.rfc2822 (returns a \Date object).
*/
static VALUE
@@ -4864,8 +4856,6 @@ date_s__rfc2822(int argc, VALUE *argv, VALUE klass)
* - Argument {start}[rdoc-ref:calendars.rdoc@Argument+start].
* - Argument {limit}[rdoc-ref:Date@Argument+limit].
*
- * Date.rfc822 is an alias for Date.rfc2822.
- *
* Related: Date._rfc2822 (returns a hash).
*/
static VALUE
@@ -5346,7 +5336,6 @@ d_lite_yday(VALUE self)
*
* Date.new(2001, 2, 3).mon # => 2
*
- * Date#month is an alias for Date#mon.
*/
static VALUE
d_lite_mon(VALUE self)
@@ -5363,7 +5352,6 @@ d_lite_mon(VALUE self)
*
* Date.new(2001, 2, 3).mday # => 3
*
- * Date#day is an alias for Date#mday.
*/
static VALUE
d_lite_mday(VALUE self)
@@ -5613,7 +5601,6 @@ d_lite_hour(VALUE self)
*
* DateTime.new(2001, 2, 3, 4, 5, 6).min # => 5
*
- * Date#minute is an alias for Date#min.
*/
static VALUE
d_lite_min(VALUE self)
@@ -5630,7 +5617,6 @@ d_lite_min(VALUE self)
*
* DateTime.new(2001, 2, 3, 4, 5, 6).sec # => 6
*
- * Date#second is an alias for Date#sec.
*/
static VALUE
d_lite_sec(VALUE self)
@@ -5648,7 +5634,6 @@ d_lite_sec(VALUE self)
*
* DateTime.new(2001, 2, 3, 4, 5, 6.5).sec_fraction # => (1/2)
*
- * Date#second_fraction is an alias for Date#sec_fraction.
*/
static VALUE
d_lite_sec_fraction(VALUE self)
@@ -6424,7 +6409,6 @@ d_lite_prev_day(int argc, VALUE *argv, VALUE self)
* d.to_s # => "2001-02-03"
* d.next.to_s # => "2001-02-04"
*
- * Date#succ is an alias for Date#next.
*/
static VALUE
d_lite_next(VALUE self)
@@ -7298,7 +7282,6 @@ strftimev(const char *fmt, VALUE self,
*
* See {asctime}[https://linux.die.net/man/3/asctime].
*
- * Date#ctime is an alias for Date#asctime.
*/
static VALUE
d_lite_asctime(VALUE self)
@@ -7316,7 +7299,6 @@ d_lite_asctime(VALUE self)
*
* Date.new(2001, 2, 3).iso8601 # => "2001-02-03"
*
- * Date#xmlschema is an alias for Date#iso8601.
*/
static VALUE
d_lite_iso8601(VALUE self)
@@ -7349,7 +7331,6 @@ d_lite_rfc3339(VALUE self)
*
* Date.new(2001, 2, 3).rfc2822 # => "Sat, 3 Feb 2001 00:00:00 +0000"
*
- * Date#rfc822 is an alias for Date#rfc2822.
*/
static VALUE
d_lite_rfc2822(VALUE self)
@@ -8745,8 +8726,8 @@ dt_lite_to_s(VALUE self)
*
* DateTime.now.strftime # => "2022-07-01T11:03:19-05:00"
*
- * For other formats, see
- * {Formats for Dates and Times}[doc/strftime_formatting.rdoc].
+ * For other formats,
+ * see {Formats for Dates and Times}[rdoc-ref:strftime_formatting.rdoc]:
*
*/
static VALUE
diff --git a/ext/date/depend b/ext/date/depend
index 3f550cd0a7..82f85f7bf3 100644
--- a/ext/date/depend
+++ b/ext/date/depend
@@ -53,6 +53,7 @@ date_core.o: $(hdrdir)/ruby/internal/attr/noexcept.h
date_core.o: $(hdrdir)/ruby/internal/attr/noinline.h
date_core.o: $(hdrdir)/ruby/internal/attr/nonnull.h
date_core.o: $(hdrdir)/ruby/internal/attr/noreturn.h
+date_core.o: $(hdrdir)/ruby/internal/attr/packed_struct.h
date_core.o: $(hdrdir)/ruby/internal/attr/pure.h
date_core.o: $(hdrdir)/ruby/internal/attr/restrict.h
date_core.o: $(hdrdir)/ruby/internal/attr/returns_nonnull.h
@@ -121,7 +122,6 @@ date_core.o: $(hdrdir)/ruby/internal/intern/enumerator.h
date_core.o: $(hdrdir)/ruby/internal/intern/error.h
date_core.o: $(hdrdir)/ruby/internal/intern/eval.h
date_core.o: $(hdrdir)/ruby/internal/intern/file.h
-date_core.o: $(hdrdir)/ruby/internal/intern/gc.h
date_core.o: $(hdrdir)/ruby/internal/intern/hash.h
date_core.o: $(hdrdir)/ruby/internal/intern/io.h
date_core.o: $(hdrdir)/ruby/internal/intern/load.h
@@ -152,7 +152,6 @@ date_core.o: $(hdrdir)/ruby/internal/memory.h
date_core.o: $(hdrdir)/ruby/internal/method.h
date_core.o: $(hdrdir)/ruby/internal/module.h
date_core.o: $(hdrdir)/ruby/internal/newobj.h
-date_core.o: $(hdrdir)/ruby/internal/rgengc.h
date_core.o: $(hdrdir)/ruby/internal/scan_args.h
date_core.o: $(hdrdir)/ruby/internal/special_consts.h
date_core.o: $(hdrdir)/ruby/internal/static_assert.h
@@ -227,6 +226,7 @@ date_parse.o: $(hdrdir)/ruby/internal/attr/noexcept.h
date_parse.o: $(hdrdir)/ruby/internal/attr/noinline.h
date_parse.o: $(hdrdir)/ruby/internal/attr/nonnull.h
date_parse.o: $(hdrdir)/ruby/internal/attr/noreturn.h
+date_parse.o: $(hdrdir)/ruby/internal/attr/packed_struct.h
date_parse.o: $(hdrdir)/ruby/internal/attr/pure.h
date_parse.o: $(hdrdir)/ruby/internal/attr/restrict.h
date_parse.o: $(hdrdir)/ruby/internal/attr/returns_nonnull.h
@@ -296,7 +296,6 @@ date_parse.o: $(hdrdir)/ruby/internal/intern/enumerator.h
date_parse.o: $(hdrdir)/ruby/internal/intern/error.h
date_parse.o: $(hdrdir)/ruby/internal/intern/eval.h
date_parse.o: $(hdrdir)/ruby/internal/intern/file.h
-date_parse.o: $(hdrdir)/ruby/internal/intern/gc.h
date_parse.o: $(hdrdir)/ruby/internal/intern/hash.h
date_parse.o: $(hdrdir)/ruby/internal/intern/io.h
date_parse.o: $(hdrdir)/ruby/internal/intern/load.h
@@ -327,7 +326,6 @@ date_parse.o: $(hdrdir)/ruby/internal/memory.h
date_parse.o: $(hdrdir)/ruby/internal/method.h
date_parse.o: $(hdrdir)/ruby/internal/module.h
date_parse.o: $(hdrdir)/ruby/internal/newobj.h
-date_parse.o: $(hdrdir)/ruby/internal/rgengc.h
date_parse.o: $(hdrdir)/ruby/internal/scan_args.h
date_parse.o: $(hdrdir)/ruby/internal/special_consts.h
date_parse.o: $(hdrdir)/ruby/internal/static_assert.h
@@ -402,6 +400,7 @@ date_strftime.o: $(hdrdir)/ruby/internal/attr/noexcept.h
date_strftime.o: $(hdrdir)/ruby/internal/attr/noinline.h
date_strftime.o: $(hdrdir)/ruby/internal/attr/nonnull.h
date_strftime.o: $(hdrdir)/ruby/internal/attr/noreturn.h
+date_strftime.o: $(hdrdir)/ruby/internal/attr/packed_struct.h
date_strftime.o: $(hdrdir)/ruby/internal/attr/pure.h
date_strftime.o: $(hdrdir)/ruby/internal/attr/restrict.h
date_strftime.o: $(hdrdir)/ruby/internal/attr/returns_nonnull.h
@@ -461,7 +460,6 @@ date_strftime.o: $(hdrdir)/ruby/internal/intern/enumerator.h
date_strftime.o: $(hdrdir)/ruby/internal/intern/error.h
date_strftime.o: $(hdrdir)/ruby/internal/intern/eval.h
date_strftime.o: $(hdrdir)/ruby/internal/intern/file.h
-date_strftime.o: $(hdrdir)/ruby/internal/intern/gc.h
date_strftime.o: $(hdrdir)/ruby/internal/intern/hash.h
date_strftime.o: $(hdrdir)/ruby/internal/intern/io.h
date_strftime.o: $(hdrdir)/ruby/internal/intern/load.h
@@ -492,7 +490,6 @@ date_strftime.o: $(hdrdir)/ruby/internal/memory.h
date_strftime.o: $(hdrdir)/ruby/internal/method.h
date_strftime.o: $(hdrdir)/ruby/internal/module.h
date_strftime.o: $(hdrdir)/ruby/internal/newobj.h
-date_strftime.o: $(hdrdir)/ruby/internal/rgengc.h
date_strftime.o: $(hdrdir)/ruby/internal/scan_args.h
date_strftime.o: $(hdrdir)/ruby/internal/special_consts.h
date_strftime.o: $(hdrdir)/ruby/internal/static_assert.h
@@ -564,6 +561,7 @@ date_strptime.o: $(hdrdir)/ruby/internal/attr/noexcept.h
date_strptime.o: $(hdrdir)/ruby/internal/attr/noinline.h
date_strptime.o: $(hdrdir)/ruby/internal/attr/nonnull.h
date_strptime.o: $(hdrdir)/ruby/internal/attr/noreturn.h
+date_strptime.o: $(hdrdir)/ruby/internal/attr/packed_struct.h
date_strptime.o: $(hdrdir)/ruby/internal/attr/pure.h
date_strptime.o: $(hdrdir)/ruby/internal/attr/restrict.h
date_strptime.o: $(hdrdir)/ruby/internal/attr/returns_nonnull.h
@@ -633,7 +631,6 @@ date_strptime.o: $(hdrdir)/ruby/internal/intern/enumerator.h
date_strptime.o: $(hdrdir)/ruby/internal/intern/error.h
date_strptime.o: $(hdrdir)/ruby/internal/intern/eval.h
date_strptime.o: $(hdrdir)/ruby/internal/intern/file.h
-date_strptime.o: $(hdrdir)/ruby/internal/intern/gc.h
date_strptime.o: $(hdrdir)/ruby/internal/intern/hash.h
date_strptime.o: $(hdrdir)/ruby/internal/intern/io.h
date_strptime.o: $(hdrdir)/ruby/internal/intern/load.h
@@ -664,7 +661,6 @@ date_strptime.o: $(hdrdir)/ruby/internal/memory.h
date_strptime.o: $(hdrdir)/ruby/internal/method.h
date_strptime.o: $(hdrdir)/ruby/internal/module.h
date_strptime.o: $(hdrdir)/ruby/internal/newobj.h
-date_strptime.o: $(hdrdir)/ruby/internal/rgengc.h
date_strptime.o: $(hdrdir)/ruby/internal/scan_args.h
date_strptime.o: $(hdrdir)/ruby/internal/special_consts.h
date_strptime.o: $(hdrdir)/ruby/internal/static_assert.h
diff --git a/ext/date/lib/date.rb b/ext/date/lib/date.rb
index a9fe3ce4b0..6888bd2d4e 100644
--- a/ext/date/lib/date.rb
+++ b/ext/date/lib/date.rb
@@ -4,7 +4,7 @@
require 'date_core'
class Date
- VERSION = "3.3.3" # :nodoc:
+ VERSION = "3.3.4" # :nodoc:
# call-seq:
# infinite? -> false
diff --git a/ext/digest/bubblebabble/depend b/ext/digest/bubblebabble/depend
index 38f5ddb1e2..6f0003a66d 100644
--- a/ext/digest/bubblebabble/depend
+++ b/ext/digest/bubblebabble/depend
@@ -52,6 +52,7 @@ bubblebabble.o: $(hdrdir)/ruby/internal/attr/noexcept.h
bubblebabble.o: $(hdrdir)/ruby/internal/attr/noinline.h
bubblebabble.o: $(hdrdir)/ruby/internal/attr/nonnull.h
bubblebabble.o: $(hdrdir)/ruby/internal/attr/noreturn.h
+bubblebabble.o: $(hdrdir)/ruby/internal/attr/packed_struct.h
bubblebabble.o: $(hdrdir)/ruby/internal/attr/pure.h
bubblebabble.o: $(hdrdir)/ruby/internal/attr/restrict.h
bubblebabble.o: $(hdrdir)/ruby/internal/attr/returns_nonnull.h
@@ -111,7 +112,6 @@ bubblebabble.o: $(hdrdir)/ruby/internal/intern/enumerator.h
bubblebabble.o: $(hdrdir)/ruby/internal/intern/error.h
bubblebabble.o: $(hdrdir)/ruby/internal/intern/eval.h
bubblebabble.o: $(hdrdir)/ruby/internal/intern/file.h
-bubblebabble.o: $(hdrdir)/ruby/internal/intern/gc.h
bubblebabble.o: $(hdrdir)/ruby/internal/intern/hash.h
bubblebabble.o: $(hdrdir)/ruby/internal/intern/io.h
bubblebabble.o: $(hdrdir)/ruby/internal/intern/load.h
@@ -142,7 +142,6 @@ bubblebabble.o: $(hdrdir)/ruby/internal/memory.h
bubblebabble.o: $(hdrdir)/ruby/internal/method.h
bubblebabble.o: $(hdrdir)/ruby/internal/module.h
bubblebabble.o: $(hdrdir)/ruby/internal/newobj.h
-bubblebabble.o: $(hdrdir)/ruby/internal/rgengc.h
bubblebabble.o: $(hdrdir)/ruby/internal/scan_args.h
bubblebabble.o: $(hdrdir)/ruby/internal/special_consts.h
bubblebabble.o: $(hdrdir)/ruby/internal/static_assert.h
diff --git a/ext/digest/depend b/ext/digest/depend
index 5a84fd53ec..6df940a679 100644
--- a/ext/digest/depend
+++ b/ext/digest/depend
@@ -52,6 +52,7 @@ digest.o: $(hdrdir)/ruby/internal/attr/noexcept.h
digest.o: $(hdrdir)/ruby/internal/attr/noinline.h
digest.o: $(hdrdir)/ruby/internal/attr/nonnull.h
digest.o: $(hdrdir)/ruby/internal/attr/noreturn.h
+digest.o: $(hdrdir)/ruby/internal/attr/packed_struct.h
digest.o: $(hdrdir)/ruby/internal/attr/pure.h
digest.o: $(hdrdir)/ruby/internal/attr/restrict.h
digest.o: $(hdrdir)/ruby/internal/attr/returns_nonnull.h
@@ -111,7 +112,6 @@ digest.o: $(hdrdir)/ruby/internal/intern/enumerator.h
digest.o: $(hdrdir)/ruby/internal/intern/error.h
digest.o: $(hdrdir)/ruby/internal/intern/eval.h
digest.o: $(hdrdir)/ruby/internal/intern/file.h
-digest.o: $(hdrdir)/ruby/internal/intern/gc.h
digest.o: $(hdrdir)/ruby/internal/intern/hash.h
digest.o: $(hdrdir)/ruby/internal/intern/io.h
digest.o: $(hdrdir)/ruby/internal/intern/load.h
@@ -142,7 +142,6 @@ digest.o: $(hdrdir)/ruby/internal/memory.h
digest.o: $(hdrdir)/ruby/internal/method.h
digest.o: $(hdrdir)/ruby/internal/module.h
digest.o: $(hdrdir)/ruby/internal/newobj.h
-digest.o: $(hdrdir)/ruby/internal/rgengc.h
digest.o: $(hdrdir)/ruby/internal/scan_args.h
digest.o: $(hdrdir)/ruby/internal/special_consts.h
digest.o: $(hdrdir)/ruby/internal/static_assert.h
diff --git a/ext/digest/digest.h b/ext/digest/digest.h
index 8a4c5b7e4e..68a3da5dd2 100644
--- a/ext/digest/digest.h
+++ b/ext/digest/digest.h
@@ -40,7 +40,8 @@ rb_digest_##name##_update(void *ctx, unsigned char *ptr, size_t size) \
for (; size > stride; size -= stride, ptr += stride) { \
name##_Update(ctx, ptr, stride); \
} \
- if (size > 0) name##_Update(ctx, ptr, size); \
+ /* Since size <= stride, size should fit into an unsigned int */ \
+ if (size > 0) name##_Update(ctx, ptr, (unsigned int)size); \
}
#define DEFINE_FINISH_FUNC_FROM_FINAL(name) \
diff --git a/ext/digest/md5/depend b/ext/digest/md5/depend
index ea1ceec7fd..da1b345999 100644
--- a/ext/digest/md5/depend
+++ b/ext/digest/md5/depend
@@ -55,6 +55,7 @@ md5.o: $(hdrdir)/ruby/internal/attr/noexcept.h
md5.o: $(hdrdir)/ruby/internal/attr/noinline.h
md5.o: $(hdrdir)/ruby/internal/attr/nonnull.h
md5.o: $(hdrdir)/ruby/internal/attr/noreturn.h
+md5.o: $(hdrdir)/ruby/internal/attr/packed_struct.h
md5.o: $(hdrdir)/ruby/internal/attr/pure.h
md5.o: $(hdrdir)/ruby/internal/attr/restrict.h
md5.o: $(hdrdir)/ruby/internal/attr/returns_nonnull.h
@@ -114,7 +115,6 @@ md5.o: $(hdrdir)/ruby/internal/intern/enumerator.h
md5.o: $(hdrdir)/ruby/internal/intern/error.h
md5.o: $(hdrdir)/ruby/internal/intern/eval.h
md5.o: $(hdrdir)/ruby/internal/intern/file.h
-md5.o: $(hdrdir)/ruby/internal/intern/gc.h
md5.o: $(hdrdir)/ruby/internal/intern/hash.h
md5.o: $(hdrdir)/ruby/internal/intern/io.h
md5.o: $(hdrdir)/ruby/internal/intern/load.h
@@ -145,7 +145,6 @@ md5.o: $(hdrdir)/ruby/internal/memory.h
md5.o: $(hdrdir)/ruby/internal/method.h
md5.o: $(hdrdir)/ruby/internal/module.h
md5.o: $(hdrdir)/ruby/internal/newobj.h
-md5.o: $(hdrdir)/ruby/internal/rgengc.h
md5.o: $(hdrdir)/ruby/internal/scan_args.h
md5.o: $(hdrdir)/ruby/internal/special_consts.h
md5.o: $(hdrdir)/ruby/internal/static_assert.h
@@ -217,6 +216,7 @@ md5init.o: $(hdrdir)/ruby/internal/attr/noexcept.h
md5init.o: $(hdrdir)/ruby/internal/attr/noinline.h
md5init.o: $(hdrdir)/ruby/internal/attr/nonnull.h
md5init.o: $(hdrdir)/ruby/internal/attr/noreturn.h
+md5init.o: $(hdrdir)/ruby/internal/attr/packed_struct.h
md5init.o: $(hdrdir)/ruby/internal/attr/pure.h
md5init.o: $(hdrdir)/ruby/internal/attr/restrict.h
md5init.o: $(hdrdir)/ruby/internal/attr/returns_nonnull.h
@@ -276,7 +276,6 @@ md5init.o: $(hdrdir)/ruby/internal/intern/enumerator.h
md5init.o: $(hdrdir)/ruby/internal/intern/error.h
md5init.o: $(hdrdir)/ruby/internal/intern/eval.h
md5init.o: $(hdrdir)/ruby/internal/intern/file.h
-md5init.o: $(hdrdir)/ruby/internal/intern/gc.h
md5init.o: $(hdrdir)/ruby/internal/intern/hash.h
md5init.o: $(hdrdir)/ruby/internal/intern/io.h
md5init.o: $(hdrdir)/ruby/internal/intern/load.h
@@ -307,7 +306,6 @@ md5init.o: $(hdrdir)/ruby/internal/memory.h
md5init.o: $(hdrdir)/ruby/internal/method.h
md5init.o: $(hdrdir)/ruby/internal/module.h
md5init.o: $(hdrdir)/ruby/internal/newobj.h
-md5init.o: $(hdrdir)/ruby/internal/rgengc.h
md5init.o: $(hdrdir)/ruby/internal/scan_args.h
md5init.o: $(hdrdir)/ruby/internal/special_consts.h
md5init.o: $(hdrdir)/ruby/internal/static_assert.h
diff --git a/ext/digest/rmd160/depend b/ext/digest/rmd160/depend
index 3a0ed72732..abfa08b023 100644
--- a/ext/digest/rmd160/depend
+++ b/ext/digest/rmd160/depend
@@ -55,6 +55,7 @@ rmd160.o: $(hdrdir)/ruby/internal/attr/noexcept.h
rmd160.o: $(hdrdir)/ruby/internal/attr/noinline.h
rmd160.o: $(hdrdir)/ruby/internal/attr/nonnull.h
rmd160.o: $(hdrdir)/ruby/internal/attr/noreturn.h
+rmd160.o: $(hdrdir)/ruby/internal/attr/packed_struct.h
rmd160.o: $(hdrdir)/ruby/internal/attr/pure.h
rmd160.o: $(hdrdir)/ruby/internal/attr/restrict.h
rmd160.o: $(hdrdir)/ruby/internal/attr/returns_nonnull.h
@@ -114,7 +115,6 @@ rmd160.o: $(hdrdir)/ruby/internal/intern/enumerator.h
rmd160.o: $(hdrdir)/ruby/internal/intern/error.h
rmd160.o: $(hdrdir)/ruby/internal/intern/eval.h
rmd160.o: $(hdrdir)/ruby/internal/intern/file.h
-rmd160.o: $(hdrdir)/ruby/internal/intern/gc.h
rmd160.o: $(hdrdir)/ruby/internal/intern/hash.h
rmd160.o: $(hdrdir)/ruby/internal/intern/io.h
rmd160.o: $(hdrdir)/ruby/internal/intern/load.h
@@ -145,7 +145,6 @@ rmd160.o: $(hdrdir)/ruby/internal/memory.h
rmd160.o: $(hdrdir)/ruby/internal/method.h
rmd160.o: $(hdrdir)/ruby/internal/module.h
rmd160.o: $(hdrdir)/ruby/internal/newobj.h
-rmd160.o: $(hdrdir)/ruby/internal/rgengc.h
rmd160.o: $(hdrdir)/ruby/internal/scan_args.h
rmd160.o: $(hdrdir)/ruby/internal/special_consts.h
rmd160.o: $(hdrdir)/ruby/internal/static_assert.h
@@ -217,6 +216,7 @@ rmd160init.o: $(hdrdir)/ruby/internal/attr/noexcept.h
rmd160init.o: $(hdrdir)/ruby/internal/attr/noinline.h
rmd160init.o: $(hdrdir)/ruby/internal/attr/nonnull.h
rmd160init.o: $(hdrdir)/ruby/internal/attr/noreturn.h
+rmd160init.o: $(hdrdir)/ruby/internal/attr/packed_struct.h
rmd160init.o: $(hdrdir)/ruby/internal/attr/pure.h
rmd160init.o: $(hdrdir)/ruby/internal/attr/restrict.h
rmd160init.o: $(hdrdir)/ruby/internal/attr/returns_nonnull.h
@@ -276,7 +276,6 @@ rmd160init.o: $(hdrdir)/ruby/internal/intern/enumerator.h
rmd160init.o: $(hdrdir)/ruby/internal/intern/error.h
rmd160init.o: $(hdrdir)/ruby/internal/intern/eval.h
rmd160init.o: $(hdrdir)/ruby/internal/intern/file.h
-rmd160init.o: $(hdrdir)/ruby/internal/intern/gc.h
rmd160init.o: $(hdrdir)/ruby/internal/intern/hash.h
rmd160init.o: $(hdrdir)/ruby/internal/intern/io.h
rmd160init.o: $(hdrdir)/ruby/internal/intern/load.h
@@ -307,7 +306,6 @@ rmd160init.o: $(hdrdir)/ruby/internal/memory.h
rmd160init.o: $(hdrdir)/ruby/internal/method.h
rmd160init.o: $(hdrdir)/ruby/internal/module.h
rmd160init.o: $(hdrdir)/ruby/internal/newobj.h
-rmd160init.o: $(hdrdir)/ruby/internal/rgengc.h
rmd160init.o: $(hdrdir)/ruby/internal/scan_args.h
rmd160init.o: $(hdrdir)/ruby/internal/special_consts.h
rmd160init.o: $(hdrdir)/ruby/internal/static_assert.h
diff --git a/ext/digest/sha1/depend b/ext/digest/sha1/depend
index 48aaef158b..d17338e92b 100644
--- a/ext/digest/sha1/depend
+++ b/ext/digest/sha1/depend
@@ -55,6 +55,7 @@ sha1.o: $(hdrdir)/ruby/internal/attr/noexcept.h
sha1.o: $(hdrdir)/ruby/internal/attr/noinline.h
sha1.o: $(hdrdir)/ruby/internal/attr/nonnull.h
sha1.o: $(hdrdir)/ruby/internal/attr/noreturn.h
+sha1.o: $(hdrdir)/ruby/internal/attr/packed_struct.h
sha1.o: $(hdrdir)/ruby/internal/attr/pure.h
sha1.o: $(hdrdir)/ruby/internal/attr/restrict.h
sha1.o: $(hdrdir)/ruby/internal/attr/returns_nonnull.h
@@ -114,7 +115,6 @@ sha1.o: $(hdrdir)/ruby/internal/intern/enumerator.h
sha1.o: $(hdrdir)/ruby/internal/intern/error.h
sha1.o: $(hdrdir)/ruby/internal/intern/eval.h
sha1.o: $(hdrdir)/ruby/internal/intern/file.h
-sha1.o: $(hdrdir)/ruby/internal/intern/gc.h
sha1.o: $(hdrdir)/ruby/internal/intern/hash.h
sha1.o: $(hdrdir)/ruby/internal/intern/io.h
sha1.o: $(hdrdir)/ruby/internal/intern/load.h
@@ -145,7 +145,6 @@ sha1.o: $(hdrdir)/ruby/internal/memory.h
sha1.o: $(hdrdir)/ruby/internal/method.h
sha1.o: $(hdrdir)/ruby/internal/module.h
sha1.o: $(hdrdir)/ruby/internal/newobj.h
-sha1.o: $(hdrdir)/ruby/internal/rgengc.h
sha1.o: $(hdrdir)/ruby/internal/scan_args.h
sha1.o: $(hdrdir)/ruby/internal/special_consts.h
sha1.o: $(hdrdir)/ruby/internal/static_assert.h
@@ -217,6 +216,7 @@ sha1init.o: $(hdrdir)/ruby/internal/attr/noexcept.h
sha1init.o: $(hdrdir)/ruby/internal/attr/noinline.h
sha1init.o: $(hdrdir)/ruby/internal/attr/nonnull.h
sha1init.o: $(hdrdir)/ruby/internal/attr/noreturn.h
+sha1init.o: $(hdrdir)/ruby/internal/attr/packed_struct.h
sha1init.o: $(hdrdir)/ruby/internal/attr/pure.h
sha1init.o: $(hdrdir)/ruby/internal/attr/restrict.h
sha1init.o: $(hdrdir)/ruby/internal/attr/returns_nonnull.h
@@ -276,7 +276,6 @@ sha1init.o: $(hdrdir)/ruby/internal/intern/enumerator.h
sha1init.o: $(hdrdir)/ruby/internal/intern/error.h
sha1init.o: $(hdrdir)/ruby/internal/intern/eval.h
sha1init.o: $(hdrdir)/ruby/internal/intern/file.h
-sha1init.o: $(hdrdir)/ruby/internal/intern/gc.h
sha1init.o: $(hdrdir)/ruby/internal/intern/hash.h
sha1init.o: $(hdrdir)/ruby/internal/intern/io.h
sha1init.o: $(hdrdir)/ruby/internal/intern/load.h
@@ -307,7 +306,6 @@ sha1init.o: $(hdrdir)/ruby/internal/memory.h
sha1init.o: $(hdrdir)/ruby/internal/method.h
sha1init.o: $(hdrdir)/ruby/internal/module.h
sha1init.o: $(hdrdir)/ruby/internal/newobj.h
-sha1init.o: $(hdrdir)/ruby/internal/rgengc.h
sha1init.o: $(hdrdir)/ruby/internal/scan_args.h
sha1init.o: $(hdrdir)/ruby/internal/special_consts.h
sha1init.o: $(hdrdir)/ruby/internal/static_assert.h
diff --git a/ext/digest/sha2/depend b/ext/digest/sha2/depend
index 47a859068c..7b88b6411f 100644
--- a/ext/digest/sha2/depend
+++ b/ext/digest/sha2/depend
@@ -55,6 +55,7 @@ sha2.o: $(hdrdir)/ruby/internal/attr/noexcept.h
sha2.o: $(hdrdir)/ruby/internal/attr/noinline.h
sha2.o: $(hdrdir)/ruby/internal/attr/nonnull.h
sha2.o: $(hdrdir)/ruby/internal/attr/noreturn.h
+sha2.o: $(hdrdir)/ruby/internal/attr/packed_struct.h
sha2.o: $(hdrdir)/ruby/internal/attr/pure.h
sha2.o: $(hdrdir)/ruby/internal/attr/restrict.h
sha2.o: $(hdrdir)/ruby/internal/attr/returns_nonnull.h
@@ -114,7 +115,6 @@ sha2.o: $(hdrdir)/ruby/internal/intern/enumerator.h
sha2.o: $(hdrdir)/ruby/internal/intern/error.h
sha2.o: $(hdrdir)/ruby/internal/intern/eval.h
sha2.o: $(hdrdir)/ruby/internal/intern/file.h
-sha2.o: $(hdrdir)/ruby/internal/intern/gc.h
sha2.o: $(hdrdir)/ruby/internal/intern/hash.h
sha2.o: $(hdrdir)/ruby/internal/intern/io.h
sha2.o: $(hdrdir)/ruby/internal/intern/load.h
@@ -145,7 +145,6 @@ sha2.o: $(hdrdir)/ruby/internal/memory.h
sha2.o: $(hdrdir)/ruby/internal/method.h
sha2.o: $(hdrdir)/ruby/internal/module.h
sha2.o: $(hdrdir)/ruby/internal/newobj.h
-sha2.o: $(hdrdir)/ruby/internal/rgengc.h
sha2.o: $(hdrdir)/ruby/internal/scan_args.h
sha2.o: $(hdrdir)/ruby/internal/special_consts.h
sha2.o: $(hdrdir)/ruby/internal/static_assert.h
@@ -217,6 +216,7 @@ sha2init.o: $(hdrdir)/ruby/internal/attr/noexcept.h
sha2init.o: $(hdrdir)/ruby/internal/attr/noinline.h
sha2init.o: $(hdrdir)/ruby/internal/attr/nonnull.h
sha2init.o: $(hdrdir)/ruby/internal/attr/noreturn.h
+sha2init.o: $(hdrdir)/ruby/internal/attr/packed_struct.h
sha2init.o: $(hdrdir)/ruby/internal/attr/pure.h
sha2init.o: $(hdrdir)/ruby/internal/attr/restrict.h
sha2init.o: $(hdrdir)/ruby/internal/attr/returns_nonnull.h
@@ -276,7 +276,6 @@ sha2init.o: $(hdrdir)/ruby/internal/intern/enumerator.h
sha2init.o: $(hdrdir)/ruby/internal/intern/error.h
sha2init.o: $(hdrdir)/ruby/internal/intern/eval.h
sha2init.o: $(hdrdir)/ruby/internal/intern/file.h
-sha2init.o: $(hdrdir)/ruby/internal/intern/gc.h
sha2init.o: $(hdrdir)/ruby/internal/intern/hash.h
sha2init.o: $(hdrdir)/ruby/internal/intern/io.h
sha2init.o: $(hdrdir)/ruby/internal/intern/load.h
@@ -307,7 +306,6 @@ sha2init.o: $(hdrdir)/ruby/internal/memory.h
sha2init.o: $(hdrdir)/ruby/internal/method.h
sha2init.o: $(hdrdir)/ruby/internal/module.h
sha2init.o: $(hdrdir)/ruby/internal/newobj.h
-sha2init.o: $(hdrdir)/ruby/internal/rgengc.h
sha2init.o: $(hdrdir)/ruby/internal/scan_args.h
sha2init.o: $(hdrdir)/ruby/internal/special_consts.h
sha2init.o: $(hdrdir)/ruby/internal/static_assert.h
diff --git a/ext/etc/depend b/ext/etc/depend
index a541db6db6..00787b6aaf 100644
--- a/ext/etc/depend
+++ b/ext/etc/depend
@@ -58,6 +58,7 @@ etc.o: $(hdrdir)/ruby/internal/attr/noexcept.h
etc.o: $(hdrdir)/ruby/internal/attr/noinline.h
etc.o: $(hdrdir)/ruby/internal/attr/nonnull.h
etc.o: $(hdrdir)/ruby/internal/attr/noreturn.h
+etc.o: $(hdrdir)/ruby/internal/attr/packed_struct.h
etc.o: $(hdrdir)/ruby/internal/attr/pure.h
etc.o: $(hdrdir)/ruby/internal/attr/restrict.h
etc.o: $(hdrdir)/ruby/internal/attr/returns_nonnull.h
@@ -126,7 +127,6 @@ etc.o: $(hdrdir)/ruby/internal/intern/enumerator.h
etc.o: $(hdrdir)/ruby/internal/intern/error.h
etc.o: $(hdrdir)/ruby/internal/intern/eval.h
etc.o: $(hdrdir)/ruby/internal/intern/file.h
-etc.o: $(hdrdir)/ruby/internal/intern/gc.h
etc.o: $(hdrdir)/ruby/internal/intern/hash.h
etc.o: $(hdrdir)/ruby/internal/intern/io.h
etc.o: $(hdrdir)/ruby/internal/intern/load.h
@@ -157,7 +157,6 @@ etc.o: $(hdrdir)/ruby/internal/memory.h
etc.o: $(hdrdir)/ruby/internal/method.h
etc.o: $(hdrdir)/ruby/internal/module.h
etc.o: $(hdrdir)/ruby/internal/newobj.h
-etc.o: $(hdrdir)/ruby/internal/rgengc.h
etc.o: $(hdrdir)/ruby/internal/scan_args.h
etc.o: $(hdrdir)/ruby/internal/special_consts.h
etc.o: $(hdrdir)/ruby/internal/static_assert.h
diff --git a/ext/etc/etc.c b/ext/etc/etc.c
index 6c7145b40b..23127ca613 100644
--- a/ext/etc/etc.c
+++ b/ext/etc/etc.c
@@ -54,9 +54,9 @@ static VALUE sGroup;
# include <stdlib.h>
# endif
#endif
-char *getlogin();
+RUBY_EXTERN char *getlogin(void);
-#define RUBY_ETC_VERSION "1.4.2"
+#define RUBY_ETC_VERSION "1.4.3"
#ifdef HAVE_RB_DEPRECATE_CONSTANT
void rb_deprecate_constant(VALUE mod, const char *name);
@@ -66,6 +66,17 @@ void rb_deprecate_constant(VALUE mod, const char *name);
#include "constdefs.h"
+#ifndef HAVE_RB_IO_DESCRIPTOR
+static int
+io_descriptor_fallback(VALUE io)
+{
+ rb_io_t *fptr;
+ GetOpenFile(io, fptr);
+ return fptr->fd;
+}
+#define rb_io_descriptor io_descriptor_fallback
+#endif
+
#ifdef HAVE_RUBY_ATOMIC_H
# include "ruby/atomic.h"
#else
@@ -941,14 +952,11 @@ io_pathconf(VALUE io, VALUE arg)
{
int name;
long ret;
- rb_io_t *fptr;
name = NUM2INT(arg);
- GetOpenFile(io, fptr);
-
errno = 0;
- ret = fpathconf(fptr->fd, name);
+ ret = fpathconf(rb_io_descriptor(io), name);
if (ret == -1) {
if (errno == 0) /* no limit */
return Qnil;
diff --git a/ext/etc/extconf.rb b/ext/etc/extconf.rb
index 159b1614b7..2e28d58037 100644
--- a/ext/etc/extconf.rb
+++ b/ext/etc/extconf.rb
@@ -43,13 +43,23 @@ have_struct_member('struct group', 'gr_passwd', 'grp.h')
# for https://github.com/ruby/etc
srcdir = File.expand_path("..", __FILE__)
-if !File.exist?("#{srcdir}/depend")
- %x[#{RbConfig.ruby} #{srcdir}/mkconstants.rb -o #{srcdir}/constdefs.h]
+constdefs = "#{srcdir}/constdefs.h"
+if !File.exist?(constdefs)
+ ruby = RbConfig.ruby
+ if File.file?(ruby)
+ ruby = [ruby]
+ else
+ require "shellwords"
+ ruby = Shellwords.split(ruby)
+ end
+ system(*ruby, "#{srcdir}/mkconstants.rb", "-o", constdefs)
end
# TODO: remove when dropping 2.7 support, as exported since 3.0
have_func('rb_deprecate_constant(Qnil, "None")')
+have_func("rb_io_descriptor")
+
$distcleanfiles << "constdefs.h"
create_makefile("etc")
diff --git a/ext/extmk.rb b/ext/extmk.rb
index cab9a519c1..d9c2417dfa 100755
--- a/ext/extmk.rb
+++ b/ext/extmk.rb
@@ -43,11 +43,7 @@ $" << "mkmf.rb"
load File.expand_path("lib/mkmf.rb", srcdir)
require 'optparse/shellwords'
-if defined?(File::NULL)
- @null = File::NULL
-elsif !File.chardev?(@null = "/dev/null")
- @null = "nul"
-end
+@null = File::NULL
def verbose?
$mflags.defined?("V") == "1"
@@ -136,6 +132,14 @@ def extract_makefile(makefile, keep = true)
true
end
+def create_makefile(target, srcprefix = nil)
+ if $static and target.include?("/")
+ base = File.basename(target)
+ $defs << "-DInit_#{base}=Init_#{target.tr('/', '_')}"
+ end
+ super
+end
+
def extmake(target, basedir = 'ext', maybestatic = true)
FileUtils.mkpath target unless File.directory?(target)
begin
@@ -549,7 +553,13 @@ extend Module.new {
end
def create_makefile(*args, &block)
- return super unless @gemname
+ unless @gemname
+ if $static and (target = args.first).include?("/")
+ base = File.basename(target)
+ $defs << "-DInit_#{base}=Init_#{target.tr('/', '_')}"
+ end
+ return super
+ end
super(*args) do |conf|
conf.find do |s|
s.sub!(%r(^(srcdir *= *)\$\(top_srcdir\)/\.bundle/gems/[^/]+(?=/))) {
@@ -764,6 +774,13 @@ begin
mf.macro "NOTE_MESG", %w[$(RUBY) $(top_srcdir)/tool/lib/colorize.rb skip]
mf.macro "NOTE_NAME", %w[$(RUBY) $(top_srcdir)/tool/lib/colorize.rb fail]
%w[RM RMDIRS RMDIR RMALL].each {|w| mf.macro w, [RbConfig::CONFIG[w]]}
+ if $nmake
+ message = ['@(for %I in (', ') do @echo.%~I)']
+ else
+ message = ['@for line in', '; do echo "$$line"; done']
+ end
+ mf.macro "MESSAGE_BEGIN", [message.first]
+ mf.macro "MESSAGE_END", [message.last]
mf.puts
targets = %w[all install static install-so install-rb clean distclean realclean]
targets.each do |tgt|
@@ -826,15 +843,17 @@ begin
fails.each do |ext, (parent, err)|
abandon ||= mandatory_exts[ext]
mf.puts %Q<\t@$(NOTE_NAME) "#{ext}:">
+ mf.puts "\t$(MESSAGE_BEGIN) \\"
if parent
- mf.puts %Q<\t@echo "\tCould not be configured. It will not be installed.">
+ mf.puts %Q<\t"\tCould not be configured. It will not be installed." \\>
err and err.scan(/.+/) do |ee|
- mf.puts %Q<\t@echo "\t#{ee.gsub(/["`$^]/, '\\\\\\&')}">
+ mf.puts %Q<\t"\t#{ee.gsub(/["`$^]/, '\\\\\\&')}" \\>
end
- mf.puts %Q<\t@echo "\tCheck #{ext_prefix}/#{ext}/mkmf.log for more details.">
+ mf.puts %Q<\t"\tCheck #{ext_prefix}/#{ext}/mkmf.log for more details." \\>
else
- mf.puts %Q<\t@echo "\tSkipped because its parent was not configured.">
+ mf.puts %Q<\t"\tSkipped because its parent was not configured." \\>
end
+ mf.puts "\t$(MESSAGE_END)"
end
mf.puts "note:\n"
mf.puts %Q<\t@$(NOTE_MESG) "*** Fix the problems, then remove these directories and try again if you want.">
diff --git a/ext/fcntl/depend b/ext/fcntl/depend
index 718de62e26..9ce9fa30ef 100644
--- a/ext/fcntl/depend
+++ b/ext/fcntl/depend
@@ -52,6 +52,7 @@ fcntl.o: $(hdrdir)/ruby/internal/attr/noexcept.h
fcntl.o: $(hdrdir)/ruby/internal/attr/noinline.h
fcntl.o: $(hdrdir)/ruby/internal/attr/nonnull.h
fcntl.o: $(hdrdir)/ruby/internal/attr/noreturn.h
+fcntl.o: $(hdrdir)/ruby/internal/attr/packed_struct.h
fcntl.o: $(hdrdir)/ruby/internal/attr/pure.h
fcntl.o: $(hdrdir)/ruby/internal/attr/restrict.h
fcntl.o: $(hdrdir)/ruby/internal/attr/returns_nonnull.h
@@ -111,7 +112,6 @@ fcntl.o: $(hdrdir)/ruby/internal/intern/enumerator.h
fcntl.o: $(hdrdir)/ruby/internal/intern/error.h
fcntl.o: $(hdrdir)/ruby/internal/intern/eval.h
fcntl.o: $(hdrdir)/ruby/internal/intern/file.h
-fcntl.o: $(hdrdir)/ruby/internal/intern/gc.h
fcntl.o: $(hdrdir)/ruby/internal/intern/hash.h
fcntl.o: $(hdrdir)/ruby/internal/intern/io.h
fcntl.o: $(hdrdir)/ruby/internal/intern/load.h
@@ -142,7 +142,6 @@ fcntl.o: $(hdrdir)/ruby/internal/memory.h
fcntl.o: $(hdrdir)/ruby/internal/method.h
fcntl.o: $(hdrdir)/ruby/internal/module.h
fcntl.o: $(hdrdir)/ruby/internal/newobj.h
-fcntl.o: $(hdrdir)/ruby/internal/rgengc.h
fcntl.o: $(hdrdir)/ruby/internal/scan_args.h
fcntl.o: $(hdrdir)/ruby/internal/special_consts.h
fcntl.o: $(hdrdir)/ruby/internal/static_assert.h
diff --git a/ext/fcntl/fcntl.c b/ext/fcntl/fcntl.c
index 3bccc41e4c..4af2077a0a 100644
--- a/ext/fcntl/fcntl.c
+++ b/ext/fcntl/fcntl.c
@@ -61,10 +61,16 @@ pack up your own arguments to pass as args for locking functions, etc.
* f.fcntl(Fcntl::F_SETFL, Fcntl::O_NONBLOCK|m)
*
*/
+
+#define FCNTL_VERSION "1.1.0"
+
void
Init_fcntl(void)
{
VALUE mFcntl = rb_define_module("Fcntl");
+
+ rb_define_const(mFcntl, "VERSION", rb_str_new_cstr(FCNTL_VERSION));
+
#ifdef F_DUPFD
/* Document-const: F_DUPFD
*
diff --git a/ext/fcntl/fcntl.gemspec b/ext/fcntl/fcntl.gemspec
index 09d3fc2568..54aadb4b81 100644
--- a/ext/fcntl/fcntl.gemspec
+++ b/ext/fcntl/fcntl.gemspec
@@ -1,9 +1,19 @@
# coding: utf-8
# frozen_string_literal: true
+source_version = ["", "ext/fcntl/"].find do |dir|
+ begin
+ break File.open(File.join(__dir__, "#{dir}fcntl.c")) {|f|
+ f.gets("\n#define FCNTL_VERSION ")
+ f.gets[/\s*"(.+)"/, 1]
+ }
+ rescue Errno::ENOENT
+ end
+end
+
Gem::Specification.new do |spec|
spec.name = "fcntl"
- spec.version = "1.0.2"
+ spec.version = source_version
spec.authors = ["Yukihiro Matsumoto"]
spec.email = ["matz@ruby-lang.org"]
diff --git a/ext/fiddle/closure.c b/ext/fiddle/closure.c
index 892f522a62..2b4cdb6608 100644
--- a/ext/fiddle/closure.c
+++ b/ext/fiddle/closure.c
@@ -1,4 +1,5 @@
#include <fiddle.h>
+#include <stdbool.h>
#include <ruby/thread.h>
int ruby_thread_has_gvl_p(void); /* from internal.h */
@@ -54,10 +55,13 @@ closure_memsize(const void * ptr)
}
const rb_data_type_t closure_data_type = {
- "fiddle/closure",
- {0, dealloc, closure_memsize,},
- 0, 0,
- RUBY_TYPED_FREE_IMMEDIATELY,
+ .wrap_struct_name = "fiddle/closure",
+ .function = {
+ .dmark = 0,
+ .dfree = dealloc,
+ .dsize = closure_memsize
+ },
+ .flags = RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_WB_PROTECTED,
};
struct callback_args {
@@ -136,6 +140,20 @@ with_gvl_callback(void *ptr)
rb_ary_push(params,
rb_str_new_cstr(*((const char **)(x->args[i]))));
break;
+ case TYPE_BOOL:
+ if (sizeof(bool) == sizeof(char)) {
+ rb_ary_push(params, CBOOL2RBBOOL(*(unsigned char *)x->args[i]));
+ } else if (sizeof(bool) == sizeof(short)) {
+ rb_ary_push(params, CBOOL2RBBOOL(*(unsigned short *)x->args[i]));
+ } else if (sizeof(bool) == sizeof(int)) {
+ rb_ary_push(params, CBOOL2RBBOOL(*(unsigned int *)x->args[i]));
+ } else if (sizeof(bool) == sizeof(long)) {
+ rb_ary_push(params, CBOOL2RBBOOL(*(unsigned long *)x->args[i]));
+ } else {
+ rb_raise(rb_eNotImpError, "bool isn't supported: %u",
+ (unsigned int)sizeof(bool));
+ }
+ break;
default:
rb_raise(rb_eRuntimeError, "closure args: %d", type);
}
@@ -185,6 +203,13 @@ with_gvl_callback(void *ptr)
/* Dangerous. Callback must keep reference of the String. */
*((const char **)(x->resp)) = StringValueCStr(ret);
break;
+ case TYPE_BOOL:
+ if (sizeof(bool) == sizeof(long)) {
+ *(unsigned long *)x->resp = RB_TEST(ret);
+ } else {
+ *(ffi_arg *)x->resp = RB_TEST(ret);
+ }
+ break;
default:
rb_raise(rb_eRuntimeError, "closure retval: %d", type);
}
diff --git a/ext/fiddle/conversions.c b/ext/fiddle/conversions.c
index 3b70f7de4c..796bf929c3 100644
--- a/ext/fiddle/conversions.c
+++ b/ext/fiddle/conversions.c
@@ -1,3 +1,5 @@
+#include <stdbool.h>
+
#include <fiddle.h>
VALUE
@@ -44,6 +46,7 @@ rb_fiddle_type_ensure(VALUE type)
ID ptrdiff_t_id;
ID intptr_t_id;
ID uintptr_t_id;
+ ID bool_id;
RUBY_CONST_ID(void_id, "void");
RUBY_CONST_ID(voidp_id, "voidp");
RUBY_CONST_ID(char_id, "char");
@@ -74,6 +77,7 @@ rb_fiddle_type_ensure(VALUE type)
RUBY_CONST_ID(ptrdiff_t_id, "ptrdiff_t");
RUBY_CONST_ID(intptr_t_id, "intptr_t");
RUBY_CONST_ID(uintptr_t_id, "uintptr_t");
+ RUBY_CONST_ID(bool_id, "bool");
if (type_id == void_id) {
return INT2NUM(TYPE_VOID);
}
@@ -144,6 +148,9 @@ rb_fiddle_type_ensure(VALUE type)
else if (type_id == uintptr_t_id) {
return INT2NUM(TYPE_UINTPTR_T);
}
+ else if (type_id == bool_id) {
+ return INT2NUM(TYPE_BOOL);
+ }
else {
type = original_type;
}
@@ -187,6 +194,20 @@ rb_fiddle_int_to_ffi_type(int type)
return &ffi_type_double;
case TYPE_CONST_STRING:
return &ffi_type_pointer;
+ case TYPE_BOOL:
+ signed_p = 0;
+ if (sizeof(bool) == sizeof(char)) {
+ return rb_ffi_type_of(char);
+ } else if (sizeof(bool) == sizeof(short)) {
+ return rb_ffi_type_of(short);
+ } else if (sizeof(bool) == sizeof(int)) {
+ return rb_ffi_type_of(int);
+ } else if (sizeof(bool) == sizeof(long)) {
+ return rb_ffi_type_of(long);
+ } else {
+ rb_raise(rb_eNotImpError, "bool isn't supported: %u",
+ (unsigned int)sizeof(bool));
+ }
default:
rb_raise(rb_eRuntimeError, "unknown type %d", type);
}
@@ -209,7 +230,11 @@ rb_fiddle_value_to_generic(int type, VALUE *src, fiddle_generic *dst)
dst->pointer = NUM2PTR(rb_Integer(*src));
break;
case TYPE_CHAR:
- dst->schar = (signed char)NUM2INT(*src);
+ if (RB_TYPE_P(*src, RUBY_T_STRING) && RSTRING_LEN(*src) == 1) {
+ dst->schar = RSTRING_PTR(*src)[0];
+ } else {
+ dst->schar = (signed char)NUM2INT(*src);
+ }
break;
case TYPE_UCHAR:
dst->uchar = (unsigned char)NUM2UINT(*src);
@@ -254,8 +279,23 @@ rb_fiddle_value_to_generic(int type, VALUE *src, fiddle_generic *dst)
dst->pointer = rb_string_value_cstr(src);
}
break;
+ case TYPE_BOOL:
+ if (sizeof(bool) == sizeof(char)) {
+ dst->uchar = RB_TEST(*src);
+ } else if (sizeof(bool) == sizeof(short)) {
+ dst->ushort = RB_TEST(*src);
+ } else if (sizeof(bool) == sizeof(int)) {
+ dst->uint = RB_TEST(*src);
+ } else if (sizeof(bool) == sizeof(long)) {
+ dst->ulong = RB_TEST(*src);
+ } else {
+ rb_raise(rb_eNotImpError, "bool isn't supported: %u",
+ (unsigned int)sizeof(bool));
+ }
+ break;
default:
rb_raise(rb_eRuntimeError, "unknown type %d", type);
+ break;
}
}
@@ -314,6 +354,19 @@ rb_fiddle_generic_to_value(VALUE rettype, fiddle_generic retval)
else {
return Qnil;
}
+ case TYPE_BOOL:
+ if (sizeof(bool) == sizeof(char)) {
+ return CBOOL2RBBOOL((unsigned char)retval.fffi_arg);
+ } else if (sizeof(bool) == sizeof(short)) {
+ return CBOOL2RBBOOL((unsigned short)retval.fffi_arg);
+ } else if (sizeof(bool) == sizeof(int)) {
+ return CBOOL2RBBOOL((unsigned int)retval.fffi_arg);
+ } else if (sizeof(bool) == sizeof(long)) {
+ return CBOOL2RBBOOL(retval.ulong);
+ } else {
+ rb_raise(rb_eNotImpError, "bool isn't supported: %u",
+ (unsigned int)sizeof(bool));
+ }
default:
rb_raise(rb_eRuntimeError, "unknown type %d", type);
}
diff --git a/ext/fiddle/conversions.h b/ext/fiddle/conversions.h
index c7c12a9234..7a1e928d56 100644
--- a/ext/fiddle/conversions.h
+++ b/ext/fiddle/conversions.h
@@ -50,4 +50,6 @@ VALUE generic_to_value(VALUE rettype, fiddle_generic retval);
# define NUM2PTR(x) ((void*)(NUM2ULL(x)))
#endif
+#define CBOOL2RBBOOL(cbool) ((cbool) ? RUBY_Qtrue : RUBY_Qfalse)
+
#endif
diff --git a/ext/fiddle/depend b/ext/fiddle/depend
index d6a053f05b..561785275e 100644
--- a/ext/fiddle/depend
+++ b/ext/fiddle/depend
@@ -105,6 +105,7 @@ closure.o: $(hdrdir)/ruby/internal/attr/noexcept.h
closure.o: $(hdrdir)/ruby/internal/attr/noinline.h
closure.o: $(hdrdir)/ruby/internal/attr/nonnull.h
closure.o: $(hdrdir)/ruby/internal/attr/noreturn.h
+closure.o: $(hdrdir)/ruby/internal/attr/packed_struct.h
closure.o: $(hdrdir)/ruby/internal/attr/pure.h
closure.o: $(hdrdir)/ruby/internal/attr/restrict.h
closure.o: $(hdrdir)/ruby/internal/attr/returns_nonnull.h
@@ -164,7 +165,6 @@ closure.o: $(hdrdir)/ruby/internal/intern/enumerator.h
closure.o: $(hdrdir)/ruby/internal/intern/error.h
closure.o: $(hdrdir)/ruby/internal/intern/eval.h
closure.o: $(hdrdir)/ruby/internal/intern/file.h
-closure.o: $(hdrdir)/ruby/internal/intern/gc.h
closure.o: $(hdrdir)/ruby/internal/intern/hash.h
closure.o: $(hdrdir)/ruby/internal/intern/io.h
closure.o: $(hdrdir)/ruby/internal/intern/load.h
@@ -195,7 +195,6 @@ closure.o: $(hdrdir)/ruby/internal/memory.h
closure.o: $(hdrdir)/ruby/internal/method.h
closure.o: $(hdrdir)/ruby/internal/module.h
closure.o: $(hdrdir)/ruby/internal/newobj.h
-closure.o: $(hdrdir)/ruby/internal/rgengc.h
closure.o: $(hdrdir)/ruby/internal/scan_args.h
closure.o: $(hdrdir)/ruby/internal/special_consts.h
closure.o: $(hdrdir)/ruby/internal/static_assert.h
@@ -270,6 +269,7 @@ conversions.o: $(hdrdir)/ruby/internal/attr/noexcept.h
conversions.o: $(hdrdir)/ruby/internal/attr/noinline.h
conversions.o: $(hdrdir)/ruby/internal/attr/nonnull.h
conversions.o: $(hdrdir)/ruby/internal/attr/noreturn.h
+conversions.o: $(hdrdir)/ruby/internal/attr/packed_struct.h
conversions.o: $(hdrdir)/ruby/internal/attr/pure.h
conversions.o: $(hdrdir)/ruby/internal/attr/restrict.h
conversions.o: $(hdrdir)/ruby/internal/attr/returns_nonnull.h
@@ -329,7 +329,6 @@ conversions.o: $(hdrdir)/ruby/internal/intern/enumerator.h
conversions.o: $(hdrdir)/ruby/internal/intern/error.h
conversions.o: $(hdrdir)/ruby/internal/intern/eval.h
conversions.o: $(hdrdir)/ruby/internal/intern/file.h
-conversions.o: $(hdrdir)/ruby/internal/intern/gc.h
conversions.o: $(hdrdir)/ruby/internal/intern/hash.h
conversions.o: $(hdrdir)/ruby/internal/intern/io.h
conversions.o: $(hdrdir)/ruby/internal/intern/load.h
@@ -360,7 +359,6 @@ conversions.o: $(hdrdir)/ruby/internal/memory.h
conversions.o: $(hdrdir)/ruby/internal/method.h
conversions.o: $(hdrdir)/ruby/internal/module.h
conversions.o: $(hdrdir)/ruby/internal/newobj.h
-conversions.o: $(hdrdir)/ruby/internal/rgengc.h
conversions.o: $(hdrdir)/ruby/internal/scan_args.h
conversions.o: $(hdrdir)/ruby/internal/special_consts.h
conversions.o: $(hdrdir)/ruby/internal/static_assert.h
@@ -434,6 +432,7 @@ fiddle.o: $(hdrdir)/ruby/internal/attr/noexcept.h
fiddle.o: $(hdrdir)/ruby/internal/attr/noinline.h
fiddle.o: $(hdrdir)/ruby/internal/attr/nonnull.h
fiddle.o: $(hdrdir)/ruby/internal/attr/noreturn.h
+fiddle.o: $(hdrdir)/ruby/internal/attr/packed_struct.h
fiddle.o: $(hdrdir)/ruby/internal/attr/pure.h
fiddle.o: $(hdrdir)/ruby/internal/attr/restrict.h
fiddle.o: $(hdrdir)/ruby/internal/attr/returns_nonnull.h
@@ -493,7 +492,6 @@ fiddle.o: $(hdrdir)/ruby/internal/intern/enumerator.h
fiddle.o: $(hdrdir)/ruby/internal/intern/error.h
fiddle.o: $(hdrdir)/ruby/internal/intern/eval.h
fiddle.o: $(hdrdir)/ruby/internal/intern/file.h
-fiddle.o: $(hdrdir)/ruby/internal/intern/gc.h
fiddle.o: $(hdrdir)/ruby/internal/intern/hash.h
fiddle.o: $(hdrdir)/ruby/internal/intern/io.h
fiddle.o: $(hdrdir)/ruby/internal/intern/load.h
@@ -524,7 +522,6 @@ fiddle.o: $(hdrdir)/ruby/internal/memory.h
fiddle.o: $(hdrdir)/ruby/internal/method.h
fiddle.o: $(hdrdir)/ruby/internal/module.h
fiddle.o: $(hdrdir)/ruby/internal/newobj.h
-fiddle.o: $(hdrdir)/ruby/internal/rgengc.h
fiddle.o: $(hdrdir)/ruby/internal/scan_args.h
fiddle.o: $(hdrdir)/ruby/internal/special_consts.h
fiddle.o: $(hdrdir)/ruby/internal/static_assert.h
@@ -598,6 +595,7 @@ function.o: $(hdrdir)/ruby/internal/attr/noexcept.h
function.o: $(hdrdir)/ruby/internal/attr/noinline.h
function.o: $(hdrdir)/ruby/internal/attr/nonnull.h
function.o: $(hdrdir)/ruby/internal/attr/noreturn.h
+function.o: $(hdrdir)/ruby/internal/attr/packed_struct.h
function.o: $(hdrdir)/ruby/internal/attr/pure.h
function.o: $(hdrdir)/ruby/internal/attr/restrict.h
function.o: $(hdrdir)/ruby/internal/attr/returns_nonnull.h
@@ -657,7 +655,6 @@ function.o: $(hdrdir)/ruby/internal/intern/enumerator.h
function.o: $(hdrdir)/ruby/internal/intern/error.h
function.o: $(hdrdir)/ruby/internal/intern/eval.h
function.o: $(hdrdir)/ruby/internal/intern/file.h
-function.o: $(hdrdir)/ruby/internal/intern/gc.h
function.o: $(hdrdir)/ruby/internal/intern/hash.h
function.o: $(hdrdir)/ruby/internal/intern/io.h
function.o: $(hdrdir)/ruby/internal/intern/load.h
@@ -688,7 +685,6 @@ function.o: $(hdrdir)/ruby/internal/memory.h
function.o: $(hdrdir)/ruby/internal/method.h
function.o: $(hdrdir)/ruby/internal/module.h
function.o: $(hdrdir)/ruby/internal/newobj.h
-function.o: $(hdrdir)/ruby/internal/rgengc.h
function.o: $(hdrdir)/ruby/internal/scan_args.h
function.o: $(hdrdir)/ruby/internal/special_consts.h
function.o: $(hdrdir)/ruby/internal/static_assert.h
@@ -763,6 +759,7 @@ handle.o: $(hdrdir)/ruby/internal/attr/noexcept.h
handle.o: $(hdrdir)/ruby/internal/attr/noinline.h
handle.o: $(hdrdir)/ruby/internal/attr/nonnull.h
handle.o: $(hdrdir)/ruby/internal/attr/noreturn.h
+handle.o: $(hdrdir)/ruby/internal/attr/packed_struct.h
handle.o: $(hdrdir)/ruby/internal/attr/pure.h
handle.o: $(hdrdir)/ruby/internal/attr/restrict.h
handle.o: $(hdrdir)/ruby/internal/attr/returns_nonnull.h
@@ -822,7 +819,6 @@ handle.o: $(hdrdir)/ruby/internal/intern/enumerator.h
handle.o: $(hdrdir)/ruby/internal/intern/error.h
handle.o: $(hdrdir)/ruby/internal/intern/eval.h
handle.o: $(hdrdir)/ruby/internal/intern/file.h
-handle.o: $(hdrdir)/ruby/internal/intern/gc.h
handle.o: $(hdrdir)/ruby/internal/intern/hash.h
handle.o: $(hdrdir)/ruby/internal/intern/io.h
handle.o: $(hdrdir)/ruby/internal/intern/load.h
@@ -853,7 +849,6 @@ handle.o: $(hdrdir)/ruby/internal/memory.h
handle.o: $(hdrdir)/ruby/internal/method.h
handle.o: $(hdrdir)/ruby/internal/module.h
handle.o: $(hdrdir)/ruby/internal/newobj.h
-handle.o: $(hdrdir)/ruby/internal/rgengc.h
handle.o: $(hdrdir)/ruby/internal/scan_args.h
handle.o: $(hdrdir)/ruby/internal/special_consts.h
handle.o: $(hdrdir)/ruby/internal/static_assert.h
@@ -928,6 +923,7 @@ memory_view.o: $(hdrdir)/ruby/internal/attr/noexcept.h
memory_view.o: $(hdrdir)/ruby/internal/attr/noinline.h
memory_view.o: $(hdrdir)/ruby/internal/attr/nonnull.h
memory_view.o: $(hdrdir)/ruby/internal/attr/noreturn.h
+memory_view.o: $(hdrdir)/ruby/internal/attr/packed_struct.h
memory_view.o: $(hdrdir)/ruby/internal/attr/pure.h
memory_view.o: $(hdrdir)/ruby/internal/attr/restrict.h
memory_view.o: $(hdrdir)/ruby/internal/attr/returns_nonnull.h
@@ -996,7 +992,6 @@ memory_view.o: $(hdrdir)/ruby/internal/intern/enumerator.h
memory_view.o: $(hdrdir)/ruby/internal/intern/error.h
memory_view.o: $(hdrdir)/ruby/internal/intern/eval.h
memory_view.o: $(hdrdir)/ruby/internal/intern/file.h
-memory_view.o: $(hdrdir)/ruby/internal/intern/gc.h
memory_view.o: $(hdrdir)/ruby/internal/intern/hash.h
memory_view.o: $(hdrdir)/ruby/internal/intern/io.h
memory_view.o: $(hdrdir)/ruby/internal/intern/load.h
@@ -1027,7 +1022,6 @@ memory_view.o: $(hdrdir)/ruby/internal/memory.h
memory_view.o: $(hdrdir)/ruby/internal/method.h
memory_view.o: $(hdrdir)/ruby/internal/module.h
memory_view.o: $(hdrdir)/ruby/internal/newobj.h
-memory_view.o: $(hdrdir)/ruby/internal/rgengc.h
memory_view.o: $(hdrdir)/ruby/internal/scan_args.h
memory_view.o: $(hdrdir)/ruby/internal/special_consts.h
memory_view.o: $(hdrdir)/ruby/internal/static_assert.h
@@ -1104,6 +1098,7 @@ pinned.o: $(hdrdir)/ruby/internal/attr/noexcept.h
pinned.o: $(hdrdir)/ruby/internal/attr/noinline.h
pinned.o: $(hdrdir)/ruby/internal/attr/nonnull.h
pinned.o: $(hdrdir)/ruby/internal/attr/noreturn.h
+pinned.o: $(hdrdir)/ruby/internal/attr/packed_struct.h
pinned.o: $(hdrdir)/ruby/internal/attr/pure.h
pinned.o: $(hdrdir)/ruby/internal/attr/restrict.h
pinned.o: $(hdrdir)/ruby/internal/attr/returns_nonnull.h
@@ -1163,7 +1158,6 @@ pinned.o: $(hdrdir)/ruby/internal/intern/enumerator.h
pinned.o: $(hdrdir)/ruby/internal/intern/error.h
pinned.o: $(hdrdir)/ruby/internal/intern/eval.h
pinned.o: $(hdrdir)/ruby/internal/intern/file.h
-pinned.o: $(hdrdir)/ruby/internal/intern/gc.h
pinned.o: $(hdrdir)/ruby/internal/intern/hash.h
pinned.o: $(hdrdir)/ruby/internal/intern/io.h
pinned.o: $(hdrdir)/ruby/internal/intern/load.h
@@ -1194,7 +1188,6 @@ pinned.o: $(hdrdir)/ruby/internal/memory.h
pinned.o: $(hdrdir)/ruby/internal/method.h
pinned.o: $(hdrdir)/ruby/internal/module.h
pinned.o: $(hdrdir)/ruby/internal/newobj.h
-pinned.o: $(hdrdir)/ruby/internal/rgengc.h
pinned.o: $(hdrdir)/ruby/internal/scan_args.h
pinned.o: $(hdrdir)/ruby/internal/special_consts.h
pinned.o: $(hdrdir)/ruby/internal/static_assert.h
@@ -1269,6 +1262,7 @@ pointer.o: $(hdrdir)/ruby/internal/attr/noexcept.h
pointer.o: $(hdrdir)/ruby/internal/attr/noinline.h
pointer.o: $(hdrdir)/ruby/internal/attr/nonnull.h
pointer.o: $(hdrdir)/ruby/internal/attr/noreturn.h
+pointer.o: $(hdrdir)/ruby/internal/attr/packed_struct.h
pointer.o: $(hdrdir)/ruby/internal/attr/pure.h
pointer.o: $(hdrdir)/ruby/internal/attr/restrict.h
pointer.o: $(hdrdir)/ruby/internal/attr/returns_nonnull.h
@@ -1337,7 +1331,6 @@ pointer.o: $(hdrdir)/ruby/internal/intern/enumerator.h
pointer.o: $(hdrdir)/ruby/internal/intern/error.h
pointer.o: $(hdrdir)/ruby/internal/intern/eval.h
pointer.o: $(hdrdir)/ruby/internal/intern/file.h
-pointer.o: $(hdrdir)/ruby/internal/intern/gc.h
pointer.o: $(hdrdir)/ruby/internal/intern/hash.h
pointer.o: $(hdrdir)/ruby/internal/intern/io.h
pointer.o: $(hdrdir)/ruby/internal/intern/load.h
@@ -1368,7 +1361,6 @@ pointer.o: $(hdrdir)/ruby/internal/memory.h
pointer.o: $(hdrdir)/ruby/internal/method.h
pointer.o: $(hdrdir)/ruby/internal/module.h
pointer.o: $(hdrdir)/ruby/internal/newobj.h
-pointer.o: $(hdrdir)/ruby/internal/rgengc.h
pointer.o: $(hdrdir)/ruby/internal/scan_args.h
pointer.o: $(hdrdir)/ruby/internal/special_consts.h
pointer.o: $(hdrdir)/ruby/internal/static_assert.h
diff --git a/ext/fiddle/extconf.rb b/ext/fiddle/extconf.rb
index cf8b5223bb..2d85b3eea5 100644
--- a/ext/fiddle/extconf.rb
+++ b/ext/fiddle/extconf.rb
@@ -63,6 +63,11 @@ unless bundle
end
if have_ffi_header && (have_library('ffi') || have_library('libffi'))
have_libffi = true
+ checking_for("undefined FFI_GO_CLOSURES is used") do
+ if egrep_cpp(/warning: 'FFI_GO_CLOSURES' is not defined/, cpp_include(ffi_header), "2>&1")
+ $defs.push('-DFFI_GO_CLOSURES=0')
+ end
+ end
end
end
diff --git a/ext/fiddle/fiddle.c b/ext/fiddle/fiddle.c
index 9ab1283ba3..f420d9fa3b 100644
--- a/ext/fiddle/fiddle.c
+++ b/ext/fiddle/fiddle.c
@@ -1,3 +1,5 @@
+#include <stdbool.h>
+
#include <fiddle.h>
VALUE mFiddle;
@@ -357,6 +359,12 @@ Init_fiddle(void)
*/
rb_define_const(mFiddleTypes, "UINTPTR_T", INT2NUM(TYPE_UINTPTR_T));
+ /* Document-const: Fiddle::Types::BOOL
+ *
+ * C type - bool
+ */
+ rb_define_const(mFiddleTypes, "BOOL" , INT2NUM(TYPE_BOOL));
+
/* Document-const: ALIGN_VOIDP
*
* The alignment size of a void*
@@ -461,6 +469,12 @@ Init_fiddle(void)
*/
rb_define_const(mFiddle, "ALIGN_UINTPTR_T", INT2NUM(ALIGN_OF(uintptr_t)));
+ /* Document-const: ALIGN_BOOL
+ *
+ * The alignment size of a bool
+ */
+ rb_define_const(mFiddle, "ALIGN_BOOL", INT2NUM(ALIGN_OF(bool)));
+
/* Document-const: WINDOWS
*
* Returns a boolean regarding whether the host is WIN32
@@ -635,6 +649,12 @@ Init_fiddle(void)
*/
rb_define_const(mFiddle, "SIZEOF_CONST_STRING", INT2NUM(sizeof(const char*)));
+ /* Document-const: SIZEOF_BOOL
+ *
+ * size of a bool
+ */
+ rb_define_const(mFiddle, "SIZEOF_BOOL", INT2NUM(sizeof(bool)));
+
/* Document-const: RUBY_FREE
*
* Address of the ruby_xfree() function
diff --git a/ext/fiddle/fiddle.h b/ext/fiddle/fiddle.h
index 684b943d30..348baa9ab9 100644
--- a/ext/fiddle/fiddle.h
+++ b/ext/fiddle/fiddle.h
@@ -118,7 +118,7 @@
#define TYPE_UINT -TYPE_INT
#define TYPE_LONG 5
#define TYPE_ULONG -TYPE_LONG
-#if HAVE_LONG_LONG
+#ifdef HAVE_LONG_LONG
#define TYPE_LONG_LONG 6
#define TYPE_ULONG_LONG -TYPE_LONG_LONG
#endif
@@ -126,6 +126,7 @@
#define TYPE_DOUBLE 8
#define TYPE_VARIADIC 9
#define TYPE_CONST_STRING 10
+#define TYPE_BOOL 11
#define TYPE_INT8_T TYPE_CHAR
#define TYPE_UINT8_T -TYPE_INT8_T
@@ -199,7 +200,10 @@
/* GCC releases before GCC 4.9 had a bug in _Alignof. See GCC bug 52023
<https://gcc.gnu.org/bugzilla/show_bug.cgi?id=52023>.
clang versions < 8.0.0 have the same bug. */
-#if (!defined(__STDC_VERSION__) || __STDC_VERSION__ < 201112 \
+#if defined(HAVE__ALIGNOF)
+# /* Autoconf detected availability of a sane `_Alignof()`. */
+# define ALIGN_OF(type) RB_GNUC_EXTENSION(_Alignof(type))
+#elif (!defined(__STDC_VERSION__) || __STDC_VERSION__ < 201112 \
|| (defined(__GNUC__) && __GNUC__ < 4 + (__GNUC_MINOR__ < 9) \
&& !defined(__clang__)) \
|| (defined(__clang__) && __clang_major__ < 8))
diff --git a/ext/fiddle/function.c b/ext/fiddle/function.c
index 274d181d17..5469e09e37 100644
--- a/ext/fiddle/function.c
+++ b/ext/fiddle/function.c
@@ -53,8 +53,13 @@ function_memsize(const void *p)
}
const rb_data_type_t function_data_type = {
- "fiddle/function",
- {0, deallocate, function_memsize,},
+ .wrap_struct_name = "fiddle/function",
+ .function = {
+ .dmark = 0,
+ .dfree = deallocate,
+ .dsize = function_memsize
+ },
+ .flags = RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_WB_PROTECTED,
};
static VALUE
diff --git a/ext/fiddle/handle.c b/ext/fiddle/handle.c
index ae8cc3a581..8ba416952a 100644
--- a/ext/fiddle/handle.c
+++ b/ext/fiddle/handle.c
@@ -50,8 +50,13 @@ fiddle_handle_memsize(const void *ptr)
}
static const rb_data_type_t fiddle_handle_data_type = {
- "fiddle/handle",
- {0, fiddle_handle_free, fiddle_handle_memsize,},
+ .wrap_struct_name = "fiddle/handle",
+ .function = {
+ .dmark = 0,
+ .dfree = fiddle_handle_free,
+ .dsize = fiddle_handle_memsize
+ },
+ .flags = RUBY_TYPED_WB_PROTECTED,
};
/*
diff --git a/ext/fiddle/lib/fiddle/cparser.rb b/ext/fiddle/lib/fiddle/cparser.rb
index 9a70402953..264ca166dd 100644
--- a/ext/fiddle/lib/fiddle/cparser.rb
+++ b/ext/fiddle/lib/fiddle/cparser.rb
@@ -165,18 +165,30 @@ module Fiddle
raise(RuntimeError, "unsupported type: #{ty}")
end
return TYPE_ULONG_LONG
- when /\A(?:signed\s+)?long(?:\s+int\s+)?(?:\s+\w+)?\z/
- return TYPE_LONG
- when /\Aunsigned\s+long(?:\s+int\s+)?(?:\s+\w+)?\z/
+ when /\Aunsigned\s+long(?:\s+int\s+)?(?:\s+\w+)?\z/,
+ /\Aunsigned\s+int\s+long(?:\s+\w+)?\z/,
+ /\Along(?:\s+int)?\s+unsigned(?:\s+\w+)?\z/,
+ /\Aint\s+unsigned\s+long(?:\s+\w+)?\z/,
+ /\A(?:int\s+)?long\s+unsigned(?:\s+\w+)?\z/
return TYPE_ULONG
+ when /\A(?:signed\s+)?long(?:\s+int\s+)?(?:\s+\w+)?\z/,
+ /\A(?:signed\s+)?int\s+long(?:\s+\w+)?\z/,
+ /\Along(?:\s+int)?\s+signed(?:\s+\w+)?\z/
+ return TYPE_LONG
+ when /\Aunsigned\s+short(?:\s+int\s+)?(?:\s+\w+)?\z/,
+ /\Aunsigned\s+int\s+short(?:\s+\w+)?\z/,
+ /\Ashort(?:\s+int)?\s+unsigned(?:\s+\w+)?\z/,
+ /\Aint\s+unsigned\s+short(?:\s+\w+)?\z/,
+ /\A(?:int\s+)?short\s+unsigned(?:\s+\w+)?\z/
+ return TYPE_USHORT
+ when /\A(?:signed\s+)?short(?:\s+int\s+)?(?:\s+\w+)?\z/,
+ /\A(?:signed\s+)?int\s+short(?:\s+\w+)?\z/,
+ /\Aint\s+(?:signed\s+)?short(?:\s+\w+)?\z/
+ return TYPE_SHORT
when /\A(?:signed\s+)?int(?:\s+\w+)?\z/
return TYPE_INT
when /\A(?:unsigned\s+int|uint)(?:\s+\w+)?\z/
return TYPE_UINT
- when /\A(?:signed\s+)?short(?:\s+int\s+)?(?:\s+\w+)?\z/
- return TYPE_SHORT
- when /\Aunsigned\s+short(?:\s+int\s+)?(?:\s+\w+)?\z/
- return TYPE_USHORT
when /\A(?:signed\s+)?char(?:\s+\w+)?\z/
return TYPE_CHAR
when /\Aunsigned\s+char(?:\s+\w+)?\z/
@@ -235,6 +247,8 @@ module Fiddle
return TYPE_INTPTR_T
when /\Auintptr_t(?:\s+\w+)?\z/
return TYPE_UINTPTR_T
+ when "bool"
+ return TYPE_BOOL
when /\*/, /\[[\s\d]*\]/
return TYPE_VOIDP
when "..."
diff --git a/ext/fiddle/lib/fiddle/import.rb b/ext/fiddle/lib/fiddle/import.rb
index 09ffcef544..050708fb96 100644
--- a/ext/fiddle/lib/fiddle/import.rb
+++ b/ext/fiddle/lib/fiddle/import.rb
@@ -119,6 +119,8 @@ module Fiddle
return SIZEOF_VOIDP
when TYPE_CONST_STRING
return SIZEOF_CONST_STRING
+ when TYPE_BOOL
+ return SIZEOF_BOOL
else
if defined?(TYPE_LONG_LONG) and
ty == TYPE_LONG_LONG
diff --git a/ext/fiddle/lib/fiddle/pack.rb b/ext/fiddle/lib/fiddle/pack.rb
index 545b985d50..81088f402b 100644
--- a/ext/fiddle/lib/fiddle/pack.rb
+++ b/ext/fiddle/lib/fiddle/pack.rb
@@ -15,6 +15,7 @@ module Fiddle
TYPE_USHORT => ALIGN_SHORT,
TYPE_UINT => ALIGN_INT,
TYPE_ULONG => ALIGN_LONG,
+ TYPE_BOOL => ALIGN_BOOL,
}
PACK_MAP = {
@@ -30,6 +31,16 @@ module Fiddle
TYPE_UINT => "I!",
TYPE_ULONG => "L!",
}
+ case SIZEOF_BOOL
+ when SIZEOF_CHAR
+ PACK_MAP[TYPE_BOOL] = PACK_MAP[TYPE_UCHAR]
+ when SIZEOF_SHORT
+ PACK_MAP[TYPE_BOOL] = PACK_MAP[TYPE_USHORT]
+ when SIZEOF_INT
+ PACK_MAP[TYPE_BOOL] = PACK_MAP[TYPE_UINT]
+ when SIZEOF_LONG
+ PACK_MAP[TYPE_BOOL] = PACK_MAP[TYPE_ULONG]
+ end
SIZE_MAP = {
TYPE_VOIDP => SIZEOF_VOIDP,
@@ -43,6 +54,7 @@ module Fiddle
TYPE_USHORT => SIZEOF_SHORT,
TYPE_UINT => SIZEOF_INT,
TYPE_ULONG => SIZEOF_LONG,
+ TYPE_BOOL => SIZEOF_BOOL,
}
if defined?(TYPE_LONG_LONG)
ALIGN_MAP[TYPE_LONG_LONG] = ALIGN_MAP[TYPE_ULONG_LONG] = ALIGN_LONG_LONG
diff --git a/ext/fiddle/pointer.c b/ext/fiddle/pointer.c
index 15107e3862..1b7d7a69f6 100644
--- a/ext/fiddle/pointer.c
+++ b/ext/fiddle/pointer.c
@@ -88,8 +88,13 @@ fiddle_ptr_memsize(const void *ptr)
}
static const rb_data_type_t fiddle_ptr_data_type = {
- "fiddle/pointer",
- {fiddle_ptr_mark, fiddle_ptr_free, fiddle_ptr_memsize,},
+ .wrap_struct_name = "fiddle/pointer",
+ .function = {
+ .dmark = fiddle_ptr_mark,
+ .dfree = fiddle_ptr_free,
+ .dsize = fiddle_ptr_memsize,
+ },
+ .flags = RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_WB_PROTECTED
};
#ifdef HAVE_RUBY_MEMORY_VIEW_H
@@ -135,8 +140,8 @@ rb_fiddle_ptr_new2(VALUE klass, void *ptr, long size, freefunc_t func, VALUE wra
data->free = func;
data->freed = false;
data->size = size;
- data->wrap[0] = wrap0;
- data->wrap[1] = wrap1;
+ RB_OBJ_WRITE(val, &data->wrap[0], wrap0);
+ RB_OBJ_WRITE(val, &data->wrap[1], wrap1);
return val;
}
@@ -235,8 +240,8 @@ rb_fiddle_ptr_initialize(int argc, VALUE argv[], VALUE self)
/* Free previous memory. Use of inappropriate initialize may cause SEGV. */
(*(data->free))(data->ptr);
}
- data->wrap[0] = wrap;
- data->wrap[1] = funcwrap;
+ RB_OBJ_WRITE(self, &data->wrap[0], wrap);
+ RB_OBJ_WRITE(self, &data->wrap[1], funcwrap);
data->ptr = p;
data->size = s;
data->free = f;
@@ -314,7 +319,7 @@ rb_fiddle_ptr_s_malloc(int argc, VALUE argv[], VALUE klass)
}
obj = rb_fiddle_ptr_malloc(klass, s,f);
- if (wrap) RPTR_DATA(obj)->wrap[1] = wrap;
+ if (wrap) RB_OBJ_WRITE(obj, &RPTR_DATA(obj)->wrap[1], wrap);
if (rb_block_given_p()) {
if (!f) {
@@ -795,10 +800,37 @@ rb_fiddle_ptr_s_to_ptr(VALUE self, VALUE val)
if (num == val) wrap = 0;
ptr = rb_fiddle_ptr_new(NUM2PTR(num), 0, NULL);
}
- if (wrap) RPTR_DATA(ptr)->wrap[0] = wrap;
+ if (wrap) RB_OBJ_WRITE(ptr, &RPTR_DATA(ptr)->wrap[0], wrap);
return ptr;
}
+/*
+ * call-seq:
+ * Fiddle::Pointer.read(address, len) => string
+ *
+ * Or read the memory at address +address+ with length +len+ and return a
+ * string with that memory
+ */
+
+static VALUE
+rb_fiddle_ptr_read_mem(VALUE klass, VALUE address, VALUE len)
+{
+ return rb_str_new((char *)NUM2PTR(address), NUM2ULONG(len));
+}
+
+/*
+ * call-seq:
+ * Fiddle::Pointer.write(address, str)
+ *
+ * Write bytes in +str+ to the location pointed to by +address+.
+ */
+static VALUE
+rb_fiddle_ptr_write_mem(VALUE klass, VALUE addr, VALUE str)
+{
+ memcpy(NUM2PTR(addr), StringValuePtr(str), RSTRING_LEN(str));
+ return str;
+}
+
void
Init_fiddle_pointer(void)
{
@@ -815,6 +847,8 @@ Init_fiddle_pointer(void)
rb_define_singleton_method(rb_cPointer, "malloc", rb_fiddle_ptr_s_malloc, -1);
rb_define_singleton_method(rb_cPointer, "to_ptr", rb_fiddle_ptr_s_to_ptr, 1);
rb_define_singleton_method(rb_cPointer, "[]", rb_fiddle_ptr_s_to_ptr, 1);
+ rb_define_singleton_method(rb_cPointer, "read", rb_fiddle_ptr_read_mem, 2);
+ rb_define_singleton_method(rb_cPointer, "write", rb_fiddle_ptr_write_mem, 2);
rb_define_method(rb_cPointer, "initialize", rb_fiddle_ptr_initialize, -1);
rb_define_method(rb_cPointer, "free=", rb_fiddle_ptr_free_set, 1);
rb_define_method(rb_cPointer, "free", rb_fiddle_ptr_free_get, 0);
diff --git a/ext/fiddle/win32/libffi-config.rb b/ext/fiddle/win32/libffi-config.rb
index 985fc29d36..8e8069a943 100755
--- a/ext/fiddle/win32/libffi-config.rb
+++ b/ext/fiddle/win32/libffi-config.rb
@@ -23,7 +23,7 @@ until ARGV.empty?
end
end
-IO.foreach("#{srcdir}/configure.ac") do |line|
+File.foreach("#{srcdir}/configure.ac") do |line|
if /^AC_INIT\((.*)\)/ =~ line
version = $1.split(/,\s*/)[1]
version.gsub!(/\A\[|\]\z/, '')
@@ -38,11 +38,11 @@ conf['TARGET'] = /^x64/ =~ host ? "X86_WIN64" : "X86_WIN32"
FileUtils.mkdir_p([builddir, "#{builddir}/include", "#{builddir}/src/x86"])
FileUtils.cp("#{basedir}/fficonfig.h", ".", preserve: true)
-hdr = IO.binread("#{srcdir}/include/ffi.h.in")
+hdr = File.binread("#{srcdir}/include/ffi.h.in")
hdr.gsub!(/@(\w+)@/) {conf[$1] || $&}
hdr.gsub!(/^(#if\s+)@\w+@/, '\10')
-IO.binwrite("#{builddir}/include/ffi.h", hdr)
+File.binwrite("#{builddir}/include/ffi.h", hdr)
-mk = IO.binread("#{basedir}/libffi.mk.tmpl")
+mk = File.binread("#{basedir}/libffi.mk.tmpl")
mk.gsub!(/@(\w+)@/) {conf[$1] || $&}
-IO.binwrite("Makefile", mk)
+File.binwrite("Makefile", mk)
diff --git a/ext/io/console/.document b/ext/io/console/.document
new file mode 100644
index 0000000000..945a377256
--- /dev/null
+++ b/ext/io/console/.document
@@ -0,0 +1,2 @@
+console.c
+lib/size.rb
diff --git a/ext/io/console/console.c b/ext/io/console/console.c
index 21454a73fa..78eb11a209 100644
--- a/ext/io/console/console.c
+++ b/ext/io/console/console.c
@@ -76,9 +76,7 @@ getattr(int fd, conmode *t)
#endif
static ID id_getc, id_console, id_close;
-#if ENABLE_IO_GETPASS
-static ID id_gets, id_chomp_bang;
-#endif
+static ID id_gets, id_flush, id_chomp_bang;
#if defined HAVE_RUBY_FIBER_SCHEDULER_H
# include "ruby/fiber/scheduler.h"
@@ -87,7 +85,41 @@ extern VALUE rb_scheduler_timeout(struct timeval *timeout);
# define rb_fiber_scheduler_make_timeout rb_scheduler_timeout
#endif
-#define sys_fail_fptr(fptr) rb_sys_fail_str((fptr)->pathv)
+#ifndef HAVE_RB_IO_DESCRIPTOR
+static int
+io_descriptor_fallback(VALUE io)
+{
+ rb_io_t *fptr;
+ GetOpenFile(io, fptr);
+ return fptr->fd;
+}
+#define rb_io_descriptor io_descriptor_fallback
+#endif
+
+#ifndef HAVE_RB_IO_PATH
+static VALUE
+io_path_fallback(VALUE io)
+{
+ rb_io_t *fptr;
+ GetOpenFile(io, fptr);
+ return fptr->pathv;
+}
+#define rb_io_path io_path_fallback
+#endif
+
+#ifndef HAVE_RB_IO_GET_WRITE_IO
+static VALUE
+io_get_write_io_fallback(VALUE io)
+{
+ rb_io_t *fptr;
+ GetOpenFile(io, fptr);
+ VALUE wio = fptr->tied_io_for_writing;
+ return wio ? wio : io;
+}
+#define rb_io_get_write_io io_get_write_io_fallback
+#endif
+
+#define sys_fail(io) rb_sys_fail_str(rb_io_path(io))
#ifndef HAVE_RB_F_SEND
#ifndef RB_PASS_CALLED_KEYWORDS
@@ -293,33 +325,21 @@ set_ttymode(int fd, conmode *t, void (*setter)(conmode *, void *), void *arg)
return setattr(fd, &r);
}
-#define GetReadFD(fptr) ((fptr)->fd)
-
-static inline int
-get_write_fd(const rb_io_t *fptr)
-{
- VALUE wio = fptr->tied_io_for_writing;
- rb_io_t *ofptr;
- if (!wio) return fptr->fd;
- GetOpenFile(wio, ofptr);
- return ofptr->fd;
-}
-#define GetWriteFD(fptr) get_write_fd(fptr)
+#define GetReadFD(io) rb_io_descriptor(io)
+#define GetWriteFD(io) rb_io_descriptor(rb_io_get_write_io(io))
#define FD_PER_IO 2
static VALUE
ttymode(VALUE io, VALUE (*func)(VALUE), VALUE farg, void (*setter)(conmode *, void *), void *arg)
{
- rb_io_t *fptr;
int status = -1;
int error = 0;
int fd[FD_PER_IO];
conmode t[FD_PER_IO];
VALUE result = Qnil;
- GetOpenFile(io, fptr);
- fd[0] = GetReadFD(fptr);
+ fd[0] = GetReadFD(io);
if (fd[0] != -1) {
if (set_ttymode(fd[0], t+0, setter, arg)) {
status = 0;
@@ -329,7 +349,7 @@ ttymode(VALUE io, VALUE (*func)(VALUE), VALUE farg, void (*setter)(conmode *, vo
fd[0] = -1;
}
}
- fd[1] = GetWriteFD(fptr);
+ fd[1] = GetWriteFD(io);
if (fd[1] != -1 && fd[1] != fd[0]) {
if (set_ttymode(fd[1], t+1, setter, arg)) {
status = 0;
@@ -342,14 +362,13 @@ ttymode(VALUE io, VALUE (*func)(VALUE), VALUE farg, void (*setter)(conmode *, vo
if (status == 0) {
result = rb_protect(func, farg, &status);
}
- GetOpenFile(io, fptr);
- if (fd[0] != -1 && fd[0] == GetReadFD(fptr)) {
+ if (fd[0] != -1 && fd[0] == GetReadFD(io)) {
if (!setattr(fd[0], t+0)) {
error = errno;
status = -1;
}
}
- if (fd[1] != -1 && fd[1] != fd[0] && fd[1] == GetWriteFD(fptr)) {
+ if (fd[1] != -1 && fd[1] != fd[0] && fd[1] == GetWriteFD(io)) {
if (!setattr(fd[1], t+1)) {
error = errno;
status = -1;
@@ -435,15 +454,11 @@ static VALUE
console_set_raw(int argc, VALUE *argv, VALUE io)
{
conmode t;
- rb_io_t *fptr;
- int fd;
rawmode_arg_t opts, *optp = rawmode_opt(&argc, argv, 0, 0, &opts);
-
- GetOpenFile(io, fptr);
- fd = GetReadFD(fptr);
- if (!getattr(fd, &t)) sys_fail_fptr(fptr);
+ int fd = GetReadFD(io);
+ if (!getattr(fd, &t)) sys_fail(io);
set_rawmode(&t, optp);
- if (!setattr(fd, &t)) sys_fail_fptr(fptr);
+ if (!setattr(fd, &t)) sys_fail(io);
return io;
}
@@ -479,14 +494,10 @@ static VALUE
console_set_cooked(VALUE io)
{
conmode t;
- rb_io_t *fptr;
- int fd;
-
- GetOpenFile(io, fptr);
- fd = GetReadFD(fptr);
- if (!getattr(fd, &t)) sys_fail_fptr(fptr);
+ int fd = GetReadFD(io);
+ if (!getattr(fd, &t)) sys_fail(io);
set_cookedmode(&t, NULL);
- if (!setattr(fd, &t)) sys_fail_fptr(fptr);
+ if (!setattr(fd, &t)) sys_fail(io);
return io;
}
@@ -638,17 +649,17 @@ static VALUE
console_set_echo(VALUE io, VALUE f)
{
conmode t;
- rb_io_t *fptr;
- int fd;
+ int fd = GetReadFD(io);
+
+ if (!getattr(fd, &t)) sys_fail(io);
- GetOpenFile(io, fptr);
- fd = GetReadFD(fptr);
- if (!getattr(fd, &t)) sys_fail_fptr(fptr);
if (RTEST(f))
- set_echo(&t, NULL);
+ set_echo(&t, NULL);
else
- set_noecho(&t, NULL);
- if (!setattr(fd, &t)) sys_fail_fptr(fptr);
+ set_noecho(&t, NULL);
+
+ if (!setattr(fd, &t)) sys_fail(io);
+
return io;
}
@@ -664,12 +675,9 @@ static VALUE
console_echo_p(VALUE io)
{
conmode t;
- rb_io_t *fptr;
- int fd;
+ int fd = GetReadFD(io);
- GetOpenFile(io, fptr);
- fd = GetReadFD(fptr);
- if (!getattr(fd, &t)) sys_fail_fptr(fptr);
+ if (!getattr(fd, &t)) sys_fail(io);
return echo_p(&t) ? Qtrue : Qfalse;
}
@@ -748,12 +756,9 @@ static VALUE
console_conmode_get(VALUE io)
{
conmode t;
- rb_io_t *fptr;
- int fd;
+ int fd = GetReadFD(io);
- GetOpenFile(io, fptr);
- fd = GetReadFD(fptr);
- if (!getattr(fd, &t)) sys_fail_fptr(fptr);
+ if (!getattr(fd, &t)) sys_fail(io);
return conmode_new(cConmode, &t);
}
@@ -770,14 +775,12 @@ static VALUE
console_conmode_set(VALUE io, VALUE mode)
{
conmode *t, r;
- rb_io_t *fptr;
- int fd;
+ int fd = GetReadFD(io);
TypedData_Get_Struct(mode, conmode, &conmode_type, t);
r = *t;
- GetOpenFile(io, fptr);
- fd = GetReadFD(fptr);
- if (!setattr(fd, &r)) sys_fail_fptr(fptr);
+
+ if (!setattr(fd, &r)) sys_fail(io);
return mode;
}
@@ -813,13 +816,9 @@ typedef CONSOLE_SCREEN_BUFFER_INFO rb_console_size_t;
static VALUE
console_winsize(VALUE io)
{
- rb_io_t *fptr;
- int fd;
rb_console_size_t ws;
-
- GetOpenFile(io, fptr);
- fd = GetWriteFD(fptr);
- if (!getwinsize(fd, &ws)) sys_fail_fptr(fptr);
+ int fd = GetWriteFD(io);
+ if (!getwinsize(fd, &ws)) sys_fail(io);
return rb_assoc_new(INT2NUM(winsize_row(&ws)), INT2NUM(winsize_col(&ws)));
}
@@ -835,7 +834,6 @@ console_winsize(VALUE io)
static VALUE
console_set_winsize(VALUE io, VALUE size)
{
- rb_io_t *fptr;
rb_console_size_t ws;
#if defined _WIN32
HANDLE wh;
@@ -844,20 +842,17 @@ console_set_winsize(VALUE io, VALUE size)
#endif
VALUE row, col, xpixel, ypixel;
const VALUE *sz;
- int fd;
long sizelen;
+ int fd;
- GetOpenFile(io, fptr);
size = rb_Array(size);
if ((sizelen = RARRAY_LEN(size)) != 2 && sizelen != 4) {
- rb_raise(rb_eArgError,
- "wrong number of arguments (given %ld, expected 2 or 4)",
- sizelen);
+ rb_raise(rb_eArgError, "wrong number of arguments (given %ld, expected 2 or 4)", sizelen);
}
sz = RARRAY_CONST_PTR(size);
row = sz[0], col = sz[1], xpixel = ypixel = Qnil;
if (sizelen == 4) xpixel = sz[2], ypixel = sz[3];
- fd = GetWriteFD(fptr);
+ fd = GetWriteFD(io);
#if defined TIOCSWINSZ
ws.ws_row = ws.ws_col = ws.ws_xpixel = ws.ws_ypixel = 0;
#define SET(m) ws.ws_##m = NIL_P(m) ? 0 : (unsigned short)NUM2UINT(m)
@@ -866,7 +861,7 @@ console_set_winsize(VALUE io, VALUE size)
SET(xpixel);
SET(ypixel);
#undef SET
- if (!setwinsize(fd, &ws)) sys_fail_fptr(fptr);
+ if (!setwinsize(fd, &ws)) sys_fail(io);
#elif defined _WIN32
wh = (HANDLE)rb_w32_get_osfhandle(fd);
#define SET(m) new##m = NIL_P(m) ? 0 : (unsigned short)NUM2UINT(m)
@@ -904,12 +899,10 @@ console_set_winsize(VALUE io, VALUE size)
static VALUE
console_check_winsize_changed(VALUE io)
{
- rb_io_t *fptr;
HANDLE h;
DWORD num;
- GetOpenFile(io, fptr);
- h = (HANDLE)rb_w32_get_osfhandle(GetReadFD(fptr));
+ h = (HANDLE)rb_w32_get_osfhandle(GetReadFD(io));
while (GetNumberOfConsoleInputEvents(h, &num) && num > 0) {
INPUT_RECORD rec;
if (ReadConsoleInput(h, &rec, 1, &num)) {
@@ -935,15 +928,11 @@ console_check_winsize_changed(VALUE io)
static VALUE
console_iflush(VALUE io)
{
- rb_io_t *fptr;
- int fd;
-
- GetOpenFile(io, fptr);
- fd = GetReadFD(fptr);
#if defined HAVE_TERMIOS_H || defined HAVE_TERMIO_H
- if (tcflush(fd, TCIFLUSH)) sys_fail_fptr(fptr);
+ int fd = GetReadFD(io);
+ if (tcflush(fd, TCIFLUSH)) sys_fail(io);
#endif
- (void)fd;
+
return io;
}
@@ -958,13 +947,9 @@ console_iflush(VALUE io)
static VALUE
console_oflush(VALUE io)
{
- rb_io_t *fptr;
- int fd;
-
- GetOpenFile(io, fptr);
- fd = GetWriteFD(fptr);
+ int fd = GetWriteFD(io);
#if defined HAVE_TERMIOS_H || defined HAVE_TERMIO_H
- if (tcflush(fd, TCOFLUSH)) sys_fail_fptr(fptr);
+ if (tcflush(fd, TCOFLUSH)) sys_fail(io);
#endif
(void)fd;
return io;
@@ -981,40 +966,30 @@ console_oflush(VALUE io)
static VALUE
console_ioflush(VALUE io)
{
- rb_io_t *fptr;
#if defined HAVE_TERMIOS_H || defined HAVE_TERMIO_H
- int fd1, fd2;
-#endif
+ int fd1 = GetReadFD(io);
+ int fd2 = GetWriteFD(io);
- GetOpenFile(io, fptr);
-#if defined HAVE_TERMIOS_H || defined HAVE_TERMIO_H
- fd1 = GetReadFD(fptr);
- fd2 = GetWriteFD(fptr);
if (fd2 != -1 && fd1 != fd2) {
- if (tcflush(fd1, TCIFLUSH)) sys_fail_fptr(fptr);
- if (tcflush(fd2, TCOFLUSH)) sys_fail_fptr(fptr);
+ if (tcflush(fd1, TCIFLUSH)) sys_fail(io);
+ if (tcflush(fd2, TCOFLUSH)) sys_fail(io);
}
else {
- if (tcflush(fd1, TCIOFLUSH)) sys_fail_fptr(fptr);
+ if (tcflush(fd1, TCIOFLUSH)) sys_fail(io);
}
#endif
+
return io;
}
static VALUE
console_beep(VALUE io)
{
- rb_io_t *fptr;
- int fd;
-
- GetOpenFile(io, fptr);
- fd = GetWriteFD(fptr);
#ifdef _WIN32
- (void)fd;
MessageBeep(0);
#else
- if (write(fd, "\a", 1) < 0)
- sys_fail_fptr(fptr);
+ int fd = GetWriteFD(io);
+ if (write(fd, "\a", 1) < 0) sys_fail(io);
#endif
return io;
}
@@ -1035,79 +1010,6 @@ mode_in_range(VALUE val, int high, const char *modename)
}
#if defined _WIN32
-static VALUE
-console_goto(VALUE io, VALUE y, VALUE x)
-{
- rb_io_t *fptr;
- int fd;
- COORD pos;
-
- GetOpenFile(io, fptr);
- fd = GetWriteFD(fptr);
- pos.X = NUM2UINT(x);
- pos.Y = NUM2UINT(y);
- if (!SetConsoleCursorPosition((HANDLE)rb_w32_get_osfhandle(fd), pos)) {
- rb_syserr_fail(LAST_ERROR, 0);
- }
- return io;
-}
-
-static VALUE
-console_cursor_pos(VALUE io)
-{
- rb_io_t *fptr;
- int fd;
- rb_console_size_t ws;
-
- GetOpenFile(io, fptr);
- fd = GetWriteFD(fptr);
- if (!GetConsoleScreenBufferInfo((HANDLE)rb_w32_get_osfhandle(fd), &ws)) {
- rb_syserr_fail(LAST_ERROR, 0);
- }
- return rb_assoc_new(UINT2NUM(ws.dwCursorPosition.Y), UINT2NUM(ws.dwCursorPosition.X));
-}
-
-static VALUE
-console_move(VALUE io, int y, int x)
-{
- rb_io_t *fptr;
- HANDLE h;
- rb_console_size_t ws;
- COORD *pos = &ws.dwCursorPosition;
-
- GetOpenFile(io, fptr);
- h = (HANDLE)rb_w32_get_osfhandle(GetWriteFD(fptr));
- if (!GetConsoleScreenBufferInfo(h, &ws)) {
- rb_syserr_fail(LAST_ERROR, 0);
- }
- pos->X += x;
- pos->Y += y;
- if (!SetConsoleCursorPosition(h, *pos)) {
- rb_syserr_fail(LAST_ERROR, 0);
- }
- return io;
-}
-
-static VALUE
-console_goto_column(VALUE io, VALUE val)
-{
- rb_io_t *fptr;
- HANDLE h;
- rb_console_size_t ws;
- COORD *pos = &ws.dwCursorPosition;
-
- GetOpenFile(io, fptr);
- h = (HANDLE)rb_w32_get_osfhandle(GetWriteFD(fptr));
- if (!GetConsoleScreenBufferInfo(h, &ws)) {
- rb_syserr_fail(LAST_ERROR, 0);
- }
- pos->X = NUM2INT(val);
- if (!SetConsoleCursorPosition(h, *pos)) {
- rb_syserr_fail(LAST_ERROR, 0);
- }
- return io;
-}
-
static void
constat_clear(HANDLE handle, WORD attr, DWORD len, COORD pos)
{
@@ -1118,86 +1020,12 @@ constat_clear(HANDLE handle, WORD attr, DWORD len, COORD pos)
}
static VALUE
-console_erase_line(VALUE io, VALUE val)
-{
- rb_io_t *fptr;
- HANDLE h;
- rb_console_size_t ws;
- COORD *pos = &ws.dwCursorPosition;
- DWORD w;
- int mode = mode_in_range(val, 2, "line erase");
-
- GetOpenFile(io, fptr);
- h = (HANDLE)rb_w32_get_osfhandle(GetWriteFD(fptr));
- if (!GetConsoleScreenBufferInfo(h, &ws)) {
- rb_syserr_fail(LAST_ERROR, 0);
- }
- w = winsize_col(&ws);
- switch (mode) {
- case 0: /* after cursor */
- w -= pos->X;
- break;
- case 1: /* before *and* cursor */
- w = pos->X + 1;
- pos->X = 0;
- break;
- case 2: /* entire line */
- pos->X = 0;
- break;
- }
- constat_clear(h, ws.wAttributes, w, *pos);
- return io;
-}
-
-static VALUE
-console_erase_screen(VALUE io, VALUE val)
-{
- rb_io_t *fptr;
- HANDLE h;
- rb_console_size_t ws;
- COORD *pos = &ws.dwCursorPosition;
- DWORD w;
- int mode = mode_in_range(val, 3, "screen erase");
-
- GetOpenFile(io, fptr);
- h = (HANDLE)rb_w32_get_osfhandle(GetWriteFD(fptr));
- if (!GetConsoleScreenBufferInfo(h, &ws)) {
- rb_syserr_fail(LAST_ERROR, 0);
- }
- w = winsize_col(&ws);
- switch (mode) {
- case 0: /* erase after cursor */
- w = (w * (ws.srWindow.Bottom - pos->Y + 1) - pos->X);
- break;
- case 1: /* erase before *and* cursor */
- w = (w * (pos->Y - ws.srWindow.Top) + pos->X + 1);
- pos->X = 0;
- pos->Y = ws.srWindow.Top;
- break;
- case 2: /* erase entire screen */
- w = (w * winsize_row(&ws));
- pos->X = 0;
- pos->Y = ws.srWindow.Top;
- break;
- case 3: /* erase entire screen */
- w = (w * ws.dwSize.Y);
- pos->X = 0;
- pos->Y = 0;
- break;
- }
- constat_clear(h, ws.wAttributes, w, *pos);
- return io;
-}
-
-static VALUE
console_scroll(VALUE io, int line)
{
- rb_io_t *fptr;
HANDLE h;
rb_console_size_t ws;
- GetOpenFile(io, fptr);
- h = (HANDLE)rb_w32_get_osfhandle(GetWriteFD(fptr));
+ h = (HANDLE)rb_w32_get_osfhandle(GetWriteFD(io));
if (!GetConsoleScreenBufferInfo(h, &ws)) {
rb_syserr_fail(LAST_ERROR, 0);
}
@@ -1256,23 +1084,11 @@ static int
direct_query(VALUE io, const struct query_args *query)
{
if (RB_TYPE_P(io, T_FILE)) {
- rb_io_t *fptr;
- VALUE wio;
- GetOpenFile(io, fptr);
- wio = fptr->tied_io_for_writing;
- if (wio) {
- VALUE s = rb_str_new_cstr(query->qstr);
- rb_io_write(wio, s);
- rb_io_flush(wio);
- return 1;
- }
- if (write(fptr->fd, query->qstr, strlen(query->qstr)) != -1) {
- return 1;
- }
- if (fptr->fd == 0 &&
- write(1, query->qstr, strlen(query->qstr)) != -1) {
- return 1;
- }
+ VALUE wio = rb_io_get_write_io(io);
+ VALUE s = rb_str_new_cstr(query->qstr);
+ rb_io_write(wio, s);
+ rb_io_flush(wio);
+ return 1;
}
return 0;
}
@@ -1323,8 +1139,40 @@ console_vt_response(int argc, VALUE *argv, VALUE io, const struct query_args *qa
}
static VALUE
+console_scroll(VALUE io, int line)
+{
+ if (line) {
+ VALUE s = rb_sprintf("\x1b[%d%c", line < 0 ? -line : line,
+ line < 0 ? 'T' : 'S');
+ rb_io_write(io, s);
+ }
+ return io;
+}
+
+# define console_key_pressed_p rb_f_notimplement
+#endif
+
+/*
+ * call-seq:
+ * io.cursor -> [row, column]
+ *
+ * Returns the current cursor position as a two-element array of integers (row, column)
+ *
+ * io.cursor # => [3, 5]
+ *
+ * You must require 'io/console' to use this method.
+ */
+static VALUE
console_cursor_pos(VALUE io)
{
+#ifdef _WIN32
+ rb_console_size_t ws;
+ int fd = GetWriteFD(io);
+ if (!GetConsoleScreenBufferInfo((HANDLE)rb_w32_get_osfhandle(fd), &ws)) {
+ rb_syserr_fail(LAST_ERROR, 0);
+ }
+ return rb_assoc_new(UINT2NUM(ws.dwCursorPosition.Y), UINT2NUM(ws.dwCursorPosition.X));
+#else
static const struct query_args query = {"\033[6n", 0};
VALUE resp = console_vt_response(0, 0, io, &query);
VALUE row, column, term;
@@ -1341,18 +1189,44 @@ console_cursor_pos(VALUE io)
RARRAY_ASET(resp, 0, INT2NUM(r));
RARRAY_ASET(resp, 1, INT2NUM(c));
return resp;
+#endif
}
static VALUE
console_goto(VALUE io, VALUE y, VALUE x)
{
+#ifdef _WIN32
+ COORD pos;
+ int fd = GetWriteFD(io);
+ pos.X = NUM2UINT(x);
+ pos.Y = NUM2UINT(y);
+ if (!SetConsoleCursorPosition((HANDLE)rb_w32_get_osfhandle(fd), pos)) {
+ rb_syserr_fail(LAST_ERROR, 0);
+ }
+#else
rb_io_write(io, rb_sprintf("\x1b[%d;%dH", NUM2UINT(y)+1, NUM2UINT(x)+1));
+#endif
return io;
}
static VALUE
console_move(VALUE io, int y, int x)
{
+#ifdef _WIN32
+ HANDLE h;
+ rb_console_size_t ws;
+ COORD *pos = &ws.dwCursorPosition;
+
+ h = (HANDLE)rb_w32_get_osfhandle(GetWriteFD(io));
+ if (!GetConsoleScreenBufferInfo(h, &ws)) {
+ rb_syserr_fail(LAST_ERROR, 0);
+ }
+ pos->X += x;
+ pos->Y += y;
+ if (!SetConsoleCursorPosition(h, *pos)) {
+ rb_syserr_fail(LAST_ERROR, 0);
+ }
+#else
if (x || y) {
VALUE s = rb_str_new_cstr("");
if (y) rb_str_catf(s, "\x1b[%d%c", y < 0 ? -y : y, y < 0 ? 'A' : 'B');
@@ -1360,13 +1234,29 @@ console_move(VALUE io, int y, int x)
rb_io_write(io, s);
rb_io_flush(io);
}
+#endif
return io;
}
static VALUE
console_goto_column(VALUE io, VALUE val)
{
+#ifdef _WIN32
+ HANDLE h;
+ rb_console_size_t ws;
+ COORD *pos = &ws.dwCursorPosition;
+
+ h = (HANDLE)rb_w32_get_osfhandle(GetWriteFD(io));
+ if (!GetConsoleScreenBufferInfo(h, &ws)) {
+ rb_syserr_fail(LAST_ERROR, 0);
+ }
+ pos->X = NUM2INT(val);
+ if (!SetConsoleCursorPosition(h, *pos)) {
+ rb_syserr_fail(LAST_ERROR, 0);
+ }
+#else
rb_io_write(io, rb_sprintf("\x1b[%dG", NUM2UINT(val)+1));
+#endif
return io;
}
@@ -1374,7 +1264,34 @@ static VALUE
console_erase_line(VALUE io, VALUE val)
{
int mode = mode_in_range(val, 2, "line erase");
+#ifdef _WIN32
+ HANDLE h;
+ rb_console_size_t ws;
+ COORD *pos = &ws.dwCursorPosition;
+ DWORD w;
+
+ h = (HANDLE)rb_w32_get_osfhandle(GetWriteFD(io));
+ if (!GetConsoleScreenBufferInfo(h, &ws)) {
+ rb_syserr_fail(LAST_ERROR, 0);
+ }
+ w = winsize_col(&ws);
+ switch (mode) {
+ case 0: /* after cursor */
+ w -= pos->X;
+ break;
+ case 1: /* before *and* cursor */
+ w = pos->X + 1;
+ pos->X = 0;
+ break;
+ case 2: /* entire line */
+ pos->X = 0;
+ break;
+ }
+ constat_clear(h, ws.wAttributes, w, *pos);
+ return io;
+#else
rb_io_write(io, rb_sprintf("\x1b[%dK", mode));
+#endif
return io;
}
@@ -1382,22 +1299,43 @@ static VALUE
console_erase_screen(VALUE io, VALUE val)
{
int mode = mode_in_range(val, 3, "screen erase");
- rb_io_write(io, rb_sprintf("\x1b[%dJ", mode));
- return io;
-}
+#ifdef _WIN32
+ HANDLE h;
+ rb_console_size_t ws;
+ COORD *pos = &ws.dwCursorPosition;
+ DWORD w;
-static VALUE
-console_scroll(VALUE io, int line)
-{
- if (line) {
- VALUE s = rb_sprintf("\x1b[%d%c", line < 0 ? -line : line,
- line < 0 ? 'T' : 'S');
- rb_io_write(io, s);
+ h = (HANDLE)rb_w32_get_osfhandle(GetWriteFD(io));
+ if (!GetConsoleScreenBufferInfo(h, &ws)) {
+ rb_syserr_fail(LAST_ERROR, 0);
}
+ w = winsize_col(&ws);
+ switch (mode) {
+ case 0: /* erase after cursor */
+ w = (w * (ws.srWindow.Bottom - pos->Y + 1) - pos->X);
+ break;
+ case 1: /* erase before *and* cursor */
+ w = (w * (pos->Y - ws.srWindow.Top) + pos->X + 1);
+ pos->X = 0;
+ pos->Y = ws.srWindow.Top;
+ break;
+ case 2: /* erase entire screen */
+ w = (w * winsize_row(&ws));
+ pos->X = 0;
+ pos->Y = ws.srWindow.Top;
+ break;
+ case 3: /* erase entire screen */
+ w = (w * ws.dwSize.Y);
+ pos->X = 0;
+ pos->Y = 0;
+ break;
+ }
+ constat_clear(h, ws.wAttributes, w, *pos);
+#else
+ rb_io_write(io, rb_sprintf("\x1b[%dJ", mode));
+#endif
return io;
}
-# define console_key_pressed_p rb_f_notimplement
-#endif
static VALUE
console_cursor_set(VALUE io, VALUE cpos)
@@ -1451,6 +1389,38 @@ console_clear_screen(VALUE io)
return io;
}
+#ifndef HAVE_RB_IO_OPEN_DESCRIPTOR
+static VALUE
+io_open_descriptor_fallback(VALUE klass, int descriptor, int mode, VALUE path, VALUE timeout, void *encoding)
+{
+ rb_update_max_fd(descriptor);
+
+ VALUE arguments[2] = {
+ INT2NUM(descriptor),
+ INT2FIX(mode),
+ };
+
+ VALUE self = rb_class_new_instance(2, arguments, klass);
+
+ rb_io_t *fptr;
+ GetOpenFile(self, fptr);
+ fptr->pathv = path;
+ fptr->mode |= mode;
+
+ return self;
+}
+#define rb_io_open_descriptor io_open_descriptor_fallback
+#endif
+
+#ifndef HAVE_RB_IO_CLOSED_P
+static VALUE
+rb_io_closed_p(VALUE io)
+{
+ rb_io_t *fptr = RFILE(io)->fptr;
+ return fptr->fd == -1 ? Qtrue : Qfalse;
+}
+#endif
+
/*
* call-seq:
* IO.console -> #<File:/dev/tty>
@@ -1468,34 +1438,37 @@ static VALUE
console_dev(int argc, VALUE *argv, VALUE klass)
{
VALUE con = 0;
- rb_io_t *fptr;
VALUE sym = 0;
rb_check_arity(argc, 0, UNLIMITED_ARGUMENTS);
+
if (argc) {
- Check_Type(sym = argv[0], T_SYMBOL);
+ Check_Type(sym = argv[0], T_SYMBOL);
}
+
+ // Force the class to be File.
if (klass == rb_cIO) klass = rb_cFile;
+
if (rb_const_defined(klass, id_console)) {
- con = rb_const_get(klass, id_console);
- if (!RB_TYPE_P(con, T_FILE) ||
- (!(fptr = RFILE(con)->fptr) || GetReadFD(fptr) == -1)) {
- rb_const_remove(klass, id_console);
- con = 0;
- }
+ con = rb_const_get(klass, id_console);
+ if (!RB_TYPE_P(con, T_FILE) || RTEST(rb_io_closed_p(con))) {
+ rb_const_remove(klass, id_console);
+ con = 0;
+ }
}
+
if (sym) {
- if (sym == ID2SYM(id_close) && argc == 1) {
- if (con) {
- rb_io_close(con);
- rb_const_remove(klass, id_console);
- con = 0;
- }
- return Qnil;
- }
+ if (sym == ID2SYM(id_close) && argc == 1) {
+ if (con) {
+ rb_io_close(con);
+ rb_const_remove(klass, id_console);
+ con = 0;
+ }
+ return Qnil;
+ }
}
+
if (!con) {
- VALUE args[2];
#if defined HAVE_TERMIOS_H || defined HAVE_TERMIO_H || defined HAVE_SGTTY_H
# define CONSOLE_DEVICE "/dev/tty"
#elif defined _WIN32
@@ -1507,44 +1480,36 @@ console_dev(int argc, VALUE *argv, VALUE klass)
# define CONSOLE_DEVICE_FOR_READING CONSOLE_DEVICE
#endif
#ifdef CONSOLE_DEVICE_FOR_WRITING
- VALUE out;
- rb_io_t *ofptr;
+ VALUE out;
+ rb_io_t *ofptr;
#endif
- int fd;
+ int fd;
+ VALUE path = rb_obj_freeze(rb_str_new2(CONSOLE_DEVICE));
#ifdef CONSOLE_DEVICE_FOR_WRITING
- fd = rb_cloexec_open(CONSOLE_DEVICE_FOR_WRITING, O_RDWR, 0);
- if (fd < 0) return Qnil;
- rb_update_max_fd(fd);
- args[1] = INT2FIX(O_WRONLY);
- args[0] = INT2NUM(fd);
- out = rb_class_new_instance(2, args, klass);
+ fd = rb_cloexec_open(CONSOLE_DEVICE_FOR_WRITING, O_RDWR, 0);
+ if (fd < 0) return Qnil;
+ out = rb_io_open_descriptor(klass, fd, FMODE_WRITABLE | FMODE_SYNC, path, Qnil, NULL);
#endif
- fd = rb_cloexec_open(CONSOLE_DEVICE_FOR_READING, O_RDWR, 0);
- if (fd < 0) {
+ fd = rb_cloexec_open(CONSOLE_DEVICE_FOR_READING, O_RDWR, 0);
+ if (fd < 0) {
#ifdef CONSOLE_DEVICE_FOR_WRITING
- rb_io_close(out);
+ rb_io_close(out);
#endif
- return Qnil;
- }
- rb_update_max_fd(fd);
- args[1] = INT2FIX(O_RDWR);
- args[0] = INT2NUM(fd);
- con = rb_class_new_instance(2, args, klass);
- GetOpenFile(con, fptr);
- fptr->pathv = rb_obj_freeze(rb_str_new2(CONSOLE_DEVICE));
+ return Qnil;
+ }
+
+ con = rb_io_open_descriptor(klass, fd, FMODE_READWRITE | FMODE_SYNC, path, Qnil, NULL);
#ifdef CONSOLE_DEVICE_FOR_WRITING
- GetOpenFile(out, ofptr);
- ofptr->pathv = fptr->pathv;
- fptr->tied_io_for_writing = out;
- ofptr->mode |= FMODE_SYNC;
+ rb_io_set_write_io(con, out);
#endif
- fptr->mode |= FMODE_SYNC;
- rb_const_set(klass, id_console, con);
+ rb_const_set(klass, id_console, con);
}
+
if (sym) {
- return rb_f_send(argc, argv, con);
+ return rb_f_send(argc, argv, con);
}
+
return con;
}
@@ -1560,7 +1525,6 @@ io_getch(int argc, VALUE *argv, VALUE io)
return rb_funcallv(io, id_getc, argc, argv);
}
-#if ENABLE_IO_GETPASS
static VALUE
puts_call(VALUE io)
{
@@ -1568,6 +1532,12 @@ puts_call(VALUE io)
}
static VALUE
+gets_call(VALUE io)
+{
+ return rb_funcallv(io, id_gets, 0, 0);
+}
+
+static VALUE
getpass_call(VALUE io)
{
return ttymode(io, rb_io_gets, io, set_noecho, NULL);
@@ -1587,7 +1557,8 @@ static VALUE
str_chomp(VALUE str)
{
if (!NIL_P(str)) {
- rb_funcallv(str, id_chomp_bang, 0, 0);
+ const VALUE rs = rb_default_rs; /* rvalue in TruffleRuby */
+ rb_funcallv(str, id_chomp_bang, 1, &rs);
}
return str;
}
@@ -1604,6 +1575,12 @@ str_chomp(VALUE str)
* see String#chomp!.
*
* You must require 'io/console' to use this method.
+ *
+ * require 'io/console'
+ * IO::console.getpass("Enter password:")
+ * Enter password:
+ * # => "mypassword"
+ *
*/
static VALUE
console_getpass(int argc, VALUE *argv, VALUE io)
@@ -1614,6 +1591,7 @@ console_getpass(int argc, VALUE *argv, VALUE io)
wio = rb_io_get_write_io(io);
if (wio == io && io == rb_stdin) wio = rb_stderr;
prompt(argc, argv, wio);
+ rb_io_flush(wio);
str = rb_ensure(getpass_call, io, puts_call, wio);
return str_chomp(str);
}
@@ -1631,11 +1609,10 @@ io_getpass(int argc, VALUE *argv, VALUE io)
rb_check_arity(argc, 0, 1);
prompt(argc, argv, io);
- str = str_chomp(rb_funcallv(io, id_gets, 0, 0));
- puts_call(io);
- return str;
+ rb_check_funcall(io, id_flush, 0, 0);
+ str = rb_ensure(gets_call, io, puts_call, io);
+ return str_chomp(str);
}
-#endif
/*
* IO console methods
@@ -1645,10 +1622,9 @@ Init_console(void)
{
#undef rb_intern
id_getc = rb_intern("getc");
-#if ENABLE_IO_GETPASS
id_gets = rb_intern("gets");
+ id_flush = rb_intern("flush");
id_chomp_bang = rb_intern("chomp!");
-#endif
id_console = rb_intern("console");
id_close = rb_intern("close");
#define init_rawmode_opt_id(name) \
@@ -1696,20 +1672,17 @@ InitVM_console(void)
rb_define_method(rb_cIO, "clear_screen", console_clear_screen, 0);
rb_define_method(rb_cIO, "pressed?", console_key_pressed_p, 1);
rb_define_method(rb_cIO, "check_winsize_changed", console_check_winsize_changed, 0);
-#if ENABLE_IO_GETPASS
rb_define_method(rb_cIO, "getpass", console_getpass, -1);
-#endif
rb_define_singleton_method(rb_cIO, "console", console_dev, -1);
{
VALUE mReadable = rb_define_module_under(rb_cIO, "generic_readable");
rb_define_method(mReadable, "getch", io_getch, -1);
-#if ENABLE_IO_GETPASS
rb_define_method(mReadable, "getpass", io_getpass, -1);
-#endif
}
{
/* :stopdoc: */
cConmode = rb_define_class_under(rb_cIO, "ConsoleMode", rb_cObject);
+ rb_define_const(cConmode, "VERSION", rb_str_new_cstr(STRINGIZE(IO_CONSOLE_VERSION)));
rb_define_alloc_func(cConmode, conmode_alloc);
rb_undef_method(cConmode, "initialize");
rb_define_method(cConmode, "initialize_copy", conmode_init_copy, 1);
diff --git a/ext/io/console/depend b/ext/io/console/depend
index 06ccdde70d..59ca3442c2 100644
--- a/ext/io/console/depend
+++ b/ext/io/console/depend
@@ -54,6 +54,7 @@ console.o: $(hdrdir)/ruby/internal/attr/noexcept.h
console.o: $(hdrdir)/ruby/internal/attr/noinline.h
console.o: $(hdrdir)/ruby/internal/attr/nonnull.h
console.o: $(hdrdir)/ruby/internal/attr/noreturn.h
+console.o: $(hdrdir)/ruby/internal/attr/packed_struct.h
console.o: $(hdrdir)/ruby/internal/attr/pure.h
console.o: $(hdrdir)/ruby/internal/attr/restrict.h
console.o: $(hdrdir)/ruby/internal/attr/returns_nonnull.h
@@ -122,7 +123,6 @@ console.o: $(hdrdir)/ruby/internal/intern/enumerator.h
console.o: $(hdrdir)/ruby/internal/intern/error.h
console.o: $(hdrdir)/ruby/internal/intern/eval.h
console.o: $(hdrdir)/ruby/internal/intern/file.h
-console.o: $(hdrdir)/ruby/internal/intern/gc.h
console.o: $(hdrdir)/ruby/internal/intern/hash.h
console.o: $(hdrdir)/ruby/internal/intern/io.h
console.o: $(hdrdir)/ruby/internal/intern/load.h
@@ -153,7 +153,6 @@ console.o: $(hdrdir)/ruby/internal/memory.h
console.o: $(hdrdir)/ruby/internal/method.h
console.o: $(hdrdir)/ruby/internal/module.h
console.o: $(hdrdir)/ruby/internal/newobj.h
-console.o: $(hdrdir)/ruby/internal/rgengc.h
console.o: $(hdrdir)/ruby/internal/scan_args.h
console.o: $(hdrdir)/ruby/internal/special_consts.h
console.o: $(hdrdir)/ruby/internal/static_assert.h
diff --git a/ext/io/console/extconf.rb b/ext/io/console/extconf.rb
index e8c5923b18..aa0b6c6cfb 100644
--- a/ext/io/console/extconf.rb
+++ b/ext/io/console/extconf.rb
@@ -1,6 +1,17 @@
# frozen_string_literal: false
require 'mkmf'
+version = ["../../..", "."].find do |dir|
+ break File.read(File.join(__dir__, dir, "io-console.gemspec"))[/^_VERSION\s*=\s*"(.*?)"/, 1]
+rescue
+end
+
+have_func("rb_io_path")
+have_func("rb_io_descriptor")
+have_func("rb_io_get_write_io")
+have_func("rb_io_closed_p")
+have_func("rb_io_open_descriptor")
+
ok = true if RUBY_ENGINE == "ruby" || RUBY_ENGINE == "truffleruby"
hdr = nil
case
@@ -29,7 +40,7 @@ when true
elsif have_func("rb_scheduler_timeout") # 3.0
have_func("rb_io_wait")
end
- $defs << "-D""ENABLE_IO_GETPASS=1"
+ $defs << "-D""IO_CONSOLE_VERSION=#{version}"
create_makefile("io/console") {|conf|
conf << "\n""VK_HEADER = #{vk_header}\n"
}
diff --git a/ext/io/console/io-console.gemspec b/ext/io/console/io-console.gemspec
index d26a757b01..d4f52763b7 100644
--- a/ext/io/console/io-console.gemspec
+++ b/ext/io/console/io-console.gemspec
@@ -1,5 +1,5 @@
# -*- ruby -*-
-_VERSION = "0.6.0"
+_VERSION = "0.7.1"
Gem::Specification.new do |s|
s.name = "io-console"
@@ -13,6 +13,7 @@ Gem::Specification.new do |s|
s.authors = ["Nobu Nakada"]
s.require_path = %[lib]
s.files = %w[
+ .document
LICENSE.txt
README.md
ext/io/console/console.c
@@ -25,15 +26,16 @@ Gem::Specification.new do |s|
if Gem::Platform === s.platform and s.platform =~ 'java'
s.files.delete_if {|f| f.start_with?("ext/")}
s.extensions.clear
+ s.require_paths.unshift('lib/ffi')
s.files.concat(%w[
- lib/io/console.rb
- lib/io/console/ffi/bsd_console.rb
- lib/io/console/ffi/common.rb
- lib/io/console/ffi/console.rb
- lib/io/console/ffi/linux_console.rb
- lib/io/console/ffi/native_console.rb
- lib/io/console/ffi/stty_console.rb
- lib/io/console/ffi/stub_console.rb
+ lib/ffi/io/console.rb
+ lib/ffi/io/console/bsd_console.rb
+ lib/ffi/io/console/common.rb
+ lib/ffi/io/console/linux_console.rb
+ lib/ffi/io/console/native_console.rb
+ lib/ffi/io/console/stty_console.rb
+ lib/ffi/io/console/stub_console.rb
+ lib/ffi/io/console/version.rb
])
end
diff --git a/ext/io/nonblock/depend b/ext/io/nonblock/depend
index 7f2db65732..48384fca62 100644
--- a/ext/io/nonblock/depend
+++ b/ext/io/nonblock/depend
@@ -53,6 +53,7 @@ nonblock.o: $(hdrdir)/ruby/internal/attr/noexcept.h
nonblock.o: $(hdrdir)/ruby/internal/attr/noinline.h
nonblock.o: $(hdrdir)/ruby/internal/attr/nonnull.h
nonblock.o: $(hdrdir)/ruby/internal/attr/noreturn.h
+nonblock.o: $(hdrdir)/ruby/internal/attr/packed_struct.h
nonblock.o: $(hdrdir)/ruby/internal/attr/pure.h
nonblock.o: $(hdrdir)/ruby/internal/attr/restrict.h
nonblock.o: $(hdrdir)/ruby/internal/attr/returns_nonnull.h
@@ -121,7 +122,6 @@ nonblock.o: $(hdrdir)/ruby/internal/intern/enumerator.h
nonblock.o: $(hdrdir)/ruby/internal/intern/error.h
nonblock.o: $(hdrdir)/ruby/internal/intern/eval.h
nonblock.o: $(hdrdir)/ruby/internal/intern/file.h
-nonblock.o: $(hdrdir)/ruby/internal/intern/gc.h
nonblock.o: $(hdrdir)/ruby/internal/intern/hash.h
nonblock.o: $(hdrdir)/ruby/internal/intern/io.h
nonblock.o: $(hdrdir)/ruby/internal/intern/load.h
@@ -152,7 +152,6 @@ nonblock.o: $(hdrdir)/ruby/internal/memory.h
nonblock.o: $(hdrdir)/ruby/internal/method.h
nonblock.o: $(hdrdir)/ruby/internal/module.h
nonblock.o: $(hdrdir)/ruby/internal/newobj.h
-nonblock.o: $(hdrdir)/ruby/internal/rgengc.h
nonblock.o: $(hdrdir)/ruby/internal/scan_args.h
nonblock.o: $(hdrdir)/ruby/internal/special_consts.h
nonblock.o: $(hdrdir)/ruby/internal/static_assert.h
diff --git a/ext/io/nonblock/extconf.rb b/ext/io/nonblock/extconf.rb
index d813a01e7c..a1e6075c9b 100644
--- a/ext/io/nonblock/extconf.rb
+++ b/ext/io/nonblock/extconf.rb
@@ -2,6 +2,13 @@
require 'mkmf'
target = "io/nonblock"
+unless RUBY_ENGINE == 'ruby'
+ File.write("Makefile", dummy_makefile($srcdir).join(""))
+ return
+end
+
+have_func("rb_io_descriptor")
+
hdr = %w"fcntl.h"
if have_macro("O_NONBLOCK", hdr) and
(have_macro("F_GETFL", hdr) or have_macro("F_SETFL", hdr))
diff --git a/ext/io/nonblock/io-nonblock.gemspec b/ext/io/nonblock/io-nonblock.gemspec
index d6df21a84d..6a16c8b03b 100644
--- a/ext/io/nonblock/io-nonblock.gemspec
+++ b/ext/io/nonblock/io-nonblock.gemspec
@@ -1,6 +1,6 @@
Gem::Specification.new do |spec|
spec.name = "io-nonblock"
- spec.version = "0.2.0"
+ spec.version = "0.3.0"
spec.authors = ["Nobu Nakada"]
spec.email = ["nobu@ruby-lang.org"]
diff --git a/ext/io/nonblock/nonblock.c b/ext/io/nonblock/nonblock.c
index b8a40ff38e..d90538f735 100644
--- a/ext/io/nonblock/nonblock.c
+++ b/ext/io/nonblock/nonblock.c
@@ -17,6 +17,17 @@
#endif
#include <fcntl.h>
+#ifndef HAVE_RB_IO_DESCRIPTOR
+static int
+io_descriptor_fallback(VALUE io)
+{
+ rb_io_t *fptr;
+ GetOpenFile(io, fptr);
+ return fptr->fd;
+}
+#define rb_io_descriptor io_descriptor_fallback
+#endif
+
#ifdef F_GETFL
static int
get_fcntl_flags(int fd)
@@ -39,10 +50,8 @@ get_fcntl_flags(int fd)
static VALUE
rb_io_nonblock_p(VALUE io)
{
- rb_io_t *fptr;
- GetOpenFile(io, fptr);
- if (get_fcntl_flags(fptr->fd) & O_NONBLOCK)
- return Qtrue;
+ if (get_fcntl_flags(rb_io_descriptor(io)) & O_NONBLOCK)
+ return Qtrue;
return Qfalse;
}
#else
@@ -57,6 +66,8 @@ set_fcntl_flags(int fd, int f)
rb_sys_fail(0);
}
+#ifndef RUBY_IO_NONBLOCK_METHODS
+
static int
io_nonblock_set(int fd, int f, int nb)
{
@@ -122,17 +133,23 @@ io_nonblock_set(int fd, int f, int nb)
*
*/
static VALUE
-rb_io_nonblock_set(VALUE io, VALUE nb)
+rb_io_nonblock_set(VALUE self, VALUE value)
{
- rb_io_t *fptr;
- GetOpenFile(io, fptr);
- if (RTEST(nb))
- rb_io_set_nonblock(fptr);
- else
- io_nonblock_set(fptr->fd, get_fcntl_flags(fptr->fd), RTEST(nb));
- return io;
+ if (RTEST(value)) {
+ rb_io_t *fptr;
+ GetOpenFile(self, fptr);
+ rb_io_set_nonblock(fptr);
+ }
+ else {
+ int descriptor = rb_io_descriptor(self);
+ io_nonblock_set(descriptor, get_fcntl_flags(descriptor), RTEST(value));
+ }
+
+ return self;
}
+#endif /* RUBY_IO_NONBLOCK_METHODS */
+
static VALUE
io_nonblock_restore(VALUE arg)
{
@@ -152,24 +169,25 @@ io_nonblock_restore(VALUE arg)
* The original mode is restored after the block is executed.
*/
static VALUE
-rb_io_nonblock_block(int argc, VALUE *argv, VALUE io)
+rb_io_nonblock_block(int argc, VALUE *argv, VALUE self)
{
int nb = 1;
- rb_io_t *fptr;
- int f, restore[2];
- GetOpenFile(io, fptr);
+ int descriptor = rb_io_descriptor(self);
+
if (argc > 0) {
- VALUE v;
- rb_scan_args(argc, argv, "01", &v);
- nb = RTEST(v);
+ VALUE v;
+ rb_scan_args(argc, argv, "01", &v);
+ nb = RTEST(v);
}
- f = get_fcntl_flags(fptr->fd);
- restore[0] = fptr->fd;
- restore[1] = f;
- if (!io_nonblock_set(fptr->fd, f, nb))
- return rb_yield(io);
- return rb_ensure(rb_yield, io, io_nonblock_restore, (VALUE)restore);
+
+ int current_flags = get_fcntl_flags(descriptor);
+ int restore[2] = {descriptor, current_flags};
+
+ if (!io_nonblock_set(descriptor, current_flags, nb))
+ return rb_yield(self);
+
+ return rb_ensure(rb_yield, self, io_nonblock_restore, (VALUE)restore);
}
#else
#define rb_io_nonblock_set rb_f_notimplement
@@ -179,7 +197,10 @@ rb_io_nonblock_block(int argc, VALUE *argv, VALUE io)
void
Init_nonblock(void)
{
+#ifndef RUBY_IO_NONBLOCK_METHODS
rb_define_method(rb_cIO, "nonblock?", rb_io_nonblock_p, 0);
rb_define_method(rb_cIO, "nonblock=", rb_io_nonblock_set, 1);
+#endif
+
rb_define_method(rb_cIO, "nonblock", rb_io_nonblock_block, -1);
}
diff --git a/ext/io/wait/depend b/ext/io/wait/depend
index 51e1af8280..83cf8f94c8 100644
--- a/ext/io/wait/depend
+++ b/ext/io/wait/depend
@@ -54,6 +54,7 @@ wait.o: $(hdrdir)/ruby/internal/attr/noexcept.h
wait.o: $(hdrdir)/ruby/internal/attr/noinline.h
wait.o: $(hdrdir)/ruby/internal/attr/nonnull.h
wait.o: $(hdrdir)/ruby/internal/attr/noreturn.h
+wait.o: $(hdrdir)/ruby/internal/attr/packed_struct.h
wait.o: $(hdrdir)/ruby/internal/attr/pure.h
wait.o: $(hdrdir)/ruby/internal/attr/restrict.h
wait.o: $(hdrdir)/ruby/internal/attr/returns_nonnull.h
@@ -122,7 +123,6 @@ wait.o: $(hdrdir)/ruby/internal/intern/enumerator.h
wait.o: $(hdrdir)/ruby/internal/intern/error.h
wait.o: $(hdrdir)/ruby/internal/intern/eval.h
wait.o: $(hdrdir)/ruby/internal/intern/file.h
-wait.o: $(hdrdir)/ruby/internal/intern/gc.h
wait.o: $(hdrdir)/ruby/internal/intern/hash.h
wait.o: $(hdrdir)/ruby/internal/intern/io.h
wait.o: $(hdrdir)/ruby/internal/intern/load.h
@@ -153,7 +153,6 @@ wait.o: $(hdrdir)/ruby/internal/memory.h
wait.o: $(hdrdir)/ruby/internal/method.h
wait.o: $(hdrdir)/ruby/internal/module.h
wait.o: $(hdrdir)/ruby/internal/newobj.h
-wait.o: $(hdrdir)/ruby/internal/rgengc.h
wait.o: $(hdrdir)/ruby/internal/scan_args.h
wait.o: $(hdrdir)/ruby/internal/special_consts.h
wait.o: $(hdrdir)/ruby/internal/static_assert.h
diff --git a/ext/io/wait/extconf.rb b/ext/io/wait/extconf.rb
index eecdcce99f..e63c046187 100644
--- a/ext/io/wait/extconf.rb
+++ b/ext/io/wait/extconf.rb
@@ -6,6 +6,7 @@ if RUBY_VERSION < "2.6"
else
target = "io/wait"
have_func("rb_io_wait")
+ have_func("rb_io_descriptor")
unless macro_defined?("DOSISH", "#include <ruby.h>")
have_header(ioctl_h = "sys/ioctl.h") or ioctl_h = nil
fionread = %w[sys/ioctl.h sys/filio.h sys/socket.h].find do |h|
diff --git a/ext/io/wait/io-wait.gemspec b/ext/io/wait/io-wait.gemspec
index ebc1f6f5c7..e850e10bf9 100644
--- a/ext/io/wait/io-wait.gemspec
+++ b/ext/io/wait/io-wait.gemspec
@@ -1,4 +1,4 @@
-_VERSION = "0.3.0"
+_VERSION = "0.3.1"
Gem::Specification.new do |spec|
spec.name = "io-wait"
diff --git a/ext/io/wait/wait.c b/ext/io/wait/wait.c
index d74afb580b..8835670e59 100644
--- a/ext/io/wait/wait.c
+++ b/ext/io/wait/wait.c
@@ -87,8 +87,15 @@ io_nread(VALUE io)
rb_io_check_readable(fptr);
len = rb_io_read_pending(fptr);
if (len > 0) return INT2FIX(len);
- if (!FIONREAD_POSSIBLE_P(fptr->fd)) return INT2FIX(0);
- if (ioctl(fptr->fd, FIONREAD, &n)) return INT2FIX(0);
+
+#ifdef HAVE_RB_IO_DESCRIPTOR
+ int fd = rb_io_descriptor(io);
+#else
+ int fd = fptr->fd;
+#endif
+
+ if (!FIONREAD_POSSIBLE_P(fd)) return INT2FIX(0);
+ if (ioctl(fd, FIONREAD, &n)) return INT2FIX(0);
if (n > 0) return ioctl_arg2num(n);
return INT2FIX(0);
}
diff --git a/ext/json/VERSION b/ext/json/VERSION
deleted file mode 100644
index ec1cf33c3f..0000000000
--- a/ext/json/VERSION
+++ /dev/null
@@ -1 +0,0 @@
-2.6.3
diff --git a/ext/json/generator/depend b/ext/json/generator/depend
index 28ef06b36d..42752d1a35 100644
--- a/ext/json/generator/depend
+++ b/ext/json/generator/depend
@@ -56,6 +56,7 @@ generator.o: $(hdrdir)/ruby/internal/attr/noexcept.h
generator.o: $(hdrdir)/ruby/internal/attr/noinline.h
generator.o: $(hdrdir)/ruby/internal/attr/nonnull.h
generator.o: $(hdrdir)/ruby/internal/attr/noreturn.h
+generator.o: $(hdrdir)/ruby/internal/attr/packed_struct.h
generator.o: $(hdrdir)/ruby/internal/attr/pure.h
generator.o: $(hdrdir)/ruby/internal/attr/restrict.h
generator.o: $(hdrdir)/ruby/internal/attr/returns_nonnull.h
@@ -125,7 +126,6 @@ generator.o: $(hdrdir)/ruby/internal/intern/enumerator.h
generator.o: $(hdrdir)/ruby/internal/intern/error.h
generator.o: $(hdrdir)/ruby/internal/intern/eval.h
generator.o: $(hdrdir)/ruby/internal/intern/file.h
-generator.o: $(hdrdir)/ruby/internal/intern/gc.h
generator.o: $(hdrdir)/ruby/internal/intern/hash.h
generator.o: $(hdrdir)/ruby/internal/intern/io.h
generator.o: $(hdrdir)/ruby/internal/intern/load.h
@@ -156,7 +156,6 @@ generator.o: $(hdrdir)/ruby/internal/memory.h
generator.o: $(hdrdir)/ruby/internal/method.h
generator.o: $(hdrdir)/ruby/internal/module.h
generator.o: $(hdrdir)/ruby/internal/newobj.h
-generator.o: $(hdrdir)/ruby/internal/rgengc.h
generator.o: $(hdrdir)/ruby/internal/scan_args.h
generator.o: $(hdrdir)/ruby/internal/special_consts.h
generator.o: $(hdrdir)/ruby/internal/static_assert.h
diff --git a/ext/json/generator/generator.c b/ext/json/generator/generator.c
index 98d0ea46c3..a71acfbb76 100644
--- a/ext/json/generator/generator.c
+++ b/ext/json/generator/generator.c
@@ -16,7 +16,7 @@ static ID i_to_s, i_to_json, i_new, i_indent, i_space, i_space_before,
i_object_nl, i_array_nl, i_max_nesting, i_allow_nan, i_ascii_only,
i_pack, i_unpack, i_create_id, i_extend, i_key_p,
i_aref, i_send, i_respond_to_p, i_match, i_keys, i_depth,
- i_buffer_initial_length, i_dup, i_escape_slash;
+ i_buffer_initial_length, i_dup, i_script_safe, i_escape_slash, i_strict;
/*
* Copyright 2001-2004 Unicode, Inc.
@@ -124,7 +124,7 @@ static void unicode_escape_to_buffer(FBuffer *buffer, char buf[6], UTF16
/* Converts string to a JSON string in FBuffer buffer, where all but the ASCII
* and control characters are JSON escaped. */
-static void convert_UTF8_to_JSON_ASCII(FBuffer *buffer, VALUE string, char escape_slash)
+static void convert_UTF8_to_JSON_ASCII(FBuffer *buffer, VALUE string, char script_safe)
{
const UTF8 *source = (UTF8 *) RSTRING_PTR(string);
const UTF8 *sourceEnd = source + RSTRING_LEN(string);
@@ -175,7 +175,7 @@ static void convert_UTF8_to_JSON_ASCII(FBuffer *buffer, VALUE string, char escap
fbuffer_append(buffer, "\\\"", 2);
break;
case '/':
- if(escape_slash) {
+ if(script_safe) {
fbuffer_append(buffer, "\\/", 2);
break;
}
@@ -228,7 +228,7 @@ static void convert_UTF8_to_JSON_ASCII(FBuffer *buffer, VALUE string, char escap
* characters required by the JSON standard are JSON escaped. The remaining
* characters (should be UTF8) are just passed through and appended to the
* result. */
-static void convert_UTF8_to_JSON(FBuffer *buffer, VALUE string, char escape_slash)
+static void convert_UTF8_to_JSON(FBuffer *buffer, VALUE string, char script_safe)
{
const char *ptr = RSTRING_PTR(string), *p;
unsigned long len = RSTRING_LEN(string), start = 0, end = 0;
@@ -280,7 +280,7 @@ static void convert_UTF8_to_JSON(FBuffer *buffer, VALUE string, char escape_slas
escape_len = 2;
break;
case '/':
- if(escape_slash) {
+ if(script_safe) {
escape = "\\/";
escape_len = 2;
break;
@@ -294,6 +294,22 @@ static void convert_UTF8_to_JSON(FBuffer *buffer, VALUE string, char escape_slas
rb_raise(rb_path2class("JSON::GeneratorError"),
"partial character in source, but hit end");
}
+
+ if (script_safe && c == 0xE2) {
+ unsigned char c2 = (unsigned char) *(p+1);
+ unsigned char c3 = (unsigned char) *(p+2);
+ if (c2 == 0x80 && (c3 == 0xA8 || c3 == 0xA9)) {
+ fbuffer_append(buffer, ptr + start, end - start);
+ start = end = (end + clen);
+ if (c3 == 0xA8) {
+ fbuffer_append(buffer, "\\u2028", 6);
+ } else {
+ fbuffer_append(buffer, "\\u2029", 6);
+ }
+ continue;
+ }
+ }
+
if (!isLegalUTF8((UTF8 *) p, clen)) {
rb_raise(rb_path2class("JSON::GeneratorError"),
"source sequence is illegal/malformed utf-8");
@@ -478,6 +494,7 @@ static VALUE mFloat_to_json(int argc, VALUE *argv, VALUE self)
*/
static VALUE mString_included_s(VALUE self, VALUE modul) {
VALUE result = rb_funcall(modul, i_extend, 1, mString_Extend);
+ rb_call_super(1, &modul);
return result;
}
@@ -726,8 +743,14 @@ static VALUE cState_configure(VALUE self, VALUE opts)
state->allow_nan = RTEST(tmp);
tmp = rb_hash_aref(opts, ID2SYM(i_ascii_only));
state->ascii_only = RTEST(tmp);
- tmp = rb_hash_aref(opts, ID2SYM(i_escape_slash));
- state->escape_slash = RTEST(tmp);
+ tmp = rb_hash_aref(opts, ID2SYM(i_script_safe));
+ state->script_safe = RTEST(tmp);
+ if (!state->script_safe) {
+ tmp = rb_hash_aref(opts, ID2SYM(i_escape_slash));
+ state->script_safe = RTEST(tmp);
+ }
+ tmp = rb_hash_aref(opts, ID2SYM(i_strict));
+ state->strict = RTEST(tmp);
return self;
}
@@ -762,7 +785,8 @@ static VALUE cState_to_h(VALUE self)
rb_hash_aset(result, ID2SYM(i_allow_nan), state->allow_nan ? Qtrue : Qfalse);
rb_hash_aset(result, ID2SYM(i_ascii_only), state->ascii_only ? Qtrue : Qfalse);
rb_hash_aset(result, ID2SYM(i_max_nesting), LONG2FIX(state->max_nesting));
- rb_hash_aset(result, ID2SYM(i_escape_slash), state->escape_slash ? Qtrue : Qfalse);
+ rb_hash_aset(result, ID2SYM(i_script_safe), state->script_safe ? Qtrue : Qfalse);
+ rb_hash_aset(result, ID2SYM(i_strict), state->strict ? Qtrue : Qfalse);
rb_hash_aset(result, ID2SYM(i_depth), LONG2FIX(state->depth));
rb_hash_aset(result, ID2SYM(i_buffer_initial_length), LONG2FIX(state->buffer_initial_length));
return result;
@@ -947,9 +971,9 @@ static void generate_json_string(FBuffer *buffer, VALUE Vstate, JSON_Generator_S
}
#endif
if (state->ascii_only) {
- convert_UTF8_to_JSON_ASCII(buffer, obj, state->escape_slash);
+ convert_UTF8_to_JSON_ASCII(buffer, obj, state->script_safe);
} else {
- convert_UTF8_to_JSON(buffer, obj, state->escape_slash);
+ convert_UTF8_to_JSON(buffer, obj, state->script_safe);
}
fbuffer_append_char(buffer, '"');
}
@@ -1028,6 +1052,8 @@ static void generate_json(FBuffer *buffer, VALUE Vstate, JSON_Generator_State *s
generate_json_bignum(buffer, Vstate, state, obj);
} else if (klass == rb_cFloat) {
generate_json_float(buffer, Vstate, state, obj);
+ } else if (state->strict) {
+ rb_raise(eGeneratorError, "%"PRIsVALUE" not allowed in JSON", RB_OBJ_STRING(CLASS_OF(obj)));
} else if (rb_respond_to(obj, i_to_json)) {
tmp = rb_funcall(obj, i_to_json, 1, Vstate);
Check_Type(tmp, T_STRING);
@@ -1390,27 +1416,58 @@ static VALUE cState_max_nesting_set(VALUE self, VALUE depth)
}
/*
- * call-seq: escape_slash
+ * call-seq: script_safe
*
* If this boolean is true, the forward slashes will be escaped in
* the json output.
*/
-static VALUE cState_escape_slash(VALUE self)
+static VALUE cState_script_safe(VALUE self)
{
GET_STATE(self);
- return state->escape_slash ? Qtrue : Qfalse;
+ return state->script_safe ? Qtrue : Qfalse;
}
/*
- * call-seq: escape_slash=(depth)
+ * call-seq: script_safe=(enable)
*
* This sets whether or not the forward slashes will be escaped in
* the json output.
*/
-static VALUE cState_escape_slash_set(VALUE self, VALUE enable)
+static VALUE cState_script_safe_set(VALUE self, VALUE enable)
+{
+ GET_STATE(self);
+ state->script_safe = RTEST(enable);
+ return Qnil;
+}
+
+/*
+ * call-seq: strict
+ *
+ * If this boolean is false, types unsupported by the JSON format will
+ * be serialized as strings.
+ * If this boolean is true, types unsupported by the JSON format will
+ * raise a JSON::GeneratorError.
+ */
+static VALUE cState_strict(VALUE self)
+{
+ GET_STATE(self);
+ return state->strict ? Qtrue : Qfalse;
+}
+
+/*
+ * call-seq: strict=(enable)
+ *
+ * This sets whether or not to serialize types unsupported by the
+ * JSON format as strings.
+ * If this boolean is false, types unsupported by the JSON format will
+ * be serialized as strings.
+ * If this boolean is true, types unsupported by the JSON format will
+ * raise a JSON::GeneratorError.
+ */
+static VALUE cState_strict_set(VALUE self, VALUE enable)
{
GET_STATE(self);
- state->escape_slash = RTEST(enable);
+ state->strict = RTEST(enable);
return Qnil;
}
@@ -1530,9 +1587,15 @@ void Init_generator(void)
rb_define_method(cState, "array_nl=", cState_array_nl_set, 1);
rb_define_method(cState, "max_nesting", cState_max_nesting, 0);
rb_define_method(cState, "max_nesting=", cState_max_nesting_set, 1);
- rb_define_method(cState, "escape_slash", cState_escape_slash, 0);
- rb_define_method(cState, "escape_slash?", cState_escape_slash, 0);
- rb_define_method(cState, "escape_slash=", cState_escape_slash_set, 1);
+ rb_define_method(cState, "script_safe", cState_script_safe, 0);
+ rb_define_method(cState, "script_safe?", cState_script_safe, 0);
+ rb_define_method(cState, "script_safe=", cState_script_safe_set, 1);
+ rb_define_alias(cState, "escape_slash", "script_safe");
+ rb_define_alias(cState, "escape_slash?", "script_safe?");
+ rb_define_alias(cState, "escape_slash=", "script_safe=");
+ rb_define_method(cState, "strict", cState_strict, 0);
+ rb_define_method(cState, "strict?", cState_strict, 0);
+ rb_define_method(cState, "strict=", cState_strict_set, 1);
rb_define_method(cState, "check_circular?", cState_check_circular_p, 0);
rb_define_method(cState, "allow_nan?", cState_allow_nan_p, 0);
rb_define_method(cState, "ascii_only?", cState_ascii_only_p, 0);
@@ -1589,7 +1652,9 @@ void Init_generator(void)
i_object_nl = rb_intern("object_nl");
i_array_nl = rb_intern("array_nl");
i_max_nesting = rb_intern("max_nesting");
+ i_script_safe = rb_intern("script_safe");
i_escape_slash = rb_intern("escape_slash");
+ i_strict = rb_intern("strict");
i_allow_nan = rb_intern("allow_nan");
i_ascii_only = rb_intern("ascii_only");
i_depth = rb_intern("depth");
diff --git a/ext/json/generator/generator.h b/ext/json/generator/generator.h
index 3ebd622554..1a736b84dd 100644
--- a/ext/json/generator/generator.h
+++ b/ext/json/generator/generator.h
@@ -49,8 +49,8 @@ static const UTF32 halfMask = 0x3FFUL;
static unsigned char isLegalUTF8(const UTF8 *source, unsigned long length);
static void unicode_escape(char *buf, UTF16 character);
static void unicode_escape_to_buffer(FBuffer *buffer, char buf[6], UTF16 character);
-static void convert_UTF8_to_JSON_ASCII(FBuffer *buffer, VALUE string, char escape_slash);
-static void convert_UTF8_to_JSON(FBuffer *buffer, VALUE string, char escape_slash);
+static void convert_UTF8_to_JSON_ASCII(FBuffer *buffer, VALUE string, char script_safe);
+static void convert_UTF8_to_JSON(FBuffer *buffer, VALUE string, char script_safe);
static char *fstrndup(const char *ptr, unsigned long len);
/* ruby api and some helpers */
@@ -72,7 +72,8 @@ typedef struct JSON_Generator_StateStruct {
long max_nesting;
char allow_nan;
char ascii_only;
- char escape_slash;
+ char script_safe;
+ char strict;
long depth;
long buffer_initial_length;
} JSON_Generator_State;
@@ -151,8 +152,10 @@ static VALUE cState_allow_nan_p(VALUE self);
static VALUE cState_ascii_only_p(VALUE self);
static VALUE cState_depth(VALUE self);
static VALUE cState_depth_set(VALUE self, VALUE depth);
-static VALUE cState_escape_slash(VALUE self);
-static VALUE cState_escape_slash_set(VALUE self, VALUE depth);
+static VALUE cState_script_safe(VALUE self);
+static VALUE cState_script_safe_set(VALUE self, VALUE depth);
+static VALUE cState_strict(VALUE self);
+static VALUE cState_strict_set(VALUE self, VALUE strict);
static FBuffer *cState_prepare_buffer(VALUE self);
#ifndef ZALLOC
#define ZALLOC(type) ((type *)ruby_zalloc(sizeof(type)))
diff --git a/ext/json/json.gemspec b/ext/json/json.gemspec
index f4b2ae791d..64d0c81391 100644
--- a/ext/json/json.gemspec
+++ b/ext/json/json.gemspec
@@ -1,8 +1,10 @@
-# -*- encoding: utf-8 -*-
+version = File.foreach(File.join(__dir__, "lib/json/version.rb")) do |line|
+ /^\s*VERSION\s*=\s*'(.*)'/ =~ line and break $1
+end rescue nil
Gem::Specification.new do |s|
s.name = "json"
- s.version = File.read(File.expand_path('../VERSION', __FILE__)).chomp
+ s.version = version
s.summary = "JSON Implementation for Ruby"
s.description = "This is a JSON implementation as a Ruby extension in C."
@@ -17,7 +19,6 @@ Gem::Specification.new do |s|
"CHANGES.md",
"LICENSE",
"README.md",
- "VERSION",
"ext/json/ext/fbuffer/fbuffer.h",
"ext/json/ext/generator/depend",
"ext/json/ext/generator/extconf.rb",
diff --git a/ext/json/lib/json.rb b/ext/json/lib/json.rb
index 1e64bfcb1a..807488ffef 100644
--- a/ext/json/lib/json.rb
+++ b/ext/json/lib/json.rb
@@ -285,6 +285,15 @@ require 'json/common'
# # Raises JSON::NestingError (nesting of 2 is too deep):
# JSON.generate(obj, max_nesting: 2)
#
+# ====== Escaping Options
+#
+# Options +script_safe+ (boolean) specifies wether <tt>'\u2028'</tt>, <tt>'\u2029'</tt>
+# and <tt>'/'</tt> should be escaped as to make the JSON object safe to interpolate in script
+# tags.
+#
+# Options +ascii_only+ (boolean) specifies wether all characters outside the ASCII range
+# should be escaped.
+#
# ====== Output Options
#
# The default formatting options generate the most compact
diff --git a/ext/json/lib/json/add/bigdecimal.rb b/ext/json/lib/json/add/bigdecimal.rb
index c8b4f567cb..b1d0cfa043 100644
--- a/ext/json/lib/json/add/bigdecimal.rb
+++ b/ext/json/lib/json/add/bigdecimal.rb
@@ -2,19 +2,36 @@
unless defined?(::JSON::JSON_LOADED) and ::JSON::JSON_LOADED
require 'json'
end
-defined?(::BigDecimal) or require 'bigdecimal'
+begin
+ require 'bigdecimal'
+rescue LoadError
+end
class BigDecimal
- # Import a JSON Marshalled object.
- #
- # method used for JSON marshalling support.
+
+ # See #as_json.
def self.json_create(object)
BigDecimal._load object['b']
end
- # Marshal the object to JSON.
+ # Methods <tt>BigDecimal#as_json</tt> and +BigDecimal.json_create+ may be used
+ # to serialize and deserialize a \BigDecimal object;
+ # see Marshal[rdoc-ref:Marshal].
+ #
+ # \Method <tt>BigDecimal#as_json</tt> serializes +self+,
+ # returning a 2-element hash representing +self+:
+ #
+ # require 'json/add/bigdecimal'
+ # x = BigDecimal(2).as_json # => {"json_class"=>"BigDecimal", "b"=>"27:0.2e1"}
+ # y = BigDecimal(2.0, 4).as_json # => {"json_class"=>"BigDecimal", "b"=>"36:0.2e1"}
+ # z = BigDecimal(Complex(2, 0)).as_json # => {"json_class"=>"BigDecimal", "b"=>"27:0.2e1"}
+ #
+ # \Method +JSON.create+ deserializes such a hash, returning a \BigDecimal object:
+ #
+ # BigDecimal.json_create(x) # => 0.2e1
+ # BigDecimal.json_create(y) # => 0.2e1
+ # BigDecimal.json_create(z) # => 0.2e1
#
- # method used for JSON marshalling support.
def as_json(*)
{
JSON.create_id => self.class.name,
@@ -22,8 +39,20 @@ class BigDecimal
}
end
- # return the JSON value
+ # Returns a JSON string representing +self+:
+ #
+ # require 'json/add/bigdecimal'
+ # puts BigDecimal(2).to_json
+ # puts BigDecimal(2.0, 4).to_json
+ # puts BigDecimal(Complex(2, 0)).to_json
+ #
+ # Output:
+ #
+ # {"json_class":"BigDecimal","b":"27:0.2e1"}
+ # {"json_class":"BigDecimal","b":"36:0.2e1"}
+ # {"json_class":"BigDecimal","b":"27:0.2e1"}
+ #
def to_json(*args)
as_json.to_json(*args)
end
-end
+end if defined?(::BigDecimal)
diff --git a/ext/json/lib/json/add/complex.rb b/ext/json/lib/json/add/complex.rb
index e63e29fd22..ef48c554c6 100644
--- a/ext/json/lib/json/add/complex.rb
+++ b/ext/json/lib/json/add/complex.rb
@@ -5,14 +5,27 @@ end
class Complex
- # Deserializes JSON string by converting Real value <tt>r</tt>, imaginary
- # value <tt>i</tt>, to a Complex object.
+ # See #as_json.
def self.json_create(object)
Complex(object['r'], object['i'])
end
- # Returns a hash, that will be turned into a JSON object and represent this
- # object.
+ # Methods <tt>Complex#as_json</tt> and +Complex.json_create+ may be used
+ # to serialize and deserialize a \Complex object;
+ # see Marshal[rdoc-ref:Marshal].
+ #
+ # \Method <tt>Complex#as_json</tt> serializes +self+,
+ # returning a 2-element hash representing +self+:
+ #
+ # require 'json/add/complex'
+ # x = Complex(2).as_json # => {"json_class"=>"Complex", "r"=>2, "i"=>0}
+ # y = Complex(2.0, 4).as_json # => {"json_class"=>"Complex", "r"=>2.0, "i"=>4}
+ #
+ # \Method +JSON.create+ deserializes such a hash, returning a \Complex object:
+ #
+ # Complex.json_create(x) # => (2+0i)
+ # Complex.json_create(y) # => (2.0+4i)
+ #
def as_json(*)
{
JSON.create_id => self.class.name,
@@ -21,7 +34,17 @@ class Complex
}
end
- # Stores class name (Complex) along with real value <tt>r</tt> and imaginary value <tt>i</tt> as JSON string
+ # Returns a JSON string representing +self+:
+ #
+ # require 'json/add/complex'
+ # puts Complex(2).to_json
+ # puts Complex(2.0, 4).to_json
+ #
+ # Output:
+ #
+ # {"json_class":"Complex","r":2,"i":0}
+ # {"json_class":"Complex","r":2.0,"i":4}
+ #
def to_json(*args)
as_json.to_json(*args)
end
diff --git a/ext/json/lib/json/add/date.rb b/ext/json/lib/json/add/date.rb
index 25523561a5..19688f751b 100644
--- a/ext/json/lib/json/add/date.rb
+++ b/ext/json/lib/json/add/date.rb
@@ -6,16 +6,29 @@ require 'date'
class Date
- # Deserializes JSON string by converting Julian year <tt>y</tt>, month
- # <tt>m</tt>, day <tt>d</tt> and Day of Calendar Reform <tt>sg</tt> to Date.
+ # See #as_json.
def self.json_create(object)
civil(*object.values_at('y', 'm', 'd', 'sg'))
end
alias start sg unless method_defined?(:start)
- # Returns a hash, that will be turned into a JSON object and represent this
- # object.
+ # Methods <tt>Date#as_json</tt> and +Date.json_create+ may be used
+ # to serialize and deserialize a \Date object;
+ # see Marshal[rdoc-ref:Marshal].
+ #
+ # \Method <tt>Date#as_json</tt> serializes +self+,
+ # returning a 2-element hash representing +self+:
+ #
+ # require 'json/add/date'
+ # x = Date.today.as_json
+ # # => {"json_class"=>"Date", "y"=>2023, "m"=>11, "d"=>21, "sg"=>2299161.0}
+ #
+ # \Method +JSON.create+ deserializes such a hash, returning a \Date object:
+ #
+ # Date.json_create(x)
+ # # => #<Date: 2023-11-21 ((2460270j,0s,0n),+0s,2299161j)>
+ #
def as_json(*)
{
JSON.create_id => self.class.name,
@@ -26,8 +39,15 @@ class Date
}
end
- # Stores class name (Date) with Julian year <tt>y</tt>, month <tt>m</tt>, day
- # <tt>d</tt> and Day of Calendar Reform <tt>sg</tt> as JSON string
+ # Returns a JSON string representing +self+:
+ #
+ # require 'json/add/date'
+ # puts Date.today.to_json
+ #
+ # Output:
+ #
+ # {"json_class":"Date","y":2023,"m":11,"d":21,"sg":2299161.0}
+ #
def to_json(*args)
as_json.to_json(*args)
end
diff --git a/ext/json/lib/json/add/date_time.rb b/ext/json/lib/json/add/date_time.rb
index 38b0e86ab8..d7d42591cf 100644
--- a/ext/json/lib/json/add/date_time.rb
+++ b/ext/json/lib/json/add/date_time.rb
@@ -6,9 +6,7 @@ require 'date'
class DateTime
- # Deserializes JSON string by converting year <tt>y</tt>, month <tt>m</tt>,
- # day <tt>d</tt>, hour <tt>H</tt>, minute <tt>M</tt>, second <tt>S</tt>,
- # offset <tt>of</tt> and Day of Calendar Reform <tt>sg</tt> to DateTime.
+ # See #as_json.
def self.json_create(object)
args = object.values_at('y', 'm', 'd', 'H', 'M', 'S')
of_a, of_b = object['of'].split('/')
@@ -23,8 +21,21 @@ class DateTime
alias start sg unless method_defined?(:start)
- # Returns a hash, that will be turned into a JSON object and represent this
- # object.
+ # Methods <tt>DateTime#as_json</tt> and +DateTime.json_create+ may be used
+ # to serialize and deserialize a \DateTime object;
+ # see Marshal[rdoc-ref:Marshal].
+ #
+ # \Method <tt>DateTime#as_json</tt> serializes +self+,
+ # returning a 2-element hash representing +self+:
+ #
+ # require 'json/add/datetime'
+ # x = DateTime.now.as_json
+ # # => {"json_class"=>"DateTime", "y"=>2023, "m"=>11, "d"=>21, "sg"=>2299161.0}
+ #
+ # \Method +JSON.create+ deserializes such a hash, returning a \DateTime object:
+ #
+ # DateTime.json_create(x) # BUG? Raises Date::Error "invalid date"
+ #
def as_json(*)
{
JSON.create_id => self.class.name,
@@ -39,9 +50,15 @@ class DateTime
}
end
- # Stores class name (DateTime) with Julian year <tt>y</tt>, month <tt>m</tt>,
- # day <tt>d</tt>, hour <tt>H</tt>, minute <tt>M</tt>, second <tt>S</tt>,
- # offset <tt>of</tt> and Day of Calendar Reform <tt>sg</tt> as JSON string
+ # Returns a JSON string representing +self+:
+ #
+ # require 'json/add/datetime'
+ # puts DateTime.now.to_json
+ #
+ # Output:
+ #
+ # {"json_class":"DateTime","y":2023,"m":11,"d":21,"sg":2299161.0}
+ #
def to_json(*args)
as_json.to_json(*args)
end
diff --git a/ext/json/lib/json/add/exception.rb b/ext/json/lib/json/add/exception.rb
index a107e5b3c4..71d8deb0ea 100644
--- a/ext/json/lib/json/add/exception.rb
+++ b/ext/json/lib/json/add/exception.rb
@@ -5,16 +5,27 @@ end
class Exception
- # Deserializes JSON string by constructing new Exception object with message
- # <tt>m</tt> and backtrace <tt>b</tt> serialized with <tt>to_json</tt>
+ # See #as_json.
def self.json_create(object)
result = new(object['m'])
result.set_backtrace object['b']
result
end
- # Returns a hash, that will be turned into a JSON object and represent this
- # object.
+ # Methods <tt>Exception#as_json</tt> and +Exception.json_create+ may be used
+ # to serialize and deserialize a \Exception object;
+ # see Marshal[rdoc-ref:Marshal].
+ #
+ # \Method <tt>Exception#as_json</tt> serializes +self+,
+ # returning a 2-element hash representing +self+:
+ #
+ # require 'json/add/exception'
+ # x = Exception.new('Foo').as_json # => {"json_class"=>"Exception", "m"=>"Foo", "b"=>nil}
+ #
+ # \Method +JSON.create+ deserializes such a hash, returning a \Exception object:
+ #
+ # Exception.json_create(x) # => #<Exception: Foo>
+ #
def as_json(*)
{
JSON.create_id => self.class.name,
@@ -23,8 +34,15 @@ class Exception
}
end
- # Stores class name (Exception) with message <tt>m</tt> and backtrace array
- # <tt>b</tt> as JSON string
+ # Returns a JSON string representing +self+:
+ #
+ # require 'json/add/exception'
+ # puts Exception.new('Foo').to_json
+ #
+ # Output:
+ #
+ # {"json_class":"Exception","m":"Foo","b":null}
+ #
def to_json(*args)
as_json.to_json(*args)
end
diff --git a/ext/json/lib/json/add/ostruct.rb b/ext/json/lib/json/add/ostruct.rb
index 686cf0025d..498de17178 100644
--- a/ext/json/lib/json/add/ostruct.rb
+++ b/ext/json/lib/json/add/ostruct.rb
@@ -6,14 +6,27 @@ require 'ostruct'
class OpenStruct
- # Deserializes JSON string by constructing new Struct object with values
- # <tt>t</tt> serialized by <tt>to_json</tt>.
+ # See #as_json.
def self.json_create(object)
new(object['t'] || object[:t])
end
- # Returns a hash, that will be turned into a JSON object and represent this
- # object.
+ # Methods <tt>OpenStruct#as_json</tt> and +OpenStruct.json_create+ may be used
+ # to serialize and deserialize a \OpenStruct object;
+ # see Marshal[rdoc-ref:Marshal].
+ #
+ # \Method <tt>OpenStruct#as_json</tt> serializes +self+,
+ # returning a 2-element hash representing +self+:
+ #
+ # require 'json/add/ostruct'
+ # x = OpenStruct.new('name' => 'Rowdy', :age => nil).as_json
+ # # => {"json_class"=>"OpenStruct", "t"=>{:name=>'Rowdy', :age=>nil}}
+ #
+ # \Method +JSON.create+ deserializes such a hash, returning a \OpenStruct object:
+ #
+ # OpenStruct.json_create(x)
+ # # => #<OpenStruct name='Rowdy', age=nil>
+ #
def as_json(*)
klass = self.class.name
klass.to_s.empty? and raise JSON::JSONError, "Only named structs are supported!"
@@ -23,8 +36,15 @@ class OpenStruct
}
end
- # Stores class name (OpenStruct) with this struct's values <tt>t</tt> as a
- # JSON string.
+ # Returns a JSON string representing +self+:
+ #
+ # require 'json/add/ostruct'
+ # puts OpenStruct.new('name' => 'Rowdy', :age => nil).to_json
+ #
+ # Output:
+ #
+ # {"json_class":"OpenStruct","t":{'name':'Rowdy',"age":null}}
+ #
def to_json(*args)
as_json.to_json(*args)
end
diff --git a/ext/json/lib/json/add/range.rb b/ext/json/lib/json/add/range.rb
index 93529fb1c4..53f54ac372 100644
--- a/ext/json/lib/json/add/range.rb
+++ b/ext/json/lib/json/add/range.rb
@@ -5,14 +5,29 @@ end
class Range
- # Deserializes JSON string by constructing new Range object with arguments
- # <tt>a</tt> serialized by <tt>to_json</tt>.
+ # See #as_json.
def self.json_create(object)
new(*object['a'])
end
- # Returns a hash, that will be turned into a JSON object and represent this
- # object.
+ # Methods <tt>Range#as_json</tt> and +Range.json_create+ may be used
+ # to serialize and deserialize a \Range object;
+ # see Marshal[rdoc-ref:Marshal].
+ #
+ # \Method <tt>Range#as_json</tt> serializes +self+,
+ # returning a 2-element hash representing +self+:
+ #
+ # require 'json/add/range'
+ # x = (1..4).as_json # => {"json_class"=>"Range", "a"=>[1, 4, false]}
+ # y = (1...4).as_json # => {"json_class"=>"Range", "a"=>[1, 4, true]}
+ # z = ('a'..'d').as_json # => {"json_class"=>"Range", "a"=>["a", "d", false]}
+ #
+ # \Method +JSON.create+ deserializes such a hash, returning a \Range object:
+ #
+ # Range.json_create(x) # => 1..4
+ # Range.json_create(y) # => 1...4
+ # Range.json_create(z) # => "a".."d"
+ #
def as_json(*)
{
JSON.create_id => self.class.name,
@@ -20,9 +35,19 @@ class Range
}
end
- # Stores class name (Range) with JSON array of arguments <tt>a</tt> which
- # include <tt>first</tt> (integer), <tt>last</tt> (integer), and
- # <tt>exclude_end?</tt> (boolean) as JSON string.
+ # Returns a JSON string representing +self+:
+ #
+ # require 'json/add/range'
+ # puts (1..4).to_json
+ # puts (1...4).to_json
+ # puts ('a'..'d').to_json
+ #
+ # Output:
+ #
+ # {"json_class":"Range","a":[1,4,false]}
+ # {"json_class":"Range","a":[1,4,true]}
+ # {"json_class":"Range","a":["a","d",false]}
+ #
def to_json(*args)
as_json.to_json(*args)
end
diff --git a/ext/json/lib/json/add/rational.rb b/ext/json/lib/json/add/rational.rb
index f776226046..8c39a7db55 100644
--- a/ext/json/lib/json/add/rational.rb
+++ b/ext/json/lib/json/add/rational.rb
@@ -4,14 +4,28 @@ unless defined?(::JSON::JSON_LOADED) and ::JSON::JSON_LOADED
end
class Rational
- # Deserializes JSON string by converting numerator value <tt>n</tt>,
- # denominator value <tt>d</tt>, to a Rational object.
+
+ # See #as_json.
def self.json_create(object)
Rational(object['n'], object['d'])
end
- # Returns a hash, that will be turned into a JSON object and represent this
- # object.
+ # Methods <tt>Rational#as_json</tt> and +Rational.json_create+ may be used
+ # to serialize and deserialize a \Rational object;
+ # see Marshal[rdoc-ref:Marshal].
+ #
+ # \Method <tt>Rational#as_json</tt> serializes +self+,
+ # returning a 2-element hash representing +self+:
+ #
+ # require 'json/add/rational'
+ # x = Rational(2, 3).as_json
+ # # => {"json_class"=>"Rational", "n"=>2, "d"=>3}
+ #
+ # \Method +JSON.create+ deserializes such a hash, returning a \Rational object:
+ #
+ # Rational.json_create(x)
+ # # => (2/3)
+ #
def as_json(*)
{
JSON.create_id => self.class.name,
@@ -20,7 +34,15 @@ class Rational
}
end
- # Stores class name (Rational) along with numerator value <tt>n</tt> and denominator value <tt>d</tt> as JSON string
+ # Returns a JSON string representing +self+:
+ #
+ # require 'json/add/rational'
+ # puts Rational(2, 3).to_json
+ #
+ # Output:
+ #
+ # {"json_class":"Rational","n":2,"d":3}
+ #
def to_json(*args)
as_json.to_json(*args)
end
diff --git a/ext/json/lib/json/add/regexp.rb b/ext/json/lib/json/add/regexp.rb
index 39d69fede7..b63f49608f 100644
--- a/ext/json/lib/json/add/regexp.rb
+++ b/ext/json/lib/json/add/regexp.rb
@@ -5,15 +5,26 @@ end
class Regexp
- # Deserializes JSON string by constructing new Regexp object with source
- # <tt>s</tt> (Regexp or String) and options <tt>o</tt> serialized by
- # <tt>to_json</tt>
+ # See #as_json.
def self.json_create(object)
new(object['s'], object['o'])
end
- # Returns a hash, that will be turned into a JSON object and represent this
- # object.
+ # Methods <tt>Regexp#as_json</tt> and +Regexp.json_create+ may be used
+ # to serialize and deserialize a \Regexp object;
+ # see Marshal[rdoc-ref:Marshal].
+ #
+ # \Method <tt>Regexp#as_json</tt> serializes +self+,
+ # returning a 2-element hash representing +self+:
+ #
+ # require 'json/add/regexp'
+ # x = /foo/.as_json
+ # # => {"json_class"=>"Regexp", "o"=>0, "s"=>"foo"}
+ #
+ # \Method +JSON.create+ deserializes such a hash, returning a \Regexp object:
+ #
+ # Regexp.json_create(x) # => /foo/
+ #
def as_json(*)
{
JSON.create_id => self.class.name,
@@ -22,8 +33,15 @@ class Regexp
}
end
- # Stores class name (Regexp) with options <tt>o</tt> and source <tt>s</tt>
- # (Regexp or String) as JSON string
+ # Returns a JSON string representing +self+:
+ #
+ # require 'json/add/regexp'
+ # puts /foo/.to_json
+ #
+ # Output:
+ #
+ # {"json_class":"Regexp","o":0,"s":"foo"}
+ #
def to_json(*args)
as_json.to_json(*args)
end
diff --git a/ext/json/lib/json/add/set.rb b/ext/json/lib/json/add/set.rb
index 71e2a0ac8b..1918353187 100644
--- a/ext/json/lib/json/add/set.rb
+++ b/ext/json/lib/json/add/set.rb
@@ -4,16 +4,27 @@ end
defined?(::Set) or require 'set'
class Set
- # Import a JSON Marshalled object.
- #
- # method used for JSON marshalling support.
+
+ # See #as_json.
def self.json_create(object)
new object['a']
end
- # Marshal the object to JSON.
+ # Methods <tt>Set#as_json</tt> and +Set.json_create+ may be used
+ # to serialize and deserialize a \Set object;
+ # see Marshal[rdoc-ref:Marshal].
+ #
+ # \Method <tt>Set#as_json</tt> serializes +self+,
+ # returning a 2-element hash representing +self+:
+ #
+ # require 'json/add/set'
+ # x = Set.new(%w/foo bar baz/).as_json
+ # # => {"json_class"=>"Set", "a"=>["foo", "bar", "baz"]}
+ #
+ # \Method +JSON.create+ deserializes such a hash, returning a \Set object:
+ #
+ # Set.json_create(x) # => #<Set: {"foo", "bar", "baz"}>
#
- # method used for JSON marshalling support.
def as_json(*)
{
JSON.create_id => self.class.name,
@@ -21,7 +32,15 @@ class Set
}
end
- # return the JSON value
+ # Returns a JSON string representing +self+:
+ #
+ # require 'json/add/set'
+ # puts Set.new(%w/foo bar baz/).to_json
+ #
+ # Output:
+ #
+ # {"json_class":"Set","a":["foo","bar","baz"]}
+ #
def to_json(*args)
as_json.to_json(*args)
end
diff --git a/ext/json/lib/json/add/struct.rb b/ext/json/lib/json/add/struct.rb
index e8395ed42f..86847762ac 100644
--- a/ext/json/lib/json/add/struct.rb
+++ b/ext/json/lib/json/add/struct.rb
@@ -5,14 +5,28 @@ end
class Struct
- # Deserializes JSON string by constructing new Struct object with values
- # <tt>v</tt> serialized by <tt>to_json</tt>.
+ # See #as_json.
def self.json_create(object)
new(*object['v'])
end
- # Returns a hash, that will be turned into a JSON object and represent this
- # object.
+ # Methods <tt>Struct#as_json</tt> and +Struct.json_create+ may be used
+ # to serialize and deserialize a \Struct object;
+ # see Marshal[rdoc-ref:Marshal].
+ #
+ # \Method <tt>Struct#as_json</tt> serializes +self+,
+ # returning a 2-element hash representing +self+:
+ #
+ # require 'json/add/struct'
+ # Customer = Struct.new('Customer', :name, :address, :zip)
+ # x = Struct::Customer.new.as_json
+ # # => {"json_class"=>"Struct::Customer", "v"=>[nil, nil, nil]}
+ #
+ # \Method +JSON.create+ deserializes such a hash, returning a \Struct object:
+ #
+ # Struct::Customer.json_create(x)
+ # # => #<struct Struct::Customer name=nil, address=nil, zip=nil>
+ #
def as_json(*)
klass = self.class.name
klass.to_s.empty? and raise JSON::JSONError, "Only named structs are supported!"
@@ -22,8 +36,16 @@ class Struct
}
end
- # Stores class name (Struct) with Struct values <tt>v</tt> as a JSON string.
- # Only named structs are supported.
+ # Returns a JSON string representing +self+:
+ #
+ # require 'json/add/struct'
+ # Customer = Struct.new('Customer', :name, :address, :zip)
+ # puts Struct::Customer.new.to_json
+ #
+ # Output:
+ #
+ # {"json_class":"Struct","t":{'name':'Rowdy',"age":null}}
+ #
def to_json(*args)
as_json.to_json(*args)
end
diff --git a/ext/json/lib/json/add/symbol.rb b/ext/json/lib/json/add/symbol.rb
index 74b13a423f..b5f3623158 100644
--- a/ext/json/lib/json/add/symbol.rb
+++ b/ext/json/lib/json/add/symbol.rb
@@ -1,11 +1,26 @@
+
#frozen_string_literal: false
unless defined?(::JSON::JSON_LOADED) and ::JSON::JSON_LOADED
require 'json'
end
class Symbol
- # Returns a hash, that will be turned into a JSON object and represent this
- # object.
+
+ # Methods <tt>Symbol#as_json</tt> and +Symbol.json_create+ may be used
+ # to serialize and deserialize a \Symbol object;
+ # see Marshal[rdoc-ref:Marshal].
+ #
+ # \Method <tt>Symbol#as_json</tt> serializes +self+,
+ # returning a 2-element hash representing +self+:
+ #
+ # require 'json/add/symbol'
+ # x = :foo.as_json
+ # # => {"json_class"=>"Symbol", "s"=>"foo"}
+ #
+ # \Method +JSON.create+ deserializes such a hash, returning a \Symbol object:
+ #
+ # Symbol.json_create(x) # => :foo
+ #
def as_json(*)
{
JSON.create_id => self.class.name,
@@ -13,12 +28,20 @@ class Symbol
}
end
- # Stores class name (Symbol) with String representation of Symbol as a JSON string.
+ # Returns a JSON string representing +self+:
+ #
+ # require 'json/add/symbol'
+ # puts :foo.to_json
+ #
+ # Output:
+ #
+ # # {"json_class":"Symbol","s":"foo"}
+ #
def to_json(*a)
as_json.to_json(*a)
end
- # Deserializes JSON string by converting the <tt>string</tt> value stored in the object to a Symbol
+ # See #as_json.
def self.json_create(o)
o['s'].to_sym
end
diff --git a/ext/json/lib/json/add/time.rb b/ext/json/lib/json/add/time.rb
index b73acc4086..599ed9e24b 100644
--- a/ext/json/lib/json/add/time.rb
+++ b/ext/json/lib/json/add/time.rb
@@ -5,7 +5,7 @@ end
class Time
- # Deserializes JSON string by converting time since epoch to Time
+ # See #as_json.
def self.json_create(object)
if usec = object.delete('u') # used to be tv_usec -> tv_nsec
object['n'] = usec * 1000
@@ -17,8 +17,22 @@ class Time
end
end
- # Returns a hash, that will be turned into a JSON object and represent this
- # object.
+ # Methods <tt>Time#as_json</tt> and +Time.json_create+ may be used
+ # to serialize and deserialize a \Time object;
+ # see Marshal[rdoc-ref:Marshal].
+ #
+ # \Method <tt>Time#as_json</tt> serializes +self+,
+ # returning a 2-element hash representing +self+:
+ #
+ # require 'json/add/time'
+ # x = Time.now.as_json
+ # # => {"json_class"=>"Time", "s"=>1700931656, "n"=>472846644}
+ #
+ # \Method +JSON.create+ deserializes such a hash, returning a \Time object:
+ #
+ # Time.json_create(x)
+ # # => 2023-11-25 11:00:56.472846644 -0600
+ #
def as_json(*)
nanoseconds = [ tv_usec * 1000 ]
respond_to?(:tv_nsec) and nanoseconds << tv_nsec
@@ -30,8 +44,15 @@ class Time
}
end
- # Stores class name (Time) with number of seconds since epoch and number of
- # microseconds for Time as JSON string
+ # Returns a JSON string representing +self+:
+ #
+ # require 'json/add/time'
+ # puts Time.now.to_json
+ #
+ # Output:
+ #
+ # {"json_class":"Time","s":1700931678,"n":980650786}
+ #
def to_json(*args)
as_json.to_json(*args)
end
diff --git a/ext/json/lib/json/common.rb b/ext/json/lib/json/common.rb
index ea46896fcc..090066012d 100644
--- a/ext/json/lib/json/common.rb
+++ b/ext/json/lib/json/common.rb
@@ -3,6 +3,9 @@ require 'json/version'
require 'json/generic_object'
module JSON
+ NOT_SET = Object.new.freeze
+ private_constant :NOT_SET
+
class << self
# :call-seq:
# JSON[object] -> new_array or new_string
@@ -295,19 +298,9 @@ module JSON
#
def generate(obj, opts = nil)
if State === opts
- state, opts = opts, nil
+ state = opts
else
- state = State.new
- end
- if opts
- if opts.respond_to? :to_hash
- opts = opts.to_hash
- elsif opts.respond_to? :to_h
- opts = opts.to_h
- else
- raise TypeError, "can't convert #{opts.class} into Hash"
- end
- state = state.configure(opts)
+ state = State.new(opts)
end
state.generate(obj)
end
@@ -334,19 +327,9 @@ module JSON
# JSON.fast_generate(a)
def fast_generate(obj, opts = nil)
if State === opts
- state, opts = opts, nil
+ state = opts
else
- state = JSON.create_fast_state
- end
- if opts
- if opts.respond_to? :to_hash
- opts = opts.to_hash
- elsif opts.respond_to? :to_h
- opts = opts.to_h
- else
- raise TypeError, "can't convert #{opts.class} into Hash"
- end
- state.configure(opts)
+ state = JSON.create_fast_state.configure(opts)
end
state.generate(obj)
end
@@ -592,13 +575,13 @@ module JSON
# Sets or returns the default options for the JSON.dump method.
# Initially:
# opts = JSON.dump_default_options
- # opts # => {:max_nesting=>false, :allow_nan=>true, :escape_slash=>false}
+ # opts # => {:max_nesting=>false, :allow_nan=>true, :script_safe=>false}
attr_accessor :dump_default_options
end
self.dump_default_options = {
:max_nesting => false,
:allow_nan => true,
- :escape_slash => false,
+ :script_safe => false,
}
# :call-seq:
@@ -628,16 +611,18 @@ module JSON
# puts File.read(path)
# Output:
# {"foo":[0,1],"bar":{"baz":2,"bat":3},"bam":"bad"}
- def dump(obj, anIO = nil, limit = nil)
- if anIO and limit.nil?
- anIO = anIO.to_io if anIO.respond_to?(:to_io)
- unless anIO.respond_to?(:write)
- limit = anIO
- anIO = nil
- end
+ def dump(obj, anIO = nil, limit = nil, kwargs = nil)
+ io_limit_opt = [anIO, limit, kwargs].compact
+ kwargs = io_limit_opt.pop if io_limit_opt.last.is_a?(Hash)
+ anIO, limit = io_limit_opt
+ if anIO.respond_to?(:to_io)
+ anIO = anIO.to_io
+ elsif limit.nil? && !anIO.respond_to?(:write)
+ anIO, limit = nil, anIO
end
opts = JSON.dump_default_options
opts = opts.merge(:max_nesting => limit) if limit
+ opts = merge_dump_options(opts, **kwargs) if kwargs
result = generate(obj, opts)
if anIO
anIO.write result
@@ -653,6 +638,15 @@ module JSON
def self.iconv(to, from, string)
string.encode(to, from)
end
+
+ def merge_dump_options(opts, strict: NOT_SET)
+ opts = opts.merge(strict: strict) if NOT_SET != strict
+ opts
+ end
+
+ class << self
+ private :merge_dump_options
+ end
end
module ::Kernel
diff --git a/ext/json/lib/json/version.rb b/ext/json/lib/json/version.rb
index 3d4326d836..b43ceecdcd 100644
--- a/ext/json/lib/json/version.rb
+++ b/ext/json/lib/json/version.rb
@@ -1,7 +1,7 @@
# frozen_string_literal: false
module JSON
# JSON version
- VERSION = '2.6.3'
+ VERSION = '2.7.1'
VERSION_ARRAY = VERSION.split(/\./).map { |x| x.to_i } # :nodoc:
VERSION_MAJOR = VERSION_ARRAY[0] # :nodoc:
VERSION_MINOR = VERSION_ARRAY[1] # :nodoc:
diff --git a/ext/json/parser/depend b/ext/json/parser/depend
index a8e066ce15..cb6e547d29 100644
--- a/ext/json/parser/depend
+++ b/ext/json/parser/depend
@@ -56,6 +56,7 @@ parser.o: $(hdrdir)/ruby/internal/attr/noexcept.h
parser.o: $(hdrdir)/ruby/internal/attr/noinline.h
parser.o: $(hdrdir)/ruby/internal/attr/nonnull.h
parser.o: $(hdrdir)/ruby/internal/attr/noreturn.h
+parser.o: $(hdrdir)/ruby/internal/attr/packed_struct.h
parser.o: $(hdrdir)/ruby/internal/attr/pure.h
parser.o: $(hdrdir)/ruby/internal/attr/restrict.h
parser.o: $(hdrdir)/ruby/internal/attr/returns_nonnull.h
@@ -124,7 +125,6 @@ parser.o: $(hdrdir)/ruby/internal/intern/enumerator.h
parser.o: $(hdrdir)/ruby/internal/intern/error.h
parser.o: $(hdrdir)/ruby/internal/intern/eval.h
parser.o: $(hdrdir)/ruby/internal/intern/file.h
-parser.o: $(hdrdir)/ruby/internal/intern/gc.h
parser.o: $(hdrdir)/ruby/internal/intern/hash.h
parser.o: $(hdrdir)/ruby/internal/intern/io.h
parser.o: $(hdrdir)/ruby/internal/intern/load.h
@@ -155,7 +155,6 @@ parser.o: $(hdrdir)/ruby/internal/memory.h
parser.o: $(hdrdir)/ruby/internal/method.h
parser.o: $(hdrdir)/ruby/internal/module.h
parser.o: $(hdrdir)/ruby/internal/newobj.h
-parser.o: $(hdrdir)/ruby/internal/rgengc.h
parser.o: $(hdrdir)/ruby/internal/scan_args.h
parser.o: $(hdrdir)/ruby/internal/special_consts.h
parser.o: $(hdrdir)/ruby/internal/static_assert.h
diff --git a/ext/json/parser/parser.c b/ext/json/parser/parser.c
index 9bd7f1971e..57f87432b6 100644
--- a/ext/json/parser/parser.c
+++ b/ext/json/parser/parser.c
@@ -9,14 +9,14 @@
static void
enc_raise(rb_encoding *enc, VALUE exc, const char *fmt, ...)
{
- va_list args;
- VALUE mesg;
+ va_list args;
+ VALUE mesg;
- va_start(args, fmt);
- mesg = rb_enc_vsprintf(enc, fmt, args);
- va_end(args);
+ va_start(args, fmt);
+ mesg = rb_enc_vsprintf(enc, fmt, args);
+ va_end(args);
- rb_exc_raise(rb_exc_new3(exc, mesg));
+ rb_exc_raise(rb_exc_new3(exc, mesg));
}
# define rb_enc_raise enc_raise
# endif
@@ -28,3320 +28,2184 @@ enc_raise(rb_encoding *enc, VALUE exc, const char *fmt, ...)
/* unicode */
static const signed char digit_values[256] = {
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, -1,
- -1, -1, -1, -1, -1, -1, 10, 11, 12, 13, 14, 15, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- 10, 11, 12, 13, 14, 15, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, -1,
+ -1, -1, -1, -1, -1, -1, 10, 11, 12, 13, 14, 15, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ 10, 11, 12, 13, 14, 15, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1
};
static UTF32 unescape_unicode(const unsigned char *p)
{
- signed char b;
- UTF32 result = 0;
- b = digit_values[p[0]];
- if (b < 0) return UNI_REPLACEMENT_CHAR;
- result = (result << 4) | (unsigned char)b;
- b = digit_values[p[1]];
- if (b < 0) return UNI_REPLACEMENT_CHAR;
- result = (result << 4) | (unsigned char)b;
- b = digit_values[p[2]];
- if (b < 0) return UNI_REPLACEMENT_CHAR;
- result = (result << 4) | (unsigned char)b;
- b = digit_values[p[3]];
- if (b < 0) return UNI_REPLACEMENT_CHAR;
- result = (result << 4) | (unsigned char)b;
- return result;
+ signed char b;
+ UTF32 result = 0;
+ b = digit_values[p[0]];
+ if (b < 0) return UNI_REPLACEMENT_CHAR;
+ result = (result << 4) | (unsigned char)b;
+ b = digit_values[p[1]];
+ if (b < 0) return UNI_REPLACEMENT_CHAR;
+ result = (result << 4) | (unsigned char)b;
+ b = digit_values[p[2]];
+ if (b < 0) return UNI_REPLACEMENT_CHAR;
+ result = (result << 4) | (unsigned char)b;
+ b = digit_values[p[3]];
+ if (b < 0) return UNI_REPLACEMENT_CHAR;
+ result = (result << 4) | (unsigned char)b;
+ return result;
}
static int convert_UTF32_to_UTF8(char *buf, UTF32 ch)
{
- int len = 1;
- if (ch <= 0x7F) {
- buf[0] = (char) ch;
- } else if (ch <= 0x07FF) {
- buf[0] = (char) ((ch >> 6) | 0xC0);
- buf[1] = (char) ((ch & 0x3F) | 0x80);
- len++;
- } else if (ch <= 0xFFFF) {
- buf[0] = (char) ((ch >> 12) | 0xE0);
- buf[1] = (char) (((ch >> 6) & 0x3F) | 0x80);
- buf[2] = (char) ((ch & 0x3F) | 0x80);
- len += 2;
- } else if (ch <= 0x1fffff) {
- buf[0] =(char) ((ch >> 18) | 0xF0);
- buf[1] =(char) (((ch >> 12) & 0x3F) | 0x80);
- buf[2] =(char) (((ch >> 6) & 0x3F) | 0x80);
- buf[3] =(char) ((ch & 0x3F) | 0x80);
- len += 3;
- } else {
- buf[0] = '?';
- }
- return len;
+ int len = 1;
+ if (ch <= 0x7F) {
+ buf[0] = (char) ch;
+ } else if (ch <= 0x07FF) {
+ buf[0] = (char) ((ch >> 6) | 0xC0);
+ buf[1] = (char) ((ch & 0x3F) | 0x80);
+ len++;
+ } else if (ch <= 0xFFFF) {
+ buf[0] = (char) ((ch >> 12) | 0xE0);
+ buf[1] = (char) (((ch >> 6) & 0x3F) | 0x80);
+ buf[2] = (char) ((ch & 0x3F) | 0x80);
+ len += 2;
+ } else if (ch <= 0x1fffff) {
+ buf[0] =(char) ((ch >> 18) | 0xF0);
+ buf[1] =(char) (((ch >> 12) & 0x3F) | 0x80);
+ buf[2] =(char) (((ch >> 6) & 0x3F) | 0x80);
+ buf[3] =(char) ((ch & 0x3F) | 0x80);
+ len += 3;
+ } else {
+ buf[0] = '?';
+ }
+ return len;
}
static VALUE mJSON, mExt, cParser, eParserError, eNestingError;
static VALUE CNaN, CInfinity, CMinusInfinity;
static ID i_json_creatable_p, i_json_create, i_create_id, i_create_additions,
-i_chr, i_max_nesting, i_allow_nan, i_symbolize_names,
-i_object_class, i_array_class, i_decimal_class, i_key_p,
-i_deep_const_get, i_match, i_match_string, i_aset, i_aref,
-i_leftshift, i_new, i_try_convert, i_freeze, i_uminus;
+ i_chr, i_max_nesting, i_allow_nan, i_symbolize_names,
+ i_object_class, i_array_class, i_decimal_class, i_key_p,
+ i_deep_const_get, i_match, i_match_string, i_aset, i_aref,
+ i_leftshift, i_new, i_try_convert, i_freeze, i_uminus;
#line 125 "parser.rl"
+#line 107 "parser.c"
enum {JSON_object_start = 1};
enum {JSON_object_first_final = 27};
enum {JSON_object_error = 0};
enum {JSON_object_en_main = 1};
-static const char MAYBE_UNUSED(_JSON_object_nfa_targs)[] = {
- 0, 0
-};
-
-static const char MAYBE_UNUSED(_JSON_object_nfa_offsets)[] = {
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0
-};
-
-static const char MAYBE_UNUSED(_JSON_object_nfa_push_actions)[] = {
- 0, 0
-};
-
-static const char MAYBE_UNUSED(_JSON_object_nfa_pop_trans)[] = {
- 0, 0
-};
-
#line 167 "parser.rl"
static char *JSON_parse_object(JSON_Parser *json, char *p, char *pe, VALUE *result, int current_nesting)
{
- int cs = EVIL;
- VALUE last_name = Qnil;
- VALUE object_class = json->object_class;
+ int cs = EVIL;
+ VALUE last_name = Qnil;
+ VALUE object_class = json->object_class;
- if (json->max_nesting && current_nesting > json->max_nesting) {
- rb_raise(eNestingError, "nesting of %d is too deep", current_nesting);
- }
+ if (json->max_nesting && current_nesting > json->max_nesting) {
+ rb_raise(eNestingError, "nesting of %d is too deep", current_nesting);
+ }
- *result = NIL_P(object_class) ? rb_hash_new() : rb_class_new_instance(0, 0, object_class);
+ *result = NIL_P(object_class) ? rb_hash_new() : rb_class_new_instance(0, 0, object_class);
+#line 131 "parser.c"
{
- cs = (int)JSON_object_start;
+ cs = JSON_object_start;
}
- #line 182 "parser.rl"
-
+#line 182 "parser.rl"
+#line 138 "parser.c"
{
- if ( p == pe )
+ if ( p == pe )
goto _test_eof;
- switch ( cs )
- {
- case 1:
- goto st_case_1;
- case 0:
- goto st_case_0;
- case 2:
- goto st_case_2;
- case 3:
- goto st_case_3;
- case 4:
- goto st_case_4;
- case 5:
- goto st_case_5;
- case 6:
- goto st_case_6;
- case 7:
- goto st_case_7;
- case 8:
- goto st_case_8;
- case 9:
- goto st_case_9;
- case 10:
- goto st_case_10;
- case 11:
- goto st_case_11;
- case 12:
- goto st_case_12;
- case 13:
- goto st_case_13;
- case 14:
- goto st_case_14;
- case 15:
- goto st_case_15;
- case 16:
- goto st_case_16;
- case 17:
- goto st_case_17;
- case 18:
- goto st_case_18;
- case 27:
- goto st_case_27;
- case 19:
- goto st_case_19;
- case 20:
- goto st_case_20;
- case 21:
- goto st_case_21;
- case 22:
- goto st_case_22;
- case 23:
- goto st_case_23;
- case 24:
- goto st_case_24;
- case 25:
- goto st_case_25;
- case 26:
- goto st_case_26;
- }
- goto st_out;
- st_case_1:
- if ( ( (*( p))) == 123 ) {
- goto st2;
- }
- {
- goto st0;
- }
- st_case_0:
- st0:
- cs = 0;
- goto _out;
- st2:
- p+= 1;
- if ( p == pe )
+ switch ( cs )
+ {
+case 1:
+ if ( (*p) == 123 )
+ goto st2;
+ goto st0;
+st0:
+cs = 0;
+ goto _out;
+st2:
+ if ( ++p == pe )
goto _test_eof2;
- st_case_2:
- switch( ( (*( p))) ) {
- case 13: {
- goto st2;
- }
- case 32: {
- goto st2;
- }
- case 34: {
- goto ctr2;
- }
- case 47: {
- goto st23;
- }
- case 125: {
- goto ctr4;
- }
- }
- if ( 9 <= ( (*( p))) && ( (*( p))) <= 10 ) {
- goto st2;
- }
- {
- goto st0;
- }
- ctr2:
- {
- #line 149 "parser.rl"
-
- char *np;
- json->parsing_name = 1;
- np = JSON_parse_string(json, p, pe, &last_name);
- json->parsing_name = 0;
- if (np == NULL) { {p = p - 1; } {p+= 1; cs = 3; goto _out;} } else {p = (( np))-1;}
-
- }
-
- goto st3;
- st3:
- p+= 1;
- if ( p == pe )
+case 2:
+ switch( (*p) ) {
+ case 13: goto st2;
+ case 32: goto st2;
+ case 34: goto tr2;
+ case 47: goto st23;
+ case 125: goto tr4;
+ }
+ if ( 9 <= (*p) && (*p) <= 10 )
+ goto st2;
+ goto st0;
+tr2:
+#line 149 "parser.rl"
+ {
+ char *np;
+ json->parsing_name = 1;
+ np = JSON_parse_string(json, p, pe, &last_name);
+ json->parsing_name = 0;
+ if (np == NULL) { p--; {p++; cs = 3; goto _out;} } else {p = (( np))-1;}
+ }
+ goto st3;
+st3:
+ if ( ++p == pe )
goto _test_eof3;
- st_case_3:
- switch( ( (*( p))) ) {
- case 13: {
- goto st3;
- }
- case 32: {
- goto st3;
- }
- case 47: {
- goto st4;
- }
- case 58: {
- goto st8;
- }
- }
- if ( 9 <= ( (*( p))) && ( (*( p))) <= 10 ) {
- goto st3;
- }
- {
- goto st0;
- }
- st4:
- p+= 1;
- if ( p == pe )
+case 3:
+#line 179 "parser.c"
+ switch( (*p) ) {
+ case 13: goto st3;
+ case 32: goto st3;
+ case 47: goto st4;
+ case 58: goto st8;
+ }
+ if ( 9 <= (*p) && (*p) <= 10 )
+ goto st3;
+ goto st0;
+st4:
+ if ( ++p == pe )
goto _test_eof4;
- st_case_4:
- switch( ( (*( p))) ) {
- case 42: {
- goto st5;
- }
- case 47: {
- goto st7;
- }
- }
- {
- goto st0;
- }
- st5:
- p+= 1;
- if ( p == pe )
+case 4:
+ switch( (*p) ) {
+ case 42: goto st5;
+ case 47: goto st7;
+ }
+ goto st0;
+st5:
+ if ( ++p == pe )
goto _test_eof5;
- st_case_5:
- if ( ( (*( p))) == 42 ) {
- goto st6;
- }
- {
- goto st5;
- }
- st6:
- p+= 1;
- if ( p == pe )
+case 5:
+ if ( (*p) == 42 )
+ goto st6;
+ goto st5;
+st6:
+ if ( ++p == pe )
goto _test_eof6;
- st_case_6:
- switch( ( (*( p))) ) {
- case 42: {
- goto st6;
- }
- case 47: {
- goto st3;
- }
- }
- {
- goto st5;
- }
- st7:
- p+= 1;
- if ( p == pe )
+case 6:
+ switch( (*p) ) {
+ case 42: goto st6;
+ case 47: goto st3;
+ }
+ goto st5;
+st7:
+ if ( ++p == pe )
goto _test_eof7;
- st_case_7:
- if ( ( (*( p))) == 10 ) {
- goto st3;
- }
- {
- goto st7;
- }
- st8:
- p+= 1;
- if ( p == pe )
+case 7:
+ if ( (*p) == 10 )
+ goto st3;
+ goto st7;
+st8:
+ if ( ++p == pe )
goto _test_eof8;
- st_case_8:
- switch( ( (*( p))) ) {
- case 13: {
- goto st8;
- }
- case 32: {
- goto st8;
- }
- case 34: {
- goto ctr11;
- }
- case 45: {
- goto ctr11;
- }
- case 47: {
- goto st19;
- }
- case 73: {
- goto ctr11;
- }
- case 78: {
- goto ctr11;
- }
- case 91: {
- goto ctr11;
- }
- case 102: {
- goto ctr11;
- }
- case 110: {
- goto ctr11;
- }
- case 116: {
- goto ctr11;
- }
- case 123: {
- goto ctr11;
- }
- }
- if ( ( (*( p))) > 10 ) {
- if ( 48 <= ( (*( p))) && ( (*( p))) <= 57 ) {
- goto ctr11;
- }
- } else if ( ( (*( p))) >= 9 ) {
- goto st8;
- }
- {
- goto st0;
- }
- ctr11:
- {
- #line 133 "parser.rl"
-
- VALUE v = Qnil;
- char *np = JSON_parse_value(json, p, pe, &v, current_nesting);
- if (np == NULL) {
- {p = p - 1; } {p+= 1; cs = 9; goto _out;}
- } else {
- if (NIL_P(json->object_class)) {
- OBJ_FREEZE(last_name);
- rb_hash_aset(*result, last_name, v);
- } else {
- rb_funcall(*result, i_aset, 2, last_name, v);
- }
- {p = (( np))-1;}
-
- }
- }
-
- goto st9;
- st9:
- p+= 1;
- if ( p == pe )
+case 8:
+ switch( (*p) ) {
+ case 13: goto st8;
+ case 32: goto st8;
+ case 34: goto tr11;
+ case 45: goto tr11;
+ case 47: goto st19;
+ case 73: goto tr11;
+ case 78: goto tr11;
+ case 91: goto tr11;
+ case 102: goto tr11;
+ case 110: goto tr11;
+ case 116: goto tr11;
+ case 123: goto tr11;
+ }
+ if ( (*p) > 10 ) {
+ if ( 48 <= (*p) && (*p) <= 57 )
+ goto tr11;
+ } else if ( (*p) >= 9 )
+ goto st8;
+ goto st0;
+tr11:
+#line 133 "parser.rl"
+ {
+ VALUE v = Qnil;
+ char *np = JSON_parse_value(json, p, pe, &v, current_nesting);
+ if (np == NULL) {
+ p--; {p++; cs = 9; goto _out;}
+ } else {
+ if (NIL_P(json->object_class)) {
+ OBJ_FREEZE(last_name);
+ rb_hash_aset(*result, last_name, v);
+ } else {
+ rb_funcall(*result, i_aset, 2, last_name, v);
+ }
+ {p = (( np))-1;}
+ }
+ }
+ goto st9;
+st9:
+ if ( ++p == pe )
goto _test_eof9;
- st_case_9:
- switch( ( (*( p))) ) {
- case 13: {
- goto st9;
- }
- case 32: {
- goto st9;
- }
- case 44: {
- goto st10;
- }
- case 47: {
- goto st15;
- }
- case 125: {
- goto ctr4;
- }
- }
- if ( 9 <= ( (*( p))) && ( (*( p))) <= 10 ) {
- goto st9;
- }
- {
- goto st0;
- }
- st10:
- p+= 1;
- if ( p == pe )
+case 9:
+#line 267 "parser.c"
+ switch( (*p) ) {
+ case 13: goto st9;
+ case 32: goto st9;
+ case 44: goto st10;
+ case 47: goto st15;
+ case 125: goto tr4;
+ }
+ if ( 9 <= (*p) && (*p) <= 10 )
+ goto st9;
+ goto st0;
+st10:
+ if ( ++p == pe )
goto _test_eof10;
- st_case_10:
- switch( ( (*( p))) ) {
- case 13: {
- goto st10;
- }
- case 32: {
- goto st10;
- }
- case 34: {
- goto ctr2;
- }
- case 47: {
- goto st11;
- }
- }
- if ( 9 <= ( (*( p))) && ( (*( p))) <= 10 ) {
- goto st10;
- }
- {
- goto st0;
- }
- st11:
- p+= 1;
- if ( p == pe )
+case 10:
+ switch( (*p) ) {
+ case 13: goto st10;
+ case 32: goto st10;
+ case 34: goto tr2;
+ case 47: goto st11;
+ }
+ if ( 9 <= (*p) && (*p) <= 10 )
+ goto st10;
+ goto st0;
+st11:
+ if ( ++p == pe )
goto _test_eof11;
- st_case_11:
- switch( ( (*( p))) ) {
- case 42: {
- goto st12;
- }
- case 47: {
- goto st14;
- }
- }
- {
- goto st0;
- }
- st12:
- p+= 1;
- if ( p == pe )
+case 11:
+ switch( (*p) ) {
+ case 42: goto st12;
+ case 47: goto st14;
+ }
+ goto st0;
+st12:
+ if ( ++p == pe )
goto _test_eof12;
- st_case_12:
- if ( ( (*( p))) == 42 ) {
- goto st13;
- }
- {
- goto st12;
- }
- st13:
- p+= 1;
- if ( p == pe )
+case 12:
+ if ( (*p) == 42 )
+ goto st13;
+ goto st12;
+st13:
+ if ( ++p == pe )
goto _test_eof13;
- st_case_13:
- switch( ( (*( p))) ) {
- case 42: {
- goto st13;
- }
- case 47: {
- goto st10;
- }
- }
- {
- goto st12;
- }
- st14:
- p+= 1;
- if ( p == pe )
+case 13:
+ switch( (*p) ) {
+ case 42: goto st13;
+ case 47: goto st10;
+ }
+ goto st12;
+st14:
+ if ( ++p == pe )
goto _test_eof14;
- st_case_14:
- if ( ( (*( p))) == 10 ) {
- goto st10;
- }
- {
- goto st14;
- }
- st15:
- p+= 1;
- if ( p == pe )
+case 14:
+ if ( (*p) == 10 )
+ goto st10;
+ goto st14;
+st15:
+ if ( ++p == pe )
goto _test_eof15;
- st_case_15:
- switch( ( (*( p))) ) {
- case 42: {
- goto st16;
- }
- case 47: {
- goto st18;
- }
- }
- {
- goto st0;
- }
- st16:
- p+= 1;
- if ( p == pe )
+case 15:
+ switch( (*p) ) {
+ case 42: goto st16;
+ case 47: goto st18;
+ }
+ goto st0;
+st16:
+ if ( ++p == pe )
goto _test_eof16;
- st_case_16:
- if ( ( (*( p))) == 42 ) {
- goto st17;
- }
- {
- goto st16;
- }
- st17:
- p+= 1;
- if ( p == pe )
+case 16:
+ if ( (*p) == 42 )
+ goto st17;
+ goto st16;
+st17:
+ if ( ++p == pe )
goto _test_eof17;
- st_case_17:
- switch( ( (*( p))) ) {
- case 42: {
- goto st17;
- }
- case 47: {
- goto st9;
- }
- }
- {
- goto st16;
- }
- st18:
- p+= 1;
- if ( p == pe )
+case 17:
+ switch( (*p) ) {
+ case 42: goto st17;
+ case 47: goto st9;
+ }
+ goto st16;
+st18:
+ if ( ++p == pe )
goto _test_eof18;
- st_case_18:
- if ( ( (*( p))) == 10 ) {
- goto st9;
- }
- {
- goto st18;
- }
- ctr4:
- {
- #line 157 "parser.rl"
- {p = p - 1; } {p+= 1; cs = 27; goto _out;} }
-
- goto st27;
- st27:
- p+= 1;
- if ( p == pe )
+case 18:
+ if ( (*p) == 10 )
+ goto st9;
+ goto st18;
+tr4:
+#line 157 "parser.rl"
+ { p--; {p++; cs = 27; goto _out;} }
+ goto st27;
+st27:
+ if ( ++p == pe )
goto _test_eof27;
- st_case_27:
- {
- goto st0;
- }
- st19:
- p+= 1;
- if ( p == pe )
+case 27:
+#line 363 "parser.c"
+ goto st0;
+st19:
+ if ( ++p == pe )
goto _test_eof19;
- st_case_19:
- switch( ( (*( p))) ) {
- case 42: {
- goto st20;
- }
- case 47: {
- goto st22;
- }
- }
- {
- goto st0;
- }
- st20:
- p+= 1;
- if ( p == pe )
+case 19:
+ switch( (*p) ) {
+ case 42: goto st20;
+ case 47: goto st22;
+ }
+ goto st0;
+st20:
+ if ( ++p == pe )
goto _test_eof20;
- st_case_20:
- if ( ( (*( p))) == 42 ) {
- goto st21;
- }
- {
- goto st20;
- }
- st21:
- p+= 1;
- if ( p == pe )
+case 20:
+ if ( (*p) == 42 )
+ goto st21;
+ goto st20;
+st21:
+ if ( ++p == pe )
goto _test_eof21;
- st_case_21:
- switch( ( (*( p))) ) {
- case 42: {
- goto st21;
- }
- case 47: {
- goto st8;
- }
- }
- {
- goto st20;
- }
- st22:
- p+= 1;
- if ( p == pe )
+case 21:
+ switch( (*p) ) {
+ case 42: goto st21;
+ case 47: goto st8;
+ }
+ goto st20;
+st22:
+ if ( ++p == pe )
goto _test_eof22;
- st_case_22:
- if ( ( (*( p))) == 10 ) {
- goto st8;
- }
- {
- goto st22;
- }
- st23:
- p+= 1;
- if ( p == pe )
+case 22:
+ if ( (*p) == 10 )
+ goto st8;
+ goto st22;
+st23:
+ if ( ++p == pe )
goto _test_eof23;
- st_case_23:
- switch( ( (*( p))) ) {
- case 42: {
- goto st24;
- }
- case 47: {
- goto st26;
- }
- }
- {
- goto st0;
- }
- st24:
- p+= 1;
- if ( p == pe )
+case 23:
+ switch( (*p) ) {
+ case 42: goto st24;
+ case 47: goto st26;
+ }
+ goto st0;
+st24:
+ if ( ++p == pe )
goto _test_eof24;
- st_case_24:
- if ( ( (*( p))) == 42 ) {
- goto st25;
- }
- {
- goto st24;
- }
- st25:
- p+= 1;
- if ( p == pe )
+case 24:
+ if ( (*p) == 42 )
+ goto st25;
+ goto st24;
+st25:
+ if ( ++p == pe )
goto _test_eof25;
- st_case_25:
- switch( ( (*( p))) ) {
- case 42: {
- goto st25;
- }
- case 47: {
- goto st2;
- }
- }
- {
- goto st24;
- }
- st26:
- p+= 1;
- if ( p == pe )
+case 25:
+ switch( (*p) ) {
+ case 42: goto st25;
+ case 47: goto st2;
+ }
+ goto st24;
+st26:
+ if ( ++p == pe )
goto _test_eof26;
- st_case_26:
- if ( ( (*( p))) == 10 ) {
- goto st2;
- }
- {
- goto st26;
- }
- st_out:
- _test_eof2: cs = 2; goto _test_eof;
- _test_eof3: cs = 3; goto _test_eof;
- _test_eof4: cs = 4; goto _test_eof;
- _test_eof5: cs = 5; goto _test_eof;
- _test_eof6: cs = 6; goto _test_eof;
- _test_eof7: cs = 7; goto _test_eof;
- _test_eof8: cs = 8; goto _test_eof;
- _test_eof9: cs = 9; goto _test_eof;
- _test_eof10: cs = 10; goto _test_eof;
- _test_eof11: cs = 11; goto _test_eof;
- _test_eof12: cs = 12; goto _test_eof;
- _test_eof13: cs = 13; goto _test_eof;
- _test_eof14: cs = 14; goto _test_eof;
- _test_eof15: cs = 15; goto _test_eof;
- _test_eof16: cs = 16; goto _test_eof;
- _test_eof17: cs = 17; goto _test_eof;
- _test_eof18: cs = 18; goto _test_eof;
- _test_eof27: cs = 27; goto _test_eof;
- _test_eof19: cs = 19; goto _test_eof;
- _test_eof20: cs = 20; goto _test_eof;
- _test_eof21: cs = 21; goto _test_eof;
- _test_eof22: cs = 22; goto _test_eof;
- _test_eof23: cs = 23; goto _test_eof;
- _test_eof24: cs = 24; goto _test_eof;
- _test_eof25: cs = 25; goto _test_eof;
- _test_eof26: cs = 26; goto _test_eof;
-
- _test_eof: {}
- _out: {}
- }
-
- #line 183 "parser.rl"
-
-
- if (cs >= JSON_object_first_final) {
- if (json->create_additions) {
- VALUE klassname;
- if (NIL_P(json->object_class)) {
- klassname = rb_hash_aref(*result, json->create_id);
- } else {
- klassname = rb_funcall(*result, i_aref, 1, json->create_id);
- }
- if (!NIL_P(klassname)) {
- VALUE klass = rb_funcall(mJSON, i_deep_const_get, 1, klassname);
- if (RTEST(rb_funcall(klass, i_json_creatable_p, 0))) {
- *result = rb_funcall(klass, i_json_create, 1, *result);
- }
- }
- }
- return p + 1;
- } else {
- return NULL;
+case 26:
+ if ( (*p) == 10 )
+ goto st2;
+ goto st26;
+ }
+ _test_eof2: cs = 2; goto _test_eof;
+ _test_eof3: cs = 3; goto _test_eof;
+ _test_eof4: cs = 4; goto _test_eof;
+ _test_eof5: cs = 5; goto _test_eof;
+ _test_eof6: cs = 6; goto _test_eof;
+ _test_eof7: cs = 7; goto _test_eof;
+ _test_eof8: cs = 8; goto _test_eof;
+ _test_eof9: cs = 9; goto _test_eof;
+ _test_eof10: cs = 10; goto _test_eof;
+ _test_eof11: cs = 11; goto _test_eof;
+ _test_eof12: cs = 12; goto _test_eof;
+ _test_eof13: cs = 13; goto _test_eof;
+ _test_eof14: cs = 14; goto _test_eof;
+ _test_eof15: cs = 15; goto _test_eof;
+ _test_eof16: cs = 16; goto _test_eof;
+ _test_eof17: cs = 17; goto _test_eof;
+ _test_eof18: cs = 18; goto _test_eof;
+ _test_eof27: cs = 27; goto _test_eof;
+ _test_eof19: cs = 19; goto _test_eof;
+ _test_eof20: cs = 20; goto _test_eof;
+ _test_eof21: cs = 21; goto _test_eof;
+ _test_eof22: cs = 22; goto _test_eof;
+ _test_eof23: cs = 23; goto _test_eof;
+ _test_eof24: cs = 24; goto _test_eof;
+ _test_eof25: cs = 25; goto _test_eof;
+ _test_eof26: cs = 26; goto _test_eof;
+
+ _test_eof: {}
+ _out: {}
}
+
+#line 183 "parser.rl"
+
+ if (cs >= JSON_object_first_final) {
+ if (json->create_additions) {
+ VALUE klassname;
+ if (NIL_P(json->object_class)) {
+ klassname = rb_hash_aref(*result, json->create_id);
+ } else {
+ klassname = rb_funcall(*result, i_aref, 1, json->create_id);
+ }
+ if (!NIL_P(klassname)) {
+ VALUE klass = rb_funcall(mJSON, i_deep_const_get, 1, klassname);
+ if (RTEST(rb_funcall(klass, i_json_creatable_p, 0))) {
+ *result = rb_funcall(klass, i_json_create, 1, *result);
+ }
+ }
+ }
+ return p + 1;
+ } else {
+ return NULL;
+ }
}
+#line 486 "parser.c"
enum {JSON_value_start = 1};
enum {JSON_value_first_final = 29};
enum {JSON_value_error = 0};
enum {JSON_value_en_main = 1};
-static const char MAYBE_UNUSED(_JSON_value_nfa_targs)[] = {
- 0, 0
-};
-
-static const char MAYBE_UNUSED(_JSON_value_nfa_offsets)[] = {
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0
-};
-
-static const char MAYBE_UNUSED(_JSON_value_nfa_push_actions)[] = {
- 0, 0
-};
-
-static const char MAYBE_UNUSED(_JSON_value_nfa_pop_trans)[] = {
- 0, 0
-};
-
#line 283 "parser.rl"
static char *JSON_parse_value(JSON_Parser *json, char *p, char *pe, VALUE *result, int current_nesting)
{
- int cs = EVIL;
+ int cs = EVIL;
+#line 502 "parser.c"
{
- cs = (int)JSON_value_start;
+ cs = JSON_value_start;
}
- #line 290 "parser.rl"
-
+#line 290 "parser.rl"
+#line 509 "parser.c"
{
- if ( p == pe )
+ if ( p == pe )
goto _test_eof;
- switch ( cs )
- {
- case 1:
- goto st_case_1;
- case 0:
- goto st_case_0;
- case 29:
- goto st_case_29;
- case 2:
- goto st_case_2;
- case 3:
- goto st_case_3;
- case 4:
- goto st_case_4;
- case 5:
- goto st_case_5;
- case 6:
- goto st_case_6;
- case 7:
- goto st_case_7;
- case 8:
- goto st_case_8;
- case 9:
- goto st_case_9;
- case 10:
- goto st_case_10;
- case 11:
- goto st_case_11;
- case 12:
- goto st_case_12;
- case 13:
- goto st_case_13;
- case 14:
- goto st_case_14;
- case 15:
- goto st_case_15;
- case 16:
- goto st_case_16;
- case 17:
- goto st_case_17;
- case 18:
- goto st_case_18;
- case 19:
- goto st_case_19;
- case 20:
- goto st_case_20;
- case 21:
- goto st_case_21;
- case 22:
- goto st_case_22;
- case 23:
- goto st_case_23;
- case 24:
- goto st_case_24;
- case 25:
- goto st_case_25;
- case 26:
- goto st_case_26;
- case 27:
- goto st_case_27;
- case 28:
- goto st_case_28;
- }
- goto st_out;
- st1:
- p+= 1;
- if ( p == pe )
+ switch ( cs )
+ {
+st1:
+ if ( ++p == pe )
goto _test_eof1;
- st_case_1:
- switch( ( (*( p))) ) {
- case 13: {
- goto st1;
- }
- case 32: {
- goto st1;
- }
- case 34: {
- goto ctr2;
- }
- case 45: {
- goto ctr3;
- }
- case 47: {
- goto st6;
- }
- case 73: {
- goto st10;
- }
- case 78: {
- goto st17;
- }
- case 91: {
- goto ctr7;
- }
- case 102: {
- goto st19;
- }
- case 110: {
- goto st23;
- }
- case 116: {
- goto st26;
- }
- case 123: {
- goto ctr11;
- }
- }
- if ( ( (*( p))) > 10 ) {
- if ( 48 <= ( (*( p))) && ( (*( p))) <= 57 ) {
- goto ctr3;
- }
- } else if ( ( (*( p))) >= 9 ) {
- goto st1;
- }
- {
- goto st0;
- }
- st_case_0:
- st0:
- cs = 0;
- goto _out;
- ctr2:
- {
- #line 235 "parser.rl"
-
- char *np = JSON_parse_string(json, p, pe, result);
- if (np == NULL) { {p = p - 1; } {p+= 1; cs = 29; goto _out;} } else {p = (( np))-1;}
-
- }
-
- goto st29;
- ctr3:
- {
- #line 240 "parser.rl"
-
- char *np;
- if(pe > p + 8 && !strncmp(MinusInfinity, p, 9)) {
- if (json->allow_nan) {
- *result = CMinusInfinity;
- {p = (( p + 10))-1;}
-
- {p = p - 1; } {p+= 1; cs = 29; goto _out;}
- } else {
- rb_enc_raise(EXC_ENCODING eParserError, "unexpected token at '%s'", p);
- }
- }
- np = JSON_parse_float(json, p, pe, result);
- if (np != NULL) {p = (( np))-1;}
-
- np = JSON_parse_integer(json, p, pe, result);
- if (np != NULL) {p = (( np))-1;}
-
- {p = p - 1; } {p+= 1; cs = 29; goto _out;}
- }
-
- goto st29;
- ctr7:
- {
- #line 258 "parser.rl"
-
- char *np;
- np = JSON_parse_array(json, p, pe, result, current_nesting + 1);
- if (np == NULL) { {p = p - 1; } {p+= 1; cs = 29; goto _out;} } else {p = (( np))-1;}
-
- }
-
- goto st29;
- ctr11:
- {
- #line 264 "parser.rl"
-
- char *np;
- np = JSON_parse_object(json, p, pe, result, current_nesting + 1);
- if (np == NULL) { {p = p - 1; } {p+= 1; cs = 29; goto _out;} } else {p = (( np))-1;}
-
- }
-
- goto st29;
- ctr25:
- {
- #line 228 "parser.rl"
-
- if (json->allow_nan) {
- *result = CInfinity;
- } else {
- rb_enc_raise(EXC_ENCODING eParserError, "unexpected token at '%s'", p - 8);
- }
- }
-
- goto st29;
- ctr27:
- {
- #line 221 "parser.rl"
-
- if (json->allow_nan) {
- *result = CNaN;
- } else {
- rb_enc_raise(EXC_ENCODING eParserError, "unexpected token at '%s'", p - 2);
- }
- }
-
- goto st29;
- ctr31:
- {
- #line 215 "parser.rl"
-
- *result = Qfalse;
- }
-
- goto st29;
- ctr34:
- {
- #line 212 "parser.rl"
-
- *result = Qnil;
- }
-
- goto st29;
- ctr37:
- {
- #line 218 "parser.rl"
-
- *result = Qtrue;
- }
-
- goto st29;
- st29:
- p+= 1;
- if ( p == pe )
+case 1:
+ switch( (*p) ) {
+ case 13: goto st1;
+ case 32: goto st1;
+ case 34: goto tr2;
+ case 45: goto tr3;
+ case 47: goto st6;
+ case 73: goto st10;
+ case 78: goto st17;
+ case 91: goto tr7;
+ case 102: goto st19;
+ case 110: goto st23;
+ case 116: goto st26;
+ case 123: goto tr11;
+ }
+ if ( (*p) > 10 ) {
+ if ( 48 <= (*p) && (*p) <= 57 )
+ goto tr3;
+ } else if ( (*p) >= 9 )
+ goto st1;
+ goto st0;
+st0:
+cs = 0;
+ goto _out;
+tr2:
+#line 235 "parser.rl"
+ {
+ char *np = JSON_parse_string(json, p, pe, result);
+ if (np == NULL) { p--; {p++; cs = 29; goto _out;} } else {p = (( np))-1;}
+ }
+ goto st29;
+tr3:
+#line 240 "parser.rl"
+ {
+ char *np;
+ if(pe > p + 8 && !strncmp(MinusInfinity, p, 9)) {
+ if (json->allow_nan) {
+ *result = CMinusInfinity;
+ {p = (( p + 10))-1;}
+ p--; {p++; cs = 29; goto _out;}
+ } else {
+ rb_enc_raise(EXC_ENCODING eParserError, "unexpected token at '%s'", p);
+ }
+ }
+ np = JSON_parse_float(json, p, pe, result);
+ if (np != NULL) {p = (( np))-1;}
+ np = JSON_parse_integer(json, p, pe, result);
+ if (np != NULL) {p = (( np))-1;}
+ p--; {p++; cs = 29; goto _out;}
+ }
+ goto st29;
+tr7:
+#line 258 "parser.rl"
+ {
+ char *np;
+ np = JSON_parse_array(json, p, pe, result, current_nesting + 1);
+ if (np == NULL) { p--; {p++; cs = 29; goto _out;} } else {p = (( np))-1;}
+ }
+ goto st29;
+tr11:
+#line 264 "parser.rl"
+ {
+ char *np;
+ np = JSON_parse_object(json, p, pe, result, current_nesting + 1);
+ if (np == NULL) { p--; {p++; cs = 29; goto _out;} } else {p = (( np))-1;}
+ }
+ goto st29;
+tr25:
+#line 228 "parser.rl"
+ {
+ if (json->allow_nan) {
+ *result = CInfinity;
+ } else {
+ rb_enc_raise(EXC_ENCODING eParserError, "unexpected token at '%s'", p - 7);
+ }
+ }
+ goto st29;
+tr27:
+#line 221 "parser.rl"
+ {
+ if (json->allow_nan) {
+ *result = CNaN;
+ } else {
+ rb_enc_raise(EXC_ENCODING eParserError, "unexpected token at '%s'", p - 2);
+ }
+ }
+ goto st29;
+tr31:
+#line 215 "parser.rl"
+ {
+ *result = Qfalse;
+ }
+ goto st29;
+tr34:
+#line 212 "parser.rl"
+ {
+ *result = Qnil;
+ }
+ goto st29;
+tr37:
+#line 218 "parser.rl"
+ {
+ *result = Qtrue;
+ }
+ goto st29;
+st29:
+ if ( ++p == pe )
goto _test_eof29;
- st_case_29:
- {
- #line 270 "parser.rl"
- {p = p - 1; } {p+= 1; cs = 29; goto _out;} }
- switch( ( (*( p))) ) {
- case 13: {
- goto st29;
- }
- case 32: {
- goto st29;
- }
- case 47: {
- goto st2;
- }
- }
- if ( 9 <= ( (*( p))) && ( (*( p))) <= 10 ) {
- goto st29;
- }
- {
- goto st0;
- }
- st2:
- p+= 1;
- if ( p == pe )
+case 29:
+#line 270 "parser.rl"
+ { p--; {p++; cs = 29; goto _out;} }
+#line 629 "parser.c"
+ switch( (*p) ) {
+ case 13: goto st29;
+ case 32: goto st29;
+ case 47: goto st2;
+ }
+ if ( 9 <= (*p) && (*p) <= 10 )
+ goto st29;
+ goto st0;
+st2:
+ if ( ++p == pe )
goto _test_eof2;
- st_case_2:
- switch( ( (*( p))) ) {
- case 42: {
- goto st3;
- }
- case 47: {
- goto st5;
- }
- }
- {
- goto st0;
- }
- st3:
- p+= 1;
- if ( p == pe )
+case 2:
+ switch( (*p) ) {
+ case 42: goto st3;
+ case 47: goto st5;
+ }
+ goto st0;
+st3:
+ if ( ++p == pe )
goto _test_eof3;
- st_case_3:
- if ( ( (*( p))) == 42 ) {
- goto st4;
- }
- {
- goto st3;
- }
- st4:
- p+= 1;
- if ( p == pe )
+case 3:
+ if ( (*p) == 42 )
+ goto st4;
+ goto st3;
+st4:
+ if ( ++p == pe )
goto _test_eof4;
- st_case_4:
- switch( ( (*( p))) ) {
- case 42: {
- goto st4;
- }
- case 47: {
- goto st29;
- }
- }
- {
- goto st3;
- }
- st5:
- p+= 1;
- if ( p == pe )
+case 4:
+ switch( (*p) ) {
+ case 42: goto st4;
+ case 47: goto st29;
+ }
+ goto st3;
+st5:
+ if ( ++p == pe )
goto _test_eof5;
- st_case_5:
- if ( ( (*( p))) == 10 ) {
- goto st29;
- }
- {
- goto st5;
- }
- st6:
- p+= 1;
- if ( p == pe )
+case 5:
+ if ( (*p) == 10 )
+ goto st29;
+ goto st5;
+st6:
+ if ( ++p == pe )
goto _test_eof6;
- st_case_6:
- switch( ( (*( p))) ) {
- case 42: {
- goto st7;
- }
- case 47: {
- goto st9;
- }
- }
- {
- goto st0;
- }
- st7:
- p+= 1;
- if ( p == pe )
+case 6:
+ switch( (*p) ) {
+ case 42: goto st7;
+ case 47: goto st9;
+ }
+ goto st0;
+st7:
+ if ( ++p == pe )
goto _test_eof7;
- st_case_7:
- if ( ( (*( p))) == 42 ) {
- goto st8;
- }
- {
- goto st7;
- }
- st8:
- p+= 1;
- if ( p == pe )
+case 7:
+ if ( (*p) == 42 )
+ goto st8;
+ goto st7;
+st8:
+ if ( ++p == pe )
goto _test_eof8;
- st_case_8:
- switch( ( (*( p))) ) {
- case 42: {
- goto st8;
- }
- case 47: {
- goto st1;
- }
- }
- {
- goto st7;
- }
- st9:
- p+= 1;
- if ( p == pe )
+case 8:
+ switch( (*p) ) {
+ case 42: goto st8;
+ case 47: goto st1;
+ }
+ goto st7;
+st9:
+ if ( ++p == pe )
goto _test_eof9;
- st_case_9:
- if ( ( (*( p))) == 10 ) {
- goto st1;
- }
- {
- goto st9;
- }
- st10:
- p+= 1;
- if ( p == pe )
+case 9:
+ if ( (*p) == 10 )
+ goto st1;
+ goto st9;
+st10:
+ if ( ++p == pe )
goto _test_eof10;
- st_case_10:
- if ( ( (*( p))) == 110 ) {
- goto st11;
- }
- {
- goto st0;
- }
- st11:
- p+= 1;
- if ( p == pe )
+case 10:
+ if ( (*p) == 110 )
+ goto st11;
+ goto st0;
+st11:
+ if ( ++p == pe )
goto _test_eof11;
- st_case_11:
- if ( ( (*( p))) == 102 ) {
- goto st12;
- }
- {
- goto st0;
- }
- st12:
- p+= 1;
- if ( p == pe )
+case 11:
+ if ( (*p) == 102 )
+ goto st12;
+ goto st0;
+st12:
+ if ( ++p == pe )
goto _test_eof12;
- st_case_12:
- if ( ( (*( p))) == 105 ) {
- goto st13;
- }
- {
- goto st0;
- }
- st13:
- p+= 1;
- if ( p == pe )
+case 12:
+ if ( (*p) == 105 )
+ goto st13;
+ goto st0;
+st13:
+ if ( ++p == pe )
goto _test_eof13;
- st_case_13:
- if ( ( (*( p))) == 110 ) {
- goto st14;
- }
- {
- goto st0;
- }
- st14:
- p+= 1;
- if ( p == pe )
+case 13:
+ if ( (*p) == 110 )
+ goto st14;
+ goto st0;
+st14:
+ if ( ++p == pe )
goto _test_eof14;
- st_case_14:
- if ( ( (*( p))) == 105 ) {
- goto st15;
- }
- {
- goto st0;
- }
- st15:
- p+= 1;
- if ( p == pe )
+case 14:
+ if ( (*p) == 105 )
+ goto st15;
+ goto st0;
+st15:
+ if ( ++p == pe )
goto _test_eof15;
- st_case_15:
- if ( ( (*( p))) == 116 ) {
- goto st16;
- }
- {
- goto st0;
- }
- st16:
- p+= 1;
- if ( p == pe )
+case 15:
+ if ( (*p) == 116 )
+ goto st16;
+ goto st0;
+st16:
+ if ( ++p == pe )
goto _test_eof16;
- st_case_16:
- if ( ( (*( p))) == 121 ) {
- goto ctr25;
- }
- {
- goto st0;
- }
- st17:
- p+= 1;
- if ( p == pe )
+case 16:
+ if ( (*p) == 121 )
+ goto tr25;
+ goto st0;
+st17:
+ if ( ++p == pe )
goto _test_eof17;
- st_case_17:
- if ( ( (*( p))) == 97 ) {
- goto st18;
- }
- {
- goto st0;
- }
- st18:
- p+= 1;
- if ( p == pe )
+case 17:
+ if ( (*p) == 97 )
+ goto st18;
+ goto st0;
+st18:
+ if ( ++p == pe )
goto _test_eof18;
- st_case_18:
- if ( ( (*( p))) == 78 ) {
- goto ctr27;
- }
- {
- goto st0;
- }
- st19:
- p+= 1;
- if ( p == pe )
+case 18:
+ if ( (*p) == 78 )
+ goto tr27;
+ goto st0;
+st19:
+ if ( ++p == pe )
goto _test_eof19;
- st_case_19:
- if ( ( (*( p))) == 97 ) {
- goto st20;
- }
- {
- goto st0;
- }
- st20:
- p+= 1;
- if ( p == pe )
+case 19:
+ if ( (*p) == 97 )
+ goto st20;
+ goto st0;
+st20:
+ if ( ++p == pe )
goto _test_eof20;
- st_case_20:
- if ( ( (*( p))) == 108 ) {
- goto st21;
- }
- {
- goto st0;
- }
- st21:
- p+= 1;
- if ( p == pe )
+case 20:
+ if ( (*p) == 108 )
+ goto st21;
+ goto st0;
+st21:
+ if ( ++p == pe )
goto _test_eof21;
- st_case_21:
- if ( ( (*( p))) == 115 ) {
- goto st22;
- }
- {
- goto st0;
- }
- st22:
- p+= 1;
- if ( p == pe )
+case 21:
+ if ( (*p) == 115 )
+ goto st22;
+ goto st0;
+st22:
+ if ( ++p == pe )
goto _test_eof22;
- st_case_22:
- if ( ( (*( p))) == 101 ) {
- goto ctr31;
- }
- {
- goto st0;
- }
- st23:
- p+= 1;
- if ( p == pe )
+case 22:
+ if ( (*p) == 101 )
+ goto tr31;
+ goto st0;
+st23:
+ if ( ++p == pe )
goto _test_eof23;
- st_case_23:
- if ( ( (*( p))) == 117 ) {
- goto st24;
- }
- {
- goto st0;
- }
- st24:
- p+= 1;
- if ( p == pe )
+case 23:
+ if ( (*p) == 117 )
+ goto st24;
+ goto st0;
+st24:
+ if ( ++p == pe )
goto _test_eof24;
- st_case_24:
- if ( ( (*( p))) == 108 ) {
- goto st25;
- }
- {
- goto st0;
- }
- st25:
- p+= 1;
- if ( p == pe )
+case 24:
+ if ( (*p) == 108 )
+ goto st25;
+ goto st0;
+st25:
+ if ( ++p == pe )
goto _test_eof25;
- st_case_25:
- if ( ( (*( p))) == 108 ) {
- goto ctr34;
- }
- {
- goto st0;
- }
- st26:
- p+= 1;
- if ( p == pe )
+case 25:
+ if ( (*p) == 108 )
+ goto tr34;
+ goto st0;
+st26:
+ if ( ++p == pe )
goto _test_eof26;
- st_case_26:
- if ( ( (*( p))) == 114 ) {
- goto st27;
- }
- {
- goto st0;
- }
- st27:
- p+= 1;
- if ( p == pe )
+case 26:
+ if ( (*p) == 114 )
+ goto st27;
+ goto st0;
+st27:
+ if ( ++p == pe )
goto _test_eof27;
- st_case_27:
- if ( ( (*( p))) == 117 ) {
- goto st28;
- }
- {
- goto st0;
- }
- st28:
- p+= 1;
- if ( p == pe )
+case 27:
+ if ( (*p) == 117 )
+ goto st28;
+ goto st0;
+st28:
+ if ( ++p == pe )
goto _test_eof28;
- st_case_28:
- if ( ( (*( p))) == 101 ) {
- goto ctr37;
- }
- {
- goto st0;
- }
- st_out:
- _test_eof1: cs = 1; goto _test_eof;
- _test_eof29: cs = 29; goto _test_eof;
- _test_eof2: cs = 2; goto _test_eof;
- _test_eof3: cs = 3; goto _test_eof;
- _test_eof4: cs = 4; goto _test_eof;
- _test_eof5: cs = 5; goto _test_eof;
- _test_eof6: cs = 6; goto _test_eof;
- _test_eof7: cs = 7; goto _test_eof;
- _test_eof8: cs = 8; goto _test_eof;
- _test_eof9: cs = 9; goto _test_eof;
- _test_eof10: cs = 10; goto _test_eof;
- _test_eof11: cs = 11; goto _test_eof;
- _test_eof12: cs = 12; goto _test_eof;
- _test_eof13: cs = 13; goto _test_eof;
- _test_eof14: cs = 14; goto _test_eof;
- _test_eof15: cs = 15; goto _test_eof;
- _test_eof16: cs = 16; goto _test_eof;
- _test_eof17: cs = 17; goto _test_eof;
- _test_eof18: cs = 18; goto _test_eof;
- _test_eof19: cs = 19; goto _test_eof;
- _test_eof20: cs = 20; goto _test_eof;
- _test_eof21: cs = 21; goto _test_eof;
- _test_eof22: cs = 22; goto _test_eof;
- _test_eof23: cs = 23; goto _test_eof;
- _test_eof24: cs = 24; goto _test_eof;
- _test_eof25: cs = 25; goto _test_eof;
- _test_eof26: cs = 26; goto _test_eof;
- _test_eof27: cs = 27; goto _test_eof;
- _test_eof28: cs = 28; goto _test_eof;
-
- _test_eof: {}
- _out: {}
- }
-
- #line 291 "parser.rl"
-
-
- if (json->freeze) {
- OBJ_FREEZE(*result);
- }
-
- if (cs >= JSON_value_first_final) {
- return p;
- } else {
- return NULL;
+case 28:
+ if ( (*p) == 101 )
+ goto tr37;
+ goto st0;
+ }
+ _test_eof1: cs = 1; goto _test_eof;
+ _test_eof29: cs = 29; goto _test_eof;
+ _test_eof2: cs = 2; goto _test_eof;
+ _test_eof3: cs = 3; goto _test_eof;
+ _test_eof4: cs = 4; goto _test_eof;
+ _test_eof5: cs = 5; goto _test_eof;
+ _test_eof6: cs = 6; goto _test_eof;
+ _test_eof7: cs = 7; goto _test_eof;
+ _test_eof8: cs = 8; goto _test_eof;
+ _test_eof9: cs = 9; goto _test_eof;
+ _test_eof10: cs = 10; goto _test_eof;
+ _test_eof11: cs = 11; goto _test_eof;
+ _test_eof12: cs = 12; goto _test_eof;
+ _test_eof13: cs = 13; goto _test_eof;
+ _test_eof14: cs = 14; goto _test_eof;
+ _test_eof15: cs = 15; goto _test_eof;
+ _test_eof16: cs = 16; goto _test_eof;
+ _test_eof17: cs = 17; goto _test_eof;
+ _test_eof18: cs = 18; goto _test_eof;
+ _test_eof19: cs = 19; goto _test_eof;
+ _test_eof20: cs = 20; goto _test_eof;
+ _test_eof21: cs = 21; goto _test_eof;
+ _test_eof22: cs = 22; goto _test_eof;
+ _test_eof23: cs = 23; goto _test_eof;
+ _test_eof24: cs = 24; goto _test_eof;
+ _test_eof25: cs = 25; goto _test_eof;
+ _test_eof26: cs = 26; goto _test_eof;
+ _test_eof27: cs = 27; goto _test_eof;
+ _test_eof28: cs = 28; goto _test_eof;
+
+ _test_eof: {}
+ _out: {}
}
+
+#line 291 "parser.rl"
+
+ if (json->freeze) {
+ OBJ_FREEZE(*result);
+ }
+
+ if (cs >= JSON_value_first_final) {
+ return p;
+ } else {
+ return NULL;
+ }
}
+#line 884 "parser.c"
enum {JSON_integer_start = 1};
enum {JSON_integer_first_final = 3};
enum {JSON_integer_error = 0};
enum {JSON_integer_en_main = 1};
-static const char MAYBE_UNUSED(_JSON_integer_nfa_targs)[] = {
- 0, 0
-};
-
-static const char MAYBE_UNUSED(_JSON_integer_nfa_offsets)[] = {
- 0, 0, 0, 0, 0, 0, 0
-};
-
-static const char MAYBE_UNUSED(_JSON_integer_nfa_push_actions)[] = {
- 0, 0
-};
-
-static const char MAYBE_UNUSED(_JSON_integer_nfa_pop_trans)[] = {
- 0, 0
-};
-
#line 311 "parser.rl"
static char *JSON_parse_integer(JSON_Parser *json, char *p, char *pe, VALUE *result)
{
- int cs = EVIL;
+ int cs = EVIL;
+#line 900 "parser.c"
{
- cs = (int)JSON_integer_start;
+ cs = JSON_integer_start;
}
- #line 318 "parser.rl"
-
- json->memo = p;
+#line 318 "parser.rl"
+ json->memo = p;
+#line 908 "parser.c"
{
- if ( p == pe )
+ if ( p == pe )
goto _test_eof;
- switch ( cs )
- {
- case 1:
- goto st_case_1;
- case 0:
- goto st_case_0;
- case 2:
- goto st_case_2;
- case 3:
- goto st_case_3;
- case 4:
- goto st_case_4;
- case 5:
- goto st_case_5;
- }
- goto st_out;
- st_case_1:
- switch( ( (*( p))) ) {
- case 45: {
- goto st2;
- }
- case 48: {
- goto st3;
- }
- }
- if ( 49 <= ( (*( p))) && ( (*( p))) <= 57 ) {
- goto st5;
- }
- {
- goto st0;
- }
- st_case_0:
- st0:
- cs = 0;
- goto _out;
- st2:
- p+= 1;
- if ( p == pe )
+ switch ( cs )
+ {
+case 1:
+ switch( (*p) ) {
+ case 45: goto st2;
+ case 48: goto st3;
+ }
+ if ( 49 <= (*p) && (*p) <= 57 )
+ goto st5;
+ goto st0;
+st0:
+cs = 0;
+ goto _out;
+st2:
+ if ( ++p == pe )
goto _test_eof2;
- st_case_2:
- if ( ( (*( p))) == 48 ) {
- goto st3;
- }
- if ( 49 <= ( (*( p))) && ( (*( p))) <= 57 ) {
- goto st5;
- }
- {
- goto st0;
- }
- st3:
- p+= 1;
- if ( p == pe )
+case 2:
+ if ( (*p) == 48 )
+ goto st3;
+ if ( 49 <= (*p) && (*p) <= 57 )
+ goto st5;
+ goto st0;
+st3:
+ if ( ++p == pe )
goto _test_eof3;
- st_case_3:
- if ( 48 <= ( (*( p))) && ( (*( p))) <= 57 ) {
- goto st0;
- }
- {
- goto ctr4;
- }
- ctr4:
- {
- #line 308 "parser.rl"
- {p = p - 1; } {p+= 1; cs = 4; goto _out;} }
-
- goto st4;
- st4:
- p+= 1;
- if ( p == pe )
+case 3:
+ if ( 48 <= (*p) && (*p) <= 57 )
+ goto st0;
+ goto tr4;
+tr4:
+#line 308 "parser.rl"
+ { p--; {p++; cs = 4; goto _out;} }
+ goto st4;
+st4:
+ if ( ++p == pe )
goto _test_eof4;
- st_case_4:
- {
- goto st0;
- }
- st5:
- p+= 1;
- if ( p == pe )
+case 4:
+#line 949 "parser.c"
+ goto st0;
+st5:
+ if ( ++p == pe )
goto _test_eof5;
- st_case_5:
- if ( 48 <= ( (*( p))) && ( (*( p))) <= 57 ) {
- goto st5;
- }
- {
- goto ctr4;
- }
- st_out:
- _test_eof2: cs = 2; goto _test_eof;
- _test_eof3: cs = 3; goto _test_eof;
- _test_eof4: cs = 4; goto _test_eof;
- _test_eof5: cs = 5; goto _test_eof;
-
- _test_eof: {}
- _out: {}
- }
-
- #line 320 "parser.rl"
-
-
- if (cs >= JSON_integer_first_final) {
- long len = p - json->memo;
- fbuffer_clear(json->fbuffer);
- fbuffer_append(json->fbuffer, json->memo, len);
- fbuffer_append_char(json->fbuffer, '\0');
- *result = rb_cstr2inum(FBUFFER_PTR(json->fbuffer), 10);
- return p + 1;
- } else {
- return NULL;
+case 5:
+ if ( 48 <= (*p) && (*p) <= 57 )
+ goto st5;
+ goto tr4;
+ }
+ _test_eof2: cs = 2; goto _test_eof;
+ _test_eof3: cs = 3; goto _test_eof;
+ _test_eof4: cs = 4; goto _test_eof;
+ _test_eof5: cs = 5; goto _test_eof;
+
+ _test_eof: {}
+ _out: {}
}
+
+#line 320 "parser.rl"
+
+ if (cs >= JSON_integer_first_final) {
+ long len = p - json->memo;
+ fbuffer_clear(json->fbuffer);
+ fbuffer_append(json->fbuffer, json->memo, len);
+ fbuffer_append_char(json->fbuffer, '\0');
+ *result = rb_cstr2inum(FBUFFER_PTR(json->fbuffer), 10);
+ return p + 1;
+ } else {
+ return NULL;
+ }
}
+#line 983 "parser.c"
enum {JSON_float_start = 1};
enum {JSON_float_first_final = 8};
enum {JSON_float_error = 0};
enum {JSON_float_en_main = 1};
-static const char MAYBE_UNUSED(_JSON_float_nfa_targs)[] = {
- 0, 0
-};
-
-static const char MAYBE_UNUSED(_JSON_float_nfa_offsets)[] = {
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0
-};
-
-static const char MAYBE_UNUSED(_JSON_float_nfa_push_actions)[] = {
- 0, 0
-};
-
-static const char MAYBE_UNUSED(_JSON_float_nfa_pop_trans)[] = {
- 0, 0
-};
-
#line 345 "parser.rl"
static char *JSON_parse_float(JSON_Parser *json, char *p, char *pe, VALUE *result)
{
- int cs = EVIL;
+ int cs = EVIL;
+#line 999 "parser.c"
{
- cs = (int)JSON_float_start;
+ cs = JSON_float_start;
}
- #line 352 "parser.rl"
-
- json->memo = p;
+#line 352 "parser.rl"
+ json->memo = p;
+#line 1007 "parser.c"
{
- if ( p == pe )
+ if ( p == pe )
goto _test_eof;
- switch ( cs )
- {
- case 1:
- goto st_case_1;
- case 0:
- goto st_case_0;
- case 2:
- goto st_case_2;
- case 3:
- goto st_case_3;
- case 4:
- goto st_case_4;
- case 8:
- goto st_case_8;
- case 9:
- goto st_case_9;
- case 5:
- goto st_case_5;
- case 6:
- goto st_case_6;
- case 10:
- goto st_case_10;
- case 7:
- goto st_case_7;
- }
- goto st_out;
- st_case_1:
- switch( ( (*( p))) ) {
- case 45: {
- goto st2;
- }
- case 48: {
- goto st3;
- }
- }
- if ( 49 <= ( (*( p))) && ( (*( p))) <= 57 ) {
- goto st7;
- }
- {
- goto st0;
- }
- st_case_0:
- st0:
- cs = 0;
- goto _out;
- st2:
- p+= 1;
- if ( p == pe )
+ switch ( cs )
+ {
+case 1:
+ switch( (*p) ) {
+ case 45: goto st2;
+ case 48: goto st3;
+ }
+ if ( 49 <= (*p) && (*p) <= 57 )
+ goto st7;
+ goto st0;
+st0:
+cs = 0;
+ goto _out;
+st2:
+ if ( ++p == pe )
goto _test_eof2;
- st_case_2:
- if ( ( (*( p))) == 48 ) {
- goto st3;
- }
- if ( 49 <= ( (*( p))) && ( (*( p))) <= 57 ) {
- goto st7;
- }
- {
- goto st0;
- }
- st3:
- p+= 1;
- if ( p == pe )
+case 2:
+ if ( (*p) == 48 )
+ goto st3;
+ if ( 49 <= (*p) && (*p) <= 57 )
+ goto st7;
+ goto st0;
+st3:
+ if ( ++p == pe )
goto _test_eof3;
- st_case_3:
- switch( ( (*( p))) ) {
- case 46: {
- goto st4;
- }
- case 69: {
- goto st5;
- }
- case 101: {
- goto st5;
- }
- }
- {
- goto st0;
- }
- st4:
- p+= 1;
- if ( p == pe )
+case 3:
+ switch( (*p) ) {
+ case 46: goto st4;
+ case 69: goto st5;
+ case 101: goto st5;
+ }
+ goto st0;
+st4:
+ if ( ++p == pe )
goto _test_eof4;
- st_case_4:
- if ( 48 <= ( (*( p))) && ( (*( p))) <= 57 ) {
- goto st8;
- }
- {
- goto st0;
- }
- st8:
- p+= 1;
- if ( p == pe )
+case 4:
+ if ( 48 <= (*p) && (*p) <= 57 )
+ goto st8;
+ goto st0;
+st8:
+ if ( ++p == pe )
goto _test_eof8;
- st_case_8:
- switch( ( (*( p))) ) {
- case 69: {
- goto st5;
- }
- case 101: {
- goto st5;
- }
- }
- if ( ( (*( p))) > 46 ) {
- if ( 48 <= ( (*( p))) && ( (*( p))) <= 57 ) {
- goto st8;
- }
- } else if ( ( (*( p))) >= 45 ) {
- goto st0;
- }
- {
- goto ctr9;
- }
- ctr9:
- {
- #line 339 "parser.rl"
- {p = p - 1; } {p+= 1; cs = 9; goto _out;} }
-
- goto st9;
- st9:
- p+= 1;
- if ( p == pe )
+case 8:
+ switch( (*p) ) {
+ case 69: goto st5;
+ case 101: goto st5;
+ }
+ if ( (*p) > 46 ) {
+ if ( 48 <= (*p) && (*p) <= 57 )
+ goto st8;
+ } else if ( (*p) >= 45 )
+ goto st0;
+ goto tr9;
+tr9:
+#line 339 "parser.rl"
+ { p--; {p++; cs = 9; goto _out;} }
+ goto st9;
+st9:
+ if ( ++p == pe )
goto _test_eof9;
- st_case_9:
- {
- goto st0;
- }
- st5:
- p+= 1;
- if ( p == pe )
+case 9:
+#line 1072 "parser.c"
+ goto st0;
+st5:
+ if ( ++p == pe )
goto _test_eof5;
- st_case_5:
- switch( ( (*( p))) ) {
- case 43: {
- goto st6;
- }
- case 45: {
- goto st6;
- }
- }
- if ( 48 <= ( (*( p))) && ( (*( p))) <= 57 ) {
- goto st10;
- }
- {
- goto st0;
- }
- st6:
- p+= 1;
- if ( p == pe )
+case 5:
+ switch( (*p) ) {
+ case 43: goto st6;
+ case 45: goto st6;
+ }
+ if ( 48 <= (*p) && (*p) <= 57 )
+ goto st10;
+ goto st0;
+st6:
+ if ( ++p == pe )
goto _test_eof6;
- st_case_6:
- if ( 48 <= ( (*( p))) && ( (*( p))) <= 57 ) {
- goto st10;
- }
- {
- goto st0;
- }
- st10:
- p+= 1;
- if ( p == pe )
+case 6:
+ if ( 48 <= (*p) && (*p) <= 57 )
+ goto st10;
+ goto st0;
+st10:
+ if ( ++p == pe )
goto _test_eof10;
- st_case_10:
- switch( ( (*( p))) ) {
- case 69: {
- goto st0;
- }
- case 101: {
- goto st0;
- }
- }
- if ( ( (*( p))) > 46 ) {
- if ( 48 <= ( (*( p))) && ( (*( p))) <= 57 ) {
- goto st10;
- }
- } else if ( ( (*( p))) >= 45 ) {
- goto st0;
- }
- {
- goto ctr9;
- }
- st7:
- p+= 1;
- if ( p == pe )
+case 10:
+ switch( (*p) ) {
+ case 69: goto st0;
+ case 101: goto st0;
+ }
+ if ( (*p) > 46 ) {
+ if ( 48 <= (*p) && (*p) <= 57 )
+ goto st10;
+ } else if ( (*p) >= 45 )
+ goto st0;
+ goto tr9;
+st7:
+ if ( ++p == pe )
goto _test_eof7;
- st_case_7:
- switch( ( (*( p))) ) {
- case 46: {
- goto st4;
- }
- case 69: {
- goto st5;
- }
- case 101: {
- goto st5;
- }
- }
- if ( 48 <= ( (*( p))) && ( (*( p))) <= 57 ) {
- goto st7;
- }
- {
- goto st0;
- }
- st_out:
- _test_eof2: cs = 2; goto _test_eof;
- _test_eof3: cs = 3; goto _test_eof;
- _test_eof4: cs = 4; goto _test_eof;
- _test_eof8: cs = 8; goto _test_eof;
- _test_eof9: cs = 9; goto _test_eof;
- _test_eof5: cs = 5; goto _test_eof;
- _test_eof6: cs = 6; goto _test_eof;
- _test_eof10: cs = 10; goto _test_eof;
- _test_eof7: cs = 7; goto _test_eof;
-
- _test_eof: {}
- _out: {}
- }
-
- #line 354 "parser.rl"
-
-
- if (cs >= JSON_float_first_final) {
- VALUE mod = Qnil;
- ID method_id = 0;
- if (rb_respond_to(json->decimal_class, i_try_convert)) {
- mod = json->decimal_class;
- method_id = i_try_convert;
- } else if (rb_respond_to(json->decimal_class, i_new)) {
- mod = json->decimal_class;
- method_id = i_new;
- } else if (RB_TYPE_P(json->decimal_class, T_CLASS)) {
- VALUE name = rb_class_name(json->decimal_class);
- const char *name_cstr = RSTRING_PTR(name);
- const char *last_colon = strrchr(name_cstr, ':');
- if (last_colon) {
- const char *mod_path_end = last_colon - 1;
- VALUE mod_path = rb_str_substr(name, 0, mod_path_end - name_cstr);
- mod = rb_path_to_class(mod_path);
-
- const char *method_name_beg = last_colon + 1;
- long before_len = method_name_beg - name_cstr;
- long len = RSTRING_LEN(name) - before_len;
- VALUE method_name = rb_str_substr(name, before_len, len);
- method_id = SYM2ID(rb_str_intern(method_name));
- } else {
- mod = rb_mKernel;
- method_id = SYM2ID(rb_str_intern(name));
- }
- }
-
- long len = p - json->memo;
- fbuffer_clear(json->fbuffer);
- fbuffer_append(json->fbuffer, json->memo, len);
- fbuffer_append_char(json->fbuffer, '\0');
-
- if (method_id) {
- VALUE text = rb_str_new2(FBUFFER_PTR(json->fbuffer));
- *result = rb_funcallv(mod, method_id, 1, &text);
- } else {
- *result = DBL2NUM(rb_cstr_to_dbl(FBUFFER_PTR(json->fbuffer), 1));
- }
-
- return p + 1;
- } else {
- return NULL;
+case 7:
+ switch( (*p) ) {
+ case 46: goto st4;
+ case 69: goto st5;
+ case 101: goto st5;
+ }
+ if ( 48 <= (*p) && (*p) <= 57 )
+ goto st7;
+ goto st0;
+ }
+ _test_eof2: cs = 2; goto _test_eof;
+ _test_eof3: cs = 3; goto _test_eof;
+ _test_eof4: cs = 4; goto _test_eof;
+ _test_eof8: cs = 8; goto _test_eof;
+ _test_eof9: cs = 9; goto _test_eof;
+ _test_eof5: cs = 5; goto _test_eof;
+ _test_eof6: cs = 6; goto _test_eof;
+ _test_eof10: cs = 10; goto _test_eof;
+ _test_eof7: cs = 7; goto _test_eof;
+
+ _test_eof: {}
+ _out: {}
}
+
+#line 354 "parser.rl"
+
+ if (cs >= JSON_float_first_final) {
+ VALUE mod = Qnil;
+ ID method_id = 0;
+ if (rb_respond_to(json->decimal_class, i_try_convert)) {
+ mod = json->decimal_class;
+ method_id = i_try_convert;
+ } else if (rb_respond_to(json->decimal_class, i_new)) {
+ mod = json->decimal_class;
+ method_id = i_new;
+ } else if (RB_TYPE_P(json->decimal_class, T_CLASS)) {
+ VALUE name = rb_class_name(json->decimal_class);
+ const char *name_cstr = RSTRING_PTR(name);
+ const char *last_colon = strrchr(name_cstr, ':');
+ if (last_colon) {
+ const char *mod_path_end = last_colon - 1;
+ VALUE mod_path = rb_str_substr(name, 0, mod_path_end - name_cstr);
+ mod = rb_path_to_class(mod_path);
+
+ const char *method_name_beg = last_colon + 1;
+ long before_len = method_name_beg - name_cstr;
+ long len = RSTRING_LEN(name) - before_len;
+ VALUE method_name = rb_str_substr(name, before_len, len);
+ method_id = SYM2ID(rb_str_intern(method_name));
+ } else {
+ mod = rb_mKernel;
+ method_id = SYM2ID(rb_str_intern(name));
+ }
+ }
+
+ long len = p - json->memo;
+ fbuffer_clear(json->fbuffer);
+ fbuffer_append(json->fbuffer, json->memo, len);
+ fbuffer_append_char(json->fbuffer, '\0');
+
+ if (method_id) {
+ VALUE text = rb_str_new2(FBUFFER_PTR(json->fbuffer));
+ *result = rb_funcallv(mod, method_id, 1, &text);
+ } else {
+ *result = DBL2NUM(rb_cstr_to_dbl(FBUFFER_PTR(json->fbuffer), 1));
+ }
+
+ return p + 1;
+ } else {
+ return NULL;
+ }
}
+#line 1184 "parser.c"
enum {JSON_array_start = 1};
enum {JSON_array_first_final = 17};
enum {JSON_array_error = 0};
enum {JSON_array_en_main = 1};
-static const char MAYBE_UNUSED(_JSON_array_nfa_targs)[] = {
- 0, 0
-};
-
-static const char MAYBE_UNUSED(_JSON_array_nfa_offsets)[] = {
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0
-};
-
-static const char MAYBE_UNUSED(_JSON_array_nfa_push_actions)[] = {
- 0, 0
-};
-
-static const char MAYBE_UNUSED(_JSON_array_nfa_pop_trans)[] = {
- 0, 0
-};
-
#line 432 "parser.rl"
static char *JSON_parse_array(JSON_Parser *json, char *p, char *pe, VALUE *result, int current_nesting)
{
- int cs = EVIL;
- VALUE array_class = json->array_class;
+ int cs = EVIL;
+ VALUE array_class = json->array_class;
- if (json->max_nesting && current_nesting > json->max_nesting) {
- rb_raise(eNestingError, "nesting of %d is too deep", current_nesting);
- }
- *result = NIL_P(array_class) ? rb_ary_new() : rb_class_new_instance(0, 0, array_class);
+ if (json->max_nesting && current_nesting > json->max_nesting) {
+ rb_raise(eNestingError, "nesting of %d is too deep", current_nesting);
+ }
+ *result = NIL_P(array_class) ? rb_ary_new() : rb_class_new_instance(0, 0, array_class);
+#line 1206 "parser.c"
{
- cs = (int)JSON_array_start;
+ cs = JSON_array_start;
}
- #line 445 "parser.rl"
-
+#line 445 "parser.rl"
+#line 1213 "parser.c"
{
- if ( p == pe )
+ if ( p == pe )
goto _test_eof;
- switch ( cs )
- {
- case 1:
- goto st_case_1;
- case 0:
- goto st_case_0;
- case 2:
- goto st_case_2;
- case 3:
- goto st_case_3;
- case 4:
- goto st_case_4;
- case 5:
- goto st_case_5;
- case 6:
- goto st_case_6;
- case 7:
- goto st_case_7;
- case 8:
- goto st_case_8;
- case 9:
- goto st_case_9;
- case 10:
- goto st_case_10;
- case 11:
- goto st_case_11;
- case 12:
- goto st_case_12;
- case 17:
- goto st_case_17;
- case 13:
- goto st_case_13;
- case 14:
- goto st_case_14;
- case 15:
- goto st_case_15;
- case 16:
- goto st_case_16;
- }
- goto st_out;
- st_case_1:
- if ( ( (*( p))) == 91 ) {
- goto st2;
- }
- {
- goto st0;
- }
- st_case_0:
- st0:
- cs = 0;
- goto _out;
- st2:
- p+= 1;
- if ( p == pe )
+ switch ( cs )
+ {
+case 1:
+ if ( (*p) == 91 )
+ goto st2;
+ goto st0;
+st0:
+cs = 0;
+ goto _out;
+st2:
+ if ( ++p == pe )
goto _test_eof2;
- st_case_2:
- switch( ( (*( p))) ) {
- case 13: {
- goto st2;
- }
- case 32: {
- goto st2;
- }
- case 34: {
- goto ctr2;
- }
- case 45: {
- goto ctr2;
- }
- case 47: {
- goto st13;
- }
- case 73: {
- goto ctr2;
- }
- case 78: {
- goto ctr2;
- }
- case 91: {
- goto ctr2;
- }
- case 93: {
- goto ctr4;
- }
- case 102: {
- goto ctr2;
- }
- case 110: {
- goto ctr2;
- }
- case 116: {
- goto ctr2;
- }
- case 123: {
- goto ctr2;
- }
- }
- if ( ( (*( p))) > 10 ) {
- if ( 48 <= ( (*( p))) && ( (*( p))) <= 57 ) {
- goto ctr2;
- }
- } else if ( ( (*( p))) >= 9 ) {
- goto st2;
- }
- {
- goto st0;
- }
- ctr2:
- {
- #line 409 "parser.rl"
-
- VALUE v = Qnil;
- char *np = JSON_parse_value(json, p, pe, &v, current_nesting);
- if (np == NULL) {
- {p = p - 1; } {p+= 1; cs = 3; goto _out;}
- } else {
- if (NIL_P(json->array_class)) {
- rb_ary_push(*result, v);
- } else {
- rb_funcall(*result, i_leftshift, 1, v);
- }
- {p = (( np))-1;}
-
- }
- }
-
- goto st3;
- st3:
- p+= 1;
- if ( p == pe )
+case 2:
+ switch( (*p) ) {
+ case 13: goto st2;
+ case 32: goto st2;
+ case 34: goto tr2;
+ case 45: goto tr2;
+ case 47: goto st13;
+ case 73: goto tr2;
+ case 78: goto tr2;
+ case 91: goto tr2;
+ case 93: goto tr4;
+ case 102: goto tr2;
+ case 110: goto tr2;
+ case 116: goto tr2;
+ case 123: goto tr2;
+ }
+ if ( (*p) > 10 ) {
+ if ( 48 <= (*p) && (*p) <= 57 )
+ goto tr2;
+ } else if ( (*p) >= 9 )
+ goto st2;
+ goto st0;
+tr2:
+#line 409 "parser.rl"
+ {
+ VALUE v = Qnil;
+ char *np = JSON_parse_value(json, p, pe, &v, current_nesting);
+ if (np == NULL) {
+ p--; {p++; cs = 3; goto _out;}
+ } else {
+ if (NIL_P(json->array_class)) {
+ rb_ary_push(*result, v);
+ } else {
+ rb_funcall(*result, i_leftshift, 1, v);
+ }
+ {p = (( np))-1;}
+ }
+ }
+ goto st3;
+st3:
+ if ( ++p == pe )
goto _test_eof3;
- st_case_3:
- switch( ( (*( p))) ) {
- case 13: {
- goto st3;
- }
- case 32: {
- goto st3;
- }
- case 44: {
- goto st4;
- }
- case 47: {
- goto st9;
- }
- case 93: {
- goto ctr4;
- }
- }
- if ( 9 <= ( (*( p))) && ( (*( p))) <= 10 ) {
- goto st3;
- }
- {
- goto st0;
- }
- st4:
- p+= 1;
- if ( p == pe )
+case 3:
+#line 1272 "parser.c"
+ switch( (*p) ) {
+ case 13: goto st3;
+ case 32: goto st3;
+ case 44: goto st4;
+ case 47: goto st9;
+ case 93: goto tr4;
+ }
+ if ( 9 <= (*p) && (*p) <= 10 )
+ goto st3;
+ goto st0;
+st4:
+ if ( ++p == pe )
goto _test_eof4;
- st_case_4:
- switch( ( (*( p))) ) {
- case 13: {
- goto st4;
- }
- case 32: {
- goto st4;
- }
- case 34: {
- goto ctr2;
- }
- case 45: {
- goto ctr2;
- }
- case 47: {
- goto st5;
- }
- case 73: {
- goto ctr2;
- }
- case 78: {
- goto ctr2;
- }
- case 91: {
- goto ctr2;
- }
- case 102: {
- goto ctr2;
- }
- case 110: {
- goto ctr2;
- }
- case 116: {
- goto ctr2;
- }
- case 123: {
- goto ctr2;
- }
- }
- if ( ( (*( p))) > 10 ) {
- if ( 48 <= ( (*( p))) && ( (*( p))) <= 57 ) {
- goto ctr2;
- }
- } else if ( ( (*( p))) >= 9 ) {
- goto st4;
- }
- {
- goto st0;
- }
- st5:
- p+= 1;
- if ( p == pe )
+case 4:
+ switch( (*p) ) {
+ case 13: goto st4;
+ case 32: goto st4;
+ case 34: goto tr2;
+ case 45: goto tr2;
+ case 47: goto st5;
+ case 73: goto tr2;
+ case 78: goto tr2;
+ case 91: goto tr2;
+ case 102: goto tr2;
+ case 110: goto tr2;
+ case 116: goto tr2;
+ case 123: goto tr2;
+ }
+ if ( (*p) > 10 ) {
+ if ( 48 <= (*p) && (*p) <= 57 )
+ goto tr2;
+ } else if ( (*p) >= 9 )
+ goto st4;
+ goto st0;
+st5:
+ if ( ++p == pe )
goto _test_eof5;
- st_case_5:
- switch( ( (*( p))) ) {
- case 42: {
- goto st6;
- }
- case 47: {
- goto st8;
- }
- }
- {
- goto st0;
- }
- st6:
- p+= 1;
- if ( p == pe )
+case 5:
+ switch( (*p) ) {
+ case 42: goto st6;
+ case 47: goto st8;
+ }
+ goto st0;
+st6:
+ if ( ++p == pe )
goto _test_eof6;
- st_case_6:
- if ( ( (*( p))) == 42 ) {
- goto st7;
- }
- {
- goto st6;
- }
- st7:
- p+= 1;
- if ( p == pe )
+case 6:
+ if ( (*p) == 42 )
+ goto st7;
+ goto st6;
+st7:
+ if ( ++p == pe )
goto _test_eof7;
- st_case_7:
- switch( ( (*( p))) ) {
- case 42: {
- goto st7;
- }
- case 47: {
- goto st4;
- }
- }
- {
- goto st6;
- }
- st8:
- p+= 1;
- if ( p == pe )
+case 7:
+ switch( (*p) ) {
+ case 42: goto st7;
+ case 47: goto st4;
+ }
+ goto st6;
+st8:
+ if ( ++p == pe )
goto _test_eof8;
- st_case_8:
- if ( ( (*( p))) == 10 ) {
- goto st4;
- }
- {
- goto st8;
- }
- st9:
- p+= 1;
- if ( p == pe )
+case 8:
+ if ( (*p) == 10 )
+ goto st4;
+ goto st8;
+st9:
+ if ( ++p == pe )
goto _test_eof9;
- st_case_9:
- switch( ( (*( p))) ) {
- case 42: {
- goto st10;
- }
- case 47: {
- goto st12;
- }
- }
- {
- goto st0;
- }
- st10:
- p+= 1;
- if ( p == pe )
+case 9:
+ switch( (*p) ) {
+ case 42: goto st10;
+ case 47: goto st12;
+ }
+ goto st0;
+st10:
+ if ( ++p == pe )
goto _test_eof10;
- st_case_10:
- if ( ( (*( p))) == 42 ) {
- goto st11;
- }
- {
- goto st10;
- }
- st11:
- p+= 1;
- if ( p == pe )
+case 10:
+ if ( (*p) == 42 )
+ goto st11;
+ goto st10;
+st11:
+ if ( ++p == pe )
goto _test_eof11;
- st_case_11:
- switch( ( (*( p))) ) {
- case 42: {
- goto st11;
- }
- case 47: {
- goto st3;
- }
- }
- {
- goto st10;
- }
- st12:
- p+= 1;
- if ( p == pe )
+case 11:
+ switch( (*p) ) {
+ case 42: goto st11;
+ case 47: goto st3;
+ }
+ goto st10;
+st12:
+ if ( ++p == pe )
goto _test_eof12;
- st_case_12:
- if ( ( (*( p))) == 10 ) {
- goto st3;
- }
- {
- goto st12;
- }
- ctr4:
- {
- #line 424 "parser.rl"
- {p = p - 1; } {p+= 1; cs = 17; goto _out;} }
-
- goto st17;
- st17:
- p+= 1;
- if ( p == pe )
+case 12:
+ if ( (*p) == 10 )
+ goto st3;
+ goto st12;
+tr4:
+#line 424 "parser.rl"
+ { p--; {p++; cs = 17; goto _out;} }
+ goto st17;
+st17:
+ if ( ++p == pe )
goto _test_eof17;
- st_case_17:
- {
- goto st0;
- }
- st13:
- p+= 1;
- if ( p == pe )
+case 17:
+#line 1379 "parser.c"
+ goto st0;
+st13:
+ if ( ++p == pe )
goto _test_eof13;
- st_case_13:
- switch( ( (*( p))) ) {
- case 42: {
- goto st14;
- }
- case 47: {
- goto st16;
- }
- }
- {
- goto st0;
- }
- st14:
- p+= 1;
- if ( p == pe )
+case 13:
+ switch( (*p) ) {
+ case 42: goto st14;
+ case 47: goto st16;
+ }
+ goto st0;
+st14:
+ if ( ++p == pe )
goto _test_eof14;
- st_case_14:
- if ( ( (*( p))) == 42 ) {
- goto st15;
- }
- {
- goto st14;
- }
- st15:
- p+= 1;
- if ( p == pe )
+case 14:
+ if ( (*p) == 42 )
+ goto st15;
+ goto st14;
+st15:
+ if ( ++p == pe )
goto _test_eof15;
- st_case_15:
- switch( ( (*( p))) ) {
- case 42: {
- goto st15;
- }
- case 47: {
- goto st2;
- }
- }
- {
- goto st14;
- }
- st16:
- p+= 1;
- if ( p == pe )
+case 15:
+ switch( (*p) ) {
+ case 42: goto st15;
+ case 47: goto st2;
+ }
+ goto st14;
+st16:
+ if ( ++p == pe )
goto _test_eof16;
- st_case_16:
- if ( ( (*( p))) == 10 ) {
- goto st2;
- }
- {
- goto st16;
- }
- st_out:
- _test_eof2: cs = 2; goto _test_eof;
- _test_eof3: cs = 3; goto _test_eof;
- _test_eof4: cs = 4; goto _test_eof;
- _test_eof5: cs = 5; goto _test_eof;
- _test_eof6: cs = 6; goto _test_eof;
- _test_eof7: cs = 7; goto _test_eof;
- _test_eof8: cs = 8; goto _test_eof;
- _test_eof9: cs = 9; goto _test_eof;
- _test_eof10: cs = 10; goto _test_eof;
- _test_eof11: cs = 11; goto _test_eof;
- _test_eof12: cs = 12; goto _test_eof;
- _test_eof17: cs = 17; goto _test_eof;
- _test_eof13: cs = 13; goto _test_eof;
- _test_eof14: cs = 14; goto _test_eof;
- _test_eof15: cs = 15; goto _test_eof;
- _test_eof16: cs = 16; goto _test_eof;
-
- _test_eof: {}
- _out: {}
- }
-
- #line 446 "parser.rl"
-
-
- if(cs >= JSON_array_first_final) {
- return p + 1;
- } else {
- rb_enc_raise(EXC_ENCODING eParserError, "unexpected token at '%s'", p);
- return NULL;
+case 16:
+ if ( (*p) == 10 )
+ goto st2;
+ goto st16;
}
+ _test_eof2: cs = 2; goto _test_eof;
+ _test_eof3: cs = 3; goto _test_eof;
+ _test_eof4: cs = 4; goto _test_eof;
+ _test_eof5: cs = 5; goto _test_eof;
+ _test_eof6: cs = 6; goto _test_eof;
+ _test_eof7: cs = 7; goto _test_eof;
+ _test_eof8: cs = 8; goto _test_eof;
+ _test_eof9: cs = 9; goto _test_eof;
+ _test_eof10: cs = 10; goto _test_eof;
+ _test_eof11: cs = 11; goto _test_eof;
+ _test_eof12: cs = 12; goto _test_eof;
+ _test_eof17: cs = 17; goto _test_eof;
+ _test_eof13: cs = 13; goto _test_eof;
+ _test_eof14: cs = 14; goto _test_eof;
+ _test_eof15: cs = 15; goto _test_eof;
+ _test_eof16: cs = 16; goto _test_eof;
+
+ _test_eof: {}
+ _out: {}
+ }
+
+#line 446 "parser.rl"
+
+ if(cs >= JSON_array_first_final) {
+ return p + 1;
+ } else {
+ rb_enc_raise(EXC_ENCODING eParserError, "unexpected token at '%s'", p);
+ return NULL;
+ }
}
static const size_t MAX_STACK_BUFFER_SIZE = 128;
static VALUE json_string_unescape(char *string, char *stringEnd, int intern, int symbolize)
{
- VALUE result = Qnil;
- size_t bufferSize = stringEnd - string;
- char *p = string, *pe = string, *unescape, *bufferStart, *buffer;
- int unescape_len;
- char buf[4];
+ VALUE result = Qnil;
+ size_t bufferSize = stringEnd - string;
+ char *p = string, *pe = string, *unescape, *bufferStart, *buffer;
+ int unescape_len;
+ char buf[4];
- if (bufferSize > MAX_STACK_BUFFER_SIZE) {
+ if (bufferSize > MAX_STACK_BUFFER_SIZE) {
# ifdef HAVE_RB_ENC_INTERNED_STR
- bufferStart = buffer = ALLOC_N(char, bufferSize ? bufferSize : 1);
+ bufferStart = buffer = ALLOC_N(char, bufferSize ? bufferSize : 1);
# else
- bufferStart = buffer = ALLOC_N(char, bufferSize);
+ bufferStart = buffer = ALLOC_N(char, bufferSize);
# endif
- } else {
+ } else {
# ifdef HAVE_RB_ENC_INTERNED_STR
- bufferStart = buffer = ALLOCA_N(char, bufferSize ? bufferSize : 1);
+ bufferStart = buffer = ALLOCA_N(char, bufferSize ? bufferSize : 1);
# else
- bufferStart = buffer = ALLOCA_N(char, bufferSize);
+ bufferStart = buffer = ALLOCA_N(char, bufferSize);
# endif
- }
-
- while (pe < stringEnd) {
- if (*pe == '\\') {
- unescape = (char *) "?";
- unescape_len = 1;
- if (pe > p) {
- MEMCPY(buffer, p, char, pe - p);
- buffer += pe - p;
- }
- switch (*++pe) {
- case 'n':
- unescape = (char *) "\n";
- break;
- case 'r':
- unescape = (char *) "\r";
- break;
- case 't':
- unescape = (char *) "\t";
- break;
- case '"':
- unescape = (char *) "\"";
- break;
- case '\\':
- unescape = (char *) "\\";
- break;
- case 'b':
- unescape = (char *) "\b";
- break;
- case 'f':
- unescape = (char *) "\f";
- break;
- case 'u':
- if (pe > stringEnd - 4) {
- if (bufferSize > MAX_STACK_BUFFER_SIZE) {
- free(bufferStart);
- }
- rb_enc_raise(
- EXC_ENCODING eParserError,
- "incomplete unicode character escape sequence at '%s'", p
- );
- } else {
- UTF32 ch = unescape_unicode((unsigned char *) ++pe);
- pe += 3;
- if (UNI_SUR_HIGH_START == (ch & 0xFC00)) {
- pe++;
- if (pe > stringEnd - 6) {
- if (bufferSize > MAX_STACK_BUFFER_SIZE) {
- free(bufferStart);
- }
- rb_enc_raise(
- EXC_ENCODING eParserError,
- "incomplete surrogate pair at '%s'", p
- );
- }
- if (pe[0] == '\\' && pe[1] == 'u') {
- UTF32 sur = unescape_unicode((unsigned char *) pe + 2);
- ch = (((ch & 0x3F) << 10) | ((((ch >> 6) & 0xF) + 1) << 16)
- | (sur & 0x3FF));
- pe += 5;
- } else {
- unescape = (char *) "?";
- break;
- }
- }
- unescape_len = convert_UTF32_to_UTF8(buf, ch);
- unescape = buf;
- }
- break;
- default:
- p = pe;
- continue;
- }
- MEMCPY(buffer, unescape, char, unescape_len);
- buffer += unescape_len;
- p = ++pe;
- } else {
- pe++;
- }
- }
-
- if (pe > p) {
- MEMCPY(buffer, p, char, pe - p);
- buffer += pe - p;
- }
-
- # ifdef HAVE_RB_ENC_INTERNED_STR
- if (intern) {
- result = rb_enc_interned_str(bufferStart, (long)(buffer - bufferStart), rb_utf8_encoding());
- } else {
- result = rb_utf8_str_new(bufferStart, (long)(buffer - bufferStart));
- }
- if (bufferSize > MAX_STACK_BUFFER_SIZE) {
- free(bufferStart);
- }
- # else
- result = rb_utf8_str_new(bufferStart, (long)(buffer - bufferStart));
+ }
+
+ while (pe < stringEnd) {
+ if (*pe == '\\') {
+ unescape = (char *) "?";
+ unescape_len = 1;
+ if (pe > p) {
+ MEMCPY(buffer, p, char, pe - p);
+ buffer += pe - p;
+ }
+ switch (*++pe) {
+ case 'n':
+ unescape = (char *) "\n";
+ break;
+ case 'r':
+ unescape = (char *) "\r";
+ break;
+ case 't':
+ unescape = (char *) "\t";
+ break;
+ case '"':
+ unescape = (char *) "\"";
+ break;
+ case '\\':
+ unescape = (char *) "\\";
+ break;
+ case 'b':
+ unescape = (char *) "\b";
+ break;
+ case 'f':
+ unescape = (char *) "\f";
+ break;
+ case 'u':
+ if (pe > stringEnd - 4) {
+ if (bufferSize > MAX_STACK_BUFFER_SIZE) {
+ ruby_xfree(bufferStart);
+ }
+ rb_enc_raise(
+ EXC_ENCODING eParserError,
+ "incomplete unicode character escape sequence at '%s'", p
+ );
+ } else {
+ UTF32 ch = unescape_unicode((unsigned char *) ++pe);
+ pe += 3;
+ if (UNI_SUR_HIGH_START == (ch & 0xFC00)) {
+ pe++;
+ if (pe > stringEnd - 6) {
+ if (bufferSize > MAX_STACK_BUFFER_SIZE) {
+ ruby_xfree(bufferStart);
+ }
+ rb_enc_raise(
+ EXC_ENCODING eParserError,
+ "incomplete surrogate pair at '%s'", p
+ );
+ }
+ if (pe[0] == '\\' && pe[1] == 'u') {
+ UTF32 sur = unescape_unicode((unsigned char *) pe + 2);
+ ch = (((ch & 0x3F) << 10) | ((((ch >> 6) & 0xF) + 1) << 16)
+ | (sur & 0x3FF));
+ pe += 5;
+ } else {
+ unescape = (char *) "?";
+ break;
+ }
+ }
+ unescape_len = convert_UTF32_to_UTF8(buf, ch);
+ unescape = buf;
+ }
+ break;
+ default:
+ p = pe;
+ continue;
+ }
+ MEMCPY(buffer, unescape, char, unescape_len);
+ buffer += unescape_len;
+ p = ++pe;
+ } else {
+ pe++;
+ }
+ }
+
+ if (pe > p) {
+ MEMCPY(buffer, p, char, pe - p);
+ buffer += pe - p;
+ }
- if (bufferSize > MAX_STACK_BUFFER_SIZE) {
- free(bufferStart);
- }
-
- if (intern) {
- # if STR_UMINUS_DEDUPE_FROZEN
- // Starting from MRI 2.8 it is preferable to freeze the string
- // before deduplication so that it can be interned directly
- // otherwise it would be duplicated first which is wasteful.
- result = rb_funcall(rb_str_freeze(result), i_uminus, 0);
- # elif STR_UMINUS_DEDUPE
- // MRI 2.5 and older do not deduplicate strings that are already
- // frozen.
- result = rb_funcall(result, i_uminus, 0);
- # else
- result = rb_str_freeze(result);
- # endif
- }
- # endif
+# ifdef HAVE_RB_ENC_INTERNED_STR
+ if (intern) {
+ result = rb_enc_interned_str(bufferStart, (long)(buffer - bufferStart), rb_utf8_encoding());
+ } else {
+ result = rb_utf8_str_new(bufferStart, (long)(buffer - bufferStart));
+ }
+ if (bufferSize > MAX_STACK_BUFFER_SIZE) {
+ ruby_xfree(bufferStart);
+ }
+# else
+ result = rb_utf8_str_new(bufferStart, (long)(buffer - bufferStart));
+
+ if (bufferSize > MAX_STACK_BUFFER_SIZE) {
+ ruby_xfree(bufferStart);
+ }
+
+ if (intern) {
+ # if STR_UMINUS_DEDUPE_FROZEN
+ // Starting from MRI 2.8 it is preferable to freeze the string
+ // before deduplication so that it can be interned directly
+ // otherwise it would be duplicated first which is wasteful.
+ result = rb_funcall(rb_str_freeze(result), i_uminus, 0);
+ # elif STR_UMINUS_DEDUPE
+ // MRI 2.5 and older do not deduplicate strings that are already
+ // frozen.
+ result = rb_funcall(result, i_uminus, 0);
+ # else
+ result = rb_str_freeze(result);
+ # endif
+ }
+# endif
- if (symbolize) {
- result = rb_str_intern(result);
- }
+ if (symbolize) {
+ result = rb_str_intern(result);
+ }
- return result;
+ return result;
}
+#line 1592 "parser.c"
enum {JSON_string_start = 1};
enum {JSON_string_first_final = 8};
enum {JSON_string_error = 0};
enum {JSON_string_en_main = 1};
-static const char MAYBE_UNUSED(_JSON_string_nfa_targs)[] = {
- 0, 0
-};
-
-static const char MAYBE_UNUSED(_JSON_string_nfa_offsets)[] = {
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0
-};
-static const char MAYBE_UNUSED(_JSON_string_nfa_push_actions)[] = {
- 0, 0
-};
-
-static const char MAYBE_UNUSED(_JSON_string_nfa_pop_trans)[] = {
- 0, 0
-};
-
-
-#line 612 "parser.rl"
+#line 620 "parser.rl"
static int
match_i(VALUE regexp, VALUE klass, VALUE memo)
{
- if (regexp == Qundef) return ST_STOP;
- if (RTEST(rb_funcall(klass, i_json_creatable_p, 0)) &&
- RTEST(rb_funcall(regexp, i_match, 1, rb_ary_entry(memo, 0)))) {
- rb_ary_push(memo, klass);
- return ST_STOP;
- }
- return ST_CONTINUE;
+ if (regexp == Qundef) return ST_STOP;
+ if (RTEST(rb_funcall(klass, i_json_creatable_p, 0)) &&
+ RTEST(rb_funcall(regexp, i_match, 1, rb_ary_entry(memo, 0)))) {
+ rb_ary_push(memo, klass);
+ return ST_STOP;
+ }
+ return ST_CONTINUE;
}
static char *JSON_parse_string(JSON_Parser *json, char *p, char *pe, VALUE *result)
{
- int cs = EVIL;
- VALUE match_string;
+ int cs = EVIL;
+ VALUE match_string;
+#line 1621 "parser.c"
{
- cs = (int)JSON_string_start;
+ cs = JSON_string_start;
}
- #line 632 "parser.rl"
-
- json->memo = p;
+#line 640 "parser.rl"
+ json->memo = p;
+#line 1629 "parser.c"
{
- if ( p == pe )
+ if ( p == pe )
goto _test_eof;
- switch ( cs )
- {
- case 1:
- goto st_case_1;
- case 0:
- goto st_case_0;
- case 2:
- goto st_case_2;
- case 8:
- goto st_case_8;
- case 3:
- goto st_case_3;
- case 4:
- goto st_case_4;
- case 5:
- goto st_case_5;
- case 6:
- goto st_case_6;
- case 7:
- goto st_case_7;
- }
- goto st_out;
- st_case_1:
- if ( ( (*( p))) == 34 ) {
- goto st2;
- }
- {
- goto st0;
- }
- st_case_0:
- st0:
- cs = 0;
- goto _out;
- st2:
- p+= 1;
- if ( p == pe )
+ switch ( cs )
+ {
+case 1:
+ if ( (*p) == 34 )
+ goto st2;
+ goto st0;
+st0:
+cs = 0;
+ goto _out;
+st2:
+ if ( ++p == pe )
goto _test_eof2;
- st_case_2:
- switch( ( (*( p))) ) {
- case 34: {
- goto ctr2;
- }
- case 92: {
- goto st3;
- }
- }
- if ( 0 <= (signed char)(*(p)) && (*(p)) <= 31 ) {
- goto st0;
- }
- {
- goto st2;
- }
- ctr2:
- {
- #line 599 "parser.rl"
-
- *result = json_string_unescape(json->memo + 1, p, json->parsing_name || json-> freeze, json->parsing_name && json->symbolize_names);
- if (NIL_P(*result)) {
- {p = p - 1; }
- {p+= 1; cs = 8; goto _out;}
- } else {
- {p = (( p + 1))-1;}
-
- }
- }
- {
- #line 609 "parser.rl"
- {p = p - 1; } {p+= 1; cs = 8; goto _out;} }
-
- goto st8;
- st8:
- p+= 1;
- if ( p == pe )
+case 2:
+ switch( (*p) ) {
+ case 34: goto tr2;
+ case 92: goto st3;
+ }
+ if ( 0 <= (signed char)(*(p)) && (*(p)) <= 31 )
+ goto st0;
+ goto st2;
+tr2:
+#line 607 "parser.rl"
+ {
+ *result = json_string_unescape(json->memo + 1, p, json->parsing_name || json-> freeze, json->parsing_name && json->symbolize_names);
+ if (NIL_P(*result)) {
+ p--;
+ {p++; cs = 8; goto _out;}
+ } else {
+ {p = (( p + 1))-1;}
+ }
+ }
+#line 617 "parser.rl"
+ { p--; {p++; cs = 8; goto _out;} }
+ goto st8;
+st8:
+ if ( ++p == pe )
goto _test_eof8;
- st_case_8:
- {
- goto st0;
- }
- st3:
- p+= 1;
- if ( p == pe )
+case 8:
+#line 1671 "parser.c"
+ goto st0;
+st3:
+ if ( ++p == pe )
goto _test_eof3;
- st_case_3:
- if ( ( (*( p))) == 117 ) {
- goto st4;
- }
- if ( 0 <= (signed char)(*(p)) && (*(p)) <= 31 ) {
- goto st0;
- }
- {
- goto st2;
- }
- st4:
- p+= 1;
- if ( p == pe )
+case 3:
+ if ( (*p) == 117 )
+ goto st4;
+ if ( 0 <= (signed char)(*(p)) && (*(p)) <= 31 )
+ goto st0;
+ goto st2;
+st4:
+ if ( ++p == pe )
goto _test_eof4;
- st_case_4:
- if ( ( (*( p))) < 65 ) {
- if ( 48 <= ( (*( p))) && ( (*( p))) <= 57 ) {
- goto st5;
- }
- } else if ( ( (*( p))) > 70 ) {
- if ( 97 <= ( (*( p))) && ( (*( p))) <= 102 ) {
- goto st5;
- }
- } else {
+case 4:
+ if ( (*p) < 65 ) {
+ if ( 48 <= (*p) && (*p) <= 57 )
goto st5;
- }
- {
- goto st0;
- }
- st5:
- p+= 1;
- if ( p == pe )
+ } else if ( (*p) > 70 ) {
+ if ( 97 <= (*p) && (*p) <= 102 )
+ goto st5;
+ } else
+ goto st5;
+ goto st0;
+st5:
+ if ( ++p == pe )
goto _test_eof5;
- st_case_5:
- if ( ( (*( p))) < 65 ) {
- if ( 48 <= ( (*( p))) && ( (*( p))) <= 57 ) {
- goto st6;
- }
- } else if ( ( (*( p))) > 70 ) {
- if ( 97 <= ( (*( p))) && ( (*( p))) <= 102 ) {
- goto st6;
- }
- } else {
+case 5:
+ if ( (*p) < 65 ) {
+ if ( 48 <= (*p) && (*p) <= 57 )
+ goto st6;
+ } else if ( (*p) > 70 ) {
+ if ( 97 <= (*p) && (*p) <= 102 )
goto st6;
- }
- {
- goto st0;
- }
- st6:
- p+= 1;
- if ( p == pe )
+ } else
+ goto st6;
+ goto st0;
+st6:
+ if ( ++p == pe )
goto _test_eof6;
- st_case_6:
- if ( ( (*( p))) < 65 ) {
- if ( 48 <= ( (*( p))) && ( (*( p))) <= 57 ) {
- goto st7;
- }
- } else if ( ( (*( p))) > 70 ) {
- if ( 97 <= ( (*( p))) && ( (*( p))) <= 102 ) {
- goto st7;
- }
- } else {
+case 6:
+ if ( (*p) < 65 ) {
+ if ( 48 <= (*p) && (*p) <= 57 )
goto st7;
- }
- {
- goto st0;
- }
- st7:
- p+= 1;
- if ( p == pe )
+ } else if ( (*p) > 70 ) {
+ if ( 97 <= (*p) && (*p) <= 102 )
+ goto st7;
+ } else
+ goto st7;
+ goto st0;
+st7:
+ if ( ++p == pe )
goto _test_eof7;
- st_case_7:
- if ( ( (*( p))) < 65 ) {
- if ( 48 <= ( (*( p))) && ( (*( p))) <= 57 ) {
- goto st2;
- }
- } else if ( ( (*( p))) > 70 ) {
- if ( 97 <= ( (*( p))) && ( (*( p))) <= 102 ) {
- goto st2;
- }
- } else {
+case 7:
+ if ( (*p) < 65 ) {
+ if ( 48 <= (*p) && (*p) <= 57 )
goto st2;
- }
- {
- goto st0;
- }
- st_out:
- _test_eof2: cs = 2; goto _test_eof;
- _test_eof8: cs = 8; goto _test_eof;
- _test_eof3: cs = 3; goto _test_eof;
- _test_eof4: cs = 4; goto _test_eof;
- _test_eof5: cs = 5; goto _test_eof;
- _test_eof6: cs = 6; goto _test_eof;
- _test_eof7: cs = 7; goto _test_eof;
-
- _test_eof: {}
- _out: {}
- }
-
- #line 634 "parser.rl"
-
-
- if (json->create_additions && RTEST(match_string = json->match_string)) {
- VALUE klass;
- VALUE memo = rb_ary_new2(2);
- rb_ary_push(memo, *result);
- rb_hash_foreach(match_string, match_i, memo);
- klass = rb_ary_entry(memo, 1);
- if (RTEST(klass)) {
- *result = rb_funcall(klass, i_json_create, 1, *result);
- }
- }
-
- if (cs >= JSON_string_first_final) {
- return p + 1;
- } else {
- return NULL;
+ } else if ( (*p) > 70 ) {
+ if ( 97 <= (*p) && (*p) <= 102 )
+ goto st2;
+ } else
+ goto st2;
+ goto st0;
}
+ _test_eof2: cs = 2; goto _test_eof;
+ _test_eof8: cs = 8; goto _test_eof;
+ _test_eof3: cs = 3; goto _test_eof;
+ _test_eof4: cs = 4; goto _test_eof;
+ _test_eof5: cs = 5; goto _test_eof;
+ _test_eof6: cs = 6; goto _test_eof;
+ _test_eof7: cs = 7; goto _test_eof;
+
+ _test_eof: {}
+ _out: {}
+ }
+
+#line 642 "parser.rl"
+
+ if (json->create_additions && RTEST(match_string = json->match_string)) {
+ VALUE klass;
+ VALUE memo = rb_ary_new2(2);
+ rb_ary_push(memo, *result);
+ rb_hash_foreach(match_string, match_i, memo);
+ klass = rb_ary_entry(memo, 1);
+ if (RTEST(klass)) {
+ *result = rb_funcall(klass, i_json_create, 1, *result);
+ }
+ }
+
+ if (cs >= JSON_string_first_final) {
+ return p + 1;
+ } else {
+ return NULL;
+ }
}
/*
-* Document-class: JSON::Ext::Parser
-*
-* This is the JSON parser implemented as a C extension. It can be configured
-* to be used by setting
-*
-* JSON.parser = JSON::Ext::Parser
-*
-* with the method parser= in JSON.
-*
-*/
+ * Document-class: JSON::Ext::Parser
+ *
+ * This is the JSON parser implemented as a C extension. It can be configured
+ * to be used by setting
+ *
+ * JSON.parser = JSON::Ext::Parser
+ *
+ * with the method parser= in JSON.
+ *
+ */
static VALUE convert_encoding(VALUE source)
{
- #ifdef HAVE_RUBY_ENCODING_H
- rb_encoding *enc = rb_enc_get(source);
- if (enc == rb_ascii8bit_encoding()) {
- if (OBJ_FROZEN(source)) {
- source = rb_str_dup(source);
- }
- FORCE_UTF8(source);
- } else {
- source = rb_str_conv_enc(source, rb_enc_get(source), rb_utf8_encoding());
- }
- #endif
- return source;
+#ifdef HAVE_RUBY_ENCODING_H
+ rb_encoding *enc = rb_enc_get(source);
+ if (enc == rb_ascii8bit_encoding()) {
+ if (OBJ_FROZEN(source)) {
+ source = rb_str_dup(source);
+ }
+ FORCE_UTF8(source);
+ } else {
+ source = rb_str_conv_enc(source, rb_enc_get(source), rb_utf8_encoding());
+ }
+#endif
+ return source;
}
/*
-* call-seq: new(source, opts => {})
-*
-* Creates a new JSON::Ext::Parser instance for the string _source_.
-*
-* Creates a new JSON::Ext::Parser instance for the string _source_.
-*
-* It will be configured by the _opts_ hash. _opts_ can have the following
-* keys:
-*
-* _opts_ can have the following keys:
-* * *max_nesting*: The maximum depth of nesting allowed in the parsed data
-* structures. Disable depth checking with :max_nesting => false|nil|0, it
-* defaults to 100.
-* * *allow_nan*: If set to true, allow NaN, Infinity and -Infinity in
-* defiance of RFC 4627 to be parsed by the Parser. This option defaults to
-* false.
-* * *symbolize_names*: If set to true, returns symbols for the names
-* (keys) in a JSON object. Otherwise strings are returned, which is
-* also the default. It's not possible to use this option in
-* conjunction with the *create_additions* option.
-* * *create_additions*: If set to false, the Parser doesn't create
-* additions even if a matching class and create_id was found. This option
-* defaults to false.
-* * *object_class*: Defaults to Hash
-* * *array_class*: Defaults to Array
-*/
+ * call-seq: new(source, opts => {})
+ *
+ * Creates a new JSON::Ext::Parser instance for the string _source_.
+ *
+ * It will be configured by the _opts_ hash. _opts_ can have the following
+ * keys:
+ *
+ * _opts_ can have the following keys:
+ * * *max_nesting*: The maximum depth of nesting allowed in the parsed data
+ * structures. Disable depth checking with :max_nesting => false|nil|0, it
+ * defaults to 100.
+ * * *allow_nan*: If set to true, allow NaN, Infinity and -Infinity in
+ * defiance of RFC 4627 to be parsed by the Parser. This option defaults to
+ * false.
+ * * *symbolize_names*: If set to true, returns symbols for the names
+ * (keys) in a JSON object. Otherwise strings are returned, which is
+ * also the default. It's not possible to use this option in
+ * conjunction with the *create_additions* option.
+ * * *create_additions*: If set to false, the Parser doesn't create
+ * additions even if a matching class and create_id was found. This option
+ * defaults to false.
+ * * *object_class*: Defaults to Hash
+ * * *array_class*: Defaults to Array
+ */
static VALUE cParser_initialize(int argc, VALUE *argv, VALUE self)
{
- VALUE source, opts;
- GET_PARSER_INIT;
-
- if (json->Vsource) {
- rb_raise(rb_eTypeError, "already initialized instance");
- }
- #ifdef HAVE_RB_SCAN_ARGS_OPTIONAL_HASH
- rb_scan_args(argc, argv, "1:", &source, &opts);
- #else
- rb_scan_args(argc, argv, "11", &source, &opts);
- #endif
- if (!NIL_P(opts)) {
- #ifndef HAVE_RB_SCAN_ARGS_OPTIONAL_HASH
- opts = rb_convert_type(opts, T_HASH, "Hash", "to_hash");
- if (NIL_P(opts)) {
- rb_raise(rb_eArgError, "opts needs to be like a hash");
- } else {
- #endif
- VALUE tmp = ID2SYM(i_max_nesting);
- if (option_given_p(opts, tmp)) {
- VALUE max_nesting = rb_hash_aref(opts, tmp);
- if (RTEST(max_nesting)) {
- Check_Type(max_nesting, T_FIXNUM);
- json->max_nesting = FIX2INT(max_nesting);
- } else {
- json->max_nesting = 0;
- }
- } else {
- json->max_nesting = 100;
- }
- tmp = ID2SYM(i_allow_nan);
- if (option_given_p(opts, tmp)) {
- json->allow_nan = RTEST(rb_hash_aref(opts, tmp)) ? 1 : 0;
- } else {
- json->allow_nan = 0;
- }
- tmp = ID2SYM(i_symbolize_names);
- if (option_given_p(opts, tmp)) {
- json->symbolize_names = RTEST(rb_hash_aref(opts, tmp)) ? 1 : 0;
- } else {
- json->symbolize_names = 0;
- }
- tmp = ID2SYM(i_freeze);
- if (option_given_p(opts, tmp)) {
- json->freeze = RTEST(rb_hash_aref(opts, tmp)) ? 1 : 0;
- } else {
- json->freeze = 0;
- }
- tmp = ID2SYM(i_create_additions);
- if (option_given_p(opts, tmp)) {
- json->create_additions = RTEST(rb_hash_aref(opts, tmp));
- } else {
- json->create_additions = 0;
- }
- if (json->symbolize_names && json->create_additions) {
- rb_raise(rb_eArgError,
- "options :symbolize_names and :create_additions cannot be "
- " used in conjunction");
- }
- tmp = ID2SYM(i_create_id);
- if (option_given_p(opts, tmp)) {
- json->create_id = rb_hash_aref(opts, tmp);
- } else {
- json->create_id = rb_funcall(mJSON, i_create_id, 0);
- }
- tmp = ID2SYM(i_object_class);
- if (option_given_p(opts, tmp)) {
- json->object_class = rb_hash_aref(opts, tmp);
- } else {
- json->object_class = Qnil;
- }
- tmp = ID2SYM(i_array_class);
- if (option_given_p(opts, tmp)) {
- json->array_class = rb_hash_aref(opts, tmp);
- } else {
- json->array_class = Qnil;
- }
- tmp = ID2SYM(i_decimal_class);
- if (option_given_p(opts, tmp)) {
- json->decimal_class = rb_hash_aref(opts, tmp);
- } else {
- json->decimal_class = Qnil;
- }
- tmp = ID2SYM(i_match_string);
- if (option_given_p(opts, tmp)) {
- VALUE match_string = rb_hash_aref(opts, tmp);
- json->match_string = RTEST(match_string) ? match_string : Qnil;
- } else {
- json->match_string = Qnil;
- }
- #ifndef HAVE_RB_SCAN_ARGS_OPTIONAL_HASH
- }
- #endif
+ VALUE source, opts;
+ GET_PARSER_INIT;
+
+ if (json->Vsource) {
+ rb_raise(rb_eTypeError, "already initialized instance");
+ }
+ rb_scan_args(argc, argv, "1:", &source, &opts);
+ if (!NIL_P(opts)) {
+ VALUE tmp = ID2SYM(i_max_nesting);
+ if (option_given_p(opts, tmp)) {
+ VALUE max_nesting = rb_hash_aref(opts, tmp);
+ if (RTEST(max_nesting)) {
+ Check_Type(max_nesting, T_FIXNUM);
+ json->max_nesting = FIX2INT(max_nesting);
+ } else {
+ json->max_nesting = 0;
+ }
+ } else {
+ json->max_nesting = 100;
+ }
+ tmp = ID2SYM(i_allow_nan);
+ if (option_given_p(opts, tmp)) {
+ json->allow_nan = RTEST(rb_hash_aref(opts, tmp)) ? 1 : 0;
+ } else {
+ json->allow_nan = 0;
+ }
+ tmp = ID2SYM(i_symbolize_names);
+ if (option_given_p(opts, tmp)) {
+ json->symbolize_names = RTEST(rb_hash_aref(opts, tmp)) ? 1 : 0;
+ } else {
+ json->symbolize_names = 0;
+ }
+ tmp = ID2SYM(i_freeze);
+ if (option_given_p(opts, tmp)) {
+ json->freeze = RTEST(rb_hash_aref(opts, tmp)) ? 1 : 0;
+ } else {
+ json->freeze = 0;
+ }
+ tmp = ID2SYM(i_create_additions);
+ if (option_given_p(opts, tmp)) {
+ json->create_additions = RTEST(rb_hash_aref(opts, tmp));
+ } else {
+ json->create_additions = 0;
+ }
+ if (json->symbolize_names && json->create_additions) {
+ rb_raise(rb_eArgError,
+ "options :symbolize_names and :create_additions cannot be "
+ " used in conjunction");
+ }
+ tmp = ID2SYM(i_create_id);
+ if (option_given_p(opts, tmp)) {
+ json->create_id = rb_hash_aref(opts, tmp);
+ } else {
+ json->create_id = rb_funcall(mJSON, i_create_id, 0);
+ }
+ tmp = ID2SYM(i_object_class);
+ if (option_given_p(opts, tmp)) {
+ json->object_class = rb_hash_aref(opts, tmp);
+ } else {
+ json->object_class = Qnil;
+ }
+ tmp = ID2SYM(i_array_class);
+ if (option_given_p(opts, tmp)) {
+ json->array_class = rb_hash_aref(opts, tmp);
+ } else {
+ json->array_class = Qnil;
+ }
+ tmp = ID2SYM(i_decimal_class);
+ if (option_given_p(opts, tmp)) {
+ json->decimal_class = rb_hash_aref(opts, tmp);
} else {
- json->max_nesting = 100;
- json->allow_nan = 0;
- json->create_additions = 0;
- json->create_id = rb_funcall(mJSON, i_create_id, 0);
- json->object_class = Qnil;
- json->array_class = Qnil;
- json->decimal_class = Qnil;
- }
- source = convert_encoding(StringValue(source));
- StringValue(source);
- json->len = RSTRING_LEN(source);
- json->source = RSTRING_PTR(source);;
- json->Vsource = source;
- return self;
+ json->decimal_class = Qnil;
+ }
+ tmp = ID2SYM(i_match_string);
+ if (option_given_p(opts, tmp)) {
+ VALUE match_string = rb_hash_aref(opts, tmp);
+ json->match_string = RTEST(match_string) ? match_string : Qnil;
+ } else {
+ json->match_string = Qnil;
+ }
+ } else {
+ json->max_nesting = 100;
+ json->allow_nan = 0;
+ json->create_additions = 0;
+ json->create_id = Qnil;
+ json->object_class = Qnil;
+ json->array_class = Qnil;
+ json->decimal_class = Qnil;
+ }
+ source = convert_encoding(StringValue(source));
+ StringValue(source);
+ json->len = RSTRING_LEN(source);
+ json->source = RSTRING_PTR(source);;
+ json->Vsource = source;
+ return self;
}
+#line 1920 "parser.c"
enum {JSON_start = 1};
enum {JSON_first_final = 10};
enum {JSON_error = 0};
enum {JSON_en_main = 1};
-static const char MAYBE_UNUSED(_JSON_nfa_targs)[] = {
- 0, 0
-};
-
-static const char MAYBE_UNUSED(_JSON_nfa_offsets)[] = {
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0
-};
-
-static const char MAYBE_UNUSED(_JSON_nfa_push_actions)[] = {
- 0, 0
-};
-
-static const char MAYBE_UNUSED(_JSON_nfa_pop_trans)[] = {
- 0, 0
-};
-
-#line 835 "parser.rl"
+#line 828 "parser.rl"
/*
-* call-seq: parse()
-*
-* Parses the current JSON text _source_ and returns the complete data
-* structure as a result.
-* It raises JSON::ParseError if fail to parse.
-*/
+ * call-seq: parse()
+ *
+ * Parses the current JSON text _source_ and returns the complete data
+ * structure as a result.
+ * It raises JSON::ParserError if fail to parse.
+ */
static VALUE cParser_parse(VALUE self)
{
- char *p, *pe;
- int cs = EVIL;
- VALUE result = Qnil;
- GET_PARSER;
+ char *p, *pe;
+ int cs = EVIL;
+ VALUE result = Qnil;
+ GET_PARSER;
+#line 1946 "parser.c"
{
- cs = (int)JSON_start;
+ cs = JSON_start;
}
- #line 851 "parser.rl"
-
- p = json->source;
- pe = p + json->len;
+#line 845 "parser.rl"
+ p = json->source;
+ pe = p + json->len;
+#line 1955 "parser.c"
{
- if ( p == pe )
+ if ( p == pe )
goto _test_eof;
- switch ( cs )
- {
- case 1:
- goto st_case_1;
- case 0:
- goto st_case_0;
- case 10:
- goto st_case_10;
- case 2:
- goto st_case_2;
- case 3:
- goto st_case_3;
- case 4:
- goto st_case_4;
- case 5:
- goto st_case_5;
- case 6:
- goto st_case_6;
- case 7:
- goto st_case_7;
- case 8:
- goto st_case_8;
- case 9:
- goto st_case_9;
- }
- goto st_out;
- st1:
- p+= 1;
- if ( p == pe )
+ switch ( cs )
+ {
+st1:
+ if ( ++p == pe )
goto _test_eof1;
- st_case_1:
- switch( ( (*( p))) ) {
- case 13: {
- goto st1;
- }
- case 32: {
- goto st1;
- }
- case 34: {
- goto ctr2;
- }
- case 45: {
- goto ctr2;
- }
- case 47: {
- goto st6;
- }
- case 73: {
- goto ctr2;
- }
- case 78: {
- goto ctr2;
- }
- case 91: {
- goto ctr2;
- }
- case 102: {
- goto ctr2;
- }
- case 110: {
- goto ctr2;
- }
- case 116: {
- goto ctr2;
- }
- case 123: {
- goto ctr2;
- }
- }
- if ( ( (*( p))) > 10 ) {
- if ( 48 <= ( (*( p))) && ( (*( p))) <= 57 ) {
- goto ctr2;
- }
- } else if ( ( (*( p))) >= 9 ) {
- goto st1;
- }
- {
- goto st0;
- }
- st_case_0:
- st0:
- cs = 0;
- goto _out;
- ctr2:
- {
- #line 827 "parser.rl"
-
- char *np = JSON_parse_value(json, p, pe, &result, 0);
- if (np == NULL) { {p = p - 1; } {p+= 1; cs = 10; goto _out;} } else {p = (( np))-1;}
-
- }
-
- goto st10;
- st10:
- p+= 1;
- if ( p == pe )
+case 1:
+ switch( (*p) ) {
+ case 13: goto st1;
+ case 32: goto st1;
+ case 34: goto tr2;
+ case 45: goto tr2;
+ case 47: goto st6;
+ case 73: goto tr2;
+ case 78: goto tr2;
+ case 91: goto tr2;
+ case 102: goto tr2;
+ case 110: goto tr2;
+ case 116: goto tr2;
+ case 123: goto tr2;
+ }
+ if ( (*p) > 10 ) {
+ if ( 48 <= (*p) && (*p) <= 57 )
+ goto tr2;
+ } else if ( (*p) >= 9 )
+ goto st1;
+ goto st0;
+st0:
+cs = 0;
+ goto _out;
+tr2:
+#line 820 "parser.rl"
+ {
+ char *np = JSON_parse_value(json, p, pe, &result, 0);
+ if (np == NULL) { p--; {p++; cs = 10; goto _out;} } else {p = (( np))-1;}
+ }
+ goto st10;
+st10:
+ if ( ++p == pe )
goto _test_eof10;
- st_case_10:
- switch( ( (*( p))) ) {
- case 13: {
- goto st10;
- }
- case 32: {
- goto st10;
- }
- case 47: {
- goto st2;
- }
- }
- if ( 9 <= ( (*( p))) && ( (*( p))) <= 10 ) {
- goto st10;
- }
- {
- goto st0;
- }
- st2:
- p+= 1;
- if ( p == pe )
+case 10:
+#line 1999 "parser.c"
+ switch( (*p) ) {
+ case 13: goto st10;
+ case 32: goto st10;
+ case 47: goto st2;
+ }
+ if ( 9 <= (*p) && (*p) <= 10 )
+ goto st10;
+ goto st0;
+st2:
+ if ( ++p == pe )
goto _test_eof2;
- st_case_2:
- switch( ( (*( p))) ) {
- case 42: {
- goto st3;
- }
- case 47: {
- goto st5;
- }
- }
- {
- goto st0;
- }
- st3:
- p+= 1;
- if ( p == pe )
+case 2:
+ switch( (*p) ) {
+ case 42: goto st3;
+ case 47: goto st5;
+ }
+ goto st0;
+st3:
+ if ( ++p == pe )
goto _test_eof3;
- st_case_3:
- if ( ( (*( p))) == 42 ) {
- goto st4;
- }
- {
- goto st3;
- }
- st4:
- p+= 1;
- if ( p == pe )
+case 3:
+ if ( (*p) == 42 )
+ goto st4;
+ goto st3;
+st4:
+ if ( ++p == pe )
goto _test_eof4;
- st_case_4:
- switch( ( (*( p))) ) {
- case 42: {
- goto st4;
- }
- case 47: {
- goto st10;
- }
- }
- {
- goto st3;
- }
- st5:
- p+= 1;
- if ( p == pe )
+case 4:
+ switch( (*p) ) {
+ case 42: goto st4;
+ case 47: goto st10;
+ }
+ goto st3;
+st5:
+ if ( ++p == pe )
goto _test_eof5;
- st_case_5:
- if ( ( (*( p))) == 10 ) {
- goto st10;
- }
- {
- goto st5;
- }
- st6:
- p+= 1;
- if ( p == pe )
+case 5:
+ if ( (*p) == 10 )
+ goto st10;
+ goto st5;
+st6:
+ if ( ++p == pe )
goto _test_eof6;
- st_case_6:
- switch( ( (*( p))) ) {
- case 42: {
- goto st7;
- }
- case 47: {
- goto st9;
- }
- }
- {
- goto st0;
- }
- st7:
- p+= 1;
- if ( p == pe )
+case 6:
+ switch( (*p) ) {
+ case 42: goto st7;
+ case 47: goto st9;
+ }
+ goto st0;
+st7:
+ if ( ++p == pe )
goto _test_eof7;
- st_case_7:
- if ( ( (*( p))) == 42 ) {
- goto st8;
- }
- {
- goto st7;
- }
- st8:
- p+= 1;
- if ( p == pe )
+case 7:
+ if ( (*p) == 42 )
+ goto st8;
+ goto st7;
+st8:
+ if ( ++p == pe )
goto _test_eof8;
- st_case_8:
- switch( ( (*( p))) ) {
- case 42: {
- goto st8;
- }
- case 47: {
- goto st1;
- }
- }
- {
- goto st7;
- }
- st9:
- p+= 1;
- if ( p == pe )
+case 8:
+ switch( (*p) ) {
+ case 42: goto st8;
+ case 47: goto st1;
+ }
+ goto st7;
+st9:
+ if ( ++p == pe )
goto _test_eof9;
- st_case_9:
- if ( ( (*( p))) == 10 ) {
- goto st1;
- }
- {
- goto st9;
- }
- st_out:
- _test_eof1: cs = 1; goto _test_eof;
- _test_eof10: cs = 10; goto _test_eof;
- _test_eof2: cs = 2; goto _test_eof;
- _test_eof3: cs = 3; goto _test_eof;
- _test_eof4: cs = 4; goto _test_eof;
- _test_eof5: cs = 5; goto _test_eof;
- _test_eof6: cs = 6; goto _test_eof;
- _test_eof7: cs = 7; goto _test_eof;
- _test_eof8: cs = 8; goto _test_eof;
- _test_eof9: cs = 9; goto _test_eof;
-
- _test_eof: {}
- _out: {}
- }
-
- #line 854 "parser.rl"
-
-
- if (cs >= JSON_first_final && p == pe) {
- return result;
- } else {
- rb_enc_raise(EXC_ENCODING eParserError, "unexpected token at '%s'", p);
- return Qnil;
+case 9:
+ if ( (*p) == 10 )
+ goto st1;
+ goto st9;
}
+ _test_eof1: cs = 1; goto _test_eof;
+ _test_eof10: cs = 10; goto _test_eof;
+ _test_eof2: cs = 2; goto _test_eof;
+ _test_eof3: cs = 3; goto _test_eof;
+ _test_eof4: cs = 4; goto _test_eof;
+ _test_eof5: cs = 5; goto _test_eof;
+ _test_eof6: cs = 6; goto _test_eof;
+ _test_eof7: cs = 7; goto _test_eof;
+ _test_eof8: cs = 8; goto _test_eof;
+ _test_eof9: cs = 9; goto _test_eof;
+
+ _test_eof: {}
+ _out: {}
+ }
+
+#line 848 "parser.rl"
+
+ if (cs >= JSON_first_final && p == pe) {
+ return result;
+ } else {
+ rb_enc_raise(EXC_ENCODING eParserError, "unexpected token at '%s'", p);
+ return Qnil;
+ }
}
static void JSON_mark(void *ptr)
{
- JSON_Parser *json = ptr;
- rb_gc_mark_maybe(json->Vsource);
- rb_gc_mark_maybe(json->create_id);
- rb_gc_mark_maybe(json->object_class);
- rb_gc_mark_maybe(json->array_class);
- rb_gc_mark_maybe(json->decimal_class);
- rb_gc_mark_maybe(json->match_string);
+ JSON_Parser *json = ptr;
+ rb_gc_mark_maybe(json->Vsource);
+ rb_gc_mark_maybe(json->create_id);
+ rb_gc_mark_maybe(json->object_class);
+ rb_gc_mark_maybe(json->array_class);
+ rb_gc_mark_maybe(json->decimal_class);
+ rb_gc_mark_maybe(json->match_string);
}
static void JSON_free(void *ptr)
{
- JSON_Parser *json = ptr;
- fbuffer_free(json->fbuffer);
- ruby_xfree(json);
+ JSON_Parser *json = ptr;
+ fbuffer_free(json->fbuffer);
+ ruby_xfree(json);
}
static size_t JSON_memsize(const void *ptr)
{
- const JSON_Parser *json = ptr;
- return sizeof(*json) + FBUFFER_CAPA(json->fbuffer);
+ const JSON_Parser *json = ptr;
+ return sizeof(*json) + FBUFFER_CAPA(json->fbuffer);
}
#ifdef NEW_TYPEDDATA_WRAPPER
static const rb_data_type_t JSON_Parser_type = {
- "JSON/Parser",
- {JSON_mark, JSON_free, JSON_memsize,},
- #ifdef RUBY_TYPED_FREE_IMMEDIATELY
- 0, 0,
- RUBY_TYPED_FREE_IMMEDIATELY,
- #endif
+ "JSON/Parser",
+ {JSON_mark, JSON_free, JSON_memsize,},
+#ifdef RUBY_TYPED_FREE_IMMEDIATELY
+ 0, 0,
+ RUBY_TYPED_FREE_IMMEDIATELY,
+#endif
};
#endif
static VALUE cJSON_parser_s_allocate(VALUE klass)
{
- JSON_Parser *json;
- VALUE obj = TypedData_Make_Struct(klass, JSON_Parser, &JSON_Parser_type, json);
- json->fbuffer = fbuffer_alloc(0);
- return obj;
+ JSON_Parser *json;
+ VALUE obj = TypedData_Make_Struct(klass, JSON_Parser, &JSON_Parser_type, json);
+ json->fbuffer = fbuffer_alloc(0);
+ return obj;
}
/*
-* call-seq: source()
-*
-* Returns a copy of the current _source_ string, that was used to construct
-* this Parser.
-*/
+ * call-seq: source()
+ *
+ * Returns a copy of the current _source_ string, that was used to construct
+ * this Parser.
+ */
static VALUE cParser_source(VALUE self)
{
- GET_PARSER;
- return rb_str_dup(json->Vsource);
+ GET_PARSER;
+ return rb_str_dup(json->Vsource);
}
void Init_parser(void)
{
- #ifdef HAVE_RB_EXT_RACTOR_SAFE
- rb_ext_ractor_safe(true);
- #endif
-
- #undef rb_intern
- rb_require("json/common");
- mJSON = rb_define_module("JSON");
- mExt = rb_define_module_under(mJSON, "Ext");
- cParser = rb_define_class_under(mExt, "Parser", rb_cObject);
- eParserError = rb_path2class("JSON::ParserError");
- eNestingError = rb_path2class("JSON::NestingError");
- rb_gc_register_mark_object(eParserError);
- rb_gc_register_mark_object(eNestingError);
- rb_define_alloc_func(cParser, cJSON_parser_s_allocate);
- rb_define_method(cParser, "initialize", cParser_initialize, -1);
- rb_define_method(cParser, "parse", cParser_parse, 0);
- rb_define_method(cParser, "source", cParser_source, 0);
-
- CNaN = rb_const_get(mJSON, rb_intern("NaN"));
- rb_gc_register_mark_object(CNaN);
-
- CInfinity = rb_const_get(mJSON, rb_intern("Infinity"));
- rb_gc_register_mark_object(CInfinity);
-
- CMinusInfinity = rb_const_get(mJSON, rb_intern("MinusInfinity"));
- rb_gc_register_mark_object(CMinusInfinity);
-
- i_json_creatable_p = rb_intern("json_creatable?");
- i_json_create = rb_intern("json_create");
- i_create_id = rb_intern("create_id");
- i_create_additions = rb_intern("create_additions");
- i_chr = rb_intern("chr");
- i_max_nesting = rb_intern("max_nesting");
- i_allow_nan = rb_intern("allow_nan");
- i_symbolize_names = rb_intern("symbolize_names");
- i_object_class = rb_intern("object_class");
- i_array_class = rb_intern("array_class");
- i_decimal_class = rb_intern("decimal_class");
- i_match = rb_intern("match");
- i_match_string = rb_intern("match_string");
- i_key_p = rb_intern("key?");
- i_deep_const_get = rb_intern("deep_const_get");
- i_aset = rb_intern("[]=");
- i_aref = rb_intern("[]");
- i_leftshift = rb_intern("<<");
- i_new = rb_intern("new");
- i_try_convert = rb_intern("try_convert");
- i_freeze = rb_intern("freeze");
- i_uminus = rb_intern("-@");
+#ifdef HAVE_RB_EXT_RACTOR_SAFE
+ rb_ext_ractor_safe(true);
+#endif
+
+#undef rb_intern
+ rb_require("json/common");
+ mJSON = rb_define_module("JSON");
+ mExt = rb_define_module_under(mJSON, "Ext");
+ cParser = rb_define_class_under(mExt, "Parser", rb_cObject);
+ eParserError = rb_path2class("JSON::ParserError");
+ eNestingError = rb_path2class("JSON::NestingError");
+ rb_gc_register_mark_object(eParserError);
+ rb_gc_register_mark_object(eNestingError);
+ rb_define_alloc_func(cParser, cJSON_parser_s_allocate);
+ rb_define_method(cParser, "initialize", cParser_initialize, -1);
+ rb_define_method(cParser, "parse", cParser_parse, 0);
+ rb_define_method(cParser, "source", cParser_source, 0);
+
+ CNaN = rb_const_get(mJSON, rb_intern("NaN"));
+ rb_gc_register_mark_object(CNaN);
+
+ CInfinity = rb_const_get(mJSON, rb_intern("Infinity"));
+ rb_gc_register_mark_object(CInfinity);
+
+ CMinusInfinity = rb_const_get(mJSON, rb_intern("MinusInfinity"));
+ rb_gc_register_mark_object(CMinusInfinity);
+
+ i_json_creatable_p = rb_intern("json_creatable?");
+ i_json_create = rb_intern("json_create");
+ i_create_id = rb_intern("create_id");
+ i_create_additions = rb_intern("create_additions");
+ i_chr = rb_intern("chr");
+ i_max_nesting = rb_intern("max_nesting");
+ i_allow_nan = rb_intern("allow_nan");
+ i_symbolize_names = rb_intern("symbolize_names");
+ i_object_class = rb_intern("object_class");
+ i_array_class = rb_intern("array_class");
+ i_decimal_class = rb_intern("decimal_class");
+ i_match = rb_intern("match");
+ i_match_string = rb_intern("match_string");
+ i_key_p = rb_intern("key?");
+ i_deep_const_get = rb_intern("deep_const_get");
+ i_aset = rb_intern("[]=");
+ i_aref = rb_intern("[]");
+ i_leftshift = rb_intern("<<");
+ i_new = rb_intern("new");
+ i_try_convert = rb_intern("try_convert");
+ i_freeze = rb_intern("freeze");
+ i_uminus = rb_intern("-@");
}
/*
-* Local variables:
-* mode: c
-* c-file-style: ruby
-* indent-tabs-mode: nil
-* End:
-*/
+ * Local variables:
+ * mode: c
+ * c-file-style: ruby
+ * indent-tabs-mode: nil
+ * End:
+ */
diff --git a/ext/json/parser/parser.rl b/ext/json/parser/parser.rl
index 2dbdc7ef24..af190e7500 100644
--- a/ext/json/parser/parser.rl
+++ b/ext/json/parser/parser.rl
@@ -229,7 +229,7 @@ static char *JSON_parse_object(JSON_Parser *json, char *p, char *pe, VALUE *resu
if (json->allow_nan) {
*result = CInfinity;
} else {
- rb_enc_raise(EXC_ENCODING eParserError, "unexpected token at '%s'", p - 8);
+ rb_enc_raise(EXC_ENCODING eParserError, "unexpected token at '%s'", p - 7);
}
}
action parse_string {
@@ -508,7 +508,7 @@ static VALUE json_string_unescape(char *string, char *stringEnd, int intern, int
case 'u':
if (pe > stringEnd - 4) {
if (bufferSize > MAX_STACK_BUFFER_SIZE) {
- free(bufferStart);
+ ruby_xfree(bufferStart);
}
rb_enc_raise(
EXC_ENCODING eParserError,
@@ -521,7 +521,7 @@ static VALUE json_string_unescape(char *string, char *stringEnd, int intern, int
pe++;
if (pe > stringEnd - 6) {
if (bufferSize > MAX_STACK_BUFFER_SIZE) {
- free(bufferStart);
+ ruby_xfree(bufferStart);
}
rb_enc_raise(
EXC_ENCODING eParserError,
@@ -566,13 +566,13 @@ static VALUE json_string_unescape(char *string, char *stringEnd, int intern, int
result = rb_utf8_str_new(bufferStart, (long)(buffer - bufferStart));
}
if (bufferSize > MAX_STACK_BUFFER_SIZE) {
- free(bufferStart);
+ ruby_xfree(bufferStart);
}
# else
result = rb_utf8_str_new(bufferStart, (long)(buffer - bufferStart));
if (bufferSize > MAX_STACK_BUFFER_SIZE) {
- free(bufferStart);
+ ruby_xfree(bufferStart);
}
if (intern) {
@@ -691,8 +691,6 @@ static VALUE convert_encoding(VALUE source)
*
* Creates a new JSON::Ext::Parser instance for the string _source_.
*
- * Creates a new JSON::Ext::Parser instance for the string _source_.
- *
* It will be configured by the _opts_ hash. _opts_ can have the following
* keys:
*
@@ -721,98 +719,85 @@ static VALUE cParser_initialize(int argc, VALUE *argv, VALUE self)
if (json->Vsource) {
rb_raise(rb_eTypeError, "already initialized instance");
}
-#ifdef HAVE_RB_SCAN_ARGS_OPTIONAL_HASH
rb_scan_args(argc, argv, "1:", &source, &opts);
-#else
- rb_scan_args(argc, argv, "11", &source, &opts);
-#endif
if (!NIL_P(opts)) {
-#ifndef HAVE_RB_SCAN_ARGS_OPTIONAL_HASH
- opts = rb_convert_type(opts, T_HASH, "Hash", "to_hash");
- if (NIL_P(opts)) {
- rb_raise(rb_eArgError, "opts needs to be like a hash");
- } else {
-#endif
- VALUE tmp = ID2SYM(i_max_nesting);
- if (option_given_p(opts, tmp)) {
- VALUE max_nesting = rb_hash_aref(opts, tmp);
- if (RTEST(max_nesting)) {
- Check_Type(max_nesting, T_FIXNUM);
- json->max_nesting = FIX2INT(max_nesting);
- } else {
- json->max_nesting = 0;
- }
- } else {
- json->max_nesting = 100;
- }
- tmp = ID2SYM(i_allow_nan);
- if (option_given_p(opts, tmp)) {
- json->allow_nan = RTEST(rb_hash_aref(opts, tmp)) ? 1 : 0;
- } else {
- json->allow_nan = 0;
- }
- tmp = ID2SYM(i_symbolize_names);
- if (option_given_p(opts, tmp)) {
- json->symbolize_names = RTEST(rb_hash_aref(opts, tmp)) ? 1 : 0;
- } else {
- json->symbolize_names = 0;
- }
- tmp = ID2SYM(i_freeze);
- if (option_given_p(opts, tmp)) {
- json->freeze = RTEST(rb_hash_aref(opts, tmp)) ? 1 : 0;
- } else {
- json->freeze = 0;
- }
- tmp = ID2SYM(i_create_additions);
- if (option_given_p(opts, tmp)) {
- json->create_additions = RTEST(rb_hash_aref(opts, tmp));
- } else {
- json->create_additions = 0;
- }
- if (json->symbolize_names && json->create_additions) {
- rb_raise(rb_eArgError,
- "options :symbolize_names and :create_additions cannot be "
- " used in conjunction");
- }
- tmp = ID2SYM(i_create_id);
- if (option_given_p(opts, tmp)) {
- json->create_id = rb_hash_aref(opts, tmp);
- } else {
- json->create_id = rb_funcall(mJSON, i_create_id, 0);
- }
- tmp = ID2SYM(i_object_class);
- if (option_given_p(opts, tmp)) {
- json->object_class = rb_hash_aref(opts, tmp);
- } else {
- json->object_class = Qnil;
- }
- tmp = ID2SYM(i_array_class);
- if (option_given_p(opts, tmp)) {
- json->array_class = rb_hash_aref(opts, tmp);
- } else {
- json->array_class = Qnil;
- }
- tmp = ID2SYM(i_decimal_class);
- if (option_given_p(opts, tmp)) {
- json->decimal_class = rb_hash_aref(opts, tmp);
- } else {
- json->decimal_class = Qnil;
- }
- tmp = ID2SYM(i_match_string);
- if (option_given_p(opts, tmp)) {
- VALUE match_string = rb_hash_aref(opts, tmp);
- json->match_string = RTEST(match_string) ? match_string : Qnil;
- } else {
- json->match_string = Qnil;
- }
-#ifndef HAVE_RB_SCAN_ARGS_OPTIONAL_HASH
- }
-#endif
+ VALUE tmp = ID2SYM(i_max_nesting);
+ if (option_given_p(opts, tmp)) {
+ VALUE max_nesting = rb_hash_aref(opts, tmp);
+ if (RTEST(max_nesting)) {
+ Check_Type(max_nesting, T_FIXNUM);
+ json->max_nesting = FIX2INT(max_nesting);
+ } else {
+ json->max_nesting = 0;
+ }
+ } else {
+ json->max_nesting = 100;
+ }
+ tmp = ID2SYM(i_allow_nan);
+ if (option_given_p(opts, tmp)) {
+ json->allow_nan = RTEST(rb_hash_aref(opts, tmp)) ? 1 : 0;
+ } else {
+ json->allow_nan = 0;
+ }
+ tmp = ID2SYM(i_symbolize_names);
+ if (option_given_p(opts, tmp)) {
+ json->symbolize_names = RTEST(rb_hash_aref(opts, tmp)) ? 1 : 0;
+ } else {
+ json->symbolize_names = 0;
+ }
+ tmp = ID2SYM(i_freeze);
+ if (option_given_p(opts, tmp)) {
+ json->freeze = RTEST(rb_hash_aref(opts, tmp)) ? 1 : 0;
+ } else {
+ json->freeze = 0;
+ }
+ tmp = ID2SYM(i_create_additions);
+ if (option_given_p(opts, tmp)) {
+ json->create_additions = RTEST(rb_hash_aref(opts, tmp));
+ } else {
+ json->create_additions = 0;
+ }
+ if (json->symbolize_names && json->create_additions) {
+ rb_raise(rb_eArgError,
+ "options :symbolize_names and :create_additions cannot be "
+ " used in conjunction");
+ }
+ tmp = ID2SYM(i_create_id);
+ if (option_given_p(opts, tmp)) {
+ json->create_id = rb_hash_aref(opts, tmp);
+ } else {
+ json->create_id = rb_funcall(mJSON, i_create_id, 0);
+ }
+ tmp = ID2SYM(i_object_class);
+ if (option_given_p(opts, tmp)) {
+ json->object_class = rb_hash_aref(opts, tmp);
+ } else {
+ json->object_class = Qnil;
+ }
+ tmp = ID2SYM(i_array_class);
+ if (option_given_p(opts, tmp)) {
+ json->array_class = rb_hash_aref(opts, tmp);
+ } else {
+ json->array_class = Qnil;
+ }
+ tmp = ID2SYM(i_decimal_class);
+ if (option_given_p(opts, tmp)) {
+ json->decimal_class = rb_hash_aref(opts, tmp);
+ } else {
+ json->decimal_class = Qnil;
+ }
+ tmp = ID2SYM(i_match_string);
+ if (option_given_p(opts, tmp)) {
+ VALUE match_string = rb_hash_aref(opts, tmp);
+ json->match_string = RTEST(match_string) ? match_string : Qnil;
+ } else {
+ json->match_string = Qnil;
+ }
} else {
json->max_nesting = 100;
json->allow_nan = 0;
json->create_additions = 0;
- json->create_id = rb_funcall(mJSON, i_create_id, 0);
+ json->create_id = Qnil;
json->object_class = Qnil;
json->array_class = Qnil;
json->decimal_class = Qnil;
@@ -847,7 +832,7 @@ static VALUE cParser_initialize(int argc, VALUE *argv, VALUE self)
*
* Parses the current JSON text _source_ and returns the complete data
* structure as a result.
- * It raises JSON::ParseError if fail to parse.
+ * It raises JSON::ParserError if fail to parse.
*/
static VALUE cParser_parse(VALUE self)
{
diff --git a/ext/monitor/depend b/ext/monitor/depend
index 3030da71d0..38e21b3f66 100644
--- a/ext/monitor/depend
+++ b/ext/monitor/depend
@@ -51,6 +51,7 @@ monitor.o: $(hdrdir)/ruby/internal/attr/noexcept.h
monitor.o: $(hdrdir)/ruby/internal/attr/noinline.h
monitor.o: $(hdrdir)/ruby/internal/attr/nonnull.h
monitor.o: $(hdrdir)/ruby/internal/attr/noreturn.h
+monitor.o: $(hdrdir)/ruby/internal/attr/packed_struct.h
monitor.o: $(hdrdir)/ruby/internal/attr/pure.h
monitor.o: $(hdrdir)/ruby/internal/attr/restrict.h
monitor.o: $(hdrdir)/ruby/internal/attr/returns_nonnull.h
@@ -110,7 +111,6 @@ monitor.o: $(hdrdir)/ruby/internal/intern/enumerator.h
monitor.o: $(hdrdir)/ruby/internal/intern/error.h
monitor.o: $(hdrdir)/ruby/internal/intern/eval.h
monitor.o: $(hdrdir)/ruby/internal/intern/file.h
-monitor.o: $(hdrdir)/ruby/internal/intern/gc.h
monitor.o: $(hdrdir)/ruby/internal/intern/hash.h
monitor.o: $(hdrdir)/ruby/internal/intern/io.h
monitor.o: $(hdrdir)/ruby/internal/intern/load.h
@@ -141,7 +141,6 @@ monitor.o: $(hdrdir)/ruby/internal/memory.h
monitor.o: $(hdrdir)/ruby/internal/method.h
monitor.o: $(hdrdir)/ruby/internal/module.h
monitor.o: $(hdrdir)/ruby/internal/newobj.h
-monitor.o: $(hdrdir)/ruby/internal/rgengc.h
monitor.o: $(hdrdir)/ruby/internal/scan_args.h
monitor.o: $(hdrdir)/ruby/internal/special_consts.h
monitor.o: $(hdrdir)/ruby/internal/static_assert.h
diff --git a/ext/monitor/monitor.c b/ext/monitor/monitor.c
index 10209cf2aa..86613f6ade 100644
--- a/ext/monitor/monitor.c
+++ b/ext/monitor/monitor.c
@@ -102,7 +102,7 @@ monitor_exit(VALUE monitor)
struct rb_monitor *mc = monitor_ptr(monitor);
- if (mc->count <= 0) rb_bug("monitor_exit: count:%d\n", (int)mc->count);
+ if (mc->count <= 0) rb_bug("monitor_exit: count:%d", (int)mc->count);
mc->count--;
if (mc->count == 0) {
diff --git a/ext/nkf/depend b/ext/nkf/depend
index 9e2f468ba1..98afc5f201 100644
--- a/ext/nkf/depend
+++ b/ext/nkf/depend
@@ -56,6 +56,7 @@ nkf.o: $(hdrdir)/ruby/internal/attr/noexcept.h
nkf.o: $(hdrdir)/ruby/internal/attr/noinline.h
nkf.o: $(hdrdir)/ruby/internal/attr/nonnull.h
nkf.o: $(hdrdir)/ruby/internal/attr/noreturn.h
+nkf.o: $(hdrdir)/ruby/internal/attr/packed_struct.h
nkf.o: $(hdrdir)/ruby/internal/attr/pure.h
nkf.o: $(hdrdir)/ruby/internal/attr/restrict.h
nkf.o: $(hdrdir)/ruby/internal/attr/returns_nonnull.h
@@ -124,7 +125,6 @@ nkf.o: $(hdrdir)/ruby/internal/intern/enumerator.h
nkf.o: $(hdrdir)/ruby/internal/intern/error.h
nkf.o: $(hdrdir)/ruby/internal/intern/eval.h
nkf.o: $(hdrdir)/ruby/internal/intern/file.h
-nkf.o: $(hdrdir)/ruby/internal/intern/gc.h
nkf.o: $(hdrdir)/ruby/internal/intern/hash.h
nkf.o: $(hdrdir)/ruby/internal/intern/io.h
nkf.o: $(hdrdir)/ruby/internal/intern/load.h
@@ -155,7 +155,6 @@ nkf.o: $(hdrdir)/ruby/internal/memory.h
nkf.o: $(hdrdir)/ruby/internal/method.h
nkf.o: $(hdrdir)/ruby/internal/module.h
nkf.o: $(hdrdir)/ruby/internal/newobj.h
-nkf.o: $(hdrdir)/ruby/internal/rgengc.h
nkf.o: $(hdrdir)/ruby/internal/scan_args.h
nkf.o: $(hdrdir)/ruby/internal/special_consts.h
nkf.o: $(hdrdir)/ruby/internal/static_assert.h
diff --git a/ext/nkf/nkf.c b/ext/nkf/nkf.c
index c6ddee1976..73b616a54f 100644
--- a/ext/nkf/nkf.c
+++ b/ext/nkf/nkf.c
@@ -9,6 +9,7 @@
#define RUBY_NKF_REVISION "$Revision$"
#define RUBY_NKF_VERSION NKF_VERSION " (" NKF_RELEASE_DATE ")"
+#define NKF_GEM_VERSION "0.1.3"
#include "ruby/ruby.h"
#include "ruby/encoding.h"
@@ -500,4 +501,6 @@ Init_nkf(void)
rb_define_const(mNKF, "NKF_VERSION", rb_str_new2(NKF_VERSION));
/* Release date of nkf */
rb_define_const(mNKF, "NKF_RELEASE_DATE", rb_str_new2(NKF_RELEASE_DATE));
+ /* Version of nkf library */
+ rb_define_const(mNKF, "GEM_VERSION", rb_str_new_cstr(NKF_GEM_VERSION));
}
diff --git a/ext/nkf/nkf.gemspec b/ext/nkf/nkf.gemspec
index 7f3bd4a4b1..097a9485ed 100644
--- a/ext/nkf/nkf.gemspec
+++ b/ext/nkf/nkf.gemspec
@@ -1,6 +1,16 @@
+source_version = ["", "ext/nkf/"].find do |dir|
+ begin
+ break File.open(File.join(__dir__, "#{dir}nkf.c")) {|f|
+ f.gets("\n#define NKF_GEM_VERSION ")
+ f.gets[/\s*"(.+)"/, 1]
+ }
+ rescue Errno::ENOENT
+ end
+end
+
Gem::Specification.new do |spec|
spec.name = "nkf"
- spec.version = "0.1.2"
+ spec.version = source_version
spec.authors = ["NARUSE Yui"]
spec.email = ["naruse@airemix.jp"]
@@ -21,4 +31,5 @@ Gem::Specification.new do |spec|
spec.bindir = "exe"
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
spec.require_paths = ["lib"]
+ spec.extensions = ["ext/nkf/extconf.rb"]
end
diff --git a/ext/objspace/depend b/ext/objspace/depend
index 435ed294b9..85e99a71b4 100644
--- a/ext/objspace/depend
+++ b/ext/objspace/depend
@@ -2,10 +2,12 @@
object_tracing.o: $(RUBY_EXTCONF_H)
object_tracing.o: $(arch_hdrdir)/ruby/config.h
object_tracing.o: $(hdrdir)/ruby/assert.h
+object_tracing.o: $(hdrdir)/ruby/atomic.h
object_tracing.o: $(hdrdir)/ruby/backward.h
object_tracing.o: $(hdrdir)/ruby/backward/2/assume.h
object_tracing.o: $(hdrdir)/ruby/backward/2/attributes.h
object_tracing.o: $(hdrdir)/ruby/backward/2/bool.h
+object_tracing.o: $(hdrdir)/ruby/backward/2/gcc_version_since.h
object_tracing.o: $(hdrdir)/ruby/backward/2/inttypes.h
object_tracing.o: $(hdrdir)/ruby/backward/2/limits.h
object_tracing.o: $(hdrdir)/ruby/backward/2/long_long.h
@@ -13,6 +15,7 @@ object_tracing.o: $(hdrdir)/ruby/backward/2/stdalign.h
object_tracing.o: $(hdrdir)/ruby/backward/2/stdarg.h
object_tracing.o: $(hdrdir)/ruby/debug.h
object_tracing.o: $(hdrdir)/ruby/defines.h
+object_tracing.o: $(hdrdir)/ruby/encoding.h
object_tracing.o: $(hdrdir)/ruby/intern.h
object_tracing.o: $(hdrdir)/ruby/internal/abi.h
object_tracing.o: $(hdrdir)/ruby/internal/anyargs.h
@@ -52,6 +55,7 @@ object_tracing.o: $(hdrdir)/ruby/internal/attr/noexcept.h
object_tracing.o: $(hdrdir)/ruby/internal/attr/noinline.h
object_tracing.o: $(hdrdir)/ruby/internal/attr/nonnull.h
object_tracing.o: $(hdrdir)/ruby/internal/attr/noreturn.h
+object_tracing.o: $(hdrdir)/ruby/internal/attr/packed_struct.h
object_tracing.o: $(hdrdir)/ruby/internal/attr/pure.h
object_tracing.o: $(hdrdir)/ruby/internal/attr/restrict.h
object_tracing.o: $(hdrdir)/ruby/internal/attr/returns_nonnull.h
@@ -84,6 +88,15 @@ object_tracing.o: $(hdrdir)/ruby/internal/core/rtypeddata.h
object_tracing.o: $(hdrdir)/ruby/internal/ctype.h
object_tracing.o: $(hdrdir)/ruby/internal/dllexport.h
object_tracing.o: $(hdrdir)/ruby/internal/dosish.h
+object_tracing.o: $(hdrdir)/ruby/internal/encoding/coderange.h
+object_tracing.o: $(hdrdir)/ruby/internal/encoding/ctype.h
+object_tracing.o: $(hdrdir)/ruby/internal/encoding/encoding.h
+object_tracing.o: $(hdrdir)/ruby/internal/encoding/pathname.h
+object_tracing.o: $(hdrdir)/ruby/internal/encoding/re.h
+object_tracing.o: $(hdrdir)/ruby/internal/encoding/sprintf.h
+object_tracing.o: $(hdrdir)/ruby/internal/encoding/string.h
+object_tracing.o: $(hdrdir)/ruby/internal/encoding/symbol.h
+object_tracing.o: $(hdrdir)/ruby/internal/encoding/transcode.h
object_tracing.o: $(hdrdir)/ruby/internal/error.h
object_tracing.o: $(hdrdir)/ruby/internal/eval.h
object_tracing.o: $(hdrdir)/ruby/internal/event.h
@@ -111,7 +124,6 @@ object_tracing.o: $(hdrdir)/ruby/internal/intern/enumerator.h
object_tracing.o: $(hdrdir)/ruby/internal/intern/error.h
object_tracing.o: $(hdrdir)/ruby/internal/intern/eval.h
object_tracing.o: $(hdrdir)/ruby/internal/intern/file.h
-object_tracing.o: $(hdrdir)/ruby/internal/intern/gc.h
object_tracing.o: $(hdrdir)/ruby/internal/intern/hash.h
object_tracing.o: $(hdrdir)/ruby/internal/intern/io.h
object_tracing.o: $(hdrdir)/ruby/internal/intern/load.h
@@ -142,7 +154,6 @@ object_tracing.o: $(hdrdir)/ruby/internal/memory.h
object_tracing.o: $(hdrdir)/ruby/internal/method.h
object_tracing.o: $(hdrdir)/ruby/internal/module.h
object_tracing.o: $(hdrdir)/ruby/internal/newobj.h
-object_tracing.o: $(hdrdir)/ruby/internal/rgengc.h
object_tracing.o: $(hdrdir)/ruby/internal/scan_args.h
object_tracing.o: $(hdrdir)/ruby/internal/special_consts.h
object_tracing.o: $(hdrdir)/ruby/internal/static_assert.h
@@ -155,16 +166,41 @@ object_tracing.o: $(hdrdir)/ruby/internal/variable.h
object_tracing.o: $(hdrdir)/ruby/internal/warning_push.h
object_tracing.o: $(hdrdir)/ruby/internal/xmalloc.h
object_tracing.o: $(hdrdir)/ruby/missing.h
+object_tracing.o: $(hdrdir)/ruby/onigmo.h
+object_tracing.o: $(hdrdir)/ruby/oniguruma.h
object_tracing.o: $(hdrdir)/ruby/ruby.h
object_tracing.o: $(hdrdir)/ruby/st.h
object_tracing.o: $(hdrdir)/ruby/subst.h
-object_tracing.o: $(top_srcdir)/gc.h
+object_tracing.o: $(hdrdir)/ruby/thread_native.h
+object_tracing.o: $(top_srcdir)/ccan/check_type/check_type.h
+object_tracing.o: $(top_srcdir)/ccan/container_of/container_of.h
+object_tracing.o: $(top_srcdir)/ccan/list/list.h
+object_tracing.o: $(top_srcdir)/ccan/str/str.h
object_tracing.o: $(top_srcdir)/internal.h
+object_tracing.o: $(top_srcdir)/internal/array.h
+object_tracing.o: $(top_srcdir)/internal/basic_operators.h
+object_tracing.o: $(top_srcdir)/internal/compilers.h
+object_tracing.o: $(top_srcdir)/internal/gc.h
+object_tracing.o: $(top_srcdir)/internal/imemo.h
+object_tracing.o: $(top_srcdir)/internal/serial.h
+object_tracing.o: $(top_srcdir)/internal/static_assert.h
+object_tracing.o: $(top_srcdir)/internal/vm.h
+object_tracing.o: $(top_srcdir)/internal/warnings.h
+object_tracing.o: $(top_srcdir)/method.h
+object_tracing.o: $(top_srcdir)/node.h
+object_tracing.o: $(top_srcdir)/ruby_assert.h
+object_tracing.o: $(top_srcdir)/ruby_atomic.h
+object_tracing.o: $(top_srcdir)/rubyparser.h
+object_tracing.o: $(top_srcdir)/thread_pthread.h
+object_tracing.o: $(top_srcdir)/vm_core.h
+object_tracing.o: $(top_srcdir)/vm_opts.h
object_tracing.o: object_tracing.c
object_tracing.o: objspace.h
+object_tracing.o: {$(VPATH)}id.h
objspace.o: $(RUBY_EXTCONF_H)
objspace.o: $(arch_hdrdir)/ruby/config.h
objspace.o: $(hdrdir)/ruby/assert.h
+objspace.o: $(hdrdir)/ruby/atomic.h
objspace.o: $(hdrdir)/ruby/backward.h
objspace.o: $(hdrdir)/ruby/backward/2/assume.h
objspace.o: $(hdrdir)/ruby/backward/2/attributes.h
@@ -216,6 +252,7 @@ objspace.o: $(hdrdir)/ruby/internal/attr/noexcept.h
objspace.o: $(hdrdir)/ruby/internal/attr/noinline.h
objspace.o: $(hdrdir)/ruby/internal/attr/nonnull.h
objspace.o: $(hdrdir)/ruby/internal/attr/noreturn.h
+objspace.o: $(hdrdir)/ruby/internal/attr/packed_struct.h
objspace.o: $(hdrdir)/ruby/internal/attr/pure.h
objspace.o: $(hdrdir)/ruby/internal/attr/restrict.h
objspace.o: $(hdrdir)/ruby/internal/attr/returns_nonnull.h
@@ -285,7 +322,6 @@ objspace.o: $(hdrdir)/ruby/internal/intern/enumerator.h
objspace.o: $(hdrdir)/ruby/internal/intern/error.h
objspace.o: $(hdrdir)/ruby/internal/intern/eval.h
objspace.o: $(hdrdir)/ruby/internal/intern/file.h
-objspace.o: $(hdrdir)/ruby/internal/intern/gc.h
objspace.o: $(hdrdir)/ruby/internal/intern/hash.h
objspace.o: $(hdrdir)/ruby/internal/intern/io.h
objspace.o: $(hdrdir)/ruby/internal/intern/load.h
@@ -316,7 +352,6 @@ objspace.o: $(hdrdir)/ruby/internal/memory.h
objspace.o: $(hdrdir)/ruby/internal/method.h
objspace.o: $(hdrdir)/ruby/internal/module.h
objspace.o: $(hdrdir)/ruby/internal/newobj.h
-objspace.o: $(hdrdir)/ruby/internal/rgengc.h
objspace.o: $(hdrdir)/ruby/internal/scan_args.h
objspace.o: $(hdrdir)/ruby/internal/special_consts.h
objspace.o: $(hdrdir)/ruby/internal/static_assert.h
@@ -337,10 +372,17 @@ objspace.o: $(hdrdir)/ruby/regex.h
objspace.o: $(hdrdir)/ruby/ruby.h
objspace.o: $(hdrdir)/ruby/st.h
objspace.o: $(hdrdir)/ruby/subst.h
-objspace.o: $(top_srcdir)/gc.h
+objspace.o: $(hdrdir)/ruby/thread_native.h
+objspace.o: $(top_srcdir)/ccan/check_type/check_type.h
+objspace.o: $(top_srcdir)/ccan/container_of/container_of.h
+objspace.o: $(top_srcdir)/ccan/list/list.h
+objspace.o: $(top_srcdir)/ccan/str/str.h
+objspace.o: $(top_srcdir)/constant.h
+objspace.o: $(top_srcdir)/debug_counter.h
objspace.o: $(top_srcdir)/id_table.h
objspace.o: $(top_srcdir)/internal.h
objspace.o: $(top_srcdir)/internal/array.h
+objspace.o: $(top_srcdir)/internal/basic_operators.h
objspace.o: $(top_srcdir)/internal/class.h
objspace.o: $(top_srcdir)/internal/compilers.h
objspace.o: $(top_srcdir)/internal/gc.h
@@ -349,10 +391,21 @@ objspace.o: $(top_srcdir)/internal/imemo.h
objspace.o: $(top_srcdir)/internal/sanitizers.h
objspace.o: $(top_srcdir)/internal/serial.h
objspace.o: $(top_srcdir)/internal/static_assert.h
+objspace.o: $(top_srcdir)/internal/variable.h
+objspace.o: $(top_srcdir)/internal/vm.h
objspace.o: $(top_srcdir)/internal/warnings.h
+objspace.o: $(top_srcdir)/method.h
objspace.o: $(top_srcdir)/node.h
+objspace.o: $(top_srcdir)/ruby_assert.h
+objspace.o: $(top_srcdir)/ruby_atomic.h
+objspace.o: $(top_srcdir)/rubyparser.h
objspace.o: $(top_srcdir)/shape.h
objspace.o: $(top_srcdir)/symbol.h
+objspace.o: $(top_srcdir)/thread_pthread.h
+objspace.o: $(top_srcdir)/vm_core.h
+objspace.o: $(top_srcdir)/vm_debug.h
+objspace.o: $(top_srcdir)/vm_opts.h
+objspace.o: $(top_srcdir)/vm_sync.h
objspace.o: objspace.c
objspace.o: {$(VPATH)}id.h
objspace_dump.o: $(RUBY_EXTCONF_H)
@@ -411,6 +464,7 @@ objspace_dump.o: $(hdrdir)/ruby/internal/attr/noexcept.h
objspace_dump.o: $(hdrdir)/ruby/internal/attr/noinline.h
objspace_dump.o: $(hdrdir)/ruby/internal/attr/nonnull.h
objspace_dump.o: $(hdrdir)/ruby/internal/attr/noreturn.h
+objspace_dump.o: $(hdrdir)/ruby/internal/attr/packed_struct.h
objspace_dump.o: $(hdrdir)/ruby/internal/attr/pure.h
objspace_dump.o: $(hdrdir)/ruby/internal/attr/restrict.h
objspace_dump.o: $(hdrdir)/ruby/internal/attr/returns_nonnull.h
@@ -479,7 +533,6 @@ objspace_dump.o: $(hdrdir)/ruby/internal/intern/enumerator.h
objspace_dump.o: $(hdrdir)/ruby/internal/intern/error.h
objspace_dump.o: $(hdrdir)/ruby/internal/intern/eval.h
objspace_dump.o: $(hdrdir)/ruby/internal/intern/file.h
-objspace_dump.o: $(hdrdir)/ruby/internal/intern/gc.h
objspace_dump.o: $(hdrdir)/ruby/internal/intern/hash.h
objspace_dump.o: $(hdrdir)/ruby/internal/intern/io.h
objspace_dump.o: $(hdrdir)/ruby/internal/intern/load.h
@@ -510,7 +563,6 @@ objspace_dump.o: $(hdrdir)/ruby/internal/memory.h
objspace_dump.o: $(hdrdir)/ruby/internal/method.h
objspace_dump.o: $(hdrdir)/ruby/internal/module.h
objspace_dump.o: $(hdrdir)/ruby/internal/newobj.h
-objspace_dump.o: $(hdrdir)/ruby/internal/rgengc.h
objspace_dump.o: $(hdrdir)/ruby/internal/scan_args.h
objspace_dump.o: $(hdrdir)/ruby/internal/special_consts.h
objspace_dump.o: $(hdrdir)/ruby/internal/static_assert.h
@@ -536,7 +588,7 @@ objspace_dump.o: $(top_srcdir)/ccan/container_of/container_of.h
objspace_dump.o: $(top_srcdir)/ccan/list/list.h
objspace_dump.o: $(top_srcdir)/ccan/str/str.h
objspace_dump.o: $(top_srcdir)/constant.h
-objspace_dump.o: $(top_srcdir)/gc.h
+objspace_dump.o: $(top_srcdir)/debug_counter.h
objspace_dump.o: $(top_srcdir)/id_table.h
objspace_dump.o: $(top_srcdir)/internal.h
objspace_dump.o: $(top_srcdir)/internal/array.h
@@ -546,6 +598,7 @@ objspace_dump.o: $(top_srcdir)/internal/compilers.h
objspace_dump.o: $(top_srcdir)/internal/gc.h
objspace_dump.o: $(top_srcdir)/internal/hash.h
objspace_dump.o: $(top_srcdir)/internal/imemo.h
+objspace_dump.o: $(top_srcdir)/internal/io.h
objspace_dump.o: $(top_srcdir)/internal/sanitizers.h
objspace_dump.o: $(top_srcdir)/internal/serial.h
objspace_dump.o: $(top_srcdir)/internal/static_assert.h
@@ -557,11 +610,15 @@ objspace_dump.o: $(top_srcdir)/method.h
objspace_dump.o: $(top_srcdir)/node.h
objspace_dump.o: $(top_srcdir)/ruby_assert.h
objspace_dump.o: $(top_srcdir)/ruby_atomic.h
+objspace_dump.o: $(top_srcdir)/rubyparser.h
objspace_dump.o: $(top_srcdir)/shape.h
objspace_dump.o: $(top_srcdir)/symbol.h
objspace_dump.o: $(top_srcdir)/thread_pthread.h
+objspace_dump.o: $(top_srcdir)/vm_callinfo.h
objspace_dump.o: $(top_srcdir)/vm_core.h
+objspace_dump.o: $(top_srcdir)/vm_debug.h
objspace_dump.o: $(top_srcdir)/vm_opts.h
+objspace_dump.o: $(top_srcdir)/vm_sync.h
objspace_dump.o: objspace.h
objspace_dump.o: objspace_dump.c
objspace_dump.o: {$(VPATH)}id.h
diff --git a/ext/objspace/lib/objspace.rb b/ext/objspace/lib/objspace.rb
index 6865fdda4c..47873f5112 100644
--- a/ext/objspace/lib/objspace.rb
+++ b/ext/objspace/lib/objspace.rb
@@ -11,13 +11,16 @@ module ObjectSpace
module_function
- # call-seq:
- # ObjectSpace.dump(obj[, output: :string]) -> "{ ... }"
- # ObjectSpace.dump(obj, output: :file) -> #<File:/tmp/rubyobj20131125-88733-1xkfmpv.json>
- # ObjectSpace.dump(obj, output: :stdout) -> nil
- #
# Dump the contents of a ruby object as JSON.
#
+ # _output_ can be one of: +:stdout+, +:file+, +:string+, or IO object.
+ #
+ # * +:file+ means dumping to a tempfile and returning corresponding File object;
+ # * +:stdout+ means printing the dump and returning +nil+;
+ # * +:string+ means returning a string with the dump;
+ # * if an instance of IO object is provided, the output goes there, and the object
+ # is returned.
+ #
# This method is only expected to work with C Ruby.
# This is an experimental method and is subject to change.
# In particular, the function signature and output format are
@@ -43,16 +46,11 @@ module ObjectSpace
end
- # call-seq:
- # ObjectSpace.dump_all([output: :file]) -> #<File:/tmp/rubyheap20131125-88469-laoj3v.json>
- # ObjectSpace.dump_all(output: :stdout) -> nil
- # ObjectSpace.dump_all(output: :string) -> "{...}\n{...}\n..."
- # ObjectSpace.dump_all(output: File.open('heap.json','w')) -> #<File:heap.json>
- # ObjectSpace.dump_all(output: :string, since: 42) -> "{...}\n{...}\n..."
- #
# Dump the contents of the ruby heap as JSON.
#
- # _full_ must be a boolean. If true all heap slots are dumped including the empty ones (T_NONE).
+ # _output_ argument is the same as for #dump.
+ #
+ # _full_ must be a boolean. If true, all heap slots are dumped including the empty ones (+T_NONE+).
#
# _since_ must be a non-negative integer or +nil+.
#
@@ -104,16 +102,11 @@ module ObjectSpace
ret
end
- # call-seq:
- # ObjectSpace.dump_shapes([output: :file]) -> #<File:/tmp/rubyshapes20131125-88469-laoj3v.json>
- # ObjectSpace.dump_shapes(output: :stdout) -> nil
- # ObjectSpace.dump_shapes(output: :string) -> "{...}\n{...}\n..."
- # ObjectSpace.dump_shapes(output: File.open('shapes.json','w')) -> #<File:shapes.json>
- # ObjectSpace.dump_all(output: :string, since: 42) -> "{...}\n{...}\n..."
- #
# Dump the contents of the ruby shape tree as JSON.
#
- # If _shapes_ is a positive integer, only shapes newer than the provided
+ # _output_ argument is the same as for #dump.
+ #
+ # If _since_ is a positive integer, only shapes newer than the provided
# shape id are dumped. The current shape_id can be accessed using <tt>RubyVM.stat(:next_shape_id)</tt>.
#
# This method is only expected to work with C Ruby.
diff --git a/ext/objspace/object_tracing.c b/ext/objspace/object_tracing.c
index 8c54d51eab..c1c93c51f5 100644
--- a/ext/objspace/object_tracing.c
+++ b/ext/objspace/object_tracing.c
@@ -13,8 +13,8 @@
**********************************************************************/
-#include "gc.h"
#include "internal.h"
+#include "internal/gc.h"
#include "ruby/debug.h"
#include "objspace.h"
diff --git a/ext/objspace/objspace.c b/ext/objspace/objspace.c
index 31099b8849..0a7896d5c6 100644
--- a/ext/objspace/objspace.c
+++ b/ext/objspace/objspace.c
@@ -12,14 +12,13 @@
**********************************************************************/
-#include "gc.h"
#include "internal.h"
#include "internal/class.h"
#include "internal/compilers.h"
+#include "internal/gc.h"
#include "internal/hash.h"
#include "internal/imemo.h"
#include "internal/sanitizers.h"
-#include "node.h"
#include "ruby/io.h"
#include "ruby/re.h"
#include "ruby/st.h"
@@ -337,17 +336,6 @@ count_symbols(int argc, VALUE *argv, VALUE os)
return hash;
}
-static void
-cn_i(VALUE v, void *n)
-{
- size_t *nodes = (size_t *)n;
-
- if (BUILTIN_TYPE(v) == T_NODE) {
- size_t s = nd_type((NODE *)v);
- nodes[s]++;
- }
-}
-
/*
* call-seq:
* ObjectSpace.count_nodes([result_hash]) -> hash
@@ -374,135 +362,7 @@ cn_i(VALUE v, void *n)
static VALUE
count_nodes(int argc, VALUE *argv, VALUE os)
{
- size_t nodes[NODE_LAST+1];
- enum node_type i;
- VALUE hash = setup_hash(argc, argv);
-
- for (i = 0; i <= NODE_LAST; i++) {
- nodes[i] = 0;
- }
-
- each_object_with_flags(cn_i, &nodes[0]);
-
- for (i=0; i<NODE_LAST; i++) {
- if (nodes[i] != 0) {
- VALUE node;
- switch (i) {
-#define COUNT_NODE(n) case n: node = ID2SYM(rb_intern(#n)); goto set
- COUNT_NODE(NODE_SCOPE);
- COUNT_NODE(NODE_BLOCK);
- COUNT_NODE(NODE_IF);
- COUNT_NODE(NODE_UNLESS);
- COUNT_NODE(NODE_CASE);
- COUNT_NODE(NODE_CASE2);
- COUNT_NODE(NODE_CASE3);
- COUNT_NODE(NODE_WHEN);
- COUNT_NODE(NODE_IN);
- COUNT_NODE(NODE_WHILE);
- COUNT_NODE(NODE_UNTIL);
- COUNT_NODE(NODE_ITER);
- COUNT_NODE(NODE_FOR);
- COUNT_NODE(NODE_FOR_MASGN);
- COUNT_NODE(NODE_BREAK);
- COUNT_NODE(NODE_NEXT);
- COUNT_NODE(NODE_REDO);
- COUNT_NODE(NODE_RETRY);
- COUNT_NODE(NODE_BEGIN);
- COUNT_NODE(NODE_RESCUE);
- COUNT_NODE(NODE_RESBODY);
- COUNT_NODE(NODE_ENSURE);
- COUNT_NODE(NODE_AND);
- COUNT_NODE(NODE_OR);
- COUNT_NODE(NODE_MASGN);
- COUNT_NODE(NODE_LASGN);
- COUNT_NODE(NODE_DASGN);
- COUNT_NODE(NODE_GASGN);
- COUNT_NODE(NODE_IASGN);
- COUNT_NODE(NODE_CDECL);
- COUNT_NODE(NODE_CVASGN);
- COUNT_NODE(NODE_OP_ASGN1);
- COUNT_NODE(NODE_OP_ASGN2);
- COUNT_NODE(NODE_OP_ASGN_AND);
- COUNT_NODE(NODE_OP_ASGN_OR);
- COUNT_NODE(NODE_OP_CDECL);
- COUNT_NODE(NODE_CALL);
- COUNT_NODE(NODE_OPCALL);
- COUNT_NODE(NODE_FCALL);
- COUNT_NODE(NODE_VCALL);
- COUNT_NODE(NODE_QCALL);
- COUNT_NODE(NODE_SUPER);
- COUNT_NODE(NODE_ZSUPER);
- COUNT_NODE(NODE_LIST);
- COUNT_NODE(NODE_ZLIST);
- COUNT_NODE(NODE_VALUES);
- COUNT_NODE(NODE_HASH);
- COUNT_NODE(NODE_RETURN);
- COUNT_NODE(NODE_YIELD);
- COUNT_NODE(NODE_LVAR);
- COUNT_NODE(NODE_DVAR);
- COUNT_NODE(NODE_GVAR);
- COUNT_NODE(NODE_IVAR);
- COUNT_NODE(NODE_CONST);
- COUNT_NODE(NODE_CVAR);
- COUNT_NODE(NODE_NTH_REF);
- COUNT_NODE(NODE_BACK_REF);
- COUNT_NODE(NODE_MATCH);
- COUNT_NODE(NODE_MATCH2);
- COUNT_NODE(NODE_MATCH3);
- COUNT_NODE(NODE_LIT);
- COUNT_NODE(NODE_STR);
- COUNT_NODE(NODE_DSTR);
- COUNT_NODE(NODE_XSTR);
- COUNT_NODE(NODE_DXSTR);
- COUNT_NODE(NODE_EVSTR);
- COUNT_NODE(NODE_DREGX);
- COUNT_NODE(NODE_ONCE);
- COUNT_NODE(NODE_ARGS);
- COUNT_NODE(NODE_ARGS_AUX);
- COUNT_NODE(NODE_OPT_ARG);
- COUNT_NODE(NODE_KW_ARG);
- COUNT_NODE(NODE_POSTARG);
- COUNT_NODE(NODE_ARGSCAT);
- COUNT_NODE(NODE_ARGSPUSH);
- COUNT_NODE(NODE_SPLAT);
- COUNT_NODE(NODE_BLOCK_PASS);
- COUNT_NODE(NODE_DEFN);
- COUNT_NODE(NODE_DEFS);
- COUNT_NODE(NODE_ALIAS);
- COUNT_NODE(NODE_VALIAS);
- COUNT_NODE(NODE_UNDEF);
- COUNT_NODE(NODE_CLASS);
- COUNT_NODE(NODE_MODULE);
- COUNT_NODE(NODE_SCLASS);
- COUNT_NODE(NODE_COLON2);
- COUNT_NODE(NODE_COLON3);
- COUNT_NODE(NODE_DOT2);
- COUNT_NODE(NODE_DOT3);
- COUNT_NODE(NODE_FLIP2);
- COUNT_NODE(NODE_FLIP3);
- COUNT_NODE(NODE_SELF);
- COUNT_NODE(NODE_NIL);
- COUNT_NODE(NODE_TRUE);
- COUNT_NODE(NODE_FALSE);
- COUNT_NODE(NODE_ERRINFO);
- COUNT_NODE(NODE_DEFINED);
- COUNT_NODE(NODE_POSTEXE);
- COUNT_NODE(NODE_DSYM);
- COUNT_NODE(NODE_ATTRASGN);
- COUNT_NODE(NODE_LAMBDA);
- COUNT_NODE(NODE_ARYPTN);
- COUNT_NODE(NODE_FNDPTN);
- COUNT_NODE(NODE_HSHPTN);
- COUNT_NODE(NODE_ERROR);
-#undef COUNT_NODE
- case NODE_LAST: break;
- }
- UNREACHABLE;
- set:
- rb_hash_aset(hash, node, SIZET2NUM(nodes[i]));
- }
- }
- return hash;
+ return setup_hash(argc, argv);
}
static void
diff --git a/ext/objspace/objspace_dump.c b/ext/objspace/objspace_dump.c
index f101b334c1..866a49eff4 100644
--- a/ext/objspace/objspace_dump.c
+++ b/ext/objspace/objspace_dump.c
@@ -12,12 +12,13 @@
**********************************************************************/
-#include "gc.h"
#include "id_table.h"
#include "internal.h"
#include "internal/array.h"
#include "internal/class.h"
+#include "internal/gc.h"
#include "internal/hash.h"
+#include "internal/io.h"
#include "internal/string.h"
#include "internal/sanitizers.h"
#include "symbol.h"
@@ -27,6 +28,7 @@
#include "ruby/debug.h"
#include "ruby/util.h"
#include "ruby/io.h"
+#include "vm_callinfo.h"
#include "vm_core.h"
RUBY_EXTERN const char ruby_hexdigits[];
@@ -166,10 +168,8 @@ dump_append_c(struct dump_config *dc, unsigned char c)
}
static void
-dump_append_ref(struct dump_config *dc, VALUE ref)
+dump_append_ptr(struct dump_config *dc, VALUE ref)
{
- RUBY_ASSERT(ref > 0);
-
char buffer[roomof(sizeof(VALUE) * CHAR_BIT, 4) + rb_strlen_lit("\"0x\"")];
char *buffer_start, *buffer_end;
@@ -186,6 +186,14 @@ dump_append_ref(struct dump_config *dc, VALUE ref)
}
static void
+dump_append_ref(struct dump_config *dc, VALUE ref)
+{
+ RUBY_ASSERT(ref > 0);
+ dump_append_ptr(dc, ref);
+}
+
+
+static void
dump_append_string_value(struct dump_config *dc, VALUE obj)
{
long i;
@@ -358,8 +366,9 @@ dump_append_string_content(struct dump_config *dc, VALUE obj)
static inline void
dump_append_id(struct dump_config *dc, ID id)
{
- if (is_instance_id(id)) {
- dump_append_string_value(dc, rb_sym2str(ID2SYM(id)));
+ VALUE str = rb_sym2str(ID2SYM(id));
+ if (RTEST(str)) {
+ dump_append_string_value(dc, str);
}
else {
dump_append(dc, "\"ID_INTERNAL(");
@@ -377,6 +386,7 @@ dump_object(VALUE obj, struct dump_config *dc)
rb_io_t *fptr;
ID flags[RB_OBJ_GC_FLAGS_MAX];
size_t n, i;
+ ID mid;
if (SPECIAL_CONST_P(obj)) {
dump_append_special_const(dc, obj);
@@ -428,6 +438,33 @@ dump_object(VALUE obj, struct dump_config *dc)
dump_append(dc, ", \"imemo_type\":\"");
dump_append(dc, rb_imemo_name(imemo_type(obj)));
dump_append(dc, "\"");
+
+ switch (imemo_type(obj)) {
+ case imemo_callinfo:
+ mid = vm_ci_mid((const struct rb_callinfo *)obj);
+ if (mid != 0) {
+ dump_append(dc, ", \"mid\":");
+ dump_append_id(dc, mid);
+ }
+ break;
+
+ case imemo_callcache:
+ mid = vm_cc_cme((const struct rb_callcache *)obj)->called_id;
+ if (mid != 0) {
+ dump_append(dc, ", \"called_id\":");
+ dump_append_id(dc, mid);
+
+ VALUE klass = ((const struct rb_callcache *)obj)->klass;
+ if (klass != 0) {
+ dump_append(dc, ", \"receiver_class\":");
+ dump_append_ref(dc, klass);
+ }
+ }
+ break;
+
+ default:
+ break;
+ }
break;
case T_SYMBOL:
@@ -755,16 +792,6 @@ shape_i(rb_shape_t *shape, void *data)
case SHAPE_FROZEN:
dump_append(dc, "\"FROZEN\"");
break;
- case SHAPE_CAPACITY_CHANGE:
- dump_append(dc, "\"CAPACITY_CHANGE\"");
- dump_append(dc, ", \"capacity\":");
- dump_append_sizet(dc, shape->capacity);
- break;
- case SHAPE_INITIAL_CAPACITY:
- dump_append(dc, "\"INITIAL_CAPACITY\"");
- dump_append(dc, ", \"capacity\":");
- dump_append_sizet(dc, shape->capacity);
- break;
case SHAPE_T_OBJECT:
dump_append(dc, "\"T_OBJECT\"");
break;
diff --git a/ext/openssl/History.md b/ext/openssl/History.md
index 1e0df7dd87..3249f6617a 100644
--- a/ext/openssl/History.md
+++ b/ext/openssl/History.md
@@ -1,3 +1,43 @@
+Version 3.2.0
+=============
+
+Compatibility
+-------------
+
+* Ruby >= 2.7
+ - Support for Ruby 2.6 has been removed. Note that Ruby 2.6 reached the
+ end-of-life in 2022-04.
+ [[GitHub #639]](https://github.com/ruby/openssl/pull/639)
+* OpenSSL >= 1.0.2 or LibreSSL >= 3.1
+
+Notable changes
+---------------
+
+* Add a stub gemspec for JRuby, which depends on the `jruby-openssl` gem.
+ [[GitHub #598]](https://github.com/ruby/openssl/pull/598)
+* Add support for the FIPS module in OpenSSL 3.0/3.1.
+ [[GitHub #608]](https://github.com/ruby/openssl/pull/608)
+* Rework `OpenSSL::PKey` routines for loading DER or PEM encoded keys for better
+ compatibility with OpenSSL 3.0/3.1 with the FIPS module.
+ [[GitHub #615]](https://github.com/ruby/openssl/pull/615)
+ [[GitHub #669]](https://github.com/ruby/openssl/pull/669)
+* Add `OpenSSL::Provider` module for loading and unloading OpenSSL 3 providers.
+ [[GitHub #635]](https://github.com/ruby/openssl/pull/635)
+* Add `OpenSSL::PKey.new_raw_private_key`, `.new_raw_public_key`,
+ `OpenSSL::PKey::PKey#raw_private_key`, and `#raw_public_key` for public key
+ algorithms that use "raw private/public key", such as X25519 and Ed25519.
+ [[GitHub #646]](https://github.com/ruby/openssl/pull/646)
+* Improve OpenSSL error messages to include additional information when
+ it is available in OpenSSL's error queue.
+ [[GitHub #648]](https://github.com/ruby/openssl/pull/648)
+* Change `OpenSSL::SSL::SSLContext#ca_file=` and `#ca_path=` to raise
+ `OpenSSL::SSL::SSLError` instead of printing a warning message.
+ [[GitHub #659]](https://github.com/ruby/openssl/pull/659)
+* Allow `OpenSSL::X509::ExtensionFactory#create_extension` to take OIDs in the
+ dotted-decimal notation.
+ [[GitHub #141]](https://github.com/ruby/openssl/pull/141)
+
+
Version 3.1.0
=============
@@ -417,7 +457,7 @@ Security fixes
Bug fixes
---------
-* Fixed OpenSSL::PKey::*.{new,generate} immediately aborting if the thread is
+* Fixed OpenSSL::PKey::\*.{new,generate} immediately aborting if the thread is
interrupted.
[[Bug #14882]](https://bugs.ruby-lang.org/issues/14882)
[[GitHub #205]](https://github.com/ruby/openssl/pull/205)
diff --git a/ext/openssl/depend b/ext/openssl/depend
index c38d224c85..0d03c85b80 100644
--- a/ext/openssl/depend
+++ b/ext/openssl/depend
@@ -57,6 +57,7 @@ ossl.o: $(hdrdir)/ruby/internal/attr/noexcept.h
ossl.o: $(hdrdir)/ruby/internal/attr/noinline.h
ossl.o: $(hdrdir)/ruby/internal/attr/nonnull.h
ossl.o: $(hdrdir)/ruby/internal/attr/noreturn.h
+ossl.o: $(hdrdir)/ruby/internal/attr/packed_struct.h
ossl.o: $(hdrdir)/ruby/internal/attr/pure.h
ossl.o: $(hdrdir)/ruby/internal/attr/restrict.h
ossl.o: $(hdrdir)/ruby/internal/attr/returns_nonnull.h
@@ -125,7 +126,6 @@ ossl.o: $(hdrdir)/ruby/internal/intern/enumerator.h
ossl.o: $(hdrdir)/ruby/internal/intern/error.h
ossl.o: $(hdrdir)/ruby/internal/intern/eval.h
ossl.o: $(hdrdir)/ruby/internal/intern/file.h
-ossl.o: $(hdrdir)/ruby/internal/intern/gc.h
ossl.o: $(hdrdir)/ruby/internal/intern/hash.h
ossl.o: $(hdrdir)/ruby/internal/intern/io.h
ossl.o: $(hdrdir)/ruby/internal/intern/load.h
@@ -156,7 +156,6 @@ ossl.o: $(hdrdir)/ruby/internal/memory.h
ossl.o: $(hdrdir)/ruby/internal/method.h
ossl.o: $(hdrdir)/ruby/internal/module.h
ossl.o: $(hdrdir)/ruby/internal/newobj.h
-ossl.o: $(hdrdir)/ruby/internal/rgengc.h
ossl.o: $(hdrdir)/ruby/internal/scan_args.h
ossl.o: $(hdrdir)/ruby/internal/special_consts.h
ossl.o: $(hdrdir)/ruby/internal/static_assert.h
@@ -193,6 +192,7 @@ ossl.o: ossl_ocsp.h
ossl.o: ossl_pkcs12.h
ossl.o: ossl_pkcs7.h
ossl.o: ossl_pkey.h
+ossl.o: ossl_provider.h
ossl.o: ossl_rand.h
ossl.o: ossl_ssl.h
ossl.o: ossl_ts.h
@@ -251,6 +251,7 @@ ossl_asn1.o: $(hdrdir)/ruby/internal/attr/noexcept.h
ossl_asn1.o: $(hdrdir)/ruby/internal/attr/noinline.h
ossl_asn1.o: $(hdrdir)/ruby/internal/attr/nonnull.h
ossl_asn1.o: $(hdrdir)/ruby/internal/attr/noreturn.h
+ossl_asn1.o: $(hdrdir)/ruby/internal/attr/packed_struct.h
ossl_asn1.o: $(hdrdir)/ruby/internal/attr/pure.h
ossl_asn1.o: $(hdrdir)/ruby/internal/attr/restrict.h
ossl_asn1.o: $(hdrdir)/ruby/internal/attr/returns_nonnull.h
@@ -319,7 +320,6 @@ ossl_asn1.o: $(hdrdir)/ruby/internal/intern/enumerator.h
ossl_asn1.o: $(hdrdir)/ruby/internal/intern/error.h
ossl_asn1.o: $(hdrdir)/ruby/internal/intern/eval.h
ossl_asn1.o: $(hdrdir)/ruby/internal/intern/file.h
-ossl_asn1.o: $(hdrdir)/ruby/internal/intern/gc.h
ossl_asn1.o: $(hdrdir)/ruby/internal/intern/hash.h
ossl_asn1.o: $(hdrdir)/ruby/internal/intern/io.h
ossl_asn1.o: $(hdrdir)/ruby/internal/intern/load.h
@@ -350,7 +350,6 @@ ossl_asn1.o: $(hdrdir)/ruby/internal/memory.h
ossl_asn1.o: $(hdrdir)/ruby/internal/method.h
ossl_asn1.o: $(hdrdir)/ruby/internal/module.h
ossl_asn1.o: $(hdrdir)/ruby/internal/newobj.h
-ossl_asn1.o: $(hdrdir)/ruby/internal/rgengc.h
ossl_asn1.o: $(hdrdir)/ruby/internal/scan_args.h
ossl_asn1.o: $(hdrdir)/ruby/internal/special_consts.h
ossl_asn1.o: $(hdrdir)/ruby/internal/static_assert.h
@@ -387,6 +386,7 @@ ossl_asn1.o: ossl_ocsp.h
ossl_asn1.o: ossl_pkcs12.h
ossl_asn1.o: ossl_pkcs7.h
ossl_asn1.o: ossl_pkey.h
+ossl_asn1.o: ossl_provider.h
ossl_asn1.o: ossl_rand.h
ossl_asn1.o: ossl_ssl.h
ossl_asn1.o: ossl_ts.h
@@ -445,6 +445,7 @@ ossl_bio.o: $(hdrdir)/ruby/internal/attr/noexcept.h
ossl_bio.o: $(hdrdir)/ruby/internal/attr/noinline.h
ossl_bio.o: $(hdrdir)/ruby/internal/attr/nonnull.h
ossl_bio.o: $(hdrdir)/ruby/internal/attr/noreturn.h
+ossl_bio.o: $(hdrdir)/ruby/internal/attr/packed_struct.h
ossl_bio.o: $(hdrdir)/ruby/internal/attr/pure.h
ossl_bio.o: $(hdrdir)/ruby/internal/attr/restrict.h
ossl_bio.o: $(hdrdir)/ruby/internal/attr/returns_nonnull.h
@@ -513,7 +514,6 @@ ossl_bio.o: $(hdrdir)/ruby/internal/intern/enumerator.h
ossl_bio.o: $(hdrdir)/ruby/internal/intern/error.h
ossl_bio.o: $(hdrdir)/ruby/internal/intern/eval.h
ossl_bio.o: $(hdrdir)/ruby/internal/intern/file.h
-ossl_bio.o: $(hdrdir)/ruby/internal/intern/gc.h
ossl_bio.o: $(hdrdir)/ruby/internal/intern/hash.h
ossl_bio.o: $(hdrdir)/ruby/internal/intern/io.h
ossl_bio.o: $(hdrdir)/ruby/internal/intern/load.h
@@ -544,7 +544,6 @@ ossl_bio.o: $(hdrdir)/ruby/internal/memory.h
ossl_bio.o: $(hdrdir)/ruby/internal/method.h
ossl_bio.o: $(hdrdir)/ruby/internal/module.h
ossl_bio.o: $(hdrdir)/ruby/internal/newobj.h
-ossl_bio.o: $(hdrdir)/ruby/internal/rgengc.h
ossl_bio.o: $(hdrdir)/ruby/internal/scan_args.h
ossl_bio.o: $(hdrdir)/ruby/internal/special_consts.h
ossl_bio.o: $(hdrdir)/ruby/internal/static_assert.h
@@ -581,6 +580,7 @@ ossl_bio.o: ossl_ocsp.h
ossl_bio.o: ossl_pkcs12.h
ossl_bio.o: ossl_pkcs7.h
ossl_bio.o: ossl_pkey.h
+ossl_bio.o: ossl_provider.h
ossl_bio.o: ossl_rand.h
ossl_bio.o: ossl_ssl.h
ossl_bio.o: ossl_ts.h
@@ -639,6 +639,7 @@ ossl_bn.o: $(hdrdir)/ruby/internal/attr/noexcept.h
ossl_bn.o: $(hdrdir)/ruby/internal/attr/noinline.h
ossl_bn.o: $(hdrdir)/ruby/internal/attr/nonnull.h
ossl_bn.o: $(hdrdir)/ruby/internal/attr/noreturn.h
+ossl_bn.o: $(hdrdir)/ruby/internal/attr/packed_struct.h
ossl_bn.o: $(hdrdir)/ruby/internal/attr/pure.h
ossl_bn.o: $(hdrdir)/ruby/internal/attr/restrict.h
ossl_bn.o: $(hdrdir)/ruby/internal/attr/returns_nonnull.h
@@ -707,7 +708,6 @@ ossl_bn.o: $(hdrdir)/ruby/internal/intern/enumerator.h
ossl_bn.o: $(hdrdir)/ruby/internal/intern/error.h
ossl_bn.o: $(hdrdir)/ruby/internal/intern/eval.h
ossl_bn.o: $(hdrdir)/ruby/internal/intern/file.h
-ossl_bn.o: $(hdrdir)/ruby/internal/intern/gc.h
ossl_bn.o: $(hdrdir)/ruby/internal/intern/hash.h
ossl_bn.o: $(hdrdir)/ruby/internal/intern/io.h
ossl_bn.o: $(hdrdir)/ruby/internal/intern/load.h
@@ -738,7 +738,6 @@ ossl_bn.o: $(hdrdir)/ruby/internal/memory.h
ossl_bn.o: $(hdrdir)/ruby/internal/method.h
ossl_bn.o: $(hdrdir)/ruby/internal/module.h
ossl_bn.o: $(hdrdir)/ruby/internal/newobj.h
-ossl_bn.o: $(hdrdir)/ruby/internal/rgengc.h
ossl_bn.o: $(hdrdir)/ruby/internal/scan_args.h
ossl_bn.o: $(hdrdir)/ruby/internal/special_consts.h
ossl_bn.o: $(hdrdir)/ruby/internal/static_assert.h
@@ -776,6 +775,7 @@ ossl_bn.o: ossl_ocsp.h
ossl_bn.o: ossl_pkcs12.h
ossl_bn.o: ossl_pkcs7.h
ossl_bn.o: ossl_pkey.h
+ossl_bn.o: ossl_provider.h
ossl_bn.o: ossl_rand.h
ossl_bn.o: ossl_ssl.h
ossl_bn.o: ossl_ts.h
@@ -834,6 +834,7 @@ ossl_cipher.o: $(hdrdir)/ruby/internal/attr/noexcept.h
ossl_cipher.o: $(hdrdir)/ruby/internal/attr/noinline.h
ossl_cipher.o: $(hdrdir)/ruby/internal/attr/nonnull.h
ossl_cipher.o: $(hdrdir)/ruby/internal/attr/noreturn.h
+ossl_cipher.o: $(hdrdir)/ruby/internal/attr/packed_struct.h
ossl_cipher.o: $(hdrdir)/ruby/internal/attr/pure.h
ossl_cipher.o: $(hdrdir)/ruby/internal/attr/restrict.h
ossl_cipher.o: $(hdrdir)/ruby/internal/attr/returns_nonnull.h
@@ -902,7 +903,6 @@ ossl_cipher.o: $(hdrdir)/ruby/internal/intern/enumerator.h
ossl_cipher.o: $(hdrdir)/ruby/internal/intern/error.h
ossl_cipher.o: $(hdrdir)/ruby/internal/intern/eval.h
ossl_cipher.o: $(hdrdir)/ruby/internal/intern/file.h
-ossl_cipher.o: $(hdrdir)/ruby/internal/intern/gc.h
ossl_cipher.o: $(hdrdir)/ruby/internal/intern/hash.h
ossl_cipher.o: $(hdrdir)/ruby/internal/intern/io.h
ossl_cipher.o: $(hdrdir)/ruby/internal/intern/load.h
@@ -933,7 +933,6 @@ ossl_cipher.o: $(hdrdir)/ruby/internal/memory.h
ossl_cipher.o: $(hdrdir)/ruby/internal/method.h
ossl_cipher.o: $(hdrdir)/ruby/internal/module.h
ossl_cipher.o: $(hdrdir)/ruby/internal/newobj.h
-ossl_cipher.o: $(hdrdir)/ruby/internal/rgengc.h
ossl_cipher.o: $(hdrdir)/ruby/internal/scan_args.h
ossl_cipher.o: $(hdrdir)/ruby/internal/special_consts.h
ossl_cipher.o: $(hdrdir)/ruby/internal/static_assert.h
@@ -970,6 +969,7 @@ ossl_cipher.o: ossl_ocsp.h
ossl_cipher.o: ossl_pkcs12.h
ossl_cipher.o: ossl_pkcs7.h
ossl_cipher.o: ossl_pkey.h
+ossl_cipher.o: ossl_provider.h
ossl_cipher.o: ossl_rand.h
ossl_cipher.o: ossl_ssl.h
ossl_cipher.o: ossl_ts.h
@@ -1028,6 +1028,7 @@ ossl_config.o: $(hdrdir)/ruby/internal/attr/noexcept.h
ossl_config.o: $(hdrdir)/ruby/internal/attr/noinline.h
ossl_config.o: $(hdrdir)/ruby/internal/attr/nonnull.h
ossl_config.o: $(hdrdir)/ruby/internal/attr/noreturn.h
+ossl_config.o: $(hdrdir)/ruby/internal/attr/packed_struct.h
ossl_config.o: $(hdrdir)/ruby/internal/attr/pure.h
ossl_config.o: $(hdrdir)/ruby/internal/attr/restrict.h
ossl_config.o: $(hdrdir)/ruby/internal/attr/returns_nonnull.h
@@ -1096,7 +1097,6 @@ ossl_config.o: $(hdrdir)/ruby/internal/intern/enumerator.h
ossl_config.o: $(hdrdir)/ruby/internal/intern/error.h
ossl_config.o: $(hdrdir)/ruby/internal/intern/eval.h
ossl_config.o: $(hdrdir)/ruby/internal/intern/file.h
-ossl_config.o: $(hdrdir)/ruby/internal/intern/gc.h
ossl_config.o: $(hdrdir)/ruby/internal/intern/hash.h
ossl_config.o: $(hdrdir)/ruby/internal/intern/io.h
ossl_config.o: $(hdrdir)/ruby/internal/intern/load.h
@@ -1127,7 +1127,6 @@ ossl_config.o: $(hdrdir)/ruby/internal/memory.h
ossl_config.o: $(hdrdir)/ruby/internal/method.h
ossl_config.o: $(hdrdir)/ruby/internal/module.h
ossl_config.o: $(hdrdir)/ruby/internal/newobj.h
-ossl_config.o: $(hdrdir)/ruby/internal/rgengc.h
ossl_config.o: $(hdrdir)/ruby/internal/scan_args.h
ossl_config.o: $(hdrdir)/ruby/internal/special_consts.h
ossl_config.o: $(hdrdir)/ruby/internal/static_assert.h
@@ -1164,6 +1163,7 @@ ossl_config.o: ossl_ocsp.h
ossl_config.o: ossl_pkcs12.h
ossl_config.o: ossl_pkcs7.h
ossl_config.o: ossl_pkey.h
+ossl_config.o: ossl_provider.h
ossl_config.o: ossl_rand.h
ossl_config.o: ossl_ssl.h
ossl_config.o: ossl_ts.h
@@ -1222,6 +1222,7 @@ ossl_digest.o: $(hdrdir)/ruby/internal/attr/noexcept.h
ossl_digest.o: $(hdrdir)/ruby/internal/attr/noinline.h
ossl_digest.o: $(hdrdir)/ruby/internal/attr/nonnull.h
ossl_digest.o: $(hdrdir)/ruby/internal/attr/noreturn.h
+ossl_digest.o: $(hdrdir)/ruby/internal/attr/packed_struct.h
ossl_digest.o: $(hdrdir)/ruby/internal/attr/pure.h
ossl_digest.o: $(hdrdir)/ruby/internal/attr/restrict.h
ossl_digest.o: $(hdrdir)/ruby/internal/attr/returns_nonnull.h
@@ -1290,7 +1291,6 @@ ossl_digest.o: $(hdrdir)/ruby/internal/intern/enumerator.h
ossl_digest.o: $(hdrdir)/ruby/internal/intern/error.h
ossl_digest.o: $(hdrdir)/ruby/internal/intern/eval.h
ossl_digest.o: $(hdrdir)/ruby/internal/intern/file.h
-ossl_digest.o: $(hdrdir)/ruby/internal/intern/gc.h
ossl_digest.o: $(hdrdir)/ruby/internal/intern/hash.h
ossl_digest.o: $(hdrdir)/ruby/internal/intern/io.h
ossl_digest.o: $(hdrdir)/ruby/internal/intern/load.h
@@ -1321,7 +1321,6 @@ ossl_digest.o: $(hdrdir)/ruby/internal/memory.h
ossl_digest.o: $(hdrdir)/ruby/internal/method.h
ossl_digest.o: $(hdrdir)/ruby/internal/module.h
ossl_digest.o: $(hdrdir)/ruby/internal/newobj.h
-ossl_digest.o: $(hdrdir)/ruby/internal/rgengc.h
ossl_digest.o: $(hdrdir)/ruby/internal/scan_args.h
ossl_digest.o: $(hdrdir)/ruby/internal/special_consts.h
ossl_digest.o: $(hdrdir)/ruby/internal/static_assert.h
@@ -1358,6 +1357,7 @@ ossl_digest.o: ossl_ocsp.h
ossl_digest.o: ossl_pkcs12.h
ossl_digest.o: ossl_pkcs7.h
ossl_digest.o: ossl_pkey.h
+ossl_digest.o: ossl_provider.h
ossl_digest.o: ossl_rand.h
ossl_digest.o: ossl_ssl.h
ossl_digest.o: ossl_ts.h
@@ -1416,6 +1416,7 @@ ossl_engine.o: $(hdrdir)/ruby/internal/attr/noexcept.h
ossl_engine.o: $(hdrdir)/ruby/internal/attr/noinline.h
ossl_engine.o: $(hdrdir)/ruby/internal/attr/nonnull.h
ossl_engine.o: $(hdrdir)/ruby/internal/attr/noreturn.h
+ossl_engine.o: $(hdrdir)/ruby/internal/attr/packed_struct.h
ossl_engine.o: $(hdrdir)/ruby/internal/attr/pure.h
ossl_engine.o: $(hdrdir)/ruby/internal/attr/restrict.h
ossl_engine.o: $(hdrdir)/ruby/internal/attr/returns_nonnull.h
@@ -1484,7 +1485,6 @@ ossl_engine.o: $(hdrdir)/ruby/internal/intern/enumerator.h
ossl_engine.o: $(hdrdir)/ruby/internal/intern/error.h
ossl_engine.o: $(hdrdir)/ruby/internal/intern/eval.h
ossl_engine.o: $(hdrdir)/ruby/internal/intern/file.h
-ossl_engine.o: $(hdrdir)/ruby/internal/intern/gc.h
ossl_engine.o: $(hdrdir)/ruby/internal/intern/hash.h
ossl_engine.o: $(hdrdir)/ruby/internal/intern/io.h
ossl_engine.o: $(hdrdir)/ruby/internal/intern/load.h
@@ -1515,7 +1515,6 @@ ossl_engine.o: $(hdrdir)/ruby/internal/memory.h
ossl_engine.o: $(hdrdir)/ruby/internal/method.h
ossl_engine.o: $(hdrdir)/ruby/internal/module.h
ossl_engine.o: $(hdrdir)/ruby/internal/newobj.h
-ossl_engine.o: $(hdrdir)/ruby/internal/rgengc.h
ossl_engine.o: $(hdrdir)/ruby/internal/scan_args.h
ossl_engine.o: $(hdrdir)/ruby/internal/special_consts.h
ossl_engine.o: $(hdrdir)/ruby/internal/static_assert.h
@@ -1552,6 +1551,7 @@ ossl_engine.o: ossl_ocsp.h
ossl_engine.o: ossl_pkcs12.h
ossl_engine.o: ossl_pkcs7.h
ossl_engine.o: ossl_pkey.h
+ossl_engine.o: ossl_provider.h
ossl_engine.o: ossl_rand.h
ossl_engine.o: ossl_ssl.h
ossl_engine.o: ossl_ts.h
@@ -1610,6 +1610,7 @@ ossl_hmac.o: $(hdrdir)/ruby/internal/attr/noexcept.h
ossl_hmac.o: $(hdrdir)/ruby/internal/attr/noinline.h
ossl_hmac.o: $(hdrdir)/ruby/internal/attr/nonnull.h
ossl_hmac.o: $(hdrdir)/ruby/internal/attr/noreturn.h
+ossl_hmac.o: $(hdrdir)/ruby/internal/attr/packed_struct.h
ossl_hmac.o: $(hdrdir)/ruby/internal/attr/pure.h
ossl_hmac.o: $(hdrdir)/ruby/internal/attr/restrict.h
ossl_hmac.o: $(hdrdir)/ruby/internal/attr/returns_nonnull.h
@@ -1678,7 +1679,6 @@ ossl_hmac.o: $(hdrdir)/ruby/internal/intern/enumerator.h
ossl_hmac.o: $(hdrdir)/ruby/internal/intern/error.h
ossl_hmac.o: $(hdrdir)/ruby/internal/intern/eval.h
ossl_hmac.o: $(hdrdir)/ruby/internal/intern/file.h
-ossl_hmac.o: $(hdrdir)/ruby/internal/intern/gc.h
ossl_hmac.o: $(hdrdir)/ruby/internal/intern/hash.h
ossl_hmac.o: $(hdrdir)/ruby/internal/intern/io.h
ossl_hmac.o: $(hdrdir)/ruby/internal/intern/load.h
@@ -1709,7 +1709,6 @@ ossl_hmac.o: $(hdrdir)/ruby/internal/memory.h
ossl_hmac.o: $(hdrdir)/ruby/internal/method.h
ossl_hmac.o: $(hdrdir)/ruby/internal/module.h
ossl_hmac.o: $(hdrdir)/ruby/internal/newobj.h
-ossl_hmac.o: $(hdrdir)/ruby/internal/rgengc.h
ossl_hmac.o: $(hdrdir)/ruby/internal/scan_args.h
ossl_hmac.o: $(hdrdir)/ruby/internal/special_consts.h
ossl_hmac.o: $(hdrdir)/ruby/internal/static_assert.h
@@ -1746,6 +1745,7 @@ ossl_hmac.o: ossl_ocsp.h
ossl_hmac.o: ossl_pkcs12.h
ossl_hmac.o: ossl_pkcs7.h
ossl_hmac.o: ossl_pkey.h
+ossl_hmac.o: ossl_provider.h
ossl_hmac.o: ossl_rand.h
ossl_hmac.o: ossl_ssl.h
ossl_hmac.o: ossl_ts.h
@@ -1804,6 +1804,7 @@ ossl_kdf.o: $(hdrdir)/ruby/internal/attr/noexcept.h
ossl_kdf.o: $(hdrdir)/ruby/internal/attr/noinline.h
ossl_kdf.o: $(hdrdir)/ruby/internal/attr/nonnull.h
ossl_kdf.o: $(hdrdir)/ruby/internal/attr/noreturn.h
+ossl_kdf.o: $(hdrdir)/ruby/internal/attr/packed_struct.h
ossl_kdf.o: $(hdrdir)/ruby/internal/attr/pure.h
ossl_kdf.o: $(hdrdir)/ruby/internal/attr/restrict.h
ossl_kdf.o: $(hdrdir)/ruby/internal/attr/returns_nonnull.h
@@ -1872,7 +1873,6 @@ ossl_kdf.o: $(hdrdir)/ruby/internal/intern/enumerator.h
ossl_kdf.o: $(hdrdir)/ruby/internal/intern/error.h
ossl_kdf.o: $(hdrdir)/ruby/internal/intern/eval.h
ossl_kdf.o: $(hdrdir)/ruby/internal/intern/file.h
-ossl_kdf.o: $(hdrdir)/ruby/internal/intern/gc.h
ossl_kdf.o: $(hdrdir)/ruby/internal/intern/hash.h
ossl_kdf.o: $(hdrdir)/ruby/internal/intern/io.h
ossl_kdf.o: $(hdrdir)/ruby/internal/intern/load.h
@@ -1903,7 +1903,6 @@ ossl_kdf.o: $(hdrdir)/ruby/internal/memory.h
ossl_kdf.o: $(hdrdir)/ruby/internal/method.h
ossl_kdf.o: $(hdrdir)/ruby/internal/module.h
ossl_kdf.o: $(hdrdir)/ruby/internal/newobj.h
-ossl_kdf.o: $(hdrdir)/ruby/internal/rgengc.h
ossl_kdf.o: $(hdrdir)/ruby/internal/scan_args.h
ossl_kdf.o: $(hdrdir)/ruby/internal/special_consts.h
ossl_kdf.o: $(hdrdir)/ruby/internal/static_assert.h
@@ -1940,6 +1939,7 @@ ossl_kdf.o: ossl_ocsp.h
ossl_kdf.o: ossl_pkcs12.h
ossl_kdf.o: ossl_pkcs7.h
ossl_kdf.o: ossl_pkey.h
+ossl_kdf.o: ossl_provider.h
ossl_kdf.o: ossl_rand.h
ossl_kdf.o: ossl_ssl.h
ossl_kdf.o: ossl_ts.h
@@ -1998,6 +1998,7 @@ ossl_ns_spki.o: $(hdrdir)/ruby/internal/attr/noexcept.h
ossl_ns_spki.o: $(hdrdir)/ruby/internal/attr/noinline.h
ossl_ns_spki.o: $(hdrdir)/ruby/internal/attr/nonnull.h
ossl_ns_spki.o: $(hdrdir)/ruby/internal/attr/noreturn.h
+ossl_ns_spki.o: $(hdrdir)/ruby/internal/attr/packed_struct.h
ossl_ns_spki.o: $(hdrdir)/ruby/internal/attr/pure.h
ossl_ns_spki.o: $(hdrdir)/ruby/internal/attr/restrict.h
ossl_ns_spki.o: $(hdrdir)/ruby/internal/attr/returns_nonnull.h
@@ -2066,7 +2067,6 @@ ossl_ns_spki.o: $(hdrdir)/ruby/internal/intern/enumerator.h
ossl_ns_spki.o: $(hdrdir)/ruby/internal/intern/error.h
ossl_ns_spki.o: $(hdrdir)/ruby/internal/intern/eval.h
ossl_ns_spki.o: $(hdrdir)/ruby/internal/intern/file.h
-ossl_ns_spki.o: $(hdrdir)/ruby/internal/intern/gc.h
ossl_ns_spki.o: $(hdrdir)/ruby/internal/intern/hash.h
ossl_ns_spki.o: $(hdrdir)/ruby/internal/intern/io.h
ossl_ns_spki.o: $(hdrdir)/ruby/internal/intern/load.h
@@ -2097,7 +2097,6 @@ ossl_ns_spki.o: $(hdrdir)/ruby/internal/memory.h
ossl_ns_spki.o: $(hdrdir)/ruby/internal/method.h
ossl_ns_spki.o: $(hdrdir)/ruby/internal/module.h
ossl_ns_spki.o: $(hdrdir)/ruby/internal/newobj.h
-ossl_ns_spki.o: $(hdrdir)/ruby/internal/rgengc.h
ossl_ns_spki.o: $(hdrdir)/ruby/internal/scan_args.h
ossl_ns_spki.o: $(hdrdir)/ruby/internal/special_consts.h
ossl_ns_spki.o: $(hdrdir)/ruby/internal/static_assert.h
@@ -2134,6 +2133,7 @@ ossl_ns_spki.o: ossl_ocsp.h
ossl_ns_spki.o: ossl_pkcs12.h
ossl_ns_spki.o: ossl_pkcs7.h
ossl_ns_spki.o: ossl_pkey.h
+ossl_ns_spki.o: ossl_provider.h
ossl_ns_spki.o: ossl_rand.h
ossl_ns_spki.o: ossl_ssl.h
ossl_ns_spki.o: ossl_ts.h
@@ -2192,6 +2192,7 @@ ossl_ocsp.o: $(hdrdir)/ruby/internal/attr/noexcept.h
ossl_ocsp.o: $(hdrdir)/ruby/internal/attr/noinline.h
ossl_ocsp.o: $(hdrdir)/ruby/internal/attr/nonnull.h
ossl_ocsp.o: $(hdrdir)/ruby/internal/attr/noreturn.h
+ossl_ocsp.o: $(hdrdir)/ruby/internal/attr/packed_struct.h
ossl_ocsp.o: $(hdrdir)/ruby/internal/attr/pure.h
ossl_ocsp.o: $(hdrdir)/ruby/internal/attr/restrict.h
ossl_ocsp.o: $(hdrdir)/ruby/internal/attr/returns_nonnull.h
@@ -2260,7 +2261,6 @@ ossl_ocsp.o: $(hdrdir)/ruby/internal/intern/enumerator.h
ossl_ocsp.o: $(hdrdir)/ruby/internal/intern/error.h
ossl_ocsp.o: $(hdrdir)/ruby/internal/intern/eval.h
ossl_ocsp.o: $(hdrdir)/ruby/internal/intern/file.h
-ossl_ocsp.o: $(hdrdir)/ruby/internal/intern/gc.h
ossl_ocsp.o: $(hdrdir)/ruby/internal/intern/hash.h
ossl_ocsp.o: $(hdrdir)/ruby/internal/intern/io.h
ossl_ocsp.o: $(hdrdir)/ruby/internal/intern/load.h
@@ -2291,7 +2291,6 @@ ossl_ocsp.o: $(hdrdir)/ruby/internal/memory.h
ossl_ocsp.o: $(hdrdir)/ruby/internal/method.h
ossl_ocsp.o: $(hdrdir)/ruby/internal/module.h
ossl_ocsp.o: $(hdrdir)/ruby/internal/newobj.h
-ossl_ocsp.o: $(hdrdir)/ruby/internal/rgengc.h
ossl_ocsp.o: $(hdrdir)/ruby/internal/scan_args.h
ossl_ocsp.o: $(hdrdir)/ruby/internal/special_consts.h
ossl_ocsp.o: $(hdrdir)/ruby/internal/static_assert.h
@@ -2328,6 +2327,7 @@ ossl_ocsp.o: ossl_ocsp.h
ossl_ocsp.o: ossl_pkcs12.h
ossl_ocsp.o: ossl_pkcs7.h
ossl_ocsp.o: ossl_pkey.h
+ossl_ocsp.o: ossl_provider.h
ossl_ocsp.o: ossl_rand.h
ossl_ocsp.o: ossl_ssl.h
ossl_ocsp.o: ossl_ts.h
@@ -2386,6 +2386,7 @@ ossl_pkcs12.o: $(hdrdir)/ruby/internal/attr/noexcept.h
ossl_pkcs12.o: $(hdrdir)/ruby/internal/attr/noinline.h
ossl_pkcs12.o: $(hdrdir)/ruby/internal/attr/nonnull.h
ossl_pkcs12.o: $(hdrdir)/ruby/internal/attr/noreturn.h
+ossl_pkcs12.o: $(hdrdir)/ruby/internal/attr/packed_struct.h
ossl_pkcs12.o: $(hdrdir)/ruby/internal/attr/pure.h
ossl_pkcs12.o: $(hdrdir)/ruby/internal/attr/restrict.h
ossl_pkcs12.o: $(hdrdir)/ruby/internal/attr/returns_nonnull.h
@@ -2454,7 +2455,6 @@ ossl_pkcs12.o: $(hdrdir)/ruby/internal/intern/enumerator.h
ossl_pkcs12.o: $(hdrdir)/ruby/internal/intern/error.h
ossl_pkcs12.o: $(hdrdir)/ruby/internal/intern/eval.h
ossl_pkcs12.o: $(hdrdir)/ruby/internal/intern/file.h
-ossl_pkcs12.o: $(hdrdir)/ruby/internal/intern/gc.h
ossl_pkcs12.o: $(hdrdir)/ruby/internal/intern/hash.h
ossl_pkcs12.o: $(hdrdir)/ruby/internal/intern/io.h
ossl_pkcs12.o: $(hdrdir)/ruby/internal/intern/load.h
@@ -2485,7 +2485,6 @@ ossl_pkcs12.o: $(hdrdir)/ruby/internal/memory.h
ossl_pkcs12.o: $(hdrdir)/ruby/internal/method.h
ossl_pkcs12.o: $(hdrdir)/ruby/internal/module.h
ossl_pkcs12.o: $(hdrdir)/ruby/internal/newobj.h
-ossl_pkcs12.o: $(hdrdir)/ruby/internal/rgengc.h
ossl_pkcs12.o: $(hdrdir)/ruby/internal/scan_args.h
ossl_pkcs12.o: $(hdrdir)/ruby/internal/special_consts.h
ossl_pkcs12.o: $(hdrdir)/ruby/internal/static_assert.h
@@ -2522,6 +2521,7 @@ ossl_pkcs12.o: ossl_pkcs12.c
ossl_pkcs12.o: ossl_pkcs12.h
ossl_pkcs12.o: ossl_pkcs7.h
ossl_pkcs12.o: ossl_pkey.h
+ossl_pkcs12.o: ossl_provider.h
ossl_pkcs12.o: ossl_rand.h
ossl_pkcs12.o: ossl_ssl.h
ossl_pkcs12.o: ossl_ts.h
@@ -2580,6 +2580,7 @@ ossl_pkcs7.o: $(hdrdir)/ruby/internal/attr/noexcept.h
ossl_pkcs7.o: $(hdrdir)/ruby/internal/attr/noinline.h
ossl_pkcs7.o: $(hdrdir)/ruby/internal/attr/nonnull.h
ossl_pkcs7.o: $(hdrdir)/ruby/internal/attr/noreturn.h
+ossl_pkcs7.o: $(hdrdir)/ruby/internal/attr/packed_struct.h
ossl_pkcs7.o: $(hdrdir)/ruby/internal/attr/pure.h
ossl_pkcs7.o: $(hdrdir)/ruby/internal/attr/restrict.h
ossl_pkcs7.o: $(hdrdir)/ruby/internal/attr/returns_nonnull.h
@@ -2648,7 +2649,6 @@ ossl_pkcs7.o: $(hdrdir)/ruby/internal/intern/enumerator.h
ossl_pkcs7.o: $(hdrdir)/ruby/internal/intern/error.h
ossl_pkcs7.o: $(hdrdir)/ruby/internal/intern/eval.h
ossl_pkcs7.o: $(hdrdir)/ruby/internal/intern/file.h
-ossl_pkcs7.o: $(hdrdir)/ruby/internal/intern/gc.h
ossl_pkcs7.o: $(hdrdir)/ruby/internal/intern/hash.h
ossl_pkcs7.o: $(hdrdir)/ruby/internal/intern/io.h
ossl_pkcs7.o: $(hdrdir)/ruby/internal/intern/load.h
@@ -2679,7 +2679,6 @@ ossl_pkcs7.o: $(hdrdir)/ruby/internal/memory.h
ossl_pkcs7.o: $(hdrdir)/ruby/internal/method.h
ossl_pkcs7.o: $(hdrdir)/ruby/internal/module.h
ossl_pkcs7.o: $(hdrdir)/ruby/internal/newobj.h
-ossl_pkcs7.o: $(hdrdir)/ruby/internal/rgengc.h
ossl_pkcs7.o: $(hdrdir)/ruby/internal/scan_args.h
ossl_pkcs7.o: $(hdrdir)/ruby/internal/special_consts.h
ossl_pkcs7.o: $(hdrdir)/ruby/internal/static_assert.h
@@ -2716,6 +2715,7 @@ ossl_pkcs7.o: ossl_pkcs12.h
ossl_pkcs7.o: ossl_pkcs7.c
ossl_pkcs7.o: ossl_pkcs7.h
ossl_pkcs7.o: ossl_pkey.h
+ossl_pkcs7.o: ossl_provider.h
ossl_pkcs7.o: ossl_rand.h
ossl_pkcs7.o: ossl_ssl.h
ossl_pkcs7.o: ossl_ts.h
@@ -2774,6 +2774,7 @@ ossl_pkey.o: $(hdrdir)/ruby/internal/attr/noexcept.h
ossl_pkey.o: $(hdrdir)/ruby/internal/attr/noinline.h
ossl_pkey.o: $(hdrdir)/ruby/internal/attr/nonnull.h
ossl_pkey.o: $(hdrdir)/ruby/internal/attr/noreturn.h
+ossl_pkey.o: $(hdrdir)/ruby/internal/attr/packed_struct.h
ossl_pkey.o: $(hdrdir)/ruby/internal/attr/pure.h
ossl_pkey.o: $(hdrdir)/ruby/internal/attr/restrict.h
ossl_pkey.o: $(hdrdir)/ruby/internal/attr/returns_nonnull.h
@@ -2842,7 +2843,6 @@ ossl_pkey.o: $(hdrdir)/ruby/internal/intern/enumerator.h
ossl_pkey.o: $(hdrdir)/ruby/internal/intern/error.h
ossl_pkey.o: $(hdrdir)/ruby/internal/intern/eval.h
ossl_pkey.o: $(hdrdir)/ruby/internal/intern/file.h
-ossl_pkey.o: $(hdrdir)/ruby/internal/intern/gc.h
ossl_pkey.o: $(hdrdir)/ruby/internal/intern/hash.h
ossl_pkey.o: $(hdrdir)/ruby/internal/intern/io.h
ossl_pkey.o: $(hdrdir)/ruby/internal/intern/load.h
@@ -2873,7 +2873,6 @@ ossl_pkey.o: $(hdrdir)/ruby/internal/memory.h
ossl_pkey.o: $(hdrdir)/ruby/internal/method.h
ossl_pkey.o: $(hdrdir)/ruby/internal/module.h
ossl_pkey.o: $(hdrdir)/ruby/internal/newobj.h
-ossl_pkey.o: $(hdrdir)/ruby/internal/rgengc.h
ossl_pkey.o: $(hdrdir)/ruby/internal/scan_args.h
ossl_pkey.o: $(hdrdir)/ruby/internal/special_consts.h
ossl_pkey.o: $(hdrdir)/ruby/internal/static_assert.h
@@ -2910,6 +2909,7 @@ ossl_pkey.o: ossl_pkcs12.h
ossl_pkey.o: ossl_pkcs7.h
ossl_pkey.o: ossl_pkey.c
ossl_pkey.o: ossl_pkey.h
+ossl_pkey.o: ossl_provider.h
ossl_pkey.o: ossl_rand.h
ossl_pkey.o: ossl_ssl.h
ossl_pkey.o: ossl_ts.h
@@ -2968,6 +2968,7 @@ ossl_pkey_dh.o: $(hdrdir)/ruby/internal/attr/noexcept.h
ossl_pkey_dh.o: $(hdrdir)/ruby/internal/attr/noinline.h
ossl_pkey_dh.o: $(hdrdir)/ruby/internal/attr/nonnull.h
ossl_pkey_dh.o: $(hdrdir)/ruby/internal/attr/noreturn.h
+ossl_pkey_dh.o: $(hdrdir)/ruby/internal/attr/packed_struct.h
ossl_pkey_dh.o: $(hdrdir)/ruby/internal/attr/pure.h
ossl_pkey_dh.o: $(hdrdir)/ruby/internal/attr/restrict.h
ossl_pkey_dh.o: $(hdrdir)/ruby/internal/attr/returns_nonnull.h
@@ -3036,7 +3037,6 @@ ossl_pkey_dh.o: $(hdrdir)/ruby/internal/intern/enumerator.h
ossl_pkey_dh.o: $(hdrdir)/ruby/internal/intern/error.h
ossl_pkey_dh.o: $(hdrdir)/ruby/internal/intern/eval.h
ossl_pkey_dh.o: $(hdrdir)/ruby/internal/intern/file.h
-ossl_pkey_dh.o: $(hdrdir)/ruby/internal/intern/gc.h
ossl_pkey_dh.o: $(hdrdir)/ruby/internal/intern/hash.h
ossl_pkey_dh.o: $(hdrdir)/ruby/internal/intern/io.h
ossl_pkey_dh.o: $(hdrdir)/ruby/internal/intern/load.h
@@ -3067,7 +3067,6 @@ ossl_pkey_dh.o: $(hdrdir)/ruby/internal/memory.h
ossl_pkey_dh.o: $(hdrdir)/ruby/internal/method.h
ossl_pkey_dh.o: $(hdrdir)/ruby/internal/module.h
ossl_pkey_dh.o: $(hdrdir)/ruby/internal/newobj.h
-ossl_pkey_dh.o: $(hdrdir)/ruby/internal/rgengc.h
ossl_pkey_dh.o: $(hdrdir)/ruby/internal/scan_args.h
ossl_pkey_dh.o: $(hdrdir)/ruby/internal/special_consts.h
ossl_pkey_dh.o: $(hdrdir)/ruby/internal/static_assert.h
@@ -3104,6 +3103,7 @@ ossl_pkey_dh.o: ossl_pkcs12.h
ossl_pkey_dh.o: ossl_pkcs7.h
ossl_pkey_dh.o: ossl_pkey.h
ossl_pkey_dh.o: ossl_pkey_dh.c
+ossl_pkey_dh.o: ossl_provider.h
ossl_pkey_dh.o: ossl_rand.h
ossl_pkey_dh.o: ossl_ssl.h
ossl_pkey_dh.o: ossl_ts.h
@@ -3162,6 +3162,7 @@ ossl_pkey_dsa.o: $(hdrdir)/ruby/internal/attr/noexcept.h
ossl_pkey_dsa.o: $(hdrdir)/ruby/internal/attr/noinline.h
ossl_pkey_dsa.o: $(hdrdir)/ruby/internal/attr/nonnull.h
ossl_pkey_dsa.o: $(hdrdir)/ruby/internal/attr/noreturn.h
+ossl_pkey_dsa.o: $(hdrdir)/ruby/internal/attr/packed_struct.h
ossl_pkey_dsa.o: $(hdrdir)/ruby/internal/attr/pure.h
ossl_pkey_dsa.o: $(hdrdir)/ruby/internal/attr/restrict.h
ossl_pkey_dsa.o: $(hdrdir)/ruby/internal/attr/returns_nonnull.h
@@ -3230,7 +3231,6 @@ ossl_pkey_dsa.o: $(hdrdir)/ruby/internal/intern/enumerator.h
ossl_pkey_dsa.o: $(hdrdir)/ruby/internal/intern/error.h
ossl_pkey_dsa.o: $(hdrdir)/ruby/internal/intern/eval.h
ossl_pkey_dsa.o: $(hdrdir)/ruby/internal/intern/file.h
-ossl_pkey_dsa.o: $(hdrdir)/ruby/internal/intern/gc.h
ossl_pkey_dsa.o: $(hdrdir)/ruby/internal/intern/hash.h
ossl_pkey_dsa.o: $(hdrdir)/ruby/internal/intern/io.h
ossl_pkey_dsa.o: $(hdrdir)/ruby/internal/intern/load.h
@@ -3261,7 +3261,6 @@ ossl_pkey_dsa.o: $(hdrdir)/ruby/internal/memory.h
ossl_pkey_dsa.o: $(hdrdir)/ruby/internal/method.h
ossl_pkey_dsa.o: $(hdrdir)/ruby/internal/module.h
ossl_pkey_dsa.o: $(hdrdir)/ruby/internal/newobj.h
-ossl_pkey_dsa.o: $(hdrdir)/ruby/internal/rgengc.h
ossl_pkey_dsa.o: $(hdrdir)/ruby/internal/scan_args.h
ossl_pkey_dsa.o: $(hdrdir)/ruby/internal/special_consts.h
ossl_pkey_dsa.o: $(hdrdir)/ruby/internal/static_assert.h
@@ -3298,6 +3297,7 @@ ossl_pkey_dsa.o: ossl_pkcs12.h
ossl_pkey_dsa.o: ossl_pkcs7.h
ossl_pkey_dsa.o: ossl_pkey.h
ossl_pkey_dsa.o: ossl_pkey_dsa.c
+ossl_pkey_dsa.o: ossl_provider.h
ossl_pkey_dsa.o: ossl_rand.h
ossl_pkey_dsa.o: ossl_ssl.h
ossl_pkey_dsa.o: ossl_ts.h
@@ -3356,6 +3356,7 @@ ossl_pkey_ec.o: $(hdrdir)/ruby/internal/attr/noexcept.h
ossl_pkey_ec.o: $(hdrdir)/ruby/internal/attr/noinline.h
ossl_pkey_ec.o: $(hdrdir)/ruby/internal/attr/nonnull.h
ossl_pkey_ec.o: $(hdrdir)/ruby/internal/attr/noreturn.h
+ossl_pkey_ec.o: $(hdrdir)/ruby/internal/attr/packed_struct.h
ossl_pkey_ec.o: $(hdrdir)/ruby/internal/attr/pure.h
ossl_pkey_ec.o: $(hdrdir)/ruby/internal/attr/restrict.h
ossl_pkey_ec.o: $(hdrdir)/ruby/internal/attr/returns_nonnull.h
@@ -3424,7 +3425,6 @@ ossl_pkey_ec.o: $(hdrdir)/ruby/internal/intern/enumerator.h
ossl_pkey_ec.o: $(hdrdir)/ruby/internal/intern/error.h
ossl_pkey_ec.o: $(hdrdir)/ruby/internal/intern/eval.h
ossl_pkey_ec.o: $(hdrdir)/ruby/internal/intern/file.h
-ossl_pkey_ec.o: $(hdrdir)/ruby/internal/intern/gc.h
ossl_pkey_ec.o: $(hdrdir)/ruby/internal/intern/hash.h
ossl_pkey_ec.o: $(hdrdir)/ruby/internal/intern/io.h
ossl_pkey_ec.o: $(hdrdir)/ruby/internal/intern/load.h
@@ -3455,7 +3455,6 @@ ossl_pkey_ec.o: $(hdrdir)/ruby/internal/memory.h
ossl_pkey_ec.o: $(hdrdir)/ruby/internal/method.h
ossl_pkey_ec.o: $(hdrdir)/ruby/internal/module.h
ossl_pkey_ec.o: $(hdrdir)/ruby/internal/newobj.h
-ossl_pkey_ec.o: $(hdrdir)/ruby/internal/rgengc.h
ossl_pkey_ec.o: $(hdrdir)/ruby/internal/scan_args.h
ossl_pkey_ec.o: $(hdrdir)/ruby/internal/special_consts.h
ossl_pkey_ec.o: $(hdrdir)/ruby/internal/static_assert.h
@@ -3492,6 +3491,7 @@ ossl_pkey_ec.o: ossl_pkcs12.h
ossl_pkey_ec.o: ossl_pkcs7.h
ossl_pkey_ec.o: ossl_pkey.h
ossl_pkey_ec.o: ossl_pkey_ec.c
+ossl_pkey_ec.o: ossl_provider.h
ossl_pkey_ec.o: ossl_rand.h
ossl_pkey_ec.o: ossl_ssl.h
ossl_pkey_ec.o: ossl_ts.h
@@ -3550,6 +3550,7 @@ ossl_pkey_rsa.o: $(hdrdir)/ruby/internal/attr/noexcept.h
ossl_pkey_rsa.o: $(hdrdir)/ruby/internal/attr/noinline.h
ossl_pkey_rsa.o: $(hdrdir)/ruby/internal/attr/nonnull.h
ossl_pkey_rsa.o: $(hdrdir)/ruby/internal/attr/noreturn.h
+ossl_pkey_rsa.o: $(hdrdir)/ruby/internal/attr/packed_struct.h
ossl_pkey_rsa.o: $(hdrdir)/ruby/internal/attr/pure.h
ossl_pkey_rsa.o: $(hdrdir)/ruby/internal/attr/restrict.h
ossl_pkey_rsa.o: $(hdrdir)/ruby/internal/attr/returns_nonnull.h
@@ -3618,7 +3619,6 @@ ossl_pkey_rsa.o: $(hdrdir)/ruby/internal/intern/enumerator.h
ossl_pkey_rsa.o: $(hdrdir)/ruby/internal/intern/error.h
ossl_pkey_rsa.o: $(hdrdir)/ruby/internal/intern/eval.h
ossl_pkey_rsa.o: $(hdrdir)/ruby/internal/intern/file.h
-ossl_pkey_rsa.o: $(hdrdir)/ruby/internal/intern/gc.h
ossl_pkey_rsa.o: $(hdrdir)/ruby/internal/intern/hash.h
ossl_pkey_rsa.o: $(hdrdir)/ruby/internal/intern/io.h
ossl_pkey_rsa.o: $(hdrdir)/ruby/internal/intern/load.h
@@ -3649,7 +3649,6 @@ ossl_pkey_rsa.o: $(hdrdir)/ruby/internal/memory.h
ossl_pkey_rsa.o: $(hdrdir)/ruby/internal/method.h
ossl_pkey_rsa.o: $(hdrdir)/ruby/internal/module.h
ossl_pkey_rsa.o: $(hdrdir)/ruby/internal/newobj.h
-ossl_pkey_rsa.o: $(hdrdir)/ruby/internal/rgengc.h
ossl_pkey_rsa.o: $(hdrdir)/ruby/internal/scan_args.h
ossl_pkey_rsa.o: $(hdrdir)/ruby/internal/special_consts.h
ossl_pkey_rsa.o: $(hdrdir)/ruby/internal/static_assert.h
@@ -3686,10 +3685,205 @@ ossl_pkey_rsa.o: ossl_pkcs12.h
ossl_pkey_rsa.o: ossl_pkcs7.h
ossl_pkey_rsa.o: ossl_pkey.h
ossl_pkey_rsa.o: ossl_pkey_rsa.c
+ossl_pkey_rsa.o: ossl_provider.h
ossl_pkey_rsa.o: ossl_rand.h
ossl_pkey_rsa.o: ossl_ssl.h
ossl_pkey_rsa.o: ossl_ts.h
ossl_pkey_rsa.o: ossl_x509.h
+ossl_provider.o: $(RUBY_EXTCONF_H)
+ossl_provider.o: $(arch_hdrdir)/ruby/config.h
+ossl_provider.o: $(hdrdir)/ruby.h
+ossl_provider.o: $(hdrdir)/ruby/assert.h
+ossl_provider.o: $(hdrdir)/ruby/backward.h
+ossl_provider.o: $(hdrdir)/ruby/backward/2/assume.h
+ossl_provider.o: $(hdrdir)/ruby/backward/2/attributes.h
+ossl_provider.o: $(hdrdir)/ruby/backward/2/bool.h
+ossl_provider.o: $(hdrdir)/ruby/backward/2/inttypes.h
+ossl_provider.o: $(hdrdir)/ruby/backward/2/limits.h
+ossl_provider.o: $(hdrdir)/ruby/backward/2/long_long.h
+ossl_provider.o: $(hdrdir)/ruby/backward/2/stdalign.h
+ossl_provider.o: $(hdrdir)/ruby/backward/2/stdarg.h
+ossl_provider.o: $(hdrdir)/ruby/defines.h
+ossl_provider.o: $(hdrdir)/ruby/encoding.h
+ossl_provider.o: $(hdrdir)/ruby/intern.h
+ossl_provider.o: $(hdrdir)/ruby/internal/abi.h
+ossl_provider.o: $(hdrdir)/ruby/internal/anyargs.h
+ossl_provider.o: $(hdrdir)/ruby/internal/arithmetic.h
+ossl_provider.o: $(hdrdir)/ruby/internal/arithmetic/char.h
+ossl_provider.o: $(hdrdir)/ruby/internal/arithmetic/double.h
+ossl_provider.o: $(hdrdir)/ruby/internal/arithmetic/fixnum.h
+ossl_provider.o: $(hdrdir)/ruby/internal/arithmetic/gid_t.h
+ossl_provider.o: $(hdrdir)/ruby/internal/arithmetic/int.h
+ossl_provider.o: $(hdrdir)/ruby/internal/arithmetic/intptr_t.h
+ossl_provider.o: $(hdrdir)/ruby/internal/arithmetic/long.h
+ossl_provider.o: $(hdrdir)/ruby/internal/arithmetic/long_long.h
+ossl_provider.o: $(hdrdir)/ruby/internal/arithmetic/mode_t.h
+ossl_provider.o: $(hdrdir)/ruby/internal/arithmetic/off_t.h
+ossl_provider.o: $(hdrdir)/ruby/internal/arithmetic/pid_t.h
+ossl_provider.o: $(hdrdir)/ruby/internal/arithmetic/short.h
+ossl_provider.o: $(hdrdir)/ruby/internal/arithmetic/size_t.h
+ossl_provider.o: $(hdrdir)/ruby/internal/arithmetic/st_data_t.h
+ossl_provider.o: $(hdrdir)/ruby/internal/arithmetic/uid_t.h
+ossl_provider.o: $(hdrdir)/ruby/internal/assume.h
+ossl_provider.o: $(hdrdir)/ruby/internal/attr/alloc_size.h
+ossl_provider.o: $(hdrdir)/ruby/internal/attr/artificial.h
+ossl_provider.o: $(hdrdir)/ruby/internal/attr/cold.h
+ossl_provider.o: $(hdrdir)/ruby/internal/attr/const.h
+ossl_provider.o: $(hdrdir)/ruby/internal/attr/constexpr.h
+ossl_provider.o: $(hdrdir)/ruby/internal/attr/deprecated.h
+ossl_provider.o: $(hdrdir)/ruby/internal/attr/diagnose_if.h
+ossl_provider.o: $(hdrdir)/ruby/internal/attr/enum_extensibility.h
+ossl_provider.o: $(hdrdir)/ruby/internal/attr/error.h
+ossl_provider.o: $(hdrdir)/ruby/internal/attr/flag_enum.h
+ossl_provider.o: $(hdrdir)/ruby/internal/attr/forceinline.h
+ossl_provider.o: $(hdrdir)/ruby/internal/attr/format.h
+ossl_provider.o: $(hdrdir)/ruby/internal/attr/maybe_unused.h
+ossl_provider.o: $(hdrdir)/ruby/internal/attr/noalias.h
+ossl_provider.o: $(hdrdir)/ruby/internal/attr/nodiscard.h
+ossl_provider.o: $(hdrdir)/ruby/internal/attr/noexcept.h
+ossl_provider.o: $(hdrdir)/ruby/internal/attr/noinline.h
+ossl_provider.o: $(hdrdir)/ruby/internal/attr/nonnull.h
+ossl_provider.o: $(hdrdir)/ruby/internal/attr/noreturn.h
+ossl_provider.o: $(hdrdir)/ruby/internal/attr/packed_struct.h
+ossl_provider.o: $(hdrdir)/ruby/internal/attr/pure.h
+ossl_provider.o: $(hdrdir)/ruby/internal/attr/restrict.h
+ossl_provider.o: $(hdrdir)/ruby/internal/attr/returns_nonnull.h
+ossl_provider.o: $(hdrdir)/ruby/internal/attr/warning.h
+ossl_provider.o: $(hdrdir)/ruby/internal/attr/weakref.h
+ossl_provider.o: $(hdrdir)/ruby/internal/cast.h
+ossl_provider.o: $(hdrdir)/ruby/internal/compiler_is.h
+ossl_provider.o: $(hdrdir)/ruby/internal/compiler_is/apple.h
+ossl_provider.o: $(hdrdir)/ruby/internal/compiler_is/clang.h
+ossl_provider.o: $(hdrdir)/ruby/internal/compiler_is/gcc.h
+ossl_provider.o: $(hdrdir)/ruby/internal/compiler_is/intel.h
+ossl_provider.o: $(hdrdir)/ruby/internal/compiler_is/msvc.h
+ossl_provider.o: $(hdrdir)/ruby/internal/compiler_is/sunpro.h
+ossl_provider.o: $(hdrdir)/ruby/internal/compiler_since.h
+ossl_provider.o: $(hdrdir)/ruby/internal/config.h
+ossl_provider.o: $(hdrdir)/ruby/internal/constant_p.h
+ossl_provider.o: $(hdrdir)/ruby/internal/core.h
+ossl_provider.o: $(hdrdir)/ruby/internal/core/rarray.h
+ossl_provider.o: $(hdrdir)/ruby/internal/core/rbasic.h
+ossl_provider.o: $(hdrdir)/ruby/internal/core/rbignum.h
+ossl_provider.o: $(hdrdir)/ruby/internal/core/rclass.h
+ossl_provider.o: $(hdrdir)/ruby/internal/core/rdata.h
+ossl_provider.o: $(hdrdir)/ruby/internal/core/rfile.h
+ossl_provider.o: $(hdrdir)/ruby/internal/core/rhash.h
+ossl_provider.o: $(hdrdir)/ruby/internal/core/robject.h
+ossl_provider.o: $(hdrdir)/ruby/internal/core/rregexp.h
+ossl_provider.o: $(hdrdir)/ruby/internal/core/rstring.h
+ossl_provider.o: $(hdrdir)/ruby/internal/core/rstruct.h
+ossl_provider.o: $(hdrdir)/ruby/internal/core/rtypeddata.h
+ossl_provider.o: $(hdrdir)/ruby/internal/ctype.h
+ossl_provider.o: $(hdrdir)/ruby/internal/dllexport.h
+ossl_provider.o: $(hdrdir)/ruby/internal/dosish.h
+ossl_provider.o: $(hdrdir)/ruby/internal/encoding/coderange.h
+ossl_provider.o: $(hdrdir)/ruby/internal/encoding/ctype.h
+ossl_provider.o: $(hdrdir)/ruby/internal/encoding/encoding.h
+ossl_provider.o: $(hdrdir)/ruby/internal/encoding/pathname.h
+ossl_provider.o: $(hdrdir)/ruby/internal/encoding/re.h
+ossl_provider.o: $(hdrdir)/ruby/internal/encoding/sprintf.h
+ossl_provider.o: $(hdrdir)/ruby/internal/encoding/string.h
+ossl_provider.o: $(hdrdir)/ruby/internal/encoding/symbol.h
+ossl_provider.o: $(hdrdir)/ruby/internal/encoding/transcode.h
+ossl_provider.o: $(hdrdir)/ruby/internal/error.h
+ossl_provider.o: $(hdrdir)/ruby/internal/eval.h
+ossl_provider.o: $(hdrdir)/ruby/internal/event.h
+ossl_provider.o: $(hdrdir)/ruby/internal/fl_type.h
+ossl_provider.o: $(hdrdir)/ruby/internal/gc.h
+ossl_provider.o: $(hdrdir)/ruby/internal/glob.h
+ossl_provider.o: $(hdrdir)/ruby/internal/globals.h
+ossl_provider.o: $(hdrdir)/ruby/internal/has/attribute.h
+ossl_provider.o: $(hdrdir)/ruby/internal/has/builtin.h
+ossl_provider.o: $(hdrdir)/ruby/internal/has/c_attribute.h
+ossl_provider.o: $(hdrdir)/ruby/internal/has/cpp_attribute.h
+ossl_provider.o: $(hdrdir)/ruby/internal/has/declspec_attribute.h
+ossl_provider.o: $(hdrdir)/ruby/internal/has/extension.h
+ossl_provider.o: $(hdrdir)/ruby/internal/has/feature.h
+ossl_provider.o: $(hdrdir)/ruby/internal/has/warning.h
+ossl_provider.o: $(hdrdir)/ruby/internal/intern/array.h
+ossl_provider.o: $(hdrdir)/ruby/internal/intern/bignum.h
+ossl_provider.o: $(hdrdir)/ruby/internal/intern/class.h
+ossl_provider.o: $(hdrdir)/ruby/internal/intern/compar.h
+ossl_provider.o: $(hdrdir)/ruby/internal/intern/complex.h
+ossl_provider.o: $(hdrdir)/ruby/internal/intern/cont.h
+ossl_provider.o: $(hdrdir)/ruby/internal/intern/dir.h
+ossl_provider.o: $(hdrdir)/ruby/internal/intern/enum.h
+ossl_provider.o: $(hdrdir)/ruby/internal/intern/enumerator.h
+ossl_provider.o: $(hdrdir)/ruby/internal/intern/error.h
+ossl_provider.o: $(hdrdir)/ruby/internal/intern/eval.h
+ossl_provider.o: $(hdrdir)/ruby/internal/intern/file.h
+ossl_provider.o: $(hdrdir)/ruby/internal/intern/hash.h
+ossl_provider.o: $(hdrdir)/ruby/internal/intern/io.h
+ossl_provider.o: $(hdrdir)/ruby/internal/intern/load.h
+ossl_provider.o: $(hdrdir)/ruby/internal/intern/marshal.h
+ossl_provider.o: $(hdrdir)/ruby/internal/intern/numeric.h
+ossl_provider.o: $(hdrdir)/ruby/internal/intern/object.h
+ossl_provider.o: $(hdrdir)/ruby/internal/intern/parse.h
+ossl_provider.o: $(hdrdir)/ruby/internal/intern/proc.h
+ossl_provider.o: $(hdrdir)/ruby/internal/intern/process.h
+ossl_provider.o: $(hdrdir)/ruby/internal/intern/random.h
+ossl_provider.o: $(hdrdir)/ruby/internal/intern/range.h
+ossl_provider.o: $(hdrdir)/ruby/internal/intern/rational.h
+ossl_provider.o: $(hdrdir)/ruby/internal/intern/re.h
+ossl_provider.o: $(hdrdir)/ruby/internal/intern/ruby.h
+ossl_provider.o: $(hdrdir)/ruby/internal/intern/select.h
+ossl_provider.o: $(hdrdir)/ruby/internal/intern/select/largesize.h
+ossl_provider.o: $(hdrdir)/ruby/internal/intern/signal.h
+ossl_provider.o: $(hdrdir)/ruby/internal/intern/sprintf.h
+ossl_provider.o: $(hdrdir)/ruby/internal/intern/string.h
+ossl_provider.o: $(hdrdir)/ruby/internal/intern/struct.h
+ossl_provider.o: $(hdrdir)/ruby/internal/intern/thread.h
+ossl_provider.o: $(hdrdir)/ruby/internal/intern/time.h
+ossl_provider.o: $(hdrdir)/ruby/internal/intern/variable.h
+ossl_provider.o: $(hdrdir)/ruby/internal/intern/vm.h
+ossl_provider.o: $(hdrdir)/ruby/internal/interpreter.h
+ossl_provider.o: $(hdrdir)/ruby/internal/iterator.h
+ossl_provider.o: $(hdrdir)/ruby/internal/memory.h
+ossl_provider.o: $(hdrdir)/ruby/internal/method.h
+ossl_provider.o: $(hdrdir)/ruby/internal/module.h
+ossl_provider.o: $(hdrdir)/ruby/internal/newobj.h
+ossl_provider.o: $(hdrdir)/ruby/internal/scan_args.h
+ossl_provider.o: $(hdrdir)/ruby/internal/special_consts.h
+ossl_provider.o: $(hdrdir)/ruby/internal/static_assert.h
+ossl_provider.o: $(hdrdir)/ruby/internal/stdalign.h
+ossl_provider.o: $(hdrdir)/ruby/internal/stdbool.h
+ossl_provider.o: $(hdrdir)/ruby/internal/symbol.h
+ossl_provider.o: $(hdrdir)/ruby/internal/value.h
+ossl_provider.o: $(hdrdir)/ruby/internal/value_type.h
+ossl_provider.o: $(hdrdir)/ruby/internal/variable.h
+ossl_provider.o: $(hdrdir)/ruby/internal/warning_push.h
+ossl_provider.o: $(hdrdir)/ruby/internal/xmalloc.h
+ossl_provider.o: $(hdrdir)/ruby/io.h
+ossl_provider.o: $(hdrdir)/ruby/missing.h
+ossl_provider.o: $(hdrdir)/ruby/onigmo.h
+ossl_provider.o: $(hdrdir)/ruby/oniguruma.h
+ossl_provider.o: $(hdrdir)/ruby/ruby.h
+ossl_provider.o: $(hdrdir)/ruby/st.h
+ossl_provider.o: $(hdrdir)/ruby/subst.h
+ossl_provider.o: $(hdrdir)/ruby/thread.h
+ossl_provider.o: openssl_missing.h
+ossl_provider.o: ossl.h
+ossl_provider.o: ossl_asn1.h
+ossl_provider.o: ossl_bio.h
+ossl_provider.o: ossl_bn.h
+ossl_provider.o: ossl_cipher.h
+ossl_provider.o: ossl_config.h
+ossl_provider.o: ossl_digest.h
+ossl_provider.o: ossl_engine.h
+ossl_provider.o: ossl_hmac.h
+ossl_provider.o: ossl_kdf.h
+ossl_provider.o: ossl_ns_spki.h
+ossl_provider.o: ossl_ocsp.h
+ossl_provider.o: ossl_pkcs12.h
+ossl_provider.o: ossl_pkcs7.h
+ossl_provider.o: ossl_pkey.h
+ossl_provider.o: ossl_provider.c
+ossl_provider.o: ossl_provider.h
+ossl_provider.o: ossl_rand.h
+ossl_provider.o: ossl_ssl.h
+ossl_provider.o: ossl_ts.h
+ossl_provider.o: ossl_x509.h
ossl_rand.o: $(RUBY_EXTCONF_H)
ossl_rand.o: $(arch_hdrdir)/ruby/config.h
ossl_rand.o: $(hdrdir)/ruby.h
@@ -3744,6 +3938,7 @@ ossl_rand.o: $(hdrdir)/ruby/internal/attr/noexcept.h
ossl_rand.o: $(hdrdir)/ruby/internal/attr/noinline.h
ossl_rand.o: $(hdrdir)/ruby/internal/attr/nonnull.h
ossl_rand.o: $(hdrdir)/ruby/internal/attr/noreturn.h
+ossl_rand.o: $(hdrdir)/ruby/internal/attr/packed_struct.h
ossl_rand.o: $(hdrdir)/ruby/internal/attr/pure.h
ossl_rand.o: $(hdrdir)/ruby/internal/attr/restrict.h
ossl_rand.o: $(hdrdir)/ruby/internal/attr/returns_nonnull.h
@@ -3812,7 +4007,6 @@ ossl_rand.o: $(hdrdir)/ruby/internal/intern/enumerator.h
ossl_rand.o: $(hdrdir)/ruby/internal/intern/error.h
ossl_rand.o: $(hdrdir)/ruby/internal/intern/eval.h
ossl_rand.o: $(hdrdir)/ruby/internal/intern/file.h
-ossl_rand.o: $(hdrdir)/ruby/internal/intern/gc.h
ossl_rand.o: $(hdrdir)/ruby/internal/intern/hash.h
ossl_rand.o: $(hdrdir)/ruby/internal/intern/io.h
ossl_rand.o: $(hdrdir)/ruby/internal/intern/load.h
@@ -3843,7 +4037,6 @@ ossl_rand.o: $(hdrdir)/ruby/internal/memory.h
ossl_rand.o: $(hdrdir)/ruby/internal/method.h
ossl_rand.o: $(hdrdir)/ruby/internal/module.h
ossl_rand.o: $(hdrdir)/ruby/internal/newobj.h
-ossl_rand.o: $(hdrdir)/ruby/internal/rgengc.h
ossl_rand.o: $(hdrdir)/ruby/internal/scan_args.h
ossl_rand.o: $(hdrdir)/ruby/internal/special_consts.h
ossl_rand.o: $(hdrdir)/ruby/internal/static_assert.h
@@ -3879,6 +4072,7 @@ ossl_rand.o: ossl_ocsp.h
ossl_rand.o: ossl_pkcs12.h
ossl_rand.o: ossl_pkcs7.h
ossl_rand.o: ossl_pkey.h
+ossl_rand.o: ossl_provider.h
ossl_rand.o: ossl_rand.c
ossl_rand.o: ossl_rand.h
ossl_rand.o: ossl_ssl.h
@@ -3938,6 +4132,7 @@ ossl_ssl.o: $(hdrdir)/ruby/internal/attr/noexcept.h
ossl_ssl.o: $(hdrdir)/ruby/internal/attr/noinline.h
ossl_ssl.o: $(hdrdir)/ruby/internal/attr/nonnull.h
ossl_ssl.o: $(hdrdir)/ruby/internal/attr/noreturn.h
+ossl_ssl.o: $(hdrdir)/ruby/internal/attr/packed_struct.h
ossl_ssl.o: $(hdrdir)/ruby/internal/attr/pure.h
ossl_ssl.o: $(hdrdir)/ruby/internal/attr/restrict.h
ossl_ssl.o: $(hdrdir)/ruby/internal/attr/returns_nonnull.h
@@ -4006,7 +4201,6 @@ ossl_ssl.o: $(hdrdir)/ruby/internal/intern/enumerator.h
ossl_ssl.o: $(hdrdir)/ruby/internal/intern/error.h
ossl_ssl.o: $(hdrdir)/ruby/internal/intern/eval.h
ossl_ssl.o: $(hdrdir)/ruby/internal/intern/file.h
-ossl_ssl.o: $(hdrdir)/ruby/internal/intern/gc.h
ossl_ssl.o: $(hdrdir)/ruby/internal/intern/hash.h
ossl_ssl.o: $(hdrdir)/ruby/internal/intern/io.h
ossl_ssl.o: $(hdrdir)/ruby/internal/intern/load.h
@@ -4037,7 +4231,6 @@ ossl_ssl.o: $(hdrdir)/ruby/internal/memory.h
ossl_ssl.o: $(hdrdir)/ruby/internal/method.h
ossl_ssl.o: $(hdrdir)/ruby/internal/module.h
ossl_ssl.o: $(hdrdir)/ruby/internal/newobj.h
-ossl_ssl.o: $(hdrdir)/ruby/internal/rgengc.h
ossl_ssl.o: $(hdrdir)/ruby/internal/scan_args.h
ossl_ssl.o: $(hdrdir)/ruby/internal/special_consts.h
ossl_ssl.o: $(hdrdir)/ruby/internal/static_assert.h
@@ -4073,6 +4266,7 @@ ossl_ssl.o: ossl_ocsp.h
ossl_ssl.o: ossl_pkcs12.h
ossl_ssl.o: ossl_pkcs7.h
ossl_ssl.o: ossl_pkey.h
+ossl_ssl.o: ossl_provider.h
ossl_ssl.o: ossl_rand.h
ossl_ssl.o: ossl_ssl.c
ossl_ssl.o: ossl_ssl.h
@@ -4132,6 +4326,7 @@ ossl_ssl_session.o: $(hdrdir)/ruby/internal/attr/noexcept.h
ossl_ssl_session.o: $(hdrdir)/ruby/internal/attr/noinline.h
ossl_ssl_session.o: $(hdrdir)/ruby/internal/attr/nonnull.h
ossl_ssl_session.o: $(hdrdir)/ruby/internal/attr/noreturn.h
+ossl_ssl_session.o: $(hdrdir)/ruby/internal/attr/packed_struct.h
ossl_ssl_session.o: $(hdrdir)/ruby/internal/attr/pure.h
ossl_ssl_session.o: $(hdrdir)/ruby/internal/attr/restrict.h
ossl_ssl_session.o: $(hdrdir)/ruby/internal/attr/returns_nonnull.h
@@ -4200,7 +4395,6 @@ ossl_ssl_session.o: $(hdrdir)/ruby/internal/intern/enumerator.h
ossl_ssl_session.o: $(hdrdir)/ruby/internal/intern/error.h
ossl_ssl_session.o: $(hdrdir)/ruby/internal/intern/eval.h
ossl_ssl_session.o: $(hdrdir)/ruby/internal/intern/file.h
-ossl_ssl_session.o: $(hdrdir)/ruby/internal/intern/gc.h
ossl_ssl_session.o: $(hdrdir)/ruby/internal/intern/hash.h
ossl_ssl_session.o: $(hdrdir)/ruby/internal/intern/io.h
ossl_ssl_session.o: $(hdrdir)/ruby/internal/intern/load.h
@@ -4231,7 +4425,6 @@ ossl_ssl_session.o: $(hdrdir)/ruby/internal/memory.h
ossl_ssl_session.o: $(hdrdir)/ruby/internal/method.h
ossl_ssl_session.o: $(hdrdir)/ruby/internal/module.h
ossl_ssl_session.o: $(hdrdir)/ruby/internal/newobj.h
-ossl_ssl_session.o: $(hdrdir)/ruby/internal/rgengc.h
ossl_ssl_session.o: $(hdrdir)/ruby/internal/scan_args.h
ossl_ssl_session.o: $(hdrdir)/ruby/internal/special_consts.h
ossl_ssl_session.o: $(hdrdir)/ruby/internal/static_assert.h
@@ -4267,6 +4460,7 @@ ossl_ssl_session.o: ossl_ocsp.h
ossl_ssl_session.o: ossl_pkcs12.h
ossl_ssl_session.o: ossl_pkcs7.h
ossl_ssl_session.o: ossl_pkey.h
+ossl_ssl_session.o: ossl_provider.h
ossl_ssl_session.o: ossl_rand.h
ossl_ssl_session.o: ossl_ssl.h
ossl_ssl_session.o: ossl_ssl_session.c
@@ -4326,6 +4520,7 @@ ossl_ts.o: $(hdrdir)/ruby/internal/attr/noexcept.h
ossl_ts.o: $(hdrdir)/ruby/internal/attr/noinline.h
ossl_ts.o: $(hdrdir)/ruby/internal/attr/nonnull.h
ossl_ts.o: $(hdrdir)/ruby/internal/attr/noreturn.h
+ossl_ts.o: $(hdrdir)/ruby/internal/attr/packed_struct.h
ossl_ts.o: $(hdrdir)/ruby/internal/attr/pure.h
ossl_ts.o: $(hdrdir)/ruby/internal/attr/restrict.h
ossl_ts.o: $(hdrdir)/ruby/internal/attr/returns_nonnull.h
@@ -4394,7 +4589,6 @@ ossl_ts.o: $(hdrdir)/ruby/internal/intern/enumerator.h
ossl_ts.o: $(hdrdir)/ruby/internal/intern/error.h
ossl_ts.o: $(hdrdir)/ruby/internal/intern/eval.h
ossl_ts.o: $(hdrdir)/ruby/internal/intern/file.h
-ossl_ts.o: $(hdrdir)/ruby/internal/intern/gc.h
ossl_ts.o: $(hdrdir)/ruby/internal/intern/hash.h
ossl_ts.o: $(hdrdir)/ruby/internal/intern/io.h
ossl_ts.o: $(hdrdir)/ruby/internal/intern/load.h
@@ -4425,7 +4619,6 @@ ossl_ts.o: $(hdrdir)/ruby/internal/memory.h
ossl_ts.o: $(hdrdir)/ruby/internal/method.h
ossl_ts.o: $(hdrdir)/ruby/internal/module.h
ossl_ts.o: $(hdrdir)/ruby/internal/newobj.h
-ossl_ts.o: $(hdrdir)/ruby/internal/rgengc.h
ossl_ts.o: $(hdrdir)/ruby/internal/scan_args.h
ossl_ts.o: $(hdrdir)/ruby/internal/special_consts.h
ossl_ts.o: $(hdrdir)/ruby/internal/static_assert.h
@@ -4461,6 +4654,7 @@ ossl_ts.o: ossl_ocsp.h
ossl_ts.o: ossl_pkcs12.h
ossl_ts.o: ossl_pkcs7.h
ossl_ts.o: ossl_pkey.h
+ossl_ts.o: ossl_provider.h
ossl_ts.o: ossl_rand.h
ossl_ts.o: ossl_ssl.h
ossl_ts.o: ossl_ts.c
@@ -4520,6 +4714,7 @@ ossl_x509.o: $(hdrdir)/ruby/internal/attr/noexcept.h
ossl_x509.o: $(hdrdir)/ruby/internal/attr/noinline.h
ossl_x509.o: $(hdrdir)/ruby/internal/attr/nonnull.h
ossl_x509.o: $(hdrdir)/ruby/internal/attr/noreturn.h
+ossl_x509.o: $(hdrdir)/ruby/internal/attr/packed_struct.h
ossl_x509.o: $(hdrdir)/ruby/internal/attr/pure.h
ossl_x509.o: $(hdrdir)/ruby/internal/attr/restrict.h
ossl_x509.o: $(hdrdir)/ruby/internal/attr/returns_nonnull.h
@@ -4588,7 +4783,6 @@ ossl_x509.o: $(hdrdir)/ruby/internal/intern/enumerator.h
ossl_x509.o: $(hdrdir)/ruby/internal/intern/error.h
ossl_x509.o: $(hdrdir)/ruby/internal/intern/eval.h
ossl_x509.o: $(hdrdir)/ruby/internal/intern/file.h
-ossl_x509.o: $(hdrdir)/ruby/internal/intern/gc.h
ossl_x509.o: $(hdrdir)/ruby/internal/intern/hash.h
ossl_x509.o: $(hdrdir)/ruby/internal/intern/io.h
ossl_x509.o: $(hdrdir)/ruby/internal/intern/load.h
@@ -4619,7 +4813,6 @@ ossl_x509.o: $(hdrdir)/ruby/internal/memory.h
ossl_x509.o: $(hdrdir)/ruby/internal/method.h
ossl_x509.o: $(hdrdir)/ruby/internal/module.h
ossl_x509.o: $(hdrdir)/ruby/internal/newobj.h
-ossl_x509.o: $(hdrdir)/ruby/internal/rgengc.h
ossl_x509.o: $(hdrdir)/ruby/internal/scan_args.h
ossl_x509.o: $(hdrdir)/ruby/internal/special_consts.h
ossl_x509.o: $(hdrdir)/ruby/internal/static_assert.h
@@ -4655,6 +4848,7 @@ ossl_x509.o: ossl_ocsp.h
ossl_x509.o: ossl_pkcs12.h
ossl_x509.o: ossl_pkcs7.h
ossl_x509.o: ossl_pkey.h
+ossl_x509.o: ossl_provider.h
ossl_x509.o: ossl_rand.h
ossl_x509.o: ossl_ssl.h
ossl_x509.o: ossl_ts.h
@@ -4714,6 +4908,7 @@ ossl_x509attr.o: $(hdrdir)/ruby/internal/attr/noexcept.h
ossl_x509attr.o: $(hdrdir)/ruby/internal/attr/noinline.h
ossl_x509attr.o: $(hdrdir)/ruby/internal/attr/nonnull.h
ossl_x509attr.o: $(hdrdir)/ruby/internal/attr/noreturn.h
+ossl_x509attr.o: $(hdrdir)/ruby/internal/attr/packed_struct.h
ossl_x509attr.o: $(hdrdir)/ruby/internal/attr/pure.h
ossl_x509attr.o: $(hdrdir)/ruby/internal/attr/restrict.h
ossl_x509attr.o: $(hdrdir)/ruby/internal/attr/returns_nonnull.h
@@ -4782,7 +4977,6 @@ ossl_x509attr.o: $(hdrdir)/ruby/internal/intern/enumerator.h
ossl_x509attr.o: $(hdrdir)/ruby/internal/intern/error.h
ossl_x509attr.o: $(hdrdir)/ruby/internal/intern/eval.h
ossl_x509attr.o: $(hdrdir)/ruby/internal/intern/file.h
-ossl_x509attr.o: $(hdrdir)/ruby/internal/intern/gc.h
ossl_x509attr.o: $(hdrdir)/ruby/internal/intern/hash.h
ossl_x509attr.o: $(hdrdir)/ruby/internal/intern/io.h
ossl_x509attr.o: $(hdrdir)/ruby/internal/intern/load.h
@@ -4813,7 +5007,6 @@ ossl_x509attr.o: $(hdrdir)/ruby/internal/memory.h
ossl_x509attr.o: $(hdrdir)/ruby/internal/method.h
ossl_x509attr.o: $(hdrdir)/ruby/internal/module.h
ossl_x509attr.o: $(hdrdir)/ruby/internal/newobj.h
-ossl_x509attr.o: $(hdrdir)/ruby/internal/rgengc.h
ossl_x509attr.o: $(hdrdir)/ruby/internal/scan_args.h
ossl_x509attr.o: $(hdrdir)/ruby/internal/special_consts.h
ossl_x509attr.o: $(hdrdir)/ruby/internal/static_assert.h
@@ -4849,6 +5042,7 @@ ossl_x509attr.o: ossl_ocsp.h
ossl_x509attr.o: ossl_pkcs12.h
ossl_x509attr.o: ossl_pkcs7.h
ossl_x509attr.o: ossl_pkey.h
+ossl_x509attr.o: ossl_provider.h
ossl_x509attr.o: ossl_rand.h
ossl_x509attr.o: ossl_ssl.h
ossl_x509attr.o: ossl_ts.h
@@ -4908,6 +5102,7 @@ ossl_x509cert.o: $(hdrdir)/ruby/internal/attr/noexcept.h
ossl_x509cert.o: $(hdrdir)/ruby/internal/attr/noinline.h
ossl_x509cert.o: $(hdrdir)/ruby/internal/attr/nonnull.h
ossl_x509cert.o: $(hdrdir)/ruby/internal/attr/noreturn.h
+ossl_x509cert.o: $(hdrdir)/ruby/internal/attr/packed_struct.h
ossl_x509cert.o: $(hdrdir)/ruby/internal/attr/pure.h
ossl_x509cert.o: $(hdrdir)/ruby/internal/attr/restrict.h
ossl_x509cert.o: $(hdrdir)/ruby/internal/attr/returns_nonnull.h
@@ -4976,7 +5171,6 @@ ossl_x509cert.o: $(hdrdir)/ruby/internal/intern/enumerator.h
ossl_x509cert.o: $(hdrdir)/ruby/internal/intern/error.h
ossl_x509cert.o: $(hdrdir)/ruby/internal/intern/eval.h
ossl_x509cert.o: $(hdrdir)/ruby/internal/intern/file.h
-ossl_x509cert.o: $(hdrdir)/ruby/internal/intern/gc.h
ossl_x509cert.o: $(hdrdir)/ruby/internal/intern/hash.h
ossl_x509cert.o: $(hdrdir)/ruby/internal/intern/io.h
ossl_x509cert.o: $(hdrdir)/ruby/internal/intern/load.h
@@ -5007,7 +5201,6 @@ ossl_x509cert.o: $(hdrdir)/ruby/internal/memory.h
ossl_x509cert.o: $(hdrdir)/ruby/internal/method.h
ossl_x509cert.o: $(hdrdir)/ruby/internal/module.h
ossl_x509cert.o: $(hdrdir)/ruby/internal/newobj.h
-ossl_x509cert.o: $(hdrdir)/ruby/internal/rgengc.h
ossl_x509cert.o: $(hdrdir)/ruby/internal/scan_args.h
ossl_x509cert.o: $(hdrdir)/ruby/internal/special_consts.h
ossl_x509cert.o: $(hdrdir)/ruby/internal/static_assert.h
@@ -5043,6 +5236,7 @@ ossl_x509cert.o: ossl_ocsp.h
ossl_x509cert.o: ossl_pkcs12.h
ossl_x509cert.o: ossl_pkcs7.h
ossl_x509cert.o: ossl_pkey.h
+ossl_x509cert.o: ossl_provider.h
ossl_x509cert.o: ossl_rand.h
ossl_x509cert.o: ossl_ssl.h
ossl_x509cert.o: ossl_ts.h
@@ -5102,6 +5296,7 @@ ossl_x509crl.o: $(hdrdir)/ruby/internal/attr/noexcept.h
ossl_x509crl.o: $(hdrdir)/ruby/internal/attr/noinline.h
ossl_x509crl.o: $(hdrdir)/ruby/internal/attr/nonnull.h
ossl_x509crl.o: $(hdrdir)/ruby/internal/attr/noreturn.h
+ossl_x509crl.o: $(hdrdir)/ruby/internal/attr/packed_struct.h
ossl_x509crl.o: $(hdrdir)/ruby/internal/attr/pure.h
ossl_x509crl.o: $(hdrdir)/ruby/internal/attr/restrict.h
ossl_x509crl.o: $(hdrdir)/ruby/internal/attr/returns_nonnull.h
@@ -5170,7 +5365,6 @@ ossl_x509crl.o: $(hdrdir)/ruby/internal/intern/enumerator.h
ossl_x509crl.o: $(hdrdir)/ruby/internal/intern/error.h
ossl_x509crl.o: $(hdrdir)/ruby/internal/intern/eval.h
ossl_x509crl.o: $(hdrdir)/ruby/internal/intern/file.h
-ossl_x509crl.o: $(hdrdir)/ruby/internal/intern/gc.h
ossl_x509crl.o: $(hdrdir)/ruby/internal/intern/hash.h
ossl_x509crl.o: $(hdrdir)/ruby/internal/intern/io.h
ossl_x509crl.o: $(hdrdir)/ruby/internal/intern/load.h
@@ -5201,7 +5395,6 @@ ossl_x509crl.o: $(hdrdir)/ruby/internal/memory.h
ossl_x509crl.o: $(hdrdir)/ruby/internal/method.h
ossl_x509crl.o: $(hdrdir)/ruby/internal/module.h
ossl_x509crl.o: $(hdrdir)/ruby/internal/newobj.h
-ossl_x509crl.o: $(hdrdir)/ruby/internal/rgengc.h
ossl_x509crl.o: $(hdrdir)/ruby/internal/scan_args.h
ossl_x509crl.o: $(hdrdir)/ruby/internal/special_consts.h
ossl_x509crl.o: $(hdrdir)/ruby/internal/static_assert.h
@@ -5237,6 +5430,7 @@ ossl_x509crl.o: ossl_ocsp.h
ossl_x509crl.o: ossl_pkcs12.h
ossl_x509crl.o: ossl_pkcs7.h
ossl_x509crl.o: ossl_pkey.h
+ossl_x509crl.o: ossl_provider.h
ossl_x509crl.o: ossl_rand.h
ossl_x509crl.o: ossl_ssl.h
ossl_x509crl.o: ossl_ts.h
@@ -5296,6 +5490,7 @@ ossl_x509ext.o: $(hdrdir)/ruby/internal/attr/noexcept.h
ossl_x509ext.o: $(hdrdir)/ruby/internal/attr/noinline.h
ossl_x509ext.o: $(hdrdir)/ruby/internal/attr/nonnull.h
ossl_x509ext.o: $(hdrdir)/ruby/internal/attr/noreturn.h
+ossl_x509ext.o: $(hdrdir)/ruby/internal/attr/packed_struct.h
ossl_x509ext.o: $(hdrdir)/ruby/internal/attr/pure.h
ossl_x509ext.o: $(hdrdir)/ruby/internal/attr/restrict.h
ossl_x509ext.o: $(hdrdir)/ruby/internal/attr/returns_nonnull.h
@@ -5364,7 +5559,6 @@ ossl_x509ext.o: $(hdrdir)/ruby/internal/intern/enumerator.h
ossl_x509ext.o: $(hdrdir)/ruby/internal/intern/error.h
ossl_x509ext.o: $(hdrdir)/ruby/internal/intern/eval.h
ossl_x509ext.o: $(hdrdir)/ruby/internal/intern/file.h
-ossl_x509ext.o: $(hdrdir)/ruby/internal/intern/gc.h
ossl_x509ext.o: $(hdrdir)/ruby/internal/intern/hash.h
ossl_x509ext.o: $(hdrdir)/ruby/internal/intern/io.h
ossl_x509ext.o: $(hdrdir)/ruby/internal/intern/load.h
@@ -5395,7 +5589,6 @@ ossl_x509ext.o: $(hdrdir)/ruby/internal/memory.h
ossl_x509ext.o: $(hdrdir)/ruby/internal/method.h
ossl_x509ext.o: $(hdrdir)/ruby/internal/module.h
ossl_x509ext.o: $(hdrdir)/ruby/internal/newobj.h
-ossl_x509ext.o: $(hdrdir)/ruby/internal/rgengc.h
ossl_x509ext.o: $(hdrdir)/ruby/internal/scan_args.h
ossl_x509ext.o: $(hdrdir)/ruby/internal/special_consts.h
ossl_x509ext.o: $(hdrdir)/ruby/internal/static_assert.h
@@ -5431,6 +5624,7 @@ ossl_x509ext.o: ossl_ocsp.h
ossl_x509ext.o: ossl_pkcs12.h
ossl_x509ext.o: ossl_pkcs7.h
ossl_x509ext.o: ossl_pkey.h
+ossl_x509ext.o: ossl_provider.h
ossl_x509ext.o: ossl_rand.h
ossl_x509ext.o: ossl_ssl.h
ossl_x509ext.o: ossl_ts.h
@@ -5490,6 +5684,7 @@ ossl_x509name.o: $(hdrdir)/ruby/internal/attr/noexcept.h
ossl_x509name.o: $(hdrdir)/ruby/internal/attr/noinline.h
ossl_x509name.o: $(hdrdir)/ruby/internal/attr/nonnull.h
ossl_x509name.o: $(hdrdir)/ruby/internal/attr/noreturn.h
+ossl_x509name.o: $(hdrdir)/ruby/internal/attr/packed_struct.h
ossl_x509name.o: $(hdrdir)/ruby/internal/attr/pure.h
ossl_x509name.o: $(hdrdir)/ruby/internal/attr/restrict.h
ossl_x509name.o: $(hdrdir)/ruby/internal/attr/returns_nonnull.h
@@ -5558,7 +5753,6 @@ ossl_x509name.o: $(hdrdir)/ruby/internal/intern/enumerator.h
ossl_x509name.o: $(hdrdir)/ruby/internal/intern/error.h
ossl_x509name.o: $(hdrdir)/ruby/internal/intern/eval.h
ossl_x509name.o: $(hdrdir)/ruby/internal/intern/file.h
-ossl_x509name.o: $(hdrdir)/ruby/internal/intern/gc.h
ossl_x509name.o: $(hdrdir)/ruby/internal/intern/hash.h
ossl_x509name.o: $(hdrdir)/ruby/internal/intern/io.h
ossl_x509name.o: $(hdrdir)/ruby/internal/intern/load.h
@@ -5589,7 +5783,6 @@ ossl_x509name.o: $(hdrdir)/ruby/internal/memory.h
ossl_x509name.o: $(hdrdir)/ruby/internal/method.h
ossl_x509name.o: $(hdrdir)/ruby/internal/module.h
ossl_x509name.o: $(hdrdir)/ruby/internal/newobj.h
-ossl_x509name.o: $(hdrdir)/ruby/internal/rgengc.h
ossl_x509name.o: $(hdrdir)/ruby/internal/scan_args.h
ossl_x509name.o: $(hdrdir)/ruby/internal/special_consts.h
ossl_x509name.o: $(hdrdir)/ruby/internal/static_assert.h
@@ -5625,6 +5818,7 @@ ossl_x509name.o: ossl_ocsp.h
ossl_x509name.o: ossl_pkcs12.h
ossl_x509name.o: ossl_pkcs7.h
ossl_x509name.o: ossl_pkey.h
+ossl_x509name.o: ossl_provider.h
ossl_x509name.o: ossl_rand.h
ossl_x509name.o: ossl_ssl.h
ossl_x509name.o: ossl_ts.h
@@ -5684,6 +5878,7 @@ ossl_x509req.o: $(hdrdir)/ruby/internal/attr/noexcept.h
ossl_x509req.o: $(hdrdir)/ruby/internal/attr/noinline.h
ossl_x509req.o: $(hdrdir)/ruby/internal/attr/nonnull.h
ossl_x509req.o: $(hdrdir)/ruby/internal/attr/noreturn.h
+ossl_x509req.o: $(hdrdir)/ruby/internal/attr/packed_struct.h
ossl_x509req.o: $(hdrdir)/ruby/internal/attr/pure.h
ossl_x509req.o: $(hdrdir)/ruby/internal/attr/restrict.h
ossl_x509req.o: $(hdrdir)/ruby/internal/attr/returns_nonnull.h
@@ -5752,7 +5947,6 @@ ossl_x509req.o: $(hdrdir)/ruby/internal/intern/enumerator.h
ossl_x509req.o: $(hdrdir)/ruby/internal/intern/error.h
ossl_x509req.o: $(hdrdir)/ruby/internal/intern/eval.h
ossl_x509req.o: $(hdrdir)/ruby/internal/intern/file.h
-ossl_x509req.o: $(hdrdir)/ruby/internal/intern/gc.h
ossl_x509req.o: $(hdrdir)/ruby/internal/intern/hash.h
ossl_x509req.o: $(hdrdir)/ruby/internal/intern/io.h
ossl_x509req.o: $(hdrdir)/ruby/internal/intern/load.h
@@ -5783,7 +5977,6 @@ ossl_x509req.o: $(hdrdir)/ruby/internal/memory.h
ossl_x509req.o: $(hdrdir)/ruby/internal/method.h
ossl_x509req.o: $(hdrdir)/ruby/internal/module.h
ossl_x509req.o: $(hdrdir)/ruby/internal/newobj.h
-ossl_x509req.o: $(hdrdir)/ruby/internal/rgengc.h
ossl_x509req.o: $(hdrdir)/ruby/internal/scan_args.h
ossl_x509req.o: $(hdrdir)/ruby/internal/special_consts.h
ossl_x509req.o: $(hdrdir)/ruby/internal/static_assert.h
@@ -5819,6 +6012,7 @@ ossl_x509req.o: ossl_ocsp.h
ossl_x509req.o: ossl_pkcs12.h
ossl_x509req.o: ossl_pkcs7.h
ossl_x509req.o: ossl_pkey.h
+ossl_x509req.o: ossl_provider.h
ossl_x509req.o: ossl_rand.h
ossl_x509req.o: ossl_ssl.h
ossl_x509req.o: ossl_ts.h
@@ -5878,6 +6072,7 @@ ossl_x509revoked.o: $(hdrdir)/ruby/internal/attr/noexcept.h
ossl_x509revoked.o: $(hdrdir)/ruby/internal/attr/noinline.h
ossl_x509revoked.o: $(hdrdir)/ruby/internal/attr/nonnull.h
ossl_x509revoked.o: $(hdrdir)/ruby/internal/attr/noreturn.h
+ossl_x509revoked.o: $(hdrdir)/ruby/internal/attr/packed_struct.h
ossl_x509revoked.o: $(hdrdir)/ruby/internal/attr/pure.h
ossl_x509revoked.o: $(hdrdir)/ruby/internal/attr/restrict.h
ossl_x509revoked.o: $(hdrdir)/ruby/internal/attr/returns_nonnull.h
@@ -5946,7 +6141,6 @@ ossl_x509revoked.o: $(hdrdir)/ruby/internal/intern/enumerator.h
ossl_x509revoked.o: $(hdrdir)/ruby/internal/intern/error.h
ossl_x509revoked.o: $(hdrdir)/ruby/internal/intern/eval.h
ossl_x509revoked.o: $(hdrdir)/ruby/internal/intern/file.h
-ossl_x509revoked.o: $(hdrdir)/ruby/internal/intern/gc.h
ossl_x509revoked.o: $(hdrdir)/ruby/internal/intern/hash.h
ossl_x509revoked.o: $(hdrdir)/ruby/internal/intern/io.h
ossl_x509revoked.o: $(hdrdir)/ruby/internal/intern/load.h
@@ -5977,7 +6171,6 @@ ossl_x509revoked.o: $(hdrdir)/ruby/internal/memory.h
ossl_x509revoked.o: $(hdrdir)/ruby/internal/method.h
ossl_x509revoked.o: $(hdrdir)/ruby/internal/module.h
ossl_x509revoked.o: $(hdrdir)/ruby/internal/newobj.h
-ossl_x509revoked.o: $(hdrdir)/ruby/internal/rgengc.h
ossl_x509revoked.o: $(hdrdir)/ruby/internal/scan_args.h
ossl_x509revoked.o: $(hdrdir)/ruby/internal/special_consts.h
ossl_x509revoked.o: $(hdrdir)/ruby/internal/static_assert.h
@@ -6013,6 +6206,7 @@ ossl_x509revoked.o: ossl_ocsp.h
ossl_x509revoked.o: ossl_pkcs12.h
ossl_x509revoked.o: ossl_pkcs7.h
ossl_x509revoked.o: ossl_pkey.h
+ossl_x509revoked.o: ossl_provider.h
ossl_x509revoked.o: ossl_rand.h
ossl_x509revoked.o: ossl_ssl.h
ossl_x509revoked.o: ossl_ts.h
@@ -6072,6 +6266,7 @@ ossl_x509store.o: $(hdrdir)/ruby/internal/attr/noexcept.h
ossl_x509store.o: $(hdrdir)/ruby/internal/attr/noinline.h
ossl_x509store.o: $(hdrdir)/ruby/internal/attr/nonnull.h
ossl_x509store.o: $(hdrdir)/ruby/internal/attr/noreturn.h
+ossl_x509store.o: $(hdrdir)/ruby/internal/attr/packed_struct.h
ossl_x509store.o: $(hdrdir)/ruby/internal/attr/pure.h
ossl_x509store.o: $(hdrdir)/ruby/internal/attr/restrict.h
ossl_x509store.o: $(hdrdir)/ruby/internal/attr/returns_nonnull.h
@@ -6140,7 +6335,6 @@ ossl_x509store.o: $(hdrdir)/ruby/internal/intern/enumerator.h
ossl_x509store.o: $(hdrdir)/ruby/internal/intern/error.h
ossl_x509store.o: $(hdrdir)/ruby/internal/intern/eval.h
ossl_x509store.o: $(hdrdir)/ruby/internal/intern/file.h
-ossl_x509store.o: $(hdrdir)/ruby/internal/intern/gc.h
ossl_x509store.o: $(hdrdir)/ruby/internal/intern/hash.h
ossl_x509store.o: $(hdrdir)/ruby/internal/intern/io.h
ossl_x509store.o: $(hdrdir)/ruby/internal/intern/load.h
@@ -6171,7 +6365,6 @@ ossl_x509store.o: $(hdrdir)/ruby/internal/memory.h
ossl_x509store.o: $(hdrdir)/ruby/internal/method.h
ossl_x509store.o: $(hdrdir)/ruby/internal/module.h
ossl_x509store.o: $(hdrdir)/ruby/internal/newobj.h
-ossl_x509store.o: $(hdrdir)/ruby/internal/rgengc.h
ossl_x509store.o: $(hdrdir)/ruby/internal/scan_args.h
ossl_x509store.o: $(hdrdir)/ruby/internal/special_consts.h
ossl_x509store.o: $(hdrdir)/ruby/internal/static_assert.h
@@ -6207,6 +6400,7 @@ ossl_x509store.o: ossl_ocsp.h
ossl_x509store.o: ossl_pkcs12.h
ossl_x509store.o: ossl_pkcs7.h
ossl_x509store.o: ossl_pkey.h
+ossl_x509store.o: ossl_provider.h
ossl_x509store.o: ossl_rand.h
ossl_x509store.o: ossl_ssl.h
ossl_x509store.o: ossl_ts.h
diff --git a/ext/openssl/extconf.rb b/ext/openssl/extconf.rb
index bc3e4d3a21..56f4a1c3ab 100644
--- a/ext/openssl/extconf.rb
+++ b/ext/openssl/extconf.rb
@@ -13,20 +13,41 @@
require "mkmf"
-dir_config_given = dir_config("openssl").any?
+ssl_dirs = nil
+if defined?(::TruffleRuby)
+ # Always respect the openssl prefix chosen by truffle/openssl-prefix
+ require 'truffle/openssl-prefix'
+ ssl_dirs = dir_config("openssl", ENV["OPENSSL_PREFIX"])
+else
+ ssl_dirs = dir_config("openssl")
+end
+dir_config_given = ssl_dirs.any?
+
+_, ssl_ldir = ssl_dirs
+if ssl_ldir&.split(File::PATH_SEPARATOR)&.none? { |dir| File.directory?(dir) }
+ # According to the `mkmf.rb#dir_config`, the `--with-openssl-dir=<dir>` uses
+ # the value of the `File.basename(RbConfig::MAKEFILE_CONFIG["libdir"])` as a
+ # loaded library directory name.
+ ruby_ldir_name = File.basename(RbConfig::MAKEFILE_CONFIG["libdir"])
+
+ raise "OpenSSL library directory could not be found in '#{ssl_ldir}'. " \
+ "You might want to fix this error in one of the following ways.\n" \
+ " * Recompile OpenSSL by configuring it with --libdir=#{ruby_ldir_name} " \
+ " to specify the OpenSSL library directory.\n" \
+ " * Recompile Ruby by configuring it with --libdir=<dir> to specify the " \
+ "Ruby library directory.\n" \
+ " * Compile this openssl gem with --with-openssl-include=<dir> and " \
+ "--with-openssl-lib=<dir> options to specify the OpenSSL include and " \
+ "library directories."
+end
+
dir_config("kerberos")
Logging::message "=== OpenSSL for Ruby configurator ===\n"
-##
-# Adds -DOSSL_DEBUG for compilation and some more targets when GCC is used
-# To turn it on, use: --with-debug or --enable-debug
-#
-if with_config("debug") or enable_config("debug")
- $defs.push("-DOSSL_DEBUG")
-end
$defs.push("-D""OPENSSL_SUPPRESS_DEPRECATED")
+have_func("rb_io_descriptor")
have_func("rb_io_maybe_wait(0, Qnil, Qnil, Qnil)", "ruby/io.h") # Ruby 3.1
Logging::message "=== Checking for system dependent stuff... ===\n"
@@ -191,6 +212,12 @@ have_func("EVP_PKEY_dup(NULL)", evp_h)
Logging::message "=== Checking done. ===\n"
+# Append flags from environment variables.
+extcflags = ENV["RUBY_OPENSSL_EXTCFLAGS"]
+append_cflags(extcflags.split) if extcflags
+extldflags = ENV["RUBY_OPENSSL_EXTLDFLAGS"]
+append_ldflags(extldflags.split) if extldflags
+
create_header
create_makefile("openssl")
Logging::message "Done.\n"
diff --git a/ext/openssl/lib/openssl/buffering.rb b/ext/openssl/lib/openssl/buffering.rb
index d47e1082ef..9570f14f37 100644
--- a/ext/openssl/lib/openssl/buffering.rb
+++ b/ext/openssl/lib/openssl/buffering.rb
@@ -93,9 +93,7 @@ module OpenSSL::Buffering
nil
else
size = @rbuffer.size unless size
- ret = @rbuffer[0, size]
- @rbuffer[0, size] = ""
- ret
+ @rbuffer.slice!(0, size)
end
end
@@ -106,8 +104,7 @@ module OpenSSL::Buffering
#
# Get the next 8bit byte from `ssl`. Returns `nil` on EOF
def getbyte
- byte = read(1)
- byte && byte.unpack1("C")
+ read(1)&.ord
end
##
diff --git a/ext/openssl/lib/openssl/ssl.rb b/ext/openssl/lib/openssl/ssl.rb
index ea8bb2a18e..e557b8b483 100644
--- a/ext/openssl/lib/openssl/ssl.rb
+++ b/ext/openssl/lib/openssl/ssl.rb
@@ -34,21 +34,21 @@ module OpenSSL
}
if defined?(OpenSSL::PKey::DH)
- DEFAULT_2048 = OpenSSL::PKey::DH.new <<-_end_of_pem_
+ DH_ffdhe2048 = OpenSSL::PKey::DH.new <<-_end_of_pem_
-----BEGIN DH PARAMETERS-----
-MIIBCAKCAQEA7E6kBrYiyvmKAMzQ7i8WvwVk9Y/+f8S7sCTN712KkK3cqd1jhJDY
-JbrYeNV3kUIKhPxWHhObHKpD1R84UpL+s2b55+iMd6GmL7OYmNIT/FccKhTcveab
-VBmZT86BZKYyf45hUF9FOuUM9xPzuK3Vd8oJQvfYMCd7LPC0taAEljQLR4Edf8E6
-YoaOffgTf5qxiwkjnlVZQc3whgnEt9FpVMvQ9eknyeGB5KHfayAc3+hUAvI3/Cr3
-1bNveX5wInh5GDx1FGhKBZ+s1H+aedudCm7sCgRwv8lKWYGiHzObSma8A86KG+MD
-7Lo5JquQ3DlBodj3IDyPrxIv96lvRPFtAwIBAg==
+MIIBCAKCAQEA//////////+t+FRYortKmq/cViAnPTzx2LnFg84tNpWp4TZBFGQz
++8yTnc4kmz75fS/jY2MMddj2gbICrsRhetPfHtXV/WVhJDP1H18GbtCFY2VVPe0a
+87VXE15/V8k1mE8McODmi3fipona8+/och3xWKE2rec1MKzKT0g6eXq8CrGCsyT7
+YdEIqUuyyOP7uWrat2DX9GgdT0Kj3jlN9K5W7edjcrsZCwenyO4KbXCeAvzhzffi
+7MA0BM0oNC9hkXL+nOmFg/+OTxIy7vKBg8P+OxtMb61zO7X8vC7CIAXFjvGDfRaD
+ssbzSibBsu/6iGtCOGEoXJf//////////wIBAg==
-----END DH PARAMETERS-----
_end_of_pem_
- private_constant :DEFAULT_2048
+ private_constant :DH_ffdhe2048
DEFAULT_TMP_DH_CALLBACK = lambda { |ctx, is_export, keylen| # :nodoc:
warn "using default DH parameters." if $VERBOSE
- DEFAULT_2048
+ DH_ffdhe2048
}
end
@@ -494,7 +494,7 @@ YoaOffgTf5qxiwkjnlVZQc3whgnEt9FpVMvQ9eknyeGB5KHfayAc3+hUAvI3/Cr3
unless ctx.session_id_context
# see #6137 - session id may not exceed 32 bytes
prng = ::Random.new($0.hash)
- session_id = prng.bytes(16).unpack('H*')[0]
+ session_id = prng.bytes(16).unpack1('H*')
@ctx.session_id_context = session_id
end
@start_immediately = true
diff --git a/ext/openssl/lib/openssl/version.rb b/ext/openssl/lib/openssl/version.rb
index 4163f55064..9315a79381 100644
--- a/ext/openssl/lib/openssl/version.rb
+++ b/ext/openssl/lib/openssl/version.rb
@@ -1,5 +1,5 @@
# frozen_string_literal: true
module OpenSSL
- VERSION = "3.1.0"
+ VERSION = "3.2.0"
end
diff --git a/ext/openssl/openssl.gemspec b/ext/openssl/openssl.gemspec
index 8d83b69193..2765f55401 100644
--- a/ext/openssl/openssl.gemspec
+++ b/ext/openssl/openssl.gemspec
@@ -1,21 +1,27 @@
Gem::Specification.new do |spec|
spec.name = "openssl"
- spec.version = "3.1.0"
+ spec.version = "3.2.0"
spec.authors = ["Martin Bosslet", "SHIBATA Hiroshi", "Zachary Scott", "Kazuki Yamaguchi"]
spec.email = ["ruby-core@ruby-lang.org"]
- spec.summary = %q{OpenSSL provides SSL, TLS and general purpose cryptography.}
- spec.description = %q{It wraps the OpenSSL library.}
+ spec.summary = %q{SSL/TLS and general-purpose cryptography for Ruby}
+ spec.description = %q{OpenSSL for Ruby provides access to SSL/TLS and general-purpose cryptography based on the OpenSSL library.}
spec.homepage = "https://github.com/ruby/openssl"
spec.license = "Ruby"
- spec.files = Dir["lib/**/*.rb", "ext/**/*.{c,h,rb}", "*.md", "BSDL", "LICENSE.txt"]
- spec.require_paths = ["lib"]
- spec.extensions = ["ext/openssl/extconf.rb"]
+ if Gem::Platform === spec.platform and spec.platform =~ 'java' or RUBY_ENGINE == 'jruby'
+ spec.platform = "java"
+ spec.files = []
+ spec.add_runtime_dependency('jruby-openssl', '~> 0.14')
+ else
+ spec.files = Dir["lib/**/*.rb", "ext/**/*.{c,h,rb}", "*.md", "BSDL", "LICENSE.txt"]
+ spec.require_paths = ["lib"]
+ spec.extensions = ["ext/openssl/extconf.rb"]
+ end
spec.extra_rdoc_files = Dir["*.md"]
spec.rdoc_options = ["--main", "README.md"]
- spec.required_ruby_version = ">= 2.6.0"
+ spec.required_ruby_version = ">= 2.7.0"
spec.metadata["msys2_mingw_dependencies"] = "openssl"
end
diff --git a/ext/openssl/ossl.c b/ext/openssl/ossl.c
index 6c532aca94..00eded55cb 100644
--- a/ext/openssl/ossl.c
+++ b/ext/openssl/ossl.c
@@ -207,7 +207,7 @@ ossl_pem_passwd_cb(char *buf, int max_len, int flag, void *pwd_)
while (1) {
/*
- * when the flag is nonzero, this passphrase
+ * when the flag is nonzero, this password
* will be used to perform encryption; otherwise it will
* be used to perform decryption.
*/
@@ -272,23 +272,28 @@ VALUE
ossl_make_error(VALUE exc, VALUE str)
{
unsigned long e;
+ const char *data;
+ int flags;
- e = ERR_peek_last_error();
+ if (NIL_P(str))
+ str = rb_str_new(NULL, 0);
+
+#ifdef HAVE_ERR_GET_ERROR_ALL
+ e = ERR_peek_last_error_all(NULL, NULL, NULL, &data, &flags);
+#else
+ e = ERR_peek_last_error_line_data(NULL, NULL, &data, &flags);
+#endif
if (e) {
- const char *msg = ERR_reason_error_string(e);
+ const char *msg = ERR_reason_error_string(e);
- if (NIL_P(str)) {
- if (msg) str = rb_str_new_cstr(msg);
- }
- else {
- if (RSTRING_LEN(str)) rb_str_cat2(str, ": ");
- rb_str_cat2(str, msg ? msg : "(null)");
- }
- ossl_clear_error();
+ if (RSTRING_LEN(str)) rb_str_cat_cstr(str, ": ");
+ rb_str_cat_cstr(str, msg ? msg : "(null)");
+ if (flags & ERR_TXT_STRING && data)
+ rb_str_catf(str, " (%s)", data);
+ ossl_clear_error();
}
- if (NIL_P(str)) str = rb_str_new(0, 0);
- return rb_exc_new3(exc, str);
+ return rb_exc_new_str(exc, str);
}
void
@@ -369,22 +374,6 @@ ossl_get_errors(VALUE _)
*/
VALUE dOSSL;
-#if !defined(HAVE_VA_ARGS_MACRO)
-void
-ossl_debug(const char *fmt, ...)
-{
- va_list args;
-
- if (dOSSL == Qtrue) {
- fprintf(stderr, "OSSL_DEBUG: ");
- va_start(args, fmt);
- vfprintf(stderr, fmt, args);
- va_end(args);
- fprintf(stderr, " [CONTEXT N/A]\n");
- }
-}
-#endif
-
/*
* call-seq:
* OpenSSL.debug -> true | false
@@ -418,7 +407,11 @@ static VALUE
ossl_fips_mode_get(VALUE self)
{
-#ifdef OPENSSL_FIPS
+#if OSSL_OPENSSL_PREREQ(3, 0, 0)
+ VALUE enabled;
+ enabled = EVP_default_properties_is_fips_enabled(NULL) ? Qtrue : Qfalse;
+ return enabled;
+#elif defined(OPENSSL_FIPS)
VALUE enabled;
enabled = FIPS_mode() ? Qtrue : Qfalse;
return enabled;
@@ -442,8 +435,18 @@ ossl_fips_mode_get(VALUE self)
static VALUE
ossl_fips_mode_set(VALUE self, VALUE enabled)
{
-
-#ifdef OPENSSL_FIPS
+#if OSSL_OPENSSL_PREREQ(3, 0, 0)
+ if (RTEST(enabled)) {
+ if (!EVP_default_properties_enable_fips(NULL, 1)) {
+ ossl_raise(eOSSLError, "Turning on FIPS mode failed");
+ }
+ } else {
+ if (!EVP_default_properties_enable_fips(NULL, 0)) {
+ ossl_raise(eOSSLError, "Turning off FIPS mode failed");
+ }
+ }
+ return enabled;
+#elif defined(OPENSSL_FIPS)
if (RTEST(enabled)) {
int mode = FIPS_mode();
if(!mode && !FIPS_mode_set(1)) /* turning on twice leads to an error */
@@ -460,75 +463,6 @@ ossl_fips_mode_set(VALUE self, VALUE enabled)
#endif
}
-#if defined(OSSL_DEBUG)
-#if !defined(LIBRESSL_VERSION_NUMBER) && \
- (OPENSSL_VERSION_NUMBER >= 0x10100000 && !defined(OPENSSL_NO_CRYPTO_MDEBUG) || \
- defined(CRYPTO_malloc_debug_init))
-/*
- * call-seq:
- * OpenSSL.mem_check_start -> nil
- *
- * Calls CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ON). Starts tracking memory
- * allocations. See also OpenSSL.print_mem_leaks.
- *
- * This is available only when built with a capable OpenSSL and --enable-debug
- * configure option.
- */
-static VALUE
-mem_check_start(VALUE self)
-{
- CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ON);
- return Qnil;
-}
-
-/*
- * call-seq:
- * OpenSSL.print_mem_leaks -> true | false
- *
- * For debugging the Ruby/OpenSSL library. Calls CRYPTO_mem_leaks_fp(stderr).
- * Prints detected memory leaks to standard error. This cleans the global state
- * up thus you cannot use any methods of the library after calling this.
- *
- * Returns +true+ if leaks detected, +false+ otherwise.
- *
- * This is available only when built with a capable OpenSSL and --enable-debug
- * configure option.
- *
- * === Example
- * OpenSSL.mem_check_start
- * NOT_GCED = OpenSSL::PKey::RSA.new(256)
- *
- * END {
- * GC.start
- * OpenSSL.print_mem_leaks # will print the leakage
- * }
- */
-static VALUE
-print_mem_leaks(VALUE self)
-{
-#if OPENSSL_VERSION_NUMBER >= 0x10100000
- int ret;
-#endif
-
-#ifndef HAVE_RB_EXT_RACTOR_SAFE
- // for Ruby 2.x
- void ossl_bn_ctx_free(void); // ossl_bn.c
- ossl_bn_ctx_free();
-#endif
-
-#if OPENSSL_VERSION_NUMBER >= 0x10100000
- ret = CRYPTO_mem_leaks_fp(stderr);
- if (ret < 0)
- ossl_raise(eOSSLError, "CRYPTO_mem_leaks_fp");
- return ret ? Qfalse : Qtrue;
-#else
- CRYPTO_mem_leaks_fp(stderr);
- return Qnil;
-#endif
-}
-#endif
-#endif
-
#if !defined(HAVE_OPENSSL_110_THREADING_API)
/**
* Stores locks needed for OpenSSL thread safety
@@ -671,23 +605,21 @@ ossl_crypto_fixed_length_secure_compare(VALUE dummy, VALUE str1, VALUE str2)
*
* key = OpenSSL::PKey::RSA.new 2048
*
- * open 'private_key.pem', 'w' do |io| io.write key.to_pem end
- * open 'public_key.pem', 'w' do |io| io.write key.public_key.to_pem end
+ * File.write 'private_key.pem', key.private_to_pem
+ * File.write 'public_key.pem', key.public_to_pem
*
* === Exporting a Key
*
* Keys saved to disk without encryption are not secure as anyone who gets
* ahold of the key may use it unless it is encrypted. In order to securely
- * export a key you may export it with a pass phrase.
+ * export a key you may export it with a password.
*
* cipher = OpenSSL::Cipher.new 'aes-256-cbc'
- * pass_phrase = 'my secure pass phrase goes here'
+ * password = 'my secure password goes here'
*
- * key_secure = key.export cipher, pass_phrase
+ * key_secure = key.private_to_pem cipher, password
*
- * open 'private.secure.pem', 'w' do |io|
- * io.write key_secure
- * end
+ * File.write 'private.secure.pem', key_secure
*
* OpenSSL::Cipher.ciphers returns a list of available ciphers.
*
@@ -707,13 +639,13 @@ ossl_crypto_fixed_length_secure_compare(VALUE dummy, VALUE str1, VALUE str2)
*
* === Loading an Encrypted Key
*
- * OpenSSL will prompt you for your pass phrase when loading an encrypted key.
- * If you will not be able to type in the pass phrase you may provide it when
+ * OpenSSL will prompt you for your password when loading an encrypted key.
+ * If you will not be able to type in the password you may provide it when
* loading the key:
*
* key4_pem = File.read 'private.secure.pem'
- * pass_phrase = 'my secure pass phrase goes here'
- * key4 = OpenSSL::PKey.read key4_pem, pass_phrase
+ * password = 'my secure password goes here'
+ * key4 = OpenSSL::PKey.read key4_pem, password
*
* == RSA Encryption
*
@@ -829,45 +761,6 @@ ossl_crypto_fixed_length_secure_compare(VALUE dummy, VALUE str1, VALUE str2)
* decrypted = cipher.update encrypted
* decrypted << cipher.final
*
- * == PKCS #5 Password-based Encryption
- *
- * PKCS #5 is a password-based encryption standard documented at
- * RFC2898[http://www.ietf.org/rfc/rfc2898.txt]. It allows a short password or
- * passphrase to be used to create a secure encryption key. If possible, PBKDF2
- * as described above should be used if the circumstances allow it.
- *
- * PKCS #5 uses a Cipher, a pass phrase and a salt to generate an encryption
- * key.
- *
- * pass_phrase = 'my secure pass phrase goes here'
- * salt = '8 octets'
- *
- * === Encryption
- *
- * First set up the cipher for encryption
- *
- * encryptor = OpenSSL::Cipher.new 'aes-256-cbc'
- * encryptor.encrypt
- * encryptor.pkcs5_keyivgen pass_phrase, salt
- *
- * Then pass the data you want to encrypt through
- *
- * encrypted = encryptor.update 'top secret document'
- * encrypted << encryptor.final
- *
- * === Decryption
- *
- * Use a new Cipher instance set up for decryption
- *
- * decryptor = OpenSSL::Cipher.new 'aes-256-cbc'
- * decryptor.decrypt
- * decryptor.pkcs5_keyivgen pass_phrase, salt
- *
- * Then pass the data you want to decrypt through
- *
- * plain = decryptor.update encrypted
- * plain << decryptor.final
- *
* == X509 Certificates
*
* === Creating a Certificate
@@ -945,12 +838,12 @@ ossl_crypto_fixed_length_secure_compare(VALUE dummy, VALUE str1, VALUE str2)
* not readable by other users.
*
* ca_key = OpenSSL::PKey::RSA.new 2048
- * pass_phrase = 'my secure pass phrase goes here'
+ * password = 'my secure password goes here'
*
- * cipher = OpenSSL::Cipher.new 'aes-256-cbc'
+ * cipher = 'aes-256-cbc'
*
* open 'ca_key.pem', 'w', 0400 do |io|
- * io.write ca_key.export(cipher, pass_phrase)
+ * io.write ca_key.private_to_pem(cipher, password)
* end
*
* === CA Certificate
@@ -1170,8 +1063,8 @@ Init_openssl(void)
/*
* Init main module
*/
- mOSSL = rb_define_module("OpenSSL");
rb_global_variable(&mOSSL);
+ mOSSL = rb_define_module("OpenSSL");
rb_define_singleton_method(mOSSL, "fixed_length_secure_compare", ossl_crypto_fixed_length_secure_compare, 2);
/*
@@ -1190,15 +1083,35 @@ Init_openssl(void)
/*
* Version number of OpenSSL the ruby OpenSSL extension was built with
- * (base 16)
+ * (base 16). The formats are below.
+ *
+ * [OpenSSL 3] <tt>0xMNN00PP0 (major minor 00 patch 0)</tt>
+ * [OpenSSL before 3] <tt>0xMNNFFPPS (major minor fix patch status)</tt>
+ * [LibreSSL] <tt>0x20000000 (fixed value)</tt>
+ *
+ * See also the man page OPENSSL_VERSION_NUMBER(3).
*/
rb_define_const(mOSSL, "OPENSSL_VERSION_NUMBER", INT2NUM(OPENSSL_VERSION_NUMBER));
+#if defined(LIBRESSL_VERSION_NUMBER)
+ /*
+ * Version number of LibreSSL the ruby OpenSSL extension was built with
+ * (base 16). The format is <tt>0xMNNFF00f (major minor fix 00
+ * status)</tt>. This constant is only defined in LibreSSL cases.
+ *
+ * See also the man page LIBRESSL_VERSION_NUMBER(3).
+ */
+ rb_define_const(mOSSL, "LIBRESSL_VERSION_NUMBER", INT2NUM(LIBRESSL_VERSION_NUMBER));
+#endif
+
/*
* Boolean indicating whether OpenSSL is FIPS-capable or not
*/
rb_define_const(mOSSL, "OPENSSL_FIPS",
-#ifdef OPENSSL_FIPS
+/* OpenSSL 3 is FIPS-capable even when it is installed without fips option */
+#if OSSL_OPENSSL_PREREQ(3, 0, 0)
+ Qtrue
+#elif defined(OPENSSL_FIPS)
Qtrue
#else
Qfalse
@@ -1208,12 +1121,12 @@ Init_openssl(void)
rb_define_module_function(mOSSL, "fips_mode", ossl_fips_mode_get, 0);
rb_define_module_function(mOSSL, "fips_mode=", ossl_fips_mode_set, 1);
+ rb_global_variable(&eOSSLError);
/*
* Generic error,
* common for all classes under OpenSSL module
*/
eOSSLError = rb_define_class_under(mOSSL,"OpenSSLError",rb_eStandardError);
- rb_global_variable(&eOSSLError);
/*
* Init debug core
@@ -1254,42 +1167,7 @@ Init_openssl(void)
Init_ossl_x509();
Init_ossl_ocsp();
Init_ossl_engine();
+ Init_ossl_provider();
Init_ossl_asn1();
Init_ossl_kdf();
-
-#if defined(OSSL_DEBUG)
- /*
- * For debugging Ruby/OpenSSL. Enable only when built with --enable-debug
- */
-#if !defined(LIBRESSL_VERSION_NUMBER) && \
- (OPENSSL_VERSION_NUMBER >= 0x10100000 && !defined(OPENSSL_NO_CRYPTO_MDEBUG) || \
- defined(CRYPTO_malloc_debug_init))
- rb_define_module_function(mOSSL, "mem_check_start", mem_check_start, 0);
- rb_define_module_function(mOSSL, "print_mem_leaks", print_mem_leaks, 0);
-
-#if defined(CRYPTO_malloc_debug_init) /* <= 1.0.2 */
- CRYPTO_malloc_debug_init();
-#endif
-
-#if defined(V_CRYPTO_MDEBUG_ALL) /* <= 1.0.2 */
- CRYPTO_set_mem_debug_options(V_CRYPTO_MDEBUG_ALL);
-#endif
-
-#if OPENSSL_VERSION_NUMBER < 0x10100000 /* <= 1.0.2 */
- {
- int i;
- /*
- * See crypto/ex_data.c; call def_get_class() immediately to avoid
- * allocations. 15 is the maximum number that is used as the class index
- * in OpenSSL 1.0.2.
- */
- for (i = 0; i <= 15; i++) {
- if (CRYPTO_get_ex_new_index(i, 0, (void *)"ossl-mdebug-dummy", 0, 0, 0) < 0)
- rb_raise(rb_eRuntimeError, "CRYPTO_get_ex_new_index for "
- "class index %d failed", i);
- }
- }
-#endif
-#endif
-#endif
}
diff --git a/ext/openssl/ossl.h b/ext/openssl/ossl.h
index facb80aa73..68d42b71e2 100644
--- a/ext/openssl/ossl.h
+++ b/ext/openssl/ossl.h
@@ -62,6 +62,10 @@
# define OSSL_USE_ENGINE
#endif
+#if OSSL_OPENSSL_PREREQ(3, 0, 0)
+# define OSSL_USE_PROVIDER
+#endif
+
/*
* Common Module
*/
@@ -157,7 +161,6 @@ VALUE ossl_to_der_if_possible(VALUE);
*/
extern VALUE dOSSL;
-#if defined(HAVE_VA_ARGS_MACRO)
#define OSSL_Debug(...) do { \
if (dOSSL == Qtrue) { \
fprintf(stderr, "OSSL_DEBUG: "); \
@@ -166,11 +169,6 @@ extern VALUE dOSSL;
} \
} while (0)
-#else
-void ossl_debug(const char *, ...);
-#define OSSL_Debug ossl_debug
-#endif
-
/*
* Include all parts
*/
@@ -194,6 +192,7 @@ void ossl_debug(const char *, ...);
#endif
#include "ossl_x509.h"
#include "ossl_engine.h"
+#include "ossl_provider.h"
#include "ossl_kdf.h"
void Init_openssl(void);
diff --git a/ext/openssl/ossl_bn.c b/ext/openssl/ossl_bn.c
index bf2bac3679..ce0d3ec7ee 100644
--- a/ext/openssl/ossl_bn.c
+++ b/ext/openssl/ossl_bn.c
@@ -41,7 +41,7 @@ static const rb_data_type_t ossl_bn_type = {
{
0, ossl_bn_free,
},
- 0, 0, RUBY_TYPED_FREE_IMMEDIATELY,
+ 0, 0, RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_WB_PROTECTED,
};
/*
diff --git a/ext/openssl/ossl_cipher.c b/ext/openssl/ossl_cipher.c
index cb8fbc3ca2..110610e1f9 100644
--- a/ext/openssl/ossl_cipher.c
+++ b/ext/openssl/ossl_cipher.c
@@ -42,7 +42,7 @@ static const rb_data_type_t ossl_cipher_type = {
{
0, ossl_cipher_free,
},
- 0, 0, RUBY_TYPED_FREE_IMMEDIATELY,
+ 0, 0, RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_WB_PROTECTED,
};
/*
diff --git a/ext/openssl/ossl_config.c b/ext/openssl/ossl_config.c
index 0bac027487..0e598b4d51 100644
--- a/ext/openssl/ossl_config.c
+++ b/ext/openssl/ossl_config.c
@@ -22,7 +22,7 @@ static const rb_data_type_t ossl_config_type = {
{
0, nconf_free,
},
- 0, 0, RUBY_TYPED_FREE_IMMEDIATELY,
+ 0, 0, RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_WB_PROTECTED,
};
CONF *
diff --git a/ext/openssl/ossl_digest.c b/ext/openssl/ossl_digest.c
index fc326ec14a..16aeeb8106 100644
--- a/ext/openssl/ossl_digest.c
+++ b/ext/openssl/ossl_digest.c
@@ -35,7 +35,7 @@ static const rb_data_type_t ossl_digest_type = {
{
0, ossl_digest_free,
},
- 0, 0, RUBY_TYPED_FREE_IMMEDIATELY,
+ 0, 0, RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_WB_PROTECTED,
};
/*
diff --git a/ext/openssl/ossl_engine.c b/ext/openssl/ossl_engine.c
index 1abde7f766..9e86321d06 100644
--- a/ext/openssl/ossl_engine.c
+++ b/ext/openssl/ossl_engine.c
@@ -78,7 +78,7 @@ static const rb_data_type_t ossl_engine_type = {
{
0, ossl_engine_free,
},
- 0, 0, RUBY_TYPED_FREE_IMMEDIATELY,
+ 0, 0, RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_WB_PROTECTED,
};
/*
diff --git a/ext/openssl/ossl_hmac.c b/ext/openssl/ossl_hmac.c
index 1a5f471a27..c485ba7e67 100644
--- a/ext/openssl/ossl_hmac.c
+++ b/ext/openssl/ossl_hmac.c
@@ -42,7 +42,7 @@ static const rb_data_type_t ossl_hmac_type = {
{
0, ossl_hmac_free,
},
- 0, 0, RUBY_TYPED_FREE_IMMEDIATELY,
+ 0, 0, RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_WB_PROTECTED,
};
static VALUE
diff --git a/ext/openssl/ossl_kdf.c b/ext/openssl/ossl_kdf.c
index 0d25a7304b..48b161d4f4 100644
--- a/ext/openssl/ossl_kdf.c
+++ b/ext/openssl/ossl_kdf.c
@@ -21,7 +21,7 @@ static VALUE mKDF, eKDF;
* (https://tools.ietf.org/html/rfc2898#section-5.2).
*
* === Parameters
- * pass :: The passphrase.
+ * pass :: The password.
* salt :: The salt. Salts prevent attacks based on dictionaries of common
* passwords and attacks based on rainbow tables. It is a public
* value that can be safely stored along with the password (e.g.
diff --git a/ext/openssl/ossl_ns_spki.c b/ext/openssl/ossl_ns_spki.c
index 9b1147367a..9bed1f330e 100644
--- a/ext/openssl/ossl_ns_spki.c
+++ b/ext/openssl/ossl_ns_spki.c
@@ -50,7 +50,7 @@ static const rb_data_type_t ossl_netscape_spki_type = {
{
0, ossl_netscape_spki_free,
},
- 0, 0, RUBY_TYPED_FREE_IMMEDIATELY,
+ 0, 0, RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_WB_PROTECTED,
};
static VALUE
diff --git a/ext/openssl/ossl_ocsp.c b/ext/openssl/ossl_ocsp.c
index 9c8d768d87..df986bb3ee 100644
--- a/ext/openssl/ossl_ocsp.c
+++ b/ext/openssl/ossl_ocsp.c
@@ -86,7 +86,7 @@ static const rb_data_type_t ossl_ocsp_request_type = {
{
0, ossl_ocsp_request_free,
},
- 0, 0, RUBY_TYPED_FREE_IMMEDIATELY,
+ 0, 0, RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_WB_PROTECTED,
};
static void
@@ -100,7 +100,7 @@ static const rb_data_type_t ossl_ocsp_response_type = {
{
0, ossl_ocsp_response_free,
},
- 0, 0, RUBY_TYPED_FREE_IMMEDIATELY,
+ 0, 0, RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_WB_PROTECTED,
};
static void
@@ -114,7 +114,7 @@ static const rb_data_type_t ossl_ocsp_basicresp_type = {
{
0, ossl_ocsp_basicresp_free,
},
- 0, 0, RUBY_TYPED_FREE_IMMEDIATELY,
+ 0, 0, RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_WB_PROTECTED,
};
static void
@@ -128,7 +128,7 @@ static const rb_data_type_t ossl_ocsp_singleresp_type = {
{
0, ossl_ocsp_singleresp_free,
},
- 0, 0, RUBY_TYPED_FREE_IMMEDIATELY,
+ 0, 0, RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_WB_PROTECTED,
};
static void
@@ -142,7 +142,7 @@ static const rb_data_type_t ossl_ocsp_certid_type = {
{
0, ossl_ocsp_certid_free,
},
- 0, 0, RUBY_TYPED_FREE_IMMEDIATELY,
+ 0, 0, RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_WB_PROTECTED,
};
/*
@@ -1701,7 +1701,7 @@ Init_ossl_ocsp(void)
* require 'net/http'
*
* http_response =
- * Net::HTTP.start ocsp_uri.hostname, ocsp.port do |http|
+ * Net::HTTP.start ocsp_uri.hostname, ocsp_uri.port do |http|
* http.post ocsp_uri.path, request.to_der,
* 'content-type' => 'application/ocsp-request'
* end
diff --git a/ext/openssl/ossl_pkcs12.c b/ext/openssl/ossl_pkcs12.c
index fb947df1d0..164b2da465 100644
--- a/ext/openssl/ossl_pkcs12.c
+++ b/ext/openssl/ossl_pkcs12.c
@@ -44,7 +44,7 @@ static const rb_data_type_t ossl_pkcs12_type = {
{
0, ossl_pkcs12_free,
},
- 0, 0, RUBY_TYPED_FREE_IMMEDIATELY,
+ 0, 0, RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_WB_PROTECTED,
};
static VALUE
diff --git a/ext/openssl/ossl_pkcs7.c b/ext/openssl/ossl_pkcs7.c
index dbe5347639..78dcbd667a 100644
--- a/ext/openssl/ossl_pkcs7.c
+++ b/ext/openssl/ossl_pkcs7.c
@@ -65,7 +65,7 @@ const rb_data_type_t ossl_pkcs7_type = {
{
0, ossl_pkcs7_free,
},
- 0, 0, RUBY_TYPED_FREE_IMMEDIATELY,
+ 0, 0, RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_WB_PROTECTED,
};
static void
@@ -79,7 +79,7 @@ static const rb_data_type_t ossl_pkcs7_signer_info_type = {
{
0, ossl_pkcs7_signer_info_free,
},
- 0, 0, RUBY_TYPED_FREE_IMMEDIATELY,
+ 0, 0, RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_WB_PROTECTED,
};
static void
@@ -93,7 +93,7 @@ static const rb_data_type_t ossl_pkcs7_recip_info_type = {
{
0, ossl_pkcs7_recip_info_free,
},
- 0, 0, RUBY_TYPED_FREE_IMMEDIATELY,
+ 0, 0, RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_WB_PROTECTED,
};
/*
diff --git a/ext/openssl/ossl_pkey.c b/ext/openssl/ossl_pkey.c
index 476256679b..013412c27f 100644
--- a/ext/openssl/ossl_pkey.c
+++ b/ext/openssl/ossl_pkey.c
@@ -35,7 +35,7 @@ const rb_data_type_t ossl_evp_pkey_type = {
{
0, ossl_evp_pkey_free,
},
- 0, 0, RUBY_TYPED_FREE_IMMEDIATELY,
+ 0, 0, RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_WB_PROTECTED,
};
static VALUE
@@ -82,31 +82,62 @@ ossl_pkey_new(EVP_PKEY *pkey)
#if OSSL_OPENSSL_PREREQ(3, 0, 0)
# include <openssl/decoder.h>
-EVP_PKEY *
-ossl_pkey_read_generic(BIO *bio, VALUE pass)
+static EVP_PKEY *
+ossl_pkey_read(BIO *bio, const char *input_type, int selection, VALUE pass)
{
void *ppass = (void *)pass;
OSSL_DECODER_CTX *dctx;
EVP_PKEY *pkey = NULL;
int pos = 0, pos2;
- dctx = OSSL_DECODER_CTX_new_for_pkey(&pkey, "DER", NULL, NULL, 0, NULL, NULL);
+ dctx = OSSL_DECODER_CTX_new_for_pkey(&pkey, input_type, NULL, NULL,
+ selection, NULL, NULL);
if (!dctx)
goto out;
- if (OSSL_DECODER_CTX_set_pem_password_cb(dctx, ossl_pem_passwd_cb, ppass) != 1)
- goto out;
-
- /* First check DER */
- if (OSSL_DECODER_from_bio(dctx, bio) == 1)
+ if (OSSL_DECODER_CTX_set_pem_password_cb(dctx, ossl_pem_passwd_cb,
+ ppass) != 1)
goto out;
+ while (1) {
+ if (OSSL_DECODER_from_bio(dctx, bio) == 1)
+ goto out;
+ if (BIO_eof(bio))
+ break;
+ pos2 = BIO_tell(bio);
+ if (pos2 < 0 || pos2 <= pos)
+ break;
+ ossl_clear_error();
+ pos = pos2;
+ }
+ out:
OSSL_BIO_reset(bio);
+ OSSL_DECODER_CTX_free(dctx);
+ return pkey;
+}
- /* Then check PEM; multiple OSSL_DECODER_from_bio() calls may be needed */
- if (OSSL_DECODER_CTX_set_input_type(dctx, "PEM") != 1)
- goto out;
+EVP_PKEY *
+ossl_pkey_read_generic(BIO *bio, VALUE pass)
+{
+ EVP_PKEY *pkey = NULL;
+ /* First check DER, then check PEM. */
+ const char *input_types[] = {"DER", "PEM"};
+ int input_type_num = (int)(sizeof(input_types) / sizeof(char *));
/*
- * First check for private key formats. This is to keep compatibility with
- * ruby/openssl < 3.0 which decoded the following as a private key.
+ * Non-zero selections to try to decode.
+ *
+ * See EVP_PKEY_fromdata(3) - Selections to see all the selections.
+ *
+ * This is a workaround for the decoder failing to decode or returning
+ * bogus keys with selection 0, if a key management provider is different
+ * from a decoder provider. The workaround is to avoid using selection 0.
+ *
+ * Affected OpenSSL versions: >= 3.1.0, <= 3.1.2, or >= 3.0.0, <= 3.0.10
+ * Fixed OpenSSL versions: 3.2, next release of the 3.1.z and 3.0.z
+ *
+ * See https://github.com/openssl/openssl/pull/21519 for details.
+ *
+ * First check for private key formats (EVP_PKEY_KEYPAIR). This is to keep
+ * compatibility with ruby/openssl < 3.0 which decoded the following as a
+ * private key.
*
* $ openssl ecparam -name prime256v1 -genkey -outform PEM
* -----BEGIN EC PARAMETERS-----
@@ -124,36 +155,28 @@ ossl_pkey_read_generic(BIO *bio, VALUE pass)
*
* Note that normally, the input is supposed to contain a single decodable
* PEM block only, so this special handling should not create a new problem.
+ *
+ * Note that we need to create the OSSL_DECODER_CTX variable each time when
+ * we use the different selection as a workaround.
+ * See https://github.com/openssl/openssl/issues/20657 for details.
*/
- OSSL_DECODER_CTX_set_selection(dctx, EVP_PKEY_KEYPAIR);
- while (1) {
- if (OSSL_DECODER_from_bio(dctx, bio) == 1)
- goto out;
- if (BIO_eof(bio))
- break;
- pos2 = BIO_tell(bio);
- if (pos2 < 0 || pos2 <= pos)
- break;
- ossl_clear_error();
- pos = pos2;
- }
-
- OSSL_BIO_reset(bio);
- OSSL_DECODER_CTX_set_selection(dctx, 0);
- while (1) {
- if (OSSL_DECODER_from_bio(dctx, bio) == 1)
- goto out;
- if (BIO_eof(bio))
- break;
- pos2 = BIO_tell(bio);
- if (pos2 < 0 || pos2 <= pos)
- break;
- ossl_clear_error();
- pos = pos2;
+ int selections[] = {
+ EVP_PKEY_KEYPAIR,
+ EVP_PKEY_KEY_PARAMETERS,
+ EVP_PKEY_PUBLIC_KEY
+ };
+ int selection_num = (int)(sizeof(selections) / sizeof(int));
+ int i, j;
+
+ for (i = 0; i < input_type_num; i++) {
+ for (j = 0; j < selection_num; j++) {
+ pkey = ossl_pkey_read(bio, input_types[i], selections[j], pass);
+ if (pkey) {
+ goto out;
+ }
+ }
}
-
out:
- OSSL_DECODER_CTX_free(dctx);
return pkey;
}
#else
@@ -260,9 +283,9 @@ struct pkey_blocking_generate_arg {
EVP_PKEY_CTX *ctx;
EVP_PKEY *pkey;
int state;
- int yield: 1;
- int genparam: 1;
- int interrupted: 1;
+ unsigned int yield: 1;
+ unsigned int genparam: 1;
+ unsigned int interrupted: 1;
};
static VALUE
@@ -612,6 +635,72 @@ ossl_pkey_initialize_copy(VALUE self, VALUE other)
}
#endif
+#ifdef HAVE_EVP_PKEY_NEW_RAW_PRIVATE_KEY
+/*
+ * call-seq:
+ * OpenSSL::PKey.new_raw_private_key(algo, string) -> PKey
+ *
+ * See the OpenSSL documentation for EVP_PKEY_new_raw_private_key()
+ */
+
+static VALUE
+ossl_pkey_new_raw_private_key(VALUE self, VALUE type, VALUE key)
+{
+ EVP_PKEY *pkey;
+ const EVP_PKEY_ASN1_METHOD *ameth;
+ int pkey_id;
+ size_t keylen;
+
+ StringValue(type);
+ StringValue(key);
+ ameth = EVP_PKEY_asn1_find_str(NULL, RSTRING_PTR(type), RSTRING_LENINT(type));
+ if (!ameth)
+ ossl_raise(ePKeyError, "algorithm %"PRIsVALUE" not found", type);
+ EVP_PKEY_asn1_get0_info(&pkey_id, NULL, NULL, NULL, NULL, ameth);
+
+ keylen = RSTRING_LEN(key);
+
+ pkey = EVP_PKEY_new_raw_private_key(pkey_id, NULL, (unsigned char *)RSTRING_PTR(key), keylen);
+ if (!pkey)
+ ossl_raise(ePKeyError, "EVP_PKEY_new_raw_private_key");
+
+ return ossl_pkey_new(pkey);
+}
+#endif
+
+#ifdef HAVE_EVP_PKEY_NEW_RAW_PRIVATE_KEY
+/*
+ * call-seq:
+ * OpenSSL::PKey.new_raw_public_key(algo, string) -> PKey
+ *
+ * See the OpenSSL documentation for EVP_PKEY_new_raw_public_key()
+ */
+
+static VALUE
+ossl_pkey_new_raw_public_key(VALUE self, VALUE type, VALUE key)
+{
+ EVP_PKEY *pkey;
+ const EVP_PKEY_ASN1_METHOD *ameth;
+ int pkey_id;
+ size_t keylen;
+
+ StringValue(type);
+ StringValue(key);
+ ameth = EVP_PKEY_asn1_find_str(NULL, RSTRING_PTR(type), RSTRING_LENINT(type));
+ if (!ameth)
+ ossl_raise(ePKeyError, "algorithm %"PRIsVALUE" not found", type);
+ EVP_PKEY_asn1_get0_info(&pkey_id, NULL, NULL, NULL, NULL, ameth);
+
+ keylen = RSTRING_LEN(key);
+
+ pkey = EVP_PKEY_new_raw_public_key(pkey_id, NULL, (unsigned char *)RSTRING_PTR(key), keylen);
+ if (!pkey)
+ ossl_raise(ePKeyError, "EVP_PKEY_new_raw_public_key");
+
+ return ossl_pkey_new(pkey);
+}
+#endif
+
/*
* call-seq:
* pkey.oid -> string
@@ -793,6 +882,18 @@ ossl_pkey_private_to_der(int argc, VALUE *argv, VALUE self)
*
* Serializes the private key to PEM-encoded PKCS #8 format. See #private_to_der
* for more details.
+ *
+ * An unencrypted PEM-encoded key will look like:
+ *
+ * -----BEGIN PRIVATE KEY-----
+ * [...]
+ * -----END PRIVATE KEY-----
+ *
+ * An encrypted PEM-encoded key will look like:
+ *
+ * -----BEGIN ENCRYPTED PRIVATE KEY-----
+ * [...]
+ * -----END ENCRYPTED PRIVATE KEY-----
*/
static VALUE
ossl_pkey_private_to_pem(int argc, VALUE *argv, VALUE self)
@@ -800,6 +901,35 @@ ossl_pkey_private_to_pem(int argc, VALUE *argv, VALUE self)
return do_pkcs8_export(argc, argv, self, 0);
}
+#ifdef HAVE_EVP_PKEY_NEW_RAW_PRIVATE_KEY
+/*
+ * call-seq:
+ * pkey.raw_private_key => string
+ *
+ * See the OpenSSL documentation for EVP_PKEY_get_raw_private_key()
+ */
+
+static VALUE
+ossl_pkey_raw_private_key(VALUE self)
+{
+ EVP_PKEY *pkey;
+ VALUE str;
+ size_t len;
+
+ GetPKey(self, pkey);
+ if (EVP_PKEY_get_raw_private_key(pkey, NULL, &len) != 1)
+ ossl_raise(ePKeyError, "EVP_PKEY_get_raw_private_key");
+ str = rb_str_new(NULL, len);
+
+ if (EVP_PKEY_get_raw_private_key(pkey, (unsigned char *)RSTRING_PTR(str), &len) != 1)
+ ossl_raise(ePKeyError, "EVP_PKEY_get_raw_private_key");
+
+ rb_str_set_len(str, len);
+
+ return str;
+}
+#endif
+
VALUE
ossl_pkey_export_spki(VALUE self, int to_der)
{
@@ -842,6 +972,12 @@ ossl_pkey_public_to_der(VALUE self)
* pkey.public_to_pem -> string
*
* Serializes the public key to PEM-encoded X.509 SubjectPublicKeyInfo format.
+ *
+ * A PEM-encoded key will look like:
+ *
+ * -----BEGIN PUBLIC KEY-----
+ * [...]
+ * -----END PUBLIC KEY-----
*/
static VALUE
ossl_pkey_public_to_pem(VALUE self)
@@ -849,6 +985,35 @@ ossl_pkey_public_to_pem(VALUE self)
return ossl_pkey_export_spki(self, 0);
}
+#ifdef HAVE_EVP_PKEY_NEW_RAW_PRIVATE_KEY
+/*
+ * call-seq:
+ * pkey.raw_public_key => string
+ *
+ * See the OpenSSL documentation for EVP_PKEY_get_raw_public_key()
+ */
+
+static VALUE
+ossl_pkey_raw_public_key(VALUE self)
+{
+ EVP_PKEY *pkey;
+ VALUE str;
+ size_t len;
+
+ GetPKey(self, pkey);
+ if (EVP_PKEY_get_raw_public_key(pkey, NULL, &len) != 1)
+ ossl_raise(ePKeyError, "EVP_PKEY_get_raw_public_key");
+ str = rb_str_new(NULL, len);
+
+ if (EVP_PKEY_get_raw_public_key(pkey, (unsigned char *)RSTRING_PTR(str), &len) != 1)
+ ossl_raise(ePKeyError, "EVP_PKEY_get_raw_public_key");
+
+ rb_str_set_len(str, len);
+
+ return str;
+}
+#endif
+
/*
* call-seq:
* pkey.compare?(another_pkey) -> true | false
@@ -1586,6 +1751,10 @@ Init_ossl_pkey(void)
rb_define_module_function(mPKey, "read", ossl_pkey_new_from_data, -1);
rb_define_module_function(mPKey, "generate_parameters", ossl_pkey_s_generate_parameters, -1);
rb_define_module_function(mPKey, "generate_key", ossl_pkey_s_generate_key, -1);
+#ifdef HAVE_EVP_PKEY_NEW_RAW_PRIVATE_KEY
+ rb_define_module_function(mPKey, "new_raw_private_key", ossl_pkey_new_raw_private_key, 2);
+ rb_define_module_function(mPKey, "new_raw_public_key", ossl_pkey_new_raw_public_key, 2);
+#endif
rb_define_alloc_func(cPKey, ossl_pkey_alloc);
rb_define_method(cPKey, "initialize", ossl_pkey_initialize, 0);
@@ -1601,6 +1770,10 @@ Init_ossl_pkey(void)
rb_define_method(cPKey, "private_to_pem", ossl_pkey_private_to_pem, -1);
rb_define_method(cPKey, "public_to_der", ossl_pkey_public_to_der, 0);
rb_define_method(cPKey, "public_to_pem", ossl_pkey_public_to_pem, 0);
+#ifdef HAVE_EVP_PKEY_NEW_RAW_PRIVATE_KEY
+ rb_define_method(cPKey, "raw_private_key", ossl_pkey_raw_private_key, 0);
+ rb_define_method(cPKey, "raw_public_key", ossl_pkey_raw_public_key, 0);
+#endif
rb_define_method(cPKey, "compare?", ossl_pkey_compare, 1);
rb_define_method(cPKey, "sign", ossl_pkey_sign, -1);
diff --git a/ext/openssl/ossl_pkey_dh.c b/ext/openssl/ossl_pkey_dh.c
index 83c41378fe..a231814a99 100644
--- a/ext/openssl/ossl_pkey_dh.c
+++ b/ext/openssl/ossl_pkey_dh.c
@@ -216,9 +216,20 @@ ossl_dh_is_private(VALUE self)
* dh.to_pem -> aString
* dh.to_s -> aString
*
- * Encodes this DH to its PEM encoding. Note that any existing per-session
- * public/private keys will *not* get encoded, just the Diffie-Hellman
- * parameters will be encoded.
+ * Serializes the DH parameters to a PEM-encoding.
+ *
+ * Note that any existing per-session public/private keys will *not* get
+ * encoded, just the Diffie-Hellman parameters will be encoded.
+ *
+ * PEM-encoded parameters will look like:
+ *
+ * -----BEGIN DH PARAMETERS-----
+ * [...]
+ * -----END DH PARAMETERS-----
+ *
+ * See also #public_to_pem (X.509 SubjectPublicKeyInfo) and
+ * #private_to_pem (PKCS #8 PrivateKeyInfo or EncryptedPrivateKeyInfo) for
+ * serialization with the private or public key components.
*/
static VALUE
ossl_dh_export(VALUE self)
@@ -244,10 +255,14 @@ ossl_dh_export(VALUE self)
* call-seq:
* dh.to_der -> aString
*
- * Encodes this DH to its DER encoding. Note that any existing per-session
- * public/private keys will *not* get encoded, just the Diffie-Hellman
- * parameters will be encoded.
-
+ * Serializes the DH parameters to a DER-encoding
+ *
+ * Note that any existing per-session public/private keys will *not* get
+ * encoded, just the Diffie-Hellman parameters will be encoded.
+ *
+ * See also #public_to_der (X.509 SubjectPublicKeyInfo) and
+ * #private_to_der (PKCS #8 PrivateKeyInfo or EncryptedPrivateKeyInfo) for
+ * serialization with the private or public key components.
*/
static VALUE
ossl_dh_to_der(VALUE self)
diff --git a/ext/openssl/ossl_pkey_dsa.c b/ext/openssl/ossl_pkey_dsa.c
index b097f8c9d2..058ce73888 100644
--- a/ext/openssl/ossl_pkey_dsa.c
+++ b/ext/openssl/ossl_pkey_dsa.c
@@ -211,16 +211,58 @@ ossl_dsa_is_private(VALUE self)
* dsa.to_pem([cipher, password]) -> aString
* dsa.to_s([cipher, password]) -> aString
*
- * Encodes this DSA to its PEM encoding.
+ * Serializes a private or public key to a PEM-encoding.
*
- * === Parameters
- * * _cipher_ is an OpenSSL::Cipher.
- * * _password_ is a string containing your password.
+ * [When the key contains public components only]
*
- * === Examples
- * DSA.to_pem -> aString
- * DSA.to_pem(cipher, 'mypassword') -> aString
+ * Serializes it into an X.509 SubjectPublicKeyInfo.
+ * The parameters _cipher_ and _password_ are ignored.
*
+ * A PEM-encoded key will look like:
+ *
+ * -----BEGIN PUBLIC KEY-----
+ * [...]
+ * -----END PUBLIC KEY-----
+ *
+ * Consider using #public_to_pem instead. This serializes the key into an
+ * X.509 SubjectPublicKeyInfo regardless of whether it is a public key
+ * or a private key.
+ *
+ * [When the key contains private components, and no parameters are given]
+ *
+ * Serializes it into a traditional \OpenSSL DSAPrivateKey.
+ *
+ * A PEM-encoded key will look like:
+ *
+ * -----BEGIN DSA PRIVATE KEY-----
+ * [...]
+ * -----END DSA PRIVATE KEY-----
+ *
+ * [When the key contains private components, and _cipher_ and _password_ are given]
+ *
+ * Serializes it into a traditional \OpenSSL DSAPrivateKey and encrypts it in
+ * OpenSSL's traditional PEM encryption format.
+ * _cipher_ must be a cipher name understood by OpenSSL::Cipher.new or an
+ * instance of OpenSSL::Cipher.
+ *
+ * An encrypted PEM-encoded key will look like:
+ *
+ * -----BEGIN DSA PRIVATE KEY-----
+ * Proc-Type: 4,ENCRYPTED
+ * DEK-Info: AES-128-CBC,733F5302505B34701FC41F5C0746E4C0
+ *
+ * [...]
+ * -----END DSA PRIVATE KEY-----
+ *
+ * Note that this format uses MD5 to derive the encryption key, and hence
+ * will not be available on FIPS-compliant systems.
+ *
+ * <b>This method is kept for compatibility.</b>
+ * This should only be used when the traditional, non-standard \OpenSSL format
+ * is required.
+ *
+ * Consider using #public_to_pem (X.509 SubjectPublicKeyInfo) or #private_to_pem
+ * (PKCS #8 PrivateKeyInfo or EncryptedPrivateKeyInfo) instead.
*/
static VALUE
ossl_dsa_export(int argc, VALUE *argv, VALUE self)
@@ -238,8 +280,15 @@ ossl_dsa_export(int argc, VALUE *argv, VALUE self)
* call-seq:
* dsa.to_der -> aString
*
- * Encodes this DSA to its DER encoding.
+ * Serializes a private or public key to a DER-encoding.
+ *
+ * See #to_pem for details.
+ *
+ * <b>This method is kept for compatibility.</b>
+ * This should only be used when the traditional, non-standard \OpenSSL format
+ * is required.
*
+ * Consider using #public_to_der or #private_to_der instead.
*/
static VALUE
ossl_dsa_to_der(VALUE self)
diff --git a/ext/openssl/ossl_pkey_ec.c b/ext/openssl/ossl_pkey_ec.c
index 92842f95ac..4b3a1fd0fe 100644
--- a/ext/openssl/ossl_pkey_ec.c
+++ b/ext/openssl/ossl_pkey_ec.c
@@ -400,13 +400,61 @@ static VALUE ossl_ec_key_is_private(VALUE self)
/*
* call-seq:
- * key.export([cipher, pass_phrase]) => String
- * key.to_pem([cipher, pass_phrase]) => String
+ * key.export([cipher, password]) => String
+ * key.to_pem([cipher, password]) => String
*
- * Outputs the EC key in PEM encoding. If _cipher_ and _pass_phrase_ are given
- * they will be used to encrypt the key. _cipher_ must be an OpenSSL::Cipher
- * instance. Note that encryption will only be effective for a private key,
- * public keys will always be encoded in plain text.
+ * Serializes a private or public key to a PEM-encoding.
+ *
+ * [When the key contains public components only]
+ *
+ * Serializes it into an X.509 SubjectPublicKeyInfo.
+ * The parameters _cipher_ and _password_ are ignored.
+ *
+ * A PEM-encoded key will look like:
+ *
+ * -----BEGIN PUBLIC KEY-----
+ * [...]
+ * -----END PUBLIC KEY-----
+ *
+ * Consider using #public_to_pem instead. This serializes the key into an
+ * X.509 SubjectPublicKeyInfo regardless of whether it is a public key
+ * or a private key.
+ *
+ * [When the key contains private components, and no parameters are given]
+ *
+ * Serializes it into a SEC 1/RFC 5915 ECPrivateKey.
+ *
+ * A PEM-encoded key will look like:
+ *
+ * -----BEGIN EC PRIVATE KEY-----
+ * [...]
+ * -----END EC PRIVATE KEY-----
+ *
+ * [When the key contains private components, and _cipher_ and _password_ are given]
+ *
+ * Serializes it into a SEC 1/RFC 5915 ECPrivateKey
+ * and encrypts it in OpenSSL's traditional PEM encryption format.
+ * _cipher_ must be a cipher name understood by OpenSSL::Cipher.new or an
+ * instance of OpenSSL::Cipher.
+ *
+ * An encrypted PEM-encoded key will look like:
+ *
+ * -----BEGIN EC PRIVATE KEY-----
+ * Proc-Type: 4,ENCRYPTED
+ * DEK-Info: AES-128-CBC,733F5302505B34701FC41F5C0746E4C0
+ *
+ * [...]
+ * -----END EC PRIVATE KEY-----
+ *
+ * Note that this format uses MD5 to derive the encryption key, and hence
+ * will not be available on FIPS-compliant systems.
+ *
+ * <b>This method is kept for compatibility.</b>
+ * This should only be used when the SEC 1/RFC 5915 ECPrivateKey format is
+ * required.
+ *
+ * Consider using #public_to_pem (X.509 SubjectPublicKeyInfo) or #private_to_pem
+ * (PKCS #8 PrivateKeyInfo or EncryptedPrivateKeyInfo) instead.
*/
static VALUE
ossl_ec_key_export(int argc, VALUE *argv, VALUE self)
@@ -426,7 +474,15 @@ ossl_ec_key_export(int argc, VALUE *argv, VALUE self)
* call-seq:
* key.to_der => String
*
- * See the OpenSSL documentation for i2d_ECPrivateKey_bio()
+ * Serializes a private or public key to a DER-encoding.
+ *
+ * See #to_pem for details.
+ *
+ * <b>This method is kept for compatibility.</b>
+ * This should only be used when the SEC 1/RFC 5915 ECPrivateKey format is
+ * required.
+ *
+ * Consider using #public_to_der or #private_to_der instead.
*/
static VALUE
ossl_ec_key_to_der(VALUE self)
@@ -530,7 +586,7 @@ static const rb_data_type_t ossl_ec_group_type = {
{
0, ossl_ec_group_free,
},
- 0, 0, RUBY_TYPED_FREE_IMMEDIATELY,
+ 0, 0, RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_WB_PROTECTED,
};
static VALUE
@@ -1115,7 +1171,7 @@ static const rb_data_type_t ossl_ec_point_type = {
{
0, ossl_ec_point_free,
},
- 0, 0, RUBY_TYPED_FREE_IMMEDIATELY,
+ 0, 0, RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_WB_PROTECTED,
};
static VALUE
diff --git a/ext/openssl/ossl_pkey_rsa.c b/ext/openssl/ossl_pkey_rsa.c
index 072adabe62..389f76f309 100644
--- a/ext/openssl/ossl_pkey_rsa.c
+++ b/ext/openssl/ossl_pkey_rsa.c
@@ -50,8 +50,8 @@ VALUE eRSAError;
/*
* call-seq:
* RSA.new -> rsa
- * RSA.new(encoded_key [, passphrase]) -> rsa
- * RSA.new(encoded_key) { passphrase } -> rsa
+ * RSA.new(encoded_key [, password ]) -> rsa
+ * RSA.new(encoded_key) { password } -> rsa
* RSA.new(size [, exponent]) -> rsa
*
* Generates or loads an \RSA keypair.
@@ -61,9 +61,9 @@ VALUE eRSAError;
* #set_crt_params.
*
* If called with a String, tries to parse as DER or PEM encoding of an \RSA key.
- * Note that, if _passphrase_ is not specified but the key is encrypted with a
- * passphrase, \OpenSSL will prompt for it.
- * See also OpenSSL::PKey.read which can parse keys of any kinds.
+ * Note that if _password_ is not specified, but the key is encrypted with a
+ * password, \OpenSSL will prompt for it.
+ * See also OpenSSL::PKey.read which can parse keys of any kind.
*
* If called with a number, generates a new key pair. This form works as an
* alias of RSA.generate.
@@ -71,7 +71,7 @@ VALUE eRSAError;
* Examples:
* OpenSSL::PKey::RSA.new 2048
* OpenSSL::PKey::RSA.new File.read 'rsa.pem'
- * OpenSSL::PKey::RSA.new File.read('rsa.pem'), 'my pass phrase'
+ * OpenSSL::PKey::RSA.new File.read('rsa.pem'), 'my password'
*/
static VALUE
ossl_rsa_initialize(int argc, VALUE *argv, VALUE self)
@@ -217,13 +217,61 @@ can_export_rsaprivatekey(VALUE self)
/*
* call-seq:
- * rsa.export([cipher, pass_phrase]) => PEM-format String
- * rsa.to_pem([cipher, pass_phrase]) => PEM-format String
- * rsa.to_s([cipher, pass_phrase]) => PEM-format String
+ * rsa.export([cipher, password]) => PEM-format String
+ * rsa.to_pem([cipher, password]) => PEM-format String
+ * rsa.to_s([cipher, password]) => PEM-format String
*
- * Outputs this keypair in PEM encoding. If _cipher_ and _pass_phrase_ are
- * given they will be used to encrypt the key. _cipher_ must be an
- * OpenSSL::Cipher instance.
+ * Serializes a private or public key to a PEM-encoding.
+ *
+ * [When the key contains public components only]
+ *
+ * Serializes it into an X.509 SubjectPublicKeyInfo.
+ * The parameters _cipher_ and _password_ are ignored.
+ *
+ * A PEM-encoded key will look like:
+ *
+ * -----BEGIN PUBLIC KEY-----
+ * [...]
+ * -----END PUBLIC KEY-----
+ *
+ * Consider using #public_to_pem instead. This serializes the key into an
+ * X.509 SubjectPublicKeyInfo regardless of whether the key is a public key
+ * or a private key.
+ *
+ * [When the key contains private components, and no parameters are given]
+ *
+ * Serializes it into a PKCS #1 RSAPrivateKey.
+ *
+ * A PEM-encoded key will look like:
+ *
+ * -----BEGIN RSA PRIVATE KEY-----
+ * [...]
+ * -----END RSA PRIVATE KEY-----
+ *
+ * [When the key contains private components, and _cipher_ and _password_ are given]
+ *
+ * Serializes it into a PKCS #1 RSAPrivateKey
+ * and encrypts it in OpenSSL's traditional PEM encryption format.
+ * _cipher_ must be a cipher name understood by OpenSSL::Cipher.new or an
+ * instance of OpenSSL::Cipher.
+ *
+ * An encrypted PEM-encoded key will look like:
+ *
+ * -----BEGIN RSA PRIVATE KEY-----
+ * Proc-Type: 4,ENCRYPTED
+ * DEK-Info: AES-128-CBC,733F5302505B34701FC41F5C0746E4C0
+ *
+ * [...]
+ * -----END RSA PRIVATE KEY-----
+ *
+ * Note that this format uses MD5 to derive the encryption key, and hence
+ * will not be available on FIPS-compliant systems.
+ *
+ * <b>This method is kept for compatibility.</b>
+ * This should only be used when the PKCS #1 RSAPrivateKey format is required.
+ *
+ * Consider using #public_to_pem (X.509 SubjectPublicKeyInfo) or #private_to_pem
+ * (PKCS #8 PrivateKeyInfo or EncryptedPrivateKeyInfo) instead.
*/
static VALUE
ossl_rsa_export(int argc, VALUE *argv, VALUE self)
@@ -238,7 +286,14 @@ ossl_rsa_export(int argc, VALUE *argv, VALUE self)
* call-seq:
* rsa.to_der => DER-format String
*
- * Outputs this keypair in DER encoding.
+ * Serializes a private or public key to a DER-encoding.
+ *
+ * See #to_pem for details.
+ *
+ * <b>This method is kept for compatibility.</b>
+ * This should only be used when the PKCS #1 RSAPrivateKey format is required.
+ *
+ * Consider using #public_to_der or #private_to_der instead.
*/
static VALUE
ossl_rsa_to_der(VALUE self)
diff --git a/ext/openssl/ossl_provider.c b/ext/openssl/ossl_provider.c
new file mode 100644
index 0000000000..981c6ccdc7
--- /dev/null
+++ b/ext/openssl/ossl_provider.c
@@ -0,0 +1,211 @@
+/*
+ * This program is licensed under the same licence as Ruby.
+ * (See the file 'LICENCE'.)
+ */
+#include "ossl.h"
+
+#ifdef OSSL_USE_PROVIDER
+# include <openssl/provider.h>
+
+#define NewProvider(klass) \
+ TypedData_Wrap_Struct((klass), &ossl_provider_type, 0)
+#define SetProvider(obj, provider) do { \
+ if (!(provider)) { \
+ ossl_raise(rb_eRuntimeError, "Provider wasn't initialized."); \
+ } \
+ RTYPEDDATA_DATA(obj) = (provider); \
+} while(0)
+#define GetProvider(obj, provider) do { \
+ TypedData_Get_Struct((obj), OSSL_PROVIDER, &ossl_provider_type, (provider)); \
+ if (!(provider)) { \
+ ossl_raise(rb_eRuntimeError, "PROVIDER wasn't initialized."); \
+ } \
+} while (0)
+
+static const rb_data_type_t ossl_provider_type = {
+ "OpenSSL/Provider",
+ {
+ 0,
+ },
+ 0, 0, RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_WB_PROTECTED,
+};
+
+/*
+ * Classes
+ */
+/* Document-class: OpenSSL::Provider
+ *
+ * This class is the access to openssl's Provider
+ * See also, https://www.openssl.org/docs/manmaster/man7/provider.html
+ */
+static VALUE cProvider;
+/* Document-class: OpenSSL::Provider::ProviderError
+ *
+ * This is the generic exception for OpenSSL::Provider related errors
+ */
+static VALUE eProviderError;
+
+/*
+ * call-seq:
+ * OpenSSL::Provider.load(name) -> provider
+ *
+ * This method loads and initializes a provider
+ */
+static VALUE
+ossl_provider_s_load(VALUE klass, VALUE name)
+{
+ OSSL_PROVIDER *provider = NULL;
+ VALUE obj;
+
+ const char *provider_name_ptr = StringValueCStr(name);
+
+ provider = OSSL_PROVIDER_load(NULL, provider_name_ptr);
+ if (provider == NULL) {
+ ossl_raise(eProviderError, "Failed to load %s provider", provider_name_ptr);
+ }
+ obj = NewProvider(klass);
+ SetProvider(obj, provider);
+
+ return obj;
+}
+
+struct ary_with_state { VALUE ary; int state; };
+struct rb_push_provider_name_args { OSSL_PROVIDER *prov; VALUE ary; };
+
+static VALUE
+rb_push_provider_name(VALUE rb_push_provider_name_args)
+{
+ struct rb_push_provider_name_args *args = (struct rb_push_provider_name_args *)rb_push_provider_name_args;
+
+ VALUE name = rb_str_new2(OSSL_PROVIDER_get0_name(args->prov));
+ return rb_ary_push(args->ary, name);
+}
+
+static int
+push_provider(OSSL_PROVIDER *prov, void *cbdata)
+{
+ struct ary_with_state *ary_with_state = (struct ary_with_state *)cbdata;
+ struct rb_push_provider_name_args args = { prov, ary_with_state->ary };
+
+ rb_protect(rb_push_provider_name, (VALUE)&args, &ary_with_state->state);
+ if (ary_with_state->state) {
+ return 0;
+ } else {
+ return 1;
+ }
+}
+
+/*
+ * call-seq:
+ * OpenSSL::Provider.provider_names -> [provider_name, ...]
+ *
+ * Returns an array of currently loaded provider names.
+ */
+static VALUE
+ossl_provider_s_provider_names(VALUE klass)
+{
+ VALUE ary = rb_ary_new();
+ struct ary_with_state cbdata = { ary, 0 };
+
+ int result = OSSL_PROVIDER_do_all(NULL, &push_provider, (void*)&cbdata);
+ if (result != 1 ) {
+ if (cbdata.state) {
+ rb_jump_tag(cbdata.state);
+ } else {
+ ossl_raise(eProviderError, "Failed to load provider names");
+ }
+ }
+
+ return ary;
+}
+
+/*
+ * call-seq:
+ * provider.unload -> true
+ *
+ * This method unloads this provider.
+ *
+ * if provider unload fails or already unloaded, it raises OpenSSL::Provider::ProviderError
+ */
+static VALUE
+ossl_provider_unload(VALUE self)
+{
+ OSSL_PROVIDER *prov;
+ if (RTYPEDDATA_DATA(self) == NULL) {
+ ossl_raise(eProviderError, "Provider already unloaded.");
+ }
+ GetProvider(self, prov);
+
+ int result = OSSL_PROVIDER_unload(prov);
+
+ if (result != 1) {
+ ossl_raise(eProviderError, "Failed to unload provider");
+ }
+ RTYPEDDATA_DATA(self) = NULL;
+ return Qtrue;
+}
+
+/*
+ * call-seq:
+ * provider.name -> string
+ *
+ * Get the name of this provider.
+ *
+ * if this provider is already unloaded, it raises OpenSSL::Provider::ProviderError
+ */
+static VALUE
+ossl_provider_get_name(VALUE self)
+{
+ OSSL_PROVIDER *prov;
+ if (RTYPEDDATA_DATA(self) == NULL) {
+ ossl_raise(eProviderError, "Provider already unloaded.");
+ }
+ GetProvider(self, prov);
+
+ return rb_str_new2(OSSL_PROVIDER_get0_name(prov));
+}
+
+/*
+ * call-seq:
+ * provider.inspect -> string
+ *
+ * Pretty prints this provider.
+ */
+static VALUE
+ossl_provider_inspect(VALUE self)
+{
+ OSSL_PROVIDER *prov;
+ if (RTYPEDDATA_DATA(self) == NULL ) {
+ return rb_sprintf("#<%"PRIsVALUE" unloaded provider>", rb_obj_class(self));
+ }
+ GetProvider(self, prov);
+
+ return rb_sprintf("#<%"PRIsVALUE" name=\"%s\">",
+ rb_obj_class(self), OSSL_PROVIDER_get0_name(prov));
+}
+
+void
+Init_ossl_provider(void)
+{
+#if 0
+ mOSSL = rb_define_module("OpenSSL");
+ eOSSLError = rb_define_class_under(mOSSL, "OpenSSLError", rb_eStandardError);
+#endif
+
+ cProvider = rb_define_class_under(mOSSL, "Provider", rb_cObject);
+ eProviderError = rb_define_class_under(cProvider, "ProviderError", eOSSLError);
+
+ rb_undef_alloc_func(cProvider);
+ rb_define_singleton_method(cProvider, "load", ossl_provider_s_load, 1);
+ rb_define_singleton_method(cProvider, "provider_names", ossl_provider_s_provider_names, 0);
+
+ rb_define_method(cProvider, "unload", ossl_provider_unload, 0);
+ rb_define_method(cProvider, "name", ossl_provider_get_name, 0);
+ rb_define_method(cProvider, "inspect", ossl_provider_inspect, 0);
+}
+#else
+void
+Init_ossl_provider(void)
+{
+}
+#endif
diff --git a/ext/openssl/ossl_provider.h b/ext/openssl/ossl_provider.h
new file mode 100644
index 0000000000..1d69cb1e44
--- /dev/null
+++ b/ext/openssl/ossl_provider.h
@@ -0,0 +1,5 @@
+#if !defined(OSSL_PROVIDER_H)
+#define OSSL_PROVIDER_H
+
+void Init_ossl_provider(void);
+#endif
diff --git a/ext/openssl/ossl_ssl.c b/ext/openssl/ossl_ssl.c
index f63992664a..236d455ff2 100644
--- a/ext/openssl/ossl_ssl.c
+++ b/ext/openssl/ossl_ssl.c
@@ -77,7 +77,7 @@ static const rb_data_type_t ossl_sslctx_type = {
{
ossl_sslctx_mark, ossl_sslctx_free,
},
- 0, 0, RUBY_TYPED_FREE_IMMEDIATELY,
+ 0, 0, RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_WB_PROTECTED,
};
static VALUE
@@ -885,9 +885,9 @@ ossl_sslctx_setup(VALUE self)
if (ca_path && !SSL_CTX_load_verify_dir(ctx, ca_path))
ossl_raise(eSSLError, "SSL_CTX_load_verify_dir");
#else
- if(ca_file || ca_path){
- if (!SSL_CTX_load_verify_locations(ctx, ca_file, ca_path))
- rb_warning("can't set verify locations");
+ if (ca_file || ca_path) {
+ if (!SSL_CTX_load_verify_locations(ctx, ca_file, ca_path))
+ ossl_raise(eSSLError, "SSL_CTX_load_verify_locations");
}
#endif
@@ -1553,6 +1553,10 @@ ossl_ssl_mark(void *ptr)
{
SSL *ssl = ptr;
rb_gc_mark((VALUE)SSL_get_ex_data(ssl, ossl_ssl_ex_ptr_idx));
+
+ // Note: this reference is stored as @verify_callback so we don't need to mark it.
+ // However we do need to ensure GC compaction won't move it, hence why
+ // we call rb_gc_mark here.
rb_gc_mark((VALUE)SSL_get_ex_data(ssl, ossl_ssl_ex_vcb_idx));
}
@@ -1567,7 +1571,7 @@ const rb_data_type_t ossl_ssl_type = {
{
ossl_ssl_mark, ossl_ssl_free,
},
- 0, 0, RUBY_TYPED_FREE_IMMEDIATELY,
+ 0, 0, RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_WB_PROTECTED,
};
static VALUE
@@ -1646,6 +1650,8 @@ ossl_ssl_initialize(int argc, VALUE *argv, VALUE self)
SSL_set_ex_data(ssl, ossl_ssl_ex_ptr_idx, (void *)self);
SSL_set_info_callback(ssl, ssl_info_cb);
verify_cb = rb_attr_get(v_ctx, id_i_verify_callback);
+ // We don't need to trigger a write barrier because it's already
+ // an instance variable of this object.
SSL_set_ex_data(ssl, ossl_ssl_ex_vcb_idx, (void *)verify_cb);
rb_call_super(0, NULL);
@@ -1653,6 +1659,17 @@ ossl_ssl_initialize(int argc, VALUE *argv, VALUE self)
return self;
}
+#ifndef HAVE_RB_IO_DESCRIPTOR
+static int
+io_descriptor_fallback(VALUE io)
+{
+ rb_io_t *fptr;
+ GetOpenFile(io, fptr);
+ return fptr->fd;
+}
+#define rb_io_descriptor io_descriptor_fallback
+#endif
+
static VALUE
ossl_ssl_setup(VALUE self)
{
@@ -1668,8 +1685,8 @@ ossl_ssl_setup(VALUE self)
GetOpenFile(io, fptr);
rb_io_check_readable(fptr);
rb_io_check_writable(fptr);
- if (!SSL_set_fd(ssl, TO_SOCKET(fptr->fd)))
- ossl_raise(eSSLError, "SSL_set_fd");
+ if (!SSL_set_fd(ssl, TO_SOCKET(rb_io_descriptor(io))))
+ ossl_raise(eSSLError, "SSL_set_fd");
return Qtrue;
}
@@ -1709,21 +1726,25 @@ no_exception_p(VALUE opts)
#endif
static void
-io_wait_writable(rb_io_t *fptr)
+io_wait_writable(VALUE io)
{
#ifdef HAVE_RB_IO_MAYBE_WAIT
- rb_io_maybe_wait_writable(errno, fptr->self, RUBY_IO_TIMEOUT_DEFAULT);
+ rb_io_maybe_wait_writable(errno, io, RUBY_IO_TIMEOUT_DEFAULT);
#else
+ rb_io_t *fptr;
+ GetOpenFile(io, fptr);
rb_io_wait_writable(fptr->fd);
#endif
}
static void
-io_wait_readable(rb_io_t *fptr)
+io_wait_readable(VALUE io)
{
#ifdef HAVE_RB_IO_MAYBE_WAIT
- rb_io_maybe_wait_readable(errno, fptr->self, RUBY_IO_TIMEOUT_DEFAULT);
+ rb_io_maybe_wait_readable(errno, io, RUBY_IO_TIMEOUT_DEFAULT);
#else
+ rb_io_t *fptr;
+ GetOpenFile(io, fptr);
rb_io_wait_readable(fptr->fd);
#endif
}
@@ -1732,75 +1753,74 @@ static VALUE
ossl_start_ssl(VALUE self, int (*func)(SSL *), const char *funcname, VALUE opts)
{
SSL *ssl;
- rb_io_t *fptr;
int ret, ret2;
VALUE cb_state;
int nonblock = opts != Qfalse;
-#if defined(SSL_R_CERTIFICATE_VERIFY_FAILED)
- unsigned long err;
-#endif
rb_ivar_set(self, ID_callback_state, Qnil);
GetSSL(self, ssl);
- GetOpenFile(rb_attr_get(self, id_i_io), fptr);
- for(;;){
- ret = func(ssl);
+ VALUE io = rb_attr_get(self, id_i_io);
+ for (;;) {
+ ret = func(ssl);
- cb_state = rb_attr_get(self, ID_callback_state);
+ cb_state = rb_attr_get(self, ID_callback_state);
if (!NIL_P(cb_state)) {
- /* must cleanup OpenSSL error stack before re-raising */
- ossl_clear_error();
- rb_jump_tag(NUM2INT(cb_state));
- }
+ /* must cleanup OpenSSL error stack before re-raising */
+ ossl_clear_error();
+ rb_jump_tag(NUM2INT(cb_state));
+ }
- if (ret > 0)
- break;
+ if (ret > 0)
+ break;
- switch((ret2 = ssl_get_error(ssl, ret))){
- case SSL_ERROR_WANT_WRITE:
+ switch ((ret2 = ssl_get_error(ssl, ret))) {
+ case SSL_ERROR_WANT_WRITE:
if (no_exception_p(opts)) { return sym_wait_writable; }
write_would_block(nonblock);
- io_wait_writable(fptr);
+ io_wait_writable(io);
continue;
- case SSL_ERROR_WANT_READ:
+ case SSL_ERROR_WANT_READ:
if (no_exception_p(opts)) { return sym_wait_readable; }
read_would_block(nonblock);
- io_wait_readable(fptr);
+ io_wait_readable(io);
continue;
- case SSL_ERROR_SYSCALL:
+ case SSL_ERROR_SYSCALL:
#ifdef __APPLE__
/* See ossl_ssl_write_internal() */
if (errno == EPROTOTYPE)
continue;
#endif
- if (errno) rb_sys_fail(funcname);
- ossl_raise(eSSLError, "%s SYSCALL returned=%d errno=%d peeraddr=%"PRIsVALUE" state=%s",
- funcname, ret2, errno, peeraddr_ip_str(self), SSL_state_string_long(ssl));
-
+ if (errno) rb_sys_fail(funcname);
+ /* fallthrough */
+ default: {
+ VALUE error_append = Qnil;
#if defined(SSL_R_CERTIFICATE_VERIFY_FAILED)
- case SSL_ERROR_SSL:
- err = ERR_peek_last_error();
- if (ERR_GET_LIB(err) == ERR_LIB_SSL &&
- ERR_GET_REASON(err) == SSL_R_CERTIFICATE_VERIFY_FAILED) {
- const char *err_msg = ERR_reason_error_string(err),
- *verify_msg = X509_verify_cert_error_string(SSL_get_verify_result(ssl));
- if (!err_msg)
- err_msg = "(null)";
- if (!verify_msg)
- verify_msg = "(null)";
- ossl_clear_error(); /* let ossl_raise() not append message */
- ossl_raise(eSSLError, "%s returned=%d errno=%d peeraddr=%"PRIsVALUE" state=%s: %s (%s)",
- funcname, ret2, errno, peeraddr_ip_str(self), SSL_state_string_long(ssl),
- err_msg, verify_msg);
- }
+ unsigned long err = ERR_peek_last_error();
+ if (ERR_GET_LIB(err) == ERR_LIB_SSL &&
+ ERR_GET_REASON(err) == SSL_R_CERTIFICATE_VERIFY_FAILED) {
+ const char *err_msg = ERR_reason_error_string(err),
+ *verify_msg = X509_verify_cert_error_string(SSL_get_verify_result(ssl));
+ if (!err_msg)
+ err_msg = "(null)";
+ if (!verify_msg)
+ verify_msg = "(null)";
+ ossl_clear_error(); /* let ossl_raise() not append message */
+ error_append = rb_sprintf(": %s (%s)", err_msg, verify_msg);
+ }
#endif
- /* fallthrough */
- default:
- ossl_raise(eSSLError, "%s returned=%d errno=%d peeraddr=%"PRIsVALUE" state=%s",
- funcname, ret2, errno, peeraddr_ip_str(self), SSL_state_string_long(ssl));
- }
+ ossl_raise(eSSLError,
+ "%s%s returned=%d errno=%d peeraddr=%"PRIsVALUE" state=%s%"PRIsVALUE,
+ funcname,
+ ret2 == SSL_ERROR_SYSCALL ? " SYSCALL" : "",
+ ret2,
+ errno,
+ peeraddr_ip_str(self),
+ SSL_state_string_long(ssl),
+ error_append);
+ }
+ }
}
return self;
@@ -1906,8 +1926,7 @@ ossl_ssl_read_internal(int argc, VALUE *argv, VALUE self, int nonblock)
SSL *ssl;
int ilen;
VALUE len, str;
- rb_io_t *fptr;
- VALUE io, opts = Qnil;
+ VALUE opts = Qnil;
if (nonblock) {
rb_scan_args(argc, argv, "11:", &len, &str, &opts);
@@ -1932,8 +1951,7 @@ ossl_ssl_read_internal(int argc, VALUE *argv, VALUE self, int nonblock)
if (ilen == 0)
return str;
- io = rb_attr_get(self, id_i_io);
- GetOpenFile(io, fptr);
+ VALUE io = rb_attr_get(self, id_i_io);
rb_str_locktmp(str);
for (;;) {
@@ -1953,7 +1971,7 @@ ossl_ssl_read_internal(int argc, VALUE *argv, VALUE self, int nonblock)
if (no_exception_p(opts)) { return sym_wait_writable; }
write_would_block(nonblock);
}
- io_wait_writable(fptr);
+ io_wait_writable(io);
continue;
case SSL_ERROR_WANT_READ:
if (nonblock) {
@@ -1961,7 +1979,7 @@ ossl_ssl_read_internal(int argc, VALUE *argv, VALUE self, int nonblock)
if (no_exception_p(opts)) { return sym_wait_readable; }
read_would_block(nonblock);
}
- io_wait_readable(fptr);
+ io_wait_readable(io);
continue;
case SSL_ERROR_SYSCALL:
if (!ERR_peek_error()) {
@@ -2027,14 +2045,14 @@ ossl_ssl_write_internal(VALUE self, VALUE str, VALUE opts)
SSL *ssl;
rb_io_t *fptr;
int num, nonblock = opts != Qfalse;
- VALUE tmp, io;
+ VALUE tmp;
GetSSL(self, ssl);
if (!ssl_started(ssl))
rb_raise(eSSLError, "SSL session is not started yet");
tmp = rb_str_new_frozen(StringValue(str));
- io = rb_attr_get(self, id_i_io);
+ VALUE io = rb_attr_get(self, id_i_io);
GetOpenFile(io, fptr);
/* SSL_write(3ssl) manpage states num == 0 is undefined */
@@ -2050,12 +2068,12 @@ ossl_ssl_write_internal(VALUE self, VALUE str, VALUE opts)
case SSL_ERROR_WANT_WRITE:
if (no_exception_p(opts)) { return sym_wait_writable; }
write_would_block(nonblock);
- io_wait_writable(fptr);
+ io_wait_writable(io);
continue;
case SSL_ERROR_WANT_READ:
if (no_exception_p(opts)) { return sym_wait_readable; }
read_would_block(nonblock);
- io_wait_readable(fptr);
+ io_wait_readable(io);
continue;
case SSL_ERROR_SYSCALL:
#ifdef __APPLE__
diff --git a/ext/openssl/ossl_ssl_session.c b/ext/openssl/ossl_ssl_session.c
index 139a474b04..c5df902c60 100644
--- a/ext/openssl/ossl_ssl_session.c
+++ b/ext/openssl/ossl_ssl_session.c
@@ -19,7 +19,7 @@ const rb_data_type_t ossl_ssl_session_type = {
{
0, ossl_ssl_session_free,
},
- 0, 0, RUBY_TYPED_FREE_IMMEDIATELY,
+ 0, 0, RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_WB_PROTECTED,
};
static VALUE ossl_ssl_session_alloc(VALUE klass)
diff --git a/ext/openssl/ossl_ts.c b/ext/openssl/ossl_ts.c
index b33ff10c10..f698bdc7ff 100644
--- a/ext/openssl/ossl_ts.c
+++ b/ext/openssl/ossl_ts.c
@@ -83,7 +83,7 @@ static const rb_data_type_t ossl_ts_req_type = {
{
0, ossl_ts_req_free,
},
- 0, 0, RUBY_TYPED_FREE_IMMEDIATELY,
+ 0, 0, RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_WB_PROTECTED,
};
static void
@@ -97,7 +97,7 @@ static const rb_data_type_t ossl_ts_resp_type = {
{
0, ossl_ts_resp_free,
},
- 0, 0, RUBY_TYPED_FREE_IMMEDIATELY,
+ 0, 0, RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_WB_PROTECTED,
};
static void
@@ -111,7 +111,7 @@ static const rb_data_type_t ossl_ts_token_info_type = {
{
0, ossl_ts_token_info_free,
},
- 0, 0, RUBY_TYPED_FREE_IMMEDIATELY,
+ 0, 0, RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_WB_PROTECTED,
};
static VALUE
diff --git a/ext/openssl/ossl_x509attr.c b/ext/openssl/ossl_x509attr.c
index 60846cfe9d..d1d8bb5e95 100644
--- a/ext/openssl/ossl_x509attr.c
+++ b/ext/openssl/ossl_x509attr.c
@@ -41,7 +41,7 @@ static const rb_data_type_t ossl_x509attr_type = {
{
0, ossl_x509attr_free,
},
- 0, 0, RUBY_TYPED_FREE_IMMEDIATELY,
+ 0, 0, RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_WB_PROTECTED,
};
/*
diff --git a/ext/openssl/ossl_x509cert.c b/ext/openssl/ossl_x509cert.c
index 9443541645..aa6b9bb7ce 100644
--- a/ext/openssl/ossl_x509cert.c
+++ b/ext/openssl/ossl_x509cert.c
@@ -41,7 +41,7 @@ static const rb_data_type_t ossl_x509_type = {
{
0, ossl_x509_free,
},
- 0, 0, RUBY_TYPED_FREE_IMMEDIATELY,
+ 0, 0, RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_WB_PROTECTED,
};
/*
diff --git a/ext/openssl/ossl_x509crl.c b/ext/openssl/ossl_x509crl.c
index 6c1d915370..80e29f9df2 100644
--- a/ext/openssl/ossl_x509crl.c
+++ b/ext/openssl/ossl_x509crl.c
@@ -41,7 +41,7 @@ static const rb_data_type_t ossl_x509crl_type = {
{
0, ossl_x509crl_free,
},
- 0, 0, RUBY_TYPED_FREE_IMMEDIATELY,
+ 0, 0, RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_WB_PROTECTED,
};
/*
diff --git a/ext/openssl/ossl_x509ext.c b/ext/openssl/ossl_x509ext.c
index e54102c771..192d09bd3f 100644
--- a/ext/openssl/ossl_x509ext.c
+++ b/ext/openssl/ossl_x509ext.c
@@ -55,7 +55,7 @@ static const rb_data_type_t ossl_x509ext_type = {
{
0, ossl_x509ext_free,
},
- 0, 0, RUBY_TYPED_FREE_IMMEDIATELY,
+ 0, 0, RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_WB_PROTECTED,
};
/*
@@ -108,7 +108,7 @@ static const rb_data_type_t ossl_x509extfactory_type = {
{
0, ossl_x509extfactory_free,
},
- 0, 0, RUBY_TYPED_FREE_IMMEDIATELY,
+ 0, 0, RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_WB_PROTECTED,
};
static VALUE
@@ -209,15 +209,16 @@ ossl_x509extfactory_create_ext(int argc, VALUE *argv, VALUE self)
int nid;
VALUE rconf;
CONF *conf;
+ const char *oid_cstr = NULL;
rb_scan_args(argc, argv, "21", &oid, &value, &critical);
- StringValueCStr(oid);
StringValue(value);
if(NIL_P(critical)) critical = Qfalse;
- nid = OBJ_ln2nid(RSTRING_PTR(oid));
- if(!nid) nid = OBJ_sn2nid(RSTRING_PTR(oid));
- if(!nid) ossl_raise(eX509ExtError, "unknown OID `%"PRIsVALUE"'", oid);
+ oid_cstr = StringValueCStr(oid);
+ nid = OBJ_ln2nid(oid_cstr);
+ if (nid != NID_undef)
+ oid_cstr = OBJ_nid2sn(nid);
valstr = rb_str_new2(RTEST(critical) ? "critical," : "");
rb_str_append(valstr, value);
@@ -228,7 +229,12 @@ ossl_x509extfactory_create_ext(int argc, VALUE *argv, VALUE self)
rconf = rb_iv_get(self, "@config");
conf = NIL_P(rconf) ? NULL : GetConfig(rconf);
X509V3_set_nconf(ctx, conf);
- ext = X509V3_EXT_nconf_nid(conf, ctx, nid, RSTRING_PTR(valstr));
+
+#if OSSL_OPENSSL_PREREQ(1, 1, 0) || OSSL_IS_LIBRESSL
+ ext = X509V3_EXT_nconf(conf, ctx, oid_cstr, RSTRING_PTR(valstr));
+#else
+ ext = X509V3_EXT_nconf(conf, ctx, (char *)oid_cstr, RSTRING_PTR(valstr));
+#endif
X509V3_set_ctx_nodb(ctx);
if (!ext){
ossl_raise(eX509ExtError, "%"PRIsVALUE" = %"PRIsVALUE, oid, valstr);
diff --git a/ext/openssl/ossl_x509name.c b/ext/openssl/ossl_x509name.c
index 13a2b2c030..9591912f70 100644
--- a/ext/openssl/ossl_x509name.c
+++ b/ext/openssl/ossl_x509name.c
@@ -46,7 +46,7 @@ static const rb_data_type_t ossl_x509name_type = {
{
0, ossl_x509name_free,
},
- 0, 0, RUBY_TYPED_FREE_IMMEDIATELY,
+ 0, 0, RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_WB_PROTECTED,
};
/*
diff --git a/ext/openssl/ossl_x509req.c b/ext/openssl/ossl_x509req.c
index 77a7d3f2ff..f058185151 100644
--- a/ext/openssl/ossl_x509req.c
+++ b/ext/openssl/ossl_x509req.c
@@ -41,7 +41,7 @@ static const rb_data_type_t ossl_x509req_type = {
{
0, ossl_x509req_free,
},
- 0, 0, RUBY_TYPED_FREE_IMMEDIATELY,
+ 0, 0, RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_WB_PROTECTED,
};
/*
diff --git a/ext/openssl/ossl_x509revoked.c b/ext/openssl/ossl_x509revoked.c
index 10b8aa4ad6..108447c868 100644
--- a/ext/openssl/ossl_x509revoked.c
+++ b/ext/openssl/ossl_x509revoked.c
@@ -41,7 +41,7 @@ static const rb_data_type_t ossl_x509rev_type = {
{
0, ossl_x509rev_free,
},
- 0, 0, RUBY_TYPED_FREE_IMMEDIATELY,
+ 0, 0, RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_WB_PROTECTED,
};
/*
diff --git a/ext/openssl/ossl_x509store.c b/ext/openssl/ossl_x509store.c
index 7c546187c3..f27381ca90 100644
--- a/ext/openssl/ossl_x509store.c
+++ b/ext/openssl/ossl_x509store.c
@@ -116,6 +116,9 @@ static void
ossl_x509store_mark(void *ptr)
{
X509_STORE *store = ptr;
+ // Note: this reference is stored as @verify_callback so we don't need to mark it.
+ // However we do need to ensure GC compaction won't move it, hence why
+ // we call rb_gc_mark here.
rb_gc_mark((VALUE)X509_STORE_get_ex_data(store, store_ex_verify_cb_idx));
}
@@ -130,7 +133,7 @@ static const rb_data_type_t ossl_x509store_type = {
{
ossl_x509store_mark, ossl_x509store_free,
},
- 0, 0, RUBY_TYPED_FREE_IMMEDIATELY,
+ 0, 0, RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_WB_PROTECTED,
};
/*
@@ -187,8 +190,9 @@ ossl_x509store_set_vfy_cb(VALUE self, VALUE cb)
X509_STORE *store;
GetX509Store(self, store);
- X509_STORE_set_ex_data(store, store_ex_verify_cb_idx, (void *)cb);
rb_iv_set(self, "@verify_callback", cb);
+ // We don't need to trigger a write barrier because `rb_iv_set` did it.
+ X509_STORE_set_ex_data(store, store_ex_verify_cb_idx, (void *)cb);
return cb;
}
@@ -507,6 +511,9 @@ static void
ossl_x509stctx_mark(void *ptr)
{
X509_STORE_CTX *ctx = ptr;
+ // Note: this reference is stored as @verify_callback so we don't need to mark it.
+ // However we do need to ensure GC compaction won't move it, hence why
+ // we call rb_gc_mark here.
rb_gc_mark((VALUE)X509_STORE_CTX_get_ex_data(ctx, stctx_ex_verify_cb_idx));
}
@@ -526,7 +533,7 @@ static const rb_data_type_t ossl_x509stctx_type = {
{
ossl_x509stctx_mark, ossl_x509stctx_free,
},
- 0, 0, RUBY_TYPED_FREE_IMMEDIATELY,
+ 0, 0, RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_WB_PROTECTED,
};
static VALUE
@@ -614,8 +621,8 @@ ossl_x509stctx_verify(VALUE self)
X509_STORE_CTX *ctx;
GetX509StCtx(self, ctx);
- X509_STORE_CTX_set_ex_data(ctx, stctx_ex_verify_cb_idx,
- (void *)rb_iv_get(self, "@verify_callback"));
+ VALUE cb = rb_iv_get(self, "@verify_callback");
+ X509_STORE_CTX_set_ex_data(ctx, stctx_ex_verify_cb_idx, (void *)cb);
switch (X509_verify_cert(ctx)) {
case 1:
diff --git a/ext/pathname/depend b/ext/pathname/depend
index a6b000e305..5dd8b042de 100644
--- a/ext/pathname/depend
+++ b/ext/pathname/depend
@@ -53,6 +53,7 @@ pathname.o: $(hdrdir)/ruby/internal/attr/noexcept.h
pathname.o: $(hdrdir)/ruby/internal/attr/noinline.h
pathname.o: $(hdrdir)/ruby/internal/attr/nonnull.h
pathname.o: $(hdrdir)/ruby/internal/attr/noreturn.h
+pathname.o: $(hdrdir)/ruby/internal/attr/packed_struct.h
pathname.o: $(hdrdir)/ruby/internal/attr/pure.h
pathname.o: $(hdrdir)/ruby/internal/attr/restrict.h
pathname.o: $(hdrdir)/ruby/internal/attr/returns_nonnull.h
@@ -121,7 +122,6 @@ pathname.o: $(hdrdir)/ruby/internal/intern/enumerator.h
pathname.o: $(hdrdir)/ruby/internal/intern/error.h
pathname.o: $(hdrdir)/ruby/internal/intern/eval.h
pathname.o: $(hdrdir)/ruby/internal/intern/file.h
-pathname.o: $(hdrdir)/ruby/internal/intern/gc.h
pathname.o: $(hdrdir)/ruby/internal/intern/hash.h
pathname.o: $(hdrdir)/ruby/internal/intern/io.h
pathname.o: $(hdrdir)/ruby/internal/intern/load.h
@@ -152,7 +152,6 @@ pathname.o: $(hdrdir)/ruby/internal/memory.h
pathname.o: $(hdrdir)/ruby/internal/method.h
pathname.o: $(hdrdir)/ruby/internal/module.h
pathname.o: $(hdrdir)/ruby/internal/newobj.h
-pathname.o: $(hdrdir)/ruby/internal/rgengc.h
pathname.o: $(hdrdir)/ruby/internal/scan_args.h
pathname.o: $(hdrdir)/ruby/internal/special_consts.h
pathname.o: $(hdrdir)/ruby/internal/static_assert.h
diff --git a/ext/pathname/lib/pathname.rb b/ext/pathname/lib/pathname.rb
index 7bdfd0eb39..8eeba6aad2 100644
--- a/ext/pathname/lib/pathname.rb
+++ b/ext/pathname/lib/pathname.rb
@@ -14,6 +14,8 @@ require 'pathname.so'
class Pathname
+ VERSION = "0.3.0"
+
# :stopdoc:
# to_path is implemented so Pathname objects are usable with File.open, etc.
diff --git a/ext/pathname/pathname.c b/ext/pathname/pathname.c
index 8ee4bcec5b..878f216fb5 100644
--- a/ext/pathname/pathname.c
+++ b/ext/pathname/pathname.c
@@ -131,32 +131,6 @@ path_freeze(VALUE self)
}
/*
- * call-seq:
- * pathname.taint -> obj
- *
- * Returns pathname. This method is deprecated and will be removed in Ruby 3.2.
- */
-static VALUE
-path_taint(VALUE self)
-{
- rb_warn("Pathname#taint is deprecated and will be removed in Ruby 3.2.");
- return self;
-}
-
-/*
- * call-seq:
- * pathname.untaint -> obj
- *
- * Returns pathname. This method is deprecated and will be removed in Ruby 3.2.
- */
-static VALUE
-path_untaint(VALUE self)
-{
- rb_warn("Pathname#untaint is deprecated and will be removed in Ruby 3.2.");
- return self;
-}
-
-/*
* Compare this pathname with +other+. The comparison is string-based.
* Be aware that two different paths (<tt>foo.txt</tt> and <tt>./foo.txt</tt>)
* can refer to the same file.
@@ -1537,8 +1511,6 @@ Init_pathname(void)
rb_cPathname = rb_define_class("Pathname", rb_cObject);
rb_define_method(rb_cPathname, "initialize", path_initialize, 1);
rb_define_method(rb_cPathname, "freeze", path_freeze, 0);
- rb_define_method(rb_cPathname, "taint", path_taint, 0);
- rb_define_method(rb_cPathname, "untaint", path_untaint, 0);
rb_define_method(rb_cPathname, "==", path_eq, 1);
rb_define_method(rb_cPathname, "===", path_eq, 1);
rb_define_method(rb_cPathname, "eql?", path_eq, 1);
diff --git a/ext/pathname/pathname.gemspec b/ext/pathname/pathname.gemspec
index 92bc02b0db..890bc2fde9 100644
--- a/ext/pathname/pathname.gemspec
+++ b/ext/pathname/pathname.gemspec
@@ -1,6 +1,13 @@
+name = File.basename(__FILE__, ".gemspec")
+version = ["lib", "ext/lib"].find do |dir|
+ break File.foreach(File.join(__dir__, dir, "#{name}.rb")) do |line|
+ /^\s*VERSION\s*=\s*"(.*)"/ =~ line and break $1
+ end rescue nil
+end
+
Gem::Specification.new do |spec|
- spec.name = "pathname"
- spec.version = "0.2.1"
+ spec.name = name
+ spec.version = version
spec.authors = ["Tanaka Akira"]
spec.email = ["akr@fsij.org"]
diff --git a/ext/psych/depend b/ext/psych/depend
index 78bde9a53d..13fbe3fb19 100644
--- a/ext/psych/depend
+++ b/ext/psych/depend
@@ -67,6 +67,7 @@ psych.o: $(hdrdir)/ruby/internal/attr/noexcept.h
psych.o: $(hdrdir)/ruby/internal/attr/noinline.h
psych.o: $(hdrdir)/ruby/internal/attr/nonnull.h
psych.o: $(hdrdir)/ruby/internal/attr/noreturn.h
+psych.o: $(hdrdir)/ruby/internal/attr/packed_struct.h
psych.o: $(hdrdir)/ruby/internal/attr/pure.h
psych.o: $(hdrdir)/ruby/internal/attr/restrict.h
psych.o: $(hdrdir)/ruby/internal/attr/returns_nonnull.h
@@ -135,7 +136,6 @@ psych.o: $(hdrdir)/ruby/internal/intern/enumerator.h
psych.o: $(hdrdir)/ruby/internal/intern/error.h
psych.o: $(hdrdir)/ruby/internal/intern/eval.h
psych.o: $(hdrdir)/ruby/internal/intern/file.h
-psych.o: $(hdrdir)/ruby/internal/intern/gc.h
psych.o: $(hdrdir)/ruby/internal/intern/hash.h
psych.o: $(hdrdir)/ruby/internal/intern/io.h
psych.o: $(hdrdir)/ruby/internal/intern/load.h
@@ -166,7 +166,6 @@ psych.o: $(hdrdir)/ruby/internal/memory.h
psych.o: $(hdrdir)/ruby/internal/method.h
psych.o: $(hdrdir)/ruby/internal/module.h
psych.o: $(hdrdir)/ruby/internal/newobj.h
-psych.o: $(hdrdir)/ruby/internal/rgengc.h
psych.o: $(hdrdir)/ruby/internal/scan_args.h
psych.o: $(hdrdir)/ruby/internal/special_consts.h
psych.o: $(hdrdir)/ruby/internal/static_assert.h
@@ -244,6 +243,7 @@ psych_emitter.o: $(hdrdir)/ruby/internal/attr/noexcept.h
psych_emitter.o: $(hdrdir)/ruby/internal/attr/noinline.h
psych_emitter.o: $(hdrdir)/ruby/internal/attr/nonnull.h
psych_emitter.o: $(hdrdir)/ruby/internal/attr/noreturn.h
+psych_emitter.o: $(hdrdir)/ruby/internal/attr/packed_struct.h
psych_emitter.o: $(hdrdir)/ruby/internal/attr/pure.h
psych_emitter.o: $(hdrdir)/ruby/internal/attr/restrict.h
psych_emitter.o: $(hdrdir)/ruby/internal/attr/returns_nonnull.h
@@ -312,7 +312,6 @@ psych_emitter.o: $(hdrdir)/ruby/internal/intern/enumerator.h
psych_emitter.o: $(hdrdir)/ruby/internal/intern/error.h
psych_emitter.o: $(hdrdir)/ruby/internal/intern/eval.h
psych_emitter.o: $(hdrdir)/ruby/internal/intern/file.h
-psych_emitter.o: $(hdrdir)/ruby/internal/intern/gc.h
psych_emitter.o: $(hdrdir)/ruby/internal/intern/hash.h
psych_emitter.o: $(hdrdir)/ruby/internal/intern/io.h
psych_emitter.o: $(hdrdir)/ruby/internal/intern/load.h
@@ -343,7 +342,6 @@ psych_emitter.o: $(hdrdir)/ruby/internal/memory.h
psych_emitter.o: $(hdrdir)/ruby/internal/method.h
psych_emitter.o: $(hdrdir)/ruby/internal/module.h
psych_emitter.o: $(hdrdir)/ruby/internal/newobj.h
-psych_emitter.o: $(hdrdir)/ruby/internal/rgengc.h
psych_emitter.o: $(hdrdir)/ruby/internal/scan_args.h
psych_emitter.o: $(hdrdir)/ruby/internal/special_consts.h
psych_emitter.o: $(hdrdir)/ruby/internal/static_assert.h
@@ -421,6 +419,7 @@ psych_parser.o: $(hdrdir)/ruby/internal/attr/noexcept.h
psych_parser.o: $(hdrdir)/ruby/internal/attr/noinline.h
psych_parser.o: $(hdrdir)/ruby/internal/attr/nonnull.h
psych_parser.o: $(hdrdir)/ruby/internal/attr/noreturn.h
+psych_parser.o: $(hdrdir)/ruby/internal/attr/packed_struct.h
psych_parser.o: $(hdrdir)/ruby/internal/attr/pure.h
psych_parser.o: $(hdrdir)/ruby/internal/attr/restrict.h
psych_parser.o: $(hdrdir)/ruby/internal/attr/returns_nonnull.h
@@ -489,7 +488,6 @@ psych_parser.o: $(hdrdir)/ruby/internal/intern/enumerator.h
psych_parser.o: $(hdrdir)/ruby/internal/intern/error.h
psych_parser.o: $(hdrdir)/ruby/internal/intern/eval.h
psych_parser.o: $(hdrdir)/ruby/internal/intern/file.h
-psych_parser.o: $(hdrdir)/ruby/internal/intern/gc.h
psych_parser.o: $(hdrdir)/ruby/internal/intern/hash.h
psych_parser.o: $(hdrdir)/ruby/internal/intern/io.h
psych_parser.o: $(hdrdir)/ruby/internal/intern/load.h
@@ -520,7 +518,6 @@ psych_parser.o: $(hdrdir)/ruby/internal/memory.h
psych_parser.o: $(hdrdir)/ruby/internal/method.h
psych_parser.o: $(hdrdir)/ruby/internal/module.h
psych_parser.o: $(hdrdir)/ruby/internal/newobj.h
-psych_parser.o: $(hdrdir)/ruby/internal/rgengc.h
psych_parser.o: $(hdrdir)/ruby/internal/scan_args.h
psych_parser.o: $(hdrdir)/ruby/internal/special_consts.h
psych_parser.o: $(hdrdir)/ruby/internal/static_assert.h
@@ -598,6 +595,7 @@ psych_to_ruby.o: $(hdrdir)/ruby/internal/attr/noexcept.h
psych_to_ruby.o: $(hdrdir)/ruby/internal/attr/noinline.h
psych_to_ruby.o: $(hdrdir)/ruby/internal/attr/nonnull.h
psych_to_ruby.o: $(hdrdir)/ruby/internal/attr/noreturn.h
+psych_to_ruby.o: $(hdrdir)/ruby/internal/attr/packed_struct.h
psych_to_ruby.o: $(hdrdir)/ruby/internal/attr/pure.h
psych_to_ruby.o: $(hdrdir)/ruby/internal/attr/restrict.h
psych_to_ruby.o: $(hdrdir)/ruby/internal/attr/returns_nonnull.h
@@ -666,7 +664,6 @@ psych_to_ruby.o: $(hdrdir)/ruby/internal/intern/enumerator.h
psych_to_ruby.o: $(hdrdir)/ruby/internal/intern/error.h
psych_to_ruby.o: $(hdrdir)/ruby/internal/intern/eval.h
psych_to_ruby.o: $(hdrdir)/ruby/internal/intern/file.h
-psych_to_ruby.o: $(hdrdir)/ruby/internal/intern/gc.h
psych_to_ruby.o: $(hdrdir)/ruby/internal/intern/hash.h
psych_to_ruby.o: $(hdrdir)/ruby/internal/intern/io.h
psych_to_ruby.o: $(hdrdir)/ruby/internal/intern/load.h
@@ -697,7 +694,6 @@ psych_to_ruby.o: $(hdrdir)/ruby/internal/memory.h
psych_to_ruby.o: $(hdrdir)/ruby/internal/method.h
psych_to_ruby.o: $(hdrdir)/ruby/internal/module.h
psych_to_ruby.o: $(hdrdir)/ruby/internal/newobj.h
-psych_to_ruby.o: $(hdrdir)/ruby/internal/rgengc.h
psych_to_ruby.o: $(hdrdir)/ruby/internal/scan_args.h
psych_to_ruby.o: $(hdrdir)/ruby/internal/special_consts.h
psych_to_ruby.o: $(hdrdir)/ruby/internal/static_assert.h
@@ -775,6 +771,7 @@ psych_yaml_tree.o: $(hdrdir)/ruby/internal/attr/noexcept.h
psych_yaml_tree.o: $(hdrdir)/ruby/internal/attr/noinline.h
psych_yaml_tree.o: $(hdrdir)/ruby/internal/attr/nonnull.h
psych_yaml_tree.o: $(hdrdir)/ruby/internal/attr/noreturn.h
+psych_yaml_tree.o: $(hdrdir)/ruby/internal/attr/packed_struct.h
psych_yaml_tree.o: $(hdrdir)/ruby/internal/attr/pure.h
psych_yaml_tree.o: $(hdrdir)/ruby/internal/attr/restrict.h
psych_yaml_tree.o: $(hdrdir)/ruby/internal/attr/returns_nonnull.h
@@ -843,7 +840,6 @@ psych_yaml_tree.o: $(hdrdir)/ruby/internal/intern/enumerator.h
psych_yaml_tree.o: $(hdrdir)/ruby/internal/intern/error.h
psych_yaml_tree.o: $(hdrdir)/ruby/internal/intern/eval.h
psych_yaml_tree.o: $(hdrdir)/ruby/internal/intern/file.h
-psych_yaml_tree.o: $(hdrdir)/ruby/internal/intern/gc.h
psych_yaml_tree.o: $(hdrdir)/ruby/internal/intern/hash.h
psych_yaml_tree.o: $(hdrdir)/ruby/internal/intern/io.h
psych_yaml_tree.o: $(hdrdir)/ruby/internal/intern/load.h
@@ -874,7 +870,6 @@ psych_yaml_tree.o: $(hdrdir)/ruby/internal/memory.h
psych_yaml_tree.o: $(hdrdir)/ruby/internal/method.h
psych_yaml_tree.o: $(hdrdir)/ruby/internal/module.h
psych_yaml_tree.o: $(hdrdir)/ruby/internal/newobj.h
-psych_yaml_tree.o: $(hdrdir)/ruby/internal/rgengc.h
psych_yaml_tree.o: $(hdrdir)/ruby/internal/scan_args.h
psych_yaml_tree.o: $(hdrdir)/ruby/internal/special_consts.h
psych_yaml_tree.o: $(hdrdir)/ruby/internal/static_assert.h
diff --git a/ext/psych/lib/psych.rb b/ext/psych/lib/psych.rb
index 4a2ab58514..ae167472f2 100644
--- a/ext/psych/lib/psych.rb
+++ b/ext/psych/lib/psych.rb
@@ -694,26 +694,8 @@ module Psych
dump_tags[klass] = tag
end
- # Workaround for emulating `warn '...', uplevel: 1` in Ruby 2.4 or lower.
- def self.warn_with_uplevel(message, uplevel: 1)
- at = parse_caller(caller[uplevel]).join(':')
- warn "#{at}: #{message}"
- end
-
- def self.parse_caller(at)
- if /^(.+?):(\d+)(?::in `.*')?/ =~ at
- file = $1
- line = $2.to_i
- [file, line]
- end
- end
- private_class_method :warn_with_uplevel, :parse_caller
-
class << self
if defined?(Ractor)
- require 'forwardable'
- extend Forwardable
-
class Config
attr_accessor :load_tags, :dump_tags, :domain_types
def initialize
@@ -727,7 +709,29 @@ module Psych
Ractor.current[:PsychConfig] ||= Config.new
end
- def_delegators :config, :load_tags, :dump_tags, :domain_types, :load_tags=, :dump_tags=, :domain_types=
+ def load_tags
+ config.load_tags
+ end
+
+ def dump_tags
+ config.dump_tags
+ end
+
+ def domain_types
+ config.domain_types
+ end
+
+ def load_tags=(value)
+ config.load_tags = value
+ end
+
+ def dump_tags=(value)
+ config.dump_tags = value
+ end
+
+ def domain_types=(value)
+ config.domain_types = value
+ end
else
attr_accessor :load_tags
attr_accessor :dump_tags
diff --git a/ext/psych/lib/psych/versions.rb b/ext/psych/lib/psych/versions.rb
index 1042a86d46..b9e8d9ef11 100644
--- a/ext/psych/lib/psych/versions.rb
+++ b/ext/psych/lib/psych/versions.rb
@@ -2,9 +2,9 @@
module Psych
# The version of Psych you are using
- VERSION = '5.0.2'
+ VERSION = '5.1.2'
if RUBY_ENGINE == 'jruby'
- DEFAULT_SNAKEYAML_VERSION = '2.6'.freeze
+ DEFAULT_SNAKEYAML_VERSION = '2.7'.freeze
end
end
diff --git a/ext/psych/lib/psych/visitors/to_ruby.rb b/ext/psych/lib/psych/visitors/to_ruby.rb
index 8614251ca9..f0fda9bdbc 100644
--- a/ext/psych/lib/psych/visitors/to_ruby.rb
+++ b/ext/psych/lib/psych/visitors/to_ruby.rb
@@ -101,7 +101,7 @@ module Psych
source = $1
options = 0
lang = nil
- ($2 || '').split('').each do |option|
+ $2&.each_char do |option|
case option
when 'x' then options |= Regexp::EXTENDED
when 'i' then options |= Regexp::IGNORECASE
diff --git a/ext/psych/lib/psych/visitors/yaml_tree.rb b/ext/psych/lib/psych/visitors/yaml_tree.rb
index 51491783c3..1dd4094c1d 100644
--- a/ext/psych/lib/psych/visitors/yaml_tree.rb
+++ b/ext/psych/lib/psych/visitors/yaml_tree.rb
@@ -15,30 +15,29 @@ module Psych
class YAMLTree < Psych::Visitors::Visitor
class Registrar # :nodoc:
def initialize
- @obj_to_id = {}
- @obj_to_node = {}
+ @obj_to_id = {}.compare_by_identity
+ @obj_to_node = {}.compare_by_identity
@targets = []
@counter = 0
end
def register target, node
- return unless target.respond_to? :object_id
@targets << target
- @obj_to_node[target.object_id] = node
+ @obj_to_node[target] = node
end
def key? target
- @obj_to_node.key? target.object_id
+ @obj_to_node.key? target
rescue NoMethodError
false
end
def id_for target
- @obj_to_id[target.object_id] ||= (@counter += 1)
+ @obj_to_id[target] ||= (@counter += 1)
end
def node_for target
- @obj_to_node[target.object_id]
+ @obj_to_node[target]
end
end
diff --git a/ext/psych/psych.gemspec b/ext/psych/psych.gemspec
index a8ee5da028..34f70095d3 100644
--- a/ext/psych/psych.gemspec
+++ b/ext/psych/psych.gemspec
@@ -21,28 +21,41 @@ DESCRIPTION
s.licenses = ["MIT"]
s.require_paths = ["lib"]
- # for ruby core repository. It was generated by `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
+ # for ruby core repository.
+ # It was generated by
+ # `git ls-files -z`.split("\x0").reject { |f|
+ # f.match(%r{^\.git|^(test|spec|features|bin|tool)/|^[A-Z]\w+file$|/extlibs$|\.(gemspec|java)$|jar})
+ # }
s.files = [
- ".gitignore", "Gemfile", "LICENSE", "Mavenfile", "README.md", "Rakefile", "bin/console",
- "bin/setup", "ext/psych/depend", "ext/psych/extconf.rb", "ext/psych/psych.c", "ext/psych/psych.h",
- "ext/psych/psych_emitter.c", "ext/psych/psych_emitter.h", "ext/psych/psych_parser.c", "ext/psych/psych_parser.h",
- "ext/psych/psych_to_ruby.c", "ext/psych/psych_to_ruby.h", "ext/psych/psych_yaml_tree.c", "ext/psych/psych_yaml_tree.h",
- "lib/psych.rb", "lib/psych/class_loader.rb", "lib/psych/coder.rb", "lib/psych/core_ext.rb", "lib/psych/exception.rb",
- "lib/psych/handler.rb", "lib/psych/handlers/document_stream.rb", "lib/psych/handlers/recorder.rb",
- "lib/psych/json/ruby_events.rb", "lib/psych/json/stream.rb", "lib/psych/json/tree_builder.rb",
- "lib/psych/json/yaml_events.rb", "lib/psych/nodes.rb", "lib/psych/nodes/alias.rb", "lib/psych/nodes/document.rb",
- "lib/psych/nodes/mapping.rb", "lib/psych/nodes/node.rb", "lib/psych/nodes/scalar.rb", "lib/psych/nodes/sequence.rb",
- "lib/psych/nodes/stream.rb", "lib/psych/omap.rb", "lib/psych/parser.rb", "lib/psych/scalar_scanner.rb",
- "lib/psych/set.rb", "lib/psych/stream.rb", "lib/psych/streaming.rb", "lib/psych/syntax_error.rb",
- "lib/psych/tree_builder.rb", "lib/psych/versions.rb", "lib/psych/visitors.rb","lib/psych/visitors/depth_first.rb",
- "lib/psych/visitors/emitter.rb", "lib/psych/visitors/json_tree.rb", "lib/psych/visitors/to_ruby.rb",
- "lib/psych/visitors/visitor.rb", "lib/psych/visitors/yaml_tree.rb", "lib/psych/y.rb", "psych.gemspec"
+ "CONTRIBUTING.md", "LICENSE", "README.md", "ext/psych/depend",
+ "ext/psych/extconf.rb", "ext/psych/psych.c", "ext/psych/psych.h",
+ "ext/psych/psych_emitter.c", "ext/psych/psych_emitter.h",
+ "ext/psych/psych_parser.c", "ext/psych/psych_parser.h",
+ "ext/psych/psych_to_ruby.c", "ext/psych/psych_to_ruby.h",
+ "ext/psych/psych_yaml_tree.c", "ext/psych/psych_yaml_tree.h",
+ "lib/psych.rb", "lib/psych/class_loader.rb", "lib/psych/coder.rb",
+ "lib/psych/core_ext.rb", "lib/psych/exception.rb", "lib/psych/handler.rb",
+ "lib/psych/handlers/document_stream.rb", "lib/psych/handlers/recorder.rb",
+ "lib/psych/json/ruby_events.rb", "lib/psych/json/stream.rb",
+ "lib/psych/json/tree_builder.rb", "lib/psych/json/yaml_events.rb",
+ "lib/psych/nodes.rb", "lib/psych/nodes/alias.rb",
+ "lib/psych/nodes/document.rb", "lib/psych/nodes/mapping.rb",
+ "lib/psych/nodes/node.rb", "lib/psych/nodes/scalar.rb",
+ "lib/psych/nodes/sequence.rb", "lib/psych/nodes/stream.rb",
+ "lib/psych/omap.rb", "lib/psych/parser.rb", "lib/psych/scalar_scanner.rb",
+ "lib/psych/set.rb", "lib/psych/stream.rb", "lib/psych/streaming.rb",
+ "lib/psych/syntax_error.rb", "lib/psych/tree_builder.rb",
+ "lib/psych/versions.rb", "lib/psych/visitors.rb",
+ "lib/psych/visitors/depth_first.rb", "lib/psych/visitors/emitter.rb",
+ "lib/psych/visitors/json_tree.rb", "lib/psych/visitors/to_ruby.rb",
+ "lib/psych/visitors/visitor.rb", "lib/psych/visitors/yaml_tree.rb",
+ "lib/psych/y.rb"
]
s.rdoc_options = ["--main", "README.md"]
s.extra_rdoc_files = ["README.md"]
- s.required_ruby_version = Gem::Requirement.new(">= 2.4.0")
+ s.required_ruby_version = Gem::Requirement.new(">= 2.5.0")
s.required_rubygems_version = Gem::Requirement.new(">= 0")
if RUBY_ENGINE == 'jruby'
diff --git a/ext/pty/depend b/ext/pty/depend
index f251caae3f..d4d0d558ef 100644
--- a/ext/pty/depend
+++ b/ext/pty/depend
@@ -53,6 +53,7 @@ pty.o: $(hdrdir)/ruby/internal/attr/noexcept.h
pty.o: $(hdrdir)/ruby/internal/attr/noinline.h
pty.o: $(hdrdir)/ruby/internal/attr/nonnull.h
pty.o: $(hdrdir)/ruby/internal/attr/noreturn.h
+pty.o: $(hdrdir)/ruby/internal/attr/packed_struct.h
pty.o: $(hdrdir)/ruby/internal/attr/pure.h
pty.o: $(hdrdir)/ruby/internal/attr/restrict.h
pty.o: $(hdrdir)/ruby/internal/attr/returns_nonnull.h
@@ -121,7 +122,6 @@ pty.o: $(hdrdir)/ruby/internal/intern/enumerator.h
pty.o: $(hdrdir)/ruby/internal/intern/error.h
pty.o: $(hdrdir)/ruby/internal/intern/eval.h
pty.o: $(hdrdir)/ruby/internal/intern/file.h
-pty.o: $(hdrdir)/ruby/internal/intern/gc.h
pty.o: $(hdrdir)/ruby/internal/intern/hash.h
pty.o: $(hdrdir)/ruby/internal/intern/io.h
pty.o: $(hdrdir)/ruby/internal/intern/load.h
@@ -152,7 +152,6 @@ pty.o: $(hdrdir)/ruby/internal/memory.h
pty.o: $(hdrdir)/ruby/internal/method.h
pty.o: $(hdrdir)/ruby/internal/module.h
pty.o: $(hdrdir)/ruby/internal/newobj.h
-pty.o: $(hdrdir)/ruby/internal/rgengc.h
pty.o: $(hdrdir)/ruby/internal/scan_args.h
pty.o: $(hdrdir)/ruby/internal/special_consts.h
pty.o: $(hdrdir)/ruby/internal/static_assert.h
diff --git a/ext/pty/pty.c b/ext/pty/pty.c
index acec33f9bf..8dca8ba281 100644
--- a/ext/pty/pty.c
+++ b/ext/pty/pty.c
@@ -448,8 +448,10 @@ pty_close_pty(VALUE assoc)
for (i = 0; i < 2; i++) {
io = rb_ary_entry(assoc, i);
- if (RB_TYPE_P(io, T_FILE) && 0 <= RFILE(io)->fptr->fd)
+ if (RB_TYPE_P(io, T_FILE)) {
+ /* it's OK to call rb_io_close again even if it's already closed */
rb_io_close(io);
+ }
}
return Qnil;
}
@@ -499,28 +501,21 @@ pty_open(VALUE klass)
{
int master_fd, slave_fd;
char slavename[DEVICELEN];
- VALUE master_io, slave_file;
- rb_io_t *master_fptr, *slave_fptr;
- VALUE assoc;
getDevice(&master_fd, &slave_fd, slavename, 1);
- master_io = rb_obj_alloc(rb_cIO);
- MakeOpenFile(master_io, master_fptr);
- master_fptr->mode = FMODE_READWRITE | FMODE_SYNC | FMODE_DUPLEX;
- master_fptr->fd = master_fd;
- master_fptr->pathv = rb_obj_freeze(rb_sprintf("masterpty:%s", slavename));
+ VALUE master_path = rb_obj_freeze(rb_sprintf("masterpty:%s", slavename));
+ VALUE master_io = rb_io_open_descriptor(rb_cIO, master_fd, FMODE_READWRITE | FMODE_SYNC | FMODE_DUPLEX, master_path, RUBY_IO_TIMEOUT_DEFAULT, NULL);
+
+ VALUE slave_path = rb_obj_freeze(rb_str_new_cstr(slavename));
+ VALUE slave_file = rb_io_open_descriptor(rb_cFile, slave_fd, FMODE_READWRITE | FMODE_SYNC | FMODE_DUPLEX | FMODE_TTY, slave_path, RUBY_IO_TIMEOUT_DEFAULT, NULL);
- slave_file = rb_obj_alloc(rb_cFile);
- MakeOpenFile(slave_file, slave_fptr);
- slave_fptr->mode = FMODE_READWRITE | FMODE_SYNC | FMODE_DUPLEX | FMODE_TTY;
- slave_fptr->fd = slave_fd;
- slave_fptr->pathv = rb_obj_freeze(rb_str_new_cstr(slavename));
+ VALUE assoc = rb_assoc_new(master_io, slave_file);
- assoc = rb_assoc_new(master_io, slave_file);
if (rb_block_given_p()) {
return rb_ensure(rb_yield, assoc, pty_close_pty, assoc);
}
+
return assoc;
}
@@ -577,30 +572,27 @@ pty_getpty(int argc, VALUE *argv, VALUE self)
{
VALUE res;
struct pty_info info;
- rb_io_t *wfptr,*rfptr;
- VALUE rport = rb_obj_alloc(rb_cFile);
- VALUE wport = rb_obj_alloc(rb_cFile);
char SlaveName[DEVICELEN];
- MakeOpenFile(rport, rfptr);
- MakeOpenFile(wport, wfptr);
-
establishShell(argc, argv, &info, SlaveName);
- rfptr->mode = rb_io_modestr_fmode("r");
- rfptr->fd = info.fd;
- rfptr->pathv = rb_obj_freeze(rb_str_new_cstr(SlaveName));
+ VALUE pty_path = rb_obj_freeze(rb_str_new_cstr(SlaveName));
+ VALUE rport = rb_io_open_descriptor(
+ rb_cFile, info.fd, FMODE_READABLE, pty_path, RUBY_IO_TIMEOUT_DEFAULT, NULL
+ );
- wfptr->mode = rb_io_modestr_fmode("w") | FMODE_SYNC;
- wfptr->fd = rb_cloexec_dup(info.fd);
- if (wfptr->fd == -1)
+ int wpty_fd = rb_cloexec_dup(info.fd);
+ if (wpty_fd == -1) {
rb_sys_fail("dup()");
- rb_update_max_fd(wfptr->fd);
- wfptr->pathv = rfptr->pathv;
+ }
+ VALUE wport = rb_io_open_descriptor(
+ rb_cFile, wpty_fd, FMODE_WRITABLE | FMODE_TRUNC | FMODE_CREATE | FMODE_SYNC,
+ pty_path, RUBY_IO_TIMEOUT_DEFAULT, NULL
+ );
res = rb_ary_new2(3);
- rb_ary_store(res,0,(VALUE)rport);
- rb_ary_store(res,1,(VALUE)wport);
+ rb_ary_store(res, 0, rport);
+ rb_ary_store(res, 1, wport);
rb_ary_store(res,2,PIDT2NUM(info.child_pid));
if (rb_block_given_p()) {
@@ -753,8 +745,13 @@ void
Init_pty(void)
{
cPTY = rb_define_module("PTY");
- /* :nodoc: */
- rb_define_module_function(cPTY,"getpty",pty_getpty,-1);
+#if 1
+ rb_define_module_function(cPTY,"get""pty",pty_getpty,-1);
+#else /* for RDoc */
+ /* show getpty as an alias of spawn */
+ VALUE sPTY = rb_singleton_class(cPTY);
+ rb_define_alias(sPTY, "getpty", "spawn");
+#endif
rb_define_module_function(cPTY,"spawn",pty_getpty,-1);
rb_define_singleton_method(cPTY,"check",pty_check,-1);
rb_define_singleton_method(cPTY,"open",pty_open,0);
diff --git a/ext/racc/cparse/README b/ext/racc/cparse/README
deleted file mode 100644
index 550e8d49fe..0000000000
--- a/ext/racc/cparse/README
+++ /dev/null
@@ -1,11 +0,0 @@
-Racc Runtime README
-===================
-
-This directory contains a runtime library of
-Racc parser generator. If you want to generate
-your own parser, you must get Racc full package.
-Get it from:
-
- - http://i.loveruby.net/en/projects/racc
- - https://github.com/ruby/racc
-
diff --git a/ext/racc/cparse/cparse.c b/ext/racc/cparse/cparse.c
deleted file mode 100644
index f752eb7749..0000000000
--- a/ext/racc/cparse/cparse.c
+++ /dev/null
@@ -1,861 +0,0 @@
-/*
-
- cparse.c -- Racc Runtime Core
-
- Copyright (c) 1999-2006 Minero Aoki
-
- This library is free software.
- You can distribute/modify this program under the same terms of ruby.
-
-*/
-
-#include <ruby.h>
-
-#ifndef FALSE
-#define FALSE 0
-#endif
-#ifndef TRUE
-#define TRUE 1
-#endif
-
-/* -----------------------------------------------------------------------
- Important Constants
------------------------------------------------------------------------ */
-
-#define RACC_VERSION "1.6.2"
-
-#define DEFAULT_TOKEN -1
-#define ERROR_TOKEN 1
-#define FINAL_TOKEN 0
-
-#define vDEFAULT_TOKEN INT2FIX(DEFAULT_TOKEN)
-#define vERROR_TOKEN INT2FIX(ERROR_TOKEN)
-#define vFINAL_TOKEN INT2FIX(FINAL_TOKEN)
-
-/* -----------------------------------------------------------------------
- File Local Variables
------------------------------------------------------------------------ */
-
-static VALUE RaccBug;
-static VALUE CparseParams;
-
-static ID id_yydebug;
-static ID id_nexttoken;
-static ID id_onerror;
-static ID id_noreduce;
-static ID id_errstatus;
-
-static ID id_d_shift;
-static ID id_d_reduce;
-static ID id_d_accept;
-static ID id_d_read_token;
-static ID id_d_next_state;
-static ID id_d_e_pop;
-
-/* -----------------------------------------------------------------------
- Utils
------------------------------------------------------------------------ */
-
-/* For backward compatibility */
-#ifndef ID2SYM
-# define ID2SYM(i) ULONG2NUM(i)
-#endif
-#ifndef SYM2ID
-# define SYM2ID(v) ((ID)NUM2ULONG(v))
-#endif
-#ifndef SYMBOL_P
-# define SYMBOL_P(v) FIXNUM_P(v)
-#endif
-#ifndef LONG2NUM
-# define LONG2NUM(i) INT2NUM(i)
-#endif
-
-#ifndef HAVE_RB_ARY_SUBSEQ
-# define rb_ary_subseq(ary, beg, len) rb_ary_new4(len, RARRAY_PTR(ary) + beg)
-#endif
-
-static ID value_to_id _((VALUE v));
-static inline long num_to_long _((VALUE n));
-
-static ID
-value_to_id(VALUE v)
-{
- if (! SYMBOL_P(v)) {
- rb_raise(rb_eTypeError, "not symbol");
- }
- return SYM2ID(v);
-}
-
-static inline long
-num_to_long(VALUE n)
-{
- return NUM2LONG(n);
-}
-
-#define AREF(s, idx) \
- ((0 <= idx && idx < RARRAY_LEN(s)) ? rb_ary_entry(s, idx) : Qnil)
-
-/* -----------------------------------------------------------------------
- Parser Stack Interfaces
------------------------------------------------------------------------ */
-
-static VALUE get_stack_tail _((VALUE stack, long len));
-static void cut_stack_tail _((VALUE stack, long len));
-
-static VALUE
-get_stack_tail(VALUE stack, long len)
-{
- if (len < 0) return Qnil; /* system error */
- if (len > RARRAY_LEN(stack)) len = RARRAY_LEN(stack);
- return rb_ary_subseq(stack, RARRAY_LEN(stack) - len, len);
-}
-
-static void
-cut_stack_tail(VALUE stack, long len)
-{
- while (len > 0) {
- rb_ary_pop(stack);
- len--;
- }
-}
-
-#define STACK_INIT_LEN 64
-#define NEW_STACK() rb_ary_new2(STACK_INIT_LEN)
-#define PUSH(s, i) rb_ary_store(s, RARRAY_LEN(s), i)
-#define POP(s) rb_ary_pop(s)
-#define LAST_I(s) \
- ((RARRAY_LEN(s) > 0) ? rb_ary_entry(s, RARRAY_LEN(s) - 1) : Qnil)
-#define GET_TAIL(s, len) get_stack_tail(s, len)
-#define CUT_TAIL(s, len) cut_stack_tail(s, len)
-
-/* -----------------------------------------------------------------------
- struct cparse_params
------------------------------------------------------------------------ */
-
-struct cparse_params {
- VALUE value_v; /* VALUE version of this struct */
-
- VALUE parser; /* parser object */
-
- int lex_is_iterator;
- VALUE lexer; /* scanner object */
- ID lexmid; /* name of scanner method (must be an iterator) */
-
- /* State transition tables (immutable)
- Data structure is from Dragon Book 4.9 */
- /* action table */
- VALUE action_table;
- VALUE action_check;
- VALUE action_default;
- VALUE action_pointer;
- /* goto table */
- VALUE goto_table;
- VALUE goto_check;
- VALUE goto_default;
- VALUE goto_pointer;
-
- long nt_base; /* NonTerminal BASE index */
- VALUE reduce_table; /* reduce data table */
- VALUE token_table; /* token conversion table */
-
- /* parser stacks and parameters */
- VALUE state;
- long curstate;
- VALUE vstack;
- VALUE tstack;
- VALUE t;
- long shift_n;
- long reduce_n;
- long ruleno;
-
- long errstatus; /* nonzero in error recovering mode */
- long nerr; /* number of error */
-
- int use_result_var;
-
- VALUE retval; /* return value of parser routine */
- long fin; /* parse result status */
-#define CP_FIN_ACCEPT 1
-#define CP_FIN_EOT 2
-#define CP_FIN_CANTPOP 3
-
- int debug; /* user level debug */
- int sys_debug; /* system level debug */
-
- long i; /* table index */
-};
-
-/* -----------------------------------------------------------------------
- Parser Main Routines
------------------------------------------------------------------------ */
-
-static VALUE racc_cparse _((VALUE parser, VALUE arg, VALUE sysdebug));
-static VALUE racc_yyparse _((VALUE parser, VALUE lexer, VALUE lexmid,
- VALUE arg, VALUE sysdebug));
-
-static void call_lexer _((struct cparse_params *v));
-static VALUE lexer_i _((RB_BLOCK_CALL_FUNC_ARGLIST(block_args, data)));
-
-static VALUE assert_array _((VALUE a));
-static long assert_integer _((VALUE n));
-static VALUE assert_hash _((VALUE h));
-static VALUE initialize_params _((VALUE vparams, VALUE parser, VALUE arg,
- VALUE lexer, VALUE lexmid));
-static void cparse_params_mark _((void *ptr));
-static size_t cparse_params_memsize _((const void *ptr));
-
-static void parse_main _((struct cparse_params *v,
- VALUE tok, VALUE val, int resume));
-static void extract_user_token _((struct cparse_params *v,
- VALUE block_args, VALUE *tok, VALUE *val));
-static void shift _((struct cparse_params* v, long act, VALUE tok, VALUE val));
-static int reduce _((struct cparse_params* v, long act));
-static rb_block_call_func reduce0;
-
-#ifdef DEBUG
-# define D_puts(msg) if (v->sys_debug) puts(msg)
-# define D_printf(fmt,arg) if (v->sys_debug) printf(fmt,arg)
-#else
-# define D_puts(msg)
-# define D_printf(fmt,arg)
-#endif
-
-#undef RUBY_UNTYPED_DATA_WARNING
-#define RUBY_UNTYPED_DATA_WARNING 1
-
-static const rb_data_type_t cparse_params_type = {
- "racc/cparse",
- {
- cparse_params_mark,
- RUBY_TYPED_DEFAULT_FREE,
- cparse_params_memsize,
- },
-#ifdef RUBY_TYPED_FREE_IMMEDIATELY
- 0, 0,
- RUBY_TYPED_FREE_IMMEDIATELY,
-#endif
-};
-
-static VALUE
-racc_cparse(VALUE parser, VALUE arg, VALUE sysdebug)
-{
- VALUE vparams;
- struct cparse_params *v;
-
- vparams = TypedData_Make_Struct(CparseParams, struct cparse_params,
- &cparse_params_type, v);
- D_puts("starting cparse");
- v->sys_debug = RTEST(sysdebug);
- vparams = initialize_params(vparams, parser, arg, Qnil, Qnil);
- v->lex_is_iterator = FALSE;
- parse_main(v, Qnil, Qnil, 0);
-
- RB_GC_GUARD(vparams);
- return v->retval;
-}
-
-static VALUE
-racc_yyparse(VALUE parser, VALUE lexer, VALUE lexmid, VALUE arg, VALUE sysdebug)
-{
- VALUE vparams;
- struct cparse_params *v;
-
- vparams = TypedData_Make_Struct(CparseParams, struct cparse_params,
- &cparse_params_type, v);
- v->sys_debug = RTEST(sysdebug);
- D_puts("start C yyparse");
- vparams = initialize_params(vparams, parser, arg, lexer, lexmid);
- v->lex_is_iterator = TRUE;
- D_puts("params initialized");
- parse_main(v, Qnil, Qnil, 0);
- call_lexer(v);
- if (!v->fin) {
- rb_raise(rb_eArgError, "%s() is finished before EndOfToken",
- rb_id2name(v->lexmid));
- }
-
- RB_GC_GUARD(vparams);
- return v->retval;
-}
-
-#ifdef HAVE_RB_BLOCK_CALL
-static void
-call_lexer(struct cparse_params *v)
-{
- rb_block_call(v->lexer, v->lexmid, 0, NULL, lexer_i, v->value_v);
-}
-#else
-static VALUE
-lexer_iter(VALUE data)
-{
- struct cparse_params *v = rb_check_typeddata(data, &cparse_params_type);
-
- rb_funcall(v->lexer, v->lexmid, 0);
- return Qnil;
-}
-
-static void
-call_lexer(struct cparse_params *v)
-{
- rb_iterate(lexer_iter, v->value_v, lexer_i, v->value_v);
-}
-#endif
-
-static VALUE
-lexer_i(RB_BLOCK_CALL_FUNC_ARGLIST(block_args, data))
-{
- struct cparse_params *v = rb_check_typeddata(data, &cparse_params_type);
- VALUE tok, val;
-
- if (v->fin)
- rb_raise(rb_eArgError, "extra token after EndOfToken");
- extract_user_token(v, block_args, &tok, &val);
- parse_main(v, tok, val, 1);
- if (v->fin && v->fin != CP_FIN_ACCEPT)
- rb_iter_break();
- return Qnil;
-}
-
-static VALUE
-assert_array(VALUE a)
-{
- Check_Type(a, T_ARRAY);
- return a;
-}
-
-static VALUE
-assert_hash(VALUE h)
-{
- Check_Type(h, T_HASH);
- return h;
-}
-
-static long
-assert_integer(VALUE n)
-{
- return NUM2LONG(n);
-}
-
-static VALUE
-initialize_params(VALUE vparams, VALUE parser, VALUE arg, VALUE lexer, VALUE lexmid)
-{
- struct cparse_params *v = rb_check_typeddata(vparams, &cparse_params_type);
-
- v->value_v = vparams;
- v->parser = parser;
- v->lexer = lexer;
- if (! NIL_P(lexmid))
- v->lexmid = value_to_id(lexmid);
-
- v->debug = RTEST(rb_ivar_get(parser, id_yydebug));
-
- Check_Type(arg, T_ARRAY);
- if (!(13 <= RARRAY_LEN(arg) && RARRAY_LEN(arg) <= 14))
- rb_raise(RaccBug, "[Racc Bug] wrong arg.size %ld", RARRAY_LEN(arg));
- v->action_table = assert_array (rb_ary_entry(arg, 0));
- v->action_check = assert_array (rb_ary_entry(arg, 1));
- v->action_default = assert_array (rb_ary_entry(arg, 2));
- v->action_pointer = assert_array (rb_ary_entry(arg, 3));
- v->goto_table = assert_array (rb_ary_entry(arg, 4));
- v->goto_check = assert_array (rb_ary_entry(arg, 5));
- v->goto_default = assert_array (rb_ary_entry(arg, 6));
- v->goto_pointer = assert_array (rb_ary_entry(arg, 7));
- v->nt_base = assert_integer(rb_ary_entry(arg, 8));
- v->reduce_table = assert_array (rb_ary_entry(arg, 9));
- v->token_table = assert_hash (rb_ary_entry(arg, 10));
- v->shift_n = assert_integer(rb_ary_entry(arg, 11));
- v->reduce_n = assert_integer(rb_ary_entry(arg, 12));
- if (RARRAY_LEN(arg) > 13) {
- v->use_result_var = RTEST(rb_ary_entry(arg, 13));
- }
- else {
- v->use_result_var = TRUE;
- }
-
- v->tstack = v->debug ? NEW_STACK() : Qnil;
- v->vstack = NEW_STACK();
- v->state = NEW_STACK();
- v->curstate = 0;
- PUSH(v->state, INT2FIX(0));
- v->t = INT2FIX(FINAL_TOKEN + 1); /* must not init to FINAL_TOKEN */
- v->nerr = 0;
- v->errstatus = 0;
- rb_ivar_set(parser, id_errstatus, LONG2NUM(v->errstatus));
-
- v->retval = Qnil;
- v->fin = 0;
-
- v->lex_is_iterator = FALSE;
-
- rb_iv_set(parser, "@vstack", v->vstack);
- if (v->debug) {
- rb_iv_set(parser, "@tstack", v->tstack);
- }
- else {
- rb_iv_set(parser, "@tstack", Qnil);
- }
-
- return vparams;
-}
-
-static void
-cparse_params_mark(void *ptr)
-{
- struct cparse_params *v = (struct cparse_params*)ptr;
-
- rb_gc_mark(v->value_v);
- rb_gc_mark(v->parser);
- rb_gc_mark(v->lexer);
- rb_gc_mark(v->action_table);
- rb_gc_mark(v->action_check);
- rb_gc_mark(v->action_default);
- rb_gc_mark(v->action_pointer);
- rb_gc_mark(v->goto_table);
- rb_gc_mark(v->goto_check);
- rb_gc_mark(v->goto_default);
- rb_gc_mark(v->goto_pointer);
- rb_gc_mark(v->reduce_table);
- rb_gc_mark(v->token_table);
- rb_gc_mark(v->state);
- rb_gc_mark(v->vstack);
- rb_gc_mark(v->tstack);
- rb_gc_mark(v->t);
- rb_gc_mark(v->retval);
-}
-
-static size_t
-cparse_params_memsize(const void *ptr)
-{
- return sizeof(struct cparse_params);
-}
-
-static void
-extract_user_token(struct cparse_params *v, VALUE block_args,
- VALUE *tok, VALUE *val)
-{
- if (NIL_P(block_args)) {
- /* EOF */
- *tok = Qfalse;
- *val = rb_str_new("$", 1);
- return;
- }
-
- if (!RB_TYPE_P(block_args, T_ARRAY)) {
- rb_raise(rb_eTypeError,
- "%s() %s %"PRIsVALUE" (must be Array[2])",
- v->lex_is_iterator ? rb_id2name(v->lexmid) : "next_token",
- v->lex_is_iterator ? "yielded" : "returned",
- rb_obj_class(block_args));
- }
- if (RARRAY_LEN(block_args) != 2) {
- rb_raise(rb_eArgError,
- "%s() %s wrong size of array (%ld for 2)",
- v->lex_is_iterator ? rb_id2name(v->lexmid) : "next_token",
- v->lex_is_iterator ? "yielded" : "returned",
- RARRAY_LEN(block_args));
- }
- *tok = AREF(block_args, 0);
- *val = AREF(block_args, 1);
-}
-
-#define SHIFT(v,act,tok,val) shift(v,act,tok,val)
-#define REDUCE(v,act) do {\
- switch (reduce(v,act)) { \
- case 0: /* normal */ \
- break; \
- case 1: /* yyerror */ \
- goto user_yyerror; \
- case 2: /* yyaccept */ \
- D_puts("u accept"); \
- goto accept; \
- default: \
- break; \
- } \
-} while (0)
-
-static void
-parse_main(struct cparse_params *v, VALUE tok, VALUE val, int resume)
-{
- long i; /* table index */
- long act; /* action type */
- VALUE act_value; /* action type, VALUE version */
- int read_next = 1; /* true if we need to read next token */
- VALUE tmp;
-
- if (resume)
- goto resume;
-
- while (1) {
- D_puts("");
- D_puts("---- enter new loop ----");
- D_puts("");
-
- D_printf("(act) k1=%ld\n", v->curstate);
- tmp = AREF(v->action_pointer, v->curstate);
- if (NIL_P(tmp)) goto notfound;
- D_puts("(act) pointer[k1] ok");
- i = NUM2LONG(tmp);
-
- D_printf("read_next=%d\n", read_next);
- if (read_next && (v->t != vFINAL_TOKEN)) {
- if (v->lex_is_iterator) {
- D_puts("resuming...");
- if (v->fin) rb_raise(rb_eArgError, "token given after EOF");
- v->i = i; /* save i */
- return;
- resume:
- D_puts("resumed");
- i = v->i; /* load i */
- }
- else {
- D_puts("next_token");
- tmp = rb_funcall(v->parser, id_nexttoken, 0);
- extract_user_token(v, tmp, &tok, &val);
- }
- /* convert token */
- v->t = rb_hash_aref(v->token_table, tok);
- if (NIL_P(v->t)) {
- v->t = vERROR_TOKEN;
- }
- D_printf("(act) t(k2)=%ld\n", NUM2LONG(v->t));
- if (v->debug) {
- rb_funcall(v->parser, id_d_read_token,
- 3, v->t, tok, val);
- }
- }
- read_next = 0;
-
- i += NUM2LONG(v->t);
- D_printf("(act) i=%ld\n", i);
- if (i < 0) goto notfound;
-
- act_value = AREF(v->action_table, i);
- if (NIL_P(act_value)) goto notfound;
- act = NUM2LONG(act_value);
- D_printf("(act) table[i]=%ld\n", act);
-
- tmp = AREF(v->action_check, i);
- if (NIL_P(tmp)) goto notfound;
- if (NUM2LONG(tmp) != v->curstate) goto notfound;
- D_printf("(act) check[i]=%ld\n", NUM2LONG(tmp));
-
- D_puts("(act) found");
- act_fixed:
- D_printf("act=%ld\n", act);
- goto handle_act;
-
- notfound:
- D_puts("(act) not found: use default");
- act_value = AREF(v->action_default, v->curstate);
- act = NUM2LONG(act_value);
- goto act_fixed;
-
-
- handle_act:
- if (act > 0 && act < v->shift_n) {
- D_puts("shift");
- if (v->errstatus > 0) {
- v->errstatus--;
- rb_ivar_set(v->parser, id_errstatus, LONG2NUM(v->errstatus));
- }
- SHIFT(v, act, v->t, val);
- read_next = 1;
- }
- else if (act < 0 && act > -(v->reduce_n)) {
- D_puts("reduce");
- REDUCE(v, act);
- }
- else if (act == -(v->reduce_n)) {
- goto error;
- error_recovered:
- ; /* goto label requires stmt */
- }
- else if (act == v->shift_n) {
- D_puts("accept");
- goto accept;
- }
- else {
- rb_raise(RaccBug, "[Racc Bug] unknown act value %ld", act);
- }
-
- if (v->debug) {
- rb_funcall(v->parser, id_d_next_state,
- 2, LONG2NUM(v->curstate), v->state);
- }
- }
- /* not reach */
-
-
- accept:
- if (v->debug) rb_funcall(v->parser, id_d_accept, 0);
- v->retval = rb_ary_entry(v->vstack, 0);
- v->fin = CP_FIN_ACCEPT;
- return;
-
-
- error:
- D_printf("error detected, status=%ld\n", v->errstatus);
- if (v->errstatus == 0) {
- v->nerr++;
- rb_funcall(v->parser, id_onerror,
- 3, v->t, val, v->vstack);
- }
- user_yyerror:
- if (v->errstatus == 3) {
- if (v->t == vFINAL_TOKEN) {
- v->retval = Qnil;
- v->fin = CP_FIN_EOT;
- return;
- }
- read_next = 1;
- }
- v->errstatus = 3;
- rb_ivar_set(v->parser, id_errstatus, LONG2NUM(v->errstatus));
-
- /* check if we can shift/reduce error token */
- D_printf("(err) k1=%ld\n", v->curstate);
- D_printf("(err) k2=%d (error)\n", ERROR_TOKEN);
- while (1) {
- tmp = AREF(v->action_pointer, v->curstate);
- if (NIL_P(tmp)) goto error_pop;
- D_puts("(err) pointer[k1] ok");
-
- i = NUM2LONG(tmp) + ERROR_TOKEN;
- D_printf("(err) i=%ld\n", i);
- if (i < 0) goto error_pop;
-
- act_value = AREF(v->action_table, i);
- if (NIL_P(act_value)) {
- D_puts("(err) table[i] == nil");
- goto error_pop;
- }
- act = NUM2LONG(act_value);
- D_printf("(err) table[i]=%ld\n", act);
-
- tmp = AREF(v->action_check, i);
- if (NIL_P(tmp)) {
- D_puts("(err) check[i] == nil");
- goto error_pop;
- }
- if (NUM2LONG(tmp) != v->curstate) {
- D_puts("(err) check[i] != k1");
- goto error_pop;
- }
-
- D_puts("(err) found: can handle error token");
- break;
-
- error_pop:
- D_puts("(err) act not found: can't handle error token; pop");
-
- if (RARRAY_LEN(v->state) <= 1) {
- v->retval = Qnil;
- v->fin = CP_FIN_CANTPOP;
- return;
- }
- POP(v->state);
- POP(v->vstack);
- v->curstate = num_to_long(LAST_I(v->state));
- if (v->debug) {
- POP(v->tstack);
- rb_funcall(v->parser, id_d_e_pop,
- 3, v->state, v->tstack, v->vstack);
- }
- }
-
- /* shift/reduce error token */
- if (act > 0 && act < v->shift_n) {
- D_puts("e shift");
- SHIFT(v, act, ERROR_TOKEN, val);
- }
- else if (act < 0 && act > -(v->reduce_n)) {
- D_puts("e reduce");
- REDUCE(v, act);
- }
- else if (act == v->shift_n) {
- D_puts("e accept");
- goto accept;
- }
- else {
- rb_raise(RaccBug, "[Racc Bug] unknown act value %ld", act);
- }
- goto error_recovered;
-}
-
-static void
-shift(struct cparse_params *v, long act, VALUE tok, VALUE val)
-{
- PUSH(v->vstack, val);
- if (v->debug) {
- PUSH(v->tstack, tok);
- rb_funcall(v->parser, id_d_shift,
- 3, tok, v->tstack, v->vstack);
- }
- v->curstate = act;
- PUSH(v->state, LONG2NUM(v->curstate));
-}
-
-static int
-reduce(struct cparse_params *v, long act)
-{
- VALUE code;
- v->ruleno = -act * 3;
- code = rb_catch("racc_jump", reduce0, v->value_v);
- v->errstatus = num_to_long(rb_ivar_get(v->parser, id_errstatus));
- return NUM2INT(code);
-}
-
-static VALUE
-reduce0(RB_BLOCK_CALL_FUNC_ARGLIST(_, data))
-{
- struct cparse_params *v = rb_check_typeddata(data, &cparse_params_type);
- VALUE reduce_to, reduce_len, method_id;
- long len;
- ID mid;
- VALUE tmp, tmp_t = Qundef, tmp_v = Qundef;
- long i, k1, k2;
- VALUE goto_state;
-
- reduce_len = rb_ary_entry(v->reduce_table, v->ruleno);
- reduce_to = rb_ary_entry(v->reduce_table, v->ruleno+1);
- method_id = rb_ary_entry(v->reduce_table, v->ruleno+2);
- len = NUM2LONG(reduce_len);
- mid = value_to_id(method_id);
-
- /* call action */
- if (len == 0) {
- tmp = Qnil;
- if (mid != id_noreduce)
- tmp_v = rb_ary_new();
- if (v->debug)
- tmp_t = rb_ary_new();
- }
- else {
- if (mid != id_noreduce) {
- tmp_v = GET_TAIL(v->vstack, len);
- tmp = rb_ary_entry(tmp_v, 0);
- }
- else {
- tmp = rb_ary_entry(v->vstack, RARRAY_LEN(v->vstack) - len);
- }
- CUT_TAIL(v->vstack, len);
- if (v->debug) {
- tmp_t = GET_TAIL(v->tstack, len);
- CUT_TAIL(v->tstack, len);
- }
- CUT_TAIL(v->state, len);
- }
- if (mid != id_noreduce) {
- if (v->use_result_var) {
- tmp = rb_funcall(v->parser, mid,
- 3, tmp_v, v->vstack, tmp);
- }
- else {
- tmp = rb_funcall(v->parser, mid,
- 2, tmp_v, v->vstack);
- }
- }
-
- /* then push result */
- PUSH(v->vstack, tmp);
- if (v->debug) {
- PUSH(v->tstack, reduce_to);
- rb_funcall(v->parser, id_d_reduce,
- 4, tmp_t, reduce_to, v->tstack, v->vstack);
- }
-
- /* calculate transition state */
- if (RARRAY_LEN(v->state) == 0)
- rb_raise(RaccBug, "state stack unexpectedly empty");
- k2 = num_to_long(LAST_I(v->state));
- k1 = num_to_long(reduce_to) - v->nt_base;
- D_printf("(goto) k1=%ld\n", k1);
- D_printf("(goto) k2=%ld\n", k2);
-
- tmp = AREF(v->goto_pointer, k1);
- if (NIL_P(tmp)) goto notfound;
-
- i = NUM2LONG(tmp) + k2;
- D_printf("(goto) i=%ld\n", i);
- if (i < 0) goto notfound;
-
- goto_state = AREF(v->goto_table, i);
- if (NIL_P(goto_state)) {
- D_puts("(goto) table[i] == nil");
- goto notfound;
- }
- D_printf("(goto) table[i]=%ld (goto_state)\n", NUM2LONG(goto_state));
-
- tmp = AREF(v->goto_check, i);
- if (NIL_P(tmp)) {
- D_puts("(goto) check[i] == nil");
- goto notfound;
- }
- if (tmp != LONG2NUM(k1)) {
- D_puts("(goto) check[i] != table[i]");
- goto notfound;
- }
- D_printf("(goto) check[i]=%ld\n", NUM2LONG(tmp));
-
- D_puts("(goto) found");
- transit:
- PUSH(v->state, goto_state);
- v->curstate = NUM2LONG(goto_state);
- return INT2FIX(0);
-
- notfound:
- D_puts("(goto) not found: use default");
- /* overwrite `goto-state' by default value */
- goto_state = AREF(v->goto_default, k1);
- goto transit;
-}
-
-/* -----------------------------------------------------------------------
- Ruby Interface
------------------------------------------------------------------------ */
-
-void
-Init_cparse(void)
-{
-#ifdef HAVE_RB_EXT_RACTOR_SAFE
- rb_ext_ractor_safe(true);
-#endif
-
- VALUE Racc, Parser;
- ID id_racc = rb_intern_const("Racc");
-
- if (rb_const_defined(rb_cObject, id_racc)) {
- Racc = rb_const_get(rb_cObject, id_racc);
- Parser = rb_const_get_at(Racc, rb_intern_const("Parser"));
- }
- else {
- Racc = rb_define_module("Racc");
- Parser = rb_define_class_under(Racc, "Parser", rb_cObject);
- }
- rb_define_private_method(Parser, "_racc_do_parse_c", racc_cparse, 2);
- rb_define_private_method(Parser, "_racc_yyparse_c", racc_yyparse, 4);
- rb_define_const(Parser, "Racc_Runtime_Core_Version_C",
- rb_str_new2(RACC_VERSION));
- rb_define_const(Parser, "Racc_Runtime_Core_Id_C",
- rb_str_new2("$originalId: cparse.c,v 1.8 2006/07/06 11:39:46 aamine Exp $"));
-
- CparseParams = rb_define_class_under(Racc, "CparseParams", rb_cObject);
- rb_undef_alloc_func(CparseParams);
- rb_undef_method(CparseParams, "initialize");
- rb_undef_method(CparseParams, "initialize_copy");
-
- RaccBug = rb_eRuntimeError;
-
- id_yydebug = rb_intern_const("@yydebug");
- id_nexttoken = rb_intern_const("next_token");
- id_onerror = rb_intern_const("on_error");
- id_noreduce = rb_intern_const("_reduce_none");
- id_errstatus = rb_intern_const("@racc_error_status");
-
- id_d_shift = rb_intern_const("racc_shift");
- id_d_reduce = rb_intern_const("racc_reduce");
- id_d_accept = rb_intern_const("racc_accept");
- id_d_read_token = rb_intern_const("racc_read_token");
- id_d_next_state = rb_intern_const("racc_next_state");
- id_d_e_pop = rb_intern_const("racc_e_pop");
-}
diff --git a/ext/racc/cparse/depend b/ext/racc/cparse/depend
deleted file mode 100644
index 9dc509dc7c..0000000000
--- a/ext/racc/cparse/depend
+++ /dev/null
@@ -1,162 +0,0 @@
-# AUTOGENERATED DEPENDENCIES START
-cparse.o: $(RUBY_EXTCONF_H)
-cparse.o: $(arch_hdrdir)/ruby/config.h
-cparse.o: $(hdrdir)/ruby.h
-cparse.o: $(hdrdir)/ruby/assert.h
-cparse.o: $(hdrdir)/ruby/backward.h
-cparse.o: $(hdrdir)/ruby/backward/2/assume.h
-cparse.o: $(hdrdir)/ruby/backward/2/attributes.h
-cparse.o: $(hdrdir)/ruby/backward/2/bool.h
-cparse.o: $(hdrdir)/ruby/backward/2/inttypes.h
-cparse.o: $(hdrdir)/ruby/backward/2/limits.h
-cparse.o: $(hdrdir)/ruby/backward/2/long_long.h
-cparse.o: $(hdrdir)/ruby/backward/2/stdalign.h
-cparse.o: $(hdrdir)/ruby/backward/2/stdarg.h
-cparse.o: $(hdrdir)/ruby/defines.h
-cparse.o: $(hdrdir)/ruby/intern.h
-cparse.o: $(hdrdir)/ruby/internal/abi.h
-cparse.o: $(hdrdir)/ruby/internal/anyargs.h
-cparse.o: $(hdrdir)/ruby/internal/arithmetic.h
-cparse.o: $(hdrdir)/ruby/internal/arithmetic/char.h
-cparse.o: $(hdrdir)/ruby/internal/arithmetic/double.h
-cparse.o: $(hdrdir)/ruby/internal/arithmetic/fixnum.h
-cparse.o: $(hdrdir)/ruby/internal/arithmetic/gid_t.h
-cparse.o: $(hdrdir)/ruby/internal/arithmetic/int.h
-cparse.o: $(hdrdir)/ruby/internal/arithmetic/intptr_t.h
-cparse.o: $(hdrdir)/ruby/internal/arithmetic/long.h
-cparse.o: $(hdrdir)/ruby/internal/arithmetic/long_long.h
-cparse.o: $(hdrdir)/ruby/internal/arithmetic/mode_t.h
-cparse.o: $(hdrdir)/ruby/internal/arithmetic/off_t.h
-cparse.o: $(hdrdir)/ruby/internal/arithmetic/pid_t.h
-cparse.o: $(hdrdir)/ruby/internal/arithmetic/short.h
-cparse.o: $(hdrdir)/ruby/internal/arithmetic/size_t.h
-cparse.o: $(hdrdir)/ruby/internal/arithmetic/st_data_t.h
-cparse.o: $(hdrdir)/ruby/internal/arithmetic/uid_t.h
-cparse.o: $(hdrdir)/ruby/internal/assume.h
-cparse.o: $(hdrdir)/ruby/internal/attr/alloc_size.h
-cparse.o: $(hdrdir)/ruby/internal/attr/artificial.h
-cparse.o: $(hdrdir)/ruby/internal/attr/cold.h
-cparse.o: $(hdrdir)/ruby/internal/attr/const.h
-cparse.o: $(hdrdir)/ruby/internal/attr/constexpr.h
-cparse.o: $(hdrdir)/ruby/internal/attr/deprecated.h
-cparse.o: $(hdrdir)/ruby/internal/attr/diagnose_if.h
-cparse.o: $(hdrdir)/ruby/internal/attr/enum_extensibility.h
-cparse.o: $(hdrdir)/ruby/internal/attr/error.h
-cparse.o: $(hdrdir)/ruby/internal/attr/flag_enum.h
-cparse.o: $(hdrdir)/ruby/internal/attr/forceinline.h
-cparse.o: $(hdrdir)/ruby/internal/attr/format.h
-cparse.o: $(hdrdir)/ruby/internal/attr/maybe_unused.h
-cparse.o: $(hdrdir)/ruby/internal/attr/noalias.h
-cparse.o: $(hdrdir)/ruby/internal/attr/nodiscard.h
-cparse.o: $(hdrdir)/ruby/internal/attr/noexcept.h
-cparse.o: $(hdrdir)/ruby/internal/attr/noinline.h
-cparse.o: $(hdrdir)/ruby/internal/attr/nonnull.h
-cparse.o: $(hdrdir)/ruby/internal/attr/noreturn.h
-cparse.o: $(hdrdir)/ruby/internal/attr/pure.h
-cparse.o: $(hdrdir)/ruby/internal/attr/restrict.h
-cparse.o: $(hdrdir)/ruby/internal/attr/returns_nonnull.h
-cparse.o: $(hdrdir)/ruby/internal/attr/warning.h
-cparse.o: $(hdrdir)/ruby/internal/attr/weakref.h
-cparse.o: $(hdrdir)/ruby/internal/cast.h
-cparse.o: $(hdrdir)/ruby/internal/compiler_is.h
-cparse.o: $(hdrdir)/ruby/internal/compiler_is/apple.h
-cparse.o: $(hdrdir)/ruby/internal/compiler_is/clang.h
-cparse.o: $(hdrdir)/ruby/internal/compiler_is/gcc.h
-cparse.o: $(hdrdir)/ruby/internal/compiler_is/intel.h
-cparse.o: $(hdrdir)/ruby/internal/compiler_is/msvc.h
-cparse.o: $(hdrdir)/ruby/internal/compiler_is/sunpro.h
-cparse.o: $(hdrdir)/ruby/internal/compiler_since.h
-cparse.o: $(hdrdir)/ruby/internal/config.h
-cparse.o: $(hdrdir)/ruby/internal/constant_p.h
-cparse.o: $(hdrdir)/ruby/internal/core.h
-cparse.o: $(hdrdir)/ruby/internal/core/rarray.h
-cparse.o: $(hdrdir)/ruby/internal/core/rbasic.h
-cparse.o: $(hdrdir)/ruby/internal/core/rbignum.h
-cparse.o: $(hdrdir)/ruby/internal/core/rclass.h
-cparse.o: $(hdrdir)/ruby/internal/core/rdata.h
-cparse.o: $(hdrdir)/ruby/internal/core/rfile.h
-cparse.o: $(hdrdir)/ruby/internal/core/rhash.h
-cparse.o: $(hdrdir)/ruby/internal/core/robject.h
-cparse.o: $(hdrdir)/ruby/internal/core/rregexp.h
-cparse.o: $(hdrdir)/ruby/internal/core/rstring.h
-cparse.o: $(hdrdir)/ruby/internal/core/rstruct.h
-cparse.o: $(hdrdir)/ruby/internal/core/rtypeddata.h
-cparse.o: $(hdrdir)/ruby/internal/ctype.h
-cparse.o: $(hdrdir)/ruby/internal/dllexport.h
-cparse.o: $(hdrdir)/ruby/internal/dosish.h
-cparse.o: $(hdrdir)/ruby/internal/error.h
-cparse.o: $(hdrdir)/ruby/internal/eval.h
-cparse.o: $(hdrdir)/ruby/internal/event.h
-cparse.o: $(hdrdir)/ruby/internal/fl_type.h
-cparse.o: $(hdrdir)/ruby/internal/gc.h
-cparse.o: $(hdrdir)/ruby/internal/glob.h
-cparse.o: $(hdrdir)/ruby/internal/globals.h
-cparse.o: $(hdrdir)/ruby/internal/has/attribute.h
-cparse.o: $(hdrdir)/ruby/internal/has/builtin.h
-cparse.o: $(hdrdir)/ruby/internal/has/c_attribute.h
-cparse.o: $(hdrdir)/ruby/internal/has/cpp_attribute.h
-cparse.o: $(hdrdir)/ruby/internal/has/declspec_attribute.h
-cparse.o: $(hdrdir)/ruby/internal/has/extension.h
-cparse.o: $(hdrdir)/ruby/internal/has/feature.h
-cparse.o: $(hdrdir)/ruby/internal/has/warning.h
-cparse.o: $(hdrdir)/ruby/internal/intern/array.h
-cparse.o: $(hdrdir)/ruby/internal/intern/bignum.h
-cparse.o: $(hdrdir)/ruby/internal/intern/class.h
-cparse.o: $(hdrdir)/ruby/internal/intern/compar.h
-cparse.o: $(hdrdir)/ruby/internal/intern/complex.h
-cparse.o: $(hdrdir)/ruby/internal/intern/cont.h
-cparse.o: $(hdrdir)/ruby/internal/intern/dir.h
-cparse.o: $(hdrdir)/ruby/internal/intern/enum.h
-cparse.o: $(hdrdir)/ruby/internal/intern/enumerator.h
-cparse.o: $(hdrdir)/ruby/internal/intern/error.h
-cparse.o: $(hdrdir)/ruby/internal/intern/eval.h
-cparse.o: $(hdrdir)/ruby/internal/intern/file.h
-cparse.o: $(hdrdir)/ruby/internal/intern/gc.h
-cparse.o: $(hdrdir)/ruby/internal/intern/hash.h
-cparse.o: $(hdrdir)/ruby/internal/intern/io.h
-cparse.o: $(hdrdir)/ruby/internal/intern/load.h
-cparse.o: $(hdrdir)/ruby/internal/intern/marshal.h
-cparse.o: $(hdrdir)/ruby/internal/intern/numeric.h
-cparse.o: $(hdrdir)/ruby/internal/intern/object.h
-cparse.o: $(hdrdir)/ruby/internal/intern/parse.h
-cparse.o: $(hdrdir)/ruby/internal/intern/proc.h
-cparse.o: $(hdrdir)/ruby/internal/intern/process.h
-cparse.o: $(hdrdir)/ruby/internal/intern/random.h
-cparse.o: $(hdrdir)/ruby/internal/intern/range.h
-cparse.o: $(hdrdir)/ruby/internal/intern/rational.h
-cparse.o: $(hdrdir)/ruby/internal/intern/re.h
-cparse.o: $(hdrdir)/ruby/internal/intern/ruby.h
-cparse.o: $(hdrdir)/ruby/internal/intern/select.h
-cparse.o: $(hdrdir)/ruby/internal/intern/select/largesize.h
-cparse.o: $(hdrdir)/ruby/internal/intern/signal.h
-cparse.o: $(hdrdir)/ruby/internal/intern/sprintf.h
-cparse.o: $(hdrdir)/ruby/internal/intern/string.h
-cparse.o: $(hdrdir)/ruby/internal/intern/struct.h
-cparse.o: $(hdrdir)/ruby/internal/intern/thread.h
-cparse.o: $(hdrdir)/ruby/internal/intern/time.h
-cparse.o: $(hdrdir)/ruby/internal/intern/variable.h
-cparse.o: $(hdrdir)/ruby/internal/intern/vm.h
-cparse.o: $(hdrdir)/ruby/internal/interpreter.h
-cparse.o: $(hdrdir)/ruby/internal/iterator.h
-cparse.o: $(hdrdir)/ruby/internal/memory.h
-cparse.o: $(hdrdir)/ruby/internal/method.h
-cparse.o: $(hdrdir)/ruby/internal/module.h
-cparse.o: $(hdrdir)/ruby/internal/newobj.h
-cparse.o: $(hdrdir)/ruby/internal/rgengc.h
-cparse.o: $(hdrdir)/ruby/internal/scan_args.h
-cparse.o: $(hdrdir)/ruby/internal/special_consts.h
-cparse.o: $(hdrdir)/ruby/internal/static_assert.h
-cparse.o: $(hdrdir)/ruby/internal/stdalign.h
-cparse.o: $(hdrdir)/ruby/internal/stdbool.h
-cparse.o: $(hdrdir)/ruby/internal/symbol.h
-cparse.o: $(hdrdir)/ruby/internal/value.h
-cparse.o: $(hdrdir)/ruby/internal/value_type.h
-cparse.o: $(hdrdir)/ruby/internal/variable.h
-cparse.o: $(hdrdir)/ruby/internal/warning_push.h
-cparse.o: $(hdrdir)/ruby/internal/xmalloc.h
-cparse.o: $(hdrdir)/ruby/missing.h
-cparse.o: $(hdrdir)/ruby/ruby.h
-cparse.o: $(hdrdir)/ruby/st.h
-cparse.o: $(hdrdir)/ruby/subst.h
-cparse.o: cparse.c
-# AUTOGENERATED DEPENDENCIES END
diff --git a/ext/racc/cparse/extconf.rb b/ext/racc/cparse/extconf.rb
deleted file mode 100644
index 18c5689ad8..0000000000
--- a/ext/racc/cparse/extconf.rb
+++ /dev/null
@@ -1,9 +0,0 @@
-# frozen_string_literal: false
-#
-
-require 'mkmf'
-
-have_func('rb_block_call')
-have_func('rb_ary_subseq')
-
-create_makefile 'racc/cparse'
diff --git a/ext/rbconfig/sizeof/depend b/ext/rbconfig/sizeof/depend
index 5b65b83772..4e4ebd4ae5 100644
--- a/ext/rbconfig/sizeof/depend
+++ b/ext/rbconfig/sizeof/depend
@@ -66,6 +66,7 @@ limits.o: $(hdrdir)/ruby/internal/attr/noexcept.h
limits.o: $(hdrdir)/ruby/internal/attr/noinline.h
limits.o: $(hdrdir)/ruby/internal/attr/nonnull.h
limits.o: $(hdrdir)/ruby/internal/attr/noreturn.h
+limits.o: $(hdrdir)/ruby/internal/attr/packed_struct.h
limits.o: $(hdrdir)/ruby/internal/attr/pure.h
limits.o: $(hdrdir)/ruby/internal/attr/restrict.h
limits.o: $(hdrdir)/ruby/internal/attr/returns_nonnull.h
@@ -125,7 +126,6 @@ limits.o: $(hdrdir)/ruby/internal/intern/enumerator.h
limits.o: $(hdrdir)/ruby/internal/intern/error.h
limits.o: $(hdrdir)/ruby/internal/intern/eval.h
limits.o: $(hdrdir)/ruby/internal/intern/file.h
-limits.o: $(hdrdir)/ruby/internal/intern/gc.h
limits.o: $(hdrdir)/ruby/internal/intern/hash.h
limits.o: $(hdrdir)/ruby/internal/intern/io.h
limits.o: $(hdrdir)/ruby/internal/intern/load.h
@@ -156,7 +156,6 @@ limits.o: $(hdrdir)/ruby/internal/memory.h
limits.o: $(hdrdir)/ruby/internal/method.h
limits.o: $(hdrdir)/ruby/internal/module.h
limits.o: $(hdrdir)/ruby/internal/newobj.h
-limits.o: $(hdrdir)/ruby/internal/rgengc.h
limits.o: $(hdrdir)/ruby/internal/scan_args.h
limits.o: $(hdrdir)/ruby/internal/special_consts.h
limits.o: $(hdrdir)/ruby/internal/static_assert.h
@@ -225,6 +224,7 @@ sizes.o: $(hdrdir)/ruby/internal/attr/noexcept.h
sizes.o: $(hdrdir)/ruby/internal/attr/noinline.h
sizes.o: $(hdrdir)/ruby/internal/attr/nonnull.h
sizes.o: $(hdrdir)/ruby/internal/attr/noreturn.h
+sizes.o: $(hdrdir)/ruby/internal/attr/packed_struct.h
sizes.o: $(hdrdir)/ruby/internal/attr/pure.h
sizes.o: $(hdrdir)/ruby/internal/attr/restrict.h
sizes.o: $(hdrdir)/ruby/internal/attr/returns_nonnull.h
@@ -284,7 +284,6 @@ sizes.o: $(hdrdir)/ruby/internal/intern/enumerator.h
sizes.o: $(hdrdir)/ruby/internal/intern/error.h
sizes.o: $(hdrdir)/ruby/internal/intern/eval.h
sizes.o: $(hdrdir)/ruby/internal/intern/file.h
-sizes.o: $(hdrdir)/ruby/internal/intern/gc.h
sizes.o: $(hdrdir)/ruby/internal/intern/hash.h
sizes.o: $(hdrdir)/ruby/internal/intern/io.h
sizes.o: $(hdrdir)/ruby/internal/intern/load.h
@@ -315,7 +314,6 @@ sizes.o: $(hdrdir)/ruby/internal/memory.h
sizes.o: $(hdrdir)/ruby/internal/method.h
sizes.o: $(hdrdir)/ruby/internal/module.h
sizes.o: $(hdrdir)/ruby/internal/newobj.h
-sizes.o: $(hdrdir)/ruby/internal/rgengc.h
sizes.o: $(hdrdir)/ruby/internal/scan_args.h
sizes.o: $(hdrdir)/ruby/internal/special_consts.h
sizes.o: $(hdrdir)/ruby/internal/static_assert.h
diff --git a/ext/readline/.gitignore b/ext/readline/.gitignore
deleted file mode 100644
index 3d372989ae..0000000000
--- a/ext/readline/.gitignore
+++ /dev/null
@@ -1 +0,0 @@
-/readline-[1-9]*.*
diff --git a/ext/readline/README b/ext/readline/README
deleted file mode 100644
index 57c51b5f5d..0000000000
--- a/ext/readline/README
+++ /dev/null
@@ -1,10 +0,0 @@
-The Readline module provides interface for GNU Readline.
-This module defines a number of methods to facilitate completion
-and accesses input history from the Ruby interpreter.
-This module supported Edit Line(libedit) too.
-libedit is compatible with GNU Readline.
-
-GNU Readline:: http://www.gnu.org/directory/readline.html
-libedit:: http://www.thrysoee.dk/editline/
-
-See RDoc for Readline module.
diff --git a/ext/readline/README.ja b/ext/readline/README.ja
deleted file mode 100644
index 57a6ee4126..0000000000
--- a/ext/readline/README.ja
+++ /dev/null
@@ -1,386 +0,0 @@
-GNU Readline によるコマンドライン入力インタフェースを提供するモジュール
-です。GNU Readline の互換ライブラリのひとつである Edit Line(libedit) も
-サポートしています。
-
-GNU Readline:: http://www.gnu.org/directory/readline.html
-libedit:: http://www.thrysoee.dk/editline/
-
-Readline.readline を使用してユーザからの入力を取得できます。このとき、
-GNU Readline のように入力の補完やEmacs のようなキー操作などができます。
-
- require "readline"
- while buf = Readline.readline("> ", true)
- p buf
- end
-
-ユーザが入力した内容を履歴(以下、ヒストリ)として記録することができます。
-定数 Readline::HISTORY を使用してヒストリにアクセスできます。
-
- require "readline"
- while buf = Readline.readline("> ", true)
- p Readline::HISTORY.to_a
- print("-> ", buf, "\n")
- end
-
-使用するライブラリにより、いくつかのメソッドで例外 NotImplementedError
-が発生します。
-
-== Readline モジュール
-
-=== モジュール関数
-
-readline([prompt, [add_hist]]) -> String | nil
-
- prompt を出力し、ユーザからのキー入力を待ちます。
- エンターキーの押下などでユーザが文字列を入力し終えると、
- 入力した文字列を返します。
- このとき、add_hist が true であれば、入力した文字列をヒストリに追加します。
-
- 何も入力していない状態で EOF(UNIX では ^D) を入力するなどで、
- ユーザからの入力がない場合は nil を返します。
-
- 次の条件を全て満たす場合、例外 IOError が発生します。
- 1. 標準入力が tty でない。
- 2. 標準入力をクローズしている。(isatty(2) の errno が EBADF である。)
-
- 本メソッドはスレッドに対応しています。
- 入力待ち状態のときはスレッドコンテキストの切替えが発生します。
-
- 入力時には行内編集が可能で、vi モードと Emacs モードが用意されています。
- デフォルトは Emacs モードです。
-
- 本メソッドには注意事項があります。
- 入力待ちの状態で ^C すると ruby インタプリタが終了し、端末状態を復帰しません。
- これを回避するための例を3つ挙げます。
-
- * ^CによるInterrupt例外を補足して、端末状態を復帰します:
-
- require "readline"
-
- stty_save = `stty -g`.chomp
- begin
- while buf = Readline.readline
- p buf
- end
- rescue Interrupt
- system("stty", stty_save)
- exit
- end
- end
- end
-
- * INTシグナルを補足して、端末状態を復帰します:
-
- require "readline"
-
- stty_save = `stty -g`.chomp
- trap("INT") { system "stty", stty_save; exit }
-
- while buf = Readline.readline
- p buf
- end
-
- * 単に ^C を無視する方法もあります:
-
- require "readline"
-
- trap("INT", "SIG_IGN")
-
- while buf = Readline.readline
- p buf
- end
-
- 入力履歴 Readline::HISTORY を使用して、空行や直前の入力と同じ内容は入力
- 履歴に残さないということもできます。
-
- require "readline"
-
- while buf = Readline.readline("> ", true)
- # p Readline::HISTORY.to_a
- Readline::HISTORY.pop if /^\s*$/ =~ buf
-
- begin
- if Readline::HISTORY[Readline::HISTORY.length-2] == buf
- Readline::HISTORY.pop
- end
- rescue IndexError
- end
-
- # p Readline::HISTORY.to_a
- print "-> ", buf, "\n"
- end
-
-=== クラスメソッド
-
-Readline.input = input
-
- Readline.readline メソッドで使用する入力用の File オブジェクト input
- を指定します。
-
-Readline.output = output
-
- Readline.readline メソッドで使用する出力用の File オブジェクト
- output を指定します。
-
-Readline.completion_proc = proc
-
- ユーザからの入力を補完する時の候補を取得する Proc オブジェクト proc を
- 指定します。proc は、次のものを想定しています。
- 1. call メソッドを持ちます。
- call メソッドを持たない場合、例外 ArgumentError が発生します。
- 2. 引数にユーザからの入力文字列(注1)を取ります。
- 3. 候補の文字列の配列を返します。
-
- 注1:「/var/lib /v」の後で補完を行うと、
- デフォルトでは proc の引数に「/v」が渡されます。
- このように、ユーザが入力した文字列を
- Readline.completer_word_break_characters に含まれる文字で区切ったも
- のを単語とすると、カーソルがある単語の最初の文字から現在のカーソル位
- 置までの文字列が proc の引数に渡されます。
-
-Readline.completion_proc -> proc
-
- ユーザからの入力を補完する時の候補を取得する Proc オブジェクト proc
- を取得します。
-
-Readline.completion_case_fold = bool
-
- ユーザの入力を補完する際、大文字と小文字を区別する/しないを指定します。
- bool が真ならば区別しません。bool が偽ならば区別します。
-
-Readline.completion_case_fold -> bool
-
- ユーザの入力を補完する際、大文字と小文字を区別する/しないを取得します。
- bool が真ならば区別しません。bool が偽ならば区別します。
-
- なお、Readline.completion_case_fold= メソッドで指定したオブジェクトを
- そのまま取得するので、次のような動作をします。
-
- require "readline"
-
- Readline.completion_case_fold = "This is a String."
- p Readline.completion_case_fold # => "This is a String."
-
-Readline.line_buffer -> string
-
- 入力中の行全体を返します。complete_proc の中で使用することを想定し
- ています。Readline.line_buffer の長さは GNU Readline の rl_end 変数の
- 値と一致します。
-
-Readline.point -> int
-
- 現在のカーソルの位置を返します。
- Readline モジュールは補完対象の単語の開始位置の情報を提供していません。
- しかしながら、 completion_proc の中で入力した単語 text と
- Readline.point を使用することで開始位置を導くことができます。
-
- 開始位置 = 入力した単語の長さ - Readline.point
-
-Readline.vi_editing_mode -> nil
-
- 編集モードを vi モードにします。
- vi モードの詳細は、GNU Readline のマニュアルを参照してください。
-
- サポートしていない環境では、例外 NotImplementedError が発生します。
-
-Readline.vi_editing_mode? -> bool
-
- 編集モードが vi モードの場合、true を返します。そうでなければ false
- を返します。
-
- サポートしていない環境では、例外 NotImplementedError が発生します。
-
-Readline.emacs_editing_mode -> nil
-
- 編集モードを Emacs モードにします。
- デフォルトは Emacs モードです。
- Emacs モードの詳細は、GNU Readline のマニュアルを参照してください。
-
- サポートしていない環境では、例外 NotImplementedError が発生します。
-
-Readline.emacs_editing_mode? -> bool
-
- 編集モードが Emacs モードの場合、true を返します。そうでなければ false
- を返します。
-
- サポートしていない環境では、例外 NotImplementedError が発生します。
-
-Readline.completion_append_character = char
-
- ユーザの入力の補完が完了した場合に、最後に付加する文字 char を指定し
- ます。半角スペース「" "」などの単語を区切る文字を指定すれば、連続して
- 入力する際に便利です。
-
- 使用例:
-
- require "readline"
-
- Readline.readline("> ", true)
- Readline.completion_append_character = " "
-
- 実行例:
-
- >
- ここで "/var/li" を入力します。
-
- > /var/li
- ここで TAB キーを入力します。
-
- > /var/lib
- "b" が補完され、最後に " " が追加されるので、"/usr" を連続して入力できます。
-
- > /var/lib /usr
-
- なお、1文字しか指定することはできません。
- 例えば、"string"を指定した場合は最初の文字である"s"だけを使用します。
-
- require "readline"
-
- Readline.completion_append_character = "string"
- p Readline.completion_append_character # => "s"
-
- サポートしていない環境では、例外 NotImplementedError が発生します。
-
-Readline.completion_append_character -> char
-
- ユーザの入力の補完が完了した場合に、最後に付加する文字を取得します。
- デフォルトは空白 (" ") です。
-
- サポートしていない環境では、例外 NotImplementedError が発生します。
-
-Readline.basic_word_break_characters = string
-
- ユーザの入力の補完を行う際、単語の区切りを示す複数の文字で構成される
- 文字列 string を指定します。
-
- GNU Readline のデフォルトの値は、Bash の補完処理で使用している文字列
- " \t\n\"\\'`@$><=;|&{(" (スペースを含む) になっています。
-
- サポートしていない環境では、例外 NotImplementedError が発生します。
-
-Readline.basic_word_break_characters -> string
-
- ユーザの入力の補完を行う際、単語の区切りを示す複数の文字で構成される
- 文字列を取得します。
-
- サポートしていない環境では、例外 NotImplementedError が発生します。
-
-Readline.completer_word_break_characters = string
-
- ユーザの入力の補完を行う際、単語の区切りを示す複数の文字で構成される
- 文字列 string を指定します。
- Readline.basic_word_break_characters= との違いは、
- GNU Readline の rl_complete_internal 関数で使用されることです。
-
- GNU Readline のデフォルトの値は、
- Readline.basic_word_break_characters と同じです。
-
- サポートしていない環境では、例外 NotImplementedError が発生します。
-
-Readline.completer_word_break_characters -> string
-
- ユーザの入力の補完を行う際、単語の区切りを示す複数の文字で構成された
- 文字列を取得します。
-
- サポートしていない環境では、例外 NotImplementedError が発生します。
-
-Readline.basic_quote_characters = string
-
- スペースなどの単語の区切りをクオートするための複数の文字で構成される
- 文字列 string を指定します。
-
- サポートしていない環境では、例外 NotImplementedError が発生します。
-
-Readline.basic_quote_characters -> string
-
- スペースなどの単語の区切りをクオートするための複数の文字で構成される
- 文字列を取得します。
-
- サポートしていない環境では、例外 NotImplementedError が発生します。
-
-Readline.completer_quote_characters = string
-
- ユーザの入力の補完を行う際、スペースなどの単語の区切りを
- クオートするための複数の文字で構成される文字列 string を指定します。
- 指定した文字の間では、Readline.completer_word_break_characters=
- で指定した文字列に含まれる文字も、普通の文字列として扱われます。
-
- サポートしていない環境では、例外 NotImplementedError が発生します。
-
-Readline.completer_quote_characters -> string
-
- ユーザの入力の補完を行う際、スペースなどの単語の区切りを
- クオートするための複数の文字で構成される文字列を取得します。
-
- サポートしていない環境では、例外 NotImplementedError が発生します。
-
-Readline.filename_quote_characters = string
-
- ユーザの入力時にファイル名の補完を行う際、スペースなどの単語の区切りを
- クオートするための複数の文字で構成される文字列 string を指定します。
-
- GNU Readline のデフォルト値は nil です。
-
- サポートしていない環境では、例外 NotImplementedError が発生します。
-
-Readline.filename_quote_characters -> string
-
- ユーザの入力時にファイル名の補完を行う際、スペースなどの単語の区切りを
- クオートするための複数の文字で構成される文字列を取得します。
-
- サポートしていない環境では、例外 NotImplementedError が発生します。
-
-=== クラス定数
-
-HISTORY
-
- 定数 HISTORY を使用してヒストリにアクセスできます。
- Enumerable モジュールを extend しており、
- 配列のように振る舞うことができます。
- 例えば、HISTORY[4] により 5 番目に入力した内容を取り出すことができます。
-
- require "readline"
-
- Readline::HISTORY.push("a", "b", "c", "d", "e")
- p Readline::HISTORY[4] # => "e"
-
- 実装しているメソッドを次に挙げます。
- * HISTORY.to_s -> "HISTORY"
- * HISTORY[index] -> string
- * HISTORY[index] = string
- * HISTORY.push(string[, string, ...]) -> self
- * HISTORY << string -> self
- * HISTORY.pop -> string
- * HISTORY.shift -> string
- * HISTORY.each -> Enumerator
- * HISTORY.each { |i| } -> [string]
- * HISTORY.length -> Integer
- * HISTORY.empty? -> true or false
- * HISTORY.delete_at(index) -> string
- * HISTORY.clear -> self
-
- サポートしていない環境では、次のメソッドで例外 NotImplementedError が
- 発生します。
- * HISTORY[index] = string
- * HISTORY.pop -> string
- * HISTORY.shift -> string
- * HISTORY.delete_at(index) -> string
- * HISTORY.clear -> self
-
-FILENAME_COMPLETION_PROC
-
- ファイル名の補完を行う call メソッドを持つオブジェクトです。
-
- Readline.completion_proc= により、ユーザの入力時にファイル名の補完を
- 行うように設定するために使用することを想定してます。
-
-USERNAME_COMPLETION_PROC
-
- ユーザ名の補完を行う call メソッドを持つオブジェクトです。
-
- Readline.completion_proc= により、ユーザの入力時にユーザ名の補完を行
- うように設定するために使用することを想定してます。
-
-VERSION
-
- 使用している GNU Readline または libedit のバージョンです。
diff --git a/ext/readline/depend b/ext/readline/depend
deleted file mode 100644
index c62309622a..0000000000
--- a/ext/readline/depend
+++ /dev/null
@@ -1,175 +0,0 @@
-# AUTOGENERATED DEPENDENCIES START
-readline.o: $(RUBY_EXTCONF_H)
-readline.o: $(arch_hdrdir)/ruby/config.h
-readline.o: $(hdrdir)/ruby/assert.h
-readline.o: $(hdrdir)/ruby/backward.h
-readline.o: $(hdrdir)/ruby/backward/2/assume.h
-readline.o: $(hdrdir)/ruby/backward/2/attributes.h
-readline.o: $(hdrdir)/ruby/backward/2/bool.h
-readline.o: $(hdrdir)/ruby/backward/2/inttypes.h
-readline.o: $(hdrdir)/ruby/backward/2/limits.h
-readline.o: $(hdrdir)/ruby/backward/2/long_long.h
-readline.o: $(hdrdir)/ruby/backward/2/stdalign.h
-readline.o: $(hdrdir)/ruby/backward/2/stdarg.h
-readline.o: $(hdrdir)/ruby/defines.h
-readline.o: $(hdrdir)/ruby/encoding.h
-readline.o: $(hdrdir)/ruby/intern.h
-readline.o: $(hdrdir)/ruby/internal/abi.h
-readline.o: $(hdrdir)/ruby/internal/anyargs.h
-readline.o: $(hdrdir)/ruby/internal/arithmetic.h
-readline.o: $(hdrdir)/ruby/internal/arithmetic/char.h
-readline.o: $(hdrdir)/ruby/internal/arithmetic/double.h
-readline.o: $(hdrdir)/ruby/internal/arithmetic/fixnum.h
-readline.o: $(hdrdir)/ruby/internal/arithmetic/gid_t.h
-readline.o: $(hdrdir)/ruby/internal/arithmetic/int.h
-readline.o: $(hdrdir)/ruby/internal/arithmetic/intptr_t.h
-readline.o: $(hdrdir)/ruby/internal/arithmetic/long.h
-readline.o: $(hdrdir)/ruby/internal/arithmetic/long_long.h
-readline.o: $(hdrdir)/ruby/internal/arithmetic/mode_t.h
-readline.o: $(hdrdir)/ruby/internal/arithmetic/off_t.h
-readline.o: $(hdrdir)/ruby/internal/arithmetic/pid_t.h
-readline.o: $(hdrdir)/ruby/internal/arithmetic/short.h
-readline.o: $(hdrdir)/ruby/internal/arithmetic/size_t.h
-readline.o: $(hdrdir)/ruby/internal/arithmetic/st_data_t.h
-readline.o: $(hdrdir)/ruby/internal/arithmetic/uid_t.h
-readline.o: $(hdrdir)/ruby/internal/assume.h
-readline.o: $(hdrdir)/ruby/internal/attr/alloc_size.h
-readline.o: $(hdrdir)/ruby/internal/attr/artificial.h
-readline.o: $(hdrdir)/ruby/internal/attr/cold.h
-readline.o: $(hdrdir)/ruby/internal/attr/const.h
-readline.o: $(hdrdir)/ruby/internal/attr/constexpr.h
-readline.o: $(hdrdir)/ruby/internal/attr/deprecated.h
-readline.o: $(hdrdir)/ruby/internal/attr/diagnose_if.h
-readline.o: $(hdrdir)/ruby/internal/attr/enum_extensibility.h
-readline.o: $(hdrdir)/ruby/internal/attr/error.h
-readline.o: $(hdrdir)/ruby/internal/attr/flag_enum.h
-readline.o: $(hdrdir)/ruby/internal/attr/forceinline.h
-readline.o: $(hdrdir)/ruby/internal/attr/format.h
-readline.o: $(hdrdir)/ruby/internal/attr/maybe_unused.h
-readline.o: $(hdrdir)/ruby/internal/attr/noalias.h
-readline.o: $(hdrdir)/ruby/internal/attr/nodiscard.h
-readline.o: $(hdrdir)/ruby/internal/attr/noexcept.h
-readline.o: $(hdrdir)/ruby/internal/attr/noinline.h
-readline.o: $(hdrdir)/ruby/internal/attr/nonnull.h
-readline.o: $(hdrdir)/ruby/internal/attr/noreturn.h
-readline.o: $(hdrdir)/ruby/internal/attr/pure.h
-readline.o: $(hdrdir)/ruby/internal/attr/restrict.h
-readline.o: $(hdrdir)/ruby/internal/attr/returns_nonnull.h
-readline.o: $(hdrdir)/ruby/internal/attr/warning.h
-readline.o: $(hdrdir)/ruby/internal/attr/weakref.h
-readline.o: $(hdrdir)/ruby/internal/cast.h
-readline.o: $(hdrdir)/ruby/internal/compiler_is.h
-readline.o: $(hdrdir)/ruby/internal/compiler_is/apple.h
-readline.o: $(hdrdir)/ruby/internal/compiler_is/clang.h
-readline.o: $(hdrdir)/ruby/internal/compiler_is/gcc.h
-readline.o: $(hdrdir)/ruby/internal/compiler_is/intel.h
-readline.o: $(hdrdir)/ruby/internal/compiler_is/msvc.h
-readline.o: $(hdrdir)/ruby/internal/compiler_is/sunpro.h
-readline.o: $(hdrdir)/ruby/internal/compiler_since.h
-readline.o: $(hdrdir)/ruby/internal/config.h
-readline.o: $(hdrdir)/ruby/internal/constant_p.h
-readline.o: $(hdrdir)/ruby/internal/core.h
-readline.o: $(hdrdir)/ruby/internal/core/rarray.h
-readline.o: $(hdrdir)/ruby/internal/core/rbasic.h
-readline.o: $(hdrdir)/ruby/internal/core/rbignum.h
-readline.o: $(hdrdir)/ruby/internal/core/rclass.h
-readline.o: $(hdrdir)/ruby/internal/core/rdata.h
-readline.o: $(hdrdir)/ruby/internal/core/rfile.h
-readline.o: $(hdrdir)/ruby/internal/core/rhash.h
-readline.o: $(hdrdir)/ruby/internal/core/robject.h
-readline.o: $(hdrdir)/ruby/internal/core/rregexp.h
-readline.o: $(hdrdir)/ruby/internal/core/rstring.h
-readline.o: $(hdrdir)/ruby/internal/core/rstruct.h
-readline.o: $(hdrdir)/ruby/internal/core/rtypeddata.h
-readline.o: $(hdrdir)/ruby/internal/ctype.h
-readline.o: $(hdrdir)/ruby/internal/dllexport.h
-readline.o: $(hdrdir)/ruby/internal/dosish.h
-readline.o: $(hdrdir)/ruby/internal/encoding/coderange.h
-readline.o: $(hdrdir)/ruby/internal/encoding/ctype.h
-readline.o: $(hdrdir)/ruby/internal/encoding/encoding.h
-readline.o: $(hdrdir)/ruby/internal/encoding/pathname.h
-readline.o: $(hdrdir)/ruby/internal/encoding/re.h
-readline.o: $(hdrdir)/ruby/internal/encoding/sprintf.h
-readline.o: $(hdrdir)/ruby/internal/encoding/string.h
-readline.o: $(hdrdir)/ruby/internal/encoding/symbol.h
-readline.o: $(hdrdir)/ruby/internal/encoding/transcode.h
-readline.o: $(hdrdir)/ruby/internal/error.h
-readline.o: $(hdrdir)/ruby/internal/eval.h
-readline.o: $(hdrdir)/ruby/internal/event.h
-readline.o: $(hdrdir)/ruby/internal/fl_type.h
-readline.o: $(hdrdir)/ruby/internal/gc.h
-readline.o: $(hdrdir)/ruby/internal/glob.h
-readline.o: $(hdrdir)/ruby/internal/globals.h
-readline.o: $(hdrdir)/ruby/internal/has/attribute.h
-readline.o: $(hdrdir)/ruby/internal/has/builtin.h
-readline.o: $(hdrdir)/ruby/internal/has/c_attribute.h
-readline.o: $(hdrdir)/ruby/internal/has/cpp_attribute.h
-readline.o: $(hdrdir)/ruby/internal/has/declspec_attribute.h
-readline.o: $(hdrdir)/ruby/internal/has/extension.h
-readline.o: $(hdrdir)/ruby/internal/has/feature.h
-readline.o: $(hdrdir)/ruby/internal/has/warning.h
-readline.o: $(hdrdir)/ruby/internal/intern/array.h
-readline.o: $(hdrdir)/ruby/internal/intern/bignum.h
-readline.o: $(hdrdir)/ruby/internal/intern/class.h
-readline.o: $(hdrdir)/ruby/internal/intern/compar.h
-readline.o: $(hdrdir)/ruby/internal/intern/complex.h
-readline.o: $(hdrdir)/ruby/internal/intern/cont.h
-readline.o: $(hdrdir)/ruby/internal/intern/dir.h
-readline.o: $(hdrdir)/ruby/internal/intern/enum.h
-readline.o: $(hdrdir)/ruby/internal/intern/enumerator.h
-readline.o: $(hdrdir)/ruby/internal/intern/error.h
-readline.o: $(hdrdir)/ruby/internal/intern/eval.h
-readline.o: $(hdrdir)/ruby/internal/intern/file.h
-readline.o: $(hdrdir)/ruby/internal/intern/gc.h
-readline.o: $(hdrdir)/ruby/internal/intern/hash.h
-readline.o: $(hdrdir)/ruby/internal/intern/io.h
-readline.o: $(hdrdir)/ruby/internal/intern/load.h
-readline.o: $(hdrdir)/ruby/internal/intern/marshal.h
-readline.o: $(hdrdir)/ruby/internal/intern/numeric.h
-readline.o: $(hdrdir)/ruby/internal/intern/object.h
-readline.o: $(hdrdir)/ruby/internal/intern/parse.h
-readline.o: $(hdrdir)/ruby/internal/intern/proc.h
-readline.o: $(hdrdir)/ruby/internal/intern/process.h
-readline.o: $(hdrdir)/ruby/internal/intern/random.h
-readline.o: $(hdrdir)/ruby/internal/intern/range.h
-readline.o: $(hdrdir)/ruby/internal/intern/rational.h
-readline.o: $(hdrdir)/ruby/internal/intern/re.h
-readline.o: $(hdrdir)/ruby/internal/intern/ruby.h
-readline.o: $(hdrdir)/ruby/internal/intern/select.h
-readline.o: $(hdrdir)/ruby/internal/intern/select/largesize.h
-readline.o: $(hdrdir)/ruby/internal/intern/signal.h
-readline.o: $(hdrdir)/ruby/internal/intern/sprintf.h
-readline.o: $(hdrdir)/ruby/internal/intern/string.h
-readline.o: $(hdrdir)/ruby/internal/intern/struct.h
-readline.o: $(hdrdir)/ruby/internal/intern/thread.h
-readline.o: $(hdrdir)/ruby/internal/intern/time.h
-readline.o: $(hdrdir)/ruby/internal/intern/variable.h
-readline.o: $(hdrdir)/ruby/internal/intern/vm.h
-readline.o: $(hdrdir)/ruby/internal/interpreter.h
-readline.o: $(hdrdir)/ruby/internal/iterator.h
-readline.o: $(hdrdir)/ruby/internal/memory.h
-readline.o: $(hdrdir)/ruby/internal/method.h
-readline.o: $(hdrdir)/ruby/internal/module.h
-readline.o: $(hdrdir)/ruby/internal/newobj.h
-readline.o: $(hdrdir)/ruby/internal/rgengc.h
-readline.o: $(hdrdir)/ruby/internal/scan_args.h
-readline.o: $(hdrdir)/ruby/internal/special_consts.h
-readline.o: $(hdrdir)/ruby/internal/static_assert.h
-readline.o: $(hdrdir)/ruby/internal/stdalign.h
-readline.o: $(hdrdir)/ruby/internal/stdbool.h
-readline.o: $(hdrdir)/ruby/internal/symbol.h
-readline.o: $(hdrdir)/ruby/internal/value.h
-readline.o: $(hdrdir)/ruby/internal/value_type.h
-readline.o: $(hdrdir)/ruby/internal/variable.h
-readline.o: $(hdrdir)/ruby/internal/warning_push.h
-readline.o: $(hdrdir)/ruby/internal/xmalloc.h
-readline.o: $(hdrdir)/ruby/io.h
-readline.o: $(hdrdir)/ruby/missing.h
-readline.o: $(hdrdir)/ruby/onigmo.h
-readline.o: $(hdrdir)/ruby/oniguruma.h
-readline.o: $(hdrdir)/ruby/ruby.h
-readline.o: $(hdrdir)/ruby/st.h
-readline.o: $(hdrdir)/ruby/subst.h
-readline.o: $(hdrdir)/ruby/thread.h
-readline.o: readline.c
-# AUTOGENERATED DEPENDENCIES END
diff --git a/ext/readline/depend-gem b/ext/readline/depend-gem
deleted file mode 100644
index df01bd2a86..0000000000
--- a/ext/readline/depend-gem
+++ /dev/null
@@ -1,4 +0,0 @@
-# AUTOGENERATED DEPENDENCIES START
-readline.o: $(RUBY_EXTCONF_H)
-readline.o: readline.c
-# AUTOGENERATED DEPENDENCIES END
diff --git a/ext/readline/extconf.rb b/ext/readline/extconf.rb
deleted file mode 100644
index d3e7872e65..0000000000
--- a/ext/readline/extconf.rb
+++ /dev/null
@@ -1,112 +0,0 @@
-# frozen_string_literal: false
-require "mkmf"
-
-readline = Struct.new(:headers, :extra_check).new(["stdio.h"])
-
-def readline.have_header(header)
- if super(header, &extra_check)
- headers.push(header)
- return true
- else
- return false
- end
-end
-
-def readline.have_var(var)
- return super(var, headers)
-end
-
-def readline.have_func(func)
- return super(func, headers)
-end
-
-def readline.have_type(type)
- return super(type, headers)
-end
-
-dir_config('curses')
-dir_config('ncurses')
-dir_config('termcap')
-dir_config("readline")
-enable_libedit = enable_config("libedit")
-
-have_library("user32", nil) if /cygwin/ === RUBY_PLATFORM
-have_library("ncurses", "tgetnum") ||
- have_library("termcap", "tgetnum") ||
- have_library("curses", "tgetnum")
-
-case enable_libedit
-when true
- # --enable-libedit
- dir_config("libedit")
- unless (readline.have_header("editline/readline.h") ||
- readline.have_header("readline/readline.h")) &&
- have_library("edit", "readline")
- raise "libedit not found"
- end
-when false
- # --disable-libedit
- unless ((readline.have_header("readline/readline.h") &&
- readline.have_header("readline/history.h")) &&
- have_library("readline", "readline"))
- raise "readline not found"
- end
-else
- # does not specify
- unless ((readline.have_header("readline/readline.h") &&
- readline.have_header("readline/history.h")) &&
- (have_library("readline", "readline") ||
- have_library("edit", "readline"))) ||
- (readline.have_header("editline/readline.h") &&
- have_library("edit", "readline"))
- raise "Neither readline nor libedit was found"
- end
-end
-
-readline.have_func("rl_getc")
-readline.have_func("rl_getc_function")
-readline.have_func("rl_filename_completion_function")
-readline.have_func("rl_username_completion_function")
-readline.have_func("rl_completion_matches")
-readline.have_func("rl_refresh_line")
-readline.have_var("rl_deprep_term_function")
-readline.have_var("rl_completion_append_character")
-readline.have_var("rl_completion_quote_character")
-readline.have_var("rl_basic_word_break_characters")
-readline.have_var("rl_completer_word_break_characters")
-readline.have_var("rl_basic_quote_characters")
-readline.have_var("rl_completer_quote_characters")
-readline.have_var("rl_filename_quote_characters")
-readline.have_var("rl_attempted_completion_over")
-readline.have_var("rl_library_version")
-readline.have_var("rl_editing_mode")
-readline.have_var("rl_line_buffer")
-readline.have_var("rl_point")
-readline.have_var("rl_char_is_quoted_p")
-# workaround for native windows.
-/mswin|bccwin/ !~ RUBY_PLATFORM && readline.have_var("rl_event_hook")
-/mswin|bccwin/ !~ RUBY_PLATFORM && readline.have_var("rl_catch_sigwinch")
-/mswin|bccwin/ !~ RUBY_PLATFORM && readline.have_var("rl_catch_signals")
-readline.have_var("rl_pre_input_hook")
-readline.have_var("rl_special_prefixes")
-readline.have_func("rl_cleanup_after_signal")
-readline.have_func("rl_free_line_state")
-readline.have_func("rl_clear_signals")
-readline.have_func("rl_set_screen_size")
-readline.have_func("rl_get_screen_size")
-readline.have_func("rl_vi_editing_mode")
-readline.have_func("rl_emacs_editing_mode")
-readline.have_func("replace_history_entry")
-readline.have_func("remove_history")
-readline.have_func("clear_history")
-readline.have_func("rl_redisplay")
-readline.have_func("rl_insert_text")
-readline.have_func("rl_delete_text")
-unless readline.have_type("rl_hook_func_t*")
- # rl_hook_func_t is available since readline-4.2 (2001).
- # Function is removed at readline-6.3 (2014).
- # However, editline (NetBSD 6.1.3, 2014) doesn't have rl_hook_func_t.
- $defs << "-Drl_hook_func_t=Function"
-end
-
-create_makefile("readline")
diff --git a/ext/readline/readline-ext.gemspec b/ext/readline/readline-ext.gemspec
deleted file mode 100644
index 1e16edbfe6..0000000000
--- a/ext/readline/readline-ext.gemspec
+++ /dev/null
@@ -1,22 +0,0 @@
-Gem::Specification.new do |spec|
- spec.name = "readline-ext"
- spec.version = "0.1.5"
- spec.authors = ["Yukihiro Matsumoto"]
- spec.email = ["matz@ruby-lang.org"]
-
- spec.summary = %q{Provides an interface for GNU Readline and Edit Line (libedit).}
- spec.description = %q{Provides an interface for GNU Readline and Edit Line (libedit).}
- spec.homepage = "https://github.com/ruby/readline-ext"
- spec.licenses = ["Ruby", "BSD-2-Clause"]
- spec.extensions = %w[ext/readline/extconf.rb]
-
- spec.metadata["homepage_uri"] = spec.homepage
- spec.metadata["source_code_uri"] = spec.homepage
-
- spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
- `git ls-files -z 2>/dev/null`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
- end
- spec.bindir = "exe"
- spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
- spec.require_paths = ["lib"]
-end
diff --git a/ext/readline/readline.c b/ext/readline/readline.c
deleted file mode 100644
index fc254ce315..0000000000
--- a/ext/readline/readline.c
+++ /dev/null
@@ -1,2144 +0,0 @@
-/************************************************
-
- readline.c - GNU Readline module
-
- $Author$
- created at: Wed Jan 20 13:59:32 JST 1999
-
- Copyright (C) 1997-2008 Shugo Maeda
- Copyright (C) 2008-2013 Kouji Takao
-
- $Id$
-
- Contact:
- - Kouji Takao <kouji dot takao at gmail dot com> (current maintainer)
-
-************************************************/
-
-#ifdef RUBY_EXTCONF_H
-#include RUBY_EXTCONF_H
-#endif
-
-#include "ruby/config.h"
-#include <errno.h>
-#include <stdio.h>
-#include <string.h>
-#ifdef HAVE_READLINE_READLINE_H
-#include <readline/readline.h>
-#endif
-#ifdef HAVE_READLINE_HISTORY_H
-#include <readline/history.h>
-#endif
-#ifdef HAVE_EDITLINE_READLINE_H
-#include <editline/readline.h>
-#endif
-
-#include "ruby/io.h"
-#include "ruby/thread.h"
-
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif
-
-#ifdef HAVE_SYS_STAT_H
-#include <sys/stat.h>
-#endif
-
-static VALUE mReadline;
-
-#define EDIT_LINE_LIBRARY_VERSION "EditLine wrapper"
-#ifndef USE_INSERT_IGNORE_ESCAPE
-# if !defined(HAVE_EDITLINE_READLINE_H) && defined(RL_PROMPT_START_IGNORE) && defined(RL_PROMPT_END_IGNORE)
-# define USE_INSERT_IGNORE_ESCAPE 1
-# else
-# define USE_INSERT_IGNORE_ESCAPE 0
-# endif
-#endif
-
-#define COMPLETION_PROC "completion_proc"
-#define COMPLETION_CASE_FOLD "completion_case_fold"
-static ID id_call, completion_proc, completion_case_fold;
-#if defined HAVE_RL_CHAR_IS_QUOTED_P
-#define QUOTING_DETECTION_PROC "quoting_detection_proc"
-static ID quoting_detection_proc;
-#endif
-#if USE_INSERT_IGNORE_ESCAPE
-static ID id_orig_prompt, id_last_prompt;
-#endif
-#if defined(HAVE_RL_PRE_INPUT_HOOK)
-static ID id_pre_input_hook;
-#endif
-#if defined(HAVE_RL_SPECIAL_PREFIXES)
-static ID id_special_prefixes;
-#endif
-
-#ifndef HAVE_RL_FILENAME_COMPLETION_FUNCTION
-# define rl_filename_completion_function filename_completion_function
-#endif
-#ifndef HAVE_RL_USERNAME_COMPLETION_FUNCTION
-# define rl_username_completion_function username_completion_function
-#else
-RUBY_EXTERN char *rl_username_completion_function(const char *, int);
-#endif
-#ifndef HAVE_RL_COMPLETION_MATCHES
-# define rl_completion_matches completion_matches
-#endif
-
-static int (*history_get_offset_func)(int);
-static int (*history_replace_offset_func)(int);
-#ifdef HAVE_RL_COMPLETION_APPEND_CHARACTER
-static int readline_completion_append_character;
-#endif
-
-static char **readline_attempted_completion_function(const char *text,
- int start, int end);
-
-#define OutputStringValue(str) do {\
- StringValueCStr(str);\
- (str) = rb_str_conv_enc((str), rb_enc_get(str), rb_locale_encoding());\
-} while (0)\
-
-
-/*
- * Document-class: Readline
- *
- * The Readline module provides interface for GNU Readline.
- * This module defines a number of methods to facilitate completion
- * and accesses input history from the Ruby interpreter.
- * This module supported Edit Line(libedit) too.
- * libedit is compatible with GNU Readline.
- *
- * GNU Readline:: http://www.gnu.org/directory/readline.html
- * libedit:: http://www.thrysoee.dk/editline/
- *
- * Reads one inputted line with line edit by Readline.readline method.
- * At this time, the facilitatation completion and the key
- * bind like Emacs can be operated like GNU Readline.
- *
- * require "readline"
- * while buf = Readline.readline("> ", true)
- * p buf
- * end
- *
- * The content that the user input can be recorded to the history.
- * The history can be accessed by Readline::HISTORY constant.
- *
- * require "readline"
- * while buf = Readline.readline("> ", true)
- * p Readline::HISTORY.to_a
- * print("-> ", buf, "\n")
- * end
- *
- * Documented by Kouji Takao <kouji dot takao at gmail dot com>.
- */
-
-static VALUE readline_instream;
-static VALUE readline_outstream;
-static FILE *readline_rl_instream;
-static FILE *readline_rl_outstream;
-
-static void
-mustbe_callable(VALUE proc)
-{
- if (!NIL_P(proc) && !rb_respond_to(proc, id_call))
- rb_raise(rb_eArgError, "argument must respond to `call'");
-}
-
-#if defined HAVE_RL_GETC_FUNCTION
-
-#ifndef HAVE_RL_GETC
-#define rl_getc(f) EOF
-#endif
-
-struct getc_struct {
- FILE *input;
- int fd;
- int ret;
- int err;
-};
-
-static int
-getc_body(struct getc_struct *p)
-{
- char ch;
- ssize_t ss;
-
-#if defined(_WIN32)
- {
- INPUT_RECORD ir;
- DWORD n;
- static int prior_key = '0';
- for (;;) {
- HANDLE h;
- if (prior_key > 0xff) {
- prior_key = rl_getc(p->input);
- return prior_key;
- }
- h = (HANDLE)_get_osfhandle(p->fd);
- if (PeekConsoleInput(h, &ir, 1, &n)) {
- if (n == 1) {
- if (ir.EventType == KEY_EVENT && ir.Event.KeyEvent.bKeyDown) {
- prior_key = rl_getc(p->input);
- return prior_key;
- } else {
- ReadConsoleInput(h, &ir, 1, &n);
- }
- } else {
- rb_w32_wait_events_blocking(&h, 1, INFINITE);
- }
- } else {
- break;
- }
- }
- }
-#endif
-
- ss = read(p->fd, &ch, 1);
- if (ss == 0) {
- errno = 0;
- return EOF;
- }
- if (ss != 1)
- return EOF;
- return (unsigned char)ch;
-}
-
-static void *
-getc_func(void *data1)
-{
- struct getc_struct *p = data1;
- errno = 0;
- p->ret = getc_body(p);
- p->err = errno;
- return NULL;
-}
-
-static int
-readline_getc(FILE *input)
-{
- struct getc_struct data;
- if (input == NULL) /* editline may give NULL as input. */
- input = stdin;
- data.input = input;
- data.fd = fileno(input);
- again:
- data.ret = EOF;
- data.err = EINTR; /* getc_func is not called if already interrupted. */
- rb_thread_call_without_gvl2(getc_func, &data, RUBY_UBF_IO, NULL);
- if (data.ret == EOF) {
- if (data.err == 0) {
- return EOF;
- }
- if (data.err == EINTR) {
- rb_thread_check_ints();
- goto again;
- }
- if (data.err == EWOULDBLOCK || data.err == EAGAIN) {
- int ret;
- if (fileno(input) != data.fd)
- rb_bug("readline_getc: input closed unexpectedly or memory corrupted");
- ret = rb_wait_for_single_fd(data.fd, RB_WAITFD_IN, NULL);
- if (ret != -1 || errno == EINTR)
- goto again;
- rb_sys_fail("rb_wait_for_single_fd");
- }
- rb_syserr_fail(data.err, "read");
- }
- return data.ret;
-}
-
-#elif defined HAVE_RL_EVENT_HOOK
-#define BUSY_WAIT 0
-
-static int readline_event(void);
-static int
-readline_event(void)
-{
-#if BUSY_WAIT
- rb_thread_schedule();
-#else
- rb_wait_for_single_fd(fileno(rl_instream), RB_WAITFD_IN, NULL);
- return 0;
-#endif
-}
-#endif
-
-#if USE_INSERT_IGNORE_ESCAPE
-static VALUE
-insert_ignore_escape(VALUE self, VALUE prompt)
-{
- VALUE last_prompt, orig_prompt = rb_attr_get(self, id_orig_prompt);
- int ignoring = 0;
- const char *s0, *s, *e;
- long len;
- static const char ignore_code[2] = {RL_PROMPT_START_IGNORE, RL_PROMPT_END_IGNORE};
-
- prompt = rb_str_new_shared(prompt);
- last_prompt = rb_attr_get(self, id_last_prompt);
- if (orig_prompt == prompt) return last_prompt;
- len = RSTRING_LEN(prompt);
- if (NIL_P(last_prompt)) {
- last_prompt = rb_str_tmp_new(len);
- }
-
- s = s0 = RSTRING_PTR(prompt);
- e = s0 + len;
- rb_str_set_len(last_prompt, 0);
- while (s < e && *s) {
- switch (*s) {
- case RL_PROMPT_START_IGNORE:
- ignoring = -1;
- rb_str_cat(last_prompt, s0, ++s - s0);
- s0 = s;
- break;
- case RL_PROMPT_END_IGNORE:
- ignoring = 0;
- rb_str_cat(last_prompt, s0, ++s - s0);
- s0 = s;
- break;
- case '\033':
- if (++s < e && *s == '[') {
- rb_str_cat(last_prompt, s0, s - s0 - 1);
- s0 = s - 1;
- while (++s < e && *s) {
- if (ISALPHA(*(unsigned char *)s)) {
- if (!ignoring) {
- ignoring = 1;
- rb_str_cat(last_prompt, ignore_code+0, 1);
- }
- rb_str_cat(last_prompt, s0, ++s - s0);
- s0 = s;
- break;
- }
- else if (!(('0' <= *s && *s <= '9') || *s == ';')) {
- break;
- }
- }
- }
- break;
- default:
- if (ignoring > 0) {
- ignoring = 0;
- rb_str_cat(last_prompt, ignore_code+1, 1);
- }
- s++;
- break;
- }
- }
- if (ignoring > 0) {
- ignoring = 0;
- rb_str_cat(last_prompt, ignore_code+1, 1);
- }
- rb_str_cat(last_prompt, s0, s - s0);
-
- rb_ivar_set(self, id_orig_prompt, prompt);
- rb_ivar_set(self, id_last_prompt, last_prompt);
-
- return last_prompt;
-}
-#endif
-
-static VALUE
-readline_get(VALUE prompt)
-{
-#ifdef HAVE_RL_COMPLETION_APPEND_CHARACTER
- readline_completion_append_character = rl_completion_append_character;
-#endif
- return (VALUE)readline((char *)prompt);
-}
-
-static void
-clear_rl_instream(void)
-{
- if (readline_rl_instream) {
- fclose(readline_rl_instream);
- if (rl_instream == readline_rl_instream)
- rl_instream = NULL;
- readline_rl_instream = NULL;
- }
- readline_instream = Qfalse;
-}
-
-static void
-clear_rl_outstream(void)
-{
- if (readline_rl_outstream) {
- fclose(readline_rl_outstream);
- if (rl_outstream == readline_rl_outstream)
- rl_outstream = NULL;
- readline_rl_outstream = NULL;
- }
- readline_outstream = Qfalse;
-}
-
-static void
-prepare_readline(void)
-{
- static int initialized = 0;
- if (!initialized) {
- rl_initialize();
- initialized = 1;
- }
-
- if (readline_instream) {
- rb_io_t *ifp;
- rb_io_check_initialized(ifp = RFILE(rb_io_taint_check(readline_instream))->fptr);
- if (ifp->fd < 0) {
- clear_rl_instream();
- rb_raise(rb_eIOError, "closed readline input");
- }
- }
-
- if (readline_outstream) {
- rb_io_t *ofp;
- rb_io_check_initialized(ofp = RFILE(rb_io_taint_check(readline_outstream))->fptr);
- if (ofp->fd < 0) {
- clear_rl_outstream();
- rb_raise(rb_eIOError, "closed readline output");
- }
- }
-}
-
-/*
- * call-seq:
- * Readline.readline(prompt = "", add_hist = false) -> string or nil
- *
- * Shows the +prompt+ and reads the inputted line with line editing.
- * The inputted line is added to the history if +add_hist+ is true.
- *
- * Returns nil when the inputted line is empty and user inputs EOF
- * (Presses ^D on UNIX).
- *
- * Raises IOError exception if one of below conditions are satisfied.
- * 1. stdin was closed.
- * 2. stdout was closed.
- *
- * This method supports thread. Switches the thread context when waits
- * inputting line.
- *
- * Supports line edit when inputs line. Provides VI and Emacs editing mode.
- * Default is Emacs editing mode.
- *
- * NOTE: Terminates ruby interpreter and does not return the terminal
- * status after user pressed '^C' when wait inputting line.
- * Give 3 examples that avoid it.
- *
- * * Catches the Interrupt exception by pressed ^C after returns
- * terminal status:
- *
- * require "readline"
- *
- * stty_save = `stty -g`.chomp
- * begin
- * while buf = Readline.readline
- * p buf
- * end
- * rescue Interrupt
- * system("stty", stty_save)
- * exit
- * end
- * end
- * end
- *
- * * Catches the INT signal by pressed ^C after returns terminal
- * status:
- *
- * require "readline"
- *
- * stty_save = `stty -g`.chomp
- * trap("INT") { system "stty", stty_save; exit }
- *
- * while buf = Readline.readline
- * p buf
- * end
- *
- * * Ignores pressing ^C:
- *
- * require "readline"
- *
- * trap("INT", "SIG_IGN")
- *
- * while buf = Readline.readline
- * p buf
- * end
- *
- * Can make as follows with Readline::HISTORY constant.
- * It does not record to the history if the inputted line is empty or
- * the same it as last one.
- *
- * require "readline"
- *
- * while buf = Readline.readline("> ", true)
- * # p Readline::HISTORY.to_a
- * Readline::HISTORY.pop if /^\s*$/ =~ buf
- *
- * begin
- * if Readline::HISTORY[Readline::HISTORY.length-2] == buf
- * Readline::HISTORY.pop
- * end
- * rescue IndexError
- * end
- *
- * # p Readline::HISTORY.to_a
- * print "-> ", buf, "\n"
- * end
- */
-static VALUE
-readline_readline(int argc, VALUE *argv, VALUE self)
-{
- VALUE tmp, add_hist, result;
- char *prompt = NULL;
- char *buff;
- int status;
-
- if (rb_scan_args(argc, argv, "02", &tmp, &add_hist) > 0) {
- OutputStringValue(tmp);
-#if USE_INSERT_IGNORE_ESCAPE
- tmp = insert_ignore_escape(self, tmp);
- rb_str_locktmp(tmp);
-#endif
- prompt = RSTRING_PTR(tmp);
- }
-
- prepare_readline();
-
-#ifdef _WIN32
- rl_prep_terminal(1);
-#endif
- buff = (char*)rb_protect(readline_get, (VALUE)prompt, &status);
-#if USE_INSERT_IGNORE_ESCAPE
- if (prompt) {
- rb_str_unlocktmp(tmp);
- }
-#endif
- if (status) {
-#if defined HAVE_RL_CLEANUP_AFTER_SIGNAL
- /* restore terminal mode and signal handler*/
-#if defined HAVE_RL_FREE_LINE_STATE
- rl_free_line_state();
-#endif
- rl_cleanup_after_signal();
-#elif defined HAVE_RL_DEPREP_TERM_FUNCTION
- /* restore terminal mode */
- if (rl_deprep_term_function != NULL) /* NULL in libedit. [ruby-dev:29116] */
- (*rl_deprep_term_function)();
- else
-#else
- rl_deprep_terminal();
-#endif
- rb_jump_tag(status);
- }
-
- if (RTEST(add_hist) && buff) {
- add_history(buff);
- }
- if (buff) {
- result = rb_locale_str_new_cstr(buff);
- }
- else
- result = Qnil;
- if (buff) free(buff);
- return result;
-}
-
-/*
- * call-seq:
- * Readline.input = input
- *
- * Specifies a File object +input+ that is input stream for
- * Readline.readline method.
- */
-static VALUE
-readline_s_set_input(VALUE self, VALUE input)
-{
- rb_io_t *ifp;
- int fd;
- FILE *f;
-
- if (NIL_P(input)) {
- clear_rl_instream();
- }
- else {
- Check_Type(input, T_FILE);
- GetOpenFile(input, ifp);
- clear_rl_instream();
- fd = rb_cloexec_dup(ifp->fd);
- if (fd == -1)
- rb_sys_fail("dup");
- f = fdopen(fd, "r");
- if (f == NULL) {
- int save_errno = errno;
- close(fd);
- rb_syserr_fail(save_errno, "fdopen");
- }
- rl_instream = readline_rl_instream = f;
- readline_instream = input;
- }
- return input;
-}
-
-/*
- * call-seq:
- * Readline.output = output
- *
- * Specifies a File object +output+ that is output stream for
- * Readline.readline method.
- */
-static VALUE
-readline_s_set_output(VALUE self, VALUE output)
-{
- rb_io_t *ofp;
- int fd;
- FILE *f;
-
- if (NIL_P(output)) {
- clear_rl_outstream();
- }
- else {
- Check_Type(output, T_FILE);
- GetOpenFile(output, ofp);
- clear_rl_outstream();
- fd = rb_cloexec_dup(ofp->fd);
- if (fd == -1)
- rb_sys_fail("dup");
- f = fdopen(fd, "w");
- if (f == NULL) {
- int save_errno = errno;
- close(fd);
- rb_syserr_fail(save_errno, "fdopen");
- }
- rl_outstream = readline_rl_outstream = f;
- readline_outstream = output;
- }
- return output;
-}
-
-#if defined(HAVE_RL_PRE_INPUT_HOOK)
-/*
- * call-seq:
- * Readline.pre_input_hook = proc
- *
- * Specifies a Proc object +proc+ to call after the first prompt has
- * been printed and just before readline starts reading input
- * characters.
- *
- * See GNU Readline's rl_pre_input_hook variable.
- *
- * Raises ArgumentError if +proc+ does not respond to the call method.
- *
- * Raises NotImplementedError if the using readline library does not support.
- */
-static VALUE
-readline_s_set_pre_input_hook(VALUE self, VALUE proc)
-{
- mustbe_callable(proc);
- return rb_ivar_set(mReadline, id_pre_input_hook, proc);
-}
-
-/*
- * call-seq:
- * Readline.pre_input_hook -> proc
- *
- * Returns a Proc object +proc+ to call after the first prompt has
- * been printed and just before readline starts reading input
- * characters. The default is nil.
- *
- * Raises NotImplementedError if the using readline library does not support.
- */
-static VALUE
-readline_s_get_pre_input_hook(VALUE self)
-{
- return rb_attr_get(mReadline, id_pre_input_hook);
-}
-
-static int
-readline_pre_input_hook(void)
-{
- VALUE proc;
-
- proc = rb_attr_get(mReadline, id_pre_input_hook);
- if (!NIL_P(proc))
- rb_funcall(proc, id_call, 0);
- return 0;
-}
-#else
-#define readline_s_set_pre_input_hook rb_f_notimplement
-#define readline_s_get_pre_input_hook rb_f_notimplement
-#endif
-
-#if defined(HAVE_RL_INSERT_TEXT)
-/*
- * call-seq:
- * Readline.insert_text(string) -> self
- *
- * Insert text into the line at the current cursor position.
- *
- * See GNU Readline's rl_insert_text function.
- *
- * Raises NotImplementedError if the using readline library does not support.
- */
-static VALUE
-readline_s_insert_text(VALUE self, VALUE str)
-{
- OutputStringValue(str);
- rl_insert_text(RSTRING_PTR(str));
- return self;
-}
-#else
-#define readline_s_insert_text rb_f_notimplement
-#endif
-
-#if defined(HAVE_RL_DELETE_TEXT)
-RUBY_EXTERN int rl_delete_text(int, int);
-static const char *
-str_subpos(const char *ptr, const char *end, long beg, long *sublen, rb_encoding *enc)
-{
- VALUE str = rb_enc_str_new_static(ptr, end-ptr, enc);
- OBJ_FREEZE(str);
- ptr = rb_str_subpos(str, beg, sublen);
- return ptr;
-}
-
-/*
- * call-seq:
- * Readline.delete_text([start[, length]]) -> self
- * Readline.delete_text(start..end) -> self
- * Readline.delete_text() -> self
- *
- * Delete text between start and end in the current line.
- *
- * See GNU Readline's rl_delete_text function.
- *
- * Raises NotImplementedError if the using readline library does not support.
- */
-static VALUE
-readline_s_delete_text(int argc, VALUE *argv, VALUE self)
-{
- rb_check_arity(argc, 0, 2);
- if (rl_line_buffer) {
- const char *p, *ptr = rl_line_buffer;
- long beg = 0, len = strlen(ptr);
- const char *end = ptr + len;
- rb_encoding *enc = rb_locale_encoding();
- if (argc == 2) {
- beg = NUM2LONG(argv[0]);
- len = NUM2LONG(argv[1]);
- num_pos:
- p = str_subpos(ptr, end, beg, &len, enc);
- if (!p) rb_raise(rb_eArgError, "invalid index");
- beg = p - ptr;
- }
- else if (argc == 1) {
- len = rb_enc_strlen(ptr, ptr + len, enc);
- if (!rb_range_beg_len(argv[0], &beg, &len, len, 1)) {
- beg = NUM2LONG(argv[0]);
- goto num_pos;
- }
- }
- rl_delete_text(rb_long2int(beg), rb_long2int(beg + len));
- }
- return self;
-}
-#else
-#define readline_s_delete_text rb_f_notimplement
-#endif
-
-#if defined(HAVE_RL_REDISPLAY)
-/*
- * call-seq:
- * Readline.redisplay -> self
- *
- * Change what's displayed on the screen to reflect the current
- * contents.
- *
- * See GNU Readline's rl_redisplay function.
- *
- * Raises NotImplementedError if the using readline library does not support.
- */
-static VALUE
-readline_s_redisplay(VALUE self)
-{
- rl_redisplay();
- return self;
-}
-#else
-#define readline_s_redisplay rb_f_notimplement
-#endif
-
-/*
- * call-seq:
- * Readline.completion_proc = proc
- *
- * Specifies a Proc object +proc+ to determine completion behavior. It
- * should take input string and return an array of completion candidates.
- *
- * The default completion is used if +proc+ is nil.
- *
- * The String that is passed to the Proc depends on the
- * Readline.completer_word_break_characters property. By default the word
- * under the cursor is passed to the Proc. For example, if the input is "foo
- * bar" then only "bar" would be passed to the completion Proc.
- *
- * Upon successful completion the Readline.completion_append_character will be
- * appended to the input so the user can start working on their next argument.
- *
- * = Examples
- *
- * == Completion for a Static List
- *
- * require 'readline'
- *
- * LIST = [
- * 'search', 'download', 'open',
- * 'help', 'history', 'quit',
- * 'url', 'next', 'clear',
- * 'prev', 'past'
- * ].sort
- *
- * comp = proc { |s| LIST.grep(/^#{Regexp.escape(s)}/) }
- *
- * Readline.completion_append_character = " "
- * Readline.completion_proc = comp
- *
- * while line = Readline.readline('> ', true)
- * p line
- * end
- *
- * == Completion For Directory Contents
- *
- * require 'readline'
- *
- * Readline.completion_append_character = " "
- * Readline.completion_proc = Proc.new do |str|
- * Dir[str+'*'].grep(/^#{Regexp.escape(str)}/)
- * end
- *
- * while line = Readline.readline('> ', true)
- * p line
- * end
- *
- * = Autocomplete strategies
- *
- * When working with auto-complete there are some strategies that work well.
- * To get some ideas you can take a look at the
- * completion.rb[https://git.ruby-lang.org/ruby.git/tree/lib/irb/completion.rb]
- * file for irb.
- *
- * The common strategy is to take a list of possible completions and filter it
- * down to those completions that start with the user input. In the above
- * examples Enumerator.grep is used. The input is escaped to prevent Regexp
- * special characters from interfering with the matching.
- *
- * It may also be helpful to use the Abbrev library to generate completions.
- *
- * Raises ArgumentError if +proc+ does not respond to the call method.
- */
-static VALUE
-readline_s_set_completion_proc(VALUE self, VALUE proc)
-{
- mustbe_callable(proc);
- return rb_ivar_set(mReadline, completion_proc, proc);
-}
-
-/*
- * call-seq:
- * Readline.completion_proc -> proc
- *
- * Returns the completion Proc object.
- */
-static VALUE
-readline_s_get_completion_proc(VALUE self)
-{
- return rb_attr_get(mReadline, completion_proc);
-}
-
-#ifdef HAVE_RL_CHAR_IS_QUOTED_P
-/*
- * call-seq:
- * Readline.quoting_detection_proc = proc
- *
- * Specifies a Proc object +proc+ to determine if a character in the user's
- * input is escaped. It should take the user's input and the index of the
- * character in question as input, and return a boolean (true if the specified
- * character is escaped).
- *
- * Readline will only call this proc with characters specified in
- * +completer_quote_characters+, to discover if they indicate the end of a
- * quoted argument, or characters specified in
- * +completer_word_break_characters+, to discover if they indicate a break
- * between arguments.
- *
- * If +completer_quote_characters+ is not set, or if the user input doesn't
- * contain one of the +completer_quote_characters+ or a +\+ character,
- * Readline will not attempt to use this proc at all.
- *
- * Raises ArgumentError if +proc+ does not respond to the call method.
- */
-static VALUE
-readline_s_set_quoting_detection_proc(VALUE self, VALUE proc)
-{
- mustbe_callable(proc);
- return rb_ivar_set(mReadline, quoting_detection_proc, proc);
-}
-
-/*
- * call-seq:
- * Readline.quoting_detection_proc -> proc
- *
- * Returns the quoting detection Proc object.
- */
-static VALUE
-readline_s_get_quoting_detection_proc(VALUE self)
-{
- return rb_attr_get(mReadline, quoting_detection_proc);
-}
-#else
-#define readline_s_set_quoting_detection_proc rb_f_notimplement
-#define readline_s_get_quoting_detection_proc rb_f_notimplement
-#endif
-
-/*
- * call-seq:
- * Readline.completion_case_fold = bool
- *
- * Sets whether or not to ignore case on completion.
- */
-static VALUE
-readline_s_set_completion_case_fold(VALUE self, VALUE val)
-{
- return rb_ivar_set(mReadline, completion_case_fold, val);
-}
-
-/*
- * call-seq:
- * Readline.completion_case_fold -> bool
- *
- * Returns true if completion ignores case. If no, returns false.
- *
- * NOTE: Returns the same object that is specified by
- * Readline.completion_case_fold= method.
- *
- * require "readline"
- *
- * Readline.completion_case_fold = "This is a String."
- * p Readline.completion_case_fold # => "This is a String."
- */
-static VALUE
-readline_s_get_completion_case_fold(VALUE self)
-{
- return rb_attr_get(mReadline, completion_case_fold);
-}
-
-#ifdef HAVE_RL_LINE_BUFFER
-/*
- * call-seq:
- * Readline.line_buffer -> string
- *
- * Returns the full line that is being edited. This is useful from
- * within the complete_proc for determining the context of the
- * completion request.
- *
- * The length of +Readline.line_buffer+ and GNU Readline's rl_end are
- * same.
- *
- * Raises NotImplementedError if the using readline library does not support.
- */
-static VALUE
-readline_s_get_line_buffer(VALUE self)
-{
- if (rl_line_buffer == NULL)
- return Qnil;
- return rb_locale_str_new_cstr(rl_line_buffer);
-}
-#else
-#define readline_s_get_line_buffer rb_f_notimplement
-#endif
-
-#ifdef HAVE_RL_POINT
-/*
- * call-seq:
- * Readline.point -> int
- *
- * Returns the index of the current cursor position in
- * +Readline.line_buffer+.
- *
- * The index in +Readline.line_buffer+ which matches the start of
- * input-string passed to completion_proc is computed by subtracting
- * the length of input-string from +Readline.point+.
- *
- * start = (the length of input-string) - Readline.point
- *
- * Raises NotImplementedError if the using readline library does not support.
- */
-static VALUE
-readline_s_get_point(VALUE self)
-{
- return INT2NUM(rl_point);
-}
-
-/*
- * call-seq:
- * Readline.point = int
- *
- * Set the index of the current cursor position in
- * +Readline.line_buffer+.
- *
- * Raises NotImplementedError if the using readline library does not support.
- *
- * See +Readline.point+.
- */
-static VALUE
-readline_s_set_point(VALUE self, VALUE pos)
-{
- rl_point = NUM2INT(pos);
- return pos;
-}
-#else
-#define readline_s_get_point rb_f_notimplement
-#define readline_s_set_point rb_f_notimplement
-#endif
-
-static char **
-readline_attempted_completion_function(const char *text, int start, int end)
-{
- VALUE proc, ary, temp;
- char **result;
- int case_fold;
- long i, matches;
- rb_encoding *enc;
- VALUE encobj;
-
- proc = rb_attr_get(mReadline, completion_proc);
- if (NIL_P(proc))
- return NULL;
-#ifdef HAVE_RL_COMPLETION_APPEND_CHARACTER
- rl_completion_append_character = readline_completion_append_character;
-#endif
-#ifdef HAVE_RL_ATTEMPTED_COMPLETION_OVER
- rl_attempted_completion_over = 1;
-#endif
- case_fold = RTEST(rb_attr_get(mReadline, completion_case_fold));
- ary = rb_funcall(proc, id_call, 1, rb_locale_str_new_cstr(text));
- if (!RB_TYPE_P(ary, T_ARRAY))
- ary = rb_Array(ary);
- matches = RARRAY_LEN(ary);
- if (matches == 0) return NULL;
- result = (char**)malloc((matches + 2)*sizeof(char*));
- if (result == NULL) rb_memerror();
- enc = rb_locale_encoding();
- encobj = rb_enc_from_encoding(enc);
- for (i = 0; i < matches; i++) {
- temp = rb_obj_as_string(RARRAY_AREF(ary, i));
- StringValueCStr(temp); /* must be NUL-terminated */
- rb_enc_check(encobj, temp);
- result[i + 1] = (char*)malloc(RSTRING_LEN(temp) + 1);
- if (result[i + 1] == NULL) rb_memerror();
- strcpy(result[i + 1], RSTRING_PTR(temp));
- }
- result[matches + 1] = NULL;
-
- if (matches == 1) {
- result[0] = strdup(result[1]);
- }
- else {
- const char *result1 = result[1];
- long low = strlen(result1);
-
- for (i = 1; i < matches; ++i) {
- register int c1, c2;
- long i1, i2, l2;
- int n1, n2;
- const char *p2 = result[i + 1];
-
- l2 = strlen(p2);
- for (i1 = i2 = 0; i1 < low && i2 < l2; i1 += n1, i2 += n2) {
- c1 = rb_enc_codepoint_len(result1 + i1, result1 + low, &n1, enc);
- c2 = rb_enc_codepoint_len(p2 + i2, p2 + l2, &n2, enc);
- if (case_fold) {
- c1 = rb_tolower(c1);
- c2 = rb_tolower(c2);
- }
- if (c1 != c2) break;
- }
-
- low = i1;
- }
- result[0] = (char*)malloc(low + 1);
- if (result[0] == NULL) rb_memerror();
- strncpy(result[0], result[1], low);
- result[0][low] = '\0';
- }
-
- return result;
-}
-
-#ifdef HAVE_RL_CHAR_IS_QUOTED_P
-static int
-readline_char_is_quoted(char *text, int byte_index)
-{
- VALUE proc, result, str;
- long char_index;
- size_t len;
-
- proc = rb_attr_get(mReadline, quoting_detection_proc);
- if (NIL_P(proc)) {
- return 0;
- }
-
- len = strlen(text);
- if (byte_index < 0 || len < (size_t)byte_index) {
- rb_raise(rb_eIndexError, "invalid byte index (%d in %"PRIdSIZE")",
- byte_index, len);
- }
-
- str = rb_locale_str_new(text, len);
- char_index = rb_str_sublen(str, byte_index);
- result = rb_funcall(proc, id_call, 2, str, LONG2FIX(char_index));
- return RTEST(result);
-}
-#endif
-
-#ifdef HAVE_RL_SET_SCREEN_SIZE
-/*
- * call-seq:
- * Readline.set_screen_size(rows, columns) -> self
- *
- * Set terminal size to +rows+ and +columns+.
- *
- * See GNU Readline's rl_set_screen_size function.
- *
- * Raises NotImplementedError if the using readline library does not support.
- */
-static VALUE
-readline_s_set_screen_size(VALUE self, VALUE rows, VALUE columns)
-{
- rl_set_screen_size(NUM2INT(rows), NUM2INT(columns));
- return self;
-}
-#else
-#define readline_s_set_screen_size rb_f_notimplement
-#endif
-
-#ifdef HAVE_RL_GET_SCREEN_SIZE
-/*
- * call-seq:
- * Readline.get_screen_size -> [rows, columns]
- *
- * Returns the terminal's rows and columns.
- *
- * See GNU Readline's rl_get_screen_size function.
- *
- * Raises NotImplementedError if the using readline library does not support.
- */
-static VALUE
-readline_s_get_screen_size(VALUE self)
-{
- int rows, columns;
- VALUE res;
-
- rl_get_screen_size(&rows, &columns);
- res = rb_ary_new();
- rb_ary_push(res, INT2NUM(rows));
- rb_ary_push(res, INT2NUM(columns));
- return res;
-}
-#else
-#define readline_s_get_screen_size rb_f_notimplement
-#endif
-
-#ifdef HAVE_RL_VI_EDITING_MODE
-RUBY_EXTERN int rl_vi_editing_mode(int, int);
-/*
- * call-seq:
- * Readline.vi_editing_mode -> nil
- *
- * Specifies VI editing mode. See the manual of GNU Readline for
- * details of VI editing mode.
- *
- * Raises NotImplementedError if the using readline library does not support.
- */
-static VALUE
-readline_s_vi_editing_mode(VALUE self)
-{
- rl_vi_editing_mode(1,0);
- return Qnil;
-}
-#else
-#define readline_s_vi_editing_mode rb_f_notimplement
-#endif
-
-#ifdef HAVE_RL_EDITING_MODE
-/*
- * call-seq:
- * Readline.vi_editing_mode? -> bool
- *
- * Returns true if vi mode is active. Returns false if not.
- *
- * Raises NotImplementedError if the using readline library does not support.
- */
-static VALUE
-readline_s_vi_editing_mode_p(VALUE self)
-{
- return rl_editing_mode == 0 ? Qtrue : Qfalse;
-}
-#else
-#define readline_s_vi_editing_mode_p rb_f_notimplement
-#endif
-
-#ifdef HAVE_RL_EMACS_EDITING_MODE
-RUBY_EXTERN int rl_emacs_editing_mode(int, int);
-/*
- * call-seq:
- * Readline.emacs_editing_mode -> nil
- *
- * Specifies Emacs editing mode. The default is this mode. See the
- * manual of GNU Readline for details of Emacs editing mode.
- *
- * Raises NotImplementedError if the using readline library does not support.
- */
-static VALUE
-readline_s_emacs_editing_mode(VALUE self)
-{
- rl_emacs_editing_mode(1,0);
- return Qnil;
-}
-#else
-#define readline_s_emacs_editing_mode rb_f_notimplement
-#endif
-
-#ifdef HAVE_RL_EDITING_MODE
-/*
- * call-seq:
- * Readline.emacs_editing_mode? -> bool
- *
- * Returns true if emacs mode is active. Returns false if not.
- *
- * Raises NotImplementedError if the using readline library does not support.
- */
-static VALUE
-readline_s_emacs_editing_mode_p(VALUE self)
-{
- return rl_editing_mode == 1 ? Qtrue : Qfalse;
-}
-#else
-#define readline_s_emacs_editing_mode_p rb_f_notimplement
-#endif
-
-#ifdef HAVE_RL_COMPLETION_APPEND_CHARACTER
-/*
- * call-seq:
- * Readline.completion_append_character = char
- *
- * Specifies a character to be appended on completion.
- * Nothing will be appended if an empty string ("") or nil is
- * specified.
- *
- * For example:
- * require "readline"
- *
- * Readline.readline("> ", true)
- * Readline.completion_append_character = " "
- *
- * Result:
- * >
- * Input "/var/li".
- *
- * > /var/li
- * Press TAB key.
- *
- * > /var/lib
- * Completes "b" and appends " ". So, you can continuously input "/usr".
- *
- * > /var/lib /usr
- *
- * NOTE: Only one character can be specified. When "string" is
- * specified, sets only "s" that is the first.
- *
- * require "readline"
- *
- * Readline.completion_append_character = "string"
- * p Readline.completion_append_character # => "s"
- *
- * Raises NotImplementedError if the using readline library does not support.
- */
-static VALUE
-readline_s_set_completion_append_character(VALUE self, VALUE str)
-{
- if (NIL_P(str)) {
- rl_completion_append_character = '\0';
- }
- else {
- OutputStringValue(str);
- if (RSTRING_LEN(str) == 0) {
- rl_completion_append_character = '\0';
- } else {
- rl_completion_append_character = RSTRING_PTR(str)[0];
- }
- }
- return self;
-}
-#else
-#define readline_s_set_completion_append_character rb_f_notimplement
-#endif
-
-#ifdef HAVE_RL_COMPLETION_APPEND_CHARACTER
-/*
- * call-seq:
- * Readline.completion_append_character -> char
- *
- * Returns a string containing a character to be appended on
- * completion. The default is a space (" ").
- *
- * Raises NotImplementedError if the using readline library does not support.
- */
-static VALUE
-readline_s_get_completion_append_character(VALUE self)
-{
- char buf[1];
-
- if (rl_completion_append_character == '\0')
- return Qnil;
-
- buf[0] = (char) rl_completion_append_character;
- return rb_locale_str_new(buf, 1);
-}
-#else
-#define readline_s_get_completion_append_character rb_f_notimplement
-#endif
-
-#ifdef HAVE_RL_COMPLETION_QUOTE_CHARACTER
-/*
- * call-seq:
- * Readline.completion_quote_character -> char
- *
- * When called during a completion (e.g. from within your completion_proc),
- * it will return a string containing the character used to quote the
- * argument being completed, or nil if the argument is unquoted.
- *
- * When called at other times, it will always return nil.
- *
- * Note that Readline.completer_quote_characters must be set,
- * or this method will always return nil.
- */
-static VALUE
-readline_s_get_completion_quote_character(VALUE self)
-{
- char buf[1];
-
- if (rl_completion_quote_character == '\0')
- return Qnil;
-
- buf[0] = (char) rl_completion_quote_character;
- return rb_locale_str_new(buf, 1);
-}
-#else
-#define readline_s_get_completion_quote_character rb_f_notimplement
-#endif
-
-#ifdef HAVE_RL_BASIC_WORD_BREAK_CHARACTERS
-/*
- * call-seq:
- * Readline.basic_word_break_characters = string
- *
- * Sets the basic list of characters that signal a break between words
- * for the completer routine. The default is the characters which
- * break words for completion in Bash: " \t\n\"\\'`@$><=;|&{(".
- *
- * Raises NotImplementedError if the using readline library does not support.
- */
-static VALUE
-readline_s_set_basic_word_break_characters(VALUE self, VALUE str)
-{
- static char *basic_word_break_characters = NULL;
-
- OutputStringValue(str);
- if (basic_word_break_characters == NULL) {
- basic_word_break_characters =
- ALLOC_N(char, RSTRING_LEN(str) + 1);
- }
- else {
- REALLOC_N(basic_word_break_characters, char, RSTRING_LEN(str) + 1);
- }
- strncpy(basic_word_break_characters,
- RSTRING_PTR(str), RSTRING_LEN(str));
- basic_word_break_characters[RSTRING_LEN(str)] = '\0';
- rl_basic_word_break_characters = basic_word_break_characters;
- return self;
-}
-#else
-#define readline_s_set_basic_word_break_characters rb_f_notimplement
-#endif
-
-#ifdef HAVE_RL_BASIC_WORD_BREAK_CHARACTERS
-/*
- * call-seq:
- * Readline.basic_word_break_characters -> string
- *
- * Gets the basic list of characters that signal a break between words
- * for the completer routine.
- *
- * Raises NotImplementedError if the using readline library does not support.
- */
-static VALUE
-readline_s_get_basic_word_break_characters(VALUE self)
-{
- if (rl_basic_word_break_characters == NULL)
- return Qnil;
- return rb_locale_str_new_cstr(rl_basic_word_break_characters);
-}
-#else
-#define readline_s_get_basic_word_break_characters rb_f_notimplement
-#endif
-
-#ifdef HAVE_RL_COMPLETER_WORD_BREAK_CHARACTERS
-/*
- * call-seq:
- * Readline.completer_word_break_characters = string
- *
- * Sets the basic list of characters that signal a break between words
- * for rl_complete_internal(). The default is the value of
- * Readline.basic_word_break_characters.
- *
- * Raises NotImplementedError if the using readline library does not support.
- */
-static VALUE
-readline_s_set_completer_word_break_characters(VALUE self, VALUE str)
-{
- static char *completer_word_break_characters = NULL;
-
- OutputStringValue(str);
- if (completer_word_break_characters == NULL) {
- completer_word_break_characters =
- ALLOC_N(char, RSTRING_LEN(str) + 1);
- }
- else {
- REALLOC_N(completer_word_break_characters, char, RSTRING_LEN(str) + 1);
- }
- strncpy(completer_word_break_characters,
- RSTRING_PTR(str), RSTRING_LEN(str));
- completer_word_break_characters[RSTRING_LEN(str)] = '\0';
- rl_completer_word_break_characters = completer_word_break_characters;
- return self;
-}
-#else
-#define readline_s_set_completer_word_break_characters rb_f_notimplement
-#endif
-
-#ifdef HAVE_RL_COMPLETER_WORD_BREAK_CHARACTERS
-/*
- * call-seq:
- * Readline.completer_word_break_characters -> string
- *
- * Gets the basic list of characters that signal a break between words
- * for rl_complete_internal().
- *
- * Raises NotImplementedError if the using readline library does not support.
- */
-static VALUE
-readline_s_get_completer_word_break_characters(VALUE self)
-{
- if (rl_completer_word_break_characters == NULL)
- return Qnil;
- return rb_locale_str_new_cstr(rl_completer_word_break_characters);
-}
-#else
-#define readline_s_get_completer_word_break_characters rb_f_notimplement
-#endif
-
-#if defined(HAVE_RL_SPECIAL_PREFIXES)
-/*
- * call-seq:
- * Readline.special_prefixes = string
- *
- * Sets the list of characters that are word break characters, but
- * should be left in text when it is passed to the completion
- * function. Programs can use this to help determine what kind of
- * completing to do. For instance, Bash sets this variable to "$@" so
- * that it can complete shell variables and hostnames.
- *
- * See GNU Readline's rl_special_prefixes variable.
- *
- * Raises NotImplementedError if the using readline library does not support.
- */
-static VALUE
-readline_s_set_special_prefixes(VALUE self, VALUE str)
-{
- if (!NIL_P(str)) {
- OutputStringValue(str);
- str = rb_str_dup_frozen(str);
- rb_obj_hide(str);
- }
- rb_ivar_set(mReadline, id_special_prefixes, str);
- if (NIL_P(str)) {
- rl_special_prefixes = NULL;
- }
- else {
- rl_special_prefixes = RSTRING_PTR(str);
- }
- return self;
-}
-
-/*
- * call-seq:
- * Readline.special_prefixes -> string
- *
- * Gets the list of characters that are word break characters, but
- * should be left in text when it is passed to the completion
- * function.
- *
- * See GNU Readline's rl_special_prefixes variable.
- *
- * Raises NotImplementedError if the using readline library does not support.
- */
-static VALUE
-readline_s_get_special_prefixes(VALUE self)
-{
- VALUE str;
- if (rl_special_prefixes == NULL) return Qnil;
- str = rb_ivar_get(mReadline, id_special_prefixes);
- if (!NIL_P(str)) {
- str = rb_str_dup_frozen(str);
- rb_obj_reveal(str, rb_cString);
- }
- return str;
-}
-#else
-#define readline_s_set_special_prefixes rb_f_notimplement
-#define readline_s_get_special_prefixes rb_f_notimplement
-#endif
-
-#ifdef HAVE_RL_BASIC_QUOTE_CHARACTERS
-/*
- * call-seq:
- * Readline.basic_quote_characters = string
- *
- * Sets a list of quote characters which can cause a word break.
- *
- * Raises NotImplementedError if the using readline library does not support.
- */
-static VALUE
-readline_s_set_basic_quote_characters(VALUE self, VALUE str)
-{
- static char *basic_quote_characters = NULL;
-
- OutputStringValue(str);
- if (basic_quote_characters == NULL) {
- basic_quote_characters =
- ALLOC_N(char, RSTRING_LEN(str) + 1);
- }
- else {
- REALLOC_N(basic_quote_characters, char, RSTRING_LEN(str) + 1);
- }
- strncpy(basic_quote_characters,
- RSTRING_PTR(str), RSTRING_LEN(str));
- basic_quote_characters[RSTRING_LEN(str)] = '\0';
- rl_basic_quote_characters = basic_quote_characters;
-
- return self;
-}
-#else
-#define readline_s_set_basic_quote_characters rb_f_notimplement
-#endif
-
-#ifdef HAVE_RL_BASIC_QUOTE_CHARACTERS
-/*
- * call-seq:
- * Readline.basic_quote_characters -> string
- *
- * Gets a list of quote characters which can cause a word break.
- *
- * Raises NotImplementedError if the using readline library does not support.
- */
-static VALUE
-readline_s_get_basic_quote_characters(VALUE self)
-{
- if (rl_basic_quote_characters == NULL)
- return Qnil;
- return rb_locale_str_new_cstr(rl_basic_quote_characters);
-}
-#else
-#define readline_s_get_basic_quote_characters rb_f_notimplement
-#endif
-
-#ifdef HAVE_RL_COMPLETER_QUOTE_CHARACTERS
-/*
- * call-seq:
- * Readline.completer_quote_characters = string
- *
- * Sets a list of characters which can be used to quote a substring of
- * the line. Completion occurs on the entire substring, and within
- * the substring Readline.completer_word_break_characters are treated
- * as any other character, unless they also appear within this list.
- *
- * Raises NotImplementedError if the using readline library does not support.
- */
-static VALUE
-readline_s_set_completer_quote_characters(VALUE self, VALUE str)
-{
- static char *completer_quote_characters = NULL;
-
- OutputStringValue(str);
- if (completer_quote_characters == NULL) {
- completer_quote_characters =
- ALLOC_N(char, RSTRING_LEN(str) + 1);
- }
- else {
- REALLOC_N(completer_quote_characters, char, RSTRING_LEN(str) + 1);
- }
- strncpy(completer_quote_characters, RSTRING_PTR(str), RSTRING_LEN(str));
- completer_quote_characters[RSTRING_LEN(str)] = '\0';
- rl_completer_quote_characters = completer_quote_characters;
-
- return self;
-}
-#else
-#define readline_s_set_completer_quote_characters rb_f_notimplement
-#endif
-
-#ifdef HAVE_RL_COMPLETER_QUOTE_CHARACTERS
-/*
- * call-seq:
- * Readline.completer_quote_characters -> string
- *
- * Gets a list of characters which can be used to quote a substring of
- * the line.
- *
- * Raises NotImplementedError if the using readline library does not support.
- */
-static VALUE
-readline_s_get_completer_quote_characters(VALUE self)
-{
- if (rl_completer_quote_characters == NULL)
- return Qnil;
- return rb_locale_str_new_cstr(rl_completer_quote_characters);
-}
-#else
-#define readline_s_get_completer_quote_characters rb_f_notimplement
-#endif
-
-#ifdef HAVE_RL_FILENAME_QUOTE_CHARACTERS
-/*
- * call-seq:
- * Readline.filename_quote_characters = string
- *
- * Sets a list of characters that cause a filename to be quoted by the completer
- * when they appear in a completed filename. The default is nil.
- *
- * Raises NotImplementedError if the using readline library does not support.
- */
-static VALUE
-readline_s_set_filename_quote_characters(VALUE self, VALUE str)
-{
- static char *filename_quote_characters = NULL;
-
- OutputStringValue(str);
- if (filename_quote_characters == NULL) {
- filename_quote_characters =
- ALLOC_N(char, RSTRING_LEN(str) + 1);
- }
- else {
- REALLOC_N(filename_quote_characters, char, RSTRING_LEN(str) + 1);
- }
- strncpy(filename_quote_characters, RSTRING_PTR(str), RSTRING_LEN(str));
- filename_quote_characters[RSTRING_LEN(str)] = '\0';
- rl_filename_quote_characters = filename_quote_characters;
-
- return self;
-}
-#else
-#define readline_s_set_filename_quote_characters rb_f_notimplement
-#endif
-
-#ifdef HAVE_RL_FILENAME_QUOTE_CHARACTERS
-/*
- * call-seq:
- * Readline.filename_quote_characters -> string
- *
- * Gets a list of characters that cause a filename to be quoted by the completer
- * when they appear in a completed filename.
- *
- * Raises NotImplementedError if the using readline library does not support.
- */
-static VALUE
-readline_s_get_filename_quote_characters(VALUE self)
-{
- if (rl_filename_quote_characters == NULL)
- return Qnil;
- return rb_locale_str_new_cstr(rl_filename_quote_characters);
-}
-#else
-#define readline_s_get_filename_quote_characters rb_f_notimplement
-#endif
-
-#ifdef HAVE_RL_REFRESH_LINE
-RUBY_EXTERN int rl_refresh_line(int, int);
-/*
- * call-seq:
- * Readline.refresh_line -> nil
- *
- * Clear the current input line.
- */
-static VALUE
-readline_s_refresh_line(VALUE self)
-{
- prepare_readline();
- rl_refresh_line(0, 0);
- return Qnil;
-}
-#else
-#define readline_s_refresh_line rb_f_notimplement
-#endif
-
-static VALUE
-hist_to_s(VALUE self)
-{
- return rb_str_new_cstr("HISTORY");
-}
-
-static int
-history_get_offset_history_base(int offset)
-{
- return history_base + offset;
-}
-
-static int
-history_get_offset_0(int offset)
-{
- return offset;
-}
-
-static VALUE
-hist_get(VALUE self, VALUE index)
-{
- HIST_ENTRY *entry = NULL;
- int i;
-
- i = NUM2INT(index);
- if (i < 0) {
- i += history_length;
- }
- if (i >= 0) {
- entry = history_get(history_get_offset_func(i));
- }
- if (entry == NULL) {
- rb_raise(rb_eIndexError, "invalid index");
- }
- return rb_locale_str_new_cstr(entry->line);
-}
-
-#ifdef HAVE_REPLACE_HISTORY_ENTRY
-static VALUE
-hist_set(VALUE self, VALUE index, VALUE str)
-{
- HIST_ENTRY *entry = NULL;
- int i;
-
- i = NUM2INT(index);
- OutputStringValue(str);
- if (i < 0) {
- i += history_length;
- }
- if (i >= 0) {
- entry = replace_history_entry(history_replace_offset_func(i), RSTRING_PTR(str), NULL);
- }
- if (entry == NULL) {
- rb_raise(rb_eIndexError, "invalid index");
- }
- return str;
-}
-#else
-#define hist_set rb_f_notimplement
-#endif
-
-static VALUE
-hist_push(VALUE self, VALUE str)
-{
- OutputStringValue(str);
- add_history(RSTRING_PTR(str));
- return self;
-}
-
-static VALUE
-hist_push_method(int argc, VALUE *argv, VALUE self)
-{
- VALUE str;
-
- while (argc--) {
- str = *argv++;
- OutputStringValue(str);
- add_history(RSTRING_PTR(str));
- }
- return self;
-}
-
-static VALUE
-rb_remove_history(int index)
-{
-#ifdef HAVE_REMOVE_HISTORY
- HIST_ENTRY *entry;
- VALUE val;
-
- entry = remove_history(index);
- if (entry) {
- val = rb_locale_str_new_cstr(entry->line);
- free((void *) entry->line);
- free(entry);
- return val;
- }
- return Qnil;
-#else
- rb_notimplement();
-
- UNREACHABLE_RETURN(Qnil);
-#endif
-}
-
-static VALUE
-hist_pop(VALUE self)
-{
- if (history_length > 0) {
- return rb_remove_history(history_length - 1);
- } else {
- return Qnil;
- }
-}
-
-static VALUE
-hist_shift(VALUE self)
-{
- if (history_length > 0) {
- return rb_remove_history(0);
- } else {
- return Qnil;
- }
-}
-
-static VALUE
-hist_each(VALUE self)
-{
- HIST_ENTRY *entry;
- int i;
-
- RETURN_ENUMERATOR(self, 0, 0);
-
- for (i = 0; i < history_length; i++) {
- entry = history_get(history_get_offset_func(i));
- if (entry == NULL)
- break;
- rb_yield(rb_locale_str_new_cstr(entry->line));
- }
- return self;
-}
-
-static VALUE
-hist_length(VALUE self)
-{
- return INT2NUM(history_length);
-}
-
-static VALUE
-hist_empty_p(VALUE self)
-{
- return history_length == 0 ? Qtrue : Qfalse;
-}
-
-static VALUE
-hist_delete_at(VALUE self, VALUE index)
-{
- int i;
-
- i = NUM2INT(index);
- if (i < 0)
- i += history_length;
- if (i < 0 || i > history_length - 1) {
- rb_raise(rb_eIndexError, "invalid index");
- }
- return rb_remove_history(i);
-}
-
-#ifdef HAVE_CLEAR_HISTORY
-static VALUE
-hist_clear(VALUE self)
-{
- clear_history();
- return self;
-}
-#else
-#define hist_clear rb_f_notimplement
-#endif
-
-static VALUE
-filename_completion_proc_call(VALUE self, VALUE str)
-{
- VALUE result;
- char **matches;
- int i;
-
- matches = rl_completion_matches(StringValuePtr(str),
- rl_filename_completion_function);
- if (matches) {
- result = rb_ary_new();
- for (i = 0; matches[i]; i++) {
- rb_ary_push(result, rb_locale_str_new_cstr(matches[i]));
- free(matches[i]);
- }
- free(matches);
- if (RARRAY_LEN(result) >= 2)
- rb_ary_shift(result);
- }
- else {
- result = Qnil;
- }
- return result;
-}
-
-static VALUE
-username_completion_proc_call(VALUE self, VALUE str)
-{
- VALUE result;
- char **matches;
- int i;
-
- matches = rl_completion_matches(StringValuePtr(str),
- rl_username_completion_function);
- if (matches) {
- result = rb_ary_new();
- for (i = 0; matches[i]; i++) {
- rb_ary_push(result, rb_locale_str_new_cstr(matches[i]));
- free(matches[i]);
- }
- free(matches);
- if (RARRAY_LEN(result) >= 2)
- rb_ary_shift(result);
- }
- else {
- result = Qnil;
- }
- return result;
-}
-
-#ifdef HAVE_RL_CATCH_SIGNALS
-RUBY_EXTERN int rl_catch_signals;
-#endif
-#ifdef HAVE_RL_CLEAR_SIGNALS
-RUBY_EXTERN int rl_clear_signals(void);
-#endif
-
-#undef rb_intern
-void
-Init_readline(void)
-{
- VALUE history, fcomp, ucomp, version;
-
- /* Allow conditional parsing of the ~/.inputrc file. */
- rl_readline_name = (char *)"Ruby";
-
-#if defined HAVE_RL_GETC_FUNCTION
- /* libedit check rl_getc_function only when rl_initialize() is called, */
- /* and using_history() call rl_initialize(). */
- /* This assignment should be placed before using_history() */
- rl_getc_function = readline_getc;
-#elif defined HAVE_RL_EVENT_HOOK
- rl_event_hook = readline_event;
-#endif
-
- using_history();
-
- id_call = rb_intern("call");
- completion_proc = rb_intern(COMPLETION_PROC);
- completion_case_fold = rb_intern(COMPLETION_CASE_FOLD);
-#if defined(HAVE_RL_PRE_INPUT_HOOK)
- id_pre_input_hook = rb_intern("pre_input_hook");
-#endif
-#if defined(HAVE_RL_SPECIAL_PREFIXES)
- id_special_prefixes = rb_intern("special_prefixes");
-#endif
-#if defined HAVE_RL_CHAR_IS_QUOTED_P
- quoting_detection_proc = rb_intern(QUOTING_DETECTION_PROC);
-#endif
-
- mReadline = rb_define_module("Readline");
- rb_define_module_function(mReadline, "readline",
- readline_readline, -1);
- rb_define_singleton_method(mReadline, "input=",
- readline_s_set_input, 1);
- rb_define_singleton_method(mReadline, "output=",
- readline_s_set_output, 1);
- rb_define_singleton_method(mReadline, "completion_proc=",
- readline_s_set_completion_proc, 1);
- rb_define_singleton_method(mReadline, "completion_proc",
- readline_s_get_completion_proc, 0);
- rb_define_singleton_method(mReadline, "quoting_detection_proc=",
- readline_s_set_quoting_detection_proc, 1);
- rb_define_singleton_method(mReadline, "quoting_detection_proc",
- readline_s_get_quoting_detection_proc, 0);
- rb_define_singleton_method(mReadline, "completion_case_fold=",
- readline_s_set_completion_case_fold, 1);
- rb_define_singleton_method(mReadline, "completion_case_fold",
- readline_s_get_completion_case_fold, 0);
- rb_define_singleton_method(mReadline, "line_buffer",
- readline_s_get_line_buffer, 0);
- rb_define_singleton_method(mReadline, "point",
- readline_s_get_point, 0);
- rb_define_singleton_method(mReadline, "point=",
- readline_s_set_point, 1);
- rb_define_singleton_method(mReadline, "set_screen_size",
- readline_s_set_screen_size, 2);
- rb_define_singleton_method(mReadline, "get_screen_size",
- readline_s_get_screen_size, 0);
- rb_define_singleton_method(mReadline, "vi_editing_mode",
- readline_s_vi_editing_mode, 0);
- rb_define_singleton_method(mReadline, "vi_editing_mode?",
- readline_s_vi_editing_mode_p, 0);
- rb_define_singleton_method(mReadline, "emacs_editing_mode",
- readline_s_emacs_editing_mode, 0);
- rb_define_singleton_method(mReadline, "emacs_editing_mode?",
- readline_s_emacs_editing_mode_p, 0);
- rb_define_singleton_method(mReadline, "completion_append_character=",
- readline_s_set_completion_append_character, 1);
- rb_define_singleton_method(mReadline, "completion_append_character",
- readline_s_get_completion_append_character, 0);
- rb_define_singleton_method(mReadline, "completion_quote_character",
- readline_s_get_completion_quote_character, 0);
- rb_define_singleton_method(mReadline, "basic_word_break_characters=",
- readline_s_set_basic_word_break_characters, 1);
- rb_define_singleton_method(mReadline, "basic_word_break_characters",
- readline_s_get_basic_word_break_characters, 0);
- rb_define_singleton_method(mReadline, "completer_word_break_characters=",
- readline_s_set_completer_word_break_characters, 1);
- rb_define_singleton_method(mReadline, "completer_word_break_characters",
- readline_s_get_completer_word_break_characters, 0);
- rb_define_singleton_method(mReadline, "basic_quote_characters=",
- readline_s_set_basic_quote_characters, 1);
- rb_define_singleton_method(mReadline, "basic_quote_characters",
- readline_s_get_basic_quote_characters, 0);
- rb_define_singleton_method(mReadline, "completer_quote_characters=",
- readline_s_set_completer_quote_characters, 1);
- rb_define_singleton_method(mReadline, "completer_quote_characters",
- readline_s_get_completer_quote_characters, 0);
- rb_define_singleton_method(mReadline, "filename_quote_characters=",
- readline_s_set_filename_quote_characters, 1);
- rb_define_singleton_method(mReadline, "filename_quote_characters",
- readline_s_get_filename_quote_characters, 0);
- rb_define_singleton_method(mReadline, "refresh_line",
- readline_s_refresh_line, 0);
- rb_define_singleton_method(mReadline, "pre_input_hook=",
- readline_s_set_pre_input_hook, 1);
- rb_define_singleton_method(mReadline, "pre_input_hook",
- readline_s_get_pre_input_hook, 0);
- rb_define_singleton_method(mReadline, "insert_text",
- readline_s_insert_text, 1);
- rb_define_singleton_method(mReadline, "delete_text",
- readline_s_delete_text, -1);
- rb_define_singleton_method(mReadline, "redisplay",
- readline_s_redisplay, 0);
- rb_define_singleton_method(mReadline, "special_prefixes=",
- readline_s_set_special_prefixes, 1);
- rb_define_singleton_method(mReadline, "special_prefixes",
- readline_s_get_special_prefixes, 0);
-
-#if USE_INSERT_IGNORE_ESCAPE
- id_orig_prompt = rb_intern("orig_prompt");
- id_last_prompt = rb_intern("last_prompt");
-#endif
-
- history = rb_obj_alloc(rb_cObject);
- rb_extend_object(history, rb_mEnumerable);
- rb_define_singleton_method(history,"to_s", hist_to_s, 0);
- rb_define_singleton_method(history,"[]", hist_get, 1);
- rb_define_singleton_method(history,"[]=", hist_set, 2);
- rb_define_singleton_method(history,"<<", hist_push, 1);
- rb_define_singleton_method(history,"push", hist_push_method, -1);
- rb_define_singleton_method(history,"pop", hist_pop, 0);
- rb_define_singleton_method(history,"shift", hist_shift, 0);
- rb_define_singleton_method(history,"each", hist_each, 0);
- rb_define_singleton_method(history,"length", hist_length, 0);
- rb_define_singleton_method(history,"size", hist_length, 0);
- rb_define_singleton_method(history,"empty?", hist_empty_p, 0);
- rb_define_singleton_method(history,"delete_at", hist_delete_at, 1);
- rb_define_singleton_method(history,"clear", hist_clear, 0);
-
- /*
- * The history buffer. It extends Enumerable module, so it behaves
- * just like an array.
- * For example, gets the fifth content that the user input by
- * <code>HISTORY[4]</code>.
- */
- rb_define_const(mReadline, "HISTORY", history);
-
- fcomp = rb_obj_alloc(rb_cObject);
- rb_define_singleton_method(fcomp, "call",
- filename_completion_proc_call, 1);
- /*
- * The Object with the call method that is a completion for filename.
- * This is sets by Readline.completion_proc= method.
- */
- rb_define_const(mReadline, "FILENAME_COMPLETION_PROC", fcomp);
-
- ucomp = rb_obj_alloc(rb_cObject);
- rb_define_singleton_method(ucomp, "call",
- username_completion_proc_call, 1);
- /*
- * The Object with the call method that is a completion for usernames.
- * This is sets by Readline.completion_proc= method.
- */
- rb_define_const(mReadline, "USERNAME_COMPLETION_PROC", ucomp);
- history_get_offset_func = history_get_offset_history_base;
- history_replace_offset_func = history_get_offset_0;
-#if defined HAVE_RL_LIBRARY_VERSION
- version = rb_str_new_cstr(rl_library_version);
-#if defined HAVE_CLEAR_HISTORY || defined HAVE_REMOVE_HISTORY
- if (strncmp(rl_library_version, EDIT_LINE_LIBRARY_VERSION,
- strlen(EDIT_LINE_LIBRARY_VERSION)) == 0) {
- prepare_readline();
- add_history("1");
- if (history_get(history_get_offset_func(0)) == NULL) {
- history_get_offset_func = history_get_offset_0;
- }
-#ifdef HAVE_REPLACE_HISTORY_ENTRY
- if (replace_history_entry(0, "a", NULL) == NULL) {
- history_replace_offset_func = history_get_offset_history_base;
- }
-#endif
-#ifdef HAVE_CLEAR_HISTORY
- clear_history();
-#else
- {
- HIST_ENTRY *entry = remove_history(0);
- if (entry) {
- free((char *)entry->line);
- free(entry);
- }
- }
-#endif
- }
-#endif
-#else
- version = rb_str_new_cstr("2.0 or prior version");
-#endif
- /* Version string of GNU Readline or libedit. */
- rb_define_const(mReadline, "VERSION", version);
-
- rl_attempted_completion_function = readline_attempted_completion_function;
-#if defined(HAVE_RL_PRE_INPUT_HOOK)
- rl_pre_input_hook = (rl_hook_func_t *)readline_pre_input_hook;
-#endif
-#if defined HAVE_RL_CHAR_IS_QUOTED_P
- rl_char_is_quoted_p = &readline_char_is_quoted;
-#endif
-#ifdef HAVE_RL_CATCH_SIGNALS
- rl_catch_signals = 0;
-#endif
-#ifdef HAVE_RL_CLEAR_SIGNALS
- rl_clear_signals();
-#endif
-
- rb_gc_register_address(&readline_instream);
- rb_gc_register_address(&readline_outstream);
-}
-
-/*
- * Local variables:
- * indent-tabs-mode: nil
- * end:
- */
diff --git a/ext/ripper/README b/ext/ripper/README
index 2ae2470e13..70fa208920 100644
--- a/ext/ripper/README
+++ b/ext/ripper/README
@@ -13,7 +13,6 @@ Requirements
------------
* ruby 1.9 (support CVS HEAD only)
- * bison 1.28 or later (Other yaccs do not work)
Usage
-----
diff --git a/ext/ripper/depend b/ext/ripper/depend
index 856283e177..a18b67abe3 100644
--- a/ext/ripper/depend
+++ b/ext/ripper/depend
@@ -1,27 +1,26 @@
GEN = $(srcdir)/tools/generate.rb
SRC1 = $(top_srcdir)/parse.y
SRC2 = $(srcdir)/eventids2.c
+BISON = $(BASERUBY) $(top_srcdir)/tool/lrama/exe/lrama
.SUFFIXES: .y
-src: ripper.c eventids1.c eventids2table.c
+src: ripper.c ripper_init.c eventids1.c eventids1.h eventids2table.c
+ripper.c ripper_init.c eventids1.c eventids1.h eventids2table.c: depend
ripper.o: ripper.c
.y.c:
$(ECHO) compiling compiler $<
- $(Q) $(BISON) -t -v -oy.tab.c $<
- $(Q) sed -e "/^#/s!y\.tab\.c!$@!" -f $(top_srcdir)/tool/ytab.sed y.tab.c > $@
- @$(RM) y.tab.c
+ $(Q) $(BISON) -t -v -o$@ - $< < $<
all: check
static: check
ripper.y: $(srcdir)/tools/preproc.rb $(srcdir)/tools/dsl.rb $(top_srcdir)/parse.y $(top_srcdir)/defs/id.def
$(ECHO) extracting $@ from $(top_srcdir)/parse.y
- $(Q) $(RUBY) $(top_srcdir)/tool/id2token.rb $(top_srcdir)/parse.y > ripper.tmp.y
- $(Q) $(RUBY) $(srcdir)/tools/preproc.rb ripper.tmp.y --output=$@
- $(Q) $(RM) ripper.tmp.y
+ $(Q) $(RUBY) $(top_srcdir)/tool/id2token.rb $(top_srcdir)/parse.y | \
+ $(RUBY) $(srcdir)/tools/preproc.rb --output=$@ - ripper.y
check: .eventids2-check
@@ -30,6 +29,10 @@ check: .eventids2-check
$(Q) $(RUBY) $(GEN) --mode=check --ids1src=$(SRC1) --ids2src=$(SRC2)
@exit > $@
+eventids1.h: $(GEN) $(srcdir)/tools/dsl.rb $(SRC1)
+ $(ECHO) generating $@ from $(SRC1)
+ $(Q) $(RUBY) $(GEN) --mode=eventids1_h --ids1src=$(SRC1) --output=$@
+
eventids1.c: $(GEN) $(srcdir)/tools/dsl.rb $(SRC1)
$(ECHO) generating $@ from $(SRC1)
$(Q) $(RUBY) $(GEN) --mode=eventids1 --ids1src=$(SRC1) --output=$@
@@ -38,6 +41,10 @@ eventids2table.c: $(GEN) $(srcdir)/tools/dsl.rb $(SRC2)
$(ECHO) generating $@ from $(SRC2)
$(Q) $(RUBY) $(GEN) --mode=eventids2table --ids2src=$(SRC2) --output=$@
+ripper_init.c: $(srcdir)/ripper_init.c.tmpl ripper.y $(srcdir)/tools/preproc.rb $(top_srcdir)/internal/ruby_parser.h
+ $(ECHO) generating $@ from $(srcdir)/ripper_init.c.tmpl
+ $(Q) $(RUBY) $(srcdir)/tools/preproc.rb --output=$@ --template=$(srcdir)/ripper_init.c.tmpl $(top_srcdir)/internal/ruby_parser.h
+
# Entries for Ripper maintainer
preproc: ripper.E
@@ -46,10 +53,347 @@ ripper.E: ripper.c
$(Q) $(CC) -E $(INCFLAGS) $(CPPFLAGS) $< | $(RUBY) $(srcdir)/tools/strip.rb > $@
# AUTOGENERATED DEPENDENCIES START
+eventids1.o: $(RUBY_EXTCONF_H)
+eventids1.o: $(arch_hdrdir)/ruby/config.h
+eventids1.o: $(hdrdir)/ruby/assert.h
+eventids1.o: $(hdrdir)/ruby/backward.h
+eventids1.o: $(hdrdir)/ruby/backward/2/assume.h
+eventids1.o: $(hdrdir)/ruby/backward/2/attributes.h
+eventids1.o: $(hdrdir)/ruby/backward/2/bool.h
+eventids1.o: $(hdrdir)/ruby/backward/2/inttypes.h
+eventids1.o: $(hdrdir)/ruby/backward/2/limits.h
+eventids1.o: $(hdrdir)/ruby/backward/2/long_long.h
+eventids1.o: $(hdrdir)/ruby/backward/2/stdalign.h
+eventids1.o: $(hdrdir)/ruby/backward/2/stdarg.h
+eventids1.o: $(hdrdir)/ruby/defines.h
+eventids1.o: $(hdrdir)/ruby/intern.h
+eventids1.o: $(hdrdir)/ruby/internal/abi.h
+eventids1.o: $(hdrdir)/ruby/internal/anyargs.h
+eventids1.o: $(hdrdir)/ruby/internal/arithmetic.h
+eventids1.o: $(hdrdir)/ruby/internal/arithmetic/char.h
+eventids1.o: $(hdrdir)/ruby/internal/arithmetic/double.h
+eventids1.o: $(hdrdir)/ruby/internal/arithmetic/fixnum.h
+eventids1.o: $(hdrdir)/ruby/internal/arithmetic/gid_t.h
+eventids1.o: $(hdrdir)/ruby/internal/arithmetic/int.h
+eventids1.o: $(hdrdir)/ruby/internal/arithmetic/intptr_t.h
+eventids1.o: $(hdrdir)/ruby/internal/arithmetic/long.h
+eventids1.o: $(hdrdir)/ruby/internal/arithmetic/long_long.h
+eventids1.o: $(hdrdir)/ruby/internal/arithmetic/mode_t.h
+eventids1.o: $(hdrdir)/ruby/internal/arithmetic/off_t.h
+eventids1.o: $(hdrdir)/ruby/internal/arithmetic/pid_t.h
+eventids1.o: $(hdrdir)/ruby/internal/arithmetic/short.h
+eventids1.o: $(hdrdir)/ruby/internal/arithmetic/size_t.h
+eventids1.o: $(hdrdir)/ruby/internal/arithmetic/st_data_t.h
+eventids1.o: $(hdrdir)/ruby/internal/arithmetic/uid_t.h
+eventids1.o: $(hdrdir)/ruby/internal/assume.h
+eventids1.o: $(hdrdir)/ruby/internal/attr/alloc_size.h
+eventids1.o: $(hdrdir)/ruby/internal/attr/artificial.h
+eventids1.o: $(hdrdir)/ruby/internal/attr/cold.h
+eventids1.o: $(hdrdir)/ruby/internal/attr/const.h
+eventids1.o: $(hdrdir)/ruby/internal/attr/constexpr.h
+eventids1.o: $(hdrdir)/ruby/internal/attr/deprecated.h
+eventids1.o: $(hdrdir)/ruby/internal/attr/diagnose_if.h
+eventids1.o: $(hdrdir)/ruby/internal/attr/enum_extensibility.h
+eventids1.o: $(hdrdir)/ruby/internal/attr/error.h
+eventids1.o: $(hdrdir)/ruby/internal/attr/flag_enum.h
+eventids1.o: $(hdrdir)/ruby/internal/attr/forceinline.h
+eventids1.o: $(hdrdir)/ruby/internal/attr/format.h
+eventids1.o: $(hdrdir)/ruby/internal/attr/maybe_unused.h
+eventids1.o: $(hdrdir)/ruby/internal/attr/noalias.h
+eventids1.o: $(hdrdir)/ruby/internal/attr/nodiscard.h
+eventids1.o: $(hdrdir)/ruby/internal/attr/noexcept.h
+eventids1.o: $(hdrdir)/ruby/internal/attr/noinline.h
+eventids1.o: $(hdrdir)/ruby/internal/attr/nonnull.h
+eventids1.o: $(hdrdir)/ruby/internal/attr/noreturn.h
+eventids1.o: $(hdrdir)/ruby/internal/attr/packed_struct.h
+eventids1.o: $(hdrdir)/ruby/internal/attr/pure.h
+eventids1.o: $(hdrdir)/ruby/internal/attr/restrict.h
+eventids1.o: $(hdrdir)/ruby/internal/attr/returns_nonnull.h
+eventids1.o: $(hdrdir)/ruby/internal/attr/warning.h
+eventids1.o: $(hdrdir)/ruby/internal/attr/weakref.h
+eventids1.o: $(hdrdir)/ruby/internal/cast.h
+eventids1.o: $(hdrdir)/ruby/internal/compiler_is.h
+eventids1.o: $(hdrdir)/ruby/internal/compiler_is/apple.h
+eventids1.o: $(hdrdir)/ruby/internal/compiler_is/clang.h
+eventids1.o: $(hdrdir)/ruby/internal/compiler_is/gcc.h
+eventids1.o: $(hdrdir)/ruby/internal/compiler_is/intel.h
+eventids1.o: $(hdrdir)/ruby/internal/compiler_is/msvc.h
+eventids1.o: $(hdrdir)/ruby/internal/compiler_is/sunpro.h
+eventids1.o: $(hdrdir)/ruby/internal/compiler_since.h
+eventids1.o: $(hdrdir)/ruby/internal/config.h
+eventids1.o: $(hdrdir)/ruby/internal/constant_p.h
+eventids1.o: $(hdrdir)/ruby/internal/core.h
+eventids1.o: $(hdrdir)/ruby/internal/core/rarray.h
+eventids1.o: $(hdrdir)/ruby/internal/core/rbasic.h
+eventids1.o: $(hdrdir)/ruby/internal/core/rbignum.h
+eventids1.o: $(hdrdir)/ruby/internal/core/rclass.h
+eventids1.o: $(hdrdir)/ruby/internal/core/rdata.h
+eventids1.o: $(hdrdir)/ruby/internal/core/rfile.h
+eventids1.o: $(hdrdir)/ruby/internal/core/rhash.h
+eventids1.o: $(hdrdir)/ruby/internal/core/robject.h
+eventids1.o: $(hdrdir)/ruby/internal/core/rregexp.h
+eventids1.o: $(hdrdir)/ruby/internal/core/rstring.h
+eventids1.o: $(hdrdir)/ruby/internal/core/rstruct.h
+eventids1.o: $(hdrdir)/ruby/internal/core/rtypeddata.h
+eventids1.o: $(hdrdir)/ruby/internal/ctype.h
+eventids1.o: $(hdrdir)/ruby/internal/dllexport.h
+eventids1.o: $(hdrdir)/ruby/internal/dosish.h
+eventids1.o: $(hdrdir)/ruby/internal/error.h
+eventids1.o: $(hdrdir)/ruby/internal/eval.h
+eventids1.o: $(hdrdir)/ruby/internal/event.h
+eventids1.o: $(hdrdir)/ruby/internal/fl_type.h
+eventids1.o: $(hdrdir)/ruby/internal/gc.h
+eventids1.o: $(hdrdir)/ruby/internal/glob.h
+eventids1.o: $(hdrdir)/ruby/internal/globals.h
+eventids1.o: $(hdrdir)/ruby/internal/has/attribute.h
+eventids1.o: $(hdrdir)/ruby/internal/has/builtin.h
+eventids1.o: $(hdrdir)/ruby/internal/has/c_attribute.h
+eventids1.o: $(hdrdir)/ruby/internal/has/cpp_attribute.h
+eventids1.o: $(hdrdir)/ruby/internal/has/declspec_attribute.h
+eventids1.o: $(hdrdir)/ruby/internal/has/extension.h
+eventids1.o: $(hdrdir)/ruby/internal/has/feature.h
+eventids1.o: $(hdrdir)/ruby/internal/has/warning.h
+eventids1.o: $(hdrdir)/ruby/internal/intern/array.h
+eventids1.o: $(hdrdir)/ruby/internal/intern/bignum.h
+eventids1.o: $(hdrdir)/ruby/internal/intern/class.h
+eventids1.o: $(hdrdir)/ruby/internal/intern/compar.h
+eventids1.o: $(hdrdir)/ruby/internal/intern/complex.h
+eventids1.o: $(hdrdir)/ruby/internal/intern/cont.h
+eventids1.o: $(hdrdir)/ruby/internal/intern/dir.h
+eventids1.o: $(hdrdir)/ruby/internal/intern/enum.h
+eventids1.o: $(hdrdir)/ruby/internal/intern/enumerator.h
+eventids1.o: $(hdrdir)/ruby/internal/intern/error.h
+eventids1.o: $(hdrdir)/ruby/internal/intern/eval.h
+eventids1.o: $(hdrdir)/ruby/internal/intern/file.h
+eventids1.o: $(hdrdir)/ruby/internal/intern/hash.h
+eventids1.o: $(hdrdir)/ruby/internal/intern/io.h
+eventids1.o: $(hdrdir)/ruby/internal/intern/load.h
+eventids1.o: $(hdrdir)/ruby/internal/intern/marshal.h
+eventids1.o: $(hdrdir)/ruby/internal/intern/numeric.h
+eventids1.o: $(hdrdir)/ruby/internal/intern/object.h
+eventids1.o: $(hdrdir)/ruby/internal/intern/parse.h
+eventids1.o: $(hdrdir)/ruby/internal/intern/proc.h
+eventids1.o: $(hdrdir)/ruby/internal/intern/process.h
+eventids1.o: $(hdrdir)/ruby/internal/intern/random.h
+eventids1.o: $(hdrdir)/ruby/internal/intern/range.h
+eventids1.o: $(hdrdir)/ruby/internal/intern/rational.h
+eventids1.o: $(hdrdir)/ruby/internal/intern/re.h
+eventids1.o: $(hdrdir)/ruby/internal/intern/ruby.h
+eventids1.o: $(hdrdir)/ruby/internal/intern/select.h
+eventids1.o: $(hdrdir)/ruby/internal/intern/select/largesize.h
+eventids1.o: $(hdrdir)/ruby/internal/intern/signal.h
+eventids1.o: $(hdrdir)/ruby/internal/intern/sprintf.h
+eventids1.o: $(hdrdir)/ruby/internal/intern/string.h
+eventids1.o: $(hdrdir)/ruby/internal/intern/struct.h
+eventids1.o: $(hdrdir)/ruby/internal/intern/thread.h
+eventids1.o: $(hdrdir)/ruby/internal/intern/time.h
+eventids1.o: $(hdrdir)/ruby/internal/intern/variable.h
+eventids1.o: $(hdrdir)/ruby/internal/intern/vm.h
+eventids1.o: $(hdrdir)/ruby/internal/interpreter.h
+eventids1.o: $(hdrdir)/ruby/internal/iterator.h
+eventids1.o: $(hdrdir)/ruby/internal/memory.h
+eventids1.o: $(hdrdir)/ruby/internal/method.h
+eventids1.o: $(hdrdir)/ruby/internal/module.h
+eventids1.o: $(hdrdir)/ruby/internal/newobj.h
+eventids1.o: $(hdrdir)/ruby/internal/scan_args.h
+eventids1.o: $(hdrdir)/ruby/internal/special_consts.h
+eventids1.o: $(hdrdir)/ruby/internal/static_assert.h
+eventids1.o: $(hdrdir)/ruby/internal/stdalign.h
+eventids1.o: $(hdrdir)/ruby/internal/stdbool.h
+eventids1.o: $(hdrdir)/ruby/internal/symbol.h
+eventids1.o: $(hdrdir)/ruby/internal/value.h
+eventids1.o: $(hdrdir)/ruby/internal/value_type.h
+eventids1.o: $(hdrdir)/ruby/internal/variable.h
+eventids1.o: $(hdrdir)/ruby/internal/warning_push.h
+eventids1.o: $(hdrdir)/ruby/internal/xmalloc.h
+eventids1.o: $(hdrdir)/ruby/missing.h
+eventids1.o: $(hdrdir)/ruby/ruby.h
+eventids1.o: $(hdrdir)/ruby/st.h
+eventids1.o: $(hdrdir)/ruby/subst.h
+eventids1.o: eventids1.h
+eventids1.o: {$(VPATH)}eventids1.c
+eventids1.o: {$(VPATH)}eventids1.h
+eventids2.o: $(RUBY_EXTCONF_H)
+eventids2.o: $(arch_hdrdir)/ruby/config.h
+eventids2.o: $(hdrdir)/ruby/assert.h
+eventids2.o: $(hdrdir)/ruby/backward.h
+eventids2.o: $(hdrdir)/ruby/backward/2/assume.h
+eventids2.o: $(hdrdir)/ruby/backward/2/attributes.h
+eventids2.o: $(hdrdir)/ruby/backward/2/bool.h
+eventids2.o: $(hdrdir)/ruby/backward/2/inttypes.h
+eventids2.o: $(hdrdir)/ruby/backward/2/limits.h
+eventids2.o: $(hdrdir)/ruby/backward/2/long_long.h
+eventids2.o: $(hdrdir)/ruby/backward/2/stdalign.h
+eventids2.o: $(hdrdir)/ruby/backward/2/stdarg.h
+eventids2.o: $(hdrdir)/ruby/defines.h
+eventids2.o: $(hdrdir)/ruby/encoding.h
+eventids2.o: $(hdrdir)/ruby/intern.h
+eventids2.o: $(hdrdir)/ruby/internal/abi.h
+eventids2.o: $(hdrdir)/ruby/internal/anyargs.h
+eventids2.o: $(hdrdir)/ruby/internal/arithmetic.h
+eventids2.o: $(hdrdir)/ruby/internal/arithmetic/char.h
+eventids2.o: $(hdrdir)/ruby/internal/arithmetic/double.h
+eventids2.o: $(hdrdir)/ruby/internal/arithmetic/fixnum.h
+eventids2.o: $(hdrdir)/ruby/internal/arithmetic/gid_t.h
+eventids2.o: $(hdrdir)/ruby/internal/arithmetic/int.h
+eventids2.o: $(hdrdir)/ruby/internal/arithmetic/intptr_t.h
+eventids2.o: $(hdrdir)/ruby/internal/arithmetic/long.h
+eventids2.o: $(hdrdir)/ruby/internal/arithmetic/long_long.h
+eventids2.o: $(hdrdir)/ruby/internal/arithmetic/mode_t.h
+eventids2.o: $(hdrdir)/ruby/internal/arithmetic/off_t.h
+eventids2.o: $(hdrdir)/ruby/internal/arithmetic/pid_t.h
+eventids2.o: $(hdrdir)/ruby/internal/arithmetic/short.h
+eventids2.o: $(hdrdir)/ruby/internal/arithmetic/size_t.h
+eventids2.o: $(hdrdir)/ruby/internal/arithmetic/st_data_t.h
+eventids2.o: $(hdrdir)/ruby/internal/arithmetic/uid_t.h
+eventids2.o: $(hdrdir)/ruby/internal/assume.h
+eventids2.o: $(hdrdir)/ruby/internal/attr/alloc_size.h
+eventids2.o: $(hdrdir)/ruby/internal/attr/artificial.h
+eventids2.o: $(hdrdir)/ruby/internal/attr/cold.h
+eventids2.o: $(hdrdir)/ruby/internal/attr/const.h
+eventids2.o: $(hdrdir)/ruby/internal/attr/constexpr.h
+eventids2.o: $(hdrdir)/ruby/internal/attr/deprecated.h
+eventids2.o: $(hdrdir)/ruby/internal/attr/diagnose_if.h
+eventids2.o: $(hdrdir)/ruby/internal/attr/enum_extensibility.h
+eventids2.o: $(hdrdir)/ruby/internal/attr/error.h
+eventids2.o: $(hdrdir)/ruby/internal/attr/flag_enum.h
+eventids2.o: $(hdrdir)/ruby/internal/attr/forceinline.h
+eventids2.o: $(hdrdir)/ruby/internal/attr/format.h
+eventids2.o: $(hdrdir)/ruby/internal/attr/maybe_unused.h
+eventids2.o: $(hdrdir)/ruby/internal/attr/noalias.h
+eventids2.o: $(hdrdir)/ruby/internal/attr/nodiscard.h
+eventids2.o: $(hdrdir)/ruby/internal/attr/noexcept.h
+eventids2.o: $(hdrdir)/ruby/internal/attr/noinline.h
+eventids2.o: $(hdrdir)/ruby/internal/attr/nonnull.h
+eventids2.o: $(hdrdir)/ruby/internal/attr/noreturn.h
+eventids2.o: $(hdrdir)/ruby/internal/attr/packed_struct.h
+eventids2.o: $(hdrdir)/ruby/internal/attr/pure.h
+eventids2.o: $(hdrdir)/ruby/internal/attr/restrict.h
+eventids2.o: $(hdrdir)/ruby/internal/attr/returns_nonnull.h
+eventids2.o: $(hdrdir)/ruby/internal/attr/warning.h
+eventids2.o: $(hdrdir)/ruby/internal/attr/weakref.h
+eventids2.o: $(hdrdir)/ruby/internal/cast.h
+eventids2.o: $(hdrdir)/ruby/internal/compiler_is.h
+eventids2.o: $(hdrdir)/ruby/internal/compiler_is/apple.h
+eventids2.o: $(hdrdir)/ruby/internal/compiler_is/clang.h
+eventids2.o: $(hdrdir)/ruby/internal/compiler_is/gcc.h
+eventids2.o: $(hdrdir)/ruby/internal/compiler_is/intel.h
+eventids2.o: $(hdrdir)/ruby/internal/compiler_is/msvc.h
+eventids2.o: $(hdrdir)/ruby/internal/compiler_is/sunpro.h
+eventids2.o: $(hdrdir)/ruby/internal/compiler_since.h
+eventids2.o: $(hdrdir)/ruby/internal/config.h
+eventids2.o: $(hdrdir)/ruby/internal/constant_p.h
+eventids2.o: $(hdrdir)/ruby/internal/core.h
+eventids2.o: $(hdrdir)/ruby/internal/core/rarray.h
+eventids2.o: $(hdrdir)/ruby/internal/core/rbasic.h
+eventids2.o: $(hdrdir)/ruby/internal/core/rbignum.h
+eventids2.o: $(hdrdir)/ruby/internal/core/rclass.h
+eventids2.o: $(hdrdir)/ruby/internal/core/rdata.h
+eventids2.o: $(hdrdir)/ruby/internal/core/rfile.h
+eventids2.o: $(hdrdir)/ruby/internal/core/rhash.h
+eventids2.o: $(hdrdir)/ruby/internal/core/robject.h
+eventids2.o: $(hdrdir)/ruby/internal/core/rregexp.h
+eventids2.o: $(hdrdir)/ruby/internal/core/rstring.h
+eventids2.o: $(hdrdir)/ruby/internal/core/rstruct.h
+eventids2.o: $(hdrdir)/ruby/internal/core/rtypeddata.h
+eventids2.o: $(hdrdir)/ruby/internal/ctype.h
+eventids2.o: $(hdrdir)/ruby/internal/dllexport.h
+eventids2.o: $(hdrdir)/ruby/internal/dosish.h
+eventids2.o: $(hdrdir)/ruby/internal/encoding/coderange.h
+eventids2.o: $(hdrdir)/ruby/internal/encoding/ctype.h
+eventids2.o: $(hdrdir)/ruby/internal/encoding/encoding.h
+eventids2.o: $(hdrdir)/ruby/internal/encoding/pathname.h
+eventids2.o: $(hdrdir)/ruby/internal/encoding/re.h
+eventids2.o: $(hdrdir)/ruby/internal/encoding/sprintf.h
+eventids2.o: $(hdrdir)/ruby/internal/encoding/string.h
+eventids2.o: $(hdrdir)/ruby/internal/encoding/symbol.h
+eventids2.o: $(hdrdir)/ruby/internal/encoding/transcode.h
+eventids2.o: $(hdrdir)/ruby/internal/error.h
+eventids2.o: $(hdrdir)/ruby/internal/eval.h
+eventids2.o: $(hdrdir)/ruby/internal/event.h
+eventids2.o: $(hdrdir)/ruby/internal/fl_type.h
+eventids2.o: $(hdrdir)/ruby/internal/gc.h
+eventids2.o: $(hdrdir)/ruby/internal/glob.h
+eventids2.o: $(hdrdir)/ruby/internal/globals.h
+eventids2.o: $(hdrdir)/ruby/internal/has/attribute.h
+eventids2.o: $(hdrdir)/ruby/internal/has/builtin.h
+eventids2.o: $(hdrdir)/ruby/internal/has/c_attribute.h
+eventids2.o: $(hdrdir)/ruby/internal/has/cpp_attribute.h
+eventids2.o: $(hdrdir)/ruby/internal/has/declspec_attribute.h
+eventids2.o: $(hdrdir)/ruby/internal/has/extension.h
+eventids2.o: $(hdrdir)/ruby/internal/has/feature.h
+eventids2.o: $(hdrdir)/ruby/internal/has/warning.h
+eventids2.o: $(hdrdir)/ruby/internal/intern/array.h
+eventids2.o: $(hdrdir)/ruby/internal/intern/bignum.h
+eventids2.o: $(hdrdir)/ruby/internal/intern/class.h
+eventids2.o: $(hdrdir)/ruby/internal/intern/compar.h
+eventids2.o: $(hdrdir)/ruby/internal/intern/complex.h
+eventids2.o: $(hdrdir)/ruby/internal/intern/cont.h
+eventids2.o: $(hdrdir)/ruby/internal/intern/dir.h
+eventids2.o: $(hdrdir)/ruby/internal/intern/enum.h
+eventids2.o: $(hdrdir)/ruby/internal/intern/enumerator.h
+eventids2.o: $(hdrdir)/ruby/internal/intern/error.h
+eventids2.o: $(hdrdir)/ruby/internal/intern/eval.h
+eventids2.o: $(hdrdir)/ruby/internal/intern/file.h
+eventids2.o: $(hdrdir)/ruby/internal/intern/hash.h
+eventids2.o: $(hdrdir)/ruby/internal/intern/io.h
+eventids2.o: $(hdrdir)/ruby/internal/intern/load.h
+eventids2.o: $(hdrdir)/ruby/internal/intern/marshal.h
+eventids2.o: $(hdrdir)/ruby/internal/intern/numeric.h
+eventids2.o: $(hdrdir)/ruby/internal/intern/object.h
+eventids2.o: $(hdrdir)/ruby/internal/intern/parse.h
+eventids2.o: $(hdrdir)/ruby/internal/intern/proc.h
+eventids2.o: $(hdrdir)/ruby/internal/intern/process.h
+eventids2.o: $(hdrdir)/ruby/internal/intern/random.h
+eventids2.o: $(hdrdir)/ruby/internal/intern/range.h
+eventids2.o: $(hdrdir)/ruby/internal/intern/rational.h
+eventids2.o: $(hdrdir)/ruby/internal/intern/re.h
+eventids2.o: $(hdrdir)/ruby/internal/intern/ruby.h
+eventids2.o: $(hdrdir)/ruby/internal/intern/select.h
+eventids2.o: $(hdrdir)/ruby/internal/intern/select/largesize.h
+eventids2.o: $(hdrdir)/ruby/internal/intern/signal.h
+eventids2.o: $(hdrdir)/ruby/internal/intern/sprintf.h
+eventids2.o: $(hdrdir)/ruby/internal/intern/string.h
+eventids2.o: $(hdrdir)/ruby/internal/intern/struct.h
+eventids2.o: $(hdrdir)/ruby/internal/intern/thread.h
+eventids2.o: $(hdrdir)/ruby/internal/intern/time.h
+eventids2.o: $(hdrdir)/ruby/internal/intern/variable.h
+eventids2.o: $(hdrdir)/ruby/internal/intern/vm.h
+eventids2.o: $(hdrdir)/ruby/internal/interpreter.h
+eventids2.o: $(hdrdir)/ruby/internal/iterator.h
+eventids2.o: $(hdrdir)/ruby/internal/memory.h
+eventids2.o: $(hdrdir)/ruby/internal/method.h
+eventids2.o: $(hdrdir)/ruby/internal/module.h
+eventids2.o: $(hdrdir)/ruby/internal/newobj.h
+eventids2.o: $(hdrdir)/ruby/internal/scan_args.h
+eventids2.o: $(hdrdir)/ruby/internal/special_consts.h
+eventids2.o: $(hdrdir)/ruby/internal/static_assert.h
+eventids2.o: $(hdrdir)/ruby/internal/stdalign.h
+eventids2.o: $(hdrdir)/ruby/internal/stdbool.h
+eventids2.o: $(hdrdir)/ruby/internal/symbol.h
+eventids2.o: $(hdrdir)/ruby/internal/value.h
+eventids2.o: $(hdrdir)/ruby/internal/value_type.h
+eventids2.o: $(hdrdir)/ruby/internal/variable.h
+eventids2.o: $(hdrdir)/ruby/internal/warning_push.h
+eventids2.o: $(hdrdir)/ruby/internal/xmalloc.h
+eventids2.o: $(hdrdir)/ruby/missing.h
+eventids2.o: $(hdrdir)/ruby/onigmo.h
+eventids2.o: $(hdrdir)/ruby/oniguruma.h
+eventids2.o: $(hdrdir)/ruby/ruby.h
+eventids2.o: $(hdrdir)/ruby/st.h
+eventids2.o: $(hdrdir)/ruby/subst.h
+eventids2.o: $(top_srcdir)/internal.h
+eventids2.o: $(top_srcdir)/internal/static_assert.h
+eventids2.o: $(top_srcdir)/rubyparser.h
+eventids2.o: eventids2.c
+eventids2.o: eventids2.h
+eventids2.o: {$(VPATH)}eventids2table.c
+eventids2.o: {$(VPATH)}parse.h
ripper.o: $(RUBY_EXTCONF_H)
ripper.o: $(arch_hdrdir)/ruby/config.h
ripper.o: $(hdrdir)/ruby.h
ripper.o: $(hdrdir)/ruby/assert.h
+ripper.o: $(hdrdir)/ruby/atomic.h
ripper.o: $(hdrdir)/ruby/backward.h
ripper.o: $(hdrdir)/ruby/backward/2/assume.h
ripper.o: $(hdrdir)/ruby/backward/2/attributes.h
@@ -101,6 +445,7 @@ ripper.o: $(hdrdir)/ruby/internal/attr/noexcept.h
ripper.o: $(hdrdir)/ruby/internal/attr/noinline.h
ripper.o: $(hdrdir)/ruby/internal/attr/nonnull.h
ripper.o: $(hdrdir)/ruby/internal/attr/noreturn.h
+ripper.o: $(hdrdir)/ruby/internal/attr/packed_struct.h
ripper.o: $(hdrdir)/ruby/internal/attr/pure.h
ripper.o: $(hdrdir)/ruby/internal/attr/restrict.h
ripper.o: $(hdrdir)/ruby/internal/attr/returns_nonnull.h
@@ -169,7 +514,6 @@ ripper.o: $(hdrdir)/ruby/internal/intern/enumerator.h
ripper.o: $(hdrdir)/ruby/internal/intern/error.h
ripper.o: $(hdrdir)/ruby/internal/intern/eval.h
ripper.o: $(hdrdir)/ruby/internal/intern/file.h
-ripper.o: $(hdrdir)/ruby/internal/intern/gc.h
ripper.o: $(hdrdir)/ruby/internal/intern/hash.h
ripper.o: $(hdrdir)/ruby/internal/intern/io.h
ripper.o: $(hdrdir)/ruby/internal/intern/load.h
@@ -200,7 +544,6 @@ ripper.o: $(hdrdir)/ruby/internal/memory.h
ripper.o: $(hdrdir)/ruby/internal/method.h
ripper.o: $(hdrdir)/ruby/internal/module.h
ripper.o: $(hdrdir)/ruby/internal/newobj.h
-ripper.o: $(hdrdir)/ruby/internal/rgengc.h
ripper.o: $(hdrdir)/ruby/internal/scan_args.h
ripper.o: $(hdrdir)/ruby/internal/special_consts.h
ripper.o: $(hdrdir)/ruby/internal/static_assert.h
@@ -221,11 +564,18 @@ ripper.o: $(hdrdir)/ruby/regex.h
ripper.o: $(hdrdir)/ruby/ruby.h
ripper.o: $(hdrdir)/ruby/st.h
ripper.o: $(hdrdir)/ruby/subst.h
+ripper.o: $(hdrdir)/ruby/thread_native.h
ripper.o: $(hdrdir)/ruby/util.h
+ripper.o: $(hdrdir)/ruby/version.h
+ripper.o: $(top_srcdir)/ccan/check_type/check_type.h
+ripper.o: $(top_srcdir)/ccan/container_of/container_of.h
+ripper.o: $(top_srcdir)/ccan/list/list.h
+ripper.o: $(top_srcdir)/ccan/str/str.h
ripper.o: $(top_srcdir)/constant.h
ripper.o: $(top_srcdir)/id_table.h
ripper.o: $(top_srcdir)/internal.h
ripper.o: $(top_srcdir)/internal/array.h
+ripper.o: $(top_srcdir)/internal/basic_operators.h
ripper.o: $(top_srcdir)/internal/bignum.h
ripper.o: $(top_srcdir)/internal/bits.h
ripper.o: $(top_srcdir)/internal/compile.h
@@ -242,6 +592,7 @@ ripper.o: $(top_srcdir)/internal/numeric.h
ripper.o: $(top_srcdir)/internal/parse.h
ripper.o: $(top_srcdir)/internal/rational.h
ripper.o: $(top_srcdir)/internal/re.h
+ripper.o: $(top_srcdir)/internal/ruby_parser.h
ripper.o: $(top_srcdir)/internal/serial.h
ripper.o: $(top_srcdir)/internal/static_assert.h
ripper.o: $(top_srcdir)/internal/string.h
@@ -250,14 +601,25 @@ ripper.o: $(top_srcdir)/internal/thread.h
ripper.o: $(top_srcdir)/internal/variable.h
ripper.o: $(top_srcdir)/internal/vm.h
ripper.o: $(top_srcdir)/internal/warnings.h
+ripper.o: $(top_srcdir)/method.h
ripper.o: $(top_srcdir)/node.h
+ripper.o: $(top_srcdir)/parser_node.h
+ripper.o: $(top_srcdir)/parser_st.h
ripper.o: $(top_srcdir)/regenc.h
ripper.o: $(top_srcdir)/ruby_assert.h
+ripper.o: $(top_srcdir)/ruby_atomic.h
+ripper.o: $(top_srcdir)/rubyparser.h
ripper.o: $(top_srcdir)/shape.h
ripper.o: $(top_srcdir)/symbol.h
+ripper.o: $(top_srcdir)/thread_pthread.h
+ripper.o: $(top_srcdir)/vm_core.h
+ripper.o: $(top_srcdir)/vm_opts.h
ripper.o: ../../probes.h
+ripper.o: eventids1.h
ripper.o: eventids2.c
+ripper.o: eventids2.h
ripper.o: ripper.y
+ripper.o: ripper_init.h
ripper.o: {$(VPATH)}eventids1.c
ripper.o: {$(VPATH)}eventids2table.c
ripper.o: {$(VPATH)}id.h
@@ -265,4 +627,188 @@ ripper.o: {$(VPATH)}lex.c
ripper.o: {$(VPATH)}parse.h
ripper.o: {$(VPATH)}probes.dmyh
ripper.o: {$(VPATH)}ripper.c
+ripper_init.o: $(RUBY_EXTCONF_H)
+ripper_init.o: $(arch_hdrdir)/ruby/config.h
+ripper_init.o: $(hdrdir)/ruby/assert.h
+ripper_init.o: $(hdrdir)/ruby/backward.h
+ripper_init.o: $(hdrdir)/ruby/backward/2/assume.h
+ripper_init.o: $(hdrdir)/ruby/backward/2/attributes.h
+ripper_init.o: $(hdrdir)/ruby/backward/2/bool.h
+ripper_init.o: $(hdrdir)/ruby/backward/2/inttypes.h
+ripper_init.o: $(hdrdir)/ruby/backward/2/limits.h
+ripper_init.o: $(hdrdir)/ruby/backward/2/long_long.h
+ripper_init.o: $(hdrdir)/ruby/backward/2/stdalign.h
+ripper_init.o: $(hdrdir)/ruby/backward/2/stdarg.h
+ripper_init.o: $(hdrdir)/ruby/defines.h
+ripper_init.o: $(hdrdir)/ruby/encoding.h
+ripper_init.o: $(hdrdir)/ruby/intern.h
+ripper_init.o: $(hdrdir)/ruby/internal/abi.h
+ripper_init.o: $(hdrdir)/ruby/internal/anyargs.h
+ripper_init.o: $(hdrdir)/ruby/internal/arithmetic.h
+ripper_init.o: $(hdrdir)/ruby/internal/arithmetic/char.h
+ripper_init.o: $(hdrdir)/ruby/internal/arithmetic/double.h
+ripper_init.o: $(hdrdir)/ruby/internal/arithmetic/fixnum.h
+ripper_init.o: $(hdrdir)/ruby/internal/arithmetic/gid_t.h
+ripper_init.o: $(hdrdir)/ruby/internal/arithmetic/int.h
+ripper_init.o: $(hdrdir)/ruby/internal/arithmetic/intptr_t.h
+ripper_init.o: $(hdrdir)/ruby/internal/arithmetic/long.h
+ripper_init.o: $(hdrdir)/ruby/internal/arithmetic/long_long.h
+ripper_init.o: $(hdrdir)/ruby/internal/arithmetic/mode_t.h
+ripper_init.o: $(hdrdir)/ruby/internal/arithmetic/off_t.h
+ripper_init.o: $(hdrdir)/ruby/internal/arithmetic/pid_t.h
+ripper_init.o: $(hdrdir)/ruby/internal/arithmetic/short.h
+ripper_init.o: $(hdrdir)/ruby/internal/arithmetic/size_t.h
+ripper_init.o: $(hdrdir)/ruby/internal/arithmetic/st_data_t.h
+ripper_init.o: $(hdrdir)/ruby/internal/arithmetic/uid_t.h
+ripper_init.o: $(hdrdir)/ruby/internal/assume.h
+ripper_init.o: $(hdrdir)/ruby/internal/attr/alloc_size.h
+ripper_init.o: $(hdrdir)/ruby/internal/attr/artificial.h
+ripper_init.o: $(hdrdir)/ruby/internal/attr/cold.h
+ripper_init.o: $(hdrdir)/ruby/internal/attr/const.h
+ripper_init.o: $(hdrdir)/ruby/internal/attr/constexpr.h
+ripper_init.o: $(hdrdir)/ruby/internal/attr/deprecated.h
+ripper_init.o: $(hdrdir)/ruby/internal/attr/diagnose_if.h
+ripper_init.o: $(hdrdir)/ruby/internal/attr/enum_extensibility.h
+ripper_init.o: $(hdrdir)/ruby/internal/attr/error.h
+ripper_init.o: $(hdrdir)/ruby/internal/attr/flag_enum.h
+ripper_init.o: $(hdrdir)/ruby/internal/attr/forceinline.h
+ripper_init.o: $(hdrdir)/ruby/internal/attr/format.h
+ripper_init.o: $(hdrdir)/ruby/internal/attr/maybe_unused.h
+ripper_init.o: $(hdrdir)/ruby/internal/attr/noalias.h
+ripper_init.o: $(hdrdir)/ruby/internal/attr/nodiscard.h
+ripper_init.o: $(hdrdir)/ruby/internal/attr/noexcept.h
+ripper_init.o: $(hdrdir)/ruby/internal/attr/noinline.h
+ripper_init.o: $(hdrdir)/ruby/internal/attr/nonnull.h
+ripper_init.o: $(hdrdir)/ruby/internal/attr/noreturn.h
+ripper_init.o: $(hdrdir)/ruby/internal/attr/packed_struct.h
+ripper_init.o: $(hdrdir)/ruby/internal/attr/pure.h
+ripper_init.o: $(hdrdir)/ruby/internal/attr/restrict.h
+ripper_init.o: $(hdrdir)/ruby/internal/attr/returns_nonnull.h
+ripper_init.o: $(hdrdir)/ruby/internal/attr/warning.h
+ripper_init.o: $(hdrdir)/ruby/internal/attr/weakref.h
+ripper_init.o: $(hdrdir)/ruby/internal/cast.h
+ripper_init.o: $(hdrdir)/ruby/internal/compiler_is.h
+ripper_init.o: $(hdrdir)/ruby/internal/compiler_is/apple.h
+ripper_init.o: $(hdrdir)/ruby/internal/compiler_is/clang.h
+ripper_init.o: $(hdrdir)/ruby/internal/compiler_is/gcc.h
+ripper_init.o: $(hdrdir)/ruby/internal/compiler_is/intel.h
+ripper_init.o: $(hdrdir)/ruby/internal/compiler_is/msvc.h
+ripper_init.o: $(hdrdir)/ruby/internal/compiler_is/sunpro.h
+ripper_init.o: $(hdrdir)/ruby/internal/compiler_since.h
+ripper_init.o: $(hdrdir)/ruby/internal/config.h
+ripper_init.o: $(hdrdir)/ruby/internal/constant_p.h
+ripper_init.o: $(hdrdir)/ruby/internal/core.h
+ripper_init.o: $(hdrdir)/ruby/internal/core/rarray.h
+ripper_init.o: $(hdrdir)/ruby/internal/core/rbasic.h
+ripper_init.o: $(hdrdir)/ruby/internal/core/rbignum.h
+ripper_init.o: $(hdrdir)/ruby/internal/core/rclass.h
+ripper_init.o: $(hdrdir)/ruby/internal/core/rdata.h
+ripper_init.o: $(hdrdir)/ruby/internal/core/rfile.h
+ripper_init.o: $(hdrdir)/ruby/internal/core/rhash.h
+ripper_init.o: $(hdrdir)/ruby/internal/core/robject.h
+ripper_init.o: $(hdrdir)/ruby/internal/core/rregexp.h
+ripper_init.o: $(hdrdir)/ruby/internal/core/rstring.h
+ripper_init.o: $(hdrdir)/ruby/internal/core/rstruct.h
+ripper_init.o: $(hdrdir)/ruby/internal/core/rtypeddata.h
+ripper_init.o: $(hdrdir)/ruby/internal/ctype.h
+ripper_init.o: $(hdrdir)/ruby/internal/dllexport.h
+ripper_init.o: $(hdrdir)/ruby/internal/dosish.h
+ripper_init.o: $(hdrdir)/ruby/internal/encoding/coderange.h
+ripper_init.o: $(hdrdir)/ruby/internal/encoding/ctype.h
+ripper_init.o: $(hdrdir)/ruby/internal/encoding/encoding.h
+ripper_init.o: $(hdrdir)/ruby/internal/encoding/pathname.h
+ripper_init.o: $(hdrdir)/ruby/internal/encoding/re.h
+ripper_init.o: $(hdrdir)/ruby/internal/encoding/sprintf.h
+ripper_init.o: $(hdrdir)/ruby/internal/encoding/string.h
+ripper_init.o: $(hdrdir)/ruby/internal/encoding/symbol.h
+ripper_init.o: $(hdrdir)/ruby/internal/encoding/transcode.h
+ripper_init.o: $(hdrdir)/ruby/internal/error.h
+ripper_init.o: $(hdrdir)/ruby/internal/eval.h
+ripper_init.o: $(hdrdir)/ruby/internal/event.h
+ripper_init.o: $(hdrdir)/ruby/internal/fl_type.h
+ripper_init.o: $(hdrdir)/ruby/internal/gc.h
+ripper_init.o: $(hdrdir)/ruby/internal/glob.h
+ripper_init.o: $(hdrdir)/ruby/internal/globals.h
+ripper_init.o: $(hdrdir)/ruby/internal/has/attribute.h
+ripper_init.o: $(hdrdir)/ruby/internal/has/builtin.h
+ripper_init.o: $(hdrdir)/ruby/internal/has/c_attribute.h
+ripper_init.o: $(hdrdir)/ruby/internal/has/cpp_attribute.h
+ripper_init.o: $(hdrdir)/ruby/internal/has/declspec_attribute.h
+ripper_init.o: $(hdrdir)/ruby/internal/has/extension.h
+ripper_init.o: $(hdrdir)/ruby/internal/has/feature.h
+ripper_init.o: $(hdrdir)/ruby/internal/has/warning.h
+ripper_init.o: $(hdrdir)/ruby/internal/intern/array.h
+ripper_init.o: $(hdrdir)/ruby/internal/intern/bignum.h
+ripper_init.o: $(hdrdir)/ruby/internal/intern/class.h
+ripper_init.o: $(hdrdir)/ruby/internal/intern/compar.h
+ripper_init.o: $(hdrdir)/ruby/internal/intern/complex.h
+ripper_init.o: $(hdrdir)/ruby/internal/intern/cont.h
+ripper_init.o: $(hdrdir)/ruby/internal/intern/dir.h
+ripper_init.o: $(hdrdir)/ruby/internal/intern/enum.h
+ripper_init.o: $(hdrdir)/ruby/internal/intern/enumerator.h
+ripper_init.o: $(hdrdir)/ruby/internal/intern/error.h
+ripper_init.o: $(hdrdir)/ruby/internal/intern/eval.h
+ripper_init.o: $(hdrdir)/ruby/internal/intern/file.h
+ripper_init.o: $(hdrdir)/ruby/internal/intern/hash.h
+ripper_init.o: $(hdrdir)/ruby/internal/intern/io.h
+ripper_init.o: $(hdrdir)/ruby/internal/intern/load.h
+ripper_init.o: $(hdrdir)/ruby/internal/intern/marshal.h
+ripper_init.o: $(hdrdir)/ruby/internal/intern/numeric.h
+ripper_init.o: $(hdrdir)/ruby/internal/intern/object.h
+ripper_init.o: $(hdrdir)/ruby/internal/intern/parse.h
+ripper_init.o: $(hdrdir)/ruby/internal/intern/proc.h
+ripper_init.o: $(hdrdir)/ruby/internal/intern/process.h
+ripper_init.o: $(hdrdir)/ruby/internal/intern/random.h
+ripper_init.o: $(hdrdir)/ruby/internal/intern/range.h
+ripper_init.o: $(hdrdir)/ruby/internal/intern/rational.h
+ripper_init.o: $(hdrdir)/ruby/internal/intern/re.h
+ripper_init.o: $(hdrdir)/ruby/internal/intern/ruby.h
+ripper_init.o: $(hdrdir)/ruby/internal/intern/select.h
+ripper_init.o: $(hdrdir)/ruby/internal/intern/select/largesize.h
+ripper_init.o: $(hdrdir)/ruby/internal/intern/signal.h
+ripper_init.o: $(hdrdir)/ruby/internal/intern/sprintf.h
+ripper_init.o: $(hdrdir)/ruby/internal/intern/string.h
+ripper_init.o: $(hdrdir)/ruby/internal/intern/struct.h
+ripper_init.o: $(hdrdir)/ruby/internal/intern/thread.h
+ripper_init.o: $(hdrdir)/ruby/internal/intern/time.h
+ripper_init.o: $(hdrdir)/ruby/internal/intern/variable.h
+ripper_init.o: $(hdrdir)/ruby/internal/intern/vm.h
+ripper_init.o: $(hdrdir)/ruby/internal/interpreter.h
+ripper_init.o: $(hdrdir)/ruby/internal/iterator.h
+ripper_init.o: $(hdrdir)/ruby/internal/memory.h
+ripper_init.o: $(hdrdir)/ruby/internal/method.h
+ripper_init.o: $(hdrdir)/ruby/internal/module.h
+ripper_init.o: $(hdrdir)/ruby/internal/newobj.h
+ripper_init.o: $(hdrdir)/ruby/internal/scan_args.h
+ripper_init.o: $(hdrdir)/ruby/internal/special_consts.h
+ripper_init.o: $(hdrdir)/ruby/internal/static_assert.h
+ripper_init.o: $(hdrdir)/ruby/internal/stdalign.h
+ripper_init.o: $(hdrdir)/ruby/internal/stdbool.h
+ripper_init.o: $(hdrdir)/ruby/internal/symbol.h
+ripper_init.o: $(hdrdir)/ruby/internal/value.h
+ripper_init.o: $(hdrdir)/ruby/internal/value_type.h
+ripper_init.o: $(hdrdir)/ruby/internal/variable.h
+ripper_init.o: $(hdrdir)/ruby/internal/warning_push.h
+ripper_init.o: $(hdrdir)/ruby/internal/xmalloc.h
+ripper_init.o: $(hdrdir)/ruby/missing.h
+ripper_init.o: $(hdrdir)/ruby/onigmo.h
+ripper_init.o: $(hdrdir)/ruby/oniguruma.h
+ripper_init.o: $(hdrdir)/ruby/ruby.h
+ripper_init.o: $(hdrdir)/ruby/st.h
+ripper_init.o: $(hdrdir)/ruby/subst.h
+ripper_init.o: $(top_srcdir)/internal.h
+ripper_init.o: $(top_srcdir)/internal/array.h
+ripper_init.o: $(top_srcdir)/internal/imemo.h
+ripper_init.o: $(top_srcdir)/internal/parse.h
+ripper_init.o: $(top_srcdir)/internal/ruby_parser.h
+ripper_init.o: $(top_srcdir)/internal/serial.h
+ripper_init.o: $(top_srcdir)/internal/static_assert.h
+ripper_init.o: $(top_srcdir)/internal/vm.h
+ripper_init.o: $(top_srcdir)/node.h
+ripper_init.o: $(top_srcdir)/rubyparser.h
+ripper_init.o: eventids1.h
+ripper_init.o: eventids2.h
+ripper_init.o: ripper_init.h
+ripper_init.o: {$(VPATH)}parse.h
+ripper_init.o: {$(VPATH)}ripper_init.c
# AUTOGENERATED DEPENDENCIES END
diff --git a/ext/ripper/eventids2.c b/ext/ripper/eventids2.c
index 05687497ac..ac54955857 100644
--- a/ext/ripper/eventids2.c
+++ b/ext/ripper/eventids2.c
@@ -1,3 +1,11 @@
+#include "ruby/ruby.h"
+#include "rubyparser.h"
+#define YYSTYPE_IS_DECLARED
+#include "parse.h"
+#include "eventids2.h"
+#include "internal.h"
+#include "internal/static_assert.h"
+
typedef struct {
ID ripper_id_backref;
ID ripper_id_backtick;
@@ -57,7 +65,7 @@ static ripper_scanner_ids_t ripper_scanner_ids;
#include "eventids2table.c"
-static void
+void
ripper_init_eventids2(void)
{
#define set_id2(name) ripper_scanner_ids.ripper_id_##name = rb_intern_const("on_"#name)
@@ -118,7 +126,7 @@ ripper_init_eventids2(void)
STATIC_ASSERT(k__END___range, k__END__ < SHRT_MAX);
STATIC_ASSERT(ripper_scanner_ids_size, sizeof(ripper_scanner_ids) < SHRT_MAX);
-static ID
+ID
ripper_token2eventid(enum yytokentype tok)
{
#define O(member) (int)offsetof(ripper_scanner_ids_t, ripper_id_##member)+1
diff --git a/ext/ripper/eventids2.h b/ext/ripper/eventids2.h
new file mode 100644
index 0000000000..49e46432b9
--- /dev/null
+++ b/ext/ripper/eventids2.h
@@ -0,0 +1,8 @@
+#ifndef RIPPER_EVENTIDS2
+#define RIPPER_EVENTIDS2
+
+void ripper_init_eventids2(void);
+void ripper_init_eventids2_table(VALUE self);
+ID ripper_token2eventid(enum yytokentype tok);
+
+#endif /* RIPPER_EVENTIDS2 */
diff --git a/ext/ripper/extconf.rb b/ext/ripper/extconf.rb
index 65cb5030d3..c3c56c27c5 100644
--- a/ext/ripper/extconf.rb
+++ b/ext/ripper/extconf.rb
@@ -5,23 +5,14 @@ require 'mkmf'
require 'rbconfig'
def main
- yacc = ENV["YACC"] || "bison"
-
- unless find_executable(yacc)
- unless File.exist?('ripper.c') or File.exist?("#{$srcdir}/ripper.c")
- raise 'missing bison; abort'
- end
- end
- $objs = %w(ripper.o)
- $distcleanfiles.concat %w(ripper.y ripper.c eventids1.c eventids2table.c)
+ $objs = %w(eventids1.o eventids2.o ripper.o ripper_init.o)
+ $distcleanfiles.concat %w(ripper.y ripper.c eventids1.c eventids1.h eventids2table.c ripper_init.c)
$cleanfiles.concat %w(ripper.E ripper.output y.output .eventids2-check)
$defs << '-DRIPPER'
$defs << '-DRIPPER_DEBUG' if $debug
$VPATH << '$(topdir)' << '$(top_srcdir)'
$INCFLAGS << ' -I$(topdir) -I$(top_srcdir)'
- create_makefile 'ripper' do |conf|
- conf << "BISON = #{yacc}"
- end
+ create_makefile 'ripper'
end
main
diff --git a/ext/ripper/ripper_init.c.tmpl b/ext/ripper/ripper_init.c.tmpl
new file mode 100644
index 0000000000..5c1a4e5bb5
--- /dev/null
+++ b/ext/ripper/ripper_init.c.tmpl
@@ -0,0 +1,618 @@
+%# -*- c -*-
+#include "ruby/ruby.h"
+#include "ruby/encoding.h"
+#include "internal.h"
+#include "internal/imemo.h" /* needed by ruby_parser.h */
+#include "internal/parse.h"
+#include "internal/ruby_parser.h"
+#include "node.h"
+#include "rubyparser.h"
+#include "eventids1.h"
+#define YYSTYPE_IS_DECLARED
+#include "parse.h"
+#include "eventids2.h"
+#include "ripper_init.h"
+
+#define STR_NEW2(ptr) rb_enc_str_new((ptr),strlen(ptr),rb_ruby_parser_enc(p))
+#define RIPPER_VERSION "0.1.0"
+
+ID id_warn, id_warning, id_gets, id_assoc;
+
+struct ripper {
+ rb_parser_t *p;
+};
+
+static void
+ripper_parser_mark2(void *ptr)
+{
+ struct ripper *r = (struct ripper*)ptr;
+ if (r->p) ripper_parser_mark(r->p);
+}
+
+static void
+ripper_parser_free2(void *ptr)
+{
+ struct ripper *r = (struct ripper*)ptr;
+ if (r->p) ripper_parser_free(r->p);
+ xfree(r);
+}
+
+static size_t
+ripper_parser_memsize2(const void *ptr)
+{
+ struct ripper *r = (struct ripper*)ptr;
+ return (r->p) ? ripper_parser_memsize(r->p) : 0;
+}
+
+static const rb_data_type_t parser_data_type = {
+ "ripper",
+ {
+ ripper_parser_mark2,
+ ripper_parser_free2,
+ ripper_parser_memsize2,
+ },
+ 0, 0, RUBY_TYPED_FREE_IMMEDIATELY
+};
+
+ID
+ripper_get_id(VALUE v)
+{
+ NODE *nd;
+ if (!RB_TYPE_P(v, T_NODE)) return 0;
+ nd = (NODE *)v;
+ if (!nd_type_p(nd, NODE_RIPPER)) return 0;
+ return RNODE_RIPPER(nd)->nd_vid;
+}
+
+VALUE
+ripper_get_value(VALUE v)
+{
+ NODE *nd;
+ if (UNDEF_P(v)) return Qnil;
+ if (!RB_TYPE_P(v, T_NODE)) return v;
+ nd = (NODE *)v;
+ if (!nd_type_p(nd, NODE_RIPPER)) return Qnil;
+ return RNODE_RIPPER(nd)->nd_rval;
+}
+
+static VALUE
+ripper_lex_get_generic(struct parser_params *p, VALUE src)
+{
+ VALUE line = rb_funcallv_public(src, id_gets, 0, 0);
+ if (!NIL_P(line) && !RB_TYPE_P(line, T_STRING)) {
+ rb_raise(rb_eTypeError,
+ "gets returned %"PRIsVALUE" (expected String or nil)",
+ rb_obj_class(line));
+ }
+ return line;
+}
+
+void
+ripper_compile_error(struct parser_params *p, const char *fmt, ...)
+{
+ VALUE str;
+ va_list args;
+
+ va_start(args, fmt);
+ str = rb_vsprintf(fmt, args);
+ va_end(args);
+ rb_funcall(ripper_value(p), rb_intern("compile_error"), 1, str);
+ ripper_error(p);
+}
+
+static VALUE
+ripper_lex_io_get(struct parser_params *p, VALUE src)
+{
+ return rb_io_gets(src);
+}
+
+static VALUE
+ripper_s_allocate(VALUE klass)
+{
+ struct ripper *r;
+
+ VALUE self = TypedData_Make_Struct(klass, struct ripper,
+ &parser_data_type, r);
+
+#ifdef UNIVERSAL_PARSER
+ rb_parser_config_t *config;
+ config = rb_ruby_parser_config_new(ruby_xmalloc);
+ rb_parser_config_initialize(config);
+ r->p = rb_ruby_parser_allocate(config);
+#else
+ r->p = rb_ruby_ripper_parser_allocate();
+#endif
+ rb_ruby_parser_set_value(r->p, self);
+ return self;
+}
+
+static struct parser_params *
+ripper_parser_params(VALUE self, bool initialized)
+{
+ struct ripper *r;
+ struct parser_params *p;
+
+ TypedData_Get_Struct(self, struct ripper, &parser_data_type, r);
+ p = r->p;
+ if (initialized && !rb_ruby_ripper_initialized_p(p)) {
+ rb_raise(rb_eArgError, "method called for uninitialized object");
+ }
+ return p;
+}
+
+/*
+ * call-seq:
+ * ripper.error? -> Boolean
+ *
+ * Return true if parsed source has errors.
+ */
+static VALUE
+ripper_error_p(VALUE vparser)
+{
+ struct parser_params *p = ripper_parser_params(vparser, false);
+
+ return RBOOL(rb_ruby_parser_error_p(p));
+}
+
+/*
+ * call-seq:
+ * ripper.end_seen? -> Boolean
+ *
+ * Return true if parsed source ended by +\_\_END\_\_+.
+ */
+static VALUE
+ripper_parser_end_seen_p(VALUE vparser)
+{
+ struct parser_params *p = ripper_parser_params(vparser, false);
+
+ return RBOOL(rb_ruby_parser_end_seen_p(p));
+}
+
+/*
+ * call-seq:
+ * ripper.encoding -> encoding
+ *
+ * Return encoding of the source.
+ */
+static VALUE
+ripper_parser_encoding(VALUE vparser)
+{
+ struct parser_params *p = ripper_parser_params(vparser, false);
+
+ return rb_ruby_parser_encoding(p);
+}
+
+/*
+ * call-seq:
+ * ripper.yydebug -> true or false
+ *
+ * Get yydebug.
+ */
+static VALUE
+ripper_parser_get_yydebug(VALUE self)
+{
+ struct parser_params *p = ripper_parser_params(self, false);
+
+ return RBOOL(rb_ruby_parser_get_yydebug(p));
+}
+
+/*
+ * call-seq:
+ * ripper.yydebug = flag
+ *
+ * Set yydebug.
+ */
+static VALUE
+ripper_parser_set_yydebug(VALUE self, VALUE flag)
+{
+ struct parser_params *p = ripper_parser_params(self, false);
+
+ rb_ruby_parser_set_yydebug(p, RTEST(flag));
+ return flag;
+}
+
+/*
+ * call-seq:
+ * ripper.debug_output -> obj
+ *
+ * Get debug output.
+ */
+static VALUE
+ripper_parser_get_debug_output(VALUE self)
+{
+ struct parser_params *p = ripper_parser_params(self, false);
+
+ return rb_ruby_parser_debug_output(p);
+}
+
+/*
+ * call-seq:
+ * ripper.debug_output = obj
+ *
+ * Set debug output.
+ */
+static VALUE
+ripper_parser_set_debug_output(VALUE self, VALUE output)
+{
+ struct parser_params *p = ripper_parser_params(self, false);
+
+ rb_ruby_parser_set_debug_output(p, output);
+ return output;
+}
+
+#ifdef UNIVERSAL_PARSER
+struct dedent_string_arg {
+ struct parser_params *p;
+ VALUE input;
+ VALUE width;
+};
+
+static VALUE
+parser_dedent_string0(VALUE a)
+{
+ struct dedent_string_arg *arg = (void *)a;
+ int wid, col;
+
+ StringValue(arg->input);
+ wid = NUM2UINT(arg->width);
+ col = rb_ruby_ripper_dedent_string(arg->p, arg->input, wid);
+ return INT2NUM(col);
+}
+
+static VALUE
+parser_config_free(VALUE a)
+{
+ rb_parser_config_t *config = (void *)a;
+
+ rb_ruby_parser_config_free(config);
+ return Qnil;
+}
+#endif
+
+/*
+ * call-seq:
+ * Ripper.dedent_string(input, width) -> Integer
+ *
+ * USE OF RIPPER LIBRARY ONLY.
+ *
+ * Strips up to +width+ leading whitespaces from +input+,
+ * and returns the stripped column width.
+ */
+#ifdef UNIVERSAL_PARSER
+static VALUE
+parser_dedent_string(VALUE self, VALUE input, VALUE width)
+{
+ struct parser_params *p;
+ rb_parser_config_t *config;
+ struct dedent_string_arg args;
+
+ config = rb_ruby_parser_config_new(ruby_xmalloc);
+ rb_parser_config_initialize(config);
+ p = rb_ruby_parser_new(config);
+
+ args.p = p;
+ args.input = input;
+ args.width = width;
+ return rb_ensure(parser_dedent_string0, (VALUE)&args, parser_config_free, (VALUE)config);
+}
+#else
+static VALUE
+parser_dedent_string(VALUE self, VALUE input, VALUE width)
+{
+ int wid, col;
+
+ StringValue(input);
+ wid = NUM2UINT(width);
+ col = rb_ruby_ripper_dedent_string(0, input, wid);
+ return INT2NUM(col);
+}
+#endif
+
+/*
+ * call-seq:
+ * Ripper.new(src, filename="(ripper)", lineno=1) -> ripper
+ *
+ * Create a new Ripper object.
+ * _src_ must be a String, an IO, or an Object which has #gets method.
+ *
+ * This method does not starts parsing.
+ * See also Ripper#parse and Ripper.parse.
+ */
+static VALUE
+ripper_initialize(int argc, VALUE *argv, VALUE self)
+{
+ struct parser_params *p;
+ VALUE src, fname, lineno;
+ VALUE (*gets)(struct parser_params*,VALUE);
+ VALUE input, sourcefile_string;
+ const char *sourcefile;
+ int sourceline;
+
+ p = ripper_parser_params(self, false);
+ rb_scan_args(argc, argv, "12", &src, &fname, &lineno);
+ if (RB_TYPE_P(src, T_FILE)) {
+ gets = ripper_lex_io_get;
+ }
+ else if (rb_respond_to(src, id_gets)) {
+ gets = ripper_lex_get_generic;
+ }
+ else {
+ StringValue(src);
+ gets = rb_ruby_ripper_lex_get_str;
+ }
+ input = src;
+ if (NIL_P(fname)) {
+ fname = STR_NEW2("(ripper)");
+ OBJ_FREEZE(fname);
+ }
+ else {
+ StringValueCStr(fname);
+ fname = rb_str_new_frozen(fname);
+ }
+ rb_ruby_ripper_parser_initialize(p);
+
+ sourcefile_string = fname;
+ sourcefile = RSTRING_PTR(fname);
+ sourceline = NIL_P(lineno) ? 0 : NUM2INT(lineno) - 1;
+
+ rb_ruby_parser_ripper_initialize(p, gets, input, sourcefile_string, sourcefile, sourceline);
+
+ return Qnil;
+}
+
+static VALUE
+ripper_parse0(VALUE vparser)
+{
+ struct parser_params *p = ripper_parser_params(vparser, false);
+
+ rb_ruby_ripper_parse0(p);
+ return rb_ruby_parser_result(p);
+}
+
+static VALUE
+ripper_ensure(VALUE vparser)
+{
+ struct parser_params *p = ripper_parser_params(vparser, false);
+
+ rb_ruby_parser_set_parsing_thread(p, Qnil);
+ return Qnil;
+}
+
+/*
+ * call-seq:
+ * ripper.parse
+ *
+ * Start parsing and returns the value of the root action.
+ */
+static VALUE
+ripper_parse(VALUE self)
+{
+ struct parser_params *p = ripper_parser_params(self, true);
+ VALUE result;
+
+ if (!NIL_P(rb_ruby_parser_parsing_thread(p))) {
+ if (rb_ruby_parser_parsing_thread(p) == rb_thread_current())
+ rb_raise(rb_eArgError, "Ripper#parse is not reentrant");
+ else
+ rb_raise(rb_eArgError, "Ripper#parse is not multithread-safe");
+ }
+ rb_ruby_parser_set_parsing_thread(p, rb_thread_current());
+ result = rb_ensure(ripper_parse0, self, ripper_ensure, self);
+ RB_GC_GUARD(self);
+
+ return result;
+}
+
+/*
+ * call-seq:
+ * ripper.column -> Integer
+ *
+ * Return column number of current parsing line.
+ * This number starts from 0.
+ */
+static VALUE
+ripper_column(VALUE self)
+{
+ struct parser_params *p = ripper_parser_params(self, true);
+ long col;
+
+ if (NIL_P(rb_ruby_parser_parsing_thread(p))) return Qnil;
+ col = rb_ruby_ripper_column(p);
+ return LONG2NUM(col);
+}
+
+/*
+ * call-seq:
+ * ripper.filename -> String
+ *
+ * Return current parsing filename.
+ */
+static VALUE
+ripper_filename(VALUE self)
+{
+ struct parser_params *p = ripper_parser_params(self, true);
+
+ return rb_ruby_parser_ruby_sourcefile_string(p);
+}
+
+/*
+ * call-seq:
+ * ripper.lineno -> Integer
+ *
+ * Return line number of current parsing line.
+ * This number starts from 1.
+ */
+static VALUE
+ripper_lineno(VALUE self)
+{
+ struct parser_params *p = ripper_parser_params(self, true);
+
+ if (NIL_P(rb_ruby_parser_parsing_thread(p))) return Qnil;
+ return INT2NUM(rb_ruby_parser_ruby_sourceline(p));
+}
+
+/*
+ * call-seq:
+ * ripper.state -> Integer
+ *
+ * Return scanner state of current token.
+ */
+static VALUE
+ripper_state(VALUE self)
+{
+ struct parser_params *p = ripper_parser_params(self, true);
+
+ if (NIL_P(rb_ruby_parser_parsing_thread(p))) return Qnil;
+ return INT2NUM(rb_ruby_parser_lex_state(p));
+}
+
+/*
+ * call-seq:
+ * ripper.token -> String
+ *
+ * Return the current token string.
+ */
+static VALUE
+ripper_token(VALUE self)
+{
+ struct parser_params *p = ripper_parser_params(self, true);
+ long pos, len;
+
+ if (NIL_P(rb_ruby_parser_parsing_thread(p))) return Qnil;
+ pos = rb_ruby_ripper_column(p);
+ len = rb_ruby_ripper_token_len(p);
+ return rb_str_subseq(rb_ruby_ripper_lex_lastline(p), pos, len);
+}
+
+#ifdef RIPPER_DEBUG
+/* :nodoc: */
+static VALUE
+ripper_assert_Qundef(VALUE self, VALUE obj, VALUE msg)
+{
+ StringValue(msg);
+ if (UNDEF_P(obj)) {
+ rb_raise(rb_eArgError, "%"PRIsVALUE, msg);
+ }
+ return Qnil;
+}
+
+/* :nodoc: */
+static VALUE
+ripper_raw_value(VALUE self, VALUE obj)
+{
+ return ULONG2NUM(obj);
+}
+#endif
+
+#ifdef UNIVERSAL_PARSER
+struct lex_state_name_arg {
+ struct parser_params *p;
+ VALUE state;
+};
+
+static VALUE
+lex_state_name0(VALUE a)
+{
+ struct lex_state_name_arg *arg = (void *)a;
+
+ return rb_ruby_ripper_lex_state_name(arg->p, NUM2INT(arg->state));
+}
+#endif
+
+/*
+ * call-seq:
+ * Ripper.lex_state_name(integer) -> string
+ *
+ * Returns a string representation of lex_state.
+ */
+#ifdef UNIVERSAL_PARSER
+static VALUE
+ripper_lex_state_name(VALUE self, VALUE state)
+{
+ struct parser_params *p;
+ rb_parser_config_t *config;
+ struct lex_state_name_arg args;
+
+ config = rb_ruby_parser_config_new(ruby_xmalloc);
+ rb_parser_config_initialize(config);
+ p = rb_ruby_parser_new(config);
+
+ args.p = p;
+ args.state = state;
+
+ return rb_ensure(lex_state_name0, (VALUE)&args, parser_config_free, (VALUE)config);
+}
+#else
+static VALUE
+ripper_lex_state_name(VALUE self, VALUE state)
+{
+ return rb_ruby_ripper_lex_state_name(0, NUM2INT(state));
+}
+#endif
+
+void
+Init_ripper(void)
+{
+ ripper_init_eventids1();
+ ripper_init_eventids2();
+ id_warn = rb_intern_const("warn");
+ id_warning = rb_intern_const("warning");
+ id_gets = rb_intern_const("gets");
+ id_assoc = rb_intern_const("=>");
+
+ InitVM(ripper);
+}
+
+void
+InitVM_ripper(void)
+{
+ VALUE Ripper;
+
+ Ripper = rb_define_class("Ripper", rb_cObject);
+ /* version of Ripper */
+ rb_define_const(Ripper, "Version", rb_usascii_str_new2(RIPPER_VERSION));
+ rb_define_alloc_func(Ripper, ripper_s_allocate);
+ rb_define_method(Ripper, "initialize", ripper_initialize, -1);
+ rb_define_method(Ripper, "parse", ripper_parse, 0);
+ rb_define_method(Ripper, "column", ripper_column, 0);
+ rb_define_method(Ripper, "filename", ripper_filename, 0);
+ rb_define_method(Ripper, "lineno", ripper_lineno, 0);
+ rb_define_method(Ripper, "state", ripper_state, 0);
+ rb_define_method(Ripper, "token", ripper_token, 0);
+ rb_define_method(Ripper, "end_seen?", ripper_parser_end_seen_p, 0);
+ rb_define_method(Ripper, "encoding", ripper_parser_encoding, 0);
+ rb_define_method(Ripper, "yydebug", ripper_parser_get_yydebug, 0);
+ rb_define_method(Ripper, "yydebug=", ripper_parser_set_yydebug, 1);
+ rb_define_method(Ripper, "debug_output", ripper_parser_get_debug_output, 0);
+ rb_define_method(Ripper, "debug_output=", ripper_parser_set_debug_output, 1);
+ rb_define_method(Ripper, "error?", ripper_error_p, 0);
+#ifdef RIPPER_DEBUG
+ rb_define_method(Ripper, "assert_Qundef", ripper_assert_Qundef, 2);
+ rb_define_method(Ripper, "rawVALUE", ripper_raw_value, 1);
+ rb_define_method(Ripper, "validate_object", ripper_validate_object, 1);
+#endif
+
+ rb_define_singleton_method(Ripper, "dedent_string", parser_dedent_string, 2);
+ rb_define_private_method(Ripper, "dedent_string", parser_dedent_string, 2);
+
+ rb_define_singleton_method(Ripper, "lex_state_name", ripper_lex_state_name, 1);
+
+<% @exprs.each do |expr, desc| -%>
+ /* <%=desc%> */
+ rb_define_const(Ripper, "<%=expr%>", INT2NUM(<%=expr%>));
+<% end %>
+ ripper_init_eventids1_table(Ripper);
+ ripper_init_eventids2_table(Ripper);
+
+# if 0
+ /* Hack to let RDoc document SCRIPT_LINES__ */
+
+ /*
+ * When a Hash is assigned to +SCRIPT_LINES__+ the contents of files loaded
+ * after the assignment will be added as an Array of lines with the file
+ * name as the key.
+ */
+ rb_define_global_const("SCRIPT_LINES__", Qnil);
+#endif
+
+}
diff --git a/ext/ripper/ripper_init.h b/ext/ripper/ripper_init.h
new file mode 100644
index 0000000000..82ff13b95f
--- /dev/null
+++ b/ext/ripper/ripper_init.h
@@ -0,0 +1,8 @@
+#ifndef RIPPER_INIT_H
+#define RIPPER_INIT_H
+
+VALUE ripper_get_value(VALUE v);
+ID ripper_get_id(VALUE v);
+PRINTF_ARGS(void ripper_compile_error(struct parser_params*, const char *fmt, ...), 2, 3);
+
+#endif /* RIPPER_INIT_H */
diff --git a/ext/ripper/tools/dsl.rb b/ext/ripper/tools/dsl.rb
index 49ff51711f..6d662b3fb8 100644
--- a/ext/ripper/tools/dsl.rb
+++ b/ext/ripper/tools/dsl.rb
@@ -6,11 +6,18 @@
# v1 = dispatch0(stmts_new);
# v2 = dispatch0(void_stmt);
# $$ = dispatch2(stmts_add, v1, v2);
-
-$dollar = "$$"
-alias $$ $dollar
+#
+# - The code must be a single line.
+#
+# - The code is basically Ruby code, even if it appears like in C and
+# the result will be processed as C. e.g., comments need to be in
+# Ruby style.
class DSL
+ TAG_PATTERN = /(?><[a-zA-Z0-9_]+>)/.source
+ NAME_PATTERN = /(?>\$|\d+|[a-zA-Z_][a-zA-Z0-9_]*|\[[a-zA-Z_.][-a-zA-Z0-9_.]*\])(?>(?:\.|->)[a-zA-Z_][a-zA-Z0-9_]*)*/.source
+ NOT_REF_PATTERN = /(?>\#.*|[^\"$@]*|"(?>\\.|[^\"])*")/.source
+
def initialize(code, options)
@events = {}
@error = options.include?("error")
@@ -18,19 +25,15 @@ class DSL
if options.include?("final")
@final = "p->result"
else
- @final = (options.grep(/\A\$(?:\$|\d+)\z/)[0] || "$$")
+ @final = (options.grep(/\A\$#{NAME_PATTERN}\z/o)[0] || "$$")
end
@vars = 0
- # create $1 == "$1", $2 == "$2", ...
- s = (1..20).map {|n| "$#{n}"}
- re = Array.new(s.size, "([^\0]+)")
- /#{re.join("\0")}/ =~ s.join("\0")
-
# struct parser_params *p
p = p = "p"
@code = ""
+ code = code.gsub(%r[\G#{NOT_REF_PATTERN}\K[$@]#{TAG_PATTERN}?#{NAME_PATTERN}]o, '"\&"')
@last_value = eval(code)
end
diff --git a/ext/ripper/tools/generate.rb b/ext/ripper/tools/generate.rb
index 883e6ef2df..bb64d2fe8b 100644
--- a/ext/ripper/tools/generate.rb
+++ b/ext/ripper/tools/generate.rb
@@ -11,7 +11,7 @@ def main
parser = @parser = OptionParser.new
parser.banner = "Usage: #{File.basename($0)} --mode=MODE [--ids1src=PATH] [--ids2src=PATH] [--output=PATH]"
- parser.on('--mode=MODE', 'check, eventids1, or eventids2table.') {|m|
+ parser.on('--mode=MODE', 'check, eventids1_h, eventids1, or eventids2table.') {|m|
mode = m
}
parser.on('--ids1src=PATH', 'A source file of event-IDs 1 (parse.y).') {|path|
@@ -45,6 +45,9 @@ def main
abort "event crash: #{common.join(' ')}"
end
exit 0
+ when 'eventids1_h'
+ usage 'no --ids1src' unless ids1src
+ result = generate_eventids1_h(read_ids1(ids1src))
when 'eventids1'
usage 'no --ids1src' unless ids1src
result = generate_eventids1(read_ids1(ids1src))
@@ -67,19 +70,35 @@ def usage(msg)
exit false
end
-def generate_eventids1(ids)
+def generate_eventids1_h(ids)
buf = "".dup
- buf << %Q[static struct {\n]
+ buf << %Q[#ifndef RIPPER_EVENTIDS1\n]
+ buf << %Q[#define RIPPER_EVENTIDS1\n]
+ buf << %Q[\n]
+ buf << %Q[void ripper_init_eventids1(void);\n]
+ buf << %Q[void ripper_init_eventids1_table(VALUE self);\n]
+ buf << %Q[\n]
+ buf << %Q[struct ripper_parser_ids {\n]
ids.each do |id, arity|
buf << %Q[ ID id_#{id};\n]
end
- buf << %Q[} ripper_parser_ids;\n]
+ buf << %Q[};\n]
buf << %Q[\n]
ids.each do |id, arity|
buf << %Q[#define ripper_id_#{id} ripper_parser_ids.id_#{id}\n]
end
+ buf << %Q[#endif /* RIPPER_EVENTIDS1 */\n]
buf << %Q[\n]
- buf << %Q[static void\n]
+end
+
+def generate_eventids1(ids)
+ buf = "".dup
+ buf << %Q[#include "ruby/ruby.h"\n]
+ buf << %Q[#include "eventids1.h"\n]
+ buf << %Q[\n]
+ buf << %Q[struct ripper_parser_ids ripper_parser_ids;\n]
+ buf << %Q[\n]
+ buf << %Q[void\n]
buf << %Q[ripper_init_eventids1(void)\n]
buf << %Q[{\n]
buf << %Q[#define set_id1(name) ripper_id_##name = rb_intern_const("on_"#name)\n]
@@ -88,7 +107,9 @@ def generate_eventids1(ids)
end
buf << %Q[}\n]
buf << %Q[\n]
- buf << %Q[static void\n]
+ buf << %Q[#define intern_sym(name) ID2SYM(rb_intern_const(name))\n]
+ buf << %Q[\n]
+ buf << %Q[void\n]
buf << %Q[ripper_init_eventids1_table(VALUE self)\n]
buf << %Q[{\n]
buf << %Q[ VALUE h = rb_hash_new();\n]
@@ -102,7 +123,11 @@ end
def generate_eventids2_table(ids)
buf = "".dup
- buf << %Q[static void\n]
+ buf << %Q[#include "ruby/ruby.h"\n]
+ buf << %Q[\n]
+ buf << %Q[#define intern_sym(name) ID2SYM(rb_intern_const(name))\n]
+ buf << %Q[\n]
+ buf << %Q[void\n]
buf << %Q[ripper_init_eventids2_table(VALUE self)\n]
buf << %Q[{\n]
buf << %Q[ VALUE h = rb_hash_new();\n]
diff --git a/ext/ripper/tools/preproc.rb b/ext/ripper/tools/preproc.rb
index cd85a5da61..a0d5e79d7d 100644
--- a/ext/ripper/tools/preproc.rb
+++ b/ext/ripper/tools/preproc.rb
@@ -5,11 +5,15 @@ require 'optparse'
def main
output = nil
+ template = nil
parser = OptionParser.new
- parser.banner = "Usage: #{File.basename($0)} [--output=PATH] <parse.y>"
+ parser.banner = "Usage: #{File.basename($0)} [--output=PATH] [--template=PATH] <parse.y>"
parser.on('--output=PATH', 'An output file.') {|path|
output = path
}
+ parser.on('--template=PATH', 'An template file.') {|path|
+ template = path
+ }
parser.on('--help', 'Prints this message and quit.') {
puts parser.help
exit true
@@ -17,28 +21,36 @@ def main
begin
parser.parse!
rescue OptionParser::ParseError => err
- $stderr.puts err.message
- $stderr.puts parser.help
- exit false
- end
- unless ARGV.size == 1
- abort "wrong number of arguments (#{ARGV.size} for 1)"
+ warn err.message
+ abort parser.help
end
out = "".dup
- File.open(ARGV[0]) {|f|
- prelude f, out
- grammar f, out
- usercode f, out
- }
- if output
- File.open(output, 'w') {|f|
- f.write out
+ if ARGV[0] == "-"
+ unless ARGV.size == 2
+ abort "wrong number of arguments (#{ARGV.size} for 2)"
+ end
+ process STDIN, out, ARGV[1], template
+ else
+ unless ARGV.size == 1
+ abort "wrong number of arguments (#{ARGV.size} for 1)"
+ end
+ File.open(ARGV[0]) {|f|
+ process f, out, ARGV[0], template
}
+ end
+ if output
+ File.write(output, out)
else
print out
end
end
+def process(f, out, path, template)
+ prelude f, out
+ grammar f, out
+ usercode f, out, path, template
+end
+
def prelude(f, out)
@exprs = {}
lex_state_def = false
@@ -47,10 +59,9 @@ def prelude(f, out)
when /\A%%/
out << "%%\n"
return
- when /\A%token/, /\A} <node>/
- out << line.sub(/<\w+>/, '<val>')
- when /\A%type/
- out << line.sub(/<\w+>/, '<val>')
+ when /\A%token/, /\A%type/, /\A} <node(?>_\w+)?>/
+ # types in %union which have corresponding set_yylval_* macro.
+ out << line.sub(/<(?:node(?>_\w+)?|num|id)>/, '<val>')
when /^enum lex_state_(?:bits|e) \{/
lex_state_def = true
out << line
@@ -95,13 +106,26 @@ def grammar(f, out)
end
end
-def usercode(f, out)
+def usercode(f, out, path, template)
require 'erb'
+ lineno = nil
+ src = nil
compiler = ERB::Compiler.new('%-')
compiler.put_cmd = compiler.insert_cmd = "out.<<"
- lineno = f.lineno
- src, = compiler.compile(f.read)
- eval(src, binding, f.path, lineno)
+
+ if template
+ File.open(template) do |f|
+ out.clear
+ lineno = f.lineno
+ src, = compiler.compile(f.read)
+ path = template
+ end
+ else
+ lineno = f.lineno
+ src, = compiler.compile(f.read)
+ end
+
+ eval(src, binding, path, lineno)
end
main
diff --git a/ext/socket/ancdata.c b/ext/socket/ancdata.c
index 7406177de2..6ef040b692 100644
--- a/ext/socket/ancdata.c
+++ b/ext/socket/ancdata.c
@@ -1555,6 +1555,10 @@ bsock_recvmsg_internal(VALUE sock,
ss = rb_recvmsg(fptr->fd, &mh, flags);
+ if (ss == 0 && !rsock_is_dgram(fptr)) {
+ return Qnil;
+ }
+
if (ss == -1) {
int e;
if (!nonblock && rb_io_maybe_wait_readable(errno, fptr->self, RUBY_IO_TIMEOUT_DEFAULT)) {
diff --git a/ext/socket/depend b/ext/socket/depend
index 28c5540cd6..3db153bb1c 100644
--- a/ext/socket/depend
+++ b/ext/socket/depend
@@ -13,6 +13,7 @@ constdefs.c: constdefs.h
ancdata.o: $(RUBY_EXTCONF_H)
ancdata.o: $(arch_hdrdir)/ruby/config.h
ancdata.o: $(hdrdir)/ruby/assert.h
+ancdata.o: $(hdrdir)/ruby/atomic.h
ancdata.o: $(hdrdir)/ruby/backward.h
ancdata.o: $(hdrdir)/ruby/backward/2/assume.h
ancdata.o: $(hdrdir)/ruby/backward/2/attributes.h
@@ -65,6 +66,7 @@ ancdata.o: $(hdrdir)/ruby/internal/attr/noexcept.h
ancdata.o: $(hdrdir)/ruby/internal/attr/noinline.h
ancdata.o: $(hdrdir)/ruby/internal/attr/nonnull.h
ancdata.o: $(hdrdir)/ruby/internal/attr/noreturn.h
+ancdata.o: $(hdrdir)/ruby/internal/attr/packed_struct.h
ancdata.o: $(hdrdir)/ruby/internal/attr/pure.h
ancdata.o: $(hdrdir)/ruby/internal/attr/restrict.h
ancdata.o: $(hdrdir)/ruby/internal/attr/returns_nonnull.h
@@ -133,7 +135,6 @@ ancdata.o: $(hdrdir)/ruby/internal/intern/enumerator.h
ancdata.o: $(hdrdir)/ruby/internal/intern/error.h
ancdata.o: $(hdrdir)/ruby/internal/intern/eval.h
ancdata.o: $(hdrdir)/ruby/internal/intern/file.h
-ancdata.o: $(hdrdir)/ruby/internal/intern/gc.h
ancdata.o: $(hdrdir)/ruby/internal/intern/hash.h
ancdata.o: $(hdrdir)/ruby/internal/intern/io.h
ancdata.o: $(hdrdir)/ruby/internal/intern/load.h
@@ -164,7 +165,6 @@ ancdata.o: $(hdrdir)/ruby/internal/memory.h
ancdata.o: $(hdrdir)/ruby/internal/method.h
ancdata.o: $(hdrdir)/ruby/internal/module.h
ancdata.o: $(hdrdir)/ruby/internal/newobj.h
-ancdata.o: $(hdrdir)/ruby/internal/rgengc.h
ancdata.o: $(hdrdir)/ruby/internal/scan_args.h
ancdata.o: $(hdrdir)/ruby/internal/special_consts.h
ancdata.o: $(hdrdir)/ruby/internal/static_assert.h
@@ -184,12 +184,20 @@ ancdata.o: $(hdrdir)/ruby/ruby.h
ancdata.o: $(hdrdir)/ruby/st.h
ancdata.o: $(hdrdir)/ruby/subst.h
ancdata.o: $(hdrdir)/ruby/thread.h
+ancdata.o: $(hdrdir)/ruby/thread_native.h
ancdata.o: $(hdrdir)/ruby/util.h
+ancdata.o: $(hdrdir)/ruby/version.h
+ancdata.o: $(top_srcdir)/ccan/check_type/check_type.h
+ancdata.o: $(top_srcdir)/ccan/container_of/container_of.h
+ancdata.o: $(top_srcdir)/ccan/list/list.h
+ancdata.o: $(top_srcdir)/ccan/str/str.h
ancdata.o: $(top_srcdir)/internal.h
ancdata.o: $(top_srcdir)/internal/array.h
+ancdata.o: $(top_srcdir)/internal/basic_operators.h
ancdata.o: $(top_srcdir)/internal/compilers.h
ancdata.o: $(top_srcdir)/internal/error.h
ancdata.o: $(top_srcdir)/internal/gc.h
+ancdata.o: $(top_srcdir)/internal/imemo.h
ancdata.o: $(top_srcdir)/internal/io.h
ancdata.o: $(top_srcdir)/internal/serial.h
ancdata.o: $(top_srcdir)/internal/static_assert.h
@@ -197,14 +205,24 @@ ancdata.o: $(top_srcdir)/internal/string.h
ancdata.o: $(top_srcdir)/internal/thread.h
ancdata.o: $(top_srcdir)/internal/vm.h
ancdata.o: $(top_srcdir)/internal/warnings.h
+ancdata.o: $(top_srcdir)/method.h
+ancdata.o: $(top_srcdir)/node.h
+ancdata.o: $(top_srcdir)/ruby_assert.h
+ancdata.o: $(top_srcdir)/ruby_atomic.h
+ancdata.o: $(top_srcdir)/rubyparser.h
ancdata.o: $(top_srcdir)/shape.h
+ancdata.o: $(top_srcdir)/thread_pthread.h
+ancdata.o: $(top_srcdir)/vm_core.h
+ancdata.o: $(top_srcdir)/vm_opts.h
ancdata.o: ancdata.c
ancdata.o: constdefs.h
ancdata.o: rubysocket.h
ancdata.o: sockport.h
+ancdata.o: {$(VPATH)}id.h
basicsocket.o: $(RUBY_EXTCONF_H)
basicsocket.o: $(arch_hdrdir)/ruby/config.h
basicsocket.o: $(hdrdir)/ruby/assert.h
+basicsocket.o: $(hdrdir)/ruby/atomic.h
basicsocket.o: $(hdrdir)/ruby/backward.h
basicsocket.o: $(hdrdir)/ruby/backward/2/assume.h
basicsocket.o: $(hdrdir)/ruby/backward/2/attributes.h
@@ -257,6 +275,7 @@ basicsocket.o: $(hdrdir)/ruby/internal/attr/noexcept.h
basicsocket.o: $(hdrdir)/ruby/internal/attr/noinline.h
basicsocket.o: $(hdrdir)/ruby/internal/attr/nonnull.h
basicsocket.o: $(hdrdir)/ruby/internal/attr/noreturn.h
+basicsocket.o: $(hdrdir)/ruby/internal/attr/packed_struct.h
basicsocket.o: $(hdrdir)/ruby/internal/attr/pure.h
basicsocket.o: $(hdrdir)/ruby/internal/attr/restrict.h
basicsocket.o: $(hdrdir)/ruby/internal/attr/returns_nonnull.h
@@ -325,7 +344,6 @@ basicsocket.o: $(hdrdir)/ruby/internal/intern/enumerator.h
basicsocket.o: $(hdrdir)/ruby/internal/intern/error.h
basicsocket.o: $(hdrdir)/ruby/internal/intern/eval.h
basicsocket.o: $(hdrdir)/ruby/internal/intern/file.h
-basicsocket.o: $(hdrdir)/ruby/internal/intern/gc.h
basicsocket.o: $(hdrdir)/ruby/internal/intern/hash.h
basicsocket.o: $(hdrdir)/ruby/internal/intern/io.h
basicsocket.o: $(hdrdir)/ruby/internal/intern/load.h
@@ -356,7 +374,6 @@ basicsocket.o: $(hdrdir)/ruby/internal/memory.h
basicsocket.o: $(hdrdir)/ruby/internal/method.h
basicsocket.o: $(hdrdir)/ruby/internal/module.h
basicsocket.o: $(hdrdir)/ruby/internal/newobj.h
-basicsocket.o: $(hdrdir)/ruby/internal/rgengc.h
basicsocket.o: $(hdrdir)/ruby/internal/scan_args.h
basicsocket.o: $(hdrdir)/ruby/internal/special_consts.h
basicsocket.o: $(hdrdir)/ruby/internal/static_assert.h
@@ -376,12 +393,20 @@ basicsocket.o: $(hdrdir)/ruby/ruby.h
basicsocket.o: $(hdrdir)/ruby/st.h
basicsocket.o: $(hdrdir)/ruby/subst.h
basicsocket.o: $(hdrdir)/ruby/thread.h
+basicsocket.o: $(hdrdir)/ruby/thread_native.h
basicsocket.o: $(hdrdir)/ruby/util.h
+basicsocket.o: $(hdrdir)/ruby/version.h
+basicsocket.o: $(top_srcdir)/ccan/check_type/check_type.h
+basicsocket.o: $(top_srcdir)/ccan/container_of/container_of.h
+basicsocket.o: $(top_srcdir)/ccan/list/list.h
+basicsocket.o: $(top_srcdir)/ccan/str/str.h
basicsocket.o: $(top_srcdir)/internal.h
basicsocket.o: $(top_srcdir)/internal/array.h
+basicsocket.o: $(top_srcdir)/internal/basic_operators.h
basicsocket.o: $(top_srcdir)/internal/compilers.h
basicsocket.o: $(top_srcdir)/internal/error.h
basicsocket.o: $(top_srcdir)/internal/gc.h
+basicsocket.o: $(top_srcdir)/internal/imemo.h
basicsocket.o: $(top_srcdir)/internal/io.h
basicsocket.o: $(top_srcdir)/internal/serial.h
basicsocket.o: $(top_srcdir)/internal/static_assert.h
@@ -389,14 +414,24 @@ basicsocket.o: $(top_srcdir)/internal/string.h
basicsocket.o: $(top_srcdir)/internal/thread.h
basicsocket.o: $(top_srcdir)/internal/vm.h
basicsocket.o: $(top_srcdir)/internal/warnings.h
+basicsocket.o: $(top_srcdir)/method.h
+basicsocket.o: $(top_srcdir)/node.h
+basicsocket.o: $(top_srcdir)/ruby_assert.h
+basicsocket.o: $(top_srcdir)/ruby_atomic.h
+basicsocket.o: $(top_srcdir)/rubyparser.h
basicsocket.o: $(top_srcdir)/shape.h
+basicsocket.o: $(top_srcdir)/thread_pthread.h
+basicsocket.o: $(top_srcdir)/vm_core.h
+basicsocket.o: $(top_srcdir)/vm_opts.h
basicsocket.o: basicsocket.c
basicsocket.o: constdefs.h
basicsocket.o: rubysocket.h
basicsocket.o: sockport.h
+basicsocket.o: {$(VPATH)}id.h
constants.o: $(RUBY_EXTCONF_H)
constants.o: $(arch_hdrdir)/ruby/config.h
constants.o: $(hdrdir)/ruby/assert.h
+constants.o: $(hdrdir)/ruby/atomic.h
constants.o: $(hdrdir)/ruby/backward.h
constants.o: $(hdrdir)/ruby/backward/2/assume.h
constants.o: $(hdrdir)/ruby/backward/2/attributes.h
@@ -449,6 +484,7 @@ constants.o: $(hdrdir)/ruby/internal/attr/noexcept.h
constants.o: $(hdrdir)/ruby/internal/attr/noinline.h
constants.o: $(hdrdir)/ruby/internal/attr/nonnull.h
constants.o: $(hdrdir)/ruby/internal/attr/noreturn.h
+constants.o: $(hdrdir)/ruby/internal/attr/packed_struct.h
constants.o: $(hdrdir)/ruby/internal/attr/pure.h
constants.o: $(hdrdir)/ruby/internal/attr/restrict.h
constants.o: $(hdrdir)/ruby/internal/attr/returns_nonnull.h
@@ -517,7 +553,6 @@ constants.o: $(hdrdir)/ruby/internal/intern/enumerator.h
constants.o: $(hdrdir)/ruby/internal/intern/error.h
constants.o: $(hdrdir)/ruby/internal/intern/eval.h
constants.o: $(hdrdir)/ruby/internal/intern/file.h
-constants.o: $(hdrdir)/ruby/internal/intern/gc.h
constants.o: $(hdrdir)/ruby/internal/intern/hash.h
constants.o: $(hdrdir)/ruby/internal/intern/io.h
constants.o: $(hdrdir)/ruby/internal/intern/load.h
@@ -548,7 +583,6 @@ constants.o: $(hdrdir)/ruby/internal/memory.h
constants.o: $(hdrdir)/ruby/internal/method.h
constants.o: $(hdrdir)/ruby/internal/module.h
constants.o: $(hdrdir)/ruby/internal/newobj.h
-constants.o: $(hdrdir)/ruby/internal/rgengc.h
constants.o: $(hdrdir)/ruby/internal/scan_args.h
constants.o: $(hdrdir)/ruby/internal/special_consts.h
constants.o: $(hdrdir)/ruby/internal/static_assert.h
@@ -568,12 +602,20 @@ constants.o: $(hdrdir)/ruby/ruby.h
constants.o: $(hdrdir)/ruby/st.h
constants.o: $(hdrdir)/ruby/subst.h
constants.o: $(hdrdir)/ruby/thread.h
+constants.o: $(hdrdir)/ruby/thread_native.h
constants.o: $(hdrdir)/ruby/util.h
+constants.o: $(hdrdir)/ruby/version.h
+constants.o: $(top_srcdir)/ccan/check_type/check_type.h
+constants.o: $(top_srcdir)/ccan/container_of/container_of.h
+constants.o: $(top_srcdir)/ccan/list/list.h
+constants.o: $(top_srcdir)/ccan/str/str.h
constants.o: $(top_srcdir)/internal.h
constants.o: $(top_srcdir)/internal/array.h
+constants.o: $(top_srcdir)/internal/basic_operators.h
constants.o: $(top_srcdir)/internal/compilers.h
constants.o: $(top_srcdir)/internal/error.h
constants.o: $(top_srcdir)/internal/gc.h
+constants.o: $(top_srcdir)/internal/imemo.h
constants.o: $(top_srcdir)/internal/io.h
constants.o: $(top_srcdir)/internal/serial.h
constants.o: $(top_srcdir)/internal/static_assert.h
@@ -581,15 +623,25 @@ constants.o: $(top_srcdir)/internal/string.h
constants.o: $(top_srcdir)/internal/thread.h
constants.o: $(top_srcdir)/internal/vm.h
constants.o: $(top_srcdir)/internal/warnings.h
+constants.o: $(top_srcdir)/method.h
+constants.o: $(top_srcdir)/node.h
+constants.o: $(top_srcdir)/ruby_assert.h
+constants.o: $(top_srcdir)/ruby_atomic.h
+constants.o: $(top_srcdir)/rubyparser.h
constants.o: $(top_srcdir)/shape.h
+constants.o: $(top_srcdir)/thread_pthread.h
+constants.o: $(top_srcdir)/vm_core.h
+constants.o: $(top_srcdir)/vm_opts.h
constants.o: constants.c
constants.o: constdefs.c
constants.o: constdefs.h
constants.o: rubysocket.h
constants.o: sockport.h
+constants.o: {$(VPATH)}id.h
ifaddr.o: $(RUBY_EXTCONF_H)
ifaddr.o: $(arch_hdrdir)/ruby/config.h
ifaddr.o: $(hdrdir)/ruby/assert.h
+ifaddr.o: $(hdrdir)/ruby/atomic.h
ifaddr.o: $(hdrdir)/ruby/backward.h
ifaddr.o: $(hdrdir)/ruby/backward/2/assume.h
ifaddr.o: $(hdrdir)/ruby/backward/2/attributes.h
@@ -642,6 +694,7 @@ ifaddr.o: $(hdrdir)/ruby/internal/attr/noexcept.h
ifaddr.o: $(hdrdir)/ruby/internal/attr/noinline.h
ifaddr.o: $(hdrdir)/ruby/internal/attr/nonnull.h
ifaddr.o: $(hdrdir)/ruby/internal/attr/noreturn.h
+ifaddr.o: $(hdrdir)/ruby/internal/attr/packed_struct.h
ifaddr.o: $(hdrdir)/ruby/internal/attr/pure.h
ifaddr.o: $(hdrdir)/ruby/internal/attr/restrict.h
ifaddr.o: $(hdrdir)/ruby/internal/attr/returns_nonnull.h
@@ -710,7 +763,6 @@ ifaddr.o: $(hdrdir)/ruby/internal/intern/enumerator.h
ifaddr.o: $(hdrdir)/ruby/internal/intern/error.h
ifaddr.o: $(hdrdir)/ruby/internal/intern/eval.h
ifaddr.o: $(hdrdir)/ruby/internal/intern/file.h
-ifaddr.o: $(hdrdir)/ruby/internal/intern/gc.h
ifaddr.o: $(hdrdir)/ruby/internal/intern/hash.h
ifaddr.o: $(hdrdir)/ruby/internal/intern/io.h
ifaddr.o: $(hdrdir)/ruby/internal/intern/load.h
@@ -741,7 +793,6 @@ ifaddr.o: $(hdrdir)/ruby/internal/memory.h
ifaddr.o: $(hdrdir)/ruby/internal/method.h
ifaddr.o: $(hdrdir)/ruby/internal/module.h
ifaddr.o: $(hdrdir)/ruby/internal/newobj.h
-ifaddr.o: $(hdrdir)/ruby/internal/rgengc.h
ifaddr.o: $(hdrdir)/ruby/internal/scan_args.h
ifaddr.o: $(hdrdir)/ruby/internal/special_consts.h
ifaddr.o: $(hdrdir)/ruby/internal/static_assert.h
@@ -761,12 +812,20 @@ ifaddr.o: $(hdrdir)/ruby/ruby.h
ifaddr.o: $(hdrdir)/ruby/st.h
ifaddr.o: $(hdrdir)/ruby/subst.h
ifaddr.o: $(hdrdir)/ruby/thread.h
+ifaddr.o: $(hdrdir)/ruby/thread_native.h
ifaddr.o: $(hdrdir)/ruby/util.h
+ifaddr.o: $(hdrdir)/ruby/version.h
+ifaddr.o: $(top_srcdir)/ccan/check_type/check_type.h
+ifaddr.o: $(top_srcdir)/ccan/container_of/container_of.h
+ifaddr.o: $(top_srcdir)/ccan/list/list.h
+ifaddr.o: $(top_srcdir)/ccan/str/str.h
ifaddr.o: $(top_srcdir)/internal.h
ifaddr.o: $(top_srcdir)/internal/array.h
+ifaddr.o: $(top_srcdir)/internal/basic_operators.h
ifaddr.o: $(top_srcdir)/internal/compilers.h
ifaddr.o: $(top_srcdir)/internal/error.h
ifaddr.o: $(top_srcdir)/internal/gc.h
+ifaddr.o: $(top_srcdir)/internal/imemo.h
ifaddr.o: $(top_srcdir)/internal/io.h
ifaddr.o: $(top_srcdir)/internal/serial.h
ifaddr.o: $(top_srcdir)/internal/static_assert.h
@@ -774,14 +833,24 @@ ifaddr.o: $(top_srcdir)/internal/string.h
ifaddr.o: $(top_srcdir)/internal/thread.h
ifaddr.o: $(top_srcdir)/internal/vm.h
ifaddr.o: $(top_srcdir)/internal/warnings.h
+ifaddr.o: $(top_srcdir)/method.h
+ifaddr.o: $(top_srcdir)/node.h
+ifaddr.o: $(top_srcdir)/ruby_assert.h
+ifaddr.o: $(top_srcdir)/ruby_atomic.h
+ifaddr.o: $(top_srcdir)/rubyparser.h
ifaddr.o: $(top_srcdir)/shape.h
+ifaddr.o: $(top_srcdir)/thread_pthread.h
+ifaddr.o: $(top_srcdir)/vm_core.h
+ifaddr.o: $(top_srcdir)/vm_opts.h
ifaddr.o: constdefs.h
ifaddr.o: ifaddr.c
ifaddr.o: rubysocket.h
ifaddr.o: sockport.h
+ifaddr.o: {$(VPATH)}id.h
init.o: $(RUBY_EXTCONF_H)
init.o: $(arch_hdrdir)/ruby/config.h
init.o: $(hdrdir)/ruby/assert.h
+init.o: $(hdrdir)/ruby/atomic.h
init.o: $(hdrdir)/ruby/backward.h
init.o: $(hdrdir)/ruby/backward/2/assume.h
init.o: $(hdrdir)/ruby/backward/2/attributes.h
@@ -834,6 +903,7 @@ init.o: $(hdrdir)/ruby/internal/attr/noexcept.h
init.o: $(hdrdir)/ruby/internal/attr/noinline.h
init.o: $(hdrdir)/ruby/internal/attr/nonnull.h
init.o: $(hdrdir)/ruby/internal/attr/noreturn.h
+init.o: $(hdrdir)/ruby/internal/attr/packed_struct.h
init.o: $(hdrdir)/ruby/internal/attr/pure.h
init.o: $(hdrdir)/ruby/internal/attr/restrict.h
init.o: $(hdrdir)/ruby/internal/attr/returns_nonnull.h
@@ -902,7 +972,6 @@ init.o: $(hdrdir)/ruby/internal/intern/enumerator.h
init.o: $(hdrdir)/ruby/internal/intern/error.h
init.o: $(hdrdir)/ruby/internal/intern/eval.h
init.o: $(hdrdir)/ruby/internal/intern/file.h
-init.o: $(hdrdir)/ruby/internal/intern/gc.h
init.o: $(hdrdir)/ruby/internal/intern/hash.h
init.o: $(hdrdir)/ruby/internal/intern/io.h
init.o: $(hdrdir)/ruby/internal/intern/load.h
@@ -933,7 +1002,6 @@ init.o: $(hdrdir)/ruby/internal/memory.h
init.o: $(hdrdir)/ruby/internal/method.h
init.o: $(hdrdir)/ruby/internal/module.h
init.o: $(hdrdir)/ruby/internal/newobj.h
-init.o: $(hdrdir)/ruby/internal/rgengc.h
init.o: $(hdrdir)/ruby/internal/scan_args.h
init.o: $(hdrdir)/ruby/internal/special_consts.h
init.o: $(hdrdir)/ruby/internal/static_assert.h
@@ -953,12 +1021,20 @@ init.o: $(hdrdir)/ruby/ruby.h
init.o: $(hdrdir)/ruby/st.h
init.o: $(hdrdir)/ruby/subst.h
init.o: $(hdrdir)/ruby/thread.h
+init.o: $(hdrdir)/ruby/thread_native.h
init.o: $(hdrdir)/ruby/util.h
+init.o: $(hdrdir)/ruby/version.h
+init.o: $(top_srcdir)/ccan/check_type/check_type.h
+init.o: $(top_srcdir)/ccan/container_of/container_of.h
+init.o: $(top_srcdir)/ccan/list/list.h
+init.o: $(top_srcdir)/ccan/str/str.h
init.o: $(top_srcdir)/internal.h
init.o: $(top_srcdir)/internal/array.h
+init.o: $(top_srcdir)/internal/basic_operators.h
init.o: $(top_srcdir)/internal/compilers.h
init.o: $(top_srcdir)/internal/error.h
init.o: $(top_srcdir)/internal/gc.h
+init.o: $(top_srcdir)/internal/imemo.h
init.o: $(top_srcdir)/internal/io.h
init.o: $(top_srcdir)/internal/serial.h
init.o: $(top_srcdir)/internal/static_assert.h
@@ -966,14 +1042,24 @@ init.o: $(top_srcdir)/internal/string.h
init.o: $(top_srcdir)/internal/thread.h
init.o: $(top_srcdir)/internal/vm.h
init.o: $(top_srcdir)/internal/warnings.h
+init.o: $(top_srcdir)/method.h
+init.o: $(top_srcdir)/node.h
+init.o: $(top_srcdir)/ruby_assert.h
+init.o: $(top_srcdir)/ruby_atomic.h
+init.o: $(top_srcdir)/rubyparser.h
init.o: $(top_srcdir)/shape.h
+init.o: $(top_srcdir)/thread_pthread.h
+init.o: $(top_srcdir)/vm_core.h
+init.o: $(top_srcdir)/vm_opts.h
init.o: constdefs.h
init.o: init.c
init.o: rubysocket.h
init.o: sockport.h
+init.o: {$(VPATH)}id.h
ipsocket.o: $(RUBY_EXTCONF_H)
ipsocket.o: $(arch_hdrdir)/ruby/config.h
ipsocket.o: $(hdrdir)/ruby/assert.h
+ipsocket.o: $(hdrdir)/ruby/atomic.h
ipsocket.o: $(hdrdir)/ruby/backward.h
ipsocket.o: $(hdrdir)/ruby/backward/2/assume.h
ipsocket.o: $(hdrdir)/ruby/backward/2/attributes.h
@@ -1026,6 +1112,7 @@ ipsocket.o: $(hdrdir)/ruby/internal/attr/noexcept.h
ipsocket.o: $(hdrdir)/ruby/internal/attr/noinline.h
ipsocket.o: $(hdrdir)/ruby/internal/attr/nonnull.h
ipsocket.o: $(hdrdir)/ruby/internal/attr/noreturn.h
+ipsocket.o: $(hdrdir)/ruby/internal/attr/packed_struct.h
ipsocket.o: $(hdrdir)/ruby/internal/attr/pure.h
ipsocket.o: $(hdrdir)/ruby/internal/attr/restrict.h
ipsocket.o: $(hdrdir)/ruby/internal/attr/returns_nonnull.h
@@ -1094,7 +1181,6 @@ ipsocket.o: $(hdrdir)/ruby/internal/intern/enumerator.h
ipsocket.o: $(hdrdir)/ruby/internal/intern/error.h
ipsocket.o: $(hdrdir)/ruby/internal/intern/eval.h
ipsocket.o: $(hdrdir)/ruby/internal/intern/file.h
-ipsocket.o: $(hdrdir)/ruby/internal/intern/gc.h
ipsocket.o: $(hdrdir)/ruby/internal/intern/hash.h
ipsocket.o: $(hdrdir)/ruby/internal/intern/io.h
ipsocket.o: $(hdrdir)/ruby/internal/intern/load.h
@@ -1125,7 +1211,6 @@ ipsocket.o: $(hdrdir)/ruby/internal/memory.h
ipsocket.o: $(hdrdir)/ruby/internal/method.h
ipsocket.o: $(hdrdir)/ruby/internal/module.h
ipsocket.o: $(hdrdir)/ruby/internal/newobj.h
-ipsocket.o: $(hdrdir)/ruby/internal/rgengc.h
ipsocket.o: $(hdrdir)/ruby/internal/scan_args.h
ipsocket.o: $(hdrdir)/ruby/internal/special_consts.h
ipsocket.o: $(hdrdir)/ruby/internal/static_assert.h
@@ -1145,12 +1230,20 @@ ipsocket.o: $(hdrdir)/ruby/ruby.h
ipsocket.o: $(hdrdir)/ruby/st.h
ipsocket.o: $(hdrdir)/ruby/subst.h
ipsocket.o: $(hdrdir)/ruby/thread.h
+ipsocket.o: $(hdrdir)/ruby/thread_native.h
ipsocket.o: $(hdrdir)/ruby/util.h
+ipsocket.o: $(hdrdir)/ruby/version.h
+ipsocket.o: $(top_srcdir)/ccan/check_type/check_type.h
+ipsocket.o: $(top_srcdir)/ccan/container_of/container_of.h
+ipsocket.o: $(top_srcdir)/ccan/list/list.h
+ipsocket.o: $(top_srcdir)/ccan/str/str.h
ipsocket.o: $(top_srcdir)/internal.h
ipsocket.o: $(top_srcdir)/internal/array.h
+ipsocket.o: $(top_srcdir)/internal/basic_operators.h
ipsocket.o: $(top_srcdir)/internal/compilers.h
ipsocket.o: $(top_srcdir)/internal/error.h
ipsocket.o: $(top_srcdir)/internal/gc.h
+ipsocket.o: $(top_srcdir)/internal/imemo.h
ipsocket.o: $(top_srcdir)/internal/io.h
ipsocket.o: $(top_srcdir)/internal/serial.h
ipsocket.o: $(top_srcdir)/internal/static_assert.h
@@ -1158,14 +1251,24 @@ ipsocket.o: $(top_srcdir)/internal/string.h
ipsocket.o: $(top_srcdir)/internal/thread.h
ipsocket.o: $(top_srcdir)/internal/vm.h
ipsocket.o: $(top_srcdir)/internal/warnings.h
+ipsocket.o: $(top_srcdir)/method.h
+ipsocket.o: $(top_srcdir)/node.h
+ipsocket.o: $(top_srcdir)/ruby_assert.h
+ipsocket.o: $(top_srcdir)/ruby_atomic.h
+ipsocket.o: $(top_srcdir)/rubyparser.h
ipsocket.o: $(top_srcdir)/shape.h
+ipsocket.o: $(top_srcdir)/thread_pthread.h
+ipsocket.o: $(top_srcdir)/vm_core.h
+ipsocket.o: $(top_srcdir)/vm_opts.h
ipsocket.o: constdefs.h
ipsocket.o: ipsocket.c
ipsocket.o: rubysocket.h
ipsocket.o: sockport.h
+ipsocket.o: {$(VPATH)}id.h
option.o: $(RUBY_EXTCONF_H)
option.o: $(arch_hdrdir)/ruby/config.h
option.o: $(hdrdir)/ruby/assert.h
+option.o: $(hdrdir)/ruby/atomic.h
option.o: $(hdrdir)/ruby/backward.h
option.o: $(hdrdir)/ruby/backward/2/assume.h
option.o: $(hdrdir)/ruby/backward/2/attributes.h
@@ -1218,6 +1321,7 @@ option.o: $(hdrdir)/ruby/internal/attr/noexcept.h
option.o: $(hdrdir)/ruby/internal/attr/noinline.h
option.o: $(hdrdir)/ruby/internal/attr/nonnull.h
option.o: $(hdrdir)/ruby/internal/attr/noreturn.h
+option.o: $(hdrdir)/ruby/internal/attr/packed_struct.h
option.o: $(hdrdir)/ruby/internal/attr/pure.h
option.o: $(hdrdir)/ruby/internal/attr/restrict.h
option.o: $(hdrdir)/ruby/internal/attr/returns_nonnull.h
@@ -1286,7 +1390,6 @@ option.o: $(hdrdir)/ruby/internal/intern/enumerator.h
option.o: $(hdrdir)/ruby/internal/intern/error.h
option.o: $(hdrdir)/ruby/internal/intern/eval.h
option.o: $(hdrdir)/ruby/internal/intern/file.h
-option.o: $(hdrdir)/ruby/internal/intern/gc.h
option.o: $(hdrdir)/ruby/internal/intern/hash.h
option.o: $(hdrdir)/ruby/internal/intern/io.h
option.o: $(hdrdir)/ruby/internal/intern/load.h
@@ -1317,7 +1420,6 @@ option.o: $(hdrdir)/ruby/internal/memory.h
option.o: $(hdrdir)/ruby/internal/method.h
option.o: $(hdrdir)/ruby/internal/module.h
option.o: $(hdrdir)/ruby/internal/newobj.h
-option.o: $(hdrdir)/ruby/internal/rgengc.h
option.o: $(hdrdir)/ruby/internal/scan_args.h
option.o: $(hdrdir)/ruby/internal/special_consts.h
option.o: $(hdrdir)/ruby/internal/static_assert.h
@@ -1337,12 +1439,20 @@ option.o: $(hdrdir)/ruby/ruby.h
option.o: $(hdrdir)/ruby/st.h
option.o: $(hdrdir)/ruby/subst.h
option.o: $(hdrdir)/ruby/thread.h
+option.o: $(hdrdir)/ruby/thread_native.h
option.o: $(hdrdir)/ruby/util.h
+option.o: $(hdrdir)/ruby/version.h
+option.o: $(top_srcdir)/ccan/check_type/check_type.h
+option.o: $(top_srcdir)/ccan/container_of/container_of.h
+option.o: $(top_srcdir)/ccan/list/list.h
+option.o: $(top_srcdir)/ccan/str/str.h
option.o: $(top_srcdir)/internal.h
option.o: $(top_srcdir)/internal/array.h
+option.o: $(top_srcdir)/internal/basic_operators.h
option.o: $(top_srcdir)/internal/compilers.h
option.o: $(top_srcdir)/internal/error.h
option.o: $(top_srcdir)/internal/gc.h
+option.o: $(top_srcdir)/internal/imemo.h
option.o: $(top_srcdir)/internal/io.h
option.o: $(top_srcdir)/internal/serial.h
option.o: $(top_srcdir)/internal/static_assert.h
@@ -1350,14 +1460,24 @@ option.o: $(top_srcdir)/internal/string.h
option.o: $(top_srcdir)/internal/thread.h
option.o: $(top_srcdir)/internal/vm.h
option.o: $(top_srcdir)/internal/warnings.h
+option.o: $(top_srcdir)/method.h
+option.o: $(top_srcdir)/node.h
+option.o: $(top_srcdir)/ruby_assert.h
+option.o: $(top_srcdir)/ruby_atomic.h
+option.o: $(top_srcdir)/rubyparser.h
option.o: $(top_srcdir)/shape.h
+option.o: $(top_srcdir)/thread_pthread.h
+option.o: $(top_srcdir)/vm_core.h
+option.o: $(top_srcdir)/vm_opts.h
option.o: constdefs.h
option.o: option.c
option.o: rubysocket.h
option.o: sockport.h
+option.o: {$(VPATH)}id.h
raddrinfo.o: $(RUBY_EXTCONF_H)
raddrinfo.o: $(arch_hdrdir)/ruby/config.h
raddrinfo.o: $(hdrdir)/ruby/assert.h
+raddrinfo.o: $(hdrdir)/ruby/atomic.h
raddrinfo.o: $(hdrdir)/ruby/backward.h
raddrinfo.o: $(hdrdir)/ruby/backward/2/assume.h
raddrinfo.o: $(hdrdir)/ruby/backward/2/attributes.h
@@ -1410,6 +1530,7 @@ raddrinfo.o: $(hdrdir)/ruby/internal/attr/noexcept.h
raddrinfo.o: $(hdrdir)/ruby/internal/attr/noinline.h
raddrinfo.o: $(hdrdir)/ruby/internal/attr/nonnull.h
raddrinfo.o: $(hdrdir)/ruby/internal/attr/noreturn.h
+raddrinfo.o: $(hdrdir)/ruby/internal/attr/packed_struct.h
raddrinfo.o: $(hdrdir)/ruby/internal/attr/pure.h
raddrinfo.o: $(hdrdir)/ruby/internal/attr/restrict.h
raddrinfo.o: $(hdrdir)/ruby/internal/attr/returns_nonnull.h
@@ -1478,7 +1599,6 @@ raddrinfo.o: $(hdrdir)/ruby/internal/intern/enumerator.h
raddrinfo.o: $(hdrdir)/ruby/internal/intern/error.h
raddrinfo.o: $(hdrdir)/ruby/internal/intern/eval.h
raddrinfo.o: $(hdrdir)/ruby/internal/intern/file.h
-raddrinfo.o: $(hdrdir)/ruby/internal/intern/gc.h
raddrinfo.o: $(hdrdir)/ruby/internal/intern/hash.h
raddrinfo.o: $(hdrdir)/ruby/internal/intern/io.h
raddrinfo.o: $(hdrdir)/ruby/internal/intern/load.h
@@ -1509,7 +1629,6 @@ raddrinfo.o: $(hdrdir)/ruby/internal/memory.h
raddrinfo.o: $(hdrdir)/ruby/internal/method.h
raddrinfo.o: $(hdrdir)/ruby/internal/module.h
raddrinfo.o: $(hdrdir)/ruby/internal/newobj.h
-raddrinfo.o: $(hdrdir)/ruby/internal/rgengc.h
raddrinfo.o: $(hdrdir)/ruby/internal/scan_args.h
raddrinfo.o: $(hdrdir)/ruby/internal/special_consts.h
raddrinfo.o: $(hdrdir)/ruby/internal/static_assert.h
@@ -1529,12 +1648,20 @@ raddrinfo.o: $(hdrdir)/ruby/ruby.h
raddrinfo.o: $(hdrdir)/ruby/st.h
raddrinfo.o: $(hdrdir)/ruby/subst.h
raddrinfo.o: $(hdrdir)/ruby/thread.h
+raddrinfo.o: $(hdrdir)/ruby/thread_native.h
raddrinfo.o: $(hdrdir)/ruby/util.h
+raddrinfo.o: $(hdrdir)/ruby/version.h
+raddrinfo.o: $(top_srcdir)/ccan/check_type/check_type.h
+raddrinfo.o: $(top_srcdir)/ccan/container_of/container_of.h
+raddrinfo.o: $(top_srcdir)/ccan/list/list.h
+raddrinfo.o: $(top_srcdir)/ccan/str/str.h
raddrinfo.o: $(top_srcdir)/internal.h
raddrinfo.o: $(top_srcdir)/internal/array.h
+raddrinfo.o: $(top_srcdir)/internal/basic_operators.h
raddrinfo.o: $(top_srcdir)/internal/compilers.h
raddrinfo.o: $(top_srcdir)/internal/error.h
raddrinfo.o: $(top_srcdir)/internal/gc.h
+raddrinfo.o: $(top_srcdir)/internal/imemo.h
raddrinfo.o: $(top_srcdir)/internal/io.h
raddrinfo.o: $(top_srcdir)/internal/serial.h
raddrinfo.o: $(top_srcdir)/internal/static_assert.h
@@ -1542,14 +1669,24 @@ raddrinfo.o: $(top_srcdir)/internal/string.h
raddrinfo.o: $(top_srcdir)/internal/thread.h
raddrinfo.o: $(top_srcdir)/internal/vm.h
raddrinfo.o: $(top_srcdir)/internal/warnings.h
+raddrinfo.o: $(top_srcdir)/method.h
+raddrinfo.o: $(top_srcdir)/node.h
+raddrinfo.o: $(top_srcdir)/ruby_assert.h
+raddrinfo.o: $(top_srcdir)/ruby_atomic.h
+raddrinfo.o: $(top_srcdir)/rubyparser.h
raddrinfo.o: $(top_srcdir)/shape.h
+raddrinfo.o: $(top_srcdir)/thread_pthread.h
+raddrinfo.o: $(top_srcdir)/vm_core.h
+raddrinfo.o: $(top_srcdir)/vm_opts.h
raddrinfo.o: constdefs.h
raddrinfo.o: raddrinfo.c
raddrinfo.o: rubysocket.h
raddrinfo.o: sockport.h
+raddrinfo.o: {$(VPATH)}id.h
socket.o: $(RUBY_EXTCONF_H)
socket.o: $(arch_hdrdir)/ruby/config.h
socket.o: $(hdrdir)/ruby/assert.h
+socket.o: $(hdrdir)/ruby/atomic.h
socket.o: $(hdrdir)/ruby/backward.h
socket.o: $(hdrdir)/ruby/backward/2/assume.h
socket.o: $(hdrdir)/ruby/backward/2/attributes.h
@@ -1602,6 +1739,7 @@ socket.o: $(hdrdir)/ruby/internal/attr/noexcept.h
socket.o: $(hdrdir)/ruby/internal/attr/noinline.h
socket.o: $(hdrdir)/ruby/internal/attr/nonnull.h
socket.o: $(hdrdir)/ruby/internal/attr/noreturn.h
+socket.o: $(hdrdir)/ruby/internal/attr/packed_struct.h
socket.o: $(hdrdir)/ruby/internal/attr/pure.h
socket.o: $(hdrdir)/ruby/internal/attr/restrict.h
socket.o: $(hdrdir)/ruby/internal/attr/returns_nonnull.h
@@ -1670,7 +1808,6 @@ socket.o: $(hdrdir)/ruby/internal/intern/enumerator.h
socket.o: $(hdrdir)/ruby/internal/intern/error.h
socket.o: $(hdrdir)/ruby/internal/intern/eval.h
socket.o: $(hdrdir)/ruby/internal/intern/file.h
-socket.o: $(hdrdir)/ruby/internal/intern/gc.h
socket.o: $(hdrdir)/ruby/internal/intern/hash.h
socket.o: $(hdrdir)/ruby/internal/intern/io.h
socket.o: $(hdrdir)/ruby/internal/intern/load.h
@@ -1701,7 +1838,6 @@ socket.o: $(hdrdir)/ruby/internal/memory.h
socket.o: $(hdrdir)/ruby/internal/method.h
socket.o: $(hdrdir)/ruby/internal/module.h
socket.o: $(hdrdir)/ruby/internal/newobj.h
-socket.o: $(hdrdir)/ruby/internal/rgengc.h
socket.o: $(hdrdir)/ruby/internal/scan_args.h
socket.o: $(hdrdir)/ruby/internal/special_consts.h
socket.o: $(hdrdir)/ruby/internal/static_assert.h
@@ -1721,12 +1857,20 @@ socket.o: $(hdrdir)/ruby/ruby.h
socket.o: $(hdrdir)/ruby/st.h
socket.o: $(hdrdir)/ruby/subst.h
socket.o: $(hdrdir)/ruby/thread.h
+socket.o: $(hdrdir)/ruby/thread_native.h
socket.o: $(hdrdir)/ruby/util.h
+socket.o: $(hdrdir)/ruby/version.h
+socket.o: $(top_srcdir)/ccan/check_type/check_type.h
+socket.o: $(top_srcdir)/ccan/container_of/container_of.h
+socket.o: $(top_srcdir)/ccan/list/list.h
+socket.o: $(top_srcdir)/ccan/str/str.h
socket.o: $(top_srcdir)/internal.h
socket.o: $(top_srcdir)/internal/array.h
+socket.o: $(top_srcdir)/internal/basic_operators.h
socket.o: $(top_srcdir)/internal/compilers.h
socket.o: $(top_srcdir)/internal/error.h
socket.o: $(top_srcdir)/internal/gc.h
+socket.o: $(top_srcdir)/internal/imemo.h
socket.o: $(top_srcdir)/internal/io.h
socket.o: $(top_srcdir)/internal/serial.h
socket.o: $(top_srcdir)/internal/static_assert.h
@@ -1734,14 +1878,24 @@ socket.o: $(top_srcdir)/internal/string.h
socket.o: $(top_srcdir)/internal/thread.h
socket.o: $(top_srcdir)/internal/vm.h
socket.o: $(top_srcdir)/internal/warnings.h
+socket.o: $(top_srcdir)/method.h
+socket.o: $(top_srcdir)/node.h
+socket.o: $(top_srcdir)/ruby_assert.h
+socket.o: $(top_srcdir)/ruby_atomic.h
+socket.o: $(top_srcdir)/rubyparser.h
socket.o: $(top_srcdir)/shape.h
+socket.o: $(top_srcdir)/thread_pthread.h
+socket.o: $(top_srcdir)/vm_core.h
+socket.o: $(top_srcdir)/vm_opts.h
socket.o: constdefs.h
socket.o: rubysocket.h
socket.o: socket.c
socket.o: sockport.h
+socket.o: {$(VPATH)}id.h
sockssocket.o: $(RUBY_EXTCONF_H)
sockssocket.o: $(arch_hdrdir)/ruby/config.h
sockssocket.o: $(hdrdir)/ruby/assert.h
+sockssocket.o: $(hdrdir)/ruby/atomic.h
sockssocket.o: $(hdrdir)/ruby/backward.h
sockssocket.o: $(hdrdir)/ruby/backward/2/assume.h
sockssocket.o: $(hdrdir)/ruby/backward/2/attributes.h
@@ -1794,6 +1948,7 @@ sockssocket.o: $(hdrdir)/ruby/internal/attr/noexcept.h
sockssocket.o: $(hdrdir)/ruby/internal/attr/noinline.h
sockssocket.o: $(hdrdir)/ruby/internal/attr/nonnull.h
sockssocket.o: $(hdrdir)/ruby/internal/attr/noreturn.h
+sockssocket.o: $(hdrdir)/ruby/internal/attr/packed_struct.h
sockssocket.o: $(hdrdir)/ruby/internal/attr/pure.h
sockssocket.o: $(hdrdir)/ruby/internal/attr/restrict.h
sockssocket.o: $(hdrdir)/ruby/internal/attr/returns_nonnull.h
@@ -1862,7 +2017,6 @@ sockssocket.o: $(hdrdir)/ruby/internal/intern/enumerator.h
sockssocket.o: $(hdrdir)/ruby/internal/intern/error.h
sockssocket.o: $(hdrdir)/ruby/internal/intern/eval.h
sockssocket.o: $(hdrdir)/ruby/internal/intern/file.h
-sockssocket.o: $(hdrdir)/ruby/internal/intern/gc.h
sockssocket.o: $(hdrdir)/ruby/internal/intern/hash.h
sockssocket.o: $(hdrdir)/ruby/internal/intern/io.h
sockssocket.o: $(hdrdir)/ruby/internal/intern/load.h
@@ -1893,7 +2047,6 @@ sockssocket.o: $(hdrdir)/ruby/internal/memory.h
sockssocket.o: $(hdrdir)/ruby/internal/method.h
sockssocket.o: $(hdrdir)/ruby/internal/module.h
sockssocket.o: $(hdrdir)/ruby/internal/newobj.h
-sockssocket.o: $(hdrdir)/ruby/internal/rgengc.h
sockssocket.o: $(hdrdir)/ruby/internal/scan_args.h
sockssocket.o: $(hdrdir)/ruby/internal/special_consts.h
sockssocket.o: $(hdrdir)/ruby/internal/static_assert.h
@@ -1913,12 +2066,20 @@ sockssocket.o: $(hdrdir)/ruby/ruby.h
sockssocket.o: $(hdrdir)/ruby/st.h
sockssocket.o: $(hdrdir)/ruby/subst.h
sockssocket.o: $(hdrdir)/ruby/thread.h
+sockssocket.o: $(hdrdir)/ruby/thread_native.h
sockssocket.o: $(hdrdir)/ruby/util.h
+sockssocket.o: $(hdrdir)/ruby/version.h
+sockssocket.o: $(top_srcdir)/ccan/check_type/check_type.h
+sockssocket.o: $(top_srcdir)/ccan/container_of/container_of.h
+sockssocket.o: $(top_srcdir)/ccan/list/list.h
+sockssocket.o: $(top_srcdir)/ccan/str/str.h
sockssocket.o: $(top_srcdir)/internal.h
sockssocket.o: $(top_srcdir)/internal/array.h
+sockssocket.o: $(top_srcdir)/internal/basic_operators.h
sockssocket.o: $(top_srcdir)/internal/compilers.h
sockssocket.o: $(top_srcdir)/internal/error.h
sockssocket.o: $(top_srcdir)/internal/gc.h
+sockssocket.o: $(top_srcdir)/internal/imemo.h
sockssocket.o: $(top_srcdir)/internal/io.h
sockssocket.o: $(top_srcdir)/internal/serial.h
sockssocket.o: $(top_srcdir)/internal/static_assert.h
@@ -1926,14 +2087,24 @@ sockssocket.o: $(top_srcdir)/internal/string.h
sockssocket.o: $(top_srcdir)/internal/thread.h
sockssocket.o: $(top_srcdir)/internal/vm.h
sockssocket.o: $(top_srcdir)/internal/warnings.h
+sockssocket.o: $(top_srcdir)/method.h
+sockssocket.o: $(top_srcdir)/node.h
+sockssocket.o: $(top_srcdir)/ruby_assert.h
+sockssocket.o: $(top_srcdir)/ruby_atomic.h
+sockssocket.o: $(top_srcdir)/rubyparser.h
sockssocket.o: $(top_srcdir)/shape.h
+sockssocket.o: $(top_srcdir)/thread_pthread.h
+sockssocket.o: $(top_srcdir)/vm_core.h
+sockssocket.o: $(top_srcdir)/vm_opts.h
sockssocket.o: constdefs.h
sockssocket.o: rubysocket.h
sockssocket.o: sockport.h
sockssocket.o: sockssocket.c
+sockssocket.o: {$(VPATH)}id.h
tcpserver.o: $(RUBY_EXTCONF_H)
tcpserver.o: $(arch_hdrdir)/ruby/config.h
tcpserver.o: $(hdrdir)/ruby/assert.h
+tcpserver.o: $(hdrdir)/ruby/atomic.h
tcpserver.o: $(hdrdir)/ruby/backward.h
tcpserver.o: $(hdrdir)/ruby/backward/2/assume.h
tcpserver.o: $(hdrdir)/ruby/backward/2/attributes.h
@@ -1986,6 +2157,7 @@ tcpserver.o: $(hdrdir)/ruby/internal/attr/noexcept.h
tcpserver.o: $(hdrdir)/ruby/internal/attr/noinline.h
tcpserver.o: $(hdrdir)/ruby/internal/attr/nonnull.h
tcpserver.o: $(hdrdir)/ruby/internal/attr/noreturn.h
+tcpserver.o: $(hdrdir)/ruby/internal/attr/packed_struct.h
tcpserver.o: $(hdrdir)/ruby/internal/attr/pure.h
tcpserver.o: $(hdrdir)/ruby/internal/attr/restrict.h
tcpserver.o: $(hdrdir)/ruby/internal/attr/returns_nonnull.h
@@ -2054,7 +2226,6 @@ tcpserver.o: $(hdrdir)/ruby/internal/intern/enumerator.h
tcpserver.o: $(hdrdir)/ruby/internal/intern/error.h
tcpserver.o: $(hdrdir)/ruby/internal/intern/eval.h
tcpserver.o: $(hdrdir)/ruby/internal/intern/file.h
-tcpserver.o: $(hdrdir)/ruby/internal/intern/gc.h
tcpserver.o: $(hdrdir)/ruby/internal/intern/hash.h
tcpserver.o: $(hdrdir)/ruby/internal/intern/io.h
tcpserver.o: $(hdrdir)/ruby/internal/intern/load.h
@@ -2085,7 +2256,6 @@ tcpserver.o: $(hdrdir)/ruby/internal/memory.h
tcpserver.o: $(hdrdir)/ruby/internal/method.h
tcpserver.o: $(hdrdir)/ruby/internal/module.h
tcpserver.o: $(hdrdir)/ruby/internal/newobj.h
-tcpserver.o: $(hdrdir)/ruby/internal/rgengc.h
tcpserver.o: $(hdrdir)/ruby/internal/scan_args.h
tcpserver.o: $(hdrdir)/ruby/internal/special_consts.h
tcpserver.o: $(hdrdir)/ruby/internal/static_assert.h
@@ -2105,12 +2275,20 @@ tcpserver.o: $(hdrdir)/ruby/ruby.h
tcpserver.o: $(hdrdir)/ruby/st.h
tcpserver.o: $(hdrdir)/ruby/subst.h
tcpserver.o: $(hdrdir)/ruby/thread.h
+tcpserver.o: $(hdrdir)/ruby/thread_native.h
tcpserver.o: $(hdrdir)/ruby/util.h
+tcpserver.o: $(hdrdir)/ruby/version.h
+tcpserver.o: $(top_srcdir)/ccan/check_type/check_type.h
+tcpserver.o: $(top_srcdir)/ccan/container_of/container_of.h
+tcpserver.o: $(top_srcdir)/ccan/list/list.h
+tcpserver.o: $(top_srcdir)/ccan/str/str.h
tcpserver.o: $(top_srcdir)/internal.h
tcpserver.o: $(top_srcdir)/internal/array.h
+tcpserver.o: $(top_srcdir)/internal/basic_operators.h
tcpserver.o: $(top_srcdir)/internal/compilers.h
tcpserver.o: $(top_srcdir)/internal/error.h
tcpserver.o: $(top_srcdir)/internal/gc.h
+tcpserver.o: $(top_srcdir)/internal/imemo.h
tcpserver.o: $(top_srcdir)/internal/io.h
tcpserver.o: $(top_srcdir)/internal/serial.h
tcpserver.o: $(top_srcdir)/internal/static_assert.h
@@ -2118,14 +2296,24 @@ tcpserver.o: $(top_srcdir)/internal/string.h
tcpserver.o: $(top_srcdir)/internal/thread.h
tcpserver.o: $(top_srcdir)/internal/vm.h
tcpserver.o: $(top_srcdir)/internal/warnings.h
+tcpserver.o: $(top_srcdir)/method.h
+tcpserver.o: $(top_srcdir)/node.h
+tcpserver.o: $(top_srcdir)/ruby_assert.h
+tcpserver.o: $(top_srcdir)/ruby_atomic.h
+tcpserver.o: $(top_srcdir)/rubyparser.h
tcpserver.o: $(top_srcdir)/shape.h
+tcpserver.o: $(top_srcdir)/thread_pthread.h
+tcpserver.o: $(top_srcdir)/vm_core.h
+tcpserver.o: $(top_srcdir)/vm_opts.h
tcpserver.o: constdefs.h
tcpserver.o: rubysocket.h
tcpserver.o: sockport.h
tcpserver.o: tcpserver.c
+tcpserver.o: {$(VPATH)}id.h
tcpsocket.o: $(RUBY_EXTCONF_H)
tcpsocket.o: $(arch_hdrdir)/ruby/config.h
tcpsocket.o: $(hdrdir)/ruby/assert.h
+tcpsocket.o: $(hdrdir)/ruby/atomic.h
tcpsocket.o: $(hdrdir)/ruby/backward.h
tcpsocket.o: $(hdrdir)/ruby/backward/2/assume.h
tcpsocket.o: $(hdrdir)/ruby/backward/2/attributes.h
@@ -2178,6 +2366,7 @@ tcpsocket.o: $(hdrdir)/ruby/internal/attr/noexcept.h
tcpsocket.o: $(hdrdir)/ruby/internal/attr/noinline.h
tcpsocket.o: $(hdrdir)/ruby/internal/attr/nonnull.h
tcpsocket.o: $(hdrdir)/ruby/internal/attr/noreturn.h
+tcpsocket.o: $(hdrdir)/ruby/internal/attr/packed_struct.h
tcpsocket.o: $(hdrdir)/ruby/internal/attr/pure.h
tcpsocket.o: $(hdrdir)/ruby/internal/attr/restrict.h
tcpsocket.o: $(hdrdir)/ruby/internal/attr/returns_nonnull.h
@@ -2246,7 +2435,6 @@ tcpsocket.o: $(hdrdir)/ruby/internal/intern/enumerator.h
tcpsocket.o: $(hdrdir)/ruby/internal/intern/error.h
tcpsocket.o: $(hdrdir)/ruby/internal/intern/eval.h
tcpsocket.o: $(hdrdir)/ruby/internal/intern/file.h
-tcpsocket.o: $(hdrdir)/ruby/internal/intern/gc.h
tcpsocket.o: $(hdrdir)/ruby/internal/intern/hash.h
tcpsocket.o: $(hdrdir)/ruby/internal/intern/io.h
tcpsocket.o: $(hdrdir)/ruby/internal/intern/load.h
@@ -2277,7 +2465,6 @@ tcpsocket.o: $(hdrdir)/ruby/internal/memory.h
tcpsocket.o: $(hdrdir)/ruby/internal/method.h
tcpsocket.o: $(hdrdir)/ruby/internal/module.h
tcpsocket.o: $(hdrdir)/ruby/internal/newobj.h
-tcpsocket.o: $(hdrdir)/ruby/internal/rgengc.h
tcpsocket.o: $(hdrdir)/ruby/internal/scan_args.h
tcpsocket.o: $(hdrdir)/ruby/internal/special_consts.h
tcpsocket.o: $(hdrdir)/ruby/internal/static_assert.h
@@ -2297,12 +2484,20 @@ tcpsocket.o: $(hdrdir)/ruby/ruby.h
tcpsocket.o: $(hdrdir)/ruby/st.h
tcpsocket.o: $(hdrdir)/ruby/subst.h
tcpsocket.o: $(hdrdir)/ruby/thread.h
+tcpsocket.o: $(hdrdir)/ruby/thread_native.h
tcpsocket.o: $(hdrdir)/ruby/util.h
+tcpsocket.o: $(hdrdir)/ruby/version.h
+tcpsocket.o: $(top_srcdir)/ccan/check_type/check_type.h
+tcpsocket.o: $(top_srcdir)/ccan/container_of/container_of.h
+tcpsocket.o: $(top_srcdir)/ccan/list/list.h
+tcpsocket.o: $(top_srcdir)/ccan/str/str.h
tcpsocket.o: $(top_srcdir)/internal.h
tcpsocket.o: $(top_srcdir)/internal/array.h
+tcpsocket.o: $(top_srcdir)/internal/basic_operators.h
tcpsocket.o: $(top_srcdir)/internal/compilers.h
tcpsocket.o: $(top_srcdir)/internal/error.h
tcpsocket.o: $(top_srcdir)/internal/gc.h
+tcpsocket.o: $(top_srcdir)/internal/imemo.h
tcpsocket.o: $(top_srcdir)/internal/io.h
tcpsocket.o: $(top_srcdir)/internal/serial.h
tcpsocket.o: $(top_srcdir)/internal/static_assert.h
@@ -2310,14 +2505,24 @@ tcpsocket.o: $(top_srcdir)/internal/string.h
tcpsocket.o: $(top_srcdir)/internal/thread.h
tcpsocket.o: $(top_srcdir)/internal/vm.h
tcpsocket.o: $(top_srcdir)/internal/warnings.h
+tcpsocket.o: $(top_srcdir)/method.h
+tcpsocket.o: $(top_srcdir)/node.h
+tcpsocket.o: $(top_srcdir)/ruby_assert.h
+tcpsocket.o: $(top_srcdir)/ruby_atomic.h
+tcpsocket.o: $(top_srcdir)/rubyparser.h
tcpsocket.o: $(top_srcdir)/shape.h
+tcpsocket.o: $(top_srcdir)/thread_pthread.h
+tcpsocket.o: $(top_srcdir)/vm_core.h
+tcpsocket.o: $(top_srcdir)/vm_opts.h
tcpsocket.o: constdefs.h
tcpsocket.o: rubysocket.h
tcpsocket.o: sockport.h
tcpsocket.o: tcpsocket.c
+tcpsocket.o: {$(VPATH)}id.h
udpsocket.o: $(RUBY_EXTCONF_H)
udpsocket.o: $(arch_hdrdir)/ruby/config.h
udpsocket.o: $(hdrdir)/ruby/assert.h
+udpsocket.o: $(hdrdir)/ruby/atomic.h
udpsocket.o: $(hdrdir)/ruby/backward.h
udpsocket.o: $(hdrdir)/ruby/backward/2/assume.h
udpsocket.o: $(hdrdir)/ruby/backward/2/attributes.h
@@ -2370,6 +2575,7 @@ udpsocket.o: $(hdrdir)/ruby/internal/attr/noexcept.h
udpsocket.o: $(hdrdir)/ruby/internal/attr/noinline.h
udpsocket.o: $(hdrdir)/ruby/internal/attr/nonnull.h
udpsocket.o: $(hdrdir)/ruby/internal/attr/noreturn.h
+udpsocket.o: $(hdrdir)/ruby/internal/attr/packed_struct.h
udpsocket.o: $(hdrdir)/ruby/internal/attr/pure.h
udpsocket.o: $(hdrdir)/ruby/internal/attr/restrict.h
udpsocket.o: $(hdrdir)/ruby/internal/attr/returns_nonnull.h
@@ -2438,7 +2644,6 @@ udpsocket.o: $(hdrdir)/ruby/internal/intern/enumerator.h
udpsocket.o: $(hdrdir)/ruby/internal/intern/error.h
udpsocket.o: $(hdrdir)/ruby/internal/intern/eval.h
udpsocket.o: $(hdrdir)/ruby/internal/intern/file.h
-udpsocket.o: $(hdrdir)/ruby/internal/intern/gc.h
udpsocket.o: $(hdrdir)/ruby/internal/intern/hash.h
udpsocket.o: $(hdrdir)/ruby/internal/intern/io.h
udpsocket.o: $(hdrdir)/ruby/internal/intern/load.h
@@ -2469,7 +2674,6 @@ udpsocket.o: $(hdrdir)/ruby/internal/memory.h
udpsocket.o: $(hdrdir)/ruby/internal/method.h
udpsocket.o: $(hdrdir)/ruby/internal/module.h
udpsocket.o: $(hdrdir)/ruby/internal/newobj.h
-udpsocket.o: $(hdrdir)/ruby/internal/rgengc.h
udpsocket.o: $(hdrdir)/ruby/internal/scan_args.h
udpsocket.o: $(hdrdir)/ruby/internal/special_consts.h
udpsocket.o: $(hdrdir)/ruby/internal/static_assert.h
@@ -2489,12 +2693,20 @@ udpsocket.o: $(hdrdir)/ruby/ruby.h
udpsocket.o: $(hdrdir)/ruby/st.h
udpsocket.o: $(hdrdir)/ruby/subst.h
udpsocket.o: $(hdrdir)/ruby/thread.h
+udpsocket.o: $(hdrdir)/ruby/thread_native.h
udpsocket.o: $(hdrdir)/ruby/util.h
+udpsocket.o: $(hdrdir)/ruby/version.h
+udpsocket.o: $(top_srcdir)/ccan/check_type/check_type.h
+udpsocket.o: $(top_srcdir)/ccan/container_of/container_of.h
+udpsocket.o: $(top_srcdir)/ccan/list/list.h
+udpsocket.o: $(top_srcdir)/ccan/str/str.h
udpsocket.o: $(top_srcdir)/internal.h
udpsocket.o: $(top_srcdir)/internal/array.h
+udpsocket.o: $(top_srcdir)/internal/basic_operators.h
udpsocket.o: $(top_srcdir)/internal/compilers.h
udpsocket.o: $(top_srcdir)/internal/error.h
udpsocket.o: $(top_srcdir)/internal/gc.h
+udpsocket.o: $(top_srcdir)/internal/imemo.h
udpsocket.o: $(top_srcdir)/internal/io.h
udpsocket.o: $(top_srcdir)/internal/serial.h
udpsocket.o: $(top_srcdir)/internal/static_assert.h
@@ -2502,14 +2714,24 @@ udpsocket.o: $(top_srcdir)/internal/string.h
udpsocket.o: $(top_srcdir)/internal/thread.h
udpsocket.o: $(top_srcdir)/internal/vm.h
udpsocket.o: $(top_srcdir)/internal/warnings.h
+udpsocket.o: $(top_srcdir)/method.h
+udpsocket.o: $(top_srcdir)/node.h
+udpsocket.o: $(top_srcdir)/ruby_assert.h
+udpsocket.o: $(top_srcdir)/ruby_atomic.h
+udpsocket.o: $(top_srcdir)/rubyparser.h
udpsocket.o: $(top_srcdir)/shape.h
+udpsocket.o: $(top_srcdir)/thread_pthread.h
+udpsocket.o: $(top_srcdir)/vm_core.h
+udpsocket.o: $(top_srcdir)/vm_opts.h
udpsocket.o: constdefs.h
udpsocket.o: rubysocket.h
udpsocket.o: sockport.h
udpsocket.o: udpsocket.c
+udpsocket.o: {$(VPATH)}id.h
unixserver.o: $(RUBY_EXTCONF_H)
unixserver.o: $(arch_hdrdir)/ruby/config.h
unixserver.o: $(hdrdir)/ruby/assert.h
+unixserver.o: $(hdrdir)/ruby/atomic.h
unixserver.o: $(hdrdir)/ruby/backward.h
unixserver.o: $(hdrdir)/ruby/backward/2/assume.h
unixserver.o: $(hdrdir)/ruby/backward/2/attributes.h
@@ -2562,6 +2784,7 @@ unixserver.o: $(hdrdir)/ruby/internal/attr/noexcept.h
unixserver.o: $(hdrdir)/ruby/internal/attr/noinline.h
unixserver.o: $(hdrdir)/ruby/internal/attr/nonnull.h
unixserver.o: $(hdrdir)/ruby/internal/attr/noreturn.h
+unixserver.o: $(hdrdir)/ruby/internal/attr/packed_struct.h
unixserver.o: $(hdrdir)/ruby/internal/attr/pure.h
unixserver.o: $(hdrdir)/ruby/internal/attr/restrict.h
unixserver.o: $(hdrdir)/ruby/internal/attr/returns_nonnull.h
@@ -2630,7 +2853,6 @@ unixserver.o: $(hdrdir)/ruby/internal/intern/enumerator.h
unixserver.o: $(hdrdir)/ruby/internal/intern/error.h
unixserver.o: $(hdrdir)/ruby/internal/intern/eval.h
unixserver.o: $(hdrdir)/ruby/internal/intern/file.h
-unixserver.o: $(hdrdir)/ruby/internal/intern/gc.h
unixserver.o: $(hdrdir)/ruby/internal/intern/hash.h
unixserver.o: $(hdrdir)/ruby/internal/intern/io.h
unixserver.o: $(hdrdir)/ruby/internal/intern/load.h
@@ -2661,7 +2883,6 @@ unixserver.o: $(hdrdir)/ruby/internal/memory.h
unixserver.o: $(hdrdir)/ruby/internal/method.h
unixserver.o: $(hdrdir)/ruby/internal/module.h
unixserver.o: $(hdrdir)/ruby/internal/newobj.h
-unixserver.o: $(hdrdir)/ruby/internal/rgengc.h
unixserver.o: $(hdrdir)/ruby/internal/scan_args.h
unixserver.o: $(hdrdir)/ruby/internal/special_consts.h
unixserver.o: $(hdrdir)/ruby/internal/static_assert.h
@@ -2681,12 +2902,20 @@ unixserver.o: $(hdrdir)/ruby/ruby.h
unixserver.o: $(hdrdir)/ruby/st.h
unixserver.o: $(hdrdir)/ruby/subst.h
unixserver.o: $(hdrdir)/ruby/thread.h
+unixserver.o: $(hdrdir)/ruby/thread_native.h
unixserver.o: $(hdrdir)/ruby/util.h
+unixserver.o: $(hdrdir)/ruby/version.h
+unixserver.o: $(top_srcdir)/ccan/check_type/check_type.h
+unixserver.o: $(top_srcdir)/ccan/container_of/container_of.h
+unixserver.o: $(top_srcdir)/ccan/list/list.h
+unixserver.o: $(top_srcdir)/ccan/str/str.h
unixserver.o: $(top_srcdir)/internal.h
unixserver.o: $(top_srcdir)/internal/array.h
+unixserver.o: $(top_srcdir)/internal/basic_operators.h
unixserver.o: $(top_srcdir)/internal/compilers.h
unixserver.o: $(top_srcdir)/internal/error.h
unixserver.o: $(top_srcdir)/internal/gc.h
+unixserver.o: $(top_srcdir)/internal/imemo.h
unixserver.o: $(top_srcdir)/internal/io.h
unixserver.o: $(top_srcdir)/internal/serial.h
unixserver.o: $(top_srcdir)/internal/static_assert.h
@@ -2694,14 +2923,24 @@ unixserver.o: $(top_srcdir)/internal/string.h
unixserver.o: $(top_srcdir)/internal/thread.h
unixserver.o: $(top_srcdir)/internal/vm.h
unixserver.o: $(top_srcdir)/internal/warnings.h
+unixserver.o: $(top_srcdir)/method.h
+unixserver.o: $(top_srcdir)/node.h
+unixserver.o: $(top_srcdir)/ruby_assert.h
+unixserver.o: $(top_srcdir)/ruby_atomic.h
+unixserver.o: $(top_srcdir)/rubyparser.h
unixserver.o: $(top_srcdir)/shape.h
+unixserver.o: $(top_srcdir)/thread_pthread.h
+unixserver.o: $(top_srcdir)/vm_core.h
+unixserver.o: $(top_srcdir)/vm_opts.h
unixserver.o: constdefs.h
unixserver.o: rubysocket.h
unixserver.o: sockport.h
unixserver.o: unixserver.c
+unixserver.o: {$(VPATH)}id.h
unixsocket.o: $(RUBY_EXTCONF_H)
unixsocket.o: $(arch_hdrdir)/ruby/config.h
unixsocket.o: $(hdrdir)/ruby/assert.h
+unixsocket.o: $(hdrdir)/ruby/atomic.h
unixsocket.o: $(hdrdir)/ruby/backward.h
unixsocket.o: $(hdrdir)/ruby/backward/2/assume.h
unixsocket.o: $(hdrdir)/ruby/backward/2/attributes.h
@@ -2754,6 +2993,7 @@ unixsocket.o: $(hdrdir)/ruby/internal/attr/noexcept.h
unixsocket.o: $(hdrdir)/ruby/internal/attr/noinline.h
unixsocket.o: $(hdrdir)/ruby/internal/attr/nonnull.h
unixsocket.o: $(hdrdir)/ruby/internal/attr/noreturn.h
+unixsocket.o: $(hdrdir)/ruby/internal/attr/packed_struct.h
unixsocket.o: $(hdrdir)/ruby/internal/attr/pure.h
unixsocket.o: $(hdrdir)/ruby/internal/attr/restrict.h
unixsocket.o: $(hdrdir)/ruby/internal/attr/returns_nonnull.h
@@ -2822,7 +3062,6 @@ unixsocket.o: $(hdrdir)/ruby/internal/intern/enumerator.h
unixsocket.o: $(hdrdir)/ruby/internal/intern/error.h
unixsocket.o: $(hdrdir)/ruby/internal/intern/eval.h
unixsocket.o: $(hdrdir)/ruby/internal/intern/file.h
-unixsocket.o: $(hdrdir)/ruby/internal/intern/gc.h
unixsocket.o: $(hdrdir)/ruby/internal/intern/hash.h
unixsocket.o: $(hdrdir)/ruby/internal/intern/io.h
unixsocket.o: $(hdrdir)/ruby/internal/intern/load.h
@@ -2853,7 +3092,6 @@ unixsocket.o: $(hdrdir)/ruby/internal/memory.h
unixsocket.o: $(hdrdir)/ruby/internal/method.h
unixsocket.o: $(hdrdir)/ruby/internal/module.h
unixsocket.o: $(hdrdir)/ruby/internal/newobj.h
-unixsocket.o: $(hdrdir)/ruby/internal/rgengc.h
unixsocket.o: $(hdrdir)/ruby/internal/scan_args.h
unixsocket.o: $(hdrdir)/ruby/internal/special_consts.h
unixsocket.o: $(hdrdir)/ruby/internal/static_assert.h
@@ -2873,12 +3111,20 @@ unixsocket.o: $(hdrdir)/ruby/ruby.h
unixsocket.o: $(hdrdir)/ruby/st.h
unixsocket.o: $(hdrdir)/ruby/subst.h
unixsocket.o: $(hdrdir)/ruby/thread.h
+unixsocket.o: $(hdrdir)/ruby/thread_native.h
unixsocket.o: $(hdrdir)/ruby/util.h
+unixsocket.o: $(hdrdir)/ruby/version.h
+unixsocket.o: $(top_srcdir)/ccan/check_type/check_type.h
+unixsocket.o: $(top_srcdir)/ccan/container_of/container_of.h
+unixsocket.o: $(top_srcdir)/ccan/list/list.h
+unixsocket.o: $(top_srcdir)/ccan/str/str.h
unixsocket.o: $(top_srcdir)/internal.h
unixsocket.o: $(top_srcdir)/internal/array.h
+unixsocket.o: $(top_srcdir)/internal/basic_operators.h
unixsocket.o: $(top_srcdir)/internal/compilers.h
unixsocket.o: $(top_srcdir)/internal/error.h
unixsocket.o: $(top_srcdir)/internal/gc.h
+unixsocket.o: $(top_srcdir)/internal/imemo.h
unixsocket.o: $(top_srcdir)/internal/io.h
unixsocket.o: $(top_srcdir)/internal/serial.h
unixsocket.o: $(top_srcdir)/internal/static_assert.h
@@ -2886,9 +3132,18 @@ unixsocket.o: $(top_srcdir)/internal/string.h
unixsocket.o: $(top_srcdir)/internal/thread.h
unixsocket.o: $(top_srcdir)/internal/vm.h
unixsocket.o: $(top_srcdir)/internal/warnings.h
+unixsocket.o: $(top_srcdir)/method.h
+unixsocket.o: $(top_srcdir)/node.h
+unixsocket.o: $(top_srcdir)/ruby_assert.h
+unixsocket.o: $(top_srcdir)/ruby_atomic.h
+unixsocket.o: $(top_srcdir)/rubyparser.h
unixsocket.o: $(top_srcdir)/shape.h
+unixsocket.o: $(top_srcdir)/thread_pthread.h
+unixsocket.o: $(top_srcdir)/vm_core.h
+unixsocket.o: $(top_srcdir)/vm_opts.h
unixsocket.o: constdefs.h
unixsocket.o: rubysocket.h
unixsocket.o: sockport.h
unixsocket.o: unixsocket.c
+unixsocket.o: {$(VPATH)}id.h
# AUTOGENERATED DEPENDENCIES END
diff --git a/ext/socket/extconf.rb b/ext/socket/extconf.rb
index 4ca0983c68..d44ce31b0a 100644
--- a/ext/socket/extconf.rb
+++ b/ext/socket/extconf.rb
@@ -327,6 +327,8 @@ end
net/if_dl.h
arpa/nameser.h
resolv.h
+ pthread.h
+ sched.h
].each {|h|
if have_header(h, headers)
headers << h
@@ -699,5 +701,10 @@ SRC
"not needed"
end
end
+
+ have_func("pthread_create")
+ have_func("pthread_detach")
+
+ $VPATH << '$(topdir)' << '$(top_srcdir)'
create_makefile("socket")
end
diff --git a/ext/socket/getaddrinfo.c b/ext/socket/getaddrinfo.c
index 95a2feb3be..bf0d90129f 100644
--- a/ext/socket/getaddrinfo.c
+++ b/ext/socket/getaddrinfo.c
@@ -219,8 +219,7 @@ freeaddrinfo(struct addrinfo *ai)
do {
next = ai->ai_next;
- if (ai->ai_canonname)
- free(ai->ai_canonname);
+ free(ai->ai_canonname);
/* no need to free(ai->ai_addr) */
free(ai);
} while ((ai = next) != NULL);
diff --git a/ext/socket/init.c b/ext/socket/init.c
index 557d4374a5..dd1158e19d 100644
--- a/ext/socket/init.c
+++ b/ext/socket/init.c
@@ -27,6 +27,7 @@ VALUE rb_cSocket;
VALUE rb_cAddrinfo;
VALUE rb_eSocket;
+VALUE rb_eResolution;
#ifdef SOCKS
VALUE rb_cSOCKSSocket;
@@ -34,9 +35,10 @@ VALUE rb_cSOCKSSocket;
int rsock_do_not_reverse_lookup = 1;
static VALUE sym_wait_readable;
+static ID id_error_code;
void
-rsock_raise_socket_error(const char *reason, int error)
+rsock_raise_resolution_error(const char *reason, int error)
{
#ifdef EAI_SYSTEM
int e;
@@ -48,10 +50,14 @@ rsock_raise_socket_error(const char *reason, int error)
VALUE msg = rb_sprintf("%s: ", reason);
if (!enc) enc = rb_default_internal_encoding();
rb_str_concat(msg, rb_w32_conv_from_wchar(gai_strerrorW(error), enc));
- rb_exc_raise(rb_exc_new_str(rb_eSocket, msg));
#else
- rb_raise(rb_eSocket, "%s: %s", reason, gai_strerror(error));
+ VALUE msg = rb_sprintf("%s: %s", reason, gai_strerror(error));
#endif
+
+ StringValue(msg);
+ VALUE self = rb_class_new_instance(1, &msg, rb_eResolution);
+ rb_ivar_set(self, id_error_code, INT2NUM(error));
+ rb_exc_raise(self);
}
#if defined __APPLE__
@@ -116,6 +122,7 @@ recvfrom_blocking(void *data)
ssize_t ret;
ret = recvfrom(arg->fd, RSTRING_PTR(arg->str), arg->length,
arg->flags, &arg->buf.addr, &arg->alen);
+
if (ret != -1 && len0 < arg->alen)
arg->alen = len0;
@@ -147,6 +154,18 @@ recvfrom_locktmp(VALUE v)
return rb_thread_io_blocking_region(recvfrom_blocking, arg, arg->fd);
}
+int
+rsock_is_dgram(rb_io_t *fptr)
+{
+ int socktype;
+ socklen_t optlen = (socklen_t)sizeof(socktype);
+ int ret = getsockopt(fptr->fd, SOL_SOCKET, SO_TYPE, (void*)&socktype, &optlen);
+ if (ret == -1) {
+ rb_sys_fail("getsockopt(SO_TYPE)");
+ }
+ return socktype == SOCK_DGRAM;
+}
+
VALUE
rsock_s_recvfrom(VALUE socket, int argc, VALUE *argv, enum sock_recv_type from)
{
@@ -187,6 +206,9 @@ rsock_s_recvfrom(VALUE socket, int argc, VALUE *argv, enum sock_recv_type from)
slen = (long)rb_str_locktmp_ensure(str, recvfrom_locktmp, (VALUE)&arg);
+ if (slen == 0 && !rsock_is_dgram(fptr)) {
+ return Qnil;
+ }
if (slen >= 0) break;
if (!rb_io_maybe_wait_readable(errno, socket, RUBY_IO_TIMEOUT_DEFAULT))
@@ -259,6 +281,10 @@ rsock_s_recvfrom_nonblock(VALUE sock, VALUE len, VALUE flg, VALUE str,
if (slen != -1 && len0 < alen)
alen = len0;
+ if (slen == 0 && !rsock_is_dgram(fptr)) {
+ return Qnil;
+ }
+
if (slen < 0) {
int e = errno;
switch (e) {
@@ -392,7 +418,7 @@ rsock_write_nonblock(VALUE sock, VALUE str, VALUE ex)
if (e == EWOULDBLOCK || e == EAGAIN) {
if (ex == Qfalse) return sym_wait_writable;
rb_readwrite_syserr_fail(RB_IO_WAIT_WRITABLE, e,
- "write would block");
+ "write would block");
}
rb_syserr_fail_path(e, fptr->pathv);
}
@@ -433,9 +459,9 @@ rsock_socket(int domain, int type, int proto)
fd = rsock_socket0(domain, type, proto);
if (fd < 0) {
- if (rb_gc_for_fd(errno)) {
- fd = rsock_socket0(domain, type, proto);
- }
+ if (rb_gc_for_fd(errno)) {
+ fd = rsock_socket0(domain, type, proto);
+ }
}
if (0 <= fd)
rb_update_max_fd(fd);
@@ -492,10 +518,10 @@ wait_connectable(int fd, struct timeval *timeout)
switch (sockerr) {
case 0:
- /*
- * be defensive in case some platforms set SO_ERROR on the original,
- * interrupted connect()
- */
+ /*
+ * be defensive in case some platforms set SO_ERROR on the original,
+ * interrupted connect()
+ */
/* when the connection timed out, no errno is set and revents is 0. */
if (timeout && revents == 0) {
@@ -681,9 +707,9 @@ rsock_s_accept(VALUE klass, VALUE io, struct sockaddr *sockaddr, socklen_t *len)
RB_IO_POINTER(io, fptr);
struct accept_arg accept_arg = {
- .fd = fptr->fd,
- .sockaddr = sockaddr,
- .len = len
+ .fd = fptr->fd,
+ .sockaddr = sockaddr,
+ .len = len
};
int retry = 0, peer;
@@ -730,10 +756,10 @@ rsock_getfamily(rb_io_t *fptr)
if (cached) {
switch (cached) {
#ifdef AF_UNIX
- case FMODE_UNIX: return AF_UNIX;
+ case FMODE_UNIX: return AF_UNIX;
#endif
- case FMODE_INET: return AF_INET;
- case FMODE_INET6: return AF_INET6;
+ case FMODE_INET: return AF_INET;
+ case FMODE_INET6: return AF_INET6;
}
}
@@ -752,6 +778,18 @@ rsock_getfamily(rb_io_t *fptr)
return ss.addr.sa_family;
}
+/*
+ * call-seq:
+ * error_code -> integer
+ *
+ * Returns the raw error code occurred at name resolution.
+ */
+static VALUE
+sock_resolv_error_code(VALUE self)
+{
+ return rb_attr_get(self, id_error_code);
+}
+
void
rsock_init_socket_init(void)
{
@@ -759,6 +797,11 @@ rsock_init_socket_init(void)
* SocketError is the error class for socket.
*/
rb_eSocket = rb_define_class("SocketError", rb_eStandardError);
+ /*
+ * ResolutionError is the error class for socket name resolution.
+ */
+ rb_eResolution = rb_define_class_under(rb_cSocket, "ResolutionError", rb_eSocket);
+ rb_define_method(rb_eResolution, "error_code", sock_resolv_error_code, 0);
rsock_init_ipsocket();
rsock_init_tcpsocket();
rsock_init_tcpserver();
@@ -772,6 +815,8 @@ rsock_init_socket_init(void)
rsock_init_sockifaddr();
rsock_init_socket_constants();
+ id_error_code = rb_intern_const("error_code");
+
#undef rb_intern
sym_wait_readable = ID2SYM(rb_intern("wait_readable"));
diff --git a/ext/socket/lib/socket.rb b/ext/socket/lib/socket.rb
index eecdc7d4b8..de542223c6 100644
--- a/ext/socket/lib/socket.rb
+++ b/ext/socket/lib/socket.rb
@@ -333,9 +333,10 @@ class BasicSocket < IO
# _flags_ is zero or more of the +MSG_+ options.
# The result, _mesg_, is the data received.
#
- # When recvfrom(2) returns 0, Socket#recv_nonblock returns
- # an empty string as data.
- # The meaning depends on the socket: EOF on TCP, empty packet on UDP, etc.
+ # When recvfrom(2) returns 0, Socket#recv_nonblock returns nil.
+ # In most cases it means the connection was closed, but for UDP connections
+ # it may mean an empty packet was received, as the underlying API makes
+ # it impossible to distinguish these two cases.
#
# === Parameters
# * +maxlen+ - the number of bytes to receive from the socket
@@ -480,9 +481,10 @@ class Socket < BasicSocket
# The second element, _sender_addrinfo_, contains protocol-specific address
# information of the sender.
#
- # When recvfrom(2) returns 0, Socket#recvfrom_nonblock returns
- # an empty string as data.
- # The meaning depends on the socket: EOF on TCP, empty packet on UDP, etc.
+ # When recvfrom(2) returns 0, Socket#recv_nonblock returns nil.
+ # In most cases it means the connection was closed, but for UDP connections
+ # it may mean an empty packet was received, as the underlying API makes
+ # it impossible to distinguish these two cases.
#
# === Parameters
# * +maxlen+ - the maximum number of bytes to receive from the socket
@@ -1229,9 +1231,10 @@ class UDPSocket < IPSocket
# The first element of the results, _mesg_, is the data received.
# The second element, _sender_inet_addr_, is an array to represent the sender address.
#
- # When recvfrom(2) returns 0,
- # Socket#recvfrom_nonblock returns an empty string as data.
- # It means an empty packet.
+ # When recvfrom(2) returns 0, Socket#recv_nonblock returns nil.
+ # In most cases it means the connection was closed, but it may also mean
+ # an empty packet was received, as the underlying API makes
+ # it impossible to distinguish these two cases.
#
# === Parameters
# * +maxlen+ - the number of bytes to receive from the socket
diff --git a/ext/socket/mkconstants.rb b/ext/socket/mkconstants.rb
index 5e6c0668f6..ba7a55b426 100644
--- a/ext/socket/mkconstants.rb
+++ b/ext/socket/mkconstants.rb
@@ -51,7 +51,10 @@ DATA.each_line {|s|
next
end
h[name] = default_value
- COMMENTS[name] = comment
+ if comment
+ # Stop unintentional references
+ COMMENTS[name] = comment.gsub(/\b(Data|Kernel|Process|Set|Socket|Time)\b/, '\\\\\\&')
+ end
}
DEFS = h.to_a
@@ -423,8 +426,8 @@ AF_ISDN nil Integrated Services Digital Network
PF_ISDN nil Integrated Services Digital Network
AF_NATM nil Native ATM access
PF_NATM nil Native ATM access
-AF_SYSTEM
-PF_SYSTEM
+AF_SYSTEM nil Kernel event messages
+PF_SYSTEM nil Kernel event messages
AF_NETBIOS nil NetBIOS
PF_NETBIOS nil NetBIOS
AF_PPP nil Point-to-Point Protocol
@@ -440,8 +443,8 @@ PF_PACKET nil Direct link-layer access
AF_E164 nil CCITT (ITU-T) E.164 recommendation
PF_XTP nil eXpress Transfer Protocol
-PF_RTIP
-PF_PIP
+PF_RTIP nil Help Identify RTIP packets
+PF_PIP nil Help Identify PIP packets
AF_KEY nil Key management protocol, originally developed for usage with IPsec
PF_KEY nil Key management protocol, originally developed for usage with IPsec
AF_NETLINK nil Kernel user interface device
diff --git a/ext/socket/raddrinfo.c b/ext/socket/raddrinfo.c
index 269edc4dad..cdb785f268 100644
--- a/ext/socket/raddrinfo.c
+++ b/ext/socket/raddrinfo.c
@@ -10,6 +10,22 @@
#include "rubysocket.h"
+// GETADDRINFO_IMPL == 0 : call getaddrinfo/getnameinfo directly
+// GETADDRINFO_IMPL == 1 : call getaddrinfo/getnameinfo without gvl (but uncancellable)
+// GETADDRINFO_IMPL == 2 : call getaddrinfo/getnameinfo in a dedicated pthread
+// (and if the call is interrupted, the pthread is detached)
+
+#ifndef GETADDRINFO_IMPL
+# ifdef GETADDRINFO_EMU
+# define GETADDRINFO_IMPL 0
+# elif !defined(HAVE_PTHREAD_CREATE) || !defined(HAVE_PTHREAD_DETACH) || defined(__MINGW32__) || defined(__MINGW64__)
+# define GETADDRINFO_IMPL 1
+# else
+# define GETADDRINFO_IMPL 2
+# include "ruby/thread_native.h"
+# endif
+#endif
+
#if defined(INET6) && (defined(LOOKUP_ORDER_HACK_INET) || defined(LOOKUP_ORDER_HACK_INET6))
#define LOOKUP_ORDERS (sizeof(lookup_order_table) / sizeof(lookup_order_table[0]))
static const int lookup_order_table[] = {
@@ -173,32 +189,6 @@ parse_numeric_port(const char *service, int *portp)
}
#endif
-#ifndef GETADDRINFO_EMU
-struct getaddrinfo_arg
-{
- const char *node;
- const char *service;
- const struct addrinfo *hints;
- struct addrinfo **res;
-};
-
-static void *
-nogvl_getaddrinfo(void *arg)
-{
- int ret;
- struct getaddrinfo_arg *ptr = arg;
- ret = getaddrinfo(ptr->node, ptr->service, ptr->hints, ptr->res);
-#ifdef __linux__
- /* On Linux (mainly Ubuntu 13.04) /etc/nsswitch.conf has mdns4 and
- * it cause getaddrinfo to return EAI_SYSTEM/ENOENT. [ruby-list:49420]
- */
- if (ret == EAI_SYSTEM && errno == ENOENT)
- ret = EAI_NONAME;
-#endif
- return (void *)(VALUE)ret;
-}
-#endif
-
static int
numeric_getaddrinfo(const char *node, const char *service,
const struct addrinfo *hints,
@@ -302,7 +292,263 @@ rb_freeaddrinfo(struct rb_addrinfo *ai)
xfree(ai);
}
-#ifndef GETADDRINFO_EMU
+#if GETADDRINFO_IMPL == 0
+
+static int
+rb_getaddrinfo(const char *hostp, const char *portp, const struct addrinfo *hints, struct addrinfo **ai)
+{
+ return getaddrinfo(hostp, portp, hints, ai);
+}
+
+#elif GETADDRINFO_IMPL == 1
+
+struct getaddrinfo_arg
+{
+ const char *node;
+ const char *service;
+ const struct addrinfo *hints;
+ struct addrinfo **res;
+};
+
+static void *
+nogvl_getaddrinfo(void *arg)
+{
+ int ret;
+ struct getaddrinfo_arg *ptr = arg;
+ ret = getaddrinfo(ptr->node, ptr->service, ptr->hints, ptr->res);
+#ifdef __linux__
+ /* On Linux (mainly Ubuntu 13.04) /etc/nsswitch.conf has mdns4 and
+ * it cause getaddrinfo to return EAI_SYSTEM/ENOENT. [ruby-list:49420]
+ */
+ if (ret == EAI_SYSTEM && errno == ENOENT)
+ ret = EAI_NONAME;
+#endif
+ return (void *)(VALUE)ret;
+}
+
+static int
+rb_getaddrinfo(const char *hostp, const char *portp, const struct addrinfo *hints, struct addrinfo **ai)
+{
+ struct getaddrinfo_arg arg;
+ MEMZERO(&arg, struct getaddrinfo_arg, 1);
+ arg.node = hostp;
+ arg.service = portp;
+ arg.hints = hints;
+ arg.res = ai;
+ return (int)(VALUE)rb_thread_call_without_gvl(nogvl_getaddrinfo, &arg, RUBY_UBF_IO, 0);
+}
+
+#elif GETADDRINFO_IMPL == 2
+
+struct getaddrinfo_arg
+{
+ char *node, *service;
+ struct addrinfo hints;
+ struct addrinfo *ai;
+ int err, gai_errno, refcount, done, cancelled;
+ rb_nativethread_lock_t lock;
+ rb_nativethread_cond_t cond;
+};
+
+static struct getaddrinfo_arg *
+allocate_getaddrinfo_arg(const char *hostp, const char *portp, const struct addrinfo *hints)
+{
+ size_t hostp_offset = sizeof(struct getaddrinfo_arg);
+ size_t portp_offset = hostp_offset + (hostp ? strlen(hostp) + 1 : 0);
+ size_t bufsize = portp_offset + (portp ? strlen(portp) + 1 : 0);
+
+ char *buf = malloc(bufsize);
+ if (!buf) {
+ rb_gc();
+ buf = malloc(bufsize);
+ if (!buf) return NULL;
+ }
+ struct getaddrinfo_arg *arg = (struct getaddrinfo_arg *)buf;
+
+ if (hostp) {
+ arg->node = buf + hostp_offset;
+ strcpy(arg->node, hostp);
+ }
+ else {
+ arg->node = NULL;
+ }
+
+ if (portp) {
+ arg->service = buf + portp_offset;
+ strcpy(arg->service, portp);
+ }
+ else {
+ arg->service = NULL;
+ }
+
+ arg->hints = *hints;
+ arg->ai = NULL;
+
+ arg->refcount = 2;
+ arg->done = arg->cancelled = 0;
+
+ rb_nativethread_lock_initialize(&arg->lock);
+ rb_native_cond_initialize(&arg->cond);
+
+ return arg;
+}
+
+static void
+free_getaddrinfo_arg(struct getaddrinfo_arg *arg)
+{
+ rb_native_cond_destroy(&arg->cond);
+ rb_nativethread_lock_destroy(&arg->lock);
+ free(arg);
+}
+
+static void *
+do_getaddrinfo(void *ptr)
+{
+ struct getaddrinfo_arg *arg = (struct getaddrinfo_arg *)ptr;
+
+ int err, gai_errno;
+ err = getaddrinfo(arg->node, arg->service, &arg->hints, &arg->ai);
+ gai_errno = errno;
+#ifdef __linux__
+ /* On Linux (mainly Ubuntu 13.04) /etc/nsswitch.conf has mdns4 and
+ * it cause getaddrinfo to return EAI_SYSTEM/ENOENT. [ruby-list:49420]
+ */
+ if (err == EAI_SYSTEM && errno == ENOENT)
+ err = EAI_NONAME;
+#endif
+
+ int need_free = 0;
+ rb_nativethread_lock_lock(&arg->lock);
+ {
+ arg->err = err;
+ arg->gai_errno = gai_errno;
+ if (arg->cancelled) {
+ freeaddrinfo(arg->ai);
+ }
+ else {
+ arg->done = 1;
+ rb_native_cond_signal(&arg->cond);
+ }
+ if (--arg->refcount == 0) need_free = 1;
+ }
+ rb_nativethread_lock_unlock(&arg->lock);
+
+ if (need_free) free_getaddrinfo_arg(arg);
+
+ return 0;
+}
+
+static void *
+wait_getaddrinfo(void *ptr)
+{
+ struct getaddrinfo_arg *arg = (struct getaddrinfo_arg *)ptr;
+ rb_nativethread_lock_lock(&arg->lock);
+ while (!arg->done && !arg->cancelled) {
+ rb_native_cond_wait(&arg->cond, &arg->lock);
+ }
+ rb_nativethread_lock_unlock(&arg->lock);
+ return 0;
+}
+
+static void
+cancel_getaddrinfo(void *ptr)
+{
+ struct getaddrinfo_arg *arg = (struct getaddrinfo_arg *)ptr;
+ rb_nativethread_lock_lock(&arg->lock);
+ {
+ arg->cancelled = 1;
+ rb_native_cond_signal(&arg->cond);
+ }
+ rb_nativethread_lock_unlock(&arg->lock);
+}
+
+static int
+do_pthread_create(pthread_t *th, void *(*start_routine) (void *), void *arg)
+{
+ int limit = 3, ret;
+ do {
+ // It is said that pthread_create may fail spuriously, so we follow the JDK and retry several times.
+ //
+ // https://bugs.openjdk.org/browse/JDK-8268605
+ // https://github.com/openjdk/jdk/commit/e35005d5ce383ddd108096a3079b17cb0bcf76f1
+ ret = pthread_create(th, 0, start_routine, arg);
+ } while (ret == EAGAIN && limit-- > 0);
+ return ret;
+}
+
+static int
+rb_getaddrinfo(const char *hostp, const char *portp, const struct addrinfo *hints, struct addrinfo **ai)
+{
+ int retry;
+ struct getaddrinfo_arg *arg;
+ int err, gai_errno;
+
+start:
+ retry = 0;
+
+ arg = allocate_getaddrinfo_arg(hostp, portp, hints);
+ if (!arg) {
+ return EAI_MEMORY;
+ }
+
+ pthread_t th;
+ if (do_pthread_create(&th, do_getaddrinfo, arg) != 0) {
+ free_getaddrinfo_arg(arg);
+ return EAI_AGAIN;
+ }
+ pthread_detach(th);
+
+ rb_thread_call_without_gvl2(wait_getaddrinfo, arg, cancel_getaddrinfo, arg);
+
+ int need_free = 0;
+ rb_nativethread_lock_lock(&arg->lock);
+ {
+ if (arg->done) {
+ err = arg->err;
+ gai_errno = arg->gai_errno;
+ if (err == 0) *ai = arg->ai;
+ }
+ else if (arg->cancelled) {
+ err = EAI_AGAIN;
+ }
+ else {
+ // If already interrupted, rb_thread_call_without_gvl2 may return without calling wait_getaddrinfo.
+ // In this case, it could be !arg->done && !arg->cancelled.
+ arg->cancelled = 1; // to make do_getaddrinfo call freeaddrinfo
+ retry = 1;
+ }
+ if (--arg->refcount == 0) need_free = 1;
+ }
+ rb_nativethread_lock_unlock(&arg->lock);
+
+ if (need_free) free_getaddrinfo_arg(arg);
+
+ // If the current thread is interrupted by asynchronous exception, the following raises the exception.
+ // But if the current thread is interrupted by timer thread, the following returns; we need to manually retry.
+ rb_thread_check_ints();
+ if (retry) goto start;
+
+ /* Because errno is threadlocal, the errno value we got from the call to getaddrinfo() in the thread
+ * (in case of EAI_SYSTEM return value) is not propagated to the caller of _this_ function. Set errno
+ * explicitly, as round-tripped through struct getaddrinfo_arg, to deal with that */
+ errno = gai_errno;
+ return err;
+}
+
+#endif
+
+#if GETADDRINFO_IMPL == 0
+
+int
+rb_getnameinfo(const struct sockaddr *sa, socklen_t salen,
+ char *host, size_t hostlen,
+ char *serv, size_t servlen, int flags)
+{
+ return getnameinfo(sa, salen, host, hostlen, serv, servlen, flags);
+}
+
+#elif GETADDRINFO_IMPL == 1
+
struct getnameinfo_arg
{
const struct sockaddr *sa;
@@ -323,16 +569,11 @@ nogvl_getnameinfo(void *arg)
ptr->serv, (socklen_t)ptr->servlen,
ptr->flags);
}
-#endif
-
int
rb_getnameinfo(const struct sockaddr *sa, socklen_t salen,
- char *host, size_t hostlen,
- char *serv, size_t servlen, int flags)
+ char *host, size_t hostlen,
+ char *serv, size_t servlen, int flags)
{
-#ifdef GETADDRINFO_EMU
- return getnameinfo(sa, salen, host, hostlen, serv, servlen, flags);
-#else
struct getnameinfo_arg arg;
int ret;
arg.sa = sa;
@@ -344,17 +585,185 @@ rb_getnameinfo(const struct sockaddr *sa, socklen_t salen,
arg.flags = flags;
ret = (int)(VALUE)rb_thread_call_without_gvl(nogvl_getnameinfo, &arg, RUBY_UBF_IO, 0);
return ret;
-#endif
+}
+
+#elif GETADDRINFO_IMPL == 2
+
+struct getnameinfo_arg
+{
+ struct sockaddr *sa;
+ socklen_t salen;
+ int flags;
+ char *host;
+ size_t hostlen;
+ char *serv;
+ size_t servlen;
+ int err, gni_errno, refcount, done, cancelled;
+ rb_nativethread_lock_t lock;
+ rb_nativethread_cond_t cond;
+};
+
+static struct getnameinfo_arg *
+allocate_getnameinfo_arg(const struct sockaddr *sa, socklen_t salen, size_t hostlen, size_t servlen, int flags)
+{
+ size_t sa_offset = sizeof(struct getnameinfo_arg);
+ size_t host_offset = sa_offset + salen;
+ size_t serv_offset = host_offset + hostlen;
+ size_t bufsize = serv_offset + servlen;
+
+ char *buf = malloc(bufsize);
+ if (!buf) {
+ rb_gc();
+ buf = malloc(bufsize);
+ if (!buf) return NULL;
+ }
+ struct getnameinfo_arg *arg = (struct getnameinfo_arg *)buf;
+
+ arg->sa = (struct sockaddr *)(buf + sa_offset);
+ memcpy(arg->sa, sa, salen);
+ arg->salen = salen;
+ arg->host = buf + host_offset;
+ arg->hostlen = hostlen;
+ arg->serv = buf + serv_offset;
+ arg->servlen = servlen;
+ arg->flags = flags;
+
+ arg->refcount = 2;
+ arg->done = arg->cancelled = 0;
+
+ rb_nativethread_lock_initialize(&arg->lock);
+ rb_native_cond_initialize(&arg->cond);
+
+ return arg;
+}
+
+static void
+free_getnameinfo_arg(struct getnameinfo_arg *arg)
+{
+ rb_native_cond_destroy(&arg->cond);
+ rb_nativethread_lock_destroy(&arg->lock);
+
+ free(arg);
+}
+
+static void *
+do_getnameinfo(void *ptr)
+{
+ struct getnameinfo_arg *arg = (struct getnameinfo_arg *)ptr;
+
+ int err, gni_errno;
+ err = getnameinfo(arg->sa, arg->salen, arg->host, (socklen_t)arg->hostlen, arg->serv, (socklen_t)arg->servlen, arg->flags);
+ gni_errno = errno;
+
+ int need_free = 0;
+ rb_nativethread_lock_lock(&arg->lock);
+ arg->err = err;
+ arg->gni_errno = gni_errno;
+ if (!arg->cancelled) {
+ arg->done = 1;
+ rb_native_cond_signal(&arg->cond);
+ }
+ if (--arg->refcount == 0) need_free = 1;
+ rb_nativethread_lock_unlock(&arg->lock);
+
+ if (need_free) free_getnameinfo_arg(arg);
+
+ return 0;
+}
+
+static void *
+wait_getnameinfo(void *ptr)
+{
+ struct getnameinfo_arg *arg = (struct getnameinfo_arg *)ptr;
+ rb_nativethread_lock_lock(&arg->lock);
+ while (!arg->done && !arg->cancelled) {
+ rb_native_cond_wait(&arg->cond, &arg->lock);
+ }
+ rb_nativethread_lock_unlock(&arg->lock);
+ return 0;
}
static void
+cancel_getnameinfo(void *ptr)
+{
+ struct getnameinfo_arg *arg = (struct getnameinfo_arg *)ptr;
+ rb_nativethread_lock_lock(&arg->lock);
+ arg->cancelled = 1;
+ rb_native_cond_signal(&arg->cond);
+ rb_nativethread_lock_unlock(&arg->lock);
+}
+
+int
+rb_getnameinfo(const struct sockaddr *sa, socklen_t salen,
+ char *host, size_t hostlen,
+ char *serv, size_t servlen, int flags)
+{
+ int retry;
+ struct getnameinfo_arg *arg;
+ int err, gni_errno;
+
+start:
+ retry = 0;
+
+ arg = allocate_getnameinfo_arg(sa, salen, hostlen, servlen, flags);
+ if (!arg) {
+ return EAI_MEMORY;
+ }
+
+ pthread_t th;
+ if (do_pthread_create(&th, do_getnameinfo, arg) != 0) {
+ free_getnameinfo_arg(arg);
+ return EAI_AGAIN;
+ }
+ pthread_detach(th);
+
+ rb_thread_call_without_gvl2(wait_getnameinfo, arg, cancel_getnameinfo, arg);
+
+ int need_free = 0;
+ rb_nativethread_lock_lock(&arg->lock);
+ if (arg->done) {
+ err = arg->err;
+ gni_errno = arg->gni_errno;
+ if (err == 0) {
+ if (host) memcpy(host, arg->host, hostlen);
+ if (serv) memcpy(serv, arg->serv, servlen);
+ }
+ }
+ else if (arg->cancelled) {
+ err = EAI_AGAIN;
+ }
+ else {
+ // If already interrupted, rb_thread_call_without_gvl2 may return without calling wait_getnameinfo.
+ // In this case, it could be !arg->done && !arg->cancelled.
+ arg->cancelled = 1;
+ retry = 1;
+ }
+ if (--arg->refcount == 0) need_free = 1;
+ rb_nativethread_lock_unlock(&arg->lock);
+
+ if (need_free) free_getnameinfo_arg(arg);
+
+ // If the current thread is interrupted by asynchronous exception, the following raises the exception.
+ // But if the current thread is interrupted by timer thread, the following returns; we need to manually retry.
+ rb_thread_check_ints();
+ if (retry) goto start;
+
+ /* Make sure we copy the thread-local errno value from the getnameinfo thread back to this thread, so
+ * calling code sees the correct errno */
+ errno = gni_errno;
+ return err;
+}
+
+#endif
+
+static void
make_ipaddr0(struct sockaddr *addr, socklen_t addrlen, char *buf, size_t buflen)
{
int error;
error = rb_getnameinfo(addr, addrlen, buf, buflen, NULL, 0, NI_NUMERICHOST);
if (error) {
- rsock_raise_socket_error("getnameinfo", error);
+ rsock_raise_resolution_error("getnameinfo", error);
}
}
@@ -550,17 +959,7 @@ rsock_getaddrinfo(VALUE host, VALUE port, struct addrinfo *hints, int socktype_h
}
if (!resolved) {
-#ifdef GETADDRINFO_EMU
- error = getaddrinfo(hostp, portp, hints, &ai);
-#else
- struct getaddrinfo_arg arg;
- MEMZERO(&arg, struct getaddrinfo_arg, 1);
- arg.node = hostp;
- arg.service = portp;
- arg.hints = hints;
- arg.res = &ai;
- error = (int)(VALUE)rb_thread_call_without_gvl(nogvl_getaddrinfo, &arg, RUBY_UBF_IO, 0);
-#endif
+ error = rb_getaddrinfo(hostp, portp, hints, &ai);
if (error == 0) {
res = (struct rb_addrinfo *)xmalloc(sizeof(struct rb_addrinfo));
res->allocated_by_malloc = 0;
@@ -573,7 +972,7 @@ rsock_getaddrinfo(VALUE host, VALUE port, struct addrinfo *hints, int socktype_h
if (hostp && hostp[strlen(hostp)-1] == '\n') {
rb_raise(rb_eSocket, "newline at the end of hostname");
}
- rsock_raise_socket_error("getaddrinfo", error);
+ rsock_raise_resolution_error("getaddrinfo", error);
}
return res;
@@ -632,7 +1031,7 @@ rsock_ipaddr(struct sockaddr *sockaddr, socklen_t sockaddrlen, int norevlookup)
error = rb_getnameinfo(sockaddr, sockaddrlen, hbuf, sizeof(hbuf),
pbuf, sizeof(pbuf), NI_NUMERICHOST | NI_NUMERICSERV);
if (error) {
- rsock_raise_socket_error("getnameinfo", error);
+ rsock_raise_resolution_error("getnameinfo", error);
}
addr2 = rb_str_new2(hbuf);
if (addr1 == Qnil) {
@@ -1266,11 +1665,11 @@ rsock_inspect_sockaddr(struct sockaddr *sockaddr_arg, socklen_t socklen, VALUE r
* RFC 4007: IPv6 Scoped Address Architecture
* draft-ietf-ipv6-scope-api-00.txt: Scoped Address Extensions to the IPv6 Basic Socket API
*/
- error = getnameinfo(&sockaddr->addr, socklen,
- hbuf, (socklen_t)sizeof(hbuf), NULL, 0,
- NI_NUMERICHOST|NI_NUMERICSERV);
+ error = rb_getnameinfo(&sockaddr->addr, socklen,
+ hbuf, (socklen_t)sizeof(hbuf), NULL, 0,
+ NI_NUMERICHOST|NI_NUMERICSERV);
if (error) {
- rsock_raise_socket_error("getnameinfo", error);
+ rsock_raise_resolution_error("getnameinfo", error);
}
if (addr->sin6_port == 0) {
rb_str_cat2(ret, hbuf);
@@ -1634,11 +2033,11 @@ addrinfo_mdump(VALUE self)
{
char hbuf[NI_MAXHOST], pbuf[NI_MAXSERV];
int error;
- error = getnameinfo(&rai->addr.addr, rai->sockaddr_len,
- hbuf, (socklen_t)sizeof(hbuf), pbuf, (socklen_t)sizeof(pbuf),
- NI_NUMERICHOST|NI_NUMERICSERV);
+ error = rb_getnameinfo(&rai->addr.addr, rai->sockaddr_len,
+ hbuf, (socklen_t)sizeof(hbuf), pbuf, (socklen_t)sizeof(pbuf),
+ NI_NUMERICHOST|NI_NUMERICSERV);
if (error) {
- rsock_raise_socket_error("getnameinfo", error);
+ rsock_raise_resolution_error("getnameinfo", error);
}
sockaddr = rb_assoc_new(rb_str_new_cstr(hbuf), rb_str_new_cstr(pbuf));
break;
@@ -1980,11 +2379,11 @@ addrinfo_getnameinfo(int argc, VALUE *argv, VALUE self)
if (rai->socktype == SOCK_DGRAM)
flags |= NI_DGRAM;
- error = getnameinfo(&rai->addr.addr, rai->sockaddr_len,
- hbuf, (socklen_t)sizeof(hbuf), pbuf, (socklen_t)sizeof(pbuf),
- flags);
+ error = rb_getnameinfo(&rai->addr.addr, rai->sockaddr_len,
+ hbuf, (socklen_t)sizeof(hbuf), pbuf, (socklen_t)sizeof(pbuf),
+ flags);
if (error) {
- rsock_raise_socket_error("getnameinfo", error);
+ rsock_raise_resolution_error("getnameinfo", error);
}
return rb_assoc_new(rb_str_new2(hbuf), rb_str_new2(pbuf));
@@ -2614,12 +3013,12 @@ rsock_io_socket_addrinfo(VALUE io, struct sockaddr *addr, socklen_t len)
void
rsock_init_addrinfo(void)
{
+ id_timeout = rb_intern("timeout");
+
/*
* The Addrinfo class maps <tt>struct addrinfo</tt> to ruby. This
* structure identifies an Internet host and a service.
*/
- id_timeout = rb_intern("timeout");
-
rb_cAddrinfo = rb_define_class("Addrinfo", rb_cObject);
rb_define_alloc_func(rb_cAddrinfo, addrinfo_s_allocate);
rb_define_method(rb_cAddrinfo, "initialize", addrinfo_initialize, -1);
diff --git a/ext/socket/rubysocket.h b/ext/socket/rubysocket.h
index 5f803ba0da..283735b12c 100644
--- a/ext/socket/rubysocket.h
+++ b/ext/socket/rubysocket.h
@@ -285,6 +285,7 @@ extern VALUE rb_cAddrinfo;
extern VALUE rb_cSockOpt;
extern VALUE rb_eSocket;
+extern VALUE rb_eResolution;
#ifdef SOCKS
extern VALUE rb_cSOCKSSocket;
@@ -307,7 +308,7 @@ VALUE rsock_sockaddr_string_value_with_addrinfo(volatile VALUE *v, VALUE *ai_ret
VALUE rb_check_sockaddr_string_type(VALUE);
-NORETURN(void rsock_raise_socket_error(const char *, int));
+NORETURN(void rsock_raise_resolution_error(const char *, int));
int rsock_family_arg(VALUE domain);
int rsock_socktype_arg(VALUE type);
@@ -459,6 +460,8 @@ VALUE rsock_write_nonblock(VALUE sock, VALUE buf, VALUE ex);
void rsock_make_fd_nonblock(int fd);
+int rsock_is_dgram(rb_io_t *fptr);
+
#if !defined HAVE_INET_NTOP && ! defined _WIN32
const char *inet_ntop(int, const void *, char *, size_t);
#elif defined __MINGW32__
diff --git a/ext/socket/socket.c b/ext/socket/socket.c
index eb74f7a936..c780d77cf6 100644
--- a/ext/socket/socket.c
+++ b/ext/socket/socket.c
@@ -1313,7 +1313,7 @@ sock_s_getnameinfo(int argc, VALUE *argv, VALUE _)
saved_errno = errno;
if (res) rb_freeaddrinfo(res);
errno = saved_errno;
- rsock_raise_socket_error("getnameinfo", error);
+ rsock_raise_resolution_error("getnameinfo", error);
UNREACHABLE_RETURN(Qnil);
}
@@ -1654,8 +1654,7 @@ socket_s_ip_address_list(VALUE self)
finish:
save_errno = errno;
- if (lc.lifc_buf != NULL)
- xfree(lc.lifc_req);
+ xfree(lc.lifc_req);
if (fd != -1)
close(fd);
errno = save_errno;
diff --git a/ext/stringio/depend b/ext/stringio/depend
index 828fc6e842..ba2b812041 100644
--- a/ext/stringio/depend
+++ b/ext/stringio/depend
@@ -53,6 +53,7 @@ stringio.o: $(hdrdir)/ruby/internal/attr/noexcept.h
stringio.o: $(hdrdir)/ruby/internal/attr/noinline.h
stringio.o: $(hdrdir)/ruby/internal/attr/nonnull.h
stringio.o: $(hdrdir)/ruby/internal/attr/noreturn.h
+stringio.o: $(hdrdir)/ruby/internal/attr/packed_struct.h
stringio.o: $(hdrdir)/ruby/internal/attr/pure.h
stringio.o: $(hdrdir)/ruby/internal/attr/restrict.h
stringio.o: $(hdrdir)/ruby/internal/attr/returns_nonnull.h
@@ -121,7 +122,6 @@ stringio.o: $(hdrdir)/ruby/internal/intern/enumerator.h
stringio.o: $(hdrdir)/ruby/internal/intern/error.h
stringio.o: $(hdrdir)/ruby/internal/intern/eval.h
stringio.o: $(hdrdir)/ruby/internal/intern/file.h
-stringio.o: $(hdrdir)/ruby/internal/intern/gc.h
stringio.o: $(hdrdir)/ruby/internal/intern/hash.h
stringio.o: $(hdrdir)/ruby/internal/intern/io.h
stringio.o: $(hdrdir)/ruby/internal/intern/load.h
@@ -152,7 +152,6 @@ stringio.o: $(hdrdir)/ruby/internal/memory.h
stringio.o: $(hdrdir)/ruby/internal/method.h
stringio.o: $(hdrdir)/ruby/internal/module.h
stringio.o: $(hdrdir)/ruby/internal/newobj.h
-stringio.o: $(hdrdir)/ruby/internal/rgengc.h
stringio.o: $(hdrdir)/ruby/internal/scan_args.h
stringio.o: $(hdrdir)/ruby/internal/special_consts.h
stringio.o: $(hdrdir)/ruby/internal/static_assert.h
diff --git a/ext/stringio/extconf.rb b/ext/stringio/extconf.rb
index a933159766..553732f79c 100644
--- a/ext/stringio/extconf.rb
+++ b/ext/stringio/extconf.rb
@@ -1,4 +1,7 @@
# frozen_string_literal: false
require 'mkmf'
-have_func("rb_io_extract_modeenc", "ruby/io.h")
-create_makefile('stringio')
+if RUBY_ENGINE == 'ruby'
+ create_makefile('stringio')
+else
+ File.write('Makefile', dummy_makefile("").join)
+end
diff --git a/ext/stringio/stringio.c b/ext/stringio/stringio.c
index 52a7072231..7eade5bcba 100644
--- a/ext/stringio/stringio.c
+++ b/ext/stringio/stringio.c
@@ -12,7 +12,8 @@
**********************************************************************/
-#define STRINGIO_VERSION "3.0.5"
+static const char *const
+STRINGIO_VERSION = "3.1.0";
#include "ruby.h"
#include "ruby/io.h"
@@ -32,86 +33,6 @@
# define rb_class_new_instance_kw(argc, argv, klass, kw_splat) rb_class_new_instance(argc, argv, klass)
#endif
-#ifndef HAVE_RB_IO_EXTRACT_MODEENC
-#define rb_io_extract_modeenc strio_extract_modeenc
-static void
-strio_extract_modeenc(VALUE *vmode_p, VALUE *vperm_p, VALUE opthash,
- int *oflags_p, int *fmode_p, struct rb_io_enc_t *convconfig_p)
-{
- VALUE mode = *vmode_p;
- VALUE intmode;
- int fmode;
- int has_enc = 0, has_vmode = 0;
-
- convconfig_p->enc = convconfig_p->enc2 = 0;
-
- vmode_handle:
- if (NIL_P(mode)) {
- fmode = FMODE_READABLE;
- }
- else if (!NIL_P(intmode = rb_check_to_integer(mode, "to_int"))) {
- int flags = NUM2INT(intmode);
- fmode = rb_io_oflags_fmode(flags);
- }
- else {
- const char *m = StringValueCStr(mode), *n, *e;
- fmode = rb_io_modestr_fmode(m);
- n = strchr(m, ':');
- if (n) {
- long len;
- char encname[ENCODING_MAXNAMELEN+1];
- has_enc = 1;
- if (fmode & FMODE_SETENC_BY_BOM) {
- n = strchr(n, '|');
- }
- e = strchr(++n, ':');
- len = e ? e - n : (long)strlen(n);
- if (len > 0 && len <= ENCODING_MAXNAMELEN) {
- rb_encoding *enc;
- if (e) {
- memcpy(encname, n, len);
- encname[len] = '\0';
- n = encname;
- }
- enc = rb_enc_find(n);
- if (e)
- convconfig_p->enc2 = enc;
- else
- convconfig_p->enc = enc;
- }
- if (e && (len = strlen(++e)) > 0 && len <= ENCODING_MAXNAMELEN) {
- convconfig_p->enc = rb_enc_find(e);
- }
- }
- }
-
- if (!NIL_P(opthash)) {
- rb_encoding *extenc = 0, *intenc = 0;
- VALUE v;
- if (!has_vmode) {
- ID id_mode;
- CONST_ID(id_mode, "mode");
- v = rb_hash_aref(opthash, ID2SYM(id_mode));
- if (!NIL_P(v)) {
- if (!NIL_P(mode)) {
- rb_raise(rb_eArgError, "mode specified twice");
- }
- has_vmode = 1;
- mode = v;
- goto vmode_handle;
- }
- }
-
- if (rb_io_extract_encoding_option(opthash, &extenc, &intenc, &fmode)) {
- if (has_enc) {
- rb_raise(rb_eArgError, "encoding specified twice");
- }
- }
- }
- *fmode_p = fmode;
-}
-#endif
-
struct StringIO {
VALUE string;
rb_encoding *enc;
@@ -171,7 +92,7 @@ static const rb_data_type_t strio_data_type = {
strio_free,
strio_memsize,
},
- 0, 0, RUBY_TYPED_FREE_IMMEDIATELY
+ 0, 0, RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_WB_PROTECTED
};
#define check_strio(self) ((struct StringIO*)rb_check_typeddata((self), &strio_data_type))
@@ -356,7 +277,7 @@ strio_init(int argc, VALUE *argv, struct StringIO *ptr, VALUE self)
{
VALUE string, vmode, opt;
int oflags;
- struct rb_io_enc_t convconfig;
+ rb_io_enc_t convconfig;
argc = rb_scan_args(argc, argv, "02:", &string, &vmode, &opt);
rb_io_extract_modeenc(&vmode, 0, opt, &oflags, &ptr->flags, &convconfig);
@@ -379,7 +300,7 @@ strio_init(int argc, VALUE *argv, struct StringIO *ptr, VALUE self)
if (ptr->flags & FMODE_TRUNC) {
rb_str_resize(string, 0);
}
- ptr->string = string;
+ RB_OBJ_WRITE(self, &ptr->string, string);
if (argc == 1) {
ptr->enc = rb_enc_get(string);
}
@@ -397,7 +318,7 @@ static VALUE
strio_finalize(VALUE self)
{
struct StringIO *ptr = StringIO(self);
- ptr->string = Qnil;
+ RB_OBJ_WRITE(self, &ptr->string, Qnil);
ptr->flags &= ~FMODE_READWRITE;
return self;
}
@@ -563,7 +484,8 @@ strio_set_string(VALUE self, VALUE string)
ptr->flags = OBJ_FROZEN(string) ? FMODE_READABLE : FMODE_READWRITE;
ptr->pos = 0;
ptr->lineno = 0;
- return ptr->string = string;
+ RB_OBJ_WRITE(self, &ptr->string, string);
+ return string;
}
/*
@@ -682,11 +604,9 @@ strio_to_read(VALUE self)
* eof? -> true or false
*
* Returns +true+ if positioned at end-of-stream, +false+ otherwise;
- * see {Position}[rdoc-ref:File@Position].
+ * see {Position}[rdoc-ref:IO@Position].
*
* Raises IOError if the stream is not opened for reading.
- *
- * StreamIO#eof is an alias for StreamIO#eof?.
*/
static VALUE
strio_eof(VALUE self)
@@ -699,15 +619,19 @@ strio_eof(VALUE self)
static VALUE
strio_copy(VALUE copy, VALUE orig)
{
- struct StringIO *ptr;
+ struct StringIO *ptr, *old_ptr;
+ VALUE old_string = Qundef;
orig = rb_convert_type(orig, T_DATA, "StringIO", "to_strio");
if (copy == orig) return copy;
ptr = StringIO(orig);
- if (check_strio(copy)) {
- strio_free(DATA_PTR(copy));
+ old_ptr = check_strio(copy);
+ if (old_ptr) {
+ old_string = old_ptr->string;
+ strio_free(old_ptr);
}
DATA_PTR(copy) = ptr;
+ RB_OBJ_WRITTEN(copy, old_string, ptr->string);
RBASIC(copy)->flags &= ~STRIO_READWRITE;
RBASIC(copy)->flags |= RBASIC(orig)->flags & STRIO_READWRITE;
++ptr->count;
@@ -808,8 +732,6 @@ strio_reopen(int argc, VALUE *argv, VALUE self)
*
* Returns the current position (in bytes);
* see {Position}[rdoc-ref:IO@Position].
- *
- * StringIO#tell is an alias for StringIO#pos.
*/
static VALUE
strio_get_pos(VALUE self)
@@ -1221,38 +1143,57 @@ struct getline_arg {
};
static struct getline_arg *
-prepare_getline_args(struct getline_arg *arg, int argc, VALUE *argv)
+prepare_getline_args(struct StringIO *ptr, struct getline_arg *arg, int argc, VALUE *argv)
{
- VALUE str, lim, opts;
+ VALUE rs, lim, opts;
long limit = -1;
int respect_chomp;
- argc = rb_scan_args(argc, argv, "02:", &str, &lim, &opts);
- respect_chomp = argc == 0 || !NIL_P(str);
+ argc = rb_scan_args(argc, argv, "02:", &rs, &lim, &opts);
+ respect_chomp = argc == 0 || !NIL_P(rs);
switch (argc) {
case 0:
- str = rb_rs;
+ rs = rb_rs;
break;
case 1:
- if (!NIL_P(str) && !RB_TYPE_P(str, T_STRING)) {
- VALUE tmp = rb_check_string_type(str);
+ if (!NIL_P(rs) && !RB_TYPE_P(rs, T_STRING)) {
+ VALUE tmp = rb_check_string_type(rs);
if (NIL_P(tmp)) {
- limit = NUM2LONG(str);
- str = rb_rs;
+ limit = NUM2LONG(rs);
+ rs = rb_rs;
}
else {
- str = tmp;
+ rs = tmp;
}
}
break;
case 2:
- if (!NIL_P(str)) StringValue(str);
+ if (!NIL_P(rs)) StringValue(rs);
if (!NIL_P(lim)) limit = NUM2LONG(lim);
break;
}
- arg->rs = str;
+ if (!NIL_P(rs)) {
+ rb_encoding *enc_rs, *enc_io;
+ enc_rs = rb_enc_get(rs);
+ enc_io = get_enc(ptr);
+ if (enc_rs != enc_io &&
+ (rb_enc_str_coderange(rs) != ENC_CODERANGE_7BIT ||
+ (RSTRING_LEN(rs) > 0 && !rb_enc_asciicompat(enc_io)))) {
+ if (rs == rb_rs) {
+ rs = rb_enc_str_new(0, 0, enc_io);
+ rb_str_buf_cat_ascii(rs, "\n");
+ rs = rs;
+ }
+ else {
+ rb_raise(rb_eArgError, "encoding mismatch: %s IO with %s RS",
+ rb_enc_name(enc_io),
+ rb_enc_name(enc_rs));
+ }
+ }
+ }
+ arg->rs = rs;
arg->limit = limit;
arg->chomp = 0;
if (!NIL_P(opts)) {
@@ -1380,15 +1321,15 @@ strio_getline(struct getline_arg *arg, struct StringIO *ptr)
static VALUE
strio_gets(int argc, VALUE *argv, VALUE self)
{
+ struct StringIO *ptr = readable(self);
struct getline_arg arg;
VALUE str;
- if (prepare_getline_args(&arg, argc, argv)->limit == 0) {
- struct StringIO *ptr = readable(self);
+ if (prepare_getline_args(ptr, &arg, argc, argv)->limit == 0) {
return rb_enc_str_new(0, 0, get_enc(ptr));
}
- str = strio_getline(&arg, readable(self));
+ str = strio_getline(&arg, ptr);
rb_lastline_set(str);
return str;
}
@@ -1420,23 +1361,21 @@ strio_readline(int argc, VALUE *argv, VALUE self)
* does nothing if already at end-of-file;
* returns +self+.
* See {Line IO}[rdoc-ref:IO@Line+IO].
- *
- * StringIO#each is an alias for StringIO#each_line.
*/
static VALUE
strio_each(int argc, VALUE *argv, VALUE self)
{
VALUE line;
+ struct StringIO *ptr = readable(self);
struct getline_arg arg;
- StringIO(self);
RETURN_ENUMERATOR(self, argc, argv);
- if (prepare_getline_args(&arg, argc, argv)->limit == 0) {
+ if (prepare_getline_args(ptr, &arg, argc, argv)->limit == 0) {
rb_raise(rb_eArgError, "invalid limit: 0 for each_line");
}
- while (!NIL_P(line = strio_getline(&arg, readable(self)))) {
+ while (!NIL_P(line = strio_getline(&arg, ptr))) {
rb_yield(line);
}
return self;
@@ -1454,15 +1393,15 @@ static VALUE
strio_readlines(int argc, VALUE *argv, VALUE self)
{
VALUE ary, line;
+ struct StringIO *ptr = readable(self);
struct getline_arg arg;
- StringIO(self);
- ary = rb_ary_new();
- if (prepare_getline_args(&arg, argc, argv)->limit == 0) {
+ if (prepare_getline_args(ptr, &arg, argc, argv)->limit == 0) {
rb_raise(rb_eArgError, "invalid limit: 0 for readlines");
}
- while (!NIL_P(line = strio_getline(&arg, readable(self)))) {
+ ary = rb_ary_new();
+ while (!NIL_P(line = strio_getline(&arg, ptr))) {
rb_ary_push(ary, line);
}
return ary;
@@ -1665,6 +1604,55 @@ strio_read(int argc, VALUE *argv, VALUE self)
}
/*
+ * call-seq:
+ * pread(maxlen, offset) -> string
+ * pread(maxlen, offset, out_string) -> string
+ *
+ * See IO#pread.
+ */
+static VALUE
+strio_pread(int argc, VALUE *argv, VALUE self)
+{
+ VALUE rb_len, rb_offset, rb_buf;
+ rb_scan_args(argc, argv, "21", &rb_len, &rb_offset, &rb_buf);
+ long len = NUM2LONG(rb_len);
+ long offset = NUM2LONG(rb_offset);
+
+ if (len < 0) {
+ rb_raise(rb_eArgError, "negative string size (or size too big): %" PRIsVALUE, rb_len);
+ }
+
+ if (len == 0) {
+ if (NIL_P(rb_buf)) {
+ return rb_str_new("", 0);
+ }
+ return rb_buf;
+ }
+
+ if (offset < 0) {
+ rb_syserr_fail_str(EINVAL, rb_sprintf("pread: Invalid offset argument: %" PRIsVALUE, rb_offset));
+ }
+
+ struct StringIO *ptr = readable(self);
+
+ if (offset >= RSTRING_LEN(ptr->string)) {
+ rb_eof_error();
+ }
+
+ if (NIL_P(rb_buf)) {
+ return strio_substr(ptr, offset, len, rb_ascii8bit_encoding());
+ }
+
+ long rest = RSTRING_LEN(ptr->string) - offset;
+ if (len > rest) len = rest;
+ rb_str_resize(rb_buf, len);
+ rb_enc_associate(rb_buf, rb_ascii8bit_encoding());
+ MEMCPY(RSTRING_PTR(rb_buf), RSTRING_PTR(ptr->string) + offset, char, len);
+ return rb_buf;
+}
+
+
+/*
* call-seq:
* strio.sysread(integer[, outbuf]) -> string
* strio.readpartial(integer[, outbuf]) -> string
@@ -1824,7 +1812,7 @@ strio_set_encoding(int argc, VALUE *argv, VALUE self)
else {
enc = rb_find_encoding(ext_enc);
if (!enc) {
- struct rb_io_enc_t convconfig;
+ rb_io_enc_t convconfig;
int oflags, fmode;
VALUE vmode = rb_str_append(rb_str_new_cstr("r:"), ext_enc);
rb_io_extract_modeenc(&vmode, 0, Qnil, &oflags, &fmode, &convconfig);
@@ -1924,6 +1912,7 @@ Init_stringio(void)
rb_define_method(StringIO, "gets", strio_gets, -1);
rb_define_method(StringIO, "readlines", strio_readlines, -1);
rb_define_method(StringIO, "read", strio_read, -1);
+ rb_define_method(StringIO, "pread", strio_pread, -1);
rb_define_method(StringIO, "write", strio_write_m, -1);
rb_define_method(StringIO, "putc", strio_putc, 1);
diff --git a/ext/stringio/stringio.gemspec b/ext/stringio/stringio.gemspec
index 1015d261f5..8c950f8ff9 100644
--- a/ext/stringio/stringio.gemspec
+++ b/ext/stringio/stringio.gemspec
@@ -4,7 +4,7 @@
source_version = ["", "ext/stringio/"].find do |dir|
begin
break File.open(File.join(__dir__, "#{dir}stringio.c")) {|f|
- f.gets("\n#define STRINGIO_VERSION ")
+ f.gets("\nSTRINGIO_VERSION ")
f.gets[/\s*"(.+)"/, 1]
}
rescue Errno::ENOENT
@@ -14,7 +14,6 @@ Gem::Specification.new do |s|
s.name = "stringio"
s.version = source_version
- s.required_rubygems_version = Gem::Requirement.new(">= 2.6")
s.require_paths = ["lib"]
s.authors = ["Nobu Nakada", "Charles Oliver Nutter"]
s.description = "Pseudo `IO` class from/to `String`."
@@ -22,7 +21,8 @@ Gem::Specification.new do |s|
s.files = ["README.md"]
jruby = true if Gem::Platform.new('java') =~ s.platform or RUBY_ENGINE == 'jruby'
if jruby
- s.files += ["lib/stringio.rb", "lib/stringio.jar"]
+ s.require_paths = "lib/java"
+ s.files += ["lib/java/stringio.rb", "lib/java/stringio.jar"]
s.platform = "java"
else
s.extensions = ["ext/stringio/extconf.rb"]
@@ -30,7 +30,7 @@ Gem::Specification.new do |s|
end
s.homepage = "https://github.com/ruby/stringio"
s.licenses = ["Ruby", "BSD-2-Clause"]
- s.required_ruby_version = ">= 2.5"
+ s.required_ruby_version = ">= 2.7"
s.summary = "Pseudo IO on String"
# s.cert_chain = %w[certs/nobu.pem]
diff --git a/ext/strscan/depend b/ext/strscan/depend
index 8fe3cb23d9..8d985b59e8 100644
--- a/ext/strscan/depend
+++ b/ext/strscan/depend
@@ -52,6 +52,7 @@ strscan.o: $(hdrdir)/ruby/internal/attr/noexcept.h
strscan.o: $(hdrdir)/ruby/internal/attr/noinline.h
strscan.o: $(hdrdir)/ruby/internal/attr/nonnull.h
strscan.o: $(hdrdir)/ruby/internal/attr/noreturn.h
+strscan.o: $(hdrdir)/ruby/internal/attr/packed_struct.h
strscan.o: $(hdrdir)/ruby/internal/attr/pure.h
strscan.o: $(hdrdir)/ruby/internal/attr/restrict.h
strscan.o: $(hdrdir)/ruby/internal/attr/returns_nonnull.h
@@ -121,7 +122,6 @@ strscan.o: $(hdrdir)/ruby/internal/intern/enumerator.h
strscan.o: $(hdrdir)/ruby/internal/intern/error.h
strscan.o: $(hdrdir)/ruby/internal/intern/eval.h
strscan.o: $(hdrdir)/ruby/internal/intern/file.h
-strscan.o: $(hdrdir)/ruby/internal/intern/gc.h
strscan.o: $(hdrdir)/ruby/internal/intern/hash.h
strscan.o: $(hdrdir)/ruby/internal/intern/io.h
strscan.o: $(hdrdir)/ruby/internal/intern/load.h
@@ -152,7 +152,6 @@ strscan.o: $(hdrdir)/ruby/internal/memory.h
strscan.o: $(hdrdir)/ruby/internal/method.h
strscan.o: $(hdrdir)/ruby/internal/module.h
strscan.o: $(hdrdir)/ruby/internal/newobj.h
-strscan.o: $(hdrdir)/ruby/internal/rgengc.h
strscan.o: $(hdrdir)/ruby/internal/scan_args.h
strscan.o: $(hdrdir)/ruby/internal/special_consts.h
strscan.o: $(hdrdir)/ruby/internal/static_assert.h
diff --git a/ext/strscan/extconf.rb b/ext/strscan/extconf.rb
index b53b63e455..bd65606a4e 100644
--- a/ext/strscan/extconf.rb
+++ b/ext/strscan/extconf.rb
@@ -3,6 +3,7 @@ require 'mkmf'
if RUBY_ENGINE == 'ruby'
$INCFLAGS << " -I$(top_srcdir)" if $extmk
have_func("onig_region_memsize", "ruby.h")
+ have_func("rb_reg_onig_match", "ruby.h")
create_makefile 'strscan'
else
File.write('Makefile', dummy_makefile("").join)
diff --git a/ext/strscan/strscan.c b/ext/strscan/strscan.c
index 172ce1d6c5..16d669d8a5 100644
--- a/ext/strscan/strscan.c
+++ b/ext/strscan/strscan.c
@@ -22,7 +22,7 @@ extern size_t onig_region_memsize(const struct re_registers *regs);
#include <stdbool.h>
-#define STRSCAN_VERSION "3.0.6"
+#define STRSCAN_VERSION "3.0.7"
/* =======================================================================
Data Type Definitions
@@ -539,6 +539,68 @@ adjust_register_position(struct strscanner *p, long position)
}
}
+/* rb_reg_onig_match is available in Ruby 3.3 and later. */
+#ifndef HAVE_RB_REG_ONIG_MATCH
+static OnigPosition
+rb_reg_onig_match(VALUE re, VALUE str,
+ OnigPosition (*match)(regex_t *reg, VALUE str, struct re_registers *regs, void *args),
+ void *args, struct re_registers *regs)
+{
+ regex_t *reg = rb_reg_prepare_re(re, str);
+
+ bool tmpreg = reg != RREGEXP_PTR(re);
+ if (!tmpreg) RREGEXP(re)->usecnt++;
+
+ OnigPosition result = match(reg, str, regs, args);
+
+ if (!tmpreg) RREGEXP(re)->usecnt--;
+ if (tmpreg) {
+ if (RREGEXP(re)->usecnt) {
+ onig_free(reg);
+ }
+ else {
+ onig_free(RREGEXP_PTR(re));
+ RREGEXP_PTR(re) = reg;
+ }
+ }
+
+ if (result < 0) {
+ if (result != ONIG_MISMATCH) {
+ rb_raise(ScanError, "regexp buffer overflow");
+ }
+ }
+
+ return result;
+}
+#endif
+
+static OnigPosition
+strscan_match(regex_t *reg, VALUE str, struct re_registers *regs, void *args_ptr)
+{
+ struct strscanner *p = (struct strscanner *)args_ptr;
+
+ return onig_match(reg,
+ match_target(p),
+ (UChar* )(CURPTR(p) + S_RESTLEN(p)),
+ (UChar* )CURPTR(p),
+ regs,
+ ONIG_OPTION_NONE);
+}
+
+static OnigPosition
+strscan_search(regex_t *reg, VALUE str, struct re_registers *regs, void *args_ptr)
+{
+ struct strscanner *p = (struct strscanner *)args_ptr;
+
+ return onig_search(reg,
+ match_target(p),
+ (UChar *)(CURPTR(p) + S_RESTLEN(p)),
+ (UChar *)CURPTR(p),
+ (UChar *)(CURPTR(p) + S_RESTLEN(p)),
+ regs,
+ ONIG_OPTION_NONE);
+}
+
static VALUE
strscan_do_scan(VALUE self, VALUE pattern, int succptr, int getstr, int headonly)
{
@@ -560,47 +622,14 @@ strscan_do_scan(VALUE self, VALUE pattern, int succptr, int getstr, int headonly
}
if (RB_TYPE_P(pattern, T_REGEXP)) {
- regex_t *rb_reg_prepare_re(VALUE re, VALUE str);
- regex_t *re;
- long ret;
- int tmpreg;
-
p->regex = pattern;
- re = rb_reg_prepare_re(pattern, p->str);
- tmpreg = re != RREGEXP_PTR(pattern);
- if (!tmpreg) RREGEXP(pattern)->usecnt++;
-
- if (headonly) {
- ret = onig_match(re,
- match_target(p),
- (UChar* )(CURPTR(p) + S_RESTLEN(p)),
- (UChar* )CURPTR(p),
- &(p->regs),
- ONIG_OPTION_NONE);
- }
- else {
- ret = onig_search(re,
- match_target(p),
- (UChar* )(CURPTR(p) + S_RESTLEN(p)),
- (UChar* )CURPTR(p),
- (UChar* )(CURPTR(p) + S_RESTLEN(p)),
- &(p->regs),
- ONIG_OPTION_NONE);
- }
- if (!tmpreg) RREGEXP(pattern)->usecnt--;
- if (tmpreg) {
- if (RREGEXP(pattern)->usecnt) {
- onig_free(re);
- }
- else {
- onig_free(RREGEXP_PTR(pattern));
- RREGEXP_PTR(pattern) = re;
- }
- }
+ OnigPosition ret = rb_reg_onig_match(pattern,
+ p->str,
+ headonly ? strscan_match : strscan_search,
+ (void *)p,
+ &(p->regs));
- if (ret == -2) rb_raise(ScanError, "regexp buffer overflow");
- if (ret < 0) {
- /* not matched */
+ if (ret == ONIG_MISMATCH) {
return Qnil;
}
}
@@ -1038,8 +1067,9 @@ strscan_empty_p(VALUE self)
* This method is obsolete; use #eos? instead.
*
* s = StringScanner.new('test string')
- * s.eos? # These two
- * s.rest? # are opposites.
+ * # These two are opposites
+ * s.eos? # => false
+ * s.rest? # => true
*/
static VALUE
strscan_rest_p(VALUE self)
@@ -1501,7 +1531,9 @@ strscan_named_captures(VALUE self)
named_captures_data data;
data.self = self;
data.captures = rb_hash_new();
- onig_foreach_name(RREGEXP_PTR(p->regex), named_captures_iter, &data);
+ if (!RB_NIL_P(p->regex)) {
+ onig_foreach_name(RREGEXP_PTR(p->regex), named_captures_iter, &data);
+ }
return data.captures;
}
diff --git a/ext/syslog/depend b/ext/syslog/depend
index 4eea8c3bf9..ee4ac5f47d 100644
--- a/ext/syslog/depend
+++ b/ext/syslog/depend
@@ -51,6 +51,7 @@ syslog.o: $(hdrdir)/ruby/internal/attr/noexcept.h
syslog.o: $(hdrdir)/ruby/internal/attr/noinline.h
syslog.o: $(hdrdir)/ruby/internal/attr/nonnull.h
syslog.o: $(hdrdir)/ruby/internal/attr/noreturn.h
+syslog.o: $(hdrdir)/ruby/internal/attr/packed_struct.h
syslog.o: $(hdrdir)/ruby/internal/attr/pure.h
syslog.o: $(hdrdir)/ruby/internal/attr/restrict.h
syslog.o: $(hdrdir)/ruby/internal/attr/returns_nonnull.h
@@ -110,7 +111,6 @@ syslog.o: $(hdrdir)/ruby/internal/intern/enumerator.h
syslog.o: $(hdrdir)/ruby/internal/intern/error.h
syslog.o: $(hdrdir)/ruby/internal/intern/eval.h
syslog.o: $(hdrdir)/ruby/internal/intern/file.h
-syslog.o: $(hdrdir)/ruby/internal/intern/gc.h
syslog.o: $(hdrdir)/ruby/internal/intern/hash.h
syslog.o: $(hdrdir)/ruby/internal/intern/io.h
syslog.o: $(hdrdir)/ruby/internal/intern/load.h
@@ -141,7 +141,6 @@ syslog.o: $(hdrdir)/ruby/internal/memory.h
syslog.o: $(hdrdir)/ruby/internal/method.h
syslog.o: $(hdrdir)/ruby/internal/module.h
syslog.o: $(hdrdir)/ruby/internal/newobj.h
-syslog.o: $(hdrdir)/ruby/internal/rgengc.h
syslog.o: $(hdrdir)/ruby/internal/scan_args.h
syslog.o: $(hdrdir)/ruby/internal/special_consts.h
syslog.o: $(hdrdir)/ruby/internal/static_assert.h
diff --git a/ext/syslog/syslog.c b/ext/syslog/syslog.c
index 8f3674aa8d..4fbbb2ec6e 100644
--- a/ext/syslog/syslog.c
+++ b/ext/syslog/syslog.c
@@ -12,6 +12,8 @@
#include "ruby/util.h"
#include <syslog.h>
+#define SYSLOG_VERSION "0.1.2"
+
/* Syslog class */
static VALUE mSyslog;
/*
@@ -574,6 +576,8 @@ void Init_syslog(void)
/* Syslog macros */
+ rb_define_const(mSyslog, "VERSION", rb_str_new_cstr(SYSLOG_VERSION));
+
rb_define_method(mSyslogMacros, "LOG_MASK", mSyslogMacros_LOG_MASK, 1);
rb_define_method(mSyslogMacros, "LOG_UPTO", mSyslogMacros_LOG_UPTO, 1);
rb_define_singleton_method(mSyslogMacros, "included", mSyslogMacros_included, 1);
diff --git a/ext/syslog/syslog.gemspec b/ext/syslog/syslog.gemspec
index 6aa2e9570d..10a6d1f25c 100644
--- a/ext/syslog/syslog.gemspec
+++ b/ext/syslog/syslog.gemspec
@@ -1,13 +1,18 @@
+source_version = %w[. ext/syslog].find do |dir|
+ break $1 if File.foreach(File.join(__dir__, dir, "syslog.c")).any?(/^#define\s+SYSLOG_VERSION\s+"(.+)"/)
+rescue Errno::ENOENT
+end
+
Gem::Specification.new do |spec|
spec.name = "syslog"
- spec.version = "0.1.1"
+ spec.version = source_version
spec.authors = ["Akinori MUSHA"]
spec.email = ["knu@idaemons.org"]
spec.summary = %q{Ruby interface for the POSIX system logging facility.}
spec.description = %q{Ruby interface for the POSIX system logging facility.}
spec.homepage = "https://github.com/ruby/syslog"
- spec.required_ruby_version = Gem::Requirement.new(">= 2.3.0")
+ spec.required_ruby_version = Gem::Requirement.new(">= 2.5.0")
spec.licenses = ["Ruby", "BSD-2-Clause"]
spec.metadata["homepage_uri"] = spec.homepage
diff --git a/ext/win32/lib/win32/registry.rb b/ext/win32/lib/win32/registry.rb
index b5b99ff684..16a08310ad 100644
--- a/ext/win32/lib/win32/registry.rb
+++ b/ext/win32/lib/win32/registry.rb
@@ -740,14 +740,11 @@ For detail, see the MSDN[http://msdn.microsoft.com/library/en-us/sysinfo/base/pr
# method returns.
#
def write(name, type, data)
- termsize = 0
case type
when REG_SZ, REG_EXPAND_SZ
- data = data.encode(WCHAR)
- termsize = WCHAR_SIZE
+ data = data.encode(WCHAR) << WCHAR_NUL
when REG_MULTI_SZ
data = data.to_a.map {|s| s.encode(WCHAR)}.join(WCHAR_NUL) << WCHAR_NUL
- termsize = WCHAR_SIZE
when REG_BINARY, REG_NONE
data = data.to_s
when REG_DWORD
@@ -759,7 +756,7 @@ For detail, see the MSDN[http://msdn.microsoft.com/library/en-us/sysinfo/base/pr
else
raise TypeError, "Unsupported type #{Registry.type2name(type)}"
end
- API.SetValue(@hkey, name, type, data, data.bytesize + termsize)
+ API.SetValue(@hkey, name, type, data, data.bytesize)
end
#
diff --git a/ext/win32ole/win32ole.c b/ext/win32ole/win32ole.c
index 3f083bb12d..a060165a1c 100644
--- a/ext/win32ole/win32ole.c
+++ b/ext/win32ole/win32ole.c
@@ -27,7 +27,7 @@
const IID IID_IMultiLanguage2 = {0xDCCFC164, 0x2B38, 0x11d2, {0xB7, 0xEC, 0x00, 0xC0, 0x4F, 0x8F, 0x5D, 0x9A}};
#endif
-#define WIN32OLE_VERSION "1.8.8"
+#define WIN32OLE_VERSION "1.8.10"
typedef HRESULT (STDAPICALLTYPE FNCOCREATEINSTANCEEX)
(REFCLSID, IUnknown*, DWORD, COSERVERINFO*, DWORD, MULTI_QI*);
diff --git a/ext/win32ole/win32ole.gemspec b/ext/win32ole/win32ole.gemspec
index b6ea8e8a55..9c137a5d70 100644
--- a/ext/win32ole/win32ole.gemspec
+++ b/ext/win32ole/win32ole.gemspec
@@ -1,6 +1,16 @@
+source_version = ["", "ext/win32ole/"].find do |dir|
+ begin
+ break File.open(File.join(__dir__, "#{dir}win32ole.c")) {|f|
+ f.gets("\n#define WIN32OLE_VERSION ")
+ f.gets[/\s*"(.+)"/, 1]
+ }
+ rescue Errno::ENOENT
+ end
+end
+
Gem::Specification.new do |spec|
spec.name = "win32ole"
- spec.version = "1.8.9"
+ spec.version = source_version
spec.authors = ["Masaki Suketa"]
spec.email = ["suke@ruby-lang.org"]
diff --git a/ext/zlib/depend b/ext/zlib/depend
index 15186f8266..bdcf6a93e8 100644
--- a/ext/zlib/depend
+++ b/ext/zlib/depend
@@ -53,6 +53,7 @@ zlib.o: $(hdrdir)/ruby/internal/attr/noexcept.h
zlib.o: $(hdrdir)/ruby/internal/attr/noinline.h
zlib.o: $(hdrdir)/ruby/internal/attr/nonnull.h
zlib.o: $(hdrdir)/ruby/internal/attr/noreturn.h
+zlib.o: $(hdrdir)/ruby/internal/attr/packed_struct.h
zlib.o: $(hdrdir)/ruby/internal/attr/pure.h
zlib.o: $(hdrdir)/ruby/internal/attr/restrict.h
zlib.o: $(hdrdir)/ruby/internal/attr/returns_nonnull.h
@@ -121,7 +122,6 @@ zlib.o: $(hdrdir)/ruby/internal/intern/enumerator.h
zlib.o: $(hdrdir)/ruby/internal/intern/error.h
zlib.o: $(hdrdir)/ruby/internal/intern/eval.h
zlib.o: $(hdrdir)/ruby/internal/intern/file.h
-zlib.o: $(hdrdir)/ruby/internal/intern/gc.h
zlib.o: $(hdrdir)/ruby/internal/intern/hash.h
zlib.o: $(hdrdir)/ruby/internal/intern/io.h
zlib.o: $(hdrdir)/ruby/internal/intern/load.h
@@ -152,7 +152,6 @@ zlib.o: $(hdrdir)/ruby/internal/memory.h
zlib.o: $(hdrdir)/ruby/internal/method.h
zlib.o: $(hdrdir)/ruby/internal/module.h
zlib.o: $(hdrdir)/ruby/internal/newobj.h
-zlib.o: $(hdrdir)/ruby/internal/rgengc.h
zlib.o: $(hdrdir)/ruby/internal/scan_args.h
zlib.o: $(hdrdir)/ruby/internal/special_consts.h
zlib.o: $(hdrdir)/ruby/internal/static_assert.h
diff --git a/ext/zlib/extconf.rb b/ext/zlib/extconf.rb
index 1254c62a17..2b2dbb1a5b 100644
--- a/ext/zlib/extconf.rb
+++ b/ext/zlib/extconf.rb
@@ -120,12 +120,18 @@ if have_zlib
$defs << "-DHAVE_CRC32_COMBINE"
$defs << "-DHAVE_ADLER32_COMBINE"
$defs << "-DHAVE_TYPE_Z_CRC_T"
- $defs << "-DHAVE_TYPE_Z_SIZE_T"
+ $defs << "-DHAVE_CRC32_Z"
+ $defs << "-DHAVE_ADLER32_Z"
+ $defs << "-DHAVE_ZLIB_SIZE_T_FUNCS"
else
have_func('crc32_combine', 'zlib.h')
have_func('adler32_combine', 'zlib.h')
have_type('z_crc_t', 'zlib.h')
- have_type('z_size_t', 'zlib.h')
+ if (have_type('z_size_t', 'zlib.h') &&
+ have_func('crc32_z', 'zlib.h') &&
+ have_func('adler32_z', 'zlib.h'))
+ $defs << "-DHAVE_ZLIB_SIZE_T_FUNCS"
+ end
end
create_makefile('zlib') {|conf|
diff --git a/ext/zlib/zlib.c b/ext/zlib/zlib.c
index aefdba0ebd..dc608ee460 100644
--- a/ext/zlib/zlib.c
+++ b/ext/zlib/zlib.c
@@ -25,7 +25,7 @@
# define VALGRIND_MAKE_MEM_UNDEFINED(p, n) 0
#endif
-#define RUBY_ZLIB_VERSION "3.0.0"
+#define RUBY_ZLIB_VERSION "3.1.0"
#ifndef RB_PASS_CALLED_KEYWORDS
# define rb_class_new_instance_kw(argc, argv, klass, kw_splat) rb_class_new_instance(argc, argv, klass)
@@ -44,7 +44,7 @@
#endif
#endif
-#if defined(HAVE_TYPE_Z_SIZE_T)
+#if defined(HAVE_ZLIB_SIZE_T_FUNCS)
typedef uLong (*checksum_func)(uLong, const Bytef*, z_size_t);
# define crc32 crc32_z
# define adler32 adler32_z
@@ -388,7 +388,7 @@ rb_zlib_version(VALUE klass)
# define mask32(x) (x)
#endif
-#if SIZEOF_LONG > SIZEOF_INT && !defined(HAVE_TYPE_Z_SIZE_T)
+#if SIZEOF_LONG > SIZEOF_INT && !defined(HAVE_ZLIB_SIZE_T_FUNCS)
static uLong
checksum_long(uLong (*func)(uLong, const Bytef*, uInt), uLong sum, const Bytef *ptr, long len)
{
@@ -923,7 +923,7 @@ zstream_discard_input(struct zstream *z, long len)
z->input = Qnil;
}
else {
- z->input = rb_str_substr(z->input, len,
+ z->input = rb_str_subseq(z->input, len,
RSTRING_LEN(z->input) - len);
}
}
diff --git a/ext/zlib/zlib.gemspec b/ext/zlib/zlib.gemspec
index 4a5f8f2ee8..bb67ea156c 100644
--- a/ext/zlib/zlib.gemspec
+++ b/ext/zlib/zlib.gemspec
@@ -27,5 +27,5 @@ Gem::Specification.new do |spec|
spec.executables = []
spec.require_paths = ["lib"]
spec.extensions = "ext/zlib/extconf.rb"
- spec.required_ruby_version = ">= 2.3.0"
+ spec.required_ruby_version = ">= 2.5.0"
end
diff --git a/file.c b/file.c
index 4c888e1293..373788b206 100644
--- a/file.c
+++ b/file.c
@@ -169,7 +169,6 @@ int flock(int, int);
#include "internal/thread.h"
#include "internal/vm.h"
#include "ruby/encoding.h"
-#include "ruby/io.h"
#include "ruby/thread.h"
#include "ruby/util.h"
@@ -484,28 +483,29 @@ apply2files(int (*func)(const char *, void *), int argc, VALUE *argv, void *arg)
return LONG2FIX(argc);
}
-static size_t
-stat_memsize(const void *p)
-{
- return sizeof(struct stat);
-}
-
static const rb_data_type_t stat_data_type = {
"stat",
- {NULL, RUBY_TYPED_DEFAULT_FREE, stat_memsize,},
- 0, 0, RUBY_TYPED_FREE_IMMEDIATELY
+ {
+ NULL,
+ RUBY_TYPED_DEFAULT_FREE,
+ NULL, // No external memory to report
+ },
+ 0, 0, RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_WB_PROTECTED | RUBY_TYPED_EMBEDDABLE
+};
+
+struct rb_stat {
+ struct stat stat;
+ bool initialized;
};
static VALUE
stat_new_0(VALUE klass, const struct stat *st)
{
- struct stat *nst = 0;
- VALUE obj = TypedData_Wrap_Struct(klass, &stat_data_type, 0);
-
+ struct rb_stat *rb_st;
+ VALUE obj = TypedData_Make_Struct(klass, struct rb_stat, &stat_data_type, rb_st);
if (st) {
- nst = ALLOC(struct stat);
- *nst = *st;
- RTYPEDDATA_DATA(obj) = nst;
+ rb_st->stat = *st;
+ rb_st->initialized = true;
}
return obj;
}
@@ -519,10 +519,10 @@ rb_stat_new(const struct stat *st)
static struct stat*
get_stat(VALUE self)
{
- struct stat* st;
- TypedData_Get_Struct(self, struct stat, &stat_data_type, st);
- if (!st) rb_raise(rb_eTypeError, "uninitialized File::Stat");
- return st;
+ struct rb_stat* rb_st;
+ TypedData_Get_Struct(self, struct rb_stat, &stat_data_type, rb_st);
+ if (!rb_st->initialized) rb_raise(rb_eTypeError, "uninitialized File::Stat");
+ return &rb_st->stat;
}
static struct timespec stat_mtimespec(const struct stat *st);
@@ -1093,9 +1093,9 @@ rb_stat_inspect(VALUE self)
#endif
};
- struct stat* st;
- TypedData_Get_Struct(self, struct stat, &stat_data_type, st);
- if (!st) {
+ struct rb_stat* rb_st;
+ TypedData_Get_Struct(self, struct rb_stat, &stat_data_type, rb_st);
+ if (!rb_st->initialized) {
return rb_sprintf("#<%s: uninitialized>", rb_obj_classname(self));
}
@@ -1594,8 +1594,6 @@ rb_access(VALUE fname, int mode)
*/
/*
- * Document-method: directory?
- *
* call-seq:
* File.directory?(path) -> true or false
*
@@ -1774,7 +1772,7 @@ rb_file_blockdev_p(VALUE obj, VALUE fname)
*
* Returns +true+ if +filepath+ points to a character device, +false+ otherwise.
*
- * File.chardev?($stdin) # => true
+ * File.chardev?($stdin) # => true
* File.chardev?('t.txt') # => false
*
*/
@@ -2455,6 +2453,7 @@ rb_file_ctime(VALUE obj)
return stat_ctime(&st);
}
+#if defined(HAVE_STAT_BIRTHTIME)
/*
* call-seq:
* File.birthtime(file_name) -> time
@@ -2469,7 +2468,6 @@ rb_file_ctime(VALUE obj)
*
*/
-#if defined(HAVE_STAT_BIRTHTIME)
RUBY_FUNC_EXPORTED VALUE
rb_file_s_birthtime(VALUE klass, VALUE fname)
{
@@ -2515,16 +2513,6 @@ rb_file_birthtime(VALUE obj)
# define rb_file_birthtime rb_f_notimplement
#endif
-/*
- * call-seq:
- * file.size -> integer
- *
- * Returns the size of <i>file</i> in bytes.
- *
- * File.new("testfile").size #=> 66
- *
- */
-
rb_off_t
rb_file_size(VALUE file)
{
@@ -2548,6 +2536,16 @@ rb_file_size(VALUE file)
}
}
+/*
+ * call-seq:
+ * file.size -> integer
+ *
+ * Returns the size of <i>file</i> in bytes.
+ *
+ * File.new("testfile").size #=> 66
+ *
+ */
+
static VALUE
file_size(VALUE self)
{
@@ -4611,7 +4609,7 @@ rmext(const char *p, long l0, long l1, const char *e, long l2, rb_encoding *enc)
if (l1 < l2) return l1;
s = p+l1-l2;
- if (rb_enc_left_char_head(p, s, p+l1, enc) != s) return 0;
+ if (!at_char_boundary(p, s, p+l1, enc)) return 0;
#if CASEFOLD_FILESYSTEM
#define fncomp strncasecmp
#else
@@ -4972,7 +4970,7 @@ rb_file_s_extname(VALUE klass, VALUE fname)
*
* Returns the string representation of the path
*
- * File.path("/dev/null") #=> "/dev/null"
+ * File.path(File::NULL) #=> "/dev/null"
* File.path(Pathname.new("/tmp")) #=> "/tmp"
*
*/
@@ -5224,47 +5222,75 @@ rb_thread_flock(void *data)
return (VALUE)ret;
}
-/*
+/* :markup: markdown
+ *
* call-seq:
- * file.flock(locking_constant) -> 0 or false
- *
- * Locks or unlocks a file according to <i>locking_constant</i> (a
- * logical <em>or</em> of the values in the table below).
- * Returns <code>false</code> if File::LOCK_NB is specified and the
- * operation would otherwise have blocked. Not available on all
- * platforms.
- *
- * Locking constants (in class File):
- *
- * LOCK_EX | Exclusive lock. Only one process may hold an
- * | exclusive lock for a given file at a time.
- * ----------+------------------------------------------------
- * LOCK_NB | Don't block when locking. May be combined
- * | with other lock options using logical or.
- * ----------+------------------------------------------------
- * LOCK_SH | Shared lock. Multiple processes may each hold a
- * | shared lock for a given file at the same time.
- * ----------+------------------------------------------------
- * LOCK_UN | Unlock.
+ * flock(locking_constant) -> 0 or false
+ *
+ * Locks or unlocks a file according to the given `locking_constant`,
+ * a bitwise OR of the values in the table below.
+ *
+ * Not available on all platforms.
*
+ * Returns `false` if `File::LOCK_NB` is specified and the operation would have blocked;
+ * otherwise returns `0`.
+ * <br>
+ *
+ * <table>
+ * <tr>
+ * <th colspan="3">Locking Constants</th>
+ * </tr>
+ * <tr>
+ * <th>Constant</th>
+ * <th>Lock</th>
+ * <th>Effect</th>
+ * </tr>
+ * <tr>
+ * <td><tt>File::LOCK_EX</tt></td>
+ * <td>Exclusive</td>
+ * <td>Only one process may hold an exclusive lock for <tt>self</tt> at a time.</td>
+ * </tr>
+ * <tr>
+ * <td><tt>File::LOCK_NB</tt></td>
+ * <td>Non-blocking</td>
+ * <td>
+ * No blocking; may be combined with other <tt>File::LOCK_SH</tt> or <tt>File::LOCK_EX</tt>
+ * using the bitwise OR operator <tt>|</tt>.
+ * </td>
+ * </tr>
+ * <tr>
+ * <td><tt>File::LOCK_SH</tt></td>
+ * <td>Shared</td>
+ * <td>Multiple processes may each hold a shared lock for <tt>self</tt> at the same time.</td>
+ * </tr>
+ * <tr>
+ * <td><tt>File::LOCK_UN</tt></td>
+ * <td>Unlock</td>
+ * <td>Remove an existing lock held by this process.</td>
+ * </tr>
+ * </table>
+ *
+ * <br>
* Example:
*
- * # update a counter using write lock
- * # don't use "w" because it truncates the file before lock.
- * File.open("counter", File::RDWR|File::CREAT, 0644) {|f|
- * f.flock(File::LOCK_EX)
- * value = f.read.to_i + 1
- * f.rewind
- * f.write("#{value}\n")
- * f.flush
- * f.truncate(f.pos)
- * }
- *
- * # read the counter using read lock
- * File.open("counter", "r") {|f|
- * f.flock(File::LOCK_SH)
- * p f.read
- * }
+ * ```ruby
+ * # Update a counter using an exclusive lock.
+ * # Don't use File::WRONLY because it truncates the file.
+ * File.open('counter', File::RDWR | File::CREAT, 0644) do |f|
+ * f.flock(File::LOCK_EX)
+ * value = f.read.to_i + 1
+ * f.rewind
+ * f.write("#{value}\n")
+ * f.flush
+ * f.truncate(f.pos)
+ * end
+ *
+ * # Read the counter using a shared lock.
+ * File.open('counter', 'r') do |f|
+ * f.flock(File::LOCK_SH)
+ * f.read
+ * end
+ * ```
*
*/
@@ -5560,7 +5586,7 @@ rb_stat_s_alloc(VALUE klass)
static VALUE
rb_stat_init(VALUE obj, VALUE fname)
{
- struct stat st, *nst;
+ struct stat st;
FilePathValue(fname);
fname = rb_str_encode_ospath(fname);
@@ -5568,13 +5594,11 @@ rb_stat_init(VALUE obj, VALUE fname)
rb_sys_fail_path(fname);
}
- if (DATA_PTR(obj)) {
- xfree(DATA_PTR(obj));
- DATA_PTR(obj) = NULL;
- }
- nst = ALLOC(struct stat);
- *nst = st;
- DATA_PTR(obj) = nst;
+ struct rb_stat *rb_st;
+ TypedData_Get_Struct(obj, struct rb_stat, &stat_data_type, rb_st);
+
+ rb_st->stat = st;
+ rb_st->initialized = true;
return Qnil;
}
@@ -5583,19 +5607,15 @@ rb_stat_init(VALUE obj, VALUE fname)
static VALUE
rb_stat_init_copy(VALUE copy, VALUE orig)
{
- struct stat *nst;
-
if (!OBJ_INIT_COPY(copy, orig)) return copy;
- if (DATA_PTR(copy)) {
- xfree(DATA_PTR(copy));
- DATA_PTR(copy) = 0;
- }
- if (DATA_PTR(orig)) {
- nst = ALLOC(struct stat);
- *nst = *(struct stat*)DATA_PTR(orig);
- DATA_PTR(copy) = nst;
- }
+ struct rb_stat *orig_rb_st;
+ TypedData_Get_Struct(orig, struct rb_stat, &stat_data_type, orig_rb_st);
+
+ struct rb_stat *copy_rb_st;
+ TypedData_Get_Struct(copy, struct rb_stat, &stat_data_type, copy_rb_st);
+
+ *copy_rb_st = *orig_rb_st;
return copy;
}
@@ -5879,10 +5899,8 @@ rb_stat_wr(VALUE obj)
if ((st->st_mode & (S_IROTH)) == S_IROTH) {
return UINT2NUM(st->st_mode & (S_IRUGO|S_IWUGO|S_IXUGO));
}
- else {
- return Qnil;
- }
#endif
+ return Qnil;
}
/*
@@ -5967,15 +5985,13 @@ rb_stat_W(VALUE obj)
static VALUE
rb_stat_ww(VALUE obj)
{
-#ifdef S_IROTH
+#ifdef S_IWOTH
struct stat *st = get_stat(obj);
if ((st->st_mode & (S_IWOTH)) == S_IWOTH) {
return UINT2NUM(st->st_mode & (S_IRUGO|S_IWUGO|S_IXUGO));
}
- else {
- return Qnil;
- }
#endif
+ return Qnil;
}
/*
@@ -6091,7 +6107,7 @@ rb_stat_z(VALUE obj)
* the file otherwise.
*
* File.stat("testfile").size? #=> 66
- * File.stat("/dev/null").size? #=> nil
+ * File.stat(File::NULL).size? #=> nil
*
*/
@@ -6374,7 +6390,11 @@ rb_file_load_ok(const char *path)
#endif
0);
int fd = rb_cloexec_open(path, mode, 0);
- if (fd == -1) return 0;
+ if (fd < 0) {
+ if (!rb_gc_for_fd(errno)) return 0;
+ fd = rb_cloexec_open(path, mode, 0);
+ if (fd < 0) return 0;
+ }
rb_update_max_fd(fd);
ret = ruby_is_fd_loadable(fd);
(void)close(fd);
@@ -6532,7 +6552,7 @@ const char ruby_null_device[] =
* \Class \File extends module FileTest, supporting such singleton methods
* as <tt>File.exist?</tt>.
*
- * === About the Examples
+ * == About the Examples
*
* Many examples here use these variables:
*
@@ -6540,11 +6560,11 @@ const char ruby_null_device[] =
*
* == Access Modes
*
- * \Methods File.new and File.open each create a \File object for a given file path.
+ * Methods File.new and File.open each create a \File object for a given file path.
*
* === \String Access Modes
*
- * \Methods File.new and File.open each may take string argument +mode+, which:
+ * Methods File.new and File.open each may take string argument +mode+, which:
*
* - Begins with a 1- or 2-character
* {read/write mode}[rdoc-ref:File@Read-2FWrite+Mode].
@@ -7135,7 +7155,6 @@ const char ruby_null_device[] =
*
* Note that file permissions are quite different from the _mode_
* of a file stream (\File object).
- * See IO@Modes.
*
* In a \File object, the permissions are available thus,
* where method +mode+, despite its name, returns permissions:
@@ -7181,7 +7200,7 @@ const char ruby_null_device[] =
*
* == \File \Constants
*
- * Various constants for use in \File and \IO methods
+ * Various constants for use in \File and IO methods
* may be found in module File::Constants;
* an array of their names is returned by <tt>File::Constants.constants</tt>.
*
@@ -7191,7 +7210,7 @@ const char ruby_null_device[] =
*
* - Inherits from {class IO}[rdoc-ref:IO@What-27s+Here],
* in particular, methods for creating, reading, and writing files
- * - Includes {module FileTest}[rdoc-ref:FileTest@What-27s+Here].
+ * - Includes module FileTest,
* which provides dozens of additional methods.
*
* Here, class \File provides methods that are useful for:
@@ -7236,15 +7255,15 @@ const char ruby_null_device[] =
*
* _Times_
*
- * - ::atime: Returns a \Time for the most recent access to the given file.
- * - ::birthtime: Returns a \Time for the creation of the given file.
- * - ::ctime: Returns a \Time for the metadata change of the given file.
- * - ::mtime: Returns a \Time for the most recent data modification to
+ * - ::atime: Returns a Time for the most recent access to the given file.
+ * - ::birthtime: Returns a Time for the creation of the given file.
+ * - ::ctime: Returns a Time for the metadata change of the given file.
+ * - ::mtime: Returns a Time for the most recent data modification to
* the content of the given file.
- * - #atime: Returns a \Time for the most recent access to +self+.
- * - #birthtime: Returns a \Time the creation for +self+.
- * - #ctime: Returns a \Time for the metadata change of +self+.
- * - #mtime: Returns a \Time for the most recent data modification
+ * - #atime: Returns a Time for the most recent access to +self+.
+ * - #birthtime: Returns a Time the creation for +self+.
+ * - #ctime: Returns a Time for the metadata change of +self+.
+ * - #mtime: Returns a Time for the most recent data modification
* to the content of +self+.
*
* _Types_
@@ -7433,93 +7452,396 @@ Init_File(void)
/*
* Document-module: File::Constants
*
- * File::Constants provides file-related constants. All possible
- * file constants are listed in the documentation but they may not all
- * be present on your platform.
+ * \Module +File::Constants+ defines file-related constants.
+ *
+ * There are two families of constants here:
+ *
+ * - Those having to do with {file access}[rdoc-ref:File::Constants@File+Access].
+ * - Those having to do with {filename globbing}[rdoc-ref:File::Constants@Filename+Globbing+Constants+-28File-3A-3AFNM_-2A-29].
+ *
+ * \File constants defined for the local process may be retrieved
+ * with method File::Constants.constants:
+ *
+ * File::Constants.constants.take(5)
+ * # => [:RDONLY, :WRONLY, :RDWR, :APPEND, :CREAT]
+ *
+ * == \File Access
+ *
+ * \File-access constants may be used with optional argument +mode+ in calls
+ * to the following methods:
+ *
+ * - File.new.
+ * - File.open.
+ * - IO.for_fd.
+ * - IO.new.
+ * - IO.open.
+ * - IO.popen.
+ * - IO.reopen.
+ * - IO.sysopen.
+ * - StringIO.new.
+ * - StringIO.open.
+ * - StringIO#reopen.
+ *
+ * === Read/Write Access
+ *
+ * Read-write access for a stream
+ * may be specified by a file-access constant.
+ *
+ * The constant may be specified as part of a bitwise OR of other such constants.
+ *
+ * Any combination of the constants in this section may be specified.
+ *
+ * ==== File::RDONLY
+ *
+ * Flag File::RDONLY specifies the the stream should be opened for reading only:
+ *
+ * filepath = '/tmp/t.tmp'
+ * f = File.new(filepath, File::RDONLY)
+ * f.write('Foo') # Raises IOError (not opened for writing).
+ *
+ * ==== File::WRONLY
+ *
+ * Flag File::WRONLY specifies that the stream should be opened for writing only:
+ *
+ * f = File.new(filepath, File::WRONLY)
+ * f.read # Raises IOError (not opened for reading).
+ *
+ * ==== File::RDWR
+ *
+ * Flag File::RDWR specifies that the stream should be opened
+ * for both reading and writing:
+ *
+ * f = File.new(filepath, File::RDWR)
+ * f.write('Foo') # => 3
+ * f.rewind # => 0
+ * f.read # => "Foo"
+ *
+ * === \File Positioning
+ *
+ * ==== File::APPEND
+ *
+ * Flag File::APPEND specifies that the stream should be opened
+ * in append mode.
+ *
+ * Before each write operation, the position is set to end-of-stream.
+ * The modification of the position and the following write operation
+ * are performed as a single atomic step.
+ *
+ * ==== File::TRUNC
*
- * If the underlying platform doesn't define a constant the corresponding
- * Ruby constant is not defined.
+ * Flag File::TRUNC specifies that the stream should be truncated
+ * at its beginning.
+ * If the file exists and is successfully opened for writing,
+ * it is to be truncated to position zero;
+ * its ctime and mtime are updated.
+ *
+ * There is no effect on a FIFO special file or a terminal device.
+ * The effect on other file types is implementation-defined.
+ * The result of using File::TRUNC with File::RDONLY is undefined.
+ *
+ * === Creating and Preserving
+ *
+ * ==== File::CREAT
+ *
+ * Flag File::CREAT specifies that the stream should be created
+ * if it does not already exist.
+ *
+ * If the file exists:
+ *
+ * - Raise an exception if File::EXCL is also specified.
+ * - Otherwise, do nothing.
+ *
+ * If the file does not exist, then it is created.
+ * Upon successful completion, the atime, ctime, and mtime of the file are updated,
+ * and the ctime and mtime of the parent directory are updated.
+ *
+ * ==== File::EXCL
+ *
+ * Flag File::EXCL specifies that the stream should not already exist;
+ * If flags File::CREAT and File::EXCL are both specified
+ * and the stream already exists, an exception is raised.
+ *
+ * The check for the existence and creation of the file is performed as an
+ * atomic operation.
+ *
+ * If both File::EXCL and File::CREAT are specified and the path names a symbolic link,
+ * an exception is raised regardless of the contents of the symbolic link.
+ *
+ * If File::EXCL is specified and File::CREAT is not specified,
+ * the result is undefined.
+ *
+ * === POSIX \File \Constants
+ *
+ * Some file-access constants are defined only on POSIX-compliant systems;
+ * those are:
+ *
+ * - File::SYNC.
+ * - File::DSYNC.
+ * - File::RSYNC.
+ * - File::DIRECT.
+ * - File::NOATIME.
+ * - File::NOCTTY.
+ * - File::NOFOLLOW.
+ * - File::TMPFILE.
+ *
+ * ==== File::SYNC, File::RSYNC, and File::DSYNC
+ *
+ * Flag File::SYNC, File::RSYNC, or File::DSYNC
+ * specifies synchronization of I/O operations with the underlying file system.
+ *
+ * These flags are valid only for POSIX-compliant systems.
+ *
+ * - File::SYNC specifies that all write operations (both data and metadata)
+ * are immediately to be flushed to the underlying storage device.
+ * This means that the data is written to the storage device,
+ * and the file's metadata (e.g., file size, timestamps, permissions)
+ * are also synchronized.
+ * This guarantees that data is safely stored on the storage medium
+ * before returning control to the calling program.
+ * This flag can have a significant impact on performance
+ * since it requires synchronous writes, which can be slower
+ * compared to asynchronous writes.
+ *
+ * - File::RSYNC specifies that any read operations on the file will not return
+ * until all outstanding write operations
+ * (those that have been issued but not completed) are also synchronized.
+ * This is useful when you want to read the most up-to-date data,
+ * which may still be in the process of being written.
+ *
+ * - File::DSYNC specifies that all _data_ write operations
+ * are immediately to be flushed to the underlying storage device;
+ * this differs from File::SYNC, which requires that _metadata_
+ * also be synchronized.
+ *
+ * Note that the behavior of these flags may vary slightly
+ * depending on the operating system and filesystem being used.
+ * Additionally, using these flags can have an impact on performance
+ * due to the synchronous nature of the I/O operations,
+ * so they should be used judiciously,
+ * especially in performance-critical applications.
+ *
+ * ==== File::NOCTTY
+ *
+ * Flag File::NOCTTY specifies that if the stream is a terminal device,
+ * that device does not become the controlling terminal for the process.
+ *
+ * Defined only for POSIX-compliant systems.
+ *
+ * ==== File::DIRECT
+ *
+ * Flag File::DIRECT requests that cache effects of the I/O to and from the stream
+ * be minimized.
+ *
+ * Defined only for POSIX-compliant systems.
+ *
+ * ==== File::NOATIME
+ *
+ * Flag File::NOATIME specifies that act of opening the stream
+ * should not modify its access time (atime).
+ *
+ * Defined only for POSIX-compliant systems.
+ *
+ * ==== File::NOFOLLOW
+ *
+ * Flag File::NOFOLLOW specifies that if path is a symbolic link,
+ * it should not be followed.
+ *
+ * Defined only for POSIX-compliant systems.
+ *
+ * ==== File::TMPFILE
+ *
+ * Flag File::TMPFILE specifies that the opened stream
+ * should be a new temporary file.
+ *
+ * Defined only for POSIX-compliant systems.
+ *
+ * === Other File-Access \Constants
+ *
+ * ==== File::NONBLOCK
+ *
+ * When possible, the file is opened in nonblocking mode.
+ * Neither the open operation nor any subsequent I/O operations on
+ * the file will cause the calling process to wait.
+ *
+ * ==== File::BINARY
+ *
+ * Flag File::BINARY specifies that the stream is to be accessed in binary mode.
+ *
+ * ==== File::SHARE_DELETE (Windows Only)
+ *
+ * Flag File::SHARE_DELETE enables other processes to open the stream
+ * with delete access.
+ *
+ * If the stream is opened for (local) delete access without File::SHARE_DELETE,
+ * and another process attempts to open it with delete access,
+ * the attempt fails and the stream is not opened for that process.
+ *
+ * == Locking
+ *
+ * Four file constants relate to stream locking;
+ * see File#flock:
+ *
+ * ==== File::LOCK_EX
+ *
+ * Flag File::LOCK_EX specifies an exclusive lock;
+ * only one process a a time may lock the stream.
+ *
+ * ==== File::LOCK_NB
+ *
+ * Flag File::LOCK_NB specifies non-blocking locking for the stream;
+ * may be combined with File::LOCK_EX or File::LOCK_SH.
+ *
+ * ==== File::LOCK_SH
+ *
+ * Flag File::LOCK_SH specifies that multiple processes may lock
+ * the stream at the same time.
+ *
+ * ==== File::LOCK_UN
+ *
+ * Flag File::LOCK_UN specifies that the stream is not to be locked.
+ *
+ * == Filename Globbing \Constants (File::FNM_*)
+ *
+ * Filename-globbing constants may be used with optional argument +flags+
+ * in calls to the following methods:
+ *
+ * - Dir.glob.
+ * - File.fnmatch.
+ * - Pathname#fnmatch.
+ * - Pathname.glob.
+ * - Pathname#glob.
+ *
+ * The constants are:
+ *
+ * ==== File::FNM_CASEFOLD
+ *
+ * Flag File::FNM_CASEFOLD makes patterns case insensitive
+ * for File.fnmatch (but not Dir.glob).
+ *
+ * ==== File::FNM_DOTMATCH
+ *
+ * Flag File::FNM_DOTMATCH makes the <tt>'*'</tt> pattern
+ * match a filename starting with <tt>'.'</tt>.
+ *
+ * ==== File::FNM_EXTGLOB
+ *
+ * Flag File::FNM_EXTGLOB enables pattern <tt>'{_a_,_b_}'</tt>,
+ * which matches pattern '_a_' and pattern '_b_';
+ * behaves like
+ * a {regexp union}[rdoc-ref:Regexp.union]
+ * (e.g., <tt>'(?:_a_|_b_)'</tt>):
+ *
+ * pattern = '{LEGAL,BSDL}'
+ * Dir.glob(pattern) # => ["LEGAL", "BSDL"]
+ * Pathname.glob(pattern) # => [#<Pathname:LEGAL>, #<Pathname:BSDL>]
+ * pathname.glob(pattern) # => [#<Pathname:LEGAL>, #<Pathname:BSDL>]
+ *
+ * ==== File::FNM_NOESCAPE
+ *
+ * Flag File::FNM_NOESCAPE disables <tt>'\'</tt> escaping.
+ *
+ * ==== File::FNM_PATHNAME
+ *
+ * Flag File::FNM_PATHNAME specifies that patterns <tt>'*'</tt> and <tt>'?'</tt>
+ * do not match the directory separator
+ * (the value of constant File::SEPARATOR).
+ *
+ * ==== File::FNM_SHORTNAME (Windows Only)
+ *
+ * Flag File::FNM_SHORTNAME Allows patterns to match short names if they exist.
+ *
+ * ==== File::FNM_SYSCASE
+ *
+ * Flag File::FNM_SYSCASE specifies that case sensitivity
+ * is the same as in the underlying operating system;
+ * effective for File.fnmatch, but not Dir.glob.
+ *
+ * == Other \Constants
+ *
+ * ==== File::NULL
+ *
+ * Flag File::NULL contains the string value of the null device:
+ *
+ * - On a Unix-like OS, <tt>'/dev/null'</tt>.
+ * - On Windows, <tt>'NUL'</tt>.
*
- * Your platform documentations (e.g. man open(2)) may describe more
- * detailed information.
*/
rb_mFConst = rb_define_module_under(rb_cFile, "Constants");
rb_include_module(rb_cIO, rb_mFConst);
-
- /* open for reading only */
+ /* {File::RDONLY}[rdoc-ref:File::Constants@File-3A-3ARDONLY] */
rb_define_const(rb_mFConst, "RDONLY", INT2FIX(O_RDONLY));
- /* open for writing only */
+ /* {File::WRONLY}[rdoc-ref:File::Constants@File-3A-3AWRONLY] */
rb_define_const(rb_mFConst, "WRONLY", INT2FIX(O_WRONLY));
- /* open for reading and writing */
+ /* {File::RDWR}[rdoc-ref:File::Constants@File-3A-3ARDWR] */
rb_define_const(rb_mFConst, "RDWR", INT2FIX(O_RDWR));
- /* append on each write */
+ /* {File::APPEND}[rdoc-ref:File::Constants@File-3A-3AAPPEND] */
rb_define_const(rb_mFConst, "APPEND", INT2FIX(O_APPEND));
- /* create file if it does not exist */
+ /* {File::CREAT}[rdoc-ref:File::Constants@File-3A-3ACREAT] */
rb_define_const(rb_mFConst, "CREAT", INT2FIX(O_CREAT));
- /* error if CREAT and the file exists */
+ /* {File::EXCL}[rdoc-ref:File::Constants@File-3A-3AEXCL] */
rb_define_const(rb_mFConst, "EXCL", INT2FIX(O_EXCL));
#if defined(O_NDELAY) || defined(O_NONBLOCK)
# ifndef O_NONBLOCK
# define O_NONBLOCK O_NDELAY
# endif
- /* do not block on open or for data to become available */
+ /* {File::NONBLOCK}[rdoc-ref:File::Constants@File-3A-3ANONBLOCK] */
rb_define_const(rb_mFConst, "NONBLOCK", INT2FIX(O_NONBLOCK));
#endif
- /* truncate size to 0 */
+ /* {File::TRUNC}[rdoc-ref:File::Constants@File-3A-3ATRUNC] */
rb_define_const(rb_mFConst, "TRUNC", INT2FIX(O_TRUNC));
#ifdef O_NOCTTY
- /* not to make opened IO the controlling terminal device */
+ /* {File::NOCTTY}[rdoc-ref:File::Constants@File-3A-3ANOCTTY] */
rb_define_const(rb_mFConst, "NOCTTY", INT2FIX(O_NOCTTY));
#endif
#ifndef O_BINARY
# define O_BINARY 0
#endif
- /* disable line code conversion */
+ /* {File::BINARY}[rdoc-ref:File::Constants@File-3A-3ABINARY] */
rb_define_const(rb_mFConst, "BINARY", INT2FIX(O_BINARY));
#ifndef O_SHARE_DELETE
# define O_SHARE_DELETE 0
#endif
- /* can delete opened file */
+ /* {File::SHARE_DELETE}[rdoc-ref:File::Constants@File-3A-3ASHARE_DELETE+-28Windows+Only-29] */
rb_define_const(rb_mFConst, "SHARE_DELETE", INT2FIX(O_SHARE_DELETE));
#ifdef O_SYNC
- /* any write operation perform synchronously */
+ /* {File::SYNC}[rdoc-ref:File::Constants@File-3A-3ASYNC-2C+File-3A-3ARSYNC-2C+and+File-3A-3ADSYNC] */
rb_define_const(rb_mFConst, "SYNC", INT2FIX(O_SYNC));
#endif
#ifdef O_DSYNC
- /* any write operation perform synchronously except some meta data */
+ /* {File::DSYNC}[rdoc-ref:File::Constants@File-3A-3ASYNC-2C+File-3A-3ARSYNC-2C+and+File-3A-3ADSYNC] */
rb_define_const(rb_mFConst, "DSYNC", INT2FIX(O_DSYNC));
#endif
#ifdef O_RSYNC
- /* any read operation perform synchronously. used with SYNC or DSYNC. */
+ /* {File::RSYNC}[rdoc-ref:File::Constants@File-3A-3ASYNC-2C+File-3A-3ARSYNC-2C+and+File-3A-3ADSYNC] */
rb_define_const(rb_mFConst, "RSYNC", INT2FIX(O_RSYNC));
#endif
#ifdef O_NOFOLLOW
- /* do not follow symlinks */
+ /* {File::NOFOLLOW}[rdoc-ref:File::Constants@File-3A-3ANOFOLLOW] */
rb_define_const(rb_mFConst, "NOFOLLOW", INT2FIX(O_NOFOLLOW)); /* FreeBSD, Linux */
#endif
#ifdef O_NOATIME
- /* do not change atime */
+ /* {File::NOATIME}[rdoc-ref:File::Constants@File-3A-3ANOATIME] */
rb_define_const(rb_mFConst, "NOATIME", INT2FIX(O_NOATIME)); /* Linux */
#endif
#ifdef O_DIRECT
- /* Try to minimize cache effects of the I/O to and from this file. */
+ /* {File::DIRECT}[rdoc-ref:File::Constants@File-3A-3ADIRECT] */
rb_define_const(rb_mFConst, "DIRECT", INT2FIX(O_DIRECT));
#endif
#ifdef O_TMPFILE
- /* Create an unnamed temporary file */
+ /* {File::TMPFILE}[rdoc-ref:File::Constants@File-3A-3ATMPFILE] */
rb_define_const(rb_mFConst, "TMPFILE", INT2FIX(O_TMPFILE));
#endif
- /* shared lock. see File#flock */
+ /* {File::LOCK_SH}[rdoc-ref:File::Constants@File-3A-3ALOCK_SH] */
rb_define_const(rb_mFConst, "LOCK_SH", INT2FIX(LOCK_SH));
- /* exclusive lock. see File#flock */
+ /* {File::LOCK_EX}[rdoc-ref:File::Constants@File-3A-3ALOCK_EX] */
rb_define_const(rb_mFConst, "LOCK_EX", INT2FIX(LOCK_EX));
- /* unlock. see File#flock */
+ /* {File::LOCK_UN}[rdoc-ref:File::Constants@File-3A-3ALOCK_UN] */
rb_define_const(rb_mFConst, "LOCK_UN", INT2FIX(LOCK_UN));
- /* non-blocking lock. used with LOCK_SH or LOCK_EX. see File#flock */
+ /* {File::LOCK_NB}[rdoc-ref:File::Constants@File-3A-3ALOCK_NB] */
rb_define_const(rb_mFConst, "LOCK_NB", INT2FIX(LOCK_NB));
- /* Name of the null device */
+ /* {File::NULL}[rdoc-ref:File::Constants@File-3A-3ANULL] */
rb_define_const(rb_mFConst, "NULL", rb_fstring_cstr(ruby_null_device));
rb_define_global_function("test", rb_f_test, -1);
diff --git a/gc.c b/gc.c
index 3baed251f4..378e4a31cb 100644
--- a/gc.c
+++ b/gc.c
@@ -60,6 +60,15 @@
# endif
#endif
+#ifdef HAVE_MALLOC_TRIM
+# include <malloc.h>
+
+# ifdef __EMSCRIPTEN__
+/* malloc_trim is defined in emscripten/emmalloc.h on emscripten. */
+# include <emscripten/emmalloc.h>
+# endif
+#endif
+
#if !defined(PAGE_SIZE) && defined(HAVE_SYS_USER_H)
/* LIST_HEAD conflicts with sys/queue.h on macOS */
# include <sys/user.h>
@@ -95,12 +104,13 @@
#undef LIST_HEAD /* ccan/list conflicts with BSD-origin sys/queue.h. */
#include "constant.h"
+#include "darray.h"
#include "debug_counter.h"
#include "eval_intern.h"
-#include "gc.h"
#include "id_table.h"
#include "internal.h"
#include "internal/class.h"
+#include "internal/compile.h"
#include "internal/complex.h"
#include "internal/cont.h"
#include "internal/error.h"
@@ -119,7 +129,7 @@
#include "internal/thread.h"
#include "internal/variable.h"
#include "internal/warnings.h"
-#include "mjit.h"
+#include "rjit.h"
#include "probes.h"
#include "regint.h"
#include "ruby/debug.h"
@@ -131,7 +141,6 @@
#include "ruby_assert.h"
#include "ruby_atomic.h"
#include "symbol.h"
-#include "transient_heap.h"
#include "vm_core.h"
#include "vm_sync.h"
#include "vm_callinfo.h"
@@ -148,6 +157,68 @@
#define MAP_ANONYMOUS MAP_ANON
#endif
+
+static size_t malloc_offset = 0;
+#if defined(HAVE_MALLOC_USABLE_SIZE)
+static size_t
+gc_compute_malloc_offset(void)
+{
+ // Different allocators use different metadata storage strategies which result in different
+ // ideal sizes.
+ // For instance malloc(64) will waste 8B with glibc, but waste 0B with jemalloc.
+ // But malloc(56) will waste 0B with glibc, but waste 8B with jemalloc.
+ // So we try allocating 64, 56 and 48 bytes and select the first offset that doesn't
+ // waste memory.
+ // This was tested on Linux with glibc 2.35 and jemalloc 5, and for both it result in
+ // no wasted memory.
+ size_t offset = 0;
+ for (offset = 0; offset <= 16; offset += 8) {
+ size_t allocated = (64 - offset);
+ void *test_ptr = malloc(allocated);
+ size_t wasted = malloc_usable_size(test_ptr) - allocated;
+ free(test_ptr);
+
+ if (wasted == 0) {
+ return offset;
+ }
+ }
+ return 0;
+}
+#else
+static size_t
+gc_compute_malloc_offset(void)
+{
+ // If we don't have malloc_usable_size, we use powers of 2.
+ return 0;
+}
+#endif
+
+size_t
+rb_malloc_grow_capa(size_t current, size_t type_size)
+{
+ size_t current_capacity = current;
+ if (current_capacity < 4) {
+ current_capacity = 4;
+ }
+ current_capacity *= type_size;
+
+ // We double the current capacity.
+ size_t new_capacity = (current_capacity * 2);
+
+ // And round up to the next power of 2 if it's not already one.
+ if (rb_popcount64(new_capacity) != 1) {
+ new_capacity = (size_t)(1 << (64 - nlz_int64(new_capacity)));
+ }
+
+ new_capacity -= malloc_offset;
+ new_capacity /= type_size;
+ if (current > new_capacity) {
+ rb_bug("rb_malloc_grow_capa: current_capacity=%zu, new_capacity=%zu, malloc_offset=%zu", current, new_capacity, malloc_offset);
+ }
+ RUBY_ASSERT(new_capacity > current);
+ return new_capacity;
+}
+
static inline struct rbimpl_size_mul_overflow_tag
size_add_overflow(size_t x, size_t y)
{
@@ -291,6 +362,9 @@ rb_gc_guarded_ptr_val(volatile VALUE *ptr, VALUE val)
#ifndef GC_HEAP_GROWTH_MAX_SLOTS
#define GC_HEAP_GROWTH_MAX_SLOTS 0 /* 0 is disable */
#endif
+#ifndef GC_HEAP_REMEMBERED_WB_UNPROTECTED_OBJECTS_LIMIT_RATIO
+# define GC_HEAP_REMEMBERED_WB_UNPROTECTED_OBJECTS_LIMIT_RATIO 0.01
+#endif
#ifndef GC_HEAP_OLDOBJECT_LIMIT_FACTOR
#define GC_HEAP_OLDOBJECT_LIMIT_FACTOR 2.0
#endif
@@ -325,6 +399,14 @@ rb_gc_guarded_ptr_val(volatile VALUE *ptr, VALUE val)
#define GC_OLDMALLOC_LIMIT_MAX (128 * 1024 * 1024 /* 128MB */)
#endif
+#ifndef GC_CAN_COMPILE_COMPACTION
+#if defined(__wasi__) /* WebAssembly doesn't support signals */
+# define GC_CAN_COMPILE_COMPACTION 0
+#else
+# define GC_CAN_COMPILE_COMPACTION 1
+#endif
+#endif
+
#ifndef PRINT_MEASURE_LINE
#define PRINT_MEASURE_LINE 0
#endif
@@ -339,7 +421,7 @@ rb_gc_guarded_ptr_val(volatile VALUE *ptr, VALUE val)
#define TICK_TYPE 1
typedef struct {
- size_t heap_init_slots;
+ size_t size_pool_init_slots[SIZE_POOL_COUNT];
size_t heap_free_slots;
double growth_factor;
size_t growth_max_slots;
@@ -347,6 +429,7 @@ typedef struct {
double heap_free_slots_min_ratio;
double heap_free_slots_goal_ratio;
double heap_free_slots_max_ratio;
+ double uncollectible_wb_unprotected_objects_limit_ratio;
double oldobject_limit_factor;
size_t malloc_limit_min;
@@ -361,7 +444,7 @@ typedef struct {
} ruby_gc_params_t;
static ruby_gc_params_t gc_params = {
- GC_HEAP_INIT_SLOTS,
+ { 0 },
GC_HEAP_FREE_SLOTS,
GC_HEAP_GROWTH_FACTOR,
GC_HEAP_GROWTH_MAX_SLOTS,
@@ -369,6 +452,7 @@ static ruby_gc_params_t gc_params = {
GC_HEAP_FREE_SLOTS_MIN_RATIO,
GC_HEAP_FREE_SLOTS_GOAL_RATIO,
GC_HEAP_FREE_SLOTS_MAX_RATIO,
+ GC_HEAP_REMEMBERED_WB_UNPROTECTED_OBJECTS_LIMIT_RATIO,
GC_HEAP_OLDOBJECT_LIMIT_FACTOR,
GC_MALLOC_LIMIT_MIN,
@@ -427,16 +511,6 @@ int ruby_rgengc_debug;
// Note: using RUBY_ASSERT_WHEN() extend a macro in expr (info by nobu).
#define GC_ASSERT(expr) RUBY_ASSERT_MESG_WHEN(RGENGC_CHECK_MODE > 0, expr, #expr)
-/* RGENGC_OLD_NEWOBJ_CHECK
- * 0: disable all assertions
- * >0: make a OLD object when new object creation.
- *
- * Make one OLD object per RGENGC_OLD_NEWOBJ_CHECK WB protected objects creation.
- */
-#ifndef RGENGC_OLD_NEWOBJ_CHECK
-#define RGENGC_OLD_NEWOBJ_CHECK 0
-#endif
-
/* RGENGC_PROFILE
* 0: disable RGenGC profiling
* 1: enable profiling for basic information
@@ -469,9 +543,6 @@ int ruby_rgengc_debug;
#ifndef GC_PROFILE_DETAIL_MEMORY
#define GC_PROFILE_DETAIL_MEMORY 0
#endif
-#ifndef GC_ENABLE_INCREMENTAL_MARK
-#define GC_ENABLE_INCREMENTAL_MARK USE_RINCGC
-#endif
#ifndef GC_ENABLE_LAZY_SWEEP
#define GC_ENABLE_LAZY_SWEEP 1
#endif
@@ -490,7 +561,7 @@ int ruby_rgengc_debug;
#endif
#ifndef GC_DEBUG_STRESS_TO_CLASS
-#define GC_DEBUG_STRESS_TO_CLASS 0
+#define GC_DEBUG_STRESS_TO_CLASS RUBY_DEBUG
#endif
#ifndef RGENGC_OBJ_INFO
@@ -688,15 +759,15 @@ typedef struct mark_stack {
#define SIZE_POOL_EDEN_HEAP(size_pool) (&(size_pool)->eden_heap)
#define SIZE_POOL_TOMB_HEAP(size_pool) (&(size_pool)->tomb_heap)
+typedef int (*gc_compact_compare_func)(const void *l, const void *r, void *d);
+
typedef struct rb_heap_struct {
struct heap_page *free_pages;
struct ccan_list_head pages;
struct heap_page *sweeping_page; /* iterator for .pages */
struct heap_page *compact_cursor;
uintptr_t compact_cursor_index;
-#if GC_ENABLE_INCREMENTAL_MARK
struct heap_page *pooled_pages;
-#endif
size_t total_pages; /* total page count in a heap */
size_t total_slots; /* total slot count (about total_pages * HEAP_PAGE_OBJ_LIMIT) */
} rb_heap_t;
@@ -710,12 +781,13 @@ typedef struct rb_size_pool_struct {
size_t total_allocated_pages;
size_t total_freed_pages;
size_t force_major_gc_count;
+ size_t force_incremental_marking_finish_count;
+ size_t total_allocated_objects;
+ size_t total_freed_objects;
-#if USE_RVARGC
/* Sweeping statistics */
size_t freed_slots;
size_t empty_slots;
-#endif
rb_heap_t eden_heap;
rb_heap_t tomb_heap;
@@ -748,16 +820,13 @@ typedef struct rb_objspace {
unsigned int during_compacting : 1;
unsigned int during_reference_updating : 1;
unsigned int gc_stressful: 1;
- unsigned int has_hook: 1;
+ unsigned int has_newobj_hook: 1;
unsigned int during_minor_gc : 1;
-#if GC_ENABLE_INCREMENTAL_MARK
unsigned int during_incremental_marking : 1;
-#endif
unsigned int measure_gc : 1;
} flags;
rb_event_flag_t hook_events;
- size_t total_allocated_objects;
VALUE next_object_id;
rb_size_pool_t size_pools[SIZE_POOL_COUNT];
@@ -826,9 +895,14 @@ typedef struct rb_objspace {
/* basic statistics */
size_t count;
- size_t total_freed_objects;
- uint64_t total_time_ns;
- struct timespec start_time;
+ uint64_t marking_time_ns;
+ struct timespec marking_start_time;
+ uint64_t sweeping_time_ns;
+ struct timespec sweeping_start_time;
+
+ /* Weak references */
+ size_t weak_references_count;
+ size_t retained_weak_references_count;
} profile;
struct gc_list *global_list;
@@ -860,14 +934,15 @@ typedef struct rb_objspace {
size_t moved_up_count_table[T_MASK];
size_t moved_down_count_table[T_MASK];
size_t total_moved;
+
+ /* This function will be used, if set, to sort the heap prior to compaction */
+ gc_compact_compare_func compare_func;
} rcompactor;
-#if GC_ENABLE_INCREMENTAL_MARK
struct {
size_t pooled_slots;
size_t step_slots;
} rincgc;
-#endif
st_table *id_to_obj_tbl;
st_table *obj_to_id_tbl;
@@ -875,6 +950,9 @@ typedef struct rb_objspace {
#if GC_DEBUG_STRESS_TO_CLASS
VALUE stress_to_class;
#endif
+
+ rb_darray(VALUE *) weak_references;
+ rb_postponed_job_handle_t finalize_deferred_pjob;
} rb_objspace_t;
@@ -897,7 +975,7 @@ enum {
#define HEAP_PAGE_ALIGN (1 << HEAP_PAGE_ALIGN_LOG)
#define HEAP_PAGE_SIZE HEAP_PAGE_ALIGN
-#if GC_ENABLE_INCREMENTAL_MARK && !defined(INCREMENTAL_MARK_STEP_ALLOCATIONS)
+#if !defined(INCREMENTAL_MARK_STEP_ALLOCATIONS)
# define INCREMENTAL_MARK_STEP_ALLOCATIONS 500
#endif
@@ -943,15 +1021,19 @@ static const bool HEAP_PAGE_ALLOC_USE_MMAP = false;
static bool heap_page_alloc_use_mmap;
#endif
+#define RVALUE_AGE_BIT_COUNT 2
+#define RVALUE_AGE_BIT_MASK (((bits_t)1 << RVALUE_AGE_BIT_COUNT) - 1)
+
struct heap_page {
short slot_size;
short total_slots;
short free_slots;
short final_slots;
+ short pinned_slots;
struct {
unsigned int before_sweep : 1;
unsigned int has_remembered_objects : 1;
- unsigned int has_uncollectible_shady_objects : 1;
+ unsigned int has_uncollectible_wb_unprotected_objects : 1;
unsigned int in_tomb : 1;
} flags;
@@ -968,8 +1050,11 @@ struct heap_page {
bits_t uncollectible_bits[HEAP_PAGE_BITMAP_LIMIT];
bits_t marking_bits[HEAP_PAGE_BITMAP_LIMIT];
+ bits_t remembered_bits[HEAP_PAGE_BITMAP_LIMIT];
+
/* If set, the object is not movable */
bits_t pinned_bits[HEAP_PAGE_BITMAP_LIMIT];
+ bits_t age_bits[HEAP_PAGE_BITMAP_LIMIT * RVALUE_AGE_BIT_COUNT];
};
/*
@@ -1013,9 +1098,43 @@ asan_unlock_freelist(struct heap_page *page)
#define GC_SWEEP_PAGES_FREEABLE_PER_STEP 3
+#define RVALUE_AGE_BITMAP_INDEX(n) (NUM_IN_PAGE(n) / (BITS_BITLENGTH / RVALUE_AGE_BIT_COUNT))
+#define RVALUE_AGE_BITMAP_OFFSET(n) ((NUM_IN_PAGE(n) % (BITS_BITLENGTH / RVALUE_AGE_BIT_COUNT)) * RVALUE_AGE_BIT_COUNT)
+
+#define RVALUE_OLD_AGE 3
+
+static int
+RVALUE_AGE_GET(VALUE obj)
+{
+ bits_t *age_bits = GET_HEAP_PAGE(obj)->age_bits;
+ return (int)(age_bits[RVALUE_AGE_BITMAP_INDEX(obj)] >> RVALUE_AGE_BITMAP_OFFSET(obj)) & RVALUE_AGE_BIT_MASK;
+}
+
+static void
+RVALUE_AGE_SET(VALUE obj, int age)
+{
+ RUBY_ASSERT(age <= RVALUE_OLD_AGE);
+ bits_t *age_bits = GET_HEAP_PAGE(obj)->age_bits;
+ // clear the bits
+ age_bits[RVALUE_AGE_BITMAP_INDEX(obj)] &= ~(RVALUE_AGE_BIT_MASK << (RVALUE_AGE_BITMAP_OFFSET(obj)));
+ // shift the correct value in
+ age_bits[RVALUE_AGE_BITMAP_INDEX(obj)] |= ((bits_t)age << RVALUE_AGE_BITMAP_OFFSET(obj));
+ if (age == RVALUE_OLD_AGE) {
+ RB_FL_SET_RAW(obj, RUBY_FL_PROMOTED);
+ }
+ else {
+ RB_FL_UNSET_RAW(obj, RUBY_FL_PROMOTED);
+ }
+}
+
/* Aliases */
#define rb_objspace (*rb_objspace_of(GET_VM()))
#define rb_objspace_of(vm) ((vm)->objspace)
+#define unless_objspace(objspace) \
+ rb_objspace_t *objspace; \
+ rb_vm_t *unless_objspace_vm = GET_VM(); \
+ if (unless_objspace_vm) objspace = unless_objspace_vm->objspace; \
+ else /* return; or objspace will be warned uninitialized */
#define ruby_initial_gc_stress gc_params.gc_stress
@@ -1041,8 +1160,10 @@ VALUE *ruby_initial_gc_stress_ptr = &ruby_initial_gc_stress;
#define ruby_gc_stress_mode objspace->gc_stress_mode
#if GC_DEBUG_STRESS_TO_CLASS
#define stress_to_class objspace->stress_to_class
+#define set_stress_to_class(c) (stress_to_class = (c))
#else
-#define stress_to_class 0
+#define stress_to_class (objspace, 0)
+#define set_stress_to_class(c) (objspace, (c))
#endif
#if 0
@@ -1159,32 +1280,43 @@ total_freed_pages(rb_objspace_t *objspace)
return count;
}
+static inline size_t
+total_allocated_objects(rb_objspace_t *objspace)
+{
+ size_t count = 0;
+ for (int i = 0; i < SIZE_POOL_COUNT; i++) {
+ rb_size_pool_t *size_pool = &size_pools[i];
+ count += size_pool->total_allocated_objects;
+ }
+ return count;
+}
+
+static inline size_t
+total_freed_objects(rb_objspace_t *objspace)
+{
+ size_t count = 0;
+ for (int i = 0; i < SIZE_POOL_COUNT; i++) {
+ rb_size_pool_t *size_pool = &size_pools[i];
+ count += size_pool->total_freed_objects;
+ }
+ return count;
+}
+
#define gc_mode(objspace) gc_mode_verify((enum gc_mode)(objspace)->flags.mode)
-#define gc_mode_set(objspace, mode) ((objspace)->flags.mode = (unsigned int)gc_mode_verify(mode))
+#define gc_mode_set(objspace, m) ((objspace)->flags.mode = (unsigned int)gc_mode_verify(m))
#define is_marking(objspace) (gc_mode(objspace) == gc_mode_marking)
#define is_sweeping(objspace) (gc_mode(objspace) == gc_mode_sweeping)
#define is_full_marking(objspace) ((objspace)->flags.during_minor_gc == FALSE)
-#if GC_ENABLE_INCREMENTAL_MARK
#define is_incremental_marking(objspace) ((objspace)->flags.during_incremental_marking != FALSE)
-#else
-#define is_incremental_marking(objspace) FALSE
-#endif
-#if GC_ENABLE_INCREMENTAL_MARK
#define will_be_incremental_marking(objspace) ((objspace)->rgengc.need_major_gc != GPR_FLAG_NONE)
-#else
-#define will_be_incremental_marking(objspace) FALSE
-#endif
-#if GC_ENABLE_INCREMENTAL_MARK
#define GC_INCREMENTAL_SWEEP_SLOT_COUNT 2048
-#endif
+#define GC_INCREMENTAL_SWEEP_POOL_SLOT_COUNT 1024
#define is_lazy_sweeping(objspace) (GC_ENABLE_LAZY_SWEEP && has_sweeping_pages(objspace))
#if SIZEOF_LONG == SIZEOF_VOIDP
-# define nonspecial_obj_id(obj) (VALUE)((SIGNED_VALUE)(obj)|FIXNUM_FLAG)
# define obj_id_to_ref(objid) ((objid) ^ FIXNUM_FLAG) /* unset FIXNUM_FLAG */
#elif SIZEOF_LONG_LONG == SIZEOF_VOIDP
-# define nonspecial_obj_id(obj) LL2NUM((SIGNED_VALUE)(obj) / 2)
# define obj_id_to_ref(objid) (FIXNUM_P(objid) ? \
((objid) ^ FIXNUM_FLAG) : (NUM2PTR(objid) << 1))
#else
@@ -1210,24 +1342,22 @@ int ruby_gc_debug_indent = 0;
VALUE rb_mGC;
int ruby_disable_gc = 0;
int ruby_enable_autocompact = 0;
+#if RGENGC_CHECK_MODE
+gc_compact_compare_func ruby_autocompact_compare_func;
+#endif
-void rb_iseq_mark_and_update(rb_iseq_t *iseq, bool referece_updating);
+void rb_iseq_mark_and_move(rb_iseq_t *iseq, bool referece_updating);
void rb_iseq_free(const rb_iseq_t *iseq);
size_t rb_iseq_memsize(const rb_iseq_t *iseq);
void rb_vm_update_references(void *ptr);
void rb_gcdebug_print_obj_condition(VALUE obj);
-static VALUE define_final0(VALUE obj, VALUE block);
-
NORETURN(static void *gc_vraise(void *ptr));
NORETURN(static void gc_raise(VALUE exc, const char *fmt, ...));
NORETURN(static void negative_size_allocation_error(const char *));
static void init_mark_stack(mark_stack_t *stack);
-
-static int ready_to_gc(rb_objspace_t *objspace);
-
static int garbage_collect(rb_objspace_t *, unsigned int reason);
static int gc_start(rb_objspace_t *objspace, unsigned int reason);
@@ -1235,8 +1365,7 @@ static void gc_rest(rb_objspace_t *objspace);
enum gc_enter_event {
gc_enter_event_start,
- gc_enter_event_mark_continue,
- gc_enter_event_sweep_continue,
+ gc_enter_event_continue,
gc_enter_event_rest,
gc_enter_event_finalizer,
gc_enter_event_rb_memerror,
@@ -1244,46 +1373,26 @@ enum gc_enter_event {
static inline void gc_enter(rb_objspace_t *objspace, enum gc_enter_event event, unsigned int *lock_lev);
static inline void gc_exit(rb_objspace_t *objspace, enum gc_enter_event event, unsigned int *lock_lev);
-
-static void gc_marks(rb_objspace_t *objspace, int full_mark);
-static void gc_marks_start(rb_objspace_t *objspace, int full);
-static void gc_marks_finish(rb_objspace_t *objspace);
-static void gc_marks_rest(rb_objspace_t *objspace);
-static void gc_marks_continue(rb_objspace_t *objspace, rb_size_pool_t *size_pool, rb_heap_t *heap);
+static void gc_marking_enter(rb_objspace_t *objspace);
+static void gc_marking_exit(rb_objspace_t *objspace);
+static void gc_sweeping_enter(rb_objspace_t *objspace);
+static void gc_sweeping_exit(rb_objspace_t *objspace);
+static bool gc_marks_continue(rb_objspace_t *objspace, rb_size_pool_t *size_pool, rb_heap_t *heap);
static void gc_sweep(rb_objspace_t *objspace);
-static void gc_sweep_start(rb_objspace_t *objspace);
-#if USE_RVARGC
static void gc_sweep_finish_size_pool(rb_objspace_t *objspace, rb_size_pool_t *size_pool);
-#endif
-static void gc_sweep_finish(rb_objspace_t *objspace);
-static int gc_sweep_step(rb_objspace_t *objspace, rb_size_pool_t *size_pool, rb_heap_t *heap);
-static void gc_sweep_rest(rb_objspace_t *objspace);
static void gc_sweep_continue(rb_objspace_t *objspace, rb_size_pool_t *size_pool, rb_heap_t *heap);
static inline void gc_mark(rb_objspace_t *objspace, VALUE ptr);
static inline void gc_pin(rb_objspace_t *objspace, VALUE ptr);
static inline void gc_mark_and_pin(rb_objspace_t *objspace, VALUE ptr);
-static void gc_mark_ptr(rb_objspace_t *objspace, VALUE ptr);
NO_SANITIZE("memory", static void gc_mark_maybe(rb_objspace_t *objspace, VALUE ptr));
-static void gc_mark_children(rb_objspace_t *objspace, VALUE ptr);
static int gc_mark_stacked_objects_incremental(rb_objspace_t *, size_t count);
-static int gc_mark_stacked_objects_all(rb_objspace_t *);
-static void gc_grey(rb_objspace_t *objspace, VALUE ptr);
-
-static inline int gc_mark_set(rb_objspace_t *objspace, VALUE obj);
NO_SANITIZE("memory", static inline int is_pointer_to_heap(rb_objspace_t *objspace, void *ptr));
-static void push_mark_stack(mark_stack_t *, VALUE);
-static int pop_mark_stack(mark_stack_t *, VALUE *);
-static size_t mark_stack_size(mark_stack_t *stack);
-static void shrink_stack_chunk_cache(mark_stack_t *stack);
-
static size_t obj_memsize_of(VALUE obj, int use_all_types);
static void gc_verify_internal_consistency(rb_objspace_t *objspace);
-static int gc_verify_heap_page(rb_objspace_t *objspace, struct heap_page *page, VALUE obj);
-static int gc_verify_heap_pages(rb_objspace_t *objspace);
static void gc_stress_set(rb_objspace_t *objspace, VALUE flag);
static VALUE gc_disable_no_rest(rb_objspace_t *);
@@ -1320,6 +1429,8 @@ PRINTF_ARGS(static void gc_report_body(int level, rb_objspace_t *objspace, const
static const char *obj_info(VALUE obj);
static const char *obj_type_name(VALUE obj);
+static void gc_finalize_deferred(void *dmy);
+
/*
* 1 - TSC (H/W Time Stamp Counter)
* 2 - getrusage
@@ -1361,7 +1472,7 @@ tick(void)
return ((unsigned long long)lo)|( ((unsigned long long)hi)<<32);
}
-#elif defined(__powerpc64__) && GCC_VERSION_SINCE(4,8,0)
+#elif defined(__powerpc64__) && (GCC_VERSION_SINCE(4,8,0) || defined(__clang__))
typedef unsigned long long tick_t;
#define PRItick "llu"
@@ -1495,21 +1606,10 @@ asan_poison_object_restore(VALUE obj, void *ptr)
#define RVALUE_PAGE_UNCOLLECTIBLE(page, obj) MARKED_IN_BITMAP((page)->uncollectible_bits, (obj))
#define RVALUE_PAGE_MARKING(page, obj) MARKED_IN_BITMAP((page)->marking_bits, (obj))
-#define RVALUE_OLD_AGE 3
-#define RVALUE_AGE_SHIFT 5 /* FL_PROMOTED0 bit */
-
-static int rgengc_remembered(rb_objspace_t *objspace, VALUE obj);
-static int rgengc_remembered_sweep(rb_objspace_t *objspace, VALUE obj);
static int rgengc_remember(rb_objspace_t *objspace, VALUE obj);
static void rgengc_mark_and_rememberset_clear(rb_objspace_t *objspace, rb_heap_t *heap);
static void rgengc_rememberset_mark(rb_objspace_t *objspace, rb_heap_t *heap);
-static inline int
-RVALUE_FLAGS_AGE(VALUE flags)
-{
- return (int)((flags & (FL_PROMOTED0 | FL_PROMOTED1)) >> RVALUE_AGE_SHIFT);
-}
-
static int
check_rvalue_consistency_force(const VALUE obj, int terminate)
{
@@ -1547,8 +1647,9 @@ check_rvalue_consistency_force(const VALUE obj, int terminate)
const int wb_unprotected_bit = RVALUE_WB_UNPROTECTED_BITMAP(obj) != 0;
const int uncollectible_bit = RVALUE_UNCOLLECTIBLE_BITMAP(obj) != 0;
const int mark_bit = RVALUE_MARK_BITMAP(obj) != 0;
- const int marking_bit = RVALUE_MARKING_BITMAP(obj) != 0, remembered_bit = marking_bit;
- const int age = RVALUE_FLAGS_AGE(RBASIC(obj)->flags);
+ const int marking_bit = RVALUE_MARKING_BITMAP(obj) != 0;
+ const int remembered_bit = MARKED_IN_BITMAP(GET_HEAP_PAGE(obj)->remembered_bits, obj) != 0;
+ const int age = RVALUE_AGE_GET((VALUE)obj);
if (GET_HEAP_PAGE(obj)->flags.in_tomb) {
fprintf(stderr, "check_rvalue_consistency: %s is in tomb page.\n", obj_info(obj));
@@ -1681,7 +1782,7 @@ static inline int
RVALUE_REMEMBERED(VALUE obj)
{
check_rvalue_consistency(obj);
- return RVALUE_MARKING_BITMAP(obj) != 0;
+ return MARKED_IN_BITMAP(GET_HEAP_PAGE(obj)->remembered_bits, obj) != 0;
}
static inline int
@@ -1692,34 +1793,20 @@ RVALUE_UNCOLLECTIBLE(VALUE obj)
}
static inline int
-RVALUE_OLD_P_RAW(VALUE obj)
-{
- const VALUE promoted = FL_PROMOTED0 | FL_PROMOTED1;
- return (RBASIC(obj)->flags & promoted) == promoted;
-}
-
-static inline int
RVALUE_OLD_P(VALUE obj)
{
+ GC_ASSERT(!RB_SPECIAL_CONST_P(obj));
check_rvalue_consistency(obj);
- return RVALUE_OLD_P_RAW(obj);
+ // Because this will only ever be called on GC controlled objects,
+ // we can use the faster _RAW function here
+ return RB_OBJ_PROMOTED_RAW(obj);
}
-#if RGENGC_CHECK_MODE || GC_DEBUG
-static inline int
-RVALUE_AGE(VALUE obj)
-{
- check_rvalue_consistency(obj);
- return RVALUE_FLAGS_AGE(RBASIC(obj)->flags);
-}
-#endif
-
static inline void
RVALUE_PAGE_OLD_UNCOLLECTIBLE_SET(rb_objspace_t *objspace, struct heap_page *page, VALUE obj)
{
MARK_IN_BITMAP(&page->uncollectible_bits[0], obj);
objspace->rgengc.old_objects++;
- rb_transient_heap_promote(obj);
#if RGENGC_PROFILE >= 2
objspace->profile.total_promoted_count++;
@@ -1734,64 +1821,39 @@ RVALUE_OLD_UNCOLLECTIBLE_SET(rb_objspace_t *objspace, VALUE obj)
RVALUE_PAGE_OLD_UNCOLLECTIBLE_SET(objspace, GET_HEAP_PAGE(obj), obj);
}
-static inline VALUE
-RVALUE_FLAGS_AGE_SET(VALUE flags, int age)
-{
- flags &= ~(FL_PROMOTED0 | FL_PROMOTED1);
- flags |= (age << RVALUE_AGE_SHIFT);
- return flags;
-}
-
/* set age to age+1 */
static inline void
RVALUE_AGE_INC(rb_objspace_t *objspace, VALUE obj)
{
- VALUE flags = RBASIC(obj)->flags;
- int age = RVALUE_FLAGS_AGE(flags);
+ int age = RVALUE_AGE_GET((VALUE)obj);
if (RGENGC_CHECK_MODE && age == RVALUE_OLD_AGE) {
rb_bug("RVALUE_AGE_INC: can not increment age of OLD object %s.", obj_info(obj));
}
age++;
- RBASIC(obj)->flags = RVALUE_FLAGS_AGE_SET(flags, age);
+ RVALUE_AGE_SET(obj, age);
if (age == RVALUE_OLD_AGE) {
RVALUE_OLD_UNCOLLECTIBLE_SET(objspace, obj);
}
- check_rvalue_consistency(obj);
-}
-
-/* set age to RVALUE_OLD_AGE */
-static inline void
-RVALUE_AGE_SET_OLD(rb_objspace_t *objspace, VALUE obj)
-{
- check_rvalue_consistency(obj);
- GC_ASSERT(!RVALUE_OLD_P(obj));
-
- RBASIC(obj)->flags = RVALUE_FLAGS_AGE_SET(RBASIC(obj)->flags, RVALUE_OLD_AGE);
- RVALUE_OLD_UNCOLLECTIBLE_SET(objspace, obj);
check_rvalue_consistency(obj);
}
-/* set age to RVALUE_OLD_AGE - 1 */
static inline void
RVALUE_AGE_SET_CANDIDATE(rb_objspace_t *objspace, VALUE obj)
{
check_rvalue_consistency(obj);
GC_ASSERT(!RVALUE_OLD_P(obj));
-
- RBASIC(obj)->flags = RVALUE_FLAGS_AGE_SET(RBASIC(obj)->flags, RVALUE_OLD_AGE - 1);
-
+ RVALUE_AGE_SET(obj, RVALUE_OLD_AGE - 1);
check_rvalue_consistency(obj);
}
static inline void
-RVALUE_DEMOTE_RAW(rb_objspace_t *objspace, VALUE obj)
+RVALUE_AGE_RESET(VALUE obj)
{
- RBASIC(obj)->flags = RVALUE_FLAGS_AGE_SET(RBASIC(obj)->flags, 0);
- CLEAR_IN_BITMAP(GET_HEAP_UNCOLLECTIBLE_BITS(obj), obj);
+ RVALUE_AGE_SET(obj, 0);
}
static inline void
@@ -1801,10 +1863,11 @@ RVALUE_DEMOTE(rb_objspace_t *objspace, VALUE obj)
GC_ASSERT(RVALUE_OLD_P(obj));
if (!is_incremental_marking(objspace) && RVALUE_REMEMBERED(obj)) {
- CLEAR_IN_BITMAP(GET_HEAP_MARKING_BITS(obj), obj);
+ CLEAR_IN_BITMAP(GET_HEAP_PAGE(obj)->remembered_bits, obj);
}
- RVALUE_DEMOTE_RAW(objspace, obj);
+ CLEAR_IN_BITMAP(GET_HEAP_UNCOLLECTIBLE_BITS(obj), obj);
+ RVALUE_AGE_RESET(obj);
if (RVALUE_MARKED(obj)) {
objspace->rgengc.old_objects--;
@@ -1813,22 +1876,6 @@ RVALUE_DEMOTE(rb_objspace_t *objspace, VALUE obj)
check_rvalue_consistency(obj);
}
-static inline void
-RVALUE_AGE_RESET_RAW(VALUE obj)
-{
- RBASIC(obj)->flags = RVALUE_FLAGS_AGE_SET(RBASIC(obj)->flags, 0);
-}
-
-static inline void
-RVALUE_AGE_RESET(VALUE obj)
-{
- check_rvalue_consistency(obj);
- GC_ASSERT(!RVALUE_OLD_P(obj));
-
- RVALUE_AGE_RESET_RAW(obj);
- check_rvalue_consistency(obj);
-}
-
static inline int
RVALUE_BLACK_P(VALUE obj)
{
@@ -1865,6 +1912,10 @@ rb_objspace_alloc(void)
rb_objspace_t *objspace = calloc1(sizeof(rb_objspace_t));
objspace->flags.measure_gc = 1;
malloc_limit = gc_params.malloc_limit_min;
+ objspace->finalize_deferred_pjob = rb_postponed_job_preregister(0, gc_finalize_deferred, objspace);
+ if (objspace->finalize_deferred_pjob == POSTPONED_JOB_HANDLE_INVALID) {
+ rb_bug("Could not preregister postponed job for GC");
+ }
for (int i = 0; i < SIZE_POOL_COUNT; i++) {
rb_size_pool_t *size_pool = &size_pools[i];
@@ -1875,6 +1926,8 @@ rb_objspace_alloc(void)
ccan_list_head_init(&SIZE_POOL_TOMB_HEAP(size_pool)->pages);
}
+ rb_darray_make_without_gc(&objspace->weak_references, 0);
+
dont_gc_on();
return objspace;
@@ -1890,10 +1943,8 @@ rb_objspace_free(rb_objspace_t *objspace)
if (is_lazy_sweeping(objspace))
rb_bug("lazy sweeping underway when freeing object space");
- if (objspace->profile.records) {
- free(objspace->profile.records);
- objspace->profile.records = 0;
- }
+ free(objspace->profile.records);
+ objspace->profile.records = NULL;
if (global_list) {
struct gc_list *list, *next;
@@ -1904,7 +1955,8 @@ rb_objspace_free(rb_objspace_t *objspace)
}
if (heap_pages_sorted) {
size_t i;
- for (i = 0; i < heap_allocated_pages; ++i) {
+ size_t total_heap_pages = heap_allocated_pages;
+ for (i = 0; i < total_heap_pages; ++i) {
heap_page_free(objspace, heap_pages_sorted[i]);
}
free(heap_pages_sorted);
@@ -1925,6 +1977,8 @@ rb_objspace_free(rb_objspace_t *objspace)
free_stack_chunks(&objspace->mark_stack);
mark_stack_free_cache(&objspace->mark_stack);
+ rb_darray_free_without_gc(objspace->weak_references);
+
free(objspace);
}
@@ -1998,6 +2052,8 @@ heap_page_add_freeobj(rb_objspace_t *objspace, struct heap_page *page, VALUE obj
page->freelist = p;
asan_lock_freelist(page);
+ RVALUE_AGE_RESET(obj);
+
if (RGENGC_CHECK_MODE &&
/* obj should belong to page */
!(page->start <= (uintptr_t)obj &&
@@ -2025,7 +2081,6 @@ heap_add_freepage(rb_heap_t *heap, struct heap_page *page)
asan_lock_freelist(page);
}
-#if GC_ENABLE_INCREMENTAL_MARK
static inline void
heap_add_poolpage(rb_objspace_t *objspace, rb_heap_t *heap, struct heap_page *page)
{
@@ -2039,7 +2094,6 @@ heap_add_poolpage(rb_objspace_t *objspace, rb_heap_t *heap, struct heap_page *pa
asan_lock_freelist(page);
}
-#endif
static void
heap_unlink_page(rb_objspace_t *objspace, rb_heap_t *heap, struct heap_page *page)
@@ -2092,7 +2146,7 @@ heap_pages_free_unused_pages(rb_objspace_t *objspace)
}
if (has_pages_in_tomb_heap) {
- for (i = j = 1; j < heap_allocated_pages; i++) {
+ for (i = j = 0; j < heap_allocated_pages; i++) {
struct heap_page *page = heap_pages_sorted[i];
if (page->flags.in_tomb && page->free_slots == page->total_slots) {
@@ -2112,6 +2166,11 @@ heap_pages_free_unused_pages(rb_objspace_t *objspace)
GC_ASSERT(himem <= heap_pages_himem);
heap_pages_himem = himem;
+ struct heap_page *lopage = heap_pages_sorted[0];
+ uintptr_t lomem = (uintptr_t)lopage->start;
+ GC_ASSERT(lomem >= heap_pages_lomem);
+ heap_pages_lomem = lomem;
+
GC_ASSERT(j == heap_allocated_pages);
}
}
@@ -2323,6 +2382,7 @@ heap_assign_page(rb_objspace_t *objspace, rb_size_pool_t *size_pool, rb_heap_t *
heap_add_freepage(heap, page);
}
+#if GC_CAN_COMPILE_COMPACTION
static void
heap_add_pages(rb_objspace_t *objspace, rb_size_pool_t *size_pool, rb_heap_t *heap, size_t add)
{
@@ -2336,6 +2396,26 @@ heap_add_pages(rb_objspace_t *objspace, rb_size_pool_t *size_pool, rb_heap_t *he
GC_ASSERT(size_pool->allocatable_pages == 0);
}
+#endif
+
+static size_t
+slots_to_pages_for_size_pool(rb_objspace_t *objspace, rb_size_pool_t *size_pool, size_t slots)
+{
+ size_t multiple = size_pool->slot_size / BASE_SLOT_SIZE;
+ /* Due to alignment, heap pages may have one less slot. We should
+ * ensure there is enough pages to guarantee that we will have at
+ * least the required number of slots after allocating all the pages. */
+ size_t slots_per_page = (HEAP_PAGE_OBJ_LIMIT / multiple) - 1;
+ return CEILDIV(slots, slots_per_page);
+}
+
+static size_t
+minimum_pages_for_size_pool(rb_objspace_t *objspace, rb_size_pool_t *size_pool)
+{
+ size_t size_pool_idx = size_pool - size_pools;
+ size_t init_slots = gc_params.size_pool_init_slots[size_pool_idx];
+ return slots_to_pages_for_size_pool(objspace, size_pool, init_slots);
+}
static size_t
heap_extend_pages(rb_objspace_t *objspace, rb_size_pool_t *size_pool, size_t free_slots, size_t total_slots, size_t used)
@@ -2347,8 +2427,7 @@ heap_extend_pages(rb_objspace_t *objspace, rb_size_pool_t *size_pool, size_t fre
next_used = (size_t)(used * gc_params.growth_factor);
}
else if (total_slots == 0) {
- int multiple = size_pool->slot_size / BASE_SLOT_SIZE;
- next_used = (gc_params.heap_init_slots * multiple) / HEAP_PAGE_OBJ_LIMIT;
+ next_used = minimum_pages_for_size_pool(objspace, size_pool);
}
else {
/* Find `f' where free_slots = f * total_slots * goal_ratio
@@ -2403,9 +2482,14 @@ heap_increment(rb_objspace_t *objspace, rb_size_pool_t *size_pool, rb_heap_t *he
static void
gc_continue(rb_objspace_t *objspace, rb_size_pool_t *size_pool, rb_heap_t *heap)
{
+ unsigned int lock_lev;
+ gc_enter(objspace, gc_enter_event_continue, &lock_lev);
+
/* Continue marking if in incremental marking. */
- if (heap->free_pages == NULL && is_incremental_marking(objspace)) {
- gc_marks_continue(objspace, size_pool, heap);
+ if (is_incremental_marking(objspace)) {
+ if (gc_marks_continue(objspace, size_pool, heap)) {
+ gc_sweep(objspace);
+ }
}
/* Continue sweeping if in lazy sweeping or the previous incremental
@@ -2413,6 +2497,8 @@ gc_continue(rb_objspace_t *objspace, rb_size_pool_t *size_pool, rb_heap_t *heap)
if (heap->free_pages == NULL && is_lazy_sweeping(objspace)) {
gc_sweep_continue(objspace, size_pool, heap);
}
+
+ gc_exit(objspace, gc_enter_event_continue, &lock_lev);
}
static void
@@ -2468,22 +2554,17 @@ rb_objspace_set_event_hook(const rb_event_flag_t event)
{
rb_objspace_t *objspace = &rb_objspace;
objspace->hook_events = event & RUBY_INTERNAL_EVENT_OBJSPACE_MASK;
- objspace->flags.has_hook = (objspace->hook_events != 0);
+ objspace->flags.has_newobj_hook = !!(objspace->hook_events & RUBY_INTERNAL_EVENT_NEWOBJ);
}
static void
gc_event_hook_body(rb_execution_context_t *ec, rb_objspace_t *objspace, const rb_event_flag_t event, VALUE data)
{
- const VALUE *pc = ec->cfp->pc;
- if (pc && VM_FRAME_RUBYFRAME_P(ec->cfp)) {
- /* increment PC because source line is calculated with PC-1 */
- ec->cfp->pc++;
- }
+ if (UNLIKELY(!ec->cfp)) return;
EXEC_EVENT_HOOK(ec, event, ec->cfp->self, 0, 0, 0, data);
- ec->cfp->pc = pc;
}
-#define gc_event_hook_available_p(objspace) ((objspace)->flags.has_hook)
+#define gc_event_newobj_hook_needed_p(objspace) ((objspace)->flags.has_newobj_hook)
#define gc_event_hook_needed_p(objspace, event) ((objspace)->hook_events & (event))
#define gc_event_hook_prep(objspace, event, data, prep) do { \
@@ -2506,6 +2587,11 @@ newobj_init(VALUE klass, VALUE flags, int wb_protected, rb_objspace_t *objspace,
p->as.basic.flags = flags;
*((VALUE *)&p->as.basic.klass) = klass;
+ int t = flags & RUBY_T_MASK;
+ if (t == T_CLASS || t == T_MODULE || t == T_ICLASS) {
+ RVALUE_AGE_SET_CANDIDATE(objspace, obj);
+ }
+
#if RACTOR_CHECK_MODE
rb_ractor_setup_belonging(obj);
#endif
@@ -2522,13 +2608,7 @@ newobj_init(VALUE klass, VALUE flags, int wb_protected, rb_objspace_t *objspace,
GC_ASSERT(RVALUE_OLD_P(obj) == FALSE);
GC_ASSERT(RVALUE_WB_UNPROTECTED(obj) == FALSE);
- if (flags & FL_PROMOTED1) {
- if (RVALUE_AGE(obj) != 2) rb_bug("newobj: %s of age (%d) != 2.", obj_info(obj), RVALUE_AGE(obj));
- }
- else {
- if (RVALUE_AGE(obj) > 0) rb_bug("newobj: %s of age (%d) > 0.", obj_info(obj), RVALUE_AGE(obj));
- }
- if (rgengc_remembered(objspace, (VALUE)obj)) rb_bug("newobj: %s is remembered.", obj_info(obj));
+ if (RVALUE_REMEMBERED((VALUE)obj)) rb_bug("newobj: %s is remembered.", obj_info(obj));
}
RB_VM_LOCK_LEAVE_NO_BARRIER();
#endif
@@ -2538,9 +2618,6 @@ newobj_init(VALUE klass, VALUE flags, int wb_protected, rb_objspace_t *objspace,
MARK_IN_BITMAP(GET_HEAP_WB_UNPROTECTED_BITS(obj), obj);
}
- // TODO: make it atomic, or ractor local
- objspace->total_allocated_objects++;
-
#if RGENGC_PROFILE
if (wb_protected) {
objspace->profile.total_generated_normal_object_count++;
@@ -2563,24 +2640,6 @@ newobj_init(VALUE klass, VALUE flags, int wb_protected, rb_objspace_t *objspace,
gc_report(5, objspace, "newobj: %s\n", obj_info(obj));
-#if RGENGC_OLD_NEWOBJ_CHECK > 0
- {
- static int newobj_cnt = RGENGC_OLD_NEWOBJ_CHECK;
-
- if (!is_incremental_marking(objspace) &&
- flags & FL_WB_PROTECTED && /* do not promote WB unprotected objects */
- ! RB_TYPE_P(obj, T_ARRAY)) { /* array.c assumes that allocated objects are new */
- if (--newobj_cnt == 0) {
- newobj_cnt = RGENGC_OLD_NEWOBJ_CHECK;
-
- gc_mark_set(objspace, obj);
- RVALUE_AGE_SET_OLD(objspace, obj);
-
- rb_gc_writebarrier_remember(obj);
- }
- }
- }
-#endif
// RUBY_DEBUG_LOG("obj:%p (%s)", (void *)obj, obj_type_name(obj));
return obj;
}
@@ -2627,7 +2686,6 @@ ractor_cache_allocate_slot(rb_objspace_t *objspace, rb_ractor_newobj_cache_t *ca
rb_ractor_newobj_size_pool_cache_t *size_pool_cache = &cache->size_pool_caches[size_pool_idx];
RVALUE *p = size_pool_cache->freelist;
-#if GC_ENABLE_INCREMENTAL_MARK
if (is_incremental_marking(objspace)) {
// Not allowed to allocate without running an incremental marking step
if (cache->incremental_mark_step_allocated_slots >= INCREMENTAL_MARK_STEP_ALLOCATIONS) {
@@ -2638,17 +2696,12 @@ ractor_cache_allocate_slot(rb_objspace_t *objspace, rb_ractor_newobj_cache_t *ca
cache->incremental_mark_step_allocated_slots++;
}
}
-#endif
if (p) {
VALUE obj = (VALUE)p;
MAYBE_UNUSED(const size_t) stride = size_pool_slot_size(size_pool_idx);
size_pool_cache->freelist = p->as.free.next;
-#if USE_RVARGC
asan_unpoison_memory_region(p, stride, true);
-#else
- asan_unpoison_object(obj, true);
-#endif
#if RGENGC_CHECK_MODE
GC_ASSERT(rb_gc_obj_slot_size(obj) == stride);
// zero clear
@@ -2718,7 +2771,6 @@ newobj_fill(VALUE obj, VALUE v1, VALUE v2, VALUE v3)
static inline size_t
size_pool_idx_for_size(size_t size)
{
-#if USE_RVARGC
size += RVALUE_OVERHEAD;
size_t slot_count = CEILDIV(size, BASE_SLOT_SIZE);
@@ -2727,7 +2779,8 @@ size_pool_idx_for_size(size_t size)
size_t size_pool_idx = 64 - nlz_int64(slot_count - 1);
if (size_pool_idx >= SIZE_POOL_COUNT) {
- rb_bug("size_pool_idx_for_size: allocation size too large");
+ rb_bug("size_pool_idx_for_size: allocation size too large "
+ "(size=%"PRIuSIZE"u, size_pool_idx=%"PRIuSIZE"u)", size, size_pool_idx);
}
#if RGENGC_CHECK_MODE
@@ -2737,10 +2790,6 @@ size_pool_idx_for_size(size_t size)
#endif
return size_pool_idx;
-#else
- GC_ASSERT(size <= sizeof(RVALUE));
- return 0;
-#endif
}
static VALUE
@@ -2765,15 +2814,13 @@ newobj_alloc(rb_objspace_t *objspace, rb_ractor_t *cr, size_t size_pool_idx, boo
{
ASSERT_vm_locking();
-#if GC_ENABLE_INCREMENTAL_MARK
if (is_incremental_marking(objspace)) {
- gc_marks_continue(objspace, size_pool, heap);
+ gc_continue(objspace, size_pool, heap);
cache->incremental_mark_step_allocated_slots = 0;
// Retry allocation after resetting incremental_mark_step_allocated_slots
obj = ractor_cache_allocate_slot(objspace, cache, size_pool_idx);
}
-#endif
if (obj == Qfalse) {
// Get next free page (possibly running GC)
@@ -2792,9 +2839,17 @@ newobj_alloc(rb_objspace_t *objspace, rb_ractor_t *cr, size_t size_pool_idx, boo
}
}
+ size_pool->total_allocated_objects++;
+
return obj;
}
+static void
+newobj_zero_slot(VALUE obj)
+{
+ memset((char *)obj + sizeof(struct RBasic), 0, rb_gc_obj_slot_size(obj) - sizeof(struct RBasic));
+}
+
ALWAYS_INLINE(static VALUE newobj_slowpath(VALUE klass, VALUE flags, rb_objspace_t *objspace, rb_ractor_t *cr, int wb_protected, size_t size_pool_idx));
static inline VALUE
@@ -2820,12 +2875,9 @@ newobj_slowpath(VALUE klass, VALUE flags, rb_objspace_t *objspace, rb_ractor_t *
}
obj = newobj_alloc(objspace, cr, size_pool_idx, true);
-#if SHAPE_IN_BASIC_FLAGS
- flags |= (VALUE)(size_pool_idx) << SHAPE_FLAG_SHIFT;
-#endif
newobj_init(klass, flags, wb_protected, objspace, obj);
- gc_event_hook_prep(objspace, RUBY_INTERNAL_EVENT_NEWOBJ, obj, newobj_fill(obj, 0, 0, 0));
+ gc_event_hook_prep(objspace, RUBY_INTERNAL_EVENT_NEWOBJ, obj, newobj_zero_slot(obj));
}
RB_VM_LOCK_LEAVE_CR_LEV(cr, &lev);
@@ -2858,25 +2910,24 @@ newobj_of0(VALUE klass, VALUE flags, int wb_protected, rb_ractor_t *cr, size_t a
RB_DEBUG_COUNTER_INC(obj_newobj);
(void)RB_DEBUG_COUNTER_INC_IF(obj_newobj_wb_unprotected, !wb_protected);
-#if GC_DEBUG_STRESS_TO_CLASS
if (UNLIKELY(stress_to_class)) {
long i, cnt = RARRAY_LEN(stress_to_class);
for (i = 0; i < cnt; ++i) {
if (klass == RARRAY_AREF(stress_to_class, i)) rb_memerror();
}
}
-#endif
size_t size_pool_idx = size_pool_idx_for_size(alloc_size);
+ if (SHAPE_IN_BASIC_FLAGS || (flags & RUBY_T_MASK) == T_OBJECT) {
+ flags |= (VALUE)size_pool_idx << SHAPE_FLAG_SHIFT;
+ }
+
if (!UNLIKELY(during_gc ||
ruby_gc_stressful ||
- gc_event_hook_available_p(objspace)) &&
+ gc_event_newobj_hook_needed_p(objspace)) &&
wb_protected) {
obj = newobj_alloc(objspace, cr, size_pool_idx, false);
-#if SHAPE_IN_BASIC_FLAGS
- flags |= (VALUE)size_pool_idx << SHAPE_FLAG_SHIFT;
-#endif
newobj_init(klass, flags, wb_protected, objspace, obj);
}
else {
@@ -2891,14 +2942,7 @@ newobj_of0(VALUE klass, VALUE flags, int wb_protected, rb_ractor_t *cr, size_t a
}
static inline VALUE
-newobj_of(VALUE klass, VALUE flags, VALUE v1, VALUE v2, VALUE v3, int wb_protected, size_t alloc_size)
-{
- VALUE obj = newobj_of0(klass, flags, wb_protected, GET_RACTOR(), alloc_size);
- return newobj_fill(obj, v1, v2, v3);
-}
-
-static inline VALUE
-newobj_of_cr(rb_ractor_t *cr, VALUE klass, VALUE flags, VALUE v1, VALUE v2, VALUE v3, int wb_protected, size_t alloc_size)
+newobj_of(rb_ractor_t *cr, VALUE klass, VALUE flags, VALUE v1, VALUE v2, VALUE v3, int wb_protected, size_t alloc_size)
{
VALUE obj = newobj_of0(klass, flags, wb_protected, cr, alloc_size);
return newobj_fill(obj, v1, v2, v3);
@@ -2908,21 +2952,14 @@ VALUE
rb_wb_unprotected_newobj_of(VALUE klass, VALUE flags, size_t size)
{
GC_ASSERT((flags & FL_WB_PROTECTED) == 0);
- return newobj_of(klass, flags, 0, 0, 0, FALSE, size);
+ return newobj_of(GET_RACTOR(), klass, flags, 0, 0, 0, FALSE, size);
}
VALUE
-rb_wb_protected_newobj_of(VALUE klass, VALUE flags, size_t size)
+rb_wb_protected_newobj_of(rb_execution_context_t *ec, VALUE klass, VALUE flags, size_t size)
{
GC_ASSERT((flags & FL_WB_PROTECTED) == 0);
- return newobj_of(klass, flags, 0, 0, 0, TRUE, size);
-}
-
-VALUE
-rb_ec_wb_protected_newobj_of(rb_execution_context_t *ec, VALUE klass, VALUE flags, size_t size)
-{
- GC_ASSERT((flags & FL_WB_PROTECTED) == 0);
- return newobj_of_cr(rb_ec_ractor_ptr(ec), klass, flags, 0, 0, 0, TRUE, size);
+ return newobj_of(rb_ec_ractor_ptr(ec), klass, flags, 0, 0, 0, TRUE, size);
}
/* for compatibility */
@@ -2930,13 +2967,7 @@ rb_ec_wb_protected_newobj_of(rb_execution_context_t *ec, VALUE klass, VALUE flag
VALUE
rb_newobj(void)
{
- return newobj_of(0, T_NONE, 0, 0, 0, FALSE, RVALUE_SIZE);
-}
-
-static size_t
-rb_obj_embedded_size(uint32_t numiv)
-{
- return offsetof(struct RObject, as.ary) + (sizeof(VALUE) * numiv);
+ return newobj_of(GET_RACTOR(), 0, T_NONE, 0, 0, 0, FALSE, RVALUE_SIZE);
}
static VALUE
@@ -2946,20 +2977,15 @@ rb_class_instance_allocate_internal(VALUE klass, VALUE flags, bool wb_protected)
GC_ASSERT(flags & ROBJECT_EMBED);
size_t size;
-#if USE_RVARGC
uint32_t index_tbl_num_entries = RCLASS_EXT(klass)->max_iv_count;
size = rb_obj_embedded_size(index_tbl_num_entries);
if (!rb_gc_size_allocatable_p(size)) {
size = sizeof(struct RObject);
}
-#else
- size = sizeof(struct RObject);
-#endif
- VALUE obj = newobj_of(klass, flags, 0, 0, 0, wb_protected, size);
- RUBY_ASSERT(rb_shape_get_shape(obj)->type == SHAPE_ROOT ||
- rb_shape_get_shape(obj)->type == SHAPE_INITIAL_CAPACITY);
+ VALUE obj = newobj_of(GET_RACTOR(), klass, flags, 0, 0, 0, wb_protected, size);
+ RUBY_ASSERT(rb_shape_get_shape(obj)->type == SHAPE_ROOT);
// Set the shape to the specific T_OBJECT shape which is always
// SIZE_POOL_COUNT away from the root shape.
@@ -2983,7 +3009,7 @@ rb_newobj_of(VALUE klass, VALUE flags)
return rb_class_instance_allocate_internal(klass, (flags | ROBJECT_EMBED) & ~FL_WB_PROTECTED, flags & FL_WB_PROTECTED);
}
else {
- return newobj_of(klass, flags & ~FL_WB_PROTECTED, 0, 0, 0, flags & FL_WB_PROTECTED, RVALUE_SIZE);
+ return newobj_of(GET_RACTOR(), klass, flags & ~FL_WB_PROTECTED, 0, 0, 0, flags & FL_WB_PROTECTED, RVALUE_SIZE);
}
}
@@ -3023,7 +3049,7 @@ rb_imemo_new(enum imemo_type type, VALUE v1, VALUE v2, VALUE v3, VALUE v0)
{
size_t size = RVALUE_SIZE;
VALUE flags = T_IMEMO | (type << FL_USHIFT);
- return newobj_of(v0, flags, v1, v2, v3, TRUE, size);
+ return newobj_of(GET_RACTOR(), v0, flags, v1, v2, v3, TRUE, size);
}
static VALUE
@@ -3031,7 +3057,7 @@ rb_imemo_tmpbuf_new(VALUE v1, VALUE v2, VALUE v3, VALUE v0)
{
size_t size = sizeof(struct rb_imemo_tmpbuf_struct);
VALUE flags = T_IMEMO | (imemo_tmpbuf << FL_USHIFT);
- return newobj_of(v0, flags, v1, v2, v3, FALSE, size);
+ return newobj_of(GET_RACTOR(), v0, flags, v1, v2, v3, FALSE, size);
}
static VALUE
@@ -3090,7 +3116,7 @@ rb_imemo_new_debug(enum imemo_type type, VALUE v1, VALUE v2, VALUE v3, VALUE v0,
}
#endif
-MJIT_FUNC_EXPORTED VALUE
+VALUE
rb_class_allocate_instance(VALUE klass)
{
return rb_class_instance_allocate_internal(klass, T_OBJECT | ROBJECT_EMBED, RGENGC_WB_PROTECTED_OBJECT);
@@ -3110,7 +3136,7 @@ rb_data_object_wrap(VALUE klass, void *datap, RUBY_DATA_FUNC dmark, RUBY_DATA_FU
{
RUBY_ASSERT_ALWAYS(dfree != (RUBY_DATA_FUNC)1);
if (klass) rb_data_object_check(klass);
- return newobj_of(klass, T_DATA, (VALUE)dmark, (VALUE)dfree, (VALUE)datap, FALSE, sizeof(struct RTypedData));
+ return newobj_of(GET_RACTOR(), klass, T_DATA, (VALUE)dmark, (VALUE)dfree, (VALUE)datap, !dmark, sizeof(struct RTypedData));
}
VALUE
@@ -3121,18 +3147,42 @@ rb_data_object_zalloc(VALUE klass, size_t size, RUBY_DATA_FUNC dmark, RUBY_DATA_
return obj;
}
-VALUE
-rb_data_typed_object_wrap(VALUE klass, void *datap, const rb_data_type_t *type)
+static VALUE
+typed_data_alloc(VALUE klass, VALUE typed_flag, void *datap, const rb_data_type_t *type, size_t size)
{
RBIMPL_NONNULL_ARG(type);
if (klass) rb_data_object_check(klass);
- return newobj_of(klass, T_DATA, (VALUE)type, (VALUE)1, (VALUE)datap, type->flags & RUBY_FL_WB_PROTECTED, sizeof(struct RTypedData));
+ bool wb_protected = (type->flags & RUBY_FL_WB_PROTECTED) || !type->function.dmark;
+ return newobj_of(GET_RACTOR(), klass, T_DATA, (VALUE)type, 1 | typed_flag, (VALUE)datap, wb_protected, size);
+}
+
+VALUE
+rb_data_typed_object_wrap(VALUE klass, void *datap, const rb_data_type_t *type)
+{
+ if (UNLIKELY(type->flags & RUBY_TYPED_EMBEDDABLE)) {
+ rb_raise(rb_eTypeError, "Cannot wrap an embeddable TypedData");
+ }
+
+ return typed_data_alloc(klass, 0, datap, type, sizeof(struct RTypedData));
}
VALUE
rb_data_typed_object_zalloc(VALUE klass, size_t size, const rb_data_type_t *type)
{
- VALUE obj = rb_data_typed_object_wrap(klass, 0, type);
+ if (type->flags & RUBY_TYPED_EMBEDDABLE) {
+ if (!(type->flags & RUBY_TYPED_FREE_IMMEDIATELY)) {
+ rb_raise(rb_eTypeError, "Embeddable TypedData must be freed immediately");
+ }
+
+ size_t embed_size = offsetof(struct RTypedData, data) + size;
+ if (rb_gc_size_allocatable_p(embed_size)) {
+ VALUE obj = typed_data_alloc(klass, TYPED_DATA_EMBEDDED, 0, type, embed_size);
+ memset((char *)obj + offsetof(struct RTypedData, data), 0, size);
+ return obj;
+ }
+ }
+
+ VALUE obj = typed_data_alloc(klass, 0, NULL, type, sizeof(struct RTypedData));
DATA_PTR(obj) = xcalloc(1, size);
return obj;
}
@@ -3140,14 +3190,23 @@ rb_data_typed_object_zalloc(VALUE klass, size_t size, const rb_data_type_t *type
size_t
rb_objspace_data_type_memsize(VALUE obj)
{
+ size_t size = 0;
if (RTYPEDDATA_P(obj)) {
const rb_data_type_t *type = RTYPEDDATA_TYPE(obj);
- const void *ptr = RTYPEDDATA_DATA(obj);
+ const void *ptr = RTYPEDDATA_GET_DATA(obj);
+
+ if (RTYPEDDATA_TYPE(obj)->flags & RUBY_TYPED_EMBEDDABLE && !RTYPEDDATA_EMBEDDED_P(obj)) {
+#ifdef HAVE_MALLOC_USABLE_SIZE
+ size += malloc_usable_size((void *)ptr);
+#endif
+ }
+
if (ptr && type->function.dsize) {
- return type->function.dsize(ptr);
+ size += type->function.dsize(ptr);
}
}
- return 0;
+
+ return size;
}
const char *
@@ -3271,6 +3330,8 @@ vm_ccs_free(struct rb_class_cc_entries *ccs, int alive, rb_objspace_t *objspace,
asan_poison_object((VALUE)cc);
}
}
+
+ VM_ASSERT(!vm_cc_super_p(cc) && !vm_cc_refinement_p(cc));
vm_cc_invalidate(cc);
}
ruby_xfree(ccs->entries);
@@ -3408,8 +3469,53 @@ obj_free_object_id(rb_objspace_t *objspace, VALUE obj)
st_delete(objspace->id_to_obj_tbl, &id, NULL);
}
else {
- rb_bug("Object ID seen, but not in mapping table: %s\n", obj_info(obj));
+ rb_bug("Object ID seen, but not in mapping table: %s", obj_info(obj));
+ }
+}
+
+static bool
+rb_data_free(rb_objspace_t *objspace, VALUE obj)
+{
+ void *data = RTYPEDDATA_P(obj) ? RTYPEDDATA_GET_DATA(obj) : DATA_PTR(obj);
+ if (data) {
+ int free_immediately = false;
+ void (*dfree)(void *);
+
+ if (RTYPEDDATA_P(obj)) {
+ free_immediately = (RANY(obj)->as.typeddata.type->flags & RUBY_TYPED_FREE_IMMEDIATELY) != 0;
+ dfree = RANY(obj)->as.typeddata.type->function.dfree;
+ }
+ else {
+ dfree = RANY(obj)->as.data.dfree;
+ }
+
+ if (dfree) {
+ if (dfree == RUBY_DEFAULT_FREE) {
+ if (!RTYPEDDATA_EMBEDDED_P(obj)) {
+ xfree(data);
+ RB_DEBUG_COUNTER_INC(obj_data_xfree);
+ }
+ }
+ else if (free_immediately) {
+ (*dfree)(data);
+ if (RTYPEDDATA_TYPE(obj)->flags & RUBY_TYPED_EMBEDDABLE && !RTYPEDDATA_EMBEDDED_P(obj)) {
+ xfree(data);
+ }
+
+ RB_DEBUG_COUNTER_INC(obj_data_imm_free);
+ }
+ else {
+ make_zombie(objspace, obj, dfree, data);
+ RB_DEBUG_COUNTER_INC(obj_data_zombie);
+ return FALSE;
+ }
+ }
+ else {
+ RB_DEBUG_COUNTER_INC(obj_data_empty);
+ }
}
+
+ return true;
}
static int
@@ -3455,14 +3561,11 @@ obj_free(rb_objspace_t *objspace, VALUE obj)
case T_OBJECT:
if (rb_shape_obj_too_complex(obj)) {
RB_DEBUG_COUNTER_INC(obj_obj_too_complex);
- rb_id_table_free(ROBJECT_IV_HASH(obj));
+ st_free_table(ROBJECT_IV_HASH(obj));
}
else if (RANY(obj)->as.basic.flags & ROBJECT_EMBED) {
RB_DEBUG_COUNTER_INC(obj_obj_embed);
}
- else if (ROBJ_TRANSIENT_P(obj)) {
- RB_DEBUG_COUNTER_INC(obj_obj_transient);
- }
else {
xfree(RANY(obj)->as.object.as.heap.ivptr);
RB_DEBUG_COUNTER_INC(obj_obj_ptr);
@@ -3472,9 +3575,13 @@ obj_free(rb_objspace_t *objspace, VALUE obj)
case T_CLASS:
rb_id_table_free(RCLASS_M_TBL(obj));
cc_table_free(objspace, obj, FALSE);
- if (RCLASS_IVPTR(obj)) {
+ if (rb_shape_obj_too_complex(obj)) {
+ st_free_table((st_table *)RCLASS_IVPTR(obj));
+ }
+ else if (RCLASS_IVPTR(obj)) {
xfree(RCLASS_IVPTR(obj));
}
+
if (RCLASS_CONST_TBL(obj)) {
rb_free_const_table(RCLASS_CONST_TBL(obj));
}
@@ -3489,11 +3596,6 @@ obj_free(rb_objspace_t *objspace, VALUE obj)
xfree(RCLASS_SUPERCLASSES(obj));
}
-#if SIZE_POOL_COUNT == 1
- if (RCLASS_EXT(obj))
- xfree(RCLASS_EXT(obj));
-#endif
-
(void)RB_DEBUG_COUNTER_INC_IF(obj_module_ptr, BUILTIN_TYPE(obj) == T_MODULE);
(void)RB_DEBUG_COUNTER_INC_IF(obj_class_ptr, BUILTIN_TYPE(obj) == T_CLASS);
break;
@@ -3544,22 +3646,8 @@ obj_free(rb_objspace_t *objspace, VALUE obj)
RB_DEBUG_COUNTER_INC(obj_hash_st);
}
#endif
- if (/* RHASH_AR_TABLE_P(obj) */ !FL_TEST_RAW(obj, RHASH_ST_TABLE_FLAG)) {
- struct ar_table_struct *tab = RHASH(obj)->as.ar;
- if (tab) {
- if (RHASH_TRANSIENT_P(obj)) {
- RB_DEBUG_COUNTER_INC(obj_hash_transient);
- }
- else {
- ruby_xfree(tab);
- }
- }
- }
- else {
- GC_ASSERT(RHASH_ST_TABLE_P(obj));
- st_free_table(RHASH(obj)->as.st);
- }
+ rb_hash_free(obj);
break;
case T_REGEXP:
if (RANY(obj)->as.regexp.ptr) {
@@ -3568,46 +3656,11 @@ obj_free(rb_objspace_t *objspace, VALUE obj)
}
break;
case T_DATA:
- if (DATA_PTR(obj)) {
- int free_immediately = FALSE;
- void (*dfree)(void *);
- void *data = DATA_PTR(obj);
-
- if (RTYPEDDATA_P(obj)) {
- free_immediately = (RANY(obj)->as.typeddata.type->flags & RUBY_TYPED_FREE_IMMEDIATELY) != 0;
- dfree = RANY(obj)->as.typeddata.type->function.dfree;
- if (0 && free_immediately == 0) {
- /* to expose non-free-immediate T_DATA */
- fprintf(stderr, "not immediate -> %s\n", RANY(obj)->as.typeddata.type->wrap_struct_name);
- }
- }
- else {
- dfree = RANY(obj)->as.data.dfree;
- }
-
- if (dfree) {
- if (dfree == RUBY_DEFAULT_FREE) {
- xfree(data);
- RB_DEBUG_COUNTER_INC(obj_data_xfree);
- }
- else if (free_immediately) {
- (*dfree)(data);
- RB_DEBUG_COUNTER_INC(obj_data_imm_free);
- }
- else {
- make_zombie(objspace, obj, dfree, data);
- RB_DEBUG_COUNTER_INC(obj_data_zombie);
- return FALSE;
- }
- }
- else {
- RB_DEBUG_COUNTER_INC(obj_data_empty);
- }
- }
+ if (!rb_data_free(objspace, obj)) return false;
break;
case T_MATCH:
- if (RANY(obj)->as.match.rmatch) {
- struct rmatch *rm = RANY(obj)->as.match.rmatch;
+ {
+ rb_matchext_t *rm = RMATCH_EXT(obj);
#if USE_DEBUG_COUNTER
if (rm->regs.num_regs >= 8) {
RB_DEBUG_COUNTER_INC(obj_match_ge8);
@@ -3622,7 +3675,6 @@ obj_free(rb_objspace_t *objspace, VALUE obj)
onig_region_free(&rm->regs, 0);
if (rm->char_offset)
xfree(rm->char_offset);
- xfree(rm);
RB_DEBUG_COUNTER_INC(obj_match_ptr);
}
@@ -3655,9 +3707,6 @@ obj_free(rb_objspace_t *objspace, VALUE obj)
cc_table_free(objspace, obj, FALSE);
rb_class_remove_from_module_subclasses(obj);
rb_class_remove_from_super_subclasses(obj);
-#if !USE_RVARGC
- xfree(RCLASS_EXT(obj));
-#endif
RB_DEBUG_COUNTER_INC(obj_iclass_ptr);
break;
@@ -3685,9 +3734,6 @@ obj_free(rb_objspace_t *objspace, VALUE obj)
RANY(obj)->as.rstruct.as.heap.ptr == NULL) {
RB_DEBUG_COUNTER_INC(obj_struct_embed);
}
- else if (RSTRUCT_TRANSIENT_P(obj)) {
- RB_DEBUG_COUNTER_INC(obj_struct_transient);
- }
else {
xfree((void *)RANY(obj)->as.rstruct.as.heap.ptr);
RB_DEBUG_COUNTER_INC(obj_struct_ptr);
@@ -3743,8 +3789,16 @@ obj_free(rb_objspace_t *objspace, VALUE obj)
RB_DEBUG_COUNTER_INC(obj_imemo_parser_strterm);
break;
case imemo_callinfo:
- RB_DEBUG_COUNTER_INC(obj_imemo_callinfo);
- break;
+ {
+ const struct rb_callinfo * ci = ((const struct rb_callinfo *)obj);
+ rb_vm_ci_free(ci);
+ if (ci->kwarg) {
+ ((struct rb_callinfo_kwarg *)ci->kwarg)->references--;
+ if (ci->kwarg->references == 0) xfree((void *)ci->kwarg);
+ }
+ RB_DEBUG_COUNTER_INC(obj_imemo_callinfo);
+ break;
+ }
case imemo_callcache:
RB_DEBUG_COUNTER_INC(obj_imemo_callcache);
break;
@@ -3816,13 +3870,14 @@ Init_heap(void)
objspace->rgengc.oldmalloc_increase_limit = gc_params.oldmalloc_limit_min;
#endif
- heap_add_pages(objspace, &size_pools[0], SIZE_POOL_EDEN_HEAP(&size_pools[0]), gc_params.heap_init_slots / HEAP_PAGE_OBJ_LIMIT);
-
- /* Give other size pools allocatable pages. */
- for (int i = 1; i < SIZE_POOL_COUNT; i++) {
+ /* Set size pools allocatable pages. */
+ for (int i = 0; i < SIZE_POOL_COUNT; i++) {
rb_size_pool_t *size_pool = &size_pools[i];
- int multiple = size_pool->slot_size / BASE_SLOT_SIZE;
- size_pool->allocatable_pages = gc_params.heap_init_slots * multiple / HEAP_PAGE_OBJ_LIMIT;
+
+ /* Set the default value of size_pool_init_slots. */
+ gc_params.size_pool_init_slots[i] = GC_HEAP_INIT_SLOTS;
+
+ size_pool->allocatable_pages = minimum_pages_for_size_pool(objspace, size_pool);
}
heap_pages_expand_sorted(objspace);
@@ -3841,6 +3896,7 @@ Init_gc_stress(void)
}
typedef int each_obj_callback(void *, void *, size_t, void *);
+typedef int each_page_callback(struct heap_page *, void *);
static void objspace_each_objects(rb_objspace_t *objspace, each_obj_callback *callback, void *data, bool protected);
static void objspace_reachable_objects_from_root(rb_objspace_t *, void (func)(const char *, VALUE, void *), void *);
@@ -3849,7 +3905,8 @@ struct each_obj_data {
rb_objspace_t *objspace;
bool reenable_incremental;
- each_obj_callback *callback;
+ each_obj_callback *each_obj_callback;
+ each_page_callback *each_page_callback;
void *data;
struct heap_page **pages[SIZE_POOL_COUNT];
@@ -3869,11 +3926,7 @@ objspace_each_objects_ensure(VALUE arg)
for (int i = 0; i < SIZE_POOL_COUNT; i++) {
struct heap_page **pages = data->pages[i];
- /* pages could be NULL if an error was raised during setup (e.g.
- * malloc failed due to out of memory). */
- if (pages) {
- free(pages);
- }
+ free(pages);
}
return Qnil;
@@ -3927,9 +3980,15 @@ objspace_each_objects_try(VALUE arg)
uintptr_t pstart = (uintptr_t)page->start;
uintptr_t pend = pstart + (page->total_slots * size_pool->slot_size);
- if (!__asan_region_is_poisoned((void *)pstart, pend - pstart) &&
- (*data->callback)((void *)pstart, (void *)pend, size_pool->slot_size, data->data)) {
- break;
+ if (!__asan_region_is_poisoned((void *)pstart, pend - pstart)) {
+ if (data->each_obj_callback &&
+ (*data->each_obj_callback)((void *)pstart, (void *)pend, size_pool->slot_size, data->data)) {
+ break;
+ }
+ if (data->each_page_callback &&
+ (*data->each_page_callback)(page, data->data)) {
+ break;
+ }
}
page = ccan_list_next(&SIZE_POOL_EDEN_HEAP(size_pool)->pages, page, page_node);
@@ -3955,14 +4014,16 @@ objspace_each_objects_try(VALUE arg)
*
* This is a sample callback code to iterate liveness objects:
*
- * int
- * sample_callback(void *vstart, void *vend, int stride, void *data) {
- * VALUE v = (VALUE)vstart;
- * for (; v != (VALUE)vend; v += stride) {
- * if (RBASIC(v)->flags) { // liveness check
- * // do something with live object 'v'
- * }
- * return 0; // continue to iteration
+ * static int
+ * sample_callback(void *vstart, void *vend, int stride, void *data)
+ * {
+ * VALUE v = (VALUE)vstart;
+ * for (; v != (VALUE)vend; v += stride) {
+ * if (!rb_objspace_internal_object_p(v)) { // liveness check
+ * // do something with live object 'v'
+ * }
+ * }
+ * return 0; // continue to iteration
* }
*
* Note: 'vstart' is not a top of heap_page. This point the first
@@ -3982,9 +4043,10 @@ rb_objspace_each_objects(each_obj_callback *callback, void *data)
}
static void
-objspace_each_objects(rb_objspace_t *objspace, each_obj_callback *callback, void *data, bool protected)
+objspace_each_exec(bool protected, struct each_obj_data *each_obj_data)
{
/* Disable incremental GC */
+ rb_objspace_t *objspace = each_obj_data->objspace;
bool reenable_incremental = FALSE;
if (protected) {
reenable_incremental = !objspace->flags.dont_incremental;
@@ -3993,18 +4055,35 @@ objspace_each_objects(rb_objspace_t *objspace, each_obj_callback *callback, void
objspace->flags.dont_incremental = TRUE;
}
+ each_obj_data->reenable_incremental = reenable_incremental;
+ memset(&each_obj_data->pages, 0, sizeof(each_obj_data->pages));
+ memset(&each_obj_data->pages_counts, 0, sizeof(each_obj_data->pages_counts));
+ rb_ensure(objspace_each_objects_try, (VALUE)each_obj_data,
+ objspace_each_objects_ensure, (VALUE)each_obj_data);
+}
+
+static void
+objspace_each_objects(rb_objspace_t *objspace, each_obj_callback *callback, void *data, bool protected)
+{
struct each_obj_data each_obj_data = {
.objspace = objspace,
- .reenable_incremental = reenable_incremental,
-
- .callback = callback,
+ .each_obj_callback = callback,
+ .each_page_callback = NULL,
.data = data,
+ };
+ objspace_each_exec(protected, &each_obj_data);
+}
- .pages = {NULL},
- .pages_counts = {0},
+static void
+objspace_each_pages(rb_objspace_t *objspace, each_page_callback *callback, void *data, bool protected)
+{
+ struct each_obj_data each_obj_data = {
+ .objspace = objspace,
+ .each_obj_callback = NULL,
+ .each_page_callback = callback,
+ .data = data,
};
- rb_ensure(objspace_each_objects_try, (VALUE)&each_obj_data,
- objspace_each_objects_ensure, (VALUE)&each_obj_data);
+ objspace_each_exec(protected, &each_obj_data);
}
void
@@ -4180,6 +4259,45 @@ should_be_finalizable(VALUE obj)
rb_check_frozen(obj);
}
+VALUE
+rb_define_finalizer_no_check(VALUE obj, VALUE block)
+{
+ rb_objspace_t *objspace = &rb_objspace;
+ VALUE table;
+ st_data_t data;
+
+ RBASIC(obj)->flags |= FL_FINALIZE;
+
+ if (st_lookup(finalizer_table, obj, &data)) {
+ table = (VALUE)data;
+
+ /* avoid duplicate block, table is usually small */
+ {
+ long len = RARRAY_LEN(table);
+ long i;
+
+ for (i = 0; i < len; i++) {
+ VALUE recv = RARRAY_AREF(table, i);
+ if (rb_equal(recv, block)) {
+ block = recv;
+ goto end;
+ }
+ }
+ }
+
+ rb_ary_push(table, block);
+ }
+ else {
+ table = rb_ary_new3(1, block);
+ RBASIC_CLEAR_CLASS(table);
+ st_add_direct(finalizer_table, obj, table);
+ }
+ end:
+ block = rb_ary_new3(2, INT2FIX(0), block);
+ OBJ_FREEZE(block);
+ return block;
+}
+
/*
* call-seq:
* ObjectSpace.define_finalizer(obj, aProc=proc())
@@ -4260,46 +4378,7 @@ define_final(int argc, VALUE *argv, VALUE os)
rb_warn("finalizer references object to be finalized");
}
- return define_final0(obj, block);
-}
-
-static VALUE
-define_final0(VALUE obj, VALUE block)
-{
- rb_objspace_t *objspace = &rb_objspace;
- VALUE table;
- st_data_t data;
-
- RBASIC(obj)->flags |= FL_FINALIZE;
-
- if (st_lookup(finalizer_table, obj, &data)) {
- table = (VALUE)data;
-
- /* avoid duplicate block, table is usually small */
- {
- long len = RARRAY_LEN(table);
- long i;
-
- for (i = 0; i < len; i++) {
- VALUE recv = RARRAY_AREF(table, i);
- if (rb_equal(recv, block)) {
- block = recv;
- goto end;
- }
- }
- }
-
- rb_ary_push(table, block);
- }
- else {
- table = rb_ary_new3(1, block);
- RBASIC_CLEAR_CLASS(table);
- st_add_direct(finalizer_table, obj, table);
- }
- end:
- block = rb_ary_new3(2, INT2FIX(0), block);
- OBJ_FREEZE(block);
- return block;
+ return rb_define_finalizer_no_check(obj, block);
}
VALUE
@@ -4307,7 +4386,7 @@ rb_define_finalizer(VALUE obj, VALUE block)
{
should_be_finalizable(obj);
should_be_callable(block);
- return define_final0(obj, block);
+ return rb_define_finalizer_no_check(obj, block);
}
void
@@ -4351,16 +4430,20 @@ run_finalizer(rb_objspace_t *objspace, VALUE obj, VALUE table)
VALUE objid;
VALUE final;
rb_control_frame_t *cfp;
+ VALUE *sp;
long finished;
} saved;
+
rb_execution_context_t * volatile ec = GET_EC();
#define RESTORE_FINALIZER() (\
ec->cfp = saved.cfp, \
+ ec->cfp->sp = saved.sp, \
ec->errinfo = saved.errinfo)
saved.errinfo = ec->errinfo;
saved.objid = rb_obj_id(obj);
saved.cfp = ec->cfp;
+ saved.sp = ec->cfp->sp;
saved.finished = 0;
saved.final = Qundef;
@@ -4420,7 +4503,7 @@ finalize_list(rb_objspace_t *objspace, VALUE zombie)
page->final_slots--;
page->free_slots++;
heap_page_add_freeobj(objspace, page, zombie);
- objspace->profile.total_freed_objects++;
+ page->size_pool->total_freed_objects++;
}
RB_VM_LOCK_LEAVE();
@@ -4459,9 +4542,44 @@ gc_finalize_deferred(void *dmy)
static void
gc_finalize_deferred_register(rb_objspace_t *objspace)
{
- if (rb_postponed_job_register_one(0, gc_finalize_deferred, objspace) == 0) {
- rb_bug("gc_finalize_deferred_register: can't register finalizer.");
+ /* will enqueue a call to gc_finalize_deferred */
+ rb_postponed_job_trigger(objspace->finalize_deferred_pjob);
+}
+
+static int pop_mark_stack(mark_stack_t *stack, VALUE *data);
+
+static void
+gc_abort(rb_objspace_t *objspace)
+{
+ if (is_incremental_marking(objspace)) {
+ /* Remove all objects from the mark stack. */
+ VALUE obj;
+ while (pop_mark_stack(&objspace->mark_stack, &obj));
+
+ objspace->flags.during_incremental_marking = FALSE;
}
+
+ if (is_lazy_sweeping(objspace)) {
+ for (int i = 0; i < SIZE_POOL_COUNT; i++) {
+ rb_size_pool_t *size_pool = &size_pools[i];
+ rb_heap_t *heap = SIZE_POOL_EDEN_HEAP(size_pool);
+
+ heap->sweeping_page = NULL;
+ struct heap_page *page = NULL;
+
+ ccan_list_for_each(&heap->pages, page, page_node) {
+ page->flags.before_sweep = false;
+ }
+ }
+ }
+
+ for (int i = 0; i < SIZE_POOL_COUNT; i++) {
+ rb_size_pool_t *size_pool = &size_pools[i];
+ rb_heap_t *heap = SIZE_POOL_EDEN_HEAP(size_pool);
+ rgengc_mark_and_rememberset_clear(objspace, heap);
+ }
+
+ gc_mode_set(objspace, gc_mode_none);
}
struct force_finalize_list {
@@ -4485,6 +4603,35 @@ force_chain_object(st_data_t key, st_data_t val, st_data_t arg)
bool rb_obj_is_main_ractor(VALUE gv);
void
+rb_objspace_free_objects(rb_objspace_t *objspace)
+{
+ for (size_t i = 0; i < heap_allocated_pages; i++) {
+ struct heap_page *page = heap_pages_sorted[i];
+ short stride = page->slot_size;
+
+ uintptr_t p = (uintptr_t)page->start;
+ uintptr_t pend = p + page->total_slots * stride;
+ for (; p < pend; p += stride) {
+ VALUE vp = (VALUE)p;
+ switch (BUILTIN_TYPE(vp)) {
+ case T_DATA: {
+ if (rb_obj_is_mutex(vp) || rb_obj_is_thread(vp) || rb_obj_is_main_ractor(vp)) {
+ obj_free(objspace, vp);
+ }
+ break;
+ }
+ case T_ARRAY:
+ obj_free(objspace, vp);
+ break;
+ default:
+ break;
+ }
+ }
+ }
+}
+
+
+void
rb_objspace_call_finalizer(rb_objspace_t *objspace)
{
size_t i;
@@ -4492,15 +4639,12 @@ rb_objspace_call_finalizer(rb_objspace_t *objspace)
#if RGENGC_CHECK_MODE >= 2
gc_verify_internal_consistency(objspace);
#endif
- gc_rest(objspace);
-
if (ATOMIC_EXCHANGE(finalizing, 1)) return;
/* run finalizers */
finalize_deferred(objspace);
GC_ASSERT(heap_pages_deferred_final == 0);
- gc_rest(objspace);
/* prohibit incremental GC */
objspace->flags.dont_incremental = 1;
@@ -4518,6 +4662,9 @@ rb_objspace_call_finalizer(rb_objspace_t *objspace)
}
}
+ /* Abort incremental marking and lazy sweeping to speed up shutdown. */
+ gc_abort(objspace);
+
/* prohibit GC because force T_DATA finalizers can break an object graph consistency */
dont_gc_on();
@@ -4542,23 +4689,20 @@ rb_objspace_call_finalizer(rb_objspace_t *objspace)
if (rb_obj_is_mutex(vp)) break;
if (rb_obj_is_fiber(vp)) break;
if (rb_obj_is_main_ractor(vp)) break;
- if (RTYPEDDATA_P(vp)) {
- RDATA(p)->dfree = RANY(p)->as.typeddata.type->function.dfree;
- }
- RANY(p)->as.free.flags = 0;
- if (RANY(p)->as.data.dfree == RUBY_DEFAULT_FREE) {
- xfree(DATA_PTR(p));
- }
- else if (RANY(p)->as.data.dfree) {
- make_zombie(objspace, vp, RANY(p)->as.data.dfree, RANY(p)->as.data.data);
- }
+
+ obj_free(objspace, vp);
break;
case T_FILE:
- if (RANY(p)->as.file.fptr) {
- make_io_zombie(objspace, vp);
- }
+ obj_free(objspace, vp);
+ break;
+ case T_SYMBOL:
+ case T_ARRAY:
+ case T_NONE:
break;
default:
+ if (rb_free_at_exit) {
+ obj_free(objspace, vp);
+ }
break;
}
if (poisoned) {
@@ -4578,7 +4722,7 @@ rb_objspace_call_finalizer(rb_objspace_t *objspace)
}
static inline int
-is_swept_object(rb_objspace_t *objspace, VALUE ptr)
+is_swept_object(VALUE ptr)
{
struct heap_page *page = GET_HEAP_PAGE(ptr);
return page->flags.before_sweep ? FALSE : TRUE;
@@ -4589,7 +4733,7 @@ static inline int
is_garbage_object(rb_objspace_t *objspace, VALUE ptr)
{
if (!is_lazy_sweeping(objspace) ||
- is_swept_object(objspace, ptr) ||
+ is_swept_object(ptr) ||
MARKED_IN_BITMAP(GET_HEAP_MARK_BITS(ptr), ptr)) {
return FALSE;
@@ -4620,7 +4764,7 @@ is_live_object(rb_objspace_t *objspace, VALUE ptr)
}
static inline int
-is_markable_object(rb_objspace_t *objspace, VALUE obj)
+is_markable_object(VALUE obj)
{
if (rb_special_const_p(obj)) return FALSE; /* special const is not markable */
check_rvalue_consistency(obj);
@@ -4631,7 +4775,7 @@ int
rb_objspace_markable_object_p(VALUE obj)
{
rb_objspace_t *objspace = &rb_objspace;
- return is_markable_object(objspace, obj) && is_live_object(objspace, obj);
+ return is_markable_object(obj) && is_live_object(objspace, obj);
}
int
@@ -4641,9 +4785,18 @@ rb_objspace_garbage_object_p(VALUE obj)
return is_garbage_object(objspace, obj);
}
-static VALUE
-id2ref_obj_tbl(rb_objspace_t *objspace, VALUE objid)
+bool
+rb_gc_is_ptr_to_obj(void *ptr)
+{
+ rb_objspace_t *objspace = &rb_objspace;
+ return is_pointer_to_heap(objspace, ptr);
+}
+
+VALUE
+rb_gc_id2ref_obj_tbl(VALUE objid)
{
+ rb_objspace_t *objspace = &rb_objspace;
+
VALUE orig;
if (st_lookup(objspace->id_to_obj_tbl, objid, &orig)) {
return orig;
@@ -4700,7 +4853,7 @@ id2ref(VALUE objid)
}
}
- if (!UNDEF_P(orig = id2ref_obj_tbl(objspace, objid)) &&
+ if (!UNDEF_P(orig = rb_gc_id2ref_obj_tbl(objid)) &&
is_live_object(objspace, orig)) {
if (!rb_multi_ractor_p() || rb_ractor_shareable_p(orig)) {
@@ -4774,16 +4927,21 @@ cached_object_id(VALUE obj)
}
static VALUE
-nonspecial_obj_id_(VALUE obj)
+nonspecial_obj_id(VALUE obj)
{
- return nonspecial_obj_id(obj);
+#if SIZEOF_LONG == SIZEOF_VOIDP
+ return (VALUE)((SIGNED_VALUE)(obj)|FIXNUM_FLAG);
+#elif SIZEOF_LONG_LONG == SIZEOF_VOIDP
+ return LL2NUM((SIGNED_VALUE)(obj) / 2);
+#else
+# error not supported
+#endif
}
-
VALUE
rb_memory_id(VALUE obj)
{
- return rb_find_object_id(obj, nonspecial_obj_id_);
+ return rb_find_object_id(obj, nonspecial_obj_id);
}
/*
@@ -4882,7 +5040,7 @@ obj_memsize_of(VALUE obj, int use_all_types)
switch (BUILTIN_TYPE(obj)) {
case T_OBJECT:
if (rb_shape_obj_too_complex(obj)) {
- size += rb_id_table_memsize(ROBJECT_IV_HASH(obj));
+ size += rb_st_memsize(ROBJECT_IV_HASH(obj));
}
else if (!(RBASIC(obj)->flags & ROBJECT_EMBED)) {
size += ROBJECT_IV_CAPACITY(obj) * sizeof(VALUE);
@@ -4890,27 +5048,22 @@ obj_memsize_of(VALUE obj, int use_all_types)
break;
case T_MODULE:
case T_CLASS:
- if (RCLASS_EXT(obj)) {
- if (RCLASS_M_TBL(obj)) {
- size += rb_id_table_memsize(RCLASS_M_TBL(obj));
- }
- // class IV sizes are allocated as powers of two
- size += SIZEOF_VALUE << bit_length(RCLASS_IV_COUNT(obj));
- if (RCLASS_CVC_TBL(obj)) {
- size += rb_id_table_memsize(RCLASS_CVC_TBL(obj));
- }
- if (RCLASS_EXT(obj)->const_tbl) {
- size += rb_id_table_memsize(RCLASS_EXT(obj)->const_tbl);
- }
- if (RCLASS_CC_TBL(obj)) {
- size += cc_table_memsize(RCLASS_CC_TBL(obj));
- }
- if (FL_TEST_RAW(obj, RCLASS_SUPERCLASSES_INCLUDE_SELF)) {
- size += (RCLASS_SUPERCLASS_DEPTH(obj) + 1) * sizeof(VALUE);
- }
-#if SIZE_POOL_COUNT == 1
- size += sizeof(rb_classext_t);
-#endif
+ if (RCLASS_M_TBL(obj)) {
+ size += rb_id_table_memsize(RCLASS_M_TBL(obj));
+ }
+ // class IV sizes are allocated as powers of two
+ size += SIZEOF_VALUE << bit_length(RCLASS_IV_COUNT(obj));
+ if (RCLASS_CVC_TBL(obj)) {
+ size += rb_id_table_memsize(RCLASS_CVC_TBL(obj));
+ }
+ if (RCLASS_EXT(obj)->const_tbl) {
+ size += rb_id_table_memsize(RCLASS_EXT(obj)->const_tbl);
+ }
+ if (RCLASS_CC_TBL(obj)) {
+ size += cc_table_memsize(RCLASS_CC_TBL(obj));
+ }
+ if (FL_TEST_RAW(obj, RCLASS_SUPERCLASSES_INCLUDE_SELF)) {
+ size += (RCLASS_SUPERCLASS_DEPTH(obj) + 1) * sizeof(VALUE);
}
break;
case T_ICLASS:
@@ -4919,7 +5072,7 @@ obj_memsize_of(VALUE obj, int use_all_types)
size += rb_id_table_memsize(RCLASS_M_TBL(obj));
}
}
- if (RCLASS_EXT(obj) && RCLASS_CC_TBL(obj)) {
+ if (RCLASS_CC_TBL(obj)) {
size += cc_table_memsize(RCLASS_CC_TBL(obj));
}
break;
@@ -4930,15 +5083,10 @@ obj_memsize_of(VALUE obj, int use_all_types)
size += rb_ary_memsize(obj);
break;
case T_HASH:
- if (RHASH_AR_TABLE_P(obj)) {
- if (RHASH_AR_TABLE(obj) != NULL) {
- size_t rb_hash_ar_table_size(void);
- size += rb_hash_ar_table_size();
- }
- }
- else {
+ if (RHASH_ST_TABLE_P(obj)) {
VM_ASSERT(RHASH_ST_TABLE(obj) != NULL);
- size += st_memsize(RHASH_ST_TABLE(obj));
+ /* st_table is in the slot */
+ size += st_memsize(RHASH_ST_TABLE(obj)) - sizeof(st_table);
}
break;
case T_REGEXP:
@@ -4950,11 +5098,10 @@ obj_memsize_of(VALUE obj, int use_all_types)
if (use_all_types) size += rb_objspace_data_type_memsize(obj);
break;
case T_MATCH:
- if (RMATCH(obj)->rmatch) {
- struct rmatch *rm = RMATCH(obj)->rmatch;
+ {
+ rb_matchext_t *rm = RMATCH_EXT(obj);
size += onig_region_memsize(&rm->regs);
size += sizeof(struct rmatch_offset) * rm->char_offset_num_allocated;
- size += sizeof(struct rmatch);
}
break;
case T_FILE:
@@ -5173,7 +5320,7 @@ objspace_available_slots(rb_objspace_t *objspace)
static size_t
objspace_live_slots(rb_objspace_t *objspace)
{
- return (objspace->total_allocated_objects - objspace->profile.total_freed_objects) - heap_pages_final_slots;
+ return total_allocated_objects(objspace) - total_freed_objects(objspace) - heap_pages_final_slots;
}
static size_t
@@ -5252,7 +5399,9 @@ try_move(rb_objspace_t *objspace, rb_heap_t *heap, struct heap_page *free_page,
* full */
return false;
}
+ asan_unlock_freelist(free_page);
free_page->freelist = RANY(dest)->as.free.next;
+ asan_lock_freelist(free_page);
GC_ASSERT(RB_BUILTIN_TYPE(dest) == T_NONE);
@@ -5284,14 +5433,8 @@ gc_unprotect_pages(rb_objspace_t *objspace, rb_heap_t *heap)
}
static void gc_update_references(rb_objspace_t * objspace);
+#if GC_CAN_COMPILE_COMPACTION
static void invalidate_moved_page(rb_objspace_t *objspace, struct heap_page *page);
-
-#ifndef GC_CAN_COMPILE_COMPACTION
-#if defined(__wasi__) /* WebAssembly doesn't support signals */
-# define GC_CAN_COMPILE_COMPACTION 0
-#else
-# define GC_CAN_COMPILE_COMPACTION 1
-#endif
#endif
#if defined(__MINGW32__) || defined(_WIN32)
@@ -5477,45 +5620,6 @@ install_handlers(void)
#endif
static void
-revert_stack_objects(VALUE stack_obj, void *ctx)
-{
- rb_objspace_t * objspace = (rb_objspace_t*)ctx;
-
- if (BUILTIN_TYPE(stack_obj) == T_MOVED) {
- /* For now we'll revert the whole page if the object made it to the
- * stack. I think we can change this to move just the one object
- * back though */
- invalidate_moved_page(objspace, GET_HEAP_PAGE(stack_obj));
- }
-}
-
-static void
-revert_machine_stack_references(rb_objspace_t *objspace, VALUE v)
-{
- if (is_pointer_to_heap(objspace, (void *)v)) {
- if (BUILTIN_TYPE(v) == T_MOVED) {
- /* For now we'll revert the whole page if the object made it to the
- * stack. I think we can change this to move just the one object
- * back though */
- invalidate_moved_page(objspace, GET_HEAP_PAGE(v));
- }
- }
-}
-
-static void each_machine_stack_value(const rb_execution_context_t *ec, void (*cb)(rb_objspace_t *, VALUE));
-
-static void
-check_stack_for_moved(rb_objspace_t *objspace)
-{
- rb_execution_context_t *ec = GET_EC();
- rb_vm_t *vm = rb_ec_vm_ptr(ec);
- rb_vm_each_stack_value(vm, revert_stack_objects, (void*)objspace);
- each_machine_stack_value(ec, revert_machine_stack_references);
-}
-
-static void gc_mode_transition(rb_objspace_t *objspace, enum gc_mode mode);
-
-static void
gc_compact_finish(rb_objspace_t *objspace)
{
for (int i = 0; i < SIZE_POOL_COUNT; i++) {
@@ -5526,13 +5630,6 @@ gc_compact_finish(rb_objspace_t *objspace)
uninstall_handlers();
- /* The mutator is allowed to run during incremental sweeping. T_MOVED
- * objects can get pushed on the stack and when the compaction process
- * finishes up, it may remove the read barrier before anything has a
- * chance to read from the T_MOVED address. To fix this, we scan the stack
- * then revert any moved objects that made it to the stack. */
- check_stack_for_moved(objspace);
-
gc_update_references(objspace);
objspace->profile.compact_count++;
@@ -5578,7 +5675,7 @@ gc_sweep_plane(rb_objspace_t *objspace, rb_heap_t *heap, uintptr_t p, bits_t bit
#if RGENGC_CHECK_MODE
if (!is_full_marking(objspace)) {
if (RVALUE_OLD_P(vp)) rb_bug("page_sweep: %p - old while minor GC.", (void *)p);
- if (rgengc_remembered_sweep(objspace, vp)) rb_bug("page_sweep: %p - remembered.", (void *)p);
+ if (RVALUE_REMEMBERED(vp)) rb_bug("page_sweep: %p - remembered.", (void *)p);
}
#endif
if (obj_free(objspace, vp)) {
@@ -5601,7 +5698,7 @@ gc_sweep_plane(rb_objspace_t *objspace, rb_heap_t *heap, uintptr_t p, bits_t bit
* The sweep cursor and compact cursor move in
* opposite directions, and when they meet references will
* get updated and "during_compacting" should get disabled */
- rb_bug("T_MOVED shouldn't be seen until compaction is finished\n");
+ rb_bug("T_MOVED shouldn't be seen until compaction is finished");
}
gc_report(3, objspace, "page_sweep: %s is added to freelist\n", obj_info(vp));
ctx->empty_slots++;
@@ -5688,7 +5785,7 @@ gc_sweep_page(rb_objspace_t *objspace, rb_heap_t *heap, struct gc_sweep_context
ctx->freed_slots, ctx->empty_slots, ctx->final_slots);
sweep_page->free_slots += ctx->freed_slots + ctx->empty_slots;
- objspace->profile.total_freed_objects += ctx->freed_slots;
+ sweep_page->size_pool->total_freed_objects += ctx->freed_slots;
if (heap_pages_deferred_final && !finalizing) {
rb_thread_t *th = GET_THREAD();
@@ -5714,23 +5811,6 @@ gc_sweep_page(rb_objspace_t *objspace, rb_heap_t *heap, struct gc_sweep_context
gc_report(2, objspace, "page_sweep: end.\n");
}
-#if !USE_RVARGC
-/* allocate additional minimum page to work */
-static void
-gc_heap_prepare_minimum_pages(rb_objspace_t *objspace, rb_size_pool_t *size_pool, rb_heap_t *heap)
-{
- for (int i = 0; i < SIZE_POOL_COUNT; i++) {
- if (!heap->free_pages && heap_increment(objspace, size_pool, heap) == FALSE) {
- /* there is no free after page_sweep() */
- size_pool_allocatable_pages_set(objspace, size_pool, 1);
- if (!heap_increment(objspace, size_pool, heap)) { /* can't allocate additional free objects */
- rb_memerror();
- }
- }
- }
-}
-#endif
-
static const char *
gc_mode_name(enum gc_mode mode)
{
@@ -5788,9 +5868,7 @@ gc_sweep_start_heap(rb_objspace_t *objspace, rb_heap_t *heap)
{
heap->sweeping_page = ccan_list_top(&heap->pages, struct heap_page, page_node);
heap->free_pages = NULL;
-#if GC_ENABLE_INCREMENTAL_MARK
heap->pooled_pages = NULL;
-#endif
if (!objspace->flags.immediate_sweep) {
struct heap_page *page = NULL;
@@ -5803,13 +5881,25 @@ gc_sweep_start_heap(rb_objspace_t *objspace, rb_heap_t *heap)
#if defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ == 4
__attribute__((noinline))
#endif
+
+#if GC_CAN_COMPILE_COMPACTION
+static void gc_sort_heap_by_compare_func(rb_objspace_t *objspace, gc_compact_compare_func compare_func);
+static int compare_pinned_slots(const void *left, const void *right, void *d);
+#endif
+
static void
gc_sweep_start(rb_objspace_t *objspace)
{
gc_mode_transition(objspace, gc_mode_sweeping);
-
-#if GC_ENABLE_INCREMENTAL_MARK
objspace->rincgc.pooled_slots = 0;
+
+#if GC_CAN_COMPILE_COMPACTION
+ if (objspace->flags.during_compacting) {
+ gc_sort_heap_by_compare_func(
+ objspace,
+ objspace->rcompactor.compare_func ? objspace->rcompactor.compare_func : compare_pinned_slots
+ );
+ }
#endif
for (int i = 0; i < SIZE_POOL_COUNT; i++) {
@@ -5818,14 +5908,12 @@ gc_sweep_start(rb_objspace_t *objspace)
gc_sweep_start_heap(objspace, heap);
-#if USE_RVARGC
/* We should call gc_sweep_finish_size_pool for size pools with no pages. */
if (heap->sweeping_page == NULL) {
GC_ASSERT(heap->total_pages == 0);
GC_ASSERT(heap->total_slots == 0);
gc_sweep_finish_size_pool(objspace, size_pool);
}
-#endif
}
rb_ractor_t *r = NULL;
@@ -5834,7 +5922,6 @@ gc_sweep_start(rb_objspace_t *objspace)
}
}
-#if USE_RVARGC
static void
gc_sweep_finish_size_pool(rb_objspace_t *objspace, rb_size_pool_t *size_pool)
{
@@ -5843,14 +5930,15 @@ gc_sweep_finish_size_pool(rb_objspace_t *objspace, rb_size_pool_t *size_pool)
size_t total_pages = heap->total_pages + SIZE_POOL_TOMB_HEAP(size_pool)->total_pages;
size_t swept_slots = size_pool->freed_slots + size_pool->empty_slots;
- size_t min_free_slots = (size_t)(total_slots * gc_params.heap_free_slots_min_ratio);
+ size_t init_slots = gc_params.size_pool_init_slots[size_pool - size_pools];
+ size_t min_free_slots = (size_t)(MAX(total_slots, init_slots) * gc_params.heap_free_slots_min_ratio);
/* If we don't have enough slots and we have pages on the tomb heap, move
* pages from the tomb heap to the eden heap. This may prevent page
* creation thrashing (frequently allocating and deallocting pages) and
* GC thrashing (running GC more frequently than required). */
struct heap_page *resurrected_page;
- while ((swept_slots < min_free_slots || swept_slots < gc_params.heap_init_slots) &&
+ while (swept_slots < min_free_slots &&
(resurrected_page = heap_page_resurrect(objspace, size_pool))) {
swept_slots += resurrected_page->free_slots;
@@ -5858,28 +5946,20 @@ gc_sweep_finish_size_pool(rb_objspace_t *objspace, rb_size_pool_t *size_pool)
heap_add_freepage(heap, resurrected_page);
}
- /* Some size pools may have very few pages (or even no pages). These size pools
- * should still have allocatable pages. */
- if (min_free_slots < gc_params.heap_init_slots && swept_slots < gc_params.heap_init_slots) {
- int multiple = size_pool->slot_size / BASE_SLOT_SIZE;
- size_t extra_slots = gc_params.heap_init_slots - swept_slots;
- size_t extend_page_count = CEILDIV(extra_slots * multiple, HEAP_PAGE_OBJ_LIMIT);
- if (extend_page_count > size_pool->allocatable_pages) {
- size_pool_allocatable_pages_set(objspace, size_pool, extend_page_count);
- }
- }
-
if (swept_slots < min_free_slots) {
bool grow_heap = is_full_marking(objspace);
- if (!is_full_marking(objspace)) {
- /* The heap is a growth heap if it freed more slots than had empty
- * slots and used up all of its allocatable pages. */
- bool is_growth_heap = (size_pool->empty_slots == 0 ||
- size_pool->freed_slots > size_pool->empty_slots) &&
- size_pool->allocatable_pages == 0;
-
- if (objspace->profile.count - objspace->rgengc.last_major_gc < RVALUE_OLD_AGE) {
+ /* Consider growing or starting a major GC if we are not currently in a
+ * major GC and we can't allocate any more pages. */
+ if (!is_full_marking(objspace) && size_pool->allocatable_pages == 0) {
+ /* The heap is a growth heap if it freed more slots than had empty slots. */
+ bool is_growth_heap = size_pool->empty_slots == 0 || size_pool->freed_slots > size_pool->empty_slots;
+
+ /* Grow this heap if we haven't run at least RVALUE_OLD_AGE minor
+ * GC since the last major GC or if this heap is smaller than the
+ * the configured initial size. */
+ if (objspace->profile.count - objspace->rgengc.last_major_gc < RVALUE_OLD_AGE ||
+ total_slots < init_slots) {
grow_heap = TRUE;
}
else if (is_growth_heap) { /* Only growth heaps are allowed to start a major GC. */
@@ -5897,7 +5977,6 @@ gc_sweep_finish_size_pool(rb_objspace_t *objspace, rb_size_pool_t *size_pool)
}
}
}
-#endif
static void
gc_sweep_finish(rb_objspace_t *objspace)
@@ -5916,11 +5995,9 @@ gc_sweep_finish(rb_objspace_t *objspace)
size_pool->allocatable_pages = tomb_pages;
}
-#if USE_RVARGC
size_pool->freed_slots = 0;
size_pool->empty_slots = 0;
-#if GC_ENABLE_INCREMENTAL_MARK
if (!will_be_incremental_marking(objspace)) {
rb_heap_t *eden_heap = SIZE_POOL_EDEN_HEAP(size_pool);
struct heap_page *end_page = eden_heap->free_pages;
@@ -5934,13 +6011,15 @@ gc_sweep_finish(rb_objspace_t *objspace)
eden_heap->pooled_pages = NULL;
objspace->rincgc.pooled_slots = 0;
}
-#endif
-#endif
}
heap_pages_expand_sorted(objspace);
gc_event_hook(objspace, RUBY_INTERNAL_EVENT_GC_END_SWEEP, 0);
gc_mode_transition(objspace, gc_mode_none);
+
+#if RGENGC_CHECK_MODE >= 2
+ gc_verify_internal_consistency(objspace);
+#endif
}
static int
@@ -5948,19 +6027,8 @@ gc_sweep_step(rb_objspace_t *objspace, rb_size_pool_t *size_pool, rb_heap_t *hea
{
struct heap_page *sweep_page = heap->sweeping_page;
int unlink_limit = GC_SWEEP_PAGES_FREEABLE_PER_STEP;
-
-#if GC_ENABLE_INCREMENTAL_MARK
int swept_slots = 0;
-#if USE_RVARGC
- bool need_pool = TRUE;
-#else
- int need_pool = will_be_incremental_marking(objspace) ? TRUE : FALSE;
-#endif
-
- gc_report(2, objspace, "gc_sweep_step (need_pool: %d)\n", need_pool);
-#else
- gc_report(2, objspace, "gc_sweep_step\n");
-#endif
+ int pooled_slots = 0;
if (sweep_page == NULL) return FALSE;
@@ -5992,15 +6060,12 @@ gc_sweep_step(rb_objspace_t *objspace, rb_size_pool_t *size_pool, rb_heap_t *hea
heap_add_page(objspace, size_pool, SIZE_POOL_TOMB_HEAP(size_pool), sweep_page);
}
else if (free_slots > 0) {
-#if USE_RVARGC
size_pool->freed_slots += ctx.freed_slots;
size_pool->empty_slots += ctx.empty_slots;
-#endif
-#if GC_ENABLE_INCREMENTAL_MARK
- if (need_pool) {
+ if (pooled_slots < GC_INCREMENTAL_SWEEP_POOL_SLOT_COUNT) {
heap_add_poolpage(objspace, heap, sweep_page);
- need_pool = FALSE;
+ pooled_slots += free_slots;
}
else {
heap_add_freepage(heap, sweep_page);
@@ -6009,10 +6074,6 @@ gc_sweep_step(rb_objspace_t *objspace, rb_size_pool_t *size_pool, rb_heap_t *hea
break;
}
}
-#else
- heap_add_freepage(heap, sweep_page);
- break;
-#endif
}
else {
sweep_page->free_next = NULL;
@@ -6020,9 +6081,7 @@ gc_sweep_step(rb_objspace_t *objspace, rb_size_pool_t *size_pool, rb_heap_t *hea
} while ((sweep_page = heap->sweeping_page));
if (!heap->sweeping_page) {
-#if USE_RVARGC
gc_sweep_finish_size_pool(objspace, size_pool);
-#endif
if (!has_sweeping_pages(objspace)) {
gc_sweep_finish(objspace);
@@ -6054,13 +6113,11 @@ gc_sweep_continue(rb_objspace_t *objspace, rb_size_pool_t *sweep_size_pool, rb_h
GC_ASSERT(dont_gc_val() == FALSE);
if (!GC_ENABLE_LAZY_SWEEP) return;
- unsigned int lock_lev;
- gc_enter(objspace, gc_enter_event_sweep_continue, &lock_lev);
+ gc_sweeping_enter(objspace);
for (int i = 0; i < SIZE_POOL_COUNT; i++) {
rb_size_pool_t *size_pool = &size_pools[i];
if (!gc_sweep_step(objspace, size_pool, SIZE_POOL_EDEN_HEAP(size_pool))) {
-#if USE_RVARGC
/* sweep_size_pool requires a free slot but sweeping did not yield any. */
if (size_pool == sweep_size_pool) {
if (size_pool->allocatable_pages > 0) {
@@ -6072,13 +6129,13 @@ gc_sweep_continue(rb_objspace_t *objspace, rb_size_pool_t *sweep_size_pool, rb_h
break;
}
}
-#endif
}
}
- gc_exit(objspace, gc_enter_event_sweep_continue, &lock_lev);
+ gc_sweeping_exit(objspace);
}
+#if GC_CAN_COMPILE_COMPACTION
static void
invalidate_moved_plane(rb_objspace_t *objspace, struct heap_page *page, uintptr_t p, bits_t bitset)
{
@@ -6151,6 +6208,7 @@ invalidate_moved_page(rb_objspace_t *objspace, struct heap_page *page)
p += BITS_BITLENGTH * BASE_SLOT_SIZE;
}
}
+#endif
static void
gc_compact_start(rb_objspace_t *objspace)
@@ -6187,6 +6245,8 @@ static void gc_sweep_compact(rb_objspace_t *objspace);
static void
gc_sweep(rb_objspace_t *objspace)
{
+ gc_sweeping_enter(objspace);
+
const unsigned int immediate_sweep = objspace->flags.immediate_sweep;
gc_report(1, objspace, "gc_sweep: immediate: %d\n", immediate_sweep);
@@ -6214,10 +6274,7 @@ gc_sweep(rb_objspace_t *objspace)
}
}
-#if !USE_RVARGC
- rb_size_pool_t *size_pool = &size_pools[0];
- gc_heap_prepare_minimum_pages(objspace, size_pool, SIZE_POOL_EDEN_HEAP(size_pool));
-#endif
+ gc_sweeping_exit(objspace);
}
/* Marking - Marking stack */
@@ -6479,7 +6536,7 @@ stack_check(rb_execution_context_t *ec, int water_mark)
#define STACKFRAME_FOR_CALL_CFUNC 2048
-MJIT_FUNC_EXPORTED int
+int
rb_ec_stack_check(rb_execution_context_t *ec)
{
return stack_check(ec, STACKFRAME_FOR_CALL_CFUNC);
@@ -6519,16 +6576,6 @@ rb_gc_mark_locations(const VALUE *start, const VALUE *end)
gc_mark_locations(&rb_objspace, start, end, gc_mark_maybe);
}
-static void
-gc_mark_values(rb_objspace_t *objspace, long n, const VALUE *values)
-{
- long i;
-
- for (i=0; i<n; i++) {
- gc_mark(objspace, values[i]);
- }
-}
-
void
rb_gc_mark_values(long n, const VALUE *values)
{
@@ -6536,7 +6583,7 @@ rb_gc_mark_values(long n, const VALUE *values)
rb_objspace_t *objspace = &rb_objspace;
for (i=0; i<n; i++) {
- gc_mark_and_pin(objspace, values[i]);
+ gc_mark(objspace, values[i]);
}
}
@@ -6546,7 +6593,7 @@ gc_mark_stack_values(rb_objspace_t *objspace, long n, const VALUE *values)
long i;
for (i=0; i<n; i++) {
- if (is_markable_object(objspace, values[i])) {
+ if (is_markable_object(values[i])) {
gc_mark_and_pin(objspace, values[i]);
}
}
@@ -6665,14 +6712,6 @@ mark_hash(rb_objspace_t *objspace, VALUE hash)
rb_hash_stlike_foreach(hash, mark_keyvalue, (st_data_t)objspace);
}
- if (RHASH_AR_TABLE_P(hash)) {
- if (LIKELY(during_gc) && RHASH_TRANSIENT_P(hash)) {
- rb_transient_heap_mark(hash, RHASH_AR_TABLE(hash));
- }
- }
- else {
- VM_ASSERT(!RHASH_TRANSIENT_P(hash));
- }
gc_mark(objspace, RHASH(hash)->ifnone);
}
@@ -6722,7 +6761,6 @@ mark_method_entry(rb_objspace_t *objspace, const rb_method_entry_t *me)
return;
case VM_METHOD_TYPE_REFINED:
gc_mark(objspace, (VALUE)def->body.refined.orig_me);
- gc_mark(objspace, (VALUE)def->body.refined.owner);
break;
case VM_METHOD_TYPE_CFUNC:
case VM_METHOD_TYPE_ZSUPER:
@@ -6857,6 +6895,7 @@ each_machine_stack_value(const rb_execution_context_t *ec, void (*cb)(rb_objspac
VALUE *stack_start, *stack_end;
GET_STACK_BOUNDS(stack_start, stack_end, 0);
+ RUBY_DEBUG_LOG("ec->th:%u stack_start:%p stack_end:%p", rb_ec_thread_ptr(ec)->serial, stack_start, stack_end);
each_stack_location(objspace, ec, stack_start, stack_end, cb);
}
@@ -6939,7 +6978,7 @@ gc_remember_unprotected(rb_objspace_t *objspace, VALUE obj)
bits_t *uncollectible_bits = &page->uncollectible_bits[0];
if (!MARKED_IN_BITMAP(uncollectible_bits, obj)) {
- page->flags.has_uncollectible_shady_objects = TRUE;
+ page->flags.has_uncollectible_wb_unprotected_objects = TRUE;
MARK_IN_BITMAP(uncollectible_bits, obj);
objspace->rgengc.uncollectible_wb_unprotected_objects++;
@@ -6962,31 +7001,8 @@ rgengc_check_relation(rb_objspace_t *objspace, VALUE obj)
const VALUE old_parent = objspace->rgengc.parent_object;
if (old_parent) { /* parent object is old */
- if (RVALUE_WB_UNPROTECTED(obj)) {
- if (gc_remember_unprotected(objspace, obj)) {
- gc_report(2, objspace, "relation: (O->S) %s -> %s\n", obj_info(old_parent), obj_info(obj));
- }
- }
- else {
- if (!RVALUE_OLD_P(obj)) {
- if (RVALUE_MARKED(obj)) {
- /* An object pointed from an OLD object should be OLD. */
- gc_report(2, objspace, "relation: (O->unmarked Y) %s -> %s\n", obj_info(old_parent), obj_info(obj));
- RVALUE_AGE_SET_OLD(objspace, obj);
- if (is_incremental_marking(objspace)) {
- if (!RVALUE_MARKING(obj)) {
- gc_grey(objspace, obj);
- }
- }
- else {
- rgengc_remember(objspace, obj);
- }
- }
- else {
- gc_report(2, objspace, "relation: (O->Y) %s -> %s\n", obj_info(old_parent), obj_info(obj));
- RVALUE_AGE_SET_CANDIDATE(objspace, obj);
- }
- }
+ if (RVALUE_WB_UNPROTECTED(obj) || !RVALUE_OLD_P(obj)) {
+ rgengc_remember(objspace, old_parent);
}
}
@@ -7001,11 +7017,9 @@ gc_grey(rb_objspace_t *objspace, VALUE obj)
if (RVALUE_MARKING(obj) == TRUE) rb_bug("gc_grey: %s is marking/remembered.", obj_info(obj));
#endif
-#if GC_ENABLE_INCREMENTAL_MARK
if (is_incremental_marking(objspace)) {
MARK_IN_BITMAP(GET_HEAP_MARKING_BITS(obj), obj);
}
-#endif
push_mark_stack(&objspace->mark_stack, obj);
}
@@ -7069,10 +7083,14 @@ gc_mark_ptr(rb_objspace_t *objspace, VALUE obj)
static inline void
gc_pin(rb_objspace_t *objspace, VALUE obj)
{
- GC_ASSERT(is_markable_object(objspace, obj));
+ GC_ASSERT(is_markable_object(obj));
if (UNLIKELY(objspace->flags.during_compacting)) {
if (LIKELY(during_gc)) {
- MARK_IN_BITMAP(GET_HEAP_PINNED_BITS(obj), obj);
+ if (!MARKED_IN_BITMAP(GET_HEAP_PINNED_BITS(obj), obj)) {
+ GC_ASSERT(GET_HEAP_PAGE(obj)->pinned_slots <= GET_HEAP_PAGE(obj)->total_slots);
+ GET_HEAP_PAGE(obj)->pinned_slots++;
+ MARK_IN_BITMAP(GET_HEAP_PINNED_BITS(obj), obj);
+ }
}
}
}
@@ -7080,7 +7098,7 @@ gc_pin(rb_objspace_t *objspace, VALUE obj)
static inline void
gc_mark_and_pin(rb_objspace_t *objspace, VALUE obj)
{
- if (!is_markable_object(objspace, obj)) return;
+ if (!is_markable_object(obj)) return;
gc_pin(objspace, obj);
gc_mark_ptr(objspace, obj);
}
@@ -7088,7 +7106,7 @@ gc_mark_and_pin(rb_objspace_t *objspace, VALUE obj)
static inline void
gc_mark(rb_objspace_t *objspace, VALUE obj)
{
- if (!is_markable_object(objspace, obj)) return;
+ if (!is_markable_object(obj)) return;
gc_mark_ptr(objspace, obj);
}
@@ -7121,6 +7139,61 @@ rb_gc_mark_and_move(VALUE *ptr)
}
}
+void
+rb_gc_mark_weak(VALUE *ptr)
+{
+ rb_objspace_t *objspace = &rb_objspace;
+
+ if (UNLIKELY(!during_gc)) return;
+
+ VALUE obj = *ptr;
+ if (RB_SPECIAL_CONST_P(obj)) return;
+
+ GC_ASSERT(objspace->rgengc.parent_object == 0 || FL_TEST(objspace->rgengc.parent_object, FL_WB_PROTECTED));
+
+ if (UNLIKELY(RB_TYPE_P(obj, T_NONE))) {
+ rp(obj);
+ rb_bug("try to mark T_NONE object");
+ }
+
+ /* If we are in a minor GC and the other object is old, then obj should
+ * already be marked and cannot be reclaimed in this GC cycle so we don't
+ * need to add it to the weak refences list. */
+ if (!is_full_marking(objspace) && RVALUE_OLD_P(obj)) {
+ GC_ASSERT(RVALUE_MARKED(obj));
+ GC_ASSERT(!objspace->flags.during_compacting);
+
+ return;
+ }
+
+ rgengc_check_relation(objspace, obj);
+
+ rb_darray_append_without_gc(&objspace->weak_references, ptr);
+
+ objspace->profile.weak_references_count++;
+}
+
+void
+rb_gc_remove_weak(VALUE parent_obj, VALUE *ptr)
+{
+ rb_objspace_t *objspace = &rb_objspace;
+
+ /* If we're not incremental marking, then the state of the objects can't
+ * change so we don't need to do anything. */
+ if (!is_incremental_marking(objspace)) return;
+ /* If parent_obj has not been marked, then ptr has not yet been marked
+ * weak, so we don't need to do anything. */
+ if (!RVALUE_MARKED(parent_obj)) return;
+
+ VALUE **ptr_ptr;
+ rb_darray_foreach(objspace->weak_references, i, ptr_ptr) {
+ if (*ptr_ptr == ptr) {
+ *ptr_ptr = NULL;
+ break;
+ }
+ }
+}
+
/* CAUTION: THIS FUNCTION ENABLE *ONLY BEFORE* SWEEPING.
* This function is only for GC_END_MARK timing.
*/
@@ -7154,7 +7227,7 @@ gc_mark_imemo(rb_objspace_t *objspace, VALUE obj)
// just after newobj() can be NULL here.
GC_ASSERT(env->ep[VM_ENV_DATA_INDEX_ENV] == obj);
GC_ASSERT(VM_ENV_ESCAPED_P(env->ep));
- gc_mark_values(objspace, (long)env->env_size, env->env);
+ rb_gc_mark_values((long)env->env_size, env->env);
VM_ENV_FLAGS_SET(env->ep, VM_ENV_FLAG_WB_REQUIRED);
gc_mark(objspace, (VALUE)rb_vm_env_prev_env(env));
gc_mark(objspace, (VALUE)env->iseq);
@@ -7187,7 +7260,7 @@ gc_mark_imemo(rb_objspace_t *objspace, VALUE obj)
mark_method_entry(objspace, &RANY(obj)->as.imemo.ment);
return;
case imemo_iseq:
- rb_iseq_mark_and_update((rb_iseq_t *)obj, false);
+ rb_iseq_mark_and_move((rb_iseq_t *)obj, false);
return;
case imemo_tmpbuf:
{
@@ -7201,15 +7274,34 @@ gc_mark_imemo(rb_objspace_t *objspace, VALUE obj)
rb_ast_mark(&RANY(obj)->as.imemo.ast);
return;
case imemo_parser_strterm:
- rb_strterm_mark(obj);
return;
case imemo_callinfo:
return;
case imemo_callcache:
+ /* cc is callcache.
+ *
+ * cc->klass (klass) should not be marked because if the klass is
+ * free'ed, the cc->klass will be cleared by `vm_cc_invalidate()`.
+ *
+ * cc->cme (cme) should not be marked because if cc is invalidated
+ * when cme is free'ed.
+ * - klass marks cme if klass uses cme.
+ * - caller classe's ccs->cme marks cc->cme.
+ * - if cc is invalidated (klass doesn't refer the cc),
+ * cc is invalidated by `vm_cc_invalidate()` and cc->cme is
+ * not be accessed.
+ * - On the multi-Ractors, cme will be collected with global GC
+ * so that it is safe if GC is not interleaving while accessing
+ * cc and cme.
+ * - However, cc_type_super and cc_type_refinement are not chained
+ * from ccs so cc->cme should be marked; the cme might be
+ * reachable only through cc in these cases.
+ */
{
const struct rb_callcache *cc = (const struct rb_callcache *)obj;
- // should not mark klass here
- gc_mark(objspace, (VALUE)vm_cc_cme(cc));
+ if (vm_cc_super_p(cc) || vm_cc_refinement_p(cc)) {
+ gc_mark(objspace, (VALUE)cc->cme_);
+ }
}
return;
case imemo_constcache:
@@ -7225,6 +7317,14 @@ gc_mark_imemo(rb_objspace_t *objspace, VALUE obj)
}
}
+static bool
+gc_declarative_marking_p(const rb_data_type_t *type)
+{
+ return (type->flags & RUBY_TYPED_DECL_MARKING) != 0;
+}
+
+static void mark_cvc_tbl(rb_objspace_t *objspace, VALUE klass);
+
static void
gc_mark_children(rb_objspace_t *objspace, VALUE obj)
{
@@ -7232,7 +7332,7 @@ gc_mark_children(rb_objspace_t *objspace, VALUE obj)
gc_mark_set_parent(objspace, obj);
if (FL_TEST(obj, FL_EXIVAR)) {
- rb_mark_and_update_generic_ivar(obj);
+ rb_mark_generic_ivar(obj);
}
switch (BUILTIN_TYPE(obj)) {
@@ -7264,16 +7364,25 @@ gc_mark_children(rb_objspace_t *objspace, VALUE obj)
switch (BUILTIN_TYPE(obj)) {
case T_CLASS:
+ if (FL_TEST(obj, FL_SINGLETON)) {
+ gc_mark(objspace, RCLASS_ATTACHED_OBJECT(obj));
+ }
+ // Continue to the shared T_CLASS/T_MODULE
case T_MODULE:
if (RCLASS_SUPER(obj)) {
gc_mark(objspace, RCLASS_SUPER(obj));
}
- if (!RCLASS_EXT(obj)) break;
mark_m_tbl(objspace, RCLASS_M_TBL(obj));
+ mark_cvc_tbl(objspace, obj);
cc_table_mark(objspace, obj);
- for (attr_index_t i = 0; i < RCLASS_IV_COUNT(obj); i++) {
- gc_mark(objspace, RCLASS_IVPTR(obj)[i]);
+ if (rb_shape_obj_too_complex(obj)) {
+ mark_tbl_no_pin(objspace, (st_table *)RCLASS_IVPTR(obj));
+ }
+ else {
+ for (attr_index_t i = 0; i < RCLASS_IV_COUNT(obj); i++) {
+ gc_mark(objspace, RCLASS_IVPTR(obj)[i]);
+ }
}
mark_const_tbl(objspace, RCLASS_CONST_TBL(obj));
@@ -7287,7 +7396,6 @@ gc_mark_children(rb_objspace_t *objspace, VALUE obj)
if (RCLASS_SUPER(obj)) {
gc_mark(objspace, RCLASS_SUPER(obj));
}
- if (!RCLASS_EXT(obj)) break;
if (RCLASS_INCLUDER(obj)) {
gc_mark(objspace, RCLASS_INCLUDER(obj));
@@ -7303,16 +7411,10 @@ gc_mark_children(rb_objspace_t *objspace, VALUE obj)
}
else {
long i, len = RARRAY_LEN(obj);
- const VALUE *ptr = RARRAY_CONST_PTR_TRANSIENT(obj);
+ const VALUE *ptr = RARRAY_CONST_PTR(obj);
for (i=0; i < len; i++) {
gc_mark(objspace, ptr[i]);
}
-
- if (LIKELY(during_gc)) {
- if (!ARY_EMBED_P(obj) && RARRAY_TRANSIENT_P(obj)) {
- rb_transient_heap_mark(obj, ptr);
- }
- }
}
break;
@@ -7322,18 +7424,37 @@ gc_mark_children(rb_objspace_t *objspace, VALUE obj)
case T_STRING:
if (STR_SHARED_P(obj)) {
- gc_mark(objspace, any->as.string.as.heap.aux.shared);
+ if (STR_EMBED_P(any->as.string.as.heap.aux.shared)) {
+ /* Embedded shared strings cannot be moved because this string
+ * points into the slot of the shared string. There may be code
+ * using the RSTRING_PTR on the stack, which would pin this
+ * string but not pin the shared string, causing it to move. */
+ gc_mark_and_pin(objspace, any->as.string.as.heap.aux.shared);
+ }
+ else {
+ gc_mark(objspace, any->as.string.as.heap.aux.shared);
+ }
}
break;
case T_DATA:
{
- void *const ptr = DATA_PTR(obj);
+ void *const ptr = RTYPEDDATA_P(obj) ? RTYPEDDATA_GET_DATA(obj) : DATA_PTR(obj);
+
if (ptr) {
- RUBY_DATA_FUNC mark_func = RTYPEDDATA_P(obj) ?
- any->as.typeddata.type->function.dmark :
- any->as.data.dmark;
- if (mark_func) (*mark_func)(ptr);
+ if (RTYPEDDATA_P(obj) && gc_declarative_marking_p(any->as.typeddata.type)) {
+ size_t *offset_list = (size_t *)RANY(obj)->as.typeddata.type->function.dmark;
+
+ for (size_t offset = *offset_list; offset != RUBY_REF_END; offset = *offset_list++) {
+ rb_gc_mark_movable(*(VALUE *)((char *)ptr + offset));
+ }
+ }
+ else {
+ RUBY_DATA_FUNC mark_func = RTYPEDDATA_P(obj) ?
+ any->as.typeddata.type->function.dmark :
+ any->as.data.dmark;
+ if (mark_func) (*mark_func)(ptr);
+ }
}
}
break;
@@ -7342,7 +7463,7 @@ gc_mark_children(rb_objspace_t *objspace, VALUE obj)
{
rb_shape_t *shape = rb_shape_get_shape_by_id(ROBJECT_SHAPE_ID(obj));
if (rb_shape_obj_too_complex(obj)) {
- mark_m_tbl(objspace, ROBJECT_IV_HASH(obj));
+ mark_tbl_no_pin(objspace, ROBJECT_IV_HASH(obj));
}
else {
const VALUE * const ptr = ROBJECT_IVPTR(obj);
@@ -7351,17 +7472,12 @@ gc_mark_children(rb_objspace_t *objspace, VALUE obj)
for (i = 0; i < len; i++) {
gc_mark(objspace, ptr[i]);
}
-
- if (LIKELY(during_gc) &&
- ROBJ_TRANSIENT_P(obj)) {
- rb_transient_heap_mark(obj, ptr);
- }
}
if (shape) {
VALUE klass = RBASIC_CLASS(obj);
// Increment max_iv_count if applicable, used to determine size pool allocation
- uint32_t num_of_ivs = shape->next_iv_index;
+ attr_index_t num_of_ivs = shape->next_iv_index;
if (RCLASS_EXT(klass)->max_iv_count < num_of_ivs) {
RCLASS_EXT(klass)->max_iv_count = num_of_ivs;
}
@@ -7412,11 +7528,6 @@ gc_mark_children(rb_objspace_t *objspace, VALUE obj)
for (i=0; i<len; i++) {
gc_mark(objspace, ptr[i]);
}
-
- if (LIKELY(during_gc) &&
- RSTRUCT_TRANSIENT_P(obj)) {
- rb_transient_heap_mark(obj, ptr);
- }
}
break;
@@ -7442,10 +7553,8 @@ gc_mark_stacked_objects(rb_objspace_t *objspace, int incremental, size_t count)
{
mark_stack_t *mstack = &objspace->mark_stack;
VALUE obj;
-#if GC_ENABLE_INCREMENTAL_MARK
size_t marked_slots_at_the_beginning = objspace->marked_slots;
size_t popped_count = 0;
-#endif
while (pop_mark_stack(mstack, &obj)) {
if (UNDEF_P(obj)) continue; /* skip */
@@ -7455,7 +7564,6 @@ gc_mark_stacked_objects(rb_objspace_t *objspace, int incremental, size_t count)
}
gc_mark_children(objspace, obj);
-#if GC_ENABLE_INCREMENTAL_MARK
if (incremental) {
if (RGENGC_CHECK_MODE && !RVALUE_MARKING(obj)) {
rb_bug("gc_mark_stacked_objects: incremental, but marking bit is 0");
@@ -7470,7 +7578,6 @@ gc_mark_stacked_objects(rb_objspace_t *objspace, int incremental, size_t count)
else {
/* just ignore marking bits */
}
-#endif
}
if (RGENGC_CHECK_MODE >= 3) gc_verify_internal_consistency(objspace);
@@ -7896,7 +8003,7 @@ check_children_i(const VALUE child, void *ptr)
if (check_rvalue_consistency_force(child, FALSE) != 0) {
fprintf(stderr, "check_children_i: %s has error (referenced from %s)",
obj_info(child), obj_info(data->parent));
- rb_print_backtrace(); /* C backtrace will help to debug */
+ rb_print_backtrace(stderr); /* C backtrace will help to debug */
data->err_count++;
}
@@ -8004,7 +8111,7 @@ gc_verify_heap_page(rb_objspace_t *objspace, struct heap_page *page, VALUE obj)
(void *)page, remembered_old_objects, obj ? obj_info(obj) : "");
}
- if (page->flags.has_uncollectible_shady_objects == FALSE && has_remembered_shady == TRUE) {
+ if (page->flags.has_uncollectible_wb_unprotected_objects == FALSE && has_remembered_shady == TRUE) {
rb_bug("page %p's has_remembered_shady should be false, but there are remembered shady objects. %s",
(void *)page, obj ? obj_info(obj) : "");
}
@@ -8012,11 +8119,11 @@ gc_verify_heap_page(rb_objspace_t *objspace, struct heap_page *page, VALUE obj)
if (0) {
/* free_slots may not equal to free_objects */
if (page->free_slots != free_objects) {
- rb_bug("page %p's free_slots should be %d, but %d\n", (void *)page, page->free_slots, free_objects);
+ rb_bug("page %p's free_slots should be %d, but %d", (void *)page, page->free_slots, free_objects);
}
}
if (page->final_slots != zombie_objects) {
- rb_bug("page %p's final_slots should be %d, but %d\n", (void *)page, page->final_slots, zombie_objects);
+ rb_bug("page %p's final_slots should be %d, but %d", (void *)page, page->final_slots, zombie_objects);
}
return remembered_old_objects;
@@ -8116,9 +8223,8 @@ gc_verify_internal_consistency_(rb_objspace_t *objspace)
!finalizing &&
ruby_single_main_ractor != NULL) {
if (objspace_live_slots(objspace) != data.live_object_count) {
- fprintf(stderr, "heap_pages_final_slots: %"PRIdSIZE", "
- "objspace->profile.total_freed_objects: %"PRIdSIZE"\n",
- heap_pages_final_slots, objspace->profile.total_freed_objects);
+ fprintf(stderr, "heap_pages_final_slots: %"PRIdSIZE", total_freed_objects: %"PRIdSIZE"\n",
+ heap_pages_final_slots, total_freed_objects(objspace));
rb_bug("inconsistent live slot number: expect %"PRIuSIZE", but %"PRIuSIZE".",
objspace_live_slots(objspace), data.live_object_count);
}
@@ -8185,14 +8291,6 @@ rb_gc_verify_internal_consistency(void)
gc_verify_internal_consistency(&rb_objspace);
}
-static VALUE
-gc_verify_transient_heap_internal_consistency(VALUE dmy)
-{
- rb_transient_heap_verify();
- return Qnil;
-}
-
-#if GC_ENABLE_INCREMENTAL_MARK
static void
heap_move_pooled_pages_to_free_pages(rb_heap_t *heap)
{
@@ -8211,7 +8309,6 @@ heap_move_pooled_pages_to_free_pages(rb_heap_t *heap)
heap->pooled_pages = NULL;
}
}
-#endif
/* marks */
@@ -8223,7 +8320,6 @@ gc_marks_start(rb_objspace_t *objspace, int full_mark)
gc_mode_transition(objspace, gc_mode_marking);
if (full_mark) {
-#if GC_ENABLE_INCREMENTAL_MARK
size_t incremental_marking_steps = (objspace->rincgc.pooled_slots / INCREMENTAL_MARK_STEP_ALLOCATIONS) + 1;
objspace->rincgc.step_slots = (objspace->marked_slots * 2) / incremental_marking_steps;
@@ -8231,7 +8327,6 @@ gc_marks_start(rb_objspace_t *objspace, int full_mark)
"objspace->rincgc.pooled_page_num: %"PRIdSIZE", "
"objspace->rincgc.step_slots: %"PRIdSIZE", \n",
objspace->marked_slots, objspace->rincgc.pooled_slots, objspace->rincgc.step_slots);
-#endif
objspace->flags.during_minor_gc = FALSE;
if (ruby_enable_autocompact) {
objspace->flags.during_compacting |= TRUE;
@@ -8247,6 +8342,14 @@ gc_marks_start(rb_objspace_t *objspace, int full_mark)
rb_heap_t *heap = SIZE_POOL_EDEN_HEAP(size_pool);
rgengc_mark_and_rememberset_clear(objspace, heap);
heap_move_pooled_pages_to_free_pages(heap);
+
+ if (objspace->flags.during_compacting) {
+ struct heap_page *page = NULL;
+
+ ccan_list_for_each(&heap->pages, page, page_node) {
+ page->pinned_slots = 0;
+ }
+ }
}
}
else {
@@ -8266,7 +8369,6 @@ gc_marks_start(rb_objspace_t *objspace, int full_mark)
full_mark ? "full" : "minor", mark_stack_size(&objspace->mark_stack));
}
-#if GC_ENABLE_INCREMENTAL_MARK
static inline void
gc_marks_wb_unprotected_objects_plane(rb_objspace_t *objspace, uintptr_t p, bits_t bits)
{
@@ -8310,12 +8412,36 @@ gc_marks_wb_unprotected_objects(rb_objspace_t *objspace, rb_heap_t *heap)
gc_mark_stacked_objects_all(objspace);
}
-#endif
+
+static void
+gc_update_weak_references(rb_objspace_t *objspace)
+{
+ size_t retained_weak_references_count = 0;
+ VALUE **ptr_ptr;
+ rb_darray_foreach(objspace->weak_references, i, ptr_ptr) {
+ if (!*ptr_ptr) continue;
+
+ VALUE obj = **ptr_ptr;
+
+ if (RB_SPECIAL_CONST_P(obj)) continue;
+
+ if (!RVALUE_MARKED(obj)) {
+ **ptr_ptr = Qundef;
+ }
+ else {
+ retained_weak_references_count++;
+ }
+ }
+
+ objspace->profile.retained_weak_references_count = retained_weak_references_count;
+
+ rb_darray_clear(objspace->weak_references);
+ rb_darray_resize_capa_without_gc(&objspace->weak_references, retained_weak_references_count);
+}
static void
gc_marks_finish(rb_objspace_t *objspace)
{
-#if GC_ENABLE_INCREMENTAL_MARK
/* finish incremental GC */
if (is_incremental_marking(objspace)) {
if (RGENGC_CHECK_MODE && is_mark_stack_empty(&objspace->mark_stack) == 0) {
@@ -8338,19 +8464,13 @@ gc_marks_finish(rb_objspace_t *objspace)
gc_marks_wb_unprotected_objects(objspace, SIZE_POOL_EDEN_HEAP(&size_pools[i]));
}
}
-#endif /* GC_ENABLE_INCREMENTAL_MARK */
+
+ gc_update_weak_references(objspace);
#if RGENGC_CHECK_MODE >= 2
gc_verify_internal_consistency(objspace);
#endif
- if (is_full_marking(objspace)) {
- /* See the comment about RUBY_GC_HEAP_OLDOBJECT_LIMIT_FACTOR */
- const double r = gc_params.oldobject_limit_factor;
- objspace->rgengc.uncollectible_wb_unprotected_objects_limit = (size_t)(objspace->rgengc.uncollectible_wb_unprotected_objects * r);
- objspace->rgengc.old_objects_limit = (size_t)(objspace->rgengc.old_objects * r);
- }
-
#if RGENGC_CHECK_MODE >= 4
during_gc = FALSE;
gc_marks_check(objspace, gc_check_after_marks_i, "after_marks");
@@ -8369,9 +8489,14 @@ gc_marks_finish(rb_objspace_t *objspace)
GC_ASSERT(heap_eden_total_slots(objspace) >= objspace->marked_slots);
- /* setup free-able page counts */
- if (max_free_slots < gc_params.heap_init_slots * r_mul) {
- max_free_slots = gc_params.heap_init_slots * r_mul;
+ /* Setup freeable slots. */
+ size_t total_init_slots = 0;
+ for (int i = 0; i < SIZE_POOL_COUNT; i++) {
+ total_init_slots += gc_params.size_pool_init_slots[i] * r_mul;
+ }
+
+ if (max_free_slots < total_init_slots) {
+ max_free_slots = total_init_slots;
}
if (sweep_slots > max_free_slots) {
@@ -8398,23 +8523,15 @@ gc_marks_finish(rb_objspace_t *objspace)
objspace->rgengc.need_major_gc |= GPR_FLAG_MAJOR_BY_NOFREE;
}
}
-
-#if !USE_RVARGC
- if (full_marking) {
- /* increment: */
- gc_report(1, objspace, "gc_marks_finish: heap_set_increment!!\n");
- rb_size_pool_t *size_pool = &size_pools[0];
- size_pool_allocatable_pages_set(objspace, size_pool, heap_extend_pages(objspace, size_pool, sweep_slots, total_slots, heap_allocated_pages + heap_allocatable_pages(objspace)));
-
- heap_increment(objspace, size_pool, SIZE_POOL_EDEN_HEAP(size_pool));
- }
-#endif
}
if (full_marking) {
/* See the comment about RUBY_GC_HEAP_OLDOBJECT_LIMIT_FACTOR */
const double r = gc_params.oldobject_limit_factor;
- objspace->rgengc.uncollectible_wb_unprotected_objects_limit = (size_t)(objspace->rgengc.uncollectible_wb_unprotected_objects * r);
+ objspace->rgengc.uncollectible_wb_unprotected_objects_limit = MAX(
+ (size_t)(objspace->rgengc.uncollectible_wb_unprotected_objects * r),
+ (size_t)(objspace->rgengc.old_objects * gc_params.uncollectible_wb_unprotected_objects_limit_ratio)
+ );
objspace->rgengc.old_objects_limit = (size_t)(objspace->rgengc.old_objects * r);
}
@@ -8435,26 +8552,11 @@ gc_marks_finish(rb_objspace_t *objspace)
objspace->rgengc.need_major_gc ? "major" : "minor");
}
- rb_transient_heap_finish_marking();
rb_ractor_finish_marking();
gc_event_hook(objspace, RUBY_INTERNAL_EVENT_GC_END_MARK, 0);
}
-#if GC_ENABLE_INCREMENTAL_MARK
-static void
-gc_marks_step(rb_objspace_t *objspace, size_t slots)
-{
- GC_ASSERT(is_marking(objspace));
-
- if (gc_mark_stacked_objects_incremental(objspace, slots)) {
- gc_marks_finish(objspace);
- gc_sweep(objspace);
- }
- if (0) fprintf(stderr, "objspace->marked_slots: %"PRIdSIZE"\n", objspace->marked_slots);
-}
-#endif
-
static bool
gc_compact_heap_cursors_met_p(rb_heap_t *heap)
{
@@ -8485,6 +8587,10 @@ gc_compact_destination_pool(rb_objspace_t *objspace, rb_size_pool_t *src_pool, V
obj_size = rb_str_size_as_embedded(src);
break;
+ case T_HASH:
+ obj_size = sizeof(struct RHash) + (RHASH_ST_TABLE_P(src) ? sizeof(st_table) : sizeof(ar_table));
+ break;
+
default:
return src_pool;
}
@@ -8681,11 +8787,9 @@ gc_marks_rest(rb_objspace_t *objspace)
{
gc_report(1, objspace, "gc_marks_rest\n");
-#if GC_ENABLE_INCREMENTAL_MARK
for (int i = 0; i < SIZE_POOL_COUNT; i++) {
SIZE_POOL_EDEN_HEAP(&size_pools[i])->pooled_pages = NULL;
}
-#endif
if (is_incremental_marking(objspace)) {
while (gc_mark_stacked_objects_incremental(objspace, INT_MAX) == FALSE);
@@ -8695,44 +8799,62 @@ gc_marks_rest(rb_objspace_t *objspace)
}
gc_marks_finish(objspace);
+}
+
+static bool
+gc_marks_step(rb_objspace_t *objspace, size_t slots)
+{
+ bool marking_finished = false;
+
+ GC_ASSERT(is_marking(objspace));
+ if (gc_mark_stacked_objects_incremental(objspace, slots)) {
+ gc_marks_finish(objspace);
- /* move to sweep */
- gc_sweep(objspace);
+ marking_finished = true;
+ }
+
+ return marking_finished;
}
-static void
+static bool
gc_marks_continue(rb_objspace_t *objspace, rb_size_pool_t *size_pool, rb_heap_t *heap)
{
GC_ASSERT(dont_gc_val() == FALSE);
-#if GC_ENABLE_INCREMENTAL_MARK
+ bool marking_finished = true;
- unsigned int lock_lev;
- gc_enter(objspace, gc_enter_event_mark_continue, &lock_lev);
+ gc_marking_enter(objspace);
if (heap->free_pages) {
gc_report(2, objspace, "gc_marks_continue: has pooled pages");
- gc_marks_step(objspace, objspace->rincgc.step_slots);
+
+ marking_finished = gc_marks_step(objspace, objspace->rincgc.step_slots);
}
else {
gc_report(2, objspace, "gc_marks_continue: no more pooled pages (stack depth: %"PRIdSIZE").\n",
mark_stack_size(&objspace->mark_stack));
+ size_pool->force_incremental_marking_finish_count++;
gc_marks_rest(objspace);
}
- gc_exit(objspace, gc_enter_event_mark_continue, &lock_lev);
-#endif
+ gc_marking_exit(objspace);
+
+ return marking_finished;
}
-static void
+static bool
gc_marks(rb_objspace_t *objspace, int full_mark)
{
gc_prof_mark_timer_start(objspace);
+ gc_marking_enter(objspace);
+
+ bool marking_finished = false;
/* setup marking */
gc_marks_start(objspace, full_mark);
if (!is_incremental_marking(objspace)) {
gc_marks_rest(objspace);
+ marking_finished = true;
}
#if RGENGC_PROFILE > 0
@@ -8741,7 +8863,11 @@ gc_marks(rb_objspace_t *objspace, int full_mark)
record->old_objects = objspace->rgengc.old_objects;
}
#endif
+
+ gc_marking_exit(objspace);
gc_prof_mark_timer_stop(objspace);
+
+ return marking_finished;
}
/* RGENGC */
@@ -8779,18 +8905,10 @@ gc_report_body(int level, rb_objspace_t *objspace, const char *fmt, ...)
/* bit operations */
static int
-rgengc_remembersetbits_get(rb_objspace_t *objspace, VALUE obj)
-{
- return RVALUE_REMEMBERED(obj);
-}
-
-static int
rgengc_remembersetbits_set(rb_objspace_t *objspace, VALUE obj)
{
struct heap_page *page = GET_HEAP_PAGE(obj);
- bits_t *bits = &page->marking_bits[0];
-
- GC_ASSERT(!is_incremental_marking(objspace));
+ bits_t *bits = &page->remembered_bits[0];
if (MARKED_IN_BITMAP(bits, obj)) {
return FALSE;
@@ -8809,7 +8927,7 @@ static int
rgengc_remember(rb_objspace_t *objspace, VALUE obj)
{
gc_report(6, objspace, "rgengc_remember: %s %s\n", obj_info(obj),
- rgengc_remembersetbits_get(objspace, obj) ? "was already remembered" : "is remembered now");
+ RVALUE_REMEMBERED(obj) ? "was already remembered" : "is remembered now");
check_rvalue_consistency(obj);
@@ -8818,7 +8936,7 @@ rgengc_remember(rb_objspace_t *objspace, VALUE obj)
}
#if RGENGC_PROFILE > 0
- if (!rgengc_remembered(objspace, obj)) {
+ if (!RVALUE_REMEMBERED(obj)) {
if (RVALUE_WB_UNPROTECTED(obj) == 0) {
objspace->profile.total_remembered_normal_object_count++;
#if RGENGC_PROFILE >= 2
@@ -8831,21 +8949,6 @@ rgengc_remember(rb_objspace_t *objspace, VALUE obj)
return rgengc_remembersetbits_set(objspace, obj);
}
-static int
-rgengc_remembered_sweep(rb_objspace_t *objspace, VALUE obj)
-{
- int result = rgengc_remembersetbits_get(objspace, obj);
- check_rvalue_consistency(obj);
- return result;
-}
-
-static int
-rgengc_remembered(rb_objspace_t *objspace, VALUE obj)
-{
- gc_report(6, objspace, "rgengc_remembered: %s\n", obj_info(obj));
- return rgengc_remembered_sweep(objspace, obj);
-}
-
#ifndef PROFILE_REMEMBERSET_MARK
#define PROFILE_REMEMBERSET_MARK 0
#endif
@@ -8880,20 +8983,20 @@ rgengc_rememberset_mark(rb_objspace_t *objspace, rb_heap_t *heap)
gc_report(1, objspace, "rgengc_rememberset_mark: start\n");
ccan_list_for_each(&heap->pages, page, page_node) {
- if (page->flags.has_remembered_objects | page->flags.has_uncollectible_shady_objects) {
+ if (page->flags.has_remembered_objects | page->flags.has_uncollectible_wb_unprotected_objects) {
uintptr_t p = page->start;
bits_t bitset, bits[HEAP_PAGE_BITMAP_LIMIT];
- bits_t *marking_bits = page->marking_bits;
+ bits_t *remembered_bits = page->remembered_bits;
bits_t *uncollectible_bits = page->uncollectible_bits;
bits_t *wb_unprotected_bits = page->wb_unprotected_bits;
#if PROFILE_REMEMBERSET_MARK
- if (page->flags.has_remembered_objects && page->flags.has_uncollectible_shady_objects) has_both++;
+ if (page->flags.has_remembered_objects && page->flags.has_uncollectible_wb_unprotected_objects) has_both++;
else if (page->flags.has_remembered_objects) has_old++;
- else if (page->flags.has_uncollectible_shady_objects) has_shady++;
+ else if (page->flags.has_uncollectible_wb_unprotected_objects) has_shady++;
#endif
for (j=0; j<HEAP_PAGE_BITMAP_LIMIT; j++) {
- bits[j] = marking_bits[j] | (uncollectible_bits[j] & wb_unprotected_bits[j]);
- marking_bits[j] = 0;
+ bits[j] = remembered_bits[j] | (uncollectible_bits[j] & wb_unprotected_bits[j]);
+ remembered_bits[j] = 0;
}
page->flags.has_remembered_objects = FALSE;
@@ -8930,8 +9033,9 @@ rgengc_mark_and_rememberset_clear(rb_objspace_t *objspace, rb_heap_t *heap)
memset(&page->mark_bits[0], 0, HEAP_PAGE_BITMAP_SIZE);
memset(&page->uncollectible_bits[0], 0, HEAP_PAGE_BITMAP_SIZE);
memset(&page->marking_bits[0], 0, HEAP_PAGE_BITMAP_SIZE);
+ memset(&page->remembered_bits[0], 0, HEAP_PAGE_BITMAP_SIZE);
memset(&page->pinned_bits[0], 0, HEAP_PAGE_BITMAP_SIZE);
- page->flags.has_uncollectible_shady_objects = FALSE;
+ page->flags.has_uncollectible_wb_unprotected_objects = FALSE;
page->flags.has_remembered_objects = FALSE;
}
}
@@ -8949,9 +9053,8 @@ gc_writebarrier_generational(VALUE a, VALUE b, rb_objspace_t *objspace)
if (is_incremental_marking(objspace)) rb_bug("gc_writebarrier_generational: called while incremental marking: %s -> %s", obj_info(a), obj_info(b));
}
-#if 1
/* mark `a' and remember (default behavior) */
- if (!rgengc_remembered(objspace, a)) {
+ if (!RVALUE_REMEMBERED(a)) {
RB_VM_LOCK_ENTER_NO_BARRIER();
{
rgengc_remember(objspace, a);
@@ -8959,25 +9062,11 @@ gc_writebarrier_generational(VALUE a, VALUE b, rb_objspace_t *objspace)
RB_VM_LOCK_LEAVE_NO_BARRIER();
gc_report(1, objspace, "gc_writebarrier_generational: %s (remembered) -> %s\n", obj_info(a), obj_info(b));
}
-#else
- /* mark `b' and remember */
- MARK_IN_BITMAP(GET_HEAP_MARK_BITS(b), b);
- if (RVALUE_WB_UNPROTECTED(b)) {
- gc_remember_unprotected(objspace, b);
- }
- else {
- RVALUE_AGE_SET_OLD(objspace, b);
- rgengc_remember(objspace, b);
- }
-
- gc_report(1, objspace, "gc_writebarrier_generational: %s -> %s (remembered)\n", obj_info(a), obj_info(b));
-#endif
check_rvalue_consistency(a);
check_rvalue_consistency(b);
}
-#if GC_ENABLE_INCREMENTAL_MARK
static void
gc_mark_from(rb_objspace_t *objspace, VALUE obj, VALUE parent)
{
@@ -9003,18 +9092,7 @@ gc_writebarrier_incremental(VALUE a, VALUE b, rb_objspace_t *objspace)
}
}
else if (RVALUE_OLD_P(a) && !RVALUE_OLD_P(b)) {
- if (!RVALUE_WB_UNPROTECTED(b)) {
- gc_report(1, objspace, "gc_writebarrier_incremental: [GN] %p -> %s\n", (void *)a, obj_info(b));
- RVALUE_AGE_SET_OLD(objspace, b);
-
- if (RVALUE_BLACK_P(b)) {
- gc_grey(objspace, b);
- }
- }
- else {
- gc_report(1, objspace, "gc_writebarrier_incremental: [LL] %p -> %s\n", (void *)a, obj_info(b));
- gc_remember_unprotected(objspace, b);
- }
+ rgengc_remember(objspace, a);
}
if (UNLIKELY(objspace->flags.during_compacting)) {
@@ -9022,9 +9100,6 @@ gc_writebarrier_incremental(VALUE a, VALUE b, rb_objspace_t *objspace)
}
}
}
-#else
-#define gc_writebarrier_incremental(a, b, objspace)
-#endif
void
rb_gc_writebarrier(VALUE a, VALUE b)
@@ -9074,7 +9149,7 @@ rb_gc_writebarrier_unprotect(VALUE obj)
rb_objspace_t *objspace = &rb_objspace;
gc_report(2, objspace, "rb_gc_writebarrier_unprotect: %s %s\n", obj_info(obj),
- rgengc_remembered(objspace, obj) ? " (already remembered)" : "");
+ RVALUE_REMEMBERED(obj) ? " (already remembered)" : "");
RB_VM_LOCK_ENTER_NO_BARRIER();
{
@@ -9105,7 +9180,7 @@ rb_gc_writebarrier_unprotect(VALUE obj)
/*
* remember `obj' if needed.
*/
-MJIT_FUNC_EXPORTED void
+void
rb_gc_writebarrier_remember(VALUE obj)
{
rb_objspace_t *objspace = &rb_objspace;
@@ -9124,49 +9199,6 @@ rb_gc_writebarrier_remember(VALUE obj)
}
}
-static st_table *rgengc_unprotect_logging_table;
-
-static int
-rgengc_unprotect_logging_exit_func_i(st_data_t key, st_data_t val, st_data_t arg)
-{
- fprintf(stderr, "%s\t%"PRIuVALUE"\n", (char *)key, (VALUE)val);
- return ST_CONTINUE;
-}
-
-static void
-rgengc_unprotect_logging_exit_func(void)
-{
- st_foreach(rgengc_unprotect_logging_table, rgengc_unprotect_logging_exit_func_i, 0);
-}
-
-void
-rb_gc_unprotect_logging(void *objptr, const char *filename, int line)
-{
- VALUE obj = (VALUE)objptr;
-
- if (rgengc_unprotect_logging_table == 0) {
- rgengc_unprotect_logging_table = st_init_strtable();
- atexit(rgengc_unprotect_logging_exit_func);
- }
-
- if (RVALUE_WB_UNPROTECTED(obj) == 0) {
- char buff[0x100];
- st_data_t cnt = 1;
- char *ptr = buff;
-
- snprintf(ptr, 0x100 - 1, "%s|%s:%d", obj_info(obj), filename, line);
-
- if (st_lookup(rgengc_unprotect_logging_table, (st_data_t)ptr, &cnt)) {
- cnt++;
- }
- else {
- ptr = (strdup)(buff);
- if (!ptr) rb_memerror();
- }
- st_insert(rgengc_unprotect_logging_table, (st_data_t)ptr, cnt);
- }
-}
-
void
rb_copy_wb_protected_attribute(VALUE dest, VALUE obj)
{
@@ -9175,7 +9207,7 @@ rb_copy_wb_protected_attribute(VALUE dest, VALUE obj)
if (RVALUE_WB_UNPROTECTED(obj) && !RVALUE_WB_UNPROTECTED(dest)) {
if (!RVALUE_OLD_P(dest)) {
MARK_IN_BITMAP(GET_HEAP_WB_UNPROTECTED_BITS(dest), dest);
- RVALUE_AGE_RESET_RAW(dest);
+ RVALUE_AGE_RESET(dest);
}
else {
RVALUE_DEMOTE(objspace, dest);
@@ -9231,9 +9263,7 @@ rb_obj_gc_flags(VALUE obj, ID* flags, size_t max)
void
rb_gc_ractor_newobj_cache_clear(rb_ractor_newobj_cache_t *newobj_cache)
{
-#if GC_ENABLE_INCREMENTAL_MARK
newobj_cache->incremental_mark_step_allocated_slots = 0;
-#endif
for (size_t size_pool_idx = 0; size_pool_idx < SIZE_POOL_COUNT; size_pool_idx++) {
rb_ractor_newobj_size_pool_cache_t *cache = &newobj_cache->size_pool_caches[size_pool_idx];
@@ -9286,10 +9316,23 @@ rb_gc_register_address(VALUE *addr)
rb_objspace_t *objspace = &rb_objspace;
struct gc_list *tmp;
+ VALUE obj = *addr;
+
tmp = ALLOC(struct gc_list);
tmp->next = global_list;
tmp->varptr = addr;
global_list = tmp;
+
+ /*
+ * Because some C extensions have assignment-then-register bugs,
+ * we guard `obj` here so that it would not get swept defensively.
+ */
+ RB_GC_GUARD(obj);
+ if (0 && !SPECIAL_CONST_P(obj)) {
+ rb_warn("Object is assigned to registering address already: %"PRIsVALUE,
+ rb_obj_class(obj));
+ rb_print_backtrace(stderr);
+ }
}
void
@@ -9455,21 +9498,10 @@ static int
gc_start(rb_objspace_t *objspace, unsigned int reason)
{
unsigned int do_full_mark = !!(reason & GPR_FLAG_FULL_MARK);
-#if GC_ENABLE_INCREMENTAL_MARK
- unsigned int immediate_mark = reason & GPR_FLAG_IMMEDIATE_MARK;
-#endif
/* reason may be clobbered, later, so keep set immediate_sweep here */
objspace->flags.immediate_sweep = !!(reason & GPR_FLAG_IMMEDIATE_SWEEP);
- /* Explicitly enable compaction (GC.compact) */
- if (do_full_mark && ruby_enable_autocompact) {
- objspace->flags.during_compacting = TRUE;
- }
- else {
- objspace->flags.during_compacting = !!(reason & GPR_FLAG_COMPACT);
- }
-
if (!heap_allocated_pages) return FALSE; /* heap is not ready */
if (!(reason & GPR_FLAG_METHOD) && !ready_to_gc(objspace)) return TRUE; /* GC is not allowed */
@@ -9493,31 +9525,41 @@ gc_start(rb_objspace_t *objspace, unsigned int reason)
objspace->flags.immediate_sweep = !(flag & (1<<gc_stress_no_immediate_sweep));
}
- else {
- if (objspace->rgengc.need_major_gc) {
- reason |= objspace->rgengc.need_major_gc;
- do_full_mark = TRUE;
- }
- else if (RGENGC_FORCE_MAJOR_GC) {
- reason = GPR_FLAG_MAJOR_BY_FORCE;
- do_full_mark = TRUE;
- }
- objspace->rgengc.need_major_gc = GPR_FLAG_NONE;
+ if (objspace->rgengc.need_major_gc) {
+ reason |= objspace->rgengc.need_major_gc;
+ do_full_mark = TRUE;
+ }
+ else if (RGENGC_FORCE_MAJOR_GC) {
+ reason = GPR_FLAG_MAJOR_BY_FORCE;
+ do_full_mark = TRUE;
}
+ objspace->rgengc.need_major_gc = GPR_FLAG_NONE;
+
if (do_full_mark && (reason & GPR_FLAG_MAJOR_MASK) == 0) {
reason |= GPR_FLAG_MAJOR_BY_FORCE; /* GC by CAPI, METHOD, and so on. */
}
-#if GC_ENABLE_INCREMENTAL_MARK
- if (!GC_ENABLE_INCREMENTAL_MARK || objspace->flags.dont_incremental || immediate_mark) {
+ if (objspace->flags.dont_incremental ||
+ reason & GPR_FLAG_IMMEDIATE_MARK ||
+ ruby_gc_stressful) {
objspace->flags.during_incremental_marking = FALSE;
}
else {
objspace->flags.during_incremental_marking = do_full_mark;
}
+
+ /* Explicitly enable compaction (GC.compact) */
+ if (do_full_mark && ruby_enable_autocompact) {
+ objspace->flags.during_compacting = TRUE;
+#if RGENGC_CHECK_MODE
+ objspace->rcompactor.compare_func = ruby_autocompact_compare_func;
#endif
+ }
+ else {
+ objspace->flags.during_compacting = !!(reason & GPR_FLAG_COMPACT);
+ }
if (!GC_ENABLE_LAZY_SWEEP || objspace->flags.dont_incremental) {
objspace->flags.immediate_sweep = TRUE;
@@ -9552,18 +9594,21 @@ gc_start(rb_objspace_t *objspace, unsigned int reason)
objspace->profile.count++;
objspace->profile.latest_gc_info = reason;
- objspace->profile.total_allocated_objects_at_gc_start = objspace->total_allocated_objects;
+ objspace->profile.total_allocated_objects_at_gc_start = total_allocated_objects(objspace);
objspace->profile.heap_used_at_gc_start = heap_allocated_pages;
+ objspace->profile.weak_references_count = 0;
+ objspace->profile.retained_weak_references_count = 0;
gc_prof_setup_new_record(objspace, reason);
gc_reset_malloc_info(objspace, do_full_mark);
- rb_transient_heap_start_marking(do_full_mark);
gc_event_hook(objspace, RUBY_INTERNAL_EVENT_GC_START, 0 /* TODO: pass minor/immediate flag? */);
GC_ASSERT(during_gc);
gc_prof_timer_start(objspace);
{
- gc_marks(objspace, do_full_mark);
+ if (gc_marks(objspace, do_full_mark)) {
+ gc_sweep(objspace);
+ }
}
gc_prof_timer_stop(objspace);
@@ -9584,11 +9629,19 @@ gc_rest(rb_objspace_t *objspace)
if (RGENGC_CHECK_MODE >= 2) gc_verify_internal_consistency(objspace);
if (is_incremental_marking(objspace)) {
+ gc_marking_enter(objspace);
gc_marks_rest(objspace);
+ gc_marking_exit(objspace);
+
+ gc_sweep(objspace);
}
+
if (is_lazy_sweeping(objspace)) {
+ gc_sweeping_enter(objspace);
gc_sweep_rest(objspace);
+ gc_sweeping_exit(objspace);
}
+
gc_exit(objspace, gc_enter_event_rest, &lock_lev);
}
}
@@ -9605,9 +9658,7 @@ gc_current_status_fill(rb_objspace_t *objspace, char *buff)
if (is_marking(objspace)) {
buff[i++] = 'M';
if (is_full_marking(objspace)) buff[i++] = 'F';
-#if GC_ENABLE_INCREMENTAL_MARK
if (is_incremental_marking(objspace)) buff[i++] = 'I';
-#endif
}
else if (is_sweeping(objspace)) {
buff[i++] = 'S';
@@ -9679,8 +9730,7 @@ gc_enter_event_cstr(enum gc_enter_event event)
{
switch (event) {
case gc_enter_event_start: return "start";
- case gc_enter_event_mark_continue: return "mark_continue";
- case gc_enter_event_sweep_continue: return "sweep_continue";
+ case gc_enter_event_continue: return "continue";
case gc_enter_event_rest: return "rest";
case gc_enter_event_finalizer: return "finalizer";
case gc_enter_event_rb_memerror: return "rb_memerror";
@@ -9693,71 +9743,37 @@ gc_enter_count(enum gc_enter_event event)
{
switch (event) {
case gc_enter_event_start: RB_DEBUG_COUNTER_INC(gc_enter_start); break;
- case gc_enter_event_mark_continue: RB_DEBUG_COUNTER_INC(gc_enter_mark_continue); break;
- case gc_enter_event_sweep_continue: RB_DEBUG_COUNTER_INC(gc_enter_sweep_continue); break;
+ case gc_enter_event_continue: RB_DEBUG_COUNTER_INC(gc_enter_continue); break;
case gc_enter_event_rest: RB_DEBUG_COUNTER_INC(gc_enter_rest); break;
case gc_enter_event_finalizer: RB_DEBUG_COUNTER_INC(gc_enter_finalizer); break;
case gc_enter_event_rb_memerror: /* nothing */ break;
}
}
-#ifndef MEASURE_GC
-#define MEASURE_GC (objspace->flags.measure_gc)
-#endif
-
-static bool
-gc_enter_event_measure_p(rb_objspace_t *objspace, enum gc_enter_event event)
-{
- if (!MEASURE_GC) return false;
-
- switch (event) {
- case gc_enter_event_start:
- case gc_enter_event_mark_continue:
- case gc_enter_event_sweep_continue:
- case gc_enter_event_rest:
- return true;
-
- default:
- // case gc_enter_event_finalizer:
- // case gc_enter_event_rb_memerror:
- return false;
- }
-}
-
static bool current_process_time(struct timespec *ts);
static void
-gc_enter_clock(rb_objspace_t *objspace, enum gc_enter_event event)
+gc_clock_start(struct timespec *ts)
{
- if (gc_enter_event_measure_p(objspace, event)) {
- if (!current_process_time(&objspace->profile.start_time)) {
- objspace->profile.start_time.tv_sec = 0;
- objspace->profile.start_time.tv_nsec = 0;
- }
+ if (!current_process_time(ts)) {
+ ts->tv_sec = 0;
+ ts->tv_nsec = 0;
}
}
-static void
-gc_exit_clock(rb_objspace_t *objspace, enum gc_enter_event event)
+static uint64_t
+gc_clock_end(struct timespec *ts)
{
- if (gc_enter_event_measure_p(objspace, event)) {
- struct timespec end_time;
-
- if ((objspace->profile.start_time.tv_sec > 0 ||
- objspace->profile.start_time.tv_nsec > 0) &&
- current_process_time(&end_time)) {
+ struct timespec end_time;
- if (end_time.tv_sec < objspace->profile.start_time.tv_sec) {
- return; // ignore
- }
- else {
- uint64_t ns =
- (uint64_t)(end_time.tv_sec - objspace->profile.start_time.tv_sec) * (1000 * 1000 * 1000) +
- (end_time.tv_nsec - objspace->profile.start_time.tv_nsec);
- objspace->profile.total_time_ns += ns;
- }
- }
+ if ((ts->tv_sec > 0 || ts->tv_nsec > 0) &&
+ current_process_time(&end_time) &&
+ end_time.tv_sec >= ts->tv_sec) {
+ return (uint64_t)(end_time.tv_sec - ts->tv_sec) * (1000 * 1000 * 1000) +
+ (end_time.tv_nsec - ts->tv_nsec);
}
+
+ return 0;
}
static inline void
@@ -9765,14 +9781,12 @@ gc_enter(rb_objspace_t *objspace, enum gc_enter_event event, unsigned int *lock_
{
RB_VM_LOCK_ENTER_LEV(lock_lev);
- gc_enter_clock(objspace, event);
-
switch (event) {
case gc_enter_event_rest:
if (!is_marking(objspace)) break;
// fall through
case gc_enter_event_start:
- case gc_enter_event_mark_continue:
+ case gc_enter_event_continue:
// stop other ractors
rb_vm_barrier();
break;
@@ -9796,22 +9810,57 @@ gc_exit(rb_objspace_t *objspace, enum gc_enter_event event, unsigned int *lock_l
{
GC_ASSERT(during_gc != 0);
- gc_event_hook(objspace, RUBY_INTERNAL_EVENT_GC_EXIT, 0); /* TODO: which parameter should be passsed? */
+ gc_event_hook(objspace, RUBY_INTERNAL_EVENT_GC_EXIT, 0); /* TODO: which parameter should be passed? */
gc_record(objspace, 1, gc_enter_event_cstr(event));
RUBY_DEBUG_LOG("%s (%s)", gc_enter_event_cstr(event), gc_current_status(objspace));
gc_report(1, objspace, "gc_exit: %s [%s]\n", gc_enter_event_cstr(event), gc_current_status(objspace));
during_gc = FALSE;
- gc_exit_clock(objspace, event);
RB_VM_LOCK_LEAVE_LEV(lock_lev);
+}
-#if RGENGC_CHECK_MODE >= 2
- if (event == gc_enter_event_sweep_continue && gc_mode(objspace) == gc_mode_none) {
- GC_ASSERT(!during_gc);
- // sweep finished
- gc_verify_internal_consistency(objspace);
- }
+#ifndef MEASURE_GC
+#define MEASURE_GC (objspace->flags.measure_gc)
#endif
+
+static void
+gc_marking_enter(rb_objspace_t *objspace)
+{
+ GC_ASSERT(during_gc != 0);
+
+ if (MEASURE_GC) {
+ gc_clock_start(&objspace->profile.marking_start_time);
+ }
+}
+
+static void
+gc_marking_exit(rb_objspace_t *objspace)
+{
+ GC_ASSERT(during_gc != 0);
+
+ if (MEASURE_GC) {
+ objspace->profile.marking_time_ns += gc_clock_end(&objspace->profile.marking_start_time);
+ }
+}
+
+static void
+gc_sweeping_enter(rb_objspace_t *objspace)
+{
+ GC_ASSERT(during_gc != 0);
+
+ if (MEASURE_GC) {
+ gc_clock_start(&objspace->profile.sweeping_start_time);
+ }
+}
+
+static void
+gc_sweeping_exit(rb_objspace_t *objspace)
+{
+ GC_ASSERT(during_gc != 0);
+
+ if (MEASURE_GC) {
+ objspace->profile.sweeping_time_ns += gc_clock_end(&objspace->profile.sweeping_start_time);
+ }
}
static void *
@@ -9843,6 +9892,31 @@ garbage_collect_with_gvl(rb_objspace_t *objspace, unsigned int reason)
}
}
+static int
+gc_set_candidate_object_i(void *vstart, void *vend, size_t stride, void *data)
+{
+ rb_objspace_t *objspace = &rb_objspace;
+ VALUE v = (VALUE)vstart;
+ for (; v != (VALUE)vend; v += stride) {
+ switch (BUILTIN_TYPE(v)) {
+ case T_NONE:
+ case T_ZOMBIE:
+ break;
+ case T_STRING:
+ // precompute the string coderange. This both save time for when it will be
+ // eventually needed, and avoid mutating heap pages after a potential fork.
+ rb_enc_str_coderange(v);
+ // fall through
+ default:
+ if (!RVALUE_OLD_P(v) && !RVALUE_WB_UNPROTECTED(v)) {
+ RVALUE_AGE_SET_CANDIDATE(objspace, v);
+ }
+ }
+ }
+
+ return 0;
+}
+
static VALUE
gc_start_internal(rb_execution_context_t *ec, VALUE self, VALUE full_mark, VALUE immediate_mark, VALUE immediate_sweep, VALUE compact)
{
@@ -9870,6 +9944,61 @@ gc_start_internal(rb_execution_context_t *ec, VALUE self, VALUE full_mark, VALUE
return Qnil;
}
+static void
+free_empty_pages(void)
+{
+ rb_objspace_t *objspace = &rb_objspace;
+
+ for (int i = 0; i < SIZE_POOL_COUNT; i++) {
+ /* Move all empty pages to the tomb heap for freeing. */
+ rb_size_pool_t *size_pool = &size_pools[i];
+ rb_heap_t *heap = SIZE_POOL_EDEN_HEAP(size_pool);
+ rb_heap_t *tomb_heap = SIZE_POOL_TOMB_HEAP(size_pool);
+
+ size_t freed_pages = 0;
+
+ struct heap_page **next_page_ptr = &heap->free_pages;
+ struct heap_page *page = heap->free_pages;
+ while (page) {
+ /* All finalizers should have been ran in gc_start_internal, so there
+ * should be no objects that require finalization. */
+ GC_ASSERT(page->final_slots == 0);
+
+ struct heap_page *next_page = page->free_next;
+
+ if (page->free_slots == page->total_slots) {
+ heap_unlink_page(objspace, heap, page);
+ heap_add_page(objspace, size_pool, tomb_heap, page);
+ freed_pages++;
+ }
+ else {
+ *next_page_ptr = page;
+ next_page_ptr = &page->free_next;
+ }
+
+ page = next_page;
+ }
+
+ *next_page_ptr = NULL;
+
+ size_pool_allocatable_pages_set(objspace, size_pool, size_pool->allocatable_pages + freed_pages);
+ }
+
+ heap_pages_free_unused_pages(objspace);
+}
+
+void
+rb_gc_prepare_heap(void)
+{
+ rb_objspace_each_objects(gc_set_candidate_object_i, NULL);
+ gc_start_internal(NULL, Qtrue, Qtrue, Qtrue, Qtrue, Qtrue);
+ free_empty_pages();
+
+#if defined(HAVE_MALLOC_TRIM) && !defined(RUBY_ALTERNATIVE_MALLOC_HEADER)
+ malloc_trim(0);
+#endif
+}
+
static int
gc_is_moveable_obj(rb_objspace_t *objspace, VALUE obj)
{
@@ -9910,9 +10039,9 @@ gc_is_moveable_obj(rb_objspace_t *objspace, VALUE obj)
* prevent the objects from being collected. This check prevents
* objects that are keys in the finalizer table from being moved
* without directly pinning them. */
- if (st_is_member(finalizer_table, obj)) {
- return FALSE;
- }
+ GC_ASSERT(st_is_member(finalizer_table, obj));
+
+ return FALSE;
}
GC_ASSERT(RVALUE_MARKED(obj));
GC_ASSERT(!RVALUE_PINNED(obj));
@@ -9927,22 +10056,13 @@ gc_is_moveable_obj(rb_objspace_t *objspace, VALUE obj)
return FALSE;
}
-/* Used in places that could malloc, which can cause the GC to run. We need to
- * temporarily disable the GC to allow the malloc to happen. */
-#define COULD_MALLOC_REGION_START() \
- GC_ASSERT(during_gc); \
- VALUE _already_disabled = rb_gc_disable_no_rest(); \
-
-#define COULD_MALLOC_REGION_END() \
- if (_already_disabled == Qfalse) rb_objspace_gc_enable(objspace);
-
static VALUE
gc_move(rb_objspace_t *objspace, VALUE scan, VALUE free, size_t src_slot_size, size_t slot_size)
{
int marked;
int wb_unprotected;
int uncollectible;
- int marking;
+ int age;
RVALUE *dest = (RVALUE *)free;
RVALUE *src = (RVALUE *)scan;
@@ -9951,25 +10071,28 @@ gc_move(rb_objspace_t *objspace, VALUE scan, VALUE free, size_t src_slot_size, s
GC_ASSERT(BUILTIN_TYPE(scan) != T_NONE);
GC_ASSERT(!MARKED_IN_BITMAP(GET_HEAP_MARK_BITS(free), free));
+ GC_ASSERT(!RVALUE_MARKING((VALUE)src));
+
/* Save off bits for current object. */
marked = rb_objspace_marked_object_p((VALUE)src);
wb_unprotected = RVALUE_WB_UNPROTECTED((VALUE)src);
uncollectible = RVALUE_UNCOLLECTIBLE((VALUE)src);
- marking = RVALUE_MARKING((VALUE)src);
+ bool remembered = RVALUE_REMEMBERED((VALUE)src);
+ age = RVALUE_AGE_GET((VALUE)src);
/* Clear bits for eventual T_MOVED */
CLEAR_IN_BITMAP(GET_HEAP_MARK_BITS((VALUE)src), (VALUE)src);
CLEAR_IN_BITMAP(GET_HEAP_WB_UNPROTECTED_BITS((VALUE)src), (VALUE)src);
CLEAR_IN_BITMAP(GET_HEAP_UNCOLLECTIBLE_BITS((VALUE)src), (VALUE)src);
- CLEAR_IN_BITMAP(GET_HEAP_MARKING_BITS((VALUE)src), (VALUE)src);
+ CLEAR_IN_BITMAP(GET_HEAP_PAGE((VALUE)src)->remembered_bits, (VALUE)src);
if (FL_TEST((VALUE)src, FL_EXIVAR)) {
/* Resizing the st table could cause a malloc */
- COULD_MALLOC_REGION_START();
+ DURING_GC_COULD_MALLOC_REGION_START();
{
rb_mv_generic_ivar((VALUE)src, (VALUE)dest);
}
- COULD_MALLOC_REGION_END();
+ DURING_GC_COULD_MALLOC_REGION_END();
}
st_data_t srcid = (st_data_t)src, id;
@@ -9979,12 +10102,12 @@ gc_move(rb_objspace_t *objspace, VALUE scan, VALUE free, size_t src_slot_size, s
if (st_lookup(objspace->obj_to_id_tbl, srcid, &id)) {
gc_report(4, objspace, "Moving object with seen id: %p -> %p\n", (void *)src, (void *)dest);
/* Resizing the st table could cause a malloc */
- COULD_MALLOC_REGION_START();
+ DURING_GC_COULD_MALLOC_REGION_START();
{
st_delete(objspace->obj_to_id_tbl, &srcid, 0);
st_insert(objspace->obj_to_id_tbl, (st_data_t)dest, id);
}
- COULD_MALLOC_REGION_END();
+ DURING_GC_COULD_MALLOC_REGION_END();
}
/* Move the object */
@@ -9998,13 +10121,14 @@ gc_move(rb_objspace_t *objspace, VALUE scan, VALUE free, size_t src_slot_size, s
}
memset(src, 0, src_slot_size);
+ RVALUE_AGE_RESET((VALUE)src);
/* Set bits for object in new location */
- if (marking) {
- MARK_IN_BITMAP(GET_HEAP_MARKING_BITS((VALUE)dest), (VALUE)dest);
+ if (remembered) {
+ MARK_IN_BITMAP(GET_HEAP_PAGE(dest)->remembered_bits, (VALUE)dest);
}
else {
- CLEAR_IN_BITMAP(GET_HEAP_MARKING_BITS((VALUE)dest), (VALUE)dest);
+ CLEAR_IN_BITMAP(GET_HEAP_PAGE(dest)->remembered_bits, (VALUE)dest);
}
if (marked) {
@@ -10028,6 +10152,7 @@ gc_move(rb_objspace_t *objspace, VALUE scan, VALUE free, size_t src_slot_size, s
CLEAR_IN_BITMAP(GET_HEAP_UNCOLLECTIBLE_BITS((VALUE)dest), (VALUE)dest);
}
+ RVALUE_AGE_SET((VALUE)dest, age);
/* Assign forwarding address */
src->as.moved.flags = T_MOVED;
src->as.moved.dummy = Qundef;
@@ -10039,6 +10164,18 @@ gc_move(rb_objspace_t *objspace, VALUE scan, VALUE free, size_t src_slot_size, s
#if GC_CAN_COMPILE_COMPACTION
static int
+compare_pinned_slots(const void *left, const void *right, void *dummy)
+{
+ struct heap_page *left_page;
+ struct heap_page *right_page;
+
+ left_page = *(struct heap_page * const *)left;
+ right_page = *(struct heap_page * const *)right;
+
+ return left_page->pinned_slots - right_page->pinned_slots;
+}
+
+static int
compare_free_slots(const void *left, const void *right, void *dummy)
{
struct heap_page *left_page;
@@ -10051,7 +10188,7 @@ compare_free_slots(const void *left, const void *right, void *dummy)
}
static void
-gc_sort_heap_by_empty_slots(rb_objspace_t *objspace)
+gc_sort_heap_by_compare_func(rb_objspace_t *objspace, gc_compact_compare_func compare_func)
{
for (int j = 0; j < SIZE_POOL_COUNT; j++) {
rb_size_pool_t *size_pool = &size_pools[j];
@@ -10071,7 +10208,7 @@ gc_sort_heap_by_empty_slots(rb_objspace_t *objspace)
/* Sort the heap so "filled pages" are first. `heap_add_page` adds to the
* head of the list, so empty pages will end up at the start of the heap */
- ruby_qsort(page_list, total_pages, sizeof(struct heap_page *), compare_free_slots, NULL);
+ ruby_qsort(page_list, total_pages, sizeof(struct heap_page *), compare_func, NULL);
/* Reset the eden heap */
ccan_list_head_init(&SIZE_POOL_EDEN_HEAP(size_pool)->pages);
@@ -10092,13 +10229,10 @@ static void
gc_ref_update_array(rb_objspace_t * objspace, VALUE v)
{
if (ARY_SHARED_P(v)) {
-#if USE_RVARGC
VALUE old_root = RARRAY(v)->as.heap.aux.shared_root;
-#endif
UPDATE_IF_MOVED(objspace, RARRAY(v)->as.heap.aux.shared_root);
-#if USE_RVARGC
VALUE new_root = RARRAY(v)->as.heap.aux.shared_root;
// If the root is embedded and its location has changed
if (ARY_EMBED_P(new_root) && new_root != old_root) {
@@ -10106,29 +10240,26 @@ gc_ref_update_array(rb_objspace_t * objspace, VALUE v)
GC_ASSERT(RARRAY(v)->as.heap.ptr >= RARRAY(old_root)->as.ary);
RARRAY(v)->as.heap.ptr = RARRAY(new_root)->as.ary + offset;
}
-#endif
}
else {
long len = RARRAY_LEN(v);
if (len > 0) {
- VALUE *ptr = (VALUE *)RARRAY_CONST_PTR_TRANSIENT(v);
+ VALUE *ptr = (VALUE *)RARRAY_CONST_PTR(v);
for (long i = 0; i < len; i++) {
UPDATE_IF_MOVED(objspace, ptr[i]);
}
}
-#if USE_RVARGC
if (rb_gc_obj_slot_size(v) >= rb_ary_size_as_embedded(v)) {
if (rb_ary_embeddable_p(v)) {
rb_ary_make_embedded(v);
}
}
-#endif
}
}
-static void update_m_tbl(rb_objspace_t *objspace, struct rb_id_table *tbl);
+static void gc_ref_update_table_values_only(rb_objspace_t *objspace, st_table *tbl);
static void
gc_ref_update_object(rb_objspace_t *objspace, VALUE v)
@@ -10136,26 +10267,19 @@ gc_ref_update_object(rb_objspace_t *objspace, VALUE v)
VALUE *ptr = ROBJECT_IVPTR(v);
if (rb_shape_obj_too_complex(v)) {
- update_m_tbl(objspace, ROBJECT_IV_HASH(v));
+ gc_ref_update_table_values_only(objspace, ROBJECT_IV_HASH(v));
return;
}
-#if USE_RVARGC
size_t slot_size = rb_gc_obj_slot_size(v);
size_t embed_size = rb_obj_embedded_size(ROBJECT_IV_CAPACITY(v));
if (slot_size >= embed_size && !RB_FL_TEST_RAW(v, ROBJECT_EMBED)) {
// Object can be re-embedded
memcpy(ROBJECT(v)->as.ary, ptr, sizeof(VALUE) * ROBJECT_IV_COUNT(v));
RB_FL_SET_RAW(v, ROBJECT_EMBED);
- if (ROBJ_TRANSIENT_P(v)) {
- ROBJ_TRANSIENT_UNSET(v);
- }
- else {
- xfree(ptr);
- }
+ xfree(ptr);
ptr = ROBJECT(v)->as.ary;
}
-#endif
for (uint32_t i = 0; i < ROBJECT_IV_COUNT(v); i++) {
UPDATE_IF_MOVED(objspace, ptr[i]);
@@ -10221,7 +10345,7 @@ hash_foreach_replace_value(st_data_t key, st_data_t value, st_data_t argp, int e
}
static void
-gc_update_tbl_refs(rb_objspace_t * objspace, st_table *tbl)
+gc_ref_update_table_values_only(rb_objspace_t *objspace, st_table *tbl)
{
if (!tbl || tbl->num_entries == 0) return;
@@ -10230,6 +10354,12 @@ gc_update_tbl_refs(rb_objspace_t * objspace, st_table *tbl)
}
}
+void
+rb_gc_ref_update_table_values_only(st_table *tbl)
+{
+ gc_ref_update_table_values_only(&rb_objspace, tbl);
+}
+
static void
gc_update_table_refs(rb_objspace_t * objspace, st_table *tbl)
{
@@ -10240,7 +10370,7 @@ gc_update_table_refs(rb_objspace_t * objspace, st_table *tbl)
}
}
-/* Update MOVED references in an st_table */
+/* Update MOVED references in a VALUE=>VALUE st_table */
void
rb_gc_update_tbl_refs(st_table *ptr)
{
@@ -10282,7 +10412,6 @@ gc_ref_update_method_entry(rb_objspace_t *objspace, rb_method_entry_t *me)
return;
case VM_METHOD_TYPE_REFINED:
TYPED_UPDATE_IF_MOVED(objspace, struct rb_method_entry_struct *, def->body.refined.orig_me);
- UPDATE_IF_MOVED(objspace, def->body.refined.owner);
break;
case VM_METHOD_TYPE_CFUNC:
case VM_METHOD_TYPE_ZSUPER:
@@ -10305,6 +10434,20 @@ gc_update_values(rb_objspace_t *objspace, long n, VALUE *values)
}
}
+void
+rb_gc_update_values(long n, VALUE *values)
+{
+ gc_update_values(&rb_objspace, n, values);
+}
+
+static bool
+moved_or_living_object_strictly_p(rb_objspace_t *objspace, VALUE obj)
+{
+ return obj &&
+ is_pointer_to_heap(objspace, (void *)obj) &&
+ (is_live_object(objspace, obj) || BUILTIN_TYPE(obj) == T_MOVED);
+}
+
static void
gc_ref_update_imemo(rb_objspace_t *objspace, VALUE obj)
{
@@ -10344,7 +10487,7 @@ gc_ref_update_imemo(rb_objspace_t *objspace, VALUE obj)
gc_ref_update_method_entry(objspace, &RANY(obj)->as.imemo.ment);
break;
case imemo_iseq:
- rb_iseq_mark_and_update((rb_iseq_t *)obj, true);
+ rb_iseq_mark_and_move((rb_iseq_t *)obj, true);
break;
case imemo_ast:
rb_ast_update_references((rb_ast_t *)obj);
@@ -10352,17 +10495,18 @@ gc_ref_update_imemo(rb_objspace_t *objspace, VALUE obj)
case imemo_callcache:
{
const struct rb_callcache *cc = (const struct rb_callcache *)obj;
- if (cc->klass) {
- UPDATE_IF_MOVED(objspace, cc->klass);
- if (!is_live_object(objspace, cc->klass)) {
- *((VALUE *)(&cc->klass)) = (VALUE)0;
- }
- }
- if (cc->cme_) {
- TYPED_UPDATE_IF_MOVED(objspace, struct rb_callable_method_entry_struct *, cc->cme_);
- if (!is_live_object(objspace, (VALUE)cc->cme_)) {
- *((struct rb_callable_method_entry_struct **)(&cc->cme_)) = (struct rb_callable_method_entry_struct *)0;
+ if (!cc->klass) {
+ // already invalidated
+ }
+ else {
+ if (moved_or_living_object_strictly_p(objspace, cc->klass) &&
+ moved_or_living_object_strictly_p(objspace, (VALUE)cc->cme_)) {
+ UPDATE_IF_MOVED(objspace, cc->klass);
+ TYPED_UPDATE_IF_MOVED(objspace, struct rb_callable_method_entry_struct *, cc->cme_);
+ }
+ else {
+ vm_cc_invalidate(cc);
}
}
}
@@ -10484,9 +10628,14 @@ static enum rb_id_table_iterator_result
update_cvc_tbl_i(VALUE cvc_entry, void *data)
{
struct rb_cvar_class_tbl_entry *entry;
+ rb_objspace_t * objspace = (rb_objspace_t *)data;
entry = (struct rb_cvar_class_tbl_entry *)cvc_entry;
+ if (entry->cref) {
+ TYPED_UPDATE_IF_MOVED(objspace, rb_cref_t *, entry->cref);
+ }
+
entry->class_value = rb_gc_location(entry->class_value);
return ID_TABLE_CONTINUE;
@@ -10502,6 +10651,29 @@ update_cvc_tbl(rb_objspace_t *objspace, VALUE klass)
}
static enum rb_id_table_iterator_result
+mark_cvc_tbl_i(VALUE cvc_entry, void *data)
+{
+ rb_objspace_t *objspace = (rb_objspace_t *)data;
+ struct rb_cvar_class_tbl_entry *entry;
+
+ entry = (struct rb_cvar_class_tbl_entry *)cvc_entry;
+
+ RUBY_ASSERT(entry->cref == 0 || (BUILTIN_TYPE((VALUE)entry->cref) == T_IMEMO && IMEMO_TYPE_P(entry->cref, imemo_cref)));
+ gc_mark(objspace, (VALUE) entry->cref);
+
+ return ID_TABLE_CONTINUE;
+}
+
+static void
+mark_cvc_tbl(rb_objspace_t *objspace, VALUE klass)
+{
+ struct rb_id_table *tbl = RCLASS_CVC_TBL(klass);
+ if (tbl) {
+ rb_id_table_foreach_values(tbl, mark_cvc_tbl_i, objspace);
+ }
+}
+
+static enum rb_id_table_iterator_result
update_const_table(VALUE value, void *data)
{
rb_const_entry_t *ce = (rb_const_entry_t *)value;
@@ -10561,23 +10733,31 @@ gc_update_object_references(rb_objspace_t *objspace, VALUE obj)
gc_report(4, objspace, "update-refs: %p ->\n", (void *)obj);
if (FL_TEST(obj, FL_EXIVAR)) {
- rb_mark_and_update_generic_ivar(obj);
+ rb_ref_update_generic_ivar(obj);
}
switch (BUILTIN_TYPE(obj)) {
case T_CLASS:
+ if (FL_TEST(obj, FL_SINGLETON)) {
+ UPDATE_IF_MOVED(objspace, RCLASS_ATTACHED_OBJECT(obj));
+ }
+ // Continue to the shared T_CLASS/T_MODULE
case T_MODULE:
if (RCLASS_SUPER((VALUE)obj)) {
UPDATE_IF_MOVED(objspace, RCLASS(obj)->super);
}
- if (!RCLASS_EXT(obj)) break;
update_m_tbl(objspace, RCLASS_M_TBL(obj));
update_cc_tbl(objspace, obj);
update_cvc_tbl(objspace, obj);
update_superclasses(objspace, obj);
- for (attr_index_t i = 0; i < RCLASS_IV_COUNT(obj); i++) {
- UPDATE_IF_MOVED(objspace, RCLASS_IVPTR(obj)[i]);
+ if (rb_shape_obj_too_complex(obj)) {
+ gc_ref_update_table_values_only(objspace, RCLASS_IV_HASH(obj));
+ }
+ else {
+ for (attr_index_t i = 0; i < RCLASS_IV_COUNT(obj); i++) {
+ UPDATE_IF_MOVED(objspace, RCLASS_IVPTR(obj)[i]);
+ }
}
update_class_ext(objspace, RCLASS_EXT(obj));
@@ -10587,14 +10767,12 @@ gc_update_object_references(rb_objspace_t *objspace, VALUE obj)
break;
case T_ICLASS:
- if (FL_TEST(obj, RICLASS_IS_ORIGIN) &&
- !FL_TEST(obj, RICLASS_ORIGIN_SHARED_MTBL)) {
+ if (RICLASS_OWNS_M_TBL_P(obj)) {
update_m_tbl(objspace, RCLASS_M_TBL(obj));
}
if (RCLASS_SUPER((VALUE)obj)) {
UPDATE_IF_MOVED(objspace, RCLASS(obj)->super);
}
- if (!RCLASS_EXT(obj)) break;
update_class_ext(objspace, RCLASS_EXT(obj));
update_m_tbl(objspace, RCLASS_CALLABLE_M_TBL(obj));
update_cc_tbl(objspace, obj);
@@ -10623,21 +10801,10 @@ gc_update_object_references(rb_objspace_t *objspace, VALUE obj)
case T_STRING:
{
-#if USE_RVARGC
-#endif
-
if (STR_SHARED_P(obj)) {
-#if USE_RVARGC
- VALUE old_root = any->as.string.as.heap.aux.shared;
-#endif
UPDATE_IF_MOVED(objspace, any->as.string.as.heap.aux.shared);
-#if USE_RVARGC
- VALUE new_root = any->as.string.as.heap.aux.shared;
- rb_str_update_shared_ary(obj, old_root, new_root);
-#endif
}
-#if USE_RVARGC
/* If, after move the string is not embedded, and can fit in the
* slot it's been placed in, then re-embed it. */
if (rb_gc_obj_slot_size(obj) >= rb_str_size_as_embedded(obj)) {
@@ -10645,16 +10812,24 @@ gc_update_object_references(rb_objspace_t *objspace, VALUE obj)
rb_str_make_embedded(obj);
}
}
-#endif
break;
}
case T_DATA:
/* Call the compaction callback, if it exists */
{
- void *const ptr = DATA_PTR(obj);
+ void *const ptr = RTYPEDDATA_P(obj) ? RTYPEDDATA_GET_DATA(obj) : DATA_PTR(obj);
if (ptr) {
- if (RTYPEDDATA_P(obj)) {
+ if (RTYPEDDATA_P(obj) && gc_declarative_marking_p(any->as.typeddata.type)) {
+ size_t *offset_list = (size_t *)RANY(obj)->as.typeddata.type->function.dmark;
+
+ for (size_t offset = *offset_list; offset != RUBY_REF_END; offset = *offset_list++) {
+ VALUE *ref = (VALUE *)((char *)ptr + offset);
+ if (SPECIAL_CONST_P(*ref)) continue;
+ *ref = rb_gc_location(*ref);
+ }
+ }
+ else if (RTYPEDDATA_P(obj)) {
RUBY_DATA_FUNC compact_func = any->as.typeddata.type->function.dcompact;
if (compact_func) (*compact_func)(ptr);
}
@@ -10741,7 +10916,7 @@ gc_ref_update(void *vstart, void *vend, size_t stride, rb_objspace_t * objspace,
VALUE v = (VALUE)vstart;
asan_unlock_freelist(page);
asan_lock_freelist(page);
- page->flags.has_uncollectible_shady_objects = FALSE;
+ page->flags.has_uncollectible_wb_unprotected_objects = FALSE;
page->flags.has_remembered_objects = FALSE;
/* For each object on the page */
@@ -10755,9 +10930,9 @@ gc_ref_update(void *vstart, void *vend, size_t stride, rb_objspace_t * objspace,
break;
default:
if (RVALUE_WB_UNPROTECTED(v)) {
- page->flags.has_uncollectible_shady_objects = TRUE;
+ page->flags.has_uncollectible_wb_unprotected_objects = TRUE;
}
- if (RVALUE_PAGE_MARKING(page, v)) {
+ if (RVALUE_REMEMBERED(v)) {
page->flags.has_remembered_objects = TRUE;
}
if (page->flags.before_sweep) {
@@ -10810,11 +10985,10 @@ gc_update_references(rb_objspace_t *objspace)
}
}
rb_vm_update_references(vm);
- rb_transient_heap_update_references();
rb_gc_update_global_tbl();
global_symbols.ids = rb_gc_location(global_symbols.ids);
global_symbols.dsymbol_fstr_hash = rb_gc_location(global_symbols.dsymbol_fstr_hash);
- gc_update_tbl_refs(objspace, objspace->obj_to_id_tbl);
+ gc_ref_update_table_values_only(objspace, objspace->obj_to_id_tbl);
gc_update_table_refs(objspace, objspace->id_to_obj_tbl);
gc_update_table_refs(objspace, global_symbols.str_sym);
gc_update_table_refs(objspace, finalizer_table);
@@ -10880,7 +11054,7 @@ static void
root_obj_check_moved_i(const char *category, VALUE obj, void *data)
{
if (gc_object_moved_p(&rb_objspace, obj)) {
- rb_bug("ROOT %s points to MOVED: %p -> %s\n", category, (void *)obj, obj_info(rb_gc_location(obj)));
+ rb_bug("ROOT %s points to MOVED: %p -> %s", category, (void *)obj, obj_info(rb_gc_location(obj)));
}
}
@@ -10889,7 +11063,7 @@ reachable_object_check_moved_i(VALUE ref, void *data)
{
VALUE parent = (VALUE)data;
if (gc_object_moved_p(&rb_objspace, ref)) {
- rb_bug("Object %s points to MOVED: %p -> %s\n", obj_info(parent), (void *)ref, obj_info(rb_gc_location(ref)));
+ rb_bug("Object %s points to MOVED: %p -> %s", obj_info(parent), (void *)ref, obj_info(rb_gc_location(ref)));
}
}
@@ -10954,6 +11128,39 @@ gc_compact(VALUE self)
#endif
#if GC_CAN_COMPILE_COMPACTION
+
+struct desired_compaction_pages_i_data {
+ rb_objspace_t *objspace;
+ size_t required_slots[SIZE_POOL_COUNT];
+};
+
+static int
+desired_compaction_pages_i(struct heap_page *page, void *data)
+{
+ struct desired_compaction_pages_i_data *tdata = data;
+ rb_objspace_t *objspace = tdata->objspace;
+ VALUE vstart = (VALUE)page->start;
+ VALUE vend = vstart + (VALUE)(page->total_slots * page->size_pool->slot_size);
+
+
+ for (VALUE v = vstart; v != vend; v += page->size_pool->slot_size) {
+ /* skip T_NONEs; they won't be moved */
+ void *poisoned = asan_unpoison_object_temporary(v);
+ if (BUILTIN_TYPE(v) == T_NONE) {
+ if (poisoned) {
+ asan_poison_object(v);
+ }
+ continue;
+ }
+
+ rb_size_pool_t *dest_pool = gc_compact_destination_pool(objspace, page->size_pool, v);
+ size_t dest_pool_idx = dest_pool - size_pools;
+ tdata->required_slots[dest_pool_idx]++;
+ }
+
+ return 0;
+}
+
static VALUE
gc_verify_compaction_references(rb_execution_context_t *ec, VALUE self, VALUE double_heap, VALUE expand_heap, VALUE toward_empty)
{
@@ -10961,7 +11168,6 @@ gc_verify_compaction_references(rb_execution_context_t *ec, VALUE self, VALUE do
/* Clear the heap. */
gc_start_internal(NULL, self, Qtrue, Qtrue, Qtrue, Qfalse);
- size_t growth_slots = gc_params.heap_init_slots;
if (RTEST(double_heap)) {
rb_warn("double_heap is deprecated, please use expand_heap instead");
@@ -10972,23 +11178,59 @@ gc_verify_compaction_references(rb_execution_context_t *ec, VALUE self, VALUE do
gc_rest(objspace);
/* if both double_heap and expand_heap are set, expand_heap takes precedence */
- if (RTEST(double_heap) || RTEST(expand_heap)) {
+ if (RTEST(expand_heap)) {
+ struct desired_compaction_pages_i_data desired_compaction = {
+ .objspace = objspace,
+ .required_slots = {0},
+ };
+ /* Work out how many objects want to be in each size pool, taking account of moves */
+ objspace_each_pages(objspace, desired_compaction_pages_i, &desired_compaction, TRUE);
+
+ /* Find out which pool has the most pages */
+ size_t max_existing_pages = 0;
+ for(int i = 0; i < SIZE_POOL_COUNT; i++) {
+ rb_size_pool_t *size_pool = &size_pools[i];
+ rb_heap_t *heap = SIZE_POOL_EDEN_HEAP(size_pool);
+ max_existing_pages = MAX(max_existing_pages, heap->total_pages);
+ }
+ /* Add pages to each size pool so that compaction is guaranteed to move every object */
for (int i = 0; i < SIZE_POOL_COUNT; i++) {
rb_size_pool_t *size_pool = &size_pools[i];
rb_heap_t *heap = SIZE_POOL_EDEN_HEAP(size_pool);
- if (RTEST(expand_heap)) {
- size_t required_pages = growth_slots / size_pool->slot_size;
- heap_add_pages(objspace, size_pool, heap, MAX(required_pages, heap->total_pages));
- }
- else {
- heap_add_pages(objspace, size_pool, heap, heap->total_pages);
- }
+ size_t pages_to_add = 0;
+ /*
+ * Step 1: Make sure every pool has the same number of pages, by adding empty pages
+ * to smaller pools. This is required to make sure the compact cursor can advance
+ * through all of the pools in `gc_sweep_compact` without hitting the "sweep &
+ * compact cursors met" condition on some pools before fully compacting others
+ */
+ pages_to_add += max_existing_pages - heap->total_pages;
+ /*
+ * Step 2: Now add additional free pages to each size pool sufficient to hold all objects
+ * that want to be in that size pool, whether moved into it or moved within it
+ */
+ pages_to_add += slots_to_pages_for_size_pool(objspace, size_pool, desired_compaction.required_slots[i]);
+ /*
+ * Step 3: Add two more pages so that the compact & sweep cursors will meet _after_ all objects
+ * have been moved, and not on the last iteration of the `gc_sweep_compact` loop
+ */
+ pages_to_add += 2;
+
+ heap_add_pages(objspace, size_pool, heap, pages_to_add);
+ }
+ }
+ else if (RTEST(double_heap)) {
+ for (int i = 0; i < SIZE_POOL_COUNT; i++) {
+ rb_size_pool_t *size_pool = &size_pools[i];
+ rb_heap_t *heap = SIZE_POOL_EDEN_HEAP(size_pool);
+ heap_add_pages(objspace, size_pool, heap, heap->total_pages);
}
+
}
if (RTEST(toward_empty)) {
- gc_sort_heap_by_empty_slots(objspace);
+ objspace->rcompactor.compare_func = compare_free_slots;
}
}
RB_VM_LOCK_LEAVE();
@@ -10998,6 +11240,7 @@ gc_verify_compaction_references(rb_execution_context_t *ec, VALUE self, VALUE do
objspace_reachable_objects_from_root(objspace, root_obj_check_moved_i, NULL);
objspace_each_objects(objspace, heap_check_moved_i, NULL, TRUE);
+ objspace->rcompactor.compare_func = NULL;
return gc_compact_stats(self);
}
#else
@@ -11014,7 +11257,7 @@ rb_gc_start(void)
void
rb_gc(void)
{
- rb_objspace_t *objspace = &rb_objspace;
+ unless_objspace(objspace) { return; }
unsigned int reason = GPR_DEFAULT_REASON;
garbage_collect(objspace, reason);
}
@@ -11022,7 +11265,7 @@ rb_gc(void)
int
rb_during_gc(void)
{
- rb_objspace_t *objspace = &rb_objspace;
+ unless_objspace(objspace) { return FALSE; }
return during_gc;
}
@@ -11065,6 +11308,7 @@ gc_info_decode(rb_objspace_t *objspace, const VALUE hash_or_key, const unsigned
#endif
static VALUE sym_newobj, sym_malloc, sym_method, sym_capi;
static VALUE sym_none, sym_marking, sym_sweeping;
+ static VALUE sym_weak_references_count, sym_retained_weak_references_count;
VALUE hash = Qnil, key = Qnil;
VALUE major_by, need_major_by;
unsigned int flags = orig_flags ? orig_flags : objspace->profile.latest_gc_info;
@@ -11104,6 +11348,9 @@ gc_info_decode(rb_objspace_t *objspace, const VALUE hash_or_key, const unsigned
S(none);
S(marking);
S(sweeping);
+
+ S(weak_references_count);
+ S(retained_weak_references_count);
#undef S
}
@@ -11154,6 +11401,9 @@ gc_info_decode(rb_objspace_t *objspace, const VALUE hash_or_key, const unsigned
SET(state, gc_mode(objspace) == gc_mode_none ? sym_none :
gc_mode(objspace) == gc_mode_marking ? sym_marking : sym_sweeping);
}
+
+ SET(weak_references_count, LONG2FIX(objspace->profile.weak_references_count));
+ SET(retained_weak_references_count, LONG2FIX(objspace->profile.retained_weak_references_count));
#undef SET
if (!NIL_P(key)) {/* matched key should return above */
@@ -11188,6 +11438,8 @@ gc_latest_gc_info(rb_execution_context_t *ec, VALUE self, VALUE arg)
enum gc_stat_sym {
gc_stat_sym_count,
gc_stat_sym_time,
+ gc_stat_sym_marking_time,
+ gc_stat_sym_sweeping_time,
gc_stat_sym_heap_allocated_pages,
gc_stat_sym_heap_sorted_length,
gc_stat_sym_heap_allocatable_pages,
@@ -11217,6 +11469,7 @@ enum gc_stat_sym {
gc_stat_sym_oldmalloc_increase_bytes,
gc_stat_sym_oldmalloc_increase_bytes_limit,
#endif
+ gc_stat_sym_weak_references_count,
#if RGENGC_PROFILE
gc_stat_sym_total_generated_normal_object_count,
gc_stat_sym_total_generated_shady_object_count,
@@ -11237,6 +11490,8 @@ setup_gc_stat_symbols(void)
#define S(s) gc_stat_symbols[gc_stat_sym_##s] = ID2SYM(rb_intern_const(#s))
S(count);
S(time);
+ S(marking_time),
+ S(sweeping_time),
S(heap_allocated_pages);
S(heap_sorted_length);
S(heap_allocatable_pages);
@@ -11266,6 +11521,7 @@ setup_gc_stat_symbols(void)
S(oldmalloc_increase_bytes);
S(oldmalloc_increase_bytes_limit);
#endif
+ S(weak_references_count);
#if RGENGC_PROFILE
S(total_generated_normal_object_count);
S(total_generated_shady_object_count);
@@ -11278,6 +11534,12 @@ setup_gc_stat_symbols(void)
}
}
+static uint64_t
+ns_to_ms(uint64_t ns)
+{
+ return ns / (1000 * 1000);
+}
+
static size_t
gc_stat_internal(VALUE hash_or_sym)
{
@@ -11303,7 +11565,9 @@ gc_stat_internal(VALUE hash_or_sym)
rb_hash_aset(hash, gc_stat_symbols[gc_stat_sym_##name], SIZET2NUM(attr));
SET(count, objspace->profile.count);
- SET(time, (size_t) (objspace->profile.total_time_ns / (1000 * 1000) /* ns -> ms */)); // TODO: UINT64T2NUM
+ SET(time, (size_t)ns_to_ms(objspace->profile.marking_time_ns + objspace->profile.sweeping_time_ns)); // TODO: UINT64T2NUM
+ SET(marking_time, (size_t)ns_to_ms(objspace->profile.marking_time_ns));
+ SET(sweeping_time, (size_t)ns_to_ms(objspace->profile.sweeping_time_ns));
/* implementation dependent counters */
SET(heap_allocated_pages, heap_allocated_pages);
@@ -11318,8 +11582,8 @@ gc_stat_internal(VALUE hash_or_sym)
SET(heap_tomb_pages, heap_tomb_total_pages(objspace));
SET(total_allocated_pages, total_allocated_pages(objspace));
SET(total_freed_pages, total_freed_pages(objspace));
- SET(total_allocated_objects, objspace->total_allocated_objects);
- SET(total_freed_objects, objspace->profile.total_freed_objects);
+ SET(total_allocated_objects, total_allocated_objects(objspace));
+ SET(total_freed_objects, total_freed_objects(objspace));
SET(malloc_increase_bytes, malloc_increase);
SET(malloc_increase_bytes_limit, malloc_limit);
SET(minor_gc_count, objspace->profile.minor_gc_count);
@@ -11409,6 +11673,9 @@ enum gc_stat_heap_sym {
gc_stat_heap_sym_total_allocated_pages,
gc_stat_heap_sym_total_freed_pages,
gc_stat_heap_sym_force_major_gc_count,
+ gc_stat_heap_sym_force_incremental_marking_finish_count,
+ gc_stat_heap_sym_total_allocated_objects,
+ gc_stat_heap_sym_total_freed_objects,
gc_stat_heap_sym_last
};
@@ -11428,6 +11695,9 @@ setup_gc_stat_heap_symbols(void)
S(total_allocated_pages);
S(total_freed_pages);
S(force_major_gc_count);
+ S(force_incremental_marking_finish_count);
+ S(total_allocated_objects);
+ S(total_freed_objects);
#undef S
}
}
@@ -11471,6 +11741,9 @@ gc_stat_heap_internal(int size_pool_idx, VALUE hash_or_sym)
SET(total_allocated_pages, size_pool->total_allocated_pages);
SET(total_freed_pages, size_pool->total_freed_pages);
SET(force_major_gc_count, size_pool->force_major_gc_count);
+ SET(force_incremental_marking_finish_count, size_pool->force_incremental_marking_finish_count);
+ SET(total_allocated_objects, size_pool->total_allocated_objects);
+ SET(total_freed_objects, size_pool->total_freed_objects);
#undef SET
if (!NIL_P(key)) { /* matched key should return above */
@@ -11625,6 +11898,18 @@ gc_set_auto_compact(VALUE _, VALUE v)
GC_ASSERT(GC_COMPACTION_SUPPORTED);
ruby_enable_autocompact = RTEST(v);
+
+#if RGENGC_CHECK_MODE
+ ruby_autocompact_compare_func = NULL;
+
+ if (SYMBOL_P(v)) {
+ ID id = RB_SYM2ID(v);
+ if (id == rb_intern("empty")) {
+ ruby_autocompact_compare_func = compare_free_slots;
+ }
+ }
+#endif
+
return v;
}
#else
@@ -11754,14 +12039,20 @@ gc_set_initial_pages(rb_objspace_t *objspace)
for (int i = 0; i < SIZE_POOL_COUNT; i++) {
rb_size_pool_t *size_pool = &size_pools[i];
+ char env_key[sizeof("RUBY_GC_HEAP_" "_INIT_SLOTS") + DECIMAL_SIZE_OF_BITS(sizeof(int) * CHAR_BIT)];
+ snprintf(env_key, sizeof(env_key), "RUBY_GC_HEAP_%d_INIT_SLOTS", i);
+
+ size_t size_pool_init_slots = gc_params.size_pool_init_slots[i];
+ if (get_envparam_size(env_key, &size_pool_init_slots, 0)) {
+ gc_params.size_pool_init_slots[i] = size_pool_init_slots;
+ }
- if (gc_params.heap_init_slots > size_pool->eden_heap.total_slots) {
- size_t slots = gc_params.heap_init_slots - size_pool->eden_heap.total_slots;
- int multiple = size_pool->slot_size / BASE_SLOT_SIZE;
- size_pool->allocatable_pages = slots * multiple / HEAP_PAGE_OBJ_LIMIT;
+ if (size_pool_init_slots > size_pool->eden_heap.total_slots) {
+ size_t slots = size_pool_init_slots - size_pool->eden_heap.total_slots;
+ size_pool->allocatable_pages = slots_to_pages_for_size_pool(objspace, size_pool, slots);
}
else {
- /* We already have more slots than heap_init_slots allows, so
+ /* We already have more slots than size_pool_init_slots allows, so
* prevent creating more pages. */
size_pool->allocatable_pages = 0;
}
@@ -11772,8 +12063,6 @@ gc_set_initial_pages(rb_objspace_t *objspace)
/*
* GC tuning environment variables
*
- * * RUBY_GC_HEAP_INIT_SLOTS
- * - Initial allocation slots.
* * RUBY_GC_HEAP_FREE_SLOTS
* - Prepare at least this amount of slots after GC.
* - Allocate slots if there are not enough slots.
@@ -11820,10 +12109,7 @@ ruby_gc_set_params(void)
/* ok */
}
- /* RUBY_GC_HEAP_INIT_SLOTS */
- if (get_envparam_size("RUBY_GC_HEAP_INIT_SLOTS", &gc_params.heap_init_slots, 0)) {
- gc_set_initial_pages(objspace);
- }
+ gc_set_initial_pages(objspace);
get_envparam_double("RUBY_GC_HEAP_GROWTH_FACTOR", &gc_params.growth_factor, 1.0, 0.0, FALSE);
get_envparam_size ("RUBY_GC_HEAP_GROWTH_MAX_SLOTS", &gc_params.growth_max_slots, 0);
@@ -11834,6 +12120,7 @@ ruby_gc_set_params(void)
get_envparam_double("RUBY_GC_HEAP_FREE_SLOTS_GOAL_RATIO", &gc_params.heap_free_slots_goal_ratio,
gc_params.heap_free_slots_min_ratio, gc_params.heap_free_slots_max_ratio, TRUE);
get_envparam_double("RUBY_GC_HEAP_OLDOBJECT_LIMIT_FACTOR", &gc_params.oldobject_limit_factor, 0.0, 0.0, TRUE);
+ get_envparam_double("RUBY_GC_HEAP_REMEMBERED_WB_UNPROTECTED_OBJECTS_LIMIT_RATIO", &gc_params.uncollectible_wb_unprotected_objects_limit_ratio, 0.0, 0.0, TRUE);
if (get_envparam_size("RUBY_GC_MALLOC_LIMIT", &gc_params.malloc_limit_min, 0)) {
malloc_limit = gc_params.malloc_limit_min;
@@ -11869,7 +12156,7 @@ rb_objspace_reachable_objects_from(VALUE obj, void (func)(VALUE, void *), void *
{
if (during_gc) rb_bug("rb_objspace_reachable_objects_from() is not supported while during_gc == true");
- if (is_markable_object(objspace, obj)) {
+ if (is_markable_object(obj)) {
rb_ractor_t *cr = GET_RACTOR();
struct gc_mark_func_data_struct mfd = {
.mark_func = func,
@@ -12306,18 +12593,23 @@ objspace_malloc_fixup(rb_objspace_t *objspace, void *mem, size_t size)
} \
} while (0)
+static void
+check_malloc_not_in_gc(rb_objspace_t *objspace, const char *msg)
+{
+ if (UNLIKELY(malloc_during_gc_p(objspace))) {
+ dont_gc_on();
+ during_gc = false;
+ rb_bug("Cannot %s during GC", msg);
+ }
+}
+
/* these shouldn't be called directly.
* objspace_* functions do not check allocation size.
*/
static void *
objspace_xmalloc0(rb_objspace_t *objspace, size_t size)
{
- if (UNLIKELY(malloc_during_gc_p(objspace))) {
- rb_warn("malloc during GC detected, this could cause crashes if it triggers another GC");
-#if RGENGC_CHECK_MODE || RUBY_DEBUG
- rb_bug("Cannot malloc during GC");
-#endif
- }
+ check_malloc_not_in_gc(objspace, "malloc");
void *mem;
@@ -12336,12 +12628,7 @@ xmalloc2_size(const size_t count, const size_t elsize)
static void *
objspace_xrealloc(rb_objspace_t *objspace, void *ptr, size_t new_size, size_t old_size)
{
- if (UNLIKELY(malloc_during_gc_p(objspace))) {
- rb_warn("realloc during GC detected, this could cause crashes if it triggers another GC");
-#if RGENGC_CHECK_MODE || RUBY_DEBUG
- rb_bug("Cannot realloc during GC");
-#endif
- }
+ check_malloc_not_in_gc(objspace, "realloc");
void *mem;
@@ -12641,8 +12928,16 @@ ruby_xrealloc2_body(void *ptr, size_t n, size_t size)
void
ruby_sized_xfree(void *x, size_t size)
{
- if (x) {
- objspace_xfree(&rb_objspace, x, size);
+ if (LIKELY(x)) {
+ /* It's possible for a C extension's pthread destructor function set by pthread_key_create
+ * to be called after ruby_vm_destruct and attempt to free memory. Fall back to mimfree in
+ * that case. */
+ if (LIKELY(GET_VM())) {
+ objspace_xfree(&rb_objspace, x, size);
+ }
+ else {
+ ruby_mimfree(x);
+ }
}
}
@@ -12804,7 +13099,8 @@ gc_malloc_allocations(VALUE self)
void
rb_gc_adjust_memory_usage(ssize_t diff)
{
- rb_objspace_t *objspace = &rb_objspace;
+ unless_objspace(objspace) { return; }
+
if (diff > 0) {
objspace_malloc_increase(objspace, 0, diff, 0, MEMOP_TYPE_REALLOC);
}
@@ -12814,481 +13110,6 @@ rb_gc_adjust_memory_usage(ssize_t diff)
}
/*
- ------------------------------ WeakMap ------------------------------
-*/
-
-struct weakmap {
- st_table *obj2wmap; /* obj -> [ref,...] */
- st_table *wmap2obj; /* ref -> obj */
- VALUE final;
-};
-
-#define WMAP_DELETE_DEAD_OBJECT_IN_MARK 0
-
-#if WMAP_DELETE_DEAD_OBJECT_IN_MARK
-static int
-wmap_mark_map(st_data_t key, st_data_t val, st_data_t arg)
-{
- rb_objspace_t *objspace = (rb_objspace_t *)arg;
- VALUE obj = (VALUE)val;
- if (!is_live_object(objspace, obj)) return ST_DELETE;
- return ST_CONTINUE;
-}
-#endif
-
-static void
-wmap_compact(void *ptr)
-{
- struct weakmap *w = ptr;
- if (w->wmap2obj) rb_gc_update_tbl_refs(w->wmap2obj);
- if (w->obj2wmap) rb_gc_update_tbl_refs(w->obj2wmap);
- w->final = rb_gc_location(w->final);
-}
-
-static void
-wmap_mark(void *ptr)
-{
- struct weakmap *w = ptr;
-#if WMAP_DELETE_DEAD_OBJECT_IN_MARK
- if (w->obj2wmap) st_foreach(w->obj2wmap, wmap_mark_map, (st_data_t)&rb_objspace);
-#endif
- rb_gc_mark_movable(w->final);
-}
-
-static int
-wmap_free_map(st_data_t key, st_data_t val, st_data_t arg)
-{
- VALUE *ptr = (VALUE *)val;
- ruby_sized_xfree(ptr, (ptr[0] + 1) * sizeof(VALUE));
- return ST_CONTINUE;
-}
-
-static void
-wmap_free(void *ptr)
-{
- struct weakmap *w = ptr;
- st_foreach(w->obj2wmap, wmap_free_map, 0);
- st_free_table(w->obj2wmap);
- st_free_table(w->wmap2obj);
- xfree(w);
-}
-
-static int
-wmap_memsize_map(st_data_t key, st_data_t val, st_data_t arg)
-{
- VALUE *ptr = (VALUE *)val;
- *(size_t *)arg += (ptr[0] + 1) * sizeof(VALUE);
- return ST_CONTINUE;
-}
-
-static size_t
-wmap_memsize(const void *ptr)
-{
- size_t size;
- const struct weakmap *w = ptr;
- size = sizeof(*w);
- size += st_memsize(w->obj2wmap);
- size += st_memsize(w->wmap2obj);
- st_foreach(w->obj2wmap, wmap_memsize_map, (st_data_t)&size);
- return size;
-}
-
-static const rb_data_type_t weakmap_type = {
- "weakmap",
- {
- wmap_mark,
- wmap_free,
- wmap_memsize,
- wmap_compact,
- },
- 0, 0, RUBY_TYPED_FREE_IMMEDIATELY
-};
-
-static VALUE wmap_finalize(RB_BLOCK_CALL_FUNC_ARGLIST(objid, self));
-
-static VALUE
-wmap_allocate(VALUE klass)
-{
- struct weakmap *w;
- VALUE obj = TypedData_Make_Struct(klass, struct weakmap, &weakmap_type, w);
- w->obj2wmap = rb_init_identtable();
- w->wmap2obj = rb_init_identtable();
- w->final = rb_func_lambda_new(wmap_finalize, obj, 1, 1);
- return obj;
-}
-
-static int
-wmap_live_p(rb_objspace_t *objspace, VALUE obj)
-{
- if (SPECIAL_CONST_P(obj)) return TRUE;
- /* If is_pointer_to_heap returns false, the page could be in the tomb heap
- * or have already been freed. */
- if (!is_pointer_to_heap(objspace, (void *)obj)) return FALSE;
-
- void *poisoned = asan_unpoison_object_temporary(obj);
-
- enum ruby_value_type t = BUILTIN_TYPE(obj);
- int ret = (!(t == T_NONE || t >= T_FIXNUM || t == T_ICLASS) &&
- is_live_object(objspace, obj));
-
- if (poisoned) {
- asan_poison_object(obj);
- }
-
- return ret;
-}
-
-static int
-wmap_final_func(st_data_t *key, st_data_t *value, st_data_t arg, int existing)
-{
- VALUE wmap, *ptr, size, i, j;
- if (!existing) return ST_STOP;
- wmap = (VALUE)arg, ptr = (VALUE *)*value;
- for (i = j = 1, size = ptr[0]; i <= size; ++i) {
- if (ptr[i] != wmap) {
- ptr[j++] = ptr[i];
- }
- }
- if (j == 1) {
- ruby_sized_xfree(ptr, i * sizeof(VALUE));
- return ST_DELETE;
- }
- if (j < i) {
- SIZED_REALLOC_N(ptr, VALUE, j + 1, i);
- ptr[0] = j;
- *value = (st_data_t)ptr;
- }
- return ST_CONTINUE;
-}
-
-/* :nodoc: */
-static VALUE
-wmap_finalize(RB_BLOCK_CALL_FUNC_ARGLIST(objid, self))
-{
- st_data_t orig, wmap, data;
- VALUE obj, *rids, i, size;
- struct weakmap *w;
-
- TypedData_Get_Struct(self, struct weakmap, &weakmap_type, w);
- /* Get reference from object id. */
- if (UNDEF_P(obj = id2ref_obj_tbl(&rb_objspace, objid))) {
- rb_bug("wmap_finalize: objid is not found.");
- }
-
- /* obj is original referenced object and/or weak reference. */
- orig = (st_data_t)obj;
- if (st_delete(w->obj2wmap, &orig, &data)) {
- rids = (VALUE *)data;
- size = *rids++;
- for (i = 0; i < size; ++i) {
- wmap = (st_data_t)rids[i];
- st_delete(w->wmap2obj, &wmap, NULL);
- }
- ruby_sized_xfree((VALUE *)data, (size + 1) * sizeof(VALUE));
- }
-
- wmap = (st_data_t)obj;
- if (st_delete(w->wmap2obj, &wmap, &orig)) {
- wmap = (st_data_t)obj;
- st_update(w->obj2wmap, orig, wmap_final_func, wmap);
- }
- return self;
-}
-
-struct wmap_iter_arg {
- rb_objspace_t *objspace;
- VALUE value;
-};
-
-static VALUE
-wmap_inspect_append(rb_objspace_t *objspace, VALUE str, VALUE obj)
-{
- if (SPECIAL_CONST_P(obj)) {
- return rb_str_append(str, rb_inspect(obj));
- }
- else if (wmap_live_p(objspace, obj)) {
- return rb_str_append(str, rb_any_to_s(obj));
- }
- else {
- return rb_str_catf(str, "#<collected:%p>", (void*)obj);
- }
-}
-
-static int
-wmap_inspect_i(st_data_t key, st_data_t val, st_data_t arg)
-{
- struct wmap_iter_arg *argp = (struct wmap_iter_arg *)arg;
- rb_objspace_t *objspace = argp->objspace;
- VALUE str = argp->value;
- VALUE k = (VALUE)key, v = (VALUE)val;
-
- if (RSTRING_PTR(str)[0] == '#') {
- rb_str_cat2(str, ", ");
- }
- else {
- rb_str_cat2(str, ": ");
- RSTRING_PTR(str)[0] = '#';
- }
- wmap_inspect_append(objspace, str, k);
- rb_str_cat2(str, " => ");
- wmap_inspect_append(objspace, str, v);
-
- return ST_CONTINUE;
-}
-
-static VALUE
-wmap_inspect(VALUE self)
-{
- VALUE str;
- VALUE c = rb_class_name(CLASS_OF(self));
- struct weakmap *w;
- struct wmap_iter_arg args;
-
- TypedData_Get_Struct(self, struct weakmap, &weakmap_type, w);
- str = rb_sprintf("-<%"PRIsVALUE":%p", c, (void *)self);
- if (w->wmap2obj) {
- args.objspace = &rb_objspace;
- args.value = str;
- st_foreach(w->wmap2obj, wmap_inspect_i, (st_data_t)&args);
- }
- RSTRING_PTR(str)[0] = '#';
- rb_str_cat2(str, ">");
- return str;
-}
-
-static inline bool
-wmap_live_entry_p(rb_objspace_t *objspace, st_data_t key, st_data_t val)
-{
- return wmap_live_p(objspace, (VALUE)key) && wmap_live_p(objspace, (VALUE)val);
-}
-
-static int
-wmap_each_i(st_data_t key, st_data_t val, st_data_t arg)
-{
- rb_objspace_t *objspace = (rb_objspace_t *)arg;
-
- if (wmap_live_entry_p(objspace, key, val)) {
- rb_yield_values(2, (VALUE)key, (VALUE)val);
- return ST_CONTINUE;
- }
- else {
- return ST_DELETE;
- }
-}
-
-/* Iterates over keys and objects in a weakly referenced object */
-static VALUE
-wmap_each(VALUE self)
-{
- struct weakmap *w;
- rb_objspace_t *objspace = &rb_objspace;
-
- TypedData_Get_Struct(self, struct weakmap, &weakmap_type, w);
- st_foreach(w->wmap2obj, wmap_each_i, (st_data_t)objspace);
- return self;
-}
-
-static int
-wmap_each_key_i(st_data_t key, st_data_t val, st_data_t arg)
-{
- rb_objspace_t *objspace = (rb_objspace_t *)arg;
-
- if (wmap_live_entry_p(objspace, key, val)) {
- rb_yield((VALUE)key);
- return ST_CONTINUE;
- }
- else {
- return ST_DELETE;
- }
-}
-
-/* Iterates over keys and objects in a weakly referenced object */
-static VALUE
-wmap_each_key(VALUE self)
-{
- struct weakmap *w;
- rb_objspace_t *objspace = &rb_objspace;
-
- TypedData_Get_Struct(self, struct weakmap, &weakmap_type, w);
- st_foreach(w->wmap2obj, wmap_each_key_i, (st_data_t)objspace);
- return self;
-}
-
-static int
-wmap_each_value_i(st_data_t key, st_data_t val, st_data_t arg)
-{
- rb_objspace_t *objspace = (rb_objspace_t *)arg;
-
- if (wmap_live_entry_p(objspace, key, val)) {
- rb_yield((VALUE)val);
- return ST_CONTINUE;
- }
- else {
- return ST_DELETE;
- }
-}
-
-/* Iterates over keys and objects in a weakly referenced object */
-static VALUE
-wmap_each_value(VALUE self)
-{
- struct weakmap *w;
- rb_objspace_t *objspace = &rb_objspace;
-
- TypedData_Get_Struct(self, struct weakmap, &weakmap_type, w);
- st_foreach(w->wmap2obj, wmap_each_value_i, (st_data_t)objspace);
- return self;
-}
-
-static int
-wmap_keys_i(st_data_t key, st_data_t val, st_data_t arg)
-{
- struct wmap_iter_arg *argp = (struct wmap_iter_arg *)arg;
- rb_objspace_t *objspace = argp->objspace;
- VALUE ary = argp->value;
-
- if (wmap_live_entry_p(objspace, key, val)) {
- rb_ary_push(ary, (VALUE)key);
- return ST_CONTINUE;
- }
- else {
- return ST_DELETE;
- }
-}
-
-/* Iterates over keys and objects in a weakly referenced object */
-static VALUE
-wmap_keys(VALUE self)
-{
- struct weakmap *w;
- struct wmap_iter_arg args;
-
- TypedData_Get_Struct(self, struct weakmap, &weakmap_type, w);
- args.objspace = &rb_objspace;
- args.value = rb_ary_new();
- st_foreach(w->wmap2obj, wmap_keys_i, (st_data_t)&args);
- return args.value;
-}
-
-static int
-wmap_values_i(st_data_t key, st_data_t val, st_data_t arg)
-{
- struct wmap_iter_arg *argp = (struct wmap_iter_arg *)arg;
- rb_objspace_t *objspace = argp->objspace;
- VALUE ary = argp->value;
-
- if (wmap_live_entry_p(objspace, key, val)) {
- rb_ary_push(ary, (VALUE)val);
- return ST_CONTINUE;
- }
- else {
- return ST_DELETE;
- }
-}
-
-/* Iterates over values and objects in a weakly referenced object */
-static VALUE
-wmap_values(VALUE self)
-{
- struct weakmap *w;
- struct wmap_iter_arg args;
-
- TypedData_Get_Struct(self, struct weakmap, &weakmap_type, w);
- args.objspace = &rb_objspace;
- args.value = rb_ary_new();
- st_foreach(w->wmap2obj, wmap_values_i, (st_data_t)&args);
- return args.value;
-}
-
-static int
-wmap_aset_update(st_data_t *key, st_data_t *val, st_data_t arg, int existing)
-{
- VALUE size, *ptr, *optr;
- if (existing) {
- size = (ptr = optr = (VALUE *)*val)[0];
- ++size;
- SIZED_REALLOC_N(ptr, VALUE, size + 1, size);
- }
- else {
- optr = 0;
- size = 1;
- ptr = ruby_xmalloc0(2 * sizeof(VALUE));
- }
- ptr[0] = size;
- ptr[size] = (VALUE)arg;
- if (ptr == optr) return ST_STOP;
- *val = (st_data_t)ptr;
- return ST_CONTINUE;
-}
-
-/* Creates a weak reference from the given key to the given value */
-static VALUE
-wmap_aset(VALUE self, VALUE key, VALUE value)
-{
- struct weakmap *w;
-
- TypedData_Get_Struct(self, struct weakmap, &weakmap_type, w);
- if (FL_ABLE(value)) {
- define_final0(value, w->final);
- }
- if (FL_ABLE(key)) {
- define_final0(key, w->final);
- }
-
- st_update(w->obj2wmap, (st_data_t)value, wmap_aset_update, key);
- st_insert(w->wmap2obj, (st_data_t)key, (st_data_t)value);
- return nonspecial_obj_id(value);
-}
-
-/* Retrieves a weakly referenced object with the given key */
-static VALUE
-wmap_lookup(VALUE self, VALUE key)
-{
- st_data_t data;
- VALUE obj;
- struct weakmap *w;
- rb_objspace_t *objspace = &rb_objspace;
- GC_ASSERT(wmap_live_p(objspace, key));
-
- TypedData_Get_Struct(self, struct weakmap, &weakmap_type, w);
- if (!st_lookup(w->wmap2obj, (st_data_t)key, &data)) return Qundef;
- obj = (VALUE)data;
- if (!wmap_live_p(objspace, obj)) return Qundef;
- return obj;
-}
-
-/* Retrieves a weakly referenced object with the given key */
-static VALUE
-wmap_aref(VALUE self, VALUE key)
-{
- VALUE obj = wmap_lookup(self, key);
- return !UNDEF_P(obj) ? obj : Qnil;
-}
-
-/* Returns +true+ if +key+ is registered */
-static VALUE
-wmap_has_key(VALUE self, VALUE key)
-{
- return RBOOL(!UNDEF_P(wmap_lookup(self, key)));
-}
-
-/* Returns the number of referenced objects */
-static VALUE
-wmap_size(VALUE self)
-{
- struct weakmap *w;
- st_index_t n;
-
- TypedData_Get_Struct(self, struct weakmap, &weakmap_type, w);
- n = w->wmap2obj->num_entries;
-#if SIZEOF_ST_INDEX_T <= SIZEOF_LONG
- return ULONG2NUM(n);
-#else
- return ULL2NUM(n);
-#endif
-}
-
-/*
------------------------------ GC profiler ------------------------------
*/
@@ -13517,7 +13338,7 @@ gc_prof_set_heap_info(rb_objspace_t *objspace)
{
if (gc_prof_enabled(objspace)) {
gc_profile_record *record = gc_prof_record(objspace);
- size_t live = objspace->profile.total_allocated_objects_at_gc_start - objspace->profile.total_freed_objects;
+ size_t live = objspace->profile.total_allocated_objects_at_gc_start - total_freed_objects(objspace);
size_t total = objspace->profile.heap_used_at_gc_start * HEAP_PAGE_OBJ_LIMIT;
#if GC_PROFILE_MORE_DETAIL
@@ -13549,9 +13370,7 @@ gc_profile_clear(VALUE _)
objspace->profile.size = 0;
objspace->profile.next_index = 0;
objspace->profile.current_record = 0;
- if (p) {
- free(p);
- }
+ free(p);
return Qnil;
}
@@ -13621,7 +13440,7 @@ gc_profile_record_get(VALUE _)
gc_profile_record *record = &objspace->profile.records[i];
prof = rb_hash_new();
- rb_hash_aset(prof, ID2SYM(rb_intern("GC_FLAGS")), gc_info_decode(0, rb_hash_new(), record->flags));
+ rb_hash_aset(prof, ID2SYM(rb_intern("GC_FLAGS")), gc_info_decode(objspace, rb_hash_new(), record->flags));
rb_hash_aset(prof, ID2SYM(rb_intern("GC_TIME")), DBL2NUM(record->gc_time));
rb_hash_aset(prof, ID2SYM(rb_intern("GC_INVOKE_TIME")), DBL2NUM(record->gc_invoke_time));
rb_hash_aset(prof, ID2SYM(rb_intern("HEAP_USE_SIZE")), SIZET2NUM(record->heap_use_size));
@@ -14015,7 +13834,7 @@ rb_raw_obj_info_common(char *const buff, const size_t buff_size, const VALUE obj
}
}
else {
- const int age = RVALUE_FLAGS_AGE(RBASIC(obj)->flags);
+ const int age = RVALUE_AGE_GET(obj);
if (is_pointer_to_heap(&rb_objspace, (void *)obj)) {
APPEND_F("%p [%d%s%s%s%s%s%s] %s ",
@@ -14079,13 +13898,12 @@ rb_raw_obj_info_buitin_type(char *const buff, const size_t buff_size, const VALU
RARRAY_LEN(obj));
}
else {
- APPEND_F("[%s%s%s] len: %ld, capa:%ld ptr:%p",
+ APPEND_F("[%s%s] len: %ld, capa:%ld ptr:%p",
C(ARY_EMBED_P(obj), "E"),
C(ARY_SHARED_P(obj), "S"),
- C(RARRAY_TRANSIENT_P(obj), "T"),
RARRAY_LEN(obj),
ARY_EMBED_P(obj) ? -1L : RARRAY(obj)->as.heap.aux.capa,
- (void *)RARRAY_CONST_PTR_TRANSIENT(obj));
+ (void *)RARRAY_CONST_PTR(obj));
}
break;
case T_STRING: {
@@ -14116,9 +13934,8 @@ rb_raw_obj_info_buitin_type(char *const buff, const size_t buff_size, const VALU
break;
}
case T_HASH: {
- APPEND_F("[%c%c] %"PRIdSIZE,
+ APPEND_F("[%c] %"PRIdSIZE,
RHASH_AR_TABLE_P(obj) ? 'A' : 'S',
- RHASH_TRANSIENT_P(obj) ? 'T' : ' ',
RHASH_SIZE(obj));
break;
}
@@ -14130,7 +13947,7 @@ rb_raw_obj_info_buitin_type(char *const buff, const size_t buff_size, const VALU
APPEND_F("%s", RSTRING_PTR(class_path));
}
else {
- APPEND_S("(annon)");
+ APPEND_S("(anon)");
}
break;
}
@@ -14144,14 +13961,20 @@ rb_raw_obj_info_buitin_type(char *const buff, const size_t buff_size, const VALU
}
case T_OBJECT:
{
- uint32_t len = ROBJECT_IV_CAPACITY(obj);
-
- if (RANY(obj)->as.basic.flags & ROBJECT_EMBED) {
- APPEND_F("(embed) len:%d", len);
+ if (rb_shape_obj_too_complex(obj)) {
+ size_t hash_len = rb_st_table_size(ROBJECT_IV_HASH(obj));
+ APPEND_F("(too_complex) len:%zu", hash_len);
}
else {
- VALUE *ptr = ROBJECT_IVPTR(obj);
- APPEND_F("len:%d ptr:%p", len, (void *)ptr);
+ uint32_t len = ROBJECT_IV_CAPACITY(obj);
+
+ if (RANY(obj)->as.basic.flags & ROBJECT_EMBED) {
+ APPEND_F("(embed) len:%d", len);
+ }
+ else {
+ VALUE *ptr = ROBJECT_IVPTR(obj);
+ APPEND_F("len:%d ptr:%p", len, (void *)ptr);
+ }
}
}
break;
@@ -14186,7 +14009,7 @@ rb_raw_obj_info_buitin_type(char *const buff, const size_t buff_size, const VALU
{
const rb_method_entry_t *me = &RANY(obj)->as.imemo.ment;
- APPEND_F(":%s (%s%s%s%s) type:%s alias:%d owner:%p defined_class:%p",
+ APPEND_F(":%s (%s%s%s%s) type:%s aliased:%d owner:%p defined_class:%p",
rb_id2name(me->called_id),
METHOD_ENTRY_VISI(me) == METHOD_VISI_PUBLIC ? "pub" :
METHOD_ENTRY_VISI(me) == METHOD_VISI_PRIVATE ? "pri" : "pro",
@@ -14194,7 +14017,7 @@ rb_raw_obj_info_buitin_type(char *const buff, const size_t buff_size, const VALU
METHOD_ENTRY_CACHED(me) ? ",cc" : "",
METHOD_ENTRY_INVALIDATED(me) ? ",inv" : "",
me->def ? rb_method_type_name(me->def->type) : "NULL",
- me->def ? me->def->alias_count : -1,
+ me->def ? me->def->aliased : -1,
(void *)me->owner, // obj_info(me->owner),
(void *)me->defined_class); //obj_info(me->defined_class)));
@@ -14308,7 +14131,7 @@ obj_info(VALUE obj)
}
#endif
-MJIT_FUNC_EXPORTED const char *
+const char *
rb_obj_info(VALUE obj)
{
return obj_info(obj);
@@ -14321,7 +14144,7 @@ rb_obj_info_dump(VALUE obj)
fprintf(stderr, "rb_obj_info_dump: %s\n", rb_raw_obj_info(buff, 0x100, obj));
}
-MJIT_FUNC_EXPORTED void
+void
rb_obj_info_dump_loc(VALUE obj, const char *file, int line, const char *func)
{
char buff[0x100];
@@ -14353,14 +14176,14 @@ rb_gcdebug_print_obj_condition(VALUE obj)
fprintf(stderr, "marked? : %s\n", MARKED_IN_BITMAP(GET_HEAP_MARK_BITS(obj), obj) ? "true" : "false");
fprintf(stderr, "pinned? : %s\n", MARKED_IN_BITMAP(GET_HEAP_PINNED_BITS(obj), obj) ? "true" : "false");
- fprintf(stderr, "age? : %d\n", RVALUE_AGE(obj));
+ fprintf(stderr, "age? : %d\n", RVALUE_AGE_GET(obj));
fprintf(stderr, "old? : %s\n", RVALUE_OLD_P(obj) ? "true" : "false");
fprintf(stderr, "WB-protected?: %s\n", RVALUE_WB_UNPROTECTED(obj) ? "false" : "true");
fprintf(stderr, "remembered? : %s\n", RVALUE_REMEMBERED(obj) ? "true" : "false");
if (is_lazy_sweeping(objspace)) {
fprintf(stderr, "lazy sweeping?: true\n");
- fprintf(stderr, "swept?: %s\n", is_swept_object(objspace, obj) ? "done" : "not yet");
+ fprintf(stderr, "swept?: %s\n", is_swept_object(obj) ? "done" : "not yet");
}
else {
fprintf(stderr, "lazy sweeping?: false\n");
@@ -14382,7 +14205,6 @@ rb_gcdebug_sentinel(VALUE obj, const char *name)
#endif /* GC_DEBUG */
-#if GC_DEBUG_STRESS_TO_CLASS
/*
* call-seq:
* GC.add_stress_to_class(class[, ...])
@@ -14396,7 +14218,7 @@ rb_gcdebug_add_stress_to_class(int argc, VALUE *argv, VALUE self)
rb_objspace_t *objspace = &rb_objspace;
if (!stress_to_class) {
- stress_to_class = rb_ary_hidden_new(argc);
+ set_stress_to_class(rb_ary_hidden_new(argc));
}
rb_ary_cat(stress_to_class, argv, argc);
return self;
@@ -14421,12 +14243,11 @@ rb_gcdebug_remove_stress_to_class(int argc, VALUE *argv, VALUE self)
rb_ary_delete_same(stress_to_class, argv[i]);
}
if (RARRAY_LEN(stress_to_class) == 0) {
- stress_to_class = 0;
+ set_stress_to_class(0);
}
}
return Qnil;
}
-#endif
/*
* Document-module: ObjectSpace
@@ -14456,16 +14277,6 @@ rb_gcdebug_remove_stress_to_class(int argc, VALUE *argv, VALUE self)
* Finalizer one on 537763480
*/
-/*
- * Document-class: ObjectSpace::WeakMap
- *
- * An ObjectSpace::WeakMap object holds references to
- * any objects, but those objects can get garbage collected.
- *
- * This class is mostly used internally by WeakRef, please use
- * +lib/weakref.rb+ for the public interface.
- */
-
/* Document-class: GC::Profiler
*
* The GC profiler provides access to information on GC runs including time,
@@ -14485,27 +14296,13 @@ rb_gcdebug_remove_stress_to_class(int argc, VALUE *argv, VALUE self)
*/
#include "gc.rbinc"
-/*
- * call-seq:
- * GC.using_rvargc? -> true or false
- *
- * Returns true if using experimental feature Variable Width Allocation, false
- * otherwise.
- */
-static VALUE
-gc_using_rvargc_p(VALUE mod)
-{
-#if USE_RVARGC
- return Qtrue;
-#else
- return Qfalse;
-#endif
-}
void
Init_GC(void)
{
#undef rb_intern
+ malloc_offset = gc_compute_malloc_offset();
+
VALUE rb_mObjSpace;
VALUE rb_mProfiler;
VALUE gc_constants;
@@ -14522,11 +14319,12 @@ Init_GC(void)
rb_hash_aset(gc_constants, ID2SYM(rb_intern("HEAP_PAGE_SIZE")), SIZET2NUM(HEAP_PAGE_SIZE));
rb_hash_aset(gc_constants, ID2SYM(rb_intern("SIZE_POOL_COUNT")), LONG2FIX(SIZE_POOL_COUNT));
rb_hash_aset(gc_constants, ID2SYM(rb_intern("RVARGC_MAX_ALLOCATE_SIZE")), LONG2FIX(size_pool_slot_size(SIZE_POOL_COUNT - 1)));
+ rb_hash_aset(gc_constants, ID2SYM(rb_intern("RVALUE_OLD_AGE")), LONG2FIX(RVALUE_OLD_AGE));
if (RB_BUG_INSTEAD_OF_RB_MEMERROR+0) {
rb_hash_aset(gc_constants, ID2SYM(rb_intern("RB_BUG_INSTEAD_OF_RB_MEMERROR")), Qtrue);
}
OBJ_FREEZE(gc_constants);
- /* internal constants */
+ /* Internal constants in the garbage collector. */
rb_define_const(rb_mGC, "INTERNAL_CONSTANTS", gc_constants);
rb_mProfiler = rb_define_module_under(rb_mGC, "Profiler");
@@ -14555,36 +14353,13 @@ Init_GC(void)
rb_define_module_function(rb_mObjSpace, "count_objects", count_objects, -1);
- {
- VALUE rb_cWeakMap = rb_define_class_under(rb_mObjSpace, "WeakMap", rb_cObject);
- rb_define_alloc_func(rb_cWeakMap, wmap_allocate);
- rb_define_method(rb_cWeakMap, "[]=", wmap_aset, 2);
- rb_define_method(rb_cWeakMap, "[]", wmap_aref, 1);
- rb_define_method(rb_cWeakMap, "include?", wmap_has_key, 1);
- rb_define_method(rb_cWeakMap, "member?", wmap_has_key, 1);
- rb_define_method(rb_cWeakMap, "key?", wmap_has_key, 1);
- rb_define_method(rb_cWeakMap, "inspect", wmap_inspect, 0);
- rb_define_method(rb_cWeakMap, "each", wmap_each, 0);
- rb_define_method(rb_cWeakMap, "each_pair", wmap_each, 0);
- rb_define_method(rb_cWeakMap, "each_key", wmap_each_key, 0);
- rb_define_method(rb_cWeakMap, "each_value", wmap_each_value, 0);
- rb_define_method(rb_cWeakMap, "keys", wmap_keys, 0);
- rb_define_method(rb_cWeakMap, "values", wmap_values, 0);
- rb_define_method(rb_cWeakMap, "size", wmap_size, 0);
- rb_define_method(rb_cWeakMap, "length", wmap_size, 0);
- rb_include_module(rb_cWeakMap, rb_mEnumerable);
- }
-
/* internal methods */
rb_define_singleton_method(rb_mGC, "verify_internal_consistency", gc_verify_internal_consistency_m, 0);
- rb_define_singleton_method(rb_mGC, "verify_transient_heap_internal_consistency", gc_verify_transient_heap_internal_consistency, 0);
#if MALLOC_ALLOCATED_SIZE
rb_define_singleton_method(rb_mGC, "malloc_allocated_size", gc_malloc_allocated_size, 0);
rb_define_singleton_method(rb_mGC, "malloc_allocations", gc_malloc_allocations, 0);
#endif
- rb_define_singleton_method(rb_mGC, "using_rvargc?", gc_using_rvargc_p, 0);
-
if (GC_COMPACTION_SUPPORTED) {
rb_define_singleton_method(rb_mGC, "compact", gc_compact, 0);
rb_define_singleton_method(rb_mGC, "auto_compact", gc_get_auto_compact, 0);
@@ -14600,10 +14375,10 @@ Init_GC(void)
rb_define_singleton_method(rb_mGC, "verify_compaction_references", rb_f_notimplement, -1);
}
-#if GC_DEBUG_STRESS_TO_CLASS
- rb_define_singleton_method(rb_mGC, "add_stress_to_class", rb_gcdebug_add_stress_to_class, -1);
- rb_define_singleton_method(rb_mGC, "remove_stress_to_class", rb_gcdebug_remove_stress_to_class, -1);
-#endif
+ if (GC_DEBUG_STRESS_TO_CLASS) {
+ rb_define_singleton_method(rb_mGC, "add_stress_to_class", rb_gcdebug_add_stress_to_class, -1);
+ rb_define_singleton_method(rb_mGC, "remove_stress_to_class", rb_gcdebug_remove_stress_to_class, -1);
+ }
{
VALUE opts;
diff --git a/gc.h b/gc.h
deleted file mode 100644
index 23218c1a9e..0000000000
--- a/gc.h
+++ /dev/null
@@ -1,147 +0,0 @@
-#ifndef RUBY_GC_H
-#define RUBY_GC_H 1
-#include "ruby/ruby.h"
-
-#if defined(__x86_64__) && !defined(_ILP32) && defined(__GNUC__)
-#define SET_MACHINE_STACK_END(p) __asm__ __volatile__ ("movq\t%%rsp, %0" : "=r" (*(p)))
-#elif defined(__i386) && defined(__GNUC__)
-#define SET_MACHINE_STACK_END(p) __asm__ __volatile__ ("movl\t%%esp, %0" : "=r" (*(p)))
-#elif (defined(__powerpc__) || defined(__powerpc64__)) && defined(__GNUC__) && !defined(_AIX) && !defined(__APPLE__) // Not Apple is NEEDED to unbreak ppc64 build on Darwin. Don't ask.
-#define SET_MACHINE_STACK_END(p) __asm__ __volatile__ ("mr\t%0, %%r1" : "=r" (*(p)))
-#elif (defined(__powerpc__) || defined(__powerpc64__)) && defined(__GNUC__) && defined(_AIX)
-#define SET_MACHINE_STACK_END(p) __asm__ __volatile__ ("mr %0,1" : "=r" (*(p)))
-#elif defined(__POWERPC__) && defined(__APPLE__) // Darwin ppc and ppc64
-#define SET_MACHINE_STACK_END(p) __asm__ volatile("mr %0, r1" : "=r" (*(p)))
-#elif defined(__aarch64__) && defined(__GNUC__)
-#define SET_MACHINE_STACK_END(p) __asm__ __volatile__ ("mov\t%0, sp" : "=r" (*(p)))
-#else
-NOINLINE(void rb_gc_set_stack_end(VALUE **stack_end_p));
-#define SET_MACHINE_STACK_END(p) rb_gc_set_stack_end(p)
-#define USE_CONSERVATIVE_STACK_END
-#endif
-
-#define RB_GC_SAVE_MACHINE_CONTEXT(th) \
- do { \
- FLUSH_REGISTER_WINDOWS; \
- setjmp((th)->ec->machine.regs); \
- SET_MACHINE_STACK_END(&(th)->ec->machine.stack_end); \
- } while (0)
-
-/* for GC debug */
-
-#ifndef RUBY_MARK_FREE_DEBUG
-#define RUBY_MARK_FREE_DEBUG 0
-#endif
-
-#if RUBY_MARK_FREE_DEBUG
-extern int ruby_gc_debug_indent;
-
-static inline void
-rb_gc_debug_indent(void)
-{
- ruby_debug_printf("%*s", ruby_gc_debug_indent, "");
-}
-
-static inline void
-rb_gc_debug_body(const char *mode, const char *msg, int st, void *ptr)
-{
- if (st == 0) {
- ruby_gc_debug_indent--;
- }
- rb_gc_debug_indent();
- ruby_debug_printf("%s: %s %s (%p)\n", mode, st ? "->" : "<-", msg, ptr);
-
- if (st) {
- ruby_gc_debug_indent++;
- }
-
- fflush(stdout);
-}
-
-#define RUBY_MARK_ENTER(msg) rb_gc_debug_body("mark", (msg), 1, ptr)
-#define RUBY_MARK_LEAVE(msg) rb_gc_debug_body("mark", (msg), 0, ptr)
-#define RUBY_FREE_ENTER(msg) rb_gc_debug_body("free", (msg), 1, ptr)
-#define RUBY_FREE_LEAVE(msg) rb_gc_debug_body("free", (msg), 0, ptr)
-#define RUBY_GC_INFO rb_gc_debug_indent(), ruby_debug_printf
-
-#else
-#define RUBY_MARK_ENTER(msg)
-#define RUBY_MARK_LEAVE(msg)
-#define RUBY_FREE_ENTER(msg)
-#define RUBY_FREE_LEAVE(msg)
-#define RUBY_GC_INFO if(0)printf
-#endif
-
-#define RUBY_MARK_MOVABLE_UNLESS_NULL(ptr) do { \
- VALUE markobj = (ptr); \
- if (RTEST(markobj)) {rb_gc_mark_movable(markobj);} \
-} while (0)
-#define RUBY_MARK_UNLESS_NULL(ptr) do { \
- VALUE markobj = (ptr); \
- if (RTEST(markobj)) {rb_gc_mark(markobj);} \
-} while (0)
-#define RUBY_FREE_UNLESS_NULL(ptr) if(ptr){ruby_xfree(ptr);(ptr)=NULL;}
-
-#if STACK_GROW_DIRECTION > 0
-# define STACK_UPPER(x, a, b) (a)
-#elif STACK_GROW_DIRECTION < 0
-# define STACK_UPPER(x, a, b) (b)
-#else
-RUBY_EXTERN int ruby_stack_grow_direction;
-int ruby_get_stack_grow_direction(volatile VALUE *addr);
-# define stack_growup_p(x) ( \
- (ruby_stack_grow_direction ? \
- ruby_stack_grow_direction : \
- ruby_get_stack_grow_direction(x)) > 0)
-# define STACK_UPPER(x, a, b) (stack_growup_p(x) ? (a) : (b))
-#endif
-
-/*
- STACK_GROW_DIR_DETECTION is used with STACK_DIR_UPPER.
-
- On most normal systems, stacks grow from high address to lower address. In
- this case, STACK_DIR_UPPER(a, b) will return (b), but on exotic systems where
- the stack grows UP (from low address to high address), it will return (a).
-*/
-
-#if STACK_GROW_DIRECTION
-#define STACK_GROW_DIR_DETECTION
-#define STACK_DIR_UPPER(a,b) STACK_UPPER(0, (a), (b))
-#else
-#define STACK_GROW_DIR_DETECTION VALUE stack_grow_dir_detection
-#define STACK_DIR_UPPER(a,b) STACK_UPPER(&stack_grow_dir_detection, (a), (b))
-#endif
-#define IS_STACK_DIR_UPPER() STACK_DIR_UPPER(1,0)
-
-const char *rb_obj_info(VALUE obj);
-const char *rb_raw_obj_info(char *const buff, const size_t buff_size, VALUE obj);
-
-struct rb_thread_struct;
-
-size_t rb_size_pool_slot_size(unsigned char pool_id);
-
-RUBY_SYMBOL_EXPORT_BEGIN
-
-/* exports for objspace module */
-size_t rb_objspace_data_type_memsize(VALUE obj);
-void rb_objspace_reachable_objects_from(VALUE obj, void (func)(VALUE, void *), void *data);
-void rb_objspace_reachable_objects_from_root(void (func)(const char *category, VALUE, void *), void *data);
-int rb_objspace_markable_object_p(VALUE obj);
-int rb_objspace_internal_object_p(VALUE obj);
-int rb_objspace_marked_object_p(VALUE obj);
-
-void rb_objspace_each_objects(
- int (*callback)(void *start, void *end, size_t stride, void *data),
- void *data);
-
-void rb_objspace_each_objects_without_setup(
- int (*callback)(void *, void *, size_t, void *),
- void *data);
-
-size_t rb_gc_obj_slot_size(VALUE obj);
-
-VALUE rb_gc_disable_no_rest(void);
-
-RUBY_SYMBOL_EXPORT_END
-
-#endif /* RUBY_GC_H */
diff --git a/gc.rb b/gc.rb
index 495f203487..c9c985b994 100644
--- a/gc.rb
+++ b/gc.rb
@@ -1,6 +1,6 @@
# for gc.c
-# The GC module provides an interface to Ruby's mark and
+# The \GC module provides an interface to Ruby's mark and
# sweep garbage collection mechanism.
#
# Some of the underlying methods are also available via the ObjectSpace
@@ -10,30 +10,36 @@
# GC::Profiler.
module GC
- # call-seq:
- # GC.start -> nil
- # ObjectSpace.garbage_collect -> nil
- # include GC; garbage_collect -> nil
- # GC.start(full_mark: true, immediate_sweep: true) -> nil
- # ObjectSpace.garbage_collect(full_mark: true, immediate_sweep: true) -> nil
- # include GC; garbage_collect(full_mark: true, immediate_sweep: true) -> nil
- #
- # Initiates garbage collection, even if manually disabled.
- #
- # This method is defined with keyword arguments that default to true:
- #
- # def GC.start(full_mark: true, immediate_sweep: true); end
- #
- # Use full_mark: false to perform a minor \GC.
- # Use immediate_sweep: false to defer sweeping (use lazy sweep).
- #
- # Note: These keyword arguments are implementation and version dependent. They
- # are not guaranteed to be future-compatible, and may be ignored if the
- # underlying implementation does not support them.
+ # Initiates garbage collection, even if manually disabled.
+ #
+ # The +full_mark+ keyword argument determines whether or not to perform a
+ # major garbage collection cycle. When set to +true+, a major garbage
+ # collection cycle is ran, meaning all objects are marked. When set to
+ # +false+, a minor garbage collection cycle is ran, meaning only young
+ # objects are marked.
+ #
+ # The +immediate_mark+ keyword argument determines whether or not to perform
+ # incremental marking. When set to +true+, marking is completed during the
+ # call to this method. When set to +false+, marking is performed in steps
+ # that is interleaved with future Ruby code execution, so marking might not
+ # be completed during this method call. Note that if +full_mark+ is +false+
+ # then marking will always be immediate, regardless of the value of
+ # +immediate_mark+.
+ #
+ # The +immedate_sweep+ keyword argument determines whether or not to defer
+ # sweeping (using lazy sweep). When set to +true+, sweeping is performed in
+ # steps that is interleaved with future Ruby code execution, so sweeping might
+ # not be completed during this method call. When set to +false+, sweeping is
+ # completed during the call to this method.
+ #
+ # Note: These keyword arguments are implementation and version dependent. They
+ # are not guaranteed to be future-compatible, and may be ignored if the
+ # underlying implementation does not support them.
def self.start full_mark: true, immediate_mark: true, immediate_sweep: true
Primitive.gc_start_internal full_mark, immediate_mark, immediate_sweep, false
end
+ # Alias of GC.start
def garbage_collect full_mark: true, immediate_mark: true, immediate_sweep: true
Primitive.gc_start_internal full_mark, immediate_mark, immediate_sweep, false
end
@@ -191,19 +197,18 @@ module GC
# GC.stat_heap(heap_name, hash) -> Hash
# GC.stat_heap(heap_name, :key) -> Numeric
#
- # Returns information for memory pools in the \GC.
+ # Returns information for heaps in the \GC.
#
# If the first optional argument, +heap_name+, is passed in and not +nil+, it
- # returns a +Hash+ containing information about the particular memory pool.
- # Otherwise, it will return a +Hash+ with memory pool names as keys and
- # a +Hash+ containing information about the memory pool as values.
+ # returns a +Hash+ containing information about the particular heap.
+ # Otherwise, it will return a +Hash+ with heap names as keys and
+ # a +Hash+ containing information about the heap as values.
#
# If the second optional argument, +hash_or_key+, is given as +Hash+, it will
# be overwritten and returned. This is intended to avoid the probe effect.
#
# If both optional arguments are passed in and the second optional argument is
- # a symbol, it will return a +Numeric+ of the value for the particular memory
- # pool.
+ # a symbol, it will return a +Numeric+ of the value for the particular heap.
#
# On CRuby, +heap_name+ is of the type +Integer+ but may be of type +String+
# on other implementations.
@@ -214,6 +219,36 @@ module GC
# If the optional argument, hash, is given, it is overwritten and returned.
#
# This method is only expected to work on CRuby.
+ #
+ # The hash includes the following keys about the internal information in
+ # the \GC:
+ #
+ # [slot_size]
+ # The slot size of the heap in bytes.
+ # [heap_allocatable_pages]
+ # The number of pages that can be allocated without triggering a new
+ # garbage collection cycle.
+ # [heap_eden_pages]
+ # The number of pages in the eden heap.
+ # [heap_eden_slots]
+ # The total number of slots in all of the pages in the eden heap.
+ # [heap_tomb_pages]
+ # The number of pages in the tomb heap. The tomb heap only contains pages
+ # that do not have any live objects.
+ # [heap_tomb_slots]
+ # The total number of slots in all of the pages in the tomb heap.
+ # [total_allocated_pages]
+ # The total number of pages that have been allocated in the heap.
+ # [total_freed_pages]
+ # The total number of pages that have been freed and released back to the
+ # system in the heap.
+ # [force_major_gc_count]
+ # The number of times major garbage collection cycles this heap has forced
+ # to start due to running out of free slots.
+ # [force_incremental_marking_finish_count]
+ # The number of times this heap has forced incremental marking to complete
+ # due to running out of pooled slots.
+ #
def self.stat_heap heap_name = nil, hash_or_key = nil
Primitive.gc_stat_heap heap_name, hash_or_key
end
@@ -282,12 +317,13 @@ module GC
# Return measured \GC total time in nano seconds.
def self.total_time
Primitive.cexpr! %{
- ULL2NUM(rb_objspace.profile.total_time_ns)
+ ULL2NUM(rb_objspace.profile.marking_time_ns + rb_objspace.profile.sweeping_time_ns)
}
end
end
module ObjectSpace
+ # Alias of GC.start
def garbage_collect full_mark: true, immediate_mark: true, immediate_sweep: true
Primitive.gc_start_internal full_mark, immediate_mark, immediate_sweep, false
end
diff --git a/gem_prelude.rb b/gem_prelude.rb
index f382021ca3..bcd2560fab 100644
--- a/gem_prelude.rb
+++ b/gem_prelude.rb
@@ -4,6 +4,8 @@ rescue LoadError => e
raise unless e.path == 'rubygems'
warn "`RubyGems' were not loaded."
+else
+ require 'bundled_gems'
end if defined?(Gem)
begin
diff --git a/gems/bundled_gems b/gems/bundled_gems
index a754e89cd2..ae0a1acc3d 100644
--- a/gems/bundled_gems
+++ b/gems/bundled_gems
@@ -5,18 +5,19 @@
# - repository-url: URL from where clone for test
# - revision: revision in repository-url to test
# if `revision` is not given, "v"+`version` or `version` will be used.
-minitest 5.17.0 https://github.com/seattlerb/minitest
+minitest 5.20.0 https://github.com/minitest/minitest
power_assert 2.0.3 https://github.com/ruby/power_assert
-rake 13.0.6 https://github.com/ruby/rake
-test-unit 3.5.7 https://github.com/test-unit/test-unit
-rexml 3.2.5 https://github.com/ruby/rexml
-rss 0.2.9 https://github.com/ruby/rss
-net-ftp 0.2.0 https://github.com/ruby/net-ftp
-net-imap 0.3.4 https://github.com/ruby/net-imap
+rake 13.1.0 https://github.com/ruby/rake
+test-unit 3.6.1 https://github.com/test-unit/test-unit
+rexml 3.2.6 https://github.com/ruby/rexml
+rss 0.3.0 https://github.com/ruby/rss
+net-ftp 0.3.4 https://github.com/ruby/net-ftp
+net-imap 0.4.9.1 https://github.com/ruby/net-imap
net-pop 0.1.2 https://github.com/ruby/net-pop
-net-smtp 0.3.3 https://github.com/ruby/net-smtp
+net-smtp 0.4.0.1 https://github.com/ruby/net-smtp
matrix 0.4.2 https://github.com/ruby/matrix
prime 0.1.2 https://github.com/ruby/prime
-rbs 2.8.4 https://github.com/ruby/rbs
-typeprof 0.21.4 https://github.com/ruby/typeprof
-debug 1.7.1 https://github.com/ruby/debug
+rbs 3.4.0 https://github.com/ruby/rbs
+typeprof 0.21.9 https://github.com/ruby/typeprof
+debug 1.9.1 https://github.com/ruby/debug
+racc 1.7.3 https://github.com/ruby/racc
diff --git a/gems/lib/core_assertions.rb b/gems/lib/core_assertions.rb
new file mode 100644
index 0000000000..7334063885
--- /dev/null
+++ b/gems/lib/core_assertions.rb
@@ -0,0 +1 @@
+require_relative "../../tool/lib/core_assertions.rb"
diff --git a/gems/lib/rake/extensiontask.rb b/gems/lib/rake/extensiontask.rb
new file mode 100644
index 0000000000..aa668935fc
--- /dev/null
+++ b/gems/lib/rake/extensiontask.rb
@@ -0,0 +1,10 @@
+module Rake
+ class ExtensionTask < TaskLib
+ def initialize(...)
+ task :compile do |args|
+ puts "Dummy `compile` task defined in #{__FILE__}"
+ puts "#{args.name} => #{args.prereqs.join(' ')}"
+ end
+ end
+ end
+end
diff --git a/hash.c b/hash.c
index ac41e08cc8..b15d856ee1 100644
--- a/hash.c
+++ b/hash.c
@@ -44,17 +44,33 @@
#include "ruby/util.h"
#include "ruby_assert.h"
#include "symbol.h"
-#include "transient_heap.h"
#include "ruby/thread_native.h"
#include "ruby/ractor.h"
#include "vm_sync.h"
+/* Flags of RHash
+ *
+ * 1: RHASH_PASS_AS_KEYWORDS
+ * The hash is flagged as Ruby 2 keywords hash.
+ * 2: RHASH_PROC_DEFAULT
+ * The hash has a default proc (rather than a default value).
+ * 3: RHASH_ST_TABLE_FLAG
+ * The hash uses a ST table (rather than an AR table).
+ * 4-7: RHASH_AR_TABLE_SIZE_MASK
+ * The size of the AR table.
+ * 8-11: RHASH_AR_TABLE_BOUND_MASK
+ * The bounds of the AR table.
+ * 13-19: RHASH_LEV_MASK
+ * The iterational level of the hash. Used to prevent modifications
+ * to the hash during interation.
+ */
+
#ifndef HASH_DEBUG
#define HASH_DEBUG 0
#endif
#if HASH_DEBUG
-#include "gc.h"
+#include "internal/gc.h"
#endif
#define SET_DEFAULT(hash, ifnone) ( \
@@ -106,7 +122,7 @@ rb_hash_set_ifnone(VALUE hash, VALUE ifnone)
return hash;
}
-static int
+int
rb_any_cmp(VALUE a, VALUE b)
{
if (a == b) return 0;
@@ -221,7 +237,7 @@ obj_any_hash(VALUE obj)
return FIX2LONG(hval);
}
-static st_index_t
+st_index_t
rb_any_hash(VALUE a)
{
return any_hash(a, obj_any_hash);
@@ -365,12 +381,10 @@ typedef st_index_t st_hash_t;
/*
* RHASH_AR_TABLE_P(h):
- * * as.ar == NULL or
- * as.ar points ar_table.
- * * as.ar is allocated by transient heap or xmalloc.
+ * RHASH_AR_TABLE points to ar_table.
*
* !RHASH_AR_TABLE_P(h):
- * * as.st points st_table.
+ * RHASH_ST_TABLE points st_table.
*/
#define RHASH_AR_TABLE_MAX_BOUND RHASH_AR_TABLE_MAX_SIZE
@@ -378,22 +392,6 @@ typedef st_index_t st_hash_t;
#define RHASH_AR_TABLE_REF(hash, n) (&RHASH_AR_TABLE(hash)->pairs[n])
#define RHASH_AR_CLEARED_HINT 0xff
-typedef struct ar_table_pair_struct {
- VALUE key;
- VALUE val;
-} ar_table_pair;
-
-typedef struct ar_table_struct {
- /* 64bit CPU: 8B * 2 * 8 = 128B */
- ar_table_pair pairs[RHASH_AR_TABLE_MAX_SIZE];
-} ar_table;
-
-size_t
-rb_hash_ar_table_size(void)
-{
- return sizeof(ar_table);
-}
-
static inline st_hash_t
ar_do_hash(st_data_t key)
{
@@ -409,13 +407,13 @@ ar_do_hash_hint(st_hash_t hash_value)
static inline ar_hint_t
ar_hint(VALUE hash, unsigned int index)
{
- return RHASH(hash)->ar_hint.ary[index];
+ return RHASH_AR_TABLE(hash)->ar_hint.ary[index];
}
static inline void
ar_hint_set_hint(VALUE hash, unsigned int index, ar_hint_t hint)
{
- RHASH(hash)->ar_hint.ary[index] = hint;
+ RHASH_AR_TABLE(hash)->ar_hint.ary[index] = hint;
}
static inline void
@@ -463,14 +461,20 @@ ar_set_entry(VALUE hash, unsigned int index, st_data_t key, st_data_t val, st_ha
((unsigned int)((RBASIC(h)->flags >> RHASH_AR_TABLE_BOUND_SHIFT) & \
(RHASH_AR_TABLE_BOUND_MASK >> RHASH_AR_TABLE_BOUND_SHIFT)))
-#define RHASH_AR_TABLE_BOUND(h) (HASH_ASSERT(RHASH_AR_TABLE_P(h)), \
- RHASH_AR_TABLE_BOUND_RAW(h))
-
#define RHASH_ST_TABLE_SET(h, s) rb_hash_st_table_set(h, s)
#define RHASH_TYPE(hash) (RHASH_AR_TABLE_P(hash) ? &objhash : RHASH_ST_TABLE(hash)->type)
#define HASH_ASSERT(expr) RUBY_ASSERT_MESG_WHEN(HASH_DEBUG, expr, #expr)
+static inline unsigned int
+RHASH_AR_TABLE_BOUND(VALUE h)
+{
+ HASH_ASSERT(RHASH_AR_TABLE_P(h));
+ const unsigned int bound = RHASH_AR_TABLE_BOUND_RAW(h);
+ HASH_ASSERT(bound <= RHASH_AR_TABLE_MAX_SIZE);
+ return bound;
+}
+
#if HASH_DEBUG
#define hash_verify(hash) hash_verify_(hash, __FILE__, __LINE__)
@@ -480,10 +484,10 @@ rb_hash_dump(VALUE hash)
rb_obj_info_dump(hash);
if (RHASH_AR_TABLE_P(hash)) {
- unsigned i, n = 0, bound = RHASH_AR_TABLE_BOUND(hash);
+ unsigned i, bound = RHASH_AR_TABLE_BOUND(hash);
fprintf(stderr, " size:%u bound:%u\n",
- RHASH_AR_TABLE_SIZE(hash), RHASH_AR_TABLE_BOUND(hash));
+ RHASH_AR_TABLE_SIZE(hash), bound);
for (i=0; i<bound; i++) {
st_data_t k, v;
@@ -497,7 +501,6 @@ rb_hash_dump(VALUE hash)
rb_raw_obj_info(b1, 0x100, k),
rb_raw_obj_info(b2, 0x100, v),
ar_hint(hash, i));
- n++;
}
else {
fprintf(stderr, " %d empty\n", i);
@@ -535,13 +538,6 @@ hash_verify_(VALUE hash, const char *file, int line)
HASH_ASSERT(RHASH_AR_TABLE_BOUND_RAW(hash) == 0);
}
-#if USE_TRANSIENT_HEAP
- if (RHASH_TRANSIENT_P(hash)) {
- volatile st_data_t MAYBE_UNUSED(key) = RHASH_AR_TABLE_REF(hash, 0)->key; /* read */
- HASH_ASSERT(RHASH_AR_TABLE(hash) != NULL);
- HASH_ASSERT(rb_transient_heap_managed_ptr_p(RHASH_AR_TABLE(hash)));
- }
-#endif
return hash;
}
@@ -550,43 +546,30 @@ hash_verify_(VALUE hash, const char *file, int line)
#endif
static inline int
-RHASH_TABLE_NULL_P(VALUE hash)
+RHASH_TABLE_EMPTY_P(VALUE hash)
{
- if (RHASH(hash)->as.ar == NULL) {
- HASH_ASSERT(RHASH_AR_TABLE_P(hash));
- return TRUE;
- }
- else {
- return FALSE;
- }
+ return RHASH_SIZE(hash) == 0;
}
-static inline int
-RHASH_TABLE_EMPTY_P(VALUE hash)
+#define RHASH_SET_ST_FLAG(h) FL_SET_RAW(h, RHASH_ST_TABLE_FLAG)
+#define RHASH_UNSET_ST_FLAG(h) FL_UNSET_RAW(h, RHASH_ST_TABLE_FLAG)
+
+static void
+hash_st_table_init(VALUE hash, const struct st_hash_type *type, st_index_t size)
{
- return RHASH_SIZE(hash) == 0;
+ st_init_existing_table_with_size(RHASH_ST_TABLE(hash), type, size);
+ RHASH_SET_ST_FLAG(hash);
}
void
rb_hash_st_table_set(VALUE hash, st_table *st)
{
HASH_ASSERT(st != NULL);
- FL_SET_RAW((hash), RHASH_ST_TABLE_FLAG);
- RHASH(hash)->as.st = st;
-}
+ RHASH_SET_ST_FLAG(hash);
-static void
-hash_ar_table_set(VALUE hash, ar_table *ar)
-{
- HASH_ASSERT(RHASH_AR_TABLE_P(hash));
- HASH_ASSERT((RHASH_TRANSIENT_P(hash) && ar == NULL) ? FALSE : TRUE);
- RHASH(hash)->as.ar = ar;
- hash_verify(hash);
+ *RHASH_ST_TABLE(hash) = *st;
}
-#define RHASH_SET_ST_FLAG(h) FL_SET_RAW(h, RHASH_ST_TABLE_FLAG)
-#define RHASH_UNSET_ST_FLAG(h) FL_UNSET_RAW(h, RHASH_ST_TABLE_FLAG)
-
static inline void
RHASH_AR_TABLE_BOUND_SET(VALUE h, st_index_t n)
{
@@ -641,27 +624,7 @@ RHASH_AR_TABLE_CLEAR(VALUE h)
RBASIC(h)->flags &= ~RHASH_AR_TABLE_SIZE_MASK;
RBASIC(h)->flags &= ~RHASH_AR_TABLE_BOUND_MASK;
- hash_ar_table_set(h, NULL);
-}
-
-static ar_table*
-ar_alloc_table(VALUE hash)
-{
- ar_table *tab = (ar_table*)rb_transient_heap_alloc(hash, sizeof(ar_table));
-
- if (tab != NULL) {
- RHASH_SET_TRANSIENT_FLAG(hash);
- }
- else {
- RHASH_UNSET_TRANSIENT_FLAG(hash);
- tab = (ar_table*)ruby_xmalloc(sizeof(ar_table));
- }
-
- RHASH_AR_TABLE_SIZE_SET(hash, 0);
- RHASH_AR_TABLE_BOUND_SET(hash, 0);
- hash_ar_table_set(hash, tab);
-
- return tab;
+ memset(RHASH_AR_TABLE(h), 0, sizeof(ar_table));
}
NOINLINE(static int ar_equal(VALUE x, VALUE y));
@@ -676,7 +639,7 @@ static unsigned
ar_find_entry_hint(VALUE hash, ar_hint_t hint, st_data_t key)
{
unsigned i, bound = RHASH_AR_TABLE_BOUND(hash);
- const ar_hint_t *hints = RHASH(hash)->ar_hint.ary;
+ const ar_hint_t *hints = RHASH_AR_TABLE(hash)->ar_hint.ary;
/* if table is NULL, then bound also should be 0 */
@@ -723,92 +686,83 @@ ar_find_entry(VALUE hash, st_hash_t hash_value, st_data_t key)
}
static inline void
-ar_free_and_clear_table(VALUE hash)
+hash_ar_free_and_clear_table(VALUE hash)
{
- ar_table *tab = RHASH_AR_TABLE(hash);
+ RHASH_AR_TABLE_CLEAR(hash);
- if (tab) {
- if (RHASH_TRANSIENT_P(hash)) {
- RHASH_UNSET_TRANSIENT_FLAG(hash);
- }
- else {
- ruby_xfree(RHASH_AR_TABLE(hash));
- }
- RHASH_AR_TABLE_CLEAR(hash);
- }
HASH_ASSERT(RHASH_AR_TABLE_SIZE(hash) == 0);
HASH_ASSERT(RHASH_AR_TABLE_BOUND(hash) == 0);
- HASH_ASSERT(RHASH_TRANSIENT_P(hash) == 0);
}
-static void
-ar_try_convert_table(VALUE hash)
-{
- if (!RHASH_AR_TABLE_P(hash)) return;
-
- const unsigned size = RHASH_AR_TABLE_SIZE(hash);
+void rb_st_add_direct_with_hash(st_table *tab, st_data_t key, st_data_t value, st_hash_t hash); // st.c
- st_table *new_tab;
- st_index_t i;
+enum ar_each_key_type {
+ ar_each_key_copy,
+ ar_each_key_cmp,
+ ar_each_key_insert,
+};
- if (size < RHASH_AR_TABLE_MAX_SIZE) {
- return;
+static inline int
+ar_each_key(ar_table *ar, int max, enum ar_each_key_type type, st_data_t *dst_keys, st_table *new_tab, st_hash_t *hashes)
+{
+ for (int i = 0; i < max; i++) {
+ ar_table_pair *pair = &ar->pairs[i];
+
+ switch (type) {
+ case ar_each_key_copy:
+ dst_keys[i] = pair->key;
+ break;
+ case ar_each_key_cmp:
+ if (dst_keys[i] != pair->key) return 1;
+ break;
+ case ar_each_key_insert:
+ if (UNDEF_P(pair->key)) continue; // deleted entry
+ rb_st_add_direct_with_hash(new_tab, pair->key, pair->val, hashes[i]);
+ break;
+ }
}
- new_tab = st_init_table_with_size(&objhash, size * 2);
-
- for (i = 0; i < RHASH_AR_TABLE_MAX_BOUND; i++) {
- ar_table_pair *pair = RHASH_AR_TABLE_REF(hash, i);
- st_add_direct(new_tab, pair->key, pair->val);
- }
- ar_free_and_clear_table(hash);
- RHASH_ST_TABLE_SET(hash, new_tab);
- return;
+ return 0;
}
static st_table *
ar_force_convert_table(VALUE hash, const char *file, int line)
{
- st_table *new_tab;
-
if (RHASH_ST_TABLE_P(hash)) {
return RHASH_ST_TABLE(hash);
}
-
- if (RHASH_AR_TABLE(hash)) {
- unsigned i, bound = RHASH_AR_TABLE_BOUND(hash);
-
-#if defined(RHASH_CONVERT_TABLE_DEBUG) && RHASH_CONVERT_TABLE_DEBUG
- rb_obj_info_dump(hash);
- fprintf(stderr, "force_convert: %s:%d\n", file, line);
- RB_DEBUG_COUNTER_INC(obj_hash_force_convert);
-#endif
-
- new_tab = st_init_table_with_size(&objhash, RHASH_AR_TABLE_SIZE(hash));
-
- for (i = 0; i < bound; i++) {
- if (ar_cleared_entry(hash, i)) continue;
-
- ar_table_pair *pair = RHASH_AR_TABLE_REF(hash, i);
- st_add_direct(new_tab, pair->key, pair->val);
- }
- ar_free_and_clear_table(hash);
- }
else {
- new_tab = st_init_table(&objhash);
- }
- RHASH_ST_TABLE_SET(hash, new_tab);
-
- return new_tab;
-}
+ ar_table *ar = RHASH_AR_TABLE(hash);
+ st_hash_t hashes[RHASH_AR_TABLE_MAX_SIZE];
+ unsigned int bound, size;
+
+ // prepare hash values
+ do {
+ st_data_t keys[RHASH_AR_TABLE_MAX_SIZE];
+ bound = RHASH_AR_TABLE_BOUND(hash);
+ size = RHASH_AR_TABLE_SIZE(hash);
+ ar_each_key(ar, bound, ar_each_key_copy, keys, NULL, NULL);
+
+ for (unsigned int i = 0; i < bound; i++) {
+ // do_hash calls #hash method and it can modify hash object
+ hashes[i] = UNDEF_P(keys[i]) ? 0 : ar_do_hash(keys[i]);
+ }
-static ar_table *
-hash_ar_table(VALUE hash)
-{
- if (RHASH_TABLE_NULL_P(hash)) {
- ar_alloc_table(hash);
+ // check if modified
+ if (UNLIKELY(!RHASH_AR_TABLE_P(hash))) return RHASH_ST_TABLE(hash);
+ if (UNLIKELY(RHASH_AR_TABLE_BOUND(hash) != bound)) continue;
+ if (UNLIKELY(ar_each_key(ar, bound, ar_each_key_cmp, keys, NULL, NULL))) continue;
+ } while (0);
+
+ // make st
+ st_table tab;
+ st_table *new_tab = &tab;
+ rb_st_init_existing_table_with_size(new_tab, &objhash, size);
+ ar_each_key(ar, bound, ar_each_key_insert, NULL, new_tab, hashes);
+ hash_ar_free_and_clear_table(hash);
+ RHASH_ST_TABLE_SET(hash, new_tab);
+ return RHASH_ST_TABLE(hash);
}
- return RHASH_AR_TABLE(hash);
}
static int
@@ -861,7 +815,6 @@ ar_add_direct_with_hash(VALUE hash, st_data_t key, st_data_t val, st_hash_t hash
else {
if (UNLIKELY(bin >= RHASH_AR_TABLE_MAX_BOUND)) {
bin = ar_compact_table(hash);
- hash_ar_table(hash);
}
HASH_ASSERT(bin < RHASH_AR_TABLE_MAX_BOUND);
@@ -872,6 +825,14 @@ ar_add_direct_with_hash(VALUE hash, st_data_t key, st_data_t val, st_hash_t hash
}
}
+static void
+ensure_ar_table(VALUE hash)
+{
+ if (!RHASH_AR_TABLE_P(hash)) {
+ rb_raise(rb_eRuntimeError, "hash representation was changed during iteration");
+ }
+}
+
static int
ar_general_foreach(VALUE hash, st_foreach_check_callback_func *func, st_update_callback_func *replace, st_data_t arg)
{
@@ -883,6 +844,7 @@ ar_general_foreach(VALUE hash, st_foreach_check_callback_func *func, st_update_c
ar_table_pair *pair = RHASH_AR_TABLE_REF(hash, i);
enum st_retval retval = (*func)(pair->key, pair->val, arg, 0);
+ ensure_ar_table(hash);
/* pair may be not valid here because of theap */
switch (retval) {
@@ -957,6 +919,7 @@ ar_foreach_check(VALUE hash, st_foreach_check_callback_func *func, st_data_t arg
hint = ar_hint(hash, i);
retval = (*func)(key, pair->val, arg, 0);
+ ensure_ar_table(hash);
hash_verify(hash);
switch (retval) {
@@ -1006,7 +969,6 @@ ar_update(VALUE hash, st_data_t key,
existing = (bin != RHASH_AR_TABLE_MAX_BOUND) ? TRUE : FALSE;
}
else {
- hash_ar_table(hash); /* allocate ltbl if needed */
existing = FALSE;
}
@@ -1018,6 +980,7 @@ ar_update(VALUE hash, st_data_t key,
old_key = key;
retval = (*func)(&key, &value, arg, existing);
/* pair can be invalid here because of theap */
+ ensure_ar_table(hash);
switch (retval) {
case ST_CONTINUE:
@@ -1055,8 +1018,6 @@ ar_insert(VALUE hash, st_data_t key, st_data_t value)
return -1;
}
- hash_ar_table(hash); /* prepare ltbl */
-
bin = ar_find_entry(hash, hash_value, key);
if (bin == RHASH_AR_TABLE_MAX_BOUND) {
if (RHASH_AR_TABLE_SIZE(hash) >= RHASH_AR_TABLE_MAX_SIZE) {
@@ -1064,7 +1025,6 @@ ar_insert(VALUE hash, st_data_t key, st_data_t value)
}
else if (bin >= RHASH_AR_TABLE_MAX_BOUND) {
bin = ar_compact_table(hash);
- hash_ar_table(hash);
}
HASH_ASSERT(bin < RHASH_AR_TABLE_MAX_BOUND);
@@ -1199,44 +1159,16 @@ static ar_table*
ar_copy(VALUE hash1, VALUE hash2)
{
ar_table *old_tab = RHASH_AR_TABLE(hash2);
+ ar_table *new_tab = RHASH_AR_TABLE(hash1);
- if (old_tab != NULL) {
- ar_table *new_tab = RHASH_AR_TABLE(hash1);
- if (new_tab == NULL) {
- new_tab = (ar_table*) rb_transient_heap_alloc(hash1, sizeof(ar_table));
- if (new_tab != NULL) {
- RHASH_SET_TRANSIENT_FLAG(hash1);
- }
- else {
- RHASH_UNSET_TRANSIENT_FLAG(hash1);
- new_tab = (ar_table*)ruby_xmalloc(sizeof(ar_table));
- }
- }
- *new_tab = *old_tab;
- RHASH(hash1)->ar_hint.word = RHASH(hash2)->ar_hint.word;
- RHASH_AR_TABLE_BOUND_SET(hash1, RHASH_AR_TABLE_BOUND(hash2));
- RHASH_AR_TABLE_SIZE_SET(hash1, RHASH_AR_TABLE_SIZE(hash2));
- hash_ar_table_set(hash1, new_tab);
+ *new_tab = *old_tab;
+ RHASH_AR_TABLE(hash1)->ar_hint.word = RHASH_AR_TABLE(hash2)->ar_hint.word;
+ RHASH_AR_TABLE_BOUND_SET(hash1, RHASH_AR_TABLE_BOUND(hash2));
+ RHASH_AR_TABLE_SIZE_SET(hash1, RHASH_AR_TABLE_SIZE(hash2));
- rb_gc_writebarrier_remember(hash1);
- return new_tab;
- }
- else {
- RHASH_AR_TABLE_BOUND_SET(hash1, RHASH_AR_TABLE_BOUND(hash2));
- RHASH_AR_TABLE_SIZE_SET(hash1, RHASH_AR_TABLE_SIZE(hash2));
-
- if (RHASH_TRANSIENT_P(hash1)) {
- RHASH_UNSET_TRANSIENT_FLAG(hash1);
- }
- else if (RHASH_AR_TABLE(hash1)) {
- ruby_xfree(RHASH_AR_TABLE(hash1));
- }
-
- hash_ar_table_set(hash1, NULL);
+ rb_gc_writebarrier_remember(hash1);
- rb_gc_writebarrier_remember(hash1);
- return old_tab;
- }
+ return new_tab;
}
static void
@@ -1252,32 +1184,32 @@ ar_clear(VALUE hash)
}
}
-#if USE_TRANSIENT_HEAP
-void
-rb_hash_transient_heap_evacuate(VALUE hash, int promote)
+static void
+hash_st_free(VALUE hash)
{
- if (RHASH_TRANSIENT_P(hash)) {
- ar_table *new_tab;
- ar_table *old_tab = RHASH_AR_TABLE(hash);
+ HASH_ASSERT(RHASH_ST_TABLE_P(hash));
- if (UNLIKELY(old_tab == NULL)) {
- return;
- }
- HASH_ASSERT(old_tab != NULL);
- if (! promote) {
- new_tab = rb_transient_heap_alloc(hash, sizeof(ar_table));
- if (new_tab == NULL) promote = true;
- }
- if (promote) {
- new_tab = ruby_xmalloc(sizeof(ar_table));
- RHASH_UNSET_TRANSIENT_FLAG(hash);
- }
- *new_tab = *old_tab;
- hash_ar_table_set(hash, new_tab);
+ st_table *tab = RHASH_ST_TABLE(hash);
+
+ xfree(tab->bins);
+ xfree(tab->entries);
+}
+
+static void
+hash_st_free_and_clear_table(VALUE hash)
+{
+ hash_st_free(hash);
+
+ RHASH_ST_CLEAR(hash);
+}
+
+void
+rb_hash_free(VALUE hash)
+{
+ if (RHASH_ST_TABLE_P(hash)) {
+ hash_st_free(hash);
}
- hash_verify(hash);
}
-#endif
typedef int st_foreach_func(st_data_t, st_data_t, st_data_t);
@@ -1367,72 +1299,79 @@ hash_foreach_iter(st_data_t key, st_data_t value, st_data_t argp, int error)
return hash_iter_status_check(status);
}
-static int
+static unsigned long
iter_lev_in_ivar(VALUE hash)
{
VALUE levval = rb_ivar_get(hash, id_hash_iter_lev);
HASH_ASSERT(FIXNUM_P(levval));
- return FIX2INT(levval);
+ long lev = FIX2LONG(levval);
+ HASH_ASSERT(lev >= 0);
+ return (unsigned long)lev;
}
void rb_ivar_set_internal(VALUE obj, ID id, VALUE val);
static void
-iter_lev_in_ivar_set(VALUE hash, int lev)
+iter_lev_in_ivar_set(VALUE hash, unsigned long lev)
{
- rb_ivar_set_internal(hash, id_hash_iter_lev, INT2FIX(lev));
+ HASH_ASSERT(lev >= RHASH_LEV_MAX);
+ HASH_ASSERT(POSFIXABLE(lev)); /* POSFIXABLE means fitting to long */
+ rb_ivar_set_internal(hash, id_hash_iter_lev, LONG2FIX((long)lev));
}
-static int
+static inline unsigned long
iter_lev_in_flags(VALUE hash)
{
- unsigned int u = (unsigned int)((RBASIC(hash)->flags >> RHASH_LEV_SHIFT) & RHASH_LEV_MAX);
- return (int)u;
+ return (unsigned long)((RBASIC(hash)->flags >> RHASH_LEV_SHIFT) & RHASH_LEV_MAX);
}
-static int
-RHASH_ITER_LEV(VALUE hash)
+static inline void
+iter_lev_in_flags_set(VALUE hash, unsigned long lev)
{
- int lev = iter_lev_in_flags(hash);
+ HASH_ASSERT(lev <= RHASH_LEV_MAX);
+ RBASIC(hash)->flags = ((RBASIC(hash)->flags & ~RHASH_LEV_MASK) | ((VALUE)lev << RHASH_LEV_SHIFT));
+}
- if (lev == RHASH_LEV_MAX) {
- return iter_lev_in_ivar(hash);
- }
- else {
- return lev;
- }
+static inline bool
+hash_iterating_p(VALUE hash)
+{
+ return iter_lev_in_flags(hash) > 0;
}
static void
hash_iter_lev_inc(VALUE hash)
{
- int lev = iter_lev_in_flags(hash);
+ unsigned long lev = iter_lev_in_flags(hash);
if (lev == RHASH_LEV_MAX) {
- lev = iter_lev_in_ivar(hash);
- iter_lev_in_ivar_set(hash, lev+1);
+ lev = iter_lev_in_ivar(hash) + 1;
+ if (!POSFIXABLE(lev)) { /* paranoiac check */
+ rb_raise(rb_eRuntimeError, "too much nested iterations");
+ }
}
else {
lev += 1;
- RBASIC(hash)->flags = ((RBASIC(hash)->flags & ~RHASH_LEV_MASK) | ((VALUE)lev << RHASH_LEV_SHIFT));
- if (lev == RHASH_LEV_MAX) {
- iter_lev_in_ivar_set(hash, lev);
- }
+ iter_lev_in_flags_set(hash, lev);
+ if (lev < RHASH_LEV_MAX) return;
}
+ iter_lev_in_ivar_set(hash, lev);
}
static void
hash_iter_lev_dec(VALUE hash)
{
- int lev = iter_lev_in_flags(hash);
+ unsigned long lev = iter_lev_in_flags(hash);
if (lev == RHASH_LEV_MAX) {
lev = iter_lev_in_ivar(hash);
- HASH_ASSERT(lev > 0);
- iter_lev_in_ivar_set(hash, lev-1);
+ if (lev > RHASH_LEV_MAX) {
+ iter_lev_in_ivar_set(hash, lev-1);
+ return;
+ }
+ rb_attr_delete(hash, id_hash_iter_lev);
}
- else {
- HASH_ASSERT(lev > 0);
- RBASIC(hash)->flags = ((RBASIC(hash)->flags & ~RHASH_LEV_MASK) | ((lev-1) << RHASH_LEV_SHIFT));
+ else if (lev == 0) {
+ rb_raise(rb_eRuntimeError, "iteration level underflow");
}
+ iter_lev_in_flags_set(hash, lev - 1);
}
static VALUE
@@ -1510,11 +1449,23 @@ rb_hash_foreach(VALUE hash, rb_foreach_func *func, VALUE farg)
hash_verify(hash);
}
+void rb_st_compact_table(st_table *tab);
+
+static void
+compact_after_delete(VALUE hash)
+{
+ if (!hash_iterating_p(hash) && RHASH_ST_TABLE_P(hash)) {
+ rb_st_compact_table(RHASH_ST_TABLE(hash));
+ }
+}
+
static VALUE
-hash_alloc_flags(VALUE klass, VALUE flags, VALUE ifnone)
+hash_alloc_flags(VALUE klass, VALUE flags, VALUE ifnone, bool st)
{
const VALUE wb = (RGENGC_WB_PROTECTED_HASH ? FL_WB_PROTECTED : 0);
- NEWOBJ_OF(hash, struct RHash, klass, T_HASH | wb | flags);
+ const size_t size = sizeof(struct RHash) + (st ? sizeof(st_table) : sizeof(ar_table));
+
+ NEWOBJ_OF(hash, struct RHash, klass, T_HASH | wb | flags, size, 0);
RHASH_SET_IFNONE((VALUE)hash, ifnone);
@@ -1524,7 +1475,8 @@ hash_alloc_flags(VALUE klass, VALUE flags, VALUE ifnone)
static VALUE
hash_alloc(VALUE klass)
{
- return hash_alloc_flags(klass, 0, Qnil);
+ /* Allocate to be able to fit both st_table and ar_table. */
+ return hash_alloc_flags(klass, 0, Qnil, sizeof(st_table) > sizeof(ar_table));
}
static VALUE
@@ -1550,19 +1502,16 @@ copy_compare_by_id(VALUE hash, VALUE basis)
return hash;
}
-MJIT_FUNC_EXPORTED VALUE
+VALUE
rb_hash_new_with_size(st_index_t size)
{
- VALUE ret = rb_hash_new();
- if (size == 0) {
- /* do nothing */
- }
- else if (size <= RHASH_AR_TABLE_MAX_SIZE) {
- ar_alloc_table(ret);
- }
- else {
- RHASH_ST_TABLE_SET(ret, st_init_table_with_size(&objhash, size));
+ bool st = size > RHASH_AR_TABLE_MAX_SIZE;
+ VALUE ret = hash_alloc_flags(rb_cHash, 0, Qnil, st);
+
+ if (st) {
+ hash_st_table_init(ret, &objhash, size);
}
+
return ret;
}
@@ -1575,27 +1524,54 @@ rb_hash_new_capa(long capa)
static VALUE
hash_copy(VALUE ret, VALUE hash)
{
- if (!RHASH_EMPTY_P(hash)) {
- if (RHASH_AR_TABLE_P(hash)) {
+ if (RHASH_AR_TABLE_P(hash)) {
+ if (RHASH_AR_TABLE_P(ret)) {
ar_copy(ret, hash);
}
else {
- RHASH_ST_TABLE_SET(ret, st_copy(RHASH_ST_TABLE(hash)));
+ st_table *tab = RHASH_ST_TABLE(ret);
+ rb_st_init_existing_table_with_size(tab, &objhash, RHASH_AR_TABLE_SIZE(hash));
+
+ int bound = RHASH_AR_TABLE_BOUND(hash);
+ for (int i = 0; i < bound; i++) {
+ if (ar_cleared_entry(hash, i)) continue;
+
+ ar_table_pair *pair = RHASH_AR_TABLE_REF(hash, i);
+ st_add_direct(tab, pair->key, pair->val);
+ RB_OBJ_WRITTEN(ret, Qundef, pair->key);
+ RB_OBJ_WRITTEN(ret, Qundef, pair->val);
+ }
}
}
+ else {
+ HASH_ASSERT(sizeof(st_table) <= sizeof(ar_table));
+
+ RHASH_SET_ST_FLAG(ret);
+ st_replace(RHASH_ST_TABLE(ret), RHASH_ST_TABLE(hash));
+
+ rb_gc_writebarrier_remember(ret);
+ }
return ret;
}
static VALUE
hash_dup_with_compare_by_id(VALUE hash)
{
- return hash_copy(copy_compare_by_id(rb_hash_new(), hash), hash);
+ VALUE dup = hash_alloc_flags(rb_cHash, 0, Qnil, RHASH_ST_TABLE_P(hash));
+ if (RHASH_ST_TABLE_P(hash)) {
+ RHASH_SET_ST_FLAG(dup);
+ }
+ else {
+ RHASH_UNSET_ST_FLAG(dup);
+ }
+
+ return hash_copy(dup, hash);
}
static VALUE
hash_dup(VALUE hash, VALUE klass, VALUE flags)
{
- return hash_copy(hash_alloc_flags(klass, flags, RHASH_IFNONE(hash)),
+ return hash_copy(hash_alloc_flags(klass, flags, RHASH_IFNONE(hash), !RHASH_EMPTY_P(hash) && RHASH_ST_TABLE_P(hash)),
hash);
}
@@ -1610,7 +1586,7 @@ rb_hash_dup(VALUE hash)
return ret;
}
-MJIT_FUNC_EXPORTED VALUE
+VALUE
rb_hash_resurrect(VALUE hash)
{
VALUE ret = hash_dup(hash, rb_cHash, 0);
@@ -1623,7 +1599,7 @@ rb_hash_modify_check(VALUE hash)
rb_check_frozen(hash);
}
-MJIT_FUNC_EXPORTED struct st_table *
+RUBY_FUNC_EXPORTED struct st_table *
rb_hash_tbl_raw(VALUE hash, const char *file, int line)
{
return ar_force_convert_table(hash, file, line);
@@ -1684,7 +1660,7 @@ rb_hash_stlike_update(VALUE hash, st_data_t key, st_update_callback_func *func,
if (RHASH_AR_TABLE_P(hash)) {
int result = ar_update(hash, key, func, arg);
if (result == -1) {
- ar_try_convert_table(hash);
+ ar_force_convert_table(hash, __FILE__, __LINE__);
}
else {
return result;
@@ -1741,14 +1717,14 @@ tbl_update(VALUE hash, VALUE key, tbl_update_func func, st_data_t optional_arg)
return ret;
}
-#define UPDATE_CALLBACK(iter_lev, func) ((iter_lev) > 0 ? func##_noinsert : func##_insert)
+#define UPDATE_CALLBACK(iter_p, func) ((iter_p) ? func##_noinsert : func##_insert)
-#define RHASH_UPDATE_ITER(h, iter_lev, key, func, a) do { \
- tbl_update((h), (key), UPDATE_CALLBACK((iter_lev), func), (st_data_t)(a)); \
+#define RHASH_UPDATE_ITER(h, iter_p, key, func, a) do { \
+ tbl_update((h), (key), UPDATE_CALLBACK(iter_p, func), (st_data_t)(a)); \
} while (0)
#define RHASH_UPDATE(hash, key, func, arg) \
- RHASH_UPDATE_ITER(hash, RHASH_ITER_LEV(hash), key, func, arg)
+ RHASH_UPDATE_ITER(hash, hash_iterating_p(hash), key, func, arg)
static void
set_proc_default(VALUE hash, VALUE proc)
@@ -1800,23 +1776,29 @@ set_proc_default(VALUE hash, VALUE proc)
static VALUE
rb_hash_initialize(int argc, VALUE *argv, VALUE hash)
{
- VALUE ifnone;
-
rb_hash_modify(hash);
+
if (rb_block_given_p()) {
rb_check_arity(argc, 0, 0);
- ifnone = rb_block_proc();
- SET_PROC_DEFAULT(hash, ifnone);
+ SET_PROC_DEFAULT(hash, rb_block_proc());
}
else {
rb_check_arity(argc, 0, 1);
- ifnone = argc == 0 ? Qnil : argv[0];
+
+ VALUE options, ifnone;
+ rb_scan_args(argc, argv, "01:", &ifnone, &options);
+ if (NIL_P(ifnone) && !NIL_P(options)) {
+ ifnone = options;
+ rb_warn_deprecated_to_remove("3.4", "Calling Hash.new with keyword arguments", "Hash.new({ key: value })");
+ }
RHASH_SET_IFNONE(hash, ifnone);
}
return hash;
}
+static VALUE rb_hash_to_a(VALUE hash);
+
/*
* call-seq:
* Hash[] -> new_empty_hash
@@ -1836,7 +1818,7 @@ rb_hash_initialize(int argc, VALUE *argv, VALUE hash)
* h = {foo: 0, bar: 1, baz: 2}
* Hash[h] # => {:foo=>0, :bar=>1, :baz=>2}
*
- * When the single given argument is an \Array of 2-element Arrays,
+ * When the single given argument is an Array of 2-element Arrays,
* returns a new \Hash object wherein each 2-element array forms a
* key-value entry:
*
@@ -1860,12 +1842,23 @@ rb_hash_s_create(int argc, VALUE *argv, VALUE klass)
if (argc == 1) {
tmp = rb_hash_s_try_convert(Qnil, argv[0]);
if (!NIL_P(tmp)) {
- hash = hash_alloc(klass);
- hash_copy(hash, tmp);
- return hash;
+ if (!RHASH_EMPTY_P(tmp) && rb_hash_compare_by_id_p(tmp)) {
+ /* hash_copy for non-empty hash will copy compare_by_identity
+ flag, but we don't want it copied. Work around by
+ converting hash to flattened array and using that. */
+ tmp = rb_hash_to_a(tmp);
+ }
+ else {
+ hash = hash_alloc(klass);
+ if (!RHASH_EMPTY_P(tmp))
+ hash_copy(hash, tmp);
+ return hash;
+ }
+ }
+ else {
+ tmp = rb_check_array_type(argv[0]);
}
- tmp = rb_check_array_type(argv[0]);
if (!NIL_P(tmp)) {
long i;
@@ -1903,7 +1896,7 @@ rb_hash_s_create(int argc, VALUE *argv, VALUE klass)
return hash;
}
-MJIT_FUNC_EXPORTED VALUE
+VALUE
rb_to_hash_type(VALUE hash)
{
return rb_convert_type_with_id(hash, T_HASH, "Hash", idTo_hash);
@@ -1976,9 +1969,12 @@ static VALUE
rb_hash_s_ruby2_keywords_hash(VALUE dummy, VALUE hash)
{
Check_Type(hash, T_HASH);
- hash = rb_hash_dup(hash);
- RHASH(hash)->basic.flags |= RHASH_PASS_AS_KEYWORDS;
- return hash;
+ VALUE tmp = rb_hash_dup(hash);
+ if (RHASH_EMPTY_P(hash) && rb_hash_compare_by_id_p(hash)) {
+ rb_hash_compare_by_id(tmp);
+ }
+ RHASH(tmp)->basic.flags |= RHASH_PASS_AS_KEYWORDS;
+ return tmp;
}
struct rehash_arg {
@@ -2016,25 +2012,27 @@ rb_hash_rehash(VALUE hash)
VALUE tmp;
st_table *tbl;
- if (RHASH_ITER_LEV(hash) > 0) {
+ if (hash_iterating_p(hash)) {
rb_raise(rb_eRuntimeError, "rehash during iteration");
}
rb_hash_modify_check(hash);
if (RHASH_AR_TABLE_P(hash)) {
tmp = hash_alloc(0);
- ar_alloc_table(tmp);
rb_hash_foreach(hash, rb_hash_rehash_i, (VALUE)tmp);
- ar_free_and_clear_table(hash);
+
+ hash_ar_free_and_clear_table(hash);
ar_copy(hash, tmp);
- ar_free_and_clear_table(tmp);
}
else if (RHASH_ST_TABLE_P(hash)) {
st_table *old_tab = RHASH_ST_TABLE(hash);
tmp = hash_alloc(0);
- tbl = st_init_table_with_size(old_tab->type, old_tab->num_entries);
- RHASH_ST_TABLE_SET(tmp, tbl);
+
+ hash_st_table_init(tmp, old_tab->type, old_tab->num_entries);
+ tbl = RHASH_ST_TABLE(tmp);
+
rb_hash_foreach(hash, rb_hash_rehash_i, (VALUE)tmp);
- st_free_table(old_tab);
+
+ hash_st_free(hash);
RHASH_ST_TABLE_SET(hash, tbl);
RHASH_ST_CLEAR(tmp);
}
@@ -2094,7 +2092,7 @@ hash_stlike_lookup(VALUE hash, st_data_t key, st_data_t *pval)
}
}
-MJIT_FUNC_EXPORTED int
+int
rb_hash_stlike_lookup(VALUE hash, st_data_t key, st_data_t *pval)
{
return hash_stlike_lookup(hash, key, pval);
@@ -2344,7 +2342,7 @@ key_i(VALUE key, VALUE value, VALUE arg)
* h.key(0) # => :foo
* h.key(2) # => :bar
*
- * Returns +nil+ if so such value is found.
+ * Returns +nil+ if no such value is found.
*/
static VALUE
@@ -2443,6 +2441,7 @@ rb_hash_delete_m(VALUE hash, VALUE key)
val = rb_hash_delete_entry(hash, key);
if (!UNDEF_P(val)) {
+ compact_after_delete(hash);
return val;
}
else {
@@ -2476,7 +2475,7 @@ shift_i_safe(VALUE key, VALUE value, VALUE arg)
*
* Removes the first hash entry
* (see {Entry Order}[rdoc-ref:Hash@Entry+Order]);
- * returns a 2-element \Array containing the removed key and value:
+ * returns a 2-element Array containing the removed key and value:
* h = {foo: 0, bar: 1, baz: 2}
* h.shift # => [:foo, 0]
* h # => {:bar=>1, :baz=>2}
@@ -2492,7 +2491,7 @@ rb_hash_shift(VALUE hash)
rb_hash_modify_check(hash);
if (RHASH_AR_TABLE_P(hash)) {
var.key = Qundef;
- if (RHASH_ITER_LEV(hash) == 0) {
+ if (!hash_iterating_p(hash)) {
if (ar_shift(hash, &var.key, &var.val)) {
return rb_assoc_new(var.key, var.val);
}
@@ -2507,7 +2506,7 @@ rb_hash_shift(VALUE hash)
}
if (RHASH_ST_TABLE_P(hash)) {
var.key = Qundef;
- if (RHASH_ITER_LEV(hash) == 0) {
+ if (!hash_iterating_p(hash)) {
if (st_shift(RHASH_ST_TABLE(hash), &var.key, &var.val)) {
return rb_assoc_new(var.key, var.val);
}
@@ -2550,7 +2549,7 @@ hash_enum_size(VALUE hash, VALUE args, VALUE eobj)
* h = {foo: 0, bar: 1, baz: 2}
* h.delete_if {|key, value| value > 0 } # => {:foo=>0}
*
- * If no block given, returns a new \Enumerator:
+ * If no block given, returns a new Enumerator:
* h = {foo: 0, bar: 1, baz: 2}
* e = h.delete_if # => #<Enumerator: {:foo=>0, :bar=>1, :baz=>2}:delete_if>
* e.each { |key, value| value > 0 } # => {:foo=>0}
@@ -2563,6 +2562,7 @@ rb_hash_delete_if(VALUE hash)
rb_hash_modify_check(hash);
if (!RHASH_TABLE_EMPTY_P(hash)) {
rb_hash_foreach(hash, delete_if_i, hash);
+ compact_after_delete(hash);
}
return hash;
}
@@ -2579,7 +2579,7 @@ rb_hash_delete_if(VALUE hash)
*
* Returns +nil+ if no entries are removed.
*
- * Returns a new \Enumerator if no block given:
+ * Returns a new Enumerator if no block given:
* h = {foo: 0, bar: 1, baz: 2}
* e = h.reject! # => #<Enumerator: {:foo=>0, :bar=>1, :baz=>2}:reject!>
* e.each {|key, value| key.start_with?('b') } # => {:foo=>0}
@@ -2610,7 +2610,7 @@ rb_hash_reject_bang(VALUE hash)
* h1 = h.reject {|key, value| key.start_with?('b') }
* h1 # => {:foo=>0}
*
- * Returns a new \Enumerator if no block given:
+ * Returns a new Enumerator if no block given:
* h = {foo: 0, bar: 1, baz: 2}
* e = h.reject # => #<Enumerator: {:foo=>0, :bar=>1, :baz=>2}:reject>
* h1 = e.each {|key, value| key.start_with?('b') }
@@ -2626,6 +2626,7 @@ rb_hash_reject(VALUE hash)
result = hash_dup_with_compare_by_id(hash);
if (!RHASH_EMPTY_P(hash)) {
rb_hash_foreach(result, delete_if_i, result);
+ compact_after_delete(result);
}
return result;
}
@@ -2685,6 +2686,7 @@ rb_hash_except(int argc, VALUE *argv, VALUE hash)
key = argv[i];
rb_hash_delete(result, key);
}
+ compact_after_delete(result);
return result;
}
@@ -2693,7 +2695,7 @@ rb_hash_except(int argc, VALUE *argv, VALUE hash)
* call-seq:
* hash.values_at(*keys) -> new_array
*
- * Returns a new \Array containing values for the given +keys+:
+ * Returns a new Array containing values for the given +keys+:
* h = {foo: 0, bar: 1, baz: 2}
* h.values_at(:baz, :foo) # => [2, 0]
*
@@ -2719,11 +2721,11 @@ rb_hash_values_at(int argc, VALUE *argv, VALUE hash)
* hash.fetch_values(*keys) -> new_array
* hash.fetch_values(*keys) {|key| ... } -> new_array
*
- * Returns a new \Array containing the values associated with the given keys *keys:
+ * Returns a new Array containing the values associated with the given keys *keys:
* h = {foo: 0, bar: 1, baz: 2}
* h.fetch_values(:baz, :foo) # => [2, 0]
*
- * Returns a new empty \Array if no arguments given.
+ * Returns a new empty Array if no arguments given.
*
* When a block is given, calls the block with each missing key,
* treating the block's return value as the value for that key:
@@ -2761,13 +2763,11 @@ keep_if_i(VALUE key, VALUE value, VALUE hash)
* hash.select {|key, value| ... } -> new_hash
* hash.select -> new_enumerator
*
- * Hash#filter is an alias for Hash#select.
- *
* Returns a new \Hash object whose entries are those for which the block returns a truthy value:
* h = {foo: 0, bar: 1, baz: 2}
* h.select {|key, value| value < 2 } # => {:foo=>0, :bar=>1}
*
- * Returns a new \Enumerator if no block given:
+ * Returns a new Enumerator if no block given:
* h = {foo: 0, bar: 1, baz: 2}
* e = h.select # => #<Enumerator: {:foo=>0, :bar=>1, :baz=>2}:select>
* e.each {|key, value| value < 2 } # => {:foo=>0, :bar=>1}
@@ -2782,6 +2782,7 @@ rb_hash_select(VALUE hash)
result = hash_dup_with_compare_by_id(hash);
if (!RHASH_EMPTY_P(hash)) {
rb_hash_foreach(result, keep_if_i, result);
+ compact_after_delete(result);
}
return result;
}
@@ -2791,15 +2792,13 @@ rb_hash_select(VALUE hash)
* hash.select! {|key, value| ... } -> self or nil
* hash.select! -> new_enumerator
*
- * Hash#filter! is an alias for Hash#select!.
- *
* Returns +self+, whose entries are those for which the block returns a truthy value:
* h = {foo: 0, bar: 1, baz: 2}
* h.select! {|key, value| value < 2 } => {:foo=>0, :bar=>1}
*
* Returns +nil+ if no entries were removed.
*
- * Returns a new \Enumerator if no block given:
+ * Returns a new Enumerator if no block given:
* h = {foo: 0, bar: 1, baz: 2}
* e = h.select! # => #<Enumerator: {:foo=>0, :bar=>1, :baz=>2}:select!>
* e.each { |key, value| value < 2 } # => {:foo=>0, :bar=>1}
@@ -2830,7 +2829,7 @@ rb_hash_select_bang(VALUE hash)
* h = {foo: 0, bar: 1, baz: 2}
* h.keep_if { |key, value| key.start_with?('b') } # => {:bar=>1, :baz=>2}
*
- * Returns a new \Enumerator if no block given:
+ * Returns a new Enumerator if no block given:
* h = {foo: 0, bar: 1, baz: 2}
* e = h.keep_if # => #<Enumerator: {:foo=>0, :bar=>1, :baz=>2}:keep_if>
* e.each { |key, value| key.start_with?('b') } # => {:bar=>1, :baz=>2}
@@ -2865,7 +2864,7 @@ rb_hash_clear(VALUE hash)
{
rb_hash_modify_check(hash);
- if (RHASH_ITER_LEV(hash) > 0) {
+ if (hash_iterating_p(hash)) {
rb_hash_foreach(hash, clear_i, 0);
}
else if (RHASH_AR_TABLE_P(hash)) {
@@ -2873,6 +2872,7 @@ rb_hash_clear(VALUE hash)
}
else {
st_clear(RHASH_ST_TABLE(hash));
+ compact_after_delete(hash);
}
return hash;
@@ -2913,8 +2913,6 @@ NOINSERT_UPDATE_CALLBACK(hash_aset_str)
* hash[key] = value -> value
* hash.store(key, value)
*
- * Hash#store is an alias for Hash#[]=.
-
* Associates the given +value+ with the given +key+; returns +value+.
*
* If the given +key+ exists, replaces its value with the given +value+;
@@ -2937,20 +2935,15 @@ NOINSERT_UPDATE_CALLBACK(hash_aset_str)
VALUE
rb_hash_aset(VALUE hash, VALUE key, VALUE val)
{
- int iter_lev = RHASH_ITER_LEV(hash);
+ bool iter_p = hash_iterating_p(hash);
rb_hash_modify(hash);
- if (RHASH_TABLE_NULL_P(hash)) {
- if (iter_lev > 0) no_new_key();
- ar_alloc_table(hash);
- }
-
if (RHASH_TYPE(hash) == &identhash || rb_obj_class(key) != rb_cString) {
- RHASH_UPDATE_ITER(hash, iter_lev, key, hash_aset, val);
+ RHASH_UPDATE_ITER(hash, iter_p, key, hash_aset, val);
}
else {
- RHASH_UPDATE_ITER(hash, iter_lev, key, hash_aset_str, val);
+ RHASH_UPDATE_ITER(hash, iter_p, key, hash_aset_str, val);
}
return val;
}
@@ -2970,7 +2963,7 @@ rb_hash_replace(VALUE hash, VALUE hash2)
{
rb_hash_modify_check(hash);
if (hash == hash2) return hash;
- if (RHASH_ITER_LEV(hash) > 0) {
+ if (hash_iterating_p(hash)) {
rb_raise(rb_eRuntimeError, "can't replace hash during iteration");
}
hash2 = to_hash(hash2);
@@ -2978,19 +2971,13 @@ rb_hash_replace(VALUE hash, VALUE hash2)
COPY_DEFAULT(hash, hash2);
if (RHASH_AR_TABLE_P(hash)) {
- ar_free_and_clear_table(hash);
+ hash_ar_free_and_clear_table(hash);
}
else {
- st_free_table(RHASH_ST_TABLE(hash));
- RHASH_ST_CLEAR(hash);
- }
- hash_copy(hash, hash2);
- if (RHASH_EMPTY_P(hash2) && RHASH_ST_TABLE_P(hash2)) {
- /* ident hash */
- RHASH_ST_TABLE_SET(hash, st_init_table_with_size(RHASH_TYPE(hash2), 0));
+ hash_st_free_and_clear_table(hash);
}
- rb_gc_writebarrier_remember(hash);
+ hash_copy(hash, hash2);
return hash;
}
@@ -3001,9 +2988,9 @@ rb_hash_replace(VALUE hash, VALUE hash2)
* hash.size -> integer
*
* Returns the count of entries in +self+:
+ *
* {foo: 0, bar: 1, baz: 2}.length # => 3
*
- * Hash#length is an alias for Hash#size.
*/
VALUE
@@ -3053,7 +3040,7 @@ each_value_i(VALUE key, VALUE value, VALUE _)
* 1
* 2
*
- * Returns a new \Enumerator if no block given:
+ * Returns a new Enumerator if no block given:
* h = {foo: 0, bar: 1, baz: 2}
* e = h.each_value # => #<Enumerator: {:foo=>0, :bar=>1, :baz=>2}:each_value>
* h1 = e.each {|value| puts value }
@@ -3092,7 +3079,7 @@ each_key_i(VALUE key, VALUE value, VALUE _)
* bar
* baz
*
- * Returns a new \Enumerator if no block given:
+ * Returns a new Enumerator if no block given:
* h = {foo: 0, bar: 1, baz: 2}
* e = h.each_key # => #<Enumerator: {:foo=>0, :bar=>1, :baz=>2}:each_key>
* h1 = e.each {|key| puts key }
@@ -3134,8 +3121,6 @@ each_pair_i_fast(VALUE key, VALUE value, VALUE _)
* hash.each -> new_enumerator
* hash.each_pair -> new_enumerator
*
- * Hash#each is an alias for Hash#each_pair.
-
* Calls the given block with each key-value pair; returns +self+:
* h = {foo: 0, bar: 1, baz: 2}
* h.each_pair {|key, value| puts "#{key}: #{value}"} # => {:foo=>0, :bar=>1, :baz=>2}
@@ -3144,7 +3129,7 @@ each_pair_i_fast(VALUE key, VALUE value, VALUE _)
* bar: 1
* baz: 2
*
- * Returns a new \Enumerator if no block given:
+ * Returns a new Enumerator if no block given:
* h = {foo: 0, bar: 1, baz: 2}
* e = h.each_pair # => #<Enumerator: {:foo=>0, :bar=>1, :baz=>2}:each_pair>
* h1 = e.each {|key, value| puts "#{key}: #{value}"}
@@ -3227,7 +3212,7 @@ transform_keys_i(VALUE key, VALUE value, VALUE result)
* h1 = h.transform_keys {|key| :bat }
* h1 # => {:bat=>2}
*
- * Returns a new \Enumerator if no block given:
+ * Returns a new Enumerator if no block given:
* h = {foo: 0, bar: 1, baz: 2}
* e = h.transform_keys # => #<Enumerator: {:foo=>0, :bar=>1, :baz=>2}:transform_keys>
* h1 = e.each { |key| key.to_s }
@@ -3318,6 +3303,7 @@ rb_hash_transform_keys_bang(int argc, VALUE *argv, VALUE hash)
rb_ary_clear(pairs);
rb_hash_clear(new_keys);
}
+ compact_after_delete(hash);
return hash;
}
@@ -3351,7 +3337,7 @@ transform_values_foreach_replace(st_data_t *key, st_data_t *value, st_data_t arg
* h1 = h.transform_values {|value| value * 100}
* h1 # => {:foo=>0, :bar=>100, :baz=>200}
*
- * Returns a new \Enumerator if no block given:
+ * Returns a new Enumerator if no block given:
* h = {foo: 0, bar: 1, baz: 2}
* e = h.transform_values # => #<Enumerator: {:foo=>0, :bar=>1, :baz=>2}:transform_values>
* h1 = e.each { |value| value * 100}
@@ -3368,6 +3354,7 @@ rb_hash_transform_values(VALUE hash)
if (!RHASH_EMPTY_P(hash)) {
rb_hash_stlike_foreach_with_replace(result, transform_values_foreach_func, transform_values_foreach_replace, result);
+ compact_after_delete(result);
}
return result;
@@ -3382,7 +3369,7 @@ rb_hash_transform_values(VALUE hash)
* h = {foo: 0, bar: 1, baz: 2}
* h.transform_values! {|value| value * 100} # => {:foo=>0, :bar=>100, :baz=>200}
*
- * Returns a new \Enumerator if no block given:
+ * Returns a new Enumerator if no block given:
* h = {foo: 0, bar: 1, baz: 2}
* e = h.transform_values! # => #<Enumerator: {:foo=>0, :bar=>100, :baz=>200}:transform_values!>
* h1 = e.each {|value| value * 100}
@@ -3412,8 +3399,8 @@ to_a_i(VALUE key, VALUE value, VALUE ary)
* call-seq:
* hash.to_a -> new_array
*
- * Returns a new \Array of 2-element \Array objects;
- * each nested \Array contains a key-value pair from +self+:
+ * Returns a new Array of 2-element Array objects;
+ * each nested Array contains a key-value pair from +self+:
* h = {foo: 0, bar: 1, baz: 2}
* h.to_a # => [[:foo, 0], [:bar, 1], [:baz, 2]]
*/
@@ -3466,11 +3453,11 @@ inspect_hash(VALUE hash, VALUE dummy, int recur)
* call-seq:
* hash.inspect -> new_string
*
- * Returns a new \String containing the hash entries:
+ * Returns a new String containing the hash entries:
+
* h = {foo: 0, bar: 1, baz: 2}
* h.inspect # => "{:foo=>0, :bar=>1, :baz=>2}"
*
- * Hash#to_s is an alias for Hash#inspect.
*/
static VALUE
@@ -3538,8 +3525,8 @@ rb_hash_to_h_block(VALUE hash)
*
* When a block is given, returns a new \Hash object
* whose content is based on the block;
- * the block should return a 2-element \Array object
- * specifying the key-value pair to be included in the returned \Array:
+ * the block should return a 2-element Array object
+ * specifying the key-value pair to be included in the returned Array:
* h = {foo: 0, bar: 1, baz: 2}
* h1 = h.to_h {|key, value| [value, key] }
* h1 # => {0=>:foo, 1=>:bar, 2=>:baz}
@@ -3569,12 +3556,12 @@ keys_i(VALUE key, VALUE value, VALUE ary)
* call-seq:
* hash.keys -> new_array
*
- * Returns a new \Array containing all keys in +self+:
+ * Returns a new Array containing all keys in +self+:
* h = {foo: 0, bar: 1, baz: 2}
* h.keys # => [:foo, :bar, :baz]
*/
-MJIT_FUNC_EXPORTED VALUE
+VALUE
rb_hash_keys(VALUE hash)
{
st_index_t size = RHASH_SIZE(hash);
@@ -3583,7 +3570,7 @@ rb_hash_keys(VALUE hash)
if (size == 0) return keys;
if (ST_DATA_COMPATIBLE_P(VALUE)) {
- RARRAY_PTR_USE_TRANSIENT(keys, ptr, {
+ RARRAY_PTR_USE(keys, ptr, {
if (RHASH_AR_TABLE_P(hash)) {
size = ar_keys(hash, ptr, size);
}
@@ -3613,7 +3600,7 @@ values_i(VALUE key, VALUE value, VALUE ary)
* call-seq:
* hash.values -> new_array
*
- * Returns a new \Array containing all values in +self+:
+ * Returns a new Array containing all values in +self+:
* h = {foo: 0, bar: 1, baz: 2}
* h.values # => [0, 1, 2]
*/
@@ -3630,14 +3617,14 @@ rb_hash_values(VALUE hash)
if (ST_DATA_COMPATIBLE_P(VALUE)) {
if (RHASH_AR_TABLE_P(hash)) {
rb_gc_writebarrier_remember(values);
- RARRAY_PTR_USE_TRANSIENT(values, ptr, {
+ RARRAY_PTR_USE(values, ptr, {
size = ar_values(hash, ptr, size);
});
}
else if (RHASH_ST_TABLE_P(hash)) {
st_table *table = RHASH_ST_TABLE(hash);
rb_gc_writebarrier_remember(values);
- RARRAY_PTR_USE_TRANSIENT(values, ptr, {
+ RARRAY_PTR_USE(values, ptr, {
size = st_values(table, ptr, size);
});
}
@@ -3657,13 +3644,11 @@ rb_hash_values(VALUE hash)
* hash.has_key?(key) -> true or false
* hash.key?(key) -> true or false
* hash.member?(key) -> true or false
-
- * Methods #has_key?, #key?, and #member? are aliases for \#include?.
*
* Returns +true+ if +key+ is a key in +self+, otherwise +false+.
*/
-MJIT_FUNC_EXPORTED VALUE
+VALUE
rb_hash_has_key(VALUE hash, VALUE key)
{
return RBOOL(hash_stlike_lookup(hash, key, NULL));
@@ -3686,8 +3671,6 @@ rb_hash_search_value(VALUE key, VALUE value, VALUE arg)
* hash.has_value?(value) -> true or false
* hash.value?(value) -> true or false
*
- * Method #value? is an alias for \#has_value?.
- *
* Returns +true+ if +value+ is a value in +self+, otherwise +false+.
*/
@@ -3849,10 +3832,10 @@ hash_i(VALUE key, VALUE val, VALUE arg)
* call-seq:
* hash.hash -> an_integer
*
- * Returns the \Integer hash-code for the hash.
+ * Returns the Integer hash-code for the hash.
*
* Two \Hash objects have the same hash-code if their content is the same
- * (regardless or order):
+ * (regardless of order):
* h1 = {foo: 0, bar: 1, baz: 2}
* h2 = {baz: 2, bar: 1, foo: 0}
* h2.hash == h1.hash # => true
@@ -3950,8 +3933,6 @@ rb_hash_update_block_i(VALUE key, VALUE value, VALUE hash)
*
* Each argument in +other_hashes+ must be a \Hash.
*
- * \Method #update is an alias for \#merge!.
- *
* With arguments and no block:
* * Returns +self+, after the given hashes are merged into it.
* * The given hashes are merged left to right.
@@ -4121,24 +4102,17 @@ assoc_cmp(VALUE a, VALUE b)
return !RTEST(rb_equal(a, b));
}
-static VALUE
-lookup2_call(VALUE arg)
-{
- VALUE *args = (VALUE *)arg;
- return rb_hash_lookup2(args[0], args[1], Qundef);
-}
-
-struct reset_hash_type_arg {
- VALUE hash;
- const struct st_hash_type *orighash;
+struct assoc_arg {
+ st_table *tbl;
+ st_data_t key;
};
static VALUE
-reset_hash_type(VALUE arg)
+assoc_lookup(VALUE arg)
{
- struct reset_hash_type_arg *p = (struct reset_hash_type_arg *)arg;
- HASH_ASSERT(RHASH_ST_TABLE_P(p->hash));
- RHASH_ST_TABLE(p->hash)->type = p->orighash;
+ struct assoc_arg *p = (struct assoc_arg*)arg;
+ st_data_t data;
+ if (st_lookup(p->tbl, p->key, &data)) return (VALUE)data;
return Qundef;
}
@@ -4158,7 +4132,7 @@ assoc_i(VALUE key, VALUE val, VALUE arg)
* call-seq:
* hash.assoc(key) -> new_array or nil
*
- * If the given +key+ is found, returns a 2-element \Array containing that key and its value:
+ * If the given +key+ is found, returns a 2-element Array containing that key and its value:
* h = {foo: 0, bar: 1, baz: 2}
* h.assoc(:bar) # => [:bar, 1]
*
@@ -4168,30 +4142,30 @@ assoc_i(VALUE key, VALUE val, VALUE arg)
static VALUE
rb_hash_assoc(VALUE hash, VALUE key)
{
- st_table *table;
- const struct st_hash_type *orighash;
VALUE args[2];
if (RHASH_EMPTY_P(hash)) return Qnil;
- ar_force_convert_table(hash, __FILE__, __LINE__);
- HASH_ASSERT(RHASH_ST_TABLE_P(hash));
- table = RHASH_ST_TABLE(hash);
- orighash = table->type;
-
- if (orighash != &identhash) {
- VALUE value;
- struct reset_hash_type_arg ensure_arg;
- struct st_hash_type assochash;
-
- assochash.compare = assoc_cmp;
- assochash.hash = orighash->hash;
- table->type = &assochash;
- args[0] = hash;
- args[1] = key;
- ensure_arg.hash = hash;
- ensure_arg.orighash = orighash;
- value = rb_ensure(lookup2_call, (VALUE)&args, reset_hash_type, (VALUE)&ensure_arg);
+ if (RHASH_ST_TABLE_P(hash) && RHASH_ST_TABLE(hash)->type != &identhash) {
+ VALUE value = Qundef;
+ st_table assoctable = *RHASH_ST_TABLE(hash);
+ assoctable.type = &(struct st_hash_type){
+ .compare = assoc_cmp,
+ .hash = assoctable.type->hash,
+ };
+ VALUE arg = (VALUE)&(struct assoc_arg){
+ .tbl = &assoctable,
+ .key = (st_data_t)key,
+ };
+
+ if (RB_OBJ_FROZEN(hash)) {
+ value = assoc_lookup(arg);
+ }
+ else {
+ hash_iter_lev_inc(hash);
+ value = rb_ensure(assoc_lookup, arg, hash_foreach_ensure, hash);
+ }
+ hash_verify(hash);
if (!UNDEF_P(value)) return rb_assoc_new(key, value);
}
@@ -4217,7 +4191,7 @@ rassoc_i(VALUE key, VALUE val, VALUE arg)
* call-seq:
* hash.rassoc(value) -> new_array or nil
*
- * Returns a new 2-element \Array consisting of the key and value
+ * Returns a new 2-element Array consisting of the key and value
* of the first-found entry whose value is <tt>==</tt> to value
* (see {Entry Order}[rdoc-ref:Hash@Entry+Order]):
* h = {foo: 0, bar: 1, baz: 1}
@@ -4254,7 +4228,7 @@ flatten_i(VALUE key, VALUE val, VALUE ary)
* hash.flatten -> new_array
* hash.flatten(level) -> new_array
*
- * Returns a new \Array object that is a 1-dimensional flattening of +self+.
+ * Returns a new Array object that is a 1-dimensional flattening of +self+.
*
* ---
*
@@ -4262,7 +4236,7 @@ flatten_i(VALUE key, VALUE val, VALUE ary)
* h = {foo: 0, bar: [:bat, 3], baz: 2}
* h.flatten # => [:foo, 0, :bar, [:bat, 3], :baz, 2]
*
- * Takes the depth of recursive flattening from \Integer argument +level+:
+ * Takes the depth of recursive flattening from Integer argument +level+:
* h = {foo: 0, bar: [:bat, [:baz, [:bat, ]]]}
* h.flatten(1) # => [:foo, 0, :bar, [:bat, [:baz, [:bat]]]]
* h.flatten(2) # => [:foo, 0, :bar, :bat, [:baz, [:bat]]]
@@ -4322,15 +4296,6 @@ delete_if_nil(VALUE key, VALUE value, VALUE hash)
return ST_CONTINUE;
}
-static int
-set_if_not_nil(VALUE key, VALUE value, VALUE hash)
-{
- if (!NIL_P(value)) {
- rb_hash_aset(hash, key, value);
- }
- return ST_CONTINUE;
-}
-
/*
* call-seq:
* hash.compact -> new_hash
@@ -4344,9 +4309,13 @@ set_if_not_nil(VALUE key, VALUE value, VALUE hash)
static VALUE
rb_hash_compact(VALUE hash)
{
- VALUE result = rb_hash_new();
+ VALUE result = rb_hash_dup(hash);
if (!RHASH_EMPTY_P(hash)) {
- rb_hash_foreach(hash, set_if_not_nil, result);
+ rb_hash_foreach(result, delete_if_nil, result);
+ compact_after_delete(result);
+ }
+ else if (rb_hash_compare_by_id_p(hash)) {
+ result = rb_hash_compare_by_id(result);
}
return result;
}
@@ -4376,8 +4345,6 @@ rb_hash_compact_bang(VALUE hash)
return Qnil;
}
-static st_table *rb_init_identtable_with_size(st_index_t size);
-
/*
* call-seq:
* hash.compare_by_identity -> self
@@ -4415,16 +4382,33 @@ rb_hash_compare_by_id(VALUE hash)
if (rb_hash_compare_by_id_p(hash)) return hash;
rb_hash_modify_check(hash);
- ar_force_convert_table(hash, __FILE__, __LINE__);
- HASH_ASSERT(RHASH_ST_TABLE_P(hash));
+ if (hash_iterating_p(hash)) {
+ rb_raise(rb_eRuntimeError, "compare_by_identity during iteration");
+ }
+
+ if (RHASH_TABLE_EMPTY_P(hash)) {
+ // Fast path: There's nothing to rehash, so we don't need a `tmp` table.
+ // We're most likely an AR table, so this will need an allocation.
+ ar_force_convert_table(hash, __FILE__, __LINE__);
+ HASH_ASSERT(RHASH_ST_TABLE_P(hash));
+
+ RHASH_ST_TABLE(hash)->type = &identhash;
+ }
+ else {
+ // Slow path: Need to rehash the members of `self` into a new
+ // `tmp` table using the new `identhash` compare/hash functions.
+ tmp = hash_alloc(0);
+ hash_st_table_init(tmp, &identhash, RHASH_SIZE(hash));
+ identtable = RHASH_ST_TABLE(tmp);
+
+ rb_hash_foreach(hash, rb_hash_rehash_i, (VALUE)tmp);
+ rb_hash_free(hash);
- tmp = hash_alloc(0);
- identtable = rb_init_identtable_with_size(RHASH_SIZE(hash));
- RHASH_ST_TABLE_SET(tmp, identtable);
- rb_hash_foreach(hash, rb_hash_rehash_i, (VALUE)tmp);
- st_free_table(RHASH_ST_TABLE(hash));
- RHASH_ST_TABLE_SET(hash, identtable);
- RHASH_ST_CLEAR(tmp);
+ // We know for sure `identtable` is an st table,
+ // so we can skip `ar_force_convert_table` here.
+ RHASH_ST_TABLE_SET(hash, identtable);
+ RHASH_ST_CLEAR(tmp);
+ }
return hash;
}
@@ -4436,7 +4420,7 @@ rb_hash_compare_by_id(VALUE hash)
* Returns +true+ if #compare_by_identity has been called, +false+ otherwise.
*/
-MJIT_FUNC_EXPORTED VALUE
+VALUE
rb_hash_compare_by_id_p(VALUE hash)
{
return RBOOL(RHASH_ST_TABLE_P(hash) && RHASH_ST_TABLE(hash)->type == &identhash);
@@ -4446,7 +4430,7 @@ VALUE
rb_ident_hash_new(void)
{
VALUE hash = rb_hash_new();
- RHASH_ST_TABLE_SET(hash, st_init_table(&identhash));
+ hash_st_table_init(hash, &identhash, 0);
return hash;
}
@@ -4454,7 +4438,7 @@ VALUE
rb_ident_hash_new_with_size(st_index_t size)
{
VALUE hash = rb_hash_new();
- RHASH_ST_TABLE_SET(hash, st_init_table_with_size(&identhash, size));
+ hash_st_table_init(hash, &identhash, size);
return hash;
}
@@ -4464,12 +4448,6 @@ rb_init_identtable(void)
return st_init_table(&identhash);
}
-static st_table *
-rb_init_identtable_with_size(st_index_t size)
-{
- return st_init_table_with_size(&identhash, size);
-}
-
static int
any_p_i(VALUE key, VALUE value, VALUE arg)
{
@@ -4512,6 +4490,9 @@ any_p_i_pattern(VALUE key, VALUE value, VALUE arg)
* Returns +true+ if any element satisfies a given criterion;
* +false+ otherwise.
*
+ * If +self+ has no element, returns +false+ and argument or block
+ * are not used.
+ *
* With no argument and no block,
* returns +true+ if +self+ is non-empty; +false+ if empty.
*
@@ -4530,6 +4511,8 @@ any_p_i_pattern(VALUE key, VALUE value, VALUE arg)
* h = {foo: 0, bar: 1, baz: 2}
* h.any? {|key, value| value < 3 } # => true
* h.any? {|key, value| value > 3 } # => false
+ *
+ * Related: Enumerable#any?
*/
static VALUE
@@ -4707,7 +4690,7 @@ hash_proc_call(RB_BLOCK_CALL_FUNC_ARGLIST(key, hash))
* call-seq:
* hash.to_proc -> proc
*
- * Returns a \Proc object that maps a key to its value:
+ * Returns a Proc object that maps a key to its value:
* h = {foo: 0, bar: 1, baz: 2}
* proc = h.to_proc
* proc.class # => Proc
@@ -4721,6 +4704,7 @@ rb_hash_to_proc(VALUE hash)
return rb_func_lambda_new(hash_proc_call, hash, 1, 1);
}
+/* :nodoc: */
static VALUE
rb_hash_deconstruct_keys(VALUE hash, VALUE keys)
{
@@ -4751,14 +4735,13 @@ rb_hash_add_new_element(VALUE hash, VALUE key, VALUE val)
args[1] = val;
if (RHASH_AR_TABLE_P(hash)) {
- hash_ar_table(hash);
-
ret = ar_update(hash, (st_data_t)key, add_new_i, (st_data_t)args);
if (ret != -1) {
return ret;
}
- ar_try_convert_table(hash);
+ ar_force_convert_table(hash, __FILE__, __LINE__);
}
+
tbl = RHASH_TBL_RAW(hash);
return st_update(tbl, (st_data_t)key, add_new_i, (st_data_t)args);
@@ -4791,15 +4774,6 @@ rb_hash_bulk_insert(long argc, const VALUE *argv, VALUE hash)
if (argc > 0) {
st_index_t size = argc / 2;
- if (RHASH_TABLE_NULL_P(hash)) {
- if (size <= RHASH_AR_TABLE_MAX_SIZE) {
- hash_ar_table(hash);
- }
- else {
- RHASH_TBL_RAW(hash);
- }
- }
-
if (RHASH_AR_TABLE_P(hash) &&
(RHASH_AR_TABLE_SIZE(hash) + size <= RHASH_AR_TABLE_MAX_SIZE)) {
ar_bulk_insert(hash, argc, argv);
@@ -4902,9 +4876,7 @@ has_env_with_lock(const char *name)
static const char TZ_ENV[] = "TZ";
static void *
-get_env_cstr(
- VALUE str,
- const char *name)
+get_env_cstr(VALUE str, const char *name)
{
char *var;
rb_encoding *enc = rb_enc_get(str);
@@ -5227,7 +5199,7 @@ ruby_setenv(const char *name, const char *value)
}
ENV_UNLOCK();
- if (ret) rb_sys_fail_str(rb_sprintf("setenv(%s)", name));
+ if (ret) rb_sys_fail_sprintf("setenv(%s)", name);
}
else {
#ifdef VOID_UNSETENV
@@ -5244,7 +5216,7 @@ ruby_setenv(const char *name, const char *value)
}
ENV_UNLOCK();
- if (ret) rb_sys_fail_str(rb_sprintf("unsetenv(%s)", name));
+ if (ret) rb_sys_fail_sprintf("unsetenv(%s)", name);
#endif
}
#elif defined __sun
@@ -5261,7 +5233,7 @@ ruby_setenv(const char *name, const char *value)
mem_size = len + strlen(value) + 2;
mem_ptr = malloc(mem_size);
if (mem_ptr == NULL)
- rb_sys_fail_str(rb_sprintf("malloc(%"PRIuSIZE")", mem_size));
+ rb_sys_fail_sprintf("malloc(%"PRIuSIZE")", mem_size);
snprintf(mem_ptr, mem_size, "%s=%s", name, value);
}
@@ -5287,7 +5259,7 @@ ruby_setenv(const char *name, const char *value)
if (ret) {
free(mem_ptr);
- rb_sys_fail_str(rb_sprintf("putenv(%s)", name));
+ rb_sys_fail_sprintf("putenv(%s)", name);
}
}
#else /* WIN32 */
@@ -5351,8 +5323,6 @@ ruby_unsetenv(const char *name)
* ENV[name] = value -> value
* ENV.store(name, value) -> value
*
- * ENV.store is an alias for ENV.[]=.
- *
* Creates, updates, or deletes the named environment variable, returning the value.
* Both +name+ and +value+ may be instances of String.
* See {Valid Names and Values}[rdoc-ref:ENV@Valid+Names+and+Values].
@@ -5593,7 +5563,7 @@ env_each_value(VALUE ehash)
* ENV.each_pair { |name, value| block } -> ENV
* ENV.each_pair -> an_enumerator
*
- * Yields each environment variable name and its value as a 2-element \Array:
+ * Yields each environment variable name and its value as a 2-element Array:
* h = {}
* ENV.each_pair { |name, value| h[name] = value } # => ENV
* h # => {"bar"=>"1", "foo"=>"0"}
@@ -5729,7 +5699,7 @@ env_delete_if(VALUE ehash)
* Returns +nil+ in the Array for each name that is not an ENV name:
* ENV.values_at('foo', 'bat', 'bar', 'bam') # => ["0", nil, "1", nil]
*
- * Returns an empty \Array if no names given.
+ * Returns an empty Array if no names given.
*
* Raises an exception if any name is invalid.
* See {Invalid Names and Values}[rdoc-ref:ENV@Invalid+Names+and+Values].
@@ -5754,8 +5724,6 @@ env_values_at(int argc, VALUE *argv, VALUE _)
* ENV.filter { |name, value| block } -> hash of name/value pairs
* ENV.filter -> an_enumerator
*
- * ENV.filter is an alias for ENV.select.
- *
* Yields each environment variable name and its value as a 2-element Array,
* returning a Hash of the names and values for which the block returns a truthy value:
* ENV.replace('foo' => '0', 'bar' => '1', 'baz' => '2')
@@ -5799,8 +5767,6 @@ env_select(VALUE ehash)
* ENV.filter! { |name, value| block } -> ENV or nil
* ENV.filter! -> an_enumerator
*
- * ENV.filter! is an alias for ENV.select!.
- *
* Yields each environment variable name and its value as a 2-element Array,
* deleting each entry for which the block returns +false+ or +nil+,
* and returning ENV if any deletions made, or +nil+ otherwise:
@@ -6111,8 +6077,6 @@ env_empty_p(VALUE _)
* ENV.member?(name) -> true or false
* ENV.key?(name) -> true or false
*
- * ENV.has_key?, ENV.member?, and ENV.key? are aliases for ENV.include?.
- *
* Returns +true+ if there is an environment variable with the given +name+:
* ENV.replace('foo' => '0', 'bar' => '1')
* ENV.include?('foo') # => true
@@ -6593,8 +6557,6 @@ env_update_block_i(VALUE key, VALUE val, VALUE _)
* ENV.merge!(*hashes) -> ENV
* ENV.merge!(*hashes) { |name, env_val, hash_val| block } -> ENV
*
- * ENV.update is an alias for ENV.merge!.
- *
* Adds to ENV each key/value pair in the given +hash+; returns ENV:
* ENV.replace('foo' => '0', 'bar' => '1')
* ENV.merge!('baz' => '2', 'bat' => '3') # => {"bar"=>"1", "bat"=>"3", "baz"=>"2", "foo"=>"0"}
@@ -6686,8 +6648,8 @@ static const rb_data_type_t env_data_type = {
/*
* A \Hash maps each of its unique keys to a specific value.
*
- * A \Hash has certain similarities to an \Array, but:
- * - An \Array index is always an \Integer.
+ * A \Hash has certain similarities to an Array, but:
+ * - An Array index is always an Integer.
* - A \Hash key can be (almost) any object.
*
* === \Hash \Data Syntax
@@ -6697,14 +6659,14 @@ static const rb_data_type_t env_data_type = {
* h = {:foo => 0, :bar => 1, :baz => 2}
* h # => {:foo=>0, :bar=>1, :baz=>2}
*
- * Alternatively, but only for a \Hash key that's a \Symbol,
+ * Alternatively, but only for a \Hash key that's a Symbol,
* you can use a newer JSON-style syntax,
- * where each bareword becomes a \Symbol:
+ * where each bareword becomes a Symbol:
*
* h = {foo: 0, bar: 1, baz: 2}
* h # => {:foo=>0, :bar=>1, :baz=>2}
*
- * You can also use a \String in place of a bareword:
+ * You can also use a String in place of a bareword:
*
* h = {'foo': 0, 'bar': 1, 'baz': 2}
* h # => {:foo=>0, :bar=>1, :baz=>2}
@@ -6829,7 +6791,7 @@ static const rb_data_type_t env_data_type = {
*
* - Iterative methods such as <tt>each</tt>, <tt>each_key</tt>, <tt>each_pair</tt>, <tt>each_value</tt>.
* - Other order-sensitive methods such as <tt>shift</tt>, <tt>keys</tt>, <tt>values</tt>.
- * - The \String returned by method <tt>inspect</tt>.
+ * - The String returned by method <tt>inspect</tt>.
*
* A new \Hash has its initial ordering per the given entries:
*
@@ -6888,9 +6850,9 @@ static const rb_data_type_t env_data_type = {
* h.include?(a0) # => true
* h[a0] # => 0
*
- * A \String key is always safe.
- * That's because an unfrozen \String
- * passed as a key will be replaced by a duplicated and frozen \String:
+ * A String key is always safe.
+ * That's because an unfrozen String
+ * passed as a key will be replaced by a duplicated and frozen String:
*
* s = 'foo'
* s.frozen? # => false
@@ -6904,9 +6866,9 @@ static const rb_data_type_t env_data_type = {
* Note: this requirement does not apply if the \Hash uses #compare_by_identity since comparison will then
* rely on the keys' object id instead of <code>hash</code> and <code>eql?</code>.
*
- * \Object defines basic implementation for <code>hash</code> and <code>eq?</code> that makes each object
+ * Object defines basic implementation for <code>hash</code> and <code>eq?</code> that makes each object
* a distinct key. Typically, user-defined classes will want to override these methods to provide meaningful
- * behavior, or for example inherit \Struct that has useful definitions for these.
+ * behavior, or for example inherit Struct that has useful definitions for these.
*
* A typical implementation of <code>hash</code> is based on the
* object's data while <code>eql?</code> is usually aliased to the overridden
@@ -6929,7 +6891,7 @@ static const rb_data_type_t env_data_type = {
* alias eql? ==
*
* def hash
- * @author.hash ^ @title.hash # XOR
+ * [self.class, @author, @title].hash
* end
* end
*
@@ -6987,7 +6949,7 @@ static const rb_data_type_t env_data_type = {
*
* To use a mutable object as default, it is recommended to use a default proc
*
- * ==== Default \Proc
+ * ==== Default Proc
*
* When the default proc for a \Hash is set (i.e., not +nil+),
* the default value returned by method #[] is determined by the default proc alone.
@@ -7088,7 +7050,7 @@ static const rb_data_type_t env_data_type = {
* - #<=: Returns whether +self+ is a subset of a given object.
* - #==: Returns whether a given object is equal to +self+.
* - #>: Returns whether +self+ is a proper superset of a given object
- * - #>=: Returns whether +self+ is a proper superset of a given object.
+ * - #>=: Returns whether +self+ is a superset of a given object.
*
* ==== Methods for Fetching
*
@@ -7101,7 +7063,7 @@ static const rb_data_type_t env_data_type = {
* - #key: Returns the key for the first-found entry with a given value.
* - #keys: Returns an array containing all keys in +self+.
* - #rassoc: Returns a 2-element array consisting of the key and value
- of the first-found entry having a given value.
+ * of the first-found entry having a given value.
* - #values: Returns an array containing all values in +self+/
* - #values_at: Returns an array containing values for given keys.
*
@@ -7266,15 +7228,15 @@ Init_Hash(void)
/* Document-class: ENV
*
- * ENV is a hash-like accessor for environment variables.
+ * \ENV is a hash-like accessor for environment variables.
*
* === Interaction with the Operating System
*
- * The ENV object interacts with the operating system's environment variables:
+ * The \ENV object interacts with the operating system's environment variables:
*
- * - When you get the value for a name in ENV, the value is retrieved from among the current environment variables.
- * - When you create or set a name-value pair in ENV, the name and value are immediately set in the environment variables.
- * - When you delete a name-value pair in ENV, it is immediately deleted from the environment variables.
+ * - When you get the value for a name in \ENV, the value is retrieved from among the current environment variables.
+ * - When you create or set a name-value pair in \ENV, the name and value are immediately set in the environment variables.
+ * - When you delete a name-value pair in \ENV, it is immediately deleted from the environment variables.
*
* === Names and Values
*
@@ -7324,24 +7286,24 @@ Init_Hash(void)
*
* === About Ordering
*
- * ENV enumerates its name/value pairs in the order found
+ * \ENV enumerates its name/value pairs in the order found
* in the operating system's environment variables.
- * Therefore the ordering of ENV content is OS-dependent, and may be indeterminate.
+ * Therefore the ordering of \ENV content is OS-dependent, and may be indeterminate.
*
* This will be seen in:
- * - A Hash returned by an ENV method.
- * - An Enumerator returned by an ENV method.
+ * - A Hash returned by an \ENV method.
+ * - An Enumerator returned by an \ENV method.
* - An Array returned by ENV.keys, ENV.values, or ENV.to_a.
* - The String returned by ENV.inspect.
* - The Array returned by ENV.shift.
* - The name returned by ENV.key.
*
* === About the Examples
- * Some methods in ENV return ENV itself. Typically, there are many environment variables.
- * It's not useful to display a large ENV in the examples here,
- * so most example snippets begin by resetting the contents of ENV:
- * - ENV.replace replaces ENV with a new collection of entries.
- * - ENV.clear empties ENV.
+ * Some methods in \ENV return \ENV itself. Typically, there are many environment variables.
+ * It's not useful to display a large \ENV in the examples here,
+ * so most example snippets begin by resetting the contents of \ENV:
+ * - ENV.replace replaces \ENV with a new collection of entries.
+ * - ENV.clear empties \ENV.
*
* == What's Here
*
@@ -7401,8 +7363,8 @@ Init_Hash(void)
* - ::except: Returns a hash of all name/value pairs except those given.
* - ::fetch: Returns the value for the given name.
* - ::inspect: Returns the contents of \ENV as a string.
- * - ::invert: Returns a hash whose keys are the ENV values,
- and whose values are the corresponding ENV names.
+ * - ::invert: Returns a hash whose keys are the \ENV values,
+ and whose values are the corresponding \ENV names.
* - ::keys: Returns an array of all names.
* - ::rassoc: Returns the name and value of the first found entry
* that has the given value.
@@ -7491,7 +7453,7 @@ Init_Hash(void)
rb_undef_method(envtbl_class, "initialize_dup");
/*
- * ENV is a Hash-like accessor for environment variables.
+ * \ENV is a Hash-like accessor for environment variables.
*
* See ENV (the class) for more details.
*/
diff --git a/id_table.c b/id_table.c
index a9a041b955..650721c670 100644
--- a/id_table.c
+++ b/id_table.c
@@ -92,7 +92,7 @@ rb_id_table_init(struct rb_id_table *tbl, int capa)
return tbl;
}
-MJIT_FUNC_EXPORTED struct rb_id_table *
+struct rb_id_table *
rb_id_table_create(size_t capa)
{
struct rb_id_table *tbl = ALLOC(struct rb_id_table);
@@ -223,7 +223,7 @@ hash_table_show(struct rb_id_table *tbl)
}
#endif
-MJIT_FUNC_EXPORTED int
+int
rb_id_table_lookup(struct rb_id_table *tbl, ID id, VALUE *valp)
{
id_key_t key = id2key(id);
@@ -253,7 +253,7 @@ rb_id_table_insert_key(struct rb_id_table *tbl, const id_key_t key, const VALUE
return TRUE;
}
-MJIT_FUNC_EXPORTED int
+int
rb_id_table_insert(struct rb_id_table *tbl, ID id, VALUE val)
{
return rb_id_table_insert_key(tbl, id2key(id), val);
diff --git a/include/ruby/atomic.h b/include/ruby/atomic.h
index 3eb80fbf7d..eb106631f6 100644
--- a/include/ruby/atomic.h
+++ b/include/ruby/atomic.h
@@ -139,6 +139,15 @@ typedef unsigned int rb_atomic_t;
rbimpl_atomic_cas(&(var), (oldval), (newval))
/**
+ * Atomic load. This loads `var` with an atomic intrinsic and returns
+ * its value.
+ *
+ * @param var A variable of ::rb_atomic_t
+ * @return What was stored in `var`j
+ */
+#define RUBY_ATOMIC_LOAD(var) rbimpl_atomic_load(&(var))
+
+/**
* Identical to #RUBY_ATOMIC_EXCHANGE, except for the return type.
*
* @param var A variable of ::rb_atomic_t.
@@ -280,6 +289,17 @@ typedef unsigned int rb_atomic_t;
RBIMPL_CAST(rbimpl_atomic_ptr_exchange((void **)&(var), (void *)val))
/**
+ * Identical to #RUBY_ATOMIC_LOAD, except it expects its arguments are `void*`.
+ * There are cases where ::rb_atomic_t is 32bit while `void*` is 64bit. This
+ * should be used for size related operations to support such platforms.
+ *
+ * @param var A variable of `void*`
+ * @return The value of `var` (without tearing)
+ */
+#define RUBY_ATOMIC_PTR_LOAD(var) \
+ RBIMPL_CAST(rbimpl_atomic_ptr_load((void **)&var))
+
+/**
* Identical to #RUBY_ATOMIC_CAS, except it expects its arguments are `void*`.
* There are cases where ::rb_atomic_t is 32bit while `void*` is 64bit. This
* should be used for size related operations to support such platforms.
@@ -749,6 +769,21 @@ rbimpl_atomic_value_exchange(volatile VALUE *ptr, VALUE val)
RBIMPL_ATTR_ARTIFICIAL()
RBIMPL_ATTR_NOALIAS()
RBIMPL_ATTR_NONNULL((1))
+static inline rb_atomic_t
+rbimpl_atomic_load(volatile rb_atomic_t *ptr)
+{
+#if 0
+
+#elif defined(HAVE_GCC_ATOMIC_BUILTINS)
+ return __atomic_load_n(ptr, __ATOMIC_SEQ_CST);
+#else
+ return rbimpl_atomic_fetch_add(ptr, 0);
+#endif
+}
+
+RBIMPL_ATTR_ARTIFICIAL()
+RBIMPL_ATTR_NOALIAS()
+RBIMPL_ATTR_NONNULL((1))
static inline void
rbimpl_atomic_set(volatile rb_atomic_t *ptr, rb_atomic_t val)
{
@@ -875,6 +910,22 @@ rbimpl_atomic_ptr_cas(void **ptr, const void *oldval, const void *newval)
RBIMPL_ATTR_ARTIFICIAL()
RBIMPL_ATTR_NOALIAS()
RBIMPL_ATTR_NONNULL((1))
+static inline void *
+rbimpl_atomic_ptr_load(void **ptr)
+{
+#if 0
+
+#elif defined(HAVE_GCC_ATOMIC_BUILTINS)
+ return __atomic_load_n(ptr, __ATOMIC_SEQ_CST);
+#else
+ void *val = *ptr;
+ return rbimpl_atomic_ptr_cas(ptr, val, val);
+#endif
+}
+
+RBIMPL_ATTR_ARTIFICIAL()
+RBIMPL_ATTR_NOALIAS()
+RBIMPL_ATTR_NONNULL((1))
static inline VALUE
rbimpl_atomic_value_cas(volatile VALUE *ptr, VALUE oldval, VALUE newval)
{
diff --git a/include/ruby/backward/2/attributes.h b/include/ruby/backward/2/attributes.h
index 73acfc9dc0..916d9e9d5b 100644
--- a/include/ruby/backward/2/attributes.h
+++ b/include/ruby/backward/2/attributes.h
@@ -39,6 +39,7 @@
#include "ruby/internal/attr/noinline.h"
#include "ruby/internal/attr/nonnull.h"
#include "ruby/internal/attr/noreturn.h"
+#include "ruby/internal/attr/packed_struct.h"
#include "ruby/internal/attr/pure.h"
#include "ruby/internal/attr/restrict.h"
#include "ruby/internal/attr/returns_nonnull.h"
@@ -80,10 +81,8 @@
#undef NOINLINE
#define NOINLINE(x) RBIMPL_ATTR_NOINLINE() x
-#ifndef MJIT_HEADER
-# undef ALWAYS_INLINE
-# define ALWAYS_INLINE(x) RBIMPL_ATTR_FORCEINLINE() x
-#endif
+#undef ALWAYS_INLINE
+#define ALWAYS_INLINE(x) RBIMPL_ATTR_FORCEINLINE() x
#undef ERRORFUNC
#define ERRORFUNC(mesg, x) RBIMPL_ATTR_ERROR(mesg) x
@@ -147,17 +146,14 @@
#define NORETURN(x) RBIMPL_ATTR_NORETURN() x
#define NORETURN_STYLE_NEW
-#ifndef PACKED_STRUCT
-# define PACKED_STRUCT(x) x
-#endif
+#undef PACKED_STRUCT
+#define PACKED_STRUCT(x) \
+ RBIMPL_ATTR_PACKED_STRUCT_BEGIN() x RBIMPL_ATTR_PACKED_STRUCT_END()
-#ifndef PACKED_STRUCT_UNALIGNED
-# if UNALIGNED_WORD_ACCESS
-# define PACKED_STRUCT_UNALIGNED(x) PACKED_STRUCT(x)
-# else
-# define PACKED_STRUCT_UNALIGNED(x) x
-# endif
-#endif
+#undef PACKED_STRUCT_UNALIGNED
+#define PACKED_STRUCT_UNALIGNED(x) \
+ RBIMPL_ATTR_PACKED_STRUCT_UNALIGNED_BEGIN() x \
+ RBIMPL_ATTR_PACKED_STRUCT_UNALIGNED_END()
#undef RB_UNUSED_VAR
#define RB_UNUSED_VAR(x) x RBIMPL_ATTR_MAYBE_UNUSED()
diff --git a/include/ruby/debug.h b/include/ruby/debug.h
index f95acdb17e..f7c8e6ca8d 100644
--- a/include/ruby/debug.h
+++ b/include/ruby/debug.h
@@ -10,6 +10,7 @@
* modify this file, provided that the conditions mentioned in the
* file COPYING are met. Consult the file for details.
*/
+#include "ruby/internal/attr/deprecated.h"
#include "ruby/internal/attr/nonnull.h"
#include "ruby/internal/attr/returns_nonnull.h"
#include "ruby/internal/dllexport.h"
@@ -51,6 +52,25 @@ RBIMPL_ATTR_NONNULL((3))
int rb_profile_frames(int start, int limit, VALUE *buff, int *lines);
/**
+ * Queries mysterious "frame"s of the given range.
+ *
+ * A per-thread version of rb_profile_frames().
+ * Arguments and return values are the same with rb_profile_frames() with the
+ * exception of the first argument _thread_, which accepts the Thread to be
+ * profiled/queried.
+ *
+ * @param[in] thread The Ruby Thread to be profiled.
+ * @param[in] start Start position (0 means the topmost).
+ * @param[in] limit Number objects of `buff`.
+ * @param[out] buff Return buffer.
+ * @param[out] lines Return buffer.
+ * @return Number of objects filled into `buff`.
+ * @post `buff` is filled with backtrace pointers.
+ * @post `lines` is filled with `__LINE__` of each backtraces.
+ */
+int rb_profile_thread_frames(VALUE thread, int start, int limit, VALUE *buff, int *lines);
+
+/**
* Queries the path of the passed backtrace.
*
* @param[in] frame What rb_profile_frames() returned.
@@ -596,48 +616,157 @@ VALUE rb_tracearg_object(rb_trace_arg_t *trace_arg);
/*
* Postponed Job API
- * rb_postponed_job_register and rb_postponed_job_register_one are
- * async-signal-safe and used via SIGPROF by the "stackprof" RubyGem
+ *
+ * This API is designed to be called from contexts where it is not safe to run Ruby
+ * code (e.g. because they do not hold the GVL or because GC is in progress), and
+ * defer a callback to run in a context where it _is_ safe. The primary intended
+ * users of this API is for sampling profilers like the "stackprof" gem; these work
+ * by scheduling the periodic delivery of a SIGPROF signal, and inside the C-level
+ * signal handler, deferring a job to collect a Ruby backtrace when it is next safe
+ * to do so.
+ *
+ * Ruby maintains a small, fixed-size postponed job table. An extension using this
+ * API should first call `rb_postponed_job_preregister` to register a callback
+ * function in this table and obtain a handle of type `rb_postponed_job_handle_t`
+ * to it. Subsequently, the callback can be triggered by calling
+ * `rb_postponed_job_trigger` with that handle, or the `data` associated with the
+ * callback function can be changed by calling `rb_postponed_job_preregister` again.
+ *
+ * Because the postponed job table is quite small (it only has 32 entries on most
+ * common systems), extensions should generally only preregister one or two `func`
+ * values.
+ *
+ * Historically, this API provided two functions `rb_postponed_job_register` and
+ * `rb_postponed_job_register_one`, which claimed to be fully async-signal-safe and
+ * would call back the provided `func` and `data` at an appropriate time. However,
+ * these functions were subject to race conditions which could cause crashes when
+ * racing with Ruby's internal use of them. These two functions are still present,
+ * but are marked as deprecated and have slightly changed semantics:
+ *
+ * * rb_postponed_job_register now works like rb_postponed_job_register_one i.e.
+ * `func` will only be executed at most one time each time Ruby checks for
+ * interrupts, no matter how many times it is registered
+ * * They are also called with the last `data` to be registered, not the first
+ * (which is how rb_postponed_job_register_one previously worked)
*/
+
/**
* Type of postponed jobs.
*
- * @param[in,out] arg What was passed to rb_postponed_job_register().
+ * @param[in,out] arg What was passed to `rb_postponed_job_preregister`
*/
typedef void (*rb_postponed_job_func_t)(void *arg);
/**
- * Registers a postponed job.
+ * The type of a handle returned from `rb_postponed_job_preregister` and
+ * passed to `rb_postponed_job_trigger`
+ */
+typedef unsigned int rb_postponed_job_handle_t;
+#define POSTPONED_JOB_HANDLE_INVALID ((rb_postponed_job_handle_t)UINT_MAX)
+
+/**
+ * Pre-registers a func in Ruby's postponed job preregistration table,
+ * returning an opaque handle which can be used to trigger the job later. Generally,
+ * this function will be called during the initialization routine of an extension.
*
- * There are situations when running a ruby program is not possible. For
- * instance when a program is in a signal handler; for another instance when
- * the GC is busy. On such situations however, there might be needs to do
- * something. We cannot but defer such operations until we are 100% sure it is
- * safe to execute them. This mechanism is called postponed jobs. This
- * function registers a new one. The registered job would eventually gets
- * executed.
+ * The returned handle can be used later to call `rb_postponed_job_trigger`. This will
+ * cause Ruby to call back into the registered `func` with `data` at a later time, in
+ * a context where the GVL is held and it is safe to perform Ruby allocations.
*
- * @param[in] flags (Unused) reserved for future extensions.
+ * If the given `func` was already pre-registered, this function will overwrite the
+ * stored data with the newly passed data, and return the same handle instance as
+ * was previously returned.
+ *
+ * If this function is called concurrently with the same `func`, then the stored data
+ * could be the value from either call (but will definitely be one of them).
+ *
+ * If this function is called to update the data concurrently with a call to
+ * `rb_postponed_job_trigger` on the same handle, it's undefined whether `func` will
+ * be called with the old data or the new data.
+ *
+ * Although the current implementation of this function is in fact async-signal-safe and
+ * has defined semantics when called concurrently on the same `func`, a future Ruby
+ * version might require that this method be called under the GVL; thus, programs which
+ * aim to be forward-compatible should call this method whilst holding the GVL.
+ *
+ * @param[in] flags Unused and ignored
+ * @param[in] func The function to be pre-registered
+ * @param[in] data The data to be pre-registered
+ * @retval POSTPONED_JOB_HANDLE_INVALID The job table is full; this registration
+ * did not succeed and no further registration will do so for
+ * the lifetime of the program.
+ * @retval otherwise A handle which can be passed to `rb_postponed_job_trigger`
+ */
+rb_postponed_job_handle_t rb_postponed_job_preregister(unsigned int flags, rb_postponed_job_func_t func, void *data);
+
+/**
+ * Triggers a pre-registered job registered with rb_postponed_job_preregister,
+ * scheduling it for execution the next time the Ruby VM checks for interrupts.
+ * The context in which the job is called in holds the GVL and is safe to perform
+ * Ruby allocations within (i.e. it is not during GC).
+ *
+ * This method is async-signal-safe and can be called from any thread, at any
+ * time, including in signal handlers.
+ *
+ * If this method is called multiple times, Ruby will coalesce this into only
+ * one call to the job the next time it checks for interrupts.
+ *
+ * @params[in] h A handle returned from rb_postponed_job_preregister
+ */
+void rb_postponed_job_trigger(rb_postponed_job_handle_t h);
+
+/**
+ * Schedules the given `func` to be called with `data` when Ruby next checks for
+ * interrupts. If this function is called multiple times in between Ruby checking
+ * for interrupts, then `func` will be called only once with the `data` value from
+ * the first call to this function.
+ *
+ * Like `rb_postponed_job_trigger`, the context in which the job is called
+ * holds the GVL and can allocate Ruby objects.
+ *
+ * This method essentially has the same semantics as:
+ *
+ * ```
+ * rb_postponed_job_trigger(rb_postponed_job_preregister(func, data));
+ * ```
+ *
+ * @note Previous versions of Ruby promised that the (`func`, `data`) pairs would
+ * be executed as many times as they were registered with this function; in
+ * reality this was always subject to race conditions and this function no
+ * longer provides this guarantee. Instead, multiple calls to this function
+ * can be coalesced into a single execution of the passed `func`, with the
+ * most recent `data` registered at that time passed in.
+ *
+ * @deprecated This interface implies that arbitrarily many `func`'s can be enqueued
+ * over the lifetime of the program, whilst in reality the registration
+ * slots for postponed jobs are a finite resource. This is made clearer
+ * by the `rb_postponed_job_preregister` and `rb_postponed_job_trigger`
+ * functions, and a future version of Ruby might delete this function.
+ *
+ * @param[in] flags Unused and ignored.
* @param[in] func Job body.
* @param[in,out] data Passed as-is to `func`.
- * @retval 0 Postponed job buffer is full. Failed.
- * @retval otherwise Opaque return value.
- * @post The passed job is postponed.
+ * @retval 0 Postponed job registration table is full. Failed.
+ * @retval 1 Registration succeeded.
+ * @post The passed job will run on the next interrupt check.
*/
+ RBIMPL_ATTR_DEPRECATED(("use rb_postponed_job_preregister and rb_postponed_job_trigger"))
int rb_postponed_job_register(unsigned int flags, rb_postponed_job_func_t func, void *data);
/**
- * Identical to rb_postponed_job_register_one(), except it additionally checks
- * for duplicated registration. In case the passed job is already in the
- * postponed job buffer this function does nothing.
+ * Identical to `rb_postponed_job_register`
+ *
+ * @deprecated This is deprecated for the same reason as `rb_postponed_job_register`
*
- * @param[in] flags (Unused) reserved for future extensions.
+ * @param[in] flags Unused and ignored.
* @param[in] func Job body.
* @param[in,out] data Passed as-is to `func`.
- * @retval 0 Postponed job buffer is full. Failed.
- * @retval otherwise Opaque return value.
+ * @retval 0 Postponed job registration table is full. Failed.
+ * @retval 1 Registration succeeded.
+ * @post The passed job will run on the next interrupt check.
*/
+ RBIMPL_ATTR_DEPRECATED(("use rb_postponed_job_preregister and rb_postponed_job_trigger"))
int rb_postponed_job_register_one(unsigned int flags, rb_postponed_job_func_t func, void *data);
/** @} */
diff --git a/include/ruby/fiber/scheduler.h b/include/ruby/fiber/scheduler.h
index 250b39b6df..8f3d383330 100644
--- a/include/ruby/fiber/scheduler.h
+++ b/include/ruby/fiber/scheduler.h
@@ -97,7 +97,7 @@ VALUE rb_fiber_scheduler_get(void);
* current thread will call scheduler's `#close` method on finalisation
* (allowing the scheduler to properly manage all non-finished fibers).
* `scheduler` can be an object of any class corresponding to
- * `Fiber::SchedulerInterface`. Its implementation is up to the user.
+ * `Fiber::Scheduler` interface. Its implementation is up to the user.
*
* @param[in] scheduler The scheduler to set.
* @exception rb_eArgError `scheduler` does not conform the interface.
@@ -267,10 +267,10 @@ VALUE rb_fiber_scheduler_io_selectv(VALUE scheduler, int argc, VALUE *argv);
* Non-blocking read from the passed IO.
*
* @param[in] scheduler Target scheduler.
- * @param[out] io An io object to read from.
- * @param[out] buffer Return buffer.
- * @param[in] length Requested number of bytes to read.
- * @param[in] offset The offset in the buffer to read to.
+ * @param[in] io An io object to read from.
+ * @param[in] buffer The buffer to read to.
+ * @param[in] length The minimum number of bytes to read.
+ * @param[in] offset The offset in the buffer to read from.
* @retval RUBY_Qundef `scheduler` doesn't have `#io_read`.
* @return otherwise What `scheduler.io_read` returns `[-errno, size]`.
*/
@@ -280,9 +280,9 @@ VALUE rb_fiber_scheduler_io_read(VALUE scheduler, VALUE io, VALUE buffer, size_t
* Non-blocking write to the passed IO.
*
* @param[in] scheduler Target scheduler.
- * @param[out] io An io object to write to.
- * @param[in] buffer What to write.
- * @param[in] length Number of bytes to write.
+ * @param[in] io An io object to write to.
+ * @param[in] buffer The buffer to write from.
+ * @param[in] length The minimum number of bytes to write.
* @param[in] offset The offset in the buffer to write from.
* @retval RUBY_Qundef `scheduler` doesn't have `#io_write`.
* @return otherwise What `scheduler.io_write` returns `[-errno, size]`.
@@ -293,10 +293,10 @@ VALUE rb_fiber_scheduler_io_write(VALUE scheduler, VALUE io, VALUE buffer, size_
* Non-blocking read from the passed IO at the specified offset.
*
* @param[in] scheduler Target scheduler.
- * @param[out] io An io object to read from.
- * @param[in] from The offset in the given IO to read the data from.
- * @param[out] buffer The buffer to read the data to.
- * @param[in] length Requested number of bytes to read.
+ * @param[in] io An io object to read from.
+ * @param[in] from The offset to read from.
+ * @param[in] buffer The buffer to read to.
+ * @param[in] length The minimum number of bytes to read.
* @param[in] offset The offset in the buffer to read to.
* @retval RUBY_Qundef `scheduler` doesn't have `#io_read`.
* @return otherwise What `scheduler.io_read` returns.
@@ -307,10 +307,10 @@ VALUE rb_fiber_scheduler_io_pread(VALUE scheduler, VALUE io, rb_off_t from, VALU
* Non-blocking write to the passed IO at the specified offset.
*
* @param[in] scheduler Target scheduler.
- * @param[out] io An io object to write to.
- * @param[in] from The offset in the given IO to write the data to.
- * @param[in] buffer The buffer to write the data from.
- * @param[in] length Number of bytes to write.
+ * @param[in] io An io object to write to.
+ * @param[in] from The offset to write to.
+ * @param[in] buffer The buffer to write from.
+ * @param[in] length The minimum number of bytes to write.
* @param[in] offset The offset in the buffer to write from.
* @retval RUBY_Qundef `scheduler` doesn't have `#io_write`.
* @return otherwise What `scheduler.io_write` returns.
@@ -321,27 +321,55 @@ VALUE rb_fiber_scheduler_io_pwrite(VALUE scheduler, VALUE io, rb_off_t from, VAL
* Non-blocking read from the passed IO using a native buffer.
*
* @param[in] scheduler Target scheduler.
- * @param[out] io An io object to read from.
- * @param[out] buffer Return buffer.
- * @param[in] size Size of the return buffer.
- * @param[in] length Requested number of bytes to read.
+ * @param[in] io An io object to read from.
+ * @param[in] base The memory to read to.
+ * @param[in] size Size of the memory.
+ * @param[in] length The minimum number of bytes to read.
* @retval RUBY_Qundef `scheduler` doesn't have `#io_read`.
* @return otherwise What `scheduler.io_read` returns.
*/
-VALUE rb_fiber_scheduler_io_read_memory(VALUE scheduler, VALUE io, void *buffer, size_t size, size_t length);
+VALUE rb_fiber_scheduler_io_read_memory(VALUE scheduler, VALUE io, void *base, size_t size, size_t length);
/**
* Non-blocking write to the passed IO using a native buffer.
*
* @param[in] scheduler Target scheduler.
- * @param[out] io An io object to write to.
- * @param[in] buffer What to write.
- * @param[in] size Size of the buffer.
- * @param[in] length Number of bytes to write.
+ * @param[in] io An io object to write to.
+ * @param[in] base The memory to write from.
+ * @param[in] size Size of the memory.
+ * @param[in] length The minimum number of bytes to write.
+ * @retval RUBY_Qundef `scheduler` doesn't have `#io_write`.
+ * @return otherwise What `scheduler.io_write` returns.
+ */
+VALUE rb_fiber_scheduler_io_write_memory(VALUE scheduler, VALUE io, const void *base, size_t size, size_t length);
+
+/**
+ * Non-blocking pread from the passed IO using a native buffer.
+ *
+ * @param[in] scheduler Target scheduler.
+ * @param[in] io An io object to read from.
+ * @param[in] from The offset to read from.
+ * @param[in] base The memory to read to.
+ * @param[in] size Size of the memory.
+ * @param[in] length The minimum number of bytes to read.
+ * @retval RUBY_Qundef `scheduler` doesn't have `#io_read`.
+ * @return otherwise What `scheduler.io_read` returns.
+ */
+VALUE rb_fiber_scheduler_io_pread_memory(VALUE scheduler, VALUE io, rb_off_t from, void *base, size_t size, size_t length);
+
+/**
+ * Non-blocking pwrite to the passed IO using a native buffer.
+ *
+ * @param[in] scheduler Target scheduler.
+ * @param[in] io An io object to write to.
+ * @param[in] from The offset to write from.
+ * @param[in] base The memory to write from.
+ * @param[in] size Size of the memory.
+ * @param[in] length The minimum number of bytes to write.
* @retval RUBY_Qundef `scheduler` doesn't have `#io_write`.
* @return otherwise What `scheduler.io_write` returns.
*/
-VALUE rb_fiber_scheduler_io_write_memory(VALUE scheduler, VALUE io, const void *buffer, size_t size, size_t length);
+VALUE rb_fiber_scheduler_io_pwrite_memory(VALUE scheduler, VALUE io, rb_off_t from, const void *base, size_t size, size_t length);
/**
* Non-blocking close the given IO.
diff --git a/include/ruby/intern.h b/include/ruby/intern.h
index 2480e2e703..48e4cd546e 100644
--- a/include/ruby/intern.h
+++ b/include/ruby/intern.h
@@ -36,7 +36,6 @@
#include "ruby/internal/intern/error.h"
#include "ruby/internal/intern/eval.h"
#include "ruby/internal/intern/file.h"
-#include "ruby/internal/intern/gc.h"
#include "ruby/internal/intern/hash.h"
#include "ruby/internal/intern/io.h"
#include "ruby/internal/intern/load.h"
diff --git a/include/ruby/internal/attr/noexcept.h b/include/ruby/internal/attr/noexcept.h
index ea3001df2a..7c3f92f1e7 100644
--- a/include/ruby/internal/attr/noexcept.h
+++ b/include/ruby/internal/attr/noexcept.h
@@ -54,7 +54,7 @@
* get smarter and smarter. Today they can infer if it actually throws
* or not without any annotations by humans (correct me if I'm wrong).
*
- * - When an inline function attributed `noexcepr` actually _does_ throw an
+ * - When an inline function attributed `noexcept` actually _does_ throw an
* exception: they have to call `std::terminate` then (C++ standard
* mandates so). This means exception handling routines are actually
* enforced, not omitted. This doesn't impact runtime performance (The
diff --git a/include/ruby/internal/attr/packed_struct.h b/include/ruby/internal/attr/packed_struct.h
new file mode 100644
index 0000000000..0678b9acc8
--- /dev/null
+++ b/include/ruby/internal/attr/packed_struct.h
@@ -0,0 +1,43 @@
+#ifndef RBIMPL_ATTR_PACKED_STRUCT_H /*-*-C++-*-vi:se ft=cpp:*/
+#define RBIMPL_ATTR_PACKED_STRUCT_H
+/**
+ * @file
+ * @author Ruby developers <ruby-core@ruby-lang.org>
+ * @copyright This file is a part of the programming language Ruby.
+ * Permission is hereby granted, to either redistribute and/or
+ * modify this file, provided that the conditions mentioned in the
+ * file COPYING are met. Consult the file for details.
+ * @warning Symbols prefixed with either `RBIMPL` or `rbimpl` are
+ * implementation details. Don't take them as canon. They could
+ * rapidly appear then vanish. The name (path) of this header file
+ * is also an implementation detail. Do not expect it to persist
+ * at the place it is now. Developers are free to move it anywhere
+ * anytime at will.
+ * @note To ruby-core: remember that this header can be possibly
+ * recursively included from extension libraries written in C++.
+ * Do not expect for instance `__VA_ARGS__` is always available.
+ * We assume C99 for ruby itself but we don't assume languages of
+ * extension libraries. They could be written in C++98.
+ * @brief Defines #RBIMPL_ATTR_PACKED_STRUCT_BEGIN,
+ * #RBIMPL_ATTR_PACKED_STRUCT_END,
+ * #RBIMPL_ATTR_PACKED_STRUCT_UNALIGNED_BEGIN, and
+ * #RBIMPL_ATTR_PACKED_STRUCT_UNALIGNED_END.
+ */
+#include "ruby/internal/config.h"
+
+#ifndef RBIMPL_ATTR_PACKED_STRUCT_BEGIN
+# define RBIMPL_ATTR_PACKED_STRUCT_BEGIN() /* void */
+#endif
+#ifndef RBIMPL_ATTR_PACKED_STRUCT_END
+# define RBIMPL_ATTR_PACKED_STRUCT_END() /* void */
+#endif
+
+#if UNALIGNED_WORD_ACCESS
+# define RBIMPL_ATTR_PACKED_STRUCT_UNALIGNED_BEGIN() RBIMPL_ATTR_PACKED_STRUCT_BEGIN()
+# define RBIMPL_ATTR_PACKED_STRUCT_UNALIGNED_END() RBIMPL_ATTR_PACKED_STRUCT_END()
+#else
+# define RBIMPL_ATTR_PACKED_STRUCT_UNALIGNED_BEGIN() /* void */
+# define RBIMPL_ATTR_PACKED_STRUCT_UNALIGNED_END() /* void */
+#endif
+
+#endif
diff --git a/include/ruby/internal/config.h b/include/ruby/internal/config.h
index aa63376d7c..da070f0979 100644
--- a/include/ruby/internal/config.h
+++ b/include/ruby/internal/config.h
@@ -148,8 +148,4 @@
# undef RBIMPL_TEST3
#endif /* HAVE_VA_ARGS_MACRO */
-#ifndef USE_RVARGC
-# define USE_RVARGC 1
-#endif
-
#endif /* RBIMPL_CONFIG_H */
diff --git a/include/ruby/internal/core/rarray.h b/include/ruby/internal/core/rarray.h
index c3bb40be25..90690fe794 100644
--- a/include/ruby/internal/core/rarray.h
+++ b/include/ruby/internal/core/rarray.h
@@ -29,25 +29,13 @@
#include "ruby/internal/core/rbasic.h"
#include "ruby/internal/dllexport.h"
#include "ruby/internal/fl_type.h"
-#include "ruby/internal/rgengc.h"
+#include "ruby/internal/gc.h"
#include "ruby/internal/stdbool.h"
#include "ruby/internal/value.h"
#include "ruby/internal/value_type.h"
#include "ruby/assert.h"
/**
- * @private
- * @warning Do not touch this macro.
- * @warning It is an implementation detail.
- * @warning The value of this macro must match for ruby itself and all
- * extension libraries, otherwise serious memory corruption shall
- * occur.
- */
-#ifndef USE_TRANSIENT_HEAP
-# define USE_TRANSIENT_HEAP 1
-#endif
-
-/**
* Convenient casting macro.
*
* @param obj An object, which is in fact an ::RArray.
@@ -59,15 +47,9 @@
#define RARRAY_EMBED_LEN_MASK RARRAY_EMBED_LEN_MASK
#define RARRAY_EMBED_LEN_MAX RARRAY_EMBED_LEN_MAX
#define RARRAY_EMBED_LEN_SHIFT RARRAY_EMBED_LEN_SHIFT
-#if USE_TRANSIENT_HEAP
-# define RARRAY_TRANSIENT_FLAG RARRAY_TRANSIENT_FLAG
-#else
-# define RARRAY_TRANSIENT_FLAG 0
-#endif
/** @endcond */
#define RARRAY_LEN rb_array_len /**< @alias{rb_array_len} */
#define RARRAY_CONST_PTR rb_array_const_ptr /**< @alias{rb_array_const_ptr} */
-#define RARRAY_CONST_PTR_TRANSIENT rb_array_const_ptr_transient /**< @alias{rb_array_const_ptr_transient} */
/** @cond INTERNAL_MACRO */
#if defined(__fcc__) || defined(__fcc_version) || \
@@ -80,7 +62,6 @@
#define RARRAY_EMBED_LEN RARRAY_EMBED_LEN
#define RARRAY_LENINT RARRAY_LENINT
-#define RARRAY_TRANSIENT_P RARRAY_TRANSIENT_P
#define RARRAY_ASET RARRAY_ASET
#define RARRAY_PTR RARRAY_PTR
/** @endcond */
@@ -130,30 +111,8 @@ enum ruby_rarray_flags {
* 3rd parties must not be aware that there even is more than one way to
* store array elements. It was a bad idea to expose this to them.
*/
-#if USE_RVARGC
RARRAY_EMBED_LEN_MASK = RUBY_FL_USER9 | RUBY_FL_USER8 | RUBY_FL_USER7 | RUBY_FL_USER6 |
RUBY_FL_USER5 | RUBY_FL_USER4 | RUBY_FL_USER3
-#else
- RARRAY_EMBED_LEN_MASK = RUBY_FL_USER4 | RUBY_FL_USER3
-#endif
-
-#if USE_TRANSIENT_HEAP
- ,
-
- /**
- * This flag has something to do with an array's "transiency". A transient
- * array is an array of young generation (of generational GC), who stores
- * its elements inside of dedicated memory pages called a transient heap.
- * Not every young generation share that storage scheme, but elder
- * generations must no join.
- *
- * @internal
- *
- * 3rd parties must not be aware that there even is more than one way to
- * store array elements. It was a bad idea to expose this to them.
- */
- RARRAY_TRANSIENT_FLAG = RUBY_FL_USER13
-#endif
};
/**
@@ -163,13 +122,6 @@ enum ruby_rarray_flags {
enum ruby_rarray_consts {
/** Where ::RARRAY_EMBED_LEN_MASK resides. */
RARRAY_EMBED_LEN_SHIFT = RUBY_FL_USHIFT + 3
-
-#if !USE_RVARGC
- ,
-
- /** Max possible number elements that can be embedded. */
- RARRAY_EMBED_LEN_MAX = RBIMPL_EMBED_LEN_MAX_OF(VALUE)
-#endif
};
/** Ruby's array. */
@@ -228,16 +180,12 @@ struct RArray {
* to store its elements. In this case the length is encoded into the
* flags.
*/
-#if USE_RVARGC
/* This is a length 1 array because:
* 1. GCC has a bug that does not optimize C flexible array members
* (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102452)
* 2. Zero length arrays are not supported by all compilers
*/
const VALUE ary[1];
-#else
- const VALUE ary[RARRAY_EMBED_LEN_MAX];
-#endif
} as;
};
@@ -264,16 +212,6 @@ VALUE *rb_ary_ptr_use_start(VALUE ary);
*/
void rb_ary_ptr_use_end(VALUE a);
-#if USE_TRANSIENT_HEAP
-/**
- * Destructively converts an array of transient backend into ordinal one.
- *
- * @param[out] a An object of ::RArray.
- * @pre `a` must be a transient array.
- * @post `a` gets out of transient heap, destructively.
- */
-void rb_ary_detransient(VALUE a);
-#endif
RBIMPL_SYMBOL_EXPORT_END()
RBIMPL_ATTR_PURE_UNLESS_DEBUG()
@@ -346,33 +284,6 @@ RARRAY_LENINT(VALUE ary)
}
RBIMPL_ATTR_PURE_UNLESS_DEBUG()
-RBIMPL_ATTR_ARTIFICIAL()
-/**
- * Queries if the array is a transient array.
- *
- * @param[in] ary Array in question.
- * @retval true Yes it is.
- * @retval false No it isn't.
- * @pre `ary` must be an instance of ::RArray.
- *
- * @internal
- *
- * @shyouhei doesn't understand the benefit of this function called from
- * extension libraries.
- */
-static inline bool
-RARRAY_TRANSIENT_P(VALUE ary)
-{
- RBIMPL_ASSERT_TYPE(ary, RUBY_T_ARRAY);
-
-#if USE_TRANSIENT_HEAP
- return RB_FL_ANY_RAW(ary, RARRAY_TRANSIENT_FLAG);
-#else
- return false;
-#endif
-}
-
-RBIMPL_ATTR_PURE_UNLESS_DEBUG()
/**
* @private
*
@@ -383,7 +294,7 @@ RBIMPL_ATTR_PURE_UNLESS_DEBUG()
* @return Its backend storage.
*/
static inline const VALUE *
-rb_array_const_ptr_transient(VALUE a)
+rb_array_const_ptr(VALUE a)
{
RBIMPL_ASSERT_TYPE(a, RUBY_T_ARRAY);
@@ -395,102 +306,21 @@ rb_array_const_ptr_transient(VALUE a)
}
}
-#if ! USE_TRANSIENT_HEAP
-RBIMPL_ATTR_PURE_UNLESS_DEBUG()
-#endif
-/**
- * @private
- *
- * This is an implementation detail of RARRAY_PTR(). People do not use it
- * directly.
- *
- * @param[in] a An object of ::RArray.
- * @return Its backend storage.
- * @post `a` is not a transient array.
- */
-static inline const VALUE *
-rb_array_const_ptr(VALUE a)
-{
- RBIMPL_ASSERT_TYPE(a, RUBY_T_ARRAY);
-
-#if USE_TRANSIENT_HEAP
- if (RARRAY_TRANSIENT_P(a)) {
- rb_ary_detransient(a);
- }
-#endif
- return rb_array_const_ptr_transient(a);
-}
-
-/**
- * @private
- *
- * This is an implementation detail of #RARRAY_PTR_USE. People do not use it
- * directly.
- *
- * @param[in] a An object of ::RArray.
- * @param[in] allow_transient Whether `a` can be transient or not.
- * @return Its backend storage.
- * @post `a` is not a transient array unless `allow_transient`.
- */
-static inline VALUE *
-rb_array_ptr_use_start(VALUE a,
- RBIMPL_ATTR_MAYBE_UNUSED()
- int allow_transient)
-{
- RBIMPL_ASSERT_TYPE(a, RUBY_T_ARRAY);
-
-#if USE_TRANSIENT_HEAP
- if (!allow_transient) {
- if (RARRAY_TRANSIENT_P(a)) {
- rb_ary_detransient(a);
- }
- }
-#endif
-
- return rb_ary_ptr_use_start(a);
-}
-
-/**
- * @private
- *
- * This is an implementation detail of #RARRAY_PTR_USE. People do not use it
- * directly.
- *
- * @param[in] a An object of ::RArray.
- * @param[in] allow_transient Whether `a` can be transient or not.
- */
-static inline void
-rb_array_ptr_use_end(VALUE a,
- RBIMPL_ATTR_MAYBE_UNUSED()
- int allow_transient)
-{
- RBIMPL_ASSERT_TYPE(a, RUBY_T_ARRAY);
- rb_ary_ptr_use_end(a);
-}
-
/**
* @private
*
* This is an implementation detail of #RARRAY_PTR_USE. People do not use it
* directly.
*/
-#define RBIMPL_RARRAY_STMT(flag, ary, var, expr) do { \
+#define RBIMPL_RARRAY_STMT(ary, var, expr) do { \
RBIMPL_ASSERT_TYPE((ary), RUBY_T_ARRAY); \
const VALUE rbimpl_ary = (ary); \
- VALUE *var = rb_array_ptr_use_start(rbimpl_ary, (flag)); \
+ VALUE *var = rb_ary_ptr_use_start(rbimpl_ary); \
expr; \
- rb_array_ptr_use_end(rbimpl_ary, (flag)); \
+ rb_ary_ptr_use_end(rbimpl_ary); \
} while (0)
/**
- * @private
- *
- * This is an implementation detail of #RARRAY_PTR_USE. People do not use it
- * directly.
- */
-#define RARRAY_PTR_USE_END(a) rb_array_ptr_use_end(a, 0)
-
-/**
* Declares a section of code where raw pointers are used. In case you need to
* touch the raw C array instead of polite CAPIs, then that operation shall be
* wrapped using this macro.
@@ -516,21 +346,11 @@ rb_array_ptr_use_end(VALUE a,
* them use it... Maybe some transition path can be implemented later.
*/
#define RARRAY_PTR_USE(ary, ptr_name, expr) \
- RBIMPL_RARRAY_STMT(0, ary, ptr_name, expr)
-
-/**
- * Identical to #RARRAY_PTR_USE, except the pointer can be a transient one.
- *
- * @param ary An object of ::RArray.
- * @param ptr_name A variable name which points the C array in `expr`.
- * @param expr The expression that touches `ptr_name`.
- */
-#define RARRAY_PTR_USE_TRANSIENT(ary, ptr_name, expr) \
- RBIMPL_RARRAY_STMT(1, ary, ptr_name, expr)
+ RBIMPL_RARRAY_STMT(ary, ptr_name, expr)
/**
* Wild use of a C pointer. This function accesses the backend storage
- * directly. This is slower than #RARRAY_PTR_USE_TRANSIENT. It exercises
+ * directly. This is slower than #RARRAY_PTR_USE. It exercises
* extra manoeuvres to protect our generational GC. Use of this function is
* considered archaic. Use a modern way instead.
*
@@ -565,7 +385,7 @@ RARRAY_PTR(VALUE ary)
static inline void
RARRAY_ASET(VALUE ary, long i, VALUE v)
{
- RARRAY_PTR_USE_TRANSIENT(ary, ptr,
+ RARRAY_PTR_USE(ary, ptr,
RB_OBJ_WRITE(ary, &ptr[i], v));
}
@@ -580,6 +400,6 @@ RARRAY_ASET(VALUE ary, long i, VALUE v)
* remains as it is due to that. If we could warn such usages we can set a
* transition path, but currently no way is found to do so.
*/
-#define RARRAY_AREF(a, i) RARRAY_CONST_PTR_TRANSIENT(a)[i]
+#define RARRAY_AREF(a, i) RARRAY_CONST_PTR(a)[i]
#endif /* RBIMPL_RARRAY_H */
diff --git a/include/ruby/internal/core/rfile.h b/include/ruby/internal/core/rfile.h
index f8dddde9e5..a0eb8cb833 100644
--- a/include/ruby/internal/core/rfile.h
+++ b/include/ruby/internal/core/rfile.h
@@ -25,7 +25,7 @@
/* rb_io_t is in ruby/io.h. The header file has historically not been included
* into ruby/ruby.h. We follow that tradition. */
-struct rb_io_t;
+struct rb_io;
/**
* Ruby's File and IO. Ruby's IO are not just file descriptors. They have
@@ -38,7 +38,7 @@ struct RFile {
struct RBasic basic;
/** IO's specific fields. */
- struct rb_io_t *fptr;
+ struct rb_io *fptr;
};
/**
diff --git a/include/ruby/internal/core/rmatch.h b/include/ruby/internal/core/rmatch.h
index 2d2fd897f5..a528c2999e 100644
--- a/include/ruby/internal/core/rmatch.h
+++ b/include/ruby/internal/core/rmatch.h
@@ -68,7 +68,7 @@ struct rmatch_offset {
};
/** Represents a match. */
-struct rmatch {
+struct rb_matchext_struct {
/**
* "Registers" of a match. This is a quasi-opaque struct that holds
* execution result of a match. Roughly resembles `&~`.
@@ -82,6 +82,8 @@ struct rmatch {
int char_offset_num_allocated;
};
+typedef struct rb_matchext_struct rb_matchext_t;
+
/**
* Regular expression execution context. When a regular expression "matches"
* to a string, it generates capture groups etc. This struct holds that info.
@@ -102,16 +104,13 @@ struct RMatch {
VALUE str;
/**
- * The result of this match.
- */
- struct rmatch *rmatch;
-
- /**
* The expression of this match.
*/
VALUE regexp; /* RRegexp */
};
+#define RMATCH_EXT(m) ((rb_matchext_t *)((char *)(m) + sizeof(struct RMatch)))
+
RBIMPL_ATTR_PURE_UNLESS_DEBUG()
RBIMPL_ATTR_ARTIFICIAL()
/**
@@ -139,8 +138,7 @@ static inline struct re_registers *
RMATCH_REGS(VALUE match)
{
RBIMPL_ASSERT_TYPE(match, RUBY_T_MATCH);
- RBIMPL_ASSERT_OR_ASSUME(RMATCH(match)->rmatch != NULL);
- return &RMATCH(match)->rmatch->regs;
+ return &RMATCH_EXT(match)->regs;
}
#endif /* RBIMPL_RMATCH_H */
diff --git a/include/ruby/internal/core/robject.h b/include/ruby/internal/core/robject.h
index b1c2e1b0a9..c2bcae6306 100644
--- a/include/ruby/internal/core/robject.h
+++ b/include/ruby/internal/core/robject.h
@@ -74,17 +74,6 @@ enum ruby_robject_flags {
ROBJECT_EMBED = RUBY_FL_USER1
};
-#if !USE_RVARGC
-/**
- * This is an enum because GDB wants it (rather than a macro). People need not
- * bother.
- */
-enum ruby_robject_consts {
- /** Max possible number of instance variables that can be embedded. */
- ROBJECT_EMBED_LEN_MAX = RBIMPL_EMBED_LEN_MAX_OF(VALUE)
-};
-#endif
-
struct st_table;
/**
@@ -118,7 +107,6 @@ struct RObject {
struct rb_id_table *iv_index_tbl;
} heap;
-#if USE_RVARGC
/* Embedded instance variables. When an object is small enough, it
* uses this area to store the instance variables.
*
@@ -128,23 +116,9 @@ struct RObject {
* 2. Zero length arrays are not supported by all compilers
*/
VALUE ary[1];
-#else
- /**
- * Embedded instance variables. When an object is small enough, it
- * uses this area to store the instance variables.
- */
- VALUE ary[ROBJECT_EMBED_LEN_MAX];
-#endif
} as;
};
-/* Offsets for YJIT */
-#ifndef __cplusplus
-static const int32_t ROBJECT_OFFSET_AS_HEAP_IVPTR = offsetof(struct RObject, as.heap.ivptr);
-static const int32_t ROBJECT_OFFSET_AS_HEAP_IV_INDEX_TBL = offsetof(struct RObject, as.heap.iv_index_tbl);
-static const int32_t ROBJECT_OFFSET_AS_ARY = offsetof(struct RObject, as.ary);
-#endif
-
RBIMPL_ATTR_PURE_UNLESS_DEBUG()
RBIMPL_ATTR_ARTIFICIAL()
/**
diff --git a/include/ruby/internal/core/rstring.h b/include/ruby/internal/core/rstring.h
index e394ab7dca..0bca74e688 100644
--- a/include/ruby/internal/core/rstring.h
+++ b/include/ruby/internal/core/rstring.h
@@ -42,13 +42,7 @@
/** @cond INTERNAL_MACRO */
#define RSTRING_NOEMBED RSTRING_NOEMBED
-#if !USE_RVARGC
-#define RSTRING_EMBED_LEN_MASK RSTRING_EMBED_LEN_MASK
-#define RSTRING_EMBED_LEN_SHIFT RSTRING_EMBED_LEN_SHIFT
-#define RSTRING_EMBED_LEN_MAX RSTRING_EMBED_LEN_MAX
-#endif
#define RSTRING_FSTR RSTRING_FSTR
-#define RSTRING_EMBED_LEN RSTRING_EMBED_LEN
#define RSTRING_LEN RSTRING_LEN
#define RSTRING_LENINT RSTRING_LENINT
#define RSTRING_PTR RSTRING_PTR
@@ -162,21 +156,6 @@ enum ruby_rstring_flags {
*/
RSTRING_NOEMBED = RUBY_FL_USER1,
-#if !USE_RVARGC
- /**
- * When a string employs embedded strategy (see ::RSTRING_NOEMBED), these
- * bits are used to store the number of bytes actually filled into
- * ::RString::ary.
- *
- * @internal
- *
- * 3rd parties must not be aware that there even is more than one way to
- * store a string. Might better be hidden.
- */
- RSTRING_EMBED_LEN_MASK = RUBY_FL_USER2 | RUBY_FL_USER3 | RUBY_FL_USER4 |
- RUBY_FL_USER5 | RUBY_FL_USER6,
-#endif
-
/* Actually, string encodings are also encoded into the flags, using
* remaining bits.*/
@@ -202,20 +181,6 @@ enum ruby_rstring_flags {
RSTRING_FSTR = RUBY_FL_USER17
};
-#if !USE_RVARGC
-/**
- * This is an enum because GDB wants it (rather than a macro). People need not
- * bother.
- */
-enum ruby_rstring_consts {
- /** Where ::RSTRING_EMBED_LEN_MASK resides. */
- RSTRING_EMBED_LEN_SHIFT = RUBY_FL_USHIFT + 2,
-
- /** Max possible number of characters that can be embedded. */
- RSTRING_EMBED_LEN_MAX = RBIMPL_EMBED_LEN_MAX_OF(char) - 1
-};
-#endif
-
/**
* Ruby's String. A string in ruby conceptually has these information:
*
@@ -233,6 +198,13 @@ struct RString {
/** Basic part, including flags and class. */
struct RBasic basic;
+ /**
+ * Length of the string, not including terminating NUL character.
+ *
+ * @note This is in bytes.
+ */
+ long len;
+
/** String's specific fields. */
union {
@@ -241,14 +213,6 @@ struct RString {
* pattern.
*/
struct {
-
- /**
- * Length of the string, not including terminating NUL character.
- *
- * @note This is in bytes.
- */
- long len;
-
/**
* Pointer to the contents of the string. In the old days each
* string had dedicated memory regions. That is no longer true
@@ -279,24 +243,12 @@ struct RString {
/** Embedded contents. */
struct {
-#if USE_RVARGC
- long len;
/* This is a length 1 array because:
* 1. GCC has a bug that does not optimize C flexible array members
* (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102452)
* 2. Zero length arrays are not supported by all compilers
*/
char ary[1];
-#else
- /**
- * When a string is short enough, it uses this area to store the
- * contents themselves. This was impractical in the 20th century,
- * but these days 64 bit machines can typically hold 24 bytes here.
- * Could be sufficiently large. In this case the length is encoded
- * into the flags.
- */
- char ary[RSTRING_EMBED_LEN_MAX + 1];
-#endif
} embed;
} as;
};
@@ -409,31 +361,12 @@ RBIMPL_ATTR_ARTIFICIAL()
*
* @param[in] str String in question.
* @return Its length, in bytes.
- * @pre `str` must be an instance of ::RString, and must has its
- * ::RSTRING_NOEMBED flag off.
- *
- * @internal
- *
- * This was a macro before. It was inevitable to be public, since macros are
- * global constructs. But should it be forever? Now that it is a function,
- * @shyouhei thinks it could just be eliminated, hidden into implementation
- * details.
+ * @pre `str` must be an instance of ::RString.
*/
static inline long
-RSTRING_EMBED_LEN(VALUE str)
+RSTRING_LEN(VALUE str)
{
- RBIMPL_ASSERT_TYPE(str, RUBY_T_STRING);
- RBIMPL_ASSERT_OR_ASSUME(! RB_FL_ANY_RAW(str, RSTRING_NOEMBED));
-
-#if USE_RVARGC
- long f = RSTRING(str)->as.embed.len;
- return f;
-#else
- VALUE f = RBASIC(str)->flags;
- f &= RSTRING_EMBED_LEN_MASK;
- f >>= RSTRING_EMBED_LEN_SHIFT;
- return RBIMPL_CAST((long)f);
-#endif
+ return RSTRING(str)->len;
}
RBIMPL_WARNING_PUSH()
@@ -463,7 +396,7 @@ rbimpl_rstring_getmem(VALUE str)
else {
/* Expecting compilers to optimize this on-stack struct away. */
struct RString retval;
- retval.as.heap.len = RSTRING_EMBED_LEN(str);
+ retval.len = RSTRING_LEN(str);
retval.as.heap.ptr = RSTRING(str)->as.embed.ary;
return retval;
}
@@ -471,21 +404,6 @@ rbimpl_rstring_getmem(VALUE str)
RBIMPL_WARNING_POP()
-RBIMPL_ATTR_PURE_UNLESS_DEBUG()
-RBIMPL_ATTR_ARTIFICIAL()
-/**
- * Queries the length of the string.
- *
- * @param[in] str String in question.
- * @return Its length, in bytes.
- * @pre `str` must be an instance of ::RString.
- */
-static inline long
-RSTRING_LEN(VALUE str)
-{
- return rbimpl_rstring_getmem(str).as.heap.len;
-}
-
RBIMPL_ATTR_ARTIFICIAL()
/**
* Queries the contents pointer of the string.
@@ -499,13 +417,9 @@ RSTRING_PTR(VALUE str)
{
char *ptr = rbimpl_rstring_getmem(str).as.heap.ptr;
- if (RB_UNLIKELY(! ptr)) {
+ if (RUBY_DEBUG && RB_UNLIKELY(! ptr)) {
/* :BEWARE: @shyouhei thinks that currently, there are rooms for this
- * function to return NULL. In the 20th century that was a pointless
- * concern. However struct RString can hold fake strings nowadays. It
- * seems no check against NULL are exercised around handling of them
- * (one of such usages is located in marshal.c, which scares
- * @shyouhei). Better check here for maximum safety.
+ * function to return NULL. Better check here for maximum safety.
*
* Also, this is not rb_warn() because RSTRING_PTR() can be called
* during GC (see what obj_info() does). rb_warn() needs to allocate
@@ -529,12 +443,12 @@ RSTRING_END(VALUE str)
{
struct RString buf = rbimpl_rstring_getmem(str);
- if (RB_UNLIKELY(! buf.as.heap.ptr)) {
+ if (RUBY_DEBUG && RB_UNLIKELY(! buf.as.heap.ptr)) {
/* Ditto. */
rb_debug_rstring_null_ptr("RSTRING_END");
}
- return &buf.as.heap.ptr[buf.as.heap.len];
+ return &buf.as.heap.ptr[buf.len];
}
RBIMPL_ATTR_ARTIFICIAL()
@@ -568,7 +482,7 @@ RSTRING_LENINT(VALUE str)
__extension__ ({ \
struct RString rbimpl_str = rbimpl_rstring_getmem(str); \
(ptrvar) = rbimpl_str.as.heap.ptr; \
- (lenvar) = rbimpl_str.as.heap.len; \
+ (lenvar) = rbimpl_str.len; \
})
#else
# define RSTRING_GETMEM(str, ptrvar, lenvar) \
diff --git a/include/ruby/internal/core/rtypeddata.h b/include/ruby/internal/core/rtypeddata.h
index bbf208867d..6c19576c20 100644
--- a/include/ruby/internal/core/rtypeddata.h
+++ b/include/ruby/internal/core/rtypeddata.h
@@ -114,6 +114,8 @@
#define RUBY_TYPED_PROMOTED1 RUBY_TYPED_PROMOTED1
/** @endcond */
+#define TYPED_DATA_EMBEDDED 2
+
/**
* @private
*
@@ -137,6 +139,8 @@ rbimpl_typeddata_flags {
*/
RUBY_TYPED_FREE_IMMEDIATELY = 1,
+ RUBY_TYPED_EMBEDDABLE = 2,
+
/**
* This flag has something to do with Ractor. Multiple Ractors run without
* protecting each other. Sharing an object among Ractors is basically
@@ -173,10 +177,16 @@ rbimpl_typeddata_flags {
RUBY_TYPED_WB_PROTECTED = RUBY_FL_WB_PROTECTED, /* THIS FLAG DEPENDS ON Ruby version */
/**
- * This flag is mysterious. It seems nobody is currently using it. The
- * intention of this flag is also unclear. We need further investigations.
+ * This flag no longer in use
*/
- RUBY_TYPED_PROMOTED1 = RUBY_FL_PROMOTED1 /* THIS FLAG DEPENDS ON Ruby version */
+ RUBY_TYPED_UNUSED = RUBY_FL_UNUSED6,
+
+ /**
+ * This flag determines whether marking and compaction should be carried out
+ * using the dmark/dcompact callback functions or whether we should mark
+ * declaratively using a list of references defined inside the data struct we're wrapping
+ */
+ RUBY_TYPED_DECL_MARKING = RUBY_FL_USER2
};
/**
@@ -347,16 +357,14 @@ struct RTypedData {
* data. This roughly resembles a Ruby level class (apart from method
* definition etc.)
*/
- const rb_data_type_t *type;
+ const rb_data_type_t *const type;
/**
* This has to be always 1.
*
* @internal
- *
- * Why, then, this is not a const ::VALUE?
*/
- VALUE typed_flag;
+ const VALUE typed_flag;
/** Pointer to the actual C level struct that you want to wrap. */
void *data;
@@ -456,7 +464,7 @@ RBIMPL_SYMBOL_EXPORT_END()
*/
#define TypedData_Make_Struct0(result, klass, type, size, data_type, sval) \
VALUE result = rb_data_typed_object_zalloc(klass, size, data_type); \
- (sval) = RBIMPL_CAST((type *)RTYPEDDATA_DATA(result)); \
+ (sval) = (type *)RTYPEDDATA_GET_DATA(result); \
RBIMPL_CAST(/*suppress unused variable warnings*/(void)(sval))
/**
@@ -507,6 +515,36 @@ RBIMPL_SYMBOL_EXPORT_END()
#define TypedData_Get_Struct(obj,type,data_type,sval) \
((sval) = RBIMPL_CAST((type *)rb_check_typeddata((obj), (data_type))))
+static inline bool
+RTYPEDDATA_EMBEDDED_P(VALUE obj)
+{
+#if RUBY_DEBUG
+ if (RB_UNLIKELY(!RB_TYPE_P(obj, RUBY_T_DATA))) {
+ Check_Type(obj, RUBY_T_DATA);
+ RBIMPL_UNREACHABLE_RETURN(false);
+ }
+#endif
+
+ return RTYPEDDATA(obj)->typed_flag & TYPED_DATA_EMBEDDED;
+}
+
+static inline void *
+RTYPEDDATA_GET_DATA(VALUE obj)
+{
+#if RUBY_DEBUG
+ if (RB_UNLIKELY(!RB_TYPE_P(obj, RUBY_T_DATA))) {
+ Check_Type(obj, RUBY_T_DATA);
+ RBIMPL_UNREACHABLE_RETURN(false);
+ }
+#endif
+
+ /* We reuse the data pointer in embedded TypedData. We can't use offsetof
+ * since RTypedData a non-POD type in C++. */
+ const size_t embedded_typed_data_size = sizeof(struct RTypedData) - sizeof(void *);
+
+ return RTYPEDDATA_EMBEDDED_P(obj) ? (char *)obj + embedded_typed_data_size : RTYPEDDATA(obj)->data;
+}
+
RBIMPL_ATTR_PURE()
RBIMPL_ATTR_ARTIFICIAL()
/**
@@ -523,7 +561,8 @@ RBIMPL_ATTR_ARTIFICIAL()
static inline bool
rbimpl_rtypeddata_p(VALUE obj)
{
- return RTYPEDDATA(obj)->typed_flag == 1;
+ VALUE typed_flag = RTYPEDDATA(obj)->typed_flag;
+ return typed_flag != 0 && typed_flag <= 3;
}
RBIMPL_ATTR_PURE_UNLESS_DEBUG()
diff --git a/include/ruby/internal/dllexport.h b/include/ruby/internal/dllexport.h
index 08a262209d..71026e7100 100644
--- a/include/ruby/internal/dllexport.h
+++ b/include/ruby/internal/dllexport.h
@@ -37,9 +37,7 @@
* ```
*/
#undef RUBY_EXTERN
-#if defined(MJIT_HEADER) && defined(_WIN32)
-# define RUBY_EXTERN extern __declspec(dllimport)
-#elif defined(RUBY_EXPORT)
+#if defined(RUBY_EXPORT)
# define RUBY_EXTERN extern
#elif defined(_WIN32)
# define RUBY_EXTERN extern __declspec(dllimport)
@@ -59,36 +57,6 @@
# define RUBY_FUNC_EXPORTED /* void */
#endif
-/**
- * @cond INTERNAL_MACRO
- *
- * These MJIT related macros are placed here because translate_mjit_header can
- * need them. Extension libraries should not touch.
- */
-
-/* These macros are used for functions which are exported only for MJIT
- and NOT ensured to be exported in future versions. */
-
-#if ! defined(MJIT_HEADER)
-# define MJIT_FUNC_EXPORTED RUBY_FUNC_EXPORTED
-#elif ! RBIMPL_COMPILER_IS(MSVC)
-# define MJIT_FUNC_EXPORTED RUBY_FUNC_EXPORTED
-#else
-# define MJIT_FUNC_EXPORTED static
-#endif
-
-#define MJIT_SYMBOL_EXPORT_BEGIN RUBY_SYMBOL_EXPORT_BEGIN
-#define MJIT_SYMBOL_EXPORT_END RUBY_SYMBOL_EXPORT_END
-
-/* On mswin, MJIT header transformation can't be used since cl.exe can't output
- preprocessed output preserving macros. So this `MJIT_STATIC` is needed
- to force non-static function to static on MJIT header to avoid symbol conflict. */
-#ifdef MJIT_HEADER
-# define MJIT_STATIC static
-#else
-# define MJIT_STATIC
-#endif
-
/** @endcond */
/** Shortcut macro equivalent to `RUBY_SYMBOL_EXPORT_BEGIN extern "C" {`.
diff --git a/include/ruby/internal/encoding/string.h b/include/ruby/internal/encoding/string.h
index 6ed7ca1c90..2b9dfe4f31 100644
--- a/include/ruby/internal/encoding/string.h
+++ b/include/ruby/internal/encoding/string.h
@@ -30,7 +30,7 @@
RBIMPL_SYMBOL_EXPORT_BEGIN()
/**
- * Identical to rb_enc_str_new(), except it additionally takes an encoding.
+ * Identical to rb_str_new(), except it additionally takes an encoding.
*
* @param[in] ptr A memory region of `len` bytes length.
* @param[in] len Length of `ptr`, in bytes, not including the
diff --git a/include/ruby/internal/error.h b/include/ruby/internal/error.h
index 49e2276cb9..cd37f4461a 100644
--- a/include/ruby/internal/error.h
+++ b/include/ruby/internal/error.h
@@ -50,7 +50,19 @@ typedef enum {
/** Warning is for experimental features. */
RB_WARN_CATEGORY_EXPERIMENTAL,
- RB_WARN_CATEGORY_ALL_BITS = 0x6 /* no RB_WARN_CATEGORY_NONE bit */
+ /** Warning is for performance issues (not enabled by -w). */
+ RB_WARN_CATEGORY_PERFORMANCE,
+
+ RB_WARN_CATEGORY_DEFAULT_BITS = (
+ (1U << RB_WARN_CATEGORY_DEPRECATED) |
+ (1U << RB_WARN_CATEGORY_EXPERIMENTAL) |
+ 0),
+
+ RB_WARN_CATEGORY_ALL_BITS = (
+ (1U << RB_WARN_CATEGORY_DEPRECATED) |
+ (1U << RB_WARN_CATEGORY_EXPERIMENTAL) |
+ (1U << RB_WARN_CATEGORY_PERFORMANCE) |
+ 0)
} rb_warning_category_t;
/** for rb_readwrite_sys_fail first argument */
@@ -469,7 +481,7 @@ VALUE *rb_ruby_debug_ptr(void);
*/
#define ruby_debug (*rb_ruby_debug_ptr())
-/* reports if `-W' specified */
+/* reports if $VERBOSE is true */
RBIMPL_ATTR_NONNULL((1))
RBIMPL_ATTR_FORMAT(RBIMPL_PRINTF_FORMAT, 1, 2)
/**
@@ -484,7 +496,8 @@ RBIMPL_ATTR_FORMAT(RBIMPL_PRINTF_FORMAT, 1, 2)
* default, the method just emits its passed contents to ::rb_stderr using
* rb_io_write().
*
- * @note This function is affected by the `-W` flag.
+ * @note This function is affected by the value of $VERBOSE, it does
+ * nothing unless $VERBOSE is true.
* @param[in] fmt Format specifier string compatible with rb_sprintf().
*
* @internal
@@ -509,7 +522,7 @@ RBIMPL_ATTR_FORMAT(RBIMPL_PRINTF_FORMAT, 3, 4)
* Issues a compile-time warning that happens at `__file__:__line__`. Purpose
* of this function being exposed to CAPI is unclear.
*
- * @note This function is affected by the `-W` flag.
+ * @note This function is affected by the value of $VERBOSE.
* @param[in] file The path corresponding to Ruby level `__FILE__`.
* @param[in] line The number corresponding to Ruby level `__LINE__`.
* @param[in] fmt Format specifier string compatible with rb_sprintf().
@@ -522,19 +535,20 @@ RBIMPL_ATTR_FORMAT(RBIMPL_PRINTF_FORMAT, 1, 2)
* Identical to rb_sys_fail(), except it does not raise an exception to render
* a warning instead.
*
- * @note This function is affected by the `-W` flag.
+ * @note This function is affected by the value of $VERBOSE.
* @param[in] fmt Format specifier string compatible with rb_sprintf().
*/
void rb_sys_warning(const char *fmt, ...);
-/* reports always */
+/* reports if $VERBOSE is not nil (so if it is true or false) */
RBIMPL_ATTR_COLD()
RBIMPL_ATTR_NONNULL((1))
RBIMPL_ATTR_FORMAT(RBIMPL_PRINTF_FORMAT, 1, 2)
/**
- * Identical to rb_warning(), except it reports always regardless of runtime
- * `-W` flag.
+ * Identical to rb_warning(), except it reports unless $VERBOSE is nil.
*
+ * @note This function is affected by the value of $VERBOSE, it does
+ * nothing if $VERBOSE is nil.
* @param[in] fmt Format specifier string compatible with rb_sprintf().
*/
void rb_warn(const char *fmt, ...);
@@ -543,8 +557,7 @@ RBIMPL_ATTR_COLD()
RBIMPL_ATTR_NONNULL((2))
RBIMPL_ATTR_FORMAT(RBIMPL_PRINTF_FORMAT, 2, 3)
/**
- * Identical to rb_category_warning(), except it reports always regardless of
- * runtime `-W` flag.
+ * Identical to rb_category_warning(), except it reports unless $VERBOSE is nil.
*
* @param[in] cat Category e.g. deprecated.
* @param[in] fmt Format specifier string compatible with rb_sprintf().
@@ -554,8 +567,7 @@ void rb_category_warn(rb_warning_category_t cat, const char *fmt, ...);
RBIMPL_ATTR_NONNULL((1, 3))
RBIMPL_ATTR_FORMAT(RBIMPL_PRINTF_FORMAT, 3, 4)
/**
- * Identical to rb_compile_warning(), except it reports always regardless of
- * runtime `-W` flag.
+ * Identical to rb_compile_warning(), except it reports unless $VERBOSE is nil.
*
* @param[in] file The path corresponding to Ruby level `__FILE__`.
* @param[in] line The number corresponding to Ruby level `__LINE__`.
diff --git a/include/ruby/internal/event.h b/include/ruby/internal/event.h
index 04b137a193..1d194ed618 100644
--- a/include/ruby/internal/event.h
+++ b/include/ruby/internal/event.h
@@ -23,6 +23,10 @@
#include "ruby/internal/dllexport.h"
#include "ruby/internal/value.h"
+#ifdef HAVE_STDINT_H
+#include <stdint.h>
+#endif
+
/* These macros are not enums because they are wider than int.*/
/**
@@ -54,6 +58,7 @@
#define RUBY_EVENT_THREAD_END 0x0800 /**< Encountered an end of a thread. */
#define RUBY_EVENT_FIBER_SWITCH 0x1000 /**< Encountered a `Fiber#yield`. */
#define RUBY_EVENT_SCRIPT_COMPILED 0x2000 /**< Encountered an `eval`. */
+#define RUBY_EVENT_RESCUE 0x4000 /**< Encountered a `rescue` statement. */
#define RUBY_EVENT_TRACEPOINT_ALL 0xffff /**< Bitmask of extended events. */
/** @} */
diff --git a/include/ruby/internal/fl_type.h b/include/ruby/internal/fl_type.h
index 7383426b23..44b3e8cc0f 100644
--- a/include/ruby/internal/fl_type.h
+++ b/include/ruby/internal/fl_type.h
@@ -57,8 +57,7 @@
#define FL_SINGLETON RBIMPL_CAST((VALUE)RUBY_FL_SINGLETON) /**< @old{RUBY_FL_SINGLETON} */
#define FL_WB_PROTECTED RBIMPL_CAST((VALUE)RUBY_FL_WB_PROTECTED) /**< @old{RUBY_FL_WB_PROTECTED} */
-#define FL_PROMOTED0 RBIMPL_CAST((VALUE)RUBY_FL_PROMOTED0) /**< @old{RUBY_FL_PROMOTED0} */
-#define FL_PROMOTED1 RBIMPL_CAST((VALUE)RUBY_FL_PROMOTED1) /**< @old{RUBY_FL_PROMOTED1} */
+#define FL_PROMOTED RBIMPL_CAST((VALUE)RUBY_FL_PROMOTED) /**< @old{RUBY_FL_PROMOTED} */
#define FL_FINALIZE RBIMPL_CAST((VALUE)RUBY_FL_FINALIZE) /**< @old{RUBY_FL_FINALIZE} */
#define FL_TAINT RBIMPL_CAST((VALUE)RUBY_FL_TAINT) /**< @old{RUBY_FL_TAINT} */
#define FL_SHAREABLE RBIMPL_CAST((VALUE)RUBY_FL_SHAREABLE) /**< @old{RUBY_FL_SHAREABLE} */
@@ -111,13 +110,6 @@
#define RB_OBJ_FREEZE_RAW RB_OBJ_FREEZE_RAW
#define RB_OBJ_FROZEN RB_OBJ_FROZEN
#define RB_OBJ_FROZEN_RAW RB_OBJ_FROZEN_RAW
-#define RB_OBJ_INFECT RB_OBJ_INFECT
-#define RB_OBJ_INFECT_RAW RB_OBJ_INFECT_RAW
-#define RB_OBJ_TAINT RB_OBJ_TAINT
-#define RB_OBJ_TAINTABLE RB_OBJ_TAINTABLE
-#define RB_OBJ_TAINTED RB_OBJ_TAINTED
-#define RB_OBJ_TAINTED_RAW RB_OBJ_TAINTED_RAW
-#define RB_OBJ_TAINT_RAW RB_OBJ_TAINT_RAW
#define RB_OBJ_UNTRUST RB_OBJ_TAINT
#define RB_OBJ_UNTRUSTED RB_OBJ_TAINTED
/** @endcond */
@@ -207,12 +199,15 @@ ruby_fl_type {
RUBY_FL_WB_PROTECTED = (1<<5),
/**
- * This flag has something to do with our garbage collector. These days
- * ruby objects are "generational". There are those who are young and
- * those who are old. Young objects are prone to die; monitored relatively
- * extensively by the garbage collector. OTOH old objects tend to live
- * longer. They are relatively rarely considered. This flag is set when a
- * object experienced promotion i.e. survived a garbage collection.
+ * Ruby objects are "generational". There are young objects & old objects.
+ * Young objects are prone to die & monitored relatively extensively by the
+ * garbage collector. Old objects tend to live longer & are monitored less
+ * frequently. When an object survives a GC, its age is incremented. When
+ * age is equal to RVALUE_OLD_AGE, the object becomes Old. This flag is set
+ * when an object becomes old, and is used by the write barrier to check if
+ * an old object should be considered for marking more frequently - as old
+ * objects that have references added between major GCs need to be remarked
+ * to prevent the referred object being mistakenly swept.
*
* @internal
*
@@ -220,41 +215,14 @@ ruby_fl_type {
* 3rd parties. It must be an implementation detail that they should never
* know. Might better be hidden.
*/
- RUBY_FL_PROMOTED0 = (1<<5),
+ RUBY_FL_PROMOTED = (1<<5),
/**
- * This flag has something to do with our garbage collector. These days
- * ruby objects are "generational". There are those who are young and
- * those who are old. Young objects are prone to die; monitored relatively
- * extensively by the garbage collector. OTOH old objects tend to live
- * longer. They are relatively rarely considered. This flag is set when a
- * object experienced two promotions i.e. survived garbage collections
- * twice.
+ * This flag is no longer in use
*
* @internal
- *
- * But honestly, @shyouhei doesn't think this flag should be visible from
- * 3rd parties. It must be an implementation detail that they should never
- * know. Might better be hidden.
- */
- RUBY_FL_PROMOTED1 = (1<<6),
-
- /**
- * This flag has something to do with our garbage collector. These days
- * ruby objects are "generational". There are those who are young and
- * those who are old. Young objects are prone to die; monitored relatively
- * extensively by the garbage collector. OTOH old objects tend to live
- * longer. They are relatively rarely considered. This flag is set when a
- * object experienced promotions i.e. survived more than one garbage
- * collections.
- *
- * @internal
- *
- * But honestly, @shyouhei doesn't think this flag should be visible from
- * 3rd parties. It must be an implementation detail that they should never
- * know. Might better be hidden.
*/
- RUBY_FL_PROMOTED = RUBY_FL_PROMOTED0 | RUBY_FL_PROMOTED1,
+ RUBY_FL_UNUSED6 = (1<<6),
/**
* This flag has something to do with finalisers. A ruby object can have
@@ -283,7 +251,7 @@ ruby_fl_type {
# pragma deprecated(RUBY_FL_TAINT)
#endif
- = (1<<8),
+ = 0,
/**
* This flag has something to do with Ractor. Multiple Ractors run without
@@ -310,7 +278,7 @@ ruby_fl_type {
# pragma deprecated(RUBY_FL_UNTRUSTED)
#endif
- = (1<<8),
+ = 0,
/**
* This flag has something to do with object IDs. Unlike in the old days,
@@ -489,7 +457,7 @@ RB_FL_ABLE(VALUE obj)
RBIMPL_ATTR_PURE_UNLESS_DEBUG()
RBIMPL_ATTR_ARTIFICIAL()
/**
- * This is an implenentation detail of RB_FL_TEST(). 3rd parties need not use
+ * This is an implementation detail of RB_FL_TEST(). 3rd parties need not use
* this. Just always use RB_FL_TEST().
*
* @param[in] obj Object in question.
@@ -537,7 +505,7 @@ RB_FL_TEST(VALUE obj, VALUE flags)
RBIMPL_ATTR_PURE_UNLESS_DEBUG()
RBIMPL_ATTR_ARTIFICIAL()
/**
- * This is an implenentation detail of RB_FL_ANY(). 3rd parties need not use
+ * This is an implementation detail of RB_FL_ANY(). 3rd parties need not use
* this. Just always use RB_FL_ANY().
*
* @param[in] obj Object in question.
@@ -571,7 +539,7 @@ RB_FL_ANY(VALUE obj, VALUE flags)
RBIMPL_ATTR_PURE_UNLESS_DEBUG()
RBIMPL_ATTR_ARTIFICIAL()
/**
- * This is an implenentation detail of RB_FL_ALL(). 3rd parties need not use
+ * This is an implementation detail of RB_FL_ALL(). 3rd parties need not use
* this. Just always use RB_FL_ALL().
*
* @param[in] obj Object in question.
@@ -607,7 +575,7 @@ RBIMPL_ATTR_ARTIFICIAL()
/**
* @private
*
- * This is an implenentation detail of RB_FL_SET(). 3rd parties need not use
+ * This is an implementation detail of RB_FL_SET(). 3rd parties need not use
* this. Just always use RB_FL_SET().
*
* @param[out] obj Object in question.
@@ -627,7 +595,7 @@ rbimpl_fl_set_raw_raw(struct RBasic *obj, VALUE flags)
RBIMPL_ATTR_ARTIFICIAL()
/**
- * This is an implenentation detail of RB_FL_SET(). 3rd parties need not use
+ * This is an implementation detail of RB_FL_SET(). 3rd parties need not use
* this. Just always use RB_FL_SET().
*
* @param[out] obj Object in question.
@@ -667,7 +635,7 @@ RBIMPL_ATTR_ARTIFICIAL()
/**
* @private
*
- * This is an implenentation detail of RB_FL_UNSET(). 3rd parties need not use
+ * This is an implementation detail of RB_FL_UNSET(). 3rd parties need not use
* this. Just always use RB_FL_UNSET().
*
* @param[out] obj Object in question.
@@ -687,7 +655,7 @@ rbimpl_fl_unset_raw_raw(struct RBasic *obj, VALUE flags)
RBIMPL_ATTR_ARTIFICIAL()
/**
- * This is an implenentation detail of RB_FL_UNSET(). 3rd parties need not use
+ * This is an implementation detail of RB_FL_UNSET(). 3rd parties need not use
* this. Just always use RB_FL_UNSET().
*
* @param[out] obj Object in question.
@@ -722,7 +690,7 @@ RBIMPL_ATTR_ARTIFICIAL()
/**
* @private
*
- * This is an implenentation detail of RB_FL_REVERSE(). 3rd parties need not
+ * This is an implementation detail of RB_FL_REVERSE(). 3rd parties need not
* use this. Just always use RB_FL_REVERSE().
*
* @param[out] obj Object in question.
@@ -742,7 +710,7 @@ rbimpl_fl_reverse_raw_raw(struct RBasic *obj, VALUE flags)
RBIMPL_ATTR_ARTIFICIAL()
/**
- * This is an implenentation detail of RB_FL_REVERSE(). 3rd parties need not
+ * This is an implementation detail of RB_FL_REVERSE(). 3rd parties need not
* use this. Just always use RB_FL_REVERSE().
*
* @param[out] obj Object in question.
@@ -787,6 +755,7 @@ RBIMPL_ATTR_DEPRECATED(("taintedness turned out to be a wrong idea."))
static inline bool
RB_OBJ_TAINTABLE(VALUE obj)
{
+ (void)obj;
return false;
}
@@ -804,6 +773,7 @@ RBIMPL_ATTR_DEPRECATED(("taintedness turned out to be a wrong idea."))
static inline VALUE
RB_OBJ_TAINTED_RAW(VALUE obj)
{
+ (void)obj;
return false;
}
@@ -821,6 +791,7 @@ RBIMPL_ATTR_DEPRECATED(("taintedness turned out to be a wrong idea."))
static inline bool
RB_OBJ_TAINTED(VALUE obj)
{
+ (void)obj;
return false;
}
@@ -836,6 +807,7 @@ RBIMPL_ATTR_DEPRECATED(("taintedness turned out to be a wrong idea."))
static inline void
RB_OBJ_TAINT_RAW(VALUE obj)
{
+ (void)obj;
return;
}
@@ -851,6 +823,7 @@ RBIMPL_ATTR_DEPRECATED(("taintedness turned out to be a wrong idea."))
static inline void
RB_OBJ_TAINT(VALUE obj)
{
+ (void)obj;
return;
}
@@ -867,6 +840,8 @@ RBIMPL_ATTR_DEPRECATED(("taintedness turned out to be a wrong idea."))
static inline void
RB_OBJ_INFECT_RAW(VALUE dst, VALUE src)
{
+ (void)dst;
+ (void)src;
return;
}
@@ -883,13 +858,15 @@ RBIMPL_ATTR_DEPRECATED(("taintedness turned out to be a wrong idea."))
static inline void
RB_OBJ_INFECT(VALUE dst, VALUE src)
{
+ (void)dst;
+ (void)src;
return;
}
RBIMPL_ATTR_PURE_UNLESS_DEBUG()
RBIMPL_ATTR_ARTIFICIAL()
/**
- * This is an implenentation detail of RB_OBJ_FROZEN(). 3rd parties need not
+ * This is an implementation detail of RB_OBJ_FROZEN(). 3rd parties need not
* use this. Just always use RB_OBJ_FROZEN().
*
* @param[in] obj Object in question.
@@ -930,7 +907,7 @@ RB_OBJ_FROZEN(VALUE obj)
RBIMPL_ATTR_ARTIFICIAL()
/**
- * This is an implenentation detail of RB_OBJ_FREEZE(). 3rd parties need not
+ * This is an implementation detail of RB_OBJ_FREEZE(). 3rd parties need not
* use this. Just always use RB_OBJ_FREEZE().
*
* @param[out] obj Object in question.
diff --git a/include/ruby/internal/gc.h b/include/ruby/internal/gc.h
index 66fc14e511..ac9dfd8842 100644
--- a/include/ruby/internal/gc.h
+++ b/include/ruby/internal/gc.h
@@ -20,16 +20,395 @@
* extension libraries. They could be written in C++98.
* @brief Registering values to the GC.
*/
+#include "ruby/internal/config.h"
+
+#ifdef STDC_HEADERS
+# include <stddef.h> /* size_t */
+#endif
+
+#ifdef HAVE_SYS_TYPES_H
+# include <sys/types.h> /* ssize_t */
+#endif
+
+#include "ruby/assert.h"
+#include "ruby/internal/attr/cold.h"
+#include "ruby/internal/attr/nonnull.h"
+#include "ruby/internal/attr/noreturn.h"
+#include "ruby/internal/attr/artificial.h"
+#include "ruby/internal/attr/maybe_unused.h"
+#include "ruby/internal/attr/pure.h"
#include "ruby/internal/dllexport.h"
+#include "ruby/internal/special_consts.h"
+#include "ruby/internal/stdbool.h"
#include "ruby/internal/value.h"
RBIMPL_SYMBOL_EXPORT_BEGIN()
+#define RUBY_REF_EDGE(s, p) offsetof(s, p)
+#define RUBY_REFS_LIST_PTR(l) (RUBY_DATA_FUNC)(l)
+#define RUBY_REF_END SIZE_MAX
+#define RUBY_REFERENCES(t) static const size_t t[]
+#define RUBY_REFERENCES_START(t) RUBY_REFERENCES(t) = {
+#define RUBY_REFERENCES_END RUBY_REF_END, };
+
+/* gc.c */
+
+RBIMPL_ATTR_COLD()
+RBIMPL_ATTR_NORETURN()
+/**
+ * Triggers out-of-memory error. If possible it raises ::rb_eNoMemError. But
+ * because we are running out of memory that is not always doable. This
+ * function tries hard to show something, but ultimately can die silently.
+ *
+ * @exception rb_eNoMemError Raises it if possible.
+ */
+void rb_memerror(void);
+
+RBIMPL_ATTR_PURE()
+/**
+ * Queries if the GC is busy.
+ *
+ * @retval 0 It isn't.
+ * @retval 1 It is.
+ */
+int rb_during_gc(void);
+
+RBIMPL_ATTR_NONNULL((1))
+/**
+ * Marks objects between the two pointers. This is one of the GC utility
+ * functions that you can call when you design your own
+ * ::rb_data_type_struct::dmark.
+ *
+ * @pre Continuous memory region from `start` to `end` shall be fully
+ * addressable.
+ * @param[out] start Pointer to an array of objects.
+ * @param[out] end Pointer that terminates the array of objects.
+ * @post Objects from `start` (included) to `end` (excluded) are marked.
+ *
+ * @internal
+ *
+ * `end` can be NULL... But that just results in no-op.
+ */
+void rb_gc_mark_locations(const VALUE *start, const VALUE *end);
+
+/**
+ * Identical to rb_mark_hash(), except it marks only values of the table and
+ * leave their associated keys unmarked. This is one of the GC utility
+ * functions that you can call when you design your own
+ * ::rb_data_type_struct::dmark.
+ *
+ * @warning Of course it can break GC. Leave it unused if unsure.
+ * @param[in] tbl A table to mark.
+ * @post Values stored in `tbl` are marked.
+ */
+void rb_mark_tbl(struct st_table *tbl);
+
+/**
+ * Identical to rb_mark_tbl(), except it marks objects using
+ * rb_gc_mark_movable(). This is one of the GC utility functions that you can
+ * call when you design your own ::rb_data_type_struct::dmark.
+ *
+ * @warning Of course it can break GC. Leave it unused if unsure.
+ * @param[in] tbl A table to mark.
+ * @post Values stored in `tbl` are marked.
+ */
+void rb_mark_tbl_no_pin(struct st_table *tbl);
+
+/**
+ * Identical to rb_mark_hash(), except it marks only keys of the table and
+ * leave their associated values unmarked. This is one of the GC utility
+ * functions that you can call when you design your own
+ * ::rb_data_type_struct::dmark.
+ *
+ * @warning Of course it can break GC. Leave it unused if unsure.
+ * @param[in] tbl A table to mark.
+ * @post Keys stored in `tbl` are marked.
+ */
+void rb_mark_set(struct st_table *tbl);
+
/**
- * Inform the garbage collector that `valptr` points to a live Ruby object that
- * should not be moved. Note that extensions should use this API on global
- * constants instead of assuming constants defined in Ruby are always alive.
- * Ruby code can remove global constants.
+ * Marks keys and values associated inside of the given table. This is one of
+ * the GC utility functions that you can call when you design your own
+ * ::rb_data_type_struct::dmark.
+ *
+ * @param[in] tbl A table to mark.
+ * @post Objects stored in `tbl` are marked.
+ */
+void rb_mark_hash(struct st_table *tbl);
+
+/**
+ * Updates references inside of tables. After you marked values using
+ * rb_mark_tbl_no_pin(), the objects inside of the table could of course be
+ * moved. This function is to fixup those references. You can call this from
+ * your ::rb_data_type_struct::dcompact.
+ *
+ * @param[out] ptr A table that potentially includes moved references.
+ * @post Moved references, if any, are corrected.
+ */
+void rb_gc_update_tbl_refs(st_table *ptr);
+
+/**
+ * Identical to rb_gc_mark(), except it allows the passed value be a
+ * non-object. For instance pointers to different type of memory regions are
+ * allowed here. Such values are silently ignored. This is one of the GC
+ * utility functions that you can call when you design your own
+ * ::rb_data_type_struct::dmark.
+ *
+ * @param[out] obj A possible object.
+ * @post `obj` is marked, if possible.
+ */
+void rb_gc_mark_maybe(VALUE obj);
+
+/**
+ * Marks an object. This is one of the GC utility functions that you can call
+ * when you design your own ::rb_data_type_struct::dmark.
+ *
+ * @param[out] obj Arbitrary Ruby object.
+ * @post `obj` is marked.
+ */
+void rb_gc_mark(VALUE obj);
+
+/**
+ * Maybe this is the only function provided for C extensions to control the
+ * pinning of objects, so let us describe it in detail. These days Ruby's GC
+ * is copying. As far as an object's physical address is guaranteed unused, it
+ * can move around the object space. Our GC engine rearranges these objects
+ * after it reclaims unreachable objects from our object space, so that the
+ * space is compact (improves memory locality). This is called the
+ * "compaction" phase, and works well most of the time... as far as there are
+ * no C extensions. C extensions complicate the scenario because Ruby core
+ * cannot detect any use of the physical address of an object inside of C
+ * functions. In order to prevent memory corruptions, objects observable from
+ * C extensions are "pinned"; they stick to where they are born until they die,
+ * just in case any C extensions touch their raw pointers. This variant of
+ * scheme is called "Mostly-Copying" garbage collector. Authors of C
+ * extensions, however, can extremely carefully write them to become
+ * compaction-aware. To do so avoid referring to a Ruby object from inside of
+ * your struct in the first place. But if that is not possible, use this
+ * function from your ::rb_data_type_struct::dmark then. This way objects
+ * marked using it are considered movable. If you chose this way you have to
+ * manually fix up locations of such moved pointers using rb_gc_location().
+ *
+ * @see Bartlett, Joel F., "Compacting Garbage Collection with Ambiguous
+ * Roots", ACM SIGPLAN Lisp Pointers Volume 1 Issue 6 pp. 3-12,
+ * April-May-June, 1988. https://doi.org/10.1145/1317224.1317225
+ *
+ * @param[in] obj Object that is movable.
+ * @post Values stored in `tbl` are marked.
+ */
+void rb_gc_mark_movable(VALUE obj);
+
+/**
+ * Finds a new "location" of an object. An object can be moved on compaction.
+ * This function projects its new abode, or just returns the passed object if
+ * not moved. This is one of the GC utility functions that you can call when
+ * you design your own ::rb_data_type_struct::dcompact.
+ *
+ * @param[in] obj An object, possibly already moved to somewhere else.
+ * @return An object, which holds the current contents of former `obj`.
+ */
+VALUE rb_gc_location(VALUE obj);
+
+/**
+ * Asserts that the passed object is no longer needed. Such objects are
+ * reclaimed sooner or later so this function is not mandatory. But sometimes
+ * you can know from your application knowledge that an object is surely dead
+ * at some point. Calling this as a hint can be a polite way.
+ *
+ * @param[out] obj Object, dead.
+ * @pre `obj` have never been passed to this function before.
+ * @post `obj` could be invalidated.
+ * @warning It is a failure to pass an object multiple times to this
+ * function.
+ * @deprecated This is now a no-op function.
+ */
+RBIMPL_ATTR_DEPRECATED(("this is now a no-op function"))
+void rb_gc_force_recycle(VALUE obj);
+
+/**
+ * Triggers a GC process. This was the only GC entry point that we had at the
+ * beginning. Over time our GC evolved. Now what this function does is just a
+ * very simplified variation of the entire GC algorithms. A series of
+ * procedures kicked by this API is called a "full" GC.
+ *
+ * - It immediately scans the entire object space to sort the dead.
+ * - It immediately reclaims any single dead bodies to reuse later.
+ *
+ * It is worth noting that the procedures above do not include evaluations of
+ * finalisers. They run later.
+ *
+ * @internal
+ *
+ * Finalisers are deferred until we can handle interrupts. See
+ * `rb_postponed_job_flush` in vm_trace.c.
+ *
+ * Of course there are GC that are not "full". For instance this one and the
+ * GC which runs when we are running out of memory are different. See
+ * `gc_profile_record_flag` defined in gc.c for the kinds of GC.
+ *
+ * In spite of the name this is not what everything that a GC can trigger. As
+ * of writing it seems this function does not trigger compaction. But this
+ * might change in future.
+ */
+void rb_gc(void);
+
+/**
+ * Copy&paste an object's finaliser to another. This is one of the GC utility
+ * functions that you can call when you design your own `initialize_copy`,
+ * `initialize_dup`, `initialize_clone`.
+ *
+ * @param[out] dst Destination object.
+ * @param[in] src Source object.
+ * @post `dst` and `src` share the same finaliser.
+ *
+ * @internal
+ *
+ * But isn't it easier for you to call super, and let `Object#initialize_copy`
+ * call this function instead?
+ */
+void rb_gc_copy_finalizer(VALUE dst, VALUE src);
+
+/**
+ * (Re-) enables GC. This makes sense only after you called rb_gc_disable().
+ *
+ * @retval RUBY_Qtrue GC was disabled before.
+ * @retval RUBY_Qfalse GC was enabled before.
+ * @post GC is enabled.
+ *
+ * @internal
+ *
+ * This is one of such exceptional functions that does not raise both Ruby
+ * exceptions and C++ exceptions.
+ */
+VALUE rb_gc_enable(void);
+
+/**
+ * Disables GC. This prevents automatic GC runs when the process is running
+ * out of memory. Such situations shall result in rb_memerror(). However this
+ * does not prevent users from manually invoking rb_gc(). That should work.
+ * People abused this by disabling GC at the beginning of an event loop,
+ * process events without GC overheads, then manually force reclaiming garbage
+ * at the bottom of the loop. However because our GC is now much smarter than
+ * just calling rb_gc(), this technique is proven to be sub-optimal these days.
+ * It is believed that there is currently practically no needs of this
+ * function.
+ *
+ * @retval RUBY_Qtrue GC was disabled before.
+ * @retval RUBY_Qfalse GC was enabled before.
+ * @post GC is disabled.
+ */
+VALUE rb_gc_disable(void);
+
+/**
+ * Identical to rb_gc(), except the return value.
+ *
+ * @return Always returns ::RUBY_Qnil.
+ */
+VALUE rb_gc_start(void);
+
+/**
+ * Assigns a finaliser for an object. Each objects can have objects (typically
+ * blocks) that run immediately after that object dies. They are called
+ * finalisers of an object. This function associates a finaliser object with a
+ * target object.
+ *
+ * @note Note that finalisers run _after_ the object they finalise dies. You
+ * cannot for instance call its methods.
+ * @note If your finaliser references the object it finalises that object
+ * loses any chance to become a garbage; effectively leaks memory until
+ * the end of the process.
+ *
+ * @param[in] obj Target to finalise.
+ * @param[in] block Something `call`able.
+ * @exception rb_eRuntimeError Somehow `obj` cannot have finalisers.
+ * @exception rb_eFrozenError `obj` is frozen.
+ * @exception rb_eArgError `block` doesn't respond to `call`.
+ * @return The passed `block`.
+ * @post `block` runs after `obj` dies.
+ */
+VALUE rb_define_finalizer(VALUE obj, VALUE block);
+
+/**
+ * Modifies the object so that it has no finalisers at all. This function is
+ * mainly provided for symmetry. No practical usages can be thought of.
+ *
+ * @param[out] obj Object to clear its finalisers.
+ * @exception rb_eFrozenError `obj` is frozen.
+ * @return The passed `obj`.
+ * @post `obj` has no finalisers.
+ * @note There is no way to undefine a specific part of many finalisers
+ * that `obj` could have. All you can do is to clear them all.
+ */
+VALUE rb_undefine_finalizer(VALUE obj);
+
+/**
+ * Identical to rb_gc_stat(), with "count" parameter.
+ *
+ * @return Lifetime total number of runs of GC.
+ */
+size_t rb_gc_count(void);
+
+/**
+ * Obtains various GC related profiles. The parameter can be either a Symbol
+ * or a Hash. If a Hash is passed, it is filled with everything currently
+ * available. If a Symbol is passed just that portion is returned.
+ *
+ * Possible variations of keys you can pass here change from version to
+ * version. You can get the list of known keys by passing an empty hash and
+ * let it be filled.
+ *
+ * @param[in,out] key_or_buf A Symbol, or a Hash.
+ * @exception rb_eTypeError Neither Symbol nor Hash.
+ * @exception rb_eFrozenError Frozen hash is passed.
+ * @return In case a Hash is passed it returns 0. Otherwise the
+ * profile value associated with the given key is returned.
+ * @post In case a Hash is passed it is filled with values.
+ */
+size_t rb_gc_stat(VALUE key_or_buf);
+
+/**
+ * Obtains various info regarding the most recent GC run. This includes for
+ * instance the reason of the GC. The parameter can be either a Symbol or a
+ * Hash. If a Hash is passed, it is filled with everything currently
+ * available. If a Symbol is passed just that portion is returned.
+ *
+ * Possible variations of keys you can pass here change from version to
+ * version. You can get the list of known keys by passing an empty hash and
+ * let it be filled.
+ *
+ * @param[in,out] key_or_buf A Symbol, or a Hash.
+ * @exception rb_eTypeError Neither Symbol nor Hash.
+ * @exception rb_eFrozenError Frozen hash is passed.
+ * @return In case a Hash is passed it returns that hash. Otherwise
+ * the profile value associated with the given key is returned.
+ * @post In case a Hash is passed it is filled with values.
+ */
+VALUE rb_gc_latest_gc_info(VALUE key_or_buf);
+
+/**
+ * Informs that there are external memory usages. Our GC runs when we are
+ * running out of memory. The amount of memory, however, can increase/decrease
+ * behind-the-scene. For instance DLLs can allocate memories using `mmap(2)`
+ * etc, which are opaque to us. Registering such external allocations using
+ * this function enables proper detection of how much memories an object used
+ * as a whole. That will trigger GCs more often than it would otherwise. You
+ * can also pass negative numbers here, to indicate that such external
+ * allocations are gone.
+ *
+ * @param[in] diff Amount of memory increased(+)/decreased(-).
+ */
+void rb_gc_adjust_memory_usage(ssize_t diff);
+
+/**
+ * Inform the garbage collector that the global or static variable pointed by
+ * `valptr` stores a live Ruby object that should not be moved. Note that
+ * extensions should use this API on global constants instead of assuming
+ * constants defined in Ruby are always alive. Ruby code can remove global
+ * constants.
+ *
+ * Because this registration itself has a possibility to trigger a GC, this
+ * function must be called before any GC-able objects is assigned to the
+ * address pointed by `valptr`.
*/
void rb_gc_register_address(VALUE *valptr);
@@ -54,4 +433,410 @@ void rb_gc_register_mark_object(VALUE object);
RBIMPL_SYMBOL_EXPORT_END()
+/**
+ * @private
+ *
+ * @deprecated This macro once was a thing in the old days, but makes no sense
+ * any longer today. Exists here for backwards compatibility
+ * only. You can safely forget about it.
+ */
+#undef USE_RGENGC
+#define USE_RGENGC 1
+
+/**
+ * @deprecated This macro seems broken. Setting this to anything other than
+ * zero just doesn't compile. We need to KonMari.
+ */
+#ifndef USE_RGENGC_LOGGING_WB_UNPROTECT
+# define USE_RGENGC_LOGGING_WB_UNPROTECT 0
+#endif
+
+/**
+ * @private
+ *
+ * This is a compile-time flag to enable/disable write barrier for
+ * struct ::RArray. It has to be set at the time ruby itself compiles. Makes
+ * no sense for 3rd parties.
+ */
+#ifndef RGENGC_WB_PROTECTED_ARRAY
+# define RGENGC_WB_PROTECTED_ARRAY 1
+#endif
+
+/**
+ * @private
+ *
+ * This is a compile-time flag to enable/disable write barrier for
+ * struct ::RHash. It has to be set at the time ruby itself compiles. Makes
+ * no sense for 3rd parties.
+ */
+#ifndef RGENGC_WB_PROTECTED_HASH
+# define RGENGC_WB_PROTECTED_HASH 1
+#endif
+
+/**
+ * @private
+ *
+ * This is a compile-time flag to enable/disable write barrier for
+ * struct ::RStruct. It has to be set at the time ruby itself compiles. Makes
+ * no sense for 3rd parties.
+ */
+#ifndef RGENGC_WB_PROTECTED_STRUCT
+# define RGENGC_WB_PROTECTED_STRUCT 1
+#endif
+
+/**
+ * @private
+ *
+ * This is a compile-time flag to enable/disable write barrier for
+ * struct ::RString. It has to be set at the time ruby itself compiles. Makes
+ * no sense for 3rd parties.
+ */
+#ifndef RGENGC_WB_PROTECTED_STRING
+# define RGENGC_WB_PROTECTED_STRING 1
+#endif
+
+/**
+ * @private
+ *
+ * This is a compile-time flag to enable/disable write barrier for
+ * struct ::RObject. It has to be set at the time ruby itself compiles. Makes
+ * no sense for 3rd parties.
+ */
+#ifndef RGENGC_WB_PROTECTED_OBJECT
+# define RGENGC_WB_PROTECTED_OBJECT 1
+#endif
+
+/**
+ * @private
+ *
+ * This is a compile-time flag to enable/disable write barrier for
+ * struct ::RRegexp. It has to be set at the time ruby itself compiles. Makes
+ * no sense for 3rd parties.
+ */
+#ifndef RGENGC_WB_PROTECTED_REGEXP
+# define RGENGC_WB_PROTECTED_REGEXP 1
+#endif
+
+/**
+ * @private
+ *
+ * This is a compile-time flag to enable/disable write barrier for
+ * struct ::RMatch. It has to be set at the time ruby itself compiles. Makes
+ * no sense for 3rd parties.
+ */
+#ifndef RGENGC_WB_PROTECTED_MATCH
+# define RGENGC_WB_PROTECTED_MATCH 1
+#endif
+
+/**
+ * @private
+ *
+ * This is a compile-time flag to enable/disable write barrier for
+ * struct ::RClass. It has to be set at the time ruby itself compiles. Makes
+ * no sense for 3rd parties.
+ */
+#ifndef RGENGC_WB_PROTECTED_CLASS
+# define RGENGC_WB_PROTECTED_CLASS 1
+#endif
+
+/**
+ * @private
+ *
+ * This is a compile-time flag to enable/disable write barrier for
+ * struct ::RFloat. It has to be set at the time ruby itself compiles. Makes
+ * no sense for 3rd parties.
+ */
+#ifndef RGENGC_WB_PROTECTED_FLOAT
+# define RGENGC_WB_PROTECTED_FLOAT 1
+#endif
+
+/**
+ * @private
+ *
+ * This is a compile-time flag to enable/disable write barrier for
+ * struct ::RComplex. It has to be set at the time ruby itself compiles.
+ * Makes no sense for 3rd parties.
+ */
+#ifndef RGENGC_WB_PROTECTED_COMPLEX
+# define RGENGC_WB_PROTECTED_COMPLEX 1
+#endif
+
+/**
+ * @private
+ *
+ * This is a compile-time flag to enable/disable write barrier for
+ * struct ::RRational. It has to be set at the time ruby itself compiles.
+ * Makes no sense for 3rd parties.
+ */
+#ifndef RGENGC_WB_PROTECTED_RATIONAL
+# define RGENGC_WB_PROTECTED_RATIONAL 1
+#endif
+
+/**
+ * @private
+ *
+ * This is a compile-time flag to enable/disable write barrier for
+ * struct ::RBignum. It has to be set at the time ruby itself compiles. Makes
+ * no sense for 3rd parties.
+ */
+#ifndef RGENGC_WB_PROTECTED_BIGNUM
+# define RGENGC_WB_PROTECTED_BIGNUM 1
+#endif
+
+/**
+ * @private
+ *
+ * @deprecated This macro once was a thing in the old days, but makes no sense
+ * any longer today. Exists here for backwards compatibility
+ * only. You can safely forget about it.
+ *
+ * @internal
+ *
+ * @shyouhei doesn't think anybody uses this right now.
+ */
+#ifndef RGENGC_WB_PROTECTED_NODE_CREF
+# define RGENGC_WB_PROTECTED_NODE_CREF 1
+#endif
+
+/**
+ * @defgroup rgengc Write barrier (WB) interfaces:
+ *
+ * @note The following core interfaces can be changed in the future. Please
+ * catch up if you want to insert WB into C-extensions correctly.
+ *
+ * @{
+ */
+
+/**
+ * Declaration of a "back" pointer. This is a write barrier for new reference
+ * from "old" generation to "young" generation. It writes `young` into
+ * `*slot`, which is a pointer inside of `old`.
+ *
+ * @param[in] old An old object.
+ * @param[in] slot A pointer inside of `old`.
+ * @param[out] young A young object.
+ */
+#define RB_OBJ_WRITE(old, slot, young) \
+ RBIMPL_CAST(rb_obj_write((VALUE)(old), (VALUE *)(slot), (VALUE)(young), __FILE__, __LINE__))
+
+/**
+ * Identical to #RB_OBJ_WRITE(), except it doesn't write any values, but only a
+ * WB declaration. `oldv` is replaced value with `b` (not used in current
+ * Ruby).
+ *
+ * @param[in] old An old object.
+ * @param[in] oldv An object previously stored inside of `old`.
+ * @param[out] young A young object.
+ */
+#define RB_OBJ_WRITTEN(old, oldv, young) \
+ RBIMPL_CAST(rb_obj_written((VALUE)(old), (VALUE)(oldv), (VALUE)(young), __FILE__, __LINE__))
+/** @} */
+
+#define OBJ_PROMOTED_RAW RB_OBJ_PROMOTED_RAW /**< @old{RB_OBJ_PROMOTED_RAW} */
+#define OBJ_PROMOTED RB_OBJ_PROMOTED /**< @old{RB_OBJ_PROMOTED} */
+#define OBJ_WB_UNPROTECT RB_OBJ_WB_UNPROTECT /**< @old{RB_OBJ_WB_UNPROTECT} */
+
+/**
+ * Asserts that the passed object is not fenced by write barriers. Objects of
+ * such property do not contribute to generational GCs. They are scanned
+ * always.
+ *
+ * @param[out] x An object that would not be protected by the barrier.
+ */
+#define RB_OBJ_WB_UNPROTECT(x) rb_obj_wb_unprotect(x, __FILE__, __LINE__)
+
+/**
+ * Identical to #RB_OBJ_WB_UNPROTECT(), except it can also assert that the
+ * given object is of given type.
+ *
+ * @param[in] type One of `ARRAY`, `STRING`, etc.
+ * @param[out] obj An object of `type` that would not be protected.
+ *
+ * @internal
+ *
+ * @shyouhei doesn't understand why this has to be visible from extensions.
+ */
+#define RB_OBJ_WB_UNPROTECT_FOR(type, obj) \
+ (RGENGC_WB_PROTECTED_##type ? OBJ_WB_UNPROTECT(obj) : obj)
+
+/**
+ * @private
+ *
+ * This is an implementation detail of rb_obj_wb_unprotect(). People don't use
+ * it directly.
+ */
+#define RGENGC_LOGGING_WB_UNPROTECT rb_gc_unprotect_logging
+
+/** @cond INTERNAL_MACRO */
+#define RB_OBJ_PROMOTED_RAW RB_OBJ_PROMOTED_RAW
+#define RB_OBJ_PROMOTED RB_OBJ_PROMOTED
+/** @endcond */
+
+RBIMPL_SYMBOL_EXPORT_BEGIN()
+/**
+ * This is the implementation of #RB_OBJ_WRITE(). People don't use it
+ * directly.
+ *
+ * @param[in] old An object that points to `young`.
+ * @param[out] young An object that is referenced from `old`.
+ */
+void rb_gc_writebarrier(VALUE old, VALUE young);
+
+/**
+ * This is the implementation of #RB_OBJ_WB_UNPROTECT(). People don't use it
+ * directly.
+ *
+ * @param[out] obj An object that does not participate in WB.
+ */
+void rb_gc_writebarrier_unprotect(VALUE obj);
+
+#if USE_RGENGC_LOGGING_WB_UNPROTECT
+/**
+ * @private
+ *
+ * This is the implementation of #RGENGC_LOGGING_WB_UNPROTECT(). People
+ * don't use it directly.
+ *
+ * @param[in] objptr Don't know why this is a pointer to void but in
+ * reality this is a pointer to an object that is about
+ * to be un-protected.
+ * @param[in] filename Pass C's `__FILE__` here.
+ * @param[in] line Pass C's `__LINE__` here.
+ */
+void rb_gc_unprotect_logging(void *objptr, const char *filename, int line);
+#endif
+
+RBIMPL_SYMBOL_EXPORT_END()
+
+RBIMPL_ATTR_PURE_UNLESS_DEBUG()
+RBIMPL_ATTR_ARTIFICIAL()
+/**
+ * This is the implementation of #RB_OBJ_PROMOTED(). People don't use it
+ * directly.
+ *
+ * @param[in] obj An object to query.
+ * @retval true The object is "promoted".
+ * @retval false The object is young. Have not experienced GC at all.
+ */
+static inline bool
+RB_OBJ_PROMOTED_RAW(VALUE obj)
+{
+ RBIMPL_ASSERT_OR_ASSUME(RB_FL_ABLE(obj));
+ return RB_FL_ANY_RAW(obj, RUBY_FL_PROMOTED);
+}
+
+RBIMPL_ATTR_PURE_UNLESS_DEBUG()
+RBIMPL_ATTR_ARTIFICIAL()
+/**
+ * Tests if the object is "promoted" -- that is, whether the object experienced
+ * one or more GC marks.
+ *
+ * @param[in] obj An object to query.
+ * @retval true The object is "promoted".
+ * @retval false The object is young. Have not experienced GC at all.
+ * @note Hello, is anyone actively calling this function? @shyouhei have
+ * never seen any actual usages outside of the GC implementation
+ * itself.
+ */
+static inline bool
+RB_OBJ_PROMOTED(VALUE obj)
+{
+ if (! RB_FL_ABLE(obj)) {
+ return false;
+ }
+ else {
+ return RB_OBJ_PROMOTED_RAW(obj);
+ }
+}
+
+/**
+ * This is the implementation of #RB_OBJ_WB_UNPROTECT(). People don't use it
+ * directly.
+ *
+ * @param[out] x An object that does not participate in WB.
+ * @param[in] filename C's `__FILE__` of the caller function.
+ * @param[in] line C's `__LINE__` of the caller function.
+ * @return x
+ */
+static inline VALUE
+rb_obj_wb_unprotect(
+ VALUE x,
+ RBIMPL_ATTR_MAYBE_UNUSED()
+ const char *filename,
+ RBIMPL_ATTR_MAYBE_UNUSED()
+ int line)
+{
+#if USE_RGENGC_LOGGING_WB_UNPROTECT
+ RGENGC_LOGGING_WB_UNPROTECT(RBIMPL_CAST((void *)x), filename, line);
+#endif
+ rb_gc_writebarrier_unprotect(x);
+ return x;
+}
+
+/**
+ * @private
+ *
+ * This is the implementation of #RB_OBJ_WRITTEN(). People don't use it
+ * directly.
+ *
+ * @param[in] a An old object.
+ * @param[in] oldv An object previously stored inside of `old`.
+ * @param[out] b A young object.
+ * @param[in] filename C's `__FILE__` of the caller function.
+ * @param[in] line C's `__LINE__` of the caller function.
+ * @return a
+ */
+static inline VALUE
+rb_obj_written(
+ VALUE a,
+ RBIMPL_ATTR_MAYBE_UNUSED()
+ VALUE oldv,
+ VALUE b,
+ RBIMPL_ATTR_MAYBE_UNUSED()
+ const char *filename,
+ RBIMPL_ATTR_MAYBE_UNUSED()
+ int line)
+{
+#if USE_RGENGC_LOGGING_WB_UNPROTECT
+ RGENGC_LOGGING_OBJ_WRITTEN(a, oldv, b, filename, line);
+#endif
+
+ if (!RB_SPECIAL_CONST_P(b)) {
+ rb_gc_writebarrier(a, b);
+ }
+
+ return a;
+}
+
+/**
+ * @private
+ *
+ * This is the implementation of #RB_OBJ_WRITE(). People don't use it
+ * directly.
+ *
+ * @param[in] a An old object.
+ * @param[in] slot A pointer inside of `old`.
+ * @param[out] b A young object.
+ * @param[in] filename C's `__FILE__` of the caller function.
+ * @param[in] line C's `__LINE__` of the caller function.
+ * @return a
+ */
+static inline VALUE
+rb_obj_write(
+ VALUE a, VALUE *slot, VALUE b,
+ RBIMPL_ATTR_MAYBE_UNUSED()
+ const char *filename,
+ RBIMPL_ATTR_MAYBE_UNUSED()
+ int line)
+{
+#ifdef RGENGC_LOGGING_WRITE
+ RGENGC_LOGGING_WRITE(a, slot, b, filename, line);
+#endif
+
+ *slot = b;
+
+ rb_obj_written(a, RUBY_Qundef /* ignore `oldv' now */, b, filename, line);
+ return a;
+}
+
#endif /* RBIMPL_GC_H */
diff --git a/include/ruby/internal/globals.h b/include/ruby/internal/globals.h
index 5a414fc472..60d8e5309a 100644
--- a/include/ruby/internal/globals.h
+++ b/include/ruby/internal/globals.h
@@ -94,7 +94,7 @@ RUBY_EXTERN VALUE rb_cRegexp; /**< `Regexp` class. */
RUBY_EXTERN VALUE rb_cStat; /**< `File::Stat` class. */
RUBY_EXTERN VALUE rb_cString; /**< `String` class. */
RUBY_EXTERN VALUE rb_cStruct; /**< `Struct` class. */
-RUBY_EXTERN VALUE rb_cSymbol; /**< `Sumbol` class. */
+RUBY_EXTERN VALUE rb_cSymbol; /**< `Symbol` class. */
RUBY_EXTERN VALUE rb_cThread; /**< `Thread` class. */
RUBY_EXTERN VALUE rb_cTime; /**< `Time` class. */
RUBY_EXTERN VALUE rb_cTrueClass; /**< `TrueClass` class. */
diff --git a/include/ruby/internal/has/c_attribute.h b/include/ruby/internal/has/c_attribute.h
index c5c48867bf..69b0f402cd 100644
--- a/include/ruby/internal/has/c_attribute.h
+++ b/include/ruby/internal/has/c_attribute.h
@@ -21,11 +21,23 @@
* @brief Defines #RBIMPL_HAS_C_ATTRIBUTE.
*/
+#include "ruby/internal/has/extension.h"
+#include "ruby/internal/has/warning.h"
+
/** Wraps (or simulates) `__has_c_attribute`. */
#if defined(__cplusplus)
# /* Makes no sense. */
# define RBIMPL_HAS_C_ATTRIBUTE(_) 0
+#elif RBIMPL_HAS_EXTENSION(c_attributes)
+# /* Hmm. It seems Clang 17 has this macro defined even when -std=c99 mode,
+# * _and_ fails to compile complaining that attributes are C2X feature. We
+# * need to work around this nonsense. */
+# define RBIMPL_HAS_C_ATTRIBUTE(_) __has_c_attribute(_)
+
+#elif RBIMPL_HAS_WARNING("-Wc2x-extensions")
+# define RBIMPL_HAS_C_ATTRIBUTE(_) 0
+
#elif defined(__has_c_attribute)
# define RBIMPL_HAS_C_ATTRIBUTE(_) __has_c_attribute(_)
diff --git a/include/ruby/internal/intern/array.h b/include/ruby/internal/intern/array.h
index 2262c6f0c6..1909fdf17b 100644
--- a/include/ruby/internal/intern/array.h
+++ b/include/ruby/internal/intern/array.h
@@ -187,7 +187,7 @@ VALUE rb_ary_shared_with_p(VALUE lhs, VALUE rhs);
* : (int i) -> T?
* | (int beg, int len) -> ::Array[T]?
* | (Range[int] r) -> ::Array[T]?
- * | (ArithmeticSequence as) -> ::Array[T]? # This also raises RagneError.
+ * | (ArithmeticSequence as) -> ::Array[T]? # This also raises RangeError.
* end
* ```
*/
diff --git a/include/ruby/internal/intern/bignum.h b/include/ruby/internal/intern/bignum.h
index 43d68018de..c27f77a1fb 100644
--- a/include/ruby/internal/intern/bignum.h
+++ b/include/ruby/internal/intern/bignum.h
@@ -51,7 +51,7 @@ RBIMPL_SYMBOL_EXPORT_BEGIN()
VALUE rb_big_new(size_t len, int sign);
/**
- * Queries if the passed bignum instance is a "bigzro". What is a bigzero?
+ * Queries if the passed bignum instance is a "bigzero". What is a bigzero?
* Well, bignums are for very big integers, but can also represent tiny ones
* like -1, 0, 1. Bigzero are instances of bignums whose values are zero.
* Knowing if a bignum is bigzero can be handy on occasions, like for instance
@@ -793,7 +793,7 @@ size_t rb_absint_size(VALUE val, int *nlz_bits_ret);
* @exception rb_eTypeError `val` doesn't respond to `#to_int`.
* @retval (size_t)-1 Overflowed.
* @retval otherwise
- `((val_numbits * CHAR_BIT + word_numbits - 1) / word_numbits)`,
+ * `((val_numbits * CHAR_BIT + word_numbits - 1) / word_numbits)`,
* where val_numbits is the number of bits of `abs(val)`.
* @post If `nlz_bits_ret` is not `NULL` and there is no overflow,
* `(return_value * word_numbits - val_numbits)` is stored in
diff --git a/include/ruby/internal/intern/error.h b/include/ruby/internal/intern/error.h
index 9c153cbac5..bf8daadd3e 100644
--- a/include/ruby/internal/intern/error.h
+++ b/include/ruby/internal/intern/error.h
@@ -235,7 +235,7 @@ RBIMPL_ATTR_NORETURN()
* @param[in] max Maximum allowed `argc`.
* @exception rb_eArgError Always.
*/
-MJIT_STATIC void rb_error_arity(int argc, int min, int max);
+void rb_error_arity(int argc, int min, int max);
RBIMPL_SYMBOL_EXPORT_END()
diff --git a/include/ruby/internal/intern/gc.h b/include/ruby/internal/intern/gc.h
deleted file mode 100644
index 2ee1d257db..0000000000
--- a/include/ruby/internal/intern/gc.h
+++ /dev/null
@@ -1,392 +0,0 @@
-#ifndef RBIMPL_INTERN_GC_H /*-*-C++-*-vi:se ft=cpp:*/
-#define RBIMPL_INTERN_GC_H
-/**
- * @file
- * @author Ruby developers <ruby-core@ruby-lang.org>
- * @copyright This file is a part of the programming language Ruby.
- * Permission is hereby granted, to either redistribute and/or
- * modify this file, provided that the conditions mentioned in the
- * file COPYING are met. Consult the file for details.
- * @warning Symbols prefixed with either `RBIMPL` or `rbimpl` are
- * implementation details. Don't take them as canon. They could
- * rapidly appear then vanish. The name (path) of this header file
- * is also an implementation detail. Do not expect it to persist
- * at the place it is now. Developers are free to move it anywhere
- * anytime at will.
- * @note To ruby-core: remember that this header can be possibly
- * recursively included from extension libraries written in C++.
- * Do not expect for instance `__VA_ARGS__` is always available.
- * We assume C99 for ruby itself but we don't assume languages of
- * extension libraries. They could be written in C++98.
- * @brief Public APIs related to ::rb_mGC.
- */
-#include "ruby/internal/config.h"
-
-#ifdef STDC_HEADERS
-# include <stddef.h> /* size_t */
-#endif
-
-#ifdef HAVE_SYS_TYPES_H
-# include <sys/types.h> /* ssize_t */
-#endif
-
-#include "ruby/internal/attr/cold.h"
-#include "ruby/internal/attr/noreturn.h"
-#include "ruby/internal/attr/nonnull.h"
-#include "ruby/internal/attr/pure.h"
-#include "ruby/internal/dllexport.h"
-#include "ruby/internal/value.h"
-
-RBIMPL_SYMBOL_EXPORT_BEGIN()
-
-/* gc.c */
-
-RBIMPL_ATTR_COLD()
-RBIMPL_ATTR_NORETURN()
-/**
- * Triggers out-of-memory error. If possible it raises ::rb_eNoMemError. But
- * because we are running out of memory that is not always doable. This
- * function tries hard to show something, but ultimately can die silently.
- *
- * @exception rb_eNoMemError Raises it if possible.
- */
-void rb_memerror(void);
-
-RBIMPL_ATTR_PURE()
-/**
- * Queries if the GC is busy.
- *
- * @retval 0 It isn't.
- * @retval 1 It is.
- */
-int rb_during_gc(void);
-
-RBIMPL_ATTR_NONNULL((1))
-/**
- * Marks objects between the two pointers. This is one of the GC utility
- * functions that you can call when you design your own
- * ::rb_data_type_struct::dmark.
- *
- * @pre Continuous memory region from `start` to `end` shall be fully
- * addressable.
- * @param[out] start Pointer to an array of objects.
- * @param[out] end Pointer that terminates the array of objects.
- * @post Objects from `start` (included) to `end` (excluded) are marked.
- *
- * @internal
- *
- * `end` can be NULL... But that just results in no-op.
- */
-void rb_gc_mark_locations(const VALUE *start, const VALUE *end);
-
-/**
- * Identical to rb_mark_hash(), except it marks only values of the table and
- * leave their associated keys unmarked. This is one of the GC utility
- * functions that you can call when you design your own
- * ::rb_data_type_struct::dmark.
- *
- * @warning Of course it can break GC. Leave it unused if unsure.
- * @param[in] tbl A table to mark.
- * @post Values stored in `tbl` are marked.
- */
-void rb_mark_tbl(struct st_table *tbl);
-
-/**
- * Identical to rb_mark_tbl(), except it marks objects using
- * rb_gc_mark_movable(). This is one of the GC utility functions that you can
- * call when you design your own ::rb_data_type_struct::dmark.
- *
- * @warning Of course it can break GC. Leave it unused if unsure.
- * @param[in] tbl A table to mark.
- * @post Values stored in `tbl` are marked.
- */
-void rb_mark_tbl_no_pin(struct st_table *tbl);
-
-/**
- * Identical to rb_mark_hash(), except it marks only keys of the table and
- * leave their associated values unmarked. This is one of the GC utility
- * functions that you can call when you design your own
- * ::rb_data_type_struct::dmark.
- *
- * @warning Of course it can break GC. Leave it unused if unsure.
- * @param[in] tbl A table to mark.
- * @post Keys stored in `tbl` are marked.
- */
-void rb_mark_set(struct st_table *tbl);
-
-/**
- * Marks keys and values associated inside of the given table. This is one of
- * the GC utility functions that you can call when you design your own
- * ::rb_data_type_struct::dmark.
- *
- * @param[in] tbl A table to mark.
- * @post Objects stored in `tbl` are marked.
- */
-void rb_mark_hash(struct st_table *tbl);
-
-/**
- * Updates references inside of tables. After you marked values using
- * rb_mark_tbl_no_pin(), the objects inside of the table could of course be
- * moved. This function is to fixup those references. You can call this from
- * your ::rb_data_type_struct::dcompact.
- *
- * @param[out] ptr A table that potentially includes moved references.
- * @post Moved references, if any, are corrected.
- */
-void rb_gc_update_tbl_refs(st_table *ptr);
-
-/**
- * Identical to rb_gc_mark(), except it allows the passed value be a
- * non-object. For instance pointers to different type of memory regions are
- * allowed here. Such values are silently ignored. This is one of the GC
- * utility functions that you can call when you design your own
- * ::rb_data_type_struct::dmark.
- *
- * @param[out] obj A possible object.
- * @post `obj` is marked, if possible.
- */
-void rb_gc_mark_maybe(VALUE obj);
-
-/**
- * Marks an object. This is one of the GC utility functions that you can call
- * when you design your own ::rb_data_type_struct::dmark.
- *
- * @param[out] obj Arbitrary Ruby object.
- * @post `obj` is marked.
- */
-void rb_gc_mark(VALUE obj);
-
-/**
- * Maybe this is the only function provided for C extensions to control the
- * pinning of objects, so let us describe it in detail. These days Ruby's GC
- * is copying. As far as an object's physical address is guaranteed unused, it
- * can move around the object space. Our GC engine rearranges these objects
- * after it reclaims unreachable objects from our object space, so that the
- * space is compact (improves memory locality). This is called the
- * "compaction" phase, and works well most of the time... as far as there are
- * no C extensions. C extensions complicate the scenario because Ruby core
- * cannot detect any use of the physical address of an object inside of C
- * functions. In order to prevent memory corruptions, objects observable from
- * C extensions are "pinned"; they stick to where they are born until they die,
- * just in case any C extensions touch their raw pointers. This variant of
- * scheme is called "Mostly-Copying" garbage collector. Authors of C
- * extensions, however, can extremely carefully write them to become
- * compaction-aware. To do so avoid referring to a Ruby object from inside of
- * your struct in the first place. But if that is not possible, use this
- * function from your ::rb_data_type_struct::dmark then. This way objects
- * marked using it are considered movable. If you chose this way you have to
- * manually fix up locations of such moved pointers using rb_gc_location().
- *
- * @see Bartlett, Joel F., "Compacting Garbage Collection with Ambiguous
- * Roots", ACM SIGPLAN Lisp Pointers Volume 1 Issue 6 pp. 3-12,
- * April-May-June, 1988. https://doi.org/10.1145/1317224.1317225
- *
- * @param[in] obj Object that is movable.
- * @post Values stored in `tbl` are marked.
- */
-void rb_gc_mark_movable(VALUE obj);
-
-/**
- * Finds a new "location" of an object. An object can be moved on compaction.
- * This function projects its new abode, or just returns the passed object if
- * not moved. This is one of the GC utility functions that you can call when
- * you design your own ::rb_data_type_struct::dcompact.
- *
- * @param[in] obj An object, possibly already moved to somewhere else.
- * @return An object, which holds the current contents of former `obj`.
- */
-VALUE rb_gc_location(VALUE obj);
-
-/**
- * Asserts that the passed object is no longer needed. Such objects are
- * reclaimed sooner or later so this function is not mandatory. But sometimes
- * you can know from your application knowledge that an object is surely dead
- * at some point. Calling this as a hint can be a polite way.
- *
- * @param[out] obj Object, dead.
- * @pre `obj` have never been passed to this function before.
- * @post `obj` could be invalidated.
- * @warning It is a failure to pass an object multiple times to this
- * function.
- * @deprecated This is now a no-op function.
- */
-RBIMPL_ATTR_DEPRECATED(("this is now a no-op function"))
-void rb_gc_force_recycle(VALUE obj);
-
-/**
- * Triggers a GC process. This was the only GC entry point that we had at the
- * beginning. Over time our GC evolved. Now what this function does is just a
- * very simplified variation of the entire GC algorithms. A series of
- * procedures kicked by this API is called a "full" GC.
- *
- * - It immediately scans the entire object space to sort the dead.
- * - It immediately reclaims any single dead bodies to reuse later.
- *
- * It is worth noting that the procedures above do not include evaluations of
- * finalisers. They run later.
- *
- * @internal
- *
- * Finalisers are deferred until we can handle interrupts. See
- * `rb_postponed_job_flush` in vm_trace.c.
- *
- * Of course there are GC that are not "full". For instance this one and the
- * GC which runs when we are running out of memory are different. See
- * `gc_profile_record_flag` defined in gc.c for the kinds of GC.
- *
- * In spite of the name this is not what everything that a GC can trigger. As
- * of writing it seems this function does not trigger compaction. But this
- * might change in future.
- */
-void rb_gc(void);
-
-/**
- * Copy&paste an object's finaliser to another. This is one of the GC utility
- * functions that you can call when you design your own `initialize_copy`,
- * `initialize_dup`, `initialize_clone`.
- *
- * @param[out] dst Destination object.
- * @param[in] src Source object.
- * @post `dst` and `src` share the same finaliser.
- *
- * @internal
- *
- * But isn't it easier for you to call super, and let `Object#initialize_copy`
- * call this function instead?
- */
-void rb_gc_copy_finalizer(VALUE dst, VALUE src);
-
-/**
- * (Re-) enables GC. This makes sense only after you called rb_gc_disable().
- *
- * @retval RUBY_Qtrue GC was disabled before.
- * @retval RUBY_Qfalse GC was enabled before.
- * @post GC is enabled.
- *
- * @internal
- *
- * This is one of such exceptional functions that does not raise both Ruby
- * exceptions and C++ exceptions.
- */
-VALUE rb_gc_enable(void);
-
-/**
- * Disables GC. This prevents automatic GC runs when the process is running
- * out of memory. Such situations shall result in rb_memerror(). However this
- * does not prevent users from manually invoking rb_gc(). That should work.
- * People abused this by disabling GC at the beginning of an event loop,
- * process events without GC overheads, then manually force reclaiming garbage
- * at the bottom of the loop. However because our GC is now much smarter than
- * just calling rb_gc(), this technique is proven to be sub-optimal these days.
- * It is believed that there is currently practically no needs of this
- * function.
- *
- * @retval RUBY_Qtrue GC was disabled before.
- * @retval RUBY_Qfalse GC was enabled before.
- * @post GC is disabled.
- */
-VALUE rb_gc_disable(void);
-
-/**
- * Identical to rb_gc(), except the return value.
- *
- * @return Always returns ::RUBY_Qnil.
- */
-VALUE rb_gc_start(void);
-
-/**
- * Assigns a finaliser for an object. Each objects can have objects (typically
- * blocks) that run immediately after that object dies. They are called
- * finalisers of an object. This function associates a finaliser object with a
- * target object.
- *
- * @note Note that finalisers run _after_ the object they finalise dies. You
- * cannot for instance call its methods.
- * @note If your finaliser references the object it finalises that object
- * loses any chance to become a garbage; effectively leaks memory until
- * the end of the process.
- *
- * @param[in] obj Target to finalise.
- * @param[in] block Something `call`able.
- * @exception rb_eRuntimeError Somehow `obj` cannot have finalisers.
- * @exception rb_eFrozenError `obj` is frozen.
- * @exception rb_eArgError `block` doesn't respond to `call`.
- * @return The passed `block`.
- * @post `block` runs after `obj` dies.
- */
-VALUE rb_define_finalizer(VALUE obj, VALUE block);
-
-/**
- * Modifies the object so that it has no finalisers at all. This function is
- * mainly provided for symmetry. No practical usages can be thought of.
- *
- * @param[out] obj Object to clear its finalisers.
- * @exception rb_eFrozenError `obj` is frozen.
- * @return The passed `obj`.
- * @post `obj` has no finalisers.
- * @note There is no way to undefine a specific part of many finalisers
- * that `obj` could have. All you can do is to clear them all.
- */
-VALUE rb_undefine_finalizer(VALUE obj);
-
-/**
- * Identical to rb_gc_stat(), with "count" parameter.
- *
- * @return Lifetime total number of runs of GC.
- */
-size_t rb_gc_count(void);
-
-/**
- * Obtains various GC related profiles. The parameter can be either a Symbol
- * or a Hash. If a Hash is passed, it is filled with everything currently
- * available. If a Symbol is passed just that portion is returned.
- *
- * Possible variations of keys you can pass here change from version to
- * version. You can get the list of known keys by passing an empty hash and
- * let it be filled.
- *
- * @param[in,out] key_or_buf A Symbol, or a Hash.
- * @exception rb_eTypeError Neither Symbol nor Hash.
- * @exception rb_eFrozenError Frozen hash is passed.
- * @return In case a Hash is passed it returns 0. Otherwise the
- * profile value associated with the given key is returned.
- * @post In case a Hash is passed it is filled with values.
- */
-size_t rb_gc_stat(VALUE key_or_buf);
-
-/**
- * Obtains various info regarding the most recent GC run. This includes for
- * instance the reason of the GC. The parameter can be either a Symbol or a
- * Hash. If a Hash is passed, it is filled with everything currently
- * available. If a Symbol is passed just that portion is returned.
- *
- * Possible variations of keys you can pass here change from version to
- * version. You can get the list of known keys by passing an empty hash and
- * let it be filled.
- *
- * @param[in,out] key_or_buf A Symbol, or a Hash.
- * @exception rb_eTypeError Neither Symbol nor Hash.
- * @exception rb_eFrozenError Frozen hash is passed.
- * @return In case a Hash is passed it returns that hash. Otherwise
- * the profile value associated with the given key is returned.
- * @post In case a Hash is passed it is filled with values.
- */
-VALUE rb_gc_latest_gc_info(VALUE key_or_buf);
-
-/**
- * Informs that there are external memory usages. Our GC runs when we are
- * running out of memory. The amount of memory, however, can increase/decrease
- * behind-the-scene. For instance DLLs can allocate memories using `mmap(2)`
- * etc, which are opaque to us. Registering such external allocations using
- * this function enables proper detection of how much memories an object used
- * as a whole. That will trigger GCs more often than it would otherwise. You
- * can also pass negative numbers here, to indicate that such external
- * allocations are gone.
- *
- * @param[in] diff Amount of memory increased(+)/decreased(-).
- */
-void rb_gc_adjust_memory_usage(ssize_t diff);
-
-RBIMPL_SYMBOL_EXPORT_END()
-
-#endif /* RBIMPL_INTERN_GC_H */
diff --git a/include/ruby/internal/intern/load.h b/include/ruby/internal/intern/load.h
index 288a16c2ec..9ceb98c2e4 100644
--- a/include/ruby/internal/intern/load.h
+++ b/include/ruby/internal/intern/load.h
@@ -177,6 +177,43 @@ VALUE rb_f_require(VALUE self, VALUE feature);
VALUE rb_require_string(VALUE feature);
/**
+ * Resolves and returns a symbol of a function in the native extension
+ * specified by the feature and symbol names. Extensions will use this function
+ * to access the symbols provided by other native extensions.
+ *
+ * @param[in] feature Name of a feature, e.g. `"json"`.
+ * @param[in] symbol Name of a symbol defined by the feature.
+ * @return The resolved symbol of a function, defined and externed by the
+ * specified feature. It may be NULL if the feature is not loaded,
+ * the feature is not extension, or the symbol is not found.
+ */
+void *rb_ext_resolve_symbol(const char *feature, const char *symbol);
+
+/**
+ * This macro is to provide backwards compatibility. It provides a way to
+ * define function prototypes and resolving function symbols in a safe way.
+ *
+ * ```CXX
+ * // prototypes
+ * #ifdef HAVE_RB_EXT_RESOLVE_SYMBOL
+ * VALUE *(*other_extension_func)(VALUE,VALUE);
+ * #else
+ * VALUE other_extension_func(VALUE);
+ * #endif
+ *
+ * // in Init_xxx()
+ * #ifdef HAVE_RB_EXT_RESOLVE_SYMBOL
+ * other_extension_func = \
+ * (VALUE(*)(VALUE,VALUE))rb_ext_resolve_symbol(fname, sym_name);
+ * if (other_extension_func == NULL) {
+ * // raise your own error
+ * }
+ * #endif
+ * ```
+ */
+#define HAVE_RB_EXT_RESOLVE_SYMBOL 1
+
+/**
* @name extension configuration
* @{
*/
diff --git a/include/ruby/internal/intern/process.h b/include/ruby/internal/intern/process.h
index 7a7b24ed4b..cfa5e13162 100644
--- a/include/ruby/internal/intern/process.h
+++ b/include/ruby/internal/intern/process.h
@@ -31,6 +31,15 @@ RBIMPL_SYMBOL_EXPORT_BEGIN()
/* process.c */
/**
+ * Wait for the specified process to terminate, reap it, and return its status.
+ *
+ * @param[in] pid The process ID to wait for.
+ * @param[in] flags The flags to pass to waitpid(2).
+ * @return VALUE An instance of Process::Status.
+ */
+VALUE rb_process_status_wait(rb_pid_t pid, int flags);
+
+/**
* Sets the "last status", or the `$?`.
*
* @param[in] status The termination status, as defined in `waitpid(3posix)`.
@@ -247,7 +256,7 @@ rb_pid_t rb_spawn_err(int argc, const VALUE *argv, char *errbuf, size_t buflen);
*
* @internal
*
- * This function might or might not exist depending on `./confiugre` result.
+ * This function might or might not exist depending on `./configure` result.
* It must be a portability hell. Better not use.
*/
VALUE rb_proc_times(VALUE _);
diff --git a/include/ruby/internal/intern/re.h b/include/ruby/internal/intern/re.h
index 31f5593275..4dd58b469b 100644
--- a/include/ruby/internal/intern/re.h
+++ b/include/ruby/internal/intern/re.h
@@ -87,11 +87,6 @@ void rb_match_busy(VALUE md);
* @retval RUBY_Qfalse There is a `n`-th capture and is empty.
* @retval RUBY_Qtrue There is a `n`-th capture that has something.
*
- * @internal
- *
- * @shyouhei wonders: why there are both rb_reg_match_defined() and
- * rb_match_nth_defined, which are largely the same things, but do not share
- * their implementations at all?
*/
VALUE rb_reg_nth_defined(int n, VALUE md);
diff --git a/include/ruby/internal/intern/select.h b/include/ruby/internal/intern/select.h
index fabc287cd1..6ba84c6e63 100644
--- a/include/ruby/internal/intern/select.h
+++ b/include/ruby/internal/intern/select.h
@@ -76,7 +76,7 @@ struct timeval;
*
* Although any file descriptors are possible here, it makes completely no
* sense to pass a descriptor that is not `O_NONBLOCK`. If you want to know
- * the reason for this limitatuon in detail, you might find this thread super
+ * the reason for this limitation in detail, you might find this thread super
* interesting: https://lkml.org/lkml/2004/10/6/117
*/
int rb_thread_fd_select(int nfds, rb_fdset_t *rfds, rb_fdset_t *wfds, rb_fdset_t *efds, struct timeval *timeout);
diff --git a/include/ruby/internal/intern/signal.h b/include/ruby/internal/intern/signal.h
index 84f7558404..e5b6d6c3d5 100644
--- a/include/ruby/internal/intern/signal.h
+++ b/include/ruby/internal/intern/signal.h
@@ -113,12 +113,6 @@ RBIMPL_ATTR_NONNULL(())
*/
VALUE rb_f_kill(int argc, const VALUE *argv);
-/* This must be private, @shyouhei guesses. */
-#ifdef POSIX_SIGNAL
-#define posix_signal ruby_posix_signal
-void (*posix_signal(int, void (*)(int)))(int);
-#endif
-
RBIMPL_ATTR_PURE()
/**
* Queries the name of the signal. It returns for instance `"KILL"` for
diff --git a/include/ruby/internal/intern/struct.h b/include/ruby/internal/intern/struct.h
index 312cf444e2..4510508d77 100644
--- a/include/ruby/internal/intern/struct.h
+++ b/include/ruby/internal/intern/struct.h
@@ -46,10 +46,10 @@ VALUE rb_struct_new(VALUE klass, ...);
*
* @param[in] name Name of the class.
* @param[in] ... Arbitrary number of `const char*`, terminated by
- * zero. Each of which are the name of fields.
+ * NULL. Each of which are the name of fields.
* @exception rb_eNameError `name` is not a constant name.
* @exception rb_eTypeError `name` is already taken.
- * @exception rb_eArgError Duplicated field name.
+ * @exception rb_eArgError Duplicated field name.
* @return The defined class.
* @post Global toplevel constant `name` is defined.
* @note `name` is allowed to be a null pointer. This function creates
@@ -70,10 +70,10 @@ RBIMPL_ATTR_NONNULL((2))
* @param[out] space Namespace that the defining class shall reside.
* @param[in] name Name of the class.
* @param[in] ... Arbitrary number of `const char*`, terminated by
- * zero. Each of which are the name of fields.
+ * NULL. Each of which are the name of fields.
* @exception rb_eNameError `name` is not a constant name.
* @exception rb_eTypeError `name` is already taken.
- * @exception rb_eArgError Duplicated field name.
+ * @exception rb_eArgError Duplicated field name.
* @return The defined class.
* @post `name` is a constant under `space`.
* @note In contrast to rb_struct_define(), it doesn't make any sense to
@@ -164,10 +164,10 @@ VALUE rb_struct_alloc_noinit(VALUE klass);
* @param[in] super Superclass of the defining class.
* @param[in] func Must be 0 for extension libraries.
* @param[in] ... Arbitrary number of `const char*`, terminated by
- * zero. Each of which are the name of fields.
+ * NULL. Each of which are the name of fields.
* @exception rb_eNameError `name` is not a constant name.
* @exception rb_eTypeError `name` is already taken.
- * @exception rb_eArgError Duplicated field name.
+ * @exception rb_eArgError Duplicated field name.
* @return The defined class.
* @post Global toplevel constant `name` is defined.
* @note `name` is allowed to be a null pointer. This function creates
@@ -187,10 +187,10 @@ RBIMPL_ATTR_NONNULL((2))
* @param[in] super Superclass of the defining class.
* @param[in] alloc Must be 0 for extension libraries.
* @param[in] ... Arbitrary number of `const char*`, terminated by
- * zero. Each of which are the name of fields.
+ * NULL. Each of which are the name of fields.
* @exception rb_eNameError `class_name` is not a constant name.
* @exception rb_eTypeError `class_name` is already taken.
- * @exception rb_eArgError Duplicated field name.
+ * @exception rb_eArgError Duplicated field name.
* @return The defined class.
* @post `class_name` is a constant under `outer`.
* @note In contrast to rb_struct_define_without_accessor(), it doesn't
@@ -198,6 +198,20 @@ RBIMPL_ATTR_NONNULL((2))
*/
VALUE rb_struct_define_without_accessor_under(VALUE outer, const char *class_name, VALUE super, rb_alloc_func_t alloc, ...);
+/**
+ * Defines an anonymous data class.
+ *
+ * @endinternal
+ *
+ * @param[in] super Superclass of the defining class. Must be a
+ * descendant of ::rb_cData, or 0 as ::rb_cData.
+ * @param[in] ... Arbitrary number of `const char*`, terminated by
+ * NULL. Each of which are the name of fields.
+ * @exception rb_eArgError Duplicated field name.
+ * @return The defined class.
+ */
+VALUE rb_data_define(VALUE super, ...);
+
RBIMPL_SYMBOL_EXPORT_END()
#endif /* RBIMPL_INTERN_STRUCT_H */
diff --git a/include/ruby/internal/memory.h b/include/ruby/internal/memory.h
index 6884db195d..8f00787512 100644
--- a/include/ruby/internal/memory.h
+++ b/include/ruby/internal/memory.h
@@ -62,7 +62,7 @@
#include "ruby/backward/2/assume.h"
#include "ruby/defines.h"
-/** @cond INTENAL_MACRO */
+/** @cond INTERNAL_MACRO */
/* Make alloca work the best possible way. */
#if defined(alloca)
diff --git a/include/ruby/internal/newobj.h b/include/ruby/internal/newobj.h
index a8a5557a25..ba1d7cbe59 100644
--- a/include/ruby/internal/newobj.h
+++ b/include/ruby/internal/newobj.h
@@ -172,6 +172,8 @@ RBIMPL_ATTR_DEPRECATED(("This is no longer how Object#clone works."))
static inline void
rb_clone_setup(VALUE clone, VALUE obj)
{
+ (void)clone;
+ (void)obj;
return;
}
@@ -189,6 +191,8 @@ RBIMPL_ATTR_DEPRECATED(("This is no longer how Object#dup works."))
static inline void
rb_dup_setup(VALUE dup, VALUE obj)
{
+ (void)dup;
+ (void)obj;
return;
}
diff --git a/include/ruby/internal/rgengc.h b/include/ruby/internal/rgengc.h
deleted file mode 100644
index 7ea04442f6..0000000000
--- a/include/ruby/internal/rgengc.h
+++ /dev/null
@@ -1,443 +0,0 @@
-#ifndef RBIMPL_RGENGC_H /*-*-C++-*-vi:se ft=cpp:*/
-#define RBIMPL_RGENGC_H
-/**
- * @file
- * @author Ruby developers <ruby-core@ruby-lang.org>
- * @copyright This file is a part of the programming language Ruby.
- * Permission is hereby granted, to either redistribute and/or
- * modify this file, provided that the conditions mentioned in the
- * file COPYING are met. Consult the file for details.
- * @warning Symbols prefixed with either `RBIMPL` or `rbimpl` are
- * implementation details. Don't take them as canon. They could
- * rapidly appear then vanish. The name (path) of this header file
- * is also an implementation detail. Do not expect it to persist
- * at the place it is now. Developers are free to move it anywhere
- * anytime at will.
- * @note To ruby-core: remember that this header can be possibly
- * recursively included from extension libraries written in C++.
- * Do not expect for instance `__VA_ARGS__` is always available.
- * We assume C99 for ruby itself but we don't assume languages of
- * extension libraries. They could be written in C++98.
- * @brief RGENGC write-barrier APIs.
- * @see Sasada, K., "Gradual write-barrier insertion into a Ruby
- * interpreter", in proceedings of the 2019 ACM SIGPLAN
- * International Symposium on Memory Management (ISMM 2019), pp
- * 115-121, 2019. https://doi.org/10.1145/3315573.3329986
- */
-#include "ruby/internal/attr/artificial.h"
-#include "ruby/internal/attr/maybe_unused.h"
-#include "ruby/internal/attr/pure.h"
-#include "ruby/internal/dllexport.h"
-#include "ruby/internal/special_consts.h"
-#include "ruby/internal/stdbool.h"
-#include "ruby/internal/value.h"
-#include "ruby/assert.h"
-
-/**
- * @private
- *
- * @deprecated This macro once was a thing in the old days, but makes no sense
- * any longer today. Exists here for backwards compatibility
- * only. You can safely forget about it.
- */
-#undef USE_RGENGC
-#define USE_RGENGC 1
-
-/**
- * @private
- *
- * This is a compile-time flag to enable/disable incremental GC feature. It
- * has to be set at the time ruby itself compiles. Makes no sense for 3rd
- * parties. It is safe for them to set this though; that just doesn't change
- * anything.
- */
-#ifndef USE_RINCGC
-# define USE_RINCGC 1
-#endif
-
-/**
- * @deprecated This macro seems broken. Setting this to anything other than
- * zero just doesn't compile. We need to KonMari.
- */
-#ifndef USE_RGENGC_LOGGING_WB_UNPROTECT
-# define USE_RGENGC_LOGGING_WB_UNPROTECT 0
-#endif
-
-/**
- * @private
- *
- * This is a compile-time flag to enable/disable write barrier for
- * struct ::RArray. It has to be set at the time ruby itself compiles. Makes
- * no sense for 3rd parties.
- */
-#ifndef RGENGC_WB_PROTECTED_ARRAY
-# define RGENGC_WB_PROTECTED_ARRAY 1
-#endif
-
-/**
- * @private
- *
- * This is a compile-time flag to enable/disable write barrier for
- * struct ::RHash. It has to be set at the time ruby itself compiles. Makes
- * no sense for 3rd parties.
- */
-#ifndef RGENGC_WB_PROTECTED_HASH
-# define RGENGC_WB_PROTECTED_HASH 1
-#endif
-
-/**
- * @private
- *
- * This is a compile-time flag to enable/disable write barrier for
- * struct ::RStruct. It has to be set at the time ruby itself compiles. Makes
- * no sense for 3rd parties.
- */
-#ifndef RGENGC_WB_PROTECTED_STRUCT
-# define RGENGC_WB_PROTECTED_STRUCT 1
-#endif
-
-/**
- * @private
- *
- * This is a compile-time flag to enable/disable write barrier for
- * struct ::RString. It has to be set at the time ruby itself compiles. Makes
- * no sense for 3rd parties.
- */
-#ifndef RGENGC_WB_PROTECTED_STRING
-# define RGENGC_WB_PROTECTED_STRING 1
-#endif
-
-/**
- * @private
- *
- * This is a compile-time flag to enable/disable write barrier for
- * struct ::RObject. It has to be set at the time ruby itself compiles. Makes
- * no sense for 3rd parties.
- */
-#ifndef RGENGC_WB_PROTECTED_OBJECT
-# define RGENGC_WB_PROTECTED_OBJECT 1
-#endif
-
-/**
- * @private
- *
- * This is a compile-time flag to enable/disable write barrier for
- * struct ::RRegexp. It has to be set at the time ruby itself compiles. Makes
- * no sense for 3rd parties.
- */
-#ifndef RGENGC_WB_PROTECTED_REGEXP
-# define RGENGC_WB_PROTECTED_REGEXP 1
-#endif
-
-/**
- * @private
- *
- * This is a compile-time flag to enable/disable write barrier for
- * struct ::RClass. It has to be set at the time ruby itself compiles. Makes
- * no sense for 3rd parties.
- */
-#ifndef RGENGC_WB_PROTECTED_CLASS
-# define RGENGC_WB_PROTECTED_CLASS 1
-#endif
-
-/**
- * @private
- *
- * This is a compile-time flag to enable/disable write barrier for
- * struct ::RFloat. It has to be set at the time ruby itself compiles. Makes
- * no sense for 3rd parties.
- */
-#ifndef RGENGC_WB_PROTECTED_FLOAT
-# define RGENGC_WB_PROTECTED_FLOAT 1
-#endif
-
-/**
- * @private
- *
- * This is a compile-time flag to enable/disable write barrier for
- * struct ::RComplex. It has to be set at the time ruby itself compiles.
- * Makes no sense for 3rd parties.
- */
-#ifndef RGENGC_WB_PROTECTED_COMPLEX
-# define RGENGC_WB_PROTECTED_COMPLEX 1
-#endif
-
-/**
- * @private
- *
- * This is a compile-time flag to enable/disable write barrier for
- * struct ::RRational. It has to be set at the time ruby itself compiles.
- * Makes no sense for 3rd parties.
- */
-#ifndef RGENGC_WB_PROTECTED_RATIONAL
-# define RGENGC_WB_PROTECTED_RATIONAL 1
-#endif
-
-/**
- * @private
- *
- * This is a compile-time flag to enable/disable write barrier for
- * struct ::RBignum. It has to be set at the time ruby itself compiles. Makes
- * no sense for 3rd parties.
- */
-#ifndef RGENGC_WB_PROTECTED_BIGNUM
-# define RGENGC_WB_PROTECTED_BIGNUM 1
-#endif
-
-/**
- * @private
- *
- * @deprecated This macro once was a thing in the old days, but makes no sense
- * any longer today. Exists here for backwards compatibility
- * only. You can safely forget about it.
- *
- * @internal
- *
- * @shyouhei doesn't think anybody uses this right now.
- */
-#ifndef RGENGC_WB_PROTECTED_NODE_CREF
-# define RGENGC_WB_PROTECTED_NODE_CREF 1
-#endif
-
-/**
- * @defgroup rgengc Write barrier (WB) interfaces:
- *
- * @note The following core interfaces can be changed in the future. Please
- * catch up if you want to insert WB into C-extensions correctly.
- *
- * @{
- */
-
-/**
- * Declaration of a "back" pointer. This is a write barrier for new reference
- * from "old" generation to "young" generation. It writes `young` into
- * `*slot`, which is a pointer inside of `old`.
- *
- * @param[in] old An old object.
- * @param[in] slot A pointer inside of `old`.
- * @param[out] young A young object.
- */
-#define RB_OBJ_WRITE(old, slot, young) \
- RBIMPL_CAST(rb_obj_write((VALUE)(old), (VALUE *)(slot), (VALUE)(young), __FILE__, __LINE__))
-
-/**
- * Identical to #RB_OBJ_WRITE(), except it doesn't write any values, but only a
- * WB declaration. `oldv` is replaced value with `b` (not used in current
- * Ruby).
- *
- * @param[in] old An old object.
- * @param[in] oldv An object previously stored inside of `old`.
- * @param[out] young A young object.
- */
-#define RB_OBJ_WRITTEN(old, oldv, young) \
- RBIMPL_CAST(rb_obj_written((VALUE)(old), (VALUE)(oldv), (VALUE)(young), __FILE__, __LINE__))
-/** @} */
-
-#define OBJ_PROMOTED_RAW RB_OBJ_PROMOTED_RAW /**< @old{RB_OBJ_PROMOTED_RAW} */
-#define OBJ_PROMOTED RB_OBJ_PROMOTED /**< @old{RB_OBJ_PROMOTED} */
-#define OBJ_WB_UNPROTECT RB_OBJ_WB_UNPROTECT /**< @old{RB_OBJ_WB_UNPROTECT} */
-
-/**
- * Asserts that the passed object is not fenced by write barriers. Objects of
- * such property do not contribute to generational GCs. They are scanned
- * always.
- *
- * @param[out] x An object that would not be protected by the barrier.
- */
-#define RB_OBJ_WB_UNPROTECT(x) rb_obj_wb_unprotect(x, __FILE__, __LINE__)
-
-/**
- * Identical to #RB_OBJ_WB_UNPROTECT(), except it can also assert that the
- * given object is of given type.
- *
- * @param[in] type One of `ARRAY`, `STRING`, etc.
- * @param[out] obj An object of `type` that would not be protected.
- *
- * @internal
- *
- * @shyouhei doesn't understand why this has to be visible from extensions.
- */
-#define RB_OBJ_WB_UNPROTECT_FOR(type, obj) \
- (RGENGC_WB_PROTECTED_##type ? OBJ_WB_UNPROTECT(obj) : obj)
-
-/**
- * @private
- *
- * This is an implementation detail of rb_obj_wb_unprotect(). People don't use
- * it directly.
- */
-#define RGENGC_LOGGING_WB_UNPROTECT rb_gc_unprotect_logging
-
-/** @cond INTERNAL_MACRO */
-#define RB_OBJ_PROMOTED_RAW RB_OBJ_PROMOTED_RAW
-#define RB_OBJ_PROMOTED RB_OBJ_PROMOTED
-/** @endcond */
-
-RBIMPL_SYMBOL_EXPORT_BEGIN()
-/**
- * This is the implementation of #RB_OBJ_WRITE(). People don't use it
- * directly.
- *
- * @param[in] old An object that points to `young`.
- * @param[out] young An object that is referenced from `old`.
- */
-void rb_gc_writebarrier(VALUE old, VALUE young);
-
-/**
- * This is the implementation of #RB_OBJ_WB_UNPROTECT(). People don't use it
- * directly.
- *
- * @param[out] obj An object that does not participate in WB.
- */
-void rb_gc_writebarrier_unprotect(VALUE obj);
-
-#if USE_RGENGC_LOGGING_WB_UNPROTECT
-/**
- * @private
- *
- * This is the implementation of #RGENGC_LOGGING_WB_UNPROTECT(). People
- * don't use it directly.
- *
- * @param[in] objptr Don't know why this is a pointer to void but in
- * reality this is a pointer to an object that is about
- * to be un-protected.
- * @param[in] filename Pass C's `__FILE__` here.
- * @param[in] line Pass C's `__LINE__` here.
- */
-void rb_gc_unprotect_logging(void *objptr, const char *filename, int line);
-#endif
-
-RBIMPL_SYMBOL_EXPORT_END()
-
-RBIMPL_ATTR_PURE_UNLESS_DEBUG()
-RBIMPL_ATTR_ARTIFICIAL()
-/**
- * This is the implementation of #RB_OBJ_PROMOTED(). People don't use it
- * directly.
- *
- * @param[in] obj An object to query.
- * @retval true The object is "promoted".
- * @retval false The object is young. Have not experienced GC at all.
- */
-static inline bool
-RB_OBJ_PROMOTED_RAW(VALUE obj)
-{
- RBIMPL_ASSERT_OR_ASSUME(RB_FL_ABLE(obj));
- return RB_FL_ANY_RAW(obj, RUBY_FL_PROMOTED);
-}
-
-RBIMPL_ATTR_PURE_UNLESS_DEBUG()
-RBIMPL_ATTR_ARTIFICIAL()
-/**
- * Tests if the object is "promoted" -- that is, whether the object experienced
- * one or more GC marks.
- *
- * @param[in] obj An object to query.
- * @retval true The object is "promoted".
- * @retval false The object is young. Have not experienced GC at all.
- * @note Hello, is anyone actively calling this function? @shyouhei have
- * never seen any actual usages outside of the GC implementation
- * itself.
- */
-static inline bool
-RB_OBJ_PROMOTED(VALUE obj)
-{
- if (! RB_FL_ABLE(obj)) {
- return false;
- }
- else {
- return RB_OBJ_PROMOTED_RAW(obj);
- }
-}
-
-/**
- * This is the implementation of #RB_OBJ_WB_UNPROTECT(). People don't use it
- * directly.
- *
- * @param[out] x An object that does not participate in WB.
- * @param[in] filename C's `__FILE__` of the caller function.
- * @param[in] line C's `__LINE__` of the caller function.
- * @return x
- */
-static inline VALUE
-rb_obj_wb_unprotect(
- VALUE x,
- RBIMPL_ATTR_MAYBE_UNUSED()
- const char *filename,
- RBIMPL_ATTR_MAYBE_UNUSED()
- int line)
-{
-#if USE_RGENGC_LOGGING_WB_UNPROTECT
- RGENGC_LOGGING_WB_UNPROTECT(RBIMPL_CAST((void *)x), filename, line);
-#endif
- rb_gc_writebarrier_unprotect(x);
- return x;
-}
-
-/**
- * @private
- *
- * This is the implementation of #RB_OBJ_WRITTEN(). People don't use it
- * directly.
- *
- * @param[in] a An old object.
- * @param[in] oldv An object previously stored inside of `old`.
- * @param[out] b A young object.
- * @param[in] filename C's `__FILE__` of the caller function.
- * @param[in] line C's `__LINE__` of the caller function.
- * @return a
- */
-static inline VALUE
-rb_obj_written(
- VALUE a,
- RBIMPL_ATTR_MAYBE_UNUSED()
- VALUE oldv,
- VALUE b,
- RBIMPL_ATTR_MAYBE_UNUSED()
- const char *filename,
- RBIMPL_ATTR_MAYBE_UNUSED()
- int line)
-{
-#if USE_RGENGC_LOGGING_WB_UNPROTECT
- RGENGC_LOGGING_OBJ_WRITTEN(a, oldv, b, filename, line);
-#endif
-
- if (!RB_SPECIAL_CONST_P(b)) {
- rb_gc_writebarrier(a, b);
- }
-
- return a;
-}
-
-/**
- * @private
- *
- * This is the implementation of #RB_OBJ_WRITE(). People don't use it
- * directly.
- *
- * @param[in] a An old object.
- * @param[in] slot A pointer inside of `old`.
- * @param[out] b A young object.
- * @param[in] filename C's `__FILE__` of the caller function.
- * @param[in] line C's `__LINE__` of the caller function.
- * @return a
- */
-static inline VALUE
-rb_obj_write(
- VALUE a, VALUE *slot, VALUE b,
- RBIMPL_ATTR_MAYBE_UNUSED()
- const char *filename,
- RBIMPL_ATTR_MAYBE_UNUSED()
- int line)
-{
-#ifdef RGENGC_LOGGING_WRITE
- RGENGC_LOGGING_WRITE(a, slot, b, filename, line);
-#endif
-
- *slot = b;
-
- rb_obj_written(a, RUBY_Qundef /* ignore `oldv' now */, b, filename, line);
- return a;
-}
-
-#endif /* RBIMPL_RGENGC_H */
diff --git a/include/ruby/io.h b/include/ruby/io.h
index 88029b1bb9..e9dfeda5b1 100644
--- a/include/ruby/io.h
+++ b/include/ruby/io.h
@@ -49,11 +49,11 @@
/** @endcond */
#include "ruby/internal/attr/const.h"
+#include "ruby/internal/attr/packed_struct.h"
#include "ruby/internal/attr/pure.h"
#include "ruby/internal/attr/noreturn.h"
#include "ruby/internal/dllexport.h"
#include "ruby/internal/value.h"
-#include "ruby/backward/2/attributes.h" /* PACKED_STRUCT_UNALIGNED */
// IO#wait, IO#wait_readable, IO#wait_writable, IO#wait_priority are defined by this implementation.
#define RUBY_IO_WAIT_METHODS
@@ -78,17 +78,20 @@ RUBY_EXTERN VALUE rb_eIOTimeoutError;
*
* This is visible from extension libraries because `io/wait` wants it.
*/
-typedef enum {
+enum rb_io_event {
RUBY_IO_READABLE = RB_WAITFD_IN, /**< `IO::READABLE` */
RUBY_IO_WRITABLE = RB_WAITFD_OUT, /**< `IO::WRITABLE` */
RUBY_IO_PRIORITY = RB_WAITFD_PRI, /**< `IO::PRIORITY` */
-} rb_io_event_t;
+};
+
+typedef enum rb_io_event rb_io_event_t;
/**
* IO buffers. This is an implementation detail of ::rb_io_t::wbuf and
* ::rb_io_t::rbuf. People don't manipulate it directly.
*/
-PACKED_STRUCT_UNALIGNED(struct rb_io_buffer_t {
+RBIMPL_ATTR_PACKED_STRUCT_UNALIGNED_BEGIN()
+struct rb_io_internal_buffer {
/** Pointer to the underlying memory region, of at least `capa` bytes. */
char *ptr; /* off + len <= capa */
@@ -101,10 +104,10 @@ PACKED_STRUCT_UNALIGNED(struct rb_io_buffer_t {
/** Designed capacity of the buffer. */
int capa;
-});
+} RBIMPL_ATTR_PACKED_STRUCT_UNALIGNED_END();
/** @alias{rb_io_buffer_t} */
-typedef struct rb_io_buffer_t rb_io_buffer_t;
+typedef struct rb_io_internal_buffer rb_io_buffer_t;
/** Decomposed encoding flags (e.g. `"enc:enc2""`). */
/*
@@ -113,7 +116,7 @@ typedef struct rb_io_buffer_t rb_io_buffer_t;
* e1 NULL force_encoding(e1) convert str.encoding to e1
* e1 e2 convert from e2 to e1 convert str.encoding to e2
*/
-struct rb_io_enc_t {
+struct rb_io_encoding {
/** Internal encoding. */
rb_encoding *enc;
/** External encoding. */
@@ -134,40 +137,51 @@ struct rb_io_enc_t {
VALUE ecopts;
};
+#ifndef HAVE_RB_IO_T
+#define HAVE_RB_IO_T 1
/** Ruby's IO, metadata and buffers. */
-typedef struct rb_io_t {
-
+struct rb_io {
/** The IO's Ruby level counterpart. */
+ RBIMPL_ATTR_DEPRECATED(("with no replacement"))
VALUE self;
/** stdio ptr for read/write, if available. */
+ RBIMPL_ATTR_DEPRECATED(("with no replacement"))
FILE *stdio_file;
/** file descriptor. */
+ RBIMPL_ATTR_DEPRECATED(("rb_io_descriptor"))
int fd;
/** mode flags: FMODE_XXXs */
+ RBIMPL_ATTR_DEPRECATED(("rb_io_mode"))
int mode;
/** child's pid (for pipes) */
+ RBIMPL_ATTR_DEPRECATED(("with no replacement"))
rb_pid_t pid;
/** number of lines read */
+ RBIMPL_ATTR_DEPRECATED(("with no replacement"))
int lineno;
/** pathname for file */
+ RBIMPL_ATTR_DEPRECATED(("rb_io_path"))
VALUE pathv;
/** finalize proc */
- void (*finalize)(struct rb_io_t*,int);
+ RBIMPL_ATTR_DEPRECATED(("with no replacement"))
+ void (*finalize)(struct rb_io*,int);
/** Write buffer. */
+ RBIMPL_ATTR_DEPRECATED(("with no replacement"))
rb_io_buffer_t wbuf;
/**
* (Byte) read buffer. Note also that there is a field called
* ::rb_io_t::cbuf, which also concerns read IO.
*/
+ RBIMPL_ATTR_DEPRECATED(("with no replacement"))
rb_io_buffer_t rbuf;
/**
@@ -175,20 +189,25 @@ typedef struct rb_io_t {
*
* @see rb_io_set_write_io()
*/
+ RBIMPL_ATTR_DEPRECATED(("rb_io_get_write_io"))
VALUE tied_io_for_writing;
- struct rb_io_enc_t encs; /**< Decomposed encoding flags. */
+ RBIMPL_ATTR_DEPRECATED(("with no replacement"))
+ struct rb_io_encoding encs; /**< Decomposed encoding flags. */
/** Encoding converter used when reading from this IO. */
+ RBIMPL_ATTR_DEPRECATED(("with no replacement"))
rb_econv_t *readconv;
/**
* rb_io_ungetc() destination. This buffer is read before checking
* ::rb_io_t::rbuf
*/
+ RBIMPL_ATTR_DEPRECATED(("with no replacement"))
rb_io_buffer_t cbuf;
/** Encoding converter used when writing to this IO. */
+ RBIMPL_ATTR_DEPRECATED(("with no replacement"))
rb_econv_t *writeconv;
/**
@@ -197,21 +216,25 @@ typedef struct rb_io_t {
* conversion from encoding X to encoding Y does not exist, Ruby finds an
* encoding Z that bridges the two, so that X to Z to Y conversion happens.
*/
+ RBIMPL_ATTR_DEPRECATED(("with no replacement"))
VALUE writeconv_asciicompat;
/** Whether ::rb_io_t::writeconv is already set up. */
+ RBIMPL_ATTR_DEPRECATED(("with no replacement"))
int writeconv_initialized;
/**
* Value of ::rb_io_t::rb_io_enc_t::ecflags stored right before
* initialising ::rb_io_t::writeconv.
*/
+ RBIMPL_ATTR_DEPRECATED(("with no replacement"))
int writeconv_pre_ecflags;
/**
* Value of ::rb_io_t::rb_io_enc_t::ecopts stored right before initialising
* ::rb_io_t::writeconv.
*/
+ RBIMPL_ATTR_DEPRECATED(("with no replacement"))
VALUE writeconv_pre_ecopts;
/**
@@ -221,25 +244,21 @@ typedef struct rb_io_t {
*
* This of course doesn't help inter-process IO interleaves, though.
*/
+ RBIMPL_ATTR_DEPRECATED(("with no replacement"))
VALUE write_lock;
/**
* The timeout associated with this IO when performing blocking operations.
*/
+ RBIMPL_ATTR_DEPRECATED(("rb_io_timeout/rb_io_set_timeout"))
VALUE timeout;
-} rb_io_t;
+};
+#endif
-/** @alias{rb_io_enc_t} */
-typedef struct rb_io_enc_t rb_io_enc_t;
+typedef struct rb_io rb_io_t;
-/**
- * @private
- *
- * @deprecated This macro once was a thing in the old days, but makes no sense
- * any longer today. Exists here for backwards compatibility
- * only. You can safely forget about it.
- */
-#define HAVE_RB_IO_T 1
+/** @alias{rb_io_enc_t} */
+typedef struct rb_io_encoding rb_io_enc_t;
/**
* @name Possible flags for ::rb_io_t::mode
@@ -330,7 +349,16 @@ typedef struct rb_io_enc_t rb_io_enc_t;
* Setting this one and #FMODE_BINMODE at the same time is a contradiction.
*/
#define FMODE_TEXTMODE 0x00001000
-/* #define FMODE_PREP 0x00010000 */
+/**
+ * This flag means that an IO object is wrapping an "external" file descriptor,
+ * which is owned by something outside the Ruby interpreter (usually a C extension).
+ * Ruby will not close this file when the IO object is garbage collected.
+ * If this flag is set, then IO#autoclose? is false, and vice-versa.
+ *
+ * This flag was previously called FMODE_PREP internally.
+ */
+#define FMODE_EXTERNAL 0x00010000
+
/* #define FMODE_SIGNAL_ON_EPIPE 0x00020000 */
/**
@@ -345,6 +373,18 @@ typedef struct rb_io_enc_t rb_io_enc_t;
/** @} */
/**
+ * Allocate a new IO object, with the given file descriptor.
+ */
+VALUE rb_io_open_descriptor(VALUE klass, int descriptor, int mode, VALUE path, VALUE timeout, struct rb_io_encoding *encoding);
+
+/**
+ * Returns whether or not the underlying IO is closed.
+ *
+ * @return Whether the underlying IO is closed.
+ */
+VALUE rb_io_closed_p(VALUE io);
+
+/**
* Queries the underlying IO pointer.
*
* @param[in] obj An IO object.
@@ -414,14 +454,14 @@ rb_io_t *rb_io_make_open_file(VALUE obj);
* like this:
*
* ```CXX
- * typedef struct rb_io_t {
+ * typedef struct rb_io {
* FILE *f; // stdio ptr for read/write
* FILE *f2; // additional ptr for rw pipes
* int mode; // mode flags
* int pid; // child's pid (for pipes)
* int lineno; // number of lines read
* char *path; // pathname for file
- * void (*finalize) _((struct rb_io_t*,int)); // finalize proc
+ * void (*finalize) _((struct rb_io*,int)); // finalize proc
* } rb_io_t;
*```
*
@@ -703,6 +743,12 @@ VALUE rb_io_set_write_io(VALUE io, VALUE w);
void rb_io_set_nonblock(rb_io_t *fptr);
/**
+ * Returns the path for the given IO.
+ *
+ */
+VALUE rb_io_path(VALUE io);
+
+/**
* Returns an integer representing the numeric file descriptor for
* <em>io</em>.
*
@@ -712,6 +758,12 @@ void rb_io_set_nonblock(rb_io_t *fptr);
int rb_io_descriptor(VALUE io);
/**
+ * Get the mode of the IO.
+ *
+ */
+int rb_io_mode(VALUE io);
+
+/**
* This function breaks down the option hash that `IO#initialize` takes into
* components. This is an implementation detail of rb_io_extract_modeenc()
* today. People prefer that API instead.
diff --git a/include/ruby/io/buffer.h b/include/ruby/io/buffer.h
index 88e5598066..b044db0539 100644
--- a/include/ruby/io/buffer.h
+++ b/include/ruby/io/buffer.h
@@ -23,10 +23,18 @@ RBIMPL_SYMBOL_EXPORT_BEGIN()
#define RUBY_IO_BUFFER_VERSION 2
+// The `IO::Buffer` class.
RUBY_EXTERN VALUE rb_cIOBuffer;
+
+// The operating system page size.
RUBY_EXTERN size_t RUBY_IO_BUFFER_PAGE_SIZE;
+
+// The default buffer size, usually a (small) multiple of the page size.
+// Can be overridden by the RUBY_IO_BUFFER_DEFAULT_SIZE environment variable.
RUBY_EXTERN size_t RUBY_IO_BUFFER_DEFAULT_SIZE;
+// Represents the internal state of the buffer.
+// More than one flag can be set at a time.
enum rb_io_buffer_flags {
// The memory in the buffer is owned by someone else.
// More specifically, it means that someone else owns the buffer and we shouldn't try to resize it.
@@ -49,20 +57,25 @@ enum rb_io_buffer_flags {
RB_IO_BUFFER_PRIVATE = 64,
// The buffer is read-only and cannot be modified.
- RB_IO_BUFFER_READONLY = 128
+ RB_IO_BUFFER_READONLY = 128,
+
+ // The buffer is backed by a file.
+ RB_IO_BUFFER_FILE = 256,
};
+// Represents the endian of the data types.
enum rb_io_buffer_endian {
+ // The least significant units are put first.
RB_IO_BUFFER_LITTLE_ENDIAN = 4,
RB_IO_BUFFER_BIG_ENDIAN = 8,
-#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
+#if defined(__BYTE_ORDER__) && __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
RB_IO_BUFFER_HOST_ENDIAN = RB_IO_BUFFER_LITTLE_ENDIAN,
-#elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
+#elif defined(__BYTE_ORDER__) && __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
RB_IO_BUFFER_HOST_ENDIAN = RB_IO_BUFFER_BIG_ENDIAN,
-#elif REG_DWORD == REG_DWORD_LITTLE_ENDIAN
+#elif defined(REG_DWORD) && REG_DWORD == REG_DWORD_LITTLE_ENDIAN
RB_IO_BUFFER_HOST_ENDIAN = RB_IO_BUFFER_LITTLE_ENDIAN,
-#elif REG_DWORD == REG_DWORD_BIG_ENDIAN
+#elif defined(REG_DWORD) && REG_DWORD == REG_DWORD_BIG_ENDIAN
RB_IO_BUFFER_HOST_ENDIAN = RB_IO_BUFFER_BIG_ENDIAN,
#endif
@@ -75,9 +88,14 @@ VALUE rb_io_buffer_map(VALUE io, size_t size, rb_off_t offset, enum rb_io_buffer
VALUE rb_io_buffer_lock(VALUE self);
VALUE rb_io_buffer_unlock(VALUE self);
int rb_io_buffer_try_unlock(VALUE self);
+
VALUE rb_io_buffer_free(VALUE self);
+VALUE rb_io_buffer_free_locked(VALUE self);
-int rb_io_buffer_get_bytes(VALUE self, void **base, size_t *size);
+// Access the internal buffer and flags. Validates the pointers.
+// The points may not remain valid if the source buffer is manipulated.
+// Consider using rb_io_buffer_lock if needed.
+enum rb_io_buffer_flags rb_io_buffer_get_bytes(VALUE self, void **base, size_t *size);
void rb_io_buffer_get_bytes_for_reading(VALUE self, const void **base, size_t *size);
void rb_io_buffer_get_bytes_for_writing(VALUE self, void **base, size_t *size);
diff --git a/include/ruby/memory_view.h b/include/ruby/memory_view.h
index 1ddca2d46f..42309d5afc 100644
--- a/include/ruby/memory_view.h
+++ b/include/ruby/memory_view.h
@@ -47,10 +47,10 @@ typedef struct {
char format;
/** :FIXME: what is a "native" size is unclear. */
- unsigned native_size_p: 1;
+ bool native_size_p;
/** Endian of the component */
- unsigned little_endian_p: 1;
+ bool little_endian_p;
/** The component's offset. */
size_t offset;
diff --git a/include/ruby/onigmo.h b/include/ruby/onigmo.h
index 8d7c601703..d233336316 100644
--- a/include/ruby/onigmo.h
+++ b/include/ruby/onigmo.h
@@ -744,8 +744,6 @@ typedef struct {
typedef struct {
int lower;
int upper;
- long base_num;
- long inner_num;
} OnigRepeatRange;
typedef void (*OnigWarnFunc)(const char* s);
@@ -846,6 +844,8 @@ void onig_free(OnigRegex);
ONIG_EXTERN
void onig_free_body(OnigRegex);
ONIG_EXTERN
+int onig_reg_copy(OnigRegex* reg, OnigRegex orig_reg);
+ONIG_EXTERN
OnigPosition onig_scan(OnigRegex reg, const OnigUChar* str, const OnigUChar* end, OnigRegion* region, OnigOptionType option, int (*scan_callback)(OnigPosition, OnigPosition, OnigRegion*, void*), void* callback_arg);
ONIG_EXTERN
OnigPosition onig_search(OnigRegex, const OnigUChar* str, const OnigUChar* end, const OnigUChar* start, const OnigUChar* range, OnigRegion* region, OnigOptionType option);
diff --git a/include/ruby/random.h b/include/ruby/random.h
index 39bdb6f3e3..f3df0d96fb 100644
--- a/include/ruby/random.h
+++ b/include/ruby/random.h
@@ -11,7 +11,7 @@
*
* This is a set of APIs to roll your own subclass of ::rb_cRandom. An
* illustrative example of such PRNG can be found at
- * `ext/-test-/ramdom/loop.c`.
+ * `ext/-test-/random/loop.c`.
*/
#include "ruby/ruby.h"
diff --git a/include/ruby/re.h b/include/ruby/re.h
index 3892d6e7f2..f86d6f26cf 100644
--- a/include/ruby/re.h
+++ b/include/ruby/re.h
@@ -18,6 +18,7 @@
#include <stdio.h>
+#include "ruby/onigmo.h"
#include "ruby/regex.h"
#include "ruby/internal/core/rmatch.h"
#include "ruby/internal/dllexport.h"
@@ -126,6 +127,30 @@ VALUE rb_reg_quote(VALUE str);
regex_t *rb_reg_prepare_re(VALUE re, VALUE str);
/**
+ * Runs a regular expression match using function `match`. Performs preparation,
+ * error handling, and memory cleanup.
+ *
+ * @param[in] re Target regular expression.
+ * @param[in] str What `re` is about to run on.
+ * @param[in] match The function to run to match `str` against `re`.
+ * @param[in] args Pointer to arguments to pass into `match`.
+ * @param[out] regs Registers on a successful match.
+ * @exception rb_eArgError `re` does not fit for `str`.
+ * @exception rb_eEncCompatError `re` and `str` are incompatible.
+ * @exception rb_eRegexpError `re` is malformed.
+ * @return Match position on a successful match, `ONIG_MISMATCH` otherwise.
+ *
+ * @internal
+ *
+ * The type `regex_t *` is defined in `<ruby/onigmo.h>`, _and_
+ * _conflicts_ with POSIX's `<regex.h>`. We can no longer save the situation
+ * at this point. Just don't mix the two.
+ */
+OnigPosition rb_reg_onig_match(VALUE re, VALUE str,
+ OnigPosition (*match)(regex_t *reg, VALUE str, struct re_registers *regs, void *args),
+ void *args, struct re_registers *regs);
+
+/**
* Duplicates a match data. This is roughly the same as `onig_region_copy()`,
* except it tries to GC when there is not enough memory.
*
diff --git a/include/ruby/ruby.h b/include/ruby/ruby.h
index 444940ca3a..035f02c70b 100644
--- a/include/ruby/ruby.h
+++ b/include/ruby/ruby.h
@@ -43,7 +43,6 @@
#include "ruby/internal/method.h"
#include "ruby/internal/module.h"
#include "ruby/internal/newobj.h"
-#include "ruby/internal/rgengc.h"
#include "ruby/internal/scan_args.h"
#include "ruby/internal/special_consts.h"
#include "ruby/internal/symbol.h"
@@ -98,8 +97,10 @@ VALUE rb_get_path(VALUE obj);
VALUE rb_get_path_no_checksafe(VALUE);
/**
- * @deprecated This macro is an alias of #FilePathValue now. The part that did
- * "String" was deleted. It remains here because of no harm.
+ * This macro actually does the same thing as #FilePathValue now. The "String"
+ * part indicates that this is for when a string is treated like a pathname,
+ * rather than the actual pathname on the file systems. For examples:
+ * `Dir.fnmatch?`, `File.join`, `File.basename`, etc.
*/
#define FilePathStringValue(v) ((v) = rb_get_path(v))
@@ -271,6 +272,124 @@ RBIMPL_ATTR_FORMAT(RBIMPL_PRINTF_FORMAT, 3, 0)
*/
int ruby_vsnprintf(char *str, size_t n, char const *fmt, va_list ap);
+#include <errno.h>
+
+/**
+ * @name Errno handling routines for userland threads
+ * @note POSIX chapter 2 section 3 states that for each thread of a process,
+ * the value of `errno` shall not be affected by function calls or
+ * assignments to `errno` by other threads.
+ *
+ * Soooo this `#define errno` below seems like a noob mistake at first sight.
+ * If you look at its actual implementation, the functions are just adding one
+ * level of indirection. It doesn't make any sense sorry? But yes! @ko1 told
+ * @shyouhei that this is inevitable.
+ *
+ * The ultimate reason is because Ruby now has N:M threads implemented.
+ * Threads of that sort change their context in user land. A function can be
+ * "transferred" between threads in middle of their executions. Let us for
+ * instance consider:
+ *
+ * ```cxx
+ * void foo()
+ * {
+ * auto i = errno;
+ * close(0);
+ * errno = i;
+ * }
+ * ```
+ *
+ * This function (if ran under our Ractor) could change its running thread at
+ * the `close` function. But the two `errno` invocations are different! Look
+ * how the source code above is compiled by clang 17 with `-O3` flag @ Linux:
+ *
+ * ```
+ * foo(int): # @foo(int)
+ * push rbp
+ * push r14
+ * push rbx
+ * mov ebx, edi
+ * call __errno_location@PLT
+ * mov r14, rax
+ * mov ebp, dword ptr [rax]
+ * mov edi, ebx
+ * call close@PLT
+ * mov dword ptr [r14], ebp
+ * pop rbx
+ * pop r14
+ * pop rbp
+ * ret
+ * ```
+ *
+ * Notice how `__errno_location@PLT` is `call`-ed only once. The compiler
+ * assumes that the location of `errno` does not change during a function call.
+ * Sadly this is no longer true for us. The `close@PLT` now changes threads,
+ * which should also change where `errno` is stored.
+ *
+ * With the `#define errno` below the compilation result changes to this:
+ *
+ * ```
+ * foo(int): # @foo(int)
+ * push rbp
+ * push rbx
+ * push rax
+ * mov ebx, edi
+ * call rb_errno_ptr()@PLT
+ * mov ebp, dword ptr [rax]
+ * mov edi, ebx
+ * call close@PLT
+ * call rb_errno_ptr()@PLT
+ * mov dword ptr [rax], ebp
+ * add rsp, 8
+ * pop rbx
+ * pop rbp
+ * ret
+ * ```
+ *
+ * Which fixes the problem.
+ */
+
+/**
+ * Identical to system `errno`.
+ *
+ * @return The last set `errno` number.
+ */
+int rb_errno(void);
+
+/**
+ * Set the errno.
+ *
+ * @param err New `errno`.
+ * @post `errno` is now set to `err`.
+ */
+void rb_errno_set(int err);
+
+/**
+ * The location of `errno`
+ *
+ * @return The (thread-specific) location of `errno`.
+ */
+int *rb_errno_ptr(void);
+
+/**
+ * Not sure if it is necessary for extension libraries but this is where the
+ * "bare" errno is located.
+ *
+ * @return The location of `errno`.
+ */
+static inline int *
+rb_orig_errno_ptr(void)
+{
+ return &errno;
+}
+
+#define rb_orig_errno errno /**< System-provided original `errno`. */
+#undef errno
+#define errno (*rb_errno_ptr()) /**< Ractor-aware version of `errno`. */
+
+/** @} */
+
+
/** @cond INTERNAL_MACRO */
#if RBIMPL_HAS_WARNING("-Wgnu-zero-variadic-macro-arguments")
# /* Skip it; clang -pedantic doesn't like the following */
diff --git a/include/ruby/st.h b/include/ruby/st.h
index 1e4bb80686..ba69c066c9 100644
--- a/include/ruby/st.h
+++ b/include/ruby/st.h
@@ -98,10 +98,14 @@ struct st_table {
enum st_retval {ST_CONTINUE, ST_STOP, ST_DELETE, ST_CHECK, ST_REPLACE};
+size_t rb_st_table_size(const struct st_table *tbl);
+#define st_table_size rb_st_table_size
st_table *rb_st_init_table(const struct st_hash_type *);
#define st_init_table rb_st_init_table
st_table *rb_st_init_table_with_size(const struct st_hash_type *, st_index_t);
#define st_init_table_with_size rb_st_init_table_with_size
+st_table *rb_st_init_existing_table_with_size(st_table *tab, const struct st_hash_type *type, st_index_t size);
+#define st_init_existing_table_with_size rb_st_init_existing_table_with_size
st_table *rb_st_init_numtable(void);
#define st_init_numtable rb_st_init_numtable
st_table *rb_st_init_numtable_with_size(st_index_t);
@@ -158,6 +162,8 @@ void rb_st_cleanup_safe(st_table *, st_data_t);
#define st_cleanup_safe rb_st_cleanup_safe
void rb_st_clear(st_table *);
#define st_clear rb_st_clear
+st_table *rb_st_replace(st_table *new_tab, st_table *old_tab);
+#define st_replace rb_st_replace
st_table *rb_st_copy(st_table *);
#define st_copy rb_st_copy
CONSTFUNC(int rb_st_numcmp(st_data_t, st_data_t));
diff --git a/include/ruby/thread.h b/include/ruby/thread.h
index 0b5b1ca0f3..f01d276a29 100644
--- a/include/ruby/thread.h
+++ b/include/ruby/thread.h
@@ -190,14 +190,46 @@ void *rb_nogvl(void *(*func)(void *), void *data1,
*/
#define RUBY_CALL_WO_GVL_FLAG_SKIP_CHECK_INTS_
-#define RUBY_INTERNAL_THREAD_EVENT_STARTED 1 << 0 /** thread started */
+/**
+ * Triggered when a new thread is started.
+ *
+ * @note The callback will be called *without* the GVL held.
+ */
+#define RUBY_INTERNAL_THREAD_EVENT_STARTED 1 << 0
+
+/**
+* Triggered when a thread attempt to acquire the GVL.
+*
+* @note The callback will be called *without* the GVL held.
+*/
#define RUBY_INTERNAL_THREAD_EVENT_READY 1 << 1 /** acquiring GVL */
+
+/**
+ * Triggered when a thread successfully acquired the GVL.
+ *
+ * @note The callback will be called *with* the GVL held.
+ */
#define RUBY_INTERNAL_THREAD_EVENT_RESUMED 1 << 2 /** acquired GVL */
+
+/**
+ * Triggered when a thread released the GVL.
+ *
+ * @note The callback will be called *without* the GVL held.
+ */
#define RUBY_INTERNAL_THREAD_EVENT_SUSPENDED 1 << 3 /** released GVL */
+
+/**
+ * Triggered when a thread exits.
+ *
+ * @note The callback will be called *without* the GVL held.
+ */
#define RUBY_INTERNAL_THREAD_EVENT_EXITED 1 << 4 /** thread terminated */
+
#define RUBY_INTERNAL_THREAD_EVENT_MASK 0xff /** All Thread events */
-typedef void rb_internal_thread_event_data_t; // for future extension.
+typedef struct rb_internal_thread_event_data {
+ VALUE thread;
+} rb_internal_thread_event_data_t;
typedef void (*rb_internal_thread_event_callback)(rb_event_flag_t event,
const rb_internal_thread_event_data_t *event_data,
@@ -211,7 +243,12 @@ typedef struct rb_internal_thread_event_hook rb_internal_thread_event_hook_t;
* @param[in] events A set of events that `func` should run.
* @param[in] data Passed as-is to `func`.
* @return An opaque pointer to the hook, to unregister it later.
- * @note This functionality is a noop on Windows.
+ * @note This functionality is a noop on Windows and WebAssembly.
+ * @note The callback will be called without the GVL held, except for the
+ * RESUMED event.
+ * @note Callbacks are not guaranteed to be executed on the native threads
+ * that corresponds to the Ruby thread. To identify which Ruby thread
+ * the event refers to, you must use `event_data->thread`.
* @warning This function MUST not be called from a thread event callback.
*/
rb_internal_thread_event_hook_t *rb_internal_thread_add_event_hook(
@@ -223,13 +260,53 @@ rb_internal_thread_event_hook_t *rb_internal_thread_add_event_hook(
* Unregister the passed hook.
*
* @param[in] hook. The hook to unregister.
- * @return Wether the hook was found and unregistered.
- * @note This functionality is a noop on Windows.
+ * @return Whether the hook was found and unregistered.
+ * @note This functionality is a noop on Windows and WebAssembly.
* @warning This function MUST not be called from a thread event callback.
*/
bool rb_internal_thread_remove_event_hook(
rb_internal_thread_event_hook_t * hook);
+
+typedef int rb_internal_thread_specific_key_t;
+#define RB_INTERNAL_THREAD_SPECIFIC_KEY_MAX 8
+/**
+ * Create a key to store thread specific data.
+ *
+ * These APIs are designed for tools using
+ * rb_internal_thread_event_hook APIs.
+ *
+ * Note that only `RB_INTERNAL_THREAD_SPECIFIC_KEY_MAX` keys
+ * can be created. raises `ThreadError` if exceeded.
+ *
+ * Usage:
+ * // at initialize time:
+ * int tool_key; // gvar
+ * Init_tool() {
+ * tool_key = rb_internal_thread_specific_key_create();
+ * }
+ *
+ * // at any timing:
+ * rb_internal_thread_specific_set(thread, tool_key, per_thread_data);
+ * ...
+ * per_thread_data = rb_internal_thread_specific_get(thread, tool_key);
+ */
+rb_internal_thread_specific_key_t rb_internal_thread_specific_key_create(void);
+
+/**
+ * Get thread and tool specific data.
+ *
+ * This function is async signal safe and thread safe.
+ */
+void *rb_internal_thread_specific_get(VALUE thread_val, rb_internal_thread_specific_key_t key);
+
+/**
+ * Set thread and tool specific data.
+ *
+ * This function is async signal safe and thread safe.
+ */
+void rb_internal_thread_specific_set(VALUE thread_val, rb_internal_thread_specific_key_t key, void *data);
+
RBIMPL_SYMBOL_EXPORT_END()
#endif /* RUBY_THREAD_H */
diff --git a/include/ruby/thread_native.h b/include/ruby/thread_native.h
index c23b15e133..8217a67514 100644
--- a/include/ruby/thread_native.h
+++ b/include/ruby/thread_native.h
@@ -28,6 +28,11 @@ typedef union rb_thread_lock_union {
CRITICAL_SECTION crit;
} rb_nativethread_lock_t;
+struct rb_thread_cond_struct {
+ struct cond_event_entry *next;
+ struct cond_event_entry *prev;
+};
+
typedef struct rb_thread_cond_struct rb_nativethread_cond_t;
#elif defined(HAVE_PTHREAD_H)
diff --git a/include/ruby/util.h b/include/ruby/util.h
index e8727a3200..12e69c4b80 100644
--- a/include/ruby/util.h
+++ b/include/ruby/util.h
@@ -33,9 +33,20 @@
RBIMPL_SYMBOL_EXPORT_BEGIN()
-/** an approximation of ceil(n * log10(2)), up to 65536 at least */
+/** an approximation of ceil(n * log10(2)), up to 1,048,576 (1<<20)
+ * without overflow within 32-bit calculation
+ */
#define DECIMAL_SIZE_OF_BITS(n) (((n) * 3010 + 9998) / 9999)
+/** an approximation of decimal representation size for n-bytes */
+#define DECIMAL_SIZE_OF_BYTES(n) DECIMAL_SIZE_OF_BITS((n) * CHAR_BIT)
+
+/**
+ * An approximation of decimal representation size. `expr` may be a
+ * type name
+ */
+#define DECIMAL_SIZE_OF(expr) DECIMAL_SIZE_OF_BYTES(sizeof(expr))
+
/**
* Character to number mapping like `'a'` -> `10`, `'b'` -> `11` etc. For
* punctuation etc., the value is -1. "36" terminology comes from the fact
diff --git a/include/ruby/win32.h b/include/ruby/win32.h
index 197eb8a802..dfb56f4182 100644
--- a/include/ruby/win32.h
+++ b/include/ruby/win32.h
@@ -147,8 +147,10 @@ typedef int clockid_t;
#define open rb_w32_uopen
#define close(h) rb_w32_close(h)
#define fclose(f) rb_w32_fclose(f)
-#define read(f, b, s) rb_w32_read(f, b, s)
-#define write(f, b, s) rb_w32_write(f, b, s)
+#define read(f, b, s) rb_w32_read(f, b, s)
+#define write(f, b, s) rb_w32_write(f, b, s)
+#define pread(f, b, s, o) rb_w32_pread(f, b, s, o)
+#define pwrite(f, b, s, o) rb_w32_pwrite(f, b, s, o)
#define getpid() rb_w32_getpid()
#undef HAVE_GETPPID
#define HAVE_GETPPID 1
@@ -716,6 +718,8 @@ int rb_w32_fclose(FILE*);
int rb_w32_pipe(int[2]);
ssize_t rb_w32_read(int, void *, size_t);
ssize_t rb_w32_write(int, const void *, size_t);
+ssize_t rb_w32_pread(int, void *, size_t, rb_off_t offset);
+ssize_t rb_w32_pwrite(int, const void *, size_t, rb_off_t offset);
rb_off_t rb_w32_lseek(int, rb_off_t, int);
int rb_w32_uutime(const char *, const struct utimbuf *);
int rb_w32_uutimes(const char *, const struct timeval *);
diff --git a/inits.c b/inits.c
index e809b56cc9..9ed104f369 100644
--- a/inits.c
+++ b/inits.c
@@ -22,11 +22,6 @@ rb_call_inits(void)
{
CALL(default_shapes);
CALL(Thread_Mutex);
-#if USE_TRANSIENT_HEAP
- CALL(TransientHeap);
-#endif
- CALL(vm_postponed_job);
- CALL(Method);
CALL(RandomSeedCore);
CALL(encodings);
CALL(sym);
@@ -56,17 +51,18 @@ rb_call_inits(void)
CALL(Dir);
CALL(Time);
CALL(Random);
- CALL(signal);
CALL(load);
CALL(Proc);
CALL(Binding);
CALL(Math);
CALL(GC);
+ CALL(WeakMap);
CALL(Enumerator);
CALL(Ractor);
CALL(VM);
CALL(ISeq);
CALL(Thread);
+ CALL(signal);
CALL(Fiber_Scheduler);
CALL(process);
CALL(Cont);
@@ -79,6 +75,7 @@ rb_call_inits(void)
CALL(ast);
CALL(gc_stress);
CALL(shape);
+ CALL(Prism);
// enable builtin loading
CALL(builtin);
@@ -105,9 +102,9 @@ rb_call_builtin_inits(void)
BUILTIN(yjit);
BUILTIN(nilclass);
BUILTIN(marshal);
-#if USE_MJIT
- BUILTIN(mjit);
- BUILTIN(mjit_c);
+#if USE_RJIT
+ BUILTIN(rjit_c);
+ BUILTIN(rjit);
#endif
Init_builtin_prelude();
}
diff --git a/insns.def b/insns.def
index 9f5ee7095a..5f6cb314ff 100644
--- a/insns.def
+++ b/insns.def
@@ -260,20 +260,7 @@ opt_getconstant_path
(VALUE val)
// attr bool leaf = false; /* may autoload or raise */
{
- const ID *segments = ic->segments;
- struct iseq_inline_constant_cache_entry *ice = ic->entry;
- if (ice && vm_ic_hit_p(ice, GET_EP())) {
- val = ice->value;
-
- VM_ASSERT(val == vm_get_ev_const_chain(ec, segments));
- } else {
- ruby_vm_constant_cache_misses++;
- val = vm_get_ev_const_chain(ec, segments);
- vm_ic_track_const_chain(GET_CFP(), ic, segments);
- // Because leaf=false, we need to undo the PC increment to get the address to this instruction
- // INSN_ATTR(width) == 2
- vm_ic_update(GET_ISEQ(), ic, val, GET_EP(), GET_PC() - 2);
- }
+ val = rb_vm_opt_getconstant_path(ec, GET_CFP(), ic);
}
/* Get constant variable id. If klass is Qnil and allow_nil is Qtrue, constants
@@ -511,10 +498,11 @@ expandarray
(rb_num_t num, rb_num_t flag)
(..., VALUE ary)
(...)
+// attr bool handles_sp = true;
// attr bool leaf = false; /* has rb_check_array_type() */
// attr rb_snum_t sp_inc = (rb_snum_t)num - 1 + (flag & 1 ? 1 : 0);
{
- vm_expandarray(GET_SP(), ary, num, (int)flag);
+ vm_expandarray(GET_CFP(), ary, num, (int)flag);
}
/* concat two arrays */
@@ -539,6 +527,17 @@ splatarray
obj = vm_splat_array(flag, ary);
}
+/* call to_hash on hash to keyword splat before converting block */
+DEFINE_INSN
+splatkw
+()
+(VALUE hash, VALUE block)
+(VALUE obj, VALUE block)
+// attr bool leaf = false; /* has rb_to_hash_type() */
+{
+ obj = rb_to_hash_type(hash);
+}
+
/* put new Hash from n elements. n must be an even number. */
DEFINE_INSN
newhash
@@ -701,6 +700,20 @@ defined
}
}
+/* defined?(@foo) */
+DEFINE_INSN
+definedivar
+(ID id, IVC ic, VALUE pushval)
+()
+(VALUE val)
+// attr bool leaf = false;
+{
+ val = Qnil;
+ if (vm_getivar(GET_SELF(), id, GET_ISEQ(), ic, NULL, FALSE, Qundef) != Qundef) {
+ val = pushval;
+ }
+}
+
/* check `target' matches `pattern'.
`flag & VM_CHECKMATCH_TYPE_MASK' describe how to check pattern.
VM_CHECKMATCH_TYPE_WHEN: ignore target and check pattern is truthy.
@@ -799,6 +812,7 @@ send
{
VALUE bh = vm_caller_setup_arg_block(ec, GET_CFP(), cd->ci, blockiseq, false);
val = vm_sendish(ec, GET_CFP(), cd, bh, mexp_search_method);
+ JIT_EXEC(ec, val);
if (val == Qundef) {
RESTORE_REGS();
@@ -818,6 +832,7 @@ opt_send_without_block
{
VALUE bh = VM_BLOCK_HANDLER_NONE;
val = vm_sendish(ec, GET_CFP(), cd, bh, mexp_search_method);
+ JIT_EXEC(ec, val);
if (val == Qundef) {
RESTORE_REGS();
@@ -883,8 +898,8 @@ opt_str_uminus
}
DEFINE_INSN
-opt_newarray_max
-(rb_num_t num)
+opt_newarray_send
+(rb_num_t num, ID method)
(...)
(VALUE val)
/* This instruction typically has no funcalls. But it compares array
@@ -893,20 +908,21 @@ opt_newarray_max
* cannot but mark it being not leaf. */
// attr bool leaf = false; /* has rb_funcall() */
// attr rb_snum_t sp_inc = 1 - (rb_snum_t)num;
-{
- val = vm_opt_newarray_max(ec, num, STACK_ADDR_FROM_TOP(num));
-}
-
-DEFINE_INSN
-opt_newarray_min
-(rb_num_t num)
-(...)
-(VALUE val)
-/* Same discussion as opt_newarray_max. */
-// attr bool leaf = false; /* has rb_funcall() */
-// attr rb_snum_t sp_inc = 1 - (rb_snum_t)num;
-{
- val = vm_opt_newarray_min(ec, num, STACK_ADDR_FROM_TOP(num));
+// attr rb_snum_t comptime_sp_inc = 1 - (rb_snum_t)num;
+{
+ switch(method) {
+ case idHash:
+ val = vm_opt_newarray_hash(ec, num, STACK_ADDR_FROM_TOP(num));
+ break;
+ case idMin:
+ val = vm_opt_newarray_min(ec, num, STACK_ADDR_FROM_TOP(num));
+ break;
+ case idMax:
+ val = vm_opt_newarray_max(ec, num, STACK_ADDR_FROM_TOP(num));
+ break;
+ default:
+ rb_bug("unreachable");
+ }
}
/* super(args) # args.size => num */
@@ -920,6 +936,7 @@ invokesuper
{
VALUE bh = vm_caller_setup_arg_block(ec, GET_CFP(), cd->ci, blockiseq, true);
val = vm_sendish(ec, GET_CFP(), cd, bh, mexp_search_super);
+ JIT_EXEC(ec, val);
if (val == Qundef) {
RESTORE_REGS();
@@ -939,6 +956,7 @@ invokeblock
{
VALUE bh = VM_BLOCK_HANDLER_NONE;
val = vm_sendish(ec, GET_CFP(), cd, bh, mexp_search_invokeblock);
+ JIT_EXEC(ec, val);
if (val == Qundef) {
RESTORE_REGS();
@@ -1345,10 +1363,8 @@ opt_aset_with
val = tmp;
}
else {
-#ifndef MJIT_HEADER
TOPN(0) = rb_str_resurrect(key);
PUSH(val);
-#endif
CALL_SIMPLE_METHOD();
}
}
@@ -1365,9 +1381,7 @@ opt_aref_with
val = vm_opt_aref_with(recv, key);
if (val == Qundef) {
-#ifndef MJIT_HEADER
PUSH(rb_str_resurrect(key));
-#endif
CALL_SIMPLE_METHOD();
}
}
@@ -1457,27 +1471,6 @@ opt_regexpmatch2
}
}
-/* call native compiled method */
-DEFINE_INSN_IF(SUPPORT_CALL_C_FUNCTION)
-opt_call_c_function
-(rb_insn_func_t funcptr)
-()
-()
-// attr bool leaf = false; /* anything can happen inside */
-// attr bool handles_sp = true;
-{
- reg_cfp = (funcptr)(ec, reg_cfp);
-
- if (reg_cfp == 0) {
- VALUE err = ec->errinfo;
- ec->errinfo = Qnil;
- THROW_EXCEPTION(err);
- }
-
- RESTORE_REGS();
- NEXT_INSN();
-}
-
/* call specific function with args */
DEFINE_INSN
invokebuiltin
diff --git a/internal/array.h b/internal/array.h
index a0d16dec3f..39f6fcbea6 100644
--- a/internal/array.h
+++ b/internal/array.h
@@ -23,6 +23,7 @@
#define RARRAY_PTR_IN_USE_FLAG FL_USER14
/* array.c */
+VALUE rb_ary_hash_values(long len, const VALUE *elements);
VALUE rb_ary_last(int, const VALUE *, VALUE);
void rb_ary_set_len(VALUE, long);
void rb_ary_delete_same(VALUE, VALUE);
@@ -39,10 +40,7 @@ VALUE rb_ary_diff(VALUE ary1, VALUE ary2);
static inline VALUE rb_ary_entry_internal(VALUE ary, long offset);
static inline bool ARY_PTR_USING_P(VALUE ary);
-static inline void RARY_TRANSIENT_SET(VALUE ary);
-static inline void RARY_TRANSIENT_UNSET(VALUE ary);
-MJIT_SYMBOL_EXPORT_BEGIN
VALUE rb_ary_tmp_new_from_values(VALUE, long, const VALUE *);
VALUE rb_check_to_array(VALUE ary);
VALUE rb_ary_behead(VALUE, long);
@@ -50,14 +48,13 @@ VALUE rb_ary_aref1(VALUE ary, VALUE i);
struct rb_execution_context_struct;
VALUE rb_ec_ary_new_from_values(struct rb_execution_context_struct *ec, long n, const VALUE *elts);
-MJIT_SYMBOL_EXPORT_END
// YJIT needs this function to never allocate and never raise
static inline VALUE
rb_ary_entry_internal(VALUE ary, long offset)
{
long len = RARRAY_LEN(ary);
- const VALUE *ptr = RARRAY_CONST_PTR_TRANSIENT(ary);
+ const VALUE *ptr = RARRAY_CONST_PTR(ary);
if (len == 0) return Qnil;
if (offset < 0) {
offset += len;
@@ -119,22 +116,6 @@ ARY_SHARED_ROOT_REFCNT(VALUE ary)
return RARRAY(ary)->as.heap.aux.capa;
}
-static inline void
-RARY_TRANSIENT_SET(VALUE ary)
-{
-#if USE_TRANSIENT_HEAP
- FL_SET_RAW(ary, RARRAY_TRANSIENT_FLAG);
-#endif
-}
-
-static inline void
-RARY_TRANSIENT_UNSET(VALUE ary)
-{
-#if USE_TRANSIENT_HEAP
- FL_UNSET_RAW(ary, RARRAY_TRANSIENT_FLAG);
-#endif
-}
-
#undef rb_ary_new_from_args
#if RBIMPL_HAS_WARNING("-Wgnu-zero-variadic-macro-arguments")
# /* Skip it; clang -pedantic doesn't like the following */
@@ -155,9 +136,16 @@ RBIMPL_ATTR_ARTIFICIAL()
static inline VALUE
RARRAY_AREF(VALUE ary, long i)
{
+ VALUE val;
RBIMPL_ASSERT_TYPE(ary, RUBY_T_ARRAY);
- return RARRAY_CONST_PTR_TRANSIENT(ary)[i];
+ RBIMPL_WARNING_PUSH();
+#if defined(__GNUC__) && !defined(__clang__) && __GNUC__ == 13
+ RBIMPL_WARNING_IGNORED(-Warray-bounds);
+#endif
+ val = RARRAY_CONST_PTR(ary)[i];
+ RBIMPL_WARNING_POP();
+ return val;
}
#endif /* INTERNAL_ARRAY_H */
diff --git a/internal/basic_operators.h b/internal/basic_operators.h
index 2cd9f50073..a59403631e 100644
--- a/internal/basic_operators.h
+++ b/internal/basic_operators.h
@@ -31,6 +31,7 @@ enum ruby_basic_operators {
BOP_UMINUS,
BOP_MAX,
BOP_MIN,
+ BOP_HASH,
BOP_CALL,
BOP_AND,
BOP_OR,
@@ -40,9 +41,7 @@ enum ruby_basic_operators {
BOP_LAST_
};
-MJIT_SYMBOL_EXPORT_BEGIN
RUBY_EXTERN short ruby_vm_redefined_flag[BOP_LAST_];
-MJIT_SYMBOL_EXPORT_END
/* optimize insn */
#define INTEGER_REDEFINED_OP_FLAG (1 << 0)
diff --git a/internal/bignum.h b/internal/bignum.h
index 5cd35ede8a..db8d3aee83 100644
--- a/internal/bignum.h
+++ b/internal/bignum.h
@@ -163,11 +163,9 @@ VALUE rb_str2big_gmp(VALUE arg, int base, int badcheck);
VALUE rb_int_parse_cstr(const char *str, ssize_t len, char **endp, size_t *ndigits, int base, int flags);
RUBY_SYMBOL_EXPORT_END
-MJIT_SYMBOL_EXPORT_BEGIN
#if defined(HAVE_INT128_T)
VALUE rb_int128t2big(int128_t n);
#endif
-MJIT_SYMBOL_EXPORT_END
/* sign: positive:1, negative:0 */
static inline bool
diff --git a/internal/bits.h b/internal/bits.h
index 2602ff7a31..1fe98fa430 100644
--- a/internal/bits.h
+++ b/internal/bits.h
@@ -34,8 +34,7 @@
# include <stdlib.h> /* for _byteswap_uint64 */
#endif
-#if defined(HAVE_X86INTRIN_H) && ! defined(MJIT_HEADER)
-# /* Rule out MJIT_HEADER, which does not interface well with <immintrin.h> */
+#if defined(HAVE_X86INTRIN_H)
# include <x86intrin.h> /* for _lzcnt_u64 */
#elif MSC_VERSION_SINCE(1310)
# include <intrin.h> /* for the following intrinsics */
@@ -119,12 +118,16 @@
MUL_OVERFLOW_SIGNED_INTEGER_P(a, b, FIXNUM_MIN, FIXNUM_MAX)
#endif
-#ifdef MUL_OVERFLOW_P
+#if defined(MUL_OVERFLOW_P) && defined(USE___BUILTIN_MUL_OVERFLOW_LONG_LONG)
# define MUL_OVERFLOW_LONG_LONG_P(a, b) MUL_OVERFLOW_P(a, b)
+#else
+# define MUL_OVERFLOW_LONG_LONG_P(a, b) MUL_OVERFLOW_SIGNED_INTEGER_P(a, b, LLONG_MIN, LLONG_MAX)
+#endif
+
+#ifdef MUL_OVERFLOW_P
# define MUL_OVERFLOW_LONG_P(a, b) MUL_OVERFLOW_P(a, b)
# define MUL_OVERFLOW_INT_P(a, b) MUL_OVERFLOW_P(a, b)
#else
-# define MUL_OVERFLOW_LONG_LONG_P(a, b) MUL_OVERFLOW_SIGNED_INTEGER_P(a, b, LLONG_MIN, LLONG_MAX)
# define MUL_OVERFLOW_LONG_P(a, b) MUL_OVERFLOW_SIGNED_INTEGER_P(a, b, LONG_MIN, LONG_MAX)
# define MUL_OVERFLOW_INT_P(a, b) MUL_OVERFLOW_SIGNED_INTEGER_P(a, b, INT_MIN, INT_MAX)
#endif
@@ -235,7 +238,7 @@ nlz_int32(uint32_t x)
* safety. */
return (unsigned int)__lzcnt(x);
-#elif defined(__x86_64__) && defined(__LZCNT__) && ! defined(MJIT_HEADER)
+#elif defined(__x86_64__) && defined(__LZCNT__)
return (unsigned int)_lzcnt_u32(x);
#elif MSC_VERSION_SINCE(1400) /* &&! defined(__AVX2__) */
@@ -264,7 +267,7 @@ nlz_int64(uint64_t x)
#if defined(_MSC_VER) && defined(__AVX2__)
return (unsigned int)__lzcnt64(x);
-#elif defined(__x86_64__) && defined(__LZCNT__) && ! defined(MJIT_HEADER)
+#elif defined(__x86_64__) && defined(__LZCNT__)
return (unsigned int)_lzcnt_u64(x);
#elif defined(_WIN64) && MSC_VERSION_SINCE(1400) /* &&! defined(__AVX2__) */
@@ -395,9 +398,9 @@ rb_popcount32(uint32_t x)
#else
x = (x & 0x55555555) + (x >> 1 & 0x55555555);
x = (x & 0x33333333) + (x >> 2 & 0x33333333);
- x = (x & 0x0f0f0f0f) + (x >> 4 & 0x0f0f0f0f);
- x = (x & 0x001f001f) + (x >> 8 & 0x001f001f);
- x = (x & 0x0000003f) + (x >>16 & 0x0000003f);
+ x = (x & 0x07070707) + (x >> 4 & 0x07070707);
+ x = (x & 0x000f000f) + (x >> 8 & 0x000f000f);
+ x = (x & 0x0000001f) + (x >>16 & 0x0000001f);
return (unsigned int)x;
#endif
@@ -425,9 +428,9 @@ rb_popcount64(uint64_t x)
x = (x & 0x5555555555555555) + (x >> 1 & 0x5555555555555555);
x = (x & 0x3333333333333333) + (x >> 2 & 0x3333333333333333);
x = (x & 0x0707070707070707) + (x >> 4 & 0x0707070707070707);
- x = (x & 0x001f001f001f001f) + (x >> 8 & 0x001f001f001f001f);
- x = (x & 0x0000003f0000003f) + (x >>16 & 0x0000003f0000003f);
- x = (x & 0x000000000000007f) + (x >>32 & 0x000000000000007f);
+ x = (x & 0x000f000f000f000f) + (x >> 8 & 0x000f000f000f000f);
+ x = (x & 0x0000001f0000001f) + (x >>16 & 0x0000001f0000001f);
+ x = (x & 0x000000000000003f) + (x >>32 & 0x000000000000003f);
return (unsigned int)x;
#endif
@@ -450,7 +453,7 @@ rb_popcount_intptr(uintptr_t x)
static inline int
ntz_int32(uint32_t x)
{
-#if defined(__x86_64__) && defined(__BMI__) && ! defined(MJIT_HEADER)
+#if defined(__x86_64__) && defined(__BMI__)
return (unsigned)_tzcnt_u32(x);
#elif MSC_VERSION_SINCE(1400)
@@ -472,7 +475,7 @@ ntz_int32(uint32_t x)
static inline int
ntz_int64(uint64_t x)
{
-#if defined(__x86_64__) && defined(__BMI__) && ! defined(MJIT_HEADER)
+#if defined(__x86_64__) && defined(__BMI__)
return (unsigned)_tzcnt_u64(x);
#elif defined(_WIN64) && MSC_VERSION_SINCE(1400)
diff --git a/internal/class.h b/internal/class.h
index bdc3bdd236..594f1daea7 100644
--- a/internal/class.h
+++ b/internal/class.h
@@ -8,13 +8,19 @@
* file COPYING are met. Consult the file for details.
* @brief Internal header for Class.
*/
+#include "id.h"
#include "id_table.h" /* for struct rb_id_table */
#include "internal/serial.h" /* for rb_serial_t */
#include "internal/static_assert.h"
+#include "internal/variable.h" /* for rb_class_ivar_set */
#include "ruby/internal/stdbool.h" /* for bool */
#include "ruby/intern.h" /* for rb_alloc_func_t */
#include "ruby/ruby.h" /* for struct RBasic */
#include "shape.h"
+#include "ruby_assert.h"
+#include "vm_core.h"
+#include "vm_sync.h"
+#include "method.h" /* for rb_cref_t */
#ifdef RCLASS_SUPER
# undef RCLASS_SUPER
@@ -30,6 +36,7 @@ typedef struct rb_subclass_entry rb_subclass_entry_t;
struct rb_cvar_class_tbl_entry {
uint32_t index;
rb_serial_t global_cvar_state;
+ const rb_cref_t * cref;
VALUE class_value;
};
@@ -37,7 +44,7 @@ struct rb_classext_struct {
VALUE *iv_ptr;
struct rb_id_table *const_tbl;
struct rb_id_table *callable_m_tbl;
- struct rb_id_table *cc_tbl; /* ID -> [[ci, cc1], cc2, ...] */
+ struct rb_id_table *cc_tbl; /* ID -> [[ci1, cc1], [ci2, cc2] ...] */
struct rb_id_table *cvc_tbl;
size_t superclass_depth;
VALUE *superclasses;
@@ -51,14 +58,19 @@ struct rb_classext_struct {
struct rb_subclass_entry *module_subclass_entry;
const VALUE origin_;
const VALUE refined_class;
- rb_alloc_func_t allocator;
+ union {
+ struct {
+ rb_alloc_func_t allocator;
+ } class;
+ struct {
+ VALUE attached_object;
+ } singleton_class;
+ } as;
const VALUE includer;
-#if !SHAPE_IN_BASIC_FLAGS
- shape_id_t shape_id;
-#endif
- uint32_t max_iv_count;
+ attr_index_t max_iv_count;
unsigned char variation_count;
- bool permanent_classpath;
+ bool permanent_classpath : 1;
+ bool cloned : 1;
VALUE classpath;
};
typedef struct rb_classext_struct rb_classext_t;
@@ -69,21 +81,17 @@ struct RClass {
struct RBasic basic;
VALUE super;
struct rb_id_table *m_tbl;
-#if SIZE_POOL_COUNT == 1
- struct rb_classext_struct *ptr;
-#endif
};
-#if RCLASS_EXT_EMBEDDED
// Assert that classes can be embedded in size_pools[2] (which has 160B slot size)
STATIC_ASSERT(sizeof_rb_classext_t, sizeof(struct RClass) + sizeof(rb_classext_t) <= 4 * RVALUE_SIZE);
-#endif
-#if RCLASS_EXT_EMBEDDED
-# define RCLASS_EXT(c) ((rb_classext_t *)((char *)(c) + sizeof(struct RClass)))
-#else
-# define RCLASS_EXT(c) (RCLASS(c)->ptr)
-#endif
+struct RClass_and_rb_classext_t {
+ struct RClass rclass;
+ rb_classext_t classext;
+};
+
+#define RCLASS_EXT(c) (&((struct RClass_and_rb_classext_t*)(c))->classext)
#define RCLASS_CONST_TBL(c) (RCLASS_EXT(c)->const_tbl)
#define RCLASS_M_TBL(c) (RCLASS(c)->m_tbl)
#define RCLASS_IVPTR(c) (RCLASS_EXT(c)->iv_ptr)
@@ -95,16 +103,60 @@ STATIC_ASSERT(sizeof_rb_classext_t, sizeof(struct RClass) + sizeof(rb_classext_t
#define RCLASS_INCLUDER(c) (RCLASS_EXT(c)->includer)
#define RCLASS_SUBCLASS_ENTRY(c) (RCLASS_EXT(c)->subclass_entry)
#define RCLASS_MODULE_SUBCLASS_ENTRY(c) (RCLASS_EXT(c)->module_subclass_entry)
-#define RCLASS_ALLOCATOR(c) (RCLASS_EXT(c)->allocator)
#define RCLASS_SUBCLASSES(c) (RCLASS_EXT(c)->subclasses)
#define RCLASS_SUPERCLASS_DEPTH(c) (RCLASS_EXT(c)->superclass_depth)
#define RCLASS_SUPERCLASSES(c) (RCLASS_EXT(c)->superclasses)
+#define RCLASS_ATTACHED_OBJECT(c) (RCLASS_EXT(c)->as.singleton_class.attached_object)
#define RICLASS_IS_ORIGIN FL_USER0
-#define RCLASS_CLONED FL_USER1
#define RCLASS_SUPERCLASSES_INCLUDE_SELF FL_USER2
#define RICLASS_ORIGIN_SHARED_MTBL FL_USER3
+static inline st_table *
+RCLASS_IV_HASH(VALUE obj)
+{
+ RUBY_ASSERT(RB_TYPE_P(obj, RUBY_T_CLASS) || RB_TYPE_P(obj, RUBY_T_MODULE));
+ RUBY_ASSERT(rb_shape_obj_too_complex(obj));
+ return (st_table *)RCLASS_IVPTR(obj);
+}
+
+static inline void
+RCLASS_SET_IV_HASH(VALUE obj, const st_table *tbl)
+{
+ RUBY_ASSERT(RB_TYPE_P(obj, RUBY_T_CLASS) || RB_TYPE_P(obj, RUBY_T_MODULE));
+ RUBY_ASSERT(rb_shape_obj_too_complex(obj));
+ RCLASS_IVPTR(obj) = (VALUE *)tbl;
+}
+
+static inline uint32_t
+RCLASS_IV_COUNT(VALUE obj)
+{
+ RUBY_ASSERT(RB_TYPE_P(obj, RUBY_T_CLASS) || RB_TYPE_P(obj, RUBY_T_MODULE));
+ if (rb_shape_obj_too_complex(obj)) {
+ uint32_t count;
+
+ // "Too complex" classes could have their IV hash mutated in
+ // parallel, so lets lock around getting the hash size.
+ RB_VM_LOCK_ENTER();
+ {
+ count = (uint32_t)rb_st_table_size(RCLASS_IV_HASH(obj));
+ }
+ RB_VM_LOCK_LEAVE();
+
+ return count;
+ }
+ else {
+ return rb_shape_get_shape_by_id(RCLASS_SHAPE_ID(obj))->next_iv_index;
+ }
+}
+
+static inline void
+RCLASS_SET_M_TBL(VALUE klass, struct rb_id_table *table)
+{
+ RUBY_ASSERT(!RB_OBJ_PROMOTED(klass));
+ RCLASS_M_TBL(klass) = table;
+}
+
/* class.c */
void rb_class_subclass_add(VALUE super, VALUE klass);
void rb_class_remove_from_super_subclasses(VALUE);
@@ -123,6 +175,7 @@ void rb_class_foreach_subclass(VALUE klass, void (*f)(VALUE, VALUE), VALUE);
void rb_class_detach_subclasses(VALUE);
void rb_class_detach_module_subclasses(VALUE);
void rb_class_remove_from_module_subclasses(VALUE);
+VALUE rb_define_class_id_under_no_pin(VALUE outer, ID id, VALUE super);
VALUE rb_obj_methods(int argc, const VALUE *argv, VALUE obj);
VALUE rb_obj_protected_methods(int argc, const VALUE *argv, VALUE obj);
VALUE rb_obj_private_methods(int argc, const VALUE *argv, VALUE obj);
@@ -139,10 +192,24 @@ static inline VALUE RCLASS_SUPER(VALUE klass);
static inline VALUE RCLASS_SET_SUPER(VALUE klass, VALUE super);
static inline void RCLASS_SET_INCLUDER(VALUE iclass, VALUE klass);
-MJIT_SYMBOL_EXPORT_BEGIN
VALUE rb_class_inherited(VALUE, VALUE);
VALUE rb_keyword_error_new(const char *, VALUE);
-MJIT_SYMBOL_EXPORT_END
+
+static inline rb_alloc_func_t
+RCLASS_ALLOCATOR(VALUE klass)
+{
+ if (FL_TEST_RAW(klass, FL_SINGLETON)) {
+ return 0;
+ }
+ return RCLASS_EXT(klass)->as.class.allocator;
+}
+
+static inline void
+RCLASS_SET_ALLOCATOR(VALUE klass, rb_alloc_func_t allocator)
+{
+ assert(!FL_TEST(klass, FL_SINGLETON));
+ RCLASS_EXT(klass)->as.class.allocator = allocator;
+}
static inline void
RCLASS_SET_ORIGIN(VALUE klass, VALUE origin)
@@ -197,4 +264,14 @@ RCLASS_SET_CLASSPATH(VALUE klass, VALUE classpath, bool permanent)
RCLASS_EXT(klass)->permanent_classpath = permanent;
}
+static inline VALUE
+RCLASS_SET_ATTACHED_OBJECT(VALUE klass, VALUE attached_object)
+{
+ assert(BUILTIN_TYPE(klass) == T_CLASS);
+ assert(FL_TEST_RAW(klass, FL_SINGLETON));
+
+ RB_OBJ_WRITE(klass, &RCLASS_EXT(klass)->as.singleton_class.attached_object, attached_object);
+ return attached_object;
+}
+
#endif /* INTERNAL_CLASS_H */
diff --git a/internal/cmdlineopt.h b/internal/cmdlineopt.h
index bf52f1214b..e79b993345 100644
--- a/internal/cmdlineopt.h
+++ b/internal/cmdlineopt.h
@@ -1,7 +1,7 @@
#ifndef INTERNAL_CMDLINEOPT_H /*-*-C-*-vi:se ft=c:*/
#define INTERNAL_CMDLINEOPT_H
-#include "mjit.h"
+#include "rjit.h"
#include "yjit.h"
typedef struct {
@@ -23,11 +23,15 @@ typedef struct ruby_cmdline_options {
ruby_features_t features;
ruby_features_t warn;
unsigned int dump;
-#if USE_MJIT
- struct mjit_options mjit;
+ long backtrace_length_limit;
+#if USE_RJIT
+ struct rb_rjit_options rjit;
#endif
- int sflag, xflag;
+ const char *crash_report;
+
+ signed int sflag: 2;
+ unsigned int xflag: 1;
unsigned int warning: 1;
unsigned int verbose: 1;
unsigned int do_loop: 1;
diff --git a/internal/compile.h b/internal/compile.h
index d32c2233c9..2ece5396f6 100644
--- a/internal/compile.h
+++ b/internal/compile.h
@@ -17,6 +17,7 @@ struct rb_iseq_struct; /* in vm_core.h */
/* compile.c */
int rb_dvar_defined(ID, const struct rb_iseq_struct *);
int rb_local_defined(ID, const struct rb_iseq_struct *);
+int rb_insn_len(VALUE insn);
const char *rb_insns_name(int i);
VALUE rb_insns_name_array(void);
int rb_iseq_cdhash_cmp(VALUE val, VALUE lit);
@@ -27,9 +28,7 @@ int rb_vm_insn_addr2insn(const void *);
int rb_vm_insn_decode(const VALUE encoded);
extern bool ruby_vm_keep_script_lines;
-MJIT_SYMBOL_EXPORT_BEGIN
/* iseq.c (export) */
rb_event_flag_t rb_iseq_event_flags(const struct rb_iseq_struct *iseq, size_t pos);
-MJIT_SYMBOL_EXPORT_END
#endif /* INTERNAL_COMPILE_H */
diff --git a/internal/cont.h b/internal/cont.h
index c3b091668a..3c2528a02a 100644
--- a/internal/cont.h
+++ b/internal/cont.h
@@ -22,6 +22,9 @@ void rb_jit_cont_init(void);
void rb_jit_cont_each_iseq(rb_iseq_callback callback, void *data);
void rb_jit_cont_finish(void);
+/* vm.c */
+void rb_free_shared_fiber_pool(void);
+
// Copy locals from the current execution to the specified fiber.
VALUE rb_fiber_inherit_storage(struct rb_execution_context_struct *ec, struct rb_fiber_struct *fiber);
diff --git a/internal/encoding.h b/internal/encoding.h
index a3b81bd388..11ffa6d83d 100644
--- a/internal/encoding.h
+++ b/internal/encoding.h
@@ -29,4 +29,7 @@ void rb_enc_set_base(const char *name, const char *orig);
int rb_enc_set_dummy(int index);
PUREFUNC(int rb_data_is_encoding(VALUE obj));
+/* vm.c */
+void rb_free_global_enc_table(void);
+
#endif /* INTERNAL_ENCODING_H */
diff --git a/internal/error.h b/internal/error.h
index 11601858f4..7e41f134d7 100644
--- a/internal/error.h
+++ b/internal/error.h
@@ -29,15 +29,37 @@
#define rb_raise_static(e, m) \
rb_raise_cstr_i((e), rb_str_new_static((m), rb_strlen_lit(m)))
#ifdef RUBY_FUNCTION_NAME_STRING
-# define rb_sys_fail_path(path) rb_sys_fail_path_in(RUBY_FUNCTION_NAME_STRING, path)
# define rb_syserr_fail_path(err, path) rb_syserr_fail_path_in(RUBY_FUNCTION_NAME_STRING, (err), (path))
# define rb_syserr_new_path(err, path) rb_syserr_new_path_in(RUBY_FUNCTION_NAME_STRING, (err), (path))
#else
-# define rb_sys_fail_path(path) rb_sys_fail_str(path)
# define rb_syserr_fail_path(err, path) rb_syserr_fail_str((err), (path))
# define rb_syserr_new_path(err, path) rb_syserr_new_str((err), (path))
#endif
+#define rb_sys_fail(mesg) \
+do { \
+ int errno_to_fail = errno; \
+ rb_syserr_fail(errno_to_fail, (mesg)); \
+} while (0)
+
+#define rb_sys_fail_str(mesg) \
+do { \
+ int errno_to_fail = errno; \
+ rb_syserr_fail_str(errno_to_fail, (mesg)); \
+} while (0)
+
+#define rb_sys_fail_path(path) \
+do { \
+ int errno_to_fail = errno; \
+ rb_syserr_fail_path(errno_to_fail, (path)); \
+} while (0)
+
+#define rb_sys_fail_sprintf(...) \
+do { \
+ int errno_to_fail = errno; \
+ rb_syserr_fail_str(errno_to_fail, rb_sprintf("" __VA_ARGS__)); \
+} while (0)
+
/* error.c */
extern long rb_backtrace_length_limit;
extern VALUE rb_eEAGAIN;
@@ -147,6 +169,9 @@ VALUE rb_syserr_new_path_in(const char *func_name, int n, VALUE path);
#endif
RUBY_SYMBOL_EXPORT_END
+/* vm.c */
+void rb_free_warning(void);
+
static inline void
rb_raise_cstr_i(VALUE etype, VALUE mesg)
{
diff --git a/internal/gc.h b/internal/gc.h
index 0e17a0f001..34a6043e8a 100644
--- a/internal/gc.h
+++ b/internal/gc.h
@@ -14,6 +14,116 @@
#include "internal/compilers.h" /* for __has_attribute */
#include "ruby/ruby.h" /* for rb_event_flag_t */
+#include "vm_core.h" /* for GET_EC() */
+
+#if defined(__x86_64__) && !defined(_ILP32) && defined(__GNUC__)
+#define SET_MACHINE_STACK_END(p) __asm__ __volatile__ ("movq\t%%rsp, %0" : "=r" (*(p)))
+#elif defined(__i386) && defined(__GNUC__)
+#define SET_MACHINE_STACK_END(p) __asm__ __volatile__ ("movl\t%%esp, %0" : "=r" (*(p)))
+#elif (defined(__powerpc__) || defined(__powerpc64__)) && defined(__GNUC__) && !defined(_AIX) && !defined(__APPLE__) // Not Apple is NEEDED to unbreak ppc64 build on Darwin. Don't ask.
+#define SET_MACHINE_STACK_END(p) __asm__ __volatile__ ("mr\t%0, %%r1" : "=r" (*(p)))
+#elif (defined(__powerpc__) || defined(__powerpc64__)) && defined(__GNUC__) && defined(_AIX)
+#define SET_MACHINE_STACK_END(p) __asm__ __volatile__ ("mr %0,1" : "=r" (*(p)))
+#elif defined(__POWERPC__) && defined(__APPLE__) // Darwin ppc and ppc64
+#define SET_MACHINE_STACK_END(p) __asm__ volatile("mr %0, r1" : "=r" (*(p)))
+#elif defined(__aarch64__) && defined(__GNUC__)
+#define SET_MACHINE_STACK_END(p) __asm__ __volatile__ ("mov\t%0, sp" : "=r" (*(p)))
+#else
+NOINLINE(void rb_gc_set_stack_end(VALUE **stack_end_p));
+#define SET_MACHINE_STACK_END(p) rb_gc_set_stack_end(p)
+#define USE_CONSERVATIVE_STACK_END
+#endif
+
+/* for GC debug */
+
+#ifndef RUBY_MARK_FREE_DEBUG
+#define RUBY_MARK_FREE_DEBUG 0
+#endif
+
+#if RUBY_MARK_FREE_DEBUG
+extern int ruby_gc_debug_indent;
+
+static inline void
+rb_gc_debug_indent(void)
+{
+ ruby_debug_printf("%*s", ruby_gc_debug_indent, "");
+}
+
+static inline void
+rb_gc_debug_body(const char *mode, const char *msg, int st, void *ptr)
+{
+ if (st == 0) {
+ ruby_gc_debug_indent--;
+ }
+ rb_gc_debug_indent();
+ ruby_debug_printf("%s: %s %s (%p)\n", mode, st ? "->" : "<-", msg, ptr);
+
+ if (st) {
+ ruby_gc_debug_indent++;
+ }
+
+ fflush(stdout);
+}
+
+#define RUBY_MARK_ENTER(msg) rb_gc_debug_body("mark", (msg), 1, ptr)
+#define RUBY_MARK_LEAVE(msg) rb_gc_debug_body("mark", (msg), 0, ptr)
+#define RUBY_FREE_ENTER(msg) rb_gc_debug_body("free", (msg), 1, ptr)
+#define RUBY_FREE_LEAVE(msg) rb_gc_debug_body("free", (msg), 0, ptr)
+#define RUBY_GC_INFO rb_gc_debug_indent(), ruby_debug_printf
+
+#else
+#define RUBY_MARK_ENTER(msg)
+#define RUBY_MARK_LEAVE(msg)
+#define RUBY_FREE_ENTER(msg)
+#define RUBY_FREE_LEAVE(msg)
+#define RUBY_GC_INFO if(0)printf
+#endif
+
+#define RUBY_MARK_MOVABLE_UNLESS_NULL(ptr) do { \
+ VALUE markobj = (ptr); \
+ if (RTEST(markobj)) {rb_gc_mark_movable(markobj);} \
+} while (0)
+#define RUBY_MARK_UNLESS_NULL(ptr) do { \
+ VALUE markobj = (ptr); \
+ if (RTEST(markobj)) {rb_gc_mark(markobj);} \
+} while (0)
+#define RUBY_FREE_UNLESS_NULL(ptr) if(ptr){ruby_xfree(ptr);(ptr)=NULL;}
+
+#if STACK_GROW_DIRECTION > 0
+# define STACK_UPPER(x, a, b) (a)
+#elif STACK_GROW_DIRECTION < 0
+# define STACK_UPPER(x, a, b) (b)
+#else
+RUBY_EXTERN int ruby_stack_grow_direction;
+int ruby_get_stack_grow_direction(volatile VALUE *addr);
+# define stack_growup_p(x) ( \
+ (ruby_stack_grow_direction ? \
+ ruby_stack_grow_direction : \
+ ruby_get_stack_grow_direction(x)) > 0)
+# define STACK_UPPER(x, a, b) (stack_growup_p(x) ? (a) : (b))
+#endif
+
+/*
+ STACK_GROW_DIR_DETECTION is used with STACK_DIR_UPPER.
+
+ On most normal systems, stacks grow from high address to lower address. In
+ this case, STACK_DIR_UPPER(a, b) will return (b), but on exotic systems where
+ the stack grows UP (from low address to high address), it will return (a).
+*/
+
+#if STACK_GROW_DIRECTION
+#define STACK_GROW_DIR_DETECTION
+#define STACK_DIR_UPPER(a,b) STACK_UPPER(0, (a), (b))
+#else
+#define STACK_GROW_DIR_DETECTION VALUE stack_grow_dir_detection
+#define STACK_DIR_UPPER(a,b) STACK_UPPER(&stack_grow_dir_detection, (a), (b))
+#endif
+#define IS_STACK_DIR_UPPER() STACK_DIR_UPPER(1,0)
+
+const char *rb_obj_info(VALUE obj);
+const char *rb_raw_obj_info(char *const buff, const size_t buff_size, VALUE obj);
+
+size_t rb_size_pool_slot_size(unsigned char pool_id);
struct rb_execution_context_struct; /* in vm_core.h */
struct rb_objspace; /* in vm_core.h */
@@ -23,25 +133,20 @@ struct rb_objspace; /* in vm_core.h */
# undef RB_NEWOBJ_OF
#endif
-#define RVALUE_SIZE (sizeof(struct RBasic) + sizeof(VALUE[RBIMPL_RVALUE_EMBED_LEN_MAX]))
-
-#define RB_RVARGC_NEWOBJ_OF(var, T, c, f, s) \
- T *(var) = (T *)(((f) & FL_WB_PROTECTED) ? \
- rb_wb_protected_newobj_of((c), (f) & ~FL_WB_PROTECTED, s) : \
- rb_wb_unprotected_newobj_of((c), (f), s))
+#define NEWOBJ_OF_0(var, T, c, f, s, ec) \
+ T *(var) = (T *)(((f) & FL_WB_PROTECTED) ? \
+ rb_wb_protected_newobj_of(GET_EC(), (c), (f) & ~FL_WB_PROTECTED, s) : \
+ rb_wb_unprotected_newobj_of((c), (f), s))
+#define NEWOBJ_OF_ec(var, T, c, f, s, ec) \
+ T *(var) = (T *)(((f) & FL_WB_PROTECTED) ? \
+ rb_wb_protected_newobj_of((ec), (c), (f) & ~FL_WB_PROTECTED, s) : \
+ rb_wb_unprotected_newobj_of((c), (f), s))
-#define RB_RVARGC_EC_NEWOBJ_OF(ec, var, T, c, f, s) \
- T *(var) = (T *)(((f) & FL_WB_PROTECTED) ? \
- rb_ec_wb_protected_newobj_of((ec), (c), (f) & ~FL_WB_PROTECTED, s) : \
- rb_wb_unprotected_newobj_of((c), (f), s))
+#define NEWOBJ_OF(var, T, c, f, s, ec) \
+ NEWOBJ_OF_HELPER(ec)(var, T, c, f, s, ec)
-/* optimized version of NEWOBJ() */
-#define RB_NEWOBJ_OF(var, T, c, f) RB_RVARGC_NEWOBJ_OF(var, T, c, f, RVALUE_SIZE)
+#define NEWOBJ_OF_HELPER(ec) NEWOBJ_OF_ ## ec
-#define RB_EC_NEWOBJ_OF(ec, var, T, c, f) RB_RVARGC_EC_NEWOBJ_OF(ec, var, T, c, f, RVALUE_SIZE)
-
-#define NEWOBJ_OF(var, T, c, f) RB_NEWOBJ_OF((var), T, (c), (f))
-#define RVARGC_NEWOBJ_OF(var, T, c, f, s) RB_RVARGC_NEWOBJ_OF((var), T, (c), (f), (s))
#define RB_OBJ_GC_FLAGS_MAX 6 /* used in ext/objspace */
#ifndef USE_UNALIGNED_MEMBER_ACCESS
@@ -73,15 +178,27 @@ struct rb_objspace; /* in vm_core.h */
# define UNALIGNED_MEMBER_PTR(ptr, mem) UNALIGNED_MEMBER_ACCESS(&(ptr)->mem)
#endif
+#define RB_OBJ_WRITE_UNALIGNED(old, slot, young) do { \
+ VALUE *_slot = UNALIGNED_MEMBER_ACCESS(slot); \
+ RB_OBJ_WRITE(old, _slot, young); \
+} while (0)
+
// We use SIZE_POOL_COUNT number of shape IDs for transitions out of different size pools
-// The next available shapd ID will be the SPECIAL_CONST_SHAPE_ID
-#if USE_RVARGC && (SIZEOF_UINT64_T == SIZEOF_VALUE)
+// The next available shape ID will be the SPECIAL_CONST_SHAPE_ID
+#ifndef SIZE_POOL_COUNT
# define SIZE_POOL_COUNT 5
-#else
-# define SIZE_POOL_COUNT 1
#endif
-#define RCLASS_EXT_EMBEDDED (SIZE_POOL_COUNT > 1)
+/* Used in places that could malloc during, which can cause the GC to run. We
+ * need to temporarily disable the GC to allow the malloc to happen.
+ * Allocating memory during GC is a bad idea, so use this only when absolutely
+ * necessary. */
+#define DURING_GC_COULD_MALLOC_REGION_START() \
+ assert(rb_during_gc()); \
+ VALUE _already_disabled = rb_gc_disable_no_rest()
+
+#define DURING_GC_COULD_MALLOC_REGION_END() \
+ if (_already_disabled == Qfalse) rb_gc_enable()
typedef struct ractor_newobj_size_pool_cache {
struct RVALUE *freelist;
@@ -98,6 +215,7 @@ extern VALUE *ruby_initial_gc_stress_ptr;
extern int ruby_disable_gc;
RUBY_ATTR_MALLOC void *ruby_mimmalloc(size_t size);
void ruby_mimfree(void *ptr);
+void rb_gc_prepare_heap(void);
void rb_objspace_set_event_hook(const rb_event_flag_t event);
VALUE rb_objspace_gc_enable(struct rb_objspace *);
VALUE rb_objspace_gc_disable(struct rb_objspace *);
@@ -109,6 +227,7 @@ __attribute__((__alloc_align__(1)))
RUBY_ATTR_MALLOC void *rb_aligned_malloc(size_t, size_t) RUBY_ATTR_ALLOC_SIZE((2));
size_t rb_size_mul_or_raise(size_t, size_t, VALUE); /* used in compile.c */
size_t rb_size_mul_add_or_raise(size_t, size_t, size_t, VALUE); /* used in iseq.h */
+size_t rb_malloc_grow_capa(size_t current_capacity, size_t type_size);
RUBY_ATTR_MALLOC void *rb_xmalloc_mul_add(size_t, size_t, size_t);
RUBY_ATTR_MALLOC void *rb_xcalloc_mul_add(size_t, size_t, size_t);
void *rb_xrealloc_mul_add(const void *, size_t, size_t, size_t);
@@ -122,9 +241,17 @@ void rb_gc_ractor_newobj_cache_clear(rb_ractor_newobj_cache_t *newobj_cache);
size_t rb_gc_obj_slot_size(VALUE obj);
bool rb_gc_size_allocatable_p(size_t size);
int rb_objspace_garbage_object_p(VALUE obj);
+bool rb_gc_is_ptr_to_obj(void *ptr);
+VALUE rb_gc_id2ref_obj_tbl(VALUE objid);
+VALUE rb_define_finalizer_no_check(VALUE obj, VALUE block);
void rb_gc_mark_and_move(VALUE *ptr);
+void rb_gc_mark_weak(VALUE *ptr);
+void rb_gc_remove_weak(VALUE parent_obj, VALUE *ptr);
+
+void rb_gc_ref_update_table_values_only(st_table *tbl);
+
#define rb_gc_mark_and_move_ptr(ptr) do { \
VALUE _obj = (VALUE)*(ptr); \
rb_gc_mark_and_move(&_obj); \
@@ -132,26 +259,45 @@ void rb_gc_mark_and_move(VALUE *ptr);
} while (0)
RUBY_SYMBOL_EXPORT_BEGIN
+/* exports for objspace module */
+size_t rb_objspace_data_type_memsize(VALUE obj);
+void rb_objspace_reachable_objects_from(VALUE obj, void (func)(VALUE, void *), void *data);
+void rb_objspace_reachable_objects_from_root(void (func)(const char *category, VALUE, void *), void *data);
+int rb_objspace_markable_object_p(VALUE obj);
+int rb_objspace_internal_object_p(VALUE obj);
+int rb_objspace_marked_object_p(VALUE obj);
+
+void rb_objspace_each_objects(
+ int (*callback)(void *start, void *end, size_t stride, void *data),
+ void *data);
+
+void rb_objspace_each_objects_without_setup(
+ int (*callback)(void *, void *, size_t, void *),
+ void *data);
+
+size_t rb_gc_obj_slot_size(VALUE obj);
+
+VALUE rb_gc_disable_no_rest(void);
+
+
/* gc.c (export) */
const char *rb_objspace_data_type_name(VALUE obj);
-VALUE rb_wb_protected_newobj_of(VALUE, VALUE, size_t);
+VALUE rb_wb_protected_newobj_of(struct rb_execution_context_struct *, VALUE, VALUE, size_t);
VALUE rb_wb_unprotected_newobj_of(VALUE, VALUE, size_t);
-VALUE rb_ec_wb_protected_newobj_of(struct rb_execution_context_struct *ec, VALUE klass, VALUE flags, size_t);
size_t rb_obj_memsize_of(VALUE);
void rb_gc_verify_internal_consistency(void);
size_t rb_obj_gc_flags(VALUE, ID[], size_t);
void rb_gc_mark_values(long n, const VALUE *values);
void rb_gc_mark_vm_stack_values(long n, const VALUE *values);
+void rb_gc_update_values(long n, VALUE *values);
void *ruby_sized_xrealloc(void *ptr, size_t new_size, size_t old_size) RUBY_ATTR_RETURNS_NONNULL RUBY_ATTR_ALLOC_SIZE((2));
void *ruby_sized_xrealloc2(void *ptr, size_t new_count, size_t element_size, size_t old_count) RUBY_ATTR_RETURNS_NONNULL RUBY_ATTR_ALLOC_SIZE((2, 3));
void ruby_sized_xfree(void *x, size_t size);
RUBY_SYMBOL_EXPORT_END
-MJIT_SYMBOL_EXPORT_BEGIN
int rb_ec_stack_check(struct rb_execution_context_struct *ec);
void rb_gc_writebarrier_remember(VALUE obj);
const char *rb_obj_info(VALUE obj);
-MJIT_SYMBOL_EXPORT_END
#if defined(HAVE_MALLOC_USABLE_SIZE) || defined(HAVE_MALLOC_SIZE) || defined(_WIN32)
@@ -175,6 +321,12 @@ ruby_sized_xfree_inlined(void *ptr, size_t size)
# define SIZED_REALLOC_N(x, y, z, w) REALLOC_N(x, y, z)
+static inline void *
+ruby_sized_realloc_n(void *ptr, size_t new_count, size_t element_size, size_t old_count)
+{
+ return ruby_xrealloc2(ptr, new_count, element_size);
+}
+
#else
static inline void *
@@ -198,6 +350,12 @@ ruby_sized_xfree_inlined(void *ptr, size_t size)
# define SIZED_REALLOC_N(v, T, m, n) \
((v) = (T *)ruby_sized_xrealloc2((void *)(v), (m), sizeof(T), (n)))
+static inline void *
+ruby_sized_realloc_n(void *ptr, size_t new_count, size_t element_size, size_t old_count)
+{
+ return ruby_sized_xrealloc2(ptr, new_count, element_size, old_count);
+}
+
#endif /* HAVE_MALLOC_USABLE_SIZE */
#define ruby_sized_xrealloc ruby_sized_xrealloc_inlined
diff --git a/internal/hash.h b/internal/hash.h
index 5545ecb855..fe859cb716 100644
--- a/internal/hash.h
+++ b/internal/hash.h
@@ -28,10 +28,6 @@ enum ruby_rhash_flags {
RHASH_AR_TABLE_BOUND_MASK = (FL_USER8|FL_USER9|FL_USER10|FL_USER11), /* FL 8..11 */
RHASH_AR_TABLE_BOUND_SHIFT = (FL_USHIFT+8),
-#if USE_TRANSIENT_HEAP
- RHASH_TRANSIENT_FLAG = FL_USER12, /* FL 12 */
-#endif
-
// we can not put it in "enum" because it can exceed "int" range.
#define RHASH_LEV_MASK (FL_USER13 | FL_USER14 | FL_USER15 | /* FL 13..19 */ \
FL_USER16 | FL_USER17 | FL_USER18 | FL_USER19)
@@ -40,17 +36,23 @@ enum ruby_rhash_flags {
RHASH_LEV_MAX = 127, /* 7 bits */
};
-struct RHash {
- struct RBasic basic;
- union {
- st_table *st;
- struct ar_table_struct *ar; /* possibly 0 */
- } as;
- const VALUE ifnone;
+typedef struct ar_table_pair_struct {
+ VALUE key;
+ VALUE val;
+} ar_table_pair;
+
+typedef struct ar_table_struct {
union {
ar_hint_t ary[RHASH_AR_TABLE_MAX_SIZE];
VALUE word;
} ar_hint;
+ /* 64bit CPU: 8B * 2 * 8 = 128B */
+ ar_table_pair pairs[RHASH_AR_TABLE_MAX_SIZE];
+} ar_table;
+
+struct RHash {
+ struct RBasic basic;
+ const VALUE ifnone;
};
#define RHASH(obj) ((struct RHash *)(obj))
@@ -73,6 +75,8 @@ VALUE rb_hash_default_value(VALUE hash, VALUE key);
VALUE rb_hash_set_default_proc(VALUE hash, VALUE proc);
long rb_dbl_long_hash(double d);
st_table *rb_init_identtable(void);
+st_index_t rb_any_hash(VALUE a);
+int rb_any_cmp(VALUE a, VALUE b);
VALUE rb_to_hash_type(VALUE obj);
VALUE rb_hash_key_str(VALUE);
VALUE rb_hash_values(VALUE hash);
@@ -83,6 +87,7 @@ int rb_hash_stlike_delete(VALUE hash, st_data_t *pkey, st_data_t *pval);
int rb_hash_stlike_foreach_with_replace(VALUE hash, st_foreach_check_callback_func *func, st_update_callback_func *replace, st_data_t arg);
int rb_hash_stlike_update(VALUE hash, st_data_t key, st_update_callback_func *func, st_data_t arg);
VALUE rb_ident_hash_new_with_size(st_index_t size);
+void rb_hash_free(VALUE hash);
static inline unsigned RHASH_AR_TABLE_SIZE_RAW(VALUE h);
static inline VALUE RHASH_IFNONE(VALUE h);
@@ -94,9 +99,6 @@ static inline struct ar_table_struct *RHASH_AR_TABLE(VALUE h);
static inline st_table *RHASH_ST_TABLE(VALUE h);
static inline size_t RHASH_ST_SIZE(VALUE h);
static inline void RHASH_ST_CLEAR(VALUE h);
-static inline bool RHASH_TRANSIENT_P(VALUE h);
-static inline void RHASH_SET_TRANSIENT_FLAG(VALUE h);
-static inline void RHASH_UNSET_TRANSIENT_FLAG(VALUE h);
RUBY_SYMBOL_EXPORT_BEGIN
/* hash.c (export) */
@@ -105,7 +107,6 @@ VALUE rb_ident_hash_new(void);
int rb_hash_stlike_foreach(VALUE hash, st_foreach_callback_func *func, st_data_t arg);
RUBY_SYMBOL_EXPORT_END
-MJIT_SYMBOL_EXPORT_BEGIN
VALUE rb_hash_new_with_size(st_index_t size);
VALUE rb_hash_resurrect(VALUE hash);
int rb_hash_stlike_lookup(VALUE hash, st_data_t key, st_data_t *pval);
@@ -115,7 +116,6 @@ VALUE rb_hash_compare_by_id_p(VALUE hash);
st_table *rb_hash_tbl_raw(VALUE hash, const char *file, int line);
#define RHASH_TBL_RAW(h) rb_hash_tbl_raw(h, __FILE__, __LINE__)
-MJIT_SYMBOL_EXPORT_END
VALUE rb_hash_compare_by_id(VALUE hash);
@@ -125,16 +125,18 @@ RHASH_AR_TABLE_P(VALUE h)
return ! FL_TEST_RAW(h, RHASH_ST_TABLE_FLAG);
}
+RBIMPL_ATTR_RETURNS_NONNULL()
static inline struct ar_table_struct *
RHASH_AR_TABLE(VALUE h)
{
- return RHASH(h)->as.ar;
+ return (struct ar_table_struct *)((uintptr_t)h + sizeof(struct RHash));
}
+RBIMPL_ATTR_RETURNS_NONNULL()
static inline st_table *
RHASH_ST_TABLE(VALUE h)
{
- return RHASH(h)->as.st;
+ return (st_table *)((uintptr_t)h + sizeof(struct RHash));
}
static inline VALUE
@@ -175,8 +177,7 @@ RHASH_ST_SIZE(VALUE h)
static inline void
RHASH_ST_CLEAR(VALUE h)
{
- RHASH(h)->as.st = NULL;
- FL_UNSET_RAW(h, RHASH_ST_TABLE_FLAG);
+ memset(RHASH_ST_TABLE(h), 0, sizeof(st_table));
}
static inline unsigned
@@ -187,30 +188,4 @@ RHASH_AR_TABLE_SIZE_RAW(VALUE h)
return (unsigned)ret;
}
-static inline bool
-RHASH_TRANSIENT_P(VALUE h)
-{
-#if USE_TRANSIENT_HEAP
- return FL_TEST_RAW(h, RHASH_TRANSIENT_FLAG);
-#else
- return false;
-#endif
-}
-
-static inline void
-RHASH_SET_TRANSIENT_FLAG(VALUE h)
-{
-#if USE_TRANSIENT_HEAP
- FL_SET_RAW(h, RHASH_TRANSIENT_FLAG);
-#endif
-}
-
-static inline void
-RHASH_UNSET_TRANSIENT_FLAG(VALUE h)
-{
-#if USE_TRANSIENT_HEAP
- FL_UNSET_RAW(h, RHASH_TRANSIENT_FLAG);
-#endif
-}
-
#endif /* INTERNAL_HASH_H */
diff --git a/internal/imemo.h b/internal/imemo.h
index 8d506dda7d..65335285ab 100644
--- a/internal/imemo.h
+++ b/internal/imemo.h
@@ -82,7 +82,7 @@ struct vm_ifunc_argc {
/*! IFUNC (Internal FUNCtion) */
struct vm_ifunc {
VALUE flags;
- struct rb_control_frame_struct *owner_cfp;
+ VALUE *svar_lep;
rb_block_call_func_t func;
const void *data;
struct vm_ifunc_argc argc;
@@ -129,7 +129,6 @@ struct MEMO {
typedef struct rb_imemo_tmpbuf_struct rb_imemo_tmpbuf_t;
rb_imemo_tmpbuf_t *rb_imemo_tmpbuf_parser_heap(void *buf, rb_imemo_tmpbuf_t *old_heap, size_t cnt);
struct vm_ifunc *rb_vm_ifunc_new(rb_block_call_func_t func, const void *data, int min_argc, int max_argc);
-void rb_strterm_mark(VALUE obj);
static inline enum imemo_type imemo_type(VALUE imemo);
static inline int imemo_type_p(VALUE imemo, enum imemo_type imemo_type);
static inline bool imemo_throw_data_p(VALUE imemo);
diff --git a/internal/io.h b/internal/io.h
index b5f15499d7..f16d9efc9c 100644
--- a/internal/io.h
+++ b/internal/io.h
@@ -9,8 +9,107 @@
* @brief Internal header for IO.
*/
#include "ruby/ruby.h" /* for VALUE */
+
+#define HAVE_RB_IO_T
+struct rb_io;
+
#include "ruby/io.h" /* for rb_io_t */
+/** Ruby's IO, metadata and buffers. */
+struct rb_io {
+
+ /** The IO's Ruby level counterpart. */
+ VALUE self;
+
+ /** stdio ptr for read/write, if available. */
+ FILE *stdio_file;
+
+ /** file descriptor. */
+ int fd;
+
+ /** mode flags: FMODE_XXXs */
+ int mode;
+
+ /** child's pid (for pipes) */
+ rb_pid_t pid;
+
+ /** number of lines read */
+ int lineno;
+
+ /** pathname for file */
+ VALUE pathv;
+
+ /** finalize proc */
+ void (*finalize)(struct rb_io*,int);
+
+ /** Write buffer. */
+ rb_io_buffer_t wbuf;
+
+ /**
+ * (Byte) read buffer. Note also that there is a field called
+ * ::rb_io_t::cbuf, which also concerns read IO.
+ */
+ rb_io_buffer_t rbuf;
+
+ /**
+ * Duplex IO object, if set.
+ *
+ * @see rb_io_set_write_io()
+ */
+ VALUE tied_io_for_writing;
+
+ struct rb_io_encoding encs; /**< Decomposed encoding flags. */
+
+ /** Encoding converter used when reading from this IO. */
+ rb_econv_t *readconv;
+
+ /**
+ * rb_io_ungetc() destination. This buffer is read before checking
+ * ::rb_io_t::rbuf
+ */
+ rb_io_buffer_t cbuf;
+
+ /** Encoding converter used when writing to this IO. */
+ rb_econv_t *writeconv;
+
+ /**
+ * This is, when set, an instance of ::rb_cString which holds the "common"
+ * encoding. Write conversion can convert strings twice... In case
+ * conversion from encoding X to encoding Y does not exist, Ruby finds an
+ * encoding Z that bridges the two, so that X to Z to Y conversion happens.
+ */
+ VALUE writeconv_asciicompat;
+
+ /** Whether ::rb_io_t::writeconv is already set up. */
+ int writeconv_initialized;
+
+ /**
+ * Value of ::rb_io_t::rb_io_enc_t::ecflags stored right before
+ * initialising ::rb_io_t::writeconv.
+ */
+ int writeconv_pre_ecflags;
+
+ /**
+ * Value of ::rb_io_t::rb_io_enc_t::ecopts stored right before initialising
+ * ::rb_io_t::writeconv.
+ */
+ VALUE writeconv_pre_ecopts;
+
+ /**
+ * This is a Ruby level mutex. It avoids multiple threads to write to an
+ * IO at once; helps for instance rb_io_puts() to ensure newlines right
+ * next to its arguments.
+ *
+ * This of course doesn't help inter-process IO interleaves, though.
+ */
+ VALUE write_lock;
+
+ /**
+ * The timeout associated with this IO when performing blocking operations.
+ */
+ VALUE timeout;
+};
+
/* io.c */
void ruby_set_inplace_mode(const char *);
void rb_stdio_set_default_encoding(void);
diff --git a/internal/numeric.h b/internal/numeric.h
index 89bc54b307..f7b8d0ad2d 100644
--- a/internal/numeric.h
+++ b/internal/numeric.h
@@ -111,7 +111,6 @@ RUBY_SYMBOL_EXPORT_BEGIN
/* numeric.c (export) */
RUBY_SYMBOL_EXPORT_END
-MJIT_SYMBOL_EXPORT_BEGIN
VALUE rb_flo_div_flo(VALUE x, VALUE y);
double ruby_float_mod(double x, double y);
VALUE rb_float_equal(VALUE x, VALUE y);
@@ -125,7 +124,6 @@ VALUE rb_int_abs(VALUE num);
VALUE rb_int_bit_length(VALUE num);
VALUE rb_int_uminus(VALUE num);
VALUE rb_int_comp(VALUE num);
-MJIT_SYMBOL_EXPORT_END
static inline bool
INT_POSITIVE_P(VALUE num)
diff --git a/internal/object.h b/internal/object.h
index 7b54e13dd2..903e2d29a5 100644
--- a/internal/object.h
+++ b/internal/object.h
@@ -11,10 +11,13 @@
#include "ruby/ruby.h" /* for VALUE */
/* object.c */
+size_t rb_obj_embedded_size(uint32_t numiv);
VALUE rb_class_search_ancestor(VALUE klass, VALUE super);
NORETURN(void rb_undefined_alloc(VALUE klass));
double rb_num_to_dbl(VALUE val);
VALUE rb_obj_dig(int argc, VALUE *argv, VALUE self, VALUE notfound);
+VALUE rb_obj_clone_setup(VALUE obj, VALUE clone, VALUE kwfreeze);
+VALUE rb_obj_dup_setup(VALUE obj, VALUE dup);
VALUE rb_immutable_obj_clone(int, VALUE *, VALUE);
VALUE rb_check_convert_type_with_id(VALUE,int,const char*,ID);
int rb_bool_expected(VALUE, const char *, int raise);
@@ -27,7 +30,6 @@ RUBY_SYMBOL_EXPORT_BEGIN
int rb_opts_exception_p(VALUE opts, int default_value);
RUBY_SYMBOL_EXPORT_END
-MJIT_SYMBOL_EXPORT_BEGIN
CONSTFUNC(VALUE rb_obj_equal(VALUE obj1, VALUE obj2));
CONSTFUNC(VALUE rb_obj_not(VALUE obj));
VALUE rb_obj_not_equal(VALUE obj1, VALUE obj2);
@@ -36,7 +38,6 @@ VALUE rb_false(VALUE obj);
VALUE rb_convert_type_with_id(VALUE v, int t, const char* nam, ID mid);
VALUE rb_obj_size(VALUE self, VALUE args, VALUE obj);
VALUE rb_get_freeze_opt(int argc, VALUE *argv);
-MJIT_SYMBOL_EXPORT_END
static inline void
RBASIC_SET_CLASS_RAW(VALUE obj, VALUE klass)
diff --git a/internal/parse.h b/internal/parse.h
index f242c384ad..bd6d295be1 100644
--- a/internal/parse.h
+++ b/internal/parse.h
@@ -8,18 +8,101 @@
* file COPYING are met. Consult the file for details.
* @brief Internal header for the parser.
*/
-#include "ruby/ruby.h" /* for VALUE */
+#include <limits.h>
+#include "rubyparser.h"
+#include "internal/static_assert.h"
+
+#ifdef UNIVERSAL_PARSER
+#define rb_encoding void
+#endif
+
struct rb_iseq_struct; /* in vm_core.h */
+#define STRTERM_HEREDOC IMEMO_FL_USER0
+
+/* structs for managing terminator of string literal and heredocment */
+typedef struct rb_strterm_literal_struct {
+ long nest;
+ int func; /* STR_FUNC_* (e.g., STR_FUNC_ESCAPE and STR_FUNC_EXPAND) */
+ int paren; /* '(' of `%q(...)` */
+ int term; /* ')' of `%q(...)` */
+} rb_strterm_literal_t;
+
+typedef struct rb_strterm_heredoc_struct {
+ VALUE lastline; /* the string of line that contains `<<"END"` */
+ long offset; /* the column of END in `<<"END"` */
+ int sourceline; /* lineno of the line that contains `<<"END"` */
+ unsigned length; /* the length of END in `<<"END"` */
+ uint8_t quote;
+ uint8_t func;
+} rb_strterm_heredoc_t;
+
+#define HERETERM_LENGTH_MAX UINT_MAX
+
+typedef struct rb_strterm_struct {
+ VALUE flags;
+ union {
+ rb_strterm_literal_t literal;
+ rb_strterm_heredoc_t heredoc;
+ } u;
+} rb_strterm_t;
+
/* parse.y */
-VALUE rb_parser_set_yydebug(VALUE, VALUE);
-void *rb_parser_load_file(VALUE parser, VALUE name);
-void rb_parser_keep_script_lines(VALUE vparser);
-void rb_parser_error_tolerant(VALUE vparser);
-void rb_parser_keep_tokens(VALUE vparser);
+void rb_ruby_parser_mark(void *ptr);
+size_t rb_ruby_parser_memsize(const void *ptr);
+
+void rb_ruby_parser_set_options(rb_parser_t *p, int print, int loop, int chomp, int split);
+rb_parser_t *rb_ruby_parser_set_context(rb_parser_t *p, const struct rb_iseq_struct *base, int main);
+void rb_ruby_parser_set_script_lines(rb_parser_t *p, VALUE lines_array);
+void rb_ruby_parser_error_tolerant(rb_parser_t *p);
+rb_ast_t* rb_ruby_parser_compile_file_path(rb_parser_t *p, VALUE fname, VALUE file, int start);
+void rb_ruby_parser_keep_tokens(rb_parser_t *p);
+rb_ast_t* rb_ruby_parser_compile_generic(rb_parser_t *p, VALUE (*lex_gets)(VALUE, int), VALUE fname, VALUE input, int start);
+rb_ast_t* rb_ruby_parser_compile_string_path(rb_parser_t *p, VALUE f, VALUE s, int line);
RUBY_SYMBOL_EXPORT_BEGIN
-VALUE rb_parser_set_context(VALUE, const struct rb_iseq_struct *, int);
+
+VALUE rb_ruby_parser_encoding(rb_parser_t *p);
+int rb_ruby_parser_end_seen_p(rb_parser_t *p);
+int rb_ruby_parser_set_yydebug(rb_parser_t *p, int flag);
+
RUBY_SYMBOL_EXPORT_END
+int rb_reg_named_capture_assign_iter_impl(struct parser_params *p, const char *s, long len, rb_encoding *enc, NODE **succ_block, const rb_code_location_t *loc);
+
+#ifdef RIPPER
+void ripper_parser_mark(void *ptr);
+void ripper_parser_free(void *ptr);
+size_t ripper_parser_memsize(const void *ptr);
+void ripper_error(struct parser_params *p);
+VALUE ripper_value(struct parser_params *p);
+int rb_ruby_parser_get_yydebug(rb_parser_t *p);
+void rb_ruby_parser_set_value(rb_parser_t *p, VALUE value);
+int rb_ruby_parser_error_p(rb_parser_t *p);
+VALUE rb_ruby_parser_debug_output(rb_parser_t *p);
+void rb_ruby_parser_set_debug_output(rb_parser_t *p, VALUE output);
+VALUE rb_ruby_parser_parsing_thread(rb_parser_t *p);
+void rb_ruby_parser_set_parsing_thread(rb_parser_t *p, VALUE parsing_thread);
+void rb_ruby_parser_ripper_initialize(rb_parser_t *p, VALUE (*gets)(struct parser_params*,VALUE), VALUE input, VALUE sourcefile_string, const char *sourcefile, int sourceline);
+VALUE rb_ruby_parser_result(rb_parser_t *p);
+rb_encoding *rb_ruby_parser_enc(rb_parser_t *p);
+VALUE rb_ruby_parser_ruby_sourcefile_string(rb_parser_t *p);
+int rb_ruby_parser_ruby_sourceline(rb_parser_t *p);
+int rb_ruby_parser_lex_state(rb_parser_t *p);
+void rb_ruby_ripper_parse0(rb_parser_t *p);
+int rb_ruby_ripper_dedent_string(rb_parser_t *p, VALUE string, int width);
+VALUE rb_ruby_ripper_lex_get_str(rb_parser_t *p, VALUE s);
+int rb_ruby_ripper_initialized_p(rb_parser_t *p);
+void rb_ruby_ripper_parser_initialize(rb_parser_t *p);
+long rb_ruby_ripper_column(rb_parser_t *p);
+long rb_ruby_ripper_token_len(rb_parser_t *p);
+VALUE rb_ruby_ripper_lex_lastline(rb_parser_t *p);
+VALUE rb_ruby_ripper_lex_state_name(struct parser_params *p, int state);
+struct parser_params *rb_ruby_ripper_parser_allocate(void);
+#endif
+
+#ifdef UNIVERSAL_PARSER
+#undef rb_encoding
+#endif
+
#endif /* INTERNAL_PARSE_H */
diff --git a/internal/proc.h b/internal/proc.h
index 2416c31e14..c75f15b283 100644
--- a/internal/proc.h
+++ b/internal/proc.h
@@ -22,11 +22,9 @@ int rb_block_min_max_arity(int *max);
VALUE rb_block_to_s(VALUE self, const struct rb_block *block, const char *additional_info);
VALUE rb_callable_receiver(VALUE);
-MJIT_SYMBOL_EXPORT_BEGIN
VALUE rb_func_proc_new(rb_block_call_func_t func, VALUE val);
VALUE rb_func_lambda_new(rb_block_call_func_t func, VALUE val, int min_argc, int max_argc);
VALUE rb_iseq_location(const struct rb_iseq_struct *iseq);
VALUE rb_sym_to_proc(VALUE sym);
-MJIT_SYMBOL_EXPORT_END
#endif /* INTERNAL_PROC_H */
diff --git a/internal/process.h b/internal/process.h
index b9c52aebaa..fd4994cb4b 100644
--- a/internal/process.h
+++ b/internal/process.h
@@ -22,7 +22,6 @@
#include "ruby/ruby.h" /* for VALUE */
#include "internal/compilers.h" /* for __has_warning */
#include "internal/imemo.h" /* for RB_IMEMO_TMPBUF_PTR */
-#include "internal/warnings.h" /* for COMPILER_WARNING_PUSH */
#define RB_MAX_GROUPS (65536)
@@ -122,17 +121,4 @@ ARGVSTR2ARGC(VALUE argv_str)
return i - 1;
}
-#ifdef HAVE_WORKING_FORK
-COMPILER_WARNING_PUSH
-#if __has_warning("-Wdeprecated-declarations") || RBIMPL_COMPILER_IS(GCC)
-COMPILER_WARNING_IGNORED(-Wdeprecated-declarations)
-#endif
-static inline rb_pid_t
-rb_fork(void)
-{
- return fork();
-}
-COMPILER_WARNING_POP
-#endif
-
#endif /* INTERNAL_PROCESS_H */
diff --git a/internal/random.h b/internal/random.h
index 231e2d5d7e..127b908e16 100644
--- a/internal/random.h
+++ b/internal/random.h
@@ -12,5 +12,6 @@
/* random.c */
int ruby_fill_random_bytes(void *, size_t, int);
+void rb_free_default_rand_key(void);
#endif /* INTERNAL_RANDOM_H */
diff --git a/internal/range.h b/internal/range.h
index 8daba0ecab..2394937bf8 100644
--- a/internal/range.h
+++ b/internal/range.h
@@ -24,13 +24,13 @@ RANGE_BEG(VALUE r)
static inline VALUE
RANGE_END(VALUE r)
{
- return RSTRUCT(r)->as.ary[1];
+ return RSTRUCT_GET(r, 1);
}
static inline VALUE
RANGE_EXCL(VALUE r)
{
- return RSTRUCT(r)->as.ary[2];
+ return RSTRUCT_GET(r, 2);
}
VALUE
diff --git a/internal/re.h b/internal/re.h
index 8b31b3d8a5..3e20114665 100644
--- a/internal/re.h
+++ b/internal/re.h
@@ -22,9 +22,7 @@ VALUE rb_reg_equal(VALUE re1, VALUE re2);
void rb_backref_set_string(VALUE string, long pos, long len);
void rb_match_unbusy(VALUE);
int rb_match_count(VALUE match);
-int rb_match_nth_defined(int nth, VALUE match);
-MJIT_SYMBOL_EXPORT_BEGIN
VALUE rb_reg_new_ary(VALUE ary, int options);
-MJIT_SYMBOL_EXPORT_END
+VALUE rb_reg_last_defined(VALUE match);
#endif /* INTERNAL_RE_H */
diff --git a/internal/ruby_parser.h b/internal/ruby_parser.h
new file mode 100644
index 0000000000..6beb2808ab
--- /dev/null
+++ b/internal/ruby_parser.h
@@ -0,0 +1,69 @@
+#ifndef INTERNAL_RUBY_PARSE_H
+#define INTERNAL_RUBY_PARSE_H
+
+#include "internal.h"
+#include "internal/imemo.h"
+#include "rubyparser.h"
+#include "vm.h"
+
+RUBY_SYMBOL_EXPORT_BEGIN
+#ifdef UNIVERSAL_PARSER
+void rb_parser_config_initialize(rb_parser_config_t *config);
+#endif
+VALUE rb_parser_set_context(VALUE, const struct rb_iseq_struct *, int);
+VALUE rb_parser_new(void);
+rb_ast_t *rb_parser_compile_string_path(VALUE vparser, VALUE fname, VALUE src, int line);
+RUBY_SYMBOL_EXPORT_END
+
+VALUE rb_parser_end_seen_p(VALUE);
+VALUE rb_parser_encoding(VALUE);
+VALUE rb_parser_set_yydebug(VALUE, VALUE);
+void rb_parser_set_options(VALUE, int, int, int, int);
+void *rb_parser_load_file(VALUE parser, VALUE name);
+void rb_parser_set_script_lines(VALUE vparser, VALUE lines_array);
+void rb_parser_error_tolerant(VALUE vparser);
+void rb_parser_keep_tokens(VALUE vparser);
+
+rb_ast_t *rb_parser_compile_string(VALUE, const char*, VALUE, int);
+rb_ast_t *rb_parser_compile_file_path(VALUE vparser, VALUE fname, VALUE input, int line);
+rb_ast_t *rb_parser_compile_generic(VALUE vparser, VALUE (*lex_gets)(VALUE, int), VALUE fname, VALUE input, int line);
+
+enum lex_state_bits {
+ EXPR_BEG_bit, /* ignore newline, +/- is a sign. */
+ EXPR_END_bit, /* newline significant, +/- is an operator. */
+ EXPR_ENDARG_bit, /* ditto, and unbound braces. */
+ EXPR_ENDFN_bit, /* ditto, and unbound braces. */
+ EXPR_ARG_bit, /* newline significant, +/- is an operator. */
+ EXPR_CMDARG_bit, /* newline significant, +/- is an operator. */
+ EXPR_MID_bit, /* newline significant, +/- is an operator. */
+ EXPR_FNAME_bit, /* ignore newline, no reserved words. */
+ EXPR_DOT_bit, /* right after `.', `&.' or `::', no reserved words. */
+ EXPR_CLASS_bit, /* immediate after `class', no here document. */
+ EXPR_LABEL_bit, /* flag bit, label is allowed. */
+ EXPR_LABELED_bit, /* flag bit, just after a label. */
+ EXPR_FITEM_bit, /* symbol literal as FNAME. */
+ EXPR_MAX_STATE
+};
+/* examine combinations */
+enum lex_state_e {
+#define DEF_EXPR(n) EXPR_##n = (1 << EXPR_##n##_bit)
+ DEF_EXPR(BEG),
+ DEF_EXPR(END),
+ DEF_EXPR(ENDARG),
+ DEF_EXPR(ENDFN),
+ DEF_EXPR(ARG),
+ DEF_EXPR(CMDARG),
+ DEF_EXPR(MID),
+ DEF_EXPR(FNAME),
+ DEF_EXPR(DOT),
+ DEF_EXPR(CLASS),
+ DEF_EXPR(LABEL),
+ DEF_EXPR(LABELED),
+ DEF_EXPR(FITEM),
+ EXPR_VALUE = EXPR_BEG,
+ EXPR_BEG_ANY = (EXPR_BEG | EXPR_MID | EXPR_CLASS),
+ EXPR_ARG_ANY = (EXPR_ARG | EXPR_CMDARG),
+ EXPR_END_ANY = (EXPR_END | EXPR_ENDARG | EXPR_ENDFN),
+ EXPR_NONE = 0
+};
+#endif /* INTERNAL_RUBY_PARSE_H */
diff --git a/internal/sanitizers.h b/internal/sanitizers.h
index 6e2d81137f..7b7d166c74 100644
--- a/internal/sanitizers.h
+++ b/internal/sanitizers.h
@@ -89,8 +89,6 @@
# define VALGRIND_MAKE_MEM_UNDEFINED(p, n) 0
#endif
-#ifndef MJIT_HEADER
-
/*!
* This function asserts that a (continuous) memory region from ptr to size
* being "poisoned". Both read / write access to such memory region are
@@ -185,6 +183,4 @@ asan_unpoison_object(VALUE obj, bool newobj_p)
asan_unpoison_memory_region(ptr, SIZEOF_VALUE, newobj_p);
}
-#endif /* MJIT_HEADER */
-
#endif /* INTERNAL_SANITIZERS_H */
diff --git a/internal/signal.h b/internal/signal.h
index 86fb54e949..660cd95f78 100644
--- a/internal/signal.h
+++ b/internal/signal.h
@@ -13,6 +13,10 @@
extern int ruby_enable_coredump;
int rb_get_next_signal(void);
+#ifdef POSIX_SIGNAL
+void (*ruby_posix_signal(int, void (*)(int)))(int);
+#endif
+
RUBY_SYMBOL_EXPORT_BEGIN
/* signal.c (export) */
int rb_grantpt(int fd);
diff --git a/internal/string.h b/internal/string.h
index 12edbff2b1..8c481f979e 100644
--- a/internal/string.h
+++ b/internal/string.h
@@ -64,10 +64,8 @@ VALUE rb_str_upto_endless_each(VALUE, int (*each)(VALUE, VALUE), VALUE);
void rb_str_make_embedded(VALUE);
size_t rb_str_size_as_embedded(VALUE);
bool rb_str_reembeddable_p(VALUE);
-void rb_str_update_shared_ary(VALUE str, VALUE old_root, VALUE new_root);
RUBY_SYMBOL_EXPORT_END
-MJIT_SYMBOL_EXPORT_BEGIN
VALUE rb_fstring_new(const char *ptr, long len);
VALUE rb_obj_as_string_result(VALUE str, VALUE obj);
VALUE rb_str_opt_plus(VALUE x, VALUE y);
@@ -78,7 +76,6 @@ VALUE rb_sym_proc_call(ID mid, int argc, const VALUE *argv, int kw_splat, VALUE
struct rb_execution_context_struct;
VALUE rb_ec_str_resurrect(struct rb_execution_context_struct *ec, VALUE str);
-MJIT_SYMBOL_EXPORT_END
#define rb_fstring_lit(str) rb_fstring_new((str), rb_strlen_lit(str))
#define rb_fstring_literal(str) rb_fstring_lit(str)
@@ -121,6 +118,21 @@ is_broken_string(VALUE str)
return rb_enc_str_coderange(str) == ENC_CODERANGE_BROKEN;
}
+static inline bool
+at_char_boundary(const char *s, const char *p, const char *e, rb_encoding *enc)
+{
+ return rb_enc_left_char_head(s, p, e, enc) == p;
+}
+
+static inline bool
+at_char_right_boundary(const char *s, const char *p, const char *e, rb_encoding *enc)
+{
+ RUBY_ASSERT(s <= p);
+ RUBY_ASSERT(p <= e);
+
+ return rb_enc_right_char_head(s, p, e, enc) == p;
+}
+
/* expect tail call optimization */
// YJIT needs this function to never allocate and never raise
static inline VALUE
diff --git a/internal/struct.h b/internal/struct.h
index 5b00e52262..6da5bad10a 100644
--- a/internal/struct.h
+++ b/internal/struct.h
@@ -12,10 +12,9 @@
#include "ruby/ruby.h" /* for struct RBasic */
enum {
- RSTRUCT_EMBED_LEN_MAX = RVALUE_EMBED_LEN_MAX,
- RSTRUCT_EMBED_LEN_MASK = (RUBY_FL_USER2|RUBY_FL_USER1),
+ RSTRUCT_EMBED_LEN_MASK = RUBY_FL_USER7 | RUBY_FL_USER6 | RUBY_FL_USER5 | RUBY_FL_USER4 |
+ RUBY_FL_USER3 | RUBY_FL_USER2 | RUBY_FL_USER1,
RSTRUCT_EMBED_LEN_SHIFT = (RUBY_FL_USHIFT+1),
- RSTRUCT_TRANSIENT_FLAG = FL_USER3,
};
struct RStruct {
@@ -25,7 +24,12 @@ struct RStruct {
long len;
const VALUE *ptr;
} heap;
- const VALUE ary[RSTRUCT_EMBED_LEN_MAX];
+ /* This is a length 1 array because:
+ * 1. GCC has a bug that does not optimize C flexible array members
+ * (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102452)
+ * 2. Zero length arrays are not supported by all compilers
+ */
+ const VALUE ary[1];
} as;
};
@@ -56,9 +60,6 @@ VALUE rb_struct_init_copy(VALUE copy, VALUE s);
VALUE rb_struct_lookup(VALUE s, VALUE idx);
VALUE rb_struct_s_keyword_init(VALUE klass);
static inline const VALUE *rb_struct_const_heap_ptr(VALUE st);
-static inline bool RSTRUCT_TRANSIENT_P(VALUE st);
-static inline void RSTRUCT_TRANSIENT_SET(VALUE st);
-static inline void RSTRUCT_TRANSIENT_UNSET(VALUE st);
static inline long RSTRUCT_EMBED_LEN(VALUE st);
static inline long RSTRUCT_LEN(VALUE st);
static inline int RSTRUCT_LENINT(VALUE st);
@@ -66,32 +67,6 @@ static inline const VALUE *RSTRUCT_CONST_PTR(VALUE st);
static inline void RSTRUCT_SET(VALUE st, long k, VALUE v);
static inline VALUE RSTRUCT_GET(VALUE st, long k);
-static inline bool
-RSTRUCT_TRANSIENT_P(VALUE st)
-{
-#if USE_TRANSIENT_HEAP
- return FL_TEST_RAW(st, RSTRUCT_TRANSIENT_FLAG);
-#else
- return false;
-#endif
-}
-
-static inline void
-RSTRUCT_TRANSIENT_SET(VALUE st)
-{
-#if USE_TRANSIENT_HEAP
- FL_SET_RAW(st, RSTRUCT_TRANSIENT_FLAG);
-#endif
-}
-
-static inline void
-RSTRUCT_TRANSIENT_UNSET(VALUE st)
-{
-#if USE_TRANSIENT_HEAP
- FL_UNSET_RAW(st, RSTRUCT_TRANSIENT_FLAG);
-#endif
-}
-
static inline long
RSTRUCT_EMBED_LEN(VALUE st)
{
@@ -145,7 +120,7 @@ RSTRUCT_GET(VALUE st, long k)
static inline const VALUE *
rb_struct_const_heap_ptr(VALUE st)
{
- /* TODO: check embed on debug mode */
+ assert(!FL_TEST_RAW(st, RSTRUCT_EMBED_LEN_MASK));
return RSTRUCT(st)->as.heap.ptr;
}
diff --git a/internal/symbol.h b/internal/symbol.h
index 30c81ea004..e7730cb70f 100644
--- a/internal/symbol.h
+++ b/internal/symbol.h
@@ -32,6 +32,9 @@ ID rb_make_temporary_id(size_t n);
void rb_gc_free_dsymbol(VALUE);
int rb_static_id_valid_p(ID id);
+/* vm.c */
+void rb_free_static_symid_str(void);
+
#if __has_builtin(__builtin_constant_p)
#define rb_sym_intern_ascii_cstr(ptr) \
(__builtin_constant_p(ptr) ? \
diff --git a/internal/thread.h b/internal/thread.h
index 6394f88d34..cf25975d8b 100644
--- a/internal/thread.h
+++ b/internal/thread.h
@@ -10,9 +10,17 @@
*/
#include "ruby/ruby.h" /* for VALUE */
#include "ruby/intern.h" /* for rb_blocking_function_t */
+#include "ccan/list/list.h" /* for list in rb_io_close_wait_list */
struct rb_thread_struct; /* in vm_core.h */
+#define RB_VM_SAVE_MACHINE_CONTEXT(th) \
+ do { \
+ FLUSH_REGISTER_WINDOWS; \
+ setjmp((th)->ec->machine.regs); \
+ SET_MACHINE_STACK_END(&(th)->ec->machine.stack_end); \
+ } while (0)
+
/* thread.c */
#define COVERAGE_INDEX_LINES 0
#define COVERAGE_INDEX_BRANCHES 1
@@ -22,6 +30,10 @@ struct rb_thread_struct; /* in vm_core.h */
#define COVERAGE_TARGET_ONESHOT_LINES 8
#define COVERAGE_TARGET_EVAL 16
+#define RUBY_FATAL_THREAD_KILLED INT2FIX(0)
+#define RUBY_FATAL_THREAD_TERMINATED INT2FIX(1)
+#define RUBY_FATAL_FIBER_KILLED RB_INT2FIX(2)
+
VALUE rb_obj_is_mutex(VALUE obj);
VALUE rb_suppress_tracing(VALUE (*func)(VALUE), VALUE arg);
void rb_thread_execute_interrupts(VALUE th);
@@ -29,6 +41,7 @@ VALUE rb_get_coverages(void);
int rb_get_coverage_mode(void);
VALUE rb_default_coverage(int);
VALUE rb_thread_shield_new(void);
+bool rb_thread_shield_owned(VALUE self);
VALUE rb_thread_shield_wait(VALUE self);
VALUE rb_thread_shield_release(VALUE self);
VALUE rb_thread_shield_destroy(VALUE self);
@@ -37,19 +50,29 @@ void rb_mutex_allow_trap(VALUE self, int val);
VALUE rb_uninterruptible(VALUE (*b_proc)(VALUE), VALUE data);
VALUE rb_mutex_owned_p(VALUE self);
VALUE rb_exec_recursive_outer_mid(VALUE (*f)(VALUE g, VALUE h, int r), VALUE g, VALUE h, ID mid);
+void ruby_mn_threads_params(void);
int rb_thread_wait_for_single_fd(int fd, int events, struct timeval * timeout);
+struct rb_io_close_wait_list {
+ struct ccan_list_head pending_fd_users;
+ VALUE closing_thread;
+ VALUE wakeup_mutex;
+};
+int rb_notify_fd_close(int fd, struct rb_io_close_wait_list *busy);
+void rb_notify_fd_close_wait(struct rb_io_close_wait_list *busy);
+
RUBY_SYMBOL_EXPORT_BEGIN
+
/* Temporary. This API will be removed (renamed). */
VALUE rb_thread_io_blocking_region(rb_blocking_function_t *func, void *data1, int fd);
+VALUE rb_thread_io_blocking_call(rb_blocking_function_t *func, void *data1, int fd, int events);
/* thread.c (export) */
int ruby_thread_has_gvl_p(void); /* for ext/fiddle/closure.c */
+
RUBY_SYMBOL_EXPORT_END
-MJIT_SYMBOL_EXPORT_BEGIN
int rb_threadptr_execute_interrupts(struct rb_thread_struct *th, int blocking_timing);
-MJIT_SYMBOL_EXPORT_END
#endif /* INTERNAL_THREAD_H */
diff --git a/internal/transcode.h b/internal/transcode.h
index 9922332ea9..ce4f2341be 100644
--- a/internal/transcode.h
+++ b/internal/transcode.h
@@ -17,4 +17,7 @@
extern VALUE rb_cEncodingConverter;
size_t rb_econv_memsize(rb_econv_t *);
+/* vm.c */
+void rb_free_transcoder_table(void);
+
#endif /* INTERNAL_TRANSCODE_H */
diff --git a/internal/variable.h b/internal/variable.h
index 88fa28e1ba..b2a30c7c58 100644
--- a/internal/variable.h
+++ b/internal/variable.h
@@ -15,10 +15,6 @@
#include "ruby/ruby.h" /* for VALUE */
#include "shape.h" /* for rb_shape_t */
-/* global variable */
-
-#define ROBJECT_TRANSIENT_FLAG FL_USER2
-
/* variable.c */
void rb_gc_mark_global_tbl(void);
void rb_gc_update_global_tbl(void);
@@ -32,59 +28,45 @@ rb_gvar_getter_t *rb_gvar_getter_function_of(ID);
rb_gvar_setter_t *rb_gvar_setter_function_of(ID);
void rb_gvar_readonly_setter(VALUE v, ID id, VALUE *_);
void rb_gvar_ractor_local(const char *name);
-static inline bool ROBJ_TRANSIENT_P(VALUE obj);
-static inline void ROBJ_TRANSIENT_SET(VALUE obj);
-static inline void ROBJ_TRANSIENT_UNSET(VALUE obj);
+
+/**
+ * Sets the name of a module.
+ *
+ * Non-permanently named classes can have a temporary name assigned (or
+ * cleared). In that case the name will be used for `#inspect` and `#to_s`, and
+ * nested classes/modules will be named with the temporary name as a prefix.
+ *
+ * After the module is assigned to a constant, the temporary name will be
+ * discarded, and the name will be computed based on the nesting.
+ *
+ * @param[in] mod An instance of ::rb_cModule.
+ * @param[in] name An instance of ::rb_cString.
+ * @retval mod
+ */
+VALUE rb_mod_set_temporary_name(VALUE, VALUE);
struct gen_ivtbl;
int rb_gen_ivtbl_get(VALUE obj, ID id, struct gen_ivtbl **ivtbl);
-int rb_obj_evacuate_ivs_to_hash_table(ID key, VALUE val, st_data_t arg);
+void rb_obj_copy_ivs_to_hash_table(VALUE obj, st_table *table);
+void rb_obj_convert_to_too_complex(VALUE obj, st_table *table);
+void rb_evict_ivars_to_hash(VALUE obj);
RUBY_SYMBOL_EXPORT_BEGIN
/* variable.c (export) */
-void rb_mark_and_update_generic_ivar(VALUE);
+void rb_mark_generic_ivar(VALUE obj);
+void rb_ref_update_generic_ivar(VALUE);
void rb_mv_generic_ivar(VALUE src, VALUE dst);
VALUE rb_const_missing(VALUE klass, VALUE name);
int rb_class_ivar_set(VALUE klass, ID vid, VALUE value);
void rb_iv_tbl_copy(VALUE dst, VALUE src);
RUBY_SYMBOL_EXPORT_END
-MJIT_SYMBOL_EXPORT_BEGIN
VALUE rb_ivar_lookup(VALUE obj, ID id, VALUE undef);
VALUE rb_gvar_get(ID);
VALUE rb_gvar_set(ID, VALUE);
VALUE rb_gvar_defined(ID);
void rb_const_warn_if_deprecated(const rb_const_entry_t *, VALUE, ID);
-rb_shape_t * rb_grow_iv_list(VALUE obj);
void rb_ensure_iv_list_size(VALUE obj, uint32_t len, uint32_t newsize);
-struct gen_ivtbl * rb_ensure_generic_iv_list_size(VALUE obj, uint32_t newsize);
attr_index_t rb_obj_ivar_set(VALUE obj, ID id, VALUE val);
-MJIT_SYMBOL_EXPORT_END
-
-static inline bool
-ROBJ_TRANSIENT_P(VALUE obj)
-{
-#if USE_TRANSIENT_HEAP
- return FL_TEST_RAW(obj, ROBJECT_TRANSIENT_FLAG);
-#else
- return false;
-#endif
-}
-
-static inline void
-ROBJ_TRANSIENT_SET(VALUE obj)
-{
-#if USE_TRANSIENT_HEAP
- FL_SET_RAW(obj, ROBJECT_TRANSIENT_FLAG);
-#endif
-}
-
-static inline void
-ROBJ_TRANSIENT_UNSET(VALUE obj)
-{
-#if USE_TRANSIENT_HEAP
- FL_UNSET_RAW(obj, ROBJECT_TRANSIENT_FLAG);
-#endif
-}
#endif /* INTERNAL_VARIABLE_H */
diff --git a/internal/vm.h b/internal/vm.h
index cf245c6579..a32a14e045 100644
--- a/internal/vm.h
+++ b/internal/vm.h
@@ -50,17 +50,15 @@ PUREFUNC(VALUE rb_vm_top_self(void));
const void **rb_vm_get_insns_address_table(void);
VALUE rb_source_location(int *pline);
const char *rb_source_location_cstr(int *pline);
-MJIT_STATIC void rb_vm_pop_cfunc_frame(void);
+void rb_vm_pop_cfunc_frame(void);
int rb_vm_add_root_module(VALUE module);
void rb_vm_check_redefinition_by_prepend(VALUE klass);
int rb_vm_check_optimizable_mid(VALUE mid);
VALUE rb_yield_refine_block(VALUE refinement, VALUE refinements);
-MJIT_STATIC VALUE ruby_vm_special_exception_copy(VALUE);
+VALUE ruby_vm_special_exception_copy(VALUE);
PUREFUNC(st_table *rb_vm_fstring_table(void));
-MJIT_SYMBOL_EXPORT_BEGIN
-VALUE vm_exec(struct rb_execution_context_struct *, bool); /* used in JIT-ed code */
-MJIT_SYMBOL_EXPORT_END
+void rb_lastline_set_up(VALUE val, unsigned int up);
/* vm_eval.c */
VALUE rb_current_realfilepath(void);
@@ -80,25 +78,31 @@ VALUE rb_lambda_call(VALUE obj, ID mid, int argc, const VALUE *argv,
VALUE data2);
void rb_check_stack_overflow(void);
+#if USE_YJIT
+/* vm_exec.c */
+extern uint64_t rb_vm_insns_count;
+#endif
+
+extern bool rb_free_at_exit;
+
+/* miniinit.c and builtin.c */
+void rb_free_loaded_builtin_table(void);
+
/* vm_insnhelper.c */
VALUE rb_equal_opt(VALUE obj1, VALUE obj2);
VALUE rb_eql_opt(VALUE obj1, VALUE obj2);
struct rb_iseq_struct;
-MJIT_SYMBOL_EXPORT_BEGIN
const struct rb_callcache *rb_vm_search_method_slowpath(const struct rb_callinfo *ci, VALUE klass);
-MJIT_SYMBOL_EXPORT_END
/* vm_method.c */
struct rb_execution_context_struct;
-MJIT_SYMBOL_EXPORT_BEGIN
int rb_ec_obj_respond_to(struct rb_execution_context_struct *ec, VALUE obj, ID id, int priv);
-MJIT_SYMBOL_EXPORT_END
void rb_clear_constant_cache(void);
/* vm_dump.c */
-void rb_print_backtrace(void);
+void rb_print_backtrace(FILE *);
/* vm_backtrace.c */
VALUE rb_vm_thread_backtrace(int argc, const VALUE *argv, VALUE thval);
@@ -106,7 +110,7 @@ VALUE rb_vm_thread_backtrace_locations(int argc, const VALUE *argv, VALUE thval)
VALUE rb_vm_backtrace(int argc, const VALUE * argv, struct rb_execution_context_struct * ec);
VALUE rb_vm_backtrace_locations(int argc, const VALUE * argv, struct rb_execution_context_struct * ec);
VALUE rb_make_backtrace(void);
-void rb_backtrace_print_as_bugreport(void);
+void rb_backtrace_print_as_bugreport(FILE*);
int rb_backtrace_p(VALUE obj);
VALUE rb_backtrace_to_str_ary(VALUE obj);
VALUE rb_backtrace_to_location_ary(VALUE obj);
@@ -115,10 +119,8 @@ int rb_frame_info_p(VALUE obj);
int rb_get_node_id_from_frame_info(VALUE obj);
const struct rb_iseq_struct *rb_get_iseq_from_frame_info(VALUE obj);
-MJIT_SYMBOL_EXPORT_BEGIN
VALUE rb_ec_backtrace_object(const struct rb_execution_context_struct *ec);
void rb_backtrace_use_iseq_first_lineno_for_last_location(VALUE self);
-MJIT_SYMBOL_EXPORT_END
#define RUBY_DTRACE_CREATE_HOOK(name, arg) \
RUBY_DTRACE_HOOK(name##_CREATE, arg)
diff --git a/io.c b/io.c
index dbcfcf3fc0..ca2cb904ee 100644
--- a/io.c
+++ b/io.c
@@ -16,11 +16,6 @@
#include "ruby/fiber/scheduler.h"
#include "ruby/io/buffer.h"
-#ifdef _WIN32
-# include "ruby/ruby.h"
-# include "ruby/io.h"
-#endif
-
#include <ctype.h>
#include <errno.h>
#include <stddef.h>
@@ -175,6 +170,7 @@ off_t __syscall(quad_t number, ...);
#define open rb_w32_uopen
#undef rename
#define rename(f, t) rb_w32_urename((f), (t))
+#include "win32/file.h"
#endif
VALUE rb_cIO;
@@ -221,7 +217,7 @@ struct argf {
long lineno;
VALUE argv;
VALUE inplace;
- struct rb_io_enc_t encs;
+ struct rb_io_encoding encs;
int8_t init_p, next_p, binmode;
};
@@ -525,7 +521,6 @@ rb_cloexec_fcntl_dupfd(int fd, int minfd)
static int io_fflush(rb_io_t *);
static rb_io_t *flush_before_seek(rb_io_t *fptr);
-#define FMODE_PREP (1<<16)
#define FMODE_SIGNAL_ON_EPIPE (1<<17)
#define fptr_signal_on_epipe(fptr) \
@@ -852,9 +847,12 @@ rb_io_timeout(VALUE self)
* timeout = duration -> duration
* timeout = nil -> nil
*
- * Set the internal timeout to the specified duration or nil. The timeout
+ * Sets the internal timeout to the specified duration or nil. The timeout
* applies to all blocking operations where possible.
*
+ * When the operation performs longer than the timeout set, IO::TimeoutError
+ * is raised.
+ *
* This affects the following methods (but is not limited to): #gets, #puts,
* #read, #write, #wait_readable and #wait_writable. This also affects
* blocking socket operations like Socket#accept and Socket#connect.
@@ -1066,20 +1064,24 @@ rb_gc_for_fd(int err)
return 0;
}
+/* try `expr` upto twice while it returns false and `errno`
+ * is to GC. Each `errno`s are available as `first_errno` and
+ * `retried_errno` respectively */
+#define TRY_WITH_GC(expr) \
+ for (int first_errno, retried_errno = 0, retried = 0; \
+ (!retried && \
+ !(expr) && \
+ (!rb_gc_for_fd(first_errno = errno) || !(expr)) && \
+ (retried_errno = errno, 1)); \
+ (void)retried_errno, retried = 1)
+
static int
ruby_dup(int orig)
{
- int fd;
+ int fd = -1;
- fd = rb_cloexec_dup(orig);
- if (fd < 0) {
- int e = errno;
- if (rb_gc_for_fd(e)) {
- fd = rb_cloexec_dup(orig);
- }
- if (fd < 0) {
- rb_syserr_fail(e, 0);
- }
+ TRY_WITH_GC((fd = rb_cloexec_dup(orig)) >= 0) {
+ rb_syserr_fail(first_errno, 0);
}
rb_update_max_fd(fd);
return fd;
@@ -1088,7 +1090,7 @@ ruby_dup(int orig)
static VALUE
io_alloc(VALUE klass)
{
- NEWOBJ_OF(io, struct RFile, klass, T_FILE);
+ NEWOBJ_OF(io, struct RFile, klass, T_FILE, sizeof(struct RFile), 0);
io->fptr = 0;
@@ -1148,7 +1150,8 @@ io_internal_wait(VALUE thread, rb_io_t *fptr, int error, int events, struct time
if (ready > 0) {
return ready;
- } else if (ready == 0) {
+ }
+ else if (ready == 0) {
errno = ETIMEDOUT;
return -1;
}
@@ -1176,7 +1179,8 @@ internal_read_func(void *ptr)
if (io_again_p(errno)) {
if (io_internal_wait(iis->th, iis->fptr, errno, RB_WAITFD_IN, iis->timeout) == -1) {
return -1;
- } else {
+ }
+ else {
goto retry;
}
}
@@ -1211,7 +1215,8 @@ internal_write_func(void *ptr)
if (io_again_p(e)) {
if (io_internal_wait(iis->th, iis->fptr, errno, RB_WAITFD_OUT, iis->timeout) == -1) {
return -1;
- } else {
+ }
+ else {
goto retry;
}
}
@@ -1240,7 +1245,8 @@ internal_writev_func(void *ptr)
if (io_again_p(errno)) {
if (io_internal_wait(iis->th, iis->fptr, errno, RB_WAITFD_OUT, iis->timeout) == -1) {
return -1;
- } else {
+ }
+ else {
goto retry;
}
}
@@ -1280,7 +1286,7 @@ rb_io_read_memory(rb_io_t *fptr, void *buf, size_t count)
iis.timeout = &timeout_storage;
}
- return (ssize_t)rb_thread_io_blocking_region(internal_read_func, &iis, fptr->fd);
+ return (ssize_t)rb_thread_io_blocking_call(internal_read_func, &iis, fptr->fd, RB_WAITFD_IN);
}
static ssize_t
@@ -1313,21 +1319,22 @@ rb_io_write_memory(rb_io_t *fptr, const void *buf, size_t count)
iis.timeout = &timeout_storage;
}
- return (ssize_t)rb_thread_io_blocking_region(internal_write_func, &iis, fptr->fd);
+ return (ssize_t)rb_thread_io_blocking_call(internal_write_func, &iis, fptr->fd, RB_WAITFD_OUT);
}
#ifdef HAVE_WRITEV
static ssize_t
rb_writev_internal(rb_io_t *fptr, const struct iovec *iov, int iovcnt)
{
+ if (!iovcnt) return 0;
+
VALUE scheduler = rb_fiber_scheduler_current();
if (scheduler != Qnil) {
- for (int i = 0; i < iovcnt; i += 1) {
- VALUE result = rb_fiber_scheduler_io_write_memory(scheduler, fptr->self, iov[i].iov_base, iov[i].iov_len, 0);
+ // This path assumes at least one `iov`:
+ VALUE result = rb_fiber_scheduler_io_write_memory(scheduler, fptr->self, iov[0].iov_base, iov[0].iov_len, 0);
- if (!UNDEF_P(result)) {
- return rb_fiber_scheduler_io_result_apply(result);
- }
+ if (!UNDEF_P(result)) {
+ return rb_fiber_scheduler_io_result_apply(result);
}
}
@@ -1349,7 +1356,7 @@ rb_writev_internal(rb_io_t *fptr, const struct iovec *iov, int iovcnt)
iis.timeout = &timeout_storage;
}
- return (ssize_t)rb_thread_io_blocking_region(internal_writev_func, &iis, fptr->fd);
+ return (ssize_t)rb_thread_io_blocking_call(internal_writev_func, &iis, fptr->fd, RB_WAITFD_OUT);
}
#endif
@@ -1379,7 +1386,7 @@ static VALUE
io_flush_buffer_async(VALUE arg)
{
rb_io_t *fptr = (rb_io_t *)arg;
- return rb_thread_io_blocking_region(io_flush_buffer_sync, fptr, fptr->fd);
+ return rb_thread_io_blocking_call(io_flush_buffer_sync, fptr, fptr->fd, RB_WAITFD_OUT);
}
static inline int
@@ -1455,7 +1462,7 @@ rb_io_wait(VALUE io, VALUE events, VALUE timeout)
static VALUE
io_from_fd(int fd)
{
- return prep_io(fd, FMODE_PREP, rb_cIO, NULL);
+ return prep_io(fd, FMODE_EXTERNAL, rb_cIO, NULL);
}
static int
@@ -1788,13 +1795,11 @@ io_binwrite_string(VALUE arg)
// Write as much as possible:
ssize_t result = io_binwrite_string_internal(p->fptr, ptr, remaining);
- // If only the internal buffer is written, result will be zero [bytes of given data written]. This means we
- // should try again.
if (result == 0) {
- errno = EWOULDBLOCK;
+ // If only the internal buffer is written, result will be zero [bytes of given data written]. This means we
+ // should try again immediately.
}
-
- if (result > 0) {
+ else if (result > 0) {
if ((size_t)result == remaining) break;
ptr += result;
remaining -= result;
@@ -1831,7 +1836,7 @@ io_allocate_write_buffer(rb_io_t *fptr, int sync)
static inline int
io_binwrite_requires_flush_write(rb_io_t *fptr, long len, int nosync)
{
- // If the requested operation was synchronous and the output mode is synchronus or a TTY:
+ // If the requested operation was synchronous and the output mode is synchronous or a TTY:
if (!nosync && (fptr->mode & (FMODE_SYNC|FMODE_TTY)))
return 1;
@@ -2034,7 +2039,7 @@ io_binwritev_internal(VALUE arg)
while (remaining) {
long result = rb_writev_internal(fptr, iov, iovcnt);
- if (result > 0) {
+ if (result >= 0) {
offset += result;
if (fptr->wbuf.ptr && fptr->wbuf.len) {
if (offset < (size_t)fptr->wbuf.len) {
@@ -2384,9 +2389,6 @@ rb_io_flush(VALUE io)
* f.close
*
* Related: IO#pos=, IO#seek.
- *
- * IO#pos is an alias for IO#tell.
- *
*/
static VALUE
@@ -2654,9 +2656,6 @@ io_fillbuf(rb_io_t *fptr)
* Note that this method reads data to the input byte buffer. So
* IO#sysread may not behave as you intend with IO#eof?, unless you
* call IO#rewind first (which is not available for some streams).
- *
- * IO#eof? is an alias for IO#eof.
- *
*/
VALUE
@@ -2847,8 +2846,6 @@ rb_io_fdatasync(VALUE io)
* File.open('t.txt').fileno # => 10
* f.close
*
- * IO#to_i is an alias for IO#fileno.
- *
*/
static VALUE
@@ -2871,8 +2868,23 @@ rb_io_descriptor(VALUE io)
return fptr->fd;
}
else {
- return RB_NUM2INT(rb_funcall(io, id_fileno, 0));
+ VALUE fileno = rb_check_funcall(io, id_fileno, 0, NULL);
+ if (!UNDEF_P(fileno)) {
+ return RB_NUM2INT(fileno);
+ }
}
+
+ rb_raise(rb_eTypeError, "expected IO or #fileno, %"PRIsVALUE" given", rb_obj_class(io));
+
+ UNREACHABLE_RETURN(-1);
+}
+
+int
+rb_io_mode(VALUE io)
+{
+ rb_io_t *fptr;
+ GetOpenFile(io, fptr);
+ return fptr->mode;
}
/*
@@ -2921,7 +2933,7 @@ rb_io_pid(VALUE io)
* File.open("testfile") {|f| f.path} # => "testfile"
*/
-static VALUE
+VALUE
rb_io_path(VALUE io)
{
rb_io_t *fptr = RFILE(io)->fptr;
@@ -3262,9 +3274,10 @@ io_setstrbuf(VALUE *str, long len)
}
else {
VALUE s = StringValue(*str);
+ rb_str_modify(s);
+
long clen = RSTRING_LEN(s);
if (clen >= len) {
- rb_str_modify(s);
return FALSE;
}
len -= clen;
@@ -3395,7 +3408,12 @@ io_read_memory_call(VALUE arg)
}
}
- return rb_thread_io_blocking_region(internal_read_func, iis, iis->fptr->fd);
+ if (iis->nonblock) {
+ return rb_thread_io_blocking_call(internal_read_func, iis, iis->fptr->fd, 0);
+ }
+ else {
+ return rb_thread_io_blocking_call(internal_read_func, iis, iis->fptr->fd, RB_WAITFD_IN);
+ }
}
static long
@@ -4138,8 +4156,7 @@ rb_io_getline_0(VALUE rs, long limit, int chomp, rb_io_t *fptr)
s = RSTRING_PTR(str);
e = RSTRING_END(str);
p = e - rslen;
- pp = rb_enc_left_char_head(s, p, e, enc);
- if (pp != p) continue;
+ if (!at_char_boundary(s, p, e, enc)) continue;
if (!rspara) rscheck(rsptr, rslen, rs);
if (memcmp(p, rsptr, rslen) == 0) {
if (chomp) {
@@ -4351,22 +4368,28 @@ rb_io_set_lineno(VALUE io, VALUE lineno)
return lineno;
}
-/*
- * call-seq:
- * readline(sep = $/, chomp: false) -> string
- * readline(limit, chomp: false) -> string
- * readline(sep, limit, chomp: false) -> string
- *
- * Reads a line as with IO#gets, but raises EOFError if already at end-of-stream.
- *
- * Optional keyword argument +chomp+ specifies whether line separators
- * are to be omitted.
- */
-
+/* :nodoc: */
static VALUE
-rb_io_readline(int argc, VALUE *argv, VALUE io)
+io_readline(rb_execution_context_t *ec, VALUE io, VALUE sep, VALUE lim, VALUE chomp)
{
- VALUE line = rb_io_gets_m(argc, argv, io);
+ if (NIL_P(lim)) {
+ // If sep is specified, but it's not a string and not nil, then assume
+ // it's the limit (it should be an integer)
+ if (!NIL_P(sep) && NIL_P(rb_check_string_type(sep))) {
+ // If the user has specified a non-nil / non-string value
+ // for the separator, we assume it's the limit and set the
+ // separator to default: rb_rs.
+ lim = sep;
+ sep = rb_rs;
+ }
+ }
+
+ if (!NIL_P(sep)) {
+ StringValue(sep);
+ }
+
+ VALUE line = rb_io_getline_1(sep, NIL_P(lim) ? -1L : NUM2LONG(lim), RTEST(chomp), io);
+ rb_lastline_set_up(line, 1);
if (NIL_P(line)) {
rb_eof_error();
@@ -4571,9 +4594,6 @@ io_readlines(const struct getline_arg *arg, VALUE io)
* "Fifth line"
*
* Returns an Enumerator if no block is given.
- *
- * IO#each is an alias for IO#each_line.
- *
*/
static VALUE
@@ -5197,8 +5217,6 @@ rb_io_ungetc(VALUE io, VALUE c)
* f = File.new('/dev/tty').isatty #=> true
* f.close
*
- * IO#tty? is an alias for IO#isatty.
- *
*/
static VALUE
@@ -5259,7 +5277,7 @@ rb_io_close_on_exec_p(VALUE io)
*
* Sets a close-on-exec flag.
*
- * f = open("/dev/null")
+ * f = File.open(File::NULL)
* f.close_on_exec = true
* system("cat", "/proc/self/fd/#{f.fileno}") # cat: /proc/self/fd/3: No such file or directory
* f.closed? #=> false
@@ -5310,7 +5328,7 @@ rb_io_set_close_on_exec(VALUE io, VALUE arg)
#define rb_io_set_close_on_exec rb_f_notimplement
#endif
-#define IS_PREP_STDIO(f) ((f)->mode & FMODE_PREP)
+#define RUBY_IO_EXTERNAL_P(f) ((f)->mode & FMODE_EXTERNAL)
#define PREP_STDIO_NAME(f) (RSTRING_PTR((f)->pathv))
static VALUE
@@ -5429,7 +5447,7 @@ static void clear_codeconv(rb_io_t *fptr);
static void
fptr_finalize_flush(rb_io_t *fptr, int noraise, int keepgvl,
- struct ccan_list_head *busy)
+ struct rb_io_close_wait_list *busy)
{
VALUE error = Qnil;
int fd = fptr->fd;
@@ -5460,7 +5478,7 @@ fptr_finalize_flush(rb_io_t *fptr, int noraise, int keepgvl,
int done = 0;
- if (IS_PREP_STDIO(fptr) || fd <= 2) {
+ if (RUBY_IO_EXTERNAL_P(fptr) || fd <= 2) {
// Need to keep FILE objects of stdin, stdout and stderr, so we are done:
done = 1;
}
@@ -5472,7 +5490,7 @@ fptr_finalize_flush(rb_io_t *fptr, int noraise, int keepgvl,
// Ensure waiting_fd users do not hit EBADF.
if (busy) {
// Wait for them to exit before we call close().
- do rb_thread_schedule(); while (!ccan_list_empty(busy));
+ rb_notify_fd_close_wait(busy);
}
// Disable for now.
@@ -5574,12 +5592,9 @@ clear_codeconv(rb_io_t *fptr)
clear_writeconv(fptr);
}
-void
-rb_io_fptr_finalize_internal(void *ptr)
+static void
+rb_io_fptr_cleanup_all(rb_io_t *fptr)
{
- rb_io_t *fptr = ptr;
-
- if (!ptr) return;
fptr->pathv = Qnil;
if (0 <= fptr->fd)
rb_io_fptr_cleanup(fptr, TRUE);
@@ -5587,7 +5602,14 @@ rb_io_fptr_finalize_internal(void *ptr)
free_io_buffer(&fptr->rbuf);
free_io_buffer(&fptr->wbuf);
clear_codeconv(fptr);
- free(fptr);
+}
+
+void
+rb_io_fptr_finalize_internal(void *ptr)
+{
+ if (!ptr) return;
+ rb_io_fptr_cleanup_all(ptr);
+ free(ptr);
}
#undef rb_io_fptr_finalize
@@ -5623,16 +5645,14 @@ rb_io_memsize(const rb_io_t *fptr)
# define KEEPGVL FALSE
#endif
-int rb_notify_fd_close(int fd, struct ccan_list_head *);
static rb_io_t *
io_close_fptr(VALUE io)
{
rb_io_t *fptr;
VALUE write_io;
rb_io_t *write_fptr;
- struct ccan_list_head busy;
+ struct rb_io_close_wait_list busy;
- ccan_list_head_init(&busy);
write_io = GetWriteIO(io);
if (io != write_io) {
write_fptr = RFILE(write_io)->fptr;
@@ -5769,10 +5789,8 @@ io_close(VALUE io)
*
* Related: IO#close_read, IO#close_write, IO#close.
*/
-
-
-static VALUE
-rb_io_closed(VALUE io)
+VALUE
+rb_io_closed_p(VALUE io)
{
rb_io_t *fptr;
VALUE write_io;
@@ -6070,28 +6088,37 @@ rb_io_sysread(int argc, VALUE *argv, VALUE io)
return str;
}
-#if defined(HAVE_PREAD) || defined(HAVE_PWRITE)
struct prdwr_internal_arg {
+ VALUE io;
int fd;
void *buf;
size_t count;
rb_off_t offset;
};
-#endif /* HAVE_PREAD || HAVE_PWRITE */
-#if defined(HAVE_PREAD)
static VALUE
-internal_pread_func(void *arg)
+internal_pread_func(void *_arg)
{
- struct prdwr_internal_arg *p = arg;
- return (VALUE)pread(p->fd, p->buf, p->count, p->offset);
+ struct prdwr_internal_arg *arg = _arg;
+
+ return (VALUE)pread(arg->fd, arg->buf, arg->count, arg->offset);
}
static VALUE
-pread_internal_call(VALUE arg)
+pread_internal_call(VALUE _arg)
{
- struct prdwr_internal_arg *p = (struct prdwr_internal_arg *)arg;
- return rb_thread_io_blocking_region(internal_pread_func, p, p->fd);
+ struct prdwr_internal_arg *arg = (struct prdwr_internal_arg *)_arg;
+
+ VALUE scheduler = rb_fiber_scheduler_current();
+ if (scheduler != Qnil) {
+ VALUE result = rb_fiber_scheduler_io_pread_memory(scheduler, arg->io, arg->offset, arg->buf, arg->count, 0);
+
+ if (!UNDEF_P(result)) {
+ return rb_fiber_scheduler_io_result_apply(result);
+ }
+ }
+
+ return rb_thread_io_blocking_call(internal_pread_func, arg, arg->fd, RB_WAITFD_IN);
}
/*
@@ -6128,7 +6155,7 @@ rb_io_pread(int argc, VALUE *argv, VALUE io)
VALUE len, offset, str;
rb_io_t *fptr;
ssize_t n;
- struct prdwr_internal_arg arg;
+ struct prdwr_internal_arg arg = {.io = io};
int shrinkable;
rb_scan_args(argc, argv, "21", &len, &offset, &str);
@@ -6158,15 +6185,21 @@ rb_io_pread(int argc, VALUE *argv, VALUE io)
return str;
}
-#else
-# define rb_io_pread rb_f_notimplement
-#endif /* HAVE_PREAD */
-#if defined(HAVE_PWRITE)
static VALUE
-internal_pwrite_func(void *ptr)
+internal_pwrite_func(void *_arg)
{
- struct prdwr_internal_arg *arg = ptr;
+ struct prdwr_internal_arg *arg = _arg;
+
+ VALUE scheduler = rb_fiber_scheduler_current();
+ if (scheduler != Qnil) {
+ VALUE result = rb_fiber_scheduler_io_pwrite_memory(scheduler, arg->io, arg->offset, arg->buf, arg->count, 0);
+
+ if (!UNDEF_P(result)) {
+ return rb_fiber_scheduler_io_result_apply(result);
+ }
+ }
+
return (VALUE)pwrite(arg->fd, arg->buf, arg->count, arg->offset);
}
@@ -6201,7 +6234,7 @@ rb_io_pwrite(VALUE io, VALUE str, VALUE offset)
{
rb_io_t *fptr;
ssize_t n;
- struct prdwr_internal_arg arg;
+ struct prdwr_internal_arg arg = {.io = io};
VALUE tmp;
if (!RB_TYPE_P(str, T_STRING))
@@ -6218,15 +6251,12 @@ rb_io_pwrite(VALUE io, VALUE str, VALUE offset)
arg.buf = RSTRING_PTR(tmp);
arg.count = (size_t)RSTRING_LEN(tmp);
- n = (ssize_t)rb_thread_io_blocking_region(internal_pwrite_func, &arg, fptr->fd);
+ n = (ssize_t)rb_thread_io_blocking_call(internal_pwrite_func, &arg, fptr->fd, RB_WAITFD_OUT);
if (n < 0) rb_sys_fail_path(fptr->pathv);
rb_str_tmp_frozen_release(str, tmp);
return SSIZET2NUM(n);
}
-#else
-# define rb_io_pwrite rb_f_notimplement
-#endif /* HAVE_PWRITE */
VALUE
rb_io_binmode(VALUE io)
@@ -6711,8 +6741,6 @@ rb_io_extract_encoding_option(VALUE opt, rb_encoding **enc_p, rb_encoding **enc2
return extracted;
}
-typedef struct rb_io_enc_t convconfig_t;
-
static void
validate_enc_binmode(int *fmode_p, int ecflags, rb_encoding *enc, rb_encoding *enc2)
{
@@ -6771,7 +6799,7 @@ extract_binmode(VALUE opthash, int *fmode)
void
rb_io_extract_modeenc(VALUE *vmode_p, VALUE *vperm_p, VALUE opthash,
- int *oflags_p, int *fmode_p, convconfig_t *convconfig_p)
+ int *oflags_p, int *fmode_p, struct rb_io_encoding *convconfig_p)
{
VALUE vmode;
int oflags, fmode;
@@ -6942,7 +6970,7 @@ rb_sysopen_internal(struct sysopen_struct *data)
static int
rb_sysopen(VALUE fname, int oflags, mode_t perm)
{
- int fd;
+ int fd = -1;
struct sysopen_struct data;
data.fname = rb_str_encode_ospath(fname);
@@ -6950,21 +6978,14 @@ rb_sysopen(VALUE fname, int oflags, mode_t perm)
data.oflags = oflags;
data.perm = perm;
- fd = rb_sysopen_internal(&data);
- if (fd < 0) {
- int e = errno;
- if (rb_gc_for_fd(e)) {
- fd = rb_sysopen_internal(&data);
- }
- if (fd < 0) {
- rb_syserr_fail_path(e, fname);
- }
+ TRY_WITH_GC((fd = rb_sysopen_internal(&data)) >= 0) {
+ rb_syserr_fail_path(first_errno, fname);
}
return fd;
}
-FILE *
-rb_fdopen(int fd, const char *modestr)
+static inline FILE *
+fdopen_internal(int fd, const char *modestr)
{
FILE *file;
@@ -6973,26 +6994,22 @@ rb_fdopen(int fd, const char *modestr)
#endif
file = fdopen(fd, modestr);
if (!file) {
- int e = errno;
-#if defined(__sun)
- if (e == 0) {
- rb_gc();
- errno = 0;
- file = fdopen(fd, modestr);
- }
- else
-#endif
- if (rb_gc_for_fd(e)) {
- file = fdopen(fd, modestr);
- }
- if (!file) {
#ifdef _WIN32
- if (e == 0) e = EINVAL;
+ if (errno == 0) errno = EINVAL;
#elif defined(__sun)
- if (e == 0) e = EMFILE;
+ if (errno == 0) errno = EMFILE;
#endif
- rb_syserr_fail(e, 0);
- }
+ }
+ return file;
+}
+
+FILE *
+rb_fdopen(int fd, const char *modestr)
+{
+ FILE *file = 0;
+
+ TRY_WITH_GC((file = fdopen_internal(fd, modestr)) != 0) {
+ rb_syserr_fail(first_errno, 0);
}
/* xxx: should be _IONBF? A buffer in FILE may have trouble. */
@@ -7099,11 +7116,11 @@ io_set_encoding_by_bom(VALUE io)
static VALUE
rb_file_open_generic(VALUE io, VALUE filename, int oflags, int fmode,
- const convconfig_t *convconfig, mode_t perm)
+ const struct rb_io_encoding *convconfig, mode_t perm)
{
VALUE pathv;
rb_io_t *fptr;
- convconfig_t cc;
+ struct rb_io_encoding cc;
if (!convconfig) {
/* Set to default encodings */
rb_io_ext_int_to_encs(NULL, NULL, &cc.enc, &cc.enc2, fmode);
@@ -7137,7 +7154,7 @@ rb_file_open_internal(VALUE io, VALUE filename, const char *modestr)
{
int fmode = rb_io_modestr_fmode(modestr);
const char *p = strchr(modestr, ':');
- convconfig_t convconfig;
+ struct rb_io_encoding convconfig;
if (p) {
parse_mode_enc(p+1, rb_usascii_encoding(),
@@ -7245,7 +7262,7 @@ static void
fptr_copy_finalizer(rb_io_t *fptr, const rb_io_t *orig)
{
#if defined(__CYGWIN__) || !defined(HAVE_WORKING_FORK)
- void (*const old_finalize)(struct rb_io_t*,int) = fptr->finalize;
+ void (*const old_finalize)(struct rb_io*,int) = fptr->finalize;
if (old_finalize == orig->finalize) return;
#endif
@@ -7283,12 +7300,7 @@ int
rb_pipe(int *pipes)
{
int ret;
- ret = rb_cloexec_pipe(pipes);
- if (ret < 0) {
- if (rb_gc_for_fd(errno)) {
- ret = rb_cloexec_pipe(pipes);
- }
- }
+ TRY_WITH_GC((ret = rb_cloexec_pipe(pipes)) >= 0);
if (ret == 0) {
rb_update_max_fd(pipes[0]);
rb_update_max_fd(pipes[1]);
@@ -7450,7 +7462,7 @@ char *rb_execarg_commandline(const struct rb_execarg *eargp, VALUE *prog);
#ifndef __EMSCRIPTEN__
static VALUE
pipe_open(VALUE execarg_obj, const char *modestr, int fmode,
- const convconfig_t *convconfig)
+ const struct rb_io_encoding *convconfig)
{
struct rb_execarg *eargp = NIL_P(execarg_obj) ? NULL : rb_execarg_get(execarg_obj);
VALUE prog = eargp ? (eargp->use_shell ? eargp->invoke.sh.shell_script : eargp->invoke.cmd.command_name) : Qfalse ;
@@ -7679,7 +7691,7 @@ pipe_open(VALUE execarg_obj, const char *modestr, int fmode,
#else
static VALUE
pipe_open(VALUE execarg_obj, const char *modestr, int fmode,
- const convconfig_t *convconfig)
+ const struct rb_io_encoding *convconfig)
{
rb_raise(rb_eNotImpError, "popen() is not available");
}
@@ -7701,7 +7713,7 @@ is_popen_fork(VALUE prog)
static VALUE
pipe_open_s(VALUE prog, const char *modestr, int fmode,
- const convconfig_t *convconfig)
+ const struct rb_io_encoding *convconfig)
{
int argc = 1;
VALUE *argv = &prog;
@@ -7910,7 +7922,7 @@ rb_io_popen(VALUE pname, VALUE pmode, VALUE env, VALUE opt)
const char *modestr;
VALUE tmp, execarg_obj = Qnil;
int oflags, fmode;
- convconfig_t convconfig;
+ struct rb_io_encoding convconfig;
tmp = rb_check_array_type(pname);
if (!NIL_P(tmp)) {
@@ -7961,10 +7973,64 @@ popen_finish(VALUE port, VALUE klass)
return port;
}
+#if defined(HAVE_WORKING_FORK) && !defined(__EMSCRIPTEN__)
+struct popen_writer_arg {
+ char *const *argv;
+ struct popen_arg popen;
+};
+
+static int
+exec_popen_writer(void *arg, char *errmsg, size_t buflen)
+{
+ struct popen_writer_arg *pw = arg;
+ pw->popen.modef = FMODE_WRITABLE;
+ popen_redirect(&pw->popen);
+ execv(pw->argv[0], pw->argv);
+ strlcpy(errmsg, strerror(errno), buflen);
+ return -1;
+}
+#endif
+
+FILE *
+ruby_popen_writer(char *const *argv, rb_pid_t *pid)
+{
+#if (defined(HAVE_WORKING_FORK) && !defined(__EMSCRIPTEN__)) || defined(_WIN32)
+# ifdef HAVE_WORKING_FORK
+ struct popen_writer_arg pw;
+ int *const write_pair = pw.popen.pair;
+# else
+ int write_pair[2];
+# endif
+
+ int result = rb_cloexec_pipe(write_pair);
+ *pid = -1;
+ if (result == 0) {
+# ifdef HAVE_WORKING_FORK
+ pw.argv = argv;
+ int status;
+ char errmsg[80] = {'\0'};
+ *pid = rb_fork_async_signal_safe(&status, exec_popen_writer, &pw, Qnil, errmsg, sizeof(errmsg));
+# else
+ *pid = rb_w32_uspawn_process(P_NOWAIT, argv[0], argv, write_pair[0], -1, -1, 0);
+ const char *errmsg = (*pid < 0) ? strerror(errno) : NULL;
+# endif
+ close(write_pair[0]);
+ if (*pid < 0) {
+ close(write_pair[1]);
+ fprintf(stderr, "ruby_popen_writer(%s): %s\n", argv[0], errmsg);
+ }
+ else {
+ return fdopen(write_pair[1], "w");
+ }
+ }
+#endif
+ return NULL;
+}
+
static void
rb_scan_open_args(int argc, const VALUE *argv,
VALUE *fname_p, int *oflags_p, int *fmode_p,
- convconfig_t *convconfig_p, mode_t *perm_p)
+ struct rb_io_encoding *convconfig_p, mode_t *perm_p)
{
VALUE opt, fname, vmode, vperm;
int oflags, fmode;
@@ -7988,7 +8054,7 @@ rb_open_file(int argc, const VALUE *argv, VALUE io)
{
VALUE fname;
int oflags, fmode;
- convconfig_t convconfig;
+ struct rb_io_encoding convconfig;
mode_t perm;
rb_scan_open_args(argc, argv, &fname, &oflags, &fmode, &convconfig, &perm);
@@ -8004,11 +8070,11 @@ rb_open_file(int argc, const VALUE *argv, VALUE io)
* File.open(path, mode = 'r', perm = 0666, **opts) -> file
* File.open(path, mode = 'r', perm = 0666, **opts) {|f| ... } -> object
*
- * Creates a new \File object, via File.new with the given arguments.
+ * Creates a new File object, via File.new with the given arguments.
*
- * With no block given, returns the \File object.
+ * With no block given, returns the File object.
*
- * With a block given, calls the block with the \File object
+ * With a block given, calls the block with the File object
* and returns the block's value.
*
*/
@@ -8106,20 +8172,10 @@ check_pipe_command(VALUE filename_or_command)
* open(path, mode = 'r', perm = 0666, **opts) -> io or nil
* open(path, mode = 'r', perm = 0666, **opts) {|io| ... } -> obj
*
- * Creates an IO object connected to the given stream, file, or subprocess.
- *
- * Required string argument +path+ determines which of the following occurs:
+ * Creates an IO object connected to the given file.
*
- * - The file at the specified +path+ is opened.
- * - The process forks.
- * - A subprocess is created.
- *
- * Each of these is detailed below.
- *
- * <b>File Opened</b>
-
- * If +path+ does _not_ start with a pipe character (<tt>'|'</tt>),
- * a file stream is opened with <tt>File.open(path, mode, perm, **opts)</tt>.
+ * This method has potential security vulnerabilities if called with untrusted input;
+ * see {Command Injection}[rdoc-ref:command_injection.rdoc].
*
* With no block given, file stream is returned:
*
@@ -8136,67 +8192,6 @@ check_pipe_command(VALUE filename_or_command)
*
* See File.open for details.
*
- * <b>Process Forked</b>
- *
- * If +path+ is the 2-character string <tt>'|-'</tt>, the process forks
- * and the child process is connected to the parent.
- *
- * With no block given:
- *
- * io = open('|-')
- * if io
- * $stderr.puts "In parent, child pid is #{io.pid}."
- * else
- * $stderr.puts "In child, pid is #{$$}."
- * end
- *
- * Output:
- *
- * In parent, child pid is 27903.
- * In child, pid is 27903.
- *
- * With a block given:
- *
- * open('|-') do |io|
- * if io
- * $stderr.puts "In parent, child pid is #{io.pid}."
- * else
- * $stderr.puts "In child, pid is #{$$}."
- * end
- * end
- *
- * Output:
- *
- * In parent, child pid is 28427.
- * In child, pid is 28427.
- *
- * <b>Subprocess Created</b>
- *
- * If +path+ is <tt>'|command'</tt> (<tt>'command' != '-'</tt>),
- * a new subprocess runs the command; its open stream is returned.
- * Note that the command may be processed by shell if it contains
- * shell metacharacters.
- *
- * With no block given:
- *
- * io = open('|echo "Hi!"') # => #<IO:fd 12>
- * print io.gets
- * io.close
- *
- * Output:
- *
- * "Hi!"
- *
- * With a block given, calls the block with the stream, then closes the stream:
- *
- * open('|echo "Hi!"') do |io|
- * print io.gets
- * end
- *
- * Output:
- *
- * "Hi!"
- *
*/
static VALUE
@@ -8219,6 +8214,8 @@ rb_f_open(int argc, VALUE *argv, VALUE _)
else {
VALUE cmd = check_pipe_command(tmp);
if (!NIL_P(cmd)) {
+ // TODO: when removed in 4.0, update command_injection.rdoc
+ rb_warn_deprecated_to_remove_at(4.0, "Calling Kernel#open with a leading '|'", "IO.popen");
argv[0] = cmd;
return rb_io_s_popen(argc, argv, rb_cIO);
}
@@ -8236,13 +8233,13 @@ rb_f_open(int argc, VALUE *argv, VALUE _)
return rb_io_s_open(argc, argv, rb_cFile);
}
-static VALUE rb_io_open_generic(VALUE, VALUE, int, int, const convconfig_t *, mode_t);
+static VALUE rb_io_open_generic(VALUE, VALUE, int, int, const struct rb_io_encoding *, mode_t);
static VALUE
rb_io_open(VALUE io, VALUE filename, VALUE vmode, VALUE vperm, VALUE opt)
{
int oflags, fmode;
- convconfig_t convconfig;
+ struct rb_io_encoding convconfig;
mode_t perm;
rb_io_extract_modeenc(&vmode, &vperm, opt, &oflags, &fmode, &convconfig);
@@ -8252,10 +8249,12 @@ rb_io_open(VALUE io, VALUE filename, VALUE vmode, VALUE vperm, VALUE opt)
static VALUE
rb_io_open_generic(VALUE klass, VALUE filename, int oflags, int fmode,
- const convconfig_t *convconfig, mode_t perm)
+ const struct rb_io_encoding *convconfig, mode_t perm)
{
VALUE cmd;
if (klass == rb_cIO && !NIL_P(cmd = check_pipe_command(filename))) {
+ // TODO: when removed in 4.0, update command_injection.rdoc
+ rb_warn_deprecated_to_remove_at(4.0, "IO process creation with a leading '|'", "IO.popen");
return pipe_open_s(cmd, rb_io_oflags_modestr(oflags), fmode, convconfig);
}
else {
@@ -8276,7 +8275,7 @@ io_reopen(VALUE io, VALUE nfile)
GetOpenFile(nfile, orig);
if (fptr == orig) return io;
- if (IS_PREP_STDIO(fptr)) {
+ if (RUBY_IO_EXTERNAL_P(fptr)) {
if ((fptr->stdio_file == stdin && !(orig->mode & FMODE_READABLE)) ||
(fptr->stdio_file == stdout && !(orig->mode & FMODE_WRITABLE)) ||
(fptr->stdio_file == stderr && !(orig->mode & FMODE_WRITABLE))) {
@@ -8302,17 +8301,17 @@ io_reopen(VALUE io, VALUE nfile)
}
/* copy rb_io_t structure */
- fptr->mode = orig->mode | (fptr->mode & FMODE_PREP);
+ fptr->mode = orig->mode | (fptr->mode & FMODE_EXTERNAL);
fptr->pid = orig->pid;
fptr->lineno = orig->lineno;
if (RTEST(orig->pathv)) fptr->pathv = orig->pathv;
- else if (!IS_PREP_STDIO(fptr)) fptr->pathv = Qnil;
+ else if (!RUBY_IO_EXTERNAL_P(fptr)) fptr->pathv = Qnil;
fptr_copy_finalizer(fptr, orig);
fd = fptr->fd;
fd2 = orig->fd;
if (fd != fd2) {
- if (IS_PREP_STDIO(fptr) || fd <= 2 || !fptr->stdio_file) {
+ if (RUBY_IO_EXTERNAL_P(fptr) || fd <= 2 || !fptr->stdio_file) {
/* need to keep FILE objects of stdin, stdout and stderr */
if (rb_cloexec_dup2(fd2, fd) < 0)
rb_sys_fail_path(orig->pathv);
@@ -8417,10 +8416,10 @@ rb_io_reopen(int argc, VALUE *argv, VALUE file)
if (!NIL_P(nmode) || !NIL_P(opt)) {
int fmode;
- convconfig_t convconfig;
+ struct rb_io_encoding convconfig;
rb_io_extract_modeenc(&nmode, 0, opt, &oflags, &fmode, &convconfig);
- if (IS_PREP_STDIO(fptr) &&
+ if (RUBY_IO_EXTERNAL_P(fptr) &&
((fptr->mode & FMODE_READWRITE) & (fmode & FMODE_READWRITE)) !=
(fptr->mode & FMODE_READWRITE)) {
rb_raise(rb_eArgError,
@@ -8499,7 +8498,7 @@ rb_io_init_copy(VALUE dest, VALUE io)
rb_io_flush(io);
/* copy rb_io_t structure */
- fptr->mode = orig->mode & ~FMODE_PREP;
+ fptr->mode = orig->mode & ~FMODE_EXTERNAL;
fptr->encs = orig->encs;
fptr->pid = orig->pid;
fptr->lineno = orig->lineno;
@@ -8863,9 +8862,9 @@ io_puts_ary(VALUE ary, VALUE out, int recur)
*
* Treatment for each object:
*
- * - \String: writes the string.
+ * - String: writes the string.
* - Neither string nor array: writes <tt>object.to_s</tt>.
- * - \Array: writes each element of the array; arrays may be nested.
+ * - Array: writes each element of the array; arrays may be nested.
*
* To keep these examples brief, we define this helper method:
*
@@ -8898,7 +8897,6 @@ io_puts_ary(VALUE ary, VALUE out, int recur)
VALUE
rb_io_puts(int argc, const VALUE *argv, VALUE out)
{
- int i, n;
VALUE line, args[2];
/* if no argument given, print newline. */
@@ -8906,22 +8904,30 @@ rb_io_puts(int argc, const VALUE *argv, VALUE out)
rb_io_write(out, rb_default_rs);
return Qnil;
}
- for (i=0; i<argc; i++) {
+ for (int i = 0; i < argc; i++) {
+ // Convert the argument to a string:
if (RB_TYPE_P(argv[i], T_STRING)) {
line = argv[i];
- goto string;
}
- if (rb_exec_recursive(io_puts_ary, argv[i], out)) {
+ else if (rb_exec_recursive(io_puts_ary, argv[i], out)) {
continue;
}
- line = rb_obj_as_string(argv[i]);
- string:
- n = 0;
- args[n++] = line;
- if (RSTRING_LEN(line) == 0 ||
- !rb_str_end_with_asciichar(line, '\n')) {
+ else {
+ line = rb_obj_as_string(argv[i]);
+ }
+
+ // Write the line:
+ int n = 0;
+ if (RSTRING_LEN(line) == 0) {
args[n++] = rb_default_rs;
}
+ else {
+ args[n++] = line;
+ if (!rb_str_end_with_asciichar(line, '\n')) {
+ args[n++] = rb_default_rs;
+ }
+ }
+
rb_io_writev(out, n, args);
}
@@ -9014,6 +9020,10 @@ rb_p_result(int argc, const VALUE *argv)
* 0..4
* [0..4, 0..4, 0..4]
*
+ * Kernel#p is designed for debugging purposes.
+ * Ruby implementations may define Kernel#p to be uninterruptible
+ * in whole or in part.
+ * On CRuby, Kernel#p's writing of data is uninterruptible.
*/
static VALUE
@@ -9167,26 +9177,78 @@ stderr_getter(ID id, VALUE *ptr)
}
static VALUE
+allocate_and_open_new_file(VALUE klass)
+{
+ VALUE self = io_alloc(klass);
+ rb_io_make_open_file(self);
+ return self;
+}
+
+VALUE
+rb_io_open_descriptor(VALUE klass, int descriptor, int mode, VALUE path, VALUE timeout, struct rb_io_encoding *encoding)
+{
+ int state;
+ VALUE self = rb_protect(allocate_and_open_new_file, klass, &state);
+ if (state) {
+ /* if we raised an exception allocating an IO object, but the caller
+ intended to transfer ownership of this FD to us, close the fd before
+ raising the exception. Otherwise, we would leak a FD - the caller
+ expects GC to close the file, but we never got around to assigning
+ it to a rb_io. */
+ if (!(mode & FMODE_EXTERNAL)) {
+ maygvl_close(descriptor, 0);
+ }
+ rb_jump_tag(state);
+ }
+
+
+ rb_io_t *io = RFILE(self)->fptr;
+ io->self = self;
+ io->fd = descriptor;
+ io->mode = mode;
+
+ /* At this point, Ruby fully owns the descriptor, and will close it when
+ the IO gets GC'd (unless FMODE_EXTERNAL was set), no matter what happens
+ in the rest of this method. */
+
+ if (NIL_P(path)) {
+ io->pathv = Qnil;
+ }
+ else {
+ StringValue(path);
+ io->pathv = rb_str_new_frozen(path);
+ }
+
+ io->timeout = timeout;
+
+ if (encoding) {
+ io->encs = *encoding;
+ }
+
+ rb_update_max_fd(descriptor);
+
+ return self;
+}
+
+static VALUE
prep_io(int fd, int fmode, VALUE klass, const char *path)
{
- rb_io_t *fp;
- VALUE io = io_alloc(klass);
+ VALUE path_value = Qnil;
+ if (path) {
+ path_value = rb_obj_freeze(rb_str_new_cstr(path));
+ }
- MakeOpenFile(io, fp);
- fp->self = io;
- fp->fd = fd;
- fp->mode = fmode;
- fp->timeout = Qnil;
- if (!io_check_tty(fp)) {
+ VALUE self = rb_io_open_descriptor(klass, fd, fmode, path_value, Qnil, NULL);
+ rb_io_t*io = RFILE(self)->fptr;
+
+ if (!io_check_tty(io)) {
#ifdef __CYGWIN__
- fp->mode |= FMODE_BINMODE;
+ io->mode |= FMODE_BINMODE;
setmode(fd, O_BINARY);
#endif
}
- if (path) fp->pathv = rb_obj_freeze(rb_str_new_cstr(path));
- rb_update_max_fd(fd);
- return io;
+ return self;
}
VALUE
@@ -9202,7 +9264,7 @@ static VALUE
prep_stdio(FILE *f, int fmode, VALUE klass, const char *path)
{
rb_io_t *fptr;
- VALUE io = prep_io(fileno(f), fmode|FMODE_PREP|DEFAULT_TEXTMODE, klass, path);
+ VALUE io = prep_io(fileno(f), fmode|FMODE_EXTERNAL|DEFAULT_TEXTMODE, klass, path);
GetOpenFile(io, fptr);
fptr->encs.ecflags |= ECONV_DEFAULT_NEWLINE_DECORATOR;
@@ -9246,7 +9308,7 @@ rb_io_stdio_file(rb_io_t *fptr)
}
static inline void
-rb_io_buffer_init(rb_io_buffer_t *buf)
+rb_io_buffer_init(struct rb_io_internal_buffer *buf)
{
buf->ptr = NULL;
buf->off = 0;
@@ -9349,7 +9411,7 @@ rb_io_initialize(int argc, VALUE *argv, VALUE io)
VALUE fnum, vmode;
rb_io_t *fp;
int fd, fmode, oflags = O_RDONLY;
- convconfig_t convconfig;
+ struct rb_io_encoding convconfig;
VALUE opt;
#if defined(HAVE_FCNTL) && defined(F_GETFL)
int ofmode;
@@ -9386,7 +9448,7 @@ rb_io_initialize(int argc, VALUE *argv, VALUE io)
if (!NIL_P(opt)) {
if (rb_hash_aref(opt, sym_autoclose) == Qfalse) {
- fmode |= FMODE_PREP;
+ fmode |= FMODE_EXTERNAL;
}
path = rb_hash_aref(opt, RB_ID2SYM(idPath));
@@ -9465,9 +9527,9 @@ rb_io_set_encoding_by_bom(VALUE io)
* File.new(path, mode = 'r', perm = 0666, **opts) -> file
*
* Opens the file at the given +path+ according to the given +mode+;
- * creates and returns a new \File object for that file.
+ * creates and returns a new File object for that file.
*
- * The new \File object is buffered mode (or non-sync mode), unless
+ * The new File object is buffered mode (or non-sync mode), unless
* +filename+ is a tty.
* See IO#flush, IO#fsync, IO#fdatasync, and IO#sync=.
*
@@ -9555,7 +9617,7 @@ rb_io_s_for_fd(int argc, VALUE *argv, VALUE klass)
* ios.autoclose? -> true or false
*
* Returns +true+ if the underlying file descriptor of _ios_ will be
- * closed automatically at its finalization, otherwise +false+.
+ * closed at its finalization or at calling #close, otherwise +false+.
*/
static VALUE
@@ -9563,7 +9625,7 @@ rb_io_autoclose_p(VALUE io)
{
rb_io_t *fptr = RFILE(io)->fptr;
rb_io_check_closed(fptr);
- return RBOOL(!(fptr->mode & FMODE_PREP));
+ return RBOOL(!(fptr->mode & FMODE_EXTERNAL));
}
/*
@@ -9572,14 +9634,14 @@ rb_io_autoclose_p(VALUE io)
*
* Sets auto-close flag.
*
- * f = open("/dev/null")
- * IO.for_fd(f.fileno)
- * # ...
- * f.gets # may cause Errno::EBADF
+ * f = File.open(File::NULL)
+ * IO.for_fd(f.fileno).close
+ * f.gets # raises Errno::EBADF
*
- * f = open("/dev/null")
- * IO.for_fd(f.fileno).autoclose = false
- * # ...
+ * f = File.open(File::NULL)
+ * g = IO.for_fd(f.fileno)
+ * g.autoclose = false
+ * g.close
* f.gets # won't cause Errno::EBADF
*/
@@ -9589,9 +9651,9 @@ rb_io_set_autoclose(VALUE io, VALUE autoclose)
rb_io_t *fptr;
GetOpenFile(io, fptr);
if (!RTEST(autoclose))
- fptr->mode |= FMODE_PREP;
+ fptr->mode |= FMODE_EXTERNAL;
else
- fptr->mode &= ~FMODE_PREP;
+ fptr->mode &= ~FMODE_EXTERNAL;
return autoclose;
}
@@ -9724,7 +9786,7 @@ wait_mode_sym(VALUE mode)
rb_raise(rb_eArgError, "unsupported mode: %"PRIsVALUE, mode);
}
-static inline rb_io_event_t
+static inline enum rb_io_event
io_event_from_value(VALUE value)
{
int events = RB_NUM2INT(value);
@@ -9755,7 +9817,7 @@ static VALUE
io_wait(int argc, VALUE *argv, VALUE io)
{
VALUE timeout = Qundef;
- rb_io_event_t events = 0;
+ enum rb_io_event events = 0;
int return_io = 0;
// The documented signature for this method is actually incorrect.
@@ -10409,19 +10471,21 @@ rb_f_readlines(int argc, VALUE *argv, VALUE recv)
/*
* call-seq:
- * ARGF.readlines(sep = $/) -> array
- * ARGF.readlines(limit) -> array
- * ARGF.readlines(sep, limit) -> array
+ * ARGF.readlines(sep = $/, chomp: false) -> array
+ * ARGF.readlines(limit, chomp: false) -> array
+ * ARGF.readlines(sep, limit, chomp: false) -> array
*
- * ARGF.to_a(sep = $/) -> array
- * ARGF.to_a(limit) -> array
- * ARGF.to_a(sep, limit) -> array
+ * ARGF.to_a(sep = $/, chomp: false) -> array
+ * ARGF.to_a(limit, chomp: false) -> array
+ * ARGF.to_a(sep, limit, chomp: false) -> array
*
* Reads each file in ARGF in its entirety, returning an Array containing
* lines from the files. Lines are assumed to be separated by _sep_.
*
* lines = ARGF.readlines
* lines[0] #=> "This is line one\n"
+ *
+ * See +IO.readlines+ for a full description of all options.
*/
static VALUE
argf_readlines(int argc, VALUE *argv, VALUE argf)
@@ -10483,8 +10547,7 @@ rb_f_backquote(VALUE obj, VALUE str)
GetOpenFile(port, fptr);
result = read_all(fptr, remain_size(fptr), Qnil);
rb_io_close(port);
- RFILE(port)->fptr = NULL;
- rb_io_fptr_finalize(fptr);
+ rb_io_fptr_cleanup_all(fptr);
RB_GC_GUARD(port);
return result;
@@ -11385,7 +11448,7 @@ rb_fcntl(VALUE io, VALUE req, VALUE arg)
* a file-oriented I/O stream. Arguments and results are platform
* dependent.
*
- * If +argument is a number, its value is passed directly;
+ * If +argument+ is a number, its value is passed directly;
* if it is a string, it is interpreted as a binary sequence of bytes.
* (Array#pack might be a useful way to build this string.)
*
@@ -11638,9 +11701,9 @@ pipe_pair_close(VALUE rw)
* IO.pipe(**opts) -> [read_io, write_io]
* IO.pipe(enc, **opts) -> [read_io, write_io]
* IO.pipe(ext_enc, int_enc, **opts) -> [read_io, write_io]
- * IO.pipe(**opts) {|read_io, write_io] ...} -> object
- * IO.pipe(enc, **opts) {|read_io, write_io] ...} -> object
- * IO.pipe(ext_enc, int_enc, **opts) {|read_io, write_io] ...} -> object
+ * IO.pipe(**opts) {|read_io, write_io| ...} -> object
+ * IO.pipe(enc, **opts) {|read_io, write_io| ...} -> object
+ * IO.pipe(ext_enc, int_enc, **opts) {|read_io, write_io| ...} -> object
*
* Creates a pair of pipe endpoints, +read_io+ and +write_io+,
* connected to each other.
@@ -11851,9 +11914,6 @@ io_s_foreach(VALUE v)
* IO.foreach(path, sep = $/, **opts) {|line| block } -> nil
* IO.foreach(path, limit, **opts) {|line| block } -> nil
* IO.foreach(path, sep, limit, **opts) {|line| block } -> nil
- * IO.foreach(command, sep = $/, **opts) {|line| block } -> nil
- * IO.foreach(command, limit, **opts) {|line| block } -> nil
- * IO.foreach(command, sep, limit, **opts) {|line| block } -> nil
* IO.foreach(...) -> an_enumerator
*
* Calls the block with each successive line read from the stream.
@@ -11862,16 +11922,7 @@ io_s_foreach(VALUE v)
* this method has potential security vulnerabilities if called with untrusted input;
* see {Command Injection}[rdoc-ref:command_injection.rdoc].
*
- * The first argument must be a string that is one of the following:
- *
- * - Path: if +self+ is a subclass of \IO (\File, for example),
- * or if the string _does_ _not_ start with the pipe character (<tt>'|'</tt>),
- * the string is the path to a file.
- * - Command: if +self+ is the class \IO,
- * and if the string starts with the pipe character,
- * the rest of the string is a command to be executed as a subprocess.
- * This usage has potential security vulnerabilities if called with untrusted input;
- * see {Command Injection}[rdoc-ref:command_injection.rdoc].
+ * The first argument must be a string that is the path to a file.
*
* With only argument +path+ given, parses lines from the file at the given +path+,
* as determined by the default line separator,
@@ -11932,7 +11983,7 @@ io_s_foreach(VALUE v)
*
* - {Open Options}[rdoc-ref:IO@Open+Options].
* - {Encoding options}[rdoc-ref:encodings.rdoc@Encoding+Options].
- * - {Line Options}[rdoc-ref:IO@Line+Options].
+ * - {Line Options}[rdoc-ref:IO@Line+IO].
*
* Returns an Enumerator if no block is given.
*
@@ -11965,9 +12016,6 @@ io_s_readlines(VALUE v)
/*
* call-seq:
- * IO.readlines(command, sep = $/, **opts) -> array
- * IO.readlines(command, limit, **opts) -> array
- * IO.readlines(command, sep, limit, **opts) -> array
* IO.readlines(path, sep = $/, **opts) -> array
* IO.readlines(path, limit, **opts) -> array
* IO.readlines(path, sep, limit, **opts) -> array
@@ -11978,19 +12026,7 @@ io_s_readlines(VALUE v)
* this method has potential security vulnerabilities if called with untrusted input;
* see {Command Injection}[rdoc-ref:command_injection.rdoc].
*
- * The first argument must be a string;
- * its meaning depends on whether it starts with the pipe character (<tt>'|'</tt>):
- *
- * - If so (and if +self+ is \IO),
- * the rest of the string is a command to be executed as a subprocess.
- * - Otherwise, the string is the path to a file.
- *
- * With only argument +command+ given, executes the command in a shell,
- * parses its $stdout into lines, as determined by the default line separator,
- * and returns those lines in an array:
- *
- * IO.readlines('| cat t.txt')
- * # => ["First line\n", "Second line\n", "\n", "Third line\n", "Fourth line\n"]
+ * The first argument must be a string that is the path to a file.
*
* With only argument +path+ given, parses lines from the file at the given +path+,
* as determined by the default line separator,
@@ -11999,8 +12035,6 @@ io_s_readlines(VALUE v)
* IO.readlines('t.txt')
* # => ["First line\n", "Second line\n", "\n", "Third line\n", "Fourth line\n"]
*
- * For both forms, command and path, the remaining arguments are the same.
- *
* With argument +sep+ given, parses lines as determined by that line separator
* (see {Line Separator}[rdoc-ref:IO@Line+Separator]):
*
@@ -12030,7 +12064,7 @@ io_s_readlines(VALUE v)
*
* - {Open Options}[rdoc-ref:IO@Open+Options].
* - {Encoding options}[rdoc-ref:encodings.rdoc@Encoding+Options].
- * - {Line Options}[rdoc-ref:IO@Line+Options].
+ * - {Line Options}[rdoc-ref:IO@Line+IO].
*
*/
@@ -12073,7 +12107,6 @@ seek_before_access(VALUE argp)
/*
* call-seq:
- * IO.read(command, length = nil, offset = 0, **opts) -> string or nil
* IO.read(path, length = nil, offset = 0, **opts) -> string or nil
*
* Opens the stream, reads and returns some or all of its content,
@@ -12083,18 +12116,7 @@ seek_before_access(VALUE argp)
* this method has potential security vulnerabilities if called with untrusted input;
* see {Command Injection}[rdoc-ref:command_injection.rdoc].
*
- * The first argument must be a string;
- * its meaning depends on whether it starts with the pipe character (<tt>'|'</tt>):
- *
- * - If so (and if +self+ is \IO),
- * the rest of the string is a command to be executed as a subprocess.
- * - Otherwise, the string is the path to a file.
- *
- * With only argument +command+ given, executes the command in a shell,
- * returns its entire $stdout:
- *
- * IO.read('| cat t.txt')
- * # => "First line\nSecond line\n\nThird line\nFourth line\n"
+ * The first argument must be a string that is the path to a file.
*
* With only argument +path+ given, reads in text mode and returns the entire content
* of the file at the given path:
@@ -12106,8 +12128,6 @@ seek_before_access(VALUE argp)
* unread when encountering certain special bytes. Consider using
* IO.binread if all bytes in the file should be read.
*
- * For both forms, command and path, the remaining arguments are the same.
- *
* With argument +length+, returns +length+ bytes if available:
*
* IO.read('t.txt', 7) # => "First l"
@@ -12131,9 +12151,13 @@ static VALUE
rb_io_s_read(int argc, VALUE *argv, VALUE io)
{
VALUE opt, offset;
+ long off;
struct foreach_arg arg;
argc = rb_scan_args(argc, argv, "13:", NULL, NULL, &offset, NULL, &opt);
+ if (!NIL_P(offset) && (off = NUM2LONG(offset)) < 0) {
+ rb_raise(rb_eArgError, "negative offset %ld given", off);
+ }
open_key_args(io, argc, argv, opt, &arg);
if (NIL_P(arg.io)) return Qnil;
if (!NIL_P(offset)) {
@@ -12154,7 +12178,6 @@ rb_io_s_read(int argc, VALUE *argv, VALUE io)
/*
* call-seq:
- * IO.binread(command, length = nil, offset = 0) -> string or nil
* IO.binread(path, length = nil, offset = 0) -> string or nil
*
* Behaves like IO.read, except that the stream is opened in binary mode
@@ -12178,7 +12201,7 @@ rb_io_s_binread(int argc, VALUE *argv, VALUE io)
|O_BINARY
#endif
};
- convconfig_t convconfig = {NULL, NULL, 0, Qnil};
+ struct rb_io_encoding convconfig = {NULL, NULL, 0, Qnil};
rb_scan_args(argc, argv, "12", NULL, NULL, &offset);
FilePathValue(argv[0]);
@@ -12259,7 +12282,6 @@ io_s_write(int argc, VALUE *argv, VALUE klass, int binary)
/*
* call-seq:
- * IO.write(command, data, **opts) -> integer
* IO.write(path, data, offset = 0, **opts) -> integer
*
* Opens the stream, writes the given +data+ to it,
@@ -12269,25 +12291,9 @@ io_s_write(int argc, VALUE *argv, VALUE klass, int binary)
* this method has potential security vulnerabilities if called with untrusted input;
* see {Command Injection}[rdoc-ref:command_injection.rdoc].
*
- * The first argument must be a string;
- * its meaning depends on whether it starts with the pipe character (<tt>'|'</tt>):
- *
- * - If so (and if +self+ is \IO),
- * the rest of the string is a command to be executed as a subprocess.
- * - Otherwise, the string is the path to a file.
+ * The first argument must be a string that is the path to a file.
*
- * With argument +command+ given, executes the command in a shell,
- * passes +data+ through standard input, writes its output to $stdout,
- * and returns the length of the given +data+:
- *
- * IO.write('| cat', 'Hello World!') # => 12
- *
- * Output:
- *
- * Hello World!
- *
- * With argument +path+ given, writes the given +data+ to the file
- * at that path:
+ * With only argument +path+ given, writes the given +data+ to the file at that path:
*
* IO.write('t.tmp', 'abc') # => 3
* File.read('t.tmp') # => "abc"
@@ -12326,7 +12332,6 @@ rb_io_s_write(int argc, VALUE *argv, VALUE io)
/*
* call-seq:
- * IO.binwrite(command, string, offset = 0) -> integer
* IO.binwrite(path, string, offset = 0) -> integer
*
* Behaves like IO.write, except that the stream is opened in binary mode
@@ -12883,12 +12888,7 @@ maygvl_copy_stream_read(int has_gvl, struct copy_stream_struct *stp, char *buf,
ss = maygvl_read(has_gvl, stp->src_fptr, buf, len);
}
else {
-#ifdef HAVE_PREAD
ss = pread(stp->src_fptr->fd, buf, len, offset);
-#else
- stp->notimp = "pread";
- return -1;
-#endif
}
if (ss == 0) {
return 0;
@@ -14422,7 +14422,7 @@ argf_closed(VALUE argf)
{
next_argv();
ARGF_FORWARD(0, 0);
- return rb_io_closed(ARGF.current_file);
+ return rb_io_closed_p(ARGF.current_file);
}
/*
@@ -14701,11 +14701,16 @@ set_LAST_READ_LINE(VALUE val, ID _x, VALUE *_y)
* ARGV.replace ["file2", "file3"]
* ARGF.read # Returns the contents of file2 and file3
*
- * If +ARGV+ is empty, ARGF acts as if it contained STDIN, i.e. the data
- * piped to your script. For example:
+ * If +ARGV+ is empty, ARGF acts as if it contained <tt>"-"</tt> that
+ * makes ARGF read from STDIN, i.e. the data piped or typed to your
+ * script. For example:
*
* $ echo "glark" | ruby -e 'p ARGF.read'
* "glark\n"
+ *
+ * $ echo Glark > file1
+ * $ echo "glark" | ruby -e 'p ARGF.read' -- - file1
+ * "glark\nGlark\n"
*/
/*
@@ -14723,7 +14728,7 @@ set_LAST_READ_LINE(VALUE val, ID _x, VALUE *_y)
* ARGF is not itself a subclass of \IO.
*
* \Class StringIO provides an IO-like stream that handles a String.
- * \StringIO is not itself a subclass of \IO.
+ * StringIO is not itself a subclass of \IO.
*
* Important objects based on \IO include:
*
@@ -14741,7 +14746,7 @@ set_LAST_READ_LINE(VALUE val, ID _x, VALUE *_y)
* - Kernel#open: Returns a new \IO object connected to a given source:
* stream, file, or subprocess.
*
- * Like a \File stream, an \IO stream has:
+ * Like a File stream, an \IO stream has:
*
* - A read/write mode, which may be read-only, write-only, or read/write;
* see {Read/Write Mode}[rdoc-ref:File@Read-2FWrite+Mode].
@@ -14777,7 +14782,7 @@ set_LAST_READ_LINE(VALUE val, ID _x, VALUE *_y)
* that determine how a new stream is to be opened:
*
* - +:mode+: Stream mode.
- * - +:flags+: \Integer file open flags;
+ * - +:flags+: Integer file open flags;
* If +mode+ is also given, the two are bitwise-ORed.
* - +:external_encoding+: External encoding for the stream.
* - +:internal_encoding+: Internal encoding for the stream.
@@ -14792,7 +14797,7 @@ set_LAST_READ_LINE(VALUE val, ID _x, VALUE *_y)
* #path method.
*
* Also available are the options offered in String#encode,
- * which may control conversion between external internal encoding.
+ * which may control conversion between external and internal encoding.
*
* == Basic \IO
*
@@ -15067,7 +15072,7 @@ set_LAST_READ_LINE(VALUE val, ID _x, VALUE *_y)
* # => 41
* f.close
*
- * - When a stream is read, <tt>#.</tt> is set to the line number for that stream:
+ * - When a stream is read, <tt>$.</tt> is set to the line number for that stream:
*
* f0 = File.new('t.txt')
* f1 = File.new('t.dat')
@@ -15316,10 +15321,14 @@ Init_IO(void)
rb_cIO = rb_define_class("IO", rb_cObject);
rb_include_module(rb_cIO, rb_mEnumerable);
+ /* Can be raised by IO operations when IO#timeout= is set. */
rb_eIOTimeoutError = rb_define_class_under(rb_cIO, "TimeoutError", rb_eIOError);
+ /* Readable event mask for IO#wait. */
rb_define_const(rb_cIO, "READABLE", INT2NUM(RUBY_IO_READABLE));
+ /* Writable event mask for IO#wait. */
rb_define_const(rb_cIO, "WRITABLE", INT2NUM(RUBY_IO_WRITABLE));
+ /* Priority event mask for IO#wait. */
rb_define_const(rb_cIO, "PRIORITY", INT2NUM(RUBY_IO_PRIORITY));
/* exception to wait for reading. see IO.select. */
@@ -15433,7 +15442,6 @@ Init_IO(void)
rb_define_method(rb_cIO, "read", io_read, -1);
rb_define_method(rb_cIO, "write", io_write_m, -1);
rb_define_method(rb_cIO, "gets", rb_io_gets_m, -1);
- rb_define_method(rb_cIO, "readline", rb_io_readline, -1);
rb_define_method(rb_cIO, "getc", rb_io_getc, 0);
rb_define_method(rb_cIO, "getbyte", rb_io_getbyte, 0);
rb_define_method(rb_cIO, "readchar", rb_io_readchar, 0);
@@ -15468,7 +15476,7 @@ Init_IO(void)
rb_define_method(rb_cIO, "close_on_exec=", rb_io_set_close_on_exec, 1);
rb_define_method(rb_cIO, "close", rb_io_close_m, 0);
- rb_define_method(rb_cIO, "closed?", rb_io_closed, 0);
+ rb_define_method(rb_cIO, "closed?", rb_io_closed_p, 0);
rb_define_method(rb_cIO, "close_read", rb_io_close_read, 0);
rb_define_method(rb_cIO, "close_write", rb_io_close_write, 0);
@@ -15512,13 +15520,12 @@ Init_IO(void)
rb_gvar_ractor_local("$>");
rb_gvar_ractor_local("$stderr");
- rb_stdin = rb_io_prep_stdin();
- rb_stdout = rb_io_prep_stdout();
- rb_stderr = rb_io_prep_stderr();
-
rb_global_variable(&rb_stdin);
+ rb_stdin = rb_io_prep_stdin();
rb_global_variable(&rb_stdout);
+ rb_stdout = rb_io_prep_stdout();
rb_global_variable(&rb_stderr);
+ rb_stderr = rb_io_prep_stderr();
orig_stdout = rb_stdout;
orig_stderr = rb_stderr;
diff --git a/io.rb b/io.rb
index 40873ea4fd..549c5e62bd 100644
--- a/io.rb
+++ b/io.rb
@@ -120,4 +120,17 @@ class IO
def write_nonblock(buf, exception: true)
Primitive.io_write_nonblock(buf, exception)
end
+
+ # call-seq:
+ # readline(sep = $/, chomp: false) -> string
+ # readline(limit, chomp: false) -> string
+ # readline(sep, limit, chomp: false) -> string
+ #
+ # Reads a line as with IO#gets, but raises EOFError if already at end-of-stream.
+ #
+ # Optional keyword argument +chomp+ specifies whether line separators
+ # are to be omitted.
+ def readline(sep = $/, limit = nil, chomp: false)
+ Primitive.io_readline(sep, limit, chomp)
+ end
end
diff --git a/io_buffer.c b/io_buffer.c
index c5f0b193c3..7715aa0d37 100644
--- a/io_buffer.c
+++ b/io_buffer.c
@@ -34,6 +34,18 @@ size_t RUBY_IO_BUFFER_DEFAULT_SIZE;
#include <sys/mman.h>
#endif
+enum {
+ RB_IO_BUFFER_HEXDUMP_DEFAULT_WIDTH = 16,
+
+ RB_IO_BUFFER_INSPECT_HEXDUMP_MAXIMUM_SIZE = 256,
+ RB_IO_BUFFER_INSPECT_HEXDUMP_WIDTH = 16,
+
+ // This is used to validate the flags given by the user.
+ RB_IO_BUFFER_FLAGS_MASK = RB_IO_BUFFER_EXTERNAL | RB_IO_BUFFER_INTERNAL | RB_IO_BUFFER_MAPPED | RB_IO_BUFFER_SHARED | RB_IO_BUFFER_LOCKED | RB_IO_BUFFER_PRIVATE | RB_IO_BUFFER_READONLY,
+
+ RB_IO_BUFFER_DEBUG = 0,
+};
+
struct rb_io_buffer {
void *base;
size_t size;
@@ -59,7 +71,8 @@ io_buffer_map_memory(size_t size, int flags)
int mmap_flags = MAP_ANONYMOUS;
if (flags & RB_IO_BUFFER_SHARED) {
mmap_flags |= MAP_SHARED;
- } else {
+ }
+ else {
mmap_flags |= MAP_PRIVATE;
}
@@ -74,7 +87,7 @@ io_buffer_map_memory(size_t size, int flags)
}
static void
-io_buffer_map_file(struct rb_io_buffer *data, int descriptor, size_t size, rb_off_t offset, enum rb_io_buffer_flags flags)
+io_buffer_map_file(struct rb_io_buffer *buffer, int descriptor, size_t size, rb_off_t offset, enum rb_io_buffer_flags flags)
{
#if defined(_WIN32)
HANDLE file = (HANDLE)_get_osfhandle(descriptor);
@@ -83,26 +96,28 @@ io_buffer_map_file(struct rb_io_buffer *data, int descriptor, size_t size, rb_of
DWORD protect = PAGE_READONLY, access = FILE_MAP_READ;
if (flags & RB_IO_BUFFER_READONLY) {
- data->flags |= RB_IO_BUFFER_READONLY;
+ buffer->flags |= RB_IO_BUFFER_READONLY;
}
else {
protect = PAGE_READWRITE;
access = FILE_MAP_WRITE;
}
- HANDLE mapping = CreateFileMapping(file, NULL, protect, 0, 0, NULL);
- if (!mapping) rb_sys_fail("io_buffer_map_descriptor:CreateFileMapping");
-
if (flags & RB_IO_BUFFER_PRIVATE) {
- access |= FILE_MAP_COPY;
- data->flags |= RB_IO_BUFFER_PRIVATE;
+ protect = PAGE_WRITECOPY;
+ access = FILE_MAP_COPY;
+ buffer->flags |= RB_IO_BUFFER_PRIVATE;
}
else {
- // This buffer refers to external data.
- data->flags |= RB_IO_BUFFER_EXTERNAL;
- data->flags |= RB_IO_BUFFER_SHARED;
+ // This buffer refers to external buffer.
+ buffer->flags |= RB_IO_BUFFER_EXTERNAL;
+ buffer->flags |= RB_IO_BUFFER_SHARED;
}
+ HANDLE mapping = CreateFileMapping(file, NULL, protect, 0, 0, NULL);
+ if (RB_IO_BUFFER_DEBUG) fprintf(stderr, "io_buffer_map_file:CreateFileMapping -> %p\n", mapping);
+ if (!mapping) rb_sys_fail("io_buffer_map_descriptor:CreateFileMapping");
+
void *base = MapViewOfFile(mapping, access, (DWORD)(offset >> 32), (DWORD)(offset & 0xFFFFFFFF), size);
if (!base) {
@@ -110,24 +125,25 @@ io_buffer_map_file(struct rb_io_buffer *data, int descriptor, size_t size, rb_of
rb_sys_fail("io_buffer_map_file:MapViewOfFile");
}
- data->mapping = mapping;
+ buffer->mapping = mapping;
#else
int protect = PROT_READ, access = 0;
if (flags & RB_IO_BUFFER_READONLY) {
- data->flags |= RB_IO_BUFFER_READONLY;
+ buffer->flags |= RB_IO_BUFFER_READONLY;
}
else {
protect |= PROT_WRITE;
}
if (flags & RB_IO_BUFFER_PRIVATE) {
- data->flags |= RB_IO_BUFFER_PRIVATE;
+ buffer->flags |= RB_IO_BUFFER_PRIVATE;
+ access |= MAP_PRIVATE;
}
else {
- // This buffer refers to external data.
- data->flags |= RB_IO_BUFFER_EXTERNAL;
- data->flags |= RB_IO_BUFFER_SHARED;
+ // This buffer refers to external buffer.
+ buffer->flags |= RB_IO_BUFFER_EXTERNAL;
+ buffer->flags |= RB_IO_BUFFER_SHARED;
access |= MAP_SHARED;
}
@@ -138,20 +154,11 @@ io_buffer_map_file(struct rb_io_buffer *data, int descriptor, size_t size, rb_of
}
#endif
- data->base = base;
- data->size = size;
+ buffer->base = base;
+ buffer->size = size;
- data->flags |= RB_IO_BUFFER_MAPPED;
-}
-
-static inline void
-io_buffer_unmap(void* base, size_t size)
-{
-#ifdef _WIN32
- VirtualFree(base, 0, MEM_RELEASE);
-#else
- munmap(base, size);
-#endif
+ buffer->flags |= RB_IO_BUFFER_MAPPED;
+ buffer->flags |= RB_IO_BUFFER_FILE;
}
static void
@@ -171,18 +178,18 @@ io_buffer_experimental(void)
}
static void
-io_buffer_zero(struct rb_io_buffer *data)
+io_buffer_zero(struct rb_io_buffer *buffer)
{
- data->base = NULL;
- data->size = 0;
+ buffer->base = NULL;
+ buffer->size = 0;
#if defined(_WIN32)
- data->mapping = NULL;
+ buffer->mapping = NULL;
#endif
- data->source = Qnil;
+ buffer->source = Qnil;
}
static void
-io_buffer_initialize(struct rb_io_buffer *data, void *base, size_t size, enum rb_io_buffer_flags flags, VALUE source)
+io_buffer_initialize(VALUE self, struct rb_io_buffer *buffer, void *base, size_t size, enum rb_io_buffer_flags flags, VALUE source)
{
if (base) {
// If we are provided a pointer, we use it.
@@ -205,73 +212,84 @@ io_buffer_initialize(struct rb_io_buffer *data, void *base, size_t size, enum rb
return;
}
- data->base = base;
- data->size = size;
- data->flags = flags;
- data->source = source;
+ buffer->base = base;
+ buffer->size = size;
+ buffer->flags = flags;
+ RB_OBJ_WRITE(self, &buffer->source, source);
+
+#if defined(_WIN32)
+ buffer->mapping = NULL;
+#endif
}
-static int
-io_buffer_free(struct rb_io_buffer *data)
+static void
+io_buffer_free(struct rb_io_buffer *buffer)
{
- if (data->base) {
- if (data->flags & RB_IO_BUFFER_INTERNAL) {
- free(data->base);
+ if (buffer->base) {
+ if (buffer->flags & RB_IO_BUFFER_INTERNAL) {
+ free(buffer->base);
}
- if (data->flags & RB_IO_BUFFER_MAPPED) {
- io_buffer_unmap(data->base, data->size);
+ if (buffer->flags & RB_IO_BUFFER_MAPPED) {
+#ifdef _WIN32
+ if (buffer->flags & RB_IO_BUFFER_FILE) {
+ UnmapViewOfFile(buffer->base);
+ }
+ else {
+ VirtualFree(buffer->base, 0, MEM_RELEASE);
+ }
+#else
+ munmap(buffer->base, buffer->size);
+#endif
}
// Previously we had this, but we found out due to the way GC works, we
// can't refer to any other Ruby objects here.
- // if (RB_TYPE_P(data->source, T_STRING)) {
- // rb_str_unlocktmp(data->source);
+ // if (RB_TYPE_P(buffer->source, T_STRING)) {
+ // rb_str_unlocktmp(buffer->source);
// }
- data->base = NULL;
+ buffer->base = NULL;
+
+ buffer->size = 0;
+ buffer->flags = 0;
+ buffer->source = Qnil;
+ }
#if defined(_WIN32)
- if (data->mapping) {
- CloseHandle(data->mapping);
- data->mapping = NULL;
+ if (buffer->mapping) {
+ if (RB_IO_BUFFER_DEBUG) fprintf(stderr, "io_buffer_free:CloseHandle -> %p\n", buffer->mapping);
+ if (!CloseHandle(buffer->mapping)) {
+ fprintf(stderr, "io_buffer_free:GetLastError -> %d\n", GetLastError());
}
-#endif
- data->size = 0;
- data->flags = 0;
- data->source = Qnil;
-
- return 1;
+ buffer->mapping = NULL;
}
-
- return 0;
+#endif
}
void
-rb_io_buffer_type_mark(void *_data)
+rb_io_buffer_type_mark(void *_buffer)
{
- struct rb_io_buffer *data = _data;
- rb_gc_mark(data->source);
+ struct rb_io_buffer *buffer = _buffer;
+ rb_gc_mark(buffer->source);
}
void
-rb_io_buffer_type_free(void *_data)
+rb_io_buffer_type_free(void *_buffer)
{
- struct rb_io_buffer *data = _data;
-
- io_buffer_free(data);
+ struct rb_io_buffer *buffer = _buffer;
- free(data);
+ io_buffer_free(buffer);
}
size_t
-rb_io_buffer_type_size(const void *_data)
+rb_io_buffer_type_size(const void *_buffer)
{
- const struct rb_io_buffer *data = _data;
+ const struct rb_io_buffer *buffer = _buffer;
size_t total = sizeof(struct rb_io_buffer);
- if (data->flags) {
- total += data->size;
+ if (buffer->flags) {
+ total += buffer->size;
}
return total;
@@ -285,34 +303,178 @@ static const rb_data_type_t rb_io_buffer_type = {
.dsize = rb_io_buffer_type_size,
},
.data = NULL,
- .flags = RUBY_TYPED_FREE_IMMEDIATELY,
+ .flags = RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_WB_PROTECTED | RUBY_TYPED_EMBEDDABLE,
};
+static inline enum rb_io_buffer_flags
+io_buffer_extract_flags(VALUE argument)
+{
+ if (rb_int_negative_p(argument)) {
+ rb_raise(rb_eArgError, "Flags can't be negative!");
+ }
+
+ enum rb_io_buffer_flags flags = RB_NUM2UINT(argument);
+
+ // We deliberately ignore unknown flags. Any future flags which are exposed this way should be safe to ignore.
+ return flags & RB_IO_BUFFER_FLAGS_MASK;
+}
+
+// Extract an offset argument, which must be a non-negative integer.
+static inline size_t
+io_buffer_extract_offset(VALUE argument)
+{
+ if (rb_int_negative_p(argument)) {
+ rb_raise(rb_eArgError, "Offset can't be negative!");
+ }
+
+ return NUM2SIZET(argument);
+}
+
+// Extract a length argument, which must be a non-negative integer.
+// Length is generally considered a mutable property of an object and
+// semantically should be considered a subset of "size" as a concept.
+static inline size_t
+io_buffer_extract_length(VALUE argument)
+{
+ if (rb_int_negative_p(argument)) {
+ rb_raise(rb_eArgError, "Length can't be negative!");
+ }
+
+ return NUM2SIZET(argument);
+}
+
+// Extract a size argument, which must be a non-negative integer.
+// Size is generally considered an immutable property of an object.
+static inline size_t
+io_buffer_extract_size(VALUE argument)
+{
+ if (rb_int_negative_p(argument)) {
+ rb_raise(rb_eArgError, "Size can't be negative!");
+ }
+
+ return NUM2SIZET(argument);
+}
+
+// Extract a width argument, which must be a non-negative integer, and must be
+// at least the given minimum.
+static inline size_t
+io_buffer_extract_width(VALUE argument, size_t minimum)
+{
+ if (rb_int_negative_p(argument)) {
+ rb_raise(rb_eArgError, "Width can't be negative!");
+ }
+
+ size_t width = NUM2SIZET(argument);
+
+ if (width < minimum) {
+ rb_raise(rb_eArgError, "Width must be at least %" PRIuSIZE "!", minimum);
+ }
+
+ return width;
+}
+
+// Compute the default length for a buffer, given an offset into that buffer.
+// The default length is the size of the buffer minus the offset. The offset
+// must be less than the size of the buffer otherwise the length will be
+// invalid; in that case, an ArgumentError exception will be raised.
+static inline size_t
+io_buffer_default_length(const struct rb_io_buffer *buffer, size_t offset)
+{
+ if (offset > buffer->size) {
+ rb_raise(rb_eArgError, "The given offset is bigger than the buffer size!");
+ }
+
+ // Note that the "length" is computed by the size the offset.
+ return buffer->size - offset;
+}
+
+// Extract the optional length and offset arguments, returning the buffer.
+// The length and offset are optional, but if they are provided, they must be
+// positive integers. If the length is not provided, the default length is
+// computed from the buffer size and offset. If the offset is not provided, it
+// defaults to zero.
+static inline struct rb_io_buffer *
+io_buffer_extract_length_offset(VALUE self, int argc, VALUE argv[], size_t *length, size_t *offset)
+{
+ struct rb_io_buffer *buffer = NULL;
+ TypedData_Get_Struct(self, struct rb_io_buffer, &rb_io_buffer_type, buffer);
+
+ if (argc >= 2 && !NIL_P(argv[1])) {
+ *offset = io_buffer_extract_offset(argv[1]);
+ }
+ else {
+ *offset = 0;
+ }
+
+ if (argc >= 1 && !NIL_P(argv[0])) {
+ *length = io_buffer_extract_length(argv[0]);
+ }
+ else {
+ *length = io_buffer_default_length(buffer, *offset);
+ }
+
+ return buffer;
+}
+
+// Extract the optional offset and length arguments, returning the buffer.
+// Similar to `io_buffer_extract_length_offset` but with the order of arguments
+// reversed.
+//
+// After much consideration, I decided to accept both forms.
+// The `(offset, length)` order is more natural when referring about data,
+// while the `(length, offset)` order is more natural when referring to
+// read/write operations. In many cases, with the latter form, `offset`
+// is usually not supplied.
+static inline struct rb_io_buffer *
+io_buffer_extract_offset_length(VALUE self, int argc, VALUE argv[], size_t *offset, size_t *length)
+{
+ struct rb_io_buffer *buffer = NULL;
+ TypedData_Get_Struct(self, struct rb_io_buffer, &rb_io_buffer_type, buffer);
+
+ if (argc >= 1 && !NIL_P(argv[0])) {
+ *offset = io_buffer_extract_offset(argv[0]);
+ }
+ else {
+ *offset = 0;
+ }
+
+ if (argc >= 2 && !NIL_P(argv[1])) {
+ *length = io_buffer_extract_length(argv[1]);
+ }
+ else {
+ *length = io_buffer_default_length(buffer, *offset);
+ }
+
+ return buffer;
+}
+
VALUE
rb_io_buffer_type_allocate(VALUE self)
{
- struct rb_io_buffer *data = NULL;
- VALUE instance = TypedData_Make_Struct(self, struct rb_io_buffer, &rb_io_buffer_type, data);
+ struct rb_io_buffer *buffer = NULL;
+ VALUE instance = TypedData_Make_Struct(self, struct rb_io_buffer, &rb_io_buffer_type, buffer);
- io_buffer_zero(data);
+ io_buffer_zero(buffer);
return instance;
}
-static VALUE
-io_buffer_for_make_instance(VALUE klass, VALUE string)
+static VALUE io_buffer_for_make_instance(VALUE klass, VALUE string, enum rb_io_buffer_flags flags)
{
VALUE instance = rb_io_buffer_type_allocate(klass);
- struct rb_io_buffer *data = NULL;
- TypedData_Get_Struct(instance, struct rb_io_buffer, &rb_io_buffer_type, data);
+ struct rb_io_buffer *buffer = NULL;
+ TypedData_Get_Struct(instance, struct rb_io_buffer, &rb_io_buffer_type, buffer);
- enum rb_io_buffer_flags flags = RB_IO_BUFFER_EXTERNAL;
+ flags |= RB_IO_BUFFER_EXTERNAL;
if (RB_OBJ_FROZEN(string))
flags |= RB_IO_BUFFER_READONLY;
- io_buffer_initialize(data, RSTRING_PTR(string), RSTRING_LEN(string), flags, string);
+ if (!(flags & RB_IO_BUFFER_READONLY))
+ rb_str_modify(string);
+
+ io_buffer_initialize(instance, buffer, RSTRING_PTR(string), RSTRING_LEN(string), flags, string);
return instance;
}
@@ -321,6 +483,7 @@ struct io_buffer_for_yield_instance_arguments {
VALUE klass;
VALUE string;
VALUE instance;
+ enum rb_io_buffer_flags flags;
};
static VALUE
@@ -328,9 +491,9 @@ io_buffer_for_yield_instance(VALUE _arguments)
{
struct io_buffer_for_yield_instance_arguments *arguments = (struct io_buffer_for_yield_instance_arguments *)_arguments;
- rb_str_locktmp(arguments->string);
+ arguments->instance = io_buffer_for_make_instance(arguments->klass, arguments->string, arguments->flags);
- arguments->instance = io_buffer_for_make_instance(arguments->klass, arguments->string);
+ rb_str_locktmp(arguments->string);
return rb_yield(arguments->instance);
}
@@ -354,17 +517,18 @@ io_buffer_for_yield_instance_ensure(VALUE _arguments)
* IO::Buffer.for(string) -> readonly io_buffer
* IO::Buffer.for(string) {|io_buffer| ... read/write io_buffer ...}
*
- * Creates a IO::Buffer from the given string's memory. Without a block a
- * frozen internal copy of the string is created efficiently and used as the
- * buffer source. When a block is provided, the buffer is associated directly
- * with the string's internal data and updating the buffer will update the
- * string.
+ * Creates a zero-copy IO::Buffer from the given string's memory. Without a
+ * block a frozen internal copy of the string is created efficiently and used
+ * as the buffer source. When a block is provided, the buffer is associated
+ * directly with the string's internal buffer and updating the buffer will
+ * update the string.
*
* Until #free is invoked on the buffer, either explicitly or via the garbage
* collector, the source string will be locked and cannot be modified.
*
* If the string is frozen, it will create a read-only buffer which cannot be
- * modified.
+ * modified. If the string is shared, it may trigger a copy-on-write when
+ * using the block form.
*
* string = 'test'
* buffer = IO::Buffer.for(string)
@@ -396,6 +560,7 @@ rb_io_buffer_type_for(VALUE klass, VALUE string)
.klass = klass,
.string = string,
.instance = Qnil,
+ .flags = 0,
};
return rb_ensure(io_buffer_for_yield_instance, (VALUE)&arguments, io_buffer_for_yield_instance_ensure, (VALUE)&arguments);
@@ -403,19 +568,48 @@ rb_io_buffer_type_for(VALUE klass, VALUE string)
else {
// This internally returns the source string if it's already frozen.
string = rb_str_tmp_frozen_acquire(string);
- return io_buffer_for_make_instance(klass, string);
+ return io_buffer_for_make_instance(klass, string, RB_IO_BUFFER_READONLY);
}
}
+/*
+ * call-seq:
+ * IO::Buffer.string(length) {|io_buffer| ... read/write io_buffer ...} -> string
+ *
+ * Creates a new string of the given length and yields a zero-copy IO::Buffer
+ * instance to the block which uses the string as a source. The block is
+ * expected to write to the buffer and the string will be returned.
+ *
+ * IO::Buffer.string(4) do |buffer|
+ * buffer.set_string("Ruby")
+ * end
+ * # => "Ruby"
+ */
+VALUE
+rb_io_buffer_type_string(VALUE klass, VALUE length)
+{
+ VALUE string = rb_str_new(NULL, RB_NUM2LONG(length));
+
+ struct io_buffer_for_yield_instance_arguments arguments = {
+ .klass = klass,
+ .string = string,
+ .instance = Qnil,
+ };
+
+ rb_ensure(io_buffer_for_yield_instance, (VALUE)&arguments, io_buffer_for_yield_instance_ensure, (VALUE)&arguments);
+
+ return string;
+}
+
VALUE
rb_io_buffer_new(void *base, size_t size, enum rb_io_buffer_flags flags)
{
VALUE instance = rb_io_buffer_type_allocate(rb_cIOBuffer);
- struct rb_io_buffer *data = NULL;
- TypedData_Get_Struct(instance, struct rb_io_buffer, &rb_io_buffer_type, data);
+ struct rb_io_buffer *buffer = NULL;
+ TypedData_Get_Struct(instance, struct rb_io_buffer, &rb_io_buffer_type, buffer);
- io_buffer_initialize(data, base, size, flags, Qnil);
+ io_buffer_initialize(instance, buffer, base, size, flags, Qnil);
return instance;
}
@@ -427,12 +621,12 @@ rb_io_buffer_map(VALUE io, size_t size, rb_off_t offset, enum rb_io_buffer_flags
VALUE instance = rb_io_buffer_type_allocate(rb_cIOBuffer);
- struct rb_io_buffer *data = NULL;
- TypedData_Get_Struct(instance, struct rb_io_buffer, &rb_io_buffer_type, data);
+ struct rb_io_buffer *buffer = NULL;
+ TypedData_Get_Struct(instance, struct rb_io_buffer, &rb_io_buffer_type, buffer);
int descriptor = rb_io_descriptor(io);
- io_buffer_map_file(data, descriptor, size, offset, flags);
+ io_buffer_map_file(buffer, descriptor, size, offset, flags);
return instance;
}
@@ -449,8 +643,6 @@ rb_io_buffer_map(VALUE io, size_t size, rb_off_t offset, enum rb_io_buffer_flags
* mapping, you need to open a file in read-write mode, and explicitly pass
* +flags+ argument without IO::Buffer::IMMUTABLE.
*
- * Example:
- *
* File.write('test.txt', 'test')
*
* buffer = IO::Buffer.map(File.open('test.txt'), nil, 0, IO::Buffer::READONLY)
@@ -486,7 +678,7 @@ io_buffer_map(int argc, VALUE *argv, VALUE klass)
size_t size;
if (argc >= 2 && !RB_NIL_P(argv[1])) {
- size = RB_NUM2SIZE(argv[1]);
+ size = io_buffer_extract_size(argv[1]);
}
else {
rb_off_t file_size = rb_file_size(io);
@@ -505,6 +697,7 @@ io_buffer_map(int argc, VALUE *argv, VALUE klass)
}
}
+ // This is the file offset, not the buffer offset:
rb_off_t offset = 0;
if (argc >= 3) {
offset = NUM2OFFT(argv[2]);
@@ -512,7 +705,7 @@ io_buffer_map(int argc, VALUE *argv, VALUE klass)
enum rb_io_buffer_flags flags = 0;
if (argc >= 4) {
- flags = RB_NUM2UINT(argv[3]);
+ flags = io_buffer_extract_flags(argv[3]);
}
return rb_io_buffer_map(io, size, offset, flags);
@@ -540,8 +733,6 @@ io_flags_for_size(size_t size)
* on Windows). The behavior can be forced by passing IO::Buffer::MAPPED
* as a second parameter.
*
- * Examples
- *
* buffer = IO::Buffer.new(4)
* # =>
* # #<IO::Buffer 0x000055b34497ea10+4 INTERNAL>
@@ -562,13 +753,12 @@ rb_io_buffer_initialize(int argc, VALUE *argv, VALUE self)
rb_check_arity(argc, 0, 2);
- struct rb_io_buffer *data = NULL;
- TypedData_Get_Struct(self, struct rb_io_buffer, &rb_io_buffer_type, data);
+ struct rb_io_buffer *buffer = NULL;
+ TypedData_Get_Struct(self, struct rb_io_buffer, &rb_io_buffer_type, buffer);
size_t size;
-
if (argc > 0) {
- size = RB_NUM2SIZE(argv[0]);
+ size = io_buffer_extract_size(argv[0]);
}
else {
size = RUBY_IO_BUFFER_DEFAULT_SIZE;
@@ -576,13 +766,13 @@ rb_io_buffer_initialize(int argc, VALUE *argv, VALUE self)
enum rb_io_buffer_flags flags = 0;
if (argc >= 2) {
- flags = RB_NUM2UINT(argv[1]);
+ flags = io_buffer_extract_flags(argv[1]);
}
else {
flags |= io_flags_for_size(size);
}
- io_buffer_initialize(data, NULL, size, flags, Qnil);
+ io_buffer_initialize(self, buffer, NULL, size, flags, Qnil);
return self;
}
@@ -617,17 +807,93 @@ io_buffer_validate_slice(VALUE source, void *base, size_t size)
}
static int
-io_buffer_validate(struct rb_io_buffer *data)
+io_buffer_validate(struct rb_io_buffer *buffer)
{
- if (data->source != Qnil) {
+ if (buffer->source != Qnil) {
// Only slices incur this overhead, unfortunately... better safe than sorry!
- return io_buffer_validate_slice(data->source, data->base, data->size);
+ return io_buffer_validate_slice(buffer->source, buffer->base, buffer->size);
}
else {
return 1;
}
}
+enum rb_io_buffer_flags
+rb_io_buffer_get_bytes(VALUE self, void **base, size_t *size)
+{
+ struct rb_io_buffer *buffer = NULL;
+ TypedData_Get_Struct(self, struct rb_io_buffer, &rb_io_buffer_type, buffer);
+
+ if (io_buffer_validate(buffer)) {
+ if (buffer->base) {
+ *base = buffer->base;
+ *size = buffer->size;
+
+ return buffer->flags;
+ }
+ }
+
+ *base = NULL;
+ *size = 0;
+
+ return 0;
+}
+
+// Internal function for accessing bytes for writing, wil
+static inline void
+io_buffer_get_bytes_for_writing(struct rb_io_buffer *buffer, void **base, size_t *size)
+{
+ if (buffer->flags & RB_IO_BUFFER_READONLY) {
+ rb_raise(rb_eIOBufferAccessError, "Buffer is not writable!");
+ }
+
+ if (!io_buffer_validate(buffer)) {
+ rb_raise(rb_eIOBufferInvalidatedError, "Buffer is invalid!");
+ }
+
+ if (buffer->base) {
+ *base = buffer->base;
+ *size = buffer->size;
+ } else {
+ *base = NULL;
+ *size = 0;
+ }
+}
+
+void
+rb_io_buffer_get_bytes_for_writing(VALUE self, void **base, size_t *size)
+{
+ struct rb_io_buffer *buffer = NULL;
+ TypedData_Get_Struct(self, struct rb_io_buffer, &rb_io_buffer_type, buffer);
+
+ io_buffer_get_bytes_for_writing(buffer, base, size);
+}
+
+static void
+io_buffer_get_bytes_for_reading(struct rb_io_buffer *buffer, const void **base, size_t *size)
+{
+ if (!io_buffer_validate(buffer)) {
+ rb_raise(rb_eIOBufferInvalidatedError, "Buffer has been invalidated!");
+ }
+
+ if (buffer->base) {
+ *base = buffer->base;
+ *size = buffer->size;
+ } else {
+ *base = NULL;
+ *size = 0;
+ }
+}
+
+void
+rb_io_buffer_get_bytes_for_reading(VALUE self, const void **base, size_t *size)
+{
+ struct rb_io_buffer *buffer = NULL;
+ TypedData_Get_Struct(self, struct rb_io_buffer, &rb_io_buffer_type, buffer);
+
+ io_buffer_get_bytes_for_reading(buffer, base, size);
+}
+
/*
* call-seq: to_s -> string
*
@@ -640,60 +906,93 @@ io_buffer_validate(struct rb_io_buffer *data)
VALUE
rb_io_buffer_to_s(VALUE self)
{
- struct rb_io_buffer *data = NULL;
- TypedData_Get_Struct(self, struct rb_io_buffer, &rb_io_buffer_type, data);
+ struct rb_io_buffer *buffer = NULL;
+ TypedData_Get_Struct(self, struct rb_io_buffer, &rb_io_buffer_type, buffer);
VALUE result = rb_str_new_cstr("#<");
rb_str_append(result, rb_class_name(CLASS_OF(self)));
- rb_str_catf(result, " %p+%"PRIdSIZE, data->base, data->size);
+ rb_str_catf(result, " %p+%"PRIdSIZE, buffer->base, buffer->size);
- if (data->base == NULL) {
+ if (buffer->base == NULL) {
rb_str_cat2(result, " NULL");
}
- if (data->flags & RB_IO_BUFFER_EXTERNAL) {
+ if (buffer->flags & RB_IO_BUFFER_EXTERNAL) {
rb_str_cat2(result, " EXTERNAL");
}
- if (data->flags & RB_IO_BUFFER_INTERNAL) {
+ if (buffer->flags & RB_IO_BUFFER_INTERNAL) {
rb_str_cat2(result, " INTERNAL");
}
- if (data->flags & RB_IO_BUFFER_MAPPED) {
+ if (buffer->flags & RB_IO_BUFFER_MAPPED) {
rb_str_cat2(result, " MAPPED");
}
- if (data->flags & RB_IO_BUFFER_SHARED) {
+ if (buffer->flags & RB_IO_BUFFER_FILE) {
+ rb_str_cat2(result, " FILE");
+ }
+
+ if (buffer->flags & RB_IO_BUFFER_SHARED) {
rb_str_cat2(result, " SHARED");
}
- if (data->flags & RB_IO_BUFFER_LOCKED) {
+ if (buffer->flags & RB_IO_BUFFER_LOCKED) {
rb_str_cat2(result, " LOCKED");
}
- if (data->flags & RB_IO_BUFFER_READONLY) {
+ if (buffer->flags & RB_IO_BUFFER_PRIVATE) {
+ rb_str_cat2(result, " PRIVATE");
+ }
+
+ if (buffer->flags & RB_IO_BUFFER_READONLY) {
rb_str_cat2(result, " READONLY");
}
- if (data->source != Qnil) {
+ if (buffer->source != Qnil) {
rb_str_cat2(result, " SLICE");
}
- if (!io_buffer_validate(data)) {
+ if (!io_buffer_validate(buffer)) {
rb_str_cat2(result, " INVALID");
}
return rb_str_cat2(result, ">");
}
+// Compute the output size of a hexdump of the given width (bytes per line), total size, and whether it is the first line in the output.
+// This is used to preallocate the output string.
+inline static size_t
+io_buffer_hexdump_output_size(size_t width, size_t size, int first)
+{
+ // The preview on the right hand side is 1:1:
+ size_t total = size;
+
+ size_t whole_lines = (size / width);
+ size_t partial_line = (size % width) ? 1 : 0;
+
+ // For each line:
+ // 1 byte 10 bytes 1 byte width*3 bytes 1 byte size bytes
+ // (newline) (address) (space) (hexdump ) (space) (preview)
+ total += (whole_lines + partial_line) * (1 + 10 + width*3 + 1 + 1);
+
+ // If the hexdump is the first line, one less newline will be emitted:
+ if (size && first) total -= 1;
+
+ return total;
+}
+
+// Append a hexdump of the given width (bytes per line), base address, size, and whether it is the first line in the output.
+// If the hexdump is not the first line, it will prepend a newline if there is any output at all.
+// If formatting here is adjusted, please update io_buffer_hexdump_output_size accordingly.
static VALUE
-io_buffer_hexdump(VALUE string, size_t width, char *base, size_t size, int first)
+io_buffer_hexdump(VALUE string, size_t width, const char *base, size_t length, size_t offset, int first)
{
char *text = alloca(width+1);
text[width] = '\0';
- for (size_t offset = 0; offset < size; offset += width) {
+ for (; offset < length; offset += width) {
memset(text, '\0', width);
if (first) {
rb_str_catf(string, "0x%08" PRIxSIZE " ", offset);
@@ -704,7 +1003,7 @@ io_buffer_hexdump(VALUE string, size_t width, char *base, size_t size, int first
}
for (size_t i = 0; i < width; i += 1) {
- if (offset+i < size) {
+ if (offset+i < length) {
unsigned char value = ((unsigned char*)base)[offset+i];
if (value < 127 && isprint(value)) {
@@ -727,35 +1026,40 @@ io_buffer_hexdump(VALUE string, size_t width, char *base, size_t size, int first
return string;
}
-static VALUE
-rb_io_buffer_hexdump(VALUE self)
-{
- struct rb_io_buffer *data = NULL;
- TypedData_Get_Struct(self, struct rb_io_buffer, &rb_io_buffer_type, data);
-
- VALUE result = Qnil;
-
- if (io_buffer_validate(data) && data->base) {
- result = rb_str_buf_new(data->size*3 + (data->size/16)*12 + 1);
-
- io_buffer_hexdump(result, 16, data->base, data->size, 1);
- }
-
- return result;
-}
-
+/*
+ * call-seq: inspect -> string
+ *
+ * Inspect the buffer and report useful information about it's internal state.
+ * Only a limited portion of the buffer will be displayed in a hexdump style
+ * format.
+ *
+ * buffer = IO::Buffer.for("Hello World")
+ * puts buffer.inspect
+ * # #<IO::Buffer 0x000000010198ccd8+11 EXTERNAL READONLY SLICE>
+ * # 0x00000000 48 65 6c 6c 6f 20 57 6f 72 6c 64 Hello World
+ */
VALUE
rb_io_buffer_inspect(VALUE self)
{
- struct rb_io_buffer *data = NULL;
- TypedData_Get_Struct(self, struct rb_io_buffer, &rb_io_buffer_type, data);
+ struct rb_io_buffer *buffer = NULL;
+ TypedData_Get_Struct(self, struct rb_io_buffer, &rb_io_buffer_type, buffer);
VALUE result = rb_io_buffer_to_s(self);
- if (io_buffer_validate(data)) {
- // Limit the maximum size genearted by inspect.
- if (data->size <= 256) {
- io_buffer_hexdump(result, 16, data->base, data->size, 0);
+ if (io_buffer_validate(buffer)) {
+ // Limit the maximum size generated by inspect:
+ size_t size = buffer->size;
+ int clamped = 0;
+
+ if (size > RB_IO_BUFFER_INSPECT_HEXDUMP_MAXIMUM_SIZE) {
+ size = RB_IO_BUFFER_INSPECT_HEXDUMP_MAXIMUM_SIZE;
+ clamped = 1;
+ }
+
+ io_buffer_hexdump(result, RB_IO_BUFFER_INSPECT_HEXDUMP_WIDTH, buffer->base, size, 0, 0);
+
+ if (clamped) {
+ rb_str_catf(result, "\n(and %" PRIuSIZE " more bytes not printed)", buffer->size - size);
}
}
@@ -771,42 +1075,50 @@ rb_io_buffer_inspect(VALUE self)
VALUE
rb_io_buffer_size(VALUE self)
{
- struct rb_io_buffer *data = NULL;
- TypedData_Get_Struct(self, struct rb_io_buffer, &rb_io_buffer_type, data);
+ struct rb_io_buffer *buffer = NULL;
+ TypedData_Get_Struct(self, struct rb_io_buffer, &rb_io_buffer_type, buffer);
- return SIZET2NUM(data->size);
+ return SIZET2NUM(buffer->size);
}
/*
* call-seq: valid? -> true or false
*
- * Returns whether the buffer data is accessible.
+ * Returns whether the buffer buffer is accessible.
*
- * A buffer becomes invalid if it is a slice of another buffer which has been
- * freed.
+ * A buffer becomes invalid if it is a slice of another buffer (or string)
+ * which has been freed or re-allocated at a different address.
*/
static VALUE
rb_io_buffer_valid_p(VALUE self)
{
- struct rb_io_buffer *data = NULL;
- TypedData_Get_Struct(self, struct rb_io_buffer, &rb_io_buffer_type, data);
+ struct rb_io_buffer *buffer = NULL;
+ TypedData_Get_Struct(self, struct rb_io_buffer, &rb_io_buffer_type, buffer);
- return RBOOL(io_buffer_validate(data));
+ return RBOOL(io_buffer_validate(buffer));
}
/*
* call-seq: null? -> true or false
*
- * If the buffer was freed with #free or was never allocated in the first
- * place.
+ * If the buffer was freed with #free, transferred with #transfer, or was
+ * never allocated in the first place.
+ *
+ * buffer = IO::Buffer.new(0)
+ * buffer.null? #=> true
+ *
+ * buffer = IO::Buffer.new(4)
+ * buffer.null? #=> false
+ * buffer.free
+ * buffer.null? #=> true
*/
static VALUE
rb_io_buffer_null_p(VALUE self)
{
- struct rb_io_buffer *data = NULL;
- TypedData_Get_Struct(self, struct rb_io_buffer, &rb_io_buffer_type, data);
+ struct rb_io_buffer *buffer = NULL;
+ TypedData_Get_Struct(self, struct rb_io_buffer, &rb_io_buffer_type, buffer);
- return RBOOL(data->base == NULL);
+ return RBOOL(buffer->base == NULL);
}
/*
@@ -819,10 +1131,10 @@ rb_io_buffer_null_p(VALUE self)
static VALUE
rb_io_buffer_empty_p(VALUE self)
{
- struct rb_io_buffer *data = NULL;
- TypedData_Get_Struct(self, struct rb_io_buffer, &rb_io_buffer_type, data);
+ struct rb_io_buffer *buffer = NULL;
+ TypedData_Get_Struct(self, struct rb_io_buffer, &rb_io_buffer_type, buffer);
- return RBOOL(data->size == 0);
+ return RBOOL(buffer->size == 0);
}
/*
@@ -839,10 +1151,10 @@ rb_io_buffer_empty_p(VALUE self)
static VALUE
rb_io_buffer_external_p(VALUE self)
{
- struct rb_io_buffer *data = NULL;
- TypedData_Get_Struct(self, struct rb_io_buffer, &rb_io_buffer_type, data);
+ struct rb_io_buffer *buffer = NULL;
+ TypedData_Get_Struct(self, struct rb_io_buffer, &rb_io_buffer_type, buffer);
- return RBOOL(data->flags & RB_IO_BUFFER_EXTERNAL);
+ return RBOOL(buffer->flags & RB_IO_BUFFER_EXTERNAL);
}
/*
@@ -864,10 +1176,10 @@ rb_io_buffer_external_p(VALUE self)
static VALUE
rb_io_buffer_internal_p(VALUE self)
{
- struct rb_io_buffer *data = NULL;
- TypedData_Get_Struct(self, struct rb_io_buffer, &rb_io_buffer_type, data);
+ struct rb_io_buffer *buffer = NULL;
+ TypedData_Get_Struct(self, struct rb_io_buffer, &rb_io_buffer_type, buffer);
- return RBOOL(data->flags & RB_IO_BUFFER_INTERNAL);
+ return RBOOL(buffer->flags & RB_IO_BUFFER_INTERNAL);
}
/*
@@ -886,10 +1198,10 @@ rb_io_buffer_internal_p(VALUE self)
static VALUE
rb_io_buffer_mapped_p(VALUE self)
{
- struct rb_io_buffer *data = NULL;
- TypedData_Get_Struct(self, struct rb_io_buffer, &rb_io_buffer_type, data);
+ struct rb_io_buffer *buffer = NULL;
+ TypedData_Get_Struct(self, struct rb_io_buffer, &rb_io_buffer_type, buffer);
- return RBOOL(data->flags & RB_IO_BUFFER_MAPPED);
+ return RBOOL(buffer->flags & RB_IO_BUFFER_MAPPED);
}
/*
@@ -898,14 +1210,30 @@ rb_io_buffer_mapped_p(VALUE self)
* If the buffer is _shared_, meaning it references memory that can be shared
* with other processes (and thus might change without being modified
* locally).
+ *
+ * # Create a test file:
+ * File.write('test.txt', 'test')
+ *
+ * # Create a shared mapping from the given file, the file must be opened in
+ * # read-write mode unless we also specify IO::Buffer::READONLY:
+ * buffer = IO::Buffer.map(File.open('test.txt', 'r+'), nil, 0)
+ * # => #<IO::Buffer 0x00007f1bffd5e000+4 EXTERNAL MAPPED SHARED>
+ *
+ * # Write to the buffer, which will modify the mapped file:
+ * buffer.set_string('b', 0)
+ * # => 1
+ *
+ * # The file itself is modified:
+ * File.read('test.txt')
+ * # => "best"
*/
static VALUE
rb_io_buffer_shared_p(VALUE self)
{
- struct rb_io_buffer *data = NULL;
- TypedData_Get_Struct(self, struct rb_io_buffer, &rb_io_buffer_type, data);
+ struct rb_io_buffer *buffer = NULL;
+ TypedData_Get_Struct(self, struct rb_io_buffer, &rb_io_buffer_type, buffer);
- return RBOOL(data->flags & RB_IO_BUFFER_SHARED);
+ return RBOOL(buffer->flags & RB_IO_BUFFER_SHARED);
}
/*
@@ -918,8 +1246,6 @@ rb_io_buffer_shared_p(VALUE self)
* Locking is not thread safe, but is a semantic used to ensure buffers don't
* move while being used by a system call.
*
- * Example:
- *
* buffer.locked do
* buffer.write(io) # theoretical system call interface
* end
@@ -927,19 +1253,50 @@ rb_io_buffer_shared_p(VALUE self)
static VALUE
rb_io_buffer_locked_p(VALUE self)
{
- struct rb_io_buffer *data = NULL;
- TypedData_Get_Struct(self, struct rb_io_buffer, &rb_io_buffer_type, data);
+ struct rb_io_buffer *buffer = NULL;
+ TypedData_Get_Struct(self, struct rb_io_buffer, &rb_io_buffer_type, buffer);
+
+ return RBOOL(buffer->flags & RB_IO_BUFFER_LOCKED);
+}
+
+/* call-seq: private? -> true or false
+ *
+ * If the buffer is _private_, meaning modifications to the buffer will not
+ * be replicated to the underlying file mapping.
+ *
+ * # Create a test file:
+ * File.write('test.txt', 'test')
+ *
+ * # Create a private mapping from the given file. Note that the file here
+ * # is opened in read-only mode, but it doesn't matter due to the private
+ * # mapping:
+ * buffer = IO::Buffer.map(File.open('test.txt'), nil, 0, IO::Buffer::PRIVATE)
+ * # => #<IO::Buffer 0x00007fce63f11000+4 MAPPED PRIVATE>
+ *
+ * # Write to the buffer (invoking CoW of the underlying file buffer):
+ * buffer.set_string('b', 0)
+ * # => 1
+ *
+ * # The file itself is not modified:
+ * File.read('test.txt')
+ * # => "test"
+ */
+static VALUE
+rb_io_buffer_private_p(VALUE self)
+{
+ struct rb_io_buffer *buffer = NULL;
+ TypedData_Get_Struct(self, struct rb_io_buffer, &rb_io_buffer_type, buffer);
- return RBOOL(data->flags & RB_IO_BUFFER_LOCKED);
+ return RBOOL(buffer->flags & RB_IO_BUFFER_PRIVATE);
}
int
rb_io_buffer_readonly_p(VALUE self)
{
- struct rb_io_buffer *data = NULL;
- TypedData_Get_Struct(self, struct rb_io_buffer, &rb_io_buffer_type, data);
+ struct rb_io_buffer *buffer = NULL;
+ TypedData_Get_Struct(self, struct rb_io_buffer, &rb_io_buffer_type, buffer);
- return data->flags & RB_IO_BUFFER_READONLY;
+ return buffer->flags & RB_IO_BUFFER_READONLY;
}
/*
@@ -956,32 +1313,44 @@ io_buffer_readonly_p(VALUE self)
return RBOOL(rb_io_buffer_readonly_p(self));
}
-VALUE
-rb_io_buffer_lock(VALUE self)
+static void
+io_buffer_lock(struct rb_io_buffer *buffer)
{
- struct rb_io_buffer *data = NULL;
- TypedData_Get_Struct(self, struct rb_io_buffer, &rb_io_buffer_type, data);
-
- if (data->flags & RB_IO_BUFFER_LOCKED) {
+ if (buffer->flags & RB_IO_BUFFER_LOCKED) {
rb_raise(rb_eIOBufferLockedError, "Buffer already locked!");
}
- data->flags |= RB_IO_BUFFER_LOCKED;
-
- return self;
+ buffer->flags |= RB_IO_BUFFER_LOCKED;
}
VALUE
-rb_io_buffer_unlock(VALUE self)
+rb_io_buffer_lock(VALUE self)
{
- struct rb_io_buffer *data = NULL;
- TypedData_Get_Struct(self, struct rb_io_buffer, &rb_io_buffer_type, data);
+ struct rb_io_buffer *buffer = NULL;
+ TypedData_Get_Struct(self, struct rb_io_buffer, &rb_io_buffer_type, buffer);
- if (!(data->flags & RB_IO_BUFFER_LOCKED)) {
+ io_buffer_lock(buffer);
+
+ return self;
+}
+
+static void
+io_buffer_unlock(struct rb_io_buffer *buffer)
+{
+ if (!(buffer->flags & RB_IO_BUFFER_LOCKED)) {
rb_raise(rb_eIOBufferLockedError, "Buffer not locked!");
}
- data->flags &= ~RB_IO_BUFFER_LOCKED;
+ buffer->flags &= ~RB_IO_BUFFER_LOCKED;
+}
+
+VALUE
+rb_io_buffer_unlock(VALUE self)
+{
+ struct rb_io_buffer *buffer = NULL;
+ TypedData_Get_Struct(self, struct rb_io_buffer, &rb_io_buffer_type, buffer);
+
+ io_buffer_unlock(buffer);
return self;
}
@@ -989,11 +1358,11 @@ rb_io_buffer_unlock(VALUE self)
int
rb_io_buffer_try_unlock(VALUE self)
{
- struct rb_io_buffer *data = NULL;
- TypedData_Get_Struct(self, struct rb_io_buffer, &rb_io_buffer_type, data);
+ struct rb_io_buffer *buffer = NULL;
+ TypedData_Get_Struct(self, struct rb_io_buffer, &rb_io_buffer_type, buffer);
- if (data->flags & RB_IO_BUFFER_LOCKED) {
- data->flags &= ~RB_IO_BUFFER_LOCKED;
+ if (buffer->flags & RB_IO_BUFFER_LOCKED) {
+ buffer->flags &= ~RB_IO_BUFFER_LOCKED;
return 1;
}
@@ -1014,8 +1383,6 @@ rb_io_buffer_try_unlock(VALUE self)
* non-blocking system calls. You can only share a buffer between threads with
* appropriate synchronisation techniques.
*
- * Example:
- *
* buffer = IO::Buffer.new(4)
* buffer.locked? #=> false
*
@@ -1035,18 +1402,18 @@ rb_io_buffer_try_unlock(VALUE self)
VALUE
rb_io_buffer_locked(VALUE self)
{
- struct rb_io_buffer *data = NULL;
- TypedData_Get_Struct(self, struct rb_io_buffer, &rb_io_buffer_type, data);
+ struct rb_io_buffer *buffer = NULL;
+ TypedData_Get_Struct(self, struct rb_io_buffer, &rb_io_buffer_type, buffer);
- if (data->flags & RB_IO_BUFFER_LOCKED) {
+ if (buffer->flags & RB_IO_BUFFER_LOCKED) {
rb_raise(rb_eIOBufferLockedError, "Buffer already locked!");
}
- data->flags |= RB_IO_BUFFER_LOCKED;
+ buffer->flags |= RB_IO_BUFFER_LOCKED;
VALUE result = rb_yield(self);
- data->flags &= ~RB_IO_BUFFER_LOCKED;
+ buffer->flags &= ~RB_IO_BUFFER_LOCKED;
return result;
}
@@ -1063,8 +1430,6 @@ rb_io_buffer_locked(VALUE self)
*
* You can resize a freed buffer to re-allocate it.
*
- * Example:
- *
* buffer = IO::Buffer.for('test')
* buffer.free
* # => #<IO::Buffer 0x0000000000000000+0 NULL>
@@ -1081,14 +1446,25 @@ rb_io_buffer_locked(VALUE self)
VALUE
rb_io_buffer_free(VALUE self)
{
- struct rb_io_buffer *data = NULL;
- TypedData_Get_Struct(self, struct rb_io_buffer, &rb_io_buffer_type, data);
+ struct rb_io_buffer *buffer = NULL;
+ TypedData_Get_Struct(self, struct rb_io_buffer, &rb_io_buffer_type, buffer);
- if (data->flags & RB_IO_BUFFER_LOCKED) {
+ if (buffer->flags & RB_IO_BUFFER_LOCKED) {
rb_raise(rb_eIOBufferLockedError, "Buffer is locked!");
}
- io_buffer_free(data);
+ io_buffer_free(buffer);
+
+ return self;
+}
+
+VALUE rb_io_buffer_free_locked(VALUE self)
+{
+ struct rb_io_buffer *buffer = NULL;
+ TypedData_Get_Struct(self, struct rb_io_buffer, &rb_io_buffer_type, buffer);
+
+ io_buffer_unlock(buffer);
+ io_buffer_free(buffer);
return self;
}
@@ -1096,36 +1472,82 @@ rb_io_buffer_free(VALUE self)
// Validate that access to the buffer is within bounds, assuming you want to
// access length bytes from the specified offset.
static inline void
-io_buffer_validate_range(struct rb_io_buffer *data, size_t offset, size_t length)
+io_buffer_validate_range(struct rb_io_buffer *buffer, size_t offset, size_t length)
{
- if (offset + length > data->size) {
- rb_raise(rb_eArgError, "Specified offset+length exceeds data size!");
+ // We assume here that offset + length won't overflow:
+ if (offset + length > buffer->size) {
+ rb_raise(rb_eArgError, "Specified offset+length is bigger than the buffer size!");
}
}
+/*
+ * call-seq: hexdump([offset, [length, [width]]]) -> string
+ *
+ * Returns a human-readable string representation of the buffer. The exact
+ * format is subject to change.
+ *
+ * buffer = IO::Buffer.for("Hello World")
+ * puts buffer.hexdump
+ * # 0x00000000 48 65 6c 6c 6f 20 57 6f 72 6c 64 Hello World
+ *
+ * As buffers are usually fairly big, you may want to limit the output by
+ * specifying the offset and length:
+ *
+ * puts buffer.hexdump(6, 5)
+ * # 0x00000006 57 6f 72 6c 64 World
+ */
static VALUE
-rb_io_buffer_slice(struct rb_io_buffer *data, VALUE self, size_t offset, size_t length)
+rb_io_buffer_hexdump(int argc, VALUE *argv, VALUE self)
{
- io_buffer_validate_range(data, offset, length);
+ rb_check_arity(argc, 0, 3);
+
+ size_t offset, length;
+ struct rb_io_buffer *buffer = io_buffer_extract_offset_length(self, argc, argv, &offset, &length);
+
+ size_t width = RB_IO_BUFFER_HEXDUMP_DEFAULT_WIDTH;
+ if (argc >= 3) {
+ width = io_buffer_extract_width(argv[2], 1);
+ }
+
+ // This may raise an exception if the offset/length is invalid:
+ io_buffer_validate_range(buffer, offset, length);
+
+ VALUE result = Qnil;
+
+ if (io_buffer_validate(buffer) && buffer->base) {
+ result = rb_str_buf_new(io_buffer_hexdump_output_size(width, length, 1));
+
+ io_buffer_hexdump(result, width, buffer->base, offset+length, offset, 1);
+ }
+
+ return result;
+}
+
+static VALUE
+rb_io_buffer_slice(struct rb_io_buffer *buffer, VALUE self, size_t offset, size_t length)
+{
+ io_buffer_validate_range(buffer, offset, length);
VALUE instance = rb_io_buffer_type_allocate(rb_class_of(self));
struct rb_io_buffer *slice = NULL;
TypedData_Get_Struct(instance, struct rb_io_buffer, &rb_io_buffer_type, slice);
- slice->base = (char*)data->base + offset;
+ slice->base = (char*)buffer->base + offset;
slice->size = length;
// The source should be the root buffer:
- if (data->source != Qnil)
- slice->source = data->source;
- else
- slice->source = self;
+ if (buffer->source != Qnil) {
+ RB_OBJ_WRITE(instance, &slice->source, buffer->source);
+ }
+ else {
+ RB_OBJ_WRITE(instance, &slice->source, self);
+ }
return instance;
}
/*
- * call-seq: slice([offset = 0, [length]]) -> io_buffer
+ * call-seq: slice([offset, [length]]) -> io_buffer
*
* Produce another IO::Buffer which is a slice (or view into) the current one
* starting at +offset+ bytes and going for +length+ bytes.
@@ -1143,8 +1565,6 @@ rb_io_buffer_slice(struct rb_io_buffer *data, VALUE self, size_t offset, size_t
* Raises RuntimeError if the <tt>offset+length</tt> is out of the current
* buffer's bounds.
*
- * Example:
- *
* string = 'test'
* buffer = IO::Buffer.for(string)
*
@@ -1185,115 +1605,17 @@ io_buffer_slice(int argc, VALUE *argv, VALUE self)
{
rb_check_arity(argc, 0, 2);
- struct rb_io_buffer *data = NULL;
- TypedData_Get_Struct(self, struct rb_io_buffer, &rb_io_buffer_type, data);
-
- size_t offset = 0, length = 0;
-
- if (argc > 0) {
- if (rb_int_negative_p(argv[0])) {
- rb_raise(rb_eArgError, "Offset can't be negative!");
- }
-
- offset = NUM2SIZET(argv[0]);
- }
-
- if (argc > 1) {
- if (rb_int_negative_p(argv[1])) {
- rb_raise(rb_eArgError, "Length can't be negative!");
- }
-
- length = NUM2SIZET(argv[1]);
- } else {
- length = data->size - offset;
- }
-
- return rb_io_buffer_slice(data, self, offset, length);
-}
-
-int
-rb_io_buffer_get_bytes(VALUE self, void **base, size_t *size)
-{
- struct rb_io_buffer *data = NULL;
- TypedData_Get_Struct(self, struct rb_io_buffer, &rb_io_buffer_type, data);
-
- if (io_buffer_validate(data)) {
- if (data->base) {
- *base = data->base;
- *size = data->size;
-
- return data->flags;
- }
- }
-
- *base = NULL;
- *size = 0;
-
- return 0;
-}
-
-static inline void
-io_buffer_get_bytes_for_writing(struct rb_io_buffer *data, void **base, size_t *size)
-{
- if (data->flags & RB_IO_BUFFER_READONLY) {
- rb_raise(rb_eIOBufferAccessError, "Buffer is not writable!");
- }
+ size_t offset, length;
+ struct rb_io_buffer *buffer = io_buffer_extract_offset_length(self, argc, argv, &offset, &length);
- if (!io_buffer_validate(data)) {
- rb_raise(rb_eIOBufferInvalidatedError, "Buffer is invalid!");
- }
-
- if (data->base) {
- *base = data->base;
- *size = data->size;
-
- return;
- }
-
- rb_raise(rb_eIOBufferAllocationError, "The buffer is not allocated!");
-}
-
-void
-rb_io_buffer_get_bytes_for_writing(VALUE self, void **base, size_t *size)
-{
- struct rb_io_buffer *data = NULL;
- TypedData_Get_Struct(self, struct rb_io_buffer, &rb_io_buffer_type, data);
-
- io_buffer_get_bytes_for_writing(data, base, size);
-}
-
-static void
-io_buffer_get_bytes_for_reading(struct rb_io_buffer *data, const void **base, size_t *size)
-{
- if (!io_buffer_validate(data)) {
- rb_raise(rb_eIOBufferInvalidatedError, "Buffer has been invalidated!");
- }
-
- if (data->base) {
- *base = data->base;
- *size = data->size;
-
- return;
- }
-
- rb_raise(rb_eIOBufferAllocationError, "The buffer is not allocated!");
-}
-
-void
-rb_io_buffer_get_bytes_for_reading(VALUE self, const void **base, size_t *size)
-{
- struct rb_io_buffer *data = NULL;
- TypedData_Get_Struct(self, struct rb_io_buffer, &rb_io_buffer_type, data);
-
- io_buffer_get_bytes_for_reading(data, base, size);
+ return rb_io_buffer_slice(buffer, self, offset, length);
}
/*
* call-seq: transfer -> new_io_buffer
*
- * Transfers ownership to a new buffer, deallocating the current one.
- *
- * Example:
+ * Transfers ownership of the underlying memory to a new buffer, causing the
+ * current buffer to become uninitialized.
*
* buffer = IO::Buffer.new('test')
* other = buffer.transfer
@@ -1310,10 +1632,10 @@ rb_io_buffer_get_bytes_for_reading(VALUE self, const void **base, size_t *size)
VALUE
rb_io_buffer_transfer(VALUE self)
{
- struct rb_io_buffer *data = NULL;
- TypedData_Get_Struct(self, struct rb_io_buffer, &rb_io_buffer_type, data);
+ struct rb_io_buffer *buffer = NULL;
+ TypedData_Get_Struct(self, struct rb_io_buffer, &rb_io_buffer_type, buffer);
- if (data->flags & RB_IO_BUFFER_LOCKED) {
+ if (buffer->flags & RB_IO_BUFFER_LOCKED) {
rb_raise(rb_eIOBufferLockedError, "Cannot transfer ownership of locked buffer!");
}
@@ -1321,91 +1643,96 @@ rb_io_buffer_transfer(VALUE self)
struct rb_io_buffer *transferred;
TypedData_Get_Struct(instance, struct rb_io_buffer, &rb_io_buffer_type, transferred);
- *transferred = *data;
- io_buffer_zero(data);
+ *transferred = *buffer;
+ io_buffer_zero(buffer);
return instance;
}
static void
-io_buffer_resize_clear(struct rb_io_buffer *data, void* base, size_t size)
+io_buffer_resize_clear(struct rb_io_buffer *buffer, void* base, size_t size)
{
- if (size > data->size) {
- memset((unsigned char*)base+data->size, 0, size - data->size);
+ if (size > buffer->size) {
+ memset((unsigned char*)base+buffer->size, 0, size - buffer->size);
}
}
static void
-io_buffer_resize_copy(struct rb_io_buffer *data, size_t size)
+io_buffer_resize_copy(VALUE self, struct rb_io_buffer *buffer, size_t size)
{
// Slow path:
struct rb_io_buffer resized;
- io_buffer_initialize(&resized, NULL, size, io_flags_for_size(size), Qnil);
+ io_buffer_initialize(self, &resized, NULL, size, io_flags_for_size(size), Qnil);
- if (data->base) {
- size_t preserve = data->size;
+ if (buffer->base) {
+ size_t preserve = buffer->size;
if (preserve > size) preserve = size;
- memcpy(resized.base, data->base, preserve);
+ memcpy(resized.base, buffer->base, preserve);
- io_buffer_resize_clear(data, resized.base, size);
+ io_buffer_resize_clear(buffer, resized.base, size);
}
- io_buffer_free(data);
- *data = resized;
+ io_buffer_free(buffer);
+ *buffer = resized;
}
void
rb_io_buffer_resize(VALUE self, size_t size)
{
- struct rb_io_buffer *data = NULL;
- TypedData_Get_Struct(self, struct rb_io_buffer, &rb_io_buffer_type, data);
+ struct rb_io_buffer *buffer = NULL;
+ TypedData_Get_Struct(self, struct rb_io_buffer, &rb_io_buffer_type, buffer);
- if (data->flags & RB_IO_BUFFER_LOCKED) {
+ if (buffer->flags & RB_IO_BUFFER_LOCKED) {
rb_raise(rb_eIOBufferLockedError, "Cannot resize locked buffer!");
}
- if (data->base == NULL) {
- io_buffer_initialize(data, NULL, size, io_flags_for_size(size), Qnil);
+ if (buffer->base == NULL) {
+ io_buffer_initialize(self, buffer, NULL, size, io_flags_for_size(size), Qnil);
return;
}
- if (data->flags & RB_IO_BUFFER_EXTERNAL) {
+ if (buffer->flags & RB_IO_BUFFER_EXTERNAL) {
rb_raise(rb_eIOBufferAccessError, "Cannot resize external buffer!");
}
#if defined(HAVE_MREMAP) && defined(MREMAP_MAYMOVE)
- if (data->flags & RB_IO_BUFFER_MAPPED) {
- void *base = mremap(data->base, data->size, size, MREMAP_MAYMOVE);
+ if (buffer->flags & RB_IO_BUFFER_MAPPED) {
+ void *base = mremap(buffer->base, buffer->size, size, MREMAP_MAYMOVE);
if (base == MAP_FAILED) {
rb_sys_fail("rb_io_buffer_resize:mremap");
}
- io_buffer_resize_clear(data, base, size);
+ io_buffer_resize_clear(buffer, base, size);
- data->base = base;
- data->size = size;
+ buffer->base = base;
+ buffer->size = size;
return;
}
#endif
- if (data->flags & RB_IO_BUFFER_INTERNAL) {
- void *base = realloc(data->base, size);
+ if (buffer->flags & RB_IO_BUFFER_INTERNAL) {
+ if (size == 0) {
+ io_buffer_free(buffer);
+ return;
+ }
+
+ void *base = realloc(buffer->base, size);
if (!base) {
rb_sys_fail("rb_io_buffer_resize:realloc");
}
- io_buffer_resize_clear(data, base, size);
+ io_buffer_resize_clear(buffer, base, size);
- data->base = base;
- data->size = size;
+ buffer->base = base;
+ buffer->size = size;
return;
}
- io_buffer_resize_copy(data, size);
+ io_buffer_resize_copy(self, buffer, size);
}
/*
@@ -1429,7 +1756,7 @@ rb_io_buffer_resize(VALUE self, size_t size)
static VALUE
io_buffer_resize(VALUE self, VALUE size)
{
- rb_io_buffer_resize(self, NUM2SIZET(size));
+ rb_io_buffer_resize(self, io_buffer_extract_size(size));
return self;
}
@@ -1567,9 +1894,9 @@ IO_BUFFER_DECLARE_TYPE(F64, double, RB_IO_BUFFER_BIG_ENDIAN, DBL2NUM, NUM2DBL, r
#undef IO_BUFFER_DECLARE_TYPE
static inline size_t
-io_buffer_data_type_size(ID data_type)
+io_buffer_buffer_type_size(ID buffer_type)
{
-#define IO_BUFFER_DATA_TYPE_SIZE(name) if (data_type == RB_IO_BUFFER_DATA_TYPE_##name) return RB_IO_BUFFER_DATA_TYPE_##name##_SIZE;
+#define IO_BUFFER_DATA_TYPE_SIZE(name) if (buffer_type == RB_IO_BUFFER_DATA_TYPE_##name) return RB_IO_BUFFER_DATA_TYPE_##name##_SIZE;
IO_BUFFER_DATA_TYPE_SIZE(U8)
IO_BUFFER_DATA_TYPE_SIZE(S8)
IO_BUFFER_DATA_TYPE_SIZE(u16)
@@ -1595,34 +1922,33 @@ io_buffer_data_type_size(ID data_type)
/*
* call-seq:
- * size_of(data_type) -> byte size
- * size_of(array of data_type) -> byte size
- *
- * Returns the size of the given data type(s) in bytes.
+ * size_of(buffer_type) -> byte size
+ * size_of(array of buffer_type) -> byte size
*
- * Example:
+ * Returns the size of the given buffer type(s) in bytes.
*
* IO::Buffer.size_of(:u32) # => 4
* IO::Buffer.size_of([:u32, :u32]) # => 8
*/
static VALUE
-io_buffer_size_of(VALUE klass, VALUE data_type)
+io_buffer_size_of(VALUE klass, VALUE buffer_type)
{
- if (RB_TYPE_P(data_type, T_ARRAY)) {
+ if (RB_TYPE_P(buffer_type, T_ARRAY)) {
size_t total = 0;
- for (long i = 0; i < RARRAY_LEN(data_type); i++) {
- total += io_buffer_data_type_size(RB_SYM2ID(RARRAY_AREF(data_type, i)));
+ for (long i = 0; i < RARRAY_LEN(buffer_type); i++) {
+ total += io_buffer_buffer_type_size(RB_SYM2ID(RARRAY_AREF(buffer_type, i)));
}
return SIZET2NUM(total);
- } else {
- return SIZET2NUM(io_buffer_data_type_size(RB_SYM2ID(data_type)));
+ }
+ else {
+ return SIZET2NUM(io_buffer_buffer_type_size(RB_SYM2ID(buffer_type)));
}
}
static inline VALUE
-rb_io_buffer_get_value(const void* base, size_t size, ID data_type, size_t *offset)
+rb_io_buffer_get_value(const void* base, size_t size, ID buffer_type, size_t *offset)
{
-#define IO_BUFFER_GET_VALUE(name) if (data_type == RB_IO_BUFFER_DATA_TYPE_##name) return io_buffer_read_##name(base, size, offset);
+#define IO_BUFFER_GET_VALUE(name) if (buffer_type == RB_IO_BUFFER_DATA_TYPE_##name) return io_buffer_read_##name(base, size, offset);
IO_BUFFER_GET_VALUE(U8)
IO_BUFFER_GET_VALUE(S8)
@@ -1651,9 +1977,9 @@ rb_io_buffer_get_value(const void* base, size_t size, ID data_type, size_t *offs
}
/*
- * call-seq: get_value(data_type, offset) -> numeric
+ * call-seq: get_value(buffer_type, offset) -> numeric
*
- * Read from buffer a value of +type+ at +offset+. +data_type+ should be one
+ * Read from buffer a value of +type+ at +offset+. +buffer_type+ should be one
* of symbols:
*
* * +:U8+: unsigned integer, 1 byte
@@ -1675,12 +2001,10 @@ rb_io_buffer_get_value(const void* base, size_t size, ID data_type, size_t *offs
* * +:f64+: double, 8 bytes, little-endian
* * +:F64+: double, 8 bytes, big-endian
*
- * A data type refers specifically to the type of binary data that is stored
- * in the buffer. For example, a +:u32+ data type is a 32-bit unsigned
+ * A buffer type refers specifically to the type of binary buffer that is stored
+ * in the buffer. For example, a +:u32+ buffer type is a 32-bit unsigned
* integer in little-endian format.
*
- * Example:
- *
* string = [1.5].pack('f')
* # => "\x00\x00\xC0?"
* IO::Buffer.for(string).get_value(:f32, 0)
@@ -1691,7 +2015,7 @@ io_buffer_get_value(VALUE self, VALUE type, VALUE _offset)
{
const void *base;
size_t size;
- size_t offset = NUM2SIZET(_offset);
+ size_t offset = io_buffer_extract_offset(_offset);
rb_io_buffer_get_bytes_for_reading(self, &base, &size);
@@ -1699,34 +2023,32 @@ io_buffer_get_value(VALUE self, VALUE type, VALUE _offset)
}
/*
- * call-seq: get_values(data_types, offset) -> array
+ * call-seq: get_values(buffer_types, offset) -> array
*
- * Similar to #get_value, except that it can handle multiple data types and
+ * Similar to #get_value, except that it can handle multiple buffer types and
* returns an array of values.
*
- * Example:
- *
* string = [1.5, 2.5].pack('ff')
* IO::Buffer.for(string).get_values([:f32, :f32], 0)
* # => [1.5, 2.5]
*/
static VALUE
-io_buffer_get_values(VALUE self, VALUE data_types, VALUE _offset)
+io_buffer_get_values(VALUE self, VALUE buffer_types, VALUE _offset)
{
- size_t offset = NUM2SIZET(_offset);
+ size_t offset = io_buffer_extract_offset(_offset);
const void *base;
size_t size;
rb_io_buffer_get_bytes_for_reading(self, &base, &size);
- if (!RB_TYPE_P(data_types, T_ARRAY)) {
- rb_raise(rb_eArgError, "Argument data_types should be an array!");
+ if (!RB_TYPE_P(buffer_types, T_ARRAY)) {
+ rb_raise(rb_eArgError, "Argument buffer_types should be an array!");
}
- VALUE array = rb_ary_new_capa(RARRAY_LEN(data_types));
+ VALUE array = rb_ary_new_capa(RARRAY_LEN(buffer_types));
- for (long i = 0; i < RARRAY_LEN(data_types); i++) {
- VALUE type = rb_ary_entry(data_types, i);
+ for (long i = 0; i < RARRAY_LEN(buffer_types); i++) {
+ VALUE type = rb_ary_entry(buffer_types, i);
VALUE value = rb_io_buffer_get_value(base, size, RB_SYM2ID(type), &offset);
rb_ary_push(array, value);
}
@@ -1734,18 +2056,50 @@ io_buffer_get_values(VALUE self, VALUE data_types, VALUE _offset)
return array;
}
+// Extract a count argument, which must be a positive integer.
+// Count is generally considered relative to the number of things.
+static inline size_t
+io_buffer_extract_count(VALUE argument)
+{
+ if (rb_int_negative_p(argument)) {
+ rb_raise(rb_eArgError, "Count can't be negative!");
+ }
+
+ return NUM2SIZET(argument);
+}
+
+static inline void
+io_buffer_extract_offset_count(ID buffer_type, size_t size, int argc, VALUE *argv, size_t *offset, size_t *count)
+{
+ if (argc >= 1) {
+ *offset = io_buffer_extract_offset(argv[0]);
+ }
+ else {
+ *offset = 0;
+ }
+
+ if (argc >= 2) {
+ *count = io_buffer_extract_count(argv[1]);
+ }
+ else {
+ if (*offset > size) {
+ rb_raise(rb_eArgError, "The given offset is bigger than the buffer size!");
+ }
+
+ *count = (size - *offset) / io_buffer_buffer_type_size(buffer_type);
+ }
+}
+
/*
* call-seq:
- * each(data_type, [offset, [count]]) {|offset, value| ...} -> self
- * each(data_type, [offset, [count]]) -> enumerator
+ * each(buffer_type, [offset, [count]]) {|offset, value| ...} -> self
+ * each(buffer_type, [offset, [count]]) -> enumerator
*
- * Iterates over the buffer, yielding each +value+ of +data_type+ starting
+ * Iterates over the buffer, yielding each +value+ of +buffer_type+ starting
* from +offset+.
*
* If +count+ is given, only +count+ values will be yielded.
*
- * Example:
- *
* IO::Buffer.for("Hello World").each(:U8, 2, 2) do |offset, value|
* puts "#{offset}: #{value}"
* end
@@ -1762,30 +2116,20 @@ io_buffer_each(int argc, VALUE *argv, VALUE self)
rb_io_buffer_get_bytes_for_reading(self, &base, &size);
- ID data_type;
+ ID buffer_type;
if (argc >= 1) {
- data_type = RB_SYM2ID(argv[0]);
- } else {
- data_type = RB_IO_BUFFER_DATA_TYPE_U8;
+ buffer_type = RB_SYM2ID(argv[0]);
}
-
- size_t offset;
- if (argc >= 2) {
- offset = NUM2SIZET(argv[1]);
- } else {
- offset = 0;
+ else {
+ buffer_type = RB_IO_BUFFER_DATA_TYPE_U8;
}
- size_t count;
- if (argc >= 3) {
- count = NUM2SIZET(argv[2]);
- } else {
- count = (size - offset) / io_buffer_data_type_size(data_type);
- }
+ size_t offset, count;
+ io_buffer_extract_offset_count(buffer_type, size, argc-1, argv+1, &offset, &count);
for (size_t i = 0; i < count; i++) {
size_t current_offset = offset;
- VALUE value = rb_io_buffer_get_value(base, size, data_type, &offset);
+ VALUE value = rb_io_buffer_get_value(base, size, buffer_type, &offset);
rb_yield_values(2, SIZET2NUM(current_offset), value);
}
@@ -1793,14 +2137,12 @@ io_buffer_each(int argc, VALUE *argv, VALUE self)
}
/*
- * call-seq: values(data_type, [offset, [count]]) -> array
+ * call-seq: values(buffer_type, [offset, [count]]) -> array
*
- * Returns an array of values of +data_type+ starting from +offset+.
+ * Returns an array of values of +buffer_type+ starting from +offset+.
*
* If +count+ is given, only +count+ values will be returned.
*
- * Example:
- *
* IO::Buffer.for("Hello World").values(:U8, 2, 2)
* # => [108, 108]
*/
@@ -1812,31 +2154,21 @@ io_buffer_values(int argc, VALUE *argv, VALUE self)
rb_io_buffer_get_bytes_for_reading(self, &base, &size);
- ID data_type;
+ ID buffer_type;
if (argc >= 1) {
- data_type = RB_SYM2ID(argv[0]);
- } else {
- data_type = RB_IO_BUFFER_DATA_TYPE_U8;
+ buffer_type = RB_SYM2ID(argv[0]);
}
-
- size_t offset;
- if (argc >= 2) {
- offset = NUM2SIZET(argv[1]);
- } else {
- offset = 0;
+ else {
+ buffer_type = RB_IO_BUFFER_DATA_TYPE_U8;
}
- size_t count;
- if (argc >= 3) {
- count = NUM2SIZET(argv[2]);
- } else {
- count = (size - offset) / io_buffer_data_type_size(data_type);
- }
+ size_t offset, count;
+ io_buffer_extract_offset_count(buffer_type, size, argc-1, argv+1, &offset, &count);
VALUE array = rb_ary_new_capa(count);
for (size_t i = 0; i < count; i++) {
- VALUE value = rb_io_buffer_get_value(base, size, data_type, &offset);
+ VALUE value = rb_io_buffer_get_value(base, size, buffer_type, &offset);
rb_ary_push(array, value);
}
@@ -1852,8 +2184,6 @@ io_buffer_values(int argc, VALUE *argv, VALUE self)
*
* If +count+ is given, only +count+ bytes will be yielded.
*
- * Example:
- *
* IO::Buffer.for("Hello World").each_byte(2, 2) do |offset, byte|
* puts "#{offset}: #{byte}"
* end
@@ -1870,19 +2200,8 @@ io_buffer_each_byte(int argc, VALUE *argv, VALUE self)
rb_io_buffer_get_bytes_for_reading(self, &base, &size);
- size_t offset;
- if (argc >= 2) {
- offset = NUM2SIZET(argv[1]);
- } else {
- offset = 0;
- }
-
- size_t count;
- if (argc >= 3) {
- count = NUM2SIZET(argv[2]);
- } else {
- count = (size - offset);
- }
+ size_t offset, count;
+ io_buffer_extract_offset_count(RB_IO_BUFFER_DATA_TYPE_U8, size, argc-1, argv+1, &offset, &count);
for (size_t i = 0; i < count; i++) {
unsigned char *value = (unsigned char *)base + i + offset;
@@ -1893,9 +2212,9 @@ io_buffer_each_byte(int argc, VALUE *argv, VALUE self)
}
static inline void
-rb_io_buffer_set_value(const void* base, size_t size, ID data_type, size_t *offset, VALUE value)
+rb_io_buffer_set_value(const void* base, size_t size, ID buffer_type, size_t *offset, VALUE value)
{
-#define IO_BUFFER_SET_VALUE(name) if (data_type == RB_IO_BUFFER_DATA_TYPE_##name) {io_buffer_write_##name(base, size, offset, value); return;}
+#define IO_BUFFER_SET_VALUE(name) if (buffer_type == RB_IO_BUFFER_DATA_TYPE_##name) {io_buffer_write_##name(base, size, offset, value); return;}
IO_BUFFER_SET_VALUE(U8);
IO_BUFFER_SET_VALUE(S8);
@@ -1958,7 +2277,7 @@ io_buffer_set_value(VALUE self, VALUE type, VALUE _offset, VALUE value)
{
void *base;
size_t size;
- size_t offset = NUM2SIZET(_offset);
+ size_t offset = io_buffer_extract_offset(_offset);
rb_io_buffer_get_bytes_for_writing(self, &base, &size);
@@ -1968,14 +2287,12 @@ io_buffer_set_value(VALUE self, VALUE type, VALUE _offset, VALUE value)
}
/*
- * call-seq: set_values(data_types, offset, values) -> offset
+ * call-seq: set_values(buffer_types, offset, values) -> offset
*
- * Write +values+ of +data_types+ at +offset+ to the buffer. +data_types+
+ * Write +values+ of +buffer_types+ at +offset+ to the buffer. +buffer_types+
* should be an array of symbols as described in #get_value. +values+ should
* be an array of values to write.
*
- * Example:
- *
* buffer = IO::Buffer.new(8)
* buffer.set_values([:U8, :U16], 0, [1, 2])
* buffer
@@ -1984,28 +2301,28 @@ io_buffer_set_value(VALUE self, VALUE type, VALUE _offset, VALUE value)
* # 0x00000000 01 00 02 00 00 00 00 00 ........
*/
static VALUE
-io_buffer_set_values(VALUE self, VALUE data_types, VALUE _offset, VALUE values)
+io_buffer_set_values(VALUE self, VALUE buffer_types, VALUE _offset, VALUE values)
{
- if (!RB_TYPE_P(data_types, T_ARRAY)) {
- rb_raise(rb_eArgError, "Argument data_types should be an array!");
+ if (!RB_TYPE_P(buffer_types, T_ARRAY)) {
+ rb_raise(rb_eArgError, "Argument buffer_types should be an array!");
}
if (!RB_TYPE_P(values, T_ARRAY)) {
rb_raise(rb_eArgError, "Argument values should be an array!");
}
- if (RARRAY_LEN(data_types) != RARRAY_LEN(values)) {
- rb_raise(rb_eArgError, "Argument data_types and values should have the same length!");
+ if (RARRAY_LEN(buffer_types) != RARRAY_LEN(values)) {
+ rb_raise(rb_eArgError, "Argument buffer_types and values should have the same length!");
}
- size_t offset = NUM2SIZET(_offset);
+ size_t offset = io_buffer_extract_offset(_offset);
void *base;
size_t size;
rb_io_buffer_get_bytes_for_writing(self, &base, &size);
- for (long i = 0; i < RARRAY_LEN(data_types); i++) {
- VALUE type = rb_ary_entry(data_types, i);
+ for (long i = 0; i < RARRAY_LEN(buffer_types); i++) {
+ VALUE type = rb_ary_entry(buffer_types, i);
VALUE value = rb_ary_entry(values, i);
rb_io_buffer_set_value(base, size, RB_SYM2ID(type), &offset, value);
}
@@ -2014,16 +2331,16 @@ io_buffer_set_values(VALUE self, VALUE data_types, VALUE _offset, VALUE values)
}
static void
-io_buffer_memcpy(struct rb_io_buffer *data, size_t offset, const void *source_base, size_t source_offset, size_t source_size, size_t length)
+io_buffer_memcpy(struct rb_io_buffer *buffer, size_t offset, const void *source_base, size_t source_offset, size_t source_size, size_t length)
{
void *base;
size_t size;
- io_buffer_get_bytes_for_writing(data, &base, &size);
+ io_buffer_get_bytes_for_writing(buffer, &base, &size);
- io_buffer_validate_range(data, offset, length);
+ io_buffer_validate_range(buffer, offset, length);
if (source_offset + length > source_size) {
- rb_raise(rb_eArgError, "The computed source range exceeds the size of the source!");
+ rb_raise(rb_eArgError, "The computed source range exceeds the size of the source buffer!");
}
memcpy((unsigned char*)base+offset, (unsigned char*)source_base+source_offset, length);
@@ -2031,23 +2348,20 @@ io_buffer_memcpy(struct rb_io_buffer *data, size_t offset, const void *source_ba
// (offset, length, source_offset) -> length
static VALUE
-io_buffer_copy_from(struct rb_io_buffer *data, const void *source_base, size_t source_size, int argc, VALUE *argv)
+io_buffer_copy_from(struct rb_io_buffer *buffer, const void *source_base, size_t source_size, int argc, VALUE *argv)
{
- size_t offset;
+ size_t offset = 0;
size_t length;
size_t source_offset;
// The offset we copy into the buffer:
if (argc >= 1) {
- offset = NUM2SIZET(argv[0]);
- }
- else {
- offset = 0;
+ offset = io_buffer_extract_offset(argv[0]);
}
// The offset we start from within the string:
if (argc >= 3) {
- source_offset = NUM2SIZET(argv[2]);
+ source_offset = io_buffer_extract_offset(argv[2]);
if (source_offset > source_size) {
rb_raise(rb_eArgError, "The given source offset is bigger than the source itself!");
@@ -2059,14 +2373,14 @@ io_buffer_copy_from(struct rb_io_buffer *data, const void *source_base, size_t s
// The length we are going to copy:
if (argc >= 2 && !RB_NIL_P(argv[1])) {
- length = NUM2SIZET(argv[1]);
+ length = io_buffer_extract_length(argv[1]);
}
else {
// Default to the source offset -> source size:
length = source_size - source_offset;
}
- io_buffer_memcpy(data, offset, source_base, source_offset, source_size, length);
+ io_buffer_memcpy(buffer, offset, source_base, source_offset, source_size, length);
return SIZET2NUM(length);
}
@@ -2091,25 +2405,25 @@ io_buffer_copy_from(struct rb_io_buffer *data, const void *source_base, size_t s
static VALUE
rb_io_buffer_initialize_copy(VALUE self, VALUE source)
{
- struct rb_io_buffer *data = NULL;
- TypedData_Get_Struct(self, struct rb_io_buffer, &rb_io_buffer_type, data);
+ struct rb_io_buffer *buffer = NULL;
+ TypedData_Get_Struct(self, struct rb_io_buffer, &rb_io_buffer_type, buffer);
const void *source_base;
size_t source_size;
rb_io_buffer_get_bytes_for_reading(source, &source_base, &source_size);
- io_buffer_initialize(data, NULL, source_size, io_flags_for_size(source_size), Qnil);
+ io_buffer_initialize(self, buffer, NULL, source_size, io_flags_for_size(source_size), Qnil);
- return io_buffer_copy_from(data, source_base, source_size, 0, NULL);
+ return io_buffer_copy_from(buffer, source_base, source_size, 0, NULL);
}
/*
* call-seq:
* copy(source, [offset, [length, [source_offset]]]) -> size
*
- * Efficiently copy data from a source IO::Buffer into the buffer,
- * at +offset+ using +memcpy+. For copying String instances, see #set_string.
+ * Efficiently copy from a source IO::Buffer into the buffer, at +offset+
+ * using +memcpy+. For copying String instances, see #set_string.
*
* buffer = IO::Buffer.new(32)
* # =>
@@ -2118,22 +2432,22 @@ rb_io_buffer_initialize_copy(VALUE self, VALUE source)
* # 0x00000010 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ *
*
* buffer.copy(IO::Buffer.for("test"), 8)
- * # => 4 -- size of data copied
+ * # => 4 -- size of buffer copied
* buffer
* # =>
* # #<IO::Buffer 0x0000555f5cf8fe40+32 INTERNAL>
* # 0x00000000 00 00 00 00 00 00 00 00 74 65 73 74 00 00 00 00 ........test....
* # 0x00000010 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ *
*
- * #copy can be used to put data into strings associated with buffer:
+ * #copy can be used to put buffer into strings associated with buffer:
*
- * string= "data: "
- * # => "data: "
+ * string= "buffer: "
+ * # => "buffer: "
* buffer = IO::Buffer.for(string)
* buffer.copy(IO::Buffer.for("test"), 5)
* # => 4
* string
- * # => "data:test"
+ * # => "buffer:test"
*
* Attempt to copy into a read-only buffer will fail:
*
@@ -2151,20 +2465,20 @@ rb_io_buffer_initialize_copy(VALUE self, VALUE source)
* File.read('test.txt')
* # => "boom"
*
- * Attempt to copy the data which will need place outside of buffer's
+ * Attempt to copy the buffer which will need place outside of buffer's
* bounds will fail:
*
* buffer = IO::Buffer.new(2)
* buffer.copy(IO::Buffer.for('test'), 0)
- * # in `copy': Specified offset+length exceeds source size! (ArgumentError)
+ * # in `copy': Specified offset+length is bigger than the buffer size! (ArgumentError)
*/
static VALUE
io_buffer_copy(int argc, VALUE *argv, VALUE self)
{
rb_check_arity(argc, 1, 4);
- struct rb_io_buffer *data = NULL;
- TypedData_Get_Struct(self, struct rb_io_buffer, &rb_io_buffer_type, data);
+ struct rb_io_buffer *buffer = NULL;
+ TypedData_Get_Struct(self, struct rb_io_buffer, &rb_io_buffer_type, buffer);
VALUE source = argv[0];
const void *source_base;
@@ -2172,7 +2486,7 @@ io_buffer_copy(int argc, VALUE *argv, VALUE self)
rb_io_buffer_get_bytes_for_reading(source, &source_base, &source_size);
- return io_buffer_copy_from(data, source_base, source_size, argc-1, argv+1);
+ return io_buffer_copy_from(buffer, source_base, source_size, argc-1, argv+1);
}
/*
@@ -2194,33 +2508,22 @@ io_buffer_get_string(int argc, VALUE *argv, VALUE self)
{
rb_check_arity(argc, 0, 3);
- struct rb_io_buffer *data = NULL;
- TypedData_Get_Struct(self, struct rb_io_buffer, &rb_io_buffer_type, data);
+ size_t offset, length;
+ struct rb_io_buffer *buffer = io_buffer_extract_offset_length(self, argc, argv, &offset, &length);
const void *base;
size_t size;
- io_buffer_get_bytes_for_reading(data, &base, &size);
-
- size_t offset = 0;
- size_t length = size;
- rb_encoding *encoding = rb_ascii8bit_encoding();
-
- if (argc >= 1) {
- offset = NUM2SIZET(argv[0]);
- }
-
- if (argc >= 2 && !RB_NIL_P(argv[1])) {
- length = NUM2SIZET(argv[1]);
- }
- else {
- length = size - offset;
- }
+ io_buffer_get_bytes_for_reading(buffer, &base, &size);
+ rb_encoding *encoding;
if (argc >= 3) {
encoding = rb_find_encoding(argv[2]);
}
+ else {
+ encoding = rb_ascii8bit_encoding();
+ }
- io_buffer_validate_range(data, offset, length);
+ io_buffer_validate_range(buffer, offset, length);
return rb_enc_str_new((const char*)base + offset, length, encoding);
}
@@ -2228,15 +2531,15 @@ io_buffer_get_string(int argc, VALUE *argv, VALUE self)
/*
* call-seq: set_string(string, [offset, [length, [source_offset]]]) -> size
*
- * Efficiently copy data from a source String into the buffer,
- * at +offset+ using +memcpy+.
+ * Efficiently copy from a source String into the buffer, at +offset+ using
+ * +memcpy+.
*
* buf = IO::Buffer.new(8)
* # =>
* # #<IO::Buffer 0x0000557412714a20+8 INTERNAL>
* # 0x00000000 00 00 00 00 00 00 00 00 ........
*
- * # set data starting from offset 1, take 2 bytes starting from string's
+ * # set buffer starting from offset 1, take 2 bytes starting from string's
* # second
* buf.set_string('test', 1, 2, 1)
* # => 2
@@ -2253,28 +2556,28 @@ io_buffer_set_string(int argc, VALUE *argv, VALUE self)
{
rb_check_arity(argc, 1, 4);
- struct rb_io_buffer *data = NULL;
- TypedData_Get_Struct(self, struct rb_io_buffer, &rb_io_buffer_type, data);
+ struct rb_io_buffer *buffer = NULL;
+ TypedData_Get_Struct(self, struct rb_io_buffer, &rb_io_buffer_type, buffer);
VALUE string = rb_str_to_str(argv[0]);
const void *source_base = RSTRING_PTR(string);
size_t source_size = RSTRING_LEN(string);
- return io_buffer_copy_from(data, source_base, source_size, argc-1, argv+1);
+ return io_buffer_copy_from(buffer, source_base, source_size, argc-1, argv+1);
}
void
rb_io_buffer_clear(VALUE self, uint8_t value, size_t offset, size_t length)
{
+ struct rb_io_buffer *buffer = NULL;
+ TypedData_Get_Struct(self, struct rb_io_buffer, &rb_io_buffer_type, buffer);
+
void *base;
size_t size;
+ io_buffer_get_bytes_for_writing(buffer, &base, &size);
- rb_io_buffer_get_bytes_for_writing(self, &base, &size);
-
- if (offset + length > size) {
- rb_raise(rb_eArgError, "The given offset + length out of bounds!");
- }
+ io_buffer_validate_range(buffer, offset, length);
memset((char*)base + offset, value, length);
}
@@ -2315,26 +2618,13 @@ io_buffer_clear(int argc, VALUE *argv, VALUE self)
{
rb_check_arity(argc, 0, 3);
- struct rb_io_buffer *data = NULL;
- TypedData_Get_Struct(self, struct rb_io_buffer, &rb_io_buffer_type, data);
-
uint8_t value = 0;
if (argc >= 1) {
value = NUM2UINT(argv[0]);
}
- size_t offset = 0;
- if (argc >= 2) {
- offset = NUM2SIZET(argv[1]);
- }
-
- size_t length;
- if (argc >= 3) {
- length = NUM2SIZET(argv[2]);
- }
- else {
- length = data->size - offset;
- }
+ size_t offset, length;
+ io_buffer_extract_offset_length(self, argc-1, argv+1, &offset, &length);
rb_io_buffer_clear(self, value, offset, length);
@@ -2366,18 +2656,90 @@ io_buffer_default_size(size_t page_size)
return platform_agnostic_default_size;
}
+struct io_buffer_blocking_region_argument {
+ struct rb_io_buffer *buffer;
+ rb_blocking_function_t *function;
+ void *data;
+ int descriptor;
+};
+
+static VALUE
+io_buffer_blocking_region_begin(VALUE _argument)
+{
+ struct io_buffer_blocking_region_argument *argument = (void*)_argument;
+
+ return rb_thread_io_blocking_region(argument->function, argument->data, argument->descriptor);
+}
+
+static VALUE
+io_buffer_blocking_region_ensure(VALUE _argument)
+{
+ struct io_buffer_blocking_region_argument *argument = (void*)_argument;
+
+ io_buffer_unlock(argument->buffer);
+
+ return Qnil;
+}
+
+static VALUE
+io_buffer_blocking_region(struct rb_io_buffer *buffer, rb_blocking_function_t *function, void *data, int descriptor)
+{
+ struct io_buffer_blocking_region_argument argument = {
+ .buffer = buffer,
+ .function = function,
+ .data = data,
+ .descriptor = descriptor,
+ };
+
+ // If the buffer is already locked, we can skip the ensure (unlock):
+ if (buffer->flags & RB_IO_BUFFER_LOCKED) {
+ return io_buffer_blocking_region_begin((VALUE)&argument);
+ }
+ else {
+ // The buffer should be locked for the duration of the blocking region:
+ io_buffer_lock(buffer);
+
+ return rb_ensure(io_buffer_blocking_region_begin, (VALUE)&argument, io_buffer_blocking_region_ensure, (VALUE)&argument);
+ }
+}
+
struct io_buffer_read_internal_argument {
+ // The file descriptor to read from:
int descriptor;
- void *base;
+ // The base pointer to read from:
+ char *base;
+ // The size of the buffer:
size_t size;
+ // The minimum number of bytes to read:
+ size_t length;
};
static VALUE
io_buffer_read_internal(void *_argument)
{
+ size_t total = 0;
struct io_buffer_read_internal_argument *argument = _argument;
- ssize_t result = read(argument->descriptor, argument->base, argument->size);
- return rb_fiber_scheduler_io_result(result, errno);
+
+ while (true) {
+ ssize_t result = read(argument->descriptor, argument->base, argument->size);
+
+ if (result < 0) {
+ return rb_fiber_scheduler_io_result(result, errno);
+ }
+ else if (result == 0) {
+ return rb_fiber_scheduler_io_result(total, 0);
+ }
+ else {
+ total += result;
+
+ if (total >= argument->length) {
+ return rb_fiber_scheduler_io_result(total, 0);
+ }
+
+ argument->base = argument->base + result;
+ argument->size = argument->size - result;
+ }
+ }
}
VALUE
@@ -2385,48 +2747,50 @@ rb_io_buffer_read(VALUE self, VALUE io, size_t length, size_t offset)
{
VALUE scheduler = rb_fiber_scheduler_current();
if (scheduler != Qnil) {
- VALUE result = rb_fiber_scheduler_io_read(scheduler, io, self, SIZET2NUM(length), SIZET2NUM(offset));
+ VALUE result = rb_fiber_scheduler_io_read(scheduler, io, self, length, offset);
if (!UNDEF_P(result)) {
return result;
}
}
- struct rb_io_buffer *data = NULL;
- TypedData_Get_Struct(self, struct rb_io_buffer, &rb_io_buffer_type, data);
+ struct rb_io_buffer *buffer = NULL;
+ TypedData_Get_Struct(self, struct rb_io_buffer, &rb_io_buffer_type, buffer);
- io_buffer_validate_range(data, offset, length);
+ io_buffer_validate_range(buffer, offset, length);
int descriptor = rb_io_descriptor(io);
void * base;
size_t size;
- io_buffer_get_bytes_for_writing(data, &base, &size);
+ io_buffer_get_bytes_for_writing(buffer, &base, &size);
base = (unsigned char*)base + offset;
+ size = size - offset;
struct io_buffer_read_internal_argument argument = {
.descriptor = descriptor,
.base = base,
- .size = length,
+ .size = size,
+ .length = length,
};
- return rb_thread_io_blocking_region(io_buffer_read_internal, &argument, descriptor);
+ return io_buffer_blocking_region(buffer, io_buffer_read_internal, &argument, descriptor);
}
/*
* call-seq: read(io, [length, [offset]]) -> read length or -errno
*
- * Read at most +length+ bytes from +io+ into the buffer, starting at
+ * Read at least +length+ bytes from the +io+, into the buffer starting at
* +offset+. If an error occurs, return <tt>-errno</tt>.
*
- * If +length+ is not given, read until the end of the buffer.
+ * If +length+ is not given or +nil+, it defaults to the size of the buffer
+ * minus the offset, i.e. the entire buffer.
*
- * If +offset+ is not given, read from the beginning of the buffer.
+ * If +length+ is zero, exactly one <tt>read</tt> operation will occur.
*
- * If +length+ is 0, read nothing.
- *
- * Example:
+ * If +offset+ is not given, it defaults to zero, i.e. the beginning of the
+ * buffer.
*
* IO::Buffer.for('test') do |buffer|
* p buffer
@@ -2443,61 +2807,56 @@ rb_io_buffer_read(VALUE self, VALUE io, size_t length, size_t offset)
static VALUE
io_buffer_read(int argc, VALUE *argv, VALUE self)
{
- rb_check_arity(argc, 2, 3);
+ rb_check_arity(argc, 1, 3);
VALUE io = argv[0];
- size_t length;
- if (argc >= 2) {
- if (rb_int_negative_p(argv[1])) {
- rb_raise(rb_eArgError, "Length can't be negative!");
- }
-
- length = NUM2SIZET(argv[1]);
- }
-
- size_t offset = 0;
- if (argc >= 3) {
- if (rb_int_negative_p(argv[2])) {
- rb_raise(rb_eArgError, "Offset can't be negative!");
- }
-
- offset = NUM2SIZET(argv[2]);
- }
+ size_t length, offset;
+ io_buffer_extract_length_offset(self, argc-1, argv+1, &length, &offset);
return rb_io_buffer_read(self, io, length, offset);
}
struct io_buffer_pread_internal_argument {
+ // The file descriptor to read from:
int descriptor;
- void *base;
+ // The base pointer to read from:
+ char *base;
+ // The size of the buffer:
size_t size;
+ // The minimum number of bytes to read:
+ size_t length;
+ // The offset to read from:
off_t offset;
};
static VALUE
io_buffer_pread_internal(void *_argument)
{
+ size_t total = 0;
struct io_buffer_pread_internal_argument *argument = _argument;
-#if defined(HAVE_PREAD)
- ssize_t result = pread(argument->descriptor, argument->base, argument->size, argument->offset);
-#else
- // This emulation is not thread safe.
- rb_off_t offset = lseek(argument->descriptor, 0, SEEK_CUR);
- if (offset == (rb_off_t)-1)
- return rb_fiber_scheduler_io_result(-1, errno);
-
- if (lseek(argument->descriptor, argument->offset, SEEK_SET) == (rb_off_t)-1)
- return rb_fiber_scheduler_io_result(-1, errno);
+ while (true) {
+ ssize_t result = pread(argument->descriptor, argument->base, argument->size, argument->offset);
- ssize_t result = read(argument->descriptor, argument->base, argument->size);
+ if (result < 0) {
+ return rb_fiber_scheduler_io_result(result, errno);
+ }
+ else if (result == 0) {
+ return rb_fiber_scheduler_io_result(total, 0);
+ }
+ else {
+ total += result;
- if (lseek(argument->descriptor, offset, SEEK_SET) == (rb_off_t)-1)
- return rb_fiber_scheduler_io_result(-1, errno);
-#endif
+ if (total >= argument->length) {
+ return rb_fiber_scheduler_io_result(total, 0);
+ }
- return rb_fiber_scheduler_io_result(result, errno);
+ argument->base = argument->base + result;
+ argument->size = argument->size - result;
+ argument->offset = argument->offset + result;
+ }
+ }
}
VALUE
@@ -2505,50 +2864,52 @@ rb_io_buffer_pread(VALUE self, VALUE io, rb_off_t from, size_t length, size_t of
{
VALUE scheduler = rb_fiber_scheduler_current();
if (scheduler != Qnil) {
- VALUE result = rb_fiber_scheduler_io_pread(scheduler, io, OFFT2NUM(from), self, SIZET2NUM(length), SIZET2NUM(offset));
+ VALUE result = rb_fiber_scheduler_io_pread(scheduler, io, from, self, length, offset);
if (!UNDEF_P(result)) {
return result;
}
}
- struct rb_io_buffer *data = NULL;
- TypedData_Get_Struct(self, struct rb_io_buffer, &rb_io_buffer_type, data);
+ struct rb_io_buffer *buffer = NULL;
+ TypedData_Get_Struct(self, struct rb_io_buffer, &rb_io_buffer_type, buffer);
- io_buffer_validate_range(data, offset, length);
+ io_buffer_validate_range(buffer, offset, length);
int descriptor = rb_io_descriptor(io);
void * base;
size_t size;
- io_buffer_get_bytes_for_writing(data, &base, &size);
+ io_buffer_get_bytes_for_writing(buffer, &base, &size);
+
+ base = (unsigned char*)base + offset;
+ size = size - offset;
struct io_buffer_pread_internal_argument argument = {
.descriptor = descriptor,
-
- // Move the base pointer to the offset:
- .base = (unsigned char*)base + offset,
-
- // And the size to the length of data we want to read:
- .size = length,
-
- // From the offset in the file we want to read from:
+ .base = base,
+ .size = size,
+ .length = length,
.offset = from,
};
- return rb_thread_io_blocking_region(io_buffer_pread_internal, &argument, descriptor);
+ return io_buffer_blocking_region(buffer, io_buffer_pread_internal, &argument, descriptor);
}
/*
- * call-seq: pread(io, from, length, [offset]) -> read length or -errno
+ * call-seq: pread(io, from, [length, [offset]]) -> read length or -errno
*
- * Read at most +length+ bytes from +io+ into the buffer, starting at
- * +from+, and put it in buffer starting from specified +offset+.
- * If an error occurs, return <tt>-errno</tt>.
+ * Read at least +length+ bytes from the +io+ starting at the specified +from+
+ * position, into the buffer starting at +offset+. If an error occurs,
+ * return <tt>-errno</tt>.
*
- * If +offset+ is not given, put it at the beginning of the buffer.
+ * If +length+ is not given or +nil+, it defaults to the size of the buffer
+ * minus the offset, i.e. the entire buffer.
*
- * Example:
+ * If +length+ is zero, exactly one <tt>pread</tt> operation will occur.
+ *
+ * If +offset+ is not given, it defaults to zero, i.e. the beginning of the
+ * buffer.
*
* IO::Buffer.for('test') do |buffer|
* p buffer
@@ -2568,41 +2929,54 @@ rb_io_buffer_pread(VALUE self, VALUE io, rb_off_t from, size_t length, size_t of
static VALUE
io_buffer_pread(int argc, VALUE *argv, VALUE self)
{
- rb_check_arity(argc, 3, 4);
+ rb_check_arity(argc, 2, 4);
VALUE io = argv[0];
rb_off_t from = NUM2OFFT(argv[1]);
- size_t length;
- if (rb_int_negative_p(argv[2])) {
- rb_raise(rb_eArgError, "Length can't be negative!");
- }
- length = NUM2SIZET(argv[2]);
-
- size_t offset = 0;
- if (argc >= 4) {
- if (rb_int_negative_p(argv[3])) {
- rb_raise(rb_eArgError, "Offset can't be negative!");
- }
-
- offset = NUM2SIZET(argv[3]);
- }
+ size_t length, offset;
+ io_buffer_extract_length_offset(self, argc-2, argv+2, &length, &offset);
return rb_io_buffer_pread(self, io, from, length, offset);
}
struct io_buffer_write_internal_argument {
+ // The file descriptor to write to:
int descriptor;
- const void *base;
+ // The base pointer to write from:
+ const char *base;
+ // The size of the buffer:
size_t size;
+ // The minimum length to write:
+ size_t length;
};
static VALUE
io_buffer_write_internal(void *_argument)
{
+ size_t total = 0;
struct io_buffer_write_internal_argument *argument = _argument;
- ssize_t result = write(argument->descriptor, argument->base, argument->size);
- return rb_fiber_scheduler_io_result(result, errno);
+
+ while (true) {
+ ssize_t result = write(argument->descriptor, argument->base, argument->size);
+
+ if (result < 0) {
+ return rb_fiber_scheduler_io_result(result, errno);
+ }
+ else if (result == 0) {
+ return rb_fiber_scheduler_io_result(total, 0);
+ }
+ else {
+ total += result;
+
+ if (total >= argument->length) {
+ return rb_fiber_scheduler_io_result(total, 0);
+ }
+
+ argument->base = argument->base + result;
+ argument->size = argument->size - result;
+ }
+ }
}
VALUE
@@ -2610,43 +2984,50 @@ rb_io_buffer_write(VALUE self, VALUE io, size_t length, size_t offset)
{
VALUE scheduler = rb_fiber_scheduler_current();
if (scheduler != Qnil) {
- VALUE result = rb_fiber_scheduler_io_write(scheduler, io, self, SIZET2NUM(length), SIZET2NUM(offset));
+ VALUE result = rb_fiber_scheduler_io_write(scheduler, io, self, length, offset);
if (!UNDEF_P(result)) {
return result;
}
}
- struct rb_io_buffer *data = NULL;
- TypedData_Get_Struct(self, struct rb_io_buffer, &rb_io_buffer_type, data);
+ struct rb_io_buffer *buffer = NULL;
+ TypedData_Get_Struct(self, struct rb_io_buffer, &rb_io_buffer_type, buffer);
- io_buffer_validate_range(data, offset, length);
+ io_buffer_validate_range(buffer, offset, length);
int descriptor = rb_io_descriptor(io);
const void * base;
size_t size;
- io_buffer_get_bytes_for_reading(data, &base, &size);
+ io_buffer_get_bytes_for_reading(buffer, &base, &size);
- base = (unsigned char *)base + offset;
+ base = (unsigned char*)base + offset;
+ size = size - offset;
struct io_buffer_write_internal_argument argument = {
.descriptor = descriptor,
.base = base,
- .size = length,
+ .size = size,
+ .length = length,
};
- return rb_thread_io_blocking_region(io_buffer_write_internal, &argument, descriptor);
+ return io_buffer_blocking_region(buffer, io_buffer_write_internal, &argument, descriptor);
}
/*
- * call-seq: write(io, length, [offset]) -> written length or -errno
+ * call-seq: write(io, [length, [offset]]) -> written length or -errno
*
- * Writes +length+ bytes from buffer into +io+, starting at
- * +offset+ in the buffer. If an error occurs, return <tt>-errno</tt>.
+ * Write at least +length+ bytes from the buffer starting at +offset+, into the +io+.
+ * If an error occurs, return <tt>-errno</tt>.
+ *
+ * If +length+ is not given or +nil+, it defaults to the size of the buffer
+ * minus the offset, i.e. the entire buffer.
*
- * If +offset+ is not given, the bytes are taken from the beginning
- * of the buffer.
+ * If +length+ is zero, exactly one <tt>write</tt> operation will occur.
+ *
+ * If +offset+ is not given, it defaults to zero, i.e. the beginning of the
+ * buffer.
*
* out = File.open('output.txt', 'wb')
* IO::Buffer.for('1234567').write(out, 3)
@@ -2656,61 +3037,55 @@ rb_io_buffer_write(VALUE self, VALUE io, size_t length, size_t offset)
static VALUE
io_buffer_write(int argc, VALUE *argv, VALUE self)
{
- rb_check_arity(argc, 2, 3);
+ rb_check_arity(argc, 1, 3);
VALUE io = argv[0];
- size_t length;
- if (argc >= 2) {
- if (rb_int_negative_p(argv[1])) {
- rb_raise(rb_eArgError, "Length can't be negative!");
- }
-
- length = NUM2SIZET(argv[1]);
- }
-
- size_t offset = 0;
- if (argc >= 3) {
- if (rb_int_negative_p(argv[2])) {
- rb_raise(rb_eArgError, "Offset can't be negative!");
- }
-
- offset = NUM2SIZET(argv[2]);
- }
+ size_t length, offset;
+ io_buffer_extract_length_offset(self, argc-1, argv+1, &length, &offset);
return rb_io_buffer_write(self, io, length, offset);
}
-
struct io_buffer_pwrite_internal_argument {
+ // The file descriptor to write to:
int descriptor;
- const void *base;
+ // The base pointer to write from:
+ const char *base;
+ // The size of the buffer:
size_t size;
+ // The minimum length to write:
+ size_t length;
+ // The offset to write to:
off_t offset;
};
static VALUE
io_buffer_pwrite_internal(void *_argument)
{
+ size_t total = 0;
struct io_buffer_pwrite_internal_argument *argument = _argument;
-#if defined(HAVE_PWRITE)
- ssize_t result = pwrite(argument->descriptor, argument->base, argument->size, argument->offset);
-#else
- // This emulation is not thread safe.
- rb_off_t offset = lseek(argument->descriptor, 0, SEEK_CUR);
- if (offset == (rb_off_t)-1)
- return rb_fiber_scheduler_io_result(-1, errno);
-
- if (lseek(argument->descriptor, argument->offset, SEEK_SET) == (rb_off_t)-1)
- return rb_fiber_scheduler_io_result(-1, errno);
+ while (true) {
+ ssize_t result = pwrite(argument->descriptor, argument->base, argument->size, argument->offset);
- ssize_t result = write(argument->descriptor, argument->base, argument->size);
+ if (result < 0) {
+ return rb_fiber_scheduler_io_result(result, errno);
+ }
+ else if (result == 0) {
+ return rb_fiber_scheduler_io_result(total, 0);
+ }
+ else {
+ total += result;
- if (lseek(argument->descriptor, offset, SEEK_SET) == (rb_off_t)-1)
- return rb_fiber_scheduler_io_result(-1, errno);
-#endif
+ if (total >= argument->length) {
+ return rb_fiber_scheduler_io_result(total, 0);
+ }
- return rb_fiber_scheduler_io_result(result, errno);
+ argument->base = argument->base + result;
+ argument->size = argument->size - result;
+ argument->offset = argument->offset + result;
+ }
+ }
}
VALUE
@@ -2718,49 +3093,63 @@ rb_io_buffer_pwrite(VALUE self, VALUE io, rb_off_t from, size_t length, size_t o
{
VALUE scheduler = rb_fiber_scheduler_current();
if (scheduler != Qnil) {
- VALUE result = rb_fiber_scheduler_io_pwrite(scheduler, io, OFFT2NUM(from), self, SIZET2NUM(length), SIZET2NUM(offset));
+ VALUE result = rb_fiber_scheduler_io_pwrite(scheduler, io, from, self, length, offset);
if (!UNDEF_P(result)) {
return result;
}
}
- struct rb_io_buffer *data = NULL;
- TypedData_Get_Struct(self, struct rb_io_buffer, &rb_io_buffer_type, data);
+ struct rb_io_buffer *buffer = NULL;
+ TypedData_Get_Struct(self, struct rb_io_buffer, &rb_io_buffer_type, buffer);
- io_buffer_validate_range(data, offset, length);
+ io_buffer_validate_range(buffer, offset, length);
int descriptor = rb_io_descriptor(io);
const void * base;
size_t size;
- io_buffer_get_bytes_for_reading(data, &base, &size);
+ io_buffer_get_bytes_for_reading(buffer, &base, &size);
+
+ base = (unsigned char*)base + offset;
+ size = size - offset;
struct io_buffer_pwrite_internal_argument argument = {
.descriptor = descriptor,
// Move the base pointer to the offset:
- .base = (unsigned char *)base + offset,
+ .base = base,
- // And the size to the length of data we want to read:
- .size = length,
+ // And the size to the length of buffer we want to read:
+ .size = size,
+
+ // And the length of the buffer we want to write:
+ .length = length,
// And the offset in the file we want to write from:
.offset = from,
};
- return rb_thread_io_blocking_region(io_buffer_pwrite_internal, &argument, descriptor);
+ return io_buffer_blocking_region(buffer, io_buffer_pwrite_internal, &argument, descriptor);
}
/*
- * call-seq: pwrite(io, from, length, [offset]) -> written length or -errno
+ * call-seq: pwrite(io, from, [length, [offset]]) -> written length or -errno
+ *
+ * Write at least +length+ bytes from the buffer starting at +offset+, into
+ * the +io+ starting at the specified +from+ position. If an error occurs,
+ * return <tt>-errno</tt>.
*
- * Writes +length+ bytes from buffer into +io+, starting at
- * +offset+ in the buffer. If an error occurs, return <tt>-errno</tt>.
+ * If +length+ is not given or +nil+, it defaults to the size of the buffer
+ * minus the offset, i.e. the entire buffer.
*
- * If +offset+ is not given, the bytes are taken from the beginning of the
- * buffer. If the +offset+ is given and is beyond the end of the file, the
- * gap will be filled with null (0 value) bytes.
+ * If +length+ is zero, exactly one <tt>pwrite</tt> operation will occur.
+ *
+ * If +offset+ is not given, it defaults to zero, i.e. the beginning of the
+ * buffer.
+ *
+ * If the +from+ position is beyond the end of the file, the gap will be
+ * filled with null (0 value) bytes.
*
* out = File.open('output.txt', File::RDWR) # open for read/write, no truncation
* IO::Buffer.for('1234567').pwrite(out, 2, 3, 1)
@@ -2771,25 +3160,13 @@ rb_io_buffer_pwrite(VALUE self, VALUE io, rb_off_t from, size_t length, size_t o
static VALUE
io_buffer_pwrite(int argc, VALUE *argv, VALUE self)
{
- rb_check_arity(argc, 3, 4);
+ rb_check_arity(argc, 2, 4);
VALUE io = argv[0];
rb_off_t from = NUM2OFFT(argv[1]);
- size_t length;
- if (rb_int_negative_p(argv[2])) {
- rb_raise(rb_eArgError, "Length can't be negative!");
- }
- length = NUM2SIZET(argv[2]);
-
- size_t offset = 0;
- if (argc >= 4) {
- if (rb_int_negative_p(argv[3])) {
- rb_raise(rb_eArgError, "Offset can't be negative!");
- }
-
- offset = NUM2SIZET(argv[3]);
- }
+ size_t length, offset;
+ io_buffer_extract_length_offset(self, argc-2, argv+2, &length, &offset);
return rb_io_buffer_pwrite(self, io, from, length, offset);
}
@@ -2824,19 +3201,19 @@ memory_and(unsigned char * restrict output, unsigned char * restrict base, size_
static VALUE
io_buffer_and(VALUE self, VALUE mask)
{
- struct rb_io_buffer *data = NULL;
- TypedData_Get_Struct(self, struct rb_io_buffer, &rb_io_buffer_type, data);
+ struct rb_io_buffer *buffer = NULL;
+ TypedData_Get_Struct(self, struct rb_io_buffer, &rb_io_buffer_type, buffer);
- struct rb_io_buffer *mask_data = NULL;
- TypedData_Get_Struct(mask, struct rb_io_buffer, &rb_io_buffer_type, mask_data);
+ struct rb_io_buffer *mask_buffer = NULL;
+ TypedData_Get_Struct(mask, struct rb_io_buffer, &rb_io_buffer_type, mask_buffer);
- io_buffer_check_mask(mask_data);
+ io_buffer_check_mask(mask_buffer);
- VALUE output = rb_io_buffer_new(NULL, data->size, io_flags_for_size(data->size));
- struct rb_io_buffer *output_data = NULL;
- TypedData_Get_Struct(output, struct rb_io_buffer, &rb_io_buffer_type, output_data);
+ VALUE output = rb_io_buffer_new(NULL, buffer->size, io_flags_for_size(buffer->size));
+ struct rb_io_buffer *output_buffer = NULL;
+ TypedData_Get_Struct(output, struct rb_io_buffer, &rb_io_buffer_type, output_buffer);
- memory_and(output_data->base, data->base, data->size, mask_data->base, mask_data->size);
+ memory_and(output_buffer->base, buffer->base, buffer->size, mask_buffer->base, mask_buffer->size);
return output;
}
@@ -2864,19 +3241,19 @@ memory_or(unsigned char * restrict output, unsigned char * restrict base, size_t
static VALUE
io_buffer_or(VALUE self, VALUE mask)
{
- struct rb_io_buffer *data = NULL;
- TypedData_Get_Struct(self, struct rb_io_buffer, &rb_io_buffer_type, data);
+ struct rb_io_buffer *buffer = NULL;
+ TypedData_Get_Struct(self, struct rb_io_buffer, &rb_io_buffer_type, buffer);
- struct rb_io_buffer *mask_data = NULL;
- TypedData_Get_Struct(mask, struct rb_io_buffer, &rb_io_buffer_type, mask_data);
+ struct rb_io_buffer *mask_buffer = NULL;
+ TypedData_Get_Struct(mask, struct rb_io_buffer, &rb_io_buffer_type, mask_buffer);
- io_buffer_check_mask(mask_data);
+ io_buffer_check_mask(mask_buffer);
- VALUE output = rb_io_buffer_new(NULL, data->size, io_flags_for_size(data->size));
- struct rb_io_buffer *output_data = NULL;
- TypedData_Get_Struct(output, struct rb_io_buffer, &rb_io_buffer_type, output_data);
+ VALUE output = rb_io_buffer_new(NULL, buffer->size, io_flags_for_size(buffer->size));
+ struct rb_io_buffer *output_buffer = NULL;
+ TypedData_Get_Struct(output, struct rb_io_buffer, &rb_io_buffer_type, output_buffer);
- memory_or(output_data->base, data->base, data->size, mask_data->base, mask_data->size);
+ memory_or(output_buffer->base, buffer->base, buffer->size, mask_buffer->base, mask_buffer->size);
return output;
}
@@ -2904,19 +3281,19 @@ memory_xor(unsigned char * restrict output, unsigned char * restrict base, size_
static VALUE
io_buffer_xor(VALUE self, VALUE mask)
{
- struct rb_io_buffer *data = NULL;
- TypedData_Get_Struct(self, struct rb_io_buffer, &rb_io_buffer_type, data);
+ struct rb_io_buffer *buffer = NULL;
+ TypedData_Get_Struct(self, struct rb_io_buffer, &rb_io_buffer_type, buffer);
- struct rb_io_buffer *mask_data = NULL;
- TypedData_Get_Struct(mask, struct rb_io_buffer, &rb_io_buffer_type, mask_data);
+ struct rb_io_buffer *mask_buffer = NULL;
+ TypedData_Get_Struct(mask, struct rb_io_buffer, &rb_io_buffer_type, mask_buffer);
- io_buffer_check_mask(mask_data);
+ io_buffer_check_mask(mask_buffer);
- VALUE output = rb_io_buffer_new(NULL, data->size, io_flags_for_size(data->size));
- struct rb_io_buffer *output_data = NULL;
- TypedData_Get_Struct(output, struct rb_io_buffer, &rb_io_buffer_type, output_data);
+ VALUE output = rb_io_buffer_new(NULL, buffer->size, io_flags_for_size(buffer->size));
+ struct rb_io_buffer *output_buffer = NULL;
+ TypedData_Get_Struct(output, struct rb_io_buffer, &rb_io_buffer_type, output_buffer);
- memory_xor(output_data->base, data->base, data->size, mask_data->base, mask_data->size);
+ memory_xor(output_buffer->base, buffer->base, buffer->size, mask_buffer->base, mask_buffer->size);
return output;
}
@@ -2944,14 +3321,14 @@ memory_not(unsigned char * restrict output, unsigned char * restrict base, size_
static VALUE
io_buffer_not(VALUE self)
{
- struct rb_io_buffer *data = NULL;
- TypedData_Get_Struct(self, struct rb_io_buffer, &rb_io_buffer_type, data);
+ struct rb_io_buffer *buffer = NULL;
+ TypedData_Get_Struct(self, struct rb_io_buffer, &rb_io_buffer_type, buffer);
- VALUE output = rb_io_buffer_new(NULL, data->size, io_flags_for_size(data->size));
- struct rb_io_buffer *output_data = NULL;
- TypedData_Get_Struct(output, struct rb_io_buffer, &rb_io_buffer_type, output_data);
+ VALUE output = rb_io_buffer_new(NULL, buffer->size, io_flags_for_size(buffer->size));
+ struct rb_io_buffer *output_buffer = NULL;
+ TypedData_Get_Struct(output, struct rb_io_buffer, &rb_io_buffer_type, output_buffer);
- memory_not(output_data->base, data->base, data->size);
+ memory_not(output_buffer->base, buffer->base, buffer->size);
return output;
}
@@ -2970,7 +3347,7 @@ static inline void
io_buffer_check_overlaps(struct rb_io_buffer *a, struct rb_io_buffer *b)
{
if (io_buffer_overlaps(a, b))
- rb_raise(rb_eIOBufferMaskError, "Mask overlaps source data!");
+ rb_raise(rb_eIOBufferMaskError, "Mask overlaps source buffer!");
}
static void
@@ -3001,20 +3378,20 @@ memory_and_inplace(unsigned char * restrict base, size_t size, unsigned char * r
static VALUE
io_buffer_and_inplace(VALUE self, VALUE mask)
{
- struct rb_io_buffer *data = NULL;
- TypedData_Get_Struct(self, struct rb_io_buffer, &rb_io_buffer_type, data);
+ struct rb_io_buffer *buffer = NULL;
+ TypedData_Get_Struct(self, struct rb_io_buffer, &rb_io_buffer_type, buffer);
- struct rb_io_buffer *mask_data = NULL;
- TypedData_Get_Struct(mask, struct rb_io_buffer, &rb_io_buffer_type, mask_data);
+ struct rb_io_buffer *mask_buffer = NULL;
+ TypedData_Get_Struct(mask, struct rb_io_buffer, &rb_io_buffer_type, mask_buffer);
- io_buffer_check_mask(mask_data);
- io_buffer_check_overlaps(data, mask_data);
+ io_buffer_check_mask(mask_buffer);
+ io_buffer_check_overlaps(buffer, mask_buffer);
void *base;
size_t size;
- io_buffer_get_bytes_for_writing(data, &base, &size);
+ io_buffer_get_bytes_for_writing(buffer, &base, &size);
- memory_and_inplace(base, size, mask_data->base, mask_data->size);
+ memory_and_inplace(base, size, mask_buffer->base, mask_buffer->size);
return self;
}
@@ -3047,20 +3424,20 @@ memory_or_inplace(unsigned char * restrict base, size_t size, unsigned char * re
static VALUE
io_buffer_or_inplace(VALUE self, VALUE mask)
{
- struct rb_io_buffer *data = NULL;
- TypedData_Get_Struct(self, struct rb_io_buffer, &rb_io_buffer_type, data);
+ struct rb_io_buffer *buffer = NULL;
+ TypedData_Get_Struct(self, struct rb_io_buffer, &rb_io_buffer_type, buffer);
- struct rb_io_buffer *mask_data = NULL;
- TypedData_Get_Struct(mask, struct rb_io_buffer, &rb_io_buffer_type, mask_data);
+ struct rb_io_buffer *mask_buffer = NULL;
+ TypedData_Get_Struct(mask, struct rb_io_buffer, &rb_io_buffer_type, mask_buffer);
- io_buffer_check_mask(mask_data);
- io_buffer_check_overlaps(data, mask_data);
+ io_buffer_check_mask(mask_buffer);
+ io_buffer_check_overlaps(buffer, mask_buffer);
void *base;
size_t size;
- io_buffer_get_bytes_for_writing(data, &base, &size);
+ io_buffer_get_bytes_for_writing(buffer, &base, &size);
- memory_or_inplace(base, size, mask_data->base, mask_data->size);
+ memory_or_inplace(base, size, mask_buffer->base, mask_buffer->size);
return self;
}
@@ -3093,20 +3470,20 @@ memory_xor_inplace(unsigned char * restrict base, size_t size, unsigned char * r
static VALUE
io_buffer_xor_inplace(VALUE self, VALUE mask)
{
- struct rb_io_buffer *data = NULL;
- TypedData_Get_Struct(self, struct rb_io_buffer, &rb_io_buffer_type, data);
+ struct rb_io_buffer *buffer = NULL;
+ TypedData_Get_Struct(self, struct rb_io_buffer, &rb_io_buffer_type, buffer);
- struct rb_io_buffer *mask_data = NULL;
- TypedData_Get_Struct(mask, struct rb_io_buffer, &rb_io_buffer_type, mask_data);
+ struct rb_io_buffer *mask_buffer = NULL;
+ TypedData_Get_Struct(mask, struct rb_io_buffer, &rb_io_buffer_type, mask_buffer);
- io_buffer_check_mask(mask_data);
- io_buffer_check_overlaps(data, mask_data);
+ io_buffer_check_mask(mask_buffer);
+ io_buffer_check_overlaps(buffer, mask_buffer);
void *base;
size_t size;
- io_buffer_get_bytes_for_writing(data, &base, &size);
+ io_buffer_get_bytes_for_writing(buffer, &base, &size);
- memory_xor_inplace(base, size, mask_data->base, mask_data->size);
+ memory_xor_inplace(base, size, mask_buffer->base, mask_buffer->size);
return self;
}
@@ -3139,12 +3516,12 @@ memory_not_inplace(unsigned char * restrict base, size_t size)
static VALUE
io_buffer_not_inplace(VALUE self)
{
- struct rb_io_buffer *data = NULL;
- TypedData_Get_Struct(self, struct rb_io_buffer, &rb_io_buffer_type, data);
+ struct rb_io_buffer *buffer = NULL;
+ TypedData_Get_Struct(self, struct rb_io_buffer, &rb_io_buffer_type, buffer);
void *base;
size_t size;
- io_buffer_get_bytes_for_writing(data, &base, &size);
+ io_buffer_get_bytes_for_writing(buffer, &base, &size);
memory_not_inplace(base, size);
@@ -3154,24 +3531,28 @@ io_buffer_not_inplace(VALUE self)
/*
* Document-class: IO::Buffer
*
- * IO::Buffer is a low-level efficient buffer for input/output. There are three
- * ways of using buffer:
+ * IO::Buffer is a efficient zero-copy buffer for input/output. There are
+ * typical use cases:
*
- * * Create an empty buffer with ::new, fill it with data using #copy or
- * #set_value, #set_string, get data with #get_string;
+ * * Create an empty buffer with ::new, fill it with buffer using #copy or
+ * #set_value, #set_string, get buffer with #get_string or write it directly
+ * to some file with #write.
* * Create a buffer mapped to some string with ::for, then it could be used
* both for reading with #get_string or #get_value, and writing (writing will
- * change the source string, too);
+ * change the source string, too).
* * Create a buffer mapped to some file with ::map, then it could be used for
* reading and writing the underlying file.
+ * * Create a string of a fixed size with ::string, then #read into it, or
+ * modify it using #set_value.
*
* Interaction with string and file memory is performed by efficient low-level
* C mechanisms like `memcpy`.
*
* The class is meant to be an utility for implementing more high-level mechanisms
- * like Fiber::SchedulerInterface#io_read and Fiber::SchedulerInterface#io_write.
+ * like Fiber::Scheduler#io_read and Fiber::Scheduler#io_write and parsing binary
+ * protocols.
*
- * <b>Examples of usage:</b>
+ * == Examples of Usage
*
* Empty buffer:
*
@@ -3190,7 +3571,7 @@ io_buffer_not_inplace(VALUE self)
*
* \Buffer from string:
*
- * string = 'data'
+ * string = 'buffer'
* buffer = IO::Buffer.for(string)
* # =>
* # #<IO::Buffer 0x00007f3f02be9b18+4 SLICE>
@@ -3198,7 +3579,7 @@ io_buffer_not_inplace(VALUE self)
* buffer
* # =>
* # #<IO::Buffer 0x00007f3f02be9b18+4 SLICE>
- * # 0x00000000 64 61 74 61 data
+ * # 0x00000000 64 61 74 61 buffer
*
* buffer.get_string(2) # read content starting from offset 2
* # => "ta"
@@ -3213,7 +3594,7 @@ io_buffer_not_inplace(VALUE self)
*
* \Buffer from file:
*
- * File.write('test.txt', 'test data')
+ * File.write('test.txt', 'test buffer')
* # => 9
* buffer = IO::Buffer.map(File.open('test.txt'))
* # =>
@@ -3230,22 +3611,35 @@ io_buffer_not_inplace(VALUE self)
* buffer.set_string('---', 1)
* # => 3 -- bytes written
* File.read('test.txt')
- * # => "t--- data"
+ * # => "t--- buffer"
*
- * <b>The class is experimental and the interface is subject to change.</b>
+ * <b>The class is experimental and the interface is subject to change, this
+ * is especially true of file mappings which may be removed entirely in
+ * the future.</b>
*/
void
Init_IO_Buffer(void)
{
rb_cIOBuffer = rb_define_class_under(rb_cIO, "Buffer", rb_cObject);
+
+ /* Raised when an operation would resize or re-allocate a locked buffer. */
rb_eIOBufferLockedError = rb_define_class_under(rb_cIOBuffer, "LockedError", rb_eRuntimeError);
+
+ /* Raised when the buffer cannot be allocated for some reason, or you try to use a buffer that's not allocated. */
rb_eIOBufferAllocationError = rb_define_class_under(rb_cIOBuffer, "AllocationError", rb_eRuntimeError);
+
+ /* Raised when you try to write to a read-only buffer, or resize an external buffer. */
rb_eIOBufferAccessError = rb_define_class_under(rb_cIOBuffer, "AccessError", rb_eRuntimeError);
+
+ /* Raised if you try to access a buffer slice which no longer references a valid memory range of the underlying source. */
rb_eIOBufferInvalidatedError = rb_define_class_under(rb_cIOBuffer, "InvalidatedError", rb_eRuntimeError);
+
+ /* Raised if the mask given to a binary operation is invalid, e.g. zero length or overlaps the target buffer. */
rb_eIOBufferMaskError = rb_define_class_under(rb_cIOBuffer, "MaskError", rb_eArgError);
rb_define_alloc_func(rb_cIOBuffer, rb_io_buffer_type_allocate);
rb_define_singleton_method(rb_cIOBuffer, "for", rb_io_buffer_type_for, 1);
+ rb_define_singleton_method(rb_cIOBuffer, "string", rb_io_buffer_type_string, 1);
#ifdef _WIN32
SYSTEM_INFO info;
@@ -3257,37 +3651,57 @@ Init_IO_Buffer(void)
RUBY_IO_BUFFER_DEFAULT_SIZE = io_buffer_default_size(RUBY_IO_BUFFER_PAGE_SIZE);
- // Efficient sizing of mapped buffers:
+ /* The operating system page size. Used for efficient page-aligned memory allocations. */
rb_define_const(rb_cIOBuffer, "PAGE_SIZE", SIZET2NUM(RUBY_IO_BUFFER_PAGE_SIZE));
+
+ /* The default buffer size, typically a (small) multiple of the PAGE_SIZE.
+ Can be explicitly specified by setting the RUBY_IO_BUFFER_DEFAULT_SIZE
+ environment variable. */
rb_define_const(rb_cIOBuffer, "DEFAULT_SIZE", SIZET2NUM(RUBY_IO_BUFFER_DEFAULT_SIZE));
rb_define_singleton_method(rb_cIOBuffer, "map", io_buffer_map, -1);
- // General use:
rb_define_method(rb_cIOBuffer, "initialize", rb_io_buffer_initialize, -1);
rb_define_method(rb_cIOBuffer, "initialize_copy", rb_io_buffer_initialize_copy, 1);
rb_define_method(rb_cIOBuffer, "inspect", rb_io_buffer_inspect, 0);
- rb_define_method(rb_cIOBuffer, "hexdump", rb_io_buffer_hexdump, 0);
+ rb_define_method(rb_cIOBuffer, "hexdump", rb_io_buffer_hexdump, -1);
rb_define_method(rb_cIOBuffer, "to_s", rb_io_buffer_to_s, 0);
rb_define_method(rb_cIOBuffer, "size", rb_io_buffer_size, 0);
rb_define_method(rb_cIOBuffer, "valid?", rb_io_buffer_valid_p, 0);
- // Ownership:
rb_define_method(rb_cIOBuffer, "transfer", rb_io_buffer_transfer, 0);
- // Flags:
+ /* Indicates that the memory in the buffer is owned by someone else. See #external? for more details. */
rb_define_const(rb_cIOBuffer, "EXTERNAL", RB_INT2NUM(RB_IO_BUFFER_EXTERNAL));
+
+ /* Indicates that the memory in the buffer is owned by the buffer. See #internal? for more details. */
rb_define_const(rb_cIOBuffer, "INTERNAL", RB_INT2NUM(RB_IO_BUFFER_INTERNAL));
+
+ /* Indicates that the memory in the buffer is mapped by the operating system. See #mapped? for more details. */
rb_define_const(rb_cIOBuffer, "MAPPED", RB_INT2NUM(RB_IO_BUFFER_MAPPED));
+
+ /* Indicates that the memory in the buffer is also mapped such that it can be shared with other processes. See #shared? for more details. */
rb_define_const(rb_cIOBuffer, "SHARED", RB_INT2NUM(RB_IO_BUFFER_SHARED));
+
+ /* Indicates that the memory in the buffer is locked and cannot be resized or freed. See #locked? and #locked for more details. */
rb_define_const(rb_cIOBuffer, "LOCKED", RB_INT2NUM(RB_IO_BUFFER_LOCKED));
+
+ /* Indicates that the memory in the buffer is mapped privately and changes won't be replicated to the underlying file. See #private? for more details. */
rb_define_const(rb_cIOBuffer, "PRIVATE", RB_INT2NUM(RB_IO_BUFFER_PRIVATE));
+
+ /* Indicates that the memory in the buffer is read only, and attempts to modify it will fail. See #readonly? for more details.*/
rb_define_const(rb_cIOBuffer, "READONLY", RB_INT2NUM(RB_IO_BUFFER_READONLY));
- // Endian:
+ /* Refers to little endian byte order, where the least significant byte is stored first. See #get_value for more details. */
rb_define_const(rb_cIOBuffer, "LITTLE_ENDIAN", RB_INT2NUM(RB_IO_BUFFER_LITTLE_ENDIAN));
+
+ /* Refers to big endian byte order, where the most significant byte is stored first. See #get_value for more details. */
rb_define_const(rb_cIOBuffer, "BIG_ENDIAN", RB_INT2NUM(RB_IO_BUFFER_BIG_ENDIAN));
+
+ /* Refers to the byte order of the host machine. See #get_value for more details. */
rb_define_const(rb_cIOBuffer, "HOST_ENDIAN", RB_INT2NUM(RB_IO_BUFFER_HOST_ENDIAN));
+
+ /* Refers to network byte order, which is the same as big endian. See #get_value for more details. */
rb_define_const(rb_cIOBuffer, "NETWORK_ENDIAN", RB_INT2NUM(RB_IO_BUFFER_NETWORK_ENDIAN));
rb_define_method(rb_cIOBuffer, "null?", rb_io_buffer_null_p, 0);
@@ -3297,6 +3711,7 @@ Init_IO_Buffer(void)
rb_define_method(rb_cIOBuffer, "mapped?", rb_io_buffer_mapped_p, 0);
rb_define_method(rb_cIOBuffer, "shared?", rb_io_buffer_shared_p, 0);
rb_define_method(rb_cIOBuffer, "locked?", rb_io_buffer_locked_p, 0);
+ rb_define_method(rb_cIOBuffer, "private?", rb_io_buffer_private_p, 0);
rb_define_method(rb_cIOBuffer, "readonly?", io_buffer_readonly_p, 0);
// Locking to prevent changes while using pointer:
@@ -3354,7 +3769,7 @@ Init_IO_Buffer(void)
rb_define_method(rb_cIOBuffer, "get_string", io_buffer_get_string, -1);
rb_define_method(rb_cIOBuffer, "set_string", io_buffer_set_string, -1);
- // Binary data manipulations:
+ // Binary buffer manipulations:
rb_define_method(rb_cIOBuffer, "&", io_buffer_and, 1);
rb_define_method(rb_cIOBuffer, "|", io_buffer_or, 1);
rb_define_method(rb_cIOBuffer, "^", io_buffer_xor, 1);
diff --git a/iseq.c b/iseq.c
index 50eb005c0a..27c5bb5d82 100644
--- a/iseq.c
+++ b/iseq.c
@@ -19,7 +19,6 @@
#endif
#include "eval_intern.h"
-#include "gc.h"
#include "id_table.h"
#include "internal.h"
#include "internal/bits.h"
@@ -27,14 +26,15 @@
#include "internal/compile.h"
#include "internal/error.h"
#include "internal/file.h"
+#include "internal/gc.h"
#include "internal/hash.h"
-#include "internal/parse.h"
+#include "internal/ruby_parser.h"
#include "internal/sanitizers.h"
#include "internal/symbol.h"
#include "internal/thread.h"
#include "internal/variable.h"
#include "iseq.h"
-#include "mjit.h"
+#include "rjit.h"
#include "ruby/util.h"
#include "vm_core.h"
#include "vm_callinfo.h"
@@ -164,15 +164,19 @@ rb_iseq_free(const rb_iseq_t *iseq)
if (iseq && ISEQ_BODY(iseq)) {
iseq_clear_ic_references(iseq);
struct rb_iseq_constant_body *const body = ISEQ_BODY(iseq);
- mjit_free_iseq(iseq); /* Notify MJIT */
+ rb_rjit_free_iseq(iseq); /* Notify RJIT */
#if USE_YJIT
rb_yjit_iseq_free(body->yjit_payload);
+ if (FL_TEST_RAW((VALUE)iseq, ISEQ_TRANSLATED)) {
+ RUBY_ASSERT(rb_yjit_live_iseq_count > 0);
+ rb_yjit_live_iseq_count--;
+ }
#endif
ruby_xfree((void *)body->iseq_encoded);
ruby_xfree((void *)body->insns_info.body);
- if (body->insns_info.positions) ruby_xfree((void *)body->insns_info.positions);
+ ruby_xfree((void *)body->insns_info.positions);
#if VM_INSN_INFO_TABLE_IMPL == 2
- if (body->insns_info.succ_index_table) ruby_xfree(body->insns_info.succ_index_table);
+ ruby_xfree(body->insns_info.succ_index_table);
#endif
if (LIKELY(body->local_table != rb_iseq_shared_exc_local_tbl))
ruby_xfree((void *)body->local_table);
@@ -187,7 +191,11 @@ rb_iseq_free(const rb_iseq_t *iseq)
ruby_xfree((void *)body->mark_bits.list);
}
+ ruby_xfree(body->variable.original_iseq);
+
if (body->param.keyword != NULL) {
+ if (body->param.keyword->table != &body->local_table[body->param.keyword->bits_start - body->param.keyword->num])
+ ruby_xfree((void *)body->param.keyword->table);
ruby_xfree((void *)body->param.keyword->default_values);
ruby_xfree((void *)body->param.keyword);
}
@@ -282,8 +290,31 @@ rb_iseq_mark_and_move_each_value(const rb_iseq_t *iseq, VALUE *original_iseq)
}
}
+static bool
+cc_is_active(const struct rb_callcache *cc, bool reference_updating)
+{
+ if (cc) {
+ if (reference_updating) {
+ cc = (const struct rb_callcache *)rb_gc_location((VALUE)cc);
+ }
+
+ if (vm_cc_markable(cc)) {
+ if (cc->klass) { // cc is not invalidated
+ const struct rb_callable_method_entry_struct *cme = vm_cc_cme(cc);
+ if (reference_updating) {
+ cme = (const struct rb_callable_method_entry_struct *)rb_gc_location((VALUE)cme);
+ }
+ if (!METHOD_ENTRY_INVALIDATED(cme)) {
+ return true;
+ }
+ }
+ }
+ }
+ return false;
+}
+
void
-rb_iseq_mark_and_update(rb_iseq_t *iseq, bool reference_updating)
+rb_iseq_mark_and_move(rb_iseq_t *iseq, bool reference_updating)
{
RUBY_MARK_ENTER("iseq");
@@ -310,27 +341,11 @@ rb_iseq_mark_and_update(rb_iseq_t *iseq, bool reference_updating)
if (cds[i].ci) rb_gc_mark_and_move_ptr(&cds[i].ci);
- const struct rb_callcache *cc = cds[i].cc;
- if (cc) {
- if (reference_updating) {
- cc = (const struct rb_callcache *)rb_gc_location((VALUE)cc);
- }
-
- if (vm_cc_markable(cc)) {
- VM_ASSERT((cc->flags & VM_CALLCACHE_ON_STACK) == 0);
-
- const struct rb_callable_method_entry_struct *cme = vm_cc_cme(cc);
- if (reference_updating) {
- cme = (const struct rb_callable_method_entry_struct *)rb_gc_location((VALUE)cme);
- }
-
- if (cc->klass && !METHOD_ENTRY_INVALIDATED(cme)) {
- rb_gc_mark_and_move_ptr(&cds[i].cc);
- }
- else {
- cds[i].cc = rb_vm_empty_cc();
- }
- }
+ if (cc_is_active(cds[i].cc, reference_updating)) {
+ rb_gc_mark_and_move_ptr(&cds[i].cc);
+ }
+ else {
+ cds[i].cc = rb_vm_empty_cc();
}
}
}
@@ -356,16 +371,16 @@ rb_iseq_mark_and_update(rb_iseq_t *iseq, bool reference_updating)
}
if (reference_updating) {
-#if USE_MJIT
- mjit_update_references(iseq);
+#if USE_RJIT
+ rb_rjit_iseq_update_references(body);
#endif
#if USE_YJIT
rb_yjit_iseq_update_references(body->yjit_payload);
#endif
}
else {
-#if USE_MJIT
- mjit_mark_cc_entries(body);
+#if USE_RJIT
+ rb_rjit_iseq_mark(body->rjit_blocks);
#endif
#if USE_YJIT
rb_yjit_iseq_mark(body->yjit_payload);
@@ -379,7 +394,14 @@ rb_iseq_mark_and_update(rb_iseq_t *iseq, bool reference_updating)
else if (FL_TEST_RAW((VALUE)iseq, ISEQ_USE_COMPILE_DATA)) {
const struct iseq_compile_data *const compile_data = ISEQ_COMPILE_DATA(iseq);
- rb_iseq_mark_and_update_insn_storage(compile_data->insn.storage_head);
+ if (!reference_updating) {
+ /* The operands in each instruction needs to be pinned because
+ * if auto-compaction runs in iseq_set_sequence, then the objects
+ * could exist on the generated_iseq buffer, which would not be
+ * reference updated which can lead to T_MOVED (and subsequently
+ * T_NONE) objects on the iseq. */
+ rb_iseq_mark_and_pin_insn_storage(compile_data->insn.storage_head);
+ }
rb_gc_mark_and_move((VALUE *)&compile_data->err_info);
rb_gc_mark_and_move((VALUE *)&compile_data->catch_table_ary);
@@ -706,7 +728,6 @@ static rb_compile_option_t COMPILE_OPTION_DEFAULT = {
OPT_SPECIALISED_INSTRUCTION, /* int specialized_instruction; */
OPT_OPERANDS_UNIFICATION, /* int operands_unification; */
OPT_INSTRUCTIONS_UNIFICATION, /* int instructions_unification; */
- OPT_STACK_CACHING, /* int stack_caching; */
OPT_FROZEN_STRING_LITERAL,
OPT_DEBUG_FROZEN_STRING_LITERAL,
TRUE, /* coverage_enabled */
@@ -723,7 +744,7 @@ set_compile_option_from_hash(rb_compile_option_t *option, VALUE opt)
else if (flag == Qfalse) { (o)->mem = 0; } \
}
#define SET_COMPILE_OPTION_NUM(o, h, mem) \
- { VALUE num = rb_hash_aref(opt, ID2SYM(rb_intern(#mem))); \
+ { VALUE num = rb_hash_aref((h), ID2SYM(rb_intern(#mem))); \
if (!NIL_P(num)) (o)->mem = NUM2INT(num); \
}
SET_COMPILE_OPTION(option, opt, inline_const_cache);
@@ -732,7 +753,6 @@ set_compile_option_from_hash(rb_compile_option_t *option, VALUE opt)
SET_COMPILE_OPTION(option, opt, specialized_instruction);
SET_COMPILE_OPTION(option, opt, operands_unification);
SET_COMPILE_OPTION(option, opt, instructions_unification);
- SET_COMPILE_OPTION(option, opt, stack_caching);
SET_COMPILE_OPTION(option, opt, frozen_string_literal);
SET_COMPILE_OPTION(option, opt, debug_frozen_string_literal);
SET_COMPILE_OPTION(option, opt, coverage_enabled);
@@ -741,11 +761,15 @@ set_compile_option_from_hash(rb_compile_option_t *option, VALUE opt)
#undef SET_COMPILE_OPTION_NUM
}
-static void
-rb_iseq_make_compile_option(rb_compile_option_t *option, VALUE opt)
+static rb_compile_option_t *
+set_compile_option_from_ast(rb_compile_option_t *option, const rb_ast_body_t *ast)
{
- Check_Type(opt, T_HASH);
- set_compile_option_from_hash(option, opt);
+#define SET_COMPILE_OPTION(o, a, mem) \
+ ((a)->mem < 0 ? 0 : ((o)->mem = (a)->mem > 0))
+ SET_COMPILE_OPTION(option, ast, frozen_string_literal);
+ SET_COMPILE_OPTION(option, ast, coverage_enabled);
+#undef SET_COMPILE_OPTION
+ return option;
}
static void
@@ -786,7 +810,6 @@ make_compile_option_value(rb_compile_option_t *option)
SET_COMPILE_OPTION(option, opt, specialized_instruction);
SET_COMPILE_OPTION(option, opt, operands_unification);
SET_COMPILE_OPTION(option, opt, instructions_unification);
- SET_COMPILE_OPTION(option, opt, stack_caching);
SET_COMPILE_OPTION(option, opt, frozen_string_literal);
SET_COMPILE_OPTION(option, opt, debug_frozen_string_literal);
SET_COMPILE_OPTION(option, opt, coverage_enabled);
@@ -902,13 +925,11 @@ rb_iseq_new_with_opt(const rb_ast_body_t *ast, VALUE name, VALUE path, VALUE rea
rb_iseq_t *iseq = iseq_alloc();
rb_compile_option_t new_opt;
- if (option) {
+ if (!option) option = &COMPILE_OPTION_DEFAULT;
+ if (ast) {
new_opt = *option;
+ option = set_compile_option_from_ast(&new_opt, ast);
}
- else {
- new_opt = COMPILE_OPTION_DEFAULT;
- }
- if (ast && ast->compile_option) rb_iseq_make_compile_option(&new_opt, ast->compile_option);
VALUE script_lines = Qnil;
@@ -920,7 +941,7 @@ rb_iseq_new_with_opt(const rb_ast_body_t *ast, VALUE name, VALUE path, VALUE rea
}
prepare_iseq_build(iseq, name, path, realpath, first_lineno, node ? &node->nd_loc : NULL, node ? nd_node_id(node) : -1,
- parent, isolated_depth, type, script_lines, &new_opt);
+ parent, isolated_depth, type, script_lines, option);
rb_iseq_compile_node(iseq, node);
finish_iseq_build(iseq);
@@ -928,6 +949,46 @@ rb_iseq_new_with_opt(const rb_ast_body_t *ast, VALUE name, VALUE path, VALUE rea
return iseq_translate(iseq);
}
+VALUE rb_iseq_compile_prism_node(rb_iseq_t * iseq, pm_scope_node_t *scope_node, pm_parser_t *parser);
+
+/**
+ * Initialize an rb_code_location_t with a prism location.
+ */
+static void
+pm_code_location(rb_code_location_t *code_location, const pm_newline_list_t *newline_list, const pm_location_t *location)
+{
+ pm_line_column_t start = pm_newline_list_line_column(newline_list, location->start);
+ pm_line_column_t end = pm_newline_list_line_column(newline_list, location->end);
+
+ *code_location = (rb_code_location_t) {
+ .beg_pos = { .lineno = (int) start.line, .column = (int) start.column },
+ .end_pos = { .lineno = (int) end.line, .column = (int) end.column }
+ };
+}
+
+rb_iseq_t *
+pm_iseq_new_with_opt(pm_scope_node_t *scope_node, pm_parser_t *parser, VALUE name, VALUE path, VALUE realpath,
+ int first_lineno, const rb_iseq_t *parent, int isolated_depth,
+ enum rb_iseq_type type, const rb_compile_option_t *option)
+{
+ rb_iseq_t *iseq = iseq_alloc();
+ VALUE script_lines = Qnil;
+ if (!option) option = &COMPILE_OPTION_DEFAULT;
+
+ rb_code_location_t code_location;
+ pm_code_location(&code_location, &parser->newline_list, &scope_node->base.location);
+
+ // TODO: node_id
+ int node_id = -1;
+ prepare_iseq_build(iseq, name, path, realpath, first_lineno, &code_location, node_id,
+ parent, isolated_depth, type, script_lines, option);
+
+ rb_iseq_compile_prism_node(iseq, scope_node, parser);
+ finish_iseq_build(iseq);
+
+ return iseq_translate(iseq);
+}
+
rb_iseq_t *
rb_iseq_new_with_callback(
const struct rb_iseq_new_with_callback_callback_func * ifunc,
@@ -1109,6 +1170,7 @@ rb_iseq_compile_with_option(VALUE src, VALUE file, VALUE realpath, VALUE line, V
const rb_iseq_t *outer_scope = rb_iseq_new(NULL, name, name, Qnil, 0, ISEQ_TYPE_TOP);
VALUE outer_scope_v = (VALUE)outer_scope;
rb_parser_set_context(parser, outer_scope, FALSE);
+ rb_parser_set_script_lines(parser, RBOOL(ruby_vm_keep_script_lines));
RB_GC_GUARD(outer_scope_v);
ast = (*parse)(parser, file, src, ln);
}
@@ -1281,8 +1343,8 @@ rb_iseqw_new(const rb_iseq_t *iseq)
* InstructionSequence.compile(source[, file[, path[, line[, options]]]]) -> iseq
* InstructionSequence.new(source[, file[, path[, line[, options]]]]) -> iseq
*
- * Takes +source+, a String of Ruby code and compiles it to an
- * InstructionSequence.
+ * Takes +source+, which can be a string of Ruby code, or an open +File+ object.
+ * that contains Ruby source code.
*
* Optionally takes +file+, +path+, and +line+ which describe the file path,
* real path and first line number of the ruby code in +source+ which are
@@ -1304,6 +1366,10 @@ rb_iseqw_new(const rb_iseq_t *iseq)
* RubyVM::InstructionSequence.compile(File.read(path), path, File.expand_path(path))
* #=> <RubyVM::InstructionSequence:<compiled>@test.rb:1>
*
+ * file = File.open("test.rb")
+ * RubyVM::InstructionSequence.compile(file)
+ * #=> <RubyVM::InstructionSequence:<compiled>@<compiled>:1>
+ *
* path = File.expand_path("test.rb")
* RubyVM::InstructionSequence.compile(File.read(path), path, path)
* #=> <RubyVM::InstructionSequence:<compiled>@/absolute/path/to/test.rb:1>
@@ -1312,7 +1378,7 @@ rb_iseqw_new(const rb_iseq_t *iseq)
static VALUE
iseqw_s_compile(int argc, VALUE *argv, VALUE self)
{
- VALUE src, file = Qnil, path = Qnil, line = INT2FIX(1), opt = Qnil;
+ VALUE src, file = Qnil, path = Qnil, line = Qnil, opt = Qnil;
int i;
i = rb_scan_args(argc, argv, "1*:", &src, NULL, &opt);
@@ -1334,6 +1400,125 @@ iseqw_s_compile(int argc, VALUE *argv, VALUE self)
return iseqw_new(rb_iseq_compile_with_option(src, file, path, line, opt));
}
+static void
+iseqw_s_compile_prism_compile(pm_parser_t *parser, VALUE opt, rb_iseq_t *iseq, VALUE file, VALUE path, int first_lineno)
+{
+ pm_node_t *node = pm_parse(parser);
+ rb_code_location_t code_location;
+ pm_code_location(&code_location, &parser->newline_list, &node->location);
+
+ rb_compile_option_t option;
+ make_compile_option(&option, opt);
+ prepare_iseq_build(iseq, rb_fstring_lit("<compiled>"), file, path, first_lineno, &code_location, -1, NULL, 0, ISEQ_TYPE_TOP, Qnil, &option);
+
+ pm_scope_node_t scope_node;
+ pm_scope_node_init(node, &scope_node, NULL, parser);
+ rb_iseq_compile_prism_node(iseq, &scope_node, parser);
+
+ finish_iseq_build(iseq);
+ pm_node_destroy(parser, node);
+}
+
+static VALUE
+iseqw_s_compile_prism(int argc, VALUE *argv, VALUE self)
+{
+ VALUE src, file = Qnil, path = Qnil, line = Qnil, opt = Qnil;
+ int i;
+
+ i = rb_scan_args(argc, argv, "1*:", &src, NULL, &opt);
+ if (i > 4+NIL_P(opt)) rb_error_arity(argc, 1, 5);
+ switch (i) {
+ case 5: opt = argv[--i];
+ case 4: line = argv[--i];
+ case 3: path = argv[--i];
+ case 2: file = argv[--i];
+ }
+
+ if (NIL_P(file)) file = rb_fstring_lit("<compiled>");
+ if (NIL_P(path)) path = file;
+ if (NIL_P(line)) line = INT2FIX(1);
+
+ Check_Type(path, T_STRING);
+ Check_Type(file, T_STRING);
+
+ pm_options_t options = { 0 };
+ pm_options_filepath_set(&options, RSTRING_PTR(file));
+
+ int start_line = NUM2INT(line);
+ pm_options_line_set(&options, start_line);
+
+ pm_parser_t parser;
+
+ if (RB_TYPE_P(src, T_FILE)) {
+ FilePathValue(src);
+ file = rb_fstring(src); /* rb_io_t->pathv gets frozen anyways */
+
+ pm_string_t input;
+ pm_string_mapped_init(&input, RSTRING_PTR(file));
+
+ pm_parser_init(&parser, pm_string_source(&input), pm_string_length(&input), &options);
+ }
+ else {
+ pm_parser_init(&parser, (const uint8_t *) RSTRING_PTR(src), RSTRING_LEN(src), &options);
+ }
+
+ rb_iseq_t *iseq = iseq_alloc();
+ iseqw_s_compile_prism_compile(&parser, opt, iseq, file, path, start_line);
+ pm_parser_free(&parser);
+ pm_options_free(&options);
+
+ return iseqw_new(iseq);
+}
+
+static VALUE
+iseqw_s_compile_file_prism(int argc, VALUE *argv, VALUE self)
+{
+ VALUE file = Qnil, opt = Qnil;
+ int i;
+
+ i = rb_scan_args(argc, argv, "1*:", &file, NULL, &opt);
+ if (i > 1+NIL_P(opt)) rb_error_arity(argc, 1, 5);
+ switch (i) {
+ case 2: opt = argv[--i];
+ }
+ FilePathValue(file);
+ file = rb_fstring(file); /* rb_io_t->pathv gets frozen anyways */
+
+ pm_string_t input;
+ pm_string_mapped_init(&input, RSTRING_PTR(file));
+
+ pm_options_t options = { 0 };
+ pm_options_filepath_set(&options, RSTRING_PTR(file));
+
+ pm_parser_t parser;
+ pm_parser_init(&parser, pm_string_source(&input), pm_string_length(&input), &options);
+
+ rb_iseq_t *iseq = iseq_alloc();
+ iseqw_s_compile_prism_compile(&parser, opt, iseq, file, rb_realpath_internal(Qnil, file, 1), 1);
+ pm_parser_free(&parser);
+ pm_string_free(&input);
+ pm_options_free(&options);
+
+ return iseqw_new(iseq);
+}
+
+rb_iseq_t *
+rb_iseq_new_main_prism(pm_string_t *input, pm_options_t *options, VALUE path)
+{
+ pm_parser_t parser;
+ pm_parser_init(&parser, pm_string_source(input), pm_string_length(input), options);
+
+ if (NIL_P(path)) path = rb_fstring_lit("<compiled>");
+ int start_line = 0;
+ pm_options_line_set(options, start_line);
+
+ rb_iseq_t *iseq = iseq_alloc();
+ iseqw_s_compile_prism_compile(&parser, Qnil, iseq, path, path, start_line);
+
+ pm_parser_free(&parser);
+ return iseq;
+}
+
/*
* call-seq:
* InstructionSequence.compile_file(file[, options]) -> iseq
@@ -1422,7 +1607,6 @@ iseqw_s_compile_file(int argc, VALUE *argv, VALUE self)
* * +:operands_unification+
* * +:peephole_optimization+
* * +:specialized_instruction+
- * * +:stack_caching+
* * +:tailcall_optimization+
*
* Additionally, +:debug_level+ can be set to an integer.
@@ -1908,7 +2092,7 @@ rb_iseq_node_id(const rb_iseq_t *iseq, size_t pos)
}
#endif
-MJIT_FUNC_EXPORTED rb_event_flag_t
+rb_event_flag_t
rb_iseq_event_flags(const rb_iseq_t *iseq, size_t pos)
{
const struct iseq_insn_info_entry *entry = get_insn_info(iseq, pos);
@@ -1950,7 +2134,7 @@ local_var_name(const rb_iseq_t *diseq, VALUE level, VALUE op)
if (!name) {
name = rb_str_new_cstr("?");
}
- else if (!rb_str_symname_p(name)) {
+ else if (!rb_is_local_id(lid)) {
name = rb_str_inspect(name);
}
else {
@@ -2104,7 +2288,6 @@ rb_insn_operand_intern(const rb_iseq_t *iseq,
CALL_FLAG(FCALL);
CALL_FLAG(VCALL);
CALL_FLAG(ARGS_SIMPLE);
- CALL_FLAG(BLOCKISEQ);
CALL_FLAG(TAILCALL);
CALL_FLAG(SUPER);
CALL_FLAG(ZSUPER);
@@ -2208,7 +2391,7 @@ rb_iseq_disasm_insn(VALUE ret, const VALUE *code, size_t pos,
{
rb_event_flag_t events = rb_iseq_event_flags(iseq, pos);
if (events) {
- str = rb_str_catf(str, "[%s%s%s%s%s%s%s%s%s%s%s]",
+ str = rb_str_catf(str, "[%s%s%s%s%s%s%s%s%s%s%s%s]",
events & RUBY_EVENT_LINE ? "Li" : "",
events & RUBY_EVENT_CLASS ? "Cl" : "",
events & RUBY_EVENT_END ? "En" : "",
@@ -2218,6 +2401,7 @@ rb_iseq_disasm_insn(VALUE ret, const VALUE *code, size_t pos,
events & RUBY_EVENT_C_RETURN ? "Cr" : "",
events & RUBY_EVENT_B_CALL ? "Bc" : "",
events & RUBY_EVENT_B_RETURN ? "Br" : "",
+ events & RUBY_EVENT_RESCUE ? "Rs" : "",
events & RUBY_EVENT_COVERAGE_LINE ? "Cli" : "",
events & RUBY_EVENT_COVERAGE_BRANCH ? "Cbr" : "");
}
@@ -2307,7 +2491,6 @@ rb_iseq_disasm_recursive(const rb_iseq_t *iseq, VALUE indent)
rb_str_cat2(str, "== disasm: ");
rb_str_append(str, iseq_inspect(iseq));
- rb_str_catf(str, " (catch: %s)", body->catch_except_p ? "true" : "false");
if ((l = RSTRING_LEN(str) - indent_len) < header_minlen) {
rb_str_modify_expand(str, header_minlen - l);
memset(RSTRING_END(str), '=', header_minlen - l);
@@ -2563,6 +2746,7 @@ push_event_info(const rb_iseq_t *iseq, rb_event_flag_t events, int line, VALUE a
C(RUBY_EVENT_END, "end", INT2FIX(line));
C(RUBY_EVENT_RETURN, "return", INT2FIX(line));
C(RUBY_EVENT_B_RETURN, "b_return", INT2FIX(line));
+ C(RUBY_EVENT_RESCUE, "rescue", INT2FIX(line));
#undef C
}
@@ -2706,17 +2890,6 @@ iseqw_s_disasm(VALUE klass, VALUE body)
return NIL_P(iseqw) ? Qnil : rb_iseq_disasm(iseqw_check(iseqw));
}
-const char *
-ruby_node_name(int node)
-{
- switch (node) {
-#include "node_name.inc"
- default:
- rb_bug("unknown node: %d", node);
- return 0;
- }
-}
-
static VALUE
register_label(struct st_table *table, unsigned long idx)
{
@@ -3091,6 +3264,7 @@ iseq_data_to_ary(const rb_iseq_t *iseq)
CHECK_EVENT(RUBY_EVENT_RETURN);
CHECK_EVENT(RUBY_EVENT_B_CALL);
CHECK_EVENT(RUBY_EVENT_B_RETURN);
+ CHECK_EVENT(RUBY_EVENT_RESCUE);
#undef CHECK_EVENT
prev_insn_info = info;
}
@@ -3279,6 +3453,12 @@ typedef struct insn_data_struct {
static insn_data_t insn_data[VM_INSTRUCTION_SIZE/2];
void
+rb_free_encoded_insn_data(void)
+{
+ st_free_table(encoded_insn_data);
+}
+
+void
rb_vm_encoded_insn_data_table_init(void)
{
#if OPT_DIRECT_THREADED_CODE || OPT_CALL_THREADED_CODE
@@ -3550,9 +3730,32 @@ rb_iseq_trace_set(const rb_iseq_t *iseq, rb_event_flag_t turnon_events)
}
}
-bool rb_vm_call_ivar_attrset_p(const vm_call_handler ch);
void rb_vm_cc_general(const struct rb_callcache *cc);
+static bool
+clear_attr_cc(VALUE v)
+{
+ if (imemo_type_p(v, imemo_callcache) && vm_cc_ivar_p((const struct rb_callcache *)v)) {
+ rb_vm_cc_general((struct rb_callcache *)v);
+ return true;
+ }
+ else {
+ return false;
+ }
+}
+
+static bool
+clear_bf_cc(VALUE v)
+{
+ if (imemo_type_p(v, imemo_callcache) && vm_cc_bf_p((const struct rb_callcache *)v)) {
+ rb_vm_cc_general((struct rb_callcache *)v);
+ return true;
+ }
+ else {
+ return false;
+ }
+}
+
static int
clear_attr_ccs_i(void *vstart, void *vend, size_t stride, void *data)
{
@@ -3560,11 +3763,7 @@ clear_attr_ccs_i(void *vstart, void *vend, size_t stride, void *data)
for (; v != (VALUE)vend; v += stride) {
void *ptr = asan_poisoned_object_p(v);
asan_unpoison_object(v, false);
-
- if (imemo_type_p(v, imemo_callcache) && rb_vm_call_ivar_attrset_p(((const struct rb_callcache *)v)->call_)) {
- rb_vm_cc_general((struct rb_callcache *)v);
- }
-
+ clear_attr_cc(v);
asan_poison_object_if(ptr, v);
}
return 0;
@@ -3577,6 +3776,25 @@ rb_clear_attr_ccs(void)
}
static int
+clear_bf_ccs_i(void *vstart, void *vend, size_t stride, void *data)
+{
+ VALUE v = (VALUE)vstart;
+ for (; v != (VALUE)vend; v += stride) {
+ void *ptr = asan_poisoned_object_p(v);
+ asan_unpoison_object(v, false);
+ clear_bf_cc(v);
+ asan_poison_object_if(ptr, v);
+ }
+ return 0;
+}
+
+void
+rb_clear_bf_ccs(void)
+{
+ rb_objspace_each_objects(clear_bf_ccs_i, NULL);
+}
+
+static int
trace_set_i(void *vstart, void *vend, size_t stride, void *data)
{
rb_event_flag_t turnon_events = *(rb_event_flag_t *)data;
@@ -3589,8 +3807,9 @@ trace_set_i(void *vstart, void *vend, size_t stride, void *data)
if (rb_obj_is_iseq(v)) {
rb_iseq_trace_set(rb_iseq_check((rb_iseq_t *)v), turnon_events);
}
- else if (imemo_type_p(v, imemo_callcache) && rb_vm_call_ivar_attrset_p(((const struct rb_callcache *)v)->call_)) {
- rb_vm_cc_general((struct rb_callcache *)v);
+ else if (clear_attr_cc(v)) {
+ }
+ else if (clear_bf_cc(v)) {
}
asan_poison_object_if(ptr, v);
@@ -3805,7 +4024,7 @@ succ_index_lookup(const struct succ_index_table *sd, int x)
* call-seq:
* iseq.script_lines -> array or nil
*
- * It returns recorded script lines if it is availalble.
+ * It returns recorded script lines if it is available.
* The script lines are not limited to the iseq range, but
* are entire lines of the source file.
*
@@ -3878,6 +4097,8 @@ Init_ISeq(void)
(void)iseq_s_load;
rb_define_singleton_method(rb_cISeq, "compile", iseqw_s_compile, -1);
+ rb_define_singleton_method(rb_cISeq, "compile_prism", iseqw_s_compile_prism, -1);
+ rb_define_singleton_method(rb_cISeq, "compile_file_prism", iseqw_s_compile_file_prism, -1);
rb_define_singleton_method(rb_cISeq, "new", iseqw_s_compile, -1);
rb_define_singleton_method(rb_cISeq, "compile_file", iseqw_s_compile_file, -1);
rb_define_singleton_method(rb_cISeq, "compile_option", iseqw_s_compile_option_get, 0);
diff --git a/iseq.h b/iseq.h
index 5e26ea3589..d71f37ca13 100644
--- a/iseq.h
+++ b/iseq.h
@@ -11,7 +11,9 @@
**********************************************************************/
#include "internal/gc.h"
+#include "shape.h"
#include "vm_core.h"
+#include "prism_compile.h"
RUBY_EXTERN const int ruby_api_version[];
#define ISEQ_MAJOR_VERSION ((unsigned int)ruby_api_version[0])
@@ -82,9 +84,10 @@ ISEQ_ORIGINAL_ISEQ_ALLOC(const rb_iseq_t *iseq, long size)
RUBY_EVENT_CALL | \
RUBY_EVENT_RETURN| \
RUBY_EVENT_C_CALL| \
- RUBY_EVENT_C_RETURN| \
- RUBY_EVENT_B_CALL| \
- RUBY_EVENT_B_RETURN| \
+ RUBY_EVENT_C_RETURN | \
+ RUBY_EVENT_B_CALL | \
+ RUBY_EVENT_B_RETURN | \
+ RUBY_EVENT_RESCUE | \
RUBY_EVENT_COVERAGE_LINE| \
RUBY_EVENT_COVERAGE_BRANCH)
@@ -125,6 +128,7 @@ struct iseq_compile_data {
struct rb_id_table *ivar_cache_table;
const struct rb_builtin_function *builtin_function_table;
const NODE *root_node;
+ bool catch_except_p; // If a frame of this ISeq may catch exception, set true.
#if OPT_SUPPORT_JOKE
st_table *labels_table;
#endif
@@ -170,6 +174,7 @@ void rb_iseq_init_trace(rb_iseq_t *iseq);
int rb_iseq_add_local_tracepoint_recursively(const rb_iseq_t *iseq, rb_event_flag_t turnon_events, VALUE tpval, unsigned int target_line, bool target_bmethod);
int rb_iseq_remove_local_tracepoint_recursively(const rb_iseq_t *iseq, VALUE tpval);
const rb_iseq_t *rb_iseq_load_iseq(VALUE fname);
+rb_iseq_t * rb_iseq_new_main_prism(pm_string_t *input, pm_options_t *options, VALUE path);
#if VM_INSN_INFO_TABLE_IMPL == 2
unsigned int *rb_iseq_insns_info_decode_positions(const struct rb_iseq_constant_body *body);
@@ -186,7 +191,7 @@ VALUE *rb_iseq_original_iseq(const rb_iseq_t *iseq);
void rb_iseq_build_from_ary(rb_iseq_t *iseq, VALUE misc,
VALUE locals, VALUE args,
VALUE exception, VALUE body);
-void rb_iseq_mark_and_update_insn_storage(struct iseq_compile_data_storage *arena);
+void rb_iseq_mark_and_pin_insn_storage(struct iseq_compile_data_storage *arena);
VALUE rb_iseq_load(VALUE data, VALUE parent, VALUE opt);
VALUE rb_iseq_parameters(const rb_iseq_t *iseq, int is_proc);
@@ -224,7 +229,6 @@ struct rb_compile_option_struct {
unsigned int specialized_instruction: 1;
unsigned int operands_unification: 1;
unsigned int instructions_unification: 1;
- unsigned int stack_caching: 1;
unsigned int frozen_string_literal: 1;
unsigned int debug_frozen_string_literal: 1;
unsigned int coverage_enabled: 1;
@@ -270,10 +274,11 @@ struct iseq_catch_table_entry {
unsigned int sp;
};
-PACKED_STRUCT_UNALIGNED(struct iseq_catch_table {
+RBIMPL_ATTR_PACKED_STRUCT_UNALIGNED_BEGIN()
+struct iseq_catch_table {
unsigned int size;
struct iseq_catch_table_entry entries[FLEX_ARY_LEN];
-});
+} RBIMPL_ATTR_PACKED_STRUCT_UNALIGNED_END();
static inline int
iseq_catch_table_bytes(int n)
@@ -324,6 +329,10 @@ VALUE rb_iseq_defined_string(enum defined_type type);
/* vm.c */
VALUE rb_iseq_local_variables(const rb_iseq_t *iseq);
+attr_index_t rb_estimate_iv_count(VALUE klass, const rb_iseq_t * initialize_iseq);
+
+void rb_free_encoded_insn_data(void);
+
RUBY_SYMBOL_EXPORT_END
#endif /* RUBY_ISEQ_H */
diff --git a/kernel.rb b/kernel.rb
index e72e7f3f58..c6b3e44000 100644
--- a/kernel.rb
+++ b/kernel.rb
@@ -16,7 +16,7 @@ module Kernel
#++
#
def class
- Primitive.attr! 'inline'
+ Primitive.attr! :leaf
Primitive.cexpr! 'rb_obj_class(self)'
end
@@ -65,7 +65,7 @@ module Kernel
#++
#
def frozen?
- Primitive.attr! 'inline'
+ Primitive.attr! :leaf
Primitive.cexpr! 'rb_obj_frozen_p(self)'
end
@@ -117,6 +117,15 @@ module Kernel
# # does not meet condition, drop value
# 2.then.detect(&:odd?) # => nil
#
+ # Good usage for +then+ is value piping in method chains:
+ #
+ # require 'open-uri'
+ # require 'json'
+ #
+ # construct_url(arguments).
+ # then {|url| URI(url).read }.
+ # then {|response| JSON.parse(response) }
+ #
def then
unless block_given?
return Primitive.cexpr! 'SIZED_ENUMERATOR(self, 0, 0, rb_obj_size)'
@@ -132,15 +141,6 @@ module Kernel
#
# "my string".yield_self {|s| s.upcase } #=> "MY STRING"
#
- # Good usage for +then+ is value piping in method chains:
- #
- # require 'open-uri'
- # require 'json'
- #
- # construct_url(arguments).
- # then {|url| URI(url).read }.
- # then {|response| JSON.parse(response) }
- #
def yield_self
unless block_given?
return Primitive.cexpr! 'SIZED_ENUMERATOR(self, 0, 0, rb_obj_size)'
@@ -216,4 +216,97 @@ module Kernel
Primitive.rb_f_float(arg, exception)
end
end
+
+ # call-seq:
+ # Integer(object, base = 0, exception: true) -> integer or nil
+ #
+ # Returns an integer converted from +object+.
+ #
+ # Tries to convert +object+ to an integer
+ # using +to_int+ first and +to_i+ second;
+ # see below for exceptions.
+ #
+ # With a non-zero +base+, +object+ must be a string or convertible
+ # to a string.
+ #
+ # ==== numeric objects
+ #
+ # With integer argument +object+ given, returns +object+:
+ #
+ # Integer(1) # => 1
+ # Integer(-1) # => -1
+ #
+ # With floating-point argument +object+ given,
+ # returns +object+ truncated to an integer:
+ #
+ # Integer(1.9) # => 1 # Rounds toward zero.
+ # Integer(-1.9) # => -1 # Rounds toward zero.
+ #
+ # ==== string objects
+ #
+ # With string argument +object+ and zero +base+ given,
+ # returns +object+ converted to an integer in base 10:
+ #
+ # Integer('100') # => 100
+ # Integer('-100') # => -100
+ #
+ # With +base+ zero, string +object+ may contain leading characters
+ # to specify the actual base (radix indicator):
+ #
+ # Integer('0100') # => 64 # Leading '0' specifies base 8.
+ # Integer('0b100') # => 4 # Leading '0b', specifies base 2.
+ # Integer('0x100') # => 256 # Leading '0x' specifies base 16.
+ #
+ # With a positive +base+ (in range 2..36) given, returns +object+
+ # converted to an integer in the given base:
+ #
+ # Integer('100', 2) # => 4
+ # Integer('100', 8) # => 64
+ # Integer('-100', 16) # => -256
+ #
+ # With a negative +base+ (in range -36..-2) given, returns +object+
+ # converted to an integer in the radix indicator if exists or
+ # +-base+:
+ #
+ # Integer('0x100', -2) # => 256
+ # Integer('100', -2) # => 4
+ # Integer('0b100', -8) # => 4
+ # Integer('100', -8) # => 64
+ # Integer('0o100', -10) # => 64
+ # Integer('100', -10) # => 100
+ #
+ # +base+ -1 is equal the -10 case.
+ #
+ # When converting strings, surrounding whitespace and embedded underscores
+ # are allowed and ignored:
+ #
+ # Integer(' 100 ') # => 100
+ # Integer('-1_0_0', 16) # => -256
+ #
+ # ==== other classes
+ #
+ # Examples with +object+ of various other classes:
+ #
+ # Integer(Rational(9, 10)) # => 0 # Rounds toward zero.
+ # Integer(Complex(2, 0)) # => 2 # Imaginary part must be zero.
+ # Integer(Time.now) # => 1650974042
+ #
+ # ==== keywords
+ #
+ # With optional keyword argument +exception+ given as +true+ (the default):
+ #
+ # - Raises TypeError if +object+ does not respond to +to_int+ or +to_i+.
+ # - Raises TypeError if +object+ is +nil+.
+ # - Raise ArgumentError if +object+ is an invalid string.
+ #
+ # With +exception+ given as +false+, an exception of any kind is suppressed
+ # and +nil+ is returned.
+
+ def Integer(arg, base = 0, exception: true)
+ if Primitive.mandatory_only?
+ Primitive.rb_f_integer1(arg)
+ else
+ Primitive.rb_f_integer(arg, base, exception);
+ end
+ end
end
diff --git a/lib/English.gemspec b/lib/English.gemspec
index a08542bcda..5f4eb420c2 100644
--- a/lib/English.gemspec
+++ b/lib/English.gemspec
@@ -1,6 +1,6 @@
Gem::Specification.new do |spec|
spec.name = "english"
- spec.version = "0.7.2"
+ spec.version = "0.8.0"
spec.authors = ["Yukihiro Matsumoto"]
spec.email = ["matz@ruby-lang.org"]
@@ -16,7 +16,7 @@ Gem::Specification.new do |spec|
# Specify which files should be added to the gem when it is released.
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
- `git ls-files -z 2>/dev/null`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
+ `git ls-files -z 2>#{IO::NULL}`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
end
spec.require_paths = ["lib"]
end
diff --git a/lib/English.rb b/lib/English.rb
index ec90ff10cd..03fe721991 100644
--- a/lib/English.rb
+++ b/lib/English.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
# Include the English library file in a Ruby script, and you can
-# reference the global variables such as <tt>$_</tt> using less
+# reference the global variables such as <code>$_</code> using less
# cryptic names, listed below.
#
# Without 'English':
@@ -39,7 +39,6 @@
# $PROCESS_ID:: $$
# $CHILD_STATUS:: $?
# $LAST_MATCH_INFO:: $~
-# $IGNORECASE:: $=
# $ARGV:: $*
# $MATCH:: $&
# $PREMATCH:: $`
@@ -56,87 +55,73 @@ alias $ERROR_INFO $!
alias $ERROR_POSITION $@
# The default separator pattern used by String#split. May be set from
-# the command line using the <tt>-F</tt> flag.
+# the command line using the <code>-F</code> flag.
alias $FS $;
-
-# The default separator pattern used by String#split. May be set from
-# the command line using the <tt>-F</tt> flag.
alias $FIELD_SEPARATOR $;
# The separator string output between the parameters to methods such
# as Kernel#print and Array#join. Defaults to +nil+, which adds no
# text.
-alias $OFS $,
# The separator string output between the parameters to methods such
# as Kernel#print and Array#join. Defaults to +nil+, which adds no
# text.
+alias $OFS $,
alias $OUTPUT_FIELD_SEPARATOR $,
# The input record separator (newline by default). This is the value
# that routines such as Kernel#gets use to determine record
# boundaries. If set to +nil+, +gets+ will read the entire file.
alias $RS $/
-
-# The input record separator (newline by default). This is the value
-# that routines such as Kernel#gets use to determine record
-# boundaries. If set to +nil+, +gets+ will read the entire file.
alias $INPUT_RECORD_SEPARATOR $/
# The string appended to the output of every call to methods such as
# Kernel#print and IO#write. The default value is +nil+.
alias $ORS $\
-
-# The string appended to the output of every call to methods such as
-# Kernel#print and IO#write. The default value is +nil+.
alias $OUTPUT_RECORD_SEPARATOR $\
# The number of the last line read from the current input file.
-alias $INPUT_LINE_NUMBER $.
-
-# The number of the last line read from the current input file.
alias $NR $.
+alias $INPUT_LINE_NUMBER $.
# The last line read by Kernel#gets or
# Kernel#readline. Many string-related functions in the
-# Kernel module operate on <tt>$_</tt> by default. The variable is
+# Kernel module operate on <code>$_</code> by default. The variable is
# local to the current scope. Thread local.
alias $LAST_READ_LINE $_
# The destination of output for Kernel#print
# and Kernel#printf. The default value is
-# <tt>$stdout</tt>.
+# <code>$stdout</code>.
alias $DEFAULT_OUTPUT $>
# An object that provides access to the concatenation
# of the contents of all the files
-# given as command-line arguments, or <tt>$stdin</tt>
+# given as command-line arguments, or <code>$stdin</code>
# (in the case where there are no
-# arguments). <tt>$<</tt> supports methods similar to a
+# arguments). <code>$<</code> supports methods similar to a
# File object:
# +inmode+, +close+,
-# <tt>closed?</tt>, +each+,
-# <tt>each_byte</tt>, <tt>each_line</tt>,
-# +eof+, <tt>eof?</tt>, +file+,
+# <code>closed?</code>, +each+,
+# <code>each_byte</code>, <code>each_line</code>,
+# +eof+, <code>eof?</code>, +file+,
# +filename+, +fileno+,
# +getc+, +gets+, +lineno+,
-# <tt>lineno=</tt>, +path+,
-# +pos+, <tt>pos=</tt>,
+# <code>lineno=</code>, +path+,
+# +pos+, <code>pos=</code>,
# +read+, +readchar+,
# +readline+, +readlines+,
# +rewind+, +seek+, +skip+,
-# +tell+, <tt>to_a</tt>, <tt>to_i</tt>,
-# <tt>to_io</tt>, <tt>to_s</tt>, along with the
+# +tell+, <code>to_a</code>, <code>to_i</code>,
+# <code>to_io</code>, <code>to_s</code>, along with the
# methods in Enumerable. The method +file+
# returns a File object for the file currently
-# being read. This may change as <tt>$<</tt> reads
+# being read. This may change as <code>$<</code> reads
# through the files on the command line. Read only.
alias $DEFAULT_INPUT $<
# The process number of the program being executed. Read only.
alias $PID $$
-
-# The process number of the program being executed. Read only.
alias $PROCESS_ID $$
# The exit status of the last child process to terminate. Read
@@ -144,16 +129,13 @@ alias $PROCESS_ID $$
alias $CHILD_STATUS $?
# A +MatchData+ object that encapsulates the results of a successful
-# pattern match. The variables <tt>$&</tt>, <tt>$`</tt>, <tt>$'</tt>,
-# and <tt>$1</tt> to <tt>$9</tt> are all derived from
-# <tt>$~</tt>. Assigning to <tt>$~</tt> changes the values of these
+# pattern match. The variables <code>$&</code>, <code>$`</code>, <code>$'</code>,
+# and <code>$1</code> to <code>$9</code> are all derived from
+# <code>$~</code>. Assigning to <code>$~</code> changes the values of these
# derived variables. This variable is local to the current
# scope.
alias $LAST_MATCH_INFO $~
-# This variable is no longer effective. Deprecated.
-alias $IGNORECASE $=
-
# An array of strings containing the command-line
# options from the invocation of the program. Options
# used by the Ruby interpreter will have been
@@ -176,7 +158,7 @@ alias $PREMATCH $`
alias $POSTMATCH $'
# The contents of the highest-numbered group matched in the last
-# successful pattern match. Thus, in <tt>"cat" =~ /(c|a)(t|z)/</tt>,
-# <tt>$+</tt> will be set to "t". This variable is local to the
+# successful pattern match. Thus, in <code>"cat" =~ /(c|a)(t|z)/</code>,
+# <code>$+</code> will be set to "t". This variable is local to the
# current scope. Read only.
alias $LAST_PAREN_MATCH $+
diff --git a/lib/abbrev.gemspec b/lib/abbrev.gemspec
index c28b960c8c..50c500bbc7 100644
--- a/lib/abbrev.gemspec
+++ b/lib/abbrev.gemspec
@@ -1,6 +1,13 @@
+name = File.basename(__FILE__, ".gemspec")
+version = ["lib", Array.new(name.count("-")+1, ".").join("/")].find do |dir|
+ break File.foreach(File.join(__dir__, dir, "#{name.tr('-', '/')}.rb")) do |line|
+ /^\s*VERSION\s*=\s*"(.*)"/ =~ line and break $1
+ end rescue nil
+end
+
Gem::Specification.new do |spec|
- spec.name = "abbrev"
- spec.version = "0.1.1"
+ spec.name = name
+ spec.version = version
spec.authors = ["Akinori MUSHA"]
spec.email = ["knu@idaemons.org"]
diff --git a/lib/abbrev.rb b/lib/abbrev.rb
index 2af01d2eae..312085c289 100644
--- a/lib/abbrev.rb
+++ b/lib/abbrev.rb
@@ -47,6 +47,7 @@
# "w" => "winter" }
module Abbrev
+ VERSION = "0.1.2"
# Given a set of strings, calculate the set of unambiguous abbreviations for
# those strings, and return a hash where the keys are all the possible
diff --git a/lib/base64.gemspec b/lib/base64.gemspec
index daa0b7fa14..c013b7c1c2 100644
--- a/lib/base64.gemspec
+++ b/lib/base64.gemspec
@@ -1,13 +1,20 @@
+name = File.basename(__FILE__, ".gemspec")
+version = ["lib", Array.new(name.count("-")+1).join("/")].find do |dir|
+ break File.foreach(File.join(__dir__, dir, "#{name.tr('-', '/')}.rb")) do |line|
+ /^\s*VERSION\s*=\s*"(.*)"/ =~ line and break $1
+ end rescue nil
+end
+
Gem::Specification.new do |spec|
- spec.name = "base64"
- spec.version = "0.1.1"
+ spec.name = name
+ spec.version = version
spec.authors = ["Yusuke Endoh"]
spec.email = ["mame@ruby-lang.org"]
spec.summary = %q{Support for encoding and decoding binary data using a Base64 representation.}
spec.description = %q{Support for encoding and decoding binary data using a Base64 representation.}
spec.homepage = "https://github.com/ruby/base64"
- spec.required_ruby_version = Gem::Requirement.new(">= 2.3.0")
+ spec.required_ruby_version = Gem::Requirement.new(">= 2.4")
spec.licenses = ["Ruby", "BSD-2-Clause"]
spec.metadata["homepage_uri"] = spec.homepage
diff --git a/lib/base64.rb b/lib/base64.rb
index 693aa1f519..cd2ecc18ea 100644
--- a/lib/base64.rb
+++ b/lib/base64.rb
@@ -1,85 +1,330 @@
# frozen_string_literal: true
#
-# = base64.rb: methods for base64-encoding and -decoding strings
+# \Module \Base64 provides methods for:
#
-
-# The Base64 module provides for the encoding (#encode64, #strict_encode64,
-# #urlsafe_encode64) and decoding (#decode64, #strict_decode64,
-# #urlsafe_decode64) of binary data using a Base64 representation.
+# - Encoding a binary string (containing non-ASCII characters)
+# as a string of printable ASCII characters.
+# - Decoding such an encoded string.
#
-# == Example
+# \Base64 is commonly used in contexts where binary data
+# is not allowed or supported:
#
-# A simple encoding and decoding.
+# - Images in HTML or CSS files, or in URLs.
+# - Email attachments.
#
-# require "base64"
+# A \Base64-encoded string is about one-third larger that its source.
+# See the {Wikipedia article}[https://en.wikipedia.org/wiki/Base64]
+# for more information.
#
-# enc = Base64.encode64('Send reinforcements')
-# # -> "U2VuZCByZWluZm9yY2VtZW50cw==\n"
-# plain = Base64.decode64(enc)
-# # -> "Send reinforcements"
+# This module provides three pairs of encode/decode methods.
+# Your choices among these methods should depend on:
+#
+# - Which character set is to be used for encoding and decoding.
+# - Whether "padding" is to be used.
+# - Whether encoded strings are to contain newlines.
+#
+# Note: Examples on this page assume that the including program has executed:
+#
+# require 'base64'
+#
+# == Encoding Character Sets
+#
+# A \Base64-encoded string consists only of characters from a 64-character set:
+#
+# - <tt>('A'..'Z')</tt>.
+# - <tt>('a'..'z')</tt>.
+# - <tt>('0'..'9')</tt>.
+# - <tt>=</tt>, the 'padding' character.
+# - Either:
+# - <tt>%w[+ /]</tt>:
+# {RFC-2045-compliant}[https://datatracker.ietf.org/doc/html/rfc2045];
+# _not_ safe for URLs.
+# - <tt>%w[- _]</tt>:
+# {RFC-4648-compliant}[https://datatracker.ietf.org/doc/html/rfc4648];
+# safe for URLs.
+#
+# If you are working with \Base64-encoded strings that will come from
+# or be put into URLs, you should choose this encoder-decoder pair
+# of RFC-4648-compliant methods:
+#
+# - Base64.urlsafe_encode64 and Base64.urlsafe_decode64.
+#
+# Otherwise, you may choose any of the pairs in this module,
+# including the pair above, or the RFC-2045-compliant pairs:
+#
+# - Base64.encode64 and Base64.decode64.
+# - Base64.strict_encode64 and Base64.strict_decode64.
+#
+# == Padding
+#
+# \Base64-encoding changes a triplet of input bytes
+# into a quartet of output characters.
+#
+# <b>Padding in Encode Methods</b>
+#
+# Padding -- extending an encoded string with zero, one, or two trailing
+# <tt>=</tt> characters -- is performed by methods Base64.encode64,
+# Base64.strict_encode64, and, by default, Base64.urlsafe_encode64:
+#
+# Base64.encode64('s') # => "cw==\n"
+# Base64.strict_encode64('s') # => "cw=="
+# Base64.urlsafe_encode64('s') # => "cw=="
+# Base64.urlsafe_encode64('s', padding: false) # => "cw"
+#
+# When padding is performed, the encoded string is always of length <em>4n</em>,
+# where +n+ is a non-negative integer:
+#
+# - Input bytes of length <em>3n</em> generate unpadded output characters
+# of length <em>4n</em>:
+#
+# # n = 1: 3 bytes => 4 characters.
+# Base64.strict_encode64('123') # => "MDEy"
+# # n = 2: 6 bytes => 8 characters.
+# Base64.strict_encode64('123456') # => "MDEyMzQ1"
+#
+# - Input bytes of length <em>3n+1</em> generate padded output characters
+# of length <em>4(n+1)</em>, with two padding characters at the end:
+#
+# # n = 1: 4 bytes => 8 characters.
+# Base64.strict_encode64('1234') # => "MDEyMw=="
+# # n = 2: 7 bytes => 12 characters.
+# Base64.strict_encode64('1234567') # => "MDEyMzQ1Ng=="
+#
+# - Input bytes of length <em>3n+2</em> generate padded output characters
+# of length <em>4(n+1)</em>, with one padding character at the end:
+#
+# # n = 1: 5 bytes => 8 characters.
+# Base64.strict_encode64('12345') # => "MDEyMzQ="
+# # n = 2: 8 bytes => 12 characters.
+# Base64.strict_encode64('12345678') # => "MDEyMzQ1Njc="
+#
+# When padding is suppressed, for a positive integer <em>n</em>:
+#
+# - Input bytes of length <em>3n</em> generate unpadded output characters
+# of length <em>4n</em>:
+#
+# # n = 1: 3 bytes => 4 characters.
+# Base64.urlsafe_encode64('123', padding: false) # => "MDEy"
+# # n = 2: 6 bytes => 8 characters.
+# Base64.urlsafe_encode64('123456', padding: false) # => "MDEyMzQ1"
+#
+# - Input bytes of length <em>3n+1</em> generate unpadded output characters
+# of length <em>4n+2</em>, with two padding characters at the end:
+#
+# # n = 1: 4 bytes => 6 characters.
+# Base64.urlsafe_encode64('1234', padding: false) # => "MDEyMw"
+# # n = 2: 7 bytes => 10 characters.
+# Base64.urlsafe_encode64('1234567', padding: false) # => "MDEyMzQ1Ng"
+#
+# - Input bytes of length <em>3n+2</em> generate unpadded output characters
+# of length <em>4n+3</em>, with one padding character at the end:
+#
+# # n = 1: 5 bytes => 7 characters.
+# Base64.urlsafe_encode64('12345', padding: false) # => "MDEyMzQ"
+# # m = 2: 8 bytes => 11 characters.
+# Base64.urlsafe_encode64('12345678', padding: false) # => "MDEyMzQ1Njc"
+#
+# <b>Padding in Decode Methods</b>
+#
+# All of the \Base64 decode methods support (but do not require) padding.
+#
+# \Method Base64.decode64 does not check the size of the padding:
+#
+# Base64.decode64("MDEyMzQ1Njc") # => "01234567"
+# Base64.decode64("MDEyMzQ1Njc=") # => "01234567"
+# Base64.decode64("MDEyMzQ1Njc==") # => "01234567"
+#
+# \Method Base64.strict_decode64 strictly enforces padding size:
+#
+# Base64.strict_decode64("MDEyMzQ1Njc") # Raises ArgumentError
+# Base64.strict_decode64("MDEyMzQ1Njc=") # => "01234567"
+# Base64.strict_decode64("MDEyMzQ1Njc==") # Raises ArgumentError
+#
+# \Method Base64.urlsafe_decode64 allows padding in +str+,
+# which if present, must be correct:
+# see {Padding}[Base64.html#module-Base64-label-Padding], above:
+#
+# Base64.urlsafe_decode64("MDEyMzQ1Njc") # => "01234567"
+# Base64.urlsafe_decode64("MDEyMzQ1Njc=") # => "01234567"
+# Base64.urlsafe_decode64("MDEyMzQ1Njc==") # Raises ArgumentError.
+#
+# == Newlines
+#
+# An encoded string returned by Base64.encode64 or Base64.urlsafe_encode64
+# has an embedded newline character
+# after each 60-character sequence, and, if non-empty, at the end:
+#
+# # No newline if empty.
+# encoded = Base64.encode64("\x00" * 0)
+# encoded.index("\n") # => nil
+#
+# # Newline at end of short output.
+# encoded = Base64.encode64("\x00" * 1)
+# encoded.size # => 4
+# encoded.index("\n") # => 4
+#
+# # Newline at end of longer output.
+# encoded = Base64.encode64("\x00" * 45)
+# encoded.size # => 60
+# encoded.index("\n") # => 60
+#
+# # Newlines embedded and at end of still longer output.
+# encoded = Base64.encode64("\x00" * 46)
+# encoded.size # => 65
+# encoded.rindex("\n") # => 65
+# encoded.split("\n").map {|s| s.size } # => [60, 4]
+#
+# The string to be encoded may itself contain newlines,
+# which are encoded as \Base64:
+#
+# # Base64.encode64("\n\n\n") # => "CgoK\n"
+# s = "This is line 1\nThis is line 2\n"
+# Base64.encode64(s) # => "VGhpcyBpcyBsaW5lIDEKVGhpcyBpcyBsaW5lIDIK\n"
#
-# The purpose of using base64 to encode data is that it translates any
-# binary data into purely printable characters.
-
module Base64
+
+ VERSION = "0.2.0"
+
module_function
- # Returns the Base64-encoded version of +bin+.
- # This method complies with RFC 2045.
- # Line feeds are added to every 60 encoded characters.
+ # Returns a string containing the RFC-2045-compliant \Base64-encoding of +bin+.
+ #
+ # Per RFC 2045, the returned string may contain the URL-unsafe characters
+ # <tt>+</tt> or <tt>/</tt>;
+ # see {Encoding Character Set}[Base64.html#module-Base64-label-Encoding+Character+Sets] above:
+ #
+ # Base64.encode64("\xFB\xEF\xBE") # => "++++\n"
+ # Base64.encode64("\xFF\xFF\xFF") # => "////\n"
#
- # require 'base64'
- # Base64.encode64("Now is the time for all good coders\nto learn Ruby")
+ # The returned string may include padding;
+ # see {Padding}[Base64.html#module-Base64-label-Padding] above.
#
- # <i>Generates:</i>
+ # Base64.encode64('*') # => "Kg==\n"
+ #
+ # The returned string ends with a newline character, and if sufficiently long
+ # will have one or more embedded newline characters;
+ # see {Newlines}[Base64.html#module-Base64-label-Newlines] above:
+ #
+ # Base64.encode64('*') # => "Kg==\n"
+ # Base64.encode64('*' * 46)
+ # # => "KioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioq\nKg==\n"
+ #
+ # The string to be encoded may itself contain newlines,
+ # which will be encoded as ordinary \Base64:
+ #
+ # Base64.encode64("\n\n\n") # => "CgoK\n"
+ # s = "This is line 1\nThis is line 2\n"
+ # Base64.encode64(s) # => "VGhpcyBpcyBsaW5lIDEKVGhpcyBpcyBsaW5lIDIK\n"
#
- # Tm93IGlzIHRoZSB0aW1lIGZvciBhbGwgZ29vZCBjb2RlcnMKdG8gbGVhcm4g
- # UnVieQ==
def encode64(bin)
[bin].pack("m")
end
- # Returns the Base64-decoded version of +str+.
- # This method complies with RFC 2045.
- # Characters outside the base alphabet are ignored.
- #
- # require 'base64'
- # str = 'VGhpcyBpcyBsaW5lIG9uZQpUaGlzIG' +
- # 'lzIGxpbmUgdHdvClRoaXMgaXMgbGlu' +
- # 'ZSB0aHJlZQpBbmQgc28gb24uLi4K'
- # puts Base64.decode64(str)
- #
- # <i>Generates:</i>
- #
- # This is line one
- # This is line two
- # This is line three
- # And so on...
+ # Returns a string containing the decoding of an RFC-2045-compliant
+ # \Base64-encoded string +str+:
+ #
+ # s = "VGhpcyBpcyBsaW5lIDEKVGhpcyBpcyBsaW5lIDIK\n"
+ # Base64.decode64(s) # => "This is line 1\nThis is line 2\n"
+ #
+ # Non-\Base64 characters in +str+ are ignored;
+ # see {Encoding Character Set}[Base64.html#module-Base64-label-Encoding+Character+Sets] above:
+ # these include newline characters and characters <tt>-</tt> and <tt>/</tt>:
+ #
+ # Base64.decode64("\x00\n-_") # => ""
+ #
+ # Padding in +str+ (even if incorrect) is ignored:
+ #
+ # Base64.decode64("MDEyMzQ1Njc") # => "01234567"
+ # Base64.decode64("MDEyMzQ1Njc=") # => "01234567"
+ # Base64.decode64("MDEyMzQ1Njc==") # => "01234567"
+ #
def decode64(str)
str.unpack1("m")
end
- # Returns the Base64-encoded version of +bin+.
- # This method complies with RFC 4648.
- # No line feeds are added.
+ # Returns a string containing the RFC-2045-compliant \Base64-encoding of +bin+.
+ #
+ # Per RFC 2045, the returned string may contain the URL-unsafe characters
+ # <tt>+</tt> or <tt>/</tt>;
+ # see {Encoding Character Set}[Base64.html#module-Base64-label-Encoding+Character+Sets] above:
+ #
+ # Base64.strict_encode64("\xFB\xEF\xBE") # => "++++\n"
+ # Base64.strict_encode64("\xFF\xFF\xFF") # => "////\n"
+ #
+ # The returned string may include padding;
+ # see {Padding}[Base64.html#module-Base64-label-Padding] above.
+ #
+ # Base64.strict_encode64('*') # => "Kg==\n"
+ #
+ # The returned string will have no newline characters, regardless of its length;
+ # see {Newlines}[Base64.html#module-Base64-label-Newlines] above:
+ #
+ # Base64.strict_encode64('*') # => "Kg=="
+ # Base64.strict_encode64('*' * 46)
+ # # => "KioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKg=="
+ #
+ # The string to be encoded may itself contain newlines,
+ # which will be encoded as ordinary \Base64:
+ #
+ # Base64.strict_encode64("\n\n\n") # => "CgoK"
+ # s = "This is line 1\nThis is line 2\n"
+ # Base64.strict_encode64(s) # => "VGhpcyBpcyBsaW5lIDEKVGhpcyBpcyBsaW5lIDIK"
+ #
def strict_encode64(bin)
[bin].pack("m0")
end
- # Returns the Base64-decoded version of +str+.
- # This method complies with RFC 4648.
- # ArgumentError is raised if +str+ is incorrectly padded or contains
- # non-alphabet characters. Note that CR or LF are also rejected.
+ # Returns a string containing the decoding of an RFC-2045-compliant
+ # \Base64-encoded string +str+:
+ #
+ # s = "VGhpcyBpcyBsaW5lIDEKVGhpcyBpcyBsaW5lIDIK"
+ # Base64.strict_decode64(s) # => "This is line 1\nThis is line 2\n"
+ #
+ # Non-\Base64 characters in +str+ not allowed;
+ # see {Encoding Character Set}[Base64.html#module-Base64-label-Encoding+Character+Sets] above:
+ # these include newline characters and characters <tt>-</tt> and <tt>/</tt>:
+ #
+ # Base64.strict_decode64("\n") # Raises ArgumentError
+ # Base64.strict_decode64('-') # Raises ArgumentError
+ # Base64.strict_decode64('_') # Raises ArgumentError
+ #
+ # Padding in +str+, if present, must be correct:
+ #
+ # Base64.strict_decode64("MDEyMzQ1Njc") # Raises ArgumentError
+ # Base64.strict_decode64("MDEyMzQ1Njc=") # => "01234567"
+ # Base64.strict_decode64("MDEyMzQ1Njc==") # Raises ArgumentError
+ #
def strict_decode64(str)
str.unpack1("m0")
end
- # Returns the Base64-encoded version of +bin+.
- # This method complies with ``Base 64 Encoding with URL and Filename Safe
- # Alphabet'' in RFC 4648.
- # The alphabet uses '-' instead of '+' and '_' instead of '/'.
- # Note that the result can still contain '='.
- # You can remove the padding by setting +padding+ as false.
+ # Returns the RFC-4648-compliant \Base64-encoding of +bin+.
+ #
+ # Per RFC 4648, the returned string will not contain the URL-unsafe characters
+ # <tt>+</tt> or <tt>/</tt>,
+ # but instead may contain the URL-safe characters
+ # <tt>-</tt> and <tt>_</tt>;
+ # see {Encoding Character Set}[Base64.html#module-Base64-label-Encoding+Character+Sets] above:
+ #
+ # Base64.urlsafe_encode64("\xFB\xEF\xBE") # => "----"
+ # Base64.urlsafe_encode64("\xFF\xFF\xFF") # => "____"
+ #
+ # By default, the returned string may have padding;
+ # see {Padding}[Base64.html#module-Base64-label-Padding], above:
+ #
+ # Base64.urlsafe_encode64('*') # => "Kg=="
+ #
+ # Optionally, you can suppress padding:
+ #
+ # Base64.urlsafe_encode64('*', padding: false) # => "Kg"
+ #
+ # The returned string will have no newline characters, regardless of its length;
+ # see {Newlines}[Base64.html#module-Base64-label-Newlines] above:
+ #
+ # Base64.urlsafe_encode64('*') # => "Kg=="
+ # Base64.urlsafe_encode64('*' * 46)
+ # # => "KioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKg=="
+ #
def urlsafe_encode64(bin, padding: true)
str = strict_encode64(bin)
str.chomp!("==") or str.chomp!("=") unless padding
@@ -87,14 +332,22 @@ module Base64
str
end
- # Returns the Base64-decoded version of +str+.
- # This method complies with ``Base 64 Encoding with URL and Filename Safe
- # Alphabet'' in RFC 4648.
- # The alphabet uses '-' instead of '+' and '_' instead of '/'.
- #
- # The padding character is optional.
- # This method accepts both correctly-padded and unpadded input.
- # Note that it still rejects incorrectly-padded input.
+ # Returns the decoding of an RFC-4648-compliant \Base64-encoded string +str+:
+ #
+ # +str+ may not contain non-Base64 characters;
+ # see {Encoding Character Set}[Base64.html#module-Base64-label-Encoding+Character+Sets] above:
+ #
+ # Base64.urlsafe_decode64('+') # Raises ArgumentError.
+ # Base64.urlsafe_decode64('/') # Raises ArgumentError.
+ # Base64.urlsafe_decode64("\n") # Raises ArgumentError.
+ #
+ # Padding in +str+, if present, must be correct:
+ # see {Padding}[Base64.html#module-Base64-label-Padding], above:
+ #
+ # Base64.urlsafe_decode64("MDEyMzQ1Njc") # => "01234567"
+ # Base64.urlsafe_decode64("MDEyMzQ1Njc=") # => "01234567"
+ # Base64.urlsafe_decode64("MDEyMzQ1Njc==") # Raises ArgumentError.
+ #
def urlsafe_decode64(str)
# NOTE: RFC 4648 does say nothing about unpadded input, but says that
# "the excess pad characters MAY also be ignored", so it is inferred that
diff --git a/lib/benchmark.gemspec b/lib/benchmark.gemspec
new file mode 100644
index 0000000000..d6e98db805
--- /dev/null
+++ b/lib/benchmark.gemspec
@@ -0,0 +1,30 @@
+name = File.basename(__FILE__, ".gemspec")
+version = ["lib", Array.new(name.count("-")+1, ".").join("/")].find do |dir|
+ break File.foreach(File.join(__dir__, dir, "#{name.tr('-', '/')}.rb")) do |line|
+ /^\s*VERSION\s*=\s*"(.*)"/ =~ line and break $1
+ end rescue nil
+end
+
+Gem::Specification.new do |spec|
+ spec.name = name
+ spec.version = version
+ spec.authors = ["Yukihiro Matsumoto"]
+ spec.email = ["matz@ruby-lang.org"]
+
+ spec.summary = %q{a performance benchmarking library}
+ spec.description = spec.summary
+ spec.homepage = "https://github.com/ruby/benchmark"
+ spec.licenses = ["Ruby", "BSD-2-Clause"]
+
+ spec.metadata["homepage_uri"] = spec.homepage
+ spec.metadata["source_code_uri"] = spec.homepage
+
+ # Specify which files should be added to the gem when it is released.
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
+ spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
+ `git ls-files -z 2>#{IO::NULL}`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
+ end
+ spec.bindir = "exe"
+ spec.executables = []
+ spec.require_paths = ["lib"]
+end
diff --git a/lib/benchmark.rb b/lib/benchmark.rb
index 79c782e262..9f43255e42 100644
--- a/lib/benchmark.rb
+++ b/lib/benchmark.rb
@@ -121,6 +121,8 @@
module Benchmark
+ VERSION = "0.3.0"
+
BENCHMARK_VERSION = "2002-04-25" # :nodoc:
# Invokes the block with a Benchmark::Report object, which
diff --git a/lib/benchmark/benchmark.gemspec b/lib/benchmark/benchmark.gemspec
deleted file mode 100644
index 58b47d95e1..0000000000
--- a/lib/benchmark/benchmark.gemspec
+++ /dev/null
@@ -1,29 +0,0 @@
-begin
- require_relative "lib/benchmark/version"
-rescue LoadError # Fallback to load version file in ruby core repository
- require_relative "version"
-end
-
-Gem::Specification.new do |spec|
- spec.name = "benchmark"
- spec.version = Benchmark::VERSION
- spec.authors = ["Yukihiro Matsumoto"]
- spec.email = ["matz@ruby-lang.org"]
-
- spec.summary = %q{a performance benchmarking library}
- spec.description = spec.summary
- spec.homepage = "https://github.com/ruby/benchmark"
- spec.licenses = ["Ruby", "BSD-2-Clause"]
-
- spec.metadata["homepage_uri"] = spec.homepage
- spec.metadata["source_code_uri"] = spec.homepage
-
- # Specify which files should be added to the gem when it is released.
- # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
- spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
- `git ls-files -z 2>/dev/null`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
- end
- spec.bindir = "exe"
- spec.executables = []
- spec.require_paths = ["lib"]
-end
diff --git a/lib/benchmark/version.rb b/lib/benchmark/version.rb
deleted file mode 100644
index 645966fd80..0000000000
--- a/lib/benchmark/version.rb
+++ /dev/null
@@ -1,4 +0,0 @@
-# frozen_string_literal: true
-module Benchmark
- VERSION = "0.2.1"
-end
diff --git a/lib/bundled_gems.rb b/lib/bundled_gems.rb
new file mode 100644
index 0000000000..e756af61ea
--- /dev/null
+++ b/lib/bundled_gems.rb
@@ -0,0 +1,192 @@
+# -*- frozen-string-literal: true -*-
+
+# :stopdoc:
+
+module Gem::BUNDLED_GEMS
+ SINCE = {
+ "rexml" => "3.0.0",
+ "rss" => "3.0.0",
+ "webrick" => "3.0.0",
+ "matrix" => "3.1.0",
+ "net-ftp" => "3.1.0",
+ "net-imap" => "3.1.0",
+ "net-pop" => "3.1.0",
+ "net-smtp" => "3.1.0",
+ "prime" => "3.1.0",
+ "racc" => "3.3.0",
+ "abbrev" => "3.4.0",
+ "base64" => "3.4.0",
+ "bigdecimal" => "3.4.0",
+ "csv" => "3.4.0",
+ "drb" => "3.4.0",
+ "getoptlong" => "3.4.0",
+ "mutex_m" => "3.4.0",
+ "nkf" => "3.4.0",
+ "observer" => "3.4.0",
+ "resolv-replace" => "3.4.0",
+ "rinda" => "3.4.0",
+ "syslog" => "3.4.0",
+ }.freeze
+
+ EXACT = {
+ "abbrev" => true,
+ "base64" => true,
+ "bigdecimal" => true,
+ "csv" => true,
+ "drb" => true,
+ "getoptlong" => true,
+ "mutex_m" => true,
+ "nkf" => true, "kconv" => "nkf",
+ "observer" => true,
+ "resolv-replace" => true,
+ "rinda" => true,
+ "syslog" => true,
+ }.freeze
+
+ PREFIXED = {
+ "bigdecimal" => true,
+ "csv" => true,
+ "drb" => true,
+ "rinda" => true,
+ "syslog" => true,
+ }.freeze
+
+ WARNED = {} # unfrozen
+
+ conf = ::RbConfig::CONFIG
+ LIBDIR = (conf["rubylibdir"] + "/").freeze
+ ARCHDIR = (conf["rubyarchdir"] + "/").freeze
+ dlext = [conf["DLEXT"], "so"].uniq
+ DLEXT = /\.#{Regexp.union(dlext)}\z/
+ LIBEXT = /\.#{Regexp.union("rb", *dlext)}\z/
+
+ def self.replace_require(specs)
+ return if [::Kernel.singleton_class, ::Kernel].any? {|klass| klass.respond_to?(:no_warning_require) }
+
+ spec_names = specs.to_a.each_with_object({}) {|spec, h| h[spec.name] = true }
+
+ [::Kernel.singleton_class, ::Kernel].each do |kernel_class|
+ kernel_class.send(:alias_method, :no_warning_require, :require)
+ kernel_class.send(:define_method, :require) do |name|
+ if message = ::Gem::BUNDLED_GEMS.warning?(name, specs: spec_names) # rubocop:disable Style/HashSyntax
+ warn message, :uplevel => 1
+ end
+ kernel_class.send(:no_warning_require, name)
+ end
+ if kernel_class == ::Kernel
+ kernel_class.send(:private, :require)
+ else
+ kernel_class.send(:public, :require)
+ end
+ end
+ end
+
+ def self.find_gem(path)
+ if !path
+ return
+ elsif path.start_with?(ARCHDIR)
+ n = path.delete_prefix(ARCHDIR).sub(DLEXT, "")
+ elsif path.start_with?(LIBDIR)
+ n = path.delete_prefix(LIBDIR).chomp(".rb")
+ else
+ return
+ end
+ EXACT[n] or PREFIXED[n = n[%r[\A[^/]+(?=/)]]] && n
+ end
+
+ def self.warning?(name, specs: nil)
+ # name can be a feature name or a file path with String or Pathname
+ feature = File.path(name)
+ # bootsnap expand `require "csv"` to `require "#{LIBDIR}/csv.rb"`
+ name = feature.delete_prefix(LIBDIR).chomp(".rb").tr("/", "-")
+ name.sub!(LIBEXT, "")
+ return if specs.include?(name)
+ _t, path = $:.resolve_feature_path(feature)
+ if gem = find_gem(path)
+ return if specs.include?(gem)
+ caller = caller_locations(3, 3).find {|c| c&.absolute_path}
+ return if find_gem(caller&.absolute_path)
+ elsif SINCE[name]
+ gem = true
+ else
+ return
+ end
+
+ return if WARNED[name]
+ WARNED[name] = true
+ if gem == true
+ gem = name
+ "#{feature} was loaded from the standard library, but"
+ elsif gem
+ return if WARNED[gem]
+ WARNED[gem] = true
+ "#{feature} is found in #{gem}, which"
+ else
+ return
+ end + build_message(gem)
+ end
+
+ def self.build_message(gem)
+ msg = " #{RUBY_VERSION < SINCE[gem] ? "will no longer be" : "is not"} part of the default gems since Ruby #{SINCE[gem]}."
+
+ if defined?(Bundler)
+ msg += " Add #{gem} to your Gemfile or gemspec."
+
+ # We detect the gem name from caller_locations. We need to skip 2 frames like:
+ # lib/ruby/3.3.0+0/bundled_gems.rb:90:in `warning?'",
+ # lib/ruby/3.3.0+0/bundler/rubygems_integration.rb:247:in `block (2 levels) in replace_require'",
+ #
+ # Additionally, we need to skip Bootsnap and Zeitwerk if present, these
+ # gems decorate Kernel#require, so they are not really the ones issuing
+ # the require call users should be warned about. Those are upwards.
+ frames_to_skip = 2
+ location = nil
+ Thread.each_caller_location do |cl|
+ if frames_to_skip >= 1
+ frames_to_skip -= 1
+ next
+ end
+
+ unless cl.path.match?(/bootsnap|zeitwerk/)
+ location = cl.path
+ break
+ end
+ end
+
+ if location && File.file?(location) && !location.start_with?(Gem::BUNDLED_GEMS::LIBDIR)
+ caller_gem = nil
+ Gem.path.each do |path|
+ if location =~ %r{#{path}/gems/([\w\-\.]+)}
+ caller_gem = $1
+ break
+ end
+ end
+ if caller_gem
+ msg += " Also contact author of #{caller_gem} to add #{gem} into its gemspec."
+ end
+ end
+ else
+ msg += " Install #{gem} from RubyGems."
+ end
+
+ msg
+ end
+
+ freeze
+end
+
+# for RubyGems without Bundler environment.
+# If loading library is not part of the default gems and the bundled gems, warn it.
+class LoadError
+ def message
+ return super unless path
+
+ name = path.tr("/", "-")
+ if !defined?(Bundler) && Gem::BUNDLED_GEMS::SINCE[name] && !Gem::BUNDLED_GEMS::WARNED[name]
+ warn name + Gem::BUNDLED_GEMS.build_message(name)
+ end
+ super
+ end
+end
+
+# :startdoc:
diff --git a/lib/bundler.rb b/lib/bundler.rb
index 132254bb25..59a1107bb7 100644
--- a/lib/bundler.rb
+++ b/lib/bundler.rb
@@ -17,7 +17,7 @@ require_relative "bundler/build_metadata"
# Bundler provides a consistent environment for Ruby projects by
# tracking and installing the exact gems and versions that are needed.
#
-# Since Ruby 2.6, Bundler is a part of Ruby's standard library.
+# Bundler is a part of Ruby's standard library.
#
# Bundler is used by creating _gemfiles_ listing all the project dependencies
# and (optionally) their versions and then using
@@ -39,16 +39,8 @@ module Bundler
environment_preserver.replace_with_backup
SUDO_MUTEX = Thread::Mutex.new
- SAFE_MARSHAL_CLASSES = [Symbol, TrueClass, String, Array, Hash].freeze
- SAFE_MARSHAL_ERROR = "Unexpected class %s present in marshaled data. Only %s are allowed."
- SAFE_MARSHAL_PROC = proc do |object|
- object.tap do
- unless SAFE_MARSHAL_CLASSES.include?(object.class)
- raise TypeError, format(SAFE_MARSHAL_ERROR, object.class, SAFE_MARSHAL_CLASSES.join(", "))
- end
- end
- end
-
+ autoload :Checksum, File.expand_path("bundler/checksum", __dir__)
+ autoload :CIDetector, File.expand_path("bundler/ci_detector", __dir__)
autoload :Definition, File.expand_path("bundler/definition", __dir__)
autoload :Dependency, File.expand_path("bundler/dependency", __dir__)
autoload :Deprecate, File.expand_path("bundler/deprecate", __dir__)
@@ -85,10 +77,12 @@ module Bundler
autoload :StubSpecification, File.expand_path("bundler/stub_specification", __dir__)
autoload :UI, File.expand_path("bundler/ui", __dir__)
autoload :URICredentialsFilter, File.expand_path("bundler/uri_credentials_filter", __dir__)
+ autoload :URINormalizer, File.expand_path("bundler/uri_normalizer", __dir__)
+ autoload :SafeMarshal, File.expand_path("bundler/safe_marshal", __dir__)
class << self
def configure
- @configured ||= configure_gem_home_and_path
+ @configure ||= configure_gem_home_and_path
end
def ui
@@ -106,9 +100,7 @@ module Bundler
end
def create_bundle_path
- SharedHelpers.filesystem_access(bundle_path.to_s) do |p|
- mkdir_p(p)
- end unless bundle_path.exist?
+ mkdir_p(bundle_path) unless bundle_path.exist?
@bundle_path = bundle_path.realpath
rescue Errno::EEXIST
@@ -125,7 +117,7 @@ module Bundler
@bin_path ||= begin
path = settings[:bin] || "bin"
path = Pathname.new(path).expand_path(root).expand_path
- SharedHelpers.filesystem_access(path) {|p| FileUtils.mkdir_p(p) }
+ mkdir_p(path)
path
end
end
@@ -200,7 +192,7 @@ module Bundler
end
def environment
- SharedHelpers.major_deprecation 2, "Bundler.environment has been removed in favor of Bundler.load", :print_caller_location => true
+ SharedHelpers.major_deprecation 2, "Bundler.environment has been removed in favor of Bundler.load", print_caller_location: true
load
end
@@ -208,19 +200,21 @@ module Bundler
#
# @param unlock [Hash, Boolean, nil] Gems that have been requested
# to be updated or true if all gems should be updated
+ # @param lockfile [Pathname] Path to Gemfile.lock
# @return [Bundler::Definition]
- def definition(unlock = nil)
+ def definition(unlock = nil, lockfile = default_lockfile)
@definition = nil if unlock
@definition ||= begin
configure
- Definition.build(default_gemfile, default_lockfile, unlock)
+ Definition.build(default_gemfile, lockfile, unlock)
end
end
def frozen_bundle?
- frozen = settings[:deployment]
- frozen ||= settings[:frozen]
- frozen
+ frozen = settings[:frozen]
+ return frozen unless frozen.nil?
+
+ settings[:deployment]
end
def locked_gems
@@ -337,14 +331,6 @@ module Bundler
def rm_rf(path)
FileUtils.remove_entry_secure(path) if path && File.exist?(path)
- rescue ArgumentError
- message = <<EOF
-It is a security vulnerability to allow your home directory to be world-writable, and bundler cannot continue.
-You should probably consider fixing this issue by running `chmod o-w ~` on *nix.
-Please refer to https://ruby-doc.org/stdlib-3.1.2/libdoc/fileutils/rdoc/FileUtils.html#method-c-remove_entry_secure for details.
-EOF
- File.world_writable?(path) ? Bundler.ui.warn(message) : raise
- raise PathError, "Please fix the world-writable issue with your #{path} directory"
end
def settings
@@ -360,13 +346,13 @@ EOF
# @deprecated Use `unbundled_env` instead
def clean_env
- Bundler::SharedHelpers.major_deprecation(
- 2,
+ message =
"`Bundler.clean_env` has been deprecated in favor of `Bundler.unbundled_env`. " \
- "If you instead want the environment before bundler was originally loaded, use `Bundler.original_env`",
- :print_caller_location => true
- )
-
+ "If you instead want the environment before bundler was originally loaded, use `Bundler.original_env`"
+ removed_message =
+ "`Bundler.clean_env` has been removed in favor of `Bundler.unbundled_env`. " \
+ "If you instead want the environment before bundler was originally loaded, use `Bundler.original_env`"
+ Bundler::SharedHelpers.major_deprecation(2, message, removed_message: removed_message, print_caller_location: true)
unbundled_env
end
@@ -403,13 +389,13 @@ EOF
# @deprecated Use `with_unbundled_env` instead
def with_clean_env
- Bundler::SharedHelpers.major_deprecation(
- 2,
+ message =
"`Bundler.with_clean_env` has been deprecated in favor of `Bundler.with_unbundled_env`. " \
- "If you instead want the environment before bundler was originally loaded, use `Bundler.with_original_env`",
- :print_caller_location => true
- )
-
+ "If you instead want the environment before bundler was originally loaded, use `Bundler.with_original_env`"
+ removed_message =
+ "`Bundler.with_clean_env` has been removed in favor of `Bundler.with_unbundled_env`. " \
+ "If you instead want the environment before bundler was originally loaded, use `Bundler.with_original_env`"
+ Bundler::SharedHelpers.major_deprecation(2, message, removed_message: removed_message, print_caller_location: true)
with_env(unbundled_env) { yield }
end
@@ -425,13 +411,13 @@ EOF
# @deprecated Use `unbundled_system` instead
def clean_system(*args)
- Bundler::SharedHelpers.major_deprecation(
- 2,
+ message =
"`Bundler.clean_system` has been deprecated in favor of `Bundler.unbundled_system`. " \
- "If you instead want to run the command in the environment before bundler was originally loaded, use `Bundler.original_system`",
- :print_caller_location => true
- )
-
+ "If you instead want to run the command in the environment before bundler was originally loaded, use `Bundler.original_system`"
+ removed_message =
+ "`Bundler.clean_system` has been removed in favor of `Bundler.unbundled_system`. " \
+ "If you instead want to run the command in the environment before bundler was originally loaded, use `Bundler.original_system`"
+ Bundler::SharedHelpers.major_deprecation(2, message, removed_message: removed_message, print_caller_location: true)
with_env(unbundled_env) { Kernel.system(*args) }
end
@@ -447,13 +433,13 @@ EOF
# @deprecated Use `unbundled_exec` instead
def clean_exec(*args)
- Bundler::SharedHelpers.major_deprecation(
- 2,
+ message =
"`Bundler.clean_exec` has been deprecated in favor of `Bundler.unbundled_exec`. " \
- "If you instead want to exec to a command in the environment before bundler was originally loaded, use `Bundler.original_exec`",
- :print_caller_location => true
- )
-
+ "If you instead want to exec to a command in the environment before bundler was originally loaded, use `Bundler.original_exec`"
+ removed_message =
+ "`Bundler.clean_exec` has been removed in favor of `Bundler.unbundled_exec`. " \
+ "If you instead want to exec to a command in the environment before bundler was originally loaded, use `Bundler.original_exec`"
+ Bundler::SharedHelpers.major_deprecation(2, message, removed_message: removed_message, print_caller_location: true)
with_env(unbundled_env) { Kernel.exec(*args) }
end
@@ -496,7 +482,7 @@ EOF
configured_bundle_path.use_system_gems?
end
- def mkdir_p(path, options = {})
+ def mkdir_p(path)
SharedHelpers.filesystem_access(path, :write) do |p|
FileUtils.mkdir_p(p)
end
@@ -522,13 +508,16 @@ EOF
end
def safe_load_marshal(data)
- load_marshal(data, :marshal_proc => SAFE_MARSHAL_PROC)
- end
-
- def load_marshal(data, marshal_proc: nil)
- Marshal.load(data, marshal_proc)
- rescue TypeError => e
- raise MarshalError, "#{e.class}: #{e.message}"
+ if Gem.respond_to?(:load_safe_marshal)
+ Gem.load_safe_marshal
+ begin
+ Gem::SafeMarshal.safe_load(data)
+ rescue Gem::SafeMarshal::Reader::Error, Gem::SafeMarshal::Visitors::ToRuby::Error => e
+ raise MarshalError, "#{e.class}: #{e.message}"
+ end
+ else
+ load_marshal(data, marshal_proc: SafeMarshal.proc)
+ end
end
def load_gemspec(file, validate = false)
@@ -586,7 +575,7 @@ EOF
@bin_path = nil
@bundler_major_version = nil
@bundle_path = nil
- @configured = nil
+ @configure = nil
@configured_bundle_path = nil
@definition = nil
@load = nil
@@ -619,6 +608,12 @@ EOF
private
+ def load_marshal(data, marshal_proc: nil)
+ Marshal.load(data, marshal_proc)
+ rescue TypeError => e
+ raise MarshalError, "#{e.class}: #{e.message}"
+ end
+
def eval_yaml_gemspec(path, contents)
Kernel.require "psych"
diff --git a/lib/bundler/build_metadata.rb b/lib/bundler/build_metadata.rb
index 8bffb2fae7..5d2a8b53bb 100644
--- a/lib/bundler/build_metadata.rb
+++ b/lib/bundler/build_metadata.rb
@@ -29,7 +29,7 @@ module Bundler
# commit instance variable then we can't determine its commits SHA.
git_dir = File.expand_path("../../../.git", __dir__)
if File.directory?(git_dir)
- return @git_commit_sha = Dir.chdir(git_dir) { `git rev-parse --short HEAD`.strip.freeze }
+ return @git_commit_sha = IO.popen(%w[git rev-parse --short HEAD], { chdir: git_dir }, &:read).strip.freeze
end
@git_commit_sha ||= "unknown"
diff --git a/lib/bundler/bundler.gemspec b/lib/bundler/bundler.gemspec
index da50b46225..2d6269fae1 100644
--- a/lib/bundler/bundler.gemspec
+++ b/lib/bundler/bundler.gemspec
@@ -29,15 +29,17 @@ Gem::Specification.new do |s|
"source_code_uri" => "https://github.com/rubygems/rubygems/tree/master/bundler",
}
- s.required_ruby_version = ">= 2.6.0"
- s.required_rubygems_version = ">= 3.0.1"
+ s.required_ruby_version = ">= 3.0.0"
+
+ # It should match the RubyGems version shipped with `required_ruby_version` above
+ s.required_rubygems_version = ">= 3.2.3"
s.files = Dir.glob("lib/bundler{.rb,/**/*}", File::FNM_DOTMATCH).reject {|f| File.directory?(f) }
# include the gemspec itself because warbler breaks w/o it
s.files += %w[lib/bundler/bundler.gemspec]
- s.bindir = "libexec"
+ s.bindir = "exe"
s.executables = %w[bundle bundler]
s.require_paths = ["lib"]
end
diff --git a/lib/bundler/capistrano.rb b/lib/bundler/capistrano.rb
index 1f3712d48e..705840143f 100644
--- a/lib/bundler/capistrano.rb
+++ b/lib/bundler/capistrano.rb
@@ -17,6 +17,6 @@ end
Capistrano::Configuration.instance(:must_exist).load do
before "deploy:finalize_update", "bundle:install"
- Bundler::Deployment.define_task(self, :task, :except => { :no_release => true })
+ Bundler::Deployment.define_task(self, :task, except: { no_release: true })
set :rake, lambda { "#{fetch(:bundle_cmd, "bundle")} exec rake" }
end
diff --git a/lib/bundler/checksum.rb b/lib/bundler/checksum.rb
new file mode 100644
index 0000000000..60ba93417c
--- /dev/null
+++ b/lib/bundler/checksum.rb
@@ -0,0 +1,254 @@
+# frozen_string_literal: true
+
+module Bundler
+ class Checksum
+ ALGO_SEPARATOR = "="
+ DEFAULT_ALGORITHM = "sha256"
+ private_constant :DEFAULT_ALGORITHM
+ DEFAULT_BLOCK_SIZE = 16_384
+ private_constant :DEFAULT_BLOCK_SIZE
+
+ class << self
+ def from_gem_package(gem_package, algo = DEFAULT_ALGORITHM)
+ return if Bundler.settings[:disable_checksum_validation]
+ return unless source = gem_package.instance_variable_get(:@gem)
+ return unless source.respond_to?(:with_read_io)
+
+ source.with_read_io do |io|
+ from_gem(io, source.path)
+ ensure
+ io.rewind
+ end
+ end
+
+ def from_gem(io, pathname, algo = DEFAULT_ALGORITHM)
+ digest = Bundler::SharedHelpers.digest(algo.upcase).new
+ buf = String.new(capacity: DEFAULT_BLOCK_SIZE)
+ digest << io.readpartial(DEFAULT_BLOCK_SIZE, buf) until io.eof?
+ Checksum.new(algo, digest.hexdigest!, Source.new(:gem, pathname))
+ end
+
+ def from_api(digest, source_uri, algo = DEFAULT_ALGORITHM)
+ return if Bundler.settings[:disable_checksum_validation]
+
+ Checksum.new(algo, to_hexdigest(digest, algo), Source.new(:api, source_uri))
+ end
+
+ def from_lock(lock_checksum, lockfile_location)
+ algo, digest = lock_checksum.strip.split(ALGO_SEPARATOR, 2)
+ Checksum.new(algo, to_hexdigest(digest, algo), Source.new(:lock, lockfile_location))
+ end
+
+ def to_hexdigest(digest, algo = DEFAULT_ALGORITHM)
+ return digest unless algo == DEFAULT_ALGORITHM
+ return digest if digest.match?(/\A[0-9a-f]{64}\z/i)
+
+ if digest.match?(%r{\A[-0-9a-z_+/]{43}={0,2}\z}i)
+ digest = digest.tr("-_", "+/") # fix urlsafe base64
+ digest.unpack1("m0").unpack1("H*")
+ else
+ raise ArgumentError, "#{digest.inspect} is not a valid SHA256 hex or base64 digest"
+ end
+ end
+ end
+
+ attr_reader :algo, :digest, :sources
+
+ def initialize(algo, digest, source)
+ @algo = algo
+ @digest = digest
+ @sources = [source]
+ end
+
+ def ==(other)
+ match?(other) && other.sources == sources
+ end
+
+ alias_method :eql?, :==
+
+ def same_source?(other)
+ sources.include?(other.sources.first)
+ end
+
+ def match?(other)
+ other.is_a?(self.class) && other.digest == digest && other.algo == algo
+ end
+
+ def hash
+ digest.hash
+ end
+
+ def to_s
+ "#{to_lock} (from #{sources.first}#{", ..." if sources.size > 1})"
+ end
+
+ def to_lock
+ "#{algo}#{ALGO_SEPARATOR}#{digest}"
+ end
+
+ def merge!(other)
+ return nil unless match?(other)
+
+ @sources.concat(other.sources).uniq!
+ self
+ end
+
+ def formatted_sources
+ sources.join("\n and ").concat("\n")
+ end
+
+ def removable?
+ sources.all?(&:removable?)
+ end
+
+ def removal_instructions
+ msg = +""
+ i = 1
+ sources.each do |source|
+ msg << " #{i}. #{source.removal}\n"
+ i += 1
+ end
+ msg << " #{i}. run `bundle install`\n"
+ end
+
+ def inspect
+ abbr = "#{algo}#{ALGO_SEPARATOR}#{digest[0, 8]}"
+ from = "from #{sources.join(" and ")}"
+ "#<#{self.class}:#{object_id} #{abbr} #{from}>"
+ end
+
+ class Source
+ attr_reader :type, :location
+
+ def initialize(type, location)
+ @type = type
+ @location = location
+ end
+
+ def removable?
+ type == :lock || type == :gem
+ end
+
+ def ==(other)
+ other.is_a?(self.class) && other.type == type && other.location == location
+ end
+
+ # phrased so that the usual string format is grammatically correct
+ # rake (10.3.2) sha256=abc123 from #{to_s}
+ def to_s
+ case type
+ when :lock
+ "the lockfile CHECKSUMS at #{location}"
+ when :gem
+ "the gem at #{location}"
+ when :api
+ "the API at #{location}"
+ else
+ "#{location} (#{type})"
+ end
+ end
+
+ # A full sentence describing how to remove the checksum
+ def removal
+ case type
+ when :lock
+ "remove the matching checksum in #{location}"
+ when :gem
+ "remove the gem at #{location}"
+ when :api
+ "checksums from #{location} cannot be locally modified, you may need to update your sources"
+ else
+ "remove #{location} (#{type})"
+ end
+ end
+ end
+
+ class Store
+ attr_reader :store
+ protected :store
+
+ def initialize
+ @store = {}
+ @store_mutex = Mutex.new
+ end
+
+ def inspect
+ "#<#{self.class}:#{object_id} size=#{store.size}>"
+ end
+
+ # Replace when the new checksum is from the same source.
+ # The primary purpose is registering checksums from gems where there are
+ # duplicates of the same gem (according to full_name) in the index.
+ #
+ # In particular, this is when 2 gems have two similar platforms, e.g.
+ # "darwin20" and "darwin-20", both of which resolve to darwin-20.
+ # In the Index, the later gem replaces the former, so we do that here.
+ #
+ # However, if the new checksum is from a different source, we register like normal.
+ # This ensures a mismatch error where there are multiple top level sources
+ # that contain the same gem with different checksums.
+ def replace(spec, checksum)
+ return unless checksum
+
+ lock_name = spec.name_tuple.lock_name
+ @store_mutex.synchronize do
+ existing = fetch_checksum(lock_name, checksum.algo)
+ if !existing || existing.same_source?(checksum)
+ store_checksum(lock_name, checksum)
+ else
+ merge_checksum(lock_name, checksum, existing)
+ end
+ end
+ end
+
+ def register(spec, checksum)
+ return unless checksum
+
+ register_checksum(spec.name_tuple.lock_name, checksum)
+ end
+
+ def merge!(other)
+ other.store.each do |lock_name, checksums|
+ checksums.each do |_algo, checksum|
+ register_checksum(lock_name, checksum)
+ end
+ end
+ end
+
+ def to_lock(spec)
+ lock_name = spec.name_tuple.lock_name
+ checksums = @store[lock_name]
+ if checksums
+ "#{lock_name} #{checksums.values.map(&:to_lock).sort.join(",")}"
+ else
+ lock_name
+ end
+ end
+
+ private
+
+ def register_checksum(lock_name, checksum)
+ @store_mutex.synchronize do
+ existing = fetch_checksum(lock_name, checksum.algo)
+ if existing
+ merge_checksum(lock_name, checksum, existing)
+ else
+ store_checksum(lock_name, checksum)
+ end
+ end
+ end
+
+ def merge_checksum(lock_name, checksum, existing)
+ existing.merge!(checksum) || raise(ChecksumMismatchError.new(lock_name, existing, checksum))
+ end
+
+ def store_checksum(lock_name, checksum)
+ (@store[lock_name] ||= {})[checksum.algo] = checksum
+ end
+
+ def fetch_checksum(lock_name, algo)
+ @store[lock_name]&.fetch(algo, nil)
+ end
+ end
+ end
+end
diff --git a/lib/bundler/ci_detector.rb b/lib/bundler/ci_detector.rb
new file mode 100644
index 0000000000..e5fedbdea8
--- /dev/null
+++ b/lib/bundler/ci_detector.rb
@@ -0,0 +1,75 @@
+# frozen_string_literal: true
+
+module Bundler
+ module CIDetector
+ # NOTE: Any changes made here will need to be made to both lib/rubygems/ci_detector.rb and
+ # bundler/lib/bundler/ci_detector.rb (which are enforced duplicates).
+ # TODO: Drop that duplication once bundler drops support for RubyGems 3.4
+ #
+ # ## Recognized CI providers, their signifiers, and the relevant docs ##
+ #
+ # Travis CI - CI, TRAVIS https://docs.travis-ci.com/user/environment-variables/#default-environment-variables
+ # Cirrus CI - CI, CIRRUS_CI https://cirrus-ci.org/guide/writing-tasks/#environment-variables
+ # Circle CI - CI, CIRCLECI https://circleci.com/docs/variables/#built-in-environment-variables
+ # Gitlab CI - CI, GITLAB_CI https://docs.gitlab.com/ee/ci/variables/
+ # AppVeyor - CI, APPVEYOR https://www.appveyor.com/docs/environment-variables/
+ # CodeShip - CI_NAME https://docs.cloudbees.com/docs/cloudbees-codeship/latest/pro-builds-and-configuration/environment-variables#_default_environment_variables
+ # dsari - CI, DSARI https://github.com/rfinnie/dsari#running
+ # Jenkins - BUILD_NUMBER https://www.jenkins.io/doc/book/pipeline/jenkinsfile/#using-environment-variables
+ # TeamCity - TEAMCITY_VERSION https://www.jetbrains.com/help/teamcity/predefined-build-parameters.html#Predefined+Server+Build+Parameters
+ # Appflow - CI_BUILD_ID https://ionic.io/docs/appflow/automation/environments#predefined-environments
+ # TaskCluster - TASKCLUSTER_ROOT_URL https://docs.taskcluster.net/docs/manual/design/env-vars
+ # Semaphore - CI, SEMAPHORE https://docs.semaphoreci.com/ci-cd-environment/environment-variables/
+ # BuildKite - CI, BUILDKITE https://buildkite.com/docs/pipelines/environment-variables
+ # GoCD - GO_SERVER_URL https://docs.gocd.org/current/faq/dev_use_current_revision_in_build.html
+ # GH Actions - CI, GITHUB_ACTIONS https://docs.github.com/en/actions/learn-github-actions/variables#default-environment-variables
+ #
+ # ### Some "standard" ENVs that multiple providers may set ###
+ #
+ # * CI - this is set by _most_ (but not all) CI providers now; it's approaching a standard.
+ # * CI_NAME - Not as frequently used, but some providers set this to specify their own name
+
+ # Any of these being set is a reasonably reliable indicator that we are
+ # executing in a CI environment.
+ ENV_INDICATORS = [
+ "CI",
+ "CI_NAME",
+ "CONTINUOUS_INTEGRATION",
+ "BUILD_NUMBER",
+ "CI_APP_ID",
+ "CI_BUILD_ID",
+ "CI_BUILD_NUMBER",
+ "RUN_ID",
+ "TASKCLUSTER_ROOT_URL",
+ ].freeze
+
+ # For each CI, this env suffices to indicate that we're on _that_ CI's
+ # containers. (A few of them only supply a CI_NAME variable, which is also
+ # nice). And if they set "CI" but we can't tell which one they are, we also
+ # want to know that - a bare "ci" without another token tells us as much.
+ ENV_DESCRIPTORS = {
+ "TRAVIS" => "travis",
+ "CIRCLECI" => "circle",
+ "CIRRUS_CI" => "cirrus",
+ "DSARI" => "dsari",
+ "SEMAPHORE" => "semaphore",
+ "JENKINS_URL" => "jenkins",
+ "BUILDKITE" => "buildkite",
+ "GO_SERVER_URL" => "go",
+ "GITLAB_CI" => "gitlab",
+ "GITHUB_ACTIONS" => "github",
+ "TASKCLUSTER_ROOT_URL" => "taskcluster",
+ "CI" => "ci",
+ }.freeze
+
+ def self.ci?
+ ENV_INDICATORS.any? {|var| ENV.include?(var) }
+ end
+
+ def self.ci_strings
+ matching_names = ENV_DESCRIPTORS.select {|env, _| ENV[env] }.values
+ matching_names << ENV["CI_NAME"].downcase if ENV["CI_NAME"]
+ matching_names.reject(&:empty?).sort.uniq
+ end
+ end
+end
diff --git a/lib/bundler/cli.rb b/lib/bundler/cli.rb
index ee73bdb506..3640536762 100644
--- a/lib/bundler/cli.rb
+++ b/lib/bundler/cli.rb
@@ -80,10 +80,10 @@ module Bundler
unprinted_warnings.each {|w| Bundler.ui.warn(w) }
end
- check_unknown_options!(:except => [:config, :exec])
+ check_unknown_options!(except: [:config, :exec])
stop_on_unknown_option! :exec
- desc "cli_help", "Prints a summary of bundler commands", :hide => true
+ desc "cli_help", "Prints a summary of bundler commands", hide: true
def cli_help
version
Bundler.ui.info "\n"
@@ -99,19 +99,19 @@ module Bundler
shell.say "Bundler commands:\n\n"
shell.say " Primary commands:\n"
- shell.print_table(primary_commands, :indent => 4, :truncate => true)
+ shell.print_table(primary_commands, indent: 4, truncate: true)
shell.say
shell.say " Utilities:\n"
- shell.print_table(utilities, :indent => 4, :truncate => true)
+ shell.print_table(utilities, indent: 4, truncate: true)
shell.say
self.class.send(:class_options_help, shell)
end
default_task(Bundler.feature_flag.default_cli_command)
- class_option "no-color", :type => :boolean, :desc => "Disable colorization in output"
- class_option "retry", :type => :numeric, :aliases => "-r", :banner => "NUM",
- :desc => "Specify the number of times you wish to attempt network commands"
- class_option "verbose", :type => :boolean, :desc => "Enable verbose output mode", :aliases => "-V"
+ class_option "no-color", type: :boolean, desc: "Disable colorization in output"
+ class_option "retry", type: :numeric, aliases: "-r", banner: "NUM",
+ desc: "Specify the number of times you wish to attempt network commands"
+ class_option "verbose", type: :boolean, desc: "Enable verbose output mode", aliases: "-V"
def help(cli = nil)
case cli
@@ -127,8 +127,8 @@ module Bundler
if man_pages.include?(command)
man_page = man_pages[command]
- if Bundler.which("man") && man_path !~ %r{^file:/.+!/META-INF/jruby.home/.+}
- Kernel.exec "man #{man_page}"
+ if Bundler.which("man") && !man_path.match?(%r{^file:/.+!/META-INF/jruby.home/.+})
+ Kernel.exec("man", man_page)
else
puts File.read("#{man_path}/#{File.basename(man_page)}.ronn")
end
@@ -155,7 +155,8 @@ module Bundler
Gemfile to a gem with a gemspec, the --gemspec option will automatically add each
dependency listed in the gemspec file to the newly created Gemfile.
D
- method_option "gemspec", :type => :string, :banner => "Use the specified .gemspec to create the Gemfile"
+ method_option "gemspec", type: :string, banner: "Use the specified .gemspec to create the Gemfile"
+ method_option "gemfile", type: :string, banner: "Use the specified name for the gemfile instead of 'Gemfile'"
def init
require_relative "cli/init"
Init.new(options.dup).run
@@ -167,12 +168,9 @@ module Bundler
all gems are found, Bundler prints a success message and exits with a status of 0.
If not, the first missing gem is listed and Bundler exits status 1.
D
- method_option "dry-run", :type => :boolean, :default => false, :banner =>
- "Lock the Gemfile"
- method_option "gemfile", :type => :string, :banner =>
- "Use the specified gemfile instead of Gemfile"
- method_option "path", :type => :string, :banner =>
- "Specify a different path than the system default ($BUNDLE_PATH or $GEM_HOME).#{" Bundler will remember this value for future installs on this machine" unless Bundler.feature_flag.forget_cli_options?}"
+ method_option "dry-run", type: :boolean, default: false, banner: "Lock the Gemfile"
+ method_option "gemfile", type: :string, banner: "Use the specified gemfile instead of Gemfile"
+ method_option "path", type: :string, banner: "Specify a different path than the system default ($BUNDLE_PATH or $GEM_HOME).#{" Bundler will remember this value for future installs on this machine" unless Bundler.feature_flag.forget_cli_options?}"
def check
remembered_flag_deprecation("path")
@@ -186,10 +184,14 @@ module Bundler
long_desc <<-D
Removes the given gems from the Gemfile while ensuring that the resulting Gemfile is still valid. If the gem is not found, Bundler prints a error message and if gem could not be removed due to any reason Bundler will display a warning.
D
- method_option "install", :type => :boolean, :banner =>
- "Runs 'bundle install' after removing the gems from the Gemfile"
+ method_option "install", type: :boolean, banner: "Runs 'bundle install' after removing the gems from the Gemfile"
def remove(*gems)
- SharedHelpers.major_deprecation(2, "The `--install` flag has been deprecated. `bundle install` is triggered by default.") if ARGV.include?("--install")
+ if ARGV.include?("--install")
+ message = "The `--install` flag has been deprecated. `bundle install` is triggered by default."
+ removed_message = "The `--install` flag has been removed. `bundle install` is triggered by default."
+ SharedHelpers.major_deprecation(2, message, removed_message: removed_message)
+ end
+
require_relative "cli/remove"
Remove.new(gems, options).run
end
@@ -205,58 +207,40 @@ module Bundler
If the bundle has already been installed, bundler will tell you so and then exit.
D
- method_option "binstubs", :type => :string, :lazy_default => "bin", :banner =>
- "Generate bin stubs for bundled gems to ./bin"
- method_option "clean", :type => :boolean, :banner =>
- "Run bundle clean automatically after install"
- method_option "deployment", :type => :boolean, :banner =>
- "Install using defaults tuned for deployment environments"
- method_option "frozen", :type => :boolean, :banner =>
- "Do not allow the Gemfile.lock to be updated after this install"
- method_option "full-index", :type => :boolean, :banner =>
- "Fall back to using the single-file index of all gems"
- method_option "gemfile", :type => :string, :banner =>
- "Use the specified gemfile instead of Gemfile"
- method_option "jobs", :aliases => "-j", :type => :numeric, :banner =>
- "Specify the number of jobs to run in parallel"
- method_option "local", :type => :boolean, :banner =>
- "Do not attempt to fetch gems remotely and use the gem cache instead"
- method_option "prefer-local", :type => :boolean, :banner =>
- "Only attempt to fetch gems remotely if not present locally, even if newer versions are available remotely"
- method_option "no-cache", :type => :boolean, :banner =>
- "Don't update the existing gem cache."
- method_option "redownload", :type => :boolean, :aliases => "--force", :banner =>
- "Force downloading every gem."
- method_option "no-prune", :type => :boolean, :banner =>
- "Don't remove stale gems from the cache."
- method_option "path", :type => :string, :banner =>
- "Specify a different path than the system default ($BUNDLE_PATH or $GEM_HOME).#{" Bundler will remember this value for future installs on this machine" unless Bundler.feature_flag.forget_cli_options?}"
- method_option "quiet", :type => :boolean, :banner =>
- "Only output warnings and errors."
- method_option "shebang", :type => :string, :banner =>
- "Specify a different shebang executable name than the default (usually 'ruby')"
- method_option "standalone", :type => :array, :lazy_default => [], :banner =>
- "Make a bundle that can work without the Bundler runtime"
- method_option "system", :type => :boolean, :banner =>
- "Install to the system location ($BUNDLE_PATH or $GEM_HOME) even if the bundle was previously installed somewhere else for this application"
- method_option "trust-policy", :alias => "P", :type => :string, :banner =>
- "Gem trust policy (like gem install -P). Must be one of " +
- Bundler.rubygems.security_policy_keys.join("|")
- method_option "without", :type => :array, :banner =>
- "Exclude gems that are part of the specified named group."
- method_option "with", :type => :array, :banner =>
- "Include gems that are part of the specified named group."
+ method_option "binstubs", type: :string, lazy_default: "bin", banner: "Generate bin stubs for bundled gems to ./bin"
+ method_option "clean", type: :boolean, banner: "Run bundle clean automatically after install"
+ method_option "deployment", type: :boolean, banner: "Install using defaults tuned for deployment environments"
+ method_option "frozen", type: :boolean, banner: "Do not allow the Gemfile.lock to be updated after this install"
+ method_option "full-index", type: :boolean, banner: "Fall back to using the single-file index of all gems"
+ method_option "gemfile", type: :string, banner: "Use the specified gemfile instead of Gemfile"
+ method_option "jobs", aliases: "-j", type: :numeric, banner: "Specify the number of jobs to run in parallel"
+ method_option "local", type: :boolean, banner: "Do not attempt to fetch gems remotely and use the gem cache instead"
+ method_option "prefer-local", type: :boolean, banner: "Only attempt to fetch gems remotely if not present locally, even if newer versions are available remotely"
+ method_option "no-cache", type: :boolean, banner: "Don't update the existing gem cache."
+ method_option "redownload", type: :boolean, aliases: "--force", banner: "Force downloading every gem."
+ method_option "no-prune", type: :boolean, banner: "Don't remove stale gems from the cache."
+ method_option "path", type: :string, banner: "Specify a different path than the system default ($BUNDLE_PATH or $GEM_HOME).#{" Bundler will remember this value for future installs on this machine" unless Bundler.feature_flag.forget_cli_options?}"
+ method_option "quiet", type: :boolean, banner: "Only output warnings and errors."
+ method_option "shebang", type: :string, banner: "Specify a different shebang executable name than the default (usually 'ruby')"
+ method_option "standalone", type: :array, lazy_default: [], banner: "Make a bundle that can work without the Bundler runtime"
+ method_option "system", type: :boolean, banner: "Install to the system location ($BUNDLE_PATH or $GEM_HOME) even if the bundle was previously installed somewhere else for this application"
+ method_option "trust-policy", alias: "P", type: :string, banner: "Gem trust policy (like gem install -P). Must be one of " +
+ Bundler.rubygems.security_policy_keys.join("|")
+ method_option "without", type: :array, banner: "Exclude gems that are part of the specified named group."
+ method_option "with", type: :array, banner: "Include gems that are part of the specified named group."
def install
SharedHelpers.major_deprecation(2, "The `--force` option has been renamed to `--redownload`") if ARGV.include?("--force")
- %w[clean deployment frozen no-prune path shebang system without with].each do |option|
+ %w[clean deployment frozen no-prune path shebang without with].each do |option|
remembered_flag_deprecation(option)
end
+ print_remembered_flag_deprecation("--system", "path.system", "true") if ARGV.include?("--system")
+
remembered_negative_flag_deprecation("no-deployment")
require_relative "cli/install"
- Bundler.settings.temporary(:no_install => false) do
+ Bundler.settings.temporary(no_install: false) do
Install.new(options.dup).run
end
end
@@ -269,44 +253,27 @@ module Bundler
update when you have changed the Gemfile, or if you want to get the newest
possible versions of the gems in the bundle.
D
- method_option "full-index", :type => :boolean, :banner =>
- "Fall back to using the single-file index of all gems"
- method_option "gemfile", :type => :string, :banner =>
- "Use the specified gemfile instead of Gemfile"
- method_option "group", :aliases => "-g", :type => :array, :banner =>
- "Update a specific group"
- method_option "jobs", :aliases => "-j", :type => :numeric, :banner =>
- "Specify the number of jobs to run in parallel"
- method_option "local", :type => :boolean, :banner =>
- "Do not attempt to fetch gems remotely and use the gem cache instead"
- method_option "quiet", :type => :boolean, :banner =>
- "Only output warnings and errors."
- method_option "source", :type => :array, :banner =>
- "Update a specific source (and all gems associated with it)"
- method_option "redownload", :type => :boolean, :aliases => "--force", :banner =>
- "Force downloading every gem."
- method_option "ruby", :type => :boolean, :banner =>
- "Update ruby specified in Gemfile.lock"
- method_option "bundler", :type => :string, :lazy_default => "> 0.a", :banner =>
- "Update the locked version of bundler"
- method_option "patch", :type => :boolean, :banner =>
- "Prefer updating only to next patch version"
- method_option "minor", :type => :boolean, :banner =>
- "Prefer updating only to next minor version"
- method_option "major", :type => :boolean, :banner =>
- "Prefer updating to next major version (default)"
- method_option "pre", :type => :boolean, :banner =>
- "Always choose the highest allowed version when updating gems, regardless of prerelease status"
- method_option "strict", :type => :boolean, :banner =>
- "Do not allow any gem to be updated past latest --patch | --minor | --major"
- method_option "conservative", :type => :boolean, :banner =>
- "Use bundle install conservative update behavior and do not allow shared dependencies to be updated."
- method_option "all", :type => :boolean, :banner =>
- "Update everything."
+ method_option "full-index", type: :boolean, banner: "Fall back to using the single-file index of all gems"
+ method_option "gemfile", type: :string, banner: "Use the specified gemfile instead of Gemfile"
+ method_option "group", aliases: "-g", type: :array, banner: "Update a specific group"
+ method_option "jobs", aliases: "-j", type: :numeric, banner: "Specify the number of jobs to run in parallel"
+ method_option "local", type: :boolean, banner: "Do not attempt to fetch gems remotely and use the gem cache instead"
+ method_option "quiet", type: :boolean, banner: "Only output warnings and errors."
+ method_option "source", type: :array, banner: "Update a specific source (and all gems associated with it)"
+ method_option "redownload", type: :boolean, aliases: "--force", banner: "Force downloading every gem."
+ method_option "ruby", type: :boolean, banner: "Update ruby specified in Gemfile.lock"
+ method_option "bundler", type: :string, lazy_default: "> 0.a", banner: "Update the locked version of bundler"
+ method_option "patch", type: :boolean, banner: "Prefer updating only to next patch version"
+ method_option "minor", type: :boolean, banner: "Prefer updating only to next minor version"
+ method_option "major", type: :boolean, banner: "Prefer updating to next major version (default)"
+ method_option "pre", type: :boolean, banner: "Always choose the highest allowed version when updating gems, regardless of prerelease status"
+ method_option "strict", type: :boolean, banner: "Do not allow any gem to be updated past latest --patch | --minor | --major"
+ method_option "conservative", type: :boolean, banner: "Use bundle install conservative update behavior and do not allow shared dependencies to be updated."
+ method_option "all", type: :boolean, banner: "Update everything."
def update(*gems)
SharedHelpers.major_deprecation(2, "The `--force` option has been renamed to `--redownload`") if ARGV.include?("--force")
require_relative "cli/update"
- Bundler.settings.temporary(:no_install => false) do
+ Bundler.settings.temporary(no_install: false) do
Update.new(options, gems).run
end
end
@@ -316,21 +283,25 @@ module Bundler
Show lists the names and versions of all gems that are required by your Gemfile.
Calling show with [GEM] will list the exact location of that gem on your machine.
D
- method_option "paths", :type => :boolean,
- :banner => "List the paths of all gems that are required by your Gemfile."
- method_option "outdated", :type => :boolean,
- :banner => "Show verbose output including whether gems are outdated."
+ method_option "paths", type: :boolean,
+ banner: "List the paths of all gems that are required by your Gemfile."
+ method_option "outdated", type: :boolean,
+ banner: "Show verbose output including whether gems are outdated."
def show(gem_name = nil)
- SharedHelpers.major_deprecation(2, "the `--outdated` flag to `bundle show` was undocumented and will be removed without replacement") if ARGV.include?("--outdated")
+ if ARGV.include?("--outdated")
+ message = "the `--outdated` flag to `bundle show` was undocumented and will be removed without replacement"
+ removed_message = "the `--outdated` flag to `bundle show` was undocumented and has been removed without replacement"
+ SharedHelpers.major_deprecation(2, message, removed_message: removed_message)
+ end
require_relative "cli/show"
Show.new(options, gem_name).run
end
desc "list", "List all gems in the bundle"
- method_option "name-only", :type => :boolean, :banner => "print only the gem names"
- method_option "only-group", :type => :array, :default => [], :banner => "print gems from a given set of groups"
- method_option "without-group", :type => :array, :default => [], :banner => "print all gems except from a given set of groups"
- method_option "paths", :type => :boolean, :banner => "print the path to each gem in the bundle"
+ method_option "name-only", type: :boolean, banner: "print only the gem names"
+ method_option "only-group", type: :array, default: [], banner: "print gems from a given set of groups"
+ method_option "without-group", type: :array, default: [], banner: "print all gems except from a given set of groups"
+ method_option "paths", type: :boolean, banner: "print the path to each gem in the bundle"
def list
require_relative "cli/list"
List.new(options).run
@@ -339,8 +310,8 @@ module Bundler
map aliases_for("list")
desc "info GEM [OPTIONS]", "Show information for the given gem"
- method_option "path", :type => :boolean, :banner => "Print full path to gem"
- method_option "version", :type => :boolean, :banner => "Print gem version"
+ method_option "path", type: :boolean, banner: "Print full path to gem"
+ method_option "version", type: :boolean, banner: "Print gem version"
def info(gem_name)
require_relative "cli/info"
Info.new(options, gem_name).run
@@ -352,18 +323,12 @@ module Bundler
or the --binstubs directory if one has been set. Calling binstubs with [GEM [GEM]]
will create binstubs for all given gems.
D
- method_option "force", :type => :boolean, :default => false, :banner =>
- "Overwrite existing binstubs if they exist"
- method_option "path", :type => :string, :lazy_default => "bin", :banner =>
- "Binstub destination directory (default bin)"
- method_option "shebang", :type => :string, :banner =>
- "Specify a different shebang executable name than the default (usually 'ruby')"
- method_option "standalone", :type => :boolean, :banner =>
- "Make binstubs that can work without the Bundler runtime"
- method_option "all", :type => :boolean, :banner =>
- "Install binstubs for all gems"
- method_option "all-platforms", :type => :boolean, :default => false, :banner =>
- "Install binstubs for all platforms"
+ method_option "force", type: :boolean, default: false, banner: "Overwrite existing binstubs if they exist"
+ method_option "path", type: :string, lazy_default: "bin", banner: "Binstub destination directory (default bin)"
+ method_option "shebang", type: :string, banner: "Specify a different shebang executable name than the default (usually 'ruby')"
+ method_option "standalone", type: :boolean, banner: "Make binstubs that can work without the Bundler runtime"
+ method_option "all", type: :boolean, banner: "Install binstubs for all gems"
+ method_option "all-platforms", type: :boolean, default: false, banner: "Install binstubs for all platforms"
def binstubs(*gems)
require_relative "cli/binstubs"
Binstubs.new(options, gems).run
@@ -373,19 +338,18 @@ module Bundler
long_desc <<-D
Adds the specified gem to Gemfile (if valid) and run 'bundle install' in one step.
D
- method_option "version", :aliases => "-v", :type => :string
- method_option "group", :aliases => "-g", :type => :string
- method_option "source", :aliases => "-s", :type => :string
- method_option "require", :aliases => "-r", :type => :string, :banner => "Adds require path to gem. Provide false, or a path as a string."
- method_option "path", :type => :string
- method_option "git", :type => :string
- method_option "github", :type => :string
- method_option "branch", :type => :string
- method_option "ref", :type => :string
- method_option "skip-install", :type => :boolean, :banner =>
- "Adds gem to the Gemfile but does not install it"
- method_option "optimistic", :type => :boolean, :banner => "Adds optimistic declaration of version to gem"
- method_option "strict", :type => :boolean, :banner => "Adds strict declaration of version to gem"
+ method_option "version", aliases: "-v", type: :string
+ method_option "group", aliases: "-g", type: :string
+ method_option "source", aliases: "-s", type: :string
+ method_option "require", aliases: "-r", type: :string, banner: "Adds require path to gem. Provide false, or a path as a string."
+ method_option "path", type: :string
+ method_option "git", type: :string
+ method_option "github", type: :string
+ method_option "branch", type: :string
+ method_option "ref", type: :string
+ method_option "skip-install", type: :boolean, banner: "Adds gem to the Gemfile but does not install it"
+ method_option "optimistic", type: :boolean, banner: "Adds optimistic declaration of version to gem"
+ method_option "strict", type: :boolean, banner: "Adds strict declaration of version to gem"
def add(*gems)
require_relative "cli/add"
Add.new(options.dup, gems).run
@@ -401,54 +365,45 @@ module Bundler
For more information on patch level options (--major, --minor, --patch,
--strict) see documentation on the same options on the update command.
D
- method_option "group", :type => :string, :banner => "List gems from a specific group"
- method_option "groups", :type => :boolean, :banner => "List gems organized by groups"
- method_option "local", :type => :boolean, :banner =>
- "Do not attempt to fetch gems remotely and use the gem cache instead"
- method_option "pre", :type => :boolean, :banner => "Check for newer pre-release gems"
- method_option "source", :type => :array, :banner => "Check against a specific source"
- method_option "filter-strict", :type => :boolean, :aliases => "--strict", :banner =>
- "Only list newer versions allowed by your Gemfile requirements"
- method_option "update-strict", :type => :boolean, :banner =>
- "Strict conservative resolution, do not allow any gem to be updated past latest --patch | --minor | --major"
- method_option "minor", :type => :boolean, :banner => "Prefer updating only to next minor version"
- method_option "major", :type => :boolean, :banner => "Prefer updating to next major version (default)"
- method_option "patch", :type => :boolean, :banner => "Prefer updating only to next patch version"
- method_option "filter-major", :type => :boolean, :banner => "Only list major newer versions"
- method_option "filter-minor", :type => :boolean, :banner => "Only list minor newer versions"
- method_option "filter-patch", :type => :boolean, :banner => "Only list patch newer versions"
- method_option "parseable", :aliases => "--porcelain", :type => :boolean, :banner =>
- "Use minimal formatting for more parseable output"
- method_option "only-explicit", :type => :boolean, :banner =>
- "Only list gems specified in your Gemfile, not their dependencies"
+ method_option "group", type: :string, banner: "List gems from a specific group"
+ method_option "groups", type: :boolean, banner: "List gems organized by groups"
+ method_option "local", type: :boolean, banner: "Do not attempt to fetch gems remotely and use the gem cache instead"
+ method_option "pre", type: :boolean, banner: "Check for newer pre-release gems"
+ method_option "source", type: :array, banner: "Check against a specific source"
+ method_option "filter-strict", type: :boolean, aliases: "--strict", banner: "Only list newer versions allowed by your Gemfile requirements"
+ method_option "update-strict", type: :boolean, banner: "Strict conservative resolution, do not allow any gem to be updated past latest --patch | --minor | --major"
+ method_option "minor", type: :boolean, banner: "Prefer updating only to next minor version"
+ method_option "major", type: :boolean, banner: "Prefer updating to next major version (default)"
+ method_option "patch", type: :boolean, banner: "Prefer updating only to next patch version"
+ method_option "filter-major", type: :boolean, banner: "Only list major newer versions"
+ method_option "filter-minor", type: :boolean, banner: "Only list minor newer versions"
+ method_option "filter-patch", type: :boolean, banner: "Only list patch newer versions"
+ method_option "parseable", aliases: "--porcelain", type: :boolean, banner: "Use minimal formatting for more parseable output"
+ method_option "only-explicit", type: :boolean, banner: "Only list gems specified in your Gemfile, not their dependencies"
def outdated(*gems)
require_relative "cli/outdated"
Outdated.new(options, gems).run
end
desc "fund [OPTIONS]", "Lists information about gems seeking funding assistance"
- method_option "group", :aliases => "-g", :type => :array, :banner =>
- "Fetch funding information for a specific group"
+ method_option "group", aliases: "-g", type: :array, banner: "Fetch funding information for a specific group"
def fund
require_relative "cli/fund"
Fund.new(options).run
end
desc "cache [OPTIONS]", "Locks and then caches all of the gems into vendor/cache"
- method_option "all", :type => :boolean,
- :default => Bundler.feature_flag.cache_all?,
- :banner => "Include all sources (including path and git)."
- method_option "all-platforms", :type => :boolean, :banner => "Include gems for all platforms present in the lockfile, not only the current one"
- method_option "cache-path", :type => :string, :banner =>
- "Specify a different cache path than the default (vendor/cache)."
- method_option "gemfile", :type => :string, :banner => "Use the specified gemfile instead of Gemfile"
- method_option "no-install", :type => :boolean, :banner => "Don't install the gems, only update the cache."
- method_option "no-prune", :type => :boolean, :banner => "Don't remove stale gems from the cache."
- method_option "path", :type => :string, :banner =>
- "Specify a different path than the system default ($BUNDLE_PATH or $GEM_HOME).#{" Bundler will remember this value for future installs on this machine" unless Bundler.feature_flag.forget_cli_options?}"
- method_option "quiet", :type => :boolean, :banner => "Only output warnings and errors."
- method_option "frozen", :type => :boolean, :banner =>
- "Do not allow the Gemfile.lock to be updated after this bundle cache operation's install"
+ method_option "all", type: :boolean,
+ default: Bundler.feature_flag.cache_all?,
+ banner: "Include all sources (including path and git)."
+ method_option "all-platforms", type: :boolean, banner: "Include gems for all platforms present in the lockfile, not only the current one"
+ method_option "cache-path", type: :string, banner: "Specify a different cache path than the default (vendor/cache)."
+ method_option "gemfile", type: :string, banner: "Use the specified gemfile instead of Gemfile"
+ method_option "no-install", type: :boolean, banner: "Don't install the gems, only update the cache."
+ method_option "no-prune", type: :boolean, banner: "Don't remove stale gems from the cache."
+ method_option "path", type: :string, banner: "Specify a different path than the system default ($BUNDLE_PATH or $GEM_HOME).#{" Bundler will remember this value for future installs on this machine" unless Bundler.feature_flag.forget_cli_options?}"
+ method_option "quiet", type: :boolean, banner: "Only output warnings and errors."
+ method_option "frozen", type: :boolean, banner: "Do not allow the Gemfile.lock to be updated after this bundle cache operation's install"
long_desc <<-D
The cache command will copy the .gem files for every gem in the bundle into the
directory ./vendor/cache. If you then check that directory into your source
@@ -456,17 +411,20 @@ module Bundler
bundle without having to download any additional gems.
D
def cache
- SharedHelpers.major_deprecation 2,
- "The `--all` flag is deprecated because it relies on being " \
- "remembered across bundler invocations, which bundler will no longer " \
- "do in future versions. Instead please use `bundle config set cache_all true`, " \
- "and stop using this flag" if ARGV.include?("--all")
-
- SharedHelpers.major_deprecation 2,
- "The `--path` flag is deprecated because its semantics are unclear. " \
- "Use `bundle config cache_path` to configure the path of your cache of gems, " \
- "and `bundle config path` to configure the path where your gems are installed, " \
- "and stop using this flag" if ARGV.include?("--path")
+ print_remembered_flag_deprecation("--all", "cache_all", "true") if ARGV.include?("--all")
+
+ if ARGV.include?("--path")
+ message =
+ "The `--path` flag is deprecated because its semantics are unclear. " \
+ "Use `bundle config cache_path` to configure the path of your cache of gems, " \
+ "and `bundle config path` to configure the path where your gems are installed, " \
+ "and stop using this flag"
+ removed_message =
+ "The `--path` flag has been removed because its semantics were unclear. " \
+ "Use `bundle config cache_path` to configure the path of your cache of gems, " \
+ "and `bundle config path` to configure the path where your gems are installed."
+ SharedHelpers.major_deprecation 2, message, removed_message: removed_message
+ end
require_relative "cli/cache"
Cache.new(options).run
@@ -475,8 +433,8 @@ module Bundler
map aliases_for("cache")
desc "exec [OPTIONS]", "Run the command in context of the bundle"
- method_option :keep_file_descriptors, :type => :boolean, :default => true
- method_option :gemfile, :type => :string, :required => false
+ method_option :keep_file_descriptors, type: :boolean, default: true
+ method_option :gemfile, type: :string, required: false
long_desc <<-D
Exec runs a command, providing it access to the gems in the bundle. While using
bundle exec you can require and call the bundled gems as if they were installed
@@ -484,7 +442,9 @@ module Bundler
D
def exec(*args)
if ARGV.include?("--no-keep-file-descriptors")
- SharedHelpers.major_deprecation(2, "The `--no-keep-file-descriptors` has been deprecated. `bundle exec` no longer mess with your file descriptors. Close them in the exec'd script if you need to")
+ message = "The `--no-keep-file-descriptors` has been deprecated. `bundle exec` no longer mess with your file descriptors. Close them in the exec'd script if you need to"
+ removed_message = "The `--no-keep-file-descriptors` has been removed. `bundle exec` no longer mess with your file descriptors. Close them in the exec'd script if you need to"
+ SharedHelpers.major_deprecation(2, message, removed_message: removed_message)
end
require_relative "cli/exec"
@@ -509,7 +469,7 @@ module Bundler
subcommand "config", Config
desc "open GEM", "Opens the source directory of the given bundled gem"
- method_option "path", :type => :string, :lazy_default => "", :banner => "Open relative path of the gem source."
+ method_option "path", type: :string, lazy_default: "", banner: "Open relative path of the gem source."
def open(name)
require_relative "cli/open"
Open.new(options, name).run
@@ -554,17 +514,17 @@ module Bundler
end
unless Bundler.feature_flag.bundler_3_mode?
- desc "viz [OPTIONS]", "Generates a visual dependency graph", :hide => true
+ desc "viz [OPTIONS]", "Generates a visual dependency graph", hide: true
long_desc <<-D
Viz generates a PNG file of the current Gemfile as a dependency graph.
Viz requires the ruby-graphviz gem (and its dependencies).
The associated gems must also be installed via 'bundle install'.
D
- method_option :file, :type => :string, :default => "gem_graph", :aliases => "-f", :desc => "The name to use for the generated file. see format option"
- method_option :format, :type => :string, :default => "png", :aliases => "-F", :desc => "This is output format option. Supported format is png, jpg, svg, dot ..."
- method_option :requirements, :type => :boolean, :default => false, :aliases => "-R", :desc => "Set to show the version of each required dependency."
- method_option :version, :type => :boolean, :default => false, :aliases => "-v", :desc => "Set to show each gem version."
- method_option :without, :type => :array, :default => [], :aliases => "-W", :banner => "GROUP[ GROUP...]", :desc => "Exclude gems that are part of the specified named group."
+ method_option :file, type: :string, default: "gem_graph", aliases: "-f", desc: "The name to use for the generated file. see format option"
+ method_option :format, type: :string, default: "png", aliases: "-F", desc: "This is output format option. Supported format is png, jpg, svg, dot ..."
+ method_option :requirements, type: :boolean, default: false, aliases: "-R", desc: "Set to show the version of each required dependency."
+ method_option :version, type: :boolean, default: false, aliases: "-v", desc: "Set to show each gem version."
+ method_option :without, type: :array, default: [], aliases: "-W", banner: "GROUP[ GROUP...]", desc: "Exclude gems that are part of the specified named group."
def viz
SharedHelpers.major_deprecation 2, "The `viz` command has been renamed to `graph` and moved to a plugin. See https://github.com/rubygems/bundler-graph"
require_relative "cli/viz"
@@ -575,23 +535,23 @@ module Bundler
old_gem = instance_method(:gem)
desc "gem NAME [OPTIONS]", "Creates a skeleton for creating a rubygem"
- method_option :exe, :type => :boolean, :default => false, :aliases => ["--bin", "-b"], :desc => "Generate a binary executable for your library."
- method_option :coc, :type => :boolean, :desc => "Generate a code of conduct file. Set a default with `bundle config set --global gem.coc true`."
- method_option :edit, :type => :string, :aliases => "-e", :required => false, :banner => "EDITOR",
- :lazy_default => [ENV["BUNDLER_EDITOR"], ENV["VISUAL"], ENV["EDITOR"]].find {|e| !e.nil? && !e.empty? },
- :desc => "Open generated gemspec in the specified editor (defaults to $EDITOR or $BUNDLER_EDITOR)"
- method_option :ext, :type => :string, :desc => "Generate the boilerplate for C extension code.", :enum => EXTENSIONS
- method_option :git, :type => :boolean, :default => true, :desc => "Initialize a git repo inside your library."
- method_option :mit, :type => :boolean, :desc => "Generate an MIT license file. Set a default with `bundle config set --global gem.mit true`."
- method_option :rubocop, :type => :boolean, :desc => "Add rubocop to the generated Rakefile and gemspec. Set a default with `bundle config set --global gem.rubocop true`."
- method_option :changelog, :type => :boolean, :desc => "Generate changelog file. Set a default with `bundle config set --global gem.changelog true`."
- method_option :test, :type => :string, :lazy_default => Bundler.settings["gem.test"] || "", :aliases => "-t", :banner => "Use the specified test framework for your library",
- :desc => "Generate a test directory for your library, either rspec, minitest or test-unit. Set a default with `bundle config set --global gem.test (rspec|minitest|test-unit)`."
- method_option :ci, :type => :string, :lazy_default => Bundler.settings["gem.ci"] || "",
- :desc => "Generate CI configuration, either GitHub Actions, GitLab CI or CircleCI. Set a default with `bundle config set --global gem.ci (github|gitlab|circle)`"
- method_option :linter, :type => :string, :lazy_default => Bundler.settings["gem.linter"] || "",
- :desc => "Add a linter and code formatter, either RuboCop or Standard. Set a default with `bundle config set --global gem.linter (rubocop|standard)`"
- method_option :github_username, :type => :string, :default => Bundler.settings["gem.github_username"], :banner => "Set your username on GitHub", :desc => "Fill in GitHub username on README so that you don't have to do it manually. Set a default with `bundle config set --global gem.github_username <your_username>`."
+ method_option :exe, type: :boolean, default: false, aliases: ["--bin", "-b"], desc: "Generate a binary executable for your library."
+ method_option :coc, type: :boolean, desc: "Generate a code of conduct file. Set a default with `bundle config set --global gem.coc true`."
+ method_option :edit, type: :string, aliases: "-e", required: false, banner: "EDITOR",
+ lazy_default: [ENV["BUNDLER_EDITOR"], ENV["VISUAL"], ENV["EDITOR"]].find {|e| !e.nil? && !e.empty? },
+ desc: "Open generated gemspec in the specified editor (defaults to $EDITOR or $BUNDLER_EDITOR)"
+ method_option :ext, type: :string, desc: "Generate the boilerplate for C extension code.", enum: EXTENSIONS
+ method_option :git, type: :boolean, default: true, desc: "Initialize a git repo inside your library."
+ method_option :mit, type: :boolean, desc: "Generate an MIT license file. Set a default with `bundle config set --global gem.mit true`."
+ method_option :rubocop, type: :boolean, desc: "Add rubocop to the generated Rakefile and gemspec. Set a default with `bundle config set --global gem.rubocop true`."
+ method_option :changelog, type: :boolean, desc: "Generate changelog file. Set a default with `bundle config set --global gem.changelog true`."
+ method_option :test, type: :string, lazy_default: Bundler.settings["gem.test"] || "", aliases: "-t", banner: "Use the specified test framework for your library",
+ desc: "Generate a test directory for your library, either rspec, minitest or test-unit. Set a default with `bundle config set --global gem.test (rspec|minitest|test-unit)`."
+ method_option :ci, type: :string, lazy_default: Bundler.settings["gem.ci"] || "",
+ desc: "Generate CI configuration, either GitHub Actions, GitLab CI or CircleCI. Set a default with `bundle config set --global gem.ci (github|gitlab|circle)`"
+ method_option :linter, type: :string, lazy_default: Bundler.settings["gem.linter"] || "",
+ desc: "Add a linter and code formatter, either RuboCop or Standard. Set a default with `bundle config set --global gem.linter (rubocop|standard)`"
+ method_option :github_username, type: :string, default: Bundler.settings["gem.github_username"], banner: "Set your username on GitHub", desc: "Fill in GitHub username on README so that you don't have to do it manually. Set a default with `bundle config set --global gem.github_username <your_username>`."
def gem(name)
end
@@ -622,29 +582,24 @@ module Bundler
File.expand_path("templates", __dir__)
end
- desc "clean [OPTIONS]", "Cleans up unused gems in your bundler directory", :hide => true
- method_option "dry-run", :type => :boolean, :default => false, :banner =>
- "Only print out changes, do not clean gems"
- method_option "force", :type => :boolean, :default => false, :banner =>
- "Forces cleaning up unused gems even if Bundler is configured to use globally installed gems. As a consequence, removes all system gems except for the ones in the current application."
+ desc "clean [OPTIONS]", "Cleans up unused gems in your bundler directory", hide: true
+ method_option "dry-run", type: :boolean, default: false, banner: "Only print out changes, do not clean gems"
+ method_option "force", type: :boolean, default: false, banner: "Forces cleaning up unused gems even if Bundler is configured to use globally installed gems. As a consequence, removes all system gems except for the ones in the current application."
def clean
require_relative "cli/clean"
Clean.new(options.dup).run
end
desc "platform [OPTIONS]", "Displays platform compatibility information"
- method_option "ruby", :type => :boolean, :default => false, :banner =>
- "only display ruby related platform information"
+ method_option "ruby", type: :boolean, default: false, banner: "only display ruby related platform information"
def platform
require_relative "cli/platform"
Platform.new(options).run
end
- desc "inject GEM VERSION", "Add the named gem, with version requirements, to the resolved Gemfile", :hide => true
- method_option "source", :type => :string, :banner =>
- "Install gem from the given source"
- method_option "group", :type => :string, :banner =>
- "Install gem into a bundler group"
+ desc "inject GEM VERSION", "Add the named gem, with version requirements, to the resolved Gemfile", hide: true
+ method_option "source", type: :string, banner: "Install gem from the given source"
+ method_option "group", type: :string, banner: "Install gem into a bundler group"
def inject(name, version)
SharedHelpers.major_deprecation 2, "The `inject` command has been replaced by the `add` command"
require_relative "cli/inject"
@@ -652,36 +607,21 @@ module Bundler
end
desc "lock", "Creates a lockfile without installing"
- method_option "update", :type => :array, :lazy_default => true, :banner =>
- "ignore the existing lockfile, update all gems by default, or update list of given gems"
- method_option "local", :type => :boolean, :default => false, :banner =>
- "do not attempt to fetch remote gemspecs and use the local gem cache only"
- method_option "print", :type => :boolean, :default => false, :banner =>
- "print the lockfile to STDOUT instead of writing to the file system"
- method_option "gemfile", :type => :string, :banner =>
- "Use the specified gemfile instead of Gemfile"
- method_option "lockfile", :type => :string, :default => nil, :banner =>
- "the path the lockfile should be written to"
- method_option "full-index", :type => :boolean, :default => false, :banner =>
- "Fall back to using the single-file index of all gems"
- method_option "add-platform", :type => :array, :default => [], :banner =>
- "Add a new platform to the lockfile"
- method_option "remove-platform", :type => :array, :default => [], :banner =>
- "Remove a platform from the lockfile"
- method_option "patch", :type => :boolean, :banner =>
- "If updating, prefer updating only to next patch version"
- method_option "minor", :type => :boolean, :banner =>
- "If updating, prefer updating only to next minor version"
- method_option "major", :type => :boolean, :banner =>
- "If updating, prefer updating to next major version (default)"
- method_option "pre", :type => :boolean, :banner =>
- "If updating, always choose the highest allowed version, regardless of prerelease status"
- method_option "strict", :type => :boolean, :banner =>
- "If updating, do not allow any gem to be updated past latest --patch | --minor | --major"
- method_option "conservative", :type => :boolean, :banner =>
- "If updating, use bundle install conservative update behavior and do not allow shared dependencies to be updated"
- method_option "bundler", :type => :string, :lazy_default => "> 0.a", :banner =>
- "Update the locked version of bundler"
+ method_option "update", type: :array, lazy_default: true, banner: "ignore the existing lockfile, update all gems by default, or update list of given gems"
+ method_option "local", type: :boolean, default: false, banner: "do not attempt to fetch remote gemspecs and use the local gem cache only"
+ method_option "print", type: :boolean, default: false, banner: "print the lockfile to STDOUT instead of writing to the file system"
+ method_option "gemfile", type: :string, banner: "Use the specified gemfile instead of Gemfile"
+ method_option "lockfile", type: :string, default: nil, banner: "the path the lockfile should be written to"
+ method_option "full-index", type: :boolean, default: false, banner: "Fall back to using the single-file index of all gems"
+ method_option "add-platform", type: :array, default: [], banner: "Add a new platform to the lockfile"
+ method_option "remove-platform", type: :array, default: [], banner: "Remove a platform from the lockfile"
+ method_option "patch", type: :boolean, banner: "If updating, prefer updating only to next patch version"
+ method_option "minor", type: :boolean, banner: "If updating, prefer updating only to next minor version"
+ method_option "major", type: :boolean, banner: "If updating, prefer updating to next major version (default)"
+ method_option "pre", type: :boolean, banner: "If updating, always choose the highest allowed version, regardless of prerelease status"
+ method_option "strict", type: :boolean, banner: "If updating, do not allow any gem to be updated past latest --patch | --minor | --major"
+ method_option "conservative", type: :boolean, banner: "If updating, use bundle install conservative update behavior and do not allow shared dependencies to be updated"
+ method_option "bundler", type: :string, lazy_default: "> 0.a", banner: "Update the locked version of bundler"
def lock
require_relative "cli/lock"
Lock.new(options).run
@@ -698,10 +638,8 @@ module Bundler
missing dependencies are detected, Bundler prints them and exits status 1.
Otherwise, Bundler prints a success message and exits with a status of 0.
D
- method_option "gemfile", :type => :string, :banner =>
- "Use the specified gemfile instead of Gemfile"
- method_option "quiet", :type => :boolean, :banner =>
- "Only output warnings and errors."
+ method_option "gemfile", type: :string, banner: "Use the specified gemfile instead of Gemfile"
+ method_option "quiet", type: :boolean, banner: "Only output warnings and errors."
def doctor
require_relative "cli/doctor"
Doctor.new(options).run
@@ -721,7 +659,9 @@ module Bundler
D
def pristine(*gems)
require_relative "cli/pristine"
- Pristine.new(gems).run
+ Bundler.settings.temporary(no_install: false) do
+ Pristine.new(gems).run
+ end
end
if Bundler.feature_flag.plugins?
@@ -763,14 +703,16 @@ module Bundler
# when deprecated version of `--ext` is called
# print out deprecation warning and pretend `--ext=c` was provided
if deprecated_ext_value?(arguments)
- SharedHelpers.major_deprecation 2, "Extensions can now be generated using C or Rust, so `--ext` with no arguments has been deprecated. Please select a language, e.g. `--ext=rust` to generate a Rust extension. This gem will now be generated as if `--ext=c` was used."
+ message = "Extensions can now be generated using C or Rust, so `--ext` with no arguments has been deprecated. Please select a language, e.g. `--ext=rust` to generate a Rust extension. This gem will now be generated as if `--ext=c` was used."
+ removed_message = "Extensions can now be generated using C or Rust, so `--ext` with no arguments has been removed. Please select a language, e.g. `--ext=rust` to generate a Rust extension."
+ SharedHelpers.major_deprecation 2, message, removed_message: removed_message
arguments[arguments.index("--ext")] = "--ext=c"
end
end
def self.deprecated_ext_value?(arguments)
index = arguments.index("--ext")
- next_argument = arguments[index+1]
+ next_argument = arguments[index + 1]
# it is ok when --ext is followed with valid extension value
# for example `bundle gem hello --ext c`
@@ -805,7 +747,7 @@ module Bundler
begin
Bundler.definition.specs
- rescue GemNotFound
+ rescue GemNotFound, GitError
Bundler.ui.info "Automatically installing missing gems."
Bundler.reset!
invoke :install, []
@@ -843,7 +785,7 @@ module Bundler
return unless SharedHelpers.md5_available?
latest = Fetcher::CompactIndex.
- new(nil, Source::Rubygems::Remote.new(Bundler::URI("https://rubygems.org")), nil).
+ new(nil, Source::Rubygems::Remote.new(Gem::URI("https://rubygems.org")), nil, nil).
send(:compact_index_client).
instance_variable_get(:@cache).
dependencies("bundler").
@@ -882,12 +824,23 @@ module Bundler
value = options[name]
value = value.join(" ").to_s if option.type == :array
+ value = "'#{value}'" unless option.type == :boolean
- Bundler::SharedHelpers.major_deprecation 2,
+ print_remembered_flag_deprecation(flag_name, name.tr("-", "_"), value)
+ end
+
+ def print_remembered_flag_deprecation(flag_name, option_name, option_value)
+ message =
"The `#{flag_name}` flag is deprecated because it relies on being " \
"remembered across bundler invocations, which bundler will no longer " \
- "do in future versions. Instead please use `bundle config set --local #{name.tr("-", "_")} " \
- "'#{value}'`, and stop using this flag"
+ "do in future versions. Instead please use `bundle config set #{option_name} " \
+ "#{option_value}`, and stop using this flag"
+ removed_message =
+ "The `#{flag_name}` flag has been removed because it relied on being " \
+ "remembered across bundler invocations, which bundler will no longer " \
+ "do. Instead please use `bundle config set #{option_name} " \
+ "#{option_value}`, and stop using this flag"
+ Bundler::SharedHelpers.major_deprecation 2, message, removed_message: removed_message
end
end
end
diff --git a/lib/bundler/cli/add.rb b/lib/bundler/cli/add.rb
index 08fa6547fb..002d9e1d33 100644
--- a/lib/bundler/cli/add.rb
+++ b/lib/bundler/cli/add.rb
@@ -28,9 +28,9 @@ module Bundler
dependencies = gems.map {|g| Bundler::Dependency.new(g, version, options) }
Injector.inject(dependencies,
- :conservative_versioning => options[:version].nil?, # Perform conservative versioning only when version is not specified
- :optimistic => options[:optimistic],
- :strict => options[:strict])
+ conservative_versioning: options[:version].nil?, # Perform conservative versioning only when version is not specified
+ optimistic: options[:optimistic],
+ strict: options[:strict])
end
def validate_options!
diff --git a/lib/bundler/cli/binstubs.rb b/lib/bundler/cli/binstubs.rb
index fc2fad47a5..8ce138df96 100644
--- a/lib/bundler/cli/binstubs.rb
+++ b/lib/bundler/cli/binstubs.rb
@@ -17,9 +17,9 @@ module Bundler
installer = Installer.new(Bundler.root, Bundler.definition)
installer_opts = {
- :force => options[:force],
- :binstubs_cmd => true,
- :all_platforms => options["all-platforms"],
+ force: options[:force],
+ binstubs_cmd: true,
+ all_platforms: options["all-platforms"],
}
if options[:all]
@@ -45,7 +45,7 @@ module Bundler
next
end
- Bundler.settings.temporary(:path => (Bundler.settings[:path] || Bundler.root)) do
+ Bundler.settings.temporary(path: Bundler.settings[:path] || Bundler.root) do
installer.generate_standalone_bundler_executable_stubs(spec, installer_opts)
end
else
diff --git a/lib/bundler/cli/cache.rb b/lib/bundler/cli/cache.rb
index c8698ed7e3..2e63a16ec3 100644
--- a/lib/bundler/cli/cache.rb
+++ b/lib/bundler/cli/cache.rb
@@ -19,7 +19,7 @@ module Bundler
# TODO: move cache contents here now that all bundles are locked
custom_path = Bundler.settings[:path] if options[:path]
- Bundler.settings.temporary(:cache_all_platforms => options["all-platforms"]) do
+ Bundler.settings.temporary(cache_all_platforms: options["all-platforms"]) do
Bundler.load.cache(custom_path)
end
end
diff --git a/lib/bundler/cli/check.rb b/lib/bundler/cli/check.rb
index cc1f37f0c3..33d31cdd27 100644
--- a/lib/bundler/cli/check.rb
+++ b/lib/bundler/cli/check.rb
@@ -29,10 +29,10 @@ module Bundler
Bundler.ui.warn "Install missing gems with `bundle install`"
exit 1
elsif !Bundler.default_lockfile.file? && Bundler.frozen_bundle?
- Bundler.ui.error "This bundle has been frozen, but there is no #{Bundler.default_lockfile.relative_path_from(SharedHelpers.pwd)} present"
+ Bundler.ui.error "This bundle has been frozen, but there is no #{SharedHelpers.relative_lockfile_path} present"
exit 1
else
- Bundler.load.lock(:preserve_unknown_sections => true) unless options[:"dry-run"]
+ Bundler.load.lock(preserve_unknown_sections: true) unless options[:"dry-run"]
Bundler.ui.info "The Gemfile's dependencies are satisfied"
end
end
diff --git a/lib/bundler/cli/common.rb b/lib/bundler/cli/common.rb
index d654406f65..7ef6deb2cf 100644
--- a/lib/bundler/cli/common.rb
+++ b/lib/bundler/cli/common.rb
@@ -54,9 +54,12 @@ module Bundler
Bundler.definition.specs.each do |spec|
return spec if spec.name == name
- specs << spec if regexp && spec.name =~ regexp
+ specs << spec if regexp && spec.name.match?(regexp)
end
+ default_spec = default_gem_spec(name)
+ specs << default_spec if default_spec
+
case specs.count
when 0
dep_in_other_group = Bundler.definition.current_dependencies.find {|dep|dep.name == name }
@@ -75,6 +78,11 @@ module Bundler
raise GemNotFound, gem_not_found_message(name, Bundler.definition.dependencies)
end
+ def self.default_gem_spec(name)
+ gem_spec = Gem::Specification.find_all_by_name(name).last
+ gem_spec if gem_spec&.default_gem?
+ end
+
def self.ask_for_spec_from(specs)
specs.each_with_index do |spec, index|
Bundler.ui.info "#{index.succ} : #{spec.name}", true
diff --git a/lib/bundler/cli/config.rb b/lib/bundler/cli/config.rb
index e1222c75dd..77b502fe60 100644
--- a/lib/bundler/cli/config.rb
+++ b/lib/bundler/cli/config.rb
@@ -2,17 +2,17 @@
module Bundler
class CLI::Config < Thor
- class_option :parseable, :type => :boolean, :banner => "Use minimal formatting for more parseable output"
+ class_option :parseable, type: :boolean, banner: "Use minimal formatting for more parseable output"
def self.scope_options
- method_option :global, :type => :boolean, :banner => "Only change the global config"
- method_option :local, :type => :boolean, :banner => "Only change the local config"
+ method_option :global, type: :boolean, banner: "Only change the global config"
+ method_option :local, type: :boolean, banner: "Only change the local config"
end
private_class_method :scope_options
- desc "base NAME [VALUE]", "The Bundler 1 config interface", :hide => true
+ desc "base NAME [VALUE]", "The Bundler 1 config interface", hide: true
scope_options
- method_option :delete, :type => :boolean, :banner => "delete"
+ method_option :delete, type: :boolean, banner: "delete"
def base(name = nil, *value)
new_args =
if ARGV.size == 1
@@ -25,8 +25,9 @@ module Bundler
["config", "get", ARGV[1]]
end
- SharedHelpers.major_deprecation 3,
- "Using the `config` command without a subcommand [list, get, set, unset] is deprecated and will be removed in the future. Use `bundle #{new_args.join(" ")}` instead."
+ message = "Using the `config` command without a subcommand [list, get, set, unset] is deprecated and will be removed in the future. Use `bundle #{new_args.join(" ")}` instead."
+ removed_message = "Using the `config` command without a subcommand [list, get, set, unset] is has been removed. Use `bundle #{new_args.join(" ")}` instead."
+ SharedHelpers.major_deprecation 3, message, removed_message: removed_message
Base.new(options, name, value, self).run
end
diff --git a/lib/bundler/cli/console.rb b/lib/bundler/cli/console.rb
index 1eb8ea8254..840cf14fd7 100644
--- a/lib/bundler/cli/console.rb
+++ b/lib/bundler/cli/console.rb
@@ -9,8 +9,9 @@ module Bundler
end
def run
- Bundler::SharedHelpers.major_deprecation 2, "bundle console will be replaced " \
- "by `bin/console` generated by `bundle gem <name>`"
+ message = "bundle console will be replaced by `bin/console` generated by `bundle gem <name>`"
+ removed_message = "bundle console has been replaced by `bin/console` generated by `bundle gem <name>`"
+ Bundler::SharedHelpers.major_deprecation 2, message, removed_message: removed_message
group ? Bundler.require(:default, *group.split(" ").map!(&:to_sym)) : Bundler.require
ARGV.clear
diff --git a/lib/bundler/cli/doctor.rb b/lib/bundler/cli/doctor.rb
index e299a5a8c2..1f6fc93c16 100644
--- a/lib/bundler/cli/doctor.rb
+++ b/lib/bundler/cli/doctor.rb
@@ -6,8 +6,8 @@ require "fiddle"
module Bundler
class CLI::Doctor
- DARWIN_REGEX = /\s+(.+) \(compatibility /.freeze
- LDD_REGEX = /\t\S+ => (\S+) \(\S+\)/.freeze
+ DARWIN_REGEX = /\s+(.+) \(compatibility /
+ LDD_REGEX = /\t\S+ => (\S+) \(\S+\)/
attr_reader :options
diff --git a/lib/bundler/cli/exec.rb b/lib/bundler/cli/exec.rb
index 42b602a055..f81cd5d2c4 100644
--- a/lib/bundler/cli/exec.rb
+++ b/lib/bundler/cli/exec.rb
@@ -12,7 +12,7 @@ module Bundler
@options = options
@cmd = args.shift
@args = args
- @args << { :close_others => !options.keep_file_descriptors? } unless Bundler.current_ruby.jruby?
+ @args << { close_others: !options.keep_file_descriptors? } unless Bundler.current_ruby.jruby?
end
def run
diff --git a/lib/bundler/cli/gem.rb b/lib/bundler/cli/gem.rb
index 7f1200f4a0..f0bb3aab18 100644
--- a/lib/bundler/cli/gem.rb
+++ b/lib/bundler/cli/gem.rb
@@ -11,7 +11,7 @@ module Bundler
class CLI::Gem
TEST_FRAMEWORK_VERSIONS = {
"rspec" => "3.0",
- "minitest" => "5.0",
+ "minitest" => "5.16",
"test-unit" => "3.0",
}.freeze
@@ -59,23 +59,23 @@ module Bundler
end
config = {
- :name => name,
- :underscored_name => underscored_name,
- :namespaced_path => namespaced_path,
- :makefile_path => "#{underscored_name}/#{underscored_name}",
- :constant_name => constant_name,
- :constant_array => constant_array,
- :author => git_author_name.empty? ? "TODO: Write your name" : git_author_name,
- :email => git_user_email.empty? ? "TODO: Write your email address" : git_user_email,
- :test => options[:test],
- :ext => extension,
- :exe => options[:exe],
- :bundler_version => bundler_dependency_version,
- :git => use_git,
- :github_username => github_username.empty? ? "[USERNAME]" : github_username,
- :required_ruby_version => required_ruby_version,
- :rust_builder_required_rubygems_version => rust_builder_required_rubygems_version,
- :minitest_constant_name => minitest_constant_name,
+ name: name,
+ underscored_name: underscored_name,
+ namespaced_path: namespaced_path,
+ makefile_path: "#{underscored_name}/#{underscored_name}",
+ constant_name: constant_name,
+ constant_array: constant_array,
+ author: git_author_name.empty? ? "TODO: Write your name" : git_author_name,
+ email: git_user_email.empty? ? "TODO: Write your email address" : git_user_email,
+ test: options[:test],
+ ext: extension,
+ exe: options[:exe],
+ bundler_version: bundler_dependency_version,
+ git: use_git,
+ github_username: github_username.empty? ? "[USERNAME]" : github_username,
+ required_ruby_version: required_ruby_version,
+ rust_builder_required_rubygems_version: rust_builder_required_rubygems_version,
+ minitest_constant_name: minitest_constant_name,
}
ensure_safe_gem_name(name, constant_array)
@@ -137,10 +137,13 @@ module Bundler
case config[:ci]
when "github"
templates.merge!("github/workflows/main.yml.tt" => ".github/workflows/main.yml")
+ config[:ci_config_path] = ".github "
when "gitlab"
templates.merge!("gitlab-ci.yml.tt" => ".gitlab-ci.yml")
+ config[:ci_config_path] = ".gitlab-ci.yml "
when "circle"
templates.merge!("circleci/config.yml.tt" => ".circleci/config.yml")
+ config[:ci_config_path] = ".circleci "
end
if ask_and_set(:mit, "Do you want to license your code permissively under the MIT license?",
@@ -233,9 +236,7 @@ module Bundler
end
if use_git
- Dir.chdir(target) do
- `git add .`
- end
+ IO.popen(%w[git add .], { chdir: target }, &:read)
end
# Open gemspec in editor
@@ -348,7 +349,7 @@ module Bundler
Bundler.ui.confirm "Do you want to add a code linter and formatter to your gem? " \
"Supported Linters:\n" \
"* RuboCop: https://rubocop.org\n" \
- "* Standard: https://github.com/testdouble/standard\n" \
+ "* Standard: https://github.com/standardrb/standard\n" \
"\n"
Bundler.ui.info hint_text("linter")
@@ -379,15 +380,20 @@ module Bundler
def deprecated_rubocop_option
if !options[:rubocop].nil?
if options[:rubocop]
- Bundler::SharedHelpers.major_deprecation 2, "--rubocop is deprecated, use --linter=rubocop"
+ Bundler::SharedHelpers.major_deprecation 2,
+ "--rubocop is deprecated, use --linter=rubocop",
+ removed_message: "--rubocop has been removed, use --linter=rubocop"
"rubocop"
else
- Bundler::SharedHelpers.major_deprecation 2, "--no-rubocop is deprecated, use --linter"
+ Bundler::SharedHelpers.major_deprecation 2,
+ "--no-rubocop is deprecated, use --linter",
+ removed_message: "--no-rubocop has been removed, use --linter"
false
end
elsif !Bundler.settings["gem.rubocop"].nil?
Bundler::SharedHelpers.major_deprecation 2,
- "config gem.rubocop is deprecated; we've updated your config to use gem.linter instead"
+ "config gem.rubocop is deprecated; we've updated your config to use gem.linter instead",
+ removed_message: "config gem.rubocop has been removed; we've updated your config to use gem.linter instead"
Bundler.settings["gem.rubocop"] ? "rubocop" : false
end
end
@@ -431,7 +437,7 @@ module Bundler
end
def required_ruby_version
- "2.6.0"
+ "3.0.0"
end
def rubocop_version
diff --git a/lib/bundler/cli/info.rb b/lib/bundler/cli/info.rb
index 36c7a58f12..8f34956aca 100644
--- a/lib/bundler/cli/info.rb
+++ b/lib/bundler/cli/info.rb
@@ -25,19 +25,8 @@ module Bundler
private
- def spec_for_gem(gem_name)
- spec = Bundler.definition.specs.find {|s| s.name == gem_name }
- spec || default_gem_spec(gem_name) || Bundler::CLI::Common.select_spec(gem_name, :regex_match)
- end
-
- def default_gem_spec(gem_name)
- return unless Gem::Specification.respond_to?(:find_all_by_name)
- gem_spec = Gem::Specification.find_all_by_name(gem_name).last
- return gem_spec if gem_spec&.default_gem?
- end
-
- def spec_not_found(gem_name)
- raise GemNotFound, Bundler::CLI::Common.gem_not_found_message(gem_name, Bundler.definition.dependencies)
+ def spec_for_gem(name)
+ Bundler::CLI::Common.select_spec(name, :regex_match)
end
def print_gem_version(spec)
diff --git a/lib/bundler/cli/init.rb b/lib/bundler/cli/init.rb
index bc96507c29..246b9d6460 100644
--- a/lib/bundler/cli/init.rb
+++ b/lib/bundler/cli/init.rb
@@ -32,7 +32,7 @@ module Bundler
file << spec.to_gemfile
end
else
- File.open(File.expand_path("../templates/#{gemfile}", __dir__), "r") do |template|
+ File.open(File.expand_path("../templates/Gemfile", __dir__), "r") do |template|
File.open(gemfile, "wb") do |destination|
IO.copy_stream(template, destination)
end
@@ -45,7 +45,7 @@ module Bundler
private
def gemfile
- @gemfile ||= Bundler.preferred_gemfile_name
+ @gemfile ||= options[:gemfile] || Bundler.preferred_gemfile_name
end
end
end
diff --git a/lib/bundler/cli/install.rb b/lib/bundler/cli/install.rb
index c71bcf159f..6c102d537d 100644
--- a/lib/bundler/cli/install.rb
+++ b/lib/bundler/cli/install.rb
@@ -28,8 +28,8 @@ module Bundler
flag = "--deployment flag" if options[:deployment]
flag ||= "--frozen flag" if options[:frozen]
flag ||= "deployment setting"
- raise ProductionError, "The #{flag} requires a #{Bundler.default_lockfile.relative_path_from(SharedHelpers.pwd)}. Please make " \
- "sure you have checked your #{Bundler.default_lockfile.relative_path_from(SharedHelpers.pwd)} into version control " \
+ raise ProductionError, "The #{flag} requires a lockfile. Please make " \
+ "sure you have checked your #{SharedHelpers.relative_lockfile_path} into version control " \
"before deploying."
end
@@ -51,7 +51,8 @@ module Bundler
if options["binstubs"]
Bundler::SharedHelpers.major_deprecation 2,
- "The --binstubs option will be removed in favor of `bundle binstubs --all`"
+ "The --binstubs option will be removed in favor of `bundle binstubs --all`",
+ removed_message: "The --binstubs option have been removed in favor of `bundle binstubs --all`"
end
Plugin.gemfile_install(Bundler.default_gemfile) if Bundler.feature_flag.plugins?
@@ -61,7 +62,7 @@ module Bundler
installer = Installer.install(Bundler.root, definition, options)
- Bundler.settings.temporary(:cache_all_platforms => options[:local] ? false : Bundler.settings[:cache_all_platforms]) do
+ Bundler.settings.temporary(cache_all_platforms: options[:local] ? false : Bundler.settings[:cache_all_platforms]) do
Bundler.load.cache(nil, options[:local]) if Bundler.app_cache.exist? && !options["no-cache"] && !Bundler.frozen_bundle?
end
@@ -95,7 +96,7 @@ module Bundler
def warn_if_root
return if Bundler.settings[:silence_root_warning] || Gem.win_platform? || !Process.uid.zero?
Bundler.ui.warn "Don't run Bundler as root. Installing your bundle as root " \
- "will break this application for all non-root users on this machine.", :wrap => true
+ "will break this application for all non-root users on this machine.", wrap: true
end
def dependencies_count_for(definition)
@@ -148,7 +149,7 @@ module Bundler
Bundler.settings.set_command_option_if_given :path, options[:path]
if options["standalone"] && Bundler.settings[:path].nil? && !options["local"]
- Bundler.settings.temporary(:path_relative_to_cwd => false) do
+ Bundler.settings.temporary(path_relative_to_cwd: false) do
Bundler.settings.set_command_option :path, "bundle"
end
end
diff --git a/lib/bundler/cli/issue.rb b/lib/bundler/cli/issue.rb
index b891ecb1d2..5f2924c4bd 100644
--- a/lib/bundler/cli/issue.rb
+++ b/lib/bundler/cli/issue.rb
@@ -5,7 +5,7 @@ require "rbconfig"
module Bundler
class CLI::Issue
def run
- Bundler.ui.info <<-EOS.gsub(/^ {8}/, "")
+ Bundler.ui.info <<~EOS
Did you find an issue with Bundler? Before filing a new issue,
be sure to check out these resources:
diff --git a/lib/bundler/cli/lock.rb b/lib/bundler/cli/lock.rb
index cb3ed27138..dac3d2a09a 100644
--- a/lib/bundler/cli/lock.rb
+++ b/lib/bundler/cli/lock.rb
@@ -26,42 +26,46 @@ module Bundler
if update.is_a?(Array) # unlocking specific gems
Bundler::CLI::Common.ensure_all_gems_in_lockfile!(update)
- update = { :gems => update, :conservative => conservative }
+ update = { gems: update, conservative: conservative }
elsif update && conservative
- update = { :conservative => conservative }
+ update = { conservative: conservative }
elsif update && bundler
- update = { :bundler => bundler }
+ update = { bundler: bundler }
end
- definition = Bundler.definition(update)
- Bundler::CLI::Common.configure_gem_version_promoter(Bundler.definition, options) if options[:update]
+ file = options[:lockfile]
+ file = file ? Pathname.new(file).expand_path : Bundler.default_lockfile
- options["remove-platform"].each do |platform|
- definition.remove_platform(platform)
- end
+ Bundler.settings.temporary(frozen: false) do
+ definition = Bundler.definition(update, file)
+
+ Bundler::CLI::Common.configure_gem_version_promoter(definition, options) if options[:update]
- options["add-platform"].each do |platform_string|
- platform = Gem::Platform.new(platform_string)
- if platform.to_s == "unknown"
- Bundler.ui.warn "The platform `#{platform_string}` is unknown to RubyGems " \
- "and adding it will likely lead to resolution errors"
+ options["remove-platform"].each do |platform|
+ definition.remove_platform(platform)
end
- definition.add_platform(platform)
- end
- if definition.platforms.empty?
- raise InvalidOption, "Removing all platforms from the bundle is not allowed"
- end
+ options["add-platform"].each do |platform_string|
+ platform = Gem::Platform.new(platform_string)
+ if platform.to_s == "unknown"
+ Bundler.ui.warn "The platform `#{platform_string}` is unknown to RubyGems " \
+ "and adding it will likely lead to resolution errors"
+ end
+ definition.add_platform(platform)
+ end
+
+ if definition.platforms.empty?
+ raise InvalidOption, "Removing all platforms from the bundle is not allowed"
+ end
- definition.resolve_remotely! unless options[:local]
+ definition.resolve_remotely! unless options[:local]
- if print
- puts definition.to_lock
- else
- file = options[:lockfile]
- file = file ? File.expand_path(file) : Bundler.default_lockfile
- puts "Writing lockfile to #{file}"
- definition.lock(file)
+ if print
+ puts definition.to_lock
+ else
+ puts "Writing lockfile to #{file}"
+ definition.lock
+ end
end
Bundler.ui.level = previous_ui_level
diff --git a/lib/bundler/cli/open.rb b/lib/bundler/cli/open.rb
index 8522ec92d6..f24693b843 100644
--- a/lib/bundler/cli/open.rb
+++ b/lib/bundler/cli/open.rb
@@ -18,13 +18,11 @@ module Bundler
Bundler.ui.info "Unable to open #{name} because it's a default gem, so the directory it would normally be installed to does not exist."
else
root_path = spec.full_gem_path
- Dir.chdir(root_path) do
- require "shellwords"
- command = Shellwords.split(editor) << File.join([root_path, path].compact)
- Bundler.with_original_env do
- system(*command)
- end || Bundler.ui.info("Could not run '#{command.join(" ")}'")
- end
+ require "shellwords"
+ command = Shellwords.split(editor) << File.join([root_path, path].compact)
+ Bundler.with_original_env do
+ system(*command, { chdir: root_path })
+ end || Bundler.ui.info("Could not run '#{command.join(" ")}'")
end
end
end
diff --git a/lib/bundler/cli/outdated.rb b/lib/bundler/cli/outdated.rb
index 68c701aefb..ec42e631bb 100644
--- a/lib/bundler/cli/outdated.rb
+++ b/lib/bundler/cli/outdated.rb
@@ -41,12 +41,12 @@ module Bundler
# We're doing a full update
Bundler.definition(true)
else
- Bundler.definition(:gems => gems, :sources => sources)
+ Bundler.definition(gems: gems, sources: sources)
end
Bundler::CLI::Common.configure_gem_version_promoter(
Bundler.definition,
- options.merge(:strict => @strict)
+ options.merge(strict: @strict)
)
definition_resolution = proc do
@@ -90,10 +90,10 @@ module Bundler
end
outdated_gems << {
- :active_spec => active_spec,
- :current_spec => current_spec,
- :dependency => dependency,
- :groups => groups,
+ active_spec: active_spec,
+ current_spec: current_spec,
+ dependency: dependency,
+ groups: groups,
}
end
diff --git a/lib/bundler/cli/plugin.rb b/lib/bundler/cli/plugin.rb
index fe3f4412fa..fd61ef0d95 100644
--- a/lib/bundler/cli/plugin.rb
+++ b/lib/bundler/cli/plugin.rb
@@ -5,20 +5,15 @@ module Bundler
class CLI::Plugin < Thor
desc "install PLUGINS", "Install the plugin from the source"
long_desc <<-D
- Install plugins either from the rubygems source provided (with --source option) or from a git source provided with --git (for remote repos) or --local_git (for local repos). If no sources are provided, it uses Gem.sources
+ Install plugins either from the rubygems source provided (with --source option), from a git source provided with --git, or a local path provided with --path. If no sources are provided, it uses Gem.sources
D
- method_option "source", :type => :string, :default => nil, :banner =>
- "URL of the RubyGems source to fetch the plugin from"
- method_option "version", :type => :string, :default => nil, :banner =>
- "The version of the plugin to fetch"
- method_option "git", :type => :string, :default => nil, :banner =>
- "URL of the git repo to fetch from"
- method_option "local_git", :type => :string, :default => nil, :banner =>
- "Path of the local git repo to fetch from"
- method_option "branch", :type => :string, :default => nil, :banner =>
- "The git branch to checkout"
- method_option "ref", :type => :string, :default => nil, :banner =>
- "The git revision to check out"
+ method_option "source", type: :string, default: nil, banner: "URL of the RubyGems source to fetch the plugin from"
+ method_option "version", type: :string, default: nil, banner: "The version of the plugin to fetch"
+ method_option "git", type: :string, default: nil, banner: "URL of the git repo to fetch from"
+ method_option "local_git", type: :string, default: nil, banner: "Path of the local git repo to fetch from (deprecated)"
+ method_option "branch", type: :string, default: nil, banner: "The git branch to checkout"
+ method_option "ref", type: :string, default: nil, banner: "The git revision to check out"
+ method_option "path", type: :string, default: nil, banner: "Path of a local gem to directly use"
def install(*plugins)
Bundler::Plugin.install(plugins, options)
end
@@ -27,8 +22,7 @@ module Bundler
long_desc <<-D
Uninstall given list of plugins. To uninstall all the plugins, use -all option.
D
- method_option "all", :type => :boolean, :default => nil, :banner =>
- "Uninstall all the installed plugins. If no plugin is installed, then it does nothing."
+ method_option "all", type: :boolean, default: nil, banner: "Uninstall all the installed plugins. If no plugin is installed, then it does nothing."
def uninstall(*plugins)
Bundler::Plugin.uninstall(plugins, options)
end
diff --git a/lib/bundler/cli/pristine.rb b/lib/bundler/cli/pristine.rb
index d6654f8053..e0d7452c44 100644
--- a/lib/bundler/cli/pristine.rb
+++ b/lib/bundler/cli/pristine.rb
@@ -12,40 +12,48 @@ module Bundler
definition.validate_runtime!
installer = Bundler::Installer.new(Bundler.root, definition)
- Bundler.load.specs.each do |spec|
- next if spec.name == "bundler" # Source::Rubygems doesn't install bundler
- next if !@gems.empty? && !@gems.include?(spec.name)
-
- gem_name = "#{spec.name} (#{spec.version}#{spec.git_version})"
- gem_name += " (#{spec.platform})" if !spec.platform.nil? && spec.platform != Gem::Platform::RUBY
-
- case source = spec.source
- when Source::Rubygems
- cached_gem = spec.cache_file
- unless File.exist?(cached_gem)
- Bundler.ui.error("Failed to pristine #{gem_name}. Cached gem #{cached_gem} does not exist.")
+ ProcessLock.lock do
+ installed_specs = definition.specs.reject do |spec|
+ next if spec.name == "bundler" # Source::Rubygems doesn't install bundler
+ next if !@gems.empty? && !@gems.include?(spec.name)
+
+ gem_name = "#{spec.name} (#{spec.version}#{spec.git_version})"
+ gem_name += " (#{spec.platform})" if !spec.platform.nil? && spec.platform != Gem::Platform::RUBY
+
+ case source = spec.source
+ when Source::Rubygems
+ cached_gem = spec.cache_file
+ unless File.exist?(cached_gem)
+ Bundler.ui.error("Failed to pristine #{gem_name}. Cached gem #{cached_gem} does not exist.")
+ next
+ end
+
+ FileUtils.rm_rf spec.full_gem_path
+ when Source::Git
+ if source.local?
+ Bundler.ui.warn("Cannot pristine #{gem_name}. Gem is locally overridden.")
+ next
+ end
+
+ source.remote!
+ if extension_cache_path = source.extension_cache_path(spec)
+ FileUtils.rm_rf extension_cache_path
+ end
+ FileUtils.rm_rf spec.extension_dir
+ FileUtils.rm_rf spec.full_gem_path
+ else
+ Bundler.ui.warn("Cannot pristine #{gem_name}. Gem is sourced from local path.")
next
end
- FileUtils.rm_rf spec.full_gem_path
- when Source::Git
- if source.local?
- Bundler.ui.warn("Cannot pristine #{gem_name}. Gem is locally overridden.")
- next
- end
+ true
+ end.map(&:name)
- source.remote!
- if extension_cache_path = source.extension_cache_path(spec)
- FileUtils.rm_rf extension_cache_path
- end
- FileUtils.rm_rf spec.extension_dir
- FileUtils.rm_rf spec.full_gem_path
- else
- Bundler.ui.warn("Cannot pristine #{gem_name}. Gem is sourced from local path.")
- next
- end
-
- Bundler::GemInstaller.new(spec, installer, false, 0, true).install_from_spec
+ jobs = installer.send(:installation_parallelization, {})
+ pristine_count = definition.specs.count - installed_specs.count
+ # allow a pristining a single gem to skip the parallel worker
+ jobs = [jobs, pristine_count].min
+ ParallelInstaller.call(installer, definition.specs, jobs, false, true, skip: installed_specs)
end
end
end
diff --git a/lib/bundler/cli/show.rb b/lib/bundler/cli/show.rb
index 2df13db1fa..59b0af42e1 100644
--- a/lib/bundler/cli/show.rb
+++ b/lib/bundler/cli/show.rb
@@ -40,8 +40,8 @@ module Bundler
desc = " * #{s.name} (#{s.version}#{s.git_version})"
if @verbose
latest = latest_specs.find {|l| l.name == s.name }
- Bundler.ui.info <<-END.gsub(/^ +/, "")
- #{desc}
+ Bundler.ui.info <<~END
+ #{desc.lstrip}
\tSummary: #{s.summary || "No description available."}
\tHomepage: #{s.homepage || "No website available."}
\tStatus: #{outdated?(s, latest) ? "Outdated - #{s.version} < #{latest.version}" : "Up to date"}
diff --git a/lib/bundler/cli/update.rb b/lib/bundler/cli/update.rb
index b49182655b..985e8db051 100644
--- a/lib/bundler/cli/update.rb
+++ b/lib/bundler/cli/update.rb
@@ -35,7 +35,7 @@ module Bundler
if full_update
if conservative
- Bundler.definition(:conservative => conservative)
+ Bundler.definition(conservative: conservative)
else
Bundler.definition(true)
end
@@ -51,9 +51,9 @@ module Bundler
gems.concat(deps.map(&:name))
end
- Bundler.definition(:gems => gems, :sources => sources, :ruby => options[:ruby],
- :conservative => conservative,
- :bundler => update_bundler)
+ Bundler.definition(gems: gems, sources: sources, ruby: options[:ruby],
+ conservative: conservative,
+ bundler: update_bundler)
end
Bundler::CLI::Common.configure_gem_version_promoter(Bundler.definition, options)
@@ -63,6 +63,7 @@ module Bundler
opts = options.dup
opts["update"] = true
opts["local"] = options[:local]
+ opts["force"] = options[:redownload]
Bundler.settings.set_command_option_if_given :jobs, opts["jobs"]
@@ -70,7 +71,7 @@ module Bundler
if locked_gems = Bundler.definition.locked_gems
previous_locked_info = locked_gems.specs.reduce({}) do |h, s|
- h[s.name] = { :spec => s, :version => s.version, :source => s.source.identifier }
+ h[s.name] = { spec: s, version: s.version, source: s.source.identifier }
h
end
end
diff --git a/lib/bundler/compact_index_client.rb b/lib/bundler/compact_index_client.rb
index 127a50e810..68e0d7e0d5 100644
--- a/lib/bundler/compact_index_client.rb
+++ b/lib/bundler/compact_index_client.rb
@@ -5,7 +5,13 @@ require "set"
module Bundler
class CompactIndexClient
+ # NOTE: MD5 is here not because we expect a server to respond with it, but
+ # because we use it to generate the etag on first request during the upgrade
+ # to the compact index client that uses opaque etags saved to files.
+ # Remove once 2.5.0 has been out for a while.
+ SUPPORTED_DIGESTS = { "sha-256" => :SHA256, "md5" => :MD5 }.freeze
DEBUG_MUTEX = Thread::Mutex.new
+
def self.debug
return unless ENV["DEBUG_COMPACT_INDEX"]
DEBUG_MUTEX.synchronize { warn("[#{self}] #{yield}") }
@@ -14,6 +20,7 @@ module Bundler
class Error < StandardError; end
require_relative "compact_index_client/cache"
+ require_relative "compact_index_client/cache_file"
require_relative "compact_index_client/updater"
attr_reader :directory
@@ -54,13 +61,13 @@ module Bundler
def names
Bundler::CompactIndexClient.debug { "/names" }
- update(@cache.names_path, "names")
+ update("names", @cache.names_path, @cache.names_etag_path)
@cache.names
end
def versions
Bundler::CompactIndexClient.debug { "/versions" }
- update(@cache.versions_path, "versions")
+ update("versions", @cache.versions_path, @cache.versions_etag_path)
versions, @info_checksums_by_name = @cache.versions
versions
end
@@ -76,36 +83,36 @@ module Bundler
def update_and_parse_checksums!
Bundler::CompactIndexClient.debug { "update_and_parse_checksums!" }
return @info_checksums_by_name if @parsed_checksums
- update(@cache.versions_path, "versions")
+ update("versions", @cache.versions_path, @cache.versions_etag_path)
@info_checksums_by_name = @cache.checksums
@parsed_checksums = true
end
private
- def update(local_path, remote_path)
+ def update(remote_path, local_path, local_etag_path)
Bundler::CompactIndexClient.debug { "update(#{local_path}, #{remote_path})" }
unless synchronize { @endpoints.add?(remote_path) }
Bundler::CompactIndexClient.debug { "already fetched #{remote_path}" }
return
end
- @updater.update(local_path, url(remote_path))
+ @updater.update(url(remote_path), local_path, local_etag_path)
end
def update_info(name)
Bundler::CompactIndexClient.debug { "update_info(#{name})" }
path = @cache.info_path(name)
- checksum = @updater.checksum_for_file(path)
unless existing = @info_checksums_by_name[name]
Bundler::CompactIndexClient.debug { "skipping updating info for #{name} since it is missing from versions" }
return
end
+ checksum = SharedHelpers.checksum_for_file(path, :MD5)
if checksum == existing
Bundler::CompactIndexClient.debug { "skipping updating info for #{name} since the versions checksum matches the local checksum" }
return
end
Bundler::CompactIndexClient.debug { "updating info for #{name} since the versions checksum #{existing} != the local checksum #{checksum}" }
- update(path, "info/#{name}")
+ update("info/#{name}", path, @cache.info_etag_path(name))
end
def url(path)
diff --git a/lib/bundler/compact_index_client/cache.rb b/lib/bundler/compact_index_client/cache.rb
index 0b43581c11..55911fdecf 100644
--- a/lib/bundler/compact_index_client/cache.rb
+++ b/lib/bundler/compact_index_client/cache.rb
@@ -9,11 +9,8 @@ module Bundler
def initialize(directory)
@directory = Pathname.new(directory).expand_path
- info_roots.each do |dir|
- SharedHelpers.filesystem_access(dir) do
- FileUtils.mkdir_p(dir)
- end
- end
+ info_roots.each {|dir| mkdir(dir) }
+ mkdir(info_etag_root)
end
def names
@@ -24,6 +21,10 @@ module Bundler
directory.join("names")
end
+ def names_etag_path
+ directory.join("names.etag")
+ end
+
def versions
versions_by_name = Hash.new {|hash, key| hash[key] = [] }
info_checksums_by_name = {}
@@ -31,12 +32,12 @@ module Bundler
lines(versions_path).each do |line|
name, versions_string, info_checksum = line.split(" ", 3)
info_checksums_by_name[name] = info_checksum || ""
- versions_string.split(",").each do |version|
- if version.start_with?("-")
- version = version[1..-1].split("-", 2).unshift(name)
+ versions_string.split(",") do |version|
+ delete = version.delete_prefix!("-")
+ version = version.split("-", 2).unshift(name)
+ if delete
versions_by_name[name].delete(version)
else
- version = version.split("-", 2).unshift(name)
versions_by_name[name] << version
end
end
@@ -49,6 +50,10 @@ module Bundler
directory.join("versions")
end
+ def versions_etag_path
+ directory.join("versions.etag")
+ end
+
def checksums
checksums = {}
@@ -76,8 +81,19 @@ module Bundler
end
end
+ def info_etag_path(name)
+ name = name.to_s
+ info_etag_root.join("#{name}-#{SharedHelpers.digest(:MD5).hexdigest(name).downcase}")
+ end
+
private
+ def mkdir(dir)
+ SharedHelpers.filesystem_access(dir) do
+ FileUtils.mkdir_p(dir)
+ end
+ end
+
def lines(path)
return [] unless path.file?
lines = SharedHelpers.filesystem_access(path, :read, &:read).split("\n")
@@ -96,6 +112,10 @@ module Bundler
directory.join("info-special-characters"),
]
end
+
+ def info_etag_root
+ directory.join("info-etags")
+ end
end
end
end
diff --git a/lib/bundler/compact_index_client/cache_file.rb b/lib/bundler/compact_index_client/cache_file.rb
new file mode 100644
index 0000000000..5988bc91b3
--- /dev/null
+++ b/lib/bundler/compact_index_client/cache_file.rb
@@ -0,0 +1,153 @@
+# frozen_string_literal: true
+
+require_relative "../vendored_fileutils"
+require "rubygems/package"
+
+module Bundler
+ class CompactIndexClient
+ # write cache files in a way that is robust to concurrent modifications
+ # if digests are given, the checksums will be verified
+ class CacheFile
+ DEFAULT_FILE_MODE = 0o644
+ private_constant :DEFAULT_FILE_MODE
+
+ class Error < RuntimeError; end
+ class ClosedError < Error; end
+
+ class DigestMismatchError < Error
+ def initialize(digests, expected_digests)
+ super "Calculated checksums #{digests.inspect} did not match expected #{expected_digests.inspect}."
+ end
+ end
+
+ # Initialize with a copy of the original file, then yield the instance.
+ def self.copy(path, &block)
+ new(path) do |file|
+ file.initialize_digests
+
+ SharedHelpers.filesystem_access(path, :read) do
+ path.open("rb") do |s|
+ file.open {|f| IO.copy_stream(s, f) }
+ end
+ end
+
+ yield file
+ end
+ end
+
+ # Write data to a temp file, then replace the original file with it verifying the digests if given.
+ def self.write(path, data, digests = nil)
+ return unless data
+ new(path) do |file|
+ file.digests = digests
+ file.write(data)
+ end
+ end
+
+ attr_reader :original_path, :path
+
+ def initialize(original_path, &block)
+ @original_path = original_path
+ @perm = original_path.file? ? original_path.stat.mode : DEFAULT_FILE_MODE
+ @path = original_path.sub(/$/, ".#{$$}.tmp")
+ return unless block_given?
+ begin
+ yield self
+ ensure
+ close
+ end
+ end
+
+ def size
+ path.size
+ end
+
+ # initialize the digests using CompactIndexClient::SUPPORTED_DIGESTS, or a subset based on keys.
+ def initialize_digests(keys = nil)
+ @digests = keys ? SUPPORTED_DIGESTS.slice(*keys) : SUPPORTED_DIGESTS.dup
+ @digests.transform_values! {|algo_class| SharedHelpers.digest(algo_class).new }
+ end
+
+ # reset the digests so they don't contain any previously read data
+ def reset_digests
+ @digests&.each_value(&:reset)
+ end
+
+ # set the digests that will be verified at the end
+ def digests=(expected_digests)
+ @expected_digests = expected_digests
+
+ if @expected_digests.nil?
+ @digests = nil
+ elsif @digests
+ @digests = @digests.slice(*@expected_digests.keys)
+ else
+ initialize_digests(@expected_digests.keys)
+ end
+ end
+
+ # remove this method when we stop generating md5 digests for legacy etags
+ def md5
+ @digests && @digests["md5"]
+ end
+
+ def digests?
+ @digests&.any?
+ end
+
+ # Open the temp file for writing, reusing original permissions, yielding the IO object.
+ def open(write_mode = "wb", perm = @perm, &block)
+ raise ClosedError, "Cannot reopen closed file" if @closed
+ SharedHelpers.filesystem_access(path, :write) do
+ path.open(write_mode, perm) do |f|
+ yield digests? ? Gem::Package::DigestIO.new(f, @digests) : f
+ end
+ end
+ end
+
+ # Returns false without appending when no digests since appending is too error prone to do without digests.
+ def append(data)
+ return false unless digests?
+ open("a") {|f| f.write data }
+ verify && commit
+ end
+
+ def write(data)
+ reset_digests
+ open {|f| f.write data }
+ commit!
+ end
+
+ def commit!
+ verify || raise(DigestMismatchError.new(@base64digests, @expected_digests))
+ commit
+ end
+
+ # Verify the digests, returning true on match, false on mismatch.
+ def verify
+ return true unless @expected_digests && digests?
+ @base64digests = @digests.transform_values!(&:base64digest)
+ @digests = nil
+ @base64digests.all? {|algo, digest| @expected_digests[algo] == digest }
+ end
+
+ # Replace the original file with the temp file without verifying digests.
+ # The file is permanently closed.
+ def commit
+ raise ClosedError, "Cannot commit closed file" if @closed
+ SharedHelpers.filesystem_access(original_path, :write) do
+ FileUtils.mv(path, original_path)
+ end
+ @closed = true
+ end
+
+ # Remove the temp file without replacing the original file.
+ # The file is permanently closed.
+ def close
+ return if @closed
+ FileUtils.remove_file(path) if @path&.file?
+ @closed = true
+ end
+ end
+ end
+end
diff --git a/lib/bundler/compact_index_client/gem_parser.rb b/lib/bundler/compact_index_client/gem_parser.rb
index e7bf4c6001..60a1817607 100644
--- a/lib/bundler/compact_index_client/gem_parser.rb
+++ b/lib/bundler/compact_index_client/gem_parser.rb
@@ -6,12 +6,15 @@ module Bundler
GemParser = Gem::Resolver::APISet::GemParser
else
class GemParser
+ EMPTY_ARRAY = [].freeze
+ private_constant :EMPTY_ARRAY
+
def parse(line)
version_and_platform, rest = line.split(" ", 2)
version, platform = version_and_platform.split("-", 2)
- dependencies, requirements = rest.split("|", 2).map {|s| s.split(",") } if rest
- dependencies = dependencies ? dependencies.map {|d| parse_dependency(d) } : []
- requirements = requirements ? requirements.map {|d| parse_dependency(d) } : []
+ dependencies, requirements = rest.split("|", 2).map! {|s| s.split(",") } if rest
+ dependencies = dependencies ? dependencies.map! {|d| parse_dependency(d) } : EMPTY_ARRAY
+ requirements = requirements ? requirements.map! {|d| parse_dependency(d) } : EMPTY_ARRAY
[version, platform, dependencies, requirements]
end
@@ -20,6 +23,7 @@ module Bundler
def parse_dependency(string)
dependency = string.split(":")
dependency[-1] = dependency[-1].split("&") if dependency.size > 1
+ dependency[0] = -dependency[0]
dependency
end
end
diff --git a/lib/bundler/compact_index_client/updater.rb b/lib/bundler/compact_index_client/updater.rb
index 0f7bf9bb50..36f6b81db8 100644
--- a/lib/bundler/compact_index_client/updater.rb
+++ b/lib/bundler/compact_index_client/updater.rb
@@ -1,20 +1,11 @@
# frozen_string_literal: true
-require_relative "../vendored_fileutils"
-
module Bundler
class CompactIndexClient
class Updater
- class MisMatchedChecksumError < Error
- def initialize(path, server_checksum, local_checksum)
- @path = path
- @server_checksum = server_checksum
- @local_checksum = local_checksum
- end
-
- def message
- "The checksum of /#{@path} does not match the checksum provided by the server! Something is wrong " \
- "(local checksum is #{@local_checksum.inspect}, was expecting #{@server_checksum.inspect})."
+ class MismatchedChecksumError < Error
+ def initialize(path, message)
+ super "The checksum of /#{path} does not match the checksum provided by the server! Something is wrong. #{message}"
end
end
@@ -22,95 +13,102 @@ module Bundler
@fetcher = fetcher
end
- def update(local_path, remote_path, retrying = nil)
- headers = {}
-
- local_temp_path = local_path.sub(/$/, ".#{$$}")
- local_temp_path = local_temp_path.sub(/$/, ".retrying") if retrying
- local_temp_path = local_temp_path.sub(/$/, ".tmp")
-
- # first try to fetch any new bytes on the existing file
- if retrying.nil? && local_path.file?
- copy_file local_path, local_temp_path
+ def update(remote_path, local_path, etag_path)
+ append(remote_path, local_path, etag_path) || replace(remote_path, local_path, etag_path)
+ rescue CacheFile::DigestMismatchError => e
+ raise MismatchedChecksumError.new(remote_path, e.message)
+ rescue Zlib::GzipFile::Error
+ raise Bundler::HTTPError
+ end
- headers["If-None-Match"] = etag_for(local_temp_path)
- headers["Range"] =
- if local_temp_path.size.nonzero?
- # Subtract a byte to ensure the range won't be empty.
- # Avoids 416 (Range Not Satisfiable) responses.
- "bytes=#{local_temp_path.size - 1}-"
- else
- "bytes=#{local_temp_path.size}-"
- end
- end
+ private
- response = @fetcher.call(remote_path, headers)
- return nil if response.is_a?(Net::HTTPNotModified)
+ def append(remote_path, local_path, etag_path)
+ return false unless local_path.file? && local_path.size.nonzero?
- content = response.body
+ CacheFile.copy(local_path) do |file|
+ etag = etag_path.read.tap(&:chomp!) if etag_path.file?
+ etag ||= generate_etag(etag_path, file) # Remove this after 2.5.0 has been out for a while.
- etag = (response["ETag"] || "").gsub(%r{\AW/}, "")
- correct_response = SharedHelpers.filesystem_access(local_temp_path) do
- if response.is_a?(Net::HTTPPartialContent) && local_temp_path.size.nonzero?
- local_temp_path.open("a") {|f| f << slice_body(content, 1..-1) }
+ # Subtract a byte to ensure the range won't be empty.
+ # Avoids 416 (Range Not Satisfiable) responses.
+ response = @fetcher.call(remote_path, request_headers(etag, file.size - 1))
+ break true if response.is_a?(Gem::Net::HTTPNotModified)
- etag_for(local_temp_path) == etag
+ file.digests = parse_digests(response)
+ # server may ignore Range and return the full response
+ if response.is_a?(Gem::Net::HTTPPartialContent)
+ break false unless file.append(response.body.byteslice(1..-1))
else
- local_temp_path.open("wb") {|f| f << content }
-
- etag.length.zero? || etag_for(local_temp_path) == etag
+ file.write(response.body)
end
+ CacheFile.write(etag_path, etag_from_response(response))
+ true
end
+ end
- if correct_response
- SharedHelpers.filesystem_access(local_path) do
- FileUtils.mv(local_temp_path, local_path)
- end
- return nil
- end
+ # request without range header to get the full file or a 304 Not Modified
+ def replace(remote_path, local_path, etag_path)
+ etag = etag_path.read.tap(&:chomp!) if etag_path.file?
+ response = @fetcher.call(remote_path, request_headers(etag))
+ return true if response.is_a?(Gem::Net::HTTPNotModified)
+ CacheFile.write(local_path, response.body, parse_digests(response))
+ CacheFile.write(etag_path, etag_from_response(response))
+ end
- if retrying
- raise MisMatchedChecksumError.new(remote_path, etag, etag_for(local_temp_path))
- end
+ def request_headers(etag, range_start = nil)
+ headers = {}
+ headers["Range"] = "bytes=#{range_start}-" if range_start
+ headers["If-None-Match"] = %("#{etag}") if etag
+ headers
+ end
- update(local_path, remote_path, :retrying)
- rescue Zlib::GzipFile::Error
- raise Bundler::HTTPError
- ensure
- FileUtils.remove_file(local_temp_path) if File.exist?(local_temp_path)
+ def etag_for_request(etag_path)
+ etag_path.read.tap(&:chomp!) if etag_path.file?
end
- def etag_for(path)
- sum = checksum_for_file(path)
- sum ? %("#{sum}") : nil
+ # When first releasing this opaque etag feature, we want to generate the old MD5 etag
+ # based on the content of the file. After that it will always use the saved opaque etag.
+ # This transparently saves existing users with good caches from updating a bunch of files.
+ # Remove this behavior after 2.5.0 has been out for a while.
+ def generate_etag(etag_path, file)
+ etag = file.md5.hexdigest
+ CacheFile.write(etag_path, etag)
+ etag
end
- def slice_body(body, range)
- body.byteslice(range)
+ def etag_from_response(response)
+ return unless response["ETag"]
+ etag = response["ETag"].delete_prefix("W/")
+ return if etag.delete_prefix!('"') && !etag.delete_suffix!('"')
+ etag
end
- def checksum_for_file(path)
- return nil unless path.file?
- # This must use File.read instead of Digest.file().hexdigest
- # because we need to preserve \n line endings on windows when calculating
- # the checksum
- SharedHelpers.filesystem_access(path, :read) do
- SharedHelpers.digest(:MD5).hexdigest(File.read(path))
+ # Unwraps and returns a Hash of digest algorithms and base64 values
+ # according to RFC 8941 Structured Field Values for HTTP.
+ # https://www.rfc-editor.org/rfc/rfc8941#name-parsing-a-byte-sequence
+ # Ignores unsupported algorithms.
+ def parse_digests(response)
+ return unless header = response["Repr-Digest"] || response["Digest"]
+ digests = {}
+ header.split(",") do |param|
+ algorithm, value = param.split("=", 2)
+ algorithm.strip!
+ algorithm.downcase!
+ next unless SUPPORTED_DIGESTS.key?(algorithm)
+ next unless value = byte_sequence(value)
+ digests[algorithm] = value
end
+ digests.empty? ? nil : digests
end
- private
-
- def copy_file(source, dest)
- SharedHelpers.filesystem_access(source, :read) do
- File.open(source, "r") do |s|
- SharedHelpers.filesystem_access(dest, :write) do
- File.open(dest, "wb", s.stat.mode) do |f|
- IO.copy_stream(s, f)
- end
- end
- end
- end
+ # Unwrap surrounding colons (byte sequence)
+ # The wrapping characters must be matched or we return nil.
+ # Also handles quotes because right now rubygems.org sends them.
+ def byte_sequence(value)
+ return if value.delete_prefix!(":") && !value.delete_suffix!(":")
+ return if value.delete_prefix!('"') && !value.delete_suffix!('"')
+ value
end
end
end
diff --git a/lib/bundler/constants.rb b/lib/bundler/constants.rb
index 8dd8a53815..de9698b577 100644
--- a/lib/bundler/constants.rb
+++ b/lib/bundler/constants.rb
@@ -3,5 +3,5 @@
module Bundler
WINDOWS = RbConfig::CONFIG["host_os"] =~ /(msdos|mswin|djgpp|mingw)/
FREEBSD = RbConfig::CONFIG["host_os"].to_s.include?("bsd")
- NULL = WINDOWS ? "NUL" : "/dev/null"
+ NULL = File::NULL
end
diff --git a/lib/bundler/current_ruby.rb b/lib/bundler/current_ruby.rb
index f9987c4da8..93e0c401c0 100644
--- a/lib/bundler/current_ruby.rb
+++ b/lib/bundler/current_ruby.rb
@@ -22,6 +22,8 @@ module Bundler
2.7
3.0
3.1
+ 3.2
+ 3.3
].freeze
KNOWN_MAJOR_VERSIONS = KNOWN_MINOR_VERSIONS.map {|v| v.split(".", 2).first }.uniq.freeze
@@ -41,7 +43,7 @@ module Bundler
].freeze
def ruby?
- return true if Bundler::GemHelpers.generic_local_platform == Gem::Platform::RUBY
+ return true if Bundler::GemHelpers.generic_local_platform_is_ruby?
!windows? && (RUBY_ENGINE == "ruby" || RUBY_ENGINE == "rbx" || RUBY_ENGINE == "maglev" || RUBY_ENGINE == "truffleruby")
end
@@ -69,26 +71,10 @@ module Bundler
def windows?
Gem.win_platform?
end
-
- def mswin?
- # For backwards compatibility
- windows?
-
- # TODO: This should correctly be:
- # windows? && Bundler.local_platform != Gem::Platform::RUBY && Bundler.local_platform.os == "mswin32" && Bundler.local_platform.cpu == "x86"
- end
-
- def mswin64?
- windows? && Bundler.local_platform != Gem::Platform::RUBY && Bundler.local_platform.os == "mswin64" && Bundler.local_platform.cpu == "x64"
- end
-
- def mingw?
- windows? && Bundler.local_platform != Gem::Platform::RUBY && Bundler.local_platform.os == "mingw32" && Bundler.local_platform.cpu != "x64"
- end
-
- def x64_mingw?
- Gem.win_platform? && Bundler.local_platform != Gem::Platform::RUBY && Bundler.local_platform.os.start_with?("mingw") && Bundler.local_platform.cpu == "x64"
- end
+ alias_method :mswin?, :windows?
+ alias_method :mswin64?, :windows?
+ alias_method :mingw?, :windows?
+ alias_method :x64_mingw?, :windows?
(KNOWN_MINOR_VERSIONS + KNOWN_MAJOR_VERSIONS).each do |version|
trimmed_version = version.tr(".", "")
diff --git a/lib/bundler/definition.rb b/lib/bundler/definition.rb
index 9763298504..c8faf77b3b 100644
--- a/lib/bundler/definition.rb
+++ b/lib/bundler/definition.rb
@@ -18,7 +18,8 @@ module Bundler
:platforms,
:ruby_version,
:lockfile,
- :gemfiles
+ :gemfiles,
+ :locked_checksums
)
# Given a gemfile and lockfile creates a Bundler definition
@@ -76,12 +77,15 @@ module Bundler
@lockfile = lockfile
@lockfile_contents = String.new
+
@locked_bundler_version = nil
- @locked_ruby_version = nil
+ @resolved_bundler_version = nil
+
+ @locked_ruby_version = nil
@new_platform = nil
@removed_platform = nil
- if lockfile && File.exist?(lockfile)
+ if lockfile_exists?
@lockfile_contents = Bundler.read_file(lockfile)
@locked_gems = LockfileParser.new(@lockfile_contents)
@locked_platforms = @locked_gems.platforms
@@ -89,6 +93,7 @@ module Bundler
@locked_bundler_version = @locked_gems.bundler_version
@locked_ruby_version = @locked_gems.ruby_version
@originally_locked_specs = SpecSet.new(@locked_gems.specs)
+ @locked_checksums = @locked_gems.checksums
if unlock != true
@locked_deps = @locked_gems.dependencies
@@ -109,6 +114,7 @@ module Bundler
@originally_locked_specs = @locked_specs
@locked_sources = []
@locked_platforms = []
+ @locked_checksums = nil
end
locked_gem_sources = @locked_sources.select {|s| s.is_a?(Source::Rubygems) }
@@ -146,7 +152,7 @@ module Bundler
@dependency_changes = converge_dependencies
@local_changes = converge_locals
- @incomplete_lockfile = check_missing_lockfile_specs
+ check_lockfile
end
def gem_version_promoter
@@ -217,6 +223,7 @@ module Bundler
rescue BundlerError => e
@resolve = nil
@resolver = nil
+ @resolution_packages = nil
@specs = nil
@gem_version_promoter = nil
@@ -233,8 +240,17 @@ module Bundler
end
def current_dependencies
+ filter_relevant(dependencies)
+ end
+
+ def current_locked_dependencies
+ filter_relevant(locked_dependencies)
+ end
+
+ def filter_relevant(dependencies)
+ platforms_array = [generic_local_platform].freeze
dependencies.select do |d|
- d.should_include? && !d.gem_platforms([generic_local_platform]).empty?
+ d.should_include? && !d.gem_platforms(platforms_array).empty?
end
end
@@ -258,9 +274,15 @@ module Bundler
def dependencies_for(groups)
groups.map!(&:to_sym)
- current_dependencies.reject do |d|
- (d.groups & groups).empty?
+ deps = current_dependencies # always returns a new array
+ deps.select! do |d|
+ if RUBY_VERSION >= "3.1"
+ d.groups.intersect?(groups)
+ else
+ !(d.groups & groups).empty?
+ end
end
+ deps
end
# Resolve all the dependencies specified in Gemfile. It ensures that
@@ -272,7 +294,7 @@ module Bundler
@resolve ||= if Bundler.frozen_bundle?
Bundler.ui.debug "Frozen, using resolution from the lockfile"
@locked_specs
- elsif !unlocking? && nothing_changed?
+ elsif no_resolve_needed?
if deleted_deps.any?
Bundler.ui.debug "Some dependencies were deleted, using a subset of the resolution from the lockfile"
SpecSet.new(filter_specs(@locked_specs, @dependencies - deleted_deps))
@@ -298,34 +320,26 @@ module Bundler
dependencies.map(&:groups).flatten.uniq
end
- def lock(file, preserve_unknown_sections = false)
- return if Definition.no_lock
-
- contents = to_lock
-
- # Convert to \r\n if the existing lock has them
- # i.e., Windows with `git config core.autocrlf=true`
- contents.gsub!(/\n/, "\r\n") if @lockfile_contents.match?("\r\n")
-
- if @locked_bundler_version
- locked_major = @locked_bundler_version.segments.first
- current_major = Bundler.gem_version.segments.first
-
- updating_major = locked_major < current_major
- end
+ def lock(file_or_preserve_unknown_sections = false, preserve_unknown_sections_or_unused = false)
+ if [true, false, nil].include?(file_or_preserve_unknown_sections)
+ target_lockfile = lockfile || Bundler.default_lockfile
+ preserve_unknown_sections = file_or_preserve_unknown_sections
+ else
+ target_lockfile = file_or_preserve_unknown_sections
+ preserve_unknown_sections = preserve_unknown_sections_or_unused
- preserve_unknown_sections ||= !updating_major && (Bundler.frozen_bundle? || !(unlocking? || @unlocking_bundler))
+ suggestion = if target_lockfile == lockfile
+ "To fix this warning, remove it from the `Definition#lock` call."
+ else
+ "Instead, instantiate a new definition passing `#{target_lockfile}`, and call `lock` without a file argument on that definition"
+ end
- return if file && File.exist?(file) && lockfiles_equal?(@lockfile_contents, contents, preserve_unknown_sections)
+ msg = "`Definition#lock` was passed a target file argument. #{suggestion}"
- if Bundler.frozen_bundle?
- Bundler.ui.error "Cannot write a changed lockfile while frozen."
- return
+ Bundler::SharedHelpers.major_deprecation 2, msg
end
- SharedHelpers.filesystem_access(file) do |p|
- File.open(p, "wb") {|f| f.puts(contents) }
- end
+ write_lock(target_lockfile, preserve_unknown_sections)
end
def locked_ruby_version
@@ -349,27 +363,16 @@ module Bundler
end
end
+ def bundler_version_to_lock
+ @resolved_bundler_version || Bundler.gem_version
+ end
+
def to_lock
require_relative "lockfile_generator"
LockfileGenerator.generate(self)
end
def ensure_equivalent_gemfile_and_lockfile(explicit_flag = false)
- msg = String.new
- msg << "You are trying to install in deployment mode after changing\n" \
- "your Gemfile. Run `bundle install` elsewhere and add the\n" \
- "updated #{Bundler.default_lockfile.relative_path_from(SharedHelpers.pwd)} to version control."
-
- unless explicit_flag
- suggested_command = if Bundler.settings.locations("frozen").keys.&([:global, :local]).any?
- "bundle config unset frozen"
- elsif Bundler.settings.locations("deployment").keys.&([:global, :local]).any?
- "bundle config unset deployment"
- end
- msg << "\n\nIf this is a development machine, remove the #{Bundler.default_gemfile} " \
- "freeze \nby running `#{suggested_command}`." if suggested_command
- end
-
added = []
deleted = []
changed = []
@@ -383,32 +386,36 @@ module Bundler
deleted.concat deleted_deps.map {|d| "* #{pretty_dep(d)}" } if deleted_deps.any?
both_sources = Hash.new {|h, k| h[k] = [] }
- @dependencies.each {|d| both_sources[d.name][0] = d }
-
- locked_dependencies.each do |d|
- next if !Bundler.feature_flag.bundler_3_mode? && @locked_specs[d.name].empty?
-
- both_sources[d.name][1] = d
- end
+ current_dependencies.each {|d| both_sources[d.name][0] = d }
+ current_locked_dependencies.each {|d| both_sources[d.name][1] = d }
both_sources.each do |name, (dep, lock_dep)|
next if dep.nil? || lock_dep.nil?
- gemfile_source = dep.source || sources.default_source
- lock_source = lock_dep.source || sources.default_source
+ gemfile_source = dep.source || default_source
+ lock_source = lock_dep.source || default_source
next if lock_source.include?(gemfile_source)
- gemfile_source_name = dep.source ? gemfile_source.identifier : "no specified source"
- lockfile_source_name = lock_dep.source ? lock_source.identifier : "no specified source"
+ gemfile_source_name = dep.source ? gemfile_source.to_gemfile : "no specified source"
+ lockfile_source_name = lock_dep.source ? lock_source.to_gemfile : "no specified source"
changed << "* #{name} from `#{lockfile_source_name}` to `#{gemfile_source_name}`"
end
reason = change_reason
- msg << "\n\n#{reason.split(", ").map(&:capitalize).join("\n")}" unless reason.strip.empty?
+ msg = String.new
+ msg << "#{reason.capitalize.strip}, but the lockfile can't be updated because frozen mode is set"
msg << "\n\nYou have added to the Gemfile:\n" << added.join("\n") if added.any?
msg << "\n\nYou have deleted from the Gemfile:\n" << deleted.join("\n") if deleted.any?
msg << "\n\nYou have changed in the Gemfile:\n" << changed.join("\n") if changed.any?
- msg << "\n"
+ msg << "\n\nRun `bundle install` elsewhere and add the updated #{SharedHelpers.relative_gemfile_path} to version control.\n"
+
+ unless explicit_flag
+ suggested_command = unless Bundler.settings.locations("frozen").keys.include?(:env)
+ "bundle config set frozen false"
+ end
+ msg << "If this is a development machine, remove the #{SharedHelpers.relative_lockfile_path} " \
+ "freeze by running `#{suggested_command}`." if suggested_command
+ end
raise ProductionError, msg if added.any? || deleted.any? || changed.any? || !nothing_changed?
end
@@ -447,8 +454,8 @@ module Bundler
return if current_platform_locked?
raise ProductionError, "Your bundle only supports platforms #{@platforms.map(&:to_s)} " \
- "but your local platform is #{Bundler.local_platform}. " \
- "Add the current platform to the lockfile with\n`bundle lock --add-platform #{Bundler.local_platform}` and try again."
+ "but your local platform is #{local_platform}. " \
+ "Add the current platform to the lockfile with\n`bundle lock --add-platform #{local_platform}` and try again."
end
def add_platform(platform)
@@ -473,7 +480,19 @@ module Bundler
private :sources
def nothing_changed?
- !@source_changes && !@dependency_changes && !@new_platform && !@path_changes && !@local_changes && !@incomplete_lockfile
+ !@source_changes &&
+ !@dependency_changes &&
+ !@new_platform &&
+ !@path_changes &&
+ !@local_changes &&
+ !@missing_lockfile_dep &&
+ !@unlocking_bundler &&
+ !@locked_spec_with_missing_deps &&
+ !@locked_spec_with_invalid_deps
+ end
+
+ def no_resolve_needed?
+ !unlocking? && nothing_changed?
end
def unlocking?
@@ -482,19 +501,72 @@ module Bundler
private
+ def should_add_extra_platforms?
+ !lockfile_exists? && generic_local_platform_is_ruby? && !Bundler.settings[:force_ruby_platform]
+ end
+
+ def lockfile_exists?
+ file_exists?(lockfile)
+ end
+
+ def file_exists?(file)
+ file && File.exist?(file)
+ end
+
+ def write_lock(file, preserve_unknown_sections)
+ return if Definition.no_lock
+
+ contents = to_lock
+
+ # Convert to \r\n if the existing lock has them
+ # i.e., Windows with `git config core.autocrlf=true`
+ contents.gsub!(/\n/, "\r\n") if @lockfile_contents.match?("\r\n")
+
+ if @locked_bundler_version
+ locked_major = @locked_bundler_version.segments.first
+ current_major = bundler_version_to_lock.segments.first
+
+ updating_major = locked_major < current_major
+ end
+
+ preserve_unknown_sections ||= !updating_major && (Bundler.frozen_bundle? || !(unlocking? || @unlocking_bundler))
+
+ if file_exists?(file) && lockfiles_equal?(@lockfile_contents, contents, preserve_unknown_sections)
+ return if Bundler.frozen_bundle?
+ SharedHelpers.filesystem_access(file) { FileUtils.touch(file) }
+ return
+ end
+
+ if Bundler.frozen_bundle?
+ Bundler.ui.error "Cannot write a changed lockfile while frozen."
+ return
+ end
+
+ SharedHelpers.filesystem_access(file) do |p|
+ File.open(p, "wb") {|f| f.puts(contents) }
+ end
+ end
+
def resolver
@resolver ||= Resolver.new(resolution_packages, gem_version_promoter)
end
def expanded_dependencies
- dependencies + metadata_dependencies
+ dependencies_with_bundler + metadata_dependencies
+ end
+
+ def dependencies_with_bundler
+ return dependencies unless @unlocking_bundler
+ return dependencies if dependencies.map(&:name).include?("bundler")
+
+ [Dependency.new("bundler", @unlocking_bundler)] + dependencies
end
def resolution_packages
@resolution_packages ||= begin
last_resolve = converge_locked_specs
- remove_ruby_from_platforms_if_necessary!(current_dependencies)
- packages = Resolver::Base.new(source_requirements, expanded_dependencies, last_resolve, @platforms, :locked_specs => @originally_locked_specs, :unlock => @unlock[:gems], :prerelease => gem_version_promoter.pre?)
+ remove_invalid_platforms!(current_dependencies)
+ packages = Resolver::Base.new(source_requirements, expanded_dependencies, last_resolve, @platforms, locked_specs: @originally_locked_specs, unlock: @unlock[:gems], prerelease: gem_version_promoter.pre?)
additional_base_requirements_for_resolve(packages, last_resolve)
end
end
@@ -551,9 +623,14 @@ module Bundler
end
def start_resolution
- result = resolver.start
+ result = SpecSet.new(resolver.start)
+
+ @resolved_bundler_version = result.find {|spec| spec.name == "bundler" }&.version
+ @platforms = result.add_extra_platforms!(platforms) if should_add_extra_platforms?
- SpecSet.new(SpecSet.new(result).for(dependencies, false, @platforms))
+ result.complete_platforms!(platforms)
+
+ SpecSet.new(result.for(dependencies, false, @platforms))
end
def precompute_source_requirements_for_indirect_dependencies?
@@ -574,7 +651,7 @@ module Bundler
end
def current_ruby_platform_locked?
- return false unless generic_local_platform == Gem::Platform::RUBY
+ return false unless generic_local_platform_is_ruby?
return false if Bundler.settings[:force_ruby_platform] && !@platforms.include?(Gem::Platform::RUBY)
current_platform_locked?
@@ -582,7 +659,7 @@ module Bundler
def current_platform_locked?
@platforms.any? do |bundle_platform|
- MatchPlatform.platforms_match?(bundle_platform, Bundler.local_platform)
+ MatchPlatform.platforms_match?(bundle_platform, local_platform)
end
end
@@ -610,7 +687,10 @@ module Bundler
[@new_platform, "you added a new platform to your gemfile"],
[@path_changes, "the gemspecs for path gems changed"],
[@local_changes, "the gemspecs for git local gems changed"],
- [@incomplete_lockfile, "your lock file is missing some gems"],
+ [@missing_lockfile_dep, "your lock file is missing \"#{@missing_lockfile_dep}\""],
+ [@unlocking_bundler, "an update to the version of Bundler itself was requested"],
+ [@locked_spec_with_missing_deps, "your lock file includes \"#{@locked_spec_with_missing_deps}\" but not some of its dependencies"],
+ [@locked_spec_with_invalid_deps, "your lockfile does not satisfy dependencies of \"#{@locked_spec_with_invalid_deps}\""],
].select(&:first).map(&:last).join(", ")
end
@@ -637,8 +717,7 @@ module Bundler
locked_index = Index.new
locked_index.use(@locked_specs.select {|s| source.can_lock?(s) })
- # order here matters, since Index#== is checking source.specs.include?(locked_index)
- locked_index != source.specs
+ !locked_index.subset?(source.specs)
rescue PathError, GitError => e
Bundler.ui.debug "Assuming that #{source} has not changed since fetching its specs errored (#{e})"
false
@@ -665,11 +744,36 @@ module Bundler
!sources_with_changes.each {|source| @unlock[:sources] << source.name }.empty?
end
- def check_missing_lockfile_specs
- all_locked_specs = @locked_specs.map(&:name) << "bundler"
+ def check_lockfile
+ @missing_lockfile_dep = nil
+
+ @locked_spec_with_invalid_deps = nil
+ @locked_spec_with_missing_deps = nil
+
+ missing = []
+ invalid = []
+
+ @locked_specs.each do |s|
+ validation = @locked_specs.validate_deps(s)
+
+ missing << s if validation == :missing
+ invalid << s if validation == :invalid
+ end
+
+ if missing.any?
+ @locked_specs.delete(missing)
+
+ @locked_spec_with_missing_deps = missing.first.name
+ elsif !@dependency_changes
+ @missing_lockfile_dep = current_dependencies.find do |d|
+ @locked_specs[d.name].empty? && d.name != "bundler"
+ end&.name
+ end
+
+ if invalid.any?
+ @locked_specs.delete(invalid)
- @locked_specs.any? do |s|
- s.dependencies.any? {|dep| !all_locked_specs.include?(dep.name) }
+ @locked_spec_with_invalid_deps = invalid.first.name
end
end
@@ -704,6 +808,11 @@ module Bundler
changes = sources.replace_sources!(@locked_sources)
sources.all_sources.each do |source|
+ # has to be done separately, because we want to keep the locked checksum
+ # store for a source, even when doing a full update
+ if @locked_checksums && @locked_gems && locked_source = @locked_gems.sources.find {|s| s == source && !s.equal?(source) }
+ source.checksum_store.merge!(locked_source.checksum_store)
+ end
# If the source is unlockable and the current command allows an unlock of
# the source (for example, you are doing a `bundle update <foo>` of a git-pinned
# gem), unlock it. For git sources, this means to unlock the revision, which
@@ -726,6 +835,8 @@ module Bundler
dep.source = sources.get(dep.source)
end
+ next if unlocking?
+
unless locked_dep = @locked_deps[dep.name]
changes = true
next
@@ -772,26 +883,27 @@ module Bundler
def converge_specs(specs)
converged = []
-
- deps = @dependencies.select do |dep|
- specs[dep].any? {|s| s.satisfies?(dep) && (!dep.source || s.source.include?(dep.source)) }
- end
+ deps = []
@specs_that_changed_sources = []
specs.each do |s|
+ name = s.name
dep = @dependencies.find {|d| s.satisfies?(d) }
+ lockfile_source = s.source
- # Replace the locked dependency's source with the equivalent source from the Gemfile
- s.source = if dep&.source
- gemfile_source = dep.source
- lockfile_source = s.source
+ if dep
+ gemfile_source = dep.source || default_source
@specs_that_changed_sources << s if gemfile_source != lockfile_source
+ deps << dep if !dep.source || lockfile_source.include?(dep.source)
+ @unlock[:gems] << name if lockfile_source.include?(dep.source) && lockfile_source != gemfile_source
- gemfile_source
+ # Replace the locked dependency's source with the equivalent source from the Gemfile
+ s.source = gemfile_source
else
- sources.get_with_fallback(s.source)
+ # Replace the locked dependency's source with the default source, if the locked source is no longer in the Gemfile
+ s.source = default_source unless sources.get(lockfile_source)
end
next if @unlock[:sources].include?(s.source.name)
@@ -800,9 +912,9 @@ module Bundler
if s.source.instance_of?(Source::Path) || s.source.instance_of?(Source::Gemspec)
new_specs = begin
s.source.specs
- rescue PathError, GitError
+ rescue PathError
# if we won't need the source (according to the lockfile),
- # don't error if the path/git source isn't available
+ # don't error if the path source isn't available
next if specs.
for(requested_dependencies, false).
none? {|locked_spec| locked_spec.source == s.source }
@@ -816,11 +928,11 @@ module Bundler
else
# If the spec is no longer in the path source, unlock it. This
# commonly happens if the version changed in the gemspec
- @unlock[:gems] << s.name
+ @unlock[:gems] << name
end
end
- if dep.nil? && requested_dependencies.find {|d| s.name == d.name }
+ if dep.nil? && requested_dependencies.find {|d| name == d.name }
@unlock[:gems] << s.name
else
converged << s
@@ -832,7 +944,7 @@ module Bundler
def metadata_dependencies
@metadata_dependencies ||= [
- Dependency.new("Ruby\0", Gem.ruby_version),
+ Dependency.new("Ruby\0", Bundler::RubyVersion.system.gem_version),
Dependency.new("RubyGems\0", Gem::VERSION),
]
end
@@ -844,20 +956,32 @@ module Bundler
source_requirements = if precompute_source_requirements_for_indirect_dependencies?
all_requirements = source_map.all_requirements
all_requirements = pin_locally_available_names(all_requirements) if @prefer_local
- { :default => sources.default_source }.merge(all_requirements)
+ { default: default_source }.merge(all_requirements)
else
- { :default => Source::RubygemsAggregate.new(sources, source_map) }.merge(source_map.direct_requirements)
+ { default: Source::RubygemsAggregate.new(sources, source_map) }.merge(source_map.direct_requirements)
end
source_requirements.merge!(source_map.locked_requirements) unless @remote
metadata_dependencies.each do |dep|
source_requirements[dep.name] = sources.metadata_source
end
- source_requirements[:default_bundler] = source_requirements["bundler"] || sources.default_source
- source_requirements["bundler"] = sources.metadata_source # needs to come last to override
+
+ default_bundler_source = source_requirements["bundler"] || default_source
+
+ if @unlocking_bundler
+ default_bundler_source.add_dependency_names("bundler")
+ else
+ source_requirements[:default_bundler] = default_bundler_source
+ source_requirements["bundler"] = sources.metadata_source # needs to come last to override
+ end
+
verify_changed_sources!
source_requirements
end
+ def default_source
+ sources.default_source
+ end
+
def verify_changed_sources!
@specs_that_changed_sources.each do |s|
if s.source.specs.search(s.name).empty?
@@ -876,7 +1000,8 @@ module Bundler
if preserve_unknown_sections
sections_to_ignore = LockfileParser.sections_to_ignore(@locked_bundler_version)
sections_to_ignore += LockfileParser.unknown_sections_in_lockfile(current)
- sections_to_ignore += LockfileParser::ENVIRONMENT_VERSION_SECTIONS
+ sections_to_ignore << LockfileParser::RUBY
+ sections_to_ignore << LockfileParser::BUNDLED unless @unlocking_bundler
pattern = /#{Regexp.union(sections_to_ignore)}\n(\s{2,}.*\n)+/
whitespace_cleanup = /\n{2,}/
current = current.gsub(pattern, "\n").gsub(whitespace_cleanup, "\n\n").strip
@@ -886,22 +1011,27 @@ module Bundler
end
def additional_base_requirements_for_resolve(resolution_packages, last_resolve)
- return resolution_packages unless @locked_gems && unlocking? && !sources.expired_sources?(@locked_gems.sources)
+ return resolution_packages unless @locked_gems && !sources.expired_sources?(@locked_gems.sources)
converge_specs(@originally_locked_specs - last_resolve).each do |locked_spec|
+ next if locked_spec.source.is_a?(Source::Path)
resolution_packages.base_requirements[locked_spec.name] = Gem::Requirement.new(">= #{locked_spec.version}")
end
resolution_packages
end
- def remove_ruby_from_platforms_if_necessary!(dependencies)
- return if Bundler.frozen_bundle? ||
- Bundler.local_platform == Gem::Platform::RUBY ||
- !platforms.include?(Gem::Platform::RUBY) ||
- (@new_platform && platforms.last == Gem::Platform::RUBY) ||
- !@originally_locked_specs.incomplete_ruby_specs?(dependencies)
+ def remove_invalid_platforms!(dependencies)
+ return if Bundler.frozen_bundle?
+
+ platforms.reverse_each do |platform|
+ next if local_platform == platform ||
+ (@new_platform && platforms.last == platform) ||
+ @path_changes ||
+ @dependency_changes ||
+ !@originally_locked_specs.incomplete_for_platform?(dependencies, platform)
- remove_platform(Gem::Platform::RUBY)
- add_current_platform
+ remove_platform(platform)
+ add_current_platform if platform == Gem::Platform::RUBY
+ end
end
def source_map
diff --git a/lib/bundler/dependency.rb b/lib/bundler/dependency.rb
index 1f8b9da2eb..77d7a00362 100644
--- a/lib/bundler/dependency.rb
+++ b/lib/bundler/dependency.rb
@@ -9,18 +9,19 @@ module Bundler
attr_reader :autorequire
attr_reader :groups, :platforms, :gemfile, :path, :git, :github, :branch, :ref
- ALL_RUBY_VERSIONS = ((18..27).to_a + (30..31).to_a).freeze
+ ALL_RUBY_VERSIONS = (18..27).to_a.concat((30..34).to_a).freeze
PLATFORM_MAP = {
- :ruby => [Gem::Platform::RUBY, ALL_RUBY_VERSIONS],
- :mri => [Gem::Platform::RUBY, ALL_RUBY_VERSIONS],
- :rbx => [Gem::Platform::RUBY],
- :truffleruby => [Gem::Platform::RUBY],
- :jruby => [Gem::Platform::JAVA, [18, 19]],
- :windows => [Gem::Platform::WINDOWS, ALL_RUBY_VERSIONS],
- :mswin => [Gem::Platform::MSWIN, ALL_RUBY_VERSIONS],
- :mswin64 => [Gem::Platform::MSWIN64, ALL_RUBY_VERSIONS - [18]],
- :mingw => [Gem::Platform::MINGW, ALL_RUBY_VERSIONS],
- :x64_mingw => [Gem::Platform::X64_MINGW, ALL_RUBY_VERSIONS - [18, 19]],
+ ruby: [Gem::Platform::RUBY, ALL_RUBY_VERSIONS],
+ mri: [Gem::Platform::RUBY, ALL_RUBY_VERSIONS],
+ rbx: [Gem::Platform::RUBY],
+ truffleruby: [Gem::Platform::RUBY],
+ jruby: [Gem::Platform::JAVA, [18, 19]],
+ windows: [Gem::Platform::WINDOWS, ALL_RUBY_VERSIONS],
+ # deprecated
+ mswin: [Gem::Platform::MSWIN, ALL_RUBY_VERSIONS],
+ mswin64: [Gem::Platform::MSWIN64, ALL_RUBY_VERSIONS - [18]],
+ mingw: [Gem::Platform::MINGW, ALL_RUBY_VERSIONS],
+ x64_mingw: [Gem::Platform::X64_MINGW, ALL_RUBY_VERSIONS - [18, 19]],
}.each_with_object({}) do |(platform, spec), hash|
hash[platform] = spec[0]
spec[1]&.each {|version| hash[:"#{platform}_#{version}"] = spec[0] }
@@ -47,10 +48,13 @@ module Bundler
@autorequire = Array(options["require"] || []) if options.key?("require")
end
+ RUBY_PLATFORM_ARRAY = [Gem::Platform::RUBY].freeze
+ private_constant :RUBY_PLATFORM_ARRAY
+
# Returns the platforms this dependency is valid for, in the same order as
# passed in the `valid_platforms` parameter
def gem_platforms(valid_platforms)
- return [Gem::Platform::RUBY] if force_ruby_platform
+ return RUBY_PLATFORM_ARRAY if force_ruby_platform
return valid_platforms if @platforms.empty?
valid_platforms.select {|p| expanded_platforms.include?(GemHelpers.generic(p)) }
@@ -64,6 +68,10 @@ module Bundler
@should_include && current_env? && current_platform?
end
+ def gemspec_dev_dep?
+ type == :development
+ end
+
def current_env?
return true unless @env
if @env.is_a?(Hash)
diff --git a/lib/bundler/digest.rb b/lib/bundler/digest.rb
index f11f5edd38..2c6d971f1b 100644
--- a/lib/bundler/digest.rb
+++ b/lib/bundler/digest.rb
@@ -26,7 +26,7 @@ module Bundler
end
a, b, c, d, e = *words
(16..79).each do |i|
- w[i] = SHA1_MASK & rotate((w[i-3] ^ w[i-8] ^ w[i-14] ^ w[i-16]), 1)
+ w[i] = SHA1_MASK & rotate((w[i - 3] ^ w[i - 8] ^ w[i - 14] ^ w[i - 16]), 1)
end
0.upto(79) do |i|
case i
@@ -50,7 +50,7 @@ module Bundler
words.map!.with_index {|word, index| SHA1_MASK & (word + mutated[index]) }
end
- words.pack("N*").unpack("H*").first
+ words.pack("N*").unpack1("H*")
end
private
diff --git a/lib/bundler/dsl.rb b/lib/bundler/dsl.rb
index 03c80a408c..6af80fb31f 100644
--- a/lib/bundler/dsl.rb
+++ b/lib/bundler/dsl.rb
@@ -18,9 +18,10 @@ module Bundler
VALID_KEYS = %w[group groups git path glob name branch ref tag require submodules
platform platforms type source install_if gemfile force_ruby_platform].freeze
- GITHUB_PULL_REQUEST_URL = %r{\Ahttps://github\.com/([A-Za-z0-9_\-\.]+/[A-Za-z0-9_\-\.]+)/pull/(\d+)\z}.freeze
+ GITHUB_PULL_REQUEST_URL = %r{\Ahttps://github\.com/([A-Za-z0-9_\-\.]+/[A-Za-z0-9_\-\.]+)/pull/(\d+)\z}
+ GITLAB_MERGE_REQUEST_URL = %r{\Ahttps://gitlab\.com/([A-Za-z0-9_\-\./]+)/-/merge_requests/(\d+)\z}
- attr_reader :gemspecs
+ attr_reader :gemspecs, :gemfile
attr_accessor :dependencies
def initialize
@@ -46,7 +47,7 @@ module Bundler
@gemfile = expanded_gemfile_path
@gemfiles << expanded_gemfile_path
contents ||= Bundler.read_file(@gemfile.to_s)
- instance_eval(contents.dup.tap {|x| x.untaint if RUBY_VERSION < "2.7" }, gemfile.to_s, 1)
+ instance_eval(contents, @gemfile.to_s, 1)
rescue Exception => e # rubocop:disable Lint/RescueException
message = "There was an error " \
"#{e.is_a?(GemfileEvalError) ? "evaluating" : "parsing"} " \
@@ -76,11 +77,11 @@ module Bundler
@gemspecs << spec
- gem spec.name, :name => spec.name, :path => path, :glob => glob
+ gem spec.name, name: spec.name, path: path, glob: glob
group(development_group) do
spec.development_dependencies.each do |dep|
- gem dep.name, *(dep.requirement.as_list + [:type => :development])
+ gem dep.name, *(dep.requirement.as_list + [type: :development])
end
end
when 0
@@ -102,39 +103,51 @@ module Bundler
# if there's already a dependency with this name we try to prefer one
if current = @dependencies.find {|d| d.name == dep.name }
- deleted_dep = @dependencies.delete(current) if current.type == :development
+ if current.requirement != dep.requirement
+ current_requirement_open = current.requirements_list.include?(">= 0")
- unless deleted_dep
- if current.requirement != dep.requirement
- return if dep.type == :development
+ gemspec_dep = [dep, current].find(&:gemspec_dev_dep?)
+ if gemspec_dep
+ gemfile_dep = [dep, current].find(&:runtime?)
+ unless current_requirement_open
+ Bundler.ui.warn "A gemspec development dependency (#{gemspec_dep.name}, #{gemspec_dep.requirement}) is being overridden by a Gemfile dependency (#{gemfile_dep.name}, #{gemfile_dep.requirement}).\n" \
+ "This behaviour may change in the future. Please remove either of them, or make sure they both have the same requirement\n"
+ end
+ else
update_prompt = ""
if File.basename(@gemfile) == Injector::INJECTED_GEMS
- if dep.requirements_list.include?(">= 0") && !current.requirements_list.include?(">= 0")
+ if dep.requirements_list.include?(">= 0") && !current_requirement_open
update_prompt = ". Gem already added"
else
update_prompt = ". If you want to update the gem version, run `bundle update #{current.name}`"
- update_prompt += ". You may also need to change the version requirement specified in the Gemfile if it's too restrictive." unless current.requirements_list.include?(">= 0")
+ update_prompt += ". You may also need to change the version requirement specified in the Gemfile if it's too restrictive." unless current_requirement_open
end
end
raise GemfileError, "You cannot specify the same gem twice with different version requirements.\n" \
- "You specified: #{current.name} (#{current.requirement}) and #{dep.name} (#{dep.requirement})" \
- "#{update_prompt}"
- elsif current.source != dep.source
- return if dep.type == :development
- raise GemfileError, "You cannot specify the same gem twice coming from different sources.\n" \
- "You specified that #{dep.name} (#{dep.requirement}) should come from " \
- "#{current.source || "an unspecified source"} and #{dep.source}\n"
- else
- Bundler.ui.warn "Your Gemfile lists the gem #{current.name} (#{current.requirement}) more than once.\n" \
- "You should probably keep only one of them.\n" \
- "Remove any duplicate entries and specify the gem only once.\n" \
- "While it's not a problem now, it could cause errors if you change the version of one of them later."
+ "You specified: #{current.name} (#{current.requirement}) and #{dep.name} (#{dep.requirement})" \
+ "#{update_prompt}"
end
end
+
+ # Always prefer the dependency from the Gemfile
+ if current.gemspec_dev_dep?
+ @dependencies.delete(current)
+ elsif dep.gemspec_dev_dep?
+ return
+ elsif current.source != dep.source
+ raise GemfileError, "You cannot specify the same gem twice coming from different sources.\n" \
+ "You specified that #{dep.name} (#{dep.requirement}) should come from " \
+ "#{current.source || "an unspecified source"} and #{dep.source}\n"
+ else
+ Bundler.ui.warn "Your Gemfile lists the gem #{current.name} (#{current.requirement}) more than once.\n" \
+ "You should probably keep only one of them.\n" \
+ "Remove any duplicate entries and specify the gem only once.\n" \
+ "While it's not a problem now, it could cause errors if you change the version of one of them later."
+ end
end
@dependencies << dep
@@ -296,6 +309,20 @@ module Bundler
repo_name ||= user_name
"https://#{user_name}@bitbucket.org/#{user_name}/#{repo_name}.git"
end
+
+ git_source(:gitlab) do |repo_name|
+ if repo_name =~ GITLAB_MERGE_REQUEST_URL
+ {
+ "git" => "https://gitlab.com/#{$1}.git",
+ "branch" => nil,
+ "ref" => "refs/merge-requests/#{$2}/head",
+ "tag" => nil,
+ }
+ else
+ repo_name = "#{repo_name}/#{repo_name}" unless repo_name.include?("/")
+ "https://gitlab.com/#{repo_name}.git"
+ end
+ end
end
def with_source(source)
@@ -397,13 +424,11 @@ module Bundler
end
def validate_keys(command, opts, valid_keys)
- invalid_keys = opts.keys - valid_keys
-
- git_source = opts.keys & @git_sources.keys.map(&:to_s)
- if opts["branch"] && !(opts["git"] || opts["github"] || git_source.any?)
+ if opts["branch"] && !(opts["git"] || opts["github"] || (opts.keys & @git_sources.keys.map(&:to_s)).any?)
raise GemfileError, %(The `branch` option for `#{command}` is not allowed. Only gems with a git source can specify a branch)
end
+ invalid_keys = opts.keys - valid_keys
return true unless invalid_keys.any?
message = String.new
@@ -422,9 +447,13 @@ module Bundler
def normalize_source(source)
case source
when :gemcutter, :rubygems, :rubyforge
- Bundler::SharedHelpers.major_deprecation 2, "The source :#{source} is deprecated because HTTP " \
- "requests are insecure.\nPlease change your source to 'https://" \
- "rubygems.org' if possible, or 'http://rubygems.org' if not."
+ message =
+ "The source :#{source} is deprecated because HTTP requests are insecure.\n" \
+ "Please change your source to 'https://rubygems.org' if possible, or 'http://rubygems.org' if not."
+ removed_message =
+ "The source :#{source} is disallowed because HTTP requests are insecure.\n" \
+ "Please change your source to 'https://rubygems.org' if possible, or 'http://rubygems.org' if not."
+ Bundler::SharedHelpers.major_deprecation 2, message, removed_message: removed_message
"http://rubygems.org"
when String
source
@@ -469,10 +498,17 @@ module Bundler
"should come from that source"
raise GemfileEvalError, msg
else
- Bundler::SharedHelpers.major_deprecation 2, "Your Gemfile contains multiple global sources. " \
+ message =
+ "Your Gemfile contains multiple global sources. " \
"Using `source` more than once without a block is a security risk, and " \
"may result in installing unexpected gems. To resolve this warning, use " \
"a block to indicate which gems should come from the secondary source."
+ removed_message =
+ "Your Gemfile contains multiple global sources. " \
+ "Using `source` more than once without a block is a security risk, and " \
+ "may result in installing unexpected gems. To resolve this error, use " \
+ "a block to indicate which gems should come from the secondary source."
+ Bundler::SharedHelpers.major_deprecation 2, message, removed_message: removed_message
end
end
diff --git a/lib/bundler/endpoint_specification.rb b/lib/bundler/endpoint_specification.rb
index d315d1cc68..87cb352efa 100644
--- a/lib/bundler/endpoint_specification.rb
+++ b/lib/bundler/endpoint_specification.rb
@@ -26,10 +26,6 @@ module Bundler
@platform
end
- def identifier
- @__identifier ||= [name, version, platform.to_s]
- end
-
# needed for standalone, load required_paths from local gemspec
# after the gem is installed
def require_paths
@@ -98,7 +94,7 @@ module Bundler
def _local_specification
return unless @loaded_from && File.exist?(local_specification_path)
- eval(File.read(local_specification_path)).tap do |spec|
+ eval(File.read(local_specification_path), nil, local_specification_path).tap do |spec|
spec.loaded_from = @loaded_from
end
end
@@ -129,7 +125,11 @@ module Bundler
next unless v
case k.to_s
when "checksum"
- @checksum = v.last
+ begin
+ @checksum = Checksum.from_api(v.last, @spec_fetcher.uri)
+ rescue ArgumentError => e
+ raise ArgumentError, "Invalid checksum for #{full_name}: #{e.message}"
+ end
when "rubygems"
@required_rubygems_version = Gem::Requirement.new(v)
when "ruby"
diff --git a/lib/bundler/env.rb b/lib/bundler/env.rb
index 7b1152930e..f6cb198e38 100644
--- a/lib/bundler/env.rb
+++ b/lib/bundler/env.rb
@@ -40,11 +40,11 @@ module Bundler
out << "\n## Gemfile\n"
gemfiles.each do |gemfile|
- out << "\n### #{Pathname.new(gemfile).relative_path_from(SharedHelpers.pwd)}\n\n"
+ out << "\n### #{SharedHelpers.relative_path_to(gemfile)}\n\n"
out << "```ruby\n" << read_file(gemfile).chomp << "\n```\n"
end
- out << "\n### #{Bundler.default_lockfile.relative_path_from(SharedHelpers.pwd)}\n\n"
+ out << "\n### #{SharedHelpers.relative_path_to(Bundler.default_lockfile)}\n\n"
out << "```\n" << read_file(Bundler.default_lockfile).chomp << "\n```\n"
end
@@ -69,9 +69,7 @@ module Bundler
end
def self.ruby_version
- str = String.new(RUBY_VERSION)
- str << "p#{RUBY_PATCHLEVEL}" if defined? RUBY_PATCHLEVEL
- str << " (#{RUBY_RELEASE_DATE} revision #{RUBY_REVISION}) [#{Gem::Platform.local}]"
+ "#{RUBY_VERSION}p#{RUBY_PATCHLEVEL} (#{RUBY_RELEASE_DATE} revision #{RUBY_REVISION}) [#{Gem::Platform.local}]"
end
def self.git_version
diff --git a/lib/bundler/environment_preserver.rb b/lib/bundler/environment_preserver.rb
index 57013f5d50..c4c1b53fa4 100644
--- a/lib/bundler/environment_preserver.rb
+++ b/lib/bundler/environment_preserver.rb
@@ -58,9 +58,9 @@ module Bundler
env = @original.clone
@keys.each do |key|
value = env[key]
- if !value.nil? && !value.empty?
+ if !value.nil?
env[@prefix + key] ||= value
- elsif value.nil?
+ else
env[@prefix + key] ||= INTENTIONALLY_NIL
end
end
@@ -72,7 +72,7 @@ module Bundler
env = @original.clone
@keys.each do |key|
value_original = env[@prefix + key]
- next if value_original.nil? || value_original.empty?
+ next if value_original.nil?
if value_original == INTENTIONALLY_NIL
env.delete(key)
else
diff --git a/lib/bundler/errors.rb b/lib/bundler/errors.rb
index 5839fc6a73..b6a11cc721 100644
--- a/lib/bundler/errors.rb
+++ b/lib/bundler/errors.rb
@@ -52,6 +52,49 @@ module Bundler
class GemfileEvalError < GemfileError; end
class MarshalError < StandardError; end
+ class ChecksumMismatchError < SecurityError
+ def initialize(lock_name, existing, checksum)
+ @lock_name = lock_name
+ @existing = existing
+ @checksum = checksum
+ end
+
+ def message
+ <<~MESSAGE
+ Bundler found mismatched checksums. This is a potential security risk.
+ #{@lock_name} #{@existing.to_lock}
+ from #{@existing.sources.join("\n and ")}
+ #{@lock_name} #{@checksum.to_lock}
+ from #{@checksum.sources.join("\n and ")}
+
+ #{mismatch_resolution_instructions}
+ To ignore checksum security warnings, disable checksum validation with
+ `bundle config set --local disable_checksum_validation true`
+ MESSAGE
+ end
+
+ def mismatch_resolution_instructions
+ removable, remote = [@existing, @checksum].partition(&:removable?)
+ case removable.size
+ when 0
+ msg = +"Mismatched checksums each have an authoritative source:\n"
+ msg << " 1. #{@existing.sources.reject(&:removable?).map(&:to_s).join(" and ")}\n"
+ msg << " 2. #{@checksum.sources.reject(&:removable?).map(&:to_s).join(" and ")}\n"
+ msg << "You may need to alter your Gemfile sources to resolve this issue.\n"
+ when 1
+ msg = +"If you trust #{remote.first.sources.first}, to resolve this issue you can:\n"
+ msg << removable.first.removal_instructions
+ when 2
+ msg = +"To resolve this issue you can either:\n"
+ msg << @checksum.removal_instructions
+ msg << "or if you are sure that the new checksum from #{@checksum.sources.first} is correct:\n"
+ msg << @existing.removal_instructions
+ end
+ end
+
+ status_code(37)
+ end
+
class PermissionError < BundlerError
def initialize(path, permission_type = :write)
@path = path
@@ -172,4 +215,19 @@ module Bundler
status_code(36)
end
+
+ class InsecureInstallPathError < BundlerError
+ def initialize(path)
+ @path = path
+ end
+
+ def message
+ "The installation path is insecure. Bundler cannot continue.\n" \
+ "#{@path} is world-writable (without sticky bit).\n" \
+ "Bundler cannot safely replace gems in world-writeable directories due to potential vulnerabilities.\n" \
+ "Please change the permissions of this directory or choose a different install path."
+ end
+
+ status_code(38)
+ end
end
diff --git a/lib/bundler/feature_flag.rb b/lib/bundler/feature_flag.rb
index 983de3137c..ab2189f7f0 100644
--- a/lib/bundler/feature_flag.rb
+++ b/lib/bundler/feature_flag.rb
@@ -37,7 +37,6 @@ module Bundler
settings_flag(:plugins) { @bundler_version >= Gem::Version.new("1.14") }
settings_flag(:print_only_version_number) { bundler_3_mode? }
settings_flag(:setup_makes_kernel_gem_public) { !bundler_3_mode? }
- settings_flag(:suppress_install_using_messages) { bundler_3_mode? }
settings_flag(:update_requires_all_flag) { bundler_4_mode? }
settings_option(:default_cli_command) { bundler_3_mode? ? :cli_help : :install }
diff --git a/lib/bundler/fetcher.rb b/lib/bundler/fetcher.rb
index a073bae278..6288b22dcd 100644
--- a/lib/bundler/fetcher.rb
+++ b/lib/bundler/fetcher.rb
@@ -1,14 +1,15 @@
# frozen_string_literal: true
require_relative "vendored_persistent"
+require_relative "vendored_timeout"
require "cgi"
require "securerandom"
require "zlib"
-require "rubygems/request"
module Bundler
# Handles all the fetching with the rubygems server
class Fetcher
+ autoload :Base, File.expand_path("fetcher/base", __dir__)
autoload :CompactIndex, File.expand_path("fetcher/compact_index", __dir__)
autoload :Downloader, File.expand_path("fetcher/downloader", __dir__)
autoload :Dependency, File.expand_path("fetcher/dependency", __dir__)
@@ -61,6 +62,16 @@ module Bundler
end
end
+ # This error is raised if HTTP authentication is correct, but lacks
+ # necessary permissions.
+ class AuthenticationForbiddenError < HTTPError
+ def initialize(remote_uri)
+ remote_uri = filter_uri(remote_uri)
+ super "Access token could not be authenticated for #{remote_uri}.\n" \
+ "Make sure it's valid and has the necessary scopes configured."
+ end
+ end
+
# Exceptions classes that should bypass retry attempts. If your password didn't work the
# first time, it's not going to the third time.
NET_ERRORS = [:HTTPBadGateway, :HTTPBadRequest, :HTTPFailedDependency,
@@ -70,9 +81,9 @@ module Bundler
:HTTPRequestURITooLong, :HTTPUnauthorized, :HTTPUnprocessableEntity,
:HTTPUnsupportedMediaType, :HTTPVersionNotSupported].freeze
FAIL_ERRORS = begin
- fail_errors = [AuthenticationRequiredError, BadAuthenticationError, FallbackError]
+ fail_errors = [AuthenticationRequiredError, BadAuthenticationError, AuthenticationForbiddenError, FallbackError, SecurityError]
fail_errors << Gem::Requirement::BadRequirementError
- fail_errors.concat(NET_ERRORS.map {|e| Net.const_get(e) })
+ fail_errors.concat(NET_ERRORS.map {|e| Gem::Net.const_get(e) })
end.freeze
class << self
@@ -84,6 +95,7 @@ module Bundler
self.max_retries = Bundler.settings[:retry] # How many retries for the API call
def initialize(remote)
+ @cis = nil
@remote = remote
Socket.do_not_reverse_lookup = true
@@ -99,15 +111,17 @@ module Bundler
spec -= [nil, "ruby", ""]
spec_file_name = "#{spec.join "-"}.gemspec"
- uri = Bundler::URI.parse("#{remote_uri}#{Gem::MARSHAL_SPEC_DIR}#{spec_file_name}.rz")
- if uri.scheme == "file"
- path = Bundler.rubygems.correct_for_windows_path(uri.path)
- Bundler.load_marshal Bundler.rubygems.inflate(Gem.read_binary(path))
+ uri = Gem::URI.parse("#{remote_uri}#{Gem::MARSHAL_SPEC_DIR}#{spec_file_name}.rz")
+ spec = if uri.scheme == "file"
+ path = Gem::Util.correct_for_windows_path(uri.path)
+ Bundler.safe_load_marshal Bundler.rubygems.inflate(Gem.read_binary(path))
elsif cached_spec_path = gemspec_cached_path(spec_file_name)
Bundler.load_gemspec(cached_spec_path)
else
- Bundler.load_marshal Bundler.rubygems.inflate(downloader.fetch(uri).body)
+ Bundler.safe_load_marshal Bundler.rubygems.inflate(downloader.fetch(uri).body)
end
+ raise MarshalError, "is #{spec.inspect}" unless spec.is_a?(Gem::Specification)
+ spec
rescue MarshalError
raise HTTPError, "Gemspec #{spec} contained invalid data.\n" \
"Your network or your gem server is probably having issues right now."
@@ -124,20 +138,11 @@ module Bundler
def specs(gem_names, source)
index = Bundler::Index.new
- if Bundler::Fetcher.disable_endpoint
- @use_api = false
- specs = fetchers.last.specs(gem_names)
- else
- specs = []
- @fetchers = fetchers.drop_while do |f|
- !f.available? || (f.api_fetcher? && !gem_names) || !specs = f.specs(gem_names)
- end
- @use_api = false if fetchers.none?(&:api_fetcher?)
- end
-
- specs.each do |name, version, platform, dependencies, metadata|
+ fetch_specs(gem_names).each do |name, version, platform, dependencies, metadata|
spec = if dependencies
- EndpointSpecification.new(name, version, platform, self, dependencies, metadata)
+ EndpointSpecification.new(name, version, platform, self, dependencies, metadata).tap do |es|
+ source.checksum_store.replace(es, es.checksum)
+ end
else
RemoteSpecification.new(name, version, platform, self)
end
@@ -148,22 +153,10 @@ module Bundler
index
rescue CertificateFailureError
- Bundler.ui.info "" if gem_names && use_api # newline after dots
+ Bundler.ui.info "" if gem_names && api_fetcher? # newline after dots
raise
end
- def use_api
- return @use_api if defined?(@use_api)
-
- fetchers.shift until fetchers.first.available?
-
- @use_api = if remote_uri.scheme == "file" || Bundler::Fetcher.disable_endpoint
- false
- else
- fetchers.first.api_fetcher?
- end
- end
-
def user_agent
@user_agent ||= begin
ruby = Bundler::RubyVersion.system
@@ -199,10 +192,6 @@ module Bundler
end
end
- def fetchers
- @fetchers ||= FETCHERS.map {|f| f.new(downloader, @remote, uri) }
- end
-
def http_proxy
return unless uri = connection.proxy_uri
uri.to_s
@@ -212,25 +201,49 @@ module Bundler
"#<#{self.class}:0x#{object_id} uri=#{uri}>"
end
+ def api_fetcher?
+ fetchers.first.api_fetcher?
+ end
+
+ def gem_remote_fetcher
+ @gem_remote_fetcher ||= begin
+ require_relative "fetcher/gem_remote_fetcher"
+ fetcher = GemRemoteFetcher.new Gem.configuration[:http_proxy]
+ fetcher.headers["User-Agent"] = user_agent
+ fetcher.headers["X-Gemfile-Source"] = @remote.original_uri.to_s if @remote.original_uri
+ fetcher
+ end
+ end
+
private
- FETCHERS = [CompactIndex, Dependency, Index].freeze
+ def available_fetchers
+ if Bundler::Fetcher.disable_endpoint
+ [Index]
+ elsif remote_uri.scheme == "file"
+ Bundler.ui.debug("Using a local server, bundler won't use the CompactIndex API")
+ [Index]
+ else
+ [CompactIndex, Dependency, Index]
+ end
+ end
+
+ def fetchers
+ @fetchers ||= available_fetchers.map {|f| f.new(downloader, @remote, uri, gem_remote_fetcher) }.drop_while {|f| !f.available? }
+ end
+
+ def fetch_specs(gem_names)
+ fetchers.reject!(&:api_fetcher?) unless gem_names
+ fetchers.reject! do |f|
+ specs = f.specs(gem_names)
+ return specs if specs
+ true
+ end
+ []
+ end
def cis
- env_cis = {
- "TRAVIS" => "travis",
- "CIRCLECI" => "circle",
- "SEMAPHORE" => "semaphore",
- "JENKINS_URL" => "jenkins",
- "BUILDBOX" => "buildbox",
- "GO_SERVER_URL" => "go",
- "SNAP_CI" => "snap",
- "GITLAB_CI" => "gitlab",
- "GITHUB_ACTIONS" => "github",
- "CI_NAME" => ENV["CI_NAME"],
- "CI" => "ci",
- }
- env_cis.find_all {|env, _| ENV[env] }.map {|_, ci| ci }
+ @cis ||= Bundler::CIDetector.ci_strings
end
def connection
@@ -240,9 +253,9 @@ module Bundler
Bundler.settings[:ssl_client_cert]
raise SSLError if needs_ssl && !defined?(OpenSSL::SSL)
- con = PersistentHTTP.new :name => "bundler", :proxy => :ENV
+ con = Gem::Net::HTTP::Persistent.new name: "bundler", proxy: :ENV
if gem_proxy = Gem.configuration[:http_proxy]
- con.proxy = Bundler::URI.parse(gem_proxy) if gem_proxy != :no_proxy
+ con.proxy = Gem::URI.parse(gem_proxy) if gem_proxy != :no_proxy
end
if remote_uri.scheme == "https"
@@ -275,10 +288,10 @@ module Bundler
end
HTTP_ERRORS = [
- Timeout::Error, EOFError, SocketError, Errno::ENETDOWN, Errno::ENETUNREACH,
+ Gem::Timeout::Error, EOFError, SocketError, Errno::ENETDOWN, Errno::ENETUNREACH,
Errno::EINVAL, Errno::ECONNRESET, Errno::ETIMEDOUT, Errno::EAGAIN,
- Net::HTTPBadResponse, Net::HTTPHeaderSyntaxError, Net::ProtocolError,
- PersistentHTTP::Error, Zlib::BufError, Errno::EHOSTUNREACH
+ Gem::Net::HTTPBadResponse, Gem::Net::HTTPHeaderSyntaxError, Gem::Net::ProtocolError,
+ Gem::Net::HTTP::Persistent::Error, Zlib::BufError, Errno::EHOSTUNREACH
].freeze
def bundler_cert_store
@@ -294,6 +307,7 @@ module Bundler
end
else
store.set_default_paths
+ require "rubygems/request"
Gem::Request.get_cert_files.each {|c| store.add_file c }
end
store
diff --git a/lib/bundler/fetcher/base.rb b/lib/bundler/fetcher/base.rb
index 62cc75add8..cfec2f8e94 100644
--- a/lib/bundler/fetcher/base.rb
+++ b/lib/bundler/fetcher/base.rb
@@ -6,12 +6,14 @@ module Bundler
attr_reader :downloader
attr_reader :display_uri
attr_reader :remote
+ attr_reader :gem_remote_fetcher
- def initialize(downloader, remote, display_uri)
+ def initialize(downloader, remote, display_uri, gem_remote_fetcher)
raise "Abstract class" if self.class == Base
@downloader = downloader
@remote = remote
@display_uri = display_uri
+ @gem_remote_fetcher = gem_remote_fetcher
end
def remote_uri
@@ -38,9 +40,9 @@ module Bundler
private
- def log_specs(debug_msg)
+ def log_specs(&block)
if Bundler.ui.debug?
- Bundler.ui.debug debug_msg
+ Bundler.ui.debug yield
else
Bundler.ui.info ".", false
end
diff --git a/lib/bundler/fetcher/compact_index.rb b/lib/bundler/fetcher/compact_index.rb
index 674d2b49f1..db914839b1 100644
--- a/lib/bundler/fetcher/compact_index.rb
+++ b/lib/bundler/fetcher/compact_index.rb
@@ -13,9 +13,9 @@ module Bundler
undef_method(method_name)
define_method(method_name) do |*args, &blk|
method.bind(self).call(*args, &blk)
- rescue NetworkDownError, CompactIndexClient::Updater::MisMatchedChecksumError => e
+ rescue NetworkDownError, CompactIndexClient::Updater::MismatchedChecksumError => e
raise HTTPError, e.message
- rescue AuthenticationRequiredError
+ rescue AuthenticationRequiredError, BadAuthenticationError
# Fail since we got a 401 from the server.
raise
rescue HTTPError => e
@@ -35,7 +35,7 @@ module Bundler
remaining_gems = gem_names.dup
until remaining_gems.empty?
- log_specs "Looking up gems #{remaining_gems.inspect}"
+ log_specs { "Looking up gems #{remaining_gems.inspect}" }
deps = begin
parallel_compact_index_client.dependencies(remaining_gems)
@@ -44,7 +44,7 @@ module Bundler
@bundle_worker = nil # reset it. Not sure if necessary
serial_compact_index_client.dependencies(remaining_gems)
end
- next_gems = deps.map {|d| d[3].map(&:first).flatten(1) }.flatten(1).uniq
+ next_gems = deps.flat_map {|d| d[3].flat_map(&:first) }.uniq
deps.each {|dep| gem_info << dep }
complete_gems.concat(deps.map(&:first)).uniq!
remaining_gems = next_gems - complete_gems
@@ -60,13 +60,9 @@ module Bundler
Bundler.ui.debug("FIPS mode is enabled, bundler can't use the CompactIndex API")
return nil
end
- if fetch_uri.scheme == "file"
- Bundler.ui.debug("Using a local server, bundler won't use the CompactIndex API")
- return false
- end
# Read info file checksums out of /versions, so we can know if gems are up to date
compact_index_client.update_and_parse_checksums!
- rescue CompactIndexClient::Updater::MisMatchedChecksumError => e
+ rescue CompactIndexClient::Updater::MismatchedChecksumError => e
Bundler.ui.debug(e.message)
nil
end
@@ -125,7 +121,7 @@ module Bundler
rescue NetworkDownError => e
raise unless Bundler.feature_flag.allow_offline_install? && headers["If-None-Match"]
ui.warn "Using the cached data for the new index because of a network error: #{e}"
- Net::HTTPNotModified.new(nil, nil, nil)
+ Gem::Net::HTTPNotModified.new(nil, nil, nil)
end
end
end
diff --git a/lib/bundler/fetcher/dependency.rb b/lib/bundler/fetcher/dependency.rb
index 332f86139d..0b807c9a4b 100644
--- a/lib/bundler/fetcher/dependency.rb
+++ b/lib/bundler/fetcher/dependency.rb
@@ -24,7 +24,7 @@ module Bundler
def specs(gem_names, full_dependency_list = [], last_spec_list = [])
query_list = gem_names.uniq - full_dependency_list
- log_specs "Query List: #{query_list.inspect}"
+ log_specs { "Query List: #{query_list.inspect}" }
return last_spec_list if query_list.empty?
@@ -34,14 +34,10 @@ module Bundler
returned_gems = spec_list.map(&:first).uniq
specs(deps_list, full_dependency_list + returned_gems, spec_list + last_spec_list)
- rescue MarshalError
+ rescue MarshalError, HTTPError, GemspecError
Bundler.ui.info "" unless Bundler.ui.debug? # new line now that the dots are over
Bundler.ui.debug "could not fetch from the dependency API, trying the full index"
nil
- rescue HTTPError, GemspecError
- Bundler.ui.info "" unless Bundler.ui.debug? # new line now that the dots are over
- Bundler.ui.debug "could not fetch from the dependency API\nit's suggested to retry using the full index via `bundle install --full-index`"
- nil
end
def dependency_specs(gem_names)
diff --git a/lib/bundler/fetcher/downloader.rb b/lib/bundler/fetcher/downloader.rb
index 28d33f1aed..868b39b959 100644
--- a/lib/bundler/fetcher/downloader.rb
+++ b/lib/bundler/fetcher/downloader.rb
@@ -20,31 +20,35 @@ module Bundler
Bundler.ui.debug("HTTP #{response.code} #{response.message} #{filtered_uri}")
case response
- when Net::HTTPSuccess, Net::HTTPNotModified
+ when Gem::Net::HTTPSuccess, Gem::Net::HTTPNotModified
response
- when Net::HTTPRedirection
- new_uri = Bundler::URI.parse(response["location"])
+ when Gem::Net::HTTPRedirection
+ new_uri = Gem::URI.parse(response["location"])
if new_uri.host == uri.host
new_uri.user = uri.user
new_uri.password = uri.password
end
fetch(new_uri, headers, counter + 1)
- when Net::HTTPRequestedRangeNotSatisfiable
+ when Gem::Net::HTTPRequestedRangeNotSatisfiable
new_headers = headers.dup
new_headers.delete("Range")
new_headers["Accept-Encoding"] = "gzip"
fetch(uri, new_headers)
- when Net::HTTPRequestEntityTooLarge
+ when Gem::Net::HTTPRequestEntityTooLarge
raise FallbackError, response.body
- when Net::HTTPTooManyRequests
+ when Gem::Net::HTTPTooManyRequests
raise TooManyRequestsError, response.body
- when Net::HTTPUnauthorized
+ when Gem::Net::HTTPUnauthorized
raise BadAuthenticationError, uri.host if uri.userinfo
raise AuthenticationRequiredError, uri.host
- when Net::HTTPNotFound
- raise FallbackError, "Net::HTTPNotFound: #{filtered_uri}"
+ when Gem::Net::HTTPForbidden
+ raise AuthenticationForbiddenError, uri.host
+ when Gem::Net::HTTPNotFound
+ raise FallbackError, "Gem::Net::HTTPNotFound: #{filtered_uri}"
else
- raise HTTPError, "#{response.class}#{": #{response.body}" unless response.body.empty?}"
+ message = "Gem::#{response.class.name.gsub(/\AGem::/, "")}"
+ message += ": #{response.body}" unless response.body.empty?
+ raise HTTPError, message
end
end
@@ -54,7 +58,7 @@ module Bundler
filtered_uri = URICredentialsFilter.credential_filtered_uri(uri)
Bundler.ui.debug "HTTP GET #{filtered_uri}"
- req = Net::HTTP::Get.new uri.request_uri, headers
+ req = Gem::Net::HTTP::Get.new uri.request_uri, headers
if uri.user
user = CGI.unescape(uri.user)
password = uri.password ? CGI.unescape(uri.password) : nil
diff --git a/lib/bundler/fetcher/gem_remote_fetcher.rb b/lib/bundler/fetcher/gem_remote_fetcher.rb
new file mode 100644
index 0000000000..3fc7b68263
--- /dev/null
+++ b/lib/bundler/fetcher/gem_remote_fetcher.rb
@@ -0,0 +1,16 @@
+# frozen_string_literal: true
+
+require "rubygems/remote_fetcher"
+
+module Bundler
+ class Fetcher
+ class GemRemoteFetcher < Gem::RemoteFetcher
+ def request(*args)
+ super do |req|
+ req.delete("User-Agent") if headers["User-Agent"]
+ yield req if block_given?
+ end
+ end
+ end
+ end
+end
diff --git a/lib/bundler/fetcher/index.rb b/lib/bundler/fetcher/index.rb
index 6bb9fcc193..6e37e1e5d1 100644
--- a/lib/bundler/fetcher/index.rb
+++ b/lib/bundler/fetcher/index.rb
@@ -6,7 +6,7 @@ module Bundler
class Fetcher
class Index < Base
def specs(_gem_names)
- Bundler.rubygems.fetch_all_remote_specs(remote)
+ Bundler.rubygems.fetch_all_remote_specs(remote, gem_remote_fetcher)
rescue Gem::RemoteFetcher::FetchError => e
case e.message
when /certificate verify failed/
@@ -15,8 +15,7 @@ module Bundler
raise BadAuthenticationError, remote_uri if remote_uri.userinfo
raise AuthenticationRequiredError, remote_uri
when /403/
- raise BadAuthenticationError, remote_uri if remote_uri.userinfo
- raise AuthenticationRequiredError, remote_uri
+ raise AuthenticationForbiddenError, remote_uri
else
raise HTTPError, "Could not fetch specs from #{display_uri} due to underlying error <#{e.message}>"
end
diff --git a/lib/bundler/friendly_errors.rb b/lib/bundler/friendly_errors.rb
index 39afe8a071..e61ed64450 100644
--- a/lib/bundler/friendly_errors.rb
+++ b/lib/bundler/friendly_errors.rb
@@ -32,7 +32,7 @@ module Bundler
if Bundler.ui.debug?
Bundler.ui.trace error
else
- Bundler.ui.error error.message, :wrap => true
+ Bundler.ui.error error.message, wrap: true
end
when Thor::Error
Bundler.ui.error error.message
@@ -40,7 +40,7 @@ module Bundler
Bundler.ui.error "\nQuitting..."
Bundler.ui.trace error
when Gem::InvalidSpecificationException
- Bundler.ui.error error.message, :wrap => true
+ Bundler.ui.error error.message, wrap: true
when SystemExit
when *[defined?(Java::JavaLang::OutOfMemoryError) && Java::JavaLang::OutOfMemoryError].compact
Bundler.ui.error "\nYour JVM has run out of memory, and Bundler cannot continue. " \
@@ -61,7 +61,7 @@ module Bundler
end
def request_issue_report_for(e)
- Bundler.ui.error <<-EOS.gsub(/^ {8}/, ""), nil, nil
+ Bundler.ui.error <<~EOS, nil, nil
--- ERROR REPORT TEMPLATE -------------------------------------------------------
```
@@ -75,7 +75,7 @@ module Bundler
Bundler.ui.error "Unfortunately, an unexpected error occurred, and Bundler cannot continue."
- Bundler.ui.error <<-EOS.gsub(/^ {8}/, ""), nil, :yellow
+ Bundler.ui.error <<~EOS, nil, :yellow
First, try this link to see if there are any existing issue reports for this error:
#{issues_url(e)}
@@ -93,7 +93,7 @@ module Bundler
end
def serialized_exception_for(e)
- <<-EOS.gsub(/^ {8}/, "")
+ <<~EOS
#{e.class}: #{e.message}
#{e.backtrace&.join("\n ")&.chomp}
EOS
diff --git a/lib/bundler/gem_helper.rb b/lib/bundler/gem_helper.rb
index dcf759cded..d535d54f9b 100644
--- a/lib/bundler/gem_helper.rb
+++ b/lib/bundler/gem_helper.rb
@@ -215,7 +215,7 @@ module Bundler
def sh_with_status(cmd, &block)
Bundler.ui.debug(cmd)
SharedHelpers.chdir(base) do
- outbuf = IO.popen(cmd, :err => [:child, :out], &:read)
+ outbuf = IO.popen(cmd, err: [:child, :out], &:read)
status = $?
block&.call(outbuf) if status.success?
[outbuf, status]
diff --git a/lib/bundler/gem_helpers.rb b/lib/bundler/gem_helpers.rb
index 2e6d788f9c..de007523ec 100644
--- a/lib/bundler/gem_helpers.rb
+++ b/lib/bundler/gem_helpers.rb
@@ -34,6 +34,11 @@ module Bundler
end
module_function :local_platform
+ def generic_local_platform_is_ruby?
+ generic_local_platform == Gem::Platform::RUBY
+ end
+ module_function :generic_local_platform_is_ruby?
+
def platform_specificity_match(spec_platform, user_platform)
spec_platform = Gem::Platform.new(spec_platform)
@@ -48,6 +53,13 @@ module Bundler
end
module_function :select_best_platform_match
+ def force_ruby_platform(specs)
+ matching = specs.select {|spec| spec.match_platform(Gem::Platform::RUBY) && spec.force_ruby_platform! }
+
+ sort_best_platform_match(matching, Gem::Platform::RUBY)
+ end
+ module_function :force_ruby_platform
+
def sort_best_platform_match(matching, platform)
exact = matching.select {|spec| spec.platform == platform }
return exact if exact.any?
@@ -107,8 +119,6 @@ module Bundler
def same_deps(spec, exemplary_spec)
same_runtime_deps = spec.dependencies.sort == exemplary_spec.dependencies.sort
- return same_runtime_deps unless spec.is_a?(Gem::Specification) && exemplary_spec.is_a?(Gem::Specification)
-
same_metadata_deps = spec.required_ruby_version == exemplary_spec.required_ruby_version && spec.required_rubygems_version == exemplary_spec.required_rubygems_version
same_runtime_deps && same_metadata_deps
end
diff --git a/lib/bundler/gem_version_promoter.rb b/lib/bundler/gem_version_promoter.rb
index f08fceb7e2..ecc65b4956 100644
--- a/lib/bundler/gem_version_promoter.rb
+++ b/lib/bundler/gem_version_promoter.rb
@@ -45,17 +45,37 @@ module Bundler
# Given a Resolver::Package and an Array of Specifications of available
# versions for a gem, this method will return the Array of Specifications
- # sorted (and possibly truncated if strict is true) in an order to give
- # preference to the current level (:major, :minor or :patch) when resolution
- # is deciding what versions best resolve all dependencies in the bundle.
+ # sorted in an order to give preference to the current level (:major, :minor
+ # or :patch) when resolution is deciding what versions best resolve all
+ # dependencies in the bundle.
# @param package [Resolver::Package] The package being resolved.
# @param specs [Specification] An array of Specifications for the package.
- # @return [Specification] A new instance of the Specification Array sorted and
- # possibly filtered.
+ # @return [Specification] A new instance of the Specification Array sorted.
def sort_versions(package, specs)
- specs = filter_dep_specs(specs, package) if strict
+ locked_version = package.locked_version
+
+ result = specs.sort do |a, b|
+ unless package.prerelease_specified? || pre?
+ a_pre = a.prerelease?
+ b_pre = b.prerelease?
+
+ next 1 if a_pre && !b_pre
+ next -1 if b_pre && !a_pre
+ end
- sort_dep_specs(specs, package)
+ if major? || locked_version.nil?
+ b <=> a
+ elsif either_version_older_than_locked?(a, b, locked_version)
+ b <=> a
+ elsif segments_do_not_match?(a, b, :major)
+ a <=> b
+ elsif !minor? && segments_do_not_match?(a, b, :minor)
+ a <=> b
+ else
+ b <=> a
+ end
+ end
+ post_sort(result, package.unlock?, locked_version)
end
# @return [bool] Convenience method for testing value of level variable.
@@ -73,9 +93,18 @@ module Bundler
pre == true
end
- private
+ # Given a Resolver::Package and an Array of Specifications of available
+ # versions for a gem, this method will truncate the Array if strict
+ # is true. That means filtering out downgrades from the version currently
+ # locked, and filtering out upgrades that go past the selected level (major,
+ # minor, or patch).
+ # @param package [Resolver::Package] The package being resolved.
+ # @param specs [Specification] An array of Specifications for the package.
+ # @return [Specification] A new instance of the Specification Array
+ # truncated.
+ def filter_versions(package, specs)
+ return specs unless strict
- def filter_dep_specs(specs, package)
locked_version = package.locked_version
return specs if locked_version.nil? || major?
@@ -89,35 +118,10 @@ module Bundler
end
end
- def sort_dep_specs(specs, package)
- locked_version = package.locked_version
-
- result = specs.sort do |a, b|
- unless locked_version && (package.prerelease_specified? || pre?)
- a_pre = a.prerelease?
- b_pre = b.prerelease?
-
- next -1 if a_pre && !b_pre
- next 1 if b_pre && !a_pre
- end
-
- if major?
- a <=> b
- elsif either_version_older_than_locked?(a, b, locked_version)
- a <=> b
- elsif segments_do_not_match?(a, b, :major)
- b <=> a
- elsif !minor? && segments_do_not_match?(a, b, :minor)
- b <=> a
- else
- a <=> b
- end
- end
- post_sort(result, package.unlock?, locked_version)
- end
+ private
def either_version_older_than_locked?(a, b, locked_version)
- locked_version && (a.version < locked_version || b.version < locked_version)
+ a.version < locked_version || b.version < locked_version
end
def segments_do_not_match?(a, b, level)
@@ -133,13 +137,13 @@ module Bundler
if unlock || locked_version.nil?
result
else
- move_version_to_end(result, locked_version)
+ move_version_to_beginning(result, locked_version)
end
end
- def move_version_to_end(result, version)
+ def move_version_to_beginning(result, version)
move, keep = result.partition {|s| s.version.to_s == version.to_s }
- keep.concat(move)
+ move.concat(keep)
end
end
end
diff --git a/lib/bundler/graph.rb b/lib/bundler/graph.rb
index 3c008e63e3..b22b17a453 100644
--- a/lib/bundler/graph.rb
+++ b/lib/bundler/graph.rb
@@ -84,7 +84,7 @@ module Bundler
else
raise ArgumentError, "2nd argument is invalid"
end
- label.nil? ? {} : { :label => label }
+ label.nil? ? {} : { label: label }
end
def spec_for_dependency(dependency)
@@ -103,7 +103,7 @@ module Bundler
end
def g
- @g ||= ::GraphViz.digraph(@graph_name, :concentrate => true, :normalize => true, :nodesep => 0.55) do |g|
+ @g ||= ::GraphViz.digraph(@graph_name, concentrate: true, normalize: true, nodesep: 0.55) do |g|
g.edge[:weight] = 2
g.edge[:fontname] = g.node[:fontname] = "Arial, Helvetica, SansSerif"
g.edge[:fontsize] = 12
@@ -114,10 +114,10 @@ module Bundler
@groups.each do |group|
g.add_nodes(
group, {
- :style => "filled",
- :fillcolor => "#B9B9D5",
- :shape => "box3d",
- :fontsize => 16,
+ style: "filled",
+ fillcolor: "#B9B9D5",
+ shape: "box3d",
+ fontsize: 16,
}.merge(@node_options[group])
)
end
@@ -125,8 +125,8 @@ module Bundler
@relations.each do |parent, children|
children.each do |child|
if @groups.include?(parent)
- g.add_nodes(child, { :style => "filled", :fillcolor => "#B9B9D5" }.merge(@node_options[child]))
- g.add_edges(parent, child, { :constraint => false }.merge(@edge_options["#{parent}_#{child}"]))
+ g.add_nodes(child, { style: "filled", fillcolor: "#B9B9D5" }.merge(@node_options[child]))
+ g.add_edges(parent, child, { constraint: false }.merge(@edge_options["#{parent}_#{child}"]))
else
g.add_nodes(child, @node_options[child])
g.add_edges(parent, child, @edge_options["#{parent}_#{child}"])
@@ -135,7 +135,7 @@ module Bundler
end
if @output_format.to_s == "debug"
- $stdout.puts g.output :none => String
+ $stdout.puts g.output none: String
Bundler.ui.info "debugging bundle viz..."
else
begin
diff --git a/lib/bundler/index.rb b/lib/bundler/index.rb
index b8c599f63a..df46facc88 100644
--- a/lib/bundler/index.rb
+++ b/lib/bundler/index.rb
@@ -10,8 +10,8 @@ module Bundler
i
end
- attr_reader :specs, :all_specs, :sources
- protected :specs, :all_specs
+ attr_reader :specs, :duplicates, :sources
+ protected :specs, :duplicates
RUBY = "ruby"
NULL = "\0"
@@ -19,21 +19,21 @@ module Bundler
def initialize
@sources = []
@cache = {}
- @specs = Hash.new {|h, k| h[k] = {} }
- @all_specs = Hash.new {|h, k| h[k] = EMPTY_SEARCH }
+ @specs = {}
+ @duplicates = {}
end
def initialize_copy(o)
@sources = o.sources.dup
@cache = {}
- @specs = Hash.new {|h, k| h[k] = {} }
- @all_specs = Hash.new {|h, k| h[k] = EMPTY_SEARCH }
+ @specs = {}
+ @duplicates = {}
o.specs.each do |name, hash|
@specs[name] = hash.dup
end
- o.all_specs.each do |name, array|
- @all_specs[name] = array.dup
+ o.duplicates.each do |name, array|
+ @duplicates[name] = array.dup
end
end
@@ -46,12 +46,11 @@ module Bundler
true
end
- def search_all(name)
- all_matches = local_search(name) + @all_specs[name]
- @sources.each do |source|
- all_matches.concat(source.search_all(name))
- end
- all_matches
+ def search_all(name, &blk)
+ return enum_for(:search_all, name) unless blk
+ specs_by_name(name).each(&blk)
+ @duplicates[name]&.each(&blk)
+ @sources.each {|source| source.search_all(name, &blk) }
end
# Search this index's specs, and any source indexes that this index knows
@@ -61,11 +60,14 @@ module Bundler
return results unless @sources.any?
@sources.each do |source|
- results.concat(source.search(query))
+ results = safe_concat(results, source.search(query))
end
- results.uniq(&:full_name)
+ results.uniq!(&:full_name) unless results.empty? # avoid modifying frozen EMPTY_SEARCH
+ results
end
+ alias_method :[], :search
+
def local_search(query)
case query
when Gem::Specification, RemoteSpecification, LazySpecification, EndpointSpecification then search_by_spec(query)
@@ -76,12 +78,10 @@ module Bundler
end
end
- alias_method :[], :search
-
- def <<(spec)
- @specs[spec.name][spec.full_name] = spec
- spec
+ def add(spec)
+ (@specs[spec.name] ||= {}).store(spec.full_name, spec)
end
+ alias_method :<<, :add
def each(&blk)
return enum_for(:each) unless blk
@@ -115,15 +115,25 @@ module Bundler
names.uniq
end
- def use(other, override_dupes = false)
+ # Combines indexes proritizing existing specs, like `Hash#reverse_merge!`
+ # Duplicate specs found in `other` are stored in `@duplicates`.
+ def use(other)
return unless other
- other.each do |s|
- if (dupes = search_by_spec(s)) && !dupes.empty?
- # safe to << since it's a new array when it has contents
- @all_specs[s.name] = dupes << s
- next unless override_dupes
+ other.each do |spec|
+ exist?(spec) ? add_duplicate(spec) : add(spec)
+ end
+ self
+ end
+
+ # Combines indexes proritizing specs from `other`, like `Hash#merge!`
+ # Duplicate specs found in `self` are saved in `@duplicates`.
+ def merge!(other)
+ return unless other
+ other.each do |spec|
+ if existing = find_by_spec(spec)
+ add_duplicate(existing)
end
- self << s
+ add spec
end
self
end
@@ -135,8 +145,7 @@ module Bundler
end
# Whether all the specs in self are in other
- # TODO: rename to #include?
- def ==(other)
+ def subset?(other)
all? do |spec|
other_spec = other[spec].first
other_spec && dependencies_eql?(spec, other_spec) && spec.source == other_spec.source
@@ -157,19 +166,40 @@ module Bundler
private
+ def safe_concat(a, b)
+ return a if b.empty?
+ return b if a.empty?
+ a.concat(b)
+ end
+
+ def add_duplicate(spec)
+ (@duplicates[spec.name] ||= []) << spec
+ end
+
def specs_by_name_and_version(name, version)
- specs_by_name(name).select {|spec| spec.version == version }
+ results = @specs[name]&.values
+ return EMPTY_SEARCH unless results
+ results.select! {|spec| spec.version == version }
+ results
end
def specs_by_name(name)
- @specs[name].values
+ @specs[name]&.values || EMPTY_SEARCH
end
EMPTY_SEARCH = [].freeze
def search_by_spec(spec)
- spec = @specs[spec.name][spec.full_name]
+ spec = find_by_spec(spec)
spec ? [spec] : EMPTY_SEARCH
end
+
+ def find_by_spec(spec)
+ @specs[spec.name]&.fetch(spec.full_name, nil)
+ end
+
+ def exist?(spec)
+ @specs[spec.name]&.key?(spec.full_name)
+ end
end
end
diff --git a/lib/bundler/injector.rb b/lib/bundler/injector.rb
index cb644a7f69..cf561c2ee4 100644
--- a/lib/bundler/injector.rb
+++ b/lib/bundler/injector.rb
@@ -29,7 +29,7 @@ module Bundler
end
# temporarily unfreeze
- Bundler.settings.temporary(:deployment => false, :frozen => false) do
+ Bundler.settings.temporary(deployment: false, frozen: false) do
# evaluate the Gemfile we have now
builder = Dsl.new
builder.eval_gemfile(gemfile_path)
@@ -50,7 +50,7 @@ module Bundler
append_to(gemfile_path, build_gem_lines(@options[:conservative_versioning])) if @deps.any?
# since we resolved successfully, write out the lockfile
- @definition.lock(Bundler.default_lockfile)
+ @definition.lock
# invalidate the cached Bundler.definition
Bundler.reset_paths!
@@ -86,7 +86,7 @@ module Bundler
segments = version.segments
seg_end_index = version >= Gem::Version.new("1.0") ? 1 : 2
- prerelease_suffix = version.to_s.gsub(version.release.to_s, "") if version.prerelease?
+ prerelease_suffix = version.to_s.delete_prefix(version.release.to_s) if version.prerelease?
"#{version_prefix}#{segments[0..seg_end_index].join(".")}#{prerelease_suffix}"
end
diff --git a/lib/bundler/inline.rb b/lib/bundler/inline.rb
index 5c184f67a1..ae4ccf2138 100644
--- a/lib/bundler/inline.rb
+++ b/lib/bundler/inline.rb
@@ -48,14 +48,14 @@ def gemfile(install = false, options = {}, &gemfile)
builder.instance_eval(&gemfile)
builder.check_primary_source_safety
- Bundler.settings.temporary(:deployment => false, :frozen => false) do
+ Bundler.settings.temporary(deployment: false, frozen: false) do
definition = builder.to_definition(nil, true)
def definition.lock(*); end
definition.validate_runtime!
if install || definition.missing_specs?
- Bundler.settings.temporary(:inline => true, :no_install => false) do
- installer = Bundler::Installer.install(Bundler.root, definition, :system => true)
+ Bundler.settings.temporary(inline: true, no_install: false) do
+ installer = Bundler::Installer.install(Bundler.root, definition, system: true)
installer.post_install_messages.each do |name, message|
Bundler.ui.info "Post-install message from #{name}:\n#{message}"
end
diff --git a/lib/bundler/installer.rb b/lib/bundler/installer.rb
index 680e812ac8..018324f840 100644
--- a/lib/bundler/installer.rb
+++ b/lib/bundler/installer.rb
@@ -90,7 +90,7 @@ module Bundler
Gem::Specification.reset # invalidate gem specification cache so that installed gems are immediately available
- lock unless Bundler.frozen_bundle?
+ lock
Standalone.new(options[:standalone], @definition).generate if options[:standalone]
end
end
@@ -136,12 +136,12 @@ module Bundler
mode = Gem.win_platform? ? "wb:UTF-8" : "w"
require "erb"
- content = ERB.new(template, :trim_mode => "-").result(binding)
+ content = ERB.new(template, trim_mode: "-").result(binding)
- File.write(binstub_path, content, :mode => mode, :perm => 0o777 & ~File.umask)
+ File.write(binstub_path, content, mode: mode, perm: 0o777 & ~File.umask)
if Gem.win_platform? || options[:all_platforms]
prefix = "@ruby -x \"%~f0\" %*\n@exit /b %ERRORLEVEL%\n\n"
- File.write("#{binstub_path}.cmd", prefix + content, :mode => mode)
+ File.write("#{binstub_path}.cmd", prefix + content, mode: mode)
end
end
@@ -179,12 +179,12 @@ module Bundler
mode = Gem.win_platform? ? "wb:UTF-8" : "w"
require "erb"
- content = ERB.new(template, :trim_mode => "-").result(binding)
+ content = ERB.new(template, trim_mode: "-").result(binding)
- File.write("#{bin_path}/#{executable}", content, :mode => mode, :perm => 0o755)
+ File.write("#{bin_path}/#{executable}", content, mode: mode, perm: 0o755)
if Gem.win_platform? || options[:all_platforms]
prefix = "@ruby -x \"%~f0\" %*\n@exit /b %ERRORLEVEL%\n\n"
- File.write("#{bin_path}/#{executable}.cmd", prefix + content, :mode => mode)
+ File.write("#{bin_path}/#{executable}.cmd", prefix + content, mode: mode)
end
end
end
@@ -214,7 +214,7 @@ module Bundler
end
def load_plugins
- Bundler.rubygems.load_plugins
+ Gem.load_plugins
requested_path_gems = @definition.requested_specs.select {|s| s.source.is_a?(Source::Path) }
path_plugin_files = requested_path_gems.map do |spec|
@@ -223,8 +223,8 @@ module Bundler
error_message = "#{spec.name} #{spec.version} has an invalid gemspec"
raise Gem::InvalidSpecificationException, error_message
end.flatten
- Bundler.rubygems.load_plugin_files(path_plugin_files)
- Bundler.rubygems.load_env_plugins
+ Gem.load_plugin_files(path_plugin_files)
+ Gem.load_env_plugins
end
def ensure_specs_are_compatible!
@@ -260,8 +260,8 @@ module Bundler
true
end
- def lock(opts = {})
- @definition.lock(Bundler.default_lockfile, opts[:preserve_unknown_sections])
+ def lock
+ @definition.lock
end
end
end
diff --git a/lib/bundler/installer/gem_installer.rb b/lib/bundler/installer/gem_installer.rb
index 9a013eea4d..d3bbcc90f5 100644
--- a/lib/bundler/installer/gem_installer.rb
+++ b/lib/bundler/installer/gem_installer.rb
@@ -16,13 +16,13 @@ module Bundler
post_install_message = install
Bundler.ui.debug "#{worker}: #{spec.name} (#{spec.version}) from #{spec.loaded_from}"
generate_executable_stubs
- return true, post_install_message
- rescue Bundler::InstallHookError, Bundler::SecurityError, Bundler::APIResponseMismatchError
+ [true, post_install_message]
+ rescue Bundler::InstallHookError, Bundler::SecurityError, Bundler::APIResponseMismatchError, Bundler::InsecureInstallPathError
raise
rescue Errno::ENOSPC
- return false, out_of_space_message
- rescue Bundler::BundlerError, Gem::InstallError, Bundler::APIResponseInvalidDependenciesError => e
- return false, specific_failure_message(e)
+ [false, out_of_space_message]
+ rescue Bundler::BundlerError, Gem::InstallError => e
+ [false, specific_failure_message(e)]
end
private
@@ -53,10 +53,10 @@ module Bundler
def install
spec.source.install(
spec,
- :force => force,
- :ensure_builtin_gems_cached => standalone,
- :build_args => Array(spec_settings),
- :previous_spec => previous_spec,
+ force: force,
+ ensure_builtin_gems_cached: standalone,
+ build_args: Array(spec_settings),
+ previous_spec: previous_spec,
)
end
@@ -77,7 +77,7 @@ module Bundler
if Bundler.settings[:bin] && standalone
installer.generate_standalone_bundler_executable_stubs(spec)
elsif Bundler.settings[:bin]
- installer.generate_bundler_executable_stubs(spec, :force => true)
+ installer.generate_bundler_executable_stubs(spec, force: true)
end
end
end
diff --git a/lib/bundler/installer/parallel_installer.rb b/lib/bundler/installer/parallel_installer.rb
index 0bbc0f256e..e745088f81 100644
--- a/lib/bundler/installer/parallel_installer.rb
+++ b/lib/bundler/installer/parallel_installer.rb
@@ -42,8 +42,7 @@ module Bundler
# Checks installed dependencies against spec's dependencies to make
# sure needed dependencies have been installed.
- def dependencies_installed?(all_specs)
- installed_specs = all_specs.select(&:installed?).map(&:name)
+ def dependencies_installed?(installed_specs)
dependencies.all? {|d| installed_specs.include? d.name }
end
@@ -63,20 +62,23 @@ module Bundler
end
end
- def self.call(*args)
- new(*args).call
+ def self.call(*args, **kwargs)
+ new(*args, **kwargs).call
end
attr_reader :size
- def initialize(installer, all_specs, size, standalone, force)
+ def initialize(installer, all_specs, size, standalone, force, skip: nil)
@installer = installer
@size = size
@standalone = standalone
@force = force
@specs = all_specs.map {|s| SpecInstallation.new(s) }
+ @specs.each do |spec_install|
+ spec_install.state = :installed if skip.include?(spec_install.name)
+ end if skip
@spec_set = all_specs
- @rake = @specs.find {|s| s.name == "rake" }
+ @rake = @specs.find {|s| s.name == "rake" unless s.installed? }
end
def call
@@ -91,37 +93,12 @@ module Bundler
install_serially
end
- check_for_unmet_dependencies
-
handle_error if failed_specs.any?
@specs
ensure
worker_pool&.stop
end
- def check_for_unmet_dependencies
- unmet_dependencies = @specs.map do |s|
- [
- s,
- s.dependencies.reject {|dep| @specs.any? {|spec| dep.matches_spec?(spec.spec) } },
- ]
- end.reject {|a| a.last.empty? }
- return if unmet_dependencies.empty?
-
- warning = []
- warning << "Your lockfile doesn't include a valid resolution."
- warning << "You can fix this by regenerating your lockfile or trying to manually editing the bad locked gems to a version that satisfies all dependencies."
- warning << "The unmet dependencies are:"
-
- unmet_dependencies.each do |spec, unmet_spec_dependencies|
- unmet_spec_dependencies.each do |unmet_spec_dependency|
- warning << "* #{unmet_spec_dependency}, depended upon #{spec.full_name}, unsatisfied by #{@specs.find {|s| s.name == unmet_spec_dependency.name && !unmet_spec_dependency.matches_spec?(s.spec) }.full_name}"
- end
- end
-
- Bundler.ui.warn(warning.join("\n"))
- end
-
private
def failed_specs
@@ -208,8 +185,14 @@ module Bundler
# previously installed specifications. We continue until all specs
# are installed.
def enqueue_specs
- @specs.select(&:ready_to_enqueue?).each do |spec|
- if spec.dependencies_installed? @specs
+ installed_specs = {}
+ @specs.each do |spec|
+ next unless spec.installed?
+ installed_specs[spec.name] = true
+ end
+
+ @specs.each do |spec|
+ if spec.ready_to_enqueue? && spec.dependencies_installed?(installed_specs)
spec.state = :enqueued
worker_pool.enq spec
end
diff --git a/lib/bundler/installer/standalone.rb b/lib/bundler/installer/standalone.rb
index 2756626f8a..5331df2e95 100644
--- a/lib/bundler/installer/standalone.rb
+++ b/lib/bundler/installer/standalone.rb
@@ -12,6 +12,7 @@ module Bundler
end
File.open File.join(bundler_path, "setup.rb"), "w" do |file|
file.puts "require 'rbconfig'"
+ file.puts prevent_gem_activation
file.puts define_path_helpers
file.puts reverse_rubygems_kernel_mixin
paths.each do |path|
@@ -52,16 +53,29 @@ module Bundler
def gem_path(path, spec)
full_path = Pathname.new(path).absolute? ? path : File.join(spec.full_gem_path, path)
- if spec.source.instance_of?(Source::Path)
+ if spec.source.instance_of?(Source::Path) && spec.source.path.absolute?
full_path
else
- Pathname.new(full_path).relative_path_from(Bundler.root.join(bundler_path)).to_s
+ SharedHelpers.relative_path_to(full_path, from: Bundler.root.join(bundler_path))
end
rescue TypeError
error_message = "#{spec.name} #{spec.version} has an invalid gemspec"
raise Gem::InvalidSpecificationException.new(error_message)
end
+ def prevent_gem_activation
+ <<~'END'
+ module Kernel
+ remove_method(:gem) if private_method_defined?(:gem)
+
+ def gem(*)
+ end
+
+ private :gem
+ end
+ END
+ end
+
def define_path_helpers
<<~'END'
unless defined?(Gem)
@@ -84,13 +98,16 @@ module Bundler
def reverse_rubygems_kernel_mixin
<<~END
- kernel = (class << ::Kernel; self; end)
- [kernel, ::Kernel].each do |k|
- if k.private_method_defined?(:gem_original_require)
- private_require = k.private_method_defined?(:require)
- k.send(:remove_method, :require)
- k.send(:define_method, :require, k.instance_method(:gem_original_require))
- k.send(:private, :require) if private_require
+ if Gem.respond_to?(:discover_gems_on_require=)
+ Gem.discover_gems_on_require = false
+ else
+ [::Kernel.singleton_class, ::Kernel].each do |k|
+ if k.private_method_defined?(:gem_original_require)
+ private_require = k.private_method_defined?(:require)
+ k.send(:remove_method, :require)
+ k.send(:define_method, :require, k.instance_method(:gem_original_require))
+ k.send(:private, :require) if private_require
+ end
end
end
END
diff --git a/lib/bundler/lazy_specification.rb b/lib/bundler/lazy_specification.rb
index 6749892930..38aea2a4aa 100644
--- a/lib/bundler/lazy_specification.rb
+++ b/lib/bundler/lazy_specification.rb
@@ -7,36 +7,56 @@ module Bundler
include MatchPlatform
include ForcePlatform
- attr_reader :name, :version, :dependencies, :platform
- attr_accessor :source, :remote, :force_ruby_platform
+ attr_reader :name, :version, :platform
+ attr_accessor :source, :remote, :force_ruby_platform, :dependencies, :required_ruby_version, :required_rubygems_version
+
+ alias_method :runtime_dependencies, :dependencies
+
+ def self.from_spec(s)
+ lazy_spec = new(s.name, s.version, s.platform, s.source)
+ lazy_spec.dependencies = s.dependencies
+ lazy_spec.required_ruby_version = s.required_ruby_version
+ lazy_spec.required_rubygems_version = s.required_rubygems_version
+ lazy_spec
+ end
def initialize(name, version, platform, source = nil)
@name = name
@version = version
@dependencies = []
+ @required_ruby_version = Gem::Requirement.default
+ @required_rubygems_version = Gem::Requirement.default
@platform = platform || Gem::Platform::RUBY
@source = source
@force_ruby_platform = default_force_ruby_platform
end
def full_name
- if platform == Gem::Platform::RUBY
+ @full_name ||= if platform == Gem::Platform::RUBY
"#{@name}-#{@version}"
else
"#{@name}-#{@version}-#{platform}"
end
end
+ def lock_name
+ @lock_name ||= name_tuple.lock_name
+ end
+
+ def name_tuple
+ Gem::NameTuple.new(@name, @version, @platform)
+ end
+
def ==(other)
- identifier == other.identifier
+ full_name == other.full_name
end
def eql?(other)
- identifier.eql?(other.identifier)
+ full_name.eql?(other.full_name)
end
def hash
- identifier.hash
+ full_name.hash
end
##
@@ -61,12 +81,7 @@ module Bundler
def to_lock
out = String.new
-
- if platform == Gem::Platform::RUBY
- out << " #{name} (#{version})\n"
- else
- out << " #{name} (#{version}-#{platform})\n"
- end
+ out << " #{lock_name}\n"
dependencies.sort_by(&:to_s).uniq.each do |dep|
next if dep.type == :development
@@ -89,7 +104,7 @@ module Bundler
installable_candidates = GemHelpers.select_best_platform_match(matching_specs, target_platform)
- specification = __materialize__(installable_candidates, :fallback_to_non_installable => false)
+ specification = __materialize__(installable_candidates, fallback_to_non_installable: false)
return specification unless specification.nil?
if target_platform != platform
@@ -109,9 +124,7 @@ module Bundler
# bad gem.
def __materialize__(candidates, fallback_to_non_installable: Bundler.frozen_bundle?)
search = candidates.reverse.find do |spec|
- spec.is_a?(StubSpecification) ||
- (spec.matches_current_ruby? &&
- spec.matches_current_rubygems?)
+ spec.is_a?(StubSpecification) || spec.matches_current_metadata?
end
if search.nil? && fallback_to_non_installable
search = candidates.last
@@ -122,15 +135,7 @@ module Bundler
end
def to_s
- @__to_s ||= if platform == Gem::Platform::RUBY
- "#{name} (#{version})"
- else
- "#{name} (#{version}-#{platform})"
- end
- end
-
- def identifier
- @__identifier ||= [name, version, platform.to_s]
+ lock_name
end
def git_version
@@ -138,6 +143,10 @@ module Bundler
" #{source.revision[0..6]}"
end
+ def force_ruby_platform!
+ @force_ruby_platform = true
+ end
+
private
def use_exact_resolved_specifications?
diff --git a/lib/bundler/lockfile_generator.rb b/lib/bundler/lockfile_generator.rb
index a7ee026f67..a646d00ee1 100644
--- a/lib/bundler/lockfile_generator.rb
+++ b/lib/bundler/lockfile_generator.rb
@@ -19,6 +19,7 @@ module Bundler
add_sources
add_platforms
add_dependencies
+ add_checksums
add_locked_ruby_version
add_bundled_with
@@ -65,13 +66,21 @@ module Bundler
end
end
+ def add_checksums
+ return unless definition.locked_checksums
+ checksums = definition.resolve.map do |spec|
+ spec.source.checksum_store.to_lock(spec)
+ end
+ add_section("CHECKSUMS", checksums)
+ end
+
def add_locked_ruby_version
return unless locked_ruby_version = definition.locked_ruby_version
add_section("RUBY VERSION", locked_ruby_version.to_s)
end
def add_bundled_with
- add_section("BUNDLED WITH", Bundler::VERSION)
+ add_section("BUNDLED WITH", definition.bundler_version_to_lock.to_s)
end
def add_section(name, value)
diff --git a/lib/bundler/lockfile_parser.rb b/lib/bundler/lockfile_parser.rb
index 237749c525..1e11621e55 100644
--- a/lib/bundler/lockfile_parser.rb
+++ b/lib/bundler/lockfile_parser.rb
@@ -2,10 +2,41 @@
module Bundler
class LockfileParser
- attr_reader :sources, :dependencies, :specs, :platforms, :bundler_version, :ruby_version
+ class Position
+ attr_reader :line, :column
+ def initialize(line, column)
+ @line = line
+ @column = column
+ end
+
+ def advance!(string)
+ lines = string.count("\n")
+ if lines > 0
+ @line += lines
+ @column = string.length - string.rindex("\n")
+ else
+ @column += string.length
+ end
+ end
+
+ def to_s
+ "#{line}:#{column}"
+ end
+ end
+
+ attr_reader(
+ :sources,
+ :dependencies,
+ :specs,
+ :platforms,
+ :bundler_version,
+ :ruby_version,
+ :checksums,
+ )
BUNDLED = "BUNDLED WITH"
DEPENDENCIES = "DEPENDENCIES"
+ CHECKSUMS = "CHECKSUMS"
PLATFORMS = "PLATFORMS"
RUBY = "RUBY VERSION"
GIT = "GIT"
@@ -13,7 +44,7 @@ module Bundler
PATH = "PATH"
PLUGIN = "PLUGIN SOURCE"
SPECS = " specs:"
- OPTIONS = /^ ([a-z]+): (.*)$/i.freeze
+ OPTIONS = /^ ([a-z]+): (.*)$/i
SOURCE = [GIT, GEM, PATH, PLUGIN].freeze
SECTIONS_BY_VERSION_INTRODUCED = {
@@ -21,14 +52,18 @@ module Bundler
Gem::Version.create("1.10") => [BUNDLED].freeze,
Gem::Version.create("1.12") => [RUBY].freeze,
Gem::Version.create("1.13") => [PLUGIN].freeze,
+ Gem::Version.create("2.5.0") => [CHECKSUMS].freeze,
}.freeze
- KNOWN_SECTIONS = SECTIONS_BY_VERSION_INTRODUCED.values.flatten.freeze
+ KNOWN_SECTIONS = SECTIONS_BY_VERSION_INTRODUCED.values.flatten!.freeze
ENVIRONMENT_VERSION_SECTIONS = [BUNDLED, RUBY].freeze
+ deprecate_constant(:ENVIRONMENT_VERSION_SECTIONS)
def self.sections_in_lockfile(lockfile_contents)
- lockfile_contents.scan(/^\w[\w ]*$/).uniq
+ sections = lockfile_contents.scan(/^\w[\w ]*$/)
+ sections.uniq!
+ sections
end
def self.unknown_sections_in_lockfile(lockfile_contents)
@@ -37,7 +72,7 @@ module Bundler
def self.sections_to_ignore(base_version = nil)
base_version &&= base_version.release
- base_version ||= Gem::Version.create("1.0".dup)
+ base_version ||= Gem::Version.create("1.0")
attributes = []
SECTIONS_BY_VERSION_INTRODUCED.each do |version, introduced|
next if version <= base_version
@@ -60,37 +95,53 @@ module Bundler
@platforms = []
@sources = []
@dependencies = {}
- @state = nil
+ @parse_method = nil
@specs = {}
+ @lockfile_path = begin
+ SharedHelpers.relative_lockfile_path
+ rescue GemfileNotFound
+ "Gemfile.lock"
+ end
+ @pos = Position.new(1, 1)
if lockfile.match?(/<<<<<<<|=======|>>>>>>>|\|\|\|\|\|\|\|/)
- raise LockfileError, "Your #{Bundler.default_lockfile.relative_path_from(SharedHelpers.pwd)} contains merge conflicts.\n" \
- "Run `git checkout HEAD -- #{Bundler.default_lockfile.relative_path_from(SharedHelpers.pwd)}` first to get a clean lock."
+ raise LockfileError, "Your #{@lockfile_path} contains merge conflicts.\n" \
+ "Run `git checkout HEAD -- #{@lockfile_path}` first to get a clean lock."
end
- lockfile.split(/(?:\r?\n)+/).each do |line|
+ lockfile.split(/((?:\r?\n)+)/) do |line|
+ # split alternates between the line and the following whitespace
+ next @pos.advance!(line) if line.match?(/^\s*$/)
+
if SOURCE.include?(line)
- @state = :source
+ @parse_method = :parse_source
parse_source(line)
elsif line == DEPENDENCIES
- @state = :dependency
+ @parse_method = :parse_dependency
+ elsif line == CHECKSUMS
+ # This is a temporary solution to make this feature disabled by default
+ # for all gemfiles that don't already explicitly include the feature.
+ @checksums = true
+ @parse_method = :parse_checksum
elsif line == PLATFORMS
- @state = :platform
+ @parse_method = :parse_platform
elsif line == RUBY
- @state = :ruby
+ @parse_method = :parse_ruby
elsif line == BUNDLED
- @state = :bundled_with
+ @parse_method = :parse_bundled_with
elsif /^[^\s]/.match?(line)
- @state = nil
- elsif @state
- send("parse_#{@state}", line)
+ @parse_method = nil
+ elsif @parse_method
+ send(@parse_method, line)
end
+ @pos.advance!(line)
end
- @specs = @specs.values.sort_by(&:identifier)
+ @specs = @specs.values.sort_by!(&:full_name)
rescue ArgumentError => e
Bundler.ui.debug(e)
- raise LockfileError, "Your lockfile is unreadable. Run `rm #{Bundler.default_lockfile.relative_path_from(SharedHelpers.pwd)}` " \
- "and then `bundle install` to generate a new lockfile."
+ raise LockfileError, "Your lockfile is unreadable. Run `rm #{@lockfile_path}` " \
+ "and then `bundle install` to generate a new lockfile. The error occurred while " \
+ "evaluating #{@lockfile_path}:#{@pos}"
end
def may_include_redundant_platform_specific_gems?
@@ -109,21 +160,9 @@ module Bundler
def parse_source(line)
case line
when SPECS
- case @type
- when PATH
- @current_source = TYPES[@type].from_lock(@opts)
- @sources << @current_source
- when GIT
- @current_source = TYPES[@type].from_lock(@opts)
- @sources << @current_source
- when GEM
- @opts["remotes"] = Array(@opts.delete("remote")).reverse
- @current_source = TYPES[@type].from_lock(@opts)
- @sources << @current_source
- when PLUGIN
- @current_source = Plugin.source_from_lock(@opts)
- @sources << @current_source
- end
+ return unless TYPES.key?(@type)
+ @current_source = TYPES[@type].from_lock(@opts)
+ @sources << @current_source
when OPTIONS
value = $2
value = true if value == "true"
@@ -153,18 +192,19 @@ module Bundler
(?:#{space}\(([^-]*) # Space, followed by version
(?:-(.*))?\))? # Optional platform
(!)? # Optional pinned marker
+ (?:#{space}([^ ]+))? # Optional checksum
$ # Line end
- /xo.freeze
+ /xo
def parse_dependency(line)
return unless line =~ NAME_VERSION
spaces = $1
return unless spaces.size == 2
- name = $2
+ name = -$2
version = $3
pinned = $5
- version = version.split(",").map(&:strip) if version
+ version = version.split(",").each(&:strip!) if version
dep = Bundler::Dependency.new(name, version)
@@ -185,23 +225,47 @@ module Bundler
@dependencies[dep.name] = dep
end
- def parse_spec(line)
+ def parse_checksum(line)
return unless line =~ NAME_VERSION
+
spaces = $1
+ return unless spaces.size == 2
+ checksums = $6
+ return unless checksums
name = $2
version = $3
platform = $4
+ version = Gem::Version.new(version)
+ platform = platform ? Gem::Platform.new(platform) : Gem::Platform::RUBY
+ full_name = Gem::NameTuple.new(name, version, platform).full_name
+ return unless spec = @specs[full_name]
+
+ checksums.split(",") do |lock_checksum|
+ column = line.index(lock_checksum) + 1
+ checksum = Checksum.from_lock(lock_checksum, "#{@lockfile_path}:#{@pos.line}:#{column}")
+ spec.source.checksum_store.register(spec, checksum)
+ end
+ end
+
+ def parse_spec(line)
+ return unless line =~ NAME_VERSION
+ spaces = $1
+ name = -$2
+ version = $3
+
if spaces.size == 4
+ # only load platform for non-dependency (spec) line
+ platform = $4
+
version = Gem::Version.new(version)
platform = platform ? Gem::Platform.new(platform) : Gem::Platform::RUBY
- @current_spec = LazySpecification.new(name, version, platform)
- @current_spec.source = @current_source
+ @current_spec = LazySpecification.new(name, version, platform, @current_source)
@current_source.add_dependency_names(name)
- @specs[@current_spec.identifier] = @current_spec
+ @specs[@current_spec.full_name] = @current_spec
elsif spaces.size == 6
- version = version.split(",").map(&:strip) if version
+ version = version.split(",").each(&:strip!) if version
dep = Gem::Dependency.new(name, version)
@current_spec.dependencies << dep
end
@@ -212,13 +276,14 @@ module Bundler
end
def parse_bundled_with(line)
- line = line.strip
+ line.strip!
return unless Gem::Version.correct?(line)
@bundler_version = Gem::Version.create(line)
end
def parse_ruby(line)
- @ruby_version = line.strip
+ line.strip!
+ @ruby_version = line
end
end
end
diff --git a/lib/bundler/man/bundle-add.1 b/lib/bundler/man/bundle-add.1
index 805bd5450d..a6cbc88f34 100644
--- a/lib/bundler/man/bundle-add.1
+++ b/lib/bundler/man/bundle-add.1
@@ -1,81 +1,58 @@
-.\" generated with Ronn/v0.7.3
-.\" http://github.com/rtomayko/ronn/tree/0.7.3
-.
-.TH "BUNDLE\-ADD" "1" "January 2023" "" ""
-.
+.\" generated with nRonn/v0.11.1
+.\" https://github.com/n-ronn/nronn/tree/0.11.1
+.TH "BUNDLE\-ADD" "1" "March 2024" ""
.SH "NAME"
\fBbundle\-add\fR \- Add gem to the Gemfile and run bundle install
-.
.SH "SYNOPSIS"
\fBbundle add\fR \fIGEM_NAME\fR [\-\-group=GROUP] [\-\-version=VERSION] [\-\-source=SOURCE] [\-\-path=PATH] [\-\-git=GIT] [\-\-github=GITHUB] [\-\-branch=BRANCH] [\-\-ref=REF] [\-\-skip\-install] [\-\-strict] [\-\-optimistic]
-.
.SH "DESCRIPTION"
Adds the named gem to the Gemfile and run \fBbundle install\fR\. \fBbundle install\fR can be avoided by using the flag \fB\-\-skip\-install\fR\.
-.
.P
Example:
-.
.P
bundle add rails
-.
.P
bundle add rails \-\-version "< 3\.0, > 1\.1"
-.
.P
bundle add rails \-\-version "~> 5\.0\.0" \-\-source "https://gems\.example\.com" \-\-group "development"
-.
.P
bundle add rails \-\-skip\-install
-.
.P
bundle add rails \-\-group "development, test"
-.
.SH "OPTIONS"
-.
.TP
\fB\-\-version\fR, \fB\-v\fR
Specify version requirements(s) for the added gem\.
-.
.TP
\fB\-\-group\fR, \fB\-g\fR
Specify the group(s) for the added gem\. Multiple groups should be separated by commas\.
-.
.TP
\fB\-\-source\fR, \fB\-s\fR
Specify the source for the added gem\.
-.
.TP
\fB\-\-require\fR, \fB\-r\fR
Adds require path to gem\. Provide false, or a path as a string\.
-.
.TP
\fB\-\-path\fR
Specify the file system path for the added gem\.
-.
.TP
\fB\-\-git\fR
Specify the git source for the added gem\.
-.
.TP
\fB\-\-github\fR
Specify the github source for the added gem\.
-.
.TP
\fB\-\-branch\fR
Specify the git branch for the added gem\.
-.
.TP
\fB\-\-ref\fR
Specify the git ref for the added gem\.
-.
.TP
\fB\-\-skip\-install\fR
Adds the gem to the Gemfile but does not install it\.
-.
.TP
\fB\-\-optimistic\fR
Adds optimistic declaration of version\.
-.
.TP
\fB\-\-strict\fR
Adds strict declaration of version\.
diff --git a/lib/bundler/man/bundle-binstubs.1 b/lib/bundler/man/bundle-binstubs.1
index f5efe77e10..2b35bc956a 100644
--- a/lib/bundler/man/bundle-binstubs.1
+++ b/lib/bundler/man/bundle-binstubs.1
@@ -1,41 +1,29 @@
-.\" generated with Ronn/v0.7.3
-.\" http://github.com/rtomayko/ronn/tree/0.7.3
-.
-.TH "BUNDLE\-BINSTUBS" "1" "January 2023" "" ""
-.
+.\" generated with nRonn/v0.11.1
+.\" https://github.com/n-ronn/nronn/tree/0.11.1
+.TH "BUNDLE\-BINSTUBS" "1" "March 2024" ""
.SH "NAME"
\fBbundle\-binstubs\fR \- Install the binstubs of the listed gems
-.
.SH "SYNOPSIS"
\fBbundle binstubs\fR \fIGEM_NAME\fR [\-\-force] [\-\-path PATH] [\-\-standalone]
-.
.SH "DESCRIPTION"
Binstubs are scripts that wrap around executables\. Bundler creates a small Ruby file (a binstub) that loads Bundler, runs the command, and puts it into \fBbin/\fR\. Binstubs are a shortcut\-or alternative\- to always using \fBbundle exec\fR\. This gives you a file that can be run directly, and one that will always run the correct gem version used by the application\.
-.
.P
For example, if you run \fBbundle binstubs rspec\-core\fR, Bundler will create the file \fBbin/rspec\fR\. That file will contain enough code to load Bundler, tell it to load the bundled gems, and then run rspec\.
-.
.P
This command generates binstubs for executables in \fBGEM_NAME\fR\. Binstubs are put into \fBbin\fR, or the \fB\-\-path\fR directory if one has been set\. Calling binstubs with [GEM [GEM]] will create binstubs for all given gems\.
-.
.SH "OPTIONS"
-.
.TP
\fB\-\-force\fR
Overwrite existing binstubs if they exist\.
-.
.TP
\fB\-\-path\fR
The location to install the specified binstubs to\. This defaults to \fBbin\fR\.
-.
.TP
\fB\-\-standalone\fR
Makes binstubs that can work without depending on Rubygems or Bundler at runtime\.
-.
.TP
\fB\-\-shebang\fR
-Specify a different shebang executable name than the default (default \'ruby\')
-.
+Specify a different shebang executable name than the default (default 'ruby')
.TP
\fB\-\-all\fR
Create binstubs for all gems in the bundle\.
diff --git a/lib/bundler/man/bundle-cache.1 b/lib/bundler/man/bundle-cache.1
index a17f1a6b06..3b86b995a6 100644
--- a/lib/bundler/man/bundle-cache.1
+++ b/lib/bundler/man/bundle-cache.1
@@ -1,61 +1,40 @@
-.\" generated with Ronn/v0.7.3
-.\" http://github.com/rtomayko/ronn/tree/0.7.3
-.
-.TH "BUNDLE\-CACHE" "1" "January 2023" "" ""
-.
+.\" generated with nRonn/v0.11.1
+.\" https://github.com/n-ronn/nronn/tree/0.11.1
+.TH "BUNDLE\-CACHE" "1" "March 2024" ""
.SH "NAME"
\fBbundle\-cache\fR \- Package your needed \fB\.gem\fR files into your application
-.
.SH "SYNOPSIS"
\fBbundle cache\fR
-.
.P
alias: \fBpackage\fR, \fBpack\fR
-.
.SH "DESCRIPTION"
-Copy all of the \fB\.gem\fR files needed to run the application into the \fBvendor/cache\fR directory\. In the future, when running [bundle install(1)][bundle\-install], use the gems in the cache in preference to the ones on \fBrubygems\.org\fR\.
-.
+Copy all of the \fB\.gem\fR files needed to run the application into the \fBvendor/cache\fR directory\. In the future, when running \fBbundle install(1)\fR \fIbundle\-install\.1\.html\fR, use the gems in the cache in preference to the ones on \fBrubygems\.org\fR\.
.SH "GIT AND PATH GEMS"
The \fBbundle cache\fR command can also package \fB:git\fR and \fB:path\fR dependencies besides \.gem files\. This needs to be explicitly enabled via the \fB\-\-all\fR option\. Once used, the \fB\-\-all\fR option will be remembered\.
-.
.SH "SUPPORT FOR MULTIPLE PLATFORMS"
When using gems that have different packages for different platforms, Bundler supports caching of gems for other platforms where the Gemfile has been resolved (i\.e\. present in the lockfile) in \fBvendor/cache\fR\. This needs to be enabled via the \fB\-\-all\-platforms\fR option\. This setting will be remembered in your local bundler configuration\.
-.
.SH "REMOTE FETCHING"
-By default, if you run \fBbundle install(1)\fR](bundle\-install\.1\.html) after running bundle cache(1) \fIbundle\-cache\.1\.html\fR, bundler will still connect to \fBrubygems\.org\fR to check whether a platform\-specific gem exists for any of the gems in \fBvendor/cache\fR\.
-.
+By default, if you run \fBbundle install(1)\fR \fIbundle\-install\.1\.html\fR after running bundle cache(1) \fIbundle\-cache\.1\.html\fR, bundler will still connect to \fBrubygems\.org\fR to check whether a platform\-specific gem exists for any of the gems in \fBvendor/cache\fR\.
.P
For instance, consider this Gemfile(5):
-.
.IP "" 4
-.
.nf
-
source "https://rubygems\.org"
gem "nokogiri"
-.
.fi
-.
.IP "" 0
-.
.P
If you run \fBbundle cache\fR under C Ruby, bundler will retrieve the version of \fBnokogiri\fR for the \fB"ruby"\fR platform\. If you deploy to JRuby and run \fBbundle install\fR, bundler is forced to check to see whether a \fB"java"\fR platformed \fBnokogiri\fR exists\.
-.
.P
Even though the \fBnokogiri\fR gem for the Ruby platform is \fItechnically\fR acceptable on JRuby, it has a C extension that does not run on JRuby\. As a result, bundler will, by default, still connect to \fBrubygems\.org\fR to check whether it has a version of one of your gems more specific to your platform\.
-.
.P
This problem is also not limited to the \fB"java"\fR platform\. A similar (common) problem can happen when developing on Windows and deploying to Linux, or even when developing on OSX and deploying to Linux\.
-.
.P
If you know for sure that the gems packaged in \fBvendor/cache\fR are appropriate for the platform you are on, you can run \fBbundle install \-\-local\fR to skip checking for more appropriate gems, and use the ones in \fBvendor/cache\fR\.
-.
.P
One way to be sure that you have the right platformed versions of all your gems is to run \fBbundle cache\fR on an identical machine and check in the gems\. For instance, you can run \fBbundle cache\fR on an identical staging box during your staging process, and check in the \fBvendor/cache\fR before deploying to production\.
-.
.P
By default, bundle cache(1) \fIbundle\-cache\.1\.html\fR fetches and also installs the gems to the default location\. To package the dependencies to \fBvendor/cache\fR without installing them to the local install location, you can run \fBbundle cache \-\-no\-install\fR\.
-.
.SH "HISTORY"
In Bundler 2\.1, \fBcache\fR took in the functionalities of \fBpackage\fR and now \fBpackage\fR and \fBpack\fR are aliases of \fBcache\fR\.
diff --git a/lib/bundler/man/bundle-cache.1.ronn b/lib/bundler/man/bundle-cache.1.ronn
index 46906d2b48..8112c2c551 100644
--- a/lib/bundler/man/bundle-cache.1.ronn
+++ b/lib/bundler/man/bundle-cache.1.ronn
@@ -10,7 +10,7 @@ alias: `package`, `pack`
## DESCRIPTION
Copy all of the `.gem` files needed to run the application into the
-`vendor/cache` directory. In the future, when running [bundle install(1)][bundle-install],
+`vendor/cache` directory. In the future, when running [`bundle install(1)`](bundle-install.1.html),
use the gems in the cache in preference to the ones on `rubygems.org`.
## GIT AND PATH GEMS
@@ -29,7 +29,7 @@ bundler configuration.
## REMOTE FETCHING
-By default, if you run `bundle install(1)`](bundle-install.1.html) after running
+By default, if you run [`bundle install(1)`](bundle-install.1.html) after running
[bundle cache(1)](bundle-cache.1.html), bundler will still connect to `rubygems.org`
to check whether a platform-specific gem exists for any of the gems
in `vendor/cache`.
diff --git a/lib/bundler/man/bundle-check.1 b/lib/bundler/man/bundle-check.1
index f1bf0b1821..7f18e26537 100644
--- a/lib/bundler/man/bundle-check.1
+++ b/lib/bundler/man/bundle-check.1
@@ -1,30 +1,21 @@
-.\" generated with Ronn/v0.7.3
-.\" http://github.com/rtomayko/ronn/tree/0.7.3
-.
-.TH "BUNDLE\-CHECK" "1" "January 2023" "" ""
-.
+.\" generated with nRonn/v0.11.1
+.\" https://github.com/n-ronn/nronn/tree/0.11.1
+.TH "BUNDLE\-CHECK" "1" "March 2024" ""
.SH "NAME"
\fBbundle\-check\fR \- Verifies if dependencies are satisfied by installed gems
-.
.SH "SYNOPSIS"
\fBbundle check\fR [\-\-dry\-run] [\-\-gemfile=FILE] [\-\-path=PATH]
-.
.SH "DESCRIPTION"
\fBcheck\fR searches the local machine for each of the gems requested in the Gemfile\. If all gems are found, Bundler prints a success message and exits with a status of 0\.
-.
.P
If not, the first missing gem is listed and Bundler exits status 1\.
-.
.SH "OPTIONS"
-.
.TP
\fB\-\-dry\-run\fR
Locks the [\fBGemfile(5)\fR][Gemfile(5)] before running the command\.
-.
.TP
\fB\-\-gemfile\fR
Use the specified gemfile instead of the [\fBGemfile(5)\fR][Gemfile(5)]\.
-.
.TP
\fB\-\-path\fR
Specify a different path than the system default (\fB$BUNDLE_PATH\fR or \fB$GEM_HOME\fR)\. Bundler will remember this value for future installs on this machine\.
diff --git a/lib/bundler/man/bundle-clean.1 b/lib/bundler/man/bundle-clean.1
index b05a8eb0eb..0180eb38a2 100644
--- a/lib/bundler/man/bundle-clean.1
+++ b/lib/bundler/man/bundle-clean.1
@@ -1,23 +1,16 @@
-.\" generated with Ronn/v0.7.3
-.\" http://github.com/rtomayko/ronn/tree/0.7.3
-.
-.TH "BUNDLE\-CLEAN" "1" "January 2023" "" ""
-.
+.\" generated with nRonn/v0.11.1
+.\" https://github.com/n-ronn/nronn/tree/0.11.1
+.TH "BUNDLE\-CLEAN" "1" "March 2024" ""
.SH "NAME"
\fBbundle\-clean\fR \- Cleans up unused gems in your bundler directory
-.
.SH "SYNOPSIS"
\fBbundle clean\fR [\-\-dry\-run] [\-\-force]
-.
.SH "DESCRIPTION"
This command will remove all unused gems in your bundler directory\. This is useful when you have made many changes to your gem dependencies\.
-.
.SH "OPTIONS"
-.
.TP
\fB\-\-dry\-run\fR
Print the changes, but do not clean the unused gems\.
-.
.TP
\fB\-\-force\fR
Forces cleaning up unused gems even if Bundler is configured to use globally installed gems\. As a consequence, removes all system gems except for the ones in the current application\.
diff --git a/lib/bundler/man/bundle-config.1 b/lib/bundler/man/bundle-config.1
index fdb06c321d..b768f1e3d2 100644
--- a/lib/bundler/man/bundle-config.1
+++ b/lib/bundler/man/bundle-config.1
@@ -1,515 +1,321 @@
-.\" generated with Ronn/v0.7.3
-.\" http://github.com/rtomayko/ronn/tree/0.7.3
-.
-.TH "BUNDLE\-CONFIG" "1" "January 2023" "" ""
-.
+.\" generated with nRonn/v0.11.1
+.\" https://github.com/n-ronn/nronn/tree/0.11.1
+.TH "BUNDLE\-CONFIG" "1" "March 2024" ""
.SH "NAME"
\fBbundle\-config\fR \- Set bundler configuration options
-.
.SH "SYNOPSIS"
\fBbundle config\fR list
-.
.br
\fBbundle config\fR [get] NAME
-.
.br
\fBbundle config\fR [set] NAME VALUE
-.
.br
\fBbundle config\fR unset NAME
-.
.SH "DESCRIPTION"
-This command allows you to interact with Bundler\'s configuration system\.
-.
+This command allows you to interact with Bundler's configuration system\.
.P
Bundler loads configuration settings in this order:
-.
.IP "1." 4
Local config (\fB<project_root>/\.bundle/config\fR or \fB$BUNDLE_APP_CONFIG/config\fR)
-.
.IP "2." 4
Environmental variables (\fBENV\fR)
-.
.IP "3." 4
Global config (\fB~/\.bundle/config\fR)
-.
.IP "4." 4
Bundler default config
-.
.IP "" 0
-.
.P
Executing \fBbundle config list\fR will print a list of all bundler configuration for the current bundle, and where that configuration was set\.
-.
.P
Executing \fBbundle config get <name>\fR will print the value of that configuration setting, and where it was set\.
-.
.P
Executing \fBbundle config set <name> <value>\fR defaults to setting \fBlocal\fR configuration if executing from within a local application, otherwise it will set \fBglobal\fR configuration\. See \fB\-\-local\fR and \fB\-\-global\fR options below\.
-.
.P
Executing \fBbundle config set \-\-local <name> <value>\fR will set that configuration in the directory for the local application\. The configuration will be stored in \fB<project_root>/\.bundle/config\fR\. If \fBBUNDLE_APP_CONFIG\fR is set, the configuration will be stored in \fB$BUNDLE_APP_CONFIG/config\fR\.
-.
.P
Executing \fBbundle config set \-\-global <name> <value>\fR will set that configuration to the value specified for all bundles executed as the current user\. The configuration will be stored in \fB~/\.bundle/config\fR\. If \fIname\fR already is set, \fIname\fR will be overridden and user will be warned\.
-.
.P
Executing \fBbundle config unset <name>\fR will delete the configuration in both local and global sources\.
-.
.P
Executing \fBbundle config unset \-\-global <name>\fR will delete the configuration only from the user configuration\.
-.
.P
Executing \fBbundle config unset \-\-local <name>\fR will delete the configuration only from the local application\.
-.
.P
Executing bundle with the \fBBUNDLE_IGNORE_CONFIG\fR environment variable set will cause it to ignore all configuration\.
-.
.SH "REMEMBERING OPTIONS"
-Flags passed to \fBbundle install\fR or the Bundler runtime, such as \fB\-\-path foo\fR or \fB\-\-without production\fR, are remembered between commands and saved to your local application\'s configuration (normally, \fB\./\.bundle/config\fR)\.
-.
+Flags passed to \fBbundle install\fR or the Bundler runtime, such as \fB\-\-path foo\fR or \fB\-\-without production\fR, are remembered between commands and saved to your local application's configuration (normally, \fB\./\.bundle/config\fR)\.
.P
-However, this will be changed in bundler 3, so it\'s better not to rely on this behavior\. If these options must be remembered, it\'s better to set them using \fBbundle config\fR (e\.g\., \fBbundle config set \-\-local path foo\fR)\.
-.
+However, this will be changed in bundler 3, so it's better not to rely on this behavior\. If these options must be remembered, it's better to set them using \fBbundle config\fR (e\.g\., \fBbundle config set \-\-local path foo\fR)\.
.P
The options that can be configured are:
-.
.TP
\fBbin\fR
-Creates a directory (defaults to \fB~/bin\fR) and place any executables from the gem there\. These executables run in Bundler\'s context\. If used, you might add this directory to your environment\'s \fBPATH\fR variable\. For instance, if the \fBrails\fR gem comes with a \fBrails\fR executable, this flag will create a \fBbin/rails\fR executable that ensures that all referred dependencies will be resolved using the bundled gems\.
-.
+Creates a directory (defaults to \fB~/bin\fR) and place any executables from the gem there\. These executables run in Bundler's context\. If used, you might add this directory to your environment's \fBPATH\fR variable\. For instance, if the \fBrails\fR gem comes with a \fBrails\fR executable, this flag will create a \fBbin/rails\fR executable that ensures that all referred dependencies will be resolved using the bundled gems\.
.TP
\fBdeployment\fR
-In deployment mode, Bundler will \'roll\-out\' the bundle for \fBproduction\fR use\. Please check carefully if you want to have this option enabled in \fBdevelopment\fR or \fBtest\fR environments\.
-.
+In deployment mode, Bundler will 'roll\-out' the bundle for \fBproduction\fR use\. Please check carefully if you want to have this option enabled in \fBdevelopment\fR or \fBtest\fR environments\.
.TP
\fBonly\fR
A space\-separated list of groups to install only gems of the specified groups\.
-.
.TP
\fBpath\fR
-The location to install the specified gems to\. This defaults to Rubygems\' setting\. Bundler shares this location with Rubygems, \fBgem install \.\.\.\fR will have gem installed there, too\. Therefore, gems installed without a \fB\-\-path \.\.\.\fR setting will show up by calling \fBgem list\fR\. Accordingly, gems installed to other locations will not get listed\.
-.
+The location to install the specified gems to\. This defaults to Rubygems' setting\. Bundler shares this location with Rubygems, \fBgem install \|\.\|\.\|\.\fR will have gem installed there, too\. Therefore, gems installed without a \fB\-\-path \|\.\|\.\|\.\fR setting will show up by calling \fBgem list\fR\. Accordingly, gems installed to other locations will not get listed\.
.TP
\fBwithout\fR
A space\-separated list of groups referencing gems to skip during installation\.
-.
.TP
\fBwith\fR
A space\-separated list of \fBoptional\fR groups referencing gems to include during installation\.
-.
.SH "BUILD OPTIONS"
You can use \fBbundle config\fR to give Bundler the flags to pass to the gem installer every time bundler tries to install a particular gem\.
-.
.P
A very common example, the \fBmysql\fR gem, requires Snow Leopard users to pass configuration flags to \fBgem install\fR to specify where to find the \fBmysql_config\fR executable\.
-.
.IP "" 4
-.
.nf
-
gem install mysql \-\- \-\-with\-mysql\-config=/usr/local/mysql/bin/mysql_config
-.
.fi
-.
.IP "" 0
-.
.P
Since the specific location of that executable can change from machine to machine, you can specify these flags on a per\-machine basis\.
-.
.IP "" 4
-.
.nf
-
bundle config set \-\-global build\.mysql \-\-with\-mysql\-config=/usr/local/mysql/bin/mysql_config
-.
.fi
-.
.IP "" 0
-.
.P
After running this command, every time bundler needs to install the \fBmysql\fR gem, it will pass along the flags you specified\.
-.
.SH "CONFIGURATION KEYS"
Configuration keys in bundler have two forms: the canonical form and the environment variable form\.
-.
.P
-For instance, passing the \fB\-\-without\fR flag to bundle install(1) \fIbundle\-install\.1\.html\fR prevents Bundler from installing certain groups specified in the Gemfile(5)\. Bundler persists this value in \fBapp/\.bundle/config\fR so that calls to \fBBundler\.setup\fR do not try to find gems from the \fBGemfile\fR that you didn\'t install\. Additionally, subsequent calls to bundle install(1) \fIbundle\-install\.1\.html\fR remember this setting and skip those groups\.
-.
+For instance, passing the \fB\-\-without\fR flag to bundle install(1) \fIbundle\-install\.1\.html\fR prevents Bundler from installing certain groups specified in the Gemfile(5)\. Bundler persists this value in \fBapp/\.bundle/config\fR so that calls to \fBBundler\.setup\fR do not try to find gems from the \fBGemfile\fR that you didn't install\. Additionally, subsequent calls to bundle install(1) \fIbundle\-install\.1\.html\fR remember this setting and skip those groups\.
.P
The canonical form of this configuration is \fB"without"\fR\. To convert the canonical form to the environment variable form, capitalize it, and prepend \fBBUNDLE_\fR\. The environment variable form of \fB"without"\fR is \fBBUNDLE_WITHOUT\fR\.
-.
.P
Any periods in the configuration keys must be replaced with two underscores when setting it via environment variables\. The configuration key \fBlocal\.rack\fR becomes the environment variable \fBBUNDLE_LOCAL__RACK\fR\.
-.
.SH "LIST OF AVAILABLE KEYS"
The following is a list of all configuration keys and their purpose\. You can learn more about their operation in bundle install(1) \fIbundle\-install\.1\.html\fR\.
-.
.IP "\(bu" 4
-\fBallow_deployment_source_credential_changes\fR (\fBBUNDLE_ALLOW_DEPLOYMENT_SOURCE_CREDENTIAL_CHANGES\fR): When in deployment mode, allow changing the credentials to a gem\'s source\. Ex: \fBhttps://some\.host\.com/gems/path/\fR \-> \fBhttps://user_name:password@some\.host\.com/gems/path\fR
-.
+\fBallow_deployment_source_credential_changes\fR (\fBBUNDLE_ALLOW_DEPLOYMENT_SOURCE_CREDENTIAL_CHANGES\fR): When in deployment mode, allow changing the credentials to a gem's source\. Ex: \fBhttps://some\.host\.com/gems/path/\fR \-> \fBhttps://user_name:password@some\.host\.com/gems/path\fR
.IP "\(bu" 4
\fBallow_offline_install\fR (\fBBUNDLE_ALLOW_OFFLINE_INSTALL\fR): Allow Bundler to use cached data when installing without network access\.
-.
.IP "\(bu" 4
\fBauto_clean_without_path\fR (\fBBUNDLE_AUTO_CLEAN_WITHOUT_PATH\fR): Automatically run \fBbundle clean\fR after installing when an explicit \fBpath\fR has not been set and Bundler is not installing into the system gems\.
-.
.IP "\(bu" 4
\fBauto_install\fR (\fBBUNDLE_AUTO_INSTALL\fR): Automatically run \fBbundle install\fR when gems are missing\.
-.
.IP "\(bu" 4
\fBbin\fR (\fBBUNDLE_BIN\fR): Install executables from gems in the bundle to the specified directory\. Defaults to \fBfalse\fR\.
-.
.IP "\(bu" 4
\fBcache_all\fR (\fBBUNDLE_CACHE_ALL\fR): Cache all gems, including path and git gems\. This needs to be explicitly configured on bundler 1 and bundler 2, but will be the default on bundler 3\.
-.
.IP "\(bu" 4
\fBcache_all_platforms\fR (\fBBUNDLE_CACHE_ALL_PLATFORMS\fR): Cache gems for all platforms\.
-.
.IP "\(bu" 4
\fBcache_path\fR (\fBBUNDLE_CACHE_PATH\fR): The directory that bundler will place cached gems in when running \fBbundle package\fR, and that bundler will look in when installing gems\. Defaults to \fBvendor/cache\fR\.
-.
.IP "\(bu" 4
\fBclean\fR (\fBBUNDLE_CLEAN\fR): Whether Bundler should run \fBbundle clean\fR automatically after \fBbundle install\fR\.
-.
.IP "\(bu" 4
\fBconsole\fR (\fBBUNDLE_CONSOLE\fR): The console that \fBbundle console\fR starts\. Defaults to \fBirb\fR\.
-.
.IP "\(bu" 4
\fBdefault_install_uses_path\fR (\fBBUNDLE_DEFAULT_INSTALL_USES_PATH\fR): Whether a \fBbundle install\fR without an explicit \fB\-\-path\fR argument defaults to installing gems in \fB\.bundle\fR\.
-.
.IP "\(bu" 4
\fBdeployment\fR (\fBBUNDLE_DEPLOYMENT\fR): Disallow changes to the \fBGemfile\fR\. When the \fBGemfile\fR is changed and the lockfile has not been updated, running Bundler commands will be blocked\.
-.
.IP "\(bu" 4
\fBdisable_checksum_validation\fR (\fBBUNDLE_DISABLE_CHECKSUM_VALIDATION\fR): Allow installing gems even if they do not match the checksum provided by RubyGems\.
-.
.IP "\(bu" 4
\fBdisable_exec_load\fR (\fBBUNDLE_DISABLE_EXEC_LOAD\fR): Stop Bundler from using \fBload\fR to launch an executable in\-process in \fBbundle exec\fR\.
-.
.IP "\(bu" 4
\fBdisable_local_branch_check\fR (\fBBUNDLE_DISABLE_LOCAL_BRANCH_CHECK\fR): Allow Bundler to use a local git override without a branch specified in the Gemfile\.
-.
.IP "\(bu" 4
\fBdisable_local_revision_check\fR (\fBBUNDLE_DISABLE_LOCAL_REVISION_CHECK\fR): Allow Bundler to use a local git override without checking if the revision present in the lockfile is present in the repository\.
-.
.IP "\(bu" 4
-\fBdisable_shared_gems\fR (\fBBUNDLE_DISABLE_SHARED_GEMS\fR): Stop Bundler from accessing gems installed to RubyGems\' normal location\.
-.
+\fBdisable_shared_gems\fR (\fBBUNDLE_DISABLE_SHARED_GEMS\fR): Stop Bundler from accessing gems installed to RubyGems' normal location\.
.IP "\(bu" 4
\fBdisable_version_check\fR (\fBBUNDLE_DISABLE_VERSION_CHECK\fR): Stop Bundler from checking if a newer Bundler version is available on rubygems\.org\.
-.
.IP "\(bu" 4
-\fBforce_ruby_platform\fR (\fBBUNDLE_FORCE_RUBY_PLATFORM\fR): Ignore the current machine\'s platform and install only \fBruby\fR platform gems\. As a result, gems with native extensions will be compiled from source\.
-.
+\fBforce_ruby_platform\fR (\fBBUNDLE_FORCE_RUBY_PLATFORM\fR): Ignore the current machine's platform and install only \fBruby\fR platform gems\. As a result, gems with native extensions will be compiled from source\.
.IP "\(bu" 4
\fBfrozen\fR (\fBBUNDLE_FROZEN\fR): Disallow changes to the \fBGemfile\fR\. When the \fBGemfile\fR is changed and the lockfile has not been updated, running Bundler commands will be blocked\. Defaults to \fBtrue\fR when \fB\-\-deployment\fR is used\.
-.
.IP "\(bu" 4
\fBgem\.github_username\fR (\fBBUNDLE_GEM__GITHUB_USERNAME\fR): Sets a GitHub username or organization to be used in \fBREADME\fR file when you create a new gem via \fBbundle gem\fR command\. It can be overridden by passing an explicit \fB\-\-github\-username\fR flag to \fBbundle gem\fR\.
-.
.IP "\(bu" 4
\fBgem\.push_key\fR (\fBBUNDLE_GEM__PUSH_KEY\fR): Sets the \fB\-\-key\fR parameter for \fBgem push\fR when using the \fBrake release\fR command with a private gemstash server\.
-.
.IP "\(bu" 4
\fBgemfile\fR (\fBBUNDLE_GEMFILE\fR): The name of the file that bundler should use as the \fBGemfile\fR\. This location of this file also sets the root of the project, which is used to resolve relative paths in the \fBGemfile\fR, among other things\. By default, bundler will search up from the current working directory until it finds a \fBGemfile\fR\.
-.
.IP "\(bu" 4
\fBglobal_gem_cache\fR (\fBBUNDLE_GLOBAL_GEM_CACHE\fR): Whether Bundler should cache all gems globally, rather than locally to the installing Ruby installation\.
-.
.IP "\(bu" 4
\fBignore_funding_requests\fR (\fBBUNDLE_IGNORE_FUNDING_REQUESTS\fR): When set, no funding requests will be printed\.
-.
.IP "\(bu" 4
\fBignore_messages\fR (\fBBUNDLE_IGNORE_MESSAGES\fR): When set, no post install messages will be printed\. To silence a single gem, use dot notation like \fBignore_messages\.httparty true\fR\.
-.
.IP "\(bu" 4
\fBinit_gems_rb\fR (\fBBUNDLE_INIT_GEMS_RB\fR): Generate a \fBgems\.rb\fR instead of a \fBGemfile\fR when running \fBbundle init\fR\.
-.
.IP "\(bu" 4
\fBjobs\fR (\fBBUNDLE_JOBS\fR): The number of gems Bundler can install in parallel\. Defaults to the number of available processors\.
-.
.IP "\(bu" 4
\fBno_install\fR (\fBBUNDLE_NO_INSTALL\fR): Whether \fBbundle package\fR should skip installing gems\.
-.
.IP "\(bu" 4
\fBno_prune\fR (\fBBUNDLE_NO_PRUNE\fR): Whether Bundler should leave outdated gems unpruned when caching\.
-.
.IP "\(bu" 4
\fBonly\fR (\fBBUNDLE_ONLY\fR): A space\-separated list of groups to install only gems of the specified groups\.
-.
.IP "\(bu" 4
\fBpath\fR (\fBBUNDLE_PATH\fR): The location on disk where all gems in your bundle will be located regardless of \fB$GEM_HOME\fR or \fB$GEM_PATH\fR values\. Bundle gems not found in this location will be installed by \fBbundle install\fR\. Defaults to \fBGem\.dir\fR\. When \-\-deployment is used, defaults to vendor/bundle\.
-.
.IP "\(bu" 4
\fBpath\.system\fR (\fBBUNDLE_PATH__SYSTEM\fR): Whether Bundler will install gems into the default system path (\fBGem\.dir\fR)\.
-.
.IP "\(bu" 4
\fBpath_relative_to_cwd\fR (\fBBUNDLE_PATH_RELATIVE_TO_CWD\fR) Makes \fB\-\-path\fR relative to the CWD instead of the \fBGemfile\fR\.
-.
.IP "\(bu" 4
-\fBplugins\fR (\fBBUNDLE_PLUGINS\fR): Enable Bundler\'s experimental plugin system\.
-.
+\fBplugins\fR (\fBBUNDLE_PLUGINS\fR): Enable Bundler's experimental plugin system\.
.IP "\(bu" 4
\fBprefer_patch\fR (BUNDLE_PREFER_PATCH): Prefer updating only to next patch version during updates\. Makes \fBbundle update\fR calls equivalent to \fBbundler update \-\-patch\fR\.
-.
.IP "\(bu" 4
\fBprint_only_version_number\fR (\fBBUNDLE_PRINT_ONLY_VERSION_NUMBER\fR): Print only version number from \fBbundler \-\-version\fR\.
-.
.IP "\(bu" 4
\fBredirect\fR (\fBBUNDLE_REDIRECT\fR): The number of redirects allowed for network requests\. Defaults to \fB5\fR\.
-.
.IP "\(bu" 4
\fBretry\fR (\fBBUNDLE_RETRY\fR): The number of times to retry failed network requests\. Defaults to \fB3\fR\.
-.
.IP "\(bu" 4
\fBsetup_makes_kernel_gem_public\fR (\fBBUNDLE_SETUP_MAKES_KERNEL_GEM_PUBLIC\fR): Have \fBBundler\.setup\fR make the \fBKernel#gem\fR method public, even though RubyGems declares it as private\.
-.
.IP "\(bu" 4
\fBshebang\fR (\fBBUNDLE_SHEBANG\fR): The program name that should be invoked for generated binstubs\. Defaults to the ruby install name used to generate the binstub\.
-.
.IP "\(bu" 4
\fBsilence_deprecations\fR (\fBBUNDLE_SILENCE_DEPRECATIONS\fR): Whether Bundler should silence deprecation warnings for behavior that will be changed in the next major version\.
-.
.IP "\(bu" 4
\fBsilence_root_warning\fR (\fBBUNDLE_SILENCE_ROOT_WARNING\fR): Silence the warning Bundler prints when installing gems as root\.
-.
.IP "\(bu" 4
\fBssl_ca_cert\fR (\fBBUNDLE_SSL_CA_CERT\fR): Path to a designated CA certificate file or folder containing multiple certificates for trusted CAs in PEM format\.
-.
.IP "\(bu" 4
\fBssl_client_cert\fR (\fBBUNDLE_SSL_CLIENT_CERT\fR): Path to a designated file containing a X\.509 client certificate and key in PEM format\.
-.
.IP "\(bu" 4
\fBssl_verify_mode\fR (\fBBUNDLE_SSL_VERIFY_MODE\fR): The SSL verification mode Bundler uses when making HTTPS requests\. Defaults to verify peer\.
-.
-.IP "\(bu" 4
-\fBsuppress_install_using_messages\fR (\fBBUNDLE_SUPPRESS_INSTALL_USING_MESSAGES\fR): Avoid printing \fBUsing \.\.\.\fR messages during installation when the version of a gem has not changed\.
-.
.IP "\(bu" 4
\fBsystem_bindir\fR (\fBBUNDLE_SYSTEM_BINDIR\fR): The location where RubyGems installs binstubs\. Defaults to \fBGem\.bindir\fR\.
-.
.IP "\(bu" 4
\fBtimeout\fR (\fBBUNDLE_TIMEOUT\fR): The seconds allowed before timing out for network requests\. Defaults to \fB10\fR\.
-.
.IP "\(bu" 4
\fBupdate_requires_all_flag\fR (\fBBUNDLE_UPDATE_REQUIRES_ALL_FLAG\fR): Require passing \fB\-\-all\fR to \fBbundle update\fR when everything should be updated, and disallow passing no options to \fBbundle update\fR\.
-.
.IP "\(bu" 4
\fBuser_agent\fR (\fBBUNDLE_USER_AGENT\fR): The custom user agent fragment Bundler includes in API requests\.
-.
+.IP "\(bu" 4
+\fBversion\fR (\fBBUNDLE_VERSION\fR): The version of Bundler to use when running under Bundler environment\. Defaults to \fBlockfile\fR\. You can also specify \fBsystem\fR or \fBx\.y\.z\fR\. \fBlockfile\fR will use the Bundler version specified in the \fBGemfile\.lock\fR, \fBsystem\fR will use the system version of Bundler, and \fBx\.y\.z\fR will use the specified version of Bundler\.
.IP "\(bu" 4
\fBwith\fR (\fBBUNDLE_WITH\fR): A \fB:\fR\-separated list of groups whose gems bundler should install\.
-.
.IP "\(bu" 4
\fBwithout\fR (\fBBUNDLE_WITHOUT\fR): A \fB:\fR\-separated list of groups whose gems bundler should not install\.
-.
.IP "" 0
-.
.P
In general, you should set these settings per\-application by using the applicable flag to the bundle install(1) \fIbundle\-install\.1\.html\fR or bundle cache(1) \fIbundle\-cache\.1\.html\fR command\.
-.
.P
You can set them globally either via environment variables or \fBbundle config\fR, whichever is preferable for your setup\. If you use both, environment variables will take preference over global settings\.
-.
.SH "LOCAL GIT REPOS"
Bundler also allows you to work against a git repository locally instead of using the remote version\. This can be achieved by setting up a local override:
-.
.IP "" 4
-.
.nf
-
bundle config set \-\-local local\.GEM_NAME /path/to/local/git/repository
-.
.fi
-.
.IP "" 0
-.
.P
For example, in order to use a local Rack repository, a developer could call:
-.
.IP "" 4
-.
.nf
-
bundle config set \-\-local local\.rack ~/Work/git/rack
-.
.fi
-.
.IP "" 0
-.
.P
-Now instead of checking out the remote git repository, the local override will be used\. Similar to a path source, every time the local git repository change, changes will be automatically picked up by Bundler\. This means a commit in the local git repo will update the revision in the \fBGemfile\.lock\fR to the local git repo revision\. This requires the same attention as git submodules\. Before pushing to the remote, you need to ensure the local override was pushed, otherwise you may point to a commit that only exists in your local machine\. You\'ll also need to CGI escape your usernames and passwords as well\.
-.
+Now instead of checking out the remote git repository, the local override will be used\. Similar to a path source, every time the local git repository change, changes will be automatically picked up by Bundler\. This means a commit in the local git repo will update the revision in the \fBGemfile\.lock\fR to the local git repo revision\. This requires the same attention as git submodules\. Before pushing to the remote, you need to ensure the local override was pushed, otherwise you may point to a commit that only exists in your local machine\. You'll also need to CGI escape your usernames and passwords as well\.
.P
-Bundler does many checks to ensure a developer won\'t work with invalid references\. Particularly, we force a developer to specify a branch in the \fBGemfile\fR in order to use this feature\. If the branch specified in the \fBGemfile\fR and the current branch in the local git repository do not match, Bundler will abort\. This ensures that a developer is always working against the correct branches, and prevents accidental locking to a different branch\.
-.
+Bundler does many checks to ensure a developer won't work with invalid references\. Particularly, we force a developer to specify a branch in the \fBGemfile\fR in order to use this feature\. If the branch specified in the \fBGemfile\fR and the current branch in the local git repository do not match, Bundler will abort\. This ensures that a developer is always working against the correct branches, and prevents accidental locking to a different branch\.
.P
Finally, Bundler also ensures that the current revision in the \fBGemfile\.lock\fR exists in the local git repository\. By doing this, Bundler forces you to fetch the latest changes in the remotes\.
-.
.SH "MIRRORS OF GEM SOURCES"
Bundler supports overriding gem sources with mirrors\. This allows you to configure rubygems\.org as the gem source in your Gemfile while still using your mirror to fetch gems\.
-.
.IP "" 4
-.
.nf
-
bundle config set \-\-global mirror\.SOURCE_URL MIRROR_URL
-.
.fi
-.
.IP "" 0
-.
.P
For example, to use a mirror of https://rubygems\.org hosted at https://example\.org:
-.
.IP "" 4
-.
.nf
-
bundle config set \-\-global mirror\.https://rubygems\.org https://example\.org
-.
.fi
-.
.IP "" 0
-.
.P
Each mirror also provides a fallback timeout setting\. If the mirror does not respond within the fallback timeout, Bundler will try to use the original server instead of the mirror\.
-.
.IP "" 4
-.
.nf
-
bundle config set \-\-global mirror\.SOURCE_URL\.fallback_timeout TIMEOUT
-.
.fi
-.
.IP "" 0
-.
.P
For example, to fall back to rubygems\.org after 3 seconds:
-.
.IP "" 4
-.
.nf
-
bundle config set \-\-global mirror\.https://rubygems\.org\.fallback_timeout 3
-.
.fi
-.
.IP "" 0
-.
.P
The default fallback timeout is 0\.1 seconds, but the setting can currently only accept whole seconds (for example, 1, 15, or 30)\.
-.
.SH "CREDENTIALS FOR GEM SOURCES"
Bundler allows you to configure credentials for any gem source, which allows you to avoid putting secrets into your Gemfile\.
-.
.IP "" 4
-.
.nf
-
bundle config set \-\-global SOURCE_HOSTNAME USERNAME:PASSWORD
-.
.fi
-.
.IP "" 0
-.
.P
For example, to save the credentials of user \fBclaudette\fR for the gem source at \fBgems\.longerous\.com\fR, you would run:
-.
.IP "" 4
-.
.nf
-
bundle config set \-\-global gems\.longerous\.com claudette:s00pers3krit
-.
.fi
-.
.IP "" 0
-.
.P
Or you can set the credentials as an environment variable like this:
-.
.IP "" 4
-.
.nf
-
export BUNDLE_GEMS__LONGEROUS__COM="claudette:s00pers3krit"
-.
.fi
-.
.IP "" 0
-.
.P
For gems with a git source with HTTP(S) URL you can specify credentials like so:
-.
.IP "" 4
-.
.nf
-
bundle config set \-\-global https://github\.com/rubygems/rubygems\.git username:password
-.
.fi
-.
.IP "" 0
-.
.P
Or you can set the credentials as an environment variable like so:
-.
.IP "" 4
-.
.nf
-
export BUNDLE_GITHUB__COM=username:password
-.
.fi
-.
.IP "" 0
-.
.P
This is especially useful for private repositories on hosts such as GitHub, where you can use personal OAuth tokens:
-.
.IP "" 4
-.
.nf
-
export BUNDLE_GITHUB__COM=abcd0123generatedtoken:x\-oauth\-basic
-.
.fi
-.
.IP "" 0
-.
.P
Note that any configured credentials will be redacted by informative commands such as \fBbundle config list\fR or \fBbundle config get\fR, unless you use the \fB\-\-parseable\fR flag\. This is to avoid unintentionally leaking credentials when copy\-pasting bundler output\.
-.
.P
Also note that to guarantee a sane mapping between valid environment variable names and valid host names, bundler makes the following transformations:
-.
.IP "\(bu" 4
-Any \fB\-\fR characters in a host name are mapped to a triple dash (\fB___\fR) in the corresponding environment variable\.
-.
+Any \fB\-\fR characters in a host name are mapped to a triple underscore (\fB___\fR) in the corresponding environment variable\.
.IP "\(bu" 4
-Any \fB\.\fR characters in a host name are mapped to a double dash (\fB__\fR) in the corresponding environment variable\.
-.
+Any \fB\.\fR characters in a host name are mapped to a double underscore (\fB__\fR) in the corresponding environment variable\.
.IP "" 0
-.
.P
-This means that if you have a gem server named \fBmy\.gem\-host\.com\fR, you\'ll need to use the \fBBUNDLE_MY__GEM___HOST__COM\fR variable to configure credentials for it through ENV\.
-.
+This means that if you have a gem server named \fBmy\.gem\-host\.com\fR, you'll need to use the \fBBUNDLE_MY__GEM___HOST__COM\fR variable to configure credentials for it through ENV\.
.SH "CONFIGURE BUNDLER DIRECTORIES"
-Bundler\'s home, config, cache and plugin directories are able to be configured through environment variables\. The default location for Bundler\'s home directory is \fB~/\.bundle\fR, which all directories inherit from by default\. The following outlines the available environment variables and their default values
-.
+Bundler's home, config, cache and plugin directories are able to be configured through environment variables\. The default location for Bundler's home directory is \fB~/\.bundle\fR, which all directories inherit from by default\. The following outlines the available environment variables and their default values
.IP "" 4
-.
.nf
-
BUNDLE_USER_HOME : $HOME/\.bundle
BUNDLE_USER_CACHE : $BUNDLE_USER_HOME/cache
BUNDLE_USER_CONFIG : $BUNDLE_USER_HOME/config
BUNDLE_USER_PLUGIN : $BUNDLE_USER_HOME/plugin
-.
.fi
-.
.IP "" 0
diff --git a/lib/bundler/man/bundle-config.1.ronn b/lib/bundler/man/bundle-config.1.ronn
index bc8b27cf89..587d31dbad 100644
--- a/lib/bundler/man/bundle-config.1.ronn
+++ b/lib/bundler/man/bundle-config.1.ronn
@@ -265,9 +265,6 @@ learn more about their operation in [bundle install(1)](bundle-install.1.html).
* `ssl_verify_mode` (`BUNDLE_SSL_VERIFY_MODE`):
The SSL verification mode Bundler uses when making HTTPS requests.
Defaults to verify peer.
-* `suppress_install_using_messages` (`BUNDLE_SUPPRESS_INSTALL_USING_MESSAGES`):
- Avoid printing `Using ...` messages during installation when the version of
- a gem has not changed.
* `system_bindir` (`BUNDLE_SYSTEM_BINDIR`):
The location where RubyGems installs binstubs. Defaults to `Gem.bindir`.
* `timeout` (`BUNDLE_TIMEOUT`):
@@ -277,6 +274,12 @@ learn more about their operation in [bundle install(1)](bundle-install.1.html).
and disallow passing no options to `bundle update`.
* `user_agent` (`BUNDLE_USER_AGENT`):
The custom user agent fragment Bundler includes in API requests.
+* `version` (`BUNDLE_VERSION`):
+ The version of Bundler to use when running under Bundler environment.
+ Defaults to `lockfile`. You can also specify `system` or `x.y.z`.
+ `lockfile` will use the Bundler version specified in the `Gemfile.lock`,
+ `system` will use the system version of Bundler, and `x.y.z` will use
+ the specified version of Bundler.
* `with` (`BUNDLE_WITH`):
A `:`-separated list of groups whose gems bundler should install.
* `without` (`BUNDLE_WITHOUT`):
@@ -385,10 +388,10 @@ copy-pasting bundler output.
Also note that to guarantee a sane mapping between valid environment variable
names and valid host names, bundler makes the following transformations:
-* Any `-` characters in a host name are mapped to a triple dash (`___`) in the
+* Any `-` characters in a host name are mapped to a triple underscore (`___`) in the
corresponding environment variable.
-* Any `.` characters in a host name are mapped to a double dash (`__`) in the
+* Any `.` characters in a host name are mapped to a double underscore (`__`) in the
corresponding environment variable.
This means that if you have a gem server named `my.gem-host.com`, you'll need to
diff --git a/lib/bundler/man/bundle-console.1 b/lib/bundler/man/bundle-console.1
index 6cb0f0f810..1368a50eb1 100644
--- a/lib/bundler/man/bundle-console.1
+++ b/lib/bundler/man/bundle-console.1
@@ -1,53 +1,35 @@
-.\" generated with Ronn/v0.7.3
-.\" http://github.com/rtomayko/ronn/tree/0.7.3
-.
-.TH "BUNDLE\-CONSOLE" "1" "January 2023" "" ""
-.
+.\" generated with nRonn/v0.11.1
+.\" https://github.com/n-ronn/nronn/tree/0.11.1
+.TH "BUNDLE\-CONSOLE" "1" "March 2024" ""
.SH "NAME"
\fBbundle\-console\fR \- Deprecated way to open an IRB session with the bundle pre\-loaded
-.
.SH "SYNOPSIS"
\fBbundle console\fR [GROUP]
-.
.SH "DESCRIPTION"
Starts an interactive Ruby console session in the context of the current bundle\.
-.
.P
If no \fBGROUP\fR is specified, all gems in the \fBdefault\fR group in the Gemfile(5) \fIhttps://bundler\.io/man/gemfile\.5\.html\fR are preliminarily loaded\.
-.
.P
If \fBGROUP\fR is specified, all gems in the given group in the Gemfile in addition to the gems in \fBdefault\fR group are loaded\. Even if the given group does not exist in the Gemfile, IRB console starts without any warning or error\.
-.
.P
The environment variable \fBBUNDLE_CONSOLE\fR or \fBbundle config set console\fR can be used to change the shell from the following:
-.
.IP "\(bu" 4
\fBirb\fR (default)
-.
.IP "\(bu" 4
\fBpry\fR (https://github\.com/pry/pry)
-.
.IP "\(bu" 4
\fBripl\fR (https://github\.com/cldwalker/ripl)
-.
.IP "" 0
-.
.P
\fBbundle console\fR uses irb by default\. An alternative Pry or Ripl can be used with \fBbundle console\fR by adjusting the \fBconsole\fR Bundler setting\. Also make sure that \fBpry\fR or \fBripl\fR is in your Gemfile\.
-.
.SH "EXAMPLE"
-.
.nf
-
$ bundle config set console pry
$ bundle console
-Resolving dependencies\.\.\.
+Resolving dependencies\|\.\|\.\|\.
[1] pry(main)>
-.
.fi
-.
.SH "NOTES"
This command was deprecated in Bundler 2\.1 and will be removed in 3\.0\. Use \fBbin/console\fR script, which can be generated by \fBbundle gem <NAME>\fR\.
-.
.SH "SEE ALSO"
Gemfile(5) \fIhttps://bundler\.io/man/gemfile\.5\.html\fR
diff --git a/lib/bundler/man/bundle-doctor.1 b/lib/bundler/man/bundle-doctor.1
index bfe928c9a1..80eaf2a888 100644
--- a/lib/bundler/man/bundle-doctor.1
+++ b/lib/bundler/man/bundle-doctor.1
@@ -1,44 +1,30 @@
-.\" generated with Ronn/v0.7.3
-.\" http://github.com/rtomayko/ronn/tree/0.7.3
-.
-.TH "BUNDLE\-DOCTOR" "1" "January 2023" "" ""
-.
+.\" generated with nRonn/v0.11.1
+.\" https://github.com/n-ronn/nronn/tree/0.11.1
+.TH "BUNDLE\-DOCTOR" "1" "March 2024" ""
.SH "NAME"
\fBbundle\-doctor\fR \- Checks the bundle for common problems
-.
.SH "SYNOPSIS"
\fBbundle doctor\fR [\-\-quiet] [\-\-gemfile=GEMFILE]
-.
.SH "DESCRIPTION"
Checks your Gemfile and gem environment for common problems\. If issues are detected, Bundler prints them and exits status 1\. Otherwise, Bundler prints a success message and exits status 0\.
-.
.P
Examples of common problems caught by bundle\-doctor include:
-.
.IP "\(bu" 4
Invalid Bundler settings
-.
.IP "\(bu" 4
Mismatched Ruby versions
-.
.IP "\(bu" 4
Mismatched platforms
-.
.IP "\(bu" 4
Uninstalled gems
-.
.IP "\(bu" 4
Missing dependencies
-.
.IP "" 0
-.
.SH "OPTIONS"
-.
.TP
\fB\-\-quiet\fR
Only output warnings and errors\.
-.
.TP
\fB\-\-gemfile=<gemfile>\fR
-The location of the Gemfile(5) which Bundler should use\. This defaults to a Gemfile(5) in the current working directory\. In general, Bundler will assume that the location of the Gemfile(5) is also the project\'s root and will try to find \fBGemfile\.lock\fR and \fBvendor/cache\fR relative to this location\.
+The location of the Gemfile(5) which Bundler should use\. This defaults to a Gemfile(5) in the current working directory\. In general, Bundler will assume that the location of the Gemfile(5) is also the project's root and will try to find \fBGemfile\.lock\fR and \fBvendor/cache\fR relative to this location\.
diff --git a/lib/bundler/man/bundle-exec.1 b/lib/bundler/man/bundle-exec.1
index 281f3faede..191863c045 100644
--- a/lib/bundler/man/bundle-exec.1
+++ b/lib/bundler/man/bundle-exec.1
@@ -1,165 +1,104 @@
-.\" generated with Ronn/v0.7.3
-.\" http://github.com/rtomayko/ronn/tree/0.7.3
-.
-.TH "BUNDLE\-EXEC" "1" "January 2023" "" ""
-.
+.\" generated with nRonn/v0.11.1
+.\" https://github.com/n-ronn/nronn/tree/0.11.1
+.TH "BUNDLE\-EXEC" "1" "March 2024" ""
.SH "NAME"
\fBbundle\-exec\fR \- Execute a command in the context of the bundle
-.
.SH "SYNOPSIS"
\fBbundle exec\fR [\-\-keep\-file\-descriptors] \fIcommand\fR
-.
.SH "DESCRIPTION"
This command executes the command, making all gems specified in the [\fBGemfile(5)\fR][Gemfile(5)] available to \fBrequire\fR in Ruby programs\.
-.
.P
Essentially, if you would normally have run something like \fBrspec spec/my_spec\.rb\fR, and you want to use the gems specified in the [\fBGemfile(5)\fR][Gemfile(5)] and installed via bundle install(1) \fIbundle\-install\.1\.html\fR, you should run \fBbundle exec rspec spec/my_spec\.rb\fR\.
-.
.P
-Note that \fBbundle exec\fR does not require that an executable is available on your shell\'s \fB$PATH\fR\.
-.
+Note that \fBbundle exec\fR does not require that an executable is available on your shell's \fB$PATH\fR\.
.SH "OPTIONS"
-.
.TP
\fB\-\-keep\-file\-descriptors\fR
-Exec in Ruby 2\.0 began discarding non\-standard file descriptors\. When this flag is passed, exec will revert to the 1\.9 behaviour of passing all file descriptors to the new process\.
-.
+Passes all file descriptors to the new processes\. Default is true from bundler version 2\.2\.26\. Setting it to false is now deprecated\.
.SH "BUNDLE INSTALL \-\-BINSTUBS"
If you use the \fB\-\-binstubs\fR flag in bundle install(1) \fIbundle\-install\.1\.html\fR, Bundler will automatically create a directory (which defaults to \fBapp_root/bin\fR) containing all of the executables available from gems in the bundle\.
-.
.P
After using \fB\-\-binstubs\fR, \fBbin/rspec spec/my_spec\.rb\fR is identical to \fBbundle exec rspec spec/my_spec\.rb\fR\.
-.
.SH "ENVIRONMENT MODIFICATIONS"
\fBbundle exec\fR makes a number of changes to the shell environment, then executes the command you specify in full\.
-.
.IP "\(bu" 4
-make sure that it\'s still possible to shell out to \fBbundle\fR from inside a command invoked by \fBbundle exec\fR (using \fB$BUNDLE_BIN_PATH\fR)
-.
+make sure that it's still possible to shell out to \fBbundle\fR from inside a command invoked by \fBbundle exec\fR (using \fB$BUNDLE_BIN_PATH\fR)
.IP "\(bu" 4
put the directory containing executables (like \fBrails\fR, \fBrspec\fR, \fBrackup\fR) for your bundle on \fB$PATH\fR
-.
.IP "\(bu" 4
make sure that if bundler is invoked in the subshell, it uses the same \fBGemfile\fR (by setting \fBBUNDLE_GEMFILE\fR)
-.
.IP "\(bu" 4
add \fB\-rbundler/setup\fR to \fB$RUBYOPT\fR, which makes sure that Ruby programs invoked in the subshell can see the gems in the bundle
-.
.IP "" 0
-.
.P
It also modifies Rubygems:
-.
.IP "\(bu" 4
disallow loading additional gems not in the bundle
-.
.IP "\(bu" 4
-modify the \fBgem\fR method to be a no\-op if a gem matching the requirements is in the bundle, and to raise a \fBGem::LoadError\fR if it\'s not
-.
+modify the \fBgem\fR method to be a no\-op if a gem matching the requirements is in the bundle, and to raise a \fBGem::LoadError\fR if it's not
.IP "\(bu" 4
Define \fBGem\.refresh\fR to be a no\-op, since the source index is always frozen when using bundler, and to prevent gems from the system leaking into the environment
-.
.IP "\(bu" 4
Override \fBGem\.bin_path\fR to use the gems in the bundle, making system executables work
-.
.IP "\(bu" 4
Add all gems in the bundle into Gem\.loaded_specs
-.
.IP "" 0
-.
.P
-Finally, \fBbundle exec\fR also implicitly modifies \fBGemfile\.lock\fR if the lockfile and the Gemfile do not match\. Bundler needs the Gemfile to determine things such as a gem\'s groups, \fBautorequire\fR, and platforms, etc\., and that information isn\'t stored in the lockfile\. The Gemfile and lockfile must be synced in order to \fBbundle exec\fR successfully, so \fBbundle exec\fR updates the lockfile beforehand\.
-.
+Finally, \fBbundle exec\fR also implicitly modifies \fBGemfile\.lock\fR if the lockfile and the Gemfile do not match\. Bundler needs the Gemfile to determine things such as a gem's groups, \fBautorequire\fR, and platforms, etc\., and that information isn't stored in the lockfile\. The Gemfile and lockfile must be synced in order to \fBbundle exec\fR successfully, so \fBbundle exec\fR updates the lockfile beforehand\.
.SS "Loading"
By default, when attempting to \fBbundle exec\fR to a file with a ruby shebang, Bundler will \fBKernel\.load\fR that file instead of using \fBKernel\.exec\fR\. For the vast majority of cases, this is a performance improvement\. In a rare few cases, this could cause some subtle side\-effects (such as dependence on the exact contents of \fB$0\fR or \fB__FILE__\fR) and the optimization can be disabled by enabling the \fBdisable_exec_load\fR setting\.
-.
.SS "Shelling out"
-Any Ruby code that opens a subshell (like \fBsystem\fR, backticks, or \fB%x{}\fR) will automatically use the current Bundler environment\. If you need to shell out to a Ruby command that is not part of your current bundle, use the \fBwith_unbundled_env\fR method with a block\. Any subshells created inside the block will be given the environment present before Bundler was activated\. For example, Homebrew commands run Ruby, but don\'t work inside a bundle:
-.
+Any Ruby code that opens a subshell (like \fBsystem\fR, backticks, or \fB%x{}\fR) will automatically use the current Bundler environment\. If you need to shell out to a Ruby command that is not part of your current bundle, use the \fBwith_unbundled_env\fR method with a block\. Any subshells created inside the block will be given the environment present before Bundler was activated\. For example, Homebrew commands run Ruby, but don't work inside a bundle:
.IP "" 4
-.
.nf
-
Bundler\.with_unbundled_env do
`brew install wget`
end
-.
.fi
-.
.IP "" 0
-.
.P
Using \fBwith_unbundled_env\fR is also necessary if you are shelling out to a different bundle\. Any Bundler commands run in a subshell will inherit the current Gemfile, so commands that need to run in the context of a different bundle also need to use \fBwith_unbundled_env\fR\.
-.
.IP "" 4
-.
.nf
-
Bundler\.with_unbundled_env do
Dir\.chdir "/other/bundler/project" do
`bundle exec \./script`
end
end
-.
.fi
-.
.IP "" 0
-.
.P
Bundler provides convenience helpers that wrap \fBsystem\fR and \fBexec\fR, and they can be used like this:
-.
.IP "" 4
-.
.nf
-
-Bundler\.clean_system(\'brew install wget\')
-Bundler\.clean_exec(\'brew install wget\')
-.
+Bundler\.clean_system('brew install wget')
+Bundler\.clean_exec('brew install wget')
.fi
-.
.IP "" 0
-.
.SH "RUBYGEMS PLUGINS"
At present, the Rubygems plugin system requires all files named \fBrubygems_plugin\.rb\fR on the load path of \fIany\fR installed gem when any Ruby code requires \fBrubygems\.rb\fR\. This includes executables installed into the system, like \fBrails\fR, \fBrackup\fR, and \fBrspec\fR\.
-.
.P
Since Rubygems plugins can contain arbitrary Ruby code, they commonly end up activating themselves or their dependencies\.
-.
.P
For instance, the \fBgemcutter 0\.5\fR gem depended on \fBjson_pure\fR\. If you had that version of gemcutter installed (even if you \fIalso\fR had a newer version without this problem), Rubygems would activate \fBgemcutter 0\.5\fR and \fBjson_pure <latest>\fR\.
-.
.P
If your Gemfile(5) also contained \fBjson_pure\fR (or a gem with a dependency on \fBjson_pure\fR), the latest version on your system might conflict with the version in your Gemfile(5), or the snapshot version in your \fBGemfile\.lock\fR\.
-.
.P
If this happens, bundler will say:
-.
.IP "" 4
-.
.nf
-
You have already activated json_pure 1\.4\.6 but your Gemfile
requires json_pure 1\.4\.3\. Consider using bundle exec\.
-.
.fi
-.
.IP "" 0
-.
.P
In this situation, you almost certainly want to remove the underlying gem with the problematic gem plugin\. In general, the authors of these plugins (in this case, the \fBgemcutter\fR gem) have released newer versions that are more careful in their plugins\.
-.
.P
You can find a list of all the gems containing gem plugins by running
-.
.IP "" 4
-.
.nf
-
-ruby \-e "puts Gem\.find_files(\'rubygems_plugin\.rb\')"
-.
+ruby \-e "puts Gem\.find_files('rubygems_plugin\.rb')"
.fi
-.
.IP "" 0
-.
.P
-At the very least, you should remove all but the newest version of each gem plugin, and also remove all gem plugins that you aren\'t using (\fBgem uninstall gem_name\fR)\.
+At the very least, you should remove all but the newest version of each gem plugin, and also remove all gem plugins that you aren't using (\fBgem uninstall gem_name\fR)\.
diff --git a/lib/bundler/man/bundle-exec.1.ronn b/lib/bundler/man/bundle-exec.1.ronn
index 05948095e2..9d5b559f26 100644
--- a/lib/bundler/man/bundle-exec.1.ronn
+++ b/lib/bundler/man/bundle-exec.1.ronn
@@ -21,9 +21,8 @@ available on your shell's `$PATH`.
## OPTIONS
* `--keep-file-descriptors`:
- Exec in Ruby 2.0 began discarding non-standard file descriptors. When this
- flag is passed, exec will revert to the 1.9 behaviour of passing all file
- descriptors to the new process.
+ Passes all file descriptors to the new processes. Default is true from
+ bundler version 2.2.26. Setting it to false is now deprecated.
## BUNDLE INSTALL --BINSTUBS
diff --git a/lib/bundler/man/bundle-gem.1 b/lib/bundler/man/bundle-gem.1
index 4bac1bf442..464d8d1126 100644
--- a/lib/bundler/man/bundle-gem.1
+++ b/lib/bundler/man/bundle-gem.1
@@ -1,105 +1,69 @@
-.\" generated with Ronn/v0.7.3
-.\" http://github.com/rtomayko/ronn/tree/0.7.3
-.
-.TH "BUNDLE\-GEM" "1" "January 2023" "" ""
-.
+.\" generated with nRonn/v0.11.1
+.\" https://github.com/n-ronn/nronn/tree/0.11.1
+.TH "BUNDLE\-GEM" "1" "March 2024" ""
.SH "NAME"
\fBbundle\-gem\fR \- Generate a project skeleton for creating a rubygem
-.
.SH "SYNOPSIS"
\fBbundle gem\fR \fIGEM_NAME\fR \fIOPTIONS\fR
-.
.SH "DESCRIPTION"
Generates a directory named \fBGEM_NAME\fR with a \fBRakefile\fR, \fBGEM_NAME\.gemspec\fR, and other supporting files and directories that can be used to develop a rubygem with that name\.
-.
.P
Run \fBrake \-T\fR in the resulting project for a list of Rake tasks that can be used to test and publish the gem to rubygems\.org\.
-.
.P
-The generated project skeleton can be customized with OPTIONS, as explained below\. Note that these options can also be specified via Bundler\'s global configuration file using the following names:
-.
+The generated project skeleton can be customized with OPTIONS, as explained below\. Note that these options can also be specified via Bundler's global configuration file using the following names:
.IP "\(bu" 4
\fBgem\.coc\fR
-.
.IP "\(bu" 4
\fBgem\.mit\fR
-.
.IP "\(bu" 4
\fBgem\.test\fR
-.
.IP "" 0
-.
.SH "OPTIONS"
-.
.IP "\(bu" 4
\fB\-\-exe\fR or \fB\-b\fR or \fB\-\-bin\fR: Specify that Bundler should create a binary executable (as \fBexe/GEM_NAME\fR) in the generated rubygem project\. This binary will also be added to the \fBGEM_NAME\.gemspec\fR manifest\. This behavior is disabled by default\.
-.
.IP "\(bu" 4
\fB\-\-no\-exe\fR: Do not create a binary (overrides \fB\-\-exe\fR specified in the global config)\.
-.
.IP "\(bu" 4
-\fB\-\-coc\fR: Add a \fBCODE_OF_CONDUCT\.md\fR file to the root of the generated project\. If this option is unspecified, an interactive prompt will be displayed and the answer will be saved in Bundler\'s global config for future \fBbundle gem\fR use\.
-.
+\fB\-\-coc\fR: Add a \fBCODE_OF_CONDUCT\.md\fR file to the root of the generated project\. If this option is unspecified, an interactive prompt will be displayed and the answer will be saved in Bundler's global config for future \fBbundle gem\fR use\.
.IP "\(bu" 4
\fB\-\-no\-coc\fR: Do not create a \fBCODE_OF_CONDUCT\.md\fR (overrides \fB\-\-coc\fR specified in the global config)\.
-.
.IP "\(bu" 4
\fB\-\-ext=c\fR, \fB\-\-ext=rust\fR Add boilerplate for C or Rust (currently magnus \fIhttps://docs\.rs/magnus\fR based) extension code to the generated project\. This behavior is disabled by default\.
-.
.IP "\(bu" 4
\fB\-\-no\-ext\fR: Do not add extension code (overrides \fB\-\-ext\fR specified in the global config)\.
-.
.IP "\(bu" 4
-\fB\-\-mit\fR: Add an MIT license to a \fBLICENSE\.txt\fR file in the root of the generated project\. Your name from the global git config is used for the copyright statement\. If this option is unspecified, an interactive prompt will be displayed and the answer will be saved in Bundler\'s global config for future \fBbundle gem\fR use\.
-.
+\fB\-\-mit\fR: Add an MIT license to a \fBLICENSE\.txt\fR file in the root of the generated project\. Your name from the global git config is used for the copyright statement\. If this option is unspecified, an interactive prompt will be displayed and the answer will be saved in Bundler's global config for future \fBbundle gem\fR use\.
.IP "\(bu" 4
\fB\-\-no\-mit\fR: Do not create a \fBLICENSE\.txt\fR (overrides \fB\-\-mit\fR specified in the global config)\.
-.
.IP "\(bu" 4
\fB\-t\fR, \fB\-\-test=minitest\fR, \fB\-\-test=rspec\fR, \fB\-\-test=test\-unit\fR: Specify the test framework that Bundler should use when generating the project\. Acceptable values are \fBminitest\fR, \fBrspec\fR and \fBtest\-unit\fR\. The \fBGEM_NAME\.gemspec\fR will be configured and a skeleton test/spec directory will be created based on this option\. Given no option is specified:
-.
.IP
-When Bundler is configured to generate tests, this defaults to Bundler\'s global config setting \fBgem\.test\fR\.
-.
+When Bundler is configured to generate tests, this defaults to Bundler's global config setting \fBgem\.test\fR\.
.IP
When Bundler is configured to not generate tests, an interactive prompt will be displayed and the answer will be used for the current rubygem project\.
-.
.IP
-When Bundler is unconfigured, an interactive prompt will be displayed and the answer will be saved in Bundler\'s global config for future \fBbundle gem\fR use\.
-.
+When Bundler is unconfigured, an interactive prompt will be displayed and the answer will be saved in Bundler's global config for future \fBbundle gem\fR use\.
.IP "\(bu" 4
\fB\-\-ci\fR, \fB\-\-ci=github\fR, \fB\-\-ci=gitlab\fR, \fB\-\-ci=circle\fR: Specify the continuous integration service that Bundler should use when generating the project\. Acceptable values are \fBgithub\fR, \fBgitlab\fR and \fBcircle\fR\. A configuration file will be generated in the project directory\. Given no option is specified:
-.
.IP
-When Bundler is configured to generate CI files, this defaults to Bundler\'s global config setting \fBgem\.ci\fR\.
-.
+When Bundler is configured to generate CI files, this defaults to Bundler's global config setting \fBgem\.ci\fR\.
.IP
When Bundler is configured to not generate CI files, an interactive prompt will be displayed and the answer will be used for the current rubygem project\.
-.
.IP
-When Bundler is unconfigured, an interactive prompt will be displayed and the answer will be saved in Bundler\'s global config for future \fBbundle gem\fR use\.
-.
+When Bundler is unconfigured, an interactive prompt will be displayed and the answer will be saved in Bundler's global config for future \fBbundle gem\fR use\.
.IP "\(bu" 4
-\fB\-\-linter\fR, \fB\-\-linter=rubocop\fR, \fB\-\-linter=standard\fR: Specify the linter and code formatter that Bundler should add to the project\'s development dependencies\. Acceptable values are \fBrubocop\fR and \fBstandard\fR\. A configuration file will be generated in the project directory\. Given no option is specified:
-.
+\fB\-\-linter\fR, \fB\-\-linter=rubocop\fR, \fB\-\-linter=standard\fR: Specify the linter and code formatter that Bundler should add to the project's development dependencies\. Acceptable values are \fBrubocop\fR and \fBstandard\fR\. A configuration file will be generated in the project directory\. Given no option is specified:
.IP
-When Bundler is configured to add a linter, this defaults to Bundler\'s global config setting \fBgem\.linter\fR\.
-.
+When Bundler is configured to add a linter, this defaults to Bundler's global config setting \fBgem\.linter\fR\.
.IP
When Bundler is configured not to add a linter, an interactive prompt will be displayed and the answer will be used for the current rubygem project\.
-.
.IP
-When Bundler is unconfigured, an interactive prompt will be displayed and the answer will be saved in Bundler\'s global config for future \fBbundle gem\fR use\.
-.
+When Bundler is unconfigured, an interactive prompt will be displayed and the answer will be saved in Bundler's global config for future \fBbundle gem\fR use\.
.IP "\(bu" 4
\fB\-e\fR, \fB\-\-edit[=EDITOR]\fR: Open the resulting GEM_NAME\.gemspec in EDITOR, or the default editor if not specified\. The default is \fB$BUNDLER_EDITOR\fR, \fB$VISUAL\fR, or \fB$EDITOR\fR\.
-.
.IP "" 0
-.
.SH "SEE ALSO"
-.
.IP "\(bu" 4
bundle config(1) \fIbundle\-config\.1\.html\fR
-.
.IP "" 0
diff --git a/lib/bundler/man/bundle-help.1 b/lib/bundler/man/bundle-help.1
index 47a42a497e..3604ad6127 100644
--- a/lib/bundler/man/bundle-help.1
+++ b/lib/bundler/man/bundle-help.1
@@ -1,13 +1,9 @@
-.\" generated with Ronn/v0.7.3
-.\" http://github.com/rtomayko/ronn/tree/0.7.3
-.
-.TH "BUNDLE\-HELP" "1" "January 2023" "" ""
-.
+.\" generated with nRonn/v0.11.1
+.\" https://github.com/n-ronn/nronn/tree/0.11.1
+.TH "BUNDLE\-HELP" "1" "March 2024" ""
.SH "NAME"
\fBbundle\-help\fR \- Displays detailed help for each subcommand
-.
.SH "SYNOPSIS"
\fBbundle help\fR [COMMAND]
-.
.SH "DESCRIPTION"
Displays detailed help for the given subcommand\. You can specify a single \fBCOMMAND\fR at the same time\. When \fBCOMMAND\fR is omitted, help for \fBhelp\fR command will be displayed\.
diff --git a/lib/bundler/man/bundle-info.1 b/lib/bundler/man/bundle-info.1
index e9f5583e85..647f5987be 100644
--- a/lib/bundler/man/bundle-info.1
+++ b/lib/bundler/man/bundle-info.1
@@ -1,19 +1,13 @@
-.\" generated with Ronn/v0.7.3
-.\" http://github.com/rtomayko/ronn/tree/0.7.3
-.
-.TH "BUNDLE\-INFO" "1" "January 2023" "" ""
-.
+.\" generated with nRonn/v0.11.1
+.\" https://github.com/n-ronn/nronn/tree/0.11.1
+.TH "BUNDLE\-INFO" "1" "March 2024" ""
.SH "NAME"
\fBbundle\-info\fR \- Show information for the given gem in your bundle
-.
.SH "SYNOPSIS"
-\fBbundle info\fR [GEM] [\-\-path]
-.
+\fBbundle info\fR [GEM_NAME] [\-\-path]
.SH "DESCRIPTION"
-Print the basic information about the provided GEM such as homepage, version, path and summary\.
-.
+Given a gem name present in your bundle, print the basic information about it such as homepage, version, path and summary\.
.SH "OPTIONS"
-.
.TP
\fB\-\-path\fR
Print the path of the given gem
diff --git a/lib/bundler/man/bundle-info.1.ronn b/lib/bundler/man/bundle-info.1.ronn
index 47e457aa3c..cecdeb564f 100644
--- a/lib/bundler/man/bundle-info.1.ronn
+++ b/lib/bundler/man/bundle-info.1.ronn
@@ -3,13 +3,13 @@ bundle-info(1) -- Show information for the given gem in your bundle
## SYNOPSIS
-`bundle info` [GEM]
+`bundle info` [GEM_NAME]
[--path]
## DESCRIPTION
-Print the basic information about the provided GEM such as homepage, version,
-path and summary.
+Given a gem name present in your bundle, print the basic information about it
+ such as homepage, version, path and summary.
## OPTIONS
diff --git a/lib/bundler/man/bundle-init.1 b/lib/bundler/man/bundle-init.1
index 9e8b059f1f..2c41a3c7de 100644
--- a/lib/bundler/man/bundle-init.1
+++ b/lib/bundler/man/bundle-init.1
@@ -1,25 +1,20 @@
-.\" generated with Ronn/v0.7.3
-.\" http://github.com/rtomayko/ronn/tree/0.7.3
-.
-.TH "BUNDLE\-INIT" "1" "January 2023" "" ""
-.
+.\" generated with nRonn/v0.11.1
+.\" https://github.com/n-ronn/nronn/tree/0.11.1
+.TH "BUNDLE\-INIT" "1" "March 2024" ""
.SH "NAME"
\fBbundle\-init\fR \- Generates a Gemfile into the current working directory
-.
.SH "SYNOPSIS"
\fBbundle init\fR [\-\-gemspec=FILE]
-.
.SH "DESCRIPTION"
Init generates a default [\fBGemfile(5)\fR][Gemfile(5)] in the current working directory\. When adding a [\fBGemfile(5)\fR][Gemfile(5)] to a gem with a gemspec, the \fB\-\-gemspec\fR option will automatically add each dependency listed in the gemspec file to the newly created [\fBGemfile(5)\fR][Gemfile(5)]\.
-.
.SH "OPTIONS"
-.
.TP
\fB\-\-gemspec\fR
Use the specified \.gemspec to create the [\fBGemfile(5)\fR][Gemfile(5)]
-.
+.TP
+\fB\-\-gemfile\fR
+Use the specified name for the gemfile instead of \fBGemfile\fR
.SH "FILES"
Included in the default [\fBGemfile(5)\fR][Gemfile(5)] generated is the line \fB# frozen_string_literal: true\fR\. This is a magic comment supported for the first time in Ruby 2\.3\. The presence of this line results in all string literals in the file being implicitly frozen\.
-.
.SH "SEE ALSO"
Gemfile(5) \fIhttps://bundler\.io/man/gemfile\.5\.html\fR
diff --git a/lib/bundler/man/bundle-init.1.ronn b/lib/bundler/man/bundle-init.1.ronn
index 9d3d97deea..7d3cede1f6 100644
--- a/lib/bundler/man/bundle-init.1.ronn
+++ b/lib/bundler/man/bundle-init.1.ronn
@@ -16,6 +16,8 @@ created [`Gemfile(5)`][Gemfile(5)].
* `--gemspec`:
Use the specified .gemspec to create the [`Gemfile(5)`][Gemfile(5)]
+* `--gemfile`:
+ Use the specified name for the gemfile instead of `Gemfile`
## FILES
diff --git a/lib/bundler/man/bundle-inject.1 b/lib/bundler/man/bundle-inject.1
index 0b0766a40c..c7269db34d 100644
--- a/lib/bundler/man/bundle-inject.1
+++ b/lib/bundler/man/bundle-inject.1
@@ -1,36 +1,23 @@
-.\" generated with Ronn/v0.7.3
-.\" http://github.com/rtomayko/ronn/tree/0.7.3
-.
-.TH "BUNDLE\-INJECT" "1" "January 2023" "" ""
-.
+.\" generated with nRonn/v0.11.1
+.\" https://github.com/n-ronn/nronn/tree/0.11.1
+.TH "BUNDLE\-INJECT" "1" "March 2024" ""
.SH "NAME"
\fBbundle\-inject\fR \- Add named gem(s) with version requirements to Gemfile
-.
.SH "SYNOPSIS"
\fBbundle inject\fR [GEM] [VERSION]
-.
.SH "DESCRIPTION"
Adds the named gem(s) with their version requirements to the resolved [\fBGemfile(5)\fR][Gemfile(5)]\.
-.
.P
-This command will add the gem to both your [\fBGemfile(5)\fR][Gemfile(5)] and Gemfile\.lock if it isn\'t listed yet\.
-.
+This command will add the gem to both your [\fBGemfile(5)\fR][Gemfile(5)] and Gemfile\.lock if it isn't listed yet\.
.P
Example:
-.
.IP "" 4
-.
.nf
-
bundle install
-bundle inject \'rack\' \'> 0\'
-.
+bundle inject 'rack' '> 0'
.fi
-.
.IP "" 0
-.
.P
-This will inject the \'rack\' gem with a version greater than 0 in your [\fBGemfile(5)\fR][Gemfile(5)] and Gemfile\.lock\.
-.
+This will inject the 'rack' gem with a version greater than 0 in your [\fBGemfile(5)\fR][Gemfile(5)] and Gemfile\.lock\.
.P
The \fBbundle inject\fR command was deprecated in Bundler 2\.1 and will be removed in Bundler 3\.0\.
diff --git a/lib/bundler/man/bundle-install.1 b/lib/bundler/man/bundle-install.1
index fcf6a6a66c..3fa1a467e2 100644
--- a/lib/bundler/man/bundle-install.1
+++ b/lib/bundler/man/bundle-install.1
@@ -1,313 +1,215 @@
-.\" generated with Ronn/v0.7.3
-.\" http://github.com/rtomayko/ronn/tree/0.7.3
-.
-.TH "BUNDLE\-INSTALL" "1" "January 2023" "" ""
-.
+.\" generated with nRonn/v0.11.1
+.\" https://github.com/n-ronn/nronn/tree/0.11.1
+.TH "BUNDLE\-INSTALL" "1" "March 2024" ""
.SH "NAME"
\fBbundle\-install\fR \- Install the dependencies specified in your Gemfile
-.
.SH "SYNOPSIS"
-\fBbundle install\fR [\-\-binstubs[=DIRECTORY]] [\-\-clean] [\-\-deployment] [\-\-frozen] [\-\-full\-index] [\-\-gemfile=GEMFILE] [\-\-jobs=NUMBER] [\-\-local] [\-\-no\-cache] [\-\-no\-prune] [\-\-path PATH] [\-\-quiet] [\-\-redownload] [\-\-retry=NUMBER] [\-\-shebang] [\-\-standalone[=GROUP[ GROUP\.\.\.]]] [\-\-system] [\-\-trust\-policy=POLICY] [\-\-with=GROUP[ GROUP\.\.\.]] [\-\-without=GROUP[ GROUP\.\.\.]]
-.
+\fBbundle install\fR [\-\-binstubs[=DIRECTORY]] [\-\-clean] [\-\-deployment] [\-\-frozen] [\-\-full\-index] [\-\-gemfile=GEMFILE] [\-\-jobs=NUMBER] [\-\-local] [\-\-no\-cache] [\-\-no\-prune] [\-\-path PATH] [\-\-prefer\-local] [\-\-quiet] [\-\-redownload] [\-\-retry=NUMBER] [\-\-shebang] [\-\-standalone[=GROUP[ GROUP\|\.\|\.\|\.]]] [\-\-system] [\-\-trust\-policy=POLICY] [\-\-with=GROUP[ GROUP\|\.\|\.\|\.]] [\-\-without=GROUP[ GROUP\|\.\|\.\|\.]]
.SH "DESCRIPTION"
Install the gems specified in your Gemfile(5)\. If this is the first time you run bundle install (and a \fBGemfile\.lock\fR does not exist), Bundler will fetch all remote sources, resolve dependencies and install all needed gems\.
-.
.P
If a \fBGemfile\.lock\fR does exist, and you have not updated your Gemfile(5), Bundler will fetch all remote sources, but use the dependencies specified in the \fBGemfile\.lock\fR instead of resolving dependencies\.
-.
.P
If a \fBGemfile\.lock\fR does exist, and you have updated your Gemfile(5), Bundler will use the dependencies in the \fBGemfile\.lock\fR for all gems that you did not update, but will re\-resolve the dependencies of gems that you did update\. You can find more information about this update process below under \fICONSERVATIVE UPDATING\fR\.
-.
.SH "OPTIONS"
The \fB\-\-clean\fR, \fB\-\-deployment\fR, \fB\-\-frozen\fR, \fB\-\-no\-prune\fR, \fB\-\-path\fR, \fB\-\-shebang\fR, \fB\-\-system\fR, \fB\-\-without\fR and \fB\-\-with\fR options are deprecated because they only make sense if they are applied to every subsequent \fBbundle install\fR run automatically and that requires \fBbundler\fR to silently remember them\. Since \fBbundler\fR will no longer remember CLI flags in future versions, \fBbundle config\fR (see bundle\-config(1)) should be used to apply them permanently\.
-.
.TP
\fB\-\-binstubs[=<directory>]\fR
Binstubs are scripts that wrap around executables\. Bundler creates a small Ruby file (a binstub) that loads Bundler, runs the command, and puts it in \fBbin/\fR\. This lets you link the binstub inside of an application to the exact gem version the application needs\.
-.
.IP
-Creates a directory (defaults to \fB~/bin\fR) and places any executables from the gem there\. These executables run in Bundler\'s context\. If used, you might add this directory to your environment\'s \fBPATH\fR variable\. For instance, if the \fBrails\fR gem comes with a \fBrails\fR executable, this flag will create a \fBbin/rails\fR executable that ensures that all referred dependencies will be resolved using the bundled gems\.
-.
+Creates a directory (defaults to \fB~/bin\fR) and places any executables from the gem there\. These executables run in Bundler's context\. If used, you might add this directory to your environment's \fBPATH\fR variable\. For instance, if the \fBrails\fR gem comes with a \fBrails\fR executable, this flag will create a \fBbin/rails\fR executable that ensures that all referred dependencies will be resolved using the bundled gems\.
.TP
\fB\-\-clean\fR
-On finishing the installation Bundler is going to remove any gems not present in the current Gemfile(5)\. Don\'t worry, gems currently in use will not be removed\.
-.
+On finishing the installation Bundler is going to remove any gems not present in the current Gemfile(5)\. Don't worry, gems currently in use will not be removed\.
.IP
This option is deprecated in favor of the \fBclean\fR setting\.
-.
.TP
\fB\-\-deployment\fR
-In \fIdeployment mode\fR, Bundler will \'roll\-out\' the bundle for production or CI use\. Please check carefully if you want to have this option enabled in your development environment\.
-.
+In \fIdeployment mode\fR, Bundler will 'roll\-out' the bundle for production or CI use\. Please check carefully if you want to have this option enabled in your development environment\.
.IP
This option is deprecated in favor of the \fBdeployment\fR setting\.
-.
.TP
\fB\-\-redownload\fR
Force download every gem, even if the required versions are already available locally\.
-.
.TP
\fB\-\-frozen\fR
Do not allow the Gemfile\.lock to be updated after this install\. Exits non\-zero if there are going to be changes to the Gemfile\.lock\.
-.
.IP
This option is deprecated in favor of the \fBfrozen\fR setting\.
-.
.TP
\fB\-\-full\-index\fR
-Bundler will not call Rubygems\' API endpoint (default) but download and cache a (currently big) index file of all gems\. Performance can be improved for large bundles that seldom change by enabling this option\.
-.
+Bundler will not call Rubygems' API endpoint (default) but download and cache a (currently big) index file of all gems\. Performance can be improved for large bundles that seldom change by enabling this option\.
.TP
\fB\-\-gemfile=<gemfile>\fR
-The location of the Gemfile(5) which Bundler should use\. This defaults to a Gemfile(5) in the current working directory\. In general, Bundler will assume that the location of the Gemfile(5) is also the project\'s root and will try to find \fBGemfile\.lock\fR and \fBvendor/cache\fR relative to this location\.
-.
+The location of the Gemfile(5) which Bundler should use\. This defaults to a Gemfile(5) in the current working directory\. In general, Bundler will assume that the location of the Gemfile(5) is also the project's root and will try to find \fBGemfile\.lock\fR and \fBvendor/cache\fR relative to this location\.
.TP
\fB\-\-jobs=[<number>]\fR, \fB\-j[<number>]\fR
The maximum number of parallel download and install jobs\. The default is the number of available processors\.
-.
.TP
\fB\-\-local\fR
-Do not attempt to connect to \fBrubygems\.org\fR\. Instead, Bundler will use the gems already present in Rubygems\' cache or in \fBvendor/cache\fR\. Note that if an appropriate platform\-specific gem exists on \fBrubygems\.org\fR it will not be found\.
-.
+Do not attempt to connect to \fBrubygems\.org\fR\. Instead, Bundler will use the gems already present in Rubygems' cache or in \fBvendor/cache\fR\. Note that if an appropriate platform\-specific gem exists on \fBrubygems\.org\fR it will not be found\.
.TP
\fB\-\-prefer\-local\fR
-Force using locally installed gems, or gems already present in Rubygems\' cache or in \fBvendor/cache\fR, when resolving, even if newer versions are available remotely\. Only attempt to connect to \fBrubygems\.org\fR for gems that are not present locally\.
-.
+Force using locally installed gems, or gems already present in Rubygems' cache or in \fBvendor/cache\fR, when resolving, even if newer versions are available remotely\. Only attempt to connect to \fBrubygems\.org\fR for gems that are not present locally\.
.TP
\fB\-\-no\-cache\fR
Do not update the cache in \fBvendor/cache\fR with the newly bundled gems\. This does not remove any gems in the cache but keeps the newly bundled gems from being cached during the install\.
-.
.TP
\fB\-\-no\-prune\fR
-Don\'t remove stale gems from the cache when the installation finishes\.
-.
+Don't remove stale gems from the cache when the installation finishes\.
.IP
This option is deprecated in favor of the \fBno_prune\fR setting\.
-.
.TP
\fB\-\-path=<path>\fR
-The location to install the specified gems to\. This defaults to Rubygems\' setting\. Bundler shares this location with Rubygems, \fBgem install \.\.\.\fR will have gem installed there, too\. Therefore, gems installed without a \fB\-\-path \.\.\.\fR setting will show up by calling \fBgem list\fR\. Accordingly, gems installed to other locations will not get listed\.
-.
+The location to install the specified gems to\. This defaults to Rubygems' setting\. Bundler shares this location with Rubygems, \fBgem install \|\.\|\.\|\.\fR will have gem installed there, too\. Therefore, gems installed without a \fB\-\-path \|\.\|\.\|\.\fR setting will show up by calling \fBgem list\fR\. Accordingly, gems installed to other locations will not get listed\.
.IP
This option is deprecated in favor of the \fBpath\fR setting\.
-.
.TP
\fB\-\-quiet\fR
Do not print progress information to the standard output\. Instead, Bundler will exit using a status code (\fB$?\fR)\.
-.
.TP
\fB\-\-retry=[<number>]\fR
Retry failed network or git requests for \fInumber\fR times\.
-.
.TP
\fB\-\-shebang=<ruby\-executable>\fR
Uses the specified ruby executable (usually \fBruby\fR) to execute the scripts created with \fB\-\-binstubs\fR\. In addition, if you use \fB\-\-binstubs\fR together with \fB\-\-shebang jruby\fR these executables will be changed to execute \fBjruby\fR instead\.
-.
.IP
This option is deprecated in favor of the \fBshebang\fR setting\.
-.
.TP
\fB\-\-standalone[=<list>]\fR
-Makes a bundle that can work without depending on Rubygems or Bundler at runtime\. A space separated list of groups to install has to be specified\. Bundler creates a directory named \fBbundle\fR and installs the bundle there\. It also generates a \fBbundle/bundler/setup\.rb\fR file to replace Bundler\'s own setup in the manner required\. Using this option implicitly sets \fBpath\fR, which is a [remembered option][REMEMBERED OPTIONS]\.
-.
+Makes a bundle that can work without depending on Rubygems or Bundler at runtime\. A space separated list of groups to install has to be specified\. Bundler creates a directory named \fBbundle\fR and installs the bundle there\. It also generates a \fBbundle/bundler/setup\.rb\fR file to replace Bundler's own setup in the manner required\. Using this option implicitly sets \fBpath\fR, which is a [remembered option][REMEMBERED OPTIONS]\.
.TP
\fB\-\-system\fR
-Installs the gems specified in the bundle to the system\'s Rubygems location\. This overrides any previous configuration of \fB\-\-path\fR\.
-.
+Installs the gems specified in the bundle to the system's Rubygems location\. This overrides any previous configuration of \fB\-\-path\fR\.
.IP
This option is deprecated in favor of the \fBsystem\fR setting\.
-.
.TP
\fB\-\-trust\-policy=[<policy>]\fR
Apply the Rubygems security policy \fIpolicy\fR, where policy is one of \fBHighSecurity\fR, \fBMediumSecurity\fR, \fBLowSecurity\fR, \fBAlmostNoSecurity\fR, or \fBNoSecurity\fR\. For more details, please see the Rubygems signing documentation linked below in \fISEE ALSO\fR\.
-.
.TP
\fB\-\-with=<list>\fR
A space\-separated list of groups referencing gems to install\. If an optional group is given it is installed\. If a group is given that is in the remembered list of groups given to \-\-without, it is removed from that list\.
-.
.IP
This option is deprecated in favor of the \fBwith\fR setting\.
-.
.TP
\fB\-\-without=<list>\fR
A space\-separated list of groups referencing gems to skip during installation\. If a group is given that is in the remembered list of groups given to \-\-with, it is removed from that list\.
-.
.IP
This option is deprecated in favor of the \fBwithout\fR setting\.
-.
.SH "DEPLOYMENT MODE"
-Bundler\'s defaults are optimized for development\. To switch to defaults optimized for deployment and for CI, use the \fB\-\-deployment\fR flag\. Do not activate deployment mode on development machines, as it will cause an error when the Gemfile(5) is modified\.
-.
+Bundler's defaults are optimized for development\. To switch to defaults optimized for deployment and for CI, use the \fB\-\-deployment\fR flag\. Do not activate deployment mode on development machines, as it will cause an error when the Gemfile(5) is modified\.
.IP "1." 4
A \fBGemfile\.lock\fR is required\.
-.
.IP
To ensure that the same versions of the gems you developed with and tested with are also used in deployments, a \fBGemfile\.lock\fR is required\.
-.
.IP
This is mainly to ensure that you remember to check your \fBGemfile\.lock\fR into version control\.
-.
.IP "2." 4
The \fBGemfile\.lock\fR must be up to date
-.
.IP
In development, you can modify your Gemfile(5) and re\-run \fBbundle install\fR to \fIconservatively update\fR your \fBGemfile\.lock\fR snapshot\.
-.
.IP
In deployment, your \fBGemfile\.lock\fR should be up\-to\-date with changes made in your Gemfile(5)\.
-.
.IP "3." 4
Gems are installed to \fBvendor/bundle\fR not your default system location
-.
.IP
-In development, it\'s convenient to share the gems used in your application with other applications and other scripts that run on the system\.
-.
+In development, it's convenient to share the gems used in your application with other applications and other scripts that run on the system\.
.IP
In deployment, isolation is a more important default\. In addition, the user deploying the application may not have permission to install gems to the system, or the web server may not have permission to read them\.
-.
.IP
As a result, \fBbundle install \-\-deployment\fR installs gems to the \fBvendor/bundle\fR directory in the application\. This may be overridden using the \fB\-\-path\fR option\.
-.
.IP "" 0
-.
.SH "INSTALLING GROUPS"
By default, \fBbundle install\fR will install all gems in all groups in your Gemfile(5), except those declared for a different platform\.
-.
.P
However, you can explicitly tell Bundler to skip installing certain groups with the \fB\-\-without\fR option\. This option takes a space\-separated list of groups\.
-.
.P
While the \fB\-\-without\fR option will skip \fIinstalling\fR the gems in the specified groups, it will still \fIdownload\fR those gems and use them to resolve the dependencies of every gem in your Gemfile(5)\.
-.
.P
This is so that installing a different set of groups on another machine (such as a production server) will not change the gems and versions that you have already developed and tested against\.
-.
.P
\fBBundler offers a rock\-solid guarantee that the third\-party code you are running in development and testing is also the third\-party code you are running in production\. You can choose to exclude some of that code in different environments, but you will never be caught flat\-footed by different versions of third\-party code being used in different environments\.\fR
-.
.P
For a simple illustration, consider the following Gemfile(5):
-.
.IP "" 4
-.
.nf
+source 'https://rubygems\.org'
-source \'https://rubygems\.org\'
-
-gem \'sinatra\'
+gem 'sinatra'
group :production do
- gem \'rack\-perftools\-profiler\'
+ gem 'rack\-perftools\-profiler'
end
-.
.fi
-.
.IP "" 0
-.
.P
In this case, \fBsinatra\fR depends on any version of Rack (\fB>= 1\.0\fR), while \fBrack\-perftools\-profiler\fR depends on 1\.x (\fB~> 1\.0\fR)\.
-.
.P
When you run \fBbundle install \-\-without production\fR in development, we look at the dependencies of \fBrack\-perftools\-profiler\fR as well\. That way, you do not spend all your time developing against Rack 2\.0, using new APIs unavailable in Rack 1\.x, only to have Bundler switch to Rack 1\.2 when the \fBproduction\fR group \fIis\fR used\.
-.
.P
This should not cause any problems in practice, because we do not attempt to \fBinstall\fR the gems in the excluded groups, and only evaluate as part of the dependency resolution process\.
-.
.P
This also means that you cannot include different versions of the same gem in different groups, because doing so would result in different sets of dependencies used in development and production\. Because of the vagaries of the dependency resolution process, this usually affects more than the gems you list in your Gemfile(5), and can (surprisingly) radically change the gems you are using\.
-.
.SH "THE GEMFILE\.LOCK"
When you run \fBbundle install\fR, Bundler will persist the full names and versions of all gems that you used (including dependencies of the gems specified in the Gemfile(5)) into a file called \fBGemfile\.lock\fR\.
-.
.P
Bundler uses this file in all subsequent calls to \fBbundle install\fR, which guarantees that you always use the same exact code, even as your application moves across machines\.
-.
.P
Because of the way dependency resolution works, even a seemingly small change (for instance, an update to a point\-release of a dependency of a gem in your Gemfile(5)) can result in radically different gems being needed to satisfy all dependencies\.
-.
.P
As a result, you \fBSHOULD\fR check your \fBGemfile\.lock\fR into version control, in both applications and gems\. If you do not, every machine that checks out your repository (including your production server) will resolve all dependencies again, which will result in different versions of third\-party code being used if \fBany\fR of the gems in the Gemfile(5) or any of their dependencies have been updated\.
-.
.P
When Bundler first shipped, the \fBGemfile\.lock\fR was included in the \fB\.gitignore\fR file included with generated gems\. Over time, however, it became clear that this practice forces the pain of broken dependencies onto new contributors, while leaving existing contributors potentially unaware of the problem\. Since \fBbundle install\fR is usually the first step towards a contribution, the pain of broken dependencies would discourage new contributors from contributing\. As a result, we have revised our guidance for gem authors to now recommend checking in the lock for gems\.
-.
.SH "CONSERVATIVE UPDATING"
When you make a change to the Gemfile(5) and then run \fBbundle install\fR, Bundler will update only the gems that you modified\.
-.
.P
In other words, if a gem that you \fBdid not modify\fR worked before you called \fBbundle install\fR, it will continue to use the exact same versions of all dependencies as it used before the update\.
-.
.P
-Let\'s take a look at an example\. Here\'s your original Gemfile(5):
-.
+Let's take a look at an example\. Here's your original Gemfile(5):
.IP "" 4
-.
.nf
+source 'https://rubygems\.org'
-source \'https://rubygems\.org\'
-
-gem \'actionpack\', \'2\.3\.8\'
-gem \'activemerchant\'
-.
+gem 'actionpack', '2\.3\.8'
+gem 'activemerchant'
.fi
-.
.IP "" 0
-.
.P
In this case, both \fBactionpack\fR and \fBactivemerchant\fR depend on \fBactivesupport\fR\. The \fBactionpack\fR gem depends on \fBactivesupport 2\.3\.8\fR and \fBrack ~> 1\.1\.0\fR, while the \fBactivemerchant\fR gem depends on \fBactivesupport >= 2\.3\.2\fR, \fBbraintree >= 2\.0\.0\fR, and \fBbuilder >= 2\.0\.0\fR\.
-.
.P
When the dependencies are first resolved, Bundler will select \fBactivesupport 2\.3\.8\fR, which satisfies the requirements of both gems in your Gemfile(5)\.
-.
.P
Next, you modify your Gemfile(5) to:
-.
.IP "" 4
-.
.nf
+source 'https://rubygems\.org'
-source \'https://rubygems\.org\'
-
-gem \'actionpack\', \'3\.0\.0\.rc\'
-gem \'activemerchant\'
-.
+gem 'actionpack', '3\.0\.0\.rc'
+gem 'activemerchant'
.fi
-.
.IP "" 0
-.
.P
The \fBactionpack 3\.0\.0\.rc\fR gem has a number of new dependencies, and updates the \fBactivesupport\fR dependency to \fB= 3\.0\.0\.rc\fR and the \fBrack\fR dependency to \fB~> 1\.2\.1\fR\.
-.
.P
When you run \fBbundle install\fR, Bundler notices that you changed the \fBactionpack\fR gem, but not the \fBactivemerchant\fR gem\. It evaluates the gems currently being used to satisfy its requirements:
-.
.TP
\fBactivesupport 2\.3\.8\fR
also used to satisfy a dependency in \fBactivemerchant\fR, which is not being updated
-.
.TP
\fBrack ~> 1\.1\.0\fR
not currently being used to satisfy another dependency
-.
.P
Because you did not explicitly ask to update \fBactivemerchant\fR, you would not expect it to suddenly stop working after updating \fBactionpack\fR\. However, satisfying the new \fBactivesupport 3\.0\.0\.rc\fR dependency of actionpack requires updating one of its dependencies\.
-.
.P
Even though \fBactivemerchant\fR declares a very loose dependency that theoretically matches \fBactivesupport 3\.0\.0\.rc\fR, Bundler treats gems in your Gemfile(5) that have not changed as an atomic unit together with their dependencies\. In this case, the \fBactivemerchant\fR dependency is treated as \fBactivemerchant 1\.7\.1 + activesupport 2\.3\.8\fR, so \fBbundle install\fR will report that it cannot update \fBactionpack\fR\.
-.
.P
To explicitly update \fBactionpack\fR, including its dependencies which other gems in the Gemfile(5) still depend on, run \fBbundle update actionpack\fR (see \fBbundle update(1)\fR)\.
-.
.P
\fBSummary\fR: In general, after making a change to the Gemfile(5) , you should first try to run \fBbundle install\fR, which will guarantee that no other gem in the Gemfile(5) is impacted by the change\. If that does not work, run bundle update(1) \fIbundle\-update\.1\.html\fR\.
-.
.SH "SEE ALSO"
-.
.IP "\(bu" 4
-Gem install docs \fIhttp://guides\.rubygems\.org/rubygems\-basics/#installing\-gems\fR
-.
+Gem install docs \fIhttps://guides\.rubygems\.org/rubygems\-basics/#installing\-gems\fR
.IP "\(bu" 4
-Rubygems signing docs \fIhttp://guides\.rubygems\.org/security/\fR
-.
+Rubygems signing docs \fIhttps://guides\.rubygems\.org/security/\fR
.IP "" 0
diff --git a/lib/bundler/man/bundle-install.1.ronn b/lib/bundler/man/bundle-install.1.ronn
index be9ed0f974..ed8169de05 100644
--- a/lib/bundler/man/bundle-install.1.ronn
+++ b/lib/bundler/man/bundle-install.1.ronn
@@ -14,6 +14,7 @@ bundle-install(1) -- Install the dependencies specified in your Gemfile
[--no-cache]
[--no-prune]
[--path PATH]
+ [--prefer-local]
[--quiet]
[--redownload]
[--retry=NUMBER]
@@ -378,5 +379,5 @@ does not work, run [bundle update(1)](bundle-update.1.html).
## SEE ALSO
-* [Gem install docs](http://guides.rubygems.org/rubygems-basics/#installing-gems)
-* [Rubygems signing docs](http://guides.rubygems.org/security/)
+* [Gem install docs](https://guides.rubygems.org/rubygems-basics/#installing-gems)
+* [Rubygems signing docs](https://guides.rubygems.org/security/)
diff --git a/lib/bundler/man/bundle-list.1 b/lib/bundler/man/bundle-list.1
index 37d2c837e4..f91fd95739 100644
--- a/lib/bundler/man/bundle-list.1
+++ b/lib/bundler/man/bundle-list.1
@@ -1,49 +1,34 @@
-.\" generated with Ronn/v0.7.3
-.\" http://github.com/rtomayko/ronn/tree/0.7.3
-.
-.TH "BUNDLE\-LIST" "1" "January 2023" "" ""
-.
+.\" generated with nRonn/v0.11.1
+.\" https://github.com/n-ronn/nronn/tree/0.11.1
+.TH "BUNDLE\-LIST" "1" "March 2024" ""
.SH "NAME"
\fBbundle\-list\fR \- List all the gems in the bundle
-.
.SH "SYNOPSIS"
-\fBbundle list\fR [\-\-name\-only] [\-\-paths] [\-\-without\-group=GROUP[ GROUP\.\.\.]] [\-\-only\-group=GROUP[ GROUP\.\.\.]]
-.
+\fBbundle list\fR [\-\-name\-only] [\-\-paths] [\-\-without\-group=GROUP[ GROUP\|\.\|\.\|\.]] [\-\-only\-group=GROUP[ GROUP\|\.\|\.\|\.]]
.SH "DESCRIPTION"
Prints a list of all the gems in the bundle including their version\.
-.
.P
Example:
-.
.P
bundle list \-\-name\-only
-.
.P
bundle list \-\-paths
-.
.P
bundle list \-\-without\-group test
-.
.P
bundle list \-\-only\-group dev
-.
.P
bundle list \-\-only\-group dev test \-\-paths
-.
.SH "OPTIONS"
-.
.TP
\fB\-\-name\-only\fR
Print only the name of each gem\.
-.
.TP
\fB\-\-paths\fR
Print the path to each gem in the bundle\.
-.
.TP
\fB\-\-without\-group=<list>\fR
A space\-separated list of groups of gems to skip during printing\.
-.
.TP
\fB\-\-only\-group=<list>\fR
A space\-separated list of groups of gems to print\.
diff --git a/lib/bundler/man/bundle-lock.1 b/lib/bundler/man/bundle-lock.1
index 422da46d00..f992f5ee5f 100644
--- a/lib/bundler/man/bundle-lock.1
+++ b/lib/bundler/man/bundle-lock.1
@@ -1,84 +1,60 @@
-.\" generated with Ronn/v0.7.3
-.\" http://github.com/rtomayko/ronn/tree/0.7.3
-.
-.TH "BUNDLE\-LOCK" "1" "January 2023" "" ""
-.
+.\" generated with nRonn/v0.11.1
+.\" https://github.com/n-ronn/nronn/tree/0.11.1
+.TH "BUNDLE\-LOCK" "1" "March 2024" ""
.SH "NAME"
\fBbundle\-lock\fR \- Creates / Updates a lockfile without installing
-.
.SH "SYNOPSIS"
\fBbundle lock\fR [\-\-update] [\-\-local] [\-\-print] [\-\-lockfile=PATH] [\-\-full\-index] [\-\-add\-platform] [\-\-remove\-platform] [\-\-patch] [\-\-minor] [\-\-major] [\-\-strict] [\-\-conservative]
-.
.SH "DESCRIPTION"
Lock the gems specified in Gemfile\.
-.
.SH "OPTIONS"
-.
.TP
\fB\-\-update=<*gems>\fR
Ignores the existing lockfile\. Resolve then updates lockfile\. Taking a list of gems or updating all gems if no list is given\.
-.
.TP
\fB\-\-local\fR
-Do not attempt to connect to \fBrubygems\.org\fR\. Instead, Bundler will use the gems already present in Rubygems\' cache or in \fBvendor/cache\fR\. Note that if a appropriate platform\-specific gem exists on \fBrubygems\.org\fR it will not be found\.
-.
+Do not attempt to connect to \fBrubygems\.org\fR\. Instead, Bundler will use the gems already present in Rubygems' cache or in \fBvendor/cache\fR\. Note that if a appropriate platform\-specific gem exists on \fBrubygems\.org\fR it will not be found\.
.TP
\fB\-\-print\fR
Prints the lockfile to STDOUT instead of writing to the file system\.
-.
.TP
\fB\-\-lockfile=<path>\fR
The path where the lockfile should be written to\.
-.
.TP
\fB\-\-full\-index\fR
Fall back to using the single\-file index of all gems\.
-.
.TP
\fB\-\-add\-platform\fR
Add a new platform to the lockfile, re\-resolving for the addition of that platform\.
-.
.TP
\fB\-\-remove\-platform\fR
Remove a platform from the lockfile\.
-.
.TP
\fB\-\-patch\fR
If updating, prefer updating only to next patch version\.
-.
.TP
\fB\-\-minor\fR
If updating, prefer updating only to next minor version\.
-.
.TP
\fB\-\-major\fR
If updating, prefer updating to next major version (default)\.
-.
.TP
\fB\-\-strict\fR
If updating, do not allow any gem to be updated past latest \-\-patch | \-\-minor | \-\-major\.
-.
.TP
\fB\-\-conservative\fR
If updating, use bundle install conservative update behavior and do not allow shared dependencies to be updated\.
-.
.SH "UPDATING ALL GEMS"
If you run \fBbundle lock\fR with \fB\-\-update\fR option without list of gems, bundler will ignore any previously installed gems and resolve all dependencies again based on the latest versions of all gems available in the sources\.
-.
.SH "UPDATING A LIST OF GEMS"
Sometimes, you want to update a single gem in the Gemfile(5), and leave the rest of the gems that you specified locked to the versions in the \fBGemfile\.lock\fR\.
-.
.P
For instance, you only want to update \fBnokogiri\fR, run \fBbundle lock \-\-update nokogiri\fR\.
-.
.P
Bundler will update \fBnokogiri\fR and any of its dependencies, but leave the rest of the gems that you specified locked to the versions in the \fBGemfile\.lock\fR\.
-.
.SH "SUPPORTING OTHER PLATFORMS"
-If you want your bundle to support platforms other than the one you\'re running locally, you can run \fBbundle lock \-\-add\-platform PLATFORM\fR to add PLATFORM to the lockfile, force bundler to re\-resolve and consider the new platform when picking gems, all without needing to have a machine that matches PLATFORM handy to install those platform\-specific gems on\.
-.
+If you want your bundle to support platforms other than the one you're running locally, you can run \fBbundle lock \-\-add\-platform PLATFORM\fR to add PLATFORM to the lockfile, force bundler to re\-resolve and consider the new platform when picking gems, all without needing to have a machine that matches PLATFORM handy to install those platform\-specific gems on\.
.P
For a full explanation of gem platforms, see \fBgem help platform\fR\.
-.
.SH "PATCH LEVEL OPTIONS"
See bundle update(1) \fIbundle\-update\.1\.html\fR for details\.
diff --git a/lib/bundler/man/bundle-open.1 b/lib/bundler/man/bundle-open.1
index c831bf9ce9..53d3541555 100644
--- a/lib/bundler/man/bundle-open.1
+++ b/lib/bundler/man/bundle-open.1
@@ -1,51 +1,31 @@
-.\" generated with Ronn/v0.7.3
-.\" http://github.com/rtomayko/ronn/tree/0.7.3
-.
-.TH "BUNDLE\-OPEN" "1" "January 2023" "" ""
-.
+.\" generated with nRonn/v0.11.1
+.\" https://github.com/n-ronn/nronn/tree/0.11.1
+.TH "BUNDLE\-OPEN" "1" "March 2024" ""
.SH "NAME"
\fBbundle\-open\fR \- Opens the source directory for a gem in your bundle
-.
.SH "SYNOPSIS"
\fBbundle open\fR [GEM] [\-\-path=PATH]
-.
.SH "DESCRIPTION"
Opens the source directory of the provided GEM in your editor\.
-.
.P
For this to work the \fBEDITOR\fR or \fBBUNDLER_EDITOR\fR environment variable has to be set\.
-.
.P
Example:
-.
.IP "" 4
-.
.nf
-
-bundle open \'rack\'
-.
+bundle open 'rack'
.fi
-.
.IP "" 0
-.
.P
-Will open the source directory for the \'rack\' gem in your bundle\.
-.
+Will open the source directory for the 'rack' gem in your bundle\.
.IP "" 4
-.
.nf
-
-bundle open \'rack\' \-\-path \'README\.md\'
-.
+bundle open 'rack' \-\-path 'README\.md'
.fi
-.
.IP "" 0
-.
.P
-Will open the README\.md file of the \'rack\' gem source in your bundle\.
-.
+Will open the README\.md file of the 'rack' gem source in your bundle\.
.SH "OPTIONS"
-.
.TP
\fB\-\-path\fR
Specify GEM source relative path to open\.
diff --git a/lib/bundler/man/bundle-outdated.1 b/lib/bundler/man/bundle-outdated.1
index 40fe8a4def..f79eff5ae9 100644
--- a/lib/bundler/man/bundle-outdated.1
+++ b/lib/bundler/man/bundle-outdated.1
@@ -1,148 +1,100 @@
-.\" generated with Ronn/v0.7.3
-.\" http://github.com/rtomayko/ronn/tree/0.7.3
-.
-.TH "BUNDLE\-OUTDATED" "1" "January 2023" "" ""
-.
+.\" generated with nRonn/v0.11.1
+.\" https://github.com/n-ronn/nronn/tree/0.11.1
+.TH "BUNDLE\-OUTDATED" "1" "March 2024" ""
.SH "NAME"
\fBbundle\-outdated\fR \- List installed gems with newer versions available
-.
.SH "SYNOPSIS"
\fBbundle outdated\fR [GEM] [\-\-local] [\-\-pre] [\-\-source] [\-\-strict] [\-\-parseable | \-\-porcelain] [\-\-group=GROUP] [\-\-groups] [\-\-patch|\-\-minor|\-\-major] [\-\-filter\-major] [\-\-filter\-minor] [\-\-filter\-patch] [\-\-only\-explicit]
-.
.SH "DESCRIPTION"
Outdated lists the names and versions of gems that have a newer version available in the given source\. Calling outdated with [GEM [GEM]] will only check for newer versions of the given gems\. Prerelease gems are ignored by default\. If your gems are up to date, Bundler will exit with a status of 0\. Otherwise, it will exit 1\.
-.
.SH "OPTIONS"
-.
.TP
\fB\-\-local\fR
Do not attempt to fetch gems remotely and use the gem cache instead\.
-.
.TP
\fB\-\-pre\fR
Check for newer pre\-release gems\.
-.
.TP
\fB\-\-source\fR
Check against a specific source\.
-.
.TP
\fB\-\-strict\fR
Only list newer versions allowed by your Gemfile requirements, also respecting conservative update flags (\-\-patch, \-\-minor, \-\-major)\.
-.
.TP
\fB\-\-parseable\fR, \fB\-\-porcelain\fR
Use minimal formatting for more parseable output\.
-.
.TP
\fB\-\-group\fR
List gems from a specific group\.
-.
.TP
\fB\-\-groups\fR
List gems organized by groups\.
-.
.TP
\fB\-\-minor\fR
Prefer updating only to next minor version\.
-.
.TP
\fB\-\-major\fR
Prefer updating to next major version (default)\.
-.
.TP
\fB\-\-patch\fR
Prefer updating only to next patch version\.
-.
.TP
\fB\-\-filter\-major\fR
Only list major newer versions\.
-.
.TP
\fB\-\-filter\-minor\fR
Only list minor newer versions\.
-.
.TP
\fB\-\-filter\-patch\fR
Only list patch newer versions\.
-.
.TP
\fB\-\-only\-explicit\fR
Only list gems specified in your Gemfile, not their dependencies\.
-.
.SH "PATCH LEVEL OPTIONS"
See bundle update(1) \fIbundle\-update\.1\.html\fR for details\.
-.
.SH "FILTERING OUTPUT"
The 3 filtering options do not affect the resolution of versions, merely what versions are shown in the output\.
-.
.P
If the regular output shows the following:
-.
.IP "" 4
-.
.nf
-
-* faker (newest 1\.6\.6, installed 1\.6\.5, requested ~> 1\.4) in groups "development, test"
-* hashie (newest 3\.4\.6, installed 1\.2\.0, requested = 1\.2\.0) in groups "default"
-* headless (newest 2\.3\.1, installed 2\.2\.3) in groups "test"
-.
+* Gem Current Latest Requested Groups
+* faker 1\.6\.5 1\.6\.6 ~> 1\.4 development, test
+* hashie 1\.2\.0 3\.4\.6 = 1\.2\.0 default
+* headless 2\.2\.3 2\.3\.1 = 2\.2\.3 test
.fi
-.
.IP "" 0
-.
.P
\fB\-\-filter\-major\fR would only show:
-.
.IP "" 4
-.
.nf
-
-* hashie (newest 3\.4\.6, installed 1\.2\.0, requested = 1\.2\.0) in groups "default"
-.
+* Gem Current Latest Requested Groups
+* hashie 1\.2\.0 3\.4\.6 = 1\.2\.0 default
.fi
-.
.IP "" 0
-.
.P
\fB\-\-filter\-minor\fR would only show:
-.
.IP "" 4
-.
.nf
-
-* headless (newest 2\.3\.1, installed 2\.2\.3) in groups "test"
-.
+* Gem Current Latest Requested Groups
+* headless 2\.2\.3 2\.3\.1 = 2\.2\.3 test
.fi
-.
.IP "" 0
-.
.P
\fB\-\-filter\-patch\fR would only show:
-.
.IP "" 4
-.
.nf
-
-* faker (newest 1\.6\.6, installed 1\.6\.5, requested ~> 1\.4) in groups "development, test"
-.
+* Gem Current Latest Requested Groups
+* faker 1\.6\.5 1\.6\.6 ~> 1\.4 development, test
.fi
-.
.IP "" 0
-.
.P
Filter options can be combined\. \fB\-\-filter\-minor\fR and \fB\-\-filter\-patch\fR would show:
-.
.IP "" 4
-.
.nf
-
-* faker (newest 1\.6\.6, installed 1\.6\.5, requested ~> 1\.4) in groups "development, test"
-* headless (newest 2\.3\.1, installed 2\.2\.3) in groups "test"
-.
+* Gem Current Latest Requested Groups
+* faker 1\.6\.5 1\.6\.6 ~> 1\.4 development, test
.fi
-.
.IP "" 0
-.
.P
Combining all three \fBfilter\fR options would be the same result as providing none of them\.
diff --git a/lib/bundler/man/bundle-outdated.1.ronn b/lib/bundler/man/bundle-outdated.1.ronn
index 04096ffbb6..4ac65d0532 100644
--- a/lib/bundler/man/bundle-outdated.1.ronn
+++ b/lib/bundler/man/bundle-outdated.1.ronn
@@ -78,25 +78,29 @@ in the output.
If the regular output shows the following:
- * faker (newest 1.6.6, installed 1.6.5, requested ~> 1.4) in groups "development, test"
- * hashie (newest 3.4.6, installed 1.2.0, requested = 1.2.0) in groups "default"
- * headless (newest 2.3.1, installed 2.2.3) in groups "test"
+ * Gem Current Latest Requested Groups
+ * faker 1.6.5 1.6.6 ~> 1.4 development, test
+ * hashie 1.2.0 3.4.6 = 1.2.0 default
+ * headless 2.2.3 2.3.1 = 2.2.3 test
`--filter-major` would only show:
- * hashie (newest 3.4.6, installed 1.2.0, requested = 1.2.0) in groups "default"
+ * Gem Current Latest Requested Groups
+ * hashie 1.2.0 3.4.6 = 1.2.0 default
`--filter-minor` would only show:
- * headless (newest 2.3.1, installed 2.2.3) in groups "test"
+ * Gem Current Latest Requested Groups
+ * headless 2.2.3 2.3.1 = 2.2.3 test
`--filter-patch` would only show:
- * faker (newest 1.6.6, installed 1.6.5, requested ~> 1.4) in groups "development, test"
+ * Gem Current Latest Requested Groups
+ * faker 1.6.5 1.6.6 ~> 1.4 development, test
Filter options can be combined. `--filter-minor` and `--filter-patch` would show:
- * faker (newest 1.6.6, installed 1.6.5, requested ~> 1.4) in groups "development, test"
- * headless (newest 2.3.1, installed 2.2.3) in groups "test"
+ * Gem Current Latest Requested Groups
+ * faker 1.6.5 1.6.6 ~> 1.4 development, test
Combining all three `filter` options would be the same result as providing none of them.
diff --git a/lib/bundler/man/bundle-platform.1 b/lib/bundler/man/bundle-platform.1
index d0015a80ef..d2133ec4d3 100644
--- a/lib/bundler/man/bundle-platform.1
+++ b/lib/bundler/man/bundle-platform.1
@@ -1,41 +1,27 @@
-.\" generated with Ronn/v0.7.3
-.\" http://github.com/rtomayko/ronn/tree/0.7.3
-.
-.TH "BUNDLE\-PLATFORM" "1" "January 2023" "" ""
-.
+.\" generated with nRonn/v0.11.1
+.\" https://github.com/n-ronn/nronn/tree/0.11.1
+.TH "BUNDLE\-PLATFORM" "1" "March 2024" ""
.SH "NAME"
\fBbundle\-platform\fR \- Displays platform compatibility information
-.
.SH "SYNOPSIS"
\fBbundle platform\fR [\-\-ruby]
-.
.SH "DESCRIPTION"
\fBplatform\fR displays information from your Gemfile, Gemfile\.lock, and Ruby VM about your platform\.
-.
.P
For instance, using this Gemfile(5):
-.
.IP "" 4
-.
.nf
-
source "https://rubygems\.org"
ruby "3\.1\.2"
gem "rack"
-.
.fi
-.
.IP "" 0
-.
.P
If you run \fBbundle platform\fR on Ruby 3\.1\.2, it displays the following output:
-.
.IP "" 4
-.
.nf
-
Your platform is: x86_64\-linux
Your app has gems that work on these platforms:
@@ -48,24 +34,16 @@ Your Gemfile specifies a Ruby version requirement:
* ruby 3\.1\.2
Your current platform satisfies the Ruby version requirement\.
-.
.fi
-.
.IP "" 0
-.
.P
-\fBplatform\fR lists all the platforms in your \fBGemfile\.lock\fR as well as the \fBruby\fR directive if applicable from your Gemfile(5)\. It also lets you know if the \fBruby\fR directive requirement has been met\. If \fBruby\fR directive doesn\'t match the running Ruby VM, it tells you what part does not\.
-.
+\fBplatform\fR lists all the platforms in your \fBGemfile\.lock\fR as well as the \fBruby\fR directive if applicable from your Gemfile(5)\. It also lets you know if the \fBruby\fR directive requirement has been met\. If \fBruby\fR directive doesn't match the running Ruby VM, it tells you what part does not\.
.SH "OPTIONS"
-.
.TP
\fB\-\-ruby\fR
-It will display the ruby directive information, so you don\'t have to parse it from the Gemfile(5)\.
-.
+It will display the ruby directive information, so you don't have to parse it from the Gemfile(5)\.
.SH "SEE ALSO"
-.
.IP "\(bu" 4
bundle\-lock(1) \fIbundle\-lock\.1\.html\fR
-.
.IP "" 0
diff --git a/lib/bundler/man/bundle-plugin.1 b/lib/bundler/man/bundle-plugin.1
index a231bb1e3d..cbdfac11b6 100644
--- a/lib/bundler/man/bundle-plugin.1
+++ b/lib/bundler/man/bundle-plugin.1
@@ -1,81 +1,58 @@
-.\" generated with Ronn/v0.7.3
-.\" http://github.com/rtomayko/ronn/tree/0.7.3
-.
-.TH "BUNDLE\-PLUGIN" "1" "January 2023" "" ""
-.
+.\" generated with nRonn/v0.11.1
+.\" https://github.com/n-ronn/nronn/tree/0.11.1
+.TH "BUNDLE\-PLUGIN" "1" "March 2024" ""
.SH "NAME"
\fBbundle\-plugin\fR \- Manage Bundler plugins
-.
.SH "SYNOPSIS"
-\fBbundle plugin\fR install PLUGINS [\-\-source=\fISOURCE\fR] [\-\-version=\fIversion\fR] [\-\-git|\-\-local_git=\fIgit\-url\fR] [\-\-branch=\fIbranch\fR|\-\-ref=\fIrev\fR]
-.
+\fBbundle plugin\fR install PLUGINS [\-\-source=\fISOURCE\fR] [\-\-version=\fIversion\fR] [\-\-git=\fIgit\-url\fR] [\-\-branch=\fIbranch\fR|\-\-ref=\fIrev\fR] [\-\-path=\fIpath\fR]
.br
\fBbundle plugin\fR uninstall PLUGINS
-.
.br
\fBbundle plugin\fR list
-.
.br
\fBbundle plugin\fR help [COMMAND]
-.
.SH "DESCRIPTION"
You can install, uninstall, and list plugin(s) with this command to extend functionalities of Bundler\.
-.
.SH "SUB\-COMMANDS"
-.
.SS "install"
Install the given plugin(s)\.
-.
-.IP "\(bu" 4
-\fBbundle plugin install bundler\-graph\fR: Install bundler\-graph gem from RubyGems\.org\. The global source, specified in source in Gemfile is ignored\.
-.
-.IP "\(bu" 4
-\fBbundle plugin install bundler\-graph \-\-source https://example\.com\fR: Install bundler\-graph gem from example\.com\. The global source, specified in source in Gemfile is not considered\.
-.
-.IP "\(bu" 4
-\fBbundle plugin install bundler\-graph \-\-version 0\.2\.1\fR: You can specify the version of the gem via \fB\-\-version\fR\.
-.
-.IP "\(bu" 4
-\fBbundle plugin install bundler\-graph \-\-git https://github\.com/rubygems/bundler\-graph\fR: Install bundler\-graph gem from Git repository\. \fB\-\-git\fR can be replaced with \fB\-\-local\-git\fR\. You cannot use both \fB\-\-git\fR and \fB\-\-local\-git\fR\. You can use standard Git URLs like:
-.
-.IP "\(bu" 4
+.TP
+\fBbundle plugin install bundler\-graph\fR
+Install bundler\-graph gem from globally configured sources (defaults to RubyGems\.org)\. The global source, specified in source in Gemfile is ignored\.
+.TP
+\fBbundle plugin install bundler\-graph \-\-source https://example\.com\fR
+Install bundler\-graph gem from example\.com\. The global source, specified in source in Gemfile is not considered\.
+.TP
+\fBbundle plugin install bundler\-graph \-\-version 0\.2\.1\fR
+You can specify the version of the gem via \fB\-\-version\fR\.
+.TP
+\fBbundle plugin install bundler\-graph \-\-git https://github\.com/rubygems/bundler\-graph\fR
+Install bundler\-graph gem from Git repository\. You can use standard Git URLs like:
+.IP
\fBssh://[user@]host\.xz[:port]/path/to/repo\.git\fR
-.
-.IP "\(bu" 4
+.br
\fBhttp[s]://host\.xz[:port]/path/to/repo\.git\fR
-.
-.IP "\(bu" 4
+.br
\fB/path/to/repo\fR
-.
-.IP "\(bu" 4
+.br
\fBfile:///path/to/repo\fR
-.
-.IP "" 0
-.
.IP
-When you specify \fB\-\-git\fR/\fB\-\-local\-git\fR, you can use \fB\-\-branch\fR or \fB\-\-ref\fR to specify any branch, tag, or commit hash (revision) to use\. When you specify both, only the latter is used\.
-.
-.IP "" 0
-.
+When you specify \fB\-\-git\fR, you can use \fB\-\-branch\fR or \fB\-\-ref\fR to specify any branch, tag, or commit hash (revision) to use\.
+.TP
+\fBbundle plugin install bundler\-graph \-\-path \.\./bundler\-graph\fR
+Install bundler\-graph gem from a local path\.
.SS "uninstall"
Uninstall the plugin(s) specified in PLUGINS\.
-.
.SS "list"
List the installed plugins and available commands\.
-.
.P
No options\.
-.
.SS "help"
Describe subcommands or one specific subcommand\.
-.
.P
No options\.
-.
.SH "SEE ALSO"
-.
.IP "\(bu" 4
How to write a Bundler plugin \fIhttps://bundler\.io/guides/bundler_plugins\.html\fR
-.
.IP "" 0
diff --git a/lib/bundler/man/bundle-plugin.1.ronn b/lib/bundler/man/bundle-plugin.1.ronn
index 4f234eeba7..b0a34660ea 100644
--- a/lib/bundler/man/bundle-plugin.1.ronn
+++ b/lib/bundler/man/bundle-plugin.1.ronn
@@ -4,7 +4,8 @@ bundle-plugin(1) -- Manage Bundler plugins
## SYNOPSIS
`bundle plugin` install PLUGINS [--source=<SOURCE>] [--version=<version>]
- [--git|--local_git=<git-url>] [--branch=<branch>|--ref=<rev>]<br>
+ [--git=<git-url>] [--branch=<branch>|--ref=<rev>]
+ [--path=<path>]<br>
`bundle plugin` uninstall PLUGINS<br>
`bundle plugin` list<br>
`bundle plugin` help [COMMAND]
@@ -20,7 +21,7 @@ You can install, uninstall, and list plugin(s) with this command to extend funct
Install the given plugin(s).
* `bundle plugin install bundler-graph`:
- Install bundler-graph gem from RubyGems.org. The global source, specified in source in Gemfile is ignored.
+ Install bundler-graph gem from globally configured sources (defaults to RubyGems.org). The global source, specified in source in Gemfile is ignored.
* `bundle plugin install bundler-graph --source https://example.com`:
Install bundler-graph gem from example.com. The global source, specified in source in Gemfile is not considered.
@@ -29,14 +30,17 @@ Install the given plugin(s).
You can specify the version of the gem via `--version`.
* `bundle plugin install bundler-graph --git https://github.com/rubygems/bundler-graph`:
- Install bundler-graph gem from Git repository. `--git` can be replaced with `--local-git`. You cannot use both `--git` and `--local-git`. You can use standard Git URLs like:
+ Install bundler-graph gem from Git repository. You can use standard Git URLs like:
- * `ssh://[user@]host.xz[:port]/path/to/repo.git`
- * `http[s]://host.xz[:port]/path/to/repo.git`
- * `/path/to/repo`
- * `file:///path/to/repo`
+ `ssh://[user@]host.xz[:port]/path/to/repo.git`<br>
+ `http[s]://host.xz[:port]/path/to/repo.git`<br>
+ `/path/to/repo`<br>
+ `file:///path/to/repo`
- When you specify `--git`/`--local-git`, you can use `--branch` or `--ref` to specify any branch, tag, or commit hash (revision) to use. When you specify both, only the latter is used.
+ When you specify `--git`, you can use `--branch` or `--ref` to specify any branch, tag, or commit hash (revision) to use.
+
+* `bundle plugin install bundler-graph --path ../bundler-graph`:
+ Install bundler-graph gem from a local path.
### uninstall
diff --git a/lib/bundler/man/bundle-pristine.1 b/lib/bundler/man/bundle-pristine.1
index 8f4bad3db6..faa04d7676 100644
--- a/lib/bundler/man/bundle-pristine.1
+++ b/lib/bundler/man/bundle-pristine.1
@@ -1,34 +1,23 @@
-.\" generated with Ronn/v0.7.3
-.\" http://github.com/rtomayko/ronn/tree/0.7.3
-.
-.TH "BUNDLE\-PRISTINE" "1" "January 2023" "" ""
-.
+.\" generated with nRonn/v0.11.1
+.\" https://github.com/n-ronn/nronn/tree/0.11.1
+.TH "BUNDLE\-PRISTINE" "1" "March 2024" ""
.SH "NAME"
\fBbundle\-pristine\fR \- Restores installed gems to their pristine condition
-.
.SH "SYNOPSIS"
\fBbundle pristine\fR
-.
.SH "DESCRIPTION"
\fBpristine\fR restores the installed gems in the bundle to their pristine condition using the local gem cache from RubyGems\. For git gems, a forced checkout will be performed\.
-.
.P
-For further explanation, \fBbundle pristine\fR ignores unpacked files on disk\. In other words, this command utilizes the local \fB\.gem\fR cache or the gem\'s git repository as if one were installing from scratch\.
-.
+For further explanation, \fBbundle pristine\fR ignores unpacked files on disk\. In other words, this command utilizes the local \fB\.gem\fR cache or the gem's git repository as if one were installing from scratch\.
.P
-Note: the Bundler gem cannot be restored to its original state with \fBpristine\fR\. One also cannot use \fBbundle pristine\fR on gems with a \'path\' option in the Gemfile, because bundler has no original copy it can restore from\.
-.
+Note: the Bundler gem cannot be restored to its original state with \fBpristine\fR\. One also cannot use \fBbundle pristine\fR on gems with a 'path' option in the Gemfile, because bundler has no original copy it can restore from\.
.P
When is it practical to use \fBbundle pristine\fR?
-.
.P
It comes in handy when a developer is debugging a gem\. \fBbundle pristine\fR is a great way to get rid of experimental changes to a gem that one may not want\.
-.
.P
Why use \fBbundle pristine\fR over \fBgem pristine \-\-all\fR?
-.
.P
Both commands are very similar\. For context: \fBbundle pristine\fR, without arguments, cleans all gems from the lockfile\. Meanwhile, \fBgem pristine \-\-all\fR cleans all installed gems for that Ruby version\.
-.
.P
If a developer forgets which gems in their project they might have been debugging, the Rubygems \fBgem pristine [GEMNAME]\fR command may be inconvenient\. One can avoid waiting for \fBgem pristine \-\-all\fR, and instead run \fBbundle pristine\fR\.
diff --git a/lib/bundler/man/bundle-remove.1 b/lib/bundler/man/bundle-remove.1
index 97a65016ac..3f8cbbd9b6 100644
--- a/lib/bundler/man/bundle-remove.1
+++ b/lib/bundler/man/bundle-remove.1
@@ -1,31 +1,21 @@
-.\" generated with Ronn/v0.7.3
-.\" http://github.com/rtomayko/ronn/tree/0.7.3
-.
-.TH "BUNDLE\-REMOVE" "1" "January 2023" "" ""
-.
+.\" generated with nRonn/v0.11.1
+.\" https://github.com/n-ronn/nronn/tree/0.11.1
+.TH "BUNDLE\-REMOVE" "1" "March 2024" ""
.SH "NAME"
\fBbundle\-remove\fR \- Removes gems from the Gemfile
-.
.SH "SYNOPSIS"
-\fBbundle remove [GEM [GEM \.\.\.]] [\-\-install]\fR
-.
+\fBbundle remove [GEM [GEM \|\.\|\.\|\.]] [\-\-install]\fR
.SH "DESCRIPTION"
Removes the given gems from the Gemfile while ensuring that the resulting Gemfile is still valid\. If a gem cannot be removed, a warning is printed\. If a gem is already absent from the Gemfile, and error is raised\.
-.
.SH "OPTIONS"
-.
.TP
\fB\-\-install\fR
Runs \fBbundle install\fR after the given gems have been removed from the Gemfile, which ensures that both the lockfile and the installed gems on disk are also updated to remove the given gem(s)\.
-.
.P
Example:
-.
.P
bundle remove rails
-.
.P
bundle remove rails rack
-.
.P
bundle remove rails rack \-\-install
diff --git a/lib/bundler/man/bundle-show.1 b/lib/bundler/man/bundle-show.1
index 82706d45f3..bc72c6e3b6 100644
--- a/lib/bundler/man/bundle-show.1
+++ b/lib/bundler/man/bundle-show.1
@@ -1,22 +1,15 @@
-.\" generated with Ronn/v0.7.3
-.\" http://github.com/rtomayko/ronn/tree/0.7.3
-.
-.TH "BUNDLE\-SHOW" "1" "January 2023" "" ""
-.
+.\" generated with nRonn/v0.11.1
+.\" https://github.com/n-ronn/nronn/tree/0.11.1
+.TH "BUNDLE\-SHOW" "1" "March 2024" ""
.SH "NAME"
\fBbundle\-show\fR \- Shows all the gems in your bundle, or the path to a gem
-.
.SH "SYNOPSIS"
\fBbundle show\fR [GEM] [\-\-paths]
-.
.SH "DESCRIPTION"
Without the [GEM] option, \fBshow\fR will print a list of the names and versions of all gems that are required by your [\fBGemfile(5)\fR][Gemfile(5)], sorted by name\.
-.
.P
Calling show with [GEM] will list the exact location of that gem on your machine\.
-.
.SH "OPTIONS"
-.
.TP
\fB\-\-paths\fR
List the paths of all gems that are required by your [\fBGemfile(5)\fR][Gemfile(5)], sorted by gem name\.
diff --git a/lib/bundler/man/bundle-update.1 b/lib/bundler/man/bundle-update.1
index 65448f4806..d1284c2e72 100644
--- a/lib/bundler/man/bundle-update.1
+++ b/lib/bundler/man/bundle-update.1
@@ -1,114 +1,81 @@
-.\" generated with Ronn/v0.7.3
-.\" http://github.com/rtomayko/ronn/tree/0.7.3
-.
-.TH "BUNDLE\-UPDATE" "1" "January 2023" "" ""
-.
+.\" generated with nRonn/v0.11.1
+.\" https://github.com/n-ronn/nronn/tree/0.11.1
+.TH "BUNDLE\-UPDATE" "1" "March 2024" ""
.SH "NAME"
\fBbundle\-update\fR \- Update your gems to the latest available versions
-.
.SH "SYNOPSIS"
\fBbundle update\fR \fI*gems\fR [\-\-all] [\-\-group=NAME] [\-\-source=NAME] [\-\-local] [\-\-ruby] [\-\-bundler[=VERSION]] [\-\-full\-index] [\-\-jobs=JOBS] [\-\-quiet] [\-\-patch|\-\-minor|\-\-major] [\-\-redownload] [\-\-strict] [\-\-conservative]
-.
.SH "DESCRIPTION"
Update the gems specified (all gems, if \fB\-\-all\fR flag is used), ignoring the previously installed gems specified in the \fBGemfile\.lock\fR\. In general, you should use bundle install(1) \fIbundle\-install\.1\.html\fR to install the same exact gems and versions across machines\.
-.
.P
You would use \fBbundle update\fR to explicitly update the version of a gem\.
-.
.SH "OPTIONS"
-.
.TP
\fB\-\-all\fR
Update all gems specified in Gemfile\.
-.
.TP
\fB\-\-group=<name>\fR, \fB\-g=[<name>]\fR
Only update the gems in the specified group\. For instance, you can update all gems in the development group with \fBbundle update \-\-group development\fR\. You can also call \fBbundle update rails \-\-group test\fR to update the rails gem and all gems in the test group, for example\.
-.
.TP
\fB\-\-source=<name>\fR
The name of a \fB:git\fR or \fB:path\fR source used in the Gemfile(5)\. For instance, with a \fB:git\fR source of \fBhttp://github\.com/rails/rails\.git\fR, you would call \fBbundle update \-\-source rails\fR
-.
.TP
\fB\-\-local\fR
Do not attempt to fetch gems remotely and use the gem cache instead\.
-.
.TP
\fB\-\-ruby\fR
Update the locked version of Ruby to the current version of Ruby\.
-.
.TP
\fB\-\-bundler\fR
Update the locked version of bundler to the invoked bundler version\.
-.
.TP
\fB\-\-full\-index\fR
Fall back to using the single\-file index of all gems\.
-.
.TP
\fB\-\-jobs=[<number>]\fR, \fB\-j[<number>]\fR
Specify the number of jobs to run in parallel\. The default is the number of available processors\.
-.
.TP
\fB\-\-retry=[<number>]\fR
Retry failed network or git requests for \fInumber\fR times\.
-.
.TP
\fB\-\-quiet\fR
Only output warnings and errors\.
-.
.TP
\fB\-\-redownload\fR
Force downloading every gem\.
-.
.TP
\fB\-\-patch\fR
Prefer updating only to next patch version\.
-.
.TP
\fB\-\-minor\fR
Prefer updating only to next minor version\.
-.
.TP
\fB\-\-major\fR
Prefer updating to next major version (default)\.
-.
.TP
\fB\-\-strict\fR
Do not allow any gem to be updated past latest \fB\-\-patch\fR | \fB\-\-minor\fR | \fB\-\-major\fR\.
-.
.TP
\fB\-\-conservative\fR
Use bundle install conservative update behavior and do not allow indirect dependencies to be updated\.
-.
.SH "UPDATING ALL GEMS"
If you run \fBbundle update \-\-all\fR, bundler will ignore any previously installed gems and resolve all dependencies again based on the latest versions of all gems available in the sources\.
-.
.P
Consider the following Gemfile(5):
-.
.IP "" 4
-.
.nf
-
source "https://rubygems\.org"
gem "rails", "3\.0\.0\.rc"
gem "nokogiri"
-.
.fi
-.
.IP "" 0
-.
.P
When you run bundle install(1) \fIbundle\-install\.1\.html\fR the first time, bundler will resolve all of the dependencies, all the way down, and install what you need:
-.
.IP "" 4
-.
.nf
-
-Fetching gem metadata from https://rubygems\.org/\.\.\.\.\.\.\.\.\.
-Resolving dependencies\.\.\.
+Fetching gem metadata from https://rubygems\.org/\|\.\|\.\|\.\|\.\|\.\|\.\|\.\|\.\|\.
+Resolving dependencies\|\.\|\.\|\.
Installing builder 2\.1\.2
Installing abstract 1\.0\.0
Installing rack 1\.2\.8
@@ -138,55 +105,36 @@ Installing nokogiri 1\.6\.5
Bundle complete! 2 Gemfile dependencies, 26 gems total\.
Use `bundle show [gemname]` to see where a bundled gem is installed\.
-.
.fi
-.
.IP "" 0
-.
.P
As you can see, even though you have two gems in the Gemfile(5), your application needs 26 different gems in order to run\. Bundler remembers the exact versions it installed in \fBGemfile\.lock\fR\. The next time you run bundle install(1) \fIbundle\-install\.1\.html\fR, bundler skips the dependency resolution and installs the same gems as it installed last time\.
-.
.P
-After checking in the \fBGemfile\.lock\fR into version control and cloning it on another machine, running bundle install(1) \fIbundle\-install\.1\.html\fR will \fIstill\fR install the gems that you installed last time\. You don\'t need to worry that a new release of \fBerubis\fR or \fBmail\fR changes the gems you use\.
-.
+After checking in the \fBGemfile\.lock\fR into version control and cloning it on another machine, running bundle install(1) \fIbundle\-install\.1\.html\fR will \fIstill\fR install the gems that you installed last time\. You don't need to worry that a new release of \fBerubis\fR or \fBmail\fR changes the gems you use\.
.P
However, from time to time, you might want to update the gems you are using to the newest versions that still match the gems in your Gemfile(5)\.
-.
.P
To do this, run \fBbundle update \-\-all\fR, which will ignore the \fBGemfile\.lock\fR, and resolve all the dependencies again\. Keep in mind that this process can result in a significantly different set of the 25 gems, based on the requirements of new gems that the gem authors released since the last time you ran \fBbundle update \-\-all\fR\.
-.
.SH "UPDATING A LIST OF GEMS"
Sometimes, you want to update a single gem in the Gemfile(5), and leave the rest of the gems that you specified locked to the versions in the \fBGemfile\.lock\fR\.
-.
.P
For instance, in the scenario above, imagine that \fBnokogiri\fR releases version \fB1\.4\.4\fR, and you want to update it \fIwithout\fR updating Rails and all of its dependencies\. To do this, run \fBbundle update nokogiri\fR\.
-.
.P
Bundler will update \fBnokogiri\fR and any of its dependencies, but leave alone Rails and its dependencies\.
-.
.SH "OVERLAPPING DEPENDENCIES"
Sometimes, multiple gems declared in your Gemfile(5) are satisfied by the same second\-level dependency\. For instance, consider the case of \fBthin\fR and \fBrack\-perftools\-profiler\fR\.
-.
.IP "" 4
-.
.nf
-
source "https://rubygems\.org"
gem "thin"
gem "rack\-perftools\-profiler"
-.
.fi
-.
.IP "" 0
-.
.P
The \fBthin\fR gem depends on \fBrack >= 1\.0\fR, while \fBrack\-perftools\-profiler\fR depends on \fBrack ~> 1\.0\fR\. If you run bundle install, you get:
-.
.IP "" 4
-.
.nf
-
Fetching source index for https://rubygems\.org/
Installing daemons (1\.1\.0)
Installing eventmachine (0\.12\.10) with native extensions
@@ -196,199 +144,132 @@ Installing rack (1\.2\.1)
Installing rack\-perftools_profiler (0\.0\.2)
Installing thin (1\.2\.7) with native extensions
Using bundler (1\.0\.0\.rc\.3)
-.
.fi
-.
.IP "" 0
-.
.P
-In this case, the two gems have their own set of dependencies, but they share \fBrack\fR in common\. If you run \fBbundle update thin\fR, bundler will update \fBdaemons\fR, \fBeventmachine\fR and \fBrack\fR, which are dependencies of \fBthin\fR, but not \fBopen4\fR or \fBperftools\.rb\fR, which are dependencies of \fBrack\-perftools_profiler\fR\. Note that \fBbundle update thin\fR will update \fBrack\fR even though it\'s \fIalso\fR a dependency of \fBrack\-perftools_profiler\fR\.
-.
+In this case, the two gems have their own set of dependencies, but they share \fBrack\fR in common\. If you run \fBbundle update thin\fR, bundler will update \fBdaemons\fR, \fBeventmachine\fR and \fBrack\fR, which are dependencies of \fBthin\fR, but not \fBopen4\fR or \fBperftools\.rb\fR, which are dependencies of \fBrack\-perftools_profiler\fR\. Note that \fBbundle update thin\fR will update \fBrack\fR even though it's \fIalso\fR a dependency of \fBrack\-perftools_profiler\fR\.
.P
In short, by default, when you update a gem using \fBbundle update\fR, bundler will update all dependencies of that gem, including those that are also dependencies of another gem\.
-.
.P
To prevent updating indirect dependencies, prior to version 1\.14 the only option was the \fBCONSERVATIVE UPDATING\fR behavior in bundle install(1) \fIbundle\-install\.1\.html\fR:
-.
.P
In this scenario, updating the \fBthin\fR version manually in the Gemfile(5), and then running bundle install(1) \fIbundle\-install\.1\.html\fR will only update \fBdaemons\fR and \fBeventmachine\fR, but not \fBrack\fR\. For more information, see the \fBCONSERVATIVE UPDATING\fR section of bundle install(1) \fIbundle\-install\.1\.html\fR\.
-.
.P
Starting with 1\.14, specifying the \fB\-\-conservative\fR option will also prevent indirect dependencies from being updated\.
-.
.SH "PATCH LEVEL OPTIONS"
Version 1\.14 introduced 4 patch\-level options that will influence how gem versions are resolved\. One of the following options can be used: \fB\-\-patch\fR, \fB\-\-minor\fR or \fB\-\-major\fR\. \fB\-\-strict\fR can be added to further influence resolution\.
-.
.TP
\fB\-\-patch\fR
Prefer updating only to next patch version\.
-.
.TP
\fB\-\-minor\fR
Prefer updating only to next minor version\.
-.
.TP
\fB\-\-major\fR
Prefer updating to next major version (default)\.
-.
.TP
\fB\-\-strict\fR
Do not allow any gem to be updated past latest \fB\-\-patch\fR | \fB\-\-minor\fR | \fB\-\-major\fR\.
-.
.P
-When Bundler is resolving what versions to use to satisfy declared requirements in the Gemfile or in parent gems, it looks up all available versions, filters out any versions that don\'t satisfy the requirement, and then, by default, sorts them from newest to oldest, considering them in that order\.
-.
+When Bundler is resolving what versions to use to satisfy declared requirements in the Gemfile or in parent gems, it looks up all available versions, filters out any versions that don't satisfy the requirement, and then, by default, sorts them from newest to oldest, considering them in that order\.
.P
Providing one of the patch level options (e\.g\. \fB\-\-patch\fR) changes the sort order of the satisfying versions, causing Bundler to consider the latest \fB\-\-patch\fR or \fB\-\-minor\fR version available before other versions\. Note that versions outside the stated patch level could still be resolved to if necessary to find a suitable dependency graph\.
-.
.P
-For example, if gem \'foo\' is locked at 1\.0\.2, with no gem requirement defined in the Gemfile, and versions 1\.0\.3, 1\.0\.4, 1\.1\.0, 1\.1\.1, 2\.0\.0 all exist, the default order of preference by default (\fB\-\-major\fR) will be "2\.0\.0, 1\.1\.1, 1\.1\.0, 1\.0\.4, 1\.0\.3, 1\.0\.2"\.
-.
+For example, if gem 'foo' is locked at 1\.0\.2, with no gem requirement defined in the Gemfile, and versions 1\.0\.3, 1\.0\.4, 1\.1\.0, 1\.1\.1, 2\.0\.0 all exist, the default order of preference by default (\fB\-\-major\fR) will be "2\.0\.0, 1\.1\.1, 1\.1\.0, 1\.0\.4, 1\.0\.3, 1\.0\.2"\.
.P
If the \fB\-\-patch\fR option is used, the order of preference will change to "1\.0\.4, 1\.0\.3, 1\.0\.2, 1\.1\.1, 1\.1\.0, 2\.0\.0"\.
-.
.P
If the \fB\-\-minor\fR option is used, the order of preference will change to "1\.1\.1, 1\.1\.0, 1\.0\.4, 1\.0\.3, 1\.0\.2, 2\.0\.0"\.
-.
.P
Combining the \fB\-\-strict\fR option with any of the patch level options will remove any versions beyond the scope of the patch level option, to ensure that no gem is updated that far\.
-.
.P
To continue the previous example, if both \fB\-\-patch\fR and \fB\-\-strict\fR options are used, the available versions for resolution would be "1\.0\.4, 1\.0\.3, 1\.0\.2"\. If \fB\-\-minor\fR and \fB\-\-strict\fR are used, it would be "1\.1\.1, 1\.1\.0, 1\.0\.4, 1\.0\.3, 1\.0\.2"\.
-.
.P
-Gem requirements as defined in the Gemfile will still be the first determining factor for what versions are available\. If the gem requirement for \fBfoo\fR in the Gemfile is \'~> 1\.0\', that will accomplish the same thing as providing the \fB\-\-minor\fR and \fB\-\-strict\fR options\.
-.
+Gem requirements as defined in the Gemfile will still be the first determining factor for what versions are available\. If the gem requirement for \fBfoo\fR in the Gemfile is '~> 1\.0', that will accomplish the same thing as providing the \fB\-\-minor\fR and \fB\-\-strict\fR options\.
.SH "PATCH LEVEL EXAMPLES"
Given the following gem specifications:
-.
.IP "" 4
-.
.nf
-
foo 1\.4\.3, requires: ~> bar 2\.0
foo 1\.4\.4, requires: ~> bar 2\.0
foo 1\.4\.5, requires: ~> bar 2\.1
foo 1\.5\.0, requires: ~> bar 2\.1
foo 1\.5\.1, requires: ~> bar 3\.0
bar with versions 2\.0\.3, 2\.0\.4, 2\.1\.0, 2\.1\.1, 3\.0\.0
-.
.fi
-.
.IP "" 0
-.
.P
Gemfile:
-.
.IP "" 4
-.
.nf
-
-gem \'foo\'
-.
+gem 'foo'
.fi
-.
.IP "" 0
-.
.P
Gemfile\.lock:
-.
.IP "" 4
-.
.nf
-
foo (1\.4\.3)
bar (~> 2\.0)
bar (2\.0\.3)
-.
.fi
-.
.IP "" 0
-.
.P
Cases:
-.
.IP "" 4
-.
.nf
-
# Command Line Result
\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-
-1 bundle update \-\-patch \'foo 1\.4\.5\', \'bar 2\.1\.1\'
-2 bundle update \-\-patch foo \'foo 1\.4\.5\', \'bar 2\.1\.1\'
-3 bundle update \-\-minor \'foo 1\.5\.1\', \'bar 3\.0\.0\'
-4 bundle update \-\-minor \-\-strict \'foo 1\.5\.0\', \'bar 2\.1\.1\'
-5 bundle update \-\-patch \-\-strict \'foo 1\.4\.4\', \'bar 2\.0\.4\'
-.
+1 bundle update \-\-patch 'foo 1\.4\.5', 'bar 2\.1\.1'
+2 bundle update \-\-patch foo 'foo 1\.4\.5', 'bar 2\.1\.1'
+3 bundle update \-\-minor 'foo 1\.5\.1', 'bar 3\.0\.0'
+4 bundle update \-\-minor \-\-strict 'foo 1\.5\.0', 'bar 2\.1\.1'
+5 bundle update \-\-patch \-\-strict 'foo 1\.4\.4', 'bar 2\.0\.4'
.fi
-.
.IP "" 0
-.
.P
In case 1, bar is upgraded to 2\.1\.1, a minor version increase, because the dependency from foo 1\.4\.5 required it\.
-.
.P
-In case 2, only foo is requested to be unlocked, but bar is also allowed to move because it\'s not a declared dependency in the Gemfile\.
-.
+In case 2, only foo is requested to be unlocked, but bar is also allowed to move because it's not a declared dependency in the Gemfile\.
.P
In case 3, bar goes up a whole major release, because a minor increase is preferred now for foo, and when it goes to 1\.5\.1, it requires 3\.0\.0 of bar\.
-.
.P
-In case 4, foo is preferred up to a minor version, but 1\.5\.1 won\'t work because the \-\-strict flag removes bar 3\.0\.0 from consideration since it\'s a major increment\.
-.
+In case 4, foo is preferred up to a minor version, but 1\.5\.1 won't work because the \-\-strict flag removes bar 3\.0\.0 from consideration since it's a major increment\.
.P
In case 5, both foo and bar have any minor or major increments removed from consideration because of the \-\-strict flag, so the most they can move is up to 1\.4\.4 and 2\.0\.4\.
-.
.SH "RECOMMENDED WORKFLOW"
In general, when working with an application managed with bundler, you should use the following workflow:
-.
.IP "\(bu" 4
After you create your Gemfile(5) for the first time, run
-.
.IP
$ bundle install
-.
.IP "\(bu" 4
Check the resulting \fBGemfile\.lock\fR into version control
-.
.IP
$ git add Gemfile\.lock
-.
.IP "\(bu" 4
When checking out this repository on another development machine, run
-.
.IP
$ bundle install
-.
.IP "\(bu" 4
When checking out this repository on a deployment machine, run
-.
.IP
$ bundle install \-\-deployment
-.
.IP "\(bu" 4
After changing the Gemfile(5) to reflect a new or update dependency, run
-.
.IP
$ bundle install
-.
.IP "\(bu" 4
Make sure to check the updated \fBGemfile\.lock\fR into version control
-.
.IP
$ git add Gemfile\.lock
-.
.IP "\(bu" 4
If bundle install(1) \fIbundle\-install\.1\.html\fR reports a conflict, manually update the specific gems that you changed in the Gemfile(5)
-.
.IP
$ bundle update rails thin
-.
.IP "\(bu" 4
If you want to update all the gems to the latest possible versions that still match the gems listed in the Gemfile(5), run
-.
.IP
$ bundle update \-\-all
-.
.IP "" 0
diff --git a/lib/bundler/man/bundle-version.1 b/lib/bundler/man/bundle-version.1
index bb03e8b5d6..05905e1347 100644
--- a/lib/bundler/man/bundle-version.1
+++ b/lib/bundler/man/bundle-version.1
@@ -1,35 +1,22 @@
-.\" generated with Ronn/v0.7.3
-.\" http://github.com/rtomayko/ronn/tree/0.7.3
-.
-.TH "BUNDLE\-VERSION" "1" "January 2023" "" ""
-.
+.\" generated with nRonn/v0.11.1
+.\" https://github.com/n-ronn/nronn/tree/0.11.1
+.TH "BUNDLE\-VERSION" "1" "March 2024" ""
.SH "NAME"
\fBbundle\-version\fR \- Prints Bundler version information
-.
.SH "SYNOPSIS"
\fBbundle version\fR
-.
.SH "DESCRIPTION"
Prints Bundler version information\.
-.
.SH "OPTIONS"
No options\.
-.
.SH "EXAMPLE"
Print the version of Bundler with build date and commit hash of the in the Git source\.
-.
.IP "" 4
-.
.nf
-
bundle version
-.
.fi
-.
.IP "" 0
-.
.P
shows \fBBundler version 2\.3\.21 (2022\-08\-24 commit d54be5fdd8)\fR for example\.
-.
.P
cf\. \fBbundle \-\-version\fR shows \fBBundler version 2\.3\.21\fR\.
diff --git a/lib/bundler/man/bundle-viz.1 b/lib/bundler/man/bundle-viz.1
index 23fb95b738..681563cd4c 100644
--- a/lib/bundler/man/bundle-viz.1
+++ b/lib/bundler/man/bundle-viz.1
@@ -1,41 +1,29 @@
-.\" generated with Ronn/v0.7.3
-.\" http://github.com/rtomayko/ronn/tree/0.7.3
-.
-.TH "BUNDLE\-VIZ" "1" "January 2023" "" ""
-.
+.\" generated with nRonn/v0.11.1
+.\" https://github.com/n-ronn/nronn/tree/0.11.1
+.TH "BUNDLE\-VIZ" "1" "March 2024" ""
.SH "NAME"
\fBbundle\-viz\fR \- Generates a visual dependency graph for your Gemfile
-.
.SH "SYNOPSIS"
\fBbundle viz\fR [\-\-file=FILE] [\-\-format=FORMAT] [\-\-requirements] [\-\-version] [\-\-without=GROUP GROUP]
-.
.SH "DESCRIPTION"
\fBviz\fR generates a PNG file of the current \fBGemfile(5)\fR as a dependency graph\. \fBviz\fR requires the ruby\-graphviz gem (and its dependencies)\.
-.
.P
The associated gems must also be installed via \fBbundle install(1)\fR \fIbundle\-install\.1\.html\fR\.
-.
.P
\fBviz\fR command was deprecated in Bundler 2\.2\. Use bundler\-graph plugin \fIhttps://github\.com/rubygems/bundler\-graph\fR instead\.
-.
.SH "OPTIONS"
-.
.TP
\fB\-\-file\fR, \fB\-f\fR
The name to use for the generated file\. See \fB\-\-format\fR option
-.
.TP
\fB\-\-format\fR, \fB\-F\fR
-This is output format option\. Supported format is png, jpg, svg, dot \.\.\.
-.
+This is output format option\. Supported format is png, jpg, svg, dot \|\.\|\.\|\.
.TP
\fB\-\-requirements\fR, \fB\-R\fR
Set to show the version of each required dependency\.
-.
.TP
\fB\-\-version\fR, \fB\-v\fR
Set to show each gem version\.
-.
.TP
\fB\-\-without\fR, \fB\-W\fR
Exclude gems that are part of the specified named group\.
diff --git a/lib/bundler/man/bundle.1 b/lib/bundler/man/bundle.1
index 39f3807f30..1d2c780060 100644
--- a/lib/bundler/man/bundle.1
+++ b/lib/bundler/man/bundle.1
@@ -1,141 +1,102 @@
-.\" generated with Ronn/v0.7.3
-.\" http://github.com/rtomayko/ronn/tree/0.7.3
-.
-.TH "BUNDLE" "1" "January 2023" "" ""
-.
+.\" generated with nRonn/v0.11.1
+.\" https://github.com/n-ronn/nronn/tree/0.11.1
+.TH "BUNDLE" "1" "March 2024" ""
.SH "NAME"
\fBbundle\fR \- Ruby Dependency Management
-.
.SH "SYNOPSIS"
\fBbundle\fR COMMAND [\-\-no\-color] [\-\-verbose] [ARGS]
-.
.SH "DESCRIPTION"
-Bundler manages an \fBapplication\'s dependencies\fR through its entire life across many machines systematically and repeatably\.
-.
+Bundler manages an \fBapplication's dependencies\fR through its entire life across many machines systematically and repeatably\.
.P
See the bundler website \fIhttps://bundler\.io\fR for information on getting started, and Gemfile(5) for more information on the \fBGemfile\fR format\.
-.
.SH "OPTIONS"
-.
.TP
\fB\-\-no\-color\fR
Print all output without color
-.
.TP
\fB\-\-retry\fR, \fB\-r\fR
Specify the number of times you wish to attempt network commands
-.
.TP
\fB\-\-verbose\fR, \fB\-V\fR
Print out additional logging information
-.
.SH "BUNDLE COMMANDS"
We divide \fBbundle\fR subcommands into primary commands and utilities:
-.
.SH "PRIMARY COMMANDS"
-.
.TP
\fBbundle install(1)\fR \fIbundle\-install\.1\.html\fR
Install the gems specified by the \fBGemfile\fR or \fBGemfile\.lock\fR
-.
.TP
\fBbundle update(1)\fR \fIbundle\-update\.1\.html\fR
Update dependencies to their latest versions
-.
.TP
\fBbundle cache(1)\fR \fIbundle\-cache\.1\.html\fR
Package the \.gem files required by your application into the \fBvendor/cache\fR directory (aliases: \fBbundle package\fR, \fBbundle pack\fR)
-.
.TP
\fBbundle exec(1)\fR \fIbundle\-exec\.1\.html\fR
Execute a script in the current bundle
-.
.TP
\fBbundle config(1)\fR \fIbundle\-config\.1\.html\fR
Specify and read configuration options for Bundler
-.
.TP
\fBbundle help(1)\fR \fIbundle\-help\.1\.html\fR
Display detailed help for each subcommand
-.
.SH "UTILITIES"
-.
.TP
\fBbundle add(1)\fR \fIbundle\-add\.1\.html\fR
Add the named gem to the Gemfile and run \fBbundle install\fR
-.
.TP
\fBbundle binstubs(1)\fR \fIbundle\-binstubs\.1\.html\fR
Generate binstubs for executables in a gem
-.
.TP
\fBbundle check(1)\fR \fIbundle\-check\.1\.html\fR
Determine whether the requirements for your application are installed and available to Bundler
-.
.TP
\fBbundle show(1)\fR \fIbundle\-show\.1\.html\fR
Show the source location of a particular gem in the bundle
-.
.TP
\fBbundle outdated(1)\fR \fIbundle\-outdated\.1\.html\fR
Show all of the outdated gems in the current bundle
-.
.TP
\fBbundle console(1)\fR (deprecated)
Start an IRB session in the current bundle
-.
.TP
\fBbundle open(1)\fR \fIbundle\-open\.1\.html\fR
Open an installed gem in the editor
-.
.TP
\fBbundle lock(1)\fR \fIbundle\-lock\.1\.html\fR
Generate a lockfile for your dependencies
-.
.TP
\fBbundle viz(1)\fR \fIbundle\-viz\.1\.html\fR (deprecated)
Generate a visual representation of your dependencies
-.
.TP
\fBbundle init(1)\fR \fIbundle\-init\.1\.html\fR
Generate a simple \fBGemfile\fR, placed in the current directory
-.
.TP
\fBbundle gem(1)\fR \fIbundle\-gem\.1\.html\fR
Create a simple gem, suitable for development with Bundler
-.
.TP
\fBbundle platform(1)\fR \fIbundle\-platform\.1\.html\fR
Display platform compatibility information
-.
.TP
\fBbundle clean(1)\fR \fIbundle\-clean\.1\.html\fR
Clean up unused gems in your Bundler directory
-.
.TP
\fBbundle doctor(1)\fR \fIbundle\-doctor\.1\.html\fR
Display warnings about common problems
-.
.TP
\fBbundle remove(1)\fR \fIbundle\-remove\.1\.html\fR
Removes gems from the Gemfile
-.
.TP
\fBbundle plugin(1)\fR \fIbundle\-plugin\.1\.html\fR
Manage Bundler plugins
-.
.TP
\fBbundle version(1)\fR \fIbundle\-version\.1\.html\fR
Prints Bundler version information
-.
.SH "PLUGINS"
-When running a command that isn\'t listed in PRIMARY COMMANDS or UTILITIES, Bundler will try to find an executable on your path named \fBbundler\-<command>\fR and execute it, passing down any extra arguments to it\.
-.
+When running a command that isn't listed in PRIMARY COMMANDS or UTILITIES, Bundler will try to find an executable on your path named \fBbundler\-<command>\fR and execute it, passing down any extra arguments to it\.
.SH "OBSOLETE"
These commands are obsolete and should no longer be used:
-.
.IP "\(bu" 4
\fBbundle inject(1)\fR
-.
.IP "" 0
diff --git a/lib/bundler/man/gemfile.5 b/lib/bundler/man/gemfile.5
index 740a01e0cc..39503f22a6 100644
--- a/lib/bundler/man/gemfile.5
+++ b/lib/bundler/man/gemfile.5
@@ -1,215 +1,143 @@
-.\" generated with Ronn/v0.7.3
-.\" http://github.com/rtomayko/ronn/tree/0.7.3
-.
-.TH "GEMFILE" "5" "January 2023" "" ""
-.
+.\" generated with nRonn/v0.11.1
+.\" https://github.com/n-ronn/nronn/tree/0.11.1
+.TH "GEMFILE" "5" "March 2024" ""
.SH "NAME"
\fBGemfile\fR \- A format for describing gem dependencies for Ruby programs
-.
.SH "SYNOPSIS"
A \fBGemfile\fR describes the gem dependencies required to execute associated Ruby code\.
-.
.P
Place the \fBGemfile\fR in the root of the directory containing the associated code\. For instance, in a Rails application, place the \fBGemfile\fR in the same directory as the \fBRakefile\fR\.
-.
.SH "SYNTAX"
A \fBGemfile\fR is evaluated as Ruby code, in a context which makes available a number of methods used to describe the gem requirements\.
-.
.SH "GLOBAL SOURCE"
At the top of the \fBGemfile\fR, add a single line for the \fBRubyGems\fR source that contains the gems listed in the \fBGemfile\fR\.
-.
.IP "" 4
-.
.nf
-
source "https://rubygems\.org"
-.
.fi
-.
.IP "" 0
-.
.P
You can add only one global source\. In Bundler 1\.13, adding multiple global sources was deprecated\. The \fBsource\fR \fBMUST\fR be a valid RubyGems repository\.
-.
.P
To use more than one source of RubyGems, you should use \fI\fBsource\fR block\fR\.
-.
.P
A source is checked for gems following the heuristics described in \fISOURCE PRIORITY\fR\.
-.
.P
\fBNote about a behavior of the feature deprecated in Bundler 1\.13\fR: If a gem is found in more than one global source, Bundler will print a warning after installing the gem indicating which source was used, and listing the other sources where the gem is available\. A specific source can be selected for gems that need to use a non\-standard repository, suppressing this warning, by using the \fI\fB:source\fR option\fR or \fBsource\fR block\.
-.
.SS "CREDENTIALS"
Some gem sources require a username and password\. Use bundle config(1) \fIbundle\-config\.1\.html\fR to set the username and password for any of the sources that need it\. The command must be run once on each computer that will install the Gemfile, but this keeps the credentials from being stored in plain text in version control\.
-.
.IP "" 4
-.
.nf
-
bundle config gems\.example\.com user:password
-.
.fi
-.
.IP "" 0
-.
.P
For some sources, like a company Gemfury account, it may be easier to include the credentials in the Gemfile as part of the source URL\.
-.
.IP "" 4
-.
.nf
-
source "https://user:password@gems\.example\.com"
-.
.fi
-.
.IP "" 0
-.
.P
Credentials in the source URL will take precedence over credentials set using \fBconfig\fR\.
-.
.SH "RUBY"
If your application requires a specific Ruby version or engine, specify your requirements using the \fBruby\fR method, with the following arguments\. All parameters are \fBOPTIONAL\fR unless otherwise specified\.
-.
.SS "VERSION (required)"
The version of Ruby that your application requires\. If your application requires an alternate Ruby engine, such as JRuby, TruffleRuby, etc\., this should be the Ruby version that the engine is compatible with\.
-.
.IP "" 4
-.
.nf
-
ruby "3\.1\.2"
-.
.fi
-.
.IP "" 0
-.
+.P
+If you wish to derive your Ruby version from a version file (ie \.ruby\-version), you can use the \fBfile\fR option instead\.
+.IP "" 4
+.nf
+ruby file: "\.ruby\-version"
+.fi
+.IP "" 0
+.P
+The version file should conform to any of the following formats:
+.IP "\(bu" 4
+\fB3\.1\.2\fR (\.ruby\-version)
+.IP "\(bu" 4
+\fBruby 3\.1\.2\fR (\.tool\-versions, read: https://asdf\-vm\.com/manage/configuration\.html#tool\-versions)
+.IP "" 0
.SS "ENGINE"
Each application \fImay\fR specify a Ruby engine\. If an engine is specified, an engine version \fImust\fR also be specified\.
-.
.P
-What exactly is an Engine? \- A Ruby engine is an implementation of the Ruby language\.
-.
+What exactly is an Engine?
+.IP "\(bu" 4
+A Ruby engine is an implementation of the Ruby language\.
.IP "\(bu" 4
-For background: the reference or original implementation of the Ruby programming language is called Matz\'s Ruby Interpreter \fIhttps://en\.wikipedia\.org/wiki/Ruby_MRI\fR, or MRI for short\. This is named after Ruby creator Yukihiro Matsumoto, also known as Matz\. MRI is also known as CRuby, because it is written in C\. MRI is the most widely used Ruby engine\.
-.
+For background: the reference or original implementation of the Ruby programming language is called Matz's Ruby Interpreter \fIhttps://en\.wikipedia\.org/wiki/Ruby_MRI\fR, or MRI for short\. This is named after Ruby creator Yukihiro Matsumoto, also known as Matz\. MRI is also known as CRuby, because it is written in C\. MRI is the most widely used Ruby engine\.
.IP "\(bu" 4
-Other implementations \fIhttps://www\.ruby\-lang\.org/en/about/\fR of Ruby exist\. Some of the more well\-known implementations include JRuby \fIhttp://jruby\.org/\fR and TruffleRuby \fIhttps://www\.graalvm\.org/ruby/\fR\. Rubinius is an alternative implementation of Ruby written in Ruby\. JRuby is an implementation of Ruby on the JVM, short for Java Virtual Machine\. TruffleRuby is a Ruby implementation on the GraalVM, a language toolkit built on the JVM\.
-.
+Other implementations \fIhttps://www\.ruby\-lang\.org/en/about/\fR of Ruby exist\. Some of the more well\-known implementations include JRuby \fIhttps://www\.jruby\.org/\fR and TruffleRuby \fIhttps://www\.graalvm\.org/ruby/\fR\. Rubinius is an alternative implementation of Ruby written in Ruby\. JRuby is an implementation of Ruby on the JVM, short for Java Virtual Machine\. TruffleRuby is a Ruby implementation on the GraalVM, a language toolkit built on the JVM\.
.IP "" 0
-.
.SS "ENGINE VERSION"
Each application \fImay\fR specify a Ruby engine version\. If an engine version is specified, an engine \fImust\fR also be specified\. If the engine is "ruby" the engine version specified \fImust\fR match the Ruby version\.
-.
.IP "" 4
-.
.nf
-
ruby "2\.6\.8", engine: "jruby", engine_version: "9\.3\.8\.0"
-.
.fi
-.
.IP "" 0
-.
.SS "PATCHLEVEL"
Each application \fImay\fR specify a Ruby patchlevel\. Specifying the patchlevel has been meaningless since Ruby 2\.1\.0 was released as the patchlevel is now uniquely determined by a combination of major, minor, and teeny version numbers\.
-.
.P
This option was implemented in Bundler 1\.4\.0 for Ruby 2\.0 or earlier\.
-.
.IP "" 4
-.
.nf
-
ruby "3\.1\.2", patchlevel: "20"
-.
.fi
-.
.IP "" 0
-.
.SH "GEMS"
Specify gem requirements using the \fBgem\fR method, with the following arguments\. All parameters are \fBOPTIONAL\fR unless otherwise specified\.
-.
.SS "NAME (required)"
For each gem requirement, list a single \fIgem\fR line\.
-.
.IP "" 4
-.
.nf
-
gem "nokogiri"
-.
.fi
-.
.IP "" 0
-.
.SS "VERSION"
Each \fIgem\fR \fBMAY\fR have one or more version specifiers\.
-.
.IP "" 4
-.
.nf
-
gem "nokogiri", ">= 1\.4\.2"
gem "RedCloth", ">= 4\.1\.0", "< 4\.2\.0"
-.
.fi
-.
.IP "" 0
-.
.SS "REQUIRE AS"
Each \fIgem\fR \fBMAY\fR specify files that should be used when autorequiring via \fBBundler\.require\fR\. You may pass an array with multiple files or \fBtrue\fR if the file you want \fBrequired\fR has the same name as \fIgem\fR or \fBfalse\fR to prevent any file from being autorequired\.
-.
.IP "" 4
-.
.nf
-
gem "redis", require: ["redis/connection/hiredis", "redis"]
gem "webmock", require: false
gem "byebug", require: true
-.
.fi
-.
.IP "" 0
-.
.P
The argument defaults to the name of the gem\. For example, these are identical:
-.
.IP "" 4
-.
.nf
-
gem "nokogiri"
gem "nokogiri", require: "nokogiri"
gem "nokogiri", require: true
-.
.fi
-.
.IP "" 0
-.
.SS "GROUPS"
Each \fIgem\fR \fBMAY\fR specify membership in one or more groups\. Any \fIgem\fR that does not specify membership in any group is placed in the \fBdefault\fR group\.
-.
.IP "" 4
-.
.nf
-
gem "rspec", group: :test
gem "wirble", groups: [:development, :test]
-.
.fi
-.
.IP "" 0
-.
.P
The Bundler runtime allows its two main methods, \fBBundler\.setup\fR and \fBBundler\.require\fR, to limit their impact to particular groups\.
-.
.IP "" 4
-.
.nf
-
-# setup adds gems to Ruby\'s load path
+# setup adds gems to Ruby's load path
Bundler\.setup # defaults to all groups
require "bundler/setup" # same as Bundler\.setup
Bundler\.setup(:default) # only set up the _default_ group
@@ -221,429 +149,269 @@ Bundler\.require # defaults to the _default_ group
Bundler\.require(:default) # identical
Bundler\.require(:default, :test) # requires the _default_ and _test_ groups
Bundler\.require(:test) # requires the _test_ group
-.
.fi
-.
.IP "" 0
-.
.P
The Bundler CLI allows you to specify a list of groups whose gems \fBbundle install\fR should not install with the \fBwithout\fR configuration\.
-.
.P
To specify multiple groups to ignore, specify a list of groups separated by spaces\.
-.
.IP "" 4
-.
.nf
-
bundle config set \-\-local without test
bundle config set \-\-local without development test
-.
.fi
-.
.IP "" 0
-.
.P
Also, calling \fBBundler\.setup\fR with no parameters, or calling \fBrequire "bundler/setup"\fR will setup all groups except for the ones you excluded via \fB\-\-without\fR (since they are not available)\.
-.
.P
Note that on \fBbundle install\fR, bundler downloads and evaluates all gems, in order to create a single canonical list of all of the required gems and their dependencies\. This means that you cannot list different versions of the same gems in different groups\. For more details, see Understanding Bundler \fIhttps://bundler\.io/rationale\.html\fR\.
-.
.SS "PLATFORMS"
If a gem should only be used in a particular platform or set of platforms, you can specify them\. Platforms are essentially identical to groups, except that you do not need to use the \fB\-\-without\fR install\-time flag to exclude groups of gems for other platforms\.
-.
.P
There are a number of \fBGemfile\fR platforms:
-.
.TP
\fBruby\fR
C Ruby (MRI), Rubinius, or TruffleRuby, but not Windows
-.
.TP
\fBmri\fR
C Ruby (MRI) only, but not Windows
-.
.TP
\fBwindows\fR
Windows C Ruby (MRI), including RubyInstaller 32\-bit and 64\-bit versions
-.
.TP
\fBmswin\fR
Windows C Ruby (MRI), including RubyInstaller 32\-bit versions
-.
.TP
\fBmswin64\fR
Windows C Ruby (MRI), including RubyInstaller 64\-bit versions
-.
.TP
\fBrbx\fR
Rubinius
-.
.TP
\fBjruby\fR
JRuby
-.
.TP
\fBtruffleruby\fR
TruffleRuby
-.
.P
On platforms \fBruby\fR, \fBmri\fR, \fBmswin\fR, \fBmswin64\fR, and \fBwindows\fR, you may additionally specify a version by appending the major and minor version numbers without a delimiter\. For example, to specify that a gem should only be used on platform \fBruby\fR version 3\.1, use:
-.
.IP "" 4
-.
.nf
-
ruby_31
-.
.fi
-.
.IP "" 0
-.
.P
As with groups (above), you may specify one or more platforms:
-.
.IP "" 4
-.
.nf
-
gem "weakling", platforms: :jruby
gem "ruby\-debug", platforms: :mri_31
gem "nokogiri", platforms: [:windows_31, :jruby]
-.
.fi
-.
.IP "" 0
-.
.P
All operations involving groups (\fBbundle install\fR \fIbundle\-install\.1\.html\fR, \fBBundler\.setup\fR, \fBBundler\.require\fR) behave exactly the same as if any groups not matching the current platform were explicitly excluded\.
-.
+.P
+The following platform values are deprecated and should be replaced with \fBwindows\fR:
+.IP "\(bu" 4
+\fBmswin\fR, \fBmswin64\fR, \fBmingw32\fR, \fBx64_mingw\fR
+.IP "" 0
.SS "FORCE_RUBY_PLATFORM"
If you always want the pure ruby variant of a gem to be chosen over platform specific variants, you can use the \fBforce_ruby_platform\fR option:
-.
.IP "" 4
-.
.nf
-
gem "ffi", force_ruby_platform: true
-.
.fi
-.
.IP "" 0
-.
.P
This can be handy (assuming the pure ruby variant works fine) when:
-.
.IP "\(bu" 4
-You\'re having issues with the platform specific variant\.
-.
+You're having issues with the platform specific variant\.
.IP "\(bu" 4
The platform specific variant does not yet support a newer ruby (and thus has a \fBrequired_ruby_version\fR upper bound), but you still want your Gemfile{\.lock} files to resolve under that ruby\.
-.
.IP "" 0
-.
.SS "SOURCE"
-You can select an alternate RubyGems repository for a gem using the \':source\' option\.
-.
+You can select an alternate RubyGems repository for a gem using the ':source' option\.
.IP "" 4
-.
.nf
-
gem "some_internal_gem", source: "https://gems\.example\.com"
-.
.fi
-.
.IP "" 0
-.
.P
This forces the gem to be loaded from this source and ignores the global source declared at the top level of the file\. If the gem does not exist in this source, it will not be installed\.
-.
.P
Bundler will search for child dependencies of this gem by first looking in the source selected for the parent, but if they are not found there, it will fall back on the global source\.
-.
.P
\fBNote about a behavior of the feature deprecated in Bundler 1\.13\fR: Selecting a specific source repository this way also suppresses the ambiguous gem warning described above in \fIGLOBAL SOURCE\fR\.
-.
.P
Using the \fB:source\fR option for an individual gem will also make that source available as a possible global source for any other gems which do not specify explicit sources\. Thus, when adding gems with explicit sources, it is recommended that you also ensure all other gems in the Gemfile are using explicit sources\.
-.
.SS "GIT"
If necessary, you can specify that a gem is located at a particular git repository using the \fB:git\fR parameter\. The repository can be accessed via several protocols:
-.
.TP
\fBHTTP(S)\fR
gem "rails", git: "https://github\.com/rails/rails\.git"
-.
.TP
\fBSSH\fR
gem "rails", git: "git@github\.com:rails/rails\.git"
-.
.TP
\fBgit\fR
gem "rails", git: "git://github\.com/rails/rails\.git"
-.
.P
If using SSH, the user that you use to run \fBbundle install\fR \fBMUST\fR have the appropriate keys available in their \fB$HOME/\.ssh\fR\.
-.
.P
\fBNOTE\fR: \fBhttp://\fR and \fBgit://\fR URLs should be avoided if at all possible\. These protocols are unauthenticated, so a man\-in\-the\-middle attacker can deliver malicious code and compromise your system\. HTTPS and SSH are strongly preferred\.
-.
.P
The \fBgroup\fR, \fBplatforms\fR, and \fBrequire\fR options are available and behave exactly the same as they would for a normal gem\.
-.
.P
A git repository \fBSHOULD\fR have at least one file, at the root of the directory containing the gem, with the extension \fB\.gemspec\fR\. This file \fBMUST\fR contain a valid gem specification, as expected by the \fBgem build\fR command\.
-.
.P
If a git repository does not have a \fB\.gemspec\fR, bundler will attempt to create one, but it will not contain any dependencies, executables, or C extension compilation instructions\. As a result, it may fail to properly integrate into your application\.
-.
.P
If a git repository does have a \fB\.gemspec\fR for the gem you attached it to, a version specifier, if provided, means that the git repository is only valid if the \fB\.gemspec\fR specifies a version matching the version specifier\. If not, bundler will print a warning\.
-.
.IP "" 4
-.
.nf
-
gem "rails", "2\.3\.8", git: "https://github\.com/rails/rails\.git"
# bundle install will fail, because the \.gemspec in the rails
-# repository\'s master branch specifies version 3\.0\.0
-.
+# repository's master branch specifies version 3\.0\.0
.fi
-.
.IP "" 0
-.
.P
If a git repository does \fBnot\fR have a \fB\.gemspec\fR for the gem you attached it to, a version specifier \fBMUST\fR be provided\. Bundler will use this version in the simple \fB\.gemspec\fR it creates\.
-.
.P
Git repositories support a number of additional options\.
-.
.TP
\fBbranch\fR, \fBtag\fR, and \fBref\fR
You \fBMUST\fR only specify at most one of these options\. The default is \fBbranch: "master"\fR\. For example:
-.
.IP
gem "rails", git: "https://github\.com/rails/rails\.git", branch: "5\-0\-stable"
-.
.IP
gem "rails", git: "https://github\.com/rails/rails\.git", tag: "v5\.0\.0"
-.
.IP
gem "rails", git: "https://github\.com/rails/rails\.git", ref: "4aded"
-.
.TP
\fBsubmodules\fR
For reference, a git submodule \fIhttps://git\-scm\.com/book/en/v2/Git\-Tools\-Submodules\fR lets you have another git repository within a subfolder of your repository\. Specify \fBsubmodules: true\fR to cause bundler to expand any submodules included in the git repository
-.
.P
If a git repository contains multiple \fB\.gemspecs\fR, each \fB\.gemspec\fR represents a gem located at the same place in the file system as the \fB\.gemspec\fR\.
-.
.IP "" 4
-.
.nf
-
|~rails [git root]
| |\-rails\.gemspec [rails gem located here]
|~actionpack
| |\-actionpack\.gemspec [actionpack gem located here]
|~activesupport
| |\-activesupport\.gemspec [activesupport gem located here]
-|\.\.\.
-.
+|\|\.\|\.\|\.
.fi
-.
.IP "" 0
-.
.P
To install a gem located in a git repository, bundler changes to the directory containing the gemspec, runs \fBgem build name\.gemspec\fR and then installs the resulting gem\. The \fBgem build\fR command, which comes standard with Rubygems, evaluates the \fB\.gemspec\fR in the context of the directory in which it is located\.
-.
.SS "GIT SOURCE"
-A custom git source can be defined via the \fBgit_source\fR method\. Provide the source\'s name as an argument, and a block which receives a single argument and interpolates it into a string to return the full repo address:
-.
+A custom git source can be defined via the \fBgit_source\fR method\. Provide the source's name as an argument, and a block which receives a single argument and interpolates it into a string to return the full repo address:
.IP "" 4
-.
.nf
-
git_source(:stash){ |repo_name| "https://stash\.corp\.acme\.pl/#{repo_name}\.git" }
-gem \'rails\', stash: \'forks/rails\'
-.
+gem 'rails', stash: 'forks/rails'
.fi
-.
.IP "" 0
-.
.P
In addition, if you wish to choose a specific branch:
-.
.IP "" 4
-.
.nf
-
gem "rails", stash: "forks/rails", branch: "branch_name"
-.
.fi
-.
.IP "" 0
-.
.SS "GITHUB"
\fBNOTE\fR: This shorthand should be avoided until Bundler 2\.0, since it currently expands to an insecure \fBgit://\fR URL\. This allows a man\-in\-the\-middle attacker to compromise your system\.
-.
.P
If the git repository you want to use is hosted on GitHub and is public, you can use the :github shorthand to specify the github username and repository name (without the trailing "\.git"), separated by a slash\. If both the username and repository name are the same, you can omit one\.
-.
.IP "" 4
-.
.nf
-
gem "rails", github: "rails/rails"
gem "rails", github: "rails"
-.
.fi
-.
.IP "" 0
-.
.P
Are both equivalent to
-.
.IP "" 4
-.
.nf
-
gem "rails", git: "https://github\.com/rails/rails\.git"
-.
.fi
-.
.IP "" 0
-.
.P
Since the \fBgithub\fR method is a specialization of \fBgit_source\fR, it accepts a \fB:branch\fR named argument\.
-.
.P
You can also directly pass a pull request URL:
-.
.IP "" 4
-.
.nf
-
gem "rails", github: "https://github\.com/rails/rails/pull/43753"
-.
.fi
-.
.IP "" 0
-.
.P
Which is equivalent to:
-.
.IP "" 4
-.
.nf
-
gem "rails", github: "rails/rails", branch: "refs/pull/43753/head"
-.
.fi
-.
.IP "" 0
-.
.SS "GIST"
If the git repository you want to use is hosted as a GitHub Gist and is public, you can use the :gist shorthand to specify the gist identifier (without the trailing "\.git")\.
-.
.IP "" 4
-.
.nf
-
gem "the_hatch", gist: "4815162342"
-.
.fi
-.
.IP "" 0
-.
.P
Is equivalent to:
-.
.IP "" 4
-.
.nf
-
gem "the_hatch", git: "https://gist\.github\.com/4815162342\.git"
-.
.fi
-.
.IP "" 0
-.
.P
Since the \fBgist\fR method is a specialization of \fBgit_source\fR, it accepts a \fB:branch\fR named argument\.
-.
.SS "BITBUCKET"
If the git repository you want to use is hosted on Bitbucket and is public, you can use the :bitbucket shorthand to specify the bitbucket username and repository name (without the trailing "\.git"), separated by a slash\. If both the username and repository name are the same, you can omit one\.
-.
.IP "" 4
-.
.nf
-
gem "rails", bitbucket: "rails/rails"
gem "rails", bitbucket: "rails"
-.
.fi
-.
.IP "" 0
-.
.P
Are both equivalent to
-.
.IP "" 4
-.
.nf
-
gem "rails", git: "https://rails@bitbucket\.org/rails/rails\.git"
-.
.fi
-.
.IP "" 0
-.
.P
Since the \fBbitbucket\fR method is a specialization of \fBgit_source\fR, it accepts a \fB:branch\fR named argument\.
-.
.SS "PATH"
You can specify that a gem is located in a particular location on the file system\. Relative paths are resolved relative to the directory containing the \fBGemfile\fR\.
-.
.P
Similar to the semantics of the \fB:git\fR option, the \fB:path\fR option requires that the directory in question either contains a \fB\.gemspec\fR for the gem, or that you specify an explicit version that bundler should use\.
-.
.P
Unlike \fB:git\fR, bundler does not compile C extensions for gems specified as paths\.
-.
.IP "" 4
-.
.nf
-
gem "rails", path: "vendor/rails"
-.
.fi
-.
.IP "" 0
-.
.P
-If you would like to use multiple local gems directly from the filesystem, you can set a global \fBpath\fR option to the path containing the gem\'s files\. This will automatically load gemspec files from subdirectories\.
-.
+If you would like to use multiple local gems directly from the filesystem, you can set a global \fBpath\fR option to the path containing the gem's files\. This will automatically load gemspec files from subdirectories\.
.IP "" 4
-.
.nf
-
-path \'components\' do
- gem \'admin_ui\'
- gem \'public_ui\'
+path 'components' do
+ gem 'admin_ui'
+ gem 'public_ui'
end
-.
.fi
-.
.IP "" 0
-.
.SH "BLOCK FORM OF SOURCE, GIT, PATH, GROUP and PLATFORMS"
The \fB:source\fR, \fB:git\fR, \fB:path\fR, \fB:group\fR, and \fB:platforms\fR options may be applied to a group of gems by using block form\.
-.
.IP "" 4
-.
.nf
-
source "https://gems\.example\.com" do
gem "some_internal_gem"
gem "another_internal_gem"
@@ -663,61 +431,40 @@ group :development, optional: true do
gem "wirble"
gem "faker"
end
-.
.fi
-.
.IP "" 0
-.
.P
In the case of the group block form the :optional option can be given to prevent a group from being installed unless listed in the \fB\-\-with\fR option given to the \fBbundle install\fR command\.
-.
.P
In the case of the \fBgit\fR block form, the \fB:ref\fR, \fB:branch\fR, \fB:tag\fR, and \fB:submodules\fR options may be passed to the \fBgit\fR method, and all gems in the block will inherit those options\.
-.
.P
The presence of a \fBsource\fR block in a Gemfile also makes that source available as a possible global source for any other gems which do not specify explicit sources\. Thus, when defining source blocks, it is recommended that you also ensure all other gems in the Gemfile are using explicit sources, either via source blocks or \fB:source\fR directives on individual gems\.
-.
.SH "INSTALL_IF"
The \fBinstall_if\fR method allows gems to be installed based on a proc or lambda\. This is especially useful for optional gems that can only be used if certain software is installed or some other conditions are met\.
-.
.IP "" 4
-.
.nf
-
install_if \-> { RUBY_PLATFORM =~ /darwin/ } do
gem "pasteboard"
end
-.
.fi
-.
.IP "" 0
-.
.SH "GEMSPEC"
-The \fB\.gemspec\fR \fIhttp://guides\.rubygems\.org/specification\-reference/\fR file is where you provide metadata about your gem to Rubygems\. Some required Gemspec attributes include the name, description, and homepage of your gem\. This is also where you specify the dependencies your gem needs to run\.
-.
+The \fB\.gemspec\fR \fIhttps://guides\.rubygems\.org/specification\-reference/\fR file is where you provide metadata about your gem to Rubygems\. Some required Gemspec attributes include the name, description, and homepage of your gem\. This is also where you specify the dependencies your gem needs to run\.
.P
If you wish to use Bundler to help install dependencies for a gem while it is being developed, use the \fBgemspec\fR method to pull in the dependencies listed in the \fB\.gemspec\fR file\.
-.
.P
-The \fBgemspec\fR method adds any runtime dependencies as gem requirements in the default group\. It also adds development dependencies as gem requirements in the \fBdevelopment\fR group\. Finally, it adds a gem requirement on your project (\fBpath: \'\.\'\fR)\. In conjunction with \fBBundler\.setup\fR, this allows you to require project files in your test code as you would if the project were installed as a gem; you need not manipulate the load path manually or require project files via relative paths\.
-.
+The \fBgemspec\fR method adds any runtime dependencies as gem requirements in the default group\. It also adds development dependencies as gem requirements in the \fBdevelopment\fR group\. Finally, it adds a gem requirement on your project (\fBpath: '\.'\fR)\. In conjunction with \fBBundler\.setup\fR, this allows you to require project files in your test code as you would if the project were installed as a gem; you need not manipulate the load path manually or require project files via relative paths\.
.P
-The \fBgemspec\fR method supports optional \fB:path\fR, \fB:glob\fR, \fB:name\fR, and \fB:development_group\fR options, which control where bundler looks for the \fB\.gemspec\fR, the glob it uses to look for the gemspec (defaults to: "{,\fI,\fR/*}\.gemspec"), what named \fB\.gemspec\fR it uses (if more than one is present), and which group development dependencies are included in\.
-.
+The \fBgemspec\fR method supports optional \fB:path\fR, \fB:glob\fR, \fB:name\fR, and \fB:development_group\fR options, which control where bundler looks for the \fB\.gemspec\fR, the glob it uses to look for the gemspec (defaults to: \fB{,*,*/*}\.gemspec\fR), what named \fB\.gemspec\fR it uses (if more than one is present), and which group development dependencies are included in\.
.P
When a \fBgemspec\fR dependency encounters version conflicts during resolution, the local version under development will always be selected \-\- even if there are remote versions that better match other requirements for the \fBgemspec\fR gem\.
-.
.SH "SOURCE PRIORITY"
When attempting to locate a gem to satisfy a gem requirement, bundler uses the following priority order:
-.
.IP "1." 4
The source explicitly attached to the gem (using \fB:source\fR, \fB:path\fR, or \fB:git\fR)
-.
.IP "2." 4
For implicit gems (dependencies of explicit gems), any source, git, or path repository declared on the parent\. This results in bundler prioritizing the ActiveSupport gem from the Rails git repository over ones from \fBrubygems\.org\fR
-.
.IP "3." 4
If neither of the above conditions are met, the global source will be used\. If multiple global sources are specified, they will be prioritized from last to first, but this is deprecated since Bundler 1\.13, so Bundler prints a warning and will abort with an error in the future\.
-.
.IP "" 0
diff --git a/lib/bundler/man/gemfile.5.ronn b/lib/bundler/man/gemfile.5.ronn
index a3affc30cc..7c1e00d13a 100644
--- a/lib/bundler/man/gemfile.5.ronn
+++ b/lib/bundler/man/gemfile.5.ronn
@@ -69,6 +69,16 @@ should be the Ruby version that the engine is compatible with.
ruby "3.1.2"
+If you wish to derive your Ruby version from a version file (ie .ruby-version),
+you can use the `file` option instead.
+
+ ruby file: ".ruby-version"
+
+The version file should conform to any of the following formats:
+
+ - `3.1.2` (.ruby-version)
+ - `ruby 3.1.2` (.tool-versions, read: https://asdf-vm.com/manage/configuration.html#tool-versions)
+
### ENGINE
Each application _may_ specify a Ruby engine. If an engine is specified, an
@@ -86,7 +96,7 @@ What exactly is an Engine?
- [Other implementations](https://www.ruby-lang.org/en/about/) of Ruby exist.
Some of the more well-known implementations include
- [JRuby](http://jruby.org/) and [TruffleRuby](https://www.graalvm.org/ruby/).
+ [JRuby](https://www.jruby.org/) and [TruffleRuby](https://www.graalvm.org/ruby/).
Rubinius is an alternative implementation of Ruby written in Ruby.
JRuby is an implementation of Ruby on the JVM, short for Java Virtual Machine.
TruffleRuby is a Ruby implementation on the GraalVM, a language toolkit built on the JVM.
@@ -228,6 +238,10 @@ All operations involving groups ([`bundle install`](bundle-install.1.html), `Bun
`Bundler.require`) behave exactly the same as if any groups not
matching the current platform were explicitly excluded.
+The following platform values are deprecated and should be replaced with `windows`:
+
+ * `mswin`, `mswin64`, `mingw32`, `x64_mingw`
+
### FORCE_RUBY_PLATFORM
If you always want the pure ruby variant of a gem to be chosen over platform
@@ -495,7 +509,7 @@ software is installed or some other conditions are met.
## GEMSPEC
-The [`.gemspec`](http://guides.rubygems.org/specification-reference/) file is where
+The [`.gemspec`](https://guides.rubygems.org/specification-reference/) file is where
you provide metadata about your gem to Rubygems. Some required Gemspec
attributes include the name, description, and homepage of your gem. This is
also where you specify the dependencies your gem needs to run.
@@ -514,7 +528,7 @@ paths.
The `gemspec` method supports optional `:path`, `:glob`, `:name`, and `:development_group`
options, which control where bundler looks for the `.gemspec`, the glob it uses to look
-for the gemspec (defaults to: "{,*,*/*}.gemspec"), what named `.gemspec` it uses
+for the gemspec (defaults to: `{,*,*/*}.gemspec`), what named `.gemspec` it uses
(if more than one is present), and which group development dependencies are included in.
When a `gemspec` dependency encounters version conflicts during resolution, the
diff --git a/lib/bundler/match_metadata.rb b/lib/bundler/match_metadata.rb
index 499036ca93..f6cc27df32 100644
--- a/lib/bundler/match_metadata.rb
+++ b/lib/bundler/match_metadata.rb
@@ -2,6 +2,10 @@
module Bundler
module MatchMetadata
+ def matches_current_metadata?
+ matches_current_ruby? && matches_current_rubygems?
+ end
+
def matches_current_ruby?
@required_ruby_version.satisfied_by?(Gem.ruby_version)
end
diff --git a/lib/bundler/match_platform.rb b/lib/bundler/match_platform.rb
index 7f7e8227f9..ece9fb8679 100644
--- a/lib/bundler/match_platform.rb
+++ b/lib/bundler/match_platform.rb
@@ -12,7 +12,7 @@ module Bundler
def self.platforms_match?(gemspec_platform, local_platform)
return true if gemspec_platform.nil?
- return true if Gem::Platform::RUBY == gemspec_platform
+ return true if gemspec_platform == Gem::Platform::RUBY
return true if local_platform == gemspec_platform
gemspec_platform = Gem::Platform.new(gemspec_platform)
return true if gemspec_platform === local_platform
diff --git a/lib/bundler/mirror.rb b/lib/bundler/mirror.rb
index 9d437a0951..494a6d6aef 100644
--- a/lib/bundler/mirror.rb
+++ b/lib/bundler/mirror.rb
@@ -47,7 +47,7 @@ module Bundler
def fetch_valid_mirror_for(uri)
downcased = uri.to_s.downcase
- mirror = @mirrors[downcased] || @mirrors[Bundler::URI(downcased).host] || Mirror.new(uri)
+ mirror = @mirrors[downcased] || @mirrors[Gem::URI(downcased).host] || Mirror.new(uri)
mirror.validate!(@prober)
mirror = Mirror.new(uri) unless mirror.valid?
mirror
@@ -74,7 +74,7 @@ module Bundler
@uri = if uri.nil?
nil
else
- Bundler::URI(uri.to_s)
+ Gem::URI(uri.to_s)
end
@valid = nil
end
@@ -126,7 +126,7 @@ module Bundler
if uri == "all"
@all = true
else
- @uri = Bundler::URI(uri).absolute? ? Settings.normalize_uri(uri) : uri
+ @uri = Gem::URI(uri).absolute? ? Settings.normalize_uri(uri) : uri
end
@value = value
end
diff --git a/lib/bundler/plugin.rb b/lib/bundler/plugin.rb
index f3caff8963..588fa79be8 100644
--- a/lib/bundler/plugin.rb
+++ b/lib/bundler/plugin.rb
@@ -62,7 +62,8 @@ module Bundler
if names.any?
names.each do |name|
if index.installed?(name)
- Bundler.rm_rf(index.plugin_path(name))
+ path = index.plugin_path(name).to_s
+ Bundler.rm_rf(path) if index.installed_in_plugin_root?(name)
index.unregister_plugin(name)
Bundler.ui.info "Uninstalled plugin #{name}"
else
@@ -100,7 +101,7 @@ module Bundler
# @param [Pathname] gemfile path
# @param [Proc] block that can be evaluated for (inline) Gemfile
def gemfile_install(gemfile = nil, &inline)
- Bundler.settings.temporary(:frozen => false, :deployment => false) do
+ Bundler.settings.temporary(frozen: false, deployment: false) do
builder = DSL.new
if block_given?
builder.instance_eval(&inline)
@@ -197,7 +198,7 @@ module Bundler
# @param [Hash] The options that are present in the lock file
# @return [API::Source] the instance of the class that handles the source
# type passed in locked_opts
- def source_from_lock(locked_opts)
+ def from_lock(locked_opts)
src = source(locked_opts["type"])
src.new(locked_opts.merge("uri" => locked_opts["remote"]))
@@ -227,7 +228,7 @@ module Bundler
plugins = index.hook_plugins(event)
return unless plugins.any?
- (plugins - @loaded_plugin_names).each {|name| load_plugin(name) }
+ plugins.each {|name| load_plugin(name) }
@hooks_by_event[event].each {|blk| blk.call(*args, &arg_blk) }
end
@@ -239,6 +240,11 @@ module Bundler
Index.new.installed?(plugin)
end
+ # @return [true, false] whether the plugin is loaded
+ def loaded?(plugin)
+ @loaded_plugin_names.include?(plugin)
+ end
+
# Post installation processing and registering with index
#
# @param [Array<String>] plugins list to be installed
@@ -301,7 +307,7 @@ module Bundler
@hooks_by_event = Hash.new {|h, k| h[k] = [] }
load_paths = spec.load_paths
- Bundler.rubygems.add_to_load_path(load_paths)
+ Gem.add_to_load_path(*load_paths)
path = Pathname.new spec.full_gem_path
begin
@@ -329,13 +335,14 @@ module Bundler
# @param [String] name of the plugin
def load_plugin(name)
return unless name && !name.empty?
+ return if loaded?(name)
# Need to ensure before this that plugin root where the rest of gems
# are installed to be on load path to support plugin deps. Currently not
# done to avoid conflicts
path = index.plugin_path(name)
- Bundler.rubygems.add_to_load_path(index.load_paths(name))
+ Gem.add_to_load_path(*index.load_paths(name))
load path.join(PLUGIN_FILE_NAME)
diff --git a/lib/bundler/plugin/api/source.rb b/lib/bundler/plugin/api/source.rb
index 67c45bd204..8563ee358a 100644
--- a/lib/bundler/plugin/api/source.rb
+++ b/lib/bundler/plugin/api/source.rb
@@ -39,7 +39,7 @@ module Bundler
# is present to be compatible with `Definition` and is used by
# rubygems source.
module Source
- attr_reader :uri, :options, :name
+ attr_reader :uri, :options, :name, :checksum_store
attr_accessor :dependency_names
def initialize(opts)
@@ -48,6 +48,7 @@ module Bundler
@uri = opts["uri"]
@type = opts["type"]
@name = opts["name"] || "#{@type} at #{@uri}"
+ @checksum_store = Checksum::Store.new
end
# This is used by the default `spec` method to constructs the
@@ -95,7 +96,7 @@ module Bundler
#
# Note: Do not override if you don't know what you are doing.
def post_install(spec, disable_exts = false)
- opts = { :env_shebang => false, :disable_extensions => disable_exts }
+ opts = { env_shebang: false, disable_extensions: disable_exts }
installer = Bundler::Source::Path::Installer.new(spec, opts)
installer.post_install
end
@@ -106,7 +107,7 @@ module Bundler
def install_path
@install_path ||=
begin
- base_name = File.basename(Bundler::URI.parse(uri).normalize.path)
+ base_name = File.basename(Gem::URI.parse(uri).normalize.path)
gem_install_dir.join("#{base_name}-#{uri_hash[0..11]}")
end
@@ -175,7 +176,7 @@ module Bundler
#
# This is used by `app_cache_path`
def app_cache_dirname
- base_name = File.basename(Bundler::URI.parse(uri).normalize.path)
+ base_name = File.basename(Gem::URI.parse(uri).normalize.path)
"#{base_name}-#{uri_hash}"
end
diff --git a/lib/bundler/plugin/index.rb b/lib/bundler/plugin/index.rb
index a2d5eaa38a..c2ab8f90da 100644
--- a/lib/bundler/plugin/index.rb
+++ b/lib/bundler/plugin/index.rb
@@ -136,6 +136,14 @@ module Bundler
@hooks[event] || []
end
+ # This plugin is installed inside the .bundle/plugin directory,
+ # and thus is managed solely by Bundler
+ def installed_in_plugin_root?(name)
+ return false unless (path = installed?(name))
+
+ path.start_with?("#{Plugin.root}/")
+ end
+
private
# Reads the index file from the directory and initializes the instance
diff --git a/lib/bundler/plugin/installer.rb b/lib/bundler/plugin/installer.rb
index 81ecafa470..4f60862bb4 100644
--- a/lib/bundler/plugin/installer.rb
+++ b/lib/bundler/plugin/installer.rb
@@ -10,6 +10,7 @@ module Bundler
class Installer
autoload :Rubygems, File.expand_path("installer/rubygems", __dir__)
autoload :Git, File.expand_path("installer/git", __dir__)
+ autoload :Path, File.expand_path("installer/path", __dir__)
def install(names, options)
check_sources_consistency!(options)
@@ -18,8 +19,8 @@ module Bundler
if options[:git]
install_git(names, version, options)
- elsif options[:local_git]
- install_local_git(names, version, options)
+ elsif options[:path]
+ install_path(names, version, options[:path])
else
sources = options[:source] || Gem.sources
install_rubygems(names, version, sources)
@@ -45,20 +46,40 @@ module Bundler
if options.key?(:git) && options.key?(:local_git)
raise InvalidOption, "Remote and local plugin git sources can't be both specified"
end
+
+ # back-compat; local_git is an alias for git
+ if options.key?(:local_git)
+ Bundler::SharedHelpers.major_deprecation(2, "--local_git is deprecated, use --git")
+ options[:git] = options.delete(:local_git)
+ end
+
+ if (options.keys & [:source, :git, :path]).length > 1
+ raise InvalidOption, "Only one of --source, --git, or --path may be specified"
+ end
+
+ if (options.key?(:branch) || options.key?(:ref)) && !options.key?(:git)
+ raise InvalidOption, "--#{options.key?(:branch) ? "branch" : "ref"} can only be used with git sources"
+ end
+
+ if options.key?(:branch) && options.key?(:ref)
+ raise InvalidOption, "--branch and --ref can't be both specified"
+ end
end
def install_git(names, version, options)
- uri = options.delete(:git)
- options["uri"] = uri
+ source_list = SourceList.new
+ source = source_list.add_git_source({ "uri" => options[:git],
+ "branch" => options[:branch],
+ "ref" => options[:ref] })
- install_all_sources(names, version, options, options[:source])
+ install_all_sources(names, version, source_list, source)
end
- def install_local_git(names, version, options)
- uri = options.delete(:local_git)
- options["uri"] = uri
+ def install_path(names, version, path)
+ source_list = SourceList.new
+ source = source_list.add_path_source({ "path" => path, "root_path" => SharedHelpers.pwd })
- install_all_sources(names, version, options, options[:source])
+ install_all_sources(names, version, source_list, source)
end
# Installs the plugin from rubygems source and returns the path where the
@@ -70,21 +91,23 @@ module Bundler
#
# @return [Hash] map of names to the specs of plugins installed
def install_rubygems(names, version, sources)
- install_all_sources(names, version, nil, sources)
- end
-
- def install_all_sources(names, version, git_source_options, rubygems_source)
source_list = SourceList.new
- source_list.add_git_source(git_source_options) if git_source_options
- Array(rubygems_source).each {|remote| source_list.add_global_rubygems_remote(remote) } if rubygems_source
+ Array(sources).each {|remote| source_list.add_global_rubygems_remote(remote) }
- deps = names.map {|name| Dependency.new name, version }
+ install_all_sources(names, version, source_list)
+ end
+
+ def install_all_sources(names, version, source_list, source = nil)
+ deps = names.map {|name| Dependency.new(name, version, { "source" => source }) }
Bundler.configure_gem_home_and_path(Plugin.root)
- definition = Definition.new(nil, deps, source_list, true)
- install_definition(definition)
+ Bundler.settings.temporary(deployment: false, frozen: false) do
+ definition = Definition.new(nil, deps, source_list, true)
+
+ install_definition(definition)
+ end
end
# Installs the plugins and deps from the provided specs and returns map of
diff --git a/lib/bundler/plugin/installer/path.rb b/lib/bundler/plugin/installer/path.rb
new file mode 100644
index 0000000000..58a8fa7426
--- /dev/null
+++ b/lib/bundler/plugin/installer/path.rb
@@ -0,0 +1,18 @@
+# frozen_string_literal: true
+
+module Bundler
+ module Plugin
+ class Installer
+ class Path < Bundler::Source::Path
+ def root
+ SharedHelpers.in_bundle? ? Bundler.root : Plugin.root
+ end
+
+ def generate_bin(spec, disable_extensions = false)
+ # Need to find a way without code duplication
+ # For now, we can ignore this
+ end
+ end
+ end
+ end
+end
diff --git a/lib/bundler/plugin/source_list.rb b/lib/bundler/plugin/source_list.rb
index 547661cf2f..746996de55 100644
--- a/lib/bundler/plugin/source_list.rb
+++ b/lib/bundler/plugin/source_list.rb
@@ -9,6 +9,10 @@ module Bundler
add_source_to_list Plugin::Installer::Git.new(options), git_sources
end
+ def add_path_source(options = {})
+ add_source_to_list Plugin::Installer::Path.new(options), path_sources
+ end
+
def add_rubygems_source(options = {})
add_source_to_list Plugin::Installer::Rubygems.new(options), @rubygems_sources
end
@@ -17,10 +21,6 @@ module Bundler
path_sources + git_sources + rubygems_sources + [metadata_source]
end
- def default_source
- git_sources.first || global_rubygems_source
- end
-
private
def rubygems_aggregate_class
diff --git a/lib/bundler/remote_specification.rb b/lib/bundler/remote_specification.rb
index 34d7fd116c..9d237f3fa0 100644
--- a/lib/bundler/remote_specification.rb
+++ b/lib/bundler/remote_specification.rb
@@ -29,12 +29,8 @@ module Bundler
@platform = _remote_specification.platform
end
- def identifier
- @__identifier ||= [name, version, @platform.to_s]
- end
-
def full_name
- if @platform == Gem::Platform::RUBY
+ @full_name ||= if @platform == Gem::Platform::RUBY
"#{@name}-#{@version}"
else
"#{@name}-#{@version}-#{@platform}"
@@ -92,6 +88,10 @@ module Bundler
end
end
+ def runtime_dependencies
+ dependencies.select(&:runtime?)
+ end
+
def git_version
return unless loaded_from && source.is_a?(Bundler::Source::Git)
" #{source.revision[0..6]}"
@@ -106,7 +106,7 @@ module Bundler
def _remote_specification
@_remote_specification ||= @spec_fetcher.fetch_spec([@name, @version, @original_platform])
@_remote_specification || raise(GemspecError, "Gemspec data for #{full_name} was" \
- " missing from the server! Try installing with `--full-index` as a workaround.")
+ " missing from the server!")
end
def method_missing(method, *args, &blk)
diff --git a/lib/bundler/resolver.rb b/lib/bundler/resolver.rb
index 8237ff53fe..1a6711ea6f 100644
--- a/lib/bundler/resolver.rb
+++ b/lib/bundler/resolver.rb
@@ -29,7 +29,7 @@ module Bundler
Bundler.ui.info "Resolving dependencies...", true
- solve_versions(:root => root, :logger => logger)
+ solve_versions(root: root, logger: logger)
end
def setup_solver
@@ -37,29 +37,39 @@ module Bundler
root_version = Resolver::Candidate.new(0)
@all_specs = Hash.new do |specs, name|
- specs[name] = source_for(name).specs.search(name).sort_by {|s| [s.version, s.platform.to_s] }
+ source = source_for(name)
+ matches = source.specs.search(name)
+
+ # Don't bother to check for circular deps when no dependency API are
+ # available, since it's too slow to be usable. That edge case won't work
+ # but resolution other than that should work fine and reasonably fast.
+ if source.respond_to?(:dependency_api_available?) && source.dependency_api_available?
+ matches = filter_invalid_self_dependencies(matches, name)
+ end
+
+ specs[name] = matches.sort_by {|s| [s.version, s.platform.to_s] }
+ end
+
+ @all_versions = Hash.new do |candidates, package|
+ candidates[package] = all_versions_for(package)
end
@sorted_versions = Hash.new do |candidates, package|
- candidates[package] = if package.root?
- [root_version]
- else
- all_versions_for(package).sort
- end
+ candidates[package] = filtered_versions_for(package).sort
end
+ @sorted_versions[root] = [root_version]
+
root_dependencies = prepare_dependencies(@requirements, @packages)
@cached_dependencies = Hash.new do |dependencies, package|
- dependencies[package] = if package.root?
- { root_version => root_dependencies }
- else
- Hash.new do |versions, version|
- versions[version] = to_dependency_hash(version.dependencies, @packages)
- end
+ dependencies[package] = Hash.new do |versions, version|
+ versions[version] = to_dependency_hash(version.dependencies.reject {|d| d.name == package.name }, @packages)
end
end
+ @cached_dependencies[root] = { root_version => root_dependencies }
+
logger = Bundler::UI::Shell.new
logger.level = debug? ? "debug" : "warn"
@@ -67,7 +77,7 @@ module Bundler
end
def solve_versions(root:, logger:)
- solver = PubGrub::VersionSolver.new(:source => self, :root => root, :logger => logger)
+ solver = PubGrub::VersionSolver.new(source: self, root: root, logger: logger)
result = solver.solve
result.map {|package, version| version.to_specs(package) }.flatten.uniq
rescue PubGrub::SolveFailure => e
@@ -121,7 +131,7 @@ module Bundler
if base_requirements[name]
names_to_unlock << name
- elsif package.ignores_prereleases?
+ elsif package.ignores_prereleases? && @all_specs[name].any? {|s| s.version.prerelease? }
names_to_allow_prereleases_for << name
end
@@ -142,13 +152,19 @@ module Bundler
requirement_to_range(dependency)
end
- PubGrub::VersionConstraint.new(package, :range => range)
+ PubGrub::VersionConstraint.new(package, range: range)
end
def versions_for(package, range=VersionRange.any)
- versions = range.select_versions(@sorted_versions[package])
+ versions = select_sorted_versions(package, range)
- sort_versions(package, versions)
+ # Conditional avoids (among other things) calling
+ # sort_versions_by_preferred with the root package
+ if versions.size > 1
+ sort_versions_by_preferred(package, versions)
+ else
+ versions
+ end
end
def no_versions_incompatibility_for(package, unsatisfied_term)
@@ -158,7 +174,7 @@ module Bundler
constraint_string = constraint.constraint_string
requirements = constraint_string.split(" OR ").map {|req| Gem::Requirement.new(req.split(",")) }
- if name == "bundler"
+ if name == "bundler" && bundler_pinned_to_current_version?
custom_explanation = "the current Bundler version (#{Bundler::VERSION}) does not satisfy #{constraint}"
extended_explanation = bundler_not_found_message(requirements)
else
@@ -171,7 +187,7 @@ module Bundler
extended_explanation = other_specs_matching_message(specs_matching_other_platforms, label) if specs_matching_other_platforms.any?
end
- Incompatibility.new([unsatisfied_term], :cause => cause, :custom_explanation => custom_explanation, :extended_explanation => extended_explanation)
+ Incompatibility.new([unsatisfied_term], cause: cause, custom_explanation: custom_explanation, extended_explanation: extended_explanation)
end
def debug?
@@ -186,11 +202,6 @@ module Bundler
package_deps = @cached_dependencies[package]
sorted_versions = @sorted_versions[package]
package_deps[version].map do |dep_package, dep_constraint|
- if package == dep_package
- cause = PubGrub::Incompatibility::CircularDependency.new(dep_package, dep_constraint.constraint_string)
- return [PubGrub::Incompatibility.new([PubGrub::Term.new(dep_constraint, true)], :cause => cause)]
- end
-
low = high = sorted_versions.index(version)
# find version low such that all >= low share the same dep
@@ -215,9 +226,9 @@ module Bundler
sorted_versions[high]
end
- range = PubGrub::VersionRange.new(:min => low, :max => high, :include_min => true)
+ range = PubGrub::VersionRange.new(min: low, max: high, include_min: true)
- self_constraint = PubGrub::VersionConstraint.new(package, :range => range)
+ self_constraint = PubGrub::VersionConstraint.new(package, range: range)
dep_term = PubGrub::Term.new(dep_constraint, false)
self_term = PubGrub::Term.new(self_constraint, true)
@@ -226,37 +237,63 @@ module Bundler
"current #{dep_package} version is #{dep_constraint.constraint_string}"
end
- PubGrub::Incompatibility.new([self_term, dep_term], :cause => :dependency, :custom_explanation => custom_explanation)
+ PubGrub::Incompatibility.new([self_term, dep_term], cause: :dependency, custom_explanation: custom_explanation)
end
end
def all_versions_for(package)
name = package.name
results = (@base[name] + filter_prereleases(@all_specs[name], package)).uniq {|spec| [spec.version.hash, spec.platform] }
+
+ if name == "bundler" && !bundler_pinned_to_current_version?
+ bundler_spec = Gem.loaded_specs["bundler"]
+ results << bundler_spec if bundler_spec
+ end
+
locked_requirement = base_requirements[name]
results = filter_matching_specs(results, locked_requirement) if locked_requirement
- versions = results.group_by(&:version).reduce([]) do |groups, (version, specs)|
- platform_specs = package.platforms.flat_map {|platform| select_best_platform_match(specs, platform) }
- next groups if platform_specs.empty?
+ results.group_by(&:version).reduce([]) do |groups, (version, specs)|
+ platform_specs = package.platforms.map {|platform| select_best_platform_match(specs, platform) }
+
+ # If package is a top-level dependency,
+ # candidate is only valid if there are matching versions for all resolution platforms.
+ #
+ # If package is not a top-level deependency,
+ # then it's not necessary that it has matching versions for all platforms, since it may have been introduced only as
+ # a dependency for a platform specific variant, so it will only need to have a valid version for that platform.
+ #
+ if package.top_level?
+ next groups if platform_specs.any?(&:empty?)
+ else
+ next groups if platform_specs.all?(&:empty?)
+ end
+
+ platform_specs.flatten!
ruby_specs = select_best_platform_match(specs, Gem::Platform::RUBY)
- groups << Resolver::Candidate.new(version, :specs => ruby_specs) if ruby_specs.any?
+ groups << Resolver::Candidate.new(version, specs: ruby_specs) if ruby_specs.any?
- next groups if platform_specs == ruby_specs
+ next groups if platform_specs == ruby_specs || package.force_ruby_platform?
- groups << Resolver::Candidate.new(version, :specs => platform_specs)
+ groups << Resolver::Candidate.new(version, specs: platform_specs)
groups
end
-
- sort_versions(package, versions)
end
def source_for(name)
@source_requirements[name] || @source_requirements[:default]
end
+ def default_bundler_source
+ @source_requirements[:default_bundler]
+ end
+
+ def bundler_pinned_to_current_version?
+ !default_bundler_source.nil?
+ end
+
def name_for_explicit_dependency_source
Bundler.default_gemfile.basename.to_s
rescue StandardError
@@ -276,15 +313,21 @@ module Bundler
end
specs_matching_requirement = filter_matching_specs(specs, package.dependency.requirement)
- if specs_matching_requirement.any?
+ not_found_message = if specs_matching_requirement.any?
specs = specs_matching_requirement
matching_part = requirement_label
platforms = package.platforms
- platform_label = platforms.size == 1 ? "platform '#{platforms.first}" : "platforms '#{platforms.join("', '")}"
- requirement_label = "#{requirement_label}' with #{platform_label}"
+
+ if platforms.size == 1
+ "Could not find gem '#{requirement_label}' with platform '#{platforms.first}'"
+ else
+ "Could not find gems matching '#{requirement_label}' valid for all resolution platforms (#{platforms.join(", ")})"
+ end
+ else
+ "Could not find gem '#{requirement_label}'"
end
- message = String.new("Could not find gem '#{requirement_label}' in #{source}#{cache_message}.\n")
+ message = String.new("#{not_found_message} in #{source}#{cache_message}.\n")
if specs.any?
message << "\n#{other_specs_matching_message(specs, matching_part)}"
@@ -295,6 +338,21 @@ module Bundler
private
+ def filtered_versions_for(package)
+ @gem_version_promoter.filter_versions(package, @all_versions[package])
+ end
+
+ def raise_all_versions_filtered_out!(package)
+ level = @gem_version_promoter.level
+ name = package.name
+ locked_version = package.locked_version
+ requirement = package.dependency
+
+ raise GemNotFound,
+ "#{name} is locked to #{locked_version}, while Gemfile is requesting #{requirement}. " \
+ "--strict --#{level} was specified, but there are no #{level} level upgrades from #{locked_version} satisfying #{requirement}, so version solving has failed"
+ end
+
def filter_matching_specs(specs, requirements)
Array(requirements).flat_map do |requirement|
specs.select {| spec| requirement_satisfied_by?(requirement, spec) }
@@ -302,21 +360,24 @@ module Bundler
end
def filter_prereleases(specs, package)
- return specs unless package.ignores_prereleases?
+ return specs unless package.ignores_prereleases? && specs.size > 1
specs.reject {|s| s.version.prerelease? }
end
+ # Ignore versions that depend on themselves incorrectly
+ def filter_invalid_self_dependencies(specs, name)
+ specs.reject do |s|
+ s.dependencies.any? {|d| d.name == name && !d.requirement.satisfied_by?(s.version) }
+ end
+ end
+
def requirement_satisfied_by?(requirement, spec)
requirement.satisfied_by?(spec.version) || spec.source.is_a?(Source::Gemspec)
end
- def sort_versions(package, versions)
- if versions.size > 1
- @gem_version_promoter.sort_versions(package, versions).reverse
- else
- versions
- end
+ def sort_versions_by_preferred(package, versions)
+ @gem_version_promoter.sort_versions(package, versions)
end
def repository_for(package)
@@ -333,12 +394,19 @@ module Bundler
next [dep_package, dep_constraint] if name == "bundler"
- versions = versions_for(dep_package, dep_constraint.range)
+ dep_range = dep_constraint.range
+ versions = select_sorted_versions(dep_package, dep_range)
if versions.empty? && dep_package.ignores_prereleases?
+ @all_versions.delete(dep_package)
@sorted_versions.delete(dep_package)
dep_package.consider_prereleases!
- versions = versions_for(dep_package, dep_constraint.range)
+ versions = select_sorted_versions(dep_package, dep_range)
+ end
+
+ if versions.empty? && select_all_versions(dep_package, dep_range).any?
+ raise_all_versions_filtered_out!(dep_package)
end
+
next [dep_package, dep_constraint] unless versions.empty?
next unless dep_package.current_platform?
@@ -347,6 +415,14 @@ module Bundler
end.compact.to_h
end
+ def select_sorted_versions(package, range)
+ range.select_versions(@sorted_versions[package])
+ end
+
+ def select_all_versions(package, range)
+ range.select_versions(@all_versions[package])
+ end
+
def other_specs_matching_message(specs, requirement)
message = String.new("The source contains the following gems matching '#{requirement}':\n")
message << specs.map {|s| " * #{s.full_name}" }.join("\n")
@@ -362,19 +438,19 @@ module Bundler
when "~>"
name = "~> #{ver}"
bump = Resolver::Candidate.new(version.bump.to_s + ".A")
- PubGrub::VersionRange.new(:name => name, :min => ver, :max => bump, :include_min => true)
+ PubGrub::VersionRange.new(name: name, min: ver, max: bump, include_min: true)
when ">"
- PubGrub::VersionRange.new(:min => platform_ver)
+ PubGrub::VersionRange.new(min: platform_ver)
when ">="
- PubGrub::VersionRange.new(:min => ver, :include_min => true)
+ PubGrub::VersionRange.new(min: ver, include_min: true)
when "<"
- PubGrub::VersionRange.new(:max => ver)
+ PubGrub::VersionRange.new(max: ver)
when "<="
- PubGrub::VersionRange.new(:max => platform_ver, :include_max => true)
+ PubGrub::VersionRange.new(max: platform_ver, include_max: true)
when "="
- PubGrub::VersionRange.new(:min => ver, :max => platform_ver, :include_min => true, :include_max => true)
+ PubGrub::VersionRange.new(min: ver, max: platform_ver, include_min: true, include_max: true)
when "!="
- PubGrub::VersionRange.new(:min => ver, :max => platform_ver, :include_min => true, :include_max => true).invert
+ PubGrub::VersionRange.new(min: ver, max: platform_ver, include_min: true, include_max: true).invert
else
raise "bad version specifier: #{op}"
end
@@ -401,7 +477,7 @@ module Bundler
end
def bundler_not_found_message(conflict_dependencies)
- candidate_specs = filter_matching_specs(source_for(:default_bundler).specs.search("bundler"), conflict_dependencies)
+ candidate_specs = filter_matching_specs(default_bundler_source.specs.search("bundler"), conflict_dependencies)
if candidate_specs.any?
target_version = candidate_specs.last.version
diff --git a/lib/bundler/resolver/base.rb b/lib/bundler/resolver/base.rb
index 6921c047a7..ad19eeb3f4 100644
--- a/lib/bundler/resolver/base.rb
+++ b/lib/bundler/resolver/base.rb
@@ -24,7 +24,7 @@ module Bundler
name = dep.name
- @packages[name] = Package.new(name, dep_platforms, **options.merge(:dependency => dep))
+ @packages[name] = Package.new(name, dep_platforms, **options.merge(dependency: dep))
dep
end.compact
@@ -35,9 +35,7 @@ module Bundler
end
def delete(specs)
- specs.each do |spec|
- @base.delete(spec)
- end
+ @base.delete(specs)
end
def get_package(name)
@@ -49,10 +47,18 @@ module Bundler
end
def unlock_names(names)
- names.each do |name|
- @base.delete_by_name(name)
-
- @base_requirements.delete(name)
+ indirect_pins = indirect_pins(names)
+
+ if indirect_pins.any?
+ loosen_names(indirect_pins)
+ else
+ pins = pins(names)
+
+ if pins.any?
+ loosen_names(pins)
+ else
+ unrestrict_names(names)
+ end
end
end
@@ -64,6 +70,30 @@ module Bundler
private
+ def indirect_pins(names)
+ names.select {|name| @base_requirements[name].exact? && @requirements.none? {|dep| dep.name == name } }
+ end
+
+ def pins(names)
+ names.select {|name| @base_requirements[name].exact? }
+ end
+
+ def loosen_names(names)
+ names.each do |name|
+ version = @base_requirements[name].requirements.first[1]
+
+ @base_requirements[name] = Gem::Requirement.new(">= #{version}")
+
+ @base.delete_by_name(name)
+ end
+ end
+
+ def unrestrict_names(names)
+ names.each do |name|
+ @base_requirements.delete(name)
+ end
+ end
+
def build_base_requirements
base_requirements = {}
@base.each do |ls|
diff --git a/lib/bundler/resolver/candidate.rb b/lib/bundler/resolver/candidate.rb
index e695ef08ee..9e8b913335 100644
--- a/lib/bundler/resolver/candidate.rb
+++ b/lib/bundler/resolver/candidate.rb
@@ -15,7 +15,7 @@ module Bundler
# considered separately.
#
# Some candidates may also keep some information explicitly about the
- # package the refer to. These candidates are referred to as "canonical" and
+ # package they refer to. These candidates are referred to as "canonical" and
# are used when materializing resolution results back into RubyGems
# specifications that can be installed, written to lock files, and so on.
#
diff --git a/lib/bundler/resolver/incompatibility.rb b/lib/bundler/resolver/incompatibility.rb
index c61151fbeb..4ac1b2e1ea 100644
--- a/lib/bundler/resolver/incompatibility.rb
+++ b/lib/bundler/resolver/incompatibility.rb
@@ -8,7 +8,7 @@ module Bundler
def initialize(terms, cause:, custom_explanation: nil, extended_explanation: nil)
@extended_explanation = extended_explanation
- super(terms, :cause => cause, :custom_explanation => custom_explanation)
+ super(terms, cause: cause, custom_explanation: custom_explanation)
end
end
end
diff --git a/lib/bundler/resolver/package.rb b/lib/bundler/resolver/package.rb
index 7499a75006..0461328683 100644
--- a/lib/bundler/resolver/package.rb
+++ b/lib/bundler/resolver/package.rb
@@ -21,6 +21,7 @@ module Bundler
@locked_version = locked_specs[name].first&.version
@unlock = unlock
@dependency = dependency || Dependency.new(name, @locked_version)
+ @top_level = !dependency.nil?
@prerelease = @dependency.prerelease? || @locked_version&.prerelease? || prerelease ? :consider_first : :ignore
end
@@ -32,6 +33,10 @@ module Bundler
false
end
+ def top_level?
+ @top_level
+ end
+
def meta?
@name.end_with?("\0")
end
diff --git a/lib/bundler/resolver/spec_group.rb b/lib/bundler/resolver/spec_group.rb
index b44c19a73f..5cee444e5e 100644
--- a/lib/bundler/resolver/spec_group.rb
+++ b/lib/bundler/resolver/spec_group.rb
@@ -25,9 +25,8 @@ module Bundler
def to_specs(force_ruby_platform)
@specs.map do |s|
- lazy_spec = LazySpecification.new(name, version, s.platform, source)
+ lazy_spec = LazySpecification.from_spec(s)
lazy_spec.force_ruby_platform = force_ruby_platform
- lazy_spec.dependencies.replace s.dependencies
lazy_spec
end
end
@@ -64,8 +63,6 @@ module Bundler
end
def metadata_dependencies(spec)
- return [] if spec.is_a?(LazySpecification)
-
[
metadata_dependency("Ruby", spec.required_ruby_version),
metadata_dependency("RubyGems", spec.required_rubygems_version),
diff --git a/lib/bundler/retry.rb b/lib/bundler/retry.rb
index 2415ade200..b95c42c361 100644
--- a/lib/bundler/retry.rb
+++ b/lib/bundler/retry.rb
@@ -56,7 +56,7 @@ module Bundler
def keep_trying?
return true if current_run.zero?
return false if last_attempt?
- return true if @failed
+ true if @failed
end
def last_attempt?
diff --git a/lib/bundler/ruby_dsl.rb b/lib/bundler/ruby_dsl.rb
index 3b3a0583a5..fb4b79c4df 100644
--- a/lib/bundler/ruby_dsl.rb
+++ b/lib/bundler/ruby_dsl.rb
@@ -3,16 +3,51 @@
module Bundler
module RubyDsl
def ruby(*ruby_version)
- options = ruby_version.last.is_a?(Hash) ? ruby_version.pop : {}
+ options = ruby_version.pop if ruby_version.last.is_a?(Hash)
ruby_version.flatten!
- raise GemfileError, "Please define :engine_version" if options[:engine] && options[:engine_version].nil?
- raise GemfileError, "Please define :engine" if options[:engine_version] && options[:engine].nil?
- if options[:engine] == "ruby" && options[:engine_version] &&
- ruby_version != Array(options[:engine_version])
- raise GemfileEvalError, "ruby_version must match the :engine_version for MRI"
+ if options
+ patchlevel = options[:patchlevel]
+ engine = options[:engine]
+ engine_version = options[:engine_version]
+
+ raise GemfileError, "Please define :engine_version" if engine && engine_version.nil?
+ raise GemfileError, "Please define :engine" if engine_version && engine.nil?
+
+ if options[:file]
+ raise GemfileError, "Do not pass version argument when using :file option" unless ruby_version.empty?
+ ruby_version << normalize_ruby_file(options[:file])
+ end
+
+ if engine == "ruby" && engine_version && ruby_version != Array(engine_version)
+ raise GemfileEvalError, "ruby_version must match the :engine_version for MRI"
+ end
+ end
+
+ @ruby_version = RubyVersion.new(ruby_version, patchlevel, engine, engine_version)
+ end
+
+ # Support the various file formats found in .ruby-version files.
+ #
+ # 3.2.2
+ # ruby-3.2.2
+ #
+ # Also supports .tool-versions files for asdf. Lines not starting with "ruby" are ignored.
+ #
+ # ruby 2.5.1 # comment is ignored
+ # ruby 2.5.1# close comment and extra spaces doesn't confuse
+ #
+ # Intentionally does not support `3.2.1@gemset` since rvm recommends using .ruby-gemset instead
+ #
+ # Loads the file relative to the dirname of the Gemfile itself.
+ def normalize_ruby_file(filename)
+ file_content = Bundler.read_file(gemfile.dirname.join(filename))
+ # match "ruby-3.2.2" or "ruby 3.2.2" capturing version string up to the first space or comment
+ if /^ruby(-|\s+)([^\s#]+)/.match(file_content)
+ $2
+ else
+ file_content.strip
end
- @ruby_version = RubyVersion.new(ruby_version, options[:patchlevel], options[:engine], options[:engine_version])
end
end
end
diff --git a/lib/bundler/ruby_version.rb b/lib/bundler/ruby_version.rb
index b6bd24e41c..7e9e072b83 100644
--- a/lib/bundler/ruby_version.rb
+++ b/lib/bundler/ruby_version.rb
@@ -23,7 +23,7 @@ module Bundler
# specified must match the version.
@versions = Array(versions).map do |v|
- op, v = Gem::Requirement.parse(v)
+ op, v = Gem::Requirement.parse(normalize_version(v))
op == "=" ? v.to_s : "#{op} #{v}"
end
@@ -49,7 +49,7 @@ module Bundler
(\d+\.\d+\.\d+(?:\.\S+)?) # ruby version
(?:p(-?\d+))? # optional patchlevel
(?:\s\((\S+)\s(.+)\))? # optional engine info
- /xo.freeze
+ /xo
# Returns a RubyVersion from the given string.
# @param [String] the version string to match.
@@ -107,11 +107,18 @@ module Bundler
ruby_engine_version = RUBY_ENGINE == "ruby" ? ruby_version : RUBY_ENGINE_VERSION.dup
patchlevel = RUBY_PATCHLEVEL.to_s
- @ruby_version ||= RubyVersion.new(ruby_version, patchlevel, ruby_engine, ruby_engine_version)
+ @system ||= RubyVersion.new(ruby_version, patchlevel, ruby_engine, ruby_engine_version)
end
private
+ # Ruby's official preview version format uses a `-`: Example: 3.3.0-preview2
+ # However, RubyGems recognizes preview version format with a `.`: Example: 3.3.0.preview2
+ # Returns version string after replacing `-` with `.`
+ def normalize_version(version)
+ version.tr("-", ".")
+ end
+
def matches?(requirements, version)
# Handles RUBY_PATCHLEVEL of -1 for instances like ruby-head
return requirements == version if requirements.to_s == "-1" || version.to_s == "-1"
diff --git a/lib/bundler/rubygems_ext.rb b/lib/bundler/rubygems_ext.rb
index 0252e1a81a..e0582beba2 100644
--- a/lib/bundler/rubygems_ext.rb
+++ b/lib/bundler/rubygems_ext.rb
@@ -2,6 +2,8 @@
require "pathname"
+require "rubygems" unless defined?(Gem)
+
require "rubygems/specification"
# We can't let `Gem::Source` be autoloaded in the `Gem::Specification#source`
@@ -46,7 +48,7 @@ module Gem
def full_gem_path
if source.respond_to?(:root)
- Pathname.new(loaded_from).dirname.expand_path(source.root).to_s.tap {|x| x.untaint if RUBY_VERSION < "2.7" }
+ Pathname.new(loaded_from).dirname.expand_path(source.root).to_s
else
rg_full_gem_path
end
@@ -66,7 +68,9 @@ module Gem
alias_method :rg_extension_dir, :extension_dir
def extension_dir
- @bundler_extension_dir ||= if source.respond_to?(:extension_dir_name)
+ # following instance variable is already used in original method
+ # and that is the reason to prefix it with bundler_ and add rubocop exception
+ @bundler_extension_dir ||= if source.respond_to?(:extension_dir_name) # rubocop:disable Naming/MemoizedInstanceVariableName
unique_extension_dir = [source.extension_dir_name, File.basename(full_gem_path)].uniq.join("-")
File.expand_path(File.join(extensions_dir, unique_extension_dir))
else
@@ -74,7 +78,7 @@ module Gem
end
end
- remove_method :gem_dir if instance_methods(false).include?(:gem_dir)
+ remove_method :gem_dir
def gem_dir
full_gem_path
end
@@ -115,17 +119,6 @@ module Gem
gemfile
end
- # Backfill missing YAML require when not defined. Fixed since 3.1.0.pre1.
- module YamlBackfiller
- def to_yaml(opts = {})
- Gem.load_yaml unless defined?(::YAML)
-
- super(opts)
- end
- end
-
- prepend YamlBackfiller
-
def nondevelopment_dependencies
dependencies - development_dependencies
end
@@ -186,37 +179,7 @@ module Gem
end
end
- # comparison is done order independently since rubygems 3.2.0.rc.2
- unless Gem::Requirement.new("> 1", "< 2") == Gem::Requirement.new("< 2", "> 1")
- class Requirement
- module OrderIndependentComparison
- def ==(other)
- return unless Gem::Requirement === other
-
- if _requirements_sorted? && other._requirements_sorted?
- super
- else
- _with_sorted_requirements == other._with_sorted_requirements
- end
- end
-
- protected
-
- def _requirements_sorted?
- return @_are_requirements_sorted if defined?(@_are_requirements_sorted)
- strings = as_list
- @_are_requirements_sorted = strings == strings.sort
- end
-
- def _with_sorted_requirements
- @_with_sorted_requirements ||= _requirements_sorted? ? self : self.class.new(as_list.sort)
- end
- end
-
- prepend OrderIndependentComparison
- end
- end
-
+ # Requirements using lambda operator differentiate trailing zeros since rubygems 3.2.6
if Gem::Requirement.new("~> 2.0").hash == Gem::Requirement.new("~> 2.0.0").hash
class Requirement
module CorrectHashForLambdaOperator
@@ -318,7 +281,7 @@ module Gem
end
# On universal Rubies, resolve the "universal" arch to the real CPU arch, without changing the extension directory.
- class Specification
+ class BasicSpecification
if /^universal\.(?<arch>.*?)-/ =~ (CROSS_COMPILING || RUBY_PLATFORM)
local_platform = Platform.local
if local_platform.cpu == "universal"
@@ -331,23 +294,35 @@ module Gem
end
def extensions_dir
- Gem.default_ext_dir_for(base_dir) ||
- File.join(base_dir, "extensions", ORIGINAL_LOCAL_PLATFORM,
- Gem.extension_api_version)
+ @extensions_dir ||=
+ Gem.default_ext_dir_for(base_dir) || File.join(base_dir, "extensions", ORIGINAL_LOCAL_PLATFORM, Gem.extension_api_version)
end
end
end
end
- require "rubygems/util"
+ require "rubygems/name_tuple"
+
+ class NameTuple
+ # Versions of RubyGems before about 3.5.0 don't to_s the platform.
+ unless Gem::NameTuple.new("a", Gem::Version.new("1"), Gem::Platform.new("x86_64-linux")).platform.is_a?(String)
+ alias_method :initialize_with_platform, :initialize
- Util.singleton_class.module_eval do
- if Util.singleton_methods.include?(:glob_files_in_dir) # since 3.0.0.beta.2
- remove_method :glob_files_in_dir
+ def initialize(name, version, platform=Gem::Platform::RUBY)
+ if Gem::Platform === platform
+ initialize_with_platform(name, version, platform.to_s)
+ else
+ initialize_with_platform(name, version, platform)
+ end
+ end
end
- def glob_files_in_dir(glob, base_path)
- Dir.glob(glob, :base => base_path).map! {|f| File.expand_path(f, base_path) }
+ def lock_name
+ if platform == Gem::Platform::RUBY
+ "#{name} (#{version})"
+ else
+ "#{name} (#{version}-#{platform})"
+ end
end
end
end
diff --git a/lib/bundler/rubygems_gem_installer.rb b/lib/bundler/rubygems_gem_installer.rb
index 38035a00ac..d563868cd2 100644
--- a/lib/bundler/rubygems_gem_installer.rb
+++ b/lib/bundler/rubygems_gem_installer.rb
@@ -20,7 +20,7 @@ module Bundler
strict_rm_rf spec.extension_dir
SharedHelpers.filesystem_access(gem_dir, :create) do
- FileUtils.mkdir_p gem_dir, :mode => 0o755
+ FileUtils.mkdir_p gem_dir, mode: 0o755
end
extract_files
@@ -45,6 +45,14 @@ module Bundler
spec
end
+ def pre_install_checks
+ super
+ rescue Gem::FilePermissionError
+ # Ignore permission checks in RubyGems. Instead, go on, and try to write
+ # for real. We properly handle permission errors when they happen.
+ nil
+ end
+
def generate_plugins
return unless Gem::Installer.instance_methods(false).include?(:generate_plugins)
@@ -60,10 +68,6 @@ module Bundler
end
end
- def pre_install_checks
- super && validate_bundler_checksum(options[:bundler_expected_checksum])
- end
-
def build_extensions
extension_cache_path = options[:bundler_extension_cache_path]
extension_dir = spec.extension_dir
@@ -98,6 +102,10 @@ module Bundler
end
end
+ def gem_checksum
+ Checksum.from_gem_package(@package)
+ end
+
private
def prepare_extension_build(extension_dir)
@@ -108,64 +116,21 @@ module Bundler
end
def strict_rm_rf(dir)
- Bundler.rm_rf dir
- rescue StandardError => e
- raise unless File.exist?(dir)
+ return unless File.exist?(dir)
- raise DirectoryRemovalError.new(e, "Could not delete previous installation of `#{dir}`")
- end
-
- def validate_bundler_checksum(checksum)
- return true if Bundler.settings[:disable_checksum_validation]
- return true unless checksum
- return true unless source = @package.instance_variable_get(:@gem)
- return true unless source.respond_to?(:with_read_io)
- digest = source.with_read_io do |io|
- digest = SharedHelpers.digest(:SHA256).new
- digest << io.read(16_384) until io.eof?
- io.rewind
- send(checksum_type(checksum), digest)
- end
- unless digest == checksum
- raise SecurityError, <<-MESSAGE
- Bundler cannot continue installing #{spec.name} (#{spec.version}).
- The checksum for the downloaded `#{spec.full_name}.gem` does not match \
- the checksum given by the server. This means the contents of the downloaded \
- gem is different from what was uploaded to the server, and could be a potential security issue.
-
- To resolve this issue:
- 1. delete the downloaded gem located at: `#{spec.gem_dir}/#{spec.full_name}.gem`
- 2. run `bundle install`
-
- If you wish to continue installing the downloaded gem, and are certain it does not pose a \
- security issue despite the mismatching checksum, do the following:
- 1. run `bundle config set --local disable_checksum_validation true` to turn off checksum verification
- 2. run `bundle install`
-
- (More info: The expected SHA256 checksum was #{checksum.inspect}, but the \
- checksum for the downloaded gem was #{digest.inspect}.)
- MESSAGE
- end
- true
- end
+ parent = File.dirname(dir)
+ parent_st = File.stat(parent)
- def checksum_type(checksum)
- case checksum.length
- when 64 then :hexdigest!
- when 44 then :base64digest!
- else raise InstallError, "The given checksum for #{spec.full_name} (#{checksum.inspect}) is not a valid SHA256 hexdigest nor base64digest"
+ if parent_st.world_writable? && !parent_st.sticky?
+ raise InsecureInstallPathError.new(parent)
end
- end
- def hexdigest!(digest)
- digest.hexdigest!
- end
+ begin
+ FileUtils.remove_entry_secure(dir)
+ rescue StandardError => e
+ raise unless File.exist?(dir)
- def base64digest!(digest)
- if digest.respond_to?(:base64digest!)
- digest.base64digest!
- else
- [digest.digest!].pack("m0")
+ raise DirectoryRemovalError.new(e, "Could not delete previous installation of `#{dir}`")
end
end
end
diff --git a/lib/bundler/rubygems_integration.rb b/lib/bundler/rubygems_integration.rb
index c67c69266e..da555681f9 100644
--- a/lib/bundler/rubygems_integration.rb
+++ b/lib/bundler/rubygems_integration.rb
@@ -4,17 +4,12 @@ require "rubygems" unless defined?(Gem)
module Bundler
class RubygemsIntegration
- if defined?(Gem::Ext::Builder::CHDIR_MONITOR)
- EXT_LOCK = Gem::Ext::Builder::CHDIR_MONITOR
- else
- require "monitor"
+ require "monitor"
- EXT_LOCK = Monitor.new
- end
+ EXT_LOCK = Monitor.new
def initialize
@replaced_methods = {}
- backport_ext_builder_monitor
end
def version
@@ -43,18 +38,6 @@ module Bundler
Gem.loaded_specs[name]
end
- def add_to_load_path(paths)
- return Gem.add_to_load_path(*paths) if Gem.respond_to?(:add_to_load_path)
-
- if insert_index = Gem.load_path_insert_index
- # Gem directories must come after -I and ENV['RUBYLIB']
- $LOAD_PATH.insert(insert_index, *paths)
- else
- # We are probably testing in core, -I and RUBYLIB don't apply
- $LOAD_PATH.unshift(*paths)
- end
- end
-
def mark_loaded(spec)
if spec.respond_to?(:activated=)
current = Gem.loaded_specs[spec.name]
@@ -91,9 +74,9 @@ module Bundler
def spec_matches_for_glob(spec, glob)
return spec.matches_for_glob(glob) if spec.respond_to?(:matches_for_glob)
- spec.load_paths.map do |lp|
+ spec.load_paths.flat_map do |lp|
Dir["#{lp}/#{glob}#{suffix_pattern}"]
- end.flatten(1)
+ end
end
def stub_set_spec(stub, spec)
@@ -116,16 +99,6 @@ module Bundler
Gem::Util.inflate(obj)
end
- def correct_for_windows_path(path)
- if Gem::Util.respond_to?(:correct_for_windows_path)
- Gem::Util.correct_for_windows_path(path)
- elsif path[0].chr == "/" && path[1].chr =~ /[a-z]/i && path[2].chr == ":"
- path[1..-1]
- else
- path
- end
- end
-
def gem_dir
Gem.dir
end
@@ -161,7 +134,7 @@ module Bundler
def spec_cache_dirs
@spec_cache_dirs ||= begin
dirs = gem_path.map {|dir| File.join(dir, "specifications") }
- dirs << Gem.spec_cache_dir if Gem.respond_to?(:spec_cache_dir) # Not in RubyGems 2.0.3 or earlier
+ dirs << Gem.spec_cache_dir
dirs.uniq.select {|dir| File.directory? dir }
end
end
@@ -183,18 +156,6 @@ module Bundler
loaded_gem_paths.flatten
end
- def load_plugins
- Gem.load_plugins if Gem.respond_to?(:load_plugins)
- end
-
- def load_plugin_files(files)
- Gem.load_plugin_files(files) if Gem.respond_to?(:load_plugin_files)
- end
-
- def load_env_plugins
- Gem.load_env_plugins if Gem.respond_to?(:load_env_plugins)
- end
-
def ui=(obj)
Gem::DefaultUserInteraction.ui = obj
end
@@ -227,21 +188,21 @@ module Bundler
def reverse_rubygems_kernel_mixin
# Disable rubygems' gem activation system
- kernel = (class << ::Kernel; self; end)
- [kernel, ::Kernel].each do |k|
- if k.private_method_defined?(:gem_original_require)
- redefine_method(k, :require, k.instance_method(:gem_original_require))
+ if Gem.respond_to?(:discover_gems_on_require=)
+ Gem.discover_gems_on_require = false
+ else
+ [::Kernel.singleton_class, ::Kernel].each do |k|
+ if k.private_method_defined?(:gem_original_require)
+ redefine_method(k, :require, k.instance_method(:gem_original_require))
+ end
end
end
end
def replace_gem(specs, specs_by_name)
- reverse_rubygems_kernel_mixin
-
executables = nil
- kernel = (class << ::Kernel; self; end)
- [kernel, ::Kernel].each do |kernel_class|
+ [::Kernel.singleton_class, ::Kernel].each do |kernel_class|
redefine_method(kernel_class, :gem) do |dep, *reqs|
if executables&.include?(File.basename(caller.first.split(":").first))
break
@@ -354,6 +315,14 @@ module Bundler
def replace_entrypoints(specs)
specs_by_name = add_default_gems_to(specs)
+ reverse_rubygems_kernel_mixin
+ begin
+ # bundled_gems only provide with Ruby 3.3 or later
+ require "bundled_gems"
+ rescue LoadError
+ else
+ Gem::BUNDLED_GEMS.replace_require(specs) if Gem::BUNDLED_GEMS.respond_to?(:replace_require)
+ end
replace_gem(specs, specs_by_name)
stub_rubygems(specs)
replace_bin_path(specs_by_name)
@@ -443,30 +412,28 @@ module Bundler
Gem::Specification.all = specs
end
- def fetch_specs(remote, name)
+ def fetch_specs(remote, name, fetcher)
require "rubygems/remote_fetcher"
path = remote.uri.to_s + "#{name}.#{Gem.marshal_version}.gz"
- fetcher = gem_remote_fetcher
- fetcher.headers = { "X-Gemfile-Source" => remote.original_uri.to_s } if remote.original_uri
string = fetcher.fetch_path(path)
- Bundler.load_marshal(string)
+ specs = Bundler.safe_load_marshal(string)
+ raise MarshalError, "Specs #{name} from #{remote} is expected to be an Array but was unexpected class #{specs.class}" unless specs.is_a?(Array)
+ specs
rescue Gem::RemoteFetcher::FetchError
# it's okay for prerelease to fail
raise unless name == "prerelease_specs"
end
- def fetch_all_remote_specs(remote)
- specs = fetch_specs(remote, "specs")
- pres = fetch_specs(remote, "prerelease_specs") || []
+ def fetch_all_remote_specs(remote, gem_remote_fetcher)
+ specs = fetch_specs(remote, "specs", gem_remote_fetcher)
+ pres = fetch_specs(remote, "prerelease_specs", gem_remote_fetcher) || []
specs.concat(pres)
end
- def download_gem(spec, uri, cache_dir)
+ def download_gem(spec, uri, cache_dir, fetcher)
require "rubygems/remote_fetcher"
uri = Bundler.settings.mirror_for(uri)
- fetcher = gem_remote_fetcher
- fetcher.headers = { "X-Gemfile-Source" => spec.remote.original_uri.to_s } if spec.remote.original_uri
Bundler::Retry.new("download gem from #{uri}").attempts do
gem_file_name = spec.file_name
local_gem_path = File.join cache_dir, gem_file_name
@@ -474,7 +441,6 @@ module Bundler
begin
remote_gem_path = uri + "gems/#{gem_file_name}"
- remote_gem_path = remote_gem_path.to_s if provides?("< 3.2.0.rc.1")
SharedHelpers.filesystem_access(local_gem_path) do
fetcher.cache_update_path remote_gem_path, local_gem_path
@@ -493,12 +459,6 @@ module Bundler
raise Bundler::HTTPError, "Could not download gem from #{uri} due to underlying error <#{e.message}>"
end
- def gem_remote_fetcher
- require "rubygems/remote_fetcher"
- proxy = Gem.configuration[:http_proxy]
- Gem::RemoteFetcher.new(proxy)
- end
-
def build(spec, skip_validation = false)
require "rubygems/package"
Gem::Package.build(spec, skip_validation)
@@ -514,25 +474,6 @@ module Bundler
end
end
- def backport_ext_builder_monitor
- # So we can avoid requiring "rubygems/ext" in its entirety
- Gem.module_eval <<-RUBY, __FILE__, __LINE__ + 1
- module Ext
- end
- RUBY
-
- require "rubygems/ext/builder"
-
- Gem::Ext::Builder.class_eval do
- unless const_defined?(:CHDIR_MONITOR)
- const_set(:CHDIR_MONITOR, EXT_LOCK)
- end
-
- remove_const(:CHDIR_MUTEX) if const_defined?(:CHDIR_MUTEX)
- const_set(:CHDIR_MUTEX, const_get(:CHDIR_MONITOR))
- end
- end
-
def find_bundler(version)
find_name("bundler").find {|s| s.version.to_s == version }
end
@@ -541,14 +482,8 @@ module Bundler
Gem::Specification.stubs_for(name).map(&:to_spec)
end
- if Gem::Specification.respond_to?(:default_stubs)
- def default_stubs
- Gem::Specification.default_stubs("*.gemspec")
- end
- else
- def default_stubs
- Gem::Specification.send(:default_stubs, "*.gemspec")
- end
+ def default_stubs
+ Gem::Specification.default_stubs("*.gemspec")
end
end
diff --git a/lib/bundler/runtime.rb b/lib/bundler/runtime.rb
index bd38353d3c..ec772cfe7b 100644
--- a/lib/bundler/runtime.rb
+++ b/lib/bundler/runtime.rb
@@ -28,11 +28,11 @@ module Bundler
spec.load_paths.reject {|path| $LOAD_PATH.include?(path) }
end.reverse.flatten
- Bundler.rubygems.add_to_load_path(load_paths)
+ Gem.add_to_load_path(*load_paths)
setup_manpath
- lock(:preserve_unknown_sections => true)
+ lock(preserve_unknown_sections: true)
self
end
@@ -94,8 +94,8 @@ module Bundler
definition_method :requires
def lock(opts = {})
- return if @definition.nothing_changed? && !@definition.unlocking?
- @definition.lock(Bundler.default_lockfile, opts[:preserve_unknown_sections])
+ return if @definition.no_resolve_needed?
+ @definition.lock(opts[:preserve_unknown_sections])
end
alias_method :gems, :specs
diff --git a/lib/bundler/safe_marshal.rb b/lib/bundler/safe_marshal.rb
new file mode 100644
index 0000000000..50aa0f60a6
--- /dev/null
+++ b/lib/bundler/safe_marshal.rb
@@ -0,0 +1,31 @@
+# frozen_string_literal: true
+
+module Bundler
+ module SafeMarshal
+ ALLOWED_CLASSES = [
+ Array,
+ FalseClass,
+ Gem::Specification,
+ Gem::Version,
+ Hash,
+ String,
+ Symbol,
+ Time,
+ TrueClass,
+ ].freeze
+
+ ERROR = "Unexpected class %s present in marshaled data. Only %s are allowed."
+
+ PROC = proc do |object|
+ object.tap do
+ unless ALLOWED_CLASSES.include?(object.class)
+ raise TypeError, format(ERROR, object.class, ALLOWED_CLASSES.join(", "))
+ end
+ end
+ end
+
+ def self.proc
+ PROC
+ end
+ end
+end
diff --git a/lib/bundler/self_manager.rb b/lib/bundler/self_manager.rb
index 827f3f9222..bfd000b1a0 100644
--- a/lib/bundler/self_manager.rb
+++ b/lib/bundler/self_manager.rb
@@ -9,17 +9,23 @@ module Bundler
def restart_with_locked_bundler_if_needed
return unless needs_switching? && installed?
- restart_with(lockfile_version)
+ restart_with(restart_version)
end
def install_locked_bundler_and_restart_with_it_if_needed
return unless needs_switching?
- Bundler.ui.info \
- "Bundler #{current_version} is running, but your lockfile was generated with #{lockfile_version}. " \
- "Installing Bundler #{lockfile_version} and restarting using that version."
+ if restart_version == lockfile_version
+ Bundler.ui.info \
+ "Bundler #{current_version} is running, but your lockfile was generated with #{lockfile_version}. " \
+ "Installing Bundler #{lockfile_version} and restarting using that version."
+ else
+ Bundler.ui.info \
+ "Bundler #{current_version} is running, but your configuration was #{restart_version}. " \
+ "Installing Bundler #{restart_version} and restarting using that version."
+ end
- install_and_restart_with(lockfile_version)
+ install_and_restart_with(restart_version)
end
def update_bundler_and_restart_with_it_if_needed(target)
@@ -79,7 +85,8 @@ module Bundler
autoswitching_applies? &&
released?(lockfile_version) &&
!running?(lockfile_version) &&
- !updating?
+ !updating? &&
+ Bundler.settings[:version] != "system"
end
def autoswitching_applies?
@@ -106,7 +113,7 @@ module Bundler
end
def local_specs
- @local_specs ||= Bundler::Source::Rubygems.new("allow_local" => true).specs.select {|spec| spec.name == "bundler" }
+ @local_specs ||= Bundler::Source::Rubygems.new("allow_local" => true, "allow_cached" => true).specs.select {|spec| spec.name == "bundler" }
end
def remote_specs
@@ -114,7 +121,7 @@ module Bundler
source = Bundler::Source::Rubygems.new("remotes" => "https://rubygems.org")
source.remote!
source.add_dependency_names("bundler")
- source.specs
+ source.specs.select(&:matches_current_metadata?)
end
end
@@ -151,7 +158,7 @@ module Bundler
def installed?
Bundler.configure
- Bundler.rubygems.find_bundler(lockfile_version.to_s)
+ Bundler.rubygems.find_bundler(restart_version.to_s)
end
def current_version
@@ -163,6 +170,17 @@ module Bundler
parsed_version = Bundler::LockfileParser.bundled_with
@lockfile_version = parsed_version ? Gem::Version.new(parsed_version) : nil
+ rescue ArgumentError
+ @lockfile_version = nil
+ end
+
+ def restart_version
+ return @restart_version if defined?(@restart_version)
+ # BUNDLE_VERSION=x.y.z
+ @restart_version = Gem::Version.new(Bundler.settings[:version])
+ rescue ArgumentError
+ # BUNDLE_VERSION=lockfile
+ @restart_version = lockfile_version
end
end
end
diff --git a/lib/bundler/settings.rb b/lib/bundler/settings.rb
index a76a792743..379abfb24a 100644
--- a/lib/bundler/settings.rb
+++ b/lib/bundler/settings.rb
@@ -43,10 +43,23 @@ module Bundler
setup_makes_kernel_gem_public
silence_deprecations
silence_root_warning
- suppress_install_using_messages
update_requires_all_flag
].freeze
+ REMEMBERED_KEYS = %w[
+ bin
+ cache_all
+ clean
+ deployment
+ frozen
+ no_prune
+ path
+ shebang
+ path.system
+ without
+ with
+ ].freeze
+
NUMBER_KEYS = %w[
jobs
redirect
@@ -75,6 +88,7 @@ module Bundler
shebang
system_bindir
trust-policy
+ version
].freeze
DEFAULT_CONFIG = {
@@ -84,25 +98,38 @@ module Bundler
"BUNDLE_REDIRECT" => 5,
"BUNDLE_RETRY" => 3,
"BUNDLE_TIMEOUT" => 10,
+ "BUNDLE_VERSION" => "lockfile",
}.freeze
def initialize(root = nil)
@root = root
@local_config = load_config(local_config_file)
- @env_config = ENV.to_h.select {|key, _value| key =~ /\ABUNDLE_.+/ }
+
+ @env_config = ENV.to_h
+ @env_config.select! {|key, _value| key.start_with?("BUNDLE_") }
+ @env_config.delete("BUNDLE_")
+
@global_config = load_config(global_config_file)
@temporary = {}
+
+ @key_cache = {}
end
def [](name)
key = key_for(name)
- value = configs.values.map {|config| config[key] }.compact.first
+
+ value = nil
+ configs.each do |_, config|
+ value = config[key]
+ next if value.nil?
+ break
+ end
converted_value(value, name)
end
def set_command_option(key, value)
- if Bundler.feature_flag.forget_cli_options?
+ if !is_remembered(key) || Bundler.feature_flag.forget_cli_options?
temporary(key => value)
value
else
@@ -139,17 +166,22 @@ module Bundler
end
def all
- keys = @temporary.keys | @global_config.keys | @local_config.keys | @env_config.keys
+ keys = @temporary.keys.union(@global_config.keys, @local_config.keys, @env_config.keys)
- keys.map do |key|
- key.sub(/^BUNDLE_/, "").gsub(/___/, "-").gsub(/__/, ".").downcase
- end.sort
+ keys.map! do |key|
+ key = key.delete_prefix("BUNDLE_")
+ key.gsub!("___", "-")
+ key.gsub!("__", ".")
+ key.downcase!
+ key
+ end.sort!
+ keys
end
def local_overrides
repos = {}
all.each do |k|
- repos[$'] = self[k] if k =~ /^local\./
+ repos[k.delete_prefix("local.")] = self[k] if k.start_with?("local.")
end
repos
end
@@ -157,7 +189,7 @@ module Bundler
def mirror_for(uri)
if uri.is_a?(String)
require_relative "vendored_uri"
- uri = Bundler::URI(uri)
+ uri = Gem::URI(uri)
end
gem_mirrors.for(uri.to_s).uri
@@ -219,7 +251,6 @@ module Bundler
def path
configs.each do |_level, settings|
path = value_for("path", settings)
- path = "vendor/bundle" if value_for("deployment", settings) && path.nil?
path_system = value_for("path.system", settings)
disabled_shared_gems = value_for("disable_shared_gems", settings)
next if path.nil? && path_system.nil? && disabled_shared_gems.nil?
@@ -227,7 +258,9 @@ module Bundler
return Path.new(path, system_path)
end
- Path.new(nil, false)
+ path = "vendor/bundle" if self[:deployment]
+
+ Path.new(path, false)
end
Path = Struct.new(:explicit_path, :system_path) do
@@ -295,18 +328,18 @@ module Bundler
end
def key_for(key)
- self.class.key_for(key)
+ @key_cache[key] ||= self.class.key_for(key)
end
private
def configs
- {
- :temporary => @temporary,
- :local => @local_config,
- :env => @env_config,
- :global => @global_config,
- :default => DEFAULT_CONFIG,
+ @configs ||= {
+ temporary: @temporary,
+ local: @local_config,
+ env: @env_config,
+ global: @global_config,
+ default: DEFAULT_CONFIG,
}
end
@@ -327,16 +360,20 @@ module Bundler
end
def is_bool(name)
- BOOL_KEYS.include?(name.to_s) || BOOL_KEYS.include?(parent_setting_for(name.to_s))
+ name = self.class.key_to_s(name)
+ BOOL_KEYS.include?(name) || BOOL_KEYS.include?(parent_setting_for(name))
end
def is_string(name)
- STRING_KEYS.include?(name.to_s) || name.to_s.start_with?("local.") || name.to_s.start_with?("mirror.") || name.to_s.start_with?("build.")
+ name = self.class.key_to_s(name)
+ STRING_KEYS.include?(name) || name.start_with?("local.") || name.start_with?("mirror.") || name.start_with?("build.")
end
def to_bool(value)
case value
- when nil, /\A(false|f|no|n|0|)\z/i, false
+ when String
+ value.match?(/\A(false|f|no|n|0|)\z/i) ? false : true
+ when nil, false
false
else
true
@@ -344,11 +381,15 @@ module Bundler
end
def is_num(key)
- NUMBER_KEYS.include?(key.to_s)
+ NUMBER_KEYS.include?(self.class.key_to_s(key))
end
def is_array(key)
- ARRAY_KEYS.include?(key.to_s)
+ ARRAY_KEYS.include?(self.class.key_to_s(key))
+ end
+
+ def is_remembered(key)
+ REMEMBERED_KEYS.include?(self.class.key_to_s(key))
end
def is_credential(key)
@@ -371,7 +412,7 @@ module Bundler
end
def set_key(raw_key, value, hash, file)
- raw_key = raw_key.to_s
+ raw_key = self.class.key_to_s(raw_key)
value = array_to_s(value) if is_array(raw_key)
key = key_for(raw_key)
@@ -386,12 +427,13 @@ module Bundler
return unless file
SharedHelpers.filesystem_access(file) do |p|
FileUtils.mkdir_p(p.dirname)
- require_relative "yaml_serializer"
- p.open("w") {|f| f.write(YAMLSerializer.dump(hash)) }
+ p.open("w") {|f| f.write(serializer_class.dump(hash)) }
end
end
def converted_value(value, key)
+ key = self.class.key_to_s(key)
+
if is_array(key)
to_array(value)
elsif value.nil?
@@ -449,24 +491,34 @@ module Bundler
SharedHelpers.filesystem_access(config_file, :read) do |file|
valid_file = file.exist? && !file.size.zero?
return {} unless valid_file
- require_relative "yaml_serializer"
- YAMLSerializer.load(file.read).inject({}) do |config, (k, v)|
- new_k = k
-
- if k.include?("-")
- Bundler.ui.warn "Your #{file} config includes `#{k}`, which contains the dash character (`-`).\n" \
- "This is deprecated, because configuration through `ENV` should be possible, but `ENV` keys cannot include dashes.\n" \
- "Please edit #{file} and replace any dashes in configuration keys with a triple underscore (`___`)."
-
- new_k = k.gsub("-", "___")
+ serializer_class.load(file.read).inject({}) do |config, (k, v)|
+ unless k.start_with?("#")
+ if k.include?("-")
+ Bundler.ui.warn "Your #{file} config includes `#{k}`, which contains the dash character (`-`).\n" \
+ "This is deprecated, because configuration through `ENV` should be possible, but `ENV` keys cannot include dashes.\n" \
+ "Please edit #{file} and replace any dashes in configuration keys with a triple underscore (`___`)."
+
+ # string hash keys are frozen
+ k = k.gsub("-", "___")
+ end
+
+ config[k] = v
end
- config[new_k] = v
config
end
end
end
+ def serializer_class
+ require "rubygems/yaml_serializer"
+ Gem::YAMLSerializer
+ rescue LoadError
+ # TODO: Remove this when RubyGems 3.4 is EOL
+ require_relative "yaml_serializer"
+ YAMLSerializer
+ end
+
PER_URI_OPTIONS = %w[
fallback_timeout
].freeze
@@ -478,12 +530,15 @@ module Bundler
(https?.*?) # URI
(\.#{Regexp.union(PER_URI_OPTIONS)})? # optional suffix key
\z
- /ix.freeze
+ /ix
def self.key_for(key)
key = normalize_uri(key).to_s if key.is_a?(String) && key.start_with?("http", "mirror.http")
- key = key.to_s.gsub(".", "__").gsub("-", "___").upcase
- "BUNDLE_#{key}"
+ key = key_to_s(key).gsub(".", "__")
+ key.gsub!("-", "___")
+ key.upcase!
+
+ key.prepend("BUNDLE_")
end
# TODO: duplicates Rubygems#normalize_uri
@@ -495,13 +550,42 @@ module Bundler
uri = $2
suffix = $3
end
- uri = "#{uri}/" unless uri.end_with?("/")
+ uri = URINormalizer.normalize_suffix(uri)
require_relative "vendored_uri"
- uri = Bundler::URI(uri)
+ uri = Gem::URI(uri)
unless uri.absolute?
raise ArgumentError, format("Gem sources must be absolute. You provided '%s'.", uri)
end
"#{prefix}#{uri}#{suffix}"
end
+
+ # This is a hot method, so avoid respond_to? checks on every invocation
+ if :read.respond_to?(:name)
+ def self.key_to_s(key)
+ case key
+ when String
+ key
+ when Symbol
+ key.name
+ when Gem::URI::HTTP
+ key.to_s
+ else
+ raise ArgumentError, "Invalid key: #{key.inspect}"
+ end
+ end
+ else
+ def self.key_to_s(key)
+ case key
+ when String
+ key
+ when Symbol
+ key.to_s
+ when Gem::URI::HTTP
+ key.to_s
+ else
+ raise ArgumentError, "Invalid key: #{key.inspect}"
+ end
+ end
+ end
end
end
diff --git a/lib/bundler/setup.rb b/lib/bundler/setup.rb
index 32e9b2d7c0..7131d15055 100644
--- a/lib/bundler/setup.rb
+++ b/lib/bundler/setup.rb
@@ -12,7 +12,13 @@ if Bundler::SharedHelpers.in_bundle?
Bundler.ui.error e.message
Bundler.ui.warn e.backtrace.join("\n") if ENV["DEBUG"]
if e.is_a?(Bundler::GemNotFound)
- Bundler.ui.warn "Run `bundle install` to install missing gems."
+ default_bundle = Gem.bin_path("bundler", "bundle")
+ current_bundle = Bundler::SharedHelpers.bundle_bin_path
+ suggested_bundle = default_bundle == current_bundle ? "bundle" : current_bundle
+ suggested_cmd = "#{suggested_bundle} install"
+ original_gemfile = Bundler.original_env["BUNDLE_GEMFILE"]
+ suggested_cmd += " --gemfile #{original_gemfile}" if original_gemfile
+ Bundler.ui.warn "Run `#{suggested_cmd}` to install missing gems."
end
exit e.status_code
end
diff --git a/lib/bundler/shared_helpers.rb b/lib/bundler/shared_helpers.rb
index 794a03e62d..78760e6fa4 100644
--- a/lib/bundler/shared_helpers.rb
+++ b/lib/bundler/shared_helpers.rb
@@ -13,13 +13,13 @@ module Bundler
def root
gemfile = find_gemfile
raise GemfileNotFound, "Could not locate Gemfile" unless gemfile
- Pathname.new(gemfile).tap {|x| x.untaint if RUBY_VERSION < "2.7" }.expand_path.parent
+ Pathname.new(gemfile).expand_path.parent
end
def default_gemfile
gemfile = find_gemfile
raise GemfileNotFound, "Could not locate Gemfile" unless gemfile
- Pathname.new(gemfile).tap {|x| x.untaint if RUBY_VERSION < "2.7" }.expand_path
+ Pathname.new(gemfile).expand_path
end
def default_lockfile
@@ -28,7 +28,7 @@ module Bundler
case gemfile.basename.to_s
when "gems.rb" then Pathname.new(gemfile.sub(/.rb$/, ".locked"))
else Pathname.new("#{gemfile}.lock")
- end.tap {|x| x.untaint if RUBY_VERSION < "2.7" }
+ end
end
def default_bundle_dir
@@ -100,7 +100,7 @@ module Bundler
#
# @see {Bundler::PermissionError}
def filesystem_access(path, action = :write, &block)
- yield(path.dup.tap {|x| x.untaint if RUBY_VERSION < "2.7" })
+ yield(path.dup)
rescue Errno::EACCES
raise PermissionError.new(path, action)
rescue Errno::EAGAIN
@@ -117,16 +117,18 @@ module Bundler
raise GenericSystemCallError.new(e, "There was an error accessing `#{path}`.")
end
- def major_deprecation(major_version, message, print_caller_location: false)
+ def major_deprecation(major_version, message, removed_message: nil, print_caller_location: false)
if print_caller_location
caller_location = caller_locations(2, 2).first
- message = "#{message} (called at #{caller_location.path}:#{caller_location.lineno})"
+ suffix = " (called at #{caller_location.path}:#{caller_location.lineno})"
+ message += suffix
+ removed_message += suffix if removed_message
end
bundler_major_version = Bundler.bundler_major_version
if bundler_major_version > major_version
require_relative "errors"
- raise DeprecatedError, "[REMOVED] #{message}"
+ raise DeprecatedError, "[REMOVED] #{removed_message || message}"
end
return unless bundler_major_version >= major_version && prints_major_deprecations?
@@ -160,7 +162,7 @@ module Bundler
" (was expecting #{old_deps.map(&:to_s)}, but the real spec has #{new_deps.map(&:to_s)})"
raise APIResponseMismatchError,
"Downloading #{spec.full_name} revealed dependencies not in the API or the lockfile (#{extra_deps.join(", ")})." \
- "\nEither installing with `--full-index` or running `bundle update #{spec.name}` should fix the problem."
+ "\nRunning `bundle update #{spec.name}` should fix the problem."
end
def pretty_dependency(dep)
@@ -193,10 +195,40 @@ module Bundler
Digest(name)
end
+ def checksum_for_file(path, digest)
+ return unless path.file?
+ # This must use File.read instead of Digest.file().hexdigest
+ # because we need to preserve \n line endings on windows when calculating
+ # the checksum
+ SharedHelpers.filesystem_access(path, :read) do
+ File.open(path, "rb") do |f|
+ digest = SharedHelpers.digest(digest).new
+ buf = String.new(capacity: 16_384, encoding: Encoding::BINARY)
+ digest << buf while f.read(16_384, buf)
+ digest.hexdigest
+ end
+ end
+ end
+
def write_to_gemfile(gemfile_path, contents)
filesystem_access(gemfile_path) {|g| File.open(g, "w") {|file| file.puts contents } }
end
+ def relative_gemfile_path
+ relative_path_to(Bundler.default_gemfile)
+ end
+
+ def relative_lockfile_path
+ relative_path_to(Bundler.default_lockfile)
+ end
+
+ def relative_path_to(destination, from: pwd)
+ Pathname.new(destination).relative_path_from(from).to_s
+ rescue ArgumentError
+ # on Windows, if source and destination are on different drivers, there's no relative path from one to the other
+ destination
+ end
+
private
def validate_bundle_path
@@ -235,7 +267,7 @@ module Bundler
def search_up(*names)
previous = nil
- current = File.expand_path(SharedHelpers.pwd).tap {|x| x.untaint if RUBY_VERSION < "2.7" }
+ current = File.expand_path(SharedHelpers.pwd)
until !File.directory?(current) || current == previous
if ENV["BUNDLER_SPEC_RUN"]
@@ -272,6 +304,13 @@ module Bundler
public :set_env
def set_bundle_variables
+ Bundler::SharedHelpers.set_env "BUNDLE_BIN_PATH", bundle_bin_path
+ Bundler::SharedHelpers.set_env "BUNDLE_GEMFILE", find_gemfile.to_s
+ Bundler::SharedHelpers.set_env "BUNDLER_VERSION", Bundler::VERSION
+ Bundler::SharedHelpers.set_env "BUNDLER_SETUP", File.expand_path("setup", __dir__)
+ end
+
+ def bundle_bin_path
# bundler exe & lib folders have same root folder, typical gem installation
exe_file = File.expand_path("../../exe/bundle", __dir__)
@@ -281,11 +320,9 @@ module Bundler
# bundler is a default gem, exe path is separate
exe_file = Bundler.rubygems.bin_path("bundler", "bundle", VERSION) unless File.exist?(exe_file)
- Bundler::SharedHelpers.set_env "BUNDLE_BIN_PATH", exe_file
- Bundler::SharedHelpers.set_env "BUNDLE_GEMFILE", find_gemfile.to_s
- Bundler::SharedHelpers.set_env "BUNDLER_VERSION", Bundler::VERSION
- Bundler::SharedHelpers.set_env "BUNDLER_SETUP", File.expand_path("setup", __dir__) unless RUBY_VERSION < "2.7"
+ exe_file
end
+ public :bundle_bin_path
def set_path
validate_bundle_path
@@ -297,7 +334,7 @@ module Bundler
def set_rubyopt
rubyopt = [ENV["RUBYOPT"]].compact
setup_require = "-r#{File.expand_path("setup", __dir__)}"
- return if !rubyopt.empty? && rubyopt.first =~ /#{setup_require}/
+ return if !rubyopt.empty? && rubyopt.first.include?(setup_require)
rubyopt.unshift setup_require
Bundler::SharedHelpers.set_env "RUBYOPT", rubyopt.join(" ")
end
diff --git a/lib/bundler/source.rb b/lib/bundler/source.rb
index 69804a2e63..115dbd1378 100644
--- a/lib/bundler/source.rb
+++ b/lib/bundler/source.rb
@@ -11,6 +11,8 @@ module Bundler
attr_accessor :dependency_names
+ attr_reader :checksum_store
+
def unmet_deps
specs.unmet_dependency_names
end
@@ -100,7 +102,7 @@ module Bundler
end
def print_using_message(message)
- if !message.include?("(was ") && Bundler.feature_flag.suppress_install_using_messages?
+ if !message.include?("(was ")
Bundler.ui.debug message
else
Bundler.ui.info message
diff --git a/lib/bundler/source/git.rb b/lib/bundler/source/git.rb
index b8ee4029b4..198e335bb6 100644
--- a/lib/bundler/source/git.rb
+++ b/lib/bundler/source/git.rb
@@ -11,6 +11,7 @@ module Bundler
def initialize(options)
@options = options
+ @checksum_store = Checksum::Store.new
@glob = options["glob"] || DEFAULT_GLOB
@allow_cached = false
@@ -19,7 +20,7 @@ module Bundler
# Stringify options that could be set as symbols
%w[ref branch tag revision].each {|k| options[k] = options[k].to_s if options[k] }
- @uri = options["uri"] || ""
+ @uri = URINormalizer.normalize_suffix(options["uri"] || "", trailing_slash: false)
@safe_uri = URICredentialsFilter.credential_filtered_uri(@uri)
@branch = options["branch"]
@ref = options["ref"] || options["branch"] || options["tag"]
@@ -46,6 +47,14 @@ module Bundler
out << " specs:\n"
end
+ def to_gemfile
+ specifiers = %w[ref branch tag submodules glob].map do |opt|
+ "#{opt}: #{options[opt]}" if options[opt]
+ end
+
+ uri_with_specifiers(specifiers)
+ end
+
def hash
[self.class, uri, ref, branch, name, version, glob, submodules].hash
end
@@ -59,28 +68,32 @@ module Bundler
alias_method :==, :eql?
+ def include?(other)
+ other.is_a?(Git) && uri == other.uri &&
+ name == other.name &&
+ glob == other.glob &&
+ submodules == other.submodules
+ end
+
def to_s
begin
- at = if local?
- path
- elsif user_ref = options["ref"]
- if /\A[a-z0-9]{4,}\z/i.match?(ref)
- shortref_for_display(user_ref)
- else
- user_ref
- end
- elsif ref
- ref
- else
- current_branch
- end
+ at = humanized_ref || current_branch
rev = "at #{at}@#{shortref_for_display(revision)}"
rescue GitError
""
end
- specifiers = [rev, glob_for_display].compact
+ uri_with_specifiers([rev, glob_for_display])
+ end
+
+ def identifier
+ uri_with_specifiers([humanized_ref, cached_revision, glob_for_display])
+ end
+
+ def uri_with_specifiers(specifiers)
+ specifiers.compact!
+
suffix =
if specifiers.any?
" (#{specifiers.join(", ")})"
@@ -173,6 +186,7 @@ module Bundler
end
def install(spec, options = {})
+ return if Bundler.settings[:no_install]
force = options[:force]
print_using_message "Using #{version_message(spec, options[:previous_spec])} from #{self}"
@@ -184,7 +198,7 @@ module Bundler
@copied = true
end
- generate_bin_options = { :disable_extensions => !Bundler.rubygems.spec_missing_extensions?(spec), :build_args => options[:build_args] }
+ generate_bin_options = { disable_extensions: !Bundler.rubygems.spec_missing_extensions?(spec), build_args: options[:build_args] }
generate_bin(spec, generate_bin_options)
requires_checkout? ? spec.post_install_message : nil
@@ -242,6 +256,20 @@ module Bundler
private
+ def humanized_ref
+ if local?
+ path
+ elsif user_ref = options["ref"]
+ if /\A[a-z0-9]{4,}\z/i.match?(ref)
+ shortref_for_display(user_ref)
+ else
+ user_ref
+ end
+ elsif ref
+ ref
+ end
+ end
+
def serialize_gemspecs_in(destination)
destination = destination.expand_path(Bundler.root) if destination.relative?
Dir["#{destination}/#{@glob}"].each do |spec_path|
@@ -298,7 +326,7 @@ module Bundler
if %r{^\w+://(\w+@)?}.match?(uri)
# Downcase the domain component of the URI
# and strip off a trailing slash, if one is present
- input = Bundler::URI.parse(uri).normalize.to_s.sub(%r{/$}, "")
+ input = Gem::URI.parse(uri).normalize.to_s.sub(%r{/$}, "")
else
# If there is no URI scheme, assume it is an ssh/git URI
input = uri
@@ -332,7 +360,7 @@ module Bundler
def load_gemspec(file)
stub = Gem::StubSpecification.gemspec_stub(file, install_path.parent, install_path.parent)
- stub.full_gem_path = Pathname.new(file).dirname.expand_path(root).to_s.tap {|x| x.untaint if RUBY_VERSION < "2.7" }
+ stub.full_gem_path = Pathname.new(file).dirname.expand_path(root).to_s
StubSpecification.from_stub(stub)
end
diff --git a/lib/bundler/source/git/git_proxy.rb b/lib/bundler/source/git/git_proxy.rb
index 2a7c8473f5..645851286c 100644
--- a/lib/bundler/source/git/git_proxy.rb
+++ b/lib/bundler/source/git/git_proxy.rb
@@ -28,8 +28,9 @@ module Bundler
def initialize(command, path, extra_info = nil)
@command = command
- msg = String.new
- msg << "Git error: command `#{command}` in directory #{path} has failed."
+ msg = String.new("Git error: command `#{command}`")
+ msg << " in directory #{path}" if path
+ msg << " has failed."
msg << "\n#{extra_info}" if extra_info
super msg
end
@@ -42,6 +43,13 @@ module Bundler
end
end
+ class AmbiguousGitReference < GitError
+ def initialize(options)
+ msg = "Specification of branch or ref with tag is ambiguous. You specified #{options.inspect}"
+ super msg
+ end
+ end
+
# The GitProxy is responsible to interact with git repositories.
# All actions required by the Git source is encapsulated in this
# object.
@@ -52,10 +60,15 @@ module Bundler
def initialize(path, uri, options = {}, revision = nil, git = nil)
@path = path
@uri = uri
- @branch = options["branch"]
@tag = options["tag"]
+ @branch = options["branch"]
@ref = options["ref"]
- @explicit_ref = branch || tag || ref
+ if @tag
+ raise AmbiguousGitReference.new(options) if @branch || @ref
+ @explicit_ref = @tag
+ else
+ @explicit_ref = @ref || @branch
+ end
@revision = revision
@git = git
@commit_ref = nil
@@ -66,15 +79,15 @@ module Bundler
end
def current_branch
- @current_branch ||= allowed_with_path do
- git("rev-parse", "--abbrev-ref", "HEAD", :dir => path).strip
+ @current_branch ||= with_path do
+ git_local("rev-parse", "--abbrev-ref", "HEAD", dir: path).strip
end
end
def contains?(commit)
allowed_with_path do
- result, status = git_null("branch", "--contains", commit, :dir => path)
- status.success? && result =~ /^\* (.*)$/
+ result, status = git_null("branch", "--contains", commit, dir: path)
+ status.success? && result.match?(/^\* (.*)$/)
end
end
@@ -83,7 +96,7 @@ module Bundler
end
def full_version
- @full_version ||= git("--version").sub(/git version\s*/, "").strip
+ @full_version ||= git_local("--version").sub(/git version\s*/, "").strip
end
def checkout
@@ -117,15 +130,20 @@ module Bundler
end
end
- git "fetch", "--force", "--quiet", *extra_fetch_args, :dir => destination if @commit_ref
+ ref = @commit_ref || (locked_to_full_sha? && @revision)
+ if ref
+ git "config", "uploadpack.allowAnySHA1InWant", "true", dir: path.to_s if @commit_ref.nil? && needs_allow_any_sha1_in_want?
+
+ git "fetch", "--force", "--quiet", *extra_fetch_args(ref), dir: destination
+ end
- git "reset", "--hard", @revision, :dir => destination
+ git "reset", "--hard", @revision, dir: destination
if submodules
- git_retry "submodule", "update", "--init", "--recursive", :dir => destination
+ git_retry "submodule", "update", "--init", "--recursive", dir: destination
elsif Gem::Version.create(version) >= Gem::Version.create("2.9.0")
inner_command = "git -C $toplevel submodule deinit --force $sm_path"
- git_retry "submodule", "foreach", "--quiet", inner_command, :dir => destination
+ git_retry "submodule", "foreach", "--quiet", inner_command, dir: destination
end
end
@@ -139,8 +157,8 @@ module Bundler
out, err, status = capture(command, path)
return out if status.success?
- if err.include?("couldn't find remote ref")
- raise MissingGitRevisionError.new(command_with_no_credentials, path, explicit_ref, credential_filtered_uri)
+ if err.include?("couldn't find remote ref") || err.include?("not our ref")
+ raise MissingGitRevisionError.new(command_with_no_credentials, path, commit || explicit_ref, credential_filtered_uri)
else
raise GitCommandError.new(command_with_no_credentials, path, err)
end
@@ -153,9 +171,20 @@ module Bundler
SharedHelpers.filesystem_access(path.dirname) do |p|
FileUtils.mkdir_p(p)
end
- git_retry "clone", "--bare", "--no-hardlinks", "--quiet", *extra_clone_args, "--", configured_uri, path.to_s
- extra_ref
+ command = ["clone", "--bare", "--no-hardlinks", "--quiet", *extra_clone_args, "--", configured_uri, path.to_s]
+ command_with_no_credentials = check_allowed(command)
+
+ Bundler::Retry.new("`#{command_with_no_credentials}`", [MissingGitRevisionError]).attempts do
+ _, err, status = capture(command, nil)
+ return extra_ref if status.success?
+
+ if err.include?("Could not find remote branch")
+ raise MissingGitRevisionError.new(command_with_no_credentials, nil, explicit_ref, credential_filtered_uri)
+ else
+ raise GitCommandError.new(command_with_no_credentials, path, err)
+ end
+ end
end
def clone_needs_unshallow?
@@ -186,8 +215,6 @@ module Bundler
end
def refspec
- commit = pinned_to_full_sha? ? ref : @revision
-
if commit
@commit_ref = "refs/#{commit}-sha"
return "#{commit}:#{@commit_ref}"
@@ -206,6 +233,10 @@ module Bundler
"#{reference}:#{reference}"
end
+ def commit
+ @commit ||= pinned_to_full_sha? ? ref : @revision
+ end
+
def fully_qualified_ref
if branch
"refs/heads/#{branch}"
@@ -221,38 +252,46 @@ module Bundler
end
def pinned_to_full_sha?
- ref =~ /\A\h{40}\z/
+ full_sha_revision?(ref)
+ end
+
+ def locked_to_full_sha?
+ full_sha_revision?(@revision)
+ end
+
+ def full_sha_revision?(ref)
+ ref&.match?(/\A\h{40}\z/)
end
def git_null(*command, dir: nil)
check_allowed(command)
- capture(command, dir, :ignore_err => true)
+ capture(command, dir, ignore_err: true)
end
def git_retry(*command, dir: nil)
command_with_no_credentials = check_allowed(command)
Bundler::Retry.new("`#{command_with_no_credentials}` at #{dir || SharedHelpers.pwd}").attempts do
- git(*command, :dir => dir)
+ git(*command, dir: dir)
end
end
def git(*command, dir: nil)
- command_with_no_credentials = check_allowed(command)
-
- out, err, status = capture(command, dir)
-
- raise GitCommandError.new(command_with_no_credentials, dir || SharedHelpers.pwd, err) unless status.success?
-
- Bundler.ui.warn err unless err.empty?
+ run_command(*command, dir: dir) do |unredacted_command|
+ check_allowed(unredacted_command)
+ end
+ end
- out
+ def git_local(*command, dir: nil)
+ run_command(*command, dir: dir) do |unredacted_command|
+ redact_and_check_presence(unredacted_command)
+ end
end
def has_revision_cached?
return unless @revision && path.exist?
- git("cat-file", "-e", @revision, :dir => path)
+ git("cat-file", "-e", @revision, dir: path)
true
rescue GitError
false
@@ -275,13 +314,13 @@ module Bundler
end
def verify(reference)
- git("rev-parse", "--verify", reference, :dir => path).strip
+ git("rev-parse", "--verify", reference, dir: path).strip
end
# Adds credentials to the URI
def configured_uri
if /https?:/.match?(uri)
- remote = Bundler::URI(uri)
+ remote = Gem::URI(uri)
config_auth = Bundler.settings[remote.to_s] || Bundler.settings[remote.host]
remote.userinfo ||= config_auth
remote.to_s
@@ -316,12 +355,30 @@ module Bundler
end
def check_allowed(command)
- require "shellwords"
- command_with_no_credentials = URICredentialsFilter.credential_filtered_string("git #{command.shelljoin}", uri)
+ command_with_no_credentials = redact_and_check_presence(command)
raise GitNotAllowedError.new(command_with_no_credentials) unless allow?
command_with_no_credentials
end
+ def redact_and_check_presence(command)
+ raise GitNotInstalledError.new unless Bundler.git_present?
+
+ require "shellwords"
+ URICredentialsFilter.credential_filtered_string("git #{command.shelljoin}", uri)
+ end
+
+ def run_command(*command, dir: nil)
+ command_with_no_credentials = yield(command)
+
+ out, err, status = capture(command, dir)
+
+ raise GitCommandError.new(command_with_no_credentials, dir || SharedHelpers.pwd, err) unless status.success?
+
+ Bundler.ui.warn err unless err.empty?
+
+ out
+ end
+
def capture(cmd, dir, ignore_err: false)
SharedHelpers.with_clean_git_env do
require "open3"
@@ -341,7 +398,7 @@ module Bundler
if Bundler.feature_flag.bundler_3_mode? || supports_minus_c?
["git", "-C", dir.to_s, *cmd]
else
- ["git", *cmd, { :chdir => dir.to_s }]
+ ["git", *cmd, { chdir: dir.to_s }]
end
end
@@ -352,6 +409,11 @@ module Bundler
args += ["--single-branch"]
args.unshift("--no-tags") if supports_cloning_with_no_tags?
+ # If there's a locked revision, no need to clone any specific branch
+ # or tag, since we will end up checking out that locked revision
+ # anyways.
+ return args if @revision
+
args += ["--branch", branch || tag] if branch || tag
args
end
@@ -362,9 +424,9 @@ module Bundler
["--depth", depth.to_s]
end
- def extra_fetch_args
+ def extra_fetch_args(ref)
extra_args = [path.to_s, *depth_args]
- extra_args.push(@commit_ref)
+ extra_args.push(ref)
extra_args
end
@@ -376,6 +438,10 @@ module Bundler
@supports_minus_c ||= Gem::Version.new(version) >= Gem::Version.new("1.8.5")
end
+ def needs_allow_any_sha1_in_want?
+ @needs_allow_any_sha1_in_want ||= Gem::Version.new(version) <= Gem::Version.new("2.13.7")
+ end
+
def supports_fetching_unreachable_refs?
@supports_fetching_unreachable_refs ||= Gem::Version.new(version) >= Gem::Version.new("2.5.0")
end
diff --git a/lib/bundler/source/metadata.rb b/lib/bundler/source/metadata.rb
index 593da6d1a7..4d27761365 100644
--- a/lib/bundler/source/metadata.rb
+++ b/lib/bundler/source/metadata.rb
@@ -5,27 +5,27 @@ module Bundler
class Metadata < Source
def specs
@specs ||= Index.build do |idx|
- idx << Gem::Specification.new("Ruby\0", Gem.ruby_version)
+ idx << Gem::Specification.new("Ruby\0", Bundler::RubyVersion.system.gem_version)
idx << Gem::Specification.new("RubyGems\0", Gem::VERSION) do |s|
s.required_rubygems_version = Gem::Requirement.default
end
- idx << Gem::Specification.new do |s|
- s.name = "bundler"
- s.version = VERSION
- s.license = "MIT"
- s.platform = Gem::Platform::RUBY
- s.authors = ["bundler team"]
- s.bindir = "exe"
- s.homepage = "https://bundler.io"
- s.summary = "The best way to manage your application's dependencies"
- s.executables = %w[bundle]
- # can't point to the actual gemspec or else the require paths will be wrong
- s.loaded_from = __dir__
- end
-
- if local_spec = Bundler.rubygems.find_bundler(VERSION)
+ if local_spec = Gem.loaded_specs["bundler"]
idx << local_spec
+ else
+ idx << Gem::Specification.new do |s|
+ s.name = "bundler"
+ s.version = VERSION
+ s.license = "MIT"
+ s.platform = Gem::Platform::RUBY
+ s.authors = ["bundler team"]
+ s.bindir = "exe"
+ s.homepage = "https://bundler.io"
+ s.summary = "The best way to manage your application's dependencies"
+ s.executables = %w[bundle]
+ # can't point to the actual gemspec or else the require paths will be wrong
+ s.loaded_from = __dir__
+ end
end
idx.each {|s| s.source = self }
diff --git a/lib/bundler/source/path.rb b/lib/bundler/source/path.rb
index bdfcf8274a..978b0b2c9f 100644
--- a/lib/bundler/source/path.rb
+++ b/lib/bundler/source/path.rb
@@ -14,6 +14,7 @@ module Bundler
DEFAULT_GLOB = "{,*,*/*}.gemspec"
def initialize(options)
+ @checksum_store = Checksum::Store.new
@options = options.dup
@glob = options["glob"] || DEFAULT_GLOB
@@ -85,7 +86,7 @@ module Bundler
using_message = "Using #{version_message(spec, options[:previous_spec])} from #{self}"
using_message += " and installing its executables" unless spec.executables.empty?
print_using_message using_message
- generate_bin(spec, :disable_extensions => true)
+ generate_bin(spec, disable_extensions: true)
nil # no post-install message
end
@@ -225,7 +226,7 @@ module Bundler
# Some gem authors put absolute paths in their gemspec
# and we have to save them from themselves
spec.files = spec.files.map do |path|
- next path unless /\A#{Pathname::SEPARATOR_PAT}/.match?(path)
+ next path unless /\A#{Pathname::SEPARATOR_PAT}/o.match?(path)
next if File.directory?(path)
begin
Pathname.new(path).relative_path_from(gem_dir).to_s
@@ -236,10 +237,10 @@ module Bundler
installer = Path::Installer.new(
spec,
- :env_shebang => false,
- :disable_extensions => options[:disable_extensions],
- :build_args => options[:build_args],
- :bundler_extension_cache_path => extension_cache_path(spec)
+ env_shebang: false,
+ disable_extensions: options[:disable_extensions],
+ build_args: options[:build_args],
+ bundler_extension_cache_path: extension_cache_path(spec)
)
installer.post_install
rescue Gem::InvalidSpecificationException => e
diff --git a/lib/bundler/source/rubygems.rb b/lib/bundler/source/rubygems.rb
index c39071705a..04cfc0a850 100644
--- a/lib/bundler/source/rubygems.rb
+++ b/lib/bundler/source/rubygems.rb
@@ -7,25 +7,27 @@ module Bundler
class Rubygems < Source
autoload :Remote, File.expand_path("rubygems/remote", __dir__)
- # Use the API when installing less than X gems
- API_REQUEST_LIMIT = 500
# Ask for X gems per API request
API_REQUEST_SIZE = 50
- attr_reader :remotes, :caches
+ attr_reader :remotes
def initialize(options = {})
@options = options
@remotes = []
@dependency_names = []
@allow_remote = false
- @allow_cached = false
+ @allow_cached = options["allow_cached"] || false
@allow_local = options["allow_local"] || false
- @caches = [cache_path, *Bundler.rubygems.gem_cache]
+ @checksum_store = Checksum::Store.new
Array(options["remotes"]).reverse_each {|r| add_remote(r) }
end
+ def caches
+ @caches ||= [cache_path, *Bundler.rubygems.gem_cache]
+ end
+
def local_only!
@specs = nil
@allow_local = true
@@ -87,6 +89,7 @@ module Bundler
end
def self.from_lock(options)
+ options["remotes"] = Array(options.delete("remote")).reverse
new(options)
end
@@ -122,16 +125,17 @@ module Bundler
end
end
alias_method :name, :identifier
+ alias_method :to_gemfile, :identifier
def specs
@specs ||= begin
# remote_specs usually generates a way larger Index than the other
- # sources, and large_idx.use small_idx is way faster than
- # small_idx.use large_idx.
- idx = @allow_remote ? remote_specs.dup : Index.new
- idx.use(cached_specs, :override_dupes) if @allow_cached || @allow_remote
- idx.use(installed_specs, :override_dupes) if @allow_local
- idx
+ # sources, and large_idx.merge! small_idx is way faster than
+ # small_idx.merge! large_idx.
+ index = @allow_remote ? remote_specs.dup : Index.new
+ index.merge!(cached_specs) if @allow_cached
+ index.merge!(installed_specs) if @allow_local
+ index
end
end
@@ -167,15 +171,14 @@ module Bundler
installer = Bundler::RubyGemsGemInstaller.at(
path,
- :security_policy => Bundler.rubygems.security_policies[Bundler.settings["trust-policy"]],
- :install_dir => install_path.to_s,
- :bin_dir => bin_path.to_s,
- :ignore_dependencies => true,
- :wrappers => true,
- :env_shebang => true,
- :build_args => options[:build_args],
- :bundler_expected_checksum => spec.respond_to?(:checksum) && spec.checksum,
- :bundler_extension_cache_path => extension_cache_path(spec)
+ security_policy: Bundler.rubygems.security_policies[Bundler.settings["trust-policy"]],
+ install_dir: install_path.to_s,
+ bin_dir: bin_path.to_s,
+ ignore_dependencies: true,
+ wrappers: true,
+ env_shebang: true,
+ build_args: options[:build_args],
+ bundler_extension_cache_path: extension_cache_path(spec)
)
if spec.remote
@@ -193,6 +196,8 @@ module Bundler
spec.__swap__(s)
end
+ spec.source.checksum_store.register(spec, installer.gem_checksum)
+
message = "Installing #{version_message(spec, options[:previous_spec])}"
message += " with native extensions" if spec.extensions.any?
Bundler.ui.confirm message
@@ -235,7 +240,7 @@ module Bundler
end
def spec_names
- if @allow_remote && dependency_api_available?
+ if dependency_api_available?
remote_specs.spec_names
else
[]
@@ -243,22 +248,25 @@ module Bundler
end
def unmet_deps
- if @allow_remote && dependency_api_available?
+ if dependency_api_available?
remote_specs.unmet_dependency_names
else
[]
end
end
- def fetchers
- @fetchers ||= remotes.map do |uri|
+ def remote_fetchers
+ @remote_fetchers ||= remotes.to_h do |uri|
remote = Source::Rubygems::Remote.new(uri)
- Bundler::Fetcher.new(remote)
- end
+ [remote, Bundler::Fetcher.new(remote)]
+ end.freeze
+ end
+
+ def fetchers
+ @fetchers ||= remote_fetchers.values.freeze
end
def double_check_for(unmet_dependency_names)
- return unless @allow_remote
return unless dependency_api_available?
unmet_dependency_names = unmet_dependency_names.call
@@ -273,7 +281,9 @@ module Bundler
Bundler.ui.debug "Double checking for #{unmet_dependency_names || "all specs (due to the size of the request)"} in #{self}"
- fetch_names(api_fetchers, unmet_dependency_names, specs, false)
+ fetch_names(api_fetchers, unmet_dependency_names, remote_specs)
+
+ specs.use remote_specs
end
def dependency_names_to_double_check
@@ -326,9 +336,9 @@ module Bundler
def cached_path(spec)
global_cache_path = download_cache_path(spec)
- @caches << global_cache_path if global_cache_path
+ caches << global_cache_path if global_cache_path
- possibilities = @caches.map {|p| package_path(p, spec) }
+ possibilities = caches.map {|p| package_path(p, spec) }
possibilities.find {|p| File.exist?(p) }
end
@@ -337,12 +347,11 @@ module Bundler
end
def normalize_uri(uri)
- uri = uri.to_s
- uri = "#{uri}/" unless %r{/$}.match?(uri)
+ uri = URINormalizer.normalize_suffix(uri.to_s)
require_relative "../vendored_uri"
- uri = Bundler::URI(uri)
+ uri = Gem::URI(uri)
raise ArgumentError, "The source must be an absolute URI. For example:\n" \
- "source 'https://rubygems.org'" if !uri.absolute? || (uri.is_a?(Bundler::URI::HTTP) && uri.host.nil?)
+ "source 'https://rubygems.org'" if !uri.absolute? || (uri.is_a?(Gem::URI::HTTP) && uri.host.nil?)
uri
end
@@ -378,10 +387,9 @@ module Bundler
def cached_specs
@cached_specs ||= begin
- idx = @allow_local ? installed_specs.dup : Index.new
+ idx = Index.new
Dir["#{cache_path}/*.gem"].each do |gemfile|
- next if /^bundler\-[\d\.]+?\.gem/.match?(gemfile)
s ||= Bundler.rubygems.spec_from_gem(gemfile)
s.source = self
idx << s
@@ -392,36 +400,30 @@ module Bundler
end
def api_fetchers
- fetchers.select {|f| f.use_api && f.fetchers.first.api_fetcher? }
+ fetchers.select(&:api_fetcher?)
end
def remote_specs
@remote_specs ||= Index.build do |idx|
index_fetchers = fetchers - api_fetchers
- # gather lists from non-api sites
- fetch_names(index_fetchers, nil, idx, false)
-
- # because ensuring we have all the gems we need involves downloading
- # the gemspecs of those gems, if the non-api sites contain more than
- # about 500 gems, we treat all sites as non-api for speed.
- allow_api = idx.size < API_REQUEST_LIMIT && dependency_names.size < API_REQUEST_LIMIT
- Bundler.ui.debug "Need to query more than #{API_REQUEST_LIMIT} gems." \
- " Downloading full index instead..." unless allow_api
-
- fetch_names(api_fetchers, allow_api && dependency_names, idx, false)
+ if index_fetchers.empty?
+ fetch_names(api_fetchers, dependency_names, idx)
+ else
+ fetch_names(fetchers, nil, idx)
+ end
end
end
- def fetch_names(fetchers, dependency_names, index, override_dupes)
+ def fetch_names(fetchers, dependency_names, index)
fetchers.each do |f|
if dependency_names
Bundler.ui.info "Fetching gem metadata from #{URICredentialsFilter.credential_filtered_uri(f.uri)}", Bundler.ui.debug?
- index.use f.specs_with_retry(dependency_names, self), override_dupes
+ index.use f.specs_with_retry(dependency_names, self)
Bundler.ui.info "" unless Bundler.ui.debug? # new line now that the dots are over
else
Bundler.ui.info "Fetching source index from #{URICredentialsFilter.credential_filtered_uri(f.uri)}"
- index.use f.specs_with_retry(nil, self), override_dupes
+ index.use f.specs_with_retry(nil, self)
end
end
end
@@ -482,7 +484,8 @@ module Bundler
def download_gem(spec, download_cache_path, previous_spec = nil)
uri = spec.remote.uri
Bundler.ui.confirm("Fetching #{version_message(spec, previous_spec)}")
- Bundler.rubygems.download_gem(spec, uri, download_cache_path)
+ gem_remote_fetcher = remote_fetchers.fetch(spec.remote).gem_remote_fetcher
+ Bundler.rubygems.download_gem(spec, uri, download_cache_path, gem_remote_fetcher)
end
# Returns the global cache path of the calling Rubygems::Source object.
diff --git a/lib/bundler/source/rubygems/remote.rb b/lib/bundler/source/rubygems/remote.rb
index 82c850ffbb..9c5c06de24 100644
--- a/lib/bundler/source/rubygems/remote.rb
+++ b/lib/bundler/source/rubygems/remote.rb
@@ -48,7 +48,7 @@ module Bundler
end
uri
- rescue Bundler::URI::InvalidComponentError
+ rescue Gem::URI::InvalidComponentError
error_message = "Please CGI escape your usernames and passwords before " \
"setting them for authentication."
raise HTTPError.new(error_message)
diff --git a/lib/bundler/source_list.rb b/lib/bundler/source_list.rb
index 63798db941..d85e1c1c01 100644
--- a/lib/bundler/source_list.rb
+++ b/lib/bundler/source_list.rb
@@ -9,7 +9,7 @@ module Bundler
:metadata_source
def global_rubygems_source
- @global_rubygems_source ||= rubygems_aggregate_class.new("allow_local" => true)
+ @global_rubygems_source ||= rubygems_aggregate_class.new("allow_local" => true, "allow_cached" => true)
end
def initialize
@@ -101,10 +101,6 @@ module Bundler
source_list_for(source).find {|s| equivalent_source?(source, s) }
end
- def get_with_fallback(source)
- get(source) || default_source
- end
-
def lock_sources
lock_other_sources + lock_rubygems_sources
end
@@ -178,7 +174,7 @@ module Bundler
replacement_source = replacement_sources.find {|s| s == global_rubygems_source }
return global_rubygems_source unless replacement_source
- replacement_source.local!
+ replacement_source.cached!
replacement_source
end
diff --git a/lib/bundler/spec_set.rb b/lib/bundler/spec_set.rb
index 7478bd9ca2..96e1403bf7 100644
--- a/lib/bundler/spec_set.rb
+++ b/lib/bundler/spec_set.rb
@@ -24,6 +24,7 @@ module Bundler
name = dep[0].name
platform = dep[1]
+ incomplete = false
key = [name, platform]
next if handled.key?(key)
@@ -36,31 +37,72 @@ module Bundler
specs_for_dep.first.dependencies.each do |d|
next if d.type == :development
+ incomplete = true if d.name != "bundler" && lookup[d.name].nil?
deps << [d, dep[1]]
end
- elsif check
- @incomplete_specs += lookup[name]
+ else
+ incomplete = true
+ end
+
+ if incomplete && check
+ @incomplete_specs += lookup[name] || [LazySpecification.new(name, nil, nil)]
end
end
- specs
+ specs.uniq
+ end
+
+ def add_extra_platforms!(platforms)
+ return platforms.concat([Gem::Platform::RUBY]).uniq if @specs.empty?
+
+ new_platforms = all_platforms.select do |platform|
+ next if platforms.include?(platform)
+ next unless GemHelpers.generic(platform) == Gem::Platform::RUBY
+
+ complete_platform(platform)
+ end
+ return platforms if new_platforms.empty?
+
+ platforms.concat(new_platforms)
+
+ less_specific_platform = new_platforms.find {|platform| platform != Gem::Platform::RUBY && Bundler.local_platform === platform }
+ platforms.delete(Bundler.local_platform) if less_specific_platform
+
+ platforms
+ end
+
+ def complete_platforms!(platforms)
+ platforms.each do |platform|
+ complete_platform(platform)
+ end
+ end
+
+ def validate_deps(s)
+ s.runtime_dependencies.each do |dep|
+ next if dep.name == "bundler"
+
+ return :missing unless names.include?(dep.name)
+ return :invalid if none? {|spec| dep.matches_spec?(spec) }
+ end
+
+ :valid
end
def [](key)
key = key.name if key.respond_to?(:name)
- lookup[key].reverse
+ lookup[key]&.reverse || []
end
def []=(key, value)
@specs << value
- @lookup = nil
- @sorted = nil
+
+ reset!
end
- def delete(spec)
- @specs.delete(spec)
- @lookup = nil
- @sorted = nil
+ def delete(specs)
+ specs.each {|spec| @specs.delete(spec) }
+
+ reset!
end
def sort!
@@ -94,8 +136,12 @@ module Bundler
end
end
- def incomplete_ruby_specs?(deps)
- self.for(deps, true, [Gem::Platform::RUBY])
+ def incomplete_for_platform?(deps, platform)
+ return false if @specs.empty?
+
+ @incomplete_specs = []
+
+ self.for(deps, true, [platform])
@incomplete_specs.any?
end
@@ -104,16 +150,6 @@ module Bundler
@specs.select {|s| s.is_a?(LazySpecification) }
end
- def merge(set)
- arr = sorted.dup
- set.each do |set_spec|
- full_name = set_spec.full_name
- next if arr.any? {|spec| spec.full_name == full_name }
- arr << set_spec
- end
- SpecSet.new(arr)
- end
-
def -(other)
SpecSet.new(to_a - other.to_a)
end
@@ -124,12 +160,12 @@ module Bundler
def delete_by_name(name)
@specs.reject! {|spec| spec.name == name }
- @lookup = nil
- @sorted = nil
+
+ reset!
end
def what_required(spec)
- unless req = find {|s| s.dependencies.any? {|d| d.type == :runtime && d.name == spec.name } }
+ unless req = find {|s| s.runtime_dependencies.any? {|d| d.name == spec.name } }
return [spec]
end
what_required(req) << spec
@@ -155,8 +191,52 @@ module Bundler
sorted.each(&b)
end
+ def names
+ lookup.keys
+ end
+
private
+ def reset!
+ @sorted = nil
+ @lookup = nil
+ end
+
+ def complete_platform(platform)
+ new_specs = []
+
+ valid_platform = lookup.all? do |_, specs|
+ spec = specs.first
+ matching_specs = spec.source.specs.search([spec.name, spec.version])
+ platform_spec = GemHelpers.select_best_platform_match(matching_specs, platform).find do |s|
+ s.matches_current_metadata? && valid_dependencies?(s)
+ end
+
+ if platform_spec
+ new_specs << LazySpecification.from_spec(platform_spec) unless specs.include?(platform_spec)
+ true
+ else
+ false
+ end
+ end
+
+ if valid_platform && new_specs.any?
+ @specs.concat(new_specs)
+
+ reset!
+ end
+
+ valid_platform
+ end
+
+ def all_platforms
+ @specs.flat_map {|spec| spec.source.specs.search([spec.name, spec.version]).map(&:platform) }.uniq
+ end
+
+ def valid_dependencies?(s)
+ validate_deps(s) == :valid
+ end
+
def sorted
rake = @specs.find {|s| s.name == "rake" }
begin
@@ -175,8 +255,9 @@ module Bundler
def lookup
@lookup ||= begin
- lookup = Hash.new {|h, k| h[k] = [] }
+ lookup = {}
@specs.each do |s|
+ lookup[s.name] ||= []
lookup[s.name] << s
end
lookup
@@ -190,8 +271,13 @@ module Bundler
def specs_for_dependency(dep, platform)
specs_for_name = lookup[dep.name]
- target_platform = dep.force_ruby_platform ? Gem::Platform::RUBY : (platform || Bundler.local_platform)
- matching_specs = GemHelpers.select_best_platform_match(specs_for_name, target_platform)
+ return [] unless specs_for_name
+
+ matching_specs = if dep.force_ruby_platform
+ GemHelpers.force_ruby_platform(specs_for_name)
+ else
+ GemHelpers.select_best_platform_match(specs_for_name, platform || Bundler.local_platform)
+ end
matching_specs.map!(&:materialize_for_installation).compact! if platform.nil?
matching_specs
end
@@ -199,7 +285,11 @@ module Bundler
def tsort_each_child(s)
s.dependencies.sort_by(&:name).each do |d|
next if d.type == :development
- lookup[d.name].each {|s2| yield s2 }
+
+ specs_for_name = lookup[d.name]
+ next unless specs_for_name
+
+ specs_for_name.each {|s2| yield s2 }
end
end
end
diff --git a/lib/bundler/stub_specification.rb b/lib/bundler/stub_specification.rb
index 88a4257fa4..da830cf8d4 100644
--- a/lib/bundler/stub_specification.rb
+++ b/lib/bundler/stub_specification.rb
@@ -9,6 +9,7 @@ module Bundler
spec
end
+ attr_reader :checksum
attr_accessor :stub, :ignored
def source=(source)
@@ -16,7 +17,8 @@ module Bundler
# Stub has no concept of source, which means that extension_dir may be wrong
# This is the case for git-based gems. So, instead manually assign the extension dir
return unless source.respond_to?(:extension_dir_name)
- path = File.join(stub.extensions_dir, source.extension_dir_name)
+ unique_extension_dir = [source.extension_dir_name, File.basename(full_gem_path)].uniq.join("-")
+ path = File.join(stub.extensions_dir, unique_extension_dir)
stub.extension_dir = File.expand_path(path)
end
@@ -56,7 +58,7 @@ module Bundler
end
def gem_build_complete_path
- File.join(extension_dir, "gem.build_complete")
+ stub.gem_build_complete_path
end
def default_gem?
@@ -108,6 +110,7 @@ module Bundler
end
rs.source = source
+ rs.base_dir = stub.base_dir
rs
end
diff --git a/lib/bundler/templates/Executable.bundler b/lib/bundler/templates/Executable.bundler
index 6dab1688f7..caa2021701 100644
--- a/lib/bundler/templates/Executable.bundler
+++ b/lib/bundler/templates/Executable.bundler
@@ -27,7 +27,7 @@ m = Module.new do
bundler_version = nil
update_index = nil
ARGV.each_with_index do |a, i|
- if update_index && update_index.succ == i && a =~ Gem::Version::ANCHORED_VERSION_PATTERN
+ if update_index && update_index.succ == i && a.match?(Gem::Version::ANCHORED_VERSION_PATTERN)
bundler_version = a
end
next unless a =~ /\A--bundler(?:[= ](#{Gem::Version::VERSION_PATTERN}))?\z/
@@ -47,7 +47,7 @@ m = Module.new do
def lockfile
lockfile =
case File.basename(gemfile)
- when "gems.rb" then gemfile.sub(/\.rb$/, gemfile)
+ when "gems.rb" then gemfile.sub(/\.rb$/, ".locked")
else "#{gemfile}.lock"
end
File.expand_path(lockfile)
diff --git a/lib/bundler/templates/gems.rb b/lib/bundler/templates/gems.rb
deleted file mode 100644
index d2403f18b2..0000000000
--- a/lib/bundler/templates/gems.rb
+++ /dev/null
@@ -1,5 +0,0 @@
-# frozen_string_literal: true
-
-source "https://rubygems.org"
-
-# gem "rails"
diff --git a/lib/bundler/templates/newgem/Gemfile.tt b/lib/bundler/templates/newgem/Gemfile.tt
index 41c95677a3..a0d2ac2826 100644
--- a/lib/bundler/templates/newgem/Gemfile.tt
+++ b/lib/bundler/templates/newgem/Gemfile.tt
@@ -10,7 +10,7 @@ gem "rake", "~> 13.0"
gem "rake-compiler"
<%- if config[:ext] == 'rust' -%>
-gem "rb_sys"
+gem "rb_sys", "~> 0.9.63"
<%- end -%>
<%- end -%>
<%- if config[:test] -%>
diff --git a/lib/bundler/templates/newgem/README.md.tt b/lib/bundler/templates/newgem/README.md.tt
index 20eaac8a62..5bf36378e8 100644
--- a/lib/bundler/templates/newgem/README.md.tt
+++ b/lib/bundler/templates/newgem/README.md.tt
@@ -6,15 +6,15 @@ Welcome to your new gem! In this directory, you'll find the files you need to be
## Installation
-TODO: Replace `UPDATE_WITH_YOUR_GEM_NAME_PRIOR_TO_RELEASE_TO_RUBYGEMS_ORG` with your gem name right after releasing it to RubyGems.org. Please do not do it earlier due to security reasons. Alternatively, replace this section with instructions to install your gem from git if you don't plan to release to RubyGems.org.
+TODO: Replace `UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG` with your gem name right after releasing it to RubyGems.org. Please do not do it earlier due to security reasons. Alternatively, replace this section with instructions to install your gem from git if you don't plan to release to RubyGems.org.
Install the gem and add to the application's Gemfile by executing:
- $ bundle add UPDATE_WITH_YOUR_GEM_NAME_PRIOR_TO_RELEASE_TO_RUBYGEMS_ORG
+ $ bundle add UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG
If bundler is not being used to manage dependencies, install the gem by executing:
- $ gem install UPDATE_WITH_YOUR_GEM_NAME_PRIOR_TO_RELEASE_TO_RUBYGEMS_ORG
+ $ gem install UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG
## Usage
diff --git a/lib/bundler/templates/newgem/Rakefile.tt b/lib/bundler/templates/newgem/Rakefile.tt
index ac14545126..172183d4b4 100644
--- a/lib/bundler/templates/newgem/Rakefile.tt
+++ b/lib/bundler/templates/newgem/Rakefile.tt
@@ -4,13 +4,9 @@ require "bundler/gem_tasks"
<% default_task_names = [config[:test_task]].compact -%>
<% case config[:test] -%>
<% when "minitest" -%>
-require "rake/testtask"
+require "minitest/test_task"
-Rake::TestTask.new(:test) do |t|
- t.libs << "test"
- t.libs << "lib"
- t.test_files = FileList["test/**/test_*.rb"]
-end
+Minitest::TestTask.create
<% when "test-unit" -%>
require "rake/testtask"
@@ -41,13 +37,27 @@ require "standard/rake"
<% if config[:ext] -%>
<% default_task_names.unshift(:compile) -%>
<% default_task_names.unshift(:clobber) unless config[:ext] == 'rust' -%>
+<% if config[:ext] == 'rust' -%>
+require "rb_sys/extensiontask"
+
+task build: :compile
+
+GEMSPEC = Gem::Specification.load("<%= config[:underscored_name] %>.gemspec")
+
+RbSys::ExtensionTask.new(<%= config[:name].inspect %>, GEMSPEC) do |ext|
+ ext.lib_dir = "lib/<%= config[:namespaced_path] %>"
+end
+<% else -%>
require "rake/extensiontask"
task build: :compile
-Rake::ExtensionTask.new("<%= config[:underscored_name] %>") do |ext|
+GEMSPEC = Gem::Specification.load("<%= config[:underscored_name] %>.gemspec")
+
+Rake::ExtensionTask.new("<%= config[:underscored_name] %>", GEMSPEC) do |ext|
ext.lib_dir = "lib/<%= config[:namespaced_path] %>"
end
+<% end -%>
<% end -%>
<% if default_task_names.size == 1 -%>
diff --git a/lib/bundler/templates/newgem/bin/console.tt b/lib/bundler/templates/newgem/bin/console.tt
index 08dfaaef69..c91ee65f93 100644
--- a/lib/bundler/templates/newgem/bin/console.tt
+++ b/lib/bundler/templates/newgem/bin/console.tt
@@ -7,9 +7,5 @@ require "<%= config[:namespaced_path] %>"
# You can add fixtures and/or initialization code here to make experimenting
# with your gem easier. You can also use a different console, if you like.
-# (If you use this, don't forget to add pry to your Gemfile!)
-# require "pry"
-# Pry.start
-
require "irb"
IRB.start(__FILE__)
diff --git a/lib/bundler/templates/newgem/ext/newgem/Cargo.toml.tt b/lib/bundler/templates/newgem/ext/newgem/Cargo.toml.tt
index 4b6e9587f7..0ebce0e4a0 100644
--- a/lib/bundler/templates/newgem/ext/newgem/Cargo.toml.tt
+++ b/lib/bundler/templates/newgem/ext/newgem/Cargo.toml.tt
@@ -12,4 +12,4 @@ publish = false
crate-type = ["cdylib"]
[dependencies]
-magnus = { version = "0.4" }
+magnus = { version = "0.6.2" }
diff --git a/lib/bundler/templates/newgem/ext/newgem/extconf-c.rb.tt b/lib/bundler/templates/newgem/ext/newgem/extconf-c.rb.tt
index e918063ddf..0a0c5a3d09 100644
--- a/lib/bundler/templates/newgem/ext/newgem/extconf-c.rb.tt
+++ b/lib/bundler/templates/newgem/ext/newgem/extconf-c.rb.tt
@@ -2,4 +2,9 @@
require "mkmf"
+# Makes all symbols private by default to avoid unintended conflict
+# with other gems. To explicitly export symbols you can use RUBY_FUNC_EXPORTED
+# selectively, or entirely remove this flag.
+append_cflags("-fvisibility=hidden")
+
create_makefile(<%= config[:makefile_path].inspect %>)
diff --git a/lib/bundler/templates/newgem/ext/newgem/newgem.c.tt b/lib/bundler/templates/newgem/ext/newgem/newgem.c.tt
index 8177c4d202..bcd5148569 100644
--- a/lib/bundler/templates/newgem/ext/newgem/newgem.c.tt
+++ b/lib/bundler/templates/newgem/ext/newgem/newgem.c.tt
@@ -2,7 +2,7 @@
VALUE rb_m<%= config[:constant_array].join %>;
-void
+RUBY_FUNC_EXPORTED void
Init_<%= config[:underscored_name] %>(void)
{
rb_m<%= config[:constant_array].join %> = rb_define_module(<%= config[:constant_name].inspect %>);
diff --git a/lib/bundler/templates/newgem/ext/newgem/src/lib.rs.tt b/lib/bundler/templates/newgem/ext/newgem/src/lib.rs.tt
index b311283997..ba234529a3 100644
--- a/lib/bundler/templates/newgem/ext/newgem/src/lib.rs.tt
+++ b/lib/bundler/templates/newgem/ext/newgem/src/lib.rs.tt
@@ -1,12 +1,12 @@
-use magnus::{define_module, function, prelude::*, Error};
+use magnus::{function, prelude::*, Error, Ruby};
fn hello(subject: String) -> String {
- format!("Hello from Rust, {}!", subject)
+ format!("Hello from Rust, {subject}!")
}
#[magnus::init]
-fn init() -> Result<(), Error> {
- let module = <%= config[:constant_array].map {|c| "define_module(#{c.dump})?"}.join(".") %>;
+fn init(ruby: &Ruby) -> Result<(), Error> {
+ let module = ruby.<%= config[:constant_array].map {|c| "define_module(#{c.dump})?"}.join(".") %>;
module.define_singleton_method("hello", function!(hello, 1))?;
Ok(())
}
diff --git a/lib/bundler/templates/newgem/github/workflows/main.yml.tt b/lib/bundler/templates/newgem/github/workflows/main.yml.tt
index d4021980b4..32b39558d8 100644
--- a/lib/bundler/templates/newgem/github/workflows/main.yml.tt
+++ b/lib/bundler/templates/newgem/github/workflows/main.yml.tt
@@ -17,10 +17,10 @@ jobs:
- '<%= RUBY_VERSION %>'
steps:
- - uses: actions/checkout@v3
+ - uses: actions/checkout@v4
<%- if config[:ext] == 'rust' -%>
- name: Set up Ruby & Rust
- uses: oxidize-rb/actions/setup-ruby-and-rust@main
+ uses: oxidize-rb/actions/setup-ruby-and-rust@v1
with:
ruby-version: ${{ matrix.ruby }}
bundler-cache: true
diff --git a/lib/bundler/templates/newgem/newgem.gemspec.tt b/lib/bundler/templates/newgem/newgem.gemspec.tt
index e35a121245..6e88f4dab1 100644
--- a/lib/bundler/templates/newgem/newgem.gemspec.tt
+++ b/lib/bundler/templates/newgem/newgem.gemspec.tt
@@ -27,9 +27,11 @@ Gem::Specification.new do |spec|
# Specify which files should be added to the gem when it is released.
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
- spec.files = Dir.chdir(__dir__) do
- `git ls-files -z`.split("\x0").reject do |f|
- (f == __FILE__) || f.match(%r{\A(?:(?:bin|test|spec|features)/|\.(?:git|circleci)|appveyor)})
+ gemspec = File.basename(__FILE__)
+ spec.files = IO.popen(%w[git ls-files -z], chdir: __dir__, err: IO::NULL) do |ls|
+ ls.readlines("\x0", chomp: true).reject do |f|
+ (f == gemspec) ||
+ f.start_with?(*%w[bin/ test/ spec/ features/ .git <%= config[:ci_config_path] %>appveyor Gemfile])
end
end
spec.bindir = "exe"
diff --git a/lib/bundler/templates/newgem/rubocop.yml.tt b/lib/bundler/templates/newgem/rubocop.yml.tt
index 9ecec78807..3d1c4ee7b2 100644
--- a/lib/bundler/templates/newgem/rubocop.yml.tt
+++ b/lib/bundler/templates/newgem/rubocop.yml.tt
@@ -2,12 +2,7 @@ AllCops:
TargetRubyVersion: <%= ::Gem::Version.new(config[:required_ruby_version]).segments[0..1].join(".") %>
Style/StringLiterals:
- Enabled: true
EnforcedStyle: double_quotes
Style/StringLiteralsInInterpolation:
- Enabled: true
EnforcedStyle: double_quotes
-
-Layout/LineLength:
- Max: 120
diff --git a/lib/bundler/templates/newgem/standard.yml.tt b/lib/bundler/templates/newgem/standard.yml.tt
index 934b0b2c37..a0696cd2e9 100644
--- a/lib/bundler/templates/newgem/standard.yml.tt
+++ b/lib/bundler/templates/newgem/standard.yml.tt
@@ -1,3 +1,3 @@
# For available configuration options, see:
-# https://github.com/testdouble/standard
+# https://github.com/standardrb/standard
ruby_version: <%= ::Gem::Version.new(config[:required_ruby_version]).segments[0..1].join(".") %>
diff --git a/lib/bundler/ui/shell.rb b/lib/bundler/ui/shell.rb
index 4139585c47..4555612dbb 100644
--- a/lib/bundler/ui/shell.rb
+++ b/lib/bundler/ui/shell.rb
@@ -130,7 +130,7 @@ module Bundler
def tell_err(message, color = nil, newline = nil)
return if @shell.send(:stderr).closed?
- newline ||= message.to_s !~ /( |\t)\Z/
+ newline ||= !message.to_s.match?(/( |\t)\Z/)
message = word_wrap(message) if newline.is_a?(Hash) && newline[:wrap]
color = nil if color && !$stderr.tty?
@@ -147,7 +147,7 @@ module Bundler
spaces ? text.gsub(/#{spaces}/, "") : text
end
- def word_wrap(text, line_width = @shell.terminal_width)
+ def word_wrap(text, line_width = Thor::Terminal.terminal_width)
strip_leading_spaces(text).split("\n").collect do |line|
line.length > line_width ? line.gsub(/(.{1,#{line_width}})(\s+|$)/, "\\1\n").strip : line
end * "\n"
diff --git a/lib/bundler/uri_credentials_filter.rb b/lib/bundler/uri_credentials_filter.rb
index ccfaf0bc5d..a83f5304e2 100644
--- a/lib/bundler/uri_credentials_filter.rb
+++ b/lib/bundler/uri_credentials_filter.rb
@@ -11,7 +11,7 @@ module Bundler
return uri if File.exist?(uri)
require_relative "vendored_uri"
- uri = Bundler::URI(uri)
+ uri = Gem::URI(uri)
end
if uri.userinfo
@@ -25,7 +25,7 @@ module Bundler
end
return uri.to_s if uri_to_anonymize.is_a?(String)
uri
- rescue Bundler::URI::InvalidURIError # uri is not canonical uri scheme
+ rescue Gem::URI::InvalidURIError # uri is not canonical uri scheme
uri
end
diff --git a/lib/bundler/uri_normalizer.rb b/lib/bundler/uri_normalizer.rb
new file mode 100644
index 0000000000..ad08593256
--- /dev/null
+++ b/lib/bundler/uri_normalizer.rb
@@ -0,0 +1,23 @@
+# frozen_string_literal: true
+
+module Bundler
+ module URINormalizer
+ module_function
+
+ # Normalizes uri to a consistent version, either with or without trailing
+ # slash.
+ #
+ # TODO: Currently gem sources are locked with a trailing slash, while git
+ # sources are locked without a trailing slash. This should be normalized but
+ # the inconsistency is there for now to avoid changing all lockfiles
+ # including GIT sources. We could normalize this on the next major.
+ #
+ def normalize_suffix(uri, trailing_slash: true)
+ if trailing_slash
+ uri.end_with?("/") ? uri : "#{uri}/"
+ else
+ uri.end_with?("/") ? uri.delete_suffix("/") : uri
+ end
+ end
+ end
+end
diff --git a/lib/rubygems/optparse/.document b/lib/bundler/vendor/connection_pool/.document
index 0c43bbd6b3..0c43bbd6b3 100644
--- a/lib/rubygems/optparse/.document
+++ b/lib/bundler/vendor/connection_pool/.document
diff --git a/lib/bundler/vendor/connection_pool/lib/connection_pool.rb b/lib/bundler/vendor/connection_pool/lib/connection_pool.rb
index 455319efe3..317088a866 100644
--- a/lib/bundler/vendor/connection_pool/lib/connection_pool.rb
+++ b/lib/bundler/vendor/connection_pool/lib/connection_pool.rb
@@ -1,4 +1,4 @@
-require "timeout"
+require_relative "../../../vendored_timeout"
require_relative "connection_pool/version"
class Bundler::ConnectionPool
@@ -6,7 +6,7 @@ class Bundler::ConnectionPool
class PoolShuttingDownError < ::Bundler::ConnectionPool::Error; end
- class TimeoutError < ::Timeout::Error; end
+ class TimeoutError < ::Gem::Timeout::Error; end
end
# Generic connection pool class for sharing a limited number of objects or network connections
@@ -36,14 +36,57 @@ end
# Accepts the following options:
# - :size - number of connections to pool, defaults to 5
# - :timeout - amount of time to wait for a connection if none currently available, defaults to 5 seconds
+# - :auto_reload_after_fork - automatically drop all connections after fork, defaults to true
#
class Bundler::ConnectionPool
- DEFAULTS = {size: 5, timeout: 5}
+ DEFAULTS = {size: 5, timeout: 5, auto_reload_after_fork: true}
def self.wrap(options, &block)
Wrapper.new(options, &block)
end
+ if Process.respond_to?(:fork)
+ INSTANCES = ObjectSpace::WeakMap.new
+ private_constant :INSTANCES
+
+ def self.after_fork
+ INSTANCES.values.each do |pool|
+ next unless pool.auto_reload_after_fork
+
+ # We're on after fork, so we know all other threads are dead.
+ # All we need to do is to ensure the main thread doesn't have a
+ # checked out connection
+ pool.checkin(force: true)
+ pool.reload do |connection|
+ # Unfortunately we don't know what method to call to close the connection,
+ # so we try the most common one.
+ connection.close if connection.respond_to?(:close)
+ end
+ end
+ nil
+ end
+
+ if ::Process.respond_to?(:_fork) # MRI 3.1+
+ module ForkTracker
+ def _fork
+ pid = super
+ if pid == 0
+ Bundler::ConnectionPool.after_fork
+ end
+ pid
+ end
+ end
+ Process.singleton_class.prepend(ForkTracker)
+ end
+ else
+ INSTANCES = nil
+ private_constant :INSTANCES
+
+ def self.after_fork
+ # noop
+ end
+ end
+
def initialize(options = {}, &block)
raise ArgumentError, "Connection pool requires a block" unless block
@@ -51,10 +94,12 @@ class Bundler::ConnectionPool
@size = Integer(options.fetch(:size))
@timeout = options.fetch(:timeout)
+ @auto_reload_after_fork = options.fetch(:auto_reload_after_fork)
@available = TimedStack.new(@size, &block)
@key = :"pool-#{@available.object_id}"
@key_count = :"pool-#{@available.object_id}-count"
+ INSTANCES[self] = self if INSTANCES
end
def with(options = {})
@@ -81,16 +126,16 @@ class Bundler::ConnectionPool
end
end
- def checkin
+ def checkin(force: false)
if ::Thread.current[@key]
- if ::Thread.current[@key_count] == 1
+ if ::Thread.current[@key_count] == 1 || force
@available.push(::Thread.current[@key])
::Thread.current[@key] = nil
::Thread.current[@key_count] = nil
else
::Thread.current[@key_count] -= 1
end
- else
+ elsif !force
raise Bundler::ConnectionPool::Error, "no connections are checked out"
end
@@ -117,6 +162,8 @@ class Bundler::ConnectionPool
# Size of this connection pool
attr_reader :size
+ # Automatically drop all connections after fork
+ attr_reader :auto_reload_after_fork
# Number of pool entries available for checkout at this instant.
def available
diff --git a/lib/bundler/vendor/connection_pool/lib/connection_pool/version.rb b/lib/bundler/vendor/connection_pool/lib/connection_pool/version.rb
index 56ebf69902..384d6fc977 100644
--- a/lib/bundler/vendor/connection_pool/lib/connection_pool/version.rb
+++ b/lib/bundler/vendor/connection_pool/lib/connection_pool/version.rb
@@ -1,3 +1,3 @@
class Bundler::ConnectionPool
- VERSION = "2.3.0"
+ VERSION = "2.4.1"
end
diff --git a/lib/rubygems/tsort/.document b/lib/bundler/vendor/fileutils/.document
index 0c43bbd6b3..0c43bbd6b3 100644
--- a/lib/rubygems/tsort/.document
+++ b/lib/bundler/vendor/fileutils/.document
diff --git a/lib/bundler/vendor/fileutils/lib/fileutils.rb b/lib/bundler/vendor/fileutils/lib/fileutils.rb
index 04ac537a28..6db19caf6f 100644
--- a/lib/bundler/vendor/fileutils/lib/fileutils.rb
+++ b/lib/bundler/vendor/fileutils/lib/fileutils.rb
@@ -3,7 +3,7 @@
begin
require 'rbconfig'
rescue LoadError
- # for make mjit-headers
+ # for make rjit-headers
end
# Namespace for file utility methods for copying, moving, removing, etc.
@@ -180,7 +180,7 @@ end
# - {CVE-2004-0452}[https://cve.mitre.org/cgi-bin/cvename.cgi?name=CAN-2004-0452].
#
module Bundler::FileUtils
- VERSION = "1.7.0"
+ VERSION = "1.7.2"
def self.private_module_function(name) #:nodoc:
module_function name
@@ -192,8 +192,6 @@ module Bundler::FileUtils
#
# Bundler::FileUtils.pwd # => "/rdoc/fileutils"
#
- # Bundler::FileUtils.getwd is an alias for Bundler::FileUtils.pwd.
- #
# Related: Bundler::FileUtils.cd.
#
def pwd
@@ -235,8 +233,6 @@ module Bundler::FileUtils
# cd ..
# cd fileutils
#
- # Bundler::FileUtils.chdir is an alias for Bundler::FileUtils.cd.
- #
# Related: Bundler::FileUtils.pwd.
#
def cd(dir, verbose: nil, &block) # :yield: dir
@@ -515,8 +511,6 @@ module Bundler::FileUtils
# Raises an exception if +dest+ is the path to an existing file
# and keyword argument +force+ is not +true+.
#
- # Bundler::FileUtils#link is an alias for Bundler::FileUtils#ln.
- #
# Related: Bundler::FileUtils.link_entry (has different options).
#
def ln(src, dest, force: nil, noop: nil, verbose: nil)
@@ -707,8 +701,6 @@ module Bundler::FileUtils
# ln -sf src2.txt dest2.txt
# ln -s srcdir3/src0.txt srcdir3/src1.txt destdir3
#
- # Bundler::FileUtils.symlink is an alias for Bundler::FileUtils.ln_s.
- #
# Related: Bundler::FileUtils.ln_sf.
#
def ln_s(src, dest, force: nil, relative: false, target_directory: true, noop: nil, verbose: nil)
@@ -876,8 +868,6 @@ module Bundler::FileUtils
#
# Raises an exception if +src+ is a directory.
#
- # Bundler::FileUtils.copy is an alias for Bundler::FileUtils.cp.
- #
# Related: {methods for copying}[rdoc-ref:FileUtils@Copying].
#
def cp(src, dest, preserve: nil, noop: nil, verbose: nil)
@@ -1164,8 +1154,6 @@ module Bundler::FileUtils
# mv src0 dest0
# mv src1.txt src1 dest1
#
- # Bundler::FileUtils.move is an alias for Bundler::FileUtils.mv.
- #
def mv(src, dest, force: nil, noop: nil, verbose: nil, secure: nil)
fu_output_message "mv#{force ? ' -f' : ''} #{[src,dest].flatten.join ' '}" if verbose
return if noop
@@ -1223,8 +1211,6 @@ module Bundler::FileUtils
#
# rm src0.dat src0.txt
#
- # Bundler::FileUtils.remove is an alias for Bundler::FileUtils.rm.
- #
# Related: {methods for deleting}[rdoc-ref:FileUtils@Deleting].
#
def rm(list, force: nil, noop: nil, verbose: nil)
@@ -1250,8 +1236,6 @@ module Bundler::FileUtils
#
# See Bundler::FileUtils.rm for keyword arguments.
#
- # Bundler::FileUtils.safe_unlink is an alias for Bundler::FileUtils.rm_f.
- #
# Related: {methods for deleting}[rdoc-ref:FileUtils@Deleting].
#
def rm_f(list, noop: nil, verbose: nil)
@@ -1339,8 +1323,6 @@ module Bundler::FileUtils
#
# See Bundler::FileUtils.rm_r for keyword arguments.
#
- # Bundler::FileUtils.rmtree is an alias for Bundler::FileUtils.rm_rf.
- #
# Related: {methods for deleting}[rdoc-ref:FileUtils@Deleting].
#
def rm_rf(list, noop: nil, verbose: nil, secure: nil)
@@ -1642,7 +1624,13 @@ module Bundler::FileUtils
st = File.stat(s)
unless File.exist?(d) and compare_file(s, d)
remove_file d, true
- copy_file s, d
+ if d.end_with?('/')
+ mkdir_p d
+ copy_file s, d + File.basename(s)
+ else
+ mkdir_p File.expand_path('..', d)
+ copy_file s, d
+ end
File.utime st.atime, st.mtime, d if preserve
File.chmod fu_mode(mode, st), d if mode
File.chown uid, gid, d if uid or gid
diff --git a/lib/bundler/vendor/net-http-persistent/.document b/lib/bundler/vendor/net-http-persistent/.document
new file mode 100644
index 0000000000..0c43bbd6b3
--- /dev/null
+++ b/lib/bundler/vendor/net-http-persistent/.document
@@ -0,0 +1 @@
+# Vendored files do not need to be documented
diff --git a/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent.rb b/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent.rb
index a4e1c5a750..c15b346330 100644
--- a/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent.rb
+++ b/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent.rb
@@ -1,14 +1,14 @@
-require 'net/http'
-require_relative '../../../../uri/lib/uri'
+require_relative '../../../../../vendored_net_http'
+require_relative '../../../../../vendored_uri'
require 'cgi' # for escaping
require_relative '../../../../connection_pool/lib/connection_pool'
autoload :OpenSSL, 'openssl'
##
-# Persistent connections for Net::HTTP
+# Persistent connections for Gem::Net::HTTP
#
-# Bundler::Persistent::Net::HTTP::Persistent maintains persistent connections across all the
+# Gem::Net::HTTP::Persistent maintains persistent connections across all the
# servers you wish to talk to. For each host:port you communicate with a
# single persistent connection is created.
#
@@ -22,34 +22,34 @@ autoload :OpenSSL, 'openssl'
#
# require 'bundler/vendor/net-http-persistent/lib/net/http/persistent'
#
-# uri = Bundler::URI 'http://example.com/awesome/web/service'
+# uri = Gem::URI 'http://example.com/awesome/web/service'
#
-# http = Bundler::Persistent::Net::HTTP::Persistent.new
+# http = Gem::Net::HTTP::Persistent.new
#
# # perform a GET
# response = http.request uri
#
# # or
#
-# get = Net::HTTP::Get.new uri.request_uri
+# get = Gem::Net::HTTP::Get.new uri.request_uri
# response = http.request get
#
# # create a POST
# post_uri = uri + 'create'
-# post = Net::HTTP::Post.new post_uri.path
+# post = Gem::Net::HTTP::Post.new post_uri.path
# post.set_form_data 'some' => 'cool data'
#
-# # perform the POST, the Bundler::URI is always required
+# # perform the POST, the Gem::URI is always required
# response http.request post_uri, post
#
# Note that for GET, HEAD and other requests that do not have a body you want
-# to use Bundler::URI#request_uri not Bundler::URI#path. The request_uri contains the query
+# to use Gem::URI#request_uri not Gem::URI#path. The request_uri contains the query
# params which are sent in the body for other requests.
#
# == TLS/SSL
#
# TLS connections are automatically created depending upon the scheme of the
-# Bundler::URI. TLS connections are automatically verified against the default
+# Gem::URI. TLS connections are automatically verified against the default
# certificate store for your computer. You can override this by changing
# verify_mode or by specifying an alternate cert_store.
#
@@ -72,7 +72,7 @@ autoload :OpenSSL, 'openssl'
# == Proxies
#
# A proxy can be set through #proxy= or at initialization time by providing a
-# second argument to ::new. The proxy may be the Bundler::URI of the proxy server or
+# second argument to ::new. The proxy may be the Gem::URI of the proxy server or
# <code>:ENV</code> which will consult environment variables.
#
# See #proxy= and #proxy_from_env for details.
@@ -92,7 +92,7 @@ autoload :OpenSSL, 'openssl'
#
# === Segregation
#
-# Each Bundler::Persistent::Net::HTTP::Persistent instance has its own pool of connections. There
+# Each Gem::Net::HTTP::Persistent instance has its own pool of connections. There
# is no sharing with other instances (as was true in earlier versions).
#
# === Idle Timeout
@@ -131,7 +131,7 @@ autoload :OpenSSL, 'openssl'
#
# === Connection Termination
#
-# If you are done using the Bundler::Persistent::Net::HTTP::Persistent instance you may shut down
+# If you are done using the Gem::Net::HTTP::Persistent instance you may shut down
# all the connections in the current thread with #shutdown. This is not
# recommended for normal use, it should only be used when it will be several
# minutes before you make another HTTP request.
@@ -141,7 +141,7 @@ autoload :OpenSSL, 'openssl'
# Ruby will automatically garbage collect and shutdown your HTTP connections
# when the thread terminates.
-class Bundler::Persistent::Net::HTTP::Persistent
+class Gem::Net::HTTP::Persistent
##
# The beginning of Time
@@ -172,12 +172,12 @@ class Bundler::Persistent::Net::HTTP::Persistent
end
##
- # The version of Bundler::Persistent::Net::HTTP::Persistent you are using
+ # The version of Gem::Net::HTTP::Persistent you are using
- VERSION = '4.0.1'
+ VERSION = '4.0.2'
##
- # Error class for errors raised by Bundler::Persistent::Net::HTTP::Persistent. Various
+ # Error class for errors raised by Gem::Net::HTTP::Persistent. Various
# SystemCallErrors are re-raised with a human-readable message under this
# class.
@@ -197,10 +197,10 @@ class Bundler::Persistent::Net::HTTP::Persistent
# NOTE: This may not work on ruby > 1.9.
def self.detect_idle_timeout uri, max = 10
- uri = Bundler::URI uri unless Bundler::URI::Generic === uri
+ uri = Gem::URI uri unless Gem::URI::Generic === uri
uri += '/'
- req = Net::HTTP::Head.new uri.request_uri
+ req = Gem::Net::HTTP::Head.new uri.request_uri
http = new 'net-http-persistent detect_idle_timeout'
@@ -214,7 +214,7 @@ class Bundler::Persistent::Net::HTTP::Persistent
$stderr.puts "HEAD #{uri} => #{response.code}" if $DEBUG
- unless Net::HTTPOK === response then
+ unless Gem::Net::HTTPOK === response then
raise Error, "bad response code #{response.code} detecting idle timeout"
end
@@ -238,7 +238,7 @@ class Bundler::Persistent::Net::HTTP::Persistent
attr_reader :certificate
##
- # For Net::HTTP parity
+ # For Gem::Net::HTTP parity
alias cert certificate
@@ -266,7 +266,7 @@ class Bundler::Persistent::Net::HTTP::Persistent
attr_reader :ciphers
##
- # Sends debug_output to this IO via Net::HTTP#set_debug_output.
+ # Sends debug_output to this IO via Gem::Net::HTTP#set_debug_output.
#
# Never use this method in production code, it causes a serious security
# hole.
@@ -279,7 +279,7 @@ class Bundler::Persistent::Net::HTTP::Persistent
attr_reader :generation # :nodoc:
##
- # Headers that are added to every request using Net::HTTP#add_field
+ # Headers that are added to every request using Gem::Net::HTTP#add_field
attr_reader :headers
@@ -304,7 +304,7 @@ class Bundler::Persistent::Net::HTTP::Persistent
##
# Number of retries to perform if a request fails.
#
- # See also #max_retries=, Net::HTTP#max_retries=.
+ # See also #max_retries=, Gem::Net::HTTP#max_retries=.
attr_reader :max_retries
@@ -325,12 +325,12 @@ class Bundler::Persistent::Net::HTTP::Persistent
attr_reader :name
##
- # Seconds to wait until a connection is opened. See Net::HTTP#open_timeout
+ # Seconds to wait until a connection is opened. See Gem::Net::HTTP#open_timeout
attr_accessor :open_timeout
##
- # Headers that are added to every request using Net::HTTP#[]=
+ # Headers that are added to every request using Gem::Net::HTTP#[]=
attr_reader :override_headers
@@ -340,7 +340,7 @@ class Bundler::Persistent::Net::HTTP::Persistent
attr_reader :private_key
##
- # For Net::HTTP parity
+ # For Gem::Net::HTTP parity
alias key private_key
@@ -360,12 +360,12 @@ class Bundler::Persistent::Net::HTTP::Persistent
attr_reader :pool # :nodoc:
##
- # Seconds to wait until reading one block. See Net::HTTP#read_timeout
+ # Seconds to wait until reading one block. See Gem::Net::HTTP#read_timeout
attr_accessor :read_timeout
##
- # Seconds to wait until writing one block. See Net::HTTP#write_timeout
+ # Seconds to wait until writing one block. See Gem::Net::HTTP#write_timeout
attr_accessor :write_timeout
@@ -450,18 +450,18 @@ class Bundler::Persistent::Net::HTTP::Persistent
attr_reader :verify_mode
##
- # Creates a new Bundler::Persistent::Net::HTTP::Persistent.
+ # Creates a new Gem::Net::HTTP::Persistent.
#
# Set a +name+ for fun. Your library name should be good enough, but this
# otherwise has no purpose.
#
- # +proxy+ may be set to a Bundler::URI::HTTP or :ENV to pick up proxy options from
+ # +proxy+ may be set to a Gem::URI::HTTP or :ENV to pick up proxy options from
# the environment. See proxy_from_env for details.
#
- # In order to use a Bundler::URI for the proxy you may need to do some extra work
- # beyond Bundler::URI parsing if the proxy requires a password:
+ # In order to use a Gem::URI for the proxy you may need to do some extra work
+ # beyond Gem::URI parsing if the proxy requires a password:
#
- # proxy = Bundler::URI 'http://proxy.example'
+ # proxy = Gem::URI 'http://proxy.example'
# proxy.user = 'AzureDiamond'
# proxy.password = 'hunter2'
#
@@ -492,8 +492,8 @@ class Bundler::Persistent::Net::HTTP::Persistent
@socket_options << [Socket::IPPROTO_TCP, Socket::TCP_NODELAY, 1] if
Socket.const_defined? :TCP_NODELAY
- @pool = Bundler::Persistent::Net::HTTP::Persistent::Pool.new size: pool_size do |http_args|
- Bundler::Persistent::Net::HTTP::Persistent::Connection.new Net::HTTP, http_args, @ssl_generation
+ @pool = Gem::Net::HTTP::Persistent::Pool.new size: pool_size do |http_args|
+ Gem::Net::HTTP::Persistent::Connection.new Gem::Net::HTTP, http_args, @ssl_generation
end
@certificate = nil
@@ -510,7 +510,7 @@ class Bundler::Persistent::Net::HTTP::Persistent
@verify_mode = nil
@cert_store = nil
- @generation = 0 # incremented when proxy Bundler::URI changes
+ @generation = 0 # incremented when proxy Gem::URI changes
if HAVE_OPENSSL then
@verify_mode = OpenSSL::SSL::VERIFY_PEER
@@ -529,7 +529,7 @@ class Bundler::Persistent::Net::HTTP::Persistent
reconnect_ssl
end
- # For Net::HTTP parity
+ # For Gem::Net::HTTP parity
alias cert= certificate=
##
@@ -648,7 +648,7 @@ class Bundler::Persistent::Net::HTTP::Persistent
end
##
- # Starts the Net::HTTP +connection+
+ # Starts the Gem::Net::HTTP +connection+
def start http
http.set_debug_output @debug_output if @debug_output
@@ -666,7 +666,7 @@ class Bundler::Persistent::Net::HTTP::Persistent
end
##
- # Finishes the Net::HTTP +connection+
+ # Finishes the Gem::Net::HTTP +connection+
def finish connection
connection.finish
@@ -716,16 +716,16 @@ class Bundler::Persistent::Net::HTTP::Persistent
reconnect_ssl
end
- # For Net::HTTP parity
+ # For Gem::Net::HTTP parity
alias key= private_key=
##
- # Sets the proxy server. The +proxy+ may be the Bundler::URI of the proxy server,
+ # Sets the proxy server. The +proxy+ may be the Gem::URI of the proxy server,
# the symbol +:ENV+ which will read the proxy from the environment or nil to
# disable use of a proxy. See #proxy_from_env for details on setting the
# proxy from the environment.
#
- # If the proxy Bundler::URI is set after requests have been made, the next request
+ # If the proxy Gem::URI is set after requests have been made, the next request
# will shut-down and re-open all connections.
#
# The +no_proxy+ query parameter can be used to specify hosts which shouldn't
@@ -736,9 +736,9 @@ class Bundler::Persistent::Net::HTTP::Persistent
def proxy= proxy
@proxy_uri = case proxy
when :ENV then proxy_from_env
- when Bundler::URI::HTTP then proxy
+ when Gem::URI::HTTP then proxy
when nil then # ignore
- else raise ArgumentError, 'proxy must be :ENV or a Bundler::URI::HTTP'
+ else raise ArgumentError, 'proxy must be :ENV or a Gem::URI::HTTP'
end
@no_proxy.clear
@@ -763,13 +763,13 @@ class Bundler::Persistent::Net::HTTP::Persistent
end
##
- # Creates a Bundler::URI for an HTTP proxy server from ENV variables.
+ # Creates a Gem::URI for an HTTP proxy server from ENV variables.
#
# If +HTTP_PROXY+ is set a proxy will be returned.
#
- # If +HTTP_PROXY_USER+ or +HTTP_PROXY_PASS+ are set the Bundler::URI is given the
+ # If +HTTP_PROXY_USER+ or +HTTP_PROXY_PASS+ are set the Gem::URI is given the
# indicated user and password unless HTTP_PROXY contains either of these in
- # the Bundler::URI.
+ # the Gem::URI.
#
# The +NO_PROXY+ ENV variable can be used to specify hosts which shouldn't
# be reached via proxy; if set it should be a comma separated list of
@@ -785,7 +785,7 @@ class Bundler::Persistent::Net::HTTP::Persistent
return nil if env_proxy.nil? or env_proxy.empty?
- uri = Bundler::URI normalize_uri env_proxy
+ uri = Gem::URI normalize_uri env_proxy
env_no_proxy = ENV['no_proxy'] || ENV['NO_PROXY']
@@ -835,7 +835,7 @@ class Bundler::Persistent::Net::HTTP::Persistent
end
##
- # Finishes then restarts the Net::HTTP +connection+
+ # Finishes then restarts the Gem::Net::HTTP +connection+
def reset connection
http = connection.http
@@ -854,16 +854,16 @@ class Bundler::Persistent::Net::HTTP::Persistent
end
##
- # Makes a request on +uri+. If +req+ is nil a Net::HTTP::Get is performed
+ # Makes a request on +uri+. If +req+ is nil a Gem::Net::HTTP::Get is performed
# against +uri+.
#
- # If a block is passed #request behaves like Net::HTTP#request (the body of
+ # If a block is passed #request behaves like Gem::Net::HTTP#request (the body of
# the response will not have been read).
#
- # +req+ must be a Net::HTTPGenericRequest subclass (see Net::HTTP for a list).
+ # +req+ must be a Gem::Net::HTTPGenericRequest subclass (see Gem::Net::HTTP for a list).
def request uri, req = nil, &block
- uri = Bundler::URI uri
+ uri = Gem::URI uri
req = request_setup req || uri
response = nil
@@ -896,14 +896,14 @@ class Bundler::Persistent::Net::HTTP::Persistent
end
##
- # Creates a GET request if +req_or_uri+ is a Bundler::URI and adds headers to the
+ # Creates a GET request if +req_or_uri+ is a Gem::URI and adds headers to the
# request.
#
# Returns the request.
def request_setup req_or_uri # :nodoc:
req = if req_or_uri.respond_to? 'request_uri' then
- Net::HTTP::Get.new req_or_uri.request_uri
+ Gem::Net::HTTP::Get.new req_or_uri.request_uri
else
req_or_uri
end
diff --git a/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent/connection.rb b/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent/connection.rb
index a57a5d1352..8b9ab5cc78 100644
--- a/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent/connection.rb
+++ b/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent/connection.rb
@@ -1,8 +1,8 @@
##
-# A Net::HTTP connection wrapper that holds extra information for managing the
+# A Gem::Net::HTTP connection wrapper that holds extra information for managing the
# connection's lifetime.
-class Bundler::Persistent::Net::HTTP::Persistent::Connection # :nodoc:
+class Gem::Net::HTTP::Persistent::Connection # :nodoc:
attr_accessor :http
@@ -25,9 +25,10 @@ class Bundler::Persistent::Net::HTTP::Persistent::Connection # :nodoc:
ensure
reset
end
+ alias_method :close, :finish
def reset
- @last_use = Bundler::Persistent::Net::HTTP::Persistent::EPOCH
+ @last_use = Gem::Net::HTTP::Persistent::EPOCH
@requests = 0
end
diff --git a/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent/pool.rb b/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent/pool.rb
index 9dfa6ffdb1..04a1e754bf 100644
--- a/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent/pool.rb
+++ b/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent/pool.rb
@@ -1,4 +1,4 @@
-class Bundler::Persistent::Net::HTTP::Persistent::Pool < Bundler::ConnectionPool # :nodoc:
+class Gem::Net::HTTP::Persistent::Pool < Bundler::ConnectionPool # :nodoc:
attr_reader :available # :nodoc:
attr_reader :key # :nodoc:
@@ -6,25 +6,37 @@ class Bundler::Persistent::Net::HTTP::Persistent::Pool < Bundler::ConnectionPool
def initialize(options = {}, &block)
super
- @available = Bundler::Persistent::Net::HTTP::Persistent::TimedStackMulti.new(@size, &block)
+ @available = Gem::Net::HTTP::Persistent::TimedStackMulti.new(@size, &block)
@key = "current-#{@available.object_id}"
end
def checkin net_http_args
- stack = Thread.current[@key][net_http_args] ||= []
+ if net_http_args.is_a?(Hash) && net_http_args.size == 1 && net_http_args[:force]
+ # Bundler::ConnectionPool 2.4+ calls `checkin(force: true)` after fork.
+ # When this happens, we should remove all connections from Thread.current
+ if stacks = Thread.current[@key]
+ stacks.each do |http_args, connections|
+ connections.each do |conn|
+ @available.push conn, connection_args: http_args
+ end
+ connections.clear
+ end
+ end
+ else
+ stack = Thread.current[@key][net_http_args] ||= []
- raise Bundler::ConnectionPool::Error, 'no connections are checked out' if
- stack.empty?
+ raise Bundler::ConnectionPool::Error, 'no connections are checked out' if
+ stack.empty?
- conn = stack.pop
+ conn = stack.pop
- if stack.empty?
- @available.push conn, connection_args: net_http_args
+ if stack.empty?
+ @available.push conn, connection_args: net_http_args
- Thread.current[@key].delete(net_http_args)
- Thread.current[@key] = nil if Thread.current[@key].empty?
+ Thread.current[@key].delete(net_http_args)
+ Thread.current[@key] = nil if Thread.current[@key].empty?
+ end
end
-
nil
end
diff --git a/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent/timed_stack_multi.rb b/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent/timed_stack_multi.rb
index 2da881c554..214804fcd9 100644
--- a/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent/timed_stack_multi.rb
+++ b/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent/timed_stack_multi.rb
@@ -1,4 +1,4 @@
-class Bundler::Persistent::Net::HTTP::Persistent::TimedStackMulti < Bundler::ConnectionPool::TimedStack # :nodoc:
+class Gem::Net::HTTP::Persistent::TimedStackMulti < Bundler::ConnectionPool::TimedStack # :nodoc:
##
# Returns a new hash that has arrays for keys
diff --git a/lib/bundler/vendor/pub_grub/.document b/lib/bundler/vendor/pub_grub/.document
new file mode 100644
index 0000000000..0c43bbd6b3
--- /dev/null
+++ b/lib/bundler/vendor/pub_grub/.document
@@ -0,0 +1 @@
+# Vendored files do not need to be documented
diff --git a/lib/bundler/vendor/pub_grub/lib/pub_grub/incompatibility.rb b/lib/bundler/vendor/pub_grub/lib/pub_grub/incompatibility.rb
index dab58ecdf7..239eaf3401 100644
--- a/lib/bundler/vendor/pub_grub/lib/pub_grub/incompatibility.rb
+++ b/lib/bundler/vendor/pub_grub/lib/pub_grub/incompatibility.rb
@@ -8,9 +8,6 @@ module Bundler::PubGrub
InvalidDependency = Struct.new(:package, :constraint) do
end
- CircularDependency = Struct.new(:package, :constraint) do
- end
-
NoVersions = Struct.new(:constraint) do
end
@@ -66,8 +63,6 @@ module Bundler::PubGrub
"#{terms[0].to_s(allow_every: true)} depends on #{terms[1].invert}"
when Bundler::PubGrub::Incompatibility::InvalidDependency
"#{terms[0].to_s(allow_every: true)} depends on unknown package #{cause.package}"
- when Bundler::PubGrub::Incompatibility::CircularDependency
- "#{terms[0].to_s(allow_every: true)} depends on itself"
when Bundler::PubGrub::Incompatibility::NoVersions
"no versions satisfy #{cause.constraint}"
when Bundler::PubGrub::Incompatibility::ConflictCause
@@ -76,9 +71,13 @@ module Bundler::PubGrub
elsif terms.length == 1
term = terms[0]
if term.positive?
- "#{terms[0].to_s(allow_every: true)} is forbidden"
+ if term.constraint.any?
+ "#{term.package} cannot be used"
+ else
+ "#{term.to_s(allow_every: true)} cannot be used"
+ end
else
- "#{terms[0].invert} is required"
+ "#{term.invert} is required"
end
else
if terms.all?(&:positive?)
diff --git a/lib/bundler/vendor/pub_grub/lib/pub_grub/static_package_source.rb b/lib/bundler/vendor/pub_grub/lib/pub_grub/static_package_source.rb
index e895812bed..36ab06254d 100644
--- a/lib/bundler/vendor/pub_grub/lib/pub_grub/static_package_source.rb
+++ b/lib/bundler/vendor/pub_grub/lib/pub_grub/static_package_source.rb
@@ -1,4 +1,5 @@
require_relative 'package'
+require_relative 'rubygems'
require_relative 'version_constraint'
require_relative 'incompatibility'
require_relative 'basic_package_source'
@@ -19,7 +20,14 @@ module Bundler::PubGrub
version = Gem::Version.new(version)
@packages[name] ||= {}
raise ArgumentError, "#{name} #{version} declared twice" if @packages[name].key?(version)
- @packages[name][version] = deps
+ @packages[name][version] = clean_deps(name, version, deps)
+ end
+
+ private
+
+ # Exclude redundant self-referencing dependencies
+ def clean_deps(name, version, deps)
+ deps.reject {|dep_name, req| name == dep_name && Bundler::PubGrub::RubyGems.parse_range(req).include?(version) }
end
end
diff --git a/lib/bundler/vendor/pub_grub/lib/pub_grub/version_constraint.rb b/lib/bundler/vendor/pub_grub/lib/pub_grub/version_constraint.rb
index 9133332d01..b71f3eaf53 100644
--- a/lib/bundler/vendor/pub_grub/lib/pub_grub/version_constraint.rb
+++ b/lib/bundler/vendor/pub_grub/lib/pub_grub/version_constraint.rb
@@ -15,15 +15,16 @@ module Bundler::PubGrub
package.hash ^ range.hash
end
+ def ==(other)
+ package == other.package &&
+ range == other.range
+ end
+
def eql?(other)
package.eql?(other.package) &&
range.eql?(other.range)
end
- def ==(other)
- package == other.package && range == other.range
- end
-
class << self
def exact(package, version)
range = VersionRange.new(min: version, max: version, include_min: true, include_max: true)
diff --git a/lib/bundler/vendor/pub_grub/lib/pub_grub/version_range.rb b/lib/bundler/vendor/pub_grub/lib/pub_grub/version_range.rb
index 506b447b36..8d73c3f7b5 100644
--- a/lib/bundler/vendor/pub_grub/lib/pub_grub/version_range.rb
+++ b/lib/bundler/vendor/pub_grub/lib/pub_grub/version_range.rb
@@ -19,7 +19,7 @@ module Bundler::PubGrub
true
end
- def eql?
+ def eql?(other)
other.empty?
end
@@ -65,6 +65,7 @@ module Bundler::PubGrub
end
EMPTY = Empty.new
+ Empty.singleton_class.undef_method(:new)
def self.empty
EMPTY
@@ -88,7 +89,8 @@ module Bundler::PubGrub
def eql?(other)
if other.is_a?(VersionRange)
- min.eql?(other.min) &&
+ !other.empty? &&
+ min.eql?(other.min) &&
max.eql?(other.max) &&
include_min.eql?(other.include_min) &&
include_max.eql?(other.include_max)
diff --git a/lib/bundler/vendor/pub_grub/lib/pub_grub/version_solver.rb b/lib/bundler/vendor/pub_grub/lib/pub_grub/version_solver.rb
index ea5e455968..4caf6b355b 100644
--- a/lib/bundler/vendor/pub_grub/lib/pub_grub/version_solver.rb
+++ b/lib/bundler/vendor/pub_grub/lib/pub_grub/version_solver.rb
@@ -125,6 +125,7 @@ module Bundler::PubGrub
package = next_package_to_try
unsatisfied_term = solution.unsatisfied.find { |t| t.package == package }
version = source.versions_for(package, unsatisfied_term.constraint.range).first
+ logger.debug { "attempting #{package} #{version}" }
if version.nil?
add_incompatibility source.no_versions_incompatibility_for(package, unsatisfied_term)
@@ -148,9 +149,11 @@ module Bundler::PubGrub
end
unless conflict
- logger.info { "selecting #{package} #{version}" }
+ logger.info { "selected #{package} #{version}" }
solution.decide(package, version)
+ else
+ logger.info { "conflict: #{conflict.inspect}" }
end
package
@@ -159,7 +162,7 @@ module Bundler::PubGrub
def resolve_conflict(incompatibility)
logger.info { "conflict: #{incompatibility}" }
- new_incompatibility = false
+ new_incompatibility = nil
while !incompatibility.failure?
most_recent_term = nil
@@ -201,7 +204,7 @@ module Bundler::PubGrub
solution.backtrack(previous_level)
if new_incompatibility
- add_incompatibility(incompatibility)
+ add_incompatibility(new_incompatibility)
end
return incompatibility
@@ -216,9 +219,14 @@ module Bundler::PubGrub
new_terms << difference.invert
end
- incompatibility = Incompatibility.new(new_terms, cause: Incompatibility::ConflictCause.new(incompatibility, most_recent_satisfier.cause))
+ new_incompatibility = Incompatibility.new(new_terms, cause: Incompatibility::ConflictCause.new(incompatibility, most_recent_satisfier.cause))
+
+ if incompatibility.to_s == new_incompatibility.to_s
+ logger.info { "!! failed to resolve conflicts, this shouldn't have happened" }
+ break
+ end
- new_incompatibility = true
+ incompatibility = new_incompatibility
partially = difference ? " partially" : ""
logger.info { "! #{most_recent_term} is#{partially} satisfied by #{most_recent_satisfier.term}" }
diff --git a/lib/bundler/vendor/thor/.document b/lib/bundler/vendor/thor/.document
new file mode 100644
index 0000000000..0c43bbd6b3
--- /dev/null
+++ b/lib/bundler/vendor/thor/.document
@@ -0,0 +1 @@
+# Vendored files do not need to be documented
diff --git a/lib/bundler/vendor/thor/lib/thor.rb b/lib/bundler/vendor/thor/lib/thor.rb
index 0794dbb522..627722164f 100644
--- a/lib/bundler/vendor/thor/lib/thor.rb
+++ b/lib/bundler/vendor/thor/lib/thor.rb
@@ -65,8 +65,15 @@ class Bundler::Thor
# Defines the long description of the next command.
#
+ # Long description is by default indented, line-wrapped and repeated whitespace merged.
+ # In order to print long description verbatim, with indentation and spacing exactly
+ # as found in the code, use the +wrap+ option
+ #
+ # long_desc 'your very long description', wrap: false
+ #
# ==== Parameters
# long description<String>
+ # options<Hash>
#
def long_desc(long_description, options = {})
if options[:for]
@@ -74,6 +81,7 @@ class Bundler::Thor
command.long_description = long_description if long_description
else
@long_desc = long_description
+ @long_desc_wrap = options[:wrap] != false
end
end
@@ -133,7 +141,7 @@ class Bundler::Thor
# # magic
# end
#
- # method_option :foo => :bar, :for => :previous_command
+ # method_option :foo, :for => :previous_command
#
# def next_command
# # magic
@@ -153,6 +161,9 @@ class Bundler::Thor
# :hide - If you want to hide this option from the help.
#
def method_option(name, options = {})
+ unless [ Symbol, String ].any? { |klass| name.is_a?(klass) }
+ raise ArgumentError, "Expected a Symbol or String, got #{name.inspect}"
+ end
scope = if options[:for]
find_and_refresh_command(options[:for]).options
else
@@ -163,6 +174,81 @@ class Bundler::Thor
end
alias_method :option, :method_option
+ # Adds and declares option group for exclusive options in the
+ # block and arguments. You can declare options as the outside of the block.
+ #
+ # If :for is given as option, it allows you to change the options from
+ # a previous defined command.
+ #
+ # ==== Parameters
+ # Array[Bundler::Thor::Option.name]
+ # options<Hash>:: :for is applied for previous defined command.
+ #
+ # ==== Examples
+ #
+ # exclusive do
+ # option :one
+ # option :two
+ # end
+ #
+ # Or
+ #
+ # option :one
+ # option :two
+ # exclusive :one, :two
+ #
+ # If you give "--one" and "--two" at the same time ExclusiveArgumentsError
+ # will be raised.
+ #
+ def method_exclusive(*args, &block)
+ register_options_relation_for(:method_options,
+ :method_exclusive_option_names, *args, &block)
+ end
+ alias_method :exclusive, :method_exclusive
+
+ # Adds and declares option group for required at least one of options in the
+ # block of arguments. You can declare options as the outside of the block.
+ #
+ # If :for is given as option, it allows you to change the options from
+ # a previous defined command.
+ #
+ # ==== Parameters
+ # Array[Bundler::Thor::Option.name]
+ # options<Hash>:: :for is applied for previous defined command.
+ #
+ # ==== Examples
+ #
+ # at_least_one do
+ # option :one
+ # option :two
+ # end
+ #
+ # Or
+ #
+ # option :one
+ # option :two
+ # at_least_one :one, :two
+ #
+ # If you do not give "--one" and "--two" AtLeastOneRequiredArgumentError
+ # will be raised.
+ #
+ # You can use at_least_one and exclusive at the same time.
+ #
+ # exclusive do
+ # at_least_one do
+ # option :one
+ # option :two
+ # end
+ # end
+ #
+ # Then it is required either only one of "--one" or "--two".
+ #
+ def method_at_least_one(*args, &block)
+ register_options_relation_for(:method_options,
+ :method_at_least_one_option_names, *args, &block)
+ end
+ alias_method :at_least_one, :method_at_least_one
+
# Prints help information for the given command.
#
# ==== Parameters
@@ -178,9 +264,16 @@ class Bundler::Thor
shell.say " #{banner(command).split("\n").join("\n ")}"
shell.say
class_options_help(shell, nil => command.options.values)
+ print_exclusive_options(shell, command)
+ print_at_least_one_required_options(shell, command)
+
if command.long_description
shell.say "Description:"
- shell.print_wrapped(command.long_description, :indent => 2)
+ if command.wrap_long_description
+ shell.print_wrapped(command.long_description, indent: 2)
+ else
+ shell.say command.long_description
+ end
else
shell.say command.description
end
@@ -197,7 +290,7 @@ class Bundler::Thor
Bundler::Thor::Util.thor_classes_in(self).each do |klass|
list += klass.printable_commands(false)
end
- list.sort! { |a, b| a[0] <=> b[0] }
+ sort_commands!(list)
if defined?(@package_name) && @package_name
shell.say "#{@package_name} commands:"
@@ -205,9 +298,11 @@ class Bundler::Thor
shell.say "Commands:"
end
- shell.print_table(list, :indent => 2, :truncate => true)
+ shell.print_table(list, indent: 2, truncate: true)
shell.say
class_options_help(shell)
+ print_exclusive_options(shell)
+ print_at_least_one_required_options(shell)
end
# Returns commands ready to be printed.
@@ -238,7 +333,7 @@ class Bundler::Thor
define_method(subcommand) do |*args|
args, opts = Bundler::Thor::Arguments.split(args)
- invoke_args = [args, opts, {:invoked_via_subcommand => true, :class_options => options}]
+ invoke_args = [args, opts, {invoked_via_subcommand: true, class_options: options}]
invoke_args.unshift "help" if opts.delete("--help") || opts.delete("-h")
invoke subcommand_class, *invoke_args
end
@@ -346,6 +441,24 @@ class Bundler::Thor
protected
+ # Returns this class exclusive options array set.
+ #
+ # ==== Returns
+ # Array[Array[Bundler::Thor::Option.name]]
+ #
+ def method_exclusive_option_names #:nodoc:
+ @method_exclusive_option_names ||= []
+ end
+
+ # Returns this class at least one of required options array set.
+ #
+ # ==== Returns
+ # Array[Array[Bundler::Thor::Option.name]]
+ #
+ def method_at_least_one_option_names #:nodoc:
+ @method_at_least_one_option_names ||= []
+ end
+
def stop_on_unknown_option #:nodoc:
@stop_on_unknown_option ||= []
end
@@ -355,8 +468,30 @@ class Bundler::Thor
@disable_required_check ||= [:help]
end
+ def print_exclusive_options(shell, command = nil) # :nodoc:
+ opts = []
+ opts = command.method_exclusive_option_names unless command.nil?
+ opts += class_exclusive_option_names
+ unless opts.empty?
+ shell.say "Exclusive Options:"
+ shell.print_table(opts.map{ |ex| ex.map{ |e| "--#{e}"}}, indent: 2 )
+ shell.say
+ end
+ end
+
+ def print_at_least_one_required_options(shell, command = nil) # :nodoc:
+ opts = []
+ opts = command.method_at_least_one_option_names unless command.nil?
+ opts += class_at_least_one_option_names
+ unless opts.empty?
+ shell.say "Required At Least One:"
+ shell.print_table(opts.map{ |ex| ex.map{ |e| "--#{e}"}}, indent: 2 )
+ shell.say
+ end
+ end
+
# The method responsible for dispatching given the args.
- def dispatch(meth, given_args, given_opts, config) #:nodoc: # rubocop:disable MethodLength
+ def dispatch(meth, given_args, given_opts, config) #:nodoc:
meth ||= retrieve_command_name(given_args)
command = all_commands[normalize_command_name(meth)]
@@ -415,12 +550,16 @@ class Bundler::Thor
@usage ||= nil
@desc ||= nil
@long_desc ||= nil
+ @long_desc_wrap ||= nil
@hide ||= nil
if @usage && @desc
base_class = @hide ? Bundler::Thor::HiddenCommand : Bundler::Thor::Command
- commands[meth] = base_class.new(meth, @desc, @long_desc, @usage, method_options)
- @usage, @desc, @long_desc, @method_options, @hide = nil
+ relations = {exclusive_option_names: method_exclusive_option_names,
+ at_least_one_option_names: method_at_least_one_option_names}
+ commands[meth] = base_class.new(meth, @desc, @long_desc, @long_desc_wrap, @usage, method_options, relations)
+ @usage, @desc, @long_desc, @long_desc_wrap, @method_options, @hide = nil
+ @method_exclusive_option_names, @method_at_least_one_option_names = nil
true
elsif all_commands[meth] || meth == "method_missing"
true
@@ -495,6 +634,14 @@ class Bundler::Thor
"
end
alias_method :subtask_help, :subcommand_help
+
+ # Sort the commands, lexicographically by default.
+ #
+ # Can be overridden in the subclass to change the display order of the
+ # commands.
+ def sort_commands!(list)
+ list.sort! { |a, b| a[0] <=> b[0] }
+ end
end
include Bundler::Thor::Base
diff --git a/lib/bundler/vendor/thor/lib/thor/actions.rb b/lib/bundler/vendor/thor/lib/thor/actions.rb
index de9b3b4c86..ca58182691 100644
--- a/lib/bundler/vendor/thor/lib/thor/actions.rb
+++ b/lib/bundler/vendor/thor/lib/thor/actions.rb
@@ -46,17 +46,17 @@ class Bundler::Thor
# Add runtime options that help actions execution.
#
def add_runtime_options!
- class_option :force, :type => :boolean, :aliases => "-f", :group => :runtime,
- :desc => "Overwrite files that already exist"
+ class_option :force, type: :boolean, aliases: "-f", group: :runtime,
+ desc: "Overwrite files that already exist"
- class_option :pretend, :type => :boolean, :aliases => "-p", :group => :runtime,
- :desc => "Run but do not make any changes"
+ class_option :pretend, type: :boolean, aliases: "-p", group: :runtime,
+ desc: "Run but do not make any changes"
- class_option :quiet, :type => :boolean, :aliases => "-q", :group => :runtime,
- :desc => "Suppress status output"
+ class_option :quiet, type: :boolean, aliases: "-q", group: :runtime,
+ desc: "Suppress status output"
- class_option :skip, :type => :boolean, :aliases => "-s", :group => :runtime,
- :desc => "Skip files that already exist"
+ class_option :skip, type: :boolean, aliases: "-s", group: :runtime,
+ desc: "Skip files that already exist"
end
end
@@ -113,9 +113,9 @@ class Bundler::Thor
#
def relative_to_original_destination_root(path, remove_dot = true)
root = @destination_stack[0]
- if path.start_with?(root) && [File::SEPARATOR, File::ALT_SEPARATOR, nil, ''].include?(path[root.size..root.size])
+ if path.start_with?(root) && [File::SEPARATOR, File::ALT_SEPARATOR, nil, ""].include?(path[root.size..root.size])
path = path.dup
- path[0...root.size] = '.'
+ path[0...root.size] = "."
remove_dot ? (path[2..-1] || "") : path
else
path
@@ -175,7 +175,7 @@ class Bundler::Thor
shell.padding += 1 if verbose
@destination_stack.push File.expand_path(dir, destination_root)
- # If the directory doesnt exist and we're not pretending
+ # If the directory doesn't exist and we're not pretending
if !File.exist?(destination_root) && !pretend
require "fileutils"
FileUtils.mkdir_p(destination_root)
@@ -225,7 +225,7 @@ class Bundler::Thor
require "open-uri"
URI.open(path, "Accept" => "application/x-thor-template", &:read)
else
- open(path, &:read)
+ File.open(path, &:read)
end
instance_eval(contents, path)
@@ -284,7 +284,7 @@ class Bundler::Thor
#
def run_ruby_script(command, config = {})
return unless behavior == :invoke
- run command, config.merge(:with => Bundler::Thor::Util.ruby_command)
+ run command, config.merge(with: Bundler::Thor::Util.ruby_command)
end
# Run a thor command. A hash of options can be given and it's converted to
@@ -315,7 +315,7 @@ class Bundler::Thor
args.push Bundler::Thor::Options.to_switches(config)
command = args.join(" ").strip
- run command, :with => :thor, :verbose => verbose, :pretend => pretend, :capture => capture
+ run command, with: :thor, verbose: verbose, pretend: pretend, capture: capture
end
protected
@@ -323,7 +323,7 @@ class Bundler::Thor
# Allow current root to be shared between invocations.
#
def _shared_configuration #:nodoc:
- super.merge!(:destination_root => destination_root)
+ super.merge!(destination_root: destination_root)
end
def _cleanup_options_and_set(options, key) #:nodoc:
diff --git a/lib/bundler/vendor/thor/lib/thor/actions/create_file.rb b/lib/bundler/vendor/thor/lib/thor/actions/create_file.rb
index 330fc08cae..6724835b01 100644
--- a/lib/bundler/vendor/thor/lib/thor/actions/create_file.rb
+++ b/lib/bundler/vendor/thor/lib/thor/actions/create_file.rb
@@ -43,7 +43,8 @@ class Bundler::Thor
# Boolean:: true if it is identical, false otherwise.
#
def identical?
- exists? && File.binread(destination) == render
+ # binread uses ASCII-8BIT, so to avoid false negatives, the string must use the same
+ exists? && File.binread(destination) == String.new(render).force_encoding("ASCII-8BIT")
end
# Holds the content to be added to the file.
@@ -60,7 +61,7 @@ class Bundler::Thor
invoke_with_conflict_check do
require "fileutils"
FileUtils.mkdir_p(File.dirname(destination))
- File.open(destination, "wb") { |f| f.write render }
+ File.open(destination, "wb", config[:perm]) { |f| f.write render }
end
given_destination
end
diff --git a/lib/bundler/vendor/thor/lib/thor/actions/directory.rb b/lib/bundler/vendor/thor/lib/thor/actions/directory.rb
index d37327a139..2f9687c0a5 100644
--- a/lib/bundler/vendor/thor/lib/thor/actions/directory.rb
+++ b/lib/bundler/vendor/thor/lib/thor/actions/directory.rb
@@ -58,7 +58,7 @@ class Bundler::Thor
def initialize(base, source, destination = nil, config = {}, &block)
@source = File.expand_path(Dir[Util.escape_globs(base.find_in_source_paths(source.to_s))].first)
@block = block
- super(base, destination, {:recursive => true}.merge(config))
+ super(base, destination, {recursive: true}.merge(config))
end
def invoke!
diff --git a/lib/bundler/vendor/thor/lib/thor/actions/empty_directory.rb b/lib/bundler/vendor/thor/lib/thor/actions/empty_directory.rb
index 284d92c19a..c0bca78525 100644
--- a/lib/bundler/vendor/thor/lib/thor/actions/empty_directory.rb
+++ b/lib/bundler/vendor/thor/lib/thor/actions/empty_directory.rb
@@ -33,7 +33,7 @@ class Bundler::Thor
#
def initialize(base, destination, config = {})
@base = base
- @config = {:verbose => true}.merge(config)
+ @config = {verbose: true}.merge(config)
self.destination = destination
end
diff --git a/lib/bundler/vendor/thor/lib/thor/actions/file_manipulation.rb b/lib/bundler/vendor/thor/lib/thor/actions/file_manipulation.rb
index bf2a737c84..80a0255996 100644
--- a/lib/bundler/vendor/thor/lib/thor/actions/file_manipulation.rb
+++ b/lib/bundler/vendor/thor/lib/thor/actions/file_manipulation.rb
@@ -66,12 +66,15 @@ class Bundler::Thor
# ==== Parameters
# source<String>:: the address of the given content.
# destination<String>:: the relative path to the destination root.
- # config<Hash>:: give :verbose => false to not log the status.
+ # config<Hash>:: give :verbose => false to not log the status, and
+ # :http_headers => <Hash> to add headers to an http request.
#
# ==== Examples
#
# get "http://gist.github.com/103208", "doc/README"
#
+ # get "http://gist.github.com/103208", "doc/README", :http_headers => {"Content-Type" => "application/json"}
+ #
# get "http://gist.github.com/103208" do |content|
# content.split("\n").first
# end
@@ -82,10 +85,10 @@ class Bundler::Thor
render = if source =~ %r{^https?\://}
require "open-uri"
- URI.send(:open, source) { |input| input.binmode.read }
+ URI.send(:open, source, config.fetch(:http_headers, {})) { |input| input.binmode.read }
else
source = File.expand_path(find_in_source_paths(source.to_s))
- open(source) { |input| input.binmode.read }
+ File.open(source) { |input| input.binmode.read }
end
destination ||= if block_given?
@@ -120,12 +123,7 @@ class Bundler::Thor
context = config.delete(:context) || instance_eval("binding")
create_file destination, nil, config do
- match = ERB.version.match(/(\d+\.\d+\.\d+)/)
- capturable_erb = if match && match[1] >= "2.2.0" # Ruby 2.6+
- CapturableERB.new(::File.binread(source), :trim_mode => "-", :eoutvar => "@output_buffer")
- else
- CapturableERB.new(::File.binread(source), nil, "-", "@output_buffer")
- end
+ capturable_erb = CapturableERB.new(::File.binread(source), trim_mode: "-", eoutvar: "@output_buffer")
content = capturable_erb.tap do |erb|
erb.filename = source
end.result(context)
@@ -252,7 +250,7 @@ class Bundler::Thor
# flag<Regexp|String>:: the regexp or string to be replaced
# replacement<String>:: the replacement, can be also given as a block
# config<Hash>:: give :verbose => false to not log the status, and
- # :force => true, to force the replacement regardles of runner behavior.
+ # :force => true, to force the replacement regardless of runner behavior.
#
# ==== Example
#
diff --git a/lib/bundler/vendor/thor/lib/thor/actions/inject_into_file.rb b/lib/bundler/vendor/thor/lib/thor/actions/inject_into_file.rb
index bf013307f1..70526e615f 100644
--- a/lib/bundler/vendor/thor/lib/thor/actions/inject_into_file.rb
+++ b/lib/bundler/vendor/thor/lib/thor/actions/inject_into_file.rb
@@ -21,7 +21,7 @@ class Bundler::Thor
# gems.split(" ").map{ |gem| " config.gem :#{gem}" }.join("\n")
# end
#
- WARNINGS = { unchanged_no_flag: 'File unchanged! The supplied flag value not found!' }
+ WARNINGS = {unchanged_no_flag: "File unchanged! Either the supplied flag value not found or the content has already been inserted!"}
def insert_into_file(destination, *args, &block)
data = block_given? ? block : args.shift
@@ -37,7 +37,7 @@ class Bundler::Thor
attr_reader :replacement, :flag, :behavior
def initialize(base, destination, data, config)
- super(base, destination, {:verbose => true}.merge(config))
+ super(base, destination, {verbose: true}.merge(config))
@behavior, @flag = if @config.key?(:after)
[:after, @config.delete(:after)]
@@ -59,6 +59,8 @@ class Bundler::Thor
if exists?
if replace!(/#{flag}/, content, config[:force])
say_status(:invoke)
+ elsif replacement_present?
+ say_status(:unchanged, color: :blue)
else
say_status(:unchanged, warning: WARNINGS[:unchanged_no_flag], color: :red)
end
@@ -96,6 +98,8 @@ class Bundler::Thor
end
elsif warning
warning
+ elsif behavior == :unchanged
+ :unchanged
else
:subtract
end
@@ -103,11 +107,18 @@ class Bundler::Thor
super(status, (color || config[:verbose]))
end
+ def content
+ @content ||= File.read(destination)
+ end
+
+ def replacement_present?
+ content.include?(replacement)
+ end
+
# Adds the content to the file.
#
def replace!(regexp, string, force)
- content = File.read(destination)
- if force || !content.include?(replacement)
+ if force || !replacement_present?
success = content.gsub!(regexp, string)
File.open(destination, "wb") { |file| file.write(content) } unless pretend?
diff --git a/lib/bundler/vendor/thor/lib/thor/base.rb b/lib/bundler/vendor/thor/lib/thor/base.rb
index 8487f9590a..b156899c1e 100644
--- a/lib/bundler/vendor/thor/lib/thor/base.rb
+++ b/lib/bundler/vendor/thor/lib/thor/base.rb
@@ -24,9 +24,9 @@ class Bundler::Thor
class << self
def deprecation_warning(message) #:nodoc:
- unless ENV['THOR_SILENCE_DEPRECATION']
+ unless ENV["THOR_SILENCE_DEPRECATION"]
warn "Deprecation warning: #{message}\n" +
- 'You can silence deprecations warning by setting the environment variable THOR_SILENCE_DEPRECATION.'
+ "You can silence deprecations warning by setting the environment variable THOR_SILENCE_DEPRECATION."
end
end
end
@@ -60,6 +60,7 @@ class Bundler::Thor
command_options = config.delete(:command_options) # hook for start
parse_options = parse_options.merge(command_options) if command_options
+
if local_options.is_a?(Array)
array_options = local_options
hash_options = {}
@@ -73,9 +74,24 @@ class Bundler::Thor
# Let Bundler::Thor::Options parse the options first, so it can remove
# declared options from the array. This will leave us with
# a list of arguments that weren't declared.
- stop_on_unknown = self.class.stop_on_unknown_option? config[:current_command]
- disable_required_check = self.class.disable_required_check? config[:current_command]
- opts = Bundler::Thor::Options.new(parse_options, hash_options, stop_on_unknown, disable_required_check)
+ current_command = config[:current_command]
+ stop_on_unknown = self.class.stop_on_unknown_option? current_command
+
+ # Give a relation of options.
+ # After parsing, Bundler::Thor::Options check whether right relations are kept
+ relations = if current_command.nil?
+ {exclusive_option_names: [], at_least_one_option_names: []}
+ else
+ current_command.options_relation
+ end
+
+ self.class.class_exclusive_option_names.map { |n| relations[:exclusive_option_names] << n }
+ self.class.class_at_least_one_option_names.map { |n| relations[:at_least_one_option_names] << n }
+
+ disable_required_check = self.class.disable_required_check? current_command
+
+ opts = Bundler::Thor::Options.new(parse_options, hash_options, stop_on_unknown, disable_required_check, relations)
+
self.options = opts.parse(array_options)
self.options = config[:class_options].merge(options) if config[:class_options]
@@ -310,9 +326,92 @@ class Bundler::Thor
# :hide:: -- If you want to hide this option from the help.
#
def class_option(name, options = {})
+ unless [ Symbol, String ].any? { |klass| name.is_a?(klass) }
+ raise ArgumentError, "Expected a Symbol or String, got #{name.inspect}"
+ end
build_option(name, options, class_options)
end
+ # Adds and declares option group for exclusive options in the
+ # block and arguments. You can declare options as the outside of the block.
+ #
+ # ==== Parameters
+ # Array[Bundler::Thor::Option.name]
+ #
+ # ==== Examples
+ #
+ # class_exclusive do
+ # class_option :one
+ # class_option :two
+ # end
+ #
+ # Or
+ #
+ # class_option :one
+ # class_option :two
+ # class_exclusive :one, :two
+ #
+ # If you give "--one" and "--two" at the same time ExclusiveArgumentsError
+ # will be raised.
+ #
+ def class_exclusive(*args, &block)
+ register_options_relation_for(:class_options,
+ :class_exclusive_option_names, *args, &block)
+ end
+
+ # Adds and declares option group for required at least one of options in the
+ # block and arguments. You can declare options as the outside of the block.
+ #
+ # ==== Examples
+ #
+ # class_at_least_one do
+ # class_option :one
+ # class_option :two
+ # end
+ #
+ # Or
+ #
+ # class_option :one
+ # class_option :two
+ # class_at_least_one :one, :two
+ #
+ # If you do not give "--one" and "--two" AtLeastOneRequiredArgumentError
+ # will be raised.
+ #
+ # You can use class_at_least_one and class_exclusive at the same time.
+ #
+ # class_exclusive do
+ # class_at_least_one do
+ # class_option :one
+ # class_option :two
+ # end
+ # end
+ #
+ # Then it is required either only one of "--one" or "--two".
+ #
+ def class_at_least_one(*args, &block)
+ register_options_relation_for(:class_options,
+ :class_at_least_one_option_names, *args, &block)
+ end
+
+ # Returns this class exclusive options array set, looking up in the ancestors chain.
+ #
+ # ==== Returns
+ # Array[Array[Bundler::Thor::Option.name]]
+ #
+ def class_exclusive_option_names
+ @class_exclusive_option_names ||= from_superclass(:class_exclusive_option_names, [])
+ end
+
+ # Returns this class at least one of required options array set, looking up in the ancestors chain.
+ #
+ # ==== Returns
+ # Array[Array[Bundler::Thor::Option.name]]
+ #
+ def class_at_least_one_option_names
+ @class_at_least_one_option_names ||= from_superclass(:class_at_least_one_option_names, [])
+ end
+
# Removes a previous defined argument. If :undefine is given, undefine
# accessors as well.
#
@@ -506,7 +605,7 @@ class Bundler::Thor
#
def public_command(*names)
names.each do |name|
- class_eval "def #{name}(*); super end"
+ class_eval "def #{name}(*); super end", __FILE__, __LINE__
end
end
alias_method :public_task, :public_command
@@ -558,20 +657,19 @@ class Bundler::Thor
return if options.empty?
list = []
- padding = options.map { |o| o.aliases.size }.max.to_i * 4
-
+ padding = options.map { |o| o.aliases_for_usage.size }.max.to_i
options.each do |option|
next if option.hide
item = [option.usage(padding)]
item.push(option.description ? "# #{option.description}" : "")
list << item
- list << ["", "# Default: #{option.default}"] if option.show_default?
- list << ["", "# Possible values: #{option.enum.join(', ')}"] if option.enum
+ list << ["", "# Default: #{option.print_default}"] if option.show_default?
+ list << ["", "# Possible values: #{option.enum_to_s}"] if option.enum
end
shell.say(group_name ? "#{group_name} options:" : "Options:")
- shell.print_table(list, :indent => 2)
+ shell.print_table(list, indent: 2)
shell.say ""
end
@@ -588,7 +686,7 @@ class Bundler::Thor
# options<Hash>:: Described in both class_option and method_option.
# scope<Hash>:: Options hash that is being built up
def build_option(name, options, scope) #:nodoc:
- scope[name] = Bundler::Thor::Option.new(name, {:check_default_type => check_default_type}.merge!(options))
+ scope[name] = Bundler::Thor::Option.new(name, {check_default_type: check_default_type}.merge!(options))
end
# Receives a hash of options, parse them and add to the scope. This is a
@@ -610,7 +708,7 @@ class Bundler::Thor
def find_and_refresh_command(name) #:nodoc:
if commands[name.to_s]
commands[name.to_s]
- elsif command = all_commands[name.to_s] # rubocop:disable AssignmentInCondition
+ elsif command = all_commands[name.to_s] # rubocop:disable Lint/AssignmentInCondition
commands[name.to_s] = command.clone
else
raise ArgumentError, "You supplied :for => #{name.inspect}, but the command #{name.inspect} could not be found."
@@ -618,7 +716,7 @@ class Bundler::Thor
end
alias_method :find_and_refresh_task, :find_and_refresh_command
- # Everytime someone inherits from a Bundler::Thor class, register the klass
+ # Every time someone inherits from a Bundler::Thor class, register the klass
# and file into baseclass.
def inherited(klass)
super(klass)
@@ -694,6 +792,34 @@ class Bundler::Thor
def dispatch(command, given_args, given_opts, config) #:nodoc:
raise NotImplementedError
end
+
+ # Register a relation of options for target(method_option/class_option)
+ # by args and block.
+ def register_options_relation_for(target, relation, *args, &block) # :nodoc:
+ opt = args.pop if args.last.is_a? Hash
+ opt ||= {}
+ names = args.map{ |arg| arg.to_s }
+ names += built_option_names(target, opt, &block) if block_given?
+ command_scope_member(relation, opt) << names
+ end
+
+ # Get target(method_options or class_options) options
+ # of before and after by block evaluation.
+ def built_option_names(target, opt = {}, &block) # :nodoc:
+ before = command_scope_member(target, opt).map{ |k,v| v.name }
+ instance_eval(&block)
+ after = command_scope_member(target, opt).map{ |k,v| v.name }
+ after - before
+ end
+
+ # Get command scope member by name.
+ def command_scope_member(name, options = {}) # :nodoc:
+ if options[:for]
+ find_and_refresh_command(options[:for]).send(name)
+ else
+ send(name)
+ end
+ end
end
end
end
diff --git a/lib/bundler/vendor/thor/lib/thor/command.rb b/lib/bundler/vendor/thor/lib/thor/command.rb
index 040c971c0c..68c8fffedb 100644
--- a/lib/bundler/vendor/thor/lib/thor/command.rb
+++ b/lib/bundler/vendor/thor/lib/thor/command.rb
@@ -1,14 +1,15 @@
class Bundler::Thor
- class Command < Struct.new(:name, :description, :long_description, :usage, :options, :ancestor_name)
+ class Command < Struct.new(:name, :description, :long_description, :wrap_long_description, :usage, :options, :options_relation, :ancestor_name)
FILE_REGEXP = /^#{Regexp.escape(File.dirname(__FILE__))}/
- def initialize(name, description, long_description, usage, options = nil)
- super(name.to_s, description, long_description, usage, options || {})
+ def initialize(name, description, long_description, wrap_long_description, usage, options = nil, options_relation = nil)
+ super(name.to_s, description, long_description, wrap_long_description, usage, options || {}, options_relation || {})
end
def initialize_copy(other) #:nodoc:
super(other)
self.options = other.options.dup if other.options
+ self.options_relation = other.options_relation.dup if other.options_relation
end
def hidden?
@@ -62,6 +63,14 @@ class Bundler::Thor
end.join("\n")
end
+ def method_exclusive_option_names #:nodoc:
+ self.options_relation[:exclusive_option_names] || []
+ end
+
+ def method_at_least_one_option_names #:nodoc:
+ self.options_relation[:at_least_one_option_names] || []
+ end
+
protected
# Add usage with required arguments
@@ -127,7 +136,7 @@ class Bundler::Thor
# A dynamic command that handles method missing scenarios.
class DynamicCommand < Command
def initialize(name, options = nil)
- super(name.to_s, "A dynamically-generated command", name.to_s, name.to_s, options)
+ super(name.to_s, "A dynamically-generated command", name.to_s, nil, name.to_s, options)
end
def run(instance, args = [])
diff --git a/lib/bundler/vendor/thor/lib/thor/core_ext/hash_with_indifferent_access.rb b/lib/bundler/vendor/thor/lib/thor/core_ext/hash_with_indifferent_access.rb
index 3c4483e5dd..b16a98f782 100644
--- a/lib/bundler/vendor/thor/lib/thor/core_ext/hash_with_indifferent_access.rb
+++ b/lib/bundler/vendor/thor/lib/thor/core_ext/hash_with_indifferent_access.rb
@@ -38,6 +38,10 @@ class Bundler::Thor
super(convert_key(key), *args)
end
+ def slice(*keys)
+ super(*keys.map{ |key| convert_key(key) })
+ end
+
def key?(key)
super(convert_key(key))
end
diff --git a/lib/bundler/vendor/thor/lib/thor/error.rb b/lib/bundler/vendor/thor/lib/thor/error.rb
index 03f2ce85bb..928646e501 100644
--- a/lib/bundler/vendor/thor/lib/thor/error.rb
+++ b/lib/bundler/vendor/thor/lib/thor/error.rb
@@ -1,18 +1,15 @@
class Bundler::Thor
Correctable = if defined?(DidYouMean::SpellChecker) && defined?(DidYouMean::Correctable) # rubocop:disable Naming/ConstantName
- # In order to support versions of Ruby that don't have keyword
- # arguments, we need our own spell checker class that doesn't take key
- # words. Even though this code wouldn't be hit because of the check
- # above, it's still necessary because the interpreter would otherwise be
- # unable to parse the file.
- class NoKwargSpellChecker < DidYouMean::SpellChecker # :nodoc:
- def initialize(dictionary)
- @dictionary = dictionary
- end
- end
-
- DidYouMean::Correctable
- end
+ Module.new do
+ def to_s
+ super + DidYouMean.formatter.message_for(corrections)
+ end
+
+ def corrections
+ @corrections ||= self.class.const_get(:SpellChecker).new(self).corrections
+ end
+ end
+ end
# Bundler::Thor::Error is raised when it's caused by wrong usage of thor classes. Those
# errors have their backtrace suppressed and are nicely shown to the user.
@@ -37,7 +34,7 @@ class Bundler::Thor
end
def spell_checker
- NoKwargSpellChecker.new(error.all_commands)
+ DidYouMean::SpellChecker.new(dictionary: error.all_commands)
end
end
@@ -79,7 +76,7 @@ class Bundler::Thor
end
def spell_checker
- @spell_checker ||= NoKwargSpellChecker.new(error.switches)
+ @spell_checker ||= DidYouMean::SpellChecker.new(dictionary: error.switches)
end
end
@@ -101,15 +98,9 @@ class Bundler::Thor
class MalformattedArgumentError < InvocationError
end
- if Correctable
- if DidYouMean.respond_to?(:correct_error)
- DidYouMean.correct_error(Bundler::Thor::UndefinedCommandError, UndefinedCommandError::SpellChecker)
- DidYouMean.correct_error(Bundler::Thor::UnknownArgumentError, UnknownArgumentError::SpellChecker)
- else
- DidYouMean::SPELL_CHECKERS.merge!(
- 'Bundler::Thor::UndefinedCommandError' => UndefinedCommandError::SpellChecker,
- 'Bundler::Thor::UnknownArgumentError' => UnknownArgumentError::SpellChecker
- )
- end
+ class ExclusiveArgumentError < InvocationError
+ end
+
+ class AtLeastOneRequiredArgumentError < InvocationError
end
end
diff --git a/lib/bundler/vendor/thor/lib/thor/group.rb b/lib/bundler/vendor/thor/lib/thor/group.rb
index 7861d05345..7ea11e8f93 100644
--- a/lib/bundler/vendor/thor/lib/thor/group.rb
+++ b/lib/bundler/vendor/thor/lib/thor/group.rb
@@ -169,7 +169,7 @@ class Bundler::Thor::Group
# options are added to group_options hash. Options that already exists
# in base_options are not added twice.
#
- def get_options_from_invocations(group_options, base_options) #:nodoc: # rubocop:disable MethodLength
+ def get_options_from_invocations(group_options, base_options) #:nodoc:
invocations.each do |name, from_option|
value = if from_option
option = class_options[name]
diff --git a/lib/bundler/vendor/thor/lib/thor/invocation.rb b/lib/bundler/vendor/thor/lib/thor/invocation.rb
index 248a466f8e..5ce74710ba 100644
--- a/lib/bundler/vendor/thor/lib/thor/invocation.rb
+++ b/lib/bundler/vendor/thor/lib/thor/invocation.rb
@@ -143,7 +143,7 @@ class Bundler::Thor
# Configuration values that are shared between invocations.
def _shared_configuration #:nodoc:
- {:invocations => @_invocations}
+ {invocations: @_invocations}
end
# This method simply retrieves the class and command to be invoked.
diff --git a/lib/bundler/vendor/thor/lib/thor/nested_context.rb b/lib/bundler/vendor/thor/lib/thor/nested_context.rb
index fd36b9d43f..7d60cb1c12 100644
--- a/lib/bundler/vendor/thor/lib/thor/nested_context.rb
+++ b/lib/bundler/vendor/thor/lib/thor/nested_context.rb
@@ -13,10 +13,10 @@ class Bundler::Thor
end
def entered?
- @depth > 0
+ @depth.positive?
end
- private
+ private
def push
@depth += 1
diff --git a/lib/bundler/vendor/thor/lib/thor/parser/argument.rb b/lib/bundler/vendor/thor/lib/thor/parser/argument.rb
index dfe7398583..b9e94e4669 100644
--- a/lib/bundler/vendor/thor/lib/thor/parser/argument.rb
+++ b/lib/bundler/vendor/thor/lib/thor/parser/argument.rb
@@ -24,6 +24,17 @@ class Bundler::Thor
validate! # Trigger specific validations
end
+ def print_default
+ if @type == :array and @default.is_a?(Array)
+ @default.map { |x|
+ p = x.gsub('"','\\"')
+ "\"#{p}\""
+ }.join(" ")
+ else
+ @default
+ end
+ end
+
def usage
required? ? banner : "[#{banner}]"
end
@@ -41,11 +52,19 @@ class Bundler::Thor
end
end
+ def enum_to_s
+ if enum.respond_to? :join
+ enum.join(", ")
+ else
+ "#{enum.first}..#{enum.last}"
+ end
+ end
+
protected
def validate!
raise ArgumentError, "An argument cannot be required and have default value." if required? && !default.nil?
- raise ArgumentError, "An argument cannot have an enum other than an array." if @enum && !@enum.is_a?(Array)
+ raise ArgumentError, "An argument cannot have an enum other than an enumerable." if @enum && !@enum.is_a?(Enumerable)
end
def valid_type?(type)
diff --git a/lib/bundler/vendor/thor/lib/thor/parser/arguments.rb b/lib/bundler/vendor/thor/lib/thor/parser/arguments.rb
index 3a5d82cf29..b6f9c9a37a 100644
--- a/lib/bundler/vendor/thor/lib/thor/parser/arguments.rb
+++ b/lib/bundler/vendor/thor/lib/thor/parser/arguments.rb
@@ -1,5 +1,5 @@
class Bundler::Thor
- class Arguments #:nodoc: # rubocop:disable ClassLength
+ class Arguments #:nodoc:
NUMERIC = /[-+]?(\d*\.\d+|\d+)/
# Receives an array of args and returns two arrays, one with arguments
@@ -30,11 +30,7 @@ class Bundler::Thor
arguments.each do |argument|
if !argument.default.nil?
- begin
- @assigns[argument.human_name] = argument.default.dup
- rescue TypeError # Compatibility shim for un-dup-able Fixnum in Ruby < 2.4
- @assigns[argument.human_name] = argument.default
- end
+ @assigns[argument.human_name] = argument.default.dup
elsif argument.required?
@non_assigned_required << argument
end
@@ -121,8 +117,18 @@ class Bundler::Thor
#
def parse_array(name)
return shift if peek.is_a?(Array)
+
array = []
- array << shift while current_is_value?
+
+ while current_is_value?
+ value = shift
+
+ if !value.empty?
+ validate_enum_value!(name, value, "Expected all values of '%s' to be one of %s; got %s")
+ end
+
+ array << value
+ end
array
end
@@ -138,11 +144,9 @@ class Bundler::Thor
end
value = $&.index(".") ? shift.to_f : shift.to_i
- if @switches.is_a?(Hash) && switch = @switches[name]
- if switch.enum && !switch.enum.include?(value)
- raise MalformattedArgumentError, "Expected '#{name}' to be one of #{switch.enum.join(', ')}; got #{value}"
- end
- end
+
+ validate_enum_value!(name, value, "Expected '%s' to be one of %s; got %s")
+
value
end
@@ -156,15 +160,27 @@ class Bundler::Thor
nil
else
value = shift
- if @switches.is_a?(Hash) && switch = @switches[name]
- if switch.enum && !switch.enum.include?(value)
- raise MalformattedArgumentError, "Expected '#{name}' to be one of #{switch.enum.join(', ')}; got #{value}"
- end
- end
+
+ validate_enum_value!(name, value, "Expected '%s' to be one of %s; got %s")
+
value
end
end
+ # Raises an error if the switch is an enum and the values aren't included on it.
+ #
+ def validate_enum_value!(name, value, message)
+ return unless @switches.is_a?(Hash)
+
+ switch = @switches[name]
+
+ return unless switch
+
+ if switch.enum && !switch.enum.include?(value)
+ raise MalformattedArgumentError, message % [name, switch.enum_to_s, value]
+ end
+ end
+
# Raises an error if @non_assigned_required array is not empty.
#
def check_requirement!
diff --git a/lib/bundler/vendor/thor/lib/thor/parser/option.rb b/lib/bundler/vendor/thor/lib/thor/parser/option.rb
index 5a5af6f888..c6af4e1e87 100644
--- a/lib/bundler/vendor/thor/lib/thor/parser/option.rb
+++ b/lib/bundler/vendor/thor/lib/thor/parser/option.rb
@@ -11,7 +11,7 @@ class Bundler::Thor
super
@lazy_default = options[:lazy_default]
@group = options[:group].to_s.capitalize if options[:group]
- @aliases = Array(options[:aliases])
+ @aliases = normalize_aliases(options[:aliases])
@hide = options[:hide]
end
@@ -58,7 +58,7 @@ class Bundler::Thor
default = nil
if VALID_TYPES.include?(value)
value
- elsif required = (value == :required) # rubocop:disable AssignmentInCondition
+ elsif required = (value == :required) # rubocop:disable Lint/AssignmentInCondition
:string
end
when TrueClass, FalseClass
@@ -69,7 +69,7 @@ class Bundler::Thor
value.class.name.downcase.to_sym
end
- new(name.to_s, :required => required, :type => type, :default => default, :aliases => aliases)
+ new(name.to_s, required: required, type: type, default: default, aliases: aliases)
end
def switch_name
@@ -90,13 +90,26 @@ class Bundler::Thor
sample = "[#{sample}]".dup unless required?
if boolean?
- sample << ", [#{dasherize('no-' + human_name)}]" unless (name == "force") || name.start_with?("no-")
+ sample << ", [#{dasherize('no-' + human_name)}]" unless (name == "force") || name.match(/\Ano[\-_]/)
end
+ aliases_for_usage.ljust(padding) + sample
+ end
+
+ def aliases_for_usage
if aliases.empty?
- (" " * padding) << sample
+ ""
+ else
+ "#{aliases.join(', ')}, "
+ end
+ end
+
+ def show_default?
+ case default
+ when TrueClass, FalseClass
+ true
else
- "#{aliases.join(', ')}, #{sample}"
+ super
end
end
@@ -138,8 +151,8 @@ class Bundler::Thor
raise ArgumentError, err
elsif @check_default_type == nil
Bundler::Thor.deprecation_warning "#{err}.\n" +
- 'This will be rejected in the future unless you explicitly pass the options `check_default_type: false`' +
- ' or call `allow_incompatible_default_type!` in your code'
+ "This will be rejected in the future unless you explicitly pass the options `check_default_type: false`" +
+ " or call `allow_incompatible_default_type!` in your code"
end
end
end
@@ -155,5 +168,11 @@ class Bundler::Thor
def dasherize(str)
(str.length > 1 ? "--" : "-") + str.tr("_", "-")
end
+
+ private
+
+ def normalize_aliases(aliases)
+ Array(aliases).map { |short| short.to_s.sub(/^(?!\-)/, "-") }
+ end
end
end
diff --git a/lib/bundler/vendor/thor/lib/thor/parser/options.rb b/lib/bundler/vendor/thor/lib/thor/parser/options.rb
index 5bd97aba6f..978e76b132 100644
--- a/lib/bundler/vendor/thor/lib/thor/parser/options.rb
+++ b/lib/bundler/vendor/thor/lib/thor/parser/options.rb
@@ -1,5 +1,5 @@
class Bundler::Thor
- class Options < Arguments #:nodoc: # rubocop:disable ClassLength
+ class Options < Arguments #:nodoc:
LONG_RE = /^(--\w+(?:-\w+)*)$/
SHORT_RE = /^(-[a-z])$/i
EQ_RE = /^(--\w+(?:-\w+)*|-[a-z])=(.*)$/i
@@ -29,8 +29,10 @@ class Bundler::Thor
#
# If +stop_on_unknown+ is true, #parse will stop as soon as it encounters
# an unknown option or a regular argument.
- def initialize(hash_options = {}, defaults = {}, stop_on_unknown = false, disable_required_check = false)
+ def initialize(hash_options = {}, defaults = {}, stop_on_unknown = false, disable_required_check = false, relations = {})
@stop_on_unknown = stop_on_unknown
+ @exclusives = (relations[:exclusive_option_names] || []).select{|array| !array.empty?}
+ @at_least_ones = (relations[:at_least_one_option_names] || []).select{|array| !array.empty?}
@disable_required_check = disable_required_check
options = hash_options.values
super(options)
@@ -50,8 +52,7 @@ class Bundler::Thor
options.each do |option|
@switches[option.switch_name] = option
- option.aliases.each do |short|
- name = short.to_s.sub(/^(?!\-)/, "-")
+ option.aliases.each do |name|
@shorts[name] ||= option.switch_name
end
end
@@ -85,7 +86,7 @@ class Bundler::Thor
super(arg)
end
- def parse(args) # rubocop:disable MethodLength
+ def parse(args) # rubocop:disable Metrics/MethodLength
@pile = args.dup
@is_treated_as_value = false
@parsing_options = true
@@ -132,12 +133,38 @@ class Bundler::Thor
end
check_requirement! unless @disable_required_check
+ check_exclusive!
+ check_at_least_one!
assigns = Bundler::Thor::CoreExt::HashWithIndifferentAccess.new(@assigns)
assigns.freeze
assigns
end
+ def check_exclusive!
+ opts = @assigns.keys
+ # When option A and B are exclusive, if A and B are given at the same time,
+ # the diffrence of argument array size will decrease.
+ found = @exclusives.find{ |ex| (ex - opts).size < ex.size - 1 }
+ if found
+ names = names_to_switch_names(found & opts).map{|n| "'#{n}'"}
+ class_name = self.class.name.split("::").last.downcase
+ fail ExclusiveArgumentError, "Found exclusive #{class_name} #{names.join(", ")}"
+ end
+ end
+
+ def check_at_least_one!
+ opts = @assigns.keys
+ # When at least one is required of the options A and B,
+ # if the both options were not given, none? would be true.
+ found = @at_least_ones.find{ |one_reqs| one_reqs.none?{ |o| opts.include? o} }
+ if found
+ names = names_to_switch_names(found).map{|n| "'#{n}'"}
+ class_name = self.class.name.split("::").last.downcase
+ fail AtLeastOneRequiredArgumentError, "Not found at least one of required #{class_name} #{names.join(", ")}"
+ end
+ end
+
def check_unknown!
to_check = @stopped_parsing_after_extra_index ? @extra[0...@stopped_parsing_after_extra_index] : @extra
@@ -148,6 +175,17 @@ class Bundler::Thor
protected
+ # Option names changes to swith name or human name
+ def names_to_switch_names(names = [])
+ @switches.map do |_, o|
+ if names.include? o.name
+ o.respond_to?(:switch_name) ? o.switch_name : o.human_name
+ else
+ nil
+ end
+ end.compact
+ end
+
def assign_result!(option, result)
if option.repeatable && option.type == :hash
(@assigns[option.human_name] ||= {}).merge!(result)
@@ -194,7 +232,7 @@ class Bundler::Thor
end
def switch_option(arg)
- if match = no_or_skip?(arg) # rubocop:disable AssignmentInCondition
+ if match = no_or_skip?(arg) # rubocop:disable Lint/AssignmentInCondition
@switches[arg] || @switches["--#{match}"]
else
@switches[arg]
diff --git a/lib/bundler/vendor/thor/lib/thor/rake_compat.rb b/lib/bundler/vendor/thor/lib/thor/rake_compat.rb
index f8f86372cc..c6a4653fc1 100644
--- a/lib/bundler/vendor/thor/lib/thor/rake_compat.rb
+++ b/lib/bundler/vendor/thor/lib/thor/rake_compat.rb
@@ -41,7 +41,7 @@ instance_eval do
def task(*)
task = super
- if klass = Bundler::Thor::RakeCompat.rake_classes.last # rubocop:disable AssignmentInCondition
+ if klass = Bundler::Thor::RakeCompat.rake_classes.last # rubocop:disable Lint/AssignmentInCondition
non_namespaced_name = task.name.split(":").last
description = non_namespaced_name
@@ -59,7 +59,7 @@ instance_eval do
end
def namespace(name)
- if klass = Bundler::Thor::RakeCompat.rake_classes.last # rubocop:disable AssignmentInCondition
+ if klass = Bundler::Thor::RakeCompat.rake_classes.last # rubocop:disable Lint/AssignmentInCondition
const_name = Bundler::Thor::Util.camel_case(name.to_s).to_sym
klass.const_set(const_name, Class.new(Bundler::Thor))
new_klass = klass.const_get(const_name)
diff --git a/lib/bundler/vendor/thor/lib/thor/runner.rb b/lib/bundler/vendor/thor/lib/thor/runner.rb
index 54c5525093..c7cc873131 100644
--- a/lib/bundler/vendor/thor/lib/thor/runner.rb
+++ b/lib/bundler/vendor/thor/lib/thor/runner.rb
@@ -2,12 +2,10 @@ require_relative "../thor"
require_relative "group"
require "yaml"
-require "digest/md5"
+require "digest/sha2"
require "pathname"
-class Bundler::Thor::Runner < Bundler::Thor #:nodoc: # rubocop:disable ClassLength
- autoload :OpenURI, "open-uri"
-
+class Bundler::Thor::Runner < Bundler::Thor #:nodoc:
map "-T" => :list, "-i" => :install, "-u" => :update, "-v" => :version
def self.banner(command, all = false, subcommand = false)
@@ -25,7 +23,7 @@ class Bundler::Thor::Runner < Bundler::Thor #:nodoc: # rubocop:disable ClassLeng
initialize_thorfiles(meth)
klass, command = Bundler::Thor::Util.find_class_and_command_by_namespace(meth)
self.class.handle_no_command_error(command, false) if klass.nil?
- klass.start(["-h", command].compact, :shell => shell)
+ klass.start(["-h", command].compact, shell: shell)
else
super
end
@@ -40,30 +38,42 @@ class Bundler::Thor::Runner < Bundler::Thor #:nodoc: # rubocop:disable ClassLeng
klass, command = Bundler::Thor::Util.find_class_and_command_by_namespace(meth)
self.class.handle_no_command_error(command, false) if klass.nil?
args.unshift(command) if command
- klass.start(args, :shell => shell)
+ klass.start(args, shell: shell)
end
desc "install NAME", "Install an optionally named Bundler::Thor file into your system commands"
- method_options :as => :string, :relative => :boolean, :force => :boolean
- def install(name) # rubocop:disable MethodLength
+ method_options as: :string, relative: :boolean, force: :boolean
+ def install(name) # rubocop:disable Metrics/MethodLength
initialize_thorfiles
- # If a directory name is provided as the argument, look for a 'main.thor'
- # command in said directory.
- begin
- if File.directory?(File.expand_path(name))
- base = File.join(name, "main.thor")
- package = :directory
- contents = open(base, &:read)
- else
- base = name
- package = :file
- contents = open(name, &:read)
+ is_uri = name =~ %r{^https?\://}
+
+ if is_uri
+ base = name
+ package = :file
+ require "open-uri"
+ begin
+ contents = URI.open(name, &:read)
+ rescue OpenURI::HTTPError
+ raise Error, "Error opening URI '#{name}'"
+ end
+ else
+ # If a directory name is provided as the argument, look for a 'main.thor'
+ # command in said directory.
+ begin
+ if File.directory?(File.expand_path(name))
+ base = File.join(name, "main.thor")
+ package = :directory
+ contents = File.open(base, &:read)
+ else
+ base = name
+ package = :file
+ require "open-uri"
+ contents = URI.open(name, &:read)
+ end
+ rescue Errno::ENOENT
+ raise Error, "Error opening file '#{name}'"
end
- rescue OpenURI::HTTPError
- raise Error, "Error opening URI '#{name}'"
- rescue Errno::ENOENT
- raise Error, "Error opening file '#{name}'"
end
say "Your Thorfile contains:"
@@ -84,16 +94,16 @@ class Bundler::Thor::Runner < Bundler::Thor #:nodoc: # rubocop:disable ClassLeng
as = basename if as.empty?
end
- location = if options[:relative] || name =~ %r{^https?://}
+ location = if options[:relative] || is_uri
name
else
File.expand_path(name)
end
thor_yaml[as] = {
- :filename => Digest::MD5.hexdigest(name + as),
- :location => location,
- :namespaces => Bundler::Thor::Util.namespaces_in_content(contents, base)
+ filename: Digest::SHA256.hexdigest(name + as),
+ location: location,
+ namespaces: Bundler::Thor::Util.namespaces_in_content(contents, base)
}
save_yaml(thor_yaml)
@@ -154,14 +164,14 @@ class Bundler::Thor::Runner < Bundler::Thor #:nodoc: # rubocop:disable ClassLeng
end
desc "installed", "List the installed Bundler::Thor modules and commands"
- method_options :internal => :boolean
+ method_options internal: :boolean
def installed
initialize_thorfiles(nil, true)
display_klasses(true, options["internal"])
end
desc "list [SEARCH]", "List the available thor commands (--substring means .*SEARCH)"
- method_options :substring => :boolean, :group => :string, :all => :boolean, :debug => :boolean
+ method_options substring: :boolean, group: :string, all: :boolean, debug: :boolean
def list(search = "")
initialize_thorfiles
@@ -303,7 +313,7 @@ private
say shell.set_color(namespace, :blue, true)
say "-" * namespace.size
- print_table(list, :truncate => true)
+ print_table(list, truncate: true)
say
end
alias_method :display_tasks, :display_commands
diff --git a/lib/bundler/vendor/thor/lib/thor/shell.rb b/lib/bundler/vendor/thor/lib/thor/shell.rb
index a4137d1bde..265f3ba046 100644
--- a/lib/bundler/vendor/thor/lib/thor/shell.rb
+++ b/lib/bundler/vendor/thor/lib/thor/shell.rb
@@ -75,7 +75,7 @@ class Bundler::Thor
# Allow shell to be shared between invocations.
#
def _shared_configuration #:nodoc:
- super.merge!(:shell => shell)
+ super.merge!(shell: shell)
end
end
end
diff --git a/lib/bundler/vendor/thor/lib/thor/shell/basic.rb b/lib/bundler/vendor/thor/lib/thor/shell/basic.rb
index ef97d52ae7..dc3179e5f3 100644
--- a/lib/bundler/vendor/thor/lib/thor/shell/basic.rb
+++ b/lib/bundler/vendor/thor/lib/thor/shell/basic.rb
@@ -1,8 +1,10 @@
+require_relative "column_printer"
+require_relative "table_printer"
+require_relative "wrapped_printer"
+
class Bundler::Thor
module Shell
class Basic
- DEFAULT_TERMINAL_WIDTH = 80
-
attr_accessor :base
attr_reader :padding
@@ -145,14 +147,14 @@ class Bundler::Thor
# "yes".
#
def yes?(statement, color = nil)
- !!(ask(statement, color, :add_to_history => false) =~ is?(:yes))
+ !!(ask(statement, color, add_to_history: false) =~ is?(:yes))
end
# Make a question the to user and returns true if the user replies "n" or
# "no".
#
def no?(statement, color = nil)
- !!(ask(statement, color, :add_to_history => false) =~ is?(:no))
+ !!(ask(statement, color, add_to_history: false) =~ is?(:no))
end
# Prints values in columns
@@ -161,16 +163,8 @@ class Bundler::Thor
# Array[String, String, ...]
#
def print_in_columns(array)
- return if array.empty?
- colwidth = (array.map { |el| el.to_s.size }.max || 0) + 2
- array.each_with_index do |value, index|
- # Don't output trailing spaces when printing the last column
- if ((((index + 1) % (terminal_width / colwidth))).zero? && !index.zero?) || index + 1 == array.length
- stdout.puts value
- else
- stdout.printf("%-#{colwidth}s", value)
- end
- end
+ printer = ColumnPrinter.new(stdout)
+ printer.print(array)
end
# Prints a table.
@@ -181,58 +175,11 @@ class Bundler::Thor
# ==== Options
# indent<Integer>:: Indent the first column by indent value.
# colwidth<Integer>:: Force the first column to colwidth spaces wide.
+ # borders<Boolean>:: Adds ascii borders.
#
- def print_table(array, options = {}) # rubocop:disable MethodLength
- return if array.empty?
-
- formats = []
- indent = options[:indent].to_i
- colwidth = options[:colwidth]
- options[:truncate] = terminal_width if options[:truncate] == true
-
- formats << "%-#{colwidth + 2}s".dup if colwidth
- start = colwidth ? 1 : 0
-
- colcount = array.max { |a, b| a.size <=> b.size }.size
-
- maximas = []
-
- start.upto(colcount - 1) do |index|
- maxima = array.map { |row| row[index] ? row[index].to_s.size : 0 }.max
- maximas << maxima
- formats << if index == colcount - 1
- # Don't output 2 trailing spaces when printing the last column
- "%-s".dup
- else
- "%-#{maxima + 2}s".dup
- end
- end
-
- formats[0] = formats[0].insert(0, " " * indent)
- formats << "%s"
-
- array.each do |row|
- sentence = "".dup
-
- row.each_with_index do |column, index|
- maxima = maximas[index]
-
- f = if column.is_a?(Numeric)
- if index == row.size - 1
- # Don't output 2 trailing spaces when printing the last column
- "%#{maxima}s"
- else
- "%#{maxima}s "
- end
- else
- formats[index]
- end
- sentence << f % column.to_s
- end
-
- sentence = truncate(sentence, options[:truncate]) if options[:truncate]
- stdout.puts sentence
- end
+ def print_table(array, options = {}) # rubocop:disable Metrics/MethodLength
+ printer = TablePrinter.new(stdout, options)
+ printer.print(array)
end
# Prints a long string, word-wrapping the text to the current width of the
@@ -245,33 +192,8 @@ class Bundler::Thor
# indent<Integer>:: Indent each line of the printed paragraph by indent value.
#
def print_wrapped(message, options = {})
- indent = options[:indent] || 0
- width = terminal_width - indent
- paras = message.split("\n\n")
-
- paras.map! do |unwrapped|
- words = unwrapped.split(" ")
- counter = words.first.length
- words.inject do |memo, word|
- word = word.gsub(/\n\005/, "\n").gsub(/\005/, "\n")
- counter = 0 if word.include? "\n"
- if (counter + word.length + 1) < width
- memo = "#{memo} #{word}"
- counter += (word.length + 1)
- else
- memo = "#{memo}\n#{word}"
- counter = word.length
- end
- memo
- end
- end.compact!
-
- paras.each do |para|
- para.split("\n").each do |line|
- stdout.puts line.insert(0, " " * indent)
- end
- stdout.puts unless para == paras.last
- end
+ printer = WrappedPrinter.new(stdout, options)
+ printer.print(message)
end
# Deals with file collision and returns true if the file should be
@@ -289,7 +211,7 @@ class Bundler::Thor
loop do
answer = ask(
%[Overwrite #{destination}? (enter "h" for help) #{options}],
- :add_to_history => false
+ add_to_history: false
)
case answer
@@ -316,24 +238,11 @@ class Bundler::Thor
say "Please specify merge tool to `THOR_MERGE` env."
else
- say file_collision_help
+ say file_collision_help(block_given?)
end
end
end
- # This code was copied from Rake, available under MIT-LICENSE
- # Copyright (c) 2003, 2004 Jim Weirich
- def terminal_width
- result = if ENV["THOR_COLUMNS"]
- ENV["THOR_COLUMNS"].to_i
- else
- unix? ? dynamic_width : DEFAULT_TERMINAL_WIDTH
- end
- result < 10 ? DEFAULT_TERMINAL_WIDTH : result
- rescue
- DEFAULT_TERMINAL_WIDTH
- end
-
# Called if something goes wrong during the execution. This is used by Bundler::Thor
# internally and should not be used inside your scripts. If something went
# wrong, you can always raise an exception. If you raise a Bundler::Thor::Error, it
@@ -384,16 +293,21 @@ class Bundler::Thor
end
end
- def file_collision_help #:nodoc:
- <<-HELP
+ def file_collision_help(block_given) #:nodoc:
+ help = <<-HELP
Y - yes, overwrite
n - no, do not overwrite
a - all, overwrite this and all others
q - quit, abort
- d - diff, show the differences between the old and the new
h - help, show this help
- m - merge, run merge tool
HELP
+ if block_given
+ help << <<-HELP
+ d - diff, show the differences between the old and the new
+ m - merge, run merge tool
+ HELP
+ end
+ help
end
def show_diff(destination, content) #:nodoc:
@@ -411,46 +325,8 @@ class Bundler::Thor
mute? || (base && base.options[:quiet])
end
- # Calculate the dynamic width of the terminal
- def dynamic_width
- @dynamic_width ||= (dynamic_width_stty.nonzero? || dynamic_width_tput)
- end
-
- def dynamic_width_stty
- `stty size 2>/dev/null`.split[1].to_i
- end
-
- def dynamic_width_tput
- `tput cols 2>/dev/null`.to_i
- end
-
def unix?
- RUBY_PLATFORM =~ /(aix|darwin|linux|(net|free|open)bsd|cygwin|solaris)/i
- end
-
- def truncate(string, width)
- as_unicode do
- chars = string.chars.to_a
- if chars.length <= width
- chars.join
- else
- chars[0, width - 3].join + "..."
- end
- end
- end
-
- if "".respond_to?(:encode)
- def as_unicode
- yield
- end
- else
- def as_unicode
- old = $KCODE
- $KCODE = "U"
- yield
- ensure
- $KCODE = old
- end
+ Terminal.unix?
end
def ask_simply(statement, color, options)
diff --git a/lib/bundler/vendor/thor/lib/thor/shell/color.rb b/lib/bundler/vendor/thor/lib/thor/shell/color.rb
index dc167ed3cc..5d708fadca 100644
--- a/lib/bundler/vendor/thor/lib/thor/shell/color.rb
+++ b/lib/bundler/vendor/thor/lib/thor/shell/color.rb
@@ -105,52 +105,7 @@ class Bundler::Thor
end
def are_colors_disabled?
- !ENV['NO_COLOR'].nil?
- end
-
- # Overwrite show_diff to show diff with colors if Diff::LCS is
- # available.
- #
- def show_diff(destination, content) #:nodoc:
- if diff_lcs_loaded? && ENV["THOR_DIFF"].nil? && ENV["RAILS_DIFF"].nil?
- actual = File.binread(destination).to_s.split("\n")
- content = content.to_s.split("\n")
-
- Diff::LCS.sdiff(actual, content).each do |diff|
- output_diff_line(diff)
- end
- else
- super
- end
- end
-
- def output_diff_line(diff) #:nodoc:
- case diff.action
- when "-"
- say "- #{diff.old_element.chomp}", :red, true
- when "+"
- say "+ #{diff.new_element.chomp}", :green, true
- when "!"
- say "- #{diff.old_element.chomp}", :red, true
- say "+ #{diff.new_element.chomp}", :green, true
- else
- say " #{diff.old_element.chomp}", nil, true
- end
- end
-
- # Check if Diff::LCS is loaded. If it is, use it to create pretty output
- # for diff.
- #
- def diff_lcs_loaded? #:nodoc:
- return true if defined?(Diff::LCS)
- return @diff_lcs_loaded unless @diff_lcs_loaded.nil?
-
- @diff_lcs_loaded = begin
- require "diff/lcs"
- true
- rescue LoadError
- false
- end
+ !ENV["NO_COLOR"].nil? && !ENV["NO_COLOR"].empty?
end
end
end
diff --git a/lib/bundler/vendor/thor/lib/thor/shell/column_printer.rb b/lib/bundler/vendor/thor/lib/thor/shell/column_printer.rb
new file mode 100644
index 0000000000..56a9e6181b
--- /dev/null
+++ b/lib/bundler/vendor/thor/lib/thor/shell/column_printer.rb
@@ -0,0 +1,29 @@
+require_relative "terminal"
+
+class Bundler::Thor
+ module Shell
+ class ColumnPrinter
+ attr_reader :stdout, :options
+
+ def initialize(stdout, options = {})
+ @stdout = stdout
+ @options = options
+ @indent = options[:indent].to_i
+ end
+
+ def print(array)
+ return if array.empty?
+ colwidth = (array.map { |el| el.to_s.size }.max || 0) + 2
+ array.each_with_index do |value, index|
+ # Don't output trailing spaces when printing the last column
+ if ((((index + 1) % (Terminal.terminal_width / colwidth))).zero? && !index.zero?) || index + 1 == array.length
+ stdout.puts value
+ else
+ stdout.printf("%-#{colwidth}s", value)
+ end
+ end
+ end
+ end
+ end
+end
+
diff --git a/lib/bundler/vendor/thor/lib/thor/shell/html.rb b/lib/bundler/vendor/thor/lib/thor/shell/html.rb
index 77a6d13a23..0277b882b7 100644
--- a/lib/bundler/vendor/thor/lib/thor/shell/html.rb
+++ b/lib/bundler/vendor/thor/lib/thor/shell/html.rb
@@ -76,51 +76,6 @@ class Bundler::Thor
def can_display_colors?
true
end
-
- # Overwrite show_diff to show diff with colors if Diff::LCS is
- # available.
- #
- def show_diff(destination, content) #:nodoc:
- if diff_lcs_loaded? && ENV["THOR_DIFF"].nil? && ENV["RAILS_DIFF"].nil?
- actual = File.binread(destination).to_s.split("\n")
- content = content.to_s.split("\n")
-
- Diff::LCS.sdiff(actual, content).each do |diff|
- output_diff_line(diff)
- end
- else
- super
- end
- end
-
- def output_diff_line(diff) #:nodoc:
- case diff.action
- when "-"
- say "- #{diff.old_element.chomp}", :red, true
- when "+"
- say "+ #{diff.new_element.chomp}", :green, true
- when "!"
- say "- #{diff.old_element.chomp}", :red, true
- say "+ #{diff.new_element.chomp}", :green, true
- else
- say " #{diff.old_element.chomp}", nil, true
- end
- end
-
- # Check if Diff::LCS is loaded. If it is, use it to create pretty output
- # for diff.
- #
- def diff_lcs_loaded? #:nodoc:
- return true if defined?(Diff::LCS)
- return @diff_lcs_loaded unless @diff_lcs_loaded.nil?
-
- @diff_lcs_loaded = begin
- require "diff/lcs"
- true
- rescue LoadError
- false
- end
- end
end
end
end
diff --git a/lib/bundler/vendor/thor/lib/thor/shell/table_printer.rb b/lib/bundler/vendor/thor/lib/thor/shell/table_printer.rb
new file mode 100644
index 0000000000..525f9ce5bb
--- /dev/null
+++ b/lib/bundler/vendor/thor/lib/thor/shell/table_printer.rb
@@ -0,0 +1,134 @@
+require_relative "column_printer"
+require_relative "terminal"
+
+class Bundler::Thor
+ module Shell
+ class TablePrinter < ColumnPrinter
+ BORDER_SEPARATOR = :separator
+
+ def initialize(stdout, options = {})
+ super
+ @formats = []
+ @maximas = []
+ @colwidth = options[:colwidth]
+ @truncate = options[:truncate] == true ? Terminal.terminal_width : options[:truncate]
+ @padding = 1
+ end
+
+ def print(array)
+ return if array.empty?
+
+ prepare(array)
+
+ print_border_separator if options[:borders]
+
+ array.each do |row|
+ if options[:borders] && row == BORDER_SEPARATOR
+ print_border_separator
+ next
+ end
+
+ sentence = "".dup
+
+ row.each_with_index do |column, index|
+ sentence << format_cell(column, row.size, index)
+ end
+
+ sentence = truncate(sentence)
+ sentence << "|" if options[:borders]
+ stdout.puts indentation + sentence
+
+ end
+ print_border_separator if options[:borders]
+ end
+
+ private
+
+ def prepare(array)
+ array = array.reject{|row| row == BORDER_SEPARATOR }
+
+ @formats << "%-#{@colwidth + 2}s".dup if @colwidth
+ start = @colwidth ? 1 : 0
+
+ colcount = array.max { |a, b| a.size <=> b.size }.size
+
+ start.upto(colcount - 1) do |index|
+ maxima = array.map { |row| row[index] ? row[index].to_s.size : 0 }.max
+
+ @maximas << maxima
+ @formats << if options[:borders]
+ "%-#{maxima}s".dup
+ elsif index == colcount - 1
+ # Don't output 2 trailing spaces when printing the last column
+ "%-s".dup
+ else
+ "%-#{maxima + 2}s".dup
+ end
+ end
+
+ @formats << "%s"
+ end
+
+ def format_cell(column, row_size, index)
+ maxima = @maximas[index]
+
+ f = if column.is_a?(Numeric)
+ if options[:borders]
+ # With borders we handle padding separately
+ "%#{maxima}s"
+ elsif index == row_size - 1
+ # Don't output 2 trailing spaces when printing the last column
+ "%#{maxima}s"
+ else
+ "%#{maxima}s "
+ end
+ else
+ @formats[index]
+ end
+
+ cell = "".dup
+ cell << "|" + " " * @padding if options[:borders]
+ cell << f % column.to_s
+ cell << " " * @padding if options[:borders]
+ cell
+ end
+
+ def print_border_separator
+ separator = @maximas.map do |maxima|
+ "+" + "-" * (maxima + 2 * @padding)
+ end
+ stdout.puts indentation + separator.join + "+"
+ end
+
+ def truncate(string)
+ return string unless @truncate
+ as_unicode do
+ chars = string.chars.to_a
+ if chars.length <= @truncate
+ chars.join
+ else
+ chars[0, @truncate - 3 - @indent].join + "..."
+ end
+ end
+ end
+
+ def indentation
+ " " * @indent
+ end
+
+ if "".respond_to?(:encode)
+ def as_unicode
+ yield
+ end
+ else
+ def as_unicode
+ old = $KCODE # rubocop:disable Style/GlobalVars
+ $KCODE = "U" # rubocop:disable Style/GlobalVars
+ yield
+ ensure
+ $KCODE = old # rubocop:disable Style/GlobalVars
+ end
+ end
+ end
+ end
+end
diff --git a/lib/bundler/vendor/thor/lib/thor/shell/terminal.rb b/lib/bundler/vendor/thor/lib/thor/shell/terminal.rb
new file mode 100644
index 0000000000..2c60684308
--- /dev/null
+++ b/lib/bundler/vendor/thor/lib/thor/shell/terminal.rb
@@ -0,0 +1,42 @@
+class Bundler::Thor
+ module Shell
+ module Terminal
+ DEFAULT_TERMINAL_WIDTH = 80
+
+ class << self
+ # This code was copied from Rake, available under MIT-LICENSE
+ # Copyright (c) 2003, 2004 Jim Weirich
+ def terminal_width
+ result = if ENV["THOR_COLUMNS"]
+ ENV["THOR_COLUMNS"].to_i
+ else
+ unix? ? dynamic_width : DEFAULT_TERMINAL_WIDTH
+ end
+ result < 10 ? DEFAULT_TERMINAL_WIDTH : result
+ rescue
+ DEFAULT_TERMINAL_WIDTH
+ end
+
+ def unix?
+ RUBY_PLATFORM =~ /(aix|darwin|linux|(net|free|open)bsd|cygwin|solaris)/i
+ end
+
+ private
+
+ # Calculate the dynamic width of the terminal
+ def dynamic_width
+ @dynamic_width ||= (dynamic_width_stty.nonzero? || dynamic_width_tput)
+ end
+
+ def dynamic_width_stty
+ `stty size 2>/dev/null`.split[1].to_i
+ end
+
+ def dynamic_width_tput
+ `tput cols 2>/dev/null`.to_i
+ end
+
+ end
+ end
+ end
+end
diff --git a/lib/bundler/vendor/thor/lib/thor/shell/wrapped_printer.rb b/lib/bundler/vendor/thor/lib/thor/shell/wrapped_printer.rb
new file mode 100644
index 0000000000..ba88e952db
--- /dev/null
+++ b/lib/bundler/vendor/thor/lib/thor/shell/wrapped_printer.rb
@@ -0,0 +1,38 @@
+require_relative "column_printer"
+require_relative "terminal"
+
+class Bundler::Thor
+ module Shell
+ class WrappedPrinter < ColumnPrinter
+ def print(message)
+ width = Terminal.terminal_width - @indent
+ paras = message.split("\n\n")
+
+ paras.map! do |unwrapped|
+ words = unwrapped.split(" ")
+ counter = words.first.length
+ words.inject do |memo, word|
+ word = word.gsub(/\n\005/, "\n").gsub(/\005/, "\n")
+ counter = 0 if word.include? "\n"
+ if (counter + word.length + 1) < width
+ memo = "#{memo} #{word}"
+ counter += (word.length + 1)
+ else
+ memo = "#{memo}\n#{word}"
+ counter = word.length
+ end
+ memo
+ end
+ end.compact!
+
+ paras.each do |para|
+ para.split("\n").each do |line|
+ stdout.puts line.insert(0, " " * @indent)
+ end
+ stdout.puts unless para == paras.last
+ end
+ end
+ end
+ end
+end
+
diff --git a/lib/bundler/vendor/thor/lib/thor/util.rb b/lib/bundler/vendor/thor/lib/thor/util.rb
index d2572a4249..68916daf2e 100644
--- a/lib/bundler/vendor/thor/lib/thor/util.rb
+++ b/lib/bundler/vendor/thor/lib/thor/util.rb
@@ -90,7 +90,7 @@ class Bundler::Thor
def snake_case(str)
return str.downcase if str =~ /^[A-Z_]+$/
str.gsub(/\B[A-Z]/, '_\&').squeeze("_") =~ /_*(.*)/
- $+.downcase
+ Regexp.last_match(-1).downcase
end
# Receives a string and convert it to camel case. camel_case returns CamelCase.
@@ -130,9 +130,10 @@ class Bundler::Thor
#
def find_class_and_command_by_namespace(namespace, fallback = true)
if namespace.include?(":") # look for a namespaced command
- pieces = namespace.split(":")
- command = pieces.pop
- klass = Bundler::Thor::Util.find_by_namespace(pieces.join(":"))
+ *pieces, command = namespace.split(":")
+ namespace = pieces.join(":")
+ namespace = "default" if namespace.empty?
+ klass = Bundler::Thor::Base.subclasses.detect { |thor| thor.namespace == namespace && thor.commands.keys.include?(command) }
end
unless klass # look for a Bundler::Thor::Group with the right name
klass = Bundler::Thor::Util.find_by_namespace(namespace)
@@ -150,7 +151,7 @@ class Bundler::Thor
# inside the sandbox to avoid namespacing conflicts.
#
def load_thorfile(path, content = nil, debug = false)
- content ||= File.binread(path)
+ content ||= File.read(path)
begin
Bundler::Thor::Sandbox.class_eval(content, path)
@@ -189,7 +190,7 @@ class Bundler::Thor
# Returns the root where thor files are located, depending on the OS.
#
def thor_root
- File.join(user_home, ".thor").tr('\\', "/")
+ File.join(user_home, ".thor").tr("\\", "/")
end
# Returns the files in the thor root. On Windows thor_root will be something
@@ -236,7 +237,7 @@ class Bundler::Thor
# symlink points to 'ruby_install_name'
ruby = alternate_ruby if linked_ruby == ruby_name || linked_ruby == ruby
end
- rescue NotImplementedError # rubocop:disable HandleExceptions
+ rescue NotImplementedError # rubocop:disable Lint/HandleExceptions
# just ignore on windows
end
end
diff --git a/lib/bundler/vendor/thor/lib/thor/version.rb b/lib/bundler/vendor/thor/lib/thor/version.rb
index 48a4788b3b..1fb00017ed 100644
--- a/lib/bundler/vendor/thor/lib/thor/version.rb
+++ b/lib/bundler/vendor/thor/lib/thor/version.rb
@@ -1,3 +1,3 @@
class Bundler::Thor
- VERSION = "1.2.1"
+ VERSION = "1.3.0"
end
diff --git a/lib/bundler/vendor/tsort/.document b/lib/bundler/vendor/tsort/.document
new file mode 100644
index 0000000000..0c43bbd6b3
--- /dev/null
+++ b/lib/bundler/vendor/tsort/.document
@@ -0,0 +1 @@
+# Vendored files do not need to be documented
diff --git a/lib/bundler/vendor/tsort/lib/tsort.rb b/lib/bundler/vendor/tsort/lib/tsort.rb
index 4a0e1a4e25..cf8731f760 100644
--- a/lib/bundler/vendor/tsort/lib/tsort.rb
+++ b/lib/bundler/vendor/tsort/lib/tsort.rb
@@ -122,6 +122,9 @@
#
module Bundler::TSort
+
+ VERSION = "0.2.0"
+
class Cyclic < StandardError
end
diff --git a/lib/bundler/vendor/uri/.document b/lib/bundler/vendor/uri/.document
new file mode 100644
index 0000000000..0c43bbd6b3
--- /dev/null
+++ b/lib/bundler/vendor/uri/.document
@@ -0,0 +1 @@
+# Vendored files do not need to be documented
diff --git a/lib/bundler/vendor/uri/lib/uri/common.rb b/lib/bundler/vendor/uri/lib/uri/common.rb
index 914a4c7581..93f4f226ad 100644
--- a/lib/bundler/vendor/uri/lib/uri/common.rb
+++ b/lib/bundler/vendor/uri/lib/uri/common.rb
@@ -68,16 +68,32 @@ module Bundler::URI
end
private_constant :Schemes
+ # Registers the given +klass+ as the class to be instantiated
+ # when parsing a \Bundler::URI with the given +scheme+:
#
- # Register the given +klass+ to be instantiated when parsing URLs with the given +scheme+.
- # Note that currently only schemes which after .upcase are valid constant names
- # can be registered (no -/+/. allowed).
+ # Bundler::URI.register_scheme('MS_SEARCH', Bundler::URI::Generic) # => Bundler::URI::Generic
+ # Bundler::URI.scheme_list['MS_SEARCH'] # => Bundler::URI::Generic
#
+ # Note that after calling String#upcase on +scheme+, it must be a valid
+ # constant name.
def self.register_scheme(scheme, klass)
Schemes.const_set(scheme.to_s.upcase, klass)
end
- # Returns a Hash of the defined schemes.
+ # Returns a hash of the defined schemes:
+ #
+ # Bundler::URI.scheme_list
+ # # =>
+ # {"MAILTO"=>Bundler::URI::MailTo,
+ # "LDAPS"=>Bundler::URI::LDAPS,
+ # "WS"=>Bundler::URI::WS,
+ # "HTTP"=>Bundler::URI::HTTP,
+ # "HTTPS"=>Bundler::URI::HTTPS,
+ # "LDAP"=>Bundler::URI::LDAP,
+ # "FILE"=>Bundler::URI::File,
+ # "FTP"=>Bundler::URI::FTP}
+ #
+ # Related: Bundler::URI.register_scheme.
def self.scheme_list
Schemes.constants.map { |name|
[name.to_s.upcase, Schemes.const_get(name)]
@@ -88,9 +104,21 @@ module Bundler::URI
private_constant :INITIAL_SCHEMES
Ractor.make_shareable(INITIAL_SCHEMES) if defined?(Ractor)
+ # Returns a new object constructed from the given +scheme+, +arguments+,
+ # and +default+:
+ #
+ # - The new object is an instance of <tt>Bundler::URI.scheme_list[scheme.upcase]</tt>.
+ # - The object is initialized by calling the class initializer
+ # using +scheme+ and +arguments+.
+ # See Bundler::URI::Generic.new.
+ #
+ # Examples:
#
- # Construct a Bundler::URI instance, using the scheme to detect the appropriate class
- # from +Bundler::URI.scheme_list+.
+ # values = ['john.doe', 'www.example.com', '123', nil, '/forum/questions/', nil, 'tag=networking&order=newest', 'top']
+ # Bundler::URI.for('https', *values)
+ # # => #<Bundler::URI::HTTPS https://john.doe@www.example.com:123/forum/questions/?tag=networking&order=newest#top>
+ # Bundler::URI.for('foo', *values, default: Bundler::URI::HTTP)
+ # # => #<Bundler::URI::HTTP foo://john.doe@www.example.com:123/forum/questions/?tag=networking&order=newest#top>
#
def self.for(scheme, *arguments, default: Generic)
const_name = scheme.to_s.upcase
@@ -121,95 +149,49 @@ module Bundler::URI
#
class BadURIError < Error; end
- #
- # == Synopsis
- #
- # Bundler::URI::split(uri)
- #
- # == Args
- #
- # +uri+::
- # String with Bundler::URI.
- #
- # == Description
- #
- # Splits the string on following parts and returns array with result:
- #
- # * Scheme
- # * Userinfo
- # * Host
- # * Port
- # * Registry
- # * Path
- # * Opaque
- # * Query
- # * Fragment
- #
- # == Usage
- #
- # require 'bundler/vendor/uri/lib/uri'
- #
- # Bundler::URI.split("http://www.ruby-lang.org/")
- # # => ["http", nil, "www.ruby-lang.org", nil, nil, "/", nil, nil, nil]
+ # Returns a 9-element array representing the parts of the \Bundler::URI
+ # formed from the string +uri+;
+ # each array element is a string or +nil+:
+ #
+ # names = %w[scheme userinfo host port registry path opaque query fragment]
+ # values = Bundler::URI.split('https://john.doe@www.example.com:123/forum/questions/?tag=networking&order=newest#top')
+ # names.zip(values)
+ # # =>
+ # [["scheme", "https"],
+ # ["userinfo", "john.doe"],
+ # ["host", "www.example.com"],
+ # ["port", "123"],
+ # ["registry", nil],
+ # ["path", "/forum/questions/"],
+ # ["opaque", nil],
+ # ["query", "tag=networking&order=newest"],
+ # ["fragment", "top"]]
#
def self.split(uri)
RFC3986_PARSER.split(uri)
end
+ # Returns a new \Bundler::URI object constructed from the given string +uri+:
#
- # == Synopsis
- #
- # Bundler::URI::parse(uri_str)
- #
- # == Args
- #
- # +uri_str+::
- # String with Bundler::URI.
- #
- # == Description
- #
- # Creates one of the Bundler::URI's subclasses instance from the string.
- #
- # == Raises
- #
- # Bundler::URI::InvalidURIError::
- # Raised if Bundler::URI given is not a correct one.
+ # Bundler::URI.parse('https://john.doe@www.example.com:123/forum/questions/?tag=networking&order=newest#top')
+ # # => #<Bundler::URI::HTTPS https://john.doe@www.example.com:123/forum/questions/?tag=networking&order=newest#top>
+ # Bundler::URI.parse('http://john.doe@www.example.com:123/forum/questions/?tag=networking&order=newest#top')
+ # # => #<Bundler::URI::HTTP http://john.doe@www.example.com:123/forum/questions/?tag=networking&order=newest#top>
#
- # == Usage
- #
- # require 'bundler/vendor/uri/lib/uri'
- #
- # uri = Bundler::URI.parse("http://www.ruby-lang.org/")
- # # => #<Bundler::URI::HTTP http://www.ruby-lang.org/>
- # uri.scheme
- # # => "http"
- # uri.host
- # # => "www.ruby-lang.org"
- #
- # It's recommended to first ::escape the provided +uri_str+ if there are any
- # invalid Bundler::URI characters.
+ # It's recommended to first ::escape string +uri+
+ # if it may contain invalid Bundler::URI characters.
#
def self.parse(uri)
RFC3986_PARSER.parse(uri)
end
+ # Merges the given Bundler::URI strings +str+
+ # per {RFC 2396}[https://www.rfc-editor.org/rfc/rfc2396.html].
#
- # == Synopsis
- #
- # Bundler::URI::join(str[, str, ...])
+ # Each string in +str+ is converted to an
+ # {RFC3986 Bundler::URI}[https://www.rfc-editor.org/rfc/rfc3986.html] before being merged.
#
- # == Args
- #
- # +str+::
- # String(s) to work with, will be converted to RFC3986 URIs before merging.
- #
- # == Description
- #
- # Joins URIs.
- #
- # == Usage
- #
- # require 'bundler/vendor/uri/lib/uri'
+ # Examples:
#
# Bundler::URI.join("http://example.com/","main.rbx")
# # => #<Bundler::URI::HTTP http://example.com/main.rbx>
@@ -254,7 +236,7 @@ module Bundler::URI
# Bundler::URI.extract("text here http://foo.example.org/bla and here mailto:test@example.com and here also.")
# # => ["http://foo.example.com/bla", "mailto:test@example.com"]
#
- def self.extract(str, schemes = nil, &block)
+ def self.extract(str, schemes = nil, &block) # :nodoc:
warn "Bundler::URI.extract is obsolete", uplevel: 1 if $VERBOSE
DEFAULT_PARSER.extract(str, schemes, &block)
end
@@ -291,7 +273,7 @@ module Bundler::URI
# p $&
# end
#
- def self.regexp(schemes = nil)
+ def self.regexp(schemes = nil)# :nodoc:
warn "Bundler::URI.regexp is obsolete", uplevel: 1 if $VERBOSE
DEFAULT_PARSER.make_regexp(schemes)
end
@@ -314,40 +296,86 @@ module Bundler::URI
TBLDECWWWCOMP_['+'] = ' '
TBLDECWWWCOMP_.freeze
- # Encodes given +str+ to URL-encoded form data.
+ # Returns a URL-encoded string derived from the given string +str+.
+ #
+ # The returned string:
+ #
+ # - Preserves:
+ #
+ # - Characters <tt>'*'</tt>, <tt>'.'</tt>, <tt>'-'</tt>, and <tt>'_'</tt>.
+ # - Character in ranges <tt>'a'..'z'</tt>, <tt>'A'..'Z'</tt>,
+ # and <tt>'0'..'9'</tt>.
+ #
+ # Example:
#
- # This method doesn't convert *, -, ., 0-9, A-Z, _, a-z, but does convert SP
- # (ASCII space) to + and converts others to %XX.
+ # Bundler::URI.encode_www_form_component('*.-_azAZ09')
+ # # => "*.-_azAZ09"
#
- # If +enc+ is given, convert +str+ to the encoding before percent encoding.
+ # - Converts:
#
- # This is an implementation of
- # https://www.w3.org/TR/2013/CR-html5-20130806/forms.html#url-encoded-form-data.
+ # - Character <tt>' '</tt> to character <tt>'+'</tt>.
+ # - Any other character to "percent notation";
+ # the percent notation for character <i>c</i> is <tt>'%%%X' % c.ord</tt>.
#
- # See Bundler::URI.decode_www_form_component, Bundler::URI.encode_www_form.
+ # Example:
+ #
+ # Bundler::URI.encode_www_form_component('Here are some punctuation characters: ,;?:')
+ # # => "Here+are+some+punctuation+characters%3A+%2C%3B%3F%3A"
+ #
+ # Encoding:
+ #
+ # - If +str+ has encoding Encoding::ASCII_8BIT, argument +enc+ is ignored.
+ # - Otherwise +str+ is converted first to Encoding::UTF_8
+ # (with suitable character replacements),
+ # and then to encoding +enc+.
+ #
+ # In either case, the returned string has forced encoding Encoding::US_ASCII.
+ #
+ # Related: Bundler::URI.encode_uri_component (encodes <tt>' '</tt> as <tt>'%20'</tt>).
def self.encode_www_form_component(str, enc=nil)
_encode_uri_component(/[^*\-.0-9A-Z_a-z]/, TBLENCWWWCOMP_, str, enc)
end
- # Decodes given +str+ of URL-encoded form data.
+ # Returns a string decoded from the given \URL-encoded string +str+.
+ #
+ # The given string is first encoded as Encoding::ASCII-8BIT (using String#b),
+ # then decoded (as below), and finally force-encoded to the given encoding +enc+.
+ #
+ # The returned string:
+ #
+ # - Preserves:
+ #
+ # - Characters <tt>'*'</tt>, <tt>'.'</tt>, <tt>'-'</tt>, and <tt>'_'</tt>.
+ # - Character in ranges <tt>'a'..'z'</tt>, <tt>'A'..'Z'</tt>,
+ # and <tt>'0'..'9'</tt>.
+ #
+ # Example:
+ #
+ # Bundler::URI.decode_www_form_component('*.-_azAZ09')
+ # # => "*.-_azAZ09"
+ #
+ # - Converts:
+ #
+ # - Character <tt>'+'</tt> to character <tt>' '</tt>.
+ # - Each "percent notation" to an ASCII character.
#
- # This decodes + to SP.
+ # Example:
#
- # See Bundler::URI.encode_www_form_component, Bundler::URI.decode_www_form.
+ # Bundler::URI.decode_www_form_component('Here+are+some+punctuation+characters%3A+%2C%3B%3F%3A')
+ # # => "Here are some punctuation characters: ,;?:"
+ #
+ # Related: Bundler::URI.decode_uri_component (preserves <tt>'+'</tt>).
def self.decode_www_form_component(str, enc=Encoding::UTF_8)
_decode_uri_component(/\+|%\h\h/, str, enc)
end
- # Encodes +str+ using URL encoding
- #
- # This encodes SP to %20 instead of +.
+ # Like Bundler::URI.encode_www_form_component, except that <tt>' '</tt> (space)
+ # is encoded as <tt>'%20'</tt> (instead of <tt>'+'</tt>).
def self.encode_uri_component(str, enc=nil)
_encode_uri_component(/[^*\-.0-9A-Z_a-z]/, TBLENCURICOMP_, str, enc)
end
- # Decodes given +str+ of URL-encoded data.
- #
- # This does not decode + to SP.
+ # Like Bundler::URI.decode_www_form_component, except that <tt>'+'</tt> is preserved.
def self.decode_uri_component(str, enc=Encoding::UTF_8)
_decode_uri_component(/%\h\h/, str, enc)
end
@@ -372,33 +400,104 @@ module Bundler::URI
end
private_class_method :_decode_uri_component
- # Generates URL-encoded form data from given +enum+.
+ # Returns a URL-encoded string derived from the given
+ # {Enumerable}[rdoc-ref:Enumerable@Enumerable+in+Ruby+Classes]
+ # +enum+.
+ #
+ # The result is suitable for use as form data
+ # for an \HTTP request whose <tt>Content-Type</tt> is
+ # <tt>'application/x-www-form-urlencoded'</tt>.
+ #
+ # The returned string consists of the elements of +enum+,
+ # each converted to one or more URL-encoded strings,
+ # and all joined with character <tt>'&'</tt>.
+ #
+ # Simple examples:
+ #
+ # Bundler::URI.encode_www_form([['foo', 0], ['bar', 1], ['baz', 2]])
+ # # => "foo=0&bar=1&baz=2"
+ # Bundler::URI.encode_www_form({foo: 0, bar: 1, baz: 2})
+ # # => "foo=0&bar=1&baz=2"
+ #
+ # The returned string is formed using method Bundler::URI.encode_www_form_component,
+ # which converts certain characters:
+ #
+ # Bundler::URI.encode_www_form('f#o': '/', 'b-r': '$', 'b z': '@')
+ # # => "f%23o=%2F&b-r=%24&b+z=%40"
+ #
+ # When +enum+ is Array-like, each element +ele+ is converted to a field:
+ #
+ # - If +ele+ is an array of two or more elements,
+ # the field is formed from its first two elements
+ # (and any additional elements are ignored):
+ #
+ # name = Bundler::URI.encode_www_form_component(ele[0], enc)
+ # value = Bundler::URI.encode_www_form_component(ele[1], enc)
+ # "#{name}=#{value}"
#
- # This generates application/x-www-form-urlencoded data defined in HTML5
- # from given an Enumerable object.
+ # Examples:
#
- # This internally uses Bundler::URI.encode_www_form_component(str).
+ # Bundler::URI.encode_www_form([%w[foo bar], %w[baz bat bah]])
+ # # => "foo=bar&baz=bat"
+ # Bundler::URI.encode_www_form([['foo', 0], ['bar', :baz, 'bat']])
+ # # => "foo=0&bar=baz"
#
- # This method doesn't convert the encoding of given items, so convert them
- # before calling this method if you want to send data as other than original
- # encoding or mixed encoding data. (Strings which are encoded in an HTML5
- # ASCII incompatible encoding are converted to UTF-8.)
+ # - If +ele+ is an array of one element,
+ # the field is formed from <tt>ele[0]</tt>:
#
- # This method doesn't handle files. When you send a file, use
- # multipart/form-data.
+ # Bundler::URI.encode_www_form_component(ele[0])
#
- # This refers https://url.spec.whatwg.org/#concept-urlencoded-serializer
+ # Example:
#
- # Bundler::URI.encode_www_form([["q", "ruby"], ["lang", "en"]])
- # #=> "q=ruby&lang=en"
- # Bundler::URI.encode_www_form("q" => "ruby", "lang" => "en")
- # #=> "q=ruby&lang=en"
- # Bundler::URI.encode_www_form("q" => ["ruby", "perl"], "lang" => "en")
- # #=> "q=ruby&q=perl&lang=en"
- # Bundler::URI.encode_www_form([["q", "ruby"], ["q", "perl"], ["lang", "en"]])
- # #=> "q=ruby&q=perl&lang=en"
+ # Bundler::URI.encode_www_form([['foo'], [:bar], [0]])
+ # # => "foo&bar&0"
+ #
+ # - Otherwise the field is formed from +ele+:
+ #
+ # Bundler::URI.encode_www_form_component(ele)
+ #
+ # Example:
+ #
+ # Bundler::URI.encode_www_form(['foo', :bar, 0])
+ # # => "foo&bar&0"
+ #
+ # The elements of an Array-like +enum+ may be mixture:
+ #
+ # Bundler::URI.encode_www_form([['foo', 0], ['bar', 1, 2], ['baz'], :bat])
+ # # => "foo=0&bar=1&baz&bat"
+ #
+ # When +enum+ is Hash-like,
+ # each +key+/+value+ pair is converted to one or more fields:
+ #
+ # - If +value+ is
+ # {Array-convertible}[rdoc-ref:implicit_conversion.rdoc@Array-Convertible+Objects],
+ # each element +ele+ in +value+ is paired with +key+ to form a field:
+ #
+ # name = Bundler::URI.encode_www_form_component(key, enc)
+ # value = Bundler::URI.encode_www_form_component(ele, enc)
+ # "#{name}=#{value}"
+ #
+ # Example:
+ #
+ # Bundler::URI.encode_www_form({foo: [:bar, 1], baz: [:bat, :bam, 2]})
+ # # => "foo=bar&foo=1&baz=bat&baz=bam&baz=2"
+ #
+ # - Otherwise, +key+ and +value+ are paired to form a field:
+ #
+ # name = Bundler::URI.encode_www_form_component(key, enc)
+ # value = Bundler::URI.encode_www_form_component(value, enc)
+ # "#{name}=#{value}"
+ #
+ # Example:
+ #
+ # Bundler::URI.encode_www_form({foo: 0, bar: 1, baz: 2})
+ # # => "foo=0&bar=1&baz=2"
+ #
+ # The elements of a Hash-like +enum+ may be mixture:
+ #
+ # Bundler::URI.encode_www_form({foo: [0, 1], bar: 2})
+ # # => "foo=0&foo=1&bar=2"
#
- # See Bundler::URI.encode_www_form_component, Bundler::URI.decode_www_form.
def self.encode_www_form(enum, enc=nil)
enum.map do |k,v|
if v.nil?
@@ -419,22 +518,39 @@ module Bundler::URI
end.join('&')
end
- # Decodes URL-encoded form data from given +str+.
+ # Returns name/value pairs derived from the given string +str+,
+ # which must be an ASCII string.
+ #
+ # The method may be used to decode the body of Net::HTTPResponse object +res+
+ # for which <tt>res['Content-Type']</tt> is <tt>'application/x-www-form-urlencoded'</tt>.
+ #
+ # The returned data is an array of 2-element subarrays;
+ # each subarray is a name/value pair (both are strings).
+ # Each returned string has encoding +enc+,
+ # and has had invalid characters removed via
+ # {String#scrub}[rdoc-ref:String#scrub].
#
- # This decodes application/x-www-form-urlencoded data
- # and returns an array of key-value arrays.
+ # A simple example:
#
- # This refers http://url.spec.whatwg.org/#concept-urlencoded-parser,
- # so this supports only &-separator, and doesn't support ;-separator.
+ # Bundler::URI.decode_www_form('foo=0&bar=1&baz')
+ # # => [["foo", "0"], ["bar", "1"], ["baz", ""]]
#
- # ary = Bundler::URI.decode_www_form("a=1&a=2&b=3")
- # ary #=> [['a', '1'], ['a', '2'], ['b', '3']]
- # ary.assoc('a').last #=> '1'
- # ary.assoc('b').last #=> '3'
- # ary.rassoc('a').last #=> '2'
- # Hash[ary] #=> {"a"=>"2", "b"=>"3"}
+ # The returned strings have certain conversions,
+ # similar to those performed in Bundler::URI.decode_www_form_component:
+ #
+ # Bundler::URI.decode_www_form('f%23o=%2F&b-r=%24&b+z=%40')
+ # # => [["f#o", "/"], ["b-r", "$"], ["b z", "@"]]
+ #
+ # The given string may contain consecutive separators:
+ #
+ # Bundler::URI.decode_www_form('foo=0&&bar=1&&baz=2')
+ # # => [["foo", "0"], ["", ""], ["bar", "1"], ["", ""], ["baz", "2"]]
+ #
+ # A different separator may be specified:
+ #
+ # Bundler::URI.decode_www_form('foo=0--bar=1--baz', separator: '--')
+ # # => [["foo", "0"], ["bar", "1"], ["baz", ""]]
#
- # See Bundler::URI.decode_www_form_component, Bundler::URI.encode_www_form.
def self.decode_www_form(str, enc=Encoding::UTF_8, separator: '&', use__charset_: false, isindex: false)
raise ArgumentError, "the input of #{self.name}.#{__method__} must be ASCII only string" unless str.ascii_only?
ary = []
@@ -713,7 +829,15 @@ end # module Bundler::URI
module Bundler
#
- # Returns +uri+ converted to an Bundler::URI object.
+ # Returns a \Bundler::URI object derived from the given +uri+,
+ # which may be a \Bundler::URI string or an existing \Bundler::URI object:
+ #
+ # # Returns a new Bundler::URI.
+ # uri = Bundler::URI('http://github.com/ruby/ruby')
+ # # => #<Bundler::URI::HTTP http://github.com/ruby/ruby>
+ # # Returns the given Bundler::URI.
+ # Bundler::URI(uri)
+ # # => #<Bundler::URI::HTTP http://github.com/ruby/ruby>
#
def URI(uri)
if uri.is_a?(Bundler::URI::Generic)
diff --git a/lib/bundler/vendor/uri/lib/uri/generic.rb b/lib/bundler/vendor/uri/lib/uri/generic.rb
index 9ae6915826..762c425ac1 100644
--- a/lib/bundler/vendor/uri/lib/uri/generic.rb
+++ b/lib/bundler/vendor/uri/lib/uri/generic.rb
@@ -1376,6 +1376,7 @@ module Bundler::URI
end
str
end
+ alias to_str to_s
#
# Compares two URIs.
diff --git a/lib/bundler/vendor/uri/lib/uri/rfc2396_parser.rb b/lib/bundler/vendor/uri/lib/uri/rfc2396_parser.rb
index 2f8d55353b..09c22c9906 100644
--- a/lib/bundler/vendor/uri/lib/uri/rfc2396_parser.rb
+++ b/lib/bundler/vendor/uri/lib/uri/rfc2396_parser.rb
@@ -497,8 +497,8 @@ module Bundler::URI
ret = {}
# for Bundler::URI::split
- ret[:ABS_URI] = Regexp.new('\A\s*' + pattern[:X_ABS_URI] + '\s*\z', Regexp::EXTENDED)
- ret[:REL_URI] = Regexp.new('\A\s*' + pattern[:X_REL_URI] + '\s*\z', Regexp::EXTENDED)
+ ret[:ABS_URI] = Regexp.new('\A\s*+' + pattern[:X_ABS_URI] + '\s*\z', Regexp::EXTENDED)
+ ret[:REL_URI] = Regexp.new('\A\s*+' + pattern[:X_REL_URI] + '\s*\z', Regexp::EXTENDED)
# for Bundler::URI::extract
ret[:URI_REF] = Regexp.new(pattern[:URI_REF])
diff --git a/lib/bundler/vendor/uri/lib/uri/rfc3986_parser.rb b/lib/bundler/vendor/uri/lib/uri/rfc3986_parser.rb
index 1307e8e474..4c9882f595 100644
--- a/lib/bundler/vendor/uri/lib/uri/rfc3986_parser.rb
+++ b/lib/bundler/vendor/uri/lib/uri/rfc3986_parser.rb
@@ -1,9 +1,73 @@
-# frozen_string_literal: false
+# frozen_string_literal: true
module Bundler::URI
class RFC3986_Parser # :nodoc:
# Bundler::URI defined in RFC3986
- RFC3986_URI = /\A(?<Bundler::URI>(?<scheme>[A-Za-z][+\-.0-9A-Za-z]*):(?<hier-part>\/\/(?<authority>(?:(?<userinfo>(?:%\h\h|[!$&-.0-;=A-Z_a-z~])*)@)?(?<host>(?<IP-literal>\[(?:(?<IPv6address>(?:\h{1,4}:){6}(?<ls32>\h{1,4}:\h{1,4}|(?<IPv4address>(?<dec-octet>[1-9]\d|1\d{2}|2[0-4]\d|25[0-5]|\d)\.\g<dec-octet>\.\g<dec-octet>\.\g<dec-octet>))|::(?:\h{1,4}:){5}\g<ls32>|\h{1,4}?::(?:\h{1,4}:){4}\g<ls32>|(?:(?:\h{1,4}:)?\h{1,4})?::(?:\h{1,4}:){3}\g<ls32>|(?:(?:\h{1,4}:){,2}\h{1,4})?::(?:\h{1,4}:){2}\g<ls32>|(?:(?:\h{1,4}:){,3}\h{1,4})?::\h{1,4}:\g<ls32>|(?:(?:\h{1,4}:){,4}\h{1,4})?::\g<ls32>|(?:(?:\h{1,4}:){,5}\h{1,4})?::\h{1,4}|(?:(?:\h{1,4}:){,6}\h{1,4})?::)|(?<IPvFuture>v\h+\.[!$&-.0-;=A-Z_a-z~]+))\])|\g<IPv4address>|(?<reg-name>(?:%\h\h|[!$&-.0-9;=A-Z_a-z~])*))(?::(?<port>\d*))?)(?<path-abempty>(?:\/(?<segment>(?:%\h\h|[!$&-.0-;=@-Z_a-z~])*))*)|(?<path-absolute>\/(?:(?<segment-nz>(?:%\h\h|[!$&-.0-;=@-Z_a-z~])+)(?:\/\g<segment>)*)?)|(?<path-rootless>\g<segment-nz>(?:\/\g<segment>)*)|(?<path-empty>))(?:\?(?<query>[^#]*))?(?:\#(?<fragment>(?:%\h\h|[!$&-.0-;=@-Z_a-z~\/?])*))?)\z/
- RFC3986_relative_ref = /\A(?<relative-ref>(?<relative-part>\/\/(?<authority>(?:(?<userinfo>(?:%\h\h|[!$&-.0-;=A-Z_a-z~])*)@)?(?<host>(?<IP-literal>\[(?:(?<IPv6address>(?:\h{1,4}:){6}(?<ls32>\h{1,4}:\h{1,4}|(?<IPv4address>(?<dec-octet>[1-9]\d|1\d{2}|2[0-4]\d|25[0-5]|\d)\.\g<dec-octet>\.\g<dec-octet>\.\g<dec-octet>))|::(?:\h{1,4}:){5}\g<ls32>|\h{1,4}?::(?:\h{1,4}:){4}\g<ls32>|(?:(?:\h{1,4}:){,1}\h{1,4})?::(?:\h{1,4}:){3}\g<ls32>|(?:(?:\h{1,4}:){,2}\h{1,4})?::(?:\h{1,4}:){2}\g<ls32>|(?:(?:\h{1,4}:){,3}\h{1,4})?::\h{1,4}:\g<ls32>|(?:(?:\h{1,4}:){,4}\h{1,4})?::\g<ls32>|(?:(?:\h{1,4}:){,5}\h{1,4})?::\h{1,4}|(?:(?:\h{1,4}:){,6}\h{1,4})?::)|(?<IPvFuture>v\h+\.[!$&-.0-;=A-Z_a-z~]+))\])|\g<IPv4address>|(?<reg-name>(?:%\h\h|[!$&-.0-9;=A-Z_a-z~])+))?(?::(?<port>\d*))?)(?<path-abempty>(?:\/(?<segment>(?:%\h\h|[!$&-.0-;=@-Z_a-z~])*))*)|(?<path-absolute>\/(?:(?<segment-nz>(?:%\h\h|[!$&-.0-;=@-Z_a-z~])+)(?:\/\g<segment>)*)?)|(?<path-noscheme>(?<segment-nz-nc>(?:%\h\h|[!$&-.0-9;=@-Z_a-z~])+)(?:\/\g<segment>)*)|(?<path-empty>))(?:\?(?<query>[^#]*))?(?:\#(?<fragment>(?:%\h\h|[!$&-.0-;=@-Z_a-z~\/?])*))?)\z/
+ HOST = %r[
+ (?<IP-literal>\[(?:
+ (?<IPv6address>
+ (?:\h{1,4}:){6}
+ (?<ls32>\h{1,4}:\h{1,4}
+ | (?<IPv4address>(?<dec-octet>[1-9]\d|1\d{2}|2[0-4]\d|25[0-5]|\d)
+ \.\g<dec-octet>\.\g<dec-octet>\.\g<dec-octet>)
+ )
+ | ::(?:\h{1,4}:){5}\g<ls32>
+ | \h{1,4}?::(?:\h{1,4}:){4}\g<ls32>
+ | (?:(?:\h{1,4}:)?\h{1,4})?::(?:\h{1,4}:){3}\g<ls32>
+ | (?:(?:\h{1,4}:){,2}\h{1,4})?::(?:\h{1,4}:){2}\g<ls32>
+ | (?:(?:\h{1,4}:){,3}\h{1,4})?::\h{1,4}:\g<ls32>
+ | (?:(?:\h{1,4}:){,4}\h{1,4})?::\g<ls32>
+ | (?:(?:\h{1,4}:){,5}\h{1,4})?::\h{1,4}
+ | (?:(?:\h{1,4}:){,6}\h{1,4})?::
+ )
+ | (?<IPvFuture>v\h++\.[!$&-.0-9:;=A-Z_a-z~]++)
+ )\])
+ | \g<IPv4address>
+ | (?<reg-name>(?:%\h\h|[!$&-.0-9;=A-Z_a-z~])*+)
+ ]x
+
+ USERINFO = /(?:%\h\h|[!$&-.0-9:;=A-Z_a-z~])*+/
+
+ SCHEME = %r[[A-Za-z][+\-.0-9A-Za-z]*+].source
+ SEG = %r[(?:%\h\h|[!$&-.0-9:;=@A-Z_a-z~/])].source
+ SEG_NC = %r[(?:%\h\h|[!$&-.0-9;=@A-Z_a-z~])].source
+ FRAGMENT = %r[(?:%\h\h|[!$&-.0-9:;=@A-Z_a-z~/?])*+].source
+
+ RFC3986_URI = %r[\A
+ (?<seg>#{SEG}){0}
+ (?<Bundler::URI>
+ (?<scheme>#{SCHEME}):
+ (?<hier-part>//
+ (?<authority>
+ (?:(?<userinfo>#{USERINFO.source})@)?
+ (?<host>#{HOST.source.delete(" \n")})
+ (?::(?<port>\d*+))?
+ )
+ (?<path-abempty>(?:/\g<seg>*+)?)
+ | (?<path-absolute>/((?!/)\g<seg>++)?)
+ | (?<path-rootless>(?!/)\g<seg>++)
+ | (?<path-empty>)
+ )
+ (?:\?(?<query>[^\#]*+))?
+ (?:\#(?<fragment>#{FRAGMENT}))?
+ )\z]x
+
+ RFC3986_relative_ref = %r[\A
+ (?<seg>#{SEG}){0}
+ (?<relative-ref>
+ (?<relative-part>//
+ (?<authority>
+ (?:(?<userinfo>#{USERINFO.source})@)?
+ (?<host>#{HOST.source.delete(" \n")}(?<!/))?
+ (?::(?<port>\d*+))?
+ )
+ (?<path-abempty>(?:/\g<seg>*+)?)
+ | (?<path-absolute>/\g<seg>*+)
+ | (?<path-noscheme>#{SEG_NC}++(?:/\g<seg>*+)?)
+ | (?<path-empty>)
+ )
+ (?:\?(?<query>[^#]*+))?
+ (?:\#(?<fragment>#{FRAGMENT}))?
+ )\z]x
attr_reader :regexp
def initialize
@@ -19,9 +83,9 @@ module Bundler::URI
uri.ascii_only? or
raise InvalidURIError, "Bundler::URI must be ascii only #{uri.dump}"
if m = RFC3986_URI.match(uri)
- query = m["query".freeze]
- scheme = m["scheme".freeze]
- opaque = m["path-rootless".freeze]
+ query = m["query"]
+ scheme = m["scheme"]
+ opaque = m["path-rootless"]
if opaque
opaque << "?#{query}" if query
[ scheme,
@@ -32,35 +96,35 @@ module Bundler::URI
nil, # path
opaque,
nil, # query
- m["fragment".freeze]
+ m["fragment"]
]
else # normal
[ scheme,
- m["userinfo".freeze],
- m["host".freeze],
- m["port".freeze],
+ m["userinfo"],
+ m["host"],
+ m["port"],
nil, # registry
- (m["path-abempty".freeze] ||
- m["path-absolute".freeze] ||
- m["path-empty".freeze]),
+ (m["path-abempty"] ||
+ m["path-absolute"] ||
+ m["path-empty"]),
nil, # opaque
query,
- m["fragment".freeze]
+ m["fragment"]
]
end
elsif m = RFC3986_relative_ref.match(uri)
[ nil, # scheme
- m["userinfo".freeze],
- m["host".freeze],
- m["port".freeze],
+ m["userinfo"],
+ m["host"],
+ m["port"],
nil, # registry,
- (m["path-abempty".freeze] ||
- m["path-absolute".freeze] ||
- m["path-noscheme".freeze] ||
- m["path-empty".freeze]),
+ (m["path-abempty"] ||
+ m["path-absolute"] ||
+ m["path-noscheme"] ||
+ m["path-empty"]),
nil, # opaque
- m["query".freeze],
- m["fragment".freeze]
+ m["query"],
+ m["fragment"]
]
else
raise InvalidURIError, "bad Bundler::URI(is not Bundler::URI?): #{uri.inspect}"
@@ -92,15 +156,15 @@ module Bundler::URI
def default_regexp # :nodoc:
{
- SCHEME: /\A[A-Za-z][A-Za-z0-9+\-.]*\z/,
- USERINFO: /\A(?:%\h\h|[!$&-.0-;=A-Z_a-z~])*\z/,
- HOST: /\A(?:(?<IP-literal>\[(?:(?<IPv6address>(?:\h{1,4}:){6}(?<ls32>\h{1,4}:\h{1,4}|(?<IPv4address>(?<dec-octet>[1-9]\d|1\d{2}|2[0-4]\d|25[0-5]|\d)\.\g<dec-octet>\.\g<dec-octet>\.\g<dec-octet>))|::(?:\h{1,4}:){5}\g<ls32>|\h{,4}::(?:\h{1,4}:){4}\g<ls32>|(?:(?:\h{1,4}:)?\h{1,4})?::(?:\h{1,4}:){3}\g<ls32>|(?:(?:\h{1,4}:){,2}\h{1,4})?::(?:\h{1,4}:){2}\g<ls32>|(?:(?:\h{1,4}:){,3}\h{1,4})?::\h{1,4}:\g<ls32>|(?:(?:\h{1,4}:){,4}\h{1,4})?::\g<ls32>|(?:(?:\h{1,4}:){,5}\h{1,4})?::\h{1,4}|(?:(?:\h{1,4}:){,6}\h{1,4})?::)|(?<IPvFuture>v\h+\.[!$&-.0-;=A-Z_a-z~]+))\])|\g<IPv4address>|(?<reg-name>(?:%\h\h|[!$&-.0-9;=A-Z_a-z~])*))\z/,
- ABS_PATH: /\A\/(?:%\h\h|[!$&-.0-;=@-Z_a-z~])*(?:\/(?:%\h\h|[!$&-.0-;=@-Z_a-z~])*)*\z/,
- REL_PATH: /\A(?:%\h\h|[!$&-.0-;=@-Z_a-z~])+(?:\/(?:%\h\h|[!$&-.0-;=@-Z_a-z~])*)*\z/,
- QUERY: /\A(?:%\h\h|[!$&-.0-;=@-Z_a-z~\/?])*\z/,
- FRAGMENT: /\A(?:%\h\h|[!$&-.0-;=@-Z_a-z~\/?])*\z/,
- OPAQUE: /\A(?:[^\/].*)?\z/,
- PORT: /\A[\x09\x0a\x0c\x0d ]*\d*[\x09\x0a\x0c\x0d ]*\z/,
+ SCHEME: %r[\A#{SCHEME}\z]o,
+ USERINFO: %r[\A#{USERINFO}\z]o,
+ HOST: %r[\A#{HOST}\z]o,
+ ABS_PATH: %r[\A/#{SEG}*+\z]o,
+ REL_PATH: %r[\A(?!/)#{SEG}++\z]o,
+ QUERY: %r[\A(?:%\h\h|[!$&-.0-9:;=@A-Z_a-z~/?])*+\z],
+ FRAGMENT: %r[\A#{FRAGMENT}\z]o,
+ OPAQUE: %r[\A(?:[^/].*)?\z],
+ PORT: /\A[\x09\x0a\x0c\x0d ]*+\d*[\x09\x0a\x0c\x0d ]*\z/,
}
end
diff --git a/lib/bundler/vendor/uri/lib/uri/version.rb b/lib/bundler/vendor/uri/lib/uri/version.rb
index 02fa367735..1fa1c7c09a 100644
--- a/lib/bundler/vendor/uri/lib/uri/version.rb
+++ b/lib/bundler/vendor/uri/lib/uri/version.rb
@@ -1,6 +1,6 @@
module Bundler::URI
# :stopdoc:
- VERSION_CODE = '001200'.freeze
+ VERSION_CODE = '001300'.freeze
VERSION = VERSION_CODE.scan(/../).collect{|n| n.to_i}.join('.').freeze
# :startdoc:
end
diff --git a/lib/bundler/vendored_net_http.rb b/lib/bundler/vendored_net_http.rb
new file mode 100644
index 0000000000..0dcabaa7d7
--- /dev/null
+++ b/lib/bundler/vendored_net_http.rb
@@ -0,0 +1,12 @@
+# frozen_string_literal: true
+
+begin
+ require "rubygems/vendored_net_http"
+rescue LoadError
+ begin
+ require "rubygems/net/http"
+ rescue LoadError
+ require "net/http"
+ Gem::Net = Net
+ end
+end
diff --git a/lib/bundler/vendored_persistent.rb b/lib/bundler/vendored_persistent.rb
index e29f27cdfd..ab985c267f 100644
--- a/lib/bundler/vendored_persistent.rb
+++ b/lib/bundler/vendored_persistent.rb
@@ -9,7 +9,3 @@ module Bundler
end
end
require_relative "vendor/net-http-persistent/lib/net/http/persistent"
-
-module Bundler
- PersistentHTTP = Persistent::Net::HTTP::Persistent
-end
diff --git a/lib/bundler/vendored_timeout.rb b/lib/bundler/vendored_timeout.rb
new file mode 100644
index 0000000000..9b2507c0cc
--- /dev/null
+++ b/lib/bundler/vendored_timeout.rb
@@ -0,0 +1,12 @@
+# frozen_string_literal: true
+
+begin
+ require "rubygems/vendored_timeout"
+rescue LoadError
+ begin
+ require "rubygems/timeout"
+ rescue LoadError
+ require "timeout"
+ Gem::Timeout = Timeout
+ end
+end
diff --git a/lib/bundler/vendored_uri.rb b/lib/bundler/vendored_uri.rb
index 905e8158e8..2efddc65f9 100644
--- a/lib/bundler/vendored_uri.rb
+++ b/lib/bundler/vendored_uri.rb
@@ -1,4 +1,21 @@
# frozen_string_literal: true
module Bundler; end
-require_relative "vendor/uri/lib/uri"
+
+# Use RubyGems vendored copy when available. Otherwise fallback to Bundler
+# vendored copy. The vendored copy in Bundler can be removed once support for
+# RubyGems 3.5 is dropped.
+
+begin
+ require "rubygems/vendor/uri/lib/uri"
+rescue LoadError
+ require_relative "vendor/uri/lib/uri"
+ Gem::URI = Bundler::URI
+
+ module Gem
+ def URI(uri) # rubocop:disable Naming/MethodName
+ Bundler::URI(uri)
+ end
+ module_function :URI
+ end
+end
diff --git a/lib/bundler/version.rb b/lib/bundler/version.rb
index 7c03d8687f..cc9550e988 100644
--- a/lib/bundler/version.rb
+++ b/lib/bundler/version.rb
@@ -1,7 +1,7 @@
# frozen_string_literal: false
module Bundler
- VERSION = "2.5.0.dev".freeze
+ VERSION = "2.5.9".freeze
def self.bundler_major_version
@bundler_major_version ||= VERSION.split(".").first.to_i
diff --git a/lib/bundler/vlad.rb b/lib/bundler/vlad.rb
index 538e8c3e74..6179d0e4eb 100644
--- a/lib/bundler/vlad.rb
+++ b/lib/bundler/vlad.rb
@@ -13,5 +13,5 @@ require_relative "deployment"
include Rake::DSL if defined? Rake::DSL
namespace :vlad do
- Bundler::Deployment.define_task(Rake::RemoteTask, :remote_task, :roles => :app)
+ Bundler::Deployment.define_task(Rake::RemoteTask, :remote_task, roles: :app)
end
diff --git a/lib/bundler/yaml_serializer.rb b/lib/bundler/yaml_serializer.rb
index d5ecbd4aef..42e6aaf89d 100644
--- a/lib/bundler/yaml_serializer.rb
+++ b/lib/bundler/yaml_serializer.rb
@@ -17,7 +17,11 @@ module Bundler
if v.is_a?(Hash)
yaml << dump_hash(v).gsub(/^(?!$)/, " ") # indent all non-empty lines
elsif v.is_a?(Array) # Expected to be array of strings
- yaml << "\n- " << v.map {|s| s.to_s.gsub(/\s+/, " ").inspect }.join("\n- ") << "\n"
+ if v.empty?
+ yaml << " []\n"
+ else
+ yaml << "\n- " << v.map {|s| s.to_s.gsub(/\s+/, " ").inspect }.join("\n- ") << "\n"
+ end
else
yaml << " " << v.to_s.gsub(/\s+/, " ").inspect << "\n"
end
@@ -32,7 +36,7 @@ module Bundler
(.*) # value
\1 # matching closing quote
$
- /xo.freeze
+ /xo
HASH_REGEX = /
^
@@ -44,18 +48,20 @@ module Bundler
(.*) # value
\3 # matching closing quote
$
- /xo.freeze
+ /xo
def load(str)
res = {}
stack = [res]
last_hash = nil
last_empty_key = nil
- str.split(/\r?\n/).each do |line|
+ str.split(/\r?\n/) do |line|
if match = HASH_REGEX.match(line)
indent, key, quote, val = match.captures
- key = convert_to_backward_compatible_key(key)
- depth = indent.scan(/ /).length
+ val = strip_comment(val)
+
+ convert_to_backward_compatible_key!(key)
+ depth = indent.size / 2
if quote.empty? && val.empty?
new_hash = {}
stack[depth][key] = new_hash
@@ -63,10 +69,13 @@ module Bundler
last_empty_key = key
last_hash = stack[depth]
else
+ val = [] if val == "[]" # empty array
stack[depth][key] = val
end
elsif match = ARRAY_REGEX.match(line)
_, val = match.captures
+ val = strip_comment(val)
+
last_hash[last_empty_key] = [] unless last_hash[last_empty_key].is_a?(Array)
last_hash[last_empty_key].push(val)
@@ -75,15 +84,22 @@ module Bundler
res
end
+ def strip_comment(val)
+ if val.include?("#") && !val.start_with?("#")
+ val.split("#", 2).first.strip
+ else
+ val
+ end
+ end
+
# for settings' keys
- def convert_to_backward_compatible_key(key)
- key = "#{key}/" if key =~ /https?:/i && key !~ %r{/\Z}
- key = key.gsub(".", "__") if key.include?(".")
- key
+ def convert_to_backward_compatible_key!(key)
+ key << "/" if /https?:/i.match?(key) && !%r{/\Z}.match?(key)
+ key.gsub!(".", "__")
end
class << self
- private :dump_hash, :convert_to_backward_compatible_key
+ private :dump_hash, :convert_to_backward_compatible_key!
end
end
end
diff --git a/lib/cgi.rb b/lib/cgi.rb
index 4cd6b3bd8e..7af85e7fc8 100644
--- a/lib/cgi.rb
+++ b/lib/cgi.rb
@@ -288,7 +288,7 @@
#
class CGI
- VERSION = "0.3.6"
+ VERSION = "0.4.1"
end
require 'cgi/core'
diff --git a/lib/cgi/util.rb b/lib/cgi/util.rb
index 5a5c77ac97..4986e544e0 100644
--- a/lib/cgi/util.rb
+++ b/lib/cgi/util.rb
@@ -36,7 +36,7 @@ module CGI::Util
# URL-encode a string following RFC 3986
# Space characters (+" "+) are encoded with (+"%20"+)
- # url_encoded_string = CGI.escape("'Stop!' said Fred")
+ # url_encoded_string = CGI.escapeURIComponent("'Stop!' said Fred")
# # => "%27Stop%21%27%20said%20Fred"
def escapeURIComponent(string)
encoding = string.encoding
@@ -46,9 +46,10 @@ module CGI::Util
end
buffer.force_encoding(encoding)
end
+ alias escape_uri_component escapeURIComponent
# URL-decode a string following RFC 3986 with encoding(optional).
- # string = CGI.unescape("%27Stop%21%27+said%20Fred")
+ # string = CGI.unescapeURIComponent("%27Stop%21%27+said%20Fred")
# # => "'Stop!'+said Fred"
def unescapeURIComponent(string, encoding = @@accept_charset)
str = string.b
@@ -59,6 +60,8 @@ module CGI::Util
str.valid_encoding? ? str : str.force_encoding(string.encoding)
end
+ alias unescape_uri_component unescapeURIComponent
+
# The set of special characters and their escaped values
TABLE_FOR_ESCAPE_HTML__ = {
"'" => '&#39;',
@@ -90,9 +93,12 @@ module CGI::Util
end
end
- begin
- require 'cgi/escape'
- rescue LoadError
+ # TruffleRuby runs the pure-Ruby variant faster, do not use the C extension there
+ unless RUBY_ENGINE == 'truffleruby'
+ begin
+ require 'cgi/escape'
+ rescue LoadError
+ end
end
# Unescape a string that has been HTML-escaped
diff --git a/lib/csv.rb b/lib/csv.rb
index 0307033941..e8aa20ddd2 100644
--- a/lib/csv.rb
+++ b/lib/csv.rb
@@ -70,7 +70,7 @@
# == What is CSV, really?
#
# CSV maintains a pretty strict definition of CSV taken directly from
-# {the RFC}[http://www.ietf.org/rfc/rfc4180.txt]. I relax the rules in only one
+# {the RFC}[https://www.ietf.org/rfc/rfc4180.txt]. I relax the rules in only one
# place and that is to make using this library easier. CSV will parse all valid
# CSV.
#
@@ -102,14 +102,6 @@ require_relative "csv/writer"
# == \CSV
#
-# === In a Hurry?
-#
-# If you are familiar with \CSV data and have a particular task in mind,
-# you may want to go directly to the:
-# - {Recipes for CSV}[doc/csv/recipes/recipes_rdoc.html].
-#
-# Otherwise, read on here, about the API: classes, methods, and constants.
-#
# === \CSV Data
#
# \CSV (comma-separated values) data is a text representation of a table:
@@ -854,6 +846,15 @@ class CSV
end
end
+ # The error thrown when the parser encounters invalid encoding in CSV.
+ class InvalidEncodingError < MalformedCSVError
+ attr_reader :encoding
+ def initialize(encoding, line_number)
+ @encoding = encoding
+ super("Invalid byte sequence in #{encoding}", line_number)
+ end
+ end
+
#
# A FieldInfo Struct contains details about a field's position in the data
# source it was read from. CSV will pass this Struct to some blocks that make
@@ -1314,8 +1315,8 @@ class CSV
#
# Arguments:
# * Argument +path_or_io+ must be a file path or an \IO stream.
- # * Argument +mode+, if given, must be a \File mode
- # See {Open Mode}[https://ruby-doc.org/core/IO.html#method-c-new-label-Open+Mode].
+ # * Argument +mode+, if given, must be a \File mode.
+ # See {Access Modes}[rdoc-ref:File@Access+Modes].
# * Arguments <tt>**options</tt> must be keyword options.
# See {Options for Parsing}[#class-CSV-label-Options+for+Parsing].
# * This method optionally accepts an additional <tt>:encoding</tt> option
@@ -1521,8 +1522,8 @@ class CSV
#
# * Argument +path+, if given, must be the path to a file.
# :include: ../doc/csv/arguments/io.rdoc
- # * Argument +mode+, if given, must be a \File mode
- # See {Open Mode}[IO.html#method-c-new-label-Open+Mode].
+ # * Argument +mode+, if given, must be a \File mode.
+ # See {Access Modes}[rdoc-ref:File@Access+Modes].
# * Arguments <tt>**options</tt> must be keyword options.
# See {Options for Generating}[#class-CSV-label-Options+for+Generating].
# * This method optionally accepts an additional <tt>:encoding</tt> option
diff --git a/lib/csv/delete_suffix.rb b/lib/csv/delete_suffix.rb
deleted file mode 100644
index d457718997..0000000000
--- a/lib/csv/delete_suffix.rb
+++ /dev/null
@@ -1,18 +0,0 @@
-# frozen_string_literal: true
-
-# This provides String#delete_suffix? for Ruby 2.4.
-unless String.method_defined?(:delete_suffix)
- class CSV
- module DeleteSuffix
- refine String do
- def delete_suffix(suffix)
- if end_with?(suffix)
- self[0...-suffix.size]
- else
- self
- end
- end
- end
- end
- end
-end
diff --git a/lib/csv/match_p.rb b/lib/csv/match_p.rb
deleted file mode 100644
index 775559a3eb..0000000000
--- a/lib/csv/match_p.rb
+++ /dev/null
@@ -1,20 +0,0 @@
-# frozen_string_literal: true
-
-# This provides String#match? and Regexp#match? for Ruby 2.3.
-unless String.method_defined?(:match?)
- class CSV
- module MatchP
- refine String do
- def match?(pattern)
- self =~ pattern
- end
- end
-
- refine Regexp do
- def match?(string)
- self =~ string
- end
- end
- end
- end
-end
diff --git a/lib/csv/parser.rb b/lib/csv/parser.rb
index afb3131cd5..4da87fbac8 100644
--- a/lib/csv/parser.rb
+++ b/lib/csv/parser.rb
@@ -101,7 +101,7 @@ class CSV
position = @scanner.pos
offset = 0
n_row_separator_chars = row_separator.size
- # trace(__method__, :start, line, input)
+ # trace(__method__, :start, input)
while true
input.each_line(row_separator) do |line|
@scanner.pos += line.bytesize
@@ -157,6 +157,7 @@ class CSV
# trace(__method__, pattern, :done, :last, value) if @last_scanner
return value if @last_scanner
+ # trace(__method__, pattern, :done, :nil) if value.nil?
return nil if value.nil?
while @scanner.eos? and read_chunk and (sub_value = @scanner.scan(pattern))
# trace(__method__, pattern, :sub, sub_value)
@@ -200,7 +201,8 @@ class CSV
# trace(__method__, :rescan, start, buffer)
string = @scanner.string
if scanner == @scanner
- keep = string.byteslice(start, string.bytesize - start)
+ keep = string.byteslice(start,
+ string.bytesize - @scanner.pos - start)
else
keep = string
end
@@ -412,8 +414,7 @@ class CSV
else
lineno = @lineno + 1
end
- message = "Invalid byte sequence in #{@encoding}"
- raise MalformedCSVError.new(message, lineno)
+ raise InvalidEncodingError.new(@encoding, lineno)
rescue UnexpectedError => error
if @scanner
ignore_broken_line
@@ -485,7 +486,6 @@ class CSV
message = ":quote_char has to be nil or a single character String"
raise ArgumentError, message
end
- @double_quote_character = @quote_character * 2
@escaped_quote_character = Regexp.escape(@quote_character)
@escaped_quote = Regexp.new(@escaped_quote_character)
end
@@ -875,8 +875,7 @@ class CSV
!line.valid_encoding?
end
if index
- message = "Invalid byte sequence in #{@encoding}"
- raise MalformedCSVError.new(message, @lineno + index + 1)
+ raise InvalidEncodingError.new(@encoding, @lineno + index + 1)
end
end
Scanner.new(string)
diff --git a/lib/csv/version.rb b/lib/csv/version.rb
index edafc6f128..9c65803a34 100644
--- a/lib/csv/version.rb
+++ b/lib/csv/version.rb
@@ -2,5 +2,5 @@
class CSV
# The version of the installed library.
- VERSION = "3.2.7"
+ VERSION = "3.2.8"
end
diff --git a/lib/delegate.gemspec b/lib/delegate.gemspec
new file mode 100644
index 0000000000..6c3feac74b
--- /dev/null
+++ b/lib/delegate.gemspec
@@ -0,0 +1,29 @@
+# frozen_string_literal: true
+
+name = File.basename(__FILE__, ".gemspec")
+version = ["lib", Array.new(name.count("-")+1, ".").join("/")].find do |dir|
+ break File.foreach(File.join(__dir__, dir, "#{name.tr('-', '/')}.rb")) do |line|
+ /^\s*VERSION\s*=\s*"(.*)"/ =~ line and break $1
+ end rescue nil
+end
+
+Gem::Specification.new do |spec|
+ spec.name = name
+ spec.version = version
+ spec.authors = ["Yukihiro Matsumoto"]
+ spec.email = ["matz@ruby-lang.org"]
+
+ spec.summary = %q{Provides three abilities to delegate method calls to an object.}
+ spec.description = %q{Provides three abilities to delegate method calls to an object.}
+ spec.homepage = "https://github.com/ruby/delegate"
+ spec.licenses = ["Ruby", "BSD-2-Clause"]
+
+ spec.metadata["homepage_uri"] = spec.homepage
+ spec.metadata["source_code_uri"] = spec.homepage
+
+ spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
+ `git ls-files -z 2>#{IO::NULL}`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
+ end
+ spec.require_paths = ["lib"]
+ spec.required_ruby_version = '>= 2.7'
+end
diff --git a/lib/delegate.rb b/lib/delegate.rb
index 387a5f063d..4d8994d8a0 100644
--- a/lib/delegate.rb
+++ b/lib/delegate.rb
@@ -39,7 +39,7 @@
# Be advised, RDoc will not detect delegated methods.
#
class Delegator < BasicObject
- VERSION = "0.3.0"
+ VERSION = "0.3.1"
kernel = ::Kernel.dup
kernel.class_eval do
diff --git a/lib/delegate/delegate.gemspec b/lib/delegate/delegate.gemspec
deleted file mode 100644
index 1cfacfeb2f..0000000000
--- a/lib/delegate/delegate.gemspec
+++ /dev/null
@@ -1,29 +0,0 @@
-# frozen_string_literal: true
-
-name = File.basename(__FILE__, ".gemspec")
-version = ["lib", Array.new(name.count("-")+1, "..").join("/")].find do |dir|
- break File.foreach(File.join(__dir__, dir, "#{name.tr('-', '/')}.rb")) do |line|
- /^\s*VERSION\s*=\s*"(.*)"/ =~ line and break $1
- end rescue nil
-end
-
-Gem::Specification.new do |spec|
- spec.name = name
- spec.version = version
- spec.authors = ["Yukihiro Matsumoto"]
- spec.email = ["matz@ruby-lang.org"]
-
- spec.summary = %q{Provides three abilities to delegate method calls to an object.}
- spec.description = %q{Provides three abilities to delegate method calls to an object.}
- spec.homepage = "https://github.com/ruby/delegate"
- spec.licenses = ["Ruby", "BSD-2-Clause"]
-
- spec.metadata["homepage_uri"] = spec.homepage
- spec.metadata["source_code_uri"] = spec.homepage
-
- spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
- `git ls-files -z 2>/dev/null`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
- end
- spec.require_paths = ["lib"]
- spec.required_ruby_version = '>= 2.7'
-end
diff --git a/lib/drb/drb.rb b/lib/drb/drb.rb
index 23181bb834..5a85e42975 100644
--- a/lib/drb/drb.rb
+++ b/lib/drb/drb.rb
@@ -2,7 +2,7 @@
#
# = drb/drb.rb
#
-# Distributed Ruby: _dRuby_ version 2.0.4
+# Distributed Ruby: _dRuby_
#
# Copyright (c) 1999-2003 Masatoshi SEKI. You can redistribute it and/or
# modify it under the same terms as Ruby.
@@ -50,6 +50,7 @@ require 'socket'
require 'io/wait'
require 'monitor'
require_relative 'eq'
+require_relative 'version'
#
# == Overview
diff --git a/lib/drb/ssl.rb b/lib/drb/ssl.rb
index 54ab1ef395..392d6560e9 100644
--- a/lib/drb/ssl.rb
+++ b/lib/drb/ssl.rb
@@ -73,6 +73,14 @@ module DRb
# :SSLTmpDhCallback ::
# A DH callback. See OpenSSL::SSL::SSLContext.tmp_dh_callback
#
+ # :SSLMinVersion ::
+ # This is the minimum SSL version to allow. See
+ # OpenSSL::SSL::SSLContext#min_version=.
+ #
+ # :SSLMaxVersion ::
+ # This is the maximum SSL version to allow. See
+ # OpenSSL::SSL::SSLContext#max_version=.
+ #
# :SSLVerifyMode ::
# This is the SSL verification mode. See OpenSSL::SSL::VERIFY_* for
# available modes. The default is OpenSSL::SSL::VERIFY_NONE
@@ -208,6 +216,8 @@ module DRb
ctx = ::OpenSSL::SSL::SSLContext.new
ctx.cert = @cert
ctx.key = @pkey
+ ctx.min_version = self[:SSLMinVersion]
+ ctx.max_version = self[:SSLMaxVersion]
ctx.client_ca = self[:SSLClientCA]
ctx.ca_path = self[:SSLCACertificatePath]
ctx.ca_file = self[:SSLCACertificateFile]
diff --git a/lib/drb/version.rb b/lib/drb/version.rb
index 10d33445b6..73fa4c18fd 100644
--- a/lib/drb/version.rb
+++ b/lib/drb/version.rb
@@ -1,3 +1,3 @@
module DRb
- VERSION = "2.1.1"
+ VERSION = "2.2.0"
end
diff --git a/lib/erb.rb b/lib/erb.rb
index 754419f819..bc1615d7da 100644
--- a/lib/erb.rb
+++ b/lib/erb.rb
@@ -307,11 +307,11 @@ class ERB
# def build
# b = binding
# # create and run templates, filling member data variables
- # ERB.new(<<-'END_PRODUCT'.gsub(/^\s+/, ""), trim_mode: "", eoutvar: "@product").result b
+ # ERB.new(<<~'END_PRODUCT', trim_mode: "", eoutvar: "@product").result b
# <%= PRODUCT[:name] %>
# <%= PRODUCT[:desc] %>
# END_PRODUCT
- # ERB.new(<<-'END_PRICE'.gsub(/^\s+/, ""), trim_mode: "", eoutvar: "@price").result b
+ # ERB.new(<<~'END_PRICE', trim_mode: "", eoutvar: "@price").result b
# <%= PRODUCT[:name] %> -- <%= PRODUCT[:cost] %>
# <%= PRODUCT[:desc] %>
# END_PRICE
diff --git a/lib/erb/compiler.rb b/lib/erb/compiler.rb
index 547d2c4c44..7096c8dcea 100644
--- a/lib/erb/compiler.rb
+++ b/lib/erb/compiler.rb
@@ -1,3 +1,4 @@
+# frozen_string_literal: true
#--
# ERB::Compiler
#
diff --git a/lib/erb/def_method.rb b/lib/erb/def_method.rb
index 17f9c0f9fa..aee989a926 100644
--- a/lib/erb/def_method.rb
+++ b/lib/erb/def_method.rb
@@ -1,3 +1,4 @@
+# frozen_string_literal: true
#--
# ERB::DefMethod
#
diff --git a/lib/erb/util.rb b/lib/erb/util.rb
index 0c1e7482a8..1d2a36275d 100644
--- a/lib/erb/util.rb
+++ b/lib/erb/util.rb
@@ -1,3 +1,4 @@
+# frozen_string_literal: true
#--
# ERB::Escape
#
diff --git a/lib/erb/version.rb b/lib/erb/version.rb
index 38e1b76ff4..295fc5fa6f 100644
--- a/lib/erb/version.rb
+++ b/lib/erb/version.rb
@@ -1,5 +1,5 @@
# frozen_string_literal: true
class ERB
- VERSION = '4.0.2'
+ VERSION = '4.0.3'
private_constant :VERSION
end
diff --git a/lib/error_highlight/version.rb b/lib/error_highlight/version.rb
index 5afe5f06d6..506d37fbc1 100644
--- a/lib/error_highlight/version.rb
+++ b/lib/error_highlight/version.rb
@@ -1,3 +1,3 @@
module ErrorHighlight
- VERSION = "0.5.1"
+ VERSION = "0.6.0"
end
diff --git a/lib/fileutils.rb b/lib/fileutils.rb
index b495078f93..8ec5a3ad12 100644
--- a/lib/fileutils.rb
+++ b/lib/fileutils.rb
@@ -3,7 +3,7 @@
begin
require 'rbconfig'
rescue LoadError
- # for make mjit-headers
+ # for make rjit-headers
end
# Namespace for file utility methods for copying, moving, removing, etc.
@@ -180,7 +180,7 @@ end
# - {CVE-2004-0452}[https://cve.mitre.org/cgi-bin/cvename.cgi?name=CAN-2004-0452].
#
module FileUtils
- VERSION = "1.7.0"
+ VERSION = "1.7.2"
def self.private_module_function(name) #:nodoc:
module_function name
@@ -192,8 +192,6 @@ module FileUtils
#
# FileUtils.pwd # => "/rdoc/fileutils"
#
- # FileUtils.getwd is an alias for FileUtils.pwd.
- #
# Related: FileUtils.cd.
#
def pwd
@@ -235,8 +233,6 @@ module FileUtils
# cd ..
# cd fileutils
#
- # FileUtils.chdir is an alias for FileUtils.cd.
- #
# Related: FileUtils.pwd.
#
def cd(dir, verbose: nil, &block) # :yield: dir
@@ -515,8 +511,6 @@ module FileUtils
# Raises an exception if +dest+ is the path to an existing file
# and keyword argument +force+ is not +true+.
#
- # FileUtils#link is an alias for FileUtils#ln.
- #
# Related: FileUtils.link_entry (has different options).
#
def ln(src, dest, force: nil, noop: nil, verbose: nil)
@@ -707,8 +701,6 @@ module FileUtils
# ln -sf src2.txt dest2.txt
# ln -s srcdir3/src0.txt srcdir3/src1.txt destdir3
#
- # FileUtils.symlink is an alias for FileUtils.ln_s.
- #
# Related: FileUtils.ln_sf.
#
def ln_s(src, dest, force: nil, relative: false, target_directory: true, noop: nil, verbose: nil)
@@ -876,8 +868,6 @@ module FileUtils
#
# Raises an exception if +src+ is a directory.
#
- # FileUtils.copy is an alias for FileUtils.cp.
- #
# Related: {methods for copying}[rdoc-ref:FileUtils@Copying].
#
def cp(src, dest, preserve: nil, noop: nil, verbose: nil)
@@ -1164,8 +1154,6 @@ module FileUtils
# mv src0 dest0
# mv src1.txt src1 dest1
#
- # FileUtils.move is an alias for FileUtils.mv.
- #
def mv(src, dest, force: nil, noop: nil, verbose: nil, secure: nil)
fu_output_message "mv#{force ? ' -f' : ''} #{[src,dest].flatten.join ' '}" if verbose
return if noop
@@ -1223,8 +1211,6 @@ module FileUtils
#
# rm src0.dat src0.txt
#
- # FileUtils.remove is an alias for FileUtils.rm.
- #
# Related: {methods for deleting}[rdoc-ref:FileUtils@Deleting].
#
def rm(list, force: nil, noop: nil, verbose: nil)
@@ -1250,8 +1236,6 @@ module FileUtils
#
# See FileUtils.rm for keyword arguments.
#
- # FileUtils.safe_unlink is an alias for FileUtils.rm_f.
- #
# Related: {methods for deleting}[rdoc-ref:FileUtils@Deleting].
#
def rm_f(list, noop: nil, verbose: nil)
@@ -1339,8 +1323,6 @@ module FileUtils
#
# See FileUtils.rm_r for keyword arguments.
#
- # FileUtils.rmtree is an alias for FileUtils.rm_rf.
- #
# Related: {methods for deleting}[rdoc-ref:FileUtils@Deleting].
#
def rm_rf(list, noop: nil, verbose: nil, secure: nil)
@@ -1642,7 +1624,13 @@ module FileUtils
st = File.stat(s)
unless File.exist?(d) and compare_file(s, d)
remove_file d, true
- copy_file s, d
+ if d.end_with?('/')
+ mkdir_p d
+ copy_file s, d + File.basename(s)
+ else
+ mkdir_p File.expand_path('..', d)
+ copy_file s, d
+ end
File.utime st.atime, st.mtime, d if preserve
File.chmod fu_mode(mode, st), d if mode
File.chown uid, gid, d if uid or gid
diff --git a/lib/find.gemspec b/lib/find.gemspec
index 3f0aadcdae..cb845e9409 100644
--- a/lib/find.gemspec
+++ b/lib/find.gemspec
@@ -1,6 +1,13 @@
+name = File.basename(__FILE__, ".gemspec")
+version = ["lib", Array.new(name.count("-")+1).join("/")].find do |dir|
+ break File.foreach(File.join(__dir__, dir, "#{name.tr('-', '/')}.rb")) do |line|
+ /^\s*VERSION\s*=\s*"(.*)"/ =~ line and break $1
+ end rescue nil
+end
+
Gem::Specification.new do |spec|
- spec.name = "find"
- spec.version = "0.1.1"
+ spec.name = name
+ spec.version = version
spec.authors = ['Kazuki Tsujimoto']
spec.email = ['kazuki@callcc.net']
diff --git a/lib/find.rb b/lib/find.rb
index 9bee99c66d..98a79cc76d 100644
--- a/lib/find.rb
+++ b/lib/find.rb
@@ -27,6 +27,8 @@
#
module Find
+ VERSION = "0.2.0"
+
#
# Calls the associated block with the name of every file and directory listed
# as arguments, then recursively on their subdirectories, and so on.
diff --git a/lib/getoptlong.gemspec b/lib/getoptlong.gemspec
new file mode 100644
index 0000000000..c2f65dcaab
--- /dev/null
+++ b/lib/getoptlong.gemspec
@@ -0,0 +1,30 @@
+# frozen_string_literal: true
+
+name = File.basename(__FILE__, ".gemspec")
+version = ["lib", Array.new(name.count("-")+1, ".").join("/")].find do |dir|
+ break File.foreach(File.join(__dir__, dir, "#{name.tr('-', '/')}.rb")) do |line|
+ /^\s*VERSION\s*=\s*"(.*)"/ =~ line and break $1
+ end rescue nil
+end
+
+Gem::Specification.new do |spec|
+ spec.name = name
+ spec.version = version
+ spec.authors = ["Yukihiro Matsumoto"]
+ spec.email = ["matz@ruby-lang.org"]
+
+ spec.summary = %q{GetoptLong for Ruby}
+ spec.description = spec.summary
+ spec.homepage = "https://github.com/ruby/getoptlong"
+ spec.licenses = ["Ruby", "BSD-2-Clause"]
+
+ spec.metadata["homepage_uri"] = spec.homepage
+ spec.metadata["source_code_uri"] = spec.homepage
+
+ # Specify which files should be added to the gem when it is released.
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
+ spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
+ `git ls-files -z 2>#{IO::NULL}`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
+ end
+ spec.require_paths = ["lib"]
+end
diff --git a/lib/getoptlong.rb b/lib/getoptlong.rb
index 5ae0e1497c..c825962160 100644
--- a/lib/getoptlong.rb
+++ b/lib/getoptlong.rb
@@ -352,7 +352,7 @@
#
# Command line:
#
-# $ ruby fibonacci.rb --number 6 --verbose yes
+# $ ruby fibonacci.rb --number 6 --verbose yes
#
# Output:
#
@@ -368,7 +368,7 @@
#
class GetoptLong
# Version.
- VERSION = "0.2.0"
+ VERSION = "0.2.1"
#
# Orderings.
diff --git a/lib/getoptlong/getoptlong.gemspec b/lib/getoptlong/getoptlong.gemspec
deleted file mode 100644
index dfe087b886..0000000000
--- a/lib/getoptlong/getoptlong.gemspec
+++ /dev/null
@@ -1,30 +0,0 @@
-# frozen_string_literal: true
-
-name = File.basename(__FILE__, ".gemspec")
-version = ["lib", Array.new(name.count("-")+1, "..").join("/")].find do |dir|
- break File.foreach(File.join(__dir__, dir, "#{name.tr('-', '/')}.rb")) do |line|
- /^\s*VERSION\s*=\s*"(.*)"/ =~ line and break $1
- end rescue nil
-end
-
-Gem::Specification.new do |spec|
- spec.name = name
- spec.version = version
- spec.authors = ["Yukihiro Matsumoto"]
- spec.email = ["matz@ruby-lang.org"]
-
- spec.summary = %q{GetoptLong for Ruby}
- spec.description = spec.summary
- spec.homepage = "https://github.com/ruby/getoptlong"
- spec.licenses = ["Ruby", "BSD-2-Clause"]
-
- spec.metadata["homepage_uri"] = spec.homepage
- spec.metadata["source_code_uri"] = spec.homepage
-
- # Specify which files should be added to the gem when it is released.
- # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
- spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
- `git ls-files -z 2>/dev/null`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
- end
- spec.require_paths = ["lib"]
-end
diff --git a/lib/ipaddr.rb b/lib/ipaddr.rb
index 7a5cf94830..03e1c18baa 100644
--- a/lib/ipaddr.rb
+++ b/lib/ipaddr.rb
@@ -40,7 +40,7 @@ require 'socket'
# p ipaddr3 #=> #<IPAddr: IPv4:192.168.2.0/255.255.255.0>
class IPAddr
- VERSION = "1.2.5"
+ VERSION = "1.2.6"
# 32 bit mask for IPv4
IN4MASK = 0xffffffff
@@ -176,9 +176,7 @@ class IPAddr
def include?(other)
other = coerce_other(other)
return false unless other.family == family
- range = to_range
- other = other.to_range
- range.begin <= other.begin && range.end >= other.end
+ begin_addr <= other.begin_addr && end_addr >= other.end_addr
end
alias === include?
@@ -263,7 +261,8 @@ class IPAddr
# Returns true if the ipaddr is a private address. IPv4 addresses
# in 10.0.0.0/8, 172.16.0.0/12 and 192.168.0.0/16 as defined in RFC
# 1918 and IPv6 Unique Local Addresses in fc00::/7 as defined in RFC
- # 4193 are considered private.
+ # 4193 are considered private. Private IPv4 addresses in the
+ # IPv4-mapped IPv6 address range are also considered private.
def private?
case @family
when Socket::AF_INET
@@ -271,7 +270,12 @@ class IPAddr
@addr & 0xfff00000 == 0xac100000 || # 172.16.0.0/12
@addr & 0xffff0000 == 0xc0a80000 # 192.168.0.0/16
when Socket::AF_INET6
- @addr & 0xfe00_0000_0000_0000_0000_0000_0000_0000 == 0xfc00_0000_0000_0000_0000_0000_0000_0000
+ @addr & 0xfe00_0000_0000_0000_0000_0000_0000_0000 == 0xfc00_0000_0000_0000_0000_0000_0000_0000 ||
+ (@addr & 0xffff_0000_0000 == 0xffff_0000_0000 && (
+ @addr & 0xff000000 == 0x0a000000 || # ::ffff:10.0.0.0/8
+ @addr & 0xfff00000 == 0xac100000 || # ::ffff::172.16.0.0/12
+ @addr & 0xffff0000 == 0xc0a80000 # ::ffff::192.168.0.0/16
+ ))
else
raise AddressFamilyError, "unsupported address family"
end
@@ -400,17 +404,6 @@ class IPAddr
# Creates a Range object for the network address.
def to_range
- begin_addr = (@addr & @mask_addr)
-
- case @family
- when Socket::AF_INET
- end_addr = (@addr | (IN4MASK ^ @mask_addr))
- when Socket::AF_INET6
- end_addr = (@addr | (IN6MASK ^ @mask_addr))
- else
- raise AddressFamilyError, "unsupported address family"
- end
-
self.class.new(begin_addr, @family)..self.class.new(end_addr, @family)
end
@@ -491,6 +484,21 @@ class IPAddr
protected
+ def begin_addr
+ @addr & @mask_addr
+ end
+
+ def end_addr
+ case @family
+ when Socket::AF_INET
+ @addr | (IN4MASK ^ @mask_addr)
+ when Socket::AF_INET6
+ @addr | (IN6MASK ^ @mask_addr)
+ else
+ raise AddressFamilyError, "unsupported address family"
+ end
+ end
+
# Set +@addr+, the internal stored ip address, to given +addr+. The
# parameter +addr+ is validated using the first +family+ member,
# which is +Socket::AF_INET+ or +Socket::AF_INET6+.
diff --git a/lib/irb.rb b/lib/irb.rb
index 96dbaaa65b..006b52bec5 100644
--- a/lib/irb.rb
+++ b/lib/irb.rb
@@ -12,287 +12,846 @@ require_relative "irb/context"
require_relative "irb/extend-command"
require_relative "irb/ruby-lex"
+require_relative "irb/statement"
require_relative "irb/input-method"
require_relative "irb/locale"
require_relative "irb/color"
require_relative "irb/version"
require_relative "irb/easter-egg"
+require_relative "irb/debug"
+require_relative "irb/pager"
-# IRB stands for "interactive Ruby" and is a tool to interactively execute Ruby
-# expressions read from the standard input.
-#
-# The +irb+ command from your shell will start the interpreter.
-#
-# == Usage
-#
-# Use of irb is easy if you know Ruby.
-#
-# When executing irb, prompts are displayed as follows. Then, enter the Ruby
-# expression. An input is executed when it is syntactically complete.
-#
-# $ irb
-# irb(main):001:0> 1+2
-# #=> 3
-# irb(main):002:0> class Foo
-# irb(main):003:1> def foo
-# irb(main):004:2> print 1
-# irb(main):005:2> end
-# irb(main):006:1> end
-# #=> nil
-#
-# The singleline editor module or multiline editor module can be used with irb.
-# Use of multiline editor is default if it's installed.
-#
-# == Command line options
-#
-# :include: ./irb/lc/help-message
-#
-# == Commands
-#
-# The following commands are available on IRB.
-#
-# * cwws
-# * Show the current workspace.
-# * cb, cws, chws
-# * Change the current workspace to an object.
-# * bindings, workspaces
-# * Show workspaces.
-# * pushb, pushws
-# * Push an object to the workspace stack.
-# * popb, popws
-# * Pop a workspace from the workspace stack.
-# * load
-# * Load a Ruby file.
-# * require
-# * Require a Ruby file.
-# * source
-# * Loads a given file in the current session.
-# * irb
-# * Start a child IRB.
-# * jobs
-# * List of current sessions.
-# * fg
-# * Switches to the session of the given number.
-# * kill
-# * Kills the session with the given number.
-# * help
-# * Enter the mode to look up RI documents.
-# * irb_info
-# * Show information about IRB.
-# * ls
-# * Show methods, constants, and variables.
-# -g [query] or -G [query] allows you to filter out the output.
-# * measure
-# * measure enables the mode to measure processing time. measure :off disables it.
-# * $, show_source
-# * Show the source code of a given method or constant.
-# * @, whereami
-# * Show the source code around binding.irb again.
-# * debug
-# * Start the debugger of debug.gem.
-# * break, delete, next, step, continue, finish, backtrace, info, catch
-# * Start the debugger of debug.gem and run the command on it.
-#
-# == Configuration
-#
-# IRB reads a personal initialization file when it's invoked.
-# IRB searches a file in the following order and loads the first one found.
-#
-# * <tt>$IRBRC</tt> (if <tt>$IRBRC</tt> is set)
-# * <tt>$XDG_CONFIG_HOME/irb/irbrc</tt> (if <tt>$XDG_CONFIG_HOME</tt> is set)
-# * <tt>~/.irbrc</tt>
-# * +.config/irb/irbrc+
-# * +.irbrc+
-# * +irb.rc+
-# * +_irbrc+
-# * <code>$irbrc</code>
-#
-# The following are alternatives to the command line options. To use them type
-# as follows in an +irb+ session:
-#
-# IRB.conf[:IRB_NAME]="irb"
-# IRB.conf[:INSPECT_MODE]=nil
-# IRB.conf[:IRB_RC] = nil
-# IRB.conf[:BACK_TRACE_LIMIT]=16
-# IRB.conf[:USE_LOADER] = false
-# IRB.conf[:USE_MULTILINE] = nil
-# IRB.conf[:USE_SINGLELINE] = nil
-# IRB.conf[:USE_COLORIZE] = true
-# IRB.conf[:USE_TRACER] = false
-# IRB.conf[:USE_AUTOCOMPLETE] = true
-# IRB.conf[:IGNORE_SIGINT] = true
-# IRB.conf[:IGNORE_EOF] = false
-# IRB.conf[:PROMPT_MODE] = :DEFAULT
-# IRB.conf[:PROMPT] = {...}
-#
-# === Auto indentation
-#
-# To disable auto-indent mode in irb, add the following to your +.irbrc+:
-#
-# IRB.conf[:AUTO_INDENT] = false
-#
-# === Autocompletion
-#
-# To disable autocompletion for irb, add the following to your +.irbrc+:
-#
-# IRB.conf[:USE_AUTOCOMPLETE] = false
-#
-# === History
-#
-# By default, irb will store the last 1000 commands you used in
-# <code>IRB.conf[:HISTORY_FILE]</code> (<code>~/.irb_history</code> by default).
-#
-# If you want to disable history, add the following to your +.irbrc+:
-#
-# IRB.conf[:SAVE_HISTORY] = nil
-#
-# See IRB::Context#save_history= for more information.
-#
-# The history of _results_ of commands evaluated is not stored by default,
-# but can be turned on to be stored with this +.irbrc+ setting:
-#
-# IRB.conf[:EVAL_HISTORY] = <number>
-#
-# See IRB::Context#eval_history= and History class. The history of command
-# results is not permanently saved in any file.
-#
-# == Customizing the IRB Prompt
-#
-# In order to customize the prompt, you can change the following Hash:
-#
-# IRB.conf[:PROMPT]
-#
-# This example can be used in your +.irbrc+
-#
-# IRB.conf[:PROMPT][:MY_PROMPT] = { # name of prompt mode
-# :AUTO_INDENT => false, # disables auto-indent mode
-# :PROMPT_I => ">> ", # simple prompt
-# :PROMPT_S => nil, # prompt for continuated strings
-# :PROMPT_C => nil, # prompt for continuated statement
-# :RETURN => " ==>%s\n" # format to return value
-# }
-#
-# IRB.conf[:PROMPT_MODE] = :MY_PROMPT
-#
-# Or, invoke irb with the above prompt mode by:
-#
-# irb --prompt my-prompt
-#
-# Constants +PROMPT_I+, +PROMPT_S+ and +PROMPT_C+ specify the format. In the
-# prompt specification, some special strings are available:
-#
-# %N # command name which is running
-# %m # to_s of main object (self)
-# %M # inspect of main object (self)
-# %l # type of string(", ', /, ]), `]' is inner %w[...]
-# %NNi # indent level. NN is digits and means as same as printf("%NNd").
-# # It can be omitted
-# %NNn # line number.
-# %% # %
-#
-# For instance, the default prompt mode is defined as follows:
-#
-# IRB.conf[:PROMPT_MODE][:DEFAULT] = {
-# :PROMPT_I => "%N(%m):%03n:%i> ",
-# :PROMPT_N => "%N(%m):%03n:%i> ",
-# :PROMPT_S => "%N(%m):%03n:%i%l ",
-# :PROMPT_C => "%N(%m):%03n:%i* ",
-# :RETURN => "%s\n" # used to printf
-# }
-#
-# irb comes with a number of available modes:
-#
-# # :NULL:
-# # :PROMPT_I:
-# # :PROMPT_N:
-# # :PROMPT_S:
-# # :PROMPT_C:
-# # :RETURN: |
-# # %s
-# # :DEFAULT:
-# # :PROMPT_I: ! '%N(%m):%03n:%i> '
-# # :PROMPT_N: ! '%N(%m):%03n:%i> '
-# # :PROMPT_S: ! '%N(%m):%03n:%i%l '
-# # :PROMPT_C: ! '%N(%m):%03n:%i* '
-# # :RETURN: |
-# # => %s
-# # :CLASSIC:
-# # :PROMPT_I: ! '%N(%m):%03n:%i> '
-# # :PROMPT_N: ! '%N(%m):%03n:%i> '
-# # :PROMPT_S: ! '%N(%m):%03n:%i%l '
-# # :PROMPT_C: ! '%N(%m):%03n:%i* '
-# # :RETURN: |
-# # %s
-# # :SIMPLE:
-# # :PROMPT_I: ! '>> '
-# # :PROMPT_N: ! '>> '
-# # :PROMPT_S:
-# # :PROMPT_C: ! '?> '
-# # :RETURN: |
-# # => %s
-# # :INF_RUBY:
-# # :PROMPT_I: ! '%N(%m):%03n:%i> '
-# # :PROMPT_N:
-# # :PROMPT_S:
-# # :PROMPT_C:
-# # :RETURN: |
-# # %s
-# # :AUTO_INDENT: true
-# # :XMP:
-# # :PROMPT_I:
-# # :PROMPT_N:
-# # :PROMPT_S:
-# # :PROMPT_C:
-# # :RETURN: |2
-# # ==>%s
+# == \IRB
#
-# == Restrictions
+# \Module \IRB ("Interactive Ruby") provides a shell-like interface
+# that supports user interaction with the Ruby interpreter.
#
-# Because irb evaluates input immediately after it is syntactically complete,
-# the results may be slightly different than directly using Ruby.
+# It operates as a <i>read-eval-print loop</i>
+# ({REPL}[https://en.wikipedia.org/wiki/Read%E2%80%93eval%E2%80%93print_loop])
+# that:
#
-# == IRB Sessions
+# - <b>_Reads_</b> each character as you type.
+# You can modify the \IRB context to change the way input works.
+# See {Input}[rdoc-ref:IRB@Input].
+# - <b>_Evaluates_</b> the code each time it has read a syntactically complete passage.
+# - <b>_Prints_</b> after evaluating.
+# You can modify the \IRB context to change the way output works.
+# See {Output}[rdoc-ref:IRB@Output].
#
-# IRB has a special feature, that allows you to manage many sessions at once.
+# Example:
#
-# You can create new sessions with Irb.irb, and get a list of current sessions
-# with the +jobs+ command in the prompt.
+# $ irb
+# irb(main):001> File.basename(Dir.pwd)
+# => "irb"
+# irb(main):002> Dir.entries('.').size
+# => 25
+# irb(main):003* Dir.entries('.').select do |entry|
+# irb(main):004* entry.start_with?('R')
+# irb(main):005> end
+# => ["README.md", "Rakefile"]
#
-# === Commands
+# The typed input may also include
+# {\IRB-specific commands}[rdoc-ref:IRB@IRB-Specific+Commands].
+#
+# As seen above, you can start \IRB by using the shell command +irb+.
+#
+# You can stop an \IRB session by typing command +exit+:
+#
+# irb(main):006> exit
+# $
+#
+# At that point, \IRB calls any hooks found in array <tt>IRB.conf[:AT_EXIT]</tt>,
+# then exits.
+#
+# == Startup
+#
+# At startup, \IRB:
+#
+# 1. Interprets (as Ruby code) the content of the
+# {configuration file}[rdoc-ref:IRB@Configuration+File] (if given).
+# 1. Constructs the initial session context
+# from {hash IRB.conf}[rdoc-ref:IRB@Hash+IRB.conf] and from default values;
+# the hash content may have been affected
+# by {command-line options}[rdoc-ref:IB@Command-Line+Options],
+# and by direct assignments in the configuration file.
+# 1. Assigns the context to variable +conf+.
+# 1. Assigns command-line arguments to variable <tt>ARGV</tt>.
+# 1. Prints the {prompt}[rdoc-ref:IRB@Prompt+and+Return+Formats].
+# 1. Puts the content of the
+# {initialization script}[rdoc-ref:IRB@Initialization+Script]
+# onto the \IRB shell, just as if it were user-typed commands.
+#
+# === The Command Line
+#
+# On the command line, all options precede all arguments;
+# the first item that is not recognized as an option is treated as an argument,
+# as are all items that follow.
+#
+# ==== Command-Line Options
+#
+# Many command-line options affect entries in hash <tt>IRB.conf</tt>,
+# which in turn affect the initial configuration of the \IRB session.
+#
+# Details of the options are described in the relevant subsections below.
+#
+# A cursory list of the \IRB command-line options
+# may be seen in the {help message}[https://raw.githubusercontent.com/ruby/irb/master/lib/irb/lc/help-message],
+# which is also displayed if you use command-line option <tt>--help</tt>.
+#
+# If you are interested in a specific option, consult the
+# {index}[rdoc-ref:doc/irb/indexes.md@Index+of+Command-Line+Options].
+#
+# ==== Command-Line Arguments
+#
+# Command-line arguments are passed to \IRB in array +ARGV+:
+#
+# $ irb --noscript Foo Bar Baz
+# irb(main):001> ARGV
+# => ["Foo", "Bar", "Baz"]
+# irb(main):002> exit
+# $
+#
+# Command-line option <tt>--</tt> causes everything that follows
+# to be treated as arguments, even those that look like options:
+#
+# $ irb --noscript -- --noscript -- Foo Bar Baz
+# irb(main):001> ARGV
+# => ["--noscript", "--", "Foo", "Bar", "Baz"]
+# irb(main):002> exit
+# $
+#
+# === Configuration File
+#
+# You can initialize \IRB via a <i>configuration file</i>.
+#
+# If command-line option <tt>-f</tt> is given,
+# no configuration file is looked for.
+#
+# Otherwise, \IRB reads and interprets a configuration file
+# if one is available.
+#
+# The configuration file can contain any Ruby code, and can usefully include
+# user code that:
+#
+# - Can then be debugged in \IRB.
+# - Configures \IRB itself.
+# - Requires or loads files.
+#
+# The path to the configuration file is the first found among:
+#
+# - The value of variable <tt>$IRBRC</tt>, if defined.
+# - The value of variable <tt>$XDG_CONFIG_HOME/irb/irbrc</tt>, if defined.
+# - File <tt>$HOME/.irbrc</tt>, if it exists.
+# - File <tt>$HOME/.config/irb/irbrc</tt>, if it exists.
+# - File +.config/irb/irbrc+ in the current directory, if it exists.
+# - File +.irbrc+ in the current directory, if it exists.
+# - File +irb.rc+ in the current directory, if it exists.
+# - File +_irbrc+ in the current directory, if it exists.
+# - File <tt>$irbrc</tt> in the current directory, if it exists.
+#
+# If the search fails, there is no configuration file.
+#
+# If the search succeeds, the configuration file is read as Ruby code,
+# and so can contain any Ruby programming you like.
+#
+# \Method <tt>conf.rc?</tt> returns +true+ if a configuration file was read,
+# +false+ otherwise.
+# \Hash entry <tt>IRB.conf[:RC]</tt> also contains that value.
+#
+# === \Hash <tt>IRB.conf</tt>
+#
+# The initial entries in hash <tt>IRB.conf</tt> are determined by:
+#
+# - Default values.
+# - Command-line options, which may override defaults.
+# - Direct assignments in the configuration file.
+#
+# You can see the hash by typing <tt>IRB.conf</tt>.
+#
+# Details of the entries' meanings are described in the relevant subsections below.
+#
+# If you are interested in a specific entry, consult the
+# {index}[rdoc-ref:doc/irb/indexes.md@Index+of+IRB.conf+Entries].
+#
+# === Notes on Initialization Precedence
+#
+# - Any conflict between an entry in hash <tt>IRB.conf</tt> and a command-line option
+# is resolved in favor of the hash entry.
+# - \Hash <tt>IRB.conf</tt> affects the context only once,
+# when the configuration file is interpreted;
+# any subsequent changes to it do not affect the context
+# and are therefore essentially meaningless.
+#
+# === Initialization Script
+#
+# By default, the first command-line argument (after any options)
+# is the path to a Ruby initialization script.
+#
+# \IRB reads the initialization script and puts its content onto the \IRB shell,
+# just as if it were user-typed commands.
+#
+# Command-line option <tt>--noscript</tt> causes the first command-line argument
+# to be treated as an ordinary argument (instead of an initialization script);
+# <tt>--script</tt> is the default.
+#
+# == Input
+#
+# This section describes the features that allow you to change
+# the way \IRB input works;
+# see also {Input and Output}[rdoc-ref:IRB@Input+and+Output].
+#
+# === Input Command History
+#
+# By default, \IRB stores a history of up to 1000 input commands
+# in file <tt>~/.irb_history</tt>
+# (or, if a {configuration file}[rdoc-ref:IRB@Configuration+File]
+# is found, in file +.irb_history+
+# inin the same directory as that file).
+#
+# A new \IRB session creates the history file if it does not exist,
+# and appends to the file if it does exist.
+#
+# You can change the filepath by adding to your configuration file:
+# <tt>IRB.conf[:HISTORY_FILE] = _filepath_</tt>,
+# where _filepath_ is a string filepath.
+#
+# During the session, method <tt>conf.history_file</tt> returns the filepath,
+# and method <tt>conf.history_file = <i>new_filepath</i></tt>
+# copies the history to the file at <i>new_filepath</i>,
+# which becomes the history file for the session.
+#
+# You can change the number of commands saved by adding to your configuration file:
+# <tt>IRB.conf[:SAVE_HISTORY] = _n_</tt>,
+# where _n_ is one of:
+#
+# - Positive integer: the number of commands to be saved,
+# - Zero: all commands are to be saved.
+# - +nil+: no commands are to be saved,.
+#
+# During the session, you can use
+# methods <tt>conf.save_history</tt> or <tt>conf.save_history=</tt>
+# to retrieve or change the count.
+#
+# === Command Aliases
+#
+# By default, \IRB defines several command aliases:
+#
+# irb(main):001> conf.command_aliases
+# => {:"$"=>:show_source, :"@"=>:whereami}
+#
+# You can change the initial aliases in the configuration file with:
+#
+# IRB.conf[:COMMAND_ALIASES] = {foo: :show_source, bar: :whereami}
+#
+# You can replace the current aliases at any time
+# with configuration method <tt>conf.command_aliases=</tt>;
+# Because <tt>conf.command_aliases</tt> is a hash,
+# you can modify it.
+#
+# === End-of-File
+#
+# By default, <tt>IRB.conf[:IGNORE_EOF]</tt> is +false+,
+# which means that typing the end-of-file character <tt>Ctrl-D</tt>
+# causes the session to exit.
+#
+# You can reverse that behavior by adding <tt>IRB.conf[:IGNORE_EOF] = true</tt>
+# to the configuration file.
+#
+# During the session, method <tt>conf.ignore_eof?</tt> returns the setting,
+# and method <tt>conf.ignore_eof = _boolean_</tt> sets it.
+#
+# === SIGINT
+#
+# By default, <tt>IRB.conf[:IGNORE_SIGINT]</tt> is +true+,
+# which means that typing the interrupt character <tt>Ctrl-C</tt>
+# causes the session to exit.
+#
+# You can reverse that behavior by adding <tt>IRB.conf[:IGNORE_SIGING] = false</tt>
+# to the configuration file.
+#
+# During the session, method <tt>conf.ignore_siging?</tt> returns the setting,
+# and method <tt>conf.ignore_sigint = _boolean_</tt> sets it.
+#
+# === Automatic Completion
+#
+# By default, \IRB enables
+# {automatic completion}[https://en.wikipedia.org/wiki/Autocomplete#In_command-line_interpreters]:
+#
+# You can disable it by either of these:
+#
+# - Adding <tt>IRB.conf[:USE_AUTOCOMPLETE] = false</tt> to the configuration file.
+# - Giving command-line option <tt>--noautocomplete</tt>
+# (<tt>--autocomplete</tt> is the default).
+#
+# \Method <tt>conf.use_autocomplete?</tt> returns +true+
+# if automatic completion is enabled, +false+ otherwise.
+#
+# The setting may not be changed during the session.
+#
+# === Automatic Indentation
+#
+# By default, \IRB automatically indents lines of code to show structure
+# (e.g., it indent the contents of a block).
+#
+# The current setting is returned
+# by the configuration method <tt>conf.auto_indent_mode</tt>.
+#
+# The default initial setting is +true+:
+#
+# irb(main):001> conf.auto_indent_mode
+# => true
+# irb(main):002* Dir.entries('.').select do |entry|
+# irb(main):003* entry.start_with?('R')
+# irb(main):004> end
+# => ["README.md", "Rakefile"]
+#
+# You can change the initial setting in the
+# configuration file with:
+#
+# IRB.conf[:AUTO_INDENT] = false
+#
+# Note that the _current_ setting <i>may not</i> be changed in the \IRB session.
+#
+# === Input \Method
+#
+# The \IRB input method determines how command input is to be read;
+# by default, the input method for a session is IRB::RelineInputMethod.
+#
+# You can set the input method by:
+#
+# - Adding to the configuration file:
+#
+# - <tt>IRB.conf[:USE_SINGLELINE] = true</tt>
+# or <tt>IRB.conf[:USE_MULTILINE]= false</tt>
+# sets the input method to IRB::ReadlineInputMethod.
+# - <tt>IRB.conf[:USE_SINGLELINE] = false</tt>
+# or <tt>IRB.conf[:USE_MULTILINE] = true</tt>
+# sets the input method to IRB::RelineInputMethod.
+#
+# - Giving command-line options:
+#
+# - <tt>--singleline</tt>
+# or <tt>--nomultiline</tt>
+# sets the input method to IRB::ReadlineInputMethod.
+# - <tt>--nosingleline</tt>
+# or <tt>--multiline/tt>
+# sets the input method to IRB::RelineInputMethod.
+#
+# \Method <tt>conf.use_multiline?</tt>
+# and its synonym <tt>conf.use_reline</tt> return:
+#
+# - +true+ if option <tt>--multiline</tt> was given.
+# - +false+ if option <tt>--nomultiline</tt> was given.
+# - +nil+ if neither was given.
+#
+# \Method <tt>conf.use_singleline?</tt>
+# and its synonym <tt>conf.use_readline</tt> return:
+#
+# - +true+ if option <tt>--singleline</tt> was given.
+# - +false+ if option <tt>--nosingleline</tt> was given.
+# - +nil+ if neither was given.
+#
+# == Output
+#
+# This section describes the features that allow you to change
+# the way \IRB output works;
+# see also {Input and Output}[rdoc-ref:IRB@Input+and+Output].
+#
+# === Return-Value Printing (Echoing)
+#
+# By default, \IRB prints (echoes) the values returned by all input commands.
+#
+# You can change the initial behavior and suppress all echoing by:
+#
+# - Adding to the configuration file: <tt>IRB.conf[:ECHO] = false</tt>.
+# (The default value for this entry is +niL+, which means the same as +true+.)
+# - Giving command-line option <tt>--noecho</tt>.
+# (The default is <tt>--echo</tt>.)
+#
+# During the session, you can change the current setting
+# with configuration method <tt>conf.echo=</tt> (set to +true+ or +false+).
+#
+# As stated above, by default \IRB prints the values returned by all input commands;
+# but \IRB offers special treatment for values returned by assignment statements,
+# which may be:
+#
+# - Printed with truncation (to fit on a single line of output),
+# which is the default;
+# an ellipsis (<tt>...</tt> is suffixed, to indicate the truncation):
+#
+# irb(main):001> x = 'abc' * 100
+# => "abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc...
+#
+# - Printed in full (regardless of the length).
+# - Suppressed (not printed at all)
+#
+# You can change the initial behavior by:
+#
+# - Adding to the configuration file: <tt>IRB.conf[:ECHO_ON_ASSIGNMENT] = false</tt>.
+# (The default value for this entry is +niL+, which means the same as +:truncate+.)
+# - Giving command-line option <tt>--noecho-on-assignment</tt>
+# or <tt>--echo-on-assignment</tt>.
+# (The default is <tt>--truncate-echo-on-assigment</tt>.)
+#
+# During the session, you can change the current setting
+# with configuration method <tt>conf.echo_on_assignment=</tt>
+# (set to +true+, +false+, or +:truncate+).
+#
+# By default, \IRB formats returned values by calling method +inspect+.
+#
+# You can change the initial behavior by:
+#
+# - Adding to the configuration file: <tt>IRB.conf[:INSPECT_MODE] = false</tt>.
+# (The default value for this entry is +true+.)
+# - Giving command-line option <tt>--noinspect</tt>.
+# (The default is <tt>--inspect</tt>.)
+#
+# During the session, you can change the setting using method <tt>conf.inspect_mode=</tt>.
+#
+# === Multiline Output
+#
+# By default, \IRB prefixes a newline to a multiline response.
+#
+# You can change the initial default value by adding to the configuation file:
+#
+# IRB.conf[:NEWLINE_BEFORE_MULTILINE_OUTPUT] = false
+#
+# During a session, you can retrieve or set the value using
+# methods <tt>conf.newline_before_multiline_output?</tt>
+# and <tt>conf.newline_before_multiline_output=</tt>.
+#
+# Examples:
+#
+# irb(main):001> conf.inspect_mode = false
+# => false
+# irb(main):002> "foo\nbar"
+# =>
+# foo
+# bar
+# irb(main):003> conf.newline_before_multiline_output = false
+# => false
+# irb(main):004> "foo\nbar"
+# => foo
+# bar
+#
+# === Evaluation History
+#
+# By default, \IRB saves no history of evaluations (returned values),
+# and the related methods <tt>conf.eval_history</tt>, <tt>_</tt>,
+# and <tt>__</tt> are undefined.
+#
+# You can turn on that history, and set the maximum number of evaluations to be stored:
+#
+# - In the configuration file: add <tt>IRB.conf[:EVAL_HISTORY] = _n_</tt>.
+# (Examples below assume that we've added <tt>IRB.conf[:EVAL_HISTORY] = 5</tt>.)
+# - In the session (at any time): <tt>conf.eval_history = _n_</tt>.
+#
+# If +n+ is zero, all evaluation history is stored.
+#
+# Doing either of the above:
+#
+# - Sets the maximum size of the evaluation history;
+# defines method <tt>conf.eval_history</tt>,
+# which returns the maximum size +n+ of the evaluation history:
+#
+# irb(main):001> conf.eval_history = 5
+# => 5
+# irb(main):002> conf.eval_history
+# => 5
+#
+# - Defines variable <tt>_</tt>, which contains the most recent evaluation,
+# or +nil+ if none; same as method <tt>conf.last_value</tt>:
+#
+# irb(main):003> _
+# => 5
+# irb(main):004> :foo
+# => :foo
+# irb(main):005> :bar
+# => :bar
+# irb(main):006> _
+# => :bar
+# irb(main):007> _
+# => :bar
+#
+# - Defines variable <tt>__</tt>:
+#
+# - <tt>__</tt> unadorned: contains all evaluation history:
+#
+# irb(main):008> :foo
+# => :foo
+# irb(main):009> :bar
+# => :bar
+# irb(main):010> :baz
+# => :baz
+# irb(main):011> :bat
+# => :bat
+# irb(main):012> :bam
+# => :bam
+# irb(main):013> __
+# =>
+# 9 :bar
+# 10 :baz
+# 11 :bat
+# 12 :bam
+# irb(main):014> __
+# =>
+# 10 :baz
+# 11 :bat
+# 12 :bam
+# 13 ...self-history...
+#
+# Note that when the evaluation is multiline, it is displayed differently.
+#
+# - <tt>__[</tt>_m_<tt>]</tt>:
+#
+# - Positive _m_: contains the evaluation for the given line number,
+# or +nil+ if that line number is not in the evaluation history:
+#
+# irb(main):015> __[12]
+# => :bam
+# irb(main):016> __[1]
+# => nil
+#
+# - Negative _m_: contains the +mth+-from-end evaluation,
+# or +nil+ if that evaluation is not in the evaluation history:
+#
+# irb(main):017> __[-3]
+# => :bam
+# irb(main):018> __[-13]
+# => nil
+#
+# - Zero _m_: contains +nil+:
+#
+# irb(main):019> __[0]
+# => nil
+#
+# === Prompt and Return Formats
+#
+# By default, \IRB uses the prompt and return value formats
+# defined in its +:DEFAULT+ prompt mode.
+#
+# ==== The Default Prompt and Return Format
+#
+# The default prompt and return values look like this:
+#
+# irb(main):001> 1 + 1
+# => 2
+# irb(main):002> 2 + 2
+# => 4
+#
+# The prompt includes:
+#
+# - The name of the running program (<tt>irb</tt>);
+# see {IRB Name}[rdoc-ref:IRB@IRB+Name].
+# - The name of the current session (<tt>main</tt>);
+# See {IRB Sessions}[rdoc-ref:IRB@IRB+Sessions].
+# - A 3-digit line number (1-based).
+#
+# The default prompt actually defines three formats:
+#
+# - One for most situations (as above):
+#
+# irb(main):003> Dir
+# => Dir
+#
+# - One for when the typed command is a statement continuation (adds trailing asterisk):
+#
+# irb(main):004* Dir.
+#
+# - One for when the typed command is a string continuation (adds trailing single-quote):
+#
+# irb(main):005' Dir.entries('.
+#
+# You can see the prompt change as you type the characters in the following:
+#
+# irb(main):001* Dir.entries('.').select do |entry|
+# irb(main):002* entry.start_with?('R')
+# irb(main):003> end
+# => ["README.md", "Rakefile"]
+#
+# ==== Pre-Defined Prompts
+#
+# \IRB has several pre-defined prompts, stored in hash <tt>IRB.conf[:PROMPT]</tt>:
+#
+# irb(main):001> IRB.conf[:PROMPT].keys
+# => [:NULL, :DEFAULT, :CLASSIC, :SIMPLE, :INF_RUBY, :XMP]
+#
+# To see the full data for these, type <tt>IRB.conf[:PROMPT]</tt>.
+#
+# Most of these prompt definitions include specifiers that represent
+# values like the \IRB name, session name, and line number;
+# see {Prompt Specifiers}[rdoc-ref:IRB@Prompt+Specifiers].
+#
+# You can change the initial prompt and return format by:
+#
+# - Adding to the configuration file: <tt>IRB.conf[:PROMPT] = _mode_</tt>
+# where _mode_ is the symbol name of a prompt mode.
+# - Giving a command-line option:
+#
+# - <tt>--prompt _mode_</tt>: sets the prompt mode to _mode_.
+# where _mode_ is the symbol name of a prompt mode.
+# - <tt>--simple-prompt</tt> or <tt>--sample-book-mode</tt>:
+# sets the prompt mode to +:SIMPLE+.
+# - <tt>--inf-ruby-mode</tt>: sets the prompt mode to +:INF_RUBY+
+# and suppresses both <tt>--multiline</tt> and <tt>--singleline</tt>.
+# - <tt>--noprompt</tt>: suppresses prompting; does not affect echoing.
+#
+# You can retrieve or set the current prompt mode with methods
+#
+# <tt>conf.prompt_mode</tt> and <tt>conf.prompt_mode=</tt>.
+#
+# If you're interested in prompts and return formats other than the defaults,
+# you might experiment by trying some of the others.
+#
+# ==== Custom Prompts
+#
+# You can also define custom prompts and return formats,
+# which may be done either in an \IRB session or in the configuration file.
+#
+# A prompt in \IRB actually defines three prompts, as seen above.
+# For simple custom data, we'll make all three the same:
+#
+# irb(main):001* IRB.conf[:PROMPT][:MY_PROMPT] = {
+# irb(main):002* PROMPT_I: ': ',
+# irb(main):003* PROMPT_C: ': ',
+# irb(main):004* PROMPT_S: ': ',
+# irb(main):005* RETURN: '=> '
+# irb(main):006> }
+# => {:PROMPT_I=>": ", :PROMPT_C=>": ", :PROMPT_S=>": ", :RETURN=>"=> "}
+#
+# If you define the custom prompt in the configuration file,
+# you can also make it the current prompt by adding:
+#
+# IRB.conf[:PROMPT_MODE] = :MY_PROMPT
+#
+# Regardless of where it's defined, you can make it the current prompt in a session:
+#
+# conf.prompt_mode = :MY_PROMPT
+#
+# You can view or modify the current prompt data with various configuration methods:
+#
+# - <tt>conf.prompt_mode</tt>, <tt>conf.prompt_mode=</tt>.
+# - <tt>conf.prompt_c</tt>, <tt>conf.c=</tt>.
+# - <tt>conf.prompt_i</tt>, <tt>conf.i=</tt>.
+# - <tt>conf.prompt_s</tt>, <tt>conf.s=</tt>.
+# - <tt>conf.return_format</tt>, <tt>return_format=</tt>.
+#
+# ==== Prompt Specifiers
+#
+# A prompt's definition can include specifiers for which certain values are substituted:
+#
+# - <tt>%N</tt>: the name of the running program.
+# - <tt>%m</tt>: the value of <tt>self.to_s</tt>.
+# - <tt>%M</tt>: the value of <tt>self.inspect</tt>.
+# - <tt>%l</tt>: an indication of the type of string;
+# one of <tt>"</tt>, <tt>'</tt>, <tt>/</tt>, <tt>]</tt>.
+# - <tt><i>NN</i>i</tt>: Indentation level.
+# - <tt><i>NN</i>n</tt>: Line number.
+# - <tt>%%</tt>: Literal <tt>%</tt>.
+#
+# === Verbosity
+#
+# By default, \IRB verbosity is disabled, which means that output is smaller
+# rather than larger.
+#
+# You can enable verbosity by:
+#
+# - Adding to the configuration file: <tt>IRB.conf[:VERBOSE] = true</tt>
+# (the default is +nil+).
+# - Giving command-line options <tt>--verbose</tt>
+# (the default is <tt>--noverbose</tt>).
+#
+# During a session, you can retrieve or set verbosity with methods
+# <tt>conf.verbose</tt> and <tt>conf.verbose=</tt>.
+#
+# === Help
+#
+# Command-line option <tt>--version</tt> causes \IRB to print its help text
+# and exit.
+#
+# === Version
+#
+# Command-line option <tt>--version</tt> causes \IRB to print its version text
+# and exit.
+#
+# == Input and Output
+#
+# === \Color Highlighting
+#
+# By default, \IRB color highlighting is enabled, and is used for both:
+#
+# - Input: As you type, \IRB reads the typed characters and highlights
+# elements that it recognizes;
+# it also highlights errors such as mismatched parentheses.
+# - Output: \IRB highlights syntactical elements.
+#
+# You can disable color highlighting by:
+#
+# - Adding to the configuration file: <tt>IRB.conf[:USE_COLORIZE] = false</tt>
+# (the default value is +true+).
+# - Giving command-line option <tt>--nocolorize</tt>
+#
+# == Debugging
+#
+# Command-line option <tt>-d</tt> sets variables <tt>$VERBOSE</tt>
+# and <tt>$DEBUG</tt> to +true+;
+# these have no effect on \IRB output.
+#
+# === Warnings
+#
+# Command-line option <tt>-w</tt> suppresses warnings.
+#
+# Command-line option <tt>-W[_level_]<tt>
+# sets warning level; 0=silence, 1=medium, 2=verbose.
+#
+# :stopdoc:
+# === Performance Measurement
+#
+# IRB.conf[:MEASURE] IRB.conf[:MEASURE_CALLBACKS] IRB.conf[:MEASURE_PROC]
+# :startdoc:
+#
+# == Other Features
+#
+# === Load Modules
+#
+# You can specify the names of modules that are to be required at startup.
+#
+# \Array <tt>conf.load_modules</tt> determines the modules (if any)
+# that are to be required during session startup.
+# The array is used only during session startup,
+# so the initial value is the only one that counts.
+#
+# The default initial value is <tt>[]</tt> (load no modules):
+#
+# irb(main):001> conf.load_modules
+# => []
+#
+# You can set the default initial value via:
+#
+# - Command-line option <tt>-r</tt>
+#
+# $ irb -r csv -r json
+# irb(main):001> conf.load_modules
+# => ["csv", "json"]
+#
+# - \Hash entry <tt>IRB.conf[:LOAD_MODULES] = _array_</tt>:
+#
+# IRB.conf[:LOAD_MODULES] = %w[csv, json]
+#
+# Note that the configuration file entry overrides the command-line options.
+#
+# === RI Documentation Directories
+#
+# You can specify the paths to RI documentation directories
+# that are to be loaded (in addition to the default directories) at startup;
+# see details about RI by typing <tt>ri --help</tt>.
+#
+# \Array <tt>conf.extra_doc_dirs</tt> determines the directories (if any)
+# that are to be loaded during session startup.
+# The array is used only during session startup,
+# so the initial value is the only one that counts.
+#
+# The default initial value is <tt>[]</tt> (load no extra documentation):
+#
+# irb(main):001> conf.extra_doc_dirs
+# => []
+#
+# You can set the default initial value via:
+#
+# - Command-line option <tt>--extra_doc_dir</tt>
+#
+# $ irb --extra-doc-dir your_doc_dir --extra-doc-dir my_doc_dir
+# irb(main):001> conf.extra_doc_dirs
+# => ["your_doc_dir", "my_doc_dir"]
+#
+# - \Hash entry <tt>IRB.conf[:EXTRA_DOC_DIRS] = _array_</tt>:
+#
+# IRB.conf[:EXTRA_DOC_DIRS] = %w[your_doc_dir my_doc_dir]
+#
+# Note that the configuration file entry overrides the command-line options.
+#
+# :stopdoc:
+# === \Context Mode
+#
+# IRB.conf[:CONTEXT_MODE]
+# :startdoc:
+#
+# === \IRB Name
+#
+# You can specify a name for \IRB.
#
-# JobManager provides commands to handle the current sessions:
+# The default initial value is <tt>'irb'</tt>:
#
-# jobs # List of current sessions
-# fg # Switches to the session of the given number
-# kill # Kills the session with the given number
+# irb(main):001> conf.irb_name
+# => "irb"
#
-# The +exit+ command, or ::irb_exit, will quit the current session and call any
-# exit hooks with IRB.irb_at_exit.
+# You can set the default initial value
+# via hash entry <tt>IRB.conf[:IRB_NAME] = _string_</tt>:
#
-# A few commands for loading files within the session are also available:
+# IRB.conf[:IRB_NAME] = 'foo'
#
-# +source+::
-# Loads a given file in the current session and displays the source lines,
-# see IrbLoader#source_file
-# +irb_load+::
-# Loads the given file similarly to Kernel#load, see IrbLoader#irb_load
-# +irb_require+::
-# Loads the given file similarly to Kernel#require
+# === Application Name
#
-# === Configuration
+# You can specify an application name for the \IRB session.
+#
+# The default initial value is <tt>'irb'</tt>:
+#
+# irb(main):001> conf.ap_name
+# => "irb"
+#
+# You can set the default initial value
+# via hash entry <tt>IRB.conf[:AP_NAME] = _string_</tt>:
+#
+# IRB.conf[:AP_NAME] = 'my_ap_name'
+#
+# === Configuration Monitor
+#
+# You can monitor changes to the configuration by assigning a proc
+# to <tt>IRB.conf[:IRB_RC]</tt> in the configuration file:
+#
+# IRB.conf[:IRB_RC] = proc {|conf| puts conf.class }
+#
+# Each time the configuration is changed,
+# that proc is called with argument +conf+:
+#
+# :stopdoc:
+# === \Locale
+#
+# IRB.conf[:LC_MESSAGES]
+# :startdoc:
+#
+# === Encodings
+#
+# Command-line option <tt>-E _ex_[:_in_]</tt>
+# sets initial external (ex) and internal (in) encodings.
+#
+# Command-line option <tt>-U</tt> sets both to UTF-8.
+#
+# === Commands
+#
+# Please use the `show_cmds` command to see the list of available commands.
+#
+# === IRB Sessions
+#
+# IRB has a special feature, that allows you to manage many sessions at once.
+#
+# You can create new sessions with Irb.irb, and get a list of current sessions
+# with the +jobs+ command in the prompt.
+#
+# ==== Configuration
#
# The command line options, or IRB.conf, specify the default behavior of
# Irb.irb.
#
-# On the other hand, each conf in IRB@Command+line+options is used to
+# On the other hand, each conf in IRB@Command-Line+Options is used to
# individually configure IRB.irb.
#
# If a proc is set for <code>IRB.conf[:IRB_RC]</code>, its will be invoked after execution
# of that proc with the context of the current session as its argument. Each
# session can be configured using this mechanism.
#
-# === Session variables
+# ==== Session variables
#
# There are a few variables in every Irb session that can come in handy:
#
@@ -307,91 +866,19 @@ require_relative "irb/easter-egg"
# If +line_no+ is a negative, the return value +line_no+ many lines before
# the most recent return value.
#
-# === Example using IRB Sessions
-#
-# # invoke a new session
-# irb(main):001:0> irb
-# # list open sessions
-# irb.1(main):001:0> jobs
-# #0->irb on main (#<Thread:0x400fb7e4> : stop)
-# #1->irb#1 on main (#<Thread:0x40125d64> : running)
-#
-# # change the active session
-# irb.1(main):002:0> fg 0
-# # define class Foo in top-level session
-# irb(main):002:0> class Foo;end
-# # invoke a new session with the context of Foo
-# irb(main):003:0> irb Foo
-# # define Foo#foo
-# irb.2(Foo):001:0> def foo
-# irb.2(Foo):002:1> print 1
-# irb.2(Foo):003:1> end
-#
-# # change the active session
-# irb.2(Foo):004:0> fg 0
-# # list open sessions
-# irb(main):004:0> jobs
-# #0->irb on main (#<Thread:0x400fb7e4> : running)
-# #1->irb#1 on main (#<Thread:0x40125d64> : stop)
-# #2->irb#2 on Foo (#<Thread:0x4011d54c> : stop)
-# # check if Foo#foo is available
-# irb(main):005:0> Foo.instance_methods #=> [:foo, ...]
-#
-# # change the active session
-# irb(main):006:0> fg 2
-# # define Foo#bar in the context of Foo
-# irb.2(Foo):005:0> def bar
-# irb.2(Foo):006:1> print "bar"
-# irb.2(Foo):007:1> end
-# irb.2(Foo):010:0> Foo.instance_methods #=> [:bar, :foo, ...]
-#
-# # change the active session
-# irb.2(Foo):011:0> fg 0
-# irb(main):007:0> f = Foo.new #=> #<Foo:0x4010af3c>
-# # invoke a new session with the context of f (instance of Foo)
-# irb(main):008:0> irb f
-# # list open sessions
-# irb.3(<Foo:0x4010af3c>):001:0> jobs
-# #0->irb on main (#<Thread:0x400fb7e4> : stop)
-# #1->irb#1 on main (#<Thread:0x40125d64> : stop)
-# #2->irb#2 on Foo (#<Thread:0x4011d54c> : stop)
-# #3->irb#3 on #<Foo:0x4010af3c> (#<Thread:0x4010a1e0> : running)
-# # evaluate f.foo
-# irb.3(<Foo:0x4010af3c>):002:0> foo #=> 1 => nil
-# # evaluate f.bar
-# irb.3(<Foo:0x4010af3c>):003:0> bar #=> bar => nil
-# # kill jobs 1, 2, and 3
-# irb.3(<Foo:0x4010af3c>):004:0> kill 1, 2, 3
-# # list open sessions, should only include main session
-# irb(main):009:0> jobs
-# #0->irb on main (#<Thread:0x400fb7e4> : running)
-# # quit irb
-# irb(main):010:0> exit
+# == Restrictions
+#
+# Ruby code typed into \IRB behaves the same as Ruby code in a file, except that:
+#
+# - Because \IRB evaluates input immediately after it is syntactically complete,
+# some results may be slightly different.
+# - Forking may not be well behaved.
+#
module IRB
# An exception raised by IRB.irb_abort
class Abort < Exception;end
- @CONF = {}
-
-
- # Displays current configuration.
- #
- # Modifying the configuration is achieved by sending a message to IRB.conf.
- #
- # See IRB@Configuration for more information.
- def IRB.conf
- @CONF
- end
-
- # Returns the current version of IRB, including release version and last
- # updated date.
- def IRB.version
- if v = @CONF[:VERSION] then return v end
-
- @CONF[:VERSION] = format("irb %s (%s)", @RELEASE_VERSION, @LAST_UPDATE_DATE)
- end
-
# The current IRB::Context of the session, see IRB.conf
#
# irb
@@ -416,11 +903,6 @@ module IRB
irb.run(@CONF)
end
- # Calls each event hook of <code>IRB.conf[:AT_EXIT]</code> when the current session quits.
- def IRB.irb_at_exit
- @CONF[:AT_EXIT].each{|hook| hook.call}
- end
-
# Quits irb
def IRB.irb_exit(irb, ret)
throw :IRB_EXIT, ret
@@ -434,46 +916,32 @@ module IRB
end
class Irb
- ASSIGNMENT_NODE_TYPES = [
- # Local, instance, global, class, constant, instance, and index assignment:
- # "foo = bar",
- # "@foo = bar",
- # "$foo = bar",
- # "@@foo = bar",
- # "::Foo = bar",
- # "a::Foo = bar",
- # "Foo = bar"
- # "foo.bar = 1"
- # "foo[1] = bar"
- :assign,
-
- # Operation assignment:
- # "foo += bar"
- # "foo -= bar"
- # "foo ||= bar"
- # "foo &&= bar"
- :opassign,
-
- # Multiple assignment:
- # "foo, bar = 1, 2
- :massign,
- ]
# Note: instance and index assignment expressions could also be written like:
# "foo.bar=(1)" and "foo.[]=(1, bar)", when expressed that way, the former
# be parsed as :assign and echo will be suppressed, but the latter is
# parsed as a :method_add_arg and the output won't be suppressed
+ PROMPT_MAIN_TRUNCATE_LENGTH = 32
+ PROMPT_MAIN_TRUNCATE_OMISSION = '...'.freeze
+ CONTROL_CHARACTERS_PATTERN = "\x00-\x1F".freeze
+
+ # Returns the current context of this irb session
+ attr_reader :context
+ # The lexer used by this irb session
+ attr_accessor :scanner
+
# Creates a new irb session
def initialize(workspace = nil, input_method = nil)
@context = Context.new(self, workspace, input_method)
- @context.main.extend ExtendCommandBundle
+ @context.workspace.load_commands_to_main
@signal_status = :IN_IRB
- @scanner = RubyLex.new(@context)
+ @scanner = RubyLex.new
+ @line_no = 1
end
- # A hook point for `debug` command's TracePoint after :IRB_EXIT as well as its clean-up
+ # A hook point for `debug` command's breakpoint after :IRB_EXIT as well as its clean-up
def debug_break
- # it means the debug command is executed
+ # it means the debug integration has been activated
if defined?(DEBUGGER__) && DEBUGGER__.respond_to?(:capture_frames_without_irb)
# after leaving this initial breakpoint, revert the capture_frames patch
DEBUGGER__.singleton_class.send(:alias_method, :capture_frames, :capture_frames_without_irb)
@@ -482,10 +950,49 @@ module IRB
end
end
+ def debug_readline(binding)
+ workspace = IRB::WorkSpace.new(binding)
+ context.workspace = workspace
+ context.workspace.load_commands_to_main
+ @line_no += 1
+
+ # When users run:
+ # 1. Debugging commands, like `step 2`
+ # 2. Any input that's not irb-command, like `foo = 123`
+ #
+ # Irb#eval_input will simply return the input, and we need to pass it to the debugger.
+ input = if IRB.conf[:SAVE_HISTORY] && context.io.support_history_saving?
+ # Previous IRB session's history has been saved when `Irb#run` is exited
+ # We need to make sure the saved history is not saved again by reseting the counter
+ context.io.reset_history_counter
+
+ begin
+ eval_input
+ ensure
+ context.io.save_history
+ end
+ else
+ eval_input
+ end
+
+ if input&.include?("\n")
+ @line_no += input.count("\n") - 1
+ end
+
+ input
+ end
+
def run(conf = IRB.conf)
+ in_nested_session = !!conf[:MAIN_CONTEXT]
conf[:IRB_RC].call(context) if conf[:IRB_RC]
conf[:MAIN_CONTEXT] = context
+ save_history = !in_nested_session && conf[:SAVE_HISTORY] && context.io.support_history_saving?
+
+ if save_history
+ context.io.load_history
+ end
+
prev_trap = trap("SIGINT") do
signal_handle
end
@@ -497,93 +1004,26 @@ module IRB
ensure
trap("SIGINT", prev_trap)
conf[:AT_EXIT].each{|hook| hook.call}
+ context.io.save_history if save_history
end
end
- # Returns the current context of this irb session
- attr_reader :context
- # The lexer used by this irb session
- attr_accessor :scanner
-
# Evaluates input for this session.
def eval_input
- exc = nil
-
- @scanner.set_prompt do
- |ltype, indent, continue, line_no|
- if ltype
- f = @context.prompt_s
- elsif continue
- f = @context.prompt_c
- elsif indent > 0
- f = @context.prompt_n
- else
- f = @context.prompt_i
- end
- f = "" unless f
- if @context.prompting?
- @context.io.prompt = p = prompt(f, ltype, indent, line_no)
- else
- @context.io.prompt = p = ""
- end
- if @context.auto_indent_mode and !@context.io.respond_to?(:auto_indent)
- unless ltype
- prompt_i = @context.prompt_i.nil? ? "" : @context.prompt_i
- ind = prompt(prompt_i, ltype, indent, line_no)[/.*\z/].size +
- indent * 2 - p.size
- ind += 2 if continue
- @context.io.prompt = p + " " * ind if ind > 0
- end
- end
- @context.io.prompt
- end
+ configure_io
- @scanner.set_input(@context.io) do
- signal_status(:IN_INPUT) do
- if l = @context.io.gets
- print l if @context.verbose?
- else
- if @context.ignore_eof? and @context.io.readable_after_eof?
- l = "\n"
- if @context.verbose?
- printf "Use \"exit\" to leave %s\n", @context.ap_name
- end
- else
- print "\n" if @context.prompting?
- end
- end
- l
- end
- end
-
- @scanner.set_auto_indent
-
- @scanner.each_top_level_statement do |line, line_no|
+ each_top_level_statement do |statement, line_no|
signal_status(:IN_EVAL) do
begin
- line.untaint if RUBY_VERSION < '2.7'
- if IRB.conf[:MEASURE] && IRB.conf[:MEASURE_CALLBACKS].empty?
- IRB.set_measure_callback
- end
- # Assignment expression check should be done before @context.evaluate to handle code like `a /2#/ if false; a = 1`
- is_assignment = assignment_expression?(line)
- if IRB.conf[:MEASURE] && !IRB.conf[:MEASURE_CALLBACKS].empty?
- result = nil
- last_proc = proc{ result = @context.evaluate(line, line_no, exception: exc) }
- IRB.conf[:MEASURE_CALLBACKS].inject(last_proc) { |chain, item|
- _name, callback, arg = item
- proc {
- callback.(@context, line, line_no, arg, exception: exc) do
- chain.call
- end
- }
- }.call
- @context.set_last_value(result)
- else
- @context.evaluate(line, line_no, exception: exc)
+ # If the integration with debugger is activated, we return certain input if it should be dealt with by debugger
+ if @context.with_debugger && statement.should_be_handled_by_debugger?
+ return statement.code
end
- if @context.echo?
- if is_assignment
+
+ @context.evaluate(statement.evaluable_code, line_no)
+
+ if @context.echo? && !statement.suppresses_echo?
+ if statement.is_assignment?
if @context.echo_on_assignment?
output_value(@context.echo_on_assignment? == :truncate)
end
@@ -591,17 +1031,146 @@ module IRB
output_value
end
end
- rescue Interrupt => exc
rescue SystemExit, SignalException
raise
- rescue Exception => exc
+ rescue Interrupt, Exception => exc
+ handle_exception(exc)
+ @context.workspace.local_variable_set(:_, exc)
+ end
+ end
+ end
+ end
+
+ def read_input(prompt)
+ signal_status(:IN_INPUT) do
+ @context.io.prompt = prompt
+ if l = @context.io.gets
+ print l if @context.verbose?
+ else
+ if @context.ignore_eof? and @context.io.readable_after_eof?
+ l = "\n"
+ if @context.verbose?
+ printf "Use \"exit\" to leave %s\n", @context.ap_name
+ end
else
- exc = nil
- next
+ print "\n" if @context.prompting?
end
- handle_exception(exc)
- @context.workspace.local_variable_set(:_, exc)
- exc = nil
+ end
+ l
+ end
+ end
+
+ def readmultiline
+ prompt = generate_prompt([], false, 0)
+
+ # multiline
+ return read_input(prompt) if @context.io.respond_to?(:check_termination)
+
+ # nomultiline
+ code = ''
+ line_offset = 0
+ loop do
+ line = read_input(prompt)
+ unless line
+ return code.empty? ? nil : code
+ end
+
+ code << line
+
+ # Accept any single-line input for symbol aliases or commands that transform args
+ return code if single_line_command?(code)
+
+ tokens, opens, terminated = @scanner.check_code_state(code, local_variables: @context.local_variables)
+ return code if terminated
+
+ line_offset += 1
+ continue = @scanner.should_continue?(tokens)
+ prompt = generate_prompt(opens, continue, line_offset)
+ end
+ end
+
+ def each_top_level_statement
+ loop do
+ code = readmultiline
+ break unless code
+
+ if code != "\n"
+ yield build_statement(code), @line_no
+ end
+ @line_no += code.count("\n")
+ rescue RubyLex::TerminateLineInput
+ end
+ end
+
+ def build_statement(code)
+ code.force_encoding(@context.io.encoding)
+ command_or_alias, arg = code.split(/\s/, 2)
+ # Transform a non-identifier alias (@, $) or keywords (next, break)
+ command_name = @context.command_aliases[command_or_alias.to_sym]
+ command = command_name || command_or_alias
+ command_class = ExtendCommandBundle.load_command(command)
+
+ if command_class
+ Statement::Command.new(code, command, arg, command_class)
+ else
+ is_assignment_expression = @scanner.assignment_expression?(code, local_variables: @context.local_variables)
+ Statement::Expression.new(code, is_assignment_expression)
+ end
+ end
+
+ def single_line_command?(code)
+ command = code.split(/\s/, 2).first
+ @context.symbol_alias?(command) || @context.transform_args?(command)
+ end
+
+ def configure_io
+ if @context.io.respond_to?(:check_termination)
+ @context.io.check_termination do |code|
+ if Reline::IOGate.in_pasting?
+ rest = @scanner.check_termination_in_prev_line(code, local_variables: @context.local_variables)
+ if rest
+ Reline.delete_text
+ rest.bytes.reverse_each do |c|
+ Reline.ungetc(c)
+ end
+ true
+ else
+ false
+ end
+ else
+ # Accept any single-line input for symbol aliases or commands that transform args
+ next true if single_line_command?(code)
+
+ _tokens, _opens, terminated = @scanner.check_code_state(code, local_variables: @context.local_variables)
+ terminated
+ end
+ end
+ end
+ if @context.io.respond_to?(:dynamic_prompt)
+ @context.io.dynamic_prompt do |lines|
+ lines << '' if lines.empty?
+ tokens = RubyLex.ripper_lex_without_warning(lines.map{ |l| l + "\n" }.join, local_variables: @context.local_variables)
+ line_results = IRB::NestingParser.parse_by_line(tokens)
+ tokens_until_line = []
+ line_results.map.with_index do |(line_tokens, _prev_opens, next_opens, _min_depth), line_num_offset|
+ line_tokens.each do |token, _s|
+ # Avoid appending duplicated token. Tokens that include "\n" like multiline tstring_content can exist in multiple lines.
+ tokens_until_line << token if token != tokens_until_line.last
+ end
+ continue = @scanner.should_continue?(tokens_until_line)
+ generate_prompt(next_opens, continue, line_num_offset)
+ end
+ end
+ end
+
+ if @context.io.respond_to?(:auto_indent) and @context.auto_indent_mode
+ @context.io.auto_indent do |lines, line_index, byte_pointer, is_newline|
+ next nil if lines == [nil] # Workaround for exit IRB with CTRL+d
+ next nil if !is_newline && lines[line_index]&.byteslice(0, byte_pointer)&.match?(/\A\s*\z/)
+
+ code = lines[0..line_index].map { |l| "#{l}\n" }.join
+ tokens = RubyLex.ripper_lex_without_warning(code, local_variables: @context.local_variables)
+ @scanner.process_indent_level(tokens, lines, line_index, is_newline)
end
end
end
@@ -636,7 +1205,7 @@ module IRB
end
def handle_exception(exc)
- if exc.backtrace && exc.backtrace[0] =~ /\/irb(2)?(\/.*|-.*|\.rb)?:/ && exc.class.to_s !~ /^IRB/ &&
+ if exc.backtrace[0] =~ /\/irb(2)?(\/.*|-.*|\.rb)?:/ && exc.class.to_s !~ /^IRB/ &&
!(SyntaxError === exc) && !(EncodingError === exc)
# The backtrace of invalid encoding hash (ex. {"\xAE": 1}) raises EncodingError without lineno.
irb_bug = true
@@ -644,45 +1213,49 @@ module IRB
irb_bug = false
end
- if exc.backtrace
- order = nil
- if RUBY_VERSION < '3.0.0'
- if STDOUT.tty?
- message = exc.full_message(order: :bottom)
- order = :bottom
- else
- message = exc.full_message(order: :top)
- order = :top
- end
- else # '3.0.0' <= RUBY_VERSION
+ if RUBY_VERSION < '3.0.0'
+ if STDOUT.tty?
+ message = exc.full_message(order: :bottom)
+ order = :bottom
+ else
message = exc.full_message(order: :top)
order = :top
end
- message = convert_invalid_byte_sequence(message, exc.message.encoding)
- message = encode_with_invalid_byte_sequence(message, IRB.conf[:LC_MESSAGES].encoding) unless message.encoding.to_s.casecmp?(IRB.conf[:LC_MESSAGES].encoding.to_s)
- message = message.gsub(/((?:^\t.+$\n)+)/) { |m|
- case order
- when :top
- lines = m.split("\n")
- when :bottom
- lines = m.split("\n").reverse
- end
- unless irb_bug
- lines = lines.map { |l| @context.workspace.filter_backtrace(l) }.compact
- if lines.size > @context.back_trace_limit
- omit = lines.size - @context.back_trace_limit
- lines = lines[0..(@context.back_trace_limit - 1)]
- lines << "\t... %d levels..." % omit
- end
+ else # '3.0.0' <= RUBY_VERSION
+ message = exc.full_message(order: :top)
+ order = :top
+ end
+ message = convert_invalid_byte_sequence(message, exc.message.encoding)
+ message = encode_with_invalid_byte_sequence(message, IRB.conf[:LC_MESSAGES].encoding) unless message.encoding.to_s.casecmp?(IRB.conf[:LC_MESSAGES].encoding.to_s)
+ message = message.gsub(/((?:^\t.+$\n)+)/) { |m|
+ case order
+ when :top
+ lines = m.split("\n")
+ when :bottom
+ lines = m.split("\n").reverse
+ end
+ unless irb_bug
+ lines = lines.map { |l| @context.workspace.filter_backtrace(l) }.compact
+ if lines.size > @context.back_trace_limit
+ omit = lines.size - @context.back_trace_limit
+ lines = lines[0..(@context.back_trace_limit - 1)]
+ lines << "\t... %d levels..." % omit
end
- lines = lines.reverse if order == :bottom
- lines.map{ |l| l + "\n" }.join
- }
- # The "<top (required)>" in "(irb)" may be the top level of IRB so imitate the main object.
- message = message.gsub(/\(irb\):(?<num>\d+):in `<(?<frame>top \(required\))>'/) { "(irb):#{$~[:num]}:in `<main>'" }
- puts message
+ end
+ lines = lines.reverse if order == :bottom
+ lines.map{ |l| l + "\n" }.join
+ }
+ # The "<top (required)>" in "(irb)" may be the top level of IRB so imitate the main object.
+ message = message.gsub(/\(irb\):(?<num>\d+):in `<(?<frame>top \(required\))>'/) { "(irb):#{$~[:num]}:in `<main>'" }
+ puts message
+ puts 'Maybe IRB bug!' if irb_bug
+ rescue Exception => handler_exc
+ begin
+ puts exc.inspect
+ puts "backtraces are hidden because #{handler_exc} was raised when processing them"
+ rescue Exception
+ puts 'Uninspectable exception occurred'
end
- print "Maybe IRB bug!\n" if irb_bug
end
# Evaluates the given block using the given +path+ as the Context#irb_path
@@ -730,16 +1303,6 @@ module IRB
end
end
- # Evaluates the given block using the given +context+ as the Context.
- def suspend_context(context)
- @context, back_context = context, @context
- begin
- yield back_context
- ensure
- @context = back_context
- end
- end
-
# Handler for the signal SIGINT, see Kernel#trap for more information.
def signal_handle
unless @context.ignore_sigint?
@@ -775,45 +1338,6 @@ module IRB
end
end
- def prompt(prompt, ltype, indent, line_no) # :nodoc:
- p = prompt.dup
- p.gsub!(/%([0-9]+)?([a-zA-Z])/) do
- case $2
- when "N"
- @context.irb_name
- when "m"
- @context.main.to_s
- when "M"
- @context.main.inspect
- when "l"
- ltype
- when "i"
- if indent < 0
- if $1
- "-".rjust($1.to_i)
- else
- "-"
- end
- else
- if $1
- format("%" + $1 + "d", indent)
- else
- indent.to_s
- end
- end
- when "n"
- if $1
- format("%" + $1 + "d", line_no)
- else
- line_no.to_s
- end
- when "%"
- "%"
- end
- end
- p
- end
-
def output_value(omit = false) # :nodoc:
str = @context.inspect_last_value
multiline_p = str.include?("\n")
@@ -843,11 +1367,12 @@ module IRB
end
end
end
+
if multiline_p && @context.newline_before_multiline_output?
- printf @context.return_format, "\n#{str}"
- else
- printf @context.return_format, str
+ str = "\n" + str
end
+
+ Pager.page_content(format(@context.return_format, str), retain_content: true)
end
# Outputs the local variables to this current session, including
@@ -867,50 +1392,85 @@ module IRB
format("#<%s: %s>", self.class, ary.join(", "))
end
- def assignment_expression?(line)
- # Try to parse the line and check if the last of possibly multiple
- # expressions is an assignment type.
-
- # If the expression is invalid, Ripper.sexp should return nil which will
- # result in false being returned. Any valid expression should return an
- # s-expression where the second element of the top level array is an
- # array of parsed expressions. The first element of each expression is the
- # expression's type.
- verbose, $VERBOSE = $VERBOSE, nil
- code = "#{RubyLex.generate_local_variables_assign_code(@context.local_variables) || 'nil;'}\n#{line}"
- # Get the last node_type of the line. drop(1) is to ignore the local_variables_assign_code part.
- node_type = Ripper.sexp(code)&.dig(1)&.drop(1)&.dig(-1, 0)
- ASSIGNMENT_NODE_TYPES.include?(node_type)
- ensure
- $VERBOSE = verbose
- end
+ private
- ATTR_TTY = "\e[%sm"
- def ATTR_TTY.[](*a) self % a.join(";"); end
- ATTR_PLAIN = ""
- def ATTR_PLAIN.[](*) self; end
- end
+ def generate_prompt(opens, continue, line_offset)
+ ltype = @scanner.ltype_from_open_tokens(opens)
+ indent = @scanner.calc_indent_level(opens)
+ continue = opens.any? || continue
+ line_no = @line_no + line_offset
- def @CONF.inspect
- IRB.version unless self[:VERSION]
-
- array = []
- for k, v in sort{|a1, a2| a1[0].id2name <=> a2[0].id2name}
- case k
- when :MAIN_CONTEXT, :__TMP__EHV__
- array.push format("CONF[:%s]=...myself...", k.id2name)
- when :PROMPT
- s = v.collect{
- |kk, vv|
- ss = vv.collect{|kkk, vvv| ":#{kkk.id2name}=>#{vvv.inspect}"}
- format(":%s=>{%s}", kk.id2name, ss.join(", "))
- }
- array.push format("CONF[:%s]={%s}", k.id2name, s.join(", "))
+ if ltype
+ f = @context.prompt_s
+ elsif continue
+ f = @context.prompt_c
+ else
+ f = @context.prompt_i
+ end
+ f = "" unless f
+ if @context.prompting?
+ p = format_prompt(f, ltype, indent, line_no)
else
- array.push format("CONF[:%s]=%s", k.id2name, v.inspect)
+ p = ""
+ end
+ if @context.auto_indent_mode and !@context.io.respond_to?(:auto_indent)
+ unless ltype
+ prompt_i = @context.prompt_i.nil? ? "" : @context.prompt_i
+ ind = format_prompt(prompt_i, ltype, indent, line_no)[/.*\z/].size +
+ indent * 2 - p.size
+ p += " " * ind if ind > 0
+ end
+ end
+ p
+ end
+
+ def truncate_prompt_main(str) # :nodoc:
+ str = str.tr(CONTROL_CHARACTERS_PATTERN, ' ')
+ if str.size <= PROMPT_MAIN_TRUNCATE_LENGTH
+ str
+ else
+ str[0, PROMPT_MAIN_TRUNCATE_LENGTH - PROMPT_MAIN_TRUNCATE_OMISSION.size] + PROMPT_MAIN_TRUNCATE_OMISSION
+ end
+ end
+
+ def format_prompt(format, ltype, indent, line_no) # :nodoc:
+ format.gsub(/%([0-9]+)?([a-zA-Z])/) do
+ case $2
+ when "N"
+ @context.irb_name
+ when "m"
+ main_str = @context.main.to_s rescue "!#{$!.class}"
+ truncate_prompt_main(main_str)
+ when "M"
+ main_str = @context.main.inspect rescue "!#{$!.class}"
+ truncate_prompt_main(main_str)
+ when "l"
+ ltype
+ when "i"
+ if indent < 0
+ if $1
+ "-".rjust($1.to_i)
+ else
+ "-"
+ end
+ else
+ if $1
+ format("%" + $1 + "d", indent)
+ else
+ indent.to_s
+ end
+ end
+ when "n"
+ if $1
+ format("%" + $1 + "d", line_no)
+ else
+ line_no.to_s
+ end
+ when "%"
+ "%"
+ end
end
end
- array.join("\n")
end
end
@@ -970,15 +1530,34 @@ class Binding
# irb(#<Potato:0x00007feea1916670>):005:0> exit
# Cooked potato: true
#
- #
- # See IRB@IRB+Usage for more information.
+ # See IRB for more information.
def irb(show_code: true)
+ # Setup IRB with the current file's path and no command line arguments
IRB.setup(source_location[0], argv: [])
+ # Create a new workspace using the current binding
workspace = IRB::WorkSpace.new(self)
+ # Print the code around the binding if show_code is true
STDOUT.print(workspace.code_around_binding) if show_code
- binding_irb = IRB::Irb.new(workspace)
- binding_irb.context.irb_path = File.expand_path(source_location[0])
- binding_irb.run(IRB.conf)
- binding_irb.debug_break
+ # Get the original IRB instance
+ debugger_irb = IRB.instance_variable_get(:@debugger_irb)
+
+ irb_path = File.expand_path(source_location[0])
+
+ if debugger_irb
+ # If we're already in a debugger session, set the workspace and irb_path for the original IRB instance
+ debugger_irb.context.workspace = workspace
+ debugger_irb.context.irb_path = irb_path
+ # If we've started a debugger session and hit another binding.irb, we don't want to start an IRB session
+ # instead, we want to resume the irb:rdbg session.
+ IRB::Debug.setup(debugger_irb)
+ IRB::Debug.insert_debug_break
+ debugger_irb.debug_break
+ else
+ # If we're not in a debugger session, create a new IRB instance with the current workspace
+ binding_irb = IRB::Irb.new(workspace)
+ binding_irb.context.irb_path = irb_path
+ binding_irb.run(IRB.conf)
+ binding_irb.debug_break
+ end
end
end
diff --git a/lib/irb/cmd/chws.rb b/lib/irb/cmd/chws.rb
index 44712fa445..31045f9bbb 100644
--- a/lib/irb/cmd/chws.rb
+++ b/lib/irb/cmd/chws.rb
@@ -13,7 +13,7 @@ module IRB
module ExtendCommand
class CurrentWorkingWorkspace < Nop
- category "IRB"
+ category "Workspace"
description "Show the current workspace."
def execute(*obj)
@@ -22,7 +22,7 @@ module IRB
end
class ChangeWorkspace < Nop
- category "IRB"
+ category "Workspace"
description "Change the current workspace to an object."
def execute(*obj)
diff --git a/lib/irb/cmd/debug.rb b/lib/irb/cmd/debug.rb
index 7d39b9fa27..e236084ca4 100644
--- a/lib/irb/cmd/debug.rb
+++ b/lib/irb/cmd/debug.rb
@@ -1,4 +1,5 @@
require_relative "nop"
+require_relative "../debug"
module IRB
# :stopdoc:
@@ -12,37 +13,46 @@ module IRB
'<internal:prelude>',
binding.method(:irb).source_location.first,
].map { |file| /\A#{Regexp.escape(file)}:\d+:in `irb'\z/ }
- IRB_DIR = File.expand_path('..', __dir__)
def execute(pre_cmds: nil, do_cmds: nil)
- unless binding_irb?
- puts "`debug` command is only available when IRB is started with binding.irb"
- return
- end
+ if irb_context.with_debugger
+ # If IRB is already running with a debug session, throw the command and IRB.debug_readline will pass it to the debugger.
+ if cmd = pre_cmds || do_cmds
+ throw :IRB_EXIT, cmd
+ else
+ puts "IRB is already running with a debug session."
+ return
+ end
+ else
+ # If IRB is not running with a debug session yet, then:
+ # 1. Check if the debugging command is run from a `binding.irb` call.
+ # 2. If so, try setting up the debug gem.
+ # 3. Insert a debug breakpoint at `Irb#debug_break` with the intended command.
+ # 4. Exit the current Irb#run call via `throw :IRB_EXIT`.
+ # 5. `Irb#debug_break` will be called and trigger the breakpoint, which will run the intended command.
+ unless binding_irb?
+ puts "Debugging commands are only available when IRB is started with binding.irb"
+ return
+ end
- unless setup_debugger
- puts <<~MSG
- You need to install the debug gem before using this command.
- If you use `bundle exec`, please add `gem "debug"` into your Gemfile.
- MSG
- return
- end
+ if IRB.respond_to?(:JobManager)
+ warn "Can't start the debugger when IRB is running in a multi-IRB session."
+ return
+ end
- options = { oneshot: true, hook_call: false }
- if pre_cmds || do_cmds
- options[:command] = ['irb', pre_cmds, do_cmds]
- end
- if DEBUGGER__::LineBreakpoint.instance_method(:initialize).parameters.include?([:key, :skip_src])
- options[:skip_src] = true
- end
+ unless IRB::Debug.setup(irb_context.irb)
+ puts <<~MSG
+ You need to install the debug gem before using this command.
+ If you use `bundle exec`, please add `gem "debug"` into your Gemfile.
+ MSG
+ return
+ end
- # To make debugger commands like `next` or `continue` work without asking
- # the user to quit IRB after that, we need to exit IRB first and then hit
- # a TracePoint on #debug_break.
- file, lineno = IRB::Irb.instance_method(:debug_break).source_location
- DEBUGGER__::SESSION.add_line_breakpoint(file, lineno + 1, **options)
- # exit current Irb#run call
- throw :IRB_EXIT
+ IRB::Debug.insert_debug_break(pre_cmds: pre_cmds, do_cmds: do_cmds)
+
+ # exit current Irb#run call
+ throw :IRB_EXIT
+ end
end
private
@@ -54,72 +64,6 @@ module IRB
end
end
end
-
- module SkipPathHelperForIRB
- def skip_internal_path?(path)
- # The latter can be removed once https://github.com/ruby/debug/issues/866 is resolved
- super || path.match?(IRB_DIR) || path.match?('<internal:prelude>')
- end
- end
-
- def setup_debugger
- unless defined?(DEBUGGER__::SESSION)
- begin
- require "debug/session"
- rescue LoadError # debug.gem is not written in Gemfile
- return false unless load_bundled_debug_gem
- end
- DEBUGGER__.start(nonstop: true)
- end
-
- unless DEBUGGER__.respond_to?(:capture_frames_without_irb)
- DEBUGGER__.singleton_class.send(:alias_method, :capture_frames_without_irb, :capture_frames)
-
- def DEBUGGER__.capture_frames(*args)
- frames = capture_frames_without_irb(*args)
- frames.reject! do |frame|
- frame.realpath&.start_with?(IRB_DIR) || frame.path == "<internal:prelude>"
- end
- frames
- end
-
- DEBUGGER__::ThreadClient.prepend(SkipPathHelperForIRB)
- end
-
- true
- end
-
- # This is used when debug.gem is not written in Gemfile. Even if it's not
- # installed by `bundle install`, debug.gem is installed by default because
- # it's a bundled gem. This method tries to activate and load that.
- def load_bundled_debug_gem
- # Discover latest debug.gem under GEM_PATH
- debug_gem = Gem.paths.path.flat_map { |path| Dir.glob("#{path}/gems/debug-*") }.select do |path|
- File.basename(path).match?(/\Adebug-\d+\.\d+\.\d+(\w+)?\z/)
- end.sort_by do |path|
- Gem::Version.new(File.basename(path).delete_prefix('debug-'))
- end.last
- return false unless debug_gem
-
- # Discover debug/debug.so under extensions for Ruby 3.2+
- ext_name = "/debug/debug.#{RbConfig::CONFIG['DLEXT']}"
- ext_path = Gem.paths.path.flat_map do |path|
- Dir.glob("#{path}/extensions/**/#{File.basename(debug_gem)}#{ext_name}")
- end.first
-
- # Attempt to forcibly load the bundled gem
- if ext_path
- $LOAD_PATH << ext_path.delete_suffix(ext_name)
- end
- $LOAD_PATH << "#{debug_gem}/lib"
- begin
- require "debug/session"
- puts "Loaded #{File.basename(debug_gem)}"
- true
- rescue LoadError
- false
- end
- end
end
class DebugCommand < Debug
diff --git a/lib/irb/cmd/edit.rb b/lib/irb/cmd/edit.rb
index 0103891cf4..69606beea0 100644
--- a/lib/irb/cmd/edit.rb
+++ b/lib/irb/cmd/edit.rb
@@ -1,5 +1,6 @@
require 'shellwords'
require_relative "nop"
+require_relative "../source_finder"
module IRB
# :stopdoc:
@@ -7,7 +8,7 @@ module IRB
module ExtendCommand
class Edit < Nop
category "Misc"
- description 'Open a file with the editor command defined with `ENV["EDITOR"]`.'
+ description 'Open a file with the editor command defined with `ENV["VISUAL"]` or `ENV["EDITOR"]`.'
class << self
def transform_args(args)
@@ -28,17 +29,15 @@ module IRB
end
if !File.exist?(path)
- require_relative "show_source"
-
source =
begin
- ShowSource.find_source(path, @irb_context)
+ SourceFinder.new(@irb_context).find_source(path)
rescue NameError
# if user enters a path that doesn't exist, it'll cause NameError when passed here because find_source would try to evaluate it as well
# in this case, we should just ignore the error
end
- if source && File.exist?(source.file)
+ if source
path = source.file
else
puts "Can not find file: #{path}"
@@ -46,12 +45,12 @@ module IRB
end
end
- if editor = ENV['EDITOR']
+ if editor = (ENV['VISUAL'] || ENV['EDITOR'])
puts "command: '#{editor}'"
puts " path: #{path}"
system(*Shellwords.split(editor), path)
else
- puts "Can not find editor setting: ENV['EDITOR']"
+ puts "Can not find editor setting: ENV['VISUAL'] or ENV['EDITOR']"
end
end
end
diff --git a/lib/irb/cmd/fork.rb b/lib/irb/cmd/fork.rb
deleted file mode 100644
index 1cd235997f..0000000000
--- a/lib/irb/cmd/fork.rb
+++ /dev/null
@@ -1,34 +0,0 @@
-# frozen_string_literal: false
-#
-# fork.rb -
-# by Keiju ISHITSUKA(keiju@ruby-lang.org)
-#
-
-require_relative "nop"
-
-module IRB
- # :stopdoc:
-
- module ExtendCommand
- class Fork < Nop
- def execute
- pid = __send__ ExtendCommand.irb_original_method_name("fork")
- unless pid
- class << self
- alias_method :exit, ExtendCommand.irb_original_method_name('exit')
- end
- if block_given?
- begin
- yield
- ensure
- exit
- end
- end
- end
- pid
- end
- end
- end
-
- # :startdoc:
-end
diff --git a/lib/irb/cmd/help.rb b/lib/irb/cmd/help.rb
index 9896fa9db1..64b885c383 100644
--- a/lib/irb/cmd/help.rb
+++ b/lib/irb/cmd/help.rb
@@ -1,57 +1,23 @@
-# frozen_string_literal: false
-#
-# help.rb - helper using ri
-#
+# frozen_string_literal: true
-require_relative "nop"
+require_relative "show_doc"
module IRB
- # :stopdoc:
-
module ExtendCommand
- class Help < Nop
- class << self
- def transform_args(args)
- # Return a string literal as is for backward compatibility
- if args.empty? || string_literal?(args)
- args
- else # Otherwise, consider the input as a String for convenience
- args.strip.dump
- end
- end
- end
-
+ class Help < ShowDoc
category "Context"
- description "Enter the mode to look up RI documents."
+ description "[DEPRECATED] Enter the mode to look up RI documents."
+
+ DEPRECATION_MESSAGE = <<~MSG
+ [Deprecation] The `help` command will be repurposed to display command help in the future.
+ For RI document lookup, please use the `show_doc` command instead.
+ For command help, please use `show_cmds` for now.
+ MSG
def execute(*names)
- require 'rdoc/ri/driver'
- opts = RDoc::RI::Driver.process_args([])
- IRB::ExtendCommand::Help.const_set(:Ri, RDoc::RI::Driver.new(opts))
- rescue LoadError, SystemExit
- IRB::ExtendCommand::Help.remove_method(:execute)
- # raise NoMethodError in ensure
- else
- def execute(*names)
- if names.empty?
- Ri.interactive
- return
- end
- names.each do |name|
- begin
- Ri.display_name(name.to_s)
- rescue RDoc::RI::Error
- puts $!.message
- end
- end
- nil
- end
- nil
- ensure
- execute(*names)
+ warn DEPRECATION_MESSAGE
+ super
end
end
end
-
- # :startdoc:
end
diff --git a/lib/irb/cmd/history.rb b/lib/irb/cmd/history.rb
new file mode 100644
index 0000000000..5b712fa44d
--- /dev/null
+++ b/lib/irb/cmd/history.rb
@@ -0,0 +1,47 @@
+# frozen_string_literal: true
+
+require "stringio"
+require_relative "nop"
+require_relative "../pager"
+
+module IRB
+ # :stopdoc:
+
+ module ExtendCommand
+ class History < Nop
+ category "IRB"
+ description "Shows the input history. `-g [query]` or `-G [query]` allows you to filter the output."
+
+ def self.transform_args(args)
+ match = args&.match(/(-g|-G)\s+(?<grep>.+)\s*\n\z/)
+ return unless match
+
+ "grep: #{Regexp.new(match[:grep]).inspect}"
+ end
+
+ def execute(grep: nil)
+ formatted_inputs = irb_context.io.class::HISTORY.each_with_index.reverse_each.filter_map do |input, index|
+ next if grep && !input.match?(grep)
+
+ header = "#{index}: "
+
+ first_line, *other_lines = input.split("\n")
+ first_line = "#{header}#{first_line}"
+
+ truncated_lines = other_lines.slice!(1..) # Show 1 additional line (2 total)
+ other_lines << "..." if truncated_lines&.any?
+
+ other_lines.map! do |line|
+ " " * header.length + line
+ end
+
+ [first_line, *other_lines].join("\n") + "\n"
+ end
+
+ Pager.page_content(formatted_inputs.join)
+ end
+ end
+ end
+
+ # :startdoc:
+end
diff --git a/lib/irb/cmd/irb_info.rb b/lib/irb/cmd/irb_info.rb
index da11e8d40b..5b905a09bd 100644
--- a/lib/irb/cmd/irb_info.rb
+++ b/lib/irb/cmd/irb_info.rb
@@ -11,24 +11,21 @@ module IRB
description "Show information about IRB."
def execute
- Class.new {
- def inspect
- str = "Ruby version: #{RUBY_VERSION}\n"
- str += "IRB version: #{IRB.version}\n"
- str += "InputMethod: #{IRB.CurrentContext.io.inspect}\n"
- str += ".irbrc path: #{IRB.rc_file}\n" if File.exist?(IRB.rc_file)
- str += "RUBY_PLATFORM: #{RUBY_PLATFORM}\n"
- str += "LANG env: #{ENV["LANG"]}\n" if ENV["LANG"] && !ENV["LANG"].empty?
- str += "LC_ALL env: #{ENV["LC_ALL"]}\n" if ENV["LC_ALL"] && !ENV["LC_ALL"].empty?
- str += "East Asian Ambiguous Width: #{Reline.ambiguous_width.inspect}\n"
- if RbConfig::CONFIG['host_os'] =~ /mswin|msys|mingw|cygwin|bccwin|wince|emc/
- codepage = `chcp`.b.sub(/.*: (\d+)\n/, '\1')
- str += "Code page: #{codepage}\n"
- end
- str
- end
- alias_method :to_s, :inspect
- }.new
+ str = "Ruby version: #{RUBY_VERSION}\n"
+ str += "IRB version: #{IRB.version}\n"
+ str += "InputMethod: #{IRB.CurrentContext.io.inspect}\n"
+ str += "Completion: #{IRB.CurrentContext.io.respond_to?(:completion_info) ? IRB.CurrentContext.io.completion_info : 'off'}\n"
+ str += ".irbrc path: #{IRB.rc_file}\n" if File.exist?(IRB.rc_file)
+ str += "RUBY_PLATFORM: #{RUBY_PLATFORM}\n"
+ str += "LANG env: #{ENV["LANG"]}\n" if ENV["LANG"] && !ENV["LANG"].empty?
+ str += "LC_ALL env: #{ENV["LC_ALL"]}\n" if ENV["LC_ALL"] && !ENV["LC_ALL"].empty?
+ str += "East Asian Ambiguous Width: #{Reline.ambiguous_width.inspect}\n"
+ if RbConfig::CONFIG['host_os'] =~ /mswin|msys|mingw|cygwin|bccwin|wince|emc/
+ codepage = `chcp`.b.sub(/.*: (\d+)\n/, '\1')
+ str += "Code page: #{codepage}\n"
+ end
+ puts str
+ nil
end
end
end
diff --git a/lib/irb/cmd/ls.rb b/lib/irb/cmd/ls.rb
index b65fae2bf1..791b1c1b21 100644
--- a/lib/irb/cmd/ls.rb
+++ b/lib/irb/cmd/ls.rb
@@ -1,7 +1,9 @@
# frozen_string_literal: true
require "reline"
+require "stringio"
require_relative "nop"
+require_relative "../pager"
require_relative "../color"
module IRB
@@ -33,26 +35,42 @@ module IRB
o.dump("instance variables", obj.instance_variables)
o.dump("class variables", klass.class_variables)
o.dump("locals", locals)
- nil
+ o.print_result
end
def dump_methods(o, klass, obj)
singleton_class = begin obj.singleton_class; rescue TypeError; nil end
- maps = class_method_map((singleton_class || klass).ancestors)
+ dumped_mods = Array.new
+ ancestors = klass.ancestors
+ ancestors = ancestors.reject { |c| c >= Object } if klass < Object
+ singleton_ancestors = (singleton_class&.ancestors || []).reject { |c| c >= Class }
+
+ # singleton_class' ancestors should be at the front
+ maps = class_method_map(singleton_ancestors, dumped_mods) + class_method_map(ancestors, dumped_mods)
maps.each do |mod, methods|
name = mod == singleton_class ? "#{klass}.methods" : "#{mod}#methods"
o.dump(name, methods)
end
end
- def class_method_map(classes)
- dumped = Array.new
- classes.reject { |mod| mod >= Object }.map do |mod|
- methods = mod.public_instance_methods(false).select do |m|
- dumped.push(m) unless dumped.include?(m)
+ def class_method_map(classes, dumped_mods)
+ dumped_methods = Array.new
+ classes.map do |mod|
+ next if dumped_mods.include? mod
+
+ dumped_mods << mod
+
+ methods = mod.public_instance_methods(false).select do |method|
+ if dumped_methods.include? method
+ false
+ else
+ dumped_methods << method
+ true
+ end
end
+
[mod, methods]
- end.reverse
+ end.compact
end
class Output
@@ -61,6 +79,11 @@ module IRB
def initialize(grep: nil)
@grep = grep
@line_width = screen_width - MARGIN.length # right padding
+ @io = StringIO.new
+ end
+
+ def print_result
+ Pager.page_content(@io.string)
end
def dump(name, strs)
@@ -69,12 +92,12 @@ module IRB
return if strs.empty?
# Attempt a single line
- print "#{Color.colorize(name, [:BOLD, :BLUE])}: "
+ @io.print "#{Color.colorize(name, [:BOLD, :BLUE])}: "
if fits_on_line?(strs, cols: strs.size, offset: "#{name}: ".length)
- puts strs.join(MARGIN)
+ @io.puts strs.join(MARGIN)
return
end
- puts
+ @io.puts
# Dump with the largest # of columns that fits on a line
cols = strs.size
@@ -83,7 +106,7 @@ module IRB
end
widths = col_widths(strs, cols: cols)
strs.each_slice(cols) do |ss|
- puts ss.map.with_index { |s, i| "#{MARGIN}%-#{widths[i]}s" % s }.join
+ @io.puts ss.map.with_index { |s, i| "#{MARGIN}%-#{widths[i]}s" % s }.join
end
end
diff --git a/lib/irb/cmd/measure.rb b/lib/irb/cmd/measure.rb
index 9122e2dac9..4e1125a0a6 100644
--- a/lib/irb/cmd/measure.rb
+++ b/lib/irb/cmd/measure.rb
@@ -12,32 +12,29 @@ module IRB
super(*args)
end
- def execute(type = nil, arg = nil, &block)
+ def execute(type = nil, arg = nil)
# Please check IRB.init_config in lib/irb/init.rb that sets
# IRB.conf[:MEASURE_PROC] to register default "measure" methods,
# "measure :time" (abbreviated as "measure") and "measure :stackprof".
+
+ if block_given?
+ warn 'Configure IRB.conf[:MEASURE_PROC] to add custom measure methods.'
+ return
+ end
+
case type
when :off
- IRB.conf[:MEASURE] = nil
IRB.unset_measure_callback(arg)
when :list
IRB.conf[:MEASURE_CALLBACKS].each do |type_name, _, arg_val|
puts "- #{type_name}" + (arg_val ? "(#{arg_val.inspect})" : '')
end
when :on
- IRB.conf[:MEASURE] = true
- added = IRB.set_measure_callback(type, arg)
+ added = IRB.set_measure_callback(arg)
puts "#{added[0]} is added." if added
else
- if block_given?
- IRB.conf[:MEASURE] = true
- added = IRB.set_measure_callback(&block)
- puts "#{added[0]} is added." if added
- else
- IRB.conf[:MEASURE] = true
- added = IRB.set_measure_callback(type, arg)
- puts "#{added[0]} is added." if added
- end
+ added = IRB.set_measure_callback(type, arg)
+ puts "#{added[0]} is added." if added
end
nil
end
diff --git a/lib/irb/cmd/nop.rb b/lib/irb/cmd/nop.rb
index 34facc7578..7fb197c51f 100644
--- a/lib/irb/cmd/nop.rb
+++ b/lib/irb/cmd/nop.rb
@@ -30,32 +30,19 @@ module IRB
end
end
- if RUBY_ENGINE == "ruby" && RUBY_VERSION >= "2.7.0"
- def self.execute(conf, *opts, **kwargs, &block)
- command = new(conf)
- command.execute(*opts, **kwargs, &block)
- rescue CommandArgumentError => e
- puts e.message
- end
- else
- def self.execute(conf, *opts, &block)
- command = new(conf)
- command.execute(*opts, &block)
- rescue CommandArgumentError => e
- puts e.message
- end
+ def self.execute(irb_context, *opts, **kwargs, &block)
+ command = new(irb_context)
+ command.execute(*opts, **kwargs, &block)
+ rescue CommandArgumentError => e
+ puts e.message
end
- def initialize(conf)
- @irb_context = conf
+ def initialize(irb_context)
+ @irb_context = irb_context
end
attr_reader :irb_context
- def irb
- @irb_context.irb
- end
-
def execute(*opts)
#nop
end
diff --git a/lib/irb/cmd/pushws.rb b/lib/irb/cmd/pushws.rb
index d64d822182..59996ceb0c 100644
--- a/lib/irb/cmd/pushws.rb
+++ b/lib/irb/cmd/pushws.rb
@@ -12,7 +12,7 @@ module IRB
module ExtendCommand
class Workspaces < Nop
- category "IRB"
+ category "Workspace"
description "Show workspaces."
def execute(*obj)
@@ -21,7 +21,7 @@ module IRB
end
class PushWorkspace < Workspaces
- category "IRB"
+ category "Workspace"
description "Push an object to the workspace stack."
def execute(*obj)
@@ -31,7 +31,7 @@ module IRB
end
class PopWorkspace < Workspaces
- category "IRB"
+ category "Workspace"
description "Pop a workspace from the workspace stack."
def execute(*obj)
diff --git a/lib/irb/cmd/show_cmds.rb b/lib/irb/cmd/show_cmds.rb
index acced27d48..a8d899e4ac 100644
--- a/lib/irb/cmd/show_cmds.rb
+++ b/lib/irb/cmd/show_cmds.rb
@@ -2,6 +2,7 @@
require "stringio"
require_relative "nop"
+require_relative "../pager"
module IRB
# :stopdoc:
@@ -14,7 +15,23 @@ module IRB
def execute(*args)
commands_info = IRB::ExtendCommandBundle.all_commands_info
commands_grouped_by_categories = commands_info.group_by { |cmd| cmd[:category] }
- longest_cmd_name_length = commands_info.map { |c| c[:display_name] }.max { |a, b| a.length <=> b.length }.length
+
+ user_aliases = irb_context.instance_variable_get(:@user_aliases)
+
+ commands_grouped_by_categories["Aliases"] = user_aliases.map do |alias_name, target|
+ { display_name: alias_name, description: "Alias for `#{target}`" }
+ end
+
+ if irb_context.with_debugger
+ # Remove the original "Debugging" category
+ commands_grouped_by_categories.delete("Debugging")
+ # Remove the `help` command as it's delegated to the debugger
+ commands_grouped_by_categories["Context"].delete_if { |cmd| cmd[:display_name] == :help }
+ # Add an empty "Debugging (from debug.gem)" category at the end
+ commands_grouped_by_categories["Debugging (from debug.gem)"] = []
+ end
+
+ longest_cmd_name_length = commands_info.map { |c| c[:display_name].length }.max
output = StringIO.new
@@ -28,9 +45,12 @@ module IRB
output.puts
end
- puts output.string
+ # Append the debugger help at the end
+ if irb_context.with_debugger
+ output.puts DEBUGGER__.help
+ end
- nil
+ Pager.page_content(output.string)
end
end
end
diff --git a/lib/irb/cmd/show_doc.rb b/lib/irb/cmd/show_doc.rb
new file mode 100644
index 0000000000..99dd9ab95a
--- /dev/null
+++ b/lib/irb/cmd/show_doc.rb
@@ -0,0 +1,48 @@
+# frozen_string_literal: true
+
+require_relative "nop"
+
+module IRB
+ module ExtendCommand
+ class ShowDoc < Nop
+ class << self
+ def transform_args(args)
+ # Return a string literal as is for backward compatibility
+ if args.empty? || string_literal?(args)
+ args
+ else # Otherwise, consider the input as a String for convenience
+ args.strip.dump
+ end
+ end
+ end
+
+ category "Context"
+ description "Enter the mode to look up RI documents."
+
+ def execute(*names)
+ require 'rdoc/ri/driver'
+
+ unless ShowDoc.const_defined?(:Ri)
+ opts = RDoc::RI::Driver.process_args([])
+ ShowDoc.const_set(:Ri, RDoc::RI::Driver.new(opts))
+ end
+
+ if names.empty?
+ Ri.interactive
+ else
+ names.each do |name|
+ begin
+ Ri.display_name(name.to_s)
+ rescue RDoc::RI::Error
+ puts $!.message
+ end
+ end
+ end
+
+ nil
+ rescue LoadError, SystemExit
+ warn "Can't display document because `rdoc` is not installed."
+ end
+ end
+ end
+end
diff --git a/lib/irb/cmd/show_source.rb b/lib/irb/cmd/show_source.rb
index eb21533b56..826cb11ed2 100644
--- a/lib/irb/cmd/show_source.rb
+++ b/lib/irb/cmd/show_source.rb
@@ -1,12 +1,11 @@
# frozen_string_literal: true
require_relative "nop"
+require_relative "../source_finder"
+require_relative "../pager"
require_relative "../color"
-require_relative "../ruby-lex"
module IRB
- # :stopdoc:
-
module ExtendCommand
class ShowSource < Nop
category "Context"
@@ -21,50 +20,6 @@ module IRB
args.strip.dump
end
end
-
- def find_source(str, irb_context)
- case str
- when /\A[A-Z]\w*(::[A-Z]\w*)*\z/ # Const::Name
- eval(str, irb_context.workspace.binding) # trigger autoload
- base = irb_context.workspace.binding.receiver.yield_self { |r| r.is_a?(Module) ? r : Object }
- file, line = base.const_source_location(str) if base.respond_to?(:const_source_location) # Ruby 2.7+
- when /\A(?<owner>[A-Z]\w*(::[A-Z]\w*)*)#(?<method>[^ :.]+)\z/ # Class#method
- owner = eval(Regexp.last_match[:owner], irb_context.workspace.binding)
- method = Regexp.last_match[:method]
- if owner.respond_to?(:instance_method) && owner.instance_methods.include?(method.to_sym)
- file, line = owner.instance_method(method).source_location
- end
- when /\A((?<receiver>.+)(\.|::))?(?<method>[^ :.]+)\z/ # method, receiver.method, receiver::method
- receiver = eval(Regexp.last_match[:receiver] || 'self', irb_context.workspace.binding)
- method = Regexp.last_match[:method]
- file, line = receiver.method(method).source_location if receiver.respond_to?(method)
- end
- if file && line
- Source.new(file: file, first_line: line, last_line: find_end(file, line, irb_context))
- end
- end
-
- private
-
- def find_end(file, first_line, irb_context)
- return first_line unless File.exist?(file)
- lex = RubyLex.new(irb_context)
- lines = File.read(file).lines[(first_line - 1)..-1]
- tokens = RubyLex.ripper_lex_without_warning(lines.join)
- prev_tokens = []
-
- # chunk with line number
- tokens.chunk { |tok| tok.pos[0] }.each do |lnum, chunk|
- code = lines[0..lnum].join
- prev_tokens.concat chunk
- continue = lex.process_continue(prev_tokens)
- code_block_open = lex.check_code_block(code, prev_tokens)
- if !continue && !code_block_open
- return first_line + lnum
- end
- end
- first_line
- end
end
def execute(str = nil)
@@ -73,9 +28,14 @@ module IRB
return
end
- source = self.class.find_source(str, @irb_context)
- if source && File.exist?(source.file)
+ str, esses = str.split(" -")
+ super_level = esses ? esses.count("s") : 0
+ source = SourceFinder.new(@irb_context).find_source(str, super_level)
+
+ if source
show_source(source)
+ elsif super_level > 0
+ puts "Error: Couldn't locate a super definition for #{str}"
else
puts "Error: Couldn't locate a definition for #{str}"
end
@@ -84,29 +44,22 @@ module IRB
private
- # @param [IRB::ExtendCommand::ShowSource::Source] source
def show_source(source)
- puts
- puts "#{bold("From")}: #{source.file}:#{source.first_line}"
- puts
- code = IRB::Color.colorize_code(File.read(source.file))
- puts code.lines[(source.first_line - 1)...source.last_line].join
- puts
+ file_content = IRB::Color.colorize_code(File.read(source.file))
+ code = file_content.lines[(source.first_line - 1)...source.last_line].join
+ content = <<~CONTENT
+
+ #{bold("From")}: #{source.file}:#{source.first_line}
+
+ #{code}
+ CONTENT
+
+ Pager.page_content(content)
end
def bold(str)
Color.colorize(str, [:BOLD])
end
-
- Source = Struct.new(
- :file, # @param [String] - file name
- :first_line, # @param [String] - first line
- :last_line, # @param [String] - last line
- keyword_init: true,
- )
- private_constant :Source
end
end
-
- # :startdoc:
end
diff --git a/lib/irb/cmd/subirb.rb b/lib/irb/cmd/subirb.rb
index 5f3e02c988..5ffd646416 100644
--- a/lib/irb/cmd/subirb.rb
+++ b/lib/irb/cmd/subirb.rb
@@ -11,52 +11,95 @@ module IRB
module ExtendCommand
class MultiIRBCommand < Nop
- def initialize(conf)
- super
+ def execute(*args)
extend_irb_context
end
private
+ def print_deprecated_warning
+ warn <<~MSG
+ Multi-irb commands are deprecated and will be removed in IRB 2.0.0. Please use workspace commands instead.
+ If you have any use case for multi-irb, please leave a comment at https://github.com/ruby/irb/issues/653
+ MSG
+ end
+
def extend_irb_context
# this extension patches IRB context like IRB.CurrentContext
require_relative "../ext/multi-irb"
end
+
+ def print_debugger_warning
+ warn "Multi-IRB commands are not available when the debugger is enabled."
+ end
end
class IrbCommand < MultiIRBCommand
- category "IRB"
+ category "Multi-irb (DEPRECATED)"
description "Start a child IRB."
def execute(*obj)
+ print_deprecated_warning
+
+ if irb_context.with_debugger
+ print_debugger_warning
+ return
+ end
+
+ super
IRB.irb(nil, *obj)
end
end
class Jobs < MultiIRBCommand
- category "IRB"
+ category "Multi-irb (DEPRECATED)"
description "List of current sessions."
def execute
+ print_deprecated_warning
+
+ if irb_context.with_debugger
+ print_debugger_warning
+ return
+ end
+
+ super
IRB.JobManager
end
end
class Foreground < MultiIRBCommand
- category "IRB"
+ category "Multi-irb (DEPRECATED)"
description "Switches to the session of the given number."
def execute(key = nil)
+ print_deprecated_warning
+
+ if irb_context.with_debugger
+ print_debugger_warning
+ return
+ end
+
+ super
+
raise CommandArgumentError.new("Please specify the id of target IRB job (listed in the `jobs` command).") unless key
IRB.JobManager.switch(key)
end
end
class Kill < MultiIRBCommand
- category "IRB"
+ category "Multi-irb (DEPRECATED)"
description "Kills the session with the given number."
def execute(*keys)
+ print_deprecated_warning
+
+ if irb_context.with_debugger
+ print_debugger_warning
+ return
+ end
+
+ super
IRB.JobManager.kill(*keys)
end
end
diff --git a/lib/irb/color.rb b/lib/irb/color.rb
index 6378e14856..ad8670160c 100644
--- a/lib/irb/color.rb
+++ b/lib/irb/color.rb
@@ -9,12 +9,14 @@ module IRB # :nodoc:
BOLD = 1
UNDERLINE = 4
REVERSE = 7
+ BLACK = 30
RED = 31
GREEN = 32
YELLOW = 33
BLUE = 34
MAGENTA = 35
CYAN = 36
+ WHITE = 37
TOKEN_KEYWORDS = {
on_kw: ['nil', 'self', 'true', 'false', '__FILE__', '__LINE__', '__ENCODING__'],
@@ -197,15 +199,9 @@ module IRB # :nodoc:
end
end
- if lexer.respond_to?(:scan) # Ruby 2.7+
- lexer.scan.each do |elem|
- next if allow_last_error and /meets end of file|unexpected end-of-input/ =~ elem.message
- on_scan.call(elem)
- end
- else
- lexer.parse.sort_by(&:pos).each do |elem|
- on_scan.call(elem)
- end
+ lexer.scan.each do |elem|
+ next if allow_last_error and /meets end of file|unexpected end-of-input/ =~ elem.message
+ on_scan.call(elem)
end
# yield uncolorable DATA section
yield(nil, inner_code.byteslice(byte_pos...inner_code.bytesize), nil) if byte_pos < inner_code.bytesize
@@ -242,7 +238,7 @@ module IRB # :nodoc:
case token
when :on_symbeg, :on_symbols_beg, :on_qsymbols_beg
@stack << true
- when :on_ident, :on_op, :on_const, :on_ivar, :on_cvar, :on_gvar, :on_kw
+ when :on_ident, :on_op, :on_const, :on_ivar, :on_cvar, :on_gvar, :on_kw, :on_backtick
if @stack.last # Pop only when it's Symbol
@stack.pop
return prev_state
diff --git a/lib/irb/color_printer.rb b/lib/irb/color_printer.rb
index 1127bcecb4..31644aa7f9 100644
--- a/lib/irb/color_printer.rb
+++ b/lib/irb/color_printer.rb
@@ -4,6 +4,9 @@ require_relative 'color'
module IRB
class ColorPrinter < ::PP
+ METHOD_RESPOND_TO = Object.instance_method(:respond_to?)
+ METHOD_INSPECT = Object.instance_method(:inspect)
+
class << self
def pp(obj, out = $>, width = screen_width)
q = ColorPrinter.new(out, width)
@@ -22,9 +25,11 @@ module IRB
end
def pp(obj)
- if obj.is_a?(String)
+ if String === obj
# Avoid calling Ruby 2.4+ String#pretty_print that splits a string by "\n"
text(obj.inspect)
+ elsif !METHOD_RESPOND_TO.bind(obj).call(:inspect)
+ text(METHOD_INSPECT.bind(obj).call)
else
super
end
diff --git a/lib/irb/completion.rb b/lib/irb/completion.rb
index 97f97dfafe..af3b69eb27 100644
--- a/lib/irb/completion.rb
+++ b/lib/irb/completion.rb
@@ -8,30 +8,7 @@
require_relative 'ruby-lex'
module IRB
- module InputCompletor # :nodoc:
- using Module.new {
- refine ::Binding do
- def eval_methods
- ::Kernel.instance_method(:methods).bind(eval("self")).call
- end
-
- def eval_private_methods
- ::Kernel.instance_method(:private_methods).bind(eval("self")).call
- end
-
- def eval_instance_variables
- ::Kernel.instance_method(:instance_variables).bind(eval("self")).call
- end
-
- def eval_global_variables
- ::Kernel.instance_method(:global_variables).bind(eval("self")).call
- end
-
- def eval_class_constants
- ::Module.instance_method(:constants).bind(eval("self.class")).call
- end
- end
- }
+ class BaseCompletor # :nodoc:
# Set of reserved words used by Ruby, you should not use these for
# constants or variables
@@ -56,21 +33,19 @@ module IRB
yield
]
- BASIC_WORD_BREAK_CHARACTERS = " \t\n`><=;|&{("
+ def completion_candidates(preposing, target, postposing, bind:)
+ raise NotImplementedError
+ end
- def self.absolute_path?(p) # TODO Remove this method after 2.6 EOL.
- if File.respond_to?(:absolute_path?)
- File.absolute_path?(p)
- else
- File.absolute_path(p) == p
- end
+ def doc_namespace(preposing, matched, postposing, bind:)
+ raise NotImplementedError
end
GEM_PATHS =
if defined?(Gem::Specification)
Gem::Specification.latest_specs(true).map { |s|
s.require_paths.map { |p|
- if absolute_path?(p)
+ if File.absolute_path?(p)
p
else
File.join(s.full_gem_path, p)
@@ -81,7 +56,7 @@ module IRB
[]
end.freeze
- def self.retrieve_gem_and_system_load_path
+ def retrieve_gem_and_system_load_path
candidates = (GEM_PATHS | $LOAD_PATH)
candidates.map do |p|
if p.respond_to?(:to_path)
@@ -92,8 +67,8 @@ module IRB
end.compact.sort
end
- def self.retrieve_files_to_require_from_load_path
- @@files_from_load_path ||=
+ def retrieve_files_to_require_from_load_path
+ @files_from_load_path ||=
(
shortest = []
rest = retrieve_gem_and_system_load_path.each_with_object([]) { |path, result|
@@ -111,13 +86,64 @@ module IRB
)
end
- def self.retrieve_files_to_require_relative_from_current_dir
- @@files_from_current_dir ||= Dir.glob("**/*.{rb,#{RbConfig::CONFIG['DLEXT']}}", base: '.').map { |path|
+ def retrieve_files_to_require_relative_from_current_dir
+ @files_from_current_dir ||= Dir.glob("**/*.{rb,#{RbConfig::CONFIG['DLEXT']}}", base: '.').map { |path|
path.sub(/\.(rb|#{RbConfig::CONFIG['DLEXT']})\z/, '')
}
end
+ end
+
+ class TypeCompletor < BaseCompletor # :nodoc:
+ def initialize(context)
+ @context = context
+ end
+
+ def inspect
+ ReplTypeCompletor.info
+ end
+
+ def completion_candidates(preposing, target, _postposing, bind:)
+ result = ReplTypeCompletor.analyze(preposing + target, binding: bind, filename: @context.irb_path)
+ return [] unless result
+ result.completion_candidates.map { target + _1 }
+ end
+
+ def doc_namespace(preposing, matched, _postposing, bind:)
+ result = ReplTypeCompletor.analyze(preposing + matched, binding: bind, filename: @context.irb_path)
+ result&.doc_namespace('')
+ end
+ end
+
+ class RegexpCompletor < BaseCompletor # :nodoc:
+ using Module.new {
+ refine ::Binding do
+ def eval_methods
+ ::Kernel.instance_method(:methods).bind(eval("self")).call
+ end
+
+ def eval_private_methods
+ ::Kernel.instance_method(:private_methods).bind(eval("self")).call
+ end
+
+ def eval_instance_variables
+ ::Kernel.instance_method(:instance_variables).bind(eval("self")).call
+ end
+
+ def eval_global_variables
+ ::Kernel.instance_method(:global_variables).bind(eval("self")).call
+ end
+
+ def eval_class_constants
+ ::Module.instance_method(:constants).bind(eval("self.class")).call
+ end
+ end
+ }
+
+ def inspect
+ 'RegexpCompletor'
+ end
- CompletionRequireProc = lambda { |target, preposing = nil, postposing = nil|
+ def complete_require_path(target, preposing, postposing)
if target =~ /\A(['"])([^'"]+)\Z/
quote = $1
actual_target = $2
@@ -132,44 +158,44 @@ module IRB
break
end
end
- result = []
- if tok && tok.event == :on_ident && tok.state == Ripper::EXPR_CMDARG
- case tok.tok
- when 'require'
- result = retrieve_files_to_require_from_load_path.select { |path|
- path.start_with?(actual_target)
- }.map { |path|
- quote + path
- }
- when 'require_relative'
- result = retrieve_files_to_require_relative_from_current_dir.select { |path|
- path.start_with?(actual_target)
- }.map { |path|
- quote + path
- }
- end
+ return unless tok&.event == :on_ident && tok.state == Ripper::EXPR_CMDARG
+
+ case tok.tok
+ when 'require'
+ retrieve_files_to_require_from_load_path.select { |path|
+ path.start_with?(actual_target)
+ }.map { |path|
+ quote + path
+ }
+ when 'require_relative'
+ retrieve_files_to_require_relative_from_current_dir.select { |path|
+ path.start_with?(actual_target)
+ }.map { |path|
+ quote + path
+ }
end
- result
- }
+ end
- CompletionProc = lambda { |target, preposing = nil, postposing = nil|
+ def completion_candidates(preposing, target, postposing, bind:)
if preposing && postposing
- result = CompletionRequireProc.(target, preposing, postposing)
- unless result
- result = retrieve_completion_data(target).compact.map{ |i| i.encode(Encoding.default_external) }
- end
- result
- else
- retrieve_completion_data(target).compact.map{ |i| i.encode(Encoding.default_external) }
+ result = complete_require_path(target, preposing, postposing)
+ return result if result
end
- }
+ retrieve_completion_data(target, bind: bind, doc_namespace: false).compact.map{ |i| i.encode(Encoding.default_external) }
+ end
- def self.retrieve_completion_data(input, bind: IRB.conf[:MAIN_CONTEXT].workspace.binding, doc_namespace: false)
+ def doc_namespace(_preposing, matched, _postposing, bind:)
+ retrieve_completion_data(matched, bind: bind, doc_namespace: true)
+ end
+
+ def retrieve_completion_data(input, bind:, doc_namespace:)
case input
- when /^((["'`]).*\2)\.([^.]*)$/
+ # this regexp only matches the closing character because of irb's Reline.completer_quote_characters setting
+ # details are described in: https://github.com/ruby/irb/pull/523
+ when /^(.*["'`])\.([^.]*)$/
# String
receiver = $1
- message = $3
+ message = $2
if doc_namespace
"String.#{message}"
@@ -178,7 +204,9 @@ module IRB
select_message(receiver, message, candidates)
end
- when /^(\/[^\/]*\/)\.([^.]*)$/
+ # this regexp only matches the closing character because of irb's Reline.completer_quote_characters setting
+ # details are described in: https://github.com/ruby/irb/pull/523
+ when /^(.*\/)\.([^.]*)$/
# Regexp
receiver = $1
message = $2
@@ -203,26 +231,26 @@ module IRB
end
when /^([^\}]*\})\.([^.]*)$/
- # Proc or Hash
+ # Hash or Proc
receiver = $1
message = $2
if doc_namespace
- ["Proc.#{message}", "Hash.#{message}"]
+ ["Hash.#{message}", "Proc.#{message}"]
else
- proc_candidates = Proc.instance_methods.collect{|m| m.to_s}
hash_candidates = Hash.instance_methods.collect{|m| m.to_s}
- select_message(receiver, message, proc_candidates | hash_candidates)
+ proc_candidates = Proc.instance_methods.collect{|m| m.to_s}
+ select_message(receiver, message, hash_candidates | proc_candidates)
end
- when /^(:[^:.]*)$/
+ when /^(:[^:.]+)$/
# Symbol
if doc_namespace
nil
else
sym = $1
candidates = Symbol.all_symbols.collect do |s|
- ":" + s.id2name.encode(Encoding.default_external)
+ s.inspect
rescue EncodingError
# ignore
end
@@ -237,7 +265,7 @@ module IRB
if doc_namespace
candidates.find { |i| i == receiver }
else
- candidates.grep(/^#{receiver}/).collect{|e| "::" + e}
+ candidates.grep(/^#{Regexp.quote(receiver)}/).collect{|e| "::" + e}
end
when /^([A-Z].*)::([^:.]*)$/
@@ -356,14 +384,6 @@ module IRB
else
# func1.func2
candidates = []
- to_ignore = ignored_modules
- ObjectSpace.each_object(Module){|m|
- next if (to_ignore.include?(m) rescue true)
- next unless m.respond_to?(:instance_methods) # JRuby has modules that represent java packages. They don't include many common ruby methods
- candidates.concat m.instance_methods(false).collect{|x| x.to_s}
- }
- candidates.sort!
- candidates.uniq!
end
if doc_namespace
@@ -406,44 +426,10 @@ module IRB
end
end
- PerfectMatchedProc = ->(matched, bind: IRB.conf[:MAIN_CONTEXT].workspace.binding) {
- begin
- require 'rdoc'
- rescue LoadError
- return
- end
-
- RDocRIDriver ||= RDoc::RI::Driver.new
-
- if matched =~ /\A(?:::)?RubyVM/ and not ENV['RUBY_YES_I_AM_NOT_A_NORMAL_USER']
- IRB.__send__(:easter_egg)
- return
- end
-
- namespace = retrieve_completion_data(matched, bind: bind, doc_namespace: true)
- return unless namespace
-
- if namespace.is_a?(Array)
- out = RDoc::Markup::Document.new
- namespace.each do |m|
- begin
- RDocRIDriver.add_method(out, m)
- rescue RDoc::RI::Driver::NotFoundError
- end
- end
- RDocRIDriver.display(out)
- else
- begin
- RDocRIDriver.display_names([namespace])
- rescue RDoc::RI::Driver::NotFoundError
- end
- end
- }
-
# Set of available operators in Ruby
Operators = %w[% & * ** + - / < << <= <=> == === =~ > >= >> [] []= ^ ! != !~]
- def self.select_message(receiver, message, candidates, sep = ".")
+ def select_message(receiver, message, candidates, sep = ".")
candidates.grep(/^#{Regexp.quote(message)}/).collect do |e|
case e
when /^[a-zA-Z_]/
@@ -454,30 +440,21 @@ module IRB
end
end
end
+ end
- def self.ignored_modules
- # We could cache the result, but this is very fast already.
- # By using this approach, we avoid Module#name calls, which are
- # relatively slow when there are a lot of anonymous modules defined.
- s = {}
-
- scanner = lambda do |m|
- next if s.include?(m) # IRB::ExtendCommandBundle::EXCB recurses.
- s[m] = true
- m.constants(false).each do |c|
- value = m.const_get(c)
- scanner.call(value) if value.is_a?(Module)
- end
+ module InputCompletor
+ class << self
+ private def regexp_completor
+ @regexp_completor ||= RegexpCompletor.new
end
- %i(IRB RubyLex).each do |sym|
- next unless Object.const_defined?(sym)
- scanner.call(Object.const_get(sym))
+ def retrieve_completion_data(input, bind: IRB.conf[:MAIN_CONTEXT].workspace.binding, doc_namespace: false)
+ regexp_completor.retrieve_completion_data(input, bind: bind, doc_namespace: doc_namespace)
end
-
- s.delete(IRB::Context) if defined?(IRB::Context)
-
- s
end
+ CompletionProc = ->(target, preposing = nil, postposing = nil) {
+ regexp_completor.completion_candidates(preposing, target, postposing, bind: IRB.conf[:MAIN_CONTEXT].workspace.binding)
+ }
end
+ deprecate_constant :InputCompletor
end
diff --git a/lib/irb/context.rb b/lib/irb/context.rb
index a8031d0294..c3690fcac7 100644
--- a/lib/irb/context.rb
+++ b/lib/irb/context.rb
@@ -86,14 +86,14 @@ module IRB
when nil
if STDIN.tty? && IRB.conf[:PROMPT_MODE] != :INF_RUBY && !use_singleline?
# Both of multiline mode and singleline mode aren't specified.
- @io = RelineInputMethod.new
+ @io = RelineInputMethod.new(build_completor)
else
@io = nil
end
when false
@io = nil
when true
- @io = RelineInputMethod.new
+ @io = RelineInputMethod.new(build_completor)
end
unless @io
case use_singleline?
@@ -129,8 +129,6 @@ module IRB
else
@io = input_method
end
- self.save_history = IRB.conf[:SAVE_HISTORY] if IRB.conf[:SAVE_HISTORY]
-
@extra_doc_dirs = IRB.conf[:EXTRA_DOC_DIRS]
@echo = IRB.conf[:ECHO]
@@ -148,7 +146,70 @@ module IRB
@newline_before_multiline_output = true
end
- @command_aliases = IRB.conf[:COMMAND_ALIASES]
+ @user_aliases = IRB.conf[:COMMAND_ALIASES].dup
+ @command_aliases = @user_aliases.merge(KEYWORD_ALIASES)
+ end
+
+ # because all input will eventually be evaluated as Ruby code,
+ # command names that conflict with Ruby keywords need special workaround
+ # we can remove them once we implemented a better command system for IRB
+ KEYWORD_ALIASES = {
+ :break => :irb_break,
+ :catch => :irb_catch,
+ :next => :irb_next,
+ }.freeze
+
+ private_constant :KEYWORD_ALIASES
+
+ private def build_completor
+ completor_type = IRB.conf[:COMPLETOR]
+ case completor_type
+ when :regexp
+ return RegexpCompletor.new
+ when :type
+ completor = build_type_completor
+ return completor if completor
+ else
+ warn "Invalid value for IRB.conf[:COMPLETOR]: #{completor_type}"
+ end
+ # Fallback to RegexpCompletor
+ RegexpCompletor.new
+ end
+
+ private def build_type_completor
+ if RUBY_ENGINE == 'truffleruby'
+ # Avoid SynatxError. truffleruby does not support endless method definition yet.
+ warn 'TypeCompletor is not supported on TruffleRuby yet'
+ return
+ end
+
+ begin
+ require 'repl_type_completor'
+ rescue LoadError => e
+ warn "TypeCompletor requires `gem repl_type_completor`: #{e.message}"
+ return
+ end
+
+ ReplTypeCompletor.preload_rbs
+ TypeCompletor.new(self)
+ end
+
+ def save_history=(val)
+ IRB.conf[:SAVE_HISTORY] = val
+ end
+
+ def save_history
+ IRB.conf[:SAVE_HISTORY]
+ end
+
+ # A copy of the default <code>IRB.conf[:HISTORY_FILE]</code>
+ def history_file
+ IRB.conf[:HISTORY_FILE]
+ end
+
+ # Set <code>IRB.conf[:HISTORY_FILE]</code> to the given +hist+.
+ def history_file=(hist)
+ IRB.conf[:HISTORY_FILE] = hist
end
# The top-level workspace, see WorkSpace#main
@@ -203,18 +264,29 @@ module IRB
attr_reader :prompt_mode
# Standard IRB prompt.
#
- # See IRB@Customizing+the+IRB+Prompt for more information.
+ # See {Custom Prompts}[rdoc-ref:IRB@Custom+Prompts] for more information.
attr_accessor :prompt_i
# IRB prompt for continuated strings.
#
- # See IRB@Customizing+the+IRB+Prompt for more information.
+ # See {Custom Prompts}[rdoc-ref:IRB@Custom+Prompts] for more information.
attr_accessor :prompt_s
# IRB prompt for continuated statement. (e.g. immediately after an +if+)
#
- # See IRB@Customizing+the+IRB+Prompt for more information.
+ # See {Custom Prompts}[rdoc-ref:IRB@Custom+Prompts] for more information.
attr_accessor :prompt_c
- # See IRB@Customizing+the+IRB+Prompt for more information.
- attr_accessor :prompt_n
+
+ # TODO: Remove this when developing v2.0
+ def prompt_n
+ warn "IRB::Context#prompt_n is deprecated and will be removed in the next major release."
+ ""
+ end
+
+ # TODO: Remove this when developing v2.0
+ def prompt_n=(_)
+ warn "IRB::Context#prompt_n= is deprecated and will be removed in the next major release."
+ ""
+ end
+
# Can be either the default <code>IRB.conf[:AUTO_INDENT]</code>, or the
# mode set by #prompt_mode=
#
@@ -322,13 +394,13 @@ module IRB
# The default value is 16.
#
# Can also be set using the +--back-trace-limit+ command line option.
- #
- # See IRB@Command+line+options for more command line options.
attr_accessor :back_trace_limit
# User-defined IRB command aliases
attr_accessor :command_aliases
+ attr_accessor :with_debugger
+
# Alias for #use_multiline
alias use_multiline? use_multiline
# Alias for #use_singleline
@@ -389,14 +461,13 @@ module IRB
# Sets the +mode+ of the prompt in this context.
#
- # See IRB@Customizing+the+IRB+Prompt for more information.
+ # See {Custom Prompts}[rdoc-ref:IRB@Custom+Prompts] for more information.
def prompt_mode=(mode)
@prompt_mode = mode
pconf = IRB.conf[:PROMPT][mode]
@prompt_i = pconf[:PROMPT_I]
@prompt_s = pconf[:PROMPT_S]
@prompt_c = pconf[:PROMPT_C]
- @prompt_n = pconf[:PROMPT_N]
@return_format = pconf[:RETURN]
@return_format = "%s\n" if @return_format == nil
if ai = pconf.include?(:AUTO_INDENT)
@@ -428,8 +499,6 @@ module IRB
#
# Can also be set using the +--inspect+ and +--noinspect+ command line
# options.
- #
- # See IRB@Command+line+options for more command line options.
def inspect_mode=(opt)
if i = Inspector::INSPECTORS[opt]
@@ -473,28 +542,31 @@ module IRB
@inspect_mode
end
- def evaluate(line, line_no, exception: nil) # :nodoc:
+ def evaluate(line, line_no) # :nodoc:
@line_no = line_no
- if exception
- line_no -= 1
- line = "begin ::Kernel.raise _; rescue _.class\n#{line}\n""end"
- @workspace.local_variable_set(:_, exception)
- end
+ result = nil
- # Transform a non-identifier alias (@, $) or keywords (next, break)
- command, args = line.split(/\s/, 2)
- if original = command_aliases[command.to_sym]
- line = line.gsub(/\A#{Regexp.escape(command)}/, original.to_s)
- command = original
+ if IRB.conf[:MEASURE] && IRB.conf[:MEASURE_CALLBACKS].empty?
+ IRB.set_measure_callback
end
- # Hook command-specific transformation
- command_class = ExtendCommandBundle.load_command(command)
- if command_class&.respond_to?(:transform_args)
- line = "#{command} #{command_class.transform_args(args)}"
+ if IRB.conf[:MEASURE] && !IRB.conf[:MEASURE_CALLBACKS].empty?
+ last_proc = proc do
+ result = @workspace.evaluate(line, irb_path, line_no)
+ end
+ IRB.conf[:MEASURE_CALLBACKS].inject(last_proc) do |chain, item|
+ _name, callback, arg = item
+ proc do
+ callback.(self, line, line_no, arg) do
+ chain.call
+ end
+ end
+ end.call
+ else
+ result = @workspace.evaluate(line, irb_path, line_no)
end
- set_last_value(@workspace.evaluate(self, line, irb_path, line_no))
+ set_last_value(result)
end
def inspect_last_value # :nodoc:
diff --git a/lib/irb/debug.rb b/lib/irb/debug.rb
new file mode 100644
index 0000000000..1ec2335a8e
--- /dev/null
+++ b/lib/irb/debug.rb
@@ -0,0 +1,130 @@
+# frozen_string_literal: true
+
+module IRB
+ module Debug
+ IRB_DIR = File.expand_path('..', __dir__)
+
+ class << self
+ def insert_debug_break(pre_cmds: nil, do_cmds: nil)
+ options = { oneshot: true, hook_call: false }
+
+ if pre_cmds || do_cmds
+ options[:command] = ['irb', pre_cmds, do_cmds]
+ end
+ if DEBUGGER__::LineBreakpoint.instance_method(:initialize).parameters.include?([:key, :skip_src])
+ options[:skip_src] = true
+ end
+
+ # To make debugger commands like `next` or `continue` work without asking
+ # the user to quit IRB after that, we need to exit IRB first and then hit
+ # a TracePoint on #debug_break.
+ file, lineno = IRB::Irb.instance_method(:debug_break).source_location
+ DEBUGGER__::SESSION.add_line_breakpoint(file, lineno + 1, **options)
+ end
+
+ def setup(irb)
+ # When debug session is not started at all
+ unless defined?(DEBUGGER__::SESSION)
+ begin
+ require "debug/session"
+ rescue LoadError # debug.gem is not written in Gemfile
+ return false unless load_bundled_debug_gem
+ end
+ DEBUGGER__::CONFIG.set_config
+ configure_irb_for_debugger(irb)
+
+ DEBUGGER__.initialize_session{ IRB::Debug::UI.new(irb) }
+ end
+
+ # When debug session was previously started but not by IRB
+ if defined?(DEBUGGER__::SESSION) && !irb.context.with_debugger
+ configure_irb_for_debugger(irb)
+ DEBUGGER__::SESSION.reset_ui(IRB::Debug::UI.new(irb))
+ end
+
+ # Apply patches to debug gem so it skips IRB frames
+ unless DEBUGGER__.respond_to?(:capture_frames_without_irb)
+ DEBUGGER__.singleton_class.send(:alias_method, :capture_frames_without_irb, :capture_frames)
+
+ def DEBUGGER__.capture_frames(*args)
+ frames = capture_frames_without_irb(*args)
+ frames.reject! do |frame|
+ frame.realpath&.start_with?(IRB_DIR) || frame.path == "<internal:prelude>"
+ end
+ frames
+ end
+
+ DEBUGGER__::ThreadClient.prepend(SkipPathHelperForIRB)
+ end
+
+ if !@output_modifier_defined && !DEBUGGER__::CONFIG[:no_hint]
+ irb_output_modifier_proc = Reline.output_modifier_proc
+
+ Reline.output_modifier_proc = proc do |output, complete:|
+ unless output.strip.empty?
+ cmd = output.split(/\s/, 2).first
+
+ if !complete && DEBUGGER__.commands.key?(cmd)
+ output = output.sub(/\n$/, " # debug command\n")
+ end
+ end
+
+ irb_output_modifier_proc.call(output, complete: complete)
+ end
+
+ @output_modifier_defined = true
+ end
+
+ true
+ end
+
+ private
+
+ def configure_irb_for_debugger(irb)
+ require 'irb/debug/ui'
+ IRB.instance_variable_set(:@debugger_irb, irb)
+ irb.context.with_debugger = true
+ irb.context.irb_name += ":rdbg"
+ end
+
+ module SkipPathHelperForIRB
+ def skip_internal_path?(path)
+ # The latter can be removed once https://github.com/ruby/debug/issues/866 is resolved
+ super || path.match?(IRB_DIR) || path.match?('<internal:prelude>')
+ end
+ end
+
+ # This is used when debug.gem is not written in Gemfile. Even if it's not
+ # installed by `bundle install`, debug.gem is installed by default because
+ # it's a bundled gem. This method tries to activate and load that.
+ def load_bundled_debug_gem
+ # Discover latest debug.gem under GEM_PATH
+ debug_gem = Gem.paths.path.flat_map { |path| Dir.glob("#{path}/gems/debug-*") }.select do |path|
+ File.basename(path).match?(/\Adebug-\d+\.\d+\.\d+(\w+)?\z/)
+ end.sort_by do |path|
+ Gem::Version.new(File.basename(path).delete_prefix('debug-'))
+ end.last
+ return false unless debug_gem
+
+ # Discover debug/debug.so under extensions for Ruby 3.2+
+ ext_name = "/debug/debug.#{RbConfig::CONFIG['DLEXT']}"
+ ext_path = Gem.paths.path.flat_map do |path|
+ Dir.glob("#{path}/extensions/**/#{File.basename(debug_gem)}#{ext_name}")
+ end.first
+
+ # Attempt to forcibly load the bundled gem
+ if ext_path
+ $LOAD_PATH << ext_path.delete_suffix(ext_name)
+ end
+ $LOAD_PATH << "#{debug_gem}/lib"
+ begin
+ require "debug/session"
+ puts "Loaded #{File.basename(debug_gem)}"
+ true
+ rescue LoadError
+ false
+ end
+ end
+ end
+ end
+end
diff --git a/lib/irb/debug/ui.rb b/lib/irb/debug/ui.rb
new file mode 100644
index 0000000000..307097b8c9
--- /dev/null
+++ b/lib/irb/debug/ui.rb
@@ -0,0 +1,103 @@
+require 'io/console/size'
+require 'debug/console'
+
+module IRB
+ module Debug
+ class UI < DEBUGGER__::UI_Base
+ def initialize(irb)
+ @irb = irb
+ end
+
+ def remote?
+ false
+ end
+
+ def activate session, on_fork: false
+ end
+
+ def deactivate
+ end
+
+ def width
+ if (w = IO.console_size[1]) == 0 # for tests PTY
+ 80
+ else
+ w
+ end
+ end
+
+ def quit n
+ yield
+ exit n
+ end
+
+ def ask prompt
+ setup_interrupt do
+ print prompt
+ ($stdin.gets || '').strip
+ end
+ end
+
+ def puts str = nil
+ case str
+ when Array
+ str.each{|line|
+ $stdout.puts line.chomp
+ }
+ when String
+ str.each_line{|line|
+ $stdout.puts line.chomp
+ }
+ when nil
+ $stdout.puts
+ end
+ end
+
+ def readline _
+ setup_interrupt do
+ tc = DEBUGGER__::SESSION.instance_variable_get(:@tc)
+ cmd = @irb.debug_readline(tc.current_frame.binding || TOPLEVEL_BINDING)
+
+ case cmd
+ when nil # when user types C-d
+ "continue"
+ else
+ cmd
+ end
+ end
+ end
+
+ def setup_interrupt
+ DEBUGGER__::SESSION.intercept_trap_sigint false do
+ current_thread = Thread.current # should be session_server thread
+
+ prev_handler = trap(:INT){
+ current_thread.raise Interrupt
+ }
+
+ yield
+ ensure
+ trap(:INT, prev_handler)
+ end
+ end
+
+ def after_fork_parent
+ parent_pid = Process.pid
+
+ at_exit{
+ DEBUGGER__::SESSION.intercept_trap_sigint_end
+ trap(:SIGINT, :IGNORE)
+
+ if Process.pid == parent_pid
+ # only check child process from its parent
+ begin
+ # wait for all child processes to keep terminal
+ Process.waitpid
+ rescue Errno::ESRCH, Errno::ECHILD
+ end
+ end
+ }
+ end
+ end
+ end
+end
diff --git a/lib/irb/easter-egg.rb b/lib/irb/easter-egg.rb
index 3e79692de9..adc0834d55 100644
--- a/lib/irb/easter-egg.rb
+++ b/lib/irb/easter-egg.rb
@@ -98,18 +98,26 @@ module IRB
end
end
+ private def easter_egg_logo(type)
+ @easter_egg_logos ||= File.read(File.join(__dir__, 'ruby_logo.aa'), encoding: 'UTF-8:UTF-8')
+ .split(/TYPE: ([A-Z]+)\n/)[1..]
+ .each_slice(2)
+ .to_h
+ @easter_egg_logos[type.to_s.upcase]
+ end
+
private def easter_egg(type = nil)
type ||= [:logo, :dancing].sample
case type
when :logo
- File.open(File.join(__dir__, 'ruby_logo.aa')) do |f|
- require "rdoc"
- RDoc::RI::Driver.new.page do |io|
- IO.copy_stream(f, io)
- end
+ require "rdoc"
+ RDoc::RI::Driver.new.page do |io|
+ io.write easter_egg_logo(:large)
end
when :dancing
- begin
+ STDOUT.cooked do
+ interrupted = false
+ prev_trap = trap("SIGINT") { interrupted = true }
canvas = Canvas.new(Reline.get_screen_size)
Reline::IOGate.set_winch_handler do
canvas = Canvas.new(Reline.get_screen_size)
@@ -125,10 +133,12 @@ module IRB
buff[0, 20] = "\e[0mPress Ctrl+C to stop\e[31m\e[1m"
print "\e[H" + buff
sleep 0.05
+ break if interrupted
end
rescue Interrupt
ensure
print "\e[0m\e[?1049l"
+ trap("SIGINT", prev_trap)
end
end
end
diff --git a/lib/irb/ext/eval_history.rb b/lib/irb/ext/eval_history.rb
new file mode 100644
index 0000000000..1a04178b40
--- /dev/null
+++ b/lib/irb/ext/eval_history.rb
@@ -0,0 +1,149 @@
+# frozen_string_literal: false
+#
+# history.rb -
+# by Keiju ISHITSUKA(keiju@ruby-lang.org)
+#
+
+module IRB # :nodoc:
+
+ class Context
+
+ NOPRINTING_IVARS.push "@eval_history_values"
+
+ # See #set_last_value
+ alias _set_last_value set_last_value
+
+ def set_last_value(value)
+ _set_last_value(value)
+
+ if defined?(@eval_history) && @eval_history
+ @eval_history_values.push @line_no, @last_value
+ @workspace.evaluate "__ = IRB.CurrentContext.instance_eval{@eval_history_values}"
+ end
+
+ @last_value
+ end
+
+ remove_method :eval_history= if method_defined?(:eval_history=)
+ # The command result history limit. This method is not available until
+ # #eval_history= was called with non-nil value (directly or via
+ # setting <code>IRB.conf[:EVAL_HISTORY]</code> in <code>.irbrc</code>).
+ attr_reader :eval_history
+ # Sets command result history limit. Default value is set from
+ # <code>IRB.conf[:EVAL_HISTORY]</code>.
+ #
+ # +no+ is an Integer or +nil+.
+ #
+ # Returns +no+ of history items if greater than 0.
+ #
+ # If +no+ is 0, the number of history items is unlimited.
+ #
+ # If +no+ is +nil+, execution result history isn't used (default).
+ #
+ # EvalHistory values are available via <code>__</code> variable, see
+ # IRB::EvalHistory.
+ def eval_history=(no)
+ if no
+ if defined?(@eval_history) && @eval_history
+ @eval_history_values.size(no)
+ else
+ @eval_history_values = EvalHistory.new(no)
+ IRB.conf[:__TMP__EHV__] = @eval_history_values
+ @workspace.evaluate("__ = IRB.conf[:__TMP__EHV__]")
+ IRB.conf.delete(:__TMP_EHV__)
+ end
+ else
+ @eval_history_values = nil
+ end
+ @eval_history = no
+ end
+ end
+
+ # Represents history of results of previously evaluated commands.
+ #
+ # Available via <code>__</code> variable, only if <code>IRB.conf[:EVAL_HISTORY]</code>
+ # or <code>IRB::CurrentContext().eval_history</code> is non-nil integer value
+ # (by default it is +nil+).
+ #
+ # Example (in `irb`):
+ #
+ # # Initialize history
+ # IRB::CurrentContext().eval_history = 10
+ # # => 10
+ #
+ # # Perform some commands...
+ # 1 + 2
+ # # => 3
+ # puts 'x'
+ # # x
+ # # => nil
+ # raise RuntimeError
+ # # ...error raised
+ #
+ # # Inspect history (format is "<item number> <evaluated value>":
+ # __
+ # # => 1 10
+ # # 2 3
+ # # 3 nil
+ #
+ # __[1]
+ # # => 10
+ #
+ class EvalHistory
+
+ def initialize(size = 16) # :nodoc:
+ @size = size
+ @contents = []
+ end
+
+ def size(size) # :nodoc:
+ if size != 0 && size < @size
+ @contents = @contents[@size - size .. @size]
+ end
+ @size = size
+ end
+
+ # Get one item of the content (both positive and negative indexes work).
+ def [](idx)
+ begin
+ if idx >= 0
+ @contents.find{|no, val| no == idx}[1]
+ else
+ @contents[idx][1]
+ end
+ rescue NameError
+ nil
+ end
+ end
+
+ def push(no, val) # :nodoc:
+ @contents.push [no, val]
+ @contents.shift if @size != 0 && @contents.size > @size
+ end
+
+ alias real_inspect inspect
+
+ def inspect # :nodoc:
+ if @contents.empty?
+ return real_inspect
+ end
+
+ unless (last = @contents.pop)[1].equal?(self)
+ @contents.push last
+ last = nil
+ end
+ str = @contents.collect{|no, val|
+ if val.equal?(self)
+ "#{no} ...self-history..."
+ else
+ "#{no} #{val.inspect}"
+ end
+ }.join("\n")
+ if str == ""
+ str = "Empty."
+ end
+ @contents.push last if last
+ str
+ end
+ end
+end
diff --git a/lib/irb/ext/history.rb b/lib/irb/ext/history.rb
deleted file mode 100644
index 59aa9cb0c7..0000000000
--- a/lib/irb/ext/history.rb
+++ /dev/null
@@ -1,149 +0,0 @@
-# frozen_string_literal: false
-#
-# history.rb -
-# by Keiju ISHITSUKA(keiju@ruby-lang.org)
-#
-
-module IRB # :nodoc:
-
- class Context
-
- NOPRINTING_IVARS.push "@eval_history_values"
-
- # See #set_last_value
- alias _set_last_value set_last_value
-
- def set_last_value(value)
- _set_last_value(value)
-
- if defined?(@eval_history) && @eval_history
- @eval_history_values.push @line_no, @last_value
- @workspace.evaluate self, "__ = IRB.CurrentContext.instance_eval{@eval_history_values}"
- end
-
- @last_value
- end
-
- remove_method :eval_history= if method_defined?(:eval_history=)
- # The command result history limit. This method is not available until
- # #eval_history= was called with non-nil value (directly or via
- # setting <code>IRB.conf[:EVAL_HISTORY]</code> in <code>.irbrc</code>).
- attr_reader :eval_history
- # Sets command result history limit. Default value is set from
- # <code>IRB.conf[:EVAL_HISTORY]</code>.
- #
- # +no+ is an Integer or +nil+.
- #
- # Returns +no+ of history items if greater than 0.
- #
- # If +no+ is 0, the number of history items is unlimited.
- #
- # If +no+ is +nil+, execution result history isn't used (default).
- #
- # History values are available via <code>__</code> variable, see
- # IRB::History.
- def eval_history=(no)
- if no
- if defined?(@eval_history) && @eval_history
- @eval_history_values.size(no)
- else
- @eval_history_values = History.new(no)
- IRB.conf[:__TMP__EHV__] = @eval_history_values
- @workspace.evaluate(self, "__ = IRB.conf[:__TMP__EHV__]")
- IRB.conf.delete(:__TMP_EHV__)
- end
- else
- @eval_history_values = nil
- end
- @eval_history = no
- end
- end
-
- # Represents history of results of previously evaluated commands.
- #
- # Available via <code>__</code> variable, only if <code>IRB.conf[:EVAL_HISTORY]</code>
- # or <code>IRB::CurrentContext().eval_history</code> is non-nil integer value
- # (by default it is +nil+).
- #
- # Example (in `irb`):
- #
- # # Initialize history
- # IRB::CurrentContext().eval_history = 10
- # # => 10
- #
- # # Perform some commands...
- # 1 + 2
- # # => 3
- # puts 'x'
- # # x
- # # => nil
- # raise RuntimeError
- # # ...error raised
- #
- # # Inspect history (format is "<item number> <evaluated value>":
- # __
- # # => 1 10
- # # 2 3
- # # 3 nil
- #
- # __[1]
- # # => 10
- #
- class History
-
- def initialize(size = 16) # :nodoc:
- @size = size
- @contents = []
- end
-
- def size(size) # :nodoc:
- if size != 0 && size < @size
- @contents = @contents[@size - size .. @size]
- end
- @size = size
- end
-
- # Get one item of the content (both positive and negative indexes work).
- def [](idx)
- begin
- if idx >= 0
- @contents.find{|no, val| no == idx}[1]
- else
- @contents[idx][1]
- end
- rescue NameError
- nil
- end
- end
-
- def push(no, val) # :nodoc:
- @contents.push [no, val]
- @contents.shift if @size != 0 && @contents.size > @size
- end
-
- alias real_inspect inspect
-
- def inspect # :nodoc:
- if @contents.empty?
- return real_inspect
- end
-
- unless (last = @contents.pop)[1].equal?(self)
- @contents.push last
- last = nil
- end
- str = @contents.collect{|no, val|
- if val.equal?(self)
- "#{no} ...self-history..."
- else
- "#{no} #{val.inspect}"
- end
- }.join("\n")
- if str == ""
- str = "Empty."
- end
- @contents.push last if last
- str
- end
- end
-end
diff --git a/lib/irb/ext/loader.rb b/lib/irb/ext/loader.rb
index 0a599ee802..d65695df3b 100644
--- a/lib/irb/ext/loader.rb
+++ b/lib/irb/ext/loader.rb
@@ -24,31 +24,8 @@ module IRB # :nodoc:
load_file(path, priv)
end
- if File.respond_to?(:absolute_path?)
- def absolute_path?(path)
- File.absolute_path?(path)
- end
- else
- separator =
- if File::ALT_SEPARATOR
- "[#{Regexp.quote(File::SEPARATOR + File::ALT_SEPARATOR)}]"
- else
- File::SEPARATOR
- end
- ABSOLUTE_PATH_PATTERN = # :nodoc:
- case Dir.pwd
- when /\A\w:/, /\A#{separator}{2}/
- /\A(?:\w:|#{separator})#{separator}/
- else
- /\A#{separator}/
- end
- def absolute_path?(path)
- ABSOLUTE_PATH_PATTERN =~ path
- end
- end
-
def search_file_from_ruby_path(fn) # :nodoc:
- if absolute_path?(fn)
+ if File.absolute_path?(fn)
return fn if File.exist?(fn)
return nil
end
@@ -65,6 +42,7 @@ module IRB # :nodoc:
#
# See Irb#suspend_input_method for more information.
def source_file(path)
+ irb = irb_context.irb
irb.suspend_name(path, File.basename(path)) do
FileInputMethod.open(path) do |io|
irb.suspend_input_method(io) do
@@ -89,6 +67,7 @@ module IRB # :nodoc:
#
# See Irb#suspend_input_method for more information.
def load_file(path, priv = nil)
+ irb = irb_context.irb
irb.suspend_name(path, File.basename(path)) do
if priv
diff --git a/lib/irb/ext/save-history.rb b/lib/irb/ext/save-history.rb
deleted file mode 100644
index b1987ea646..0000000000
--- a/lib/irb/ext/save-history.rb
+++ /dev/null
@@ -1,125 +0,0 @@
-# frozen_string_literal: false
-#
-# save-history.rb -
-# by Keiju ISHITSUKA(keiju@ruby-lang.org)
-#
-
-module IRB
- module HistorySavingAbility # :nodoc:
- end
-
- class Context
- def init_save_history# :nodoc:
- unless (class<<@io;self;end).include?(HistorySavingAbility)
- @io.extend(HistorySavingAbility)
- end
- end
-
- # A copy of the default <code>IRB.conf[:SAVE_HISTORY]</code>
- def save_history
- IRB.conf[:SAVE_HISTORY]
- end
-
- remove_method(:save_history=) if method_defined?(:save_history=)
- # Sets <code>IRB.conf[:SAVE_HISTORY]</code> to the given +val+ and calls
- # #init_save_history with this context.
- #
- # Will store the number of +val+ entries of history in the #history_file
- #
- # Add the following to your +.irbrc+ to change the number of history
- # entries stored to 1000:
- #
- # IRB.conf[:SAVE_HISTORY] = 1000
- def save_history=(val)
- IRB.conf[:SAVE_HISTORY] = val
- if val
- main_context = IRB.conf[:MAIN_CONTEXT]
- main_context = self unless main_context
- main_context.init_save_history
- end
- end
-
- # A copy of the default <code>IRB.conf[:HISTORY_FILE]</code>
- def history_file
- IRB.conf[:HISTORY_FILE]
- end
-
- # Set <code>IRB.conf[:HISTORY_FILE]</code> to the given +hist+.
- def history_file=(hist)
- IRB.conf[:HISTORY_FILE] = hist
- end
- end
-
- module HistorySavingAbility # :nodoc:
- def HistorySavingAbility.extended(obj)
- IRB.conf[:AT_EXIT].push proc{obj.save_history}
- obj.load_history
- obj
- end
-
- def load_history
- return unless self.class.const_defined?(:HISTORY)
- history = self.class::HISTORY
- if history_file = IRB.conf[:HISTORY_FILE]
- history_file = File.expand_path(history_file)
- end
- history_file = IRB.rc_file("_history") unless history_file
- if File.exist?(history_file)
- File.open(history_file, "r:#{IRB.conf[:LC_MESSAGES].encoding}") do |f|
- f.each { |l|
- l = l.chomp
- if self.class == RelineInputMethod and history.last&.end_with?("\\")
- history.last.delete_suffix!("\\")
- history.last << "\n" << l
- else
- history << l
- end
- }
- end
- @loaded_history_lines = history.size
- @loaded_history_mtime = File.mtime(history_file)
- end
- end
-
- def save_history
- return unless self.class.const_defined?(:HISTORY)
- history = self.class::HISTORY
- if num = IRB.conf[:SAVE_HISTORY] and (num = num.to_i) != 0
- if history_file = IRB.conf[:HISTORY_FILE]
- history_file = File.expand_path(history_file)
- end
- history_file = IRB.rc_file("_history") unless history_file
-
- # Change the permission of a file that already exists[BUG #7694]
- begin
- if File.stat(history_file).mode & 066 != 0
- File.chmod(0600, history_file)
- end
- rescue Errno::ENOENT
- rescue Errno::EPERM
- return
- rescue
- raise
- end
-
- if File.exist?(history_file) &&
- File.mtime(history_file) != @loaded_history_mtime
- history = history[@loaded_history_lines..-1] if @loaded_history_lines
- append_history = true
- end
-
- File.open(history_file, (append_history ? 'a' : 'w'), 0o600, encoding: IRB.conf[:LC_MESSAGES]&.encoding) do |f|
- hist = history.map{ |l| l.split("\n").join("\\\n") }
- unless append_history
- begin
- hist = hist.last(num) if hist.size > num and num > 0
- rescue RangeError # bignum too big to convert into `long'
- # Do nothing because the bignum should be treated as inifinity
- end
- end
- f.puts(hist)
- end
- end
- end
- end
-end
diff --git a/lib/irb/ext/tracer.rb b/lib/irb/ext/tracer.rb
index 56beb0a1dd..3eaeb70ef2 100644
--- a/lib/irb/ext/tracer.rb
+++ b/lib/irb/ext/tracer.rb
@@ -7,9 +7,8 @@
begin
require "tracer"
rescue LoadError
- $stderr.puts "Tracer extension of IRB is enabled but tracer gem doesn't found."
+ $stderr.puts "Tracer extension of IRB is enabled but tracer gem wasn't found."
module IRB
- TracerLoadError = true
class Context
def use_tracer=(opt)
# do nothing
@@ -65,12 +64,12 @@ module IRB
if context.use_tracer? && file != nil && line != nil
Tracer.on
begin
- __evaluate__(context, statements, file, line)
+ __evaluate__(statements, file, line)
ensure
Tracer.off
end
else
- __evaluate__(context, statements, file || __FILE__, line || __LINE__)
+ __evaluate__(statements, file || __FILE__, line || __LINE__)
end
end
end
diff --git a/lib/irb/extend-command.rb b/lib/irb/extend-command.rb
index 5020b1e5cd..072069d4c4 100644
--- a/lib/irb/extend-command.rb
+++ b/lib/irb/extend-command.rb
@@ -157,11 +157,15 @@ module IRB # :nodoc:
[
:irb_help, :Help, "cmd/help",
- [:show_doc, NO_OVERRIDE],
[:help, NO_OVERRIDE],
],
[
+ :irb_show_doc, :ShowDoc, "cmd/show_doc",
+ [:show_doc, NO_OVERRIDE],
+ ],
+
+ [
:irb_info, :IrbInfo, "cmd/irb_info"
],
@@ -187,6 +191,12 @@ module IRB # :nodoc:
[
:irb_show_cmds, :ShowCmds, "cmd/show_cmds",
[:show_cmds, NO_OVERRIDE],
+ ],
+
+ [
+ :irb_history, :History, "cmd/history",
+ [:history, NO_OVERRIDE],
+ [:hist, NO_OVERRIDE],
]
]
@@ -246,7 +256,7 @@ module IRB # :nodoc:
#
# The optional +load_file+ parameter will be required within the method
# definition.
- def self.def_extend_command(cmd_name, cmd_class, load_file = nil, *aliases)
+ def self.def_extend_command(cmd_name, cmd_class, load_file, *aliases)
case cmd_class
when Symbol
cmd_class = cmd_class.id2name
@@ -255,34 +265,12 @@ module IRB # :nodoc:
cmd_class = cmd_class.name
end
- if load_file
- kwargs = ", **kwargs" if RUBY_ENGINE == "ruby" && RUBY_VERSION >= "2.7.0"
- line = __LINE__; eval %[
- def #{cmd_name}(*opts#{kwargs}, &b)
- Kernel.require_relative "#{load_file}"
- arity = ::IRB::ExtendCommand::#{cmd_class}.instance_method(:execute).arity
- args = (1..(arity < 0 ? ~arity : arity)).map {|i| "arg" + i.to_s }
- args << "*opts#{kwargs}" if arity < 0
- args << "&block"
- args = args.join(", ")
- line = __LINE__; eval %[
- unless singleton_class.class_variable_defined?(:@@#{cmd_name}_)
- singleton_class.class_variable_set(:@@#{cmd_name}_, true)
- def self.#{cmd_name}_(\#{args})
- ::IRB::ExtendCommand::#{cmd_class}.execute(irb_context, \#{args})
- end
- end
- ], nil, __FILE__, line
- __send__ :#{cmd_name}_, *opts#{kwargs}, &b
- end
- ], nil, __FILE__, line
- else
- line = __LINE__; eval %[
- def #{cmd_name}(*opts, &b)
- ::IRB::ExtendCommand::#{cmd_class}.execute(irb_context, *opts, &b)
- end
- ], nil, __FILE__, line
- end
+ line = __LINE__; eval %[
+ def #{cmd_name}(*opts, **kwargs, &b)
+ Kernel.require_relative "#{load_file}"
+ ::IRB::ExtendCommand::#{cmd_class}.execute(irb_context, *opts, **kwargs, &b)
+ end
+ ], nil, __FILE__, line
for ali, flag in aliases
@ALIASES.push [ali, cmd_name, flag]
@@ -307,7 +295,7 @@ module IRB # :nodoc:
alias_method to, from
}
else
- Kernel.print "irb: warn: can't alias #{to} from #{from}.\n"
+ Kernel.warn "irb: warn: can't alias #{to} from #{from}.\n"
end
end
@@ -334,10 +322,9 @@ module IRB # :nodoc:
CE = ContextExtender # :nodoc:
@EXTEND_COMMANDS = [
- [:eval_history=, "ext/history.rb"],
+ [:eval_history=, "ext/eval_history.rb"],
[:use_tracer=, "ext/tracer.rb"],
[:use_loader=, "ext/use-loader.rb"],
- [:save_history=, "ext/save-history.rb"],
]
# Installs the default context extensions as irb commands:
@@ -345,7 +332,6 @@ module IRB # :nodoc:
# Context#eval_history=:: +irb/ext/history.rb+
# Context#use_tracer=:: +irb/ext/tracer.rb+
# Context#use_loader=:: +irb/ext/use-loader.rb+
- # Context#save_history=:: +irb/ext/save-history.rb+
def self.install_extend_commands
for args in @EXTEND_COMMANDS
def_extend_command(*args)
@@ -371,58 +357,4 @@ module IRB # :nodoc:
CE.install_extend_commands
end
-
- # A convenience module for extending Ruby methods.
- module MethodExtender
- # Extends the given +base_method+ with a prefix call to the given
- # +extend_method+.
- def def_pre_proc(base_method, extend_method)
- base_method = base_method.to_s
- extend_method = extend_method.to_s
-
- alias_name = new_alias_name(base_method)
- module_eval %[
- alias_method alias_name, base_method
- def #{base_method}(*opts)
- __send__ :#{extend_method}, *opts
- __send__ :#{alias_name}, *opts
- end
- ]
- end
-
- # Extends the given +base_method+ with a postfix call to the given
- # +extend_method+.
- def def_post_proc(base_method, extend_method)
- base_method = base_method.to_s
- extend_method = extend_method.to_s
-
- alias_name = new_alias_name(base_method)
- module_eval %[
- alias_method alias_name, base_method
- def #{base_method}(*opts)
- __send__ :#{alias_name}, *opts
- __send__ :#{extend_method}, *opts
- end
- ]
- end
-
- # Returns a unique method name to use as an alias for the given +name+.
- #
- # Usually returns <code>#{prefix}#{name}#{postfix}<num></code>, example:
- #
- # new_alias_name('foo') #=> __alias_of__foo__
- # def bar; end
- # new_alias_name('bar') #=> __alias_of__bar__2
- def new_alias_name(name, prefix = "__alias_of__", postfix = "__")
- base_name = "#{prefix}#{name}#{postfix}"
- all_methods = instance_methods(true) + private_instance_methods(true)
- same_methods = all_methods.grep(/^#{Regexp.quote(base_name)}[0-9]*$/)
- return base_name if same_methods.empty?
- no = same_methods.size
- while !same_methods.include?(alias_name = base_name + no)
- no += 1
- end
- alias_name
- end
- end
end
diff --git a/lib/irb/help.rb b/lib/irb/help.rb
index 7624d05dd4..6861d7efc8 100644
--- a/lib/irb/help.rb
+++ b/lib/irb/help.rb
@@ -4,15 +4,13 @@
# by Keiju ISHITSUKA(keiju@ishitsuka.com)
#
-require_relative 'magic-file'
-
module IRB
- # Outputs the irb help message, see IRB@Command+line+options.
+ # Outputs the irb help message, see IRB@Command-Line+Options.
def IRB.print_usage
lc = IRB.conf[:LC_MESSAGES]
path = lc.find("irb/help-message")
space_line = false
- IRB::MagicFile.open(path){|f|
+ File.open(path){|f|
f.each_line do |l|
if /^\s*$/ =~ l
lc.puts l unless space_line
diff --git a/lib/irb/history.rb b/lib/irb/history.rb
new file mode 100644
index 0000000000..06088adb0d
--- /dev/null
+++ b/lib/irb/history.rb
@@ -0,0 +1,76 @@
+module IRB
+ module HistorySavingAbility # :nodoc:
+ def support_history_saving?
+ true
+ end
+
+ def reset_history_counter
+ @loaded_history_lines = self.class::HISTORY.size if defined? @loaded_history_lines
+ end
+
+ def load_history
+ history = self.class::HISTORY
+
+ if history_file = IRB.conf[:HISTORY_FILE]
+ history_file = File.expand_path(history_file)
+ end
+ history_file = IRB.rc_file("_history") unless history_file
+ if File.exist?(history_file)
+ File.open(history_file, "r:#{IRB.conf[:LC_MESSAGES].encoding}") do |f|
+ f.each { |l|
+ l = l.chomp
+ if self.class == RelineInputMethod and history.last&.end_with?("\\")
+ history.last.delete_suffix!("\\")
+ history.last << "\n" << l
+ else
+ history << l
+ end
+ }
+ end
+ @loaded_history_lines = history.size
+ @loaded_history_mtime = File.mtime(history_file)
+ end
+ end
+
+ def save_history
+ history = self.class::HISTORY.to_a
+
+ if num = IRB.conf[:SAVE_HISTORY] and (num = num.to_i) != 0
+ if history_file = IRB.conf[:HISTORY_FILE]
+ history_file = File.expand_path(history_file)
+ end
+ history_file = IRB.rc_file("_history") unless history_file
+
+ # Change the permission of a file that already exists[BUG #7694]
+ begin
+ if File.stat(history_file).mode & 066 != 0
+ File.chmod(0600, history_file)
+ end
+ rescue Errno::ENOENT
+ rescue Errno::EPERM
+ return
+ rescue
+ raise
+ end
+
+ if File.exist?(history_file) &&
+ File.mtime(history_file) != @loaded_history_mtime
+ history = history[@loaded_history_lines..-1] if @loaded_history_lines
+ append_history = true
+ end
+
+ File.open(history_file, (append_history ? 'a' : 'w'), 0o600, encoding: IRB.conf[:LC_MESSAGES]&.encoding) do |f|
+ hist = history.map{ |l| l.scrub.split("\n").join("\\\n") }
+ unless append_history
+ begin
+ hist = hist.last(num) if hist.size > num and num > 0
+ rescue RangeError # bignum too big to convert into `long'
+ # Do nothing because the bignum should be treated as inifinity
+ end
+ end
+ f.puts(hist)
+ end
+ end
+ end
+ end
+end
diff --git a/lib/irb/init.rb b/lib/irb/init.rb
index f790f7f41d..66e7b61468 100644
--- a/lib/irb/init.rb
+++ b/lib/irb/init.rb
@@ -5,6 +5,41 @@
#
module IRB # :nodoc:
+ @CONF = {}
+ # Displays current configuration.
+ #
+ # Modifying the configuration is achieved by sending a message to IRB.conf.
+ #
+ # See IRB@Configuration for more information.
+ def IRB.conf
+ @CONF
+ end
+
+ def @CONF.inspect
+ array = []
+ for k, v in sort{|a1, a2| a1[0].id2name <=> a2[0].id2name}
+ case k
+ when :MAIN_CONTEXT, :__TMP__EHV__
+ array.push format("CONF[:%s]=...myself...", k.id2name)
+ when :PROMPT
+ s = v.collect{
+ |kk, vv|
+ ss = vv.collect{|kkk, vvv| ":#{kkk.id2name}=>#{vvv.inspect}"}
+ format(":%s=>{%s}", kk.id2name, ss.join(", "))
+ }
+ array.push format("CONF[:%s]={%s}", k.id2name, s.join(", "))
+ else
+ array.push format("CONF[:%s]=%s", k.id2name, v.inspect)
+ end
+ end
+ array.join("\n")
+ end
+
+ # Returns the current version of IRB, including release version and last
+ # updated date.
+ def IRB.version
+ format("irb %s (%s)", @RELEASE_VERSION, @LAST_UPDATE_DATE)
+ end
# initialize config
def IRB.setup(ap_path, argv: ::ARGV)
@@ -28,6 +63,7 @@ module IRB # :nodoc:
unless ap_path and @CONF[:AP_NAME]
ap_path = File.join(File.dirname(File.dirname(__FILE__)), "irb.rb")
end
+ @CONF[:VERSION] = version
@CONF[:AP_NAME] = File::basename(ap_path, ".rb")
@CONF[:IRB_NAME] = "irb"
@@ -40,11 +76,13 @@ module IRB # :nodoc:
@CONF[:USE_SINGLELINE] = false unless defined?(ReadlineInputMethod)
@CONF[:USE_COLORIZE] = (nc = ENV['NO_COLOR']).nil? || nc.empty?
@CONF[:USE_AUTOCOMPLETE] = ENV.fetch("IRB_USE_AUTOCOMPLETE", "true") != "false"
+ @CONF[:COMPLETOR] = ENV.fetch("IRB_COMPLETOR", "regexp").to_sym
@CONF[:INSPECT_MODE] = true
@CONF[:USE_TRACER] = false
@CONF[:USE_LOADER] = false
@CONF[:IGNORE_SIGINT] = true
@CONF[:IGNORE_EOF] = false
+ @CONF[:USE_PAGER] = true
@CONF[:EXTRA_DOC_DIRS] = []
@CONF[:ECHO] = nil
@CONF[:ECHO_ON_ASSIGNMENT] = nil
@@ -58,35 +96,30 @@ module IRB # :nodoc:
@CONF[:PROMPT] = {
:NULL => {
:PROMPT_I => nil,
- :PROMPT_N => nil,
:PROMPT_S => nil,
:PROMPT_C => nil,
:RETURN => "%s\n"
},
:DEFAULT => {
- :PROMPT_I => "%N(%m):%03n:%i> ",
- :PROMPT_N => "%N(%m):%03n:%i> ",
- :PROMPT_S => "%N(%m):%03n:%i%l ",
- :PROMPT_C => "%N(%m):%03n:%i* ",
+ :PROMPT_I => "%N(%m):%03n> ",
+ :PROMPT_S => "%N(%m):%03n%l ",
+ :PROMPT_C => "%N(%m):%03n* ",
:RETURN => "=> %s\n"
},
:CLASSIC => {
:PROMPT_I => "%N(%m):%03n:%i> ",
- :PROMPT_N => "%N(%m):%03n:%i> ",
:PROMPT_S => "%N(%m):%03n:%i%l ",
:PROMPT_C => "%N(%m):%03n:%i* ",
:RETURN => "%s\n"
},
:SIMPLE => {
:PROMPT_I => ">> ",
- :PROMPT_N => ">> ",
:PROMPT_S => "%l> ",
:PROMPT_C => "?> ",
:RETURN => "=> %s\n"
},
:INF_RUBY => {
- :PROMPT_I => "%N(%m):%03n:%i> ",
- :PROMPT_N => nil,
+ :PROMPT_I => "%N(%m):%03n> ",
:PROMPT_S => nil,
:PROMPT_C => nil,
:RETURN => "%s\n",
@@ -94,7 +127,6 @@ module IRB # :nodoc:
},
:XMP => {
:PROMPT_I => nil,
- :PROMPT_N => nil,
:PROMPT_S => nil,
:PROMPT_C => nil,
:RETURN => " ==>%s\n"
@@ -157,10 +189,6 @@ module IRB # :nodoc:
# Symbol aliases
:'$' => :show_source,
:'@' => :whereami,
- # Keyword aliases
- :break => :irb_break,
- :catch => :irb_catch,
- :next => :irb_next,
}
end
@@ -187,6 +215,7 @@ module IRB # :nodoc:
added = [:TIME, IRB.conf[:MEASURE_PROC][:TIME], arg]
end
if added
+ IRB.conf[:MEASURE] = true
found = IRB.conf[:MEASURE_CALLBACKS].find{ |m| m[0] == added[0] && m[2] == added[2] }
if found
# already added
@@ -207,6 +236,7 @@ module IRB # :nodoc:
type_sym = type.upcase.to_sym
IRB.conf[:MEASURE_CALLBACKS].reject!{ |t, | t == type_sym }
end
+ IRB.conf[:MEASURE] = nil if IRB.conf[:MEASURE_CALLBACKS].empty?
end
def IRB.init_error
@@ -254,6 +284,8 @@ module IRB # :nodoc:
end
when "--noinspect"
@CONF[:INSPECT_MODE] = false
+ when "--no-pager"
+ @CONF[:USE_PAGER] = false
when "--singleline", "--readline", "--legacy"
@CONF[:USE_SINGLELINE] = true
when "--nosingleline", "--noreadline"
@@ -299,6 +331,10 @@ module IRB # :nodoc:
@CONF[:USE_AUTOCOMPLETE] = true
when "--noautocomplete"
@CONF[:USE_AUTOCOMPLETE] = false
+ when "--regexp-completor"
+ @CONF[:COMPLETOR] = :regexp
+ when "--type-completor"
+ @CONF[:COMPLETOR] = :type
when /^--prompt-mode(?:=(.+))?/, /^--prompt(?:=(.+))?/
opt = $1 || argv.shift
prompt_mode = opt.upcase.tr("-", "_").intern
@@ -353,18 +389,16 @@ module IRB # :nodoc:
$LOAD_PATH.unshift(*load_path)
end
- # running config
+ # Run the config file
def IRB.run_config
if @CONF[:RC]
begin
- load rc_file
- rescue LoadError, Errno::ENOENT
- rescue # StandardError, ScriptError
- print "load error: #{rc_file}\n"
- print $!.class, ": ", $!, "\n"
- for err in $@[0, $@.size - 2]
- print "\t", err, "\n"
- end
+ file = rc_file
+ # Because rc_file always returns `HOME/.irbrc` even if no rc file is present, we can't warn users about missing rc files.
+ # Otherwise, it'd be very noisy.
+ load file if File.exist?(file)
+ rescue StandardError, ScriptError => e
+ warn "Error loading RC file '#{file}':\n#{e.full_message(highlight: false)}"
end
end
end
@@ -382,7 +416,7 @@ module IRB # :nodoc:
end
case rc_file = @CONF[:RC_NAME_GENERATOR].call(ext)
when String
- return rc_file
+ rc_file
else
fail IllegalRCNameGenerator
end
@@ -421,8 +455,6 @@ module IRB # :nodoc:
end
end
-
- DefaultEncodings = Struct.new(:external, :internal)
class << IRB
private
def set_encoding(extern, intern = nil, override: true)
diff --git a/lib/irb/input-method.rb b/lib/irb/input-method.rb
index bc61805ebb..b74974b925 100644
--- a/lib/irb/input-method.rb
+++ b/lib/irb/input-method.rb
@@ -4,22 +4,14 @@
# by Keiju ISHITSUKA(keiju@ruby-lang.org)
#
-require_relative 'src_encoding'
-require_relative 'magic-file'
require_relative 'completion'
+require_relative "history"
require 'io/console'
require 'reline'
module IRB
- STDIN_FILE_NAME = "(line)" # :nodoc:
class InputMethod
-
- # Creates a new input method object
- def initialize(file = STDIN_FILE_NAME)
- @file_name = file
- end
- # The file name of this input method, usually given during initialization.
- attr_reader :file_name
+ BASIC_WORD_BREAK_CHARACTERS = " \t\n`><=;|&{("
# The irb prompt associated with this input method
attr_accessor :prompt
@@ -48,6 +40,10 @@ module IRB
false
end
+ def support_history_saving?
+ false
+ end
+
# For debug message
def inspect
'Abstract InputMethod'
@@ -57,7 +53,6 @@ module IRB
class StdioInputMethod < InputMethod
# Creates a new input method object
def initialize
- super
@line_no = 0
@line = []
@stdin = IO.open(STDIN.to_i, :external_encoding => IRB.conf[:LC_MESSAGES].encoding, :internal_encoding => "-")
@@ -131,12 +126,9 @@ module IRB
# Creates a new input method object
def initialize(file)
- super
- @io = file.is_a?(IO) ? file : IRB::MagicFile.open(file)
+ @io = file.is_a?(IO) ? file : File.open(file)
@external_encoding = @io.external_encoding
end
- # The file name of this input method, usually given during initialization.
- attr_reader :file_name
# Whether the end of this input method has been reached, returns +true+ if
# there is no more data to read.
@@ -169,114 +161,95 @@ module IRB
end
end
- begin
- class ReadlineInputMethod < InputMethod
- def self.initialize_readline
- require "readline"
- rescue LoadError
- else
- include ::Readline
- end
-
- # Creates a new input method object using Readline
- def initialize
- self.class.initialize_readline
- if Readline.respond_to?(:encoding_system_needs)
- IRB.__send__(:set_encoding, Readline.encoding_system_needs.name, override: false)
- end
- super
-
- @line_no = 0
- @line = []
- @eof = false
+ class ReadlineInputMethod < StdioInputMethod
+ def self.initialize_readline
+ require "readline"
+ rescue LoadError
+ else
+ include ::Readline
+ end
- @stdin = IO.open(STDIN.to_i, :external_encoding => IRB.conf[:LC_MESSAGES].encoding, :internal_encoding => "-")
- @stdout = IO.open(STDOUT.to_i, 'w', :external_encoding => IRB.conf[:LC_MESSAGES].encoding, :internal_encoding => "-")
+ include HistorySavingAbility
- if Readline.respond_to?("basic_word_break_characters=")
- Readline.basic_word_break_characters = IRB::InputCompletor::BASIC_WORD_BREAK_CHARACTERS
- end
- Readline.completion_append_character = nil
- Readline.completion_proc = IRB::InputCompletor::CompletionProc
+ # Creates a new input method object using Readline
+ def initialize
+ self.class.initialize_readline
+ if Readline.respond_to?(:encoding_system_needs)
+ IRB.__send__(:set_encoding, Readline.encoding_system_needs.name, override: false)
end
- # Reads the next line from this input method.
- #
- # See IO#gets for more information.
- def gets
- Readline.input = @stdin
- Readline.output = @stdout
- if l = readline(@prompt, false)
- HISTORY.push(l) if !l.empty?
- @line[@line_no += 1] = l + "\n"
- else
- @eof = true
- l
- end
- end
+ super
- # Whether the end of this input method has been reached, returns +true+
- # if there is no more data to read.
- #
- # See IO#eof? for more information.
- def eof?
- @eof
- end
+ @eof = false
+ @completor = RegexpCompletor.new
- # Whether this input method is still readable when there is no more data to
- # read.
- #
- # See IO#eof for more information.
- def readable_after_eof?
- true
+ if Readline.respond_to?("basic_word_break_characters=")
+ Readline.basic_word_break_characters = BASIC_WORD_BREAK_CHARACTERS
end
+ Readline.completion_append_character = nil
+ Readline.completion_proc = ->(target) {
+ bind = IRB.conf[:MAIN_CONTEXT].workspace.binding
+ @completor.completion_candidates('', target, '', bind: bind)
+ }
+ end
- # Returns the current line number for #io.
- #
- # #line counts the number of times #gets is called.
- #
- # See IO#lineno for more information.
- def line(line_no)
- @line[line_no]
- end
+ def completion_info
+ 'RegexpCompletor'
+ end
- # The external encoding for standard input.
- def encoding
- @stdin.external_encoding
+ # Reads the next line from this input method.
+ #
+ # See IO#gets for more information.
+ def gets
+ Readline.input = @stdin
+ Readline.output = @stdout
+ if l = readline(@prompt, false)
+ HISTORY.push(l) if !l.empty?
+ @line[@line_no += 1] = l + "\n"
+ else
+ @eof = true
+ l
end
+ end
- # For debug message
- def inspect
- readline_impl = (defined?(Reline) && Readline == Reline) ? 'Reline' : 'ext/readline'
- str = "ReadlineInputMethod with #{readline_impl} #{Readline::VERSION}"
- inputrc_path = File.expand_path(ENV['INPUTRC'] || '~/.inputrc')
- str += " and #{inputrc_path}" if File.exist?(inputrc_path)
- str
- end
+ # Whether the end of this input method has been reached, returns +true+
+ # if there is no more data to read.
+ #
+ # See IO#eof? for more information.
+ def eof?
+ @eof
end
- end
- class RelineInputMethod < InputMethod
- include Reline
+ # For debug message
+ def inspect
+ readline_impl = (defined?(Reline) && Readline == Reline) ? 'Reline' : 'ext/readline'
+ str = "ReadlineInputMethod with #{readline_impl} #{Readline::VERSION}"
+ inputrc_path = File.expand_path(ENV['INPUTRC'] || '~/.inputrc')
+ str += " and #{inputrc_path}" if File.exist?(inputrc_path)
+ str
+ end
+ end
+ class RelineInputMethod < StdioInputMethod
+ HISTORY = Reline::HISTORY
+ include HistorySavingAbility
# Creates a new input method object using Reline
- def initialize
+ def initialize(completor)
IRB.__send__(:set_encoding, Reline.encoding_system_needs.name, override: false)
- super
- @line_no = 0
- @line = []
- @eof = false
+ super()
- @stdin = ::IO.open(STDIN.to_i, :external_encoding => IRB.conf[:LC_MESSAGES].encoding, :internal_encoding => "-")
- @stdout = ::IO.open(STDOUT.to_i, 'w', :external_encoding => IRB.conf[:LC_MESSAGES].encoding, :internal_encoding => "-")
+ @eof = false
+ @completor = completor
- if Reline.respond_to?("basic_word_break_characters=")
- Reline.basic_word_break_characters = IRB::InputCompletor::BASIC_WORD_BREAK_CHARACTERS
- end
+ Reline.basic_word_break_characters = BASIC_WORD_BREAK_CHARACTERS
Reline.completion_append_character = nil
Reline.completer_quote_characters = ''
- Reline.completion_proc = IRB::InputCompletor::CompletionProc
+ Reline.completion_proc = ->(target, preposing, postposing) {
+ bind = IRB.conf[:MAIN_CONTEXT].workspace.binding
+ @completion_params = [preposing, target, postposing, bind]
+ @completor.completion_candidates(preposing, target, postposing, bind: bind)
+ }
Reline.output_modifier_proc =
if IRB.conf[:USE_COLORIZE]
proc do |output, complete: |
@@ -289,18 +262,23 @@ module IRB
Reline::Unicode.escape_for_print(output)
end
end
- Reline.dig_perfect_match_proc = IRB::InputCompletor::PerfectMatchedProc
+ Reline.dig_perfect_match_proc = ->(matched) { display_document(matched) }
Reline.autocompletion = IRB.conf[:USE_AUTOCOMPLETE]
if IRB.conf[:USE_AUTOCOMPLETE]
begin
require 'rdoc'
- Reline.add_dialog_proc(:show_doc, SHOW_DOC_DIALOG, Reline::DEFAULT_DIALOG_CONTEXT)
+ Reline.add_dialog_proc(:show_doc, show_doc_dialog_proc, Reline::DEFAULT_DIALOG_CONTEXT)
rescue LoadError
end
end
end
+ def completion_info
+ autocomplete_message = Reline.autocompletion ? 'Autocomplete' : 'Tab Complete'
+ "#{autocomplete_message}, #{@completor.inspect}"
+ end
+
def check_termination(&block)
@check_termination_proc = block
end
@@ -313,98 +291,155 @@ module IRB
@auto_indent_proc = block
end
- SHOW_DOC_DIALOG = ->() {
- dialog.trap_key = nil
- alt_d = [
- [Reline::Key.new(nil, 0xE4, true)], # Normal Alt+d.
- [27, 100], # Normal Alt+d when convert-meta isn't used.
- [195, 164], # The "ä" that appears when Alt+d is pressed on xterm.
- [226, 136, 130] # The "∂" that appears when Alt+d in pressed on iTerm2.
- ]
+ def show_doc_dialog_proc
+ doc_namespace = ->(matched) {
+ preposing, _target, postposing, bind = @completion_params
+ @completor.doc_namespace(preposing, matched, postposing, bind: bind)
+ }
+ ->() {
+ dialog.trap_key = nil
+ alt_d = [
+ [Reline::Key.new(nil, 0xE4, true)], # Normal Alt+d.
+ [27, 100], # Normal Alt+d when convert-meta isn't used.
+ [195, 164], # The "ä" that appears when Alt+d is pressed on xterm.
+ [226, 136, 130] # The "∂" that appears when Alt+d in pressed on iTerm2.
+ ]
+
+ if just_cursor_moving and completion_journey_data.nil?
+ return nil
+ end
+ cursor_pos_to_render, result, pointer, autocomplete_dialog = context.pop(4)
+ return nil if result.nil? or pointer.nil? or pointer < 0
- if just_cursor_moving and completion_journey_data.nil?
- return nil
- end
- cursor_pos_to_render, result, pointer, autocomplete_dialog = context.pop(4)
- return nil if result.nil? or pointer.nil? or pointer < 0
- name = result[pointer]
- name = IRB::InputCompletor.retrieve_completion_data(name, doc_namespace: true)
+ name = doc_namespace.call(result[pointer])
+ # Use first one because document dialog does not support multiple namespaces.
+ name = name.first if name.is_a?(Array)
- options = {}
- options[:extra_doc_dirs] = IRB.conf[:EXTRA_DOC_DIRS] unless IRB.conf[:EXTRA_DOC_DIRS].empty?
- driver = RDoc::RI::Driver.new(options)
+ show_easter_egg = name&.match?(/\ARubyVM/) && !ENV['RUBY_YES_I_AM_NOT_A_NORMAL_USER']
- if key.match?(dialog.name)
- begin
- driver.display_names([name])
- rescue RDoc::RI::Driver::NotFoundError
- end
- end
+ options = {}
+ options[:extra_doc_dirs] = IRB.conf[:EXTRA_DOC_DIRS] unless IRB.conf[:EXTRA_DOC_DIRS].empty?
+ driver = RDoc::RI::Driver.new(options)
- begin
- name = driver.expand_name(name)
- rescue RDoc::RI::Driver::NotFoundError
- return nil
- rescue
- return nil # unknown error
- end
- doc = nil
- used_for_class = false
- if not name =~ /#|\./
- found, klasses, includes, extends = driver.classes_and_includes_and_extends_for(name)
- if not found.empty?
- doc = driver.class_document(name, found, klasses, includes, extends)
- used_for_class = true
+ if key.match?(dialog.name)
+ if show_easter_egg
+ IRB.__send__(:easter_egg)
+ else
+ begin
+ driver.display_names([name])
+ rescue RDoc::RI::Driver::NotFoundError
+ end
+ end
end
- end
- unless used_for_class
- doc = RDoc::Markup::Document.new
+
begin
- driver.add_method(doc, name)
+ name = driver.expand_name(name)
rescue RDoc::RI::Driver::NotFoundError
- doc = nil
+ return nil
rescue
return nil # unknown error
end
- end
- return nil if doc.nil?
- width = 40
-
- right_x = cursor_pos_to_render.x + autocomplete_dialog.width
- if right_x + width > screen_width
- right_width = screen_width - (right_x + 1)
- left_x = autocomplete_dialog.column - width
- left_x = 0 if left_x < 0
- left_width = width > autocomplete_dialog.column ? autocomplete_dialog.column : width
- if right_width.positive? and left_width.positive?
- if right_width >= left_width
+ doc = nil
+ used_for_class = false
+ if not name =~ /#|\./
+ found, klasses, includes, extends = driver.classes_and_includes_and_extends_for(name)
+ if not found.empty?
+ doc = driver.class_document(name, found, klasses, includes, extends)
+ used_for_class = true
+ end
+ end
+ unless used_for_class
+ doc = RDoc::Markup::Document.new
+ begin
+ driver.add_method(doc, name)
+ rescue RDoc::RI::Driver::NotFoundError
+ doc = nil
+ rescue
+ return nil # unknown error
+ end
+ end
+ return nil if doc.nil?
+ width = 40
+
+ right_x = cursor_pos_to_render.x + autocomplete_dialog.width
+ if right_x + width > screen_width
+ right_width = screen_width - (right_x + 1)
+ left_x = autocomplete_dialog.column - width
+ left_x = 0 if left_x < 0
+ left_width = width > autocomplete_dialog.column ? autocomplete_dialog.column : width
+ if right_width.positive? and left_width.positive?
+ if right_width >= left_width
+ width = right_width
+ x = right_x
+ else
+ width = left_width
+ x = left_x
+ end
+ elsif right_width.positive? and left_width <= 0
width = right_width
x = right_x
- else
+ elsif right_width <= 0 and left_width.positive?
width = left_width
x = left_x
+ else # Both are negative width.
+ return nil
end
- elsif right_width.positive? and left_width <= 0
- width = right_width
+ else
x = right_x
- elsif right_width <= 0 and left_width.positive?
- width = left_width
- x = left_x
- else # Both are negative width.
- return nil
end
- else
- x = right_x
+ formatter = RDoc::Markup::ToAnsi.new
+ formatter.width = width
+ dialog.trap_key = alt_d
+ mod_key = RUBY_PLATFORM.match?(/darwin/) ? "Option" : "Alt"
+ if show_easter_egg
+ type = STDOUT.external_encoding == Encoding::UTF_8 ? :unicode : :ascii
+ contents = IRB.send(:easter_egg_logo, type).split("\n")
+ message = "Press #{mod_key}+d to see more"
+ contents[0][0, message.size] = message
+ else
+ message = "Press #{mod_key}+d to read the full document"
+ contents = [message] + doc.accept(formatter).split("\n")
+ end
+ contents = contents.take(preferred_dialog_height)
+
+ y = cursor_pos_to_render.y
+ Reline::DialogRenderInfo.new(pos: Reline::CursorPos.new(x, y), contents: contents, width: width, bg_color: '49')
+ }
+ end
+
+ def display_document(matched, driver: nil)
+ begin
+ require 'rdoc'
+ rescue LoadError
+ return
end
- formatter = RDoc::Markup::ToAnsi.new
- formatter.width = width
- dialog.trap_key = alt_d
- message = 'Press Alt+d to read the full document'
- contents = [message] + doc.accept(formatter).split("\n")
- y = cursor_pos_to_render.y
- DialogRenderInfo.new(pos: Reline::CursorPos.new(x, y), contents: contents, width: width, bg_color: '49')
- }
+ if matched =~ /\A(?:::)?RubyVM/ and not ENV['RUBY_YES_I_AM_NOT_A_NORMAL_USER']
+ IRB.__send__(:easter_egg)
+ return
+ end
+
+ _target, preposing, postposing, bind = @completion_params
+ namespace = @completor.doc_namespace(preposing, matched, postposing, bind: bind)
+ return unless namespace
+
+ driver ||= RDoc::RI::Driver.new
+ if namespace.is_a?(Array)
+ out = RDoc::Markup::Document.new
+ namespace.each do |m|
+ begin
+ driver.add_method(out, m)
+ rescue RDoc::RI::Driver::NotFoundError
+ end
+ end
+ driver.display(out)
+ else
+ begin
+ driver.display_names([namespace])
+ rescue RDoc::RI::Driver::NotFoundError
+ end
+ end
+ end
# Reads the next line from this input method.
#
@@ -414,8 +449,8 @@ module IRB
Reline.output = @stdout
Reline.prompt_proc = @prompt_proc
Reline.auto_indent_proc = @auto_indent_proc if @auto_indent_proc
- if l = readmultiline(@prompt, false, &@check_termination_proc)
- HISTORY.push(l) if !l.empty?
+ if l = Reline.readmultiline(@prompt, false, &@check_termination_proc)
+ Reline::HISTORY.push(l) if !l.empty?
@line[@line_no += 1] = l + "\n"
else
@eof = true
@@ -431,37 +466,11 @@ module IRB
@eof
end
- # Whether this input method is still readable when there is no more data to
- # read.
- #
- # See IO#eof for more information.
- def readable_after_eof?
- true
- end
-
- # Returns the current line number for #io.
- #
- # #line counts the number of times #gets is called.
- #
- # See IO#lineno for more information.
- def line(line_no)
- @line[line_no]
- end
-
- # The external encoding for standard input.
- def encoding
- @stdin.external_encoding
- end
-
# For debug message
def inspect
config = Reline::Config.new
str = "RelineInputMethod with Reline #{Reline::VERSION}"
- if config.respond_to?(:inputrc_path)
- inputrc_path = File.expand_path(config.inputrc_path)
- else
- inputrc_path = File.expand_path(ENV['INPUTRC'] || '~/.inputrc')
- end
+ inputrc_path = File.expand_path(config.inputrc_path)
str += " and #{inputrc_path}" if File.exist?(inputrc_path)
str
end
diff --git a/lib/irb/inspector.rb b/lib/irb/inspector.rb
index 50f6ebf383..ee3b19efdc 100644
--- a/lib/irb/inspector.rb
+++ b/lib/irb/inspector.rb
@@ -35,6 +35,7 @@ module IRB # :nodoc:
# irb(main):001:0> "what?" #=> omg! what?
#
class Inspector
+ KERNEL_INSPECT = Object.instance_method(:inspect)
# Default inspectors available to irb, this includes:
#
# +:pp+:: Using Kernel#pretty_inspect
@@ -93,9 +94,17 @@ module IRB # :nodoc:
# Proc to call when the input is evaluated and output in irb.
def inspect_value(v)
@inspect.call(v)
- rescue
- puts "(Object doesn't support #inspect)"
- ''
+ rescue => e
+ puts "An error occurred when inspecting the object: #{e.inspect}"
+
+ begin
+ puts "Result of Kernel#inspect: #{KERNEL_INSPECT.bind_call(v)}"
+ ''
+ rescue => e
+ puts "An error occurred when running Kernel#inspect: #{e.inspect}"
+ puts e.backtrace.join("\n")
+ ''
+ end
end
end
diff --git a/lib/irb/irb.gemspec b/lib/irb/irb.gemspec
index c3e8a4dc58..a008a39f9d 100644
--- a/lib/irb/irb.gemspec
+++ b/lib/irb/irb.gemspec
@@ -16,6 +16,11 @@ Gem::Specification.new do |spec|
spec.homepage = "https://github.com/ruby/irb"
spec.licenses = ["Ruby", "BSD-2-Clause"]
+ spec.metadata["homepage_uri"] = spec.homepage
+ spec.metadata["source_code_uri"] = spec.homepage
+ spec.metadata["documentation_uri"] = spec.homepage
+ spec.metadata["changelog_uri"] = "#{spec.homepage}/releases"
+
spec.files = [
".document",
"Gemfile",
@@ -34,7 +39,8 @@ Gem::Specification.new do |spec|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
spec.require_paths = ["lib"]
- spec.required_ruby_version = Gem::Requirement.new(">= 2.6")
+ spec.required_ruby_version = Gem::Requirement.new(">= 2.7")
- spec.add_dependency "reline", ">= 0.3.0"
+ spec.add_dependency "reline", ">= 0.3.8"
+ spec.add_dependency "rdoc"
end
diff --git a/lib/irb/lc/help-message b/lib/irb/lc/help-message
index 5b23f4c41e..37347306e8 100644
--- a/lib/irb/lc/help-message
+++ b/lib/irb/lc/help-message
@@ -22,14 +22,18 @@ Usage: irb.rb [options] [programfile] [arguments]
Show truncated result on assignment (default).
--inspect Use 'inspect' for output.
--noinspect Don't use 'inspect' for output.
- --multiline Use multiline editor module.
- --nomultiline Don't use multiline editor module (default).
+ --no-pager Don't use pager.
+ --multiline Use multiline editor module (default).
+ --nomultiline Don't use multiline editor module.
--singleline Use single line editor module.
--nosingleline Don't use single line editor module (default).
--colorize Use color-highlighting (default).
--nocolorize Don't use color-highlighting.
--autocomplete Use auto-completion (default).
--noautocomplete Don't use auto-completion.
+ --regexp-completor
+ Use regexp based completion (default).
+ --type-completor Use type based completion.
--prompt prompt-mode, --prompt-mode prompt-mode
Set prompt mode. Pre-defined prompt modes are:
'default', 'classic', 'simple', 'inf-ruby', 'xmp', 'null'.
diff --git a/lib/irb/lc/ja/encoding_aliases.rb b/lib/irb/lc/ja/encoding_aliases.rb
deleted file mode 100644
index 08180c3ec2..0000000000
--- a/lib/irb/lc/ja/encoding_aliases.rb
+++ /dev/null
@@ -1,13 +0,0 @@
-# frozen_string_literal: false
-module IRB
- # :stopdoc:
-
- class Locale
- @@legacy_encoding_alias_map = {
- 'ujis' => Encoding::EUC_JP,
- 'euc' => Encoding::EUC_JP
- }.freeze
- end
-
- # :startdoc:
-end
diff --git a/lib/irb/lc/ja/help-message b/lib/irb/lc/ja/help-message
index 1c15d331ea..cec339cf2f 100644
--- a/lib/irb/lc/ja/help-message
+++ b/lib/irb/lc/ja/help-message
@@ -21,6 +21,9 @@ Usage: irb.rb [options] [programfile] [arguments]
--nocolorize 色付けを利用しない.
--autocomplete オートコンプリートを利用する.
--noautocomplete オートコンプリートを利用しない.
+ --regexp-completor
+ 補完に正規表現を利用する.
+ --type-completor 補完に型情報を利用する.
--prompt prompt-mode/--prompt-mode prompt-mode
プロンプトモードを切替えます. 現在定義されているプ
ロンプトモードは, default, simple, xmp, inf-rubyが
diff --git a/lib/irb/locale.rb b/lib/irb/locale.rb
index eb3028616d..f94aa0f40b 100644
--- a/lib/irb/locale.rb
+++ b/lib/irb/locale.rb
@@ -15,7 +15,11 @@ module IRB # :nodoc:
]x
LOCALE_DIR = "/lc/"
- @@legacy_encoding_alias_map = {}.freeze
+ LEGACY_ENCODING_ALIAS_MAP = {
+ 'ujis' => Encoding::EUC_JP,
+ 'euc' => Encoding::EUC_JP
+ }
+
@@loaded = []
def initialize(locale = nil)
@@ -26,11 +30,11 @@ module IRB # :nodoc:
@lang, @territory, @encoding_name, @modifier = m[:language], m[:territory], m[:codeset], m[:modifier]
if @encoding_name
- begin load 'irb/encoding_aliases.rb'; rescue LoadError; end
- if @encoding = @@legacy_encoding_alias_map[@encoding_name]
+ if @encoding = LEGACY_ENCODING_ALIAS_MAP[@encoding_name]
warn(("%s is obsolete. use %s" % ["#{@lang}_#{@territory}.#{@encoding_name}", "#{@lang}_#{@territory}.#{@encoding.name}"]), uplevel: 1)
+ else
+ @encoding = Encoding.find(@encoding_name) rescue nil
end
- @encoding = Encoding.find(@encoding_name) rescue nil
end
end
@encoding ||= (Encoding.find('locale') rescue Encoding::ASCII_8BIT)
@@ -78,39 +82,12 @@ module IRB # :nodoc:
super(*ary)
end
- def require(file, priv = nil)
- rex = Regexp.new("lc/#{Regexp.quote(file)}\.(so|o|sl|rb)?")
- return false if $".find{|f| f =~ rex}
-
- case file
- when /\.rb$/
- begin
- load(file, priv)
- $".push file
- return true
- rescue LoadError
- end
- when /\.(so|o|sl)$/
- return super
- end
-
- begin
- load(f = file + ".rb")
- $".push f #"
- return true
- rescue LoadError
- return ruby_require(file)
- end
- end
-
- alias toplevel_load load
-
- def load(file, priv=nil)
+ def load(file)
found = find(file)
if found
unless @@loaded.include?(found)
@@loaded << found # cache
- return real_load(found, priv)
+ Kernel.load(found)
end
else
raise LoadError, "No such file to load -- #{file}"
@@ -129,16 +106,6 @@ module IRB # :nodoc:
end
end
- private
- def real_load(path, priv)
- src = MagicFile.open(path){|f| f.read}
- if priv
- eval("self", TOPLEVEL_BINDING).extend(Module.new {eval(src, nil, path)})
- else
- eval(src, TOPLEVEL_BINDING, path)
- end
- end
-
# @param paths load paths in which IRB find a localized file.
# @param dir directory
# @param file basename to be localized
diff --git a/lib/irb/magic-file.rb b/lib/irb/magic-file.rb
deleted file mode 100644
index 34e06d64b3..0000000000
--- a/lib/irb/magic-file.rb
+++ /dev/null
@@ -1,38 +0,0 @@
-# frozen_string_literal: false
-module IRB
- class << (MagicFile = Object.new)
- # see parser_magic_comment in parse.y
- ENCODING_SPEC_RE = %r"coding\s*[=:]\s*([[:alnum:]\-_]+)"
-
- def open(path)
- io = File.open(path, 'rb')
- line = io.gets
- line = io.gets if line[0,2] == "#!"
- encoding = detect_encoding(line)
- internal_encoding = encoding
- encoding ||= IRB.default_src_encoding
- io.rewind
- io.set_encoding(encoding, internal_encoding)
-
- if block_given?
- begin
- return (yield io)
- ensure
- io.close
- end
- else
- return io
- end
- end
-
- private
- def detect_encoding(line)
- return unless line[0] == ?#
- line = line[1..-1]
- line = $1 if line[/-\*-\s*(.*?)\s*-*-$/]
- return nil unless ENCODING_SPEC_RE =~ line
- encoding = $1
- return encoding.sub(/-(?:mac|dos|unix)/i, '')
- end
- end
-end
diff --git a/lib/irb/nesting_parser.rb b/lib/irb/nesting_parser.rb
new file mode 100644
index 0000000000..3d4db82444
--- /dev/null
+++ b/lib/irb/nesting_parser.rb
@@ -0,0 +1,227 @@
+# frozen_string_literal: true
+module IRB
+ module NestingParser
+ IGNORE_TOKENS = %i[on_sp on_ignored_nl on_comment on_embdoc_beg on_embdoc on_embdoc_end]
+
+ # Scan each token and call the given block with array of token and other information for parsing
+ def self.scan_opens(tokens)
+ opens = []
+ pending_heredocs = []
+ first_token_on_line = true
+ tokens.each do |t|
+ skip = false
+ last_tok, state, args = opens.last
+ case state
+ when :in_unquoted_symbol
+ unless IGNORE_TOKENS.include?(t.event)
+ opens.pop
+ skip = true
+ end
+ when :in_lambda_head
+ opens.pop if t.event == :on_tlambeg || (t.event == :on_kw && t.tok == 'do')
+ when :in_method_head
+ unless IGNORE_TOKENS.include?(t.event)
+ next_args = []
+ body = nil
+ if args.include?(:receiver)
+ case t.event
+ when :on_lparen, :on_ivar, :on_gvar, :on_cvar
+ # def (receiver). | def @ivar. | def $gvar. | def @@cvar.
+ next_args << :dot
+ when :on_kw
+ case t.tok
+ when 'self', 'true', 'false', 'nil'
+ # def self(arg) | def self.
+ next_args.push(:arg, :dot)
+ else
+ # def if(arg)
+ skip = true
+ next_args << :arg
+ end
+ when :on_op, :on_backtick
+ # def +(arg)
+ skip = true
+ next_args << :arg
+ when :on_ident, :on_const
+ # def a(arg) | def a.
+ next_args.push(:arg, :dot)
+ end
+ end
+ if args.include?(:dot)
+ # def receiver.name
+ next_args << :name if t.event == :on_period || (t.event == :on_op && t.tok == '::')
+ end
+ if args.include?(:name)
+ if %i[on_ident on_const on_op on_kw on_backtick].include?(t.event)
+ # def name(arg) | def receiver.name(arg)
+ next_args << :arg
+ skip = true
+ end
+ end
+ if args.include?(:arg)
+ case t.event
+ when :on_nl, :on_semicolon
+ # def recever.f;
+ body = :normal
+ when :on_lparen
+ # def recever.f()
+ next_args << :eq
+ else
+ if t.event == :on_op && t.tok == '='
+ # def receiver.f =
+ body = :oneliner
+ else
+ # def recever.f arg
+ next_args << :arg_without_paren
+ end
+ end
+ end
+ if args.include?(:eq)
+ if t.event == :on_op && t.tok == '='
+ body = :oneliner
+ else
+ body = :normal
+ end
+ end
+ if args.include?(:arg_without_paren)
+ if %i[on_semicolon on_nl].include?(t.event)
+ # def f a;
+ body = :normal
+ else
+ # def f a, b
+ next_args << :arg_without_paren
+ end
+ end
+ if body == :oneliner
+ opens.pop
+ elsif body
+ opens[-1] = [last_tok, nil]
+ else
+ opens[-1] = [last_tok, :in_method_head, next_args]
+ end
+ end
+ when :in_for_while_until_condition
+ if t.event == :on_semicolon || t.event == :on_nl || (t.event == :on_kw && t.tok == 'do')
+ skip = true if t.event == :on_kw && t.tok == 'do'
+ opens[-1] = [last_tok, nil]
+ end
+ end
+
+ unless skip
+ case t.event
+ when :on_kw
+ case t.tok
+ when 'begin', 'class', 'module', 'do', 'case'
+ opens << [t, nil]
+ when 'end'
+ opens.pop
+ when 'def'
+ opens << [t, :in_method_head, [:receiver, :name]]
+ when 'if', 'unless'
+ unless t.state.allbits?(Ripper::EXPR_LABEL)
+ opens << [t, nil]
+ end
+ when 'while', 'until'
+ unless t.state.allbits?(Ripper::EXPR_LABEL)
+ opens << [t, :in_for_while_until_condition]
+ end
+ when 'ensure', 'rescue'
+ unless t.state.allbits?(Ripper::EXPR_LABEL)
+ opens.pop
+ opens << [t, nil]
+ end
+ when 'elsif', 'else', 'when'
+ opens.pop
+ opens << [t, nil]
+ when 'for'
+ opens << [t, :in_for_while_until_condition]
+ when 'in'
+ if last_tok&.event == :on_kw && %w[case in].include?(last_tok.tok) && first_token_on_line
+ opens.pop
+ opens << [t, nil]
+ end
+ end
+ when :on_tlambda
+ opens << [t, :in_lambda_head]
+ when :on_lparen, :on_lbracket, :on_lbrace, :on_tlambeg, :on_embexpr_beg, :on_embdoc_beg
+ opens << [t, nil]
+ when :on_rparen, :on_rbracket, :on_rbrace, :on_embexpr_end, :on_embdoc_end
+ opens.pop
+ when :on_heredoc_beg
+ pending_heredocs << t
+ when :on_heredoc_end
+ opens.pop
+ when :on_backtick
+ opens << [t, nil] if t.state.allbits?(Ripper::EXPR_BEG)
+ when :on_tstring_beg, :on_words_beg, :on_qwords_beg, :on_symbols_beg, :on_qsymbols_beg, :on_regexp_beg
+ opens << [t, nil]
+ when :on_tstring_end, :on_regexp_end, :on_label_end
+ opens.pop
+ when :on_symbeg
+ if t.tok == ':'
+ opens << [t, :in_unquoted_symbol]
+ else
+ opens << [t, nil]
+ end
+ end
+ end
+ if t.event == :on_nl || t.event == :on_semicolon
+ first_token_on_line = true
+ elsif t.event != :on_sp
+ first_token_on_line = false
+ end
+ if pending_heredocs.any? && t.tok.include?("\n")
+ pending_heredocs.reverse_each { |t| opens << [t, nil] }
+ pending_heredocs = []
+ end
+ yield t, opens if block_given?
+ end
+ opens.map(&:first) + pending_heredocs.reverse
+ end
+
+ def self.open_tokens(tokens)
+ # scan_opens without block will return a list of open tokens at last token position
+ scan_opens(tokens)
+ end
+
+ # Calculates token information [line_tokens, prev_opens, next_opens, min_depth] for each line.
+ # Example code
+ # ["hello
+ # world"+(
+ # First line
+ # line_tokens: [[lbracket, '['], [tstring_beg, '"'], [tstring_content("hello\nworld"), "hello\n"]]
+ # prev_opens: []
+ # next_tokens: [lbracket, tstring_beg]
+ # min_depth: 0 (minimum at beginning of line)
+ # Second line
+ # line_tokens: [[tstring_content("hello\nworld"), "world"], [tstring_end, '"'], [op, '+'], [lparen, '(']]
+ # prev_opens: [lbracket, tstring_beg]
+ # next_tokens: [lbracket, lparen]
+ # min_depth: 1 (minimum just after tstring_end)
+ def self.parse_by_line(tokens)
+ line_tokens = []
+ prev_opens = []
+ min_depth = 0
+ output = []
+ last_opens = scan_opens(tokens) do |t, opens|
+ depth = t == opens.last&.first ? opens.size - 1 : opens.size
+ min_depth = depth if depth < min_depth
+ if t.tok.include?("\n")
+ t.tok.each_line do |line|
+ line_tokens << [t, line]
+ next if line[-1] != "\n"
+ next_opens = opens.map(&:first)
+ output << [line_tokens, prev_opens, next_opens, min_depth]
+ prev_opens = next_opens
+ min_depth = prev_opens.size
+ line_tokens = []
+ end
+ else
+ line_tokens << [t, t.tok]
+ end
+ end
+ output << [line_tokens, prev_opens, last_opens, min_depth] if line_tokens.any?
+ output
+ end
+ end
+end
diff --git a/lib/irb/pager.rb b/lib/irb/pager.rb
new file mode 100644
index 0000000000..3391b32c66
--- /dev/null
+++ b/lib/irb/pager.rb
@@ -0,0 +1,91 @@
+# frozen_string_literal: true
+
+module IRB
+ # The implementation of this class is borrowed from RDoc's lib/rdoc/ri/driver.rb.
+ # Please do NOT use this class directly outside of IRB.
+ class Pager
+ PAGE_COMMANDS = [ENV['RI_PAGER'], ENV['PAGER'], 'less', 'more'].compact.uniq
+
+ class << self
+ def page_content(content, **options)
+ if content_exceeds_screen_height?(content)
+ page(**options) do |io|
+ io.puts content
+ end
+ else
+ $stdout.puts content
+ end
+ end
+
+ def page(retain_content: false)
+ if should_page? && pager = setup_pager(retain_content: retain_content)
+ begin
+ pid = pager.pid
+ yield pager
+ ensure
+ pager.close
+ end
+ else
+ yield $stdout
+ end
+ # When user presses Ctrl-C, IRB would raise `IRB::Abort`
+ # But since Pager is implemented by running paging commands like `less` in another process with `IO.popen`,
+ # the `IRB::Abort` exception only interrupts IRB's execution but doesn't affect the pager
+ # So to properly terminate the pager with Ctrl-C, we need to catch `IRB::Abort` and kill the pager process
+ rescue IRB::Abort
+ Process.kill("TERM", pid) if pid
+ nil
+ rescue Errno::EPIPE
+ end
+
+ private
+
+ def should_page?
+ IRB.conf[:USE_PAGER] && STDIN.tty? && (ENV.key?("TERM") && ENV["TERM"] != "dumb")
+ end
+
+ def content_exceeds_screen_height?(content)
+ screen_height, screen_width = begin
+ Reline.get_screen_size
+ rescue Errno::EINVAL
+ [24, 80]
+ end
+
+ pageable_height = screen_height - 3 # leave some space for previous and the current prompt
+
+ # If the content has more lines than the pageable height
+ content.lines.count > pageable_height ||
+ # Or if the content is a few long lines
+ pageable_height * screen_width < Reline::Unicode.calculate_width(content, true)
+ end
+
+ def setup_pager(retain_content:)
+ require 'shellwords'
+
+ PAGE_COMMANDS.each do |pager_cmd|
+ cmd = Shellwords.split(pager_cmd)
+ next if cmd.empty?
+
+ if cmd.first == 'less'
+ cmd << '-R' unless cmd.include?('-R')
+ cmd << '-X' if retain_content && !cmd.include?('-X')
+ end
+
+ begin
+ io = IO.popen(cmd, 'w')
+ rescue
+ next
+ end
+
+ if $? && $?.pid == io.pid && $?.exited? # pager didn't work
+ next
+ end
+
+ return io
+ end
+
+ nil
+ end
+ end
+ end
+end
diff --git a/lib/irb/ruby-lex.rb b/lib/irb/ruby-lex.rb
index 9e4a7b28fa..4bce2aa6b2 100644
--- a/lib/irb/ruby-lex.rb
+++ b/lib/irb/ruby-lex.rb
@@ -6,150 +6,119 @@
require "ripper"
require "jruby" if RUBY_ENGINE == "jruby"
-
-# :stopdoc:
-class RubyLex
-
- class TerminateLineInput < StandardError
- def initialize
- super("Terminate Line Input")
+require_relative "nesting_parser"
+
+module IRB
+ # :stopdoc:
+ class RubyLex
+ ASSIGNMENT_NODE_TYPES = [
+ # Local, instance, global, class, constant, instance, and index assignment:
+ # "foo = bar",
+ # "@foo = bar",
+ # "$foo = bar",
+ # "@@foo = bar",
+ # "::Foo = bar",
+ # "a::Foo = bar",
+ # "Foo = bar"
+ # "foo.bar = 1"
+ # "foo[1] = bar"
+ :assign,
+
+ # Operation assignment:
+ # "foo += bar"
+ # "foo -= bar"
+ # "foo ||= bar"
+ # "foo &&= bar"
+ :opassign,
+
+ # Multiple assignment:
+ # "foo, bar = 1, 2
+ :massign,
+ ]
+
+ class TerminateLineInput < StandardError
+ def initialize
+ super("Terminate Line Input")
+ end
end
- end
-
- def initialize(context)
- @context = context
- @exp_line_no = @line_no = 1
- @indent = 0
- @continue = false
- @line = ""
- @prompt = nil
- end
- def self.compile_with_errors_suppressed(code, line_no: 1)
- begin
- result = yield code, line_no
- rescue ArgumentError
- # Ruby can issue an error for the code if there is an
- # incomplete magic comment for encoding in it. Force an
- # expression with a new line before the code in this
- # case to prevent magic comment handling. To make sure
- # line numbers in the lexed code remain the same,
- # decrease the line number by one.
- code = ";\n#{code}"
- line_no -= 1
- result = yield code, line_no
+ def self.compile_with_errors_suppressed(code, line_no: 1)
+ begin
+ result = yield code, line_no
+ rescue ArgumentError
+ # Ruby can issue an error for the code if there is an
+ # incomplete magic comment for encoding in it. Force an
+ # expression with a new line before the code in this
+ # case to prevent magic comment handling. To make sure
+ # line numbers in the lexed code remain the same,
+ # decrease the line number by one.
+ code = ";\n#{code}"
+ line_no -= 1
+ result = yield code, line_no
+ end
+ result
end
- result
- end
- # io functions
- def set_input(io, &block)
- @io = io
- if @io.respond_to?(:check_termination)
- @io.check_termination do |code|
- if Reline::IOGate.in_pasting?
- lex = RubyLex.new(@context)
- rest = lex.check_termination_in_prev_line(code)
- if rest
- Reline.delete_text
- rest.bytes.reverse_each do |c|
- Reline.ungetc(c)
- end
- true
- else
- false
- end
- else
- # Accept any single-line input for symbol aliases or commands that transform args
- command = code.split(/\s/, 2).first
- if @context.symbol_alias?(command) || @context.transform_args?(command)
- next true
- end
-
- code.gsub!(/\s*\z/, '').concat("\n")
- tokens = self.class.ripper_lex_without_warning(code, context: @context)
- ltype, indent, continue, code_block_open = check_state(code, tokens)
- if ltype or indent > 0 or continue or code_block_open
- false
- else
- true
- end
- end
- end
+ ERROR_TOKENS = [
+ :on_parse_error,
+ :compile_error,
+ :on_assign_error,
+ :on_alias_error,
+ :on_class_name_error,
+ :on_param_error
+ ]
+
+ def self.generate_local_variables_assign_code(local_variables)
+ "#{local_variables.join('=')}=nil;" unless local_variables.empty?
end
- if @io.respond_to?(:dynamic_prompt)
- @io.dynamic_prompt do |lines|
- lines << '' if lines.empty?
- result = []
- tokens = self.class.ripper_lex_without_warning(lines.map{ |l| l + "\n" }.join, context: @context)
- code = String.new
- partial_tokens = []
- unprocessed_tokens = []
- line_num_offset = 0
- tokens.each do |t|
- partial_tokens << t
- unprocessed_tokens << t
- if t.tok.include?("\n")
- t_str = t.tok
- t_str.each_line("\n") do |s|
- code << s
- next unless s.include?("\n")
- ltype, indent, continue, code_block_open = check_state(code, partial_tokens)
- result << @prompt.call(ltype, indent, continue || code_block_open, @line_no + line_num_offset)
- line_num_offset += 1
- end
- unprocessed_tokens = []
- else
- code << t.tok
- end
- end
- unless unprocessed_tokens.empty?
- ltype, indent, continue, code_block_open = check_state(code, unprocessed_tokens)
- result << @prompt.call(ltype, indent, continue || code_block_open, @line_no + line_num_offset)
+ # Some part of the code is not included in Ripper's token.
+ # Example: DATA part, token after heredoc_beg when heredoc has unclosed embexpr.
+ # With interpolated tokens, tokens.map(&:tok).join will be equal to code.
+ def self.interpolate_ripper_ignored_tokens(code, tokens)
+ line_positions = [0]
+ code.lines.each do |line|
+ line_positions << line_positions.last + line.bytesize
+ end
+ prev_byte_pos = 0
+ interpolated = []
+ prev_line = 1
+ tokens.each do |t|
+ line, col = t.pos
+ byte_pos = line_positions[line - 1] + col
+ if prev_byte_pos < byte_pos
+ tok = code.byteslice(prev_byte_pos...byte_pos)
+ pos = [prev_line, prev_byte_pos - line_positions[prev_line - 1]]
+ interpolated << Ripper::Lexer::Elem.new(pos, :on_ignored_by_ripper, tok, 0)
+ prev_line += tok.count("\n")
end
- result
+ interpolated << t
+ prev_byte_pos = byte_pos + t.tok.bytesize
+ prev_line += t.tok.count("\n")
end
+ if prev_byte_pos < code.bytesize
+ tok = code.byteslice(prev_byte_pos..)
+ pos = [prev_line, prev_byte_pos - line_positions[prev_line - 1]]
+ interpolated << Ripper::Lexer::Elem.new(pos, :on_ignored_by_ripper, tok, 0)
+ end
+ interpolated
end
- if block_given?
- @input = block
- else
- @input = Proc.new{@io.gets}
- end
- end
-
- def set_prompt(&block)
- @prompt = block
- end
-
- ERROR_TOKENS = [
- :on_parse_error,
- :compile_error,
- :on_assign_error,
- :on_alias_error,
- :on_class_name_error,
- :on_param_error
- ]
-
- def self.generate_local_variables_assign_code(local_variables)
- "#{local_variables.join('=')}=nil;" unless local_variables.empty?
- end
-
- def self.ripper_lex_without_warning(code, context: nil)
- verbose, $VERBOSE = $VERBOSE, nil
- lvars_code = generate_local_variables_assign_code(context&.local_variables || [])
- if lvars_code
- code = "#{lvars_code}\n#{code}"
- line_no = 0
- else
- line_no = 1
- end
+ def self.ripper_lex_without_warning(code, local_variables: [])
+ verbose, $VERBOSE = $VERBOSE, nil
+ lvars_code = generate_local_variables_assign_code(local_variables)
+ original_code = code
+ if lvars_code
+ code = "#{lvars_code}\n#{code}"
+ line_no = 0
+ else
+ line_no = 1
+ end
- compile_with_errors_suppressed(code, line_no: line_no) do |inner_code, line_no|
- lexer = Ripper::Lexer.new(inner_code, '-', line_no)
- if lexer.respond_to?(:scan) # Ruby 2.7+
- lexer.scan.each_with_object([]) do |t, tokens|
+ compile_with_errors_suppressed(code, line_no: line_no) do |inner_code, line_no|
+ lexer = Ripper::Lexer.new(inner_code, '-', line_no)
+ tokens = []
+ lexer.scan.each do |t|
next if t.pos.first == 0
prev_tk = tokens.last
position_overlapped = prev_tk && t.pos[0] == prev_tk.pos[0] && t.pos[1] < prev_tk.pos[1] + prev_tk.tok.bytesize
@@ -159,693 +128,347 @@ class RubyLex
tokens << t
end
end
- else
- lexer.parse.reject { |it| it.pos.first == 0 }.sort_by(&:pos)
- end
- end
- ensure
- $VERBOSE = verbose
- end
-
- def find_prev_spaces(line_index)
- return 0 if @tokens.size == 0
- md = @tokens[0].tok.match(/(\A +)/)
- prev_spaces = md.nil? ? 0 : md[1].count(' ')
- line_count = 0
- @tokens.each_with_index do |t, i|
- if t.tok.include?("\n")
- line_count += t.tok.count("\n")
- if line_count >= line_index
- return prev_spaces
- end
- next if t.event == :on_tstring_content || t.event == :on_words_sep
- if (@tokens.size - 1) > i
- md = @tokens[i + 1].tok.match(/(\A +)/)
- prev_spaces = md.nil? ? 0 : md[1].count(' ')
- end
+ interpolate_ripper_ignored_tokens(original_code, tokens)
end
+ ensure
+ $VERBOSE = verbose
end
- prev_spaces
- end
- def set_auto_indent
- if @io.respond_to?(:auto_indent) and @context.auto_indent_mode
- @io.auto_indent do |lines, line_index, byte_pointer, is_newline|
- if is_newline
- @tokens = self.class.ripper_lex_without_warning(lines[0..line_index].join("\n"), context: @context)
- prev_spaces = find_prev_spaces(line_index)
- depth_difference = check_newline_depth_difference
- depth_difference = 0 if depth_difference < 0
- prev_spaces + depth_difference * 2
- else
- code = line_index.zero? ? '' : lines[0..(line_index - 1)].map{ |l| l + "\n" }.join
- last_line = lines[line_index]&.byteslice(0, byte_pointer)
- code += last_line if last_line
- @tokens = self.class.ripper_lex_without_warning(code, context: @context)
- check_corresponding_token_depth(lines, line_index)
- end
- end
+ def check_code_state(code, local_variables:)
+ tokens = self.class.ripper_lex_without_warning(code, local_variables: local_variables)
+ opens = NestingParser.open_tokens(tokens)
+ [tokens, opens, code_terminated?(code, tokens, opens, local_variables: local_variables)]
end
- end
-
- def check_state(code, tokens)
- ltype = process_literal_type(tokens)
- indent = process_nesting_level(tokens)
- continue = process_continue(tokens)
- lvars_code = self.class.generate_local_variables_assign_code(@context.local_variables)
- code = "#{lvars_code}\n#{code}" if lvars_code
- code_block_open = check_code_block(code, tokens)
- [ltype, indent, continue, code_block_open]
- end
- def prompt
- if @prompt
- @prompt.call(@ltype, @indent, @continue, @line_no)
- end
- end
-
- def initialize_input
- @ltype = nil
- @indent = 0
- @continue = false
- @line = ""
- @exp_line_no = @line_no
- @code_block_open = false
- end
-
- def each_top_level_statement
- initialize_input
- catch(:TERM_INPUT) do
- loop do
- begin
- prompt
- unless l = lex
- throw :TERM_INPUT if @line == ''
- else
- @line_no += l.count("\n")
- if l == "\n"
- @exp_line_no += 1
- next
- end
- @line.concat l
- if @code_block_open or @ltype or @continue or @indent > 0
- next
- end
- end
- if @line != "\n"
- @line.force_encoding(@io.encoding)
- yield @line, @exp_line_no
- end
- raise TerminateLineInput if @io.eof?
- @line = ''
- @exp_line_no = @line_no
-
- @indent = 0
- rescue TerminateLineInput
- initialize_input
- prompt
- end
+ def code_terminated?(code, tokens, opens, local_variables:)
+ case check_code_syntax(code, local_variables: local_variables)
+ when :unrecoverable_error
+ true
+ when :recoverable_error
+ false
+ when :other_error
+ opens.empty? && !should_continue?(tokens)
+ when :valid
+ !should_continue?(tokens)
end
end
- end
- def lex
- line = @input.call
- if @io.respond_to?(:check_termination)
- return line # multiline
- end
- code = @line + (line.nil? ? '' : line)
- code.gsub!(/\s*\z/, '').concat("\n")
- @tokens = self.class.ripper_lex_without_warning(code, context: @context)
- @ltype, @indent, @continue, @code_block_open = check_state(code, @tokens)
- line
- end
+ def assignment_expression?(code, local_variables:)
+ # Try to parse the code and check if the last of possibly multiple
+ # expressions is an assignment type.
- def process_continue(tokens)
- # last token is always newline
- if tokens.size >= 2 and tokens[-2].event == :on_regexp_end
- # end of regexp literal
- return false
- elsif tokens.size >= 2 and tokens[-2].event == :on_semicolon
- return false
- elsif tokens.size >= 2 and tokens[-2].event == :on_kw and ['begin', 'else', 'ensure'].include?(tokens[-2].tok)
- return false
- elsif !tokens.empty? and tokens.last.tok == "\\\n"
- return true
- elsif tokens.size >= 1 and tokens[-1].event == :on_heredoc_end # "EOH\n"
- return false
- elsif tokens.size >= 2 and tokens[-2].state.anybits?(Ripper::EXPR_BEG | Ripper::EXPR_FNAME) and tokens[-2].tok !~ /\A\.\.\.?\z/
- # end of literal except for regexp
- # endless range at end of line is not a continue
- return true
- end
- false
- end
-
- def check_code_block(code, tokens)
- return true if tokens.empty?
- if tokens.last.event == :on_heredoc_beg
- return true
- end
-
- begin # check if parser error are available
+ # If the expression is invalid, Ripper.sexp should return nil which will
+ # result in false being returned. Any valid expression should return an
+ # s-expression where the second element of the top level array is an
+ # array of parsed expressions. The first element of each expression is the
+ # expression's type.
verbose, $VERBOSE = $VERBOSE, nil
- case RUBY_ENGINE
- when 'ruby'
- self.class.compile_with_errors_suppressed(code) do |inner_code, line_no|
- RubyVM::InstructionSequence.compile(inner_code, nil, nil, line_no)
- end
- when 'jruby'
- JRuby.compile_ir(code)
- else
- catch(:valid) do
- eval("BEGIN { throw :valid, true }\n#{code}")
- false
- end
- end
- rescue EncodingError
- # This is for a hash with invalid encoding symbol, {"\xAE": 1}
- rescue SyntaxError => e
- case e.message
- when /unterminated (?:string|regexp) meets end of file/
- # "unterminated regexp meets end of file"
- #
- # example:
- # /
- #
- # "unterminated string meets end of file"
- #
- # example:
- # '
- return true
- when /syntax error, unexpected end-of-input/
- # "syntax error, unexpected end-of-input, expecting keyword_end"
- #
- # example:
- # if true
- # hoge
- # if false
- # fuga
- # end
- return true
- when /syntax error, unexpected keyword_end/
- # "syntax error, unexpected keyword_end"
- #
- # example:
- # if (
- # end
- #
- # example:
- # end
- return false
- when /syntax error, unexpected '\.'/
- # "syntax error, unexpected '.'"
- #
- # example:
- # .
- return false
- when /unexpected tREGEXP_BEG/
- # "syntax error, unexpected tREGEXP_BEG, expecting keyword_do or '{' or '('"
- #
- # example:
- # method / f /
- return false
- end
+ code = "#{RubyLex.generate_local_variables_assign_code(local_variables) || 'nil;'}\n#{code}"
+ # Get the last node_type of the line. drop(1) is to ignore the local_variables_assign_code part.
+ node_type = Ripper.sexp(code)&.dig(1)&.drop(1)&.dig(-1, 0)
+ ASSIGNMENT_NODE_TYPES.include?(node_type)
ensure
$VERBOSE = verbose
end
- last_lex_state = tokens.last.state
-
- if last_lex_state.allbits?(Ripper::EXPR_BEG)
- return false
- elsif last_lex_state.allbits?(Ripper::EXPR_DOT)
- return true
- elsif last_lex_state.allbits?(Ripper::EXPR_CLASS)
- return true
- elsif last_lex_state.allbits?(Ripper::EXPR_FNAME)
- return true
- elsif last_lex_state.allbits?(Ripper::EXPR_VALUE)
- return true
- elsif last_lex_state.allbits?(Ripper::EXPR_ARG)
- return false
+ def should_continue?(tokens)
+ # Look at the last token and check if IRB need to continue reading next line.
+ # Example code that should continue: `a\` `a +` `a.`
+ # Trailing spaces, newline, comments are skipped
+ return true if tokens.last&.event == :on_sp && tokens.last.tok == "\\\n"
+
+ tokens.reverse_each do |token|
+ case token.event
+ when :on_sp, :on_nl, :on_ignored_nl, :on_comment, :on_embdoc_beg, :on_embdoc, :on_embdoc_end
+ # Skip
+ when :on_regexp_end, :on_heredoc_end, :on_semicolon
+ # State is EXPR_BEG but should not continue
+ return false
+ else
+ # Endless range should not continue
+ return false if token.event == :on_op && token.tok.match?(/\A\.\.\.?\z/)
+
+ # EXPR_DOT and most of the EXPR_BEG should continue
+ return token.state.anybits?(Ripper::EXPR_BEG | Ripper::EXPR_DOT)
+ end
+ end
+ false
end
- false
- end
+ def check_code_syntax(code, local_variables:)
+ lvars_code = RubyLex.generate_local_variables_assign_code(local_variables)
+ code = "#{lvars_code}\n#{code}"
- def process_nesting_level(tokens)
- indent = 0
- in_oneliner_def = nil
- tokens.each_with_index { |t, index|
- # detecting one-liner method definition
- if in_oneliner_def.nil?
- if t.state.allbits?(Ripper::EXPR_ENDFN)
- in_oneliner_def = :ENDFN
- end
- else
- if t.state.allbits?(Ripper::EXPR_ENDFN)
- # continuing
- elsif t.state.allbits?(Ripper::EXPR_BEG)
- if t.tok == '='
- in_oneliner_def = :BODY
+ begin # check if parser error are available
+ verbose, $VERBOSE = $VERBOSE, nil
+ case RUBY_ENGINE
+ when 'ruby'
+ self.class.compile_with_errors_suppressed(code) do |inner_code, line_no|
+ RubyVM::InstructionSequence.compile(inner_code, nil, nil, line_no)
end
+ when 'jruby'
+ JRuby.compile_ir(code)
else
- if in_oneliner_def == :BODY
- # one-liner method definition
- indent -= 1
+ catch(:valid) do
+ eval("BEGIN { throw :valid, true }\n#{code}")
+ false
end
- in_oneliner_def = nil
end
- end
-
- case t.event
- when :on_lbracket, :on_lbrace, :on_lparen, :on_tlambeg
- indent += 1
- when :on_rbracket, :on_rbrace, :on_rparen
- indent -= 1
- when :on_kw
- next if index > 0 and tokens[index - 1].state.allbits?(Ripper::EXPR_FNAME)
- case t.tok
- when 'do'
- syntax_of_do = take_corresponding_syntax_to_kw_do(tokens, index)
- indent += 1 if syntax_of_do == :method_calling
- when 'def', 'case', 'for', 'begin', 'class', 'module'
- indent += 1
- when 'if', 'unless', 'while', 'until'
- # postfix if/unless/while/until must be Ripper::EXPR_LABEL
- indent += 1 unless t.state.allbits?(Ripper::EXPR_LABEL)
- when 'end'
- indent -= 1
+ rescue EncodingError
+ # This is for a hash with invalid encoding symbol, {"\xAE": 1}
+ :unrecoverable_error
+ rescue SyntaxError => e
+ case e.message
+ when /unterminated (?:string|regexp) meets end of file/
+ # "unterminated regexp meets end of file"
+ #
+ # example:
+ # /
+ #
+ # "unterminated string meets end of file"
+ #
+ # example:
+ # '
+ return :recoverable_error
+ when /syntax error, unexpected end-of-input/
+ # "syntax error, unexpected end-of-input, expecting keyword_end"
+ #
+ # example:
+ # if true
+ # hoge
+ # if false
+ # fuga
+ # end
+ return :recoverable_error
+ when /syntax error, unexpected keyword_end/
+ # "syntax error, unexpected keyword_end"
+ #
+ # example:
+ # if (
+ # end
+ #
+ # example:
+ # end
+ return :unrecoverable_error
+ when /syntax error, unexpected '\.'/
+ # "syntax error, unexpected '.'"
+ #
+ # example:
+ # .
+ return :unrecoverable_error
+ when /unexpected tREGEXP_BEG/
+ # "syntax error, unexpected tREGEXP_BEG, expecting keyword_do or '{' or '('"
+ #
+ # example:
+ # method / f /
+ return :unrecoverable_error
+ else
+ return :other_error
end
+ ensure
+ $VERBOSE = verbose
end
- # percent literals are not indented
- }
- indent
- end
+ :valid
+ end
- def is_method_calling?(tokens, index)
- tk = tokens[index]
- if tk.state.anybits?(Ripper::EXPR_CMDARG) and tk.event == :on_ident
- # The target method call to pass the block with "do".
- return true
- elsif tk.state.anybits?(Ripper::EXPR_ARG) and tk.event == :on_ident
- non_sp_index = tokens[0..(index - 1)].rindex{ |t| t.event != :on_sp }
- if non_sp_index
- prev_tk = tokens[non_sp_index]
- if prev_tk.state.anybits?(Ripper::EXPR_DOT) and prev_tk.event == :on_period
- # The target method call with receiver to pass the block with "do".
- return true
+ def calc_indent_level(opens)
+ indent_level = 0
+ opens.each_with_index do |t, index|
+ case t.event
+ when :on_heredoc_beg
+ if opens[index + 1]&.event != :on_heredoc_beg
+ if t.tok.match?(/^<<[~-]/)
+ indent_level += 1
+ else
+ indent_level = 0
+ end
+ end
+ when :on_tstring_beg, :on_regexp_beg, :on_symbeg, :on_backtick
+ # No indent: "", //, :"", ``
+ # Indent: %(), %r(), %i(), %x()
+ indent_level += 1 if t.tok.start_with? '%'
+ when :on_embdoc_beg
+ indent_level = 0
+ else
+ indent_level += 1
end
end
+ indent_level
end
- false
- end
- def take_corresponding_syntax_to_kw_do(tokens, index)
- syntax_of_do = nil
- # Finding a syntax corresponding to "do".
- index.downto(0) do |i|
- tk = tokens[i]
- # In "continue", the token isn't the corresponding syntax to "do".
- non_sp_index = tokens[0..(i - 1)].rindex{ |t| t.event != :on_sp }
- first_in_fomula = false
- if non_sp_index.nil?
- first_in_fomula = true
- elsif [:on_ignored_nl, :on_nl, :on_comment].include?(tokens[non_sp_index].event)
- first_in_fomula = true
- end
- if is_method_calling?(tokens, i)
- syntax_of_do = :method_calling
- break if first_in_fomula
- elsif tk.event == :on_kw && %w{while until for}.include?(tk.tok)
- # A loop syntax in front of "do" found.
- #
- # while cond do # also "until" or "for"
- # end
- #
- # This "do" doesn't increment indent because the loop syntax already
- # incremented.
- syntax_of_do = :loop_syntax
- break if first_in_fomula
- end
+ FREE_INDENT_TOKENS = %i[on_tstring_beg on_backtick on_regexp_beg on_symbeg]
+
+ def free_indent_token?(token)
+ FREE_INDENT_TOKENS.include?(token&.event)
end
- syntax_of_do
- end
- def is_the_in_correspond_to_a_for(tokens, index)
- syntax_of_in = nil
- # Finding a syntax corresponding to "do".
- index.downto(0) do |i|
- tk = tokens[i]
- # In "continue", the token isn't the corresponding syntax to "do".
- non_sp_index = tokens[0..(i - 1)].rindex{ |t| t.event != :on_sp }
- first_in_fomula = false
- if non_sp_index.nil?
- first_in_fomula = true
- elsif [:on_ignored_nl, :on_nl, :on_comment].include?(tokens[non_sp_index].event)
- first_in_fomula = true
- end
- if tk.event == :on_kw && tk.tok == 'for'
- # A loop syntax in front of "do" found.
- #
- # while cond do # also "until" or "for"
- # end
- #
- # This "do" doesn't increment indent because the loop syntax already
- # incremented.
- syntax_of_in = :for
+ # Calculates the difference of pasted code's indent and indent calculated from tokens
+ def indent_difference(lines, line_results, line_index)
+ loop do
+ _tokens, prev_opens, _next_opens, min_depth = line_results[line_index]
+ open_token = prev_opens.last
+ if !open_token || (open_token.event != :on_heredoc_beg && !free_indent_token?(open_token))
+ # If the leading whitespace is an indent, return the difference
+ indent_level = calc_indent_level(prev_opens.take(min_depth))
+ calculated_indent = 2 * indent_level
+ actual_indent = lines[line_index][/^ */].size
+ return actual_indent - calculated_indent
+ elsif open_token.event == :on_heredoc_beg && open_token.tok.match?(/^<<[^-~]/)
+ return 0
+ end
+ # If the leading whitespace is not an indent but part of a multiline token
+ # Calculate base_indent of the multiline token's beginning line
+ line_index = open_token.pos[0] - 1
end
- break if first_in_fomula
end
- syntax_of_in
- end
- def check_newline_depth_difference
- depth_difference = 0
- open_brace_on_line = 0
- in_oneliner_def = nil
- @tokens.each_with_index do |t, index|
- # detecting one-liner method definition
- if in_oneliner_def.nil?
- if t.state.allbits?(Ripper::EXPR_ENDFN)
- in_oneliner_def = :ENDFN
- end
+ def process_indent_level(tokens, lines, line_index, is_newline)
+ line_results = NestingParser.parse_by_line(tokens)
+ result = line_results[line_index]
+ if result
+ _tokens, prev_opens, next_opens, min_depth = result
else
- if t.state.allbits?(Ripper::EXPR_ENDFN)
- # continuing
- elsif t.state.allbits?(Ripper::EXPR_BEG)
- if t.tok == '='
- in_oneliner_def = :BODY
- end
- else
- if in_oneliner_def == :BODY
- # one-liner method definition
- depth_difference -= 1
- end
- in_oneliner_def = nil
- end
+ # When last line is empty
+ prev_opens = next_opens = line_results.last[2]
+ min_depth = next_opens.size
end
- case t.event
- when :on_ignored_nl, :on_nl, :on_comment
- if index != (@tokens.size - 1) and in_oneliner_def != :BODY
- depth_difference = 0
- open_brace_on_line = 0
- end
- next
- when :on_sp
- next
- end
+ # To correctly indent line like `end.map do`, we use shortest open tokens on each line for indent calculation.
+ # Shortest open tokens can be calculated by `opens.take(min_depth)`
+ indent = 2 * calc_indent_level(prev_opens.take(min_depth))
- case t.event
- when :on_lbracket, :on_lbrace, :on_lparen, :on_tlambeg
- depth_difference += 1
- open_brace_on_line += 1
- when :on_rbracket, :on_rbrace, :on_rparen
- depth_difference -= 1 if open_brace_on_line > 0
- when :on_kw
- next if index > 0 and @tokens[index - 1].state.allbits?(Ripper::EXPR_FNAME)
- case t.tok
- when 'do'
- syntax_of_do = take_corresponding_syntax_to_kw_do(@tokens, index)
- depth_difference += 1 if syntax_of_do == :method_calling
- when 'def', 'case', 'for', 'begin', 'class', 'module'
- depth_difference += 1
- when 'if', 'unless', 'while', 'until', 'rescue'
- # postfix if/unless/while/until/rescue must be Ripper::EXPR_LABEL
- unless t.state.allbits?(Ripper::EXPR_LABEL)
- depth_difference += 1
- end
- when 'else', 'elsif', 'ensure', 'when'
- depth_difference += 1
- when 'in'
- unless is_the_in_correspond_to_a_for(@tokens, index)
- depth_difference += 1
- end
- when 'end'
- depth_difference -= 1
- end
- end
- end
- depth_difference
- end
+ preserve_indent = lines[line_index - (is_newline ? 1 : 0)][/^ */].size
- def check_corresponding_token_depth(lines, line_index)
- corresponding_token_depth = nil
- is_first_spaces_of_line = true
- is_first_printable_of_line = true
- spaces_of_nest = []
- spaces_at_line_head = 0
- open_brace_on_line = 0
- in_oneliner_def = nil
-
- if heredoc_scope?
- return lines[line_index][/^ */].length
- end
+ prev_open_token = prev_opens.last
+ next_open_token = next_opens.last
- @tokens.each_with_index do |t, index|
- # detecting one-liner method definition
- if in_oneliner_def.nil?
- if t.state.allbits?(Ripper::EXPR_ENDFN)
- in_oneliner_def = :ENDFN
- end
+ # Calculates base indent for pasted code on the line where prev_open_token is located
+ # irb(main):001:1* if a # base_indent is 2, indent calculated from tokens is 0
+ # irb(main):002:1* if b # base_indent is 6, indent calculated from tokens is 2
+ # irb(main):003:0> c # base_indent is 6, indent calculated from tokens is 4
+ if prev_open_token
+ base_indent = [0, indent_difference(lines, line_results, prev_open_token.pos[0] - 1)].max
else
- if t.state.allbits?(Ripper::EXPR_ENDFN)
- # continuing
- elsif t.state.allbits?(Ripper::EXPR_BEG)
- if t.tok == '='
- in_oneliner_def = :BODY
- end
- else
- if in_oneliner_def == :BODY
- # one-liner method definition
- if is_first_printable_of_line
- corresponding_token_depth = spaces_of_nest.pop
- else
- spaces_of_nest.pop
- corresponding_token_depth = nil
- end
- end
- in_oneliner_def = nil
- end
+ base_indent = 0
end
- case t.event
- when :on_ignored_nl, :on_nl, :on_comment, :on_heredoc_end, :on_embdoc_end
- if in_oneliner_def != :BODY
- corresponding_token_depth = nil
- spaces_at_line_head = 0
- is_first_spaces_of_line = true
- is_first_printable_of_line = true
- open_brace_on_line = 0
+ if free_indent_token?(prev_open_token)
+ if is_newline && prev_open_token.pos[0] == line_index
+ # First newline inside free-indent token
+ base_indent + indent
+ else
+ # Accept any number of indent inside free-indent token
+ preserve_indent
end
- next
- when :on_sp
- spaces_at_line_head = t.tok.count(' ') if is_first_spaces_of_line
- is_first_spaces_of_line = false
- next
- end
-
- case t.event
- when :on_lbracket, :on_lbrace, :on_lparen, :on_tlambeg
- spaces_of_nest.push(spaces_at_line_head + open_brace_on_line * 2)
- open_brace_on_line += 1
- when :on_rbracket, :on_rbrace, :on_rparen
- if is_first_printable_of_line
- corresponding_token_depth = spaces_of_nest.pop
+ elsif prev_open_token&.event == :on_embdoc_beg || next_open_token&.event == :on_embdoc_beg
+ if prev_open_token&.event == next_open_token&.event
+ # Accept any number of indent inside embdoc content
+ preserve_indent
else
- spaces_of_nest.pop
- corresponding_token_depth = nil
+ # =begin or =end
+ 0
end
- open_brace_on_line -= 1
- when :on_kw
- next if index > 0 and @tokens[index - 1].state.allbits?(Ripper::EXPR_FNAME)
- case t.tok
- when 'do'
- syntax_of_do = take_corresponding_syntax_to_kw_do(@tokens, index)
- if syntax_of_do == :method_calling
- spaces_of_nest.push(spaces_at_line_head)
- end
- when 'def', 'case', 'for', 'begin', 'class', 'module'
- spaces_of_nest.push(spaces_at_line_head)
- when 'rescue'
- unless t.state.allbits?(Ripper::EXPR_LABEL)
- corresponding_token_depth = spaces_of_nest.last
- end
- when 'if', 'unless', 'while', 'until'
- # postfix if/unless/while/until must be Ripper::EXPR_LABEL
- unless t.state.allbits?(Ripper::EXPR_LABEL)
- spaces_of_nest.push(spaces_at_line_head)
- end
- when 'else', 'elsif', 'ensure', 'when'
- corresponding_token_depth = spaces_of_nest.last
- when 'in'
- if in_keyword_case_scope?
- corresponding_token_depth = spaces_of_nest.last
- end
- when 'end'
- if is_first_printable_of_line
- corresponding_token_depth = spaces_of_nest.pop
+ elsif prev_open_token&.event == :on_heredoc_beg
+ tok = prev_open_token.tok
+ if prev_opens.size <= next_opens.size
+ if is_newline && lines[line_index].empty? && line_results[line_index - 1][1].last != next_open_token
+ # First line in heredoc
+ tok.match?(/^<<[-~]/) ? base_indent + indent : indent
+ elsif tok.match?(/^<<~/)
+ # Accept extra indent spaces inside `<<~` heredoc
+ [base_indent + indent, preserve_indent].max
else
- spaces_of_nest.pop
- corresponding_token_depth = nil
+ # Accept any number of indent inside other heredoc
+ preserve_indent
end
+ else
+ # Heredoc close
+ prev_line_indent_level = calc_indent_level(prev_opens)
+ tok.match?(/^<<[~-]/) ? base_indent + 2 * (prev_line_indent_level - 1) : 0
end
+ else
+ base_indent + indent
end
- is_first_spaces_of_line = false
- is_first_printable_of_line = false
end
- corresponding_token_depth
- end
- def check_string_literal(tokens)
- i = 0
- start_token = []
- end_type = []
- pending_heredocs = []
- while i < tokens.size
- t = tokens[i]
- case t.event
- when *end_type.last
- start_token.pop
- end_type.pop
- when :on_tstring_beg
- start_token << t
- end_type << [:on_tstring_end, :on_label_end]
- when :on_regexp_beg
- start_token << t
- end_type << :on_regexp_end
- when :on_symbeg
- acceptable_single_tokens = %i{on_ident on_const on_op on_cvar on_ivar on_gvar on_kw on_int on_backtick}
- if (i + 1) < tokens.size
- if acceptable_single_tokens.all?{ |st| tokens[i + 1].event != st }
- start_token << t
- end_type << :on_tstring_end
- else
- i += 1
- end
- end
- when :on_backtick
- if t.state.allbits?(Ripper::EXPR_BEG)
- start_token << t
- end_type << :on_tstring_end
- end
- when :on_qwords_beg, :on_words_beg, :on_qsymbols_beg, :on_symbols_beg
- start_token << t
- end_type << :on_tstring_end
- when :on_heredoc_beg
- pending_heredocs << t
- end
+ LTYPE_TOKENS = %i[
+ on_heredoc_beg on_tstring_beg
+ on_regexp_beg on_symbeg on_backtick
+ on_symbols_beg on_qsymbols_beg
+ on_words_beg on_qwords_beg
+ ]
- if pending_heredocs.any? && t.tok.include?("\n")
- pending_heredocs.reverse_each do |t|
- start_token << t
- end_type << :on_heredoc_end
- end
- pending_heredocs = []
+ def ltype_from_open_tokens(opens)
+ start_token = opens.reverse_each.find do |tok|
+ LTYPE_TOKENS.include?(tok.event)
end
- i += 1
- end
- pending_heredocs.first || start_token.last
- end
+ return nil unless start_token
- def process_literal_type(tokens)
- start_token = check_string_literal(tokens)
- return nil if start_token == ""
-
- case start_token&.event
- when :on_tstring_beg
- case start_token&.tok
- when ?" then ?"
- when /^%.$/ then ?"
- when /^%Q.$/ then ?"
- when ?' then ?'
- when /^%q.$/ then ?'
- end
- when :on_regexp_beg then ?/
- when :on_symbeg then ?:
- when :on_backtick then ?`
- when :on_qwords_beg then ?]
- when :on_words_beg then ?]
- when :on_qsymbols_beg then ?]
- when :on_symbols_beg then ?]
- when :on_heredoc_beg
- start_token&.tok =~ /<<[-~]?(['"`])\w+\1/
- $1 || ?"
- else
- nil
- end
- end
-
- def check_termination_in_prev_line(code)
- tokens = self.class.ripper_lex_without_warning(code, context: @context)
- past_first_newline = false
- index = tokens.rindex do |t|
- # traverse first token before last line
- if past_first_newline
- if t.tok.include?("\n")
- true
+ case start_token&.event
+ when :on_tstring_beg
+ case start_token&.tok
+ when ?" then ?"
+ when /^%.$/ then ?"
+ when /^%Q.$/ then ?"
+ when ?' then ?'
+ when /^%q.$/ then ?'
end
- elsif t.tok.include?("\n")
- past_first_newline = true
- false
+ when :on_regexp_beg then ?/
+ when :on_symbeg then ?:
+ when :on_backtick then ?`
+ when :on_qwords_beg then ?]
+ when :on_words_beg then ?]
+ when :on_qsymbols_beg then ?]
+ when :on_symbols_beg then ?]
+ when :on_heredoc_beg
+ start_token&.tok =~ /<<[-~]?(['"`])\w+\1/
+ $1 || ?"
else
- false
+ nil
end
end
- if index
- first_token = nil
- last_line_tokens = tokens[(index + 1)..(tokens.size - 1)]
- last_line_tokens.each do |t|
- unless [:on_sp, :on_ignored_sp, :on_comment].include?(t.event)
- first_token = t
- break
- end
- end
-
- if first_token.nil?
- return false
- elsif first_token && first_token.state == Ripper::EXPR_DOT
- return false
- else
- tokens_without_last_line = tokens[0..index]
- ltype = process_literal_type(tokens_without_last_line)
- indent = process_nesting_level(tokens_without_last_line)
- continue = process_continue(tokens_without_last_line)
- code_block_open = check_code_block(tokens_without_last_line.map(&:tok).join(''), tokens_without_last_line)
- if ltype or indent > 0 or continue or code_block_open
- return false
+ def check_termination_in_prev_line(code, local_variables:)
+ tokens = self.class.ripper_lex_without_warning(code, local_variables: local_variables)
+ past_first_newline = false
+ index = tokens.rindex do |t|
+ # traverse first token before last line
+ if past_first_newline
+ if t.tok.include?("\n")
+ true
+ end
+ elsif t.tok.include?("\n")
+ past_first_newline = true
+ false
else
- return last_line_tokens.map(&:tok).join('')
+ false
end
end
- end
- false
- end
-
- private
- def heredoc_scope?
- heredoc_tokens = @tokens.select { |t| [:on_heredoc_beg, :on_heredoc_end].include?(t.event) }
- heredoc_tokens[-1]&.event == :on_heredoc_beg
- end
+ if index
+ first_token = nil
+ last_line_tokens = tokens[(index + 1)..(tokens.size - 1)]
+ last_line_tokens.each do |t|
+ unless [:on_sp, :on_ignored_sp, :on_comment].include?(t.event)
+ first_token = t
+ break
+ end
+ end
- def in_keyword_case_scope?
- kw_tokens = @tokens.select { |t| t.event == :on_kw && ['case', 'for', 'end'].include?(t.tok) }
- counter = 0
- kw_tokens.reverse.each do |t|
- if t.tok == 'case'
- return true if counter.zero?
- counter += 1
- elsif t.tok == 'for'
- counter += 1
- elsif t.tok == 'end'
- counter -= 1
+ if first_token && first_token.state != Ripper::EXPR_DOT
+ tokens_without_last_line = tokens[0..index]
+ code_without_last_line = tokens_without_last_line.map(&:tok).join
+ opens_without_last_line = NestingParser.open_tokens(tokens_without_last_line)
+ if code_terminated?(code_without_last_line, tokens_without_last_line, opens_without_last_line, local_variables: local_variables)
+ return last_line_tokens.map(&:tok).join
+ end
+ end
end
+ false
end
- false
end
+ # :startdoc:
end
-# :startdoc:
+
+RubyLex = IRB::RubyLex
+Object.deprecate_constant(:RubyLex)
diff --git a/lib/irb/ruby_logo.aa b/lib/irb/ruby_logo.aa
index a34a3e2f28..61fe22c94a 100644
--- a/lib/irb/ruby_logo.aa
+++ b/lib/irb/ruby_logo.aa
@@ -1,3 +1,4 @@
+TYPE: LARGE
-+smJYYN?mm-
HB"BBYT TQg NggT
@@ -35,3 +36,45 @@
m7 NW H N HSVO1z=?11-
NgTH bB kH WBHWWHBHWmQgg&gggggNNN
NNggggggNN
+TYPE: ASCII
+ ,,,;;;;''''';;;'';,
+ ,,;'' ';;,;;; ',
+ ,,'' ;;'';'''';;;;;;
+ ,;' ;; ',, ;
+ ,;' ,;' ';, ;
+ ;' ,;; ',,,;
+ ,' ,;;,,,,,,,,,,,;;;;
+ ;' ;;';;;; ,;;
+ ;' ,;' ;; '',, ,;;;
+ ;; ,;' ; '';, ,; ;'
+;; ,;;' ;; ;; ;;
+;;, ,,;;' ; ;'; ;;
+;';;,,,,;;;;;;;,,, ;; ,' ; ;;
+; ;;''' ,;'; ''';,,, ; ,;' ;;;;
+;;;;, ; '; ''';;;' ';;;
+;'; ;, ;' '; ,;' ', ;;;
+;;; ; ,; '; ,,' ',, ;;
+;;; '; ;' ';,,'' ';,;;
+ '; ';,; ,,;''''''''';;;;;;,,;;;
+ ';,,;;,,;;;;;;;;;;''''''''''''''
+TYPE: UNICODE
+ ⣀⣤⣴⣾⣿⣿⣿⡛⠛⠛⠛⠛⣻⣿⠿⠛⠛⠶⣤⡀
+ ⣀⣴⠾⠛⠉⠁ ⠙⣿⣶⣤⣶⣟⣉ ⠈⠻⣦
+ ⣀⣴⠟⠋ ⢸⣿⠟⠻⣯⡙⠛⠛⠛⠶⠶⠶⢶⣽⣇
+ ⣠⡾⠋⠁ ⣾⡿ ⠈⠛⢦⣄ ⣿
+ ⣠⡾⠋ ⣰⣿⠃ ⠙⠷⣤⡀ ⣿
+ ⢀⡾⠋ ⣰⣿⡏ ⠈⠻⣦⣄⢠⣿
+ ⣰⠟⠁ ⣴⣿⣿⣁⣀⣠⣤⣤⣤⣤⣤⣤⣤⣴⠶⠿⣿⡏
+ ⣼⠏ ⢀⣾⣿⠟⣿⠿⣯⣍⠁ ⣰⣿⡇
+ ⢀⣼⠋ ⢀⣴⣿⠟⠁ ⢸⡇ ⠙⠻⢦⣄⡀ ⢠⡿⣿⡇
+⢀⣾⡏ ⢀⣴⣿⠟⠁ ⣿ ⠉⠻⢶⣄⡀⣰⡟ ⣿⠃
+⣾⣿⠁ ⣠⣶⡿⠋⠁ ⢹⡇ ⠈⣿⡏ ⢸⣿
+⣿⣿⡆ ⢀⣠⣴⣿⡿⠋ ⠈⣿ ⢀⡾⠋⣿ ⢸⣿
+⣿⠸⣿⣶⣤⣤⣤⣤⣶⣾⠿⠿⣿⣿⠶⣤⣤⣀⡀ ⢹⡇ ⣴⠟⠁ ⣿⡀⢸⣿
+⣿⢀⣿⣟⠛⠋⠉⠁ ⢰⡟⠹⣧ ⠈⠉⠛⠻⠶⢦⣤⣀⡀ ⠈⣿ ⣠⡾⠃ ⢸⡇⢸⡇
+⣿⣾⣿⢿⡄ ⣿⠁ ⠘⣧ ⠉⠙⠛⠷⣿⣿⡋ ⠸⣇⣸⡇
+⣿⠃⣿⠈⢿⡄ ⣸⠇ ⠘⣧ ⢀⣤⠾⠋⠈⠻⣦⡀ ⣿⣿⡇
+⣿⢸⡏ ⠈⣷⡀ ⢠⡿ ⠘⣧⡀ ⣠⡴⠟⠁ ⠈⠻⣦⣀ ⢿⣿⠁
+⢻⣾⡇ ⠘⣷ ⣼⠃ ⠘⣷⣠⣴⠟⠋ ⠙⢷⣄⢸⣿
+ ⠻⣧⡀ ⠘⣧⣰⡏ ⢀⣠⣤⠶⠛⠉⠛⠛⠛⠛⠛⠛⠻⢶⣶⣶⣶⣶⣶⣤⣤⣽⣿⣿
+ ⠈⠛⠷⢦⣤⣽⣿⣥⣤⣶⣶⡿⠿⠿⠶⠶⠶⠶⠾⠛⠛⠛⠛⠛⠛⠛⠋⠉⠉⠉⠉⠉⠉⠁
diff --git a/lib/irb/source_finder.rb b/lib/irb/source_finder.rb
new file mode 100644
index 0000000000..659d4200fd
--- /dev/null
+++ b/lib/irb/source_finder.rb
@@ -0,0 +1,78 @@
+# frozen_string_literal: true
+
+require_relative "ruby-lex"
+
+module IRB
+ class SourceFinder
+ Source = Struct.new(
+ :file, # @param [String] - file name
+ :first_line, # @param [String] - first line
+ :last_line, # @param [String] - last line
+ keyword_init: true,
+ )
+ private_constant :Source
+
+ def initialize(irb_context)
+ @irb_context = irb_context
+ end
+
+ def find_source(signature, super_level = 0)
+ context_binding = @irb_context.workspace.binding
+ case signature
+ when /\A[A-Z]\w*(::[A-Z]\w*)*\z/ # Const::Name
+ eval(signature, context_binding) # trigger autoload
+ base = context_binding.receiver.yield_self { |r| r.is_a?(Module) ? r : Object }
+ file, line = base.const_source_location(signature)
+ when /\A(?<owner>[A-Z]\w*(::[A-Z]\w*)*)#(?<method>[^ :.]+)\z/ # Class#method
+ owner = eval(Regexp.last_match[:owner], context_binding)
+ method = Regexp.last_match[:method]
+ return unless owner.respond_to?(:instance_method)
+ file, line = method_target(owner, super_level, method, "owner")
+ when /\A((?<receiver>.+)(\.|::))?(?<method>[^ :.]+)\z/ # method, receiver.method, receiver::method
+ receiver = eval(Regexp.last_match[:receiver] || 'self', context_binding)
+ method = Regexp.last_match[:method]
+ return unless receiver.respond_to?(method, true)
+ file, line = method_target(receiver, super_level, method, "receiver")
+ end
+ if file && line && File.exist?(file)
+ Source.new(file: file, first_line: line, last_line: find_end(file, line))
+ end
+ end
+
+ private
+
+ def find_end(file, first_line)
+ lex = RubyLex.new
+ lines = File.read(file).lines[(first_line - 1)..-1]
+ tokens = RubyLex.ripper_lex_without_warning(lines.join)
+ prev_tokens = []
+
+ # chunk with line number
+ tokens.chunk { |tok| tok.pos[0] }.each do |lnum, chunk|
+ code = lines[0..lnum].join
+ prev_tokens.concat chunk
+ continue = lex.should_continue?(prev_tokens)
+ syntax = lex.check_code_syntax(code, local_variables: [])
+ if !continue && syntax == :valid
+ return first_line + lnum
+ end
+ end
+ first_line
+ end
+
+ def method_target(owner_receiver, super_level, method, type)
+ case type
+ when "owner"
+ target_method = owner_receiver.instance_method(method)
+ when "receiver"
+ target_method = owner_receiver.method(method)
+ end
+ super_level.times do |s|
+ target_method = target_method.super_method if target_method
+ end
+ target_method.nil? ? nil : target_method.source_location
+ rescue NameError
+ nil
+ end
+ end
+end
diff --git a/lib/irb/src_encoding.rb b/lib/irb/src_encoding.rb
deleted file mode 100644
index 99aea2b43e..0000000000
--- a/lib/irb/src_encoding.rb
+++ /dev/null
@@ -1,7 +0,0 @@
-# frozen_string_literal: false
-# DO NOT WRITE ANY MAGIC COMMENT HERE.
-module IRB
- def self.default_src_encoding
- return __ENCODING__
- end
-end
diff --git a/lib/irb/statement.rb b/lib/irb/statement.rb
new file mode 100644
index 0000000000..b12110600c
--- /dev/null
+++ b/lib/irb/statement.rb
@@ -0,0 +1,80 @@
+# frozen_string_literal: true
+
+module IRB
+ class Statement
+ attr_reader :code
+
+ def is_assignment?
+ raise NotImplementedError
+ end
+
+ def suppresses_echo?
+ raise NotImplementedError
+ end
+
+ def should_be_handled_by_debugger?
+ raise NotImplementedError
+ end
+
+ def evaluable_code
+ raise NotImplementedError
+ end
+
+ class Expression < Statement
+ def initialize(code, is_assignment)
+ @code = code
+ @is_assignment = is_assignment
+ end
+
+ def suppresses_echo?
+ @code.match?(/;\s*\z/)
+ end
+
+ def should_be_handled_by_debugger?
+ true
+ end
+
+ def is_assignment?
+ @is_assignment
+ end
+
+ def evaluable_code
+ @code
+ end
+ end
+
+ class Command < Statement
+ def initialize(code, command, arg, command_class)
+ @code = code
+ @command = command
+ @arg = arg
+ @command_class = command_class
+ end
+
+ def is_assignment?
+ false
+ end
+
+ def suppresses_echo?
+ false
+ end
+
+ def should_be_handled_by_debugger?
+ require_relative 'cmd/help'
+ require_relative 'cmd/debug'
+ IRB::ExtendCommand::DebugCommand > @command_class || IRB::ExtendCommand::Help == @command_class
+ end
+
+ def evaluable_code
+ # Hook command-specific transformation to return valid Ruby code
+ if @command_class.respond_to?(:transform_args)
+ arg = @command_class.transform_args(@arg)
+ else
+ arg = @arg
+ end
+
+ [@command, arg].compact.join(' ')
+ end
+ end
+ end
+end
diff --git a/lib/irb/version.rb b/lib/irb/version.rb
index 33b423ea18..c0be6d91e5 100644
--- a/lib/irb/version.rb
+++ b/lib/irb/version.rb
@@ -5,7 +5,7 @@
#
module IRB # :nodoc:
- VERSION = "1.6.2"
+ VERSION = "1.11.0"
@RELEASE_VERSION = VERSION
- @LAST_UPDATE_DATE = "2022-12-13"
+ @LAST_UPDATE_DATE = "2023-12-19"
end
diff --git a/lib/irb/workspace.rb b/lib/irb/workspace.rb
index 5f990940e8..2bf3d5e0f1 100644
--- a/lib/irb/workspace.rb
+++ b/lib/irb/workspace.rb
@@ -108,8 +108,12 @@ EOF
# <code>IRB.conf[:__MAIN__]</code>
attr_reader :main
+ def load_commands_to_main
+ main.extend ExtendCommandBundle
+ end
+
# Evaluate the given +statements+ within the context of this workspace.
- def evaluate(context, statements, file = __FILE__, line = __LINE__)
+ def evaluate(statements, file = __FILE__, line = __LINE__)
eval(statements, @binding, file, line)
end
@@ -122,6 +126,8 @@ EOF
end
# error message manipulator
+ # WARN: Rails patches this method to filter its own backtrace. Be cautious when changing it.
+ # See: https://github.com/rails/rails/blob/main/railties/lib/rails/commands/console/console_command.rb#L8:~:text=def,filter_backtrace
def filter_backtrace(bt)
return nil if bt =~ /\/irb\/.*\.rb/
return nil if bt =~ /\/irb\.rb/
diff --git a/lib/irb/xmp.rb b/lib/irb/xmp.rb
index 94c700b484..de29089429 100644
--- a/lib/irb/xmp.rb
+++ b/lib/irb/xmp.rb
@@ -44,8 +44,8 @@ class XMP
# The top-level binding or, optional +bind+ parameter will be used when
# creating the workspace. See WorkSpace.new for more information.
#
- # This uses the +:XMP+ prompt mode, see IRB@Customizing+the+IRB+Prompt for
- # full detail.
+ # This uses the +:XMP+ prompt mode.
+ # See {Custom Prompts}[rdoc-ref:IRB@Custom+Prompts] for more information.
def initialize(bind = nil)
IRB.init_config(nil)
diff --git a/lib/logger.rb b/lib/logger.rb
index 7e4dacc911..4099955ef2 100644
--- a/lib/logger.rb
+++ b/lib/logger.rb
@@ -10,6 +10,7 @@
#
# A simple system for logging messages. See Logger for more documentation.
+require 'fiber'
require 'monitor'
require 'rbconfig'
@@ -264,8 +265,7 @@ require_relative 'logger/errors'
# logger.error! # => 3
# logger.fatal! # => 4
#
-# You can retrieve the log level with method
-# {level}[Logger.html#attribute-i-level]:
+# You can retrieve the log level with method #level.
#
# logger.level = Logger::ERROR
# logger.level # => 3
@@ -380,7 +380,9 @@ class Logger
include Severity
# Logging severity threshold (e.g. <tt>Logger::INFO</tt>).
- attr_reader :level
+ def level
+ @level_override[Fiber.current] || @level
+ end
# Sets the log level; returns +severity+.
# See {Log Level}[rdoc-ref:Logger@Log+Level].
@@ -395,24 +397,23 @@ class Logger
# Logger#sev_threshold= is an alias for Logger#level=.
#
def level=(severity)
- if severity.is_a?(Integer)
- @level = severity
- else
- case severity.to_s.downcase
- when 'debug'
- @level = DEBUG
- when 'info'
- @level = INFO
- when 'warn'
- @level = WARN
- when 'error'
- @level = ERROR
- when 'fatal'
- @level = FATAL
- when 'unknown'
- @level = UNKNOWN
+ @level = Severity.coerce(severity)
+ end
+
+ # Adjust the log level during the block execution for the current Fiber only
+ #
+ # logger.with_level(:debug) do
+ # logger.debug { "Hello" }
+ # end
+ def with_level(severity)
+ prev, @level_override[Fiber.current] = level, Severity.coerce(severity)
+ begin
+ yield
+ ensure
+ if prev
+ @level_override[Fiber.current] = prev
else
- raise ArgumentError, "invalid log level: #{severity}"
+ @level_override.delete(Fiber.current)
end
end
end
@@ -583,6 +584,7 @@ class Logger
self.datetime_format = datetime_format
self.formatter = formatter
@logdev = nil
+ @level_override = {}
if logdev && logdev != File::NULL
@logdev = LogDevice.new(logdev, shift_age: shift_age,
shift_size: shift_size,
diff --git a/lib/logger/logger.gemspec b/lib/logger/logger.gemspec
index d12db625d9..5e8232e4ab 100644
--- a/lib/logger/logger.gemspec
+++ b/lib/logger/logger.gemspec
@@ -18,9 +18,5 @@ Gem::Specification.new do |spec|
spec.files = Dir.glob("lib/**/*.rb") + ["logger.gemspec"]
spec.require_paths = ["lib"]
- spec.required_ruby_version = ">= 2.3.0"
-
- spec.add_development_dependency "bundler", ">= 0"
- spec.add_development_dependency "rake", ">= 12.3.3"
- spec.add_development_dependency "test-unit"
+ spec.required_ruby_version = ">= 2.5.0"
end
diff --git a/lib/logger/severity.rb b/lib/logger/severity.rb
index b38afb7d22..e96fb0d320 100644
--- a/lib/logger/severity.rb
+++ b/lib/logger/severity.rb
@@ -15,5 +15,24 @@ class Logger
FATAL = 4
# An unknown message that should always be logged.
UNKNOWN = 5
+
+ LEVELS = {
+ "debug" => DEBUG,
+ "info" => INFO,
+ "warn" => WARN,
+ "error" => ERROR,
+ "fatal" => FATAL,
+ "unknown" => UNKNOWN,
+ }
+ private_constant :LEVELS
+
+ def self.coerce(severity)
+ if severity.is_a?(Integer)
+ severity
+ else
+ key = severity.to_s.downcase
+ LEVELS[key] || raise(ArgumentError, "invalid log level: #{severity}")
+ end
+ end
end
end
diff --git a/lib/logger/version.rb b/lib/logger/version.rb
index f85c72eed3..202b6e4fba 100644
--- a/lib/logger/version.rb
+++ b/lib/logger/version.rb
@@ -1,5 +1,5 @@
# frozen_string_literal: true
class Logger
- VERSION = "1.5.3"
+ VERSION = "1.6.0"
end
diff --git a/lib/mkmf.rb b/lib/mkmf.rb
index 245b0a44ce..6da7dde5f1 100644
--- a/lib/mkmf.rb
+++ b/lib/mkmf.rb
@@ -1792,7 +1792,8 @@ SRC
# application.
#
def dir_config(target, idefault=nil, ldefault=nil)
- if conf = $config_dirs[target]
+ key = [target, idefault, ldefault].compact.join("\0")
+ if conf = $config_dirs[key]
return conf
end
@@ -1802,9 +1803,13 @@ SRC
end
idir = with_config(target + "-include", idefault)
- $arg_config.last[1] ||= "${#{target}-dir}/include"
+ if conf = $arg_config.assoc("--with-#{target}-include")
+ conf[1] ||= "${#{target}-dir}/include"
+ end
ldir = with_config(target + "-lib", ldefault)
- $arg_config.last[1] ||= "${#{target}-dir}/#{_libdir_basename}"
+ if conf = $arg_config.assoc("--with-#{target}-lib")
+ conf[1] ||= "${#{target}-dir}/#{_libdir_basename}"
+ end
idirs = idir ? Array === idir ? idir.dup : idir.split(File::PATH_SEPARATOR) : []
if defaults
@@ -1826,7 +1831,7 @@ SRC
end
$LIBPATH = ldirs | $LIBPATH
- $config_dirs[target] = [idir, ldir]
+ $config_dirs[key] = [idir, ldir]
end
# Returns compile/link information about an installed library in a tuple of <code>[cflags,
@@ -1965,14 +1970,14 @@ SRC
def configuration(srcdir)
mk = []
- CONFIG['MKMF_VERBOSE'] ||= "0"
+ verbose = with_config('verbose') ? "1" : (CONFIG['MKMF_VERBOSE'] || "0")
vpath = $VPATH.dup
CONFIG["hdrdir"] ||= $hdrdir
mk << %{
SHELL = /bin/sh
# V=0 quiet, V=1 verbose. other values don't work.
-V = #{CONFIG['MKMF_VERBOSE']}
+V = #{verbose}
V0 = $(V:0=)
Q1 = $(V:1=)
Q = $(Q1:0=@)
@@ -2699,7 +2704,7 @@ MESSAGE
when $mswin
$nmake = ?m if /nmake/i =~ make
end
- $ignore_error = $nmake ? '' : ' 2> /dev/null || true'
+ $ignore_error = " 2> #{File::NULL} || #{$mswin ? 'exit /b0' : 'true'}"
RbConfig::CONFIG["srcdir"] = CONFIG["srcdir"] =
$srcdir = arg_config("--srcdir", File.dirname($0))
diff --git a/lib/mutex_m.rb b/lib/mutex_m.rb
index 4c888d6a17..7e55181881 100644
--- a/lib/mutex_m.rb
+++ b/lib/mutex_m.rb
@@ -40,7 +40,7 @@
#
module Mutex_m
- VERSION = "0.1.2"
+ VERSION = "0.2.0"
Ractor.make_shareable(VERSION) if defined?(Ractor)
def Mutex_m.define_aliases(cl) # :nodoc:
diff --git a/lib/net/http.rb b/lib/net/http.rb
index 2b8e9a9907..387df4b8f4 100644
--- a/lib/net/http.rb
+++ b/lib/net/http.rb
@@ -1,4 +1,4 @@
-# frozen_string_literal: false
+# frozen_string_literal: true
#
# = net/http.rb
#
@@ -173,7 +173,7 @@ module Net #:nodoc:
# {Request Fields}[https://en.wikipedia.org/wiki/List_of_HTTP_header_fields#Request_fields].
# A host may also accept other custom fields.
#
- # == Sessions
+ # == \HTTP Sessions
#
# A _session_ is a connection between a server (host) and a client that:
#
@@ -332,34 +332,397 @@ module Net #:nodoc:
# uri # => #<URI::HTTPS https://jsonplaceholder.typicode.com/>
# Net::HTTP.get(uri)
#
- # == Proxies
+ # == Proxy Server
#
- # \Net::HTTP will automatically create a proxy from the +http_proxy+
- # environment variable if it is present. To disable use of +http_proxy+,
- # pass +nil+ for the proxy address.
+ # An \HTTP object can have
+ # a {proxy server}[https://en.wikipedia.org/wiki/Proxy_server].
#
- # You may also create a custom proxy:
+ # You can create an \HTTP object with a proxy server
+ # using method Net::HTTP.new or method Net::HTTP.start.
#
- # proxy_addr = 'your.proxy.host'
- # proxy_port = 8080
+ # The proxy may be defined either by argument +p_addr+
+ # or by environment variable <tt>'http_proxy'</tt>.
#
- # Net::HTTP.new('example.com', nil, proxy_addr, proxy_port).start { |http|
- # # always proxy via your.proxy.addr:8080
- # }
+ # === Proxy Using Argument +p_addr+ as a \String
#
- # == Compression
+ # When argument +p_addr+ is a string hostname,
+ # the returned +http+ has the given host as its proxy:
#
- # \Net::HTTP automatically adds Accept-Encoding for compression of response
- # bodies and automatically decompresses gzip and deflate responses unless a
- # Range header was sent.
+ # http = Net::HTTP.new(hostname, nil, 'proxy.example')
+ # http.proxy? # => true
+ # http.proxy_from_env? # => false
+ # http.proxy_address # => "proxy.example"
+ # # These use default values.
+ # http.proxy_port # => 80
+ # http.proxy_user # => nil
+ # http.proxy_pass # => nil
#
- # Compression can be disabled through the Accept-Encoding: identity header.
+ # The port, username, and password for the proxy may also be given:
+ #
+ # http = Net::HTTP.new(hostname, nil, 'proxy.example', 8000, 'pname', 'ppass')
+ # # => #<Net::HTTP jsonplaceholder.typicode.com:80 open=false>
+ # http.proxy? # => true
+ # http.proxy_from_env? # => false
+ # http.proxy_address # => "proxy.example"
+ # http.proxy_port # => 8000
+ # http.proxy_user # => "pname"
+ # http.proxy_pass # => "ppass"
+ #
+ # === Proxy Using '<tt>ENV['http_proxy']</tt>'
+ #
+ # When environment variable <tt>'http_proxy'</tt>
+ # is set to a \URI string,
+ # the returned +http+ will have the server at that URI as its proxy;
+ # note that the \URI string must have a protocol
+ # such as <tt>'http'</tt> or <tt>'https'</tt>:
+ #
+ # ENV['http_proxy'] = 'http://example.com'
+ # http = Net::HTTP.new(hostname)
+ # http.proxy? # => true
+ # http.proxy_from_env? # => true
+ # http.proxy_address # => "example.com"
+ # # These use default values.
+ # http.proxy_port # => 80
+ # http.proxy_user # => nil
+ # http.proxy_pass # => nil
+ #
+ # The \URI string may include proxy username, password, and port number:
+ #
+ # ENV['http_proxy'] = 'http://pname:ppass@example.com:8000'
+ # http = Net::HTTP.new(hostname)
+ # http.proxy? # => true
+ # http.proxy_from_env? # => true
+ # http.proxy_address # => "example.com"
+ # http.proxy_port # => 8000
+ # http.proxy_user # => "pname"
+ # http.proxy_pass # => "ppass"
+ #
+ # === Filtering Proxies
+ #
+ # With method Net::HTTP.new (but not Net::HTTP.start),
+ # you can use argument +p_no_proxy+ to filter proxies:
+ #
+ # - Reject a certain address:
+ #
+ # http = Net::HTTP.new('example.com', nil, 'proxy.example', 8000, 'pname', 'ppass', 'proxy.example')
+ # http.proxy_address # => nil
+ #
+ # - Reject certain domains or subdomains:
+ #
+ # http = Net::HTTP.new('example.com', nil, 'my.proxy.example', 8000, 'pname', 'ppass', 'proxy.example')
+ # http.proxy_address # => nil
+ #
+ # - Reject certain addresses and port combinations:
+ #
+ # http = Net::HTTP.new('example.com', nil, 'proxy.example', 8000, 'pname', 'ppass', 'proxy.example:1234')
+ # http.proxy_address # => "proxy.example"
+ #
+ # http = Net::HTTP.new('example.com', nil, 'proxy.example', 8000, 'pname', 'ppass', 'proxy.example:8000')
+ # http.proxy_address # => nil
+ #
+ # - Reject a list of the types above delimited using a comma:
+ #
+ # http = Net::HTTP.new('example.com', nil, 'proxy.example', 8000, 'pname', 'ppass', 'my.proxy,proxy.example:8000')
+ # http.proxy_address # => nil
+ #
+ # http = Net::HTTP.new('example.com', nil, 'my.proxy', 8000, 'pname', 'ppass', 'my.proxy,proxy.example:8000')
+ # http.proxy_address # => nil
+ #
+ # == Compression and Decompression
+ #
+ # \Net::HTTP does not compress the body of a request before sending.
+ #
+ # By default, \Net::HTTP adds header <tt>'Accept-Encoding'</tt>
+ # to a new {request object}[rdoc-ref:Net::HTTPRequest]:
+ #
+ # Net::HTTP::Get.new(uri)['Accept-Encoding']
+ # # => "gzip;q=1.0,deflate;q=0.6,identity;q=0.3"
+ #
+ # This requests the server to zip-encode the response body if there is one;
+ # the server is not required to do so.
+ #
+ # \Net::HTTP does not automatically decompress a response body
+ # if the response has header <tt>'Content-Range'</tt>.
+ #
+ # Otherwise decompression (or not) depends on the value of header
+ # {Content-Encoding}[https://en.wikipedia.org/wiki/List_of_HTTP_header_fields#content-encoding-response-header]:
+ #
+ # - <tt>'deflate'</tt>, <tt>'gzip'</tt>, or <tt>'x-gzip'</tt>:
+ # decompresses the body and deletes the header.
+ # - <tt>'none'</tt> or <tt>'identity'</tt>:
+ # does not decompress the body, but deletes the header.
+ # - Any other value:
+ # leaves the body and header unchanged.
+ #
+ # == What's Here
+ #
+ # This is a categorized summary of methods and attributes.
+ #
+ # === \Net::HTTP Objects
+ #
+ # - {::new}[rdoc-ref:Net::HTTP.new]:
+ # Creates a new instance.
+ # - {#inspect}[rdoc-ref:Net::HTTP#inspect]:
+ # Returns a string representation of +self+.
+ #
+ # === Sessions
+ #
+ # - {::start}[rdoc-ref:Net::HTTP.start]:
+ # Begins a new session in a new \Net::HTTP object.
+ # - {#started?}[rdoc-ref:Net::HTTP#started?]
+ # (aliased as {#active?}[rdoc-ref:Net::HTTP#active?]):
+ # Returns whether in a session.
+ # - {#finish}[rdoc-ref:Net::HTTP#finish]:
+ # Ends an active session.
+ # - {#start}[rdoc-ref:Net::HTTP#start]:
+ # Begins a new session in an existing \Net::HTTP object (+self+).
+ #
+ # === Connections
+ #
+ # - {:continue_timeout}[rdoc-ref:Net::HTTP#continue_timeout]:
+ # Returns the continue timeout.
+ # - {#continue_timeout=}[rdoc-ref:Net::HTTP#continue_timeout=]:
+ # Sets the continue timeout seconds.
+ # - {:keep_alive_timeout}[rdoc-ref:Net::HTTP#keep_alive_timeout]:
+ # Returns the keep-alive timeout.
+ # - {:keep_alive_timeout=}[rdoc-ref:Net::HTTP#keep_alive_timeout=]:
+ # Sets the keep-alive timeout.
+ # - {:max_retries}[rdoc-ref:Net::HTTP#max_retries]:
+ # Returns the maximum retries.
+ # - {#max_retries=}[rdoc-ref:Net::HTTP#max_retries=]:
+ # Sets the maximum retries.
+ # - {:open_timeout}[rdoc-ref:Net::HTTP#open_timeout]:
+ # Returns the open timeout.
+ # - {:open_timeout=}[rdoc-ref:Net::HTTP#open_timeout=]:
+ # Sets the open timeout.
+ # - {:read_timeout}[rdoc-ref:Net::HTTP#read_timeout]:
+ # Returns the open timeout.
+ # - {:read_timeout=}[rdoc-ref:Net::HTTP#read_timeout=]:
+ # Sets the read timeout.
+ # - {:ssl_timeout}[rdoc-ref:Net::HTTP#ssl_timeout]:
+ # Returns the ssl timeout.
+ # - {:ssl_timeout=}[rdoc-ref:Net::HTTP#ssl_timeout=]:
+ # Sets the ssl timeout.
+ # - {:write_timeout}[rdoc-ref:Net::HTTP#write_timeout]:
+ # Returns the write timeout.
+ # - {write_timeout=}[rdoc-ref:Net::HTTP#write_timeout=]:
+ # Sets the write timeout.
+ #
+ # === Requests
+ #
+ # - {::get}[rdoc-ref:Net::HTTP.get]:
+ # Sends a GET request and returns the string response body.
+ # - {::get_print}[rdoc-ref:Net::HTTP.get_print]:
+ # Sends a GET request and write the string response body to $stdout.
+ # - {::get_response}[rdoc-ref:Net::HTTP.get_response]:
+ # Sends a GET request and returns a response object.
+ # - {::post_form}[rdoc-ref:Net::HTTP.post_form]:
+ # Sends a POST request with form data and returns a response object.
+ # - {::post}[rdoc-ref:Net::HTTP.post]:
+ # Sends a POST request with data and returns a response object.
+ # - {#copy}[rdoc-ref:Net::HTTP#copy]:
+ # Sends a COPY request and returns a response object.
+ # - {#delete}[rdoc-ref:Net::HTTP#delete]:
+ # Sends a DELETE request and returns a response object.
+ # - {#get}[rdoc-ref:Net::HTTP#get]:
+ # Sends a GET request and returns a response object.
+ # - {#head}[rdoc-ref:Net::HTTP#head]:
+ # Sends a HEAD request and returns a response object.
+ # - {#lock}[rdoc-ref:Net::HTTP#lock]:
+ # Sends a LOCK request and returns a response object.
+ # - {#mkcol}[rdoc-ref:Net::HTTP#mkcol]:
+ # Sends a MKCOL request and returns a response object.
+ # - {#move}[rdoc-ref:Net::HTTP#move]:
+ # Sends a MOVE request and returns a response object.
+ # - {#options}[rdoc-ref:Net::HTTP#options]:
+ # Sends a OPTIONS request and returns a response object.
+ # - {#patch}[rdoc-ref:Net::HTTP#patch]:
+ # Sends a PATCH request and returns a response object.
+ # - {#post}[rdoc-ref:Net::HTTP#post]:
+ # Sends a POST request and returns a response object.
+ # - {#propfind}[rdoc-ref:Net::HTTP#propfind]:
+ # Sends a PROPFIND request and returns a response object.
+ # - {#proppatch}[rdoc-ref:Net::HTTP#proppatch]:
+ # Sends a PROPPATCH request and returns a response object.
+ # - {#put}[rdoc-ref:Net::HTTP#put]:
+ # Sends a PUT request and returns a response object.
+ # - {#request}[rdoc-ref:Net::HTTP#request]:
+ # Sends a request and returns a response object.
+ # - {#request_get}[rdoc-ref:Net::HTTP#request_get]
+ # (aliased as {#get2}[rdoc-ref:Net::HTTP#get2]):
+ # Sends a GET request and forms a response object;
+ # if a block given, calls the block with the object,
+ # otherwise returns the object.
+ # - {#request_head}[rdoc-ref:Net::HTTP#request_head]
+ # (aliased as {#head2}[rdoc-ref:Net::HTTP#head2]):
+ # Sends a HEAD request and forms a response object;
+ # if a block given, calls the block with the object,
+ # otherwise returns the object.
+ # - {#request_post}[rdoc-ref:Net::HTTP#request_post]
+ # (aliased as {#post2}[rdoc-ref:Net::HTTP#post2]):
+ # Sends a POST request and forms a response object;
+ # if a block given, calls the block with the object,
+ # otherwise returns the object.
+ # - {#send_request}[rdoc-ref:Net::HTTP#send_request]:
+ # Sends a request and returns a response object.
+ # - {#trace}[rdoc-ref:Net::HTTP#trace]:
+ # Sends a TRACE request and returns a response object.
+ # - {#unlock}[rdoc-ref:Net::HTTP#unlock]:
+ # Sends an UNLOCK request and returns a response object.
+ #
+ # === Responses
+ #
+ # - {:close_on_empty_response}[rdoc-ref:Net::HTTP#close_on_empty_response]:
+ # Returns whether to close connection on empty response.
+ # - {:close_on_empty_response=}[rdoc-ref:Net::HTTP#close_on_empty_response=]:
+ # Sets whether to close connection on empty response.
+ # - {:ignore_eof}[rdoc-ref:Net::HTTP#ignore_eof]:
+ # Returns whether to ignore end-of-file when reading a response body
+ # with <tt>Content-Length</tt> headers.
+ # - {:ignore_eof=}[rdoc-ref:Net::HTTP#ignore_eof=]:
+ # Sets whether to ignore end-of-file when reading a response body
+ # with <tt>Content-Length</tt> headers.
+ # - {:response_body_encoding}[rdoc-ref:Net::HTTP#response_body_encoding]:
+ # Returns the encoding to use for the response body.
+ # - {#response_body_encoding=}[rdoc-ref:Net::HTTP#response_body_encoding=]:
+ # Sets the response body encoding.
+ #
+ # === Proxies
+ #
+ # - {:proxy_address}[rdoc-ref:Net::HTTP#proxy_address]:
+ # Returns the proxy address.
+ # - {:proxy_address=}[rdoc-ref:Net::HTTP#proxy_address=]:
+ # Sets the proxy address.
+ # - {::proxy_class?}[rdoc-ref:Net::HTTP.proxy_class?]:
+ # Returns whether +self+ is a proxy class.
+ # - {#proxy?}[rdoc-ref:Net::HTTP#proxy?]:
+ # Returns whether +self+ has a proxy.
+ # - {#proxy_address}[rdoc-ref:Net::HTTP#proxy_address]
+ # (aliased as {#proxyaddr}[rdoc-ref:Net::HTTP#proxyaddr]):
+ # Returns the proxy address.
+ # - {#proxy_from_env?}[rdoc-ref:Net::HTTP#proxy_from_env?]:
+ # Returns whether the proxy is taken from an environment variable.
+ # - {:proxy_from_env=}[rdoc-ref:Net::HTTP#proxy_from_env=]:
+ # Sets whether the proxy is to be taken from an environment variable.
+ # - {:proxy_pass}[rdoc-ref:Net::HTTP#proxy_pass]:
+ # Returns the proxy password.
+ # - {:proxy_pass=}[rdoc-ref:Net::HTTP#proxy_pass=]:
+ # Sets the proxy password.
+ # - {:proxy_port}[rdoc-ref:Net::HTTP#proxy_port]:
+ # Returns the proxy port.
+ # - {:proxy_port=}[rdoc-ref:Net::HTTP#proxy_port=]:
+ # Sets the proxy port.
+ # - {#proxy_user}[rdoc-ref:Net::HTTP#proxy_user]:
+ # Returns the proxy user name.
+ # - {:proxy_user=}[rdoc-ref:Net::HTTP#proxy_user=]:
+ # Sets the proxy user.
+ #
+ # === Security
+ #
+ # - {:ca_file}[rdoc-ref:Net::HTTP#ca_file]:
+ # Returns the path to a CA certification file.
+ # - {:ca_file=}[rdoc-ref:Net::HTTP#ca_file=]:
+ # Sets the path to a CA certification file.
+ # - {:ca_path}[rdoc-ref:Net::HTTP#ca_path]:
+ # Returns the path of to CA directory containing certification files.
+ # - {:ca_path=}[rdoc-ref:Net::HTTP#ca_path=]:
+ # Sets the path of to CA directory containing certification files.
+ # - {:cert}[rdoc-ref:Net::HTTP#cert]:
+ # Returns the OpenSSL::X509::Certificate object to be used for client certification.
+ # - {:cert=}[rdoc-ref:Net::HTTP#cert=]:
+ # Sets the OpenSSL::X509::Certificate object to be used for client certification.
+ # - {:cert_store}[rdoc-ref:Net::HTTP#cert_store]:
+ # Returns the X509::Store to be used for verifying peer certificate.
+ # - {:cert_store=}[rdoc-ref:Net::HTTP#cert_store=]:
+ # Sets the X509::Store to be used for verifying peer certificate.
+ # - {:ciphers}[rdoc-ref:Net::HTTP#ciphers]:
+ # Returns the available SSL ciphers.
+ # - {:ciphers=}[rdoc-ref:Net::HTTP#ciphers=]:
+ # Sets the available SSL ciphers.
+ # - {:extra_chain_cert}[rdoc-ref:Net::HTTP#extra_chain_cert]:
+ # Returns the extra X509 certificates to be added to the certificate chain.
+ # - {:extra_chain_cert=}[rdoc-ref:Net::HTTP#extra_chain_cert=]:
+ # Sets the extra X509 certificates to be added to the certificate chain.
+ # - {:key}[rdoc-ref:Net::HTTP#key]:
+ # Returns the OpenSSL::PKey::RSA or OpenSSL::PKey::DSA object.
+ # - {:key=}[rdoc-ref:Net::HTTP#key=]:
+ # Sets the OpenSSL::PKey::RSA or OpenSSL::PKey::DSA object.
+ # - {:max_version}[rdoc-ref:Net::HTTP#max_version]:
+ # Returns the maximum SSL version.
+ # - {:max_version=}[rdoc-ref:Net::HTTP#max_version=]:
+ # Sets the maximum SSL version.
+ # - {:min_version}[rdoc-ref:Net::HTTP#min_version]:
+ # Returns the minimum SSL version.
+ # - {:min_version=}[rdoc-ref:Net::HTTP#min_version=]:
+ # Sets the minimum SSL version.
+ # - {#peer_cert}[rdoc-ref:Net::HTTP#peer_cert]:
+ # Returns the X509 certificate chain for the session's socket peer.
+ # - {:ssl_version}[rdoc-ref:Net::HTTP#ssl_version]:
+ # Returns the SSL version.
+ # - {:ssl_version=}[rdoc-ref:Net::HTTP#ssl_version=]:
+ # Sets the SSL version.
+ # - {#use_ssl=}[rdoc-ref:Net::HTTP#use_ssl=]:
+ # Sets whether a new session is to use Transport Layer Security.
+ # - {#use_ssl?}[rdoc-ref:Net::HTTP#use_ssl?]:
+ # Returns whether +self+ uses SSL.
+ # - {:verify_callback}[rdoc-ref:Net::HTTP#verify_callback]:
+ # Returns the callback for the server certification verification.
+ # - {:verify_callback=}[rdoc-ref:Net::HTTP#verify_callback=]:
+ # Sets the callback for the server certification verification.
+ # - {:verify_depth}[rdoc-ref:Net::HTTP#verify_depth]:
+ # Returns the maximum depth for the certificate chain verification.
+ # - {:verify_depth=}[rdoc-ref:Net::HTTP#verify_depth=]:
+ # Sets the maximum depth for the certificate chain verification.
+ # - {:verify_hostname}[rdoc-ref:Net::HTTP#verify_hostname]:
+ # Returns the flags for server the certification verification at the beginning of the SSL/TLS session.
+ # - {:verify_hostname=}[rdoc-ref:Net::HTTP#verify_hostname=]:
+ # Sets he flags for server the certification verification at the beginning of the SSL/TLS session.
+ # - {:verify_mode}[rdoc-ref:Net::HTTP#verify_mode]:
+ # Returns the flags for server the certification verification at the beginning of the SSL/TLS session.
+ # - {:verify_mode=}[rdoc-ref:Net::HTTP#verify_mode=]:
+ # Sets the flags for server the certification verification at the beginning of the SSL/TLS session.
+ #
+ # === Addresses and Ports
+ #
+ # - {:address}[rdoc-ref:Net::HTTP#address]:
+ # Returns the string host name or host IP.
+ # - {::default_port}[rdoc-ref:Net::HTTP.default_port]:
+ # Returns integer 80, the default port to use for HTTP requests.
+ # - {::http_default_port}[rdoc-ref:Net::HTTP.http_default_port]:
+ # Returns integer 80, the default port to use for HTTP requests.
+ # - {::https_default_port}[rdoc-ref:Net::HTTP.https_default_port]:
+ # Returns integer 443, the default port to use for HTTPS requests.
+ # - {#ipaddr}[rdoc-ref:Net::HTTP#ipaddr]:
+ # Returns the IP address for the connection.
+ # - {#ipaddr=}[rdoc-ref:Net::HTTP#ipaddr=]:
+ # Sets the IP address for the connection.
+ # - {:local_host}[rdoc-ref:Net::HTTP#local_host]:
+ # Returns the string local host used to establish the connection.
+ # - {:local_host=}[rdoc-ref:Net::HTTP#local_host=]:
+ # Sets the string local host used to establish the connection.
+ # - {:local_port}[rdoc-ref:Net::HTTP#local_port]:
+ # Returns the integer local port used to establish the connection.
+ # - {:local_port=}[rdoc-ref:Net::HTTP#local_port=]:
+ # Sets the integer local port used to establish the connection.
+ # - {:port}[rdoc-ref:Net::HTTP#port]:
+ # Returns the integer port number.
+ #
+ # === \HTTP Version
+ #
+ # - {::version_1_2?}[rdoc-ref:Net::HTTP.version_1_2?]
+ # (aliased as {::is_version_1_2?}[rdoc-ref:Net::HTTP.is_version_1_2?]
+ # and {::version_1_2}[rdoc-ref:Net::HTTP.version_1_2]):
+ # Returns true; retained for compatibility.
+ #
+ # === Debugging
+ #
+ # - {#set_debug_output}[rdoc-ref:Net::HTTP#set_debug_output]:
+ # Sets the output stream for debugging.
#
class HTTP < Protocol
# :stopdoc:
- VERSION = "0.3.2"
- Revision = %q$Revision$.split[1]
+ VERSION = "0.4.1"
HTTPVersion = '1.1'
begin
require 'zlib'
@@ -530,7 +893,7 @@ module Net #:nodoc:
# \HTTP session management
#
- # Returns intger +80+, the default port to use for \HTTP requests:
+ # Returns integer +80+, the default port to use for \HTTP requests:
#
# Net::HTTP.default_port # => 80
#
@@ -564,14 +927,11 @@ module Net #:nodoc:
#
# Creates a new \Net::HTTP object, +http+, via \Net::HTTP.new:
#
- # Net::HTTP.new(address, port, p_addr, p_port, p_user, p_pass)
- #
- # - For arguments +hostname+ through +p_pass+, see Net::HTTP.new.
+ # - For arguments +address+ and +port+, see Net::HTTP.new.
+ # - For proxy-defining arguments +p_addr+ through +p_pass+,
+ # see {Proxy Server}[rdoc-ref:Net::HTTP@Proxy+Server].
# - For argument +opts+, see below.
#
- # Note: If +port+ is +nil+ and <tt>opts[:use_ssl]</tt> is a truthy value,
- # the value passed to +new+ is Net::HTTP.https_default_port, not +port+.
- #
# With no block given:
#
# - Calls <tt>http.start</tt> with no block (see #start),
@@ -644,6 +1004,9 @@ module Net #:nodoc:
# - #verify_mode
# - #write_timeout
#
+ # Note: If +port+ is +nil+ and <tt>opts[:use_ssl]</tt> is a truthy value,
+ # the value passed to +new+ is Net::HTTP.https_default_port, not +port+.
+ #
def HTTP.start(address, *arg, &block) # :yield: +http+
arg.pop if opt = Hash.try_convert(arg[-1])
port, p_addr, p_port, p_user, p_pass = *arg
@@ -673,9 +1036,7 @@ module Net #:nodoc:
# Returns a new \Net::HTTP object +http+
# (but does not open a TCP connection or \HTTP session).
#
- # <b>No Proxy</b>
- #
- # With only string argument +hostname+ given
+ # With only string argument +address+ given
# (and <tt>ENV['http_proxy']</tt> undefined or +nil+),
# the returned +http+:
#
@@ -698,85 +1059,8 @@ module Net #:nodoc:
# # => #<Net::HTTP jsonplaceholder.typicode.com:8000 open=false>
# http.port # => 8000
#
- # <b>Proxy Using Argument +p_addr+ as a \String</b>
- #
- # When argument +p_addr+ is a string hostname,
- # the returned +http+ has a proxy:
- #
- # http = Net::HTTP.new(hostname, nil, 'proxy.example')
- # # => #<Net::HTTP jsonplaceholder.typicode.com:80 open=false>
- # http.proxy? # => true
- # http.proxy_address # => "proxy.example"
- # # These use default values.
- # http.proxy_port # => 80
- # http.proxy_user # => nil
- # http.proxy_pass # => nil
- #
- # The port, username, and password for the proxy may also be given:
- #
- # http = Net::HTTP.new(hostname, nil, 'proxy.example', 8000, 'pname', 'ppass')
- # # => #<Net::HTTP jsonplaceholder.typicode.com:80 open=false>
- # http.proxy? # => true
- # http.proxy_address # => "proxy.example"
- # http.proxy_port # => 8000
- # http.proxy_user # => "pname"
- # http.proxy_pass # => "ppass"
- #
- # <b>Proxy Using <tt>ENV['http_proxy']</tt></b>
- #
- # When environment variable <tt>'http_proxy'</tt>
- # is set to a \URI string,
- # the returned +http+ will have that URI as its proxy;
- # note that the \URI string must have a protocol
- # such as <tt>'http'</tt> or <tt>'https'</tt>:
- #
- # ENV['http_proxy'] = 'http://example.com'
- # # => "http://example.com"
- # http = Net::HTTP.new(hostname)
- # # => #<Net::HTTP jsonplaceholder.typicode.com:80 open=false>
- # http.proxy? # => true
- # http.address # => "jsonplaceholder.typicode.com"
- # http.proxy_address # => "example.com"
- #
- # The \URI string may include proxy username, password, and port number:
- #
- # ENV['http_proxy'] = 'http://pname:ppass@example.com:8000'
- # # => "http://pname:ppass@example.com:8000"
- # http = Net::HTTP.new(hostname)
- # # => #<Net::HTTP jsonplaceholder.typicode.com:80 open=false>
- # http.proxy_port # => 8000
- # http.proxy_user # => "pname"
- # http.proxy_pass # => "ppass"
- #
- # <b>Argument +p_no_proxy+</b>
- #
- # You can use argument +p_no_proxy+ to reject certain proxies:
- #
- # - Reject a certain address:
- #
- # http = Net::HTTP.new('example.com', nil, 'proxy.example', 8000, 'pname', 'ppass', 'proxy.example')
- # http.proxy_address # => nil
- #
- # - Reject certain domains or subdomains:
- #
- # http = Net::HTTP.new('example.com', nil, 'my.proxy.example', 8000, 'pname', 'ppass', 'proxy.example')
- # http.proxy_address # => nil
- #
- # - Reject certain addresses and port combinations:
- #
- # http = Net::HTTP.new('example.com', nil, 'proxy.example', 8000, 'pname', 'ppass', 'proxy.example:1234')
- # http.proxy_address # => "proxy.example"
- #
- # http = Net::HTTP.new('example.com', nil, 'proxy.example', 8000, 'pname', 'ppass', 'proxy.example:8000')
- # http.proxy_address # => nil
- #
- # - Reject a list of the types above delimited using a comma:
- #
- # http = Net::HTTP.new('example.com', nil, 'proxy.example', 8000, 'pname', 'ppass', 'my.proxy,proxy.example:8000')
- # http.proxy_address # => nil
- #
- # http = Net::HTTP.new('example.com', nil, 'my.proxy', 8000, 'pname', 'ppass', 'my.proxy,proxy.example:8000')
- # http.proxy_address # => nil
+ # For proxy-defining arguments +p_addr+ through +p_no_proxy+,
+ # see {Proxy Server}[rdoc-ref:Net::HTTP@Proxy+Server].
#
def HTTP.new(address, port = nil, p_addr = :ENV, p_port = nil, p_user = nil, p_pass = nil, p_no_proxy = nil)
http = super address, port
@@ -790,7 +1074,7 @@ module Net #:nodoc:
elsif p_addr == :ENV then
http.proxy_from_env = true
else
- if p_addr && p_no_proxy && !URI::Generic.use_proxy?(p_addr, p_addr, p_port, p_no_proxy)
+ if p_addr && p_no_proxy && !URI::Generic.use_proxy?(address, address, port, p_no_proxy)
p_addr = nil
p_port = nil
end
@@ -806,7 +1090,7 @@ module Net #:nodoc:
# Creates a new \Net::HTTP object for the specified server address,
# without opening the TCP connection or initializing the \HTTP session.
# The +address+ should be a DNS hostname or IP address.
- def initialize(address, port = nil)
+ def initialize(address, port = nil) # :nodoc:
@address = address
@port = (port || HTTP.default_port)
@ipaddr = nil
@@ -906,21 +1190,22 @@ module Net #:nodoc:
@debug_output = output
end
- # The DNS host name or IP address to connect to.
+ # Returns the string host name or host IP given as argument +address+ in ::new.
attr_reader :address
- # The port number to connect to.
+ # Returns the integer port number given as argument +port+ in ::new.
attr_reader :port
- # The local host used to establish the connection.
+ # Sets or returns the string local host used to establish the connection;
+ # initially +nil+.
attr_accessor :local_host
- # The local port used to establish the connection.
+ # Sets or returns the integer local port used to establish the connection;
+ # initially +nil+.
attr_accessor :local_port
- # The encoding to use for the response body. If Encoding, uses the
- # specified encoding. If other true value, tries to detect the response
- # body encoding.
+ # Returns the encoding to use for the response body;
+ # see #response_body_encoding=.
attr_reader :response_body_encoding
# Sets the encoding to be used for the response body;
@@ -946,10 +1231,25 @@ module Net #:nodoc:
@response_body_encoding = value
end
+ # Sets whether to determine the proxy from environment variable
+ # '<tt>ENV['http_proxy']</tt>';
+ # see {Proxy Using ENV['http_proxy']}[rdoc-ref:Net::HTTP@Proxy+Using+-27ENV-5B-27http_proxy-27-5D-27].
attr_writer :proxy_from_env
+
+ # Sets the proxy address;
+ # see {Proxy Server}[rdoc-ref:Net::HTTP@Proxy+Server].
attr_writer :proxy_address
+
+ # Sets the proxy port;
+ # see {Proxy Server}[rdoc-ref:Net::HTTP@Proxy+Server].
attr_writer :proxy_port
+
+ # Sets the proxy user;
+ # see {Proxy Server}[rdoc-ref:Net::HTTP@Proxy+Server].
attr_writer :proxy_user
+
+ # Sets the proxy password;
+ # see {Proxy Server}[rdoc-ref:Net::HTTP@Proxy+Server].
attr_writer :proxy_pass
# Returns the IP address for the connection.
@@ -988,23 +1288,21 @@ module Net #:nodoc:
@ipaddr = addr
end
- # Number of seconds to wait for the connection to open. Any number
- # may be used, including Floats for fractional seconds. If the \HTTP
- # object cannot open a connection in this many seconds, it raises a
- # \Net::OpenTimeout exception. The default value is 60 seconds.
+ # Sets or returns the numeric (\Integer or \Float) number of seconds
+ # to wait for a connection to open;
+ # initially 60.
+ # If the connection is not made in the given interval,
+ # an exception is raised.
attr_accessor :open_timeout
- # Number of seconds to wait for one block to be read (via one read(2)
- # call). Any number may be used, including Floats for fractional
- # seconds. If the \HTTP object cannot read data in this many seconds,
- # it raises a Net::ReadTimeout exception. The default value is 60 seconds.
+ # Returns the numeric (\Integer or \Float) number of seconds
+ # to wait for one block to be read (via one read(2) call);
+ # see #read_timeout=.
attr_reader :read_timeout
- # Number of seconds to wait for one block to be written (via one write(2)
- # call). Any number may be used, including Floats for fractional
- # seconds. If the \HTTP object cannot write data in this many seconds,
- # it raises a \Net::WriteTimeout exception. The default value is 60 seconds.
- # \Net::WriteTimeout is not raised on Windows.
+ # Returns the numeric (\Integer or \Float) number of seconds
+ # to wait for one block to be written (via one write(2) call);
+ # see #write_timeout=.
attr_reader :write_timeout
# Sets the maximum number of times to retry an idempotent request in case of
@@ -1027,6 +1325,8 @@ module Net #:nodoc:
@max_retries = retries
end
+ # Returns the maximum number of times to retry an idempotent request;
+ # see #max_retries=.
attr_reader :max_retries
# Sets the read timeout, in seconds, for +self+ to integer +sec+;
@@ -1048,52 +1348,90 @@ module Net #:nodoc:
# Sets the write timeout, in seconds, for +self+ to integer +sec+;
# the initial value is 60.
#
- # Argument +sec+ must be a non-negative numeric value.
+ # Argument +sec+ must be a non-negative numeric value:
+ #
+ # _uri = uri.dup
+ # _uri.path = '/posts'
+ # body = 'bar' * 200000
+ # data = <<EOF
+ # {"title": "foo", "body": "#{body}", "userId": "1"}
+ # EOF
+ # headers = {'content-type': 'application/json'}
+ # http = Net::HTTP.new(hostname)
+ # http.write_timeout # => 60
+ # http.post(_uri.path, data, headers)
+ # # => #<Net::HTTPCreated 201 Created readbody=true>
+ # http.write_timeout = 0
+ # http.post(_uri.path, data, headers) # Raises Net::WriteTimeout.
#
def write_timeout=(sec)
@socket.write_timeout = sec if @socket
@write_timeout = sec
end
- # Seconds to wait for 100 Continue response. If the \HTTP object does not
- # receive a response in this many seconds it sends the request body. The
- # default value is +nil+.
+ # Returns the continue timeout value;
+ # see continue_timeout=.
attr_reader :continue_timeout
- # Setter for the continue_timeout attribute.
+ # Sets the continue timeout value,
+ # which is the number of seconds to wait for an expected 100 Continue response.
+ # If the \HTTP object does not receive a response in this many seconds
+ # it sends the request body.
def continue_timeout=(sec)
@socket.continue_timeout = sec if @socket
@continue_timeout = sec
end
- # Seconds to reuse the connection of the previous request.
- # If the idle time is less than this Keep-Alive Timeout,
- # \Net::HTTP reuses the TCP/IP socket used by the previous communication.
- # The default value is 2 seconds.
+ # Sets or returns the numeric (\Integer or \Float) number of seconds
+ # to keep the connection open after a request is sent;
+ # initially 2.
+ # If a new request is made during the given interval,
+ # the still-open connection is used;
+ # otherwise the connection will have been closed
+ # and a new connection is opened.
attr_accessor :keep_alive_timeout
- # Whether to ignore EOF when reading response bodies with defined
- # Content-Length headers. For backwards compatibility, the default is true.
+ # Sets or returns whether to ignore end-of-file when reading a response body
+ # with <tt>Content-Length</tt> headers;
+ # initially +true+.
attr_accessor :ignore_eof
- # Returns true if the \HTTP session has been started.
+ # Returns +true+ if the \HTTP session has been started:
+ #
+ # http = Net::HTTP.new(hostname)
+ # http.started? # => false
+ # http.start
+ # http.started? # => true
+ # http.finish # => nil
+ # http.started? # => false
+ #
+ # Net::HTTP.start(hostname) do |http|
+ # http.started?
+ # end # => true
+ # http.started? # => false
+ #
def started?
@started
end
alias active? started? #:nodoc: obsolete
+ # Sets or returns whether to close the connection when the response is empty;
+ # initially +false+.
attr_accessor :close_on_empty_response
- # Returns true if SSL/TLS is being used with \HTTP.
+ # Returns +true+ if +self+ uses SSL, +false+ otherwise.
+ # See Net::HTTP#use_ssl=.
def use_ssl?
@use_ssl
end
- # Turn on/off SSL.
- # This flag must be set before starting session.
- # If you change use_ssl value after session started,
- # IOError is raised.
+ # Sets whether a new session is to use
+ # {Transport Layer Security}[https://en.wikipedia.org/wiki/Transport_Layer_Security]:
+ #
+ # Raises IOError if attempting to change during a session.
+ #
+ # Raises OpenSSL::SSL::SSLError if the port is not an HTTPS port.
def use_ssl=(flag)
flag = flag ? true : false
if started? and @use_ssl != flag
@@ -1118,7 +1456,7 @@ module Net #:nodoc:
:@verify_depth,
:@verify_mode,
:@verify_hostname,
- ]
+ ] # :nodoc:
SSL_ATTRIBUTES = [
:ca_file,
:ca_path,
@@ -1135,64 +1473,67 @@ module Net #:nodoc:
:verify_depth,
:verify_mode,
:verify_hostname,
- ]
+ ] # :nodoc:
- # Sets path of a CA certification file in PEM format.
- #
- # The file can contain several CA certificates.
+ # Sets or returns the path to a CA certification file in PEM format.
attr_accessor :ca_file
- # Sets path of a CA certification directory containing certifications in
- # PEM format.
+ # Sets or returns the path of to CA directory
+ # containing certification files in PEM format.
attr_accessor :ca_path
- # Sets an OpenSSL::X509::Certificate object as client certificate.
- # (This method is appeared in Michal Rokos's OpenSSL extension).
+ # Sets or returns the OpenSSL::X509::Certificate object
+ # to be used for client certification.
attr_accessor :cert
- # Sets the X509::Store to verify peer certificate.
+ # Sets or returns the X509::Store to be used for verifying peer certificate.
attr_accessor :cert_store
- # Sets the available ciphers. See OpenSSL::SSL::SSLContext#ciphers=
+ # Sets or returns the available SSL ciphers.
+ # See {OpenSSL::SSL::SSLContext#ciphers=}[rdoc-ref:OpenSSL::SSL::SSLContext#ciphers-3D].
attr_accessor :ciphers
- # Sets the extra X509 certificates to be added to the certificate chain.
- # See OpenSSL::SSL::SSLContext#extra_chain_cert=
+ # Sets or returns the extra X509 certificates to be added to the certificate chain.
+ # See {OpenSSL::SSL::SSLContext#add_certificate}[rdoc-ref:OpenSSL::SSL::SSLContext#add_certificate].
attr_accessor :extra_chain_cert
- # Sets an OpenSSL::PKey::RSA or OpenSSL::PKey::DSA object.
- # (This method is appeared in Michal Rokos's OpenSSL extension.)
+ # Sets or returns the OpenSSL::PKey::RSA or OpenSSL::PKey::DSA object.
attr_accessor :key
- # Sets the SSL timeout seconds.
+ # Sets or returns the SSL timeout seconds.
attr_accessor :ssl_timeout
- # Sets the SSL version. See OpenSSL::SSL::SSLContext#ssl_version=
+ # Sets or returns the SSL version.
+ # See {OpenSSL::SSL::SSLContext#ssl_version=}[rdoc-ref:OpenSSL::SSL::SSLContext#ssl_version-3D].
attr_accessor :ssl_version
- # Sets the minimum SSL version. See OpenSSL::SSL::SSLContext#min_version=
+ # Sets or returns the minimum SSL version.
+ # See {OpenSSL::SSL::SSLContext#min_version=}[rdoc-ref:OpenSSL::SSL::SSLContext#min_version-3D].
attr_accessor :min_version
- # Sets the maximum SSL version. See OpenSSL::SSL::SSLContext#max_version=
+ # Sets or returns the maximum SSL version.
+ # See {OpenSSL::SSL::SSLContext#max_version=}[rdoc-ref:OpenSSL::SSL::SSLContext#max_version-3D].
attr_accessor :max_version
- # Sets the verify callback for the server certification verification.
+ # Sets or returns the callback for the server certification verification.
attr_accessor :verify_callback
- # Sets the maximum depth for the certificate chain verification.
+ # Sets or returns the maximum depth for the certificate chain verification.
attr_accessor :verify_depth
- # Sets the flags for server the certification verification at beginning of
- # SSL/TLS session.
- #
+ # Sets or returns the flags for server the certification verification
+ # at the beginning of the SSL/TLS session.
# OpenSSL::SSL::VERIFY_NONE or OpenSSL::SSL::VERIFY_PEER are acceptable.
attr_accessor :verify_mode
- # Sets to check the server certificate is valid for the hostname.
- # See OpenSSL::SSL::SSLContext#verify_hostname=
+ # Sets or returns whether to verify that the server certificate is valid
+ # for the hostname.
+ # See {OpenSSL::SSL::SSLContext#verify_hostname=}[rdoc-ref:OpenSSL::SSL::SSLContext#attribute-i-verify_mode].
attr_accessor :verify_hostname
- # Returns the X.509 certificates the server presented.
+ # Returns the X509 certificate chain (an array of strings)
+ # for the session's socket peer,
+ # or +nil+ if none.
def peer_cert
if not use_ssl? or not @socket
return nil
@@ -1200,14 +1541,26 @@ module Net #:nodoc:
@socket.io.peer_cert
end
- # Opens a TCP connection and \HTTP session.
+ # Starts an \HTTP session.
+ #
+ # Without a block, returns +self+:
#
- # When this method is called with a block, it passes the \Net::HTTP
- # object to the block, and closes the TCP connection and \HTTP session
- # after the block has been executed.
+ # http = Net::HTTP.new(hostname)
+ # # => #<Net::HTTP jsonplaceholder.typicode.com:80 open=false>
+ # http.start
+ # # => #<Net::HTTP jsonplaceholder.typicode.com:80 open=true>
+ # http.started? # => true
+ # http.finish
#
- # When called with a block, it returns the return value of the
- # block; otherwise, it returns self.
+ # With a block, calls the block with +self+,
+ # finishes the session when the block exits,
+ # and returns the block's value:
+ #
+ # http.start do |http|
+ # http
+ # end
+ # # => #<Net::HTTP jsonplaceholder.typicode.com:80 open=false>
+ # http.started? # => false
#
def start # :yield: http
raise IOError, 'HTTP session already opened' if @started
@@ -1261,8 +1614,8 @@ module Net #:nodoc:
write_timeout: @write_timeout,
continue_timeout: @continue_timeout,
debug_output: @debug_output)
- buf = "CONNECT #{conn_address}:#{@port} HTTP/#{HTTPVersion}\r\n"
- buf << "Host: #{@address}:#{@port}\r\n"
+ buf = +"CONNECT #{conn_address}:#{@port} HTTP/#{HTTPVersion}\r\n" \
+ "Host: #{@address}:#{@port}\r\n"
if proxy_user
credential = ["#{proxy_user}:#{proxy_pass}"].pack('m0')
buf << "Proxy-Authorization: Basic #{credential}\r\n"
@@ -1343,8 +1696,15 @@ module Net #:nodoc:
end
private :on_connect
- # Finishes the \HTTP session and closes the TCP connection.
- # Raises IOError if the session has not been started.
+ # Finishes the \HTTP session:
+ #
+ # http = Net::HTTP.new(hostname)
+ # http.start
+ # http.started? # => true
+ # http.finish # => nil
+ # http.started? # => false
+ #
+ # Raises IOError if not in a session.
def finish
raise IOError, 'HTTP session not yet started' unless started?
do_finish
@@ -1398,31 +1758,37 @@ module Net #:nodoc:
end
class << HTTP
- # returns true if self is a class which was created by HTTP::Proxy.
+ # Returns true if self is a class which was created by HTTP::Proxy.
def proxy_class?
defined?(@is_proxy_class) ? @is_proxy_class : false
end
- # Address of proxy host. If \Net::HTTP does not use a proxy, nil.
+ # Returns the address of the proxy host, or +nil+ if none;
+ # see Net::HTTP@Proxy+Server.
attr_reader :proxy_address
- # Port number of proxy host. If \Net::HTTP does not use a proxy, nil.
+ # Returns the port number of the proxy host, or +nil+ if none;
+ # see Net::HTTP@Proxy+Server.
attr_reader :proxy_port
- # User name for accessing proxy. If \Net::HTTP does not use a proxy, nil.
+ # Returns the user name for accessing the proxy, or +nil+ if none;
+ # see Net::HTTP@Proxy+Server.
attr_reader :proxy_user
- # User password for accessing proxy. \If Net::HTTP does not use a proxy,
- # nil.
+ # Returns the password for accessing the proxy, or +nil+ if none;
+ # see Net::HTTP@Proxy+Server.
attr_reader :proxy_pass
end
- # True if requests for this connection will be proxied
+ # Returns +true+ if a proxy server is defined, +false+ otherwise;
+ # see {Proxy Server}[rdoc-ref:Net::HTTP@Proxy+Server].
def proxy?
!!(@proxy_from_env ? proxy_uri : @proxy_address)
end
- # True if the proxy for this connection is determined from the environment
+ # Returns +true+ if the proxy server is defined in the environment,
+ # +false+ otherwise;
+ # see {Proxy Server}[rdoc-ref:Net::HTTP@Proxy+Server].
def proxy_from_env?
@proxy_from_env
end
@@ -1431,12 +1797,13 @@ module Net #:nodoc:
def proxy_uri # :nodoc:
return if @proxy_uri == false
@proxy_uri ||= URI::HTTP.new(
- "http".freeze, nil, address, port, nil, nil, nil, nil, nil
+ "http", nil, address, port, nil, nil, nil, nil, nil
).find_proxy || false
@proxy_uri || nil
end
- # The address of the proxy server, if one is configured.
+ # Returns the address of the proxy server, if defined, +nil+ otherwise;
+ # see {Proxy Server}[rdoc-ref:Net::HTTP@Proxy+Server].
def proxy_address
if @proxy_from_env then
proxy_uri&.hostname
@@ -1445,7 +1812,8 @@ module Net #:nodoc:
end
end
- # The port of the proxy server, if one is configured.
+ # Returns the port number of the proxy server, if defined, +nil+ otherwise;
+ # see {Proxy Server}[rdoc-ref:Net::HTTP@Proxy+Server].
def proxy_port
if @proxy_from_env then
proxy_uri&.port
@@ -1454,7 +1822,8 @@ module Net #:nodoc:
end
end
- # The username of the proxy server, if one is configured.
+ # Returns the user name of the proxy server, if defined, +nil+ otherwise;
+ # see {Proxy Server}[rdoc-ref:Net::HTTP@Proxy+Server].
def proxy_user
if @proxy_from_env
user = proxy_uri&.user
@@ -1464,7 +1833,8 @@ module Net #:nodoc:
end
end
- # The password of the proxy server, if one is configured.
+ # Returns the password of the proxy server, if defined, +nil+ otherwise;
+ # see {Proxy Server}[rdoc-ref:Net::HTTP@Proxy+Server].
def proxy_pass
if @proxy_from_env
pass = proxy_uri&.password
@@ -1512,45 +1882,38 @@ module Net #:nodoc:
public
- # Retrieves data from +path+ on the connected-to host which may be an
- # absolute path String or a URI to extract the path from.
+ # :call-seq:
+ # get(path, initheader = nil) {|res| ... }
+ #
+ # Sends a GET request to the server;
+ # returns an instance of a subclass of Net::HTTPResponse.
+ #
+ # The request is based on the Net::HTTP::Get object
+ # created from string +path+ and initial headers hash +initheader+.
#
- # +initheader+ must be a Hash like { 'Accept' => '*/*', ... },
- # and it defaults to an empty hash.
- # If +initheader+ doesn't have the key 'accept-encoding', then
- # a value of "gzip;q=1.0,deflate;q=0.6,identity;q=0.3" is used,
- # so that gzip compression is used in preference to deflate
- # compression, which is used in preference to no compression.
- # Ruby doesn't have libraries to support the compress (Lempel-Ziv)
- # compression, so that is not supported. The intent of this is
- # to reduce bandwidth by default. If this routine sets up
- # compression, then it does the decompression also, removing
- # the header as well to prevent confusion. Otherwise
- # it leaves the body as it found it.
+ # With a block given, calls the block with the response body:
#
- # This method returns a Net::HTTPResponse object.
+ # http = Net::HTTP.new(hostname)
+ # http.get('/todos/1') do |res|
+ # p res
+ # end # => #<Net::HTTPOK 200 OK readbody=true>
#
- # If called with a block, yields each fragment of the
- # entity body in turn as a string as it is read from
- # the socket. Note that in this case, the returned response
- # object will *not* contain a (meaningful) body.
+ # Output:
#
- # +dest+ argument is obsolete.
- # It still works but you must not use it.
+ # "{\n \"userId\": 1,\n \"id\": 1,\n \"title\": \"delectus aut autem\",\n \"completed\": false\n}"
#
- # This method never raises an exception.
+ # With no block given, simply returns the response object:
#
- # response = http.get('/index.html')
+ # http.get('/') # => #<Net::HTTPOK 200 OK readbody=true>
#
- # # using block
- # File.open('result.txt', 'w') {|f|
- # http.get('/~foo/') do |str|
- # f.write str
- # end
- # }
+ # Related:
+ #
+ # - Net::HTTP::Get: request class for \HTTP method GET.
+ # - Net::HTTP.get: sends GET request, returns response body.
#
def get(path, initheader = nil, dest = nil, &block) # :yield: +body_segment+
res = nil
+
request(Get.new(path, initheader)) {|r|
r.read_body dest, &block
res = r
@@ -1558,198 +1921,312 @@ module Net #:nodoc:
res
end
- # Gets only the header from +path+ on the connected-to host.
- # +header+ is a Hash like { 'Accept' => '*/*', ... }.
+ # Sends a HEAD request to the server;
+ # returns an instance of a subclass of Net::HTTPResponse.
#
- # This method returns a Net::HTTPResponse object.
+ # The request is based on the Net::HTTP::Head object
+ # created from string +path+ and initial headers hash +initheader+:
#
- # This method never raises an exception.
- #
- # response = nil
- # Net::HTTP.start('some.www.server', 80) {|http|
- # response = http.head('/index.html')
- # }
- # p response['content-type']
+ # res = http.head('/todos/1') # => #<Net::HTTPOK 200 OK readbody=true>
+ # res.body # => nil
+ # res.to_hash.take(3)
+ # # =>
+ # [["date", ["Wed, 15 Feb 2023 15:25:42 GMT"]],
+ # ["content-type", ["application/json; charset=utf-8"]],
+ # ["connection", ["close"]]]
#
def head(path, initheader = nil)
request(Head.new(path, initheader))
end
- # Posts +data+ (must be a String) to +path+. +header+ must be a Hash
- # like { 'Accept' => '*/*', ... }.
+ # :call-seq:
+ # post(path, data, initheader = nil) {|res| ... }
+ #
+ # Sends a POST request to the server;
+ # returns an instance of a subclass of Net::HTTPResponse.
#
- # This method returns a Net::HTTPResponse object.
+ # The request is based on the Net::HTTP::Post object
+ # created from string +path+, string +data+, and initial headers hash +initheader+.
#
- # If called with a block, yields each fragment of the
- # entity body in turn as a string as it is read from
- # the socket. Note that in this case, the returned response
- # object will *not* contain a (meaningful) body.
+ # With a block given, calls the block with the response body:
#
- # +dest+ argument is obsolete.
- # It still works but you must not use it.
+ # data = '{"userId": 1, "id": 1, "title": "delectus aut autem", "completed": false}'
+ # http = Net::HTTP.new(hostname)
+ # http.post('/todos', data) do |res|
+ # p res
+ # end # => #<Net::HTTPCreated 201 Created readbody=true>
#
- # This method never raises exception.
+ # Output:
#
- # response = http.post('/cgi-bin/search.rb', 'query=foo')
+ # "{\n \"{\\\"userId\\\": 1, \\\"id\\\": 1, \\\"title\\\": \\\"delectus aut autem\\\", \\\"completed\\\": false}\": \"\",\n \"id\": 201\n}"
#
- # # using block
- # File.open('result.txt', 'w') {|f|
- # http.post('/cgi-bin/search.rb', 'query=foo') do |str|
- # f.write str
- # end
- # }
+ # With no block given, simply returns the response object:
#
- # You should set Content-Type: header field for POST.
- # If no Content-Type: field given, this method uses
- # "application/x-www-form-urlencoded" by default.
+ # http.post('/todos', data) # => #<Net::HTTPCreated 201 Created readbody=true>
+ #
+ # Related:
+ #
+ # - Net::HTTP::Post: request class for \HTTP method POST.
+ # - Net::HTTP.post: sends POST request, returns response body.
#
def post(path, data, initheader = nil, dest = nil, &block) # :yield: +body_segment+
send_entity(path, data, initheader, dest, Post, &block)
end
- # Sends a PATCH request to the +path+ and gets a response,
- # as an HTTPResponse object.
+ # :call-seq:
+ # patch(path, data, initheader = nil) {|res| ... }
+ #
+ # Sends a PATCH request to the server;
+ # returns an instance of a subclass of Net::HTTPResponse.
+ #
+ # The request is based on the Net::HTTP::Patch object
+ # created from string +path+, string +data+, and initial headers hash +initheader+.
+ #
+ # With a block given, calls the block with the response body:
+ #
+ # data = '{"userId": 1, "id": 1, "title": "delectus aut autem", "completed": false}'
+ # http = Net::HTTP.new(hostname)
+ # http.patch('/todos/1', data) do |res|
+ # p res
+ # end # => #<Net::HTTPOK 200 OK readbody=true>
+ #
+ # Output:
+ #
+ # "{\n \"userId\": 1,\n \"id\": 1,\n \"title\": \"delectus aut autem\",\n \"completed\": false,\n \"{\\\"userId\\\": 1, \\\"id\\\": 1, \\\"title\\\": \\\"delectus aut autem\\\", \\\"completed\\\": false}\": \"\"\n}"
+ #
+ # With no block given, simply returns the response object:
+ #
+ # http.patch('/todos/1', data) # => #<Net::HTTPCreated 201 Created readbody=true>
+ #
def patch(path, data, initheader = nil, dest = nil, &block) # :yield: +body_segment+
send_entity(path, data, initheader, dest, Patch, &block)
end
- def put(path, data, initheader = nil) #:nodoc:
+ # Sends a PUT request to the server;
+ # returns an instance of a subclass of Net::HTTPResponse.
+ #
+ # The request is based on the Net::HTTP::Put object
+ # created from string +path+, string +data+, and initial headers hash +initheader+.
+ #
+ # data = '{"userId": 1, "id": 1, "title": "delectus aut autem", "completed": false}'
+ # http = Net::HTTP.new(hostname)
+ # http.put('/todos/1', data) # => #<Net::HTTPOK 200 OK readbody=true>
+ #
+ def put(path, data, initheader = nil)
request(Put.new(path, initheader), data)
end
- # Sends a PROPPATCH request to the +path+ and gets a response,
- # as an HTTPResponse object.
+ # Sends a PROPPATCH request to the server;
+ # returns an instance of a subclass of Net::HTTPResponse.
+ #
+ # The request is based on the Net::HTTP::Proppatch object
+ # created from string +path+, string +body+, and initial headers hash +initheader+.
+ #
+ # data = '{"userId": 1, "id": 1, "title": "delectus aut autem", "completed": false}'
+ # http = Net::HTTP.new(hostname)
+ # http.proppatch('/todos/1', data)
+ #
def proppatch(path, body, initheader = nil)
request(Proppatch.new(path, initheader), body)
end
- # Sends a LOCK request to the +path+ and gets a response,
- # as an HTTPResponse object.
+ # Sends a LOCK request to the server;
+ # returns an instance of a subclass of Net::HTTPResponse.
+ #
+ # The request is based on the Net::HTTP::Lock object
+ # created from string +path+, string +body+, and initial headers hash +initheader+.
+ #
+ # data = '{"userId": 1, "id": 1, "title": "delectus aut autem", "completed": false}'
+ # http = Net::HTTP.new(hostname)
+ # http.lock('/todos/1', data)
+ #
def lock(path, body, initheader = nil)
request(Lock.new(path, initheader), body)
end
- # Sends a UNLOCK request to the +path+ and gets a response,
- # as an HTTPResponse object.
+ # Sends an UNLOCK request to the server;
+ # returns an instance of a subclass of Net::HTTPResponse.
+ #
+ # The request is based on the Net::HTTP::Unlock object
+ # created from string +path+, string +body+, and initial headers hash +initheader+.
+ #
+ # data = '{"userId": 1, "id": 1, "title": "delectus aut autem", "completed": false}'
+ # http = Net::HTTP.new(hostname)
+ # http.unlock('/todos/1', data)
+ #
def unlock(path, body, initheader = nil)
request(Unlock.new(path, initheader), body)
end
- # Sends a OPTIONS request to the +path+ and gets a response,
- # as an HTTPResponse object.
+ # Sends an Options request to the server;
+ # returns an instance of a subclass of Net::HTTPResponse.
+ #
+ # The request is based on the Net::HTTP::Options object
+ # created from string +path+ and initial headers hash +initheader+.
+ #
+ # http = Net::HTTP.new(hostname)
+ # http.options('/')
+ #
def options(path, initheader = nil)
request(Options.new(path, initheader))
end
- # Sends a PROPFIND request to the +path+ and gets a response,
- # as an HTTPResponse object.
+ # Sends a PROPFIND request to the server;
+ # returns an instance of a subclass of Net::HTTPResponse.
+ #
+ # The request is based on the Net::HTTP::Propfind object
+ # created from string +path+, string +body+, and initial headers hash +initheader+.
+ #
+ # data = '{"userId": 1, "id": 1, "title": "delectus aut autem", "completed": false}'
+ # http = Net::HTTP.new(hostname)
+ # http.propfind('/todos/1', data)
+ #
def propfind(path, body = nil, initheader = {'Depth' => '0'})
request(Propfind.new(path, initheader), body)
end
- # Sends a DELETE request to the +path+ and gets a response,
- # as an HTTPResponse object.
+ # Sends a DELETE request to the server;
+ # returns an instance of a subclass of Net::HTTPResponse.
+ #
+ # The request is based on the Net::HTTP::Delete object
+ # created from string +path+ and initial headers hash +initheader+.
+ #
+ # http = Net::HTTP.new(hostname)
+ # http.delete('/todos/1')
+ #
def delete(path, initheader = {'Depth' => 'Infinity'})
request(Delete.new(path, initheader))
end
- # Sends a MOVE request to the +path+ and gets a response,
- # as an HTTPResponse object.
+ # Sends a MOVE request to the server;
+ # returns an instance of a subclass of Net::HTTPResponse.
+ #
+ # The request is based on the Net::HTTP::Move object
+ # created from string +path+ and initial headers hash +initheader+.
+ #
+ # http = Net::HTTP.new(hostname)
+ # http.move('/todos/1')
+ #
def move(path, initheader = nil)
request(Move.new(path, initheader))
end
- # Sends a COPY request to the +path+ and gets a response,
- # as an HTTPResponse object.
+ # Sends a COPY request to the server;
+ # returns an instance of a subclass of Net::HTTPResponse.
+ #
+ # The request is based on the Net::HTTP::Copy object
+ # created from string +path+ and initial headers hash +initheader+.
+ #
+ # http = Net::HTTP.new(hostname)
+ # http.copy('/todos/1')
+ #
def copy(path, initheader = nil)
request(Copy.new(path, initheader))
end
- # Sends a MKCOL request to the +path+ and gets a response,
- # as an HTTPResponse object.
+ # Sends a MKCOL request to the server;
+ # returns an instance of a subclass of Net::HTTPResponse.
+ #
+ # The request is based on the Net::HTTP::Mkcol object
+ # created from string +path+, string +body+, and initial headers hash +initheader+.
+ #
+ # data = '{"userId": 1, "id": 1, "title": "delectus aut autem", "completed": false}'
+ # http.mkcol('/todos/1', data)
+ # http = Net::HTTP.new(hostname)
+ #
def mkcol(path, body = nil, initheader = nil)
request(Mkcol.new(path, initheader), body)
end
- # Sends a TRACE request to the +path+ and gets a response,
- # as an HTTPResponse object.
+ # Sends a TRACE request to the server;
+ # returns an instance of a subclass of Net::HTTPResponse.
+ #
+ # The request is based on the Net::HTTP::Trace object
+ # created from string +path+ and initial headers hash +initheader+.
+ #
+ # http = Net::HTTP.new(hostname)
+ # http.trace('/todos/1')
+ #
def trace(path, initheader = nil)
request(Trace.new(path, initheader))
end
- # Sends a GET request to the +path+.
- # Returns the response as a Net::HTTPResponse object.
+ # Sends a GET request to the server;
+ # forms the response into a Net::HTTPResponse object.
#
- # When called with a block, passes an HTTPResponse object to the block.
- # The body of the response will not have been read yet;
- # the block can process it using HTTPResponse#read_body,
- # if desired.
+ # The request is based on the Net::HTTP::Get object
+ # created from string +path+ and initial headers hash +initheader+.
#
- # Returns the response.
+ # With no block given, returns the response object:
#
- # This method never raises Net::* exceptions.
+ # http = Net::HTTP.new(hostname)
+ # http.request_get('/todos') # => #<Net::HTTPOK 200 OK readbody=true>
#
- # response = http.request_get('/index.html')
- # # The entity body is already read in this case.
- # p response['content-type']
- # puts response.body
+ # With a block given, calls the block with the response object
+ # and returns the response object:
#
- # # Using a block
- # http.request_get('/index.html') {|response|
- # p response['content-type']
- # response.read_body do |str| # read body now
- # print str
- # end
- # }
+ # http.request_get('/todos') do |res|
+ # p res
+ # end # => #<Net::HTTPOK 200 OK readbody=true>
+ #
+ # Output:
+ #
+ # #<Net::HTTPOK 200 OK readbody=false>
#
def request_get(path, initheader = nil, &block) # :yield: +response+
request(Get.new(path, initheader), &block)
end
- # Sends a HEAD request to the +path+ and returns the response
- # as a Net::HTTPResponse object.
- #
- # Returns the response.
+ # Sends a HEAD request to the server;
+ # returns an instance of a subclass of Net::HTTPResponse.
#
- # This method never raises Net::* exceptions.
+ # The request is based on the Net::HTTP::Head object
+ # created from string +path+ and initial headers hash +initheader+.
#
- # response = http.request_head('/index.html')
- # p response['content-type']
+ # http = Net::HTTP.new(hostname)
+ # http.head('/todos/1') # => #<Net::HTTPOK 200 OK readbody=true>
#
def request_head(path, initheader = nil, &block)
request(Head.new(path, initheader), &block)
end
- # Sends a POST request to the +path+.
+ # Sends a POST request to the server;
+ # forms the response into a Net::HTTPResponse object.
#
- # Returns the response as a Net::HTTPResponse object.
+ # The request is based on the Net::HTTP::Post object
+ # created from string +path+, string +data+, and initial headers hash +initheader+.
#
- # When called with a block, the block is passed an HTTPResponse
- # object. The body of that response will not have been read yet;
- # the block can process it using HTTPResponse#read_body, if desired.
+ # With no block given, returns the response object:
#
- # Returns the response.
+ # http = Net::HTTP.new(hostname)
+ # http.post('/todos', 'xyzzy')
+ # # => #<Net::HTTPCreated 201 Created readbody=true>
#
- # This method never raises Net::* exceptions.
+ # With a block given, calls the block with the response body
+ # and returns the response object:
#
- # # example
- # response = http.request_post('/cgi-bin/nice.rb', 'datadatadata...')
- # p response.status
- # puts response.body # body is already read in this case
+ # http.post('/todos', 'xyzzy') do |res|
+ # p res
+ # end # => #<Net::HTTPCreated 201 Created readbody=true>
#
- # # using block
- # http.request_post('/cgi-bin/nice.rb', 'datadatadata...') {|response|
- # p response.status
- # p response['content-type']
- # response.read_body do |str| # read body now
- # print str
- # end
- # }
+ # Output:
+ #
+ # "{\n \"xyzzy\": \"\",\n \"id\": 201\n}"
#
def request_post(path, data, initheader = nil, &block) # :yield: +response+
request Post.new(path, initheader), data, &block
end
+ # Sends a PUT request to the server;
+ # returns an instance of a subclass of Net::HTTPResponse.
+ #
+ # The request is based on the Net::HTTP::Put object
+ # created from string +path+, string +data+, and initial headers hash +initheader+.
+ #
+ # http = Net::HTTP.new(hostname)
+ # http.put('/todos/1', 'xyzzy')
+ # # => #<Net::HTTPOK 200 OK readbody=true>
+ #
def request_put(path, data, initheader = nil, &block) #:nodoc:
request Put.new(path, initheader), data, &block
end
@@ -1759,16 +2236,25 @@ module Net #:nodoc:
alias post2 request_post #:nodoc: obsolete
alias put2 request_put #:nodoc: obsolete
-
- # Sends an \HTTP request to the \HTTP server.
- # Also sends a DATA string if +data+ is given.
+ # Sends an \HTTP request to the server;
+ # returns an instance of a subclass of Net::HTTPResponse.
#
- # Returns a Net::HTTPResponse object.
+ # The request is based on the Net::HTTPRequest object
+ # created from string +path+, string +data+, and initial headers hash +header+.
+ # That object is an instance of the
+ # {subclass of Net::HTTPRequest}[rdoc-ref:Net::HTTPRequest@Request+Subclasses],
+ # that corresponds to the given uppercase string +name+,
+ # which must be
+ # an {HTTP request method}[https://en.wikipedia.org/wiki/HTTP#Request_methods]
+ # or a {WebDAV request method}[https://en.wikipedia.org/wiki/WebDAV#Implementation].
#
- # This method never raises Net::* exceptions.
+ # Examples:
#
- # response = http.send_request('GET', '/index.html')
- # puts response.body
+ # http = Net::HTTP.new(hostname)
+ # http.send_request('GET', '/todos/1')
+ # # => #<Net::HTTPOK 200 OK readbody=true>
+ # http.send_request('POST', '/todos', 'xyzzy')
+ # # => #<Net::HTTPCreated 201 Created readbody=true>
#
def send_request(name, path, data = nil, header = nil)
has_response_body = name != 'HEAD'
@@ -1776,20 +2262,35 @@ module Net #:nodoc:
request r, data
end
- # Sends an HTTPRequest object +req+ to the \HTTP server.
+ # Sends the given request +req+ to the server;
+ # forms the response into a Net::HTTPResponse object.
+ #
+ # The given +req+ must be an instance of a
+ # {subclass of Net::HTTPRequest}[rdoc-ref:Net::HTTPRequest@Request+Subclasses].
+ # Argument +body+ should be given only if needed for the request.
+ #
+ # With no block given, returns the response object:
#
- # If +req+ is a Net::HTTP::Post or Net::HTTP::Put request containing
- # data, the data is also sent. Providing data for a Net::HTTP::Head or
- # \Net::HTTP::Get request results in an ArgumentError.
+ # http = Net::HTTP.new(hostname)
+ #
+ # req = Net::HTTP::Get.new('/todos/1')
+ # http.request(req)
+ # # => #<Net::HTTPOK 200 OK readbody=true>
+ #
+ # req = Net::HTTP::Post.new('/todos')
+ # http.request(req, 'xyzzy')
+ # # => #<Net::HTTPCreated 201 Created readbody=true>
#
- # Returns an HTTPResponse object.
+ # With a block given, calls the block with the response and returns the response:
#
- # When called with a block, passes an HTTPResponse object to the block.
- # The body of the response will not have been read yet;
- # the block can process it using HTTPResponse#read_body,
- # if desired.
+ # req = Net::HTTP::Get.new('/todos/1')
+ # http.request(req) do |res|
+ # p res
+ # end # => #<Net::HTTPOK 200 OK readbody=true>
+ #
+ # Output:
#
- # This method never raises Net::* exceptions.
+ # #<Net::HTTPOK 200 OK readbody=false>
#
def request(req, body = nil, &block) # :yield: +response+
unless started?
diff --git a/lib/net/http/backward.rb b/lib/net/http/backward.rb
index 691e41e4f1..b44577edbd 100644
--- a/lib/net/http/backward.rb
+++ b/lib/net/http/backward.rb
@@ -1,4 +1,4 @@
-# frozen_string_literal: false
+# frozen_string_literal: true
# for backward compatibility
# :enddoc:
diff --git a/lib/net/http/exceptions.rb b/lib/net/http/exceptions.rb
index 9c425cae16..ceec8f7b0a 100644
--- a/lib/net/http/exceptions.rb
+++ b/lib/net/http/exceptions.rb
@@ -1,4 +1,4 @@
-# frozen_string_literal: false
+# frozen_string_literal: true
module Net
# Net::HTTP exception class.
# You cannot use Net::HTTPExceptions directly; instead, you must use
diff --git a/lib/net/http/generic_request.rb b/lib/net/http/generic_request.rb
index 8877cd04ae..44e329a0c8 100644
--- a/lib/net/http/generic_request.rb
+++ b/lib/net/http/generic_request.rb
@@ -1,4 +1,4 @@
-# frozen_string_literal: false
+# frozen_string_literal: true
#
# \HTTPGenericRequest is the parent of the Net::HTTPRequest class.
#
@@ -23,7 +23,7 @@ class Net::HTTPGenericRequest
raise ArgumentError, "no host component for URI" unless (hostname && hostname.length > 0)
@uri = uri_or_path.dup
host = @uri.hostname.dup
- host << ":".freeze << @uri.port.to_s if @uri.port != @uri.default_port
+ host << ":" << @uri.port.to_s if @uri.port != @uri.default_port
@path = uri_or_path.request_uri
raise ArgumentError, "no HTTP request path given" unless @path
else
@@ -212,15 +212,15 @@ class Net::HTTPGenericRequest
return unless @uri
if ssl
- scheme = 'https'.freeze
+ scheme = 'https'
klass = URI::HTTPS
else
- scheme = 'http'.freeze
+ scheme = 'http'
klass = URI::HTTP
end
if host = self['host']
- host.sub!(/:.*/m, ''.freeze)
+ host.sub!(/:.*/m, '')
elsif host = @uri.host
else
host = addr
@@ -316,7 +316,7 @@ class Net::HTTPGenericRequest
boundary ||= SecureRandom.urlsafe_base64(40)
chunked_p = chunked?
- buf = ''
+ buf = +''
params.each do |key, value, h={}|
key = quote_string(key, charset)
filename =
@@ -401,7 +401,7 @@ class Net::HTTPGenericRequest
if /[\r\n]/ =~ reqline
raise ArgumentError, "A Request-Line must not contain CR or LF"
end
- buf = ""
+ buf = +''
buf << reqline << "\r\n"
each_capitalized do |k,v|
buf << "#{k}: #{v}\r\n"
diff --git a/lib/net/http/header.rb b/lib/net/http/header.rb
index 1425b6b329..6660c8075a 100644
--- a/lib/net/http/header.rb
+++ b/lib/net/http/header.rb
@@ -1,4 +1,4 @@
-# frozen_string_literal: false
+# frozen_string_literal: true
#
# The \HTTPHeader module provides access to \HTTP headers.
#
@@ -179,6 +179,8 @@
# - #each_value: Passes each string field value to the block.
#
module Net::HTTPHeader
+ MAX_KEY_LENGTH = 1024
+ MAX_FIELD_LENGTH = 65536
def initialize_http_header(initheader) #:nodoc:
@header = {}
@@ -189,6 +191,12 @@ module Net::HTTPHeader
warn "net/http: nil HTTP header: #{key}", uplevel: 3 if $VERBOSE
else
value = value.strip # raise error for invalid byte sequences
+ if key.to_s.bytesize > MAX_KEY_LENGTH
+ raise ArgumentError, "too long (#{key.bytesize} bytes) header: #{key[0, 30].inspect}..."
+ end
+ if value.to_s.bytesize > MAX_FIELD_LENGTH
+ raise ArgumentError, "header #{key} has too long field value: #{value.bytesize}"
+ end
if value.count("\r\n") > 0
raise ArgumentError, "header #{key} has field value #{value.inspect}, this cannot include CR/LF"
end
@@ -691,10 +699,14 @@ module Net::HTTPHeader
# res.content_type # => "application/json"
#
def content_type
- return nil unless main_type()
- if sub_type()
- then "#{main_type()}/#{sub_type()}"
- else main_type()
+ main = main_type()
+ return nil unless main
+
+ sub = sub_type()
+ if sub
+ "#{main}/#{sub}"
+ else
+ main
end
end
diff --git a/lib/net/http/net-http.gemspec b/lib/net/http/net-http.gemspec
index a7f122fc0e..0021136793 100644
--- a/lib/net/http/net-http.gemspec
+++ b/lib/net/http/net-http.gemspec
@@ -2,9 +2,14 @@
name = File.basename(__FILE__, ".gemspec")
version = ["lib", Array.new(name.count("-")+1, "..").join("/")].find do |dir|
- break File.foreach(File.join(__dir__, dir, "#{name.tr('-', '/')}.rb")) do |line|
- /^\s*VERSION\s*=\s*"(.*)"/ =~ line and break $1
- end rescue nil
+ file = File.join(__dir__, dir, "#{name.tr('-', '/')}.rb")
+ begin
+ break File.foreach(file, mode: "rb") do |line|
+ /^\s*VERSION\s*=\s*"(.*)"/ =~ line and break $1
+ end
+ rescue SystemCallError
+ next
+ end
end
Gem::Specification.new do |spec|
@@ -25,7 +30,7 @@ Gem::Specification.new do |spec|
# Specify which files should be added to the gem when it is released.
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
- `git ls-files -z 2>/dev/null`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
+ `git ls-files -z 2>#{IO::NULL}`.split("\x0").reject { |f| f.match(%r{\A(?:(?:test|spec|features)/|\.git)}) }
end
spec.bindir = "exe"
spec.require_paths = ["lib"]
diff --git a/lib/net/http/proxy_delta.rb b/lib/net/http/proxy_delta.rb
index a2f770ebdb..e7d30def64 100644
--- a/lib/net/http/proxy_delta.rb
+++ b/lib/net/http/proxy_delta.rb
@@ -1,4 +1,4 @@
-# frozen_string_literal: false
+# frozen_string_literal: true
module Net::HTTP::ProxyDelta #:nodoc: internal use only
private
diff --git a/lib/net/http/request.rb b/lib/net/http/request.rb
index f3d32edb62..4a138572e9 100644
--- a/lib/net/http/request.rb
+++ b/lib/net/http/request.rb
@@ -1,10 +1,55 @@
-# frozen_string_literal: false
+# frozen_string_literal: true
-# This class is the base class for \Net::HTTP request classes;
-# it wraps together the request path and the request headers.
-#
+# This class is the base class for \Net::HTTP request classes.
# The class should not be used directly;
-# instead you should use its subclasses.
+# instead you should use its subclasses, listed below.
+#
+# == Creating a Request
+#
+# An request object may be created with either a URI or a string hostname:
+#
+# require 'net/http'
+# uri = URI('https://jsonplaceholder.typicode.com/')
+# req = Net::HTTP::Get.new(uri) # => #<Net::HTTP::Get GET>
+# req = Net::HTTP::Get.new(uri.hostname) # => #<Net::HTTP::Get GET>
+#
+# And with any of the subclasses:
+#
+# req = Net::HTTP::Head.new(uri) # => #<Net::HTTP::Head HEAD>
+# req = Net::HTTP::Post.new(uri) # => #<Net::HTTP::Post POST>
+# req = Net::HTTP::Put.new(uri) # => #<Net::HTTP::Put PUT>
+# # ...
+#
+# The new instance is suitable for use as the argument to Net::HTTP#request.
+#
+# == Request Headers
+#
+# A new request object has these header fields by default:
+#
+# req.to_hash
+# # =>
+# {"accept-encoding"=>["gzip;q=1.0,deflate;q=0.6,identity;q=0.3"],
+# "accept"=>["*/*"],
+# "user-agent"=>["Ruby"],
+# "host"=>["jsonplaceholder.typicode.com"]}
+#
+# See:
+#
+# - {Request header Accept-Encoding}[https://en.wikipedia.org/wiki/List_of_HTTP_header_fields#Accept-Encoding]
+# and {Compression and Decompression}[rdoc-ref:Net::HTTP@Compression+and+Decompression].
+# - {Request header Accept}[https://en.wikipedia.org/wiki/List_of_HTTP_header_fields#accept-request-header].
+# - {Request header User-Agent}[https://en.wikipedia.org/wiki/List_of_HTTP_header_fields#user-agent-request-header].
+# - {Request header Host}[https://en.wikipedia.org/wiki/List_of_HTTP_header_fields#host-request-header].
+#
+# You can add headers or override default headers:
+#
+# # res = Net::HTTP::Get.new(uri, {'foo' => '0', 'bar' => '1'})
+#
+# This class (and therefore its subclasses) also includes (indirectly)
+# module Net::HTTPHeader, which gives access to its
+# {methods for setting headers}[rdoc-ref:Net::HTTPHeader@Setters].
+#
+# == Request Subclasses
#
# Subclasses for HTTP requests:
#
diff --git a/lib/net/http/requests.rb b/lib/net/http/requests.rb
index 7da2d0fee7..5724164205 100644
--- a/lib/net/http/requests.rb
+++ b/lib/net/http/requests.rb
@@ -1,4 +1,4 @@
-# frozen_string_literal: false
+# frozen_string_literal: true
# HTTP/1.1 methods --- RFC2616
@@ -13,7 +13,7 @@
# http.request(req)
# end
#
-# :include: doc/net-http/included_setters.rdoc
+# See {Request Headers}[rdoc-ref:Net::HTTPRequest@Request+Headers].
#
# Properties:
#
@@ -45,7 +45,7 @@ end
# http.request(req)
# end
#
-# :include: doc/net-http/included_setters.rdoc
+# See {Request Headers}[rdoc-ref:Net::HTTPRequest@Request+Headers].
#
# Properties:
#
@@ -79,7 +79,7 @@ end
# http.request(req)
# end
#
-# :include: doc/net-http/included_setters.rdoc
+# See {Request Headers}[rdoc-ref:Net::HTTPRequest@Request+Headers].
#
# Properties:
#
@@ -114,7 +114,7 @@ end
# http.request(req)
# end
#
-# :include: doc/net-http/included_setters.rdoc
+# See {Request Headers}[rdoc-ref:Net::HTTPRequest@Request+Headers].
#
# Properties:
#
@@ -142,7 +142,7 @@ end
# http.request(req)
# end
#
-# :include: doc/net-http/included_setters.rdoc
+# See {Request Headers}[rdoc-ref:Net::HTTPRequest@Request+Headers].
#
# Properties:
#
@@ -173,7 +173,7 @@ end
# http.request(req)
# end
#
-# :include: doc/net-http/included_setters.rdoc
+# See {Request Headers}[rdoc-ref:Net::HTTPRequest@Request+Headers].
#
# Properties:
#
@@ -204,7 +204,7 @@ end
# http.request(req)
# end
#
-# :include: doc/net-http/included_setters.rdoc
+# See {Request Headers}[rdoc-ref:Net::HTTPRequest@Request+Headers].
#
# Properties:
#
@@ -238,7 +238,7 @@ end
# http.request(req)
# end
#
-# :include: doc/net-http/included_setters.rdoc
+# See {Request Headers}[rdoc-ref:Net::HTTPRequest@Request+Headers].
#
# Properties:
#
@@ -273,7 +273,7 @@ end
# http.request(req)
# end
#
-# :include: doc/net-http/included_setters.rdoc
+# See {Request Headers}[rdoc-ref:Net::HTTPRequest@Request+Headers].
#
# Related:
#
@@ -296,7 +296,7 @@ end
# http.request(req)
# end
#
-# :include: doc/net-http/included_setters.rdoc
+# See {Request Headers}[rdoc-ref:Net::HTTPRequest@Request+Headers].
#
# Related:
#
@@ -319,7 +319,7 @@ end
# http.request(req)
# end
#
-# :include: doc/net-http/included_setters.rdoc
+# See {Request Headers}[rdoc-ref:Net::HTTPRequest@Request+Headers].
#
# Related:
#
@@ -342,7 +342,7 @@ end
# http.request(req)
# end
#
-# :include: doc/net-http/included_setters.rdoc
+# See {Request Headers}[rdoc-ref:Net::HTTPRequest@Request+Headers].
#
# Related:
#
@@ -365,7 +365,7 @@ end
# http.request(req)
# end
#
-# :include: doc/net-http/included_setters.rdoc
+# See {Request Headers}[rdoc-ref:Net::HTTPRequest@Request+Headers].
#
# Related:
#
@@ -388,7 +388,7 @@ end
# http.request(req)
# end
#
-# :include: doc/net-http/included_setters.rdoc
+# See {Request Headers}[rdoc-ref:Net::HTTPRequest@Request+Headers].
#
# Related:
#
@@ -411,7 +411,7 @@ end
# http.request(req)
# end
#
-# :include: doc/net-http/included_setters.rdoc
+# See {Request Headers}[rdoc-ref:Net::HTTPRequest@Request+Headers].
#
# Related:
#
diff --git a/lib/net/http/response.rb b/lib/net/http/response.rb
index 90c425b1a7..40de963868 100644
--- a/lib/net/http/response.rb
+++ b/lib/net/http/response.rb
@@ -1,4 +1,4 @@
-# frozen_string_literal: false
+# frozen_string_literal: true
# This class is the base class for \Net::HTTP response classes.
#
@@ -224,13 +224,32 @@ class Net::HTTPResponse
# Accept-Encoding header from the user.
attr_accessor :decode_content
- # The encoding to use for the response body. If Encoding, use that encoding.
- # If other true value, attempt to detect the appropriate encoding, and use
- # that.
+ # Returns the value set by body_encoding=, or +false+ if none;
+ # see #body_encoding=.
attr_reader :body_encoding
- # Set the encoding to use for the response body. If given a String, find
- # the related Encoding.
+ # Sets the encoding that should be used when reading the body:
+ #
+ # - If the given value is an Encoding object, that encoding will be used.
+ # - Otherwise if the value is a string, the value of
+ # {Encoding#find(value)}[rdoc-ref:Encoding.find]
+ # will be used.
+ # - Otherwise an encoding will be deduced from the body itself.
+ #
+ # Examples:
+ #
+ # http = Net::HTTP.new(hostname)
+ # req = Net::HTTP::Get.new('/')
+ #
+ # http.request(req) do |res|
+ # p res.body.encoding # => #<Encoding:ASCII-8BIT>
+ # end
+ #
+ # http.request(req) do |res|
+ # res.body_encoding = "UTF-8"
+ # p res.body.encoding # => #<Encoding:UTF-8>
+ # end
+ #
def body_encoding=(value)
value = Encoding.find(value) if value.is_a?(String)
@body_encoding = value
@@ -254,7 +273,7 @@ class Net::HTTPResponse
def error! #:nodoc:
message = @code
- message += ' ' + @message.dump if @message
+ message = "#{message} #{@message.dump}" if @message
raise error_type().new(message, self)
end
@@ -347,6 +366,7 @@ class Net::HTTPResponse
@body = nil
end
@read = true
+ return if @body.nil?
case enc = @body_encoding
when Encoding, false, nil
@@ -362,26 +382,26 @@ class Net::HTTPResponse
@body
end
- # Returns the full entity body.
+ # Returns the string response body;
+ # note that repeated calls for the unmodified body return a cached string:
#
- # Calling this method a second or subsequent time will return the
- # string already read.
+ # path = '/todos/1'
+ # Net::HTTP.start(hostname) do |http|
+ # res = http.get(path)
+ # p res.body
+ # p http.head(path).body # No body.
+ # end
#
- # http.request_get('/index.html') {|res|
- # puts res.body
- # }
+ # Output:
#
- # http.request_get('/index.html') {|res|
- # p res.body.object_id # 538149362
- # p res.body.object_id # 538149362
- # }
+ # "{\n \"userId\": 1,\n \"id\": 1,\n \"title\": \"delectus aut autem\",\n \"completed\": false\n}"
+ # nil
#
def body
read_body()
end
- # Because it may be necessary to modify the body, Eg, decompression
- # this method facilitates that.
+ # Sets the body of the response to the given value.
def body=(value)
@body = value
end
@@ -620,7 +640,7 @@ class Net::HTTPResponse
end
def stream_check
- raise IOError, 'attempt to read body out of block' if @socket.closed?
+ raise IOError, 'attempt to read body out of block' if @socket.nil? || @socket.closed?
end
def procdest(dest, block)
@@ -629,7 +649,7 @@ class Net::HTTPResponse
if block
Net::ReadAdapter.new(block)
else
- dest || ''
+ dest || +''
end
end
diff --git a/lib/net/http/status.rb b/lib/net/http/status.rb
index 8db3f7d9e3..e70b47d9fb 100644
--- a/lib/net/http/status.rb
+++ b/lib/net/http/status.rb
@@ -4,7 +4,7 @@ require_relative '../http'
if $0 == __FILE__
require 'open-uri'
- IO.foreach(__FILE__) do |line|
+ File.foreach(__FILE__) do |line|
puts line
break if line.start_with?('end')
end
@@ -16,7 +16,7 @@ if $0 == __FILE__
next if ['(Unused)', 'Unassigned', 'Description'].include?(mes)
puts " #{code} => '#{mes}',"
end
- puts "}"
+ puts "} # :nodoc:"
end
Net::HTTP::STATUS_CODES = {
@@ -55,15 +55,16 @@ Net::HTTP::STATUS_CODES = {
410 => 'Gone',
411 => 'Length Required',
412 => 'Precondition Failed',
- 413 => 'Payload Too Large',
+ 413 => 'Content Too Large',
414 => 'URI Too Long',
415 => 'Unsupported Media Type',
416 => 'Range Not Satisfiable',
417 => 'Expectation Failed',
421 => 'Misdirected Request',
- 422 => 'Unprocessable Entity',
+ 422 => 'Unprocessable Content',
423 => 'Locked',
424 => 'Failed Dependency',
+ 425 => 'Too Early',
426 => 'Upgrade Required',
428 => 'Precondition Required',
429 => 'Too Many Requests',
@@ -78,6 +79,6 @@ Net::HTTP::STATUS_CODES = {
506 => 'Variant Also Negotiates',
507 => 'Insufficient Storage',
508 => 'Loop Detected',
- 510 => 'Not Extended',
+ 510 => 'Not Extended (OBSOLETED)',
511 => 'Network Authentication Required',
-}
+} # :nodoc:
diff --git a/lib/net/https.rb b/lib/net/https.rb
index d46721c82a..0f23e1fb13 100644
--- a/lib/net/https.rb
+++ b/lib/net/https.rb
@@ -1,4 +1,4 @@
-# frozen_string_literal: false
+# frozen_string_literal: true
=begin
= net/https -- SSL/TLS enhancement for Net::HTTP.
diff --git a/lib/net/net-protocol.gemspec b/lib/net/net-protocol.gemspec
index c03621cb0d..29ad2504eb 100644
--- a/lib/net/net-protocol.gemspec
+++ b/lib/net/net-protocol.gemspec
@@ -25,7 +25,7 @@ Gem::Specification.new do |spec|
# Specify which files should be added to the gem when it is released.
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
- `git ls-files -z 2>/dev/null`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
+ `git ls-files -z 2>#{IO::NULL}`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
end
spec.require_paths = ["lib"]
diff --git a/lib/net/protocol.rb b/lib/net/protocol.rb
index ea0752a971..197ea09089 100644
--- a/lib/net/protocol.rb
+++ b/lib/net/protocol.rb
@@ -26,7 +26,7 @@ require 'io/wait'
module Net # :nodoc:
class Protocol #:nodoc: internal use only
- VERSION = "0.2.1"
+ VERSION = "0.2.2"
private
def Protocol.protocol_param(name, val)
diff --git a/lib/observer.gemspec b/lib/observer.gemspec
new file mode 100644
index 0000000000..93e61b8c84
--- /dev/null
+++ b/lib/observer.gemspec
@@ -0,0 +1,32 @@
+# frozen_string_literal: true
+
+name = File.basename(__FILE__, ".gemspec")
+version = ["lib", Array.new(name.count("-")+1, ".").join("/")].find do |dir|
+ break File.foreach(File.join(__dir__, dir, "#{name.tr('-', '/')}.rb")) do |line|
+ /^\s*VERSION\s*=\s*"(.*)"/ =~ line and break $1
+ end rescue nil
+end
+
+Gem::Specification.new do |spec|
+ spec.name = name
+ spec.version = version
+ spec.authors = ["Yukihiro Matsumoto"]
+ spec.email = ["matz@ruby-lang.org"]
+
+ spec.summary = %q{Implementation of the Observer object-oriented design pattern.}
+ spec.description = spec.summary
+ spec.homepage = "https://github.com/ruby/observer"
+ spec.licenses = ["Ruby", "BSD-2-Clause"]
+
+ spec.metadata["homepage_uri"] = spec.homepage
+ spec.metadata["source_code_uri"] = spec.homepage
+
+ # Specify which files should be added to the gem when it is released.
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
+ spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
+ `git ls-files -z 2>#{IO::NULL}`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
+ end
+ spec.bindir = "exe"
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
+ spec.require_paths = ["lib"]
+end
diff --git a/lib/observer.rb b/lib/observer.rb
index ef70e39dd8..75832cace2 100644
--- a/lib/observer.rb
+++ b/lib/observer.rb
@@ -136,7 +136,7 @@
# ticker.add_observer(warner, :call)
# ticker.run
module Observable
- VERSION = "0.1.1"
+ VERSION = "0.1.2"
#
# Add +observer+ as an observer on this object. So that it will receive
diff --git a/lib/observer/observer.gemspec b/lib/observer/observer.gemspec
deleted file mode 100644
index 46538e881a..0000000000
--- a/lib/observer/observer.gemspec
+++ /dev/null
@@ -1,32 +0,0 @@
-# frozen_string_literal: true
-
-name = File.basename(__FILE__, ".gemspec")
-version = ["lib", Array.new(name.count("-")+1, "..").join("/")].find do |dir|
- break File.foreach(File.join(__dir__, dir, "#{name.tr('-', '/')}.rb")) do |line|
- /^\s*VERSION\s*=\s*"(.*)"/ =~ line and break $1
- end rescue nil
-end
-
-Gem::Specification.new do |spec|
- spec.name = name
- spec.version = version
- spec.authors = ["Yukihiro Matsumoto"]
- spec.email = ["matz@ruby-lang.org"]
-
- spec.summary = %q{Implementation of the Observer object-oriented design pattern.}
- spec.description = spec.summary
- spec.homepage = "https://github.com/ruby/observer"
- spec.licenses = ["Ruby", "BSD-2-Clause"]
-
- spec.metadata["homepage_uri"] = spec.homepage
- spec.metadata["source_code_uri"] = spec.homepage
-
- # Specify which files should be added to the gem when it is released.
- # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
- spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
- `git ls-files -z 2>/dev/null`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
- end
- spec.bindir = "exe"
- spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
- spec.require_paths = ["lib"]
-end
diff --git a/lib/open-uri.gemspec b/lib/open-uri.gemspec
index cad63e4d80..b6aaf35200 100644
--- a/lib/open-uri.gemspec
+++ b/lib/open-uri.gemspec
@@ -1,6 +1,13 @@
+name = File.basename(__FILE__, ".gemspec")
+version = ["lib", "."].find do |dir|
+ break File.foreach(File.join(__dir__, dir, "#{name}.rb")) do |line|
+ /^\s*VERSION\s*=\s*"(.*)"/ =~ line and break $1
+ end rescue nil
+end
+
Gem::Specification.new do |spec|
- spec.name = "open-uri"
- spec.version = "0.3.0"
+ spec.name = name
+ spec.version = version
spec.authors = ["Tanaka Akira"]
spec.email = ["akr@fsij.org"]
diff --git a/lib/open-uri.rb b/lib/open-uri.rb
index 93e8cfcdb7..ba2379325f 100644
--- a/lib/open-uri.rb
+++ b/lib/open-uri.rb
@@ -31,6 +31,7 @@ module URI
super
end
end
+ singleton_class.send(:ruby2_keywords, :open) if respond_to?(:ruby2_keywords, true)
end
# OpenURI is an easy-to-use wrapper for Net::HTTP, Net::HTTPS and Net::FTP.
@@ -89,6 +90,9 @@ end
# Author:: Tanaka Akira <akr@m17n.org>
module OpenURI
+
+ VERSION = "0.4.1"
+
Options = {
:proxy => true,
:proxy_http_basic_authentication => true,
@@ -104,6 +108,7 @@ module OpenURI
:ftp_active_mode => false,
:redirect => true,
:encoding => nil,
+ :max_redirects => 64,
}
def OpenURI.check_options(options) # :nodoc:
@@ -207,6 +212,7 @@ module OpenURI
end
uri_set = {}
+ max_redirects = options[:max_redirects]
buf = nil
while true
redirect = catch(:open_uri_redirect) {
@@ -234,6 +240,7 @@ module OpenURI
uri = redirect
raise "HTTP redirection loop: #{uri}" if uri_set.include? uri.to_s
uri_set[uri.to_s] = true
+ raise TooManyRedirects.new("Too many redirects", buf.io) if max_redirects && uri_set.size > max_redirects
else
break
end
@@ -388,6 +395,9 @@ module OpenURI
attr_reader :uri
end
+ class TooManyRedirects < HTTPError
+ end
+
class Buffer # :nodoc: all
def initialize
@io = StringIO.new
diff --git a/lib/open3.rb b/lib/open3.rb
index 9652b27194..74d00b86d9 100644
--- a/lib/open3.rb
+++ b/lib/open3.rb
@@ -31,57 +31,189 @@
require 'open3/version'
+# \Module \Open3 supports creating child processes
+# with access to their $stdin, $stdout, and $stderr streams.
+#
+# == What's Here
+#
+# Each of these methods executes a given command in a new process or subshell,
+# or multiple commands in new processes and/or subshells:
+#
+# - Each of these methods executes a single command in a process or subshell,
+# accepts a string for input to $stdin,
+# and returns string output from $stdout, $stderr, or both:
+#
+# - Open3.capture2: Executes the command;
+# returns the string from $stdout.
+# - Open3.capture2e: Executes the command;
+# returns the string from merged $stdout and $stderr.
+# - Open3.capture3: Executes the command;
+# returns strings from $stdout and $stderr.
+#
+# - Each of these methods executes a single command in a process or subshell,
+# and returns pipes for $stdin, $stdout, and/or $stderr:
+#
+# - Open3.popen2: Executes the command;
+# returns pipes for $stdin and $stdout.
+# - Open3.popen2e: Executes the command;
+# returns pipes for $stdin and merged $stdout and $stderr.
+# - Open3.popen3: Executes the command;
+# returns pipes for $stdin, $stdout, and $stderr.
+#
+# - Each of these methods executes one or more commands in processes and/or subshells,
+# returns pipes for the first $stdin, the last $stdout, or both:
+#
+# - Open3.pipeline_r: Returns a pipe for the last $stdout.
+# - Open3.pipeline_rw: Returns pipes for the first $stdin and the last $stdout.
+# - Open3.pipeline_w: Returns a pipe for the first $stdin.
+# - Open3.pipeline_start: Does not wait for processes to complete.
+# - Open3.pipeline: Waits for processes to complete.
+#
+# Each of the methods above accepts:
+#
+# - An optional hash of environment variable names and values;
+# see {Execution Environment}[rdoc-ref:Process@Execution+Environment].
+# - A required string argument that is a +command_line+ or +exe_path+;
+# see {Argument command_line or exe_path}[rdoc-ref:Process@Argument+command_line+or+exe_path].
+# - An optional hash of execution options;
+# see {Execution Options}[rdoc-ref:Process@Execution+Options].
+#
module Open3
- # Open stdin, stdout, and stderr streams and start external executable.
- # In addition, a thread to wait for the started process is created.
- # The thread has a pid method and a thread variable :pid which is the pid of
- # the started process.
+ # :call-seq:
+ # Open3.popen3([env, ] command_line, options = {}) -> [stdin, stdout, stderr, wait_thread]
+ # Open3.popen3([env, ] exe_path, *args, options = {}) -> [stdin, stdout, stderr, wait_thread]
+ # Open3.popen3([env, ] command_line, options = {}) {|stdin, stdout, stderr, wait_thread| ... } -> object
+ # Open3.popen3([env, ] exe_path, *args, options = {}) {|stdin, stdout, stderr, wait_thread| ... } -> object
+ #
+ # Basically a wrapper for
+ # {Process.spawn}[rdoc-ref:Process.spawn]
+ # that:
+ #
+ # - Creates a child process, by calling Process.spawn with the given arguments.
+ # - Creates streams +stdin+, +stdout+, and +stderr+,
+ # which are the standard input, standard output, and standard error streams
+ # in the child process.
+ # - Creates thread +wait_thread+ that waits for the child process to exit;
+ # the thread has method +pid+, which returns the process ID
+ # of the child process.
+ #
+ # With no block given, returns the array
+ # <tt>[stdin, stdout, stderr, wait_thread]</tt>.
+ # The caller should close each of the three returned streams.
+ #
+ # stdin, stdout, stderr, wait_thread = Open3.popen3('echo')
+ # # => [#<IO:fd 8>, #<IO:fd 10>, #<IO:fd 12>, #<Process::Waiter:0x00007f58d5428f58 run>]
+ # stdin.close
+ # stdout.close
+ # stderr.close
+ # wait_thread.pid # => 2210481
+ # wait_thread.value # => #<Process::Status: pid 2210481 exit 0>
+ #
+ # With a block given, calls the block with the four variables
+ # (three streams and the wait thread)
+ # and returns the block's return value.
+ # The caller need not close the streams:
+ #
+ # Open3.popen3('echo') do |stdin, stdout, stderr, wait_thread|
+ # p stdin
+ # p stdout
+ # p stderr
+ # p wait_thread
+ # p wait_thread.pid
+ # p wait_thread.value
+ # end
#
- # Block form:
+ # Output:
#
- # Open3.popen3([env,] cmd... [, opts]) {|stdin, stdout, stderr, wait_thr|
- # pid = wait_thr.pid # pid of the started process.
- # ...
- # exit_status = wait_thr.value # Process::Status object returned.
- # }
+ # #<IO:fd 6>
+ # #<IO:fd 7>
+ # #<IO:fd 9>
+ # #<Process::Waiter:0x00007f58d53606e8 sleep>
+ # 2211047
+ # #<Process::Status: pid 2211047 exit 0>
#
- # Non-block form:
+ # Like Process.spawn, this method has potential security vulnerabilities
+ # if called with untrusted input;
+ # see {Command Injection}[rdoc-ref:command_injection.rdoc@Command+Injection].
#
- # stdin, stdout, stderr, wait_thr = Open3.popen3([env,] cmd... [, opts])
- # pid = wait_thr[:pid] # pid of the started process
- # ...
- # stdin.close # stdin, stdout and stderr should be closed explicitly in this form.
- # stdout.close
- # stderr.close
- # exit_status = wait_thr.value # Process::Status object returned.
+ # Unlike Process.spawn, this method waits for the child process to exit
+ # before returning, so the caller need not do so.
+ #
+ # If the first argument is a hash, it becomes leading argument +env+
+ # in the call to Process.spawn;
+ # see {Execution Environment}[rdoc-ref:Process@Execution+Environment].
+ #
+ # If the last argument is a hash, it becomes trailing argument +options+
+ # in the call to Process.spawn;
+ # see {Execution Options}[rdoc-ref:Process@Execution+Options].
+ #
+ # The single required argument is one of the following:
+ #
+ # - +command_line+ if it is a string,
+ # and if it begins with a shell reserved word or special built-in,
+ # or if it contains one or more metacharacters.
+ # - +exe_path+ otherwise.
+ #
+ # <b>Argument +command_line+</b>
#
- # The parameters env, cmd, and opts are passed to Process.spawn.
- # A commandline string and a list of argument strings can be accepted as follows:
+ # \String argument +command_line+ is a command line to be passed to a shell;
+ # it must begin with a shell reserved word, begin with a special built-in,
+ # or contain meta characters:
#
- # Open3.popen3("echo abc") {|i, o, e, t| ... }
- # Open3.popen3("echo", "abc") {|i, o, e, t| ... }
- # Open3.popen3(["echo", "argv0"], "abc") {|i, o, e, t| ... }
+ # Open3.popen3('if true; then echo "Foo"; fi') {|*args| p args } # Shell reserved word.
+ # Open3.popen3('echo') {|*args| p args } # Built-in.
+ # Open3.popen3('date > date.tmp') {|*args| p args } # Contains meta character.
#
- # If the last parameter, opts, is a Hash, it is recognized as an option for Process.spawn.
+ # Output (similar for each call above):
#
- # Open3.popen3("pwd", :chdir=>"/") {|i,o,e,t|
- # p o.read.chomp #=> "/"
- # }
+ # [#<IO:(closed)>, #<IO:(closed)>, #<IO:(closed)>, #<Process::Waiter:0x00007f58d52f28c8 dead>]
#
- # wait_thr.value waits for the termination of the process.
- # The block form also waits for the process when it returns.
+ # The command line may also contain arguments and options for the command:
+ #
+ # Open3.popen3('echo "Foo"') { |i, o, e, t| o.gets }
+ # "Foo\n"
+ #
+ # <b>Argument +exe_path+</b>
+ #
+ # Argument +exe_path+ is one of the following:
+ #
+ # - The string path to an executable to be called.
+ # - A 2-element array containing the path to an executable
+ # and the string to be used as the name of the executing process.
+ #
+ # Example:
#
- # Closing stdin, stdout and stderr does not wait for the process to complete.
+ # Open3.popen3('/usr/bin/date') { |i, o, e, t| o.gets }
+ # # => "Wed Sep 27 02:56:44 PM CDT 2023\n"
#
- # You should be careful to avoid deadlocks.
- # Since pipes are fixed length buffers,
- # Open3.popen3("prog") {|i, o, e, t| o.read } deadlocks if
- # the program generates too much output on stderr.
- # You should read stdout and stderr simultaneously (using threads or IO.select).
- # However, if you don't need stderr output, you can use Open3.popen2.
- # If merged stdout and stderr output is not a problem, you can use Open3.popen2e.
- # If you really need stdout and stderr output as separate strings, you can consider Open3.capture3.
+ # Ruby invokes the executable directly, with no shell and no shell expansion:
+ #
+ # Open3.popen3('doesnt_exist') { |i, o, e, t| o.gets } # Raises Errno::ENOENT
+ #
+ # If one or more +args+ is given, each is an argument or option
+ # to be passed to the executable:
+ #
+ # Open3.popen3('echo', 'C #') { |i, o, e, t| o.gets }
+ # # => "C #\n"
+ # Open3.popen3('echo', 'hello', 'world') { |i, o, e, t| o.gets }
+ # # => "hello world\n"
+ #
+ # Take care to avoid deadlocks.
+ # Output streams +stdout+ and +stderr+ have fixed-size buffers,
+ # so reading extensively from one but not the other can cause a deadlock
+ # when the unread buffer fills.
+ # To avoid that, +stdout+ and +stderr+ should be read simultaneously
+ # (using threads or IO.select).
+ #
+ # Related:
+ #
+ # - Open3.popen2: Makes the standard input and standard output streams
+ # of the child process available as separate streams,
+ # with no access to the standard error stream.
+ # - Open3.popen2e: Makes the standard input and the merge
+ # of the standard output and standard error streams
+ # of the child process available as separate streams.
#
def popen3(*cmd, &block)
if Hash === cmd.last
@@ -104,45 +236,131 @@ module Open3
end
module_function :popen3
- # Open3.popen2 is similar to Open3.popen3 except that it doesn't create a pipe for
- # the standard error stream.
+ # :call-seq:
+ # Open3.popen2([env, ] command_line, options = {}) -> [stdin, stdout, wait_thread]
+ # Open3.popen2([env, ] exe_path, *args, options = {}) -> [stdin, stdout, wait_thread]
+ # Open3.popen2([env, ] command_line, options = {}) {|stdin, stdout, wait_thread| ... } -> object
+ # Open3.popen2([env, ] exe_path, *args, options = {}) {|stdin, stdout, wait_thread| ... } -> object
+ #
+ # Basically a wrapper for
+ # {Process.spawn}[rdoc-ref:Process.spawn]
+ # that:
+ #
+ # - Creates a child process, by calling Process.spawn with the given arguments.
+ # - Creates streams +stdin+ and +stdout+,
+ # which are the standard input and standard output streams
+ # in the child process.
+ # - Creates thread +wait_thread+ that waits for the child process to exit;
+ # the thread has method +pid+, which returns the process ID
+ # of the child process.
+ #
+ # With no block given, returns the array
+ # <tt>[stdin, stdout, wait_thread]</tt>.
+ # The caller should close each of the two returned streams.
+ #
+ # stdin, stdout, wait_thread = Open3.popen2('echo')
+ # # => [#<IO:fd 6>, #<IO:fd 7>, #<Process::Waiter:0x00007f58d52dbe98 run>]
+ # stdin.close
+ # stdout.close
+ # wait_thread.pid # => 2263572
+ # wait_thread.value # => #<Process::Status: pid 2263572 exit 0>
+ #
+ # With a block given, calls the block with the three variables
+ # (two streams and the wait thread)
+ # and returns the block's return value.
+ # The caller need not close the streams:
+ #
+ # Open3.popen2('echo') do |stdin, stdout, wait_thread|
+ # p stdin
+ # p stdout
+ # p wait_thread
+ # p wait_thread.pid
+ # p wait_thread.value
+ # end
#
- # Block form:
+ # Output:
#
- # Open3.popen2([env,] cmd... [, opts]) {|stdin, stdout, wait_thr|
- # pid = wait_thr.pid # pid of the started process.
- # ...
- # exit_status = wait_thr.value # Process::Status object returned.
- # }
+ # #<IO:fd 6>
+ # #<IO:fd 7>
+ # #<Process::Waiter:0x00007f58d59a34b0 sleep>
+ # 2263636
+ # #<Process::Status: pid 2263636 exit 0>
#
- # Non-block form:
+ # Like Process.spawn, this method has potential security vulnerabilities
+ # if called with untrusted input;
+ # see {Command Injection}[rdoc-ref:command_injection.rdoc@Command+Injection].
#
- # stdin, stdout, wait_thr = Open3.popen2([env,] cmd... [, opts])
- # ...
- # stdin.close # stdin and stdout should be closed explicitly in this form.
- # stdout.close
+ # Unlike Process.spawn, this method waits for the child process to exit
+ # before returning, so the caller need not do so.
+ #
+ # If the first argument is a hash, it becomes leading argument +env+
+ # in the call to Process.spawn;
+ # see {Execution Environment}[rdoc-ref:Process@Execution+Environment].
+ #
+ # If the last argument is a hash, it becomes trailing argument +options+
+ # in the call to Process.spawn;
+ # see {Execution Options}[rdoc-ref:Process@Execution+Options].
+ #
+ # The single required argument is one of the following:
+ #
+ # - +command_line+ if it is a string,
+ # and if it begins with a shell reserved word or special built-in,
+ # or if it contains one or more metacharacters.
+ # - +exe_path+ otherwise.
#
- # See Process.spawn for the optional hash arguments _env_ and _opts_.
+ # <b>Argument +command_line+</b>
+ #
+ # \String argument +command_line+ is a command line to be passed to a shell;
+ # it must begin with a shell reserved word, begin with a special built-in,
+ # or contain meta characters:
+ #
+ # Open3.popen2('if true; then echo "Foo"; fi') {|*args| p args } # Shell reserved word.
+ # Open3.popen2('echo') {|*args| p args } # Built-in.
+ # Open3.popen2('date > date.tmp') {|*args| p args } # Contains meta character.
+ #
+ # Output (similar for each call above):
+ #
+ # # => [#<IO:(closed)>, #<IO:(closed)>, #<Process::Waiter:0x00007f7577dfe410 dead>]
+ #
+ # The command line may also contain arguments and options for the command:
+ #
+ # Open3.popen2('echo "Foo"') { |i, o, t| o.gets }
+ # "Foo\n"
+ #
+ # <b>Argument +exe_path+</b>
+ #
+ # Argument +exe_path+ is one of the following:
+ #
+ # - The string path to an executable to be called.
+ # - A 2-element array containing the path to an executable
+ # and the string to be used as the name of the executing process.
#
# Example:
#
- # Open3.popen2("wc -c") {|i,o,t|
- # i.print "answer to life the universe and everything"
- # i.close
- # p o.gets #=> "42\n"
- # }
+ # Open3.popen2('/usr/bin/date') { |i, o, t| o.gets }
+ # # => "Thu Sep 28 09:41:06 AM CDT 2023\n"
+ #
+ # Ruby invokes the executable directly, with no shell and no shell expansion:
+ #
+ # Open3.popen2('doesnt_exist') { |i, o, t| o.gets } # Raises Errno::ENOENT
+ #
+ # If one or more +args+ is given, each is an argument or option
+ # to be passed to the executable:
+ #
+ # Open3.popen2('echo', 'C #') { |i, o, t| o.gets }
+ # # => "C #\n"
+ # Open3.popen2('echo', 'hello', 'world') { |i, o, t| o.gets }
+ # # => "hello world\n"
#
- # Open3.popen2("bc -q") {|i,o,t|
- # i.puts "obase=13"
- # i.puts "6 * 9"
- # p o.gets #=> "42\n"
- # }
#
- # Open3.popen2("dc") {|i,o,t|
- # i.print "42P"
- # i.close
- # p o.read #=> "*"
- # }
+ # Related:
+ #
+ # - Open3.popen2e: Makes the standard input and the merge
+ # of the standard output and standard error streams
+ # of the child process available as separate streams.
+ # - Open3.popen3: Makes the standard input, standard output,
+ # and standard error streams
+ # of the child process available as separate streams.
#
def popen2(*cmd, &block)
if Hash === cmd.last
@@ -162,36 +380,130 @@ module Open3
end
module_function :popen2
- # Open3.popen2e is similar to Open3.popen3 except that it merges
- # the standard output stream and the standard error stream.
+ # :call-seq:
+ # Open3.popen2e([env, ] command_line, options = {}) -> [stdin, stdout_and_stderr, wait_thread]
+ # Open3.popen2e([env, ] exe_path, *args, options = {}) -> [stdin, stdout_and_stderr, wait_thread]
+ # Open3.popen2e([env, ] command_line, options = {}) {|stdin, stdout_and_stderr, wait_thread| ... } -> object
+ # Open3.popen2e([env, ] exe_path, *args, options = {}) {|stdin, stdout_and_stderr, wait_thread| ... } -> object
+ #
+ # Basically a wrapper for
+ # {Process.spawn}[rdoc-ref:Process.spawn]
+ # that:
+ #
+ # - Creates a child process, by calling Process.spawn with the given arguments.
+ # - Creates streams +stdin+, +stdout_and_stderr+,
+ # which are the standard input and the merge of the standard output
+ # and standard error streams in the child process.
+ # - Creates thread +wait_thread+ that waits for the child process to exit;
+ # the thread has method +pid+, which returns the process ID
+ # of the child process.
+ #
+ # With no block given, returns the array
+ # <tt>[stdin, stdout_and_stderr, wait_thread]</tt>.
+ # The caller should close each of the two returned streams.
+ #
+ # stdin, stdout_and_stderr, wait_thread = Open3.popen2e('echo')
+ # # => [#<IO:fd 6>, #<IO:fd 7>, #<Process::Waiter:0x00007f7577da4398 run>]
+ # stdin.close
+ # stdout_and_stderr.close
+ # wait_thread.pid # => 2274600
+ # wait_thread.value # => #<Process::Status: pid 2274600 exit 0>
+ #
+ # With a block given, calls the block with the three variables
+ # (two streams and the wait thread)
+ # and returns the block's return value.
+ # The caller need not close the streams:
+ #
+ # Open3.popen2e('echo') do |stdin, stdout_and_stderr, wait_thread|
+ # p stdin
+ # p stdout_and_stderr
+ # p wait_thread
+ # p wait_thread.pid
+ # p wait_thread.value
+ # end
#
- # Block form:
+ # Output:
#
- # Open3.popen2e([env,] cmd... [, opts]) {|stdin, stdout_and_stderr, wait_thr|
- # pid = wait_thr.pid # pid of the started process.
- # ...
- # exit_status = wait_thr.value # Process::Status object returned.
- # }
+ # #<IO:fd 6>
+ # #<IO:fd 7>
+ # #<Process::Waiter:0x00007f75777578c8 sleep>
+ # 2274763
+ # #<Process::Status: pid 2274763 exit 0>
#
- # Non-block form:
+ # Like Process.spawn, this method has potential security vulnerabilities
+ # if called with untrusted input;
+ # see {Command Injection}[rdoc-ref:command_injection.rdoc@Command+Injection].
#
- # stdin, stdout_and_stderr, wait_thr = Open3.popen2e([env,] cmd... [, opts])
- # ...
- # stdin.close # stdin and stdout_and_stderr should be closed explicitly in this form.
- # stdout_and_stderr.close
+ # Unlike Process.spawn, this method waits for the child process to exit
+ # before returning, so the caller need not do so.
+ #
+ # If the first argument is a hash, it becomes leading argument +env+
+ # in the call to Process.spawn;
+ # see {Execution Environment}[rdoc-ref:Process@Execution+Environment].
+ #
+ # If the last argument is a hash, it becomes trailing argument +options+
+ # in the call to Process.spawn;
+ # see {Execution Options}[rdoc-ref:Process@Execution+Options].
+ #
+ # The single required argument is one of the following:
+ #
+ # - +command_line+ if it is a string,
+ # and if it begins with a shell reserved word or special built-in,
+ # or if it contains one or more metacharacters.
+ # - +exe_path+ otherwise.
+ #
+ # <b>Argument +command_line+</b>
+ #
+ # \String argument +command_line+ is a command line to be passed to a shell;
+ # it must begin with a shell reserved word, begin with a special built-in,
+ # or contain meta characters:
+ #
+ # Open3.popen2e('if true; then echo "Foo"; fi') {|*args| p args } # Shell reserved word.
+ # Open3.popen2e('echo') {|*args| p args } # Built-in.
+ # Open3.popen2e('date > date.tmp') {|*args| p args } # Contains meta character.
+ #
+ # Output (similar for each call above):
+ #
+ # # => [#<IO:(closed)>, #<IO:(closed)>, #<Process::Waiter:0x00007f7577d8a1f0 dead>]
#
- # See Process.spawn for the optional hash arguments _env_ and _opts_.
+ # The command line may also contain arguments and options for the command:
+ #
+ # Open3.popen2e('echo "Foo"') { |i, o_and_e, t| o_and_e.gets }
+ # "Foo\n"
+ #
+ # <b>Argument +exe_path+</b>
+ #
+ # Argument +exe_path+ is one of the following:
+ #
+ # - The string path to an executable to be called.
+ # - A 2-element array containing the path to an executable
+ # and the string to be used as the name of the executing process.
#
# Example:
- # # check gcc warnings
- # source = "foo.c"
- # Open3.popen2e("gcc", "-Wall", source) {|i,oe,t|
- # oe.each {|line|
- # if /warning/ =~ line
- # ...
- # end
- # }
- # }
+ #
+ # Open3.popen2e('/usr/bin/date') { |i, o_and_e, t| o_and_e.gets }
+ # # => "Thu Sep 28 01:58:45 PM CDT 2023\n"
+ #
+ # Ruby invokes the executable directly, with no shell and no shell expansion:
+ #
+ # Open3.popen2e('doesnt_exist') { |i, o_and_e, t| o_and_e.gets } # Raises Errno::ENOENT
+ #
+ # If one or more +args+ is given, each is an argument or option
+ # to be passed to the executable:
+ #
+ # Open3.popen2e('echo', 'C #') { |i, o_and_e, t| o_and_e.gets }
+ # # => "C #\n"
+ # Open3.popen2e('echo', 'hello', 'world') { |i, o_and_e, t| o_and_e.gets }
+ # # => "hello world\n"
+ #
+ # Related:
+ #
+ # - Open3.popen2: Makes the standard input and standard output streams
+ # of the child process available as separate streams,
+ # with no access to the standard error stream.
+ # - Open3.popen3: Makes the standard input, standard output,
+ # and standard error streams
+ # of the child process available as separate streams.
#
def popen2e(*cmd, &block)
if Hash === cmd.last
@@ -238,44 +550,100 @@ module Open3
private :popen_run
end
- # Open3.capture3 captures the standard output and the standard error of a command.
+ # :call-seq:
+ # Open3.capture3([env, ] command_line, options = {}) -> [stdout_s, stderr_s, status]
+ # Open3.capture3([env, ] exe_path, *args, options = {}) -> [stdout_s, stderr_s, status]
#
- # stdout_str, stderr_str, status = Open3.capture3([env,] cmd... [, opts])
+ # Basically a wrapper for Open3.popen3 that:
#
- # The arguments env, cmd and opts are passed to Open3.popen3 except
- # <code>opts[:stdin_data]</code> and <code>opts[:binmode]</code>. See Process.spawn.
+ # - Creates a child process, by calling Open3.popen3 with the given arguments
+ # (except for certain entries in hash +options+; see below).
+ # - Returns as strings +stdout_s+ and +stderr_s+ the standard output
+ # and standard error of the child process.
+ # - Returns as +status+ a <tt>Process::Status</tt> object
+ # that represents the exit status of the child process.
#
- # If <code>opts[:stdin_data]</code> is specified, it is sent to the command's standard input.
+ # Returns the array <tt>[stdout_s, stderr_s, status]</tt>:
#
- # If <code>opts[:binmode]</code> is true, internal pipes are set to binary mode.
+ # stdout_s, stderr_s, status = Open3.capture3('echo "Foo"')
+ # # => ["Foo\n", "", #<Process::Status: pid 2281954 exit 0>]
#
- # Examples:
+ # Like Process.spawn, this method has potential security vulnerabilities
+ # if called with untrusted input;
+ # see {Command Injection}[rdoc-ref:command_injection.rdoc@Command+Injection].
#
- # # dot is a command of graphviz.
- # graph = <<'End'
- # digraph g {
- # a -> b
- # }
- # End
- # drawn_graph, dot_log = Open3.capture3("dot -v", :stdin_data=>graph)
+ # Unlike Process.spawn, this method waits for the child process to exit
+ # before returning, so the caller need not do so.
#
- # o, e, s = Open3.capture3("echo abc; sort >&2", :stdin_data=>"foo\nbar\nbaz\n")
- # p o #=> "abc\n"
- # p e #=> "bar\nbaz\nfoo\n"
- # p s #=> #<Process::Status: pid 32682 exit 0>
+ # If the first argument is a hash, it becomes leading argument +env+
+ # in the call to Open3.popen3;
+ # see {Execution Environment}[rdoc-ref:Process@Execution+Environment].
#
- # # generate a thumbnail image using the convert command of ImageMagick.
- # # However, if the image is really stored in a file,
- # # system("convert", "-thumbnail", "80", "png:#{filename}", "png:-") is better
- # # because of reduced memory consumption.
- # # But if the image is stored in a DB or generated by the gnuplot Open3.capture2 example,
- # # Open3.capture3 should be considered.
- # #
- # image = File.read("/usr/share/openclipart/png/animals/mammals/sheep-md-v0.1.png", :binmode=>true)
- # thumbnail, err, s = Open3.capture3("convert -thumbnail 80 png:- png:-", :stdin_data=>image, :binmode=>true)
- # if s.success?
- # STDOUT.binmode; print thumbnail
- # end
+ # If the last argument is a hash, it becomes trailing argument +options+
+ # in the call to Open3.popen3;
+ # see {Execution Options}[rdoc-ref:Process@Execution+Options].
+ #
+ # The hash +options+ is given;
+ # two options have local effect in method Open3.capture3:
+ #
+ # - If entry <tt>options[:stdin_data]</tt> exists, the entry is removed
+ # and its string value is sent to the command's standard input:
+ #
+ # Open3.capture3('tee', stdin_data: 'Foo')
+ # # => ["Foo", "", #<Process::Status: pid 2319575 exit 0>]
+ #
+ # - If entry <tt>options[:binmode]</tt> exists, the entry is removed and
+ # the internal streams are set to binary mode.
+ #
+ # The single required argument is one of the following:
+ #
+ # - +command_line+ if it is a string,
+ # and if it begins with a shell reserved word or special built-in,
+ # or if it contains one or more metacharacters.
+ # - +exe_path+ otherwise.
+ #
+ # <b>Argument +command_line+</b>
+ #
+ # \String argument +command_line+ is a command line to be passed to a shell;
+ # it must begin with a shell reserved word, begin with a special built-in,
+ # or contain meta characters:
+ #
+ # Open3.capture3('if true; then echo "Foo"; fi') # Shell reserved word.
+ # # => ["Foo\n", "", #<Process::Status: pid 2282025 exit 0>]
+ # Open3.capture3('echo') # Built-in.
+ # # => ["\n", "", #<Process::Status: pid 2282092 exit 0>]
+ # Open3.capture3('date > date.tmp') # Contains meta character.
+ # # => ["", "", #<Process::Status: pid 2282110 exit 0>]
+ #
+ # The command line may also contain arguments and options for the command:
+ #
+ # Open3.capture3('echo "Foo"')
+ # # => ["Foo\n", "", #<Process::Status: pid 2282092 exit 0>]
+ #
+ # <b>Argument +exe_path+</b>
+ #
+ # Argument +exe_path+ is one of the following:
+ #
+ # - The string path to an executable to be called.
+ # - A 2-element array containing the path to an executable
+ # and the string to be used as the name of the executing process.
+ #
+ # Example:
+ #
+ # Open3.capture3('/usr/bin/date')
+ # # => ["Thu Sep 28 05:03:51 PM CDT 2023\n", "", #<Process::Status: pid 2282300 exit 0>]
+ #
+ # Ruby invokes the executable directly, with no shell and no shell expansion:
+ #
+ # Open3.capture3('doesnt_exist') # Raises Errno::ENOENT
+ #
+ # If one or more +args+ is given, each is an argument or option
+ # to be passed to the executable:
+ #
+ # Open3.capture3('echo', 'C #')
+ # # => ["C #\n", "", #<Process::Status: pid 2282368 exit 0>]
+ # Open3.capture3('echo', 'hello', 'world')
+ # # => ["hello world\n", "", #<Process::Status: pid 2282372 exit 0>]
#
def capture3(*cmd)
if Hash === cmd.last
@@ -309,34 +677,100 @@ module Open3
end
module_function :capture3
- # Open3.capture2 captures the standard output of a command.
+ # :call-seq:
+ # Open3.capture2([env, ] command_line, options = {}) -> [stdout_s, status]
+ # Open3.capture2([env, ] exe_path, *args, options = {}) -> [stdout_s, status]
+ #
+ # Basically a wrapper for Open3.popen3 that:
+ #
+ # - Creates a child process, by calling Open3.popen3 with the given arguments
+ # (except for certain entries in hash +options+; see below).
+ # - Returns as string +stdout_s+ the standard output of the child process.
+ # - Returns as +status+ a <tt>Process::Status</tt> object
+ # that represents the exit status of the child process.
+ #
+ # Returns the array <tt>[stdout_s, status]</tt>:
+ #
+ # stdout_s, status = Open3.capture2('echo "Foo"')
+ # # => ["Foo\n", #<Process::Status: pid 2326047 exit 0>]
+ #
+ # Like Process.spawn, this method has potential security vulnerabilities
+ # if called with untrusted input;
+ # see {Command Injection}[rdoc-ref:command_injection.rdoc@Command+Injection].
+ #
+ # Unlike Process.spawn, this method waits for the child process to exit
+ # before returning, so the caller need not do so.
#
- # stdout_str, status = Open3.capture2([env,] cmd... [, opts])
+ # If the first argument is a hash, it becomes leading argument +env+
+ # in the call to Open3.popen3;
+ # see {Execution Environment}[rdoc-ref:Process@Execution+Environment].
#
- # The arguments env, cmd and opts are passed to Open3.popen3 except
- # <code>opts[:stdin_data]</code> and <code>opts[:binmode]</code>. See Process.spawn.
+ # If the last argument is a hash, it becomes trailing argument +options+
+ # in the call to Open3.popen3;
+ # see {Execution Options}[rdoc-ref:Process@Execution+Options].
#
- # If <code>opts[:stdin_data]</code> is specified, it is sent to the command's standard input.
+ # The hash +options+ is given;
+ # two options have local effect in method Open3.capture2:
#
- # If <code>opts[:binmode]</code> is true, internal pipes are set to binary mode.
+ # - If entry <tt>options[:stdin_data]</tt> exists, the entry is removed
+ # and its string value is sent to the command's standard input:
+ #
+ # Open3.capture2('tee', stdin_data: 'Foo')
+ #
+ # # => ["Foo", #<Process::Status: pid 2326087 exit 0>]
+ #
+ # - If entry <tt>options[:binmode]</tt> exists, the entry is removed and
+ # the internal streams are set to binary mode.
+ #
+ # The single required argument is one of the following:
+ #
+ # - +command_line+ if it is a string,
+ # and if it begins with a shell reserved word or special built-in,
+ # or if it contains one or more metacharacters.
+ # - +exe_path+ otherwise.
+ #
+ # <b>Argument +command_line+</b>
+ #
+ # \String argument +command_line+ is a command line to be passed to a shell;
+ # it must begin with a shell reserved word, begin with a special built-in,
+ # or contain meta characters:
+ #
+ # Open3.capture2('if true; then echo "Foo"; fi') # Shell reserved word.
+ # # => ["Foo\n", #<Process::Status: pid 2326131 exit 0>]
+ # Open3.capture2('echo') # Built-in.
+ # # => ["\n", #<Process::Status: pid 2326139 exit 0>]
+ # Open3.capture2('date > date.tmp') # Contains meta character.
+ # # => ["", #<Process::Status: pid 2326174 exit 0>]
+ #
+ # The command line may also contain arguments and options for the command:
+ #
+ # Open3.capture2('echo "Foo"')
+ # # => ["Foo\n", #<Process::Status: pid 2326183 exit 0>]
+ #
+ # <b>Argument +exe_path+</b>
+ #
+ # Argument +exe_path+ is one of the following:
+ #
+ # - The string path to an executable to be called.
+ # - A 2-element array containing the path to an executable
+ # and the string to be used as the name of the executing process.
#
# Example:
#
- # # factor is a command for integer factorization.
- # o, s = Open3.capture2("factor", :stdin_data=>"42")
- # p o #=> "42: 2 3 7\n"
- #
- # # generate x**2 graph in png using gnuplot.
- # gnuplot_commands = <<"End"
- # set terminal png
- # plot x**2, "-" with lines
- # 1 14
- # 2 1
- # 3 8
- # 4 5
- # e
- # End
- # image, s = Open3.capture2("gnuplot", :stdin_data=>gnuplot_commands, :binmode=>true)
+ # Open3.capture2('/usr/bin/date')
+ # # => ["Fri Sep 29 01:00:39 PM CDT 2023\n", #<Process::Status: pid 2326222 exit 0>]
+ #
+ # Ruby invokes the executable directly, with no shell and no shell expansion:
+ #
+ # Open3.capture2('doesnt_exist') # Raises Errno::ENOENT
+ #
+ # If one or more +args+ is given, each is an argument or option
+ # to be passed to the executable:
+ #
+ # Open3.capture2('echo', 'C #')
+ # # => ["C #\n", #<Process::Status: pid 2326267 exit 0>]
+ # Open3.capture2('echo', 'hello', 'world')
+ # # => ["hello world\n", #<Process::Status: pid 2326299 exit 0>]
#
def capture2(*cmd)
if Hash === cmd.last
@@ -370,21 +804,100 @@ module Open3
end
module_function :capture2
- # Open3.capture2e captures the standard output and the standard error of a command.
+ # :call-seq:
+ # Open3.capture2e([env, ] command_line, options = {}) -> [stdout_and_stderr_s, status]
+ # Open3.capture2e([env, ] exe_path, *args, options = {}) -> [stdout_and_stderr_s, status]
+ #
+ # Basically a wrapper for Open3.popen3 that:
+ #
+ # - Creates a child process, by calling Open3.popen3 with the given arguments
+ # (except for certain entries in hash +options+; see below).
+ # - Returns as string +stdout_and_stderr_s+ the merged standard output
+ # and standard error of the child process.
+ # - Returns as +status+ a <tt>Process::Status</tt> object
+ # that represents the exit status of the child process.
+ #
+ # Returns the array <tt>[stdout_and_stderr_s, status]</tt>:
+ #
+ # stdout_and_stderr_s, status = Open3.capture2e('echo "Foo"')
+ # # => ["Foo\n", #<Process::Status: pid 2371692 exit 0>]
+ #
+ # Like Process.spawn, this method has potential security vulnerabilities
+ # if called with untrusted input;
+ # see {Command Injection}[rdoc-ref:command_injection.rdoc@Command+Injection].
+ #
+ # Unlike Process.spawn, this method waits for the child process to exit
+ # before returning, so the caller need not do so.
+ #
+ # If the first argument is a hash, it becomes leading argument +env+
+ # in the call to Open3.popen3;
+ # see {Execution Environment}[rdoc-ref:Process@Execution+Environment].
+ #
+ # If the last argument is a hash, it becomes trailing argument +options+
+ # in the call to Open3.popen3;
+ # see {Execution Options}[rdoc-ref:Process@Execution+Options].
+ #
+ # The hash +options+ is given;
+ # two options have local effect in method Open3.capture2e:
+ #
+ # - If entry <tt>options[:stdin_data]</tt> exists, the entry is removed
+ # and its string value is sent to the command's standard input:
#
- # stdout_and_stderr_str, status = Open3.capture2e([env,] cmd... [, opts])
+ # Open3.capture2e('tee', stdin_data: 'Foo')
+ # # => ["Foo", #<Process::Status: pid 2371732 exit 0>]
#
- # The arguments env, cmd and opts are passed to Open3.popen3 except
- # <code>opts[:stdin_data]</code> and <code>opts[:binmode]</code>. See Process.spawn.
+ # - If entry <tt>options[:binmode]</tt> exists, the entry is removed and
+ # the internal streams are set to binary mode.
#
- # If <code>opts[:stdin_data]</code> is specified, it is sent to the command's standard input.
+ # The single required argument is one of the following:
#
- # If <code>opts[:binmode]</code> is true, internal pipes are set to binary mode.
+ # - +command_line+ if it is a string,
+ # and if it begins with a shell reserved word or special built-in,
+ # or if it contains one or more metacharacters.
+ # - +exe_path+ otherwise.
+ #
+ # <b>Argument +command_line+</b>
+ #
+ # \String argument +command_line+ is a command line to be passed to a shell;
+ # it must begin with a shell reserved word, begin with a special built-in,
+ # or contain meta characters:
+ #
+ # Open3.capture2e('if true; then echo "Foo"; fi') # Shell reserved word.
+ # # => ["Foo\n", #<Process::Status: pid 2371740 exit 0>]
+ # Open3.capture2e('echo') # Built-in.
+ # # => ["\n", #<Process::Status: pid 2371774 exit 0>]
+ # Open3.capture2e('date > date.tmp') # Contains meta character.
+ # # => ["", #<Process::Status: pid 2371812 exit 0>]
+ #
+ # The command line may also contain arguments and options for the command:
+ #
+ # Open3.capture2e('echo "Foo"')
+ # # => ["Foo\n", #<Process::Status: pid 2326183 exit 0>]
+ #
+ # <b>Argument +exe_path+</b>
+ #
+ # Argument +exe_path+ is one of the following:
+ #
+ # - The string path to an executable to be called.
+ # - A 2-element array containing the path to an executable
+ # and the string to be used as the name of the executing process.
#
# Example:
#
- # # capture make log
- # make_log, s = Open3.capture2e("make")
+ # Open3.capture2e('/usr/bin/date')
+ # # => ["Sat Sep 30 09:01:46 AM CDT 2023\n", #<Process::Status: pid 2371820 exit 0>]
+ #
+ # Ruby invokes the executable directly, with no shell and no shell expansion:
+ #
+ # Open3.capture2e('doesnt_exist') # Raises Errno::ENOENT
+ #
+ # If one or more +args+ is given, each is an argument or option
+ # to be passed to the executable:
+ #
+ # Open3.capture2e('echo', 'C #')
+ # # => ["C #\n", #<Process::Status: pid 2371856 exit 0>]
+ # Open3.capture2e('echo', 'hello', 'world')
+ # # => ["hello world\n", #<Process::Status: pid 2371894 exit 0>]
#
def capture2e(*cmd)
if Hash === cmd.last
@@ -418,48 +931,86 @@ module Open3
end
module_function :capture2e
- # Open3.pipeline_rw starts a list of commands as a pipeline with pipes
- # which connect to stdin of the first command and stdout of the last command.
- #
- # Open3.pipeline_rw(cmd1, cmd2, ... [, opts]) {|first_stdin, last_stdout, wait_threads|
- # ...
- # }
+ # :call-seq:
+ # Open3.pipeline_rw([env, ] *cmds, options = {}) -> [first_stdin, last_stdout, wait_threads]
#
- # first_stdin, last_stdout, wait_threads = Open3.pipeline_rw(cmd1, cmd2, ... [, opts])
- # ...
- # first_stdin.close
- # last_stdout.close
+ # Basically a wrapper for
+ # {Process.spawn}[rdoc-ref:Process.spawn]
+ # that:
#
- # Each cmd is a string or an array.
- # If it is an array, the elements are passed to Process.spawn.
+ # - Creates a child process for each of the given +cmds+
+ # by calling Process.spawn.
+ # - Pipes the +stdout+ from each child to the +stdin+ of the next child,
+ # or, for the first child, from the caller's +stdin+,
+ # or, for the last child, to the caller's +stdout+.
#
- # cmd:
- # commandline command line string which is passed to a shell
- # [env, commandline, opts] command line string which is passed to a shell
- # [env, cmdname, arg1, ..., opts] command name and one or more arguments (no shell)
- # [env, [cmdname, argv0], arg1, ..., opts] command name and arguments including argv[0] (no shell)
+ # The method does not wait for child processes to exit,
+ # so the caller must do so.
#
- # Note that env and opts are optional, as for Process.spawn.
+ # With no block given, returns a 3-element array containing:
#
- # The options to pass to Process.spawn are constructed by merging
- # +opts+, the last hash element of the array, and
- # specifications for the pipes between each of the commands.
+ # - The +stdin+ stream of the first child process.
+ # - The +stdout+ stream of the last child process.
+ # - An array of the wait threads for all of the child processes.
#
# Example:
#
- # Open3.pipeline_rw("tr -dc A-Za-z", "wc -c") {|i, o, ts|
- # i.puts "All persons more than a mile high to leave the court."
- # i.close
- # p o.gets #=> "42\n"
- # }
- #
- # Open3.pipeline_rw("sort", "cat -n") {|stdin, stdout, wait_thrs|
- # stdin.puts "foo"
- # stdin.puts "bar"
- # stdin.puts "baz"
- # stdin.close # send EOF to sort.
- # p stdout.read #=> " 1\tbar\n 2\tbaz\n 3\tfoo\n"
- # }
+ # first_stdin, last_stdout, wait_threads = Open3.pipeline_rw('sort', 'cat -n')
+ # # => [#<IO:fd 20>, #<IO:fd 21>, [#<Process::Waiter:0x000055e8de29ab40 sleep>, #<Process::Waiter:0x000055e8de29a690 sleep>]]
+ # first_stdin.puts("foo\nbar\nbaz")
+ # first_stdin.close # Send EOF to sort.
+ # puts last_stdout.read
+ # wait_threads.each do |wait_thread|
+ # wait_thread.join
+ # end
+ #
+ # Output:
+ #
+ # 1 bar
+ # 2 baz
+ # 3 foo
+ #
+ # With a block given, calls the block with the +stdin+ stream of the first child,
+ # the +stdout+ stream of the last child,
+ # and an array of the wait processes:
+ #
+ # Open3.pipeline_rw('sort', 'cat -n') do |first_stdin, last_stdout, wait_threads|
+ # first_stdin.puts "foo\nbar\nbaz"
+ # first_stdin.close # send EOF to sort.
+ # puts last_stdout.read
+ # wait_threads.each do |wait_thread|
+ # wait_thread.join
+ # end
+ # end
+ #
+ # Output:
+ #
+ # 1 bar
+ # 2 baz
+ # 3 foo
+ #
+ # Like Process.spawn, this method has potential security vulnerabilities
+ # if called with untrusted input;
+ # see {Command Injection}[rdoc-ref:command_injection.rdoc@Command+Injection].
+ #
+ # If the first argument is a hash, it becomes leading argument +env+
+ # in each call to Process.spawn;
+ # see {Execution Environment}[rdoc-ref:Process@Execution+Environment].
+ #
+ # If the last argument is a hash, it becomes trailing argument +options+
+ # in each call to Process.spawn;
+ # see {Execution Options}[rdoc-ref:Process@Execution+Options].
+ #
+ # Each remaining argument in +cmds+ is one of:
+ #
+ # - A +command_line+: a string that begins with a shell reserved word
+ # or special built-in, or contains one or more metacharacters.
+ # - An +exe_path+: the string path to an executable to be called.
+ # - An array containing a +command_line+ or an +exe_path+,
+ # along with zero or more string arguments for the command.
+ #
+ # See {Argument command_line or exe_path}[rdoc-ref:Process@Argument+command_line+or+exe_path].
+ #
def pipeline_rw(*cmds, &block)
if Hash === cmds.last
opts = cmds.pop.dup
@@ -478,43 +1029,77 @@ module Open3
end
module_function :pipeline_rw
- # Open3.pipeline_r starts a list of commands as a pipeline with a pipe
- # which connects to stdout of the last command.
+ # :call-seq:
+ # Open3.pipeline_r([env, ] *cmds, options = {}) -> [last_stdout, wait_threads]
#
- # Open3.pipeline_r(cmd1, cmd2, ... [, opts]) {|last_stdout, wait_threads|
- # ...
- # }
+ # Basically a wrapper for
+ # {Process.spawn}[rdoc-ref:Process.spawn]
+ # that:
#
- # last_stdout, wait_threads = Open3.pipeline_r(cmd1, cmd2, ... [, opts])
- # ...
- # last_stdout.close
+ # - Creates a child process for each of the given +cmds+
+ # by calling Process.spawn.
+ # - Pipes the +stdout+ from each child to the +stdin+ of the next child,
+ # or, for the last child, to the caller's +stdout+.
#
- # Each cmd is a string or an array.
- # If it is an array, the elements are passed to Process.spawn.
+ # The method does not wait for child processes to exit,
+ # so the caller must do so.
#
- # cmd:
- # commandline command line string which is passed to a shell
- # [env, commandline, opts] command line string which is passed to a shell
- # [env, cmdname, arg1, ..., opts] command name and one or more arguments (no shell)
- # [env, [cmdname, argv0], arg1, ..., opts] command name and arguments including argv[0] (no shell)
+ # With no block given, returns a 2-element array containing:
#
- # Note that env and opts are optional, as for Process.spawn.
+ # - The +stdout+ stream of the last child process.
+ # - An array of the wait threads for all of the child processes.
#
# Example:
#
- # Open3.pipeline_r("zcat /var/log/apache2/access.log.*.gz",
- # [{"LANG"=>"C"}, "grep", "GET /favicon.ico"],
- # "logresolve") {|o, ts|
- # o.each_line {|line|
- # ...
- # }
- # }
+ # last_stdout, wait_threads = Open3.pipeline_r('ls', 'grep R')
+ # # => [#<IO:fd 5>, [#<Process::Waiter:0x000055e8de2f9898 dead>, #<Process::Waiter:0x000055e8de2f94b0 sleep>]]
+ # puts last_stdout.read
+ # wait_threads.each do |wait_thread|
+ # wait_thread.join
+ # end
+ #
+ # Output:
+ #
+ # Rakefile
+ # README.md
+ #
+ # With a block given, calls the block with the +stdout+ stream
+ # of the last child process,
+ # and an array of the wait processes:
+ #
+ # Open3.pipeline_r('ls', 'grep R') do |last_stdout, wait_threads|
+ # puts last_stdout.read
+ # wait_threads.each do |wait_thread|
+ # wait_thread.join
+ # end
+ # end
+ #
+ # Output:
+ #
+ # Rakefile
+ # README.md
+ #
+ # Like Process.spawn, this method has potential security vulnerabilities
+ # if called with untrusted input;
+ # see {Command Injection}[rdoc-ref:command_injection.rdoc@Command+Injection].
+ #
+ # If the first argument is a hash, it becomes leading argument +env+
+ # in each call to Process.spawn;
+ # see {Execution Environment}[rdoc-ref:Process@Execution+Environment].
+ #
+ # If the last argument is a hash, it becomes trailing argument +options+
+ # in each call to Process.spawn;
+ # see {Execution Options}[rdoc-ref:Process@Execution+Options].
#
- # Open3.pipeline_r("yes", "head -10") {|o, ts|
- # p o.read #=> "y\ny\ny\ny\ny\ny\ny\ny\ny\ny\n"
- # p ts[0].value #=> #<Process::Status: pid 24910 SIGPIPE (signal 13)>
- # p ts[1].value #=> #<Process::Status: pid 24913 exit 0>
- # }
+ # Each remaining argument in +cmds+ is one of:
+ #
+ # - A +command_line+: a string that begins with a shell reserved word
+ # or special built-in, or contains one or more metacharacters.
+ # - An +exe_path+: the string path to an executable to be called.
+ # - An array containing a +command_line+ or an +exe_path+,
+ # along with zero or more string arguments for the command.
+ #
+ # See {Argument command_line or exe_path}[rdoc-ref:Process@Argument+command_line+or+exe_path].
#
def pipeline_r(*cmds, &block)
if Hash === cmds.last
@@ -530,33 +1115,82 @@ module Open3
end
module_function :pipeline_r
- # Open3.pipeline_w starts a list of commands as a pipeline with a pipe
- # which connects to stdin of the first command.
+
+ # :call-seq:
+ # Open3.pipeline_w([env, ] *cmds, options = {}) -> [first_stdin, wait_threads]
#
- # Open3.pipeline_w(cmd1, cmd2, ... [, opts]) {|first_stdin, wait_threads|
- # ...
- # }
+ # Basically a wrapper for
+ # {Process.spawn}[rdoc-ref:Process.spawn]
+ # that:
#
- # first_stdin, wait_threads = Open3.pipeline_w(cmd1, cmd2, ... [, opts])
- # ...
- # first_stdin.close
+ # - Creates a child process for each of the given +cmds+
+ # by calling Process.spawn.
+ # - Pipes the +stdout+ from each child to the +stdin+ of the next child,
+ # or, for the first child, pipes the caller's +stdout+ to the child's +stdin+.
#
- # Each cmd is a string or an array.
- # If it is an array, the elements are passed to Process.spawn.
+ # The method does not wait for child processes to exit,
+ # so the caller must do so.
#
- # cmd:
- # commandline command line string which is passed to a shell
- # [env, commandline, opts] command line string which is passed to a shell
- # [env, cmdname, arg1, ..., opts] command name and one or more arguments (no shell)
- # [env, [cmdname, argv0], arg1, ..., opts] command name and arguments including argv[0] (no shell)
+ # With no block given, returns a 2-element array containing:
#
- # Note that env and opts are optional, as for Process.spawn.
+ # - The +stdin+ stream of the first child process.
+ # - An array of the wait threads for all of the child processes.
#
# Example:
#
- # Open3.pipeline_w("bzip2 -c", :out=>"/tmp/hello.bz2") {|i, ts|
- # i.puts "hello"
- # }
+ # first_stdin, wait_threads = Open3.pipeline_w('sort', 'cat -n')
+ # # => [#<IO:fd 7>, [#<Process::Waiter:0x000055e8de928278 run>, #<Process::Waiter:0x000055e8de923e80 run>]]
+ # first_stdin.puts("foo\nbar\nbaz")
+ # first_stdin.close # Send EOF to sort.
+ # wait_threads.each do |wait_thread|
+ # wait_thread.join
+ # end
+ #
+ # Output:
+ #
+ # 1 bar
+ # 2 baz
+ # 3 foo
+ #
+ # With a block given, calls the block with the +stdin+ stream
+ # of the first child process,
+ # and an array of the wait processes:
+ #
+ # Open3.pipeline_w('sort', 'cat -n') do |first_stdin, wait_threads|
+ # first_stdin.puts("foo\nbar\nbaz")
+ # first_stdin.close # Send EOF to sort.
+ # wait_threads.each do |wait_thread|
+ # wait_thread.join
+ # end
+ # end
+ #
+ # Output:
+ #
+ # 1 bar
+ # 2 baz
+ # 3 foo
+ #
+ # Like Process.spawn, this method has potential security vulnerabilities
+ # if called with untrusted input;
+ # see {Command Injection}[rdoc-ref:command_injection.rdoc@Command+Injection].
+ #
+ # If the first argument is a hash, it becomes leading argument +env+
+ # in each call to Process.spawn;
+ # see {Execution Environment}[rdoc-ref:Process@Execution+Environment].
+ #
+ # If the last argument is a hash, it becomes trailing argument +options+
+ # in each call to Process.spawn;
+ # see {Execution Options}[rdoc-ref:Process@Execution+Options].
+ #
+ # Each remaining argument in +cmds+ is one of:
+ #
+ # - A +command_line+: a string that begins with a shell reserved word
+ # or special built-in, or contains one or more metacharacters.
+ # - An +exe_path+: the string path to an executable to be called.
+ # - An array containing a +command_line+ or an +exe_path+,
+ # along with zero or more string arguments for the command.
+ #
+ # See {Argument command_line or exe_path}[rdoc-ref:Process@Argument+command_line+or+exe_path].
#
def pipeline_w(*cmds, &block)
if Hash === cmds.last
@@ -573,49 +1207,67 @@ module Open3
end
module_function :pipeline_w
- # Open3.pipeline_start starts a list of commands as a pipeline.
- # No pipes are created for stdin of the first command and
- # stdout of the last command.
+ # :call-seq:
+ # Open3.pipeline_start([env, ] *cmds, options = {}) -> [wait_threads]
#
- # Open3.pipeline_start(cmd1, cmd2, ... [, opts]) {|wait_threads|
- # ...
- # }
+ # Basically a wrapper for
+ # {Process.spawn}[rdoc-ref:Process.spawn]
+ # that:
#
- # wait_threads = Open3.pipeline_start(cmd1, cmd2, ... [, opts])
- # ...
+ # - Creates a child process for each of the given +cmds+
+ # by calling Process.spawn.
+ # - Does not wait for child processes to exit.
#
- # Each cmd is a string or an array.
- # If it is an array, the elements are passed to Process.spawn.
+ # With no block given, returns an array of the wait threads
+ # for all of the child processes.
#
- # cmd:
- # commandline command line string which is passed to a shell
- # [env, commandline, opts] command line string which is passed to a shell
- # [env, cmdname, arg1, ..., opts] command name and one or more arguments (no shell)
- # [env, [cmdname, argv0], arg1, ..., opts] command name and arguments including argv[0] (no shell)
+ # Example:
#
- # Note that env and opts are optional, as for Process.spawn.
+ # wait_threads = Open3.pipeline_start('ls', 'grep R')
+ # # => [#<Process::Waiter:0x000055e8de9d2bb0 run>, #<Process::Waiter:0x000055e8de9d2890 run>]
+ # wait_threads.each do |wait_thread|
+ # wait_thread.join
+ # end
#
- # Example:
+ # Output:
+ #
+ # Rakefile
+ # README.md
+ #
+ # With a block given, calls the block with an array of the wait processes:
+ #
+ # Open3.pipeline_start('ls', 'grep R') do |wait_threads|
+ # wait_threads.each do |wait_thread|
+ # wait_thread.join
+ # end
+ # end
+ #
+ # Output:
+ #
+ # Rakefile
+ # README.md
#
- # # Run xeyes in 10 seconds.
- # Open3.pipeline_start("xeyes") {|ts|
- # sleep 10
- # t = ts[0]
- # Process.kill("TERM", t.pid)
- # p t.value #=> #<Process::Status: pid 911 SIGTERM (signal 15)>
- # }
- #
- # # Convert pdf to ps and send it to a printer.
- # # Collect error message of pdftops and lpr.
- # pdf_file = "paper.pdf"
- # printer = "printer-name"
- # err_r, err_w = IO.pipe
- # Open3.pipeline_start(["pdftops", pdf_file, "-"],
- # ["lpr", "-P#{printer}"],
- # :err=>err_w) {|ts|
- # err_w.close
- # p err_r.read # error messages of pdftops and lpr.
- # }
+ # Like Process.spawn, this method has potential security vulnerabilities
+ # if called with untrusted input;
+ # see {Command Injection}[rdoc-ref:command_injection.rdoc@Command+Injection].
+ #
+ # If the first argument is a hash, it becomes leading argument +env+
+ # in each call to Process.spawn;
+ # see {Execution Environment}[rdoc-ref:Process@Execution+Environment].
+ #
+ # If the last argument is a hash, it becomes trailing argument +options+
+ # in each call to Process.spawn;
+ # see {Execution Options}[rdoc-ref:Process@Execution+Options].
+ #
+ # Each remaining argument in +cmds+ is one of:
+ #
+ # - A +command_line+: a string that begins with a shell reserved word
+ # or special built-in, or contains one or more metacharacters.
+ # - An +exe_path+: the string path to an executable to be called.
+ # - An array containing a +command_line+ or an +exe_path+,
+ # along with zero or more string arguments for the command.
+ #
+ # See {Argument command_line or exe_path}[rdoc-ref:Process@Argument+command_line+or+exe_path].
#
def pipeline_start(*cmds, &block)
if Hash === cmds.last
@@ -633,57 +1285,51 @@ module Open3
end
module_function :pipeline_start
- # Open3.pipeline starts a list of commands as a pipeline.
- # It waits for the completion of the commands.
- # No pipes are created for stdin of the first command and
- # stdout of the last command.
+ # :call-seq:
+ # Open3.pipeline([env, ] *cmds, options = {}) -> array_of_statuses
#
- # status_list = Open3.pipeline(cmd1, cmd2, ... [, opts])
+ # Basically a wrapper for
+ # {Process.spawn}[rdoc-ref:Process.spawn]
+ # that:
#
- # Each cmd is a string or an array.
- # If it is an array, the elements are passed to Process.spawn.
+ # - Creates a child process for each of the given +cmds+
+ # by calling Process.spawn.
+ # - Pipes the +stdout+ from each child to the +stdin+ of the next child,
+ # or, for the last child, to the caller's +stdout+.
+ # - Waits for the child processes to exit.
+ # - Returns an array of Process::Status objects (one for each child).
#
- # cmd:
- # commandline command line string which is passed to a shell
- # [env, commandline, opts] command line string which is passed to a shell
- # [env, cmdname, arg1, ..., opts] command name and one or more arguments (no shell)
- # [env, [cmdname, argv0], arg1, ..., opts] command name and arguments including argv[0] (no shell)
+ # Example:
#
- # Note that env and opts are optional, as Process.spawn.
+ # wait_threads = Open3.pipeline('ls', 'grep R')
+ # # => [#<Process::Status: pid 2139200 exit 0>, #<Process::Status: pid 2139202 exit 0>]
#
- # Example:
+ # Output:
+ #
+ # Rakefile
+ # README.md
+ #
+ # Like Process.spawn, this method has potential security vulnerabilities
+ # if called with untrusted input;
+ # see {Command Injection}[rdoc-ref:command_injection.rdoc@Command+Injection].
+ #
+ # If the first argument is a hash, it becomes leading argument +env+
+ # in each call to Process.spawn;
+ # see {Execution Environment}[rdoc-ref:Process@Execution+Environment].
+ #
+ # If the last argument is a hash, it becomes trailing argument +options+
+ # in each call to Process.spawn'
+ # see {Execution Options}[rdoc-ref:Process@Execution+Options].
+ #
+ # Each remaining argument in +cmds+ is one of:
+ #
+ # - A +command_line+: a string that begins with a shell reserved word
+ # or special built-in, or contains one or more metacharacters.
+ # - An +exe_path+: the string path to an executable to be called.
+ # - An array containing a +command_line+ or an +exe_path+,
+ # along with zero or more string arguments for the command.
#
- # fname = "/usr/share/man/man1/ruby.1.gz"
- # p Open3.pipeline(["zcat", fname], "nroff -man", "less")
- # #=> [#<Process::Status: pid 11817 exit 0>,
- # # #<Process::Status: pid 11820 exit 0>,
- # # #<Process::Status: pid 11828 exit 0>]
- #
- # fname = "/usr/share/man/man1/ls.1.gz"
- # Open3.pipeline(["zcat", fname], "nroff -man", "colcrt")
- #
- # # convert PDF to PS and send to a printer by lpr
- # pdf_file = "paper.pdf"
- # printer = "printer-name"
- # Open3.pipeline(["pdftops", pdf_file, "-"],
- # ["lpr", "-P#{printer}"])
- #
- # # count lines
- # Open3.pipeline("sort", "uniq -c", :in=>"names.txt", :out=>"count")
- #
- # # cyclic pipeline
- # r,w = IO.pipe
- # w.print "ibase=14\n10\n"
- # Open3.pipeline("bc", "tee /dev/tty", :in=>r, :out=>w)
- # #=> 14
- # # 18
- # # 22
- # # 30
- # # 42
- # # 58
- # # 78
- # # 106
- # # 202
+ # See {Argument command_line or exe_path}[rdoc-ref:Process@Argument+command_line+or+exe_path].
#
def pipeline(*cmds)
if Hash === cmds.last
diff --git a/lib/open3/open3.gemspec b/lib/open3/open3.gemspec
index a33fca7444..21980decac 100644
--- a/lib/open3/open3.gemspec
+++ b/lib/open3/open3.gemspec
@@ -25,7 +25,7 @@ Gem::Specification.new do |spec|
# Specify which files should be added to the gem when it is released.
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
- `git ls-files -z 2>/dev/null`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
+ `git ls-files -z 2>#{IO::NULL}`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
end
spec.bindir = "exe"
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
diff --git a/lib/open3/version.rb b/lib/open3/version.rb
index b6b6ee2c9c..bfcec44ccc 100644
--- a/lib/open3/version.rb
+++ b/lib/open3/version.rb
@@ -1,3 +1,3 @@
module Open3
- VERSION = "0.1.2"
+ VERSION = "0.2.1"
end
diff --git a/lib/optparse.rb b/lib/optparse.rb
index 7e0479bfff..832b928a2d 100644
--- a/lib/optparse.rb
+++ b/lib/optparse.rb
@@ -48,7 +48,7 @@
#
# == OptionParser
#
-# === New to \OptionParser?
+# === New to +OptionParser+?
#
# See the {Tutorial}[optparse/tutorial.rdoc].
#
@@ -152,14 +152,14 @@
# OptionParser supports the ability to coerce command line arguments
# into objects for us.
#
-# OptionParser comes with a few ready-to-use kinds of type
+# OptionParser comes with a few ready-to-use kinds of type
# coercion. They are:
#
-# - Date -- Anything accepted by +Date.parse+
-# - DateTime -- Anything accepted by +DateTime.parse+
-# - Time -- Anything accepted by +Time.httpdate+ or +Time.parse+
-# - URI -- Anything accepted by +URI.parse+
-# - Shellwords -- Anything accepted by +Shellwords.shellwords+
+# - Date -- Anything accepted by +Date.parse+ (need to require +optparse/date+)
+# - DateTime -- Anything accepted by +DateTime.parse+ (need to require +optparse/date+)
+# - Time -- Anything accepted by +Time.httpdate+ or +Time.parse+ (need to require +optparse/time+)
+# - URI -- Anything accepted by +URI.parse+ (need to require +optparse/uri+)
+# - Shellwords -- Anything accepted by +Shellwords.shellwords+ (need to require +optparse/shellwords+)
# - String -- Any non-empty string
# - Integer -- Any integer. Will convert octal. (e.g. 124, -3, 040)
# - Float -- Any float. (e.g. 10, 3.14, -100E+13)
@@ -425,7 +425,7 @@
# If you have any questions, file a ticket at http://bugs.ruby-lang.org.
#
class OptionParser
- OptionParser::Version = "0.4.0.pre.1"
+ OptionParser::Version = "0.4.0"
# :stopdoc:
NoArgument = [NO_ARGUMENT = :NONE, nil].freeze
diff --git a/lib/ostruct.gemspec b/lib/ostruct.gemspec
new file mode 100644
index 0000000000..08a7aefb05
--- /dev/null
+++ b/lib/ostruct.gemspec
@@ -0,0 +1,24 @@
+# frozen_string_literal: true
+
+name = File.basename(__FILE__, ".gemspec")
+version = ["lib", Array.new(name.count("-")+1, ".").join("/")].find do |dir|
+ break File.foreach(File.join(__dir__, dir, "#{name.tr('-', '/')}.rb")) do |line|
+ /^\s*VERSION\s*=\s*"(.*)"/ =~ line and break $1
+ end rescue nil
+end
+
+Gem::Specification.new do |spec|
+ spec.name = name
+ spec.version = version
+ spec.authors = ["Marc-Andre Lafortune"]
+ spec.email = ["ruby-core@marc-andre.ca"]
+
+ spec.summary = %q{Class to build custom data structures, similar to a Hash.}
+ spec.description = %q{Class to build custom data structures, similar to a Hash.}
+ spec.homepage = "https://github.com/ruby/ostruct"
+ spec.licenses = ["Ruby", "BSD-2-Clause"]
+ spec.required_ruby_version = ">= 2.5.0"
+
+ spec.files = [".gitignore", "Gemfile", "LICENSE.txt", "README.md", "Rakefile", "bin/console", "bin/setup", "lib/ostruct.rb", "ostruct.gemspec"]
+ spec.require_paths = ["lib"]
+end
diff --git a/lib/ostruct.rb b/lib/ostruct.rb
index a08561d6c9..fa882b7b9b 100644
--- a/lib/ostruct.rb
+++ b/lib/ostruct.rb
@@ -107,7 +107,15 @@
# For all these reasons, consider not using OpenStruct at all.
#
class OpenStruct
- VERSION = "0.5.5"
+ VERSION = "0.6.0"
+
+ HAS_PERFORMANCE_WARNINGS = begin
+ Warning[:performance]
+ true
+ rescue NoMethodError, ArgumentError
+ false
+ end
+ private_constant :HAS_PERFORMANCE_WARNINGS
#
# Creates a new OpenStruct object. By default, the resulting OpenStruct
@@ -124,6 +132,10 @@ class OpenStruct
# data # => #<OpenStruct country="Australia", capital="Canberra">
#
def initialize(hash=nil)
+ if HAS_PERFORMANCE_WARNINGS && Warning[:performance]
+ warn "OpenStruct use is discouraged for performance reasons", uplevel: 1, category: :performance
+ end
+
if hash
update_to_values!(hash)
else
diff --git a/lib/ostruct/ostruct.gemspec b/lib/ostruct/ostruct.gemspec
deleted file mode 100644
index 31ecc312c3..0000000000
--- a/lib/ostruct/ostruct.gemspec
+++ /dev/null
@@ -1,27 +0,0 @@
-# frozen_string_literal: true
-
-name = File.basename(__FILE__, ".gemspec")
-version = ["lib", Array.new(name.count("-")+1, "..").join("/")].find do |dir|
- break File.foreach(File.join(__dir__, dir, "#{name.tr('-', '/')}.rb")) do |line|
- /^\s*VERSION\s*=\s*"(.*)"/ =~ line and break $1
- end rescue nil
-end
-
-Gem::Specification.new do |spec|
- spec.name = name
- spec.version = version
- spec.authors = ["Marc-Andre Lafortune"]
- spec.email = ["ruby-core@marc-andre.ca"]
-
- spec.summary = %q{Class to build custom data structures, similar to a Hash.}
- spec.description = %q{Class to build custom data structures, similar to a Hash.}
- spec.homepage = "https://github.com/ruby/ostruct"
- spec.licenses = ["Ruby", "BSD-2-Clause"]
- spec.required_ruby_version = ">= 2.5.0"
-
- spec.files = [".gitignore", "Gemfile", "LICENSE.txt", "README.md", "Rakefile", "bin/console", "bin/setup", "lib/ostruct.rb", "ostruct.gemspec"]
- spec.require_paths = ["lib"]
-
- spec.add_development_dependency "bundler"
- spec.add_development_dependency "rake"
-end
diff --git a/lib/pp.gemspec b/lib/pp.gemspec
index 3f08f400c4..27a92a8ce4 100644
--- a/lib/pp.gemspec
+++ b/lib/pp.gemspec
@@ -1,6 +1,13 @@
+name = File.basename(__FILE__, ".gemspec")
+version = ["lib", Array.new(name.count("-")+1).join("/")].find do |dir|
+ break File.foreach(File.join(__dir__, dir, "#{name.tr('-', '/')}.rb")) do |line|
+ /^\s*VERSION\s*=\s*"(.*)"/ =~ line and break $1
+ end rescue nil
+end
+
Gem::Specification.new do |spec|
- spec.name = "pp"
- spec.version = "0.4.0"
+ spec.name = name
+ spec.version = version
spec.authors = ["Tanaka Akira"]
spec.email = ["akr@fsij.org"]
diff --git a/lib/pp.rb b/lib/pp.rb
index 81551aa116..1708dee05e 100644
--- a/lib/pp.rb
+++ b/lib/pp.rb
@@ -46,6 +46,7 @@ require 'prettyprint'
#
# To define a customized pretty printing function for your classes,
# redefine method <code>#pretty_print(pp)</code> in the class.
+# Note that <code>require 'pp'</code> is needed before redefining <code>#pretty_print(pp)</code>.
#
# <code>#pretty_print</code> takes the +pp+ argument, which is an instance of the PP class.
# The method uses #text, #breakable, #nest, #group and #pp to print the
@@ -61,6 +62,9 @@ require 'prettyprint'
# Tanaka Akira <akr@fsij.org>
class PP < PrettyPrint
+
+ VERSION = "0.5.0"
+
# Returns the usable width for +out+.
# As the width of +out+:
# 1. If +out+ is assigned to a tty device, its width is used.
@@ -629,10 +633,6 @@ end
module Kernel
# Returns a pretty printed object as a string.
#
- # In order to use this method you must first require the PP module:
- #
- # require 'pp'
- #
# See the PP module for more information.
def pretty_inspect
PP.pp(self, ''.dup)
diff --git a/lib/prettyprint.gemspec b/lib/prettyprint.gemspec
index eae2227d60..a18adb174b 100644
--- a/lib/prettyprint.gemspec
+++ b/lib/prettyprint.gemspec
@@ -1,6 +1,13 @@
+name = File.basename(__FILE__, ".gemspec")
+version = ["lib", Array.new(name.count("-")+1).join("/")].find do |dir|
+ break File.foreach(File.join(__dir__, dir, "#{name.tr('-', '/')}.rb")) do |line|
+ /^\s*VERSION\s*=\s*"(.*)"/ =~ line and break $1
+ end rescue nil
+end
+
Gem::Specification.new do |spec|
- spec.name = "prettyprint"
- spec.version = "0.1.1"
+ spec.name = name
+ spec.version = version
spec.authors = ["Tanaka Akira"]
spec.email = ["akr@fsij.org"]
diff --git a/lib/prettyprint.rb b/lib/prettyprint.rb
index 188c2e6db0..6f50192f5d 100644
--- a/lib/prettyprint.rb
+++ b/lib/prettyprint.rb
@@ -23,16 +23,18 @@
#
# == References
# Christian Lindig, Strictly Pretty, March 2000,
-# http://www.st.cs.uni-sb.de/~lindig/papers/#pretty
+# https://lindig.github.io/papers/strictly-pretty-2000.pdf
#
# Philip Wadler, A prettier printer, March 1998,
-# http://homepages.inf.ed.ac.uk/wadler/topics/language-design.html#prettier
+# https://homepages.inf.ed.ac.uk/wadler/topics/language-design.html#prettier
#
# == Author
# Tanaka Akira <akr@fsij.org>
#
class PrettyPrint
+ VERSION = "0.2.0"
+
# This is a convenience method which is same as follows:
#
# begin
diff --git a/lib/prism.rb b/lib/prism.rb
new file mode 100644
index 0000000000..e44d163d02
--- /dev/null
+++ b/lib/prism.rb
@@ -0,0 +1,99 @@
+# frozen_string_literal: true
+
+# The Prism Ruby parser.
+#
+# "Parsing Ruby is suddenly manageable!"
+# - You, hopefully
+#
+module Prism
+ # There are many files in prism that are templated to handle every node type,
+ # which means the files can end up being quite large. We autoload them to make
+ # our require speed faster since consuming libraries are unlikely to use all
+ # of these features.
+
+ autoload :BasicVisitor, "prism/visitor"
+ autoload :Compiler, "prism/compiler"
+ autoload :Debug, "prism/debug"
+ autoload :DesugarCompiler, "prism/desugar_compiler"
+ autoload :Dispatcher, "prism/dispatcher"
+ autoload :DotVisitor, "prism/dot_visitor"
+ autoload :DSL, "prism/dsl"
+ autoload :LexCompat, "prism/lex_compat"
+ autoload :LexRipper, "prism/lex_compat"
+ autoload :MutationCompiler, "prism/mutation_compiler"
+ autoload :NodeInspector, "prism/node_inspector"
+ autoload :RipperCompat, "prism/ripper_compat"
+ autoload :Pack, "prism/pack"
+ autoload :Pattern, "prism/pattern"
+ autoload :Serialize, "prism/serialize"
+ autoload :Visitor, "prism/visitor"
+
+ # Some of these constants are not meant to be exposed, so marking them as
+ # private here.
+
+ private_constant :Debug
+ private_constant :LexCompat
+ private_constant :LexRipper
+
+ # :call-seq:
+ # Prism::lex_compat(source, **options) -> ParseResult
+ #
+ # Returns a parse result whose value is an array of tokens that closely
+ # resembles the return value of Ripper::lex. The main difference is that the
+ # `:on_sp` token is not emitted.
+ #
+ # For supported options, see Prism::parse.
+ def self.lex_compat(source, **options)
+ LexCompat.new(source, **options).result
+ end
+
+ # :call-seq:
+ # Prism::lex_ripper(source) -> Array
+ #
+ # This lexes with the Ripper lex. It drops any space events but otherwise
+ # returns the same tokens. Raises SyntaxError if the syntax in source is
+ # invalid.
+ def self.lex_ripper(source)
+ LexRipper.new(source).result
+ end
+
+ # :call-seq:
+ # Prism::load(source, serialized) -> ParseResult
+ #
+ # Load the serialized AST using the source as a reference into a tree.
+ def self.load(source, serialized)
+ Serialize.load(source, serialized)
+ end
+
+ # :call-seq:
+ # Prism::parse_failure?(source, **options) -> bool
+ #
+ # Returns true if the source parses with errors.
+ def self.parse_failure?(source, **options)
+ !parse_success?(source, **options)
+ end
+
+ # :call-seq:
+ # Prism::parse_file_failure?(filepath, **options) -> bool
+ #
+ # Returns true if the file at filepath parses with errors.
+ def self.parse_file_failure?(filepath, **options)
+ !parse_file_success?(filepath, **options)
+ end
+end
+
+require_relative "prism/node"
+require_relative "prism/node_ext"
+require_relative "prism/parse_result"
+require_relative "prism/parse_result/comments"
+require_relative "prism/parse_result/newlines"
+
+# This is a Ruby implementation of the prism parser. If we're running on CRuby
+# and we haven't explicitly set the PRISM_FFI_BACKEND environment variable, then
+# it's going to require the built library. Otherwise, it's going to require a
+# module that uses FFI to call into the library.
+if RUBY_ENGINE == "ruby" and !ENV["PRISM_FFI_BACKEND"]
+ require "prism/prism"
+else
+ require_relative "prism/ffi"
+end
diff --git a/lib/prism/debug.rb b/lib/prism/debug.rb
new file mode 100644
index 0000000000..e275fe1dff
--- /dev/null
+++ b/lib/prism/debug.rb
@@ -0,0 +1,200 @@
+# frozen_string_literal: true
+
+module Prism
+ # This module is used for testing and debugging and is not meant to be used by
+ # consumers of this library.
+ module Debug
+ # A wrapper around a RubyVM::InstructionSequence that provides a more
+ # convenient interface for accessing parts of the iseq.
+ class ISeq # :nodoc:
+ attr_reader :parts
+
+ def initialize(parts)
+ @parts = parts
+ end
+
+ def type
+ parts[0]
+ end
+
+ def local_table
+ parts[10]
+ end
+
+ def instructions
+ parts[13]
+ end
+
+ def each_child
+ instructions.each do |instruction|
+ # Only look at arrays. Other instructions are line numbers or
+ # tracepoint events.
+ next unless instruction.is_a?(Array)
+
+ instruction.each do |opnd|
+ # Only look at arrays. Other operands are literals.
+ next unless opnd.is_a?(Array)
+
+ # Only look at instruction sequences. Other operands are literals.
+ next unless opnd[0] == "YARVInstructionSequence/SimpleDataFormat"
+
+ yield ISeq.new(opnd)
+ end
+ end
+ end
+ end
+
+ private_constant :ISeq
+
+ # :call-seq:
+ # Debug::cruby_locals(source) -> Array
+ #
+ # For the given source, compiles with CRuby and returns a list of all of the
+ # sets of local variables that were encountered.
+ def self.cruby_locals(source)
+ verbose, $VERBOSE = $VERBOSE, nil
+
+ begin
+ locals = []
+ stack = [ISeq.new(RubyVM::InstructionSequence.compile(source).to_a)]
+
+ while (iseq = stack.pop)
+ names = [*iseq.local_table]
+ names.map!.with_index do |name, index|
+ # When an anonymous local variable is present in the iseq's local
+ # table, it is represented as the stack offset from the top.
+ # However, when these are dumped to binary and read back in, they
+ # are replaced with the symbol :#arg_rest. To consistently handle
+ # this, we replace them here with their index.
+ if name == :"#arg_rest"
+ names.length - index + 1
+ else
+ name
+ end
+ end
+
+ locals << names
+ iseq.each_child { |child| stack << child }
+ end
+
+ locals
+ ensure
+ $VERBOSE = verbose
+ end
+ end
+
+ # Used to hold the place of a local that will be in the local table but
+ # cannot be accessed directly from the source code. For example, the
+ # iteration variable in a for loop or the positional parameter on a method
+ # definition that is destructured.
+ AnonymousLocal = Object.new
+ private_constant :AnonymousLocal
+
+ # :call-seq:
+ # Debug::prism_locals(source) -> Array
+ #
+ # For the given source, parses with prism and returns a list of all of the
+ # sets of local variables that were encountered.
+ def self.prism_locals(source)
+ locals = []
+ stack = [Prism.parse(source).value]
+
+ while (node = stack.pop)
+ case node
+ when BlockNode, DefNode, LambdaNode
+ names = node.locals
+ params =
+ if node.is_a?(DefNode)
+ node.parameters
+ elsif node.parameters.is_a?(NumberedParametersNode)
+ nil
+ else
+ node.parameters&.parameters
+ end
+
+ # prism places parameters in the same order that they appear in the
+ # source. CRuby places them in the order that they need to appear
+ # according to their own internal calling convention. We mimic that
+ # order here so that we can compare properly.
+ if params
+ sorted = [
+ *params.requireds.map do |required|
+ if required.is_a?(RequiredParameterNode)
+ required.name
+ else
+ AnonymousLocal
+ end
+ end,
+ *params.optionals.map(&:name),
+ *((params.rest.name || :*) if params.rest && !params.rest.is_a?(ImplicitRestNode)),
+ *params.posts.map do |post|
+ if post.is_a?(RequiredParameterNode)
+ post.name
+ else
+ AnonymousLocal
+ end
+ end,
+ *params.keywords.grep(RequiredKeywordParameterNode).map(&:name),
+ *params.keywords.grep(OptionalKeywordParameterNode).map(&:name),
+ ]
+
+ if params.keyword_rest.is_a?(ForwardingParameterNode)
+ sorted.push(:*, :&, :"...")
+ end
+
+ sorted << AnonymousLocal if params.keywords.any?
+
+ # Recurse down the parameter tree to find any destructured
+ # parameters and add them after the other parameters.
+ param_stack = params.requireds.concat(params.posts).grep(MultiTargetNode).reverse
+ while (param = param_stack.pop)
+ case param
+ when MultiTargetNode
+ param_stack.concat(param.rights.reverse)
+ param_stack << param.rest
+ param_stack.concat(param.lefts.reverse)
+ when RequiredParameterNode
+ sorted << param.name
+ when SplatNode
+ sorted << param.expression.name if param.expression
+ end
+ end
+
+ names = sorted.concat(names - sorted)
+ end
+
+ names.map!.with_index do |name, index|
+ if name == AnonymousLocal
+ names.length - index + 1
+ else
+ name
+ end
+ end
+
+ locals << names
+ when ClassNode, ModuleNode, ProgramNode, SingletonClassNode
+ locals << node.locals
+ when ForNode
+ locals << [2]
+ when PostExecutionNode
+ locals.push([], [])
+ when InterpolatedRegularExpressionNode
+ locals << [] if node.once?
+ end
+
+ stack.concat(node.compact_child_nodes)
+ end
+
+ locals
+ end
+
+ # :call-seq:
+ # Debug::newlines(source) -> Array
+ #
+ # For the given source string, return the byte offsets of every newline in
+ # the source.
+ def self.newlines(source)
+ Prism.parse(source).source.offsets
+ end
+ end
+end
diff --git a/lib/prism/desugar_compiler.rb b/lib/prism/desugar_compiler.rb
new file mode 100644
index 0000000000..daca02f35e
--- /dev/null
+++ b/lib/prism/desugar_compiler.rb
@@ -0,0 +1,207 @@
+# frozen_string_literal: true
+
+module Prism
+ # DesugarCompiler is a compiler that desugars Ruby code into a more primitive
+ # form. This is useful for consumers that want to deal with fewer node types.
+ class DesugarCompiler < MutationCompiler
+ # @@foo &&= bar
+ #
+ # becomes
+ #
+ # @@foo && @@foo = bar
+ def visit_class_variable_and_write_node(node)
+ desugar_and_write_node(node, ClassVariableReadNode, ClassVariableWriteNode, node.name)
+ end
+
+ # @@foo ||= bar
+ #
+ # becomes
+ #
+ # defined?(@@foo) ? @@foo : @@foo = bar
+ def visit_class_variable_or_write_node(node)
+ desugar_or_write_defined_node(node, ClassVariableReadNode, ClassVariableWriteNode, node.name)
+ end
+
+ # @@foo += bar
+ #
+ # becomes
+ #
+ # @@foo = @@foo + bar
+ def visit_class_variable_operator_write_node(node)
+ desugar_operator_write_node(node, ClassVariableReadNode, ClassVariableWriteNode, node.name)
+ end
+
+ # Foo &&= bar
+ #
+ # becomes
+ #
+ # Foo && Foo = bar
+ def visit_constant_and_write_node(node)
+ desugar_and_write_node(node, ConstantReadNode, ConstantWriteNode, node.name)
+ end
+
+ # Foo ||= bar
+ #
+ # becomes
+ #
+ # defined?(Foo) ? Foo : Foo = bar
+ def visit_constant_or_write_node(node)
+ desugar_or_write_defined_node(node, ConstantReadNode, ConstantWriteNode, node.name)
+ end
+
+ # Foo += bar
+ #
+ # becomes
+ #
+ # Foo = Foo + bar
+ def visit_constant_operator_write_node(node)
+ desugar_operator_write_node(node, ConstantReadNode, ConstantWriteNode, node.name)
+ end
+
+ # $foo &&= bar
+ #
+ # becomes
+ #
+ # $foo && $foo = bar
+ def visit_global_variable_and_write_node(node)
+ desugar_and_write_node(node, GlobalVariableReadNode, GlobalVariableWriteNode, node.name)
+ end
+
+ # $foo ||= bar
+ #
+ # becomes
+ #
+ # defined?($foo) ? $foo : $foo = bar
+ def visit_global_variable_or_write_node(node)
+ desugar_or_write_defined_node(node, GlobalVariableReadNode, GlobalVariableWriteNode, node.name)
+ end
+
+ # $foo += bar
+ #
+ # becomes
+ #
+ # $foo = $foo + bar
+ def visit_global_variable_operator_write_node(node)
+ desugar_operator_write_node(node, GlobalVariableReadNode, GlobalVariableWriteNode, node.name)
+ end
+
+ # @foo &&= bar
+ #
+ # becomes
+ #
+ # @foo && @foo = bar
+ def visit_instance_variable_and_write_node(node)
+ desugar_and_write_node(node, InstanceVariableReadNode, InstanceVariableWriteNode, node.name)
+ end
+
+ # @foo ||= bar
+ #
+ # becomes
+ #
+ # @foo || @foo = bar
+ def visit_instance_variable_or_write_node(node)
+ desugar_or_write_node(node, InstanceVariableReadNode, InstanceVariableWriteNode, node.name)
+ end
+
+ # @foo += bar
+ #
+ # becomes
+ #
+ # @foo = @foo + bar
+ def visit_instance_variable_operator_write_node(node)
+ desugar_operator_write_node(node, InstanceVariableReadNode, InstanceVariableWriteNode, node.name)
+ end
+
+ # foo &&= bar
+ #
+ # becomes
+ #
+ # foo && foo = bar
+ def visit_local_variable_and_write_node(node)
+ desugar_and_write_node(node, LocalVariableReadNode, LocalVariableWriteNode, node.name, node.depth)
+ end
+
+ # foo ||= bar
+ #
+ # becomes
+ #
+ # foo || foo = bar
+ def visit_local_variable_or_write_node(node)
+ desugar_or_write_node(node, LocalVariableReadNode, LocalVariableWriteNode, node.name, node.depth)
+ end
+
+ # foo += bar
+ #
+ # becomes
+ #
+ # foo = foo + bar
+ def visit_local_variable_operator_write_node(node)
+ desugar_operator_write_node(node, LocalVariableReadNode, LocalVariableWriteNode, node.name, node.depth)
+ end
+
+ private
+
+ # Desugar `x &&= y` to `x && x = y`
+ def desugar_and_write_node(node, read_class, write_class, *arguments)
+ AndNode.new(
+ read_class.new(*arguments, node.name_loc),
+ write_class.new(*arguments, node.name_loc, node.value, node.operator_loc, node.location),
+ node.operator_loc,
+ node.location
+ )
+ end
+
+ # Desugar `x += y` to `x = x + y`
+ def desugar_operator_write_node(node, read_class, write_class, *arguments)
+ write_class.new(
+ *arguments,
+ node.name_loc,
+ CallNode.new(
+ 0,
+ read_class.new(*arguments, node.name_loc),
+ nil,
+ node.operator_loc.slice.chomp("="),
+ node.operator_loc.copy(length: node.operator_loc.length - 1),
+ nil,
+ ArgumentsNode.new(0, [node.value], node.value.location),
+ nil,
+ nil,
+ node.location
+ ),
+ node.operator_loc.copy(start_offset: node.operator_loc.end_offset - 1, length: 1),
+ node.location
+ )
+ end
+
+ # Desugar `x ||= y` to `x || x = y`
+ def desugar_or_write_node(node, read_class, write_class, *arguments)
+ OrNode.new(
+ read_class.new(*arguments, node.name_loc),
+ write_class.new(*arguments, node.name_loc, node.value, node.operator_loc, node.location),
+ node.operator_loc,
+ node.location
+ )
+ end
+
+ # Desugar `x ||= y` to `defined?(x) ? x : x = y`
+ def desugar_or_write_defined_node(node, read_class, write_class, *arguments)
+ IfNode.new(
+ node.operator_loc,
+ DefinedNode.new(nil, read_class.new(*arguments, node.name_loc), nil, node.operator_loc, node.name_loc),
+ node.operator_loc,
+ StatementsNode.new([read_class.new(*arguments, node.name_loc)], node.location),
+ ElseNode.new(
+ node.operator_loc,
+ StatementsNode.new(
+ [write_class.new(*arguments, node.name_loc, node.value, node.operator_loc, node.location)],
+ node.location
+ ),
+ node.operator_loc,
+ node.location
+ ),
+ node.operator_loc,
+ node.location
+ )
+ end
+ end
+end
diff --git a/lib/prism/ffi.rb b/lib/prism/ffi.rb
new file mode 100644
index 0000000000..8324f722a7
--- /dev/null
+++ b/lib/prism/ffi.rb
@@ -0,0 +1,341 @@
+# frozen_string_literal: true
+
+# This file is responsible for mirroring the API provided by the C extension by
+# using FFI to call into the shared library.
+
+require "rbconfig"
+require "ffi"
+
+module Prism
+ BACKEND = :FFI
+
+ module LibRubyParser # :nodoc:
+ extend FFI::Library
+
+ # Define the library that we will be pulling functions from. Note that this
+ # must align with the build shared library from make/rake.
+ ffi_lib File.expand_path("../../build/libprism.#{RbConfig::CONFIG["SOEXT"]}", __dir__)
+
+ # Convert a native C type declaration into a symbol that FFI understands.
+ # For example:
+ #
+ # const char * -> :pointer
+ # bool -> :bool
+ # size_t -> :size_t
+ # void -> :void
+ #
+ def self.resolve_type(type)
+ type = type.strip
+ type.end_with?("*") ? :pointer : type.delete_prefix("const ").to_sym
+ end
+
+ # Read through the given header file and find the declaration of each of the
+ # given functions. For each one, define a function with the same name and
+ # signature as the C function.
+ def self.load_exported_functions_from(header, *functions)
+ File.foreach(File.expand_path("../../include/#{header}", __dir__)) do |line|
+ # We only want to attempt to load exported functions.
+ next unless line.start_with?("PRISM_EXPORTED_FUNCTION ")
+
+ # We only want to load the functions that we are interested in.
+ next unless functions.any? { |function| line.include?(function) }
+
+ # Parse the function declaration.
+ unless /^PRISM_EXPORTED_FUNCTION (?<return_type>.+) (?<name>\w+)\((?<arg_types>.+)\);$/ =~ line
+ raise "Could not parse #{line}"
+ end
+
+ # Delete the function from the list of functions we are looking for to
+ # mark it as having been found.
+ functions.delete(name)
+
+ # Split up the argument types into an array, ensure we handle the case
+ # where there are no arguments (by explicit void).
+ arg_types = arg_types.split(",").map(&:strip)
+ arg_types = [] if arg_types == %w[void]
+
+ # Resolve the type of the argument by dropping the name of the argument
+ # first if it is present.
+ arg_types.map! { |type| resolve_type(type.sub(/\w+$/, "")) }
+
+ # Attach the function using the FFI library.
+ attach_function name, arg_types, resolve_type(return_type)
+ end
+
+ # If we didn't find all of the functions, raise an error.
+ raise "Could not find functions #{functions.inspect}" unless functions.empty?
+ end
+
+ load_exported_functions_from(
+ "prism.h",
+ "pm_version",
+ "pm_serialize_parse",
+ "pm_serialize_parse_comments",
+ "pm_serialize_lex",
+ "pm_serialize_parse_lex",
+ "pm_parse_success_p"
+ )
+
+ load_exported_functions_from(
+ "prism/util/pm_buffer.h",
+ "pm_buffer_sizeof",
+ "pm_buffer_init",
+ "pm_buffer_value",
+ "pm_buffer_length",
+ "pm_buffer_free"
+ )
+
+ load_exported_functions_from(
+ "prism/util/pm_string.h",
+ "pm_string_mapped_init",
+ "pm_string_free",
+ "pm_string_source",
+ "pm_string_length",
+ "pm_string_sizeof"
+ )
+
+ # This object represents a pm_buffer_t. We only use it as an opaque pointer,
+ # so it doesn't need to know the fields of pm_buffer_t.
+ class PrismBuffer # :nodoc:
+ SIZEOF = LibRubyParser.pm_buffer_sizeof
+
+ attr_reader :pointer
+
+ def initialize(pointer)
+ @pointer = pointer
+ end
+
+ def value
+ LibRubyParser.pm_buffer_value(pointer)
+ end
+
+ def length
+ LibRubyParser.pm_buffer_length(pointer)
+ end
+
+ def read
+ value.read_string(length)
+ end
+
+ # Initialize a new buffer and yield it to the block. The buffer will be
+ # automatically freed when the block returns.
+ def self.with(&block)
+ pointer = FFI::MemoryPointer.new(SIZEOF)
+
+ begin
+ raise unless LibRubyParser.pm_buffer_init(pointer)
+ yield new(pointer)
+ ensure
+ LibRubyParser.pm_buffer_free(pointer)
+ pointer.free
+ end
+ end
+ end
+
+ # This object represents a pm_string_t. We only use it as an opaque pointer,
+ # so it doesn't have to be an FFI::Struct.
+ class PrismString # :nodoc:
+ SIZEOF = LibRubyParser.pm_string_sizeof
+
+ attr_reader :pointer
+
+ def initialize(pointer)
+ @pointer = pointer
+ end
+
+ def source
+ LibRubyParser.pm_string_source(pointer)
+ end
+
+ def length
+ LibRubyParser.pm_string_length(pointer)
+ end
+
+ def read
+ source.read_string(length)
+ end
+
+ # Yields a pm_string_t pointer to the given block.
+ def self.with(filepath, &block)
+ pointer = FFI::MemoryPointer.new(SIZEOF)
+
+ begin
+ raise unless LibRubyParser.pm_string_mapped_init(pointer, filepath)
+ yield new(pointer)
+ ensure
+ LibRubyParser.pm_string_free(pointer)
+ pointer.free
+ end
+ end
+ end
+ end
+
+ # Mark the LibRubyParser module as private as it should only be called through
+ # the prism module.
+ private_constant :LibRubyParser
+
+ # The version constant is set by reading the result of calling pm_version.
+ VERSION = LibRubyParser.pm_version.read_string
+
+ class << self
+ # Mirror the Prism.dump API by using the serialization API.
+ def dump(code, **options)
+ LibRubyParser::PrismBuffer.with do |buffer|
+ LibRubyParser.pm_serialize_parse(buffer.pointer, code, code.bytesize, dump_options(options))
+ buffer.read
+ end
+ end
+
+ # Mirror the Prism.dump_file API by using the serialization API.
+ def dump_file(filepath, **options)
+ LibRubyParser::PrismString.with(filepath) do |string|
+ dump(string.read, **options, filepath: filepath)
+ end
+ end
+
+ # Mirror the Prism.lex API by using the serialization API.
+ def lex(code, **options)
+ LibRubyParser::PrismBuffer.with do |buffer|
+ LibRubyParser.pm_serialize_lex(buffer.pointer, code, code.bytesize, dump_options(options))
+ Serialize.load_tokens(Source.new(code), buffer.read)
+ end
+ end
+
+ # Mirror the Prism.lex_file API by using the serialization API.
+ def lex_file(filepath, **options)
+ LibRubyParser::PrismString.with(filepath) do |string|
+ lex(string.read, **options, filepath: filepath)
+ end
+ end
+
+ # Mirror the Prism.parse API by using the serialization API.
+ def parse(code, **options)
+ Prism.load(code, dump(code, **options))
+ end
+
+ # Mirror the Prism.parse_file API by using the serialization API. This uses
+ # native strings instead of Ruby strings because it allows us to use mmap when
+ # it is available.
+ def parse_file(filepath, **options)
+ LibRubyParser::PrismString.with(filepath) do |string|
+ parse(string.read, **options, filepath: filepath)
+ end
+ end
+
+ # Mirror the Prism.parse_comments API by using the serialization API.
+ def parse_comments(code, **options)
+ LibRubyParser::PrismBuffer.with do |buffer|
+ LibRubyParser.pm_serialize_parse_comments(buffer.pointer, code, code.bytesize, dump_options(options))
+
+ source = Source.new(code)
+ loader = Serialize::Loader.new(source, buffer.read)
+
+ loader.load_header
+ loader.load_encoding
+ loader.load_start_line
+ loader.load_comments
+ end
+ end
+
+ # Mirror the Prism.parse_file_comments API by using the serialization
+ # API. This uses native strings instead of Ruby strings because it allows us
+ # to use mmap when it is available.
+ def parse_file_comments(filepath, **options)
+ LibRubyParser::PrismString.with(filepath) do |string|
+ parse_comments(string.read, **options, filepath: filepath)
+ end
+ end
+
+ # Mirror the Prism.parse_lex API by using the serialization API.
+ def parse_lex(code, **options)
+ LibRubyParser::PrismBuffer.with do |buffer|
+ LibRubyParser.pm_serialize_parse_lex(buffer.pointer, code, code.bytesize, dump_options(options))
+
+ source = Source.new(code)
+ loader = Serialize::Loader.new(source, buffer.read)
+
+ tokens = loader.load_tokens
+ node, comments, magic_comments, data_loc, errors, warnings = loader.load_nodes
+ tokens.each { |token,| token.value.force_encoding(loader.encoding) }
+
+ ParseResult.new([node, tokens], comments, magic_comments, data_loc, errors, warnings, source)
+ end
+ end
+
+ # Mirror the Prism.parse_lex_file API by using the serialization API.
+ def parse_lex_file(filepath, **options)
+ LibRubyParser::PrismString.with(filepath) do |string|
+ parse_lex(string.read, **options, filepath: filepath)
+ end
+ end
+
+ # Mirror the Prism.parse_success? API by using the serialization API.
+ def parse_success?(code, **options)
+ LibRubyParser.pm_parse_success_p(code, code.bytesize, dump_options(options))
+ end
+
+ # Mirror the Prism.parse_file_success? API by using the serialization API.
+ def parse_file_success?(filepath, **options)
+ LibRubyParser::PrismString.with(filepath) do |string|
+ parse_success?(string.read, **options, filepath: filepath)
+ end
+ end
+
+ private
+
+ # Convert the given options into a serialized options string.
+ def dump_options(options)
+ template = +""
+ values = []
+
+ template << "L"
+ if (filepath = options[:filepath])
+ values.push(filepath.bytesize, filepath.b)
+ template << "A*"
+ else
+ values << 0
+ end
+
+ template << "L"
+ values << options.fetch(:line, 1)
+
+ template << "L"
+ if (encoding = options[:encoding])
+ name = encoding.name
+ values.push(name.bytesize, name.b)
+ template << "A*"
+ else
+ values << 0
+ end
+
+ template << "C"
+ values << (options.fetch(:frozen_string_literal, false) ? 1 : 0)
+
+ template << "C"
+ values << (options.fetch(:verbose, true) ? 0 : 1)
+
+ template << "L"
+ if (scopes = options[:scopes])
+ values << scopes.length
+
+ scopes.each do |scope|
+ template << "L"
+ values << scope.length
+
+ scope.each do |local|
+ name = local.name
+ template << "L"
+ values << name.bytesize
+
+ template << "A*"
+ values << name.b
+ end
+ end
+ else
+ values << 0
+ end
+
+ values.pack(template)
+ end
+ end
+end
diff --git a/lib/prism/lex_compat.rb b/lib/prism/lex_compat.rb
new file mode 100644
index 0000000000..2c23933714
--- /dev/null
+++ b/lib/prism/lex_compat.rb
@@ -0,0 +1,892 @@
+# frozen_string_literal: true
+
+require "delegate"
+
+module Prism
+ # This class is responsible for lexing the source using prism and then
+ # converting those tokens to be compatible with Ripper. In the vast majority
+ # of cases, this is a one-to-one mapping of the token type. Everything else
+ # generally lines up. However, there are a few cases that require special
+ # handling.
+ class LexCompat # :nodoc:
+ # This is a mapping of prism token types to Ripper token types. This is a
+ # many-to-one mapping because we split up our token types, whereas Ripper
+ # tends to group them.
+ RIPPER = {
+ AMPERSAND: :on_op,
+ AMPERSAND_AMPERSAND: :on_op,
+ AMPERSAND_AMPERSAND_EQUAL: :on_op,
+ AMPERSAND_DOT: :on_op,
+ AMPERSAND_EQUAL: :on_op,
+ BACK_REFERENCE: :on_backref,
+ BACKTICK: :on_backtick,
+ BANG: :on_op,
+ BANG_EQUAL: :on_op,
+ BANG_TILDE: :on_op,
+ BRACE_LEFT: :on_lbrace,
+ BRACE_RIGHT: :on_rbrace,
+ BRACKET_LEFT: :on_lbracket,
+ BRACKET_LEFT_ARRAY: :on_lbracket,
+ BRACKET_LEFT_RIGHT: :on_op,
+ BRACKET_LEFT_RIGHT_EQUAL: :on_op,
+ BRACKET_RIGHT: :on_rbracket,
+ CARET: :on_op,
+ CARET_EQUAL: :on_op,
+ CHARACTER_LITERAL: :on_CHAR,
+ CLASS_VARIABLE: :on_cvar,
+ COLON: :on_op,
+ COLON_COLON: :on_op,
+ COMMA: :on_comma,
+ COMMENT: :on_comment,
+ CONSTANT: :on_const,
+ DOT: :on_period,
+ DOT_DOT: :on_op,
+ DOT_DOT_DOT: :on_op,
+ EMBDOC_BEGIN: :on_embdoc_beg,
+ EMBDOC_END: :on_embdoc_end,
+ EMBDOC_LINE: :on_embdoc,
+ EMBEXPR_BEGIN: :on_embexpr_beg,
+ EMBEXPR_END: :on_embexpr_end,
+ EMBVAR: :on_embvar,
+ EOF: :on_eof,
+ EQUAL: :on_op,
+ EQUAL_EQUAL: :on_op,
+ EQUAL_EQUAL_EQUAL: :on_op,
+ EQUAL_GREATER: :on_op,
+ EQUAL_TILDE: :on_op,
+ FLOAT: :on_float,
+ FLOAT_IMAGINARY: :on_imaginary,
+ FLOAT_RATIONAL: :on_rational,
+ FLOAT_RATIONAL_IMAGINARY: :on_imaginary,
+ GREATER: :on_op,
+ GREATER_EQUAL: :on_op,
+ GREATER_GREATER: :on_op,
+ GREATER_GREATER_EQUAL: :on_op,
+ GLOBAL_VARIABLE: :on_gvar,
+ HEREDOC_END: :on_heredoc_end,
+ HEREDOC_START: :on_heredoc_beg,
+ IDENTIFIER: :on_ident,
+ IGNORED_NEWLINE: :on_ignored_nl,
+ INTEGER: :on_int,
+ INTEGER_IMAGINARY: :on_imaginary,
+ INTEGER_RATIONAL: :on_rational,
+ INTEGER_RATIONAL_IMAGINARY: :on_imaginary,
+ INSTANCE_VARIABLE: :on_ivar,
+ INVALID: :INVALID,
+ KEYWORD___ENCODING__: :on_kw,
+ KEYWORD___LINE__: :on_kw,
+ KEYWORD___FILE__: :on_kw,
+ KEYWORD_ALIAS: :on_kw,
+ KEYWORD_AND: :on_kw,
+ KEYWORD_BEGIN: :on_kw,
+ KEYWORD_BEGIN_UPCASE: :on_kw,
+ KEYWORD_BREAK: :on_kw,
+ KEYWORD_CASE: :on_kw,
+ KEYWORD_CLASS: :on_kw,
+ KEYWORD_DEF: :on_kw,
+ KEYWORD_DEFINED: :on_kw,
+ KEYWORD_DO: :on_kw,
+ KEYWORD_DO_LOOP: :on_kw,
+ KEYWORD_ELSE: :on_kw,
+ KEYWORD_ELSIF: :on_kw,
+ KEYWORD_END: :on_kw,
+ KEYWORD_END_UPCASE: :on_kw,
+ KEYWORD_ENSURE: :on_kw,
+ KEYWORD_FALSE: :on_kw,
+ KEYWORD_FOR: :on_kw,
+ KEYWORD_IF: :on_kw,
+ KEYWORD_IF_MODIFIER: :on_kw,
+ KEYWORD_IN: :on_kw,
+ KEYWORD_MODULE: :on_kw,
+ KEYWORD_NEXT: :on_kw,
+ KEYWORD_NIL: :on_kw,
+ KEYWORD_NOT: :on_kw,
+ KEYWORD_OR: :on_kw,
+ KEYWORD_REDO: :on_kw,
+ KEYWORD_RESCUE: :on_kw,
+ KEYWORD_RESCUE_MODIFIER: :on_kw,
+ KEYWORD_RETRY: :on_kw,
+ KEYWORD_RETURN: :on_kw,
+ KEYWORD_SELF: :on_kw,
+ KEYWORD_SUPER: :on_kw,
+ KEYWORD_THEN: :on_kw,
+ KEYWORD_TRUE: :on_kw,
+ KEYWORD_UNDEF: :on_kw,
+ KEYWORD_UNLESS: :on_kw,
+ KEYWORD_UNLESS_MODIFIER: :on_kw,
+ KEYWORD_UNTIL: :on_kw,
+ KEYWORD_UNTIL_MODIFIER: :on_kw,
+ KEYWORD_WHEN: :on_kw,
+ KEYWORD_WHILE: :on_kw,
+ KEYWORD_WHILE_MODIFIER: :on_kw,
+ KEYWORD_YIELD: :on_kw,
+ LABEL: :on_label,
+ LABEL_END: :on_label_end,
+ LAMBDA_BEGIN: :on_tlambeg,
+ LESS: :on_op,
+ LESS_EQUAL: :on_op,
+ LESS_EQUAL_GREATER: :on_op,
+ LESS_LESS: :on_op,
+ LESS_LESS_EQUAL: :on_op,
+ METHOD_NAME: :on_ident,
+ MINUS: :on_op,
+ MINUS_EQUAL: :on_op,
+ MINUS_GREATER: :on_tlambda,
+ NEWLINE: :on_nl,
+ NUMBERED_REFERENCE: :on_backref,
+ PARENTHESIS_LEFT: :on_lparen,
+ PARENTHESIS_LEFT_PARENTHESES: :on_lparen,
+ PARENTHESIS_RIGHT: :on_rparen,
+ PERCENT: :on_op,
+ PERCENT_EQUAL: :on_op,
+ PERCENT_LOWER_I: :on_qsymbols_beg,
+ PERCENT_LOWER_W: :on_qwords_beg,
+ PERCENT_LOWER_X: :on_backtick,
+ PERCENT_UPPER_I: :on_symbols_beg,
+ PERCENT_UPPER_W: :on_words_beg,
+ PIPE: :on_op,
+ PIPE_EQUAL: :on_op,
+ PIPE_PIPE: :on_op,
+ PIPE_PIPE_EQUAL: :on_op,
+ PLUS: :on_op,
+ PLUS_EQUAL: :on_op,
+ QUESTION_MARK: :on_op,
+ RATIONAL_FLOAT: :on_rational,
+ RATIONAL_INTEGER: :on_rational,
+ REGEXP_BEGIN: :on_regexp_beg,
+ REGEXP_END: :on_regexp_end,
+ SEMICOLON: :on_semicolon,
+ SLASH: :on_op,
+ SLASH_EQUAL: :on_op,
+ STAR: :on_op,
+ STAR_EQUAL: :on_op,
+ STAR_STAR: :on_op,
+ STAR_STAR_EQUAL: :on_op,
+ STRING_BEGIN: :on_tstring_beg,
+ STRING_CONTENT: :on_tstring_content,
+ STRING_END: :on_tstring_end,
+ SYMBOL_BEGIN: :on_symbeg,
+ TILDE: :on_op,
+ UAMPERSAND: :on_op,
+ UCOLON_COLON: :on_op,
+ UDOT_DOT: :on_op,
+ UDOT_DOT_DOT: :on_op,
+ UMINUS: :on_op,
+ UMINUS_NUM: :on_op,
+ UPLUS: :on_op,
+ USTAR: :on_op,
+ USTAR_STAR: :on_op,
+ WORDS_SEP: :on_words_sep,
+ "__END__": :on___end__
+ }.freeze
+
+ # When we produce tokens, we produce the same arrays that Ripper does.
+ # However, we add a couple of convenience methods onto them to make them a
+ # little easier to work with. We delegate all other methods to the array.
+ class Token < SimpleDelegator
+ # The location of the token in the source.
+ def location
+ self[0]
+ end
+
+ # The type of the token.
+ def event
+ self[1]
+ end
+
+ # The slice of the source that this token represents.
+ def value
+ self[2]
+ end
+
+ # The state of the lexer when this token was produced.
+ def state
+ self[3]
+ end
+ end
+
+ # Ripper doesn't include the rest of the token in the event, so we need to
+ # trim it down to just the content on the first line when comparing.
+ class EndContentToken < Token
+ def ==(other) # :nodoc:
+ [self[0], self[1], self[2][0..self[2].index("\n")], self[3]] == other
+ end
+ end
+
+ # Tokens where state should be ignored
+ # used for :on_comment, :on_heredoc_end, :on_embexpr_end
+ class IgnoreStateToken < Token
+ def ==(other) # :nodoc:
+ self[0...-1] == other[0...-1]
+ end
+ end
+
+ # Ident tokens for the most part are exactly the same, except sometimes we
+ # know an ident is a local when ripper doesn't (when they are introduced
+ # through named captures in regular expressions). In that case we don't
+ # compare the state.
+ class IdentToken < Token
+ def ==(other) # :nodoc:
+ (self[0...-1] == other[0...-1]) && (
+ (other[3] == Ripper::EXPR_LABEL | Ripper::EXPR_END) ||
+ (other[3] & Ripper::EXPR_ARG_ANY != 0)
+ )
+ end
+ end
+
+ # Ignored newlines can occasionally have a LABEL state attached to them, so
+ # we compare the state differently here.
+ class IgnoredNewlineToken < Token
+ def ==(other) # :nodoc:
+ return false unless self[0...-1] == other[0...-1]
+
+ if self[4] == Ripper::EXPR_ARG | Ripper::EXPR_LABELED
+ other[4] & Ripper::EXPR_ARG | Ripper::EXPR_LABELED > 0
+ else
+ self[4] == other[4]
+ end
+ end
+ end
+
+ # If we have an identifier that follows a method name like:
+ #
+ # def foo bar
+ #
+ # then Ripper will mark bar as END|LABEL if there is a local in a parent
+ # scope named bar because it hasn't pushed the local table yet. We do this
+ # more accurately, so we need to allow comparing against both END and
+ # END|LABEL.
+ class ParamToken < Token
+ def ==(other) # :nodoc:
+ (self[0...-1] == other[0...-1]) && (
+ (other[3] == Ripper::EXPR_END) ||
+ (other[3] == Ripper::EXPR_END | Ripper::EXPR_LABEL)
+ )
+ end
+ end
+
+ # A heredoc in this case is a list of tokens that belong to the body of the
+ # heredoc that should be appended onto the list of tokens when the heredoc
+ # closes.
+ module Heredoc # :nodoc:
+ # Heredocs that are no dash or tilde heredocs are just a list of tokens.
+ # We need to keep them around so that we can insert them in the correct
+ # order back into the token stream and set the state of the last token to
+ # the state that the heredoc was opened in.
+ class PlainHeredoc # :nodoc:
+ attr_reader :tokens
+
+ def initialize
+ @tokens = []
+ end
+
+ def <<(token)
+ tokens << token
+ end
+
+ def to_a
+ tokens
+ end
+ end
+
+ # Dash heredocs are a little more complicated. They are a list of tokens
+ # that need to be split on "\\\n" to mimic Ripper's behavior. We also need
+ # to keep track of the state that the heredoc was opened in.
+ class DashHeredoc # :nodoc:
+ attr_reader :split, :tokens
+
+ def initialize(split)
+ @split = split
+ @tokens = []
+ end
+
+ def <<(token)
+ tokens << token
+ end
+
+ def to_a
+ embexpr_balance = 0
+
+ tokens.each_with_object([]) do |token, results|
+ case token.event
+ when :on_embexpr_beg
+ embexpr_balance += 1
+ results << token
+ when :on_embexpr_end
+ embexpr_balance -= 1
+ results << token
+ when :on_tstring_content
+ if embexpr_balance == 0
+ lineno = token[0][0]
+ column = token[0][1]
+
+ if split
+ # Split on "\\\n" to mimic Ripper's behavior. Use a lookbehind
+ # to keep the delimiter in the result.
+ token.value.split(/(?<=[^\\]\\\n)|(?<=[^\\]\\\r\n)/).each_with_index do |value, index|
+ column = 0 if index > 0
+ results << Token.new([[lineno, column], :on_tstring_content, value, token.state])
+ lineno += value.count("\n")
+ end
+ else
+ results << token
+ end
+ else
+ results << token
+ end
+ else
+ results << token
+ end
+ end
+ end
+ end
+
+ # Heredocs that are dedenting heredocs are a little more complicated.
+ # Ripper outputs on_ignored_sp tokens for the whitespace that is being
+ # removed from the output. prism only modifies the node itself and keeps
+ # the token the same. This simplifies prism, but makes comparing against
+ # Ripper much harder because there is a length mismatch.
+ #
+ # Fortunately, we already have to pull out the heredoc tokens in order to
+ # insert them into the stream in the correct order. As such, we can do
+ # some extra manipulation on the tokens to make them match Ripper's
+ # output by mirroring the dedent logic that Ripper uses.
+ class DedentingHeredoc # :nodoc:
+ TAB_WIDTH = 8
+
+ attr_reader :tokens, :dedent_next, :dedent, :embexpr_balance
+
+ def initialize
+ @tokens = []
+ @dedent_next = true
+ @dedent = nil
+ @embexpr_balance = 0
+ @ended_on_newline = false
+ end
+
+ # As tokens are coming in, we track the minimum amount of common leading
+ # whitespace on plain string content tokens. This allows us to later
+ # remove that amount of whitespace from the beginning of each line.
+ def <<(token)
+ case token.event
+ when :on_embexpr_beg, :on_heredoc_beg
+ @embexpr_balance += 1
+ @dedent = 0 if @dedent_next && @ended_on_newline
+ when :on_embexpr_end, :on_heredoc_end
+ @embexpr_balance -= 1
+ when :on_tstring_content
+ if embexpr_balance == 0
+ line = token.value
+
+ if dedent_next && !(line.strip.empty? && line.end_with?("\n"))
+ leading = line[/\A(\s*)\n?/, 1]
+ next_dedent = 0
+
+ leading.each_char do |char|
+ if char == "\t"
+ next_dedent = next_dedent - (next_dedent % TAB_WIDTH) + TAB_WIDTH
+ else
+ next_dedent += 1
+ end
+ end
+
+ @dedent = [dedent, next_dedent].compact.min
+ @dedent_next = true
+ @ended_on_newline = line.end_with?("\n")
+ tokens << token
+ return
+ end
+ end
+ end
+
+ @dedent_next = token.event == :on_tstring_content && embexpr_balance == 0
+ @ended_on_newline = false
+ tokens << token
+ end
+
+ def to_a
+ # If every line in the heredoc is blank, we still need to split up the
+ # string content token into multiple tokens.
+ if dedent.nil?
+ results = []
+ embexpr_balance = 0
+
+ tokens.each do |token|
+ case token.event
+ when :on_embexpr_beg, :on_heredoc_beg
+ embexpr_balance += 1
+ results << token
+ when :on_embexpr_end, :on_heredoc_end
+ embexpr_balance -= 1
+ results << token
+ when :on_tstring_content
+ if embexpr_balance == 0
+ lineno = token[0][0]
+ column = token[0][1]
+
+ token.value.split(/(?<=\n)/).each_with_index do |value, index|
+ column = 0 if index > 0
+ results << Token.new([[lineno, column], :on_tstring_content, value, token.state])
+ lineno += 1
+ end
+ else
+ results << token
+ end
+ else
+ results << token
+ end
+ end
+
+ return results
+ end
+
+ # If the minimum common whitespace is 0, then we need to concatenate
+ # string nodes together that are immediately adjacent.
+ if dedent == 0
+ results = []
+ embexpr_balance = 0
+
+ index = 0
+ max_index = tokens.length
+
+ while index < max_index
+ token = tokens[index]
+ results << token
+ index += 1
+
+ case token.event
+ when :on_embexpr_beg, :on_heredoc_beg
+ embexpr_balance += 1
+ when :on_embexpr_end, :on_heredoc_end
+ embexpr_balance -= 1
+ when :on_tstring_content
+ if embexpr_balance == 0
+ while index < max_index && tokens[index].event == :on_tstring_content
+ token.value << tokens[index].value
+ index += 1
+ end
+ end
+ end
+ end
+
+ return results
+ end
+
+ # Otherwise, we're going to run through each token in the list and
+ # insert on_ignored_sp tokens for the amount of dedent that we need to
+ # perform. We also need to remove the dedent from the beginning of
+ # each line of plain string content tokens.
+ results = []
+ dedent_next = true
+ embexpr_balance = 0
+
+ tokens.each do |token|
+ # Notice that the structure of this conditional largely matches the
+ # whitespace calculation we performed above. This is because
+ # checking if the subsequent token needs to be dedented is common to
+ # both the dedent calculation and the ignored_sp insertion.
+ case token.event
+ when :on_embexpr_beg
+ embexpr_balance += 1
+ results << token
+ when :on_embexpr_end
+ embexpr_balance -= 1
+ results << token
+ when :on_tstring_content
+ if embexpr_balance == 0
+ # Here we're going to split the string on newlines, but maintain
+ # the newlines in the resulting array. We'll do that with a look
+ # behind assertion.
+ splits = token.value.split(/(?<=\n)/)
+ index = 0
+
+ while index < splits.length
+ line = splits[index]
+ lineno = token[0][0] + index
+ column = token[0][1]
+
+ # Blank lines do not count toward common leading whitespace
+ # calculation and do not need to be dedented.
+ if dedent_next || index > 0
+ column = 0
+ end
+
+ # If the dedent is 0 and we're not supposed to dedent the next
+ # line or this line doesn't start with whitespace, then we
+ # should concatenate the rest of the string to match ripper.
+ if dedent == 0 && (!dedent_next || !line.start_with?(/\s/))
+ line = splits[index..].join
+ index = splits.length
+ end
+
+ # If we are supposed to dedent this line or if this is not the
+ # first line of the string and this line isn't entirely blank,
+ # then we need to insert an on_ignored_sp token and remove the
+ # dedent from the beginning of the line.
+ if (dedent > 0) && (dedent_next || index > 0)
+ deleting = 0
+ deleted_chars = []
+
+ # Gather up all of the characters that we're going to
+ # delete, stopping when you hit a character that would put
+ # you over the dedent amount.
+ line.each_char.with_index do |char, i|
+ case char
+ when "\r"
+ if line[i + 1] == "\n"
+ break
+ end
+ when "\n"
+ break
+ when "\t"
+ deleting = deleting - (deleting % TAB_WIDTH) + TAB_WIDTH
+ else
+ deleting += 1
+ end
+
+ break if deleting > dedent
+ deleted_chars << char
+ end
+
+ # If we have something to delete, then delete it from the
+ # string and insert an on_ignored_sp token.
+ if deleted_chars.any?
+ ignored = deleted_chars.join
+ line.delete_prefix!(ignored)
+
+ results << Token.new([[lineno, 0], :on_ignored_sp, ignored, token[3]])
+ column = ignored.length
+ end
+ end
+
+ results << Token.new([[lineno, column], token[1], line, token[3]]) unless line.empty?
+ index += 1
+ end
+ else
+ results << token
+ end
+ else
+ results << token
+ end
+
+ dedent_next =
+ ((token.event == :on_tstring_content) || (token.event == :on_heredoc_end)) &&
+ embexpr_balance == 0
+ end
+
+ results
+ end
+ end
+
+ # Here we will split between the two types of heredocs and return the
+ # object that will store their tokens.
+ def self.build(opening)
+ case opening.value[2]
+ when "~"
+ DedentingHeredoc.new
+ when "-"
+ DashHeredoc.new(opening.value[3] != "'")
+ else
+ PlainHeredoc.new
+ end
+ end
+ end
+
+ private_constant :Heredoc
+
+ attr_reader :source, :options
+
+ def initialize(source, **options)
+ @source = source
+ @options = options
+ end
+
+ def result
+ tokens = []
+
+ state = :default
+ heredoc_stack = [[]]
+
+ result = Prism.lex(source, **options)
+ result_value = result.value
+ previous_state = nil
+ last_heredoc_end = nil
+
+ # In previous versions of Ruby, Ripper wouldn't flush the bom before the
+ # first token, so we had to have a hack in place to account for that. This
+ # checks for that behavior.
+ bom_flushed = Ripper.lex("\xEF\xBB\xBF# test")[0][0][1] == 0
+ bom = source.byteslice(0..2) == "\xEF\xBB\xBF"
+
+ result_value.each_with_index do |(token, lex_state), index|
+ lineno = token.location.start_line
+ column = token.location.start_column
+
+ # If there's a UTF-8 byte-order mark as the start of the file, then for
+ # certain tokens ripper sets the first token back by 3 bytes. It also
+ # keeps the byte order mark in the first token's value. This is weird,
+ # and I don't want to mirror that in our parser. So instead, we'll match
+ # up the columns and values here.
+ if bom && lineno == 1
+ column -= 3
+
+ if index == 0 && column == 0 && !bom_flushed
+ flushed =
+ case token.type
+ when :BACK_REFERENCE, :INSTANCE_VARIABLE, :CLASS_VARIABLE,
+ :GLOBAL_VARIABLE, :NUMBERED_REFERENCE, :PERCENT_LOWER_I,
+ :PERCENT_LOWER_X, :PERCENT_LOWER_W, :PERCENT_UPPER_I,
+ :PERCENT_UPPER_W, :STRING_BEGIN
+ true
+ when :REGEXP_BEGIN, :SYMBOL_BEGIN
+ token.value.start_with?("%")
+ else
+ false
+ end
+
+ unless flushed
+ column -= 3
+ value = token.value
+ value.prepend(String.new("\xEF\xBB\xBF", encoding: value.encoding))
+ end
+ end
+ end
+
+ event = RIPPER.fetch(token.type)
+ value = token.value
+ lex_state = Ripper::Lexer::State.new(lex_state)
+
+ token =
+ case event
+ when :on___end__
+ EndContentToken.new([[lineno, column], event, value, lex_state])
+ when :on_comment
+ IgnoreStateToken.new([[lineno, column], event, value, lex_state])
+ when :on_heredoc_end
+ # Heredoc end tokens can be emitted in an odd order, so we don't
+ # want to bother comparing the state on them.
+ last_heredoc_end = token.location.end_offset
+ IgnoreStateToken.new([[lineno, column], event, value, lex_state])
+ when :on_ident
+ if lex_state == Ripper::EXPR_END
+ # If we have an identifier that follows a method name like:
+ #
+ # def foo bar
+ #
+ # then Ripper will mark bar as END|LABEL if there is a local in a
+ # parent scope named bar because it hasn't pushed the local table
+ # yet. We do this more accurately, so we need to allow comparing
+ # against both END and END|LABEL.
+ ParamToken.new([[lineno, column], event, value, lex_state])
+ elsif lex_state == Ripper::EXPR_END | Ripper::EXPR_LABEL
+ # In the event that we're comparing identifiers, we're going to
+ # allow a little divergence. Ripper doesn't account for local
+ # variables introduced through named captures in regexes, and we
+ # do, which accounts for this difference.
+ IdentToken.new([[lineno, column], event, value, lex_state])
+ else
+ Token.new([[lineno, column], event, value, lex_state])
+ end
+ when :on_embexpr_end
+ IgnoreStateToken.new([[lineno, column], event, value, lex_state])
+ when :on_ignored_nl
+ # Ignored newlines can occasionally have a LABEL state attached to
+ # them which doesn't actually impact anything. We don't mirror that
+ # state so we ignored it.
+ IgnoredNewlineToken.new([[lineno, column], event, value, lex_state])
+ when :on_regexp_end
+ # On regex end, Ripper scans and then sets end state, so the ripper
+ # lexed output is begin, when it should be end. prism sets lex state
+ # correctly to end state, but we want to be able to compare against
+ # Ripper's lexed state. So here, if it's a regexp end token, we
+ # output the state as the previous state, solely for the sake of
+ # comparison.
+ previous_token = result_value[index - 1][0]
+ lex_state =
+ if RIPPER.fetch(previous_token.type) == :on_embexpr_end
+ # If the previous token is embexpr_end, then we have to do even
+ # more processing. The end of an embedded expression sets the
+ # state to the state that it had at the beginning of the
+ # embedded expression. So we have to go and find that state and
+ # set it here.
+ counter = 1
+ current_index = index - 1
+
+ until counter == 0
+ current_index -= 1
+ current_event = RIPPER.fetch(result_value[current_index][0].type)
+ counter += { on_embexpr_beg: -1, on_embexpr_end: 1 }[current_event] || 0
+ end
+
+ Ripper::Lexer::State.new(result_value[current_index][1])
+ else
+ previous_state
+ end
+
+ Token.new([[lineno, column], event, value, lex_state])
+ when :on_eof
+ previous_token = result_value[index - 1][0]
+
+ # If we're at the end of the file and the previous token was a
+ # comment and there is still whitespace after the comment, then
+ # Ripper will append a on_nl token (even though there isn't
+ # necessarily a newline). We mirror that here.
+ if previous_token.type == :COMMENT
+ # If the comment is at the start of a heredoc: <<HEREDOC # comment
+ # then the comment's end_offset is up near the heredoc_beg.
+ # This is not the correct offset to use for figuring out if
+ # there is trailing whitespace after the last token.
+ # Use the greater offset of the two to determine the start of
+ # the trailing whitespace.
+ start_offset = [previous_token.location.end_offset, last_heredoc_end].compact.max
+ end_offset = token.location.start_offset
+
+ if start_offset < end_offset
+ if bom
+ start_offset += 3
+ end_offset += 3
+ end
+
+ tokens << Token.new([[lineno, 0], :on_nl, source.byteslice(start_offset...end_offset), lex_state])
+ end
+ end
+
+ Token.new([[lineno, column], event, value, lex_state])
+ else
+ Token.new([[lineno, column], event, value, lex_state])
+ end
+
+ previous_state = lex_state
+
+ # The order in which tokens appear in our lexer is different from the
+ # order that they appear in Ripper. When we hit the declaration of a
+ # heredoc in prism, we skip forward and lex the rest of the content of
+ # the heredoc before going back and lexing at the end of the heredoc
+ # identifier.
+ #
+ # To match up to ripper, we keep a small state variable around here to
+ # track whether we're in the middle of a heredoc or not. In this way we
+ # can shuffle around the token to match Ripper's output.
+ case state
+ when :default
+ # The default state is when there are no heredocs at all. In this
+ # state we can append the token to the list of tokens and move on.
+ tokens << token
+
+ # If we get the declaration of a heredoc, then we open a new heredoc
+ # and move into the heredoc_opened state.
+ if event == :on_heredoc_beg
+ state = :heredoc_opened
+ heredoc_stack.last << Heredoc.build(token)
+ end
+ when :heredoc_opened
+ # The heredoc_opened state is when we've seen the declaration of a
+ # heredoc and are now lexing the body of the heredoc. In this state we
+ # push tokens onto the most recently created heredoc.
+ heredoc_stack.last.last << token
+
+ case event
+ when :on_heredoc_beg
+ # If we receive a heredoc declaration while lexing the body of a
+ # heredoc, this means we have nested heredocs. In this case we'll
+ # push a new heredoc onto the stack and stay in the heredoc_opened
+ # state since we're now lexing the body of the new heredoc.
+ heredoc_stack << [Heredoc.build(token)]
+ when :on_heredoc_end
+ # If we receive the end of a heredoc, then we're done lexing the
+ # body of the heredoc. In this case we now have a completed heredoc
+ # but need to wait for the next newline to push it into the token
+ # stream.
+ state = :heredoc_closed
+ end
+ when :heredoc_closed
+ if %i[on_nl on_ignored_nl on_comment].include?(event) || (event == :on_tstring_content && value.end_with?("\n"))
+ if heredoc_stack.size > 1
+ flushing = heredoc_stack.pop
+ heredoc_stack.last.last << token
+
+ flushing.each do |heredoc|
+ heredoc.to_a.each do |flushed_token|
+ heredoc_stack.last.last << flushed_token
+ end
+ end
+
+ state = :heredoc_opened
+ next
+ end
+ elsif event == :on_heredoc_beg
+ tokens << token
+ state = :heredoc_opened
+ heredoc_stack.last << Heredoc.build(token)
+ next
+ elsif heredoc_stack.size > 1
+ heredoc_stack[-2].last << token
+ next
+ end
+
+ heredoc_stack.last.each do |heredoc|
+ tokens.concat(heredoc.to_a)
+ end
+
+ heredoc_stack.last.clear
+ state = :default
+
+ tokens << token
+ end
+ end
+
+ # Drop the EOF token from the list
+ tokens = tokens[0...-1]
+
+ # We sort by location to compare against Ripper's output
+ tokens.sort_by!(&:location)
+
+ ParseResult.new(tokens, result.comments, result.magic_comments, result.data_loc, result.errors, result.warnings, [])
+ end
+ end
+
+ private_constant :LexCompat
+
+ # This is a class that wraps the Ripper lexer to produce almost exactly the
+ # same tokens.
+ class LexRipper # :nodoc:
+ attr_reader :source
+
+ def initialize(source)
+ @source = source
+ end
+
+ def result
+ previous = []
+ results = []
+
+ Ripper.lex(source, raise_errors: true).each do |token|
+ case token[1]
+ when :on_sp
+ # skip
+ when :on_tstring_content
+ if previous[1] == :on_tstring_content && (token[2].start_with?("\#$") || token[2].start_with?("\#@"))
+ previous[2] << token[2]
+ else
+ results << token
+ previous = token
+ end
+ when :on_words_sep
+ if previous[1] == :on_words_sep
+ previous[2] << token[2]
+ else
+ results << token
+ previous = token
+ end
+ else
+ results << token
+ previous = token
+ end
+ end
+
+ results
+ end
+ end
+
+ private_constant :LexRipper
+end
diff --git a/lib/prism/node_ext.rb b/lib/prism/node_ext.rb
new file mode 100644
index 0000000000..8c09632345
--- /dev/null
+++ b/lib/prism/node_ext.rb
@@ -0,0 +1,189 @@
+# frozen_string_literal: true
+
+# Here we are reopening the prism module to provide methods on nodes that aren't
+# templated and are meant as convenience methods.
+module Prism
+ module RegularExpressionOptions # :nodoc:
+ # Returns a numeric value that represents the flags that were used to create
+ # the regular expression.
+ def options
+ o = flags & (RegularExpressionFlags::IGNORE_CASE | RegularExpressionFlags::EXTENDED | RegularExpressionFlags::MULTI_LINE)
+ o |= Regexp::FIXEDENCODING if flags.anybits?(RegularExpressionFlags::EUC_JP | RegularExpressionFlags::WINDOWS_31J | RegularExpressionFlags::UTF_8)
+ o |= Regexp::NOENCODING if flags.anybits?(RegularExpressionFlags::ASCII_8BIT)
+ o
+ end
+ end
+
+ class InterpolatedMatchLastLineNode < Node
+ include RegularExpressionOptions
+ end
+
+ class InterpolatedRegularExpressionNode < Node
+ include RegularExpressionOptions
+ end
+
+ class MatchLastLineNode < Node
+ include RegularExpressionOptions
+ end
+
+ class RegularExpressionNode < Node
+ include RegularExpressionOptions
+ end
+
+ private_constant :RegularExpressionOptions
+
+ module HeredocQuery # :nodoc:
+ # Returns true if this node was represented as a heredoc in the source code.
+ def heredoc?
+ opening&.start_with?("<<")
+ end
+ end
+
+ class InterpolatedStringNode < Node
+ include HeredocQuery
+ end
+
+ class InterpolatedXStringNode < Node
+ include HeredocQuery
+ end
+
+ class StringNode < Node
+ include HeredocQuery
+ end
+
+ class XStringNode < Node
+ include HeredocQuery
+ end
+
+ private_constant :HeredocQuery
+
+ class FloatNode < Node
+ # Returns the value of the node as a Ruby Float.
+ def value
+ Float(slice)
+ end
+ end
+
+ class ImaginaryNode < Node
+ # Returns the value of the node as a Ruby Complex.
+ def value
+ Complex(0, numeric.value)
+ end
+ end
+
+ class IntegerNode < Node
+ # Returns the value of the node as a Ruby Integer.
+ def value
+ Integer(slice)
+ end
+ end
+
+ class RationalNode < Node
+ # Returns the value of the node as a Ruby Rational.
+ def value
+ Rational(slice.chomp("r"))
+ end
+ end
+
+ class ConstantReadNode < Node
+ # Returns the list of parts for the full name of this constant.
+ # For example: [:Foo]
+ def full_name_parts
+ [name]
+ end
+
+ # Returns the full name of this constant. For example: "Foo"
+ def full_name
+ name.name
+ end
+ end
+
+ class ConstantPathNode < Node
+ # An error class raised when dynamic parts are found while computing a
+ # constant path's full name. For example:
+ # Foo::Bar::Baz -> does not raise because all parts of the constant path are
+ # simple constants
+ # var::Bar::Baz -> raises because the first part of the constant path is a
+ # local variable
+ class DynamicPartsInConstantPathError < StandardError; end
+
+ # Returns the list of parts for the full name of this constant path.
+ # For example: [:Foo, :Bar]
+ def full_name_parts
+ parts = [child.name]
+ current = parent
+
+ while current.is_a?(ConstantPathNode)
+ parts.unshift(current.child.name)
+ current = current.parent
+ end
+
+ unless current.is_a?(ConstantReadNode)
+ raise DynamicPartsInConstantPathError, "Constant path contains dynamic parts. Cannot compute full name"
+ end
+
+ parts.unshift(current&.name || :"")
+ end
+
+ # Returns the full name of this constant path. For example: "Foo::Bar"
+ def full_name
+ full_name_parts.join("::")
+ end
+ end
+
+ class ConstantPathTargetNode < Node
+ # Returns the list of parts for the full name of this constant path.
+ # For example: [:Foo, :Bar]
+ def full_name_parts
+ (parent&.full_name_parts || [:""]).push(child.name)
+ end
+
+ # Returns the full name of this constant path. For example: "Foo::Bar"
+ def full_name
+ full_name_parts.join("::")
+ end
+ end
+
+ class ParametersNode < Node
+ # Mirrors the Method#parameters method.
+ def signature
+ names = []
+
+ requireds.each do |param|
+ names << (param.is_a?(MultiTargetNode) ? [:req] : [:req, param.name])
+ end
+
+ optionals.each { |param| names << [:opt, param.name] }
+ names << [:rest, rest.name || :*] if rest
+
+ posts.each do |param|
+ names << (param.is_a?(MultiTargetNode) ? [:req] : [:req, param.name])
+ end
+
+ # Regardless of the order in which the keywords were defined, the required
+ # keywords always come first followed by the optional keywords.
+ keyopt = []
+ keywords.each do |param|
+ if param.is_a?(OptionalKeywordParameterNode)
+ keyopt << param
+ else
+ names << [:keyreq, param.name]
+ end
+ end
+
+ keyopt.each { |param| names << [:key, param.name] }
+
+ case keyword_rest
+ when ForwardingParameterNode
+ names.concat([[:rest, :*], [:keyrest, :**], [:block, :&]])
+ when KeywordRestParameterNode
+ names << [:keyrest, keyword_rest.name || :**]
+ when NoKeywordsParameterNode
+ names << [:nokey]
+ end
+
+ names << [:block, block.name || :&] if block
+ names
+ end
+ end
+end
diff --git a/lib/prism/node_inspector.rb b/lib/prism/node_inspector.rb
new file mode 100644
index 0000000000..d77af33c3a
--- /dev/null
+++ b/lib/prism/node_inspector.rb
@@ -0,0 +1,68 @@
+# frozen_string_literal: true
+
+module Prism
+ # This object is responsible for generating the output for the inspect method
+ # implementations of child nodes.
+ class NodeInspector # :nodoc:
+ attr_reader :prefix, :output
+
+ def initialize(prefix = "")
+ @prefix = prefix
+ @output = +""
+ end
+
+ # Appends a line to the output with the current prefix.
+ def <<(line)
+ output << "#{prefix}#{line}"
+ end
+
+ # This generates a string that is used as the header of the inspect output
+ # for any given node.
+ def header(node)
+ output = +"@ #{node.class.name.split("::").last} ("
+ output << "location: (#{node.location.start_line},#{node.location.start_column})-(#{node.location.end_line},#{node.location.end_column})"
+ output << ", newline: true" if node.newline?
+ output << ")\n"
+ output
+ end
+
+ # Generates a string that represents a list of nodes. It handles properly
+ # using the box drawing characters to make the output look nice.
+ def list(prefix, nodes)
+ output = +"(length: #{nodes.length})\n"
+ last_index = nodes.length - 1
+
+ nodes.each_with_index do |node, index|
+ pointer, preadd = (index == last_index) ? ["└── ", " "] : ["├── ", "│ "]
+ node_prefix = "#{prefix}#{preadd}"
+ output << node.inspect(NodeInspector.new(node_prefix)).sub(node_prefix, "#{prefix}#{pointer}")
+ end
+
+ output
+ end
+
+ # Generates a string that represents a location field on a node.
+ def location(value)
+ if value
+ "(#{value.start_line},#{value.start_column})-(#{value.end_line},#{value.end_column}) = #{value.slice.inspect}"
+ else
+ "∅"
+ end
+ end
+
+ # Generates a string that represents a child node.
+ def child_node(node, append)
+ node.inspect(child_inspector(append)).delete_prefix(prefix)
+ end
+
+ # Returns a new inspector that can be used to inspect a child node.
+ def child_inspector(append)
+ NodeInspector.new("#{prefix}#{append}")
+ end
+
+ # Returns the output as a string.
+ def to_str
+ output
+ end
+ end
+end
diff --git a/lib/prism/pack.rb b/lib/prism/pack.rb
new file mode 100644
index 0000000000..00caf553c6
--- /dev/null
+++ b/lib/prism/pack.rb
@@ -0,0 +1,224 @@
+# frozen_string_literal: true
+
+module Prism
+ # A parser for the pack template language.
+ module Pack
+ %i[
+ SPACE
+ COMMENT
+ INTEGER
+ UTF8
+ BER
+ FLOAT
+ STRING_SPACE_PADDED
+ STRING_NULL_PADDED
+ STRING_NULL_TERMINATED
+ STRING_MSB
+ STRING_LSB
+ STRING_HEX_HIGH
+ STRING_HEX_LOW
+ STRING_UU
+ STRING_MIME
+ STRING_BASE64
+ STRING_FIXED
+ STRING_POINTER
+ MOVE
+ BACK
+ NULL
+
+ UNSIGNED
+ SIGNED
+ SIGNED_NA
+
+ AGNOSTIC_ENDIAN
+ LITTLE_ENDIAN
+ BIG_ENDIAN
+ NATIVE_ENDIAN
+ ENDIAN_NA
+
+ SIZE_SHORT
+ SIZE_INT
+ SIZE_LONG
+ SIZE_LONG_LONG
+ SIZE_8
+ SIZE_16
+ SIZE_32
+ SIZE_64
+ SIZE_P
+ SIZE_NA
+
+ LENGTH_FIXED
+ LENGTH_MAX
+ LENGTH_RELATIVE
+ LENGTH_NA
+ ].each do |const|
+ const_set(const, const)
+ end
+
+ # A directive in the pack template language.
+ class Directive
+ # A symbol representing the version of Ruby.
+ attr_reader :version
+
+ # A symbol representing whether or not we are packing or unpacking.
+ attr_reader :variant
+
+ # A byteslice of the source string that this directive represents.
+ attr_reader :source
+
+ # The type of the directive.
+ attr_reader :type
+
+ # The type of signedness of the directive.
+ attr_reader :signed
+
+ # The type of endianness of the directive.
+ attr_reader :endian
+
+ # The size of the directive.
+ attr_reader :size
+
+ # The length type of this directive (used for integers).
+ attr_reader :length_type
+
+ # The length of this directive (used for integers).
+ attr_reader :length
+
+ # Initialize a new directive with the given values.
+ def initialize(version, variant, source, type, signed, endian, size, length_type, length)
+ @version = version
+ @variant = variant
+ @source = source
+ @type = type
+ @signed = signed
+ @endian = endian
+ @size = size
+ @length_type = length_type
+ @length = length
+ end
+
+ # The descriptions of the various types of endianness.
+ ENDIAN_DESCRIPTIONS = {
+ AGNOSTIC_ENDIAN: "agnostic",
+ LITTLE_ENDIAN: "little-endian (VAX)",
+ BIG_ENDIAN: "big-endian (network)",
+ NATIVE_ENDIAN: "native-endian",
+ ENDIAN_NA: "n/a"
+ }
+
+ # The descriptions of the various types of signedness.
+ SIGNED_DESCRIPTIONS = {
+ UNSIGNED: "unsigned",
+ SIGNED: "signed",
+ SIGNED_NA: "n/a"
+ }
+
+ # The descriptions of the various types of sizes.
+ SIZE_DESCRIPTIONS = {
+ SIZE_SHORT: "short",
+ SIZE_INT: "int-width",
+ SIZE_LONG: "long",
+ SIZE_LONG_LONG: "long long",
+ SIZE_8: "8-bit",
+ SIZE_16: "16-bit",
+ SIZE_32: "32-bit",
+ SIZE_64: "64-bit",
+ SIZE_P: "pointer-width"
+ }
+
+ # Provide a human-readable description of the directive.
+ def describe
+ case type
+ when SPACE
+ "whitespace"
+ when COMMENT
+ "comment"
+ when INTEGER
+ if size == SIZE_8
+ base = "#{SIGNED_DESCRIPTIONS[signed]} #{SIZE_DESCRIPTIONS[size]} integer"
+ else
+ base = "#{SIGNED_DESCRIPTIONS[signed]} #{SIZE_DESCRIPTIONS[size]} #{ENDIAN_DESCRIPTIONS[endian]} integer"
+ end
+ case length_type
+ when LENGTH_FIXED
+ if length > 1
+ base + ", x#{length}"
+ else
+ base
+ end
+ when LENGTH_MAX
+ base + ", as many as possible"
+ end
+ when UTF8
+ "UTF-8 character"
+ when BER
+ "BER-compressed integer"
+ when FLOAT
+ "#{SIZE_DESCRIPTIONS[size]} #{ENDIAN_DESCRIPTIONS[endian]} float"
+ when STRING_SPACE_PADDED
+ "arbitrary binary string (space padded)"
+ when STRING_NULL_PADDED
+ "arbitrary binary string (null padded, count is width)"
+ when STRING_NULL_TERMINATED
+ "arbitrary binary string (null padded, count is width), except that null is added with *"
+ when STRING_MSB
+ "bit string (MSB first)"
+ when STRING_LSB
+ "bit string (LSB first)"
+ when STRING_HEX_HIGH
+ "hex string (high nibble first)"
+ when STRING_HEX_LOW
+ "hex string (low nibble first)"
+ when STRING_UU
+ "UU-encoded string"
+ when STRING_MIME
+ "quoted printable, MIME encoding"
+ when STRING_BASE64
+ "base64 encoded string"
+ when STRING_FIXED
+ "pointer to a structure (fixed-length string)"
+ when STRING_POINTER
+ "pointer to a null-terminated string"
+ when MOVE
+ "move to absolute position"
+ when BACK
+ "back up a byte"
+ when NULL
+ "null byte"
+ else
+ raise
+ end
+ end
+ end
+
+ # The result of parsing a pack template.
+ class Format
+ # A list of the directives in the template.
+ attr_reader :directives
+
+ # The encoding of the template.
+ attr_reader :encoding
+
+ # Create a new Format with the given directives and encoding.
+ def initialize(directives, encoding)
+ @directives = directives
+ @encoding = encoding
+ end
+
+ # Provide a human-readable description of the format.
+ def describe
+ source_width = directives.map { |d| d.source.inspect.length }.max
+ directive_lines = directives.map do |directive|
+ if directive.type == SPACE
+ source = directive.source.inspect
+ else
+ source = directive.source
+ end
+ " #{source.ljust(source_width)} #{directive.describe}"
+ end
+
+ (["Directives:"] + directive_lines + ["Encoding:", " #{encoding}"]).join("\n")
+ end
+ end
+ end
+end
diff --git a/lib/prism/parse_result.rb b/lib/prism/parse_result.rb
new file mode 100644
index 0000000000..753d72f10b
--- /dev/null
+++ b/lib/prism/parse_result.rb
@@ -0,0 +1,460 @@
+# frozen_string_literal: true
+
+module Prism
+ # This represents a source of Ruby code that has been parsed. It is used in
+ # conjunction with locations to allow them to resolve line numbers and source
+ # ranges.
+ class Source
+ # The source code that this source object represents.
+ attr_reader :source
+
+ # The line number where this source starts.
+ attr_accessor :start_line
+
+ # The list of newline byte offsets in the source code.
+ attr_reader :offsets
+
+ # Create a new source object with the given source code and newline byte
+ # offsets. If no newline byte offsets are given, they will be computed from
+ # the source code.
+ def initialize(source, start_line = 1, offsets = compute_offsets(source))
+ @source = source
+ @start_line = start_line
+ @offsets = offsets
+ end
+
+ # Perform a byteslice on the source code using the given byte offset and
+ # byte length.
+ def slice(byte_offset, length)
+ source.byteslice(byte_offset, length)
+ end
+
+ # Binary search through the offsets to find the line number for the given
+ # byte offset.
+ def line(byte_offset)
+ start_line + find_line(byte_offset)
+ end
+
+ # Return the byte offset of the start of the line corresponding to the given
+ # byte offset.
+ def line_start(byte_offset)
+ offsets[find_line(byte_offset)]
+ end
+
+ # Return the column number for the given byte offset.
+ def column(byte_offset)
+ byte_offset - line_start(byte_offset)
+ end
+
+ # Return the character offset for the given byte offset.
+ def character_offset(byte_offset)
+ source.byteslice(0, byte_offset).length
+ end
+
+ # Return the column number in characters for the given byte offset.
+ def character_column(byte_offset)
+ character_offset(byte_offset) - character_offset(line_start(byte_offset))
+ end
+
+ private
+
+ # Binary search through the offsets to find the line number for the given
+ # byte offset.
+ def find_line(byte_offset)
+ left = 0
+ right = offsets.length - 1
+
+ while left <= right
+ mid = left + (right - left) / 2
+ return mid if offsets[mid] == byte_offset
+
+ if offsets[mid] < byte_offset
+ left = mid + 1
+ else
+ right = mid - 1
+ end
+ end
+
+ left - 1
+ end
+
+ # Find all of the newlines in the source code and return their byte offsets
+ # from the start of the string an array.
+ def compute_offsets(code)
+ offsets = [0]
+ code.b.scan("\n") { offsets << $~.end(0) }
+ offsets
+ end
+ end
+
+ # This represents a location in the source.
+ class Location
+ # A Source object that is used to determine more information from the given
+ # offset and length.
+ protected attr_reader :source
+
+ # The byte offset from the beginning of the source where this location
+ # starts.
+ attr_reader :start_offset
+
+ # The length of this location in bytes.
+ attr_reader :length
+
+ # The list of comments attached to this location
+ attr_reader :comments
+
+ # Create a new location object with the given source, start byte offset, and
+ # byte length.
+ def initialize(source, start_offset, length)
+ @source = source
+ @start_offset = start_offset
+ @length = length
+ @comments = []
+ end
+
+ # Create a new location object with the given options.
+ def copy(**options)
+ Location.new(
+ options.fetch(:source) { source },
+ options.fetch(:start_offset) { start_offset },
+ options.fetch(:length) { length }
+ )
+ end
+
+ # Returns a string representation of this location.
+ def inspect
+ "#<Prism::Location @start_offset=#{@start_offset} @length=#{@length} start_line=#{start_line}>"
+ end
+
+ # The source code that this location represents.
+ def slice
+ source.slice(start_offset, length)
+ end
+
+ # The character offset from the beginning of the source where this location
+ # starts.
+ def start_character_offset
+ source.character_offset(start_offset)
+ end
+
+ # The byte offset from the beginning of the source where this location ends.
+ def end_offset
+ start_offset + length
+ end
+
+ # The character offset from the beginning of the source where this location
+ # ends.
+ def end_character_offset
+ source.character_offset(end_offset)
+ end
+
+ # The line number where this location starts.
+ def start_line
+ source.line(start_offset)
+ end
+
+ # The content of the line where this location starts before this location.
+ def start_line_slice
+ offset = source.line_start(start_offset)
+ source.slice(offset, start_offset - offset)
+ end
+
+ # The line number where this location ends.
+ def end_line
+ source.line(end_offset)
+ end
+
+ # The column number in bytes where this location starts from the start of
+ # the line.
+ def start_column
+ source.column(start_offset)
+ end
+
+ # The column number in characters where this location ends from the start of
+ # the line.
+ def start_character_column
+ source.character_column(start_offset)
+ end
+
+ # The column number in bytes where this location ends from the start of the
+ # line.
+ def end_column
+ source.column(end_offset)
+ end
+
+ # The column number in characters where this location ends from the start of
+ # the line.
+ def end_character_column
+ source.character_column(end_offset)
+ end
+
+ # Implement the hash pattern matching interface for Location.
+ def deconstruct_keys(keys)
+ { start_offset: start_offset, end_offset: end_offset }
+ end
+
+ # Implement the pretty print interface for Location.
+ def pretty_print(q)
+ q.text("(#{start_line},#{start_column})-(#{end_line},#{end_column})")
+ end
+
+ # Returns true if the given other location is equal to this location.
+ def ==(other)
+ other.is_a?(Location) &&
+ other.start_offset == start_offset &&
+ other.end_offset == end_offset
+ end
+
+ # Returns a new location that stretches from this location to the given
+ # other location. Raises an error if this location is not before the other
+ # location or if they don't share the same source.
+ def join(other)
+ raise "Incompatible sources" if source != other.source
+ raise "Incompatible locations" if start_offset > other.start_offset
+
+ Location.new(source, start_offset, other.end_offset - start_offset)
+ end
+
+ # Returns a null location that does not correspond to a source and points to
+ # the beginning of the file. Useful for when you want a location object but
+ # do not care where it points.
+ def self.null
+ new(nil, 0, 0)
+ end
+ end
+
+ # This represents a comment that was encountered during parsing. It is the
+ # base class for all comment types.
+ class Comment
+ # The location of this comment in the source.
+ attr_reader :location
+
+ # Create a new comment object with the given location.
+ def initialize(location)
+ @location = location
+ end
+
+ # Implement the hash pattern matching interface for Comment.
+ def deconstruct_keys(keys)
+ { location: location }
+ end
+ end
+
+ # InlineComment objects are the most common. They correspond to comments in
+ # the source file like this one that start with #.
+ class InlineComment < Comment
+ # Returns true if this comment happens on the same line as other code and
+ # false if the comment is by itself.
+ def trailing?
+ !location.start_line_slice.strip.empty?
+ end
+
+ # Returns a string representation of this comment.
+ def inspect
+ "#<Prism::InlineComment @location=#{location.inspect}>"
+ end
+ end
+
+ # EmbDocComment objects correspond to comments that are surrounded by =begin
+ # and =end.
+ class EmbDocComment < Comment
+ # This can only be true for inline comments.
+ def trailing?
+ false
+ end
+
+ # Returns a string representation of this comment.
+ def inspect
+ "#<Prism::EmbDocComment @location=#{location.inspect}>"
+ end
+ end
+
+ # This represents a magic comment that was encountered during parsing.
+ class MagicComment
+ # A Location object representing the location of the key in the source.
+ attr_reader :key_loc
+
+ # A Location object representing the location of the value in the source.
+ attr_reader :value_loc
+
+ # Create a new magic comment object with the given key and value locations.
+ def initialize(key_loc, value_loc)
+ @key_loc = key_loc
+ @value_loc = value_loc
+ end
+
+ # Returns the key of the magic comment by slicing it from the source code.
+ def key
+ key_loc.slice
+ end
+
+ # Returns the value of the magic comment by slicing it from the source code.
+ def value
+ value_loc.slice
+ end
+
+ # Implement the hash pattern matching interface for MagicComment.
+ def deconstruct_keys(keys)
+ { key_loc: key_loc, value_loc: value_loc }
+ end
+
+ # Returns a string representation of this magic comment.
+ def inspect
+ "#<Prism::MagicComment @key=#{key.inspect} @value=#{value.inspect}>"
+ end
+ end
+
+ # This represents an error that was encountered during parsing.
+ class ParseError
+ # The message associated with this error.
+ attr_reader :message
+
+ # A Location object representing the location of this error in the source.
+ attr_reader :location
+
+ # Create a new error object with the given message and location.
+ def initialize(message, location)
+ @message = message
+ @location = location
+ end
+
+ # Implement the hash pattern matching interface for ParseError.
+ def deconstruct_keys(keys)
+ { message: message, location: location }
+ end
+
+ # Returns a string representation of this error.
+ def inspect
+ "#<Prism::ParseError @message=#{@message.inspect} @location=#{@location.inspect}>"
+ end
+ end
+
+ # This represents a warning that was encountered during parsing.
+ class ParseWarning
+ # The message associated with this warning.
+ attr_reader :message
+
+ # A Location object representing the location of this warning in the source.
+ attr_reader :location
+
+ # Create a new warning object with the given message and location.
+ def initialize(message, location)
+ @message = message
+ @location = location
+ end
+
+ # Implement the hash pattern matching interface for ParseWarning.
+ def deconstruct_keys(keys)
+ { message: message, location: location }
+ end
+
+ # Returns a string representation of this warning.
+ def inspect
+ "#<Prism::ParseWarning @message=#{@message.inspect} @location=#{@location.inspect}>"
+ end
+ end
+
+ # This represents the result of a call to ::parse or ::parse_file. It contains
+ # the AST, any comments that were encounters, and any errors that were
+ # encountered.
+ class ParseResult
+ # The value that was generated by parsing. Normally this holds the AST, but
+ # it can sometimes how a list of tokens or other results passed back from
+ # the parser.
+ attr_reader :value
+
+ # The list of comments that were encountered during parsing.
+ attr_reader :comments
+
+ # The list of magic comments that were encountered during parsing.
+ attr_reader :magic_comments
+
+ # An optional location that represents the location of the content after the
+ # __END__ marker. This content is loaded into the DATA constant when the
+ # file being parsed is the main file being executed.
+ attr_reader :data_loc
+
+ # The list of errors that were generated during parsing.
+ attr_reader :errors
+
+ # The list of warnings that were generated during parsing.
+ attr_reader :warnings
+
+ # A Source instance that represents the source code that was parsed.
+ attr_reader :source
+
+ # Create a new parse result object with the given values.
+ def initialize(value, comments, magic_comments, data_loc, errors, warnings, source)
+ @value = value
+ @comments = comments
+ @magic_comments = magic_comments
+ @data_loc = data_loc
+ @errors = errors
+ @warnings = warnings
+ @source = source
+ end
+
+ # Implement the hash pattern matching interface for ParseResult.
+ def deconstruct_keys(keys)
+ { value: value, comments: comments, magic_comments: magic_comments, data_loc: data_loc, errors: errors, warnings: warnings }
+ end
+
+ # Returns true if there were no errors during parsing and false if there
+ # were.
+ def success?
+ errors.empty?
+ end
+
+ # Returns true if there were errors during parsing and false if there were
+ # not.
+ def failure?
+ !success?
+ end
+ end
+
+ # This represents a token from the Ruby source.
+ class Token
+ # The type of token that this token is.
+ attr_reader :type
+
+ # A byteslice of the source that this token represents.
+ attr_reader :value
+
+ # A Location object representing the location of this token in the source.
+ attr_reader :location
+
+ # Create a new token object with the given type, value, and location.
+ def initialize(type, value, location)
+ @type = type
+ @value = value
+ @location = location
+ end
+
+ # Implement the hash pattern matching interface for Token.
+ def deconstruct_keys(keys)
+ { type: type, value: value, location: location }
+ end
+
+ # Implement the pretty print interface for Token.
+ def pretty_print(q)
+ q.group do
+ q.text(type.to_s)
+ self.location.pretty_print(q)
+ q.text("(")
+ q.nest(2) do
+ q.breakable("")
+ q.pp(value)
+ end
+ q.breakable("")
+ q.text(")")
+ end
+ end
+
+ # Returns true if the given other token is equal to this token.
+ def ==(other)
+ other.is_a?(Token) &&
+ other.type == type &&
+ other.value == value
+ end
+ end
+end
diff --git a/lib/prism/parse_result/comments.rb b/lib/prism/parse_result/comments.rb
new file mode 100644
index 0000000000..7a3a47de50
--- /dev/null
+++ b/lib/prism/parse_result/comments.rb
@@ -0,0 +1,177 @@
+# frozen_string_literal: true
+
+module Prism
+ class ParseResult
+ # When we've parsed the source, we have both the syntax tree and the list of
+ # comments that we found in the source. This class is responsible for
+ # walking the tree and finding the nearest location to attach each comment.
+ #
+ # It does this by first finding the nearest locations to each comment.
+ # Locations can either come from nodes directly or from location fields on
+ # nodes. For example, a `ClassNode` has an overall location encompassing the
+ # entire class, but it also has a location for the `class` keyword.
+ #
+ # Once the nearest locations are found, it determines which one to attach
+ # to. If it's a trailing comment (a comment on the same line as other source
+ # code), it will favor attaching to the nearest location that occurs before
+ # the comment. Otherwise it will favor attaching to the nearest location
+ # that is after the comment.
+ class Comments
+ # A target for attaching comments that is based on a specific node's
+ # location.
+ class NodeTarget # :nodoc:
+ attr_reader :node
+
+ def initialize(node)
+ @node = node
+ end
+
+ def start_offset
+ node.location.start_offset
+ end
+
+ def end_offset
+ node.location.end_offset
+ end
+
+ def encloses?(comment)
+ start_offset <= comment.location.start_offset &&
+ comment.location.end_offset <= end_offset
+ end
+
+ def <<(comment)
+ node.location.comments << comment
+ end
+ end
+
+ # A target for attaching comments that is based on a location field on a
+ # node. For example, the `end` token of a ClassNode.
+ class LocationTarget # :nodoc:
+ attr_reader :location
+
+ def initialize(location)
+ @location = location
+ end
+
+ def start_offset
+ location.start_offset
+ end
+
+ def end_offset
+ location.end_offset
+ end
+
+ def encloses?(comment)
+ false
+ end
+
+ def <<(comment)
+ location.comments << comment
+ end
+ end
+
+ # The parse result that we are attaching comments to.
+ attr_reader :parse_result
+
+ # Create a new Comments object that will attach comments to the given
+ # parse result.
+ def initialize(parse_result)
+ @parse_result = parse_result
+ end
+
+ # Attach the comments to their respective locations in the tree by
+ # mutating the parse result.
+ def attach!
+ parse_result.comments.each do |comment|
+ preceding, enclosing, following = nearest_targets(parse_result.value, comment)
+ target =
+ if comment.trailing?
+ preceding || following || enclosing || NodeTarget.new(parse_result.value)
+ else
+ # If a comment exists on its own line, prefer a leading comment.
+ following || preceding || enclosing || NodeTarget.new(parse_result.value)
+ end
+
+ target << comment
+ end
+ end
+
+ private
+
+ # Responsible for finding the nearest targets to the given comment within
+ # the context of the given encapsulating node.
+ def nearest_targets(node, comment)
+ comment_start = comment.location.start_offset
+ comment_end = comment.location.end_offset
+
+ targets = []
+ node.comment_targets.map do |value|
+ case value
+ when StatementsNode
+ targets.concat(value.body.map { |node| NodeTarget.new(node) })
+ when Node
+ targets << NodeTarget.new(value)
+ when Location
+ targets << LocationTarget.new(value)
+ end
+ end
+
+ targets.sort_by!(&:start_offset)
+ preceding = nil
+ following = nil
+
+ left = 0
+ right = targets.length
+
+ # This is a custom binary search that finds the nearest nodes to the
+ # given comment. When it finds a node that completely encapsulates the
+ # comment, it recurses downward into the tree.
+ while left < right
+ middle = (left + right) / 2
+ target = targets[middle]
+
+ target_start = target.start_offset
+ target_end = target.end_offset
+
+ if target.encloses?(comment)
+ # The comment is completely contained by this target. Abandon the
+ # binary search at this level.
+ return nearest_targets(target.node, comment)
+ end
+
+ if target_end <= comment_start
+ # This target falls completely before the comment. Because we will
+ # never consider this target or any targets before it again, this
+ # target must be the closest preceding target we have encountered so
+ # far.
+ preceding = target
+ left = middle + 1
+ next
+ end
+
+ if comment_end <= target_start
+ # This target falls completely after the comment. Because we will
+ # never consider this target or any targets after it again, this
+ # target must be the closest following target we have encountered so
+ # far.
+ following = target
+ right = middle
+ next
+ end
+
+ # This should only happen if there is a bug in this parser.
+ raise "Comment location overlaps with a target location"
+ end
+
+ [preceding, NodeTarget.new(node), following]
+ end
+ end
+
+ private_constant :Comments
+
+ # Attach the list of comments to their respective locations in the tree.
+ def attach_comments!
+ Comments.new(self).attach!
+ end
+ end
+end
diff --git a/lib/prism/parse_result/newlines.rb b/lib/prism/parse_result/newlines.rb
new file mode 100644
index 0000000000..ca05f5b702
--- /dev/null
+++ b/lib/prism/parse_result/newlines.rb
@@ -0,0 +1,64 @@
+# frozen_string_literal: true
+
+module Prism
+ class ParseResult
+ # The :line tracepoint event gets fired whenever the Ruby VM encounters an
+ # expression on a new line. The types of expressions that can trigger this
+ # event are:
+ #
+ # * if statements
+ # * unless statements
+ # * nodes that are children of statements lists
+ #
+ # In order to keep track of the newlines, we have a list of offsets that
+ # come back from the parser. We assign these offsets to the first nodes that
+ # we find in the tree that are on those lines.
+ #
+ # Note that the logic in this file should be kept in sync with the Java
+ # MarkNewlinesVisitor, since that visitor is responsible for marking the
+ # newlines for JRuby/TruffleRuby.
+ class Newlines < Visitor
+ # Create a new Newlines visitor with the given newline offsets.
+ def initialize(newline_marked)
+ @newline_marked = newline_marked
+ end
+
+ # Permit block/lambda nodes to mark newlines within themselves.
+ def visit_block_node(node)
+ old_newline_marked = @newline_marked
+ @newline_marked = Array.new(old_newline_marked.size, false)
+
+ begin
+ super(node)
+ ensure
+ @newline_marked = old_newline_marked
+ end
+ end
+
+ alias_method :visit_lambda_node, :visit_block_node
+
+ # Mark if/unless nodes as newlines.
+ def visit_if_node(node)
+ node.set_newline_flag(@newline_marked)
+ super(node)
+ end
+
+ alias_method :visit_unless_node, :visit_if_node
+
+ # Permit statements lists to mark newlines within themselves.
+ def visit_statements_node(node)
+ node.body.each do |child|
+ child.set_newline_flag(@newline_marked)
+ end
+ super(node)
+ end
+ end
+
+ private_constant :Newlines
+
+ # Walk the tree and mark nodes that are on a new line.
+ def mark_newlines!
+ value.accept(Newlines.new(Array.new(1 + source.offsets.size, false)))
+ end
+ end
+end
diff --git a/lib/prism/pattern.rb b/lib/prism/pattern.rb
new file mode 100644
index 0000000000..e1643671ec
--- /dev/null
+++ b/lib/prism/pattern.rb
@@ -0,0 +1,250 @@
+# frozen_string_literal: true
+
+module Prism
+ # A pattern is an object that wraps a Ruby pattern matching expression. The
+ # expression would normally be passed to an `in` clause within a `case`
+ # expression or a rightward assignment expression. For example, in the
+ # following snippet:
+ #
+ # case node
+ # in ConstantPathNode[ConstantReadNode[name: :Prism], ConstantReadNode[name: :Pattern]]
+ # end
+ #
+ # the pattern is the <tt>ConstantPathNode[...]</tt> expression.
+ #
+ # The pattern gets compiled into an object that responds to #call by running
+ # the #compile method. This method itself will run back through Prism to
+ # parse the expression into a tree, then walk the tree to generate the
+ # necessary callable objects. For example, if you wanted to compile the
+ # expression above into a callable, you would:
+ #
+ # callable = Prism::Pattern.new("ConstantPathNode[ConstantReadNode[name: :Prism], ConstantReadNode[name: :Pattern]]").compile
+ # callable.call(node)
+ #
+ # The callable object returned by #compile is guaranteed to respond to #call
+ # with a single argument, which is the node to match against. It also is
+ # guaranteed to respond to #===, which means it itself can be used in a `case`
+ # expression, as in:
+ #
+ # case node
+ # when callable
+ # end
+ #
+ # If the query given to the initializer cannot be compiled into a valid
+ # matcher (either because of a syntax error or because it is using syntax we
+ # do not yet support) then a Prism::Pattern::CompilationError will be
+ # raised.
+ class Pattern
+ # Raised when the query given to a pattern is either invalid Ruby syntax or
+ # is using syntax that we don't yet support.
+ class CompilationError < StandardError
+ # Create a new CompilationError with the given representation of the node
+ # that caused the error.
+ def initialize(repr)
+ super(<<~ERROR)
+ prism was unable to compile the pattern you provided into a usable
+ expression. It failed on to understand the node represented by:
+
+ #{repr}
+
+ Note that not all syntax supported by Ruby's pattern matching syntax
+ is also supported by prism's patterns. If you're using some syntax
+ that you believe should be supported, please open an issue on
+ GitHub at https://github.com/ruby/prism/issues/new.
+ ERROR
+ end
+ end
+
+ # The query that this pattern was initialized with.
+ attr_reader :query
+
+ # Create a new pattern with the given query. The query should be a string
+ # containing a Ruby pattern matching expression.
+ def initialize(query)
+ @query = query
+ @compiled = nil
+ end
+
+ # Compile the query into a callable object that can be used to match against
+ # nodes.
+ def compile
+ result = Prism.parse("case nil\nin #{query}\nend")
+ compile_node(result.value.statements.body.last.conditions.last.pattern)
+ end
+
+ # Scan the given node and all of its children for nodes that match the
+ # pattern. If a block is given, it will be called with each node that
+ # matches the pattern. If no block is given, an enumerator will be returned
+ # that will yield each node that matches the pattern.
+ def scan(root)
+ return to_enum(__method__, root) unless block_given?
+
+ @compiled ||= compile
+ queue = [root]
+
+ while (node = queue.shift)
+ yield node if @compiled.call(node)
+ queue.concat(node.compact_child_nodes)
+ end
+ end
+
+ private
+
+ # Shortcut for combining two procs into one that returns true if both return
+ # true.
+ def combine_and(left, right)
+ ->(other) { left.call(other) && right.call(other) }
+ end
+
+ # Shortcut for combining two procs into one that returns true if either
+ # returns true.
+ def combine_or(left, right)
+ ->(other) { left.call(other) || right.call(other) }
+ end
+
+ # Raise an error because the given node is not supported.
+ def compile_error(node)
+ raise CompilationError, node.inspect
+ end
+
+ # in [foo, bar, baz]
+ def compile_array_pattern_node(node)
+ compile_error(node) if !node.rest.nil? || node.posts.any?
+
+ constant = node.constant
+ compiled_constant = compile_node(constant) if constant
+
+ preprocessed = node.requireds.map { |required| compile_node(required) }
+
+ compiled_requireds = ->(other) do
+ deconstructed = other.deconstruct
+
+ deconstructed.length == preprocessed.length &&
+ preprocessed
+ .zip(deconstructed)
+ .all? { |(matcher, value)| matcher.call(value) }
+ end
+
+ if compiled_constant
+ combine_and(compiled_constant, compiled_requireds)
+ else
+ compiled_requireds
+ end
+ end
+
+ # in foo | bar
+ def compile_alternation_pattern_node(node)
+ combine_or(compile_node(node.left), compile_node(node.right))
+ end
+
+ # in Prism::ConstantReadNode
+ def compile_constant_path_node(node)
+ parent = node.parent
+
+ if parent.is_a?(ConstantReadNode) && parent.slice == "Prism"
+ compile_node(node.child)
+ else
+ compile_error(node)
+ end
+ end
+
+ # in ConstantReadNode
+ # in String
+ def compile_constant_read_node(node)
+ value = node.slice
+
+ if Prism.const_defined?(value, false)
+ clazz = Prism.const_get(value)
+
+ ->(other) { clazz === other }
+ elsif Object.const_defined?(value, false)
+ clazz = Object.const_get(value)
+
+ ->(other) { clazz === other }
+ else
+ compile_error(node)
+ end
+ end
+
+ # in InstanceVariableReadNode[name: Symbol]
+ # in { name: Symbol }
+ def compile_hash_pattern_node(node)
+ compile_error(node) if node.rest
+ compiled_constant = compile_node(node.constant) if node.constant
+
+ preprocessed =
+ node.elements.to_h do |element|
+ [element.key.unescaped.to_sym, compile_node(element.value)]
+ end
+
+ compiled_keywords = ->(other) do
+ deconstructed = other.deconstruct_keys(preprocessed.keys)
+
+ preprocessed.all? do |keyword, matcher|
+ deconstructed.key?(keyword) && matcher.call(deconstructed[keyword])
+ end
+ end
+
+ if compiled_constant
+ combine_and(compiled_constant, compiled_keywords)
+ else
+ compiled_keywords
+ end
+ end
+
+ # in nil
+ def compile_nil_node(node)
+ ->(attribute) { attribute.nil? }
+ end
+
+ # in /foo/
+ def compile_regular_expression_node(node)
+ regexp = Regexp.new(node.unescaped, node.closing[1..])
+
+ ->(attribute) { regexp === attribute }
+ end
+
+ # in ""
+ # in "foo"
+ def compile_string_node(node)
+ string = node.unescaped
+
+ ->(attribute) { string === attribute }
+ end
+
+ # in :+
+ # in :foo
+ def compile_symbol_node(node)
+ symbol = node.unescaped.to_sym
+
+ ->(attribute) { symbol === attribute }
+ end
+
+ # Compile any kind of node. Dispatch out to the individual compilation
+ # methods based on the type of node.
+ def compile_node(node)
+ case node
+ when AlternationPatternNode
+ compile_alternation_pattern_node(node)
+ when ArrayPatternNode
+ compile_array_pattern_node(node)
+ when ConstantPathNode
+ compile_constant_path_node(node)
+ when ConstantReadNode
+ compile_constant_read_node(node)
+ when HashPatternNode
+ compile_hash_pattern_node(node)
+ when NilNode
+ compile_nil_node(node)
+ when RegularExpressionNode
+ compile_regular_expression_node(node)
+ when StringNode
+ compile_string_node(node)
+ when SymbolNode
+ compile_symbol_node(node)
+ else
+ compile_error(node)
+ end
+ end
+ end
+end
diff --git a/lib/prism/prism.gemspec b/lib/prism/prism.gemspec
new file mode 100644
index 0000000000..9f5cea4e20
--- /dev/null
+++ b/lib/prism/prism.gemspec
@@ -0,0 +1,119 @@
+# frozen_string_literal: true
+
+Gem::Specification.new do |spec|
+ spec.name = "prism"
+ spec.version = "0.19.0"
+ spec.authors = ["Shopify"]
+ spec.email = ["ruby@shopify.com"]
+
+ spec.summary = "Prism Ruby parser"
+ spec.homepage = "https://github.com/ruby/prism"
+ spec.license = "MIT"
+
+ spec.required_ruby_version = ">= 3.0.0"
+
+ spec.require_paths = ["lib"]
+ spec.files = [
+ "CHANGELOG.md",
+ "CODE_OF_CONDUCT.md",
+ "CONTRIBUTING.md",
+ "LICENSE.md",
+ "Makefile",
+ "README.md",
+ "config.yml",
+ "docs/build_system.md",
+ "docs/building.md",
+ "docs/configuration.md",
+ "docs/design.md",
+ "docs/encoding.md",
+ "docs/fuzzing.md",
+ "docs/heredocs.md",
+ "docs/javascript.md",
+ "docs/local_variable_depth.md",
+ "docs/mapping.md",
+ "docs/releasing.md",
+ "docs/ripper.md",
+ "docs/ruby_api.md",
+ "docs/serialization.md",
+ "docs/testing.md",
+ "ext/prism/api_node.c",
+ "ext/prism/api_pack.c",
+ "ext/prism/extension.c",
+ "ext/prism/extension.h",
+ "include/prism.h",
+ "include/prism/ast.h",
+ "include/prism/defines.h",
+ "include/prism/diagnostic.h",
+ "include/prism/encoding.h",
+ "include/prism/node.h",
+ "include/prism/options.h",
+ "include/prism/pack.h",
+ "include/prism/parser.h",
+ "include/prism/prettyprint.h",
+ "include/prism/regexp.h",
+ "include/prism/util/pm_buffer.h",
+ "include/prism/util/pm_char.h",
+ "include/prism/util/pm_constant_pool.h",
+ "include/prism/util/pm_list.h",
+ "include/prism/util/pm_memchr.h",
+ "include/prism/util/pm_newline_list.h",
+ "include/prism/util/pm_state_stack.h",
+ "include/prism/util/pm_strncasecmp.h",
+ "include/prism/util/pm_string.h",
+ "include/prism/util/pm_string_list.h",
+ "include/prism/util/pm_strpbrk.h",
+ "include/prism/version.h",
+ "lib/prism.rb",
+ "lib/prism/compiler.rb",
+ "lib/prism/debug.rb",
+ "lib/prism/desugar_compiler.rb",
+ "lib/prism/dispatcher.rb",
+ "lib/prism/dot_visitor.rb",
+ "lib/prism/dsl.rb",
+ "lib/prism/ffi.rb",
+ "lib/prism/lex_compat.rb",
+ "lib/prism/mutation_compiler.rb",
+ "lib/prism/node.rb",
+ "lib/prism/node_ext.rb",
+ "lib/prism/node_inspector.rb",
+ "lib/prism/pack.rb",
+ "lib/prism/parse_result.rb",
+ "lib/prism/pattern.rb",
+ "lib/prism/ripper_compat.rb",
+ "lib/prism/serialize.rb",
+ "lib/prism/parse_result/comments.rb",
+ "lib/prism/parse_result/newlines.rb",
+ "lib/prism/visitor.rb",
+ "src/diagnostic.c",
+ "src/encoding.c",
+ "src/node.c",
+ "src/pack.c",
+ "src/prettyprint.c",
+ "src/regexp.c",
+ "src/serialize.c",
+ "src/token_type.c",
+ "src/util/pm_buffer.c",
+ "src/util/pm_char.c",
+ "src/util/pm_constant_pool.c",
+ "src/util/pm_list.c",
+ "src/util/pm_memchr.c",
+ "src/util/pm_newline_list.c",
+ "src/util/pm_state_stack.c",
+ "src/util/pm_string.c",
+ "src/util/pm_string_list.c",
+ "src/util/pm_strncasecmp.c",
+ "src/util/pm_strpbrk.c",
+ "src/options.c",
+ "src/prism.c",
+ "prism.gemspec",
+ "sig/prism.rbs",
+ "sig/prism_static.rbs",
+ "rbi/prism.rbi",
+ "rbi/prism_static.rbi"
+ ]
+
+ spec.extensions = ["ext/prism/extconf.rb"]
+ spec.metadata["allowed_push_host"] = "https://rubygems.org"
+ spec.metadata["source_code_uri"] = "https://github.com/ruby/prism"
+ spec.metadata["changelog_uri"] = "https://github.com/ruby/prism/blob/main/CHANGELOG.md"
+end
diff --git a/lib/prism/ripper_compat.rb b/lib/prism/ripper_compat.rb
new file mode 100644
index 0000000000..5bd3088a6a
--- /dev/null
+++ b/lib/prism/ripper_compat.rb
@@ -0,0 +1,207 @@
+# frozen_string_literal: true
+
+require "ripper"
+
+module Prism
+ # Note: This integration is not finished, and therefore still has many
+ # inconsistencies with Ripper. If you'd like to help out, pull requests would
+ # be greatly appreciated!
+ #
+ # This class is meant to provide a compatibility layer between prism and
+ # Ripper. It functions by parsing the entire tree first and then walking it
+ # and executing each of the Ripper callbacks as it goes.
+ #
+ # This class is going to necessarily be slower than the native Ripper API. It
+ # is meant as a stopgap until developers migrate to using prism. It is also
+ # meant as a test harness for the prism parser.
+ #
+ # To use this class, you treat `Prism::RipperCompat` effectively as you would
+ # treat the `Ripper` class.
+ class RipperCompat < Visitor
+ # This class mirrors the ::Ripper::SexpBuilder subclass of ::Ripper that
+ # returns the arrays of [type, *children].
+ class SexpBuilder < RipperCompat
+ private
+
+ Ripper::PARSER_EVENTS.each do |event|
+ define_method(:"on_#{event}") do |*args|
+ [event, *args]
+ end
+ end
+
+ Ripper::SCANNER_EVENTS.each do |event|
+ define_method(:"on_#{event}") do |value|
+ [:"@#{event}", value, [lineno, column]]
+ end
+ end
+ end
+
+ # This class mirrors the ::Ripper::SexpBuilderPP subclass of ::Ripper that
+ # returns the same values as ::Ripper::SexpBuilder except with a couple of
+ # niceties that flatten linked lists into arrays.
+ class SexpBuilderPP < SexpBuilder
+ private
+
+ def _dispatch_event_new # :nodoc:
+ []
+ end
+
+ def _dispatch_event_push(list, item) # :nodoc:
+ list << item
+ list
+ end
+
+ Ripper::PARSER_EVENT_TABLE.each do |event, arity|
+ case event
+ when /_new\z/
+ alias_method :"on_#{event}", :_dispatch_event_new if arity == 0
+ when /_add\z/
+ alias_method :"on_#{event}", :_dispatch_event_push
+ end
+ end
+ end
+
+ # The source that is being parsed.
+ attr_reader :source
+
+ # The current line number of the parser.
+ attr_reader :lineno
+
+ # The current column number of the parser.
+ attr_reader :column
+
+ # Create a new RipperCompat object with the given source.
+ def initialize(source)
+ @source = source
+ @result = nil
+ @lineno = nil
+ @column = nil
+ end
+
+ ############################################################################
+ # Public interface
+ ############################################################################
+
+ # True if the parser encountered an error during parsing.
+ def error?
+ result.failure?
+ end
+
+ # Parse the source and return the result.
+ def parse
+ result.magic_comments.each do |magic_comment|
+ on_magic_comment(magic_comment.key, magic_comment.value)
+ end
+
+ if error?
+ result.errors.each do |error|
+ on_parse_error(error.message)
+ end
+ else
+ result.value.accept(self)
+ end
+ end
+
+ ############################################################################
+ # Visitor methods
+ ############################################################################
+
+ # Visit a CallNode node.
+ def visit_call_node(node)
+ if !node.message.match?(/^[[:alpha:]_]/) && node.opening_loc.nil? && node.arguments&.arguments&.length == 1
+ left = visit(node.receiver)
+ right = visit(node.arguments.arguments.first)
+
+ bounds(node.location)
+ on_binary(left, node.name, right)
+ else
+ raise NotImplementedError
+ end
+ end
+
+ # Visit a FloatNode node.
+ def visit_float_node(node)
+ bounds(node.location)
+ on_float(node.slice)
+ end
+
+ # Visit a ImaginaryNode node.
+ def visit_imaginary_node(node)
+ bounds(node.location)
+ on_imaginary(node.slice)
+ end
+
+ # Visit an IntegerNode node.
+ def visit_integer_node(node)
+ bounds(node.location)
+ on_int(node.slice)
+ end
+
+ # Visit a RationalNode node.
+ def visit_rational_node(node)
+ bounds(node.location)
+ on_rational(node.slice)
+ end
+
+ # Visit a StatementsNode node.
+ def visit_statements_node(node)
+ bounds(node.location)
+ node.body.inject(on_stmts_new) do |stmts, stmt|
+ on_stmts_add(stmts, visit(stmt))
+ end
+ end
+
+ # Visit a ProgramNode node.
+ def visit_program_node(node)
+ statements = visit(node.statements)
+ bounds(node.location)
+ on_program(statements)
+ end
+
+ ############################################################################
+ # Entrypoints for subclasses
+ ############################################################################
+
+ # This is a convenience method that runs the SexpBuilder subclass parser.
+ def self.sexp_raw(source)
+ SexpBuilder.new(source).parse
+ end
+
+ # This is a convenience method that runs the SexpBuilderPP subclass parser.
+ def self.sexp(source)
+ SexpBuilderPP.new(source).parse
+ end
+
+ private
+
+ # This method is responsible for updating lineno and column information
+ # to reflect the current node.
+ #
+ # This method could be drastically improved with some caching on the start
+ # of every line, but for now it's good enough.
+ def bounds(location)
+ @lineno = location.start_line
+ @column = location.start_column
+ end
+
+ # Lazily initialize the parse result.
+ def result
+ @result ||= Prism.parse(source)
+ end
+
+ def _dispatch0; end # :nodoc:
+ def _dispatch1(_); end # :nodoc:
+ def _dispatch2(_, _); end # :nodoc:
+ def _dispatch3(_, _, _); end # :nodoc:
+ def _dispatch4(_, _, _, _); end # :nodoc:
+ def _dispatch5(_, _, _, _, _); end # :nodoc:
+ def _dispatch7(_, _, _, _, _, _, _); end # :nodoc:
+
+ alias_method :on_parse_error, :_dispatch1
+ alias_method :on_magic_comment, :_dispatch2
+
+ (Ripper::SCANNER_EVENT_TABLE.merge(Ripper::PARSER_EVENT_TABLE)).each do |event, arity|
+ alias_method :"on_#{event}", :"_dispatch#{arity}"
+ end
+ end
+end
diff --git a/lib/pstore.gemspec b/lib/pstore.gemspec
new file mode 100644
index 0000000000..86051d2f43
--- /dev/null
+++ b/lib/pstore.gemspec
@@ -0,0 +1,32 @@
+# frozen_string_literal: true
+
+name = File.basename(__FILE__, ".gemspec")
+version = ["lib", Array.new(name.count("-")+1, ".").join("/")].find do |dir|
+ break File.foreach(File.join(__dir__, dir, "#{name.tr('-', '/')}.rb")) do |line|
+ /^\s*VERSION\s*=\s*"(.*)"/ =~ line and break $1
+ end rescue nil
+end
+
+Gem::Specification.new do |spec|
+ spec.name = name
+ spec.version = version
+ spec.authors = ["Yukihiro Matsumoto"]
+ spec.email = ["matz@ruby-lang.org"]
+
+ spec.summary = %q{Transactional File Storage for Ruby Objects}
+ spec.description = spec.summary
+ spec.homepage = "https://github.com/ruby/pstore"
+ spec.licenses = ["Ruby", "BSD-2-Clause"]
+
+ spec.metadata["homepage_uri"] = spec.homepage
+ spec.metadata["source_code_uri"] = "https://github.com/ruby/pstore"
+
+ # Specify which files should be added to the gem when it is released.
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
+ spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
+ `git ls-files -z 2>#{IO::NULL}`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
+ end
+ spec.bindir = "exe"
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
+ spec.require_paths = ["lib"]
+end
diff --git a/lib/pstore.rb b/lib/pstore.rb
index 72deaa1017..818ffa07e0 100644
--- a/lib/pstore.rb
+++ b/lib/pstore.rb
@@ -326,7 +326,7 @@ require "digest"
# end
#
class PStore
- VERSION = "0.1.2"
+ VERSION = "0.1.3"
RDWR_ACCESS = {mode: IO::RDWR | IO::CREAT | IO::BINARY, encoding: Encoding::ASCII_8BIT}.freeze
RD_ACCESS = {mode: IO::RDONLY | IO::BINARY, encoding: Encoding::ASCII_8BIT}.freeze
@@ -487,8 +487,6 @@ class PStore
# end
#
# Raises an exception if called outside a transaction block.
- #
- # PStore#roots is an alias for PStore#keys.
def keys
in_transaction
@table.keys
@@ -504,8 +502,6 @@ class PStore
# end
#
# Raises an exception if called outside a transaction block.
- #
- # PStore#root? is an alias for PStore#key?.
def key?(key)
in_transaction
@table.key? key
@@ -521,8 +517,8 @@ class PStore
end
# Exits the current transaction block, committing any changes
- # specified in the transaction block.
- # See {Committing or Aborting}[rdoc-ref:PStore@Committing+or+Aborting].
+ # specified in the
+ # {transaction block}[rdoc-ref:PStore@The+Transaction+Block].
#
# Raises an exception if called outside a transaction block.
def commit
@@ -532,8 +528,8 @@ class PStore
end
# Exits the current transaction block, discarding any changes
- # specified in the transaction block.
- # See {Committing or Aborting}[rdoc-ref:PStore@Committing+or+Aborting].
+ # specified in the
+ # {transaction block}[rdoc-ref:PStore@The+Transaction+Block].
#
# Raises an exception if called outside a transaction block.
def abort
diff --git a/lib/pstore/pstore.gemspec b/lib/pstore/pstore.gemspec
deleted file mode 100644
index 8425795afe..0000000000
--- a/lib/pstore/pstore.gemspec
+++ /dev/null
@@ -1,32 +0,0 @@
-# frozen_string_literal: true
-
-name = File.basename(__FILE__, ".gemspec")
-version = ["lib", Array.new(name.count("-")+1, "..").join("/")].find do |dir|
- break File.foreach(File.join(__dir__, dir, "#{name.tr('-', '/')}.rb")) do |line|
- /^\s*VERSION\s*=\s*"(.*)"/ =~ line and break $1
- end rescue nil
-end
-
-Gem::Specification.new do |spec|
- spec.name = name
- spec.version = version
- spec.authors = ["Yukihiro Matsumoto"]
- spec.email = ["matz@ruby-lang.org"]
-
- spec.summary = %q{Transactional File Storage for Ruby Objects}
- spec.description = spec.summary
- spec.homepage = "https://github.com/ruby/pstore"
- spec.licenses = ["Ruby", "BSD-2-Clause"]
-
- spec.metadata["homepage_uri"] = spec.homepage
- spec.metadata["source_code_uri"] = "https://github.com/ruby/pstore"
-
- # Specify which files should be added to the gem when it is released.
- # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
- spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
- `git ls-files -z 2>/dev/null`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
- end
- spec.bindir = "exe"
- spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
- spec.require_paths = ["lib"]
-end
diff --git a/lib/racc.rb b/lib/racc.rb
deleted file mode 100644
index f6e4ac03a8..0000000000
--- a/lib/racc.rb
+++ /dev/null
@@ -1,6 +0,0 @@
-require 'racc/compat'
-require 'racc/debugflags'
-require 'racc/grammar'
-require 'racc/state'
-require 'racc/exception'
-require 'racc/info'
diff --git a/lib/racc/compat.rb b/lib/racc/compat.rb
deleted file mode 100644
index 62f4f630be..0000000000
--- a/lib/racc/compat.rb
+++ /dev/null
@@ -1,33 +0,0 @@
-#--
-#
-#
-#
-# Copyright (c) 1999-2006 Minero Aoki
-#
-# This program is free software.
-# You can distribute/modify this program under the same terms of ruby.
-# see the file "COPYING".
-#
-#++
-
-unless Object.method_defined?(:__send)
- class Object
- alias __send __send__
- end
-end
-
-unless Object.method_defined?(:__send!)
- class Object
- alias __send! __send__
- end
-end
-
-unless Array.method_defined?(:map!)
- class Array
- if Array.method_defined?(:collect!)
- alias map! collect!
- else
- alias map! filter
- end
- end
-end
diff --git a/lib/racc/debugflags.rb b/lib/racc/debugflags.rb
deleted file mode 100644
index ee34cf2314..0000000000
--- a/lib/racc/debugflags.rb
+++ /dev/null
@@ -1,60 +0,0 @@
-#--
-#
-#
-#
-# Copyright (c) 1999-2006 Minero Aoki
-#
-# This program is free software.
-# You can distribute/modify this program under the same terms of ruby.
-# see the file "COPYING".
-#
-#++
-
-module Racc
-
- class DebugFlags
- def DebugFlags.parse_option_string(s)
- parse = rule = token = state = la = prec = conf = false
- s.split(//).each do |ch|
- case ch
- when 'p' then parse = true
- when 'r' then rule = true
- when 't' then token = true
- when 's' then state = true
- when 'l' then la = true
- when 'c' then prec = true
- when 'o' then conf = true
- else
- raise "unknown debug flag char: #{ch.inspect}"
- end
- end
- new(parse, rule, token, state, la, prec, conf)
- end
-
- def initialize(parse = false, rule = false, token = false, state = false,
- la = false, prec = false, conf = false)
- @parse = parse
- @rule = rule
- @token = token
- @state = state
- @la = la
- @prec = prec
- @any = (parse || rule || token || state || la || prec)
- @status_logging = conf
- end
-
- attr_reader :parse
- attr_reader :rule
- attr_reader :token
- attr_reader :state
- attr_reader :la
- attr_reader :prec
-
- def any?
- @any
- end
-
- attr_reader :status_logging
- end
-
-end
diff --git a/lib/racc/exception.rb b/lib/racc/exception.rb
deleted file mode 100644
index c11dc2e43e..0000000000
--- a/lib/racc/exception.rb
+++ /dev/null
@@ -1,16 +0,0 @@
-#--
-#
-#
-#
-# Copyright (c) 1999-2006 Minero Aoki
-#
-# This program is free software.
-# You can distribute/modify this program under the same terms of ruby.
-# see the file "COPYING".
-#
-#++
-
-module Racc
- class Error < StandardError; end
- class CompileError < Error; end
-end
diff --git a/lib/racc/grammar.rb b/lib/racc/grammar.rb
deleted file mode 100644
index 01c4c3df69..0000000000
--- a/lib/racc/grammar.rb
+++ /dev/null
@@ -1,1118 +0,0 @@
-#--
-#
-#
-#
-# Copyright (c) 1999-2006 Minero Aoki
-#
-# This program is free software.
-# You can distribute/modify this program under the same terms of ruby.
-# see the file "COPYING".
-#
-#++
-
-require 'racc/compat'
-require 'racc/iset'
-require 'racc/sourcetext'
-require 'racc/logfilegenerator'
-require 'racc/exception'
-require 'forwardable'
-
-module Racc
-
- class Grammar
-
- def initialize(debug_flags = DebugFlags.new)
- @symboltable = SymbolTable.new
- @debug_symbol = debug_flags.token
- @rules = [] # :: [Rule]
- @start = nil
- @n_expected_srconflicts = nil
- @prec_table = []
- @prec_table_closed = false
- @closed = false
- @states = nil
- end
-
- attr_reader :start
- attr_reader :symboltable
- attr_accessor :n_expected_srconflicts
-
- def [](x)
- @rules[x]
- end
-
- def each_rule(&block)
- @rules.each(&block)
- end
-
- alias each each_rule
-
- def each_index(&block)
- @rules.each_index(&block)
- end
-
- def each_with_index(&block)
- @rules.each_with_index(&block)
- end
-
- def size
- @rules.size
- end
-
- def to_s
- "<Racc::Grammar>"
- end
-
- extend Forwardable
-
- def_delegator "@symboltable", :each, :each_symbol
- def_delegator "@symboltable", :each_terminal
- def_delegator "@symboltable", :each_nonterminal
-
- def intern(value, dummy = false)
- @symboltable.intern(value, dummy)
- end
-
- def symbols
- @symboltable.symbols
- end
-
- def nonterminal_base
- @symboltable.nt_base
- end
-
- def useless_nonterminal_exist?
- n_useless_nonterminals() != 0
- end
-
- def n_useless_nonterminals
- @n_useless_nonterminals ||= each_useless_nonterminal.count
- end
-
- def each_useless_nonterminal
- return to_enum __method__ unless block_given?
-
- @symboltable.each_nonterminal do |sym|
- yield sym if sym.useless?
- end
- end
-
- def useless_rule_exist?
- n_useless_rules() != 0
- end
-
- def n_useless_rules
- @n_useless_rules ||= each_useless_rule.count
- end
-
- def each_useless_rule
- return to_enum __method__ unless block_given?
-
- each do |r|
- yield r if r.useless?
- end
- end
-
- def nfa
- (@states ||= States.new(self)).nfa
- end
-
- def dfa
- (@states ||= States.new(self)).dfa
- end
-
- alias states dfa
-
- def state_transition_table
- states().state_transition_table
- end
-
- def parser_class
- states = states() # cache
- if $DEBUG
- srcfilename = caller(1).first.slice(/\A(.*?):/, 1)
- begin
- write_log srcfilename + ".output"
- rescue SystemCallError
- end
- report = lambda {|s| $stderr.puts "racc: #{srcfilename}: #{s}" }
- if states.should_report_srconflict?
- report["#{states.n_srconflicts} shift/reduce conflicts"]
- end
- if states.rrconflict_exist?
- report["#{states.n_rrconflicts} reduce/reduce conflicts"]
- end
- g = states.grammar
- if g.useless_nonterminal_exist?
- report["#{g.n_useless_nonterminals} useless nonterminals"]
- end
- if g.useless_rule_exist?
- report["#{g.n_useless_rules} useless rules"]
- end
- end
- states.state_transition_table.parser_class
- end
-
- def write_log(path)
- File.open(path, 'w') {|f|
- LogFileGenerator.new(states()).output f
- }
- end
-
- #
- # Grammar Definition Interface
- #
-
- def add(rule)
- raise ArgumentError, "rule added after the Grammar closed" if @closed
- @rules.push rule
- end
-
- def added?(sym)
- @rules.detect {|r| r.target == sym }
- end
-
- def start_symbol=(s)
- raise CompileError, "start symbol set twice'" if @start
- @start = s
- end
-
- def declare_precedence(assoc, syms)
- raise CompileError, "precedence table defined twice" if @prec_table_closed
- @prec_table.push [assoc, syms]
- end
-
- def end_precedence_declaration(reverse)
- @prec_table_closed = true
- return if @prec_table.empty?
- table = reverse ? @prec_table.reverse : @prec_table
- table.each_with_index do |(assoc, syms), idx|
- syms.each do |sym|
- sym.assoc = assoc
- sym.precedence = idx
- end
- end
- end
-
- #
- # Dynamic Generation Interface
- #
-
- def Grammar.define(&block)
- env = DefinitionEnv.new
- env.instance_eval(&block)
- env.grammar
- end
-
- class DefinitionEnv
- def initialize
- @grammar = Grammar.new
- @seqs = Hash.new(0)
- @delayed = []
- end
-
- def grammar
- flush_delayed
- @grammar.each do |rule|
- if rule.specified_prec
- rule.specified_prec = @grammar.intern(rule.specified_prec)
- end
- end
- @grammar.init
- @grammar
- end
-
- def precedence_table(&block)
- env = PrecedenceDefinitionEnv.new(@grammar)
- env.instance_eval(&block)
- @grammar.end_precedence_declaration env.reverse
- end
-
- def method_missing(mid, *args, &block)
- unless mid.to_s[-1,1] == '='
- super # raises NoMethodError
- end
- target = @grammar.intern(mid.to_s.chop.intern)
- unless args.size == 1
- raise ArgumentError, "too many arguments for #{mid} (#{args.size} for 1)"
- end
- _add target, args.first
- end
-
- def _add(target, x)
- case x
- when Sym
- @delayed.each do |rule|
- rule.replace x, target if rule.target == x
- end
- @grammar.symboltable.delete x
- else
- x.each_rule do |r|
- r.target = target
- @grammar.add r
- end
- end
- flush_delayed
- end
-
- def _delayed_add(rule)
- @delayed.push rule
- end
-
- def _added?(sym)
- @grammar.added?(sym) or @delayed.detect {|r| r.target == sym }
- end
-
- def flush_delayed
- return if @delayed.empty?
- @delayed.each do |rule|
- @grammar.add rule
- end
- @delayed.clear
- end
-
- def seq(*list, &block)
- Rule.new(nil, list.map {|x| _intern(x) }, UserAction.proc(block))
- end
-
- def null(&block)
- seq(&block)
- end
-
- def action(&block)
- id = "@#{@seqs["action"] += 1}".intern
- _delayed_add Rule.new(@grammar.intern(id), [], UserAction.proc(block))
- id
- end
-
- alias _ action
-
- def option(sym, default = nil, &block)
- _defmetasyntax("option", _intern(sym), block) {|target|
- seq() { default } | seq(sym)
- }
- end
-
- def many(sym, &block)
- _defmetasyntax("many", _intern(sym), block) {|target|
- seq() { [] }\
- | seq(target, sym) {|list, x| list.push x; list }
- }
- end
-
- def many1(sym, &block)
- _defmetasyntax("many1", _intern(sym), block) {|target|
- seq(sym) {|x| [x] }\
- | seq(target, sym) {|list, x| list.push x; list }
- }
- end
-
- def separated_by(sep, sym, &block)
- option(separated_by1(sep, sym), [], &block)
- end
-
- def separated_by1(sep, sym, &block)
- _defmetasyntax("separated_by1", _intern(sym), block) {|target|
- seq(sym) {|x| [x] }\
- | seq(target, sep, sym) {|list, _, x| list.push x; list }
- }
- end
-
- def _intern(x)
- case x
- when Symbol, String
- @grammar.intern(x)
- when Racc::Sym
- x
- else
- raise TypeError, "wrong type #{x.class} (expected Symbol/String/Racc::Sym)"
- end
- end
-
- private
-
- def _defmetasyntax(type, id, action, &block)
- if action
- idbase = "#{type}@#{id}-#{@seqs[type] += 1}"
- target = _wrap(idbase, "#{idbase}-core", action)
- _register("#{idbase}-core", &block)
- else
- target = _register("#{type}@#{id}", &block)
- end
- @grammar.intern(target)
- end
-
- def _register(target_name)
- target = target_name.intern
- unless _added?(@grammar.intern(target))
- yield(target).each_rule do |rule|
- rule.target = @grammar.intern(target)
- _delayed_add rule
- end
- end
- target
- end
-
- def _wrap(target_name, sym, block)
- target = target_name.intern
- _delayed_add Rule.new(@grammar.intern(target),
- [@grammar.intern(sym.intern)],
- UserAction.proc(block))
- target
- end
- end
-
- class PrecedenceDefinitionEnv
- def initialize(g)
- @grammar = g
- @prechigh_seen = false
- @preclow_seen = false
- @reverse = false
- end
-
- attr_reader :reverse
-
- def higher
- if @prechigh_seen
- raise CompileError, "prechigh used twice"
- end
- @prechigh_seen = true
- end
-
- def lower
- if @preclow_seen
- raise CompileError, "preclow used twice"
- end
- if @prechigh_seen
- @reverse = true
- end
- @preclow_seen = true
- end
-
- def left(*syms)
- @grammar.declare_precedence :Left, syms.map {|s| @grammar.intern(s) }
- end
-
- def right(*syms)
- @grammar.declare_precedence :Right, syms.map {|s| @grammar.intern(s) }
- end
-
- def nonassoc(*syms)
- @grammar.declare_precedence :Nonassoc, syms.map {|s| @grammar.intern(s)}
- end
- end
-
- #
- # Computation
- #
-
- def init
- return if @closed
- @closed = true
- @start ||= @rules.map {|r| r.target }.detect {|sym| not sym.dummy? }
- raise CompileError, 'no rule in input' if @rules.empty?
- add_start_rule
- @rules.freeze
- fix_ident
- compute_hash
- compute_heads
- determine_terminals
- compute_nullable_0
- @symboltable.fix
- compute_locate
- @symboltable.each_nonterminal {|t| compute_expand t }
- compute_nullable
- compute_useless
- end
-
- private
-
- def add_start_rule
- r = Rule.new(@symboltable.dummy,
- [@start, @symboltable.anchor, @symboltable.anchor],
- UserAction.empty)
- r.ident = 0
- r.hash = 0
- r.precedence = nil
- @rules.unshift r
- end
-
- # Rule#ident
- # LocationPointer#ident
- def fix_ident
- @rules.each_with_index do |rule, idx|
- rule.ident = idx
- end
- end
-
- # Rule#hash
- def compute_hash
- hash = 4 # size of dummy rule
- @rules.each do |rule|
- rule.hash = hash
- hash += (rule.size + 1)
- end
- end
-
- # Sym#heads
- def compute_heads
- @rules.each do |rule|
- rule.target.heads.push rule.ptrs[0]
- end
- end
-
- # Sym#terminal?
- def determine_terminals
- @symboltable.each do |s|
- s.term = s.heads.empty?
- end
- end
-
- # Sym#self_null?
- def compute_nullable_0
- @symboltable.each do |s|
- if s.terminal?
- s.snull = false
- else
- s.snull = s.heads.any? {|loc| loc.reduce? }
- end
- end
- end
-
- # Sym#locate
- def compute_locate
- @rules.each do |rule|
- t = nil
- rule.ptrs.each do |ptr|
- unless ptr.reduce?
- tok = ptr.dereference
- tok.locate.push ptr
- t = tok if tok.terminal?
- end
- end
- rule.precedence = t
- end
- end
-
- # Sym#expand
- def compute_expand(t)
- puts "expand> #{t.to_s}" if @debug_symbol
- t.expand = _compute_expand(t, ISet.new, [])
- puts "expand< #{t.to_s}: #{t.expand.to_s}" if @debug_symbol
- end
-
- def _compute_expand(t, set, lock)
- if tmp = t.expand
- set.update tmp
- return set
- end
- tok = nil
- set.update_a t.heads
- t.heads.each do |ptr|
- tok = ptr.dereference
- if tok and tok.nonterminal?
- unless lock[tok.ident]
- lock[tok.ident] = true
- _compute_expand tok, set, lock
- end
- end
- end
- set
- end
-
- # Sym#nullable?, Rule#nullable?
- def compute_nullable
- @rules.each {|r| r.null = false }
- @symboltable.each {|t| t.null = false }
- r = @rules.dup
- s = @symboltable.nonterminals
- begin
- rs = r.size
- ss = s.size
- check_rules_nullable r
- check_symbols_nullable s
- end until rs == r.size and ss == s.size
- end
-
- def check_rules_nullable(rules)
- rules.delete_if do |rule|
- rule.null = true
- rule.symbols.each do |t|
- unless t.nullable?
- rule.null = false
- break
- end
- end
- rule.nullable?
- end
- end
-
- def check_symbols_nullable(symbols)
- symbols.delete_if do |sym|
- sym.heads.each do |ptr|
- if ptr.rule.nullable?
- sym.null = true
- break
- end
- end
- sym.nullable?
- end
- end
-
- # Sym#useless?, Rule#useless?
- # FIXME: what means "useless"?
- def compute_useless
- @symboltable.each_terminal {|sym| sym.useless = false }
- @symboltable.each_nonterminal {|sym| sym.useless = true }
- @rules.each {|rule| rule.useless = true }
- r = @rules.dup
- s = @symboltable.nonterminals
- begin
- rs = r.size
- ss = s.size
- check_rules_useless r
- check_symbols_useless s
- end until r.size == rs and s.size == ss
- end
-
- def check_rules_useless(rules)
- rules.delete_if do |rule|
- rule.useless = false
- rule.symbols.each do |sym|
- if sym.useless?
- rule.useless = true
- break
- end
- end
- not rule.useless?
- end
- end
-
- def check_symbols_useless(s)
- s.delete_if do |t|
- t.heads.each do |ptr|
- unless ptr.rule.useless?
- t.useless = false
- break
- end
- end
- not t.useless?
- end
- end
-
- end # class Grammar
-
-
- class Rule
-
- def initialize(target, syms, act)
- @target = target
- @symbols = syms
- @action = act
- @alternatives = []
-
- @ident = nil
- @hash = nil
- @ptrs = nil
- @precedence = nil
- @specified_prec = nil
- @null = nil
- @useless = nil
- end
-
- attr_accessor :target
- attr_reader :symbols
- attr_reader :action
-
- def |(x)
- @alternatives.push x.rule
- self
- end
-
- def rule
- self
- end
-
- def each_rule(&block)
- yield self
- @alternatives.each(&block)
- end
-
- attr_accessor :ident
-
- attr_reader :hash
- attr_reader :ptrs
-
- def hash=(n)
- @hash = n
- ptrs = []
- @symbols.each_with_index do |sym, idx|
- ptrs.push LocationPointer.new(self, idx, sym)
- end
- ptrs.push LocationPointer.new(self, @symbols.size, nil)
- @ptrs = ptrs
- end
-
- def precedence
- @specified_prec || @precedence
- end
-
- def precedence=(sym)
- @precedence ||= sym
- end
-
- def prec(sym, &block)
- @specified_prec = sym
- if block
- unless @action.empty?
- raise CompileError, 'both of rule action block and prec block given'
- end
- @action = UserAction.proc(block)
- end
- self
- end
-
- attr_accessor :specified_prec
-
- def nullable?() @null end
- def null=(n) @null = n end
-
- def useless?() @useless end
- def useless=(u) @useless = u end
-
- def inspect
- "#<Racc::Rule id=#{@ident} (#{@target})>"
- end
-
- def ==(other)
- other.kind_of?(Rule) and @ident == other.ident
- end
-
- def [](idx)
- @symbols[idx]
- end
-
- def size
- @symbols.size
- end
-
- def empty?
- @symbols.empty?
- end
-
- def to_s
- "#<rule#{@ident}>"
- end
-
- def accept?
- if tok = @symbols[-1]
- tok.anchor?
- else
- false
- end
- end
-
- def each(&block)
- @symbols.each(&block)
- end
-
- def replace(src, dest)
- @target = dest
- @symbols = @symbols.map {|s| s == src ? dest : s }
- end
-
- end # class Rule
-
-
- class UserAction
-
- def UserAction.source_text(src)
- new(src, nil)
- end
-
- def UserAction.proc(pr = nil, &block)
- if pr and block
- raise ArgumentError, "both of argument and block given"
- end
- new(nil, pr || block)
- end
-
- def UserAction.empty
- new(nil, nil)
- end
-
- private_class_method :new
-
- def initialize(src, proc)
- @source = src
- @proc = proc
- end
-
- attr_reader :source
- attr_reader :proc
-
- def source?
- not @proc
- end
-
- def proc?
- not @source
- end
-
- def empty?
- not @proc and not @source
- end
-
- def name
- "{action type=#{@source || @proc || 'nil'}}"
- end
-
- alias inspect name
-
- end
-
-
- class OrMark
- def initialize(lineno)
- @lineno = lineno
- end
-
- def name
- '|'
- end
-
- alias inspect name
-
- attr_reader :lineno
- end
-
-
- class Prec
- def initialize(symbol, lineno)
- @symbol = symbol
- @lineno = lineno
- end
-
- def name
- "=#{@symbol}"
- end
-
- alias inspect name
-
- attr_reader :symbol
- attr_reader :lineno
- end
-
-
- #
- # A set of rule and position in it's RHS.
- # Note that the number of pointers is more than rule's RHS array,
- # because pointer points right edge of the final symbol when reducing.
- #
- class LocationPointer
-
- def initialize(rule, i, sym)
- @rule = rule
- @index = i
- @symbol = sym
- @ident = @rule.hash + i
- @reduce = sym.nil?
- end
-
- attr_reader :rule
- attr_reader :index
- attr_reader :symbol
-
- alias dereference symbol
-
- attr_reader :ident
- alias hash ident
- attr_reader :reduce
- alias reduce? reduce
-
- def to_s
- sprintf('(%d,%d %s)',
- @rule.ident, @index, (reduce?() ? '#' : @symbol.to_s))
- end
-
- alias inspect to_s
-
- def eql?(ot)
- @hash == ot.hash
- end
-
- alias == eql?
-
- def head?
- @index == 0
- end
-
- def next
- @rule.ptrs[@index + 1] or ptr_bug!
- end
-
- alias increment next
-
- def before(len)
- @rule.ptrs[@index - len] or ptr_bug!
- end
-
- private
-
- def ptr_bug!
- raise "racc: fatal: pointer not exist: self: #{to_s}"
- end
-
- end # class LocationPointer
-
-
- class SymbolTable
-
- include Enumerable
-
- def initialize
- @symbols = [] # :: [Racc::Sym]
- @cache = {} # :: {(String|Symbol) => Racc::Sym}
- @dummy = intern(:$start, true)
- @anchor = intern(false, true) # Symbol ID = 0
- @error = intern(:error, false) # Symbol ID = 1
- end
-
- attr_reader :dummy
- attr_reader :anchor
- attr_reader :error
-
- def [](id)
- @symbols[id]
- end
-
- def intern(val, dummy = false)
- @cache[val] ||=
- begin
- sym = Sym.new(val, dummy)
- @symbols.push sym
- sym
- end
- end
-
- attr_reader :symbols
- alias to_a symbols
-
- def delete(sym)
- @symbols.delete sym
- @cache.delete sym.value
- end
-
- attr_reader :nt_base
-
- def nt_max
- @symbols.size
- end
-
- def each(&block)
- @symbols.each(&block)
- end
-
- def terminals(&block)
- @symbols[0, @nt_base]
- end
-
- def each_terminal(&block)
- @terms.each(&block)
- end
-
- def nonterminals
- @symbols[@nt_base, @symbols.size - @nt_base]
- end
-
- def each_nonterminal(&block)
- @nterms.each(&block)
- end
-
- def fix
- terms, nterms = @symbols.partition {|s| s.terminal? }
- @symbols = terms + nterms
- @terms = terms
- @nterms = nterms
- @nt_base = terms.size
- fix_ident
- check_terminals
- end
-
- private
-
- def fix_ident
- @symbols.each_with_index do |t, i|
- t.ident = i
- end
- end
-
- def check_terminals
- return unless @symbols.any? {|s| s.should_terminal? }
- @anchor.should_terminal
- @error.should_terminal
- each_terminal do |t|
- t.should_terminal if t.string_symbol?
- end
- each do |s|
- s.should_terminal if s.assoc
- end
- terminals().reject {|t| t.should_terminal? }.each do |t|
- raise CompileError, "terminal #{t} not declared as terminal"
- end
- nonterminals().select {|n| n.should_terminal? }.each do |n|
- raise CompileError, "symbol #{n} declared as terminal but is not terminal"
- end
- end
-
- end # class SymbolTable
-
-
- # Stands terminal and nonterminal symbols.
- class Sym
-
- def initialize(value, dummyp)
- @ident = nil
- @value = value
- @dummyp = dummyp
-
- @term = nil
- @nterm = nil
- @should_terminal = false
- @precedence = nil
- case value
- when Symbol
- @to_s = value.to_s
- @serialized = value.inspect
- @string = false
- when String
- @to_s = value.inspect
- @serialized = value.dump
- @string = true
- when false
- @to_s = '$end'
- @serialized = 'false'
- @string = false
- when ErrorSymbolValue
- @to_s = 'error'
- @serialized = 'Object.new'
- @string = false
- else
- raise ArgumentError, "unknown symbol value: #{value.class}"
- end
-
- @heads = []
- @locate = []
- @snull = nil
- @null = nil
- @expand = nil
- @useless = nil
- end
-
- class << self
- def once_writer(nm)
- nm = nm.id2name
- module_eval(<<-EOS)
- def #{nm}=(v)
- raise 'racc: fatal: @#{nm} != nil' unless @#{nm}.nil?
- @#{nm} = v
- end
- EOS
- end
- end
-
- once_writer :ident
- attr_reader :ident
-
- alias hash ident
-
- attr_reader :value
-
- def dummy?
- @dummyp
- end
-
- def terminal?
- @term
- end
-
- def nonterminal?
- @nterm
- end
-
- def term=(t)
- raise 'racc: fatal: term= called twice' unless @term.nil?
- @term = t
- @nterm = !t
- end
-
- def should_terminal
- @should_terminal = true
- end
-
- def should_terminal?
- @should_terminal
- end
-
- def string_symbol?
- @string
- end
-
- def serialize
- @serialized
- end
-
- attr_writer :serialized
-
- attr_accessor :precedence
- attr_accessor :assoc
-
- def to_s
- @to_s.dup
- end
-
- alias inspect to_s
-
- def |(x)
- rule() | x.rule
- end
-
- def rule
- Rule.new(nil, [self], UserAction.empty)
- end
-
- #
- # cache
- #
-
- attr_reader :heads
- attr_reader :locate
-
- def self_null?
- @snull
- end
-
- once_writer :snull
-
- def nullable?
- @null
- end
-
- def null=(n)
- @null = n
- end
-
- attr_reader :expand
- once_writer :expand
-
- def useless?
- @useless
- end
-
- def useless=(f)
- @useless = f
- end
-
- end # class Sym
-