if (parent!=null) commands.set(commands.size()-1, newcommand); else commands.add(newcommand);
}
/** Resolve a particular command. */
private Command resolveCommand(Command cmd, ConstList<Sig> exactSigs, Expr globalFacts) throws Err {
Command parent = cmd.parent==null ? null : resolveCommand(cmd.parent, exactSigs, globalFacts);
String cname = ((ExprVar)(cmd.formula)).label;
Expr e;
if (cmd.check) {
List<Object> m = getRawQS(2, cname); // We prefer assertion in the topmost module
if (m.size()==0 && cname.indexOf('/')<0) m=getRawNQS(this, 2, cname);
if (m.size()>1) unique(cmd.pos, cname, m);
if (m.size()<1) throw new ErrorSyntax(cmd.pos, "The assertion \""+cname+"\" cannot be found.");
e = ((Expr)(m.get(0))).not();
} else {
List<Object> m = getRawQS(4, cname); // We prefer fun/pred in the topmost module
if (m.size()==0 && cname.indexOf('/')<0) m=getRawNQS(this, 4, cname);
if (m.size()>1) unique(cmd.pos, cname, m);
if (m.size()<1) throw new ErrorSyntax(cmd.pos, "The predicate/function \""+cname+"\" cannot be found.");
Func f = (Func) (m.get(0));
e = f.getBody();
if (!f.isPred) e = e.in(f.returnDecl);
if (f.decls.size()>0) e = ExprQt.Op.SOME.make(null, null, f.decls, e);
}
if (e==null) e = ExprConstant.TRUE;
TempList<CommandScope> sc=new TempList<CommandScope>(cmd.scope.size());
for(CommandScope et: cmd.scope) {
Sig s = getRawSIG(et.sig.pos, et.sig.label);
if (s==null) throw new ErrorSyntax(et.sig.pos, "The sig \""+et.sig.label+"\" cannot be found.");
sc.add(new CommandScope(null, s, et.isExact, et.startingScope, et.endingScope, et.increment));
}
return new Command(cmd.pos, cmd.label, cmd.check, cmd.overall, cmd.bitwidth, cmd.maxseq, cmd.expects, sc.makeConst(), exactSigs, globalFacts.and(e), parent);
}