Esempio n. 1
0
  /**
   * Creates an array access with a single index expression.
   *
   * @param array An expression evaluating to an address.
   * @param index The expression with which to index the array.
   */
  public ArrayAccess(Expression array, Expression index) {
    super(2);

    object_print_method = class_print_method;

    children.add(array);
    array.setParent(this);

    children.add(index);
    index.setParent(this);
  }
Esempio n. 2
0
  public ThrowExpression(Expression expr) {
    super(1);

    object_print_method = class_print_method;

    children.add(expr);
    expr.setParent(this);
  }
Esempio n. 3
0
  public OffsetofExpression(List<Specifier> pspecs, Expression expr) {
    object_print_method = class_print_method;

    children.add(expr);
    expr.setParent(this);

    specs = new LinkedList<Specifier>();
    specs.addAll(pspecs);
  }
Esempio n. 4
0
  /**
   * Creates an array access with multiple index expressions.
   *
   * @param array An expression evaluating to an address.
   * @param indices A list of expressions with which to index the array.
   */
  public ArrayAccess(Expression array, List indices) {
    super(indices.size() + 1);

    object_print_method = class_print_method;

    children.add(array);
    array.setParent(this);

    setIndices(indices);
  }
Esempio n. 5
0
  /**
   * Set the list of index expressions.
   *
   * @param indices A list of expressions.
   */
  public void setIndices(List indices) {
    /* clear out everything but the first item */
    Expression name = (Expression) children.get(0);
    children.clear();
    children.add(name);

    Iterator iter = indices.iterator();
    while (iter.hasNext()) {
      Expression expr = null;
      try {
        expr = (Expression) iter.next();
      } catch (ClassCastException e) {
        throw new IllegalArgumentException();
      }

      children.add(expr);
      expr.setParent(this);
    }
  }
Esempio n. 6
0
  public void addIndex(Expression expr) {
    if (expr.getParent() != null) throw new NotAnOrphanException();

    children.add(expr);
    expr.setParent(this);
  }
Esempio n. 7
0
  /**
   * Sets the nth index expression of this array access.
   *
   * @param n The position of the index expression.
   * @param expr The expression to use for the index.
   * @throws IndexOutOfBoundsException if there is no expression at that position.
   */
  public void setIndex(int n, Expression expr) {
    if (expr.getParent() != null) throw new NotAnOrphanException();

    children.set(n + 1, expr);
    expr.setParent(this);
  }
Esempio n. 8
0
 /**
  * Creates a statement that returns an expression.
  *
  * @param expr The expression to return.
  */
 public ReturnStatement(Expression expr) {
   object_print_method = class_print_method;
   children.add(expr);
   expr.setParent(this);
 }