[Laszlo-checkins] r11750 - openlaszlo/trunk/lps/components/debugger
ptw@openlaszlo.org
ptw at openlaszlo.org
Thu Nov 13 05:41:13 PST 2008
Author: ptw
Date: 2008-11-13 05:41:11 -0800 (Thu, 13 Nov 2008)
New Revision: 11750
Modified:
openlaszlo/trunk/lps/components/debugger/debugger.lzx
Log:
Change 20081112-ptw-E by ptw at dueling-banjos.home on 2008-11-12 21:45:49 EST
in /Users/ptw/OpenLaszlo/trunk
for http://svn.openlaszlo.org/openlaszlo/trunk
Summary: Add a simple evaluator to the swf8/9 debugger
Bugs Fixed:
LPP-7271 swf9: exceptions running debugger in embedded HTML
Technical Reviewer: hminsky (Message-ID: <8c61fad60811121955x1acf10f3w2f4c3d80dbf0e52a at mail.gmail.com>)
QA Reviewer: a.bargull at intensis.de (pending)
Details:
Added a simple "path" evaluator that can evaluate globals, object
member and array index expressions without having to invoke the
server compiler (e.g., `canvas.subviews[0]`). This will allow
simple object inspection in the debugger in solo apps or apps
deployed without the lps server; it will also speed up the
evaluation of such simple expressions as the server will not be
invoked to compile them.
Tests:
lzc --debug someapp.lzx, load that app directly from your
filesystem, evaluate `canvas.subviews[0]` in the debugger and note
that it works.
Modified: openlaszlo/trunk/lps/components/debugger/debugger.lzx
===================================================================
--- openlaszlo/trunk/lps/components/debugger/debugger.lzx 2008-11-13 09:00:10 UTC (rev 11749)
+++ openlaszlo/trunk/lps/components/debugger/debugger.lzx 2008-11-13 13:41:11 UTC (rev 11750)
@@ -259,8 +259,14 @@
]]>
</method>
+ <!-- Simple "path" expressions will only have symbols, `.`, or `[numbers]` -->
+ <!-- @keywords private readonly -->
+ <attribute name="SimpleExprPattern" value="$once{new RegExp('^([$_A-Za-z][$\\w]*)((\\.[$_A-Za-z][$\\w]*)|(\\[\\d+\\]))*$')}" />
+ <!-- Now pull out just the element 'selectors', so you can walk down them -->
+ <!-- @keywords private readonly -->
+ <attribute name="ElementPattern" value="$once{new RegExp('([$_A-Za-z][$\\w]*)|(\\d+)', 'g')}" />
<!-- send the input text field to server for compile/eval -->
-<method name="doEval">
+ <method name="doEval">
<![CDATA[
var expr = this.bottom.center.input.getText();
this.commandhistory[this.commandhistory.length] = expr;
@@ -271,14 +277,31 @@
// Echo input to output
Debug.freshPrompt();
this.echo(String(expr)['toHTML']());
- // Will try to compile as 'Debug.displayResult(expr);' and if
- // that fails, will try to compile as a series of statements
- // (with no display). Finally, will compile
- // 'Debug.__write(<error message>)' if both of those fail.
- if (this.solo_mode) {
- Debug.displayResult(globalValue(expr));
+ // try to avoid calling the compiler if you can
+ var simple, val;
+ if (expr.match(this.SimpleExprPattern)) {
+ simple = true;
+ try {
+ var parts = expr.match(this.ElementPattern)
+ val = globalValue(parts[0]);
+ for (var i = 1, l = parts.length; i < l; i++) {
+ val = val[parts[i]];
+ }
+ } catch (e) {
+ // If we get an error, the expression must not be simple
+ simple = false;
+ }
+ }
+ if (simple) {
+ Debug.displayResult(val);
+ } else if (! this.solo_mode) {
+ // Will try to compile as 'Debug.displayResult(expr);' and if
+ // that fails, will try to compile as a series of statements
+ // (with no display). Finally, will compile
+ // 'Debug.__write(<error message>)' if both of those fail.
+ this.evalloader.doEval(expr, this.commandhistory.length);
} else {
- this.evalloader.doEval(expr, this.commandhistory.length);
+ Debug.warn('Expression too complex to evaluate in SOLO mode.');
}
// Clear the input text field
if (!this.bottom.center.input.multiline) {
More information about the Laszlo-checkins
mailing list