Browse Source

first experiments

Nicolas Petton 11 years ago
parent
commit
b5c77ebb64
7 changed files with 682 additions and 1 deletions
  1. 16 0
      js/Kernel-Classes.deploy.js
  2. 21 0
      js/Kernel-Classes.js
  3. 208 0
      js/Nemo.deploy.js
  4. 293 0
      js/Nemo.js
  5. 2 1
      js/amber.js
  6. 20 0
      st/Kernel-Classes.st
  7. 122 0
      st/Nemo.st

+ 16 - 0
js/Kernel-Classes.deploy.js

@@ -321,6 +321,22 @@ return self;}
 }),
 smalltalk.Class);
 
+smalltalk.addMethod(
+"_definition",
+smalltalk.method({
+selector: "definition",
+fn: function (){
+var self=this;
+var stream=nil;
+(stream=smalltalk.send("", "_writeStream", []));
+(function($rec){smalltalk.send($rec, "_nextPutAll_", [smalltalk.send(smalltalk.send(self, "_superclass", []), "_asString", [])]);smalltalk.send($rec, "_nextPutAll_", [" subclass: #"]);smalltalk.send($rec, "_nextPutAll_", [smalltalk.send(self, "_name", [])]);smalltalk.send($rec, "_nextPutAll_", [smalltalk.send(smalltalk.send((smalltalk.String || String), "_lf", []), "__comma", [smalltalk.send((smalltalk.String || String), "_tab", [])])]);return smalltalk.send($rec, "_nextPutAll_", ["instanceVariableNames: '"]);})(stream);
+smalltalk.send(smalltalk.send(self, "_instanceVariableNames", []), "_do_separatedBy_", [(function(each){return smalltalk.send(stream, "_nextPutAll_", [each]);}), (function(){return smalltalk.send(stream, "_nextPutAll_", [" "]);})]);
+(function($rec){smalltalk.send($rec, "_nextPutAll_", [smalltalk.send(smalltalk.send("'", "__comma", [smalltalk.send((smalltalk.String || String), "_lf", [])]), "__comma", [smalltalk.send((smalltalk.String || String), "_tab", [])])]);smalltalk.send($rec, "_nextPutAll_", ["package: '"]);smalltalk.send($rec, "_nextPutAll_", [smalltalk.send(self, "_category", [])]);return smalltalk.send($rec, "_nextPutAll_", ["'"]);})(stream);
+return smalltalk.send(stream, "_contents", []);
+return self;}
+}),
+smalltalk.Class);
+
 smalltalk.addMethod(
 "_isClass",
 smalltalk.method({

+ 21 - 0
js/Kernel-Classes.js

@@ -458,6 +458,27 @@ referencedClasses: []
 }),
 smalltalk.Class);
 
+smalltalk.addMethod(
+"_definition",
+smalltalk.method({
+selector: "definition",
+category: 'accessing',
+fn: function (){
+var self=this;
+var stream=nil;
+(stream=smalltalk.send("", "_writeStream", []));
+(function($rec){smalltalk.send($rec, "_nextPutAll_", [smalltalk.send(smalltalk.send(self, "_superclass", []), "_asString", [])]);smalltalk.send($rec, "_nextPutAll_", [" subclass: #"]);smalltalk.send($rec, "_nextPutAll_", [smalltalk.send(self, "_name", [])]);smalltalk.send($rec, "_nextPutAll_", [smalltalk.send(smalltalk.send((smalltalk.String || String), "_lf", []), "__comma", [smalltalk.send((smalltalk.String || String), "_tab", [])])]);return smalltalk.send($rec, "_nextPutAll_", ["instanceVariableNames: '"]);})(stream);
+smalltalk.send(smalltalk.send(self, "_instanceVariableNames", []), "_do_separatedBy_", [(function(each){return smalltalk.send(stream, "_nextPutAll_", [each]);}), (function(){return smalltalk.send(stream, "_nextPutAll_", [" "]);})]);
+(function($rec){smalltalk.send($rec, "_nextPutAll_", [smalltalk.send(smalltalk.send("'", "__comma", [smalltalk.send((smalltalk.String || String), "_lf", [])]), "__comma", [smalltalk.send((smalltalk.String || String), "_tab", [])])]);smalltalk.send($rec, "_nextPutAll_", ["package: '"]);smalltalk.send($rec, "_nextPutAll_", [smalltalk.send(self, "_category", [])]);return smalltalk.send($rec, "_nextPutAll_", ["'"]);})(stream);
+return smalltalk.send(stream, "_contents", []);
+return self;},
+args: [],
+source: "definition\x0a\x09| stream |\x0a\x09stream := '' writeStream.\x0a\x09stream \x0a\x09    nextPutAll: self superclass asString;\x0a\x09    nextPutAll: ' subclass: #';\x0a\x09    nextPutAll: self name;\x0a\x09    nextPutAll: String lf, String tab;\x0a\x09    nextPutAll: 'instanceVariableNames: '''.\x0a\x09self instanceVariableNames \x0a\x09    do: [:each | stream nextPutAll: each] \x0a\x09    separatedBy: [stream nextPutAll: ' '].\x0a\x09stream\x0a\x09    nextPutAll: '''', String lf, String tab;\x0a\x09    nextPutAll: 'package: ''';\x0a\x09    nextPutAll: self category;\x0a\x09    nextPutAll: ''''.\x0a\x09^stream contents",
+messageSends: ["writeStream", "nextPutAll:", "asString", "superclass", "name", ",", "lf", "tab", "do:separatedBy:", "instanceVariableNames", "category", "contents"],
+referencedClasses: ["String"]
+}),
+smalltalk.Class);
+
 smalltalk.addMethod(
 "_isClass",
 smalltalk.method({

+ 208 - 0
js/Nemo.deploy.js

@@ -0,0 +1,208 @@
+smalltalk.addPackage('Nemo', {});
+smalltalk.addClass('NemoConnection', smalltalk.Object, ['socket'], 'Nemo');
+smalltalk.addMethod(
+"_close",
+smalltalk.method({
+selector: "close",
+fn: function (){
+var self=this;
+smalltalk.send(self['@socket'], "_close", []);
+(self['@socket']=nil);
+return self;}
+}),
+smalltalk.NemoConnection);
+
+smalltalk.addMethod(
+"_createDefaultSocket",
+smalltalk.method({
+selector: "createDefaultSocket",
+fn: function (){
+var self=this;
+smalltalk.send(self, "_createSocketOn_", [smalltalk.send(self, "_defaultURL", [])]);
+return self;}
+}),
+smalltalk.NemoConnection);
+
+smalltalk.addMethod(
+"_createLocalSocketOn_",
+smalltalk.method({
+selector: "createLocalSocketOn:",
+fn: function (aPort){
+var self=this;
+return smalltalk.send(self, "_createSocketOn_", [smalltalk.send(smalltalk.send("ws://localhost:", "__comma", [smalltalk.send(aPort, "_asString", [])]), "__comma", ["/nemo"])]);
+return self;}
+}),
+smalltalk.NemoConnection);
+
+smalltalk.addMethod(
+"_createSocketOn_",
+smalltalk.method({
+selector: "createSocketOn:",
+fn: function (uri){
+var self=this;
+(self['@socket']=new WebSocket(uri));
+smalltalk.send(self['@socket'], "_at_put_", ["onmessage", (function(message){return smalltalk.send(self, "_handleMessage_", [message]);})]);
+smalltalk.send(self['@socket'], "_at_put_", ["onerror", (function(err){return smalltalk.send((typeof console == 'undefined' ? nil : console), "_log_", [err]);})]);
+return self;}
+}),
+smalltalk.NemoConnection);
+
+smalltalk.addMethod(
+"_defaultURL",
+smalltalk.method({
+selector: "defaultURL",
+fn: function (){
+var self=this;
+return smalltalk.send(smalltalk.send(self, "_class", []), "_defaultURL", []);
+return self;}
+}),
+smalltalk.NemoConnection);
+
+smalltalk.addMethod(
+"_handleMessage_",
+smalltalk.method({
+selector: "handleMessage:",
+fn: function (aMessage){
+var self=this;
+var $early={};
+try{var string=nil;
+var result=nil;
+(string=smalltalk.send(aMessage, "_data", []));
+((($receiver = smalltalk.send(string, "_isString", [])).klass === smalltalk.Boolean) ? (! $receiver ? (function(){return (function(){throw $early=[self]})();})() : nil) : smalltalk.send($receiver, "_ifFalse_", [(function(){return (function(){throw $early=[self]})();})]));
+smalltalk.send((smalltalk.Transcript || Transcript), "_show_", [string]);
+(result=smalltalk.send(smalltalk.send((smalltalk.Compiler || Compiler), "_new", []), "_evaluateExpression_", [string]));
+smalltalk.send((typeof console == 'undefined' ? nil : console), "_log_", [result]);
+smalltalk.send((typeof console == 'undefined' ? nil : console), "_log_", [smalltalk.send(result, "_asNemoString", [])]);
+smalltalk.send(self['@socket'], "_send_", [smalltalk.send(result, "_asNemoString", [])]);
+return self;
+} catch(e) {if(e===$early)return e[0]; throw e}}
+}),
+smalltalk.NemoConnection);
+
+smalltalk.addMethod(
+"_send_",
+smalltalk.method({
+selector: "send:",
+fn: function (aString){
+var self=this;
+smalltalk.send(self['@socket'], "_send_", [aString]);
+return self;}
+}),
+smalltalk.NemoConnection);
+
+
+smalltalk.NemoConnection.klass.iVarNames = ['default'];
+smalltalk.addMethod(
+"_default",
+smalltalk.method({
+selector: "default",
+fn: function (){
+var self=this;
+return (($receiver = self['@default']) == nil || $receiver == undefined) ? (function(){return (self['@default']=smalltalk.send(self, "_new", []));})() : $receiver;
+return self;}
+}),
+smalltalk.NemoConnection.klass);
+
+smalltalk.addMethod(
+"_defaultURL",
+smalltalk.method({
+selector: "defaultURL",
+fn: function (){
+var self=this;
+return "ws://localhost:8010/nemo";
+return self;}
+}),
+smalltalk.NemoConnection.klass);
+
+
+smalltalk.addMethod(
+"_asNemo",
+smalltalk.method({
+selector: "asNemo",
+fn: function (){
+var self=this;
+return smalltalk.send(self, "_asJSON", []);
+return self;}
+}),
+smalltalk.Object);
+
+smalltalk.addMethod(
+"_asNemoString",
+smalltalk.method({
+selector: "asNemoString",
+fn: function (){
+var self=this;
+return smalltalk.send((smalltalk.JSON || JSON), "_stringify_", [smalltalk.send(self, "_asNemo", [])]);
+return self;}
+}),
+smalltalk.Object);
+
+smalltalk.addMethod(
+"_asNemo",
+smalltalk.method({
+selector: "asNemo",
+fn: function (){
+var self=this;
+return (function($rec){smalltalk.send($rec, "_at_put_", ["name", smalltalk.send(self, "_name", [])]);smalltalk.send($rec, "_at_put_", ["superclass", (($receiver = smalltalk.send(self, "_superclass", [])) != nil && $receiver != undefined) ? (function(){return smalltalk.send(smalltalk.send(self, "_superclass", []), "_name", []);})() : nil]);smalltalk.send($rec, "_at_put_", ["classComment", smalltalk.send(self, "_comment", [])]);smalltalk.send($rec, "_at_put_", ["definition", smalltalk.send(self, "_definition", [])]);smalltalk.send($rec, "_at_put_", ["package", smalltalk.send(self, "_category", [])]);return smalltalk.send($rec, "_asNemo", []);})(smalltalk.send((smalltalk.Dictionary || Dictionary), "_new", []));
+return self;}
+}),
+smalltalk.Class);
+
+smalltalk.addMethod(
+"_asNemo",
+smalltalk.method({
+selector: "asNemo",
+fn: function (){
+var self=this;
+return smalltalk.send(smalltalk.send(self, "_asArray", []), "_collect_", [(function(each){return smalltalk.send(each, "_asNemo", []);})]);
+return self;}
+}),
+smalltalk.Collection);
+
+smalltalk.addMethod(
+"_asNemo",
+smalltalk.method({
+selector: "asNemo",
+fn: function (){
+var self=this;
+var c=nil;
+(c=smalltalk.send(smalltalk.send(self, "_class", []), "_new", []));
+smalltalk.send(self, "_keysAndValuesDo_", [(function(key, value){return smalltalk.send(c, "_at_put_", [key, smalltalk.send(value, "_asNemo", [])]);})]);
+return c;
+return self;}
+}),
+smalltalk.HashedCollection);
+
+smalltalk.addMethod(
+"_asNemo",
+smalltalk.method({
+selector: "asNemo",
+fn: function (){
+var self=this;
+return smalltalk.send(smalltalk.send(self, "_asHashedCollection", []), "_asNemo", []);
+return self;}
+}),
+smalltalk.Dictionary);
+
+smalltalk.addMethod(
+"_asNemo",
+smalltalk.method({
+selector: "asNemo",
+fn: function (){
+var self=this;
+return self;
+return self;}
+}),
+smalltalk.String);
+
+smalltalk.addMethod(
+"_asNemo",
+smalltalk.method({
+selector: "asNemo",
+fn: function (){
+var self=this;
+return (function($rec){smalltalk.send($rec, "_at_put_", ["name", smalltalk.send(self, "_name", [])]);return smalltalk.send($rec, "_asNemo", []);})(smalltalk.send((smalltalk.Dictionary || Dictionary), "_new", []));
+return self;}
+}),
+smalltalk.Package);
+

+ 293 - 0
js/Nemo.js

@@ -0,0 +1,293 @@
+smalltalk.addPackage('Nemo', {});
+smalltalk.addClass('NemoConnection', smalltalk.Object, ['socket'], 'Nemo');
+smalltalk.addMethod(
+"_close",
+smalltalk.method({
+selector: "close",
+category: 'not yet classified',
+fn: function (){
+var self=this;
+smalltalk.send(self['@socket'], "_close", []);
+(self['@socket']=nil);
+return self;},
+args: [],
+source: "close\x0a\x09socket close.\x0a\x09socket := nil",
+messageSends: ["close"],
+referencedClasses: []
+}),
+smalltalk.NemoConnection);
+
+smalltalk.addMethod(
+"_createDefaultSocket",
+smalltalk.method({
+selector: "createDefaultSocket",
+category: 'not yet classified',
+fn: function (){
+var self=this;
+smalltalk.send(self, "_createSocketOn_", [smalltalk.send(self, "_defaultURL", [])]);
+return self;},
+args: [],
+source: "createDefaultSocket\x0a\x09\x0a\x09self createSocketOn: self defaultURL.",
+messageSends: ["createSocketOn:", "defaultURL"],
+referencedClasses: []
+}),
+smalltalk.NemoConnection);
+
+smalltalk.addMethod(
+"_createLocalSocketOn_",
+smalltalk.method({
+selector: "createLocalSocketOn:",
+category: 'not yet classified',
+fn: function (aPort){
+var self=this;
+return smalltalk.send(self, "_createSocketOn_", [smalltalk.send(smalltalk.send("ws://localhost:", "__comma", [smalltalk.send(aPort, "_asString", [])]), "__comma", ["/nemo"])]);
+return self;},
+args: ["aPort"],
+source: "createLocalSocketOn: aPort\x0a\x0a\x09^ self createSocketOn: 'ws://localhost:',aPort asString,'/nemo'",
+messageSends: ["createSocketOn:", ",", "asString"],
+referencedClasses: []
+}),
+smalltalk.NemoConnection);
+
+smalltalk.addMethod(
+"_createSocketOn_",
+smalltalk.method({
+selector: "createSocketOn:",
+category: 'not yet classified',
+fn: function (uri){
+var self=this;
+(self['@socket']=new WebSocket(uri));
+smalltalk.send(self['@socket'], "_at_put_", ["onmessage", (function(message){return smalltalk.send(self, "_handleMessage_", [message]);})]);
+smalltalk.send(self['@socket'], "_at_put_", ["onerror", (function(err){return smalltalk.send((typeof console == 'undefined' ? nil : console), "_log_", [err]);})]);
+return self;},
+args: ["uri"],
+source: "createSocketOn: uri\x0a\x09socket := <new WebSocket(uri)>.\x0a\x09socket at: 'onmessage' put: [ :message | self handleMessage: message ].\x0a\x09socket at: 'onerror' put: [ :err | console log: err ]",
+messageSends: ["at:put:", "handleMessage:", "log:"],
+referencedClasses: []
+}),
+smalltalk.NemoConnection);
+
+smalltalk.addMethod(
+"_defaultURL",
+smalltalk.method({
+selector: "defaultURL",
+category: 'not yet classified',
+fn: function (){
+var self=this;
+return smalltalk.send(smalltalk.send(self, "_class", []), "_defaultURL", []);
+return self;},
+args: [],
+source: "defaultURL\x0a\x0a\x09^ self class defaultURL",
+messageSends: ["defaultURL", "class"],
+referencedClasses: []
+}),
+smalltalk.NemoConnection);
+
+smalltalk.addMethod(
+"_handleMessage_",
+smalltalk.method({
+selector: "handleMessage:",
+category: 'not yet classified',
+fn: function (aMessage){
+var self=this;
+var $early={};
+try{var string=nil;
+var result=nil;
+(string=smalltalk.send(aMessage, "_data", []));
+((($receiver = smalltalk.send(string, "_isString", [])).klass === smalltalk.Boolean) ? (! $receiver ? (function(){return (function(){throw $early=[self]})();})() : nil) : smalltalk.send($receiver, "_ifFalse_", [(function(){return (function(){throw $early=[self]})();})]));
+smalltalk.send((smalltalk.Transcript || Transcript), "_show_", [string]);
+(result=smalltalk.send(smalltalk.send((smalltalk.Compiler || Compiler), "_new", []), "_evaluateExpression_", [string]));
+smalltalk.send((typeof console == 'undefined' ? nil : console), "_log_", [result]);
+smalltalk.send((typeof console == 'undefined' ? nil : console), "_log_", [smalltalk.send(result, "_asNemoString", [])]);
+smalltalk.send(self['@socket'], "_send_", [smalltalk.send(result, "_asNemoString", [])]);
+return self;
+} catch(e) {if(e===$early)return e[0]; throw e}},
+args: ["aMessage"],
+source: "handleMessage: aMessage\x0a\x09| string result |\x0a\x0a\x09string := aMessage data.\x0a\x09string isString ifFalse: [ ^ self ].\x0a\x0a\x09Transcript show: string.\x0a\x0a\x09result := Compiler new evaluateExpression: string.\x0a\x09console log: result.\x0a\x09console log: result asNemoString.\x0a\x09socket send: result asNemoString",
+messageSends: ["data", "ifFalse:", "isString", "show:", "evaluateExpression:", "new", "log:", "asNemoString", "send:"],
+referencedClasses: ["Transcript", "Compiler"]
+}),
+smalltalk.NemoConnection);
+
+smalltalk.addMethod(
+"_send_",
+smalltalk.method({
+selector: "send:",
+category: 'not yet classified',
+fn: function (aString){
+var self=this;
+smalltalk.send(self['@socket'], "_send_", [aString]);
+return self;},
+args: ["aString"],
+source: "send: aString\x0a\x09socket send: aString",
+messageSends: ["send:"],
+referencedClasses: []
+}),
+smalltalk.NemoConnection);
+
+
+smalltalk.NemoConnection.klass.iVarNames = ['default'];
+smalltalk.addMethod(
+"_default",
+smalltalk.method({
+selector: "default",
+category: 'not yet classified',
+fn: function (){
+var self=this;
+return (($receiver = self['@default']) == nil || $receiver == undefined) ? (function(){return (self['@default']=smalltalk.send(self, "_new", []));})() : $receiver;
+return self;},
+args: [],
+source: "default\x0a\x09^ default ifNil: [ default := self new ]",
+messageSends: ["ifNil:", "new"],
+referencedClasses: []
+}),
+smalltalk.NemoConnection.klass);
+
+smalltalk.addMethod(
+"_defaultURL",
+smalltalk.method({
+selector: "defaultURL",
+category: 'not yet classified',
+fn: function (){
+var self=this;
+return "ws://localhost:8010/nemo";
+return self;},
+args: [],
+source: "defaultURL\x0a\x0a\x09^ 'ws://localhost:8010/nemo'",
+messageSends: [],
+referencedClasses: []
+}),
+smalltalk.NemoConnection.klass);
+
+
+smalltalk.addMethod(
+"_asNemo",
+smalltalk.method({
+selector: "asNemo",
+category: '*Nemo',
+fn: function (){
+var self=this;
+return smalltalk.send(self, "_asJSON", []);
+return self;},
+args: [],
+source: "asNemo\x0a\x09^ self asJSON",
+messageSends: ["asJSON"],
+referencedClasses: []
+}),
+smalltalk.Object);
+
+smalltalk.addMethod(
+"_asNemoString",
+smalltalk.method({
+selector: "asNemoString",
+category: '*Nemo',
+fn: function (){
+var self=this;
+return smalltalk.send((smalltalk.JSON || JSON), "_stringify_", [smalltalk.send(self, "_asNemo", [])]);
+return self;},
+args: [],
+source: "asNemoString\x0a\x09^JSON stringify: self asNemo",
+messageSends: ["stringify:", "asNemo"],
+referencedClasses: ["JSON"]
+}),
+smalltalk.Object);
+
+smalltalk.addMethod(
+"_asNemo",
+smalltalk.method({
+selector: "asNemo",
+category: '*Nemo',
+fn: function (){
+var self=this;
+return (function($rec){smalltalk.send($rec, "_at_put_", ["name", smalltalk.send(self, "_name", [])]);smalltalk.send($rec, "_at_put_", ["superclass", (($receiver = smalltalk.send(self, "_superclass", [])) != nil && $receiver != undefined) ? (function(){return smalltalk.send(smalltalk.send(self, "_superclass", []), "_name", []);})() : nil]);smalltalk.send($rec, "_at_put_", ["classComment", smalltalk.send(self, "_comment", [])]);smalltalk.send($rec, "_at_put_", ["definition", smalltalk.send(self, "_definition", [])]);smalltalk.send($rec, "_at_put_", ["package", smalltalk.send(self, "_category", [])]);return smalltalk.send($rec, "_asNemo", []);})(smalltalk.send((smalltalk.Dictionary || Dictionary), "_new", []));
+return self;},
+args: [],
+source: "asNemo\x0a\x09^ Dictionary new\x0a\x09\x09at: 'name' put: self name;\x0a\x09\x09at: 'superclass' put: (self superclass ifNotNil: [ self superclass name ]);\x0a\x09\x09at: 'classComment' put: self comment;\x0a\x09\x09at: 'definition' put: self definition;\x0a\x09\x09at: 'package' put: self category;\x0a\x09\x09asNemo",
+messageSends: ["at:put:", "name", "ifNotNil:", "superclass", "comment", "definition", "category", "asNemo", "new"],
+referencedClasses: ["Dictionary"]
+}),
+smalltalk.Class);
+
+smalltalk.addMethod(
+"_asNemo",
+smalltalk.method({
+selector: "asNemo",
+category: '*Nemo',
+fn: function (){
+var self=this;
+return smalltalk.send(smalltalk.send(self, "_asArray", []), "_collect_", [(function(each){return smalltalk.send(each, "_asNemo", []);})]);
+return self;},
+args: [],
+source: "asNemo\x0a\x09^self asArray collect: [:each | each asNemo]",
+messageSends: ["collect:", "asArray", "asNemo"],
+referencedClasses: []
+}),
+smalltalk.Collection);
+
+smalltalk.addMethod(
+"_asNemo",
+smalltalk.method({
+selector: "asNemo",
+category: '*Nemo',
+fn: function (){
+var self=this;
+var c=nil;
+(c=smalltalk.send(smalltalk.send(self, "_class", []), "_new", []));
+smalltalk.send(self, "_keysAndValuesDo_", [(function(key, value){return smalltalk.send(c, "_at_put_", [key, smalltalk.send(value, "_asNemo", [])]);})]);
+return c;
+return self;},
+args: [],
+source: "asNemo\x0a\x09| c |\x0a\x09c := self class new.\x0a\x09self keysAndValuesDo: [:key :value |\x0a\x09\x09c at: key put: value asNemo].\x0a\x09^c",
+messageSends: ["new", "class", "keysAndValuesDo:", "at:put:", "asNemo"],
+referencedClasses: []
+}),
+smalltalk.HashedCollection);
+
+smalltalk.addMethod(
+"_asNemo",
+smalltalk.method({
+selector: "asNemo",
+category: '*Nemo',
+fn: function (){
+var self=this;
+return smalltalk.send(smalltalk.send(self, "_asHashedCollection", []), "_asNemo", []);
+return self;},
+args: [],
+source: "asNemo\x0a\x09^self asHashedCollection asNemo",
+messageSends: ["asNemo", "asHashedCollection"],
+referencedClasses: []
+}),
+smalltalk.Dictionary);
+
+smalltalk.addMethod(
+"_asNemo",
+smalltalk.method({
+selector: "asNemo",
+category: '*Nemo',
+fn: function (){
+var self=this;
+return self;
+return self;},
+args: [],
+source: "asNemo\x0a\x09^ self",
+messageSends: [],
+referencedClasses: []
+}),
+smalltalk.String);
+
+smalltalk.addMethod(
+"_asNemo",
+smalltalk.method({
+selector: "asNemo",
+category: '*Nemo',
+fn: function (){
+var self=this;
+return (function($rec){smalltalk.send($rec, "_at_put_", ["name", smalltalk.send(self, "_name", [])]);return smalltalk.send($rec, "_asNemo", []);})(smalltalk.send((smalltalk.Dictionary || Dictionary), "_new", []));
+return self;},
+args: [],
+source: "asNemo\x0a\x09^ Dictionary new\x0a\x09\x09at: 'name' put: self name;\x0a\x09\x09asNemo",
+messageSends: ["at:put:", "name", "asNemo", "new"],
+referencedClasses: ["Dictionary"]
+}),
+smalltalk.Package);
+

+ 2 - 1
js/amber.js

@@ -89,7 +89,8 @@ amber = (function() {
 				'SUnit',
 				'Examples',
 				'Benchfib',
-				'Kernel-Tests'
+				'Kernel-Tests',
+                'Nemo'
 			]);
 		}
 

+ 20 - 0
st/Kernel-Classes.st

@@ -177,6 +177,26 @@ category
 	^self package ifNil: ['Unclassified'] ifNotNil: [self package name]
 !
 
+definition
+	| stream |
+	stream := '' writeStream.
+	stream 
+	    nextPutAll: self superclass asString;
+	    nextPutAll: ' subclass: #';
+	    nextPutAll: self name;
+	    nextPutAll: String lf, String tab;
+	    nextPutAll: 'instanceVariableNames: '''.
+	self instanceVariableNames 
+	    do: [:each | stream nextPutAll: each] 
+	    separatedBy: [stream nextPutAll: ' '].
+	stream
+	    nextPutAll: '''', String lf, String tab;
+	    nextPutAll: 'package: ''';
+	    nextPutAll: self category;
+	    nextPutAll: ''''.
+	^stream contents
+!
+
 package
 	<return self.pkg>
 !

+ 122 - 0
st/Nemo.st

@@ -0,0 +1,122 @@
+Smalltalk current createPackage: 'Nemo' properties: #{}!
+Object subclass: #NemoConnection
+	instanceVariableNames: 'socket'
+	package: 'Nemo'!
+
+!NemoConnection methodsFor: 'not yet classified'!
+
+close
+	socket close.
+	socket := nil
+!
+
+createDefaultSocket
+	
+	self createSocketOn: self defaultURL.
+!
+
+createLocalSocketOn: aPort
+
+	^ self createSocketOn: 'ws://localhost:',aPort asString,'/nemo'
+!
+
+createSocketOn: uri
+	socket := <new WebSocket(uri)>.
+	socket at: 'onmessage' put: [ :message | self handleMessage: message ].
+	socket at: 'onerror' put: [ :err | console log: err ]
+!
+
+defaultURL
+
+	^ self class defaultURL
+!
+
+handleMessage: aMessage
+	| string result |
+
+	string := aMessage data.
+	string isString ifFalse: [ ^ self ].
+
+	Transcript show: string.
+
+	result := Compiler new evaluateExpression: string.
+	console log: result.
+	console log: result asNemoString.
+	socket send: result asNemoString
+!
+
+send: aString
+	socket send: aString
+! !
+
+NemoConnection class instanceVariableNames: 'default'!
+
+!NemoConnection class methodsFor: 'not yet classified'!
+
+default
+	^ default ifNil: [ default := self new ]
+!
+
+defaultURL
+
+	^ 'ws://localhost:8010/nemo'
+! !
+
+!Object methodsFor: '*Nemo'!
+
+asNemo
+	^ self asJSON
+!
+
+asNemoString
+	^JSON stringify: self asNemo
+! !
+
+!Class methodsFor: '*Nemo'!
+
+asNemo
+	^ Dictionary new
+		at: 'name' put: self name;
+		at: 'superclass' put: (self superclass ifNotNil: [ self superclass name ]);
+		at: 'classComment' put: self comment;
+		at: 'definition' put: self definition;
+		at: 'package' put: self category;
+		asNemo
+! !
+
+!Collection methodsFor: '*Nemo'!
+
+asNemo
+	^self asArray collect: [:each | each asNemo]
+! !
+
+!HashedCollection methodsFor: '*Nemo'!
+
+asNemo
+	| c |
+	c := self class new.
+	self keysAndValuesDo: [:key :value |
+		c at: key put: value asNemo].
+	^c
+! !
+
+!Dictionary methodsFor: '*Nemo'!
+
+asNemo
+	^self asHashedCollection asNemo
+! !
+
+!String methodsFor: '*Nemo'!
+
+asNemo
+	^ self
+! !
+
+!Package methodsFor: '*Nemo'!
+
+asNemo
+	^ Dictionary new
+		at: 'name' put: self name;
+		asNemo
+! !
+