KickJava   Java API By Example, From Geeks To Geeks.

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


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 PrefixPlusPlusOperator extends XfixOperator {
18     
19     public PrefixPlusPlusOperator(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         
29         switch (fVariableTypeId) {
30             case T_byte :
31                 variable.setValue(newValue((byte)(((IJavaPrimitiveValue)variable.getValue()).getByteValue() + 1)));
32                 break;
33             case T_short :
34                 variable.setValue(newValue((short)(((IJavaPrimitiveValue)variable.getValue()).getShortValue() + 1)));
35                 break;
36             case T_char :
37                 variable.setValue(newValue((char)(((IJavaPrimitiveValue)variable.getValue()).getCharValue() + 1)));
38                 break;
39             case T_int :
40                 variable.setValue(newValue(((IJavaPrimitiveValue)variable.getValue()).getIntValue() + 1));
41                 break;
42             case T_long :
43                 variable.setValue(newValue(((IJavaPrimitiveValue)variable.getValue()).getLongValue() + 1));
44                 break;
45             case T_float :
46                 variable.setValue(newValue(((IJavaPrimitiveValue)variable.getValue()).getFloatValue() + 1));
47                 break;
48             case T_double :
49                 variable.setValue(newValue(((IJavaPrimitiveValue)variable.getValue()).getDoubleValue() + 1));
50                 break;
51         }
52
53         push(variable.getValue());
54     }
55
56     public String JavaDoc toString() {
57         return InstructionsEvaluationMessages.PrefixPlusPlusOperator_prefix________operator_1;
58     }
59
60 }
61
Popular Tags