8291f624c56ebb7e609d14d0ca61bbed1ac1b90b
[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 import java.util.ArrayList;
5
6 /**
7  * This is a cast expression.
8  * @author Matthieu Casanova
9  */
10 public class CastExpression extends Expression {
11
12   /** The type in which we cast the expression. */
13   public ConstantIdentifier type;
14
15   /** The expression to be casted. */
16   public Expression expression;
17
18   /**
19    * Create a cast expression.
20    * @param type the type
21    * @param expression the expression
22    * @param sourceStart starting offset
23    * @param sourceEnd ending offset
24    */
25   public CastExpression(final ConstantIdentifier type,
26                         final Expression expression,
27                         final int sourceStart,
28                         final int sourceEnd) {
29     super(sourceStart, sourceEnd);
30     this.type = type;
31     this.expression = expression;
32   }
33
34   /**
35    * Return the expression as String.
36    * @return the expression
37    */
38   public String toStringExpression() {
39     final StringBuffer buff = new StringBuffer("(");
40     buff.append(type.toStringExpression());
41     buff.append(") ");
42     buff.append(expression.toStringExpression());
43     return buff.toString();
44   }
45
46       /**
47    * Get the variables from outside (parameters, globals ...)
48    * @return the variables from outside
49    */
50   public List getOutsideVariable() {
51     return new ArrayList();
52   }
53
54   /**
55    * get the modified variables.
56    * @return the variables from we change value
57    */
58   public List getModifiedVariable() {
59     return expression.getModifiedVariable();
60   }
61
62   /**
63    * Get the variables used.
64    * @return the variables used
65    */
66   public List getUsedVariable() {
67     return expression.getUsedVariable();
68   }
69 }