/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/** A helper class for code generation. Items are objects
* that stand for addressable entities in the bytecode. Each item
* supports a fixed protocol for loading the item on the stack, storing
* into it, converting it into a jump condition, and several others.
* There are many individual forms of items, such as local, static,
* indexed, or instance variables, values on the top of stack, the
* special values this or super, etc. Individual items are represented as
* inner classes in class Items.
*
* <p><b>This is NOT part of any supported API.
* If you write code that depends on this, you do so at your own risk.
* This code and its internal interfaces are subject to change or
* deletion without notice.</b>
*/
public class Items {
/** The current constant pool.
*/
/** The current code buffer.
*/
/** The current symbol table.
*/
/** Type utilities. */
/** Items that exist only once (flyweight pattern).
*/
};
}
/** Make a void item
*/
return voidItem;
}
/** Make an item representing `this'.
*/
return thisItem;
}
/** Make an item representing `super'.
*/
return superItem;
}
/** Make an item representing a value on stack.
* @param type The value's type.
*/
}
/** Make an item representing an indexed expression.
* @param type The expression's type.
*/
return new IndexedItem(type);
}
/** Make an item representing a local variable.
* @param v The represented variable.
*/
}
/** Make an item representing a local anonymous variable.
* @param type The represented variable's type.
* @param reg The represented variable's register.
*/
}
/** Make an item representing a static variable or method.
* @param member The represented symbol.
*/
return new StaticItem(member);
}
/** Make an item representing an instance variable or method.
* @param member The represented symbol.
* @param nonvirtual Is the reference not virtual? (true for constructors
* and private members).
*/
}
/** Make an item representing a literal.
* @param type The literal's type.
* @param value The literal's value.
*/
}
/** Make an item representing an assignment expression.
* @param lhs The item representing the assignment's left hand side.
*/
return new AssignItem(lhs);
}
/** Make an item representing a conditional or unconditional jump.
* @param opcode The jump's opcode.
* @param trueJumps A chain encomassing all jumps that can be taken
* if the condition evaluates to true.
* @param falseJumps A chain encomassing all jumps that can be taken
* if the condition evaluates to false.
*/
}
/** Make an item representing a conditional or unconditional jump.
* @param opcode The jump's opcode.
*/
}
/** The base class of all items, which implements default behavior.
*/
abstract class Item {
/** The type code of values represented by this item.
*/
int typecode;
}
/** Generate code to load this item onto stack.
*/
throw new AssertionError();
}
/** Generate code to store top of stack into this item.
*/
void store() {
throw new AssertionError("store unsupported: " + this);
}
/** Generate code to invoke method represented by this item.
*/
throw new AssertionError(this);
}
/** Generate code to use this item twice.
*/
void duplicate() {}
/** Generate code to avoid having to use this item.
*/
void drop() {}
/** Generate code to stash a copy of top of stack - of typecode toscode -
* under this item.
*/
}
/** Generate code to turn item into a testable condition.
*/
load();
return makeCondItem(ifne);
}
/** Generate code to coerce item to given type code.
* @param targetcode The type code to coerce to.
*/
if (typecode == targetcode)
return this;
else {
load();
if (typecode1 != targetcode1) {
: targetcode1;
}
if (targetcode != targetcode1) {
}
return stackItem[targetcode];
}
}
/** Generate code to coerce item to given type.
* @param targettype The type to coerce to.
*/
}
/** Return the width of this item on stack as a number of words.
*/
int width() {
return 0;
}
}
/** An item representing a value on stack.
*/
super(typecode);
}
return this;
}
void duplicate() {
}
void drop() {
}
}
int width() {
}
}
}
/** An item representing an indexed expression.
*/
}
}
void store() {
}
void duplicate() {
}
void drop() {
}
}
int width() {
return 2;
}
}
}
/** An item representing `this' or `super'.
*/
/** Flag which determines whether this item represents `this' or `super'.
*/
boolean isSuper;
super(OBJECTcode);
}
}
}
}
/** An item representing a local variable.
*/
/** The variable's register.
*/
int reg;
/** The variable's type.
*/
}
if (reg <= 3)
else
}
void store() {
if (reg <= 3)
else
}
void incr(int x) {
} else {
load();
if (x >= 0) {
} else {
}
store();
}
}
}
}
/** An item representing a static variable or method.
*/
/** The represented symbol.
*/
}
}
void store() {
}
}
}
}
/** An item representing an instance variable or method.
*/
/** The represented symbol.
*/
/** Flag that determines whether or not access is virtual.
*/
boolean nonvirtual;
this.nonvirtual = nonvirtual;
}
}
void store() {
}
} else if (nonvirtual) {
} else {
}
}
void duplicate() {
}
void drop() {
}
}
int width() {
return 1;
}
}
}
/** An item representing a literal.
*/
/** The literal's value.
*/
}
private void ldc() {
} else if (idx <= 255) {
} else {
}
}
switch (typecode) {
else
ldc();
break;
case LONGcode:
else
ldc();
break;
case FLOATcode:
else {
ldc();
}
break;
case DOUBLEcode:
else
ldc();
break;
case OBJECTcode:
ldc();
break;
default:
}
}
//where
/** Return true iff float number is positive 0.
*/
private boolean isPosZero(float x) {
return x == 0.0f && 1.0f / x > 0.0f;
}
/** Return true iff double number is positive 0.
*/
private boolean isPosZero(double x) {
return x == 0.0d && 1.0d / x > 0.0d;
}
}
if (typecode == targetcode) {
return this;
} else {
switch (targetcode) {
case INTcode:
return this;
else
return new ImmediateItem(
case LONGcode:
return new ImmediateItem(
case FLOATcode:
return new ImmediateItem(
case DOUBLEcode:
return new ImmediateItem(
case BYTEcode:
return new ImmediateItem(
case CHARcode:
return new ImmediateItem(
case SHORTcode:
return new ImmediateItem(
default:
return super.coerce(targetcode);
}
}
}
}
}
/** An item representing an assignment expressions.
*/
/** The item representing the assignment's left hand side.
*/
}
}
void duplicate() {
}
void drop() {
}
}
int width() {
}
}
}
/** An item representing a conditional or unconditional jump.
*/
/** A chain encomassing all jumps that can be taken
* if the condition evaluates to true.
*/
/** A chain encomassing all jumps that can be taken
* if the condition evaluates to false.
*/
/** The jump's opcode.
*/
int opcode;
/*
* An abstract syntax tree of this item. It is needed
* for branch entries in 'CharacterRangeTable' attribute.
*/
super(BYTEcode);
this.falseJumps = falsejumps;
}
if (!isFalse()) {
}
if (falseChain != null) {
}
}
void duplicate() {
}
void drop() {
}
}
return this;
}
// we should proceed further in -Xjcov mode only
return c;
}
// we should proceed further in -Xjcov mode only
return c;
}
return c;
}
int width() {
// a CondItem doesn't have a size on the stack per se.
throw new AssertionError();
}
boolean isTrue() {
}
boolean isFalse() {
}
}
}
}