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

1345 Коммитов

Автор SHA1 Сообщение Дата
nobu 0b7d473734 safe navigation attrset
* compile.c (iseq_compile_each): support safe navigation of simple
  attribute assignment.  [Feature #11537]
* parse.y (mlhs_node, lhs, attrset_gen): ditto.  keep mid
  non-attrset as the sign of safe navigation.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52234 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-10-23 01:49:38 +00:00
nobu a356fe1c35 Safe navigation operator
* compile.c (iseq_peephole_optimize): peephole optimization for
  branchnil jumps.
* compile.c (iseq_compile_each): generate save navigation operator
  code.
* insns.def (branchnil): new opcode to pop the tos and branch if
  it is nil.
* parse.y (NEW_QCALL, call_op, parser_yylex): parse token '.?'.
  [Feature #11537]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52214 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-10-22 06:30:12 +00:00
nobu a76fdea9fc parse.y: magic comment w/o indicators
* parse.y (parser_magic_comment): allow a sole magic comment without
  indicators, neither other non-space comments.  [Feature #8976]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52208 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-10-21 09:34:09 +00:00
nobu e21f1875b7 parse.y: fix ripper warnings
* parse.y (parser_nextc): send a warning to ripper, not to STDERR
  always.
* parse.y (rb_warn1, rb_warning1): move argument conversions to
  callers.  PRIsVALUE is not valid in String#%.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52122 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-10-14 04:58:47 +00:00
nobu b0e372a867 parse.y: move ripper_id2sym
* parse.y (new_attr_op_assign): move ripper_id2sym from each
  rules.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52115 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-10-12 03:26:24 +00:00
nobu c2310baf9a parse.y: reorder conditions
* parse.y (token_info_pop): scan lex buffer only when token info
  is enabled.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51984 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-09-29 16:47:13 +00:00
nobu aad3a8679f parse.y: token length
* parse.y (token_info_push, token_info_push): add token length
  parameter instead of strlen.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51983 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-09-29 16:38:02 +00:00
nobu 17ff3b9b85 parse.y: fix memory leak
* parse.y (parser_free): fix memory leak at syntax error when
  warn-indent is enabled.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51981 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-09-29 16:34:37 +00:00
eregon b881747bbd * parse.y: fix minor typo. [ci skip][fix GH-1038].
Patch by @ltratt.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51980 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-09-29 13:29:44 +00:00
nobu 13d53f9ae9 parse.y: mark
* parse.y (parser_mark): mark compile option hash.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51979 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-09-29 12:13:30 +00:00
nobu 859337b17b fronzen-string-literal pragma
* compile.c (iseq_compile_each): override compile option by option
  given by pragma.
* iseq.c (rb_iseq_make_compile_option): extract a function to
  overwrite rb_compile_option_t.
* parse.y (parser_set_compile_option_flag): introduce pragma to
  override compile options.
* parse.y (magic_comments): new pragma "fronzen-string-literal".
  [Feature #8976]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51953 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-09-27 06:44:02 +00:00
nobu 3fa061cd57 parse.y: fix token
* parse.y (paren_args): fix separator token at `foo::bar()` in
  ripper.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51927 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-09-24 08:25:11 +00:00
nobu 6628cd6b37 parse.y: simplify ripper_id2sym
* parse.y (ripper_id2sym): remove unnecessary comparison as
  rb_ispunct has stricter condition, and cast explicitly to
  suppress warnings.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51905 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-09-19 23:04:48 +00:00
nobu b4efab9ed9 parse.y: keep literal encoding
* parse.y (literal_concat_gen, evstr2dstr_gen): keep literal
  encoding beginning with an interpolation same as the source file
  encoding.  [ruby-core:70703] [Bug #11519]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51820 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-09-10 13:48:51 +00:00
nobu 0958af2ad4 parse.y: fix labelarg
* parse.y (IS_BEG): include labeled argument state, which was
  EXPR_LABELARG.  [ruby-dev:49221] [Bug #11456]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51624 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-08-18 08:19:24 +00:00
nobu 94b1db5d67 parse.y: fix block after conditional
* parse.y: fix syntax error at do-block after a conditional
  operator.  separate label-allowed and after-a-label states from
  others as bit flags.  [ruby-dev:48790] [Bug #10653]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51617 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-08-17 11:56:55 +00:00
nobu 23352f62a7 parse.y: revert arg in r47649
* parse.y (arg): revert a part of r47649.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51616 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-08-17 11:56:31 +00:00
normal 2c80c9495e rb_parser_compile_*: remove volatile arg
RB_GC_GUARD is sufficient to prevent tail call optimization from
making the object invisible from GC., and we don't need to
encourage more volatile usage.

* parse.y (rb_parser_compile_cstr): remove volatile arg
  (rb_parser_compile_string): ditto
  (rb_parser_compile_file): ditto
  (rb_parser_compile_string_path): ditto
  (rb_parser_compile_file_path): ditto
  [ruby-core:70323] [Misc #11431]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51537 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-08-11 20:35:12 +00:00
nobu d311b7d0eb parse.y: optional superclass
* parse.y (superclass): make superclass rule optional and allow
  any contents without a terminator.  [EXPERIMENTAL]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51529 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-08-11 02:53:31 +00:00
nobu 48baa71ec6 parse.y: shrink parser_params
* parse.y (parser_params): turn in_def and in_single into bit
  flags and reduce the size by 2-words.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51505 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-08-07 12:04:22 +00:00
nobu ebdf35e1e4 parse.y: remove prefixes
* parse.y (parser_params): remove redundant prefixes.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51504 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-08-07 08:30:22 +00:00
nobu 3168ffbd54 parse.y: require pure parser
* parse.y (yylex): non-pure parser has not been supported since
  merger of ripper.  change argument types from void pointers.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51503 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-08-07 08:23:09 +00:00
nobu dfec9d9788 parse.y: pop cmdarg
* parse.y (lambda_body): pop cmdarg stack for lookahead
  token.  [ruby-core:70067] [Bug #11380]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51350 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-07-23 00:05:30 +00:00
nobu da4d4c0024 parse.y: call rb_intern2
* parse.y (parse_ident): call rb_intern2 with the known length
  instead of strlen().

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51332 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-07-22 00:36:09 +00:00
normal 8754f619d5 parse.y (parser_initialize): avoid redundant zero-ing
TypedData_Make_Struct already initializes fields to zero by default,
so there's no need to waste code re-zeroing them.

Size reduction on 32-bit x86:

  text    data     bss     dec     hex filename
 187231    2372      80  189683   2e4f3 parse.o.before
 186939    2372      80  189391   2e3cf parse.o

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51304 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-07-20 06:05:08 +00:00
normal 12652453b2 parse.y (ripper_initialize): fixup r51302
Missed eofp bitfield change in ripper_initialize in r51302 :x
("parse.y (struct parser_params): pack to 4 cache lines on x86-64")

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51303 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-07-20 03:27:50 +00:00
normal 3114f4a2ca parse.y (struct parser_params): pack to 4 cache lines on x86-64
This reduces the struct from 256 (from 288) bytes on my x86-64
system, allowing the struct to fit cleanly into 4 cache lines
(if a malloc implementation allows it).

* parse.y (struct parser_params): pack: 88 => 256 bytes on 64-bit
  [ruby-core:70034] [Feature #11371]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51302 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-07-20 03:21:58 +00:00
zzak d5e6c16762 * parse.y: Improve duplicate key warning with patch by @andremedeiros
[Fix GH-938] https://github.com/ruby/ruby/pull/938 [Bug #11327]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51196 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-07-09 00:27:04 +00:00
ko1 18bbd05709 * method.h: split rb_method_definition_t::flag to several flags.
`flag' contains several categories of attributes and it makes us
  confusion (at least, I had confused).
  * rb_method_visibility_t (flags::visi)
    * NOEX_UNDEF     -> METHOD_VISI_UNDEF     = 0
    * NOEX_PUBLIC    -> METHOD_VISI_PUBLIC    = 1
    * NOEX_PRIVATE   -> METHOD_VISI_PRIVATE   = 2
    * NOEX_PROTECTED -> METHOD_VISI_PROTECTED = 3
  * NOEX_SAFE(flag)) -> safe (flags::safe, 2 bits)
  * NOEX_BASIC       -> basic (flags::basic, 1 bit)
  * NOEX_MODFUNC     -> rb_scope_visibility_t in CREF
  * NOEX_SUPER       -> MISSING_SUPER (enum missing_reason)
  * NOEX_VCALL       -> MISSING_VCALL (enum missing_reason)
  * NOEX_RESPONDS    -> BOUND_RESPONDS (macro)
  Now, NOEX_NOREDEF is not supported (I'm not sure it is needed).
  Background:
    I did not know what "NOEX" stands for.
    I asked Matz (who made this name) and his answer was "Nothing".
    "At first, it meant NO EXport (private), but the original
    meaning was gone."
    This is why I remove the mysterious word "NOEX" from MRI.
* vm_core.h: introduce `enum missing_reason' to represent
  method_missing (NoMethodError) reason.
* eval_intern.h: introduce rb_scope_visibility_t to represent
  scope visibility.
  It has 3 method visibilities (public/private/protected)
  and `module_function`.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50743 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-06-03 01:39:16 +00:00
nobu 238394e738 parse.y: check NTH_REF range
* compile.c (iseq_compile_each): out of range NTH_REF is always
  nil.
* parse.y (parse_numvar): check overflow of NTH_REF and range.
  [ruby-core:69393] [Bug #11192]
* util.c (ruby_scan_digits): make public and add length parameter.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50671 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-05-29 05:39:03 +00:00
nobu 6fb9349d85 allocate structs with wrapper
* parse.y (rb_parser_new, ripper_s_allocate): allocate structs
  with making new wrapper objects and get rid of potential memory
  leak.

* variable.c (rb_autoload): ditto.

* ext/digest/digest.c (rb_digest_base_alloc): ditto.

* ext/strscan/strscan.c (strscan_s_allocate): ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50511 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-05-16 12:56:48 +00:00
nobu 60730d91ce parse.y: refine message for gvar w/o identitirs
* parse.y (parse_gvar): separate message for gvar without
  non-space characters from message for invalid identitirs.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50480 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-05-13 02:13:43 +00:00
shugo 77da72162e Revert "support ES6-like hash literals."
This reverts commit 0d3797f8b62394f5634f4b2b529d28cb46bebf8a.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50445 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-05-08 06:48:11 +00:00
shugo a64ec79c8e support ES6-like hash literals.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50443 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-05-08 06:46:00 +00:00
nobu 4d12807e30 parse.y: %-string cannot be a label
* parse.y (parser_yylex): %-string cannot be a label even if
  terminated by single/double quotes.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50409 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-04-30 14:36:19 +00:00
nobu fd0e9d2580 parse.y: push cmdarg_stack
* parse.y (lambda): push and reset cmdarg_stack in lambda body.
  [ruby-core:69017] [Bug #11107]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50402 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-04-30 07:22:19 +00:00
nobu 9efec44c07 parse.y: simplified
* parse.y (primary): turned nested if-else blocks into a switch
  statement.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50399 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-04-29 03:49:05 +00:00
nobu 810522e0ff compile.c: move expansion of massign
* compile.c (iseq_compile_each): move expansion for massign to
  variable of for-loop from the parser, to reduce method calls on
  intermediate objects.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50398 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-04-29 03:48:26 +00:00
nobu ee725321b6 parse.y: null by syntax error
* parse.y (arg): fix segfault by null caused by syntax error.
  [ruby-core:68851] [Bug #10957]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50265 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-04-12 06:35:02 +00:00
nobu 2456df7584 parse.y: empty paren
* parse.y (primary): empty parentheses at cmdarg can be null.
  [ruby-core:68477] [Bug #10957]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49964 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-03-13 17:14:53 +00:00
ko1 08f3cfb585 * internal.h: use T_IMEMO to represent `struct MEMO' value.
memo->v1 and memo->v2 is WB protected values.
  So use MEMO_V1/V2_SET() macros to set these values.
  memo->u3 is ambiguous (sometimes a VALUE, sometimes an integer
  value), so use gc_mark_maybe() in gc.c to mark it.
  Rename NEW_MEMO() to MEMO_NEW().
  Move MEMO_FOR and NEW_MEMO_FOF macros from node.h.
  Export a rb_imemo_new() function for ext/ripper.
* node.h: remove NODE_MEMO.
* enum.c: catch up these change.
* enumerator.c: ditto.
* load.c: ditto.
* ext/objspace/objspace.c (count_nodes): ditto.
* gc.c (gc_mark_children): mark imemo_memo type.
* parse.y (new_args_gen): use T_IMEMO.
  (I'm not sure it is working correctly...)



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49942 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-03-11 23:13:01 +00:00
nobu 16294913f7 use rb_funcallv
* use rb_funcallv() for no arguments call instead of variadic
  rb_funcall().

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49612 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-02-16 04:08:52 +00:00
nobu 21f6bb283f parse.y: no optimization in defined?
* parse.y (logop_gen): no needs for optimization in defined?
  operator.  literal conditions are optimized away eventually.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49439 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-01-29 13:22:45 +00:00
nobu 082445e7af parse.y: condition node
* parse.y (logop_gen): keep non-null condition node.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49438 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-01-29 13:22:39 +00:00
nobu 9443203ee8 parse.y: optimize conditions
* parse.y (new_if_gen, logop_gen): simplify constant conditional
  expressions to help the optimizer.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49435 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-01-29 08:03:24 +00:00
nobu 17a65c320d parse.y: eliminate empty hashes
* parse.y (assocs, assoc): eliminate splatting empty literal
  hashes.  [ruby-core:67446] [Bug #10719]
* compile.c (compile_array_): supprt splatted hash in hash type.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49193 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-01-09 02:13:03 +00:00
nobu 3977fd332f parse.y: fix f_label result
* parse.y (f_label): return tLABEL value as it is.
  [ruby-core:67315] [Bug #10693]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49140 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-01-04 12:32:54 +00:00
nobu ac47d6a8cf parse.y: disable past scope warnings
* parse.y (gettable_gen): disable warnings of possible reference
  to a local variable defined in a past scope.
  [ruby-core:67162] [Bug #10661]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49082 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-12-31 07:48:47 +00:00
nobu 952ed33b13 parse.y: fix internal IDs conflict
* parse.y (f_kwrest, new_args_tail_gen): unnamed rest keyword and
  keywords bits arguments should be unique.  since internal IDs
  depend on the local variable index in the current scope, new ID
  should be made before popping those vtables.
  [ruby-core:67157] [Bug #10659]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49041 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-12-28 04:54:28 +00:00
nobu f5f6218a23 parse.y: warn past scope variable
* parse.y (gettable_gen): warn possible reference to a local
  variable defined in a past scope.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48986 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-12-25 03:47:46 +00:00
nobu 2de3281af4 parse.y: warn reference after method definition
* parse.y (primary): restore current_arg so that circular
  reference after a method definition is also warned.
  [ruby-core:61299] [Bug #9593]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48835 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-12-14 11:11:45 +00:00
nobu cbdac1eaf6 parse.y: fix lex_state after tLABEL_END
* parse.y (parser_yylex): fix lex_state after tLABEL_END, should
  be EXPR_LABELARG to be followed by "paren with arg".
  [ruby-core:66705] [Feature #4935]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48712 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-12-05 00:46:08 +00:00
nobu 0a190272cd parse.y: preserve tSTRING_CONTENT results
* parse.y (ripper_flush_string_content): preserve the dispatched
  results at tSTRING_CONTENT.  [ruby-dev:48714] [Bug #10437]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48674 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-12-01 21:32:04 +00:00
nobu 1549a6b78d parse.y: check single regexp only
* parse.y (regexp_contents): check in ripper only if the whole
  content is a single regexp without interpolation.
  [ruby-dev:48714] [Bug #10437]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48673 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-12-01 21:31:33 +00:00
nobu 4ea50d7aea parse.y: remove garbage
* parse.y (parser_magic_comment): remove a garbage line inserted
  at previous ripper fix, r48668.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48671 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-12-01 19:53:54 +00:00
nobu 11dc42c20c parse.y: enable encoding pragma in ripper
* parse.y (magic_comment_encoding): enable in ripper, since the
  encoding is necessary to parse non-default encoding scripts.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48668 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-12-01 17:53:02 +00:00
nobu e580a631be use 0 for reserved
use 0 for rb_data_type_t::reserved instead of NULL, since its type
may be changed in the future and possibly not a pointer type.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48662 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-12-01 06:38:04 +00:00
nobu d40aad1c09 parse.y: fix a typo
* parse.y (regexp_contents): fix a typo.  pointed out by wanabe.
  [ruby-dev:48741] [Bug #10543]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48655 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-11-30 11:05:58 +00:00
nobu eab191040e parse.y: fix invalid keyword argument
* parse.y (f_label, f_kw, formal_argument_gen): ignore invalid
  formal argument in keyword argument definition.
  [ruby-dev:48742] [Bug #10545]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48583 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-11-26 08:25:48 +00:00
nobu be5bbaf5dc parse.y: replace with TOK_INTERN
* parse.y (parse_gvar): replace with equivalent macro, TOK_INTERN,
  as well as other places.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48545 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-11-23 17:02:43 +00:00
nobu 6f4e3f05f5 parse.y: shrink parser_params
* parse.y (struct parser_params): reduce size by reordering
  members and an unused member.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48508 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-11-19 23:54:59 +00:00
nobu 098127dc2b parse.y: regexp error in ripper
* parse.y (ripper_flush_string_content, parser_parse_string):
  preserve parsed string content.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48504 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-11-19 17:10:35 +00:00
nobu 3cdbc18f57 parse.y: ripper_new_yylval
* parse.y (ripper_new_yylval): abstract function to create ripper
  wrapper, and make it able to hold another object.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48503 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-11-19 17:09:38 +00:00
nobu a80d546264 parse.y: predefined ID
* parse.y (reg_named_capture_assign_gen): use predefined ID
  instead of rb_intern.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48502 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-11-19 16:01:02 +00:00
nobu 595ce95d3c parse.y: append directly to delayed content
* parse.y (parser_here_document): append byte sequence directly to
  the delayed content instead of creating an intermediate string
  object.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48500 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-11-19 15:26:41 +00:00
nobu 5023492957 parse.y: fix literal symbol list node type
* parse.y (symbol_list): fix the node type of literal symbol list
  with no interpolation.  [ruby-core:66343]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48484 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-11-18 19:16:27 +00:00
ko1 fbebd502f9 * rewrite method/block parameter fitting logic to optimize
keyword arguments/parameters and a splat argument.
  [Feature #10440] (Details are described in this ticket)
  Most of complex part is moved to vm_args.c.
  Now, ISeq#to_a does not catch up new instruction format.
* vm_core.h: change iseq data structures.
  * introduce rb_call_info_kw_arg_t to represent keyword arguments.
  * add rb_call_info_t::kw_arg.
  * rename rb_iseq_t::arg_post_len to rb_iseq_t::arg_post_num.
  * rename rb_iseq_t::arg_keywords to arg_keyword_num.
  * rename rb_iseq_t::arg_keyword to rb_iseq_t::arg_keyword_bits.
    to represent keyword bitmap parameter index.
    This bitmap parameter shows that which keyword parameters are given
    or not given (0 for given).
    It is refered by `checkkeyword' instruction described bellow.
  * rename rb_iseq_t::arg_keyword_check to rb_iseq_t::arg_keyword_rest
    to represent keyword rest parameter index.
  * add rb_iseq_t::arg_keyword_default_values to represent default
    keyword values.
  * rename VM_CALL_ARGS_SKIP_SETUP to VM_CALL_ARGS_SIMPLE
    to represent
      (ci->flag & (SPLAT|BLOCKARG)) &&
      ci->blockiseq == NULL &&
      ci->kw_arg == NULL.
* vm_insnhelper.c, vm_args.c: rewrite with refactoring.
  * rewrite splat argument code.
  * rewrite keyword arguments/parameters code.
  * merge method and block parameter fitting code into one code base.
* vm.c, vm_eval.c: catch up these changes.
* compile.c (new_callinfo): callinfo requires kw_arg parameter.
* compile.c (compile_array_): check the last argument Hash object or
  not. If Hash object and all keys are Symbol literals, they are
  compiled to keyword arguments.
* insns.def (checkkeyword): add new instruction.
  This instruction check the availability of corresponding keyword.
  For example, a method "def foo k1: 'v1'; end" is cimpiled to the
  following instructions.
    0000 checkkeyword     2, 0  # check k1 is given.
    0003 branchif         9     # if given, jump to address #9
    0005 putstring        "v1"
    0007 setlocal_OP__WC__0 3   # k1 = 'v1'
    0009 trace            8
    0011 putnil
    0012 trace            16
    0014 leave
* insns.def (opt_send_simple): removed and add new instruction
  "opt_send_without_block".
* parse.y (new_args_tail_gen): reorder variables.
  Before this patch, a method "def foo(k1: 1, kr1:, k2: 2, **krest, &b)"
  has parameter variables "k1, kr1, k2, &b, internal_id, krest",
  but this patch reorders to "kr1, k1, k2, internal_id, krest, &b".
  (locate a block variable at last)
* parse.y (vtable_pop): added.
  This function remove latest `n' variables from vtable.
* iseq.c: catch up iseq data changes.
* proc.c: ditto.
* class.c (keyword_error): export as rb_keyword_error().
* common.mk: depend vm_args.c for vm.o.
* hash.c (rb_hash_has_key): export.
* internal.h: ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48239 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-11-02 18:02:55 +00:00
nobu 119afd7531 parse.y: separate error messages
* parse.y (parse_atmark): separate error messages for sigil types,
  and make more descriptive

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48221 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-11-01 06:59:43 +00:00
nobu b5ba1dcdf0 parse.y: invalid instance/class variable names
* parse.y (parse_atmark): mere atmark and two atmarks without
  succeeding identifiers are invalid as instance/class variable
  names.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48220 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-11-01 06:45:17 +00:00
nobu 049bbd72e3 parse.y: reset current_arg after block var
* parse.y (block_param_def): reset current_arg after block
  parameter definition, not to warn references in that block body.
  [ruby-core:65990] [Bug #10314]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48190 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-10-29 15:01:49 +00:00
nobu 6fe9b2b794 parse.y: warn iside a block
* parse.y (gettable_gen): also warn circular argument reference even
  inside a block.  [ruby-core:65990] [Bug #10314]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48189 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-10-29 14:24:24 +00:00
nobu 98ea627561 parse.y: warn circular argument reference
* parse.y (gettable_gen): warn circular argument reference, for
  transition from 2.1 and earlier.  [ruby-core:65990] [Bug #10314]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48188 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-10-29 12:13:26 +00:00
nobu d8270efcc9 parse.y: unused member
* parse.y (parser_params): remove unused member `cur_mid`.
  this has been taken over by `in_def` since 1.6.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48187 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-10-29 11:41:03 +00:00
nobu 92c61ca747 ripper/tools/generate.rb: shorten generated source
* ext/ripper/tools/generate.rb (generate_eventids1): shorten
  generated source.

* ext/ripper/tools/generate.rb (generate_eventids2): ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48155 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-10-27 06:38:09 +00:00
nobu d8e1bf2760 id.h.tmpl: ANDOP and OROP
* template/id.h.tmpl (token_op_ids): define && and || for ripper.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48154 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-10-27 06:25:59 +00:00
nobu 5a277b4070 parse.y: optimize IDs in ripper
* parse.y: optimize ripper_intern calls, ::, **, -@, +@, <=>, >=,
  <=, ==, ===, !=, =~, !~, <<, >>, and call.

* parse.y: use initialized IDs, warn and warning.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48153 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-10-27 06:23:09 +00:00
nobu d1ec43ae7a parse.y: Ripper.sexp returns error
* ext/ripper/lib/ripper/sexp.rb (Ripper.sexp, Ripper.sexp_raw):
  return nil on error.  [ruby-dev:48678] [Bug #10405]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48144 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-10-26 03:24:18 +00:00
nobu 5940b1f6fc parse.y: fix fluent interface identifier
* parse.y (parser_yylex): dispatch newline and space at fluent
  interface, so that the following identifier does not include the
  space.  [ruby-dev:48684] [Bug #10411]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48126 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-10-24 13:49:44 +00:00
nobu fe4ed311d1 parse.y: indent
* parse.y (parser_yylex): adjust indent.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48125 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-10-24 13:33:06 +00:00
nobu 04e5c65ff7 parse.y: do not use disposed string
* parse.y (parser_here_document): do not append already appended
  and disposed code fragment.  [ruby-dev:48647] [Bug #10392]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47973 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-10-16 06:05:03 +00:00
nobu 4a883ff9a8 parse.y: keep nodes linking
* parse.y (remove_duplicate_keys): should keep nodes linking not
  to be collected.  [Bug #10315]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47898 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-10-13 00:40:32 +00:00
nobu 37d0c873f6 parse.y: should not eliminate value nodes
* parse.y (remove_duplicate_keys): should not simply eliminate all
  value nodes, which may have side effects.
  [ruby-core:65625] [Bug #10315]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47894 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-10-12 17:39:29 +00:00
nobu 5fa4d56263 parse.y: remove duplicate keys
* parse.y (remove_duplicate_keys): remove duplicate literal keys,
  i.e., symbols and strings.  [ruby-core:65368] [Bug #10315]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47879 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-10-11 04:47:06 +00:00
nobu 1571682719 parse.y: precedence of duplicated keys
* parse.y (assocs): concatenate splatted literal hashes.  the
  former key has precedence even if duplicated literal keys
  follow.  [ruby-core:65368] [Bug #10315]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47877 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-10-11 04:46:42 +00:00
nobu bc512a375d parse.y: remove unused argument
* parse.y (list_concat): remove unused argument parser, since
  never allocates new node.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47789 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-10-04 15:07:51 +00:00
nobu ffe920d674 parse.y: separate ripper data type
* parse.y (parser_data_type): separate ripper data type for from
  parser.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47747 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-09-30 13:25:28 +00:00
nobu 08248c937c parse.y: label cannot be followed by a modifier
* parse.y (parse_ident): just after a label, new expression should
  start, cannot be a modifier.  [ruby-core:65211] [Bug #10279]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47696 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-09-23 13:00:27 +00:00
nari 5390e32119 * parse.y (parser_class_nest): unused variable after YARV
merged (r11439).

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47674 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-09-21 09:52:37 +00:00
nobu b0c03f63e5 parse.y: quoted ID key
* parse.y (assoc): allow quoted ID as a key of a hash literal.
  [ruby-core:34453] [Feature #4276]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47649 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-09-20 01:48:43 +00:00
nobu da7475b00d parse.y: intern_cstr
* parse.y (intern_cstr): remove `_without_pindown` suffix and use
  rb_intern3() as well as RIPPER, for the time being.
  [ruby-core:65009] [Bug #10206]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47569 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-09-13 01:28:57 +00:00
nobu 3fd37d0824 parse.y: fix warning message
* parse.y (arg_ambiguous_gen): fix warning message, "even" does
  not mean the number of spaces here.  state the place to put a
  space and the operator.  [ruby-core:64790] [Bug #10204]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-09-06 02:08:45 +00:00
nobu 66c2bbdea3 parse.y: use rb_ary_tmp_new_fill
* parse.y (coverage): use rb_ary_tmp_new_fill() instead of setting
  internal structure directly.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47296 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-08-27 02:10:22 +00:00
nobu bef5ddbb71 parser.y: warning with VALUE for ripper
* parse.y (ripper_warnV, ripper_warningV): add versions using
  VALUE for ripper.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47184 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-08-14 23:32:06 +00:00
nobu 02c86ce1ee parse.y: preserve encodings
* parse.y (shadowing_lvar, warn_unused_var),
  (reg_named_capture_assign_iter): preserve encodings in warning
  messages.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47171 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-08-13 12:20:13 +00:00
nobu a7c4146d9c parse.y: fix invalid char in eval
* parse.y (parser_yylex): fix invalid char in eval, should raise
  an syntax error too, as well as directly coded.
  [ruby-core:64243] [Bug #10117]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47098 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-08-07 16:07:25 +00:00
nobu 2bd1ae1e67 parse.y: preserve encoding
* parse.y (parser_yyerror): preserve source code encoding in
  syntax error messages.  [ruby-core:64228] [Bug #10114]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47090 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-08-06 21:04:52 +00:00
normal 6358bae370 struct parse_params: trivial packing
* parse.y (struct parse_params): shrink to 320 to 304 bytes on 64-bit

Some elements may be removed/resized as well, but not as important
as reducing more-frequently allocated structures.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46954 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-07-25 21:47:20 +00:00
normal 48a2b96d2b introduce ZALLOC{,_N} to replace ALLOC{,_N}+MEMZERO use
Using calloc where possible reduces code and binary sizes.

* include/ruby/ruby.h (ZALLOC, ZALLOC_N): implement
  (Data_Make_Struct, TypedData_Make_Struct):
  ZALLOC replaces ALLOC+memset
* compile.c (iseq_seq_sequence): ZALLOC_N replaces ALLOC_N+MEMZERO
* cont.c (fiber_t_alloc): ZALLOC replaces ALLOC+MEMZERO
* io.c (rb_io_reopen): ditto
* iseq.c (prepare_iseq_build): ditto
* parse.y (new_args_tail_gen, parser_new, ripper_s_allocate): ditto
* re.c (match_alloc): ditto
* variable.c (rb_const_set): ditto
* ext/socket/raddrinfo.c (get_addrinfo): ditto
* ext/strscan/strscan.c (strscan_s_allocate): ditto
* gc.c (rb_objspace_alloc): calloc replaces malloc+MEMZERO

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46952 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-07-25 21:34:35 +00:00
nobu be7c04e197 parse.y: dynamic const assign_error in ripper
* parse.y (mlhs_node): dynamic constant assignment in massign
  should cause assign_error, like as single assign and backref
  assignment in massign.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46931 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-07-24 15:28:14 +00:00
nobu 418c46f284 parse.y: move common code
* parse.y (arg, primary): move common code shared with ripper.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46930 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-07-24 15:28:01 +00:00
nobu 4cd0471178 parse.y: remove garbage
* parse.y (assoc): remove garbage semicolon added by r35489.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46926 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-07-24 08:22:17 +00:00
nobu 25a2e870d4 parse.y: separate from parse_ident
* parse.y (tokadd_ident, tokenize_ident): extract from
  parse_ident().

* parse.y (parse_gvar, parse_atmark): move tokenization from
  parse_ident().

* parse.y (parse_ident): now deals with non-sigil names only.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46850 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-07-17 04:30:44 +00:00
nobu 27e1b24776 parse.y: parse_atmark
* parse.y (parse_atmark): extract from parser_yylex().

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46849 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-07-17 04:30:38 +00:00
nobu db155640b7 parse.y: parse_ident
* parse.y (parse_ident): extract from parser_yylex().

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46848 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-07-17 04:30:34 +00:00
nobu 5faf8f07e9 parse.y: parse_gvar
* parse.y (parse_gvar): extract from parser_yylex().

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46847 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-07-17 04:30:31 +00:00
nobu d41b3e8874 parse.y: parse_percent
* parse.y (parse_percent): extract from parser_yylex().

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46846 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-07-17 04:30:27 +00:00
nobu c42029f34a parse.y: parse_qmark
* parse.y (parse_qmark): extract from parser_yylex().

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46845 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-07-17 04:30:24 +00:00
nobu 9e09b370c1 parse.y: parse_rational
* parse.y (parse_rational): extract from parse_numeric().

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46844 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-07-17 04:30:21 +00:00
nobu 5000ed38f4 parse.y: parse_numeric
* parse.y (parse_numeric): extract from parser_yylex().

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46842 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-07-17 04:30:13 +00:00
nobu 88d4f46f5e parse.y: negate_lit
* parse.y (negate_lit): alter only literal object itself, not NODE.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46841 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-07-17 04:30:04 +00:00
nobu d33d22c7a0 parse.y: rename Init_parser
* parse.y (rb_init_parse): rename to get rid of name clash with
  json/parser at statically linking.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46787 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-07-11 13:52:47 +00:00
nobu 94ce481263 symbol.c, symbol.h: split from parse.y
* symbol.c, symbol.h: Symbol class implementation and internals,
  split from parse.y.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46768 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-07-09 08:07:32 +00:00
nobu d299250afa parse.y: adjust argument types
* parse.y (symbols_i): adjust argument types for st_foreach()
  using st_data_t.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46767 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-07-09 07:31:42 +00:00
ko1 76a929a7fc * parse.y: change Symbol <-> ID relationship to avoid
exposing IDs from collectable symbols.
  [Bug #10014]
  Now, rb_check_id() returns 0 if corresponding symbol is
  pinned dynamic symbol.
  There is remaining intern_cstr_without_pindown(), it can return
  IDs from collectable symbols. We must be careful to use it
  (only used in parse.y).  I think it should be removed if
  it does not have impact for performance.
* parse.y:
  add:
  * STATIC_SYM2ID()
  * STATIC_ID2SYM()
  rename:
  * rb_pin_dynamic_symbol() -> dsymbol_pindown()
* internal.h:
  remove:
  * rb_check_id_without_pindown()
  * rb_sym2id_without_pindown()
  add:
  * rb_check_symbol()
  * rb_check_symbol_cstr()
* load.c: use rb_check_id() or rb_check_id_cstr().
* object.c: ditto.
* struct.c: ditto.
* thread.c: ditto.
* vm_method.c: ditto.
* string.c (sym_find): use only rb_check_symbol().
* sprintf.c (rb_str_format): use rb_check_symbol_cstr().



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46764 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-07-09 06:14:41 +00:00
ko1 37f018fdf5 * parse.y (symbols_i): delete garbage symbols for Symbol.all_symbols.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46763 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-07-09 05:00:53 +00:00
nobu 65accad30a parse.y: expand is_asgn_or_id
* parse.y (new_op_assign_gen): expand is_asgn_or_id(), which call
  id_type() function multiple times now.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46754 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-07-08 07:01:10 +00:00
ko1 fd7073f7aa * parse.y (dsymbol_alloc): set global_symbols.minor_marked to 0.
* parse.y (dsymbol_check): set RSYMBOL(sym)->fstr to 0
  because we should not touch fstr after that.
* parse.y (rb_gc_free_dsymbol): skip deleting str and sym
  from tables if fstr == 0.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46752 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-07-08 05:48:36 +00:00
ko1 8572ed5c0d * parse.y: remove global_symbols::pinned_dsym
(and ::pinned_dsym_minor_marked).
  Mark pinned dsymbols by rb_gc_register_mark_object() because
  they are immortal.
* prase.y (rb_gc_free_dsymbol): rename parameter name `ptr' to `sym'.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46749 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-07-07 05:36:25 +00:00
ko1 2c551e4715 * parse.y: need to use updated (re-created) symbols.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46737 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-07-07 03:42:42 +00:00
ko1 a31219c91c * parse.y: do not use rb_gc_resurrect(), but create a new dynamic
symbol for garbage dynamic symbol.
* common.mk: use gc.h by parse.y.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46729 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-07-07 01:53:54 +00:00
nobu 5405eff901 parse.y: fix casts
* parse.y (reg_named_capture_assign_gen): remove needless cast.

* parse.y (must_be_dynamic_symbol, intern_cstr_without_pindown):
  get rid of type-punning cast.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46697 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-07-04 17:27:08 +00:00
ko1 336f65eb57 * parse.y: rename symbols::sym_id to symbols::str_id.
This table is not {Symbol => ID} table, but
  {String => ID} table.
* parse.y (lookup_sym_id): also rename lookup_sym_id() to
  lookup_str_id() because key is not Symbol, but String.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46696 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-07-04 11:48:47 +00:00
ko1 a99a88d49d * parse.y (must_be_dynamic_symbol): fix missed-condition.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46695 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-07-04 09:42:55 +00:00
ko1 cc462eed98 * parse.y (rb_pin_dynamic_symbol): should be `static' function.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46694 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-07-04 09:39:14 +00:00
ko1 a227b16eba * parse.y (must_be_dynamic_symbol): refactoring.
* add `inline'.
  * use UNLIKELY().
  * check only DYNAMIC_SYM_P(), otherwise it is a bug.
  * lookup_id_str() is not needed in second condition.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46693 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-07-04 09:11:05 +00:00
nobu 27cafcfc89 parse.y: remove global_symbols.op_sym
* parse.y (global_symbols): remove op_sym, cache by fstring
  instead.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46691 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-07-04 07:30:11 +00:00
nobu 56ff2b50f3 parse.y: use rb_fstring_new
* parse.y (rb_id2str): use rb_fstring_new() instead of rb_fstring()
  with a new string instance.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46690 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-07-04 07:16:21 +00:00
nobu 5e294b7820 parse.y: pack op_tbl
* parse.y (op_tbl): pack limited size strings.  gcc/clang warn
  if initializer-string for char array is too long, but no option
  to err it now.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46688 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-07-04 06:10:37 +00:00
ko1 3e8a898bfe * parse.y: remove unused code
srounded by `#if ENABLE_SELECTOR_NAMESPACE'



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46685 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-07-04 02:56:34 +00:00
nobu fd8b254705 node.h: remove NODE_PRIVATE_RECV
* compile.c (private_recv_p): check by node type, instead of a
  magic number.
* node.h (NODE_PRIVATE_RECV), parse.y (attrset_gen): remove

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46366 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-06-06 13:19:31 +00:00
nobu 199f814f32 compile.c, parse.y: private op assign
* compile.c (iseq_compile_each), parse.y (new_attr_op_assign_gen):
  allow op assign to a private attribute.
  [ruby-core:62949] [Bug #9907]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46365 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-06-06 08:07:13 +00:00
nobu 118f0d1da5 parse.y: attr_receiver
* parse.y (aryset_gen): use `attr_receiver()`.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46362 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-06-06 07:54:37 +00:00
nobu bb3f036336 node.h: NODE_PRIVATE_RECV
* node.h (NODE_PRIVATE_RECV): name a magic number, `self` as the
  receiver of a setter method call.

* compile.c (private_recv_p), parse.y (attr_receiver): use the
  named macro.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46361 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-06-06 06:05:19 +00:00
nobu 6ab08d2e8d configure.in, missing.h: jemalloc mangling
* configure.in (with-jemalloc): also check for header, for ABIs
  which JEMALLOC_MANGLE is needed, i.e., Mach-O and PE-COFF
  platforms.  [ruby-core:62939] [Feature #9113]
* include/ruby/missing.h: include alternative malloc header to
  replace memory management functions.
* dln.c, io.c, parse.y, st.c: undef malloc family before
  re-definition to suppress warnings.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46354 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-06-05 05:16:46 +00:00
nobu f2980e3e20 encoding.h: constify rb_encoding
* include/ruby/encoding.h: constify `rb_encoding` itself, not only
  arguments.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46322 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-06-02 20:23:47 +00:00
nobu 046831094b constify rb_encoding and OnigEncoding
* include/ruby/encoding.h: constify `rb_encoding` arguments.
* include/ruby/oniguruma.h: constify `OnigEncoding` arguments.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46309 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-06-01 22:06:11 +00:00
nobu 70d34c623a parse.y: no duplicate attrset ID
* parse.y (intern_str): dynamic attrset ID is registered by
  `rb_id_attrset()` already, so no further registration is needed.
  [ruby-core:62861]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46289 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-05-31 21:55:53 +00:00
normal fae18c95be remove empty rb_gc_mark_parser function
* parse.y (rb_gc_mark_parser): remove, empty since r8758
* internal.h: ditto, not usable from extensions since 2.0.0
* gc.c (gc_mark_roots): remove checkpoint for parser

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46239 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-05-29 19:49:22 +00:00
nobu fe780f2997 parse.y: refine error message
* parse.y (parser_number_literal_suffix): refine error message for
  extra dot and digits.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46179 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-05-27 14:06:48 +00:00
nobu b5cae3820b parse.y: no duplicated names
* parse.y (new_bv_gen): no duplicated names, if already added in
  shadowing_lvar().

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45846 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-05-06 14:29:07 +00:00
nobu d750b62d66 parse.y: remove duplicated names
* parse.y (local_tbl_gen): remove local variables duplicated with
  arguments.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45845 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-05-06 14:28:48 +00:00
nobu 8a57bb7b4a parse.y: unused return values
* parse.y (arg_var_gen, local_var_gen): make void since the result
  values are not used.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45844 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-05-06 14:28:38 +00:00
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