Source Code Cross Referenced for AbstractVisitor.java in  » Web-Framework » rife-1.6.1 » com » uwyn » rife » asm » util » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Web Framework » rife 1.6.1 » com.uwyn.rife.asm.util 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /***
002:         * ASM: a very small and fast Java bytecode manipulation framework
003:         * Copyright (c) 2000-2005 INRIA, France Telecom
004:         * All rights reserved.
005:         *
006:         * Redistribution and use in source and binary forms, with or without
007:         * modification, are permitted provided that the following conditions
008:         * are met:
009:         * 1. Redistributions of source code must retain the above copyright
010:         *    notice, this list of conditions and the following disclaimer.
011:         * 2. Redistributions in binary form must reproduce the above copyright
012:         *    notice, this list of conditions and the following disclaimer in the
013:         *    documentation and/or other materials provided with the distribution.
014:         * 3. Neither the name of the copyright holders nor the names of its
015:         *    contributors may be used to endorse or promote products derived from
016:         *    this software without specific prior written permission.
017:         *
018:         * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
019:         * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
020:         * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
021:         * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
022:         * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
023:         * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
024:         * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
025:         * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
026:         * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
027:         * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
028:         * THE POSSIBILITY OF SUCH DAMAGE.
029:         */package com.uwyn.rife.asm.util;
030:
031:        import java.io.PrintWriter;
032:        import java.util.ArrayList;
033:        import java.util.List;
034:
035:        import com.uwyn.rife.asm.Attribute;
036:        import com.uwyn.rife.asm.util.attrs.ASMStackMapAttribute;
037:        import com.uwyn.rife.asm.util.attrs.ASMStackMapTableAttribute;
038:
039:        /**
040:         * An abstract visitor.
041:         * 
042:         * @author Eric Bruneton
043:         */
044:        public abstract class AbstractVisitor {
045:
046:            /**
047:             * The names of the Java Virtual Machine opcodes.
048:             */
049:            public final static String[] OPCODES;
050:            /**
051:             * Types for <code>operand</code> parameter of the
052:             * {@link com.uwyn.rife.asm.MethodVisitor#visitIntInsn} method when
053:             * <code>opcode</code> is <code>NEWARRAY</code>.
054:             */
055:            public final static String[] TYPES;
056:
057:            static {
058:                String s = "NOP,ACONST_NULL,ICONST_M1,ICONST_0,ICONST_1,ICONST_2,"
059:                        + "ICONST_3,ICONST_4,ICONST_5,LCONST_0,LCONST_1,FCONST_0,"
060:                        + "FCONST_1,FCONST_2,DCONST_0,DCONST_1,BIPUSH,SIPUSH,LDC,,,"
061:                        + "ILOAD,LLOAD,FLOAD,DLOAD,ALOAD,,,,,,,,,,,,,,,,,,,,,IALOAD,"
062:                        + "LALOAD,FALOAD,DALOAD,AALOAD,BALOAD,CALOAD,SALOAD,ISTORE,"
063:                        + "LSTORE,FSTORE,DSTORE,ASTORE,,,,,,,,,,,,,,,,,,,,,IASTORE,"
064:                        + "LASTORE,FASTORE,DASTORE,AASTORE,BASTORE,CASTORE,SASTORE,POP,"
065:                        + "POP2,DUP,DUP_X1,DUP_X2,DUP2,DUP2_X1,DUP2_X2,SWAP,IADD,LADD,"
066:                        + "FADD,DADD,ISUB,LSUB,FSUB,DSUB,IMUL,LMUL,FMUL,DMUL,IDIV,LDIV,"
067:                        + "FDIV,DDIV,IREM,LREM,FREM,DREM,INEG,LNEG,FNEG,DNEG,ISHL,LSHL,"
068:                        + "ISHR,LSHR,IUSHR,LUSHR,IAND,LAND,IOR,LOR,IXOR,LXOR,IINC,I2L,"
069:                        + "I2F,I2D,L2I,L2F,L2D,F2I,F2L,F2D,D2I,D2L,D2F,I2B,I2C,I2S,LCMP,"
070:                        + "FCMPL,FCMPG,DCMPL,DCMPG,IFEQ,IFNE,IFLT,IFGE,IFGT,IFLE,"
071:                        + "IF_ICMPEQ,IF_ICMPNE,IF_ICMPLT,IF_ICMPGE,IF_ICMPGT,IF_ICMPLE,"
072:                        + "IF_ACMPEQ,IF_ACMPNE,GOTO,JSR,RET,TABLESWITCH,LOOKUPSWITCH,"
073:                        + "IRETURN,LRETURN,FRETURN,DRETURN,ARETURN,RETURN,GETSTATIC,"
074:                        + "PUTSTATIC,GETFIELD,PUTFIELD,INVOKEVIRTUAL,INVOKESPECIAL,"
075:                        + "INVOKESTATIC,INVOKEINTERFACE,,NEW,NEWARRAY,ANEWARRAY,"
076:                        + "ARRAYLENGTH,ATHROW,CHECKCAST,INSTANCEOF,MONITORENTER,"
077:                        + "MONITOREXIT,,MULTIANEWARRAY,IFNULL,IFNONNULL,";
078:                OPCODES = new String[200];
079:                int i = 0;
080:                int j = 0;
081:                int l;
082:                while ((l = s.indexOf(',', j)) > 0) {
083:                    OPCODES[i++] = j + 1 == l ? null : s.substring(j, l);
084:                    j = l + 1;
085:                }
086:
087:                s = "T_BOOLEAN,T_CHAR,T_FLOAT,T_DOUBLE,T_BYTE,T_SHORT,T_INT,T_LONG,";
088:                TYPES = new String[12];
089:                j = 0;
090:                i = 4;
091:                while ((l = s.indexOf(',', j)) > 0) {
092:                    TYPES[i++] = s.substring(j, l);
093:                    j = l + 1;
094:                }
095:            }
096:
097:            /**
098:             * The text to be printed. Since the code of methods is not necessarily
099:             * visited in sequential order, one method after the other, but can be
100:             * interlaced (some instructions from method one, then some instructions
101:             * from method two, then some instructions from method one again...), it is
102:             * not possible to print the visited instructions directly to a sequential
103:             * stream. A class is therefore printed in a two steps process: a string
104:             * tree is constructed during the visit, and printed to a sequential stream
105:             * at the end of the visit. This string tree is stored in this field, as a
106:             * string list that can contain other string lists, which can themselves
107:             * contain other string lists, and so on.
108:             */
109:            public final List text;
110:
111:            /**
112:             * A buffer that can be used to create strings.
113:             */
114:            protected final StringBuffer buf;
115:
116:            /**
117:             * Constructs a new {@link AbstractVisitor}.
118:             */
119:            protected AbstractVisitor() {
120:                this .text = new ArrayList();
121:                this .buf = new StringBuffer();
122:            }
123:
124:            /**
125:             * Returns the text printed by this visitor.
126:             * 
127:             * @return the text printed by this visitor.
128:             */
129:            public List getText() {
130:                return text;
131:            }
132:
133:            /**
134:             * Appends a quoted string to a given buffer.
135:             * 
136:             * @param buf the buffer where the string must be added.
137:             * @param s the string to be added.
138:             */
139:            public static void appendString(final StringBuffer buf,
140:                    final String s) {
141:                buf.append("\"");
142:                for (int i = 0; i < s.length(); ++i) {
143:                    char c = s.charAt(i);
144:                    if (c == '\n') {
145:                        buf.append("\\n");
146:                    } else if (c == '\r') {
147:                        buf.append("\\r");
148:                    } else if (c == '\\') {
149:                        buf.append("\\\\");
150:                    } else if (c == '"') {
151:                        buf.append("\\\"");
152:                    } else if (c < 0x20 || c > 0x7f) {
153:                        buf.append("\\u");
154:                        if (c < 0x10) {
155:                            buf.append("000");
156:                        } else if (c < 0x100) {
157:                            buf.append("00");
158:                        } else if (c < 0x1000) {
159:                            buf.append("0");
160:                        }
161:                        buf.append(Integer.toString(c, 16));
162:                    } else {
163:                        buf.append(c);
164:                    }
165:                }
166:                buf.append("\"");
167:            }
168:
169:            /**
170:             * Prints the given string tree.
171:             * 
172:             * @param pw the writer to be used to print the tree.
173:             * @param l a string tree, i.e., a string list that can contain other string
174:             *        lists, and so on recursively.
175:             */
176:            void printList(final PrintWriter pw, final List l) {
177:                for (int i = 0; i < l.size(); ++i) {
178:                    Object o = l.get(i);
179:                    if (o instanceof  List) {
180:                        printList(pw, (List) o);
181:                    } else {
182:                        pw.print(o.toString());
183:                    }
184:                }
185:            }
186:
187:            /**
188:             * Returns the default {@link ASMifiable} prototypes.
189:             * 
190:             * @return the default {@link ASMifiable} prototypes.
191:             */
192:            public static Attribute[] getDefaultAttributes() {
193:                try {
194:                    return new Attribute[] { new ASMStackMapAttribute(),
195:                            new ASMStackMapTableAttribute() };
196:                } catch (Exception e) {
197:                    return new Attribute[0];
198:                }
199:            }
200:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.