KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > jdt > internal > debug > eval > ast > instructions > PostfixPlusPlusOperator


1 /*******************************************************************************
2  * Copyright (c) 2000, 2005 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.jdt.internal.debug.eval.ast.instructions;
12
13 import org.eclipse.core.runtime.CoreException;
14 import org.eclipse.jdt.debug.core.IJavaPrimitiveValue;
15 import org.eclipse.jdt.debug.core.IJavaVariable;
16
17 public class PostfixPlusPlusOperator extends XfixOperator {
18     
19     public PostfixPlusPlusOperator(int variableTypeId, int start) {
20         super(variableTypeId, start);
21     }
22
23     /*
24      * @see Instruction#execute()
25      */

26     public void execute() throws CoreException {
27         IJavaVariable variable = (IJavaVariable) pop();
28         push(variable.getValue());
29         
30         switch (fVariableTypeId) {
31             case T_byte :
32                 variable.setValue(newValue((byte)(((IJavaPrimitiveValue)variable.getValue()).getByteValue() + 1)));
33                 break;
34             case T_short :
35                 variable.setValue(newValue((short)(((IJavaPrimitiveValue)variable.getValue()).getShortValue() + 1)));
36                 break;
37             case T_char :
38                 variable.setValue(newValue((char)(((IJavaPrimitiveValue)variable.getValue()).getCharValue() + 1)));
39                 break;
40             case T_int :
41                 variable.setValue(newValue(((IJavaPrimitiveValue)variable.getValue()).getIntValue() + 1));
42                 break;
43             case T_long :
44                 variable.setValue(newValue(((IJavaPrimitiveValue)variable.getValue()).getLongValue() + 1));
45                 break;
46             case T_float :
47                 variable.setValue(newValue(((IJavaPrimitiveValue)variable.getValue()).getFloatValue() + 1));
48                 break;
49             case T_double :
50                 variable.setValue(newValue(((IJavaPrimitiveValue)variable.getValue()).getDoubleValue() + 1));
51                 break;
52         }
53     }
54
55     public String JavaDoc toString() {
56         return InstructionsEvaluationMessages.PostfixPlusPlusOperator_postfix________operator_1;
57     }
58
59 }
60
Popular Tags