discuss-gnustep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: StepTalk Segfaults


From: Stefan Urbanek
Subject: Re: StepTalk Segfaults
Date: Sun, 20 Feb 2005 23:07:27 +0100

On Sun, 2005-02-20 at 14:52 -0600, Matthew D Swank wrote:
> Stefan Urbanek wrote:
> 
> > if someone would like to investigate it,
> > I can give him few pointers.
> >
> > Regards,
> >
> > Stefan Urbanek
> 
> Well I am experimenting with blocks. My latest test is:
> "-------------------------------------------------"
> |main sub|
> sub :=
>   [:continuation |
>   Transcript  show: '\n   begin sub'.
>   Transcript  show: '\n   |-- Objective C --|'.
>   continuation value.
>   Transcript  show: '\n   end sub'.].
> 
> main :=
>   [:continuation |
>   Transcript show: '\n begin main'.
>   Transcript show: '\n |-- StepTalk --|'.
>   sub
>     valueWith:
>       [Transcript show: '\n |-- ANSI C --|'.
>       continuation value.].
>   Transcript show: '\n end main'.].
> 
> Transcript show: '\nbegin program'.
> main  valueWith: [Transcript show: '\nend program'.].
> 
> "-------------------------------------------------"
> I believe the output should be:
> 
> begin program
>  begin main
>  |-- StepTalk --|
>    begin sub
>    |-- Objective C --|
>  |-- ANSI C --|
> end program
> 
> but I get:
> 
> begin program
>  begin main
>  |-- StepTalk --|
>    begin sub
>    |-- Objective C --|
>  |-- ANSI C --|
>  |-- ANSI C --|
>  |-- ANSI C --|
>  |-- ANSI C --|
> ...
> ad infinitum.
> 
> What do I need to look at in terms of how StepTalk scopes compiles and 
> interprets blocks?

Start in Languages/Smalltalk: STBytecodeInterpreter.m. There is a
method:
- (void)createBlockWithArgumentCount:(int)argCount
stackSize:(int)stackSize

Then look at classes STBlock and STBlockContext. Follow to the
STExecutionContext class.

The block lives as long as it's parent context and the interpreter live.
I do not say that it is good, so if you think that it should be
different I will not mind.

The STByteCodeInterpreter was written as simplified interpreter from
"the blue book". If I was writing it now, I would write it differently,
if at all. The interpreter can be removed if the compiler would generate
directly "executable object command tree" made of message sends,
assignments and context changes.

Regards,

Stefan Urbanek
-- 
http://stefan.agentfarms.net

First they ignore you, then they laugh at you, then they fight you, then
you win.
- Mahatma Gandhi






reply via email to

[Prev in Thread] Current Thread [Next in Thread]