src/share/classes/com/sun/tools/javac/comp/ConstFold.java

changeset 1374
c002fdee76fd
parent 581
f2fdd52e4e87
child 1442
fcf89720ae71
     1.1 --- a/src/share/classes/com/sun/tools/javac/comp/ConstFold.java	Tue Oct 23 13:58:56 2012 -0700
     1.2 +++ b/src/share/classes/com/sun/tools/javac/comp/ConstFold.java	Thu Oct 25 11:09:36 2012 -0700
     1.3 @@ -1,5 +1,5 @@
     1.4  /*
     1.5 - * Copyright (c) 1999, 2006, Oracle and/or its affiliates. All rights reserved.
     1.6 + * Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved.
     1.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     1.8   *
     1.9   * This code is free software; you can redistribute it and/or modify it
    1.10 @@ -31,7 +31,8 @@
    1.11  
    1.12  import com.sun.tools.javac.code.Type.*;
    1.13  
    1.14 -import static com.sun.tools.javac.code.TypeTags.*;
    1.15 +import static com.sun.tools.javac.code.TypeTag.BOOLEAN;
    1.16 +
    1.17  import static com.sun.tools.javac.jvm.ByteCodes.*;
    1.18  
    1.19  /** Helper class for constant folding, used by the attribution phase.
    1.20 @@ -176,19 +177,19 @@
    1.21                  case imod:
    1.22                      return syms.intType.constType(intValue(l) % intValue(r));
    1.23                  case iand:
    1.24 -                    return (left.tag == BOOLEAN
    1.25 +                    return (left.hasTag(BOOLEAN)
    1.26                        ? syms.booleanType : syms.intType)
    1.27                        .constType(intValue(l) & intValue(r));
    1.28                  case bool_and:
    1.29                      return syms.booleanType.constType(b2i((intValue(l) & intValue(r)) != 0));
    1.30                  case ior:
    1.31 -                    return (left.tag == BOOLEAN
    1.32 +                    return (left.hasTag(BOOLEAN)
    1.33                        ? syms.booleanType : syms.intType)
    1.34                        .constType(intValue(l) | intValue(r));
    1.35                  case bool_or:
    1.36                      return syms.booleanType.constType(b2i((intValue(l) | intValue(r)) != 0));
    1.37                  case ixor:
    1.38 -                    return (left.tag == BOOLEAN
    1.39 +                    return (left.hasTag(BOOLEAN)
    1.40                        ? syms.booleanType : syms.intType)
    1.41                        .constType(intValue(l) ^ intValue(r));
    1.42                  case ishl: case ishll:
    1.43 @@ -326,7 +327,7 @@
    1.44  
    1.45      /** Coerce constant type to target type.
    1.46       *  @param etype      The source type of the coercion,
    1.47 -     *                    which is assumed to be a constant type compatble with
    1.48 +     *                    which is assumed to be a constant type compatible with
    1.49       *                    ttype.
    1.50       *  @param ttype      The target type of the coercion.
    1.51       */
    1.52 @@ -334,9 +335,9 @@
    1.53           // WAS if (etype.baseType() == ttype.baseType())
    1.54           if (etype.tsym.type == ttype.tsym.type)
    1.55               return etype;
    1.56 -         if (etype.tag <= DOUBLE) {
    1.57 +         if (etype.isNumeric()) {
    1.58               Object n = etype.constValue();
    1.59 -             switch (ttype.tag) {
    1.60 +             switch (ttype.getTag()) {
    1.61               case BYTE:
    1.62                   return syms.byteType.constType(0 + (byte)intValue(n));
    1.63               case CHAR:

mercurial