< prev index next >

src/jdk.compiler/share/classes/com/sun/tools/javac/util/Bits.java

Print this page

  1 /*
  2  * Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved.
  3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  4  *
  5  * This code is free software; you can redistribute it and/or modify it
  6  * under the terms of the GNU General Public License version 2 only, as
  7  * published by the Free Software Foundation.  Oracle designates this
  8  * particular file as subject to the "Classpath" exception as provided
  9  * by Oracle in the LICENSE file that accompanied this code.
 10  *
 11  * This code is distributed in the hope that it will be useful, but WITHOUT
 12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 14  * version 2 for more details (a copy is included in the LICENSE file that
 15  * accompanied this code).
 16  *
 17  * You should have received a copy of the GNU General Public License version
 18  * 2 along with this work; if not, write to the Free Software Foundation,
 19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 20  *
 21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
 22  * or visit www.oracle.com if you need additional information or have any

 71         NORMAL;
 72 
 73         static BitsState getState(int[] someBits, boolean reset) {
 74             if (reset) {
 75                 return UNKNOWN;
 76             } else {
 77                 if (someBits != unassignedBits) {
 78                     return NORMAL;
 79                 } else {
 80                     return UNINIT;
 81                 }
 82             }
 83         }
 84 
 85     }
 86 
 87     private static final int wordlen = 32;
 88     private static final int wordshift = 5;
 89     private static final int wordmask = wordlen - 1;
 90 
 91     public int[] bits = null;



 92     // This field will store last version of bits after every change.
 93     private static final int[] unassignedBits = new int[0];
 94 
 95     protected BitsState currentState;
 96 
 97     /** Construct an initially empty set.
 98      */
 99     public Bits() {
100         this(false);
101     }
102 
103     public Bits(Bits someBits) {
104         this(someBits.dup().bits, BitsState.getState(someBits.bits, false));
105     }
106 
107     public Bits(boolean reset) {
108         this(unassignedBits, BitsState.getState(unassignedBits, reset));
109     }
110 
111     /** Construct a set consisting initially of given bit vector.

  1 /*
  2  * Copyright (c) 1999, 2025, Oracle and/or its affiliates. All rights reserved.
  3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  4  *
  5  * This code is free software; you can redistribute it and/or modify it
  6  * under the terms of the GNU General Public License version 2 only, as
  7  * published by the Free Software Foundation.  Oracle designates this
  8  * particular file as subject to the "Classpath" exception as provided
  9  * by Oracle in the LICENSE file that accompanied this code.
 10  *
 11  * This code is distributed in the hope that it will be useful, but WITHOUT
 12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 14  * version 2 for more details (a copy is included in the LICENSE file that
 15  * accompanied this code).
 16  *
 17  * You should have received a copy of the GNU General Public License version
 18  * 2 along with this work; if not, write to the Free Software Foundation,
 19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 20  *
 21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
 22  * or visit www.oracle.com if you need additional information or have any

 71         NORMAL;
 72 
 73         static BitsState getState(int[] someBits, boolean reset) {
 74             if (reset) {
 75                 return UNKNOWN;
 76             } else {
 77                 if (someBits != unassignedBits) {
 78                     return NORMAL;
 79                 } else {
 80                     return UNINIT;
 81                 }
 82             }
 83         }
 84 
 85     }
 86 
 87     private static final int wordlen = 32;
 88     private static final int wordshift = 5;
 89     private static final int wordmask = wordlen - 1;
 90 
 91     /* every int in the bits array is used to represent 32 bits, so the bits array will have
 92      * length == 1 until we need to represent the 33rd bit and so on.
 93      */
 94     private int[] bits = null;
 95     // This field will store last version of bits after every change.
 96     private static final int[] unassignedBits = new int[0];
 97 
 98     protected BitsState currentState;
 99 
100     /** Construct an initially empty set.
101      */
102     public Bits() {
103         this(false);
104     }
105 
106     public Bits(Bits someBits) {
107         this(someBits.dup().bits, BitsState.getState(someBits.bits, false));
108     }
109 
110     public Bits(boolean reset) {
111         this(unassignedBits, BitsState.getState(unassignedBits, reset));
112     }
113 
114     /** Construct a set consisting initially of given bit vector.
< prev index next >