I approved your change (sorry, I did it out of order).  Could you file  
an improvement based on the below?  Basically we want to extend the  
eval compiler and leverage the scriptElement kludge to allow you to  
specify a "global object" where bindings should be made (and free  
references looked up).

On 2009-09-28, at 12:14, André Bargull wrote:

> On 9/28/2009 5:46 PM, P T Withington wrote:
>> The officially supported way to create a binding that persists in  
>> the debugger is to say:
>>  var foo = something;
>> That should create Debug.environment['foo'] and bind it to  
>> `something`.
>
> It should be in 'Debug.environment', but currently swf8 and dhtml  
> create global variables. In swf9, you get only a local variable  
> which is no longer available after you've evaluated the expression,  
> so the variable is neither available in 'Debug.environment' nor in  
> global.
>
>
>> If you simply say:
>>  foo = something;
>> that it magically creates a global binding on some platforms is an  
>> artifact of JS1's global implementation.  I have to confess, I'm  
>> not sure what the AS3 semantics are supposed to be, if you try to  
>> assign to a non-existent reference.  A with-block does mean the  
>> lookup has to be dynamic, but if there is no reference found, that  
>> should be an error.  Perhaps this is really an AS3 runtime bug.
>> ---
>> Did you test that `var foo ...` creates a binding in  
>> Debug.environment that you can later refer to in swf9+?  This works  
>> in swf8 by the compiler 'scriptElement' kludge that transforms top- 
>> level declarations in a function into global assignments (relying  
>> on the JS1 global semantics).  In swf9+ we could extend this kludge  
>> by allowing you to specify an Object to use (in lieu of the JS1  
>> global object).  In the debug eval case, the object would be  
>> Debug.environment.  But see also:  
>> (http://jira.openlaszlo.org/jira/browse/LPP-6837 
>> ).
>
> No, as explained above, it doesn't create any bindings. (But this is  
> not a regression due to my change.)
>
>
>
>> On 2009-09-28, at 11:21, Henry Minsky wrote:
>>> Yeah this has always been a not-officially supported but useful  
>>> feature,
>>> that you could say "foo = something" and create a global, or at  
>>> least
>>> something that acts like a global in the expressions
>>> you write in the debugger.
>>>
>>> It would be great if we could figure out a way to make this work  
>>> in swf10. I
>>> wonder if we could go so far as to try to recognize statements of  
>>> the form
>>> "somevar = someexpression" and put code that wraps around to
>>> check if "somevar" is not yet defined, and if so, to define it in  
>>> the
>>> Debug.environment.
>>>
>>>
>>> On Mon, Sep 28, 2009 at 9:54 AM, André Bargull <[email protected] 
>>> >wrote:
>>>
>>>> Forget to mention:
>>>> There is now a funny effect in swf9/swf10 because of the with- 
>>>> block. You
>>>> can evaluate the expression 'lzx> foo = 42' even if 'foo' is not  
>>>> a defined
>>>> variable, but if you later want to retrieve the value of 'foo' by  
>>>> evaluating
>>>> 'lzx> foo', the runtime reports a ReferenceError. Without the  
>>>> with-block,
>>>> you'd get a static compiler error because 'foo' is not defined.  
>>>> But as the
>>>> with-block forces dynamic look-up, the runtime needs perform this  
>>>> check, but
>>>> apparently fails for assignment expressions, only dereferencing  
>>>> gives the
>>>> ReferenceError. I'd consider this as a bug...
>>>>
>>>>
>>>>
>>>> On 9/28/2009 3:28 PM, André Bargull wrote:
>>>>
>>>>> Change 20090928-bargull-YnE by barg...@dell--p4--2-53 on  
>>>>> 2009-09-28
>>>>> 12:39:38
>>>>> in /home/Admin/src/svn/openlaszlo/trunk
>>>>> for http://svn.openlaszlo.org/openlaszlo/trunk
>>>>>
>>>>> Summary: update eval-script compiler to use Debug.environment
>>>>>
>>>>> New Features: LPP-8519 (wrap evalscript in "with 
>>>>> (Debug.environment){...}")
>>>>>
>>>>> Bugs Fixed:
>>>>>
>>>>> Technical Reviewer: ptw
>>>>> QA Reviewer: hqm
>>>>> Doc Reviewer: (pending)
>>>>>
>>>>> Documentation:
>>>>>
>>>>> Release Notes:
>>>>>
>>>>> Details:
>>>>> Compiler.java:
>>>>> Added "compileEvalScript()" to avoid duplicate code for swf8 and  
>>>>> AS3
>>>>> runtimes. Every eval-script is now surrounded with "with 
>>>>> (Debug.environment)
>>>>> {...}" in order to allow eval-expressions to access properties  
>>>>> from the
>>>>> Debugger environment.
>>>>> For swf8 compilation, the catch block only caught
>>>>> "sc.parser.ParseException", this is now just "Exception" (it was  
>>>>> already
>>>>> just "Exception" for swf9), so every possible exception is  
>>>>> caught (e.g.
>>>>> otherwise an unterminated multi-line comment throws the compiler  
>>>>> out of
>>>>> whack).
>>>>> Apparently it's no longer necessary to prepend "_level0" before  
>>>>> references
>>>>> to "Debug" in swf8, so I removed it. I've also added try-catch  
>>>>> for swf8 like
>>>>> it's already done in swf9, because otherwise throwing an Error  
>>>>> leads a
>>>>> timeout of the eval-request (see 1st comment on LPP-8519). And I  
>>>>> wonder how
>>>>> remote debug requests did work in the past, because there was a  
>>>>> stray
>>>>> semicolon in the code (l.493). And made sure that  
>>>>> Debug.sockWriteAsXML() is
>>>>> always called for remote debug request, so the  
>>>>> Debug.inEvalRequest flag gets
>>>>> updated.
>>>>> Also removed the excessive import list for swf9, because it has  
>>>>> no use
>>>>> since the script isn't executed in "DebugExec" but in  
>>>>> "DebugEvaluate".
>>>>> LzDebug.as (swf8):
>>>>> - removed override of "displayResult()", no longer necessary
>>>>> LzDebug.as (swf9):
>>>>> - removed override of "displayResult()", no longer necessary
>>>>> - cleaned up imports
>>>>> - removed '_', '__' and '___', no longer global
>>>>> - removed "TODO" from comment in "IDForObject()"
>>>>> LzMemory.lzs:
>>>>> - updated to use "Debug.environment" instead of "global" for  
>>>>> '_', '__' and
>>>>> '___'
>>>>> LzCanvas.lzs:
>>>>> - added "swf10" to the supported runtimes comment
>>>>>
>>>>>
>>>>>
>>>>> Tests:
>>>>> try eval'ing expression, statements and erroneous inputs in  
>>>>> swf8, swf9,
>>>>> swf10
>>>>>
>>>>> Files:
>>>>> M WEB-INF/lps/lfc/debugger/platform/swf/LzDebug.as
>>>>> M WEB-INF/lps/lfc/debugger/platform/swf9/LzDebug.as
>>>>> M WEB-INF/lps/lfc/debugger/LzMemory.lzs
>>>>> M WEB-INF/lps/lfc/views/LaszloCanvas.lzs
>>>>> M WEB-INF/lps/server/src/org/openlaszlo/compiler/Compiler.java
>>>>>
>>>>> Changeset:
>>>>> http://svn.openlaszlo.org/openlaszlo/patches/20090928-bargull-YnE.tar
>>>>>
>>>>>
>>>>>
>>>
>>>
>>> -- 
>>> Henry Minsky
>>> Software Architect
>>> [email protected]


_______________________________________________
Laszlo-reviews mailing list
[email protected]
http://www.openlaszlo.org/mailman/listinfo/laszlo-reviews

Reply via email to