3.x RC1 compatibility
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpdt / internal / compiler / ast / CastExpression.java
1 package net.sourceforge.phpdt.internal.compiler.ast;
2
3 import java.util.List;
4
5 /**
6  * This is a cast expression.
7  * @author Matthieu Casanova
8  */
9 public final class CastExpression extends Expression {
10
11   /** The type in which we cast the expression. */
12   private final ConstantIdentifier type;
13
14   /** The expression to be casted. */
15   private final Expression expression;
16
17   /**
18    * Create a cast expression.
19    * @param type the type
20    * @param expression the expression
21    * @param sourceStart starting offset
22    * @param sourceEnd ending offset
23    */
24   public CastExpression(final ConstantIdentifier type,
25                         final Expression expression,
26                         final int sourceStart,
27                         final int sourceEnd) {
28     super(sourceStart, sourceEnd);
29     this.type = type;
30     this.expression = expression;
31   }
32
33   /**
34    * Return the expression as String.
35    * @return the expression
36    */
37   public String toStringExpression() {
38     final StringBuffer buff = new StringBuffer("(");
39     buff.append(type.toStringExpression());
40     buff.append(") ");
41     buff.append(expression.toStringExpression());
42     return buff.toString();
43   }
44
45   /**
46    * Get the variables from outside (parameters, globals ...)
47    *
48    * @param list the list where we will put variables
49    */
50   public void getOutsideVariable(final List list) {}
51
52   /**
53    * get the modified variables.
54    *
55    * @param list the list where we will put variables
56    */
57   public void getModifiedVariable(final List list) {
58     expression.getModifiedVariable(list);
59   }
60
61   /**
62    * Get the variables used.
63    *
64    * @param list the list where we will put variables
65    */
66   public void getUsedVariable(final List list) {
67     expression.getUsedVariable(list);
68   }
69 }