First try for AST structure. A lot of things to change
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpdt / internal / compiler / ast / CastExpression.java
diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/CastExpression.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/CastExpression.java
new file mode 100644 (file)
index 0000000..ec518ac
--- /dev/null
@@ -0,0 +1,42 @@
+package net.sourceforge.phpdt.internal.compiler.ast;
+
+/**
+ * This is a cast expression.
+ * @author Matthieu Casanova
+ */
+public class CastExpression extends Expression {
+
+  /** The type in which we cast the expression. */
+  public ConstantIdentifier type;
+
+  /** The expression to be casted. */
+  public Expression expression;
+
+  /**
+   * Create a cast expression.
+   * @param type the type
+   * @param expression the expression
+   * @param sourceStart starting offset
+   * @param sourceEnd ending offset
+   */
+  public CastExpression(ConstantIdentifier type,
+                        Expression expression,
+                        int sourceStart,
+                        int sourceEnd) {
+    super(sourceStart, sourceEnd);
+    this.type = type;
+    this.expression = expression;
+  }
+
+  /**
+   * Return the expression as String.
+   * @return the expression
+   */
+  public String toStringExpression() {
+    final StringBuffer buff = new StringBuffer('(');
+    buff.append(type.toStringExpression());
+    buff.append(") ");
+    buff.append(expression.toStringExpression());
+    return buff.toString();
+  }
+}