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

118 Коммитов

Автор SHA1 Сообщение Дата
nobu 0d957a91ba Removed unreachable code
* node.c (rb_ast_dispose): since `ast->node_buffer` is freed in
  `rb_ast_free()`, it should be always NULL.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65031 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-10-12 12:54:21 +00:00
nobu d8104d73d1 Missing write-barrier
Fix up r64507.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65023 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-10-12 02:22:55 +00:00
marcandre 2b3982ad1c node.c: Typo fix. Patch by Shuichi Tamayose. [ci skip] [Fix GH-1880]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64758 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-09-16 03:24:15 +00:00
mame 52bd0d1900 node.h (rb_ast_t): move its field mark_ary to node_buffer_t
I want to add a new field to rb_ast_t whose size is restricted because
it is an imemo.  This change makes one room in rb_ast_t.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64507 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-08-22 10:38:55 +00:00
nobu 7c9fa8f9bb Use nd_X shorthand for annotation
[Fix GH-1901]

From: hkdnet <satoko.itse@gmail.com>

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63780 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-06-28 13:22:13 +00:00
yui-knk da9bd7a460 node.c: Fix format of NODE_OP_ASGN1 and NODE_OP_ASGN2
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63605 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-06-07 23:18:16 +00:00
yui-knk bd97ca443f node.c: Fix format and example of NODE_OPCALL
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63393 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-05-10 09:49:55 +00:00
yui-knk 59a571d14c node.c: Fix typos
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63386 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-05-10 00:23:23 +00:00
nobu b4b3de3e7c node.c: predicates for special NODEs
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62861 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-03-20 13:30:57 +00:00
hsbt 9869ec7a7d Fix typos.
* node.c: strucutre -> structure
 * random.c: acquried -> acquired
 * thread.c: accross -> across

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61889 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-17 13:15:13 +00:00
mame 5fd143c141 node.c: Separately allocate a struct having flexible array
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61876 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-16 15:12:09 +00:00
shyouhei 96268c1dbd nested flexible array member is a GCCism
This is NG. The ISO C section 6.7.2.1 explicitly states that
structs having flexible array members "shall not be a member
of a structure or an element of an array."

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61875 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-16 09:21:07 +00:00
mame 4b6f3bce25 node.c: Stop double meaning of NODE_FOR by introducing NODE_FOR_MASGN
NODE_FOR was used both for "for"-statement itself and for
multi-assignment of for-statement (for x, y, in...end).
This change separates the two purposes, NODE_FOR for the former, and
newly introduced NODE_FOR_MASGN for the latter.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61871 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-16 07:24:53 +00:00
mame 2768bae806 node.c (node_buffer_elem_t): Use FLEX_ARY_LEN
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61805 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-13 12:09:24 +00:00
mame 4928900814 Rename code_range to code_location
Because the name "code_range" is ambiguous with encoding's.
Abbreviations ("crange", and "cr") are also renamed to "loc".

The traditional "code_location" (a pair of lineno and column) is
renamed to "code_position".  Abbreviations are also renamed
(first_loc to beg_pos, and last_loc to end_pos).

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61721 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-09 08:45:35 +00:00
mame da4067bab8 parse.y: Remove special handling of tOROP and tANDOP
The complexity is no longer considered necessary.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61701 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-09 01:49:40 +00:00
mame 52057336b7 parse.y: Make consistent with the terms about code ranges and locations
"loc" was ambiguous; it might refer both a location and a code range.
This change uses "loc" for a location, and "crange" or "cr" for a code
range.

A location (abbr. loc) is a point in a program and consists of line
number and column number.  A code range (abbr. crange and cr) is a range
within a program and consists of a pair of locations which is the first
and the last.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61690 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-08 12:56:58 +00:00
mame ec01271cae parse.y: Remove dispose_string
I think that recycling the delimiter string objects doesn't pay its
complexity.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61682 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-08 09:39:01 +00:00
nobu 39c7700d13 node.c: show newline node mark
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61678 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-08 06:55:12 +00:00
mame 933a3eb07e node.c: fix SEGV of `->(a:){}` when --dump=parsetree
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61655 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-07 12:55:10 +00:00
mame d3cea2edeb node.c: factor out the part of operator output into F_OPERATOR
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61615 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-05 11:39:27 +00:00
mame 80e45b047c node.c: remove unused macro F_OPTION
Follow up of r61610

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61614 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-05 11:39:25 +00:00
mame fee54c824d node.c (NODE_OP_CDECL): fix a typo bug.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61613 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-05 10:46:24 +00:00
mame 38c62063c0 node.h: remove NODE_PRELUDE
NODE_PRELUDE contains a `BEGIN` node, a main node, and compile_option.
This node is assumed that it must be located immediately under the root
NODE_SCOPE, but this strange assumption is not so good, IMO.

This change removes the assumtion; it integrates the former two nodes by
block_append, and moves compile_option into rb_ast_body_t.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61610 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-05 08:59:23 +00:00
mame 503b858cef node.h: define rb_ast_body_t and restructure rb_ast_t
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61608 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-05 08:59:20 +00:00
mame a6794c4b01 node.c: constify NODE* arguments in node.c
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61607 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-05 07:47:51 +00:00
mame 0947c2ba63 node.h: add NODE_ONCE instead of reuse of NODE_SCOPE
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61597 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-04 12:47:22 +00:00
mame 57b0489cdb node.c: show variable type for NODE_*ASGN
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61273 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-15 05:55:11 +00:00
mame 641870746f node.c (NODE_HASH): remove wrong default case
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61272 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-15 05:55:10 +00:00
mame d11fbf43c2 node.c: add more comment to NODE_CASE2
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61271 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-15 05:55:09 +00:00
mame 30930ba050 node.c: fix typos
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61270 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-15 05:55:08 +00:00
mame ad12b5c285 node.[ch], parse.y, compile.c: rename nd_column to nd_first_column
nd_set_column -> nd_first_set_column
nd_lineno -> nd_first_lineno
nd_set_lineno -> nd_first_set_lineno

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61224 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-14 06:02:26 +00:00
nobu 2d592329e0 node.c: FIELD_BLOCK
* node.c (COMPOUND_FIELD, FIELD_BLOCK): moved block outside
  arguments like as SIMPLE_FIELD.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61024 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-05 08:50:14 +00:00
mame aa87ae7a04 node.c: a simple notation for code range of NODEs
This affects only `--dump=parsetree` and `--dump=parsetree_with_comment`.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61022 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-05 04:23:06 +00:00
mame ec3a906bb6 Refactoring out the direct accesses of NODE's u1, u2, and u3
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60812 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-11-16 11:03:37 +00:00
ko1 8798822564 make funcs static.
* node.c: make them static:
  * rb_node_buffer_new
  * rb_node_buffer_free


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60806 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-11-16 08:19:46 +00:00
yui-knk 8020a87df0 Print last location of a node
* node.c (A_NODE_HEADER): Print last location of a node.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60752 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-11-13 01:24:16 +00:00
yui-knk 1ef7b0cd5a Store last location of a node on RNode
* node.c (rb_node_init): Initialize last location with 0.

* node.h (struct rb_code_range_struct): Define a structure
  which contains first location and last location of a node.
* node.h (struct RNode): Use rb_code_range_t to store last
  location of a node.
* node.h (nd_column, nd_set_column, nd_lineno, nd_set_lineno):
  Follow-up the change of struct RNode.
* node.h (nd_last_column, nd_set_last_column, nd_last_lineno, nd_set_last_lineno):
  Define getter/setter macros for last location of RNode.

* parse.y : Set last location of tokens.

Thanks to Yusuke Endoh (mame) for design of data structures.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60750 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-11-13 00:14:33 +00:00
mame 139eb4e862 Make `rb_ast_dispose` use `RB_OBJ_WRITE`
This fixes the mistake of r60722.
I used `rb_gc_writebarrier_remember` to notify to GC that the references
is changed.  But the function just adds the object to the remember set
blindly.  Ko1 told me that `RB_OBJ_WRITE` is suitable in this case.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60737 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-11-10 13:46:38 +00:00
mame 2b60e342bd node.c (dump_node): add an explanation of NODE_HASH's nd_alen
The field has a flag to represent if it is a keyword argument (that has
no braces, e.g., `foo(k:1)`) or hash literal (that has braces, e.g.,
`foo({k:1})`).

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60723 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-11-09 01:50:58 +00:00
mame 0ee24acb5a Introduce `rb_code_location_t`
`rb_code_location_t` has two integers, lineno and column, which point to
one location on a code.  Now `rb_code_location_t` is used instead of
`VALUE nd_location`.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60652 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-11-04 15:22:18 +00:00
mame af9b0da125 Avoid usage of the magic number `(NODE*)-1`
This magic number has two meanings depending upon the context:

* "required keyword argument (no name)" on NODE_LASGN (`def foo(x:)`)
* "rest argument (no name)" on NODE_MASGN and NODE_POSTARG
  ('a, b, * = ary` or `a, b, *, z = ary`)

To show this intention explicitly, two macros are introduced:
NODE_SPECIAL_REQUIRED_KEYWORD and NODE_SPECIAL_NO_NAME_REST.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60650 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-11-04 14:24:16 +00:00
mame deb5693149 Remove NODE-related pieces of code from GC
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60640 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-11-04 10:02:43 +00:00
yui-knk 1f67ebd5a7 node.c: Add some comments
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60629 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-11-03 03:49:07 +00:00
yui-knk f7fb086789 node.c: Fix possible alignment bugs
* node.c (rb_node_buffer_new): Use offsetof for
  node_buffer_t size calculation.
* node.c (rb_ast_newnode): Use offsetof for
  node_buffer_elem_t size calculation.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60628 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-11-03 03:22:23 +00:00
yui-knk a09e175068 Use NODE_CASE2 if case expressions don't exist
When NODE_WHEN is compiled by iseq_compile_each0,
the node passed to compile_when is NODE_WHEN (not NODE_CASE).
So we can not handle the location of NODE_CASE of
case statements which don't have case expressions.

e.g. :

```
case; when 1; foo; when 2; bar; else baz; end
```

This commit adds NODE_CASE2, and compiles it by
iseq_compile_each0.

* compile.c (compile_case): Does not call COMPILE_ when
  NODE_CASE does not have case expressions.
* compile.c (compile_case2): Compile NODE_CASE2 by compile_case2.
* compile.c (compile_when): Delete an obsoleted function.
* compile.c (iseq_compile_each0): Compile NODE_CASE2.

* ext/objspace/objspace.c (count_nodes): Add NODE_CASE2 case.

* node.c (dump_node, rb_gc_mark_node): Add NODE_CASE2 case.

* node.h (node_type): Add NODE_CASE2.
* node.h (NEW_CASE2): Add a macro which generates NODE_CASE2.

* parse.y: Generate NODE_CASE2 if case expressions don't exist.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60585 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-31 00:46:30 +00:00
yui-knk 7a42b03b0c Store lineno on RNode
* node.c (A_NODE_HEADER): Print lineno.

* node.h (nd_column, nd_set_column): Store column
  number with 16-bit.
* node.h (nd_lineno, nd_set_lineno): Define
  getter/setter macros for lineno of RNode.

* parse.y : Set first lineno of tokens.

Thanks to takeshinoda for review.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60580 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-30 13:36:20 +00:00
ko1 85fcaf025d * node.h (ast_t): renamed to `rb_ast_t`.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60565 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-29 15:51:23 +00:00
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