Граф коммитов

1153 Коммитов

Автор SHA1 Сообщение Дата
nobu b1520b7459 parse.y: fix wrong static symbol
* parse.y (next_id): no reason to set ID_STATIC_SYM here, as ID
  returned by rb_intern3 can be a dynamic symbol and the static
  symbol flag is set otherwise.  [Bug #9787]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45788 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-05-02 12:04:04 +00:00
nobu ff99fd4de1 parse.y: hide anonymous id
* parse.y (rb_id_attrset): should not reveal anonymous ID as an
  instance variable.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45784 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-05-02 03:20:21 +00:00
nobu d42e0ea844 parse.y: turn dynamically interned Symbol into an ID
* parse.y (rb_id_attrset): turn dynamically interned Symbol into
  an ID, since rb_str_dynamic_intern returns a Symbol but not an
  ID.  [ruby-core:62226] [Bug #9787]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45782 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-05-02 01:37:57 +00:00
nobu 0e7a25bd4e parse.y: abort at inappropriate symbol
* parse.y (must_be_dynamic_symbol): abort if inappropriate symbol
  is given, which should never happen.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45777 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-05-01 13:52:36 +00:00
nobu ad528e85c6 parse.y: show symbol name
* parse.y (must_be_dynamic_symbol): show the name if it is a
  static symbol.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45771 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-05-01 10:53:18 +00:00
nobu 795a6b2374 parse.y: show name as possible
* parse.y (rb_id_attrset): show the name of broken ID if it is
  still registered.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45767 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-04-30 15:37:56 +00:00
nobu fba47c1397 parse.y: raise with numeric ID type
* parse.y (rb_id_attrset): all valid ID types are handled
  properly, raise with numeric ID type which may be broken for
  GCed static symbol.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45766 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-04-30 15:25:46 +00:00
nobu 6b7ed6048e parse.y: use rb_id2str
* parse.y (rb_id_attrset): use rb_id2str to get rid of method call.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45764 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-04-30 15:16:09 +00:00
nobu 60375cd6ba parse.y: use rb_str_ellipsize
* parse.y (next_id): use rb_str_ellipsize to preserve encoding and
  get rid of incomplete multibyte sequence.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45761 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-04-30 12:09:35 +00:00
nobu 48384bbab7 parse.y: pin down dynamic symbol only
* parse.y (rb_id_attrset): pin down dynamic symbol only. it is
  possibe that attrset ID can be registered as a static symbol
  after the corresponding attrget ID has been registered as a
  dynamic, and then the latter may be collected.
  [ruby-core:62226] [Bug #9787]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45756 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-04-30 08:06:51 +00:00
ktsj 0f51db6a1e * parse.y (symbols_i): like r45492, call rb_gc_resurrect().
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45741 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-04-29 01:25:36 +00:00
nobu d182cd3053 parse.y: resurrect dynamic symbol and name
* parse.y (lookup_id_str): resurrect the dynamic symbol before
  accessing its content, and its name before returning.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45703 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-04-24 04:24:56 +00:00
nobu a680ee9ffa parse.y: check for symbol
* parse.y (rb_sym2id, rb_sym2id_without_pindown): reject
  non-symbol values.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45702 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-04-24 03:08:49 +00:00
nobu 34c35bf107 parse.y: check for symbol
* parse.y (rb_sym2id, rb_sym2id_without_pindown): return 0 for
  non-symbol values, for the time being.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45700 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-04-24 02:21:38 +00:00
nobu 977a5147b4 parse.y: resurrect before pindown
* parse.y (rb_pin_dynamic_symbol): resurrect the dynamic symbol
  which may be unmarked already and swept at next time, before
  pindown.

* parse.y (dsym_node_gen): now rb_intern_str() resurrects dynamic
  symbols, via lookup_sym_id() and rb_pin_dynamic_symbol().

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45698 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-04-24 02:04:33 +00:00
nobu 91c6d41ac3 parse.y: trivial optimization
* parse.y (rb_str_dynamic_intern): branch by same condition as
  rb_id2sym to reduce unnecessary branch.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45697 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-04-24 02:04:29 +00:00
naruse 2dca886a07 * parse.y (dsym_node_gen): like r45492, call rb_gc_resurrect().
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45693 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-04-23 20:59:03 +00:00
nobu c501345218 parse.y: allow parenthesed do-block in cmdarg
* parse.y (primary): flush cmdarg flags inside left-paren in a
  command argument, to allow parenthesed do-block as an argument
  without arguments parentheses.  [ruby-core:61950] [Bug #9726]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45637 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-04-19 06:38:31 +00:00
nobu 5b54488e78 parse.y: shared substring of source
* parse.y (lex_get_str): return shared sub-string of entire source
  string instead of a partial copy.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45629 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-04-18 14:27:22 +00:00
ktsj f6686b5132 * parse.y (rb_str_dynamic_intern): set mark bit if dynamic symbol
is before sweeping.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45492 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-04-01 00:07:58 +00:00
ktsj e4879afe3e * parse.y (rb_str_dynamic_intern): [DOC] move rdoc from rb_str_intern.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45469 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-03-30 08:10:04 +00:00
nobu fd8f3cb987 parse.y: rb_id_attrget
* parse.y (rb_id_attrget): new function to convert setter ID to
  getter ID.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45464 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-03-28 12:36:26 +00:00
nobu d94dcf1e10 parse.y: type-punning cast
* parse.y (rb_gc_free_dsymbol): use intermediate st_data_t and get
  rid of type-punning cast.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45443 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-03-27 02:58:32 +00:00
nobu bb1d0d2807 parse.y: set encoding
* parse.y (rb_str_dynamic_intern): associate proper encoding with
  the result symbol.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45439 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-03-26 11:30:54 +00:00
nobu ef02cae507 parse.y: fix rb_str_symname_type call
* parse.y (rb_str_dynamic_intern): fix the second argument to
  rb_str_symname_type, which is a bit mask but not a boolean.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45434 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-03-26 06:43:02 +00:00
nobu 5620a51996 * parse.y (rb_str_dynamic_intern): fix commit miss.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45433 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-03-26 06:36:50 +00:00
nobu 33b8663f1b parse.y: guard dup string
* parse.y (rb_str_dynamic_intern): prevent a string which may be
  duplicated, from GC.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45432 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-03-26 06:34:35 +00:00
nobu ad8ed59ab9 parse.y: dup iff needed
* parse.y (rb_str_dynamic_intern): dup the given string only if
  needed.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-03-26 06:34:33 +00:00
nobu 9a848c5f4a parse.y: no dup US-ASCII string
* parse.y (rb_str_dynamic_intern): no needs to associate encoding
  if it is US-ASCII.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45430 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-03-26 06:34:31 +00:00
usa e70b61d010 * parse.y: inline must be static (for mswin).
fixed build error introduced at r45426.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45429 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-03-26 05:58:41 +00:00
nari b9ea135950 * internal.h (USE_SYMBOL_GC): enable Symbol GC by default (USE_SYMBOL_GC == 1).
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45428 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-03-26 05:39:22 +00:00
nari 17a6f9227a cast to int to silence clang compile error
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45427 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-03-26 05:14:51 +00:00
nari 90b7073842 * parse.y: support Symbol GC. [ruby-trunk Feature #9634]
See this ticket about Symbol GC.

* include/ruby/ruby.h:
  Declare few functions.
  * rb_sym2id: almost same as old SYM2ID but support dynamic symbols.
  * rb_id2sym: almost same as old ID2SYM but support dynamic symbols.
  * rb_sym2str: almost same as `rb_id2str(SYM2ID(sym))` but not
    pin down a dynamic symbol.
  Declare a new struct.
  * struct RSymbol: represents a dynamic symbol as object in
    Ruby's heaps.
  Add few macros.
  * STATIC_SYM_P: check a static symbol.
  * DYNAMIC_SYM_P: check a dynamic symbol.
  * RSYMBOL: cast to RSymbol

* gc.c: declare RSymbol. support T_SYMBOL.

* internal.h: Declare few functions.
  * rb_gc_free_dsymbol: free up a dynamic symbol. GC call this
    function at a sweep phase.
  * rb_str_dynamic_intern: convert a string to a dynamic symbol.
  * rb_check_id_without_pindown: not pinning function.
  * rb_sym2id_without_pindown: ditto.
  * rb_check_id_cstr_without_pindown: ditto.

* string.c (Init_String): String#intern and String#to_sym use
  rb_str_dynamic_intern.

* template/id.h.tmpl: use LSB of ID as a flag for determining a
  static symbol, so we shift left other ruby_id_types.

* string.c: use rb_sym2str instead `rb_id2str(SYM2ID(sym))` to
  avoid pinning.

* load.c: use xx_without_pindown function at creating temporary ID
  to avoid pinning.

* object.c: ditto.

* sprintf.c: ditto.

* struct.c: ditto.

* thread.c: ditto.

* variable.c: ditto.

* vm_method.c: ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45426 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-03-26 04:57:47 +00:00
nobu dcd1e5e5c2 parse.y: required kwarg without parentheses
* parse.y (parser_yylex): only a newline after label should be
  significant.  [ruby-core:61658] [Bug #9669]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45408 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-03-25 14:57:18 +00:00
nobu d7442c32df parse.y: required kwarg without parentheses
* parse.y (lex_state_e, parser_params, f_arglist, parser_yylex):
  separate EXPR_LABELARG from EXPR_BEG and let newline significant,
  so that required keyword argument can place at the end of
  argument list without parentheses.  [ruby-core:61658] [Bug #9669]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45405 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-03-25 07:47:37 +00:00
nobu 0574b64694 parse.y: removing padding
* parse.y (parser_params): shrink struct size by removing padding
  on 64-bit platforms.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45404 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-03-25 07:39:58 +00:00
nobu 0331e42be3 parse.y: freeze filename
* parse.y (ripper_initialize): filename can not be modified.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45397 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-03-24 13:19:57 +00:00
nari 537ee14ff4 * parse.y (ENC_SINGLE): Unused macro removed.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45281 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-03-07 05:53:11 +00:00
nobu 01740f0c27 parse.y: optional arguments in rhs
* parse.y (f_arg_asgn): define optional arguments as argument
  variables in the rhs default expressions.
  [ruby-core:61299] [Bug #9593]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45272 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-03-05 06:56:49 +00:00
nobu ead3306b60 parse.y: refine error message
* parse.y (rb_check_id): refine error message, expected a symbol
  or a string.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45177 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-02-26 00:43:46 +00:00
nobu 5b56c1c42b parse.y: attrset from junk ID
* parse.y (IDSET_ATTRSET_FOR_INTERN): fix off-by-one bug.
* parse.y (rb_enc_symname_type): junk ID succeeded by '=' is also
  attrset ID.  [ruby-core:60668] [Bug #8756]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44926 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-02-13 06:43:18 +00:00
nobu b2b5a5db09 pack.c: hide associated objects
* marshal.c (to_be_skipped_id): ignore anonymous attributes.
* pack.c (Init_pack): use anonymous ID so that associated objects
  do not appear in the packed result.
* parse.y (rb_make_internal_id): return an anonymous ID for
  internal use.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44840 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-02-05 11:56:35 +00:00
nobu e10e309dce parse.y: symbol names must be ascii-compatible
* parse.y (rb_enc_symname_type): encoding of symbol names must be
  ascii-compatible, reject ascii-incompatible encodings.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44836 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-02-05 06:49:35 +00:00
nobu 04bb9d6b75 parse.y: save cmdarg_stack in local scope
* parse.y (local_push_gen, local_pop_gen): save cmdarg_stack to
  isolate command argument state from outer scope.
  [ruby-core:59342] [Bug #9308]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44449 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-12-27 15:42:49 +00:00
nobu 27682eefa4 compile.c: unnamed keyword rest check
* compile.c (iseq_set_arguments): set arg_keyword_check from
  nd_cflag, which is set by parser.  internal ID is used for
  unnamed keyword rest argument, which should be separated from no
  keyword check.
* iseq.c (rb_iseq_parameters): if no keyword check, keyword rest is
  present.
* parse.y (new_args_tail_gen): set keywords check to nd_cflag, which
  equals to that keyword rest is not present.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44420 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-12-25 13:44:18 +00:00
tmm1 779ae78995 hash.c: revert r43870 and add alternative parser patch for literal keys
* hash.c (hash_aset_str): revert r43870 due to performance issue
  [Bug #9188] [ruby-core:58730]
* parse.y (assoc): convert literal string hash keys to fstrings
* test/ruby/test_hash.rb (class TestHash): expand test

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44058 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-12-08 01:52:28 +00:00
tmm1 98a74d4dd5 parse.y: use rb_fstring() for strings stored in the symbol table
* parse.y (register_symid_str): use fstrings in symbol table
  [Bug #9171] [ruby-core:58656]
* parse.y (rb_id2str): ditto
* string.c (rb_fstring): create frozen_strings on first usage. this
  allows rb_fstring() calls from the parser (before cString is created)
* string.c (fstring_set_class_i): set klass on fstrings generated
  before cString was defined
* string.c (Init_String): convert frozen_strings table to String
  objects after boot
* ext/-test-/symbol/type.c (bug_sym_id2str): expose rb_id2str()
* test/-ext-/symbol/test_type.rb (module Test_Symbol): verify symbol
  table entries are fstrings

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44057 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-12-08 01:39:27 +00:00
ko1 4e064fb0fd * parse.y (rb_gc_mark_symbols): set global_symbols.minor_marked only
when full_mark is 0.
  rb_gc_mark_symbols() (with full_mark == 1) can be called by other
  than GC (such as rb_objspace_reachable_objects_from_root()).



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43734 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-11-20 08:40:56 +00:00
nobu 90b9996523 parse.y: remove "f" suffix [ruby-core:57966] [Feature #9042]
revert r42847 "test_string.rb: add test string encoding"

revert r42846 "parse.y: freeze in advance to reduce objects"

revert r42843 "parse.y: deduplicate frozen string literals"

revert r42780 "test_string.rb: yet another test"

revert r42779 "parse.y: valid suffix word only"

revert r42778 "test_string.rb: remove duplicated code"

revert r42775 "parse.y: force_encoding"

This reverts commit 93ea04ecec.

revert r42773 "Add frozen string literals"

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43634 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-11-10 06:13:02 +00:00
ko1 c5e08b764e * add RUBY_TYPED_FREE_IMMEDIATELY to data types which only use
safe functions during garbage collection such as xfree().
  On default, T_DATA objects are freed at same points as fianlizers.
  This approach protects issues such as reported by [ruby-dev:35578].
  However, freeing T_DATA objects immediately helps heap usage.
  Most of T_DATA (in other words, most of dfree functions) are safe.
  However, we turned off RUBY_TYPED_FREE_IMMEDIATELY by default
  for safety.
* cont.c: ditto.
* dir.c: ditto.
* encoding.c: ditto.
* enumerator.c: ditto.
* error.c: ditto.
* file.c: ditto.
* gc.c: ditto.
* io.c: ditto.
* iseq.c: ditto.
* marshal.c: ditto.
* parse.y: ditto.
* proc.c: ditto.
* process.c: ditto.
* random.c: ditto.
* thread.c: ditto.
* time.c: ditto.
* transcode.c: ditto.
* variable.c: ditto.
* vm.c: ditto.
* vm_backtrace.c: ditto.
* vm_trace.c: ditto.
* ext/bigdecimal/bigdecimal.c: ditto.
* ext/objspace/objspace.c: ditto.
* ext/stringio/stringio.c: ditto.
* ext/strscan/strscan.c: ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43466 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-10-29 11:16:54 +00:00
marcandre 8afbb0e6ef * parse.y: Remove +(binary) and -(binary) special cases [Feature #9048]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43413 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-10-24 12:58:54 +00:00
ko1 588586d9d4 * internal.h, parse.y: use `full_mark' instead of `full_marking'.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43258 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-10-11 12:06:25 +00:00
ko1 f44b0e5b4f * gc.c, parse.y: support generational Symbol relatetd marking.
Each symbols has String objects respectively to represent
  Symbols.
  These objects are marked only when:
* full marking
* new symbols are added
  This hack reduce symbols (related strings) marking time.
  For example, on my Linux environment, the following code
  "20_000_000.times{''}"
  with 40k symbols (similar symbol number on Rails 3.2.14 app,
  @jugyo tells me) boosts, from 7.3sec to 4.2sec.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43255 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-10-11 11:45:38 +00:00
nobu 6496dc892d parse.y: allow junk attrset
* parse.y (rb_id_attrset, intern_str): allow junk attrset ID for
  Struct.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43085 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-09-29 14:45:46 +00:00
nobu 771c8ed338 parse.y: fix inconsistency with literals
* parse.y (rb_id_attrset): fix inconsistency with literals, allow
  ID_ATTRSET and return it itself, but ID_JUNK cannot make ID_ATTRSET.
  and raise a NameError instead of rb_bug() for invalid argument.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43083 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-09-29 13:56:33 +00:00
nobu aba824fece parse.y: junk sigil only names
* parse.y (intern_str): sigil only names are junk, at least one
  identifier character is needed.  [ruby-dev:47723] [Bug #8928]
* parse.y (rb_enc_symname_type): fix out of bound access.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42988 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-09-20 06:01:57 +00:00
nobu 5cda4e9071 parse.y: adjust position of lambda
* parse.y (lambda): adjust position to the beginning of the block.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42980 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-09-19 07:59:07 +00:00
nobu eb568bdee6 parse.y: duplicate code
* parse.y (f_larglist): remove duplicate code in ripper.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42979 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-09-19 07:59:05 +00:00
nobu dffae9a1f9 string.c: reduce objects in rb_fstring
* string.c (rb_fstring, rb_str_free): use st_data_t instead of VALUE.
* string.c (rb_fstring): get rid of duplicating already frozen object.
* parse.y (str_suffix_gen): freeze in advance to reduce objects.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42846 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-09-05 08:25:56 +00:00
charliesome 6fd9000076 * include/ruby/ruby.h: add RSTRING_FSTR flag
* internal.h: add rb_fstring() prototype
* parse.y (str_suffix_gen): deduplicate frozen string literals
* string.c (rb_fstring): deduplicate frozen string literals
* string.c (rb_str_free): delete fstrings from frozen_strings table when
  they are GC'd
* string.c (Init_String): initialize frozen_strings table
* test/ruby/test_string.rb: test frozen strings are deduplicated

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42843 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-09-05 04:49:16 +00:00
nobu 306cf3ac03 parse.y: valid suffix word only
* parse.y (parser_str_options): use valid suffix word only, as well as
  numeric literal, for the backward comatibility.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42779 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-09-02 14:46:25 +00:00
nobu 93ea04ecec parse.y: force_encoding
* parse.y (str_suffix_gen): String#b creates new string object, use
  force_encoding instead.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42775 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-09-02 08:53:40 +00:00
charliesome a056098cb7 * NEWS: Add note about frozen string literals
* compile.c (case_when_optimizable_literal): optimize NODE_LIT strings
  in when clauses of case statements

* ext/ripper/eventids2.c: add tSTRING_SUFFIX

* parse.y: add 'f' suffix on string literals for frozen strings

* test/ripper/test_scanner_events.rb: add scanner tests

* test/ruby/test_string.rb: add frozen string tests

[Feature #8579] [ruby-core:55699]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42773 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-09-02 07:11:41 +00:00
eregon cddd93a575 fix typo of r42691
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42692 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-08-26 08:59:55 +00:00
nobu a6a85a0cb7 parse.y: warn CR
* parse.y (parser_nextc): warn carriage return in middle of line.
  [ruby-core:56240] [Feature #8699]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42691 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-08-26 07:25:08 +00:00
kazu 85afb17bbc fix typos
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42579 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-08-16 05:19:08 +00:00
nobu 12a0b0c8f4 parse.y: simplify
* parse.y (f_label): extract from f_kw and f_block_kw.

* parse.y (f_opt, f_block_opt): use f_norm_arg to simlify actions.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42563 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-08-15 11:09:26 +00:00
nobu c48b4209c2 parse.y: CR in middle
* parse.y (parser_whole_match_p): treat CR in middle of a line as a
  mere whitespace.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42535 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-08-12 06:59:57 +00:00
nobu c6282e9bf9 parse.y: non-local/const attrset
* parse.y (rb_enc_symname_type): allow ID_ATTRSET for ID_INSTANCE,
  ID_GLOBAL, ID_CLASS, ID_JUNK too.  [Bug #8756]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42509 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-08-11 06:11:17 +00:00
nobu 0dd8ec36c0 parse.y: non-local/const attrset
* parse.y (rb_id_attrset): allow other than ID_ATTRSET.
* parse.y (intern_str): ditto.  try stem ID for ID_INSTANCE,
  ID_GLOBAL, ID_CLASS, ID_JUNK too.  [Bug #8756]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42490 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-08-10 04:53:31 +00:00
nobu 70973af1d5 parse.y: check for attr
* parse.y (rb_id_attrset): check if the argument is valid type as an
  attribute.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42479 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-08-10 00:12:05 +00:00
nobu 6660c5fb0c parse.y: no reduction with 1
* parse.y (parser_set_integer_literal): use rb_rational_raw1() for
  integral rational because no reduction is needed with 1.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42350 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-08-03 01:33:58 +00:00
usa ccd5c3ddfc * parse.y (value_expr_gen): now NODE_DEFN and NODE_DEFS are not void
value expressions.  get rid of wrong warning with -w, and make to
  pass tests with chkbuild.  ref. [Feature #3753]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42347 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-08-02 21:57:49 +00:00
nobu 7c9a3d19fc parse.y: calculate powers of ten
* parse.y (parser_yylex): calculate denominator directly as powers of
  ten, not parsing string.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42334 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-08-02 14:48:55 +00:00
nobu 0eab2b464e parse.y: ripper for new literals
* parse.y (ripper_validate_object): ripper support for new literals,
  tRATIONAL and tIMAGINARY.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42333 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-08-02 14:24:17 +00:00
nobu 2f57e80640 parse.y: parse precisely
* parse.y (parser_number_literal_suffix): return bit set of found
  suffixes.
* parse.y (parser_set_number_literal, parser_set_integer_literal):
  split from parser_number_literal_suffix to set yyvlal.
* parse.y (parser_yylex): parse rational number literal with decimal
  point precisely.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42332 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-08-02 14:14:55 +00:00
nobu e176b8e1c1 parse.y: simplify numerics
* parse.y (simple_numeric): integrate numeric literals and simplify
  numeric rules.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42331 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-08-02 14:14:18 +00:00
charliesome 29c5a3b89c * parse.y (negate_lit): add T_RATIONAL and T_COMPLEX to the switch
statement, and call rb_bug() if an unknown type is passed to
  negate_lit(). [ruby-core:56316] [Bug #8717]

* bootstraptest/test_literal_suffix.rb (assert_equal): add test

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42323 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-08-02 01:40:27 +00:00
mrkn e06407cf7d * rational.c (rb_flt_rationalize_with_prec): new public C function
to rationalize a Float instance with a precision.

* rational.c (rb_flt_rationalize): new public C function to
 rationalize a Float instance.  A precision is calculated from
 the given float number.

* include/ruby/intern.h: Add rb_flt_rationalize_with_prec and
  rb_flt_rationalize.

* parse.y: implement number literal suffixes, 'r' and 'i'.
  [ruby-core:55096] [Feature #8430]

* bootstraptest/test_literal_suffix.rb: add tests for parser to scan
  number literals with the above tsuffixes.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42311 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-08-01 14:58:54 +00:00
kazu 434826c0e9 * parse.y: fix build error with bison-3.0.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42282 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-31 13:01:57 +00:00
nobu aa2a845168 parse.y, vm_eval.c: file encoding in eval
* parse.y (yycompile): store file name as String to keep the encoding.

* parse.y (rb_parser_compile_string_path, rb_parser_compile_file_path):
  new functions to pass file name as a String.

* parse.y (gettable_gen): return a copy of the original file name, not
  a copy in filesystem encoding.

* vm_eval.c (eval_string_with_cref): use Qundef instead of "(eval)".

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42230 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-29 08:00:34 +00:00
nobu 41f864faab parse.y: separate numeric literal
* parse.y (parser_yylex): separate numeric literal from succeeding
  token, and treat 'e' as floating point number only if followed by
  exponent part.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42197 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-26 14:05:34 +00:00
charliesome fff3589899 * compile.c (make_name_for_block): use PRIsVALUE in format string
instead of %s and RSTRING_PTR to protect objects from being garbage
  collected too soon
* encoding.c (str_to_encindex): ditto
* hash.c (rb_hash_fetch_m): ditto
* io.c (rb_io_reopen): ditto
* parse.y (reg_fragment_check_gen): ditto
* parse.y (reg_compile_gen): ditto
* parse.y (ripper_assert_Qundef): ditto
* re.c (rb_reg_raise): ditto
* ruby.c (set_option_encoding_once): ditto
* vm_eval.c (rb_throw_obj): ditto

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41597 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-24 11:31:21 +00:00
nobu ca7bdc882b parse.y: clear lex_strterm
* parse.y (parser_heredoc_restore): clear lex_strterm always to get
  rid of marking recycled node.  this bug is revealed by r41372 with
  GC.stress=true.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41378 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-18 07:43:47 +00:00
nobu 299d96cadd parse.y: non-shady ruby_debug_lines
* parse.y (parser_set_encode): get rid of making ruby_debug_lines
  non-shady.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41244 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-12 03:00:22 +00:00
akr bd15d4ca78 * internal.h (numberof): Gathered from various files.
* array.c, math.c, thread_pthread.c, iseq.c, enum.c, string.c, io.c,
  load.c, compile.c, struct.c, eval.c, gc.c, parse.y, process.c,
  error.c, ruby.c: Remove the definitions of numberof.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41142 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-07 10:01:19 +00:00
nobu 6db56c86c9 fill rdocs
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41027 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-02 03:12:04 +00:00
nobu e6589b2b55 parse.y: fix argument type
* parse.y (is_global_name_punct): fix argument type, to get rid of
  implicit promotion.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40723 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-05-14 08:24:55 +00:00
ko1 83aba04862 * include/ruby/ruby.h: constify RBasic::klass and add
RBASIC_CLASS(obj) macro which returns a class of `obj'.
  This change is a part of RGENGC branch [ruby-trunk - Feature #8339].
* object.c: add new function rb_obj_reveal().
  This function reveal interal (hidden) object by rb_obj_hide().
  Note that do not change class before and after hiding.
  Only permitted example is:
  klass = RBASIC_CLASS(obj);
  rb_obj_hide(obj);
  ....
  rb_obj_reveal(obj, klass);
  TODO: API design. rb_obj_reveal() should be replaced with others.
  TODO: modify constified variables using cast may be harmful for
  compiler's analysis and optimizaton.
  Any idea to prohibt inserting RBasic::klass directly?
  If rename RBasic::klass and force to use RBASIC_CLASS(obj),
  then all codes such as `RBASIC(obj)->klass' will be
  compilation error. Is it acceptable? (We have similar
  experience at Ruby 1.9,
  for example "RARRAY(ary)->ptr" to "RARRAY_PTR(ary)".
* internal.h: add some macros.
* RBASIC_CLEAR_CLASS(obj) clear RBasic::klass to make it internal
  object.
* RBASIC_SET_CLASS(obj, cls) set RBasic::klass.
* RBASIC_SET_CLASS_RAW(obj, cls) same as RBASIC_SET_CLASS
  without write barrier (planned).
* RCLASS_SET_SUPER(a, b) set super class of a.
* array.c, class.c, compile.c, encoding.c, enum.c, error.c, eval.c,
  file.c, gc.c, hash.c, io.c, iseq.c, marshal.c, object.c,
  parse.y, proc.c, process.c, random.c, ruby.c, sprintf.c,
  string.c, thread.c, transcode.c, vm.c, vm_eval.c, win32/file.c:
  Use above macros and functions to access RBasic::klass.
* ext/coverage/coverage.c, ext/readline/readline.c,
  ext/socket/ancdata.c, ext/socket/init.c,
* ext/zlib/zlib.c: ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40691 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-05-13 10:49:11 +00:00
ko1 aacd771046 * *.c, parse.y, insns.def: use RARRAY_AREF/ASET macro
instead of using RARRAY_PTR().



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40690 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-05-13 09:56:22 +00:00
nobu ecddb96785 parse.y: invalid name as mere string
* parse.y (parser_peek_variable_name): treat invalid global, class,
  and instance variable names as mere strings rather than errors.
  [ruby-core:54885] [Bug #8375]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40635 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-05-10 14:56:40 +00:00
nobu 0542f05b32 parse.y: lex_state macros
* parse.y (parser_yylex): use IS_lex_state() and IS_lex_state_for()
  instead of direct comparison.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40634 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-05-10 14:56:37 +00:00
nobu 85280f4b55 parse.y: fail if invalid name
* parse.y (parser_yylex): fail if $, @, @@ are not followed by a valid
  name character.  [ruby-core:54846] [Bug #8375].

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40607 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-05-08 04:07:22 +00:00
nobu 498c8763fe parse.y: setup_fake_str
* parse.y (setup_fake_str): extract function.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40439 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-04-24 05:22:00 +00:00
nobu 531329a291 parse.y: disallow $-
* parse.y (parser_yylex): disallow $- without following identifier
  character.  [ruby-talk:406969]
* parse.y (is_special_global_name): mere $- is not a valid global
  variable name.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40436 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-04-24 05:04:01 +00:00
nobu ea16ec561f parse.y: mrhs_arg
* parse.y (mrhs_arg): reduce duplicated code.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40213 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-04-10 02:38:29 +00:00
nobu 40370296c7 parse.y: "nil" for defined? with empty expression
* parse.y (new_defined): remove all extra parentheses, and return
  "nil" for defined? with empty expression.
  [ruby-core:54024] [Bug #8224]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40138 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-04-05 17:30:42 +00:00
nobu 9150340b9b parse.y: refine warning message
* parse.y (ambiguous_operator): refine warning message, since this
  warning is shown after literal too.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39870 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-03-21 20:30:53 +00:00
nobu ebd8663482 parse.y: escape all closing parens
* parse.y (simple_re_meta): escape all closing characters, not only
  round parenthesis.  [ruby-core:53578] [Bug #8133]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39858 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-03-21 07:48:11 +00:00
nobu 34a95669da required keyword arguments
* compile.c (iseq_set_arguments, iseq_compile_each): support required
  keyword arguments.   [ruby-core:51454] [Feature #7701]
* iseq.c (rb_iseq_parameters): ditto.
* parse.y (f_kw, f_block_kw): ditto.  this syntax is still
  experimental, the notation may change.
* vm_core.h (rb_iseq_struct): ditto.
* vm_insnhelper.c (vm_callee_setup_keyword_arg): ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39735 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-03-12 13:20:50 +00:00