@Test public void shouldReduceCapturesToLets() { Value pattern = matcher("scotch.test.max", t(1), asList(arg("#0", t(2)), arg("#1", t(3))), pattern( "scotch.test.(max#0)", asList(capture(arg("#0", t(10)), "a", t(4)), capture(arg("#1", t(12)), "b", t(5))), apply( id("a", t(6)), id("b", t(7)), t(8) ) ) ); SymbolGenerator generator = new DefaultSymbolGenerator() {{ startTypesAt(9); }}; assertThat(pattern.reducePatterns(new DefaultPatternReducer(generator)), is(fn("scotch.test.max", asList(arg("#0", t(2)), arg("#1", t(3))), scope("scotch.test.(max#0)", let(t(12), "a", arg("#0", t(10)), let(t(11), "b", arg("#1", t(12)), apply( id("a", t(6)), id("b", t(7)), t(8) )))) ))); }
private PatternState pattern() { return patterns.peek(); }
DefaultPatternReducer implements PatternReducer { private PatternState pattern() { return patterns.peek(); } }
DefaultPatternReducer implements PatternReducer { private PatternState pattern() { return patterns.peek(); } DefaultPatternReducer(SymbolGenerator generator); }
DefaultPatternReducer implements PatternReducer { private PatternState pattern() { return patterns.peek(); } DefaultPatternReducer(SymbolGenerator generator); @Override void addAssignment(CaptureMatch capture); @Override void addCondition(Value argument, Value value); @Override void addCondition(IsConstructor constructor); @Override void addTaggedArgument(Value taggedArgument); @Override void beginPattern(PatternMatcher matcher); @Override void beginPatternCase(PatternCase patternCase); @Override void endPattern(); @Override void endPatternCase(); @Override Value getTaggedArgument(Value argument); @Override void markFunction(FunctionValue function); @Override Value reducePattern(); }
DefaultPatternReducer implements PatternReducer { private PatternState pattern() { return patterns.peek(); } DefaultPatternReducer(SymbolGenerator generator); @Override void addAssignment(CaptureMatch capture); @Override void addCondition(Value argument, Value value); @Override void addCondition(IsConstructor constructor); @Override void addTaggedArgument(Value taggedArgument); @Override void beginPattern(PatternMatcher matcher); @Override void beginPatternCase(PatternCase patternCase); @Override void endPattern(); @Override void endPatternCase(); @Override Value getTaggedArgument(Value argument); @Override void markFunction(FunctionValue function); @Override Value reducePattern();  }