KickJava   Java API By Example, From Geeks To Geeks.

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


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.jdt.debug.core.IJavaPrimitiveValue;
14 import org.eclipse.jdt.debug.core.IJavaValue;
15
16 public class LeftShiftOperator extends BinaryOperator {
17     public LeftShiftOperator(int resultId, int leftTypeId, int rightTypeId, int start) {
18         this(resultId, leftTypeId, rightTypeId, false, start);
19     }
20
21     protected LeftShiftOperator(int resultId, int leftTypeId, int rightTypeId, boolean isAssignmentOperator, int start) {
22         super(resultId, leftTypeId, rightTypeId, isAssignmentOperator, start);
23     }
24
25     /*
26      * @see BinaryOperator#getBooleanResult(IJavaValue, IJavaValue)
27      */

28     protected boolean getBooleanResult(IJavaValue leftOperand, IJavaValue rightOperand) {
29         return false;
30     }
31
32     /*
33      * @see BinaryOperator#getDoubleResult(IJavaValue, IJavaValue)
34      */

35     protected double getDoubleResult(IJavaValue leftOperand, IJavaValue rightOperand) {
36         return 0;
37     }
38
39     /*
40      * @see BinaryOperator#getFloatResult(IJavaValue, IJavaValue)
41      */

42     protected float getFloatResult(IJavaValue leftOperand, IJavaValue rightOperand) {
43         return 0;
44     }
45
46     /*
47      * @see BinaryOperator#getIntResult(IJavaValue, IJavaValue)
48      */

49     protected int getIntResult(IJavaValue leftOperand, IJavaValue rightOperand) {
50         // unary type promotion on both operands see 5.6.1 and 15.18
51
switch (fRightTypeId) {
52             case T_long :
53                 return ((IJavaPrimitiveValue) leftOperand).getIntValue() << ((IJavaPrimitiveValue) rightOperand).getLongValue();
54             case T_int :
55             case T_short :
56             case T_byte :
57             case T_char :
58                 return ((IJavaPrimitiveValue) leftOperand).getIntValue() << ((IJavaPrimitiveValue) rightOperand).getIntValue();
59             default :
60                 return 0;
61         }
62     }
63
64     /*
65      * @see BinaryOperator#getLongResult(IJavaValue, IJavaValue)
66      */

67     protected long getLongResult(IJavaValue leftOperand, IJavaValue rightOperand) {
68         // unary type promotion on both operands see 5.6.1 and 15.18
69
switch (fRightTypeId) {
70             case T_long :
71                 return ((IJavaPrimitiveValue) leftOperand).getLongValue() << ((IJavaPrimitiveValue) rightOperand).getLongValue();
72             case T_int :
73             case T_short :
74             case T_byte :
75             case T_char :
76                 return ((IJavaPrimitiveValue) leftOperand).getLongValue() << ((IJavaPrimitiveValue) rightOperand).getIntValue();
77             default :
78                 return 0;
79         }
80     }
81
82     /*
83      * @see BinaryOperator#getStringResult(IJavaValue, IJavaValue)
84      */

85     protected String JavaDoc getStringResult(IJavaValue leftOperand, IJavaValue rightOperand) {
86         return null;
87     }
88
89     protected int getInternResultType() {
90         // unary type promotion on both operands see 5.6.1 and 15.18
91
return getUnaryPromotionType(fLeftTypeId);
92     }
93
94     public String JavaDoc toString() {
95         return InstructionsEvaluationMessages.LeftShiftOperator_______operator_1;
96     }
97
98 }
99
Popular Tags