blob: e271ae840b55634c4201d9c4cc8020d9e6065cd0 (
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
|
/*******************************************************************************
* Copyright (c) 2004, 2006 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
package org.eclipse.debug.internal.ui.views.memory.renderings;
import org.eclipse.debug.core.model.IMemoryBlock;
import org.eclipse.debug.core.model.IMemoryBlockExtension;
import org.eclipse.debug.core.model.MemoryByte;
import org.eclipse.debug.internal.ui.memory.provisional.AbstractAsyncTableRendering;
import org.eclipse.debug.ui.memory.IMemoryRenderingContainer;
/**
* Abstract implementation to an integer rendering.
* @since 3.1
*
*/
public abstract class AbstractIntegerRendering extends AbstractAsyncTableRendering {
private int fDisplayEndianess = RenderingsUtil.ENDIANESS_UNKNOWN;
public AbstractIntegerRendering(String renderingId){
super(renderingId);
}
@Override
public void init(IMemoryRenderingContainer container, IMemoryBlock block) {
super.init(container, block);
// default to big endian for simple memory block
if (!(block instanceof IMemoryBlockExtension))
fDisplayEndianess = RenderingsUtil.BIG_ENDIAN;
}
/**
* @return Returns the currentEndianess.
*/
public int getDisplayEndianess() {
return fDisplayEndianess;
}
/**
* @param currentEndianess The currentEndianess to set.
*/
public void setDisplayEndianess(int currentEndianess) {
fDisplayEndianess = currentEndianess;
}
protected int getBytesEndianess(MemoryByte[] data) {
int endianess = RenderingsUtil.ENDIANESS_UNKNOWN;
if (!data[0].isEndianessKnown())
return endianess;
if (data[0].isBigEndian())
endianess = RenderingsUtil.BIG_ENDIAN;
else
endianess = RenderingsUtil.LITTLE_ENDIAN;
for (int i=1; i<data.length; i++)
{
// if endianess is not known for a byte, return unknown
if (!data[i].isEndianessKnown())
return RenderingsUtil.ENDIANESS_UNKNOWN;
int byteEndianess = data[i].isBigEndian()?RenderingsUtil.BIG_ENDIAN:RenderingsUtil.LITTLE_ENDIAN;
if (byteEndianess != endianess)
{
endianess = RenderingsUtil.ENDIANESS_UNKNOWN;
break;
}
}
return endianess;
}
}
|