added a first php $f command to the PHP console
[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  * @author Matthieu Casanova
5  */
6 public class VarAssignation extends Expression {
7
8   public static final int EQUAL = 0;
9   public static final int PLUS_EQUAL = 1;
10   public static final int MINUS_EQUAL = 2;
11   public static final int STAR_EQUAL = 3;
12   public static final int SLASH_EQUAL = 4;
13   public static final int AND_EQUAL = 5;
14   public static final int OR_EQUAL = 6;
15   public static final int XOR_EQUAL = 7;
16   public static final int DOT_EQUAL = 8;
17   public static final int REM_EQUAL = 9;
18   public static final int TILDE_EQUAL = 10;
19   public static final int LSHIFT_EQUAL = 11;
20   public static final int RSIGNEDSHIFT_EQUAL = 12;
21
22   public char[] variable;
23   public Expression expression;
24   public int operator;
25
26
27   public VarAssignation(char[] variable,
28                         Expression expression,
29                         int operator,
30                         int sourceStart,
31                         int sourceEnd) {
32     super(sourceStart, sourceEnd);
33     this.variable = variable;
34     this.expression = expression;
35     this.operator = operator;
36   }
37
38   public String operatorToString() {
39     switch (operator) {
40       case EQUAL:
41         return "="; //$NON-NLS-1$
42       case PLUS_EQUAL:
43         return "+=";   //$NON-NLS-1$
44       case MINUS_EQUAL:
45         return "-=";   //$NON-NLS-1$
46       case STAR_EQUAL:
47         return "*="; //$NON-NLS-1$
48       case SLASH_EQUAL:
49         return "/="; //$NON-NLS-1$
50       case AND_EQUAL:
51         return "<="; //$NON-NLS-1$
52       case OR_EQUAL:
53         return "|=";//$NON-NLS-1$
54       case XOR_EQUAL:
55         return "^=";//$NON-NLS-1$
56       case DOT_EQUAL:
57         return ".="; //$NON-NLS-1$
58       case REM_EQUAL:
59         return "%="; //$NON-NLS-1$
60       case TILDE_EQUAL:
61         return " ="; //$NON-NLS-1$
62       case LSHIFT_EQUAL:
63         return "<<="; //$NON-NLS-1$
64       case RSIGNEDSHIFT_EQUAL:
65         return ">>="; //$NON-NLS-1$
66     }
67     return " unknown operator ";
68   }
69
70   /**
71    * Return the expression as String.
72    * @return the expression
73    */
74   public String toStringExpression() {
75     final StringBuffer buff = new StringBuffer();
76     buff.append(variable);
77     buff.append(' ');
78     buff.append(operatorToString());
79     buff.append(' ');
80     buff.append(expression.toStringExpression());
81     return buff.toString();
82   }
83 }