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

1153 Коммитов

Автор SHA1 Сообщение Дата
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
nobu c07d78eb0e parse.y: keyword argument without paren
* parse.y (IS_LABEL_POSSIBLE): allow labels for keyword arguments just
  after method definition without a parenthesis.  [ruby-core:52820]
  [Bug #7942]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39504 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-02-26 01:24:52 +00:00
tenderlove 53f97f1c27 * parse.y: add dtrace probe for symbol create.
* probes.d: ditto

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39266 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-02-16 03:16:05 +00:00
nobu 20af032e82 parse.y: no assigned but unused warnings in eval
* parse.y (local_push_gen): no assigned but unused variable warnings
  in eval as well as -e.  [Feature #7730] [ruby-core:51580]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38998 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-01-31 07:33:30 +00:00
nobu 71eddb1dea parse.y: warn assigned but unused in toplevel
* parse.y (local_push_gen): warn assigned but unused variables also in
  toplevel, except for -e option.  [Feature #7730] [ruby-core:51580]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38982 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-01-30 04:22:12 +00:00
naruse 2bcff78b42 * string.c (dispose_string): use rb_str_free for freeing string in
parse.y. by Sokolov Yura <funny.falcon@gmail.com>
  https://github.com/ruby/ruby/pull/87 fix GH-87

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38774 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-01-11 03:00:23 +00:00
nobu e489dc1ff4 parse.y: bare kwrest_mark
* parse.y (f_kwrest): allow bare kwrest_mark as valid syntax.  its
  semantics is still undefined.  [Bug #7662] [ruby-core:51269]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38725 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-01-07 06:42:13 +00:00
nobu 38da1a5398 parse.y: duplicated kwrest name
* parse.y (f_kwrest): reject duplicated kwrest argument name.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38724 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-01-07 06:32:01 +00:00
nobu 77df5bb1b5 parse.y: escaped closing parenthsis
* parse.y (simple_re_meta): escaped closing parenthsis has different
  meaning.  [Bug #7610] [ruby-core:51088]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38663 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-12-30 14:33:38 +00:00
nobu e878df745c use RB_TYPE_P
* enumerator.c (enumerator_initialize), eval.c (rb_using_refinement),
  (add_activated_refinement), numeric.c (num_interval_step_size),
  parse.y (arg, match_op_gen, cond0), range.c (range_bsearch),
  vm_insnhelper.c (vm_get_iclass): use RB_TYPE_P() to optimize.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38653 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-12-29 12:22:01 +00:00
nobu 7ea675732a scoped constant op-assignment
* node.h (NODE_OP_CDECL), compile.c (iseq_compile_each),
  parse.y (stmt, arg): allow scoped constant op-assignment.
  [ruby-core:40154] [Bug #5449]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38585 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-12-24 15:59:31 +00:00
nobu 2ca5e8eeab * parse.y (yycompile0): adjust indent.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38403 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-12-15 06:10:01 +00:00
nobu 5a565d5c4d parse.y: fix line number
* parse.y (parser_params): parser_tokline to track the line number at
  which token started.  [ruby-dev:46737] [Bug #7559]

* parse.y (fcall): operation with starting line number.

* parse.y (command, primary, method_call): point method name line.

* parse.y (gettable_gen): return token line for __LINE__.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38378 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-12-14 08:11:00 +00:00
nobu bd0c636211 parse.y: flush string content
* parse.y (parser_here_document): flush string content between new
  line and :string_embexpr.  [ruby-core:48703] [Bug #7255]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38235 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-12-06 08:29:16 +00:00
naruse f68ab20044 * parse.y: replase parser->enc with current_enc.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38171 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-12-04 01:01:34 +00:00
ko1 f6f388a5bd * array.c, enum.c, insns.def, io.c, numeric.c, parse.y, process.c,
range.c: use prepared IDs.
  A patch from charliesome (Charlie Somerville).
  [Bug #7495]
* common.mk: add dependency to id.h.
* common.mk: replace ID_H_INCLUDES with id.h.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38143 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-12-02 09:57:47 +00:00
naruse b1920c034b * parse.y (parser.utf8): remove unused property.
* parse.y (UTF8_ENC): remove unused macro.

* parse.y (parser_tokadd_utf8): use rb_utf8_encoding() directly.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38093 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-30 19:10:17 +00:00
nobu 8e2839ba2f parse.y: false usage of local variable
* parse.y (parser_yylex): fix false usage of local variable, it cannot
  appear in fname state [ruby-core:49659] [Bug #7408]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38039 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-30 06:24:40 +00:00
nobu 25b0a58bf5 parse.y: LVAR_USED
* parse.y (LVAR_USED): use MSB of ID.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38035 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-30 05:42:01 +00:00
nobu 7e42e55e08 parse.y: IS_lex_state_for
* parse.y (IS_lex_state_for): new macro similar to IS_lex_state() but
  for arbitrary variables.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38034 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-30 05:41:57 +00:00
tadf c07d295204 * include/ruby/util.h: removed extra semicolon in definition of
macro.
	* compile.c: ditto.
	* cont.c: ditto.
	* math.c: ditto.
	* node.c: ditto.
	* parse.y: ditto.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37781 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-21 12:42:11 +00:00
tenderlove 4c740bae97 * probes.d: add DTrace probe declarations. [ruby-core:27448]
* array.c (empty_ary_alloc, ary_new): added array create DTrace probe.

* compile.c (rb_insns_name): allowing DTrace probes to access
  instruction sequence name.

* Makefile.in: translate probes.d file to appropriate header file.

* common.mk: declare dependencies on the DTrace header.

* configure.in: add a test for existence of DTrace.

* eval.c (setup_exception): add a probe for when an exception is
  raised.

* gc.c: Add DTrace probes for mark begin and end, and sweep begin and
  end.

* hash.c (empty_hash_alloc): Add a probe for hash allocation.

* insns.def: Add probes for function entry and return.

* internal.h: function declaration for compile.c change.

* load.c (rb_f_load): add probes for `load` entry and exit, require
  entry and exit, and wrapping search_required for load path search.

* object.c (rb_obj_alloc): added a probe for general object creation.

* parse.y (yycompile0): added a probe around parse and compile phase.

* string.c (empty_str_alloc, str_new): DTrace probes for string
  allocation.

* test/dtrace/*: tests for DTrace probes.

* vm.c (vm_invoke_proc): add probes for function return on exception
  raise, hash create, and instruction sequence execution.

* vm_core.h: add probe declarations for function entry and exit.

* vm_dump.c: add probes header file.

* vm_eval.c (vm_call0_cfunc, vm_call0_cfunc_with_frame): add probe on
  function entry and return.

* vm_exec.c: expose instruction number to instruction name function.

* vm_insnshelper.c: add function entry and exit probes for cfunc
  methods.

* vm_insnhelper.h: vm usage information is always collected, so
  uncomment the functions.

12 19:14:50 2012  Akinori MUSHA  <knu@iDaemons.org>

* configure.in (isinf, isnan): isinf() and isnan() are macros on
  DragonFly which cannot be found by AC_REPLACE_FUNCS().  This
  workaround enforces the fact that they exist on DragonFly.

12 15:59:38 2012  Shugo Maeda  <shugo@ruby-lang.org>

* vm_core.h (rb_call_info_t::refinements), compile.c (new_callinfo),
  vm_insnhelper.c (vm_search_method): revert r37616 because it's too
  slow.  [ruby-dev:46477]

* test/ruby/test_refinement.rb (test_inline_method_cache): skip
  the test until the bug is fixed efficiently.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37631 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-12 21:52:12 +00:00
nobu f030a91d3e * parse.y (warn_balanced): use bit-wise operation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37579 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-09 06:57:42 +00:00
naruse 58ef0f06c6 * ruby.c (load_file_internal): set default source encoding as
UTF-8 instead of US-ASCII. [ruby-core:46021] [Feature #6679]

* parse.y (parser_initialize): set default parser encoding as
  UTF-8 instead of US-ASCII.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37485 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-06 00:49:57 +00:00
nobu e672994d14 parse.y: warn static content assign in cond
* parse.y (assign_in_cond): warn for static content object asignments
  in conditional statements.  [ruby-dev:43083] [Feature #4299]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37344 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-10-27 15:49:09 +00:00
shyouhei d090f17f21 * iseq.c (rb_iseq_compile_with_option): Instead of testing
respond_to, just check if the argument is actually a file,
  because by calling user-defined gets something weired can
  happen.  Patch by Glass_saga. [ruby-dev:40202] [Bug #2861]

* parse.y (ripper_initialize): ditto.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37339 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-10-27 01:16:25 +00:00
nobu 197e7b812c parse.y: bit field lex_state
* parse.y (enum lex_state_e): [EXPERIMENTAL] lex_state as bit field /
  IS_lex_state() macro.  based on the patch by Dave B in
  [ruby-core:23503].  [Feature #1493]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37338 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-10-27 01:07:59 +00:00
nobu e7576a777c parse.y: concatenated literals
* parse.y (literal_concat_gen): merge fixed strings across
  concatenated literals, after an interpolation.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37331 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-10-26 04:24:29 +00:00
naruse c6629c48e6 Revert r37316
The commit introduces too many failures and disturbs release engineering.
Re-commit it with fixed tests.

Thu Oct 25 13:09:01 2012  NAKAMURA Usaku  <usa@ruby-lang.org>

       * parse.y: show a warning for concatenating string literals because
         it will be deprecated in the future.
         patched by mame (Yusuke Endoh) at [ruby-core:44207].
         [ruby-core:44156] [Feature #6265]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37327 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-10-25 11:50:20 +00:00
usa 4a309b765e * parse.y: show a warning for concatenating string literals because
it will be deprecated in the future.
  patched by mame (Yusuke Endoh) at [ruby-core:44207].
  [ruby-core:44156] [Feature #6265]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37317 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-10-25 04:22:21 +00:00
nobu 676c01bb36 parse.y: fail if yyerror
* parse.y (assignable_gen): fail if yyerror occurred.  fix a bug in
  r36973.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37251 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-10-18 01:30:37 +00:00
nobu f3dd7c4963 parse.y: suppress warnings
* parse.y (id_type): suppress warnings.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36983 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-09-16 09:09:10 +00:00
nobu 47b642bdd3 parse.y: new_attr_op_assign
* parse.y (new_attr_op_assign): extract.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36975 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-09-15 09:26:33 +00:00
nobu 2bfc48dd62 parse.y: new_op_assign
* parse.y (new_op_assign): extract.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36974 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-09-15 09:26:31 +00:00
nobu 66d03f5f3c parse.y: switch
* parse.y (gettable_gen, assignable_gen): rewrite sequential if-else
  as switch.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36973 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-09-15 09:26:28 +00:00
nobu b520b21839 parse.y: static table
* parse.y (lex_state_name): use static table.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36972 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-09-15 09:26:26 +00:00
usa 8ee2226068 * parse.y (rb_warn4S): renamed from rb_warn4(), because the case in
r36911 takes a string.

* parse.y (rb_warn4S): use ripper_warnS() for ripper.

* parse.y (ripper_warnS): now it is used.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36913 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-09-05 10:22:49 +00:00
naruse 406f6a23d5 * parse.y (rb_warn4): added as a rb_warn variant to warn with explicit
source file name and line in parse.y.

* parse.y (warn_unused_var): use rb_warn4 to suppress warning on ripper.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36911 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-09-05 06:23:20 +00:00
nobu 470c941ce5 id.h: independent from parse.h
* template/id.h.tmpl, tool/id2token.rb: make id.h independent from
  parse.h, and make parse.c dependent on it instead.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36864 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-08-31 05:31:20 +00:00
nobu 87450541b3 parse.y: extract function
* parse.y (new_args_tail_gen): extract from dsym rule.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36824 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-08-25 07:21:07 +00:00
ko1 b3b5e626ad * include/ruby/ruby.h: introduce flonum technique for
64bit CPU environment (sizeof(double) == sizeof(VALUE)).
  flonum technique enables to avoid double object creation
  if the double value d is in range about between
  1.72723e-77 < |d| <= 1.15792e+77 or 0.0.
  flonum Float value is immediate and their lowest two bits
  are b10.
  If flonum is activated, then USE_FLONUM macro is 1.
  I'll write detailed in this technique on
  https://bugs.ruby-lang.org/projects/ruby-trunk/wiki/Flonum_tech
* benchmark/bmx_temp.rb: add an benchmark for simple
  Float calculation.
* gc.c (id2ref, rb_obj_id): add flonum Float support.
* include/ruby/intern.h: move decl of rb_float_new(double)
  to include/ruby/ruby.h.
* insns.def, vm.c, vm_insnhelper.c: add flonum optimization
  and simplify source code.
* vm_insnhelper.h (FLONUM_2_P): added.
* marshal.c: support flonum output.
* numeric.c (rb_float_new_in_heap): added.
* parse.y: support flonum.
* random.c: ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36798 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-08-23 07:22:40 +00:00
nobu 89bcc681f0 parse.y: token name
* parse.y: more descriptive token names in syntax error messages.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36738 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-08-20 14:02:32 +00:00
nobu f7c2791c60 id.h.tmpl: preserved ids
* template/id.h.tmpl (preserved_ids): move from parse.y.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36722 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-08-17 08:35:12 +00:00
ko1 4a4a702e61 * vm_trace.c, vm_core.h: simplify tracing mechanism.
(1) add rb_hook_list_t data structure which includes
  hooks, events (flag) and `need_clean' flag.
  If the last flag is true, then clean the hooks list.
  In other words, deleted hooks are contained by `hooks'.
  Cleanup process should run before traversing the list.
  (2) Change check mechanism
  See EXEC_EVENT_HOOK() in vm_core.h.
  (3) Add `raw' hooks APIs
  Normal hooks are guarded from exception by rb_protect().
  However, this protection is overhead for too simple
  functions which never cause exceptions.  `raw' hooks
  are executed without protection and faster.
  Now, we only provide registration APIs.  All `raw'
  hooks are kicked under protection (same as normal hooks).
* include/ruby/ruby.h: remove internal data definition and
  macros.
* internal.h (ruby_suppress_tracing), vm_trace.c: rename
  ruby_suppress_tracing() to rb_suppress_tracing()
  and remove unused function parameter.
* parse.y: fix to use renamed rb_suppress_tracing().
* thread.c (thread_create_core): no need to set RUBY_VM_VM.
* vm.c (mark_event_hooks): move definition to vm_trace.c.
* vm.c (ruby_vm_event_flags): add a global variable.
  This global variable represents all of Threads and VM's
  event masks (T1#events | T2#events | ... | VM#events).
  You can check the possibility kick trace func or not
  with ruby_vm_event_flags.
  ruby_vm_event_flags is maintained by vm_trace.c.
* cont.c (fiber_switch, rb_cont_call): restore tracing status.
  [Feature #4347]
* test/ruby/test_continuation.rb: ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36715 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-08-16 11:41:24 +00:00
tenderlove 91bd6e711d * parse.y: added symbols and qsymbols productions for %i and %I
support. %i{ .. } returns a list of symbols without interpolation,
  %I{ .. } returns a list of symbols with interpolation.  Thanks to
  Josh Susser for inspiration of this feature. [Feature #4985]

* ext/ripper/eventids2.c: added ripper events for %i and %I.

* test/ripper/test_parser_events.rb: ripper tests

* test/ripper/test_scanner_events.rb: ditto

* test/ruby/test_array.rb: test for %i and %I behavior

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36524 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-07-24 18:10:35 +00:00
nobu 1ea6c81762 remove garbage spaces
* insns.def, parse.y: remove garbage spaces.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36479 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-07-20 07:27:28 +00:00
shugo bbaf9b2800 * parse.y (primary): allow an empty grouped expression as the
operand of the not operator (e.g., not ()).
  [ruby-core:45976] [Bug #6674]

* parse.y (parser_yylex): show no warning for a grouped expression
  as the operand of the not operator (e.g., not (a)) or as an
  argument of a method call without parentheses (e.g., foo (a)).
  [ruby-core:39050] [Bug #5214]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36434 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-07-18 07:05:12 +00:00
nobu fbacb71b38 [Feature #6693]
* parse.y (shadowing_lvar_gen, warn_unused_var): no warnings for
  variables starting with _.  [ruby-core:46160][Feature #6693]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36337 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-07-07 22:36:25 +00:00
nobu 64ae33a18a parse.y: fix GC problem of keyword rest argument
* parse.y (new_args_tail_gen): fix GC problem of keyword rest
  argument.  the wrapped struct should be bound to the wrapping node
  before assignment of child nodes, to get rid of the case the
  children are referred by only the struct pointer which is not a
  subject of GC.  [ruby-core:45744]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36161 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-06-21 08:20:51 +00:00
nobu 45f6cdcdd3 Bug #6403: reset states after empty args
* parse.y (f_arglist): should reset lexical states after empty
  argument list with no parenthesis as well as parenthesized list,
  so that reserved name method definition work.  [ruby-dev:45626]
  [Bug #6403]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35644 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-05-14 07:28:36 +00:00
nobu 4bbb0f9801 Bug #6419: fix cmdarg begin
* parse.y (primary): begin/end block should be isolated from outside.
  [ruby-dev:45631][Bug #6419]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35620 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-05-11 05:23:14 +00:00
nobu ae32e9a225 parse.y: debugging stuff
* parse.y (lex_state_name): returns name for lex_state_e, for debug
  use.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35607 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-05-10 01:18:27 +00:00
nobu 9cf2170e78 * parse.y (parser_yylex): allow spaces between lambda arrow and
parenthesis.  [ruby-dev:45605][Feature #6390]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35520 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-05-02 14:21:23 +00:00
nobu 3380974143 * parse.y (assoc, parser_yylex): add syntax to splat keyword hash.
[ruby-core:44591][Feature #6353]
* compile.c (compile_array_): generate keyword splat insns.
* vm.c (m_core_hash_merge_kwd): merge keyword hash into intermediate
  hash.  leftward argument is prior currently.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35489 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-04-28 21:12:05 +00:00
nobu 5f34227718 * parse.y (parser_yylex): EXPR_BEG by keywords is a start point of
commands.  [ruby-dev:45563][Bug #6347]
* parse.y (superclass): ditto for superclass.
* parse.y (parser_parse_string, parser_here_document): ditto for
  string interpolation.
* parse.y (parser_yylex): ditto for singleton class.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35457 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-04-24 07:04:41 +00:00
mame 563762f6c5 * parse.y (primary): remove wrong "fixpos" that caused incorrect
source_location of blocks.  [ruby-core:42232] [Bug #5930]

* test/ruby/test_proc.rb: add a test for above.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35447 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-04-23 15:23:41 +00:00
ko1 ee7f8d4805 * compile.c (compile_array, compile_array_):
Divide big array (or hash) literals into several blocks and
  concatetene them.  There was a problem that a big array (hash)
  literal causes SystemStackError exception (stack overflow)
  because VM push all contents of the literal onto VM stack to
  make an array (or hash).  To solve this issue, we make several
  arrays (hashes) and concatenate them to make a big array (hash)
  object.
  ??
* compile.c (iseq_compile_each, setup_args): use modified
  compile_array.
* vm.c (m_core_hash_from_ary, m_core_hash_merge_ary,
  m_core_hash_merge_ptr): added for above change.
* id.c (Init_id), parse.y: add core method ids.
* bootstraptest/test_literal.rb: add simple tests.
* bootstraptest/test_eval.rb: remove rescue clause to catch
  SystemStackError exception.
* test/ruby/test_literal.rb: add tests to check no stack overflow.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35306 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-04-12 01:33:34 +00:00
nobu db5265a82c * parse.y (rb_check_id_cstr): new function to check if ID is
registered with NUL-terminated C string.
* sprintf.c (rb_str_format): avoid inadvertent symbol creation.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35300 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-04-11 13:31:23 +00:00
nobu 41c199130a * parse.y (string_content, parser_yylex): count brace nesting to
dispatch embexpr_end.  [ruby-core:43775][Bug #6211]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35269 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-04-09 06:16:07 +00:00
nobu 7af3e9f08b fix unreachable warning line number
* parse.y (block_append_gen): fix unreachable warning line number.
  should warn at the code, not jump.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35068 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-03-16 08:42:16 +00:00
nobu bf87ec4eb9 * parse.y (parser_yylex): fix warning line number.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35038 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-03-15 06:37:46 +00:00
nobu 375aedbfb4 * parse.y (sym_check_asciionly): check ascii compatibility before
scanning for code range.
* parse.y (intern_str): set to us-ascii if ascii only.
  [ruby-dev:45363][Bug #6146]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35034 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-03-15 06:04:44 +00:00
nobu 08d81f2683 fix ripper
* parse.y (new_args_gen, new_args_tail_gen): fix ripper.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35000 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-03-13 15:26:03 +00:00
nobu 8fe3fb4c0f * compile.c (iseq_set_arguments): keyword rest arg without keyword args.
* node.c (dump_node): dump kw_rest_arg too.
* parse.y (block_param, f_arg): more kwrest patterns.
  [ruby-core:42455][Bug #5989]
* parse.y (new_args_gen): no extra kw_rest_arg if no keyword rest arg.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34999 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-03-13 13:00:17 +00:00
nobu d6a977f667 * parse.y (block_param, f_args): add rules for the case arguments
begin with kwrest.  [ruby-core:42455][Bug #5989]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34998 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-03-13 06:17:08 +00:00
nobu c5feeb9ac1 * node.h (NEW_YIELD), parse.y (new_yield_gen): array-values flags
has been already obsolete.  patch by Thomas Enebo.
  [ruby-core:41929][Bug #5847]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34984 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-03-12 05:56:57 +00:00
nobu bc6dde9420 * parse.y (parser_tokadd_string): escape simple regexp meta
character termninators.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34929 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-03-06 07:24:07 +00:00
nobu c46bdadb84 * parse.y (block_call): rules for block_call after block_call.
based on a patch by pasberth https://github.com/ruby/ruby/pull/102
  [ruby-dev:45308][Bug #6115]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34913 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-03-05 16:34:21 +00:00
nobu 45f3651d1c * parse.y (block_command, block_call): simplified rules.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34912 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-03-05 16:24:15 +00:00
nobu 68a16f9a2d * parse.y (parser_tokadd_string): regexp engine doesn't need
terminators to be escaped.  [ruby-core:40364][Bug #5484]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34896 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-03-04 14:21:13 +00:00
matz f3e1c29b24 * parse.y (opt_bv_decl): allow newline at the end. [ruby-dev:45292]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34835 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-02-27 14:47:02 +00:00
nobu 785521bd51 * parse.y (parser_tokadd_string): insert a backslash only if
quoted by single quotes.  [ruby-dev:45281] [Bug #6069]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34796 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-02-24 22:54:00 +00:00
nobu 45c6daeed7 * parse.y (parser_tokadd_string, parser_yylex): insert a backslash
if the next character is non-ascii.  [ruby-dev:45278] [Bug #6069]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34776 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-02-23 23:52:12 +00:00
mame 8107587039 * parse.y (debug_lines, coverage): set file path encoding for coverage
result.  [ruby-dev:44950]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34415 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-02-01 16:28:14 +00:00
nobu bb19bcf93e * parse.y (rb_intern3): split to registration check and new
registration.
* parse.y (rb_intern_str): make interned string shared with the
  given string.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34354 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-01-22 06:41:29 +00:00
nobu f1dc132b41 * parse.y (rb_intern3, rb_intern_str): check the coderange first.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34352 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-01-22 06:23:38 +00:00
nobu 731e45216a * node.h (rb_args_info): change pre_args_num and post_args_num as
int, to match with rb_iseq_t.
* parse.y (new_args_gen): check overflow.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34139 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-12-27 12:17:36 +00:00
mame 1ab3974b0e * node.h, node.c, parse.y: implement a parser part for keyword arguments. This is a preparation for keyword argument (see [ruby-core:40290]).
* gc.c (gc_mark_children): bookkeeping.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34135 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-12-26 14:20:03 +00:00
mame afb10c62c2 * node.h, parse.y (new_args_gen), compile.c (iseq_set_arguments): use struct rb_args_info instead of NODEs. This is a preparation for keyword argument (see [ruby-core:40290]).
* node.c (dump_node), gc.c (gc_mark_children, obj_free): bookkeeping.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34134 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-12-26 14:19:58 +00:00
mame 90b1afa310 * node.h, parse.y (lambda, f_larglist): remove NEW_LAMBDA hack. This is a preparation for keyword argument (see [ruby-core:40290]).
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34133 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-12-26 14:19:52 +00:00
nobu d62f56b041 * parse.y (primary): point method name line. [ruby-core:40936]
[Bug #5614]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34031 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-12-13 15:01:20 +00:00
nobu 0f9662f366 * parse.y (parser_magic_comment): should pass the proper value.
[ruby-dev:44984][Bug #5753]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34022 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-12-12 21:29:53 +00:00
shugo 900b4a6db6 * parse.y (stmt_or_begin): changed the error message for BEGIN not
at toplevel.  [ruby-dev:44963] [Bug #5738]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34016 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-12-12 13:43:56 +00:00
nobu b526738c3b * bignum.c (big_rshift), compile.c (validate_label,
iseq_build_from_ary_exception), cont.c (cont_capture), dir.c
  (dir_open_dir), gc.c (objspace_each_objects), io.c (pipe_open)
  (rb_io_advise), parse.y (parser_compile_string)
  (rb_parser_compile_file), proc.c (binding_free), process.c
  (rb_proc_exec_n, rb_seteuid_core, proc_setegid, rb_setegid_core)
  (p_uid_exchange, p_gid_exchange), regparse.c (strdup_with_null),
  signal.c (sig_dfl), vm.c (rb_iseq_eval, rb_iseq_eval_main),
  vm_insnhelper.c (vm_expandarray): suppress
  unused-but-set-variable warnings.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33951 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-12-05 09:57:00 +00:00
nobu 4659b00b9a * parse.y (nodetype, nodeline): suppress warnings.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33892 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-11-29 00:51:37 +00:00
usa 4d6de2f7c4 * parse.y (nodetype, nodeline): static. these functions are for
debugging, and not intend to be public.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33883 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-11-28 03:49:00 +00:00
naruse 615d5068d2 * parse.y (parser_nextc): set encoding for the buffer of ripper.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33542 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-10-28 02:30:22 +00:00
nobu 560a6c6ffa * ext/ripper/eventids2.c (ripper_init_eventids2): separate
initializations of IDs and objects.
* ext/ripper/tools/generate.rb (generate_eventids1): ditto.
* parse.y (Init_ripper, InitVM_ripper): fix inversed roles.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33474 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-10-18 14:05:51 +00:00
nobu 8e6e8e6288 * use RB_TYPE_P which is optimized for constant types, instead of
comparison with TYPE.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33357 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-09-29 11:07:45 +00:00
nobu c4d77cb4ad * parse.y (parser_data_type): inherit the core type in ripper so
that checks in core would work.  [ruby-core:39591] [Bug #5331]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33291 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-09-17 14:34:13 +00:00
nobu 4705fcc3c0 * README.EXT, README.EXT.ja (2.2.2), parse.y (rb_check_id): add
documents for rb_check_id().

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33255 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-09-12 04:38:15 +00:00
matz 6126c50add * parse.y (bv_decls): parse.y relies on $$ = $1 before action
routines.  a patch from Michael Edgar.  [Bug #5303]
  [ruby-core:39429]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33242 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-09-09 23:32:56 +00:00
nobu 5e14b97947 * parse.y (parser_tokadd_string, parser_yylex): ignore a backslash
which prefixes an non-ascii character, which has no escape
  syntax.  [ruby-core:39222] [Ruby 1.9 - Bug #5262]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33161 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-09-02 00:58:10 +00:00
nobu 3fbc65d47f * parse.y (rb_check_id): make the given name a symbol or a string.
based on the second patch by Jeremy Evans at [ruby-core:38447]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32684 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-07-26 16:05:27 +00:00
naruse 65658ea0d4 * parse.y (rb_enc_symname_type): :$a!, @a! and so on are not
valid symbols, so they should be inspected with quotes.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32639 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-07-23 10:03:30 +00:00
nobu 12d9be6b72 * parse.y (rb_check_id): take care of attrset ID created
implicitly by local ID.  [Bug #5084]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32635 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-07-23 03:19:07 +00:00
nobu d9242d5966 * parse.y (rb_check_id): conversion condition was inverse.
[Bug #5084]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32634 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-07-23 03:12:28 +00:00
nobu 34918aa832 * object.c (rb_mod_{const,cvar}_defined, rb_obj_ivar_defined):
avoid inadvertent symbol creation in reflection methods.  based
  on a patch by Jeremy Evans at [ruby-core:38367].  [Feature #5072]
* vm_method.c (rb_mod_method_defined)
  (rb_mod_{public,private,protected}_method_defined)
  (obj_respond_to): ditto.
* parse.y (rb_check_id): new function returns already interned ID
  or 0.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32621 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-07-22 12:06:42 +00:00
nobu c276b73804 * parse.y (rb_is_global_id, rb_is_attrset_id): add missing
predicates.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32620 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-07-22 11:44:53 +00:00
nobu e0060732f1 * parse.y (rb_enc_symname2_p): get rid of potential out-of-bound
access.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32618 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-07-22 10:05:49 +00:00
nobu 577c03c713 * parse.y (var_ref): distinguish vcall from local variable
references.  based on a patch by Michael Edgar michael.j.edgar
  AT dartmouth.edu.  Bug #5002

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32498 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-07-10 13:38:17 +00:00