@@ -56,12 +56,11 @@ static VALUE
56
56
node_block_to_hash (const NODE * node )
57
57
{
58
58
VALUE result = rb_ary_new ();
59
- NODE * nd_head = RNODE_BLOCK (node )-> nd_head ;
60
- NODE * nd_end = RNODE_BLOCK (node )-> nd_end ;
61
-
62
- while (RNODE_BLOCK (node )-> nd_next && nd_head != nd_end ) {
63
- rb_ary_push (result , ast_to_values (Qnil , nd_head ));
64
- nd_head = RNODE_BLOCK (node )-> nd_next ;
59
+ const NODE * current_node = node ;
60
+
61
+ while (current_node ) {
62
+ rb_ary_push (result , ast_to_values (Qnil , RNODE_BLOCK (current_node )-> nd_head ));
63
+ current_node = RNODE_BLOCK (current_node )-> nd_next ;
65
64
}
66
65
67
66
return result ;
@@ -76,6 +75,14 @@ left_assign_to_hash(const NODE *node)
76
75
return result ;
77
76
}
78
77
78
+ static VALUE
79
+ node_lvar_to_hash (const NODE * node )
80
+ {
81
+ VALUE result = rb_hash_new ();
82
+ rb_hash_aset (result , rb_str_new2 ("vid" ), ID2SYM (RNODE_LVAR (node )-> nd_vid ));
83
+ return result ;
84
+ }
85
+
79
86
static VALUE
80
87
literal_node_to_hash (const NODE * node )
81
88
{
@@ -143,13 +150,20 @@ ast_to_values(VALUE hash, const NODE *node)
143
150
return result ;
144
151
}
145
152
case NODE_BLOCK : {
146
- return node_block_to_hash (node );
153
+ VALUE result = rb_hash_new ();
154
+ rb_hash_aset (result , rb_str_new2 ("NODE_BLOCK" ), node_block_to_hash (node ));
155
+ return result ;
147
156
}
148
157
case NODE_LASGN : {
149
158
VALUE result = rb_hash_new ();
150
159
rb_hash_aset (result , rb_str_new2 ("NODE_LASGN" ), left_assign_to_hash (node ));
151
160
return result ;
152
161
}
162
+ case NODE_LVAR : {
163
+ VALUE result = rb_hash_new ();
164
+ rb_hash_aset (result , rb_str_new2 ("NODE_LVAR" ), node_lvar_to_hash (node ));
165
+ return result ;
166
+ }
153
167
case NODE_LIST : {
154
168
VALUE result = rb_hash_new ();
155
169
rb_hash_aset (result , rb_str_new2 ("NODE_LIST" ), list_node_to_hash (node ));
0 commit comments