Question on amberc and node.js

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

Question on amberc and node.js

Stefan Krecher
Hi,
i try the following: generate an amber-startup-script that contains Kernel + Compiler classes and that filesIn the FileServer.st (or arbitrary packages) when started on node.js Server.
The goal is to manipulate code in the client and bring it to the server by filing it in at startup or by pushing/ executing it to/ on the running (node.js) server.
I generate a Server.js with amberc containing the Compiler-package and add something like that:

var src = fs.readFileSync('st/FileServer.st', 'utf8');
smalltalk.Importer._new()._importString_(src); <- importString opens a stream on a String and calls "import: aStream"

Though FileServer.st gets loaded, i get the stack-trace:

a Importer>>import:
a Compiler>>loadExpression:
a Compiler>>compileExpression:
a Compiler>>parse:
a Smalltalk>>parse:
a Smalltalk>>try:catch:
a Smalltalk>>basicParse:
a Smalltalk>>parseError:parsing:
a Array ('doIt ^[Object subclass: #FileServer' ' instanceVariableNames: 'path http fs url port basePath sys'' ' category: 'FileServer'] value')>>at:
a Array ('doIt ^[Object subclass: #FileServer' ' instanceVariableNames: 'path http fs url port basePath sys'' ' category: 'FileServer'] value')>>at:ifAbsent:
a Array ('doIt ^[Object subclass: #FileServer' ' instanceVariableNames: 'path http fs url port basePath sys'' ' category: 'FileServer'] value')>>errorNotFound
a Array ('doIt ^[Object subclass: #FileServer' ' instanceVariableNames: 'path http fs url port basePath sys'' ' category: 'FileServer'] value')>>error:
Error>>signal:
Object is not in the collection

I tried to programmatically fileIn other packages but the error is always the same.

Does anybody have an Idea whats going on?

Thanks,
Stefan
Reply | Threaded
Open this post in threaded view
|

Re: Question on amberc and node.js

Stefan Krecher
Hi,
i'still struggling with this issue - when i execute the following in the server.js Script:
smalltalk.Compiler._new()._compileExpression_('1 + 1');
i get a similar Exception (see below).
Could it be that the result of "compileExpression" is a complex Javascript Expression that somehow gets escaped and misinterpreted?
I would be very thankful for any hints -
regards,
Stefan

a Compiler>>parse:
a Smalltalk>>parse:
a Smalltalk>>try:catch:
a Smalltalk>>basicParse:
a Smalltalk>>parseError:parsing:
a Array ('doIt ^[1 + 1] value')>>at:
a Array ('doIt ^[1 + 1] value')>>at:ifAbsent:
a Array ('doIt ^[1 + 1] value')>>errorNotFound
a Array ('doIt ^[1 + 1] value')>>error:
Error>>signal:
Object is not in the collection
a Compiler>>compileNode:
a Compiler>>visit:
nil does not understand #accept:
Starting file server on port 4000
Reply | Threaded
Open this post in threaded view
|

Re: Question on amberc and node.js

Nicolas Petton
Hi,

Can you tell me how you add this line and where? How do you start the
server after that?

Your code seems to be fine :)

Cheers,
Nico

On Mon, 2011-10-17 at 03:33 -0700, Stefan Krecher wrote:

> Hi,
> i'still struggling with this issue - when i execute the following in
> the server.js Script:
> smalltalk.Compiler._new()._compileExpression_('1 + 1');
> i get a similar Exception (see below).
>
> Could it be that the result of "compileExpression" is a complex
> Javascript Expression that somehow gets escaped and misinterpreted?
> I would be very thankful for any hints -
> regards,
> Stefan
>
>
> a Compiler>>parse:
> a Smalltalk>>parse:
> a Smalltalk>>try:catch:
> a Smalltalk>>basicParse:
> a Smalltalk>>parseError:parsing:
> a Array ('doIt ^[1 + 1] value')>>at:
> a Array ('doIt ^[1 + 1] value')>>at:ifAbsent:
> a Array ('doIt ^[1 + 1] value')>>errorNotFound
> a Array ('doIt ^[1 + 1] value')>>error:
> Error>>signal:
> Object is not in the collection
> a Compiler>>compileNode:
> a Compiler>>visit:
> nil does not understand #accept:
> Starting file server on port 4000


Reply | Threaded
Open this post in threaded view
|

Re: Question on amberc and node.js

Stefan Krecher-2
Here's what i do:

1. compile a server-script to be started with node: bin/amberc -m FileServer st/FileServer.st st/Compiler.st server
2. edit the generated server.js and put the line "smalltalk.Compiler._new()._compileExpression_('1 + 1');" right before the Statement "smalltalk.FileServer._main()"
3. start node: "node server.js" - on startup the error occurs.

regards,
Stefan

2011/10/17 Nicolas Petton <[hidden email]>
Hi,

Can you tell me how you add this line and where? How do you start the
server after that?

Your code seems to be fine :)

Cheers,
Nico

On Mon, 2011-10-17 at 03:33 -0700, Stefan Krecher wrote:
> Hi,
> i'still struggling with this issue - when i execute the following in
> the server.js Script:
> smalltalk.Compiler._new()._compileExpression_('1 + 1');
> i get a similar Exception (see below).
>
> Could it be that the result of "compileExpression" is a complex
> Javascript Expression that somehow gets escaped and misinterpreted?
> I would be very thankful for any hints -
> regards,
> Stefan
>
>
> a Compiler>>parse:
> a Smalltalk>>parse:
> a Smalltalk>>try:catch:
> a Smalltalk>>basicParse:
> a Smalltalk>>parseError:parsing:
> a Array ('doIt ^[1 + 1] value')>>at:
> a Array ('doIt ^[1 + 1] value')>>at:ifAbsent:
> a Array ('doIt ^[1 + 1] value')>>errorNotFound
> a Array ('doIt ^[1 + 1] value')>>error:
> Error>>signal:
> Object is not in the collection
> a Compiler>>compileNode:
> a Compiler>>visit:
> nil does not understand #accept:
> Starting file server on port 4000





--
Dipl.-Wirtsch.-Inf. Stefan Krecher
Neulander Str. 17, 27374 Visselhövede
Tel +49(0)4262 958848
mobil +49(0)172 3608616
http://krecher.com
Reply | Threaded
Open this post in threaded view
|

Re: Question on amberc and node.js

Stefan Krecher
just saw that i forgot to link the parser.js ...

Reply | Threaded
Open this post in threaded view
|

Re: Question on amberc and node.js

Nicolas Petton
Hehe, indeed, without the parser you won't go very far :)
Does it work now?

Cheers,
Nico

On Mon, 2011-10-17 at 04:36 -0700, Stefan Krecher wrote:
> just saw that i forgot to link the parser.js ...
>
>


Reply | Threaded
Open this post in threaded view
|

Re: Question on amberc and node.js

Stefan Krecher
Yes it works - and it is so cool :-)
I'm experimenting with running amber on dotcloud (there is a free plan for hosting node.js apps).
It is very cool to have amber running on the serverside, serving the GUI via HTTP-Requests. The server-part of course is coded from the amber-web-client and then pushed to the server.
Best of all: the free plan on dotcloud allows two services - one is node.js, the other could be a Database. Besides mysql and postgres they support MongoDB and Redis!
I'm preparing an article/ blog-entry on this.
regards,
Stefan
Reply | Threaded
Open this post in threaded view
|

Re: Question on amberc and node.js

Nicolas Petton
Excellent!

Nico

On Tue, 2011-10-18 at 07:12 -0700, Stefan Krecher wrote:

> Yes it works - and it is so cool :-)
> I'm experimenting with running amber on dotcloud (there is a free plan
> for hosting node.js apps).
> It is very cool to have amber running on the serverside, serving the
> GUI via HTTP-Requests. The server-part of course is coded from the
> amber-web-client and then pushed to the server.
> Best of all: the free plan on dotcloud allows two services - one is
> node.js, the other could be a Database. Besides mysql and postgres
> they support MongoDB and Redis!
> I'm preparing an article/ blog-entry on this.
> regards,
> Stefan