/** Place expressions around an Op */ private static Op buildFilter(ExprList exprs, Op op) { if (exprs.isEmpty()) return op; for (Iterator<Expr> iter = exprs.iterator(); iter.hasNext(); ) { Expr expr = iter.next(); if (op == null) op = OpTable.unit(); op = OpFilter.filter(expr, op); iter.remove(); } return op; }
/** For any expression now in scope, wrap the op with a filter */ private static Op insertAnyFilter(ExprList exprs, Set<Var> patternVarsScope, Op op) { for (Iterator<Expr> iter = exprs.iterator(); iter.hasNext(); ) { Expr expr = iter.next(); // Cache Set<Var> exprVars = expr.getVarsMentioned(); if (patternVarsScope.containsAll(exprVars)) { if (op == null) op = OpTable.unit(); op = OpFilter.filter(expr, op); iter.remove(); } } return op; }
@Test public void testOp_04() { opSame("(label 'ABC' (table unit))", OpLabel.create("ABC", OpTable.unit())); }