summaryrefslogtreecommitdiff
path: root/ast.rb
diff options
context:
space:
mode:
authorYusuke Endoh <mame@ruby-lang.org>2021-06-21 21:15:25 +0900
committerYusuke Endoh <mame@ruby-lang.org>2021-06-21 21:15:25 +0900
commited8e265d4be53e15bffea3b1db649b1cea4ea864 (patch)
treecd3faaa65dd3ebf0fd5b3f9dae16666fa9f17196 /ast.rb
parent089a26b0a619a649b1958061df8f21a6cdc6cacd (diff)
Experimentally expose RubyVM::AST::Node#node_id
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.
Diffstat (limited to 'ast.rb')
-rw-r--r--ast.rb11
1 files changed, 11 insertions, 0 deletions
diff --git a/ast.rb b/ast.rb
index ce99f53c45..34dd3f1d49 100644
--- a/ast.rb
+++ b/ast.rb
@@ -141,6 +141,17 @@ module RubyVM::AbstractSyntaxTree
end
# call-seq:
+ # node.node_id -> integer
+ #
+ # Returns an internal node_id number.
+ # Note that this is an API for ruby internal use, debugging,
+ # and research. Do not use this for any other purpose.
+ # The compatibility is not guaranteed.
+ def node_id
+ Primitive.ast_node_node_id
+ end
+
+ # call-seq:
# node.script_lines -> array
#
# Returns the original source code as an array of lines.