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 8a15874..40afdb0 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 @@ -15,26 +15,27 @@ package net.sourceforge.phpdt.internal.debug.core.model; import java.util.Vector; -import org.eclipse.debug.core.DebugException; import net.sourceforge.phpdt.internal.debug.core.PHPDebugCorePlugin; + import org.eclipse.core.runtime.Status; +import org.eclipse.debug.core.DebugException; public class PHPDBGEvalString { String workStr; private PHPStackFrame fStackFrame; - + public PHPDBGEvalString(PHPStackFrame stack,String dataStr) { fStackFrame=stack; workStr=dataStr; } - + String ExtractSubStr(char chstart, char chend,int startIdx) throws DebugException { int idx=startIdx; String rslt; if (idx >= (workStr.length() - 1) || workStr.charAt(idx) != chstart) { - Status status= new Status(Status.ERROR,PHPDebugCorePlugin.getUniqueIdentifier(),Status.OK,"worng startIdx!",null); + Status status= new Status(Status.ERROR,PHPDebugCorePlugin.getUniqueIdentifier(),Status.OK,"worng startIdx!",null); throw new DebugException(status); } int i = ++idx; @@ -48,11 +49,11 @@ public class PHPDBGEvalString { workStr=workStr.substring(i+1); return rslt; } - + String ExtractQuotedSubStr(int slen,int startIdx) throws DebugException { int idx=startIdx; String rslt; - if (idx+slen+1 >= workStr.length() || + if (idx+slen+1 >= workStr.length() || workStr.charAt(idx)!= '"' || workStr.charAt(idx+slen+1) != '"') { Status status= new Status(Status.ERROR,PHPDebugCorePlugin.getUniqueIdentifier(),Status.OK,"no quoted substring found!",null); @@ -63,7 +64,7 @@ public class PHPDBGEvalString { return rslt; } - + int ExtractInt(char chstart, char chend,int startIdx) throws DebugException { String subs; int rslt; @@ -90,7 +91,7 @@ public class PHPDBGEvalString { if (arritems > 0) { subitems = new Vector(); } else - if (workStr.charAt(0)!='}') + if (workStr.charAt(0)!='}') { Status status= new Status(Status.ERROR,PHPDebugCorePlugin.getUniqueIdentifier(),Status.OK,"no array endcharecter!",null); throw new DebugException(status); @@ -105,18 +106,18 @@ public class PHPDBGEvalString { } // value parse(((PHPVariable)tmplst.elementAt(0)).getValue().getValueString(),item, subitems, var_list, true,0); - + } ((PHPValue)item.getValue()).addVariable(subitems); workStr=workStr.substring(1); return item; } - + void ParseEvalNULL(String name,PHPVariable parent,Vector list, Vector var_list, int startIdx) throws DebugException { int idx=startIdx; if (idx >= workStr.length() || workStr.charAt(idx) != ';') { Status status= new Status(Status.ERROR,PHPDebugCorePlugin.getUniqueIdentifier(),Status.OK,"NULL not found!",null); - throw new DebugException(status); + throw new DebugException(status); } workStr=workStr.substring(1); PHPVariable item= new PHPVariable(fStackFrame, name,parent,"NULL",PHPValue.PEVT_UNKNOWN,null); @@ -124,7 +125,7 @@ public class PHPDBGEvalString { if (var_list!=null) var_list.add(item); } - + boolean ParseEvalInt( String name, PHPVariable parent, Vector list, Vector var_list, int startIdx) throws DebugException { String subs=null; PHPVariable item; @@ -135,7 +136,7 @@ public class PHPDBGEvalString { var_list.add(item); return true; } - + boolean ParseEvalDouble(String name,PHPVariable parent, Vector list, Vector var_list, int startIdx) throws DebugException { String subs=null; PHPVariable item; @@ -146,7 +147,7 @@ public class PHPDBGEvalString { var_list.add(item); return true; } - + boolean ParseEvalString(String name,PHPVariable parent, Vector list, Vector var_list, boolean MakePhpStr, int startIdx) throws DebugException{ int slen; @@ -175,7 +176,7 @@ public class PHPDBGEvalString { var_list.add(item); return true; } - + boolean ParseEvalBool(String name,PHPVariable parent, Vector list, Vector var_list, int startIdx) throws DebugException{ long v; @@ -185,8 +186,8 @@ public class PHPDBGEvalString { if (var_list!=null) list.add(item); return true; - } - + } + boolean ParseEvalObject(String name,PHPVariable parent, Vector list, Vector var_list, int startIdx) throws DebugException{ int slen; @@ -198,7 +199,7 @@ public class PHPDBGEvalString { ParseEvalArray(name,parent, list, var_list, classname,PHPValue.PEVT_OBJECT); return true; } - + boolean ParseEvalResource(String name,PHPVariable parent, Vector list, Vector var_list, int startIdx) throws DebugException{ int v, slen; @@ -212,18 +213,18 @@ public class PHPDBGEvalString { return true; } - + boolean ParseEvalRef(String name,PHPVariable parent, Vector list, Vector var_list, boolean isSoftRef, int startIdx) throws DebugException{ int v; v=ExtractInt(':', ';',startIdx); - PHPVariable item= new PHPVariable(fStackFrame, name,parent,"",(isSoftRef)? (PHPValue.PEVT_SOFTREF): (PHPValue.PEVT_REF),null); + PHPVariable 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())) { + if ((var_list==null) || (v<0) || (v >= var_list.size())) { // item.ref = item; // self-resolving return true; } else { @@ -236,63 +237,77 @@ public class PHPDBGEvalString { // TODO Auto-generated catch block e.printStackTrace(); } - list.add(item); + list.add(item); } - + return true; } - - public PHPVariable[] getVars(){ - Vector list=new Vector(); - Vector var_list=new Vector(); - parse("",null,list,var_list,false,0); - return (PHPVariable[])list.toArray(new PHPVariable[list.size()]); + + /** + * + * @return The array of PHPVariables + */ + public PHPVariable[] getVars () { + Vector list = new Vector (); + Vector var_list = new Vector (); + + 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 } - - boolean parse(String name,PHPVariable parent, Vector list, Vector var_list, boolean MakePhpStr,int startIdx) { + + /** + * + * @return The array of PHPVariables + */ + public Vector getVariables () { + Vector list = new Vector (); + Vector var_list = new Vector (); + + parse ("", null, list, var_list, false, 0); + + return list; // return the PHPVariable list + } + + /** + * + * @param name + * @param parent + * @param list + * @param var_list + * @param MakePhpStr + * @param startIdx + */ + boolean parse (String name, PHPVariable parent, Vector list, Vector var_list, boolean MakePhpStr, int startIdx) { boolean ret_val = false; + char ch; + + if (startIdx >= workStr.length ()) { + return false; + } + + ch = workStr.charAt (startIdx); + workStr = workStr.substring (1); - if (startIdx >= workStr.length()) return false; - char ch = workStr.charAt(startIdx); - workStr=workStr.substring(1); try { switch (ch) { - case 'N': - ParseEvalNULL(name,parent, list, var_list, startIdx); - break; - case 'i': - ParseEvalInt(name,parent, list, var_list, startIdx); - break; - case 'd': - ParseEvalDouble(name,parent, list, var_list, startIdx); - break; - case 's': - ParseEvalString(name,parent, list, var_list, MakePhpStr, startIdx); - break; - case 'a': - ParseEvalArray(name,parent, list, var_list, "", PHPValue.PEVT_ARRAY); - break; - case 'O': - ParseEvalObject(name,parent, list, var_list, startIdx); - break; - case 'b': - ParseEvalBool(name,parent, list, var_list, startIdx); - break; - case 'z': - ParseEvalResource(name,parent, list, var_list, startIdx); - break; - case 'R': - ParseEvalRef(name,parent, list, var_list, false, startIdx); - break; - case 'r': - ParseEvalRef(name,parent, list, var_list, true, startIdx); - break; + case 'N': ParseEvalNULL (name, parent, list, var_list, startIdx); break; + case 'i': ParseEvalInt (name, parent, list, var_list, startIdx); break; + case 'd': ParseEvalDouble (name, parent, list, var_list, startIdx); break; + case 's': ParseEvalString (name, parent, list, var_list, MakePhpStr, startIdx); break; + case 'a': ParseEvalArray (name, parent, list, var_list, "", PHPValue.PEVT_ARRAY); break; + case 'O': ParseEvalObject (name, parent, list, var_list, startIdx); break; + case 'b': ParseEvalBool (name, parent, list, var_list, startIdx); break; + case 'z': ParseEvalResource (name, parent, list, var_list, startIdx); break; + case 'R': ParseEvalRef (name, parent, list, var_list, false, startIdx); break; + case 'r': ParseEvalRef (name, parent, list, var_list, true, startIdx); break; } } catch (DebugException e) { // TODO Auto-generated catch block e.printStackTrace(); } + /* if (!ret_val) { // try to recover unsigned int i=*startIdx; while (i