blob: ac7e4ac8e2c11c2dfd2c362350772543a315f25b (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
|
/*******************************************************************************
* Copyright (c) 2000, 2006 QNX Software Systems 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 accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* QNX Software Systems - Initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.debug.mi.core.cdi.model.type;
import java.math.BigInteger;
import org.eclipse.cdt.debug.core.cdi.CDIException;
import org.eclipse.cdt.debug.core.cdi.model.type.ICDIIntegralValue;
import org.eclipse.cdt.debug.mi.core.MIFormat;
import org.eclipse.cdt.debug.mi.core.cdi.model.Value;
import org.eclipse.cdt.debug.mi.core.cdi.model.Variable;
/**
*/
public abstract class IntegralValue extends Value implements ICDIIntegralValue {
/**
* @param v
*/
public IntegralValue(Variable v) {
super(v);
}
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.core.cdi.model.ICDIIntegralValue#biIntegerValue()
*/
@Override
public BigInteger bigIntegerValue() throws CDIException {
return bigIntegerValue(getValueString());
}
public static BigInteger bigIntegerValue(String valueString) {
// Coming from a reference
if (valueString.startsWith("@")) { //$NON-NLS-1$
valueString = valueString.substring(1);
int colon = valueString.indexOf(':');
if (colon != -1) {
valueString = valueString.substring(colon + 1).trim();
}
}
int space = valueString.indexOf(' ');
if (space != -1) {
valueString = valueString.substring(0, space).trim();
}
try {
return MIFormat.getBigInteger(valueString);
} catch (NumberFormatException e) {
//
}
return BigInteger.ZERO;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.core.cdi.model.ICDIIntegralValue#longValue()
*/
@Override
public long longValue() throws CDIException {
return bigIntegerValue().longValue();
}
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.core.cdi.model.ICDIIntegralValue#longValue()
*/
@Override
public int intValue() throws CDIException {
return bigIntegerValue().intValue();
}
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.core.cdi.model.ICDIIntegralValue#shortValue()
*/
@Override
public short shortValue() throws CDIException {
return bigIntegerValue().shortValue();
}
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.core.cdi.model.ICDIIntegralValue#byteValue()
*/
@Override
public int byteValue() throws CDIException {
return bigIntegerValue().byteValue();
}
}
|