001: /***
002: * ASM Guide
003: * Copyright (c) 2007 Eric Bruneton
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 ch3.sec2;
030:
031: import org.objectweb.asm.Label;
032: import org.objectweb.asm.MethodAdapter;
033: import org.objectweb.asm.MethodVisitor;
034:
035: /**
036: * ASM Guide example class.
037: *
038: * @author Eric Bruneton
039: */
040: public abstract class PatternMethodAdapter extends MethodAdapter {
041:
042: protected final static int SEEN_NOTHING = 0;
043:
044: protected int state;
045:
046: public PatternMethodAdapter(MethodVisitor mv) {
047: super (mv);
048: }
049:
050: public void visitFrame(int type, int nLocal, Object[] local,
051: int nStack, Object[] stack) {
052: visitInsn();
053: mv.visitFrame(type, nLocal, local, nStack, stack);
054: }
055:
056: public void visitInsn(int opcode) {
057: visitInsn();
058: mv.visitInsn(opcode);
059: }
060:
061: public void visitIntInsn(int opcode, int operand) {
062: visitInsn();
063: mv.visitIntInsn(opcode, operand);
064: }
065:
066: public void visitVarInsn(int opcode, int var) {
067: visitInsn();
068: mv.visitVarInsn(opcode, var);
069: }
070:
071: public void visitTypeInsn(int opcode, String desc) {
072: visitInsn();
073: mv.visitTypeInsn(opcode, desc);
074: }
075:
076: public void visitFieldInsn(int opcode, String owner, String name,
077: String desc) {
078: visitInsn();
079: mv.visitFieldInsn(opcode, owner, name, desc);
080: }
081:
082: public void visitMethodInsn(int opcode, String owner, String name,
083: String desc) {
084: visitInsn();
085: mv.visitMethodInsn(opcode, owner, name, desc);
086: }
087:
088: public void visitJumpInsn(int opcode, Label label) {
089: visitInsn();
090: mv.visitJumpInsn(opcode, label);
091: }
092:
093: public void visitLabel(Label label) {
094: visitInsn();
095: mv.visitLabel(label);
096: }
097:
098: public void visitLdcInsn(Object cst) {
099: visitInsn();
100: mv.visitLdcInsn(cst);
101: }
102:
103: public void visitIincInsn(int var, int increment) {
104: visitInsn();
105: mv.visitIincInsn(var, increment);
106: }
107:
108: public void visitTableSwitchInsn(int min, int max, Label dflt,
109: Label labels[]) {
110: visitInsn();
111: mv.visitTableSwitchInsn(min, max, dflt, labels);
112: }
113:
114: public void visitLookupSwitchInsn(Label dflt, int keys[],
115: Label labels[]) {
116: visitInsn();
117: mv.visitLookupSwitchInsn(dflt, keys, labels);
118: }
119:
120: public void visitMultiANewArrayInsn(String desc, int dims) {
121: visitInsn();
122: mv.visitMultiANewArrayInsn(desc, dims);
123: }
124:
125: public void visitMaxs(int maxStack, int maxLocals) {
126: visitInsn();
127: mv.visitMaxs(maxStack, maxLocals);
128: }
129:
130: protected abstract void visitInsn();
131: }
|