public Object report(final Context context) throws LogoException {
Object agentOrSet = args[0].report(context);
if (agentOrSet instanceof Agent) {
Agent agent = (Agent) agentOrSet;
if (agent.id == -1) {
throw new EngineException(context, this,
I18N.errorsJ().getN("org.nlogo.$common.thatAgentIsDead", agent.classDisplayName()));
}
try {
return agent.getTurtleOrLinkVariable(varName);
} catch (org.nlogo.api.AgentException ex) {
throw new EngineException(context, this, ex.getMessage());
}
} else if (agentOrSet instanceof AgentSet) {
AgentSet sourceSet = (AgentSet) agentOrSet;
LogoListBuilder result = new LogoListBuilder();
try {
for (AgentSet.Iterator iter = sourceSet.shufflerator(context.job.random);
iter.hasNext();) {
result.add(iter.next().getTurtleOrLinkVariable(varName));
}
} catch (org.nlogo.api.AgentException ex) {
throw new EngineException(context, this, ex.getMessage());
}
return result.toLogoList();
} else {
throw new org.nlogo.nvm.ArgumentTypeException
(context, this, 0,