|
|
@@ -18,16 +18,18 @@ def validate(exp, result):
|
|
|
|
|
|
node_expr = str(node)
|
|
|
|
|
|
+ possibilities = find_possibilities(node)
|
|
|
+
|
|
|
+ # If a best possibility chain of rewrite steps is discovered before,
|
|
|
+ # use the corresponding possibility index of that chain instead.
|
|
|
if node_expr in BEST_POSSIBILITY_CACHE:
|
|
|
- possibility_index = BEST_POSSIBILITY_CACHE[node_expr]
|
|
|
+ p = BEST_POSSIBILITY_CACHE[node_expr]
|
|
|
|
|
|
# If there is no possible rewrite step, bail out
|
|
|
- if possibility_index is None:
|
|
|
+ if p is None:
|
|
|
return False
|
|
|
|
|
|
- possibilities = [possibility_index]
|
|
|
- else:
|
|
|
- possibilities = find_possibilities(node)
|
|
|
+ possibilities = possibilities[p]
|
|
|
|
|
|
for p in possibilities:
|
|
|
# Clone the root node because it will be used in multiple
|