01: /*
02: * Bytecode Analysis Framework
03: * Copyright (C) 2003,2004 University of Maryland
04: *
05: * This library is free software; you can redistribute it and/or
06: * modify it under the terms of the GNU Lesser General Public
07: * License as published by the Free Software Foundation; either
08: * version 2.1 of the License, or (at your option) any later version.
09: *
10: * This library is distributed in the hope that it will be useful,
11: * but WITHOUT ANY WARRANTY; without even the implied warranty of
12: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13: * Lesser General Public License for more details.
14: *
15: * You should have received a copy of the GNU Lesser General Public
16: * License along with this library; if not, write to the Free Software
17: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18: */
19:
20: package edu.umd.cs.findbugs.ba.bcp;
21:
22: import java.util.Iterator;
23: import java.util.LinkedList;
24:
25: import org.apache.bcel.generic.InstructionHandle;
26:
27: public class ByteCodePatternMatch {
28: private BindingSet bindingSet;
29: private PatternElementMatch lastElementMatch;
30: private LinkedList<PatternElementMatch> patternElementMatchList;
31:
32: public ByteCodePatternMatch(BindingSet bindingSet,
33: PatternElementMatch lastElementMatch) {
34: this .bindingSet = bindingSet;
35: this .lastElementMatch = lastElementMatch;
36: this .patternElementMatchList = new LinkedList<PatternElementMatch>();
37:
38: // The PatternElementMatch objects are stored in reverse order.
39: // So, put them in a LinkedList to get them in the right order.
40: while (lastElementMatch != null) {
41: patternElementMatchList.addFirst(lastElementMatch);
42: lastElementMatch = lastElementMatch.getPrev();
43: }
44: }
45:
46: public BindingSet getBindingSet() {
47: return bindingSet;
48: }
49:
50: public Iterator<PatternElementMatch> patternElementMatchIterator() {
51: return patternElementMatchList.iterator();
52: }
53:
54: public InstructionHandle getLabeledInstruction(String label) {
55: return lastElementMatch != null ? lastElementMatch
56: .getLabeledInstruction(label) : null;
57: }
58:
59: public PatternElementMatch getFirstLabeledMatch(String label) {
60: return lastElementMatch != null ? lastElementMatch
61: .getFirstLabeledMatch(label) : null;
62: }
63:
64: public PatternElementMatch getLastLabeledMatch(String label) {
65: return lastElementMatch != null ? lastElementMatch
66: .getLastLabeledMatch(label) : null;
67: }
68: }
69:
70: // vim:ts=4
|