Package org.nlogo.prim

Source Code of org.nlogo.prim._repeatinternal

// (C) Uri Wilensky. https://github.com/NetLogo/NetLogo

package org.nlogo.prim;

import org.nlogo.api.Let;
import org.nlogo.api.Syntax;
import org.nlogo.nvm.Command;
import org.nlogo.nvm.Context;
import org.nlogo.nvm.MutableLong;

public final strictfp class _repeatinternal
    extends Command {
  private final Let let;

  public _repeatinternal(int offset, Let let) {
    this.offset = offset;
    this.let = let;
  }

  @Override
  public Syntax syntax() {
    return Syntax.commandSyntax();
  }

  @Override
  public String toString() {
    return super.toString() + ":" + offset;
  }

  @Override
  public void perform(final Context context) {
    MutableLong counter = (MutableLong) context.getLet(let);
    if (counter.value() <= 0) {
      context.ip = next;
    } else {
      counter.value_$eq(counter.value() - 1);
      context.ip = offset;
    }
  }

  public void perform_1(final Context context) {
    MutableLong counter = (MutableLong) context.getLet(let);
    if (counter.value() <= 0) {
      context.ip = next;
    } else {
      counter.value_$eq(counter.value() - 1);
      context.ip = offset;
    }
  }
}
TOP

Related Classes of org.nlogo.prim._repeatinternal

TOP
Copyright © 2018 www.massapi.com. 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.