Contexts and exception handlers

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Contexts and exception handlers

cdavidshaffer
When saving a context and using it in
Compiler>>evaluate:in:to:notifying:ifFail:logged: it doesn't appear that
exception handlers are active.  Here's a test case which demonstrates my
expectations (which are clearly flawed).  Can anyone help me understand
why this notification isn't caught?

BTW, I'm simply trying to figure out how to get the Inspector, Debugger,
ObjectExplorer etc to be able to access "dynamic variables" which
existed in the context in which the tool was activated.

David


'From Squeak3.7 of ''4 September 2004'' [latest update: #5989] on 2 August 2006 at 12:34:47 pm'!
TestCase subclass: #SCContextTest
        instanceVariableNames: ''
        classVariableNames: ''
        poolDictionaries: ''
        category: 'SCContextAwareInspector'!

!SCContextTest methodsFor: 'running' stamp: 'cds 8/2/2006 12:33'!
testNotificationCaught
        |ctxt notified|
        notified := false.
        [ctxt := thisContext] on: SCTestNotification do: [notified := true].
        self deny: notified.
        Compiler new evaluate: 'SCTestNotification signal' in: ctxt to: self notifying: nil ifFail: [^nil] logged: false.
        self assert: notified! !

'From Squeak3.7 of ''4 September 2004'' [latest update: #5989] on 2 August 2006 at 12:34:49 pm'!
Notification subclass: #SCTestNotification
        instanceVariableNames: ''
        classVariableNames: ''
        poolDictionaries: ''
        category: 'SCContextAwareInspector'!


Reply | Threaded
Open this post in threaded view
|

Re: Contexts and exception handlers

Adrian Lienhard
Hi David,

It's not the case that the exception handler is not active but rather  
that the context is not on the stack. It looks like the context is  
only used in the compiler to allow you to access its temps (and  
args). But the method itself is executed as a normal send without any  
mangling of the stack. If you put a halt in the evaluated code, you  
don't find the block context on the stack. Of course, what works is  
to put the evaluation of the code within the block, but that's maybe  
not what you wanted. To make the tools aware of dynamic variables  
would indeed be useful (e.g., for the current Seaside session).

Cheers,
Adrian

On Aug 2, 2006, at 18:42 , David Shaffer wrote:

> When saving a context and using it in
> Compiler>>evaluate:in:to:notifying:ifFail:logged: it doesn't appear  
> that
> exception handlers are active.  Here's a test case which  
> demonstrates my
> expectations (which are clearly flawed).  Can anyone help me  
> understand
> why this notification isn't caught?
>
> BTW, I'm simply trying to figure out how to get the Inspector,  
> Debugger,
> ObjectExplorer etc to be able to access "dynamic variables" which
> existed in the context in which the tool was activated.
>
> David
>
> 'From Squeak3.7 of ''4 September 2004'' [latest update: #5989] on 2  
> August 2006 at 12:34:47 pm'!
> TestCase subclass: #SCContextTest
> instanceVariableNames: ''
> classVariableNames: ''
> poolDictionaries: ''
> category: 'SCContextAwareInspector'!
>
> !SCContextTest methodsFor: 'running' stamp: 'cds 8/2/2006 12:33'!
> testNotificationCaught
> |ctxt notified|
> notified := false.
> [ctxt := thisContext] on: SCTestNotification do: [notified := true].
> self deny: notified.
> Compiler new evaluate: 'SCTestNotification signal' in: ctxt to:  
> self notifying: nil ifFail: [^nil] logged: false.
> self assert: notified! !
> 'From Squeak3.7 of ''4 September 2004'' [latest update: #5989] on 2  
> August 2006 at 12:34:49 pm'!
> Notification subclass: #SCTestNotification
> instanceVariableNames: ''
> classVariableNames: ''
> poolDictionaries: ''
> category: 'SCContextAwareInspector'!
>


Reply | Threaded
Open this post in threaded view
|

Re: Contexts and exception handlers

Tony Garnock-Jones-2
In reply to this post by cdavidshaffer
David Shaffer wrote:
> BTW, I'm simply trying to figure out how to get the Inspector, Debugger,
> ObjectExplorer etc to be able to access "dynamic variables" which
> existed in the context in which the tool was activated.

You could try looking at the implementations of dynamic-wind for Scheme
(the implementation of dynamic variables in Squeak would need to be
changed, of course). Basically these reify the "windings" that go on
during changes of dynamic-variable values. The meta-level code in
Inspector, Debugger etc would then manipulate the reified windings just
like it manipulates reified stacks.

Tony