@@ -8,7 +8,7 @@ import scala.tasty._
8
8
9
9
object Matcher {
10
10
11
- private final val debug = false
11
+ private final val debug = true
12
12
13
13
/** Pattern matches an the scrutineeExpr aquainsnt the patternExpr and returns a tuple
14
14
* with the matched holes if successful.
@@ -45,6 +45,17 @@ object Matcher {
45
45
*/
46
46
def treeMatches (scrutinee : Tree , pattern : Tree )(implicit env : Set [(Symbol , Symbol )]): Option [Tuple ] = {
47
47
48
+ println(" ++++++++++++++++++++++++++++++++++++++++=" )
49
+ println(" ++++++++++++++++++++++++++++++++++++++++=" )
50
+ println(scrutinee.show)
51
+ println(scrutinee.showExtractors)
52
+ println()
53
+ println(pattern.show)
54
+ println(pattern.showExtractors)
55
+ println()
56
+ println()
57
+ println()
58
+
48
59
/** Check that both are `val` or both are `lazy val` or both are `var` **/
49
60
def checkValFlags (): Boolean = {
50
61
import Flags ._
@@ -117,7 +128,14 @@ object Matcher {
117
128
foldMatchings(treeMatches(fn1, fn2), treesMatch(args1, args2))
118
129
119
130
case (Block (stats1, expr1), Block (stats2, expr2)) =>
120
- foldMatchings(treesMatch(stats1, stats2), treeMatches(expr1, expr2))
131
+ def rec (scrutinees : List [Tree ], patterns : List [Tree ], acc : Option [Tuple ]): Option [Tuple ] = (scrutinees, patterns) match {
132
+ case (x :: xs, y :: ys) =>
133
+ rec(xs, ys, foldMatchings(acc, treeMatches(x, y)))
134
+ case (Nil , Nil ) =>
135
+ foldMatchings(acc, treeMatches(expr1, expr2))
136
+ case _ => None
137
+ }
138
+ rec(stats1, stats2, Some (()))
121
139
122
140
case (If (cond1, thenp1, elsep1), If (cond2, thenp2, elsep2)) =>
123
141
foldMatchings(treeMatches(cond1, cond2), treeMatches(thenp1, thenp2), treeMatches(elsep1, elsep2))
@@ -219,7 +237,8 @@ object Matcher {
219
237
|
220
238
| ${pattern.showExtractors}
221
239
|
222
- |
240
+ |with environment
241
+ | ${env}
223
242
|
224
243
|
225
244
| """ .stripMargin)
0 commit comments