Quantcast

Creating new instance variables in a dynamically created class in gst-remote

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

Creating new instance variables in a dynamically created class in gst-remote

Mark Bratcher-2
Hello

I have an application I'm building in which some classes get created
dynamically by a piece of code, which we'll call "maker.st". I create an
image file by executing `gst -I seaside.im`, loading `maker.st`,
executing the code, and saving a new image file which includes Seaside.
We'll call this "maker.im". This is done with the following command:

    gst -I seaside.im maker.st


So `maker.st` creates some classes, and then writes a `maker.im` image
(using `objectMemory snapshot: 'maker.im'`) after they've been created.

I want my Seaside application, which consists of a number of smalltalk
source files put into a package "MyApp", to be able to extend and use
these dynamically created classes. So the running of gst-remote looks
like this:

    gst-remote -I maker.im --daemon --start=Seaside > tcob.log 2>&1
    sleep 1
    gst-remote --package=MyApp

Thus far, it's worked pretty well. I've been able to `extend` the
dynamically created classes and add selectors (at class and metaclass
level).

However, as soon as I included instance variable declarations in my
extensions, I hit this error when I attempt to run the server and
application:

    gst-remote -I maker.im --daemon --start=Seaside > tcob.log 2>&1
    sleep 1
    gst-remote --package=MyApp
      error: did not understand #statements
    MessageNotUnderstood(Exception)>>signal (ExcHandling.st:254)
    STInST.RBVariableNode(Object)>>doesNotUnderstand: #statements
    (SysExcept.st:1448)
    STInST.GSTFileInParser(STInST.STFileParser)>>evaluate:
    (Parser.star#VFS.ZipFile/STFileParser.st:111)
    STInST.GSTFileInParser>>evaluate:
    (Parser.star#VFS.ZipFile/GSTParser.st:377)
    STInST.GSTFileInParser(STInST.STFileParser)>>resolveClass:
    (Parser.star#VFS.ZipFile/STFileParser.st:101)
    STInST.GSTFileInParser>>parseInstanceVariables:add:
    (Parser.star#VFS.ZipFile/GSTParser.st:332)
    STInST.GSTFileInParser>>parseClassBodyElement:withinExtend:
    (Parser.star#VFS.ZipFile/GSTParser.st:234)
    STInST.GSTFileInParser>>parseClassBody:
    (Parser.star#VFS.ZipFile/GSTParser.st:169)
    STInST.GSTFileInParser>>parseClassExtension:
    (Parser.star#VFS.ZipFile/GSTParser.st:147)
    STInST.GSTFileInParser>>parseDeclaration:
    (Parser.star#VFS.ZipFile/GSTParser.st:98)
    STInST.GSTFileInParser>>parseDoit
    (Parser.star#VFS.ZipFile/GSTParser.st:82)
    STInST.GSTFileInParser>>parseDoits
    (Parser.star#VFS.ZipFile/GSTParser.st:67)
    STInST.GSTFileInParser(STInST.STFileInParser)>>parseSmalltalk
    (Parser.star#VFS.ZipFile/STFileParser.st:282)
    STInST.GSTFileInParser class(STInST.STFileParser
    class)>>parseSmalltalkStream:with:onError:
    (Parser.star#VFS.ZipFile/STFileParser.st:70)
    STInST.GSTFileInParser class(STInST.STFileParser
    class)>>parseSmalltalkStream:with:
    (Parser.star#VFS.ZipFile/STFileParser.st:60)
    STInST.STEvaluationDriver(STInST.STParsingDriver)>>parseSmalltalkStream:with:
    (Parser.star#VFS.ZipFile/STFileParser.st:181)
    optimized [] in Stream>>fileInLine:file:at:
    (Compiler.star#VFS.ZipFile/StartCompiler.st:69)
    BlockClosure>>ensure: (BlkClosure.st:268)
    Kernel.LimitedStream(Stream)>>fileInLine:file:at:
    (Compiler.star#VFS.ZipFile/StartCompiler.st:65)
    Kernel.LimitedStream(Stream)>>fileInLine:file:fileName:at:
    (Compiler.star#VFS.ZipFile/StartCompiler.st:76)
    Kernel.LimitedStream>>fileIn (VFSZip.st:352)
    optimized [] in FilePath>>fileIn (FilePath.st:665)
    [] in VFS.StoredZipMember(FilePath)>>withReadStreamDo: (FilePath.st:658)
    BlockClosure>>ensure: (BlkClosure.st:268)
    VFS.StoredZipMember(FilePath)>>withReadStreamDo: (FilePath.st:657)
    VFS.StoredZipMember(FilePath)>>fileIn (FilePath.st:665)
    optimized [] in Package>>primFileIn (PkgLoader.st:1574)
    OrderedCollection>>do: (OrderColl.st:67)
    [] in Package>>primFileIn (PkgLoader.st:1574)
    BlockClosure>>ensure: (BlkClosure.st:268)
    Package>>primFileIn (PkgLoader.st:1560)
    Kernel.StarPackage>>primFileIn (PkgLoader.st:1078)
    optimized [] in PackageLoader class>>fileInPackages: (PkgLoader.st:1973)
    OrderedCollection>>do: (OrderColl.st:67)
    PackageLoader class>>fileInPackages: (PkgLoader.st:1966)
    PackageLoader class>>fileInPackage: (PkgLoader.st:1954)
    UndefinedObject>>executeStatements (a String:1)
    [] in STInST.STEvaluationDriver>>evaluate:
    (Parser.star#VFS.ZipFile/STEvaluationDriver.st:210)

I narrowed it down specifically to the instance variable declarations.
If I simply add these declarations and nothing else, I get the error.
I'm adding instance variables using the common approach:

    MyClass extend [
         | newVariable |    "Remove this, the error goes away"

         ...   "Various selectors added for extension"
    ]

How can we figure out why this error occurs? I can try to put together a
very minimal Seaside app to reproduce it in that context if needed.

Thanks
Mark

_______________________________________________
help-smalltalk mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-smalltalk
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Creating new instance variables in a dynamically created class in gst-remote

Holger Freyther

> On 05 Sep 2015, at 19:24, Mark Bratcher <[hidden email]> wrote:
>
> Hello

Hi!


> I narrowed it down specifically to the instance variable declarations. If I simply add these declarations and nothing else, I get the error. I'm adding instance variables using the common approach:
>
>   MyClass extend [
>        | newVariable |    "Remove this, the error goes away"
>
>        ...   "Various selectors added for extension"
>   ]
>
> How can we figure out why this error occurs? I can try to put together a very minimal Seaside app to reproduce it in that context if needed.

I am afraid it is a known issue. When using gst-remote (the scripts/Remote.st)
the Smalltalk In Smalltalk (STinST) parser is being used to parse your extension
and it doesn’t seem to handle instance variables.

With my time constraints I just maned to switch the order, load my code before
gst-remote is being used. :(

The STInST package is in packages/stinst/parser and based on the refactory
browser. With the Converter.st there are some examples. I used VisualGST in
the past to debug it but then renamed the namespace so I would use a different
parser than VisualGST is using itself. There are also some testcases that could
be serve as an example.

holger
_______________________________________________
help-smalltalk mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-smalltalk
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Creating new instance variables in a dynamically created class in gst-remote

Mark Bratcher-2
Thank you, Holger. I'll explore the options. As always, I appreciate the
prompt response.

Mark

On 9/5/2015 2:28 PM, Holger Freyther wrote:

>> On 05 Sep 2015, at 19:24, Mark Bratcher <[hidden email]> wrote:
>>
>> Hello
> Hi!
>
>
>> I narrowed it down specifically to the instance variable declarations. If I simply add these declarations and nothing else, I get the error. I'm adding instance variables using the common approach:
>>
>>    MyClass extend [
>>         | newVariable |    "Remove this, the error goes away"
>>
>>         ...   "Various selectors added for extension"
>>    ]
>>
>> How can we figure out why this error occurs? I can try to put together a very minimal Seaside app to reproduce it in that context if needed.
> I am afraid it is a known issue. When using gst-remote (the scripts/Remote.st)
> the Smalltalk In Smalltalk (STinST) parser is being used to parse your extension
> and it doesn’t seem to handle instance variables.
>
> With my time constraints I just maned to switch the order, load my code before
> gst-remote is being used. :(
>
> The STInST package is in packages/stinst/parser and based on the refactory
> browser. With the Converter.st there are some examples. I used VisualGST in
> the past to debug it but then renamed the namespace so I would use a different
> parser than VisualGST is using itself. There are also some testcases that could
> be serve as an example.
>
> holger


_______________________________________________
help-smalltalk mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-smalltalk
Loading...