Пример #1
0
  /** 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);
  }
Пример #2
0
  /** 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;
  }
Пример #3
0
  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;
  }
Пример #4
0
 /** 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;
 }
Пример #5
0
 /** 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(")");
 }
Пример #6
0
 /** 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;
 }
Пример #7
0
  /** 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;
  }