aboutsummaryrefslogtreecommitdiffstats
path: root/node.c
Commit message (Collapse)AuthorAgeFilesLines
...
* node.c: Fix typosyui-knk2018-05-101-2/+2
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63386 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* node.c: predicates for special NODEsnobu2018-03-201-4/+4
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62861 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Fix typos.hsbt2018-01-171-1/+1
| | | | | | | | * 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
* node.c: Separately allocate a struct having flexible arraymame2018-01-161-5/+5
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61876 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* nested flexible array member is a GCCismshyouhei2018-01-161-1/+1
| | | | | | | | 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
* node.c: Stop double meaning of NODE_FOR by introducing NODE_FOR_MASGNmame2018-01-161-0/+8
| | | | | | | | | 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
* node.c (node_buffer_elem_t): Use FLEX_ARY_LENmame2018-01-131-2/+2
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61805 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Rename code_range to code_locationmame2018-01-091-5/+5
| | | | | | | | | | | 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
* parse.y: Remove special handling of tOROP and tANDOPmame2018-01-091-15/+3
| | | | | | The complexity is no longer considered necessary. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61701 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* parse.y: Make consistent with the terms about code ranges and locationsmame2018-01-081-4/+4
| | | | | | | | | | | | | "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
* parse.y: Remove dispose_stringmame2018-01-081-11/+0
| | | | | | | 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
* node.c: show newline node marknobu2018-01-081-2/+5
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61678 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* node.c: fix SEGV of `->(a:){}` when --dump=parsetreemame2018-01-071-2/+7
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61655 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* node.c: factor out the part of operator output into F_OPERATORmame2018-01-051-21/+15
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61615 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* node.c: remove unused macro F_OPTIONmame2018-01-051-2/+0
| | | | | | Follow up of r61610 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61614 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* node.c (NODE_OP_CDECL): fix a typo bug.mame2018-01-051-1/+1
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61613 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* node.h: remove NODE_PRELUDEmame2018-01-051-44/+0
| | | | | | | | | | | 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
* node.h: define rb_ast_body_t and restructure rb_ast_tmame2018-01-051-1/+1
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61608 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* node.c: constify NODE* arguments in node.cmame2018-01-051-4/+4
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61607 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* node.h: add NODE_ONCE instead of reuse of NODE_SCOPEmame2018-01-041-0/+7
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61597 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* node.c: show variable type for NODE_*ASGNmame2017-12-151-13/+23
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61273 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* node.c (NODE_HASH): remove wrong default casemame2017-12-151-2/+1
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61272 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* node.c: add more comment to NODE_CASE2mame2017-12-151-1/+1
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61271 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* node.c: fix typosmame2017-12-151-3/+3
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61270 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* node.[ch], parse.y, compile.c: rename nd_column to nd_first_columnmame2017-12-141-1/+1
| | | | | | | | 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
* node.c: FIELD_BLOCKnobu2017-12-051-15/+12
| | | | | | | * 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
* node.c: a simple notation for code range of NODEsmame2017-12-051-1/+1
| | | | | | 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
* Refactoring out the direct accesses of NODE's u1, u2, and u3mame2017-11-161-6/+5
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60812 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* make funcs static.ko12017-11-161-3/+3
| | | | | | | | | * 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
* Print last location of a nodeyui-knk2017-11-131-1/+2
| | | | | | * 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
* Store last location of a node on RNodeyui-knk2017-11-131-2/+4
| | | | | | | | | | | | | | | | | | | * 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
* Make `rb_ast_dispose` use `RB_OBJ_WRITE`mame2017-11-101-5/+5
| | | | | | | | | 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
* node.c (dump_node): add an explanation of NODE_HASH's nd_alenmame2017-11-091-0/+7
| | | | | | | | 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
* Introduce `rb_code_location_t`mame2017-11-041-2/+3
| | | | | | | | `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
* Avoid usage of the magic number `(NODE*)-1`mame2017-11-041-6/+6
| | | | | | | | | | | | | 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
* Remove NODE-related pieces of code from GCmame2017-11-041-163/+7
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60640 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* node.c: Add some commentsyui-knk2017-11-031-2/+2
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60629 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* node.c: Fix possible alignment bugsyui-knk2017-11-031-2/+2
| | | | | | | | | * 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
* Use NODE_CASE2 if case expressions don't existyui-knk2017-10-311-0/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Store lineno on RNodeyui-knk2017-10-301-1/+1
| | | | | | | | | | | | | | | * 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
* * node.h (ast_t): renamed to `rb_ast_t`.ko12017-10-291-9/+9
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60565 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* node.c: removed duplicate node_buffer_t definitionnobu2017-10-271-2/+2
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60495 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Revert "Revert "Manage AST NODEs out of GC""mame2017-10-271-0/+104
| | | | | | | This re-introduces r60485. This reverts commit 5a176b75b1187cbd3861c387bde65ff66396a07c. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60488 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Revert "Manage AST NODEs out of GC"mame2017-10-271-104/+0
| | | | | | This reverts commit 620ba74778bfdbdc34ffbb142d49ce84a0ef58e9. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60486 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Manage AST NODEs out of GCmame2017-10-271-0/+104
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Removed NODE_OPT_Nnobu2017-10-241-6/+0
| | | | | | | | | * 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
* Remove dynamic NODE allocation out of parsermame2017-10-241-0/+12
| | | | | | | | 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
* Remove special handling for (NODE*)1mame2017-10-241-6/+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
* remove NODE_DREGX_ONCEnobu2017-10-221-6/+0
| | | | | | | * 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
* Remove not used node_type NODE_BMETHODyui-knk2017-10-221-1/+0
| | | | | | | | | * 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