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

170 Коммитов

Автор SHA1 Сообщение Дата
nobu c3bbc2ffd5 node.c: removed duplicate node_buffer_t definition
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60495 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-27 21:08:37 +00:00
mame e35fe8d11b Revert "Revert "Manage AST NODEs out of GC""
This re-introduces r60485.
This reverts commit 5a176b75b1.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60488 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-27 16:44:57 +00:00
mame 5a176b75b1 Revert "Manage AST NODEs out of GC"
This reverts commit 620ba74778.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60486 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-27 16:02:34 +00:00
mame 620ba74778 Manage AST NODEs out of GC
NODEs in AST are no longer objects managed by GC.  This change will
remove the restriction imposed by the GC.  For example, a NODE can use
more than five words (this is my primary purpose; we want to store the
position data for each NODE, for coverage library), or even a NODE can
have variable length (some kinds of NODEs have unused fields).
To do this, however, we need more work, since Ripper still uses T_NODE
objects managed by the GC.

The life time of NODEs is more obvious than other kinds of objects; they
are created at parsing, and they become disused immediately after
compilation.  This change releases all NODEs by a few `xfree`s after
compilation, so performance will be improved a bit.  In extreme example,
`eval("x=1;" * 10000000)` runs much faster (40 sec. -> 7.8 sec. on my
machine).

The most important part of this change is `ast_t` struct, which has
three contents: (1) NODE buffer (malloc'ed memory), (2) a reference to
the root NODE, and (3) an array that contains objects that must be
marked during parsing (such as literal objects).  Some functions that
had received `NODE*` arguments, must now receive `ast_t*`.

* node.c, node.h: defines `ast_t` struct and related operations.
* gc.c, internal.h: defines `imemo_ast`.
* parse.y: makes `parser_params` struct have a reference to `ast_t`.
  Instead of `rb_node_newnode`, use `rb_ast_newnode` to create a NODE.
* iseq.c, load.c, ruby.c, template/prelude.c.tmpl: modifies some
  functions to handle `ast_t*` instead of `NODE*`.
* test/ruby/test_gc.rb: ad-hoc fix for a failed test.  The test assumes
  GC eden is increased at startup by NODE object creation.  However,
  this change now create no NODE object, so GC eden is not necessarily
  increased.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60485 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-27 15:59:02 +00:00
nobu 2c786bf35d Removed NODE_OPT_N
* node.h (NODE_OPT_N): removed.

* parse.y (parser_append_options): expand -n option loop to while
  gets loop.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60394 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-24 08:00:36 +00:00
mame ac3bad418c Remove dynamic NODE allocation out of parser
A temporary NODE object was allocated to create iseq.  Instead, this
patch allocates a dummy NODE as auto variable, and discard it soon.
This change is intended as a preparation to manage AST NODEs out of GC.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60390 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-24 06:16:31 +00:00
mame f70aa7637b Remove special handling for (NODE*)1
The magic number was used to mark NODE_ATTRASGN when its receiver is
self.  But the hack was refactored at r46366.  So the remaining code
fragments are no longer needed.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60389 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-24 05:54:30 +00:00
nobu 1528a9859c remove NODE_DREGX_ONCE
* node.h (enum node_type): remove NODE_DREGX_ONCE which is not
  used anymore.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60347 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-22 05:13:57 +00:00
yui-knk 25a7dfc6d7 Remove not used node_type NODE_BMETHOD
* ext/objspace/objspace.c (count_nodes): This node_type has
  not been used since r24128.
* node.c (dump_node): ditto
* node.h (node_type, NEW_BMETHOD): ditto

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60336 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-22 00:45:05 +00:00
yui-knk fdc5864090 Remove not used node_type NODE_BLOCK_ARG
* ext/objspace/objspace.c (count_nodes): This node_type has
  not been used since r11840.
* node.c (dump_node, rb_gc_mark_node): ditto
* node.h (node_type, NEW_BLOCK_ARG): ditto

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60334 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-22 00:29:40 +00:00
yui-knk f36ee4406e Remove not used node_type NODE_TO_ARY
* ext/objspace/objspace.c (count_nodes): This node_type has
  not been used since r13236.
* node.c (dump_node, rb_gc_mark_node): ditto
* node.h (node_type, NEW_TO_ARY): ditto

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60332 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-22 00:17:39 +00:00
yui-knk d98db55b73 Remove not used node_type NODE_CVDECL
* compile.c (defined_expr0): This node_type has
  not been used since r11614.
* ext/objspace/objspace.c (count_nodes): ditto
* node.c (dump_node): ditto
* node.h (node_type, NEW_CVDECL): ditto

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60307 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-21 16:09:51 +00:00
yui-knk 92746378ab Remove not used node_type NODE_IASGN2
* compile.c (compile_massign_opt, iseq_compile_each0): This
  node_type has not been used since r11813.
* ext/objspace/objspace.c (count_nodes): ditto
* node.c (dump_node, rb_gc_mark_node): ditto
* node.h (node_type, NEW_IASGN2): ditto
* parse.y (node_assign_gen): ditto

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60302 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-21 15:56:03 +00:00
mame ccfe37884a Replace NODE_ALLOCA with T_IMEMO (imemo_alloc)
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60239 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-21 08:40:28 +00:00
yui-knk 6d4b557811 Store token first column number on RNode
* node.c (A_NODE_HEADER): Print column number.
* node.h (nd_column, nd_set_column): Define getter/setter
  macros for column number of RNode.
* parse.y: Set first column number of tokens.

Notes:

* Use `@n` to get the location of token in parse.y.
* When we use `@n`, arguments of yyerror and yylex are
  changed.
* Initialize column of nodes with -1 to make it easy
  to detect nodes which we forget to set a column number.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60220 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-20 16:22:22 +00:00
nobu ecf61fa5b0 node.c: all node types
* node.c (dump_node): moved rb_bug for unknown node outside to let
  unhandled node types be warned.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60202 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-17 12:30:12 +00:00
nobu 4e01c50774 node.c: adjust indent
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60201 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-17 12:30:11 +00:00
mame c5fd4cd732 Improve some annotation names of output of parsetree-with-comment
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60197 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-17 11:38:16 +00:00
yui-knk 0c8292cb1b node.c: Add NODE_OP_CDECL to dump node list.
* node.c (dump_node): Add NODE_OP_CDECL to dump node list.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60196 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-17 11:13:53 +00:00
mame 3c8c17d30d Introduce NODE_UNLESS for branch coverage
`unless` statement was a syntactic sugar for `if` statement,
which made the result of branch coverage hard to understand.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59889 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-09-14 05:27:02 +00:00
nobu 03a2862b98 separate hash literal and keyword arguments
* compile.c (compile_array_keyword_arg): separate keyword splat
  inside hash literal from argument list.

* parse.y (rparen): flag hash literal.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59572 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-08-11 01:27:24 +00:00
nobu af4ba5c12a parse.y: should not warn op method call
* parse.y (void_expr_gen): should warn operator expression style
  calls only, but not method style calls.  [Fix GH-1660]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59162 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-06-23 11:56:48 +00:00
nobu fd1462576c no mark of u3 in NODE_BLOCK_PASS
* node.c (rb_gc_mark_node): u3 in NODE_BLOCK_PASS is not used and
  does not need to be marked.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58283 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-04-09 02:06:45 +00:00
nobu 6d3654d59b fix nd_ainfo->kw_rest_arg
[Fix GH-5129]
Author:    fate0 <fate0@users.noreply.github.com>

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57734 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-02-27 13:52:08 +00:00
nobu 5c5d894474 node.c: fix NODE_OP_ASGN1
* node.c (dump_node): fix a typo, index and rvalue.  fix
  NODE_OP_ASGN1 operator to nd_mid.  [Fix GH-1528]

Author:    fate0 <fate0@users.noreply.github.com>

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57718 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-02-26 09:33:17 +00:00
ko1 470564331d remove warning about enum and int comparison.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57575 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-02-08 03:59:53 +00:00
nobu d1b386a224 node.c: compress logop sequence
* node.c (dump_node): compress sequence of same logical binary
  operators, NODE_AND/NODE_OR.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57573 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-02-08 01:18:56 +00:00
yui-knk 48d61170a2 node.c: Fix a typo
* node.c (dump_node): Fix a typo of || operator example

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57540 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-02-05 14:16:52 +00:00
nobu e3e17eb975 node.c: flatten NODE_BLOCK [ci skip]
* node.c (dump_node): flatten statements in NODE_BLOCK.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56348 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-10-05 06:43:34 +00:00
ktsj dd3ccb8b50 * node.c (dump_array): remove duplicate header of NODE_ARRAY/
NODE_VALUES.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56235 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-09-25 10:23:33 +00:00
nobu 86006209cd node.c: nd_alen only in the head
* node.c (dump_array): show nd_alen field in NODE_ARRAY only in
  the first node.  it is nd_end in the rest nodes.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55901 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-08-15 11:31:36 +00:00
nobu 90c543e483 node.c: mark u3 of NODE_MATCH2
* node.c (rb_gc_mark_node): NODE_MATCH2 can have nd_args, u3,
  since r54100.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54209 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-03-21 09:55:50 +00:00
nobu ea5e885a95 optimize named capture assignment
* compile.c (compile_named_capture_assign): optimize named capture
  assignments, by replacing repeating global variable accesses
  with `dup`, and by returning the matched result instead of
  re-getting it from the MatchData.

* parse.y (reg_named_capture_assign_gen): build just assignment
  nodes for the optimization.

ex. `/(?<x>.)/ =~ "bar"`

- old
  ```
  0000 putstring        "bar"
  0002 opt_regexpmatch1 /(?<x>.)/
  0004 pop
  0005 getglobal        $~
  0007 branchunless     25
  0009 getglobal        $~
  0011 putobject        :x
  0013 opt_aref         <callinfo!mid:[], argc:1, ARGS_SIMPLE>
  0016 setlocal_OP__WC__0 2
  0018 getglobal        $~
  0020 putobject_OP_INT2FIX_O_0_C_
  0021 opt_send_without_block <callinfo!mid:begin, argc:1, ARGS_SIMPLE>
  0024 leave
  0025 putobject        nil
  0027 setlocal_OP__WC__0 2
  0029 putobject        nil
  0031 leave
  ```

- new
  ```
  0000 putstring        "bar"
  0002 opt_regexpmatch1 /(?<x>.)/
  0004 getglobal        $~
  0006 dup
  0007 branchunless     14
  0009 putobject        :x
  0011 opt_aref         <callinfo!mid:[], argc:1, ARGS_SIMPLE>
  0014 setlocal_OP__WC__0 2
  0016 leave
  ```

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54100 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-03-14 07:53:39 +00:00
nobu 2d39d11436 node.c: no nd_compile_option unless set
* node.c (dump_node): show nd_compile_option only when it is set.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54080 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-03-10 07:27:41 +00:00
nobu 72b3e226fc node.c: stringize before expansion
* node.c (F_NODE, F_OPTION): stringize member names defined as
  macros before expansion.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54079 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-03-10 07:27:40 +00:00
nobu a944bdd5fa node.c: hidden options hash
* node.c (dump_option): nd_compile_option is a hidden hash object,
  cannot call inspect on it.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54077 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-03-10 06:19:55 +00:00
nobu 613737eee9 node.c: NODE_QCALL
* node.c (dump_node): dump NODE_QCALL.  [Feature #11537]
  http://twitter.com/watson1978/status/673042429931446272

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

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52214 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-10-22 06:30:12 +00:00
nobu 18e4a39c9a node.c: update comment
* node.c (dump_node): update comment for OP_ASGN2 and fix unused
  field.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52116 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-10-12 03:39:23 +00:00
nobu 14e606ae53 node.c: no attrset ID in NODE
* node.c (dump_node): attrset ID is no longer in NODE_OP_ASGN2.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52114 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-10-12 03:03:36 +00:00
nobu d8d51b6708 node.c: fix comments [ci skip]
* node.c (dump_node): fix comments of dynamic string literals,
  nd_next->nd_head is the interpolation but not a literal string.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52091 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-10-09 06:44:22 +00:00
nobu 25a8b98e3a node.c: reduce size
* node.c (A_FIELD_HEADER): reduce text size by sharing messages
  with and without comments.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52081 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-10-08 01:45:41 +00:00
nobu 29d88e4592 node.c: move block
* node.c (SIMPLE_FIELD): move block after macro call.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52080 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-10-08 01:45:00 +00:00
nobu 4334bb87f9 node.c: D_FIELD_HEADER
* node.c (D_FIELD_HEADER): concatenate sequential strings.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52078 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-10-08 01:44:51 +00:00
nobu 77ac4a50f1 node.c: indent [ci skip
* node.c (dump_node): adjust indent.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52077 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-10-08 01:44:37 +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 95c84eac49 gc.c: move tmp buffer functions
* gc.c (rb_alloc_tmp_buffer, rb_free_tmp_buffer): move from
  node.c.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51500 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-08-06 01:56:37 +00:00
nobu 8b6a0f7325 node.c: check size
* node.c (rb_alloc_tmp_buffer): round up the size and check the
  range.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51499 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-08-06 01:50:00 +00:00
nobu ec10c033a7 ruby_atomic.h: atomic VALUE operations
* ruby_atomic.h (ATOMIC_VALUE_EXCHANGE, ATOMIC_VALUE_CAS): add
  atomic operations for VALUE.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51498 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-08-06 01:44:03 +00:00
nobu fb25833690 node.c: NODE_ALLOCA for ALLOCV
* node.c (rb_alloc_tmp_buffer): use NODE_ALLOCA to mark locations
  like as builtin alloca.  [ruby-core:70251] [Bug #11418]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51492 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-08-05 17:25:35 +00:00
ko1 ac28b985bd * vm_insnhelper.c: use T_IMEMO to create SVAR.
* internal.h, vm_insnhelper.h: move definition `struct SVAR'
  from vm_insnhelper.h to internal.h. And rename it to strcut vm_svar.
  new imemo_type imemo_svar is added.
* gc.c (gc_mark_children): mark imemo_svar.
* node.c (rb_gc_mark_node): remove useless marking.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49935 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-03-11 12:27:34 +00:00
ko1 0952b43b9b * include/ruby/ruby.h: introduce new type T_IMEMO.
T_IMEMO is Internal Memo type, internal use only.
  T_IMEMO has same purpose of NODE_MEMO.
  To insert T_IMEMO, type numbers are modified a little.
* internal.h: define struct RIMemo. Each RIMemo objects
  has imemo_type. We can observe it by the imemo_type() function.
* gc.c (rb_imemo_new): added.
* node.h: remove NODE_CREF and NEW_CREF().
* node.c (rb_gc_mark_node): ditto.
* vm.c (vm_cref_new): use rb_imem_new().
* vm_eval.c: ditto.
* vm_eval.c (eval_string_with_cref):
* vm_eval.c (rb_type_str):
* vm_insnhelper.c: use RIMemo objects for CREF.
* ext/objspace/objspace.c: support T_IMEMO.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49932 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-03-11 10:36:17 +00:00
ko1 8dced4d2c0 * internal.h: define rb_cref_t and change to use it.
rb_cref_t is data type of CREF. Now, the body is still NODE.
  It is easy to understand what is CREF and what is pure NODE.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49897 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-03-08 21:22:43 +00:00
ko1 ae166317a4 * internal.h: define CREF accessor macros.
* CREF_CLASS(cref)
  * CREF_NEXT(cref)
  * CREF_VISI(cref)
  * CREF_VISI_SET(cref, v)
  * CREF_REFINEMENTS(cref)
  * CREF_PUSHED_BY_EVAL(cref)
  * CREF_PUSHED_BY_EVAL_SET(cref)
  * CREF_OMOD_SHARED(cref)
  * CREF_OMOD_SHARED_SET(cref)
  * CREF_OMOD_SHARED_UNSET(cref)
  This is process to change CREF data type from NODE.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49894 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-03-08 19:50:37 +00:00
ko1 d84f9b1694 * fix namespace issue on singleton class expressions. [Bug #10943]
* vm_core.h, method.h: remove rb_iseq_t::cref_stack. CREF is stored
  to rb_method_definition_t::body.iseq_body.cref.
* vm_insnhelper.c: modify SVAR usage.
  When calling ISEQ type method, push CREF information onto method
  frame, SVAR located place. Before this fix, SVAR is simply nil.
  After this patch, CREF (or NULL == Qfalse for not iseq methods)
  is stored at the method invocation.
  When SVAR is requierd, then put NODE_IF onto SVAR location,
  and NDOE_IF::nd_reserved points CREF itself.
* vm.c (vm_cref_new, vm_cref_dump, vm_cref_new_toplevel): added.
* vm_insnhelper.c (vm_push_frame): accept CREF.
* method.h, vm_method.c (rb_add_method_iseq): added. This function
  accepts iseq and CREF.
* class.c (clone_method): use rb_add_method_iseq().
* gc.c (mark_method_entry): mark method_entry::body.iseq_body.cref.
* iseq.c: remove CREF related codes.
* insns.def (getinlinecache/setinlinecache): CREF should be cache key
  because a different CREF has a different namespace.
* node.c (rb_gc_mark_node): mark NODE_IF::nd_reserved for SVAR.
* proc.c: catch up changes.
* struct.c: ditto.
* insns.def: ditto.
* vm_args.c (raise_argument_error): ditto.
* vm_eval.c: ditto.
* test/ruby/test_class.rb: add a test.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49874 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-03-06 12:24:58 +00:00
nari a5c91a3811 * st.c (numberof): unused. internal.h has same macro.
* node.c (F_CUSTOM2): unused.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47673 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-09-21 09:22:42 +00:00
nobu a669514e63 node.h: extract NODE functions from gc.c
* node.h (rb_gc_free_node, rb_node_memsize, rb_gc_mark_node):
  extract functions for NODE from obj_free(), obj_memsize_of(),
  gc_mark_children() in gc.c.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47197 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-08-16 01:53:10 +00:00
charliesome d3a54f6fe8 Fix --dump=parsetree segfault on required keyword argument
* node.c (dump_node): handle nd_value == (NODE *)-1 to mean this
  keyword argument is required

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46649 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-07-01 18:21:22 +00:00
nobu ef9408d8dd node.c: indent
* node.c (dump_node): adjust indent to "ruby-style.el".

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45718 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-04-25 07:12:58 +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
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 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 e98c84519f * node.c (dump_node): add today's knowledge. "init arguments (m)" and
"init arguments (p)" of compile.c indicates a Ruby code that
  evaluates multiple assignments that is in method or block
  parameters:  def foo((m1,m2), (m3,m4), *r, (p1,p2), (p3,p4)); end
  The former (init arguments (m)) evaluates the multiple assignments
  before rest argument, that are (m1,m2) and (m3,m4).  The letter
  (init arguments (p)) does ones after rest argument, that are
  (p1,p2) and (p3, p4).

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32596 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-07-21 10:35:52 +00:00
nagachika 6b06ba0c05 * node.c (add_id): remove duplicated rb_id2str() call.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30746 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-01-31 14:29:49 +00:00
akr 8f6c729601 * node.c: parenthesize macro arguments.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30270 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-12-20 14:13:12 +00:00
nobu df54a2e6be * cont.c (fiber_set_stack_location), iseq.c (prepare_iseq_build),
node.c (dump_node): suppress warnings.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@27808 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-05-16 02:46:16 +00:00
nobu 7cd9a5d363 * node.c (dump_node): fixed for long members.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@26054 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-12-09 15:46:45 +00:00
mame 38828fa8d1 * node.c: node management added. Currently, only pretty-dumper is
implemented.  [ruby-dev:39853]

* ruby.c: --dump=parsetree and --dump=parsetree_with_comment options
  added.  This is just for debug or research purpose.  Note that the
  compatibility of these options are not supported at all.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@26053 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-12-09 14:05:59 +00:00