aboutsummaryrefslogtreecommitdiffstats
path: root/parse.y
Commit message (Collapse)AuthorAgeFilesLines
* * method.h: split rb_method_definition_t::flag to several flags.ko12015-06-031-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | `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
* parse.y: check NTH_REF rangenobu2015-05-291-5/+22
| | | | | | | | | | * 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
* allocate structs with wrappernobu2015-05-161-17/+7
| | | | | | | | | | | | | | * 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
* parse.y: refine message for gvar w/o identitirsnobu2015-05-131-2/+7
| | | | | | | * 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
* Revert "support ES6-like hash literals."shugo2015-05-081-72/+17
| | | | | | This reverts commit 0d3797f8b62394f5634f4b2b529d28cb46bebf8a. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50445 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* support ES6-like hash literals.shugo2015-05-081-17/+72
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50443 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* parse.y: %-string cannot be a labelnobu2015-04-301-3/+4
| | | | | | | * 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
* parse.y: push cmdarg_stacknobu2015-04-301-2/+7
| | | | | | | * 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
* parse.y: simplifiednobu2015-04-291-15/+15
| | | | | | | * 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
* compile.c: move expansion of massignnobu2015-04-291-19/+1
| | | | | | | | * 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
* parse.y: null by syntax errornobu2015-04-121-2/+2
| | | | | | | * 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
* parse.y: empty parennobu2015-03-131-2/+2
| | | | | | | * 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
* * internal.h: use T_IMEMO to represent `struct MEMO' value.ko12015-03-111-1/+1
| | | | | | | | | | | | | | | | | | | | | | 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
* use rb_funcallvnobu2015-02-161-1/+1
| | | | | | | * 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
* parse.y: no optimization in defined?nobu2015-01-291-2/+2
| | | | | | | * 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
* parse.y: condition nodenobu2015-01-291-1/+0
| | | | | | * 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
* parse.y: optimize conditionsnobu2015-01-291-5/+43
| | | | | | | * 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
* parse.y: eliminate empty hashesnobu2015-01-091-13/+23
| | | | | | | | * 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
* parse.y: fix f_label resultnobu2015-01-041-2/+2
| | | | | | | * 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
* parse.y: disable past scope warningsnobu2014-12-311-8/+46
| | | | | | | | * 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
* parse.y: fix internal IDs conflictnobu2014-12-281-1/+3
| | | | | | | | | | * 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
* parse.y: warn past scope variablenobu2014-12-251-2/+25
| | | | | | | * 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
* parse.y: warn reference after method definitionnobu2014-12-141-0/+4
| | | | | | | | * 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
* parse.y: fix lex_state after tLABEL_ENDnobu2014-12-051-1/+1
| | | | | | | | * 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
* parse.y: preserve tSTRING_CONTENT resultsnobu2014-12-011-3/+6
| | | | | | | * 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
* parse.y: check single regexp onlynobu2014-12-011-4/+3
| | | | | | | | * 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
* parse.y: remove garbagenobu2014-12-011-1/+0
| | | | | | | * 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
* parse.y: enable encoding pragma in rippernobu2014-12-011-6/+6
| | | | | | | * 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
* use 0 for reservednobu2014-12-011-1/+1
| | | | | | | 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
* parse.y: fix a typonobu2014-11-301-1/+1
| | | | | | | * 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
* parse.y: fix invalid keyword argumentnobu2014-11-261-8/+28
| | | | | | | | * 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
* parse.y: replace with TOK_INTERNnobu2014-11-231-1/+1
| | | | | | | * 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
* parse.y: shrink parser_paramsnobu2014-11-191-20/+23
| | | | | | | * 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
* parse.y: regexp error in rippernobu2014-11-191-8/+61
| | | | | | | * 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
* parse.y: ripper_new_yylvalnobu2014-11-191-4/+18
| | | | | | | * 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
* parse.y: predefined IDnobu2014-11-191-3/+2
| | | | | | | * 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
* parse.y: append directly to delayed contentnobu2014-11-191-3/+13
| | | | | | | | * 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
* parse.y: fix literal symbol list node typenobu2014-11-181-1/+7
| | | | | | | * 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
* * rewrite method/block parameter fitting logic to optimizeko12014-11-021-9/+55
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* parse.y: separate error messagesnobu2014-11-011-1/+6
| | | | | | | * 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
* parse.y: invalid instance/class variable namesnobu2014-11-011-2/+6
| | | | | | | | * 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
* parse.y: reset current_arg after block varnobu2014-10-291-0/+2
| | | | | | | | * 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
* parse.y: warn iside a blocknobu2014-10-291-1/+6
| | | | | | | * 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
* parse.y: warn circular argument referencenobu2014-10-291-3/+24
| | | | | | | * 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
* parse.y: unused membernobu2014-10-291-6/+0
| | | | | | | * 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
* ripper/tools/generate.rb: shorten generated sourcenobu2014-10-271-0/+9
| | | | | | | | | * 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
* id.h.tmpl: ANDOP and OROPnobu2014-10-271-17/+7
| | | | | | * 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
* parse.y: optimize IDs in rippernobu2014-10-271-37/+38
| | | | | | | | | * 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
* parse.y: Ripper.sexp returns errornobu2014-10-261-1/+43
| | | | | | | * 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
* parse.y: fix fluent interface identifiernobu2014-10-241-0/+6
| | | | | | | | * 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