At 10:54 AM 4/5/01 -0500, "Nick Sieger" <[EMAIL PROTECTED]> wrote:
>> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
>> Sent: Thursday, April 05, 2001 10:45 AM
>
>[...]
>
>> trying out more of the commands and helping with debugging. My favorite
>> command would be a fully functional "evaluate expression". I know you
>> have said in the past that JPDA doesn't support this, but there must be
>> some way to at kludge it as I know of other JPDA based debuggers, e.g.
>> JBuilder Professional, that support this functionality.
>>
>
>My apologies if this has been thought of, but it seems like a perfect fit
>and a relatively quick implementation to simply use the beanshell (or some
>subset of the beanshell classes) inside the same JVM as JDEbug for
>expression evaluation. Of course, now that I've mentioned it, I should
>probably put my money where my mouth is and code it up myself. Maybe if I
>get time... Anyway, just wanted to throw that out there as it seems like a
>good solution with a minimal amount of new code to write.
This won't work. The expression evaluator has to use JPDA functions to
access the values of variables defined by the debuggee process. JDEbug has
a simple arithmetic expression parser. Here is how it works:
1. Parse expression (e.g., a+b) to determine operator and operands, e.g.,
op = "+"; opl = "a"; opr = "b";
2. Use JPDA method to obtain value of operands in the debuggee process.
3. Apply operand to operands, using a switch statement based on operand
type, e.g.
switch (op) {
case plus:
result = opl + opr;
case mult:
result = opl * opr;
default:
error("Unknown operand");
}
4. Display result to user.
My plan is to enhance the expression evaluator to handle most Java
expressions, using a parser generated by javacc. I started this work more
than a year ago but got sidetracked by editing engine enhancements.
- Paul