1 package net.sourceforge.phpdt.internal.compiler.ast;
3 import net.sourceforge.phpdt.internal.compiler.ast.declarations.VariableUsage;
6 import java.util.ArrayList;
9 * an array initializer.
10 * array('a','b','c') or array('a' => 2,'b' = '3');
11 * @author Matthieu Casanova
13 public class ArrayInitializer extends Expression {
15 public ArrayVariableDeclaration[] vars;
17 public ArrayInitializer(final ArrayVariableDeclaration[] vars,
18 final int sourceStart,
19 final int sourceEnd) {
20 super(sourceStart, sourceEnd);
25 * Return the expression as String.
26 * @return the expression
28 public String toStringExpression() {
29 final StringBuffer buff = new StringBuffer("array(");
30 for (int i = 0; i < vars.length; i++) {
34 if (vars[i] != null) {
35 buff.append(vars[i].toStringExpression());
39 return buff.toString();
43 * Get the variables from outside (parameters, globals ...)
45 public void getOutsideVariable(final List list) {
49 * get the modified variables.
51 public void getModifiedVariable(final List list) {
52 for (int i = 0; i < vars.length; i++) {
53 if (vars[i] != null) {
54 vars[i].getModifiedVariable(list);
60 * Get the variables used.
62 public void getUsedVariable(final List list) {
63 for (int i = 0; i < vars.length; i++) {
64 if (vars[i] != null) {
65 vars[i].getUsedVariable(list);