blob: 200fb426a35108277d48b4f63a78411beb62bd0a (
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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
|
/*******************************************************************************
* Copyright (c) 2004, 2012 Intel Corporation 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:
* Intel Corporation - Initial API and implementation
* Mark Mitchell, CodeSourcery - Bug 136896: View variables in binary format
* Mathias Kunter - Bug 370462: View variables in octal format
*******************************************************************************/
package org.eclipse.cdt.core;
import java.math.BigInteger;
/**
* Represents C/C++ address in CDT. All implementors of this interface should be
* immutable, i.e. all methods should not modify objects, they should return
* new object.
*
* Please see Addr32 and Addr64 classes to see how this interface should
* be extended
*/
public interface IAddress extends Comparable<Object> {
/**
* Adds offset to address and returns new address object
* which is the result
* @param offset to add
* @return the new address
*/
IAddress add(BigInteger offset);
/**
* Adds offset to address and returns new address object
* which is the result
* <br><br>Note: This method has an offset limit of Long.MAX and Long.MIN, which under some addressing schems
* may impose an unnesseary limitation, see <code>IAddressa.add(BigInteger offset)</code> to handle larger offsets.
* @param offset to add
* @return the new address
*/
IAddress add(long offset);
/**
* Returns maximal offset possible for address. The offset
* should be Identicall for all addresses of given class.
* @return the max offset for this address class
*/
BigInteger getMaxOffset();
/**
* Returns distance to address. Distance may be positive or negative
* @param other address which distance is calculated to.
* @return distance to address
*/
BigInteger distanceTo(IAddress other);
/**
* Returns the value of the address.
*/
BigInteger getValue();
/**
* Returns whether this address equals the given object.
*
* @param obj the other object
* @return <code>true</code> if the addresses are equivalent,
* and <code>false</code> if they are not
*/
@Override
boolean equals(Object addr);
/**
* Return true if address is zero, i.e. minimal possible
* @return true is address is zero
*/
boolean isZero();
/**
* Return true if address is maximal, i.e. maximal possible
* @return true if address is maximal
*/
boolean isMax();
/**
* Converts address to string as an unsigned number with given radix
* @param radix to use for strng conversion
* @return a string representation of address
*/
String toString(int radix);
/**
* Identical to toString(10)
* @return a string representation of address using a radix of 10
*/
@Override
String toString();
/**
* Converts address to the hex representation with '0x' prefix and
* with all leading zeros. The length of returned string should be
* the same for all addresses of given class. I.e. 10 for 32-bit
* addresses and 18 for 64-bit addresses
*/
String toHexAddressString();
/**
* Converts address to the octal representation with '0' prefix and
* with all leading zeros. The length of returned string should be
* the same for all addresses of given class. I.e. 12 for 32-bit
* addresses and 23 for 64-bit addresses
* @since 5.4
*/
String toOctalAddressString();
/**
* Converts address to the binary representation with '0b' prefix and
* with all leading zeros. The length of returned string should be
* the same for all addresses of given class. I.e. 34 for 32-bit
* addresses and 66 for 64-bit addresses
*/
String toBinaryAddressString();
/**
* Returns amount of symbols in hex representation. Is identical to
* toHexAddressString().length(). It is present for perfomance purpose.
*
* @return the nmber os chararcter symbols to represent this address in hex.
*/
int getCharsNum();
/**
* Returns the address size in bytes.
*
* @return the number of bytes required to hold this address.
*/
int getSize();
}
|