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

1291 Коммитов

Автор SHA1 Сообщение Дата
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