package nxm.sys.libm;

import nxm.sys.inc.InternalUseOnly;

/**
  Defines an Argument to a Calculator Object.

  @author Jeff Schoen
*/
public class Argument {

  /** Mnemonic for an operator argument. */
  public static final int OPERATOR=1;
  /** Mnemonic for an constant expression or number argument. */
  public static final int CONSTANT=2;
  /** Mnemonic for an variable expression or result argument. */
  public static final int VARIABLE=3;
  /** Mnemonic for an input argument.  A file or result. */
  public static final int STACKIN=11;
  /** Mnemonic for an output argument.  A file or result. */
  public static final int STACKOUT=12;

  /** The mnemonic for the kind of argument. This is an OPERATOR, CONSTANT, VARIABLE, STACKIN or STACKOUT */
  @InternalUseOnly public int kind;
  /** The raw argument string. Name of a file, expression, result, or number */
  @InternalUseOnly public String name;
  /** Description is TBD */
  @InternalUseOnly public int mode;
  /** Description is TBD */
  @InternalUseOnly public int size;
  /** Description is TBD */
  @InternalUseOnly public Operator op;
  /** Reference used for translation.  Usually passed in as this or Midas. */
  @InternalUseOnly public Object ref;
  /** Description is TBD */
  @InternalUseOnly public int info;
  /** Holds data if of double type. */
  @InternalUseOnly public double[][] dv;
  /** Holds data if of float type. */
  @InternalUseOnly public float[][] fv;
  /** Holds data if of int type. */
  @InternalUseOnly public int[][] lv;

  /** Constructor.
      @param kind  The {@link #kind} kind of argument
      @param name the raw argument string. Name of a file, expression, result, or number.
  */
  public Argument (int kind, String name) {
    this.kind = kind;
    this.name = name;
  }

  @Override
  public String toString() {
    return "Name "+name+" info "+info+" kind "+getKind()+" op "+op+" mode "+mode+" size "+size;
  }
  /** Returns a String representation of the kind of argument.  Returns null
      if there is no mnemonic for the kind.
      @return String representation of the kind of argument
  */
  public String getKind() {
    if (kind == OPERATOR) return "OPERATOR";
    if (kind == CONSTANT) return "CONSTANT";
    if (kind == VARIABLE) return "VARIABLE";
    if (kind == STACKIN)  return "STACKIN";
    if (kind == STACKOUT) return "STACKOUT";
    return null;
  }

}
