1/*
2 * Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved.
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
24package jdk.test.lib.jittester;
25
26import jdk.test.lib.jittester.types.TypeKlass;
27
28public class Symbol {
29
30    public String name;
31    public Type type;
32    public TypeKlass owner;
33    public static final int NONE = 0x00;
34    public static final int PRIVATE = 0x01;
35    public static final int DEFAULT = 0x02;
36    public static final int PROTECTED = 0x04;
37    public static final int PUBLIC = 0x08;
38    public static final int ACCESS_ATTRS_MASK = PRIVATE + PROTECTED + DEFAULT + PUBLIC;
39    public static final int STATIC = 0x10;
40    public static final int FINAL = 0x20;
41    public int flags = NONE;
42
43    protected Symbol() {
44    }
45
46    protected Symbol(String name) {
47        this.name = name;
48    }
49
50    public Symbol(String name, TypeKlass owner, Type type, int flags) {
51        this.name = name;
52        this.owner = owner;
53        this.type = type;
54        this.flags = flags;
55    }
56
57    protected Symbol(Symbol value) {
58        this.name = value.name;
59        this.owner = value.owner;
60        this.type = value.type;
61        this.flags = value.flags;
62    }
63
64    @Override
65    public boolean equals(Object o) {
66        if (this == o) {
67            return true;
68        }
69        if (o == null || !(o instanceof Symbol)) {
70            return false;
71        }
72        try {
73            Symbol s = (Symbol) o;
74            return owner.equals(s.owner) && name.equals(s.name);
75        } catch (Exception e) {
76            return false;
77        }
78    }
79
80    @Override
81    public int hashCode() {
82        return name.hashCode();
83    }
84
85
86    public boolean isStatic() {
87        return (flags & STATIC) > 0;
88    }
89
90    public boolean isFinal() {
91        return (flags & FINAL) > 0;
92    }
93
94    public boolean isPublic() {
95        return (flags & PUBLIC) > 0;
96    }
97
98    public boolean isProtected() {
99        return (flags & PROTECTED) > 0;
100    }
101
102    public boolean isPrivate() {
103        return (flags & PRIVATE) > 0;
104    }
105
106    protected Symbol copy() {
107        return new Symbol(this);
108    }
109
110    public Symbol deepCopy() {
111        return new Symbol(this);
112    }
113
114
115    public TypeKlass getOwner() {
116        return owner;
117    }
118}
119