autoboxing & numeric promotion support for debugger evaluators: fixes in implicit...
[fedora-idea.git] / java / debugger / impl / src / com / intellij / debugger / engine / evaluation / expression / BinaryExpressionEvaluator.java
blob1c653301b25f3e66a2cf6f8e32838e781aafc16e
1 /*
2 * Copyright 2000-2009 JetBrains s.r.o.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
18 * Class BinaryExpressionEvaluator
19 * @author Jeka
21 package com.intellij.debugger.engine.evaluation.expression;
23 import com.intellij.debugger.DebuggerBundle;
24 import com.intellij.debugger.engine.evaluation.EvaluateException;
25 import com.intellij.debugger.engine.evaluation.EvaluateExceptionUtil;
26 import com.intellij.debugger.engine.evaluation.EvaluationContextImpl;
27 import com.intellij.debugger.impl.DebuggerUtilsEx;
28 import com.intellij.debugger.jdi.VirtualMachineProxyImpl;
29 import com.intellij.openapi.diagnostic.Logger;
30 import com.intellij.psi.JavaTokenType;
31 import com.intellij.psi.tree.IElementType;
32 import com.sun.jdi.*;
34 class BinaryExpressionEvaluator implements Evaluator {
35 private static final Logger LOG = Logger.getInstance("#com.intellij.debugger.engine.evaluation.expression.BinaryExpressionEvaluator");
36 private final Evaluator myLeftOperand;
37 private final Evaluator myRightOperand;
38 private final IElementType myOpType;
39 private final String myExpectedType; // a result of PsiType.getCanonicalText()
41 public BinaryExpressionEvaluator(Evaluator leftOperand, Evaluator rightOperand, IElementType opType, String expectedType) {
42 myLeftOperand = leftOperand;
43 myRightOperand = rightOperand;
44 myOpType = opType;
45 myExpectedType = expectedType;
48 public Modifier getModifier() {
49 return null;
52 public Object evaluate(EvaluationContextImpl context) throws EvaluateException {
53 Value leftResult = (Value)myLeftOperand.evaluate(context);
54 return evaluateOperation(leftResult, myOpType, myRightOperand, myExpectedType, context);
58 static Object evaluateOperation(final Value leftResult,
59 final IElementType opType,
60 final Evaluator rightOperand,
61 final String expectedType,
62 final EvaluationContextImpl context) throws EvaluateException {
63 VirtualMachineProxyImpl vm = context.getDebugProcess().getVirtualMachineProxy();
64 if (leftResult instanceof BooleanValue) {
65 boolean v1 = ((PrimitiveValue)leftResult).booleanValue();
66 if (opType == JavaTokenType.OROR && v1) {
67 return DebuggerUtilsEx.createValue(vm, expectedType, true);
69 if (opType == JavaTokenType.ANDAND && !v1) {
70 return DebuggerUtilsEx.createValue(vm, expectedType, false);
73 Value rightResult = (Value)rightOperand.evaluate(context);
74 if (opType == JavaTokenType.PLUS) {
75 if (DebuggerUtilsEx.isInteger(leftResult) && DebuggerUtilsEx.isInteger(rightResult)) {
76 final long v1 = ((PrimitiveValue)leftResult).longValue();
77 final long v2 = ((PrimitiveValue)rightResult).longValue();
78 return DebuggerUtilsEx.createValue(vm, expectedType, v1 + v2);
80 if (DebuggerUtilsEx.isNumeric(leftResult) && DebuggerUtilsEx.isNumeric(rightResult)) {
81 final double v1 = ((PrimitiveValue)leftResult).doubleValue();
82 final double v2 = ((PrimitiveValue)rightResult).doubleValue();
83 return DebuggerUtilsEx.createValue(vm, expectedType, v1 + v2);
85 if (leftResult instanceof CharValue && rightResult instanceof CharValue) {
86 char v1 = ((CharValue)leftResult).charValue();
87 char v2 = ((CharValue)rightResult).charValue();
88 return DebuggerUtilsEx.createValue(vm, expectedType, v1 + v2);
90 if (leftResult instanceof StringReference || rightResult instanceof StringReference) {
91 String v1 = DebuggerUtilsEx.getValueAsString(context, leftResult);
92 String v2 = DebuggerUtilsEx.getValueAsString(context, rightResult);
93 return vm.mirrorOf(v1 + v2);
95 throw EvaluateExceptionUtil.createEvaluateException(DebuggerBundle.message("evaluation.error.incompatible.types", "+"));
97 else if (opType == JavaTokenType.MINUS) {
98 if (DebuggerUtilsEx.isInteger(leftResult) && DebuggerUtilsEx.isInteger(rightResult)) {
99 final long v1 = ((PrimitiveValue)leftResult).longValue();
100 final long v2 = ((PrimitiveValue)rightResult).longValue();
101 return DebuggerUtilsEx.createValue(vm, expectedType, v1 - v2);
103 if (DebuggerUtilsEx.isNumeric(leftResult) && DebuggerUtilsEx.isNumeric(rightResult)) {
104 double v1 = ((PrimitiveValue)leftResult).doubleValue();
105 double v2 = ((PrimitiveValue)rightResult).doubleValue();
106 return DebuggerUtilsEx.createValue(vm, expectedType, v1 - v2);
108 if (leftResult instanceof CharValue && rightResult instanceof CharValue) {
109 char v1 = ((CharValue)leftResult).charValue();
110 char v2 = ((CharValue)rightResult).charValue();
111 return DebuggerUtilsEx.createValue(vm, expectedType, v1 - v2);
113 throw EvaluateExceptionUtil.createEvaluateException(DebuggerBundle.message("evaluation.error.incompatible.types", "-"));
115 else if (opType == JavaTokenType.ASTERISK) {
116 if (DebuggerUtilsEx.isInteger(leftResult) && DebuggerUtilsEx.isInteger(rightResult)) {
117 final long v1 = ((PrimitiveValue)leftResult).longValue();
118 final long v2 = ((PrimitiveValue)rightResult).longValue();
119 return DebuggerUtilsEx.createValue(vm, expectedType, v1 * v2);
121 if (DebuggerUtilsEx.isNumeric(leftResult) && DebuggerUtilsEx.isNumeric(rightResult)) {
122 double v1 = ((PrimitiveValue)leftResult).doubleValue();
123 double v2 = ((PrimitiveValue)rightResult).doubleValue();
124 return DebuggerUtilsEx.createValue(vm, expectedType, v1 * v2);
126 if (leftResult instanceof CharValue && rightResult instanceof CharValue) {
127 char v1 = ((CharValue)leftResult).charValue();
128 char v2 = ((CharValue)rightResult).charValue();
129 return DebuggerUtilsEx.createValue(vm, expectedType, v1 * v2);
131 throw EvaluateExceptionUtil.createEvaluateException(DebuggerBundle.message("evaluation.error.incompatible.types", "*"));
133 else if (opType == JavaTokenType.DIV) {
134 if (DebuggerUtilsEx.isInteger(leftResult) && DebuggerUtilsEx.isInteger(rightResult)) {
135 long v1 = ((PrimitiveValue)leftResult).longValue();
136 long v2 = ((PrimitiveValue)rightResult).longValue();
137 return DebuggerUtilsEx.createValue(vm, expectedType, v1 / v2);
139 if (DebuggerUtilsEx.isNumeric(leftResult) && DebuggerUtilsEx.isNumeric(rightResult)) {
140 double v1 = ((PrimitiveValue)leftResult).doubleValue();
141 double v2 = ((PrimitiveValue)rightResult).doubleValue();
142 return DebuggerUtilsEx.createValue(vm, expectedType, v1 / v2);
144 if (leftResult instanceof CharValue && rightResult instanceof CharValue) {
145 char v1 = ((CharValue)leftResult).charValue();
146 char v2 = ((CharValue)rightResult).charValue();
147 return DebuggerUtilsEx.createValue(vm, expectedType, v1 / v2);
149 throw EvaluateExceptionUtil.createEvaluateException(DebuggerBundle.message("evaluation.error.incompatible.types", "/"));
151 else if (opType == JavaTokenType.PERC) {
152 if (DebuggerUtilsEx.isInteger(leftResult) && DebuggerUtilsEx.isInteger(rightResult)) {
153 long v1 = ((PrimitiveValue)leftResult).longValue();
154 long v2 = ((PrimitiveValue)rightResult).longValue();
155 return DebuggerUtilsEx.createValue(vm, expectedType, v1 % v2);
157 if (DebuggerUtilsEx.isNumeric(leftResult) && DebuggerUtilsEx.isNumeric(rightResult)) {
158 double v1 = ((PrimitiveValue)leftResult).doubleValue();
159 double v2 = ((PrimitiveValue)rightResult).doubleValue();
160 return DebuggerUtilsEx.createValue(vm, expectedType, v1 % v2);
162 if (leftResult instanceof CharValue && rightResult instanceof CharValue) {
163 char v1 = ((CharValue)leftResult).charValue();
164 char v2 = ((CharValue)rightResult).charValue();
165 return DebuggerUtilsEx.createValue(vm, expectedType, v1 % v2);
167 throw EvaluateExceptionUtil.createEvaluateException(DebuggerBundle.message("evaluation.error.incompatible.types", "%"));
169 else if (opType == JavaTokenType.LTLT) {
170 if (DebuggerUtilsEx.isInteger(leftResult) && DebuggerUtilsEx.isInteger(rightResult)) {
171 final long v2 = ((PrimitiveValue)rightResult).longValue();
172 if (leftResult instanceof ByteValue) {
173 return DebuggerUtilsEx.createValue(vm, expectedType, ((ByteValue)leftResult).byteValue() << v2);
175 else if (leftResult instanceof ShortValue) {
176 return DebuggerUtilsEx.createValue(vm, expectedType, ((ShortValue)leftResult).shortValue() << v2);
178 else if (leftResult instanceof IntegerValue) {
179 return DebuggerUtilsEx.createValue(vm, expectedType, ((IntegerValue)leftResult).intValue() << v2);
181 return DebuggerUtilsEx.createValue(vm, expectedType, ((PrimitiveValue)leftResult).longValue() << v2);
183 if (leftResult instanceof CharValue && rightResult instanceof CharValue) {
184 return DebuggerUtilsEx.createValue(vm, expectedType, ((CharValue)leftResult).charValue() << ((CharValue)rightResult).charValue());
186 throw EvaluateExceptionUtil.createEvaluateException(DebuggerBundle.message("evaluation.error.incompatible.types", "<<"));
188 else if (opType == JavaTokenType.GTGT) {
189 if (DebuggerUtilsEx.isInteger(leftResult) && DebuggerUtilsEx.isInteger(rightResult)) {
190 final long v2 = ((PrimitiveValue)rightResult).longValue();
191 if (leftResult instanceof ByteValue) {
192 return DebuggerUtilsEx.createValue(vm, expectedType, ((ByteValue)leftResult).byteValue() >> v2);
194 else if (leftResult instanceof ShortValue) {
195 return DebuggerUtilsEx.createValue(vm, expectedType, ((ShortValue)leftResult).shortValue() >> v2);
197 else if (leftResult instanceof IntegerValue) {
198 return DebuggerUtilsEx.createValue(vm, expectedType, ((IntegerValue)leftResult).intValue() >> v2);
200 return DebuggerUtilsEx.createValue(vm, expectedType, ((PrimitiveValue)leftResult).longValue() >> v2);
202 if (leftResult instanceof CharValue && rightResult instanceof CharValue) {
203 return DebuggerUtilsEx.createValue(vm, expectedType, ((CharValue)leftResult).charValue() >> ((CharValue)rightResult).charValue());
205 throw EvaluateExceptionUtil.createEvaluateException(DebuggerBundle.message("evaluation.error.incompatible.types", ">>"));
207 else if (opType == JavaTokenType.GTGTGT) {
208 if (DebuggerUtilsEx.isInteger(leftResult) && DebuggerUtilsEx.isInteger(rightResult)) {
209 final long v2 = ((PrimitiveValue)rightResult).longValue();
210 if (leftResult instanceof ByteValue) {
211 return DebuggerUtilsEx.createValue(vm, expectedType, ((ByteValue)leftResult).byteValue() >>> v2);
213 else if (leftResult instanceof ShortValue) {
214 return DebuggerUtilsEx.createValue(vm, expectedType, ((ShortValue)leftResult).shortValue() >>> v2);
216 else if (leftResult instanceof IntegerValue) {
217 return DebuggerUtilsEx.createValue(vm, expectedType, ((IntegerValue)leftResult).intValue() >>> v2);
219 return DebuggerUtilsEx.createValue(vm, expectedType, ((PrimitiveValue)leftResult).longValue() >>> v2);
221 if (leftResult instanceof CharValue && rightResult instanceof CharValue) {
222 return DebuggerUtilsEx.createValue(vm, expectedType, ((CharValue)leftResult).charValue() >>> ((CharValue)rightResult).charValue());
224 throw EvaluateExceptionUtil.createEvaluateException(DebuggerBundle.message("evaluation.error.incompatible.types", ">>>"));
226 else if (opType == JavaTokenType.AND) {
227 if (DebuggerUtilsEx.isInteger(leftResult) && DebuggerUtilsEx.isInteger(rightResult)) {
228 long v1 = ((PrimitiveValue)leftResult).longValue();
229 long v2 = ((PrimitiveValue)rightResult).longValue();
230 return DebuggerUtilsEx.createValue(vm, expectedType, v1 & v2);
232 if (leftResult instanceof CharValue && rightResult instanceof CharValue) {
233 char v1 = ((CharValue)leftResult).charValue();
234 char v2 = ((CharValue)rightResult).charValue();
235 return DebuggerUtilsEx.createValue(vm, expectedType, v1 & v2);
237 if (leftResult instanceof BooleanValue && rightResult instanceof BooleanValue) {
238 boolean v1 = ((PrimitiveValue)leftResult).booleanValue();
239 boolean v2 = ((PrimitiveValue)rightResult).booleanValue();
240 return DebuggerUtilsEx.createValue(vm, expectedType, v1 & v2);
242 throw EvaluateExceptionUtil.createEvaluateException(DebuggerBundle.message("evaluation.error.incompatible.types", "&"));
244 else if (opType == JavaTokenType.OR) {
245 if (DebuggerUtilsEx.isInteger(leftResult) && DebuggerUtilsEx.isInteger(rightResult)) {
246 long v1 = ((PrimitiveValue)leftResult).longValue();
247 long v2 = ((PrimitiveValue)rightResult).longValue();
248 return DebuggerUtilsEx.createValue(vm, expectedType, v1 | v2);
250 if (leftResult instanceof CharValue && rightResult instanceof CharValue) {
251 char v1 = ((CharValue)leftResult).charValue();
252 char v2 = ((CharValue)rightResult).charValue();
253 return DebuggerUtilsEx.createValue(vm, expectedType, v1 | v2);
255 if (leftResult instanceof BooleanValue && rightResult instanceof BooleanValue) {
256 boolean v1 = ((PrimitiveValue)leftResult).booleanValue();
257 boolean v2 = ((PrimitiveValue)rightResult).booleanValue();
258 return DebuggerUtilsEx.createValue(vm, expectedType, v1 | v2);
260 throw EvaluateExceptionUtil.createEvaluateException(DebuggerBundle.message("evaluation.error.incompatible.types", "|"));
262 else if (opType == JavaTokenType.XOR) {
263 if (DebuggerUtilsEx.isInteger(leftResult) && DebuggerUtilsEx.isInteger(rightResult)) {
264 long v1 = ((PrimitiveValue)leftResult).longValue();
265 long v2 = ((PrimitiveValue)rightResult).longValue();
266 return DebuggerUtilsEx.createValue(vm, expectedType, v1 ^ v2);
268 if (leftResult instanceof CharValue && rightResult instanceof CharValue) {
269 char v1 = ((CharValue)leftResult).charValue();
270 char v2 = ((CharValue)rightResult).charValue();
271 return DebuggerUtilsEx.createValue(vm, expectedType, v1 ^ v2);
273 if (leftResult instanceof BooleanValue && rightResult instanceof BooleanValue) {
274 boolean v1 = ((PrimitiveValue)leftResult).booleanValue();
275 boolean v2 = ((PrimitiveValue)rightResult).booleanValue();
276 return DebuggerUtilsEx.createValue(vm, expectedType, v1 ^ v2);
278 throw EvaluateExceptionUtil.createEvaluateException(DebuggerBundle.message("evaluation.error.incompatible.types", "^"));
280 else if (opType == JavaTokenType.EQEQ) {
281 if (leftResult == null && rightResult == null) {
282 return DebuggerUtilsEx.createValue(vm, expectedType, true);
284 if (leftResult == null) {
285 return DebuggerUtilsEx.createValue(vm, expectedType, rightResult.equals(leftResult));
287 if (rightResult == null) {
288 return DebuggerUtilsEx.createValue(vm, expectedType, leftResult.equals(rightResult));
290 if (DebuggerUtilsEx.isInteger(leftResult) && DebuggerUtilsEx.isInteger(rightResult)) {
291 final long v1 = ((PrimitiveValue)leftResult).longValue();
292 final long v2 = ((PrimitiveValue)rightResult).longValue();
293 return DebuggerUtilsEx.createValue(vm, expectedType, v1 == v2);
295 if (DebuggerUtilsEx.isNumeric(leftResult) && DebuggerUtilsEx.isNumeric(rightResult)) {
296 double v1 = ((PrimitiveValue)leftResult).doubleValue();
297 double v2 = ((PrimitiveValue)rightResult).doubleValue();
298 return DebuggerUtilsEx.createValue(vm, expectedType, v1 == v2);
300 if (leftResult instanceof BooleanValue && rightResult instanceof BooleanValue) {
301 boolean v1 = ((PrimitiveValue)leftResult).booleanValue();
302 boolean v2 = ((PrimitiveValue)rightResult).booleanValue();
303 return DebuggerUtilsEx.createValue(vm, expectedType, v1 == v2);
305 if (leftResult instanceof CharValue && rightResult instanceof CharValue) {
306 char v1 = ((CharValue)leftResult).charValue();
307 char v2 = ((CharValue)rightResult).charValue();
308 return DebuggerUtilsEx.createValue(vm, expectedType, v1 == v2);
310 if (leftResult instanceof ObjectReference && rightResult instanceof ObjectReference) {
311 ObjectReference v1 = (ObjectReference)leftResult;
312 ObjectReference v2 = (ObjectReference)rightResult;
313 return DebuggerUtilsEx.createValue(vm, expectedType, v1.uniqueID() == v2.uniqueID());
315 throw EvaluateExceptionUtil.createEvaluateException(DebuggerBundle.message("evaluation.error.incompatible.types", "=="));
317 else if (opType == JavaTokenType.OROR) {
318 if (leftResult instanceof BooleanValue && rightResult instanceof BooleanValue) {
319 boolean v1 = ((PrimitiveValue)leftResult).booleanValue();
320 boolean v2 = ((PrimitiveValue)rightResult).booleanValue();
321 return DebuggerUtilsEx.createValue(vm, expectedType, v1 || v2);
323 throw EvaluateExceptionUtil.createEvaluateException(DebuggerBundle.message("evaluation.error.incompatible.types", "||"));
325 else if (opType == JavaTokenType.ANDAND) {
326 if (leftResult instanceof BooleanValue && rightResult instanceof BooleanValue) {
327 boolean v1 = ((PrimitiveValue)leftResult).booleanValue();
328 boolean v2 = ((PrimitiveValue)rightResult).booleanValue();
329 return DebuggerUtilsEx.createValue(vm, expectedType, v1 && v2);
331 throw EvaluateExceptionUtil.createEvaluateException(DebuggerBundle.message("evaluation.error.incompatible.types", "&&"));
333 else if (opType == JavaTokenType.NE) {
334 if (leftResult == null && rightResult == null) return DebuggerUtilsEx.createValue(vm, expectedType, false);
335 if (leftResult == null) return DebuggerUtilsEx.createValue(vm, expectedType, !rightResult.equals(leftResult));
336 if (rightResult == null) return DebuggerUtilsEx.createValue(vm, expectedType, !leftResult.equals(rightResult));
337 if (DebuggerUtilsEx.isInteger(leftResult) && DebuggerUtilsEx.isInteger(rightResult)) {
338 final long v1 = ((PrimitiveValue)leftResult).longValue();
339 final long v2 = ((PrimitiveValue)rightResult).longValue();
340 return DebuggerUtilsEx.createValue(vm, expectedType, v1 != v2);
342 if (DebuggerUtilsEx.isNumeric(leftResult) && DebuggerUtilsEx.isNumeric(rightResult)) {
343 double v1 = ((PrimitiveValue)leftResult).doubleValue();
344 double v2 = ((PrimitiveValue)rightResult).doubleValue();
345 return DebuggerUtilsEx.createValue(vm, expectedType, v1 != v2);
347 if (leftResult instanceof BooleanValue && rightResult instanceof BooleanValue) {
348 boolean v1 = ((PrimitiveValue)leftResult).booleanValue();
349 boolean v2 = ((PrimitiveValue)rightResult).booleanValue();
350 return DebuggerUtilsEx.createValue(vm, expectedType, v1 != v2);
352 if (leftResult instanceof CharValue && rightResult instanceof CharValue) {
353 char v1 = ((CharValue)leftResult).charValue();
354 char v2 = ((CharValue)rightResult).charValue();
355 return DebuggerUtilsEx.createValue(vm, expectedType, v1 != v2);
357 if (leftResult instanceof ObjectReference && rightResult instanceof ObjectReference) {
358 ObjectReference v1 = (ObjectReference)leftResult;
359 ObjectReference v2 = (ObjectReference)rightResult;
360 return DebuggerUtilsEx.createValue(vm, expectedType, v1.uniqueID() != v2.uniqueID());
362 throw EvaluateExceptionUtil.createEvaluateException(DebuggerBundle.message("evaluation.error.incompatible.types", "!="));
364 else if (opType == JavaTokenType.LT) {
365 if (DebuggerUtilsEx.isInteger(leftResult) && DebuggerUtilsEx.isInteger(rightResult)) {
366 final long v1 = ((PrimitiveValue)leftResult).longValue();
367 final long v2 = ((PrimitiveValue)rightResult).longValue();
368 return DebuggerUtilsEx.createValue(vm, expectedType, v1 < v2);
370 if (DebuggerUtilsEx.isNumeric(leftResult) && DebuggerUtilsEx.isNumeric(rightResult)) {
371 double v1 = ((PrimitiveValue)leftResult).doubleValue();
372 double v2 = ((PrimitiveValue)rightResult).doubleValue();
373 return DebuggerUtilsEx.createValue(vm, expectedType, v1 < v2);
375 if (leftResult instanceof CharValue && rightResult instanceof CharValue) {
376 char v1 = ((CharValue)leftResult).charValue();
377 char v2 = ((CharValue)rightResult).charValue();
378 return DebuggerUtilsEx.createValue(vm, expectedType, v1 < v2);
380 throw EvaluateExceptionUtil.createEvaluateException(DebuggerBundle.message("evaluation.error.incompatible.types", "<"));
382 else if (opType == JavaTokenType.GT) {
383 if (DebuggerUtilsEx.isInteger(leftResult) && DebuggerUtilsEx.isInteger(rightResult)) {
384 final long v1 = ((PrimitiveValue)leftResult).longValue();
385 final long v2 = ((PrimitiveValue)rightResult).longValue();
386 return DebuggerUtilsEx.createValue(vm, expectedType, v1 > v2);
388 if (DebuggerUtilsEx.isNumeric(leftResult) && DebuggerUtilsEx.isNumeric(rightResult)) {
389 double v1 = ((PrimitiveValue)leftResult).doubleValue();
390 double v2 = ((PrimitiveValue)rightResult).doubleValue();
391 return DebuggerUtilsEx.createValue(vm, expectedType, v1 > v2);
393 if (leftResult instanceof CharValue && rightResult instanceof CharValue) {
394 char v1 = ((CharValue)leftResult).charValue();
395 char v2 = ((CharValue)rightResult).charValue();
396 return DebuggerUtilsEx.createValue(vm, expectedType, v1 > v2);
398 throw EvaluateExceptionUtil.createEvaluateException(DebuggerBundle.message("evaluation.error.incompatible.types", ">"));
400 else if (opType == JavaTokenType.LE) {
401 if (DebuggerUtilsEx.isInteger(leftResult) && DebuggerUtilsEx.isInteger(rightResult)) {
402 final long v1 = ((PrimitiveValue)leftResult).longValue();
403 final long v2 = ((PrimitiveValue)rightResult).longValue();
404 return DebuggerUtilsEx.createValue(vm, expectedType, v1 <= v2);
406 if (DebuggerUtilsEx.isNumeric(leftResult) && DebuggerUtilsEx.isNumeric(rightResult)) {
407 double v1 = ((PrimitiveValue)leftResult).doubleValue();
408 double v2 = ((PrimitiveValue)rightResult).doubleValue();
409 return DebuggerUtilsEx.createValue(vm, expectedType, v1 <= v2);
411 if (leftResult instanceof CharValue && rightResult instanceof CharValue) {
412 char v1 = ((CharValue)leftResult).charValue();
413 char v2 = ((CharValue)rightResult).charValue();
414 return DebuggerUtilsEx.createValue(vm, expectedType, v1 <= v2);
416 throw EvaluateExceptionUtil.createEvaluateException(DebuggerBundle.message("evaluation.error.incompatible.types", "<="));
418 else if (opType == JavaTokenType.GE) {
419 if (DebuggerUtilsEx.isInteger(leftResult) && DebuggerUtilsEx.isInteger(rightResult)) {
420 final long v1 = ((PrimitiveValue)leftResult).longValue();
421 final long v2 = ((PrimitiveValue)rightResult).longValue();
422 return DebuggerUtilsEx.createValue(vm, expectedType, v1 >= v2);
424 if (DebuggerUtilsEx.isNumeric(leftResult) && DebuggerUtilsEx.isNumeric(rightResult)) {
425 double v1 = ((PrimitiveValue)leftResult).doubleValue();
426 double v2 = ((PrimitiveValue)rightResult).doubleValue();
427 return DebuggerUtilsEx.createValue(vm, expectedType, v1 >= v2);
429 if (leftResult instanceof CharValue && rightResult instanceof CharValue) {
430 char v1 = ((CharValue)leftResult).charValue();
431 char v2 = ((CharValue)rightResult).charValue();
432 return DebuggerUtilsEx.createValue(vm, expectedType, v1 >= v2);
434 throw EvaluateExceptionUtil.createEvaluateException(DebuggerBundle.message("evaluation.error.incompatible.types", ">="));
437 LOG.assertTrue(false);
439 return null;