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;
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);
return rslt;
}
-
+
int ExtractInt(char chstart, char chend,int startIdx) throws DebugException {
String subs;
int rslt;
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);
}
// 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);
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;
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;
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;
var_list.add(item);
return true;
}
-
+
boolean ParseEvalBool(String name,PHPVariable parent, Vector list, Vector var_list, int startIdx)
throws DebugException{
long v;
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;
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;
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 {
// 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<str.length() && str[i]!='{' && str[i]!=';') i++;
while (i<str.length() && cnt!=0) {
if (str[i] == '{')
cnt++;
- else if (str[i] == '}')
+ else if (str[i] == '}')
cnt--;
i++;
}
*/
return ret_val;
}
-
-
}