1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-06-08 18:26:01 +02:00

cleanup and new helper methods.

This commit is contained in:
Alain Magloire 2003-08-07 03:28:59 +00:00
parent e67d9935f9
commit 3c01dde2ff

View file

@ -32,33 +32,56 @@ import org.eclipse.cdt.debug.mi.core.output.MIWhatisInfo;
public class VariableObject extends CObject implements ICDIVariableObject { public class VariableObject extends CObject implements ICDIVariableObject {
// Casting info. // Casting info.
public String casting_type; String castingType;
public int casting_index; int castingIndex;
public int casting_length; int castingLength;
Type type = null;
String typename = null;
String sizeof = null;
String name; String name;
int position; int position;
ICDIStackFrame frame; ICDIStackFrame frame;
int stackdepth; int stackdepth;
public VariableObject(VariableObject obj, String n) { String qualifiedName = null;
Type type = null;
String typename = null;
String sizeof = null;
/**
* Copy constructor.
* @param obj
*/
public VariableObject(VariableObject obj) {
super(obj.getTarget()); super(obj.getTarget());
name = n; name = obj.getName();
try { try {
frame = obj.getStackFrame(); frame = obj.getStackFrame();
} catch (CDIException e) { } catch (CDIException e) {
} }
position = obj.getPosition(); position = obj.getPosition();
stackdepth = obj.getStackDepth(); 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) { 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); super(target);
name = n; name = n;
qualifiedName = q;
frame = stack; frame = stack;
position = pos; position = pos;
stackdepth = depth; stackdepth = depth;
@ -72,6 +95,57 @@ public class VariableObject extends CObject implements ICDIVariableObject {
return stackdepth; 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() * @see org.eclipse.cdt.debug.core.cdi.ICDIVariableObject#getName()
*/ */
@ -183,4 +257,15 @@ public class VariableObject extends CObject implements ICDIVariableObject {
return typename; return typename;
} }
/**
* @see org.eclipse.cdt.debug.core.cdi.model.ICDIVariable#getQualifiedName()
*/
public String getQualifiedName() throws CDIException {
if (qualifiedName == null) {
qualifiedName = encodeVariable();
}
return qualifiedName;
}
} }