mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-23 22:52:11 +02:00
cleanup and new helper methods.
This commit is contained in:
parent
e67d9935f9
commit
3c01dde2ff
1 changed files with 94 additions and 9 deletions
|
@ -32,33 +32,56 @@ import org.eclipse.cdt.debug.mi.core.output.MIWhatisInfo;
|
|||
public class VariableObject extends CObject implements ICDIVariableObject {
|
||||
|
||||
// Casting info.
|
||||
public String casting_type;
|
||||
public int casting_index;
|
||||
public int casting_length;
|
||||
|
||||
Type type = null;
|
||||
String typename = null;
|
||||
String sizeof = null;
|
||||
String castingType;
|
||||
int castingIndex;
|
||||
int castingLength;
|
||||
|
||||
String name;
|
||||
int position;
|
||||
ICDIStackFrame frame;
|
||||
int stackdepth;
|
||||
|
||||
String qualifiedName = null;
|
||||
Type type = null;
|
||||
String typename = null;
|
||||
String sizeof = null;
|
||||
|
||||
public VariableObject(VariableObject obj, String n) {
|
||||
/**
|
||||
* Copy constructor.
|
||||
* @param obj
|
||||
*/
|
||||
public VariableObject(VariableObject obj) {
|
||||
super(obj.getTarget());
|
||||
name = n;
|
||||
name = obj.getName();
|
||||
try {
|
||||
frame = obj.getStackFrame();
|
||||
} catch (CDIException e) {
|
||||
}
|
||||
position = obj.getPosition();
|
||||
stackdepth = obj.getStackDepth();
|
||||
castingIndex = obj.getCastingArrayStart();
|
||||
castingLength = obj.getCastingArrayEnd();
|
||||
castingType = obj.getCastingType();
|
||||
}
|
||||
// public VariableObject(VariableObject obj, String n) {
|
||||
// super(obj.getTarget());
|
||||
// name = n;
|
||||
// try {
|
||||
// frame = obj.getStackFrame();
|
||||
// } catch (CDIException e) {
|
||||
// }
|
||||
// position = obj.getPosition();
|
||||
// stackdepth = obj.getStackDepth();
|
||||
// }
|
||||
|
||||
public VariableObject(ICDITarget target, String n, ICDIStackFrame stack, int pos, int depth) {
|
||||
this(target, n, null, stack, pos, depth);
|
||||
}
|
||||
|
||||
public VariableObject(ICDITarget target, String n, String q, ICDIStackFrame stack, int pos, int depth) {
|
||||
super(target);
|
||||
name = n;
|
||||
qualifiedName = q;
|
||||
frame = stack;
|
||||
position = pos;
|
||||
stackdepth = depth;
|
||||
|
@ -72,6 +95,57 @@ public class VariableObject extends CObject implements ICDIVariableObject {
|
|||
return stackdepth;
|
||||
}
|
||||
|
||||
public void setCastingArrayStart(int start) {
|
||||
castingIndex = start;
|
||||
}
|
||||
public int getCastingArrayStart() {
|
||||
return castingIndex;
|
||||
}
|
||||
|
||||
public void setCastingArrayEnd(int end) {
|
||||
castingLength = end;
|
||||
}
|
||||
public int getCastingArrayEnd() {
|
||||
return castingLength;
|
||||
}
|
||||
|
||||
public void setCastingType(String t) {
|
||||
castingType = t;
|
||||
}
|
||||
public String getCastingType() {
|
||||
return castingType;
|
||||
}
|
||||
|
||||
/**
|
||||
* If the variable was a cast encode the string appropriately for GDB.
|
||||
* For example castin to an array is of 2 elements:
|
||||
* (foo)@2
|
||||
* @return
|
||||
*/
|
||||
public String encodeVariable() {
|
||||
StringBuffer buffer = new StringBuffer();
|
||||
if (castingLength > 0 || castingIndex > 0) {
|
||||
buffer.append("(");
|
||||
//buffer.append('(');
|
||||
if (castingType != null && castingType.length() > 0) {
|
||||
buffer.append('(').append(castingType).append(')');
|
||||
}
|
||||
buffer.append(getName());
|
||||
//buffer.append(')');
|
||||
if (castingIndex != 0) {
|
||||
buffer.append('+').append(castingIndex);
|
||||
}
|
||||
buffer.append(')');
|
||||
buffer.append('@').append(castingLength - castingIndex);
|
||||
} else if (castingType != null && castingType.length() > 0) {
|
||||
buffer.append('(').append(castingType).append(')');
|
||||
buffer.append('(').append(getName()).append(')');
|
||||
} else {
|
||||
buffer.append(getName());
|
||||
}
|
||||
return buffer.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.eclipse.cdt.debug.core.cdi.ICDIVariableObject#getName()
|
||||
*/
|
||||
|
@ -183,4 +257,15 @@ public class VariableObject extends CObject implements ICDIVariableObject {
|
|||
return typename;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.eclipse.cdt.debug.core.cdi.model.ICDIVariable#getQualifiedName()
|
||||
*/
|
||||
public String getQualifiedName() throws CDIException {
|
||||
if (qualifiedName == null) {
|
||||
qualifiedName = encodeVariable();
|
||||
}
|
||||
return qualifiedName;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue