Package org.nlogo.nvm

Examples of org.nlogo.nvm.EngineException


  public void perform(final Context context)
      throws LogoException {
    org.nlogo.agent.AgentSet breed = argEvalAgentSet(context, 0);
    String shape = argEvalString(context, 1);
    if (breed.type() == org.nlogo.agent.Patch.class) {
      throw new EngineException(context, this,
          I18N.errorsJ().get("org.nlogo.prim.etc._setdefaultshape.cantSetDefaultShapeOfPatch"));
    }
    if (breed.type() == org.nlogo.agent.Observer.class) {
      throw new EngineException(context, this,
          "cannot set the default shape of the observer, because the observer does not have a shape");
    }
    if (breed != world.turtles() && !world.isBreed(breed) &&
        breed != world.links() && !world.isLinkBreed(breed)) {
      throw new EngineException(context, this,
          I18N.errorsJ().get("org.nlogo.prim.etc._setdefaultshape.canOnlySetDefaultShapeOfEntireBreed"));
    }
    if (breed.type() == org.nlogo.agent.Turtle.class) {
      String checkedShape = world.checkTurtleShapeName(shape);
      if (checkedShape == null) {
        throw new EngineException(context, this,
            I18N.errorsJ().getN("org.nlogo.prim.etc._setDefaultShape.notADefinedTurtleShape", shape));
      }
      world.turtleBreedShapes.setBreedShape(breed, checkedShape);
    } else if (breed.type() == org.nlogo.agent.Link.class) {
      String checkedShape = world.checkLinkShapeName(shape);
      if (checkedShape == null) {
        throw new EngineException(context, this,
            I18N.errorsJ().getN("org.nlogo.prim.etc._setDefaultShape.notADefinedLinkShape", shape));
      }
      world.linkBreedShapes.setBreedShape(breed, checkedShape);
    }
    context.ip = next;
View Full Code Here


  @Override
  public void perform(final Context context) throws LogoException {
    double diffuseparam = argEvalDoubleValue(context, 0);
    if (diffuseparam < 0.0 || diffuseparam > 1.0) {
      throw new EngineException
          (context, this, I18N.errorsJ().getN("org.nlogo.prim.$common.paramOutOfBounds", diffuseparam));
    }
    try {
      world.diffuse(diffuseparam, reference.vn());
    } catch (AgentException ex) {
      throw new EngineException(context, this, ex.getMessage());
    } catch (PatchException ex) {
      Object value = ex.patch().getPatchVariable(reference.vn());
      throw new EngineException
          (context, this,
              ex.patch() + " should contain a number in the " + world.patchesOwnNameAt(reference.vn()) +
                  " variable, but contains " +
                  (value == org.nlogo.api.Nobody$.MODULE$
                      ? "NOBODY"
View Full Code Here

          (workspace.fileManager().getFile
              (workspace.fileManager().attachPrefix
                  (argEvalString(context, 0))),
              world, false);
    } catch (java.io.IOException ex) {
      throw new EngineException
          (context, this,
              token().name() +
                  ": " + ex.getMessage());
    }
    context.ip = next;
View Full Code Here

  }

  @Override
  public Object report(Context context)
      throws LogoException {
    throw new EngineException(context, this, "boom!");
  }
View Full Code Here

    return report_1(context, argEvalDoubleValue(context, 0));
  }

  public double report_1(Context context, double arg0) throws LogoException {
    if (arg0 < 0) {
      throw new EngineException(context, this,
          I18N.errorsJ().getN("org.nlogo.prim.etc._sqrt.squareRootIsImaginary", arg0));
    }
    return StrictMath.sqrt(arg0);
  }
View Full Code Here

      // if we're not in an ask, then "stop" means to exit this procedure
      // immediately.  first we must check that it's a command procedure
      // and not a reporter procedure.
      if (context.activation.procedure.tyype == Procedure.Type.REPORTER ||
          context.activation.procedure.isTask() && context.activation.procedure.parent.tyype == Procedure.Type.REPORTER) {
        throw new EngineException(context, this,
            I18N.errorsJ().getN("org.nlogo.prim.etc._stop.notAllowedInsideToReport", displayName()));
      }
      context.stop();
    }
  }
View Full Code Here

    if (!context.atTopActivation()) {
      context.finished = true;
    } else {
      if (context.activation.procedure.tyype == Procedure.Type.REPORTER ||
          context.activation.procedure.isTask() && context.activation.procedure.parent.tyype == Procedure.Type.REPORTER) {
        throw new EngineException(context, this,
            I18N.errorsJ().getN("org.nlogo.prim.etc._stop.notAllowedInsideToReport", displayName()));
      }
      workspace.profilingTracer().closeCallRecord(context, context.activation);
      context.stop();
    }
View Full Code Here

  }

  public void perform_1(final Context context, Agent target)
      throws LogoException {
    if (target instanceof org.nlogo.agent.Link) {
      throw new EngineException
          (context, this, I18N.errorsJ().get("org.nlogo.prim.etc.$common.expectedTurtleOrPatchButGotLink"));
    }
    if (target.id == -1) {
      throw new EngineException(context, this,
        I18N.errorsJ().getN("org.nlogo.$common.thatAgentIsDead", target.classDisplayName()));
    }
    if (context.agent instanceof Turtle) {
      ((Turtle) context.agent).face(target, true);
    } else {
View Full Code Here

  public Object report(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.getBreedVariable(name);
      } 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().getBreedVariable(name));
        }
      } 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,
View Full Code Here

      if (tester == context.agent) {
        continue;
      }
      Object value = freshContext.evaluateReporter(tester, reporterBlock);
      if (!(value instanceof Boolean)) {
        throw new EngineException
            (context, this, I18N.errorsJ().getN("org.nlogo.prim.$common.expectedBooleanValue",
                displayName(), Dump.logoObject(tester), Dump.logoObject(value)));
      }
      if (((Boolean) value).booleanValue()) {
        result++;
View Full Code Here

TOP

Related Classes of org.nlogo.nvm.EngineException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.