MCPcopy Create free account
hub / github.com/beanshell/beanshell / intBinaryOperation

Method intBinaryOperation

src/bsh/Primitive.java:392–466  ·  view source on GitHub ↗
(Integer I1, Integer I2, int kind)

Source from the content-addressed store, hash-verified

390
391 // returns Object covering both Integer and Boolean return types
392 static Object intBinaryOperation(Integer I1, Integer I2, int kind)
393 {
394 int lhs = I1.intValue();
395 int rhs = I2.intValue();
396
397 switch(kind)
398 {
399 // boolean
400 case LT:
401 case LTX:
402 return lhs < rhs ? Boolean.TRUE : Boolean.FALSE;
403
404 case GT:
405 case GTX:
406 return lhs > rhs ? Boolean.TRUE : Boolean.FALSE;
407
408 case EQ:
409 return lhs == rhs ? Boolean.TRUE : Boolean.FALSE;
410
411 case LE:
412 case LEX:
413 return lhs <= rhs ? Boolean.TRUE : Boolean.FALSE;
414
415 case GE:
416 case GEX:
417 return lhs >= rhs ? Boolean.TRUE : Boolean.FALSE;
418
419 case NE:
420 return lhs != rhs ? Boolean.TRUE : Boolean.FALSE;
421
422 // arithmetic
423 case PLUS:
424 return new Integer(lhs + rhs);
425
426 case MINUS:
427 return new Integer(lhs - rhs);
428
429 case STAR:
430 return new Integer(lhs * rhs);
431
432 case SLASH:
433 return new Integer(lhs / rhs);
434
435 case MOD:
436 return new Integer(lhs % rhs);
437
438 // bitwise
439 case LSHIFT:
440 case LSHIFTX:
441 return new Integer(lhs << rhs);
442
443 case RSIGNEDSHIFT:
444 case RSIGNEDSHIFTX:
445 return new Integer(lhs >> rhs);
446
447 case RUNSIGNEDSHIFT:
448 case RUNSIGNEDSHIFTX:
449 return new Integer(lhs >>> rhs);

Callers 1

binaryOperationImplMethod · 0.95

Calls 1

intValueMethod · 0.80

Tested by

no test coverage detected