author | kvn |
Tue, 22 Aug 2017 11:50:51 -0700 | |
changeset 46949 | 44ccdba2d72e |
parent 46260 | 5de61384fba6 |
permissions | -rw-r--r-- |
42650 | 1 |
/* |
46260
5de61384fba6
8172670: AOT Platform Support for Windows and Mac OS X x64
bobv
parents:
42650
diff
changeset
|
2 |
* Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved. |
42650 | 3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 |
* |
|
5 |
* This code is free software; you can redistribute it and/or modify it |
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
|
7 |
* published by the Free Software Foundation. |
|
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.tools.jaotc.binformat; |
|
25 |
||
26 |
import java.util.Objects; |
|
27 |
||
46260
5de61384fba6
8172670: AOT Platform Support for Windows and Mac OS X x64
bobv
parents:
42650
diff
changeset
|
28 |
import jdk.tools.jaotc.binformat.NativeSymbol; |
42650 | 29 |
|
30 |
public class Symbol { |
|
31 |
||
32 |
public enum Binding { |
|
33 |
UNDEFINED, |
|
34 |
LOCAL, |
|
35 |
GLOBAL |
|
36 |
} |
|
37 |
||
38 |
public enum Kind { |
|
39 |
UNDEFINED, |
|
40 |
NATIVE_FUNCTION, |
|
41 |
JAVA_FUNCTION, |
|
42 |
OBJECT, |
|
43 |
NOTYPE |
|
44 |
} |
|
45 |
||
46 |
private final String name; |
|
47 |
private final int size; |
|
48 |
private final int offset; |
|
49 |
private final Binding binding; |
|
50 |
private final Kind kind; |
|
51 |
||
52 |
private ByteContainer section; |
|
46260
5de61384fba6
8172670: AOT Platform Support for Windows and Mac OS X x64
bobv
parents:
42650
diff
changeset
|
53 |
private NativeSymbol nativeSymbol; |
42650 | 54 |
|
55 |
/** |
|
56 |
* Create symbol info. |
|
57 |
* |
|
58 |
* @param offset section offset for the defined symbol |
|
59 |
* @param kind kind of the symbol (UNDEFINED, FUNC, etc) |
|
60 |
* @param binding binding of the symbol (LOCAL, GLOBAL, ...) |
|
61 |
* @param section section in which this symbol is "defined" |
|
62 |
* @param size size of the symbol |
|
63 |
* @param name name of the symbol |
|
64 |
*/ |
|
65 |
||
66 |
public Symbol(int offset, Kind kind, Binding binding, ByteContainer section, int size, String name) { |
|
67 |
this.binding = binding; |
|
68 |
this.kind = kind; |
|
69 |
this.section = section; |
|
70 |
this.size = size; |
|
71 |
this.offset = offset; |
|
72 |
this.name = name; |
|
73 |
} |
|
74 |
||
75 |
public String getName() { |
|
76 |
return name; |
|
77 |
} |
|
78 |
||
46260
5de61384fba6
8172670: AOT Platform Support for Windows and Mac OS X x64
bobv
parents:
42650
diff
changeset
|
79 |
public NativeSymbol getNativeSymbol() { |
5de61384fba6
8172670: AOT Platform Support for Windows and Mac OS X x64
bobv
parents:
42650
diff
changeset
|
80 |
return nativeSymbol; |
42650 | 81 |
} |
82 |
||
46260
5de61384fba6
8172670: AOT Platform Support for Windows and Mac OS X x64
bobv
parents:
42650
diff
changeset
|
83 |
public void setNativeSymbol(NativeSymbol nativeSym) { |
5de61384fba6
8172670: AOT Platform Support for Windows and Mac OS X x64
bobv
parents:
42650
diff
changeset
|
84 |
this.nativeSymbol = nativeSym; |
42650 | 85 |
} |
86 |
||
87 |
public Binding getBinding() { |
|
88 |
return binding; |
|
89 |
} |
|
90 |
||
91 |
public Kind getKind() { |
|
92 |
return kind; |
|
93 |
} |
|
94 |
||
95 |
public int getSize() { |
|
96 |
return size; |
|
97 |
} |
|
98 |
||
99 |
public ByteContainer getSection() { |
|
100 |
return section; |
|
101 |
} |
|
102 |
||
103 |
public int getOffset() { |
|
104 |
return offset; |
|
105 |
} |
|
106 |
||
107 |
@Override |
|
108 |
public boolean equals(Object obj) { |
|
109 |
if (this == obj) { |
|
110 |
return true; |
|
111 |
} |
|
112 |
if (!(obj instanceof Symbol)) { |
|
113 |
return false; |
|
114 |
} |
|
115 |
if (getClass() != obj.getClass()) { |
|
116 |
return false; |
|
117 |
} |
|
118 |
||
119 |
Symbol symbol = (Symbol) obj; |
|
120 |
||
121 |
if (size != symbol.size) { |
|
122 |
return false; |
|
123 |
} |
|
124 |
if (offset != symbol.offset) { |
|
125 |
return false; |
|
126 |
} |
|
127 |
if (!name.equals(symbol.name)) { |
|
128 |
return false; |
|
129 |
} |
|
130 |
if (binding != symbol.binding) { |
|
131 |
return false; |
|
132 |
} |
|
133 |
if (kind != symbol.kind) { |
|
134 |
return false; |
|
135 |
} |
|
136 |
return !(section != null ? !section.equals(symbol.section) : symbol.section != null); |
|
137 |
} |
|
138 |
||
139 |
@Override |
|
140 |
public int hashCode() { |
|
141 |
int result = Objects.hash(name, binding, kind, section); |
|
142 |
result = 31 * result + size; |
|
143 |
result = 31 * result + offset; |
|
144 |
return result; |
|
145 |
} |
|
146 |
||
147 |
@Override |
|
148 |
public String toString() { |
|
149 |
return "[" + name + ", " + size + ", " + offset + ", " + binding + ", " + kind + ", " + section + "]"; |
|
150 |
} |
|
151 |
||
152 |
} |