001: /***
002: * Retrotranslator: a Java bytecode transformer that translates Java classes
003: * compiled with JDK 5.0 into classes that can be run on JVM 1.4.
004: *
005: * Copyright (c) 2005 - 2008 Taras Puchko
006: * All rights reserved.
007: *
008: * Redistribution and use in source and binary forms, with or without
009: * modification, are permitted provided that the following conditions
010: * are met:
011: * 1. Redistributions of source code must retain the above copyright
012: * notice, this list of conditions and the following disclaimer.
013: * 2. Redistributions in binary form must reproduce the above copyright
014: * notice, this list of conditions and the following disclaimer in the
015: * documentation and/or other materials provided with the distribution.
016: * 3. Neither the name of the copyright holders nor the names of its
017: * contributors may be used to endorse or promote products derived from
018: * this software without specific prior written permission.
019: *
020: * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
021: * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
022: * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
023: * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
024: * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
025: * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
026: * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
027: * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
028: * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
029: * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
030: * THE POSSIBILITY OF SUCH DAMAGE.
031: */package net.sf.retrotranslator.transformer;
032:
033: import net.sf.retrotranslator.runtime.asm.*;
034:
035: /**
036: * @author Taras Puchko
037: */
038: abstract class AbstractMethodVisitor implements MethodVisitor {
039:
040: protected final MethodVisitor mv;
041:
042: protected AbstractMethodVisitor(MethodVisitor mv) {
043: this .mv = mv;
044: }
045:
046: protected abstract void flush();
047:
048: public AnnotationVisitor visitAnnotation(String desc,
049: boolean visible) {
050: flush();
051: return mv.visitAnnotation(desc, visible);
052: }
053:
054: public AnnotationVisitor visitAnnotationDefault() {
055: flush();
056: return mv.visitAnnotationDefault();
057: }
058:
059: public void visitAttribute(Attribute attr) {
060: flush();
061: mv.visitAttribute(attr);
062: }
063:
064: public void visitCode() {
065: flush();
066: mv.visitCode();
067: }
068:
069: public void visitEnd() {
070: flush();
071: mv.visitEnd();
072: }
073:
074: public void visitFieldInsn(int opcode, String owner, String name,
075: String desc) {
076: flush();
077: mv.visitFieldInsn(opcode, owner, name, desc);
078: }
079:
080: public void visitIincInsn(int var, int increment) {
081: flush();
082: mv.visitIincInsn(var, increment);
083: }
084:
085: public void visitInsn(int opcode) {
086: flush();
087: mv.visitInsn(opcode);
088: }
089:
090: public void visitIntInsn(int opcode, int operand) {
091: flush();
092: mv.visitIntInsn(opcode, operand);
093: }
094:
095: public void visitJumpInsn(int opcode, Label label) {
096: flush();
097: mv.visitJumpInsn(opcode, label);
098: }
099:
100: public void visitLabel(Label label) {
101: flush();
102: mv.visitLabel(label);
103: }
104:
105: public void visitLdcInsn(Object cst) {
106: flush();
107: mv.visitLdcInsn(cst);
108: }
109:
110: public void visitLineNumber(int line, Label start) {
111: flush();
112: mv.visitLineNumber(line, start);
113: }
114:
115: public void visitLocalVariable(String name, String desc,
116: String signature, Label start, Label end, int index) {
117: flush();
118: mv.visitLocalVariable(name, desc, signature, start, end, index);
119: }
120:
121: public void visitLookupSwitchInsn(Label dflt, int[] keys,
122: Label[] labels) {
123: flush();
124: mv.visitLookupSwitchInsn(dflt, keys, labels);
125: }
126:
127: public void visitMaxs(int maxStack, int maxLocals) {
128: flush();
129: mv.visitMaxs(maxStack, maxLocals);
130: }
131:
132: public void visitMethodInsn(int opcode, String owner, String name,
133: String desc) {
134: flush();
135: mv.visitMethodInsn(opcode, owner, name, desc);
136: }
137:
138: public void visitMultiANewArrayInsn(String desc, int dims) {
139: flush();
140: mv.visitMultiANewArrayInsn(desc, dims);
141: }
142:
143: public AnnotationVisitor visitParameterAnnotation(int parameter,
144: String desc, boolean visible) {
145: flush();
146: return mv.visitParameterAnnotation(parameter, desc, visible);
147: }
148:
149: public void visitTableSwitchInsn(int min, int max, Label dflt,
150: Label[] labels) {
151: flush();
152: mv.visitTableSwitchInsn(min, max, dflt, labels);
153: }
154:
155: public void visitTryCatchBlock(Label start, Label end,
156: Label handler, String type) {
157: flush();
158: mv.visitTryCatchBlock(start, end, handler, type);
159: }
160:
161: public void visitTypeInsn(int opcode, String desc) {
162: flush();
163: mv.visitTypeInsn(opcode, desc);
164: }
165:
166: public void visitVarInsn(int opcode, int var) {
167: flush();
168: mv.visitVarInsn(opcode, var);
169: }
170:
171: }
|