perform_1(context, args[0].report(context));
}
public void perform_1(Context context, Object target)
throws LogoException {
AgentSet agentset;
if (target instanceof AgentSet) {
agentset = (AgentSet) target;
if (!(context.agent instanceof Observer)) {
if (agentset == world.turtles()) {
throw new EngineException
(context, this, I18N.errorsJ().get("org.nlogo.prim.$common.onlyObserverCanAskAllTurtles"));
}
if (agentset == world.patches()) {
throw new EngineException
(context, this, I18N.errorsJ().get("org.nlogo.prim.$common.onlyObserverCanAskAllPatches"));
}
}
} else if (target instanceof Agent) {
Agent agent = (Agent) target;
if (agent.id == -1) {
throw new EngineException(context, this,
I18N.errorsJ().getN("org.nlogo.$common.thatAgentIsDead", agent.classDisplayName()));
}
agentset = new ArrayAgentSet(agent.getAgentClass(), 1, false, world);
agentset.add(agent);
} else {
throw new ArgumentTypeException(context, this, 0, Syntax.AgentsetType() | Syntax.AgentType(), target);
}
context.runExclusiveJob(agentset, next);
context.ip = offset;