@@ -48,6 +48,7 @@ def self.create_node(raw_node, lenv, use_result = true)
4848 when :if_node then IfNode . new ( raw_node , lenv )
4949 when :unless_node then UnlessNode . new ( raw_node , lenv )
5050 when :case_node then CaseNode . new ( raw_node , lenv )
51+ when :case_match_node then CaseMatchNode . new ( raw_node , lenv )
5152 when :while_node then WhileNode . new ( raw_node , lenv )
5253 when :until_node then UntilNode . new ( raw_node , lenv )
5354 when :break_node then BreakNode . new ( raw_node , lenv )
@@ -194,15 +195,15 @@ def self.create_node(raw_node, lenv, use_result = true)
194195 when :float_node then FloatNode . new ( raw_node , lenv )
195196 when :rational_node then RationalNode . new ( raw_node , lenv )
196197 when :imaginary_node then ComplexNode . new ( raw_node , lenv )
198+ when :source_file_node then StringNode . new ( raw_node , lenv , "" )
199+ when :source_line_node then IntegerNode . new ( raw_node , lenv , 0 )
200+ when :source_encoding_node then SourceEncodingNode . new ( raw_node , lenv )
197201 when :symbol_node then SymbolNode . new ( raw_node , lenv )
198202 when :interpolated_symbol_node then InterpolatedSymbolNode . new ( raw_node , lenv )
199203 when :string_node then StringNode . new ( raw_node , lenv , raw_node . content )
204+ when :interpolated_string_node then InterpolatedStringNode . new ( raw_node , lenv )
200205 when :x_string_node then StringNode . new ( raw_node , lenv , "" )
201206 when :interpolated_x_string_node then InterpolatedStringNode . new ( raw_node , lenv )
202- when :source_file_node then StringNode . new ( raw_node , lenv , "" )
203- when :source_line_node then IntegerNode . new ( raw_node , lenv , 0 )
204- when :source_encoding_node then SourceEncodingNode . new ( raw_node , lenv )
205- when :interpolated_string_node then InterpolatedStringNode . new ( raw_node , lenv )
206207 when :regular_expression_node then RegexpNode . new ( raw_node , lenv )
207208 when :interpolated_regular_expression_node then InterpolatedRegexpNode . new ( raw_node , lenv )
208209 when :match_last_line_node then MatchLastLineNode . new ( raw_node , lenv )
@@ -220,8 +221,9 @@ def self.create_node(raw_node, lenv, use_result = true)
220221 when :alias_global_variable_node then AliasGlobalVariableNode . new ( raw_node , lenv )
221222 when :post_execution_node then PostExecutionNode . new ( raw_node , lenv )
222223 when :flip_flop_node then FlipFlopNode . new ( raw_node , lenv )
223- when :shareable_constant_node
224- create_node ( raw_node . write , lenv )
224+ when :shareable_constant_node then create_node ( raw_node . write , lenv )
225+ when :match_required_node then MatchRequiredNode . new ( raw_node , lenv )
226+ when :match_predicate_node then MatchPreidcateNode . new ( raw_node , lenv )
225227
226228 # call
227229 when :super_node then SuperNode . new ( raw_node , lenv )
@@ -271,6 +273,67 @@ def self.create_target_node(raw_node, lenv)
271273 end
272274 end
273275
276+ def self . create_pattern_node ( raw_node , lenv )
277+ while true
278+ case raw_node . type
279+ when :parentheses_node
280+ raw_node = raw_node . body
281+ when :implicit_node
282+ raw_node = raw_node . value
283+ else
284+ break
285+ end
286+ end
287+
288+ case raw_node . type
289+ when :array_pattern_node then ArrayPatternNode . new ( raw_node , lenv )
290+ when :hash_pattern_node then HashPatternNode . new ( raw_node , lenv )
291+ when :find_pattern_node then FindPatternNode . new ( raw_node , lenv )
292+
293+ when :alternation_pattern_node then AltPatternNode . new ( raw_node , lenv )
294+
295+ when :capture_pattern_node then CapturePatternNode . new ( raw_node , lenv )
296+
297+ when :if_node then IfPatternNode . new ( raw_node , lenv )
298+
299+ when :pinned_variable_node then PinnedPatternNode . new ( raw_node , lenv )
300+ when :pinned_expression_node then PinnedPatternNode . new ( raw_node , lenv )
301+
302+ when :local_variable_target_node
303+ dummy_node = DummyRHSNode . new ( TypeProf ::CodeRange . from_node ( raw_node . location ) , lenv )
304+ LocalVariableWriteNode . new ( raw_node , dummy_node , lenv )
305+
306+ when :constant_read_node , :constant_path_node
307+ ConstantReadNode . new ( raw_node , lenv )
308+
309+ when :self_node then SelfNode . new ( raw_node , lenv )
310+ when :nil_node then NilNode . new ( raw_node , lenv )
311+ when :true_node then TrueNode . new ( raw_node , lenv )
312+ when :false_node then FalseNode . new ( raw_node , lenv )
313+ when :integer_node then IntegerNode . new ( raw_node , lenv )
314+ when :float_node then FloatNode . new ( raw_node , lenv )
315+ when :rational_node then RationalNode . new ( raw_node , lenv )
316+ when :imaginary_node then ComplexNode . new ( raw_node , lenv )
317+ when :source_file_node then StringNode . new ( raw_node , lenv , "" )
318+ when :source_line_node then IntegerNode . new ( raw_node , lenv , 0 )
319+ when :source_encoding_node then SourceEncodingNode . new ( raw_node , lenv )
320+ when :symbol_node then SymbolNode . new ( raw_node , lenv )
321+ when :interpolated_symbol_node then InterpolatedSymbolNode . new ( raw_node , lenv )
322+ when :string_node then StringNode . new ( raw_node , lenv , raw_node . content )
323+ when :interpolated_string_node then InterpolatedStringNode . new ( raw_node , lenv )
324+ when :x_string_node then StringNode . new ( raw_node , lenv , "" )
325+ when :interpolated_x_string_node then InterpolatedStringNode . new ( raw_node , lenv )
326+ when :regular_expression_node then RegexpNode . new ( raw_node , lenv )
327+ when :interpolated_regular_expression_node then InterpolatedRegexpNode . new ( raw_node , lenv )
328+
329+ when :array_node then ArrayNode . new ( raw_node , lenv ) # for %w[foo bar]
330+ when :range_node then RangeNode . new ( raw_node , lenv ) # TODO: support range pattern correctly
331+
332+ else
333+ raise "unknown pattern node type: #{ raw_node . type } "
334+ end
335+ end
336+
274337 def self . parse_cpath ( raw_node , cref )
275338 names = [ ]
276339 while raw_node
0 commit comments