Browse Source

Improvements on contexts

Nicolas Petton 11 years ago
parent
commit
ec7bfbdeeb
8 changed files with 797 additions and 274 deletions
  1. 73 62
      js/Compiler-IR.deploy.js
  2. 102 92
      js/Compiler-IR.js
  3. 26 0
      js/Compiler-Semantic.deploy.js
  4. 36 0
      js/Compiler-Semantic.js
  5. 207 17
      js/Kernel-Objects.deploy.js
  6. 275 19
      js/Kernel-Objects.js
  7. 40 29
      st/Compiler-IR.st
  8. 38 55
      st/Kernel-Objects.st

+ 73 - 62
js/Compiler-IR.deploy.js

@@ -164,23 +164,23 @@ smalltalk.method({
 selector: "visitBlockNode:",
 fn: function (aNode){
 var self=this;
-return smalltalk.withContext(function($ctx) { var $1,$2,$3,$4;
-var closure;
+return smalltalk.withContext(function($ctx1) { var $1,$2,$3,$4;
 $1=_st((smalltalk.IRClosure || IRClosure))._new();
 _st($1)._arguments_(_st(aNode)._parameters());
 _st($1)._scope_(_st(aNode)._scope());
 $2=_st($1)._yourself();
-closure=$2;
+$ctx1.closure=$2;
 _st(_st(_st(aNode)._scope())._temps())._do_((function(each){
 $3=_st((smalltalk.IRTempDeclaration || IRTempDeclaration))._new();
 _st($3)._name_(_st(each)._name());
+_st($3)._scope_(_st(aNode)._scope());
 $4=_st($3)._yourself();
-return _st(closure)._add_($4);
+return _st($ctx1.closure)._add_($4);
 }));
 _st(_st(aNode)._nodes())._do_((function(each){
-return _st(closure)._add_(_st(self)._visit_(each));
+return _st($ctx1.closure)._add_(_st(self)._visit_(each));
 }));
-return closure;
+return $ctx1.closure;
 }, self, "visitBlockNode:", [aNode], smalltalk.IRASTTranslator)}
 }),
 smalltalk.IRASTTranslator);
@@ -292,7 +292,7 @@ smalltalk.method({
 selector: "visitMethodNode:",
 fn: function (aNode){
 var self=this;
-return smalltalk.withContext(function($ctx) { var $1,$2,$3,$4,$5,$6,$7,$8;
+return smalltalk.withContext(function($ctx1) { var $1,$2,$3,$4,$5,$6,$7,$8;
 $1=_st((smalltalk.IRMethod || IRMethod))._new();
 _st($1)._source_(_st(self)._source());
 _st($1)._theClass_(_st(self)._theClass());
@@ -307,6 +307,7 @@ _st(self)._method_($2);
 _st(_st(_st(aNode)._scope())._temps())._do_((function(each){
 $3=_st((smalltalk.IRTempDeclaration || IRTempDeclaration))._new();
 _st($3)._name_(_st(each)._name());
+_st($3)._scope_(_st(aNode)._scope());
 $4=_st($3)._yourself();
 return _st(_st(self)._method())._add_($4);
 }));
@@ -1174,6 +1175,44 @@ smalltalk.IRNonLocalReturn);
 
 
 
+smalltalk.addClass('IRTempDeclaration', smalltalk.IRScopedInstruction, ['name'], 'Compiler-IR');
+smalltalk.addMethod(
+"_accept_",
+smalltalk.method({
+selector: "accept:",
+fn: function (aVisitor){
+var self=this;
+return smalltalk.withContext(function($ctx1) { 
var $1;
+$1=_st(aVisitor)._visitIRTempDeclaration_(self);
+return $1;
+}, self, "accept:", [aVisitor], smalltalk.IRTempDeclaration)}
+}),
+smalltalk.IRTempDeclaration);
+
+smalltalk.addMethod(
+"_name",
+smalltalk.method({
+selector: "name",
+fn: function (){
+var self=this;
+return smalltalk.withContext(function($ctx1) { return self["@name"];
+}, self, "name", [], smalltalk.IRTempDeclaration)}
+}),
+smalltalk.IRTempDeclaration);
+
+smalltalk.addMethod(
+"_name_",
+smalltalk.method({
+selector: "name:",
+fn: function (aString){
+var self=this;
+return smalltalk.withContext(function($ctx1) { self["@name"]=aString;
+return self}, self, "name:", [aString], smalltalk.IRTempDeclaration)}
+}),
+smalltalk.IRTempDeclaration);
+
+
+
 smalltalk.addClass('IRSend', smalltalk.IRInstruction, ['selector', 'classSend', 'index'], 'Compiler-IR');
 smalltalk.addMethod(
 "_accept_",
@@ -1328,55 +1367,6 @@ smalltalk.IRBlockSequence);
 
 
 
-smalltalk.addClass('IRTempDeclaration', smalltalk.IRInstruction, ['name'], 'Compiler-IR');
-smalltalk.addMethod(
-"_accept_",
-smalltalk.method({
-selector: "accept:",
-fn: function (aVisitor){
-var self=this;
-return smalltalk.withContext(function($ctx) { var $1;
-$1=_st(aVisitor)._visitIRTempDeclaration_(self);
-return $1;
-}, self, "accept:", [aVisitor], smalltalk.IRTempDeclaration)}
-}),
-smalltalk.IRTempDeclaration);
-
-smalltalk.addMethod(
-"_isTempDeclaration",
-smalltalk.method({
-selector: "isTempDeclaration",
-fn: function (){
-var self=this;
-return smalltalk.withContext(function($ctx) { return true;
-}, self, "isTempDeclaration", [], smalltalk.IRTempDeclaration)}
-}),
-smalltalk.IRTempDeclaration);
-
-smalltalk.addMethod(
-"_name",
-smalltalk.method({
-selector: "name",
-fn: function (){
-var self=this;
-return smalltalk.withContext(function($ctx) { return self["@name"];
-}, self, "name", [], smalltalk.IRTempDeclaration)}
-}),
-smalltalk.IRTempDeclaration);
-
-smalltalk.addMethod(
-"_name_",
-smalltalk.method({
-selector: "name:",
-fn: function (aString){
-var self=this;
-return smalltalk.withContext(function($ctx) { self["@name"]=aString;
-return self}, self, "name:", [aString], smalltalk.IRTempDeclaration)}
-}),
-smalltalk.IRTempDeclaration);
-
-
-
 smalltalk.addClass('IRValue', smalltalk.IRInstruction, ['value'], 'Compiler-IR');
 smalltalk.addMethod(
 "_accept_",
@@ -1833,8 +1823,10 @@ smalltalk.method({
 selector: "visitIRClosure:",
 fn: function (anIRClosure){
 var self=this;
-return smalltalk.withContext(function($ctx) { _st(_st(self)._stream())._nextPutClosureWith_arguments_((function(){
+return smalltalk.withContext(function($ctx1) { 
_st(_st(self)._stream())._nextPutClosureWith_arguments_((function(){
+return _st(_st(self)._stream())._nextPutBlockContextFor_during_(anIRClosure,(function(){
 return smalltalk.IRVisitor.fn.prototype._visitIRClosure_.apply(_st(self), [anIRClosure]);
+}));
 }),_st(anIRClosure)._arguments());
 return self}, self, "visitIRClosure:", [anIRClosure], smalltalk.IRJSTranslator)}
 }),
@@ -2016,7 +2008,10 @@ smalltalk.method({
 selector: "visitIRTempDeclaration:",
 fn: function (anIRTempDeclaration){
 var self=this;
-return smalltalk.withContext(function($ctx) { _st(_st(self)._stream())._nextPutVar_(_st(_st(anIRTempDeclaration)._name())._asVariableName());
+return smalltalk.withContext(function($ctx1) { 
var $1,$2;
+$1=_st(self)._stream();
+_st($1)._nextPutAll_(_st(_st(_st(_st(_st(anIRTempDeclaration)._scope())._alias()).__comma(".")).__comma(_st(anIRTempDeclaration)._name())).__comma("=nil;"));
+$2=_st($1)._lf();
 return self}, self, "visitIRTempDeclaration:", [anIRTempDeclaration], smalltalk.IRJSTranslator)}
 }),
 smalltalk.IRJSTranslator);
@@ -2134,6 +2129,21 @@ return self}, self, "nextPutAssignment", [], smalltalk.JSStream)}
 }),
 smalltalk.JSStream);
 
+smalltalk.addMethod(
+"_nextPutBlockContextFor_during_",
+smalltalk.method({
+selector: "nextPutBlockContextFor:during:",
+fn: function (anIRClosure,aBlock){
+var self=this;
+return smalltalk.withContext(function($ctx1) { 
var $1;
+_st(self)._nextPutAll_(_st(_st("return smalltalk.withContext(function(").__comma(_st(_st(anIRClosure)._scope())._alias())).__comma(") { "));
+$1=_st(self)._nextPutAll_(_st((smalltalk.String || String))._cr());
+_st(aBlock)._value();
+_st(self)._nextPutAll_("})");
+return self}, self, "nextPutBlockContextFor:during:", [anIRClosure,aBlock], smalltalk.JSStream)}
+}),
+smalltalk.JSStream);
+
 smalltalk.addMethod(
 "_nextPutClosureWith_arguments_",
 smalltalk.method({
@@ -2161,11 +2171,12 @@ smalltalk.method({
 selector: "nextPutContextFor:during:",
 fn: function (aMethod,aBlock){
 var self=this;
-return smalltalk.withContext(function($ctx) { var $1,$2;
-_st(self)._nextPutAll_("return smalltalk.withContext(function($ctx) { ");
+return smalltalk.withContext(function($ctx1) { var $1,$2,$3;
+_st(self)._nextPutAll_(_st(_st("return smalltalk.withContext(function(").__comma(_st(_st(aMethod)._scope())._alias())).__comma(") { "));
+$1=_st(self)._nextPutAll_(_st((smalltalk.String || String))._cr());
 _st(aBlock)._value();
 _st(self)._nextPutAll_("}, self, ");
-$1=_st(self)._nextPutAll_(_st(_st(_st(aMethod)._selector())._asJavascript()).__comma(", ["));
+$2=_st(self)._nextPutAll_(_st(_st(_st(aMethod)._selector())._asJavascript()).__comma(", ["));
 _st(_st(aMethod)._arguments())._do_separatedBy_((function(each){
 return _st(self)._nextPutAll_(each);
 }),(function(){
@@ -2173,7 +2184,7 @@ return _st(self)._nextPutAll_(",");
 }));
 _st(self)._nextPutAll_("], ");
 _st(self)._nextPutAll_(_st(_st(aMethod)._theClass())._asJavascript());
-$2=_st(self)._nextPutAll_(")");
+$3=_st(self)._nextPutAll_(")");
 return self}, self, "nextPutContextFor:during:", [aMethod,aBlock], smalltalk.JSStream)}
 }),
 smalltalk.JSStream);

+ 102 - 92
js/Compiler-IR.js

@@ -221,26 +221,26 @@ selector: "visitBlockNode:",
 category: 'visiting',
 fn: function (aNode){
 var self=this;
-return smalltalk.withContext(function($ctx) { var $1,$2,$3,$4;
-var closure;
+return smalltalk.withContext(function($ctx1) { var $1,$2,$3,$4;
 $1=_st((smalltalk.IRClosure || IRClosure))._new();
 _st($1)._arguments_(_st(aNode)._parameters());
 _st($1)._scope_(_st(aNode)._scope());
 $2=_st($1)._yourself();
-closure=$2;
+$ctx1.closure=$2;
 _st(_st(_st(aNode)._scope())._temps())._do_((function(each){
 $3=_st((smalltalk.IRTempDeclaration || IRTempDeclaration))._new();
 _st($3)._name_(_st(each)._name());
+_st($3)._scope_(_st(aNode)._scope());
 $4=_st($3)._yourself();
-return _st(closure)._add_($4);
+return _st($ctx1.closure)._add_($4);
 }));
 _st(_st(aNode)._nodes())._do_((function(each){
-return _st(closure)._add_(_st(self)._visit_(each));
+return _st($ctx1.closure)._add_(_st(self)._visit_(each));
 }));
-return closure;
+return $ctx1.closure;
 }, self, "visitBlockNode:", [aNode], smalltalk.IRASTTranslator)},
 args: ["aNode"],
-source: "visitBlockNode: aNode\x0a\x09| closure |\x0a\x09closure := IRClosure new\x0a\x09\x09arguments: aNode parameters;\x0a\x09\x09scope: aNode scope;\x0a\x09\x09yourself.\x0a\x09aNode scope temps do: [ :each |\x0a\x09\x09closure add: (IRTempDeclaration new \x0a\x09\x09\x09name: each name;\x0a\x09\x09\x09yourself) ].\x0a\x09aNode nodes do: [ :each | closure add: (self visit: each) ].\x0a\x09^ closure",
+source: "visitBlockNode: aNode\x0a\x09| closure |\x0a\x09closure := IRClosure new\x0a\x09\x09arguments: aNode parameters;\x0a\x09\x09scope: aNode scope;\x0a\x09\x09yourself.\x0a\x09aNode scope temps do: [ :each |\x0a\x09\x09closure add: (IRTempDeclaration new \x0a\x09\x09\x09name: each name;\x0a            scope: aNode scope;\x0a\x09\x09\x09yourself) ].\x0a\x09aNode nodes do: [ :each | closure add: (self visit: each) ].\x0a\x09^ closure",
 messageSends: ["arguments:", "parameters", "new", "scope:", "scope", "yourself", "do:", "add:", "name:", "name", "temps", "visit:", "nodes"],
 referencedClasses: ["IRClosure", "IRTempDeclaration"]
 }),
@@ -379,7 +379,7 @@ selector: "visitMethodNode:",
 category: 'visiting',
 fn: function (aNode){
 var self=this;
-return smalltalk.withContext(function($ctx) { var $1,$2,$3,$4,$5,$6,$7,$8;
+return smalltalk.withContext(function($ctx1) { var $1,$2,$3,$4,$5,$6,$7,$8;
 $1=_st((smalltalk.IRMethod || IRMethod))._new();
 _st($1)._source_(_st(self)._source());
 _st($1)._theClass_(_st(self)._theClass());
@@ -394,6 +394,7 @@ _st(self)._method_($2);
 _st(_st(_st(aNode)._scope())._temps())._do_((function(each){
 $3=_st((smalltalk.IRTempDeclaration || IRTempDeclaration))._new();
 _st($3)._name_(_st(each)._name());
+_st($3)._scope_(_st(aNode)._scope());
 $4=_st($3)._yourself();
 return _st(_st(self)._method())._add_($4);
 }));
@@ -411,7 +412,7 @@ $8=_st(self)._method();
 return $8;
 }, self, "visitMethodNode:", [aNode], smalltalk.IRASTTranslator)},
 args: ["aNode"],
-source: "visitMethodNode: aNode\x0a\x0a\x09self method: (IRMethod new\x0a\x09\x09source: self source;\x0a        theClass: self theClass;\x0a\x09\x09arguments: aNode arguments;\x0a\x09\x09selector: aNode selector;\x0a\x09\x09messageSends: aNode messageSends;\x0a        superSends: aNode superSends;\x0a\x09\x09classReferences: aNode classReferences;\x0a\x09\x09scope: aNode scope;\x0a\x09\x09yourself).\x0a\x0a\x09aNode scope temps do: [ :each |\x0a\x09\x09self method add: (IRTempDeclaration new\x0a\x09\x09\x09name: each name;\x0a\x09\x09\x09yourself) ].\x0a\x0a\x09aNode nodes do: [ :each | self method add: (self visit: each) ].\x0a\x0a\x09aNode scope hasLocalReturn ifFalse: [\x0a\x09\x09(self method add: IRReturn new) add: (IRVariable new\x0a\x09\x09\x09variable: (aNode scope pseudoVars at: 'self');\x0a\x09\x09\x09yourself) ].\x0a\x0a\x09^ self method",
+source: "visitMethodNode: aNode\x0a\x0a\x09self method: (IRMethod new\x0a\x09\x09source: self source;\x0a        theClass: self theClass;\x0a\x09\x09arguments: aNode arguments;\x0a\x09\x09selector: aNode selector;\x0a\x09\x09messageSends: aNode messageSends;\x0a        superSends: aNode superSends;\x0a\x09\x09classReferences: aNode classReferences;\x0a\x09\x09scope: aNode scope;\x0a\x09\x09yourself).\x0a\x0a\x09aNode scope temps do: [ :each |\x0a\x09\x09self method add: (IRTempDeclaration new\x0a\x09\x09\x09name: each name;\x0a            scope: aNode scope;\x0a\x09\x09\x09yourself) ].\x0a\x0a\x09aNode nodes do: [ :each | self method add: (self visit: each) ].\x0a\x0a\x09aNode scope hasLocalReturn ifFalse: [\x0a\x09\x09(self method add: IRReturn new) add: (IRVariable new\x0a\x09\x09\x09variable: (aNode scope pseudoVars at: 'self');\x0a\x09\x09\x09yourself) ].\x0a\x0a\x09^ self method",
 messageSends: ["method:", "source:", "source", "new", "theClass:", "theClass", "arguments:", "arguments", "selector:", "selector", "messageSends:", "messageSends", "superSends:", "superSends", "classReferences:", "classReferences", "scope:", "scope", "yourself", "do:", "add:", "name:", "name", "method", "temps", "visit:", "nodes", "ifFalse:", "variable:", "at:", "pseudoVars", "hasLocalReturn"],
 referencedClasses: ["IRMethod", "IRTempDeclaration", "IRVariable", "IRReturn"]
 }),
@@ -1585,6 +1586,59 @@ smalltalk.IRNonLocalReturn);
 
 
 
+smalltalk.addClass('IRTempDeclaration', smalltalk.IRScopedInstruction, ['name'], 'Compiler-IR');
+smalltalk.addMethod(
+"_accept_",
+smalltalk.method({
+selector: "accept:",
+category: 'visiting',
+fn: function (aVisitor){
+var self=this;
+return smalltalk.withContext(function($ctx1) { 
var $1;
+$1=_st(aVisitor)._visitIRTempDeclaration_(self);
+return $1;
+}, self, "accept:", [aVisitor], smalltalk.IRTempDeclaration)},
+args: ["aVisitor"],
+source: "accept: aVisitor\x0a\x09^ aVisitor visitIRTempDeclaration: self",
+messageSends: ["visitIRTempDeclaration:"],
+referencedClasses: []
+}),
+smalltalk.IRTempDeclaration);
+
+smalltalk.addMethod(
+"_name",
+smalltalk.method({
+selector: "name",
+category: 'accessing',
+fn: function (){
+var self=this;
+return smalltalk.withContext(function($ctx1) { return self["@name"];
+}, self, "name", [], smalltalk.IRTempDeclaration)},
+args: [],
+source: "name\x0a\x09^ name",
+messageSends: [],
+referencedClasses: []
+}),
+smalltalk.IRTempDeclaration);
+
+smalltalk.addMethod(
+"_name_",
+smalltalk.method({
+selector: "name:",
+category: 'accessing',
+fn: function (aString){
+var self=this;
+return smalltalk.withContext(function($ctx1) { self["@name"]=aString;
+return self}, self, "name:", [aString], smalltalk.IRTempDeclaration)},
+args: ["aString"],
+source: "name: aString\x0a\x09name := aString",
+messageSends: [],
+referencedClasses: []
+}),
+smalltalk.IRTempDeclaration);
+
+
+
 smalltalk.addClass('IRSend', smalltalk.IRInstruction, ['selector', 'classSend', 'index'], 'Compiler-IR');
 smalltalk.IRSend.comment="I am a message send instruction. "
 smalltalk.addMethod(
@@ -1800,76 +1854,6 @@ smalltalk.IRBlockSequence);
 
 
 
-smalltalk.addClass('IRTempDeclaration', smalltalk.IRInstruction, ['name'], 'Compiler-IR');
-smalltalk.IRTempDeclaration.comment="I am a temporary variable declaration instruction"
-smalltalk.addMethod(
-"_accept_",
-smalltalk.method({
-selector: "accept:",
-category: 'visiting',
-fn: function (aVisitor){
-var self=this;
-return smalltalk.withContext(function($ctx) { var $1;
-$1=_st(aVisitor)._visitIRTempDeclaration_(self);
-return $1;
-}, self, "accept:", [aVisitor], smalltalk.IRTempDeclaration)},
-args: ["aVisitor"],
-source: "accept: aVisitor\x0a\x09^ aVisitor visitIRTempDeclaration: self",
-messageSends: ["visitIRTempDeclaration:"],
-referencedClasses: []
-}),
-smalltalk.IRTempDeclaration);
-
-smalltalk.addMethod(
-"_isTempDeclaration",
-smalltalk.method({
-selector: "isTempDeclaration",
-category: 'visiting',
-fn: function (){
-var self=this;
-return smalltalk.withContext(function($ctx) { return true;
-}, self, "isTempDeclaration", [], smalltalk.IRTempDeclaration)},
-args: [],
-source: "isTempDeclaration\x0a\x09^ true",
-messageSends: [],
-referencedClasses: []
-}),
-smalltalk.IRTempDeclaration);
-
-smalltalk.addMethod(
-"_name",
-smalltalk.method({
-selector: "name",
-category: 'accessing',
-fn: function (){
-var self=this;
-return smalltalk.withContext(function($ctx) { return self["@name"];
-}, self, "name", [], smalltalk.IRTempDeclaration)},
-args: [],
-source: "name\x0a\x09^ name",
-messageSends: [],
-referencedClasses: []
-}),
-smalltalk.IRTempDeclaration);
-
-smalltalk.addMethod(
-"_name_",
-smalltalk.method({
-selector: "name:",
-category: 'accessing',
-fn: function (aString){
-var self=this;
-return smalltalk.withContext(function($ctx) { self["@name"]=aString;
-return self}, self, "name:", [aString], smalltalk.IRTempDeclaration)},
-args: ["aString"],
-source: "name: aString\x0a\x09name := aString",
-messageSends: [],
-referencedClasses: []
-}),
-smalltalk.IRTempDeclaration);
-
-
-
 smalltalk.addClass('IRValue', smalltalk.IRInstruction, ['value'], 'Compiler-IR');
 smalltalk.IRValue.comment="I am the simplest possible instruction. I represent a value."
 smalltalk.addMethod(
@@ -2504,13 +2488,15 @@ selector: "visitIRClosure:",
 category: 'visiting',
 fn: function (anIRClosure){
 var self=this;
-return smalltalk.withContext(function($ctx) { _st(_st(self)._stream())._nextPutClosureWith_arguments_((function(){
+return smalltalk.withContext(function($ctx1) { 
_st(_st(self)._stream())._nextPutClosureWith_arguments_((function(){
+return _st(_st(self)._stream())._nextPutBlockContextFor_during_(anIRClosure,(function(){
 return smalltalk.IRVisitor.fn.prototype._visitIRClosure_.apply(_st(self), [anIRClosure]);
+}));
 }),_st(anIRClosure)._arguments());
 return self}, self, "visitIRClosure:", [anIRClosure], smalltalk.IRJSTranslator)},
 args: ["anIRClosure"],
-source: "visitIRClosure: anIRClosure\x0a\x09self stream \x0a\x09\x09nextPutClosureWith: [ super visitIRClosure: anIRClosure ] \x0a\x09\x09arguments: anIRClosure arguments",
-messageSends: ["nextPutClosureWith:arguments:", "visitIRClosure:", "arguments", "stream"],
+source: "visitIRClosure: anIRClosure\x0a\x09self stream \x0a\x09\x09nextPutClosureWith: [ \x0a        \x09self stream \x0a            \x09nextPutBlockContextFor: anIRClosure\x0a                during: [ super visitIRClosure: anIRClosure ] ]\x0a\x09\x09arguments: anIRClosure arguments",
+messageSends: ["nextPutClosureWith:arguments:", "nextPutBlockContextFor:during:", "visitIRClosure:", "stream", "arguments"],
 referencedClasses: []
 }),
 smalltalk.IRJSTranslator);
@@ -2732,11 +2718,14 @@ selector: "visitIRTempDeclaration:",
 category: 'visiting',
 fn: function (anIRTempDeclaration){
 var self=this;
-return smalltalk.withContext(function($ctx) { _st(_st(self)._stream())._nextPutVar_(_st(_st(anIRTempDeclaration)._name())._asVariableName());
+return smalltalk.withContext(function($ctx1) { 
var $1,$2;
+$1=_st(self)._stream();
+_st($1)._nextPutAll_(_st(_st(_st(_st(_st(anIRTempDeclaration)._scope())._alias()).__comma(".")).__comma(_st(anIRTempDeclaration)._name())).__comma("=nil;"));
+$2=_st($1)._lf();
 return self}, self, "visitIRTempDeclaration:", [anIRTempDeclaration], smalltalk.IRJSTranslator)},
 args: ["anIRTempDeclaration"],
-source: "visitIRTempDeclaration: anIRTempDeclaration\x0a\x09self stream nextPutVar: anIRTempDeclaration name asVariableName",
-messageSends: ["nextPutVar:", "asVariableName", "name", "stream"],
+source: "visitIRTempDeclaration: anIRTempDeclaration\x0a\x09self stream \x0a    \x09nextPutAll: anIRTempDeclaration scope alias, '.', anIRTempDeclaration name, '=nil;'; \x0a        lf",
+messageSends: ["nextPutAll:", ",", "name", "alias", "scope", "stream", "lf"],
 referencedClasses: []
 }),
 smalltalk.IRJSTranslator);
@@ -2899,6 +2888,26 @@ referencedClasses: []
 }),
 smalltalk.JSStream);
 
+smalltalk.addMethod(
+"_nextPutBlockContextFor_during_",
+smalltalk.method({
+selector: "nextPutBlockContextFor:during:",
+category: 'streaming',
+fn: function (anIRClosure,aBlock){
+var self=this;
+return smalltalk.withContext(function($ctx1) { 
var $1;
+_st(self)._nextPutAll_(_st(_st("return smalltalk.withContext(function(").__comma(_st(_st(anIRClosure)._scope())._alias())).__comma(") { "));
+$1=_st(self)._nextPutAll_(_st((smalltalk.String || String))._cr());
+_st(aBlock)._value();
+_st(self)._nextPutAll_("})");
+return self}, self, "nextPutBlockContextFor:during:", [anIRClosure,aBlock], smalltalk.JSStream)},
+args: ["anIRClosure", "aBlock"],
+source: "nextPutBlockContextFor: anIRClosure during: aBlock\x0a\x09self \x0a    \x09nextPutAll: 'return smalltalk.withContext(function(', anIRClosure scope alias, ') { '; \x0a        nextPutAll: String cr.\x0a    aBlock value.\x0a    self nextPutAll: '})'",
+messageSends: ["nextPutAll:", ",", "alias", "scope", "cr", "value"],
+referencedClasses: ["String"]
+}),
+smalltalk.JSStream);
+
 smalltalk.addMethod(
 "_nextPutClosureWith_arguments_",
 smalltalk.method({
@@ -2932,11 +2941,12 @@ selector: "nextPutContextFor:during:",
 category: 'streaming',
 fn: function (aMethod,aBlock){
 var self=this;
-return smalltalk.withContext(function($ctx) { var $1,$2;
-_st(self)._nextPutAll_("return smalltalk.withContext(function($ctx) { ");
+return smalltalk.withContext(function($ctx1) { var $1,$2,$3;
+_st(self)._nextPutAll_(_st(_st("return smalltalk.withContext(function(").__comma(_st(_st(aMethod)._scope())._alias())).__comma(") { "));
+$1=_st(self)._nextPutAll_(_st((smalltalk.String || String))._cr());
 _st(aBlock)._value();
 _st(self)._nextPutAll_("}, self, ");
-$1=_st(self)._nextPutAll_(_st(_st(_st(aMethod)._selector())._asJavascript()).__comma(", ["));
+$2=_st(self)._nextPutAll_(_st(_st(_st(aMethod)._selector())._asJavascript()).__comma(", ["));
 _st(_st(aMethod)._arguments())._do_separatedBy_((function(each){
 return _st(self)._nextPutAll_(each);
 }),(function(){
@@ -2944,12 +2954,12 @@ return _st(self)._nextPutAll_(",");
 }));
 _st(self)._nextPutAll_("], ");
 _st(self)._nextPutAll_(_st(_st(aMethod)._theClass())._asJavascript());
-$2=_st(self)._nextPutAll_(")");
+$3=_st(self)._nextPutAll_(")");
 return self}, self, "nextPutContextFor:during:", [aMethod,aBlock], smalltalk.JSStream)},
 args: ["aMethod", "aBlock"],
-source: "nextPutContextFor: aMethod during: aBlock\x0a\x09self nextPutAll: 'return smalltalk.withContext(function($ctx) { '.\x0a    aBlock value.\x0a    self \x0a    \x09nextPutAll: '}, self, ';\x0a        nextPutAll: aMethod selector asJavascript, ', ['.\x0a    aMethod arguments \x0a    \x09do: [ :each | self nextPutAll: each ]\x0a      \x09separatedBy: [ self nextPutAll: ','  ].\x0a    self nextPutAll: '], ';\x0a        nextPutAll: aMethod theClass asJavascript;\x0a        nextPutAll: ')'",
-messageSends: ["nextPutAll:", "value", ",", "asJavascript", "selector", "do:separatedBy:", "arguments", "theClass"],
-referencedClasses: []
+source: "nextPutContextFor: aMethod during: aBlock\x0a\x09self \x0a    \x09nextPutAll: 'return smalltalk.withContext(function(', aMethod scope alias, ') { '; \x0a        nextPutAll: String cr.\x0a    aBlock value.\x0a    self \x0a    \x09nextPutAll: '}, self, ';\x0a        nextPutAll: aMethod selector asJavascript, ', ['.\x0a    aMethod arguments \x0a    \x09do: [ :each | self nextPutAll: each ]\x0a      \x09separatedBy: [ self nextPutAll: ','  ].\x0a    self nextPutAll: '], ';\x0a        nextPutAll: aMethod theClass asJavascript;\x0a        nextPutAll: ')'",
+messageSends: ["nextPutAll:", ",", "alias", "scope", "cr", "value", "asJavascript", "selector", "do:separatedBy:", "arguments", "theClass"],
+referencedClasses: ["String"]
 }),
 smalltalk.JSStream);
 

+ 26 - 0
js/Compiler-Semantic.deploy.js

@@ -24,6 +24,19 @@ return self}, self, "addTemp:", [aString], smalltalk.LexicalScope)}
 }),
 smalltalk.LexicalScope);
 
+smalltalk.addMethod(
+"_alias",
+smalltalk.method({
+selector: "alias",
+fn: function (){
+var self=this;
+return smalltalk.withContext(function($ctx) { var $1;
+$1=_st("$ctx").__comma(_st(_st(self)._scopeLevel())._asString());
+return $1;
+}, self, "alias", [], smalltalk.LexicalScope)}
+}),
+smalltalk.LexicalScope);
+
 smalltalk.addMethod(
 "_allVariableNames",
 smalltalk.method({
@@ -806,6 +819,19 @@ smalltalk.PseudoVar);
 
 
 smalltalk.addClass('TempVar', smalltalk.ScopeVar, [], 'Compiler-Semantic');
+smalltalk.addMethod(
+"_alias",
+smalltalk.method({
+selector: "alias",
+fn: function (){
+var self=this;
+return smalltalk.withContext(function($ctx) { var $1;
+$1=_st(_st(_st(_st(self)._scope())._alias()).__comma(".")).__comma(smalltalk.ScopeVar.fn.prototype._alias.apply(_st(self), []));
+return $1;
+}, self, "alias", [], smalltalk.TempVar)}
+}),
+smalltalk.TempVar);
+
 smalltalk.addMethod(
 "_isTempVar",
 smalltalk.method({

+ 36 - 0
js/Compiler-Semantic.js

@@ -35,6 +35,24 @@ referencedClasses: ["TempVar"]
 }),
 smalltalk.LexicalScope);
 
+smalltalk.addMethod(
+"_alias",
+smalltalk.method({
+selector: "alias",
+category: 'accessing',
+fn: function (){
+var self=this;
+return smalltalk.withContext(function($ctx) { var $1;
+$1=_st("$ctx").__comma(_st(_st(self)._scopeLevel())._asString());
+return $1;
+}, self, "alias", [], smalltalk.LexicalScope)},
+args: [],
+source: "alias\x0a\x09^ '$ctx', self scopeLevel asString",
+messageSends: [",", "asString", "scopeLevel"],
+referencedClasses: []
+}),
+smalltalk.LexicalScope);
+
 smalltalk.addMethod(
 "_allVariableNames",
 smalltalk.method({
@@ -1105,6 +1123,24 @@ smalltalk.PseudoVar);
 
 smalltalk.addClass('TempVar', smalltalk.ScopeVar, [], 'Compiler-Semantic');
 smalltalk.TempVar.comment="I am an temporary variable of a method or block."
+smalltalk.addMethod(
+"_alias",
+smalltalk.method({
+selector: "alias",
+category: 'accessing',
+fn: function (){
+var self=this;
+return smalltalk.withContext(function($ctx) { var $1;
+$1=_st(_st(_st(_st(self)._scope())._alias()).__comma(".")).__comma(smalltalk.ScopeVar.fn.prototype._alias.apply(_st(self), []));
+return $1;
+}, self, "alias", [], smalltalk.TempVar)},
+args: [],
+source: "alias\x0a\x09^ self scope alias, '.', super alias",
+messageSends: [",", "alias", "scope"],
+referencedClasses: []
+}),
+smalltalk.TempVar);
+
 smalltalk.addMethod(
 "_isTempVar",
 smalltalk.method({

+ 207 - 17
js/Kernel-Objects.deploy.js

@@ -697,7 +697,7 @@ fn: function () {
 smalltalk.Object);
 
 smalltalk.addMethod(
-"_~_eq",
+"__tild_eq",
 smalltalk.method({
 selector: "~=",
 fn: function (anObject) {
@@ -710,7 +710,7 @@ fn: function (anObject) {
 smalltalk.Object);
 
 smalltalk.addMethod(
-"_~~",
+"__tild_tild",
 smalltalk.method({
 selector: "~~",
 fn: function (anObject) {
@@ -737,7 +737,7 @@ smalltalk.Object.klass);
 
 smalltalk.addClass('Boolean', smalltalk.Object, [], 'Kernel-Objects');
 smalltalk.addMethod(
-"_&",
+"__and",
 smalltalk.method({
 selector: "&",
 fn: function (aBoolean) {
@@ -924,7 +924,7 @@ fn: function () {
 smalltalk.Boolean);
 
 smalltalk.addMethod(
-"_|",
+"__or",
 smalltalk.method({
 selector: "|",
 fn: function (aBoolean) {
@@ -941,6 +941,196 @@ smalltalk.Boolean);
 
 
 
+smalltalk.addClass('CompiledMethod', smalltalk.Object, [], 'Kernel-Methods');
+smalltalk.addMethod(
+"_arguments",
+smalltalk.method({
+selector: "arguments",
+fn: function () {
+    var self = this;
+    return self.args || [];
+    return self;
+}
+}),
+smalltalk.CompiledMethod);
+
+smalltalk.addMethod(
+"_category",
+smalltalk.method({
+selector: "category",
+fn: function () {
+    var self = this;
+    var $2, $1;
+    $2 = smalltalk.send(self, "_basicAt_", ["category"]);
+    if (($receiver = $2) == nil || $receiver == undefined) {
+        $1 = "";
+    } else {
+        $1 = $2;
+    }
+    return $1;
+}
+}),
+smalltalk.CompiledMethod);
+
+smalltalk.addMethod(
+"_category_",
+smalltalk.method({
+selector: "category:",
+fn: function (aString){
+var self=this;
+var $1;
+var oldCategory;
+oldCategory=smalltalk.send(self,"_category",[]);
+smalltalk.send(self,"_basicAt_put_",["category",aString]);
+$1=smalltalk.send(self,"_methodClass",[]);
+if(($receiver = $1) == nil || $receiver == undefined){
+$1;
+} else {
+smalltalk.send(smalltalk.send(smalltalk.send(self,"_methodClass",[]),"_organization",[]),"_addElement_",[aString]);
+smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.send(self,"_methodClass",[]),"_methods",[]),"_select_",[(function(each){
+return smalltalk.send(smalltalk.send(each,"_category",[]),"__eq",[oldCategory]);
+})]),"_ifEmpty_",[(function(){
+return smalltalk.send(smalltalk.send(smalltalk.send(self,"_methodClass",[]),"_organization",[]),"_removeElement_",[oldCategory]);
+})]);
+};
+return self}
+}),
+smalltalk.CompiledMethod);
+
+smalltalk.addMethod(
+"_fn",
+smalltalk.method({
+selector: "fn",
+fn: function () {
+    var self = this;
+    var $1;
+    $1 = smalltalk.send(self, "_basicAt_", ["fn"]);
+    return $1;
+}
+}),
+smalltalk.CompiledMethod);
+
+smalltalk.addMethod(
+"_fn_",
+smalltalk.method({
+selector: "fn:",
+fn: function (aBlock) {
+    var self = this;
+    smalltalk.send(self, "_basicAt_put_", ["fn", aBlock]);
+    return self;
+}
+}),
+smalltalk.CompiledMethod);
+
+smalltalk.addMethod(
+"_messageSends",
+smalltalk.method({
+selector: "messageSends",
+fn: function () {
+    var self = this;
+    var $1;
+    $1 = smalltalk.send(self, "_basicAt_", ["messageSends"]);
+    return $1;
+}
+}),
+smalltalk.CompiledMethod);
+
+smalltalk.addMethod(
+"_methodClass",
+smalltalk.method({
+selector: "methodClass",
+fn: function () {
+    var self = this;
+    var $1;
+    $1 = smalltalk.send(self, "_basicAt_", ["methodClass"]);
+    return $1;
+}
+}),
+smalltalk.CompiledMethod);
+
+smalltalk.addMethod(
+"_protocol",
+smalltalk.method({
+selector: "protocol",
+fn: function () {
+    var self = this;
+    var $1;
+    $1 = smalltalk.send(self, "_category", []);
+    return $1;
+}
+}),
+smalltalk.CompiledMethod);
+
+smalltalk.addMethod(
+"_referencedClasses",
+smalltalk.method({
+selector: "referencedClasses",
+fn: function () {
+    var self = this;
+    var $1;
+    $1 = smalltalk.send(self, "_basicAt_", ["referencedClasses"]);
+    return $1;
+}
+}),
+smalltalk.CompiledMethod);
+
+smalltalk.addMethod(
+"_selector",
+smalltalk.method({
+selector: "selector",
+fn: function () {
+    var self = this;
+    var $1;
+    $1 = smalltalk.send(self, "_basicAt_", ["selector"]);
+    return $1;
+}
+}),
+smalltalk.CompiledMethod);
+
+smalltalk.addMethod(
+"_selector_",
+smalltalk.method({
+selector: "selector:",
+fn: function (aString) {
+    var self = this;
+    smalltalk.send(self, "_basicAt_put_", ["selector", aString]);
+    return self;
+}
+}),
+smalltalk.CompiledMethod);
+
+smalltalk.addMethod(
+"_source",
+smalltalk.method({
+selector: "source",
+fn: function () {
+    var self = this;
+    var $2, $1;
+    $2 = smalltalk.send(self, "_basicAt_", ["source"]);
+    if (($receiver = $2) == nil || $receiver == undefined) {
+        $1 = "";
+    } else {
+        $1 = $2;
+    }
+    return $1;
+}
+}),
+smalltalk.CompiledMethod);
+
+smalltalk.addMethod(
+"_source_",
+smalltalk.method({
+selector: "source:",
+fn: function (aString) {
+    var self = this;
+    smalltalk.send(self, "_basicAt_put_", ["source", aString]);
+    return self;
+}
+}),
+smalltalk.CompiledMethod);
+
+
+
 smalltalk.addClass('Date', smalltalk.Object, [], 'Kernel-Objects');
 smalltalk.addMethod(
 "__plus",
@@ -1564,7 +1754,7 @@ smalltalk.JSObjectProxy.klass);
 
 smalltalk.addClass('Number', smalltalk.Object, [], 'Kernel-Objects');
 smalltalk.addMethod(
-"_&",
+"__and",
 smalltalk.method({
 selector: "&",
 fn: function (aNumber) {
@@ -1702,7 +1892,7 @@ fn: function (aNumber) {
 smalltalk.Number);
 
 smalltalk.addMethod(
-"_\x5c\x5c",
+"__backslash_backslash",
 smalltalk.method({
 selector: "\x5c\x5c",
 fn: function (aNumber) {
@@ -2146,7 +2336,7 @@ fn: function () {
 smalltalk.Number);
 
 smalltalk.addMethod(
-"_|",
+"__or",
 smalltalk.method({
 selector: "|",
 fn: function (aNumber) {
@@ -2176,11 +2366,11 @@ smalltalk.addMethod(
 "_addElement_",
 smalltalk.method({
 selector: "addElement:",
-fn: function (anObject) {
-    var self = this;
-    self.addElement(anObject);
-    return self;
-}
+fn: function (anObject){
+var self=this;
+return smalltalk.withContext(function($ctx1) { 
self.elements.addElement(anObject);
+;
+return self}, self, "addElement:", [anObject], smalltalk.Organizer)}
 }),
 smalltalk.Organizer);
 
@@ -2201,11 +2391,11 @@ smalltalk.addMethod(
 "_removeElement_",
 smalltalk.method({
 selector: "removeElement:",
-fn: function (anObject) {
-    var self = this;
-    self.removeElement(anObject);
-    return self;
-}
+fn: function (anObject){
+var self=this;
+return smalltalk.withContext(function($ctx1) { 
self.elements.removeElement(anObject);
+;
+return self}, self, "removeElement:", [anObject], smalltalk.Organizer)}
 }),
 smalltalk.Organizer);
 

+ 275 - 19
js/Kernel-Objects.js

@@ -968,7 +968,7 @@ referencedClasses: []
 smalltalk.Object);
 
 smalltalk.addMethod(
-"_~_eq",
+"__tild_eq",
 smalltalk.method({
 selector: "~=",
 category: 'comparing',
@@ -986,7 +986,7 @@ referencedClasses: []
 smalltalk.Object);
 
 smalltalk.addMethod(
-"_~~",
+"__tild_tild",
 smalltalk.method({
 selector: "~~",
 category: 'comparing',
@@ -1024,7 +1024,7 @@ smalltalk.Object.klass);
 smalltalk.addClass('Boolean', smalltalk.Object, [], 'Kernel-Objects');
 smalltalk.Boolean.comment="Boolean wraps the JavaScript `Boolean()` constructor. The `true` and `false` objects are the JavaScript boolean objects.\x0a\x0aBoolean defines the protocol for logic testing operations and conditional control structures for the logical values.\x0aBoolean instances are weither `true` or `false`."
 smalltalk.addMethod(
-"_&",
+"__and",
 smalltalk.method({
 selector: "&",
 category: 'controlling',
@@ -1281,7 +1281,7 @@ referencedClasses: []
 smalltalk.Boolean);
 
 smalltalk.addMethod(
-"_|",
+"__or",
 smalltalk.method({
 selector: "|",
 category: 'controlling',
@@ -1303,6 +1303,262 @@ smalltalk.Boolean);
 
 
 
+smalltalk.addClass('CompiledMethod', smalltalk.Object, [], 'Kernel-Methods');
+smalltalk.CompiledMethod.comment="CompiledMethod hold the source and compiled code of a class method.\x0a\x0aYou can get a CompiledMethod using `Behavior>>methodAt:`\x0a\x0a\x09String methodAt: 'lines'\x0a\x0aand read the source code\x0a\x0a\x09(String methodAt: 'lines') source\x0a\x0aSee referenced classes:\x0a\x0a\x09(String methodAt: 'lines') referencedClasses\x0a\x0aor messages sent from this method:\x0a\x09\x0a\x09(String methodAt: 'lines')  messageSends"
+smalltalk.addMethod(
+"_arguments",
+smalltalk.method({
+selector: "arguments",
+category: 'accessing',
+fn: function () {
+    var self = this;
+    return self.args || [];
+    return self;
+},
+args: [],
+source: "arguments\x0a\x09<return self.args || []>",
+messageSends: [],
+referencedClasses: []
+}),
+smalltalk.CompiledMethod);
+
+smalltalk.addMethod(
+"_category",
+smalltalk.method({
+selector: "category",
+category: 'accessing',
+fn: function () {
+    var self = this;
+    var $2, $1;
+    $2 = smalltalk.send(self, "_basicAt_", ["category"]);
+    if (($receiver = $2) == nil || $receiver == undefined) {
+        $1 = "";
+    } else {
+        $1 = $2;
+    }
+    return $1;
+},
+args: [],
+source: "category\x0a\x09^(self basicAt: 'category') ifNil: ['']",
+messageSends: ["ifNil:", "basicAt:"],
+referencedClasses: []
+}),
+smalltalk.CompiledMethod);
+
+smalltalk.addMethod(
+"_category_",
+smalltalk.method({
+selector: "category:",
+category: 'accessing',
+fn: function (aString){
+var self=this;
+var $1;
+var oldCategory;
+oldCategory=smalltalk.send(self,"_category",[]);
+smalltalk.send(self,"_basicAt_put_",["category",aString]);
+$1=smalltalk.send(self,"_methodClass",[]);
+if(($receiver = $1) == nil || $receiver == undefined){
+$1;
+} else {
+smalltalk.send(smalltalk.send(smalltalk.send(self,"_methodClass",[]),"_organization",[]),"_addElement_",[aString]);
+smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.send(self,"_methodClass",[]),"_methods",[]),"_select_",[(function(each){
+return smalltalk.send(smalltalk.send(each,"_category",[]),"__eq",[oldCategory]);
+})]),"_ifEmpty_",[(function(){
+return smalltalk.send(smalltalk.send(smalltalk.send(self,"_methodClass",[]),"_organization",[]),"_removeElement_",[oldCategory]);
+})]);
+};
+return self},
+args: ["aString"],
+source: "category: aString\x0a\x09| oldCategory |\x0a    oldCategory := self category.\x0a\x09self basicAt: 'category' put: aString.\x0a    \x0a    self methodClass ifNotNil: [\x0a    \x09self methodClass organization addElement: aString.\x0a    \x0a\x09\x09(self methodClass methods \x0a    \x09\x09select: [ :each | each category = oldCategory ])\x0a        \x09ifEmpty: [ self methodClass organization removeElement: oldCategory ] ]",
+messageSends: ["category", "basicAt:put:", "ifNotNil:", "addElement:", "organization", "methodClass", "ifEmpty:", "removeElement:", "select:", "=", "methods"],
+referencedClasses: []
+}),
+smalltalk.CompiledMethod);
+
+smalltalk.addMethod(
+"_fn",
+smalltalk.method({
+selector: "fn",
+category: 'accessing',
+fn: function () {
+    var self = this;
+    var $1;
+    $1 = smalltalk.send(self, "_basicAt_", ["fn"]);
+    return $1;
+},
+args: [],
+source: "fn\x0a\x09^self basicAt: 'fn'",
+messageSends: ["basicAt:"],
+referencedClasses: []
+}),
+smalltalk.CompiledMethod);
+
+smalltalk.addMethod(
+"_fn_",
+smalltalk.method({
+selector: "fn:",
+category: 'accessing',
+fn: function (aBlock) {
+    var self = this;
+    smalltalk.send(self, "_basicAt_put_", ["fn", aBlock]);
+    return self;
+},
+args: ["aBlock"],
+source: "fn: aBlock\x0a\x09self basicAt: 'fn' put: aBlock",
+messageSends: ["basicAt:put:"],
+referencedClasses: []
+}),
+smalltalk.CompiledMethod);
+
+smalltalk.addMethod(
+"_messageSends",
+smalltalk.method({
+selector: "messageSends",
+category: 'accessing',
+fn: function () {
+    var self = this;
+    var $1;
+    $1 = smalltalk.send(self, "_basicAt_", ["messageSends"]);
+    return $1;
+},
+args: [],
+source: "messageSends\x0a\x09^self basicAt: 'messageSends'",
+messageSends: ["basicAt:"],
+referencedClasses: []
+}),
+smalltalk.CompiledMethod);
+
+smalltalk.addMethod(
+"_methodClass",
+smalltalk.method({
+selector: "methodClass",
+category: 'accessing',
+fn: function () {
+    var self = this;
+    var $1;
+    $1 = smalltalk.send(self, "_basicAt_", ["methodClass"]);
+    return $1;
+},
+args: [],
+source: "methodClass\x0a\x09^self basicAt: 'methodClass'",
+messageSends: ["basicAt:"],
+referencedClasses: []
+}),
+smalltalk.CompiledMethod);
+
+smalltalk.addMethod(
+"_protocol",
+smalltalk.method({
+selector: "protocol",
+category: 'accessing',
+fn: function () {
+    var self = this;
+    var $1;
+    $1 = smalltalk.send(self, "_category", []);
+    return $1;
+},
+args: [],
+source: "protocol\x0a\x09^ self category",
+messageSends: ["category"],
+referencedClasses: []
+}),
+smalltalk.CompiledMethod);
+
+smalltalk.addMethod(
+"_referencedClasses",
+smalltalk.method({
+selector: "referencedClasses",
+category: 'accessing',
+fn: function () {
+    var self = this;
+    var $1;
+    $1 = smalltalk.send(self, "_basicAt_", ["referencedClasses"]);
+    return $1;
+},
+args: [],
+source: "referencedClasses\x0a\x09^self basicAt: 'referencedClasses'",
+messageSends: ["basicAt:"],
+referencedClasses: []
+}),
+smalltalk.CompiledMethod);
+
+smalltalk.addMethod(
+"_selector",
+smalltalk.method({
+selector: "selector",
+category: 'accessing',
+fn: function () {
+    var self = this;
+    var $1;
+    $1 = smalltalk.send(self, "_basicAt_", ["selector"]);
+    return $1;
+},
+args: [],
+source: "selector\x0a\x09^self basicAt: 'selector'",
+messageSends: ["basicAt:"],
+referencedClasses: []
+}),
+smalltalk.CompiledMethod);
+
+smalltalk.addMethod(
+"_selector_",
+smalltalk.method({
+selector: "selector:",
+category: 'accessing',
+fn: function (aString) {
+    var self = this;
+    smalltalk.send(self, "_basicAt_put_", ["selector", aString]);
+    return self;
+},
+args: ["aString"],
+source: "selector: aString\x0a\x09self basicAt: 'selector' put: aString",
+messageSends: ["basicAt:put:"],
+referencedClasses: []
+}),
+smalltalk.CompiledMethod);
+
+smalltalk.addMethod(
+"_source",
+smalltalk.method({
+selector: "source",
+category: 'accessing',
+fn: function () {
+    var self = this;
+    var $2, $1;
+    $2 = smalltalk.send(self, "_basicAt_", ["source"]);
+    if (($receiver = $2) == nil || $receiver == undefined) {
+        $1 = "";
+    } else {
+        $1 = $2;
+    }
+    return $1;
+},
+args: [],
+source: "source\x0a\x09^(self basicAt: 'source') ifNil: ['']",
+messageSends: ["ifNil:", "basicAt:"],
+referencedClasses: []
+}),
+smalltalk.CompiledMethod);
+
+smalltalk.addMethod(
+"_source_",
+smalltalk.method({
+selector: "source:",
+category: 'accessing',
+fn: function (aString) {
+    var self = this;
+    smalltalk.send(self, "_basicAt_put_", ["source", aString]);
+    return self;
+},
+args: ["aString"],
+source: "source: aString\x0a\x09self basicAt: 'source' put: aString",
+messageSends: ["basicAt:put:"],
+referencedClasses: []
+}),
+smalltalk.CompiledMethod);
+
+
+
 smalltalk.addClass('Date', smalltalk.Object, [], 'Kernel-Objects');
 smalltalk.Date.comment="The Date class is used to work with dates and times. Therefore `Date today` and `Date now` are both valid in\x0aAmber and answer the same date object.\x0a\x0aDate wraps the `Date()` JavaScript constructor, and Smalltalk date objects are JavaScript date objects."
 smalltalk.addMethod(
@@ -2169,7 +2425,7 @@ smalltalk.JSObjectProxy.klass);
 smalltalk.addClass('Number', smalltalk.Object, [], 'Kernel-Objects');
 smalltalk.Number.comment="Number holds the most general methods for dealing with numbers.  \x0aNumber is directly mapped to JavaScript Number.\x0a\x0aMost arithmetic methods like `#+` `#/` `#-` `#max:` are directly inlined into javascript. \x0a\x0a##Enumerating\x0aA Number can be used to evaluate a Block a fixed number of times:\x0a\x0a\x095 timesRepeat: [Transcript show: 'This will be printed 5 times'; cr].\x0a\x09\x0a\x091 to: 5 do: [:aNumber| Transcript show: aNumber asString; cr].\x0a\x09\x0a\x091 to: 10 by: 2 do: [:aNumber| Transcript show: aNumber asString; cr]."
 smalltalk.addMethod(
-"_&",
+"__and",
 smalltalk.method({
 selector: "&",
 category: 'converting',
@@ -2362,7 +2618,7 @@ referencedClasses: ["Point"]
 smalltalk.Number);
 
 smalltalk.addMethod(
-"_\x5c\x5c",
+"__backslash_backslash",
 smalltalk.method({
 selector: "\x5c\x5c",
 category: 'arithmetic',
@@ -2966,7 +3222,7 @@ referencedClasses: []
 smalltalk.Number);
 
 smalltalk.addMethod(
-"_|",
+"__or",
 smalltalk.method({
 selector: "|",
 category: 'converting',
@@ -3007,13 +3263,13 @@ smalltalk.addMethod(
 smalltalk.method({
 selector: "addElement:",
 category: 'accessing',
-fn: function (anObject) {
-    var self = this;
-    self.addElement(anObject);
-    return self;
-},
+fn: function (anObject){
+var self=this;
+return smalltalk.withContext(function($ctx1) { 
self.elements.addElement(anObject);
+;
+return self}, self, "addElement:", [anObject], smalltalk.Organizer)},
 args: ["anObject"],
-source: "addElement: anObject\x0a\x09<self.addElement(anObject)>",
+source: "addElement: anObject\x0a\x09<self.elements.addElement(anObject)>",
 messageSends: [],
 referencedClasses: []
 }),
@@ -3042,13 +3298,13 @@ smalltalk.addMethod(
 smalltalk.method({
 selector: "removeElement:",
 category: 'accessing',
-fn: function (anObject) {
-    var self = this;
-    self.removeElement(anObject);
-    return self;
-},
+fn: function (anObject){
+var self=this;
+return smalltalk.withContext(function($ctx1) { 
self.elements.removeElement(anObject);
+;
+return self}, self, "removeElement:", [anObject], smalltalk.Organizer)},
 args: ["anObject"],
-source: "removeElement: anObject\x0a\x09<self.removeElement(anObject)>",
+source: "removeElement: anObject\x0a\x09<self.elements.removeElement(anObject)>",
 messageSends: [],
 referencedClasses: []
 }),

+ 40 - 29
st/Compiler-IR.st

@@ -96,6 +96,7 @@ visitBlockNode: aNode
 	aNode scope temps do: [ :each |
 		closure add: (IRTempDeclaration new 
 			name: each name;
+            scope: aNode scope;
 			yourself) ].
 	aNode nodes do: [ :each | closure add: (self visit: each) ].
 	^ closure
@@ -163,6 +164,7 @@ visitMethodNode: aNode
 	aNode scope temps do: [ :each |
 		self method add: (IRTempDeclaration new
 			name: each name;
+            scope: aNode scope;
 			yourself) ].
 
 	aNode nodes do: [ :each | self method add: (self visit: each) ].
@@ -561,6 +563,26 @@ accept: aVisitor
 	^ aVisitor visitIRNonLocalReturn: self
 ! !
 
+IRScopedInstruction subclass: #IRTempDeclaration
+	instanceVariableNames: 'name'
+	package: 'Compiler-IR'!
+
+!IRTempDeclaration methodsFor: 'accessing'!
+
+name
+	^ name
+!
+
+name: aString
+	name := aString
+! !
+
+!IRTempDeclaration methodsFor: 'visiting'!
+
+accept: aVisitor
+	^ aVisitor visitIRTempDeclaration: self
+! !
+
 IRInstruction subclass: #IRSend
 	instanceVariableNames: 'selector classSend index'
 	package: 'Compiler-IR'!
@@ -637,32 +659,6 @@ accept: aVisitor
 	^ aVisitor visitIRBlockSequence: self
 ! !
 
-IRInstruction subclass: #IRTempDeclaration
-	instanceVariableNames: 'name'
-	package: 'Compiler-IR'!
-!IRTempDeclaration commentStamp!
-I am a temporary variable declaration instruction!
-
-!IRTempDeclaration methodsFor: 'accessing'!
-
-name
-	^ name
-!
-
-name: aString
-	name := aString
-! !
-
-!IRTempDeclaration methodsFor: 'visiting'!
-
-accept: aVisitor
-	^ aVisitor visitIRTempDeclaration: self
-!
-
-isTempDeclaration
-	^ true
-! !
-
 IRInstruction subclass: #IRValue
 	instanceVariableNames: 'value'
 	package: 'Compiler-IR'!
@@ -855,7 +851,10 @@ visitIRAssignment: anIRAssignment
 
 visitIRClosure: anIRClosure
 	self stream 
-		nextPutClosureWith: [ super visitIRClosure: anIRClosure ] 
+		nextPutClosureWith: [ 
+        	self stream 
+            	nextPutBlockContextFor: anIRClosure
+                during: [ super visitIRClosure: anIRClosure ] ]
 		arguments: anIRClosure arguments
 !
 
@@ -952,7 +951,9 @@ visitIRSequence: anIRSequence
 !
 
 visitIRTempDeclaration: anIRTempDeclaration
-	self stream nextPutVar: anIRTempDeclaration name asVariableName
+	self stream 
+    	nextPutAll: anIRTempDeclaration scope alias, '.', anIRTempDeclaration name, '=nil;'; 
+        lf
 !
 
 visitIRValue: anIRValue
@@ -1005,6 +1006,14 @@ nextPutAssignment
 	stream nextPutAll: '='
 !
 
+nextPutBlockContextFor: anIRClosure during: aBlock
+	self 
+    	nextPutAll: 'return smalltalk.withContext(function(', anIRClosure scope alias, ') { '; 
+        nextPutAll: String cr.
+    aBlock value.
+    self nextPutAll: '})'
+!
+
 nextPutClosureWith: aBlock arguments: anArray
 	stream nextPutAll: '(function('.
 	anArray 
@@ -1016,7 +1025,9 @@ nextPutClosureWith: aBlock arguments: anArray
 !
 
 nextPutContextFor: aMethod during: aBlock
-	self nextPutAll: 'return smalltalk.withContext(function($ctx) { '.
+	self 
+    	nextPutAll: 'return smalltalk.withContext(function(', aMethod scope alias, ') { '; 
+        nextPutAll: String cr.
     aBlock value.
     self 
     	nextPutAll: '}, self, ';

+ 38 - 55
st/Kernel-Objects.st

@@ -68,11 +68,15 @@ identityHash
 !
 
 instVarAt: aSymbol
-	<return self['@'+aSymbol._asString()]>
+	| varname |
+	varname := aSymbol asString.
+	<return self['@'+varname]>
 !
 
 instVarAt: aSymbol put: anObject
-	<self['@' + aSymbol._asString()] = anObject>
+	| varname |
+	varname := aSymbol asString.
+	<self['@' + varname] = anObject>
 !
 
 size
@@ -225,7 +229,9 @@ perform: aSymbol
 !
 
 perform: aSymbol withArguments: aCollection
-	<return smalltalk.send(self, aSymbol._asSelector(), aCollection)>
+	| selector |
+	selector := aSymbol asSelector.
+	<return smalltalk.send(self, selector, aCollection)>
 ! !
 
 !Object methodsFor: 'printing'!
@@ -497,10 +503,6 @@ methodClass
 	^self basicAt: 'methodClass'
 !
 
-printString
-	^ self methodClass name, ' >> ', self selector
-!
-
 protocol
 	^ self category
 !
@@ -739,11 +741,15 @@ __Note:__ For keyword-based messages, only the first keyword is kept: `window fo
 !JSObjectProxy methodsFor: 'accessing'!
 
 at: aSymbol
-	<return self['@jsObject'][aSymbol._asString()]>
+	| attr |
+	attr := aSymbol asString.
+	<return self['@jsObject'][attr]>
 !
 
 at: aSymbol put: anObject
-	<self['@jsObject'][aSymbol._asString()] = anObject>
+	| attr |
+	attr := aSymbol asString.
+	<self['@jsObject'][attr] = anObject>
 !
 
 jsObject
@@ -756,39 +762,27 @@ jsObject: aJSObject
 
 !JSObjectProxy methodsFor: 'proxy'!
 
-canUnderstand: aSelector
-	<return self._jsObject()[aSelector._asJavaScriptSelector()] !!= undefined>
-!
-
 doesNotUnderstand: aMessage
 	| obj selector jsSelector arguments |
 	obj := self jsObject.
 	selector := aMessage selector.
 	jsSelector := selector asJavaScriptSelector.
 	arguments := aMessage arguments.
-    (self canUnderstand: selector) ifTrue: [
-      	^ Smalltalk current basicSend: jsSelector to: obj arguments: arguments ].
+	<if(obj[jsSelector] !!= undefined) {return smalltalk.send(obj, jsSelector, arguments)}>.
 	super doesNotUnderstand: aMessage
 !
 
 inspectOn: anInspector
 	| variables |
-	variables := self inspectorVariables.
+	variables := Dictionary new.
 	variables at: '#self' put: self jsObject.
 	anInspector setLabel: self printString.
+	<for(var i in self['@jsObject']) {
+		variables._at_put_(i, self['@jsObject'][i]);
+	}>.
 	anInspector setVariables: variables
 !
 
-inspectorVariables
-	<
-    	var variables = smalltalk.Dictionary._new();
-        for(var i in self['@jsObject']) {
-			variables._at_put_(i, self['@jsObject'][i]);
-		};
-        return variables
-    >
-!
-
 printString
 	^self jsObject toString
 ! !
@@ -851,10 +845,6 @@ identityHash
 	<return self % aNumber>
 !
 
-\\ aNumber
-	<return self % aNumber>
-!
-
 abs
 	^ <Math.abs(self);>
 !
@@ -972,13 +962,13 @@ to: stop by: step
 !
 
 truncated
-	<
-    	if(self >>= 0) {
-        	return Math.floor(self);
-        } else {
-        	return Math.floor(self * (-1)) * (-1);
-        }
-    >
+|result|
+
+    self >= 0 
+        ifTrue: [<result = Math.floor(self);>]
+        ifFalse: [<result = (Math.floor(self * (-1)) * (-1));>].
+
+    ^ result
 !
 
 | aNumber
@@ -1171,7 +1161,8 @@ properties
 properties: aDict
 	"We store it as a javascript object."
 	
-	<var object = {};>.
+	| object |
+	<object = {};>.
 	aDict keysAndValuesDo: [:key :value |
 		<object[key] = value>.
 	].
@@ -1488,10 +1479,6 @@ basicParse: aString
 	<return smalltalk.parser.parse(aString)>
 !
 
-basicSend: aSelector to: anObject arguments: aCollection
-	<return self.send(anObject, aSelector, aCollection)>
-!
-
 parse: aString
 	| result | 
 	self try: [result := self basicParse: aString] catch: [:ex | (self parseError: ex parsing: aString) signal].
@@ -1500,9 +1487,9 @@ parse: aString
 
 parseError: anException parsing: aString
 	| row col message lines badLine code |
-	row := anException basicAt: 'line'.
-    col := anException basicAt: 'column'.
-    message := anException basicAt: 'message'.
+	<row = anException.line;
+	col = anException.column;
+	message = anException.message;>.
 	lines := aString lines.
 	badLine := lines at: row.
 	badLine := (badLine copyFrom: 1 to: col - 1), ' ===>', (badLine copyFrom:  col to: badLine size).
@@ -1523,7 +1510,9 @@ reservedWords
 !
 
 send: aSelector to: anObject arguments: aCollection
-	^ self basicSend: aSelector asString asSelector to: anObject arguments: aCollection
+	| selector |
+	selector := aSelector asString asSelector.
+	<return self.send(anObject, selector, aCollection)>
 ! !
 
 !Smalltalk methodsFor: 'classes'!
@@ -1559,10 +1548,6 @@ packageAt: packageName ifAbsent: aBlock
        ^(self packageAt: packageName) ifNil: aBlock
 !
 
-packageAt: packageName put: aPackage
-       <return self.packages[packageName] = aPackage>
-!
-
 packages
 	"Return all Package instances in the system."
 
@@ -1589,7 +1574,7 @@ renamePackage: packageName to: newName
 	| pkg |
 	pkg := self packageAt: packageName ifAbsent: [self error: 'Missing package: ', packageName].
 	(self packageAt: newName) ifNotNil: [self error: 'Already exists a package called: ', newName].
-	self packageAt: newName put: pkg.
+	<smalltalk.packages[newName] = smalltalk.packages[packageName]>.
 	pkg name: newName.
 	self deletePackage: packageName.
 ! !
@@ -1605,7 +1590,8 @@ createPackage: packageName
 createPackage: packageName properties: aDict
 	"Create and bind a new package with given name and return it."
 
-	<var object = {};>.
+	| object |
+	<object = {};>.
 	aDict keysAndValuesDo: [:key :value |
 		<object[key] = value>.
 	].
@@ -1660,9 +1646,6 @@ subclass: aString instanceVariableNames: aString2 package: aString3
 
 !UndefinedObject methodsFor: 'converting'!
 
-accept: aVisitor
-!
-
 asJSON
 	^null
 ! !