/*******************************************************************************
- * Copyright (c) 2011, 2013 Ericsson, Ecole Polytechnique de Montreal and others
+ * Copyright (c) 2011, 2014 Ericsson, Ecole Polytechnique de Montreal and others
*
* All rights reserved. This program and the accompanying materials are made
* available under the terms of the Eclipse Public License v1.0 which
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
+import org.eclipse.tracecompass.ctf.core.CTFException;
import org.eclipse.tracecompass.ctf.core.event.io.BitBuffer;
import org.eclipse.tracecompass.ctf.core.event.scope.IDefinitionScope;
-import org.eclipse.tracecompass.ctf.core.trace.CTFReaderException;
/**
* A CTF float declaration.
return fAlignement;
}
- /**
- * @since 3.0
- */
@Override
public int getMaximumSize() {
return fMantissa + fExponent + 1;
// Operations
// ------------------------------------------------------------------------
- /**
- * @since 3.0
- */
@Override
public FloatDefinition createDefinition(@Nullable IDefinitionScope definitionScope,
- String fieldName, BitBuffer input) throws CTFReaderException {
+ String fieldName, BitBuffer input) throws CTFException {
ByteOrder byteOrder = input.getByteOrder();
input.setByteOrder(fByteOrder);
double value = read(input);
return "[declaration] float[" + Integer.toHexString(hashCode()) + ']'; //$NON-NLS-1$
}
- private double read(BitBuffer input) throws CTFReaderException {
+ private double read(BitBuffer input) throws CTFException {
/* Offset the buffer position wrt the current alignment */
alignRead(input);
final int exp = getExponent();
}
private static double readRawFloat32(BitBuffer input, final int manBits,
- final int expBits) throws CTFReaderException {
+ final int expBits) throws CTFException {
long temp = input.get(32, false);
return createFloat(temp, manBits - 1, expBits);
}
private static double readRawFloat64(BitBuffer input, final int manBits,
- final int expBits) throws CTFReaderException {
+ final int expBits) throws CTFException {
long temp = input.get(64, false);
return createFloat(temp, manBits - 1, expBits);
}
ret *= expPow;
return ret;
}
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + (int) (fAlignement ^ (fAlignement >>> 32));
+ result = prime * result + fByteOrder.toString().hashCode(); // don't evaluate object but string
+ result = prime * result + fExponent;
+ result = prime * result + fMantissa;
+ return result;
+ }
+
+ @Override
+ public boolean equals(@Nullable Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj == null) {
+ return false;
+ }
+ if (getClass() != obj.getClass()) {
+ return false;
+ }
+ FloatDeclaration other = (FloatDeclaration) obj;
+ if (fAlignement != other.fAlignement) {
+ return false;
+ }
+ if (!fByteOrder.equals(other.fByteOrder)) {
+ return false;
+ }
+ if (fExponent != other.fExponent) {
+ return false;
+ }
+ if (fMantissa != other.fMantissa) {
+ return false;
+ }
+ return true;
+ }
+
+ @Override
+ public boolean isBinaryEquivalent(@Nullable IDeclaration obj) {
+ return equals(obj);
+ }
}