summaryrefslogtreecommitdiff
path: root/ast.c
AgeCommit message (Collapse)Author
2021-09-18ast.c: AST.of against C method should return nil (as Ruby 2.6--3.0)Yusuke Endoh
2021-09-18ast.c: AST.of checks if a given method object is defined in CYusuke Endoh
[Bug #18178]
2021-09-05Replace RBOOL macroS-H-GAMELINKS
Notes: Merged: https://github.com/ruby/ruby/pull/4791
2021-08-20ast.c: Rename "save_script_lines" to "keep_script_lines"Yusuke Endoh
... as per ko1's preference. He is preparing to extend this feature to ISeq for his new debugger. He prefers "keep" to "save" for this wording. This API is internal and not included in any released version, so I change it in advance.
2021-07-29Make RubyVM::AbstractSyntaxTree.of raise for method/proc created in evalJeremy Evans
This changes Thread::Location::Backtrace#absolute_path to return nil for methods/procs defined in eval. If the realpath of an iseq is nil, that indicates it was defined in eval, in which case you cannot use RubyVM::AbstractSyntaxTree.of. Fixes [Bug #16983] Co-authored-by: Koichi Sasada <ko1@atdot.net> Notes: Merged: https://github.com/ruby/ruby/pull/4519
2021-06-21Experimentally expose RubyVM::AST::Node#node_idYusuke Endoh
Now ISeq#to_a includes the node_id list for each bytecode instruction. I want a way to retrieve the AST::Node instance corresponding to an instruction for a research purpose including TypeProf-based LSP server.
2021-06-18Enable USE_ISEQ_NODE_ID by defaultYusuke Endoh
... which is formally called EXPERIMENTAL_ISEQ_NODE_ID. See also ff69ef27b06eed1ba750e7d9cab8322f351ed245. https://bugs.ruby-lang.org/issues/17930 Notes: Merged: https://github.com/ruby/ruby/pull/4558
2021-06-18Make it possible to get AST::Node from Thread::Backtrace::LocationYusuke Endoh
RubyVM::AST.of(Thread::Backtrace::Location) returns a node that corresponds to the location. Typically, the node is a method call, but not always. This change also includes iseq's dump/load support of node_ids for each instructions. Notes: Merged: https://github.com/ruby/ruby/pull/4558
2021-06-18node.h: Reduce struct size to fit with Ruby object size (five VALUEs)Yusuke Endoh
by merging `rb_ast_body_t#line_count` and `#script_lines`. Fortunately `line_count == RARRAY_LEN(script_lines)` was always satisfied. When script_lines is saved, it has an array of lines, and when not saved, it has a Fixnum that represents the old line_count. Notes: Merged: https://github.com/ruby/ruby/pull/4581
2021-06-18ast.rb: RubyVM::AST.parse and .of accepts `save_script_lines: true`Yusuke Endoh
This option makes the parser keep the original source as an array of the original code lines. This feature exploits the mechanism of `SCRIPT_LINES__` but records only the specified code that is passed to RubyVM::AST.of or .parse, instead of recording all parsed program texts. Notes: Merged: https://github.com/ruby/ruby/pull/4581
2021-05-07compile.c: Pass node instead of nd_line(node) to ADD_INSN* functionsYusuke Endoh
... then, new_insn_core extracts nd_line(node). Also, if a macro "EXPERIMENTAL_ISEQ_NODE_ID" is defined, this changeset keeps nd_node_id(node) for each instruction. This is intended for TypeProf to identify what AST::Node corresponds to each instruction. This patch is originally authored by @yui-knk for showing which column a NoMethodError occurred. https://github.com/ruby/ruby/compare/master...yui-knk:feature/node_id Co-Authored-By: Yuichiro Kaneko <yui-knk@ruby-lang.org> Notes: Merged: https://github.com/ruby/ruby/pull/4470
2021-03-20Remove unused rb_ast_parse_array declarationS.H
Notes: Merged: https://github.com/ruby/ruby/pull/4270 Merged-By: nobu <nobu@ruby-lang.org>
2020-09-30Unfreeze string-literal-only interpolated string-literalNobuyoshi Nakada
[Feature #17104]
2020-07-08Hoisted out functions for no name rest argument symbolNobuyoshi Nakada
2020-07-08Constified NODE pointer in ASTNodeDataNobuyoshi Nakada
2020-07-08Added `NODE_SPECIAL_EXCESSIVE_COMMA` info to `ARGS` of ↵manga_osyo
`RubyVM::AbstractSyntaxTree`. Notes: Merged: https://github.com/ruby/ruby/pull/3298
2020-07-06Add operator info to `OP_ASGN2` of `RubyVM::AbstractSyntaxTree`.manga_osyo
Notes: Merged: https://github.com/ruby/ruby/pull/3294
2020-06-29node_children: do not goto into a branch卜部昌平
Was this an autogenerated function? This tendency of avoiding empty branches are no longer preserved (see for instance NODE_IVAR). Let's just delete those unnecessary jumps into branches. Notes: Merged: https://github.com/ruby/ruby/pull/3247
2020-06-14Introduce find pattern [Feature #16828]Kazuki Tsujimoto
2019-12-29Separate builtin initialization callsNobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/2792
2019-12-26decouple internal.h headers卜部昌平
Saves comitters' daily life by avoid #include-ing everything from internal.h to make each file do so instead. This would significantly speed up incremental builds. We take the following inclusion order in this changeset: 1. "ruby/config.h", where _GNU_SOURCE is defined (must be the very first thing among everything). 2. RUBY_EXTCONF_H if any. 3. Standard C headers, sorted alphabetically. 4. Other system headers, maybe guarded by #ifdef 5. Everything else, sorted alphabetically. Exceptions are those win32-related headers, which tend not be self- containing (headers have inclusion order dependencies). Notes: Merged: https://github.com/ruby/ruby/pull/2711
2019-11-12Revert "Method reference operator"Nobuyoshi Nakada
This reverts commit 67c574736912003c377218153f9d3b9c0c96a17b. [Feature #16275]
2019-11-08Renamed `load_*.inc` as `*.rbinc` to utilize a suffix ruleNobuyoshi Nakada
2019-11-08use builtin for RubyVM::AbstractSyntaxTree.Koichi Sasada
Define RubyVM::AbstractSyntaxTree in ast.rb with __builtin functions. Notes: Merged: https://github.com/ruby/ruby/pull/2655
2019-09-07Rename NODE_ARRAY to NODE_LIST to reflect its actual use casesYusuke Endoh
and NODE_ZARRAY to NODE_ZLIST. NODE_ARRAY is used not only by an Array literal, but also the contents of Hash literals, method call arguments, dynamic string literals, etc. In addition, the structure of NODE_ARRAY is a linked list, not an array. This is very confusing, so I believe `NODE_LIST` is a better name.
2019-09-01Make pattern matching support **nil syntaxKazuki Tsujimoto
2019-08-30Make RubyVM::AbstractSyntaxTree handle **nil syntaxJeremy Evans
Use false instead of nil for the keyword and keyword rest values in that case. Notes: Merged: https://github.com/ruby/ruby/pull/2395
2019-08-19Make it as clear as possible that RubyVM is MRI-specific and only exists on ↵Benoit Daloze
MRI (#2113) [ci skip] * Make it clear as possible that RubyVM is MRI-specific and only exists on MRI * See [Bug #15743]. * Use "CRuby VM" instead of "Ruby VM" for clarity. * Use YARV rather than "CRuby VM" for documenting RubyVM::InstructionSequence * Avoid introducing a new "CRuby VM" term in documentation
2019-07-23Support memsize of ASTNobuyoshi Nakada
2019-05-22ast.c: update inspect results in the documentsNobuyoshi Nakada
2019-05-18Distinguish pre-condition and post-condition loopsNobuyoshi Nakada
2019-04-20Avoid usage of the dummy empty BEGIN nodektsj
Use NODE_SPECIAL_NO_NAME_REST instead. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67629 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2019-04-20Add symbol to the result of `RubyVM::AbstractSyntaxTree#children`.yui-knk
Add symbol to the result to make pattern match easily. For example: (1) NODE_MASGN * NODE_SPECIAL_NO_NAME_REST ``` $ ./miniruby -e 'p RubyVM::AbstractSyntaxTree.parse("a, * = b").children[-1].children' [#<RubyVM::AbstractSyntaxTree::Node:VCALL@1:7-1:8>, #<RubyVM::AbstractSyntaxTree::Node:ARRAY@1:0-1:1>, :NODE_SPECIAL_NO_NAME_REST] ``` (2) NODE_POSTARG * NODE_SPECIAL_NO_NAME_REST ``` $ ./miniruby -e 'p RubyVM::AbstractSyntaxTree.parse("a, *, _ = b").children[-1].children[-1].children' [:NODE_SPECIAL_NO_NAME_REST, #<RubyVM::AbstractSyntaxTree::Node:ARRAY@1:6-1:7>] ``` (3) NODE_LASGN * NODE_SPECIAL_REQUIRED_KEYWORD ``` $ ./miniruby -e 'p RubyVM::AbstractSyntaxTree.parse("def a(k:) end").children[-1].children[-1].children[1].children[7].children[0].children' [:k, :NODE_SPECIAL_REQUIRED_KEYWORD] ``` git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67627 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2019-04-17Introduce pattern matching [EXPERIMENTAL]ktsj
[ruby-core:87945] [Feature #14912] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67586 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2019-03-22[DOC] fix markups [ci skip]nobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67337 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2019-01-14ast.c: fix missing head part in dynamic literalnobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66819 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2019-01-06ast.c: argument must be a stringnobu
[ruby-core:90904] [Bug #15511] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66736 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-12-31Method reference operatornobu
Introduce the new operator for method reference, `.:`. [Feature #12125] [Feature #13581] [EXPERIMENTAL] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66667 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-12-24Compact AST::Node#inspectnobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66521 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-12-03Refine RubyVM::AbstractSyntaxTree::Node#typenobu
* ast.c (rb_ast_node_type): simplified to return a Symbol without "NODE_" prefix. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66142 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-11-11Add docs to RubyVM::AbstractSyntaxTree.ofyui-knk
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65666 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-11-11Make some functions to be staticyui-knk
These functions are used only in ast.c. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65663 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-11-10AST.of -e scriptnobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65654 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-11-10Parse the source in SCRIPT_LINES__ as arraynobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65653 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-11-10Check the argument before creating a parsernobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65652 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-11-10Parse the source in SCRIPT_LINES__ if possiblenobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65651 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-11-09Get rid of setting SCRIPT_LINES__ by AST.parsenobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65647 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-11-09Hoisted out rb_ast_parse_str and rb_ast_parse_filenobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65646 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-11-09Rename `AST` module to `AbstractSyntaxTree`yui-knk
Follow the same naming convention of `InstructionSequence` class. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65641 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-11-05Implement `RubyVM::AST.of` [Feature #14836]yui-knk
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65542 b2dd03c8-39d4-4d8f-98ff-823fe69b080e