package net.sourceforge.phpdt.internal.compiler.ast;
+import java.util.List;
+import java.util.ArrayList;
+
/**
+ * A list expression.
+ * it could be list($v1,$v2), list(,$v2) ...
* @author Matthieu Casanova
*/
public class ListExpression extends Expression {
- public String[] vars;
+ public Expression[] vars;
public Expression expression;
- public ListExpression(String[] vars, Expression expression, int sourceStart, int sourceEnd) {
+ public ListExpression(final Expression[] vars,
+ final Expression expression,
+ final int sourceStart,
+ final int sourceEnd) {
super(sourceStart, sourceEnd);
this.vars = vars;
this.expression = expression;
}
+ public ListExpression(final Expression[] vars,
+ final int sourceStart,
+ final int sourceEnd) {
+ super(sourceStart, sourceEnd);
+ this.vars = vars;
+ }
+
/**
* Return the expression as String.
* @return the expression
public String toStringExpression() {
final StringBuffer buff = new StringBuffer("list(");
for (int i = 0; i < vars.length; i++) {
- String var = vars[i];
if (i != 0) {
buff.append(", ");
}
- if (var != null) {
- buff.append(vars);
+ if (vars[i] != null) {
+ buff.append(vars[i].toStringExpression());
}
}
if (expression != null) {
}
return buff.toString();
}
+
+ /**
+ * Get the variables from outside (parameters, globals ...)
+ * @return the variables from outside
+ */
+ public List getOutsideVariable() {
+ return new ArrayList(1);
+ }
+
+ /**
+ * get the modified variables.
+ * @return the variables from we change value
+ */
+ public List getModifiedVariable() {
+ final ArrayList list = new ArrayList();
+ for (int i = 0; i < vars.length; i++) {
+ if (vars[i] != null) {
+ list.addAll(vars[i].getUsedVariable());
+ }
+ }
+ if (expression != null) {
+ list.addAll(expression.getModifiedVariable());
+ }
+ return list;
+ }
+
+ /**
+ * Get the variables used.
+ * @return the variables used
+ */
+ public List getUsedVariable() {
+ if (expression == null) {
+ return new ArrayList(1);
+ }
+ return expression.getUsedVariable();
+ }
}