View Javadoc

1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one or more
3    * contributor license agreements.  See the NOTICE file distributed with
4    * this work for additional information regarding copyright ownership.
5    * The ASF licenses this file to You under the Apache License, Version 2.0
6    * (the "License"); you may not use this file except in compliance with
7    * the License.  You may obtain a copy of the License at
8    * 
9    *     http://www.apache.org/licenses/LICENSE-2.0
10   * 
11   * Unless required by applicable law or agreed to in writing, software 
12   * distributed under the License is distributed on an "AS IS" BASIS, 
13   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
14   * See the License for the specific language governing permissions and 
15   * limitations under the License.
16   */
17  
18  
19  package org.apache.jdo.impl.enhancer.classfile;
20  
21  import java.io.PrintStream;
22  import java.util.Stack;
23  
24  /***
25   * InsnTarget is a pseudo-instruction which represents a branch target
26   * in an instruction stream.
27   */
28  public class InsnTarget extends Insn {
29  
30      private boolean branchTarget = false;
31  
32      public int nStackArgs() {
33          return 0;
34      }
35  
36      public int nStackResults() {
37          return 0;
38      }
39  
40      public String argTypes() {
41          return "";
42      }
43  
44      public String resultTypes() {
45          return "";
46      }
47  
48      public boolean branches() {
49          return false;
50      }
51  
52      public void setBranchTarget() {
53          branchTarget = true;
54      }
55  
56      /* not valid unless method instructions processed specially */
57      public boolean isBranchTarget() {
58          return branchTarget;
59      }
60  
61      /***
62       * Constructor
63       */
64      public InsnTarget() {
65          super(opc_target, NO_OFFSET);
66      }
67  
68      /***
69       * Compares this instance with another for structural equality.
70       */
71      //@olsen: added method
72      public boolean isEqual(Stack msg, Object obj) {
73          if (!(obj instanceof InsnTarget)) {
74              msg.push("obj/obj.getClass() = "
75                       + (obj == null ? null : obj.getClass()));
76              msg.push("this.getClass() = "
77                       + this.getClass());
78              return false;
79          }
80          InsnTarget other = (InsnTarget)obj;
81  
82          if (!super.isEqual(msg, other)) {
83              return false;
84          }
85  
86          if (this.branchTarget != other.branchTarget) {
87              msg.push(String.valueOf("branchTarget = "
88                                      + other.branchTarget));
89              msg.push(String.valueOf("branchTarget = "
90                                      + this.branchTarget));
91              return false;
92          }
93          return true;
94      }
95  
96      /* package local methods *//package-summary/html">class="comment"> package local methods *//package-summary.html">/* package local methods *//package-summary.html">class="comment"> package local methods */
97  
98      void print (PrintStream out, int indent) {
99          ClassPrint.spaces(out, indent);
100         out.println(offset() + ":");
101     }
102 
103     int store(byte buf[], int index) {
104         return index;
105     }
106 
107     int size() {
108         return 0;
109     }
110 
111     InsnTarget(int offset) {
112         super(opc_target, offset);
113     }
114 }