Package org.nlogo.prim

Source Code of org.nlogo.prim._observervariable

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

package org.nlogo.prim;

import org.nlogo.agent.Observer;
import org.nlogo.api.Syntax;
import org.nlogo.nvm.Reference;
import org.nlogo.nvm.Reporter;

public final strictfp class _observervariable
    extends Reporter {
  public int vn = 0;

  public _observervariable(int vn) {
    this.vn = vn;
  }

  public Reference makeReference() {
    return new Reference(Observer.class, vn, this);
  }

  @Override
  public Object report(final org.nlogo.nvm.Context context) {
    return context.agent.getObserverVariable(vn);
  }

  @Override
  public String toString() {
    if (world != null) {
      return super.toString() + ":" + world.observerOwnsNameAt(vn);
    } else {
      return super.toString() + ":" + vn;
    }
  }

  @Override
  public Syntax syntax() {
    return Syntax.reporterSyntax(Syntax.WildcardType() | Syntax.ReferenceType());
  }

  public Object report_1(final org.nlogo.nvm.Context context) {
    return context.agent.getObserverVariable(vn);
  }
}
TOP

Related Classes of org.nlogo.prim._observervariable

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.