package net.sourceforge.phpdt.internal.compiler.ast;
+
/**
* An argument declaration.
* @author Matthieu Casanova
*/
public class ArgumentDeclaration extends VariableDeclaration {
+ /** The argument is a reference or not. */
public boolean reference;
+
/**
* Create an argument.
+ * @param name the name
+ * @param reference the variable is a reference ?
* @param initialization the initialization
+ * @param sourceStart the start point
+ */
+ public ArgumentDeclaration(final Variable name,
+ final boolean reference,
+ final Expression initialization,
+ final int sourceStart) {
+ super(name, initialization,VariableDeclaration.EQUAL, sourceStart);
+ this.reference = reference;
+ }
+
+ /**
+ * Create an argument.
* @param name the name
+ * @param reference the variable is a reference ?
* @param sourceStart the start point
- * @param sourceEnd the end point
*/
- public ArgumentDeclaration(Expression initialization,
- char[] name,
- int sourceStart,
- int sourceEnd,
- boolean reference) {
- super(initialization,name, sourceStart, sourceEnd);
- this.reference = reference;
+ public ArgumentDeclaration(final Variable name,
+ final boolean reference,
+ final int sourceStart) {
+ super(name, sourceStart);
+ this.reference = reference;
+ }
+ /**
+ * Return the expression as String.
+ * @return the expression
+ */
+ public String toStringExpression() {
+ final StringBuffer buff;
+ if (reference) {
+ buff = new StringBuffer("&");
+ } else {
+ buff = new StringBuffer();
+ }
+ buff.append(variable.toStringExpression());
+ if (initialization != null) {
+ buff.append(" = ");
+ buff.append(initialization.toStringExpression());
+ }
+ return buff.toString();
}
}