1 package net.sourceforge.phpdt.internal.compiler.ast;
4 * A Variable assignation.
5 * $varname = initializer
6 * @author Matthieu Casanova
8 public class VarAssignation extends Expression {
10 public static final int EQUAL = 0;
11 public static final int PLUS_EQUAL = 1;
12 public static final int MINUS_EQUAL = 2;
13 public static final int STAR_EQUAL = 3;
14 public static final int SLASH_EQUAL = 4;
15 public static final int AND_EQUAL = 5;
16 public static final int OR_EQUAL = 6;
17 public static final int XOR_EQUAL = 7;
18 public static final int DOT_EQUAL = 8;
19 public static final int REM_EQUAL = 9;
20 public static final int TILDE_EQUAL = 10;
21 public static final int LSHIFT_EQUAL = 11;
22 public static final int RSIGNEDSHIFT_EQUAL = 12;
24 public Expression variableName;
25 public Expression initializer;
29 * Create a new variable assignation.
30 * @param variableName the name of the variable
31 * @param initializer the expression in initializer
32 * @param operator the operator of assignation
33 * @param sourceStart the sourceStart
34 * @param sourceEnd the sourceEnd
36 public VarAssignation(final Expression variableName,
37 final Expression initializer,
39 final int sourceStart,
40 final int sourceEnd) {
41 super(sourceStart, sourceEnd);
42 this.variableName = variableName;
43 this.initializer = initializer;
44 this.operator = operator;
48 * Return the operator as String.
49 * @return the operator
51 public final String operatorToString() {
54 return "="; //$NON-NLS-1$
56 return "+="; //$NON-NLS-1$
58 return "-="; //$NON-NLS-1$
60 return "*="; //$NON-NLS-1$
62 return "/="; //$NON-NLS-1$
64 return "<="; //$NON-NLS-1$
66 return "|=";//$NON-NLS-1$
68 return "^=";//$NON-NLS-1$
70 return ".="; //$NON-NLS-1$
72 return "%="; //$NON-NLS-1$
74 return " ="; //$NON-NLS-1$
76 return "<<="; //$NON-NLS-1$
77 case RSIGNEDSHIFT_EQUAL:
78 return ">>="; //$NON-NLS-1$
80 return " unknown operator ";//$NON-NLS-1$
84 * Return the expression as String.
85 * @return the expression
87 public String toStringExpression() {
88 final StringBuffer buff = new StringBuffer(variableName.toStringExpression());
89 buff.append(" ");//$NON-NLS-1$
90 buff.append(operatorToString());
91 buff.append(" ");//$NON-NLS-1$
92 buff.append(initializer.toStringExpression());
93 return buff.toString();