// close options
a2 = a2.dereference();
Term tmp = a2;
while (!tmp.isNil()) {
if (tmp.isVariable()) {
throw new PInstantiationException(this, 2);
}
if (!tmp.isList()) {
throw new IllegalTypeException(this, 2, "list", a2);
}
Term car = ((ListTerm) tmp).car().dereference();
if (car.isVariable()) {
throw new PInstantiationException(this, 2);
}
if (car.isStructure()) {
SymbolTerm functor = ((StructureTerm) car).functor();
Term[] args = ((StructureTerm) car).args();
if (functor.equals(SYM_FORCE_1)) {
Term bool = args[0].dereference();
if (bool.equals(SYM_TRUE)) {
forceFlag = true;
} else if (bool.equals(SYM_FALSE)) {
forceFlag = false;
} else {
throw new IllegalDomainException(this, 2,
"close_option", car);
}
} else {
throw new IllegalDomainException(this, 2, "close_option",
car);
}
} else {
throw new IllegalDomainException(this, 2, "close_option", car);
}
tmp = ((ListTerm) tmp).cdr().dereference();
}
// stream
a1 = a1.dereference();
if (a1.isVariable()) {
throw new PInstantiationException(this, 1);
} else if (a1.isSymbol()) {
if (!engine.getStreamManager().containsKey(a1)) {
throw new ExistenceException(this, 1, "stream", a1, "");
}
stream = ((JavaObjectTerm) engine.getStreamManager().get(a1))