Browse Source

added BlockClosure>>ensure:

Nicolas Petton 14 years ago
parent
commit
b6da02b88d
4 changed files with 1036 additions and 751 deletions
  1. 318 257
      js/Compiler.js
  2. 278 230
      js/Examples.js
  3. 422 260
      js/Kernel.js
  4. 18 4
      js/boot.js

File diff suppressed because it is too large
+ 318 - 257
js/Compiler.js


+ 278 - 230
js/Examples.js

@@ -1,14 +1,15 @@
-smalltalk.addClass('Counter', smalltalk.Widget, ['count'], 'Examples');
+smalltalk.addClass('Counter', smalltalk.Widget, ['count', 'header'], 'Examples');
 smalltalk.addMethod(
 '_initialize',
 smalltalk.method({
 selector: 'initialize',
 category: 'initialization',
-fn: function (){
-var self=this;
-self.klass.superclass.fn.prototype['_initialize'].apply(self, []);
-self['@count']=(0);
-return self;},
+fn: function () {
+    var self = this;
+    self.klass.superclass.fn.prototype._initialize.apply(self, []);
+    self['@count'] = 0;
+    return self;
+},
 source: unescape('initialize%0A%20%20%20%20super%20initialize.%0A%20%20%20%20count%20%3A%3D%200%0A')}),
 smalltalk.Counter);
 
@@ -17,13 +18,14 @@ smalltalk.addMethod(
 smalltalk.method({
 selector: 'renderOn:',
 category: 'rendering',
-fn: function (html){
-var self=this;
-smalltalk.send(smalltalk.send(html, "_h1", []), "_with_", [smalltalk.send(self['@count'], "_asString", [])]);
-(function($rec){smalltalk.send($rec, "_with_", [unescape("++")]);return smalltalk.send($rec, "_onClick_", [(function(){return smalltalk.send(self, "_increase", []);})]);})(smalltalk.send(html, "_button", []));
-(function($rec){smalltalk.send($rec, "_with_", [unescape("--")]);return smalltalk.send($rec, "_onClick_", [(function(){return smalltalk.send(self, "_decrease", []);})]);})(smalltalk.send(html, "_button", []));
-return self;},
-source: unescape('renderOn%3A%20html%0A%20%20%20%20html%20h1%20with%3A%20count%20asString.%0A%20%20%20%20html%20button%0A%09with%3A%20%27++%27%3B%0A%09onClick%3A%20%5Bself%20increase%5D.%0A%20%20%20%20html%20button%0A%09with%3A%20%27--%27%3B%0A%09onClick%3A%20%5Bself%20decrease%5D%0A')}),
+fn: function (html) {
+    var self = this;
+    self['@header'] = function ($rec) {smalltalk.send($rec, "_with_", [smalltalk.send(self['@count'], "_asString", [])]);return smalltalk.send($rec, "_yourself", []);}(smalltalk.send(html, "_h1", []));
+    (function ($rec) {smalltalk.send($rec, "_with_", [unescape("++")]);return smalltalk.send($rec, "_onClick_", [function () {return smalltalk.send(self, "_increase", []);}]);}(smalltalk.send(html, "_button", [])));
+    (function ($rec) {smalltalk.send($rec, "_with_", [unescape("--")]);return smalltalk.send($rec, "_onClick_", [function () {return smalltalk.send(self, "_decrease", []);}]);}(smalltalk.send(html, "_button", [])));
+    return self;
+},
+source: unescape('renderOn%3A%20html%0A%20%20%20%20header%20%3A%3D%20html%20h1%20%0A%09with%3A%20count%20asString%3B%0A%09yourself.%0A%20%20%20%20html%20button%0A%09with%3A%20%27++%27%3B%0A%09onClick%3A%20%5Bself%20increase%5D.%0A%20%20%20%20html%20button%0A%09with%3A%20%27--%27%3B%0A%09onClick%3A%20%5Bself%20decrease%5D%0A')}),
 smalltalk.Counter);
 
 smalltalk.addMethod(
@@ -31,12 +33,13 @@ smalltalk.addMethod(
 smalltalk.method({
 selector: 'increase',
 category: 'actions',
-fn: function (){
-var self=this;
-self['@count']=smalltalk.send(self['@count'], "__plus", [(1)]);
-smalltalk.send(self, "_update", []);
-return self;},
-source: unescape('increase%0A%20%20%20%20count%20%3A%3D%20count%20+%201.%0A%20%20%20%20self%20update%0A')}),
+fn: function () {
+    var self = this;
+    self['@count'] = smalltalk.send(self['@count'], "__plus", [1]);
+    smalltalk.send(self['@header'], "_contents_", [function (html) {return smalltalk.send(html, "_with_", [smalltalk.send(self['@count'], "_asString", [])]);}]);
+    return self;
+},
+source: unescape('increase%0A%20%20%20%20count%20%3A%3D%20count%20+%201.%0A%20%20%20%20header%20contents%3A%20%5B%3Ahtml%20%7C%20html%20with%3A%20count%20asString%5D')}),
 smalltalk.Counter);
 
 smalltalk.addMethod(
@@ -44,12 +47,13 @@ smalltalk.addMethod(
 smalltalk.method({
 selector: 'decrease',
 category: 'actions',
-fn: function (){
-var self=this;
-self['@count']=smalltalk.send(self['@count'], "__minus", [(1)]);
-smalltalk.send(self, "_update", []);
-return self;},
-source: unescape('decrease%0A%20%20%20%20count%20%3A%3D%20count%20-%201.%0A%20%20%20%20self%20update%0A')}),
+fn: function () {
+    var self = this;
+    self['@count'] = smalltalk.send(self['@count'], "__minus", [1]);
+    smalltalk.send(self['@header'], "_contents_", [function (html) {return smalltalk.send(html, "_with_", [smalltalk.send(self['@count'], "_asString", [])]);}]);
+    return self;
+},
+source: unescape('decrease%0A%20%20%20%20count%20%3A%3D%20count%20-%201.%0A%20%20%20%20header%20contents%3A%20%5B%3Ahtml%20%7C%20html%20with%3A%20count%20asString%5D')}),
 smalltalk.Counter);
 
 
@@ -60,10 +64,11 @@ smalltalk.addMethod(
 smalltalk.method({
 selector: 'renderOn:',
 category: 'rendering',
-fn: function (html){
-var self=this;
-(function($rec){smalltalk.send($rec, "_class_", ["tetris"]);return smalltalk.send($rec, "_with_", [(function(){smalltalk.send(smalltalk.send(html, "_h3", []), "_with_", ["Tetris"]);smalltalk.send(self, "_renderCanvasOn_", [html]);return smalltalk.send(self, "_renderButtonsOn_", [html]);})]);})(smalltalk.send(html, "_div", []));
-return self;},
+fn: function (html) {
+    var self = this;
+    (function ($rec) {smalltalk.send($rec, "_class_", ["tetris"]);return smalltalk.send($rec, "_with_", [function () {smalltalk.send(smalltalk.send(html, "_h3", []), "_with_", ["Tetris"]);smalltalk.send(self, "_renderCanvasOn_", [html]);return smalltalk.send(self, "_renderButtonsOn_", [html]);}]);}(smalltalk.send(html, "_div", [])));
+    return self;
+},
 source: unescape('renderOn%3A%20html%0A%09html%20div%0A%09%09class%3A%20%27tetris%27%3B%0A%09%09with%3A%20%5B%0A%09%09%09html%20h3%20with%3A%20%27Tetris%27.%0A%09%09%09self%20renderCanvasOn%3A%20html.%0A%09%09%09self%20renderButtonsOn%3A%20html%5D')}),
 smalltalk.Tetris);
 
@@ -72,15 +77,16 @@ smalltalk.addMethod(
 smalltalk.method({
 selector: 'renderCanvasOn:',
 category: 'rendering',
-fn: function (html){
-var self=this;
-var canvas=nil;
-canvas=smalltalk.send(html, "_canvas", []);
-smalltalk.send(canvas, "_at_put_", ["width", smalltalk.send(smalltalk.send(self, "_width", []), "_asString", [])]);
-smalltalk.send(canvas, "_at_put_", ["height", smalltalk.send(smalltalk.send(self, "_height", []), "_asString", [])]);
-self['@renderingContext']=smalltalk.send(smalltalk.CanvasRenderingContext, "_tagBrush_", [canvas]);
-smalltalk.send(self, "_redraw", []);
-return self;},
+fn: function (html) {
+    var self = this;
+    var canvas = nil;
+    canvas = smalltalk.send(html, "_canvas", []);
+    smalltalk.send(canvas, "_at_put_", ["width", smalltalk.send(smalltalk.send(self, "_width", []), "_asString", [])]);
+    smalltalk.send(canvas, "_at_put_", ["height", smalltalk.send(smalltalk.send(self, "_height", []), "_asString", [])]);
+    self['@renderingContext'] = smalltalk.send(smalltalk.CanvasRenderingContext, "_tagBrush_", [canvas]);
+    smalltalk.send(self, "_redraw", []);
+    return self;
+},
 source: unescape('renderCanvasOn%3A%20html%0A%09%7C%20canvas%20%7C%0A%09canvas%20%3A%3D%20html%20canvas.%0A%09canvas%20at%3A%20%27width%27%20put%3A%20self%20width%20asString.%0A%09canvas%20at%3A%20%27height%27%20put%3A%20self%20height%20asString.%0A%09renderingContext%20%3A%3D%20CanvasRenderingContext%20tagBrush%3A%20canvas.%0A%09self%20redraw')}),
 smalltalk.Tetris);
 
@@ -89,10 +95,11 @@ smalltalk.addMethod(
 smalltalk.method({
 selector: 'renderButtonsOn:',
 category: 'rendering',
-fn: function (html){
-var self=this;
-(function($rec){smalltalk.send($rec, "_class_", ["tetris_buttons"]);return smalltalk.send($rec, "_with_", [(function(){(function($rec){smalltalk.send($rec, "_with_", ["New game"]);return smalltalk.send($rec, "_onClick_", [(function(){return smalltalk.send(self, "_startNewGame", []);})]);})(smalltalk.send(html, "_button", []));return (function($rec){smalltalk.send($rec, "_with_", [unescape("play/pause")]);return smalltalk.send($rec, "_onClick_", [(function(){return smalltalk.send(self, "_update", []);})]);})(smalltalk.send(html, "_button", []));})]);})(smalltalk.send(html, "_div", []));
-return self;},
+fn: function (html) {
+    var self = this;
+    (function ($rec) {smalltalk.send($rec, "_class_", ["tetris_buttons"]);return smalltalk.send($rec, "_with_", [function () {(function ($rec) {smalltalk.send($rec, "_with_", ["New game"]);return smalltalk.send($rec, "_onClick_", [function () {return smalltalk.send(self, "_startNewGame", []);}]);}(smalltalk.send(html, "_button", [])));return function ($rec) {smalltalk.send($rec, "_with_", [unescape("play/pause")]);return smalltalk.send($rec, "_onClick_", [function () {return smalltalk.send(self, "_update", []);}]);}(smalltalk.send(html, "_button", []));}]);}(smalltalk.send(html, "_div", [])));
+    return self;
+},
 source: unescape('renderButtonsOn%3A%20html%0A%09html%20div%20%0A%09%09class%3A%20%27tetris_buttons%27%3B%0A%09%09with%3A%20%5B%0A%09%09%09html%20button%0A%09%09%09%09with%3A%20%27New%20game%27%3B%0A%09%09%09%09onClick%3A%20%5Bself%20startNewGame%5D.%0A%09%09%09html%20button%0A%09%09%09%09with%3A%20%27play/pause%27%3B%0A%09%09%09%09onClick%3A%20%5Bself%20update%5D%5D')}),
 smalltalk.Tetris);
 
@@ -101,11 +108,12 @@ smalltalk.addMethod(
 smalltalk.method({
 selector: 'initialize',
 category: 'initialization',
-fn: function (){
-var self=this;
-self.klass.superclass.fn.prototype['_initialize'].apply(self, []);
-smalltalk.send(self, "_newGame", []);
-return self;},
+fn: function () {
+    var self = this;
+    self.klass.superclass.fn.prototype._initialize.apply(self, []);
+    smalltalk.send(self, "_newGame", []);
+    return self;
+},
 source: unescape('initialize%0A%09super%20initialize.%0A%09self%20newGame')}),
 smalltalk.Tetris);
 
@@ -114,12 +122,13 @@ smalltalk.addMethod(
 smalltalk.method({
 selector: 'startNewGame',
 category: 'actions',
-fn: function (){
-var self=this;
-smalltalk.send(self, "_newGame", []);
-smalltalk.send(self['@timer'], "_ifNotNil_", [(function(){return smalltalk.send(self['@timer'], "_clearInterval", []);})]);
-self['@timer']=smalltalk.send((function(){return smalltalk.send(self, "_nextStep", []);}), "_valueWithInterval_", [self['@speed']]);
-return self;},
+fn: function () {
+    var self = this;
+    smalltalk.send(self, "_newGame", []);
+    smalltalk.send(self['@timer'], "_ifNotNil_", [function () {return smalltalk.send(self['@timer'], "_clearInterval", []);}]);
+    self['@timer'] = smalltalk.send(function () {return smalltalk.send(self, "_nextStep", []);}, "_valueWithInterval_", [self['@speed']]);
+    return self;
+},
 source: unescape('startNewGame%0A%09self%20newGame.%0A%09timer%20ifNotNil%3A%20%5Btimer%20clearInterval%5D.%0A%09timer%20%3A%3D%20%5Bself%20nextStep%5D%20valueWithInterval%3A%20speed')}),
 smalltalk.Tetris);
 
@@ -128,10 +137,11 @@ smalltalk.addMethod(
 smalltalk.method({
 selector: 'width',
 category: 'accessing',
-fn: function (){
-var self=this;
-return smalltalk.send(smalltalk.send(self, "_class", []), "_width", []);
-return self;},
+fn: function () {
+    var self = this;
+    return smalltalk.send(smalltalk.send(self, "_class", []), "_width", []);
+    return self;
+},
 source: unescape('width%0A%09%5Eself%20class%20width')}),
 smalltalk.Tetris);
 
@@ -140,10 +150,11 @@ smalltalk.addMethod(
 smalltalk.method({
 selector: 'height',
 category: 'accessing',
-fn: function (){
-var self=this;
-return smalltalk.send(smalltalk.send(self, "_class", []), "_height", []);
-return self;},
+fn: function () {
+    var self = this;
+    return smalltalk.send(smalltalk.send(self, "_class", []), "_height", []);
+    return self;
+},
 source: unescape('height%0A%09%5Eself%20class%20height')}),
 smalltalk.Tetris);
 
@@ -152,12 +163,13 @@ smalltalk.addMethod(
 smalltalk.method({
 selector: 'nextStep',
 category: 'actions',
-fn: function (){
-var self=this;
-smalltalk.send(self['@movingPiece'], "_ifNil_", [(function(){return smalltalk.send(self, "_newPiece", []);})]);
-smalltalk.send(smalltalk.send(self['@movingPiece'], "_canMoveIn_", [self]), "_ifTrue_ifFalse_", [(function(){return smalltalk.send(self['@movingPiece'], "_position_", [smalltalk.send(smalltalk.send(self['@movingPiece'], "_position", []), "__plus", [smalltalk.send((0), "__at", [(1)])])]);}), (function(){return smalltalk.send(self, "_newPiece", []);})]);
-smalltalk.send(self, "_redraw", []);
-return self;},
+fn: function () {
+    var self = this;
+    smalltalk.send(self['@movingPiece'], "_ifNil_", [function () {return smalltalk.send(self, "_newPiece", []);}]);
+    smalltalk.send(smalltalk.send(self['@movingPiece'], "_canMoveIn_", [self]), "_ifTrue_ifFalse_", [function () {return smalltalk.send(self['@movingPiece'], "_position_", [smalltalk.send(smalltalk.send(self['@movingPiece'], "_position", []), "__plus", [smalltalk.send(0, "__at", [1])])]);}, function () {return smalltalk.send(self, "_newPiece", []);}]);
+    smalltalk.send(self, "_redraw", []);
+    return self;
+},
 source: unescape('nextStep%0A%09movingPiece%20ifNil%3A%20%5Bself%20newPiece%5D.%0A%09%28movingPiece%20canMoveIn%3A%20self%29%0A%09%09ifTrue%3A%20%5BmovingPiece%20position%3A%20movingPiece%20position%20+%20%280@1%29%5D%0A%09%09ifFalse%3A%20%5Bself%20newPiece%5D.%0A%09self%20redraw%0A%09')}),
 smalltalk.Tetris);
 
@@ -166,11 +178,12 @@ smalltalk.addMethod(
 smalltalk.method({
 selector: 'redraw',
 category: 'actions',
-fn: function (){
-var self=this;
-smalltalk.send(self['@renderingContext'], "_clearRectFrom_to_", [smalltalk.send((0), "__at", [smalltalk.send(self, "_width", [])]), smalltalk.send((0), "__at", [smalltalk.send(self, "_height", [])])]);
-(function($rec){smalltalk.send($rec, "_drawMap", []);return smalltalk.send($rec, "_drawPiece", []);})(self);
-return self;},
+fn: function () {
+    var self = this;
+    smalltalk.send(self['@renderingContext'], "_clearRectFrom_to_", [smalltalk.send(0, "__at", [smalltalk.send(self, "_width", [])]), smalltalk.send(0, "__at", [smalltalk.send(self, "_height", [])])]);
+    (function ($rec) {smalltalk.send($rec, "_drawMap", []);return smalltalk.send($rec, "_drawPiece", []);}(self));
+    return self;
+},
 source: unescape('redraw%0A%09renderingContext%20clearRectFrom%3A%200@%20self%20width%20to%3A%200@%20self%20height.%0A%09self%20%0A%09%09drawMap%3B%0A%09%09drawPiece')}),
 smalltalk.Tetris);
 
@@ -179,15 +192,14 @@ smalltalk.addMethod(
 smalltalk.method({
 selector: 'drawMap',
 category: 'actions',
-fn: function (){
-var self=this;
-(function($rec){smalltalk.send($rec, "_fillStyle_", [unescape("%23fafafa")]);return smalltalk.send($rec, "_fillRectFrom_to_", [smalltalk.send((0), "__at", [(0)]), smalltalk.send(smalltalk.send(self, "_width", []), "__at", [smalltalk.send(self, "_height", [])])]);})(self['@renderingContext']);
-(function($rec){smalltalk.send($rec, "_lineWidth_", [(0.5)]);return smalltalk.send($rec, "_strokeStyle_", [unescape("%23999")]);})(self['@renderingContext']);
-smalltalk.send((0), "_to_do_", [smalltalk.send(smalltalk.send(smalltalk.send(self, "_class", []), "_squares", []), "_x", []), (function(each){var x=nil;
-x=smalltalk.send(each, "__star", [smalltalk.send(smalltalk.send(self, "_class", []), "_squareSize", [])]);return smalltalk.send(self, "_drawLineFrom_to_", [smalltalk.send(x, "__at", [(0)]), smalltalk.send(x, "__at", [smalltalk.send(self, "_height", [])])]);})]);
-smalltalk.send((0), "_to_do_", [smalltalk.send(smalltalk.send(smalltalk.send(self, "_class", []), "_squares", []), "_y", []), (function(each){var y=nil;
-y=smalltalk.send(each, "__star", [smalltalk.send(smalltalk.send(self, "_class", []), "_squareSize", [])]);return smalltalk.send(self, "_drawLineFrom_to_", [smalltalk.send((0), "__at", [y]), smalltalk.send(smalltalk.send(self, "_width", []), "__at", [y])]);})]);
-return self;},
+fn: function () {
+    var self = this;
+    (function ($rec) {smalltalk.send($rec, "_fillStyle_", [unescape("%23fafafa")]);return smalltalk.send($rec, "_fillRectFrom_to_", [smalltalk.send(0, "__at", [0]), smalltalk.send(smalltalk.send(self, "_width", []), "__at", [smalltalk.send(self, "_height", [])])]);}(self['@renderingContext']));
+    (function ($rec) {smalltalk.send($rec, "_lineWidth_", [0.5]);return smalltalk.send($rec, "_strokeStyle_", [unescape("%23999")]);}(self['@renderingContext']));
+    smalltalk.send(0, "_to_do_", [smalltalk.send(smalltalk.send(smalltalk.send(self, "_class", []), "_squares", []), "_x", []), function (each) {var x = nil;x = smalltalk.send(each, "__star", [smalltalk.send(smalltalk.send(self, "_class", []), "_squareSize", [])]);return smalltalk.send(self, "_drawLineFrom_to_", [smalltalk.send(x, "__at", [0]), smalltalk.send(x, "__at", [smalltalk.send(self, "_height", [])])]);}]);
+    smalltalk.send(0, "_to_do_", [smalltalk.send(smalltalk.send(smalltalk.send(self, "_class", []), "_squares", []), "_y", []), function (each) {var y = nil;y = smalltalk.send(each, "__star", [smalltalk.send(smalltalk.send(self, "_class", []), "_squareSize", [])]);return smalltalk.send(self, "_drawLineFrom_to_", [smalltalk.send(0, "__at", [y]), smalltalk.send(smalltalk.send(self, "_width", []), "__at", [y])]);}]);
+    return self;
+},
 source: unescape('drawMap%0A%09renderingContext%20%0A%09%09fillStyle%3A%20%27%23fafafa%27%3B%0A%09%09fillRectFrom%3A%200@0%20to%3A%20self%20width@self%20height.%0A%09renderingContext%20%0A%09%09lineWidth%3A%200.5%3B%0A%09%09strokeStyle%3A%20%27%23999%27.%0A%090%20to%3A%20self%20class%20squares%20x%20do%3A%20%5B%3Aeach%20%7C%20%7C%20x%20%7C%0A%09%09x%20%3A%3D%20each%20*%20self%20class%20squareSize.%0A%09%09self%20drawLineFrom%3A%20x@0%20to%3A%20x@self%20height%5D.%0A%090%20to%3A%20self%20class%20squares%20y%20do%3A%20%5B%3Aeach%20%7C%20%7C%20y%20%7C%0A%09%09y%20%3A%3D%20each%20*%20self%20class%20squareSize.%0A%09%09self%20drawLineFrom%3A%200@y%20to%3A%20self%20width@y%5D.')}),
 smalltalk.Tetris);
 
@@ -196,10 +208,11 @@ smalltalk.addMethod(
 smalltalk.method({
 selector: 'drawLineFrom:to:',
 category: 'actions',
-fn: function (aPoint, anotherPoint){
-var self=this;
-(function($rec){smalltalk.send($rec, "_beginPath", []);smalltalk.send($rec, "_moveTo_", [aPoint]);smalltalk.send($rec, "_lineTo_", [anotherPoint]);return smalltalk.send($rec, "_stroke", []);})(self['@renderingContext']);
-return self;},
+fn: function (aPoint, anotherPoint) {
+    var self = this;
+    (function ($rec) {smalltalk.send($rec, "_beginPath", []);smalltalk.send($rec, "_moveTo_", [aPoint]);smalltalk.send($rec, "_lineTo_", [anotherPoint]);return smalltalk.send($rec, "_stroke", []);}(self['@renderingContext']));
+    return self;
+},
 source: unescape('drawLineFrom%3A%20aPoint%20to%3A%20anotherPoint%0A%09renderingContext%20%0A%09%09beginPath%3B%0A%09%09moveTo%3A%20aPoint%3B%0A%09%09lineTo%3A%20anotherPoint%3B%0A%09%09stroke')}),
 smalltalk.Tetris);
 
@@ -208,13 +221,14 @@ smalltalk.addMethod(
 smalltalk.method({
 selector: 'newGame',
 category: 'actions',
-fn: function (){
-var self=this;
-self['@rows']=[];
-self['@movingPiece']=nil;
-self['@speed']=(200);
-self['@score']=(0);
-return self;},
+fn: function () {
+    var self = this;
+    self['@rows'] = [];
+    self['@movingPiece'] = nil;
+    self['@speed'] = 200;
+    self['@score'] = 0;
+    return self;
+},
 source: unescape('newGame%0A%09rows%20%3A%3D%20%23%28%29.%0A%09movingPiece%20%3A%3D%20nil.%0A%09speed%20%3A%3D%20200.%0A%09score%20%3A%3D%200')}),
 smalltalk.Tetris);
 
@@ -223,10 +237,11 @@ smalltalk.addMethod(
 smalltalk.method({
 selector: 'newPiece',
 category: 'actions',
-fn: function (){
-var self=this;
-self['@movingPiece']=smalltalk.send(smalltalk.TetrisPiece, "_atRandom", []);
-return self;},
+fn: function () {
+    var self = this;
+    self['@movingPiece'] = smalltalk.send(smalltalk.TetrisPiece, "_atRandom", []);
+    return self;
+},
 source: unescape('newPiece%0A%09movingPiece%20%3A%3D%20TetrisPiece%20atRandom')}),
 smalltalk.Tetris);
 
@@ -235,10 +250,11 @@ smalltalk.addMethod(
 smalltalk.method({
 selector: 'squares',
 category: 'accessing',
-fn: function (){
-var self=this;
-return smalltalk.send(smalltalk.send(self, "_class", []), "_squares", []);
-return self;},
+fn: function () {
+    var self = this;
+    return smalltalk.send(smalltalk.send(self, "_class", []), "_squares", []);
+    return self;
+},
 source: unescape('squares%0A%09%5Eself%20class%20squares')}),
 smalltalk.Tetris);
 
@@ -247,10 +263,11 @@ smalltalk.addMethod(
 smalltalk.method({
 selector: 'gluePiece:',
 category: 'accessing',
-fn: function (aPiece){
-var self=this;
-smalltalk.send(aPiece, "_glueOn_", [self]);
-return self;},
+fn: function (aPiece) {
+    var self = this;
+    smalltalk.send(aPiece, "_glueOn_", [self]);
+    return self;
+},
 source: unescape('gluePiece%3A%20aPiece%0A%09aPiece%20glueOn%3A%20self%0A%09')}),
 smalltalk.Tetris);
 
@@ -259,11 +276,12 @@ smalltalk.addMethod(
 smalltalk.method({
 selector: 'drawRows',
 category: 'actions',
-fn: function (){
-var self=this;
-smalltalk.send(smalltalk.send(self, "_rows", []), "_do_", [(function(each){return nil;})]);
-smalltalk.send(self['@movingPiece'], "_ifNotNil_", [(function(){return smalltalk.send(self['@movingPiece'], "_drawOn_", [self['@renderingContext']]);})]);
-return self;},
+fn: function () {
+    var self = this;
+    smalltalk.send(smalltalk.send(self, "_rows", []), "_do_", [function (each) {return nil;}]);
+    smalltalk.send(self['@movingPiece'], "_ifNotNil_", [function () {return smalltalk.send(self['@movingPiece'], "_drawOn_", [self['@renderingContext']]);}]);
+    return self;
+},
 source: unescape('drawRows%0A%09self%20rows%20do%3A%20%5B%3Aeach%20%7C%5D.%0A%09movingPiece%20ifNotNil%3A%20%5BmovingPiece%20drawOn%3A%20renderingContext%5D')}),
 smalltalk.Tetris);
 
@@ -272,10 +290,11 @@ smalltalk.addMethod(
 smalltalk.method({
 selector: 'drawPiece',
 category: 'actions',
-fn: function (){
-var self=this;
-smalltalk.send(self['@movingPiece'], "_ifNotNil_", [(function(){return smalltalk.send(self['@movingPiece'], "_drawOn_", [self['@renderingContext']]);})]);
-return self;},
+fn: function () {
+    var self = this;
+    smalltalk.send(self['@movingPiece'], "_ifNotNil_", [function () {return smalltalk.send(self['@movingPiece'], "_drawOn_", [self['@renderingContext']]);}]);
+    return self;
+},
 source: unescape('drawPiece%0A%09movingPiece%20ifNotNil%3A%20%5B%0A%09%09movingPiece%20drawOn%3A%20renderingContext%5D')}),
 smalltalk.Tetris);
 
@@ -284,10 +303,11 @@ smalltalk.addMethod(
 smalltalk.method({
 selector: 'rows',
 category: 'accessing',
-fn: function (){
-var self=this;
-return self['@rows'];
-return self;},
+fn: function () {
+    var self = this;
+    return self['@rows'];
+    return self;
+},
 source: unescape('rows%0A%09%22An%20array%20of%20rows.%20Each%20row%20is%20a%20collection%20of%20points.%22%0A%09%5Erows')}),
 smalltalk.Tetris);
 
@@ -296,10 +316,11 @@ smalltalk.addMethod(
 smalltalk.method({
 selector: 'addRow:',
 category: 'accessing',
-fn: function (aCollection){
-var self=this;
-smalltalk.send(smalltalk.send(self, "_rows", []), "_add_", [aCollection]);
-return self;},
+fn: function (aCollection) {
+    var self = this;
+    smalltalk.send(smalltalk.send(self, "_rows", []), "_add_", [aCollection]);
+    return self;
+},
 source: unescape('addRow%3A%20aCollection%0A%09self%20rows%20add%3A%20aCollection')}),
 smalltalk.Tetris);
 
@@ -309,10 +330,11 @@ smalltalk.addMethod(
 smalltalk.method({
 selector: 'squareSize',
 category: 'accessing',
-fn: function (){
-var self=this;
-return (22);
-return self;},
+fn: function () {
+    var self = this;
+    return 22;
+    return self;
+},
 source: unescape('squareSize%0A%09%5E22')}),
 smalltalk.Tetris.klass);
 
@@ -321,10 +343,11 @@ smalltalk.addMethod(
 smalltalk.method({
 selector: 'width',
 category: 'accessing',
-fn: function (){
-var self=this;
-return smalltalk.send(smalltalk.send(self, "_squareSize", []), "__star", [smalltalk.send(smalltalk.send(self, "_squares", []), "_x", [])]);
-return self;},
+fn: function () {
+    var self = this;
+    return smalltalk.send(smalltalk.send(self, "_squareSize", []), "__star", [smalltalk.send(smalltalk.send(self, "_squares", []), "_x", [])]);
+    return self;
+},
 source: unescape('width%0A%09%5Eself%20squareSize%20*%20%28self%20squares%20x%29')}),
 smalltalk.Tetris.klass);
 
@@ -333,10 +356,11 @@ smalltalk.addMethod(
 smalltalk.method({
 selector: 'height',
 category: 'accessing',
-fn: function (){
-var self=this;
-return smalltalk.send(smalltalk.send(self, "_squareSize", []), "__star", [smalltalk.send(smalltalk.send(self, "_squares", []), "_y", [])]);
-return self;},
+fn: function () {
+    var self = this;
+    return smalltalk.send(smalltalk.send(self, "_squareSize", []), "__star", [smalltalk.send(smalltalk.send(self, "_squares", []), "_y", [])]);
+    return self;
+},
 source: unescape('height%0A%09%5Eself%20squareSize%20*%20%28self%20squares%20y%29')}),
 smalltalk.Tetris.klass);
 
@@ -345,10 +369,11 @@ smalltalk.addMethod(
 smalltalk.method({
 selector: 'squares',
 category: 'accessing',
-fn: function (){
-var self=this;
-return smalltalk.send((10), "__at", [(15)]);
-return self;},
+fn: function () {
+    var self = this;
+    return smalltalk.send(10, "__at", [15]);
+    return self;
+},
 source: unescape('squares%0A%09%5E10@15')}),
 smalltalk.Tetris.klass);
 
@@ -359,11 +384,12 @@ smalltalk.addMethod(
 smalltalk.method({
 selector: 'drawOn:',
 category: 'drawing',
-fn: function (aRenderingContext){
-var self=this;
-smalltalk.send(aRenderingContext, "_fillStyle_", [smalltalk.send(self, "_color", [])]);
-smalltalk.send(smalltalk.send(self, "_bounds", []), "_do_", [(function(each){return (function($rec){smalltalk.send($rec, "_fillRectFrom_to_", [smalltalk.send(smalltalk.send(each, "__plus", [smalltalk.send(self, "_position", [])]), "__star", [smalltalk.send(smalltalk.Tetris, "_squareSize", [])]), smalltalk.send(smalltalk.send((1), "__at", [(1)]), "__star", [smalltalk.send(smalltalk.Tetris, "_squareSize", [])])]);smalltalk.send($rec, "_strokeStyle_", [unescape("%23999")]);smalltalk.send($rec, "_lineWidth_", [(2)]);return smalltalk.send($rec, "_strokeRectFrom_to_", [smalltalk.send(smalltalk.send(each, "__plus", [smalltalk.send(self, "_position", [])]), "__star", [smalltalk.send(smalltalk.Tetris, "_squareSize", [])]), smalltalk.send(smalltalk.send((1), "__at", [(1)]), "__star", [smalltalk.send(smalltalk.Tetris, "_squareSize", [])])]);})(aRenderingContext);})]);
-return self;},
+fn: function (aRenderingContext) {
+    var self = this;
+    smalltalk.send(aRenderingContext, "_fillStyle_", [smalltalk.send(self, "_color", [])]);
+    smalltalk.send(smalltalk.send(self, "_bounds", []), "_do_", [function (each) {return function ($rec) {smalltalk.send($rec, "_fillRectFrom_to_", [smalltalk.send(smalltalk.send(each, "__plus", [smalltalk.send(self, "_position", [])]), "__star", [smalltalk.send(smalltalk.Tetris, "_squareSize", [])]), smalltalk.send(smalltalk.send(1, "__at", [1]), "__star", [smalltalk.send(smalltalk.Tetris, "_squareSize", [])])]);smalltalk.send($rec, "_strokeStyle_", [unescape("%23999")]);smalltalk.send($rec, "_lineWidth_", [2]);return smalltalk.send($rec, "_strokeRectFrom_to_", [smalltalk.send(smalltalk.send(each, "__plus", [smalltalk.send(self, "_position", [])]), "__star", [smalltalk.send(smalltalk.Tetris, "_squareSize", [])]), smalltalk.send(smalltalk.send(1, "__at", [1]), "__star", [smalltalk.send(smalltalk.Tetris, "_squareSize", [])])]);}(aRenderingContext);}]);
+    return self;
+},
 source: unescape('drawOn%3A%20aRenderingContext%0A%09aRenderingContext%20fillStyle%3A%20self%20color.%0A%09self%20bounds%20do%3A%20%5B%3Aeach%20%7C%0A%09%09aRenderingContext%20%0A%09%09%09fillRectFrom%3A%20each%20+%20self%20position*%20Tetris%20squareSize%20to%3A%201@1%20*%20Tetris%20squareSize%3B%0A%09%09%09strokeStyle%3A%20%27%23999%27%3B%0A%09%09%09lineWidth%3A%202%3B%0A%09%09%09strokeRectFrom%3A%20each%20+%20self%20position*%20Tetris%20squareSize%20to%3A%201@1%20*%20Tetris%20squareSize%5D')}),
 smalltalk.TetrisPiece);
 
@@ -372,10 +398,11 @@ smalltalk.addMethod(
 smalltalk.method({
 selector: 'rotation',
 category: 'accessing',
-fn: function (){
-var self=this;
-return smalltalk.send(self['@rotation'], "_ifNil_", [(function(){return self['@rotation']=(1);})]);
-return self;},
+fn: function () {
+    var self = this;
+    return smalltalk.send(self['@rotation'], "_ifNil_", [function () {return self['@rotation'] = 1;}]);
+    return self;
+},
 source: unescape('rotation%0A%09%5Erotation%20ifNil%3A%20%5Brotation%20%3A%3D%201%5D')}),
 smalltalk.TetrisPiece);
 
@@ -384,10 +411,11 @@ smalltalk.addMethod(
 smalltalk.method({
 selector: 'rotation:',
 category: 'accessing',
-fn: function (aNumber){
-var self=this;
-self['@rotation']=aNumber;
-return self;},
+fn: function (aNumber) {
+    var self = this;
+    self['@rotation'] = aNumber;
+    return self;
+},
 source: unescape('rotation%3A%20aNumber%0A%09rotation%20%3A%3D%20aNumber')}),
 smalltalk.TetrisPiece);
 
@@ -396,10 +424,11 @@ smalltalk.addMethod(
 smalltalk.method({
 selector: 'position',
 category: 'accessing',
-fn: function (){
-var self=this;
-return smalltalk.send(self['@position'], "_ifNil_", [(function(){return smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.Tetris, "_squares", []), "_x", []), "__slash", [(2)]), "__minus", [(1)]), "__at", [(0)]);})]);
-return self;},
+fn: function () {
+    var self = this;
+    return smalltalk.send(self['@position'], "_ifNil_", [function () {return smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.Tetris, "_squares", []), "_x", []), "__slash", [2]), "__minus", [1]), "__at", [0]);}]);
+    return self;
+},
 source: unescape('position%0A%09%5Eposition%20ifNil%3A%20%5B%28Tetris%20squares%20x%20/%202%29%20-1%20@%200%5D')}),
 smalltalk.TetrisPiece);
 
@@ -408,10 +437,11 @@ smalltalk.addMethod(
 smalltalk.method({
 selector: 'position:',
 category: 'accessing',
-fn: function (aPoint){
-var self=this;
-return self['@position']=aPoint;
-return self;},
+fn: function (aPoint) {
+    var self = this;
+    return self['@position'] = aPoint;
+    return self;
+},
 source: unescape('position%3A%20aPoint%0A%09%5Eposition%20%3A%3D%20aPoint')}),
 smalltalk.TetrisPiece);
 
@@ -420,10 +450,11 @@ smalltalk.addMethod(
 smalltalk.method({
 selector: 'bounds',
 category: 'accessing',
-fn: function (){
-var self=this;
-smalltalk.send(self, "_subclassResponsibility", []);
-return self;},
+fn: function () {
+    var self = this;
+    smalltalk.send(self, "_subclassResponsibility", []);
+    return self;
+},
 source: unescape('bounds%0A%09self%20subclassResponsibility')}),
 smalltalk.TetrisPiece);
 
@@ -432,10 +463,11 @@ smalltalk.addMethod(
 smalltalk.method({
 selector: 'color',
 category: 'accessing',
-fn: function (){
-var self=this;
-return unescape("%23afa");
-return self;},
+fn: function () {
+    var self = this;
+    return unescape("%23afa");
+    return self;
+},
 source: unescape('color%0A%09%5E%27%23afa%27')}),
 smalltalk.TetrisPiece);
 
@@ -444,10 +476,11 @@ smalltalk.addMethod(
 smalltalk.method({
 selector: 'canMove',
 category: 'testing',
-fn: function (){
-var self=this;
-return smalltalk.send(smalltalk.send(smalltalk.send(self, "_position", []), "_y", []), "__lt", [smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.Tetris, "_squares", []), "_y", []), "__minus", [smalltalk.send(self, "_height", [])])]);
-return self;},
+fn: function () {
+    var self = this;
+    return smalltalk.send(smalltalk.send(smalltalk.send(self, "_position", []), "_y", []), "__lt", [smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.Tetris, "_squares", []), "_y", []), "__minus", [smalltalk.send(self, "_height", [])])]);
+    return self;
+},
 source: unescape('canMove%0A%09%5Eself%20position%20y%20%3C%20%28Tetris%20squares%20y%20-%20self%20height%29')}),
 smalltalk.TetrisPiece);
 
@@ -456,10 +489,11 @@ smalltalk.addMethod(
 smalltalk.method({
 selector: 'height',
 category: 'accessing',
-fn: function (){
-var self=this;
-return (2);
-return self;},
+fn: function () {
+    var self = this;
+    return 2;
+    return self;
+},
 source: unescape('height%0A%09%5E2')}),
 smalltalk.TetrisPiece);
 
@@ -468,10 +502,11 @@ smalltalk.addMethod(
 smalltalk.method({
 selector: 'canMoveIn:',
 category: 'testing',
-fn: function (aTetris){
-var self=this;
-return smalltalk.send(smalltalk.send(smalltalk.send(self, "_position", []), "_y", []), "__lt", [smalltalk.send(smalltalk.send(smalltalk.send(aTetris, "_squares", []), "_y", []), "__minus", [smalltalk.send(self, "_height", [])])]);
-return self;},
+fn: function (aTetris) {
+    var self = this;
+    return smalltalk.send(smalltalk.send(smalltalk.send(self, "_position", []), "_y", []), "__lt", [smalltalk.send(smalltalk.send(smalltalk.send(aTetris, "_squares", []), "_y", []), "__minus", [smalltalk.send(self, "_height", [])])]);
+    return self;
+},
 source: unescape('canMoveIn%3A%20aTetris%0A%09%5Eself%20position%20y%20%3C%20%28aTetris%20squares%20y%20-%20self%20height%29')}),
 smalltalk.TetrisPiece);
 
@@ -481,10 +516,11 @@ smalltalk.addMethod(
 smalltalk.method({
 selector: 'atRandom',
 category: 'instance creation',
-fn: function (){
-var self=this;
-return smalltalk.send(smalltalk.send(smalltalk.send(self, "_subclasses", []), "_at_", [smalltalk.send(smalltalk.send(smalltalk.send(self, "_subclasses", []), "_size", []), "_atRandom", [])]), "_new", []);
-return self;},
+fn: function () {
+    var self = this;
+    return smalltalk.send(smalltalk.send(smalltalk.send(self, "_subclasses", []), "_at_", [smalltalk.send(smalltalk.send(smalltalk.send(self, "_subclasses", []), "_size", []), "_atRandom", [])]), "_new", []);
+    return self;
+},
 source: unescape('atRandom%0A%09%5E%28self%20subclasses%20at%3A%20self%20subclasses%20size%20atRandom%29%20new')}),
 smalltalk.TetrisPiece.klass);
 
@@ -495,10 +531,11 @@ smalltalk.addMethod(
 smalltalk.method({
 selector: 'bounds',
 category: 'accessing',
-fn: function (){
-var self=this;
-return (function($rec){smalltalk.send($rec, "_add_", [smalltalk.send((0), "__at", [(0)])]);smalltalk.send($rec, "_add_", [smalltalk.send((0), "__at", [(1)])]);smalltalk.send($rec, "_add_", [smalltalk.send((1), "__at", [(0)])]);smalltalk.send($rec, "_add_", [smalltalk.send((1), "__at", [(1)])]);return smalltalk.send($rec, "_yourself", []);})(smalltalk.send(smalltalk.Array, "_new", []));
-return self;},
+fn: function () {
+    var self = this;
+    return function ($rec) {smalltalk.send($rec, "_add_", [smalltalk.send(0, "__at", [0])]);smalltalk.send($rec, "_add_", [smalltalk.send(0, "__at", [1])]);smalltalk.send($rec, "_add_", [smalltalk.send(1, "__at", [0])]);smalltalk.send($rec, "_add_", [smalltalk.send(1, "__at", [1])]);return smalltalk.send($rec, "_yourself", []);}(smalltalk.send(smalltalk.Array, "_new", []));
+    return self;
+},
 source: unescape('bounds%0A%09%5EArray%20new%0A%09%09add%3A%200@0%3B%0A%09%09add%3A%200@1%3B%0A%09%09add%3A%201@0%3B%0A%09%09add%3A%201@1%3B%0A%09%09yourself')}),
 smalltalk.TetrisPieceO);
 
@@ -510,10 +547,11 @@ smalltalk.addMethod(
 smalltalk.method({
 selector: 'bounds',
 category: 'accessing',
-fn: function (){
-var self=this;
-return (function($rec){smalltalk.send($rec, "_add_", [smalltalk.send((0), "__at", [(0)])]);smalltalk.send($rec, "_add_", [smalltalk.send((0), "__at", [(1)])]);smalltalk.send($rec, "_add_", [smalltalk.send((0), "__at", [(2)])]);smalltalk.send($rec, "_add_", [smalltalk.send((1), "__at", [(2)])]);return smalltalk.send($rec, "_yourself", []);})(smalltalk.send(smalltalk.Array, "_new", []));
-return self;},
+fn: function () {
+    var self = this;
+    return function ($rec) {smalltalk.send($rec, "_add_", [smalltalk.send(0, "__at", [0])]);smalltalk.send($rec, "_add_", [smalltalk.send(0, "__at", [1])]);smalltalk.send($rec, "_add_", [smalltalk.send(0, "__at", [2])]);smalltalk.send($rec, "_add_", [smalltalk.send(1, "__at", [2])]);return smalltalk.send($rec, "_yourself", []);}(smalltalk.send(smalltalk.Array, "_new", []));
+    return self;
+},
 source: unescape('bounds%0A%09%5EArray%20new%0A%09%09add%3A%200@0%3B%0A%09%09add%3A%200@1%3B%0A%09%09add%3A%200@2%3B%0A%09%09add%3A%201@2%3B%0A%09%09yourself')}),
 smalltalk.TetrisPieceL);
 
@@ -522,10 +560,11 @@ smalltalk.addMethod(
 smalltalk.method({
 selector: 'color',
 category: 'accessing',
-fn: function (){
-var self=this;
-return unescape("%23ffa");
-return self;},
+fn: function () {
+    var self = this;
+    return unescape("%23ffa");
+    return self;
+},
 source: unescape('color%0A%09%5E%27%23ffa%27')}),
 smalltalk.TetrisPieceL);
 
@@ -534,10 +573,11 @@ smalltalk.addMethod(
 smalltalk.method({
 selector: 'height',
 category: 'accessing',
-fn: function (){
-var self=this;
-return (3);
-return self;},
+fn: function () {
+    var self = this;
+    return 3;
+    return self;
+},
 source: unescape('height%0A%09%5E3')}),
 smalltalk.TetrisPieceL);
 
@@ -549,10 +589,11 @@ smalltalk.addMethod(
 smalltalk.method({
 selector: 'color',
 category: 'accessing',
-fn: function (){
-var self=this;
-return unescape("%23aaf");
-return self;},
+fn: function () {
+    var self = this;
+    return unescape("%23aaf");
+    return self;
+},
 source: unescape('color%0A%09%5E%27%23aaf%27')}),
 smalltalk.TetrisPieceJ);
 
@@ -561,10 +602,11 @@ smalltalk.addMethod(
 smalltalk.method({
 selector: 'bounds',
 category: 'accessing',
-fn: function (){
-var self=this;
-return (function($rec){smalltalk.send($rec, "_add_", [smalltalk.send((1), "__at", [(0)])]);smalltalk.send($rec, "_add_", [smalltalk.send((1), "__at", [(1)])]);smalltalk.send($rec, "_add_", [smalltalk.send((1), "__at", [(2)])]);smalltalk.send($rec, "_add_", [smalltalk.send((0), "__at", [(2)])]);return smalltalk.send($rec, "_yourself", []);})(smalltalk.send(smalltalk.Array, "_new", []));
-return self;},
+fn: function () {
+    var self = this;
+    return function ($rec) {smalltalk.send($rec, "_add_", [smalltalk.send(1, "__at", [0])]);smalltalk.send($rec, "_add_", [smalltalk.send(1, "__at", [1])]);smalltalk.send($rec, "_add_", [smalltalk.send(1, "__at", [2])]);smalltalk.send($rec, "_add_", [smalltalk.send(0, "__at", [2])]);return smalltalk.send($rec, "_yourself", []);}(smalltalk.send(smalltalk.Array, "_new", []));
+    return self;
+},
 source: unescape('bounds%0A%09%5EArray%20new%0A%09%09add%3A%201@0%3B%0A%09%09add%3A%201@1%3B%0A%09%09add%3A%201@2%3B%0A%09%09add%3A%200@2%3B%0A%09%09yourself')}),
 smalltalk.TetrisPieceJ);
 
@@ -573,10 +615,11 @@ smalltalk.addMethod(
 smalltalk.method({
 selector: 'height',
 category: 'accessing',
-fn: function (){
-var self=this;
-return (3);
-return self;},
+fn: function () {
+    var self = this;
+    return 3;
+    return self;
+},
 source: unescape('height%0A%09%5E3')}),
 smalltalk.TetrisPieceJ);
 
@@ -588,10 +631,11 @@ smalltalk.addMethod(
 smalltalk.method({
 selector: 'color',
 category: 'accessing',
-fn: function (){
-var self=this;
-return unescape("%23faa");
-return self;},
+fn: function () {
+    var self = this;
+    return unescape("%23faa");
+    return self;
+},
 source: unescape('color%0A%09%5E%27%23faa%27')}),
 smalltalk.TetrisPieceI);
 
@@ -600,10 +644,11 @@ smalltalk.addMethod(
 smalltalk.method({
 selector: 'bounds',
 category: 'accessing',
-fn: function (){
-var self=this;
-return (function($rec){smalltalk.send($rec, "_add_", [smalltalk.send((0), "__at", [(0)])]);smalltalk.send($rec, "_add_", [smalltalk.send((0), "__at", [(1)])]);smalltalk.send($rec, "_add_", [smalltalk.send((0), "__at", [(2)])]);smalltalk.send($rec, "_add_", [smalltalk.send((0), "__at", [(3)])]);return smalltalk.send($rec, "_yourself", []);})(smalltalk.send(smalltalk.Array, "_new", []));
-return self;},
+fn: function () {
+    var self = this;
+    return function ($rec) {smalltalk.send($rec, "_add_", [smalltalk.send(0, "__at", [0])]);smalltalk.send($rec, "_add_", [smalltalk.send(0, "__at", [1])]);smalltalk.send($rec, "_add_", [smalltalk.send(0, "__at", [2])]);smalltalk.send($rec, "_add_", [smalltalk.send(0, "__at", [3])]);return smalltalk.send($rec, "_yourself", []);}(smalltalk.send(smalltalk.Array, "_new", []));
+    return self;
+},
 source: unescape('bounds%0A%09%5EArray%20new%0A%09%09add%3A%200@0%3B%0A%09%09add%3A%200@1%3B%0A%09%09add%3A%200@2%3B%0A%09%09add%3A%200@3%3B%0A%09%09yourself')}),
 smalltalk.TetrisPieceI);
 
@@ -612,10 +657,11 @@ smalltalk.addMethod(
 smalltalk.method({
 selector: 'height',
 category: 'accessing',
-fn: function (){
-var self=this;
-return (4);
-return self;},
+fn: function () {
+    var self = this;
+    return 4;
+    return self;
+},
 source: unescape('height%0A%09%5E4')}),
 smalltalk.TetrisPieceI);
 
@@ -627,10 +673,11 @@ smalltalk.addMethod(
 smalltalk.method({
 selector: 'bounds',
 category: 'accessing',
-fn: function (){
-var self=this;
-return (function($rec){smalltalk.send($rec, "_add_", [smalltalk.send((0), "__at", [(0)])]);smalltalk.send($rec, "_add_", [smalltalk.send((1), "__at", [(0)])]);smalltalk.send($rec, "_add_", [smalltalk.send((2), "__at", [(0)])]);smalltalk.send($rec, "_add_", [smalltalk.send((1), "__at", [(1)])]);return smalltalk.send($rec, "_yourself", []);})(smalltalk.send(smalltalk.Array, "_new", []));
-return self;},
+fn: function () {
+    var self = this;
+    return function ($rec) {smalltalk.send($rec, "_add_", [smalltalk.send(0, "__at", [0])]);smalltalk.send($rec, "_add_", [smalltalk.send(1, "__at", [0])]);smalltalk.send($rec, "_add_", [smalltalk.send(2, "__at", [0])]);smalltalk.send($rec, "_add_", [smalltalk.send(1, "__at", [1])]);return smalltalk.send($rec, "_yourself", []);}(smalltalk.send(smalltalk.Array, "_new", []));
+    return self;
+},
 source: unescape('bounds%0A%09%5EArray%20new%0A%09%09add%3A%200@0%3B%0A%09%09add%3A%201@0%3B%0A%09%09add%3A%202@0%3B%0A%09%09add%3A%201@1%3B%0A%09%09yourself')}),
 smalltalk.TetrisPieceT);
 
@@ -639,10 +686,11 @@ smalltalk.addMethod(
 smalltalk.method({
 selector: 'color',
 category: 'accessing',
-fn: function (){
-var self=this;
-return unescape("%23aaf");
-return self;},
+fn: function () {
+    var self = this;
+    return unescape("%23aaf");
+    return self;
+},
 source: unescape('color%0A%09%5E%27%23aaf%27')}),
 smalltalk.TetrisPieceT);
 

+ 422 - 260
js/Kernel.js

@@ -612,6 +612,35 @@ fn: function (aMessage) {
 source: unescape('doesNotUnderstand%3A%20aMessage%0A%09MessageNotUnderstood%20new%0A%09%09receiver%3A%20self%3B%0A%09%09message%3A%20aMessage%3B%0A%09%09signal')}),
 smalltalk.Object);
 
+smalltalk.addMethod(
+'_asJSON',
+smalltalk.method({
+selector: 'asJSON',
+category: 'converting',
+fn: function () {
+    var self = this;
+    return JSON.stringify(self._asJSONObject());
+    return self;
+},
+source: unescape('asJSON%0A%09%7B%27return%20JSON.stringify%28self._asJSONObject%28%29%29%27%7D')}),
+smalltalk.Object);
+
+smalltalk.addMethod(
+'_asJSONObject',
+smalltalk.method({
+selector: 'asJSONObject',
+category: 'converting',
+fn: function () {
+    var self = this;
+    var object = nil;
+    object = smalltalk.send(smalltalk.Object, "_new", []);
+    smalltalk.send(smalltalk.send(smalltalk.send(self, "_class", []), "_instanceVariableNames", []), "_do_", [function (each) {return smalltalk.send(object, "_basicAt_put_", [each, smalltalk.send(smalltalk.send(self, "_instVarAt_", [each]), "_asJSONObject", [])]);}]);
+    return object;
+    return self;
+},
+source: unescape('asJSONObject%0A%09%7C%20object%20%7C%0A%09object%20%3A%3D%20Object%20new.%0A%09self%20class%20instanceVariableNames%20do%3A%20%5B%3Aeach%20%7C%0A%09%09object%20basicAt%3A%20each%20put%3A%20%28self%20instVarAt%3A%20each%29%20asJSONObject%5D.%0A%09%5Eobject')}),
+smalltalk.Object);
+
 
 
 smalltalk.addClass('Smalltalk', smalltalk.Object, [], 'Kernel');
@@ -628,6 +657,32 @@ fn: function () {
 source: unescape('classes%0A%09%7B%27return%20self.classes%28%29%27%7D')}),
 smalltalk.Smalltalk);
 
+smalltalk.addMethod(
+'_debugMode',
+smalltalk.method({
+selector: 'debugMode',
+category: 'accessing',
+fn: function () {
+    var self = this;
+    return self.debugMode;
+    return self;
+},
+source: unescape('debugMode%0A%09%7B%27return%20self.debugMode%27%7D')}),
+smalltalk.Smalltalk);
+
+smalltalk.addMethod(
+'_debugMode_',
+smalltalk.method({
+selector: 'debugMode:',
+category: 'accessing',
+fn: function (aBoolean) {
+    var self = this;
+    self.debugMode = aBoolean;
+    return self;
+},
+source: unescape('debugMode%3A%20aBoolean%0A%09%7B%27self.debugMode%20%3D%20aBoolean%27%7D')}),
+smalltalk.Smalltalk);
+
 
 smalltalk.Smalltalk.klass.iVarNames = ['current'];
 smalltalk.addMethod(
@@ -1452,6 +1507,19 @@ fn: function () {
 source: unescape('clearInterval%0A%09%7B%27clearInterval%28Number%28self%29%29%27%7D')}),
 smalltalk.Number);
 
+smalltalk.addMethod(
+'_asJSONObject',
+smalltalk.method({
+selector: 'asJSONObject',
+category: 'converting',
+fn: function () {
+    var self = this;
+    return self;
+    return self;
+},
+source: unescape('asJSONObject%0A%09%5Eself')}),
+smalltalk.Number);
+
 
 smalltalk.addMethod(
 '_pi',
@@ -1644,6 +1712,29 @@ fn: function (aNumber) {
 source: unescape('valueWithInterval%3A%20aNumber%0A%09%7B%27return%20setInterval%28self%2C%20aNumber%29%27%7D')}),
 smalltalk.BlockClosure);
 
+smalltalk.addMethod(
+'_ensure_',
+smalltalk.method({
+selector: 'ensure:',
+category: 'error handling',
+fn: function (aBlock) {
+    var self = this;
+    var success = true;
+    try {
+        self();
+    } catch (e) {
+        success = false;
+        aBlock();
+        throw e;
+    }
+    if (success) {
+        aBlock();
+    }
+    return self;
+},
+source: unescape('ensure%3A%20aBlock%0A%09%7B%27var%20success%20%3D%20true%3B%0A%09try%7Bself%28%29%7D%20catch%28e%29%20%7B%0A%09%09success%20%3D%20false%3B%0A%09%09aBlock%28%29%3B%0A%09%09throw%28e%29%3B%0A%09%7D%0A%09if%28success%29%20%7BaBlock%28%29%7D%27%7D%0A')}),
+smalltalk.BlockClosure);
+
 
 
 smalltalk.addClass('Boolean', smalltalk.Object, [], 'Kernel');
@@ -2250,6 +2341,19 @@ fn: function (aDate) {
 source: unescape('+%20aDate%0A%09%7B%27return%20self%20+%20aDate%27%7D')}),
 smalltalk.Date);
 
+smalltalk.addMethod(
+'_asJSONObject',
+smalltalk.method({
+selector: 'asJSONObject',
+category: 'converting',
+fn: function () {
+    var self = this;
+    return self;
+    return self;
+},
+source: unescape('asJSONObject%0A%09%5Eself')}),
+smalltalk.Date);
+
 
 smalltalk.addMethod(
 '_new_',
@@ -2519,110 +2623,6 @@ fn: function () {
 source: unescape('size%0A%09self%20subclassResponsibility%0A')}),
 smalltalk.Collection);
 
-smalltalk.addMethod(
-'_at_',
-smalltalk.method({
-selector: 'at:',
-category: 'accessing',
-fn: function (anIndex) {
-    var self = this;
-    return smalltalk.send(self, "_at_ifAbsent_", [anIndex, function () {return smalltalk.send(self, "_errorNotFound", []);}]);
-    return self;
-},
-source: unescape('at%3A%20anIndex%0A%09%5Eself%20at%3A%20anIndex%20ifAbsent%3A%20%5B%0A%09%20%20%20%20self%20errorNotFound%5D%0A')}),
-smalltalk.Collection);
-
-smalltalk.addMethod(
-'_at_put_',
-smalltalk.method({
-selector: 'at:put:',
-category: 'accessing',
-fn: function (anIndex, anObject) {
-    var self = this;
-    smalltalk.send(self, "_subclassResponsibility", []);
-    return self;
-},
-source: unescape('at%3A%20anIndex%20put%3A%20anObject%0A%09self%20subclassResponsibility%0A')}),
-smalltalk.Collection);
-
-smalltalk.addMethod(
-'_at_ifAbsent_',
-smalltalk.method({
-selector: 'at:ifAbsent:',
-category: 'accessing',
-fn: function (anIndex, aBlock) {
-    var self = this;
-    smalltalk.send(self, "_subclassResponsibility", []);
-    return self;
-},
-source: unescape('at%3A%20anIndex%20ifAbsent%3A%20aBlock%0A%09self%20subclassResponsibility%0A')}),
-smalltalk.Collection);
-
-smalltalk.addMethod(
-'_first',
-smalltalk.method({
-selector: 'first',
-category: 'accessing',
-fn: function () {
-    var self = this;
-    return smalltalk.send(self, "_at_", [1]);
-    return self;
-},
-source: unescape('first%0A%09%5Eself%20at%3A%201%0A')}),
-smalltalk.Collection);
-
-smalltalk.addMethod(
-'_second',
-smalltalk.method({
-selector: 'second',
-category: 'accessing',
-fn: function () {
-    var self = this;
-    return smalltalk.send(self, "_at_", [2]);
-    return self;
-},
-source: unescape('second%0A%09%5Eself%20at%3A%202%0A')}),
-smalltalk.Collection);
-
-smalltalk.addMethod(
-'_third',
-smalltalk.method({
-selector: 'third',
-category: 'accessing',
-fn: function () {
-    var self = this;
-    return smalltalk.send(self, "_at_", [3]);
-    return self;
-},
-source: unescape('third%0A%09%5Eself%20at%3A%203%0A')}),
-smalltalk.Collection);
-
-smalltalk.addMethod(
-'_fourth',
-smalltalk.method({
-selector: 'fourth',
-category: 'accessing',
-fn: function () {
-    var self = this;
-    return smalltalk.send(self, "_at_", [4]);
-    return self;
-},
-source: unescape('fourth%0A%09%5Eself%20at%3A%204%0A')}),
-smalltalk.Collection);
-
-smalltalk.addMethod(
-'_last',
-smalltalk.method({
-selector: 'last',
-category: 'accessing',
-fn: function () {
-    var self = this;
-    return smalltalk.send(self, "_at_", [smalltalk.send(self, "_size", [])]);
-    return self;
-},
-source: unescape('last%0A%09%5Eself%20at%3A%20self%20size%0A')}),
-smalltalk.Collection);
-
 smalltalk.addMethod(
 '_readStream',
 smalltalk.method({
@@ -2715,19 +2715,6 @@ fn: function (aCollection) {
 source: unescape('%2C%20aCollection%0A%09%5Eself%20copy%20%0A%09%20%20%20%20addAll%3A%20aCollection%3B%20%0A%09%20%20%20%20yourself%0A')}),
 smalltalk.Collection);
 
-smalltalk.addMethod(
-'_copyFrom_to_',
-smalltalk.method({
-selector: 'copyFrom:to:',
-category: 'copying',
-fn: function (anIndex, anotherIndex) {
-    var self = this;
-    smalltalk.send(self, "_subclassResponsibility", []);
-    return self;
-},
-source: unescape('copyFrom%3A%20anIndex%20to%3A%20anotherIndex%0A%09self%20subclassResponsibility%0A')}),
-smalltalk.Collection);
-
 smalltalk.addMethod(
 '_copyWith_',
 smalltalk.method({
@@ -2794,13 +2781,13 @@ selector: 'collect:',
 category: 'enumerating',
 fn: function (aBlock) {
     var self = this;
-    var stream = nil;
-    stream = smalltalk.send(smalltalk.send(smalltalk.send(self, "_class", []), "_new", []), "_writeStream", []);
-    smalltalk.send(self, "_do_", [function (each) {return smalltalk.send(stream, "_nextPut_", [smalltalk.send(aBlock, "_value_", [each])]);}]);
-    return smalltalk.send(stream, "_contents", []);
+    var newCollection = nil;
+    newCollection = smalltalk.send(smalltalk.send(self, "_class", []), "_new", []);
+    smalltalk.send(self, "_do_", [function (each) {return smalltalk.send(newCollection, "_add_", [smalltalk.send(aBlock, "_value_", [each])]);}]);
+    return newCollection;
     return self;
 },
-source: unescape('collect%3A%20aBlock%0A%09%7C%20stream%20%7C%0A%09stream%20%3A%3D%20self%20class%20new%20writeStream.%0A%09self%20do%3A%20%5B%3Aeach%20%7C%0A%09%20%20%20%20stream%20nextPut%3A%20%28aBlock%20value%3A%20each%29%5D.%0A%09%5Estream%20contents%0A')}),
+source: unescape('collect%3A%20aBlock%0A%09%7C%20newCollection%20%7C%0A%09newCollection%20%3A%3D%20self%20class%20new.%0A%09self%20do%3A%20%5B%3Aeach%20%7C%0A%09%20%20%20%20newCollection%20add%3A%20%28aBlock%20value%3A%20each%29%5D.%0A%09%5EnewCollection%0A')}),
 smalltalk.Collection);
 
 smalltalk.addMethod(
@@ -2965,19 +2952,6 @@ fn: function (anObject) {
 source: unescape('remove%3A%20anObject%0A%20%20%20%20self%20subclassResponsibility%0A')}),
 smalltalk.Collection);
 
-smalltalk.addMethod(
-'_removeLast',
-smalltalk.method({
-selector: 'removeLast',
-category: 'adding/removing',
-fn: function () {
-    var self = this;
-    smalltalk.send(self, "_remove_", [smalltalk.send(self, "_last", [])]);
-    return self;
-},
-source: unescape('removeLast%0A%09self%20remove%3A%20self%20last')}),
-smalltalk.Collection);
-
 smalltalk.addMethod(
 '_inspectOn_',
 smalltalk.method({
@@ -2995,21 +2969,6 @@ fn: function (anInspector) {
 source: unescape('inspectOn%3A%20anInspector%0A%09%7C%20variables%20%7C%0A%09variables%20%3A%3D%20Dictionary%20new.%0A%09variables%20at%3A%20%27%23self%27%20put%3A%20self.%0A%09self%20withIndexDo%3A%20%5B%3Aeach%20%3Ai%20%7C%0A%09%09variables%20at%3A%20i%20put%3A%20each%5D.%0A%09anInspector%20%0A%09%09setLabel%3A%20self%20printString%3B%0A%09%09setVariables%3A%20variables')}),
 smalltalk.Collection);
 
-smalltalk.addMethod(
-'_withIndexDo_',
-smalltalk.method({
-selector: 'withIndexDo:',
-category: 'enumerating',
-fn: function (aBlock) {
-    var self = this;
-    for (var i = 0; i < self.length; i++) {
-        aBlock(self[i], i + 1);
-    }
-    return self;
-},
-source: unescape('withIndexDo%3A%20aBlock%0A%09%7B%27for%28var%20i%3D0%3Bi%3Cself.length%3Bi++%29%7BaBlock%28self%5Bi%5D%2C%20i+1%29%3B%7D%27%7D%0A')}),
-smalltalk.Collection);
-
 
 smalltalk.addMethod(
 '_streamClass',
@@ -3077,45 +3036,32 @@ source: unescape('withAll%3A%20aCollection%0A%09%20%20%20%20%5Eself%20new%0A%09%
 smalltalk.Collection.klass);
 
 
-smalltalk.addClass('String', smalltalk.Collection, [], 'Kernel');
-smalltalk.addMethod(
-'__eq',
-smalltalk.method({
-selector: '=',
-category: 'comparing',
-fn: function (aString) {
-    var self = this;
-    return String(self) == aString;
-    return self;
-},
-source: unescape('%3D%20aString%0A%09%7B%27return%20String%28self%29%20%3D%3D%20aString%27%7D')}),
-smalltalk.String);
-
+smalltalk.addClass('SequenceableCollection', smalltalk.Collection, [], 'Kernel');
 smalltalk.addMethod(
-'_size',
+'_at_',
 smalltalk.method({
-selector: 'size',
+selector: 'at:',
 category: 'accessing',
-fn: function () {
+fn: function (anIndex) {
     var self = this;
-    return self.length;
+    return smalltalk.send(self, "_at_ifAbsent_", [anIndex, function () {return smalltalk.send(self, "_errorNotFound", []);}]);
     return self;
 },
-source: unescape('size%0A%09%7B%27return%20self.length%27%7D%0A')}),
-smalltalk.String);
+source: unescape('at%3A%20anIndex%0A%09%5Eself%20at%3A%20anIndex%20ifAbsent%3A%20%5B%0A%09%20%20%20%20self%20errorNotFound%5D%0A')}),
+smalltalk.SequenceableCollection);
 
 smalltalk.addMethod(
-'_at_',
+'_at_ifAbsent_',
 smalltalk.method({
-selector: 'at:',
+selector: 'at:ifAbsent:',
 category: 'accessing',
-fn: function (anIndex) {
+fn: function (anIndex, aBlock) {
     var self = this;
-    return self[anIndex - 1] || nil;
+    smalltalk.send(self, "_subclassResponsibility", []);
     return self;
 },
-source: unescape('at%3A%20anIndex%0A%09%7B%27return%20self%5BanIndex%20-%201%5D%20%7C%7C%20nil%3B%27%7D')}),
-smalltalk.String);
+source: unescape('at%3A%20anIndex%20ifAbsent%3A%20aBlock%0A%09self%20subclassResponsibility')}),
+smalltalk.SequenceableCollection);
 
 smalltalk.addMethod(
 '_at_put_',
@@ -3124,10 +3070,184 @@ selector: 'at:put:',
 category: 'accessing',
 fn: function (anIndex, anObject) {
     var self = this;
-    smalltalk.send(self, "_errorReadOnly", []);
+    smalltalk.send(self, "_subclassResponsibility", []);
     return self;
 },
-source: unescape('at%3A%20anIndex%20put%3A%20anObject%0A%20%20%20%20%09self%20errorReadOnly%0A')}),
+source: unescape('at%3A%20anIndex%20put%3A%20anObject%0A%09self%20subclassResponsibility%0A')}),
+smalltalk.SequenceableCollection);
+
+smalltalk.addMethod(
+'_copyFrom_to_',
+smalltalk.method({
+selector: 'copyFrom:to:',
+category: 'copying',
+fn: function (anIndex, anotherIndex) {
+    var self = this;
+    smalltalk.send(self, "_subclassResponsibility", []);
+    return self;
+},
+source: unescape('copyFrom%3A%20anIndex%20to%3A%20anotherIndex%0A%09self%20subclassResponsibility%0A')}),
+smalltalk.SequenceableCollection);
+
+smalltalk.addMethod(
+'_first',
+smalltalk.method({
+selector: 'first',
+category: 'accessing',
+fn: function () {
+    var self = this;
+    return smalltalk.send(self, "_at_", [1]);
+    return self;
+},
+source: unescape('first%0A%09%5Eself%20at%3A%201%0A')}),
+smalltalk.SequenceableCollection);
+
+smalltalk.addMethod(
+'_fourth',
+smalltalk.method({
+selector: 'fourth',
+category: 'accessing',
+fn: function () {
+    var self = this;
+    return smalltalk.send(self, "_at_", [4]);
+    return self;
+},
+source: unescape('fourth%0A%09%5Eself%20at%3A%204%0A')}),
+smalltalk.SequenceableCollection);
+
+smalltalk.addMethod(
+'_last',
+smalltalk.method({
+selector: 'last',
+category: 'accessing',
+fn: function () {
+    var self = this;
+    return smalltalk.send(self, "_at_", [smalltalk.send(self, "_size", [])]);
+    return self;
+},
+source: unescape('last%0A%09%5Eself%20at%3A%20self%20size%0A')}),
+smalltalk.SequenceableCollection);
+
+smalltalk.addMethod(
+'_second',
+smalltalk.method({
+selector: 'second',
+category: 'accessing',
+fn: function () {
+    var self = this;
+    return smalltalk.send(self, "_at_", [2]);
+    return self;
+},
+source: unescape('second%0A%09%5Eself%20at%3A%202%0A')}),
+smalltalk.SequenceableCollection);
+
+smalltalk.addMethod(
+'_third',
+smalltalk.method({
+selector: 'third',
+category: 'accessing',
+fn: function () {
+    var self = this;
+    return smalltalk.send(self, "_at_", [3]);
+    return self;
+},
+source: unescape('third%0A%09%5Eself%20at%3A%203%0A')}),
+smalltalk.SequenceableCollection);
+
+smalltalk.addMethod(
+'_removeLast',
+smalltalk.method({
+selector: 'removeLast',
+category: 'adding',
+fn: function () {
+    var self = this;
+    smalltalk.send(self, "_remove_", [smalltalk.send(self, "_last", [])]);
+    return self;
+},
+source: unescape('removeLast%0A%09self%20remove%3A%20self%20last')}),
+smalltalk.SequenceableCollection);
+
+smalltalk.addMethod(
+'_addLast_',
+smalltalk.method({
+selector: 'addLast:',
+category: 'adding',
+fn: function (anObject) {
+    var self = this;
+    smalltalk.send(self, "_add_", [anObject]);
+    return self;
+},
+source: unescape('addLast%3A%20anObject%0A%09self%20add%3A%20anObject')}),
+smalltalk.SequenceableCollection);
+
+smalltalk.addMethod(
+'_withIndexDo_',
+smalltalk.method({
+selector: 'withIndexDo:',
+category: 'enumerating',
+fn: function (aBlock) {
+    var self = this;
+    for (var i = 0; i < self.length; i++) {
+        aBlock(self[i], i + 1);
+    }
+    return self;
+},
+source: unescape('withIndexDo%3A%20aBlock%0A%09%7B%27for%28var%20i%3D0%3Bi%3Cself.length%3Bi++%29%7BaBlock%28self%5Bi%5D%2C%20i+1%29%3B%7D%27%7D')}),
+smalltalk.SequenceableCollection);
+
+
+
+smalltalk.addClass('String', smalltalk.SequenceableCollection, [], 'Kernel');
+smalltalk.addMethod(
+'__eq',
+smalltalk.method({
+selector: '=',
+category: 'comparing',
+fn: function (aString) {
+    var self = this;
+    return String(self) == aString;
+    return self;
+},
+source: unescape('%3D%20aString%0A%09%7B%27return%20String%28self%29%20%3D%3D%20aString%27%7D')}),
+smalltalk.String);
+
+smalltalk.addMethod(
+'_size',
+smalltalk.method({
+selector: 'size',
+category: 'accessing',
+fn: function () {
+    var self = this;
+    return self.length;
+    return self;
+},
+source: unescape('size%0A%09%7B%27return%20self.length%27%7D%0A')}),
+smalltalk.String);
+
+smalltalk.addMethod(
+'_at_',
+smalltalk.method({
+selector: 'at:',
+category: 'accessing',
+fn: function (anIndex) {
+    var self = this;
+    return self[anIndex - 1];
+    return self;
+},
+source: unescape('at%3A%20anIndex%0A%09%7B%27return%20self%5BanIndex%20-%201%5D%3B%27%7D')}),
+smalltalk.String);
+
+smalltalk.addMethod(
+'_at_put_',
+smalltalk.method({
+selector: 'at:put:',
+category: 'accessing',
+fn: function (anIndex, anObject) {
+    var self = this;
+    smalltalk.send(self, "_errorReadOnly", []);
+    return self;
+},
+source: unescape('at%3A%20anIndex%20put%3A%20anObject%0A%20%20%20%20%09self%20errorReadOnly%0A')}),
 smalltalk.String);
 
 smalltalk.addMethod(
@@ -3565,6 +3685,19 @@ fn: function (anInspector) {
 source: unescape('inspectOn%3A%20anInspector%0A%09%7C%20label%20%7C%0A%09super%20inspectOn%3A%20anInspector.%0A%09self%20printString%20size%20%3E%2030%20%0A%09%09ifTrue%3A%20%5Blabel%20%3A%3D%20%28self%20printString%20copyFrom%3A%201%20to%3A%2030%29%2C%20%27...%27%27%27%5D%0A%09%09ifFalse%3A%20%5Blabel%20%3A%3D%20self%20printString%5D.%20%0A%09anInspector%20setLabel%3A%20label')}),
 smalltalk.String);
 
+smalltalk.addMethod(
+'_asJSONObject',
+smalltalk.method({
+selector: 'asJSONObject',
+category: 'converting',
+fn: function () {
+    var self = this;
+    return self;
+    return self;
+},
+source: unescape('asJSONObject%0A%09%5Eself')}),
+smalltalk.String);
+
 
 smalltalk.addMethod(
 '_streamClass',
@@ -3645,75 +3778,7 @@ source: unescape('tab%0A%09%7B%27return%20%27%27%5Ct%27%27%3B%27%7D')}),
 smalltalk.String.klass);
 
 
-smalltalk.addClass('RegularExpression', smalltalk.Object, [], 'Kernel');
-smalltalk.addMethod(
-'_compile_',
-smalltalk.method({
-selector: 'compile:',
-category: 'evaluating',
-fn: function (aString) {
-    var self = this;
-    return self.compile(aString);
-    return self;
-},
-source: unescape('compile%3A%20aString%0A%09%7B%27return%20self.compile%28aString%29%3B%27%7D')}),
-smalltalk.RegularExpression);
-
-smalltalk.addMethod(
-'_exec_',
-smalltalk.method({
-selector: 'exec:',
-category: 'evaluating',
-fn: function (aString) {
-    var self = this;
-    return self.exec(aString);
-    return self;
-},
-source: unescape('exec%3A%20aString%0A%09%7B%27return%20self.exec%28aString%29%3B%27%7D')}),
-smalltalk.RegularExpression);
-
-smalltalk.addMethod(
-'_test_',
-smalltalk.method({
-selector: 'test:',
-category: 'evaluating',
-fn: function (aString) {
-    var self = this;
-    return self.test(aString);
-    return self;
-},
-source: unescape('test%3A%20aString%0A%09%7B%27return%20self.test%28aString%29%3B%27%7D')}),
-smalltalk.RegularExpression);
-
-
-smalltalk.addMethod(
-'_fromString_flag_',
-smalltalk.method({
-selector: 'fromString:flag:',
-category: 'instance creation',
-fn: function (aString, anotherString) {
-    var self = this;
-    return new RegExp(aString, anotherString);
-    return self;
-},
-source: unescape('fromString%3A%20aString%20flag%3A%20anotherString%0A%09%7B%27return%20new%20RegExp%28aString%2C%20anotherString%29%3B%27%7D%0A')}),
-smalltalk.RegularExpression.klass);
-
-smalltalk.addMethod(
-'_fromString_',
-smalltalk.method({
-selector: 'fromString:',
-category: 'instance creation',
-fn: function (aString) {
-    var self = this;
-    return smalltalk.send(self, "_fromString_flag_", [aString, ""]);
-    return self;
-},
-source: unescape('fromString%3A%20aString%0A%09%20%20%20%20%5Eself%20fromString%3A%20aString%20flag%3A%20%27%27%0A')}),
-smalltalk.RegularExpression.klass);
-
-
-smalltalk.addClass('Array', smalltalk.Collection, [], 'Kernel');
+smalltalk.addClass('Array', smalltalk.SequenceableCollection, [], 'Kernel');
 smalltalk.addMethod(
 '_size',
 smalltalk.method({
@@ -3772,19 +3837,6 @@ fn: function (anObject) {
 source: unescape('add%3A%20anObject%0A%09%7B%27self.push%28anObject%29%3B%20return%20anObject%3B%27%7D%0A')}),
 smalltalk.Array);
 
-smalltalk.addMethod(
-'_addLast_',
-smalltalk.method({
-selector: 'addLast:',
-category: 'adding',
-fn: function (anObject) {
-    var self = this;
-    return smalltalk.send(self, "_add_", [anObject]);
-    return self;
-},
-source: unescape('addLast%3A%20anObject%0A%09%5Eself%20add%3A%20anObject%0A')}),
-smalltalk.Array);
-
 smalltalk.addMethod(
 '_shallowCopy',
 smalltalk.method({
@@ -3929,6 +3981,87 @@ fn: function (aBlock) {
 source: unescape('sorted%3A%20aBlock%0A%09%5Eself%20copy%20sorted%3A%20aBlock')}),
 smalltalk.Array);
 
+smalltalk.addMethod(
+'_asJSONObject',
+smalltalk.method({
+selector: 'asJSONObject',
+category: 'converting',
+fn: function () {
+    var self = this;
+    return smalltalk.send(self, "_collect_", [function (each) {return smalltalk.send(each, "_asJSONObject", []);}]);
+    return self;
+},
+source: unescape('asJSONObject%0A%09%5Eself%20collect%3A%20%5B%3Aeach%20%7C%20each%20asJSONObject%5D')}),
+smalltalk.Array);
+
+
+
+smalltalk.addClass('RegularExpression', smalltalk.Object, [], 'Kernel');
+smalltalk.addMethod(
+'_compile_',
+smalltalk.method({
+selector: 'compile:',
+category: 'evaluating',
+fn: function (aString) {
+    var self = this;
+    return self.compile(aString);
+    return self;
+},
+source: unescape('compile%3A%20aString%0A%09%7B%27return%20self.compile%28aString%29%3B%27%7D')}),
+smalltalk.RegularExpression);
+
+smalltalk.addMethod(
+'_exec_',
+smalltalk.method({
+selector: 'exec:',
+category: 'evaluating',
+fn: function (aString) {
+    var self = this;
+    return self.exec(aString);
+    return self;
+},
+source: unescape('exec%3A%20aString%0A%09%7B%27return%20self.exec%28aString%29%3B%27%7D')}),
+smalltalk.RegularExpression);
+
+smalltalk.addMethod(
+'_test_',
+smalltalk.method({
+selector: 'test:',
+category: 'evaluating',
+fn: function (aString) {
+    var self = this;
+    return self.test(aString);
+    return self;
+},
+source: unescape('test%3A%20aString%0A%09%7B%27return%20self.test%28aString%29%3B%27%7D')}),
+smalltalk.RegularExpression);
+
+
+smalltalk.addMethod(
+'_fromString_flag_',
+smalltalk.method({
+selector: 'fromString:flag:',
+category: 'instance creation',
+fn: function (aString, anotherString) {
+    var self = this;
+    return new RegExp(aString, anotherString);
+    return self;
+},
+source: unescape('fromString%3A%20aString%20flag%3A%20anotherString%0A%09%7B%27return%20new%20RegExp%28aString%2C%20anotherString%29%3B%27%7D%0A')}),
+smalltalk.RegularExpression.klass);
+
+smalltalk.addMethod(
+'_fromString_',
+smalltalk.method({
+selector: 'fromString:',
+category: 'instance creation',
+fn: function (aString) {
+    var self = this;
+    return smalltalk.send(self, "_fromString_flag_", [aString, ""]);
+    return self;
+},
+source: unescape('fromString%3A%20aString%0A%09%20%20%20%20%5Eself%20fromString%3A%20aString%20flag%3A%20%27%27%0A')}),
+smalltalk.RegularExpression.klass);
 
 
 smalltalk.addClass('Error', smalltalk.Object, ['messageText'], 'Kernel');
@@ -4435,6 +4568,35 @@ fn: function (anInspector) {
 source: unescape('inspectOn%3A%20anInspector%0A%09%7C%20variables%20%7C%0A%09variables%20%3A%3D%20Dictionary%20new.%0A%09variables%20at%3A%20%27%23self%27%20put%3A%20self.%0A%09variables%20at%3A%20%27%23keys%27%20put%3A%20self%20keys.%0A%09self%20keysAndValuesDo%3A%20%5B%3Akey%20%3Avalue%20%7C%0A%09%09variables%20at%3A%20key%20put%3A%20value%5D.%0A%09anInspector%20%0A%09%09setLabel%3A%20self%20printString%3B%0A%09%09setVariables%3A%20variables')}),
 smalltalk.Dictionary);
 
+smalltalk.addMethod(
+'_at_',
+smalltalk.method({
+selector: 'at:',
+category: 'accessing',
+fn: function (aKey) {
+    var self = this;
+    return smalltalk.send(self, "_at_ifAbsent_", [aKey, function () {return smalltalk.send(self, "_errorNotFound", []);}]);
+    return self;
+},
+source: unescape('at%3A%20aKey%0A%09%5Eself%20at%3A%20aKey%20ifAbsent%3A%20%5Bself%20errorNotFound%5D')}),
+smalltalk.Dictionary);
+
+smalltalk.addMethod(
+'_asJSONObject',
+smalltalk.method({
+selector: 'asJSONObject',
+category: 'converting',
+fn: function () {
+    var self = this;
+    var object = nil;
+    object = smalltalk.send(smalltalk.Object, "_new", []);
+    smalltalk.send(self, "_keysAndValuesDo_", [function (key, value) {return smalltalk.send(object, "_basicAt_put_", [key, smalltalk.send(value, "_asJSONObject", [])]);}]);
+    return object;
+    return self;
+},
+source: unescape('asJSONObject%0A%09%7C%20object%20%7C%0A%09object%20%3A%3D%20Object%20new.%0A%09self%20keysAndValuesDo%3A%20%5B%3Akey%20%3Avalue%20%7C%0A%09%09object%20basicAt%3A%20key%20put%3A%20value%20asJSONObject%5D.%0A%09%5Eobject')}),
+smalltalk.Dictionary);
+
 
 
 smalltalk.addClass('ClassBuilder', smalltalk.Object, [], 'Kernel');

+ 18 - 4
js/boot.js

@@ -48,6 +48,7 @@ function SmalltalkNil(){};
 function Smalltalk(){
 
     var st = this;
+    st.debugMode = true;
 
     /* Smalltalk class creation. A class is an instance of an automatically 
        created metaclass object. Newly created classes (not their metaclass) 
@@ -242,11 +243,23 @@ function Smalltalk(){
     };
 }
 
-/* Global Smalltalk objects. nil shouldn't be a global. */
+function SmalltalkMethodContext() {
+    this.stack = [];
+
+    this.push = function(context) {
+	stack.push(context);
+    };
+    
+    this.pop = function() {
+	stack.pop();
+    };
+}
+
+/* Global Smalltalk objects. nil and thisContext shouldn't be globals. */
 
 var nil = new SmalltalkNil();
 var smalltalk = new Smalltalk();
-
+var thisContext = nil;
 
 /****************************************************************************************/
 
@@ -270,9 +283,10 @@ smalltalk.mapClassName("Date", "Kernel", Date, smalltalk.Object);
 smalltalk.mapClassName("UndefinedObject", "Kernel", SmalltalkNil, smalltalk.Object);
 
 smalltalk.mapClassName("Collection", "Kernel", null, smalltalk.Object);
-smalltalk.mapClassName("String", "Kernel", String, smalltalk.Collection);
+smalltalk.mapClassName("SequenceableCollection", "Kernel", null, smalltalk.Collection);
+smalltalk.mapClassName("String", "Kernel", String, smalltalk.SequenceableCollection);
+smalltalk.mapClassName("Array", "Kernel", Array, smalltalk.SequenceableCollection);
 smalltalk.mapClassName("RegularExpression", "Kernel", RegExp, smalltalk.String);
-smalltalk.mapClassName("Array", "Kernel", Array, smalltalk.Collection);
 
 if(CanvasRenderingContext2D) {
     smalltalk.mapClassName("CanvasRenderingContext", "Canvas", CanvasRenderingContext2D, smalltalk.Object);

Some files were not shown because too many files changed in this diff