X-Git-Url: http://git.phpeclipse.com diff --git a/net.sourceforge.phpeclipse.debug.core/src/net/sourceforge/phpdt/internal/debug/core/model/PHPDBGEvalString.java b/net.sourceforge.phpeclipse.debug.core/src/net/sourceforge/phpdt/internal/debug/core/model/PHPDBGEvalString.java index 8916bce..1439ed9 100644 --- a/net.sourceforge.phpeclipse.debug.core/src/net/sourceforge/phpdt/internal/debug/core/model/PHPDBGEvalString.java +++ b/net.sourceforge.phpeclipse.debug.core/src/net/sourceforge/phpdt/internal/debug/core/model/PHPDBGEvalString.java @@ -31,9 +31,9 @@ public class PHPDBGEvalString { /** * */ - public PHPDBGEvalString (PHPStackFrame stack, String dataStr) { - fStackFrame = stack; - workStr = dataStr; + public PHPDBGEvalString(PHPStackFrame stack, String dataStr) { + fStackFrame = stack; + workStr = dataStr; } /** @@ -107,7 +107,6 @@ public class PHPDBGEvalString { */ int ExtractInt (char chstart, char chend, int startIdx) throws DebugException { String subs; - int rslt; subs = ExtractSubStr (chstart, chend, startIdx); @@ -396,34 +395,47 @@ public class PHPDBGEvalString { * @param var_list * @param startIdx */ - boolean ParseEvalRef (String name, PHPVariable parent, Vector list, Vector var_list, boolean isSoftRef, int startIdx) throws DebugException { - int v; + private boolean ParseEvalRef(String name, PHPVariable parent, Vector list, + Vector var_list, boolean isSoftRef, int startIdx) + throws DebugException { + int v; PHPVariable item; PHPVariable var_item; - v = ExtractInt(':', ';',startIdx); - item = new PHPVariable (fStackFrame, name, parent, "", (isSoftRef) ? (PHPValue.PEVT_SOFTREF) : (PHPValue.PEVT_REF), null); - v--; // ref ID is 1-based, EvalList is 0-based + v = ExtractInt(':', ';', startIdx); + item = new PHPVariable(fStackFrame, name, parent, "", + isSoftRef ? PHPValue.PEVT_SOFTREF : PHPValue.PEVT_REF, null); + v--; // ref ID is 1-based, EvalList is 0-based - if ((var_list == null) || - (v < 0) || - (v >= var_list.size ())) { -// item.ref = item; // self-resolving -// + if ((var_list == null) || (v < 0) || (v >= var_list.size())) { + //item.ref = item; // self-resolving return true; } else { - var_item = (PHPVariable) var_list.get (v); + var_item = (PHPVariable) var_list.get(v); + + PHPValue new_val = (PHPValue) var_item.getValue(); + if (isSoftRef) { + // expand reduced structure to full tree + // each value must have its appropriate parent + try { + new_val = copyItems(new_val); + } catch (CloneNotSupportedException e) { + // never occurs + } + } try { - item.setValue (var_item.getValue ()); - item.setReferenceType (var_item.getReferenceType ()); - ((PHPValue) item.getValue ()).setParent (item); + //item.setValue(var_item.getValue()); + //item.setReferenceType(var_item.getReferenceType()); + //((PHPValue) item.getValue()).setParent(item); + item.setValue(new_val); + item.setReferenceType(var_item.getReferenceType()); + new_val.setParent(item); } catch (DebugException e) { - // TODO Auto-generated catch block - e.printStackTrace (); + // never occurs } - list.add (item); + list.add(item); } return true; @@ -433,26 +445,27 @@ public class PHPDBGEvalString { * * @return The array of PHPVariables */ - public PHPVariable[] getVars () { - Vector list = new Vector (); - Vector var_list = new Vector (); + public PHPVariable[] getVars() { + Vector list = new Vector(); + Vector var_list = new Vector(); - parse ("", null, list, var_list, false, 0); + parse("", null, list, var_list, false, 0); - return (PHPVariable[]) list.toArray (new PHPVariable[list.size ()]); // Convert the list to an array and return the array + return (PHPVariable[]) list.toArray(new PHPVariable[list.size()]); // Convert the list to an array and return the array } /** * * @return The PHPVariables as list */ - public Vector getVariables () { - Vector list = new Vector (); - Vector var_list = new Vector (); + public Vector getVariables() { + Vector list = new Vector(); + Vector var_list = new Vector(); - parse ("", null, list, var_list, false, 0); + parse("", null, list, var_list, false, 0); - return list; // return the PHPVariable list + //debugDump(list, ""); + return list; // return the PHPVariable list } /** @@ -492,8 +505,7 @@ public class PHPDBGEvalString { case '?': ParseEvalUnknown(name, parent, list, var_list, startIdx); break; } } catch (DebugException e) { - // TODO Auto-generated catch block - e.printStackTrace(); + PHPDebugCorePlugin.log(e); } /* if (!ret_val) { // try to recover @@ -537,4 +549,43 @@ public class PHPDBGEvalString { var_list.add(item); } } + + /* + * Copy referenced items tree + */ + private PHPValue copyItems(PHPValue val) throws CloneNotSupportedException { + PHPValue newVal = (PHPValue) val.clone(); + Vector vars = newVal.getChildVariables(); + Vector newVars = new Vector(); + for (int i = 0; i < vars.size(); i++) { + PHPVariable newVar = (PHPVariable) ((PHPVariable) vars.get(i)).clone(); + try { + newVar.setValue(copyItems((PHPValue) newVar.getValue())); + } catch (DebugException e) { + // never occurs + } + newVars.add(newVar); + } + val.setVariables(newVars); + return newVal; + } + +// private void debugDump(Vector list, String indent) { +// for (int i = 0; i < list.size(); i++) { +// PHPVariable var = (PHPVariable) list.get(i); +// System.out.print(indent + var.getName()); +// PHPValue val = (PHPValue) var.getValue(); +// try { +// if (val.hasVariables() && !var.getName().equals("['GLOBALS']")) { +// System.out.println(); +// debugDump(val.getChildVariables(), indent + " "); +// } else { +// PHPVariable parent = var.getParent(); +// System.out.println(val.getValueString() + " \t>>" + (parent == null ? "null" : parent.getLongName())); +// } +// } catch (DebugException e) { +// e.printStackTrace(); +// } +// } +// } }