Browse Source

Merge remote-tracking branch 'upstream/master'

Laurent Laffont 13 years ago
parent
commit
22f1307716
6 changed files with 233 additions and 1134 deletions
  1. 1 1
      LICENSE
  2. 90 463
      js/Kernel.deploy.js
  3. 77 187
      js/Kernel.js
  4. 4 0
      js/amber.js
  5. 0 226
      server/FileServer.deploy.js
  6. 61 257
      st/Kernel.st

+ 1 - 1
LICENSE

@@ -1,4 +1,4 @@
-Copyright (C) 2011 by Nicolas Petton <petton.nicolas@gmail.com>
+Copyright (C) 2011 Nicolas Petton <petton.nicolas@gmail.com>
 Copyright (C) 2011 Amber contributors https://github.com/NicolasPetton/amber/contributors
 
 Parts of Amber take ideas from Clamato (http://clamato.net), written by Avi Bryant.

+ 90 - 463
js/Kernel.deploy.js

@@ -462,7 +462,7 @@ smalltalk.method({
 selector: 'basicDelete:',
 fn: function (aString){
 var self=this;
-delete self[aString];
+delete self[aString]; return aString;
 return self;}
 }),
 smalltalk.Object);
@@ -484,21 +484,7 @@ smalltalk.method({
 selector: 'asJSON',
 fn: function (){
 var self=this;
-return JSON.stringify(self._asJSONObject());
-return self;}
-}),
-smalltalk.Object);
-
-smalltalk.addMethod(
-'_asJSONObject',
-smalltalk.method({
-selector: 'asJSONObject',
-fn: function (){
-var self=this;
-var object=nil;
-object=smalltalk.send((smalltalk.Object || 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 smalltalk.send((smalltalk.JSON || JSON), "_parse_", [smalltalk.send(self, "_asJSONString", [])]);
 return self;}
 }),
 smalltalk.Object);
@@ -555,7 +541,7 @@ smalltalk.method({
 selector: 'deprecatedAPI',
 fn: function (){
 var self=this;
-smalltalk.send((typeof console == 'undefined' ? nil : console), "_warn_", [smalltalk.send(smalltalk.send(smalltalk.send((smalltalk.getThisContext()), "_home", []), "_asString", []), "__comma", [unescape("%20is%20deprecated%21")])]);
+smalltalk.send((typeof console == 'undefined' ? nil : console), "_warn_", [smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.send(smalltalk.send((smalltalk.getThisContext()), "_home", []), "_asString", []), "__comma", [unescape("%20is%20deprecated%21%20%28in%20")]), "__comma", [smalltalk.send(smalltalk.send(smalltalk.send((smalltalk.getThisContext()), "_home", []), "_home", []), "_asString", [])]), "__comma", [unescape("%29")])]);
 return self;}
 }),
 smalltalk.Object);
@@ -582,6 +568,17 @@ return self;}
 }),
 smalltalk.Object);
 
+smalltalk.addMethod(
+'_asJSONString',
+smalltalk.method({
+selector: 'asJSONString',
+fn: function (){
+var self=this;
+return smalltalk.send((smalltalk.JSON || JSON), "_stringify_", [self]);
+return self;}
+}),
+smalltalk.Object);
+
 
 smalltalk.addMethod(
 '_initialize',
@@ -1430,6 +1427,7 @@ smalltalk.method({
 selector: 'subclass:instanceVariableNames:category:',
 fn: function (aString, aString2, aString3){
 var self=this;
+smalltalk.send(self, "_deprecatedAPI", []);
 return smalltalk.send(self, "_subclass_instanceVariableNames_package_", [aString, aString2, aString3]);
 return self;}
 }),
@@ -1984,17 +1982,6 @@ return self;}
 }),
 smalltalk.Number);
 
-smalltalk.addMethod(
-'_asJSONObject',
-smalltalk.method({
-selector: 'asJSONObject',
-fn: function (){
-var self=this;
-return self;
-return self;}
-}),
-smalltalk.Number);
-
 smalltalk.addMethod(
 '_clearTimeout',
 smalltalk.method({
@@ -2508,17 +2495,6 @@ return self;}
 }),
 smalltalk.Boolean);
 
-smalltalk.addMethod(
-'_asJSONObject',
-smalltalk.method({
-selector: 'asJSONObject',
-fn: function (){
-var self=this;
-return self;
-return self;}
-}),
-smalltalk.Boolean);
-
 smalltalk.addMethod(
 '_&',
 smalltalk.method({
@@ -2932,17 +2908,6 @@ return self;}
 }),
 smalltalk.Date);
 
-smalltalk.addMethod(
-'_asJSONObject',
-smalltalk.method({
-selector: 'asJSONObject',
-fn: function (){
-var self=this;
-return self;
-return self;}
-}),
-smalltalk.Date);
-
 
 smalltalk.addMethod(
 '_new_',
@@ -3043,6 +3008,7 @@ smalltalk.method({
 selector: 'subclass:instanceVariableNames:category:',
 fn: function (aString, aString2, aString3){
 var self=this;
+smalltalk.send(self, "_deprecatedAPI", []);
 return smalltalk.send(self, "_subclass_instanceVariableNames_package_", [aString, aString2, aString3]);
 return self;}
 }),
@@ -3459,7 +3425,7 @@ smalltalk.method({
 selector: 'remove:',
 fn: function (anObject){
 var self=this;
-smalltalk.send(self, "_subclassResponsibility", []);
+return smalltalk.send(self, "_remove_ifAbsent_", [anObject, (function(){return smalltalk.send(self, "_errorNotFound", []);})]);
 return self;}
 }),
 smalltalk.Collection);
@@ -3508,6 +3474,17 @@ return self;}
 }),
 smalltalk.Collection);
 
+smalltalk.addMethod(
+'_remove_ifAbsent_',
+smalltalk.method({
+selector: 'remove:ifAbsent:',
+fn: function (anObject, aBlock){
+var self=this;
+smalltalk.send(self, "_subclassResponsibility", []);
+return self;}
+}),
+smalltalk.Collection);
+
 
 smalltalk.addMethod(
 '_streamClass',
@@ -4137,17 +4114,6 @@ return self;}
 }),
 smalltalk.String);
 
-smalltalk.addMethod(
-'_asJSONObject',
-smalltalk.method({
-selector: 'asJSONObject',
-fn: function (){
-var self=this;
-return self;
-return self;}
-}),
-smalltalk.String);
-
 smalltalk.addMethod(
 '_trimLeft_',
 smalltalk.method({
@@ -4654,17 +4620,6 @@ return self;}
 }),
 smalltalk.Array);
 
-smalltalk.addMethod(
-'_asJSONObject',
-smalltalk.method({
-selector: 'asJSONObject',
-fn: function (){
-var self=this;
-return smalltalk.send(self, "_collect_", [(function(each){return smalltalk.send(each, "_asJSONObject", []);})]);
-return self;}
-}),
-smalltalk.Array);
-
 smalltalk.addMethod(
 '_removeFrom_to_',
 smalltalk.method({
@@ -5008,7 +4963,7 @@ return self;}
 smalltalk.Association.klass);
 
 
-smalltalk.addClass('Dictionary', smalltalk.Collection, ['keys'], 'Kernel');
+smalltalk.addClass('Dictionary', smalltalk.Collection, [], 'Kernel');
 smalltalk.addMethod(
 '__eq',
 smalltalk.method({
@@ -5037,25 +4992,13 @@ return self;}
 }),
 smalltalk.Dictionary);
 
-smalltalk.addMethod(
-'_initialize',
-smalltalk.method({
-selector: 'initialize',
-fn: function (){
-var self=this;
-smalltalk.send(self, "_initialize", [], smalltalk.Collection);
-self['@keys']=[];
-return self;}
-}),
-smalltalk.Dictionary);
-
 smalltalk.addMethod(
 '_size',
 smalltalk.method({
 selector: 'size',
 fn: function (){
 var self=this;
-return smalltalk.send(self['@keys'], "_size", []);
+return smalltalk.send(smalltalk.send(self, "_keys", []), "_size", []);
 return self;}
 }),
 smalltalk.Dictionary);
@@ -5068,7 +5011,7 @@ fn: function (){
 var self=this;
 var associations=nil;
 associations=[];
-smalltalk.send(self['@keys'], "_do_", [(function(each){return smalltalk.send(associations, "_add_", [smalltalk.send((smalltalk.Association || Association), "_key_value_", [each, smalltalk.send(self, "_at_", [each])])]);})]);
+smalltalk.send(smalltalk.send(self, "_keys", []), "_do_", [(function(each){return smalltalk.send(associations, "_add_", [smalltalk.send((smalltalk.Association || Association), "_key_value_", [each, smalltalk.send(self, "_at_", [each])])]);})]);
 return associations;
 return self;}
 }),
@@ -5080,7 +5023,15 @@ smalltalk.method({
 selector: 'keys',
 fn: function (){
 var self=this;
-return smalltalk.send(self['@keys'], "_copy", []);
+
+		var keys = [];
+		for(var i in self) {
+			if(self.hasOwnProperty(i)) {
+				keys.push(i);
+			}
+		};
+		return keys;
+	;
 return self;}
 }),
 smalltalk.Dictionary);
@@ -5091,7 +5042,7 @@ smalltalk.method({
 selector: 'values',
 fn: function (){
 var self=this;
-return smalltalk.send(self['@keys'], "_collect_", [(function(each){return smalltalk.send(self, "_at_", [each]);})]);
+return smalltalk.send(smalltalk.send(self, "_keys", []), "_collect_", [(function(each){return smalltalk.send(self, "_at_", [each]);})]);
 return self;}
 }),
 smalltalk.Dictionary);
@@ -5102,7 +5053,6 @@ smalltalk.method({
 selector: 'at:put:',
 fn: function (aKey, aValue){
 var self=this;
-((($receiver = smalltalk.send(self['@keys'], "_includes_", [aKey])).klass === smalltalk.Boolean) ? (! $receiver ? (function(){return smalltalk.send(self['@keys'], "_add_", [aKey]);})() : nil) : smalltalk.send($receiver, "_ifFalse_", [(function(){return smalltalk.send(self['@keys'], "_add_", [aKey]);})]));
 return smalltalk.send(self, "_basicAt_put_", [aKey, aValue]);
 return self;}
 }),
@@ -5114,7 +5064,7 @@ smalltalk.method({
 selector: 'at:ifAbsent:',
 fn: function (aKey, aBlock){
 var self=this;
-return smalltalk.send(smalltalk.send(smalltalk.send(self, "_keys", []), "_includes_", [aKey]), "_ifTrue_ifFalse_", [(function(){return smalltalk.send(self, "_basicAt_", [aKey]);}), aBlock]);
+return smalltalk.send(smalltalk.send(self, "_includesKey_", [aKey]), "_ifTrue_ifFalse_", [(function(){return smalltalk.send(self, "_basicAt_", [aKey]);}), aBlock]);
 return self;}
 }),
 smalltalk.Dictionary);
@@ -5280,24 +5230,13 @@ return self;}
 }),
 smalltalk.Dictionary);
 
-smalltalk.addMethod(
-'_remove_',
-smalltalk.method({
-selector: 'remove:',
-fn: function (aKey){
-var self=this;
-smalltalk.send(self, "_removeKey_", [aKey]);
-return self;}
-}),
-smalltalk.Dictionary);
-
 smalltalk.addMethod(
 '_removeKey_',
 smalltalk.method({
 selector: 'removeKey:',
 fn: function (aKey){
 var self=this;
-smalltalk.send(self['@keys'], "_remove_", [aKey]);
+smalltalk.send(self, "_remove_", [aKey]);
 return self;}
 }),
 smalltalk.Dictionary);
@@ -5313,20 +5252,6 @@ return self;}
 }),
 smalltalk.Dictionary);
 
-smalltalk.addMethod(
-'_asJSONObject',
-smalltalk.method({
-selector: 'asJSONObject',
-fn: function (){
-var self=this;
-var object=nil;
-object=smalltalk.send((smalltalk.Object || Object), "_new", []);
-smalltalk.send(self, "_keysAndValuesDo_", [(function(key, value){return smalltalk.send(object, "_basicAt_put_", [key, smalltalk.send(value, "_asJSONObject", [])]);})]);
-return object;
-return self;}
-}),
-smalltalk.Dictionary);
-
 smalltalk.addMethod(
 '_printString',
 smalltalk.method({
@@ -5351,6 +5276,53 @@ return self;}
 }),
 smalltalk.Dictionary);
 
+smalltalk.addMethod(
+'_includesKey_',
+smalltalk.method({
+selector: 'includesKey:',
+fn: function (aKey){
+var self=this;
+return self.hasOwnProperty(aKey);
+return self;}
+}),
+smalltalk.Dictionary);
+
+smalltalk.addMethod(
+'_remove_ifAbsent_',
+smalltalk.method({
+selector: 'remove:ifAbsent:',
+fn: function (aKey, aBlock){
+var self=this;
+return smalltalk.send(self, "_removeKey_ifAbsent_", [aKey, aBlock]);
+return self;}
+}),
+smalltalk.Dictionary);
+
+smalltalk.addMethod(
+'_removeKey_ifAbsent_',
+smalltalk.method({
+selector: 'removeKey:ifAbsent:',
+fn: function (aKey, aBlock){
+var self=this;
+return ((($receiver = smalltalk.send(self, "_includesKey_", [aKey])).klass === smalltalk.Boolean) ? (! $receiver ? (function(){return smalltalk.send(aBlock, "_value", []);})() : (function(){return smalltalk.send(self, "_basicDelete_", [aKey]);})()) : smalltalk.send($receiver, "_ifFalse_ifTrue_", [(function(){return smalltalk.send(aBlock, "_value", []);}), (function(){return smalltalk.send(self, "_basicDelete_", [aKey]);})]));
+return self;}
+}),
+smalltalk.Dictionary);
+
+smalltalk.addMethod(
+'_deepCopy',
+smalltalk.method({
+selector: 'deepCopy',
+fn: function (){
+var self=this;
+var copy=nil;
+copy=smalltalk.send(smalltalk.send(self, "_class", []), "_new", []);
+smalltalk.send(self, "_associationsDo_", [(function(each){return smalltalk.send(copy, "_at_put_", [smalltalk.send(each, "_key", []), smalltalk.send(smalltalk.send(each, "_value", []), "_deepCopy", [])]);})]);
+return copy;
+return self;}
+}),
+smalltalk.Dictionary);
+
 
 smalltalk.addMethod(
 '_fromPairs_',
@@ -6674,348 +6646,3 @@ return self;}
 smalltalk.ConsoleTranscript.klass);
 
 
-smalltalk.addClass('Dictionary2', smalltalk.Dictionary, ['keys'], 'Kernel');
-smalltalk.addMethod(
-'__eq',
-smalltalk.method({
-selector: '=',
-fn: function (aDictionary){
-var self=this;
-try{((($receiver = smalltalk.send(smalltalk.send(self, "_class", []), "__eq", [smalltalk.send(aDictionary, "_class", [])])).klass === smalltalk.Boolean) ? (! $receiver ? (function(){return (function(){throw({name: 'stReturn', selector: '__eq', fn: function(){return false}})})();})() : nil) : smalltalk.send($receiver, "_ifFalse_", [(function(){return (function(){throw({name: 'stReturn', selector: '__eq', fn: function(){return false}})})();})]));
-((($receiver = smalltalk.send(smalltalk.send(self, "_size", []), "__eq", [smalltalk.send(aDictionary, "_size", [])])).klass === smalltalk.Boolean) ? (! $receiver ? (function(){return (function(){throw({name: 'stReturn', selector: '__eq', fn: function(){return false}})})();})() : nil) : smalltalk.send($receiver, "_ifFalse_", [(function(){return (function(){throw({name: 'stReturn', selector: '__eq', fn: function(){return false}})})();})]));
-(function(){throw({name: 'stReturn', selector: '__eq', fn: function(){return smalltalk.send(smalltalk.send(self, "_associations", []), "__eq", [smalltalk.send(aDictionary, "_associations", [])])}})})();
-return self;
-} catch(e) {if(e.name === 'stReturn' && e.selector === '__eq'){return e.fn()} throw(e)}}
-}),
-smalltalk.Dictionary2);
-
-smalltalk.addMethod(
-'_shallowCopy',
-smalltalk.method({
-selector: 'shallowCopy',
-fn: function (){
-var self=this;
-var copy=nil;
-copy=smalltalk.send(smalltalk.send(self, "_class", []), "_new", []);
-smalltalk.send(self, "_associationsDo_", [(function(each){return smalltalk.send(copy, "_at_put_", [smalltalk.send(each, "_key", []), smalltalk.send(each, "_value", [])]);})]);
-return copy;
-return self;}
-}),
-smalltalk.Dictionary2);
-
-smalltalk.addMethod(
-'_initialize',
-smalltalk.method({
-selector: 'initialize',
-fn: function (){
-var self=this;
-smalltalk.send(self, "_initialize", [], smalltalk.Dictionary);
-self['@keys']=[];
-return self;}
-}),
-smalltalk.Dictionary2);
-
-smalltalk.addMethod(
-'_size',
-smalltalk.method({
-selector: 'size',
-fn: function (){
-var self=this;
-return smalltalk.send(self['@keys'], "_size", []);
-return self;}
-}),
-smalltalk.Dictionary2);
-
-smalltalk.addMethod(
-'_associations',
-smalltalk.method({
-selector: 'associations',
-fn: function (){
-var self=this;
-var associations=nil;
-associations=[];
-smalltalk.send(self['@keys'], "_do_", [(function(each){return smalltalk.send(associations, "_add_", [smalltalk.send((smalltalk.Association || Association), "_key_value_", [each, smalltalk.send(self, "_at_", [each])])]);})]);
-return associations;
-return self;}
-}),
-smalltalk.Dictionary2);
-
-smalltalk.addMethod(
-'_keys',
-smalltalk.method({
-selector: 'keys',
-fn: function (){
-var self=this;
-return smalltalk.send(self['@keys'], "_copy", []);
-return self;}
-}),
-smalltalk.Dictionary2);
-
-smalltalk.addMethod(
-'_values',
-smalltalk.method({
-selector: 'values',
-fn: function (){
-var self=this;
-return smalltalk.send(self['@keys'], "_collect_", [(function(each){return smalltalk.send(self, "_at_", [each]);})]);
-return self;}
-}),
-smalltalk.Dictionary2);
-
-smalltalk.addMethod(
-'_at_put_',
-smalltalk.method({
-selector: 'at:put:',
-fn: function (aKey, aValue){
-var self=this;
-((($receiver = smalltalk.send(self['@keys'], "_includes_", [aKey])).klass === smalltalk.Boolean) ? (! $receiver ? (function(){return smalltalk.send(self['@keys'], "_add_", [aKey]);})() : nil) : smalltalk.send($receiver, "_ifFalse_", [(function(){return smalltalk.send(self['@keys'], "_add_", [aKey]);})]));
-return smalltalk.send(self, "_basicAt_put_", [aKey, aValue]);
-return self;}
-}),
-smalltalk.Dictionary2);
-
-smalltalk.addMethod(
-'_at_ifAbsent_',
-smalltalk.method({
-selector: 'at:ifAbsent:',
-fn: function (aKey, aBlock){
-var self=this;
-return smalltalk.send(smalltalk.send(smalltalk.send(self, "_keys", []), "_includes_", [aKey]), "_ifTrue_ifFalse_", [(function(){return smalltalk.send(self, "_basicAt_", [aKey]);}), aBlock]);
-return self;}
-}),
-smalltalk.Dictionary2);
-
-smalltalk.addMethod(
-'_at_ifAbsentPut_',
-smalltalk.method({
-selector: 'at:ifAbsentPut:',
-fn: function (aKey, aBlock){
-var self=this;
-return smalltalk.send(self, "_at_ifAbsent_", [aKey, (function(){return smalltalk.send(self, "_at_put_", [aKey, smalltalk.send(aBlock, "_value", [])]);})]);
-return self;}
-}),
-smalltalk.Dictionary2);
-
-smalltalk.addMethod(
-'_at_ifPresent_',
-smalltalk.method({
-selector: 'at:ifPresent:',
-fn: function (aKey, aBlock){
-var self=this;
-return (($receiver = smalltalk.send(self, "_basicAt_", [aKey])) != nil && $receiver != undefined) ? (function(){return smalltalk.send(aBlock, "_value_", [smalltalk.send(self, "_at_", [aKey])]);})() : nil;
-return self;}
-}),
-smalltalk.Dictionary2);
-
-smalltalk.addMethod(
-'_at_ifPresent_ifAbsent_',
-smalltalk.method({
-selector: 'at:ifPresent:ifAbsent:',
-fn: function (aKey, aBlock, anotherBlock){
-var self=this;
-return smalltalk.send(smalltalk.send(self, "_basicAt_", [aKey]), "_ifNil_ifNotNil_", [anotherBlock, (function(){return smalltalk.send(aBlock, "_value_", [smalltalk.send(self, "_at_", [aKey])]);})]);
-return self;}
-}),
-smalltalk.Dictionary2);
-
-smalltalk.addMethod(
-'_add_',
-smalltalk.method({
-selector: 'add:',
-fn: function (anAssociation){
-var self=this;
-smalltalk.send(self, "_at_put_", [smalltalk.send(anAssociation, "_key", []), smalltalk.send(anAssociation, "_value", [])]);
-return self;}
-}),
-smalltalk.Dictionary2);
-
-smalltalk.addMethod(
-'_addAll_',
-smalltalk.method({
-selector: 'addAll:',
-fn: function (aDictionary){
-var self=this;
-smalltalk.send(self, "_addAll_", [smalltalk.send(aDictionary, "_associations", [])], smalltalk.Dictionary);
-return aDictionary;
-return self;}
-}),
-smalltalk.Dictionary2);
-
-smalltalk.addMethod(
-'__comma',
-smalltalk.method({
-selector: ',',
-fn: function (aCollection){
-var self=this;
-smalltalk.send(self, "_shouldNotImplement", []);
-return self;}
-}),
-smalltalk.Dictionary2);
-
-smalltalk.addMethod(
-'_copyFrom_to_',
-smalltalk.method({
-selector: 'copyFrom:to:',
-fn: function (anIndex, anotherIndex){
-var self=this;
-smalltalk.send(self, "_shouldNotImplement", []);
-return self;}
-}),
-smalltalk.Dictionary2);
-
-smalltalk.addMethod(
-'_associationsDo_',
-smalltalk.method({
-selector: 'associationsDo:',
-fn: function (aBlock){
-var self=this;
-smalltalk.send(smalltalk.send(self, "_associations", []), "_do_", [aBlock]);
-return self;}
-}),
-smalltalk.Dictionary2);
-
-smalltalk.addMethod(
-'_keysAndValuesDo_',
-smalltalk.method({
-selector: 'keysAndValuesDo:',
-fn: function (aBlock){
-var self=this;
-smalltalk.send(self, "_associationsDo_", [(function(each){return smalltalk.send(aBlock, "_value_value_", [smalltalk.send(each, "_key", []), smalltalk.send(each, "_value", [])]);})]);
-return self;}
-}),
-smalltalk.Dictionary2);
-
-smalltalk.addMethod(
-'_do_',
-smalltalk.method({
-selector: 'do:',
-fn: function (aBlock){
-var self=this;
-smalltalk.send(smalltalk.send(self, "_values", []), "_do_", [aBlock]);
-return self;}
-}),
-smalltalk.Dictionary2);
-
-smalltalk.addMethod(
-'_select_',
-smalltalk.method({
-selector: 'select:',
-fn: function (aBlock){
-var self=this;
-var newDict=nil;
-newDict=smalltalk.send(smalltalk.send(self, "_class", []), "_new", []);
-smalltalk.send(self, "_keysAndValuesDo_", [(function(key, value){return ((($receiver = smalltalk.send(aBlock, "_value_", [value])).klass === smalltalk.Boolean) ? ($receiver ? (function(){return smalltalk.send(newDict, "_at_put_", [key, value]);})() : nil) : smalltalk.send($receiver, "_ifTrue_", [(function(){return smalltalk.send(newDict, "_at_put_", [key, value]);})]));})]);
-return newDict;
-return self;}
-}),
-smalltalk.Dictionary2);
-
-smalltalk.addMethod(
-'_collect_',
-smalltalk.method({
-selector: 'collect:',
-fn: function (aBlock){
-var self=this;
-var newDict=nil;
-newDict=smalltalk.send(smalltalk.send(self, "_class", []), "_new", []);
-smalltalk.send(self, "_keysAndValuesDo_", [(function(key, value){return smalltalk.send(newDict, "_at_put_", [key, smalltalk.send(aBlock, "_value_", [value])]);})]);
-return newDict;
-return self;}
-}),
-smalltalk.Dictionary2);
-
-smalltalk.addMethod(
-'_detect_ifNone_',
-smalltalk.method({
-selector: 'detect:ifNone:',
-fn: function (aBlock, anotherBlock){
-var self=this;
-return smalltalk.send(smalltalk.send(self, "_values", []), "_detect_ifNone_", [aBlock, anotherBlock]);
-return self;}
-}),
-smalltalk.Dictionary2);
-
-smalltalk.addMethod(
-'_includes_',
-smalltalk.method({
-selector: 'includes:',
-fn: function (anObject){
-var self=this;
-return smalltalk.send(smalltalk.send(self, "_values", []), "_includes_", [anObject]);
-return self;}
-}),
-smalltalk.Dictionary2);
-
-smalltalk.addMethod(
-'_remove_',
-smalltalk.method({
-selector: 'remove:',
-fn: function (aKey){
-var self=this;
-smalltalk.send(self, "_removeKey_", [aKey]);
-return self;}
-}),
-smalltalk.Dictionary2);
-
-smalltalk.addMethod(
-'_removeKey_',
-smalltalk.method({
-selector: 'removeKey:',
-fn: function (aKey){
-var self=this;
-smalltalk.send(self['@keys'], "_remove_", [aKey]);
-return self;}
-}),
-smalltalk.Dictionary2);
-
-smalltalk.addMethod(
-'_at_',
-smalltalk.method({
-selector: 'at:',
-fn: function (aKey){
-var self=this;
-return smalltalk.send(self, "_at_ifAbsent_", [aKey, (function(){return smalltalk.send(self, "_errorNotFound", []);})]);
-return self;}
-}),
-smalltalk.Dictionary2);
-
-smalltalk.addMethod(
-'_asJSONObject',
-smalltalk.method({
-selector: 'asJSONObject',
-fn: function (){
-var self=this;
-var object=nil;
-object=smalltalk.send((smalltalk.Object || Object), "_new", []);
-smalltalk.send(self, "_keysAndValuesDo_", [(function(key, value){return smalltalk.send(object, "_basicAt_put_", [key, smalltalk.send(value, "_asJSONObject", [])]);})]);
-return object;
-return self;}
-}),
-smalltalk.Dictionary2);
-
-smalltalk.addMethod(
-'_printString',
-smalltalk.method({
-selector: 'printString',
-fn: function (){
-var self=this;
-return smalltalk.send((smalltalk.String || String), "_streamContents_", [(function(aStream){(function($rec){smalltalk.send($rec, "_nextPutAll_", [smalltalk.send(self, "_printString", [], smalltalk.Dictionary)]);return smalltalk.send($rec, "_nextPutAll_", [unescape("%28")]);})(aStream);smalltalk.send(smalltalk.send(self, "_associations", []), "_do_separatedBy_", [(function(anAssociation){return (function($rec){smalltalk.send($rec, "_nextPutAll_", [smalltalk.send(smalltalk.send(anAssociation, "_key", []), "_printString", [])]);smalltalk.send($rec, "_nextPutAll_", [unescape("%20-%3E%20")]);return smalltalk.send($rec, "_nextPutAll_", [smalltalk.send(smalltalk.send(anAssociation, "_value", []), "_printString", [])]);})(aStream);}), (function(){return smalltalk.send(aStream, "_nextPutAll_", [unescape("%20%2C%20")]);})]);return smalltalk.send(aStream, "_nextPutAll_", [unescape("%29")]);})]);
-return self;}
-}),
-smalltalk.Dictionary2);
-
-smalltalk.addMethod(
-'_storeOn_',
-smalltalk.method({
-selector: 'storeOn:',
-fn: function (aStream){
-var self=this;
-smalltalk.send(aStream, "_nextPutAll_", [unescape("%23%7B")]);
-smalltalk.send(smalltalk.send(self, "_associations", []), "_do_separatedBy_", [(function(each){return smalltalk.send(each, "_storeOn_", [aStream]);}), (function(){return smalltalk.send(aStream, "_nextPutAll_", [". "]);})]);
-smalltalk.send(aStream, "_nextPutAll_", [unescape("%7D")]);
-return self;}
-}),
-smalltalk.Dictionary2);
-
-
-

File diff suppressed because it is too large
+ 77 - 187
js/Kernel.js


+ 4 - 0
js/amber.js

@@ -30,6 +30,10 @@ amber = (function() {
 		deploy = spec.deploy || false;
 		debug = spec.debug || false;
 
+    // Allow loading default Amber files from a different location
+    // e.g. http://amber-lang.net/amber/
+    if (spec.home) home = spec.home;
+
 		// Specify a version string to avoid wrong browser caching
 		if (spec.version) {
 			nocache = '?' + spec.version;

File diff suppressed because it is too large
+ 0 - 226
server/FileServer.deploy.js


+ 61 - 257
st/Kernel.st

@@ -34,7 +34,7 @@ basicAt: aString put: anObject
 !
 
 basicDelete: aString
-    <delete self[aString]>
+    <delete self[aString]; return aString>
 ! !
 
 !Object methodsFor: 'comparing'!
@@ -70,15 +70,11 @@ asJavascript
 !
 
 asJSON
-	<return JSON.stringify(self._asJSONObject())>
+	^JSON parse: self asJSONString
 !
 
-asJSONObject
-	| object |
-	object := Object new.
-	self class instanceVariableNames do: [:each |
-		object basicAt: each put: (self instVarAt: each) asJSONObject].
-	^object
+asJSONString
+	^JSON stringify: self
 ! !
 
 !Object methodsFor: 'copying'!
@@ -147,7 +143,7 @@ deprecatedAPI
 	"Just a simple way to deprecate methods.
 	#deprecatedAPI is in the 'error handling' protocol even if it doesn't throw an error,
 	but it could in the future."
-	console warn: thisContext home asString, ' is deprecated!!'
+	console warn: thisContext home asString, ' is deprecated!! (in ', thisContext home home asString, ')'
 ! !
 
 !Object methodsFor: 'initialization'!
@@ -731,6 +727,7 @@ subclass: aString instanceVariableNames: anotherString
 
 subclass: aString instanceVariableNames: aString2 category: aString3
 	"Kept for compatibility."
+	self deprecatedAPI.
 	^self subclass: aString instanceVariableNames: aString2 package: aString3
 !
 
@@ -973,10 +970,6 @@ asPoint
 	^Point x: self y: self
 !
 
-asJSONObject
-	^self
-!
-
 to: stop by: step
 	| array value pos |
 	value := self.
@@ -1266,12 +1259,6 @@ not
 	>
 ! !
 
-!Boolean methodsFor: 'converting'!
-
-asJSONObject
-	^self
-! !
-
 !Boolean methodsFor: 'copying'!
 
 shallowCopy
@@ -1428,10 +1415,6 @@ asLocaleString
 
 asNumber
 	^self asMilliseconds
-!
-
-asJSONObject
-	^self
 ! !
 
 !Date methodsFor: 'printing'!
@@ -1486,6 +1469,7 @@ subclass: aString instanceVariableNames: anotherString
 
 subclass: aString instanceVariableNames: aString2 category: aString3
 	"Kept for compatibility."
+	self deprecatedAPI.
 	^self subclass: aString instanceVariableNames: aString2 package: aString3
 !
 
@@ -1585,6 +1569,10 @@ addAll: aCollection
 !
 
 remove: anObject
+    ^self remove: anObject ifAbsent: [self errorNotFound]
+!
+
+remove: anObject ifAbsent: aBlock
     self subclassResponsibility
 ! !
 
@@ -1975,10 +1963,6 @@ asNumber
 	<return Number(self)>
 !
 
-asJSONObject
-	^self
-!
-
 asLowercase
 	<return self.toLowerCase()>
 !
@@ -2257,10 +2241,6 @@ asJavascript
 	^'[', ((self collect: [:each | each asJavascript]) join: ', '),  ']'
 !
 
-asJSONObject
-	^self collect: [:each | each asJSONObject]
-!
-
 reversed
 	<return self._copy().reverse()>
 ! !
@@ -2476,38 +2456,45 @@ key: aKey value: aValue
 ! !
 
 Collection subclass: #Dictionary
-	instanceVariableNames: 'keys'
+	instanceVariableNames: ''
 	category: 'Kernel'!
 
 !Dictionary methodsFor: 'accessing'!
 
 size
-	^keys size
+	^self keys size
 !
 
 associations
 	| associations |
 	associations := #().
-	keys do: [:each |
+	self keys do: [:each |
 	    associations add: (Association key: each value: (self at: each))].
 	^associations
 !
 
 keys
-	^keys copy
+	<
+		var keys = [];
+		for(var i in self) {
+			if(self.hasOwnProperty(i)) {
+				keys.push(i);
+			}
+		};
+		return keys;
+	>
 !
 
 values
-    	^keys collect: [:each | self at: each]
+    	^self keys collect: [:each | self at: each]
 !
 
 at: aKey put: aValue
-	(keys includes: aKey) ifFalse: [keys add: aKey].
 	^self basicAt: aKey put: aValue
 !
 
 at: aKey ifAbsent: aBlock
-	^(self keys includes: aKey)
+	^(self includesKey: aKey)
 		ifTrue: [self basicAt: aKey]
 		ifFalse: aBlock
 !
@@ -2542,12 +2529,18 @@ addAll: aDictionary
     	^aDictionary
 !
 
-remove: aKey
-    self removeKey: aKey
+removeKey: aKey
+    self remove: aKey
 !
 
-removeKey: aKey
-    keys remove: aKey
+remove: aKey ifAbsent: aBlock
+    ^self removeKey: aKey ifAbsent: aBlock
+!
+
+removeKey: aKey ifAbsent: aBlock
+	^(self includesKey: aKey) 
+		ifFalse: [aBlock value]
+		ifTrue: [self basicDelete: aKey]
 ! !
 
 !Dictionary methodsFor: 'comparing'!
@@ -2558,16 +2551,6 @@ removeKey: aKey
 	^self associations = aDictionary associations
 ! !
 
-!Dictionary methodsFor: 'converting'!
-
-asJSONObject
-	| object |
-	object := Object new.
-	self keysAndValuesDo: [:key :value |
-		object basicAt: key put: value asJSONObject].
-	^object
-! !
-
 !Dictionary methodsFor: 'copying'!
 
 shallowCopy
@@ -2584,6 +2567,14 @@ shallowCopy
 
 copyFrom: anIndex to: anotherIndex
 	self shouldNotImplement
+!
+
+deepCopy
+	| copy |
+	copy := self class new.
+	self associationsDo: [:each |
+	    copy at: each key  put: each value deepCopy].
+	^copy
 ! !
 
 !Dictionary methodsFor: 'enumerating'!
@@ -2625,30 +2616,21 @@ includes: anObject
 	^self values includes: anObject
 ! !
 
-!Dictionary methodsFor: 'initialization'!
-
-initialize
-    	super initialize.
-    	keys := #()
-! !
-
 !Dictionary methodsFor: 'printing'!
 
 printString
-	^ String streamContents: [:aStream|  
-                                  		aStream 
-                                  			nextPutAll: super printString;
-                                  			nextPutAll: '('.
-                                  		self associations 
-                                  			do: [:anAssociation|  
-                                                                      	aStream 
-                                                                      		nextPutAll: anAssociation key printString;
-                                                                      		nextPutAll: ' -> ';
-                                                                      		nextPutAll: anAssociation value printString]
-                                  
-                                 			separatedBy: [aStream nextPutAll: ' , '].
-                                  		aStream nextPutAll: ')'.
-                                 ]
+	^String streamContents: [:aStream|  
+		aStream 
+			nextPutAll: super printString;
+			nextPutAll: '('.
+				self associations 
+					do: [:anAssociation|  
+						aStream 
+							nextPutAll: anAssociation key printString;
+								nextPutAll: ' -> ';
+								nextPutAll: anAssociation value printString]
+							separatedBy: [aStream nextPutAll: ' , '].
+						aStream nextPutAll: ')']
 !
 
 storeOn: aStream
@@ -2659,6 +2641,12 @@ storeOn: aStream
 	aStream nextPutAll: '}'
 ! !
 
+!Dictionary methodsFor: 'testing'!
+
+includesKey: aKey
+	<return self.hasOwnProperty(aKey)>
+! !
+
 !Dictionary class methodsFor: 'instance creation'!
 
 fromPairs: aCollection
@@ -3368,187 +3356,3 @@ initialize
 	Transcript register: self new
 ! !
 
-Dictionary subclass: #Dictionary2
-	instanceVariableNames: 'keys'
-	category: 'Kernel'!
-
-!Dictionary2 methodsFor: 'accessing'!
-
-size
-	^keys size
-!
-
-associations
-	| associations |
-	associations := #().
-	keys do: [:each |
-	    associations add: (Association key: each value: (self at: each))].
-	^associations
-!
-
-keys
-	^keys copy
-!
-
-values
-    	^keys collect: [:each | self at: each]
-!
-
-at: aKey put: aValue
-	(keys includes: aKey) ifFalse: [keys add: aKey].
-	^self basicAt: aKey put: aValue
-!
-
-at: aKey ifAbsent: aBlock
-	^(self keys includes: aKey)
-		ifTrue: [self basicAt: aKey]
-		ifFalse: aBlock
-!
-
-at: aKey ifAbsentPut: aBlock
-    	^self at: aKey ifAbsent: [
-    	    self at: aKey put: aBlock value]
-!
-
-at: aKey ifPresent: aBlock
-	^(self basicAt: aKey) ifNotNil: [aBlock value: (self at: aKey)]
-!
-
-at: aKey ifPresent: aBlock ifAbsent: anotherBlock
-	^(self basicAt: aKey)
-	    ifNil: anotherBlock
-	    ifNotNil: [aBlock value: (self at: aKey)]
-!
-
-at: aKey
-	^self at: aKey ifAbsent: [self errorNotFound]
-! !
-
-!Dictionary2 methodsFor: 'adding/removing'!
-
-add: anAssociation
-    	self at: anAssociation key put: anAssociation value
-!
-
-addAll: aDictionary
-    	super addAll: aDictionary associations.
-    	^aDictionary
-!
-
-remove: aKey
-    self removeKey: aKey
-!
-
-removeKey: aKey
-    keys remove: aKey
-! !
-
-!Dictionary2 methodsFor: 'comparing'!
-
-= aDictionary
-	self class = aDictionary class ifFalse: [^false].
-	self size = aDictionary size ifFalse: [^false].
-	^self associations = aDictionary associations
-! !
-
-!Dictionary2 methodsFor: 'converting'!
-
-asJSONObject
-	| object |
-	object := Object new.
-	self keysAndValuesDo: [:key :value |
-		object basicAt: key put: value asJSONObject].
-	^object
-! !
-
-!Dictionary2 methodsFor: 'copying'!
-
-shallowCopy
-	| copy |
-	copy := self class new.
-	self associationsDo: [:each |
-	    copy at: each key  put: each value].
-	^copy
-!
-
-, aCollection
-	self shouldNotImplement
-!
-
-copyFrom: anIndex to: anotherIndex
-	self shouldNotImplement
-! !
-
-!Dictionary2 methodsFor: 'enumerating'!
-
-associationsDo: aBlock
-    	self associations do: aBlock
-!
-
-keysAndValuesDo: aBlock
-    	self associationsDo: [:each |
-    	    aBlock value: each key value: each value]
-!
-
-do: aBlock
-    	self values do: aBlock
-!
-
-select: aBlock
-    	| newDict |
-    	newDict := self class new.
-    	self keysAndValuesDo: [:key :value |
-    	    (aBlock value: value) ifTrue: [newDict at: key put: value]].
-    	^newDict
-!
-
-collect: aBlock
-    	| newDict |
-    	newDict := self class new.
-    	self keysAndValuesDo: [:key :value |
-    	    newDict at: key put: (aBlock value: value)].
-    	^newDict
-!
-
-detect: aBlock ifNone: anotherBlock
-	^self values detect: aBlock ifNone: anotherBlock
-!
-
-includes: anObject
-	^self values includes: anObject
-! !
-
-!Dictionary2 methodsFor: 'initialization'!
-
-initialize
-    	super initialize.
-    	keys := #()
-! !
-
-!Dictionary2 methodsFor: 'printing'!
-
-printString
-	^ String streamContents: [:aStream|  
-                                  		aStream 
-                                  			nextPutAll: super printString;
-                                  			nextPutAll: '('.
-                                  		self associations 
-                                  			do: [:anAssociation|  
-                                                                      	aStream 
-                                                                      		nextPutAll: anAssociation key printString;
-                                                                      		nextPutAll: ' -> ';
-                                                                      		nextPutAll: anAssociation value printString]
-                                  
-                                 			separatedBy: [aStream nextPutAll: ' , '].
-                                  		aStream nextPutAll: ')'.
-                                 ]
-!
-
-storeOn: aStream
-	aStream nextPutAll: '#{'.
-	self associations
-		do: [:each | each storeOn: aStream]
-		separatedBy: [ aStream nextPutAll: '. '].
-	aStream nextPutAll: '}'
-! !
-

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