+++ /dev/null
-package net.sourceforge.phpdt.internal.compiler.ast;
-
-import net.sourceforge.phpeclipse.PHPeclipsePlugin;
-
-import java.util.List;
-import java.util.ArrayList;
-
-/**
- * A Variable assignation.
- * $varname = initializer
- * @author Matthieu Casanova
- */
-public class VarAssignation extends Expression {
-
- public static final int EQUAL = 0;
- public static final int PLUS_EQUAL = 1;
- public static final int MINUS_EQUAL = 2;
- public static final int STAR_EQUAL = 3;
- public static final int SLASH_EQUAL = 4;
- public static final int AND_EQUAL = 5;
- public static final int OR_EQUAL = 6;
- public static final int XOR_EQUAL = 7;
- public static final int DOT_EQUAL = 8;
- public static final int REM_EQUAL = 9;
- public static final int TILDE_EQUAL = 10;
- public static final int LSHIFT_EQUAL = 11;
- public static final int RSIGNEDSHIFT_EQUAL = 12;
-
- public Expression variableName;
- public Expression initializer;
- public int operator;
-
- /**
- * Create a new variable assignation.
- * @param variableName the name of the variable
- * @param initializer the expression in initializer
- * @param operator the operator of assignation
- * @param sourceStart the sourceStart
- * @param sourceEnd the sourceEnd
- */
- public VarAssignation(final Expression variableName,
- final Expression initializer,
- final int operator,
- final int sourceStart,
- final int sourceEnd) {
- super(sourceStart, sourceEnd);
- this.variableName = variableName;
- this.initializer = initializer;
- this.operator = operator;
- }
-
- /**
- * Return the operator as String.
- * @return the operator
- */
- public final String operatorToString() {
- switch (operator) {
- case EQUAL:
- return "="; //$NON-NLS-1$
- case PLUS_EQUAL:
- return "+="; //$NON-NLS-1$
- case MINUS_EQUAL:
- return "-="; //$NON-NLS-1$
- case STAR_EQUAL:
- return "*="; //$NON-NLS-1$
- case SLASH_EQUAL:
- return "/="; //$NON-NLS-1$
- case AND_EQUAL:
- return "<="; //$NON-NLS-1$
- case OR_EQUAL:
- return "|=";//$NON-NLS-1$
- case XOR_EQUAL:
- return "^=";//$NON-NLS-1$
- case DOT_EQUAL:
- return ".="; //$NON-NLS-1$
- case REM_EQUAL:
- return "%="; //$NON-NLS-1$
- case TILDE_EQUAL:
- return "~="; //$NON-NLS-1$
- case LSHIFT_EQUAL:
- return "<<="; //$NON-NLS-1$
- case RSIGNEDSHIFT_EQUAL:
- return ">>="; //$NON-NLS-1$
- }
- return " unknown operator ";//$NON-NLS-1$
- }
-
- /**
- * Return the expression as String.
- * @return the expression
- */
- public String toStringExpression() {
- final String varName = variableName.toStringExpression();
- final String init = initializer.toStringExpression();
- final String operatorString = operatorToString();
- final StringBuffer buff = new StringBuffer(varName.length() + operatorString.length() + init.length() + 2);
- buff.append(varName);
- buff.append(" ");//$NON-NLS-1$
- buff.append(operatorString);
- buff.append(" ");//$NON-NLS-1$
- buff.append(init);
- return buff.toString();
- }
-
-
- /**
- * Get the variables from outside (parameters, globals ...)
- * @return the variables from outside
- */
- public List getOutsideVariable() {
- return new ArrayList();
- }
-
- /**
- * get the modified variables.
- * @return the variables from we change value
- */
- public List getModifiedVariable() {
- final ArrayList list = new ArrayList();
- list.addAll(variableName.getUsedVariable());
- list.addAll(initializer.getModifiedVariable());
- return list;
- }
-
- /**
- * Get the variables used.
- * @return the variables used
- */
- public List getUsedVariable() {
- final ArrayList list = new ArrayList();
- list.addAll(initializer.getUsedVariable());
- return list;
- }
-}