comparison truffle/com.oracle.truffle.api/src/com/oracle/truffle/api/utilities/PrimitiveValueProfile.java @ 22123:329fe954f6f2

Can compile Truffle API with following javac lints: -Xlint:all,-auxiliaryclass,-try,-processing
author Jaroslav Tulach <jaroslav.tulach@oracle.com>
date Wed, 02 Sep 2015 13:15:51 +0200
parents 9c8c0937da41
children dc83cc1f94f2
comparison
equal deleted inserted replaced
22122:ac017ff52c07 22123:329fe954f6f2
48 PrimitiveValueProfile() { 48 PrimitiveValueProfile() {
49 } 49 }
50 50
51 @SuppressWarnings("unchecked") 51 @SuppressWarnings("unchecked")
52 @Override 52 @Override
53 public Object profile(Object value) { 53 public <T> T profile(T v) {
54 Object value = v;
54 Object snapshot = this.cachedValue; 55 Object snapshot = this.cachedValue;
55 if (snapshot != GENERIC) { 56 if (snapshot != GENERIC) {
56 if (snapshot instanceof Byte) { 57 if (snapshot instanceof Byte) {
57 if (value instanceof Byte && (byte) snapshot == (byte) value) { 58 if (value instanceof Byte && (byte) snapshot == (byte) value) {
58 return snapshot; 59 return (T) snapshot;
59 } 60 }
60 } else if (snapshot instanceof Short) { 61 } else if (snapshot instanceof Short) {
61 if (value instanceof Short && (short) snapshot == (short) value) { 62 if (value instanceof Short && (short) snapshot == (short) value) {
62 return snapshot; 63 return (T) snapshot;
63 } 64 }
64 } else if (snapshot instanceof Integer) { 65 } else if (snapshot instanceof Integer) {
65 if (value instanceof Integer && (int) snapshot == (int) value) { 66 if (value instanceof Integer && (int) snapshot == (int) value) {
66 return snapshot; 67 return (T) snapshot;
67 } 68 }
68 } else if (snapshot instanceof Long) { 69 } else if (snapshot instanceof Long) {
69 if (value instanceof Long && (long) snapshot == (long) value) { 70 if (value instanceof Long && (long) snapshot == (long) value) {
70 return snapshot; 71 return (T) snapshot;
71 } 72 }
72 } else if (snapshot instanceof Float) { 73 } else if (snapshot instanceof Float) {
73 if (value instanceof Float && exactCompare((float) snapshot, (float) value)) { 74 if (value instanceof Float && exactCompare((float) snapshot, (float) value)) {
74 return snapshot; 75 return (T) snapshot;
75 } 76 }
76 } else if (snapshot instanceof Double) { 77 } else if (snapshot instanceof Double) {
77 if (value instanceof Double && exactCompare((double) snapshot, (double) value)) { 78 if (value instanceof Double && exactCompare((double) snapshot, (double) value)) {
78 return snapshot; 79 return (T) snapshot;
79 } 80 }
80 } else if (snapshot instanceof Boolean) { 81 } else if (snapshot instanceof Boolean) {
81 if (value instanceof Boolean && (boolean) snapshot == (boolean) value) { 82 if (value instanceof Boolean && (boolean) snapshot == (boolean) value) {
82 return snapshot; 83 return (T) snapshot;
83 } 84 }
84 } else if (snapshot instanceof Character) { 85 } else if (snapshot instanceof Character) {
85 if (value instanceof Character && (char) snapshot == (char) value) { 86 if (value instanceof Character && (char) snapshot == (char) value) {
86 return snapshot; 87 return (T) snapshot;
87 } 88 }
88 } else if (snapshot == value) { 89 } else if (snapshot == value) {
89 return snapshot; 90 return (T) snapshot;
90 } 91 }
91 cacheMiss(value); 92 cacheMiss(value);
92 } 93 }
93 return value; 94 return (T) value;
94 } 95 }
95 96
96 public byte profile(byte value) { 97 public byte profile(byte value) {
97 Object snapshot = this.cachedValue; 98 Object snapshot = this.cachedValue;
98 if (snapshot != GENERIC) { 99 if (snapshot != GENERIC) {