diff options
Diffstat (limited to 'core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/Addr64.java')
-rw-r--r-- | core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/Addr64.java | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/Addr64.java b/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/Addr64.java index f7321cc39ff..9babfb41c18 100644 --- a/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/Addr64.java +++ b/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/Addr64.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2010 Intel Corporation and others. + * 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 @@ -8,6 +8,7 @@ * 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.utils; @@ -27,6 +28,8 @@ public class Addr64 implements IAddress, Serializable { private static final int BYTES_NUM = 8; private static final int DIGITS_NUM = BYTES_NUM * 2; private static final int CHARS_NUM = DIGITS_NUM + 2; + private static final int OCTAL_DIGITS_NUM = (BYTES_NUM * 8 + 2) / 3; + private static final int OCTAL_CHARS_NUM = OCTAL_DIGITS_NUM + 1; private static final int BINARY_DIGITS_NUM = BYTES_NUM * 8; private static final int BINARY_CHARS_NUM = BINARY_DIGITS_NUM + 2; @@ -161,7 +164,23 @@ public class Addr64 implements IAddress, Serializable { sb.append(addressString); return sb.toString(); } - + + /** + * @since 5.4 + */ + @Override + public String toOctalAddressString() { + String addressString = address.toString(8); + StringBuffer sb = new StringBuffer(OCTAL_CHARS_NUM); + int count = OCTAL_DIGITS_NUM - addressString.length(); + sb.append("0"); //$NON-NLS-1$ + for (int i = 0; i < count; ++i) { + sb.append('0'); + } + sb.append(addressString); + return sb.toString(); + } + @Override public String toBinaryAddressString() { String addressString = address.toString(2); |