bytecodeStream.hpp revision 1490
1485N/A * Copyright 1997-2010 Sun Microsystems, Inc. All Rights Reserved. 0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 0N/A * This code is free software; you can redistribute it and/or modify it 0N/A * under the terms of the GNU General Public License version 2 only, as 0N/A * published by the Free Software Foundation. 0N/A * This code is distributed in the hope that it will be useful, but WITHOUT 0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 0N/A * version 2 for more details (a copy is included in the LICENSE file that 0N/A * accompanied this code). 0N/A * You should have received a copy of the GNU General Public License version 0N/A * 2 along with this work; if not, write to the Free Software Foundation, 0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 0N/A * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 0N/A * CA 95054 USA or visit www.sun.com if you need additional information or 0N/A * have any questions. 0N/A// A BytecodeStream is used for fast iteration over the bytecodes 0N/A// BytecodeStream s(method); 0N/A// Bytecodes::Code c; 0N/A// while ((c = s.next()) >= 0) { 0N/A// A RawBytecodeStream is a simple version of BytecodeStream. 0N/A// It is used ONLY when we know the bytecodes haven't been rewritten 1485N/A// yet, such as in the rewriter or the verifier. 1485N/A// Here is the common base class for both RawBytecodeStream and BytecodeStream: 0N/A int _bci;
// bci if current bytecode 0N/A int _end_bci;
// bci after the current iteration interval 0N/A // last bytecode read 0N/A // Iteration control 0N/A // iterate over the interval [beg_bci, end_bci) 0N/A // setup of iteration pointers 1485N/A // Bytecode-specific attributes 0N/A // Use raw_next() rather than next() for faster method reference 0N/A // set reading position 0N/A // set next bytecode position 1485N/A // Unsigned indices, widening, with no swapping of bytes 1485N/A // Get an unsigned 2-byte index, with no swapping of bytes. 0N/A// In BytecodeStream, non-java bytecodes will be translated into the 0N/A// corresponding java bytecodes. 0N/A // set reading position 0N/A // indicate end of bytecode stream 0N/A // set next bytecode position 0N/A // note that we cannot advance before having the 0N/A // tty bytecode otherwise the stepping is wrong! 0N/A // (carefull: length_for(...) must be used first!) 0N/A // check for special (uncommon) cases 1485N/A // Unsigned indices, widening 1485N/A // Get an unsigned 2-byte index, swapping the bytes if necessary. 1485N/A // Get an unsigned 2-byte index in native order.