public boolean handlesTime() { for (BArm arm : arms) { if (arm.patterns.length == 1) { Pattern p = arm.patterns[0]; if (p instanceof PTerm) { PTerm term = (PTerm) p; if (term.getName().equals("Time")) return true; } } } return false; }
private boolean isDisjointArms() { // Returns true when the arms of the case are all headed by unique term patterns... Set<String> terms = new HashSet<String>(); for (BArm arm : arms) { Pattern[] patterns = arm.patterns; Pattern pattern = patterns[0]; if (pattern instanceof PNil) { if (terms.contains("[]")) return false; else terms.add("[]"); } else if (pattern instanceof PCons) { if (terms.contains(":")) return false; else terms.add(":"); } else if (pattern instanceof ast.patterns.PTerm) { ast.patterns.PTerm term = (ast.patterns.PTerm) pattern; String functor = term.getName(); if (terms.contains(functor)) return false; else terms.add(functor); } else return false; } return true; }