Пример #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);
  }
Пример #2
0
  public ThrowExpression(Expression expr) {
    super(1);

    object_print_method = class_print_method;

    children.add(expr);
    expr.setParent(this);
  }
Пример #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);
  }
Пример #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);
  }
Пример #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);
    }
  }
Пример #6
0
  public void addIndex(Expression expr) {
    if (expr.getParent() != null) throw new NotAnOrphanException();

    children.add(expr);
    expr.setParent(this);
  }
Пример #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);
  }
Пример #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);
 }