|
From: <ls...@us...> - 2007-06-10 08:42:17
|
Revision: 3232
http://jnode.svn.sourceforge.net/jnode/?rev=3232&view=rev
Author: lsantha
Date: 2007-06-10 01:42:12 -0700 (Sun, 10 Jun 2007)
Log Message:
-----------
Added javap from openjdk.
Added Paths:
-----------
trunk/core/src/openjdk/sun/sun/tools/
trunk/core/src/openjdk/sun/sun/tools/asm/
trunk/core/src/openjdk/sun/sun/tools/asm/ArrayData.java
trunk/core/src/openjdk/sun/sun/tools/asm/Assembler.java
trunk/core/src/openjdk/sun/sun/tools/asm/CatchData.java
trunk/core/src/openjdk/sun/sun/tools/asm/ClassConstantData.java
trunk/core/src/openjdk/sun/sun/tools/asm/ConstantPool.java
trunk/core/src/openjdk/sun/sun/tools/asm/ConstantPoolData.java
trunk/core/src/openjdk/sun/sun/tools/asm/Cover.java
trunk/core/src/openjdk/sun/sun/tools/asm/FieldConstantData.java
trunk/core/src/openjdk/sun/sun/tools/asm/Instruction.java
trunk/core/src/openjdk/sun/sun/tools/asm/Label.java
trunk/core/src/openjdk/sun/sun/tools/asm/LocalVariable.java
trunk/core/src/openjdk/sun/sun/tools/asm/LocalVariableTable.java
trunk/core/src/openjdk/sun/sun/tools/asm/NameAndTypeConstantData.java
trunk/core/src/openjdk/sun/sun/tools/asm/NameAndTypeData.java
trunk/core/src/openjdk/sun/sun/tools/asm/NumberConstantData.java
trunk/core/src/openjdk/sun/sun/tools/asm/StringConstantData.java
trunk/core/src/openjdk/sun/sun/tools/asm/StringExpressionConstantData.java
trunk/core/src/openjdk/sun/sun/tools/asm/SwitchData.java
trunk/core/src/openjdk/sun/sun/tools/asm/TryData.java
trunk/core/src/openjdk/sun/sun/tools/java/
trunk/core/src/openjdk/sun/sun/tools/java/AmbiguousClass.java
trunk/core/src/openjdk/sun/sun/tools/java/AmbiguousMember.java
trunk/core/src/openjdk/sun/sun/tools/java/ArrayType.java
trunk/core/src/openjdk/sun/sun/tools/java/BinaryAttribute.java
trunk/core/src/openjdk/sun/sun/tools/java/BinaryClass.java
trunk/core/src/openjdk/sun/sun/tools/java/BinaryCode.java
trunk/core/src/openjdk/sun/sun/tools/java/BinaryConstantPool.java
trunk/core/src/openjdk/sun/sun/tools/java/BinaryExceptionHandler.java
trunk/core/src/openjdk/sun/sun/tools/java/BinaryMember.java
trunk/core/src/openjdk/sun/sun/tools/java/ClassDeclaration.java
trunk/core/src/openjdk/sun/sun/tools/java/ClassDefinition.java
trunk/core/src/openjdk/sun/sun/tools/java/ClassFile.java
trunk/core/src/openjdk/sun/sun/tools/java/ClassNotFound.java
trunk/core/src/openjdk/sun/sun/tools/java/ClassPath.java
trunk/core/src/openjdk/sun/sun/tools/java/ClassType.java
trunk/core/src/openjdk/sun/sun/tools/java/CompilerError.java
trunk/core/src/openjdk/sun/sun/tools/java/Constants.java
trunk/core/src/openjdk/sun/sun/tools/java/Environment.java
trunk/core/src/openjdk/sun/sun/tools/java/Identifier.java
trunk/core/src/openjdk/sun/sun/tools/java/IdentifierToken.java
trunk/core/src/openjdk/sun/sun/tools/java/Imports.java
trunk/core/src/openjdk/sun/sun/tools/java/MemberDefinition.java
trunk/core/src/openjdk/sun/sun/tools/java/MethodSet.java
trunk/core/src/openjdk/sun/sun/tools/java/MethodType.java
trunk/core/src/openjdk/sun/sun/tools/java/Package.java
trunk/core/src/openjdk/sun/sun/tools/java/Parser.java
trunk/core/src/openjdk/sun/sun/tools/java/ParserActions.java
trunk/core/src/openjdk/sun/sun/tools/java/RuntimeConstants.java
trunk/core/src/openjdk/sun/sun/tools/java/Scanner.java
trunk/core/src/openjdk/sun/sun/tools/java/ScannerInputReader.java
trunk/core/src/openjdk/sun/sun/tools/java/SyntaxError.java
trunk/core/src/openjdk/sun/sun/tools/java/Type.java
trunk/core/src/openjdk/sun/sun/tools/javac/
trunk/core/src/openjdk/sun/sun/tools/javac/BatchEnvironment.java
trunk/core/src/openjdk/sun/sun/tools/javac/BatchParser.java
trunk/core/src/openjdk/sun/sun/tools/javac/CompilerMember.java
trunk/core/src/openjdk/sun/sun/tools/javac/ErrorConsumer.java
trunk/core/src/openjdk/sun/sun/tools/javac/ErrorMessage.java
trunk/core/src/openjdk/sun/sun/tools/javac/Main.java
trunk/core/src/openjdk/sun/sun/tools/javac/SourceClass.java
trunk/core/src/openjdk/sun/sun/tools/javac/SourceMember.java
trunk/core/src/openjdk/sun/sun/tools/javac/resources/
trunk/core/src/openjdk/sun/sun/tools/javac/resources/javac.properties
trunk/core/src/openjdk/sun/sun/tools/javac/resources/javac_ja.properties
trunk/core/src/openjdk/sun/sun/tools/javac/resources/javac_zh_CN.properties
trunk/core/src/openjdk/sun/sun/tools/javap/
trunk/core/src/openjdk/sun/sun/tools/javap/AttrData.java
trunk/core/src/openjdk/sun/sun/tools/javap/CPX.java
trunk/core/src/openjdk/sun/sun/tools/javap/CPX2.java
trunk/core/src/openjdk/sun/sun/tools/javap/ClassData.java
trunk/core/src/openjdk/sun/sun/tools/javap/Constants.java
trunk/core/src/openjdk/sun/sun/tools/javap/FieldData.java
trunk/core/src/openjdk/sun/sun/tools/javap/InnerClassData.java
trunk/core/src/openjdk/sun/sun/tools/javap/JavapEnvironment.java
trunk/core/src/openjdk/sun/sun/tools/javap/JavapPrinter.java
trunk/core/src/openjdk/sun/sun/tools/javap/LineNumData.java
trunk/core/src/openjdk/sun/sun/tools/javap/LocVarData.java
trunk/core/src/openjdk/sun/sun/tools/javap/Main.java
trunk/core/src/openjdk/sun/sun/tools/javap/MethodData.java
trunk/core/src/openjdk/sun/sun/tools/javap/RuntimeConstants.java
trunk/core/src/openjdk/sun/sun/tools/javap/StackMapData.java
trunk/core/src/openjdk/sun/sun/tools/javap/StackMapTableData.java
trunk/core/src/openjdk/sun/sun/tools/javap/Tables.java
trunk/core/src/openjdk/sun/sun/tools/javap/TrapData.java
trunk/core/src/openjdk/sun/sun/tools/javap/TypeSignature.java
trunk/core/src/openjdk/sun/sun/tools/javap/oldjavap/
trunk/core/src/openjdk/sun/sun/tools/javap/oldjavap/ConstantPrinter.java
trunk/core/src/openjdk/sun/sun/tools/javap/oldjavap/JavaP.java
trunk/core/src/openjdk/sun/sun/tools/javap/oldjavap/JavaPBinaryCode.java
trunk/core/src/openjdk/sun/sun/tools/javap/oldjavap/JavaPClassPrinter.java
trunk/core/src/openjdk/sun/sun/tools/javap/oldjavap/JavaPEnvironment.java
trunk/core/src/openjdk/sun/sun/tools/tree/
trunk/core/src/openjdk/sun/sun/tools/tree/AddExpression.java
trunk/core/src/openjdk/sun/sun/tools/tree/AndExpression.java
trunk/core/src/openjdk/sun/sun/tools/tree/ArrayAccessExpression.java
trunk/core/src/openjdk/sun/sun/tools/tree/ArrayExpression.java
trunk/core/src/openjdk/sun/sun/tools/tree/AssignAddExpression.java
trunk/core/src/openjdk/sun/sun/tools/tree/AssignBitAndExpression.java
trunk/core/src/openjdk/sun/sun/tools/tree/AssignBitOrExpression.java
trunk/core/src/openjdk/sun/sun/tools/tree/AssignBitXorExpression.java
trunk/core/src/openjdk/sun/sun/tools/tree/AssignDivideExpression.java
trunk/core/src/openjdk/sun/sun/tools/tree/AssignExpression.java
trunk/core/src/openjdk/sun/sun/tools/tree/AssignMultiplyExpression.java
trunk/core/src/openjdk/sun/sun/tools/tree/AssignOpExpression.java
trunk/core/src/openjdk/sun/sun/tools/tree/AssignRemainderExpression.java
trunk/core/src/openjdk/sun/sun/tools/tree/AssignShiftLeftExpression.java
trunk/core/src/openjdk/sun/sun/tools/tree/AssignShiftRightExpression.java
trunk/core/src/openjdk/sun/sun/tools/tree/AssignSubtractExpression.java
trunk/core/src/openjdk/sun/sun/tools/tree/AssignUnsignedShiftRightExpression.java
trunk/core/src/openjdk/sun/sun/tools/tree/BinaryArithmeticExpression.java
trunk/core/src/openjdk/sun/sun/tools/tree/BinaryAssignExpression.java
trunk/core/src/openjdk/sun/sun/tools/tree/BinaryBitExpression.java
trunk/core/src/openjdk/sun/sun/tools/tree/BinaryCompareExpression.java
trunk/core/src/openjdk/sun/sun/tools/tree/BinaryEqualityExpression.java
trunk/core/src/openjdk/sun/sun/tools/tree/BinaryExpression.java
trunk/core/src/openjdk/sun/sun/tools/tree/BinaryLogicalExpression.java
trunk/core/src/openjdk/sun/sun/tools/tree/BinaryShiftExpression.java
trunk/core/src/openjdk/sun/sun/tools/tree/BitAndExpression.java
trunk/core/src/openjdk/sun/sun/tools/tree/BitNotExpression.java
trunk/core/src/openjdk/sun/sun/tools/tree/BitOrExpression.java
trunk/core/src/openjdk/sun/sun/tools/tree/BitXorExpression.java
trunk/core/src/openjdk/sun/sun/tools/tree/BooleanExpression.java
trunk/core/src/openjdk/sun/sun/tools/tree/BreakStatement.java
trunk/core/src/openjdk/sun/sun/tools/tree/ByteExpression.java
trunk/core/src/openjdk/sun/sun/tools/tree/CaseStatement.java
trunk/core/src/openjdk/sun/sun/tools/tree/CastExpression.java
trunk/core/src/openjdk/sun/sun/tools/tree/CatchStatement.java
trunk/core/src/openjdk/sun/sun/tools/tree/CharExpression.java
trunk/core/src/openjdk/sun/sun/tools/tree/CheckContext.java
trunk/core/src/openjdk/sun/sun/tools/tree/CodeContext.java
trunk/core/src/openjdk/sun/sun/tools/tree/CommaExpression.java
trunk/core/src/openjdk/sun/sun/tools/tree/CompoundStatement.java
trunk/core/src/openjdk/sun/sun/tools/tree/ConditionVars.java
trunk/core/src/openjdk/sun/sun/tools/tree/ConditionalExpression.java
trunk/core/src/openjdk/sun/sun/tools/tree/ConstantExpression.java
trunk/core/src/openjdk/sun/sun/tools/tree/Context.java
trunk/core/src/openjdk/sun/sun/tools/tree/ContinueStatement.java
trunk/core/src/openjdk/sun/sun/tools/tree/ConvertExpression.java
trunk/core/src/openjdk/sun/sun/tools/tree/DeclarationStatement.java
trunk/core/src/openjdk/sun/sun/tools/tree/DivRemExpression.java
trunk/core/src/openjdk/sun/sun/tools/tree/DivideExpression.java
trunk/core/src/openjdk/sun/sun/tools/tree/DoStatement.java
trunk/core/src/openjdk/sun/sun/tools/tree/DoubleExpression.java
trunk/core/src/openjdk/sun/sun/tools/tree/EqualExpression.java
trunk/core/src/openjdk/sun/sun/tools/tree/ExprExpression.java
trunk/core/src/openjdk/sun/sun/tools/tree/Expression.java
trunk/core/src/openjdk/sun/sun/tools/tree/ExpressionStatement.java
trunk/core/src/openjdk/sun/sun/tools/tree/FieldExpression.java
trunk/core/src/openjdk/sun/sun/tools/tree/FieldUpdater.java
trunk/core/src/openjdk/sun/sun/tools/tree/FinallyStatement.java
trunk/core/src/openjdk/sun/sun/tools/tree/FloatExpression.java
trunk/core/src/openjdk/sun/sun/tools/tree/ForStatement.java
trunk/core/src/openjdk/sun/sun/tools/tree/GreaterExpression.java
trunk/core/src/openjdk/sun/sun/tools/tree/GreaterOrEqualExpression.java
trunk/core/src/openjdk/sun/sun/tools/tree/IdentifierExpression.java
trunk/core/src/openjdk/sun/sun/tools/tree/IfStatement.java
trunk/core/src/openjdk/sun/sun/tools/tree/IncDecExpression.java
trunk/core/src/openjdk/sun/sun/tools/tree/InlineMethodExpression.java
trunk/core/src/openjdk/sun/sun/tools/tree/InlineNewInstanceExpression.java
trunk/core/src/openjdk/sun/sun/tools/tree/InlineReturnStatement.java
trunk/core/src/openjdk/sun/sun/tools/tree/InstanceOfExpression.java
trunk/core/src/openjdk/sun/sun/tools/tree/IntExpression.java
trunk/core/src/openjdk/sun/sun/tools/tree/IntegerExpression.java
trunk/core/src/openjdk/sun/sun/tools/tree/LengthExpression.java
trunk/core/src/openjdk/sun/sun/tools/tree/LessExpression.java
trunk/core/src/openjdk/sun/sun/tools/tree/LessOrEqualExpression.java
trunk/core/src/openjdk/sun/sun/tools/tree/LocalMember.java
trunk/core/src/openjdk/sun/sun/tools/tree/LongExpression.java
trunk/core/src/openjdk/sun/sun/tools/tree/MethodExpression.java
trunk/core/src/openjdk/sun/sun/tools/tree/MultiplyExpression.java
trunk/core/src/openjdk/sun/sun/tools/tree/NaryExpression.java
trunk/core/src/openjdk/sun/sun/tools/tree/NegativeExpression.java
trunk/core/src/openjdk/sun/sun/tools/tree/NewArrayExpression.java
trunk/core/src/openjdk/sun/sun/tools/tree/NewInstanceExpression.java
trunk/core/src/openjdk/sun/sun/tools/tree/Node.java
trunk/core/src/openjdk/sun/sun/tools/tree/NotEqualExpression.java
trunk/core/src/openjdk/sun/sun/tools/tree/NotExpression.java
trunk/core/src/openjdk/sun/sun/tools/tree/NullExpression.java
trunk/core/src/openjdk/sun/sun/tools/tree/OrExpression.java
trunk/core/src/openjdk/sun/sun/tools/tree/PositiveExpression.java
trunk/core/src/openjdk/sun/sun/tools/tree/PostDecExpression.java
trunk/core/src/openjdk/sun/sun/tools/tree/PostIncExpression.java
trunk/core/src/openjdk/sun/sun/tools/tree/PreDecExpression.java
trunk/core/src/openjdk/sun/sun/tools/tree/PreIncExpression.java
trunk/core/src/openjdk/sun/sun/tools/tree/RemainderExpression.java
trunk/core/src/openjdk/sun/sun/tools/tree/ReturnStatement.java
trunk/core/src/openjdk/sun/sun/tools/tree/ShiftLeftExpression.java
trunk/core/src/openjdk/sun/sun/tools/tree/ShiftRightExpression.java
trunk/core/src/openjdk/sun/sun/tools/tree/ShortExpression.java
trunk/core/src/openjdk/sun/sun/tools/tree/Statement.java
trunk/core/src/openjdk/sun/sun/tools/tree/StringExpression.java
trunk/core/src/openjdk/sun/sun/tools/tree/SubtractExpression.java
trunk/core/src/openjdk/sun/sun/tools/tree/SuperExpression.java
trunk/core/src/openjdk/sun/sun/tools/tree/SwitchStatement.java
trunk/core/src/openjdk/sun/sun/tools/tree/SynchronizedStatement.java
trunk/core/src/openjdk/sun/sun/tools/tree/ThisExpression.java
trunk/core/src/openjdk/sun/sun/tools/tree/ThrowStatement.java
trunk/core/src/openjdk/sun/sun/tools/tree/TryStatement.java
trunk/core/src/openjdk/sun/sun/tools/tree/TypeExpression.java
trunk/core/src/openjdk/sun/sun/tools/tree/UnaryExpression.java
trunk/core/src/openjdk/sun/sun/tools/tree/UnsignedShiftRightExpression.java
trunk/core/src/openjdk/sun/sun/tools/tree/UplevelReference.java
trunk/core/src/openjdk/sun/sun/tools/tree/VarDeclarationStatement.java
trunk/core/src/openjdk/sun/sun/tools/tree/Vset.java
trunk/core/src/openjdk/sun/sun/tools/tree/WhileStatement.java
trunk/core/src/openjdk/sun/sun/tools/util/
trunk/core/src/openjdk/sun/sun/tools/util/CommandLine.java
trunk/core/src/openjdk/sun/sun/tools/util/ModifierFilter.java
Added: trunk/core/src/openjdk/sun/sun/tools/asm/ArrayData.java
===================================================================
--- trunk/core/src/openjdk/sun/sun/tools/asm/ArrayData.java (rev 0)
+++ trunk/core/src/openjdk/sun/sun/tools/asm/ArrayData.java 2007-06-10 08:42:12 UTC (rev 3232)
@@ -0,0 +1,44 @@
+/*
+ * Copyright 1995-2003 Sun Microsystems, Inc. All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Sun designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Sun 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+package sun.tools.asm;
+
+import sun.tools.java.*;
+
+/**
+ * WARNING: The contents of this source file are not part of any
+ * supported API. Code that depends on them does so at its own risk:
+ * they are subject to change or removal without notice.
+ */
+public final
+class ArrayData {
+ Type type;
+ int nargs;
+
+ public ArrayData(Type type, int nargs) {
+ this.type = type;
+ this.nargs = nargs;
+ }
+}
Added: trunk/core/src/openjdk/sun/sun/tools/asm/Assembler.java
===================================================================
--- trunk/core/src/openjdk/sun/sun/tools/asm/Assembler.java (rev 0)
+++ trunk/core/src/openjdk/sun/sun/tools/asm/Assembler.java 2007-06-10 08:42:12 UTC (rev 3232)
@@ -0,0 +1,957 @@
+/*
+ * Copyright 1994-2003 Sun Microsystems, Inc. All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Sun designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Sun 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+package sun.tools.asm;
+
+import sun.tools.java.*;
+import java.util.Enumeration;
+import java.io.IOException;
+import java.io.DataOutputStream;
+import java.io.PrintStream;
+import java.util.Vector;
+// JCOV
+import sun.tools.javac.*;
+import java.io.File;
+import java.io.BufferedInputStream;
+import java.io.DataInputStream;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.lang.String;
+// end JCOV
+
+/**
+ * This class is used to assemble the bytecode instructions for a method.
+ *
+ * WARNING: The contents of this source file are not part of any
+ * supported API. Code that depends on them does so at its own risk:
+ * they are subject to change or removal without notice.
+ *
+ * @author Arthur van Hoff
+ * @version 1.41, 08/19/97
+ */
+public final
+class Assembler implements Constants {
+ static final int NOTREACHED = 0;
+ static final int REACHED = 1;
+ static final int NEEDED = 2;
+
+ Label first = new Label();
+ Instruction last = first;
+ int maxdepth;
+ int maxvar;
+ int maxpc;
+
+ /**
+ * Add an instruction
+ */
+ public void add(Instruction inst) {
+ if (inst != null) {
+ last.next = inst;
+ last = inst;
+ }
+ }
+ public void add(long where, int opc) {
+ add(new Instruction(where, opc, null));
+ }
+ public void add(long where, int opc, Object obj) {
+ add(new Instruction(where, opc, obj));
+ }
+// JCOV
+ public void add(long where, int opc, Object obj, boolean flagCondInverted) {
+ add(new Instruction(where, opc, obj, flagCondInverted));
+ }
+
+ public void add(boolean flagNoCovered, long where, int opc, Object obj) {
+ add(new Instruction(flagNoCovered, where, opc, obj));
+ }
+
+ public void add(long where, int opc, boolean flagNoCovered) {
+ add(new Instruction(where, opc, flagNoCovered));
+ }
+
+ static Vector SourceClassList = new Vector();
+
+ static Vector TmpCovTable = new Vector();
+
+ static int[] JcovClassCountArray = new int[CT_LAST_KIND + 1];
+
+ static String JcovMagicLine = "JCOV-DATA-FILE-VERSION: 2.0";
+ static String JcovClassLine = "CLASS: ";
+ static String JcovSrcfileLine = "SRCFILE: ";
+ static String JcovTimestampLine = "TIMESTAMP: ";
+ static String JcovDataLine = "DATA: ";
+ static String JcovHeadingLine = "#kind\tcount";
+
+ static int[] arrayModifiers =
+ {M_PUBLIC, M_PRIVATE, M_PROTECTED, M_ABSTRACT, M_FINAL, M_INTERFACE};
+ static int[] arrayModifiersOpc =
+ {PUBLIC, PRIVATE, PROTECTED, ABSTRACT, FINAL, INTERFACE};
+//end JCOV
+
+ /**
+ * Optimize instructions and mark those that can be reached
+ */
+ void optimize(Environment env, Label lbl) {
+ lbl.pc = REACHED;
+
+ for (Instruction inst = lbl.next ; inst != null ; inst = inst.next) {
+ switch (inst.pc) {
+ case NOTREACHED:
+ inst.optimize(env);
+ inst.pc = REACHED;
+ break;
+ case REACHED:
+ return;
+ case NEEDED:
+ break;
+ }
+
+ switch (inst.opc) {
+ case opc_label:
+ case opc_dead:
+ if (inst.pc == REACHED) {
+ inst.pc = NOTREACHED;
+ }
+ break;
+
+ case opc_ifeq:
+ case opc_ifne:
+ case opc_ifgt:
+ case opc_ifge:
+ case opc_iflt:
+ case opc_ifle:
+ case opc_if_icmpeq:
+ case opc_if_icmpne:
+ case opc_if_icmpgt:
+ case opc_if_icmpge:
+ case opc_if_icmplt:
+ case opc_if_icmple:
+ case opc_if_acmpeq:
+ case opc_if_acmpne:
+ case opc_ifnull:
+ case opc_ifnonnull:
+ optimize(env, (Label)inst.value);
+ break;
+
+ case opc_goto:
+ optimize(env, (Label)inst.value);
+ return;
+
+ case opc_jsr:
+ optimize(env, (Label)inst.value);
+ break;
+
+ case opc_ret:
+ case opc_return:
+ case opc_ireturn:
+ case opc_lreturn:
+ case opc_freturn:
+ case opc_dreturn:
+ case opc_areturn:
+ case opc_athrow:
+ return;
+
+ case opc_tableswitch:
+ case opc_lookupswitch: {
+ SwitchData sw = (SwitchData)inst.value;
+ optimize(env, sw.defaultLabel);
+ for (Enumeration e = sw.tab.elements() ; e.hasMoreElements();) {
+ optimize(env, (Label)e.nextElement());
+ }
+ return;
+ }
+
+ case opc_try: {
+ TryData td = (TryData)inst.value;
+ td.getEndLabel().pc = NEEDED;
+ for (Enumeration e = td.catches.elements() ; e.hasMoreElements();) {
+ CatchData cd = (CatchData)e.nextElement();
+ optimize(env, cd.getLabel());
+ }
+ break;
+ }
+ }
+ }
+ }
+
+ /**
+ * Eliminate instructions that are not reached
+ */
+ boolean eliminate() {
+ boolean change = false;
+ Instruction prev = first;
+
+ for (Instruction inst = first.next ; inst != null ; inst = inst.next) {
+ if (inst.pc != NOTREACHED) {
+ prev.next = inst;
+ prev = inst;
+ inst.pc = NOTREACHED;
+ } else {
+ change = true;
+ }
+ }
+ first.pc = NOTREACHED;
+ prev.next = null;
+ return change;
+ }
+
+ /**
+ * Optimize the byte codes
+ */
+ public void optimize(Environment env) {
+ //listing(System.out);
+ do {
+ // Figure out which instructions are reached
+ optimize(env, first);
+
+ // Eliminate instructions that are not reached
+ } while (eliminate() && env.opt());
+ }
+
+ /**
+ * Collect all constants into the constant table
+ */
+ public void collect(Environment env, MemberDefinition field, ConstantPool tab) {
+ // Collect constants for arguments only
+ // if a local variable table is generated
+ if ((field != null) && env.debug_vars()) {
+ if (field.getArguments() != null) {
+ for (Enumeration e = field.getArguments().elements() ; e.hasMoreElements() ;) {
+ MemberDefinition f = (MemberDefinition)e.nextElement();
+ tab.put(f.getName().toString());
+ tab.put(f.getType().getTypeSignature());
+ }
+ }
+ }
+
+ // Collect constants from the instructions
+ for (Instruction inst = first ; inst != null ; inst = inst.next) {
+ inst.collect(tab);
+ }
+ }
+
+ /**
+ * Determine stack size, count local variables
+ */
+ void balance(Label lbl, int depth) {
+ for (Instruction inst = lbl ; inst != null ; inst = inst.next) {
+ //Environment.debugOutput(inst.toString() + ": " + depth + " => " +
+ // (depth + inst.balance()));
+ depth += inst.balance();
+ if (depth < 0) {
+ throw new CompilerError("stack under flow: " + inst.toString() + " = " + depth);
+ }
+ if (depth > maxdepth) {
+ maxdepth = depth;
+ }
+ switch (inst.opc) {
+ case opc_label:
+ lbl = (Label)inst;
+ if (inst.pc == REACHED) {
+ if (lbl.depth != depth) {
+ throw new CompilerError("stack depth error " +
+ depth + "/" + lbl.depth +
+ ": " + inst.toString());
+ }
+ return;
+ }
+ lbl.pc = REACHED;
+ lbl.depth = depth;
+ break;
+
+ case opc_ifeq:
+ case opc_ifne:
+ case opc_ifgt:
+ case opc_ifge:
+ case opc_iflt:
+ case opc_ifle:
+ case opc_if_icmpeq:
+ case opc_if_icmpne:
+ case opc_if_icmpgt:
+ case opc_if_icmpge:
+ case opc_if_icmplt:
+ case opc_if_icmple:
+ case opc_if_acmpeq:
+ case opc_if_acmpne:
+ case opc_ifnull:
+ case opc_ifnonnull:
+ balance((Label)inst.value, depth);
+ break;
+
+ case opc_goto:
+ balance((Label)inst.value, depth);
+ return;
+
+ case opc_jsr:
+ balance((Label)inst.value, depth + 1);
+ break;
+
+ case opc_ret:
+ case opc_return:
+ case opc_ireturn:
+ case opc_lreturn:
+ case opc_freturn:
+ case opc_dreturn:
+ case opc_areturn:
+ case opc_athrow:
+ return;
+
+ case opc_iload:
+ case opc_fload:
+ case opc_aload:
+ case opc_istore:
+ case opc_fstore:
+ case opc_astore: {
+ int v = ((inst.value instanceof Number)
+ ? ((Number)inst.value).intValue()
+ : ((LocalVariable)inst.value).slot) + 1;
+ if (v > maxvar)
+ maxvar = v;
+ break;
+ }
+
+ case opc_lload:
+ case opc_dload:
+ case opc_lstore:
+ case opc_dstore: {
+ int v = ((inst.value instanceof Number)
+ ? ((Number)inst.value).intValue()
+ : ((LocalVariable)inst.value).slot) + 2;
+ if (v > maxvar)
+ maxvar = v;
+ break;
+ }
+
+ case opc_iinc: {
+ int v = ((int[])inst.value)[0] + 1;
+ if (v > maxvar)
+ maxvar = v + 1;
+ break;
+ }
+
+ case opc_tableswitch:
+ case opc_lookupswitch: {
+ SwitchData sw = (SwitchData)inst.value;
+ balance(sw.defaultLabel, depth);
+ for (Enumeration e = sw.tab.elements() ; e.hasMoreElements();) {
+ balance((Label)e.nextElement(), depth);
+ }
+ return;
+ }
+
+ case opc_try: {
+ TryData td = (TryData)inst.value;
+ for (Enumeration e = td.catches.elements() ; e.hasMoreElements();) {
+ CatchData cd = (CatchData)e.nextElement();
+ balance(cd.getLabel(), depth + 1);
+ }
+ break;
+ }
+ }
+ }
+ }
+
+ /**
+ * Generate code
+ */
+ public void write(Environment env, DataOutputStream out,
+ MemberDefinition field, ConstantPool tab)
+ throws IOException {
+ //listing(System.out);
+
+ if ((field != null) && field.getArguments() != null) {
+ int sum = 0;
+ Vector v = field.getArguments();
+ for (Enumeration e = v.elements(); e.hasMoreElements(); ) {
+ MemberDefinition f = ((MemberDefinition)e.nextElement());
+ sum += f.getType().stackSize();
+ }
+ maxvar = sum;
+ }
+
+ // Make sure the stack balances. Also calculate maxvar and maxstack
+ try {
+ balance(first, 0);
+ } catch (CompilerError e) {
+ System.out.println("ERROR: " + e);
+ listing(System.out);
+ throw e;
+ }
+
+ // Assign PCs
+ int pc = 0, nexceptions = 0;
+ for (Instruction inst = first ; inst != null ; inst = inst.next) {
+ inst.pc = pc;
+ int sz = inst.size(tab);
+ if (pc<65536 && (pc+sz)>=65536) {
+ env.error(inst.where, "warn.method.too.long");
+ }
+ pc += sz;
+
+ if (inst.opc == opc_try) {
+ nexceptions += ((TryData)inst.value).catches.size();
+ }
+ }
+
+ // Write header
+ out.writeShort(maxdepth);
+ out.writeShort(maxvar);
+ out.writeInt(maxpc = pc);
+
+ // Generate code
+ for (Instruction inst = first.next ; inst != null ; inst = inst.next) {
+ inst.write(out, tab);
+ }
+
+ // write exceptions
+ out.writeShort(nexceptions);
+ if (nexceptions > 0) {
+ //listing(System.out);
+ writeExceptions(env, out, tab, first, last);
+ }
+ }
+
+ /**
+ * Write the exceptions table
+ */
+ void writeExceptions(Environment env, DataOutputStream out, ConstantPool tab, Instruction first, Instruction last) throws IOException {
+ for (Instruction inst = first ; inst != last.next ; inst = inst.next) {
+ if (inst.opc == opc_try) {
+ TryData td = (TryData)inst.value;
+ writeExceptions(env, out, tab, inst.next, td.getEndLabel());
+ for (Enumeration e = td.catches.elements() ; e.hasMoreElements();) {
+ CatchData cd = (CatchData)e.nextElement();
+ //System.out.println("EXCEPTION: " + env.getSource() + ", pc=" + inst.pc + ", end=" + td.getEndLabel().pc + ", hdl=" + cd.getLabel().pc + ", tp=" + cd.getType());
+ out.writeShort(inst.pc);
+ out.writeShort(td.getEndLabel().pc);
+ out.writeShort(cd.getLabel().pc);
+ if (cd.getType() != null) {
+ out.writeShort(tab.index(cd.getType()));
+ } else {
+ out.writeShort(0);
+ }
+ }
+ inst = td.getEndLabel();
+ }
+ }
+ }
+
+//JCOV
+ /**
+ * Write the coverage table
+ */
+ public void writeCoverageTable(Environment env, ClassDefinition c, DataOutputStream out, ConstantPool tab, long whereField) throws IOException {
+ Vector TableLot = new Vector(); /* Coverage table */
+ boolean begseg = false;
+ boolean begmeth = false;
+ long whereClass = ((SourceClass)c).getWhere();
+ Vector whereTry = new Vector();
+ int numberTry = 0;
+ int count = 0;
+
+ for (Instruction inst = first ; inst != null ; inst = inst.next) {
+ long n = (inst.where >> WHEREOFFSETBITS);
+ if (n > 0 && inst.opc != opc_label) {
+ if (!begmeth) {
+ if ( whereClass == inst.where)
+ TableLot.addElement(new Cover(CT_FIKT_METHOD, whereField, inst.pc));
+ else
+ TableLot.addElement(new Cover(CT_METHOD, whereField, inst.pc));
+ count++;
+ begmeth = true;
+ }
+ if (!begseg && !inst.flagNoCovered ) {
+ boolean findTry = false;
+ for (Enumeration e = whereTry.elements(); e.hasMoreElements();) {
+ if ( ((Long)(e.nextElement())).longValue() == inst.where) {
+ findTry = true;
+ break;
+ }
+ }
+ if (!findTry) {
+ TableLot.addElement(new Cover(CT_BLOCK, inst.where, inst.pc));
+ count++;
+ begseg = true;
+ }
+ }
+ }
+ switch (inst.opc) {
+ case opc_label:
+ begseg = false;
+ break;
+ case opc_ifeq:
+ case opc_ifne:
+ case opc_ifnull:
+ case opc_ifnonnull:
+ case opc_ifgt:
+ case opc_ifge:
+ case opc_iflt:
+ case opc_ifle:
+ case opc_if_icmpeq:
+ case opc_if_icmpne:
+ case opc_if_icmpgt:
+ case opc_if_icmpge:
+ case opc_if_icmplt:
+ case opc_if_icmple:
+ case opc_if_acmpeq:
+ case opc_if_acmpne: {
+ if ( inst.flagCondInverted ) {
+ TableLot.addElement(new Cover(CT_BRANCH_TRUE, inst.where, inst.pc));
+ TableLot.addElement(new Cover(CT_BRANCH_FALSE, inst.where, inst.pc));
+ } else {
+ TableLot.addElement(new Cover(CT_BRANCH_FALSE, inst.where, inst.pc));
+ TableLot.addElement(new Cover(CT_BRANCH_TRUE, inst.where, inst.pc));
+ }
+ count += 2;
+ begseg = false;
+ break;
+ }
+
+ case opc_goto: {
+ begseg = false;
+ break;
+ }
+
+ case opc_ret:
+ case opc_return:
+ case opc_ireturn:
+ case opc_lreturn:
+ case opc_freturn:
+ case opc_dreturn:
+ case opc_areturn:
+ case opc_athrow: {
+ break;
+ }
+
+ case opc_try: {
+ whereTry.addElement(new Long(inst.where));
+ begseg = false;
+ break;
+ }
+
+ case opc_tableswitch: {
+ SwitchData sw = (SwitchData)inst.value;
+ for (int i = sw.minValue; i <= sw.maxValue; i++) {
+ TableLot.addElement(new Cover(CT_CASE, sw.whereCase(new Integer(i)), inst.pc));
+ count++;
+ }
+ if (!sw.getDefault()) {
+ TableLot.addElement(new Cover(CT_SWITH_WO_DEF, inst.where, inst.pc));
+ count++;
+ } else {
+ TableLot.addElement(new Cover(CT_CASE, sw.whereCase("default"), inst.pc));
+ count++;
+ }
+ begseg = false;
+ break;
+ }
+ case opc_lookupswitch: {
+ SwitchData sw = (SwitchData)inst.value;
+ for (Enumeration e = sw.sortedKeys(); e.hasMoreElements() ; ) {
+ Integer v = (Integer)e.nextElement();
+ TableLot.addElement(new Cover(CT_CASE, sw.whereCase(v), inst.pc));
+ count++;
+ }
+ if (!sw.getDefault()) {
+ TableLot.addElement(new Cover(CT_SWITH_WO_DEF, inst.where, inst.pc));
+ count++;
+ } else {
+ TableLot.addElement(new Cover(CT_CASE, sw.whereCase("default"), inst.pc));
+ count++;
+ }
+ begseg = false;
+ break;
+ }
+ }
+ }
+ Cover Lot;
+ long ln, pos;
+
+ out.writeShort(count);
+ for (int i = 0; i < count; i++) {
+ Lot = (Cover)TableLot.elementAt(i);
+ ln = (Lot.Addr >> WHEREOFFSETBITS);
+ pos = (Lot.Addr << (64 - WHEREOFFSETBITS)) >> (64 - WHEREOFFSETBITS);
+ out.writeShort(Lot.NumCommand);
+ out.writeShort(Lot.Type);
+ out.writeInt((int)ln);
+ out.writeInt((int)pos);
+
+ if ( !(Lot.Type == CT_CASE && Lot.Addr == 0) ) {
+ JcovClassCountArray[Lot.Type]++;
+ }
+ }
+
+ }
+
+/*
+ * Increase count of methods for native methods
+ */
+
+public void addNativeToJcovTab(Environment env, ClassDefinition c) {
+ JcovClassCountArray[CT_METHOD]++;
+}
+
+/*
+ * Create class jcov element
+ */
+
+private String createClassJcovElement(Environment env, ClassDefinition c) {
+ String SourceClass = (Type.mangleInnerType((c.getClassDeclaration()).getName())).toString();
+ String ConvSourceClass;
+ String classJcovLine;
+
+ SourceClassList.addElement(SourceClass);
+ ConvSourceClass = SourceClass.replace('.', '/');
+ classJcovLine = JcovClassLine + ConvSourceClass;
+
+ classJcovLine = classJcovLine + " [";
+ String blank = "";
+
+ for (int i = 0; i < arrayModifiers.length; i++ ) {
+ if ((c.getModifiers() & arrayModifiers[i]) != 0) {
+ classJcovLine = classJcovLine + blank + opNames[arrayModifiersOpc[i]];
+ blank = " ";
+ }
+ }
+ classJcovLine = classJcovLine + "]";
+
+ return classJcovLine;
+}
+
+/*
+ * generate coverage data
+ */
+
+public void GenVecJCov(Environment env, ClassDefinition c, long Time) {
+ String SourceFile = ((SourceClass)c).getAbsoluteName();
+
+ TmpCovTable.addElement(createClassJcovElement(env, c));
+ TmpCovTable.addElement(JcovSrcfileLine + SourceFile);
+ TmpCovTable.addElement(JcovTimestampLine + Time);
+ TmpCovTable.addElement(JcovDataLine + "A"); // data format
+ TmpCovTable.addElement(JcovHeadingLine);
+
+ for (int i = CT_FIRST_KIND; i <= CT_LAST_KIND; i++) {
+ if (JcovClassCountArray[i] != 0) {
+ TmpCovTable.addElement(new String(i + "\t" + JcovClassCountArray[i]));
+ JcovClassCountArray[i] = 0;
+ }
+ }
+}
+
+
+/*
+ * generate file of coverage data
+ */
+
+public void GenJCov(Environment env) {
+
+ try {
+ File outFile = env.getcovFile();
+ if( outFile.exists()) {
+ DataInputStream JCovd = new DataInputStream(
+ new BufferedInputStream(
+ new FileInputStream(outFile)));
+ String CurrLine = null;
+ boolean first = true;
+ String Class;
+
+ CurrLine = JCovd.readLine();
+ if ((CurrLine != null) && CurrLine.startsWith(JcovMagicLine)) {
+ // this is a good Jcov file
+
+ while((CurrLine = JCovd.readLine()) != null ) {
+ if ( CurrLine.startsWith(JcovClassLine) ) {
+ first = true;
+ for(Enumeration e = SourceClassList.elements(); e.hasMoreElements();) {
+ String clsName = CurrLine.substring(JcovClassLine.length());
+ int idx = clsName.indexOf(' ');
+
+ if (idx != -1) {
+ clsName = clsName.substring(0, idx);
+ }
+ Class = (String)e.nextElement();
+ if ( Class.compareTo(clsName) == 0) {
+ first = false;
+ break;
+ }
+ }
+ }
+ if (first) // re-write old class
+ TmpCovTable.addElement(CurrLine);
+ }
+ }
+ JCovd.close();
+ }
+ PrintStream CovFile = new PrintStream(new DataOutputStream(new FileOutputStream(outFile)));
+ CovFile.println(JcovMagicLine);
+ for(Enumeration e = TmpCovTable.elements(); e.hasMoreElements();) {
+ CovFile.println(e.nextElement());
+ }
+ CovFile.close();
+ }
+ catch (FileNotFoundException e) {
+ System.out.println("ERROR: " + e);
+ }
+ catch (IOException e) {
+ System.out.println("ERROR: " + e);
+ }
+}
+// end JCOV
+
+
+ /**
+ * Write the linenumber table
+ */
+ public void writeLineNumberTable(Environment env, DataOutputStream out, ConstantPool tab) throws IOException {
+ long ln = -1;
+ int count = 0;
+
+ for (Instruction inst = first ; inst != null ; inst = inst.next) {
+ long n = (inst.where >> WHEREOFFSETBITS);
+ if ((n > 0) && (ln != n)) {
+ ln = n;
+ count++;
+ }
+ }
+
+ ln = -1;
+ out.writeShort(count);
+ for (Instruction inst = first ; inst != null ; inst = inst.next) {
+ long n = (inst.where >> WHEREOFFSETBITS);
+ if ((n > 0) && (ln != n)) {
+ ln = n;
+ out.writeShort(inst.pc);
+ out.writeShort((int)ln);
+ //System.out.println("pc = " + inst.pc + ", ln = " + ln);
+ }
+ }
+ }
+
+ /**
+ * Figure out when registers contain a legal value. This is done
+ * using a simple data flow algorithm. This information is later used
+ * to generate the local variable table.
+ */
+ void flowFields(Environment env, Label lbl, MemberDefinition locals[]) {
+ if (lbl.locals != null) {
+ // Been here before. Erase any conflicts.
+ MemberDefinition f[] = lbl.locals;
+ for (int i = 0 ; i < maxvar ; i++) {
+ if (f[i] != locals[i]) {
+ f[i] = null;
+ }
+ }
+ return;
+ }
+
+ // Remember the set of active registers at this point
+ lbl.locals = new MemberDefinition[maxvar];
+ System.arraycopy(locals, 0, lbl.locals, 0, maxvar);
+
+ MemberDefinition newlocals[] = new MemberDefinition[maxvar];
+ System.arraycopy(locals, 0, newlocals, 0, maxvar);
+ locals = newlocals;
+
+ for (Instruction inst = lbl.next ; inst != null ; inst = inst.next) {
+ switch (inst.opc) {
+ case opc_istore: case opc_istore_0: case opc_istore_1:
+ case opc_istore_2: case opc_istore_3:
+ case opc_fstore: case opc_fstore_0: case opc_fstore_1:
+ case opc_fstore_2: case opc_fstore_3:
+ case opc_astore: case opc_astore_0: case opc_astore_1:
+ case opc_astore_2: case opc_astore_3:
+ case opc_lstore: case opc_lstore_0: case opc_lstore_1:
+ case opc_lstore_2: case opc_lstore_3:
+ case opc_dstore: case opc_dstore_0: case opc_dstore_1:
+ case opc_dstore_2: case opc_dstore_3:
+ if (inst.value instanceof LocalVariable) {
+ LocalVariable v = (LocalVariable)inst.value;
+ locals[v.slot] = v.field;
+ }
+ break;
+
+ case opc_label:
+ flowFields(env, (Label)inst, locals);
+ return;
+
+ case opc_ifeq: case opc_ifne: case opc_ifgt:
+ case opc_ifge: case opc_iflt: case opc_ifle:
+ case opc_if_icmpeq: case opc_if_icmpne: case opc_if_icmpgt:
+ case opc_if_icmpge: case opc_if_icmplt: case opc_if_icmple:
+ case opc_if_acmpeq: case opc_if_acmpne:
+ case opc_ifnull: case opc_ifnonnull:
+ case opc_jsr:
+ flowFields(env, (Label)inst.value, locals);
+ break;
+
+ case opc_goto:
+ flowFields(env, (Label)inst.value, locals);
+ return;
+
+ case opc_return: case opc_ireturn: case opc_lreturn:
+ case opc_freturn: case opc_dreturn: case opc_areturn:
+ case opc_athrow: case opc_ret:
+ return;
+
+ case opc_tableswitch:
+ case opc_lookupswitch: {
+ SwitchData sw = (SwitchData)inst.value;
+ flowFields(env, sw.defaultLabel, locals);
+ for (Enumeration e = sw.tab.elements() ; e.hasMoreElements();) {
+ flowFields(env, (Label)e.nextElement(), locals);
+ }
+ return;
+ }
+
+ case opc_try: {
+ Vector catches = ((TryData)inst.value).catches;
+ for (Enumeration e = catches.elements(); e.hasMoreElements();) {
+ CatchData cd = (CatchData)e.nextElement();
+ flowFields(env, cd.getLabel(), locals);
+ }
+ break;
+ }
+ }
+ }
+ }
+
+ /**
+ * Write the local variable table. The necessary constants have already been
+ * added to the constant table by the collect() method. The flowFields method
+ * is used to determine which variables are alive at each pc.
+ */
+ public void writeLocalVariableTable(Environment env, MemberDefinition field, DataOutputStream out, ConstantPool tab) throws IOException {
+ MemberDefinition locals[] = new MemberDefinition[maxvar];
+ int i = 0;
+
+ // Initialize arguments
+ if ((field != null) && (field.getArguments() != null)) {
+ int reg = 0;
+ Vector v = field.getArguments();
+ for (Enumeration e = v.elements(); e.hasMoreElements(); ) {
+ MemberDefinition f = ((MemberDefinition)e.nextElement());
+ locals[reg] = f;
+ reg += f.getType().stackSize();
+ }
+ }
+
+ flowFields(env, first, locals);
+ LocalVariableTable lvtab = new LocalVariableTable();
+
+ // Initialize arguments again
+ for (i = 0; i < maxvar; i++)
+ locals[i] = null;
+ if ((field != null) && (field.getArguments() != null)) {
+ int reg = 0;
+ Vector v = field.getArguments();
+ for (Enumeration e = v.elements(); e.hasMoreElements(); ) {
+ MemberDefinition f = ((MemberDefinition)e.nextElement());
+ locals[reg] = f;
+ lvtab.define(f, reg, 0, maxpc);
+ reg += f.getType().stackSize();
+ }
+ }
+
+ int pcs[] = new int[maxvar];
+
+ for (Instruction inst = first ; inst != null ; inst = inst.next) {
+ switch (inst.opc) {
+ case opc_istore: case opc_istore_0: case opc_istore_1:
+ case opc_istore_2: case opc_istore_3: case opc_fstore:
+ case opc_fstore_0: case opc_fstore_1: case opc_fstore_2:
+ case opc_fstore_3:
+ case opc_astore: case opc_astore_0: case opc_astore_1:
+ case opc_astore_2: case opc_astore_3:
+ case opc_lstore: case opc_lstore_0: case opc_lstore_1:
+ case opc_lstore_2: case opc_lstore_3:
+ case opc_dstore: case opc_dstore_0: case opc_dstore_1:
+ case opc_dstore_2: case opc_dstore_3:
+ if (inst.value instanceof LocalVariable) {
+ LocalVariable v = (LocalVariable)inst.value;
+ int pc = (inst.next != null) ? inst.next.pc : inst.pc;
+ if (locals[v.slot] != null) {
+ lvtab.define(locals[v.slot], v.slot, pcs[v.slot], pc);
+ }
+ pcs[v.slot] = pc;
+ locals[v.slot] = v.field;
+ }
+ break;
+
+ case opc_label: {
+ // flush previous labels
+ for (i = 0 ; i < maxvar ; i++) {
+ if (locals[i] != null) {
+ lvtab.define(locals[i], i, pcs[i], inst.pc);
+ }
+ }
+ // init new labels
+ int pc = inst.pc;
+ MemberDefinition[] labelLocals = ((Label)inst).locals;
+ if (labelLocals == null) { // unreachable code??
+ for (i = 0; i < maxvar; i++)
+ locals[i] = null;
+ } else {
+ System.arraycopy(labelLocals, 0, locals, 0, maxvar);
+ }
+ for (i = 0 ; i < maxvar ; i++) {
+ pcs[i] = pc;
+ }
+ break;
+ }
+ }
+ }
+
+ // flush remaining labels
+ for (i = 0 ; i < maxvar ; i++) {
+ if (locals[i] != null) {
+ lvtab.define(locals[i], i, pcs[i], maxpc);
+ }
+ }
+
+ // write the local variable table
+ lvtab.write(env, out, tab);
+ }
+
+ /**
+ * Return true if empty
+ */
+ public boolean empty() {
+ return first == last;
+ }
+
+ /**
+ * Print the byte codes
+ */
+ public void listing(PrintStream out) {
+ out.println("-- listing --");
+ for (Instruction inst = first ; inst != null ; inst = inst.next) {
+ out.println(inst.toString());
+ }
+ }
+}
+
Added: trunk/core/src/openjdk/sun/sun/tools/asm/CatchData.java
===================================================================
--- trunk/core/src/openjdk/sun/sun/tools/asm/CatchData.java (rev 0)
+++ trunk/core/src/openjdk/sun/sun/tools/asm/CatchData.java 2007-06-10 08:42:12 UTC (rev 3232)
@@ -0,0 +1,62 @@
+/*
+ * Copyright 1994-2003 Sun Microsystems, Inc. All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Sun designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Sun 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+package sun.tools.asm;
+
+import sun.tools.java.*;
+import java.util.Hashtable;
+
+/**
+ * WARNING: The contents of this source file are not part of any
+ * supported API. Code that depends on them does so at its own risk:
+ * they are subject to change or removal without notice.
+ */
+public final
+class CatchData {
+ Object type;
+ Label label;
+
+ /**
+ * Constructor
+ */
+ CatchData(Object type) {
+ this.type = type;
+ this.label = new Label();
+ }
+
+ /**
+ * Get the label
+ */
+ public Label getLabel() {
+ return label;
+ }
+
+ /**
+ * Get the clazz
+ */
+ public Object getType() {
+ return type;
+ }
+}
Added: trunk/core/src/openjdk/sun/sun/tools/asm/ClassConstantData.java
===================================================================
--- trunk/core/src/openjdk/sun/sun/tools/asm/ClassConstantData.java (rev 0)
+++ trunk/core/src/openjdk/sun/sun/tools/asm/ClassConstantData.java 2007-06-10 08:42:12 UTC (rev 3232)
@@ -0,0 +1,79 @@
+/*
+ * Copyright 1994-2003 Sun Microsystems, Inc. All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Sun designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Sun 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+package sun.tools.asm;
+
+import sun.tools.java.*;
+import java.io.IOException;
+import java.io.DataOutputStream;
+
+/**
+ * This is a class constant pool item.
+ *
+ * WARNING: The contents of this source file are not part of any
+ * supported API. Code that depends on them does so at its own risk:
+ * they are subject to change or removal without notice.
+ */
+final
+class ClassConstantData extends ConstantPoolData {
+ String name;
+
+ /**
+ * Constructor
+ */
+
+ ClassConstantData(ConstantPool tab, ClassDeclaration clazz) {
+ String sig = clazz.getType().getTypeSignature();
+ // sig is like "Lfoo/bar;", name is like "foo/bar".
+ // We assume SIG_CLASS and SIG_ENDCLASS are 1 char each.
+ name = sig.substring(1, sig.length()-1);
+ tab.put(name);
+ }
+
+ // REMIND: this case should eventually go away.
+ ClassConstantData(ConstantPool tab, Type t) {
+ name = t.getTypeSignature();
+ tab.put(name);
+ }
+
+ /**
+ * Write the constant to the output stream
+ */
+ void write(Environment env, DataOutputStream out, ConstantPool tab) throws IOException {
+ out.writeByte(CONSTANT_CLASS);
+ out.writeShort(tab.index(name));
+ }
+
+ /**
+ * Return the order of the constant
+ */
+ int order() {
+ return 1;
+ }
+
+ public String toString() {
+ return "ClassConstantData[" + name + "]";
+ }
+}
Added: trunk/core/src/openjdk/sun/sun/tools/asm/ConstantPool.java
===================================================================
--- trunk/core/src/openjdk/sun/sun/tools/asm/ConstantPool.java (rev 0)
+++ trunk/core/src/openjdk/sun/sun/tools/asm/ConstantPool.java 2007-06-10 08:42:12 UTC (rev 3232)
@@ -0,0 +1,177 @@
+/*
+ * Copyright 1994-2003 Sun Microsystems, Inc. All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Sun designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Sun 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+package sun.tools.asm;
+
+import sun.tools.java.*;
+import sun.tools.tree.StringExpression;
+import java.util.Enumeration;
+import java.util.Hashtable;
+import java.util.Vector;
+import java.io.IOException;
+import java.io.DataOutputStream;
+
+/**
+ * A table of constants
+ *
+ * WARNING: The contents of this source file are not part of any
+ * supported API. Code that depends on them does so at its own risk:
+ * they are subject to change or removal without notice.
+ */
+public final
+class ConstantPool implements RuntimeConstants {
+ Hashtable hash = new Hashtable(101);
+
+ /**
+ * Find an entry, may return 0
+ */
+ public int index(Object obj) {
+ return ((ConstantPoolData)hash.get(obj)).index;
+ }
+
+ /**
+ * Add an entry
+ */
+ public void put(Object obj) {
+ ConstantPoolData data = (ConstantPoolData)hash.get(obj);
+ if (data == null) {
+ if (obj instanceof String) {
+ data = new StringConstantData(this, (String)obj);
+ } else if (obj instanceof StringExpression) {
+ data = new StringExpressionConstantData(this, (StringExpression)obj);
+ } else if (obj instanceof ClassDeclaration) {
+ data = new ClassConstantData(this, (ClassDeclaration)obj);
+ } else if (obj instanceof Type) {
+ data = new ClassConstantData(this, (Type)obj);
+ } else if (obj instanceof MemberDefinition) {
+ data = new FieldConstantData(this, (MemberDefinition)obj);
+ } else if (obj instanceof NameAndTypeData) {
+ data = new NameAndTypeConstantData(this, (NameAndTypeData)obj);
+ } else if (obj instanceof Number) {
+ data = new NumberConstantData(this, (Number)obj);
+ }
+ hash.put(obj, data);
+ }
+ }
+
+ /**
+ * Write to output
+ */
+ public void write(Environment env, DataOutputStream out) throws IOException {
+ ConstantPoolData list[] = new ConstantPoolData[hash.size()];
+ String keys[] = new String[list.length];
+ int index = 1, count = 0;
+
+ // Make a list of all the constant pool items
+ for (int n = 0 ; n < 5 ; n++) {
+ int first = count;
+ for (Enumeration e = hash.elements() ; e.hasMoreElements() ;) {
+ ConstantPoolData data = (ConstantPoolData)e.nextElement();
+ if (data.order() == n) {
+ keys[count] = sortKey(data);
+ list[count++] = data;
+ }
+ }
+ xsort(list, keys, first, count-1);
+ }
+
+ // Assign an index to each constant pool item
+ for (int n = 0 ; n < list.length ; n++) {
+ ConstantPoolData data = list[n];
+ data.index = index;
+ index += data.width();
+ }
+
+ // Write length
+ out.writeShort(index);
+
+ // Write each constant pool item
+ for (int n = 0 ; n < count ; n++) {
+ list[n].write(env, out, this);
+ }
+ }
+
+ private
+ static String sortKey(ConstantPoolData f) {
+ if (f instanceof NumberConstantData) {
+ Number num = ((NumberConstantData)f).num;
+ String str = num.toString();
+ int key = 3;
+ if (num instanceof Integer) key = 0;
+ else if (num instanceof Float) key = 1;
+ else if (num instanceof Long) key = 2;
+ return "\0" + (char)(str.length() + key<<8) + str;
+ }
+ if (f instanceof StringExpressionConstantData)
+ return (String)((StringExpressionConstantData)f).str.getValue();
+ if (f instanceof FieldConstantData) {
+ MemberDefinition fd = ((FieldConstantData)f).field;
+ return fd.getName()+" "+fd.getType().getTypeSignature()
+ +" "+fd.getClassDeclaration().getName();
+ }
+ if (f instanceof NameAndTypeConstantData)
+ return ((NameAndTypeConstantData)f).name+
+ " "+((NameAndTypeConstantData)f).type;
+ if (f instanceof ClassConstantData)
+ return ((ClassConstantData)f).name;
+ return ((StringConstantData)f).str;
+ }
+
+ /**
+ * Quick sort an array of pool entries and a corresponding array of Strings
+ * that are the sort keys for the field.
+ */
+ private
+ static void xsort(ConstantPoolData ff[], String ss[], int left, int right) {
+ if (left >= right)
+ return;
+ String pivot = ss[left];
+ int l = left;
+ int r = right;
+ while (l < r) {
+ while (l <= right && ss[l].compareTo(pivot) <= 0)
+ l++;
+ while (r >= left && ss[r].compareTo(pivot) > 0)
+ r--;
+ if (l < r) {
+ // swap items at l and at r
+ ConstantPoolData def = ff[l];
+ String name = ss[l];
+ ff[l] = ff[r]; ff[r] = def;
+ ss[l] = ss[r]; ss[r] = name;
+ }
+ }
+ int middle = r;
+ // swap left and middle
+ ConstantPoolData def = ff[left];
+ String name = ss[left];
+ ff[left] = ff[middle]; ff[middle] = def;
+ ss[left] = ss[middle]; ss[middle] = name;
+ xsort(ff, ss, left, middle-1);
+ xsort(ff, ss, middle + 1, right);
+ }
+
+}
+
Added: trunk/core/src/openjdk/sun/sun/tools/asm/ConstantPoolData.java
===================================================================
--- trunk/core/src/openjdk/sun/sun/tools/asm/ConstantPoolData.java (rev 0)
+++ trunk/core/src/openjdk/sun/sun/tools/asm/ConstantPoolData.java 2007-06-10 08:42:12 UTC (rev 3232)
@@ -0,0 +1,62 @@
+/*
+ * Copyright 1994-2003 Sun Microsystems, Inc. All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Sun designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Sun 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+package sun.tools.asm;
+
+import sun.tools.java.*;
+import java.io.IOException;
+import java.io.DataOutputStream;
+
+/**
+ * Base constant data class. Every constant pool data item
+ * is derived from this class.
+ *
+ * WARNING: The contents of this source file are not part of any
+ * supported API. Code that depends on them does so at its own risk:
+ * they are subject to change or removal without notice.
+ */
+
+abstract class ConstantPoolData implements RuntimeConstants {
+ int index;
+
+ /**
+ * Write the constant to the output stream
+ */
+ abstract void write(Environment env, DataOutputStream out, ConstantPool tab) throws IOException;
+
+ /**
+ * Return the order of the constant
+ */
+ int order() {
+ return 0;
+ }
+
+ /**
+ * Return the number of entries that it takes up in the constant pool
+ */
+ int width() {
+ return 1;
+ }
+}
Added: trunk/core/src/openjdk/sun/sun/tools/asm/Cover.java
===================================================================
--- trunk/core/src/openjdk/sun/sun/tools/asm/Cover.java (rev 0)
+++ trunk/core/src/openjdk/sun/sun/tools/asm/Cover.java 2007-06-10 08:42:12 UTC (rev 3232)
@@ -0,0 +1,46 @@
+/*
+ * Copyright 1996-2003 Sun Microsystems, Inc. All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Sun designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Sun 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+package sun.tools.asm;
+
+/**
+ * WARNING: The contents of this source file are not part of any
+ * supported API. Code that depends on them does so at its own ri...
[truncated message content] |