aboutsummaryrefslogtreecommitdiffstats
path: root/parse.y
Commit message (Collapse)AuthorAgeFilesLines
* * 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
* parse.y: indentnobu2014-10-241-5/+5
| | | | | | * parse.y (parser_yylex): adjust indent. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48125 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* parse.y: do not use disposed stringnobu2014-10-161-1/+4
| | | | | | | * 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
* parse.y: keep nodes linkingnobu2014-10-131-3/+3
| | | | | | | * 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
* parse.y: should not eliminate value nodesnobu2014-10-121-14/+15
| | | | | | | | * 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
* parse.y: remove duplicate keysnobu2014-10-111-7/+64
| | | | | | | * 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
* parse.y: precedence of duplicated keysnobu2014-10-111-1/+9
| | | | | | | | * 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
* parse.y: remove unused argumentnobu2014-10-041-3/+2
| | | | | | | * 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
* parse.y: separate ripper data typenobu2014-09-301-9/+18
| | | | | | | * 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
* parse.y: label cannot be followed by a modifiernobu2014-09-231-1/+1
| | | | | | | * 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
* * parse.y (parser_class_nest): unused variable after YARVnari2014-09-211-3/+0
| | | | | | merged (r11439). git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47674 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* parse.y: quoted ID keynobu2014-09-201-9/+38
| | | | | | | * 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
* parse.y: intern_cstrnobu2014-09-131-5/+5
| | | | | | | | * 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
* parse.y: fix warning messagenobu2014-09-061-7/+7
| | | | | | | | * 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
* parse.y: use rb_ary_tmp_new_fillnobu2014-08-271-5/+1
| | | | | | | * 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
* parser.y: warning with VALUE for rippernobu2014-08-141-3/+28
| | | | | | | * 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
* parse.y: preserve encodingsnobu2014-08-131-12/+11
| | | | | | | | * 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
* parse.y: fix invalid char in evalnobu2014-08-071-1/+1
| | | | | | | | * 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
* parse.y: preserve encodingnobu2014-08-061-1/+1
| | | | | | | * 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
* struct parse_params: trivial packingnormal2014-07-251-3/+3
| | | | | | | | | * 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
* introduce ZALLOC{,_N} to replace ALLOC{,_N}+MEMZERO usenormal2014-07-251-6/+3
| | | | | | | | | | | | | | | | | | | | 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
* parse.y: dynamic const assign_error in rippernobu2014-07-241-2/+6
| | | | | | | | * 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
* parse.y: move common codenobu2014-07-241-4/+2
| | | | | | * 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
* parse.y: remove garbagenobu2014-07-241-2/+0
| | | | | | * 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
* parse.y: separate from parse_identnobu2014-07-171-114/+108
| | | | | | | | | | | | * 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
* parse.y: parse_atmarknobu2014-07-171-17/+29
| | | | | | * 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
* parse.y: parse_identnobu2014-07-171-134/+141
| | | | | | * 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
* parse.y: parse_gvarnobu2014-07-171-85/+96
| | | | | | * parse.y (parse_gvar): extract from parser_yylex(). git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46847 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* parse.y: parse_percentnobu2014-07-171-91/+99
| | | | | | * parse.y (parse_percent): extract from parser_yylex(). git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46846 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* parse.y: parse_qmarknobu2014-07-171-78/+86
| | | | | | * parse.y (parse_qmark): extract from parser_yylex(). git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46845 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* parse.y: parse_rationalnobu2014-07-171-5/+12
| | | | | | * parse.y (parse_rational): extract from parse_numeric(). git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46844 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* parse.y: parse_numericnobu2014-07-171-239/+241
| | | | | | * parse.y (parse_numeric): extract from parser_yylex(). git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46842 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* parse.y: negate_litnobu2014-07-171-16/+15
| | | | | | * parse.y (negate_lit): alter only literal object itself, not NODE. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46841 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* parse.y: rename Init_parsernobu2014-07-111-1/+2
| | | | | | | * parse.y (rb_init_parse): rename to get rid of name clash with json/parser at statically linking. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46787 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* symbol.c, symbol.h: split from parse.ynobu2014-07-091-1148/+3
| | | | | | | * symbol.c, symbol.h: Symbol class implementation and internals, split from parse.y. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46768 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* parse.y: adjust argument typesnobu2014-07-091-2/+3
| | | | | | | * parse.y (symbols_i): adjust argument types for st_foreach() using st_data_t. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46767 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * parse.y: change Symbol <-> ID relationship to avoidko12014-07-091-96/+155
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | exposing IDs from collectable symbols. [Bug #10014] Now, rb_check_id() returns 0 if corresponding symbol is pinned dynamic symbol. There is remaining intern_cstr_without_pindown(), it can return IDs from collectable symbols. We must be careful to use it (only used in parse.y). I think it should be removed if it does not have impact for performance. * parse.y: add: * STATIC_SYM2ID() * STATIC_ID2SYM() rename: * rb_pin_dynamic_symbol() -> dsymbol_pindown() * internal.h: remove: * rb_check_id_without_pindown() * rb_sym2id_without_pindown() add: * rb_check_symbol() * rb_check_symbol_cstr() * load.c: use rb_check_id() or rb_check_id_cstr(). * object.c: ditto. * struct.c: ditto. * thread.c: ditto. * vm_method.c: ditto. * string.c (sym_find): use only rb_check_symbol(). * sprintf.c (rb_str_format): use rb_check_symbol_cstr(). git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46764 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * parse.y (symbols_i): delete garbage symbols for Symbol.all_symbols.ko12014-07-091-5/+11
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46763 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* parse.y: expand is_asgn_or_idnobu2014-07-081-7/+7
| | | | | | | * parse.y (new_op_assign_gen): expand is_asgn_or_id(), which call id_type() function multiple times now. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46754 b2dd03c8-39d4-4d8f-98ff-823fe69b080e