00001 package gov.nasa.arc.ase.jpf.expr;
00002
00003
00004 class Or implements SubExpr {
00005 private int length;
00006 private SubExpr[] terms;
00007
00008 Or(int l) {
00009 length = l;
00010 terms = new SubExpr[l];
00011 }
00012 public void backtrack() {
00013 throw new RuntimeException("Expression is not executable");
00014 }
00015 public boolean evaluate() {
00016 boolean result = false;
00017
00018 for(int i = 0; !result && i < length; i++) {
00019 result |= terms[i].evaluate();
00020 }
00021
00022 return result;
00023 }
00024 public void execute() {
00025 throw new RuntimeException("Expression is not executable");
00026 }
00027 void set(int index, SubExpr t) {
00028 terms[index] = t;
00029 }
00030 public String toString() {
00031 StringBuffer sb = new StringBuffer();
00032
00033 for(int i = 0; i < length; i++) {
00034 if(i != 0) sb.append(" | ");
00035 sb.append(terms[i]);
00036 }
00037
00038 return sb.toString();
00039 }
00040 }