1
0
Bläddra i källkod

Merge branch 'master' into helios

Nicolas Petton 12 år sedan
förälder
incheckning
2bf1bd23bd

Filskillnaden har hållts tillbaka eftersom den är för stor
+ 161 - 123
js/Compiler-Interpreter.deploy.js


Filskillnaden har hållts tillbaka eftersom den är för stor
+ 173 - 125
js/Compiler-Interpreter.js


+ 14 - 0
js/Compiler-Tests.deploy.js

@@ -270,6 +270,20 @@ return self}, function($ctx1) {$ctx1.fill(self,"testTempAssignment",{},smalltalk
 messageSends: ["assert:equals:", "interpret:"]}),
 smalltalk.ASTInterpreterTest);
 
+smalltalk.addMethod(
+"_testThisContext",
+smalltalk.method({
+selector: "testThisContext",
+fn: function (){
+var self=this;
+return smalltalk.withContext(function($ctx1) { 
+_st(self)._assert_(_st(_st(_st(self)._interpret_("foo ^ thisContext"))._outerContext())._isNil());
+_st(self)._assert_(_st(_st(_st(self)._interpret_("foo ^ [ thisContext ] value"))._outerContext())._notNil());
+_st(self)._assert_(_st(self)._interpret_("foo ^ [ thisContext ] value outerContext == thisContext"));
+return self}, function($ctx1) {$ctx1.fill(self,"testThisContext",{},smalltalk.ASTInterpreterTest)})},
+messageSends: ["assert:", "isNil", "outerContext", "interpret:", "notNil"]}),
+smalltalk.ASTInterpreterTest);
+
 
 
 smalltalk.addClass('ASTSteppingInterpreterTest', smalltalk.AbstractASTInterpreterTest, ['interpreter'], 'Compiler-Tests');

+ 19 - 0
js/Compiler-Tests.js

@@ -365,6 +365,25 @@ referencedClasses: []
 }),
 smalltalk.ASTInterpreterTest);
 
+smalltalk.addMethod(
+"_testThisContext",
+smalltalk.method({
+selector: "testThisContext",
+category: 'tests',
+fn: function (){
+var self=this;
+return smalltalk.withContext(function($ctx1) { 
+_st(self)._assert_(_st(_st(_st(self)._interpret_("foo ^ thisContext"))._outerContext())._isNil());
+_st(self)._assert_(_st(_st(_st(self)._interpret_("foo ^ [ thisContext ] value"))._outerContext())._notNil());
+_st(self)._assert_(_st(self)._interpret_("foo ^ [ thisContext ] value outerContext == thisContext"));
+return self}, function($ctx1) {$ctx1.fill(self,"testThisContext",{},smalltalk.ASTInterpreterTest)})},
+args: [],
+source: "testThisContext\x0a\x09self assert: (self interpret: 'foo ^ thisContext') outerContext isNil.\x0a\x09self assert: (self interpret: 'foo ^ [ thisContext ] value') outerContext notNil.\x0a\x09self assert: (self interpret: 'foo ^ [ thisContext ] value outerContext == thisContext')",
+messageSends: ["assert:", "isNil", "outerContext", "interpret:", "notNil"],
+referencedClasses: []
+}),
+smalltalk.ASTInterpreterTest);
+
 
 
 smalltalk.addClass('ASTSteppingInterpreterTest', smalltalk.AbstractASTInterpreterTest, ['interpreter'], 'Compiler-Tests');

+ 6 - 42
js/Importer-Exporter.deploy.js

@@ -1,7 +1,6 @@
 smalltalk.addPackage('Importer-Exporter');
 smalltalk.addClass('ChunkParser', smalltalk.Object, ['stream'], 'Importer-Exporter');
 smalltalk.addMethod(
-"_nextChunk",
 smalltalk.method({
 selector: "nextChunk",
 fn: function () {
@@ -39,7 +38,6 @@ messageSends: ["writeStream", "whileTrue:", "ifTrue:", "ifTrue:ifFalse:", "next"
 smalltalk.ChunkParser);
 
 smalltalk.addMethod(
-"_stream_",
 smalltalk.method({
 selector: "stream:",
 fn: function (aStream) {
@@ -52,7 +50,6 @@ smalltalk.ChunkParser);
 
 
 smalltalk.addMethod(
-"_on_",
 smalltalk.method({
 selector: "on:",
 fn: function (aStream) {
@@ -68,7 +65,6 @@ smalltalk.ChunkParser.klass);
 
 smalltalk.addClass('Exporter', smalltalk.Object, [], 'Importer-Exporter');
 smalltalk.addMethod(
-"_classNameFor_",
 smalltalk.method({
 selector: "classNameFor:",
 fn: function (aClass) {
@@ -92,7 +88,6 @@ messageSends: ["ifTrue:ifFalse:", ",", "name", "instanceClass", "isNil", "isMeta
 smalltalk.Exporter);
 
 smalltalk.addMethod(
-"_exportAll",
 smalltalk.method({
 selector: "exportAll",
 fn: function () {
@@ -114,7 +109,6 @@ messageSends: ["streamContents:", "do:", "nextPutAll:", "exportPackage:", "name"
 smalltalk.Exporter);
 
 smalltalk.addMethod(
-"_exportClass_",
 smalltalk.method({
 selector: "exportClass:",
 fn: function (aClass) {
@@ -135,7 +129,6 @@ messageSends: ["streamContents:", "exportDefinitionOf:on:", "exportMethodsOf:on:
 smalltalk.Exporter);
 
 smalltalk.addMethod(
-"_exportDefinitionOf_on_",
 smalltalk.method({
 selector: "exportDefinitionOf:on:",
 fn: function (aClass, aStream) {
@@ -174,7 +167,6 @@ messageSends: ["nextPutAll:", ",", "classNameFor:", "superclass", "do:separatedB
 smalltalk.Exporter);
 
 smalltalk.addMethod(
-"_exportMetaDefinitionOf_on_",
 smalltalk.method({
 selector: "exportMetaDefinitionOf:on:",
 fn: function (aClass, aStream) {
@@ -202,18 +194,15 @@ messageSends: ["ifFalse:", "nextPutAll:", ",", "classNameFor:", "class", "do:sep
 smalltalk.Exporter);
 
 smalltalk.addMethod(
-"_exportMethod_of_on_",
 smalltalk.method({
 selector: "exportMethod:of:on:",
-fn: function (aMethod, aClass, aStream) {
+fn: function (aMethod,aClass,aStream){
 var self=this;
 return smalltalk.withContext(function($ctx1) { 
 var $1,$2,$3,$4;
 $1=aStream;
 _st($1)._nextPutAll_("smalltalk.addMethod(");
 _st($1)._lf();
-_st($1)._nextPutAll_(_st(_st(_st(_st(aMethod)._selector())._asSelector())._asJavascript()).__comma(","));
-_st($1)._lf();
 _st($1)._nextPutAll_("smalltalk.method({");
 _st($1)._lf();
 _st($1)._nextPutAll_(_st(_st("selector: ").__comma(_st(_st(aMethod)._selector())._asJavascript())).__comma(","));
@@ -237,12 +226,11 @@ _st($3)._nextPutAll_(_st("smalltalk.").__comma(_st(self)._classNameFor_(aClass))
 _st($3)._nextPutAll_(");");
 _st($3)._lf();
 $4=_st($3)._lf();
-return self}, function($ctx1) {$ctx1.fill(self,"exportMethod:of:on:",{aMethod:aMethod,aClass:aClass,aStream:aStream},smalltalk.Exporter)});},
-messageSends: ["nextPutAll:", "lf", ",", "asJavascript", "asSelector", "selector", "category", "compiledSource", "fn", "arguments", "source", "messageSends", "referencedClasses", "classNameFor:"]}),
+return self}, function($ctx1) {$ctx1.fill(self,"exportMethod:of:on:",{aMethod:aMethod,aClass:aClass,aStream:aStream},smalltalk.Exporter)})},
+messageSends: ["nextPutAll:", "lf", ",", "asJavascript", "selector", "category", "compiledSource", "fn", "arguments", "source", "messageSends", "referencedClasses", "classNameFor:"]}),
 smalltalk.Exporter);
 
 smalltalk.addMethod(
-"_exportMethodsOf_on_",
 smalltalk.method({
 selector: "exportMethodsOf:on:",
 fn: function (aClass, aStream) {
@@ -265,7 +253,6 @@ messageSends: ["do:", "ifFalse:", "exportMethod:of:on:", "match:", "category", "
 smalltalk.Exporter);
 
 smalltalk.addMethod(
-"_exportPackage_",
 smalltalk.method({
 selector: "exportPackage:",
 fn: function (packageName) {
@@ -292,7 +279,6 @@ messageSends: ["streamContents:", "packageAt:", "current", "exportPackageDefinit
 smalltalk.Exporter);
 
 smalltalk.addMethod(
-"_exportPackageDefinitionOf_on_",
 smalltalk.method({
 selector: "exportPackageDefinitionOf:on:",
 fn: function (package_, aStream) {
@@ -308,7 +294,6 @@ messageSends: ["nextPutAll:", ",", "name", "lf"]}),
 smalltalk.Exporter);
 
 smalltalk.addMethod(
-"_exportPackageExtensionsOf_on_",
 smalltalk.method({
 selector: "exportPackageExtensionsOf:on:",
 fn: function (package_, aStream) {
@@ -343,7 +328,6 @@ smalltalk.Exporter);
 
 smalltalk.addClass('ChunkExporter', smalltalk.Exporter, [], 'Importer-Exporter');
 smalltalk.addMethod(
-"_chunkEscape_",
 smalltalk.method({
 selector: "chunkEscape:",
 fn: function (aString) {
@@ -357,7 +341,6 @@ messageSends: ["trimBoth", "replace:with:"]}),
 smalltalk.ChunkExporter);
 
 smalltalk.addMethod(
-"_classNameFor_",
 smalltalk.method({
 selector: "classNameFor:",
 fn: function (aClass) {
@@ -381,7 +364,6 @@ messageSends: ["ifTrue:ifFalse:", ",", "name", "instanceClass", "isNil", "isMeta
 smalltalk.ChunkExporter);
 
 smalltalk.addMethod(
-"_exportDefinitionOf_on_",
 smalltalk.method({
 selector: "exportDefinitionOf:on:",
 fn: function (aClass, aStream) {
@@ -422,7 +404,6 @@ messageSends: ["nextPutAll:", "classNameFor:", "superclass", ",", "lf", "tab", "
 smalltalk.ChunkExporter);
 
 smalltalk.addMethod(
-"_exportMetaDefinitionOf_on_",
 smalltalk.method({
 selector: "exportMetaDefinitionOf:on:",
 fn: function (aClass, aStream) {
@@ -453,7 +434,6 @@ messageSends: ["ifFalse:", "nextPutAll:", "classNameFor:", "class", "do:separate
 smalltalk.ChunkExporter);
 
 smalltalk.addMethod(
-"_exportMethod_of_on_",
 smalltalk.method({
 selector: "exportMethod:of:on:",
 fn: function (aMethod, aClass, aStream) {
@@ -471,7 +451,6 @@ messageSends: ["lf", "nextPutAll:", "chunkEscape:", "source"]}),
 smalltalk.ChunkExporter);
 
 smalltalk.addMethod(
-"_exportMethods_category_of_on_",
 smalltalk.method({
 selector: "exportMethods:category:of:on:",
 fn: function (methods, category, aClass, aStream) {
@@ -497,7 +476,6 @@ messageSends: ["nextPutAll:", ",", "classNameFor:", "do:", "exportMethod:of:on:"
 smalltalk.ChunkExporter);
 
 smalltalk.addMethod(
-"_exportMethodsOf_on_",
 smalltalk.method({
 selector: "exportMethodsOf:on:",
 fn: function (aClass, aStream) {
@@ -529,7 +507,6 @@ messageSends: ["new", "protocolsDo:", "ifFalse:", "at:put:", "match:", "do:", "a
 smalltalk.ChunkExporter);
 
 smalltalk.addMethod(
-"_exportPackageDefinitionOf_on_",
 smalltalk.method({
 selector: "exportPackageDefinitionOf:on:",
 fn: function (package_, aStream) {
@@ -544,7 +521,6 @@ messageSends: ["nextPutAll:", ",", "name", "lf"]}),
 smalltalk.ChunkExporter);
 
 smalltalk.addMethod(
-"_exportPackageExtensionsOf_on_",
 smalltalk.method({
 selector: "exportPackageExtensionsOf:on:",
 fn: function (package_, aStream) {
@@ -589,7 +565,6 @@ smalltalk.ChunkExporter);
 
 smalltalk.addClass('StrippedExporter', smalltalk.Exporter, [], 'Importer-Exporter');
 smalltalk.addMethod(
-"_exportDefinitionOf_on_",
 smalltalk.method({
 selector: "exportDefinitionOf:on:",
 fn: function (aClass, aStream) {
@@ -618,18 +593,15 @@ messageSends: ["nextPutAll:", ",", "classNameFor:", "superclass", "do:separatedB
 smalltalk.StrippedExporter);
 
 smalltalk.addMethod(
-"_exportMethod_of_on_",
 smalltalk.method({
 selector: "exportMethod:of:on:",
-fn: function (aMethod, aClass, aStream) {
+fn: function (aMethod,aClass,aStream){
 var self=this;
 return smalltalk.withContext(function($ctx1) { 
 var $1,$2;
 $1=aStream;
 _st($1)._nextPutAll_("smalltalk.addMethod(");
 _st($1)._lf();
-_st($1)._nextPutAll_(_st(_st(_st(_st(aMethod)._selector())._asSelector())._asJavascript()).__comma(","));
-_st($1)._lf();
 _st($1)._nextPutAll_("smalltalk.method({");
 _st($1)._lf();
 _st($1)._nextPutAll_(_st(_st("selector: ").__comma(_st(_st(aMethod)._selector())._asJavascript())).__comma(","));
@@ -643,15 +615,14 @@ _st($1)._nextPutAll_(_st("smalltalk.").__comma(_st(self)._classNameFor_(aClass))
 _st($1)._nextPutAll_(");");
 _st($1)._lf();
 $2=_st($1)._lf();
-return self}, function($ctx1) {$ctx1.fill(self,"exportMethod:of:on:",{aMethod:aMethod,aClass:aClass,aStream:aStream},smalltalk.StrippedExporter)});},
-messageSends: ["nextPutAll:", "lf", ",", "asJavascript", "asSelector", "selector", "compiledSource", "fn", "messageSends", "classNameFor:"]}),
+return self}, function($ctx1) {$ctx1.fill(self,"exportMethod:of:on:",{aMethod:aMethod,aClass:aClass,aStream:aStream},smalltalk.StrippedExporter)})},
+messageSends: ["nextPutAll:", "lf", ",", "asJavascript", "selector", "compiledSource", "fn", "messageSends", "classNameFor:"]}),
 smalltalk.StrippedExporter);
 
 
 
 smalltalk.addClass('Importer', smalltalk.Object, [], 'Importer-Exporter');
 smalltalk.addMethod(
-"_import_",
 smalltalk.method({
 selector: "import:",
 fn: function (aStream) {
@@ -693,7 +664,6 @@ smalltalk.Importer);
 
 smalltalk.addClass('PackageHandler', smalltalk.Object, [], 'Importer-Exporter');
 smalltalk.addMethod(
-"_ajaxPutAt_data_",
 smalltalk.method({
 selector: "ajaxPutAt:data:",
 fn: function (aURL, aString) {
@@ -708,7 +678,6 @@ messageSends: ["ajax:options:", "->", "error:", ",", "responseText"]}),
 smalltalk.PackageHandler);
 
 smalltalk.addMethod(
-"_commit_",
 smalltalk.method({
 selector: "commit:",
 fn: function (aPackage) {
@@ -729,7 +698,6 @@ messageSends: ["do:", "exportPackage:", "name", "new", "key", "ajaxPutAt:data:",
 smalltalk.PackageHandler);
 
 smalltalk.addMethod(
-"_loadPackage_prefix_",
 smalltalk.method({
 selector: "loadPackage:prefix:",
 fn: function (packageName, aString) {
@@ -753,7 +721,6 @@ messageSends: [",", "ajax:options:", "->", "ifTrue:", "setupPackageNamed:prefix:
 smalltalk.PackageHandler);
 
 smalltalk.addMethod(
-"_loadPackages_prefix_",
 smalltalk.method({
 selector: "loadPackages:prefix:",
 fn: function (aCollection, aString) {
@@ -768,7 +735,6 @@ messageSends: ["do:", "loadPackage:prefix:"]}),
 smalltalk.PackageHandler);
 
 smalltalk.addMethod(
-"_setupPackageNamed_prefix_",
 smalltalk.method({
 selector: "setupPackageNamed:prefix:",
 fn: function (packageName, aString) {
@@ -786,7 +752,6 @@ smalltalk.PackageHandler);
 
 
 smalltalk.addMethod(
-"_loadPackages_prefix_",
 smalltalk.method({
 selector: "loadPackages:prefix:",
 fn: function (aCollection, aString) {
@@ -801,7 +766,6 @@ smalltalk.PackageHandler.klass);
 
 
 smalltalk.addMethod(
-"_commit",
 smalltalk.method({
 selector: "commit",
 fn: function () {

+ 8 - 44
js/Importer-Exporter.js

@@ -1,7 +1,6 @@
 smalltalk.addPackage('Importer-Exporter');
 smalltalk.addClass('ChunkParser', smalltalk.Object, ['stream'], 'Importer-Exporter');
 smalltalk.addMethod(
-"_nextChunk",
 smalltalk.method({
 selector: "nextChunk",
 category: 'reading',
@@ -44,7 +43,6 @@ referencedClasses: []
 smalltalk.ChunkParser);
 
 smalltalk.addMethod(
-"_stream_",
 smalltalk.method({
 selector: "stream:",
 category: 'accessing',
@@ -62,7 +60,6 @@ smalltalk.ChunkParser);
 
 
 smalltalk.addMethod(
-"_on_",
 smalltalk.method({
 selector: "on:",
 category: 'not yet classified',
@@ -83,7 +80,6 @@ smalltalk.ChunkParser.klass);
 
 smalltalk.addClass('Exporter', smalltalk.Object, [], 'Importer-Exporter');
 smalltalk.addMethod(
-"_classNameFor_",
 smalltalk.method({
 selector: "classNameFor:",
 category: 'private',
@@ -112,7 +108,6 @@ referencedClasses: []
 smalltalk.Exporter);
 
 smalltalk.addMethod(
-"_exportAll",
 smalltalk.method({
 selector: "exportAll",
 category: 'fileOut',
@@ -139,7 +134,6 @@ referencedClasses: ["Smalltalk", "String"]
 smalltalk.Exporter);
 
 smalltalk.addMethod(
-"_exportClass_",
 smalltalk.method({
 selector: "exportClass:",
 category: 'fileOut',
@@ -165,7 +159,6 @@ referencedClasses: ["String"]
 smalltalk.Exporter);
 
 smalltalk.addMethod(
-"_exportDefinitionOf_on_",
 smalltalk.method({
 selector: "exportDefinitionOf:on:",
 category: 'private',
@@ -209,7 +202,6 @@ referencedClasses: []
 smalltalk.Exporter);
 
 smalltalk.addMethod(
-"_exportMetaDefinitionOf_on_",
 smalltalk.method({
 selector: "exportMetaDefinitionOf:on:",
 category: 'private',
@@ -242,19 +234,16 @@ referencedClasses: ["String"]
 smalltalk.Exporter);
 
 smalltalk.addMethod(
-"_exportMethod_of_on_",
 smalltalk.method({
 selector: "exportMethod:of:on:",
 category: 'private',
-fn: function (aMethod, aClass, aStream) {
+fn: function (aMethod,aClass,aStream){
 var self=this;
 return smalltalk.withContext(function($ctx1) { 
 var $1,$2,$3,$4;
 $1=aStream;
 _st($1)._nextPutAll_("smalltalk.addMethod(");
 _st($1)._lf();
-_st($1)._nextPutAll_(_st(_st(_st(_st(aMethod)._selector())._asSelector())._asJavascript()).__comma(","));
-_st($1)._lf();
 _st($1)._nextPutAll_("smalltalk.method({");
 _st($1)._lf();
 _st($1)._nextPutAll_(_st(_st("selector: ").__comma(_st(_st(aMethod)._selector())._asJavascript())).__comma(","));
@@ -278,16 +267,15 @@ _st($3)._nextPutAll_(_st("smalltalk.").__comma(_st(self)._classNameFor_(aClass))
 _st($3)._nextPutAll_(");");
 _st($3)._lf();
 $4=_st($3)._lf();
-return self}, function($ctx1) {$ctx1.fill(self,"exportMethod:of:on:",{aMethod:aMethod,aClass:aClass,aStream:aStream},smalltalk.Exporter)});},
+return self}, function($ctx1) {$ctx1.fill(self,"exportMethod:of:on:",{aMethod:aMethod,aClass:aClass,aStream:aStream},smalltalk.Exporter)})},
 args: ["aMethod", "aClass", "aStream"],
-source: "exportMethod: aMethod of: aClass on: aStream\x0a\x09aStream\x0a\x09\x09nextPutAll: 'smalltalk.addMethod(';lf;\x0a\x09\x09nextPutAll: aMethod selector asSelector asJavascript, ',';lf;\x0a\x09\x09nextPutAll: 'smalltalk.method({';lf;\x0a\x09\x09nextPutAll: 'selector: ', aMethod selector asJavascript, ',';lf;\x0a\x09\x09nextPutAll: 'category: ''', aMethod category, ''',';lf;\x0a\x09\x09nextPutAll: 'fn: ', aMethod fn compiledSource, ',';lf;\x0a\x09\x09nextPutAll: 'args: ', aMethod arguments asJavascript, ','; lf;\x0a\x09\x09nextPutAll: 'source: ', aMethod source asJavascript, ',';lf;\x0a\x09\x09nextPutAll: 'messageSends: ', aMethod messageSends asJavascript, ',';lf;\x0a\x09\x09nextPutAll: 'referencedClasses: ', aMethod referencedClasses asJavascript.\x0a\x09aStream\x0a\x09\x09lf;\x0a\x09\x09nextPutAll: '}),';lf;\x0a\x09\x09nextPutAll: 'smalltalk.', (self classNameFor: aClass);\x0a\x09\x09nextPutAll: ');';lf;lf",
-messageSends: ["nextPutAll:", "lf", ",", "asJavascript", "asSelector", "selector", "category", "compiledSource", "fn", "arguments", "source", "messageSends", "referencedClasses", "classNameFor:"],
+source: "exportMethod: aMethod of: aClass on: aStream\x0a\x09aStream\x0a\x09\x09nextPutAll: 'smalltalk.addMethod(';lf;\x0a\x09\x09\x22nextPutAll: aMethod selector asSelector asJavascript, ',';lf;\x22\x0a\x09\x09nextPutAll: 'smalltalk.method({';lf;\x0a\x09\x09nextPutAll: 'selector: ', aMethod selector asJavascript, ',';lf;\x0a\x09\x09nextPutAll: 'category: ''', aMethod category, ''',';lf;\x0a\x09\x09nextPutAll: 'fn: ', aMethod fn compiledSource, ',';lf;\x0a\x09\x09nextPutAll: 'args: ', aMethod arguments asJavascript, ','; lf;\x0a\x09\x09nextPutAll: 'source: ', aMethod source asJavascript, ',';lf;\x0a\x09\x09nextPutAll: 'messageSends: ', aMethod messageSends asJavascript, ',';lf;\x0a\x09\x09nextPutAll: 'referencedClasses: ', aMethod referencedClasses asJavascript.\x0a\x09aStream\x0a\x09\x09lf;\x0a\x09\x09nextPutAll: '}),';lf;\x0a\x09\x09nextPutAll: 'smalltalk.', (self classNameFor: aClass);\x0a\x09\x09nextPutAll: ');';lf;lf",
+messageSends: ["nextPutAll:", "lf", ",", "asJavascript", "selector", "category", "compiledSource", "fn", "arguments", "source", "messageSends", "referencedClasses", "classNameFor:"],
 referencedClasses: []
 }),
 smalltalk.Exporter);
 
 smalltalk.addMethod(
-"_exportMethodsOf_on_",
 smalltalk.method({
 selector: "exportMethodsOf:on:",
 category: 'private',
@@ -315,7 +303,6 @@ referencedClasses: []
 smalltalk.Exporter);
 
 smalltalk.addMethod(
-"_exportPackage_",
 smalltalk.method({
 selector: "exportPackage:",
 category: 'fileOut',
@@ -347,7 +334,6 @@ referencedClasses: ["Smalltalk", "String"]
 smalltalk.Exporter);
 
 smalltalk.addMethod(
-"_exportPackageDefinitionOf_on_",
 smalltalk.method({
 selector: "exportPackageDefinitionOf:on:",
 category: 'private',
@@ -368,7 +354,6 @@ referencedClasses: []
 smalltalk.Exporter);
 
 smalltalk.addMethod(
-"_exportPackageExtensionsOf_on_",
 smalltalk.method({
 selector: "exportPackageExtensionsOf:on:",
 category: 'private',
@@ -408,7 +393,6 @@ smalltalk.Exporter);
 
 smalltalk.addClass('ChunkExporter', smalltalk.Exporter, [], 'Importer-Exporter');
 smalltalk.addMethod(
-"_chunkEscape_",
 smalltalk.method({
 selector: "chunkEscape:",
 category: 'not yet classified',
@@ -427,7 +411,6 @@ referencedClasses: []
 smalltalk.ChunkExporter);
 
 smalltalk.addMethod(
-"_classNameFor_",
 smalltalk.method({
 selector: "classNameFor:",
 category: 'not yet classified',
@@ -456,7 +439,6 @@ referencedClasses: []
 smalltalk.ChunkExporter);
 
 smalltalk.addMethod(
-"_exportDefinitionOf_on_",
 smalltalk.method({
 selector: "exportDefinitionOf:on:",
 category: 'not yet classified',
@@ -502,7 +484,6 @@ referencedClasses: []
 smalltalk.ChunkExporter);
 
 smalltalk.addMethod(
-"_exportMetaDefinitionOf_on_",
 smalltalk.method({
 selector: "exportMetaDefinitionOf:on:",
 category: 'not yet classified',
@@ -538,7 +519,6 @@ referencedClasses: []
 smalltalk.ChunkExporter);
 
 smalltalk.addMethod(
-"_exportMethod_of_on_",
 smalltalk.method({
 selector: "exportMethod:of:on:",
 category: 'not yet classified',
@@ -561,7 +541,6 @@ referencedClasses: []
 smalltalk.ChunkExporter);
 
 smalltalk.addMethod(
-"_exportMethods_category_of_on_",
 smalltalk.method({
 selector: "exportMethods:category:of:on:",
 category: 'not yet classified',
@@ -592,7 +571,6 @@ referencedClasses: []
 smalltalk.ChunkExporter);
 
 smalltalk.addMethod(
-"_exportMethodsOf_on_",
 smalltalk.method({
 selector: "exportMethodsOf:on:",
 category: 'not yet classified',
@@ -629,7 +607,6 @@ referencedClasses: ["Dictionary"]
 smalltalk.ChunkExporter);
 
 smalltalk.addMethod(
-"_exportPackageDefinitionOf_on_",
 smalltalk.method({
 selector: "exportPackageDefinitionOf:on:",
 category: 'not yet classified',
@@ -649,7 +626,6 @@ referencedClasses: []
 smalltalk.ChunkExporter);
 
 smalltalk.addMethod(
-"_exportPackageExtensionsOf_on_",
 smalltalk.method({
 selector: "exportPackageExtensionsOf:on:",
 category: 'not yet classified',
@@ -699,7 +675,6 @@ smalltalk.ChunkExporter);
 
 smalltalk.addClass('StrippedExporter', smalltalk.Exporter, [], 'Importer-Exporter');
 smalltalk.addMethod(
-"_exportDefinitionOf_on_",
 smalltalk.method({
 selector: "exportDefinitionOf:on:",
 category: 'private',
@@ -733,19 +708,16 @@ referencedClasses: []
 smalltalk.StrippedExporter);
 
 smalltalk.addMethod(
-"_exportMethod_of_on_",
 smalltalk.method({
 selector: "exportMethod:of:on:",
 category: 'private',
-fn: function (aMethod, aClass, aStream) {
+fn: function (aMethod,aClass,aStream){
 var self=this;
 return smalltalk.withContext(function($ctx1) { 
 var $1,$2;
 $1=aStream;
 _st($1)._nextPutAll_("smalltalk.addMethod(");
 _st($1)._lf();
-_st($1)._nextPutAll_(_st(_st(_st(_st(aMethod)._selector())._asSelector())._asJavascript()).__comma(","));
-_st($1)._lf();
 _st($1)._nextPutAll_("smalltalk.method({");
 _st($1)._lf();
 _st($1)._nextPutAll_(_st(_st("selector: ").__comma(_st(_st(aMethod)._selector())._asJavascript())).__comma(","));
@@ -759,10 +731,10 @@ _st($1)._nextPutAll_(_st("smalltalk.").__comma(_st(self)._classNameFor_(aClass))
 _st($1)._nextPutAll_(");");
 _st($1)._lf();
 $2=_st($1)._lf();
-return self}, function($ctx1) {$ctx1.fill(self,"exportMethod:of:on:",{aMethod:aMethod,aClass:aClass,aStream:aStream},smalltalk.StrippedExporter)});},
+return self}, function($ctx1) {$ctx1.fill(self,"exportMethod:of:on:",{aMethod:aMethod,aClass:aClass,aStream:aStream},smalltalk.StrippedExporter)})},
 args: ["aMethod", "aClass", "aStream"],
-source: "exportMethod: aMethod of: aClass on: aStream\x0a\x09aStream\x0a\x09\x09nextPutAll: 'smalltalk.addMethod(';lf;\x0a\x09\x09nextPutAll: aMethod selector asSelector asJavascript, ',';lf;\x0a\x09\x09nextPutAll: 'smalltalk.method({';lf;\x0a\x09\x09nextPutAll: 'selector: ', aMethod selector asJavascript, ',';lf;\x0a\x09\x09nextPutAll: 'fn: ', aMethod fn compiledSource, ',';lf;\x0a\x09\x09nextPutAll: 'messageSends: ', aMethod messageSends asJavascript;\x0a\x09\x09nextPutAll: '}),';lf;\x0a\x09\x09nextPutAll: 'smalltalk.', (self classNameFor: aClass);\x0a\x09\x09nextPutAll: ');';lf;lf",
-messageSends: ["nextPutAll:", "lf", ",", "asJavascript", "asSelector", "selector", "compiledSource", "fn", "messageSends", "classNameFor:"],
+source: "exportMethod: aMethod of: aClass on: aStream\x0a\x09aStream\x0a\x09\x09nextPutAll: 'smalltalk.addMethod(';lf;\x0a\x09\x09\x22nextPutAll: aMethod selector asSelector asJavascript, ',';lf;\x22\x0a\x09\x09nextPutAll: 'smalltalk.method({';lf;\x0a\x09\x09nextPutAll: 'selector: ', aMethod selector asJavascript, ',';lf;\x0a\x09\x09nextPutAll: 'fn: ', aMethod fn compiledSource, ',';lf;\x0a\x09\x09nextPutAll: 'messageSends: ', aMethod messageSends asJavascript;\x0a\x09\x09nextPutAll: '}),';lf;\x0a\x09\x09nextPutAll: 'smalltalk.', (self classNameFor: aClass);\x0a\x09\x09nextPutAll: ');';lf;lf",
+messageSends: ["nextPutAll:", "lf", ",", "asJavascript", "selector", "compiledSource", "fn", "messageSends", "classNameFor:"],
 referencedClasses: []
 }),
 smalltalk.StrippedExporter);
@@ -771,7 +743,6 @@ smalltalk.StrippedExporter);
 
 smalltalk.addClass('Importer', smalltalk.Object, [], 'Importer-Exporter');
 smalltalk.addMethod(
-"_import_",
 smalltalk.method({
 selector: "import:",
 category: 'fileIn',
@@ -818,7 +789,6 @@ smalltalk.Importer);
 
 smalltalk.addClass('PackageHandler', smalltalk.Object, [], 'Importer-Exporter');
 smalltalk.addMethod(
-"_ajaxPutAt_data_",
 smalltalk.method({
 selector: "ajaxPutAt:data:",
 category: 'private',
@@ -838,7 +808,6 @@ referencedClasses: []
 smalltalk.PackageHandler);
 
 smalltalk.addMethod(
-"_commit_",
 smalltalk.method({
 selector: "commit:",
 category: 'committing',
@@ -864,7 +833,6 @@ referencedClasses: ["Exporter", "StrippedExporter", "ChunkExporter"]
 smalltalk.PackageHandler);
 
 smalltalk.addMethod(
-"_loadPackage_prefix_",
 smalltalk.method({
 selector: "loadPackage:prefix:",
 category: 'loading',
@@ -893,7 +861,6 @@ referencedClasses: []
 smalltalk.PackageHandler);
 
 smalltalk.addMethod(
-"_loadPackages_prefix_",
 smalltalk.method({
 selector: "loadPackages:prefix:",
 category: 'loading',
@@ -913,7 +880,6 @@ referencedClasses: []
 smalltalk.PackageHandler);
 
 smalltalk.addMethod(
-"_setupPackageNamed_prefix_",
 smalltalk.method({
 selector: "setupPackageNamed:prefix:",
 category: 'private',
@@ -936,7 +902,6 @@ smalltalk.PackageHandler);
 
 
 smalltalk.addMethod(
-"_loadPackages_prefix_",
 smalltalk.method({
 selector: "loadPackages:prefix:",
 category: 'not yet classified',
@@ -956,7 +921,6 @@ smalltalk.PackageHandler.klass);
 
 
 smalltalk.addMethod(
-"_commit",
 smalltalk.method({
 selector: "commit",
 category: '*Importer-Exporter',

+ 1 - 1
js/Kernel-Classes.deploy.js

@@ -147,7 +147,7 @@ selector: "basicAddCompiledMethod:",
 fn: function (aMethod){
 var self=this;
 return smalltalk.withContext(function($ctx1) { 
-smalltalk.addMethod(aMethod.selector._asSelector(), aMethod, self);
+smalltalk.addMethod(aMethod, self);
 return self}, function($ctx1) {$ctx1.fill(self,"basicAddCompiledMethod:",{aMethod:aMethod},smalltalk.Behavior)})},
 messageSends: []}),
 smalltalk.Behavior);

+ 2 - 2
js/Kernel-Classes.js

@@ -179,10 +179,10 @@ category: 'private',
 fn: function (aMethod){
 var self=this;
 return smalltalk.withContext(function($ctx1) { 
-smalltalk.addMethod(aMethod.selector._asSelector(), aMethod, self);
+smalltalk.addMethod(aMethod, self);
 return self}, function($ctx1) {$ctx1.fill(self,"basicAddCompiledMethod:",{aMethod:aMethod},smalltalk.Behavior)})},
 args: ["aMethod"],
-source: "basicAddCompiledMethod: aMethod\x0a\x09<smalltalk.addMethod(aMethod.selector._asSelector(), aMethod, self)>",
+source: "basicAddCompiledMethod: aMethod\x0a\x09<smalltalk.addMethod(aMethod, self)>",
 messageSends: [],
 referencedClasses: []
 }),

+ 1 - 1
js/Kernel-Objects.deploy.js

@@ -1706,7 +1706,7 @@ $1=_st(self)._forwardMessage_withArguments_(jsSelector,_st(aMessage)._arguments(
 };
 return $1;
 }, function($ctx1) {$ctx1.fill(self,"doesNotUnderstand:",{aMessage:aMessage},smalltalk.JSObjectProxy)})},
-messageSends: ["ifNotNil:ifNil:", "forwardMessage:withArguments:", "arguments", "doesNotUnderstand:", "lookupProperty:", "asJavaScriptSelector", "selector"]}),
+messageSends: ["ifNil:ifNotNil:", "doesNotUnderstand:", "forwardMessage:withArguments:", "arguments", "lookupProperty:", "asJavaScriptSelector", "selector"]}),
 smalltalk.JSObjectProxy);
 
 smalltalk.addMethod(

+ 3 - 3
js/Kernel-Objects.js

@@ -2332,8 +2332,8 @@ $1=_st(self)._forwardMessage_withArguments_(jsSelector,_st(aMessage)._arguments(
 return $1;
 }, function($ctx1) {$ctx1.fill(self,"doesNotUnderstand:",{aMessage:aMessage},smalltalk.JSObjectProxy)})},
 args: ["aMessage"],
-source: "doesNotUnderstand: aMessage\x0a\x09^(self lookupProperty: aMessage selector asJavaScriptSelector)\x0a\x09\x09ifNotNil: [ :jsSelector | self forwardMessage: jsSelector withArguments: aMessage arguments ]\x0a\x09\x09ifNil: [ super doesNotUnderstand: aMessage ]",
-messageSends: ["ifNotNil:ifNil:", "forwardMessage:withArguments:", "arguments", "doesNotUnderstand:", "lookupProperty:", "asJavaScriptSelector", "selector"],
+source: "doesNotUnderstand: aMessage\x0a\x09^ (self lookupProperty: aMessage selector asJavaScriptSelector)\x0a\x09\x09ifNil: [ super doesNotUnderstand: aMessage ]\x0a\x09\x09ifNotNil: [ :jsSelector | \x0a\x09\x09\x09self \x0a\x09\x09\x09\x09forwardMessage: jsSelector \x0a\x09\x09\x09\x09withArguments: aMessage arguments ]",
+messageSends: ["ifNil:ifNotNil:", "doesNotUnderstand:", "forwardMessage:withArguments:", "arguments", "lookupProperty:", "asJavaScriptSelector", "selector"],
 referencedClasses: []
 }),
 smalltalk.JSObjectProxy);
@@ -2449,7 +2449,7 @@ return smalltalk.withContext(function($ctx1) {
 return aString in self._jsObject() ? aString : nil;
 return self}, function($ctx1) {$ctx1.fill(self,"lookupProperty:",{aString:aString},smalltalk.JSObjectProxy)})},
 args: ["aString"],
-source: "lookupProperty: aString\x0a\x09\x22Looks up a property in JS object.\x0a\x09Return the property if it is present, or nil if it is not present.\x22\x0a\x09<return aString in self._jsObject() ? aString : nil>",
+source: "lookupProperty: aString\x0a\x09\x22Looks up a property in JS object.\x0a\x09Answer the property if it is present, or nil if it is not present.\x22\x0a\x09\x0a\x09<return aString in self._jsObject() ? aString : nil>",
 messageSends: [],
 referencedClasses: []
 }),

+ 19 - 2
js/boot.js

@@ -472,8 +472,25 @@ function Smalltalk() {
      * Add/remove a method to/from a class 
      */
 
-	st.addMethod = function(jsSelector, method, klass) {
-		method.jsSelector = jsSelector;
+	st.addMethod = function(method_exJsSelector, klass_exMethod, exKlass) {
+        if (typeof method_exJsSelector === "string") { //legacy
+            if (method_exJsSelector !== st.selector(klass_exMethod.selector)) {
+                console.log("DISCREPANCY: arg, in_method");
+                console.log(method_exJsSelector);
+                console.log(st.selector(klass_exMethod.selector));
+                klass_exMethod.jsSelector = method_exJsSelector;
+            }
+            return new_addMethod(klass_exMethod, exKlass);
+        }
+
+        return new_addMethod(method_exJsSelector, klass_exMethod);
+    }
+
+    // later, st.addMethod can be this:
+    function new_addMethod(method, klass) {
+        if (!(method.jsSelector)) {
+            method.jsSelector = st.selector(method.selector);
+        }
 		installMethod(method, klass);
 		klass.methods[method.selector] = method;
 		method.methodClass = klass;

+ 30 - 5
st/Compiler-Interpreter.st

@@ -19,7 +19,9 @@ localAt: aString put: anObject
 !
 
 locals
-	^ locals ifNil: [ locals := Dictionary new ]
+	locals ifNil: [ self initializeLocals ].
+	
+	^ locals
 !
 
 method
@@ -55,7 +57,7 @@ receiver: anObject
 !
 
 selector
-	^ self metod
+	^ self method
 		ifNotNil: [ self method selector ]
 ! !
 
@@ -69,6 +71,11 @@ initializeFromMethodContext: aMethodContext
 		self outerContext: (self class fromMethodContext: aMethodContext outerContext) ].
 	aMethodContext locals keysAndValuesDo: [ :key :value |
 		self locals at: key put: value ]
+!
+
+initializeLocals
+	locals := Dictionary new.
+	locals at: 'thisContext' put: self.
 ! !
 
 !AIContext class methodsFor: 'instance creation'!
@@ -254,11 +261,11 @@ interpretAssignmentNode: aNode continue: aBlock
 !
 
 interpretBlockNode: aNode continue: aBlock
-	"TODO: Context should be set"
-	
 	self
 		continue: aBlock
-		value: [ self interpret: aNode nodes first; result ]
+		value: [ 
+			self withBlockContext: [ 
+				self interpret: aNode nodes first; result ] ]
 !
 
 interpretBlockSequenceNode: aNode continue: aBlock
@@ -411,6 +418,24 @@ messageFromSendNode: aSendNode arguments: aCollection do: aBlock
 			selector: aSendNode selector;
 			arguments: aCollection;
 			yourself)
+!
+
+withBlockContext: aBlock
+	"Evaluate aBlock with a BlockContext:
+	- a context is pushed before aBlock evaluation.
+	- the context is poped after aBlock evaluation
+	- the result of aBlock evaluation is answered"
+	
+	| blockResult |
+			
+	self context: (AIContext new
+		outerContext: self context;
+		yourself).
+	
+	blockResult := aBlock value.
+	
+	self context: self context outerContext.
+	^ blockResult
 ! !
 
 !ASTInterpreter methodsFor: 'testing'!

+ 6 - 0
st/Compiler-Tests.st

@@ -133,6 +133,12 @@ testReceiver
 
 testTempAssignment
 	self assert: (self interpret: 'foo | a | a := 2. ^ a') equals: 2
+!
+
+testThisContext
+	self assert: (self interpret: 'foo ^ thisContext') outerContext isNil.
+	self assert: (self interpret: 'foo ^ [ thisContext ] value') outerContext notNil.
+	self assert: (self interpret: 'foo ^ [ thisContext ] value outerContext == thisContext')
 ! !
 
 AbstractASTInterpreterTest subclass: #ASTSteppingInterpreterTest

+ 2 - 2
st/Importer-Exporter.st

@@ -127,7 +127,7 @@ exportMetaDefinitionOf: aClass on: aStream
 exportMethod: aMethod of: aClass on: aStream
 	aStream
 		nextPutAll: 'smalltalk.addMethod(';lf;
-		nextPutAll: aMethod selector asSelector asJavascript, ',';lf;
+		"nextPutAll: aMethod selector asSelector asJavascript, ',';lf;"
 		nextPutAll: 'smalltalk.method({';lf;
 		nextPutAll: 'selector: ', aMethod selector asJavascript, ',';lf;
 		nextPutAll: 'category: ''', aMethod category, ''',';lf;
@@ -310,7 +310,7 @@ exportDefinitionOf: aClass on: aStream
 exportMethod: aMethod of: aClass on: aStream
 	aStream
 		nextPutAll: 'smalltalk.addMethod(';lf;
-		nextPutAll: aMethod selector asSelector asJavascript, ',';lf;
+		"nextPutAll: aMethod selector asSelector asJavascript, ',';lf;"
 		nextPutAll: 'smalltalk.method({';lf;
 		nextPutAll: 'selector: ', aMethod selector asJavascript, ',';lf;
 		nextPutAll: 'fn: ', aMethod fn compiledSource, ',';lf;

+ 1 - 1
st/Kernel-Classes.st

@@ -267,7 +267,7 @@ new
 !Behavior methodsFor: 'private'!
 
 basicAddCompiledMethod: aMethod
-	<smalltalk.addMethod(aMethod.selector._asSelector(), aMethod, self)>
+	<smalltalk.addMethod(aMethod, self)>
 !
 
 basicRemoveCompiledMethod: aMethod

+ 7 - 3
st/Kernel-Objects.st

@@ -726,7 +726,8 @@ jsObject: aJSObject
 
 lookupProperty: aString
 	"Looks up a property in JS object.
-	Return the property if it is present, or nil if it is not present."
+	Answer the property if it is present, or nil if it is not present."
+	
 	<return aString in self._jsObject() ? aString : nil>
 !
 
@@ -767,9 +768,12 @@ addObjectVariablesTo: aDictionary
 !
 
 doesNotUnderstand: aMessage
-	^(self lookupProperty: aMessage selector asJavaScriptSelector)
-		ifNotNil: [ :jsSelector | self forwardMessage: jsSelector withArguments: aMessage arguments ]
+	^ (self lookupProperty: aMessage selector asJavaScriptSelector)
 		ifNil: [ super doesNotUnderstand: aMessage ]
+		ifNotNil: [ :jsSelector | 
+			self 
+				forwardMessage: jsSelector 
+				withArguments: aMessage arguments ]
 !
 
 forwardMessage: aString withArguments: anArray

Vissa filer visades inte eftersom för många filer har ändrats