Skip to content

Commit 512233e

Browse files
ctf: simplify integer declaration
optimizations negatively affect ctf2. Roles do not work with it. Change-Id: I34812fe76934c62f00ae3de10cdfad074e996f7f Signed-off-by: Matthew Khouzam <[email protected]>
1 parent 1cb8ae3 commit 512233e

File tree

1 file changed

+2
-74
lines changed

1 file changed

+2
-74
lines changed

ctf/org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/ctf/core/event/types/IntegerDeclaration.java

Lines changed: 2 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -51,14 +51,9 @@ public final class IntegerDeclaration extends Declaration implements ISimpleData
5151
// Helpers
5252
// ------------------------------------------------------------------------
5353

54-
private static final int SIZE_64 = 64;
55-
private static final int SIZE_32 = 32;
56-
private static final int SIZE_27 = 27;
57-
private static final int SIZE_16 = 16;
58-
private static final int SIZE_8 = 8;
59-
private static final int SIZE_5 = 5;
6054
private static final int BYTE_ALIGN = 8;
6155
private static final int BASE_10 = 10;
56+
private static final int SIZE_8 = 8;
6257
/**
6358
* unsigned int 32 bits big endian
6459
*/
@@ -178,69 +173,6 @@ private static class IntervalNode {
178173
*/
179174
public static IntegerDeclaration createDeclaration(int len, boolean signed, int base,
180175
@Nullable ByteOrder byteOrder, Encoding encoding, String clock, long alignment, @Nullable String role) {
181-
if (encoding.equals(Encoding.NONE) && (clock.equals("")) && base == BASE_10 && byteOrder != null) { //$NON-NLS-1$
182-
if (alignment == BYTE_ALIGN) {
183-
switch (len) {
184-
case SIZE_8:
185-
return signed ? INT_8_DECL : UINT_8_DECL;
186-
case SIZE_16:
187-
if (!signed) {
188-
if (isBigEndian(byteOrder)) {
189-
return UINT_16B_DECL;
190-
}
191-
return UINT_16L_DECL;
192-
}
193-
break;
194-
case SIZE_32:
195-
if (signed) {
196-
if (isBigEndian(byteOrder)) {
197-
return INT_32B_DECL;
198-
}
199-
return INT_32L_DECL;
200-
}
201-
if (isBigEndian(byteOrder)) {
202-
return UINT_32B_DECL;
203-
}
204-
return UINT_32L_DECL;
205-
case SIZE_64:
206-
if (signed) {
207-
if (isBigEndian(byteOrder)) {
208-
return INT_64B_DECL;
209-
}
210-
return INT_64L_DECL;
211-
}
212-
if (isBigEndian(byteOrder)) {
213-
return UINT_64B_DECL;
214-
}
215-
return UINT_64L_DECL;
216-
217-
default:
218-
219-
}
220-
221-
} else if (alignment == 1) {
222-
switch (len) {
223-
case SIZE_5:
224-
if (!signed) {
225-
if (isBigEndian(byteOrder)) {
226-
return UINT_5B_DECL;
227-
}
228-
return UINT_5L_DECL;
229-
}
230-
break;
231-
case SIZE_27:
232-
if (!signed) {
233-
if (isBigEndian(byteOrder)) {
234-
return UINT_27B_DECL;
235-
}
236-
return UINT_27L_DECL;
237-
}
238-
break;
239-
default:
240-
break;
241-
}
242-
}
243-
}
244176
return new IntegerDeclaration(len, signed, base, byteOrder, encoding, clock, alignment, role, null);
245177
}
246178

@@ -324,10 +256,6 @@ public static IntegerDeclaration createVarintDeclaration(boolean signed, int bas
324256
return decl;
325257
}
326258

327-
private static boolean isBigEndian(@Nullable ByteOrder byteOrder) {
328-
return (byteOrder != null) && byteOrder.equals(ByteOrder.BIG_ENDIAN);
329-
}
330-
331259
/**
332260
* Constructor
333261
*
@@ -618,7 +546,7 @@ private long read(BitBuffer input) throws CTFException {
618546
input.setByteOrder(getByteOrder());
619547
}
620548

621-
if (length > SIZE_64) {
549+
if (length > Long.SIZE) {
622550
throw new CTFException("Cannot read an integer with over 64 bits. Length given: " + length); //$NON-NLS-1$
623551
}
624552

0 commit comments

Comments
 (0)