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

Mark Bratcher <[email protected]>
Newsgroups gmane.comp.lang.smalltalk.gnu.general
Message-ID <[email protected]>
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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.