예제 #1
0
  @Override
  public Syntax getSyntax() {
    int[] input = new int[] {Syntax.StringType() | Syntax.TurtleType(), Syntax.StringType()};
    int output = Syntax.BooleanType();

    return Syntax.reporterSyntax(input, output);
  }
예제 #2
0
 @Override
 public Syntax getSyntax() {
   return Syntax.commandSyntax(
       new int[] {
         Syntax.StringType(),
         Syntax.StringType(),
         Syntax.NumberType(),
         Syntax.StringType() | Syntax.RepeatableType()
       },
       3);
 }
예제 #3
0
 @Override
 public Syntax syntax() {
   int[] right = {
     Syntax.WildcardType(), Syntax.ListType() | Syntax.StringType() | Syntax.AgentsetType()
   };
   int ret = Syntax.BooleanType();
   return Syntax.reporterSyntax(right, ret);
 }
예제 #4
0
 @Override
 public Object report(final org.nlogo.nvm.Context context) throws LogoException {
   Object obj = args[1].report(context);
   if (obj instanceof LogoList) {
     Object value = args[0].report(context);
     LogoList list = (LogoList) obj;
     for (Iterator<Object> it = list.iterator(); it.hasNext(); ) {
       if (Equality.equals(value, it.next())) {
         return Boolean.TRUE;
       }
     }
     return Boolean.FALSE;
   } else if (obj instanceof String) {
     return ((String) obj).indexOf(argEvalString(context, 0)) != -1 ? Boolean.TRUE : Boolean.FALSE;
   } else if (obj instanceof AgentSet) {
     Agent agent = argEvalAgent(context, 0);
     AgentSet agentset = (AgentSet) obj;
     if (agent instanceof Turtle) {
       if (agent.id == -1) {
         return Boolean.FALSE;
       }
       if (agentset.type() != Turtle.class) {
         return Boolean.FALSE;
       }
       if (agentset == world.turtles()) {
         return Boolean.TRUE;
       }
       if (world.isBreed(agentset)) {
         return agentset == ((Turtle) agent).getBreed() ? Boolean.TRUE : Boolean.FALSE;
       }
     }
     if (agent instanceof Link) {
       if (agent.id == -1) {
         return Boolean.FALSE;
       }
       if (agentset.type() != Link.class) {
         return Boolean.FALSE;
       }
       if (agentset == world.links()) {
         return Boolean.TRUE;
       }
       if (world.isBreed(agentset)) {
         return agentset == ((Link) agent).getBreed() ? Boolean.TRUE : Boolean.FALSE;
       }
     } else if (agent instanceof Patch) {
       if (agentset.type() != Patch.class) {
         return Boolean.FALSE;
       }
       if (agentset == world.patches()) {
         return Boolean.TRUE;
       }
     }
     return agentset.contains(agent) ? Boolean.TRUE : Boolean.FALSE;
   } else {
     throw new ArgumentTypeException(
         context, this, 1, Syntax.ListType() | Syntax.StringType() | Syntax.AgentsetType(), obj);
   }
 }
 public Syntax getSyntax() {
   return Syntax.commandSyntax(
       new int[] {
         Syntax.StringType(),
         Syntax.NumberType(),
         Syntax.NumberType(),
         Syntax.NumberType(),
         Syntax.NumberType(),
         Syntax.NumberType(),
         Syntax.NumberType()
       });
 }
예제 #6
0
파일: _item.java 프로젝트: smbillah/NetLogo
 @Override
 public Object report(final org.nlogo.nvm.Context context) throws LogoException {
   int index = argEvalIntValue(context, 0);
   Object obj = args[1].report(context);
   if (index < 0) {
     throw new EngineException(
         context, this, I18N.errorsJ().getN("org.nlogo.prim.etc.$common.negativeIndex", index));
   }
   if (obj instanceof LogoList) {
     LogoList list = (LogoList) obj;
     if (index >= list.size()) {
       throw new EngineException(
           context,
           this,
           I18N.errorsJ()
               .getN(
                   "org.nlogo.prim.etc.$common.indexExceedsListSize",
                   index,
                   Dump.logoObject(list),
                   list.size()));
     }
     return list.get(index);
   } else if (obj instanceof String) {
     String string = (String) obj;
     if (index >= string.length()) {
       throw new EngineException(
           context,
           this,
           I18N.errorsJ()
               .getN(
                   "org.nlogo.prim.etc.$common.indexExceedsListSize",
                   index,
                   Dump.logoObject(string),
                   string.length()));
     }
     return string.substring(index, index + 1);
   } else {
     throw new ArgumentTypeException(
         context, this, 1, Syntax.ListType() | Syntax.StringType(), obj);
   }
 }
예제 #7
0
 @Override
 public Syntax getSyntax() {
   return Syntax.commandSyntax(new int[] {Syntax.StringType()});
 }