/** The cost of inlining this expression */
  public int costInline(int thresh, Environment env, Context ctx) {
    // costInline() should not end up being called when the index is
    // null.  If it is null, we let this method fail with a
    // NullPointerException.

    return 1 + right.costInline(thresh, env, ctx) + index.costInline(thresh, env, ctx);
  }
  /** Code */
  int codeLValue(Environment env, Context ctx, Assembler asm) {
    // codeLValue() should not end up being called when the index is
    // null.  If it is null, we let this method fail with a
    // NullPointerException.

    right.codeValue(env, ctx, asm);
    index.codeValue(env, ctx, asm);
    return 2;
  }
  public Expression inlineValue(Environment env, Context ctx) {
    // inlineValue() should not end up being called when the index is
    // null.  If it is null, we let this method fail with a
    // NullPointerException.

    right = right.inlineValue(env, ctx);
    index = index.inlineValue(env, ctx);
    return this;
  }
 /** Inline */
 public Expression inline(Environment env, Context ctx) {
   // It isn't possible to simply replace an array access
   // with a CommaExpression as happens with many binary
   // operators, because array accesses may have side effects
   // such as NullPointerException or IndexOutOfBoundsException.
   right = right.inlineValue(env, ctx);
   index = index.inlineValue(env, ctx);
   return this;
 }
 /** Print */
 public void print(PrintStream out) {
   out.print("(" + opNames[op] + " ");
   right.print(out);
   out.print(" ");
   if (index != null) {
     index.print(out);
   } else {
     out.print("<empty>");
   }
   out.print(")");
 }
 /** Create a copy of the expression for method inlining */
 public Expression copyInline(Context ctx) {
   ArrayAccessExpression e = (ArrayAccessExpression) clone();
   e.right = right.copyInline(ctx);
   if (index == null) {
     // The index can be null when this node is being used to
     // represent a type (e.g. Object[]) used in a cast expression.
     // We need to copy such structures without complaint.
     e.index = null;
   } else {
     e.index = index.copyInline(ctx);
   }
   return e;
 }
  /** Check expression type */
  public Vset checkValue(Environment env, Context ctx, Vset vset, Hashtable exp) {
    vset = right.checkValue(env, ctx, vset, exp);
    if (index == null) {
      env.error(where, "array.index.required");
      return vset;
    }
    vset = index.checkValue(env, ctx, vset, exp);
    index = convert(env, ctx, Type.tInt, index);

    if (!right.type.isType(TC_ARRAY)) {
      if (!right.type.isType(TC_ERROR)) {
        env.error(where, "not.array", right.type);
      }
      return vset;
    }

    type = right.type.getElementType();
    return vset;
  }