private final boolean[] bits;
+ private boolean immutable = false;
+
public BitVector(int length) {
this.bits = new boolean[length];
}
- /** copy the low-order bits of the argument into this BitVector; returns this */
+ /** copy the low-order bits of the argument into this BitVector; returns <tt>this</tt> */
public BitVector set(long value) {
+ if (immutable) throw new RuntimeException("attempt to modify an immutable BitVector");
for(int i=0; i<length(); i++)
set(i, ((value >>> i) & 1L) != 0);
return this;
}
public void set(int bit, boolean value) {
+ if (immutable) throw new RuntimeException("attempt to modify an immutable BitVector");
bits[bit] = value;
}
ret.append(get(i) ? '1' : '0');
return ret.toString();
}
+
+ public void setImmutable() {
+ immutable = true;
+ }
}
public Shift(Dock dock, boolean looping, Predicate predicate, BitVector immediate) {
super(dock, looping, predicate);
this.immediate = immediate;
+ this.immediate.setImmutable();
}
public String toString() { return super.toString()+"shift "+immediate; }
}