6b434d0cc2b00247a682af15ecd1b9cfcfb0722f
[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    */
49   public void getOutsideVariable(final List list) {
50   }
51
52   /**
53    * get the modified variables.
54    */
55   public void getModifiedVariable(final List list) {
56     expression.getModifiedVariable(list);
57   }
58
59   /**
60    * Get the variables used.
61    */
62   public void getUsedVariable(final List list) {
63     expression.getUsedVariable(list);
64   }
65 }