import org.eclipse.debug.core.model.IThread;
import org.eclipse.debug.core.model.IVariable;
-public class PHPStackFrame implements IStackFrame {
-
- private PHPThread thread;
- private String file;
- private int lineNumber;
- private int index;
- private int modno;
- private PHPVariable[] variables;
- private String description;
-
- public PHPStackFrame(PHPThread thread, String file, int line, int index, String desc, int modno) {
- this.lineNumber = line;
- this.index = index;
- this.file = file;
- this.thread = thread;
+public class PHPStackFrame extends PHPDebugElement implements IStackFrame {
+
+ private PHPThread thread; // The thread to which this stackframe belongs
+ private String file; // The file name???
+ private int lineNumber; //
+ private int index; //
+ private int modno; //
+ private PHPVariable[] variables; // The array of variables
+ private String description; //
+
+ /**
+ *
+ * @param thread
+ * @param file
+ * @param line
+ * @param index
+ * @param desc
+ * @param modno
+ */
+ public PHPStackFrame (PHPThread thread, String file, int line, int index, String desc, int modno) {
+ super (null);
+
+ this.lineNumber = line;
+ this.index = index;
+ this.file = file;
+ this.thread = thread;
this.description = desc;
- this.modno = modno;
+ this.modno = modno;
}
- public PHPStackFrame(PHPThread thread, String file, int line, int index) {
+ /**
+ *
+ * @param thread
+ * @param file
+ * @param line
+ * @param index
+ */
+ public PHPStackFrame (PHPThread thread, String file, int line, int index) {
+ super (null);
+
this.lineNumber = line;
- this.index = index;
- this.file = file;
- this.thread = thread;
+ this.index = index;
+ this.file = file;
+ this.thread = thread;
}
- public IThread getThread() {
+ /**
+ *
+ */
+ public IThread getThread () {
return thread;
}
- public void setThread(PHPThread thread) {
+ /**
+ * @param thread
+ */
+ public void setThread (PHPThread thread) {
this.thread = thread;
}
+ /**
+ *
+ * This function returns the array of PHPVariables for this stackframe
+ * The PHPVariables should not change (newly build up) between two steps
+ * (or breaks).
+ * A PHPVariable with the same name but with different object ID is
+ * handled as a new variable.
+ *
+ * TODO Remove the intermediate storage array
+ *
+ * @return The array of PHPVariables for this stackframe.
+ */
public IVariable[] getVariables() throws DebugException {
- if (variables == null) {
- variables = this.getPHPDBGProxy().readVariables(this);
- }
- return variables;
+ PHPVariable[] variablesNew; // The intermediate storage of the variable array we get from DBG proxy
+
+ variablesNew = this.getPHPDBGProxy ().readVariables (this); // Get the variable array from DBG proxy
+ variables = variablesNew; // Store the array the stackframes member variable
+
+ return variables; // Give the array back to user interface
}
- public IVariable findVariable(String s) throws DebugException {
- if (this.hasVariables()) {
- String name="$"+s;
- for(int i= 0; i < variables.length; i++) {
- String n= variables[i].getName();
- if((variables[i].getName()).equals(name))
+ /**
+ * TODO Is this really used (who calls this)
+ * I think this method could be removed
+ *
+ * @param s The variables name we are looking for.
+ * @return
+ */
+ public IVariable findVariable (String s) throws DebugException {
+ String name;
+ int i;
+
+ if (this.hasVariables ()) { // Does this stackframe have variables?
+ name = "$" + s; // Prefix the variable name with $
+
+ for (i = 0; i < variables.length; i++) { // For all variables
+ if ((variables[i].getName ()).equals (name)) {
return variables[i];
+ }
}
}
+
return null;
}
- public boolean hasVariables() throws DebugException {
- if (variables == null) {
- return false;
+ /**
+ *
+ */
+ public boolean hasVariables () throws DebugException {
+ if (variables == null) { // Do we have a variables array?
+ return false; // No
}
- return variables.length > 0;
+
+ return variables.length > 0; // Is there something within the array?
}
public int getLineNumber() {
return lineNumber;
}
+ public void setLineNumber(int line) {
+ lineNumber = line;
+ }
+
public int getCharStart() throws DebugException {
// not supported
return -1;
return false;
}
- public void stepInto() throws DebugException {
- thread.prepareForResume() ;
- this.getPHPDBGProxy().readStepIntoEnd(PHPStackFrame.this) ;
- DebugEvent ev = new DebugEvent(this.getThread(), DebugEvent.RESUME, DebugEvent.STEP_INTO);
- DebugPlugin.getDefault().fireDebugEventSet(new DebugEvent[] { ev });
+ /**
+ *
+ */
+ public void stepInto () throws DebugException {
+ DebugEvent ev;
+
+ thread.prepareForResume (DebugEvent.STEP_INTO); // Don't know why, but this is necessary
+ this.getPHPDBGProxy ().readStepIntoEnd (PHPStackFrame.this);
+
+ ev = new DebugEvent (this.getThread (), DebugEvent.RESUME, DebugEvent.STEP_INTO);
+ DebugPlugin.getDefault().fireDebugEventSet (new DebugEvent[] { ev });
}
- public void stepOver() throws DebugException {
- thread.prepareForResume() ;
- this.getPHPDBGProxy().readStepOverEnd(PHPStackFrame.this) ;
- DebugEvent ev = new DebugEvent(this.getThread(), DebugEvent.RESUME, DebugEvent.STEP_OVER);
- DebugPlugin.getDefault().fireDebugEventSet(new DebugEvent[] { ev });
+ /**
+ *
+ */
+ public void stepOver () throws DebugException {
+ DebugEvent ev;
+
+ thread.prepareForResume (DebugEvent.STEP_OVER);
+ this.getPHPDBGProxy ().readStepOverEnd (PHPStackFrame.this) ;
+
+ ev = new DebugEvent (this.getThread (), DebugEvent.RESUME, DebugEvent.STEP_OVER);
+ DebugPlugin.getDefault ().fireDebugEventSet (new DebugEvent[] { ev });
}
- public void stepReturn() throws DebugException {
- thread.prepareForResume() ;
- this.getPHPDBGProxy().readStepReturnEnd(PHPStackFrame.this) ;
- DebugEvent ev = new DebugEvent(this.getThread(), DebugEvent.RESUME, DebugEvent.STEP_RETURN);
- DebugPlugin.getDefault().fireDebugEventSet(new DebugEvent[] { ev });
+ /**
+ *
+ */
+ public void stepReturn () throws DebugException {
+ DebugEvent ev;
+
+ thread.prepareForResume (DebugEvent.STEP_RETURN);
+ this.getPHPDBGProxy ().readStepReturnEnd (PHPStackFrame.this) ;
+
+ ev = new DebugEvent (this.getThread (), DebugEvent.RESUME, DebugEvent.STEP_RETURN);
+ DebugPlugin.getDefault ().fireDebugEventSet (new DebugEvent[] { ev });
}
getPHPDBGProxy().stop();
}
- public Object getAdapter(Class arg0) {
- if (arg0==PHPStackFrame.class)
- return this;
- else
- return null;
- }
-
public int getIndex() {
return index;
}
public PHPDBGProxy getPHPDBGProxy() {
PHPDebugTarget DebugTarget;
- DebugTarget= (PHPDebugTarget)thread.getDebugTarget();
- return DebugTarget.getPHPDBGProxy();
+
+ DebugTarget = (PHPDebugTarget) thread.getDebugTarget ();
+
+ return DebugTarget.getPHPDBGProxy ();
}
public void setFile(String file) {