public void execute(Handler handler) {
    int operand1;
    int operand2;
    int result;

    operand2 = ((Integer) handler.pop()).intValue();
    operand1 = ((Integer) handler.pop()).intValue();
    if (operand2 > 0) {
      result = operand1 << operand2;
    } else {
      result = operand1 >> -operand2;
    }
    handler.push(new Integer(result));
  }
예제 #2
0
 @Override
 public void execute(Handler handler) throws ParseException {
   Object o2 = handler.pop();
   Object o1 = handler.pop();
   if (o1 instanceof Number && o2 instanceof Number) {
     handler.push(((Number) o1).doubleValue() <= ((Number) o2).doubleValue());
     return;
   }
   if (o1 instanceof String && o2 instanceof String) {
     handler.push(((String) o1).compareTo((String) o2) <= 0);
     return;
   }
   throw new ParseException("operandes to not comparable");
 }
예제 #3
0
 @Override
 public void execute(Handler handler) {
   Object o1 = handler.pop();
   Object o2 = handler.pop();
   handler.push(o1.equals(o2));
 }