PHP obfuscator gets it's ignored identifiers from an "obfuscator.xml" file
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpdt / internal / compiler / ast / VarAssignation.java
1 package net.sourceforge.phpdt.internal.compiler.ast;
2
3 /**
4  * A Variable assignation.
5  * $varname = initializer
6  * @author Matthieu Casanova
7  */
8 public class VarAssignation extends Expression {
9
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;
23
24   public Expression variableName;
25   public Expression initializer;
26   public int operator;
27
28   /**
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
35    */
36   public VarAssignation(final Expression variableName,
37                         final Expression initializer,
38                         final int operator,
39                         final int sourceStart,
40                         final int sourceEnd) {
41     super(sourceStart, sourceEnd);
42     this.variableName = variableName;
43     this.initializer = initializer;
44     this.operator = operator;
45   }
46
47   /**
48    * Return the operator as String.
49     * @return the operator
50    */
51   public final String operatorToString() {
52     switch (operator) {
53       case EQUAL:
54         return "="; //$NON-NLS-1$
55       case PLUS_EQUAL:
56         return "+=";   //$NON-NLS-1$
57       case MINUS_EQUAL:
58         return "-=";   //$NON-NLS-1$
59       case STAR_EQUAL:
60         return "*="; //$NON-NLS-1$
61       case SLASH_EQUAL:
62         return "/="; //$NON-NLS-1$
63       case AND_EQUAL:
64         return "<="; //$NON-NLS-1$
65       case OR_EQUAL:
66         return "|=";//$NON-NLS-1$
67       case XOR_EQUAL:
68         return "^=";//$NON-NLS-1$
69       case DOT_EQUAL:
70         return ".="; //$NON-NLS-1$
71       case REM_EQUAL:
72         return "%="; //$NON-NLS-1$
73       case TILDE_EQUAL:
74         return "~="; //$NON-NLS-1$
75       case LSHIFT_EQUAL:
76         return "<<="; //$NON-NLS-1$
77       case RSIGNEDSHIFT_EQUAL:
78         return ">>="; //$NON-NLS-1$
79     }
80     return " unknown operator ";//$NON-NLS-1$
81   }
82
83   /**
84    * Return the expression as String.
85    * @return the expression
86    */
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();
94   }
95 }