8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 */
23
24 package jdk.test.lib.jittester.functions;
25
26 import java.util.ArrayList;
27 import java.util.Arrays;
28 import jdk.test.lib.jittester.Symbol;
29 import jdk.test.lib.jittester.Type;
30 import jdk.test.lib.jittester.VariableInfo;
31 import jdk.test.lib.jittester.types.TypeKlass;
32
33 public class FunctionInfo extends Symbol {
34 public ArrayList<VariableInfo> argTypes;
35 public long complexity = 0;
36 public static final int ABSTRACT = 0x40;
37 public static final int NONRECURSIVE = 0x80;
38 public static final int SYNCHRONIZED = 0x100;
39
40 public FunctionInfo() {
41 }
42
43 public FunctionInfo(String name, TypeKlass ownerClass, Type returnType,
44 long complexity, int flags, VariableInfo... args) {
45 super(name, ownerClass, returnType, flags);
46 argTypes = new ArrayList<>();
47 argTypes.addAll(Arrays.asList(args));
72 protected Symbol copy() {
73 return this;
74 }
75
76 @Override
77 public Symbol deepCopy() {
78 return new FunctionInfo(this);
79 }
80
81 @Override
82 public boolean equals(Object o) {
83 if (this == o) {
84 return true;
85 }
86 if (o == null || !(o instanceof FunctionInfo)) {
87 return false;
88 }
89
90 try {
91 FunctionInfo f = (FunctionInfo) o;
92 return klass.equals(f.klass) && hasEqualSignature(o);
93 } catch (Exception e) {
94 }
95 return false;
96 }
97
98 protected boolean hasEqualSignature(Object o) {
99 try {
100 FunctionInfo f = (FunctionInfo) o;
101 if (name.equals(f.name)) {
102 int i = (flags & STATIC) > 0 ? 0 : 1;
103 int j = (f.flags & STATIC) > 0 ? 0 : 1;
104
105 if (argTypes.size() - i == f.argTypes.size() - j) {
106 while (i < argTypes.size() && j < f.argTypes.size()) {
107 if (!argTypes.get(i++).type.equals(f.argTypes.get(j++).type)) {
108 return false;
109 }
110 }
111 return true;
112 }
113 }
114 } catch (Exception e) {
115 }
116 return false;
117 }
118
119 public boolean isConstructor() {
120 return name.equals(klass.getName());
121 }
122
123 @Override
124 public int hashCode() {
125 return name.hashCode();
126 }
127
128 @Override
129 public boolean isStatic() {
130 return (flags & STATIC) > 0;
131 }
132 }
|
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 */
23
24 package jdk.test.lib.jittester.functions;
25
26 import java.util.ArrayList;
27 import java.util.Arrays;
28
29 import jdk.test.lib.jittester.Symbol;
30 import jdk.test.lib.jittester.Type;
31 import jdk.test.lib.jittester.VariableInfo;
32 import jdk.test.lib.jittester.types.TypeKlass;
33
34 public class FunctionInfo extends Symbol {
35 public ArrayList<VariableInfo> argTypes;
36 public long complexity = 0;
37 public static final int ABSTRACT = 0x40;
38 public static final int NONRECURSIVE = 0x80;
39 public static final int SYNCHRONIZED = 0x100;
40
41 public FunctionInfo() {
42 }
43
44 public FunctionInfo(String name, TypeKlass ownerClass, Type returnType,
45 long complexity, int flags, VariableInfo... args) {
46 super(name, ownerClass, returnType, flags);
47 argTypes = new ArrayList<>();
48 argTypes.addAll(Arrays.asList(args));
73 protected Symbol copy() {
74 return this;
75 }
76
77 @Override
78 public Symbol deepCopy() {
79 return new FunctionInfo(this);
80 }
81
82 @Override
83 public boolean equals(Object o) {
84 if (this == o) {
85 return true;
86 }
87 if (o == null || !(o instanceof FunctionInfo)) {
88 return false;
89 }
90
91 try {
92 FunctionInfo f = (FunctionInfo) o;
93 return owner.equals(f.owner) && hasEqualSignature(o);
94 } catch (Exception e) {
95 }
96 return false;
97 }
98
99 protected boolean hasEqualSignature(Object o) {
100 try {
101 FunctionInfo f = (FunctionInfo) o;
102 if (name.equals(f.name)) {
103 int i = (flags & STATIC) > 0 ? 0 : 1;
104 int j = (f.flags & STATIC) > 0 ? 0 : 1;
105
106 if (argTypes.size() - i == f.argTypes.size() - j) {
107 while (i < argTypes.size() && j < f.argTypes.size()) {
108 if (!argTypes.get(i++).type.equals(f.argTypes.get(j++).type)) {
109 return false;
110 }
111 }
112 return true;
113 }
114 }
115 } catch (Exception e) {
116 }
117 return false;
118 }
119
120 public boolean isConstructor() {
121 return name.equals(owner.getName());
122 }
123
124 @Override
125 public int hashCode() {
126 return name.hashCode();
127 }
128
129 @Override
130 public boolean isStatic() {
131 return (flags & STATIC) > 0;
132 }
133 }
|