0
|
1 /*
|
|
2 * Copyright 2000 Sun Microsystems, Inc. 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
|
|
20 * CA 95054 USA or visit www.sun.com if you need additional information or
|
|
21 * have any questions.
|
|
22 *
|
|
23 */
|
|
24
|
|
25 package sun.jvm.hotspot.types.basic;
|
|
26
|
|
27 import java.util.*;
|
|
28 import sun.jvm.hotspot.debugger.*;
|
|
29 import sun.jvm.hotspot.types.*;
|
|
30
|
|
31 /** <P> This specialization of BasicType implements the CIntegerType
|
|
32 interface and describes all C integer types. */
|
|
33
|
|
34 public class BasicCIntegerType extends BasicType implements CIntegerType {
|
|
35 private boolean isUnsigned;
|
|
36
|
|
37 public BasicCIntegerType(BasicTypeDataBase db, String name, boolean isUnsigned) {
|
|
38 super(db, name, null);
|
|
39
|
|
40 this.isUnsigned = isUnsigned;
|
|
41 }
|
|
42
|
|
43 public boolean equals(Object obj) {
|
|
44 if (!super.equals(obj)) {
|
|
45 return false;
|
|
46 }
|
|
47
|
|
48 if (!(obj instanceof BasicCIntegerType)) {
|
|
49 return false;
|
|
50 }
|
|
51
|
|
52 BasicCIntegerType arg = (BasicCIntegerType) obj;
|
|
53
|
|
54 if (isUnsigned != arg.isUnsigned) {
|
|
55 return false;
|
|
56 }
|
|
57
|
|
58 return true;
|
|
59 }
|
|
60
|
|
61 public String toString() {
|
|
62 String prefix = null;
|
|
63 if (isUnsigned) {
|
|
64 prefix = "unsigned";
|
|
65 }
|
|
66
|
|
67 if (prefix != null) {
|
|
68 return prefix + " " + getName();
|
|
69 }
|
|
70
|
|
71 return getName();
|
|
72 }
|
|
73
|
|
74 public boolean isCIntegerType() {
|
|
75 return true;
|
|
76 }
|
|
77
|
|
78 public boolean isUnsigned() {
|
|
79 return isUnsigned;
|
|
80 }
|
|
81
|
|
82 /** This should be called at most once, and only by the builder of
|
|
83 the TypeDataBase */
|
|
84 public void setIsUnsigned(boolean isUnsigned) {
|
|
85 this.isUnsigned = isUnsigned;
|
|
86 }
|
|
87
|
|
88 public long maxValue() {
|
|
89 return db.cIntegerTypeMaxValue(getSize(), isUnsigned());
|
|
90 }
|
|
91
|
|
92 public long minValue() {
|
|
93 return db.cIntegerTypeMinValue(getSize(), isUnsigned());
|
|
94 }
|
|
95 }
|