org.eclipse.jem.proxy_2.0.400.v201101101900

ublic final void pushExpressionProxy(int proxyid)
  {
    boolean ignore = (ignoreExpression != null) || (errorOccurred);
    if (traceOn) {
      printTrace("Push Expression Proxy #" + proxyid, ignore);
    }
    try
    {
      if (ignore) {
        return;
      }
      if ((expressionProxies != null) && (expressionProxies.size() > proxyid))
      {
        InternalExpressionProxy proxy = (InternalExpressionProxy)expressionProxies.get(proxyid);
        if ((proxy != null) && (proxy.isSet()))
        {
          if (traceOn) {
            printObjectAndType(proxy.getValue(), proxy.getType());
          }
          pushExpressionValue(proxy.getValue(), proxy.getType());
        }
        else
        {
          processException(new NoExpressionValueException("Proxy id: " + proxyid));
        }
      }
      else
      {
        processException(new NoExpressionValueException("Proxy id: " + proxyid));
      }
    }
    finally
    {
      if (traceOn) {
        printTraceEnd();
      }
    }
    jsr -15;
  }
  
  public final void pushCast(Class type)
  {
    boolean ignore = (ignoreExpression != null) || (errorOccurred);
    if (traceOn) {
      printTrace("Cast to: " + type, ignore);
    }
    try
    {
      if (ignore) {
        return;
      }
      try
      {
        Object exp = popExpression();
        Class exptype = popExpressionType(false);
        
        pushExpressionValue(castBean(type, exp, exptype), type);
      }
      catch (RuntimeException e)
      {
        processException(e);
      }
      catch (NoExpressionValueException e)
      {
        processException(e);
      }
    }
    finally
    {
      if (traceOn) {
        printTraceEnd();
      }
    }
  }
  
  protected final Object castBean(Class returnType, Object bean, Class beanType)
    throws ClassCastException
  {
    if (bean == null)
    {
      if (!returnType.isPrimitive()) {
        return bean;
      }
      throwClassCast(returnType, bean);
    }
    else
    {
      if (returnType.equals(bean.getClass())) {
        return bean;
      }
      if (!returnType.isPrimitive())
      {
        if ((!beanType.isPrimitive()) && (returnType.isInstance(bean))) {
          return bean;
        }
        throwClassCast(returnType, bean);
      }
      else
      {
        if (!beanType.isPrimitive()) {
          throwClassCast(returnType, bean);
        }
        if (returnType == Boolean.TYPE)
        {
          if ((bean instanceof Boolean)) {
            return bean;
          }
          throwClassCast(returnType, bean);
        }
        else if ((bean instanceof Number))
        {
          if (returnType == Integer.TYPE)
          {
            if ((bean instanceof Integer)) {
              return bean;
            }
            return new Integer(((Number)bean).intValue());
          }
          if (returnType == Byte.TYPE)
          {
            if ((bean instanceof Byte)) {
              return bean;
            }
            return new Byte(((Number)bean).byteValue());
          }
          if (returnType == Character.TYPE)
          {
            if ((bean instanceof Character)) {
              return bean;
            }
            return new Character((char)((Number)bean).intValue());
          }
          if (returnType == Double.TYPE)
          {
            if ((bean instanceof Double)) {
              return bean;
            }
            return new Double(((Number)bean).doubleValue());
          }
          if (returnType == Float.TYPE)
          {
            if ((bean instanceof Float)) {
              return bean;
            }
            return new Float(((Number)bean).floatValue());
          }
          if (returnType == Long.TYPE)
          {
            if ((bean instanceof Long)) {
              return bean;
            }
            return new Long(((Number)bean).longValue());
          }
          if (returnType == Short.TYPE)
          {
            if ((bean instanceof Short)) {
              return bean;
            }
            return new Short(((Number)bean).shortValue());
          }
          throwClassCast(returnType, bean);
        }
        else if ((bean instanceof Character))
        {
          if (returnType == Character.TYPE) {
            return bean;
          }
          if (returnType == Integer.TYPE) {
            return new Integer(((Character)bean).charValue());
          }
          if (returnType == Byte.TYPE) {
            return new Byte((byte)((Character)bean).charValue());
          }
          if (returnType == Double.TYPE) {
            return new Double(((Character)bean).charValue());
          }
          if (returnType == Float.TYPE) {
            return new Float(((Character)bean).charValue());
          }
          if (returnType == Long.TYPE) {
            return new Long(((Character)bean).charValue());
          }
          if (returnType == Short.TYPE) {
            return new Short((short)((Character)bean).charValue());
          }
          throwClassCast(returnType, bean);
        }
        else
        {
          throwClassCast(returnType, bean);
        }
      }
    }
    return null;
  }
  
  private void throwClassCast(Class returnType, Object bean)
    throws ClassCastException
  {
    throw new ClassCastException(MessageFormat.format(InitparserTreeMessages.getString("ExpressionProcesser.CannotCastXToY_EXC_"), new Object[] { bean != null ? bean.getClass().getName() : null, returnType.getName() }));
  }
  
  protected final Class getPrimitiveType(Object bean)
    throws IllegalArgumentException
  {
    if ((bean instanceof Boolean)) {
      return Boolean.TYPE;
    }
    if ((bean instanceof Integer)) {
      return Integer.TYPE;
    }
    if ((bean instanceof Byte)) {
      return Byte.TYPE;
    }
    if ((bean instanceof Character)) {
      return Character.TYPE;
    }
    if ((bean instanceof Double)) {
      return Double.TYPE;
    }
    if ((bean instanceof Float)) {
      return Float.TYPE;
    }
    if ((bean instanceof Long)) {
      return Long.TYPE;
    }
    if ((bean instanceof Short)) {
      return Short.TYPE;
    }
    throw new IllegalArgumentException(bean != null ? bean.getClass().getName() : "null");
  }
  
  private static final Object IFELSE_IGNORE = "IF/ELSE IGNORE";
  private int ifElseNesting = 0;
  private int ifElseIgnoreNestCount = 0;
  private boolean ifElseSkipTruePart;
  protected static final int BOOLEAN = 0;
  protected static final int BYTE = 1;
  protected static final int SHORT = 2;
  protected static final int CHAR = 3;
  protected static final int INT = 4;
  protected static final int LONG = 5;
  protected static final int FLOAT = 6;
  protected static final int DOUBLE = 7;
  
  public final void pushIfElse()
  {
    try
    {
      boolean ignore = true;
      try
      {
        if (errorOccurred) {}
        do
        {
          return;
          
          ifElseNesting += 1;
        } while (ignoreExpression != null);
        ignore = false;
      }
      finally
      {
        if (traceOn) {
          printTrace("If test condition", ignore);
        }
      }
      try
      {
        Object condition = popExpression();
        Class type = popExpressionType(false);
        if (type != Boolean.TYPE) {
          throwClassCast(Boolean.TYPE, condition);
        }
        if (traceOn)
        {
          System.out.print(" Test Result=" + condition);
          printTraceEnd();
          indent(true);
          printTrace("Begin True Expression.", ignore);
          printTraceEnd();
          indent(true);
        }
        if (!((Boolean)condition).booleanValue())
        {
          ifElseSkipTruePart = true;
          ignoreExpression = IFELSE_IGNORE;
          ifElseIgnoreNestCount = ifElseNesting;
        }
      }
      catch (RuntimeException e)
      {
        processException(e);
      }
      catch (NoExpressionValueException e)
      {
        processException(e);
      }
    }
    finally
    {
      jsr 6;
      
      throw ((Throwable)localObject4);localObject3 = returnAddress;
      if (traceOn) {
        printTraceEnd();
      }
    }
  }
  
  public final void pushIfElse(InternalIfElseOperandType clauseType)
  {
    try
    {
      boolean ignore = true;
      if (errorOccurred) {}
      label172:
      do
      {
        for (;;)
        {
          return;
          switch (clauseType.getValue())
          {
          case 1: 
            if (traceOn)
            {
              indent(false);
              printTrace("Begin False Expression.", ignore);
              printTraceEnd();
              indent(true);
            }
            if ((!ifElseSkipTruePart) || (ignoreExpression != IFELSE_IGNORE) || (ifElseIgnoreNestCount != ifElseNesting)) {
              break label172;
            }
            ignoreExpression = null;
            break;
          case 0: 
            if (traceOn)
            {
              indent(false);
              indent(false);
              printTrace("End IF/ELSE Expression.", ignore);
              printTraceEnd();
            }
            int currentNesting = ifElseNesting--;
            if ((ignoreExpression != IFELSE_IGNORE) || (ifElseIgnoreNestCount != currentNesting)) {
              break label172;
            }
            ignoreExpression = null;
          }
        }
      } while (ignoreExpression != null);
      ignore = false;
      try
      {
        switch (clauseType.getValue())
        {
        case 1: 
          ifElseSkipTruePart = false;
          ignoreExpression = IFELSE_IGNORE;
          ifElseIgnoreNestCount = ifElseNesting;
        }
      }
      catch (RuntimeException e)
      {
        processException(e);
      }
    }
    finally
    {
      if (traceOn) {
        printTraceEnd();
      }
    }
  }
  
  public final void pushInstanceof(Class type)
  {
    boolean ignore = (ignoreExpression != null) || (errorOccurred);
    if (traceOn) {
      printTrace("Instanceof type: " + type, ignore);
    }
    try
    {
      if (ignore) {
        return;
      }
      try
      {
        Object exp = popExpression();
        Class exptype = popExpressionType(false);
        pushExpressionValue(Boolean.valueOf(isInstance(type, exp, exptype)), Boolean.TYPE);
      }
      catch (NoExpressionValueException e)
      {
        processException(e);
      }
      catch (RuntimeException e)
      {
        processException(e);
      }
    }
    finally
    {
      if (traceOn) {
        printTraceEnd();
      }
    }
  }
  
  protected final boolean isInstance(Class type, Object bean, Class beanType)
  {
    if (type.isPrimitive()) {
      return (beanType.isPrimitive()) && (type == beanType);
    }
    return type.isInstance(bean);
  }
  
  public final void pushNewInstanceFromString(String initializationString, Class resultType, ClassLoader classloader)
  {
    boolean ignore = (ignoreExpression != null) || (errorOccurred);
    if (traceOn) {
      printTrace("New instance from string: \"" + initializationString + "\" Type=" + resultType, ignore);
    }
    try
    {
      if (ignore) {
        return;
      }
      try
      {
        InitializationStringParser parser = InitializationStringParser.createParser(initializationString, classloader);
        Object newValue = parser.evaluate();
        newValue = castBean(resultType, newValue, parser.getExpectedType());
        pushExpressionValue(newValue, resultType);
      }
      catch (RuntimeException e)
      {
        processException(e);
      }
      catch (InitializationStringEvaluationException e)
      {
        processException(e);
      }
    }
    finally
    {
      if (traceOn) {
        printTraceEnd();
      }
    }
  }
  
  public final void pushPrefix(PrefixOperator operator)
  {
    try
    {
      if ((ignoreExpression != null) || (errorOccurred)) {
        if (traceOn) {
          printTrace("Prefix: '" + operator + "'", true);
        }
      }
      while (operator == PrefixOperator.PRE_PLUS) {
        return;
      }
      if (traceOn) {
        printTrace("Prefix: '" + operator + "' ", false);
      }
      try
      {
        Object exp = popExpression();
        Class exptype = popExpressionType(false);
        if (!exptype.isPrimitive()) {
          throwInvalidPrefix(operator, exp);
        }
        int primTypeEnum = getEnumForPrimitive(exptype);
        switch (operator.getValue())
        {
        case 1: 
          switch (primTypeEnum)
          {
          case 0: 
            throwInvalidPrefix(operator, exp);
          case 1: 
            exp = new Integer(-((Number)exp).byteValue());
            break;
          case 3: 
            exp = new Integer(-((Character)exp).charValue());
            break;
          case 7: 
            exp = new Double(-((Number)exp).doubleValue());
            break;
          case 6: 
            exp = new Float(-((Number)exp).floatValue());
            break;
          case 4: 
            exp = new Integer(-((Number)exp).intValue());
            break;
          case 5: 
            exp = new Long(-((Number)exp).longValue());
            break;
          case 2: 
            exp = new Integer(-((Number)exp).shortValue());
          }
          exptype = getPrimitiveType(exp);
          break;
        case 2: 
          switch (primTypeEnum)
          {
          case 0: 
          case 6: 
          case 7: 
            throwInvalidPrefix(operator, exp);
          case 1: 
            exp = new Integer(((Number)exp).byteValue() ^ 0xFFFFFFFF);
            break;
          case 3: 
            exp = new Integer(((Character)exp).charValue() ^ 0xFFFFFFFF);
            break;
          case 4: 
            exp = new Integer(((Number)exp).intValue() ^ 0xFFFFFFFF);
            break;
          case 5: 
            exp = new Long(((Number)exp).longValue() ^ 0xFFFFFFFFFFFFFFFF);
            break;
          case 2: 
            exp = new Integer(((Number)exp).shortValue() ^ 0xFFFFFFFF);
          }
          exptype = getPrimitiveType(exp);
          break;
        case 3: 
          switch (primTypeEnum)
          {
          case 0: 
            exp = !((Boolean)exp).booleanValue() ? Boolean.TRUE : Boolean.FALSE;
            break;
          case 1: 
          case 2: 
          case 3: 
          case 4: 
          case 5: 
          case 6: 
          case 7: 
            throwInvalidPrefix(operator, exp);
          }
          break;
        }
        if (traceOn) {
          printObjectAndType(exp, exptype);
        }
        pushExpressionValue(exp, exptype);
      }
      catch (IllegalArgumentException e)
      {
        processSyntaxException(e);
      }
      catch (NoExpressionValueException e)
      {
        processException(e);
      }
      catch (RuntimeException e)
      {
        processException(e);
      }
    }
    finally
    {
      if (traceOn) {
        printTraceEnd();
      }
    }
  }
  
  public final void pushAssignment()
  {
    if ((ignoreExpression != null) || (errorOccurred))
    {
      if (traceOn)
      {
        printTrace("Assignment", true);
        printTraceEnd();
      }
      return;
    }
    try
    {
      try
      {
        if (traceOn) {
          printTrace("Assignment: ", false);
        }
        Object value = popExpression();
        Class type = popExpressionType(false);
        
        VariableReference left = (VariableReference)popExpression(false);
        Class refType = popExpressionType(false);
        if (traceOn) {
          printObjectAndType(left, refType);
        }
        leftValue = left.set(value, type);
      }
      finally
      {
        Object leftValue;
        if (traceOn) {
          printTraceEnd();
        }
      }
      Class refType;
      Object leftValue;
      pushExpression(leftValue, refType);
    }
    catch (IllegalArgumentException e)
    {
      processException(e);
    }
    catch (NoExpressionValueException e)
    {
      processException(e);
    }
    catch (IllegalAccessException e)
    {
      processException(e);
    }
    catch (RuntimeException e)
    {
      processException(e);
    }
  }
  
  public final void pushAssignment(InternalExpressionProxy proxy)
  {
    boolean ignore = (ignoreExpression != null) || (errorOccurred);
    try
    {
      if (traceOn) {
        printTrace("Assign to Proxy #" + proxy.getProxyID(), ignore);
      }
      if (ignore) {
        return;
      }
      try
      {
        assignToExpressionProxyFromTopStackEntry(proxy);
        if (traceOn) {
          printObjectAndType(proxy.getValue(), proxy.getType());
        }
      }
      catch (NoExpressionValueException e)
      {
        processException(e);
      }
      catch (RuntimeException e)
      {
        processException(e);
      }
    }
    finally
    {
      if (traceOn) {
        printTraceEnd();
      }
    }
  }
  
  protected void assignToExpressionProxyFromTopStackEntry(InternalExpressionProxy proxy)
    throws NoExpressionValueException
  {
    Object value = getExpression(1);
    Class type = getExpressionType(1, true);
    if ((value instanceof VariableReference)) {
      value = ((VariableReference)value).dereference();
    }
    proxy.setProxy(value, type);
    allocateExpressionProxy(proxy);
  }
  
  public void allocateExpressionProxy(InternalExpressionProxy proxy)
  {
    int minSize = proxy.getProxyID() + 1;
    if (expressionProxies == null) {
      expressionProxies = new ArrayList(minSize + 10);
    } else if (expressionProxies.size() < minSize) {
      expressionProxies.ensureCapacity(minSize + 10);
    }
    int fill = minSize - expressionProxies.size();
    if (fill > 0)
    {
      do
      {
        expressionProxies.add(null);fill--;
      } while (fill > 0);
      expressionProxies.add(proxy);
    }
    else
    {
      expressionProxies.set(proxy.getProxyID(), proxy);
    }
  }
  
  protected final int getEnumForPrimitive(Class primitiveType)
    throws IllegalArgumentException
  {
    if (primitiveType == Boolean.TYPE) {
      return 0;
    }
    if (primitiveType == Integer.TYPE) {
      return 4;
    }
    if (primitiveType == Byte.TYPE) {
      return 1;
    }
    if (primitiveType == Character.TYPE) {
      return 3;
    }
    if (primitiveType == Double.TYPE) {
      return 7;
    }
    if (primitiveType == Float.TYPE) {
      return 6;
    }
    if (primitiveType == Long.TYPE) {
      return 5;
    }
    if (primitiveType == Short.TYPE) {
      return 2;
    }
    throw new IllegalArgumentException(primitiveType != null ? primitiveType.getName() : "null");
  }
  
  private void throwInvalidPrefix(PrefixOperator operator, Object exp)
    throws IllegalArgumentException
  {
    throw new IllegalArgumentException(MessageFormat.format(InitparserTreeMessages.getString("ExpressionProcesser.InvalidOperandOfPrefixOperator_EXC_"), new Object[] { exp != null ? exp.toString() : null, operator.toString() }));
  }
  
  private static final Object INFIX_IGNORE = "INFIX IGNORE";
  private int infixNesting = 0;
  private int infixIgnoreNestCount = 0;
  
  public final void pushInfix(InfixOperator operator, InternalInfixOperandType operandType)
  {
    try
    {
      boolean ignore = true;
      try
      {
        if (errorOccurred) {}
        do
        {
          for (;;)
          {
            return;
            if (operandType == InternalInfixOperandType.INFIX_LEFT_OPERAND)
            {
              infixNesting += 1; break;
            }
            if (operandType != InternalInfixOperandType.INFIX_LAST_OPERAND) {
              break;
            }
            int currentNest = infixNesting--;
            if ((ignoreExpression != INFIX_IGNORE) || (currentNest != infixIgnoreNestCount)) {
              break;
            }
            ignoreExpression = null;
          }
        } while (ignoreExpression != null);
        ignore = false;
      }
      finally
      {
        if (traceOn) {
          printTrace("Infix: " + operator, ignore);
        }
      }
      try
      {
        Object right = null;
        Class rightType = null;
        if (operandType != InternalInfixOperandType.INFIX_LEFT_OPERAND)
        {
          right = popExpression();
          rightType = popExpressionType(false);
        }
        Object value = popExpression();
        Class valueType = popExpressionType(false);
        switch (operator.getValue())
        {
        case 15: 
          if (operandType != InternalInfixOperandType.INFIX_LEFT_OPERAND)
          {
            testValidBitType(valueType, InfixOperator.IN_AND);
            testValidBitType(rightType, InfixOperator.IN_AND);
            if ((valueType == Long.TYPE) || (rightType == Long.TYPE))
            {
              value = new Long(getLong(value) & getLong(right));
              valueType = Long.TYPE;
            }
            else
            {
              value = new Integer(getInt(value) & getInt(right));
              valueType = Integer.TYPE;
            }
          }
          break;
        case 17: 
          if (operandType != InternalInfixOperandType.INFIX_LEFT_OPERAND)
          {
            value = right;
            valueType = rightType;
          }
          if (valueType != Boolean.TYPE) {
            throwInvalidInfix(operator, value);
          }
          if ((!((Boolean)value).booleanValue()) && (operandType != InternalInfixOperandType.INFIX_LAST_OPERAND)) {
            startInfixIgnore();
          }
          break;
        case 18: 
          if (operandType != InternalInfixOperandType.INFIX_LEFT_OPERAND)
          {
            value = right;
            valueType = rightType;
          }
          if (valueType != Boolean.TYPE) {
            throwInvalidInfix(operator, value);
          }
          if ((((Boolean)value).booleanValue()) && (operandType != InternalInfixOperandType.INFIX_LAST_OPERAND)) {
            startInfixIgnore();
          }
          break;
        case 1: 
          if (operandType != InternalInfixOperandType.INFIX_LEFT_OPERAND)
          {
            testValidArithmeticType(valueType, InfixOperator.IN_DIVIDE);
            testValidArithmeticType(rightType, InfixOperator.IN_DIVIDE);
            if ((valueType == Double.TYPE) || (rightType == Double.TYPE))
            {
              value = new Double(getDouble(value) / getDouble(right));
              valueType = Double.TYPE;
            }
            else if ((valueType == Float.TYPE) || (rightType == Float.TYPE))
            {
              value = new Float(getFloat(value) / getFloat(right));
              valueType = Float.TYPE;
            }
            else if ((valueType == Long.TYPE) || (rightType == Long.TYPE))
            {
              value = new Long(getLong(value) / getLong(right));
              valueType = Long.TYPE;
            }
            else
            {
              value = new Integer(getInt(value) / getInt(right));
              valueType = Integer.TYPE;
            }
          }
          break;
        case 12: 
          if (operandType != InternalInfixOperandType.INFIX_LEFT_OPERAND)
          {
            if ((valueType.isPrimitive()) && (rightType.isPrimitive()))
            {
              if ((valueType == Boolean.TYPE) || (rightType == Boolean.TYPE))
              {
                if ((valueType != Boolean.TYPE) || (valueType != Boolean.TYPE)) {
                  value = Boolean.FALSE;
                } else {
                  value = ((Boolean)value).booleanValue() == ((Boolean)right).booleanValue() ? Boolean.TRUE : Boolean.FALSE;
                }
              }
              else if ((valueType == Double.TYPE) || (rightType == Double.TYPE)) {
                value = getDouble(value) == getDouble(right) ? Boolean.TRUE : Boolean.FALSE;
              } else if ((valueType == Float.TYPE) || (rightType == Float.TYPE)) {
                value = getFloat(value) == getFloat(right) ? Boolean.TRUE : Boolean.FALSE;
              } else if ((valueType == Long.TYPE) || (rightType == Long.TYPE)) {
                value = getLong(value) == getLong(right) ? Boolean.TRUE : Boolean.FALSE;
              } else {
                value = getInt(value) == getInt(right) ? Boolean.TRUE : Boolean.FALSE;
              }
            }
            else if ((valueType.isPrimitive()) || (rightType.isPrimitive())) {
              value = Boolean.FALSE;
            } else {
              value = value == right ? Boolean.TRUE : Boolean.FALSE;
            }
            valueType = Boolean.TYPE;
          }
          break;
        case 9: 
          if (operandType != InternalInfixOperandType.INFIX_LEFT_OPERAND)
          {
            testValidArithmeticType(valueType, InfixOperator.IN_GREATER);
            testValidArithmeticType(rightType, InfixOperator.IN_GREATER);
            if ((valueType == Double.TYPE) || (rightType == Double.TYPE)) {
              value = getDouble(value) > getDouble(right) ? Boolean.TRUE : Boolean.FALSE;
            } else if ((valueType == Float.TYPE) || (rightType == Float.TYPE)) {
              value = getFloat(value) > getFloat(right) ? Boolean.TRUE : Boolean.FALSE;
            } else if ((valueType == Long.TYPE) || (rightType == Long.TYPE)) {
              value = getLong(value) > getLong(right) ? Boolean.TRUE : Boolean.FALSE;
            } else {
              value = getInt(value) > getInt(right) ? Boolean.TRUE : Boolean.FALSE;
            }
            valueType = Boolean.TYPE;
          }
          break;
        case 11: 
          if (operandType != InternalInfixOperandType.INFIX_LEFT_OPERAND)
          {
            testValidArithmeticType(valueType, InfixOperator.IN_GREATER_EQUALS);
            testValidArithmeticType(rightType, InfixOperator.IN_GREATER_EQUALS);
            if ((valueType == Double.TYPE) || (rightType == Double.TYPE)) {
              value = getDouble(value) >= getDouble(right) ? Boolean.TRUE : Boolean.FALSE;
            } else if ((valueType == Float.TYPE) || (rightType == Float.TYPE)) {
              value = getFloat(value) >= getFloat(right) ? Boolean.TRUE : Boolean.FALSE;
            } else if ((valueType == Long.TYPE) || (rightType == Long.TYPE)) {
              value = getLong(value) >= getLong(right) ? Boolean.TRUE : Boolean.FALSE;
            } else {
              value = getInt(value) >= getInt(right) ? Boolean.TRUE : Boolean.FALSE;
            }
            valueType = Boolean.TYPE;
          }
          break;
        case 5: 
          if (operandType != InternalInfixOperandType.INFIX_LEFT_OPERAND)
          {
            testValidBitType(valueType, InfixOperator.IN_LEFT_SHIFT);
            testValidBitType(rightType, InfixOperator.IN_LEFT_SHIFT);
            if ((valueType == Long.TYPE) || (rightType == Long.TYPE))
            {
              value = new Long(getLong(value) << (int)getLong(right));
              valueType = Long.TYPE;
            }
            else
            {
              value = new Integer(getInt(value) << getInt(right));
              valueType = Integer.TYPE;
            }
          }
          break;
        case 8: 
          if (operandType != InternalInfixOperandType.INFIX_LEFT_OPERAND)
          {
            testValidArithmeticType(valueType, InfixOperator.IN_LESS);
            testValidArithmeticType(rightType, InfixOperator.IN_LESS);
            if ((valueType == Double.TYPE) || (rightType == Double.TYPE)) {
              value = getDouble(value) < getDouble(right) ? Boolean.TRUE : Boolean.FALSE;
            } else if ((valueType == Float.TYPE) || (rightType == Float.TYPE)) {
              value = getFloat(value) < getFloat(right) ? Boolean.TRUE : Boolean.FALSE;
            } else if ((valueType == Long.TYPE) || (rightType == Long.TYPE)) {
              value = getLong(value) < getLong(right) ? Boolean.TRUE : Boolean.FALSE;
            } else {
              value = getInt(value) < getInt(right) ? Boolean.TRUE : Boolean.FALSE;
            }
            valueType = Boolean.TYPE;
          }
          break;
        case 10: 
          if (operandType != InternalInfixOperandType.INFIX_LEFT_OPERAND)
          {
            testValidArithmeticType(valueType, InfixOperator.IN_LESS_EQUALS);
            testValidArithmeticType(rightType, InfixOperator.IN_LESS_EQUALS);
            if ((valueType == Double.TYPE) || (rightType == Double.TYPE)) {
              value = getDouble(value) <= getDouble(right) ? Boolean.TRUE : Boolean.FALSE;
            } else if ((valueType == Float.TYPE) || (rightType == Float.TYPE)) {
              value = getFloat(value) <= getFloat(right) ? Boolean.TRUE : Boolean.FALSE;
            } else if ((valueType == Long.TYPE) || (rightType == Long.TYPE)) {
              value = getLong(value) <= getLong(right) ? Boolean.TRUE : Boolean.FALSE;
            } else {
              value = getInt(value) <= getInt(right) ? Boolean.TRUE : Boolean.FALSE;
            }
            valueType = Boolean.TYPE;
          }
          break;
        case 4: 
          if (operandType != InternalInfixOperandType.INFIX_LEFT_OPERAND)
          {
            testValidArithmeticType(valueType, InfixOperator.IN_MINUS);
            testValidArithmeticType(rightType, InfixOperator.IN_MINUS);
            if ((valueType == Double.TYPE) || (rightType == Double.TYPE))
            {
              value = new Double(getDouble(value) - getDouble(right));
              valueType = Double.TYPE;
            }
            else if ((valueType == Float.TYPE) || (rightType == Float.TYPE))
            {
              value = new Float(getFloat(value) - getFloat(right));
              valueType = Float.TYPE;
            }
            else if ((valueType == Long.TYPE) || (rightType == Long.TYPE))
            {
              value = new Long(getLong(value) - getLong(right));
              valueType = Long.TYPE;
            }
            else
            {
              value = new Integer(getInt(value) - getInt(right));
              valueType = Integer.TYPE;
            }
          }
          break;
        case 13: 
          if (operandType != InternalInfixOperandType.INFIX_LEFT_OPERAND)
          {
            if ((valueType.isPrimitive()) && (rightType.isPrimitive()))
            {
              if ((valueType == Boolean.TYPE) || (rightType == Boolean.TYPE))
              {
                if ((valueType != Boolean.TYPE) || (valueType != Boolean.TYPE)) {
                  value = Boolean.TRUE;
                } else {
                  value = ((Boolean)value).booleanValue() != ((Boolean)right).booleanValue() ? Boolean.TRUE : Boolean.FALSE;
                }
              }
              else if ((valueType == Double.TYPE) || (rightType == Double.TYPE)) {
                value = getDouble(value) != getDouble(right) ? Boolean.TRUE : Boolean.FALSE;
              } else if ((valueType == Float.TYPE) || (rightType == Float.TYPE)) {
                value = getFloat(value) != getFloat(right) ? Boolean.TRUE : Boolean.FALSE;
              } else if ((valueType == Long.TYPE) || (rightType == Long.TYPE)) {
                value = getLong(value) != getLong(right) ? Boolean.TRUE : Boolean.FALSE;
              } else {
                value = getInt(value) != getInt(right) ? Boolean.TRUE : Boolean.FALSE;
              }
            }
            else if ((valueType.isPrimitive()) || (rightType.isPrimitive())) {
              value = Boolean.TRUE;
            } else {
              value = value != right ? Boolean.TRUE : Boolean.FALSE;
            }
            valueType = Boolean.TYPE;
          }
          break;
        case 16: 
          if (operandType != InternalInfixOperandType.INFIX_LEFT_OPERAND)
          {
            testValidBitType(valueType, InfixOperator.IN_OR);
            testValidBitType(rightType, InfixOperator.IN_OR);
            if ((valueType == Long.TYPE) || (rightType == Long.TYPE))
            {
              value = new Long(getLong(value) | getLong(right));
              valueType = Long.TYPE;
            }
            else
            {
              value = new Integer(getInt(value) | getInt(right));
              valueType = Integer.TYPE;
            }
          }
          break;
        case 3: 
          if (operandType == InternalInfixOperandType.INFIX_LEFT_OPERAND)
          {
            if (valueType == String.class) {
              value = new StringBuffer((String)value);
            }
          }
          else
          {
            testValidPlusType(valueType, rightType);
            if ((valueType == String.class) || (rightType == String.class))
            {
              StringBuffer sb = null;
              if (valueType == String.class)
              {
                sb = (StringBuffer)value;
              }
              else
              {
                sb = new StringBuffer(((String)right).length() + 16);
                appendToBuffer(sb, value, valueType);
                value = sb;
                valueType = String.class;
              }
              appendToBuffer(sb, right, rightType);
              if (operandType == InternalInfixOperandType.INFIX_LAST_OPERAND) {
                value = sb.toString();
              }
            }
            else if ((valueType == Double.TYPE) || (rightType == Double.TYPE))
            {
              value = new Double(getDouble(value) + getDouble(right));
              valueType = Double.TYPE;
            }
            else if ((valueType == Float.TYPE) || (rightType == Float.TYPE))
            {
              value = new Float(getFloat(value) + getFloat(right));
              valueType = Float.TYPE;
            }
            else if ((valueType == Long.TYPE) || (rightType == Long.TYPE))
            {
              value = new Long(getLong(value) + getLong(right));
              valueType = Long.TYPE;
            }
            else
            {
              value = new Integer(getInt(value) + getInt(right));
              valueType = Integer.TYPE;
            }
          }
          break;
        case 2: 
          if (operandType != InternalInfixOperandType.INFIX_LEFT_OPERAND)
          {
            testValidArithmeticType(valueType, InfixOperator.IN_REMAINDER);
            testValidArithmeticType(rightType, InfixOperator.IN_REMAINDER);
            if ((valueType == Double.TYPE) || (rightType == Double.TYPE))
            {
              value = new Double(getDouble(value) % getDouble(right));
              valueType = Double.TYPE;
            }
            else if ((valueType == Float.TYPE) || (rightType == Float.TYPE))
            {
              value = new Float(getFloat(value) % getFloat(right));
              valueType = Float.TYPE;
            }
            else if ((valueType == Long.TYPE) || (rightType == Long.TYPE))
            {
              value = new Long(getLong(value) % getLong(right));
              valueType = Long.TYPE;
            }
            else
            {
              value = new Integer(getInt(value) % getInt(right));
              valueType = Integer.TYPE;
            }
          }
          break;
        case 6: 
          if (operandType != InternalInfixOperandType.INFIX_LEFT_OPERAND)
          {
            testValidBitType(valueType, InfixOperator.IN_RIGHT_SHIFT_SIGNED);
            testValidBitType(rightType, InfixOperator.IN_RIGHT_SHIFT_SIGNED);
            if ((valueType == Long.TYPE) || (rightType == Long.TYPE))
            {
              value = new Long(getLong(value) >> (int)getLong(right));
              valueType = Long.TYPE;
            }
            else
            {
              value = new Integer(getInt(value) >> getInt(right));
              valueType = Integer.TYPE;
            }
          }
          break;
        case 7: 
          if (operandType != InternalInfixOperandType.INFIX_LEFT_OPERAND)
          {
            testValidBitType(valueType, InfixOperator.IN_RIGHT_SHIFT_UNSIGNED);
            testValidBitType(rightType, InfixOperator.IN_RIGHT_SHIFT_UNSIGNED);
            if ((valueType == Long.TYPE) || (rightType == Long.TYPE))
            {
              value = new Long(getLong(value) >>> (int)getLong(right));
              valueType = Long.TYPE;
            }
            else
            {
              value = new Integer(getInt(value) >>> getInt(right));
              valueType = Integer.TYPE;
            }
          }
          break;
        case 0: 
          if (operandType != InternalInfixOperandType.INFIX_LEFT_OPERAND)
          {
            testValidArithmeticType(valueType, InfixOperator.IN_TIMES);
            testValidArithmeticType(rightType, InfixOperator.IN_TIMES);
            if ((valueType == Double.TYPE) || (rightType == Double.TYPE))
            {
              value = new Double(getDouble(value) * getDouble(right));
              valueType = Double.TYPE;
            }
            else if ((valueType == Float.TYPE) || (rightType == Float.TYPE))
            {
              value = new Float(getFloat(value) * getFloat(right));
              valueType = Float.TYPE;
            }
            else if ((valueType == Long.TYPE) || (rightType == Long.TYPE))
            {
              value = new Long(getLong(value) * getLong(right));
              valueType = Long.TYPE;
            }
            else
            {
              value = new Integer(getInt(value) * getInt(right));
              valueType = Integer.TYPE;
            }
          }
          break;
        case 14: 
          if (operandType != InternalInfixOperandType.INFIX_LEFT_OPERAND)
          {
            testValidBitType(valueType, InfixOperator.IN_XOR);
            testValidBitType(rightType, InfixOperator.IN_XOR);
            if ((valueType == Long.TYPE) || (rightType == Long.TYPE))
            {
              value = new Long(getLong(value) ^ getLong(right));
              valueType = Long.TYPE;
            }
            else
            {
              value = new Integer(getInt(value) ^ getInt(right));
              valueType = Integer.TYPE;
            }
          }
          break;
        }
        if (traceOn) {
          printObjectAndType(value, valueType);
        }
        pushExpressionValue(value, valueType);
      }
      catch (IllegalArgumentException e)
      {
        processException(e);
      }
      catch (NoExpressionValueException e)
      {
        processException(e);
      }
      catch (RuntimeException e)
      {
        processException(e);
      }
    }
    finally
    {
      jsr 6;
      
      throw ((Throwable)localObject4);localObject3 = returnAddress;
      if (traceOn) {
        printTraceEnd();
      }
    }
  }
  
  private void startInfixIgnore()
  {
    ignoreExpression = INFIX_IGNORE;
    infixIgnoreNestCount = infixNesting;
  }
  
  protected final int getInt(Object bean)
    throws ClassCastException
  {
    return (bean instanceof Number) ? ((Number)bean).intValue() : ((Character)bean).charValue();
  }
  
  protected final float getFloat(Object bean)
    throws ClassCastException
  {
    return (bean instanceof Number) ? ((Number)bean).floatValue() : ((Character)bean).charValue();
  }
  
  protected final double getDouble(Object bean)
    throws ClassCastException
  {
    return (bean instanceof Number) ? ((Number)bean).doubleValue() : ((Character)bean).charValue();
  }
  
  protected final long getLong(Object bean)
    throws ClassCastException
  {
    return (bean instanceof Number) ? ((Number)bean).longValue() : ((Character)bean).charValue();
  }
  
  private void throwInvalidInfix(InfixOperator operator, Object value)
    throws IllegalArgumentException
  {
    throw new IllegalArgumentException(MessageFormat.format(InitparserTreeMessages.getString("ExpressionProcesser.InvalidOperandOfOperator_EXC_"), new Object[] { value != null ? value.toString() : null, operator.toString() }));
  }
  
  private void testValidBitType(Class type, InfixOperator operator)
  {
    if ((!type.isPrimitive()) || (type == Boolean.TYPE) || (type == Double.TYPE) || (type == Float.TYPE)) {
      throwInvalidInfix(operator, type);
    }
  }
  
  private void testValidArithmeticType(Class type, InfixOperator operator)
  {
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30

Further reading...

For more information on Java 1.5 Tiger, you may find Java 1.5 Tiger, A developer's Notebook by D. Flanagan and B. McLaughlin from O'Reilly of interest.

New!JAR listings


Copyright 2006-2017. Infinite Loop Ltd