diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2018-12-03 01:06:34 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2018-12-03 01:06:34 +0000 |
commit | afa685398e6c098a55bb2d0565e8f1bd380e4ab9 (patch) | |
tree | 4a37b0f466328af12c4b9a0e8f403c0ccf8b497c /ast.c | |
parent | 8edd642381e6f5b53dd45de641aadc4bebee1603 (diff) |
Refine RubyVM::AbstractSyntaxTree::Node#type
* 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
Diffstat (limited to 'ast.c')
-rw-r--r-- | ast.c | 14 |
1 files changed, 7 insertions, 7 deletions
@@ -262,21 +262,21 @@ rb_ast_node_alloc(VALUE klass) } static const char* -node_type_to_str(NODE *node) +node_type_to_str(const NODE *node) { - return ruby_node_name(nd_type(node)); + return (ruby_node_name(nd_type(node)) + rb_strlen_lit("NODE_")); } /* * call-seq: - * node.type -> string + * node.type -> symbol * - * Returns the type of this node as a string. + * Returns the type of this node as a symbol. * * root = RubyVM::AbstractSyntaxTree.parse("x = 1 + 2") - * root.type # => "NODE_SCOPE" + * root.type # => :SCOPE * call = root.children[2] - * call.type # => "NODE_OPCALL" + * call.type # => :OPCALL */ static VALUE rb_ast_node_type(VALUE self) @@ -284,7 +284,7 @@ rb_ast_node_type(VALUE self) struct ASTNodeData *data; TypedData_Get_Struct(self, struct ASTNodeData, &rb_node_type, data); - return rb_fstring_cstr(node_type_to_str(data->node)); + return rb_sym_intern_ascii_cstr(node_type_to_str(data->node)); } #define NEW_CHILD(ast, node) node ? ast_new_internal(ast, node) : Qnil |